@getpara/core-sdk 2.0.0-alpha.32 → 2.0.0-alpha.34

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.
@@ -99,7 +99,7 @@ var import_recovery = require("./shares/recovery.js");
99
99
  var import_utils2 = require("./utils/index.js");
100
100
  var import_errors = require("./errors.js");
101
101
  var constants = __toESM(require("./constants.js"));
102
- var _authInfo, _partner, _ParaCore_instances, assertPartner_fn, guestWalletIds_get, guestWalletIdsArray_get, toAuthInfo_fn, setAuthInfo_fn, getPartner_fn, assertIsLinkingAccount_fn, assertIsLinkingAccountOrStart_fn, getOAuthUrl_fn, createPregenWallet_fn, _isCreateGuestWalletsPending, prepareAuthState_fn, prepareLogin_fn, prepareLoginState_fn, prepareSignUpState_fn;
102
+ var _authInfo, _partner, _ParaCore_instances, assertPartner_fn, guestWalletIds_get, guestWalletIdsArray_get, toAuthInfo_fn, setAuthInfo_fn, getPartner_fn, assertIsLinkingAccount_fn, assertIsLinkingAccountOrStart_fn, getOAuthUrl_fn, createPregenWallet_fn, _isCreateGuestWalletsPending, prepareAuthState_fn, prepareLoginState_fn, prepareSignUpState_fn;
103
103
  if (typeof global !== "undefined") {
104
104
  global.Buffer = global.Buffer || import_buffer.Buffer;
105
105
  } else if (typeof window !== "undefined") {
@@ -129,6 +129,7 @@ const _ParaCore = class _ParaCore {
129
129
  this.isAwaitingLogin = false;
130
130
  this.isAwaitingFarcaster = false;
131
131
  this.isAwaitingOAuth = false;
132
+ this.isWorkerInitialized = false;
132
133
  /**
133
134
  * 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.
134
135
  */
@@ -137,6 +138,7 @@ const _ParaCore = class _ParaCore {
137
138
  * Wallets associated with the `ParaCore` instance.
138
139
  */
139
140
  this.externalWallets = {};
141
+ this.onRampPopup = void 0;
140
142
  this.localStorageGetItem = (key) => {
141
143
  return this.platformUtils.localStorage.get(key);
142
144
  };
@@ -288,6 +290,16 @@ const _ParaCore = class _ParaCore {
288
290
  const _externalWallets = JSON.parse(stringExternalWallets || "{}");
289
291
  this.setExternalWallets(_externalWallets);
290
292
  };
293
+ this.initializeWorker = () => __async(this, null, function* () {
294
+ if (!this.isWorkerInitialized && !this.ctx.disableWebSockets && !this.ctx.disableWorkers) {
295
+ try {
296
+ this.isWorkerInitialized = true;
297
+ yield this.platformUtils.initializeWorker(this.ctx);
298
+ } catch (e) {
299
+ this.devLog("error initializing worker:", e);
300
+ }
301
+ }
302
+ });
291
303
  /**
292
304
  * Creates several new wallets with the desired types. If no types are provided, this method
293
305
  * will create one for each of the non-optional types specified in the instance's `supportedWalletTypes`
@@ -710,7 +722,7 @@ const _ParaCore = class _ParaCore {
710
722
  break;
711
723
  }
712
724
  case "onRamp": {
713
- path = `/web/users/${this.userId}/on-ramp-transaction/${opts.pathId}`;
725
+ path = `/web/users/${this.userId}/on-ramp-transaction/v2/${opts.pathId}`;
714
726
  break;
715
727
  }
716
728
  case "telegramLogin": {
@@ -753,7 +765,7 @@ const _ParaCore = class _ParaCore {
753
765
  }, (0, import_user_management_client.isPhone)(this.authInfo.auth) ? (0, import_utils2.splitPhoneNumber)(this.authInfo.auth.phone) : this.authInfo.auth), {
754
766
  pfpUrl: this.authInfo.pfpUrl,
755
767
  displayName: this.authInfo.displayName
756
- }) : {}), isOnRamp ? { sessionId } : {}), isLogin ? __spreadProps(__spreadValues({
768
+ }) : {}), isOnRamp ? { origin: typeof window !== "undefined" ? window.location.origin : void 0, email: this.email } : {}), isLogin ? __spreadProps(__spreadValues({
757
769
  sessionId: thisDevice.sessionId,
758
770
  encryptionKey: thisDevice.encryptionKey
759
771
  }, opts.newDevice ? {
@@ -772,6 +784,9 @@ const _ParaCore = class _ParaCore {
772
784
  touchSession(regenerate = false) {
773
785
  return __async(this, null, function* () {
774
786
  var _a, _b, _c;
787
+ if (!this.isWorkerInitialized) {
788
+ this.initializeWorker();
789
+ }
775
790
  if (!this.isReady) {
776
791
  yield this.ready();
777
792
  }
@@ -935,11 +950,59 @@ const _ParaCore = class _ParaCore {
935
950
  */
936
951
  setExternalWallet(externalWallet) {
937
952
  return __async(this, null, function* () {
953
+ const { id: partnerId, supportedWalletTypes } = yield __privateMethod(this, _ParaCore_instances, assertPartner_fn).call(this);
938
954
  this.externalWallets = (Array.isArray(externalWallet) ? externalWallet : [externalWallet]).reduce(
955
+ (acc, {
956
+ partnerId: wPartnerId,
957
+ address,
958
+ type,
959
+ provider,
960
+ providerId,
961
+ addressBech32,
962
+ withFullParaAuth,
963
+ isConnectionOnly,
964
+ withVerification
965
+ }) => {
966
+ if (partnerId === wPartnerId && supportedWalletTypes.some(({ type: supportedType }) => supportedType === type)) {
967
+ return __spreadProps(__spreadValues({}, acc), {
968
+ [address]: {
969
+ id: address,
970
+ partnerId,
971
+ address: addressBech32 != null ? addressBech32 : address,
972
+ type,
973
+ name: provider,
974
+ isExternal: true,
975
+ isExternalWithParaAuth: withFullParaAuth,
976
+ externalProviderId: providerId,
977
+ signer: "",
978
+ isExternalConnectionOnly: isConnectionOnly,
979
+ isExternalWithVerification: withVerification
980
+ }
981
+ });
982
+ }
983
+ return acc;
984
+ },
985
+ {}
986
+ ), this.setExternalWallets(this.externalWallets);
987
+ (0, import_utils2.dispatchEvent)(import_types.ParaEvent.EXTERNAL_WALLET_CHANGE_EVENT, null);
988
+ });
989
+ }
990
+ addExternalWallets(externalWallets) {
991
+ return __async(this, null, function* () {
992
+ const { id: partnerId, supportedWalletTypes } = yield __privateMethod(this, _ParaCore_instances, assertPartner_fn).call(this);
993
+ this.externalWallets = __spreadValues(__spreadValues({}, Object.entries(this.externalWallets).reduce((acc, [address, wallet]) => {
994
+ if (partnerId === wallet.partnerId && supportedWalletTypes.some(({ type }) => type === wallet.type)) {
995
+ return __spreadProps(__spreadValues({}, acc), {
996
+ [address]: wallet
997
+ });
998
+ }
999
+ return acc;
1000
+ }, {})), externalWallets.reduce(
939
1001
  (acc, { address, type, provider, providerId, addressBech32, withFullParaAuth, isConnectionOnly, withVerification }) => {
940
1002
  return __spreadProps(__spreadValues({}, acc), {
941
1003
  [address]: {
942
1004
  id: address,
1005
+ partnerId,
943
1006
  address: addressBech32 != null ? addressBech32 : address,
944
1007
  type,
945
1008
  name: provider,
@@ -953,7 +1016,7 @@ const _ParaCore = class _ParaCore {
953
1016
  });
954
1017
  },
955
1018
  {}
956
- );
1019
+ ));
957
1020
  this.setExternalWallets(this.externalWallets);
958
1021
  (0, import_utils2.dispatchEvent)(import_types.ParaEvent.EXTERNAL_WALLET_CHANGE_EVENT, null);
959
1022
  });
@@ -1307,7 +1370,7 @@ const _ParaCore = class _ParaCore {
1307
1370
  ]);
1308
1371
  const externalWallets = Array.isArray(externalWallet) ? externalWallet : [externalWallet];
1309
1372
  if (this.externalWalletConnectionOnly || externalWallets.every((wallet) => wallet.isConnectionOnly)) {
1310
- yield this.setExternalWallet(
1373
+ yield this.addExternalWallets(
1311
1374
  externalWallets.map((wallet) => __spreadProps(__spreadValues({}, wallet), {
1312
1375
  withFullParaAuth: false
1313
1376
  }))
@@ -1717,9 +1780,14 @@ const _ParaCore = class _ParaCore {
1717
1780
  }
1718
1781
  getOAuthUrl(opts) {
1719
1782
  return __async(this, null, function* () {
1720
- return __privateMethod(this, _ParaCore_instances, getOAuthUrl_fn).call(this, opts);
1783
+ var _a;
1784
+ const sessionLookupId = (_a = opts.sessionLookupId) != null ? _a : yield this.prepareLogin();
1785
+ return __privateMethod(this, _ParaCore_instances, getOAuthUrl_fn).call(this, __spreadProps(__spreadValues({}, opts), { sessionLookupId }));
1721
1786
  });
1722
1787
  }
1788
+ getOAuthUrlSync(opts) {
1789
+ return __privateMethod(this, _ParaCore_instances, getOAuthUrl_fn).call(this, opts);
1790
+ }
1723
1791
  /**
1724
1792
  * Awaits the response from a user's attempt to log in with OAuth.
1725
1793
  * If successful, this returns the user's email address and indicates whether the user already exists.
@@ -1728,9 +1796,9 @@ const _ParaCore = class _ParaCore {
1728
1796
  * @param {Window} [opts.popupWindow] the popup window being used for login.
1729
1797
  * @return {Object} `{ email?: string; isError?: boolean; userExists: boolean; }` the result data
1730
1798
  */
1731
- verifyOAuthProcess(_k) {
1799
+ verifyOAuthProcess(_i) {
1732
1800
  return __async(this, null, function* () {
1733
- var _l = _k, {
1801
+ var _j = _i, {
1734
1802
  method,
1735
1803
  appScheme,
1736
1804
  isCanceled = () => false,
@@ -1738,7 +1806,7 @@ const _ParaCore = class _ParaCore {
1738
1806
  onPoll,
1739
1807
  onOAuthUrl,
1740
1808
  isLinkAccount
1741
- } = _l, urlOptions = __objRest(_l, [
1809
+ } = _j, urlOptions = __objRest(_j, [
1742
1810
  "method",
1743
1811
  "appScheme",
1744
1812
  "isCanceled",
@@ -1753,7 +1821,7 @@ const _ParaCore = class _ParaCore {
1753
1821
  accountLinkInProgress = yield __privateMethod(this, _ParaCore_instances, assertIsLinkingAccountOrStart_fn).call(this, method);
1754
1822
  sessionLookupId = (yield this.touchSession()).sessionLookupId;
1755
1823
  } else {
1756
- sessionLookupId = yield __privateMethod(this, _ParaCore_instances, prepareLogin_fn).call(this);
1824
+ sessionLookupId = yield this.prepareLogin();
1757
1825
  }
1758
1826
  const oAuthUrl = yield __privateMethod(this, _ParaCore_instances, getOAuthUrl_fn).call(this, { method, appScheme, sessionLookupId, accountLinkInProgress });
1759
1827
  onOAuthUrl(oAuthUrl);
@@ -1892,7 +1960,7 @@ const _ParaCore = class _ParaCore {
1892
1960
  sessionId
1893
1961
  });
1894
1962
  if (shouldOpenPopup) {
1895
- this.platformUtils.openPopup(link);
1963
+ yield this.platformUtils.openPopup(link);
1896
1964
  }
1897
1965
  return link;
1898
1966
  });
@@ -2436,25 +2504,12 @@ const _ParaCore = class _ParaCore {
2436
2504
  });
2437
2505
  });
2438
2506
  }
2439
- getOnRampTransactionUrl(_m) {
2440
- return __async(this, null, function* () {
2441
- var _n = _m, {
2442
- purchaseId,
2443
- providerKey
2444
- } = _n, walletParams = __objRest(_n, [
2445
- "purchaseId",
2446
- "providerKey"
2447
- ]);
2448
- const { sessionId } = yield this.touchSession();
2449
- const [key, identifier] = (0, import_user_management_client.extractWalletRef)(walletParams);
2507
+ getOnRampTransactionUrl(_0) {
2508
+ return __async(this, arguments, function* ({
2509
+ purchaseId
2510
+ }) {
2450
2511
  return this.constructPortalUrl("onRamp", {
2451
- pathId: purchaseId,
2452
- sessionId,
2453
- params: {
2454
- [key]: identifier,
2455
- providerKey,
2456
- currentWalletIds: JSON.stringify(this.currentWalletIds)
2457
- }
2512
+ pathId: purchaseId
2458
2513
  });
2459
2514
  });
2460
2515
  }
@@ -2488,7 +2543,7 @@ const _ParaCore = class _ParaCore {
2488
2543
  let signRes = yield this.signMessageInner({ wallet, signerId, messageBase64, cosmosSignDocBase64 });
2489
2544
  let timeStart = Date.now();
2490
2545
  if (signRes.pendingTransactionId) {
2491
- this.platformUtils.openPopup(
2546
+ yield this.platformUtils.openPopup(
2492
2547
  yield this.getTransactionReviewUrl(signRes.pendingTransactionId, timeoutMs),
2493
2548
  { type: cosmosSignDocBase64 ? import_types.PopupType.SIGN_TRANSACTION_REVIEW : import_types.PopupType.SIGN_MESSAGE_REVIEW }
2494
2549
  );
@@ -2600,7 +2655,7 @@ const _ParaCore = class _ParaCore {
2600
2655
  );
2601
2656
  let timeStart = Date.now();
2602
2657
  if (signRes.pendingTransactionId) {
2603
- this.platformUtils.openPopup(
2658
+ yield this.platformUtils.openPopup(
2604
2659
  yield this.getTransactionReviewUrl(signRes.pendingTransactionId, timeoutMs),
2605
2660
  { type: import_types.PopupType.SIGN_TRANSACTION_REVIEW }
2606
2661
  );
@@ -2676,7 +2731,8 @@ const _ParaCore = class _ParaCore {
2676
2731
  providerKey: onRampPurchase.providerKey
2677
2732
  }, walletParams));
2678
2733
  if (shouldOpenPopup) {
2679
- this.platformUtils.openPopup(portalUrl, { type: import_types.PopupType.ON_RAMP_TRANSACTION });
2734
+ const onRampWindow = yield this.platformUtils.openPopup(portalUrl, { type: import_types.PopupType.ON_RAMP_TRANSACTION });
2735
+ this.onRampPopup = { window: onRampWindow, onRampPurchase };
2680
2736
  }
2681
2737
  return { onRampPurchase, portalUrl };
2682
2738
  });
@@ -2927,9 +2983,19 @@ const _ParaCore = class _ParaCore {
2927
2983
  });
2928
2984
  });
2929
2985
  }
2930
- signUpOrLogIn(_o) {
2986
+ prepareLogin() {
2987
+ return __async(this, null, function* () {
2988
+ yield this.logout();
2989
+ const { sessionLookupId } = yield this.touchSession(true);
2990
+ if (!this.loginEncryptionKeyPair) {
2991
+ yield this.setLoginEncryptionKeyPair();
2992
+ }
2993
+ return sessionLookupId;
2994
+ });
2995
+ }
2996
+ signUpOrLogIn(_k) {
2931
2997
  return __async(this, null, function* () {
2932
- var _p = _o, { auth } = _p, urlOptions = __objRest(_p, ["auth"]);
2998
+ var _l = _k, { auth } = _l, urlOptions = __objRest(_l, ["auth"]);
2933
2999
  const serverAuthState = yield this.ctx.client.signUpOrLogIn(__spreadValues(__spreadValues({}, auth), this.getVerificationEmailProps()));
2934
3000
  const authInfo = serverAuthState.auth;
2935
3001
  if (this.fetchPregenWalletsOverride && (0, import_user_management_client.isPregenAuth)(authInfo)) {
@@ -2941,11 +3007,11 @@ const _ParaCore = class _ParaCore {
2941
3007
  return __privateMethod(this, _ParaCore_instances, prepareAuthState_fn).call(this, serverAuthState, urlOptions);
2942
3008
  });
2943
3009
  }
2944
- verifyNewAccount(_q) {
3010
+ verifyNewAccount(_m) {
2945
3011
  return __async(this, null, function* () {
2946
- var _r = _q, {
3012
+ var _n = _m, {
2947
3013
  verificationCode
2948
- } = _r, urlOptions = __objRest(_r, [
3014
+ } = _n, urlOptions = __objRest(_n, [
2949
3015
  "verificationCode"
2950
3016
  ]);
2951
3017
  this.assertIsAuthSet(["email", "phone"]);
@@ -3039,10 +3105,10 @@ const _ParaCore = class _ParaCore {
3039
3105
  });
3040
3106
  }
3041
3107
  verifyLink() {
3042
- return __async(this, arguments, function* (_s = {}) {
3043
- var _t = _s, {
3108
+ return __async(this, arguments, function* (_o = {}) {
3109
+ var _p = _o, {
3044
3110
  accountLinkInProgress = __privateMethod(this, _ParaCore_instances, assertIsLinkingAccount_fn).call(this)
3045
- } = _t, opts = __objRest(_t, [
3111
+ } = _p, opts = __objRest(_p, [
3046
3112
  "accountLinkInProgress"
3047
3113
  ]);
3048
3114
  try {
@@ -3179,30 +3245,30 @@ assertIsLinkingAccountOrStart_fn = function(type) {
3179
3245
  return yield this.linkAccount({ type });
3180
3246
  });
3181
3247
  };
3182
- getOAuthUrl_fn = function(_i) {
3183
- return __async(this, null, function* () {
3184
- var _j = _i, {
3185
- method,
3186
- appScheme,
3187
- accountLinkInProgress
3188
- } = _j, params = __objRest(_j, [
3189
- "method",
3190
- "appScheme",
3191
- "accountLinkInProgress"
3192
- ]);
3193
- var _a;
3194
- const sessionLookupId = (_a = params.sessionLookupId) != null ? _a : yield __privateMethod(this, _ParaCore_instances, prepareLogin_fn).call(this);
3195
- return (0, import_utils2.constructUrl)({
3196
- base: (0, import_userManagementClient.getBaseOAuthUrl)(this.ctx.env),
3197
- path: `/auth/${method}`,
3198
- params: __spreadValues({
3199
- apiKey: this.ctx.apiKey,
3200
- sessionLookupId,
3201
- appScheme
3202
- }, accountLinkInProgress ? {
3203
- linkedAccountId: this.accountLinkInProgress.id
3204
- } : {})
3205
- });
3248
+ /**
3249
+ * Generates a URL for the user to log in with OAuth using a desire method.
3250
+ *
3251
+ * @param {Object} opts the options object
3252
+ * @param {TOAuthMethod} opts.method the third-party service to use for OAuth.
3253
+ * @param {string} [opts.appScheme] the app scheme to redirect to after the OAuth flow. This is for mobile only.
3254
+ * @returns {string} the URL for the user to log in with OAuth.
3255
+ */
3256
+ getOAuthUrl_fn = function({
3257
+ method,
3258
+ appScheme,
3259
+ accountLinkInProgress,
3260
+ sessionLookupId
3261
+ }) {
3262
+ return (0, import_utils2.constructUrl)({
3263
+ base: (0, import_userManagementClient.getBaseOAuthUrl)(this.ctx.env),
3264
+ path: `/auth/${method}`,
3265
+ params: __spreadValues({
3266
+ apiKey: this.ctx.apiKey,
3267
+ sessionLookupId,
3268
+ appScheme
3269
+ }, accountLinkInProgress ? {
3270
+ linkedAccountId: this.accountLinkInProgress.id
3271
+ } : {})
3206
3272
  });
3207
3273
  };
3208
3274
  createPregenWallet_fn = function(opts) {
@@ -3256,7 +3322,7 @@ _isCreateGuestWalletsPending = new WeakMap();
3256
3322
  prepareAuthState_fn = function(_0) {
3257
3323
  return __async(this, arguments, function* (serverAuthState, opts = {}) {
3258
3324
  if (!opts.sessionLookupId && serverAuthState.stage === "login") {
3259
- opts.sessionLookupId = yield __privateMethod(this, _ParaCore_instances, prepareLogin_fn).call(this);
3325
+ opts.sessionLookupId = yield this.prepareLogin();
3260
3326
  }
3261
3327
  const { auth, externalWallet, userId, displayName, pfpUrl, username } = serverAuthState;
3262
3328
  const authInfo = __spreadValues(__spreadValues({}, (0, import_user_management_client.extractAuthInfo)(auth, { isRequired: true })), Object.fromEntries(
@@ -3298,16 +3364,6 @@ prepareAuthState_fn = function(_0) {
3298
3364
  return authState;
3299
3365
  });
3300
3366
  };
3301
- prepareLogin_fn = function() {
3302
- return __async(this, null, function* () {
3303
- yield this.logout();
3304
- const { sessionLookupId } = yield this.touchSession(true);
3305
- if (!this.loginEncryptionKeyPair) {
3306
- yield this.setLoginEncryptionKeyPair();
3307
- }
3308
- return sessionLookupId;
3309
- });
3310
- };
3311
3367
  prepareLoginState_fn = function(_0, _1) {
3312
3368
  return __async(this, arguments, function* (loginState, {
3313
3369
  useShortUrls: shorten = false,
@@ -40,7 +40,7 @@ __export(constants_exports, {
40
40
  SHORT_POLLING_INTERVAL_MS: () => SHORT_POLLING_INTERVAL_MS
41
41
  });
42
42
  module.exports = __toCommonJS(constants_exports);
43
- const PARA_CORE_VERSION = "2.0.0-alpha.32";
43
+ const PARA_CORE_VERSION = "2.0.0-alpha.34";
44
44
  const PREFIX = "@CAPSULE/";
45
45
  const LOCAL_STORAGE_AUTH_INFO = `${PREFIX}authInfo`;
46
46
  const LOCAL_STORAGE_EMAIL = `${PREFIX}e-mail`;
@@ -80,7 +80,8 @@ const PARA_INTERNAL_METHODS = [
80
80
  "verifyFarcasterLink",
81
81
  "verifyTelegramLink",
82
82
  "verifyExternalWalletLink",
83
- "accountLinkInProgress"
83
+ "accountLinkInProgress",
84
+ "prepareLogin"
84
85
  ];
85
86
  // Annotate the CommonJS export names for ESM import in node:
86
87
  0 && (module.exports = {
@@ -8,7 +8,7 @@ import {
8
8
  __spreadProps,
9
9
  __spreadValues
10
10
  } from "./chunk-7B52C2XE.js";
11
- var _authInfo, _partner, _ParaCore_instances, assertPartner_fn, guestWalletIds_get, guestWalletIdsArray_get, toAuthInfo_fn, setAuthInfo_fn, getPartner_fn, assertIsLinkingAccount_fn, assertIsLinkingAccountOrStart_fn, getOAuthUrl_fn, createPregenWallet_fn, _isCreateGuestWalletsPending, prepareAuthState_fn, prepareLogin_fn, prepareLoginState_fn, prepareSignUpState_fn;
11
+ var _authInfo, _partner, _ParaCore_instances, assertPartner_fn, guestWalletIds_get, guestWalletIdsArray_get, toAuthInfo_fn, setAuthInfo_fn, getPartner_fn, assertIsLinkingAccount_fn, assertIsLinkingAccountOrStart_fn, getOAuthUrl_fn, createPregenWallet_fn, _isCreateGuestWalletsPending, prepareAuthState_fn, prepareLoginState_fn, prepareSignUpState_fn;
12
12
  import { Buffer as NodeBuffer } from "buffer";
13
13
  if (typeof global !== "undefined") {
14
14
  global.Buffer = global.Buffer || NodeBuffer;
@@ -23,7 +23,6 @@ import {
23
23
  AuthMethod,
24
24
  PublicKeyStatus,
25
25
  PublicKeyType,
26
- extractWalletRef,
27
26
  PasswordStatus,
28
27
  extractAuthInfo,
29
28
  isEmail,
@@ -95,6 +94,7 @@ const _ParaCore = class _ParaCore {
95
94
  this.isAwaitingLogin = false;
96
95
  this.isAwaitingFarcaster = false;
97
96
  this.isAwaitingOAuth = false;
97
+ this.isWorkerInitialized = false;
98
98
  /**
99
99
  * 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.
100
100
  */
@@ -103,6 +103,7 @@ const _ParaCore = class _ParaCore {
103
103
  * Wallets associated with the `ParaCore` instance.
104
104
  */
105
105
  this.externalWallets = {};
106
+ this.onRampPopup = void 0;
106
107
  this.localStorageGetItem = (key) => {
107
108
  return this.platformUtils.localStorage.get(key);
108
109
  };
@@ -254,6 +255,16 @@ const _ParaCore = class _ParaCore {
254
255
  const _externalWallets = JSON.parse(stringExternalWallets || "{}");
255
256
  this.setExternalWallets(_externalWallets);
256
257
  };
258
+ this.initializeWorker = () => __async(this, null, function* () {
259
+ if (!this.isWorkerInitialized && !this.ctx.disableWebSockets && !this.ctx.disableWorkers) {
260
+ try {
261
+ this.isWorkerInitialized = true;
262
+ yield this.platformUtils.initializeWorker(this.ctx);
263
+ } catch (e) {
264
+ this.devLog("error initializing worker:", e);
265
+ }
266
+ }
267
+ });
257
268
  /**
258
269
  * Creates several new wallets with the desired types. If no types are provided, this method
259
270
  * will create one for each of the non-optional types specified in the instance's `supportedWalletTypes`
@@ -676,7 +687,7 @@ const _ParaCore = class _ParaCore {
676
687
  break;
677
688
  }
678
689
  case "onRamp": {
679
- path = `/web/users/${this.userId}/on-ramp-transaction/${opts.pathId}`;
690
+ path = `/web/users/${this.userId}/on-ramp-transaction/v2/${opts.pathId}`;
680
691
  break;
681
692
  }
682
693
  case "telegramLogin": {
@@ -719,7 +730,7 @@ const _ParaCore = class _ParaCore {
719
730
  }, isPhone(this.authInfo.auth) ? splitPhoneNumber(this.authInfo.auth.phone) : this.authInfo.auth), {
720
731
  pfpUrl: this.authInfo.pfpUrl,
721
732
  displayName: this.authInfo.displayName
722
- }) : {}), isOnRamp ? { sessionId } : {}), isLogin ? __spreadProps(__spreadValues({
733
+ }) : {}), isOnRamp ? { origin: typeof window !== "undefined" ? window.location.origin : void 0, email: this.email } : {}), isLogin ? __spreadProps(__spreadValues({
723
734
  sessionId: thisDevice.sessionId,
724
735
  encryptionKey: thisDevice.encryptionKey
725
736
  }, opts.newDevice ? {
@@ -738,6 +749,9 @@ const _ParaCore = class _ParaCore {
738
749
  touchSession(regenerate = false) {
739
750
  return __async(this, null, function* () {
740
751
  var _a, _b, _c;
752
+ if (!this.isWorkerInitialized) {
753
+ this.initializeWorker();
754
+ }
741
755
  if (!this.isReady) {
742
756
  yield this.ready();
743
757
  }
@@ -901,11 +915,59 @@ const _ParaCore = class _ParaCore {
901
915
  */
902
916
  setExternalWallet(externalWallet) {
903
917
  return __async(this, null, function* () {
918
+ const { id: partnerId, supportedWalletTypes } = yield __privateMethod(this, _ParaCore_instances, assertPartner_fn).call(this);
904
919
  this.externalWallets = (Array.isArray(externalWallet) ? externalWallet : [externalWallet]).reduce(
920
+ (acc, {
921
+ partnerId: wPartnerId,
922
+ address,
923
+ type,
924
+ provider,
925
+ providerId,
926
+ addressBech32,
927
+ withFullParaAuth,
928
+ isConnectionOnly,
929
+ withVerification
930
+ }) => {
931
+ if (partnerId === wPartnerId && supportedWalletTypes.some(({ type: supportedType }) => supportedType === type)) {
932
+ return __spreadProps(__spreadValues({}, acc), {
933
+ [address]: {
934
+ id: address,
935
+ partnerId,
936
+ address: addressBech32 != null ? addressBech32 : address,
937
+ type,
938
+ name: provider,
939
+ isExternal: true,
940
+ isExternalWithParaAuth: withFullParaAuth,
941
+ externalProviderId: providerId,
942
+ signer: "",
943
+ isExternalConnectionOnly: isConnectionOnly,
944
+ isExternalWithVerification: withVerification
945
+ }
946
+ });
947
+ }
948
+ return acc;
949
+ },
950
+ {}
951
+ ), this.setExternalWallets(this.externalWallets);
952
+ dispatchEvent(ParaEvent.EXTERNAL_WALLET_CHANGE_EVENT, null);
953
+ });
954
+ }
955
+ addExternalWallets(externalWallets) {
956
+ return __async(this, null, function* () {
957
+ const { id: partnerId, supportedWalletTypes } = yield __privateMethod(this, _ParaCore_instances, assertPartner_fn).call(this);
958
+ this.externalWallets = __spreadValues(__spreadValues({}, Object.entries(this.externalWallets).reduce((acc, [address, wallet]) => {
959
+ if (partnerId === wallet.partnerId && supportedWalletTypes.some(({ type }) => type === wallet.type)) {
960
+ return __spreadProps(__spreadValues({}, acc), {
961
+ [address]: wallet
962
+ });
963
+ }
964
+ return acc;
965
+ }, {})), externalWallets.reduce(
905
966
  (acc, { address, type, provider, providerId, addressBech32, withFullParaAuth, isConnectionOnly, withVerification }) => {
906
967
  return __spreadProps(__spreadValues({}, acc), {
907
968
  [address]: {
908
969
  id: address,
970
+ partnerId,
909
971
  address: addressBech32 != null ? addressBech32 : address,
910
972
  type,
911
973
  name: provider,
@@ -919,7 +981,7 @@ const _ParaCore = class _ParaCore {
919
981
  });
920
982
  },
921
983
  {}
922
- );
984
+ ));
923
985
  this.setExternalWallets(this.externalWallets);
924
986
  dispatchEvent(ParaEvent.EXTERNAL_WALLET_CHANGE_EVENT, null);
925
987
  });
@@ -1273,7 +1335,7 @@ const _ParaCore = class _ParaCore {
1273
1335
  ]);
1274
1336
  const externalWallets = Array.isArray(externalWallet) ? externalWallet : [externalWallet];
1275
1337
  if (this.externalWalletConnectionOnly || externalWallets.every((wallet) => wallet.isConnectionOnly)) {
1276
- yield this.setExternalWallet(
1338
+ yield this.addExternalWallets(
1277
1339
  externalWallets.map((wallet) => __spreadProps(__spreadValues({}, wallet), {
1278
1340
  withFullParaAuth: false
1279
1341
  }))
@@ -1683,9 +1745,14 @@ const _ParaCore = class _ParaCore {
1683
1745
  }
1684
1746
  getOAuthUrl(opts) {
1685
1747
  return __async(this, null, function* () {
1686
- return __privateMethod(this, _ParaCore_instances, getOAuthUrl_fn).call(this, opts);
1748
+ var _a;
1749
+ const sessionLookupId = (_a = opts.sessionLookupId) != null ? _a : yield this.prepareLogin();
1750
+ return __privateMethod(this, _ParaCore_instances, getOAuthUrl_fn).call(this, __spreadProps(__spreadValues({}, opts), { sessionLookupId }));
1687
1751
  });
1688
1752
  }
1753
+ getOAuthUrlSync(opts) {
1754
+ return __privateMethod(this, _ParaCore_instances, getOAuthUrl_fn).call(this, opts);
1755
+ }
1689
1756
  /**
1690
1757
  * Awaits the response from a user's attempt to log in with OAuth.
1691
1758
  * If successful, this returns the user's email address and indicates whether the user already exists.
@@ -1694,9 +1761,9 @@ const _ParaCore = class _ParaCore {
1694
1761
  * @param {Window} [opts.popupWindow] the popup window being used for login.
1695
1762
  * @return {Object} `{ email?: string; isError?: boolean; userExists: boolean; }` the result data
1696
1763
  */
1697
- verifyOAuthProcess(_k) {
1764
+ verifyOAuthProcess(_i) {
1698
1765
  return __async(this, null, function* () {
1699
- var _l = _k, {
1766
+ var _j = _i, {
1700
1767
  method,
1701
1768
  appScheme,
1702
1769
  isCanceled = () => false,
@@ -1704,7 +1771,7 @@ const _ParaCore = class _ParaCore {
1704
1771
  onPoll,
1705
1772
  onOAuthUrl,
1706
1773
  isLinkAccount
1707
- } = _l, urlOptions = __objRest(_l, [
1774
+ } = _j, urlOptions = __objRest(_j, [
1708
1775
  "method",
1709
1776
  "appScheme",
1710
1777
  "isCanceled",
@@ -1719,7 +1786,7 @@ const _ParaCore = class _ParaCore {
1719
1786
  accountLinkInProgress = yield __privateMethod(this, _ParaCore_instances, assertIsLinkingAccountOrStart_fn).call(this, method);
1720
1787
  sessionLookupId = (yield this.touchSession()).sessionLookupId;
1721
1788
  } else {
1722
- sessionLookupId = yield __privateMethod(this, _ParaCore_instances, prepareLogin_fn).call(this);
1789
+ sessionLookupId = yield this.prepareLogin();
1723
1790
  }
1724
1791
  const oAuthUrl = yield __privateMethod(this, _ParaCore_instances, getOAuthUrl_fn).call(this, { method, appScheme, sessionLookupId, accountLinkInProgress });
1725
1792
  onOAuthUrl(oAuthUrl);
@@ -1858,7 +1925,7 @@ const _ParaCore = class _ParaCore {
1858
1925
  sessionId
1859
1926
  });
1860
1927
  if (shouldOpenPopup) {
1861
- this.platformUtils.openPopup(link);
1928
+ yield this.platformUtils.openPopup(link);
1862
1929
  }
1863
1930
  return link;
1864
1931
  });
@@ -2402,25 +2469,12 @@ const _ParaCore = class _ParaCore {
2402
2469
  });
2403
2470
  });
2404
2471
  }
2405
- getOnRampTransactionUrl(_m) {
2406
- return __async(this, null, function* () {
2407
- var _n = _m, {
2408
- purchaseId,
2409
- providerKey
2410
- } = _n, walletParams = __objRest(_n, [
2411
- "purchaseId",
2412
- "providerKey"
2413
- ]);
2414
- const { sessionId } = yield this.touchSession();
2415
- const [key, identifier] = extractWalletRef(walletParams);
2472
+ getOnRampTransactionUrl(_0) {
2473
+ return __async(this, arguments, function* ({
2474
+ purchaseId
2475
+ }) {
2416
2476
  return this.constructPortalUrl("onRamp", {
2417
- pathId: purchaseId,
2418
- sessionId,
2419
- params: {
2420
- [key]: identifier,
2421
- providerKey,
2422
- currentWalletIds: JSON.stringify(this.currentWalletIds)
2423
- }
2477
+ pathId: purchaseId
2424
2478
  });
2425
2479
  });
2426
2480
  }
@@ -2454,7 +2508,7 @@ const _ParaCore = class _ParaCore {
2454
2508
  let signRes = yield this.signMessageInner({ wallet, signerId, messageBase64, cosmosSignDocBase64 });
2455
2509
  let timeStart = Date.now();
2456
2510
  if (signRes.pendingTransactionId) {
2457
- this.platformUtils.openPopup(
2511
+ yield this.platformUtils.openPopup(
2458
2512
  yield this.getTransactionReviewUrl(signRes.pendingTransactionId, timeoutMs),
2459
2513
  { type: cosmosSignDocBase64 ? PopupType.SIGN_TRANSACTION_REVIEW : PopupType.SIGN_MESSAGE_REVIEW }
2460
2514
  );
@@ -2566,7 +2620,7 @@ const _ParaCore = class _ParaCore {
2566
2620
  );
2567
2621
  let timeStart = Date.now();
2568
2622
  if (signRes.pendingTransactionId) {
2569
- this.platformUtils.openPopup(
2623
+ yield this.platformUtils.openPopup(
2570
2624
  yield this.getTransactionReviewUrl(signRes.pendingTransactionId, timeoutMs),
2571
2625
  { type: PopupType.SIGN_TRANSACTION_REVIEW }
2572
2626
  );
@@ -2642,7 +2696,8 @@ const _ParaCore = class _ParaCore {
2642
2696
  providerKey: onRampPurchase.providerKey
2643
2697
  }, walletParams));
2644
2698
  if (shouldOpenPopup) {
2645
- this.platformUtils.openPopup(portalUrl, { type: PopupType.ON_RAMP_TRANSACTION });
2699
+ const onRampWindow = yield this.platformUtils.openPopup(portalUrl, { type: PopupType.ON_RAMP_TRANSACTION });
2700
+ this.onRampPopup = { window: onRampWindow, onRampPurchase };
2646
2701
  }
2647
2702
  return { onRampPurchase, portalUrl };
2648
2703
  });
@@ -2893,9 +2948,19 @@ const _ParaCore = class _ParaCore {
2893
2948
  });
2894
2949
  });
2895
2950
  }
2896
- signUpOrLogIn(_o) {
2951
+ prepareLogin() {
2952
+ return __async(this, null, function* () {
2953
+ yield this.logout();
2954
+ const { sessionLookupId } = yield this.touchSession(true);
2955
+ if (!this.loginEncryptionKeyPair) {
2956
+ yield this.setLoginEncryptionKeyPair();
2957
+ }
2958
+ return sessionLookupId;
2959
+ });
2960
+ }
2961
+ signUpOrLogIn(_k) {
2897
2962
  return __async(this, null, function* () {
2898
- var _p = _o, { auth } = _p, urlOptions = __objRest(_p, ["auth"]);
2963
+ var _l = _k, { auth } = _l, urlOptions = __objRest(_l, ["auth"]);
2899
2964
  const serverAuthState = yield this.ctx.client.signUpOrLogIn(__spreadValues(__spreadValues({}, auth), this.getVerificationEmailProps()));
2900
2965
  const authInfo = serverAuthState.auth;
2901
2966
  if (this.fetchPregenWalletsOverride && isPregenAuth(authInfo)) {
@@ -2907,11 +2972,11 @@ const _ParaCore = class _ParaCore {
2907
2972
  return __privateMethod(this, _ParaCore_instances, prepareAuthState_fn).call(this, serverAuthState, urlOptions);
2908
2973
  });
2909
2974
  }
2910
- verifyNewAccount(_q) {
2975
+ verifyNewAccount(_m) {
2911
2976
  return __async(this, null, function* () {
2912
- var _r = _q, {
2977
+ var _n = _m, {
2913
2978
  verificationCode
2914
- } = _r, urlOptions = __objRest(_r, [
2979
+ } = _n, urlOptions = __objRest(_n, [
2915
2980
  "verificationCode"
2916
2981
  ]);
2917
2982
  this.assertIsAuthSet(["email", "phone"]);
@@ -3005,10 +3070,10 @@ const _ParaCore = class _ParaCore {
3005
3070
  });
3006
3071
  }
3007
3072
  verifyLink() {
3008
- return __async(this, arguments, function* (_s = {}) {
3009
- var _t = _s, {
3073
+ return __async(this, arguments, function* (_o = {}) {
3074
+ var _p = _o, {
3010
3075
  accountLinkInProgress = __privateMethod(this, _ParaCore_instances, assertIsLinkingAccount_fn).call(this)
3011
- } = _t, opts = __objRest(_t, [
3076
+ } = _p, opts = __objRest(_p, [
3012
3077
  "accountLinkInProgress"
3013
3078
  ]);
3014
3079
  try {
@@ -3145,30 +3210,30 @@ assertIsLinkingAccountOrStart_fn = function(type) {
3145
3210
  return yield this.linkAccount({ type });
3146
3211
  });
3147
3212
  };
3148
- getOAuthUrl_fn = function(_i) {
3149
- return __async(this, null, function* () {
3150
- var _j = _i, {
3151
- method,
3152
- appScheme,
3153
- accountLinkInProgress
3154
- } = _j, params = __objRest(_j, [
3155
- "method",
3156
- "appScheme",
3157
- "accountLinkInProgress"
3158
- ]);
3159
- var _a;
3160
- const sessionLookupId = (_a = params.sessionLookupId) != null ? _a : yield __privateMethod(this, _ParaCore_instances, prepareLogin_fn).call(this);
3161
- return constructUrl({
3162
- base: getBaseOAuthUrl(this.ctx.env),
3163
- path: `/auth/${method}`,
3164
- params: __spreadValues({
3165
- apiKey: this.ctx.apiKey,
3166
- sessionLookupId,
3167
- appScheme
3168
- }, accountLinkInProgress ? {
3169
- linkedAccountId: this.accountLinkInProgress.id
3170
- } : {})
3171
- });
3213
+ /**
3214
+ * Generates a URL for the user to log in with OAuth using a desire method.
3215
+ *
3216
+ * @param {Object} opts the options object
3217
+ * @param {TOAuthMethod} opts.method the third-party service to use for OAuth.
3218
+ * @param {string} [opts.appScheme] the app scheme to redirect to after the OAuth flow. This is for mobile only.
3219
+ * @returns {string} the URL for the user to log in with OAuth.
3220
+ */
3221
+ getOAuthUrl_fn = function({
3222
+ method,
3223
+ appScheme,
3224
+ accountLinkInProgress,
3225
+ sessionLookupId
3226
+ }) {
3227
+ return constructUrl({
3228
+ base: getBaseOAuthUrl(this.ctx.env),
3229
+ path: `/auth/${method}`,
3230
+ params: __spreadValues({
3231
+ apiKey: this.ctx.apiKey,
3232
+ sessionLookupId,
3233
+ appScheme
3234
+ }, accountLinkInProgress ? {
3235
+ linkedAccountId: this.accountLinkInProgress.id
3236
+ } : {})
3172
3237
  });
3173
3238
  };
3174
3239
  createPregenWallet_fn = function(opts) {
@@ -3222,7 +3287,7 @@ _isCreateGuestWalletsPending = new WeakMap();
3222
3287
  prepareAuthState_fn = function(_0) {
3223
3288
  return __async(this, arguments, function* (serverAuthState, opts = {}) {
3224
3289
  if (!opts.sessionLookupId && serverAuthState.stage === "login") {
3225
- opts.sessionLookupId = yield __privateMethod(this, _ParaCore_instances, prepareLogin_fn).call(this);
3290
+ opts.sessionLookupId = yield this.prepareLogin();
3226
3291
  }
3227
3292
  const { auth, externalWallet, userId, displayName, pfpUrl, username } = serverAuthState;
3228
3293
  const authInfo = __spreadValues(__spreadValues({}, extractAuthInfo(auth, { isRequired: true })), Object.fromEntries(
@@ -3264,16 +3329,6 @@ prepareAuthState_fn = function(_0) {
3264
3329
  return authState;
3265
3330
  });
3266
3331
  };
3267
- prepareLogin_fn = function() {
3268
- return __async(this, null, function* () {
3269
- yield this.logout();
3270
- const { sessionLookupId } = yield this.touchSession(true);
3271
- if (!this.loginEncryptionKeyPair) {
3272
- yield this.setLoginEncryptionKeyPair();
3273
- }
3274
- return sessionLookupId;
3275
- });
3276
- };
3277
3332
  prepareLoginState_fn = function(_0, _1) {
3278
3333
  return __async(this, arguments, function* (loginState, {
3279
3334
  useShortUrls: shorten = false,
@@ -1,5 +1,5 @@
1
1
  import "./chunk-7B52C2XE.js";
2
- const PARA_CORE_VERSION = "2.0.0-alpha.32";
2
+ const PARA_CORE_VERSION = "2.0.0-alpha.34";
3
3
  const PREFIX = "@CAPSULE/";
4
4
  const LOCAL_STORAGE_AUTH_INFO = `${PREFIX}authInfo`;
5
5
  const LOCAL_STORAGE_EMAIL = `${PREFIX}e-mail`;
@@ -58,7 +58,8 @@ const PARA_INTERNAL_METHODS = [
58
58
  "verifyFarcasterLink",
59
59
  "verifyTelegramLink",
60
60
  "verifyExternalWalletLink",
61
- "accountLinkInProgress"
61
+ "accountLinkInProgress",
62
+ "prepareLogin"
62
63
  ];
63
64
  export {
64
65
  PARA_CORE_METHODS,
@@ -1,4 +1,4 @@
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, 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
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';
@@ -23,6 +23,7 @@ export declare abstract class ParaCore implements CoreInterface {
23
23
  private isAwaitingLogin;
24
24
  private isAwaitingFarcaster;
25
25
  private isAwaitingOAuth;
26
+ private isWorkerInitialized;
26
27
  get isEmail(): boolean;
27
28
  get isPhone(): boolean;
28
29
  get isFarcaster(): boolean;
@@ -129,7 +130,11 @@ export declare abstract class ParaCore implements CoreInterface {
129
130
  get cosmosPrefix(): string | undefined;
130
131
  get supportedAccountLinks(): SupportedAccountLinks;
131
132
  get isWalletTypeEnabled(): Partial<Record<TWalletType, boolean>>;
132
- private platformUtils;
133
+ protected onRampPopup: {
134
+ window: Window;
135
+ onRampPurchase: OnRampPurchase;
136
+ } | undefined;
137
+ protected platformUtils: PlatformUtils;
133
138
  private localStorageGetItem;
134
139
  private localStorageSetItem;
135
140
  private localStorageRemoveItem;
@@ -145,7 +150,7 @@ export declare abstract class ParaCore implements CoreInterface {
145
150
  clearStorage: (type?: CoreMethodParams<"clearStorage">) => CoreMethodResponse<"clearStorage">;
146
151
  private convertBigInt;
147
152
  private convertEncryptionKeyPair;
148
- private isPortal;
153
+ protected isPortal(envOverride?: Environment): boolean;
149
154
  private isParaConnect;
150
155
  private requireApiKey;
151
156
  private isWalletSupported;
@@ -197,6 +202,7 @@ export declare abstract class ParaCore implements CoreInterface {
197
202
  private updateSessionCookieFromStorage;
198
203
  private updateLoginEncryptionKeyPairFromStorage;
199
204
  private updateExternalWalletsFromStorage;
205
+ protected initializeWorker: () => Promise<void>;
200
206
  touchSession(regenerate?: boolean): Promise<SessionInfo>;
201
207
  private getVerificationEmailProps;
202
208
  private getBackupKitEmailProps;
@@ -206,7 +212,12 @@ export declare abstract class ParaCore implements CoreInterface {
206
212
  * Init only needs to be called for storage that is async.
207
213
  */
208
214
  init(): Promise<void>;
209
- protected abstract ready(): Promise<void>;
215
+ /**
216
+ * Call this method to perform initial setup for the `ParaCore` instance.
217
+ *
218
+ * This method will be called automatically if you use the React `ParaProvider` or when you call any methods that request an updated session.
219
+ */
220
+ abstract ready(): Promise<void>;
210
221
  protected setAuth(auth: PrimaryAuth, { extras, userId }?: {
211
222
  extras?: AuthExtras;
212
223
  userId?: string;
@@ -240,6 +251,7 @@ export declare abstract class ParaCore implements CoreInterface {
240
251
  * @param externalType - Type of external wallet to set.
241
252
  */
242
253
  setExternalWallet(externalWallet: ExternalWalletInfo[] | ExternalWalletInfo): Promise<void>;
254
+ protected addExternalWallets(externalWallets: ExternalWalletInfo[]): Promise<void>;
243
255
  /**
244
256
  * Sets the user id associated with the `ParaCore` instance.
245
257
  * @param userId - User id to set.
@@ -423,6 +435,9 @@ export declare abstract class ParaCore implements CoreInterface {
423
435
  verifyFarcaster(opts: CoreMethodParams<'verifyFarcaster'>): CoreMethodResponse<'verifyFarcaster'>;
424
436
  protected verifyFarcasterLink(opts: InternalMethodParams<'verifyFarcasterLink'>): InternalMethodResponse<'verifyFarcasterLink'>;
425
437
  getOAuthUrl(opts: CoreMethodParams<'getOAuthUrl'>): CoreMethodResponse<'getOAuthUrl'>;
438
+ getOAuthUrlSync(opts: Omit<CoreMethodParams<'getOAuthUrl'>, 'sessionLookupId'> & {
439
+ sessionLookupId: string;
440
+ }): Awaited<CoreMethodResponse<'getOAuthUrl'>>;
426
441
  protected verifyOAuthProcess(_: InternalMethodParams<'verifyOAuthLink'> & {
427
442
  isLinkAccount: true;
428
443
  }): InternalMethodResponse<'verifyOAuthLink'>;
@@ -676,6 +691,7 @@ export declare abstract class ParaCore implements CoreInterface {
676
691
  * @returns {SignUpOrLogInResponse} an object in the form of either: `{ stage: 'verify' }` or `{ stage: 'login'; passkeyUrl?: string; passwordUrl?: string; biometricHints?: BiometricLocationHint[] }`
677
692
  */
678
693
  protected getLoginUrl({ authMethod, shorten, portalTheme, sessionId, }: LoginUrlParams): Promise<string>;
694
+ protected prepareLogin(): InternalMethodResponse<'prepareLogin'>;
679
695
  signUpOrLogIn({ auth, ...urlOptions }: CoreMethodParams<'signUpOrLogIn'>): CoreMethodResponse<'signUpOrLogIn'>;
680
696
  verifyNewAccount({ verificationCode, ...urlOptions }: CoreMethodParams<'verifyNewAccount'>): CoreMethodResponse<'verifyNewAccount'>;
681
697
  getLinkedAccounts({ withMetadata, }?: CoreMethodParams<'getLinkedAccounts'>): CoreMethodResponse<'getLinkedAccounts'>;
@@ -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
  }
@@ -4,7 +4,7 @@ import { ParaCore } from '../ParaCore.js';
4
4
  import { FullSignatureRes, Wallet } from './wallet.js';
5
5
  import { AccountLinkInProgress } from './auth.js';
6
6
  export declare const PARA_CORE_METHODS: readonly ["getAuthInfo", "signUpOrLogIn", "verifyNewAccount", "waitForLogin", "waitForSignup", "waitForWalletCreation", "getOAuthUrl", "verifyOAuth", "getFarcasterConnectUri", "verifyFarcaster", "verifyTelegram", "resendVerificationCode", "loginExternalWallet", "verifyExternalWallet", "setup2fa", "enable2fa", "verify2fa", "logout", "clearStorage", "isSessionActive", "isFullyLoggedIn", "refreshSession", "keepSessionAlive", "exportSession", "importSession", "getVerificationToken", "getWallets", "getWalletsByType", "fetchWallets", "createWallet", "createWalletPerType", "getPregenWallets", "hasPregenWallet", "updatePregenWalletIdentifier", "createPregenWallet", "createPregenWalletPerType", "claimPregenWallets", "createGuestWallets", "distributeNewWalletShare", "getUserShare", "setUserShare", "refreshShare", "signMessage", "signTransaction", "initiateOnRampTransaction", "getWalletBalance", "issueJwt", "getLinkedAccounts", "accountLinkInProgress"];
7
- export declare const PARA_INTERNAL_METHODS: readonly ["linkAccount", "unlinkAccount", "verifyEmailOrPhoneLink", "verifyOAuthLink", "verifyFarcasterLink", "verifyTelegramLink", "verifyExternalWalletLink", "accountLinkInProgress"];
7
+ export declare const PARA_INTERNAL_METHODS: readonly ["linkAccount", "unlinkAccount", "verifyEmailOrPhoneLink", "verifyOAuthLink", "verifyFarcasterLink", "verifyTelegramLink", "verifyExternalWalletLink", "accountLinkInProgress", "prepareLogin"];
8
8
  export type CoreMethodName = (typeof PARA_CORE_METHODS)[number];
9
9
  export type CoreMethodParams<method extends CoreMethodName & keyof CoreMethods> = CoreMethods[method] extends {
10
10
  params: infer P;
@@ -522,6 +522,10 @@ export type InternalMethods = {
522
522
  params: Omit<VerifyExternalWalletParams, 'externalWallet'>;
523
523
  response: LinkedAccounts;
524
524
  };
525
+ prepareLogin: {
526
+ params: void;
527
+ response: string;
528
+ };
525
529
  };
526
530
  export type CoreInterface = {
527
531
  [key in keyof CoreMethods]: Partial<CoreMethod<key>>;
@@ -1,4 +1,4 @@
1
- import { EmbeddedWalletType, ExternalWalletType, PartnerEntity, TExternalWallet, TPregenIdentifierType, TWalletScheme } from '@getpara/user-management-client';
1
+ import { EmbeddedWalletType, ExternalWalletType, PartnerEntity, TPregenIdentifierType, TWalletScheme } from '@getpara/user-management-client';
2
2
  export interface Wallet {
3
3
  createdAt?: string;
4
4
  id: string;
@@ -20,7 +20,7 @@ export interface Wallet {
20
20
  lastUsedPartnerId?: string;
21
21
  isExternal?: boolean;
22
22
  isExternalWithParaAuth?: boolean;
23
- externalProviderId?: TExternalWallet;
23
+ externalProviderId?: string;
24
24
  isExternalWithVerification?: boolean;
25
25
  isExternalConnectionOnly?: boolean;
26
26
  ensName?: string | null;
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@getpara/core-sdk",
3
- "version": "2.0.0-alpha.32",
3
+ "version": "2.0.0-alpha.34",
4
4
  "dependencies": {
5
5
  "@celo/utils": "^8.0.2",
6
6
  "@cosmjs/encoding": "^0.32.4",
7
7
  "@ethereumjs/util": "^9.1.0",
8
- "@getpara/user-management-client": "2.0.0-alpha.32",
8
+ "@getpara/user-management-client": "2.0.0-alpha.34",
9
9
  "@noble/hashes": "^1.5.0",
10
10
  "base64url": "^3.0.1",
11
11
  "libphonenumber-js": "^1.11.7",
@@ -27,7 +27,7 @@
27
27
  "dist",
28
28
  "package.json"
29
29
  ],
30
- "gitHead": "2c1a4e1ef169c177238c8b0358e84dc86f614614",
30
+ "gitHead": "cff5cb1fa7284a850e688b20a6596d435315a475",
31
31
  "main": "dist/cjs/index.js",
32
32
  "module": "dist/esm/index.js",
33
33
  "scripts": {