@getpara/core-sdk 3.3.0 → 3.5.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 +36 -2
- package/dist/cjs/constants.js +1 -1
- package/dist/cjs/external/userManagementClient.js +6 -2
- package/dist/cjs/services/AuthService.js +42 -1
- package/dist/cjs/state/CoreStateManager.js +33 -6
- package/dist/cjs/state/machines/authStateMachine.js +105 -8
- package/dist/cjs/state/machines/coreStateMachine.js +8 -0
- package/dist/cjs/types/coreApi.js +2 -0
- package/dist/esm/ParaCore.js +36 -2
- package/dist/esm/constants.js +1 -1
- package/dist/esm/external/userManagementClient.js +6 -2
- package/dist/esm/services/AuthService.js +42 -1
- package/dist/esm/state/CoreStateManager.js +33 -6
- package/dist/esm/state/machines/authStateMachine.js +105 -8
- package/dist/esm/state/machines/coreStateMachine.js +8 -0
- package/dist/esm/types/coreApi.js +2 -0
- package/dist/types/ParaCore.d.ts +23 -2
- package/dist/types/PlatformUtils.d.ts +11 -0
- package/dist/types/external/userManagementClient.d.ts +3 -1
- package/dist/types/index.d.ts +2 -2
- package/dist/types/services/AuthService.d.ts +10 -1
- package/dist/types/services/types/AuthServiceTypes.d.ts +6 -3
- package/dist/types/state/CoreStateManager.d.ts +1 -0
- package/dist/types/state/machines/authStateMachine.d.ts +77 -1
- package/dist/types/state/machines/coreStateMachine.d.ts +465 -6
- package/dist/types/state/types/auth.d.ts +4 -1
- package/dist/types/state/types/core.d.ts +23 -1
- package/dist/types/types/authState.d.ts +9 -3
- package/dist/types/types/coreApi.d.ts +17 -2
- package/package.json +3 -3
|
@@ -19,7 +19,7 @@ import type { BaseVerifyExternalWalletParams, ConnectExternalWalletParams, InitO
|
|
|
19
19
|
* }
|
|
20
20
|
* ```
|
|
21
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';
|
|
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_2fa' | 'awaiting_2fa_enrollment' | 'resolving_2fa' | 'awaiting_session_start' | 'verifying_new_account' | 'verifying_external_wallet' | 'waiting_for_session' | 'authenticated' | 'guest_mode' | 'error' | 'signing_external_wallet_verification';
|
|
23
23
|
export type AuthEvents = {
|
|
24
24
|
type: 'AUTHENTICATE_EMAIL_PHONE';
|
|
25
25
|
data: PerformSignUpOrLogInParams & {
|
|
@@ -54,6 +54,9 @@ export type AuthEvents = {
|
|
|
54
54
|
} | {
|
|
55
55
|
type: 'VERIFY_NEW_ACCOUNT';
|
|
56
56
|
data: PerformVerifyNewAccountParams;
|
|
57
|
+
} | {
|
|
58
|
+
type: 'RESOLVE_2FA';
|
|
59
|
+
data?: PollingCallbacks;
|
|
57
60
|
} | {
|
|
58
61
|
type: 'VERIFY_EXTERNAL_WALLET';
|
|
59
62
|
data?: VerifyExternalWalletParams;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { BiometricLocationHint, CurrentWalletIds, DeliveryChannel, ServerAuthState, TOAuthMethod } from '@getpara/user-management-client';
|
|
1
|
+
import type { BiometricLocationHint, CurrentWalletIds, DeliveryChannel, MfaMode, MfaStep, ServerAuthState, TOAuthMethod } from '@getpara/user-management-client';
|
|
2
2
|
import type { AuthState, Wallet, WithCustomTheme, WithUseShortUrls } from '../../types/index.js';
|
|
3
3
|
import { AuthMachine, AuthPhase } from './auth.js';
|
|
4
4
|
import { WalletMachine, WalletPhase } from './wallet.js';
|
|
@@ -108,6 +108,28 @@ export type AuthStateInfo = {
|
|
|
108
108
|
walletAddress: string;
|
|
109
109
|
walletType: string;
|
|
110
110
|
} | null;
|
|
111
|
+
/**
|
|
112
|
+
* Login-time 2FA challenge data (ENG-6906). Non-null only while the auth phase is
|
|
113
|
+
* `awaiting_2fa` / `awaiting_2fa_enrollment`. A custom UI reads this via
|
|
114
|
+
* onStatePhaseChange to render the enroll/verify step, then drives it with the
|
|
115
|
+
* useEnrollMfa / useVerifyMfa hooks.
|
|
116
|
+
*/
|
|
117
|
+
mfa: {
|
|
118
|
+
/** 'enroll' = no factor yet (set one up); 'verify' = satisfy an existing factor. */
|
|
119
|
+
mode: MfaMode;
|
|
120
|
+
/** The specific step within the enroll/verify flow (show_secret, prompt, failed, …). */
|
|
121
|
+
step: MfaStep;
|
|
122
|
+
/** Methods the user may use to satisfy the challenge (e.g. totp, backup_code). */
|
|
123
|
+
methods: ('totp' | 'backup_code')[] | null;
|
|
124
|
+
/** Remaining verify attempts before lockout, when the server provides it. */
|
|
125
|
+
attemptsRemaining: number | null;
|
|
126
|
+
/** Epoch ms until which verification is locked out, when applicable. */
|
|
127
|
+
lockedUntil: number | null;
|
|
128
|
+
/** otpauth:// URI — present during headless enrollment (show_secret). */
|
|
129
|
+
secretUri: string | null;
|
|
130
|
+
/** One-time backup codes — present at show_backup_codes (shown once). */
|
|
131
|
+
backupCodes: string[] | null;
|
|
132
|
+
} | null;
|
|
111
133
|
/** Recovery secret after wallet creation */
|
|
112
134
|
recoverySecret: string | null;
|
|
113
135
|
/** Whether this is a new user (signup flow) */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AuthExtras, PrimaryAuthInfo, ServerAuthStateDone, ServerAuthStateLogin, ServerAuthStateSignup, ServerAuthStateVerify, TAuthMethod } from '@getpara/user-management-client';
|
|
1
|
+
import type { AuthExtras, PrimaryAuthInfo, ServerAuthStateDone, ServerAuthStateLogin, ServerAuthStateMfa, ServerAuthStateSignup, ServerAuthStateVerify, TAuthMethod } from '@getpara/user-management-client';
|
|
2
2
|
import type { WithCustomTheme, WithIsPasskeySupported, WithUseShortUrls } from './util';
|
|
3
3
|
export type CoreAuthInfo = PrimaryAuthInfo & AuthExtras;
|
|
4
4
|
export type AuthStateBaseParams = WithCustomTheme & WithUseShortUrls;
|
|
@@ -85,7 +85,13 @@ export type AuthStateSignup = Omit<ServerAuthStateSignup, 'signupAuthMethods'> &
|
|
|
85
85
|
export type AuthStateDone = Omit<ServerAuthStateDone, 'authMethods'> & {
|
|
86
86
|
authMethods: TAuthMethod[];
|
|
87
87
|
};
|
|
88
|
+
/**
|
|
89
|
+
* Login-time 2FA (MFA) challenge state (ENG-6906). The server returns
|
|
90
|
+
* `stage:'mfa'` with the `mfa` challenge during a login; the SDK surfaces it
|
|
91
|
+
* unchanged (no portal-URL adornment) so a custom UI can drive enroll/verify.
|
|
92
|
+
*/
|
|
93
|
+
export type AuthStateMfa = ServerAuthStateMfa;
|
|
88
94
|
export type AuthStateVerifyOrLogin = AuthStateVerify | AuthStateLogin;
|
|
89
95
|
export type AuthStateSignupOrLoginOrDone = AuthStateSignup | AuthStateLogin | AuthStateDone;
|
|
90
|
-
export type OAuthResponse = AuthStateSignupOrLoginOrDone;
|
|
91
|
-
export type AuthState = AuthStateVerify | AuthStateLogin | AuthStateSignup | AuthStateDone;
|
|
96
|
+
export type OAuthResponse = AuthStateSignupOrLoginOrDone | AuthStateMfa;
|
|
97
|
+
export type AuthState = AuthStateVerify | AuthStateLogin | AuthStateSignup | AuthStateDone | AuthStateMfa;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { ExternalWalletInfo, OnRampPurchase, OnRampPurchaseCreateParams, Setup2faResponse, VerifiedAuth, WalletEntity, WalletParams, TWalletType, IssueJwtParams, IssueJwtResponse, TLinkedAccountType, LinkedAccounts, AuthMethod, DeliveryChannel } from '@getpara/user-management-client';
|
|
1
|
+
import { EnrollMfaResponse, ExternalWalletInfo, OnRampPurchase, OnRampPurchaseCreateParams, Setup2faResponse, VerifiedAuth, VerifyMfaResult, WalletEntity, WalletParams, TWalletType, IssueJwtParams, IssueJwtResponse, TLinkedAccountType, LinkedAccounts, AuthMethod, DeliveryChannel } from '@getpara/user-management-client';
|
|
2
2
|
import type { OAuthResponse, WithCustomTheme, WithUseShortUrls, Verify2faParams, Verify2faResponse, AuthStateSignup, StorageType, CoreAuthInfo, TelegramParams } from './';
|
|
3
3
|
import { ParaCore } from '../ParaCore.js';
|
|
4
4
|
import { FullSignatureRes, Wallet } from './wallet.js';
|
|
5
5
|
import { AccountLinkInProgress } from './accountLinking.js';
|
|
6
6
|
import type { WaitForLoginParams, WaitForLoginResponse, WaitForSignupParams, WaitForWalletCreationParams, WaitForWalletCreationResponse, GetOAuthUrlParams, AddCredentialParams, LoginExternalWalletParams, LoginExternalWalletResponse, ResendVerificationCodeParams, ResendVerificationCodeResponse, SignUpOrLogInParams, SignUpOrLogInResponse, VerifyOAuthProcessParams, VerifyExternalWalletParams, VerifyExternalWalletResponse, VerifyFarcasterParams, VerifyTelegramParams, ClaimPregenWalletsParams, ClaimPregenWalletsResponse, CreateGuestWalletsResponse, CreatePregenWalletParams, CreatePregenWalletPerTypeParams, CreatePregenWalletPerTypeResponse, CreatePregenWalletResponse, CreateWalletParams, CreateWalletPerTypeParams, CreateWalletPerTypeResponse, CreateWalletResponse, DistributeNewWalletShareParams, GetPregenWalletsParams, GetPregenWalletsResponse, GetWalletBalanceParams, HasPregenWalletParams, PollingCallbacks, RefreshShareParams, RefreshShareResponse, RequestFaucetParams, RequestFaucetResponse, UpdatePregenWalletIdentifierParams, BaseVerifyExternalWalletParams, AuthenticateWithEmailOrPhoneParams, AuthenticateWithEmailOrPhoneResponse, AuthenticateWithOAuthParams, AuthenticateWithOAuthResponse } from '../services/types';
|
|
7
|
-
export declare const PARA_CORE_METHODS: readonly ["getAuthInfo", "signUpOrLogIn", "verifyNewAccount", "waitForLogin", "waitForSignup", "waitForWalletCreation", "getOAuthUrl", "verifyOAuth", "getFarcasterConnectUri", "verifyFarcaster", "verifyTelegram", "resendVerificationCode", "loginExternalWallet", "verifyExternalWallet", "setup2fa", "enable2fa", "verify2fa", "logout", "clearStorage", "isSessionActive", "isFullyLoggedIn", "refreshSession", "keepSessionAlive", "exportSession", "waitAndExportSession", "importSession", "getVerificationToken", "getWallets", "getWalletsByType", "fetchWallets", "createWallet", "createWalletPerType", "getPregenWallets", "hasPregenWallet", "updatePregenWalletIdentifier", "createPregenWallet", "createPregenWalletPerType", "claimPregenWallets", "createGuestWallets", "distributeNewWalletShare", "getUserShare", "setUserShare", "refreshShare", "signMessage", "signTransaction", "initiateOnRampTransaction", "getWalletBalance", "requestFaucet", "issueJwt", "getLinkedAccounts", "accountLinkInProgress", "addCredential", "exportPrivateKey", "authenticateWithEmailOrPhone", "authenticateWithOAuth"];
|
|
7
|
+
export declare const PARA_CORE_METHODS: readonly ["getAuthInfo", "signUpOrLogIn", "verifyNewAccount", "waitForLogin", "waitForSignup", "waitForWalletCreation", "getOAuthUrl", "verifyOAuth", "getFarcasterConnectUri", "verifyFarcaster", "verifyTelegram", "resendVerificationCode", "loginExternalWallet", "verifyExternalWallet", "setup2fa", "enable2fa", "verify2fa", "enrollMfa", "verifyMfa", "logout", "clearStorage", "isSessionActive", "isFullyLoggedIn", "refreshSession", "keepSessionAlive", "exportSession", "waitAndExportSession", "importSession", "getVerificationToken", "getWallets", "getWalletsByType", "fetchWallets", "createWallet", "createWalletPerType", "getPregenWallets", "hasPregenWallet", "updatePregenWalletIdentifier", "createPregenWallet", "createPregenWalletPerType", "claimPregenWallets", "createGuestWallets", "distributeNewWalletShare", "getUserShare", "setUserShare", "refreshShare", "signMessage", "signTransaction", "initiateOnRampTransaction", "getWalletBalance", "requestFaucet", "issueJwt", "getLinkedAccounts", "accountLinkInProgress", "addCredential", "exportPrivateKey", "authenticateWithEmailOrPhone", "authenticateWithOAuth"];
|
|
8
8
|
export declare const PARA_INTERNAL_METHODS: readonly ["linkAccount", "unlinkAccount", "verifyEmailOrPhoneLink", "verifyOAuthLink", "verifyFarcasterLink", "verifyTelegramLink", "verifyExternalWalletLink", "accountLinkInProgress", "prepareLogin", "sendLoginCode", "supportedUserAuthMethods"];
|
|
9
9
|
export type CoreMethodName = (typeof PARA_CORE_METHODS)[number];
|
|
10
10
|
export type CoreMethodParams<method extends CoreMethodName & keyof CoreMethods> = CoreMethods[method] extends {
|
|
@@ -46,6 +46,13 @@ export type Enable2faParams = {
|
|
|
46
46
|
*/
|
|
47
47
|
verificationCode: string;
|
|
48
48
|
};
|
|
49
|
+
/** Login-time 2FA (ENG-6906) verify params. */
|
|
50
|
+
export type VerifyMfaParams = {
|
|
51
|
+
/**
|
|
52
|
+
* The TOTP or one-time backup code entered by the user.
|
|
53
|
+
*/
|
|
54
|
+
code: string;
|
|
55
|
+
};
|
|
49
56
|
export type SignMessageParams = PollingCallbacks & {
|
|
50
57
|
/**
|
|
51
58
|
* The ID of the wallet to use for signing.
|
|
@@ -256,6 +263,14 @@ export type CoreMethods = Record<CoreMethodName, {
|
|
|
256
263
|
params: Verify2faParams;
|
|
257
264
|
response: Verify2faResponse;
|
|
258
265
|
};
|
|
266
|
+
enrollMfa: {
|
|
267
|
+
params: void;
|
|
268
|
+
response: EnrollMfaResponse;
|
|
269
|
+
};
|
|
270
|
+
verifyMfa: {
|
|
271
|
+
params: VerifyMfaParams;
|
|
272
|
+
response: VerifyMfaResult;
|
|
273
|
+
};
|
|
259
274
|
getWallets: {
|
|
260
275
|
params: void;
|
|
261
276
|
response: Record<string, Wallet>;
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@getpara/core-sdk",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.5.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": "3.
|
|
8
|
+
"@getpara/user-management-client": "3.5.0",
|
|
9
9
|
"@noble/hashes": "^1.5.0",
|
|
10
10
|
"@opentelemetry/api": "^1.9.1",
|
|
11
11
|
"@opentelemetry/context-zone": "^2.7.1",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"dist",
|
|
42
42
|
"package.json"
|
|
43
43
|
],
|
|
44
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "2e70485f8f206ff50f58b339ebf0922fd259858f",
|
|
45
45
|
"main": "dist/cjs/index.js",
|
|
46
46
|
"module": "dist/esm/index.js",
|
|
47
47
|
"scripts": {
|