@amaster.ai/auth-client 1.1.2 → 1.1.4

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.
@@ -34,13 +34,6 @@
34
34
  * });
35
35
  * ```
36
36
  *
37
- * @example
38
- * With custom base URL:
39
- * ```typescript
40
- * const authClient = createAuthClient({
41
- * baseURL: "https://api.example.com",
42
- * });
43
- * ```
44
37
  */
45
38
  interface AuthClientOptions {
46
39
  /**
@@ -406,7 +399,7 @@ interface ChangePasswordParams {
406
399
  * - google: Google OAuth
407
400
  * - github: GitHub OAuth
408
401
  * - wechat: WeChat Open Platform OAuth (for web/mobile apps)
409
- * - wechat_mini: WeChat Mini Program login
402
+ * - wechat_mini: legacy mini-program provider marker kept for compatibility
410
403
  * - platform: AMaster Platform OAuth
411
404
  */
412
405
  type OAuthProvider = "google" | "github" | "wechat" | "wechat_mini" | "platform";
@@ -419,45 +412,88 @@ interface OAuthBinding {
419
412
  createdAt: string;
420
413
  }
421
414
  /**
422
- * WeChat Mini Program login parameters
415
+ * Mini Program platform type
416
+ * - wechat: WeChat Mini Program
417
+ * - douyin: Douyin Mini Program
418
+ */
419
+ type MiniProgramPlatform = "wechat" | "douyin";
420
+ /**
421
+ * Unified Mini Program login options
422
+ */
423
+ interface MiniLoginParams {
424
+ /**
425
+ * Optional explicit platform override.
426
+ * When omitted, the SDK auto-detects the current mini-program runtime.
427
+ */
428
+ platform?: MiniProgramPlatform;
429
+ }
430
+ /**
431
+ * Mini Program login parameters
423
432
  * @example
424
433
  * ```typescript
425
- * // 1. Get code from WeChat
426
- * wx.login({
427
- * success: async (res) => {
428
- * if (res.code) {
429
- * await authClient.loginWithMiniProgram(res.code);
430
- * }
431
- * }
434
+ * // WeChat
435
+ * await authClient.miniLogin();
436
+ *
437
+ * // Douyin
438
+ * await authClient.miniLogin({
439
+ * platform: "douyin",
432
440
  * });
433
441
  * ```
434
442
  */
435
443
  interface MiniProgramLoginParams {
436
- /** Code from wx.login() API, valid for 5 minutes */
444
+ /** Code from mini-program login API, valid for a short time */
437
445
  code: string;
446
+ /**
447
+ * Optional explicit platform override
448
+ * When omitted, the SDK will auto-detect the current mini-program runtime.
449
+ */
450
+ platform?: MiniProgramPlatform;
438
451
  }
439
452
  /**
440
- * WeChat Mini Program phone number parameters
453
+ * Mini Program phone number parameters
441
454
  * @example
442
455
  * ```typescript
443
- * // WXML
456
+ * // WeChat WXML
444
457
  * <button open-type="getPhoneNumber" bindgetphonenumber="onGetPhoneNumber">
445
458
  * Get Phone Number
446
459
  * </button>
447
460
  *
448
461
  * // JS
449
462
  * async onGetPhoneNumber(e) {
450
- * const { code } = e.detail;
451
- * if (code) {
452
- * await authClient.getMiniProgramPhoneNumber(code);
453
- * }
463
+ * await authClient.miniGetPhone(e);
454
464
  * }
465
+ *
466
+ * // Douyin
467
+ * await authClient.miniGetPhone({
468
+ * code,
469
+ * platform: "douyin",
470
+ * });
455
471
  * ```
456
472
  */
457
473
  interface MiniProgramPhoneParams {
458
474
  /** Code from getPhoneNumber button event */
459
475
  code: string;
476
+ /**
477
+ * Optional explicit platform override
478
+ * When omitted, the SDK will auto-detect the current mini-program runtime.
479
+ */
480
+ platform?: MiniProgramPlatform;
481
+ }
482
+ /**
483
+ * Mini Program phone event-like payload
484
+ * Compatible with WeChat `wx`, Douyin `tt`, and Taro event objects.
485
+ */
486
+ interface MiniGetPhoneEvent {
487
+ code?: string;
488
+ platform?: MiniProgramPlatform;
489
+ detail?: {
490
+ code?: string;
491
+ } | null;
460
492
  }
493
+ /**
494
+ * Unified Mini Program phone input
495
+ */
496
+ type MiniGetPhoneParams = string | MiniProgramPhoneParams | MiniGetPhoneEvent;
461
497
  /**
462
498
  * WeChat Mini Program phone number response
463
499
  */
@@ -539,4 +575,4 @@ interface RevokeAllSessionsResponse {
539
575
  revokedCount: number;
540
576
  }
541
577
 
542
- export type { AuthClientOptions as A, ChangePasswordParams as C, EventHandler as E, LoginParams as L, MiniProgramLoginParams as M, OAuthBinding as O, Permission as P, RefreshTokenResponse as R, SendCodeParams as S, UpdateMeParams as U, AuthEvent as a, CaptchaResponse as b, CodeLoginParams as c, CodeLoginType as d, LoginResponse as e, LoginType as f, MiniProgramPhoneParams as g, MiniProgramPhoneResponse as h, OAuthProvider as i, PermissionDetail as j, RegisterParams as k, RegisterResponse as l, RevokeAllSessionsResponse as m, Role as n, RoleDetail as o, SendCodeType as p, Session as q, SuccessResponse as r, User as s };
578
+ export type { AuthClientOptions as A, ChangePasswordParams as C, EventHandler as E, LoginParams as L, MiniGetPhoneEvent as M, OAuthBinding as O, Permission as P, RefreshTokenResponse as R, SendCodeParams as S, UpdateMeParams as U, AuthEvent as a, CaptchaResponse as b, CodeLoginParams as c, CodeLoginType as d, LoginResponse as e, LoginType as f, MiniGetPhoneParams as g, MiniLoginParams as h, MiniProgramLoginParams as i, MiniProgramPlatform as j, MiniProgramPhoneParams as k, MiniProgramPhoneResponse as l, OAuthProvider as m, PermissionDetail as n, RegisterParams as o, RegisterResponse as p, RevokeAllSessionsResponse as q, Role as r, RoleDetail as s, SendCodeType as t, Session as u, SuccessResponse as v, User as w };
package/dist/user.d.cts CHANGED
@@ -14,7 +14,7 @@
14
14
  * ============================================================================
15
15
  */
16
16
  import { HttpClient, ClientResult } from '@amaster.ai/http-client';
17
- import { s as User, U as UpdateMeParams, C as ChangePasswordParams, r as SuccessResponse } from './types-YfiSfMTJ.cjs';
17
+ import { w as User, U as UpdateMeParams, C as ChangePasswordParams, v as SuccessResponse } from './types-CsCZTBIx.cjs';
18
18
 
19
19
  /**
20
20
  * User Management Module
package/dist/user.d.ts CHANGED
@@ -14,7 +14,7 @@
14
14
  * ============================================================================
15
15
  */
16
16
  import { HttpClient, ClientResult } from '@amaster.ai/http-client';
17
- import { s as User, U as UpdateMeParams, C as ChangePasswordParams, r as SuccessResponse } from './types-YfiSfMTJ.js';
17
+ import { w as User, U as UpdateMeParams, C as ChangePasswordParams, v as SuccessResponse } from './types-CsCZTBIx.js';
18
18
 
19
19
  /**
20
20
  * User Management Module
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@amaster.ai/auth-client",
3
- "version": "1.1.2",
3
+ "version": "1.1.4",
4
4
  "description": "Authentication SDK for Amaster platform",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -8,9 +8,9 @@
8
8
  "types": "./dist/index.d.ts",
9
9
  "exports": {
10
10
  ".": {
11
+ "types": "./dist/index.d.ts",
11
12
  "import": "./dist/index.js",
12
- "require": "./dist/index.cjs",
13
- "types": "./dist/index.d.ts"
13
+ "require": "./dist/index.cjs"
14
14
  },
15
15
  "./auth": {
16
16
  "types": "./dist/auth.d.ts"
@@ -47,7 +47,7 @@
47
47
  "registry": "https://registry.npmjs.org/"
48
48
  },
49
49
  "dependencies": {
50
- "@amaster.ai/http-client": "1.1.2"
50
+ "@amaster.ai/http-client": "1.1.4"
51
51
  },
52
52
  "peerDependencies": {
53
53
  "axios": "^1.11.0"