@getpara/core-sdk 2.11.0 → 2.13.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/dist/cjs/ParaCore.js +809 -2003
- package/dist/cjs/constants.js +4 -1
- package/dist/cjs/services/AuthService.js +787 -0
- package/dist/cjs/services/BaseAuthFlowService.js +78 -0
- package/dist/cjs/services/ExternalWalletService.js +386 -0
- package/dist/cjs/services/LoginFlowService.js +163 -0
- package/dist/cjs/services/PollingService.js +448 -0
- package/dist/cjs/services/PortalUrlService.js +379 -0
- package/dist/cjs/services/PregenWalletService.js +442 -0
- package/dist/cjs/services/SessionManagementService.js +280 -0
- package/dist/cjs/services/SignupFlowService.js +185 -0
- package/dist/cjs/services/VerificationFlowService.js +242 -0
- package/dist/cjs/services/WalletService.js +577 -0
- package/dist/cjs/services/types/AuthServiceTypes.js +15 -0
- package/dist/cjs/services/types/BaseAuthFlowServiceTypes.js +15 -0
- package/dist/cjs/services/types/ExternalWalletServiceTypes.js +15 -0
- package/dist/cjs/services/types/LoginFlowServiceTypes.js +15 -0
- package/dist/cjs/services/types/PollingServiceTypes.js +15 -0
- package/dist/cjs/services/types/PortalUrlServiceTypes.js +15 -0
- package/dist/cjs/services/types/PregenWalletServiceTypes.js +15 -0
- package/dist/cjs/services/types/SessionManagementServiceTypes.js +15 -0
- package/dist/cjs/services/types/SignupFlowServiceTypes.js +15 -0
- package/dist/cjs/services/types/VerificationFlowServiceTypes.js +15 -0
- package/dist/cjs/services/types/WalletServiceTypes.js +15 -0
- package/dist/cjs/services/types/index.js +15 -0
- package/dist/cjs/state/CoreStateManager.js +297 -0
- package/dist/cjs/state/actors/authenticateWithEmailOrPhone.js +50 -0
- package/dist/cjs/state/actors/authenticateWithExternalWallet.js +50 -0
- package/dist/cjs/state/actors/authenticateWithFarcaster.js +50 -0
- package/dist/cjs/state/actors/authenticateWithFarcasterLegacy.js +50 -0
- package/dist/cjs/state/actors/authenticateWithTelegram.js +50 -0
- package/dist/cjs/state/actors/authenticateWithTelegramLegacy.js +50 -0
- package/dist/cjs/state/actors/checkUserState.js +53 -0
- package/dist/cjs/state/actors/claimWallets.js +56 -0
- package/dist/cjs/state/actors/connectExternalConnectors.js +54 -0
- package/dist/cjs/state/actors/connectExternalWallet.js +50 -0
- package/dist/cjs/state/actors/createGuestWallets.js +50 -0
- package/dist/cjs/state/actors/createWallets.js +73 -0
- package/dist/cjs/state/actors/polling.js +91 -0
- package/dist/cjs/state/actors/processAuthentication.js +50 -0
- package/dist/cjs/state/actors/setupAfterLogin.js +52 -0
- package/dist/cjs/state/actors/setupPara.js +50 -0
- package/dist/cjs/state/actors/signExternalWalletVerification.js +79 -0
- package/dist/cjs/state/actors/switchExternalWallet.js +50 -0
- package/dist/cjs/state/actors/verifyExternalWallet.js +50 -0
- package/dist/cjs/state/actors/verifyNewAccount.js +50 -0
- package/dist/cjs/state/actors/waitForExternalWalletProviders.js +54 -0
- package/dist/cjs/state/machines/authStateMachine.helpers.js +137 -0
- package/dist/cjs/state/machines/authStateMachine.js +1084 -0
- package/dist/cjs/state/machines/coreStateMachine.js +383 -0
- package/dist/cjs/state/machines/walletStateMachine.js +437 -0
- package/dist/cjs/state/types/auth.js +15 -0
- package/dist/cjs/state/types/core.js +15 -0
- package/dist/cjs/state/types/wallet.js +15 -0
- package/dist/cjs/types/{auth.js → accountLinking.js} +3 -3
- package/dist/cjs/types/authState.js +15 -0
- package/dist/cjs/types/coreApi.js +3 -1
- package/dist/cjs/types/index.js +2 -2
- package/dist/cjs/types/serviceInterfaces.js +15 -0
- package/dist/cjs/types/util.js +15 -0
- package/dist/cjs/utils/formatting.js +6 -0
- package/dist/cjs/utils/retryBackoff.js +30 -0
- package/dist/cjs/utils/stateErrorHelpers.js +60 -0
- package/dist/cjs/utils/stateListener.js +129 -0
- package/dist/esm/ParaCore.js +812 -2031
- package/dist/esm/constants.js +3 -1
- package/dist/esm/services/AuthService.js +717 -0
- package/dist/esm/services/BaseAuthFlowService.js +25 -0
- package/dist/esm/services/ExternalWalletService.js +327 -0
- package/dist/esm/services/LoginFlowService.js +97 -0
- package/dist/esm/services/PollingService.js +389 -0
- package/dist/esm/services/PortalUrlService.js +320 -0
- package/dist/esm/services/PregenWalletService.js +393 -0
- package/dist/esm/services/SessionManagementService.js +236 -0
- package/dist/esm/services/SignupFlowService.js +119 -0
- package/dist/esm/services/VerificationFlowService.js +178 -0
- package/dist/esm/services/WalletService.js +514 -0
- package/dist/esm/services/types/AuthServiceTypes.js +0 -0
- package/dist/esm/services/types/BaseAuthFlowServiceTypes.js +0 -0
- package/dist/esm/services/types/ExternalWalletServiceTypes.js +0 -0
- package/dist/esm/services/types/LoginFlowServiceTypes.js +0 -0
- package/dist/esm/services/types/PollingServiceTypes.js +0 -0
- package/dist/esm/services/types/PortalUrlServiceTypes.js +0 -0
- package/dist/esm/services/types/PregenWalletServiceTypes.js +0 -0
- package/dist/esm/services/types/SessionManagementServiceTypes.js +0 -0
- package/dist/esm/services/types/SignupFlowServiceTypes.js +0 -0
- package/dist/esm/services/types/VerificationFlowServiceTypes.js +0 -0
- package/dist/esm/services/types/WalletServiceTypes.js +0 -0
- package/dist/esm/services/types/index.js +0 -0
- package/dist/esm/state/CoreStateManager.js +261 -0
- package/dist/esm/state/actors/authenticateWithEmailOrPhone.js +10 -0
- package/dist/esm/state/actors/authenticateWithExternalWallet.js +10 -0
- package/dist/esm/state/actors/authenticateWithFarcaster.js +10 -0
- package/dist/esm/state/actors/authenticateWithFarcasterLegacy.js +10 -0
- package/dist/esm/state/actors/authenticateWithTelegram.js +10 -0
- package/dist/esm/state/actors/authenticateWithTelegramLegacy.js +10 -0
- package/dist/esm/state/actors/checkUserState.js +13 -0
- package/dist/esm/state/actors/claimWallets.js +16 -0
- package/dist/esm/state/actors/connectExternalConnectors.js +14 -0
- package/dist/esm/state/actors/connectExternalWallet.js +10 -0
- package/dist/esm/state/actors/createGuestWallets.js +10 -0
- package/dist/esm/state/actors/createWallets.js +20 -0
- package/dist/esm/state/actors/polling.js +55 -0
- package/dist/esm/state/actors/processAuthentication.js +10 -0
- package/dist/esm/state/actors/setupAfterLogin.js +12 -0
- package/dist/esm/state/actors/setupPara.js +10 -0
- package/dist/esm/state/actors/signExternalWalletVerification.js +15 -0
- package/dist/esm/state/actors/switchExternalWallet.js +10 -0
- package/dist/esm/state/actors/verifyExternalWallet.js +10 -0
- package/dist/esm/state/actors/verifyNewAccount.js +10 -0
- package/dist/esm/state/actors/waitForExternalWalletProviders.js +14 -0
- package/dist/esm/state/machines/authStateMachine.helpers.js +92 -0
- package/dist/esm/state/machines/authStateMachine.js +1039 -0
- package/dist/esm/state/machines/coreStateMachine.js +343 -0
- package/dist/esm/state/machines/walletStateMachine.js +382 -0
- package/dist/esm/state/types/auth.js +0 -0
- package/dist/esm/state/types/core.js +0 -0
- package/dist/esm/state/types/wallet.js +0 -0
- package/dist/esm/types/authState.js +0 -0
- package/dist/esm/types/coreApi.js +3 -1
- package/dist/esm/types/index.js +1 -1
- package/dist/esm/types/serviceInterfaces.js +0 -0
- package/dist/esm/types/util.js +0 -0
- package/dist/esm/utils/formatting.js +6 -0
- package/dist/esm/utils/retryBackoff.js +7 -0
- package/dist/esm/utils/stateErrorHelpers.js +37 -0
- package/dist/esm/utils/stateListener.js +106 -0
- package/dist/types/ParaCore.d.ts +190 -119
- package/dist/types/PlatformUtils.d.ts +23 -0
- package/dist/types/constants.d.ts +1 -0
- package/dist/types/index.d.ts +4 -2
- package/dist/types/services/AuthService.d.ts +72 -0
- package/dist/types/services/BaseAuthFlowService.d.ts +28 -0
- package/dist/types/services/ExternalWalletService.d.ts +44 -0
- package/dist/types/services/LoginFlowService.d.ts +9 -0
- package/dist/types/services/PollingService.d.ts +35 -0
- package/dist/types/services/PortalUrlService.d.ts +26 -0
- package/dist/types/services/PregenWalletService.d.ts +38 -0
- package/dist/types/services/SessionManagementService.d.ts +28 -0
- package/dist/types/services/SignupFlowService.d.ts +10 -0
- package/dist/types/services/VerificationFlowService.d.ts +17 -0
- package/dist/types/services/WalletService.d.ts +54 -0
- package/dist/types/services/types/AuthServiceTypes.d.ts +147 -0
- package/dist/types/services/types/BaseAuthFlowServiceTypes.d.ts +4 -0
- package/dist/types/services/types/ExternalWalletServiceTypes.d.ts +67 -0
- package/dist/types/services/types/LoginFlowServiceTypes.d.ts +19 -0
- package/dist/types/services/types/PollingServiceTypes.d.ts +82 -0
- package/dist/types/services/types/PortalUrlServiceTypes.d.ts +46 -0
- package/dist/types/services/types/PregenWalletServiceTypes.d.ts +73 -0
- package/dist/types/services/types/SessionManagementServiceTypes.d.ts +27 -0
- package/dist/types/services/types/SignupFlowServiceTypes.d.ts +18 -0
- package/dist/types/services/types/VerificationFlowServiceTypes.d.ts +90 -0
- package/dist/types/services/types/WalletServiceTypes.d.ts +109 -0
- package/dist/types/services/types/index.d.ts +11 -0
- package/dist/types/state/CoreStateManager.d.ts +36 -0
- package/dist/types/state/actors/authenticateWithEmailOrPhone.d.ts +8 -0
- package/dist/types/state/actors/authenticateWithExternalWallet.d.ts +8 -0
- package/dist/types/state/actors/authenticateWithFarcaster.d.ts +3 -0
- package/dist/types/state/actors/authenticateWithFarcasterLegacy.d.ts +3 -0
- package/dist/types/state/actors/authenticateWithTelegram.d.ts +3 -0
- package/dist/types/state/actors/authenticateWithTelegramLegacy.d.ts +8 -0
- package/dist/types/state/actors/checkUserState.d.ts +6 -0
- package/dist/types/state/actors/claimWallets.d.ts +8 -0
- package/dist/types/state/actors/connectExternalConnectors.d.ts +4 -0
- package/dist/types/state/actors/connectExternalWallet.d.ts +3 -0
- package/dist/types/state/actors/createGuestWallets.d.ts +3 -0
- package/dist/types/state/actors/createWallets.d.ts +10 -0
- package/dist/types/state/actors/polling.d.ts +3 -0
- package/dist/types/state/actors/processAuthentication.d.ts +10 -0
- package/dist/types/state/actors/setupAfterLogin.d.ts +5 -0
- package/dist/types/state/actors/setupPara.d.ts +2 -0
- package/dist/types/state/actors/signExternalWalletVerification.d.ts +7 -0
- package/dist/types/state/actors/switchExternalWallet.d.ts +3 -0
- package/dist/types/state/actors/verifyExternalWallet.d.ts +8 -0
- package/dist/types/state/actors/verifyNewAccount.d.ts +8 -0
- package/dist/types/state/actors/waitForExternalWalletProviders.d.ts +2 -0
- package/dist/types/state/machines/authStateMachine.d.ts +2570 -0
- package/dist/types/state/machines/authStateMachine.helpers.d.ts +57 -0
- package/dist/types/state/machines/coreStateMachine.d.ts +22033 -0
- package/dist/types/state/machines/walletStateMachine.d.ts +1049 -0
- package/dist/types/state/types/auth.d.ts +113 -0
- package/dist/types/state/types/core.d.ts +114 -0
- package/dist/types/state/types/wallet.d.ts +76 -0
- package/dist/types/types/authState.d.ts +66 -0
- package/dist/types/types/config.d.ts +5 -0
- package/dist/types/types/coreApi.d.ts +148 -298
- package/dist/types/types/index.d.ts +3 -1
- package/dist/types/types/methods.d.ts +1 -191
- package/dist/types/types/serviceInterfaces.d.ts +125 -0
- package/dist/types/types/util.d.ts +43 -0
- package/dist/types/types/wallet.d.ts +3 -1
- package/dist/types/utils/retryBackoff.d.ts +2 -0
- package/dist/types/utils/stateErrorHelpers.d.ts +2 -0
- package/dist/types/utils/stateListener.d.ts +47 -0
- package/package.json +5 -4
- /package/dist/esm/types/{auth.js → accountLinking.js} +0 -0
- /package/dist/types/types/{auth.d.ts → accountLinking.d.ts} +0 -0
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import type { ServerAuthState } from '@getpara/user-management-client';
|
|
2
|
+
import type { AuthState, WithCustomTheme, WithUseShortUrls } from '../../types/index.js';
|
|
3
|
+
import type { createAuthStateMachine } from '../machines/authStateMachine.js';
|
|
4
|
+
import type { CoreActor, ServerAuthStateResult } from './core.js';
|
|
5
|
+
import type { LoginExternalWalletParams } from '../../services/types/AuthServiceTypes.js';
|
|
6
|
+
import type { PerformVerifyNewAccountParams, VerifyFarcasterParams, VerifyTelegramParams } from '../../services/types/VerificationFlowServiceTypes.js';
|
|
7
|
+
import type { WaitForWalletCreationParams } from '../../services/types/SignupFlowServiceTypes.js';
|
|
8
|
+
import type { BaseVerifyExternalWalletParams, ConnectExternalWalletParams, InitOAuthPollingParams, PerformConnectExternalWalletResponse, PerformSignUpOrLogInParams, ExternalSignMessageParams, SwitchExternalWalletParams, VerifyExternalWalletParams, WaitForTelegramEventParams, WaitForFarcasterEventParams, PollingCallbacks } from '../../services/types';
|
|
9
|
+
/**
|
|
10
|
+
* Represents the current phase of the authentication flow.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* // Check current auth phase
|
|
15
|
+
* if (authPhase === 'unauthenticated') {
|
|
16
|
+
* // Show login form
|
|
17
|
+
* } else if (authPhase === 'authenticated') {
|
|
18
|
+
* // The user's session is active
|
|
19
|
+
* }
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export type AuthPhase = 'uninitialized' | 'checking_state' | 'clearing_state' | 'unauthenticated' | 'authenticating_email_phone' | 'authenticating_oauth' | 'connecting_external_wallet' | 'switching_external_wallet' | 'authenticating_external_wallet' | 'authenticating_telegram' | 'authenticating_telegram_legacy' | 'authenticating_farcaster' | 'authenticating_farcaster_legacy' | 'waiting_for_farcaster' | 'processing_authentication' | 'awaiting_wallet_signature' | 'awaiting_wallet_verification' | 'awaiting_account_verification' | 'awaiting_session_start' | 'verifying_new_account' | 'verifying_external_wallet' | 'waiting_for_session' | 'authenticated' | 'guest_mode' | 'error' | 'signing_external_wallet_verification';
|
|
23
|
+
export type AuthEvents = {
|
|
24
|
+
type: 'AUTHENTICATE_EMAIL_PHONE';
|
|
25
|
+
data: PerformSignUpOrLogInParams & {
|
|
26
|
+
isLegacy: boolean;
|
|
27
|
+
};
|
|
28
|
+
} | {
|
|
29
|
+
type: 'AUTHENTICATE_OAUTH';
|
|
30
|
+
data: InitOAuthPollingParams & PollingCallbacks & {
|
|
31
|
+
isLegacy: boolean;
|
|
32
|
+
};
|
|
33
|
+
} | {
|
|
34
|
+
type: 'AUTHENTICATE_EXTERNAL_WALLET';
|
|
35
|
+
data: LoginExternalWalletParams;
|
|
36
|
+
} | {
|
|
37
|
+
type: 'CONNECT_EXTERNAL_WALLET';
|
|
38
|
+
data: ConnectExternalWalletParams;
|
|
39
|
+
} | {
|
|
40
|
+
type: 'SWITCH_EXTERNAL_WALLET';
|
|
41
|
+
data: SwitchExternalWalletParams;
|
|
42
|
+
} | {
|
|
43
|
+
type: 'AUTHENTICATE_TELEGRAM';
|
|
44
|
+
data: WaitForTelegramEventParams;
|
|
45
|
+
} | {
|
|
46
|
+
type: 'AUTHENTICATE_TELEGRAM_LEGACY';
|
|
47
|
+
data: VerifyTelegramParams;
|
|
48
|
+
} | {
|
|
49
|
+
type: 'AUTHENTICATE_FARCASTER';
|
|
50
|
+
data: WaitForFarcasterEventParams;
|
|
51
|
+
} | {
|
|
52
|
+
type: 'AUTHENTICATE_FARCASTER_LEGACY';
|
|
53
|
+
data: VerifyFarcasterParams;
|
|
54
|
+
} | {
|
|
55
|
+
type: 'VERIFY_NEW_ACCOUNT';
|
|
56
|
+
data: PerformVerifyNewAccountParams;
|
|
57
|
+
} | {
|
|
58
|
+
type: 'VERIFY_EXTERNAL_WALLET';
|
|
59
|
+
data?: VerifyExternalWalletParams;
|
|
60
|
+
} | {
|
|
61
|
+
type: 'SIGN_EXTERNAL_WALLET_VERIFICATION';
|
|
62
|
+
data: ExternalSignMessageParams;
|
|
63
|
+
} | {
|
|
64
|
+
type: 'WAIT_FOR_SESSION';
|
|
65
|
+
data: PollingCallbacks & {
|
|
66
|
+
autoCreateWallets?: boolean;
|
|
67
|
+
skipSessionRefresh?: boolean;
|
|
68
|
+
};
|
|
69
|
+
} | {
|
|
70
|
+
type: 'WAIT_FOR_WALLET_CREATION';
|
|
71
|
+
data?: WaitForWalletCreationParams;
|
|
72
|
+
} | {
|
|
73
|
+
type: 'RESET';
|
|
74
|
+
} | {
|
|
75
|
+
type: 'COMPLETE';
|
|
76
|
+
} | {
|
|
77
|
+
type: 'CANCEL';
|
|
78
|
+
} | {
|
|
79
|
+
type: 'INITIALIZE_GUEST_MODE';
|
|
80
|
+
} | {
|
|
81
|
+
type: 'SESSION_IMPORTED';
|
|
82
|
+
} | {
|
|
83
|
+
type: 'ERROR';
|
|
84
|
+
error: string;
|
|
85
|
+
};
|
|
86
|
+
export type AuthMachine = ReturnType<typeof createAuthStateMachine>;
|
|
87
|
+
export interface AuthContext {
|
|
88
|
+
coreRef: CoreActor | null;
|
|
89
|
+
authStateResult: AuthState | null;
|
|
90
|
+
serverAuthStateResult: ServerAuthStateResult;
|
|
91
|
+
isNewUser: boolean;
|
|
92
|
+
error: Error | null;
|
|
93
|
+
pollingCallbacks: PollingCallbacks | null;
|
|
94
|
+
shouldAutoCreateWallets: boolean;
|
|
95
|
+
skipSessionRefreshOnSetup: boolean;
|
|
96
|
+
externalWalletInfo?: PerformConnectExternalWalletResponse;
|
|
97
|
+
externalWalletSignVerification?: BaseVerifyExternalWalletParams;
|
|
98
|
+
isLegacy: boolean;
|
|
99
|
+
retryAttempts?: {
|
|
100
|
+
externalWalletVerification?: number;
|
|
101
|
+
newAccountVerification?: number;
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
export interface AuthInput {
|
|
105
|
+
coreRef: CoreActor;
|
|
106
|
+
}
|
|
107
|
+
export type AuthenticationOutput = {
|
|
108
|
+
authState: ServerAuthState;
|
|
109
|
+
opts: WithCustomTheme & WithUseShortUrls & {
|
|
110
|
+
sessionLookupId?: string;
|
|
111
|
+
isFromExternalWallet?: boolean;
|
|
112
|
+
};
|
|
113
|
+
};
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import type { BiometricLocationHint, CurrentWalletIds, ServerAuthState } from '@getpara/user-management-client';
|
|
2
|
+
import type { AuthState, Wallet, WithCustomTheme, WithUseShortUrls } from '../../types/index.js';
|
|
3
|
+
import { AuthMachine, AuthPhase } from './auth.js';
|
|
4
|
+
import { WalletMachine, WalletPhase } from './wallet.js';
|
|
5
|
+
import { BaseVerifyExternalWalletParams } from '../../services/types/VerificationFlowServiceTypes.js';
|
|
6
|
+
import { ActorRef, ActorRefFrom, Snapshot } from 'xstate';
|
|
7
|
+
/**
|
|
8
|
+
* Represents the current phase of the core flow.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* // Check current core phase
|
|
13
|
+
* if (corePhase === 'initializing') {
|
|
14
|
+
* // Show loading indicator
|
|
15
|
+
* } else if (corePhase === 'auth_flow') {
|
|
16
|
+
* // The user is in the authentication flow (refer to the authPhase for more details)
|
|
17
|
+
* } else if (corePhase === 'wallet_flow') {
|
|
18
|
+
* // The user is in the wallet flow (refer to the walletPhase for more details)
|
|
19
|
+
* } else if (corePhase === 'authenticated') {
|
|
20
|
+
* // The user is fully logged in
|
|
21
|
+
* }
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export type CorePhase = 'setting_up' | 'waiting_for_external_wallet_providers' | 'logging_out' | 'auth_flow' | 'wallet_flow' | 'authenticated' | 'guest_mode' | 'error';
|
|
25
|
+
export type CoreEvents = {
|
|
26
|
+
type: 'LOGOUT';
|
|
27
|
+
} | {
|
|
28
|
+
type: 'RETRY_WALLET_FLOW';
|
|
29
|
+
};
|
|
30
|
+
type ChildEvents = {
|
|
31
|
+
type: 'AUTHENTICATED' | 'GUEST_MODE';
|
|
32
|
+
};
|
|
33
|
+
export type CoreActor = ActorRef<Snapshot<unknown>, ChildEvents>;
|
|
34
|
+
export type CoreContext = {
|
|
35
|
+
isReady: boolean;
|
|
36
|
+
authMachineRef: ActorRefFrom<AuthMachine> | null;
|
|
37
|
+
walletMachineRef: ActorRefFrom<WalletMachine> | null;
|
|
38
|
+
error: Error | null;
|
|
39
|
+
setupRetryCount: number;
|
|
40
|
+
lastErrorSource: 'auth' | 'wallet' | null;
|
|
41
|
+
};
|
|
42
|
+
export interface CoreState {
|
|
43
|
+
phase: CorePhase;
|
|
44
|
+
isLoading: boolean;
|
|
45
|
+
error: Error | null;
|
|
46
|
+
isReady: boolean;
|
|
47
|
+
isNewUser: boolean;
|
|
48
|
+
authStatePhase: AuthPhase;
|
|
49
|
+
walletStatePhase: WalletPhase;
|
|
50
|
+
authStateInfo: AuthStateInfo;
|
|
51
|
+
authStateResult: AuthState | null;
|
|
52
|
+
newWalletsResult: {
|
|
53
|
+
walletIds: CurrentWalletIds;
|
|
54
|
+
recoverySecret: string | undefined;
|
|
55
|
+
} | null;
|
|
56
|
+
needsWallet: boolean;
|
|
57
|
+
externalWalletSignVerification?: BaseVerifyExternalWalletParams;
|
|
58
|
+
guestWallets: Wallet[] | null;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Contains all authentication state data needed by UI consumers.
|
|
62
|
+
* This is extracted from the internal authStateResult and provides
|
|
63
|
+
* a flat, consistent interface for rendering auth UIs.
|
|
64
|
+
*/
|
|
65
|
+
export type AuthStateInfo = {
|
|
66
|
+
/** User ID if available */
|
|
67
|
+
userId: string | null;
|
|
68
|
+
/** Whether the current device supports passkeys/WebAuthn */
|
|
69
|
+
isPasskeySupported: boolean;
|
|
70
|
+
/** Passkey hints for known device detection */
|
|
71
|
+
passkeyHints: BiometricLocationHint[] | null;
|
|
72
|
+
/** Whether the user has a passkey configured */
|
|
73
|
+
hasPasskey: boolean;
|
|
74
|
+
/** Whether the user has a password configured */
|
|
75
|
+
hasPassword: boolean;
|
|
76
|
+
/** Whether the user has a PIN configured */
|
|
77
|
+
hasPin: boolean;
|
|
78
|
+
/** Portal URL for passkey login/signup */
|
|
79
|
+
passkeyUrl: string | null;
|
|
80
|
+
/** Portal URL for authorizing from a known device with passkey */
|
|
81
|
+
passkeyKnownDeviceUrl: string | null;
|
|
82
|
+
/** Portal URL for password login/signup */
|
|
83
|
+
passwordUrl: string | null;
|
|
84
|
+
/** Portal URL for PIN login/signup */
|
|
85
|
+
pinUrl: string | null;
|
|
86
|
+
/** Verification URL for email/phone verification in SLO */
|
|
87
|
+
verificationUrl: string | null;
|
|
88
|
+
/** External wallet verification data when signature is needed */
|
|
89
|
+
externalWalletVerification: {
|
|
90
|
+
signatureVerificationMessage: string;
|
|
91
|
+
walletAddress: string;
|
|
92
|
+
walletType: string;
|
|
93
|
+
} | null;
|
|
94
|
+
/** Recovery secret after wallet creation */
|
|
95
|
+
recoverySecret: string | null;
|
|
96
|
+
/** Whether this is a new user (signup flow) */
|
|
97
|
+
isNewUser: boolean;
|
|
98
|
+
};
|
|
99
|
+
export type StateSnapshot = {
|
|
100
|
+
corePhase: CorePhase;
|
|
101
|
+
authPhase: AuthPhase;
|
|
102
|
+
walletPhase: WalletPhase;
|
|
103
|
+
authStateInfo: AuthStateInfo;
|
|
104
|
+
error: Error | null;
|
|
105
|
+
isReady: boolean;
|
|
106
|
+
};
|
|
107
|
+
export type ServerAuthStateResult = {
|
|
108
|
+
authState: ServerAuthState | null;
|
|
109
|
+
opts: WithCustomTheme & WithUseShortUrls & {
|
|
110
|
+
sessionLookupId?: string;
|
|
111
|
+
isFromExternalWallet?: boolean;
|
|
112
|
+
};
|
|
113
|
+
} | null;
|
|
114
|
+
export {};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import type { CurrentWalletIds } from '@getpara/user-management-client';
|
|
2
|
+
import type { createWalletStateMachine } from '../machines/walletStateMachine.js';
|
|
3
|
+
import type { AuthState, Wallet } from '../../types/index.js';
|
|
4
|
+
import type { PollingCallbacks } from '../../services/types/PollingServiceTypes.js';
|
|
5
|
+
export type WalletMachine = ReturnType<typeof createWalletStateMachine>;
|
|
6
|
+
/**
|
|
7
|
+
* Represents the current phase of the wallet flow.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* // Check current wallet phase
|
|
12
|
+
* if (walletPhase === 'needs_wallets') {
|
|
13
|
+
* // Call waitForWalletCreation to create wallets
|
|
14
|
+
* } else if (walletPhase === 'wallets_ready' || walletPhase === 'no_wallets_needed') {
|
|
15
|
+
* // The user's wallets are ready (if applicable) and they are fully logged in
|
|
16
|
+
* }
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export type WalletPhase = 'uninitialized' | 'checking_wallet_state' | 'needs_wallets' | 'claiming_wallets' | 'creating_wallets' | 'connecting_para_connectors' | 'waiting_for_wallets' | 'setting_up_after_login' | 'no_wallets_needed' | 'wallets_ready' | 'guest_mode' | 'creating_guest_wallets' | 'error';
|
|
20
|
+
export type WalletEvents = {
|
|
21
|
+
type: 'WAIT_FOR_WALLET_CREATION';
|
|
22
|
+
data?: {
|
|
23
|
+
pollingCallbacks?: PollingCallbacks;
|
|
24
|
+
};
|
|
25
|
+
} | {
|
|
26
|
+
type: 'SET_NEEDS_WALLET';
|
|
27
|
+
data: {
|
|
28
|
+
needsWallet: boolean;
|
|
29
|
+
};
|
|
30
|
+
} | {
|
|
31
|
+
type: 'SET_TEMPORARY_SHARES';
|
|
32
|
+
data: {
|
|
33
|
+
temporaryShares: any[];
|
|
34
|
+
};
|
|
35
|
+
} | {
|
|
36
|
+
type: 'COMPLETE';
|
|
37
|
+
} | {
|
|
38
|
+
type: 'CLAIM_WALLETS';
|
|
39
|
+
} | {
|
|
40
|
+
type: 'ERROR';
|
|
41
|
+
error: string;
|
|
42
|
+
};
|
|
43
|
+
export interface WalletContext {
|
|
44
|
+
needsWallet: boolean;
|
|
45
|
+
newWalletsResult: {
|
|
46
|
+
walletIds: CurrentWalletIds;
|
|
47
|
+
recoverySecret: string | undefined;
|
|
48
|
+
} | null;
|
|
49
|
+
temporaryShares: any[] | null;
|
|
50
|
+
pollingCallbacks: PollingCallbacks | null;
|
|
51
|
+
error: Error | null;
|
|
52
|
+
authData: {
|
|
53
|
+
shouldAutoCreateWallets: boolean;
|
|
54
|
+
isNewUser: boolean;
|
|
55
|
+
authStateResult: AuthState | null;
|
|
56
|
+
skipSessionRefreshOnSetup: boolean;
|
|
57
|
+
isGuestMode?: boolean;
|
|
58
|
+
} | null;
|
|
59
|
+
guestWallets: Wallet[] | null;
|
|
60
|
+
retryAttempts: {
|
|
61
|
+
claiming?: number;
|
|
62
|
+
creating?: number;
|
|
63
|
+
connecting?: number;
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
export interface WalletMachineInput {
|
|
67
|
+
shouldAutoCreateWallets?: boolean;
|
|
68
|
+
isNewUser?: boolean;
|
|
69
|
+
authStateResult?: AuthState | null;
|
|
70
|
+
skipSessionRefreshOnSetup?: boolean;
|
|
71
|
+
isGuestMode?: boolean;
|
|
72
|
+
previousWalletsResult?: {
|
|
73
|
+
walletIds: CurrentWalletIds;
|
|
74
|
+
recoverySecret: string | undefined;
|
|
75
|
+
} | null;
|
|
76
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { AuthExtras, PrimaryAuthInfo, ServerAuthStateDone, ServerAuthStateLogin, ServerAuthStateSignup, ServerAuthStateVerify, TAuthMethod } from '@getpara/user-management-client';
|
|
2
|
+
import type { WithCustomTheme, WithIsPasskeySupported, WithUseShortUrls } from './util';
|
|
3
|
+
export type CoreAuthInfo = PrimaryAuthInfo & AuthExtras;
|
|
4
|
+
export type AuthStateBaseParams = WithCustomTheme & WithUseShortUrls;
|
|
5
|
+
export type AuthStateVerify = ServerAuthStateVerify & {
|
|
6
|
+
loginUrl?: string;
|
|
7
|
+
};
|
|
8
|
+
export type AuthStateLogin = Omit<ServerAuthStateLogin, 'loginAuthMethods'> & WithIsPasskeySupported & {
|
|
9
|
+
/**
|
|
10
|
+
* A Para Portal URL for logging in via a WebAuth passkey. For best compatibility, you should open this URL in a new window or tab.
|
|
11
|
+
*/
|
|
12
|
+
passkeyUrl?: string;
|
|
13
|
+
/**
|
|
14
|
+
* A Para Portal URL for authorizing a new device using a WebAuth passkey located elsewhere, to be visited using that other device.
|
|
15
|
+
*/
|
|
16
|
+
passkeyKnownDeviceUrl?: string;
|
|
17
|
+
/**
|
|
18
|
+
* A Para Portal URL for logging in via a password.
|
|
19
|
+
*/
|
|
20
|
+
passwordUrl?: string;
|
|
21
|
+
/**
|
|
22
|
+
* A Para Portal URL for logging in via a PIN.
|
|
23
|
+
*/
|
|
24
|
+
pinUrl?: string;
|
|
25
|
+
/**
|
|
26
|
+
* Supported login auth methods for this session.
|
|
27
|
+
*/
|
|
28
|
+
loginAuthMethods?: TAuthMethod[];
|
|
29
|
+
};
|
|
30
|
+
export type AuthStateSignup = Omit<ServerAuthStateSignup, 'signupAuthMethods'> & WithIsPasskeySupported & {
|
|
31
|
+
/**
|
|
32
|
+
* A Para Portal URL for creating a new WebAuth passkey.
|
|
33
|
+
*/
|
|
34
|
+
passkeyUrl?: string;
|
|
35
|
+
/**
|
|
36
|
+
* A Para Portal URL for creating a new user password.
|
|
37
|
+
*/
|
|
38
|
+
passwordUrl?: string;
|
|
39
|
+
/**
|
|
40
|
+
* A Para Portal URL for creating a new user PIN.
|
|
41
|
+
*/
|
|
42
|
+
pinUrl?: string;
|
|
43
|
+
/**
|
|
44
|
+
* The Para system ID for the newly generated passkey.
|
|
45
|
+
*/
|
|
46
|
+
passkeyId?: string;
|
|
47
|
+
/**
|
|
48
|
+
* The Para system ID for the newly generated password.
|
|
49
|
+
*/
|
|
50
|
+
passwordId?: string;
|
|
51
|
+
/**
|
|
52
|
+
* The Para system ID for the newly generated PIN.
|
|
53
|
+
*/
|
|
54
|
+
pinId?: string;
|
|
55
|
+
/**
|
|
56
|
+
* Supported signup auth methods for this session.
|
|
57
|
+
*/
|
|
58
|
+
signupAuthMethods?: TAuthMethod[];
|
|
59
|
+
};
|
|
60
|
+
export type AuthStateDone = Omit<ServerAuthStateDone, 'authMethods'> & {
|
|
61
|
+
authMethods: TAuthMethod[];
|
|
62
|
+
};
|
|
63
|
+
export type AuthStateVerifyOrLogin = AuthStateVerify | AuthStateLogin;
|
|
64
|
+
export type AuthStateSignupOrLoginOrDone = AuthStateSignup | AuthStateLogin | AuthStateDone;
|
|
65
|
+
export type OAuthResponse = AuthStateSignupOrLoginOrDone;
|
|
66
|
+
export type AuthState = AuthStateVerify | AuthStateLogin | AuthStateSignup | AuthStateDone;
|
|
@@ -151,4 +151,9 @@ export interface ConstructorOpts {
|
|
|
151
151
|
}) => Promise<{
|
|
152
152
|
userShare?: string;
|
|
153
153
|
}>;
|
|
154
|
+
/**
|
|
155
|
+
* If `true`, enables verbose logging for debugging purposes. This will output additional internal SDK operations to the console.
|
|
156
|
+
* @default false
|
|
157
|
+
*/
|
|
158
|
+
enableDebugLogs?: boolean;
|
|
154
159
|
}
|