@getpara/core-sdk 2.0.0-alpha.6 → 2.0.0-alpha.61

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.
Files changed (75) hide show
  1. package/dist/cjs/ParaCore.js +1038 -248
  2. package/dist/cjs/constants.js +13 -1
  3. package/dist/cjs/index.js +31 -3
  4. package/dist/cjs/shares/enclave.js +266 -0
  5. package/dist/cjs/shares/shareDistribution.js +16 -1
  6. package/dist/cjs/types/{theme.js → assets.js} +2 -2
  7. package/dist/cjs/types/{onRamps.js → auth.js} +12 -12
  8. package/dist/cjs/types/coreApi.js +20 -3
  9. package/dist/cjs/types/events.js +2 -0
  10. package/dist/cjs/types/index.js +2 -21
  11. package/dist/cjs/utils/config.js +108 -0
  12. package/dist/cjs/utils/formatting.js +46 -0
  13. package/dist/cjs/utils/index.js +2 -0
  14. package/dist/cjs/utils/onRamps.js +2 -3
  15. package/dist/cjs/utils/wallet.js +3 -0
  16. package/dist/esm/ParaCore.js +1045 -254
  17. package/dist/esm/{chunk-7B52C2XE.js → chunk-W5CT3TVS.js} +2 -0
  18. package/dist/esm/constants.js +10 -2
  19. package/dist/esm/cryptography/utils.js +1 -1
  20. package/dist/esm/errors.js +1 -1
  21. package/dist/esm/external/mpcComputationClient.js +1 -1
  22. package/dist/esm/external/userManagementClient.js +1 -1
  23. package/dist/esm/index.js +31 -6
  24. package/dist/esm/shares/KeyContainer.js +1 -1
  25. package/dist/esm/shares/enclave.js +226 -0
  26. package/dist/esm/shares/recovery.js +1 -1
  27. package/dist/esm/shares/shareDistribution.js +17 -2
  28. package/dist/esm/transmission/transmissionUtils.js +1 -1
  29. package/dist/esm/types/auth.js +11 -0
  30. package/dist/esm/types/config.js +1 -1
  31. package/dist/esm/types/coreApi.js +19 -3
  32. package/dist/esm/types/events.js +3 -1
  33. package/dist/esm/types/index.js +1 -16
  34. package/dist/esm/types/popup.js +1 -1
  35. package/dist/esm/types/wallet.js +1 -1
  36. package/dist/esm/utils/autobind.js +1 -1
  37. package/dist/esm/utils/config.js +86 -0
  38. package/dist/esm/utils/events.js +1 -1
  39. package/dist/esm/utils/formatting.js +44 -1
  40. package/dist/esm/utils/index.js +1 -0
  41. package/dist/esm/utils/json.js +1 -1
  42. package/dist/esm/utils/listeners.js +1 -1
  43. package/dist/esm/utils/onRamps.js +3 -4
  44. package/dist/esm/utils/phone.js +1 -1
  45. package/dist/esm/utils/polling.js +1 -1
  46. package/dist/esm/utils/types.js +1 -1
  47. package/dist/esm/utils/url.js +1 -1
  48. package/dist/esm/utils/wallet.js +4 -1
  49. package/dist/types/ParaCore.d.ts +115 -52
  50. package/dist/types/PlatformUtils.d.ts +2 -3
  51. package/dist/types/constants.d.ts +18 -14
  52. package/dist/types/index.d.ts +6 -4
  53. package/dist/types/shares/KeyContainer.d.ts +0 -2
  54. package/dist/types/shares/enclave.d.ts +81 -0
  55. package/dist/types/shares/shareDistribution.d.ts +4 -2
  56. package/dist/types/types/assets.d.ts +14 -0
  57. package/dist/types/types/auth.d.ts +16 -0
  58. package/dist/types/types/config.d.ts +11 -2
  59. package/dist/types/types/coreApi.d.ts +101 -36
  60. package/dist/types/types/events.d.ts +7 -2
  61. package/dist/types/types/index.d.ts +1 -4
  62. package/dist/types/types/methods.d.ts +85 -13
  63. package/dist/types/types/wallet.d.ts +7 -4
  64. package/dist/types/utils/config.d.ts +7 -0
  65. package/dist/types/utils/formatting.d.ts +12 -1
  66. package/dist/types/utils/index.d.ts +1 -0
  67. package/dist/types/utils/onRamps.d.ts +9 -10
  68. package/package.json +23 -23
  69. package/dist/cjs/types/recovery.js +0 -34
  70. package/dist/esm/types/onRamps.js +0 -11
  71. package/dist/esm/types/recovery.js +0 -12
  72. package/dist/types/types/onRamps.d.ts +0 -10
  73. package/dist/types/types/recovery.d.ts +0 -7
  74. package/dist/types/types/theme.d.ts +0 -12
  75. /package/dist/esm/types/{theme.js → assets.js} +0 -0
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  __spreadValues
3
- } from "../chunk-7B52C2XE.js";
3
+ } from "../chunk-W5CT3TVS.js";
4
4
  function dispatchEvent(type, data, error) {
5
5
  typeof window !== "undefined" && !!window.dispatchEvent && window.dispatchEvent(
6
6
  new CustomEvent(type, { detail: __spreadValues({ data }, error && { error: new Error(error) }) })
@@ -1,4 +1,6 @@
1
- import "../chunk-7B52C2XE.js";
1
+ import {
2
+ __pow
3
+ } from "../chunk-W5CT3TVS.js";
2
4
  import { toBech32 } from "@cosmjs/encoding";
3
5
  import { sha256 } from "@noble/hashes/sha256";
4
6
  import { ripemd160 } from "@noble/hashes/ripemd160";
@@ -63,12 +65,53 @@ function truncateAddress(str, addressType, {
63
65
  const margin = targetLength !== void 0 ? (targetLength - minimum) / 2 : 4;
64
66
  return `${str.slice(0, minimum + margin)}...${str.slice(-1 * margin)}`;
65
67
  }
68
+ function formatCurrency(value, { fallback = "" } = {}) {
69
+ if (!value) {
70
+ return fallback;
71
+ }
72
+ const formatter = new Intl.NumberFormat("en-US", {
73
+ style: "currency",
74
+ currency: value.currency
75
+ });
76
+ const zeroFormatter = new Intl.NumberFormat("en-US", {
77
+ style: "currency",
78
+ currency: value.currency,
79
+ maximumFractionDigits: 0
80
+ });
81
+ return Math.abs(value.value) < 0.01 ? zeroFormatter.format(0) : formatter.format(value.value);
82
+ }
83
+ const zeroAssetFormatter = new Intl.NumberFormat("en-US", {
84
+ style: "decimal",
85
+ maximumFractionDigits: 0,
86
+ minimumFractionDigits: 0
87
+ });
88
+ function formatAssetQuantity({
89
+ quantity,
90
+ symbol = "",
91
+ decimals,
92
+ fallback = ""
93
+ }) {
94
+ if (quantity == null) {
95
+ return fallback;
96
+ }
97
+ const formatter = new Intl.NumberFormat("en-US", {
98
+ style: "decimal",
99
+ maximumFractionDigits: decimals != null ? decimals : Math.abs(quantity) < 1e-3 ? 6 : 3,
100
+ minimumFractionDigits: decimals != null ? decimals : 3
101
+ });
102
+ const formattedQuantity = quantity === 0 ? "0" : Math.abs(quantity) < __pow(10, -1 * (decimals != null ? decimals : 6)) ? zeroAssetFormatter.format(0) : formatter.format(quantity);
103
+ return `${formattedQuantity}${symbol && symbol.length > 0 ? ` ${symbol}` : ""}`;
104
+ }
66
105
  export {
106
+ compressPubkey,
67
107
  decimalToHex,
108
+ formatAssetQuantity,
109
+ formatCurrency,
68
110
  getCosmosAddress,
69
111
  hexStringToBase64,
70
112
  hexToDecimal,
71
113
  hexToSignature,
72
114
  hexToUint8Array,
115
+ rawSecp256k1PubkeyToRawAddress,
73
116
  truncateAddress
74
117
  };
@@ -1,4 +1,5 @@
1
1
  export * from "./autobind.js";
2
+ export * from "./config.js";
2
3
  export * from "./events.js";
3
4
  export * from "./formatting.js";
4
5
  export * from "./json.js";
@@ -1,4 +1,4 @@
1
- import "../chunk-7B52C2XE.js";
1
+ import "../chunk-W5CT3TVS.js";
2
2
  function jsonParse(data, validate) {
3
3
  try {
4
4
  const res = JSON.parse(data);
@@ -1,4 +1,4 @@
1
- import "../chunk-7B52C2XE.js";
1
+ import "../chunk-W5CT3TVS.js";
2
2
  import * as constants from "../constants.js";
3
3
  function storageListener(e) {
4
4
  if (!e.url.includes(window.location.origin)) {
@@ -1,5 +1,4 @@
1
- import "../chunk-7B52C2XE.js";
2
- import { Network } from "@getpara/user-management-client";
1
+ import "../chunk-W5CT3TVS.js";
3
2
  function toAssetInfoArray(data) {
4
3
  const result = [];
5
4
  Object.keys(data).forEach((walletType) => {
@@ -51,8 +50,8 @@ function getOnRampAssets(data, {
51
50
  ];
52
51
  }
53
52
  const NETWORK_PREFIXES = {
54
- [Network.COSMOS]: "cosmos",
55
- [Network.NOBLE]: "noble"
53
+ COSMOS: "cosmos",
54
+ NOBLE: "noble"
56
55
  };
57
56
  function getNetworkPrefix(network) {
58
57
  return NETWORK_PREFIXES[network];
@@ -1,4 +1,4 @@
1
- import "../chunk-7B52C2XE.js";
1
+ import "../chunk-W5CT3TVS.js";
2
2
  import parsePhoneNumberFromString from "libphonenumber-js";
3
3
  function formatPhoneNumber(phone, countryCode, { forDisplay = false } = {}) {
4
4
  phone = phone.toString();
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  __async
3
- } from "../chunk-7B52C2XE.js";
3
+ } from "../chunk-W5CT3TVS.js";
4
4
  function waitUntilTrue(condition, timeoutMs, intervalMs) {
5
5
  return __async(this, null, function* () {
6
6
  const start = Date.now();
@@ -1,4 +1,4 @@
1
- import "../chunk-7B52C2XE.js";
1
+ import "../chunk-W5CT3TVS.js";
2
2
  function isServerAuthState(obj) {
3
3
  return "stage" in obj;
4
4
  }
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  __async
3
- } from "../chunk-7B52C2XE.js";
3
+ } from "../chunk-W5CT3TVS.js";
4
4
  import { upload } from "../transmission/transmissionUtils.js";
5
5
  import { Environment } from "../types/index.js";
6
6
  function getPortalDomain(env, isE2E) {
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  __spreadProps,
3
3
  __spreadValues
4
- } from "../chunk-7B52C2XE.js";
4
+ } from "../chunk-W5CT3TVS.js";
5
5
  import * as uuid from "uuid";
6
6
  import { formatPhoneNumber } from "./phone.js";
7
7
  const WalletSchemeTypeMap = {
@@ -59,7 +59,10 @@ function getEquivalentTypes(types) {
59
59
  return getWalletTypes(getSchemes(Array.isArray(types) ? types : [types]));
60
60
  }
61
61
  function entityToWallet(w) {
62
+ var _a;
62
63
  return __spreadProps(__spreadValues({}, w), {
64
+ createdAt: typeof w.createdAt === "string" ? w.createdAt : w.createdAt.toISOString(),
65
+ lastUsedAt: typeof w.lastUsedAt === "string" ? w.lastUsedAt : (_a = w.lastUsedAt) == null ? void 0 : _a.toISOString(),
63
66
  scheme: w.scheme,
64
67
  type: w.type,
65
68
  pregenIdentifierType: w.pregenIdentifierType
@@ -1,12 +1,16 @@
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, BalancesConfig, Theme } 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, 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
+ popupWindow: Window | null;
7
8
  static version?: string;
8
9
  ctx: Ctx;
9
10
  protected isNativePasskey: boolean;
11
+ protected isPartnerOptional?: boolean;
12
+ protected setModalError(_error?: string): void;
13
+ isReady: boolean;
10
14
  get authInfo(): CoreAuthInfo | undefined;
11
15
  get email(): AuthIdentifier<'email'> | undefined;
12
16
  get phone(): AuthIdentifier<'phone'> | undefined;
@@ -14,18 +18,27 @@ export declare abstract class ParaCore implements CoreInterface {
14
18
  get telegramUserId(): AuthIdentifier<'telegram'> | undefined;
15
19
  get externalWalletWithParaAuth(): Wallet | undefined;
16
20
  get externalWalletConnectionType(): ExternalWalletConnectionType;
21
+ protected partner?: PartnerEntity;
17
22
  userId?: string;
23
+ accountLinkInProgress: AccountLinkInProgress | undefined;
18
24
  private sessionCookie?;
25
+ isEnclaveUser: boolean;
26
+ private enclaveJwt?;
27
+ private enclaveRefreshJwt?;
19
28
  private isAwaitingAccountCreation;
20
29
  private isAwaitingLogin;
21
30
  private isAwaitingFarcaster;
22
31
  private isAwaitingOAuth;
32
+ private isWorkerInitialized;
23
33
  get isEmail(): boolean;
24
34
  get isPhone(): boolean;
25
35
  get isFarcaster(): boolean;
26
36
  get isTelegram(): boolean;
27
37
  get isExternalWalletAuth(): boolean;
38
+ get isExternalWalletWithVerification(): boolean;
28
39
  get partnerId(): string | undefined;
40
+ protected get partnerName(): string | undefined;
41
+ protected get partnerLogo(): string | undefined;
29
42
  /**
30
43
  * 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
44
  */
@@ -111,7 +124,7 @@ export declare abstract class ParaCore implements CoreInterface {
111
124
  portalPrimaryButtonTextColor?: string;
112
125
  /**
113
126
  * Theme to use for the portal
114
- * @deprecated configure theming through the developer portal
127
+ * WARNING: This theme will override portal options set within the developer portal.
115
128
  */
116
129
  portalTheme?: Theme;
117
130
  /**
@@ -119,11 +132,17 @@ export declare abstract class ParaCore implements CoreInterface {
119
132
  */
120
133
  externalWalletConnectionOnly?: boolean;
121
134
  private disableProviderModal?;
135
+ private fetchPregenWalletsOverride?;
122
136
  get isNoWalletConfig(): boolean;
123
137
  get supportedWalletTypes(): SupportedWalletTypes;
124
138
  get cosmosPrefix(): string | undefined;
139
+ get supportedAccountLinks(): SupportedAccountLinks;
125
140
  get isWalletTypeEnabled(): Partial<Record<TWalletType, boolean>>;
126
- private platformUtils;
141
+ protected onRampPopup: {
142
+ window: Window;
143
+ onRampPurchase: OnRampPurchase;
144
+ } | undefined;
145
+ protected platformUtils: PlatformUtils;
127
146
  private localStorageGetItem;
128
147
  private localStorageSetItem;
129
148
  private localStorageRemoveItem;
@@ -132,14 +151,19 @@ export declare abstract class ParaCore implements CoreInterface {
132
151
  private sessionStorageRemoveItem;
133
152
  retrieveSessionCookie: () => string | undefined;
134
153
  persistSessionCookie: (cookie: string) => void;
154
+ retrieveEnclaveJwt: () => string;
155
+ persistEnclaveJwt: (jwt: string) => void;
156
+ retrieveEnclaveRefreshJwt: () => string;
157
+ persistEnclaveRefreshJwt: (jwt: string) => void;
135
158
  /**
136
159
  * Remove all local storage and prefixed session storage.
137
160
  * @param {'local' | 'session' | 'secure' | 'all'} type - Type of storage to clear. Defaults to 'all'.
138
161
  */
139
- clearStorage: (type?: CoreMethodParams<'clearStorage'>) => CoreMethodResponse<'clearStorage'>;
162
+ clearStorage: (type?: CoreMethodParams<"clearStorage">) => CoreMethodResponse<"clearStorage">;
140
163
  private convertBigInt;
141
164
  private convertEncryptionKeyPair;
142
- private isPortal;
165
+ protected isPortal(envOverride?: Environment): boolean;
166
+ protected isRecoveryPortal(envOverride?: Environment): boolean;
143
167
  private isParaConnect;
144
168
  private requireApiKey;
145
169
  private isWalletSupported;
@@ -171,25 +195,30 @@ export declare abstract class ParaCore implements CoreInterface {
171
195
  getWallets(): Record<string, Wallet>;
172
196
  getAddress(walletId?: string): string | undefined;
173
197
  protected abstract getPlatformUtils(): PlatformUtils;
198
+ abstract isPasskeySupported(): Promise<boolean>;
174
199
  protected constructPortalUrl(type: PortalUrlType, opts?: PortalUrlOptions): Promise<string>;
200
+ static resolveEnvironment(env: Environment | undefined, apiKey: string | undefined): Environment;
175
201
  /**
176
202
  * Constructs a new `ParaCore` instance.
177
- * @param env - `Environment` to use.
203
+ * @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
204
  * @param apiKey - API key to use.
179
205
  * @param opts - Additional constructor options; see `ConstructorOpts`.
180
206
  * @returns - A new ParaCore instance.
181
207
  */
182
- constructor(env: Environment, apiKey: string, opts?: ConstructorOpts);
208
+ constructor(env: Environment | undefined, apiKey: string, opts?: ConstructorOpts);
209
+ constructor(apiKey: string, opts?: ConstructorOpts);
183
210
  private trackError;
184
211
  private wrapMethodsWithErrorTracking;
185
212
  private initializeFromStorage;
186
213
  private updateAuthInfoFromStorage;
214
+ private updateEnclaveJwtFromStorage;
187
215
  private updateUserIdFromStorage;
188
216
  private updateWalletsFromStorage;
189
217
  private updateWalletIdsFromStorage;
190
218
  private updateSessionCookieFromStorage;
191
219
  private updateLoginEncryptionKeyPairFromStorage;
192
220
  private updateExternalWalletsFromStorage;
221
+ protected initializeWorker: () => Promise<void>;
193
222
  touchSession(regenerate?: boolean): Promise<SessionInfo>;
194
223
  private getVerificationEmailProps;
195
224
  private getBackupKitEmailProps;
@@ -199,11 +228,29 @@ export declare abstract class ParaCore implements CoreInterface {
199
228
  * Init only needs to be called for storage that is async.
200
229
  */
201
230
  init(): Promise<void>;
231
+ /**
232
+ * Call this method to perform initial setup for the `ParaCore` instance.
233
+ *
234
+ * This method will be called automatically if you use the React `ParaProvider` or when you call any methods that request an updated session.
235
+ */
236
+ abstract ready(): Promise<void>;
202
237
  protected setAuth(auth: PrimaryAuth, { extras, userId }?: {
203
238
  extras?: AuthExtras;
204
239
  userId?: string;
205
240
  }): Promise<typeof this.authInfo>;
206
- protected assertUserId(): string;
241
+ /**
242
+ * Display an error message in the modal (if available)
243
+ * @internal
244
+ */
245
+ protected displayModalError(error?: string): void;
246
+ /**
247
+ * Handle specific touchSession errors with user-friendly messages
248
+ * @private
249
+ */
250
+ private handleTouchSessionError;
251
+ protected assertUserId({ allowGuestMode }?: {
252
+ allowGuestMode?: boolean;
253
+ }): string;
207
254
  protected assertIsAuthSet(allowed?: AuthType[]): PrimaryAuthInfo;
208
255
  /**
209
256
  * Sets the email associated with the `ParaCore` instance.
@@ -231,7 +278,8 @@ export declare abstract class ParaCore implements CoreInterface {
231
278
  * @param externalAddress - External wallet address to set.
232
279
  * @param externalType - Type of external wallet to set.
233
280
  */
234
- setExternalWallet({ address, type, provider, addressBech32, withFullParaAuth }: ExternalWalletInfo): Promise<void>;
281
+ setExternalWallet(externalWallet: ExternalWalletInfo[] | ExternalWalletInfo): Promise<void>;
282
+ protected addExternalWallets(externalWallets: ExternalWalletInfo[]): Promise<void>;
235
283
  /**
236
284
  * Sets the user id associated with the `ParaCore` instance.
237
285
  * @param userId - User id to set.
@@ -244,9 +292,9 @@ export declare abstract class ParaCore implements CoreInterface {
244
292
  setWallets(wallets: Record<string, Wallet>): Promise<void>;
245
293
  /**
246
294
  * Sets the external wallets associated with the `ParaCore` instance.
247
- * @param externalWallets - External wallets to set.
295
+ * @param externalWallets - External wallets to set, or a function that modifies the current wallets.
248
296
  */
249
- setExternalWallets(externalWallets: Record<string, Wallet>): Promise<void>;
297
+ setExternalWallets(externalWallets: Record<string, Wallet> | ((current: Record<string, Wallet>) => Record<string, Wallet>)): Promise<void>;
250
298
  /**
251
299
  * Sets the login encryption key pair associated with the `ParaCore` instance.
252
300
  * @param keyPair - Encryption key pair generated from loginEncryptionKey.
@@ -282,6 +330,7 @@ export declare abstract class ParaCore implements CoreInterface {
282
330
  /**
283
331
  * Fetches the most recent OAuth account metadata for the signed-in user.
284
332
  * 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.
333
+ * @deprecated use `para.getLinkedAccounts({ withMetadata: true })` instead.
285
334
  * @returns {Promise<AccountMetadata>} the user's account metadata.
286
335
  */
287
336
  getAccountMetadata(): Promise<AccountMetadata>;
@@ -302,7 +351,7 @@ export declare abstract class ParaCore implements CoreInterface {
302
351
  */
303
352
  findWalletByAddress(address: string, filter?: WalletFilters | undefined): any;
304
353
  findWallet(idOrAddress?: string, overrideType?: TWalletType, filter?: WalletFilters): Omit<Wallet, 'signer'> | undefined;
305
- get availableWallets(): Pick<Wallet, 'id' | 'type' | 'name' | 'address' | 'isExternal'>[];
354
+ get availableWallets(): Pick<Wallet, 'id' | 'type' | 'name' | 'address' | 'isExternal' | 'externalProviderId' | 'isExternalConnectionOnly'>[];
306
355
  /**
307
356
  * Retrieves all usable wallets with the provided type (`'EVM' | 'COSMOS' | 'SOLANA'`)
308
357
  * @param {string} type the wallet type to filter by.
@@ -342,13 +391,15 @@ export declare abstract class ParaCore implements CoreInterface {
342
391
  */
343
392
  loginExternalWallet({ externalWallet, ...urlOptions }: CoreMethodParams<'loginExternalWallet'>): CoreMethodResponse<'loginExternalWallet'>;
344
393
  verifyExternalWallet({ externalWallet, signedMessage, cosmosPublicKeyHex, cosmosSigner, ...urlOptions }: CoreMethodParams<'verifyExternalWallet'>): CoreMethodResponse<'verifyExternalWallet'>;
345
- /**
346
- * Validates the response received from an attempted Telegram login for authenticity, then
347
- * creates or retrieves the corresponding Para user and prepares the Para instance to sign in with that user.
348
- * @param authResponse - the response JSON object received from the Telegram widget.
349
- * @returns `{ isValid: boolean; telegramUserId?: string; userId?: string; isNewUser?: boolean; supportedAuthMethods?: AuthMethod[]; biometricHints?: BiometricLocationHint[] }`
350
- */
351
- verifyTelegram({ telegramAuthResponse, ...urlOptions }: CoreMethodParams<'verifyTelegram'>): CoreMethodResponse<'verifyTelegram'>;
394
+ protected verifyExternalWalletLink(opts: InternalMethodParams<'verifyExternalWalletLink'>): InternalMethodResponse<'verifyExternalWalletLink'>;
395
+ protected verifyTelegramProcess(opts: CoreMethodParams<'verifyTelegram'> & {
396
+ isLinkAccount: false;
397
+ }): CoreMethodResponse<'verifyTelegram'>;
398
+ protected verifyTelegramProcess(opts: InternalMethodParams<'verifyTelegramLink'> & {
399
+ isLinkAccount: true;
400
+ }): InternalMethodResponse<'verifyTelegramLink'>;
401
+ verifyTelegram(opts: CoreMethodParams<'verifyTelegram'>): CoreMethodResponse<'verifyTelegram'>;
402
+ protected verifyTelegramLink(opts: InternalMethodParams<'verifyTelegramLink'>): InternalMethodResponse<'verifyTelegramLink'>;
352
403
  /**
353
404
  * Performs 2FA verification.
354
405
  * @param {Object} opts the options object
@@ -371,7 +422,7 @@ export declare abstract class ParaCore implements CoreInterface {
371
422
  /**
372
423
  * Resend a verification email for the current user.
373
424
  */
374
- resendVerificationCode(): CoreMethodResponse<'resendVerificationCode'>;
425
+ resendVerificationCode({ type: reason, }: CoreMethodParams<'resendVerificationCode'>): CoreMethodResponse<'resendVerificationCode'>;
375
426
  /**
376
427
  * Checks if the current session is active.
377
428
  * @returns `true` if active, `false` otherwise
@@ -383,6 +434,9 @@ export declare abstract class ParaCore implements CoreInterface {
383
434
  **/
384
435
  isFullyLoggedIn(): CoreMethodResponse<'isFullyLoggedIn'>;
385
436
  get isGuestMode(): boolean;
437
+ /**
438
+ * Get the auth methods available to an existing user
439
+ */
386
440
  protected supportedAuthMethods(auth: Auth<PrimaryAuthType | 'userId'>): Promise<Set<AuthMethod>>;
387
441
  /**
388
442
  * Get hints associated with the users stored biometrics.
@@ -396,35 +450,30 @@ export declare abstract class ParaCore implements CoreInterface {
396
450
  waitForSignup({ isCanceled, onCancel, onPoll, }: CoreMethodParams<'waitForSignup'>): CoreMethodResponse<'waitForSignup'>;
397
451
  waitForWalletCreation({ isCanceled, onCancel, }?: CoreMethodParams<'waitForWalletCreation'>): CoreMethodResponse<'waitForWalletCreation'>;
398
452
  /**
399
- * Initiates a Farcaster login attempt and return the URI for the user to connect.
453
+ * Initiates a Farcaster login attempt and returns the URL for the user to connect.
400
454
  * You can create a QR code with this URI that works with Farcaster's mobile app.
401
455
  * @return {string} the Farcaster connect URI
402
456
  */
403
- getFarcasterConnectUri(): CoreMethodResponse<'getFarcasterConnectUri'>;
404
- /**
405
- * Awaits the response from a user's attempt to log in with Farcaster.
406
- * If successful, this returns the user's Farcaster username and profile picture and indicates whether the user already exists.
407
- * @return {Object} `{userExists: boolean; username: string; pfpUrl?: string | null }` - the user's information and whether the user already exists.
408
- */
409
- verifyFarcaster({ isCanceled, onConnectUri, onCancel, onPoll, ...urlOptions }: CoreMethodParams<'verifyFarcaster'>): CoreMethodResponse<'verifyFarcaster'>;
410
- /**
411
- * Generates a URL for the user to log in with OAuth using a desire method.
412
- *
413
- * @param {Object} opts the options object
414
- * @param {TOAuthMethod} opts.method the third-party service to use for OAuth.
415
- * @param {string} [opts.deeplinkUrl] the deeplink to redirect to after the OAuth flow. This is for mobile only.
416
- * @returns {string} the URL for the user to log in with OAuth.
417
- */
418
- getOAuthUrl({ method, deeplinkUrl, ...params }: CoreMethodParams<'getOAuthUrl'>): CoreMethodResponse<'getOAuthUrl'>;
419
- /**
420
- * Awaits the response from a user's attempt to log in with OAuth.
421
- * If successful, this returns the user's email address and indicates whether the user already exists.
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'>;
457
+ getFarcasterConnectUri({ appScheme }?: {
458
+ appScheme?: string;
459
+ }): CoreMethodResponse<'getFarcasterConnectUri'>;
460
+ protected verifyFarcasterProcess(opts: CoreMethodParams<'verifyFarcaster'> & {
461
+ isLinkAccount: false;
462
+ }): CoreMethodResponse<'verifyFarcaster'>;
463
+ protected verifyFarcasterProcess(opts: InternalMethodParams<'verifyFarcasterLink'> & {
464
+ isLinkAccount: true;
465
+ }): InternalMethodResponse<'verifyFarcasterLink'>;
466
+ verifyFarcaster(opts: CoreMethodParams<'verifyFarcaster'>): CoreMethodResponse<'verifyFarcaster'>;
467
+ protected verifyFarcasterLink(opts: InternalMethodParams<'verifyFarcasterLink'>): InternalMethodResponse<'verifyFarcasterLink'>;
468
+ getOAuthUrl(opts: CoreMethodParams<'getOAuthUrl'>): CoreMethodResponse<'getOAuthUrl'>;
469
+ protected verifyOAuthProcess(_: InternalMethodParams<'verifyOAuthLink'> & {
470
+ isLinkAccount: true;
471
+ }): InternalMethodResponse<'verifyOAuthLink'>;
472
+ protected verifyOAuthProcess(_: CoreMethodParams<'verifyOAuth'> & {
473
+ isLinkAccount: false;
474
+ }): CoreMethodResponse<'verifyOAuth'>;
475
+ verifyOAuth(opts: CoreMethodParams<'verifyOAuth'>): CoreMethodResponse<'verifyOAuth'>;
476
+ protected verifyOAuthLink(opts: InternalMethodParams<'verifyOAuthLink'>): InternalMethodResponse<'verifyOAuthLink'>;
428
477
  /**
429
478
  * Waits for the session to be active and sets up the user.
430
479
  *
@@ -495,7 +544,7 @@ export declare abstract class ParaCore implements CoreInterface {
495
544
  *
496
545
  * @deprecated alias for `createWalletPerType`
497
546
  **/
498
- createWalletPerMissingType: ({ skipDistribute, types, }?: CoreMethodParams<'createWalletPerType'>) => CoreMethodResponse<'createWalletPerType'>;
547
+ createWalletPerMissingType: ({ skipDistribute, types, }?: CoreMethodParams<"createWalletPerType">) => CoreMethodResponse<"createWalletPerType">;
499
548
  /**
500
549
  * Creates several new wallets with the desired types. If no types are provided, this method
501
550
  * will create one for each of the non-optional types specified in the instance's `supportedWalletTypes`
@@ -587,7 +636,7 @@ export declare abstract class ParaCore implements CoreInterface {
587
636
  setUserShare(base64Wallets: CoreMethodParams<'setUserShare'>): CoreMethodResponse<'setUserShare'>;
588
637
  private getTransactionReviewUrl;
589
638
  private getOnRampTransactionUrl;
590
- getWalletBalance: ({ walletId, rpcUrl, }: CoreMethodParams<'getWalletBalance'>) => CoreMethodResponse<'getWalletBalance'>;
639
+ getWalletBalance: ({ walletId, rpcUrl, }: CoreMethodParams<"getWalletBalance">) => CoreMethodResponse<"getWalletBalance">;
591
640
  /**
592
641
  * Signs a message using one of the current wallets.
593
642
  *
@@ -640,6 +689,7 @@ export declare abstract class ParaCore implements CoreInterface {
640
689
  * @returns {Promise<string>} the ID
641
690
  **/
642
691
  getVerificationToken(): CoreMethodResponse<'getVerificationToken'>;
692
+ issueJwt({ keyIndex }?: CoreMethodParams<'issueJwt'>): CoreMethodResponse<'issueJwt'>;
643
693
  /**
644
694
  * Logs the user out.
645
695
  * @param {Object} opts the options object.
@@ -648,20 +698,20 @@ export declare abstract class ParaCore implements CoreInterface {
648
698
  logout({ clearPregenWallets }?: {
649
699
  clearPregenWallets?: boolean;
650
700
  }): Promise<void>;
651
- /** @deprecated */
652
- protected getSupportedCreateAuthMethods(): Promise<Set<AuthMethod>>;
701
+ protected get toStringAdditions(): Record<string, unknown>;
653
702
  /**
654
703
  * Converts to a string, removing sensitive data when logging this class.
655
704
  *
656
705
  * Doesn't work for all types of logging.
657
706
  **/
658
707
  toString(): string;
708
+ protected devLog(...s: string[]): void;
659
709
  protected getNewCredentialAndUrl({ authMethod, isForNewDevice, portalTheme, shorten, }?: NewCredentialUrlParams): Promise<{
660
710
  credentialId: string;
661
711
  url?: string;
662
712
  }>;
663
713
  /**
664
- * Returns a Para Portal URL for logging in with a WebAuth passkey or a password.
714
+ * Returns a Para Portal URL for logging in with a WebAuth passkey, password, PIN or OTP.
665
715
  * @param {Object} opts the options object
666
716
  * @param {String} opts.auth - the user auth to sign up or log in with, in the form ` { email: string } | { phone: `+${number}` } `
667
717
  * @param {boolean} opts.useShortUrls - whether to shorten the generated portal URLs
@@ -669,6 +719,19 @@ export declare abstract class ParaCore implements CoreInterface {
669
719
  * @returns {SignUpOrLogInResponse} an object in the form of either: `{ stage: 'verify' }` or `{ stage: 'login'; passkeyUrl?: string; passwordUrl?: string; biometricHints?: BiometricLocationHint[] }`
670
720
  */
671
721
  protected getLoginUrl({ authMethod, shorten, portalTheme, sessionId, }: LoginUrlParams): Promise<string>;
722
+ protected prepareLogin(): InternalMethodResponse<'prepareLogin'>;
672
723
  signUpOrLogIn({ auth, ...urlOptions }: CoreMethodParams<'signUpOrLogIn'>): CoreMethodResponse<'signUpOrLogIn'>;
673
724
  verifyNewAccount({ verificationCode, ...urlOptions }: CoreMethodParams<'verifyNewAccount'>): CoreMethodResponse<'verifyNewAccount'>;
725
+ getLinkedAccounts({ withMetadata, }?: CoreMethodParams<'getLinkedAccounts'>): CoreMethodResponse<'getLinkedAccounts'>;
726
+ protected linkAccount(opts: InternalMethodParams<'linkAccount'>): InternalMethodResponse<'linkAccount'>;
727
+ protected unlinkAccount({ linkedAccountId, }: InternalMethodParams<'unlinkAccount'>): InternalMethodResponse<'unlinkAccount'>;
728
+ protected verifyLink({ accountLinkInProgress, ...opts }?: {
729
+ accountLinkInProgress?: AccountLinkInProgress;
730
+ } & Partial<Pick<VerifyLinkParams, 'verificationCode' | 'telegramAuthResponse'> & VerifyExternalWalletParams>): Promise<LinkedAccounts>;
731
+ protected verifyEmailOrPhoneLink({ verificationCode, }: InternalMethodParams<'verifyEmailOrPhoneLink'>): InternalMethodResponse<'verifyEmailOrPhoneLink'>;
732
+ protected getProfileBalance({ config, refetch }?: {
733
+ config?: BalancesConfig;
734
+ refetch?: boolean;
735
+ }): Promise<import("@getpara/user-management-client").ProfileBalance>;
736
+ protected sendLoginCode(): Promise<void>;
674
737
  }
@@ -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,24 @@
1
1
  export declare const PARA_CORE_VERSION: string;
2
2
  export declare const PREFIX = "@CAPSULE/";
3
- export declare const LOCAL_STORAGE_AUTH_INFO: string;
4
- export declare const LOCAL_STORAGE_EMAIL: string;
5
- export declare const LOCAL_STORAGE_PHONE: string;
6
- export declare const LOCAL_STORAGE_COUNTRY_CODE: string;
7
- export declare const LOCAL_STORAGE_FARCASTER_USERNAME: string;
8
- export declare const LOCAL_STORAGE_TELEGRAM_USER_ID: string;
9
- export declare const LOCAL_STORAGE_EXTERNAL_WALLET_USER_ID: string;
10
- export declare const LOCAL_STORAGE_USER_ID: string;
11
- export declare const LOCAL_STORAGE_ED25519_WALLETS: string;
12
- export declare const LOCAL_STORAGE_WALLETS: string;
13
- export declare const LOCAL_STORAGE_EXTERNAL_WALLETS: string;
14
- export declare const LOCAL_STORAGE_CURRENT_WALLET_IDS: string;
15
- export declare const LOCAL_STORAGE_SESSION_COOKIE: string;
16
- export declare const SESSION_STORAGE_LOGIN_ENCRYPTION_KEY_PAIR: string;
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 LOCAL_STORAGE_ENCLAVE_JWT = "@CAPSULE/enclaveJwt";
18
+ export declare const LOCAL_STORAGE_ENCLAVE_REFRESH_JWT = "@CAPSULE/enclaveRefreshJwt";
19
+ export declare const SESSION_STORAGE_LOGIN_ENCRYPTION_KEY_PAIR = "@CAPSULE/loginEncryptionKeyPair";
17
20
  export declare const POLLING_INTERVAL_MS = 2000;
18
21
  export declare const SHORT_POLLING_INTERVAL_MS = 1000;
19
22
  export declare const POLLING_TIMEOUT_MS = 300000;
20
23
  export declare const EXTERNAL_WALLET_CONNECTION_ONLY_USER_ID = "EXTERNAL_WALLET_CONNECTION_ONLY";
24
+ export declare const ACCOUNT_LINK_CONFLICT = "Account already linked";
@@ -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, 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';
4
4
  export * from './types/coreApi.js';
5
5
  export * from './types/events.js';
6
6
  export * from './types/config.js';
7
- export { getPortalDomain, entityToWallet, constructUrl, shortenUrl } from './utils/index.js';
8
- export { PREFIX as STORAGE_PREFIX } from './constants.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';
9
9
  export { distributeNewShare } from './shares/shareDistribution.js';
10
10
  export { KeyContainer } from './shares/KeyContainer.js';
11
11
  export type { PlatformUtils } from './PlatformUtils.js';
@@ -18,9 +18,11 @@ export * from './errors.js';
18
18
  export * from './utils/formatting.js';
19
19
  export * from './utils/polling.js';
20
20
  export * from './utils/phone.js';
21
+ export * from './utils/config.js';
21
22
  export { isWalletSupported } from './utils/wallet.js';
22
23
  export { getNetworkPrefix, getOnRampAssets, getOnRampNetworks, toAssetInfoArray } from './utils/onRamps.js';
23
24
  export { getPortalBaseURL } from './utils/url.js';
24
25
  export { retrieve as transmissionUtilsRetrieve } from './transmission/transmissionUtils.js';
26
+ export type { ShareData } from './shares/enclave.js';
25
27
  export declare const paraVersion: string;
26
28
  export default ParaCore;
@@ -1,5 +1,3 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
1
  export declare class KeyContainer {
4
2
  walletId: string;
5
3
  keyshare: string;