@pmate/account-sdk 0.0.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/api/AccountService.d.ts +11 -0
- package/dist/api/Api.d.ts +11 -0
- package/dist/api/EntityService.d.ts +9 -0
- package/dist/api/ProfileService.d.ts +28 -0
- package/dist/api/cacheInMem.d.ts +1 -0
- package/dist/api/index.d.ts +4 -0
- package/dist/app.config.d.ts +16 -0
- package/dist/atoms/accountAtom.d.ts +5 -0
- package/dist/atoms/accountProfileAtom.d.ts +3 -0
- package/dist/atoms/createProfileAtom.d.ts +7 -0
- package/dist/atoms/index.d.ts +16 -0
- package/dist/atoms/learningLangAtom.d.ts +1 -0
- package/dist/atoms/localStorageAtom.d.ts +8 -0
- package/dist/atoms/loginAtom.d.ts +3 -0
- package/dist/atoms/motherTongueAtom.d.ts +1 -0
- package/dist/atoms/profileAtom.d.ts +6 -0
- package/dist/atoms/profileDraftAtom.d.ts +7 -0
- package/dist/atoms/profilesAtom.d.ts +2 -0
- package/dist/atoms/sessionCheckAtom.d.ts +3 -0
- package/dist/atoms/switchProfileAtom.d.ts +4 -0
- package/dist/atoms/updateProfileAtom.d.ts +3 -0
- package/dist/atoms/uploadAvatarAtom.d.ts +8 -0
- package/dist/atoms/userLogoutAtom.d.ts +3 -0
- package/dist/atoms/userSettingsAtom.d.ts +3 -0
- package/dist/components/AuthProviderV2.d.ts +15 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/hooks/index.d.ts +3 -0
- package/dist/hooks/useAppBackgroundStyle.d.ts +3 -0
- package/dist/hooks/useAuthApp.d.ts +21 -0
- package/dist/hooks/useAuthSnapshot.d.ts +8 -0
- package/dist/hooks/useProfileStepFlow.d.ts +13 -0
- package/dist/index.cjs.js +22 -0
- package/dist/index.cjs.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.es.js +2800 -0
- package/dist/index.es.js.map +1 -0
- package/dist/types/account.types.d.ts +25 -0
- package/dist/types/profile.d.ts +5 -0
- package/dist/utils/AccountManagerV2.d.ts +43 -0
- package/dist/utils/Redirect.d.ts +4 -0
- package/dist/utils/accountStorage.d.ts +5 -0
- package/dist/utils/errors.d.ts +2 -0
- package/dist/utils/index.d.ts +6 -0
- package/dist/utils/profileStep.d.ts +6 -0
- package/dist/utils/resolveAppId.d.ts +1 -0
- package/dist/utils/selectedProfileStorage.d.ts +4 -0
- package/dist/utils/tokenStorage.d.ts +4 -0
- package/package.json +50 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { AccountState, Profile } from "@pmate/meta";
|
|
2
|
+
export declare enum AccountLifecycleState {
|
|
3
|
+
Idle = "idle",
|
|
4
|
+
Checking = "checking",
|
|
5
|
+
Authenticated = "authenticated",
|
|
6
|
+
Unauthenticated = "unauthenticated",
|
|
7
|
+
ProfileUninitialized = "profile-uninitialized",
|
|
8
|
+
ProfileInitializing = "profile-initializing",
|
|
9
|
+
ProfileReady = "profile-ready",
|
|
10
|
+
LoggingIn = "logging-in",
|
|
11
|
+
LoggingOut = "logging-out",
|
|
12
|
+
Error = "error"
|
|
13
|
+
}
|
|
14
|
+
export type AccountSnapshot = {
|
|
15
|
+
state: AccountLifecycleState;
|
|
16
|
+
account: AccountState | null;
|
|
17
|
+
accountId: string | null;
|
|
18
|
+
error: Error | null;
|
|
19
|
+
profiles: Profile[];
|
|
20
|
+
profile: Profile | null;
|
|
21
|
+
};
|
|
22
|
+
export type AuthBehaviors = {
|
|
23
|
+
authBehavior: "redirect" | "prompt";
|
|
24
|
+
requiresAuth: boolean;
|
|
25
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Emitter } from "@pchip/utils";
|
|
2
|
+
import { AccountState, LangShort, LocalProfileState, Profile, RoomPeerInfo } from "@pmate/meta";
|
|
3
|
+
import { AccountLifecycleState } from "../types/account.types";
|
|
4
|
+
import type { AccountSnapshot } from "../types/account.types";
|
|
5
|
+
export declare enum AccountManagerEvent {
|
|
6
|
+
StateChange = "stateChange"
|
|
7
|
+
}
|
|
8
|
+
export declare class AccountManagerV2 extends Emitter<AccountManagerEvent> {
|
|
9
|
+
private readonly app;
|
|
10
|
+
private static instances;
|
|
11
|
+
constructor(app: string);
|
|
12
|
+
static get(app?: string): AccountManagerV2;
|
|
13
|
+
session(): Promise<import("@pmate/meta").AuthSession | null>;
|
|
14
|
+
login(): Promise<AccountState>;
|
|
15
|
+
hasUrlSession(): boolean;
|
|
16
|
+
/**
|
|
17
|
+
* When a URL contains a sessionId parameter, this method logs in the user.
|
|
18
|
+
* If URL does not contain a sessionId parameter, this method logs in from existing session.
|
|
19
|
+
*/
|
|
20
|
+
loginUrlSessionOverride(): Promise<AccountState>;
|
|
21
|
+
logout(): Promise<void>;
|
|
22
|
+
getSnapshot(): Promise<AccountSnapshot>;
|
|
23
|
+
transition(next: AccountLifecycleState, error?: Error | null): void;
|
|
24
|
+
getAccountState(): Promise<AccountState | null>;
|
|
25
|
+
setAccountState(state: AccountState): void;
|
|
26
|
+
clearAccountState(): void;
|
|
27
|
+
getSelectedProfile(profiles?: Profile[]): Promise<Profile | null>;
|
|
28
|
+
setSelectedProfile(profile: Profile | LocalProfileState | string): void;
|
|
29
|
+
clearSelectedProfile(): void;
|
|
30
|
+
getProfiles(): Promise<Profile[]>;
|
|
31
|
+
clearProfiles(): void;
|
|
32
|
+
clearSession(): void;
|
|
33
|
+
getAuthToken(): string | null;
|
|
34
|
+
setAuthToken(token: string): void;
|
|
35
|
+
clearAuthToken(): void;
|
|
36
|
+
getLocalProfile(): Promise<LocalProfileState | null>;
|
|
37
|
+
getCurrentPeer(): Promise<RoomPeerInfo | undefined>;
|
|
38
|
+
createProfile(payload: {
|
|
39
|
+
nickName: string;
|
|
40
|
+
learningTargetLang?: LangShort;
|
|
41
|
+
}): Promise<Profile>;
|
|
42
|
+
private prepareProfiles;
|
|
43
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { AccountState } from "@pmate/meta";
|
|
2
|
+
export declare const ACCOUNT_STATE_KEY = "account-state";
|
|
3
|
+
export declare const getAccountState: () => AccountState | null;
|
|
4
|
+
export declare const setAccountState: (state: AccountState) => void;
|
|
5
|
+
export declare const clearAccountState: () => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const resolveAppId: (fallbackApp?: string) => string;
|
package/package.json
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@pmate/account-sdk",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"main": "./dist/index.cjs.js",
|
|
5
|
+
"module": "./dist/index.es.js",
|
|
6
|
+
"types": "./dist/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"import": "./dist/index.es.js",
|
|
11
|
+
"require": "./dist/index.cjs.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist"
|
|
16
|
+
],
|
|
17
|
+
"publishConfig": {
|
|
18
|
+
"access": "public"
|
|
19
|
+
},
|
|
20
|
+
"scripts": {
|
|
21
|
+
"build": "vite build && tsc -p tsconfig.build.json",
|
|
22
|
+
"npm:publish": "pnpm build && npm publish --registry https://registry.npmjs.org/"
|
|
23
|
+
},
|
|
24
|
+
"peerDependencies": {
|
|
25
|
+
"@pchip/components": "workspace:*",
|
|
26
|
+
"@pchip/utils": "workspace:*",
|
|
27
|
+
"@pmate/i18n": "workspace:*",
|
|
28
|
+
"@pmate/lang": "workspace:*",
|
|
29
|
+
"@pmate/meta": "workspace:*",
|
|
30
|
+
"@pmate/uikit": "workspace:*",
|
|
31
|
+
"jotai": "*",
|
|
32
|
+
"jotai-family": "*",
|
|
33
|
+
"react": "*",
|
|
34
|
+
"react-dom": "*",
|
|
35
|
+
"react-hook-form": "*",
|
|
36
|
+
"react-router": "*",
|
|
37
|
+
"react-router-dom": "*"
|
|
38
|
+
},
|
|
39
|
+
"dependencies": {
|
|
40
|
+
"browser-image-compression": "^2.0.2",
|
|
41
|
+
"react-use": "^17.6.0"
|
|
42
|
+
},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"@types/react": "*",
|
|
45
|
+
"@types/react-dom": "*",
|
|
46
|
+
"@vitejs/plugin-react": "^4.2.1",
|
|
47
|
+
"typescript": "^5.2.2",
|
|
48
|
+
"vite": "catalog:"
|
|
49
|
+
}
|
|
50
|
+
}
|