1 | /**
|
2 | * Copyright 2018 Google Inc. All Rights Reserved.
|
3 | *
|
4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | * you may not use this file except in compliance with the License.
|
6 | * You may obtain a copy of the License at
|
7 | *
|
8 | * http://www.apache.org/licenses/LICENSE-2.0
|
9 | *
|
10 | * Unless required by applicable law or agreed to in writing, software
|
11 | * distributed under the License is distributed on an "AS IS" BASIS,
|
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13 | * See the License for the specific language governing permissions and
|
14 | * limitations under the License.
|
15 | */
|
16 | import * as Api from '../api/v2';
|
17 | import { OAuth2Client } from 'google-auth-library';
|
18 | import { TokenPayload } from 'google-auth-library/build/src/auth/loginticket';
|
19 | export declare class Last {
|
20 | /**
|
21 | * Timestamp for the last access from the user.
|
22 | * Undefined if never seen.
|
23 | * @public
|
24 | */
|
25 | seen?: Date;
|
26 | /** @hidden */
|
27 | constructor(user: Api.GoogleActionsV2User);
|
28 | }
|
29 | export declare class Name {
|
30 | /**
|
31 | * User's display name.
|
32 | * @public
|
33 | */
|
34 | display?: string;
|
35 | /**
|
36 | * User's family name.
|
37 | * @public
|
38 | */
|
39 | family?: string;
|
40 | /**
|
41 | * User's given name.
|
42 | * @public
|
43 | */
|
44 | given?: string;
|
45 | /** @hidden */
|
46 | constructor(profile: Api.GoogleActionsV2UserProfile);
|
47 | }
|
48 | export declare class Access {
|
49 | /**
|
50 | * Unique Oauth2 token. Only available with account linking.
|
51 | * @public
|
52 | */
|
53 | token?: string;
|
54 | /** @hidden */
|
55 | constructor(user: Api.GoogleActionsV2User);
|
56 | }
|
57 | export declare class Profile {
|
58 | /**
|
59 | * Gets the Profile Payload object encoded in {@link Profile#token|conv.user.profile.token}.
|
60 | * Only retrievable with "Google Sign In" linking type set up for account linking in the console.
|
61 | *
|
62 | * To access just the email in the payload, you can also use {@link User#email|conv.user.email}.
|
63 | *
|
64 | * @example
|
65 | * ```javascript
|
66 | *
|
67 | * // Dialogflow
|
68 | * const app = dialogflow({
|
69 | * clientId: CLIENT_ID,
|
70 | * })
|
71 | *
|
72 | * app.intent('Default Welcome Intent', conv => {
|
73 | * conv.ask(new SignIn('To get your account details'))
|
74 | * })
|
75 | *
|
76 | * // Create a Dialogflow intent with the `actions_intent_SIGN_IN` event
|
77 | * app.intent('Get Signin', (conv, params, signin) => {
|
78 | * if (signin.status === 'OK') {
|
79 | * const payload = conv.user.profile.payload
|
80 | * conv.ask(`I got your account details. What do you want to do next?`)
|
81 | * } else {
|
82 | * conv.ask(`I won't be able to save your data, but what do you want to do next?`)
|
83 | * }
|
84 | * })
|
85 | *
|
86 | * // Actions SDK
|
87 | * const app = actionssdk({
|
88 | * clientId: CLIENT_ID,
|
89 | * })
|
90 | *
|
91 | * app.intent('actions.intent.MAIN', conv => {
|
92 | * conv.ask(new SignIn('To get your account details'))
|
93 | * })
|
94 | *
|
95 | * app.intent('actions.intent.SIGN_IN', (conv, input, signin) => {
|
96 | * if (signin.status === 'OK') {
|
97 | * const payload = conv.user.profile.payload
|
98 | * conv.ask(`I got your account details. What do you want to do next?`)
|
99 | * } else {
|
100 | * conv.ask(`I won't be able to save your data, but what do you want to do next?`)
|
101 | * }
|
102 | * })
|
103 | * ```
|
104 | *
|
105 | * @public
|
106 | */
|
107 | payload?: TokenPayload;
|
108 | /**
|
109 | * The `user.idToken` retrieved from account linking.
|
110 | * Only retrievable with "Google Sign In" linking type set up for account linking in the console.
|
111 | * @public
|
112 | */
|
113 | token?: string;
|
114 | /** @hidden */
|
115 | constructor(user: Api.GoogleActionsV2User);
|
116 | /** @hidden */
|
117 | _verify(client: OAuth2Client, id: string): Promise<TokenPayload>;
|
118 | }
|
119 | export declare class User<TUserStorage> {
|
120 | raw: Api.GoogleActionsV2User;
|
121 | /**
|
122 | * The data persistent across sessions in JSON format.
|
123 | * It exists in the same context as `conv.user.id`
|
124 | *
|
125 | * @example
|
126 | * ```javascript
|
127 | *
|
128 | * // Actions SDK
|
129 | * app.intent('actions.intent.MAIN', conv => {
|
130 | * conv.user.storage.someProperty = 'someValue'
|
131 | * })
|
132 | *
|
133 | * // Dialogflow
|
134 | * app.intent('Default Welcome Intent', conv => {
|
135 | * conv.user.storage.someProperty = 'someValue'
|
136 | * })
|
137 | * ```
|
138 | *
|
139 | * @public
|
140 | */
|
141 | storage: TUserStorage;
|
142 | /**
|
143 | * The user locale. String represents the regional language
|
144 | * information of the user set in their Assistant settings.
|
145 | * For example, 'en-US' represents US English.
|
146 | * @public
|
147 | */
|
148 | locale: string;
|
149 | /** @public */
|
150 | last: Last;
|
151 | /** @public */
|
152 | permissions: Api.GoogleActionsV2UserPermissions[];
|
153 | /**
|
154 | * User's permissioned name info.
|
155 | * Properties will be undefined if not request with {@link Permission|conv.ask(new Permission)}
|
156 | * @public
|
157 | */
|
158 | name: Name;
|
159 | /**
|
160 | * The list of all digital goods that your user purchased from
|
161 | * your published Android apps. To enable this feature, see the instructions
|
162 | * in the {@link https://developers.google.com/actions/identity/digital-goods|documentation}.
|
163 | * @public
|
164 | */
|
165 | entitlements: Api.GoogleActionsV2PackageEntitlement[];
|
166 | /** @public */
|
167 | access: Access;
|
168 | /** @public */
|
169 | profile: Profile;
|
170 | /** @hidden */
|
171 | _id: string;
|
172 | /**
|
173 | * Gets the user profile email.
|
174 | * Only retrievable with "Google Sign In" linking type set up for account linking in the console.
|
175 | *
|
176 | * See {@link Profile#payload|conv.user.profile.payload} for all the payload properties.
|
177 | *
|
178 | * @example
|
179 | * ```javascript
|
180 | *
|
181 | * // Dialogflow
|
182 | * const app = dialogflow({
|
183 | * clientId: CLIENT_ID,
|
184 | * })
|
185 | *
|
186 | * app.intent('Default Welcome Intent', conv => {
|
187 | * conv.ask(new SignIn('To get your account details'))
|
188 | * })
|
189 | *
|
190 | * // Create a Dialogflow intent with the `actions_intent_SIGN_IN` event
|
191 | * app.intent('Get Signin', (conv, params, signin) => {
|
192 | * if (signin.status === 'OK') {
|
193 | * const email = conv.user.email
|
194 | * conv.ask(`I got your email as ${email}. What do you want to do next?`)
|
195 | * } else {
|
196 | * conv.ask(`I won't be able to save your data, but what do you want to next?`)
|
197 | * }
|
198 | * })
|
199 | *
|
200 | * // Actions SDK
|
201 | * const app = actionssdk({
|
202 | * clientId: CLIENT_ID,
|
203 | * })
|
204 | *
|
205 | * app.intent('actions.intent.MAIN', conv => {
|
206 | * conv.ask(new SignIn('To get your account details'))
|
207 | * })
|
208 | *
|
209 | * app.intent('actions.intent.SIGN_IN', (conv, input, signin) => {
|
210 | * if (signin.status === 'OK') {
|
211 | * const email = conv.user.email
|
212 | * conv.ask(`I got your email as ${email}. What do you want to do next?`)
|
213 | * } else {
|
214 | * conv.ask(`I won't be able to save your data, but what do you want to next?`)
|
215 | * }
|
216 | * })
|
217 | * ```
|
218 | *
|
219 | * @public
|
220 | */
|
221 | email?: string;
|
222 | /**
|
223 | * Determine if the user is 'GUEST' or 'VERIFIED'
|
224 | * @public
|
225 | */
|
226 | verification?: Api.GoogleActionsV2UserUserVerificationStatus;
|
227 | /** @hidden */
|
228 | constructor(raw?: Api.GoogleActionsV2User, initial?: TUserStorage);
|
229 | /** @hidden */
|
230 | _serialize(): string;
|
231 | /** @hidden */
|
232 | _verifyProfile(client: OAuth2Client, id: string): Promise<TokenPayload>;
|
233 | }
|