interface StorageDriver { get(key: string): string | null; set(key: string, value: string): void; remove(key: string): void; } declare class CustomStorage { private readonly storage; constructor(storage: StorageDriver); open: () => Promise; create: (user: T) => Promise; getById: (id: string) => Promise; getAll: () => Promise; update: >(id: string, updates: Partial) => Promise>; delete: (id: string) => Promise; reset: () => Promise; } declare class Database { private readonly config; constructor(config: { dbName: string; dbVersion: number; storeName: string; }); open: () => Promise; create: (user: { id: string; [key: string]: any; }) => Promise; getById: (id: string) => Promise; getAll: () => Promise; update: (id: string, updates: Partial>) => Promise; delete: (id: string) => Promise; reset: () => Promise; } interface DBRes { id: string; firstName: string; lastName: string; displayName: string | null; email: string; photoURL: string | null; pending: boolean; anonymous: boolean; bodyHeight: string | null; bodyShape: string | null; clothingIdBottom: string | null; clothingIdShoes: string | null; clothingIdTop: string | null; clothingIdMaterial: string | null; skullId: string | null; additionalInfo: Record | null; skull: string | null; clothingTop: string | null; clothingBottom: string | null; clothingShoes: string | null; clothingMaterial: string | null; deviceId: string; userId: string; tokens: { accessToken: string; refreshToken: string; }; } interface Config { sdkKey: string; storage?: CustomStorage; clientUrl?: string; serverUrl?: string; } interface Profile { id: string; firstName: string; lastName: string; displayName: string | null; email: string; photoURL: null | string; pending: boolean; anonymous: boolean; bodyHeight: null | string; bodyShape: null | string; clothingIdBottom: null | string; clothingIdShoes: null | string; clothingIdTop: null | string; clothingIdMaterial: null | string; skullId: string | null; additionalInfo: null | Record; bodyId: null | string | number; skinColor: null | string; eyeColor: null | string; hairId: null | string; hairColor: null | string; clothingIdMaterialBottom: null | string; clothingIdMaterialShoes: null | string; skull: null | Skull; clothingTop: null | Cloth; clothingBottom: null | Cloth; clothingShoes: null | Cloth; clothingMaterial: null | Material; body: null | Body; clothingMaterialBottom: null | Material; clothingMaterialShoes: null | Material; hair: null | SkullMaterial; deviceId: string; } interface RefToken { accessToken: string; refreshToken: string; } interface ActionSSOExchange { type: "sso-exchange"; payload: Profile; } interface ActionLocalExchange { type: "local-exchange"; payload: Profile; } interface ActionLogout { type: "logout"; payload: null; } interface ActionRefresh { type: "refresh"; payload: RefToken; } interface ActionProfileFetch { type: "profile.fetch"; payload: Profile; } interface ActionProfileUpdate { type: "profile.update"; payload: Profile; } interface ActionProfilePhotoUpdate { type: "profile-photo.update"; payload: UpdateProfilePicture; } interface ActionAddClothUpdate { type: "cloth.add"; payload: Cloth; } interface ActionFetchAllCloths { type: "cloth.fetch-all"; payload: Cloth[]; } interface ActionFetchCloth { type: "cloth.fetch"; payload: Cloth; } interface ActionUpdateCloth { type: "cloth.update"; payload: Cloth; } interface ActionClothDelete { type: "cloth.delete"; payload: Cloth; } interface ActionAddMaterial { type: "material.add"; payload: Material; } interface ActionGetMaterials { type: "material.fetch-all"; payload: Material[]; } interface ActionGetMaterial { type: "material.fetch"; payload: Material; } interface ActionUpdateMaterial { type: "material.update"; payload: Material; } interface ActionDeleteMaterial { type: "material.delete"; payload: Material; } interface ActionAddSkull { type: "skull.add"; payload: Skull; } interface ActionUpdateSkull { type: "skull.update"; payload: Skull; } interface ActionGetAllSkulls { type: "skull.fetch-all"; payload: Skull[]; } interface ActionGetSkull { type: "skull.fetch"; payload: Skull; } interface ActionDeleteSkull { type: "skull.delete"; payload: Skull; } interface ActionSkullMaterialAdd { type: "skull-material.add"; payload: SkullMaterial; } interface ActionSkullMaterialGetAll { type: "skull-material.fetch-all"; payload: SkullMaterial[]; } interface ActionSkullMaterialGetById { type: "skull-material.fetch"; payload: SkullMaterial; } interface ActionSkullMaterialUpdate { type: "skull-material.update"; payload: SkullMaterial; } interface ActionSkullMaterialDelete { type: "skull-material.delete"; payload: SkullMaterial; } interface ActionBodyAddFile { type: "body.add"; payload: Body; } interface ActionBodyGetAll { type: "body.fetch-all"; payload: Body[]; } interface ActionBodyGetById { type: "body.fetch"; payload: Body; } interface ActionBodyUpdate { type: "body.update"; payload: Body; } interface ActionBodyDelete { type: "body.delete"; payload: Body; } interface ActionLocalLogin { type: "local-login"; payload: null; } interface ActionLocalRegister { type: "local-register"; payload: LocalRegister; } interface ActionLocalLogout { type: "local-logout"; payload: null; } interface ActionSessionCleared { type: "session-cleared"; payload: null; } 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; type Cb = (action: Actions) => void; interface ErrorRes { statusCode: number; success: false; message: string; data: null; } interface SuccessRes { statusCode: number; success: true; message: string; data: T; } type EmailVerificationPayload = { type: "otp"; redirectUri?: string; } | { type?: undefined; redirectUri: string; }; type LocalLoginPayload = EmailVerificationPayload & { email: string; }; type LocalRegisterPayload = EmailVerificationPayload & { firstName: string; lastName: string; displayName?: string; email: string; }; interface VerifyOtpPayload { email: string; otpCode: string; } interface LocalRegister { id: string; firstName: string; lastName: string; displayName: string | null; email: string; photoURL: null; pending: boolean; verifiedAt: null; anonymous: boolean; updatedAt: Date; createdAt: Date; } interface UpdateProfilePayload { firstName?: string; lastName?: string; displayName?: string; bodyHeight?: string; bodyShape?: string; clothingIdBottom?: string; clothingIdShoes?: string; clothingIdTop?: string; clothingIdMaterial?: string; anonymous?: boolean; skullId?: string; additionalInfo?: Record; bodyId?: string; skinColor?: string; eyeColor?: string; hairId?: string; hairColor?: string; clothingIdMaterialBottom?: string; clothingIdMaterialShoes?: string; } interface UpdateProfilePicturePayload { photoURL: string; } interface UpdateProfilePicture { id: string; firstName: string; lastName: string; displayName: string | null; email: string; photoURL: string; pending: boolean; anonymous: boolean; } type AssetGender = "MALE" | "FEMALE"; interface AddClothPayload { name: string; bodyDefinition: AssetGender; description: string; public: boolean; thumb: string; type: string; } interface AddClothFilePayload { name: string; bodyDefinition: AssetGender; description: string; public: boolean; thumb: File; type: string; } interface Cloth { id: string; ownerId: string | null; name: string; bodyDefinition: AssetGender; description: string; public: boolean; thumb: string; type: string; updatedAt: Date; createdAt: Date; } interface GetClothsOptions { skip: number; limit: number; sort: "asc" | "desc"; } interface UpdateClothPayload { name?: string; bodyDefinition?: AssetGender; description?: string; public?: boolean; type?: string; } interface Material { id: string; ownerId: string | null; name: string; description: string; public: boolean; thumb: string; type: string; updatedAt: Date; createdAt: Date; } type AddMaterialPayload = Pick; type AddMaterialFilePayload = Exclude & { thumb: File; }; interface GetMaterialsOptions { skip: number; limit: number; sort: "asc" | "desc"; } type UpdateMaterialPayload = Exclude; interface Skull { id: string; ownerId: string | null; name: string; previewUrl: string; url3d: string; public: boolean; gender: AssetGender; updatedAt: Date; createdAt: Date; } type AddSkullPayload = Pick; type AddSkullFilePayload = Exclude & { filePreview: File; file3d: File; }; type UpdateSkullPayload = Partial>; interface SkullMaterial { id: string; name: string; description: string; previewUrl: string; url3d: string; type: string; updatedAt: Date; createdAt: Date; } type SkullMaterialAddPayload = Omit; interface SkullMaterialAddFilePayload extends Omit { previewFile: File; file3d: File; } type SkullMaterialUpdatePayload = Partial>; interface SkullMaterialUpdateFilePayload extends Omit { previewFile?: File; file3d?: File; } interface BodyAddPayload { shape: "SKINNY" | "NORMAL" | "FAT"; name: string; gender: AssetGender; previewUrl: string; url3d: string; description?: string; } interface BodyAddFilePayload extends Omit { previewFile: File; file3d: File; } interface Body { id: string; shapeNo: number; name: string; description: string; gender: AssetGender; shape: string; previewUrl: string; url3d: string; updatedAt: Date; createdAt: Date; } type BodyUpdatePayload = Partial>; interface BodyUpdateFilePayload extends Omit { previewFile?: File; file3d?: File; } interface Verify { tokens: { accessToken: string; refreshToken: string; }; } interface Exchange extends Profile { tokens: { accessToken: string; refreshToken: string; }; } interface SignedUrl { url: string; method: string; headers: Record; } type LoginPayload = string | LocalLoginPayload; interface AccessTokenPayload { firstName: string; lastName: string; email: string; deviceId: string; isClassic: boolean; iat: number; exp: number; sub: string; } interface RefreshTokenPayload { crypto: string; isClassic: boolean; iat: number; exp: number; } declare class SSO { private readonly config; readonly serviceType = "AVATAR_SSO"; protected readonly db: Database | CustomStorage; protected ssoClientUrl: string; protected ssoServerUrl: string; readonly sdkKey: string; readonly dbId = "local-user"; private callbacks; private cb; constructor(config: Config); readonly register: (payload: LocalRegisterPayload) => Promise; private readonly localLogin; private readonly ssoLogin; /** * Login function that triggers both local and SSO login flows. If the payload is a string, it will trigger the SSO login flow with the payload as the redirect URL. If the payload is an object, it will trigger the local login flow with the payload as the login data. * @param payload just redirect URL string for SSO login or LocalLoginPayload for local login * @returns */ readonly login: (payload: LoginPayload) => Promise; private readonly decodeJwtPayload; /** * - it throws. */ private readonly autoRefresh; private readonly localExchange; readonly verifyOtp: (payload: VerifyOtpPayload) => Promise; private readonly ssoExchange; /** * - this will just skip the exchange returning null if the query params are not correct and won't throw an error. */ readonly exchange: () => Promise; readonly fetchProfile: () => Promise; private refreshPromise; readonly refresh: () => Promise; private readonly doRefresh; readonly logout: () => Promise; readonly onEvents: (cb: Cb) => () => boolean; protected readonly withRefresh: (api: (aT: string) => Promise) => Promise; readonly profileUpdate: (payload: UpdateProfilePayload) => Promise; readonly avatarUpdate: (file: File) => Promise; private readonly fileUpload; private readonly clothAdd; readonly clothGetAll: (options?: GetClothsOptions) => Promise; readonly clothGetById: (clothId: string) => Promise; private readonly clothUpdate; private readonly clothDelete; private readonly materialAdd; readonly materialGetAll: (options?: GetMaterialsOptions) => Promise; readonly materialGetById: (materialId: string) => Promise; private readonly materialUpdate; private readonly materialDelete; private readonly skullAdd; private readonly skullUpdate; readonly skullGetAll: () => Promise; readonly skullGetById: (skullId: string) => Promise; private readonly skullDelete; private readonly skullMaterialAdd; readonly skullMaterialGetAll: () => Promise; readonly skullMaterialGetById: (id: string) => Promise; private readonly skullMaterialUpdate; private readonly skullMaterialDelete; private readonly bodyAdd; readonly bodyGetAll: () => Promise; readonly bodyGetById: (id: string) => Promise; private readonly bodyUpdate; private readonly bodyDelete; private validatedUrl; private emailVerificationQuery; private throwIfNotBrowser; /** * get user from indexedDB without validating tokens. */ readonly getLocalUser: () => Promise; } 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 };