swiftbase-admin-sdk 1.0.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.
- package/LICENSE +19 -0
- package/README.md +224 -0
- package/dist/index.cjs +4718 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +360 -0
- package/dist/index.d.ts +360 -0
- package/dist/index.js +4688 -0
- package/dist/index.js.map +1 -0
- package/package.json +47 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,360 @@
|
|
|
1
|
+
declare class Token {
|
|
2
|
+
#private;
|
|
3
|
+
constructor(token: string, type: string, expiration?: number);
|
|
4
|
+
private decodeExpiration;
|
|
5
|
+
/**
|
|
6
|
+
* Getter for the raw token
|
|
7
|
+
*
|
|
8
|
+
* @returns {string} The token
|
|
9
|
+
*/
|
|
10
|
+
value(): string;
|
|
11
|
+
/**
|
|
12
|
+
* Checks if the token is valid
|
|
13
|
+
*
|
|
14
|
+
* @returns {boolean} True if the API key is valid, false otherwise
|
|
15
|
+
*/
|
|
16
|
+
isValid(): boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Checks if the API key is a secret key
|
|
19
|
+
*
|
|
20
|
+
* @returns {boolean} True if the API key is a secret key, false otherwise
|
|
21
|
+
*/
|
|
22
|
+
isAccessToken(): boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Checks if the API key is a public key
|
|
25
|
+
*
|
|
26
|
+
* @returns {boolean} True if the API key is a public key, false otherwise
|
|
27
|
+
*/
|
|
28
|
+
isRefreshToken(): boolean;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
interface SwiftbaseApp {
|
|
32
|
+
projectId: string;
|
|
33
|
+
baseUrl: string;
|
|
34
|
+
accessToken: Token | null;
|
|
35
|
+
serviceId?: string;
|
|
36
|
+
serviceKey?: string;
|
|
37
|
+
debounceTimeout: number;
|
|
38
|
+
cacheArticles: boolean;
|
|
39
|
+
searchCacheEnabled: boolean;
|
|
40
|
+
searchCacheCapacity: number;
|
|
41
|
+
}
|
|
42
|
+
interface initializeSdkOptions {
|
|
43
|
+
baseUrl: string;
|
|
44
|
+
serviceId?: string;
|
|
45
|
+
serviceKey?: string;
|
|
46
|
+
debounceTimeout?: number;
|
|
47
|
+
cacheArticles?: boolean;
|
|
48
|
+
searchCacheEnabled?: boolean;
|
|
49
|
+
searchCacheCapacity?: number;
|
|
50
|
+
}
|
|
51
|
+
declare const app: SwiftbaseApp;
|
|
52
|
+
declare const initializeSdk: (projectId: string, options: initializeSdkOptions) => void;
|
|
53
|
+
declare const setAccessToken: (token: string, expiration?: number) => void;
|
|
54
|
+
declare const isLoggedIn: () => boolean;
|
|
55
|
+
declare const logout: () => void;
|
|
56
|
+
|
|
57
|
+
interface RESTPaginatedResponse<T> {
|
|
58
|
+
data: T[];
|
|
59
|
+
meta: {
|
|
60
|
+
total: number;
|
|
61
|
+
page: number;
|
|
62
|
+
limit: number;
|
|
63
|
+
next: string | null;
|
|
64
|
+
back: string | null;
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
declare class PaginatedResponse<T> {
|
|
68
|
+
#private;
|
|
69
|
+
constructor(response: RESTPaginatedResponse<T>);
|
|
70
|
+
get items(): T[];
|
|
71
|
+
get total(): number;
|
|
72
|
+
get page(): number;
|
|
73
|
+
get limit(): number;
|
|
74
|
+
get hasNext(): boolean;
|
|
75
|
+
get hasBack(): boolean;
|
|
76
|
+
next(): Promise<PaginatedResponse<T> | null>;
|
|
77
|
+
back(): Promise<PaginatedResponse<T> | null>;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Login as a service
|
|
82
|
+
*
|
|
83
|
+
* @param {string} serviceId The service ID
|
|
84
|
+
* @param {string} secretKey The service secret key
|
|
85
|
+
*
|
|
86
|
+
* @returns {Promise<void>}
|
|
87
|
+
*/
|
|
88
|
+
declare const login: (serviceId: string, secretKey: string) => Promise<void>;
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Get a valid access token.
|
|
92
|
+
* If the current token is missing or expired, it will attempt to login again
|
|
93
|
+
* using the stored serviceId and serviceKey.
|
|
94
|
+
*
|
|
95
|
+
* @returns {Promise<string | null>} The access token
|
|
96
|
+
*/
|
|
97
|
+
declare const getAccessToken: () => Promise<string | null>;
|
|
98
|
+
|
|
99
|
+
interface User$1 {
|
|
100
|
+
id: string;
|
|
101
|
+
email: string;
|
|
102
|
+
firstName?: string;
|
|
103
|
+
lastName?: string;
|
|
104
|
+
avatar?: string;
|
|
105
|
+
projectId?: string;
|
|
106
|
+
roles?: string[];
|
|
107
|
+
approved?: boolean;
|
|
108
|
+
attributes?: Record<string, any>;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Verify a user's access token
|
|
113
|
+
*
|
|
114
|
+
* @param {string} token The access token to verify
|
|
115
|
+
*
|
|
116
|
+
* @returns {Promise<User>} The user associated with the token
|
|
117
|
+
*/
|
|
118
|
+
declare const verifyToken: (token: string) => Promise<User$1>;
|
|
119
|
+
|
|
120
|
+
interface Role {
|
|
121
|
+
id: string;
|
|
122
|
+
name: string;
|
|
123
|
+
permissions: string[];
|
|
124
|
+
projectId: string;
|
|
125
|
+
}
|
|
126
|
+
interface RoleInput {
|
|
127
|
+
name: string;
|
|
128
|
+
permissions: string[];
|
|
129
|
+
projectId: string;
|
|
130
|
+
}
|
|
131
|
+
interface RoleUpdateInput {
|
|
132
|
+
id: string;
|
|
133
|
+
name?: string;
|
|
134
|
+
permissions?: string[];
|
|
135
|
+
}
|
|
136
|
+
interface Service {
|
|
137
|
+
id: string;
|
|
138
|
+
name: string;
|
|
139
|
+
description?: string;
|
|
140
|
+
projectId: string;
|
|
141
|
+
scope?: string[];
|
|
142
|
+
}
|
|
143
|
+
interface ServiceInput {
|
|
144
|
+
name: string;
|
|
145
|
+
description?: string;
|
|
146
|
+
projectId: string;
|
|
147
|
+
secretKey: string;
|
|
148
|
+
scope?: string[];
|
|
149
|
+
}
|
|
150
|
+
interface ServiceUpdateInput {
|
|
151
|
+
id: string;
|
|
152
|
+
name?: string;
|
|
153
|
+
description?: string;
|
|
154
|
+
}
|
|
155
|
+
interface User {
|
|
156
|
+
id: string;
|
|
157
|
+
email: string;
|
|
158
|
+
firstName?: string;
|
|
159
|
+
lastName?: string;
|
|
160
|
+
avatar?: string;
|
|
161
|
+
projectId?: string;
|
|
162
|
+
roles?: string[];
|
|
163
|
+
approved?: boolean;
|
|
164
|
+
attributes?: any;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Verify a service's access token
|
|
169
|
+
*
|
|
170
|
+
* @param {string} token The access token to verify
|
|
171
|
+
* @param {string} [scope] Optional scope to verify
|
|
172
|
+
*
|
|
173
|
+
* @returns {Promise<Service>} The service associated with the token
|
|
174
|
+
*/
|
|
175
|
+
declare const verifyServiceToken: (token: string, scope?: string) => Promise<Service>;
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Roles Management
|
|
179
|
+
*/
|
|
180
|
+
declare const getRoles: (projectId: string) => Promise<Role[]>;
|
|
181
|
+
declare const createRole: (input: RoleInput) => Promise<Role>;
|
|
182
|
+
declare const updateRole: (input: RoleUpdateInput) => Promise<Role>;
|
|
183
|
+
declare const deleteRole: (id: string) => Promise<string>;
|
|
184
|
+
/**
|
|
185
|
+
* Services Management
|
|
186
|
+
*/
|
|
187
|
+
declare const getServices: (projectId: string) => Promise<Service[]>;
|
|
188
|
+
declare const createService: (input: ServiceInput) => Promise<Service>;
|
|
189
|
+
declare const updateService: (input: ServiceUpdateInput) => Promise<Service>;
|
|
190
|
+
declare const deleteService: (id: string) => Promise<string>;
|
|
191
|
+
/**
|
|
192
|
+
* User Management
|
|
193
|
+
*/
|
|
194
|
+
declare const getUsers: (projectId: string) => Promise<User[]>;
|
|
195
|
+
declare const assignRole: (userId: string, roleName: string) => Promise<User>;
|
|
196
|
+
declare const unassignRole: (userId: string, roleName: string) => Promise<User>;
|
|
197
|
+
|
|
198
|
+
interface Profile {
|
|
199
|
+
id: string;
|
|
200
|
+
email: string;
|
|
201
|
+
firstName?: string;
|
|
202
|
+
lastName?: string;
|
|
203
|
+
projectId?: string;
|
|
204
|
+
roles?: string[];
|
|
205
|
+
lastLoginAt?: string;
|
|
206
|
+
failedLoginAttempts?: number;
|
|
207
|
+
lockedUntilAt?: string;
|
|
208
|
+
attributes?: Record<string, any>;
|
|
209
|
+
createdAt?: string;
|
|
210
|
+
updatedAt?: string;
|
|
211
|
+
}
|
|
212
|
+
interface ProfileInput {
|
|
213
|
+
firstName?: string;
|
|
214
|
+
lastName?: string;
|
|
215
|
+
attributes?: Record<string, any>;
|
|
216
|
+
}
|
|
217
|
+
interface ChangePasswordInput {
|
|
218
|
+
currentPassword?: string;
|
|
219
|
+
newPassword?: string;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* Get the current user profile
|
|
224
|
+
*
|
|
225
|
+
* @returns {Promise<Profile>} The user profile
|
|
226
|
+
*/
|
|
227
|
+
declare const getProfile: () => Promise<Profile>;
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* Update the current user profile
|
|
231
|
+
*
|
|
232
|
+
* @param {ProfileInput} input The profile data to update
|
|
233
|
+
* @returns {Promise<Profile>} The updated profile
|
|
234
|
+
*/
|
|
235
|
+
declare const updateProfile: (input: ProfileInput) => Promise<Profile>;
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* Update a user by ID
|
|
239
|
+
*
|
|
240
|
+
* @param {string} id The user ID
|
|
241
|
+
* @param {ProfileInput} input The user data to update
|
|
242
|
+
* @returns {Promise<Profile>} The updated user
|
|
243
|
+
*/
|
|
244
|
+
declare const updateUser: (id: string, input: ProfileInput) => Promise<Profile>;
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* Change the current user password
|
|
248
|
+
*
|
|
249
|
+
* @param {ChangePasswordInput} input The password data
|
|
250
|
+
* @returns {Promise<void>}
|
|
251
|
+
*/
|
|
252
|
+
declare const changePassword: (input: ChangePasswordInput) => Promise<void>;
|
|
253
|
+
|
|
254
|
+
interface Configuration {
|
|
255
|
+
id: string;
|
|
256
|
+
project_id: string;
|
|
257
|
+
allow_registration: boolean;
|
|
258
|
+
allow_password_reset: boolean;
|
|
259
|
+
mfa_required: boolean;
|
|
260
|
+
access_expiry: string;
|
|
261
|
+
refresh_expiry: string;
|
|
262
|
+
google_enabled: boolean;
|
|
263
|
+
microsoft_enabled: boolean;
|
|
264
|
+
github_enabled: boolean;
|
|
265
|
+
facebook_enabled: boolean;
|
|
266
|
+
apple_enabled: boolean;
|
|
267
|
+
totp_enabled: boolean;
|
|
268
|
+
totp_required: boolean;
|
|
269
|
+
passkeys_enabled: boolean;
|
|
270
|
+
universal_login_enabled: boolean;
|
|
271
|
+
request_beta_access: boolean;
|
|
272
|
+
beta_access_button_text: string;
|
|
273
|
+
brand_name: string;
|
|
274
|
+
brand_logo_url?: string;
|
|
275
|
+
primary_color: string;
|
|
276
|
+
created_at: string;
|
|
277
|
+
updated_at: string;
|
|
278
|
+
}
|
|
279
|
+
type ConfigurationInput = Partial<Omit<Configuration, "id" | "project_id" | "created_at" | "updated_at">>;
|
|
280
|
+
|
|
281
|
+
declare const getConfiguration: (projectId: string) => Promise<Configuration>;
|
|
282
|
+
declare const updateConfiguration: (projectId: string, data: ConfigurationInput) => Promise<Configuration>;
|
|
283
|
+
|
|
284
|
+
declare class QueryBuilder implements PromiseLike<any> {
|
|
285
|
+
private dbName;
|
|
286
|
+
private tableName;
|
|
287
|
+
private payload;
|
|
288
|
+
constructor(dbName: string, tableName: string);
|
|
289
|
+
select(...columns: Array<string | string[]>): this;
|
|
290
|
+
where(column: string, value: any): this;
|
|
291
|
+
where(column: string, operator: string, value: any): this;
|
|
292
|
+
where(obj: Record<string, any>): this;
|
|
293
|
+
limit(value: number): this;
|
|
294
|
+
offset(value: number): this;
|
|
295
|
+
insert(data: any): this;
|
|
296
|
+
update(data: any): this;
|
|
297
|
+
delete(): this;
|
|
298
|
+
listen(callback: (change: {
|
|
299
|
+
event: 'insert' | 'update' | 'delete';
|
|
300
|
+
data: any;
|
|
301
|
+
}) => void): () => void;
|
|
302
|
+
execute(): Promise<{
|
|
303
|
+
data: any[];
|
|
304
|
+
columns: string[];
|
|
305
|
+
count: number;
|
|
306
|
+
}>;
|
|
307
|
+
then<TResult1 = any, TResult2 = never>(onfulfilled?: ((value: any) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null): Promise<TResult1 | TResult2>;
|
|
308
|
+
}
|
|
309
|
+
declare function db(dbName: string): (tableName: string) => QueryBuilder;
|
|
310
|
+
|
|
311
|
+
interface StorageOptions {
|
|
312
|
+
bucket: string;
|
|
313
|
+
endpoint?: string;
|
|
314
|
+
region?: string;
|
|
315
|
+
accessKeyId?: string;
|
|
316
|
+
secretAccessKey?: string;
|
|
317
|
+
}
|
|
318
|
+
interface BucketInfo {
|
|
319
|
+
name: string;
|
|
320
|
+
creationDate?: string;
|
|
321
|
+
}
|
|
322
|
+
interface S3Object {
|
|
323
|
+
key: string;
|
|
324
|
+
lastModified?: string;
|
|
325
|
+
etag?: string;
|
|
326
|
+
size: number;
|
|
327
|
+
}
|
|
328
|
+
interface ListObjectsResult {
|
|
329
|
+
name: string;
|
|
330
|
+
prefix: string;
|
|
331
|
+
maxKeys: number;
|
|
332
|
+
isTruncated: boolean;
|
|
333
|
+
contents: S3Object[];
|
|
334
|
+
commonPrefixes: string[];
|
|
335
|
+
}
|
|
336
|
+
declare class Storage {
|
|
337
|
+
private bucket;
|
|
338
|
+
private endpoint;
|
|
339
|
+
private region;
|
|
340
|
+
private accessKeyId?;
|
|
341
|
+
private secretAccessKey?;
|
|
342
|
+
constructor(options: StorageOptions);
|
|
343
|
+
private getHeaders;
|
|
344
|
+
listBuckets(): Promise<BucketInfo[]>;
|
|
345
|
+
listObjects(options?: {
|
|
346
|
+
prefix?: string;
|
|
347
|
+
delimiter?: string;
|
|
348
|
+
maxKeys?: number;
|
|
349
|
+
}): Promise<ListObjectsResult>;
|
|
350
|
+
getObject(key: string): Promise<Response>;
|
|
351
|
+
getObjectAsText(key: string): Promise<string>;
|
|
352
|
+
getObjectAsJson<T = any>(key: string): Promise<T>;
|
|
353
|
+
getObjectAsArrayBuffer(key: string): Promise<ArrayBuffer>;
|
|
354
|
+
putObject(key: string, body: Uint8Array | ArrayBuffer | string | Blob, options?: {
|
|
355
|
+
contentType?: string;
|
|
356
|
+
}): Promise<void>;
|
|
357
|
+
deleteObject(key: string): Promise<void>;
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
export { type BucketInfo, type ChangePasswordInput, type Configuration, type ConfigurationInput, type User as IdentityUser, type ListObjectsResult, PaginatedResponse, type Profile, type ProfileInput, type Role, type RoleInput, type RoleUpdateInput, type S3Object, type Service, type ServiceInput, type ServiceUpdateInput, Storage, type StorageOptions, type User$1 as User, app, assignRole, changePassword, createRole, createService, db, deleteRole, deleteService, getAccessToken, getConfiguration, getProfile, getRoles, getServices, getUsers, initializeSdk, isLoggedIn, login, logout, setAccessToken, unassignRole, updateConfiguration, updateProfile, updateRole, updateService, updateUser, verifyServiceToken, verifyToken };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,360 @@
|
|
|
1
|
+
declare class Token {
|
|
2
|
+
#private;
|
|
3
|
+
constructor(token: string, type: string, expiration?: number);
|
|
4
|
+
private decodeExpiration;
|
|
5
|
+
/**
|
|
6
|
+
* Getter for the raw token
|
|
7
|
+
*
|
|
8
|
+
* @returns {string} The token
|
|
9
|
+
*/
|
|
10
|
+
value(): string;
|
|
11
|
+
/**
|
|
12
|
+
* Checks if the token is valid
|
|
13
|
+
*
|
|
14
|
+
* @returns {boolean} True if the API key is valid, false otherwise
|
|
15
|
+
*/
|
|
16
|
+
isValid(): boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Checks if the API key is a secret key
|
|
19
|
+
*
|
|
20
|
+
* @returns {boolean} True if the API key is a secret key, false otherwise
|
|
21
|
+
*/
|
|
22
|
+
isAccessToken(): boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Checks if the API key is a public key
|
|
25
|
+
*
|
|
26
|
+
* @returns {boolean} True if the API key is a public key, false otherwise
|
|
27
|
+
*/
|
|
28
|
+
isRefreshToken(): boolean;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
interface SwiftbaseApp {
|
|
32
|
+
projectId: string;
|
|
33
|
+
baseUrl: string;
|
|
34
|
+
accessToken: Token | null;
|
|
35
|
+
serviceId?: string;
|
|
36
|
+
serviceKey?: string;
|
|
37
|
+
debounceTimeout: number;
|
|
38
|
+
cacheArticles: boolean;
|
|
39
|
+
searchCacheEnabled: boolean;
|
|
40
|
+
searchCacheCapacity: number;
|
|
41
|
+
}
|
|
42
|
+
interface initializeSdkOptions {
|
|
43
|
+
baseUrl: string;
|
|
44
|
+
serviceId?: string;
|
|
45
|
+
serviceKey?: string;
|
|
46
|
+
debounceTimeout?: number;
|
|
47
|
+
cacheArticles?: boolean;
|
|
48
|
+
searchCacheEnabled?: boolean;
|
|
49
|
+
searchCacheCapacity?: number;
|
|
50
|
+
}
|
|
51
|
+
declare const app: SwiftbaseApp;
|
|
52
|
+
declare const initializeSdk: (projectId: string, options: initializeSdkOptions) => void;
|
|
53
|
+
declare const setAccessToken: (token: string, expiration?: number) => void;
|
|
54
|
+
declare const isLoggedIn: () => boolean;
|
|
55
|
+
declare const logout: () => void;
|
|
56
|
+
|
|
57
|
+
interface RESTPaginatedResponse<T> {
|
|
58
|
+
data: T[];
|
|
59
|
+
meta: {
|
|
60
|
+
total: number;
|
|
61
|
+
page: number;
|
|
62
|
+
limit: number;
|
|
63
|
+
next: string | null;
|
|
64
|
+
back: string | null;
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
declare class PaginatedResponse<T> {
|
|
68
|
+
#private;
|
|
69
|
+
constructor(response: RESTPaginatedResponse<T>);
|
|
70
|
+
get items(): T[];
|
|
71
|
+
get total(): number;
|
|
72
|
+
get page(): number;
|
|
73
|
+
get limit(): number;
|
|
74
|
+
get hasNext(): boolean;
|
|
75
|
+
get hasBack(): boolean;
|
|
76
|
+
next(): Promise<PaginatedResponse<T> | null>;
|
|
77
|
+
back(): Promise<PaginatedResponse<T> | null>;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Login as a service
|
|
82
|
+
*
|
|
83
|
+
* @param {string} serviceId The service ID
|
|
84
|
+
* @param {string} secretKey The service secret key
|
|
85
|
+
*
|
|
86
|
+
* @returns {Promise<void>}
|
|
87
|
+
*/
|
|
88
|
+
declare const login: (serviceId: string, secretKey: string) => Promise<void>;
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Get a valid access token.
|
|
92
|
+
* If the current token is missing or expired, it will attempt to login again
|
|
93
|
+
* using the stored serviceId and serviceKey.
|
|
94
|
+
*
|
|
95
|
+
* @returns {Promise<string | null>} The access token
|
|
96
|
+
*/
|
|
97
|
+
declare const getAccessToken: () => Promise<string | null>;
|
|
98
|
+
|
|
99
|
+
interface User$1 {
|
|
100
|
+
id: string;
|
|
101
|
+
email: string;
|
|
102
|
+
firstName?: string;
|
|
103
|
+
lastName?: string;
|
|
104
|
+
avatar?: string;
|
|
105
|
+
projectId?: string;
|
|
106
|
+
roles?: string[];
|
|
107
|
+
approved?: boolean;
|
|
108
|
+
attributes?: Record<string, any>;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Verify a user's access token
|
|
113
|
+
*
|
|
114
|
+
* @param {string} token The access token to verify
|
|
115
|
+
*
|
|
116
|
+
* @returns {Promise<User>} The user associated with the token
|
|
117
|
+
*/
|
|
118
|
+
declare const verifyToken: (token: string) => Promise<User$1>;
|
|
119
|
+
|
|
120
|
+
interface Role {
|
|
121
|
+
id: string;
|
|
122
|
+
name: string;
|
|
123
|
+
permissions: string[];
|
|
124
|
+
projectId: string;
|
|
125
|
+
}
|
|
126
|
+
interface RoleInput {
|
|
127
|
+
name: string;
|
|
128
|
+
permissions: string[];
|
|
129
|
+
projectId: string;
|
|
130
|
+
}
|
|
131
|
+
interface RoleUpdateInput {
|
|
132
|
+
id: string;
|
|
133
|
+
name?: string;
|
|
134
|
+
permissions?: string[];
|
|
135
|
+
}
|
|
136
|
+
interface Service {
|
|
137
|
+
id: string;
|
|
138
|
+
name: string;
|
|
139
|
+
description?: string;
|
|
140
|
+
projectId: string;
|
|
141
|
+
scope?: string[];
|
|
142
|
+
}
|
|
143
|
+
interface ServiceInput {
|
|
144
|
+
name: string;
|
|
145
|
+
description?: string;
|
|
146
|
+
projectId: string;
|
|
147
|
+
secretKey: string;
|
|
148
|
+
scope?: string[];
|
|
149
|
+
}
|
|
150
|
+
interface ServiceUpdateInput {
|
|
151
|
+
id: string;
|
|
152
|
+
name?: string;
|
|
153
|
+
description?: string;
|
|
154
|
+
}
|
|
155
|
+
interface User {
|
|
156
|
+
id: string;
|
|
157
|
+
email: string;
|
|
158
|
+
firstName?: string;
|
|
159
|
+
lastName?: string;
|
|
160
|
+
avatar?: string;
|
|
161
|
+
projectId?: string;
|
|
162
|
+
roles?: string[];
|
|
163
|
+
approved?: boolean;
|
|
164
|
+
attributes?: any;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Verify a service's access token
|
|
169
|
+
*
|
|
170
|
+
* @param {string} token The access token to verify
|
|
171
|
+
* @param {string} [scope] Optional scope to verify
|
|
172
|
+
*
|
|
173
|
+
* @returns {Promise<Service>} The service associated with the token
|
|
174
|
+
*/
|
|
175
|
+
declare const verifyServiceToken: (token: string, scope?: string) => Promise<Service>;
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Roles Management
|
|
179
|
+
*/
|
|
180
|
+
declare const getRoles: (projectId: string) => Promise<Role[]>;
|
|
181
|
+
declare const createRole: (input: RoleInput) => Promise<Role>;
|
|
182
|
+
declare const updateRole: (input: RoleUpdateInput) => Promise<Role>;
|
|
183
|
+
declare const deleteRole: (id: string) => Promise<string>;
|
|
184
|
+
/**
|
|
185
|
+
* Services Management
|
|
186
|
+
*/
|
|
187
|
+
declare const getServices: (projectId: string) => Promise<Service[]>;
|
|
188
|
+
declare const createService: (input: ServiceInput) => Promise<Service>;
|
|
189
|
+
declare const updateService: (input: ServiceUpdateInput) => Promise<Service>;
|
|
190
|
+
declare const deleteService: (id: string) => Promise<string>;
|
|
191
|
+
/**
|
|
192
|
+
* User Management
|
|
193
|
+
*/
|
|
194
|
+
declare const getUsers: (projectId: string) => Promise<User[]>;
|
|
195
|
+
declare const assignRole: (userId: string, roleName: string) => Promise<User>;
|
|
196
|
+
declare const unassignRole: (userId: string, roleName: string) => Promise<User>;
|
|
197
|
+
|
|
198
|
+
interface Profile {
|
|
199
|
+
id: string;
|
|
200
|
+
email: string;
|
|
201
|
+
firstName?: string;
|
|
202
|
+
lastName?: string;
|
|
203
|
+
projectId?: string;
|
|
204
|
+
roles?: string[];
|
|
205
|
+
lastLoginAt?: string;
|
|
206
|
+
failedLoginAttempts?: number;
|
|
207
|
+
lockedUntilAt?: string;
|
|
208
|
+
attributes?: Record<string, any>;
|
|
209
|
+
createdAt?: string;
|
|
210
|
+
updatedAt?: string;
|
|
211
|
+
}
|
|
212
|
+
interface ProfileInput {
|
|
213
|
+
firstName?: string;
|
|
214
|
+
lastName?: string;
|
|
215
|
+
attributes?: Record<string, any>;
|
|
216
|
+
}
|
|
217
|
+
interface ChangePasswordInput {
|
|
218
|
+
currentPassword?: string;
|
|
219
|
+
newPassword?: string;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* Get the current user profile
|
|
224
|
+
*
|
|
225
|
+
* @returns {Promise<Profile>} The user profile
|
|
226
|
+
*/
|
|
227
|
+
declare const getProfile: () => Promise<Profile>;
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* Update the current user profile
|
|
231
|
+
*
|
|
232
|
+
* @param {ProfileInput} input The profile data to update
|
|
233
|
+
* @returns {Promise<Profile>} The updated profile
|
|
234
|
+
*/
|
|
235
|
+
declare const updateProfile: (input: ProfileInput) => Promise<Profile>;
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* Update a user by ID
|
|
239
|
+
*
|
|
240
|
+
* @param {string} id The user ID
|
|
241
|
+
* @param {ProfileInput} input The user data to update
|
|
242
|
+
* @returns {Promise<Profile>} The updated user
|
|
243
|
+
*/
|
|
244
|
+
declare const updateUser: (id: string, input: ProfileInput) => Promise<Profile>;
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* Change the current user password
|
|
248
|
+
*
|
|
249
|
+
* @param {ChangePasswordInput} input The password data
|
|
250
|
+
* @returns {Promise<void>}
|
|
251
|
+
*/
|
|
252
|
+
declare const changePassword: (input: ChangePasswordInput) => Promise<void>;
|
|
253
|
+
|
|
254
|
+
interface Configuration {
|
|
255
|
+
id: string;
|
|
256
|
+
project_id: string;
|
|
257
|
+
allow_registration: boolean;
|
|
258
|
+
allow_password_reset: boolean;
|
|
259
|
+
mfa_required: boolean;
|
|
260
|
+
access_expiry: string;
|
|
261
|
+
refresh_expiry: string;
|
|
262
|
+
google_enabled: boolean;
|
|
263
|
+
microsoft_enabled: boolean;
|
|
264
|
+
github_enabled: boolean;
|
|
265
|
+
facebook_enabled: boolean;
|
|
266
|
+
apple_enabled: boolean;
|
|
267
|
+
totp_enabled: boolean;
|
|
268
|
+
totp_required: boolean;
|
|
269
|
+
passkeys_enabled: boolean;
|
|
270
|
+
universal_login_enabled: boolean;
|
|
271
|
+
request_beta_access: boolean;
|
|
272
|
+
beta_access_button_text: string;
|
|
273
|
+
brand_name: string;
|
|
274
|
+
brand_logo_url?: string;
|
|
275
|
+
primary_color: string;
|
|
276
|
+
created_at: string;
|
|
277
|
+
updated_at: string;
|
|
278
|
+
}
|
|
279
|
+
type ConfigurationInput = Partial<Omit<Configuration, "id" | "project_id" | "created_at" | "updated_at">>;
|
|
280
|
+
|
|
281
|
+
declare const getConfiguration: (projectId: string) => Promise<Configuration>;
|
|
282
|
+
declare const updateConfiguration: (projectId: string, data: ConfigurationInput) => Promise<Configuration>;
|
|
283
|
+
|
|
284
|
+
declare class QueryBuilder implements PromiseLike<any> {
|
|
285
|
+
private dbName;
|
|
286
|
+
private tableName;
|
|
287
|
+
private payload;
|
|
288
|
+
constructor(dbName: string, tableName: string);
|
|
289
|
+
select(...columns: Array<string | string[]>): this;
|
|
290
|
+
where(column: string, value: any): this;
|
|
291
|
+
where(column: string, operator: string, value: any): this;
|
|
292
|
+
where(obj: Record<string, any>): this;
|
|
293
|
+
limit(value: number): this;
|
|
294
|
+
offset(value: number): this;
|
|
295
|
+
insert(data: any): this;
|
|
296
|
+
update(data: any): this;
|
|
297
|
+
delete(): this;
|
|
298
|
+
listen(callback: (change: {
|
|
299
|
+
event: 'insert' | 'update' | 'delete';
|
|
300
|
+
data: any;
|
|
301
|
+
}) => void): () => void;
|
|
302
|
+
execute(): Promise<{
|
|
303
|
+
data: any[];
|
|
304
|
+
columns: string[];
|
|
305
|
+
count: number;
|
|
306
|
+
}>;
|
|
307
|
+
then<TResult1 = any, TResult2 = never>(onfulfilled?: ((value: any) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null): Promise<TResult1 | TResult2>;
|
|
308
|
+
}
|
|
309
|
+
declare function db(dbName: string): (tableName: string) => QueryBuilder;
|
|
310
|
+
|
|
311
|
+
interface StorageOptions {
|
|
312
|
+
bucket: string;
|
|
313
|
+
endpoint?: string;
|
|
314
|
+
region?: string;
|
|
315
|
+
accessKeyId?: string;
|
|
316
|
+
secretAccessKey?: string;
|
|
317
|
+
}
|
|
318
|
+
interface BucketInfo {
|
|
319
|
+
name: string;
|
|
320
|
+
creationDate?: string;
|
|
321
|
+
}
|
|
322
|
+
interface S3Object {
|
|
323
|
+
key: string;
|
|
324
|
+
lastModified?: string;
|
|
325
|
+
etag?: string;
|
|
326
|
+
size: number;
|
|
327
|
+
}
|
|
328
|
+
interface ListObjectsResult {
|
|
329
|
+
name: string;
|
|
330
|
+
prefix: string;
|
|
331
|
+
maxKeys: number;
|
|
332
|
+
isTruncated: boolean;
|
|
333
|
+
contents: S3Object[];
|
|
334
|
+
commonPrefixes: string[];
|
|
335
|
+
}
|
|
336
|
+
declare class Storage {
|
|
337
|
+
private bucket;
|
|
338
|
+
private endpoint;
|
|
339
|
+
private region;
|
|
340
|
+
private accessKeyId?;
|
|
341
|
+
private secretAccessKey?;
|
|
342
|
+
constructor(options: StorageOptions);
|
|
343
|
+
private getHeaders;
|
|
344
|
+
listBuckets(): Promise<BucketInfo[]>;
|
|
345
|
+
listObjects(options?: {
|
|
346
|
+
prefix?: string;
|
|
347
|
+
delimiter?: string;
|
|
348
|
+
maxKeys?: number;
|
|
349
|
+
}): Promise<ListObjectsResult>;
|
|
350
|
+
getObject(key: string): Promise<Response>;
|
|
351
|
+
getObjectAsText(key: string): Promise<string>;
|
|
352
|
+
getObjectAsJson<T = any>(key: string): Promise<T>;
|
|
353
|
+
getObjectAsArrayBuffer(key: string): Promise<ArrayBuffer>;
|
|
354
|
+
putObject(key: string, body: Uint8Array | ArrayBuffer | string | Blob, options?: {
|
|
355
|
+
contentType?: string;
|
|
356
|
+
}): Promise<void>;
|
|
357
|
+
deleteObject(key: string): Promise<void>;
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
export { type BucketInfo, type ChangePasswordInput, type Configuration, type ConfigurationInput, type User as IdentityUser, type ListObjectsResult, PaginatedResponse, type Profile, type ProfileInput, type Role, type RoleInput, type RoleUpdateInput, type S3Object, type Service, type ServiceInput, type ServiceUpdateInput, Storage, type StorageOptions, type User$1 as User, app, assignRole, changePassword, createRole, createService, db, deleteRole, deleteService, getAccessToken, getConfiguration, getProfile, getRoles, getServices, getUsers, initializeSdk, isLoggedIn, login, logout, setAccessToken, unassignRole, updateConfiguration, updateProfile, updateRole, updateService, updateUser, verifyServiceToken, verifyToken };
|