@amaster.ai/auth-client 1.1.71 → 1.1.73
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/README.md +40 -0
- package/dist/auth.d.cts +12 -3
- package/dist/auth.d.ts +12 -3
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +81 -22
- package/dist/index.d.ts +81 -22
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/oauth.d.cts +1 -1
- package/dist/oauth.d.ts +1 -1
- package/dist/permissions.d.cts +3 -3
- package/dist/permissions.d.ts +3 -3
- package/dist/rbac.cjs +3 -0
- package/dist/rbac.cjs.map +1 -0
- package/dist/rbac.d.cts +552 -0
- package/dist/rbac.d.ts +552 -0
- package/dist/rbac.js +3 -0
- package/dist/rbac.js.map +1 -0
- package/dist/sessions.d.cts +1 -1
- package/dist/sessions.d.ts +1 -1
- package/dist/tenancy.cjs +2 -0
- package/dist/tenancy.cjs.map +1 -0
- package/dist/tenancy.d.cts +157 -0
- package/dist/tenancy.d.ts +157 -0
- package/dist/tenancy.js +2 -0
- package/dist/tenancy.js.map +1 -0
- package/dist/tenant-management.cjs +2 -0
- package/dist/tenant-management.cjs.map +1 -0
- package/dist/tenant-management.d.cts +167 -0
- package/dist/tenant-management.d.ts +167 -0
- package/dist/tenant-management.js +2 -0
- package/dist/tenant-management.js.map +1 -0
- package/dist/tenant-structure.d.cts +38 -0
- package/dist/tenant-structure.d.ts +38 -0
- package/dist/{types-okzoIgFt.d.cts → types-D5c61dWd.d.cts} +50 -3
- package/dist/{types-okzoIgFt.d.ts → types-D5c61dWd.d.ts} +50 -3
- package/dist/user.d.cts +3 -1
- package/dist/user.d.ts +3 -1
- package/package.json +17 -2
|
@@ -13,7 +13,40 @@
|
|
|
13
13
|
*
|
|
14
14
|
* ============================================================================
|
|
15
15
|
*/
|
|
16
|
-
import { MiniProgramRuntime } from '@amaster.ai/http-client';
|
|
16
|
+
import { ClientResult, MiniProgramRuntime } from '@amaster.ai/http-client';
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Storage adapter for token and user data persistence
|
|
20
|
+
* Auto-detects environment and uses appropriate storage:
|
|
21
|
+
* - Browser: localStorage
|
|
22
|
+
* - WeChat Mini Program: wx.setStorageSync/wx.getStorageSync
|
|
23
|
+
* - Douyin Mini Program: `tt.setStorageSync` / `tt.getStorageSync`
|
|
24
|
+
* - SSR/Node.js: No-op (no persistence)
|
|
25
|
+
*/
|
|
26
|
+
interface StorageAdapter {
|
|
27
|
+
getItem(key: string): string | null;
|
|
28
|
+
setItem(key: string, value: string): void;
|
|
29
|
+
removeItem(key: string): void;
|
|
30
|
+
clear(): void;
|
|
31
|
+
}
|
|
32
|
+
/** A separate instance per application; nothing is persisted in the host origin. */
|
|
33
|
+
declare function createMemoryStorage(): StorageAdapter;
|
|
34
|
+
/**
|
|
35
|
+
* Create a storage adapter that auto-detects environment
|
|
36
|
+
*
|
|
37
|
+
* @returns Storage adapter optimized for current environment
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```typescript
|
|
41
|
+
* const storage = createStorageAdapter();
|
|
42
|
+
*
|
|
43
|
+
* // Browser → uses localStorage
|
|
44
|
+
* // WeChat Mini Program → uses wx.setStorageSync
|
|
45
|
+
* // Douyin Mini Program -> uses tt.setStorageSync
|
|
46
|
+
* // SSR/Node.js → uses no-op (no persistence)
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
declare function createStorageAdapter(namespace?: string): StorageAdapter;
|
|
17
50
|
|
|
18
51
|
/**
|
|
19
52
|
* Authentication SDK Types
|
|
@@ -39,6 +72,14 @@ import { MiniProgramRuntime } from '@amaster.ai/http-client';
|
|
|
39
72
|
*
|
|
40
73
|
*/
|
|
41
74
|
interface AuthClientOptions {
|
|
75
|
+
storage?: StorageAdapter;
|
|
76
|
+
withCredentials?: boolean;
|
|
77
|
+
/** Isolate credentials by consumer application/environment. No legacy-key fallback. */
|
|
78
|
+
storageNamespace?: string;
|
|
79
|
+
/** A host using a separate authoritative account protocol can own initialization. */
|
|
80
|
+
syncUserOnInit?: boolean;
|
|
81
|
+
/** Verify consumer identity before committing a refreshed credential. */
|
|
82
|
+
verifyRefresh?: (accessToken: string) => Promise<ClientResult<unknown>>;
|
|
42
83
|
/** Disable when a trusted host manages access-token renewal externally. Defaults to true. */
|
|
43
84
|
autoRefresh?: boolean;
|
|
44
85
|
/**
|
|
@@ -98,6 +139,12 @@ interface AuthClientOptions {
|
|
|
98
139
|
*/
|
|
99
140
|
runtime?: Partial<MiniProgramRuntime>;
|
|
100
141
|
}
|
|
142
|
+
/** Explicit browser settings select the extended client overload. */
|
|
143
|
+
type BrowserAuthClientOptions = AuthClientOptions & ({
|
|
144
|
+
storage: StorageAdapter;
|
|
145
|
+
} | {
|
|
146
|
+
withCredentials: boolean;
|
|
147
|
+
});
|
|
101
148
|
/**
|
|
102
149
|
* User information with roles and permissions
|
|
103
150
|
*
|
|
@@ -561,7 +608,7 @@ interface Session {
|
|
|
561
608
|
/** Whether this is the current session */
|
|
562
609
|
isCurrent: boolean;
|
|
563
610
|
}
|
|
564
|
-
type AuthEvent = "login" | "logout" | "tokenExpired" | "tokenRefreshed" | "unauthorized";
|
|
611
|
+
type AuthEvent = "credentialsChanged" | "login" | "logout" | "tokenExpired" | "tokenRefreshed" | "unauthorized";
|
|
565
612
|
type EventHandler = (...args: any[]) => void;
|
|
566
613
|
/**
|
|
567
614
|
* Standard success response from backend
|
|
@@ -604,4 +651,4 @@ interface DepartmentPosition {
|
|
|
604
651
|
description?: string;
|
|
605
652
|
}
|
|
606
653
|
|
|
607
|
-
export type
|
|
654
|
+
export { type AuthEvent as A, type BrowserAuthClientOptions as B, type ChangePasswordParams as C, type DepartmentPosition as D, type EventHandler as E, type FeishuPublicConfig as F, createStorageAdapter as G, type LoginResponse as L, type MiniGetPhoneEvent as M, type OAuthBinding as O, type Permission as P, type RefreshTokenResponse as R, type StorageAdapter as S, type User as U, type AuthClientOptions as a, type CaptchaResponse as b, type CodeLoginParams as c, type CodeLoginType as d, type LoginParams as e, type LoginType as f, type MiniGetPhoneParams as g, type MiniLoginParams as h, type MiniProgramLoginParams as i, type MiniProgramPlatform as j, type MiniProgramPhoneParams as k, type MiniProgramPhoneResponse as l, type OAuthLoginTicketResponse as m, type OAuthProvider as n, type PermissionDetail as o, type RegisterParams as p, type RegisterResponse as q, type RevokeAllSessionsResponse as r, type Role as s, type RoleDetail as t, type SendCodeParams as u, type SendCodeType as v, type Session as w, type SuccessResponse as x, type UpdateMeParams as y, createMemoryStorage as z };
|
|
@@ -13,7 +13,40 @@
|
|
|
13
13
|
*
|
|
14
14
|
* ============================================================================
|
|
15
15
|
*/
|
|
16
|
-
import { MiniProgramRuntime } from '@amaster.ai/http-client';
|
|
16
|
+
import { ClientResult, MiniProgramRuntime } from '@amaster.ai/http-client';
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Storage adapter for token and user data persistence
|
|
20
|
+
* Auto-detects environment and uses appropriate storage:
|
|
21
|
+
* - Browser: localStorage
|
|
22
|
+
* - WeChat Mini Program: wx.setStorageSync/wx.getStorageSync
|
|
23
|
+
* - Douyin Mini Program: `tt.setStorageSync` / `tt.getStorageSync`
|
|
24
|
+
* - SSR/Node.js: No-op (no persistence)
|
|
25
|
+
*/
|
|
26
|
+
interface StorageAdapter {
|
|
27
|
+
getItem(key: string): string | null;
|
|
28
|
+
setItem(key: string, value: string): void;
|
|
29
|
+
removeItem(key: string): void;
|
|
30
|
+
clear(): void;
|
|
31
|
+
}
|
|
32
|
+
/** A separate instance per application; nothing is persisted in the host origin. */
|
|
33
|
+
declare function createMemoryStorage(): StorageAdapter;
|
|
34
|
+
/**
|
|
35
|
+
* Create a storage adapter that auto-detects environment
|
|
36
|
+
*
|
|
37
|
+
* @returns Storage adapter optimized for current environment
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```typescript
|
|
41
|
+
* const storage = createStorageAdapter();
|
|
42
|
+
*
|
|
43
|
+
* // Browser → uses localStorage
|
|
44
|
+
* // WeChat Mini Program → uses wx.setStorageSync
|
|
45
|
+
* // Douyin Mini Program -> uses tt.setStorageSync
|
|
46
|
+
* // SSR/Node.js → uses no-op (no persistence)
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
declare function createStorageAdapter(namespace?: string): StorageAdapter;
|
|
17
50
|
|
|
18
51
|
/**
|
|
19
52
|
* Authentication SDK Types
|
|
@@ -39,6 +72,14 @@ import { MiniProgramRuntime } from '@amaster.ai/http-client';
|
|
|
39
72
|
*
|
|
40
73
|
*/
|
|
41
74
|
interface AuthClientOptions {
|
|
75
|
+
storage?: StorageAdapter;
|
|
76
|
+
withCredentials?: boolean;
|
|
77
|
+
/** Isolate credentials by consumer application/environment. No legacy-key fallback. */
|
|
78
|
+
storageNamespace?: string;
|
|
79
|
+
/** A host using a separate authoritative account protocol can own initialization. */
|
|
80
|
+
syncUserOnInit?: boolean;
|
|
81
|
+
/** Verify consumer identity before committing a refreshed credential. */
|
|
82
|
+
verifyRefresh?: (accessToken: string) => Promise<ClientResult<unknown>>;
|
|
42
83
|
/** Disable when a trusted host manages access-token renewal externally. Defaults to true. */
|
|
43
84
|
autoRefresh?: boolean;
|
|
44
85
|
/**
|
|
@@ -98,6 +139,12 @@ interface AuthClientOptions {
|
|
|
98
139
|
*/
|
|
99
140
|
runtime?: Partial<MiniProgramRuntime>;
|
|
100
141
|
}
|
|
142
|
+
/** Explicit browser settings select the extended client overload. */
|
|
143
|
+
type BrowserAuthClientOptions = AuthClientOptions & ({
|
|
144
|
+
storage: StorageAdapter;
|
|
145
|
+
} | {
|
|
146
|
+
withCredentials: boolean;
|
|
147
|
+
});
|
|
101
148
|
/**
|
|
102
149
|
* User information with roles and permissions
|
|
103
150
|
*
|
|
@@ -561,7 +608,7 @@ interface Session {
|
|
|
561
608
|
/** Whether this is the current session */
|
|
562
609
|
isCurrent: boolean;
|
|
563
610
|
}
|
|
564
|
-
type AuthEvent = "login" | "logout" | "tokenExpired" | "tokenRefreshed" | "unauthorized";
|
|
611
|
+
type AuthEvent = "credentialsChanged" | "login" | "logout" | "tokenExpired" | "tokenRefreshed" | "unauthorized";
|
|
565
612
|
type EventHandler = (...args: any[]) => void;
|
|
566
613
|
/**
|
|
567
614
|
* Standard success response from backend
|
|
@@ -604,4 +651,4 @@ interface DepartmentPosition {
|
|
|
604
651
|
description?: string;
|
|
605
652
|
}
|
|
606
653
|
|
|
607
|
-
export type
|
|
654
|
+
export { type AuthEvent as A, type BrowserAuthClientOptions as B, type ChangePasswordParams as C, type DepartmentPosition as D, type EventHandler as E, type FeishuPublicConfig as F, createStorageAdapter as G, type LoginResponse as L, type MiniGetPhoneEvent as M, type OAuthBinding as O, type Permission as P, type RefreshTokenResponse as R, type StorageAdapter as S, type User as U, type AuthClientOptions as a, type CaptchaResponse as b, type CodeLoginParams as c, type CodeLoginType as d, type LoginParams as e, type LoginType as f, type MiniGetPhoneParams as g, type MiniLoginParams as h, type MiniProgramLoginParams as i, type MiniProgramPlatform as j, type MiniProgramPhoneParams as k, type MiniProgramPhoneResponse as l, type OAuthLoginTicketResponse as m, type OAuthProvider as n, type PermissionDetail as o, type RegisterParams as p, type RegisterResponse as q, type RevokeAllSessionsResponse as r, type Role as s, type RoleDetail as t, type SendCodeParams as u, type SendCodeType as v, type Session as w, type SuccessResponse as x, type UpdateMeParams as y, createMemoryStorage as z };
|
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 {
|
|
17
|
+
import { U as User, y as UpdateMeParams, C as ChangePasswordParams, x as SuccessResponse } from './types-D5c61dWd.cjs';
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
20
|
* User Management Module
|
|
@@ -35,7 +35,9 @@ interface UserModuleDeps {
|
|
|
35
35
|
setItem: (key: string, value: string) => void;
|
|
36
36
|
};
|
|
37
37
|
onUserUpdate: (user: User) => void;
|
|
38
|
+
getAuthVersion?: () => number | undefined;
|
|
38
39
|
onAuthFailure?: (result: ClientResult<User>) => void;
|
|
40
|
+
isCurrentResult?: (result: ClientResult<unknown>) => boolean;
|
|
39
41
|
}
|
|
40
42
|
declare function createUserModule(deps: UserModuleDeps): {
|
|
41
43
|
/**
|
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 {
|
|
17
|
+
import { U as User, y as UpdateMeParams, C as ChangePasswordParams, x as SuccessResponse } from './types-D5c61dWd.js';
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
20
|
* User Management Module
|
|
@@ -35,7 +35,9 @@ interface UserModuleDeps {
|
|
|
35
35
|
setItem: (key: string, value: string) => void;
|
|
36
36
|
};
|
|
37
37
|
onUserUpdate: (user: User) => void;
|
|
38
|
+
getAuthVersion?: () => number | undefined;
|
|
38
39
|
onAuthFailure?: (result: ClientResult<User>) => void;
|
|
40
|
+
isCurrentResult?: (result: ClientResult<unknown>) => boolean;
|
|
39
41
|
}
|
|
40
42
|
declare function createUserModule(deps: UserModuleDeps): {
|
|
41
43
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@amaster.ai/auth-client",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.73",
|
|
4
4
|
"description": "Authentication SDK for Amaster platform",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -26,6 +26,21 @@
|
|
|
26
26
|
},
|
|
27
27
|
"./sessions": {
|
|
28
28
|
"types": "./dist/sessions.d.ts"
|
|
29
|
+
},
|
|
30
|
+
"./rbac": {
|
|
31
|
+
"types": "./dist/rbac.d.ts",
|
|
32
|
+
"import": "./dist/rbac.js",
|
|
33
|
+
"require": "./dist/rbac.cjs"
|
|
34
|
+
},
|
|
35
|
+
"./tenancy": {
|
|
36
|
+
"types": "./dist/tenancy.d.ts",
|
|
37
|
+
"import": "./dist/tenancy.js",
|
|
38
|
+
"require": "./dist/tenancy.cjs"
|
|
39
|
+
},
|
|
40
|
+
"./tenant-management": {
|
|
41
|
+
"types": "./dist/tenant-management.d.ts",
|
|
42
|
+
"import": "./dist/tenant-management.js",
|
|
43
|
+
"require": "./dist/tenant-management.cjs"
|
|
29
44
|
}
|
|
30
45
|
},
|
|
31
46
|
"files": [
|
|
@@ -47,7 +62,7 @@
|
|
|
47
62
|
"registry": "https://registry.npmjs.org/"
|
|
48
63
|
},
|
|
49
64
|
"dependencies": {
|
|
50
|
-
"@amaster.ai/http-client": "1.1.
|
|
65
|
+
"@amaster.ai/http-client": "1.1.73"
|
|
51
66
|
},
|
|
52
67
|
"peerDependencies": {
|
|
53
68
|
"axios": "^1.11.0"
|