@amaster.ai/auth-client 1.1.0-beta.73 → 1.1.0-beta.74

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.
@@ -13,9 +13,12 @@
13
13
  *
14
14
  * ============================================================================
15
15
  */
16
+ import { MiniProgramRuntime } from '@amaster.ai/http-client';
17
+
16
18
  /**
17
19
  * Authentication SDK Types
18
20
  */
21
+
19
22
  /**
20
23
  * Authentication client configuration options
21
24
  *
@@ -34,13 +37,6 @@
34
37
  * });
35
38
  * ```
36
39
  *
37
- * @example
38
- * With custom base URL:
39
- * ```typescript
40
- * const authClient = createAuthClient({
41
- * baseURL: "https://api.example.com",
42
- * });
43
- * ```
44
40
  */
45
41
  interface AuthClientOptions {
46
42
  /**
@@ -93,6 +89,10 @@ interface AuthClientOptions {
93
89
  * @default true
94
90
  */
95
91
  autoRedirectAfterLogin?: boolean;
92
+ /**
93
+ * Explicitly provide the Taro runtime object when it is not exposed on `globalThis`.
94
+ */
95
+ runtime?: Partial<MiniProgramRuntime>;
96
96
  }
97
97
  /**
98
98
  * User information with roles and permissions
@@ -332,6 +332,17 @@ interface LoginResponse {
332
332
  accessToken: string;
333
333
  /** Token expiration time in seconds */
334
334
  expiresIn?: number;
335
+ /**
336
+ * Whether the SDK has already consumed the current page's `?redirect=...`
337
+ * and started browser navigation.
338
+ *
339
+ * Use this to avoid running application-level success redirects twice.
340
+ */
341
+ redirectHandled?: boolean;
342
+ /**
343
+ * The redirect target consumed by the SDK when `redirectHandled` is `true`.
344
+ */
345
+ redirectTarget?: string;
335
346
  }
336
347
  /**
337
348
  * Register response - user and accessToken are optional
@@ -395,7 +406,7 @@ interface ChangePasswordParams {
395
406
  * - google: Google OAuth
396
407
  * - github: GitHub OAuth
397
408
  * - wechat: WeChat Open Platform OAuth (for web/mobile apps)
398
- * - wechat_mini: WeChat Mini Program login
409
+ * - wechat_mini: legacy mini-program provider marker kept for compatibility
399
410
  * - platform: AMaster Platform OAuth
400
411
  */
401
412
  type OAuthProvider = "google" | "github" | "wechat" | "wechat_mini" | "platform";
@@ -407,6 +418,89 @@ interface OAuthBinding {
407
418
  avatarUrl: string | null;
408
419
  createdAt: string;
409
420
  }
421
+ /**
422
+ * Mini Program platform type
423
+ * - wechat: WeChat Mini Program
424
+ * - douyin: Douyin Mini Program
425
+ */
426
+ type MiniProgramPlatform = "wechat" | "douyin";
427
+ /**
428
+ * Unified Mini Program login options
429
+ */
430
+ interface MiniLoginParams {
431
+ /**
432
+ * Optional explicit platform override.
433
+ * When omitted, the SDK auto-detects the current mini-program runtime.
434
+ */
435
+ platform?: MiniProgramPlatform;
436
+ }
437
+ /**
438
+ * Mini Program login parameters
439
+ * @example
440
+ * ```typescript
441
+ * // WeChat
442
+ * await authClient.miniLogin();
443
+ *
444
+ * // Douyin
445
+ * await authClient.miniLogin({
446
+ * platform: "douyin",
447
+ * });
448
+ * ```
449
+ */
450
+ interface MiniProgramLoginParams {
451
+ /** Code from mini-program login API, valid for a short time */
452
+ code: string;
453
+ /**
454
+ * Optional explicit platform override
455
+ * When omitted, the SDK will auto-detect the current mini-program runtime.
456
+ */
457
+ platform?: MiniProgramPlatform;
458
+ }
459
+ /**
460
+ * Mini Program phone number parameters
461
+ * @example
462
+ * ```typescript
463
+ * // WeChat WXML
464
+ * <button open-type="getPhoneNumber" bindgetphonenumber="onGetPhoneNumber">
465
+ * Get Phone Number
466
+ * </button>
467
+ *
468
+ * // JS
469
+ * async onGetPhoneNumber(e) {
470
+ * await authClient.miniGetPhone(e);
471
+ * }
472
+ *
473
+ * // Douyin
474
+ * await authClient.miniGetPhone({
475
+ * code,
476
+ * platform: "douyin",
477
+ * });
478
+ * ```
479
+ */
480
+ interface MiniProgramPhoneParams {
481
+ /** Code from getPhoneNumber button event */
482
+ code: string;
483
+ /**
484
+ * Optional explicit platform override
485
+ * When omitted, the SDK will auto-detect the current mini-program runtime.
486
+ */
487
+ platform?: MiniProgramPlatform;
488
+ }
489
+ /**
490
+ * Mini Program phone event-like payload
491
+ * Compatible with WeChat `wx`, Douyin `tt`, and Taro event objects.
492
+ */
493
+ interface MiniGetPhoneEvent {
494
+ code?: string;
495
+ platform?: MiniProgramPlatform;
496
+ detail?: {
497
+ code?: string;
498
+ } | null;
499
+ }
500
+ /**
501
+ * Unified Mini Program phone input
502
+ */
503
+ type MiniGetPhoneParams = string | MiniProgramPhoneParams | MiniGetPhoneEvent;
410
504
  /**
411
505
  * WeChat Mini Program phone number response
412
506
  */
@@ -488,4 +582,4 @@ interface RevokeAllSessionsResponse {
488
582
  revokedCount: number;
489
583
  }
490
584
 
491
- export type { AuthClientOptions as A, ChangePasswordParams as C, EventHandler as E, LoginParams as L, MiniProgramPhoneResponse 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, OAuthProvider as g, PermissionDetail as h, RegisterParams as i, RegisterResponse as j, RevokeAllSessionsResponse as k, Role as l, RoleDetail as m, SendCodeType as n, Session as o, SuccessResponse as p, User as q };
585
+ 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 { q as User, U as UpdateMeParams, C as ChangePasswordParams, p as SuccessResponse } from './types-DGF9cpAg.cjs';
17
+ import { w as User, U as UpdateMeParams, C as ChangePasswordParams, v as SuccessResponse } from './types-DqwQ2EzH.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 { q as User, U as UpdateMeParams, C as ChangePasswordParams, p as SuccessResponse } from './types-DGF9cpAg.js';
17
+ import { w as User, U as UpdateMeParams, C as ChangePasswordParams, v as SuccessResponse } from './types-DqwQ2EzH.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.0-beta.73",
3
+ "version": "1.1.0-beta.74",
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.0-beta.73"
50
+ "@amaster.ai/http-client": "1.1.0-beta.74"
51
51
  },
52
52
  "peerDependencies": {
53
53
  "axios": "^1.11.0"