tale-js-sdk 0.1.2 → 0.1.3
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/dist/acl/index.d.ts +170 -0
- package/dist/acl/index.js +747 -0
- package/dist/acl/types.d.ts +208 -0
- package/dist/acl/types.js +1 -0
- package/dist/auth/index.d.ts +2 -134
- package/dist/auth/index.js +120 -96
- package/dist/auth/types.d.ts +122 -0
- package/dist/auth/types.js +1 -0
- package/dist/common/types.d.ts +76 -0
- package/dist/common/types.js +3 -0
- package/dist/errors.js +18 -18
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/rbac/acl.d.ts +152 -0
- package/dist/rbac/acl.js +723 -0
- package/dist/rbac/index.d.ts +2 -0
- package/dist/rbac/index.js +2 -0
- package/dist/rbac/rbac.d.ts +198 -0
- package/dist/rbac/rbac.js +984 -0
- package/dist/rbac/types.d.ts +356 -0
- package/dist/rbac/types.js +1 -0
- package/dist/rbac/user-group.d.ts +122 -0
- package/dist/rbac/user-group.js +570 -0
- package/dist/status.js +3 -3
- package/dist/token.d.ts +1 -1
- package/dist/token.js +5 -4
- package/dist/user/index.d.ts +2 -142
- package/dist/user/index.js +60 -59
- package/dist/user/types.d.ts +96 -0
- package/dist/user/types.js +1 -0
- package/dist/user-group/index.d.ts +230 -0
- package/dist/user-group/index.js +560 -0
- package/dist/user-group/types.d.ts +61 -0
- package/dist/user-group/types.js +1 -0
- package/package.json +13 -14
- package/dist/auth.d.ts +0 -271
- package/dist/auth.js +0 -461
- package/dist/client.d.ts +0 -20
- package/dist/client.js +0 -62
- package/dist/info.d.ts +0 -9
- package/dist/info.js +0 -18
- package/dist/package.json +0 -36
- package/dist/src/index.d.ts +0 -1
- package/dist/src/index.js +0 -1
- package/dist/src/info.d.ts +0 -6
- package/dist/src/info.js +0 -4
- package/dist/user.d.ts +0 -242
- package/dist/user.js +0 -331
package/dist/auth.d.ts
DELETED
|
@@ -1,271 +0,0 @@
|
|
|
1
|
-
export interface LoginRequest {
|
|
2
|
-
username: string;
|
|
3
|
-
password: string;
|
|
4
|
-
app_key?: string;
|
|
5
|
-
}
|
|
6
|
-
export interface LoginOptions {
|
|
7
|
-
baseUrl?: string;
|
|
8
|
-
appKey?: string;
|
|
9
|
-
device_name?: string;
|
|
10
|
-
device_fingerprint?: string;
|
|
11
|
-
scope?: string;
|
|
12
|
-
}
|
|
13
|
-
export interface SendSmsOptions {
|
|
14
|
-
baseUrl?: string;
|
|
15
|
-
appKey?: string;
|
|
16
|
-
}
|
|
17
|
-
export interface VerifySmsOptions {
|
|
18
|
-
baseUrl?: string;
|
|
19
|
-
appKey?: string;
|
|
20
|
-
device_name?: string;
|
|
21
|
-
device_fingerprint?: string;
|
|
22
|
-
scope?: string;
|
|
23
|
-
}
|
|
24
|
-
export interface AuthAppInfo {
|
|
25
|
-
app_id: string;
|
|
26
|
-
org_id: string;
|
|
27
|
-
app_key: string;
|
|
28
|
-
app_name: string;
|
|
29
|
-
}
|
|
30
|
-
export interface AuthUser {
|
|
31
|
-
user_id: string;
|
|
32
|
-
nick_name: string;
|
|
33
|
-
avatar_url: string;
|
|
34
|
-
username: string;
|
|
35
|
-
email: string;
|
|
36
|
-
phone: string;
|
|
37
|
-
registered_at: string;
|
|
38
|
-
remark: string;
|
|
39
|
-
is_frozen: boolean;
|
|
40
|
-
latest_login_time?: string;
|
|
41
|
-
}
|
|
42
|
-
export interface UserToken {
|
|
43
|
-
token: string;
|
|
44
|
-
scope: string;
|
|
45
|
-
device_name?: string;
|
|
46
|
-
device_fingerprint?: string;
|
|
47
|
-
granted_at: string;
|
|
48
|
-
expired_at: string;
|
|
49
|
-
}
|
|
50
|
-
export interface AuthRole {
|
|
51
|
-
role_id: string;
|
|
52
|
-
role_name: string;
|
|
53
|
-
description?: string;
|
|
54
|
-
assigned_at: string;
|
|
55
|
-
expires_at?: string;
|
|
56
|
-
is_active: boolean;
|
|
57
|
-
}
|
|
58
|
-
export interface AuthPrivilege {
|
|
59
|
-
privilege_id: string;
|
|
60
|
-
privilege_name: string;
|
|
61
|
-
description?: string;
|
|
62
|
-
granted_directly: boolean;
|
|
63
|
-
role_id?: string;
|
|
64
|
-
assigned_at: string;
|
|
65
|
-
expires_at?: string;
|
|
66
|
-
is_active: boolean;
|
|
67
|
-
}
|
|
68
|
-
export interface AuthUserGroup {
|
|
69
|
-
group_id: string;
|
|
70
|
-
group_name: string;
|
|
71
|
-
description?: string;
|
|
72
|
-
}
|
|
73
|
-
export interface AuthUserLoginMethod {
|
|
74
|
-
method_type: string;
|
|
75
|
-
identifier: string;
|
|
76
|
-
is_active: boolean;
|
|
77
|
-
created_at: string;
|
|
78
|
-
last_used_at?: string;
|
|
79
|
-
}
|
|
80
|
-
export interface LoginResponse {
|
|
81
|
-
app: AuthAppInfo;
|
|
82
|
-
user: AuthUser;
|
|
83
|
-
token: UserToken;
|
|
84
|
-
user_roles: AuthRole[];
|
|
85
|
-
user_privileges: AuthPrivilege[];
|
|
86
|
-
user_groups: AuthUserGroup[];
|
|
87
|
-
user_login_methods: AuthUserLoginMethod[];
|
|
88
|
-
}
|
|
89
|
-
export interface LoginJson {
|
|
90
|
-
app: AuthAppInfo;
|
|
91
|
-
user: AuthUser;
|
|
92
|
-
token: UserToken;
|
|
93
|
-
user_roles: AuthRole[];
|
|
94
|
-
user_privileges: AuthPrivilege[];
|
|
95
|
-
user_groups: AuthUserGroup[];
|
|
96
|
-
user_login_methods: AuthUserLoginMethod[];
|
|
97
|
-
}
|
|
98
|
-
export interface SendSmsResponse {
|
|
99
|
-
app_key: string;
|
|
100
|
-
phone: string;
|
|
101
|
-
type: 'login' | 'register';
|
|
102
|
-
sms_id: string;
|
|
103
|
-
expired_at: string;
|
|
104
|
-
}
|
|
105
|
-
export interface SendSmsJson {
|
|
106
|
-
app_key: string;
|
|
107
|
-
phone: string;
|
|
108
|
-
type: 'login' | 'register';
|
|
109
|
-
sms_id: string;
|
|
110
|
-
expired_at: string;
|
|
111
|
-
}
|
|
112
|
-
export interface VerifySmsRequest {
|
|
113
|
-
sms_id: string;
|
|
114
|
-
sms_type: 'login' | 'register';
|
|
115
|
-
verification_code: string;
|
|
116
|
-
username?: string;
|
|
117
|
-
password_encrypted?: string;
|
|
118
|
-
}
|
|
119
|
-
export interface SmsLoginResponse {
|
|
120
|
-
app: AuthAppInfo;
|
|
121
|
-
user: AuthUser;
|
|
122
|
-
token: UserToken;
|
|
123
|
-
user_roles: AuthRole[];
|
|
124
|
-
user_privileges: AuthPrivilege[];
|
|
125
|
-
user_groups: AuthUserGroup[];
|
|
126
|
-
user_login_methods: AuthUserLoginMethod[];
|
|
127
|
-
}
|
|
128
|
-
export interface SmsLoginJson {
|
|
129
|
-
app: AuthAppInfo;
|
|
130
|
-
user: AuthUser;
|
|
131
|
-
token: UserToken;
|
|
132
|
-
user_roles: AuthRole[];
|
|
133
|
-
user_privileges: AuthPrivilege[];
|
|
134
|
-
user_groups: AuthUserGroup[];
|
|
135
|
-
user_login_methods: AuthUserLoginMethod[];
|
|
136
|
-
}
|
|
137
|
-
/**
|
|
138
|
-
* Authenticates a user with username and password.
|
|
139
|
-
*
|
|
140
|
-
* @param credentials - User login credentials
|
|
141
|
-
* @param options - Optional configuration for the login request
|
|
142
|
-
* @returns Promise resolving to login response with user info and token
|
|
143
|
-
* @throws {ConfigurationError} When required environment variables are missing
|
|
144
|
-
* @throws {ApiError} When authentication fails or returns invalid response
|
|
145
|
-
* @throws {NetworkError} When network request fails
|
|
146
|
-
*
|
|
147
|
-
* @example
|
|
148
|
-
* ```typescript
|
|
149
|
-
* import { login } from '@tale/client';
|
|
150
|
-
*
|
|
151
|
-
* try {
|
|
152
|
-
* const result = await login({
|
|
153
|
-
* username: 'johndoe',
|
|
154
|
-
* password: 'secure_password_123'
|
|
155
|
-
* });
|
|
156
|
-
* console.log('Login successful:', result.user.username);
|
|
157
|
-
* console.log('User token:', result.token.token);
|
|
158
|
-
* } catch (error) {
|
|
159
|
-
* console.error('Login failed:', error.message);
|
|
160
|
-
* }
|
|
161
|
-
* ```
|
|
162
|
-
*/
|
|
163
|
-
export declare function login(credentials: LoginRequest, options?: LoginOptions): Promise<LoginResponse>;
|
|
164
|
-
/**
|
|
165
|
-
* Validates a user token.
|
|
166
|
-
*
|
|
167
|
-
* @param token - User token to validate
|
|
168
|
-
* @param options - Optional configuration for validation
|
|
169
|
-
* @returns Promise resolving to validation result
|
|
170
|
-
* @throws {ConfigurationError} When required environment variables are missing
|
|
171
|
-
* @throws {ApiError} When validation fails
|
|
172
|
-
* @throws {NetworkError} When network request fails
|
|
173
|
-
*
|
|
174
|
-
* @example
|
|
175
|
-
* ```typescript
|
|
176
|
-
* import { validateToken } from '@tale/client';
|
|
177
|
-
*
|
|
178
|
-
* try {
|
|
179
|
-
* const result = await validateToken('tu_user_token_here');
|
|
180
|
-
* console.log('Token is valid');
|
|
181
|
-
* } catch (error) {
|
|
182
|
-
* console.error('Token validation failed:', error.message);
|
|
183
|
-
* }
|
|
184
|
-
* ```
|
|
185
|
-
*/
|
|
186
|
-
export declare function validateToken(token: string, options?: {
|
|
187
|
-
scope?: string;
|
|
188
|
-
baseUrl?: string;
|
|
189
|
-
}): Promise<boolean>;
|
|
190
|
-
/**
|
|
191
|
-
* Sends SMS verification code for login or registration.
|
|
192
|
-
*
|
|
193
|
-
* @param phone - Phone number for sending SMS
|
|
194
|
-
* @param options - Optional configuration for the request
|
|
195
|
-
* @returns Promise resolving to SMS sending response
|
|
196
|
-
* @throws {ConfigurationError} When required environment variables are missing
|
|
197
|
-
* @throws {ApiError} When SMS sending fails or returns invalid response
|
|
198
|
-
* @throws {NetworkError} When network request fails
|
|
199
|
-
*
|
|
200
|
-
* @example
|
|
201
|
-
* ```typescript
|
|
202
|
-
* import { sendSmsVerification } from '@tale/client';
|
|
203
|
-
*
|
|
204
|
-
* try {
|
|
205
|
-
* const result = await sendSmsVerification('+8613800138000');
|
|
206
|
-
* console.log('SMS sent:', result.sms_id);
|
|
207
|
-
* console.log('Type:', result.type); // 'login' or 'register'
|
|
208
|
-
* } catch (error) {
|
|
209
|
-
* console.error('SMS sending failed:', error.message);
|
|
210
|
-
* }
|
|
211
|
-
* ```
|
|
212
|
-
*/
|
|
213
|
-
export declare function sendSmsVerification(phone: string, options?: SendSmsOptions): Promise<SendSmsResponse>;
|
|
214
|
-
/**
|
|
215
|
-
* Verifies SMS code and authenticates user (login or register).
|
|
216
|
-
*
|
|
217
|
-
* @param request - SMS verification request with sms_id, code, and optional user data
|
|
218
|
-
* @param options - Optional configuration for the request
|
|
219
|
-
* @returns Promise resolving to login response with user info and token
|
|
220
|
-
* @throws {ConfigurationError} When required environment variables are missing
|
|
221
|
-
* @throws {ApiError} When verification fails or returns invalid response
|
|
222
|
-
* @throws {NetworkError} When network request fails
|
|
223
|
-
*
|
|
224
|
-
* @example
|
|
225
|
-
* ```typescript
|
|
226
|
-
* import { verifySmsCode } from '@tale/client';
|
|
227
|
-
*
|
|
228
|
-
* try {
|
|
229
|
-
* const result = await verifySmsCode({
|
|
230
|
-
* sms_id: 'uuid-here',
|
|
231
|
-
* sms_type: 'login',
|
|
232
|
-
* verification_code: '123456'
|
|
233
|
-
* });
|
|
234
|
-
* console.log('Login successful:', result.user.user_id);
|
|
235
|
-
* console.log('User token:', result.token.token);
|
|
236
|
-
* } catch (error) {
|
|
237
|
-
* console.error('SMS verification failed:', error.message);
|
|
238
|
-
* }
|
|
239
|
-
* ```
|
|
240
|
-
*/
|
|
241
|
-
export declare function verifySmsCode(request: VerifySmsRequest, options?: VerifySmsOptions): Promise<SmsLoginResponse>;
|
|
242
|
-
/**
|
|
243
|
-
* Registers a new user with SMS verification and optional additional information.
|
|
244
|
-
*
|
|
245
|
-
* @param request - Registration request with SMS verification and optional user data
|
|
246
|
-
* @param options - Optional configuration for the request
|
|
247
|
-
* @returns Promise resolving to registration response with user info and token
|
|
248
|
-
* @throws {ConfigurationError} When required environment variables are missing
|
|
249
|
-
* @throws {ApiError} When registration fails or returns invalid response
|
|
250
|
-
* @throws {NetworkError} When network request fails
|
|
251
|
-
*
|
|
252
|
-
* @example
|
|
253
|
-
* ```typescript
|
|
254
|
-
* import { registerWithSms } from '@tale/client';
|
|
255
|
-
*
|
|
256
|
-
* try {
|
|
257
|
-
* const result = await registerWithSms({
|
|
258
|
-
* sms_id: 'uuid-here',
|
|
259
|
-
* sms_type: 'register',
|
|
260
|
-
* verification_code: '123456',
|
|
261
|
-
* username: 'newuser',
|
|
262
|
-
* password_encrypted: 'encrypted_password'
|
|
263
|
-
* });
|
|
264
|
-
* console.log('Registration successful:', result.user.user_id);
|
|
265
|
-
* console.log('User token:', result.token.token);
|
|
266
|
-
* } catch (error) {
|
|
267
|
-
* console.error('Registration failed:', error.message);
|
|
268
|
-
* }
|
|
269
|
-
* ```
|
|
270
|
-
*/
|
|
271
|
-
export declare function registerWithSms(request: VerifySmsRequest, options?: VerifySmsOptions): Promise<SmsLoginResponse>;
|