@getpara/core-sdk 2.0.0-alpha.63 → 2.0.0-alpha.65
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 +372 -104
- package/dist/cjs/constants.js +1 -1
- package/dist/cjs/index.js +6 -0
- package/dist/cjs/transmission/transmissionUtils.js +4 -3
- package/dist/cjs/types/coreApi.js +5 -2
- package/dist/cjs/types/popup.js +1 -0
- package/dist/cjs/utils/index.js +3 -1
- package/dist/cjs/utils/wallet.js +15 -0
- package/dist/cjs/utils/window.js +38 -0
- package/dist/esm/ParaCore.js +375 -105
- package/dist/esm/constants.js +1 -1
- package/dist/esm/index.js +10 -2
- package/dist/esm/transmission/transmissionUtils.js +4 -3
- package/dist/esm/types/coreApi.js +5 -2
- package/dist/esm/types/popup.js +1 -0
- package/dist/esm/utils/index.js +1 -0
- package/dist/esm/utils/wallet.js +14 -0
- package/dist/esm/utils/window.js +16 -0
- package/dist/types/ParaCore.d.ts +23 -7
- package/dist/types/index.d.ts +4 -4
- package/dist/types/shares/enclave.d.ts +1 -1
- package/dist/types/types/coreApi.d.ts +23 -4
- package/dist/types/types/methods.d.ts +15 -8
- package/dist/types/types/popup.d.ts +2 -1
- package/dist/types/types/wallet.d.ts +1 -0
- package/dist/types/utils/index.d.ts +1 -0
- package/dist/types/utils/wallet.d.ts +1 -0
- package/dist/types/utils/window.d.ts +2 -0
- package/package.json +3 -3
package/dist/esm/constants.js
CHANGED
package/dist/esm/index.js
CHANGED
|
@@ -34,8 +34,13 @@ import {
|
|
|
34
34
|
export * from "./types/coreApi.js";
|
|
35
35
|
export * from "./types/events.js";
|
|
36
36
|
export * from "./types/config.js";
|
|
37
|
-
import { getPortalDomain, dispatchEvent, entityToWallet, constructUrl, shortenUrl } from "./utils/index.js";
|
|
38
|
-
import {
|
|
37
|
+
import { getPortalDomain, dispatchEvent, entityToWallet, constructUrl, shortenUrl, isPortal } from "./utils/index.js";
|
|
38
|
+
import {
|
|
39
|
+
PREFIX,
|
|
40
|
+
PARA_PREFIX,
|
|
41
|
+
LOCAL_STORAGE_CURRENT_WALLET_IDS,
|
|
42
|
+
LOCAL_STORAGE_WALLETS
|
|
43
|
+
} from "./constants.js";
|
|
39
44
|
import { distributeNewShare } from "./shares/shareDistribution.js";
|
|
40
45
|
import { KeyContainer } from "./shares/KeyContainer.js";
|
|
41
46
|
import { getBaseUrl, initClient } from "./external/userManagementClient.js";
|
|
@@ -80,6 +85,8 @@ export {
|
|
|
80
85
|
EmailTheme,
|
|
81
86
|
KeyContainer,
|
|
82
87
|
LINKED_ACCOUNT_TYPES,
|
|
88
|
+
LOCAL_STORAGE_CURRENT_WALLET_IDS,
|
|
89
|
+
LOCAL_STORAGE_WALLETS,
|
|
83
90
|
NON_ED25519,
|
|
84
91
|
Network,
|
|
85
92
|
OAUTH_METHODS,
|
|
@@ -128,6 +135,7 @@ export {
|
|
|
128
135
|
getSHA256HashHex,
|
|
129
136
|
hashPasswordWithSalt,
|
|
130
137
|
initClient,
|
|
138
|
+
isPortal,
|
|
131
139
|
isWalletSupported,
|
|
132
140
|
mpcComputationClient,
|
|
133
141
|
paraVersion,
|
|
@@ -4,15 +4,16 @@ import {
|
|
|
4
4
|
import { Encrypt as ECIESEncrypt, Decrypt as ECIESDecrypt } from "@celo/utils/lib/ecies.js";
|
|
5
5
|
import { Buffer } from "buffer";
|
|
6
6
|
import * as eutil from "@ethereumjs/util";
|
|
7
|
-
import { randomBytes } from "crypto";
|
|
8
7
|
function upload(message, userManagementClient) {
|
|
9
8
|
return __async(this, null, function* () {
|
|
10
9
|
let secret;
|
|
11
10
|
let publicKeyUint8Array;
|
|
12
11
|
while (true) {
|
|
13
12
|
try {
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
const privateKeyUint8Array = new Uint8Array(32);
|
|
14
|
+
crypto.getRandomValues(privateKeyUint8Array);
|
|
15
|
+
secret = Buffer.from(privateKeyUint8Array).toString("hex");
|
|
16
|
+
publicKeyUint8Array = eutil.privateToPublic(privateKeyUint8Array);
|
|
16
17
|
break;
|
|
17
18
|
} catch (e) {
|
|
18
19
|
continue;
|
|
@@ -48,7 +48,9 @@ const PARA_CORE_METHODS = [
|
|
|
48
48
|
"getWalletBalance",
|
|
49
49
|
"issueJwt",
|
|
50
50
|
"getLinkedAccounts",
|
|
51
|
-
"accountLinkInProgress"
|
|
51
|
+
"accountLinkInProgress",
|
|
52
|
+
"addCredential",
|
|
53
|
+
"exportPrivateKey"
|
|
52
54
|
];
|
|
53
55
|
const PARA_INTERNAL_METHODS = [
|
|
54
56
|
"linkAccount",
|
|
@@ -60,7 +62,8 @@ const PARA_INTERNAL_METHODS = [
|
|
|
60
62
|
"verifyExternalWalletLink",
|
|
61
63
|
"accountLinkInProgress",
|
|
62
64
|
"prepareLogin",
|
|
63
|
-
"sendLoginCode"
|
|
65
|
+
"sendLoginCode",
|
|
66
|
+
"supportedUserAuthMethods"
|
|
64
67
|
];
|
|
65
68
|
export {
|
|
66
69
|
PARA_CORE_METHODS,
|
package/dist/esm/types/popup.js
CHANGED
|
@@ -6,6 +6,7 @@ var PopupType = /* @__PURE__ */ ((PopupType2) => {
|
|
|
6
6
|
PopupType2["CREATE_PASSKEY"] = "CREATE_PASSKEY";
|
|
7
7
|
PopupType2["OAUTH"] = "OAUTH";
|
|
8
8
|
PopupType2["ON_RAMP_TRANSACTION"] = "ON_RAMP_TRANSACTION";
|
|
9
|
+
PopupType2["EXPORT_PRIVATE_KEY"] = "EXPORT_PRIVATE_KEY";
|
|
9
10
|
return PopupType2;
|
|
10
11
|
})(PopupType || {});
|
|
11
12
|
export {
|
package/dist/esm/utils/index.js
CHANGED
package/dist/esm/utils/wallet.js
CHANGED
|
@@ -91,8 +91,22 @@ function mergeCurrentWalletIds(original, additional) {
|
|
|
91
91
|
function newUuid() {
|
|
92
92
|
return uuid.v4();
|
|
93
93
|
}
|
|
94
|
+
function currentWalletIdsEq(a, b) {
|
|
95
|
+
if (!a && !b) return true;
|
|
96
|
+
if (!a || !b) return false;
|
|
97
|
+
const aKeys = Object.keys(a);
|
|
98
|
+
const bKeys = Object.keys(b);
|
|
99
|
+
if (aKeys.length !== bKeys.length) return false;
|
|
100
|
+
return aKeys.every((key) => {
|
|
101
|
+
var _a, _b;
|
|
102
|
+
const aIds = ((_a = a[key]) == null ? void 0 : _a.sort()) || [];
|
|
103
|
+
const bIds = ((_b = b[key]) == null ? void 0 : _b.sort()) || [];
|
|
104
|
+
return aIds.length === bIds.length && aIds.every((id, index) => id === bIds[index]);
|
|
105
|
+
});
|
|
106
|
+
}
|
|
94
107
|
export {
|
|
95
108
|
WalletSchemeTypeMap,
|
|
109
|
+
currentWalletIdsEq,
|
|
96
110
|
entityToWallet,
|
|
97
111
|
getEquivalentTypes,
|
|
98
112
|
getSchemes,
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import "../chunk-W5CT3TVS.js";
|
|
2
|
+
import { getPortalBaseURL } from "./url.js";
|
|
3
|
+
function isPortal(ctx, env) {
|
|
4
|
+
var _a, _b;
|
|
5
|
+
if (typeof window === "undefined") return false;
|
|
6
|
+
const normalizedUrl = (_b = (_a = window.location) == null ? void 0 : _a.host) == null ? void 0 : _b.replace("getpara", "usecapsule");
|
|
7
|
+
const isOnPortalDomain = getPortalBaseURL(env ? { env } : ctx).includes(normalizedUrl);
|
|
8
|
+
if (!isOnPortalDomain) return false;
|
|
9
|
+
const isInIframe = window.parent !== window && !window.opener;
|
|
10
|
+
const isInPopup = window.opener && window.parent === window;
|
|
11
|
+
const isDirectAccess = window.parent === window && !window.opener;
|
|
12
|
+
return isInIframe || isInPopup || isDirectAccess;
|
|
13
|
+
}
|
|
14
|
+
export {
|
|
15
|
+
isPortal
|
|
16
|
+
};
|
package/dist/types/ParaCore.d.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { AuthMethod, AuthExtras, CurrentWalletIds, EmailTheme, PartnerEntity, TWalletType, PregenIds, BiometricLocationHint, Auth, SupportedWalletTypes, AuthIdentifier, AuthType, ExternalWalletInfo, PrimaryAuthInfo, SessionInfo, PrimaryAuth, PrimaryAuthType, AccountMetadata, LinkedAccounts, VerifyLinkParams, VerifyExternalWalletParams, SupportedAccountLinks, OnRampPurchase, BalancesConfig, Theme } from '@getpara/user-management-client';
|
|
2
2
|
import type { pki as pkiType } from 'node-forge';
|
|
3
|
-
import { Ctx, Environment, WalletFilters, Wallet, PortalUrlOptions, ConstructorOpts, CoreAuthInfo, PortalUrlType, CoreMethodParams, CoreMethodResponse, NewCredentialUrlParams, LoginUrlParams, CoreInterface, ExternalWalletConnectionType, AccountLinkInProgress, InternalMethodParams, InternalMethodResponse } from './types/index.js';
|
|
3
|
+
import { Ctx, Environment, WalletFilters, Wallet, PortalUrlOptions, ConstructorOpts, CoreAuthInfo, PortalUrlType, CoreMethodParams, CoreMethodResponse, NewCredentialUrlParams, LoginUrlParams, CoreInterface, ExternalWalletConnectionType, AccountLinkInProgress, InternalMethodParams, InternalMethodResponse, AvailableWallet } from './types/index.js';
|
|
4
4
|
import { PlatformUtils } from './PlatformUtils.js';
|
|
5
5
|
export declare abstract class ParaCore implements CoreInterface {
|
|
6
6
|
#private;
|
|
7
7
|
popupWindow: Window | null;
|
|
8
8
|
static version?: string;
|
|
9
9
|
ctx: Ctx;
|
|
10
|
+
protected isSwitchingWallets: boolean;
|
|
10
11
|
protected isNativePasskey: boolean;
|
|
11
12
|
protected isPartnerOptional?: boolean;
|
|
12
13
|
protected setModalError(_error?: string): void;
|
|
@@ -143,6 +144,7 @@ export declare abstract class ParaCore implements CoreInterface {
|
|
|
143
144
|
onRampPurchase: OnRampPurchase;
|
|
144
145
|
} | undefined;
|
|
145
146
|
protected platformUtils: PlatformUtils;
|
|
147
|
+
protected nonPersistedStorageKeys: string[];
|
|
146
148
|
private localStorageGetItem;
|
|
147
149
|
private localStorageSetItem;
|
|
148
150
|
private localStorageRemoveItem;
|
|
@@ -163,7 +165,6 @@ export declare abstract class ParaCore implements CoreInterface {
|
|
|
163
165
|
private convertBigInt;
|
|
164
166
|
private convertEncryptionKeyPair;
|
|
165
167
|
protected isPortal(envOverride?: Environment): boolean;
|
|
166
|
-
protected isRecoveryPortal(envOverride?: Environment): boolean;
|
|
167
168
|
private isParaConnect;
|
|
168
169
|
private requireApiKey;
|
|
169
170
|
private isWalletSupported;
|
|
@@ -351,7 +352,7 @@ export declare abstract class ParaCore implements CoreInterface {
|
|
|
351
352
|
*/
|
|
352
353
|
findWalletByAddress(address: string, filter?: WalletFilters | undefined): any;
|
|
353
354
|
findWallet(idOrAddress?: string, overrideType?: TWalletType, filter?: WalletFilters): Omit<Wallet, 'signer'> | undefined;
|
|
354
|
-
get availableWallets():
|
|
355
|
+
get availableWallets(): AvailableWallet[];
|
|
355
356
|
/**
|
|
356
357
|
* Retrieves all usable wallets with the provided type (`'EVM' | 'COSMOS' | 'SOLANA'`)
|
|
357
358
|
* @param {string} type the wallet type to filter by.
|
|
@@ -380,7 +381,7 @@ export declare abstract class ParaCore implements CoreInterface {
|
|
|
380
381
|
* @returns {WalletEntity[]} wallets that were fetched.
|
|
381
382
|
*/
|
|
382
383
|
fetchWallets(): CoreMethodResponse<'fetchWallets'>;
|
|
383
|
-
|
|
384
|
+
protected populateWalletAddresses(): Promise<void>;
|
|
384
385
|
private populatePregenWalletAddresses;
|
|
385
386
|
/**
|
|
386
387
|
* Logs in or creates a new user using an external wallet address.
|
|
@@ -436,8 +437,13 @@ export declare abstract class ParaCore implements CoreInterface {
|
|
|
436
437
|
get isGuestMode(): boolean;
|
|
437
438
|
/**
|
|
438
439
|
* Get the auth methods available to an existing user
|
|
440
|
+
* @deprecated Use supportedUserAuthMethods instead
|
|
439
441
|
*/
|
|
440
442
|
protected supportedAuthMethods(auth: Auth<PrimaryAuthType | 'userId'>): Promise<Set<AuthMethod>>;
|
|
443
|
+
/**
|
|
444
|
+
* Get the auth methods available to an existing user
|
|
445
|
+
*/
|
|
446
|
+
protected supportedUserAuthMethods(): Promise<Set<AuthMethod>>;
|
|
441
447
|
/**
|
|
442
448
|
* Get hints associated with the users stored biometrics.
|
|
443
449
|
* @deprecated
|
|
@@ -482,7 +488,15 @@ export declare abstract class ParaCore implements CoreInterface {
|
|
|
482
488
|
* @param {boolean} [opts.skipSessionRefresh] whether to skip refreshing the session.
|
|
483
489
|
* @returns {Object} `{ isComplete: boolean; isError: boolean; needsWallet: boolean; partnerId: string; }` the result data
|
|
484
490
|
**/
|
|
485
|
-
waitForLogin(
|
|
491
|
+
waitForLogin(args: CoreMethodParams<'waitForLogin'>): CoreMethodResponse<'waitForLogin'>;
|
|
492
|
+
protected waitForWalletSwitching(args: CoreMethodParams<'waitForLogin'>): CoreMethodResponse<'waitForLogin'>;
|
|
493
|
+
/**
|
|
494
|
+
* Gets the switch wallets URL for wallet selection.
|
|
495
|
+
* The authMethod is automatically included in the URL if available.
|
|
496
|
+
*
|
|
497
|
+
* @returns {Promise<{ url: string; authMethod: TAuthMethod }>} The switch wallets URL and authMethod
|
|
498
|
+
*/
|
|
499
|
+
protected getSwitchWalletsUrl(): Promise<string>;
|
|
486
500
|
/**
|
|
487
501
|
* Updates the session with the user management server, possibly
|
|
488
502
|
* opening a popup to refresh the session.
|
|
@@ -705,11 +719,12 @@ export declare abstract class ParaCore implements CoreInterface {
|
|
|
705
719
|
* Doesn't work for all types of logging.
|
|
706
720
|
**/
|
|
707
721
|
toString(): string;
|
|
708
|
-
protected devLog(...s:
|
|
709
|
-
protected getNewCredentialAndUrl({ authMethod, isForNewDevice, portalTheme, shorten, }?: NewCredentialUrlParams): Promise<{
|
|
722
|
+
protected devLog(...s: any[]): void;
|
|
723
|
+
protected getNewCredentialAndUrl({ authMethod: optsAuthMethod, isForNewDevice, portalTheme, shorten, }?: NewCredentialUrlParams): Promise<{
|
|
710
724
|
credentialId: string;
|
|
711
725
|
url?: string;
|
|
712
726
|
}>;
|
|
727
|
+
addCredential({ authMethod }: Pick<NewCredentialUrlParams, 'authMethod'>): Promise<string>;
|
|
713
728
|
/**
|
|
714
729
|
* Returns a Para Portal URL for logging in with a WebAuth passkey, password, PIN or OTP.
|
|
715
730
|
* @param {Object} opts the options object
|
|
@@ -734,4 +749,5 @@ export declare abstract class ParaCore implements CoreInterface {
|
|
|
734
749
|
refetch?: boolean;
|
|
735
750
|
}): Promise<import("@getpara/user-management-client").ProfileBalance>;
|
|
736
751
|
protected sendLoginCode(): Promise<void>;
|
|
752
|
+
exportPrivateKey(args?: CoreMethodParams<'exportPrivateKey'>): CoreMethodResponse<'exportPrivateKey'>;
|
|
737
753
|
}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { ParaCore } from './ParaCore.js';
|
|
2
|
-
export { type Auth, type AuthInfo, type PrimaryAuthInfo, type VerifiedAuthInfo, type VerifiedAuth, AuthMethod, AuthMethodStatus, type AuthExtras, type CurrentWalletIds, EmailTheme, type PartnerEntity, type WalletEntity, Network, type TNetwork, WalletType, type TWalletType, WalletScheme, type TWalletScheme, OnRampAsset, type TOnRampAsset, OnRampPurchaseType, OnRampProvider, OnRampPurchaseStatus, type OnRampConfig, type OnRampAssets, type OnRampPurchase, type OnRampAssetInfo, type ProviderAssetInfo, OnRampMethod, type Theme, OAuthMethod, type TOAuthMethod, type TLinkedAccountType, type SupportedAccountLinks, type SupportedWalletTypes, type TPregenIdentifierType, type PregenIds, type LinkedAccount, type LinkedAccounts, type TExternalWallet, type ExternalWalletInfo, type PregenAuth, type Setup2faResponse, type TelegramAuthResponse, type VerifyExternalWalletParams, type AssetMetadata, type AssetMetadataIndexed, type AssetValue, type BalancesConfig, type WalletBalance, type ProfileBalance, type OfframpDepositRequest, RecoveryStatus, ThemeMode, NON_ED25519, PREGEN_IDENTIFIER_TYPES, WALLET_TYPES, WALLET_SCHEMES, OAUTH_METHODS, LINKED_ACCOUNT_TYPES, EXTERNAL_WALLET_TYPES, EVM_WALLETS, SOLANA_WALLETS, COSMOS_WALLETS, } from '@getpara/user-management-client';
|
|
3
|
-
export { PopupType, PregenIdentifierType, type AuthStateSignup, type AuthStateVerify, type AuthStateLogin, type AuthState, type OAuthResponse, type CoreAuthInfo, type SignatureRes, type FullSignatureRes, type SuccessfulSignatureRes, type DeniedSignatureRes, type DeniedSignatureResWithUrl, type Wallet, type GetWalletBalanceParams, type AccountLinkInProgress, AccountLinkError, type InternalInterface, } from './types/index.js';
|
|
2
|
+
export { type Auth, type AuthInfo, type PrimaryAuthInfo, type VerifiedAuthInfo, type VerifiedAuth, AuthMethod, type TAuthMethod, AuthMethodStatus, type AuthExtras, type CurrentWalletIds, EmailTheme, type PartnerEntity, type WalletEntity, Network, type TNetwork, WalletType, type TWalletType, WalletScheme, type TWalletScheme, OnRampAsset, type TOnRampAsset, OnRampPurchaseType, OnRampProvider, OnRampPurchaseStatus, type OnRampConfig, type OnRampAssets, type OnRampPurchase, type OnRampAssetInfo, type ProviderAssetInfo, OnRampMethod, type Theme, OAuthMethod, type TOAuthMethod, type TLinkedAccountType, type SupportedAccountLinks, type SupportedWalletTypes, type TPregenIdentifierType, type PregenIds, type LinkedAccount, type LinkedAccounts, type TExternalWallet, type ExternalWalletInfo, type PregenAuth, type Setup2faResponse, type TelegramAuthResponse, type VerifyExternalWalletParams, type AssetMetadata, type AssetMetadataIndexed, type AssetValue, type BalancesConfig, type WalletBalance, type ProfileBalance, type OfframpDepositRequest, RecoveryStatus, ThemeMode, NON_ED25519, PREGEN_IDENTIFIER_TYPES, WALLET_TYPES, WALLET_SCHEMES, OAUTH_METHODS, LINKED_ACCOUNT_TYPES, EXTERNAL_WALLET_TYPES, EVM_WALLETS, SOLANA_WALLETS, COSMOS_WALLETS, } from '@getpara/user-management-client';
|
|
3
|
+
export { PopupType, PregenIdentifierType, type AuthStateSignup, type AuthStateVerify, type AuthStateLogin, type AuthState, type OAuthResponse, type CoreAuthInfo, type SignatureRes, type FullSignatureRes, type SuccessfulSignatureRes, type DeniedSignatureRes, type DeniedSignatureResWithUrl, type Wallet, type AvailableWallet, type GetWalletBalanceParams, type AccountLinkInProgress, AccountLinkError, type InternalInterface, } from './types/index.js';
|
|
4
4
|
export * from './types/coreApi.js';
|
|
5
5
|
export * from './types/events.js';
|
|
6
6
|
export * from './types/config.js';
|
|
7
|
-
export { getPortalDomain, dispatchEvent, entityToWallet, constructUrl, shortenUrl } from './utils/index.js';
|
|
8
|
-
export { PREFIX as STORAGE_PREFIX, PARA_PREFIX as PARA_STORAGE_PREFIX } from './constants.js';
|
|
7
|
+
export { getPortalDomain, dispatchEvent, entityToWallet, constructUrl, shortenUrl, isPortal } from './utils/index.js';
|
|
8
|
+
export { PREFIX as STORAGE_PREFIX, PARA_PREFIX as PARA_STORAGE_PREFIX, LOCAL_STORAGE_CURRENT_WALLET_IDS, LOCAL_STORAGE_WALLETS, } from './constants.js';
|
|
9
9
|
export { distributeNewShare } from './shares/shareDistribution.js';
|
|
10
10
|
export { KeyContainer } from './shares/KeyContainer.js';
|
|
11
11
|
export type { PlatformUtils } from './PlatformUtils.js';
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { BackupKitEmailProps, CurrentWalletIds, ExternalWalletInfo, OnRampPurchase, OnRampPurchaseCreateParams, PregenAuth, Setup2faResponse, VerifiedAuth, VerifyExternalWalletParams, WalletEntity, WalletParams, TWalletType, IssueJwtParams, IssueJwtResponse, TLinkedAccountType, LinkedAccounts } from '@getpara/user-management-client';
|
|
2
|
-
import { AuthStateLogin, AuthStateVerify, OAuthResponse, AuthStateBaseParams, WithCustomTheme, WithUseShortUrls, Verify2faResponse, AuthStateSignup, AuthStateVerifyOrLogin, OAuthUrlParams, StorageType, PollParams, CoreAuthInfo, GetWalletBalanceParams, GetWalletBalanceResponse, FarcasterParams, TelegramParams, OAuthParams } from './methods.js';
|
|
1
|
+
import { BackupKitEmailProps, CurrentWalletIds, ExternalWalletInfo, OnRampPurchase, OnRampPurchaseCreateParams, PregenAuth, Setup2faResponse, VerifiedAuth, VerifyExternalWalletParams, WalletEntity, WalletParams, TWalletType, IssueJwtParams, IssueJwtResponse, TLinkedAccountType, LinkedAccounts, AuthMethod } from '@getpara/user-management-client';
|
|
2
|
+
import { AuthStateLogin, AuthStateVerify, OAuthResponse, AuthStateBaseParams, WithCustomTheme, WithUseShortUrls, Verify2faResponse, AuthStateSignup, AuthStateVerifyOrLogin, OAuthUrlParams, StorageType, PollParams, CoreAuthInfo, GetWalletBalanceParams, GetWalletBalanceResponse, FarcasterParams, TelegramParams, OAuthParams, NewCredentialUrlParams } from './methods.js';
|
|
3
3
|
import { ParaCore } from '../ParaCore.js';
|
|
4
4
|
import { FullSignatureRes, Wallet } from './wallet.js';
|
|
5
5
|
import { AccountLinkInProgress } from './auth.js';
|
|
6
|
-
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", "importSession", "getVerificationToken", "getWallets", "getWalletsByType", "fetchWallets", "createWallet", "createWalletPerType", "getPregenWallets", "hasPregenWallet", "updatePregenWalletIdentifier", "createPregenWallet", "createPregenWalletPerType", "claimPregenWallets", "createGuestWallets", "distributeNewWalletShare", "getUserShare", "setUserShare", "refreshShare", "signMessage", "signTransaction", "initiateOnRampTransaction", "getWalletBalance", "issueJwt", "getLinkedAccounts", "accountLinkInProgress"];
|
|
7
|
-
export declare const PARA_INTERNAL_METHODS: readonly ["linkAccount", "unlinkAccount", "verifyEmailOrPhoneLink", "verifyOAuthLink", "verifyFarcasterLink", "verifyTelegramLink", "verifyExternalWalletLink", "accountLinkInProgress", "prepareLogin", "sendLoginCode"];
|
|
6
|
+
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", "importSession", "getVerificationToken", "getWallets", "getWalletsByType", "fetchWallets", "createWallet", "createWalletPerType", "getPregenWallets", "hasPregenWallet", "updatePregenWalletIdentifier", "createPregenWallet", "createPregenWalletPerType", "claimPregenWallets", "createGuestWallets", "distributeNewWalletShare", "getUserShare", "setUserShare", "refreshShare", "signMessage", "signTransaction", "initiateOnRampTransaction", "getWalletBalance", "issueJwt", "getLinkedAccounts", "accountLinkInProgress", "addCredential", "exportPrivateKey"];
|
|
7
|
+
export declare const PARA_INTERNAL_METHODS: readonly ["linkAccount", "unlinkAccount", "verifyEmailOrPhoneLink", "verifyOAuthLink", "verifyFarcasterLink", "verifyTelegramLink", "verifyExternalWalletLink", "accountLinkInProgress", "prepareLogin", "sendLoginCode", "supportedUserAuthMethods"];
|
|
8
8
|
export type CoreMethodName = (typeof PARA_CORE_METHODS)[number];
|
|
9
9
|
export type CoreMethodParams<method extends CoreMethodName & keyof CoreMethods> = CoreMethods[method] extends {
|
|
10
10
|
params: infer P;
|
|
@@ -119,6 +119,7 @@ export type CoreMethods = Record<CoreMethodName, {
|
|
|
119
119
|
params: OAuthUrlParams & {
|
|
120
120
|
sessionLookupId?: string;
|
|
121
121
|
encryptionKey?: string;
|
|
122
|
+
portalCallbackParams?: Record<string, string>;
|
|
122
123
|
};
|
|
123
124
|
response: string;
|
|
124
125
|
};
|
|
@@ -483,6 +484,20 @@ export type CoreMethods = Record<CoreMethodName, {
|
|
|
483
484
|
userId: string;
|
|
484
485
|
};
|
|
485
486
|
};
|
|
487
|
+
addCredential: {
|
|
488
|
+
params: Pick<NewCredentialUrlParams, 'authMethod'>;
|
|
489
|
+
response: Promise<string>;
|
|
490
|
+
};
|
|
491
|
+
exportPrivateKey: {
|
|
492
|
+
params: {
|
|
493
|
+
walletId?: string;
|
|
494
|
+
shouldOpenPopup?: boolean;
|
|
495
|
+
} | undefined;
|
|
496
|
+
response: {
|
|
497
|
+
popupWindow?: Window;
|
|
498
|
+
url: string;
|
|
499
|
+
};
|
|
500
|
+
};
|
|
486
501
|
};
|
|
487
502
|
export type InternalMethods = {
|
|
488
503
|
linkAccount: {
|
|
@@ -531,6 +546,10 @@ export type InternalMethods = {
|
|
|
531
546
|
params: void;
|
|
532
547
|
response: void;
|
|
533
548
|
};
|
|
549
|
+
supportedUserAuthMethods: {
|
|
550
|
+
params: void;
|
|
551
|
+
response: Promise<Set<AuthMethod>>;
|
|
552
|
+
};
|
|
534
553
|
};
|
|
535
554
|
export type CoreInterface = {
|
|
536
555
|
[key in keyof CoreMethods]: Partial<CoreMethod<key>>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PrimaryAuthInfo, ServerAuthStateLogin, ServerAuthStateSignup,
|
|
1
|
+
import { PrimaryAuthInfo, ServerAuthStateLogin, ServerAuthStateSignup, TAuthMethod, ServerAuthStateVerify, VerifiedAuth, AuthExtras, RecoveryStatus, Theme, TOAuthMethod, TWalletType, TelegramAuthResponse, VerifyThirdPartyAuth, ServerAuthStateDone } from '@getpara/user-management-client';
|
|
2
2
|
import { Wallet } from './wallet.js';
|
|
3
3
|
type Device = {
|
|
4
4
|
sessionId: string;
|
|
@@ -12,7 +12,7 @@ export type VerifyExternalWalletV1 = {
|
|
|
12
12
|
cosmosPublicKeyHex?: string;
|
|
13
13
|
cosmosSigner?: string;
|
|
14
14
|
};
|
|
15
|
-
export type PortalUrlType = 'createAuth' | 'createPassword' | 'loginAuth' | 'loginPassword' | 'txReview' | 'onRamp' | 'telegramLogin' | 'createPIN' | 'loginPIN' | 'oAuth' | 'oAuthCallback' | 'loginOTP' | 'telegramLoginVerify' | 'loginFarcaster';
|
|
15
|
+
export type PortalUrlType = 'createAuth' | 'createPassword' | 'loginAuth' | 'loginPassword' | 'txReview' | 'onRamp' | 'telegramLogin' | 'createPIN' | 'loginPIN' | 'oAuth' | 'oAuthCallback' | 'loginOTP' | 'telegramLoginVerify' | 'loginFarcaster' | 'switchWallets' | 'addNewCredential' | 'exportPrivateKey';
|
|
16
16
|
export type PortalUrlOptions = {
|
|
17
17
|
params?: Record<string, string | undefined | null>;
|
|
18
18
|
isForNewDevice?: boolean;
|
|
@@ -26,12 +26,15 @@ export type PortalUrlOptions = {
|
|
|
26
26
|
oAuthMethod?: OAuthUrlParams['method'];
|
|
27
27
|
appScheme?: string;
|
|
28
28
|
encryptionKey?: string;
|
|
29
|
+
addNewCredentialType?: Exclude<TAuthMethod, 'BASIC_LOGIN'>;
|
|
30
|
+
addNewCredentialPasswordId?: string;
|
|
31
|
+
addNewCredentialPasskeyId?: string;
|
|
29
32
|
};
|
|
30
33
|
export type WithAuthMethod = {
|
|
31
34
|
/**
|
|
32
|
-
* Which authorization method to use for the URL, either `'
|
|
35
|
+
* Which authorization method to use for the URL, either `'PASSKEY'`, `'PASSWORD'` or `'PIN'`.
|
|
33
36
|
*/
|
|
34
|
-
authMethod?: Uppercase<
|
|
37
|
+
authMethod?: Uppercase<TAuthMethod>;
|
|
35
38
|
};
|
|
36
39
|
export type WithCustomTheme = {
|
|
37
40
|
/**
|
|
@@ -89,11 +92,15 @@ export type TelegramParams = {
|
|
|
89
92
|
export type LoginUrlParams = WithAuthMethod & WithCustomTheme & WithShorten & {
|
|
90
93
|
sessionId?: string;
|
|
91
94
|
};
|
|
92
|
-
export type NewCredentialUrlParams =
|
|
95
|
+
export type NewCredentialUrlParams = WithCustomTheme & WithShorten & {
|
|
93
96
|
/**
|
|
94
97
|
* Whether the URL is meant to add a passkey for a previous user on a new device. Defaults to `false`.
|
|
95
98
|
*/
|
|
96
99
|
isForNewDevice?: boolean;
|
|
100
|
+
/**
|
|
101
|
+
* The authentication method to add.
|
|
102
|
+
*/
|
|
103
|
+
authMethod?: Exclude<TAuthMethod, 'BASIC_LOGIN'>;
|
|
97
104
|
};
|
|
98
105
|
export type OAuthUrlParams = {
|
|
99
106
|
/**
|
|
@@ -149,7 +156,7 @@ export type AuthStateLogin = Omit<ServerAuthStateLogin, 'loginAuthMethods'> & Wi
|
|
|
149
156
|
/**
|
|
150
157
|
* Supported login auth methods for this session.
|
|
151
158
|
*/
|
|
152
|
-
loginAuthMethods?:
|
|
159
|
+
loginAuthMethods?: TAuthMethod[];
|
|
153
160
|
};
|
|
154
161
|
export type AuthStateSignup = Omit<ServerAuthStateSignup, 'signupAuthMethods'> & WithIsPasskeySupported & {
|
|
155
162
|
/**
|
|
@@ -179,10 +186,10 @@ export type AuthStateSignup = Omit<ServerAuthStateSignup, 'signupAuthMethods'> &
|
|
|
179
186
|
/**
|
|
180
187
|
* Supported signup auth methods for this session.
|
|
181
188
|
*/
|
|
182
|
-
signupAuthMethods?:
|
|
189
|
+
signupAuthMethods?: TAuthMethod[];
|
|
183
190
|
};
|
|
184
191
|
export type AuthStateDone = Omit<ServerAuthStateDone, 'authMethods'> & {
|
|
185
|
-
authMethods:
|
|
192
|
+
authMethods: TAuthMethod[];
|
|
186
193
|
};
|
|
187
194
|
export type AuthStateVerifyOrLogin = AuthStateVerify | AuthStateLogin;
|
|
188
195
|
export type AuthStateSignupOrLoginOrDone = AuthStateSignup | AuthStateLogin | AuthStateDone;
|
|
@@ -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 AvailableWallet = Pick<Wallet, 'id' | 'type' | 'name' | 'address' | 'partner' | 'isExternal' | 'externalProviderId' | 'isExternalConnectionOnly'>;
|
|
29
30
|
/** @deprecated */
|
|
30
31
|
export declare enum PregenIdentifierType {
|
|
31
32
|
EMAIL = "EMAIL",
|
|
@@ -11,3 +11,4 @@ export declare function migrateWallet(obj: Record<string, unknown>): Wallet;
|
|
|
11
11
|
export declare function supportedWalletTypesEq(a: SupportedWalletTypes, b: SupportedWalletTypes): boolean;
|
|
12
12
|
export declare function mergeCurrentWalletIds(original: CurrentWalletIds, additional: CurrentWalletIds): CurrentWalletIds;
|
|
13
13
|
export declare function newUuid(): string;
|
|
14
|
+
export declare function currentWalletIdsEq(a: CurrentWalletIds | undefined, b: CurrentWalletIds | undefined): boolean;
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@getpara/core-sdk",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.65",
|
|
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.0.0-alpha.
|
|
8
|
+
"@getpara/user-management-client": "2.0.0-alpha.65",
|
|
9
9
|
"@noble/hashes": "^1.5.0",
|
|
10
10
|
"base64url": "^3.0.1",
|
|
11
11
|
"libphonenumber-js": "^1.11.7",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"dist",
|
|
28
28
|
"package.json"
|
|
29
29
|
],
|
|
30
|
-
"gitHead": "
|
|
30
|
+
"gitHead": "9945ab14944c22851eb81c5bbb831b23bf7eaf2a",
|
|
31
31
|
"main": "dist/cjs/index.js",
|
|
32
32
|
"module": "dist/esm/index.js",
|
|
33
33
|
"scripts": {
|