@getpara/core-sdk 2.0.0-alpha.31 → 2.0.0-alpha.33

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") {
@@ -935,11 +935,59 @@ const _ParaCore = class _ParaCore {
935
935
  */
936
936
  setExternalWallet(externalWallet) {
937
937
  return __async(this, null, function* () {
938
+ const { id: partnerId, supportedWalletTypes } = yield __privateMethod(this, _ParaCore_instances, assertPartner_fn).call(this);
938
939
  this.externalWallets = (Array.isArray(externalWallet) ? externalWallet : [externalWallet]).reduce(
940
+ (acc, {
941
+ partnerId: wPartnerId,
942
+ address,
943
+ type,
944
+ provider,
945
+ providerId,
946
+ addressBech32,
947
+ withFullParaAuth,
948
+ isConnectionOnly,
949
+ withVerification
950
+ }) => {
951
+ if (partnerId === wPartnerId && supportedWalletTypes.some(({ type: supportedType }) => supportedType === type)) {
952
+ return __spreadProps(__spreadValues({}, acc), {
953
+ [address]: {
954
+ id: address,
955
+ partnerId,
956
+ address: addressBech32 != null ? addressBech32 : address,
957
+ type,
958
+ name: provider,
959
+ isExternal: true,
960
+ isExternalWithParaAuth: withFullParaAuth,
961
+ externalProviderId: providerId,
962
+ signer: "",
963
+ isExternalConnectionOnly: isConnectionOnly,
964
+ isExternalWithVerification: withVerification
965
+ }
966
+ });
967
+ }
968
+ return acc;
969
+ },
970
+ {}
971
+ ), this.setExternalWallets(this.externalWallets);
972
+ (0, import_utils2.dispatchEvent)(import_types.ParaEvent.EXTERNAL_WALLET_CHANGE_EVENT, null);
973
+ });
974
+ }
975
+ addExternalWallets(externalWallets) {
976
+ return __async(this, null, function* () {
977
+ const { id: partnerId, supportedWalletTypes } = yield __privateMethod(this, _ParaCore_instances, assertPartner_fn).call(this);
978
+ this.externalWallets = __spreadValues(__spreadValues({}, Object.entries(this.externalWallets).reduce((acc, [address, wallet]) => {
979
+ if (partnerId === wallet.partnerId && supportedWalletTypes.some(({ type }) => type === wallet.type)) {
980
+ return __spreadProps(__spreadValues({}, acc), {
981
+ [address]: wallet
982
+ });
983
+ }
984
+ return acc;
985
+ }, {})), externalWallets.reduce(
939
986
  (acc, { address, type, provider, providerId, addressBech32, withFullParaAuth, isConnectionOnly, withVerification }) => {
940
987
  return __spreadProps(__spreadValues({}, acc), {
941
988
  [address]: {
942
989
  id: address,
990
+ partnerId,
943
991
  address: addressBech32 != null ? addressBech32 : address,
944
992
  type,
945
993
  name: provider,
@@ -953,7 +1001,7 @@ const _ParaCore = class _ParaCore {
953
1001
  });
954
1002
  },
955
1003
  {}
956
- );
1004
+ ));
957
1005
  this.setExternalWallets(this.externalWallets);
958
1006
  (0, import_utils2.dispatchEvent)(import_types.ParaEvent.EXTERNAL_WALLET_CHANGE_EVENT, null);
959
1007
  });
@@ -1307,7 +1355,7 @@ const _ParaCore = class _ParaCore {
1307
1355
  ]);
1308
1356
  const externalWallets = Array.isArray(externalWallet) ? externalWallet : [externalWallet];
1309
1357
  if (this.externalWalletConnectionOnly || externalWallets.every((wallet) => wallet.isConnectionOnly)) {
1310
- yield this.setExternalWallet(
1358
+ yield this.addExternalWallets(
1311
1359
  externalWallets.map((wallet) => __spreadProps(__spreadValues({}, wallet), {
1312
1360
  withFullParaAuth: false
1313
1361
  }))
@@ -1510,6 +1558,9 @@ const _ParaCore = class _ParaCore {
1510
1558
  isFullyLoggedIn() {
1511
1559
  return __async(this, null, function* () {
1512
1560
  if (this.externalWalletConnectionType === "CONNECTION_ONLY") {
1561
+ if (!this.isReady) {
1562
+ yield this.ready();
1563
+ }
1513
1564
  return true;
1514
1565
  }
1515
1566
  if (this.isGuestMode) {
@@ -1714,9 +1765,14 @@ const _ParaCore = class _ParaCore {
1714
1765
  }
1715
1766
  getOAuthUrl(opts) {
1716
1767
  return __async(this, null, function* () {
1717
- return __privateMethod(this, _ParaCore_instances, getOAuthUrl_fn).call(this, opts);
1768
+ var _a;
1769
+ const sessionLookupId = (_a = opts.sessionLookupId) != null ? _a : yield this.prepareLogin();
1770
+ return __privateMethod(this, _ParaCore_instances, getOAuthUrl_fn).call(this, __spreadProps(__spreadValues({}, opts), { sessionLookupId }));
1718
1771
  });
1719
1772
  }
1773
+ getOAuthUrlSync(opts) {
1774
+ return __privateMethod(this, _ParaCore_instances, getOAuthUrl_fn).call(this, opts);
1775
+ }
1720
1776
  /**
1721
1777
  * Awaits the response from a user's attempt to log in with OAuth.
1722
1778
  * If successful, this returns the user's email address and indicates whether the user already exists.
@@ -1725,9 +1781,9 @@ const _ParaCore = class _ParaCore {
1725
1781
  * @param {Window} [opts.popupWindow] the popup window being used for login.
1726
1782
  * @return {Object} `{ email?: string; isError?: boolean; userExists: boolean; }` the result data
1727
1783
  */
1728
- verifyOAuthProcess(_k) {
1784
+ verifyOAuthProcess(_i) {
1729
1785
  return __async(this, null, function* () {
1730
- var _l = _k, {
1786
+ var _j = _i, {
1731
1787
  method,
1732
1788
  appScheme,
1733
1789
  isCanceled = () => false,
@@ -1735,7 +1791,7 @@ const _ParaCore = class _ParaCore {
1735
1791
  onPoll,
1736
1792
  onOAuthUrl,
1737
1793
  isLinkAccount
1738
- } = _l, urlOptions = __objRest(_l, [
1794
+ } = _j, urlOptions = __objRest(_j, [
1739
1795
  "method",
1740
1796
  "appScheme",
1741
1797
  "isCanceled",
@@ -1750,7 +1806,7 @@ const _ParaCore = class _ParaCore {
1750
1806
  accountLinkInProgress = yield __privateMethod(this, _ParaCore_instances, assertIsLinkingAccountOrStart_fn).call(this, method);
1751
1807
  sessionLookupId = (yield this.touchSession()).sessionLookupId;
1752
1808
  } else {
1753
- sessionLookupId = yield __privateMethod(this, _ParaCore_instances, prepareLogin_fn).call(this);
1809
+ sessionLookupId = yield this.prepareLogin();
1754
1810
  }
1755
1811
  const oAuthUrl = yield __privateMethod(this, _ParaCore_instances, getOAuthUrl_fn).call(this, { method, appScheme, sessionLookupId, accountLinkInProgress });
1756
1812
  onOAuthUrl(oAuthUrl);
@@ -2433,12 +2489,12 @@ const _ParaCore = class _ParaCore {
2433
2489
  });
2434
2490
  });
2435
2491
  }
2436
- getOnRampTransactionUrl(_m) {
2492
+ getOnRampTransactionUrl(_k) {
2437
2493
  return __async(this, null, function* () {
2438
- var _n = _m, {
2494
+ var _l = _k, {
2439
2495
  purchaseId,
2440
2496
  providerKey
2441
- } = _n, walletParams = __objRest(_n, [
2497
+ } = _l, walletParams = __objRest(_l, [
2442
2498
  "purchaseId",
2443
2499
  "providerKey"
2444
2500
  ]);
@@ -2924,9 +2980,19 @@ const _ParaCore = class _ParaCore {
2924
2980
  });
2925
2981
  });
2926
2982
  }
2927
- signUpOrLogIn(_o) {
2983
+ prepareLogin() {
2928
2984
  return __async(this, null, function* () {
2929
- var _p = _o, { auth } = _p, urlOptions = __objRest(_p, ["auth"]);
2985
+ yield this.logout();
2986
+ const { sessionLookupId } = yield this.touchSession(true);
2987
+ if (!this.loginEncryptionKeyPair) {
2988
+ yield this.setLoginEncryptionKeyPair();
2989
+ }
2990
+ return sessionLookupId;
2991
+ });
2992
+ }
2993
+ signUpOrLogIn(_m) {
2994
+ return __async(this, null, function* () {
2995
+ var _n = _m, { auth } = _n, urlOptions = __objRest(_n, ["auth"]);
2930
2996
  const serverAuthState = yield this.ctx.client.signUpOrLogIn(__spreadValues(__spreadValues({}, auth), this.getVerificationEmailProps()));
2931
2997
  const authInfo = serverAuthState.auth;
2932
2998
  if (this.fetchPregenWalletsOverride && (0, import_user_management_client.isPregenAuth)(authInfo)) {
@@ -2938,11 +3004,11 @@ const _ParaCore = class _ParaCore {
2938
3004
  return __privateMethod(this, _ParaCore_instances, prepareAuthState_fn).call(this, serverAuthState, urlOptions);
2939
3005
  });
2940
3006
  }
2941
- verifyNewAccount(_q) {
3007
+ verifyNewAccount(_o) {
2942
3008
  return __async(this, null, function* () {
2943
- var _r = _q, {
3009
+ var _p = _o, {
2944
3010
  verificationCode
2945
- } = _r, urlOptions = __objRest(_r, [
3011
+ } = _p, urlOptions = __objRest(_p, [
2946
3012
  "verificationCode"
2947
3013
  ]);
2948
3014
  this.assertIsAuthSet(["email", "phone"]);
@@ -3036,10 +3102,10 @@ const _ParaCore = class _ParaCore {
3036
3102
  });
3037
3103
  }
3038
3104
  verifyLink() {
3039
- return __async(this, arguments, function* (_s = {}) {
3040
- var _t = _s, {
3105
+ return __async(this, arguments, function* (_q = {}) {
3106
+ var _r = _q, {
3041
3107
  accountLinkInProgress = __privateMethod(this, _ParaCore_instances, assertIsLinkingAccount_fn).call(this)
3042
- } = _t, opts = __objRest(_t, [
3108
+ } = _r, opts = __objRest(_r, [
3043
3109
  "accountLinkInProgress"
3044
3110
  ]);
3045
3111
  try {
@@ -3176,30 +3242,30 @@ assertIsLinkingAccountOrStart_fn = function(type) {
3176
3242
  return yield this.linkAccount({ type });
3177
3243
  });
3178
3244
  };
3179
- getOAuthUrl_fn = function(_i) {
3180
- return __async(this, null, function* () {
3181
- var _j = _i, {
3182
- method,
3183
- appScheme,
3184
- accountLinkInProgress
3185
- } = _j, params = __objRest(_j, [
3186
- "method",
3187
- "appScheme",
3188
- "accountLinkInProgress"
3189
- ]);
3190
- var _a;
3191
- const sessionLookupId = (_a = params.sessionLookupId) != null ? _a : yield __privateMethod(this, _ParaCore_instances, prepareLogin_fn).call(this);
3192
- return (0, import_utils2.constructUrl)({
3193
- base: (0, import_userManagementClient.getBaseOAuthUrl)(this.ctx.env),
3194
- path: `/auth/${method}`,
3195
- params: __spreadValues({
3196
- apiKey: this.ctx.apiKey,
3197
- sessionLookupId,
3198
- appScheme
3199
- }, accountLinkInProgress ? {
3200
- linkedAccountId: this.accountLinkInProgress.id
3201
- } : {})
3202
- });
3245
+ /**
3246
+ * Generates a URL for the user to log in with OAuth using a desire method.
3247
+ *
3248
+ * @param {Object} opts the options object
3249
+ * @param {TOAuthMethod} opts.method the third-party service to use for OAuth.
3250
+ * @param {string} [opts.appScheme] the app scheme to redirect to after the OAuth flow. This is for mobile only.
3251
+ * @returns {string} the URL for the user to log in with OAuth.
3252
+ */
3253
+ getOAuthUrl_fn = function({
3254
+ method,
3255
+ appScheme,
3256
+ accountLinkInProgress,
3257
+ sessionLookupId
3258
+ }) {
3259
+ return (0, import_utils2.constructUrl)({
3260
+ base: (0, import_userManagementClient.getBaseOAuthUrl)(this.ctx.env),
3261
+ path: `/auth/${method}`,
3262
+ params: __spreadValues({
3263
+ apiKey: this.ctx.apiKey,
3264
+ sessionLookupId,
3265
+ appScheme
3266
+ }, accountLinkInProgress ? {
3267
+ linkedAccountId: this.accountLinkInProgress.id
3268
+ } : {})
3203
3269
  });
3204
3270
  };
3205
3271
  createPregenWallet_fn = function(opts) {
@@ -3253,7 +3319,7 @@ _isCreateGuestWalletsPending = new WeakMap();
3253
3319
  prepareAuthState_fn = function(_0) {
3254
3320
  return __async(this, arguments, function* (serverAuthState, opts = {}) {
3255
3321
  if (!opts.sessionLookupId && serverAuthState.stage === "login") {
3256
- opts.sessionLookupId = yield __privateMethod(this, _ParaCore_instances, prepareLogin_fn).call(this);
3322
+ opts.sessionLookupId = yield this.prepareLogin();
3257
3323
  }
3258
3324
  const { auth, externalWallet, userId, displayName, pfpUrl, username } = serverAuthState;
3259
3325
  const authInfo = __spreadValues(__spreadValues({}, (0, import_user_management_client.extractAuthInfo)(auth, { isRequired: true })), Object.fromEntries(
@@ -3295,16 +3361,6 @@ prepareAuthState_fn = function(_0) {
3295
3361
  return authState;
3296
3362
  });
3297
3363
  };
3298
- prepareLogin_fn = function() {
3299
- return __async(this, null, function* () {
3300
- yield this.logout();
3301
- const { sessionLookupId } = yield this.touchSession(true);
3302
- if (!this.loginEncryptionKeyPair) {
3303
- yield this.setLoginEncryptionKeyPair();
3304
- }
3305
- return sessionLookupId;
3306
- });
3307
- };
3308
3364
  prepareLoginState_fn = function(_0, _1) {
3309
3365
  return __async(this, arguments, function* (loginState, {
3310
3366
  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.31";
43
+ const PARA_CORE_VERSION = "2.0.0-alpha.33";
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;
@@ -901,11 +901,59 @@ const _ParaCore = class _ParaCore {
901
901
  */
902
902
  setExternalWallet(externalWallet) {
903
903
  return __async(this, null, function* () {
904
+ const { id: partnerId, supportedWalletTypes } = yield __privateMethod(this, _ParaCore_instances, assertPartner_fn).call(this);
904
905
  this.externalWallets = (Array.isArray(externalWallet) ? externalWallet : [externalWallet]).reduce(
906
+ (acc, {
907
+ partnerId: wPartnerId,
908
+ address,
909
+ type,
910
+ provider,
911
+ providerId,
912
+ addressBech32,
913
+ withFullParaAuth,
914
+ isConnectionOnly,
915
+ withVerification
916
+ }) => {
917
+ if (partnerId === wPartnerId && supportedWalletTypes.some(({ type: supportedType }) => supportedType === type)) {
918
+ return __spreadProps(__spreadValues({}, acc), {
919
+ [address]: {
920
+ id: address,
921
+ partnerId,
922
+ address: addressBech32 != null ? addressBech32 : address,
923
+ type,
924
+ name: provider,
925
+ isExternal: true,
926
+ isExternalWithParaAuth: withFullParaAuth,
927
+ externalProviderId: providerId,
928
+ signer: "",
929
+ isExternalConnectionOnly: isConnectionOnly,
930
+ isExternalWithVerification: withVerification
931
+ }
932
+ });
933
+ }
934
+ return acc;
935
+ },
936
+ {}
937
+ ), this.setExternalWallets(this.externalWallets);
938
+ dispatchEvent(ParaEvent.EXTERNAL_WALLET_CHANGE_EVENT, null);
939
+ });
940
+ }
941
+ addExternalWallets(externalWallets) {
942
+ return __async(this, null, function* () {
943
+ const { id: partnerId, supportedWalletTypes } = yield __privateMethod(this, _ParaCore_instances, assertPartner_fn).call(this);
944
+ this.externalWallets = __spreadValues(__spreadValues({}, Object.entries(this.externalWallets).reduce((acc, [address, wallet]) => {
945
+ if (partnerId === wallet.partnerId && supportedWalletTypes.some(({ type }) => type === wallet.type)) {
946
+ return __spreadProps(__spreadValues({}, acc), {
947
+ [address]: wallet
948
+ });
949
+ }
950
+ return acc;
951
+ }, {})), externalWallets.reduce(
905
952
  (acc, { address, type, provider, providerId, addressBech32, withFullParaAuth, isConnectionOnly, withVerification }) => {
906
953
  return __spreadProps(__spreadValues({}, acc), {
907
954
  [address]: {
908
955
  id: address,
956
+ partnerId,
909
957
  address: addressBech32 != null ? addressBech32 : address,
910
958
  type,
911
959
  name: provider,
@@ -919,7 +967,7 @@ const _ParaCore = class _ParaCore {
919
967
  });
920
968
  },
921
969
  {}
922
- );
970
+ ));
923
971
  this.setExternalWallets(this.externalWallets);
924
972
  dispatchEvent(ParaEvent.EXTERNAL_WALLET_CHANGE_EVENT, null);
925
973
  });
@@ -1273,7 +1321,7 @@ const _ParaCore = class _ParaCore {
1273
1321
  ]);
1274
1322
  const externalWallets = Array.isArray(externalWallet) ? externalWallet : [externalWallet];
1275
1323
  if (this.externalWalletConnectionOnly || externalWallets.every((wallet) => wallet.isConnectionOnly)) {
1276
- yield this.setExternalWallet(
1324
+ yield this.addExternalWallets(
1277
1325
  externalWallets.map((wallet) => __spreadProps(__spreadValues({}, wallet), {
1278
1326
  withFullParaAuth: false
1279
1327
  }))
@@ -1476,6 +1524,9 @@ const _ParaCore = class _ParaCore {
1476
1524
  isFullyLoggedIn() {
1477
1525
  return __async(this, null, function* () {
1478
1526
  if (this.externalWalletConnectionType === "CONNECTION_ONLY") {
1527
+ if (!this.isReady) {
1528
+ yield this.ready();
1529
+ }
1479
1530
  return true;
1480
1531
  }
1481
1532
  if (this.isGuestMode) {
@@ -1680,9 +1731,14 @@ const _ParaCore = class _ParaCore {
1680
1731
  }
1681
1732
  getOAuthUrl(opts) {
1682
1733
  return __async(this, null, function* () {
1683
- return __privateMethod(this, _ParaCore_instances, getOAuthUrl_fn).call(this, opts);
1734
+ var _a;
1735
+ const sessionLookupId = (_a = opts.sessionLookupId) != null ? _a : yield this.prepareLogin();
1736
+ return __privateMethod(this, _ParaCore_instances, getOAuthUrl_fn).call(this, __spreadProps(__spreadValues({}, opts), { sessionLookupId }));
1684
1737
  });
1685
1738
  }
1739
+ getOAuthUrlSync(opts) {
1740
+ return __privateMethod(this, _ParaCore_instances, getOAuthUrl_fn).call(this, opts);
1741
+ }
1686
1742
  /**
1687
1743
  * Awaits the response from a user's attempt to log in with OAuth.
1688
1744
  * If successful, this returns the user's email address and indicates whether the user already exists.
@@ -1691,9 +1747,9 @@ const _ParaCore = class _ParaCore {
1691
1747
  * @param {Window} [opts.popupWindow] the popup window being used for login.
1692
1748
  * @return {Object} `{ email?: string; isError?: boolean; userExists: boolean; }` the result data
1693
1749
  */
1694
- verifyOAuthProcess(_k) {
1750
+ verifyOAuthProcess(_i) {
1695
1751
  return __async(this, null, function* () {
1696
- var _l = _k, {
1752
+ var _j = _i, {
1697
1753
  method,
1698
1754
  appScheme,
1699
1755
  isCanceled = () => false,
@@ -1701,7 +1757,7 @@ const _ParaCore = class _ParaCore {
1701
1757
  onPoll,
1702
1758
  onOAuthUrl,
1703
1759
  isLinkAccount
1704
- } = _l, urlOptions = __objRest(_l, [
1760
+ } = _j, urlOptions = __objRest(_j, [
1705
1761
  "method",
1706
1762
  "appScheme",
1707
1763
  "isCanceled",
@@ -1716,7 +1772,7 @@ const _ParaCore = class _ParaCore {
1716
1772
  accountLinkInProgress = yield __privateMethod(this, _ParaCore_instances, assertIsLinkingAccountOrStart_fn).call(this, method);
1717
1773
  sessionLookupId = (yield this.touchSession()).sessionLookupId;
1718
1774
  } else {
1719
- sessionLookupId = yield __privateMethod(this, _ParaCore_instances, prepareLogin_fn).call(this);
1775
+ sessionLookupId = yield this.prepareLogin();
1720
1776
  }
1721
1777
  const oAuthUrl = yield __privateMethod(this, _ParaCore_instances, getOAuthUrl_fn).call(this, { method, appScheme, sessionLookupId, accountLinkInProgress });
1722
1778
  onOAuthUrl(oAuthUrl);
@@ -2399,12 +2455,12 @@ const _ParaCore = class _ParaCore {
2399
2455
  });
2400
2456
  });
2401
2457
  }
2402
- getOnRampTransactionUrl(_m) {
2458
+ getOnRampTransactionUrl(_k) {
2403
2459
  return __async(this, null, function* () {
2404
- var _n = _m, {
2460
+ var _l = _k, {
2405
2461
  purchaseId,
2406
2462
  providerKey
2407
- } = _n, walletParams = __objRest(_n, [
2463
+ } = _l, walletParams = __objRest(_l, [
2408
2464
  "purchaseId",
2409
2465
  "providerKey"
2410
2466
  ]);
@@ -2890,9 +2946,19 @@ const _ParaCore = class _ParaCore {
2890
2946
  });
2891
2947
  });
2892
2948
  }
2893
- signUpOrLogIn(_o) {
2949
+ prepareLogin() {
2894
2950
  return __async(this, null, function* () {
2895
- var _p = _o, { auth } = _p, urlOptions = __objRest(_p, ["auth"]);
2951
+ yield this.logout();
2952
+ const { sessionLookupId } = yield this.touchSession(true);
2953
+ if (!this.loginEncryptionKeyPair) {
2954
+ yield this.setLoginEncryptionKeyPair();
2955
+ }
2956
+ return sessionLookupId;
2957
+ });
2958
+ }
2959
+ signUpOrLogIn(_m) {
2960
+ return __async(this, null, function* () {
2961
+ var _n = _m, { auth } = _n, urlOptions = __objRest(_n, ["auth"]);
2896
2962
  const serverAuthState = yield this.ctx.client.signUpOrLogIn(__spreadValues(__spreadValues({}, auth), this.getVerificationEmailProps()));
2897
2963
  const authInfo = serverAuthState.auth;
2898
2964
  if (this.fetchPregenWalletsOverride && isPregenAuth(authInfo)) {
@@ -2904,11 +2970,11 @@ const _ParaCore = class _ParaCore {
2904
2970
  return __privateMethod(this, _ParaCore_instances, prepareAuthState_fn).call(this, serverAuthState, urlOptions);
2905
2971
  });
2906
2972
  }
2907
- verifyNewAccount(_q) {
2973
+ verifyNewAccount(_o) {
2908
2974
  return __async(this, null, function* () {
2909
- var _r = _q, {
2975
+ var _p = _o, {
2910
2976
  verificationCode
2911
- } = _r, urlOptions = __objRest(_r, [
2977
+ } = _p, urlOptions = __objRest(_p, [
2912
2978
  "verificationCode"
2913
2979
  ]);
2914
2980
  this.assertIsAuthSet(["email", "phone"]);
@@ -3002,10 +3068,10 @@ const _ParaCore = class _ParaCore {
3002
3068
  });
3003
3069
  }
3004
3070
  verifyLink() {
3005
- return __async(this, arguments, function* (_s = {}) {
3006
- var _t = _s, {
3071
+ return __async(this, arguments, function* (_q = {}) {
3072
+ var _r = _q, {
3007
3073
  accountLinkInProgress = __privateMethod(this, _ParaCore_instances, assertIsLinkingAccount_fn).call(this)
3008
- } = _t, opts = __objRest(_t, [
3074
+ } = _r, opts = __objRest(_r, [
3009
3075
  "accountLinkInProgress"
3010
3076
  ]);
3011
3077
  try {
@@ -3142,30 +3208,30 @@ assertIsLinkingAccountOrStart_fn = function(type) {
3142
3208
  return yield this.linkAccount({ type });
3143
3209
  });
3144
3210
  };
3145
- getOAuthUrl_fn = function(_i) {
3146
- return __async(this, null, function* () {
3147
- var _j = _i, {
3148
- method,
3149
- appScheme,
3150
- accountLinkInProgress
3151
- } = _j, params = __objRest(_j, [
3152
- "method",
3153
- "appScheme",
3154
- "accountLinkInProgress"
3155
- ]);
3156
- var _a;
3157
- const sessionLookupId = (_a = params.sessionLookupId) != null ? _a : yield __privateMethod(this, _ParaCore_instances, prepareLogin_fn).call(this);
3158
- return constructUrl({
3159
- base: getBaseOAuthUrl(this.ctx.env),
3160
- path: `/auth/${method}`,
3161
- params: __spreadValues({
3162
- apiKey: this.ctx.apiKey,
3163
- sessionLookupId,
3164
- appScheme
3165
- }, accountLinkInProgress ? {
3166
- linkedAccountId: this.accountLinkInProgress.id
3167
- } : {})
3168
- });
3211
+ /**
3212
+ * Generates a URL for the user to log in with OAuth using a desire method.
3213
+ *
3214
+ * @param {Object} opts the options object
3215
+ * @param {TOAuthMethod} opts.method the third-party service to use for OAuth.
3216
+ * @param {string} [opts.appScheme] the app scheme to redirect to after the OAuth flow. This is for mobile only.
3217
+ * @returns {string} the URL for the user to log in with OAuth.
3218
+ */
3219
+ getOAuthUrl_fn = function({
3220
+ method,
3221
+ appScheme,
3222
+ accountLinkInProgress,
3223
+ sessionLookupId
3224
+ }) {
3225
+ return constructUrl({
3226
+ base: getBaseOAuthUrl(this.ctx.env),
3227
+ path: `/auth/${method}`,
3228
+ params: __spreadValues({
3229
+ apiKey: this.ctx.apiKey,
3230
+ sessionLookupId,
3231
+ appScheme
3232
+ }, accountLinkInProgress ? {
3233
+ linkedAccountId: this.accountLinkInProgress.id
3234
+ } : {})
3169
3235
  });
3170
3236
  };
3171
3237
  createPregenWallet_fn = function(opts) {
@@ -3219,7 +3285,7 @@ _isCreateGuestWalletsPending = new WeakMap();
3219
3285
  prepareAuthState_fn = function(_0) {
3220
3286
  return __async(this, arguments, function* (serverAuthState, opts = {}) {
3221
3287
  if (!opts.sessionLookupId && serverAuthState.stage === "login") {
3222
- opts.sessionLookupId = yield __privateMethod(this, _ParaCore_instances, prepareLogin_fn).call(this);
3288
+ opts.sessionLookupId = yield this.prepareLogin();
3223
3289
  }
3224
3290
  const { auth, externalWallet, userId, displayName, pfpUrl, username } = serverAuthState;
3225
3291
  const authInfo = __spreadValues(__spreadValues({}, extractAuthInfo(auth, { isRequired: true })), Object.fromEntries(
@@ -3261,16 +3327,6 @@ prepareAuthState_fn = function(_0) {
3261
3327
  return authState;
3262
3328
  });
3263
3329
  };
3264
- prepareLogin_fn = function() {
3265
- return __async(this, null, function* () {
3266
- yield this.logout();
3267
- const { sessionLookupId } = yield this.touchSession(true);
3268
- if (!this.loginEncryptionKeyPair) {
3269
- yield this.setLoginEncryptionKeyPair();
3270
- }
3271
- return sessionLookupId;
3272
- });
3273
- };
3274
3330
  prepareLoginState_fn = function(_0, _1) {
3275
3331
  return __async(this, arguments, function* (loginState, {
3276
3332
  useShortUrls: shorten = false,
@@ -1,5 +1,5 @@
1
1
  import "./chunk-7B52C2XE.js";
2
- const PARA_CORE_VERSION = "2.0.0-alpha.31";
2
+ const PARA_CORE_VERSION = "2.0.0-alpha.33";
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,
@@ -206,7 +206,12 @@ export declare abstract class ParaCore implements CoreInterface {
206
206
  * Init only needs to be called for storage that is async.
207
207
  */
208
208
  init(): Promise<void>;
209
- protected abstract ready(): Promise<void>;
209
+ /**
210
+ * Call this method to perform initial setup for the `ParaCore` instance.
211
+ *
212
+ * This method will be called automatically if you use the React `ParaProvider` or when you call any methods that request an updated session.
213
+ */
214
+ abstract ready(): Promise<void>;
210
215
  protected setAuth(auth: PrimaryAuth, { extras, userId }?: {
211
216
  extras?: AuthExtras;
212
217
  userId?: string;
@@ -240,6 +245,7 @@ export declare abstract class ParaCore implements CoreInterface {
240
245
  * @param externalType - Type of external wallet to set.
241
246
  */
242
247
  setExternalWallet(externalWallet: ExternalWalletInfo[] | ExternalWalletInfo): Promise<void>;
248
+ protected addExternalWallets(externalWallets: ExternalWalletInfo[]): Promise<void>;
243
249
  /**
244
250
  * Sets the user id associated with the `ParaCore` instance.
245
251
  * @param userId - User id to set.
@@ -423,6 +429,9 @@ export declare abstract class ParaCore implements CoreInterface {
423
429
  verifyFarcaster(opts: CoreMethodParams<'verifyFarcaster'>): CoreMethodResponse<'verifyFarcaster'>;
424
430
  protected verifyFarcasterLink(opts: InternalMethodParams<'verifyFarcasterLink'>): InternalMethodResponse<'verifyFarcasterLink'>;
425
431
  getOAuthUrl(opts: CoreMethodParams<'getOAuthUrl'>): CoreMethodResponse<'getOAuthUrl'>;
432
+ getOAuthUrlSync(opts: Omit<CoreMethodParams<'getOAuthUrl'>, 'sessionLookupId'> & {
433
+ sessionLookupId: string;
434
+ }): Awaited<CoreMethodResponse<'getOAuthUrl'>>;
426
435
  protected verifyOAuthProcess(_: InternalMethodParams<'verifyOAuthLink'> & {
427
436
  isLinkAccount: true;
428
437
  }): InternalMethodResponse<'verifyOAuthLink'>;
@@ -676,6 +685,7 @@ export declare abstract class ParaCore implements CoreInterface {
676
685
  * @returns {SignUpOrLogInResponse} an object in the form of either: `{ stage: 'verify' }` or `{ stage: 'login'; passkeyUrl?: string; passwordUrl?: string; biometricHints?: BiometricLocationHint[] }`
677
686
  */
678
687
  protected getLoginUrl({ authMethod, shorten, portalTheme, sessionId, }: LoginUrlParams): Promise<string>;
688
+ protected prepareLogin(): InternalMethodResponse<'prepareLogin'>;
679
689
  signUpOrLogIn({ auth, ...urlOptions }: CoreMethodParams<'signUpOrLogIn'>): CoreMethodResponse<'signUpOrLogIn'>;
680
690
  verifyNewAccount({ verificationCode, ...urlOptions }: CoreMethodParams<'verifyNewAccount'>): CoreMethodResponse<'verifyNewAccount'>;
681
691
  getLinkedAccounts({ withMetadata, }?: CoreMethodParams<'getLinkedAccounts'>): CoreMethodResponse<'getLinkedAccounts'>;
@@ -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>>;
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@getpara/core-sdk",
3
- "version": "2.0.0-alpha.31",
3
+ "version": "2.0.0-alpha.33",
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.31",
8
+ "@getpara/user-management-client": "2.0.0-alpha.33",
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": "54aac22b2d0b4cc730ab7f2e82cdd8a96729b039",
30
+ "gitHead": "f338306fa30497d2190f8da2ff72ddd8d9d9032f",
31
31
  "main": "dist/cjs/index.js",
32
32
  "module": "dist/esm/index.js",
33
33
  "scripts": {