@cloudbase/oauth 0.0.3-alpha.0 → 1.0.0-alpha.0

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.
@@ -17,8 +17,12 @@ 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
- BIND_PHONE_URL = '/auth/v1/user/contact',
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'
22
26
  }
23
27
 
24
28
  export enum VerificationUsages {
@@ -28,3 +32,25 @@ export enum VerificationUsages {
28
32
  EMAIL_ADDRESS_CHANGE = 'EMAIL_ADDRESS_CHANGE',
29
33
  PHONE_NUMBER_CHANGE = 'PHONE_NUMBER_CHANGE',
30
34
  }
35
+
36
+ export enum ErrorType {
37
+ INVALID_ARGUMENT = 'invalid_argument',
38
+ DEADLINE_EXCEEDED = 'deadline_exceeded',
39
+ NOT_FOUND = 'not_found',
40
+ ALREADY_EXISTS = 'already_exists',
41
+ PERMISSION_DENIED = 'permission_denied',
42
+ ABORTED = 'aborted',
43
+ OUT_OF_RANGE = 'out_of_range',
44
+ UNIMPLEMENTED = 'unimplemented',
45
+ INTERNAL = 'internal',
46
+ UNAVAILABLE = 'unavailable',
47
+ DATA_LOSS = 'data_loss',
48
+ // CommonError
49
+ CAPTCHA_REQUIRED = 'captcha_required',
50
+ CAPTCHA_INVALID = 'captcha_invalid',
51
+ INVALID_PASSWORD = 'invalid_password',
52
+ PASSWORD_NOT_SET = 'password_not_set',
53
+ INVALID_STATUS = 'invalid_status',
54
+ USER_PENDING = 'user_pending',
55
+ USER_BLOCKED = 'user_blocked',
56
+ }
@@ -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
 
@@ -111,6 +112,7 @@ export interface UserProfileProvider {
111
112
  export interface UserProfile {
112
113
  name?: string;
113
114
  picture?: string;
115
+ avatarUrl?: string;
114
116
  username?: string;
115
117
  email?: string;
116
118
  email_verified?: boolean;
@@ -121,6 +123,20 @@ export interface UserProfile {
121
123
  zoneinfo?: string;
122
124
  locale?: string;
123
125
  created_from?: string;
126
+ sub?: string
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:
124
140
  }
125
141
 
126
142
  export type UserInfo = UserProfile;
@@ -173,3 +189,244 @@ export type ChangeBindedProviderResponse = BaseRequest
173
189
  export interface QueryUserProfileReq extends BaseRequest {
174
190
  appended_params: string;
175
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
+ target?: string | 'ANY';
217
+ usage?: string;
218
+ }
219
+
220
+ export interface GetVerificationResponse {
221
+ verification_id?: string;
222
+ is_user?: boolean | false;
223
+ }
224
+
225
+ export interface VerifyResponse {
226
+ verification_token?: string;
227
+ }
228
+
229
+ export interface VerifyRequest {
230
+ verification_code: string;
231
+ verification_id?: string;
232
+ }
233
+
234
+ export interface ProviderBindRequest {
235
+ provider_token: string;
236
+ }
237
+
238
+ export interface GrantProviderTokenRequest {
239
+ provider_id: string;
240
+ provider_redirect_uri?: string;
241
+ provider_code?: string;
242
+ provider_access_token?: string;
243
+ provider_id_token?: string;
244
+ }
245
+
246
+ export interface GrantProviderTokenResponse {
247
+ provider_token: string;
248
+ expires_in: number;
249
+ }
250
+
251
+ export interface PatchProviderTokenRequest {
252
+ provider_token: string;
253
+ provider_params: {
254
+ encryptedData: string;
255
+ iv: string;
256
+ };
257
+ }
258
+
259
+ export interface PatchProviderTokenResponse {
260
+ provider_token: string;
261
+ expires_in: number;
262
+ provider_profile: ProviderProfile;
263
+ }
264
+
265
+ export interface GenProviderRedirectUriRequest {
266
+ provider_id: string;
267
+ provider_redirect_uri: string;
268
+ state: string;
269
+ other_params?: {
270
+ sign_out_uri?: string;
271
+ };
272
+ }
273
+
274
+ export interface GenProviderRedirectUriResponse {
275
+ uri: string;
276
+ signout_uri?: string;
277
+ }
278
+
279
+ export interface BindWithProviderRequest {
280
+ provider_token: string;
281
+ }
282
+
283
+ export interface BindWithProviderRequest {
284
+ provider_token: string;
285
+ }
286
+
287
+ export interface UserProfileProvider {
288
+ id?: string;
289
+ provider_user_id?: string;
290
+ name?: string;
291
+ }
292
+
293
+ export interface UserProfile {
294
+ name?: string;
295
+ picture?: string;
296
+ username?: string;
297
+ email?: string;
298
+ email_verified?: boolean;
299
+ phone_number?: string;
300
+ providers?: [UserProfileProvider];
301
+ gender?: string;
302
+ birthdate?: string;
303
+ zoneinfo?: string;
304
+ locale?: string;
305
+ created_from?: string;
306
+ }
307
+
308
+ export interface ProviderProfile {
309
+ provider_id: string;
310
+ phone_number?: string;
311
+ }
312
+
313
+ export interface TransByProviderRequest {
314
+ provider_token: string;
315
+ }
316
+
317
+ export interface GrantTokenRequest {
318
+ client_secret?: string;
319
+ code?: string;
320
+ grant_type?: string;
321
+ redirect_uri?: string;
322
+ nonce?: string;
323
+ refresh_token?: string;
324
+ scope?: string;
325
+ }
326
+
327
+ export interface UnbindProviderRequest {
328
+ provider_id: string;
329
+ }
330
+
331
+ export interface CheckPasswordrRequest {
332
+ password: string;
333
+ }
334
+
335
+ export interface BindPhoneRequest {
336
+ phone_number: string;
337
+ sudo_token: string;
338
+ verification_token: string;
339
+ conflict_resolution: string
340
+ // 1. DEFAULT 0, 默认提示用户手机号已被绑定
341
+ // 2. DELETE_ACCOUNT_TRANSFER 1, 标记原账号已被注销,并将手机换绑给自己
342
+ // 3. TRANSFER 2, 仅换绑手机号,不注销原有账号(换绑后原账号无法登录时,则自动注销原账号)
343
+ }
344
+
345
+ export interface BindEmailRequest {
346
+ email: string;
347
+ sudo_token: string;
348
+ verification_token: string;
349
+ }
350
+
351
+ export interface SetPasswordRequest {
352
+ new_password: string;
353
+ sudo_token: string;
354
+ }
355
+
356
+
357
+ export interface SetPasswordRequest {
358
+ new_password: string;
359
+ sudo_token: string;
360
+ }
361
+
362
+ export interface UpdatePasswordRequest {
363
+ old_password: string;
364
+ new_password: string;
365
+ }
366
+
367
+ // password 和 verification_token 而选一,如果绑定了手机号,则必须使用verification_token 进行sudo
368
+ export interface SudoRequest {
369
+ password?: string;
370
+ verification_token?: string
371
+ }
372
+
373
+ export interface SudoResponse {
374
+ sudo_token?: string
375
+ }
376
+
377
+
378
+ export interface ChangeBoundProviderRequest {
379
+ trans_token: string;
380
+ provider_id: string;
381
+ }
382
+
383
+ export interface ChangeBoundProviderResponse {
384
+ client_id: string;
385
+ }
386
+
387
+ export interface QueryUserProfileRequest {
388
+ id?: [string];
389
+ username?: string;
390
+ email?: string;
391
+ phone_number?: string;
392
+ }
393
+
394
+ export interface QueryUserProfileResponse {
395
+ total: string;
396
+ data: SimpleUserProfile[]
397
+ }
398
+
399
+ export interface ResetPasswordRequest extends BaseRequest {
400
+ email: string
401
+ phone_number: string
402
+ new_password: string
403
+ verification_token: string
404
+ }
405
+
406
+ export interface DeviceAuthorizeRequest extends BaseRequest {
407
+ scope?: string
408
+ }
409
+
410
+ export interface DeviceAuthorizeResponse {
411
+ device_code: string
412
+ user_code: string
413
+ expires_in: number
414
+ interval: number
415
+ verification_url: string
416
+ verification_uri_complete: string
417
+ }
418
+
419
+ // 简化版用户信息
420
+ export interface SimpleUserProfile {
421
+ sub: string;
422
+ name: string;
423
+ picture?: string;
424
+ gender?: string;
425
+ locale?: string;
426
+ email?: string;
427
+ phone_number?: string;
428
+ }
429
+
430
+ export interface CheckUsernameRequest {
431
+ username: string
432
+ }