@getpara/core-sdk 2.12.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 +793 -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 +796 -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
|
@@ -1,88 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { VerifiedAuth, RecoveryStatus, TelegramAuthResponse, VerifyThirdPartyAuth } from '@getpara/user-management-client';
|
|
2
2
|
import { Wallet } from './wallet.js';
|
|
3
|
-
type Device = {
|
|
4
|
-
sessionId: string;
|
|
5
|
-
encryptionKey: string;
|
|
6
|
-
};
|
|
7
|
-
export type EmbeddedWalletType = Exclude<TWalletType, never>;
|
|
8
|
-
export type ExternalWalletType = Exclude<TWalletType, never>;
|
|
9
3
|
export type VerifyExternalWalletV1 = {
|
|
10
4
|
address: string;
|
|
11
5
|
signedMessage: string;
|
|
12
6
|
cosmosPublicKeyHex?: string;
|
|
13
7
|
cosmosSigner?: string;
|
|
14
8
|
};
|
|
15
|
-
export type PortalUrlType = 'createAuth' | 'createPassword' | 'loginAuth' | 'loginPassword' | 'txReview' | 'onRamp' | 'telegramLogin' | 'createPIN' | 'loginPIN' | 'oAuth' | 'oAuthCallback' | 'loginOTP' | 'telegramLoginVerify' | 'loginFarcaster' | 'switchWallets' | 'addNewCredential' | 'exportPrivateKey' | 'loginExternalWallet' | 'connectExternalWallet';
|
|
16
|
-
export type PortalUrlOptions = {
|
|
17
|
-
params?: Record<string, string | undefined | null>;
|
|
18
|
-
isForNewDevice?: boolean;
|
|
19
|
-
thisDevice?: Device;
|
|
20
|
-
newDevice?: Device;
|
|
21
|
-
sessionId?: string;
|
|
22
|
-
portalTheme?: Theme;
|
|
23
|
-
pathId?: string;
|
|
24
|
-
shorten?: boolean;
|
|
25
|
-
isEmbedded?: boolean;
|
|
26
|
-
oAuthMethod?: OAuthUrlParams['method'];
|
|
27
|
-
appScheme?: string;
|
|
28
|
-
encryptionKey?: string;
|
|
29
|
-
addNewCredentialType?: TAuthMethod;
|
|
30
|
-
addNewCredentialPasswordId?: string;
|
|
31
|
-
addNewCredentialPasskeyId?: string;
|
|
32
|
-
useLegacyUrl?: boolean;
|
|
33
|
-
};
|
|
34
|
-
export type WithAuthMethod = {
|
|
35
|
-
/**
|
|
36
|
-
* Which authorization method to use for the URL, either `'PASSKEY'`, `'PASSWORD'` or `'PIN'`.
|
|
37
|
-
*/
|
|
38
|
-
authMethod?: Uppercase<TAuthMethod>;
|
|
39
|
-
};
|
|
40
|
-
export type WithCustomTheme = {
|
|
41
|
-
/**
|
|
42
|
-
* The theme to apply to generated URLs, if different from your configured theme.
|
|
43
|
-
*/
|
|
44
|
-
portalTheme?: Theme;
|
|
45
|
-
};
|
|
46
|
-
export type WithUseShortUrls = {
|
|
47
|
-
/**
|
|
48
|
-
* Whether to shorten generated URLs. This may correct any issues with generated QR codes. Defaults to `false`.
|
|
49
|
-
*/
|
|
50
|
-
useShortUrls?: boolean;
|
|
51
|
-
};
|
|
52
|
-
export type WithShorten = {
|
|
53
|
-
/**
|
|
54
|
-
* Whether to shorten the generated URL. This may correct any issues with generated QR codes. Defaults to `false`.
|
|
55
|
-
*/
|
|
56
|
-
shorten?: boolean;
|
|
57
|
-
};
|
|
58
|
-
export type WithIsPasskeySupported = {
|
|
59
|
-
/**
|
|
60
|
-
* Whether the current device supports WebAuth passkeys.
|
|
61
|
-
*/
|
|
62
|
-
isPasskeySupported: boolean;
|
|
63
|
-
};
|
|
64
|
-
export type PollParams = {
|
|
65
|
-
/**
|
|
66
|
-
* A callback function that will be invoked on each method poll.
|
|
67
|
-
*/
|
|
68
|
-
onPoll?: () => void;
|
|
69
|
-
/**
|
|
70
|
-
* A callback function that will be invoked if the method call is canceled.
|
|
71
|
-
*/
|
|
72
|
-
onCancel?: () => void;
|
|
73
|
-
};
|
|
74
|
-
export type FarcasterParams = PollParams & {
|
|
75
|
-
/**
|
|
76
|
-
* A function returning a boolean, indicating whether the Farcaster login process should be cancelled.
|
|
77
|
-
*/
|
|
78
|
-
isCanceled?: () => boolean;
|
|
79
|
-
/**
|
|
80
|
-
* A callback function that will be invoked with the Farcaster Connect URI when it is available.
|
|
81
|
-
* You will need to display the URI as a QR code.
|
|
82
|
-
*/
|
|
83
|
-
onConnectUri?: (uri: string) => void;
|
|
84
|
-
serverAuthState?: VerifyThirdPartyAuth;
|
|
85
|
-
};
|
|
86
9
|
export type TelegramParams = {
|
|
87
10
|
/**
|
|
88
11
|
* The response received from the Telegram login bot.
|
|
@@ -90,112 +13,6 @@ export type TelegramParams = {
|
|
|
90
13
|
telegramAuthResponse?: TelegramAuthResponse;
|
|
91
14
|
serverAuthState?: VerifyThirdPartyAuth;
|
|
92
15
|
};
|
|
93
|
-
export type LoginUrlParams = WithAuthMethod & WithCustomTheme & WithShorten & {
|
|
94
|
-
sessionId?: string;
|
|
95
|
-
};
|
|
96
|
-
export type NewCredentialUrlParams = WithCustomTheme & WithShorten & {
|
|
97
|
-
/**
|
|
98
|
-
* Whether the URL is meant to add a passkey for a previous user on a new device. Defaults to `false`.
|
|
99
|
-
*/
|
|
100
|
-
isForNewDevice?: boolean;
|
|
101
|
-
/**
|
|
102
|
-
* The authentication method to add.
|
|
103
|
-
*/
|
|
104
|
-
authMethod?: TAuthMethod;
|
|
105
|
-
};
|
|
106
|
-
export type OAuthUrlParams = {
|
|
107
|
-
/**
|
|
108
|
-
* The third-party OAuth service.
|
|
109
|
-
*/
|
|
110
|
-
method: Exclude<TOAuthMethod, 'TELEGRAM' | 'FARCASTER'>;
|
|
111
|
-
/**
|
|
112
|
-
* The app scheme to redirect to after OAuth is complete.
|
|
113
|
-
*/
|
|
114
|
-
appScheme?: string;
|
|
115
|
-
};
|
|
116
|
-
export type OAuthParams = OAuthUrlParams & PollParams & {
|
|
117
|
-
/**
|
|
118
|
-
* A function returning a boolean, indicating whether the OAuth process should be cancelled.
|
|
119
|
-
*/
|
|
120
|
-
isCanceled?: () => boolean;
|
|
121
|
-
/**
|
|
122
|
-
* A callback function that will be invoked with the OAuth URL when it is available.
|
|
123
|
-
* For example, you can use this to open the URL in a new window or tab.
|
|
124
|
-
*
|
|
125
|
-
* You should pass one of `onOAuthUrl` or `onOAuthPopup`, not both.
|
|
126
|
-
*/
|
|
127
|
-
onOAuthUrl?: (url: string) => void;
|
|
128
|
-
/**
|
|
129
|
-
* A callback function that will be invoked with the OAuth popup window when it is available.
|
|
130
|
-
* If supplied, a window will automatically be opened for you if running on an applicable platform.
|
|
131
|
-
*
|
|
132
|
-
* You should pass one of `onOAuthUrl` or `onOAuthPopup`, not both.
|
|
133
|
-
*/
|
|
134
|
-
onOAuthPopup?: (popup: Window) => void;
|
|
135
|
-
};
|
|
136
|
-
export type AuthStateBaseParams = WithCustomTheme & WithUseShortUrls;
|
|
137
|
-
export type AuthStateVerify = ServerAuthStateVerify & {
|
|
138
|
-
loginUrl?: string;
|
|
139
|
-
};
|
|
140
|
-
export type AuthStateLogin = Omit<ServerAuthStateLogin, 'loginAuthMethods'> & WithIsPasskeySupported & {
|
|
141
|
-
/**
|
|
142
|
-
* 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.
|
|
143
|
-
*/
|
|
144
|
-
passkeyUrl?: string;
|
|
145
|
-
/**
|
|
146
|
-
* A Para Portal URL for authorizing a new device using a WebAuth passkey located elsewhere, to be visited using that other device.
|
|
147
|
-
*/
|
|
148
|
-
passkeyKnownDeviceUrl?: string;
|
|
149
|
-
/**
|
|
150
|
-
* A Para Portal URL for logging in via a password.
|
|
151
|
-
*/
|
|
152
|
-
passwordUrl?: string;
|
|
153
|
-
/**
|
|
154
|
-
* A Para Portal URL for logging in via a PIN.
|
|
155
|
-
*/
|
|
156
|
-
pinUrl?: string;
|
|
157
|
-
/**
|
|
158
|
-
* Supported login auth methods for this session.
|
|
159
|
-
*/
|
|
160
|
-
loginAuthMethods?: TAuthMethod[];
|
|
161
|
-
};
|
|
162
|
-
export type AuthStateSignup = Omit<ServerAuthStateSignup, 'signupAuthMethods'> & WithIsPasskeySupported & {
|
|
163
|
-
/**
|
|
164
|
-
* A Para Portal URL for creating a new WebAuth passkey.
|
|
165
|
-
*/
|
|
166
|
-
passkeyUrl?: string;
|
|
167
|
-
/**
|
|
168
|
-
* A Para Portal URL for creating a new user password.
|
|
169
|
-
*/
|
|
170
|
-
passwordUrl?: string;
|
|
171
|
-
/**
|
|
172
|
-
* A Para Portal URL for creating a new user PIN.
|
|
173
|
-
*/
|
|
174
|
-
pinUrl?: string;
|
|
175
|
-
/**
|
|
176
|
-
* The Para system ID for the newly generated passkey.
|
|
177
|
-
*/
|
|
178
|
-
passkeyId?: string;
|
|
179
|
-
/**
|
|
180
|
-
* The Para system ID for the newly generated password.
|
|
181
|
-
*/
|
|
182
|
-
passwordId?: string;
|
|
183
|
-
/**
|
|
184
|
-
* The Para system ID for the newly generated PIN.
|
|
185
|
-
*/
|
|
186
|
-
pinId?: string;
|
|
187
|
-
/**
|
|
188
|
-
* Supported signup auth methods for this session.
|
|
189
|
-
*/
|
|
190
|
-
signupAuthMethods?: TAuthMethod[];
|
|
191
|
-
};
|
|
192
|
-
export type AuthStateDone = Omit<ServerAuthStateDone, 'authMethods'> & {
|
|
193
|
-
authMethods: TAuthMethod[];
|
|
194
|
-
};
|
|
195
|
-
export type AuthStateVerifyOrLogin = AuthStateVerify | AuthStateLogin;
|
|
196
|
-
export type AuthStateSignupOrLoginOrDone = AuthStateSignup | AuthStateLogin | AuthStateDone;
|
|
197
|
-
export type OAuthResponse = AuthStateSignupOrLoginOrDone;
|
|
198
|
-
export type AuthState = AuthStateVerify | AuthStateLogin | AuthStateSignup | AuthStateDone;
|
|
199
16
|
export type Verify2faParams = {
|
|
200
17
|
auth: VerifiedAuth;
|
|
201
18
|
verificationCode: string;
|
|
@@ -218,11 +35,4 @@ export type Verify2faResponse = {
|
|
|
218
35
|
*/
|
|
219
36
|
wallets: Pick<Wallet, 'address' | 'id'>[];
|
|
220
37
|
};
|
|
221
|
-
export type CoreAuthInfo = PrimaryAuthInfo & AuthExtras;
|
|
222
38
|
export type StorageType = 'local' | 'session' | 'secure' | 'all';
|
|
223
|
-
export type GetWalletBalanceParams = {
|
|
224
|
-
walletId: string;
|
|
225
|
-
rpcUrl?: string;
|
|
226
|
-
};
|
|
227
|
-
export type GetWalletBalanceResponse = Promise<string | undefined>;
|
|
228
|
-
export {};
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import type { pki as pkiType } from 'node-forge';
|
|
2
|
+
import type { PartnerEntity, BackupKitEmailProps, VerificationEmailProps, TLinkedAccountType, Theme } from '@getpara/user-management-client';
|
|
3
|
+
import type { Ctx, Environment, AccountLinkInProgress, ConstructorOpts } from './index.js';
|
|
4
|
+
import type { PlatformUtils } from '../PlatformUtils.js';
|
|
5
|
+
import type { AuthService } from '../services/AuthService.js';
|
|
6
|
+
import type { WalletService } from '../services/WalletService.js';
|
|
7
|
+
import type { PregenWalletService } from '../services/PregenWalletService.js';
|
|
8
|
+
import type { PollingService } from '../services/PollingService.js';
|
|
9
|
+
import type { SessionManagementService } from '../services/SessionManagementService.js';
|
|
10
|
+
import type { ExternalWalletService } from '../services/ExternalWalletService.js';
|
|
11
|
+
import { PortalUrlService } from '../services/PortalUrlService.js';
|
|
12
|
+
export interface AuthServiceInterface {
|
|
13
|
+
logout: (opts?: {
|
|
14
|
+
clearPregenWallets?: boolean;
|
|
15
|
+
skipStateReset?: boolean;
|
|
16
|
+
}) => Promise<void>;
|
|
17
|
+
setLoginEncryptionKeyPair: (keyPair?: pkiType.rsa.KeyPair) => Promise<void>;
|
|
18
|
+
localStorageGetItem: (key: string) => Promise<string | null> | string | null;
|
|
19
|
+
localStorageSetItem: (key: string, value: string) => Promise<void> | void;
|
|
20
|
+
localStorageRemoveItem: (key: string) => Promise<void> | void;
|
|
21
|
+
isPasskeySupported: () => Promise<boolean>;
|
|
22
|
+
getVerificationEmailProps: () => VerificationEmailProps;
|
|
23
|
+
displayModalError: (error?: string) => void;
|
|
24
|
+
isPortal: (envOverride?: Environment) => boolean;
|
|
25
|
+
assertIsLinkingAccount: (types?: TLinkedAccountType[]) => AccountLinkInProgress;
|
|
26
|
+
requireApiKey: () => void;
|
|
27
|
+
get loginEncryptionKeyPair(): pkiType.rsa.KeyPair | undefined;
|
|
28
|
+
isNativePasskey: boolean;
|
|
29
|
+
ctx: Ctx;
|
|
30
|
+
get accountLinkInProgress(): AccountLinkInProgress | undefined;
|
|
31
|
+
partnerId: string | undefined;
|
|
32
|
+
platformUtils: PlatformUtils;
|
|
33
|
+
externalWalletConnectionOnly: boolean;
|
|
34
|
+
}
|
|
35
|
+
export interface WalletServiceInterface {
|
|
36
|
+
assertPartner: () => Promise<PartnerEntity>;
|
|
37
|
+
requireApiKey: () => void;
|
|
38
|
+
isPortal: () => boolean;
|
|
39
|
+
localStorageSetItem: (key: string, value: string) => Promise<void> | void;
|
|
40
|
+
getBackupKitEmailProps: () => BackupKitEmailProps;
|
|
41
|
+
retrieveSessionCookie: () => string | undefined;
|
|
42
|
+
isParaConnect: () => boolean;
|
|
43
|
+
ctx: Ctx;
|
|
44
|
+
get partner(): PartnerEntity | undefined;
|
|
45
|
+
platformUtils: PlatformUtils;
|
|
46
|
+
cosmosPrefix: string | undefined;
|
|
47
|
+
}
|
|
48
|
+
export interface PregenWalletServiceInterface {
|
|
49
|
+
assertPartner: () => Promise<PartnerEntity>;
|
|
50
|
+
requireApiKey: () => void;
|
|
51
|
+
getBackupKitEmailProps: () => BackupKitEmailProps;
|
|
52
|
+
isPortal: () => boolean;
|
|
53
|
+
retrieveSessionCookie: () => string | undefined;
|
|
54
|
+
fetchPregenWalletsOverride: ConstructorOpts['fetchPregenWalletsOverride'];
|
|
55
|
+
ctx: Ctx;
|
|
56
|
+
platformUtils: PlatformUtils;
|
|
57
|
+
get partner(): PartnerEntity | undefined;
|
|
58
|
+
}
|
|
59
|
+
export interface ExternalWalletServiceInterface {
|
|
60
|
+
assertPartner: () => Promise<PartnerEntity>;
|
|
61
|
+
localStorageSetItem: (key: string, value: string) => Promise<void> | void;
|
|
62
|
+
logout: (opts?: {
|
|
63
|
+
clearPregenWallets?: boolean;
|
|
64
|
+
skipStateReset?: boolean;
|
|
65
|
+
}) => Promise<void>;
|
|
66
|
+
}
|
|
67
|
+
export interface PortalUrlServiceInterface {
|
|
68
|
+
assertPartner: () => Promise<PartnerEntity>;
|
|
69
|
+
setLoginEncryptionKeyPair: (keyPair?: pkiType.rsa.KeyPair) => Promise<void>;
|
|
70
|
+
isPortal: (envOverride?: Environment) => boolean;
|
|
71
|
+
isPartnerOptional: boolean | undefined;
|
|
72
|
+
ctx: Ctx;
|
|
73
|
+
get loginEncryptionKeyPair(): pkiType.rsa.KeyPair | undefined;
|
|
74
|
+
portalTheme?: Theme;
|
|
75
|
+
portalPrimaryButtonColor?: string;
|
|
76
|
+
portalTextColor?: string;
|
|
77
|
+
portalPrimaryButtonTextColor?: string;
|
|
78
|
+
portalBackgroundColor?: string;
|
|
79
|
+
borderRadius?: string;
|
|
80
|
+
get accountLinkInProgress(): AccountLinkInProgress | undefined;
|
|
81
|
+
}
|
|
82
|
+
export interface SessionManagementServiceInterface {
|
|
83
|
+
displayModalError: (error?: string) => void;
|
|
84
|
+
setLoginEncryptionKeyPair: (keyPair?: pkiType.rsa.KeyPair) => Promise<void>;
|
|
85
|
+
initializeWorker: () => Promise<void>;
|
|
86
|
+
isPortal: () => boolean;
|
|
87
|
+
getPartner: (_: string) => Promise<PartnerEntity>;
|
|
88
|
+
assertPartner: () => Promise<PartnerEntity>;
|
|
89
|
+
platformUtils: PlatformUtils;
|
|
90
|
+
ctx: Ctx;
|
|
91
|
+
get loginEncryptionKeyPair(): pkiType.rsa.KeyPair | undefined;
|
|
92
|
+
isWorkerInitialized: boolean;
|
|
93
|
+
get partner(): PartnerEntity | undefined;
|
|
94
|
+
isReady: boolean;
|
|
95
|
+
isSwitchingWallets: boolean;
|
|
96
|
+
isNoWalletConfig: boolean;
|
|
97
|
+
}
|
|
98
|
+
export interface PollingServiceInterface {
|
|
99
|
+
isPortal: () => boolean;
|
|
100
|
+
devLog: (...s: any[]) => void;
|
|
101
|
+
popupWindow: Window | null;
|
|
102
|
+
platformUtils: PlatformUtils;
|
|
103
|
+
ctx: Ctx;
|
|
104
|
+
}
|
|
105
|
+
export interface StateMachineInterface {
|
|
106
|
+
setup: () => Promise<void>;
|
|
107
|
+
logout: (opts?: {
|
|
108
|
+
clearPregenWallets?: boolean;
|
|
109
|
+
skipStateReset?: boolean;
|
|
110
|
+
}) => Promise<void>;
|
|
111
|
+
isPortal: (envOverride?: Environment) => boolean;
|
|
112
|
+
setupAfterLogin: ({}: {
|
|
113
|
+
temporaryShares: any[];
|
|
114
|
+
skipSessionRefresh?: boolean;
|
|
115
|
+
}) => Promise<void>;
|
|
116
|
+
devLog: (...s: any[]) => void;
|
|
117
|
+
authService: AuthService;
|
|
118
|
+
walletService: WalletService;
|
|
119
|
+
pregenWalletService: PregenWalletService;
|
|
120
|
+
pollingService: PollingService;
|
|
121
|
+
externalWalletService: ExternalWalletService;
|
|
122
|
+
sessionManagementService: SessionManagementService;
|
|
123
|
+
portalUrlService: PortalUrlService;
|
|
124
|
+
get isNoWalletConfig(): boolean;
|
|
125
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { TAuthMethod, Theme } from '@getpara/user-management-client';
|
|
2
|
+
export type WithAuthMethod = {
|
|
3
|
+
/**
|
|
4
|
+
* Which authorization method to use for the URL, either `'PASSKEY'`, `'PASSWORD'` or `'PIN'`.
|
|
5
|
+
*/
|
|
6
|
+
authMethod?: Uppercase<TAuthMethod>;
|
|
7
|
+
};
|
|
8
|
+
export type WithCustomTheme = {
|
|
9
|
+
/**
|
|
10
|
+
* The theme to apply to generated URLs, if different from your configured theme.
|
|
11
|
+
*/
|
|
12
|
+
portalTheme?: Theme;
|
|
13
|
+
};
|
|
14
|
+
export type WithUseShortUrls = {
|
|
15
|
+
/**
|
|
16
|
+
* Whether to shorten generated URLs. This may correct any issues with generated QR codes. Defaults to `false`.
|
|
17
|
+
*/
|
|
18
|
+
useShortUrls?: boolean;
|
|
19
|
+
};
|
|
20
|
+
export type WithSessionLookupId = {
|
|
21
|
+
/**
|
|
22
|
+
* The session lookup ID to use for generated URLs.
|
|
23
|
+
*/
|
|
24
|
+
sessionLookupId?: string;
|
|
25
|
+
};
|
|
26
|
+
export type WithSessionId = {
|
|
27
|
+
/**
|
|
28
|
+
* The session ID to use for generated URLs.
|
|
29
|
+
*/
|
|
30
|
+
sessionId?: string;
|
|
31
|
+
};
|
|
32
|
+
export type WithShorten = {
|
|
33
|
+
/**
|
|
34
|
+
* Whether to shorten the generated URL. This may correct any issues with generated QR codes. Defaults to `false`.
|
|
35
|
+
*/
|
|
36
|
+
shorten?: boolean;
|
|
37
|
+
};
|
|
38
|
+
export type WithIsPasskeySupported = {
|
|
39
|
+
/**
|
|
40
|
+
* Whether the current device supports WebAuth passkeys.
|
|
41
|
+
*/
|
|
42
|
+
isPasskeySupported: boolean;
|
|
43
|
+
};
|
|
@@ -26,6 +26,7 @@ export interface Wallet extends Omit<IWalletEntity, 'createdAt' | 'updatedAt' |
|
|
|
26
26
|
ensName?: string | null;
|
|
27
27
|
ensAvatar?: string | null;
|
|
28
28
|
}
|
|
29
|
+
export type WalletNoSigner = Omit<Wallet, 'signer'>;
|
|
29
30
|
export type AvailableWallet = Pick<Wallet, 'id' | 'type' | 'name' | 'address' | 'partner' | 'ensName' | 'ensAvatar' | 'isExternal' | 'externalProviderId' | 'isExternalConnectionOnly'> & {
|
|
30
31
|
addressShort?: string;
|
|
31
32
|
displayName?: string;
|
|
@@ -46,4 +47,5 @@ export interface DeniedSignatureResWithUrl extends DeniedSignatureRes {
|
|
|
46
47
|
}
|
|
47
48
|
export type SignatureRes = SuccessfulSignatureRes | DeniedSignatureRes;
|
|
48
49
|
export type FullSignatureRes = SuccessfulSignatureRes | DeniedSignatureResWithUrl;
|
|
49
|
-
export type
|
|
50
|
+
export type EmbeddedWalletType = Exclude<TWalletType, never>;
|
|
51
|
+
export type ExternalWalletType = Exclude<TWalletType, never>;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { CoreStateManager } from '../state/CoreStateManager.js';
|
|
2
|
+
import { AuthPhase } from '../state/types/auth.js';
|
|
3
|
+
import { CorePhase, CoreState } from '../state/types/core.js';
|
|
4
|
+
type PhaseConfig<P, T> = {
|
|
5
|
+
phase: P;
|
|
6
|
+
onPhase: (state: CoreState) => T;
|
|
7
|
+
};
|
|
8
|
+
type BaseStateListenerParams = {
|
|
9
|
+
stateManager: CoreStateManager;
|
|
10
|
+
onReject?: (state: CoreState) => void;
|
|
11
|
+
/**
|
|
12
|
+
* Whether to reject the promise only when the state is in an error phase
|
|
13
|
+
*
|
|
14
|
+
* If false, the promise will reject if an error is present in state, regardless of the current phase
|
|
15
|
+
*
|
|
16
|
+
* Useful for flows where errors can be transient and retried (e.g. account verification)
|
|
17
|
+
* @default false
|
|
18
|
+
*/
|
|
19
|
+
rejectInErrorPhaseOnly?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Timeout in milliseconds after which the promise rejects if not resolved.
|
|
22
|
+
* @default 300000
|
|
23
|
+
*/
|
|
24
|
+
timeoutMs?: number;
|
|
25
|
+
};
|
|
26
|
+
type WaitForCoreStateChangeParams<T> = BaseStateListenerParams & {
|
|
27
|
+
resolvePhases: PhaseConfig<CorePhase, T>[];
|
|
28
|
+
rejectPhases?: PhaseConfig<CorePhase, Error>[];
|
|
29
|
+
};
|
|
30
|
+
type WaitForAuthStateChangeParams<T> = BaseStateListenerParams & {
|
|
31
|
+
resolvePhases: PhaseConfig<AuthPhase, T>[];
|
|
32
|
+
rejectPhases?: PhaseConfig<AuthPhase, Error>[];
|
|
33
|
+
/**
|
|
34
|
+
* Whether to wait for the core state to also be 'authenticated' when resolving on the 'authenticated' auth phase
|
|
35
|
+
* @default true
|
|
36
|
+
*/
|
|
37
|
+
waitForCoreAuthenticated?: boolean;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Helper specifically for core state changes
|
|
41
|
+
*/
|
|
42
|
+
export declare function waitForCoreStateChange<T>({ stateManager, resolvePhases, onReject, rejectInErrorPhaseOnly, timeoutMs, }: WaitForCoreStateChangeParams<T>): Promise<T>;
|
|
43
|
+
/**
|
|
44
|
+
* Helper specifically for auth state changes
|
|
45
|
+
*/
|
|
46
|
+
export declare function waitForAuthStateChange<T>({ stateManager, resolvePhases, rejectPhases, onReject, waitForCoreAuthenticated, rejectInErrorPhaseOnly, timeoutMs, }: WaitForAuthStateChangeParams<T>): Promise<T>;
|
|
47
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@getpara/core-sdk",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.13.0",
|
|
4
4
|
"dependencies": {
|
|
5
5
|
"@celo/utils": "^8.0.2",
|
|
6
6
|
"@cosmjs/encoding": "^0.32.4",
|
|
7
7
|
"@ethereumjs/util": "^9.1.0",
|
|
8
|
-
"@getpara/user-management-client": "2.
|
|
8
|
+
"@getpara/user-management-client": "2.13.0",
|
|
9
9
|
"@noble/hashes": "^1.5.0",
|
|
10
10
|
"base64url": "^3.0.1",
|
|
11
11
|
"libphonenumber-js": "^1.11.7",
|
|
12
12
|
"node-forge": "^1.3.1",
|
|
13
|
-
"uuid": "^11.1.0"
|
|
13
|
+
"uuid": "^11.1.0",
|
|
14
|
+
"xstate": "^5.24.0"
|
|
14
15
|
},
|
|
15
16
|
"devDependencies": {
|
|
16
17
|
"@faker-js/faker": "^9.5.1",
|
|
@@ -27,7 +28,7 @@
|
|
|
27
28
|
"dist",
|
|
28
29
|
"package.json"
|
|
29
30
|
],
|
|
30
|
-
"gitHead": "
|
|
31
|
+
"gitHead": "75ac5d1ebe87366c23bb4e485481deb1b593e299",
|
|
31
32
|
"main": "dist/cjs/index.js",
|
|
32
33
|
"module": "dist/esm/index.js",
|
|
33
34
|
"scripts": {
|
|
File without changes
|
|
File without changes
|