@getpara/core-sdk 1.10.0 → 1.12.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 +133 -49
  2. package/dist/cjs/constants.js +4 -1
  3. package/dist/cjs/utils/formatting.js +7 -3
  4. package/dist/cjs/utils/wallet.js +18 -2
  5. package/dist/esm/ParaCore.js +135 -50
  6. package/dist/esm/{chunk-UICEQADR.js → chunk-7B52C2XE.js} +2 -0
  7. package/dist/esm/constants.js +4 -2
  8. package/dist/esm/cryptography/utils.js +1 -1
  9. package/dist/esm/errors.js +1 -1
  10. package/dist/esm/external/mpcComputationClient.js +1 -1
  11. package/dist/esm/external/userManagementClient.js +1 -1
  12. package/dist/esm/index.js +1 -1
  13. package/dist/esm/shares/KeyContainer.js +1 -1
  14. package/dist/esm/shares/recovery.js +1 -1
  15. package/dist/esm/shares/shareDistribution.js +1 -1
  16. package/dist/esm/transmission/transmissionUtils.js +1 -1
  17. package/dist/esm/types/config.js +1 -1
  18. package/dist/esm/types/events.js +1 -1
  19. package/dist/esm/types/index.js +1 -1
  20. package/dist/esm/types/onRamps.js +1 -1
  21. package/dist/esm/types/popup.js +1 -1
  22. package/dist/esm/types/recovery.js +1 -1
  23. package/dist/esm/types/wallet.js +1 -1
  24. package/dist/esm/utils/events.js +1 -1
  25. package/dist/esm/utils/formatting.js +8 -4
  26. package/dist/esm/utils/listeners.js +1 -1
  27. package/dist/esm/utils/onRamps.js +1 -1
  28. package/dist/esm/utils/polling.js +1 -1
  29. package/dist/esm/utils/url.js +1 -1
  30. package/dist/esm/utils/wallet.js +7 -2
  31. package/dist/types/ParaCore.d.ts +12 -3
  32. package/dist/types/PlatformUtils.d.ts +2 -1
  33. package/dist/types/constants.d.ts +1 -0
  34. package/dist/types/index.d.ts +1 -1
  35. package/dist/types/types/config.d.ts +1 -0
  36. package/dist/types/types/params.d.ts +3 -0
  37. package/dist/types/utils/formatting.d.ts +2 -1
  38. package/dist/types/utils/wallet.d.ts +1 -0
  39. package/package.json +5 -5
@@ -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;
@@ -160,6 +162,37 @@ const _ParaCore = class _ParaCore {
160
162
  this.platformUtils.secureStorage.clear(constants.PREFIX);
161
163
  }
162
164
  });
165
+ this.trackError = (methodName, err) => __async(this, null, function* () {
166
+ try {
167
+ yield this.ctx.client.trackError({
168
+ methodName,
169
+ sdkType: this.platformUtils.sdkType,
170
+ userId: this.userId,
171
+ error: {
172
+ name: err.name,
173
+ message: err.message
174
+ }
175
+ });
176
+ } catch (e) {
177
+ console.error("error tracking error:", e);
178
+ }
179
+ throw err;
180
+ });
181
+ this.wrapMethodsWithErrorTracking = (methodNames) => {
182
+ for (const methodName of methodNames) {
183
+ const original = this[methodName];
184
+ if (typeof original === "function") {
185
+ this[methodName] = (...args) => {
186
+ try {
187
+ const result = original.apply(this, args);
188
+ return result instanceof Promise ? result.catch((err) => this.trackError(methodName, err)) : result;
189
+ } catch (err) {
190
+ return this.trackError(methodName, err);
191
+ }
192
+ };
193
+ }
194
+ }
195
+ };
163
196
  this.initializeFromStorage = () => {
164
197
  this.updateEmailFromStorage();
165
198
  this.updateCountryCodeFromStorage();
@@ -265,6 +298,7 @@ const _ParaCore = class _ParaCore {
265
298
  isE2E = true;
266
299
  env = import_types.Environment.SANDBOX;
267
300
  }
301
+ this.externalWalletConnectionOnly = opts.externalWalletConnectionOnly;
268
302
  this.emailPrimaryColor = opts.emailPrimaryColor;
269
303
  this.emailTheme = opts.emailTheme;
270
304
  this.homepageUrl = opts.homepageUrl;
@@ -352,6 +386,19 @@ const _ParaCore = class _ParaCore {
352
386
  }
353
387
  this.initializeFromStorage();
354
388
  import_listeners.setupListeners.bind(this)();
389
+ if (env !== import_types.Environment.PROD) {
390
+ this.wrapMethodsWithErrorTracking([
391
+ "createUser",
392
+ "initiateUserLoginV2",
393
+ "waitForPasskeyAndCreateWallet",
394
+ "waitForOAuth",
395
+ "waitForLoginAndSetup",
396
+ "createPregenWallet",
397
+ "claimPregenWallets",
398
+ "signMessage",
399
+ "signTransaction"
400
+ ]);
401
+ }
355
402
  }
356
403
  get isEmail() {
357
404
  return !!this.email && !this.phone && !this.countryCode && !this.farcasterUsername && !this.telegramUserId && !this.externalWalletWithParaAuth;
@@ -526,7 +573,7 @@ const _ParaCore = class _ParaCore {
526
573
  var _a, _b;
527
574
  if (this.externalWallets[walletId]) {
528
575
  const wallet2 = this.externalWallets[walletId];
529
- return options.truncate ? (0, import_utils2.truncateAddress)(wallet2.address, wallet2.type, { prefix: this.cosmosPrefix }) : wallet2.address;
576
+ return options.truncate ? (0, import_utils2.truncateAddress)(wallet2.address, wallet2.type, { prefix: this.cosmosPrefix, targetLength: options.targetLength }) : wallet2.address;
530
577
  }
531
578
  const wallet = this.findWallet(walletId, options.addressType);
532
579
  if (!wallet) {
@@ -544,7 +591,7 @@ const _ParaCore = class _ParaCore {
544
591
  str = wallet.address;
545
592
  break;
546
593
  }
547
- return options.truncate ? (0, import_utils2.truncateAddress)(str, wallet.type, { prefix }) : str;
594
+ return options.truncate ? (0, import_utils2.truncateAddress)(str, wallet.type, { prefix, targetLength: options.targetLength }) : str;
548
595
  }
549
596
  /**
550
597
  * Returns a unique hash for a wallet suitable for use as an identicon seed.
@@ -1264,6 +1311,13 @@ const _ParaCore = class _ParaCore {
1264
1311
  */
1265
1312
  externalWalletLogin(wallet) {
1266
1313
  return __async(this, null, function* () {
1314
+ if (this.externalWalletConnectionOnly) {
1315
+ wallet.withFullParaAuth = false;
1316
+ yield this.setExternalWallet(wallet);
1317
+ return Promise.resolve({
1318
+ userId: constants.EXTERNAL_WALLET_CONNECTION_ONLY_USER_ID
1319
+ });
1320
+ }
1267
1321
  this.requireApiKey();
1268
1322
  const res = yield this.ctx.client.externalWalletLogin({
1269
1323
  externalAddress: wallet.address,
@@ -1530,10 +1584,16 @@ const _ParaCore = class _ParaCore {
1530
1584
  if (this.isUsingExternalWallet()) {
1531
1585
  return true;
1532
1586
  }
1587
+ if (this.isGuestMode) {
1588
+ return true;
1589
+ }
1533
1590
  const isSessionActive = yield this.isSessionActive();
1534
1591
  return isSessionActive && (this.isNoWalletConfig || this.currentWalletIdsArray.length > 0 && this.currentWalletIdsArray.reduce((acc, [id]) => acc && !!this.wallets[id], true));
1535
1592
  });
1536
1593
  }
1594
+ get isGuestMode() {
1595
+ return !this.userId && this.currentWalletIdsArray.length > 0 && this.currentWalletIdsArray.every(([id]) => !!this.wallets[id] && this.wallets[id].pregenIdentifierType === "GUEST_ID");
1596
+ }
1537
1597
  supportedAuthMethods(auth) {
1538
1598
  return __async(this, null, function* () {
1539
1599
  const { supportedAuthMethods } = yield this.ctx.client.getSupportedAuthMethods(auth);
@@ -2238,51 +2298,7 @@ const _ParaCore = class _ParaCore {
2238
2298
  **/
2239
2299
  createPregenWallet(opts) {
2240
2300
  return __async(this, null, function* () {
2241
- var _a, _b;
2242
- const {
2243
- type: _type = (_a = this.supportedWalletTypes.find(({ optional }) => !optional)) == null ? void 0 : _a.type,
2244
- pregenIdentifier,
2245
- pregenIdentifierType = "EMAIL"
2246
- } = opts;
2247
- this.requireApiKey();
2248
- const walletType = yield this.assertIsValidWalletType(
2249
- _type != null ? _type : (_b = this.supportedWalletTypes.find(({ optional }) => !optional)) == null ? void 0 : _b.type
2250
- );
2251
- let keygenRes;
2252
- switch (walletType) {
2253
- case import_user_management_client.WalletType.SOLANA:
2254
- keygenRes = yield this.platformUtils.ed25519PreKeygen(
2255
- this.ctx,
2256
- pregenIdentifier,
2257
- pregenIdentifierType,
2258
- this.retrieveSessionCookie()
2259
- );
2260
- break;
2261
- default:
2262
- keygenRes = yield this.platformUtils.preKeygen(
2263
- this.ctx,
2264
- void 0,
2265
- pregenIdentifier,
2266
- pregenIdentifierType,
2267
- walletType,
2268
- null,
2269
- this.retrieveSessionCookie()
2270
- );
2271
- break;
2272
- }
2273
- const { signer, walletId } = keygenRes;
2274
- this.wallets[walletId] = {
2275
- id: walletId,
2276
- signer,
2277
- scheme: walletType === import_user_management_client.WalletType.SOLANA ? import_user_management_client.WalletScheme.ED25519 : import_user_management_client.WalletScheme.DKLS,
2278
- type: walletType,
2279
- isPregen: true,
2280
- pregenIdentifier,
2281
- pregenIdentifierType
2282
- };
2283
- yield this.waitForPregenWalletAddress(walletId);
2284
- yield this.populatePregenWalletAddresses();
2285
- return this.wallets[walletId];
2301
+ return yield __privateMethod(this, _ParaCore_instances, createPregenWallet_fn).call(this, opts);
2286
2302
  });
2287
2303
  }
2288
2304
  /**
@@ -2303,7 +2319,7 @@ const _ParaCore = class _ParaCore {
2303
2319
  }) {
2304
2320
  const wallets = [];
2305
2321
  for (const type of yield this.getTypesToCreate(types)) {
2306
- const wallet = yield this.createPregenWallet({ type, pregenIdentifier, pregenIdentifierType });
2322
+ const wallet = yield __privateMethod(this, _ParaCore_instances, createPregenWallet_fn).call(this, { type, pregenIdentifier, pregenIdentifierType });
2307
2323
  wallets.push(wallet);
2308
2324
  }
2309
2325
  return wallets;
@@ -2452,6 +2468,24 @@ const _ParaCore = class _ParaCore {
2452
2468
  return res.wallets.filter((w) => this.isWalletSupported((0, import_utils2.entityToWallet)(w)));
2453
2469
  });
2454
2470
  }
2471
+ createGuestWallets() {
2472
+ return __async(this, arguments, function* ({ types } = {}) {
2473
+ const wallets = [];
2474
+ const currentWalletIds = {};
2475
+ const guestId = (0, import_utils2.newUuid)();
2476
+ for (const type of yield this.getTypesToCreate(
2477
+ types != null ? types : this.supportedWalletTypes.filter(({ optional }) => !optional).map(({ type: type2 }) => type2)
2478
+ )) {
2479
+ const wallet = yield __privateMethod(this, _ParaCore_instances, createPregenWallet_fn).call(this, { type, pregenIdentifier: guestId, pregenIdentifierType: "GUEST_ID" });
2480
+ wallets.push(wallet);
2481
+ (0, import_utils2.getEquivalentTypes)(type).filter((t) => __privateGet(this, _supportedWalletTypes).some(({ type: type2, optional }) => t === type2 && !optional)).forEach((eqType) => {
2482
+ currentWalletIds[eqType] = [wallet.id];
2483
+ });
2484
+ }
2485
+ yield this.setCurrentWalletIds(currentWalletIds);
2486
+ return wallets;
2487
+ });
2488
+ }
2455
2489
  encodeWalletBase64(wallet) {
2456
2490
  const walletJson = JSON.stringify(wallet);
2457
2491
  const base64Wallet = Buffer.from(walletJson).toString("base64");
@@ -2969,6 +3003,56 @@ const _ParaCore = class _ParaCore {
2969
3003
  };
2970
3004
  _supportedWalletTypes = new WeakMap();
2971
3005
  _supportedWalletTypesOpt = new WeakMap();
3006
+ _ParaCore_instances = new WeakSet();
3007
+ createPregenWallet_fn = function(opts) {
3008
+ return __async(this, null, function* () {
3009
+ var _a, _b;
3010
+ const {
3011
+ type: _type = (_a = this.supportedWalletTypes.find(({ optional }) => !optional)) == null ? void 0 : _a.type,
3012
+ pregenIdentifier,
3013
+ pregenIdentifierType = "EMAIL"
3014
+ } = opts;
3015
+ this.requireApiKey();
3016
+ const walletType = yield this.assertIsValidWalletType(
3017
+ _type != null ? _type : (_b = this.supportedWalletTypes.find(({ optional }) => !optional)) == null ? void 0 : _b.type
3018
+ );
3019
+ let keygenRes;
3020
+ switch (walletType) {
3021
+ case import_user_management_client.WalletType.SOLANA:
3022
+ keygenRes = yield this.platformUtils.ed25519PreKeygen(
3023
+ this.ctx,
3024
+ pregenIdentifier,
3025
+ pregenIdentifierType,
3026
+ this.retrieveSessionCookie()
3027
+ );
3028
+ break;
3029
+ default:
3030
+ keygenRes = yield this.platformUtils.preKeygen(
3031
+ this.ctx,
3032
+ void 0,
3033
+ pregenIdentifier,
3034
+ pregenIdentifierType,
3035
+ walletType,
3036
+ null,
3037
+ this.retrieveSessionCookie()
3038
+ );
3039
+ break;
3040
+ }
3041
+ const { signer, walletId } = keygenRes;
3042
+ this.wallets[walletId] = {
3043
+ id: walletId,
3044
+ signer,
3045
+ scheme: walletType === import_user_management_client.WalletType.SOLANA ? import_user_management_client.WalletScheme.ED25519 : import_user_management_client.WalletScheme.DKLS,
3046
+ type: walletType,
3047
+ isPregen: true,
3048
+ pregenIdentifier,
3049
+ pregenIdentifierType
3050
+ };
3051
+ yield this.waitForPregenWalletAddress(walletId);
3052
+ yield this.populatePregenWalletAddresses();
3053
+ return this.wallets[walletId];
3054
+ });
3055
+ };
2972
3056
  _ParaCore.version = constants.PARA_CORE_VERSION;
2973
3057
  let ParaCore = _ParaCore;
2974
3058
  // Annotate the CommonJS export names for ESM import in node:
@@ -17,6 +17,7 @@ var __copyProps = (to, from, except, desc) => {
17
17
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
18
  var constants_exports = {};
19
19
  __export(constants_exports, {
20
+ EXTERNAL_WALLET_CONNECTION_ONLY_USER_ID: () => EXTERNAL_WALLET_CONNECTION_ONLY_USER_ID,
20
21
  LOCAL_STORAGE_COUNTRY_CODE: () => LOCAL_STORAGE_COUNTRY_CODE,
21
22
  LOCAL_STORAGE_CURRENT_WALLET_IDS: () => LOCAL_STORAGE_CURRENT_WALLET_IDS,
22
23
  LOCAL_STORAGE_ED25519_WALLETS: () => LOCAL_STORAGE_ED25519_WALLETS,
@@ -36,7 +37,7 @@ __export(constants_exports, {
36
37
  SHORT_POLLING_INTERVAL_MS: () => SHORT_POLLING_INTERVAL_MS
37
38
  });
38
39
  module.exports = __toCommonJS(constants_exports);
39
- const PARA_CORE_VERSION = '1.10.0';
40
+ const PARA_CORE_VERSION = "1.12.0";
40
41
  const PREFIX = "@CAPSULE/";
41
42
  const LOCAL_STORAGE_EMAIL = `${PREFIX}e-mail`;
42
43
  const LOCAL_STORAGE_PHONE = `${PREFIX}phone`;
@@ -53,8 +54,10 @@ const LOCAL_STORAGE_SESSION_COOKIE = `${PREFIX}sessionCookie`;
53
54
  const SESSION_STORAGE_LOGIN_ENCRYPTION_KEY_PAIR = `${PREFIX}loginEncryptionKeyPair`;
54
55
  const POLLING_INTERVAL_MS = 2e3;
55
56
  const SHORT_POLLING_INTERVAL_MS = 1e3;
57
+ const EXTERNAL_WALLET_CONNECTION_ONLY_USER_ID = "EXTERNAL_WALLET_CONNECTION_ONLY";
56
58
  // Annotate the CommonJS export names for ESM import in node:
57
59
  0 && (module.exports = {
60
+ EXTERNAL_WALLET_CONNECTION_ONLY_USER_ID,
58
61
  LOCAL_STORAGE_COUNTRY_CODE,
59
62
  LOCAL_STORAGE_CURRENT_WALLET_IDS,
60
63
  LOCAL_STORAGE_ED25519_WALLETS,
@@ -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;
@@ -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;
@@ -110,6 +113,37 @@ const _ParaCore = class _ParaCore {
110
113
  this.platformUtils.secureStorage.clear(constants.PREFIX);
111
114
  }
112
115
  });
116
+ this.trackError = (methodName, err) => __async(this, null, function* () {
117
+ try {
118
+ yield this.ctx.client.trackError({
119
+ methodName,
120
+ sdkType: this.platformUtils.sdkType,
121
+ userId: this.userId,
122
+ error: {
123
+ name: err.name,
124
+ message: err.message
125
+ }
126
+ });
127
+ } catch (e) {
128
+ console.error("error tracking error:", e);
129
+ }
130
+ throw err;
131
+ });
132
+ this.wrapMethodsWithErrorTracking = (methodNames) => {
133
+ for (const methodName of methodNames) {
134
+ const original = this[methodName];
135
+ if (typeof original === "function") {
136
+ this[methodName] = (...args) => {
137
+ try {
138
+ const result = original.apply(this, args);
139
+ return result instanceof Promise ? result.catch((err) => this.trackError(methodName, err)) : result;
140
+ } catch (err) {
141
+ return this.trackError(methodName, err);
142
+ }
143
+ };
144
+ }
145
+ }
146
+ };
113
147
  this.initializeFromStorage = () => {
114
148
  this.updateEmailFromStorage();
115
149
  this.updateCountryCodeFromStorage();
@@ -215,6 +249,7 @@ const _ParaCore = class _ParaCore {
215
249
  isE2E = true;
216
250
  env = Environment.SANDBOX;
217
251
  }
252
+ this.externalWalletConnectionOnly = opts.externalWalletConnectionOnly;
218
253
  this.emailPrimaryColor = opts.emailPrimaryColor;
219
254
  this.emailTheme = opts.emailTheme;
220
255
  this.homepageUrl = opts.homepageUrl;
@@ -302,6 +337,19 @@ const _ParaCore = class _ParaCore {
302
337
  }
303
338
  this.initializeFromStorage();
304
339
  setupListeners.bind(this)();
340
+ if (env !== Environment.PROD) {
341
+ this.wrapMethodsWithErrorTracking([
342
+ "createUser",
343
+ "initiateUserLoginV2",
344
+ "waitForPasskeyAndCreateWallet",
345
+ "waitForOAuth",
346
+ "waitForLoginAndSetup",
347
+ "createPregenWallet",
348
+ "claimPregenWallets",
349
+ "signMessage",
350
+ "signTransaction"
351
+ ]);
352
+ }
305
353
  }
306
354
  get isEmail() {
307
355
  return !!this.email && !this.phone && !this.countryCode && !this.farcasterUsername && !this.telegramUserId && !this.externalWalletWithParaAuth;
@@ -476,7 +524,7 @@ const _ParaCore = class _ParaCore {
476
524
  var _a, _b;
477
525
  if (this.externalWallets[walletId]) {
478
526
  const wallet2 = this.externalWallets[walletId];
479
- return options.truncate ? truncateAddress(wallet2.address, wallet2.type, { prefix: this.cosmosPrefix }) : wallet2.address;
527
+ return options.truncate ? truncateAddress(wallet2.address, wallet2.type, { prefix: this.cosmosPrefix, targetLength: options.targetLength }) : wallet2.address;
480
528
  }
481
529
  const wallet = this.findWallet(walletId, options.addressType);
482
530
  if (!wallet) {
@@ -494,7 +542,7 @@ const _ParaCore = class _ParaCore {
494
542
  str = wallet.address;
495
543
  break;
496
544
  }
497
- return options.truncate ? truncateAddress(str, wallet.type, { prefix }) : str;
545
+ return options.truncate ? truncateAddress(str, wallet.type, { prefix, targetLength: options.targetLength }) : str;
498
546
  }
499
547
  /**
500
548
  * Returns a unique hash for a wallet suitable for use as an identicon seed.
@@ -1214,6 +1262,13 @@ const _ParaCore = class _ParaCore {
1214
1262
  */
1215
1263
  externalWalletLogin(wallet) {
1216
1264
  return __async(this, null, function* () {
1265
+ if (this.externalWalletConnectionOnly) {
1266
+ wallet.withFullParaAuth = false;
1267
+ yield this.setExternalWallet(wallet);
1268
+ return Promise.resolve({
1269
+ userId: constants.EXTERNAL_WALLET_CONNECTION_ONLY_USER_ID
1270
+ });
1271
+ }
1217
1272
  this.requireApiKey();
1218
1273
  const res = yield this.ctx.client.externalWalletLogin({
1219
1274
  externalAddress: wallet.address,
@@ -1480,10 +1535,16 @@ const _ParaCore = class _ParaCore {
1480
1535
  if (this.isUsingExternalWallet()) {
1481
1536
  return true;
1482
1537
  }
1538
+ if (this.isGuestMode) {
1539
+ return true;
1540
+ }
1483
1541
  const isSessionActive = yield this.isSessionActive();
1484
1542
  return isSessionActive && (this.isNoWalletConfig || this.currentWalletIdsArray.length > 0 && this.currentWalletIdsArray.reduce((acc, [id]) => acc && !!this.wallets[id], true));
1485
1543
  });
1486
1544
  }
1545
+ get isGuestMode() {
1546
+ return !this.userId && this.currentWalletIdsArray.length > 0 && this.currentWalletIdsArray.every(([id]) => !!this.wallets[id] && this.wallets[id].pregenIdentifierType === "GUEST_ID");
1547
+ }
1487
1548
  supportedAuthMethods(auth) {
1488
1549
  return __async(this, null, function* () {
1489
1550
  const { supportedAuthMethods } = yield this.ctx.client.getSupportedAuthMethods(auth);
@@ -2188,51 +2249,7 @@ const _ParaCore = class _ParaCore {
2188
2249
  **/
2189
2250
  createPregenWallet(opts) {
2190
2251
  return __async(this, null, function* () {
2191
- var _a, _b;
2192
- const {
2193
- type: _type = (_a = this.supportedWalletTypes.find(({ optional }) => !optional)) == null ? void 0 : _a.type,
2194
- pregenIdentifier,
2195
- pregenIdentifierType = "EMAIL"
2196
- } = opts;
2197
- this.requireApiKey();
2198
- const walletType = yield this.assertIsValidWalletType(
2199
- _type != null ? _type : (_b = this.supportedWalletTypes.find(({ optional }) => !optional)) == null ? void 0 : _b.type
2200
- );
2201
- let keygenRes;
2202
- switch (walletType) {
2203
- case WalletType.SOLANA:
2204
- keygenRes = yield this.platformUtils.ed25519PreKeygen(
2205
- this.ctx,
2206
- pregenIdentifier,
2207
- pregenIdentifierType,
2208
- this.retrieveSessionCookie()
2209
- );
2210
- break;
2211
- default:
2212
- keygenRes = yield this.platformUtils.preKeygen(
2213
- this.ctx,
2214
- void 0,
2215
- pregenIdentifier,
2216
- pregenIdentifierType,
2217
- walletType,
2218
- null,
2219
- this.retrieveSessionCookie()
2220
- );
2221
- break;
2222
- }
2223
- const { signer, walletId } = keygenRes;
2224
- this.wallets[walletId] = {
2225
- id: walletId,
2226
- signer,
2227
- scheme: walletType === WalletType.SOLANA ? WalletScheme.ED25519 : WalletScheme.DKLS,
2228
- type: walletType,
2229
- isPregen: true,
2230
- pregenIdentifier,
2231
- pregenIdentifierType
2232
- };
2233
- yield this.waitForPregenWalletAddress(walletId);
2234
- yield this.populatePregenWalletAddresses();
2235
- return this.wallets[walletId];
2252
+ return yield __privateMethod(this, _ParaCore_instances, createPregenWallet_fn).call(this, opts);
2236
2253
  });
2237
2254
  }
2238
2255
  /**
@@ -2253,7 +2270,7 @@ const _ParaCore = class _ParaCore {
2253
2270
  }) {
2254
2271
  const wallets = [];
2255
2272
  for (const type of yield this.getTypesToCreate(types)) {
2256
- const wallet = yield this.createPregenWallet({ type, pregenIdentifier, pregenIdentifierType });
2273
+ const wallet = yield __privateMethod(this, _ParaCore_instances, createPregenWallet_fn).call(this, { type, pregenIdentifier, pregenIdentifierType });
2257
2274
  wallets.push(wallet);
2258
2275
  }
2259
2276
  return wallets;
@@ -2402,6 +2419,24 @@ const _ParaCore = class _ParaCore {
2402
2419
  return res.wallets.filter((w) => this.isWalletSupported(entityToWallet(w)));
2403
2420
  });
2404
2421
  }
2422
+ createGuestWallets() {
2423
+ return __async(this, arguments, function* ({ types } = {}) {
2424
+ const wallets = [];
2425
+ const currentWalletIds = {};
2426
+ const guestId = newUuid();
2427
+ for (const type of yield this.getTypesToCreate(
2428
+ types != null ? types : this.supportedWalletTypes.filter(({ optional }) => !optional).map(({ type: type2 }) => type2)
2429
+ )) {
2430
+ const wallet = yield __privateMethod(this, _ParaCore_instances, createPregenWallet_fn).call(this, { type, pregenIdentifier: guestId, pregenIdentifierType: "GUEST_ID" });
2431
+ wallets.push(wallet);
2432
+ getEquivalentTypes(type).filter((t) => __privateGet(this, _supportedWalletTypes).some(({ type: type2, optional }) => t === type2 && !optional)).forEach((eqType) => {
2433
+ currentWalletIds[eqType] = [wallet.id];
2434
+ });
2435
+ }
2436
+ yield this.setCurrentWalletIds(currentWalletIds);
2437
+ return wallets;
2438
+ });
2439
+ }
2405
2440
  encodeWalletBase64(wallet) {
2406
2441
  const walletJson = JSON.stringify(wallet);
2407
2442
  const base64Wallet = Buffer.from(walletJson).toString("base64");
@@ -2919,6 +2954,56 @@ const _ParaCore = class _ParaCore {
2919
2954
  };
2920
2955
  _supportedWalletTypes = new WeakMap();
2921
2956
  _supportedWalletTypesOpt = new WeakMap();
2957
+ _ParaCore_instances = new WeakSet();
2958
+ createPregenWallet_fn = function(opts) {
2959
+ return __async(this, null, function* () {
2960
+ var _a, _b;
2961
+ const {
2962
+ type: _type = (_a = this.supportedWalletTypes.find(({ optional }) => !optional)) == null ? void 0 : _a.type,
2963
+ pregenIdentifier,
2964
+ pregenIdentifierType = "EMAIL"
2965
+ } = opts;
2966
+ this.requireApiKey();
2967
+ const walletType = yield this.assertIsValidWalletType(
2968
+ _type != null ? _type : (_b = this.supportedWalletTypes.find(({ optional }) => !optional)) == null ? void 0 : _b.type
2969
+ );
2970
+ let keygenRes;
2971
+ switch (walletType) {
2972
+ case WalletType.SOLANA:
2973
+ keygenRes = yield this.platformUtils.ed25519PreKeygen(
2974
+ this.ctx,
2975
+ pregenIdentifier,
2976
+ pregenIdentifierType,
2977
+ this.retrieveSessionCookie()
2978
+ );
2979
+ break;
2980
+ default:
2981
+ keygenRes = yield this.platformUtils.preKeygen(
2982
+ this.ctx,
2983
+ void 0,
2984
+ pregenIdentifier,
2985
+ pregenIdentifierType,
2986
+ walletType,
2987
+ null,
2988
+ this.retrieveSessionCookie()
2989
+ );
2990
+ break;
2991
+ }
2992
+ const { signer, walletId } = keygenRes;
2993
+ this.wallets[walletId] = {
2994
+ id: walletId,
2995
+ signer,
2996
+ scheme: walletType === WalletType.SOLANA ? WalletScheme.ED25519 : WalletScheme.DKLS,
2997
+ type: walletType,
2998
+ isPregen: true,
2999
+ pregenIdentifier,
3000
+ pregenIdentifierType
3001
+ };
3002
+ yield this.waitForPregenWalletAddress(walletId);
3003
+ yield this.populatePregenWalletAddresses();
3004
+ return this.wallets[walletId];
3005
+ });
3006
+ };
2922
3007
  _ParaCore.version = constants.PARA_CORE_VERSION;
2923
3008
  let ParaCore = _ParaCore;
2924
3009
  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.10.0';
1
+ import "./chunk-7B52C2XE.js";
2
+ const PARA_CORE_VERSION = "1.12.0";
3
3
  const PREFIX = "@CAPSULE/";
4
4
  const LOCAL_STORAGE_EMAIL = `${PREFIX}e-mail`;
5
5
  const LOCAL_STORAGE_PHONE = `${PREFIX}phone`;
@@ -16,7 +16,9 @@ const LOCAL_STORAGE_SESSION_COOKIE = `${PREFIX}sessionCookie`;
16
16
  const SESSION_STORAGE_LOGIN_ENCRYPTION_KEY_PAIR = `${PREFIX}loginEncryptionKeyPair`;
17
17
  const POLLING_INTERVAL_MS = 2e3;
18
18
  const SHORT_POLLING_INTERVAL_MS = 1e3;
19
+ const EXTERNAL_WALLET_CONNECTION_ONLY_USER_ID = "EXTERNAL_WALLET_CONNECTION_ONLY";
19
20
  export {
21
+ EXTERNAL_WALLET_CONNECTION_ONLY_USER_ID,
20
22
  LOCAL_STORAGE_COUNTRY_CODE,
21
23
  LOCAL_STORAGE_CURRENT_WALLET_IDS,
22
24
  LOCAL_STORAGE_ED25519_WALLETS,
@@ -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,
@@ -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,4 @@
1
- import "../chunk-UICEQADR.js";
1
+ import "../chunk-7B52C2XE.js";
2
2
  import { Network } from "@getpara/user-management-client";
3
3
  function toAssetInfoArray(data) {
4
4
  const result = [];
@@ -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 {
@@ -112,6 +112,10 @@ export declare abstract class ParaCore {
112
112
  * @deprecated configure theming through the developer portal
113
113
  */
114
114
  portalTheme?: Theme;
115
+ /**
116
+ * Whether or not to treat external wallets as connections only, skipping all Para functionality.
117
+ */
118
+ externalWalletConnectionOnly?: boolean;
115
119
  private disableProviderModal?;
116
120
  get isNoWalletConfig(): boolean;
117
121
  get supportedWalletTypes(): SupportedWalletTypes;
@@ -151,6 +155,7 @@ export declare abstract class ParaCore {
151
155
  truncate?: boolean;
152
156
  addressType?: WalletTypeProp | undefined;
153
157
  cosmosPrefix?: string;
158
+ targetLength?: number;
154
159
  } | undefined): string;
155
160
  /**
156
161
  * Returns a unique hash for a wallet suitable for use as an identicon seed.
@@ -171,6 +176,8 @@ export declare abstract class ParaCore {
171
176
  * @returns - A new ParaCore instance.
172
177
  */
173
178
  constructor(env: Environment, apiKey?: string, opts?: ConstructorOpts);
179
+ private trackError;
180
+ private wrapMethodsWithErrorTracking;
174
181
  private initializeFromStorage;
175
182
  private updateTelegramUserIdFromStorage;
176
183
  private updateUserIdFromStorage;
@@ -527,6 +534,7 @@ export declare abstract class ParaCore {
527
534
  * @returns `true` if active, `false` otherwise
528
535
  **/
529
536
  isFullyLoggedIn(): Promise<boolean>;
537
+ get isGuestMode(): boolean;
530
538
  protected supportedAuthMethods(auth: Auth): Promise<Set<AuthMethod>>;
531
539
  /**
532
540
  * Get hints associated with the users stored biometrics.
@@ -774,7 +782,7 @@ export declare abstract class ParaCore {
774
782
  createPregenWallet(opts: {
775
783
  type: WalletType;
776
784
  pregenIdentifier: string;
777
- pregenIdentifierType: TPregenIdentifierType;
785
+ pregenIdentifierType: Exclude<TPregenIdentifierType, 'GUEST_ID'>;
778
786
  }): Promise<Wallet>;
779
787
  /**
780
788
  * Creates new pregenerated wallets for each desired type.
@@ -788,7 +796,7 @@ export declare abstract class ParaCore {
788
796
  **/
789
797
  createPregenWalletPerType({ types, pregenIdentifier, pregenIdentifierType, }: {
790
798
  pregenIdentifier: string;
791
- pregenIdentifierType: TPregenIdentifierType;
799
+ pregenIdentifierType: Exclude<TPregenIdentifierType, 'GUEST_ID'>;
792
800
  types?: WalletType[];
793
801
  }): Promise<Wallet[]>;
794
802
  /**
@@ -837,6 +845,7 @@ export declare abstract class ParaCore {
837
845
  pregenIdentifier?: string;
838
846
  pregenIdentifierType?: TPregenIdentifierType;
839
847
  }): Promise<WalletEntity[]>;
848
+ createGuestWallets({ types }?: CreateGuestWalletsParams): Promise<Wallet[]>;
840
849
  private encodeWalletBase64;
841
850
  /**
842
851
  * Encodes the current wallets encoded in Base 64.
@@ -1,9 +1,10 @@
1
1
  /// <reference types="node" />
2
2
  /// <reference types="node" />
3
- import { BackupKitEmailProps, TPregenIdentifierType, WalletType } from '@getpara/user-management-client';
3
+ import { BackupKitEmailProps, TPregenIdentifierType, WalletType, SDKType } from '@getpara/user-management-client';
4
4
  import { Ctx, PopupType, SignatureRes } from './types/index.js';
5
5
  import { StorageUtils } from './StorageUtils.js';
6
6
  export interface PlatformUtils {
7
+ sdkType: SDKType;
7
8
  getPrivateKey(ctx: Ctx, userId: string, walletId: string, share: string, sessionCookie: string): Promise<string>;
8
9
  keygen(ctx: Ctx, userId: string, type: Exclude<WalletType, WalletType.SOLANA>, secretKey: string | null, // should be acceptable as null in RN as we don't pre-gen them
9
10
  sessionCookie: string, emailProps?: BackupKitEmailProps): Promise<{
@@ -15,3 +15,4 @@ export declare const LOCAL_STORAGE_SESSION_COOKIE: string;
15
15
  export declare const SESSION_STORAGE_LOGIN_ENCRYPTION_KEY_PAIR: string;
16
16
  export declare const POLLING_INTERVAL_MS = 2000;
17
17
  export declare const SHORT_POLLING_INTERVAL_MS = 1000;
18
+ export declare const EXTERNAL_WALLET_CONNECTION_ONLY_USER_ID = "EXTERNAL_WALLET_CONNECTION_ONLY";
@@ -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';
@@ -69,6 +69,7 @@ export type SupportedWalletTypes = {
69
69
  optional?: boolean;
70
70
  }[];
71
71
  export interface ConstructorOpts {
72
+ externalWalletConnectionOnly?: boolean;
72
73
  useStorageOverrides?: boolean;
73
74
  disableWorkers?: boolean;
74
75
  offloadMPCComputationURL?: 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;
@@ -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.10.0",
3
+ "version": "1.12.0",
4
4
  "main": "dist/cjs/index.js",
5
5
  "module": "dist/esm/index.js",
6
6
  "types": "dist/types/index.d.ts",
@@ -10,15 +10,15 @@
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.10.0",
13
+ "@getpara/user-management-client": "1.12.0",
14
14
  "@noble/hashes": "^1.5.0",
15
15
  "base64url": "^3.0.1",
16
16
  "libphonenumber-js": "1.11.2",
17
17
  "node-forge": "^1.3.1",
18
- "qs": "^6.12.0"
18
+ "uuid": "^11.1.0"
19
19
  },
20
20
  "scripts": {
21
- "build": "rm -rf dist && node ./scripts/build.mjs && yarn build:types && yarn post-build",
21
+ "build": "rm -rf dist && node ./scripts/build.mjs && yarn build:types",
22
22
  "old-build": "yarn build:cjs && yarn build:esm && yarn build:types; yarn post-build",
23
23
  "post-build": "./scripts/set-version.sh",
24
24
  "build:cjs": "rm -rf dist/cjs && tsc --module commonjs --outDir dist/cjs && printf '{\"type\":\"commonjs\"}' > dist/cjs/package.json",
@@ -40,5 +40,5 @@
40
40
  "require": "./dist/cjs/index.js"
41
41
  }
42
42
  },
43
- "gitHead": "617cf0aa1307a96ec5e91d39e306e8a0b3b86b82"
43
+ "gitHead": "748afcf08c9d307a2d3eaf0716f73132f3eb8529"
44
44
  }