@getpara/core-sdk 2.0.0-alpha.5 → 2.0.0-alpha.51
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 +764 -204
- package/dist/cjs/constants.js +7 -1
- package/dist/cjs/index.js +20 -0
- package/dist/cjs/types/auth.js +33 -0
- package/dist/cjs/types/coreApi.js +20 -3
- package/dist/cjs/types/index.js +2 -0
- package/dist/cjs/utils/formatting.js +4 -0
- package/dist/cjs/utils/phone.js +14 -2
- package/dist/esm/ParaCore.js +771 -208
- package/dist/esm/constants.js +5 -1
- package/dist/esm/index.js +22 -3
- package/dist/esm/types/auth.js +11 -0
- package/dist/esm/types/coreApi.js +18 -2
- package/dist/esm/types/index.js +1 -0
- package/dist/esm/utils/formatting.js +2 -0
- package/dist/esm/utils/phone.js +12 -1
- package/dist/types/ParaCore.d.ts +87 -49
- package/dist/types/PlatformUtils.d.ts +2 -3
- package/dist/types/constants.d.ts +16 -14
- package/dist/types/index.d.ts +3 -3
- package/dist/types/shares/KeyContainer.d.ts +0 -2
- package/dist/types/types/auth.d.ts +16 -0
- package/dist/types/types/config.d.ts +9 -1
- package/dist/types/types/coreApi.d.ts +100 -36
- package/dist/types/types/index.d.ts +1 -0
- package/dist/types/types/methods.d.ts +63 -7
- package/dist/types/types/wallet.d.ts +4 -1
- package/dist/types/utils/formatting.d.ts +2 -0
- package/dist/types/utils/phone.d.ts +4 -0
- package/package.json +23 -23
package/dist/esm/constants.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import "./chunk-7B52C2XE.js";
|
|
2
|
-
const PARA_CORE_VERSION = "2.0.0-alpha.
|
|
2
|
+
const PARA_CORE_VERSION = "2.0.0-alpha.51";
|
|
3
3
|
const PREFIX = "@CAPSULE/";
|
|
4
|
+
const PARA_PREFIX = "@PARA/";
|
|
4
5
|
const LOCAL_STORAGE_AUTH_INFO = `${PREFIX}authInfo`;
|
|
5
6
|
const LOCAL_STORAGE_EMAIL = `${PREFIX}e-mail`;
|
|
6
7
|
const LOCAL_STORAGE_PHONE = `${PREFIX}phone`;
|
|
@@ -19,7 +20,9 @@ const POLLING_INTERVAL_MS = 2e3;
|
|
|
19
20
|
const SHORT_POLLING_INTERVAL_MS = 1e3;
|
|
20
21
|
const POLLING_TIMEOUT_MS = 3e5;
|
|
21
22
|
const EXTERNAL_WALLET_CONNECTION_ONLY_USER_ID = "EXTERNAL_WALLET_CONNECTION_ONLY";
|
|
23
|
+
const ACCOUNT_LINK_CONFLICT = "Account already linked";
|
|
22
24
|
export {
|
|
25
|
+
ACCOUNT_LINK_CONFLICT,
|
|
23
26
|
EXTERNAL_WALLET_CONNECTION_ONLY_USER_ID,
|
|
24
27
|
LOCAL_STORAGE_AUTH_INFO,
|
|
25
28
|
LOCAL_STORAGE_COUNTRY_CODE,
|
|
@@ -35,6 +38,7 @@ export {
|
|
|
35
38
|
LOCAL_STORAGE_USER_ID,
|
|
36
39
|
LOCAL_STORAGE_WALLETS,
|
|
37
40
|
PARA_CORE_VERSION,
|
|
41
|
+
PARA_PREFIX,
|
|
38
42
|
POLLING_INTERVAL_MS,
|
|
39
43
|
POLLING_TIMEOUT_MS,
|
|
40
44
|
PREFIX,
|
package/dist/esm/index.js
CHANGED
|
@@ -4,27 +4,36 @@ import {
|
|
|
4
4
|
AuthMethod,
|
|
5
5
|
EmailTheme,
|
|
6
6
|
Network,
|
|
7
|
+
WalletType,
|
|
8
|
+
WalletScheme,
|
|
7
9
|
OnRampAsset,
|
|
8
10
|
OnRampPurchaseType,
|
|
9
11
|
OnRampProvider,
|
|
10
12
|
OnRampPurchaseStatus,
|
|
13
|
+
OAuthMethod,
|
|
11
14
|
NON_ED25519,
|
|
12
15
|
PREGEN_IDENTIFIER_TYPES,
|
|
13
16
|
WALLET_TYPES,
|
|
14
17
|
WALLET_SCHEMES,
|
|
15
|
-
OAUTH_METHODS
|
|
18
|
+
OAUTH_METHODS,
|
|
19
|
+
LINKED_ACCOUNT_TYPES,
|
|
20
|
+
EXTERNAL_WALLET_TYPES,
|
|
21
|
+
EVM_WALLETS,
|
|
22
|
+
SOLANA_WALLETS,
|
|
23
|
+
COSMOS_WALLETS
|
|
16
24
|
} from "@getpara/user-management-client";
|
|
17
25
|
import {
|
|
18
26
|
OnRampMethod,
|
|
19
27
|
PopupType,
|
|
20
28
|
PregenIdentifierType,
|
|
21
|
-
RecoveryStatus
|
|
29
|
+
RecoveryStatus,
|
|
30
|
+
AccountLinkError
|
|
22
31
|
} from "./types/index.js";
|
|
23
32
|
export * from "./types/coreApi.js";
|
|
24
33
|
export * from "./types/events.js";
|
|
25
34
|
export * from "./types/config.js";
|
|
26
35
|
import { getPortalDomain, entityToWallet, constructUrl, shortenUrl } from "./utils/index.js";
|
|
27
|
-
import { PREFIX } from "./constants.js";
|
|
36
|
+
import { PREFIX, PARA_PREFIX } from "./constants.js";
|
|
28
37
|
import { distributeNewShare } from "./shares/shareDistribution.js";
|
|
29
38
|
import { KeyContainer } from "./shares/KeyContainer.js";
|
|
30
39
|
import { getBaseUrl, initClient } from "./external/userManagementClient.js";
|
|
@@ -59,24 +68,34 @@ import { retrieve } from "./transmission/transmissionUtils.js";
|
|
|
59
68
|
const paraVersion = ParaCore.version;
|
|
60
69
|
var src_default = ParaCore;
|
|
61
70
|
export {
|
|
71
|
+
AccountLinkError,
|
|
62
72
|
AuthMethod,
|
|
73
|
+
COSMOS_WALLETS,
|
|
74
|
+
EVM_WALLETS,
|
|
75
|
+
EXTERNAL_WALLET_TYPES,
|
|
63
76
|
EmailTheme,
|
|
64
77
|
KeyContainer,
|
|
78
|
+
LINKED_ACCOUNT_TYPES,
|
|
65
79
|
NON_ED25519,
|
|
66
80
|
Network,
|
|
67
81
|
OAUTH_METHODS,
|
|
82
|
+
OAuthMethod,
|
|
68
83
|
OnRampAsset,
|
|
69
84
|
OnRampMethod,
|
|
70
85
|
OnRampProvider,
|
|
71
86
|
OnRampPurchaseStatus,
|
|
72
87
|
OnRampPurchaseType,
|
|
88
|
+
PARA_PREFIX as PARA_STORAGE_PREFIX,
|
|
73
89
|
PREGEN_IDENTIFIER_TYPES,
|
|
74
90
|
PopupType,
|
|
75
91
|
PregenIdentifierType,
|
|
76
92
|
RecoveryStatus,
|
|
93
|
+
SOLANA_WALLETS,
|
|
77
94
|
PREFIX as STORAGE_PREFIX,
|
|
78
95
|
WALLET_SCHEMES,
|
|
79
96
|
WALLET_TYPES,
|
|
97
|
+
WalletScheme,
|
|
98
|
+
WalletType,
|
|
80
99
|
constructUrl,
|
|
81
100
|
decryptPrivateKey,
|
|
82
101
|
decryptPrivateKeyAndDecryptShare,
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import "../chunk-7B52C2XE.js";
|
|
2
|
+
var AccountLinkError = /* @__PURE__ */ ((AccountLinkError2) => {
|
|
3
|
+
AccountLinkError2["NotAuthenticated"] = "No user is currently authenticated";
|
|
4
|
+
AccountLinkError2["Conflict"] = "Account already linked";
|
|
5
|
+
AccountLinkError2["Canceled"] = "Account linking was canceled";
|
|
6
|
+
AccountLinkError2["Unknown"] = "An unknown error occurred";
|
|
7
|
+
return AccountLinkError2;
|
|
8
|
+
})(AccountLinkError || {});
|
|
9
|
+
export {
|
|
10
|
+
AccountLinkError
|
|
11
|
+
};
|
|
@@ -45,8 +45,24 @@ const PARA_CORE_METHODS = [
|
|
|
45
45
|
"signMessage",
|
|
46
46
|
"signTransaction",
|
|
47
47
|
"initiateOnRampTransaction",
|
|
48
|
-
"getWalletBalance"
|
|
48
|
+
"getWalletBalance",
|
|
49
|
+
"issueJwt",
|
|
50
|
+
"getLinkedAccounts",
|
|
51
|
+
"accountLinkInProgress"
|
|
52
|
+
];
|
|
53
|
+
const PARA_INTERNAL_METHODS = [
|
|
54
|
+
"linkAccount",
|
|
55
|
+
"unlinkAccount",
|
|
56
|
+
"verifyEmailOrPhoneLink",
|
|
57
|
+
"verifyOAuthLink",
|
|
58
|
+
"verifyFarcasterLink",
|
|
59
|
+
"verifyTelegramLink",
|
|
60
|
+
"verifyExternalWalletLink",
|
|
61
|
+
"accountLinkInProgress",
|
|
62
|
+
"prepareLogin",
|
|
63
|
+
"sendLoginCode"
|
|
49
64
|
];
|
|
50
65
|
export {
|
|
51
|
-
PARA_CORE_METHODS
|
|
66
|
+
PARA_CORE_METHODS,
|
|
67
|
+
PARA_INTERNAL_METHODS
|
|
52
68
|
};
|
package/dist/esm/types/index.js
CHANGED
|
@@ -64,11 +64,13 @@ function truncateAddress(str, addressType, {
|
|
|
64
64
|
return `${str.slice(0, minimum + margin)}...${str.slice(-1 * margin)}`;
|
|
65
65
|
}
|
|
66
66
|
export {
|
|
67
|
+
compressPubkey,
|
|
67
68
|
decimalToHex,
|
|
68
69
|
getCosmosAddress,
|
|
69
70
|
hexStringToBase64,
|
|
70
71
|
hexToDecimal,
|
|
71
72
|
hexToSignature,
|
|
72
73
|
hexToUint8Array,
|
|
74
|
+
rawSecp256k1PubkeyToRawAddress,
|
|
73
75
|
truncateAddress
|
|
74
76
|
};
|
package/dist/esm/utils/phone.js
CHANGED
|
@@ -22,7 +22,18 @@ function formatPhoneNumber(phone, countryCode, { forDisplay = false } = {}) {
|
|
|
22
22
|
function displayPhoneNumber(phone, countryCode) {
|
|
23
23
|
return formatPhoneNumber(phone, countryCode, { forDisplay: true });
|
|
24
24
|
}
|
|
25
|
+
function splitPhoneNumber(phone) {
|
|
26
|
+
const parsedNumber = parsePhoneNumberFromString(phone);
|
|
27
|
+
if (parsedNumber == null ? void 0 : parsedNumber.isValid()) {
|
|
28
|
+
return {
|
|
29
|
+
phone: parsedNumber.nationalNumber.replace(/\D/g, ""),
|
|
30
|
+
countryCode: `+${parsedNumber.countryCallingCode}`
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
throw new Error("Invalid phone number");
|
|
34
|
+
}
|
|
25
35
|
export {
|
|
26
36
|
displayPhoneNumber,
|
|
27
|
-
formatPhoneNumber
|
|
37
|
+
formatPhoneNumber,
|
|
38
|
+
splitPhoneNumber
|
|
28
39
|
};
|
package/dist/types/ParaCore.d.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
import { AuthMethod, AuthExtras, CurrentWalletIds, EmailTheme, TWalletType, PregenIds, BiometricLocationHint, Auth, SupportedWalletTypes, AuthIdentifier, AuthType, ExternalWalletInfo, PrimaryAuthInfo, SessionInfo, PrimaryAuth, PrimaryAuthType, AccountMetadata } from '@getpara/user-management-client';
|
|
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 } from '@getpara/user-management-client';
|
|
2
2
|
import type { pki as pkiType } from 'node-forge';
|
|
3
|
-
import { Ctx, Environment, Theme, WalletFilters, Wallet, PortalUrlOptions, ConstructorOpts, CoreAuthInfo, PortalUrlType, CoreMethodParams, CoreMethodResponse, NewCredentialUrlParams, LoginUrlParams, CoreInterface, ExternalWalletConnectionType } from './types/index.js';
|
|
3
|
+
import { Ctx, Environment, Theme, WalletFilters, Wallet, PortalUrlOptions, ConstructorOpts, CoreAuthInfo, PortalUrlType, CoreMethodParams, CoreMethodResponse, NewCredentialUrlParams, LoginUrlParams, CoreInterface, ExternalWalletConnectionType, AccountLinkInProgress, InternalMethodParams, InternalMethodResponse } 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
|
static version?: string;
|
|
8
8
|
ctx: Ctx;
|
|
9
9
|
protected isNativePasskey: boolean;
|
|
10
|
+
protected isPartnerOptional?: boolean;
|
|
11
|
+
isReady: boolean;
|
|
10
12
|
get authInfo(): CoreAuthInfo | undefined;
|
|
11
13
|
get email(): AuthIdentifier<'email'> | undefined;
|
|
12
14
|
get phone(): AuthIdentifier<'phone'> | undefined;
|
|
@@ -14,18 +16,24 @@ export declare abstract class ParaCore implements CoreInterface {
|
|
|
14
16
|
get telegramUserId(): AuthIdentifier<'telegram'> | undefined;
|
|
15
17
|
get externalWalletWithParaAuth(): Wallet | undefined;
|
|
16
18
|
get externalWalletConnectionType(): ExternalWalletConnectionType;
|
|
19
|
+
protected partner?: PartnerEntity;
|
|
17
20
|
userId?: string;
|
|
21
|
+
accountLinkInProgress: AccountLinkInProgress | undefined;
|
|
18
22
|
private sessionCookie?;
|
|
19
23
|
private isAwaitingAccountCreation;
|
|
20
24
|
private isAwaitingLogin;
|
|
21
25
|
private isAwaitingFarcaster;
|
|
22
26
|
private isAwaitingOAuth;
|
|
27
|
+
private isWorkerInitialized;
|
|
23
28
|
get isEmail(): boolean;
|
|
24
29
|
get isPhone(): boolean;
|
|
25
30
|
get isFarcaster(): boolean;
|
|
26
31
|
get isTelegram(): boolean;
|
|
27
32
|
get isExternalWalletAuth(): boolean;
|
|
33
|
+
get isExternalWalletWithVerification(): boolean;
|
|
28
34
|
get partnerId(): string | undefined;
|
|
35
|
+
protected get partnerName(): string | undefined;
|
|
36
|
+
protected get partnerLogo(): string | undefined;
|
|
29
37
|
/**
|
|
30
38
|
* The IDs of the currently active wallets, for each supported wallet type. Any signer integrations will default to the first viable wallet ID in this dictionary.
|
|
31
39
|
*/
|
|
@@ -119,11 +127,17 @@ export declare abstract class ParaCore implements CoreInterface {
|
|
|
119
127
|
*/
|
|
120
128
|
externalWalletConnectionOnly?: boolean;
|
|
121
129
|
private disableProviderModal?;
|
|
130
|
+
private fetchPregenWalletsOverride?;
|
|
122
131
|
get isNoWalletConfig(): boolean;
|
|
123
132
|
get supportedWalletTypes(): SupportedWalletTypes;
|
|
124
133
|
get cosmosPrefix(): string | undefined;
|
|
134
|
+
get supportedAccountLinks(): SupportedAccountLinks;
|
|
125
135
|
get isWalletTypeEnabled(): Partial<Record<TWalletType, boolean>>;
|
|
126
|
-
|
|
136
|
+
protected onRampPopup: {
|
|
137
|
+
window: Window;
|
|
138
|
+
onRampPurchase: OnRampPurchase;
|
|
139
|
+
} | undefined;
|
|
140
|
+
protected platformUtils: PlatformUtils;
|
|
127
141
|
private localStorageGetItem;
|
|
128
142
|
private localStorageSetItem;
|
|
129
143
|
private localStorageRemoveItem;
|
|
@@ -136,10 +150,10 @@ export declare abstract class ParaCore implements CoreInterface {
|
|
|
136
150
|
* Remove all local storage and prefixed session storage.
|
|
137
151
|
* @param {'local' | 'session' | 'secure' | 'all'} type - Type of storage to clear. Defaults to 'all'.
|
|
138
152
|
*/
|
|
139
|
-
clearStorage: (type?: CoreMethodParams<
|
|
153
|
+
clearStorage: (type?: CoreMethodParams<"clearStorage">) => CoreMethodResponse<"clearStorage">;
|
|
140
154
|
private convertBigInt;
|
|
141
155
|
private convertEncryptionKeyPair;
|
|
142
|
-
|
|
156
|
+
protected isPortal(envOverride?: Environment): boolean;
|
|
143
157
|
private isParaConnect;
|
|
144
158
|
private requireApiKey;
|
|
145
159
|
private isWalletSupported;
|
|
@@ -171,15 +185,18 @@ export declare abstract class ParaCore implements CoreInterface {
|
|
|
171
185
|
getWallets(): Record<string, Wallet>;
|
|
172
186
|
getAddress(walletId?: string): string | undefined;
|
|
173
187
|
protected abstract getPlatformUtils(): PlatformUtils;
|
|
188
|
+
abstract isPasskeySupported(): Promise<boolean>;
|
|
174
189
|
protected constructPortalUrl(type: PortalUrlType, opts?: PortalUrlOptions): Promise<string>;
|
|
190
|
+
static resolveEnvironment(env: Environment | undefined, apiKey: string | undefined): Environment;
|
|
175
191
|
/**
|
|
176
192
|
* Constructs a new `ParaCore` instance.
|
|
177
|
-
* @param env - `Environment` to use.
|
|
193
|
+
* @param env - `Environment` to use. Optional if the apiKey contains an environment prefix (e.g., "prod_your_api_key"). Updated API keys can be found at https://developer.getpara.com.
|
|
178
194
|
* @param apiKey - API key to use.
|
|
179
195
|
* @param opts - Additional constructor options; see `ConstructorOpts`.
|
|
180
196
|
* @returns - A new ParaCore instance.
|
|
181
197
|
*/
|
|
182
|
-
constructor(env: Environment, apiKey: string, opts?: ConstructorOpts);
|
|
198
|
+
constructor(env: Environment | undefined, apiKey: string, opts?: ConstructorOpts);
|
|
199
|
+
constructor(apiKey: string, opts?: ConstructorOpts);
|
|
183
200
|
private trackError;
|
|
184
201
|
private wrapMethodsWithErrorTracking;
|
|
185
202
|
private initializeFromStorage;
|
|
@@ -190,6 +207,7 @@ export declare abstract class ParaCore implements CoreInterface {
|
|
|
190
207
|
private updateSessionCookieFromStorage;
|
|
191
208
|
private updateLoginEncryptionKeyPairFromStorage;
|
|
192
209
|
private updateExternalWalletsFromStorage;
|
|
210
|
+
protected initializeWorker: () => Promise<void>;
|
|
193
211
|
touchSession(regenerate?: boolean): Promise<SessionInfo>;
|
|
194
212
|
private getVerificationEmailProps;
|
|
195
213
|
private getBackupKitEmailProps;
|
|
@@ -199,11 +217,19 @@ export declare abstract class ParaCore implements CoreInterface {
|
|
|
199
217
|
* Init only needs to be called for storage that is async.
|
|
200
218
|
*/
|
|
201
219
|
init(): Promise<void>;
|
|
220
|
+
/**
|
|
221
|
+
* Call this method to perform initial setup for the `ParaCore` instance.
|
|
222
|
+
*
|
|
223
|
+
* This method will be called automatically if you use the React `ParaProvider` or when you call any methods that request an updated session.
|
|
224
|
+
*/
|
|
225
|
+
abstract ready(): Promise<void>;
|
|
202
226
|
protected setAuth(auth: PrimaryAuth, { extras, userId }?: {
|
|
203
227
|
extras?: AuthExtras;
|
|
204
228
|
userId?: string;
|
|
205
229
|
}): Promise<typeof this.authInfo>;
|
|
206
|
-
protected assertUserId(
|
|
230
|
+
protected assertUserId({ allowGuestMode }?: {
|
|
231
|
+
allowGuestMode?: boolean;
|
|
232
|
+
}): string;
|
|
207
233
|
protected assertIsAuthSet(allowed?: AuthType[]): PrimaryAuthInfo;
|
|
208
234
|
/**
|
|
209
235
|
* Sets the email associated with the `ParaCore` instance.
|
|
@@ -231,7 +257,8 @@ export declare abstract class ParaCore implements CoreInterface {
|
|
|
231
257
|
* @param externalAddress - External wallet address to set.
|
|
232
258
|
* @param externalType - Type of external wallet to set.
|
|
233
259
|
*/
|
|
234
|
-
setExternalWallet(
|
|
260
|
+
setExternalWallet(externalWallet: ExternalWalletInfo[] | ExternalWalletInfo): Promise<void>;
|
|
261
|
+
protected addExternalWallets(externalWallets: ExternalWalletInfo[]): Promise<void>;
|
|
235
262
|
/**
|
|
236
263
|
* Sets the user id associated with the `ParaCore` instance.
|
|
237
264
|
* @param userId - User id to set.
|
|
@@ -282,6 +309,7 @@ export declare abstract class ParaCore implements CoreInterface {
|
|
|
282
309
|
/**
|
|
283
310
|
* Fetches the most recent OAuth account metadata for the signed-in user.
|
|
284
311
|
* If applicable, this will include the user's most recent metadata from their Google, Apple, Facebook, X, Discord, Farcaster, or Telegram account, the last time they signed in to your app.
|
|
312
|
+
* @deprecated use `para.getLinkedAccounts({ withMetadata: true })` instead.
|
|
285
313
|
* @returns {Promise<AccountMetadata>} the user's account metadata.
|
|
286
314
|
*/
|
|
287
315
|
getAccountMetadata(): Promise<AccountMetadata>;
|
|
@@ -302,7 +330,7 @@ export declare abstract class ParaCore implements CoreInterface {
|
|
|
302
330
|
*/
|
|
303
331
|
findWalletByAddress(address: string, filter?: WalletFilters | undefined): any;
|
|
304
332
|
findWallet(idOrAddress?: string, overrideType?: TWalletType, filter?: WalletFilters): Omit<Wallet, 'signer'> | undefined;
|
|
305
|
-
get availableWallets(): Pick<Wallet, 'id' | 'type' | 'name' | 'address' | 'isExternal'>[];
|
|
333
|
+
get availableWallets(): Pick<Wallet, 'id' | 'type' | 'name' | 'address' | 'isExternal' | 'externalProviderId' | 'isExternalConnectionOnly'>[];
|
|
306
334
|
/**
|
|
307
335
|
* Retrieves all usable wallets with the provided type (`'EVM' | 'COSMOS' | 'SOLANA'`)
|
|
308
336
|
* @param {string} type the wallet type to filter by.
|
|
@@ -342,13 +370,15 @@ export declare abstract class ParaCore implements CoreInterface {
|
|
|
342
370
|
*/
|
|
343
371
|
loginExternalWallet({ externalWallet, ...urlOptions }: CoreMethodParams<'loginExternalWallet'>): CoreMethodResponse<'loginExternalWallet'>;
|
|
344
372
|
verifyExternalWallet({ externalWallet, signedMessage, cosmosPublicKeyHex, cosmosSigner, ...urlOptions }: CoreMethodParams<'verifyExternalWallet'>): CoreMethodResponse<'verifyExternalWallet'>;
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
373
|
+
protected verifyExternalWalletLink(opts: InternalMethodParams<'verifyExternalWalletLink'>): InternalMethodResponse<'verifyExternalWalletLink'>;
|
|
374
|
+
protected verifyTelegramProcess(opts: CoreMethodParams<'verifyTelegram'> & {
|
|
375
|
+
isLinkAccount: false;
|
|
376
|
+
}): CoreMethodResponse<'verifyTelegram'>;
|
|
377
|
+
protected verifyTelegramProcess(opts: InternalMethodParams<'verifyTelegramLink'> & {
|
|
378
|
+
isLinkAccount: true;
|
|
379
|
+
}): InternalMethodResponse<'verifyTelegramLink'>;
|
|
380
|
+
verifyTelegram(opts: CoreMethodParams<'verifyTelegram'>): CoreMethodResponse<'verifyTelegram'>;
|
|
381
|
+
protected verifyTelegramLink(opts: InternalMethodParams<'verifyTelegramLink'>): InternalMethodResponse<'verifyTelegramLink'>;
|
|
352
382
|
/**
|
|
353
383
|
* Performs 2FA verification.
|
|
354
384
|
* @param {Object} opts the options object
|
|
@@ -371,7 +401,7 @@ export declare abstract class ParaCore implements CoreInterface {
|
|
|
371
401
|
/**
|
|
372
402
|
* Resend a verification email for the current user.
|
|
373
403
|
*/
|
|
374
|
-
resendVerificationCode(): CoreMethodResponse<'resendVerificationCode'>;
|
|
404
|
+
resendVerificationCode({ type: reason, }: CoreMethodParams<'resendVerificationCode'>): CoreMethodResponse<'resendVerificationCode'>;
|
|
375
405
|
/**
|
|
376
406
|
* Checks if the current session is active.
|
|
377
407
|
* @returns `true` if active, `false` otherwise
|
|
@@ -383,6 +413,9 @@ export declare abstract class ParaCore implements CoreInterface {
|
|
|
383
413
|
**/
|
|
384
414
|
isFullyLoggedIn(): CoreMethodResponse<'isFullyLoggedIn'>;
|
|
385
415
|
get isGuestMode(): boolean;
|
|
416
|
+
/**
|
|
417
|
+
* Get the auth methods available to an existing user
|
|
418
|
+
*/
|
|
386
419
|
protected supportedAuthMethods(auth: Auth<PrimaryAuthType | 'userId'>): Promise<Set<AuthMethod>>;
|
|
387
420
|
/**
|
|
388
421
|
* Get hints associated with the users stored biometrics.
|
|
@@ -396,35 +429,30 @@ export declare abstract class ParaCore implements CoreInterface {
|
|
|
396
429
|
waitForSignup({ isCanceled, onCancel, onPoll, }: CoreMethodParams<'waitForSignup'>): CoreMethodResponse<'waitForSignup'>;
|
|
397
430
|
waitForWalletCreation({ isCanceled, onCancel, }?: CoreMethodParams<'waitForWalletCreation'>): CoreMethodResponse<'waitForWalletCreation'>;
|
|
398
431
|
/**
|
|
399
|
-
* Initiates a Farcaster login attempt and
|
|
432
|
+
* Initiates a Farcaster login attempt and returns the URL for the user to connect.
|
|
400
433
|
* You can create a QR code with this URI that works with Farcaster's mobile app.
|
|
401
434
|
* @return {string} the Farcaster connect URI
|
|
402
435
|
*/
|
|
403
|
-
getFarcasterConnectUri(
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
* @param {Object} opts the options object.
|
|
424
|
-
* @param {Window} [opts.popupWindow] the popup window being used for login.
|
|
425
|
-
* @return {Object} `{ email?: string; isError?: boolean; userExists: boolean; }` the result data
|
|
426
|
-
*/
|
|
427
|
-
verifyOAuth({ method, deeplinkUrl, isCanceled, onCancel, onPoll, onOAuthUrl, ...urlOptions }: CoreMethodParams<'verifyOAuth'>): CoreMethodResponse<'verifyOAuth'>;
|
|
436
|
+
getFarcasterConnectUri({ appScheme }?: {
|
|
437
|
+
appScheme?: string;
|
|
438
|
+
}): CoreMethodResponse<'getFarcasterConnectUri'>;
|
|
439
|
+
protected verifyFarcasterProcess(opts: CoreMethodParams<'verifyFarcaster'> & {
|
|
440
|
+
isLinkAccount: false;
|
|
441
|
+
}): CoreMethodResponse<'verifyFarcaster'>;
|
|
442
|
+
protected verifyFarcasterProcess(opts: InternalMethodParams<'verifyFarcasterLink'> & {
|
|
443
|
+
isLinkAccount: true;
|
|
444
|
+
}): InternalMethodResponse<'verifyFarcasterLink'>;
|
|
445
|
+
verifyFarcaster(opts: CoreMethodParams<'verifyFarcaster'>): CoreMethodResponse<'verifyFarcaster'>;
|
|
446
|
+
protected verifyFarcasterLink(opts: InternalMethodParams<'verifyFarcasterLink'>): InternalMethodResponse<'verifyFarcasterLink'>;
|
|
447
|
+
getOAuthUrl(opts: CoreMethodParams<'getOAuthUrl'>): CoreMethodResponse<'getOAuthUrl'>;
|
|
448
|
+
protected verifyOAuthProcess(_: InternalMethodParams<'verifyOAuthLink'> & {
|
|
449
|
+
isLinkAccount: true;
|
|
450
|
+
}): InternalMethodResponse<'verifyOAuthLink'>;
|
|
451
|
+
protected verifyOAuthProcess(_: CoreMethodParams<'verifyOAuth'> & {
|
|
452
|
+
isLinkAccount: false;
|
|
453
|
+
}): CoreMethodResponse<'verifyOAuth'>;
|
|
454
|
+
verifyOAuth(opts: CoreMethodParams<'verifyOAuth'>): CoreMethodResponse<'verifyOAuth'>;
|
|
455
|
+
protected verifyOAuthLink(opts: InternalMethodParams<'verifyOAuthLink'>): InternalMethodResponse<'verifyOAuthLink'>;
|
|
428
456
|
/**
|
|
429
457
|
* Waits for the session to be active and sets up the user.
|
|
430
458
|
*
|
|
@@ -495,7 +523,7 @@ export declare abstract class ParaCore implements CoreInterface {
|
|
|
495
523
|
*
|
|
496
524
|
* @deprecated alias for `createWalletPerType`
|
|
497
525
|
**/
|
|
498
|
-
createWalletPerMissingType: ({ skipDistribute, types, }?: CoreMethodParams<
|
|
526
|
+
createWalletPerMissingType: ({ skipDistribute, types, }?: CoreMethodParams<"createWalletPerType">) => CoreMethodResponse<"createWalletPerType">;
|
|
499
527
|
/**
|
|
500
528
|
* Creates several new wallets with the desired types. If no types are provided, this method
|
|
501
529
|
* will create one for each of the non-optional types specified in the instance's `supportedWalletTypes`
|
|
@@ -587,7 +615,7 @@ export declare abstract class ParaCore implements CoreInterface {
|
|
|
587
615
|
setUserShare(base64Wallets: CoreMethodParams<'setUserShare'>): CoreMethodResponse<'setUserShare'>;
|
|
588
616
|
private getTransactionReviewUrl;
|
|
589
617
|
private getOnRampTransactionUrl;
|
|
590
|
-
getWalletBalance: ({ walletId, rpcUrl, }: CoreMethodParams<
|
|
618
|
+
getWalletBalance: ({ walletId, rpcUrl, }: CoreMethodParams<"getWalletBalance">) => CoreMethodResponse<"getWalletBalance">;
|
|
591
619
|
/**
|
|
592
620
|
* Signs a message using one of the current wallets.
|
|
593
621
|
*
|
|
@@ -640,6 +668,7 @@ export declare abstract class ParaCore implements CoreInterface {
|
|
|
640
668
|
* @returns {Promise<string>} the ID
|
|
641
669
|
**/
|
|
642
670
|
getVerificationToken(): CoreMethodResponse<'getVerificationToken'>;
|
|
671
|
+
issueJwt({ keyIndex }?: CoreMethodParams<'issueJwt'>): CoreMethodResponse<'issueJwt'>;
|
|
643
672
|
/**
|
|
644
673
|
* Logs the user out.
|
|
645
674
|
* @param {Object} opts the options object.
|
|
@@ -648,20 +677,20 @@ export declare abstract class ParaCore implements CoreInterface {
|
|
|
648
677
|
logout({ clearPregenWallets }?: {
|
|
649
678
|
clearPregenWallets?: boolean;
|
|
650
679
|
}): Promise<void>;
|
|
651
|
-
|
|
652
|
-
protected getSupportedCreateAuthMethods(): Promise<Set<AuthMethod>>;
|
|
680
|
+
protected get toStringAdditions(): Record<string, unknown>;
|
|
653
681
|
/**
|
|
654
682
|
* Converts to a string, removing sensitive data when logging this class.
|
|
655
683
|
*
|
|
656
684
|
* Doesn't work for all types of logging.
|
|
657
685
|
**/
|
|
658
686
|
toString(): string;
|
|
687
|
+
protected devLog(...s: string[]): void;
|
|
659
688
|
protected getNewCredentialAndUrl({ authMethod, isForNewDevice, portalTheme, shorten, }?: NewCredentialUrlParams): Promise<{
|
|
660
689
|
credentialId: string;
|
|
661
690
|
url?: string;
|
|
662
691
|
}>;
|
|
663
692
|
/**
|
|
664
|
-
* Returns a Para Portal URL for logging in with a WebAuth passkey or
|
|
693
|
+
* Returns a Para Portal URL for logging in with a WebAuth passkey, password or PIN.
|
|
665
694
|
* @param {Object} opts the options object
|
|
666
695
|
* @param {String} opts.auth - the user auth to sign up or log in with, in the form ` { email: string } | { phone: `+${number}` } `
|
|
667
696
|
* @param {boolean} opts.useShortUrls - whether to shorten the generated portal URLs
|
|
@@ -669,6 +698,15 @@ export declare abstract class ParaCore implements CoreInterface {
|
|
|
669
698
|
* @returns {SignUpOrLogInResponse} an object in the form of either: `{ stage: 'verify' }` or `{ stage: 'login'; passkeyUrl?: string; passwordUrl?: string; biometricHints?: BiometricLocationHint[] }`
|
|
670
699
|
*/
|
|
671
700
|
protected getLoginUrl({ authMethod, shorten, portalTheme, sessionId, }: LoginUrlParams): Promise<string>;
|
|
701
|
+
protected prepareLogin(): InternalMethodResponse<'prepareLogin'>;
|
|
672
702
|
signUpOrLogIn({ auth, ...urlOptions }: CoreMethodParams<'signUpOrLogIn'>): CoreMethodResponse<'signUpOrLogIn'>;
|
|
673
703
|
verifyNewAccount({ verificationCode, ...urlOptions }: CoreMethodParams<'verifyNewAccount'>): CoreMethodResponse<'verifyNewAccount'>;
|
|
704
|
+
getLinkedAccounts({ withMetadata, }?: CoreMethodParams<'getLinkedAccounts'>): CoreMethodResponse<'getLinkedAccounts'>;
|
|
705
|
+
protected linkAccount(opts: InternalMethodParams<'linkAccount'>): InternalMethodResponse<'linkAccount'>;
|
|
706
|
+
protected unlinkAccount({ linkedAccountId, }: InternalMethodParams<'unlinkAccount'>): InternalMethodResponse<'unlinkAccount'>;
|
|
707
|
+
protected verifyLink({ accountLinkInProgress, ...opts }?: {
|
|
708
|
+
accountLinkInProgress?: AccountLinkInProgress;
|
|
709
|
+
} & Partial<Pick<VerifyLinkParams, 'verificationCode' | 'telegramAuthResponse'> & VerifyExternalWalletParams>): Promise<LinkedAccounts>;
|
|
710
|
+
protected verifyEmailOrPhoneLink({ verificationCode, }: InternalMethodParams<'verifyEmailOrPhoneLink'>): InternalMethodResponse<'verifyEmailOrPhoneLink'>;
|
|
711
|
+
protected sendLoginCode(): Promise<void>;
|
|
674
712
|
}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/// <reference types="node" />
|
|
3
1
|
import { BackupKitEmailProps, TPregenIdentifierType, TWalletType, SDKType } from '@getpara/user-management-client';
|
|
4
2
|
import { Ctx, PopupType, SignatureRes } from './types/index.js';
|
|
5
3
|
import { StorageUtils } from './StorageUtils.js';
|
|
@@ -44,5 +42,6 @@ export interface PlatformUtils {
|
|
|
44
42
|
disableProviderModal?: boolean;
|
|
45
43
|
openPopup(popupUrl: string, opts?: {
|
|
46
44
|
type: PopupType;
|
|
47
|
-
}): Window
|
|
45
|
+
}): Promise<Window>;
|
|
46
|
+
initializeWorker(ctx: Ctx): Promise<void>;
|
|
48
47
|
}
|
|
@@ -1,20 +1,22 @@
|
|
|
1
1
|
export declare const PARA_CORE_VERSION: string;
|
|
2
2
|
export declare const PREFIX = "@CAPSULE/";
|
|
3
|
-
export declare const
|
|
4
|
-
export declare const
|
|
5
|
-
export declare const
|
|
6
|
-
export declare const
|
|
7
|
-
export declare const
|
|
8
|
-
export declare const
|
|
9
|
-
export declare const
|
|
10
|
-
export declare const
|
|
11
|
-
export declare const
|
|
12
|
-
export declare const
|
|
13
|
-
export declare const
|
|
14
|
-
export declare const
|
|
15
|
-
export declare const
|
|
16
|
-
export declare const
|
|
3
|
+
export declare const PARA_PREFIX = "@PARA/";
|
|
4
|
+
export declare const LOCAL_STORAGE_AUTH_INFO = "@CAPSULE/authInfo";
|
|
5
|
+
export declare const LOCAL_STORAGE_EMAIL = "@CAPSULE/e-mail";
|
|
6
|
+
export declare const LOCAL_STORAGE_PHONE = "@CAPSULE/phone";
|
|
7
|
+
export declare const LOCAL_STORAGE_COUNTRY_CODE = "@CAPSULE/countryCode";
|
|
8
|
+
export declare const LOCAL_STORAGE_FARCASTER_USERNAME = "@CAPSULE/farcasterUsername";
|
|
9
|
+
export declare const LOCAL_STORAGE_TELEGRAM_USER_ID = "@CAPSULE/telegramUserId";
|
|
10
|
+
export declare const LOCAL_STORAGE_EXTERNAL_WALLET_USER_ID = "@CAPSULE/externalWalletUserId";
|
|
11
|
+
export declare const LOCAL_STORAGE_USER_ID = "@CAPSULE/userId";
|
|
12
|
+
export declare const LOCAL_STORAGE_ED25519_WALLETS = "@CAPSULE/ed25519Wallets";
|
|
13
|
+
export declare const LOCAL_STORAGE_WALLETS = "@CAPSULE/wallets";
|
|
14
|
+
export declare const LOCAL_STORAGE_EXTERNAL_WALLETS = "@CAPSULE/externalWallets";
|
|
15
|
+
export declare const LOCAL_STORAGE_CURRENT_WALLET_IDS = "@CAPSULE/currentWalletIds";
|
|
16
|
+
export declare const LOCAL_STORAGE_SESSION_COOKIE = "@CAPSULE/sessionCookie";
|
|
17
|
+
export declare const SESSION_STORAGE_LOGIN_ENCRYPTION_KEY_PAIR = "@CAPSULE/loginEncryptionKeyPair";
|
|
17
18
|
export declare const POLLING_INTERVAL_MS = 2000;
|
|
18
19
|
export declare const SHORT_POLLING_INTERVAL_MS = 1000;
|
|
19
20
|
export declare const POLLING_TIMEOUT_MS = 300000;
|
|
20
21
|
export declare const EXTERNAL_WALLET_CONNECTION_ONLY_USER_ID = "EXTERNAL_WALLET_CONNECTION_ONLY";
|
|
22
|
+
export declare const ACCOUNT_LINK_CONFLICT = "Account already linked";
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { ParaCore } from './ParaCore.js';
|
|
2
|
-
export { type AuthInfo, type PrimaryAuthInfo, type VerifiedAuthInfo, AuthMethod, type AuthExtras, type CurrentWalletIds, EmailTheme, type PartnerEntity, type WalletEntity, Network, type TWalletType, type TWalletScheme, OnRampAsset, OnRampPurchaseType, OnRampProvider, OnRampPurchaseStatus, type OnRampConfig, type OnRampAllowedAssets, type OnRampPurchase, type TOAuthMethod, type SupportedWalletTypes, type TPregenIdentifierType, type PregenIds, NON_ED25519, PREGEN_IDENTIFIER_TYPES, WALLET_TYPES, WALLET_SCHEMES, OAUTH_METHODS, } from '@getpara/user-management-client';
|
|
3
|
-
export { OnRampMethod, PopupType, PregenIdentifierType, RecoveryStatus, type AuthStateSignup, type AuthStateVerify, type AuthStateLogin, type AuthState, type OAuthResponse, type CoreAuthInfo, type ProviderAssetInfo, type SignatureRes, type FullSignatureRes, type SuccessfulSignatureRes, type DeniedSignatureRes, type DeniedSignatureResWithUrl, type OnRampAssetInfo, type Theme, type Wallet, type GetWalletBalanceParams, } from './types/index.js';
|
|
2
|
+
export { type Auth, type AuthInfo, type PrimaryAuthInfo, type VerifiedAuthInfo, type VerifiedAuth, AuthMethod, type AuthExtras, type CurrentWalletIds, EmailTheme, type PartnerEntity, type WalletEntity, Network, WalletType, type TWalletType, WalletScheme, type TWalletScheme, OnRampAsset, OnRampPurchaseType, OnRampProvider, OnRampPurchaseStatus, type OnRampConfig, type OnRampAllowedAssets, type OnRampPurchase, 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, 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 { OnRampMethod, PopupType, PregenIdentifierType, RecoveryStatus, type AuthStateSignup, type AuthStateVerify, type AuthStateLogin, type AuthState, type OAuthResponse, type CoreAuthInfo, type ProviderAssetInfo, type SignatureRes, type FullSignatureRes, type SuccessfulSignatureRes, type DeniedSignatureRes, type DeniedSignatureResWithUrl, type OnRampAssetInfo, type Theme, type Wallet, 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
7
|
export { getPortalDomain, entityToWallet, constructUrl, shortenUrl } from './utils/index.js';
|
|
8
|
-
export { PREFIX as STORAGE_PREFIX } from './constants.js';
|
|
8
|
+
export { PREFIX as STORAGE_PREFIX, PARA_PREFIX as PARA_STORAGE_PREFIX } 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';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ExternalWalletInfo, TLinkedAccountType } from '@getpara/user-management-client';
|
|
2
|
+
export type AccountLinkInProgress = {
|
|
3
|
+
id: string;
|
|
4
|
+
type: TLinkedAccountType;
|
|
5
|
+
identifier?: string;
|
|
6
|
+
isComplete: boolean;
|
|
7
|
+
externalWallet?: ExternalWalletInfo & {
|
|
8
|
+
signatureVerificationMessage: string;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
export declare enum AccountLinkError {
|
|
12
|
+
NotAuthenticated = "No user is currently authenticated",
|
|
13
|
+
Conflict = "Account already linked",
|
|
14
|
+
Canceled = "Account linking was canceled",
|
|
15
|
+
Unknown = "An unknown error occurred"
|
|
16
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AxiosInstance } from 'axios';
|
|
2
|
-
import Client, { EmailTheme, Network, OnRampAsset, OnRampProvider, TWalletScheme, TWalletType } from '@getpara/user-management-client';
|
|
2
|
+
import Client, { EmailTheme, Network, OnRampAsset, OnRampProvider, PregenAuth, TWalletScheme, TWalletType } from '@getpara/user-management-client';
|
|
3
3
|
import { Theme } from './theme.js';
|
|
4
4
|
export declare enum Environment {
|
|
5
5
|
DEV = "DEV",
|
|
@@ -140,4 +140,12 @@ export interface ConstructorOpts {
|
|
|
140
140
|
* Partner ID set in the Para Portal to track analytics for legacy SDK versions. This variable is unused outside of the Para Portal.
|
|
141
141
|
*/
|
|
142
142
|
portalPartnerId?: string;
|
|
143
|
+
/**
|
|
144
|
+
* An optional function that fetches the pregenerated wallets for a given identifier so a user can claim them on account creation.
|
|
145
|
+
*/
|
|
146
|
+
fetchPregenWalletsOverride?: (opts: {
|
|
147
|
+
pregenId: PregenAuth;
|
|
148
|
+
}) => Promise<{
|
|
149
|
+
userShare?: string;
|
|
150
|
+
}>;
|
|
143
151
|
}
|