@getpara/core-sdk 1.5.1 → 1.7.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.
package/dist/cjs/index.js CHANGED
@@ -1104,13 +1104,14 @@ var TransactionReviewTimeout = class extends Error {
1104
1104
  };
1105
1105
 
1106
1106
  // src/constants.ts
1107
- var PARA_CORE_VERSION = '1.5.1';
1107
+ var PARA_CORE_VERSION = '1.7.0';
1108
1108
  var PREFIX = "@CAPSULE/";
1109
1109
  var LOCAL_STORAGE_EMAIL = `${PREFIX}e-mail`;
1110
1110
  var LOCAL_STORAGE_PHONE = `${PREFIX}phone`;
1111
1111
  var LOCAL_STORAGE_COUNTRY_CODE = `${PREFIX}countryCode`;
1112
1112
  var LOCAL_STORAGE_FARCASTER_USERNAME = `${PREFIX}farcasterUsername`;
1113
1113
  var LOCAL_STORAGE_TELEGRAM_USER_ID = `${PREFIX}telegramUserId`;
1114
+ var LOCAL_STORAGE_EXTERNAL_WALLET_USER_ID = `${PREFIX}externalWalletUserId`;
1114
1115
  var LOCAL_STORAGE_USER_ID = `${PREFIX}userId`;
1115
1116
  var LOCAL_STORAGE_ED25519_WALLETS = `${PREFIX}ed25519Wallets`;
1116
1117
  var LOCAL_STORAGE_WALLETS = `${PREFIX}wallets`;
@@ -1413,16 +1414,23 @@ var _ParaCore = class _ParaCore {
1413
1414
  setupListeners.bind(this)();
1414
1415
  }
1415
1416
  get isEmail() {
1416
- return !!this.email && !this.phone && !this.countryCode && !this.farcasterUsername && !this.telegramUserId;
1417
+ return !!this.email && !this.phone && !this.countryCode && !this.farcasterUsername && !this.telegramUserId && !this.externalWalletWithParaAuth;
1417
1418
  }
1418
1419
  get isPhone() {
1419
- return !!this.phone && !!this.countryCode && !this.email && !this.farcasterUsername && !this.telegramUserId;
1420
+ return !!this.phone && !!this.countryCode && !this.email && !this.farcasterUsername && !this.telegramUserId && !this.externalWalletWithParaAuth;
1420
1421
  }
1421
1422
  get isFarcaster() {
1422
- return !!this.farcasterUsername && !this.email && !this.phone && !this.countryCode && !this.telegramUserId;
1423
+ return !!this.farcasterUsername && !this.email && !this.phone && !this.countryCode && !this.telegramUserId && !this.externalWalletWithParaAuth;
1423
1424
  }
1424
1425
  get isTelegram() {
1425
- return !!this.telegramUserId && !this.email && !this.phone && !this.countryCode && !this.farcasterUsername;
1426
+ return !!this.telegramUserId && !this.email && !this.phone && !this.countryCode && !this.farcasterUsername && !this.externalWalletWithParaAuth;
1427
+ }
1428
+ get externalWalletWithParaAuth() {
1429
+ const externalWallets = Object.values(this.externalWallets);
1430
+ return externalWallets.find((w) => w.isExternalWithParaAuth);
1431
+ }
1432
+ get isExternalWalletAuth() {
1433
+ return !!this.externalWalletWithParaAuth && !this.email && !this.phone && !this.countryCode && !this.farcasterUsername && !this.telegramUserId;
1426
1434
  }
1427
1435
  get currentWalletIdsArray() {
1428
1436
  return this.supportedWalletTypes.reduce((acc, { type }) => {
@@ -1530,7 +1538,11 @@ var _ParaCore = class _ParaCore {
1530
1538
  ));
1531
1539
  }
1532
1540
  isWalletUsable(walletId, { type: types, scheme: schemes, forbidPregen = false } = {}, throwError = false) {
1541
+ var _a;
1533
1542
  let error;
1543
+ if ((_a = this.externalWallets) == null ? void 0 : _a[walletId]) {
1544
+ return true;
1545
+ }
1534
1546
  if (!this.wallets[walletId]) {
1535
1547
  error = `wallet with id ${walletId} does not exist`;
1536
1548
  } else {
@@ -1543,8 +1555,8 @@ var _ParaCore = class _ParaCore {
1543
1555
  } else if (!this.isWalletSupported(wallet)) {
1544
1556
  error = `wallet with id ${wallet == null ? void 0 : wallet.id} and type ${wallet == null ? void 0 : wallet.type} is not supported, supported types are: ${this.supportedWalletTypes.map(({ type }) => type).join(", ")}`;
1545
1557
  } else if (types && (!getEquivalentTypes(types).includes(wallet == null ? void 0 : wallet.type) || isOwned && !types.some((type) => {
1546
- var _a, _b;
1547
- return (_b = (_a = this.currentWalletIds) == null ? void 0 : _a[type]) == null ? void 0 : _b.includes(walletId);
1558
+ var _a2, _b;
1559
+ return (_b = (_a2 = this.currentWalletIds) == null ? void 0 : _a2[type]) == null ? void 0 : _b.includes(walletId);
1548
1560
  }))) {
1549
1561
  error = `wallet with id ${wallet == null ? void 0 : wallet.id} and type ${wallet == null ? void 0 : wallet.type} cannot be selected`;
1550
1562
  } else if (schemes && !schemes.includes(wallet == null ? void 0 : wallet.scheme)) {
@@ -1611,7 +1623,7 @@ var _ParaCore = class _ParaCore {
1611
1623
  }
1612
1624
  constructPortalUrl(_0) {
1613
1625
  return __async(this, arguments, function* (type, opts = {}) {
1614
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
1626
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
1615
1627
  const base = type === "onRamp" ? getPortalBaseURL(this.ctx) : yield this.getPortalURL(opts.partnerId);
1616
1628
  let path;
1617
1629
  switch (type) {
@@ -1663,7 +1675,10 @@ var _ParaCore = class _ParaCore {
1663
1675
  portalPrimaryButtonTextColor: this.portalPrimaryButtonTextColor,
1664
1676
  isForNewDevice: opts.isForNewDevice ? opts.isForNewDevice.toString() : void 0,
1665
1677
  supportedWalletTypes: __privateGet(this, _supportedWalletTypesOpt) ? JSON.stringify(__privateGet(this, _supportedWalletTypesOpt)) : void 0
1666
- }, isCreate || isLogin ? __spreadValues(__spreadValues(__spreadValues(__spreadValues({}, opts.authType === "email" ? { email: this.email } : {}), opts.authType === "phone" ? { phone: this.phone, countryCode: this.countryCode } : {}), opts.authType === "farcaster" ? { farcasterUsername: this.farcasterUsername } : {}), opts.authType === "telegram" ? { telegramUserId: this.telegramUserId } : {}) : {}), isLogin || isOnRamp ? { sessionId: opts.sessionId } : {}), isLogin ? {
1678
+ }, isCreate || isLogin ? __spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues({}, opts.authType === "email" ? { email: this.email } : {}), opts.authType === "phone" ? { phone: this.phone, countryCode: this.countryCode } : {}), opts.authType === "farcaster" ? { farcasterUsername: this.farcasterUsername } : {}), opts.authType === "telegram" ? { telegramUserId: this.telegramUserId } : {}), opts.authType === "externalWallet" ? {
1679
+ // Using id here since we store the bech32 address for cosmos in the address field of the wallet
1680
+ externalWalletAddress: (_n = this.externalWalletWithParaAuth) == null ? void 0 : _n.id
1681
+ } : {}) : {}), isLogin || isOnRamp ? { sessionId: opts.sessionId } : {}), isLogin ? {
1667
1682
  encryptionKey: opts.loginEncryptionPublicKey,
1668
1683
  newDeviceSessionLookupId: opts.newDeviceSessionId,
1669
1684
  newDeviceEncryptionKey: opts.newDeviceEncryptionKey,
@@ -1817,7 +1832,7 @@ var _ParaCore = class _ParaCore {
1817
1832
  * @param externalType - Type of external wallet to set.
1818
1833
  */
1819
1834
  setExternalWallet(_0) {
1820
- return __async(this, arguments, function* ({ address, type, provider, addressBech32 }) {
1835
+ return __async(this, arguments, function* ({ address, type, provider, addressBech32, withFullParaAuth }) {
1821
1836
  this.externalWallets = {
1822
1837
  [address]: {
1823
1838
  id: address,
@@ -1825,6 +1840,7 @@ var _ParaCore = class _ParaCore {
1825
1840
  type,
1826
1841
  name: provider,
1827
1842
  isExternal: true,
1843
+ isExternalWithParaAuth: withFullParaAuth,
1828
1844
  signer: ""
1829
1845
  }
1830
1846
  };
@@ -1943,6 +1959,23 @@ var _ParaCore = class _ParaCore {
1943
1959
  dispatchEvent(ParaEvent.WALLETS_CHANGE_EVENT, null);
1944
1960
  });
1945
1961
  }
1962
+ /**
1963
+ * Fetches the most recent OAuth account metadata for the signed-in user.
1964
+ * If applicable, this will include the user's most recent metadata from their Google, Apple, Facebook, X, Discord, Farcaster, or Telegram account, the last time they signed in to your app.
1965
+ * @returns {Promise<AccountMetadata>} the user's account metadata.
1966
+ */
1967
+ getAccountMetadata() {
1968
+ return __async(this, null, function* () {
1969
+ if (!(yield this.isSessionActive()) || !this.userId) {
1970
+ throw new Error("no signed-in user");
1971
+ }
1972
+ const {
1973
+ data: { partnerId }
1974
+ } = yield this.touchSession();
1975
+ const { accountMetadata } = yield this.ctx.client.getAccountMetadata(this.userId, partnerId);
1976
+ return accountMetadata;
1977
+ });
1978
+ }
1946
1979
  /**
1947
1980
  * Validates that a wallet ID is present on the instance, usable, and matches the desired filters.
1948
1981
  * If no ID is passed, this will instead return the first valid, usable wallet ID that matches the filters.
@@ -1995,18 +2028,18 @@ var _ParaCore = class _ParaCore {
1995
2028
  return wallet;
1996
2029
  }
1997
2030
  findWallet(idOrAddress, overrideType, filter = {}) {
1998
- var _b, _c;
1999
- if (!idOrAddress && Object.keys(this.externalWallets).length > 0) {
2031
+ var _a, _c, _d;
2032
+ if (!this.isExternalWalletAuth && !idOrAddress && Object.keys(this.externalWallets).length > 0) {
2000
2033
  return Object.values(this.externalWallets)[0];
2001
2034
  }
2002
- if (this.externalWallets[idOrAddress]) {
2035
+ if ((_a = this.externalWallets) == null ? void 0 : _a[idOrAddress]) {
2003
2036
  return this.externalWallets[idOrAddress];
2004
2037
  }
2005
2038
  try {
2006
2039
  const walletId = this.findWalletId(idOrAddress, filter);
2007
2040
  if (walletId && !!this.wallets[walletId]) {
2008
- const _a = this.wallets[walletId], { signer: _signer } = _a, wallet = __objRest(_a, ["signer"]);
2009
- const type = (_c = overrideType != null ? overrideType : (_b = this.currentWalletIdsArray.find(([id]) => id === walletId)) == null ? void 0 : _b[1]) != null ? _c : wallet.type;
2041
+ const _b = this.wallets[walletId], { signer: _signer } = _b, wallet = __objRest(_b, ["signer"]);
2042
+ const type = (_d = overrideType != null ? overrideType : (_c = this.currentWalletIdsArray.find(([id]) => id === walletId)) == null ? void 0 : _c[1]) != null ? _d : wallet.type;
2010
2043
  return __spreadProps(__spreadValues({}, wallet), {
2011
2044
  type: import_user_management_client5.WalletType[type]
2012
2045
  });
@@ -2290,7 +2323,8 @@ var _ParaCore = class _ParaCore {
2290
2323
  externalAddress: wallet.address,
2291
2324
  type: wallet.type,
2292
2325
  externalWalletProvider: wallet.provider,
2293
- shouldTrackUser: wallet.shouldTrackUser
2326
+ // If the wallet isn't using full Para auth we want to track the login here
2327
+ shouldTrackUser: !wallet.withFullParaAuth
2294
2328
  });
2295
2329
  yield this.setExternalWallet(wallet);
2296
2330
  yield this.setUserId(res.userId);
@@ -2298,10 +2332,10 @@ var _ParaCore = class _ParaCore {
2298
2332
  });
2299
2333
  }
2300
2334
  /**
2301
- * Returns whether or not the user is connected with an external wallet.
2335
+ * Returns whether or not the user is connected with only an external wallet, not an external wallet with Para auth.
2302
2336
  */
2303
2337
  isUsingExternalWallet() {
2304
- return !!Object.keys(this.externalWallets).length;
2338
+ return !this.isExternalWalletAuth && !!Object.keys(this.externalWallets).length;
2305
2339
  }
2306
2340
  /**
2307
2341
  * Passes the email code obtained from the user for verification.
@@ -2323,7 +2357,7 @@ var _ParaCore = class _ParaCore {
2323
2357
  cosmosSigner
2324
2358
  }) {
2325
2359
  yield this.ctx.client.verifyExternalWallet(this.userId, { address, signedMessage, cosmosPublicKeyHex, cosmosSigner });
2326
- return this.getSetUpBiometricsURL();
2360
+ return this.getSetUpBiometricsURL({ authType: "externalWallet" });
2327
2361
  });
2328
2362
  }
2329
2363
  /**
@@ -2577,15 +2611,20 @@ var _ParaCore = class _ParaCore {
2577
2611
  */
2578
2612
  getUserBiometricLocationHints() {
2579
2613
  return __async(this, null, function* () {
2580
- if (!this.email && !this.phone && !this.farcasterUsername && !this.telegramUserId) {
2581
- throw new Error("one of email, phone or farcaster username are required to get biometric location hints");
2614
+ var _a;
2615
+ if (!this.email && !this.phone && !this.farcasterUsername && !this.telegramUserId && !this.isExternalWalletAuth) {
2616
+ throw new Error(
2617
+ "one of email, phone, farcaster username, telegram user id or external wallet with Para auth are required to get biometric location hints"
2618
+ );
2582
2619
  }
2583
2620
  return yield this.ctx.client.getBiometricLocationHints({
2584
2621
  email: this.email,
2585
2622
  phone: this.phone,
2586
2623
  countryCode: this.countryCode,
2587
2624
  farcasterUsername: this.farcasterUsername,
2588
- telegramUserId: this.telegramUserId
2625
+ telegramUserId: this.telegramUserId,
2626
+ // Using id here since we store the bech32 address for cosmos in the address field of the wallet
2627
+ externalWalletAddress: (_a = this.externalWalletWithParaAuth) == null ? void 0 : _a.id
2589
2628
  });
2590
2629
  });
2591
2630
  }
@@ -2697,7 +2736,9 @@ var _ParaCore = class _ParaCore {
2697
2736
  waitForAccountCreation() {
2698
2737
  return __async(this, arguments, function* ({ popupWindow } = {}) {
2699
2738
  yield this.touchSession();
2700
- this.externalWallets = {};
2739
+ if (!this.isExternalWalletAuth) {
2740
+ this.externalWallets = {};
2741
+ }
2701
2742
  this.isAwaitingAccountCreation = true;
2702
2743
  while (this.isAwaitingAccountCreation) {
2703
2744
  try {
@@ -2865,7 +2906,9 @@ var _ParaCore = class _ParaCore {
2865
2906
  skipSessionRefresh = false
2866
2907
  } = {}) {
2867
2908
  var _a;
2868
- this.externalWallets = {};
2909
+ if (!this.isExternalWalletAuth) {
2910
+ this.externalWallets = {};
2911
+ }
2869
2912
  this.isAwaitingLogin = true;
2870
2913
  while (this.isAwaitingLogin) {
2871
2914
  try {
@@ -3332,6 +3375,12 @@ var _ParaCore = class _ParaCore {
3332
3375
  if (pregenWallets.length === 0) {
3333
3376
  return void 0;
3334
3377
  }
3378
+ const missingWallets = pregenWallets.filter((wallet) => !this.wallets[wallet.id]);
3379
+ if (missingWallets.length > 0) {
3380
+ throw new Error(
3381
+ `Cannot claim pregen wallets because wallet data is missing. Please call setUserShare first to load the wallet data for the following wallet IDs: ${missingWallets.map((w) => w.id).join(", ")}`
3382
+ );
3383
+ }
3335
3384
  let newRecoverySecret;
3336
3385
  const { walletIds } = yield this.ctx.client.claimPregenWallets({
3337
3386
  userId: this.userId,
@@ -3785,13 +3834,14 @@ var _ParaCore = class _ParaCore {
3785
3834
  }
3786
3835
  /**
3787
3836
  * Serialize the current session for import by another Para instance.
3837
+ * @param {boolean} excludeSigners - whether or not to exclude the signer from the exported wallets.
3788
3838
  * @returns {string} the serialized session
3789
3839
  */
3790
- exportSession() {
3840
+ exportSession({ excludeSigners } = {}) {
3791
3841
  const sessionInfo = {
3792
3842
  email: this.email,
3793
3843
  userId: this.userId,
3794
- wallets: this.wallets,
3844
+ wallets: structuredClone(this.wallets),
3795
3845
  currentWalletIds: this.currentWalletIds,
3796
3846
  sessionCookie: this.sessionCookie,
3797
3847
  phone: this.phone,
@@ -3800,6 +3850,11 @@ var _ParaCore = class _ParaCore {
3800
3850
  farcasterUsername: this.farcasterUsername,
3801
3851
  externalWallets: this.externalWallets
3802
3852
  };
3853
+ if (excludeSigners) {
3854
+ for (const wallet of Object.values(sessionInfo.wallets)) {
3855
+ delete wallet.signer;
3856
+ }
3857
+ }
3803
3858
  return Buffer.from(JSON.stringify(sessionInfo)).toString("base64");
3804
3859
  }
3805
3860
  /**
@@ -3923,6 +3978,14 @@ var _ParaCore = class _ParaCore {
3923
3978
  }),
3924
3979
  {}
3925
3980
  );
3981
+ const redactedExternalWallets = Object.keys(this.externalWallets).reduce(
3982
+ (acc, walletId) => __spreadProps(__spreadValues({}, acc), {
3983
+ [walletId]: __spreadProps(__spreadValues({}, this.externalWallets[walletId]), {
3984
+ signer: this.externalWallets[walletId].signer ? "[REDACTED]" : void 0
3985
+ })
3986
+ }),
3987
+ {}
3988
+ );
3926
3989
  const obj = {
3927
3990
  supportedWalletTypes: this.supportedWalletTypes,
3928
3991
  cosmosPrefix: this.cosmosPrefix,
@@ -3935,6 +3998,7 @@ var _ParaCore = class _ParaCore {
3935
3998
  pregenIds: this.pregenIds,
3936
3999
  currentWalletIds: this.currentWalletIds,
3937
4000
  wallets: redactedWallets,
4001
+ externalWallets: redactedExternalWallets,
3938
4002
  loginEncryptionKeyPair: this.loginEncryptionKeyPair ? "[REDACTED]" : void 0,
3939
4003
  ctx: {
3940
4004
  apiKey: this.ctx.apiKey,
Binary file
Binary file
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "commonjs"
3
+ }
package/dist/esm/index.js CHANGED
@@ -1021,13 +1021,14 @@ var TransactionReviewTimeout = class extends Error {
1021
1021
  };
1022
1022
 
1023
1023
  // src/constants.ts
1024
- var PARA_CORE_VERSION = '1.5.1';
1024
+ var PARA_CORE_VERSION = '1.7.0';
1025
1025
  var PREFIX = "@CAPSULE/";
1026
1026
  var LOCAL_STORAGE_EMAIL = `${PREFIX}e-mail`;
1027
1027
  var LOCAL_STORAGE_PHONE = `${PREFIX}phone`;
1028
1028
  var LOCAL_STORAGE_COUNTRY_CODE = `${PREFIX}countryCode`;
1029
1029
  var LOCAL_STORAGE_FARCASTER_USERNAME = `${PREFIX}farcasterUsername`;
1030
1030
  var LOCAL_STORAGE_TELEGRAM_USER_ID = `${PREFIX}telegramUserId`;
1031
+ var LOCAL_STORAGE_EXTERNAL_WALLET_USER_ID = `${PREFIX}externalWalletUserId`;
1031
1032
  var LOCAL_STORAGE_USER_ID = `${PREFIX}userId`;
1032
1033
  var LOCAL_STORAGE_ED25519_WALLETS = `${PREFIX}ed25519Wallets`;
1033
1034
  var LOCAL_STORAGE_WALLETS = `${PREFIX}wallets`;
@@ -1330,16 +1331,23 @@ var _ParaCore = class _ParaCore {
1330
1331
  setupListeners.bind(this)();
1331
1332
  }
1332
1333
  get isEmail() {
1333
- return !!this.email && !this.phone && !this.countryCode && !this.farcasterUsername && !this.telegramUserId;
1334
+ return !!this.email && !this.phone && !this.countryCode && !this.farcasterUsername && !this.telegramUserId && !this.externalWalletWithParaAuth;
1334
1335
  }
1335
1336
  get isPhone() {
1336
- return !!this.phone && !!this.countryCode && !this.email && !this.farcasterUsername && !this.telegramUserId;
1337
+ return !!this.phone && !!this.countryCode && !this.email && !this.farcasterUsername && !this.telegramUserId && !this.externalWalletWithParaAuth;
1337
1338
  }
1338
1339
  get isFarcaster() {
1339
- return !!this.farcasterUsername && !this.email && !this.phone && !this.countryCode && !this.telegramUserId;
1340
+ return !!this.farcasterUsername && !this.email && !this.phone && !this.countryCode && !this.telegramUserId && !this.externalWalletWithParaAuth;
1340
1341
  }
1341
1342
  get isTelegram() {
1342
- return !!this.telegramUserId && !this.email && !this.phone && !this.countryCode && !this.farcasterUsername;
1343
+ return !!this.telegramUserId && !this.email && !this.phone && !this.countryCode && !this.farcasterUsername && !this.externalWalletWithParaAuth;
1344
+ }
1345
+ get externalWalletWithParaAuth() {
1346
+ const externalWallets = Object.values(this.externalWallets);
1347
+ return externalWallets.find((w) => w.isExternalWithParaAuth);
1348
+ }
1349
+ get isExternalWalletAuth() {
1350
+ return !!this.externalWalletWithParaAuth && !this.email && !this.phone && !this.countryCode && !this.farcasterUsername && !this.telegramUserId;
1343
1351
  }
1344
1352
  get currentWalletIdsArray() {
1345
1353
  return this.supportedWalletTypes.reduce((acc, { type }) => {
@@ -1447,7 +1455,11 @@ var _ParaCore = class _ParaCore {
1447
1455
  ));
1448
1456
  }
1449
1457
  isWalletUsable(walletId, { type: types, scheme: schemes, forbidPregen = false } = {}, throwError = false) {
1458
+ var _a;
1450
1459
  let error;
1460
+ if ((_a = this.externalWallets) == null ? void 0 : _a[walletId]) {
1461
+ return true;
1462
+ }
1451
1463
  if (!this.wallets[walletId]) {
1452
1464
  error = `wallet with id ${walletId} does not exist`;
1453
1465
  } else {
@@ -1460,8 +1472,8 @@ var _ParaCore = class _ParaCore {
1460
1472
  } else if (!this.isWalletSupported(wallet)) {
1461
1473
  error = `wallet with id ${wallet == null ? void 0 : wallet.id} and type ${wallet == null ? void 0 : wallet.type} is not supported, supported types are: ${this.supportedWalletTypes.map(({ type }) => type).join(", ")}`;
1462
1474
  } else if (types && (!getEquivalentTypes(types).includes(wallet == null ? void 0 : wallet.type) || isOwned && !types.some((type) => {
1463
- var _a, _b;
1464
- return (_b = (_a = this.currentWalletIds) == null ? void 0 : _a[type]) == null ? void 0 : _b.includes(walletId);
1475
+ var _a2, _b;
1476
+ return (_b = (_a2 = this.currentWalletIds) == null ? void 0 : _a2[type]) == null ? void 0 : _b.includes(walletId);
1465
1477
  }))) {
1466
1478
  error = `wallet with id ${wallet == null ? void 0 : wallet.id} and type ${wallet == null ? void 0 : wallet.type} cannot be selected`;
1467
1479
  } else if (schemes && !schemes.includes(wallet == null ? void 0 : wallet.scheme)) {
@@ -1528,7 +1540,7 @@ var _ParaCore = class _ParaCore {
1528
1540
  }
1529
1541
  constructPortalUrl(_0) {
1530
1542
  return __async(this, arguments, function* (type, opts = {}) {
1531
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
1543
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
1532
1544
  const base = type === "onRamp" ? getPortalBaseURL(this.ctx) : yield this.getPortalURL(opts.partnerId);
1533
1545
  let path;
1534
1546
  switch (type) {
@@ -1580,7 +1592,10 @@ var _ParaCore = class _ParaCore {
1580
1592
  portalPrimaryButtonTextColor: this.portalPrimaryButtonTextColor,
1581
1593
  isForNewDevice: opts.isForNewDevice ? opts.isForNewDevice.toString() : void 0,
1582
1594
  supportedWalletTypes: __privateGet(this, _supportedWalletTypesOpt) ? JSON.stringify(__privateGet(this, _supportedWalletTypesOpt)) : void 0
1583
- }, isCreate || isLogin ? __spreadValues(__spreadValues(__spreadValues(__spreadValues({}, opts.authType === "email" ? { email: this.email } : {}), opts.authType === "phone" ? { phone: this.phone, countryCode: this.countryCode } : {}), opts.authType === "farcaster" ? { farcasterUsername: this.farcasterUsername } : {}), opts.authType === "telegram" ? { telegramUserId: this.telegramUserId } : {}) : {}), isLogin || isOnRamp ? { sessionId: opts.sessionId } : {}), isLogin ? {
1595
+ }, isCreate || isLogin ? __spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues({}, opts.authType === "email" ? { email: this.email } : {}), opts.authType === "phone" ? { phone: this.phone, countryCode: this.countryCode } : {}), opts.authType === "farcaster" ? { farcasterUsername: this.farcasterUsername } : {}), opts.authType === "telegram" ? { telegramUserId: this.telegramUserId } : {}), opts.authType === "externalWallet" ? {
1596
+ // Using id here since we store the bech32 address for cosmos in the address field of the wallet
1597
+ externalWalletAddress: (_n = this.externalWalletWithParaAuth) == null ? void 0 : _n.id
1598
+ } : {}) : {}), isLogin || isOnRamp ? { sessionId: opts.sessionId } : {}), isLogin ? {
1584
1599
  encryptionKey: opts.loginEncryptionPublicKey,
1585
1600
  newDeviceSessionLookupId: opts.newDeviceSessionId,
1586
1601
  newDeviceEncryptionKey: opts.newDeviceEncryptionKey,
@@ -1734,7 +1749,7 @@ var _ParaCore = class _ParaCore {
1734
1749
  * @param externalType - Type of external wallet to set.
1735
1750
  */
1736
1751
  setExternalWallet(_0) {
1737
- return __async(this, arguments, function* ({ address, type, provider, addressBech32 }) {
1752
+ return __async(this, arguments, function* ({ address, type, provider, addressBech32, withFullParaAuth }) {
1738
1753
  this.externalWallets = {
1739
1754
  [address]: {
1740
1755
  id: address,
@@ -1742,6 +1757,7 @@ var _ParaCore = class _ParaCore {
1742
1757
  type,
1743
1758
  name: provider,
1744
1759
  isExternal: true,
1760
+ isExternalWithParaAuth: withFullParaAuth,
1745
1761
  signer: ""
1746
1762
  }
1747
1763
  };
@@ -1860,6 +1876,23 @@ var _ParaCore = class _ParaCore {
1860
1876
  dispatchEvent(ParaEvent.WALLETS_CHANGE_EVENT, null);
1861
1877
  });
1862
1878
  }
1879
+ /**
1880
+ * Fetches the most recent OAuth account metadata for the signed-in user.
1881
+ * If applicable, this will include the user's most recent metadata from their Google, Apple, Facebook, X, Discord, Farcaster, or Telegram account, the last time they signed in to your app.
1882
+ * @returns {Promise<AccountMetadata>} the user's account metadata.
1883
+ */
1884
+ getAccountMetadata() {
1885
+ return __async(this, null, function* () {
1886
+ if (!(yield this.isSessionActive()) || !this.userId) {
1887
+ throw new Error("no signed-in user");
1888
+ }
1889
+ const {
1890
+ data: { partnerId }
1891
+ } = yield this.touchSession();
1892
+ const { accountMetadata } = yield this.ctx.client.getAccountMetadata(this.userId, partnerId);
1893
+ return accountMetadata;
1894
+ });
1895
+ }
1863
1896
  /**
1864
1897
  * Validates that a wallet ID is present on the instance, usable, and matches the desired filters.
1865
1898
  * If no ID is passed, this will instead return the first valid, usable wallet ID that matches the filters.
@@ -1912,18 +1945,18 @@ var _ParaCore = class _ParaCore {
1912
1945
  return wallet;
1913
1946
  }
1914
1947
  findWallet(idOrAddress, overrideType, filter = {}) {
1915
- var _b, _c;
1916
- if (!idOrAddress && Object.keys(this.externalWallets).length > 0) {
1948
+ var _a, _c, _d;
1949
+ if (!this.isExternalWalletAuth && !idOrAddress && Object.keys(this.externalWallets).length > 0) {
1917
1950
  return Object.values(this.externalWallets)[0];
1918
1951
  }
1919
- if (this.externalWallets[idOrAddress]) {
1952
+ if ((_a = this.externalWallets) == null ? void 0 : _a[idOrAddress]) {
1920
1953
  return this.externalWallets[idOrAddress];
1921
1954
  }
1922
1955
  try {
1923
1956
  const walletId = this.findWalletId(idOrAddress, filter);
1924
1957
  if (walletId && !!this.wallets[walletId]) {
1925
- const _a = this.wallets[walletId], { signer: _signer } = _a, wallet = __objRest(_a, ["signer"]);
1926
- const type = (_c = overrideType != null ? overrideType : (_b = this.currentWalletIdsArray.find(([id]) => id === walletId)) == null ? void 0 : _b[1]) != null ? _c : wallet.type;
1958
+ const _b = this.wallets[walletId], { signer: _signer } = _b, wallet = __objRest(_b, ["signer"]);
1959
+ const type = (_d = overrideType != null ? overrideType : (_c = this.currentWalletIdsArray.find(([id]) => id === walletId)) == null ? void 0 : _c[1]) != null ? _d : wallet.type;
1927
1960
  return __spreadProps(__spreadValues({}, wallet), {
1928
1961
  type: WalletType2[type]
1929
1962
  });
@@ -2207,7 +2240,8 @@ var _ParaCore = class _ParaCore {
2207
2240
  externalAddress: wallet.address,
2208
2241
  type: wallet.type,
2209
2242
  externalWalletProvider: wallet.provider,
2210
- shouldTrackUser: wallet.shouldTrackUser
2243
+ // If the wallet isn't using full Para auth we want to track the login here
2244
+ shouldTrackUser: !wallet.withFullParaAuth
2211
2245
  });
2212
2246
  yield this.setExternalWallet(wallet);
2213
2247
  yield this.setUserId(res.userId);
@@ -2215,10 +2249,10 @@ var _ParaCore = class _ParaCore {
2215
2249
  });
2216
2250
  }
2217
2251
  /**
2218
- * Returns whether or not the user is connected with an external wallet.
2252
+ * Returns whether or not the user is connected with only an external wallet, not an external wallet with Para auth.
2219
2253
  */
2220
2254
  isUsingExternalWallet() {
2221
- return !!Object.keys(this.externalWallets).length;
2255
+ return !this.isExternalWalletAuth && !!Object.keys(this.externalWallets).length;
2222
2256
  }
2223
2257
  /**
2224
2258
  * Passes the email code obtained from the user for verification.
@@ -2240,7 +2274,7 @@ var _ParaCore = class _ParaCore {
2240
2274
  cosmosSigner
2241
2275
  }) {
2242
2276
  yield this.ctx.client.verifyExternalWallet(this.userId, { address, signedMessage, cosmosPublicKeyHex, cosmosSigner });
2243
- return this.getSetUpBiometricsURL();
2277
+ return this.getSetUpBiometricsURL({ authType: "externalWallet" });
2244
2278
  });
2245
2279
  }
2246
2280
  /**
@@ -2494,15 +2528,20 @@ var _ParaCore = class _ParaCore {
2494
2528
  */
2495
2529
  getUserBiometricLocationHints() {
2496
2530
  return __async(this, null, function* () {
2497
- if (!this.email && !this.phone && !this.farcasterUsername && !this.telegramUserId) {
2498
- throw new Error("one of email, phone or farcaster username are required to get biometric location hints");
2531
+ var _a;
2532
+ if (!this.email && !this.phone && !this.farcasterUsername && !this.telegramUserId && !this.isExternalWalletAuth) {
2533
+ throw new Error(
2534
+ "one of email, phone, farcaster username, telegram user id or external wallet with Para auth are required to get biometric location hints"
2535
+ );
2499
2536
  }
2500
2537
  return yield this.ctx.client.getBiometricLocationHints({
2501
2538
  email: this.email,
2502
2539
  phone: this.phone,
2503
2540
  countryCode: this.countryCode,
2504
2541
  farcasterUsername: this.farcasterUsername,
2505
- telegramUserId: this.telegramUserId
2542
+ telegramUserId: this.telegramUserId,
2543
+ // Using id here since we store the bech32 address for cosmos in the address field of the wallet
2544
+ externalWalletAddress: (_a = this.externalWalletWithParaAuth) == null ? void 0 : _a.id
2506
2545
  });
2507
2546
  });
2508
2547
  }
@@ -2614,7 +2653,9 @@ var _ParaCore = class _ParaCore {
2614
2653
  waitForAccountCreation() {
2615
2654
  return __async(this, arguments, function* ({ popupWindow } = {}) {
2616
2655
  yield this.touchSession();
2617
- this.externalWallets = {};
2656
+ if (!this.isExternalWalletAuth) {
2657
+ this.externalWallets = {};
2658
+ }
2618
2659
  this.isAwaitingAccountCreation = true;
2619
2660
  while (this.isAwaitingAccountCreation) {
2620
2661
  try {
@@ -2782,7 +2823,9 @@ var _ParaCore = class _ParaCore {
2782
2823
  skipSessionRefresh = false
2783
2824
  } = {}) {
2784
2825
  var _a;
2785
- this.externalWallets = {};
2826
+ if (!this.isExternalWalletAuth) {
2827
+ this.externalWallets = {};
2828
+ }
2786
2829
  this.isAwaitingLogin = true;
2787
2830
  while (this.isAwaitingLogin) {
2788
2831
  try {
@@ -3249,6 +3292,12 @@ var _ParaCore = class _ParaCore {
3249
3292
  if (pregenWallets.length === 0) {
3250
3293
  return void 0;
3251
3294
  }
3295
+ const missingWallets = pregenWallets.filter((wallet) => !this.wallets[wallet.id]);
3296
+ if (missingWallets.length > 0) {
3297
+ throw new Error(
3298
+ `Cannot claim pregen wallets because wallet data is missing. Please call setUserShare first to load the wallet data for the following wallet IDs: ${missingWallets.map((w) => w.id).join(", ")}`
3299
+ );
3300
+ }
3252
3301
  let newRecoverySecret;
3253
3302
  const { walletIds } = yield this.ctx.client.claimPregenWallets({
3254
3303
  userId: this.userId,
@@ -3702,13 +3751,14 @@ var _ParaCore = class _ParaCore {
3702
3751
  }
3703
3752
  /**
3704
3753
  * Serialize the current session for import by another Para instance.
3754
+ * @param {boolean} excludeSigners - whether or not to exclude the signer from the exported wallets.
3705
3755
  * @returns {string} the serialized session
3706
3756
  */
3707
- exportSession() {
3757
+ exportSession({ excludeSigners } = {}) {
3708
3758
  const sessionInfo = {
3709
3759
  email: this.email,
3710
3760
  userId: this.userId,
3711
- wallets: this.wallets,
3761
+ wallets: structuredClone(this.wallets),
3712
3762
  currentWalletIds: this.currentWalletIds,
3713
3763
  sessionCookie: this.sessionCookie,
3714
3764
  phone: this.phone,
@@ -3717,6 +3767,11 @@ var _ParaCore = class _ParaCore {
3717
3767
  farcasterUsername: this.farcasterUsername,
3718
3768
  externalWallets: this.externalWallets
3719
3769
  };
3770
+ if (excludeSigners) {
3771
+ for (const wallet of Object.values(sessionInfo.wallets)) {
3772
+ delete wallet.signer;
3773
+ }
3774
+ }
3720
3775
  return Buffer.from(JSON.stringify(sessionInfo)).toString("base64");
3721
3776
  }
3722
3777
  /**
@@ -3840,6 +3895,14 @@ var _ParaCore = class _ParaCore {
3840
3895
  }),
3841
3896
  {}
3842
3897
  );
3898
+ const redactedExternalWallets = Object.keys(this.externalWallets).reduce(
3899
+ (acc, walletId) => __spreadProps(__spreadValues({}, acc), {
3900
+ [walletId]: __spreadProps(__spreadValues({}, this.externalWallets[walletId]), {
3901
+ signer: this.externalWallets[walletId].signer ? "[REDACTED]" : void 0
3902
+ })
3903
+ }),
3904
+ {}
3905
+ );
3843
3906
  const obj = {
3844
3907
  supportedWalletTypes: this.supportedWalletTypes,
3845
3908
  cosmosPrefix: this.cosmosPrefix,
@@ -3852,6 +3915,7 @@ var _ParaCore = class _ParaCore {
3852
3915
  pregenIds: this.pregenIds,
3853
3916
  currentWalletIds: this.currentWalletIds,
3854
3917
  wallets: redactedWallets,
3918
+ externalWallets: redactedExternalWallets,
3855
3919
  loginEncryptionKeyPair: this.loginEncryptionKeyPair ? "[REDACTED]" : void 0,
3856
3920
  ctx: {
3857
3921
  apiKey: this.ctx.apiKey,
Binary file
Binary file
@@ -0,0 +1,4 @@
1
+ {
2
+ "type": "module",
3
+ "sideEffects": false
4
+ }
@@ -1,4 +1,4 @@
1
- import Client, { AuthMethod, BackupKitEmailProps, CurrentWalletIds, EmailTheme, WalletEntity, WalletType, WalletParams, OAuthMethod, OnRampPurchaseCreateParams, OnRampPurchase, TPregenIdentifierType, PregenIds, BiometricLocationHint, TelegramAuthResponse, VerifyTelegramRes, Auth, ExternalWalletLoginRes } from '@getpara/user-management-client';
1
+ import Client, { AuthMethod, BackupKitEmailProps, CurrentWalletIds, EmailTheme, WalletEntity, WalletType, WalletParams, OAuthMethod, OnRampPurchaseCreateParams, OnRampPurchase, TPregenIdentifierType, PregenIds, BiometricLocationHint, TelegramAuthResponse, VerifyTelegramRes, Auth, ExternalWalletLoginRes, AccountMetadata } from '@getpara/user-management-client';
2
2
  import type { pki as pkiType } from 'node-forge';
3
3
  import { Ctx, Environment, Theme, FullSignatureRes, ExternalWalletInfo, GetWebAuthUrlForLoginParams, AccountSetupResponse, LoginResponse, WalletFilters, WalletTypeProp, Wallet, SupportedWalletTypes, PortalUrlOptions, ConstructorOpts, RecoveryStatus } from './types/index.js';
4
4
  import { PlatformUtils } from './PlatformUtils.js';
@@ -22,6 +22,8 @@ export declare abstract class ParaCore {
22
22
  get isPhone(): boolean;
23
23
  get isFarcaster(): boolean;
24
24
  get isTelegram(): boolean;
25
+ get externalWalletWithParaAuth(): Wallet | undefined;
26
+ get isExternalWalletAuth(): boolean;
25
27
  /**
26
28
  * 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.
27
29
  */
@@ -214,7 +216,7 @@ export declare abstract class ParaCore {
214
216
  * @param externalAddress - External wallet address to set.
215
217
  * @param externalType - Type of external wallet to set.
216
218
  */
217
- setExternalWallet({ address, type, provider, addressBech32 }: ExternalWalletInfo): Promise<void>;
219
+ setExternalWallet({ address, type, provider, addressBech32, withFullParaAuth }: ExternalWalletInfo): Promise<void>;
218
220
  /**
219
221
  * Sets the user id associated with the `ParaCore` instance.
220
222
  * @param userId - User id to set.
@@ -269,6 +271,12 @@ export declare abstract class ParaCore {
269
271
  sessionLookupId?: string;
270
272
  newDeviceSessionLookupId?: string;
271
273
  }): Promise<void>;
274
+ /**
275
+ * Fetches the most recent OAuth account metadata for the signed-in user.
276
+ * If applicable, this will include the user's most recent metadata from their Google, Apple, Facebook, X, Discord, Farcaster, or Telegram account, the last time they signed in to your app.
277
+ * @returns {Promise<AccountMetadata>} the user's account metadata.
278
+ */
279
+ getAccountMetadata(): Promise<AccountMetadata>;
272
280
  /**
273
281
  * The prefix for the instance's managed Cosmos wallets. Defaults to `'cosmos'`.
274
282
  */
@@ -385,7 +393,7 @@ export declare abstract class ParaCore {
385
393
  */
386
394
  externalWalletLogin(wallet: ExternalWalletInfo): Promise<ExternalWalletLoginRes>;
387
395
  /**
388
- * Returns whether or not the user is connected with an external wallet.
396
+ * Returns whether or not the user is connected with only an external wallet, not an external wallet with Para auth.
389
397
  */
390
398
  protected isUsingExternalWallet(): boolean;
391
399
  /**
@@ -906,9 +914,12 @@ export declare abstract class ParaCore {
906
914
  keepSessionAlive(): Promise<boolean>;
907
915
  /**
908
916
  * Serialize the current session for import by another Para instance.
917
+ * @param {boolean} excludeSigners - whether or not to exclude the signer from the exported wallets.
909
918
  * @returns {string} the serialized session
910
919
  */
911
- exportSession(): string;
920
+ exportSession({ excludeSigners }?: {
921
+ excludeSigners?: boolean;
922
+ }): string;
912
923
  /**
913
924
  * Imports a session serialized by another Para instance.
914
925
  * @param {string} serializedInstanceBase64 the serialized session
@@ -5,6 +5,7 @@ export declare const LOCAL_STORAGE_PHONE: string;
5
5
  export declare const LOCAL_STORAGE_COUNTRY_CODE: string;
6
6
  export declare const LOCAL_STORAGE_FARCASTER_USERNAME: string;
7
7
  export declare const LOCAL_STORAGE_TELEGRAM_USER_ID: string;
8
+ export declare const LOCAL_STORAGE_EXTERNAL_WALLET_USER_ID: string;
8
9
  export declare const LOCAL_STORAGE_USER_ID: string;
9
10
  export declare const LOCAL_STORAGE_ED25519_WALLETS: string;
10
11
  export declare const LOCAL_STORAGE_WALLETS: string;
@@ -7,7 +7,14 @@ export type ExternalWalletInfo = {
7
7
  type: ExternalWalletType;
8
8
  provider?: string;
9
9
  addressBech32?: string;
10
- shouldTrackUser?: boolean;
10
+ ensName?: string | null;
11
+ ensAvatar?: string | null;
12
+ withFullParaAuth?: boolean;
13
+ };
14
+ export type VerifyExternalWallet = {
15
+ signedMessage: string;
16
+ cosmosPublicKeyHex?: string;
17
+ cosmosSigner?: string;
11
18
  };
12
19
  export type PortalUrlOptions = {
13
20
  params?: Record<string, string | undefined | null>;
@@ -20,6 +20,9 @@ export interface Wallet {
20
20
  lastUsedPartner?: PartnerEntity;
21
21
  lastUsedPartnerId?: string;
22
22
  isExternal?: boolean;
23
+ ensName?: string | null;
24
+ ensAvatar?: string | null;
25
+ isExternalWithParaAuth?: boolean;
23
26
  }
24
27
  /** @deprecated */
25
28
  export declare enum PregenIdentifierType {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getpara/core-sdk",
3
- "version": "1.5.1",
3
+ "version": "1.7.0",
4
4
  "main": "dist/cjs/index.js",
5
5
  "module": "dist/esm/index.js",
6
6
  "types": "dist/types/index.d.ts",
@@ -9,7 +9,7 @@
9
9
  "dependencies": {
10
10
  "@celo/utils": "^8.0.0",
11
11
  "@cosmjs/encoding": "^0.32.4",
12
- "@getpara/user-management-client": "1.5.1",
12
+ "@getpara/user-management-client": "1.7.0",
13
13
  "@noble/hashes": "^1.5.0",
14
14
  "base64url": "^3.0.1",
15
15
  "ethereumjs-util": "7.1.5",
@@ -40,5 +40,5 @@
40
40
  "require": "./dist/cjs/index.js"
41
41
  }
42
42
  },
43
- "gitHead": "f77e0f5e162a1672219b01dbf7c06a3baadd2f35"
43
+ "gitHead": "241b03ee3d3502af3b8d702dabd615b266da10ae"
44
44
  }