@cloudbase/oauth 0.0.5-alpha.0 → 1.0.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +30 -0
- package/Dockerfile +15 -0
- package/README.md +165 -3
- package/_exmaple/assets/scripts/function/function.ts +99 -0
- package/_exmaple/assets/scripts/index.ts +101 -0
- package/_exmaple/assets/scripts/request.ts +11 -0
- package/_exmaple/index.html +15 -0
- package/_exmaple/package.json +33 -0
- package/_exmaple/tsconfig.json +71 -0
- package/_exmaple/typings.d.ts +0 -0
- package/_exmaple/webpack.config.js +42 -0
- package/dist/auth/apis.d.ts +14 -5
- package/dist/auth/apis.js +146 -45
- package/dist/auth/consts.d.ts +27 -2
- package/dist/auth/consts.js +29 -3
- package/dist/auth/models.d.ts +213 -1
- package/dist/auth/models.js +1 -1
- package/dist/captcha/captcha.js +16 -11
- package/dist/index.d.ts +7 -2
- package/dist/index.js +4 -175
- package/dist/oauth2client/interface.d.ts +6 -6
- package/dist/oauth2client/interface.js +1 -1
- package/dist/oauth2client/oauth2client.d.ts +1 -0
- package/dist/oauth2client/oauth2client.js +17 -1
- package/package.json +2 -7
- package/publish.sh +2 -0
- package/src/auth/apis.ts +143 -29
- package/src/auth/consts.ts +28 -1
- package/src/auth/models.ts +264 -1
- package/src/captcha/captcha.ts +185 -180
- package/src/index.ts +3 -116
- package/src/oauth2client/interface.ts +6 -6
- package/src/oauth2client/oauth2client.ts +9 -0
- package/wiki/README.md +75 -0
package/src/auth/apis.ts
CHANGED
|
@@ -24,16 +24,27 @@ import {
|
|
|
24
24
|
UnbindProviderRequest,
|
|
25
25
|
CheckPasswordrRequest,
|
|
26
26
|
BindPhoneRequest,
|
|
27
|
+
BindEmailRequest,
|
|
27
28
|
SetPasswordRequest,
|
|
28
29
|
ChangeBindedProviderRequest,
|
|
29
30
|
ChangeBindedProviderResponse,
|
|
30
|
-
|
|
31
|
+
UpdatePasswordRequest,
|
|
32
|
+
SudoResponse,
|
|
33
|
+
SudoRequest,
|
|
34
|
+
GetCustomSignTicketFn,
|
|
35
|
+
QueryUserProfileRequest,
|
|
36
|
+
QueryUserProfileResponse,
|
|
37
|
+
ResetPasswordRequest,
|
|
38
|
+
DeviceAuthorizeRequest,
|
|
39
|
+
DeviceAuthorizeResponse,
|
|
40
|
+
CheckUsernameRequest,
|
|
41
|
+
CheckIfUserExistRequest,
|
|
42
|
+
CheckIfUserExistResponse
|
|
31
43
|
} from './models';
|
|
32
44
|
import { SimpleStorage, RequestFunction } from '../oauth2client/interface';
|
|
33
45
|
import { OAuth2Client, defaultStorage } from '../oauth2client/oauth2client';
|
|
34
46
|
import { Credentials } from '../oauth2client/models';
|
|
35
47
|
import { Captcha } from '../captcha/captcha';
|
|
36
|
-
import { ICloudbase } from '@cloudbase/types';
|
|
37
48
|
|
|
38
49
|
|
|
39
50
|
export interface AuthOptions {
|
|
@@ -42,7 +53,6 @@ export interface AuthOptions {
|
|
|
42
53
|
credentialsClient?: OAuth2Client;
|
|
43
54
|
request?: RequestFunction;
|
|
44
55
|
storage?: SimpleStorage;
|
|
45
|
-
_fromApp?: ICloudbase // 所属cloudbase app对象
|
|
46
56
|
}
|
|
47
57
|
|
|
48
58
|
/**
|
|
@@ -50,6 +60,8 @@ export interface AuthOptions {
|
|
|
50
60
|
*/
|
|
51
61
|
export class Auth {
|
|
52
62
|
private _config: AuthOptions;
|
|
63
|
+
private _getCustomSignTicketFn?: GetCustomSignTicketFn;
|
|
64
|
+
|
|
53
65
|
|
|
54
66
|
/**
|
|
55
67
|
* constructor
|
|
@@ -90,7 +102,6 @@ export class Auth {
|
|
|
90
102
|
* @return {Promise<Credentials>} A Promise<Credentials> object.
|
|
91
103
|
*/
|
|
92
104
|
public async signIn(params: SignInRequest): Promise<Credentials> {
|
|
93
|
-
params.client_id = this._config.clientId;
|
|
94
105
|
const credentials: Credentials = await this._config.request<Credentials>(
|
|
95
106
|
ApiUrls.AUTH_SIGN_IN_URL,
|
|
96
107
|
{
|
|
@@ -111,9 +122,7 @@ export class Auth {
|
|
|
111
122
|
ApiUrls.AUTH_SIGN_IN_ANONYMOUSLY_URL,
|
|
112
123
|
{
|
|
113
124
|
method: 'POST',
|
|
114
|
-
body: {
|
|
115
|
-
client_id: this._config.clientId
|
|
116
|
-
}
|
|
125
|
+
body: {}
|
|
117
126
|
},
|
|
118
127
|
);
|
|
119
128
|
await this._config.credentialsClient.setCredentials(credentials);
|
|
@@ -125,8 +134,7 @@ export class Auth {
|
|
|
125
134
|
* @param {SignUpRequest} params A SignUpRequest Object.
|
|
126
135
|
* @return {Promise<Credentials>} A Promise<Credentials> object.
|
|
127
136
|
*/
|
|
128
|
-
|
|
129
|
-
params.client_id = this._config.clientId;
|
|
137
|
+
public async signUp(params: SignUpRequest): Promise<Credentials> {
|
|
130
138
|
const data: Credentials = await this._config.request<Credentials>(
|
|
131
139
|
ApiUrls.AUTH_SIGN_UP_URL,
|
|
132
140
|
{
|
|
@@ -147,7 +155,6 @@ export class Auth {
|
|
|
147
155
|
const data = await this._config.request(ApiUrls.AUTH_REVOKE_URL, {
|
|
148
156
|
method: 'POST',
|
|
149
157
|
body: {
|
|
150
|
-
client_id: this._config.clientId,
|
|
151
158
|
token: accessToken,
|
|
152
159
|
},
|
|
153
160
|
});
|
|
@@ -163,13 +170,23 @@ export class Auth {
|
|
|
163
170
|
public async getVerification(
|
|
164
171
|
params: GetVerificationRequest,
|
|
165
172
|
): Promise<GetVerificationResponse> {
|
|
166
|
-
|
|
173
|
+
let withCredentials = false;
|
|
174
|
+
// 发送短信时,如果时给当前用户发,则需要带上鉴权信息
|
|
175
|
+
if (params.target == 'CUR_USER') {
|
|
176
|
+
withCredentials = true
|
|
177
|
+
} else {
|
|
178
|
+
const hasLogin = await this.hasLoginState()
|
|
179
|
+
if (hasLogin) {
|
|
180
|
+
withCredentials = true
|
|
181
|
+
}
|
|
182
|
+
}
|
|
167
183
|
return this._config.request<GetVerificationResponse>(
|
|
168
184
|
ApiUrls.VERIFICATION_URL,
|
|
169
185
|
{
|
|
170
186
|
method: 'POST',
|
|
171
187
|
body: params,
|
|
172
|
-
withCaptcha: true
|
|
188
|
+
withCaptcha: true,
|
|
189
|
+
withCredentials: withCredentials,
|
|
173
190
|
},
|
|
174
191
|
);
|
|
175
192
|
}
|
|
@@ -180,7 +197,6 @@ export class Auth {
|
|
|
180
197
|
* @return {Promise<VerifyResponse>} A Promise<VerifyResponse> object.
|
|
181
198
|
*/
|
|
182
199
|
public async verify(params: VerifyRequest): Promise<VerifyResponse> {
|
|
183
|
-
params.client_id = this._config.clientId;
|
|
184
200
|
return this._config.request<VerifyResponse>(ApiUrls.VERIFY_URL, {
|
|
185
201
|
method: 'POST',
|
|
186
202
|
body: params,
|
|
@@ -221,7 +237,6 @@ export class Auth {
|
|
|
221
237
|
public async grantProviderToken(
|
|
222
238
|
params: GrantProviderTokenRequest,
|
|
223
239
|
): Promise<GrantProviderTokenResponse> {
|
|
224
|
-
params.client_id = this._config.clientId;
|
|
225
240
|
return this._config.request<GrantProviderTokenResponse>(
|
|
226
241
|
ApiUrls.PROVIDER_TOKEN_URL,
|
|
227
242
|
{
|
|
@@ -239,7 +254,6 @@ export class Auth {
|
|
|
239
254
|
public async patchProviderToken(
|
|
240
255
|
params: PatchProviderTokenRequest,
|
|
241
256
|
): Promise<PatchProviderTokenResponse> {
|
|
242
|
-
params.client_id = this._config.clientId;
|
|
243
257
|
return this._config.request<PatchProviderTokenResponse>(
|
|
244
258
|
ApiUrls.PROVIDER_TOKEN_URL,
|
|
245
259
|
{
|
|
@@ -257,7 +271,6 @@ export class Auth {
|
|
|
257
271
|
public async signInWithProvider(
|
|
258
272
|
params: SignInWithProviderRequest,
|
|
259
273
|
): Promise<Credentials> {
|
|
260
|
-
params.client_id = this._config.clientId;
|
|
261
274
|
const credentials: Credentials = await this._config.request<Credentials>(
|
|
262
275
|
ApiUrls.AUTH_SIGN_IN_WITH_PROVIDER_URL,
|
|
263
276
|
{
|
|
@@ -277,7 +290,6 @@ export class Auth {
|
|
|
277
290
|
public async bindWithProvider(
|
|
278
291
|
params: BindWithProviderRequest,
|
|
279
292
|
): Promise<void> {
|
|
280
|
-
params.client_id = this._config.clientId;
|
|
281
293
|
return this._config.request<any>(ApiUrls.PROVIDER_BIND_URL, {
|
|
282
294
|
method: 'POST',
|
|
283
295
|
body: params,
|
|
@@ -310,9 +322,6 @@ export class Auth {
|
|
|
310
322
|
userInfo.uid = userInfo.sub
|
|
311
323
|
}
|
|
312
324
|
|
|
313
|
-
if (userInfo.name) {
|
|
314
|
-
userInfo.username = userInfo.name
|
|
315
|
-
}
|
|
316
325
|
return userInfo;
|
|
317
326
|
}
|
|
318
327
|
|
|
@@ -362,7 +371,6 @@ export class Auth {
|
|
|
362
371
|
* @return {Promise<Credentials>} A Promise<Credentials> object.
|
|
363
372
|
*/
|
|
364
373
|
public async grantToken(params: GrantTokenRequest): Promise<Credentials> {
|
|
365
|
-
params.client_id = this._config.clientId;
|
|
366
374
|
return this._config.request<Credentials>(ApiUrls.AUTH_TOKEN_URL, {
|
|
367
375
|
method: 'POST',
|
|
368
376
|
body: params,
|
|
@@ -386,7 +394,6 @@ export class Auth {
|
|
|
386
394
|
* @return {Promise<any>}
|
|
387
395
|
*/
|
|
388
396
|
public async unbindProvider(params: UnbindProviderRequest): Promise<void> {
|
|
389
|
-
params.client_id = this._config.clientId;
|
|
390
397
|
return this._config.request<any>(
|
|
391
398
|
`${ApiUrls.PROVIDER_UNBIND_URL}/${params.provider_id}`,
|
|
392
399
|
{
|
|
@@ -415,7 +422,20 @@ export class Auth {
|
|
|
415
422
|
* @return {Promise<any>}
|
|
416
423
|
*/
|
|
417
424
|
public async bindPhone(params: BindPhoneRequest): Promise<void> {
|
|
418
|
-
return this._config.request<any>(`${ApiUrls.
|
|
425
|
+
return this._config.request<any>(`${ApiUrls.BIND_CONTACT_URL}`, {
|
|
426
|
+
method: 'PATCH',
|
|
427
|
+
withCredentials: true,
|
|
428
|
+
body: params,
|
|
429
|
+
});
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
/**
|
|
433
|
+
* check Password.
|
|
434
|
+
* @param {CheckPasswordrRequest} params
|
|
435
|
+
* @return {Promise<any>}
|
|
436
|
+
*/
|
|
437
|
+
public async bindEmail(params: BindEmailRequest): Promise<void> {
|
|
438
|
+
return this._config.request<any>(`${ApiUrls.BIND_CONTACT_URL}`, {
|
|
419
439
|
method: 'PATCH',
|
|
420
440
|
withCredentials: true,
|
|
421
441
|
body: params,
|
|
@@ -435,6 +455,33 @@ export class Auth {
|
|
|
435
455
|
});
|
|
436
456
|
}
|
|
437
457
|
|
|
458
|
+
/**
|
|
459
|
+
* updatePasswordByOld 使用旧密码修改密码,如果已经绑定手机号,请先:sudo,再修改密码
|
|
460
|
+
* @param {SetPasswordrRequest} params
|
|
461
|
+
* @return {Promise<any>}
|
|
462
|
+
*/
|
|
463
|
+
public async updatePasswordByOld(params: UpdatePasswordRequest): Promise<void> {
|
|
464
|
+
const sudoToken = await this.sudo({ password: params.old_password })
|
|
465
|
+
return this.setPassword({
|
|
466
|
+
sudo_token: sudoToken.sudo_token,
|
|
467
|
+
new_password: params.new_password,
|
|
468
|
+
})
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
|
|
472
|
+
/**
|
|
473
|
+
* sudo
|
|
474
|
+
* @param {sudo} params
|
|
475
|
+
* @return {Promise<any>}
|
|
476
|
+
*/
|
|
477
|
+
public async sudo(params: SudoRequest): Promise<SudoResponse> {
|
|
478
|
+
return this._config.request<SudoResponse>(`${ApiUrls.SUDO_URL}`, {
|
|
479
|
+
method: 'POST',
|
|
480
|
+
withCredentials: true,
|
|
481
|
+
body: params,
|
|
482
|
+
});
|
|
483
|
+
}
|
|
484
|
+
|
|
438
485
|
/**
|
|
439
486
|
* Get the current user verification.
|
|
440
487
|
* @param {GetVerificationRequest} params A GetVerificationRequest Object.
|
|
@@ -443,7 +490,6 @@ export class Auth {
|
|
|
443
490
|
public async getCurUserVerification(
|
|
444
491
|
params: GetVerificationRequest,
|
|
445
492
|
): Promise<GetVerificationResponse> {
|
|
446
|
-
params.client_id = this._config.clientId;
|
|
447
493
|
params.target = 'CUR_USER';
|
|
448
494
|
return this._config.request<GetVerificationResponse>(
|
|
449
495
|
ApiUrls.VERIFICATION_URL,
|
|
@@ -464,7 +510,6 @@ export class Auth {
|
|
|
464
510
|
public async changeBindedProvider(
|
|
465
511
|
params: ChangeBindedProviderRequest,
|
|
466
512
|
): Promise<ChangeBindedProviderResponse> {
|
|
467
|
-
params.client_id = this._config.clientId;
|
|
468
513
|
return this._config.request<ChangeBindedProviderResponse>(
|
|
469
514
|
`${ApiUrls.PROVIDER_LIST}/${params.provider_id}/trans`,
|
|
470
515
|
{
|
|
@@ -496,12 +541,81 @@ export class Auth {
|
|
|
496
541
|
* @return {Promise<UserProfile>} A Promise<UserProfile> object.
|
|
497
542
|
*/
|
|
498
543
|
public async queryUserProfile(
|
|
499
|
-
|
|
500
|
-
): Promise<
|
|
501
|
-
|
|
502
|
-
|
|
544
|
+
params: QueryUserProfileRequest,
|
|
545
|
+
): Promise<QueryUserProfileResponse> {
|
|
546
|
+
// let url = new URL(ApiUrls.USER_QUERY_URL);
|
|
547
|
+
const searchParams = new URLSearchParams(params as any);
|
|
548
|
+
// url.search = searchParams.toString();
|
|
549
|
+
return this._config.request<QueryUserProfileResponse>(`${ApiUrls.USER_QUERY_URL}?${searchParams.toString()}`, {
|
|
503
550
|
method: 'GET',
|
|
504
551
|
withCredentials: true,
|
|
505
552
|
});
|
|
506
553
|
}
|
|
554
|
+
|
|
555
|
+
/**
|
|
556
|
+
* setCustomSignFunc set the get ticket function
|
|
557
|
+
* @param getTickFn
|
|
558
|
+
*/
|
|
559
|
+
public setCustomSignFunc(getTickFn: GetCustomSignTicketFn) {
|
|
560
|
+
this._getCustomSignTicketFn = getTickFn
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
/**
|
|
564
|
+
* SignInWithCustomTicket custom signIn
|
|
565
|
+
* @constructor
|
|
566
|
+
*/
|
|
567
|
+
public async signInWithCustomTicket(): Promise<Credentials> {
|
|
568
|
+
const customTicket = await this._getCustomSignTicketFn()
|
|
569
|
+
return this.signInWithProvider({
|
|
570
|
+
provider_id: 'custom',
|
|
571
|
+
provider_token: customTicket
|
|
572
|
+
})
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
/**
|
|
576
|
+
* Reset password
|
|
577
|
+
* @param {ResetPasswordRequest} params
|
|
578
|
+
* @returns {Promise<void>}
|
|
579
|
+
* @memberof Auth
|
|
580
|
+
*/
|
|
581
|
+
public async resetPassword(params: ResetPasswordRequest): Promise<void> {
|
|
582
|
+
return this._config.request(ApiUrls.AUTH_SET_PASSWORD, {
|
|
583
|
+
method: 'POST',
|
|
584
|
+
body: params,
|
|
585
|
+
// withCredentials: true
|
|
586
|
+
})
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
/**
|
|
590
|
+
* device authorization
|
|
591
|
+
* @param {DeviceAuthorizeRequest} params
|
|
592
|
+
* @returns {Promise<DeviceAuthorizeResponse>}
|
|
593
|
+
* @memberof Auth
|
|
594
|
+
*/
|
|
595
|
+
public async deviceAuthorize(params: DeviceAuthorizeRequest): Promise<DeviceAuthorizeResponse> {
|
|
596
|
+
return this._config.request(ApiUrls.AUTH_GET_DEVICE_CODE, {
|
|
597
|
+
method: 'POST',
|
|
598
|
+
body: params,
|
|
599
|
+
withCredentials: true
|
|
600
|
+
})
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
public async checkUsername(params: CheckUsernameRequest): Promise<void> {
|
|
604
|
+
return this._config.request(ApiUrls.CHECK_USERNAME, {
|
|
605
|
+
method: 'GET',
|
|
606
|
+
body: params,
|
|
607
|
+
withCredentials: true
|
|
608
|
+
})
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
public async checkIfUserExist(params: CheckIfUserExistRequest): Promise<CheckIfUserExistResponse> {
|
|
612
|
+
return this._config.request<CheckIfUserExistResponse>(ApiUrls.CHECK_IF_USER_EXIST, {
|
|
613
|
+
method: 'POST',
|
|
614
|
+
body: params,
|
|
615
|
+
});
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
public async loginScope(): Promise<string> {
|
|
619
|
+
return this._config.credentialsClient.getScope()
|
|
620
|
+
}
|
|
507
621
|
}
|
package/src/auth/consts.ts
CHANGED
|
@@ -17,8 +17,13 @@ export enum ApiUrls {
|
|
|
17
17
|
PROVIDER_LIST = '/auth/v1/user/provider',
|
|
18
18
|
PROVIDER_UNBIND_URL = '/auth/v1/user/provider',
|
|
19
19
|
CHECK_PWD_URL = '/auth/v1/user/sudo',
|
|
20
|
-
|
|
20
|
+
SUDO_URL = '/auth/v1/user/sudo',
|
|
21
|
+
BIND_CONTACT_URL = '/auth/v1/user/contact',
|
|
21
22
|
AUTH_SET_PASSWORD = '/auth/v1/user/password',
|
|
23
|
+
AUTH_RESET_PASSWORD = '/auth/v1/reset',
|
|
24
|
+
AUTH_GET_DEVICE_CODE = '/auth/v1/device/code',
|
|
25
|
+
CHECK_USERNAME = '/auth/v1/checkUsername',
|
|
26
|
+
CHECK_IF_USER_EXIST = '/auth/v1/checkIfUserExist'
|
|
22
27
|
}
|
|
23
28
|
|
|
24
29
|
export enum VerificationUsages {
|
|
@@ -28,3 +33,25 @@ export enum VerificationUsages {
|
|
|
28
33
|
EMAIL_ADDRESS_CHANGE = 'EMAIL_ADDRESS_CHANGE',
|
|
29
34
|
PHONE_NUMBER_CHANGE = 'PHONE_NUMBER_CHANGE',
|
|
30
35
|
}
|
|
36
|
+
|
|
37
|
+
export enum ErrorType {
|
|
38
|
+
INVALID_ARGUMENT = 'invalid_argument',
|
|
39
|
+
DEADLINE_EXCEEDED = 'deadline_exceeded',
|
|
40
|
+
NOT_FOUND = 'not_found',
|
|
41
|
+
ALREADY_EXISTS = 'already_exists',
|
|
42
|
+
PERMISSION_DENIED = 'permission_denied',
|
|
43
|
+
ABORTED = 'aborted',
|
|
44
|
+
OUT_OF_RANGE = 'out_of_range',
|
|
45
|
+
UNIMPLEMENTED = 'unimplemented',
|
|
46
|
+
INTERNAL = 'internal',
|
|
47
|
+
UNAVAILABLE = 'unavailable',
|
|
48
|
+
DATA_LOSS = 'data_loss',
|
|
49
|
+
// CommonError
|
|
50
|
+
CAPTCHA_REQUIRED = 'captcha_required',
|
|
51
|
+
CAPTCHA_INVALID = 'captcha_invalid',
|
|
52
|
+
INVALID_PASSWORD = 'invalid_password',
|
|
53
|
+
PASSWORD_NOT_SET = 'password_not_set',
|
|
54
|
+
INVALID_STATUS = 'invalid_status',
|
|
55
|
+
USER_PENDING = 'user_pending',
|
|
56
|
+
USER_BLOCKED = 'user_blocked',
|
|
57
|
+
}
|
package/src/auth/models.ts
CHANGED
|
@@ -2,10 +2,11 @@ interface BaseRequest {
|
|
|
2
2
|
client_id?: string;
|
|
3
3
|
}
|
|
4
4
|
|
|
5
|
+
export type GetCustomSignTicketFn = () => Promise<string>;
|
|
6
|
+
|
|
5
7
|
export interface SignInRequest extends BaseRequest {
|
|
6
8
|
username?: string;
|
|
7
9
|
password?: string;
|
|
8
|
-
verification_code?: string;
|
|
9
10
|
verification_token?: string;
|
|
10
11
|
}
|
|
11
12
|
|
|
@@ -124,6 +125,18 @@ export interface UserProfile {
|
|
|
124
125
|
created_from?: string;
|
|
125
126
|
sub?: string
|
|
126
127
|
uid?: string
|
|
128
|
+
address?: {
|
|
129
|
+
formatted?: string,
|
|
130
|
+
street_address?: string,
|
|
131
|
+
locality?: string,
|
|
132
|
+
region?: string,
|
|
133
|
+
postal_code?: string,
|
|
134
|
+
country?: string
|
|
135
|
+
}
|
|
136
|
+
nickName?: string // TODO:
|
|
137
|
+
province?: string // TODO:
|
|
138
|
+
country?: string // TODO:
|
|
139
|
+
city?: string // TODO:
|
|
127
140
|
}
|
|
128
141
|
|
|
129
142
|
export type UserInfo = UserProfile;
|
|
@@ -176,3 +189,253 @@ export type ChangeBindedProviderResponse = BaseRequest
|
|
|
176
189
|
export interface QueryUserProfileReq extends BaseRequest {
|
|
177
190
|
appended_params: string;
|
|
178
191
|
}
|
|
192
|
+
|
|
193
|
+
export interface SignInWithProviderRequest {
|
|
194
|
+
provider_token: string;
|
|
195
|
+
provider_id?: string;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
export interface SignUpRequest {
|
|
199
|
+
phone_number?: string;
|
|
200
|
+
email?: string;
|
|
201
|
+
|
|
202
|
+
verification_code?: string;
|
|
203
|
+
verification_token?: string;
|
|
204
|
+
provider_token?: string;
|
|
205
|
+
|
|
206
|
+
password?: string;
|
|
207
|
+
name?: string;
|
|
208
|
+
gender?: string;
|
|
209
|
+
picture?: string;
|
|
210
|
+
locale?: string;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
export interface GetVerificationRequest {
|
|
214
|
+
phone_number?: string;
|
|
215
|
+
email?: string;
|
|
216
|
+
// 可选 ANY,USER,NOT_USER, CUR_USER;
|
|
217
|
+
target?: string | 'ANY';
|
|
218
|
+
usage?: string;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
export interface GetVerificationResponse {
|
|
222
|
+
verification_id?: string;
|
|
223
|
+
is_user?: boolean | false;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
export interface VerifyResponse {
|
|
227
|
+
verification_token?: string;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
export interface VerifyRequest {
|
|
231
|
+
verification_code: string;
|
|
232
|
+
verification_id?: string;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
export interface ProviderBindRequest {
|
|
236
|
+
provider_token: string;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
export interface GrantProviderTokenRequest {
|
|
240
|
+
provider_id: string;
|
|
241
|
+
provider_redirect_uri?: string;
|
|
242
|
+
provider_code?: string;
|
|
243
|
+
provider_access_token?: string;
|
|
244
|
+
provider_id_token?: string;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
export interface GrantProviderTokenResponse {
|
|
248
|
+
provider_token: string;
|
|
249
|
+
expires_in: number;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
export interface PatchProviderTokenRequest {
|
|
253
|
+
provider_token: string;
|
|
254
|
+
provider_params: {
|
|
255
|
+
encryptedData: string;
|
|
256
|
+
iv: string;
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
export interface PatchProviderTokenResponse {
|
|
261
|
+
provider_token: string;
|
|
262
|
+
expires_in: number;
|
|
263
|
+
provider_profile: ProviderProfile;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
export interface GenProviderRedirectUriRequest {
|
|
267
|
+
provider_id: string;
|
|
268
|
+
provider_redirect_uri: string;
|
|
269
|
+
state: string;
|
|
270
|
+
other_params?: {
|
|
271
|
+
sign_out_uri?: string;
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
export interface GenProviderRedirectUriResponse {
|
|
276
|
+
uri: string;
|
|
277
|
+
signout_uri?: string;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
export interface BindWithProviderRequest {
|
|
281
|
+
provider_token: string;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
export interface BindWithProviderRequest {
|
|
285
|
+
provider_token: string;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
export interface UserProfileProvider {
|
|
289
|
+
id?: string;
|
|
290
|
+
provider_user_id?: string;
|
|
291
|
+
name?: string;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
export interface UserProfile {
|
|
295
|
+
name?: string;
|
|
296
|
+
picture?: string;
|
|
297
|
+
username?: string;
|
|
298
|
+
email?: string;
|
|
299
|
+
email_verified?: boolean;
|
|
300
|
+
phone_number?: string;
|
|
301
|
+
providers?: [UserProfileProvider];
|
|
302
|
+
gender?: string;
|
|
303
|
+
birthdate?: string;
|
|
304
|
+
zoneinfo?: string;
|
|
305
|
+
locale?: string;
|
|
306
|
+
created_from?: string;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
export interface ProviderProfile {
|
|
310
|
+
provider_id: string;
|
|
311
|
+
phone_number?: string;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
export interface TransByProviderRequest {
|
|
315
|
+
provider_token: string;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
export interface GrantTokenRequest {
|
|
319
|
+
client_secret?: string;
|
|
320
|
+
code?: string;
|
|
321
|
+
grant_type?: string;
|
|
322
|
+
redirect_uri?: string;
|
|
323
|
+
nonce?: string;
|
|
324
|
+
refresh_token?: string;
|
|
325
|
+
scope?: string;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
export interface UnbindProviderRequest {
|
|
329
|
+
provider_id: string;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
export interface CheckPasswordrRequest {
|
|
333
|
+
password: string;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
export interface BindPhoneRequest {
|
|
337
|
+
phone_number: string;
|
|
338
|
+
sudo_token: string;
|
|
339
|
+
verification_token: string;
|
|
340
|
+
conflict_resolution: string
|
|
341
|
+
// 1. DEFAULT 0, 默认提示用户手机号已被绑定
|
|
342
|
+
// 2. DELETE_ACCOUNT_TRANSFER 1, 标记原账号已被注销,并将手机换绑给自己
|
|
343
|
+
// 3. TRANSFER 2, 仅换绑手机号,不注销原有账号(换绑后原账号无法登录时,则自动注销原账号)
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
export interface BindEmailRequest {
|
|
347
|
+
email: string;
|
|
348
|
+
sudo_token: string;
|
|
349
|
+
verification_token: string;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
export interface SetPasswordRequest {
|
|
353
|
+
new_password: string;
|
|
354
|
+
sudo_token: string;
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
|
|
358
|
+
export interface SetPasswordRequest {
|
|
359
|
+
new_password: string;
|
|
360
|
+
sudo_token: string;
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
export interface UpdatePasswordRequest {
|
|
364
|
+
old_password: string;
|
|
365
|
+
new_password: string;
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
// password 和 verification_token 而选一,如果绑定了手机号,则必须使用verification_token 进行sudo
|
|
369
|
+
export interface SudoRequest {
|
|
370
|
+
password?: string;
|
|
371
|
+
verification_token?: string
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
export interface SudoResponse {
|
|
375
|
+
sudo_token?: string
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
|
|
379
|
+
export interface ChangeBoundProviderRequest {
|
|
380
|
+
trans_token: string;
|
|
381
|
+
provider_id: string;
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
export interface ChangeBoundProviderResponse {
|
|
385
|
+
client_id: string;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
export interface QueryUserProfileRequest {
|
|
389
|
+
id?: [string];
|
|
390
|
+
username?: string;
|
|
391
|
+
email?: string;
|
|
392
|
+
phone_number?: string;
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
export interface QueryUserProfileResponse {
|
|
396
|
+
total: string;
|
|
397
|
+
data: SimpleUserProfile[]
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
export interface ResetPasswordRequest extends BaseRequest {
|
|
401
|
+
email: string
|
|
402
|
+
phone_number: string
|
|
403
|
+
new_password: string
|
|
404
|
+
verification_token: string
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
export interface DeviceAuthorizeRequest extends BaseRequest {
|
|
408
|
+
scope?: string
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
export interface DeviceAuthorizeResponse {
|
|
412
|
+
device_code: string
|
|
413
|
+
user_code: string
|
|
414
|
+
expires_in: number
|
|
415
|
+
interval: number
|
|
416
|
+
verification_url: string
|
|
417
|
+
verification_uri_complete: string
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
// 简化版用户信息
|
|
421
|
+
export interface SimpleUserProfile {
|
|
422
|
+
sub: string;
|
|
423
|
+
name: string;
|
|
424
|
+
picture?: string;
|
|
425
|
+
gender?: string;
|
|
426
|
+
locale?: string;
|
|
427
|
+
email?: string;
|
|
428
|
+
phone_number?: string;
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
export interface CheckUsernameRequest {
|
|
432
|
+
username: string
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
export interface CheckIfUserExistRequest {
|
|
436
|
+
username: string;
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
export interface CheckIfUserExistResponse {
|
|
440
|
+
exist: boolean;
|
|
441
|
+
}
|