@getpara/core-sdk 2.0.0-fc.3 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/dist/cjs/ParaCore.js +1119 -319
  2. package/dist/cjs/constants.js +10 -1
  3. package/dist/cjs/index.js +23 -3
  4. package/dist/cjs/shares/KeyContainer.js +3 -3
  5. package/dist/cjs/shares/enclave.js +287 -0
  6. package/dist/cjs/shares/shareDistribution.js +16 -1
  7. package/dist/cjs/transmission/transmissionUtils.js +4 -3
  8. package/dist/cjs/types/{theme.js → assets.js} +2 -2
  9. package/dist/cjs/types/coreApi.js +7 -2
  10. package/dist/cjs/types/events.js +2 -0
  11. package/dist/cjs/types/index.js +0 -21
  12. package/dist/cjs/types/popup.js +1 -0
  13. package/dist/cjs/utils/config.js +108 -0
  14. package/dist/cjs/utils/index.js +5 -1
  15. package/dist/cjs/utils/onRamps.js +2 -3
  16. package/dist/cjs/utils/url.js +10 -9
  17. package/dist/cjs/utils/wallet.js +18 -0
  18. package/dist/cjs/{types/onRamps.js → utils/window.js} +17 -12
  19. package/dist/esm/ParaCore.js +1123 -323
  20. package/dist/esm/constants.js +7 -1
  21. package/dist/esm/index.js +24 -5
  22. package/dist/esm/shares/KeyContainer.js +3 -3
  23. package/dist/esm/shares/enclave.js +247 -0
  24. package/dist/esm/shares/shareDistribution.js +16 -1
  25. package/dist/esm/transmission/transmissionUtils.js +4 -3
  26. package/dist/esm/types/coreApi.js +7 -2
  27. package/dist/esm/types/events.js +2 -0
  28. package/dist/esm/types/index.js +0 -16
  29. package/dist/esm/types/popup.js +1 -0
  30. package/dist/esm/utils/config.js +86 -0
  31. package/dist/esm/utils/index.js +2 -0
  32. package/dist/esm/utils/onRamps.js +2 -3
  33. package/dist/esm/utils/url.js +10 -9
  34. package/dist/esm/utils/wallet.js +17 -0
  35. package/dist/esm/utils/window.js +16 -0
  36. package/dist/types/ParaCore.d.ts +91 -20
  37. package/dist/types/PlatformUtils.d.ts +2 -1
  38. package/dist/types/constants.d.ts +3 -0
  39. package/dist/types/index.d.ts +6 -4
  40. package/dist/types/shares/enclave.d.ts +83 -0
  41. package/dist/types/shares/shareDistribution.d.ts +4 -2
  42. package/dist/types/types/assets.d.ts +14 -0
  43. package/dist/types/types/config.d.ts +3 -2
  44. package/dist/types/types/coreApi.d.ts +47 -7
  45. package/dist/types/types/events.d.ts +7 -2
  46. package/dist/types/types/index.d.ts +0 -4
  47. package/dist/types/types/methods.d.ts +57 -12
  48. package/dist/types/types/popup.d.ts +2 -1
  49. package/dist/types/types/wallet.d.ts +8 -4
  50. package/dist/types/utils/config.d.ts +7 -0
  51. package/dist/types/utils/index.d.ts +2 -0
  52. package/dist/types/utils/onRamps.d.ts +9 -10
  53. package/dist/types/utils/url.d.ts +3 -3
  54. package/dist/types/utils/wallet.d.ts +1 -0
  55. package/dist/types/utils/window.d.ts +2 -0
  56. package/package.json +3 -3
  57. package/dist/cjs/types/recovery.js +0 -34
  58. package/dist/esm/types/onRamps.js +0 -11
  59. package/dist/esm/types/recovery.js +0 -12
  60. package/dist/types/types/onRamps.d.ts +0 -10
  61. package/dist/types/types/recovery.d.ts +0 -7
  62. package/dist/types/types/theme.d.ts +0 -12
  63. /package/dist/esm/types/{theme.js → assets.js} +0 -0
@@ -3,31 +3,32 @@ import {
3
3
  } from "../chunk-7B52C2XE.js";
4
4
  import { upload } from "../transmission/transmissionUtils.js";
5
5
  import { Environment } from "../types/index.js";
6
- function getPortalDomain(env, isE2E) {
6
+ function getPortalDomain(env, isE2E, isLegacy) {
7
7
  if (isE2E) {
8
8
  return `localhost`;
9
9
  }
10
+ const domainRoot = isLegacy ? "usecapsule" : "getpara";
10
11
  switch (env) {
11
12
  case Environment.DEV:
12
13
  return "localhost";
13
14
  case Environment.SANDBOX:
14
- return "app.sandbox.usecapsule.com";
15
+ return `app.sandbox.${domainRoot}.com`;
15
16
  case Environment.BETA:
16
- return "app.beta.usecapsule.com";
17
+ return `app.beta.${domainRoot}.com`;
17
18
  case Environment.PROD:
18
- return "app.usecapsule.com";
19
+ return `app.${domainRoot}.com`;
19
20
  default:
20
21
  throw new Error(`env: ${env} not supported`);
21
22
  }
22
23
  }
23
- function getPortalBaseURL({ env, isE2E }, useLocalIp, isForWasm) {
24
+ function getPortalBaseURL({ env, isE2E }, useLocalIp, isForWasm, isLegacy) {
24
25
  if (isE2E) {
25
26
  if (isForWasm) {
26
- return `https://app.sandbox.usecapsule.com`;
27
+ return `https://app.sandbox.getpara.com`;
27
28
  }
28
29
  return `http://localhost:3003`;
29
30
  }
30
- const domain = getPortalDomain(env);
31
+ const domain = getPortalDomain(env, false, isLegacy);
31
32
  if (env === Environment.DEV) {
32
33
  if (useLocalIp) {
33
34
  return `http://127.0.0.1:3003`;
@@ -71,11 +72,11 @@ function constructUrl({
71
72
  });
72
73
  return url.toString();
73
74
  }
74
- function shortenUrl(ctx, url) {
75
+ function shortenUrl(ctx, url, isLegacy) {
75
76
  return __async(this, null, function* () {
76
77
  const compressedUrl = yield upload(url, ctx.client);
77
78
  return constructUrl({
78
- base: getPortalBaseURL(ctx),
79
+ base: getPortalBaseURL(ctx, false, false, isLegacy),
79
80
  path: `/short/${compressedUrl}`
80
81
  });
81
82
  });
@@ -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
@@ -88,8 +91,22 @@ function mergeCurrentWalletIds(original, additional) {
88
91
  function newUuid() {
89
92
  return uuid.v4();
90
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
+ }
91
107
  export {
92
108
  WalletSchemeTypeMap,
109
+ currentWalletIdsEq,
93
110
  entityToWallet,
94
111
  getEquivalentTypes,
95
112
  getSchemes,
@@ -0,0 +1,16 @@
1
+ import "../chunk-7B52C2XE.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("usecapsule", "getpara");
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
+ };
@@ -1,13 +1,16 @@
1
- import { AuthMethod, AuthExtras, CurrentWalletIds, EmailTheme, TWalletType, PregenIds, BiometricLocationHint, Auth, SupportedWalletTypes, AuthIdentifier, AuthType, ExternalWalletInfo, PrimaryAuthInfo, SessionInfo, PrimaryAuth, PrimaryAuthType, AccountMetadata, LinkedAccounts, VerifyLinkParams, VerifyExternalWalletParams, SupportedAccountLinks } from '@getpara/user-management-client';
1
+ import { AuthMethod, AuthExtras, CurrentWalletIds, EmailTheme, PartnerEntity, TWalletType, PregenIds, BiometricLocationHint, Auth, SupportedWalletTypes, AuthIdentifier, AuthType, ExternalWalletInfo, ServerAuthStateLogin, ServerAuthStateSignup, PrimaryAuthInfo, SessionInfo, PrimaryAuth, PrimaryAuthType, AccountMetadata, LinkedAccounts, VerifyLinkParams, VerifyExternalWalletParams, SupportedAccountLinks, OnRampPurchase, BalancesConfig, Theme, ServerAuthStateDone } 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, 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
+ popupWindow: Window | null;
7
8
  static version?: string;
8
9
  ctx: Ctx;
10
+ protected isSwitchingWallets: boolean;
9
11
  protected isNativePasskey: boolean;
10
12
  protected isPartnerOptional?: boolean;
13
+ protected setModalError(_error?: string): void;
11
14
  isReady: boolean;
12
15
  get authInfo(): CoreAuthInfo | undefined;
13
16
  get email(): AuthIdentifier<'email'> | undefined;
@@ -16,13 +19,18 @@ export declare abstract class ParaCore implements CoreInterface {
16
19
  get telegramUserId(): AuthIdentifier<'telegram'> | undefined;
17
20
  get externalWalletWithParaAuth(): Wallet | undefined;
18
21
  get externalWalletConnectionType(): ExternalWalletConnectionType;
22
+ protected partner?: PartnerEntity;
19
23
  userId?: string;
20
24
  accountLinkInProgress: AccountLinkInProgress | undefined;
21
25
  private sessionCookie?;
26
+ isEnclaveUser: boolean;
27
+ private enclaveJwt?;
28
+ private enclaveRefreshJwt?;
22
29
  private isAwaitingAccountCreation;
23
30
  private isAwaitingLogin;
24
31
  private isAwaitingFarcaster;
25
32
  private isAwaitingOAuth;
33
+ private isWorkerInitialized;
26
34
  get isEmail(): boolean;
27
35
  get isPhone(): boolean;
28
36
  get isFarcaster(): boolean;
@@ -30,6 +38,8 @@ export declare abstract class ParaCore implements CoreInterface {
30
38
  get isExternalWalletAuth(): boolean;
31
39
  get isExternalWalletWithVerification(): boolean;
32
40
  get partnerId(): string | undefined;
41
+ protected get partnerName(): string | undefined;
42
+ protected get partnerLogo(): string | undefined;
33
43
  /**
34
44
  * 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.
35
45
  */
@@ -115,7 +125,7 @@ export declare abstract class ParaCore implements CoreInterface {
115
125
  portalPrimaryButtonTextColor?: string;
116
126
  /**
117
127
  * Theme to use for the portal
118
- * @deprecated configure theming through the developer portal
128
+ * WARNING: This theme will override portal options set within the developer portal.
119
129
  */
120
130
  portalTheme?: Theme;
121
131
  /**
@@ -129,7 +139,12 @@ export declare abstract class ParaCore implements CoreInterface {
129
139
  get cosmosPrefix(): string | undefined;
130
140
  get supportedAccountLinks(): SupportedAccountLinks;
131
141
  get isWalletTypeEnabled(): Partial<Record<TWalletType, boolean>>;
132
- private platformUtils;
142
+ protected onRampPopup: {
143
+ window: Window;
144
+ onRampPurchase: OnRampPurchase;
145
+ } | undefined;
146
+ protected platformUtils: PlatformUtils;
147
+ protected nonPersistedStorageKeys: string[];
133
148
  private localStorageGetItem;
134
149
  private localStorageSetItem;
135
150
  private localStorageRemoveItem;
@@ -138,6 +153,10 @@ export declare abstract class ParaCore implements CoreInterface {
138
153
  private sessionStorageRemoveItem;
139
154
  retrieveSessionCookie: () => string | undefined;
140
155
  persistSessionCookie: (cookie: string) => void;
156
+ retrieveEnclaveJwt: () => string;
157
+ persistEnclaveJwt: (jwt: string) => void;
158
+ retrieveEnclaveRefreshJwt: () => string;
159
+ persistEnclaveRefreshJwt: (jwt: string) => void;
141
160
  /**
142
161
  * Remove all local storage and prefixed session storage.
143
162
  * @param {'local' | 'session' | 'secure' | 'all'} type - Type of storage to clear. Defaults to 'all'.
@@ -145,7 +164,7 @@ export declare abstract class ParaCore implements CoreInterface {
145
164
  clearStorage: (type?: CoreMethodParams<"clearStorage">) => CoreMethodResponse<"clearStorage">;
146
165
  private convertBigInt;
147
166
  private convertEncryptionKeyPair;
148
- private isPortal;
167
+ protected isPortal(envOverride?: Environment): boolean;
149
168
  private isParaConnect;
150
169
  private requireApiKey;
151
170
  private isWalletSupported;
@@ -153,6 +172,7 @@ export declare abstract class ParaCore implements CoreInterface {
153
172
  private isPregenWalletUnclaimed;
154
173
  private isPregenWalletClaimable;
155
174
  private isWalletUsable;
175
+ private truncateAddress;
156
176
  /**
157
177
  * Returns the formatted address for the desired wallet ID, depending on your app settings.
158
178
  * @param {string} walletId the ID of the wallet address to display.
@@ -179,24 +199,28 @@ export declare abstract class ParaCore implements CoreInterface {
179
199
  protected abstract getPlatformUtils(): PlatformUtils;
180
200
  abstract isPasskeySupported(): Promise<boolean>;
181
201
  protected constructPortalUrl(type: PortalUrlType, opts?: PortalUrlOptions): Promise<string>;
202
+ static resolveEnvironment(env: Environment | undefined, apiKey: string | undefined): Environment;
182
203
  /**
183
204
  * Constructs a new `ParaCore` instance.
184
- * @param env - `Environment` to use.
205
+ * @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.
185
206
  * @param apiKey - API key to use.
186
207
  * @param opts - Additional constructor options; see `ConstructorOpts`.
187
208
  * @returns - A new ParaCore instance.
188
209
  */
189
- constructor(env: Environment, apiKey: string, opts?: ConstructorOpts);
210
+ constructor(env: Environment | undefined, apiKey: string, opts?: ConstructorOpts);
211
+ constructor(apiKey: string, opts?: ConstructorOpts);
190
212
  private trackError;
191
213
  private wrapMethodsWithErrorTracking;
192
214
  private initializeFromStorage;
193
215
  private updateAuthInfoFromStorage;
216
+ private updateEnclaveJwtFromStorage;
194
217
  private updateUserIdFromStorage;
195
218
  private updateWalletsFromStorage;
196
219
  private updateWalletIdsFromStorage;
197
220
  private updateSessionCookieFromStorage;
198
221
  private updateLoginEncryptionKeyPairFromStorage;
199
222
  private updateExternalWalletsFromStorage;
223
+ protected initializeWorker: () => Promise<void>;
200
224
  touchSession(regenerate?: boolean): Promise<SessionInfo>;
201
225
  private getVerificationEmailProps;
202
226
  private getBackupKitEmailProps;
@@ -206,12 +230,29 @@ export declare abstract class ParaCore implements CoreInterface {
206
230
  * Init only needs to be called for storage that is async.
207
231
  */
208
232
  init(): Promise<void>;
209
- protected abstract ready(): Promise<void>;
233
+ /**
234
+ * Call this method to perform initial setup for the `ParaCore` instance.
235
+ *
236
+ * This method will be called automatically if you use the React `ParaProvider` or when you call any methods that request an updated session.
237
+ */
238
+ abstract ready(): Promise<void>;
210
239
  protected setAuth(auth: PrimaryAuth, { extras, userId }?: {
211
240
  extras?: AuthExtras;
212
241
  userId?: string;
213
242
  }): Promise<typeof this.authInfo>;
214
- protected assertUserId(): string;
243
+ /**
244
+ * Display an error message in the modal (if available)
245
+ * @internal
246
+ */
247
+ protected displayModalError(error?: string): void;
248
+ /**
249
+ * Handle specific touchSession errors with user-friendly messages
250
+ * @private
251
+ */
252
+ private handleTouchSessionError;
253
+ protected assertUserId({ allowGuestMode }?: {
254
+ allowGuestMode?: boolean;
255
+ }): string;
215
256
  protected assertIsAuthSet(allowed?: AuthType[]): PrimaryAuthInfo;
216
257
  /**
217
258
  * Sets the email associated with the `ParaCore` instance.
@@ -240,6 +281,7 @@ export declare abstract class ParaCore implements CoreInterface {
240
281
  * @param externalType - Type of external wallet to set.
241
282
  */
242
283
  setExternalWallet(externalWallet: ExternalWalletInfo[] | ExternalWalletInfo): Promise<void>;
284
+ protected addExternalWallets(externalWallets: ExternalWalletInfo[]): Promise<void>;
243
285
  /**
244
286
  * Sets the user id associated with the `ParaCore` instance.
245
287
  * @param userId - User id to set.
@@ -252,9 +294,9 @@ export declare abstract class ParaCore implements CoreInterface {
252
294
  setWallets(wallets: Record<string, Wallet>): Promise<void>;
253
295
  /**
254
296
  * Sets the external wallets associated with the `ParaCore` instance.
255
- * @param externalWallets - External wallets to set.
297
+ * @param externalWallets - External wallets to set, or a function that modifies the current wallets.
256
298
  */
257
- setExternalWallets(externalWallets: Record<string, Wallet>): Promise<void>;
299
+ setExternalWallets(externalWallets: Record<string, Wallet> | ((current: Record<string, Wallet>) => Record<string, Wallet>)): Promise<void>;
258
300
  /**
259
301
  * Sets the login encryption key pair associated with the `ParaCore` instance.
260
302
  * @param keyPair - Encryption key pair generated from loginEncryptionKey.
@@ -311,7 +353,7 @@ export declare abstract class ParaCore implements CoreInterface {
311
353
  */
312
354
  findWalletByAddress(address: string, filter?: WalletFilters | undefined): any;
313
355
  findWallet(idOrAddress?: string, overrideType?: TWalletType, filter?: WalletFilters): Omit<Wallet, 'signer'> | undefined;
314
- get availableWallets(): Pick<Wallet, 'id' | 'type' | 'name' | 'address' | 'isExternal' | 'externalProviderId' | 'isExternalConnectionOnly'>[];
356
+ get availableWallets(): AvailableWallet[];
315
357
  /**
316
358
  * Retrieves all usable wallets with the provided type (`'EVM' | 'COSMOS' | 'SOLANA'`)
317
359
  * @param {string} type the wallet type to filter by.
@@ -328,7 +370,7 @@ export declare abstract class ParaCore implements CoreInterface {
328
370
  * @param partnerId: string - id of the partner to get the portal URL for
329
371
  * @returns - portal URL
330
372
  */
331
- protected getPortalURL(): Promise<string>;
373
+ protected getPortalURL(isLegacy?: boolean): Promise<string>;
332
374
  /**
333
375
  * Gets the private key for the given wallet.
334
376
  * @param {string } [walletId] id of the wallet to get the private key for. Will default to the first wallet if not provided.
@@ -340,7 +382,7 @@ export declare abstract class ParaCore implements CoreInterface {
340
382
  * @returns {WalletEntity[]} wallets that were fetched.
341
383
  */
342
384
  fetchWallets(): CoreMethodResponse<'fetchWallets'>;
343
- private populateWalletAddresses;
385
+ protected populateWalletAddresses(): Promise<void>;
344
386
  private populatePregenWalletAddresses;
345
387
  /**
346
388
  * Logs in or creates a new user using an external wallet address.
@@ -349,8 +391,13 @@ export declare abstract class ParaCore implements CoreInterface {
349
391
  * @param {TWalletType} opts.type type of external wallet to use for identification.
350
392
  * @param {string} opts.provider the name of the provider for the external wallet.
351
393
  */
352
- loginExternalWallet({ externalWallet, ...urlOptions }: CoreMethodParams<'loginExternalWallet'>): CoreMethodResponse<'loginExternalWallet'>;
353
- verifyExternalWallet({ externalWallet, signedMessage, cosmosPublicKeyHex, cosmosSigner, ...urlOptions }: CoreMethodParams<'verifyExternalWallet'>): CoreMethodResponse<'verifyExternalWallet'>;
394
+ loginExternalWallet({ externalWallet, chainId, uri, ...urlOptions }: CoreMethodParams<'loginExternalWallet'>): CoreMethodResponse<'loginExternalWallet'>;
395
+ verifyExternalWallet(params: {
396
+ serverAuthState: ServerAuthStateSignup | ServerAuthStateLogin | ServerAuthStateDone;
397
+ } & Omit<CoreMethodParams<'verifyExternalWallet'>, keyof VerifyExternalWalletParams>): CoreMethodResponse<'verifyExternalWallet'>;
398
+ verifyExternalWallet(params: VerifyExternalWalletParams & {
399
+ serverAuthState?: undefined;
400
+ } & Omit<CoreMethodParams<'verifyExternalWallet'>, 'serverAuthState'>): CoreMethodResponse<'verifyExternalWallet'>;
354
401
  protected verifyExternalWalletLink(opts: InternalMethodParams<'verifyExternalWalletLink'>): InternalMethodResponse<'verifyExternalWalletLink'>;
355
402
  protected verifyTelegramProcess(opts: CoreMethodParams<'verifyTelegram'> & {
356
403
  isLinkAccount: false;
@@ -394,7 +441,15 @@ export declare abstract class ParaCore implements CoreInterface {
394
441
  **/
395
442
  isFullyLoggedIn(): CoreMethodResponse<'isFullyLoggedIn'>;
396
443
  get isGuestMode(): boolean;
444
+ /**
445
+ * Get the auth methods available to an existing user
446
+ * @deprecated Use supportedUserAuthMethods instead
447
+ */
397
448
  protected supportedAuthMethods(auth: Auth<PrimaryAuthType | 'userId'>): Promise<Set<AuthMethod>>;
449
+ /**
450
+ * Get the auth methods available to an existing user
451
+ */
452
+ protected supportedUserAuthMethods(): Promise<Set<AuthMethod>>;
398
453
  /**
399
454
  * Get hints associated with the users stored biometrics.
400
455
  * @deprecated
@@ -439,7 +494,15 @@ export declare abstract class ParaCore implements CoreInterface {
439
494
  * @param {boolean} [opts.skipSessionRefresh] whether to skip refreshing the session.
440
495
  * @returns {Object} `{ isComplete: boolean; isError: boolean; needsWallet: boolean; partnerId: string; }` the result data
441
496
  **/
442
- waitForLogin({ isCanceled, onCancel, onPoll, skipSessionRefresh, }?: CoreMethodParams<'waitForLogin'>): CoreMethodResponse<'waitForLogin'>;
497
+ waitForLogin(args: CoreMethodParams<'waitForLogin'>): CoreMethodResponse<'waitForLogin'>;
498
+ protected waitForWalletSwitching(args: CoreMethodParams<'waitForLogin'>): CoreMethodResponse<'waitForLogin'>;
499
+ /**
500
+ * Gets the switch wallets URL for wallet selection.
501
+ * The authMethod is automatically included in the URL if available.
502
+ *
503
+ * @returns {Promise<{ url: string; authMethod: TAuthMethod }>} The switch wallets URL and authMethod
504
+ */
505
+ protected getSwitchWalletsUrl(): Promise<string>;
443
506
  /**
444
507
  * Updates the session with the user management server, possibly
445
508
  * opening a popup to refresh the session.
@@ -662,13 +725,14 @@ export declare abstract class ParaCore implements CoreInterface {
662
725
  * Doesn't work for all types of logging.
663
726
  **/
664
727
  toString(): string;
665
- protected devLog(...s: string[]): void;
666
- protected getNewCredentialAndUrl({ authMethod, isForNewDevice, portalTheme, shorten, }?: NewCredentialUrlParams): Promise<{
728
+ protected devLog(...s: any[]): void;
729
+ protected getNewCredentialAndUrl({ authMethod: optsAuthMethod, isForNewDevice, portalTheme, shorten, }?: NewCredentialUrlParams): Promise<{
667
730
  credentialId: string;
668
731
  url?: string;
669
732
  }>;
733
+ addCredential({ authMethod }: Pick<NewCredentialUrlParams, 'authMethod'>): Promise<string>;
670
734
  /**
671
- * Returns a Para Portal URL for logging in with a WebAuth passkey or a password.
735
+ * Returns a Para Portal URL for logging in with a WebAuth passkey, password, PIN or OTP.
672
736
  * @param {Object} opts the options object
673
737
  * @param {String} opts.auth - the user auth to sign up or log in with, in the form ` { email: string } | { phone: `+${number}` } `
674
738
  * @param {boolean} opts.useShortUrls - whether to shorten the generated portal URLs
@@ -676,6 +740,7 @@ export declare abstract class ParaCore implements CoreInterface {
676
740
  * @returns {SignUpOrLogInResponse} an object in the form of either: `{ stage: 'verify' }` or `{ stage: 'login'; passkeyUrl?: string; passwordUrl?: string; biometricHints?: BiometricLocationHint[] }`
677
741
  */
678
742
  protected getLoginUrl({ authMethod, shorten, portalTheme, sessionId, }: LoginUrlParams): Promise<string>;
743
+ protected prepareLogin(): InternalMethodResponse<'prepareLogin'>;
679
744
  signUpOrLogIn({ auth, ...urlOptions }: CoreMethodParams<'signUpOrLogIn'>): CoreMethodResponse<'signUpOrLogIn'>;
680
745
  verifyNewAccount({ verificationCode, ...urlOptions }: CoreMethodParams<'verifyNewAccount'>): CoreMethodResponse<'verifyNewAccount'>;
681
746
  getLinkedAccounts({ withMetadata, }?: CoreMethodParams<'getLinkedAccounts'>): CoreMethodResponse<'getLinkedAccounts'>;
@@ -685,4 +750,10 @@ export declare abstract class ParaCore implements CoreInterface {
685
750
  accountLinkInProgress?: AccountLinkInProgress;
686
751
  } & Partial<Pick<VerifyLinkParams, 'verificationCode' | 'telegramAuthResponse'> & VerifyExternalWalletParams>): Promise<LinkedAccounts>;
687
752
  protected verifyEmailOrPhoneLink({ verificationCode, }: InternalMethodParams<'verifyEmailOrPhoneLink'>): InternalMethodResponse<'verifyEmailOrPhoneLink'>;
753
+ protected getProfileBalance({ config, refetch }?: {
754
+ config?: BalancesConfig;
755
+ refetch?: boolean;
756
+ }): Promise<import("@getpara/user-management-client").ProfileBalance>;
757
+ protected sendLoginCode(): Promise<void>;
758
+ exportPrivateKey(args?: CoreMethodParams<'exportPrivateKey'>): CoreMethodResponse<'exportPrivateKey'>;
688
759
  }
@@ -42,5 +42,6 @@ export interface PlatformUtils {
42
42
  disableProviderModal?: boolean;
43
43
  openPopup(popupUrl: string, opts?: {
44
44
  type: PopupType;
45
- }): Window;
45
+ }): Promise<Window>;
46
+ initializeWorker(ctx: Ctx): Promise<void>;
46
47
  }
@@ -1,5 +1,6 @@
1
1
  export declare const PARA_CORE_VERSION: string;
2
2
  export declare const PREFIX = "@CAPSULE/";
3
+ export declare const PARA_PREFIX = "@PARA/";
3
4
  export declare const LOCAL_STORAGE_AUTH_INFO = "@CAPSULE/authInfo";
4
5
  export declare const LOCAL_STORAGE_EMAIL = "@CAPSULE/e-mail";
5
6
  export declare const LOCAL_STORAGE_PHONE = "@CAPSULE/phone";
@@ -13,6 +14,8 @@ export declare const LOCAL_STORAGE_WALLETS = "@CAPSULE/wallets";
13
14
  export declare const LOCAL_STORAGE_EXTERNAL_WALLETS = "@CAPSULE/externalWallets";
14
15
  export declare const LOCAL_STORAGE_CURRENT_WALLET_IDS = "@CAPSULE/currentWalletIds";
15
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";
16
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;
@@ -1,11 +1,11 @@
1
1
  import { ParaCore } from './ParaCore.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';
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, type WalletWithMetadata, 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, formatAssetQuantity, formatCurrency, type EstimateTransactionOpts, type EstimateTransactionResult, type BroadcastTransactionOpts, type BroadcastTransactionResult, } 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, entityToWallet, constructUrl, shortenUrl } from './utils/index.js';
8
- export { PREFIX as 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';
@@ -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;
@@ -0,0 +1,83 @@
1
+ import UserManagementClient from '@getpara/user-management-client';
2
+ export interface ShareData {
3
+ userId: string;
4
+ walletId: string;
5
+ walletScheme: string;
6
+ partnerId?: string;
7
+ protocolId?: string;
8
+ signer: string;
9
+ createdAt?: string;
10
+ updatedAt?: string;
11
+ }
12
+ export interface ShareQuery {
13
+ userId: string;
14
+ walletId?: string;
15
+ partnerId?: string;
16
+ }
17
+ export interface EncryptedPayload {
18
+ encryptedData: string;
19
+ keyId: string;
20
+ algorithm: string;
21
+ ephemeral: string;
22
+ }
23
+ /**
24
+ * Enclave client for secure key share operations
25
+ * Handles encryption/decryption and communication with the enclave service
26
+ */
27
+ export declare class EnclaveClient {
28
+ private userManagementClient;
29
+ private enclavePublicKey;
30
+ private frontendKeyPair;
31
+ private retrieveJwt;
32
+ private persistJwt;
33
+ private retrieveRefreshJwt;
34
+ private persistRefreshJwt;
35
+ constructor({ userManagementClient, retrieveJwt, persistJwt, retrieveRefreshJwt, persistRefreshJwt, }: {
36
+ userManagementClient: UserManagementClient;
37
+ retrieveJwt: () => string;
38
+ persistJwt: (jwt: string) => void;
39
+ retrieveRefreshJwt: () => string;
40
+ persistRefreshJwt: (refreshJwt: string) => void;
41
+ });
42
+ private refreshJwt;
43
+ private withJwtRefreshRetry;
44
+ issueEnclaveJwt(): Promise<void>;
45
+ /**
46
+ * Generate a P-256 keypair for the frontend to receive encrypted responses
47
+ */
48
+ private generateFrontendKeyPair;
49
+ /**
50
+ * Get the enclave's public key from the user-management service
51
+ */
52
+ private getEnclavePublicKey;
53
+ /**
54
+ * Import a PEM-formatted public key for use with Web Crypto API
55
+ */
56
+ private importPublicKeyFromPEM;
57
+ /**
58
+ * Export a public key to PEM format
59
+ */
60
+ private exportPublicKeyToPEM;
61
+ /**
62
+ * Encrypt data using P-256 ECIES for the enclave
63
+ */
64
+ private encryptForEnclave;
65
+ /**
66
+ * Decrypt response encrypted for the frontend
67
+ */
68
+ private decryptForFrontend;
69
+ /**
70
+ * Persist key shares to the enclave
71
+ * @param shares Array of share data to persist
72
+ */
73
+ private persistShares;
74
+ /**
75
+ * Retrieve key shares from the enclave
76
+ * @param query Query parameters for finding shares (single query or array of queries)
77
+ */
78
+ private retrieveShares;
79
+ deleteShares(): Promise<void>;
80
+ retrieveSharesWithRetry(query: ShareQuery[]): Promise<ShareData[]>;
81
+ persistSharesWithRetry(shares: ShareData[]): Promise<any>;
82
+ deleteSharesWithRetry(): Promise<void>;
83
+ }
@@ -1,6 +1,6 @@
1
- import { BackupKitEmailProps } from '@getpara/user-management-client';
1
+ import { BackupKitEmailProps, TWalletScheme } from '@getpara/user-management-client';
2
2
  import { Ctx } from '../types/index.js';
3
- export declare function distributeNewShare({ ctx, userId, walletId, userShare, ignoreRedistributingBackupEncryptedShare, emailProps, partnerId, protocolId, }: {
3
+ export declare function distributeNewShare({ ctx, userId, walletId, userShare, ignoreRedistributingBackupEncryptedShare, emailProps, partnerId, protocolId, isEnclaveUser, walletScheme, }: {
4
4
  ctx: Ctx;
5
5
  userId: string;
6
6
  walletId: string;
@@ -9,4 +9,6 @@ export declare function distributeNewShare({ ctx, userId, walletId, userShare, i
9
9
  emailProps?: BackupKitEmailProps;
10
10
  partnerId?: string;
11
11
  protocolId?: string;
12
+ isEnclaveUser: boolean;
13
+ walletScheme: TWalletScheme;
12
14
  }): Promise<string>;
@@ -0,0 +1,14 @@
1
+ import { TNetwork, TOnRampAsset } from '@getpara/user-management-client';
2
+ import { Wallet } from './wallet.js';
3
+ export type AssetTransferType = 'INBOUND' | 'OUTBOUND';
4
+ export type AssetTransfer = {
5
+ wallet: Omit<Wallet, 'signer'>;
6
+ type: AssetTransferType;
7
+ sourceAddress: string;
8
+ destinationAddress: string;
9
+ asset: TOnRampAsset;
10
+ network: TNetwork;
11
+ quantity: string;
12
+ chainId?: string;
13
+ contractAddress?: string;
14
+ };
@@ -1,6 +1,6 @@
1
1
  import { AxiosInstance } from 'axios';
2
- import Client, { EmailTheme, Network, OnRampAsset, OnRampProvider, PregenAuth, TWalletScheme, TWalletType } from '@getpara/user-management-client';
3
- import { Theme } from './theme.js';
2
+ import Client, { EmailTheme, Network, OnRampAsset, OnRampProvider, PregenAuth, TWalletScheme, TWalletType, Theme } from '@getpara/user-management-client';
3
+ import { EnclaveClient } from '../shares/enclave.js';
4
4
  export declare enum Environment {
5
5
  DEV = "DEV",
6
6
  SANDBOX = "SANDBOX",
@@ -13,6 +13,7 @@ export interface Ctx {
13
13
  env: Environment;
14
14
  apiKey: string;
15
15
  client: Client;
16
+ enclaveClient?: EnclaveClient;
16
17
  disableWorkers?: boolean;
17
18
  offloadMPCComputationURL?: string;
18
19
  mpcComputationClient?: AxiosInstance;