@getpara/core-sdk 1.9.0 → 1.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/dist/cjs/ParaCore.js +86 -51
  2. package/dist/cjs/constants.js +1 -1
  3. package/dist/cjs/index.js +2 -0
  4. package/dist/cjs/utils/formatting.js +7 -3
  5. package/dist/cjs/utils/onRamps.js +32 -4
  6. package/dist/cjs/utils/wallet.js +18 -2
  7. package/dist/esm/ParaCore.js +88 -52
  8. package/dist/esm/{chunk-UICEQADR.js → chunk-7B52C2XE.js} +2 -0
  9. package/dist/esm/constants.js +2 -2
  10. package/dist/esm/cryptography/utils.js +1 -1
  11. package/dist/esm/errors.js +1 -1
  12. package/dist/esm/external/mpcComputationClient.js +1 -1
  13. package/dist/esm/external/userManagementClient.js +1 -1
  14. package/dist/esm/index.js +3 -2
  15. package/dist/esm/shares/KeyContainer.js +1 -1
  16. package/dist/esm/shares/recovery.js +1 -1
  17. package/dist/esm/shares/shareDistribution.js +1 -1
  18. package/dist/esm/transmission/transmissionUtils.js +1 -1
  19. package/dist/esm/types/config.js +1 -1
  20. package/dist/esm/types/events.js +1 -1
  21. package/dist/esm/types/index.js +1 -1
  22. package/dist/esm/types/onRamps.js +1 -1
  23. package/dist/esm/types/popup.js +1 -1
  24. package/dist/esm/types/recovery.js +1 -1
  25. package/dist/esm/types/wallet.js +1 -1
  26. package/dist/esm/utils/events.js +1 -1
  27. package/dist/esm/utils/formatting.js +8 -4
  28. package/dist/esm/utils/listeners.js +1 -1
  29. package/dist/esm/utils/onRamps.js +31 -5
  30. package/dist/esm/utils/polling.js +1 -1
  31. package/dist/esm/utils/url.js +1 -1
  32. package/dist/esm/utils/wallet.js +7 -2
  33. package/dist/types/ParaCore.d.ts +7 -3
  34. package/dist/types/index.d.ts +2 -2
  35. package/dist/types/types/params.d.ts +3 -0
  36. package/dist/types/utils/formatting.d.ts +2 -1
  37. package/dist/types/utils/onRamps.d.ts +10 -3
  38. package/dist/types/utils/wallet.d.ts +1 -0
  39. package/package.json +3 -3
@@ -61,6 +61,7 @@ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot
61
61
  var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
62
62
  var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
63
63
  var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
64
+ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
64
65
  var __async = (__this, __arguments, generator) => {
65
66
  return new Promise((resolve, reject) => {
66
67
  var fulfilled = (value) => {
@@ -100,7 +101,7 @@ var import_utils2 = require("./utils/index.js");
100
101
  var import_errors = require("./errors.js");
101
102
  var constants = __toESM(require("./constants.js"));
102
103
  var import_listeners = require("./utils/listeners.js");
103
- var _supportedWalletTypes, _supportedWalletTypesOpt;
104
+ var _supportedWalletTypes, _supportedWalletTypesOpt, _ParaCore_instances, createPregenWallet_fn;
104
105
  if (typeof global !== "undefined") {
105
106
  global.Buffer = global.Buffer || import_buffer.Buffer;
106
107
  } else if (typeof window !== "undefined") {
@@ -120,6 +121,7 @@ const _ParaCore = class _ParaCore {
120
121
  * @returns - A new ParaCore instance.
121
122
  */
122
123
  constructor(env, apiKey, opts) {
124
+ __privateAdd(this, _ParaCore_instances);
123
125
  this.isAwaitingAccountCreation = false;
124
126
  this.isAwaitingLogin = false;
125
127
  this.isAwaitingFarcaster = false;
@@ -523,25 +525,28 @@ const _ParaCore = class _ParaCore {
523
525
  * @returns the formatted address
524
526
  */
525
527
  getDisplayAddress(walletId, options = {}) {
526
- var _a;
528
+ var _a, _b;
527
529
  if (this.externalWallets[walletId]) {
528
530
  const wallet2 = this.externalWallets[walletId];
529
- return options.truncate ? (0, import_utils2.truncateAddress)(wallet2.address, wallet2.type, { prefix: this.cosmosPrefix }) : wallet2.address;
531
+ return options.truncate ? (0, import_utils2.truncateAddress)(wallet2.address, wallet2.type, { prefix: this.cosmosPrefix, targetLength: options.targetLength }) : wallet2.address;
530
532
  }
531
533
  const wallet = this.findWallet(walletId, options.addressType);
532
534
  if (!wallet) {
533
535
  return void 0;
534
536
  }
535
537
  let str;
538
+ let prefix;
536
539
  switch (wallet.type) {
537
540
  case import_user_management_client.WalletType.COSMOS:
538
- str = (0, import_utils2.getCosmosAddress)(wallet.publicKey, (_a = this.cosmosPrefix) != null ? _a : "cosmos");
541
+ prefix = (_b = (_a = options.cosmosPrefix) != null ? _a : this.cosmosPrefix) != null ? _b : "cosmos";
542
+ str = (0, import_utils2.getCosmosAddress)(wallet.publicKey, prefix);
539
543
  break;
540
544
  default:
545
+ prefix = this.cosmosPrefix;
541
546
  str = wallet.address;
542
547
  break;
543
548
  }
544
- return options.truncate ? (0, import_utils2.truncateAddress)(str, wallet.type, { prefix: this.cosmosPrefix }) : str;
549
+ return options.truncate ? (0, import_utils2.truncateAddress)(str, wallet.type, { prefix, targetLength: options.targetLength }) : str;
545
550
  }
546
551
  /**
547
552
  * Returns a unique hash for a wallet suitable for use as an identicon seed.
@@ -1527,10 +1532,16 @@ const _ParaCore = class _ParaCore {
1527
1532
  if (this.isUsingExternalWallet()) {
1528
1533
  return true;
1529
1534
  }
1535
+ if (this.isGuestMode) {
1536
+ return true;
1537
+ }
1530
1538
  const isSessionActive = yield this.isSessionActive();
1531
1539
  return isSessionActive && (this.isNoWalletConfig || this.currentWalletIdsArray.length > 0 && this.currentWalletIdsArray.reduce((acc, [id]) => acc && !!this.wallets[id], true));
1532
1540
  });
1533
1541
  }
1542
+ get isGuestMode() {
1543
+ return !this.userId && this.currentWalletIdsArray.length > 0 && this.currentWalletIdsArray.every(([id]) => !!this.wallets[id] && this.wallets[id].pregenIdentifierType === "GUEST_ID");
1544
+ }
1534
1545
  supportedAuthMethods(auth) {
1535
1546
  return __async(this, null, function* () {
1536
1547
  const { supportedAuthMethods } = yield this.ctx.client.getSupportedAuthMethods(auth);
@@ -2235,51 +2246,7 @@ const _ParaCore = class _ParaCore {
2235
2246
  **/
2236
2247
  createPregenWallet(opts) {
2237
2248
  return __async(this, null, function* () {
2238
- var _a, _b;
2239
- const {
2240
- type: _type = (_a = this.supportedWalletTypes.find(({ optional }) => !optional)) == null ? void 0 : _a.type,
2241
- pregenIdentifier,
2242
- pregenIdentifierType = "EMAIL"
2243
- } = opts;
2244
- this.requireApiKey();
2245
- const walletType = yield this.assertIsValidWalletType(
2246
- _type != null ? _type : (_b = this.supportedWalletTypes.find(({ optional }) => !optional)) == null ? void 0 : _b.type
2247
- );
2248
- let keygenRes;
2249
- switch (walletType) {
2250
- case import_user_management_client.WalletType.SOLANA:
2251
- keygenRes = yield this.platformUtils.ed25519PreKeygen(
2252
- this.ctx,
2253
- pregenIdentifier,
2254
- pregenIdentifierType,
2255
- this.retrieveSessionCookie()
2256
- );
2257
- break;
2258
- default:
2259
- keygenRes = yield this.platformUtils.preKeygen(
2260
- this.ctx,
2261
- void 0,
2262
- pregenIdentifier,
2263
- pregenIdentifierType,
2264
- walletType,
2265
- null,
2266
- this.retrieveSessionCookie()
2267
- );
2268
- break;
2269
- }
2270
- const { signer, walletId } = keygenRes;
2271
- this.wallets[walletId] = {
2272
- id: walletId,
2273
- signer,
2274
- scheme: walletType === import_user_management_client.WalletType.SOLANA ? import_user_management_client.WalletScheme.ED25519 : import_user_management_client.WalletScheme.DKLS,
2275
- type: walletType,
2276
- isPregen: true,
2277
- pregenIdentifier,
2278
- pregenIdentifierType
2279
- };
2280
- yield this.waitForPregenWalletAddress(walletId);
2281
- yield this.populatePregenWalletAddresses();
2282
- return this.wallets[walletId];
2249
+ return yield __privateMethod(this, _ParaCore_instances, createPregenWallet_fn).call(this, opts);
2283
2250
  });
2284
2251
  }
2285
2252
  /**
@@ -2300,7 +2267,7 @@ const _ParaCore = class _ParaCore {
2300
2267
  }) {
2301
2268
  const wallets = [];
2302
2269
  for (const type of yield this.getTypesToCreate(types)) {
2303
- const wallet = yield this.createPregenWallet({ type, pregenIdentifier, pregenIdentifierType });
2270
+ const wallet = yield __privateMethod(this, _ParaCore_instances, createPregenWallet_fn).call(this, { type, pregenIdentifier, pregenIdentifierType });
2304
2271
  wallets.push(wallet);
2305
2272
  }
2306
2273
  return wallets;
@@ -2449,6 +2416,24 @@ const _ParaCore = class _ParaCore {
2449
2416
  return res.wallets.filter((w) => this.isWalletSupported((0, import_utils2.entityToWallet)(w)));
2450
2417
  });
2451
2418
  }
2419
+ createGuestWallets() {
2420
+ return __async(this, arguments, function* ({ types } = {}) {
2421
+ const wallets = [];
2422
+ const currentWalletIds = {};
2423
+ const guestId = (0, import_utils2.newUuid)();
2424
+ for (const type of yield this.getTypesToCreate(
2425
+ types != null ? types : this.supportedWalletTypes.filter(({ optional }) => !optional).map(({ type: type2 }) => type2)
2426
+ )) {
2427
+ const wallet = yield __privateMethod(this, _ParaCore_instances, createPregenWallet_fn).call(this, { type, pregenIdentifier: guestId, pregenIdentifierType: "GUEST_ID" });
2428
+ wallets.push(wallet);
2429
+ (0, import_utils2.getEquivalentTypes)(type).filter((t) => __privateGet(this, _supportedWalletTypes).some(({ type: type2, optional }) => t === type2 && !optional)).forEach((eqType) => {
2430
+ currentWalletIds[eqType] = [wallet.id];
2431
+ });
2432
+ }
2433
+ yield this.setCurrentWalletIds(currentWalletIds);
2434
+ return wallets;
2435
+ });
2436
+ }
2452
2437
  encodeWalletBase64(wallet) {
2453
2438
  const walletJson = JSON.stringify(wallet);
2454
2439
  const base64Wallet = Buffer.from(walletJson).toString("base64");
@@ -2966,6 +2951,56 @@ const _ParaCore = class _ParaCore {
2966
2951
  };
2967
2952
  _supportedWalletTypes = new WeakMap();
2968
2953
  _supportedWalletTypesOpt = new WeakMap();
2954
+ _ParaCore_instances = new WeakSet();
2955
+ createPregenWallet_fn = function(opts) {
2956
+ return __async(this, null, function* () {
2957
+ var _a, _b;
2958
+ const {
2959
+ type: _type = (_a = this.supportedWalletTypes.find(({ optional }) => !optional)) == null ? void 0 : _a.type,
2960
+ pregenIdentifier,
2961
+ pregenIdentifierType = "EMAIL"
2962
+ } = opts;
2963
+ this.requireApiKey();
2964
+ const walletType = yield this.assertIsValidWalletType(
2965
+ _type != null ? _type : (_b = this.supportedWalletTypes.find(({ optional }) => !optional)) == null ? void 0 : _b.type
2966
+ );
2967
+ let keygenRes;
2968
+ switch (walletType) {
2969
+ case import_user_management_client.WalletType.SOLANA:
2970
+ keygenRes = yield this.platformUtils.ed25519PreKeygen(
2971
+ this.ctx,
2972
+ pregenIdentifier,
2973
+ pregenIdentifierType,
2974
+ this.retrieveSessionCookie()
2975
+ );
2976
+ break;
2977
+ default:
2978
+ keygenRes = yield this.platformUtils.preKeygen(
2979
+ this.ctx,
2980
+ void 0,
2981
+ pregenIdentifier,
2982
+ pregenIdentifierType,
2983
+ walletType,
2984
+ null,
2985
+ this.retrieveSessionCookie()
2986
+ );
2987
+ break;
2988
+ }
2989
+ const { signer, walletId } = keygenRes;
2990
+ this.wallets[walletId] = {
2991
+ id: walletId,
2992
+ signer,
2993
+ scheme: walletType === import_user_management_client.WalletType.SOLANA ? import_user_management_client.WalletScheme.ED25519 : import_user_management_client.WalletScheme.DKLS,
2994
+ type: walletType,
2995
+ isPregen: true,
2996
+ pregenIdentifier,
2997
+ pregenIdentifierType
2998
+ };
2999
+ yield this.waitForPregenWalletAddress(walletId);
3000
+ yield this.populatePregenWalletAddresses();
3001
+ return this.wallets[walletId];
3002
+ });
3003
+ };
2969
3004
  _ParaCore.version = constants.PARA_CORE_VERSION;
2970
3005
  let ParaCore = _ParaCore;
2971
3006
  // Annotate the CommonJS export names for ESM import in node:
@@ -36,7 +36,7 @@ __export(constants_exports, {
36
36
  SHORT_POLLING_INTERVAL_MS: () => SHORT_POLLING_INTERVAL_MS
37
37
  });
38
38
  module.exports = __toCommonJS(constants_exports);
39
- const PARA_CORE_VERSION = '1.9.0';
39
+ const PARA_CORE_VERSION = '1.11.0';
40
40
  const PREFIX = "@CAPSULE/";
41
41
  const LOCAL_STORAGE_EMAIL = `${PREFIX}e-mail`;
42
42
  const LOCAL_STORAGE_PHONE = `${PREFIX}phone`;
package/dist/cjs/index.js CHANGED
@@ -61,6 +61,7 @@ __export(src_exports, {
61
61
  getAsymmetricKeyPair: () => import_utils2.getAsymmetricKeyPair,
62
62
  getBaseUrl: () => import_userManagementClient.getBaseUrl,
63
63
  getDerivedPrivateKeyAndDecrypt: () => import_utils2.getDerivedPrivateKeyAndDecrypt,
64
+ getNetworkPrefix: () => import_onRamps.getNetworkPrefix,
64
65
  getOnRampAssets: () => import_onRamps.getOnRampAssets,
65
66
  getOnRampNetworks: () => import_onRamps.getOnRampNetworks,
66
67
  getPortalBaseURL: () => import_url.getPortalBaseURL,
@@ -135,6 +136,7 @@ var src_default = import_ParaCore.ParaCore;
135
136
  getAsymmetricKeyPair,
136
137
  getBaseUrl,
137
138
  getDerivedPrivateKeyAndDecrypt,
139
+ getNetworkPrefix,
138
140
  getOnRampAssets,
139
141
  getOnRampNetworks,
140
142
  getPortalBaseURL,
@@ -95,9 +95,13 @@ function getCosmosAddress(publicKey, prefix) {
95
95
  const compressedPublicKey = compressPubkey(uncompressedPublicKey);
96
96
  return (0, import_encoding.toBech32)(prefix, rawSecp256k1PubkeyToRawAddress(compressedPublicKey));
97
97
  }
98
- function truncateAddress(str, addressType, { prefix = addressType === "COSMOS" ? "cosmos" : void 0 } = {}) {
99
- const headLength = (addressType === "COSMOS" ? prefix.length : addressType === "SOLANA" ? 0 : 2) + 4;
100
- return `${str.slice(0, headLength)}...${str.slice(-4)}`;
98
+ function truncateAddress(str, addressType, {
99
+ prefix = addressType === "COSMOS" ? "cosmos" : void 0,
100
+ targetLength
101
+ } = {}) {
102
+ const minimum = addressType === "COSMOS" ? prefix.length : addressType === "EVM" ? 2 : 0;
103
+ const margin = targetLength !== void 0 ? (targetLength - minimum) / 2 : 4;
104
+ return `${str.slice(0, minimum + margin)}...${str.slice(-1 * margin)}`;
101
105
  }
102
106
  function stringToPhoneNumber(str) {
103
107
  var _a;
@@ -17,11 +17,14 @@ var __copyProps = (to, from, except, desc) => {
17
17
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
18
  var onRamps_exports = {};
19
19
  __export(onRamps_exports, {
20
+ NETWORK_PREFIXES: () => NETWORK_PREFIXES,
21
+ getNetworkPrefix: () => getNetworkPrefix,
20
22
  getOnRampAssets: () => getOnRampAssets,
21
23
  getOnRampNetworks: () => getOnRampNetworks,
22
24
  toAssetInfoArray: () => toAssetInfoArray
23
25
  });
24
26
  module.exports = __toCommonJS(onRamps_exports);
27
+ var import_user_management_client = require("@getpara/user-management-client");
25
28
  function toAssetInfoArray(data) {
26
29
  const result = [];
27
30
  Object.keys(data).forEach((walletType) => {
@@ -36,28 +39,53 @@ function toAssetInfoArray(data) {
36
39
  });
37
40
  return result;
38
41
  }
39
- function getOnRampNetworks(data, { walletType, allowed } = {}) {
42
+ function getOnRampNetworks(data, {
43
+ walletType,
44
+ allowed,
45
+ assets,
46
+ providers,
47
+ action
48
+ } = {}) {
40
49
  return [
41
50
  ...new Set(
42
- toAssetInfoArray(data).filter(([type, network]) => (!walletType || type === walletType) && (!allowed || allowed.includes(network))).map(([_, network]) => network)
51
+ toAssetInfoArray(data).filter(
52
+ ([type, network, asset, providerInfo]) => (!walletType || type === walletType) && (!allowed || allowed.includes(network)) && (!assets || assets.includes(asset)) && (!providers || providers.some((provider) => {
53
+ var _a;
54
+ return ((_a = providerInfo[provider]) == null ? void 0 : _a[1]) && (!action || providerInfo[provider][1][action]);
55
+ }))
56
+ ).map(([_, network]) => network)
43
57
  )
44
58
  ];
45
59
  }
46
60
  function getOnRampAssets(data, {
47
61
  walletType,
48
62
  network,
49
- allowed
63
+ allowed,
64
+ providers,
65
+ action
50
66
  } = {}) {
51
67
  return [
52
68
  ...new Set(
53
69
  toAssetInfoArray(data).filter(
54
- ([t, n, a]) => (!walletType || t === walletType) && (!network || n === network) && (!Array.isArray(allowed) || allowed.includes(a))
70
+ ([t, n, a, p]) => (!walletType || t === walletType) && (!network || n === network) && (!Array.isArray(allowed) || allowed.includes(a)) && (!providers || providers.some((provider) => {
71
+ var _a;
72
+ return ((_a = p[provider]) == null ? void 0 : _a[1]) && (!action || p[provider][1][action]);
73
+ }))
55
74
  ).map(([, , asset]) => asset)
56
75
  )
57
76
  ];
58
77
  }
78
+ const NETWORK_PREFIXES = {
79
+ [import_user_management_client.Network.COSMOS]: "cosmos",
80
+ [import_user_management_client.Network.NOBLE]: "noble"
81
+ };
82
+ function getNetworkPrefix(network) {
83
+ return NETWORK_PREFIXES[network];
84
+ }
59
85
  // Annotate the CommonJS export names for ESM import in node:
60
86
  0 && (module.exports = {
87
+ NETWORK_PREFIXES,
88
+ getNetworkPrefix,
61
89
  getOnRampAssets,
62
90
  getOnRampNetworks,
63
91
  toAssetInfoArray
@@ -1,9 +1,11 @@
1
+ var __create = Object.create;
1
2
  var __defProp = Object.defineProperty;
2
3
  var __defProps = Object.defineProperties;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
5
  var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
5
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
7
  var __getOwnPropSymbols = Object.getOwnPropertySymbols;
8
+ var __getProtoOf = Object.getPrototypeOf;
7
9
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
10
  var __propIsEnum = Object.prototype.propertyIsEnumerable;
9
11
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
@@ -31,6 +33,14 @@ var __copyProps = (to, from, except, desc) => {
31
33
  }
32
34
  return to;
33
35
  };
36
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
37
+ // If the importer is in node compatibility mode or this is not an ESM
38
+ // file that has been converted to a CommonJS file using a Babel-
39
+ // compatible transform (i.e. "__esModule" has not been set), then set
40
+ // "default" to the CommonJS "module.exports" for node compatibility.
41
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
42
+ mod
43
+ ));
34
44
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
35
45
  var wallet_exports = {};
36
46
  __export(wallet_exports, {
@@ -41,9 +51,11 @@ __export(wallet_exports, {
41
51
  getWalletTypes: () => getWalletTypes,
42
52
  isPregenIdentifierMatch: () => isPregenIdentifierMatch,
43
53
  isWalletSupported: () => isWalletSupported,
44
- migrateWallet: () => migrateWallet
54
+ migrateWallet: () => migrateWallet,
55
+ newUuid: () => newUuid
45
56
  });
46
57
  module.exports = __toCommonJS(wallet_exports);
58
+ var uuid = __toESM(require("uuid"));
47
59
  var import_user_management_client = require("@getpara/user-management-client");
48
60
  var import_formatting = require("./formatting.js");
49
61
  const WalletSchemeTypeMap = {
@@ -117,6 +129,9 @@ function migrateWallet(obj) {
117
129
  }
118
130
  return obj;
119
131
  }
132
+ function newUuid() {
133
+ return uuid.v4();
134
+ }
120
135
  // Annotate the CommonJS export names for ESM import in node:
121
136
  0 && (module.exports = {
122
137
  WalletSchemeTypeMap,
@@ -126,5 +141,6 @@ function migrateWallet(obj) {
126
141
  getWalletTypes,
127
142
  isPregenIdentifierMatch,
128
143
  isWalletSupported,
129
- migrateWallet
144
+ migrateWallet,
145
+ newUuid
130
146
  });
@@ -3,11 +3,12 @@ import {
3
3
  __objRest,
4
4
  __privateAdd,
5
5
  __privateGet,
6
+ __privateMethod,
6
7
  __privateSet,
7
8
  __spreadProps,
8
9
  __spreadValues
9
- } from "./chunk-UICEQADR.js";
10
- var _supportedWalletTypes, _supportedWalletTypesOpt;
10
+ } from "./chunk-7B52C2XE.js";
11
+ var _supportedWalletTypes, _supportedWalletTypesOpt, _ParaCore_instances, createPregenWallet_fn;
11
12
  import { Buffer as NodeBuffer } from "buffer";
12
13
  if (typeof global !== "undefined") {
13
14
  global.Buffer = global.Buffer || NodeBuffer;
@@ -54,6 +55,7 @@ import {
54
55
  isPregenIdentifierMatch,
55
56
  isWalletSupported,
56
57
  migrateWallet,
58
+ newUuid,
57
59
  normalizePhoneNumber,
58
60
  truncateAddress,
59
61
  WalletSchemeTypeMap
@@ -70,6 +72,7 @@ const _ParaCore = class _ParaCore {
70
72
  * @returns - A new ParaCore instance.
71
73
  */
72
74
  constructor(env, apiKey, opts) {
75
+ __privateAdd(this, _ParaCore_instances);
73
76
  this.isAwaitingAccountCreation = false;
74
77
  this.isAwaitingLogin = false;
75
78
  this.isAwaitingFarcaster = false;
@@ -473,25 +476,28 @@ const _ParaCore = class _ParaCore {
473
476
  * @returns the formatted address
474
477
  */
475
478
  getDisplayAddress(walletId, options = {}) {
476
- var _a;
479
+ var _a, _b;
477
480
  if (this.externalWallets[walletId]) {
478
481
  const wallet2 = this.externalWallets[walletId];
479
- return options.truncate ? truncateAddress(wallet2.address, wallet2.type, { prefix: this.cosmosPrefix }) : wallet2.address;
482
+ return options.truncate ? truncateAddress(wallet2.address, wallet2.type, { prefix: this.cosmosPrefix, targetLength: options.targetLength }) : wallet2.address;
480
483
  }
481
484
  const wallet = this.findWallet(walletId, options.addressType);
482
485
  if (!wallet) {
483
486
  return void 0;
484
487
  }
485
488
  let str;
489
+ let prefix;
486
490
  switch (wallet.type) {
487
491
  case WalletType.COSMOS:
488
- str = getCosmosAddress(wallet.publicKey, (_a = this.cosmosPrefix) != null ? _a : "cosmos");
492
+ prefix = (_b = (_a = options.cosmosPrefix) != null ? _a : this.cosmosPrefix) != null ? _b : "cosmos";
493
+ str = getCosmosAddress(wallet.publicKey, prefix);
489
494
  break;
490
495
  default:
496
+ prefix = this.cosmosPrefix;
491
497
  str = wallet.address;
492
498
  break;
493
499
  }
494
- return options.truncate ? truncateAddress(str, wallet.type, { prefix: this.cosmosPrefix }) : str;
500
+ return options.truncate ? truncateAddress(str, wallet.type, { prefix, targetLength: options.targetLength }) : str;
495
501
  }
496
502
  /**
497
503
  * Returns a unique hash for a wallet suitable for use as an identicon seed.
@@ -1477,10 +1483,16 @@ const _ParaCore = class _ParaCore {
1477
1483
  if (this.isUsingExternalWallet()) {
1478
1484
  return true;
1479
1485
  }
1486
+ if (this.isGuestMode) {
1487
+ return true;
1488
+ }
1480
1489
  const isSessionActive = yield this.isSessionActive();
1481
1490
  return isSessionActive && (this.isNoWalletConfig || this.currentWalletIdsArray.length > 0 && this.currentWalletIdsArray.reduce((acc, [id]) => acc && !!this.wallets[id], true));
1482
1491
  });
1483
1492
  }
1493
+ get isGuestMode() {
1494
+ return !this.userId && this.currentWalletIdsArray.length > 0 && this.currentWalletIdsArray.every(([id]) => !!this.wallets[id] && this.wallets[id].pregenIdentifierType === "GUEST_ID");
1495
+ }
1484
1496
  supportedAuthMethods(auth) {
1485
1497
  return __async(this, null, function* () {
1486
1498
  const { supportedAuthMethods } = yield this.ctx.client.getSupportedAuthMethods(auth);
@@ -2185,51 +2197,7 @@ const _ParaCore = class _ParaCore {
2185
2197
  **/
2186
2198
  createPregenWallet(opts) {
2187
2199
  return __async(this, null, function* () {
2188
- var _a, _b;
2189
- const {
2190
- type: _type = (_a = this.supportedWalletTypes.find(({ optional }) => !optional)) == null ? void 0 : _a.type,
2191
- pregenIdentifier,
2192
- pregenIdentifierType = "EMAIL"
2193
- } = opts;
2194
- this.requireApiKey();
2195
- const walletType = yield this.assertIsValidWalletType(
2196
- _type != null ? _type : (_b = this.supportedWalletTypes.find(({ optional }) => !optional)) == null ? void 0 : _b.type
2197
- );
2198
- let keygenRes;
2199
- switch (walletType) {
2200
- case WalletType.SOLANA:
2201
- keygenRes = yield this.platformUtils.ed25519PreKeygen(
2202
- this.ctx,
2203
- pregenIdentifier,
2204
- pregenIdentifierType,
2205
- this.retrieveSessionCookie()
2206
- );
2207
- break;
2208
- default:
2209
- keygenRes = yield this.platformUtils.preKeygen(
2210
- this.ctx,
2211
- void 0,
2212
- pregenIdentifier,
2213
- pregenIdentifierType,
2214
- walletType,
2215
- null,
2216
- this.retrieveSessionCookie()
2217
- );
2218
- break;
2219
- }
2220
- const { signer, walletId } = keygenRes;
2221
- this.wallets[walletId] = {
2222
- id: walletId,
2223
- signer,
2224
- scheme: walletType === WalletType.SOLANA ? WalletScheme.ED25519 : WalletScheme.DKLS,
2225
- type: walletType,
2226
- isPregen: true,
2227
- pregenIdentifier,
2228
- pregenIdentifierType
2229
- };
2230
- yield this.waitForPregenWalletAddress(walletId);
2231
- yield this.populatePregenWalletAddresses();
2232
- return this.wallets[walletId];
2200
+ return yield __privateMethod(this, _ParaCore_instances, createPregenWallet_fn).call(this, opts);
2233
2201
  });
2234
2202
  }
2235
2203
  /**
@@ -2250,7 +2218,7 @@ const _ParaCore = class _ParaCore {
2250
2218
  }) {
2251
2219
  const wallets = [];
2252
2220
  for (const type of yield this.getTypesToCreate(types)) {
2253
- const wallet = yield this.createPregenWallet({ type, pregenIdentifier, pregenIdentifierType });
2221
+ const wallet = yield __privateMethod(this, _ParaCore_instances, createPregenWallet_fn).call(this, { type, pregenIdentifier, pregenIdentifierType });
2254
2222
  wallets.push(wallet);
2255
2223
  }
2256
2224
  return wallets;
@@ -2399,6 +2367,24 @@ const _ParaCore = class _ParaCore {
2399
2367
  return res.wallets.filter((w) => this.isWalletSupported(entityToWallet(w)));
2400
2368
  });
2401
2369
  }
2370
+ createGuestWallets() {
2371
+ return __async(this, arguments, function* ({ types } = {}) {
2372
+ const wallets = [];
2373
+ const currentWalletIds = {};
2374
+ const guestId = newUuid();
2375
+ for (const type of yield this.getTypesToCreate(
2376
+ types != null ? types : this.supportedWalletTypes.filter(({ optional }) => !optional).map(({ type: type2 }) => type2)
2377
+ )) {
2378
+ const wallet = yield __privateMethod(this, _ParaCore_instances, createPregenWallet_fn).call(this, { type, pregenIdentifier: guestId, pregenIdentifierType: "GUEST_ID" });
2379
+ wallets.push(wallet);
2380
+ getEquivalentTypes(type).filter((t) => __privateGet(this, _supportedWalletTypes).some(({ type: type2, optional }) => t === type2 && !optional)).forEach((eqType) => {
2381
+ currentWalletIds[eqType] = [wallet.id];
2382
+ });
2383
+ }
2384
+ yield this.setCurrentWalletIds(currentWalletIds);
2385
+ return wallets;
2386
+ });
2387
+ }
2402
2388
  encodeWalletBase64(wallet) {
2403
2389
  const walletJson = JSON.stringify(wallet);
2404
2390
  const base64Wallet = Buffer.from(walletJson).toString("base64");
@@ -2916,6 +2902,56 @@ const _ParaCore = class _ParaCore {
2916
2902
  };
2917
2903
  _supportedWalletTypes = new WeakMap();
2918
2904
  _supportedWalletTypesOpt = new WeakMap();
2905
+ _ParaCore_instances = new WeakSet();
2906
+ createPregenWallet_fn = function(opts) {
2907
+ return __async(this, null, function* () {
2908
+ var _a, _b;
2909
+ const {
2910
+ type: _type = (_a = this.supportedWalletTypes.find(({ optional }) => !optional)) == null ? void 0 : _a.type,
2911
+ pregenIdentifier,
2912
+ pregenIdentifierType = "EMAIL"
2913
+ } = opts;
2914
+ this.requireApiKey();
2915
+ const walletType = yield this.assertIsValidWalletType(
2916
+ _type != null ? _type : (_b = this.supportedWalletTypes.find(({ optional }) => !optional)) == null ? void 0 : _b.type
2917
+ );
2918
+ let keygenRes;
2919
+ switch (walletType) {
2920
+ case WalletType.SOLANA:
2921
+ keygenRes = yield this.platformUtils.ed25519PreKeygen(
2922
+ this.ctx,
2923
+ pregenIdentifier,
2924
+ pregenIdentifierType,
2925
+ this.retrieveSessionCookie()
2926
+ );
2927
+ break;
2928
+ default:
2929
+ keygenRes = yield this.platformUtils.preKeygen(
2930
+ this.ctx,
2931
+ void 0,
2932
+ pregenIdentifier,
2933
+ pregenIdentifierType,
2934
+ walletType,
2935
+ null,
2936
+ this.retrieveSessionCookie()
2937
+ );
2938
+ break;
2939
+ }
2940
+ const { signer, walletId } = keygenRes;
2941
+ this.wallets[walletId] = {
2942
+ id: walletId,
2943
+ signer,
2944
+ scheme: walletType === WalletType.SOLANA ? WalletScheme.ED25519 : WalletScheme.DKLS,
2945
+ type: walletType,
2946
+ isPregen: true,
2947
+ pregenIdentifier,
2948
+ pregenIdentifierType
2949
+ };
2950
+ yield this.waitForPregenWalletAddress(walletId);
2951
+ yield this.populatePregenWalletAddresses();
2952
+ return this.wallets[walletId];
2953
+ });
2954
+ };
2919
2955
  _ParaCore.version = constants.PARA_CORE_VERSION;
2920
2956
  let ParaCore = _ParaCore;
2921
2957
  export {
@@ -36,6 +36,7 @@ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot
36
36
  var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
37
37
  var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
38
38
  var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
39
+ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
39
40
  var __async = (__this, __arguments, generator) => {
40
41
  return new Promise((resolve, reject) => {
41
42
  var fulfilled = (value) => {
@@ -64,5 +65,6 @@ export {
64
65
  __privateGet,
65
66
  __privateAdd,
66
67
  __privateSet,
68
+ __privateMethod,
67
69
  __async
68
70
  };
@@ -1,5 +1,5 @@
1
- import "./chunk-UICEQADR.js";
2
- const PARA_CORE_VERSION = '1.9.0';
1
+ import "./chunk-7B52C2XE.js";
2
+ const PARA_CORE_VERSION = '1.11.0';
3
3
  const PREFIX = "@CAPSULE/";
4
4
  const LOCAL_STORAGE_EMAIL = `${PREFIX}e-mail`;
5
5
  const LOCAL_STORAGE_PHONE = `${PREFIX}phone`;
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  __async
3
- } from "../chunk-UICEQADR.js";
3
+ } from "../chunk-7B52C2XE.js";
4
4
  import base64url from "base64url";
5
5
  import forge from "node-forge";
6
6
  import { getPortalBaseURL } from "../utils/index.js";
@@ -1,4 +1,4 @@
1
- import "./chunk-UICEQADR.js";
1
+ import "./chunk-7B52C2XE.js";
2
2
  class TransactionReviewError extends Error {
3
3
  constructor(transactionReviewUrl) {
4
4
  super("transaction review error");
@@ -1,4 +1,4 @@
1
- import "../chunk-UICEQADR.js";
1
+ import "../chunk-7B52C2XE.js";
2
2
  import axios from "axios";
3
3
  function initClient(baseURL, useAdapter) {
4
4
  const client = axios.create({ baseURL });
@@ -1,4 +1,4 @@
1
- import "../chunk-UICEQADR.js";
1
+ import "../chunk-7B52C2XE.js";
2
2
  import Client from "@getpara/user-management-client";
3
3
  import { Environment } from "../types/index.js";
4
4
  function getBaseOAuthUrl(env) {
package/dist/esm/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import "./chunk-UICEQADR.js";
1
+ import "./chunk-7B52C2XE.js";
2
2
  import { ParaCore } from "./ParaCore.js";
3
3
  import {
4
4
  AuthMethod,
@@ -51,7 +51,7 @@ export * from "./errors.js";
51
51
  export * from "./utils/formatting.js";
52
52
  export * from "./utils/polling.js";
53
53
  import { isWalletSupported } from "./utils/wallet.js";
54
- import { getOnRampAssets, getOnRampNetworks, toAssetInfoArray } from "./utils/onRamps.js";
54
+ import { getNetworkPrefix, getOnRampAssets, getOnRampNetworks, toAssetInfoArray } from "./utils/onRamps.js";
55
55
  import { getPortalBaseURL } from "./utils/url.js";
56
56
  import { retrieve } from "./transmission/transmissionUtils.js";
57
57
  const paraVersion = ParaCore.version;
@@ -90,6 +90,7 @@ export {
90
90
  getAsymmetricKeyPair,
91
91
  getBaseUrl,
92
92
  getDerivedPrivateKeyAndDecrypt,
93
+ getNetworkPrefix,
93
94
  getOnRampAssets,
94
95
  getOnRampNetworks,
95
96
  getPortalBaseURL,
@@ -1,4 +1,4 @@
1
- import "../chunk-UICEQADR.js";
1
+ import "../chunk-7B52C2XE.js";
2
2
  import { Encrypt as ECIESEncrypt, Decrypt as ECIESDecrypt } from "@celo/utils/lib/ecies.js";
3
3
  import * as eutil from "@ethereumjs/util";
4
4
  import * as forge from "node-forge";
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  __async,
3
3
  __spreadValues
4
- } from "../chunk-UICEQADR.js";
4
+ } from "../chunk-7B52C2XE.js";
5
5
  import { EncryptorType, KeyShareType } from "@getpara/user-management-client";
6
6
  import { KeyContainer } from "./KeyContainer.js";
7
7
  function sendRecoveryForShare(_0) {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  __async
3
- } from "../chunk-UICEQADR.js";
3
+ } from "../chunk-7B52C2XE.js";
4
4
  import { EncryptorType, KeyShareType } from "@getpara/user-management-client";
5
5
  import { encryptWithDerivedPublicKey } from "../cryptography/utils.js";
6
6
  import { sendRecoveryForShare } from "./recovery.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  __async
3
- } from "../chunk-UICEQADR.js";
3
+ } from "../chunk-7B52C2XE.js";
4
4
  import { Encrypt as ECIESEncrypt, Decrypt as ECIESDecrypt } from "@celo/utils/lib/ecies.js";
5
5
  import { Buffer } from "buffer";
6
6
  import * as eutil from "@ethereumjs/util";
@@ -1,4 +1,4 @@
1
- import "../chunk-UICEQADR.js";
1
+ import "../chunk-7B52C2XE.js";
2
2
  var Environment = /* @__PURE__ */ ((Environment2) => {
3
3
  Environment2["DEV"] = "DEV";
4
4
  Environment2["SANDBOX"] = "SANDBOX";
@@ -1,4 +1,4 @@
1
- import "../chunk-UICEQADR.js";
1
+ import "../chunk-7B52C2XE.js";
2
2
  const EVENT_PREFIX = "para";
3
3
  var ParaEvent = ((ParaEvent2) => {
4
4
  ParaEvent2["LOGIN_EVENT"] = `${EVENT_PREFIX}Login`;
@@ -1,4 +1,4 @@
1
- import "../chunk-UICEQADR.js";
1
+ import "../chunk-7B52C2XE.js";
2
2
  export * from "./config.js";
3
3
  export * from "./wallet.js";
4
4
  export * from "./params.js";
@@ -1,4 +1,4 @@
1
- import "../chunk-UICEQADR.js";
1
+ import "../chunk-7B52C2XE.js";
2
2
  var OnRampMethod = /* @__PURE__ */ ((OnRampMethod2) => {
3
3
  OnRampMethod2["ACH"] = "ACH";
4
4
  OnRampMethod2["DEBIT"] = "Debit";
@@ -1,4 +1,4 @@
1
- import "../chunk-UICEQADR.js";
1
+ import "../chunk-7B52C2XE.js";
2
2
  var PopupType = /* @__PURE__ */ ((PopupType2) => {
3
3
  PopupType2["SIGN_TRANSACTION_REVIEW"] = "SIGN_TRANSACTION_REVIEW";
4
4
  PopupType2["SIGN_MESSAGE_REVIEW"] = "SIGN_MESSAGE_REVIEW";
@@ -1,4 +1,4 @@
1
- import "../chunk-UICEQADR.js";
1
+ import "../chunk-7B52C2XE.js";
2
2
  var RecoveryStatus = /* @__PURE__ */ ((RecoveryStatus2) => {
3
3
  RecoveryStatus2["INITIATED"] = "INITIATED";
4
4
  RecoveryStatus2["READY"] = "READY";
@@ -1,4 +1,4 @@
1
- import "../chunk-UICEQADR.js";
1
+ import "../chunk-7B52C2XE.js";
2
2
  var PregenIdentifierType = /* @__PURE__ */ ((PregenIdentifierType2) => {
3
3
  PregenIdentifierType2["EMAIL"] = "EMAIL";
4
4
  PregenIdentifierType2["PHONE"] = "PHONE";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  __spreadValues
3
- } from "../chunk-UICEQADR.js";
3
+ } from "../chunk-7B52C2XE.js";
4
4
  function dispatchEvent(type, data, error) {
5
5
  typeof window !== "undefined" && !!window.dispatchEvent && window.dispatchEvent(
6
6
  new CustomEvent(type, { detail: __spreadValues({ data }, error && { error: new Error(error) }) })
@@ -1,4 +1,4 @@
1
- import "../chunk-UICEQADR.js";
1
+ import "../chunk-7B52C2XE.js";
2
2
  import { toBech32 } from "@cosmjs/encoding";
3
3
  import { sha256 } from "@noble/hashes/sha256";
4
4
  import { ripemd160 } from "@noble/hashes/ripemd160";
@@ -56,9 +56,13 @@ function getCosmosAddress(publicKey, prefix) {
56
56
  const compressedPublicKey = compressPubkey(uncompressedPublicKey);
57
57
  return toBech32(prefix, rawSecp256k1PubkeyToRawAddress(compressedPublicKey));
58
58
  }
59
- function truncateAddress(str, addressType, { prefix = addressType === "COSMOS" ? "cosmos" : void 0 } = {}) {
60
- const headLength = (addressType === "COSMOS" ? prefix.length : addressType === "SOLANA" ? 0 : 2) + 4;
61
- return `${str.slice(0, headLength)}...${str.slice(-4)}`;
59
+ function truncateAddress(str, addressType, {
60
+ prefix = addressType === "COSMOS" ? "cosmos" : void 0,
61
+ targetLength
62
+ } = {}) {
63
+ const minimum = addressType === "COSMOS" ? prefix.length : addressType === "EVM" ? 2 : 0;
64
+ const margin = targetLength !== void 0 ? (targetLength - minimum) / 2 : 4;
65
+ return `${str.slice(0, minimum + margin)}...${str.slice(-1 * margin)}`;
62
66
  }
63
67
  function stringToPhoneNumber(str) {
64
68
  var _a;
@@ -1,4 +1,4 @@
1
- import "../chunk-UICEQADR.js";
1
+ import "../chunk-7B52C2XE.js";
2
2
  import * as constants from "../constants.js";
3
3
  function storageListener(e) {
4
4
  if (!e.url.includes(window.location.origin)) {
@@ -1,4 +1,5 @@
1
- import "../chunk-UICEQADR.js";
1
+ import "../chunk-7B52C2XE.js";
2
+ import { Network } from "@getpara/user-management-client";
2
3
  function toAssetInfoArray(data) {
3
4
  const result = [];
4
5
  Object.keys(data).forEach((walletType) => {
@@ -13,27 +14,52 @@ function toAssetInfoArray(data) {
13
14
  });
14
15
  return result;
15
16
  }
16
- function getOnRampNetworks(data, { walletType, allowed } = {}) {
17
+ function getOnRampNetworks(data, {
18
+ walletType,
19
+ allowed,
20
+ assets,
21
+ providers,
22
+ action
23
+ } = {}) {
17
24
  return [
18
25
  ...new Set(
19
- toAssetInfoArray(data).filter(([type, network]) => (!walletType || type === walletType) && (!allowed || allowed.includes(network))).map(([_, network]) => network)
26
+ toAssetInfoArray(data).filter(
27
+ ([type, network, asset, providerInfo]) => (!walletType || type === walletType) && (!allowed || allowed.includes(network)) && (!assets || assets.includes(asset)) && (!providers || providers.some((provider) => {
28
+ var _a;
29
+ return ((_a = providerInfo[provider]) == null ? void 0 : _a[1]) && (!action || providerInfo[provider][1][action]);
30
+ }))
31
+ ).map(([_, network]) => network)
20
32
  )
21
33
  ];
22
34
  }
23
35
  function getOnRampAssets(data, {
24
36
  walletType,
25
37
  network,
26
- allowed
38
+ allowed,
39
+ providers,
40
+ action
27
41
  } = {}) {
28
42
  return [
29
43
  ...new Set(
30
44
  toAssetInfoArray(data).filter(
31
- ([t, n, a]) => (!walletType || t === walletType) && (!network || n === network) && (!Array.isArray(allowed) || allowed.includes(a))
45
+ ([t, n, a, p]) => (!walletType || t === walletType) && (!network || n === network) && (!Array.isArray(allowed) || allowed.includes(a)) && (!providers || providers.some((provider) => {
46
+ var _a;
47
+ return ((_a = p[provider]) == null ? void 0 : _a[1]) && (!action || p[provider][1][action]);
48
+ }))
32
49
  ).map(([, , asset]) => asset)
33
50
  )
34
51
  ];
35
52
  }
53
+ const NETWORK_PREFIXES = {
54
+ [Network.COSMOS]: "cosmos",
55
+ [Network.NOBLE]: "noble"
56
+ };
57
+ function getNetworkPrefix(network) {
58
+ return NETWORK_PREFIXES[network];
59
+ }
36
60
  export {
61
+ NETWORK_PREFIXES,
62
+ getNetworkPrefix,
37
63
  getOnRampAssets,
38
64
  getOnRampNetworks,
39
65
  toAssetInfoArray
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  __async
3
- } from "../chunk-UICEQADR.js";
3
+ } from "../chunk-7B52C2XE.js";
4
4
  function waitUntilTrue(condition, timeoutMs, intervalMs) {
5
5
  return __async(this, null, function* () {
6
6
  const start = Date.now();
@@ -1,4 +1,4 @@
1
- import "../chunk-UICEQADR.js";
1
+ import "../chunk-7B52C2XE.js";
2
2
  import { Environment } from "../types/index.js";
3
3
  function getPortalDomain(env, isE2E) {
4
4
  if (isE2E) {
@@ -1,7 +1,8 @@
1
1
  import {
2
2
  __spreadProps,
3
3
  __spreadValues
4
- } from "../chunk-UICEQADR.js";
4
+ } from "../chunk-7B52C2XE.js";
5
+ import * as uuid from "uuid";
5
6
  import { WalletScheme, WalletType } from "@getpara/user-management-client";
6
7
  import { stringToPhoneNumber } from "./formatting.js";
7
8
  const WalletSchemeTypeMap = {
@@ -75,6 +76,9 @@ function migrateWallet(obj) {
75
76
  }
76
77
  return obj;
77
78
  }
79
+ function newUuid() {
80
+ return uuid.v4();
81
+ }
78
82
  export {
79
83
  WalletSchemeTypeMap,
80
84
  entityToWallet,
@@ -83,5 +87,6 @@ export {
83
87
  getWalletTypes,
84
88
  isPregenIdentifierMatch,
85
89
  isWalletSupported,
86
- migrateWallet
90
+ migrateWallet,
91
+ newUuid
87
92
  };
@@ -1,6 +1,6 @@
1
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
- import { Ctx, Environment, Theme, FullSignatureRes, ExternalWalletInfo, GetWebAuthUrlForLoginParams, AccountSetupResponse, LoginResponse, WalletFilters, WalletTypeProp, Wallet, SupportedWalletTypes, PortalUrlOptions, ConstructorOpts, RecoveryStatus, GetWalletBalanceParams } from './types/index.js';
3
+ import { Ctx, Environment, Theme, FullSignatureRes, ExternalWalletInfo, GetWebAuthUrlForLoginParams, AccountSetupResponse, LoginResponse, WalletFilters, WalletTypeProp, Wallet, SupportedWalletTypes, PortalUrlOptions, ConstructorOpts, RecoveryStatus, GetWalletBalanceParams, CreateGuestWalletsParams } from './types/index.js';
4
4
  import { PlatformUtils } from './PlatformUtils.js';
5
5
  import { CountryCallingCode } from 'libphonenumber-js';
6
6
  export declare abstract class ParaCore {
@@ -150,6 +150,8 @@ export declare abstract class ParaCore {
150
150
  getDisplayAddress(walletId: string, options?: {
151
151
  truncate?: boolean;
152
152
  addressType?: WalletTypeProp | undefined;
153
+ cosmosPrefix?: string;
154
+ targetLength?: number;
153
155
  } | undefined): string;
154
156
  /**
155
157
  * Returns a unique hash for a wallet suitable for use as an identicon seed.
@@ -526,6 +528,7 @@ export declare abstract class ParaCore {
526
528
  * @returns `true` if active, `false` otherwise
527
529
  **/
528
530
  isFullyLoggedIn(): Promise<boolean>;
531
+ get isGuestMode(): boolean;
529
532
  protected supportedAuthMethods(auth: Auth): Promise<Set<AuthMethod>>;
530
533
  /**
531
534
  * Get hints associated with the users stored biometrics.
@@ -773,7 +776,7 @@ export declare abstract class ParaCore {
773
776
  createPregenWallet(opts: {
774
777
  type: WalletType;
775
778
  pregenIdentifier: string;
776
- pregenIdentifierType: TPregenIdentifierType;
779
+ pregenIdentifierType: Exclude<TPregenIdentifierType, 'GUEST_ID'>;
777
780
  }): Promise<Wallet>;
778
781
  /**
779
782
  * Creates new pregenerated wallets for each desired type.
@@ -787,7 +790,7 @@ export declare abstract class ParaCore {
787
790
  **/
788
791
  createPregenWalletPerType({ types, pregenIdentifier, pregenIdentifierType, }: {
789
792
  pregenIdentifier: string;
790
- pregenIdentifierType: TPregenIdentifierType;
793
+ pregenIdentifierType: Exclude<TPregenIdentifierType, 'GUEST_ID'>;
791
794
  types?: WalletType[];
792
795
  }): Promise<Wallet[]>;
793
796
  /**
@@ -836,6 +839,7 @@ export declare abstract class ParaCore {
836
839
  pregenIdentifier?: string;
837
840
  pregenIdentifierType?: TPregenIdentifierType;
838
841
  }): Promise<WalletEntity[]>;
842
+ createGuestWallets({ types }?: CreateGuestWalletsParams): Promise<Wallet[]>;
839
843
  private encodeWalletBase64;
840
844
  /**
841
845
  * Encodes the current wallets encoded in Base 64.
@@ -1,6 +1,6 @@
1
1
  import { ParaCore } from './ParaCore.js';
2
2
  export { AuthMethod, type CurrentWalletIds, EmailTheme, type PartnerEntity, type WalletEntity, Network, WalletType, WalletScheme, OnRampAsset, OnRampPurchaseType, OnRampProvider, OnRampPurchaseStatus, type OnRampConfig, type OnRampAllowedAssets, type OnRampPurchase, OAuthMethod, type TPregenIdentifierType, type PregenIds, NON_ED25519, PREGEN_IDENTIFIER_TYPES, } from '@getpara/user-management-client';
3
- export { OnRampMethod, PopupType, PregenIdentifierType, RecoveryStatus, type ProviderAssetInfo, type SignatureRes, type FullSignatureRes, type SuccessfulSignatureRes, type DeniedSignatureRes, type DeniedSignatureResWithUrl, type OnRampAssetInfo, type Theme, type Wallet, type GetWalletBalanceParams, } from './types/index.js';
3
+ export { OnRampMethod, PopupType, PregenIdentifierType, RecoveryStatus, type ProviderAssetInfo, type SignatureRes, type FullSignatureRes, type SuccessfulSignatureRes, type DeniedSignatureRes, type DeniedSignatureResWithUrl, type OnRampAssetInfo, type Theme, type Wallet, type GetWalletBalanceParams, type CreateGuestWalletsParams, } from './types/index.js';
4
4
  export * from './types/events.js';
5
5
  export * from './types/config.js';
6
6
  export { getPortalDomain, stringToPhoneNumber, entityToWallet } from './utils/index.js';
@@ -17,7 +17,7 @@ export * from './errors.js';
17
17
  export * from './utils/formatting.js';
18
18
  export * from './utils/polling.js';
19
19
  export { isWalletSupported } from './utils/wallet.js';
20
- export { getOnRampAssets, getOnRampNetworks, toAssetInfoArray } from './utils/onRamps.js';
20
+ export { getNetworkPrefix, getOnRampAssets, getOnRampNetworks, toAssetInfoArray } from './utils/onRamps.js';
21
21
  export { getPortalBaseURL } from './utils/url.js';
22
22
  export { retrieve as transmissionUtilsRetrieve } from './transmission/transmissionUtils.js';
23
23
  export declare const paraVersion: string;
@@ -68,3 +68,6 @@ export type GetWalletBalanceParams = {
68
68
  walletId: string;
69
69
  rpcUrl?: string;
70
70
  };
71
+ export type CreateGuestWalletsParams = {
72
+ types?: WalletType[];
73
+ };
@@ -11,8 +11,9 @@ export declare function hexToUint8Array(hex: string): Uint8Array;
11
11
  export declare function hexToDecimal(hex: string): string;
12
12
  export declare function decimalToHex(decimal: string): Hex;
13
13
  export declare function getCosmosAddress(publicKey: string, prefix: string): string;
14
- export declare function truncateAddress(str: string, addressType: WalletTypeProp, { prefix }?: {
14
+ export declare function truncateAddress(str: string, addressType: WalletTypeProp, { prefix, targetLength, }?: {
15
15
  prefix?: string;
16
+ targetLength?: number;
16
17
  }): string;
17
18
  export declare function stringToPhoneNumber(str: string): string;
18
19
  export declare function normalizePhoneNumber(countryCode: string, number: string): string | undefined;
@@ -1,12 +1,19 @@
1
- import { Network, OnRampAsset, WalletType } from '@getpara/user-management-client';
1
+ import { Network, OnRampAsset, OnRampProvider, OnRampPurchaseType, WalletType } from '@getpara/user-management-client';
2
2
  import { OnRampAssetInfoRow, OnRampAssetInfo } from '../types/index.js';
3
3
  export declare function toAssetInfoArray(data: OnRampAssetInfo): OnRampAssetInfoRow[];
4
- export declare function getOnRampNetworks(data: OnRampAssetInfo, { walletType, allowed }?: {
4
+ export declare function getOnRampNetworks(data: OnRampAssetInfo, { walletType, allowed, assets, providers, action, }?: {
5
5
  walletType?: WalletType;
6
6
  allowed?: Network[];
7
+ assets?: OnRampAsset[];
8
+ providers?: OnRampProvider[];
9
+ action?: OnRampPurchaseType;
7
10
  }): Network[];
8
- export declare function getOnRampAssets(data: OnRampAssetInfo, { walletType, network, allowed, }?: {
11
+ export declare function getOnRampAssets(data: OnRampAssetInfo, { walletType, network, allowed, providers, action, }?: {
9
12
  walletType?: WalletType;
10
13
  network?: Network;
11
14
  allowed?: OnRampAsset[];
15
+ providers?: OnRampProvider[];
16
+ action?: OnRampPurchaseType;
12
17
  }): OnRampAsset[];
18
+ export declare const NETWORK_PREFIXES: Partial<Record<Network, string>>;
19
+ export declare function getNetworkPrefix(network: Network): string | undefined;
@@ -8,3 +8,4 @@ export declare function getWalletTypes(schemes: WalletScheme[]): WalletType[];
8
8
  export declare function getEquivalentTypes(types: WalletTypeProp[] | WalletTypeProp): WalletType[];
9
9
  export declare function entityToWallet(w: WalletEntity): Omit<Wallet, 'signer'>;
10
10
  export declare function migrateWallet(obj: Record<string, unknown>): Wallet;
11
+ export declare function newUuid(): string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getpara/core-sdk",
3
- "version": "1.9.0",
3
+ "version": "1.11.0",
4
4
  "main": "dist/cjs/index.js",
5
5
  "module": "dist/esm/index.js",
6
6
  "types": "dist/types/index.d.ts",
@@ -10,7 +10,7 @@
10
10
  "@celo/utils": "^8.0.2",
11
11
  "@cosmjs/encoding": "^0.32.4",
12
12
  "@ethereumjs/util": "^9.1.0",
13
- "@getpara/user-management-client": "1.9.0",
13
+ "@getpara/user-management-client": "1.11.0",
14
14
  "@noble/hashes": "^1.5.0",
15
15
  "base64url": "^3.0.1",
16
16
  "libphonenumber-js": "1.11.2",
@@ -40,5 +40,5 @@
40
40
  "require": "./dist/cjs/index.js"
41
41
  }
42
42
  },
43
- "gitHead": "3d749844bf071e2c8de2769dd16e17c026951109"
43
+ "gitHead": "91b68e4ead22e2104307c934f2a582245b176619"
44
44
  }