@alliumcloud/avatar-sso-internal 2.5.5-testing.0 → 2.5.6-dev.1

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/main.d.ts CHANGED
@@ -1,9 +1,498 @@
1
- import CustomStorage from "./lib/CustomStorage";
2
- import Database from "./lib/database";
3
- import { Body, Cb, Cloth, Config, DBRes, Exchange, GetClothsOptions, GetMaterialsOptions, LocalRegister, LocalRegisterPayload, LoginPayload, Material, Profile, RefToken, Skull, SkullMaterial, UpdateProfilePayload, UpdateProfilePicture, VerifyOtpPayload } from "./types";
4
- export type * from "./types";
5
- export { default as CustomStorage } from "./lib/CustomStorage";
6
- export default class SSO {
1
+ interface StorageDriver {
2
+ get(key: string): string | null;
3
+ set(key: string, value: string): void;
4
+ remove(key: string): void;
5
+ }
6
+ declare class CustomStorage {
7
+ private readonly storage;
8
+ constructor(storage: StorageDriver);
9
+ open: () => Promise<StorageDriver>;
10
+ create: <T extends {
11
+ id: string;
12
+ }>(user: T) => Promise<T>;
13
+ getById: <T = unknown>(id: string) => Promise<T | null>;
14
+ getAll: () => Promise<never[]>;
15
+ update: <T extends Record<string, unknown>>(id: string, updates: Partial<T>) => Promise<T & Partial<T>>;
16
+ delete: (id: string) => Promise<boolean>;
17
+ reset: () => Promise<boolean>;
18
+ }
19
+
20
+ declare class Database {
21
+ private readonly config;
22
+ constructor(config: {
23
+ dbName: string;
24
+ dbVersion: number;
25
+ storeName: string;
26
+ });
27
+ open: () => Promise<IDBDatabase>;
28
+ create: (user: {
29
+ id: string;
30
+ [key: string]: any;
31
+ }) => Promise<unknown>;
32
+ getById: <T = unknown>(id: string) => Promise<T | null>;
33
+ getAll: () => Promise<unknown>;
34
+ update: (id: string, updates: Partial<Record<string, any>>) => Promise<unknown>;
35
+ delete: (id: string) => Promise<unknown>;
36
+ reset: () => Promise<unknown>;
37
+ }
38
+
39
+ interface DBRes {
40
+ id: string;
41
+ firstName: string;
42
+ lastName: string;
43
+ email: string;
44
+ photoURL: string | null;
45
+ pending: boolean;
46
+ anonymous: boolean;
47
+ bodyHeight: string | null;
48
+ bodyShape: string | null;
49
+ clothingIdBottom: string | null;
50
+ clothingIdShoes: string | null;
51
+ clothingIdTop: string | null;
52
+ clothingIdMaterial: string | null;
53
+ skullId: string | null;
54
+ additionalInfo: Record<string, unknown> | null;
55
+ skull: string | null;
56
+ clothingTop: string | null;
57
+ clothingBottom: string | null;
58
+ clothingShoes: string | null;
59
+ clothingMaterial: string | null;
60
+ deviceId: string;
61
+ userId: string;
62
+ tokens: {
63
+ accessToken: string;
64
+ refreshToken: string;
65
+ };
66
+ }
67
+ interface Config {
68
+ sdkKey: string;
69
+ storage?: CustomStorage;
70
+ clientUrl?: string;
71
+ serverUrl?: string;
72
+ }
73
+ interface Profile {
74
+ id: string;
75
+ firstName: string;
76
+ lastName: string;
77
+ email: string;
78
+ photoURL: null | string;
79
+ pending: boolean;
80
+ anonymous: boolean;
81
+ bodyHeight: null | string;
82
+ bodyShape: null | string;
83
+ clothingIdBottom: null | string;
84
+ clothingIdShoes: null | string;
85
+ clothingIdTop: null | string;
86
+ clothingIdMaterial: null | string;
87
+ skullId: string | null;
88
+ additionalInfo: null | Record<string, unknown>;
89
+ bodyId: null | string | number;
90
+ skinColor: null | string;
91
+ eyeColor: null | string;
92
+ hairId: null | string;
93
+ hairColor: null | string;
94
+ clothingIdMaterialBottom: null | string;
95
+ clothingIdMaterialShoes: null | string;
96
+ skull: null | Skull;
97
+ clothingTop: null | Cloth;
98
+ clothingBottom: null | Cloth;
99
+ clothingShoes: null | Cloth;
100
+ clothingMaterial: null | Material;
101
+ body: null | Body;
102
+ clothingMaterialBottom: null | Material;
103
+ clothingMaterialShoes: null | Material;
104
+ hair: null | SkullMaterial;
105
+ deviceId: string;
106
+ }
107
+ interface RefToken {
108
+ accessToken: string;
109
+ refreshToken: string;
110
+ }
111
+ interface ActionSSOExchange {
112
+ type: "sso-exchange";
113
+ payload: Profile;
114
+ }
115
+ interface ActionLocalExchange {
116
+ type: "local-exchange";
117
+ payload: Profile;
118
+ }
119
+ interface ActionLogout {
120
+ type: "logout";
121
+ payload: null;
122
+ }
123
+ interface ActionRefresh {
124
+ type: "refresh";
125
+ payload: RefToken;
126
+ }
127
+ interface ActionProfileFetch {
128
+ type: "profile.fetch";
129
+ payload: Profile;
130
+ }
131
+ interface ActionProfileUpdate {
132
+ type: "profile.update";
133
+ payload: Profile;
134
+ }
135
+ interface ActionProfilePhotoUpdate {
136
+ type: "profile-photo.update";
137
+ payload: UpdateProfilePicture;
138
+ }
139
+ interface ActionAddClothUpdate {
140
+ type: "cloth.add";
141
+ payload: Cloth;
142
+ }
143
+ interface ActionFetchAllCloths {
144
+ type: "cloth.fetch-all";
145
+ payload: Cloth[];
146
+ }
147
+ interface ActionFetchCloth {
148
+ type: "cloth.fetch";
149
+ payload: Cloth;
150
+ }
151
+ interface ActionUpdateCloth {
152
+ type: "cloth.update";
153
+ payload: Cloth;
154
+ }
155
+ interface ActionClothDelete {
156
+ type: "cloth.delete";
157
+ payload: Cloth;
158
+ }
159
+ interface ActionAddMaterial {
160
+ type: "material.add";
161
+ payload: Material;
162
+ }
163
+ interface ActionGetMaterials {
164
+ type: "material.fetch-all";
165
+ payload: Material[];
166
+ }
167
+ interface ActionGetMaterial {
168
+ type: "material.fetch";
169
+ payload: Material;
170
+ }
171
+ interface ActionUpdateMaterial {
172
+ type: "material.update";
173
+ payload: Material;
174
+ }
175
+ interface ActionDeleteMaterial {
176
+ type: "material.delete";
177
+ payload: Material;
178
+ }
179
+ interface ActionAddSkull {
180
+ type: "skull.add";
181
+ payload: Skull;
182
+ }
183
+ interface ActionUpdateSkull {
184
+ type: "skull.update";
185
+ payload: Skull;
186
+ }
187
+ interface ActionGetAllSkulls {
188
+ type: "skull.fetch-all";
189
+ payload: Skull[];
190
+ }
191
+ interface ActionGetSkull {
192
+ type: "skull.fetch";
193
+ payload: Skull;
194
+ }
195
+ interface ActionDeleteSkull {
196
+ type: "skull.delete";
197
+ payload: Skull;
198
+ }
199
+ interface ActionSkullMaterialAdd {
200
+ type: "skull-material.add";
201
+ payload: SkullMaterial;
202
+ }
203
+ interface ActionSkullMaterialGetAll {
204
+ type: "skull-material.fetch-all";
205
+ payload: SkullMaterial[];
206
+ }
207
+ interface ActionSkullMaterialGetById {
208
+ type: "skull-material.fetch";
209
+ payload: SkullMaterial;
210
+ }
211
+ interface ActionSkullMaterialUpdate {
212
+ type: "skull-material.update";
213
+ payload: SkullMaterial;
214
+ }
215
+ interface ActionSkullMaterialDelete {
216
+ type: "skull-material.delete";
217
+ payload: SkullMaterial;
218
+ }
219
+ interface ActionBodyAddFile {
220
+ type: "body.add";
221
+ payload: Body;
222
+ }
223
+ interface ActionBodyGetAll {
224
+ type: "body.fetch-all";
225
+ payload: Body[];
226
+ }
227
+ interface ActionBodyGetById {
228
+ type: "body.fetch";
229
+ payload: Body;
230
+ }
231
+ interface ActionBodyUpdate {
232
+ type: "body.update";
233
+ payload: Body;
234
+ }
235
+ interface ActionBodyDelete {
236
+ type: "body.delete";
237
+ payload: Body;
238
+ }
239
+ interface ActionLocalLogin {
240
+ type: "local-login";
241
+ payload: null;
242
+ }
243
+ interface ActionLocalRegister {
244
+ type: "local-register";
245
+ payload: LocalRegister;
246
+ }
247
+ interface ActionLocalLogout {
248
+ type: "local-logout";
249
+ payload: null;
250
+ }
251
+ interface ActionSessionCleared {
252
+ type: "session-cleared";
253
+ payload: null;
254
+ }
255
+ type Actions = ActionSessionCleared | ActionSSOExchange | ActionLocalExchange | ActionLogout | ActionRefresh | ActionProfileFetch | ActionProfileUpdate | ActionProfilePhotoUpdate | ActionAddClothUpdate | ActionFetchAllCloths | ActionFetchCloth | ActionUpdateCloth | ActionClothDelete | ActionAddMaterial | ActionGetMaterials | ActionGetMaterial | ActionUpdateMaterial | ActionDeleteMaterial | ActionAddSkull | ActionUpdateSkull | ActionGetAllSkulls | ActionGetSkull | ActionDeleteSkull | ActionSkullMaterialAdd | ActionSkullMaterialGetAll | ActionSkullMaterialGetById | ActionSkullMaterialUpdate | ActionSkullMaterialDelete | ActionBodyAddFile | ActionBodyGetAll | ActionBodyGetById | ActionBodyUpdate | ActionBodyDelete | ActionLocalLogin | ActionLocalRegister | ActionLocalLogout;
256
+ type Cb = (action: Actions) => void;
257
+ interface ErrorRes {
258
+ statusCode: number;
259
+ success: false;
260
+ message: string;
261
+ data: null;
262
+ }
263
+ interface SuccessRes<T = null> {
264
+ statusCode: number;
265
+ success: true;
266
+ message: string;
267
+ data: T;
268
+ }
269
+ type EmailVerificationPayload = {
270
+ type: "otp";
271
+ redirectUri?: string;
272
+ } | {
273
+ type?: undefined;
274
+ redirectUri: string;
275
+ };
276
+ type LocalLoginPayload = EmailVerificationPayload & {
277
+ email: string;
278
+ };
279
+ type LocalRegisterPayload = EmailVerificationPayload & {
280
+ firstName: string;
281
+ lastName: string;
282
+ email: string;
283
+ };
284
+ interface VerifyOtpPayload {
285
+ email: string;
286
+ otpCode: string;
287
+ }
288
+ interface LocalRegister {
289
+ id: string;
290
+ firstName: string;
291
+ lastName: string;
292
+ email: string;
293
+ photoURL: null;
294
+ pending: boolean;
295
+ verifiedAt: null;
296
+ anonymous: boolean;
297
+ updatedAt: Date;
298
+ createdAt: Date;
299
+ }
300
+ interface UpdateProfilePayload {
301
+ firstName?: string;
302
+ lastName?: string;
303
+ bodyHeight?: string;
304
+ bodyShape?: string;
305
+ clothingIdBottom?: string;
306
+ clothingIdShoes?: string;
307
+ clothingIdTop?: string;
308
+ clothingIdMaterial?: string;
309
+ anonymous?: boolean;
310
+ skullId?: string;
311
+ additionalInfo?: Record<string, unknown>;
312
+ bodyId?: string;
313
+ skinColor?: string;
314
+ eyeColor?: string;
315
+ hairId?: string;
316
+ hairColor?: string;
317
+ clothingIdMaterialBottom?: string;
318
+ clothingIdMaterialShoes?: string;
319
+ }
320
+ interface UpdateProfilePicturePayload {
321
+ photoURL: string;
322
+ }
323
+ interface UpdateProfilePicture {
324
+ id: string;
325
+ firstName: string;
326
+ lastName: string;
327
+ email: string;
328
+ photoURL: string;
329
+ pending: boolean;
330
+ anonymous: boolean;
331
+ }
332
+ type AssetGender = "MALE" | "FEMALE";
333
+ interface AddClothPayload {
334
+ name: string;
335
+ bodyDefinition: AssetGender;
336
+ description: string;
337
+ public: boolean;
338
+ thumb: string;
339
+ type: string;
340
+ }
341
+ interface AddClothFilePayload {
342
+ name: string;
343
+ bodyDefinition: AssetGender;
344
+ description: string;
345
+ public: boolean;
346
+ thumb: File;
347
+ type: string;
348
+ }
349
+ interface Cloth {
350
+ id: string;
351
+ ownerId: string | null;
352
+ name: string;
353
+ bodyDefinition: AssetGender;
354
+ description: string;
355
+ public: boolean;
356
+ thumb: string;
357
+ type: string;
358
+ updatedAt: Date;
359
+ createdAt: Date;
360
+ }
361
+ interface GetClothsOptions {
362
+ skip: number;
363
+ limit: number;
364
+ sort: "asc" | "desc";
365
+ }
366
+ interface UpdateClothPayload {
367
+ name?: string;
368
+ bodyDefinition?: AssetGender;
369
+ description?: string;
370
+ public?: boolean;
371
+ type?: string;
372
+ }
373
+ interface Material {
374
+ id: string;
375
+ ownerId: string | null;
376
+ name: string;
377
+ description: string;
378
+ public: boolean;
379
+ thumb: string;
380
+ type: string;
381
+ updatedAt: Date;
382
+ createdAt: Date;
383
+ }
384
+ type AddMaterialPayload = Pick<Material, "name" | "description" | "public" | "thumb" | "type">;
385
+ type AddMaterialFilePayload = Exclude<AddMaterialPayload, "thumb"> & {
386
+ thumb: File;
387
+ };
388
+ interface GetMaterialsOptions {
389
+ skip: number;
390
+ limit: number;
391
+ sort: "asc" | "desc";
392
+ }
393
+ type UpdateMaterialPayload = Exclude<AddMaterialPayload, "thumb">;
394
+ interface Skull {
395
+ id: string;
396
+ ownerId: string | null;
397
+ name: string;
398
+ previewUrl: string;
399
+ url3d: string;
400
+ public: boolean;
401
+ gender: AssetGender;
402
+ updatedAt: Date;
403
+ createdAt: Date;
404
+ }
405
+ type AddSkullPayload = Pick<Skull, "name" | "previewUrl" | "url3d" | "public" | "gender">;
406
+ type AddSkullFilePayload = Exclude<AddSkullPayload, "previewUrl" | "url3d"> & {
407
+ filePreview: File;
408
+ file3d: File;
409
+ };
410
+ type UpdateSkullPayload = Partial<Pick<Skull, "name" | "public">>;
411
+ interface SkullMaterial {
412
+ id: string;
413
+ name: string;
414
+ description: string;
415
+ previewUrl: string;
416
+ url3d: string;
417
+ type: string;
418
+ updatedAt: Date;
419
+ createdAt: Date;
420
+ }
421
+ type SkullMaterialAddPayload = Omit<SkullMaterial, "id" | "updatedAt" | "createdAt">;
422
+ interface SkullMaterialAddFilePayload extends Omit<SkullMaterialAddPayload, "previewUrl" | "url3d"> {
423
+ previewFile: File;
424
+ file3d: File;
425
+ }
426
+ type SkullMaterialUpdatePayload = Partial<Omit<SkullMaterial, "id" | "updatedAt" | "createdAt">>;
427
+ interface SkullMaterialUpdateFilePayload extends Omit<SkullMaterialUpdatePayload, "previewUrl" | "url3d"> {
428
+ previewFile?: File;
429
+ file3d?: File;
430
+ }
431
+ interface BodyAddPayload {
432
+ shape: "SKINNY" | "NORMAL" | "FAT";
433
+ name: string;
434
+ gender: AssetGender;
435
+ previewUrl: string;
436
+ url3d: string;
437
+ description?: string;
438
+ }
439
+ interface BodyAddFilePayload extends Omit<BodyAddPayload, "previewUrl" | "url3d"> {
440
+ previewFile: File;
441
+ file3d: File;
442
+ }
443
+ interface Body {
444
+ id: string;
445
+ shapeNo: number;
446
+ name: string;
447
+ description: string;
448
+ gender: AssetGender;
449
+ shape: string;
450
+ previewUrl: string;
451
+ url3d: string;
452
+ updatedAt: Date;
453
+ createdAt: Date;
454
+ }
455
+ type BodyUpdatePayload = Partial<Omit<Body, "id" | "shapeNo" | "updatedAt" | "createdAt">>;
456
+ interface BodyUpdateFilePayload extends Omit<BodyUpdatePayload, "previewUrl" | "url3d"> {
457
+ previewFile?: File;
458
+ file3d?: File;
459
+ }
460
+ interface Verify {
461
+ tokens: {
462
+ accessToken: string;
463
+ refreshToken: string;
464
+ };
465
+ }
466
+ interface Exchange extends Profile {
467
+ tokens: {
468
+ accessToken: string;
469
+ refreshToken: string;
470
+ };
471
+ }
472
+ interface SignedUrl {
473
+ url: string;
474
+ method: string;
475
+ headers: Record<string, string>;
476
+ }
477
+ type LoginPayload = string | LocalLoginPayload;
478
+ interface AccessTokenPayload {
479
+ firstName: string;
480
+ lastName: string;
481
+ email: string;
482
+ deviceId: string;
483
+ isClassic: boolean;
484
+ iat: number;
485
+ exp: number;
486
+ sub: string;
487
+ }
488
+ interface RefreshTokenPayload {
489
+ crypto: string;
490
+ isClassic: boolean;
491
+ iat: number;
492
+ exp: number;
493
+ }
494
+
495
+ declare class SSO {
7
496
  private readonly config;
8
497
  readonly serviceType = "AVATAR_SSO";
9
498
  protected readonly db: Database | CustomStorage;
@@ -82,4 +571,5 @@ export default class SSO {
82
571
  */
83
572
  readonly getLocalUser: () => Promise<DBRes>;
84
573
  }
85
- //# sourceMappingURL=main.d.ts.map
574
+
575
+ export { type AccessTokenPayload, type Actions, type AddClothFilePayload, type AddClothPayload, type AddMaterialFilePayload, type AddMaterialPayload, type AddSkullFilePayload, type AddSkullPayload, type AssetGender, type Body, type BodyAddFilePayload, type BodyAddPayload, type BodyUpdateFilePayload, type BodyUpdatePayload, type Cb, type Cloth, type Config, CustomStorage, type DBRes, type ErrorRes, type Exchange, type GetClothsOptions, type GetMaterialsOptions, type LocalLoginPayload, type LocalRegister, type LocalRegisterPayload, type LoginPayload, type Material, type Profile, type RefToken, type RefreshTokenPayload, type SignedUrl, type Skull, type SkullMaterial, type SkullMaterialAddFilePayload, type SkullMaterialAddPayload, type SkullMaterialUpdateFilePayload, type SkullMaterialUpdatePayload, type SuccessRes, type UpdateClothPayload, type UpdateMaterialPayload, type UpdateProfilePayload, type UpdateProfilePicture, type UpdateProfilePicturePayload, type UpdateSkullPayload, type Verify, type VerifyOtpPayload, SSO as default };