@getpara/core-sdk 1.2.0 → 1.3.1

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 (69) hide show
  1. package/dist/cjs/.!4351!index.js.br +0 -0
  2. package/dist/cjs/.!4353!index.js.gz +0 -0
  3. package/dist/cjs/index.js +2 -97
  4. package/dist/cjs/index.js.br +0 -0
  5. package/dist/cjs/index.js.gz +0 -0
  6. package/dist/esm/.!4345!index.js.br +0 -0
  7. package/dist/esm/.!4347!index.js.gz +0 -0
  8. package/dist/esm/index.js +2 -23
  9. package/dist/esm/index.js.br +0 -0
  10. package/dist/esm/index.js.gz +0 -0
  11. package/package.json +7 -7
  12. package/dist/cjs/ParaCore.js +0 -2620
  13. package/dist/cjs/PlatformUtils.js +0 -2
  14. package/dist/cjs/StorageUtils.js +0 -2
  15. package/dist/cjs/constants.js +0 -20
  16. package/dist/cjs/cryptography/utils.js +0 -251
  17. package/dist/cjs/errors.js +0 -27
  18. package/dist/cjs/external/mpcComputationClient.js +0 -33
  19. package/dist/cjs/external/userManagementClient.js +0 -66
  20. package/dist/cjs/package.json +0 -1
  21. package/dist/cjs/shares/KeyContainer.js +0 -84
  22. package/dist/cjs/shares/recovery.js +0 -62
  23. package/dist/cjs/shares/shareDistribution.js +0 -67
  24. package/dist/cjs/transmission/transmissionUtils.js +0 -73
  25. package/dist/cjs/types/config.js +0 -22
  26. package/dist/cjs/types/events.js +0 -17
  27. package/dist/cjs/types/index.js +0 -30
  28. package/dist/cjs/types/onRamps.js +0 -10
  29. package/dist/cjs/types/params.js +0 -2
  30. package/dist/cjs/types/popup.js +0 -12
  31. package/dist/cjs/types/recovery.js +0 -12
  32. package/dist/cjs/types/theme.js +0 -2
  33. package/dist/cjs/types/wallet.js +0 -9
  34. package/dist/cjs/utils/events.js +0 -9
  35. package/dist/cjs/utils/formatting.js +0 -81
  36. package/dist/cjs/utils/index.js +0 -22
  37. package/dist/cjs/utils/onRamps.js +0 -36
  38. package/dist/cjs/utils/polling.js +0 -25
  39. package/dist/cjs/utils/url.js +0 -74
  40. package/dist/cjs/utils/wallet.js +0 -74
  41. package/dist/esm/ParaCore.js +0 -2590
  42. package/dist/esm/PlatformUtils.js +0 -1
  43. package/dist/esm/StorageUtils.js +0 -1
  44. package/dist/esm/constants.js +0 -17
  45. package/dist/esm/cryptography/utils.js +0 -226
  46. package/dist/esm/errors.js +0 -21
  47. package/dist/esm/external/mpcComputationClient.js +0 -26
  48. package/dist/esm/external/userManagementClient.js +0 -56
  49. package/dist/esm/package.json +0 -1
  50. package/dist/esm/shares/KeyContainer.js +0 -57
  51. package/dist/esm/shares/recovery.js +0 -58
  52. package/dist/esm/shares/shareDistribution.js +0 -63
  53. package/dist/esm/transmission/transmissionUtils.js +0 -45
  54. package/dist/esm/types/config.js +0 -19
  55. package/dist/esm/types/events.js +0 -14
  56. package/dist/esm/types/index.js +0 -9
  57. package/dist/esm/types/onRamps.js +0 -7
  58. package/dist/esm/types/params.js +0 -1
  59. package/dist/esm/types/popup.js +0 -9
  60. package/dist/esm/types/recovery.js +0 -9
  61. package/dist/esm/types/theme.js +0 -1
  62. package/dist/esm/types/wallet.js +0 -6
  63. package/dist/esm/utils/events.js +0 -5
  64. package/dist/esm/utils/formatting.js +0 -66
  65. package/dist/esm/utils/index.js +0 -6
  66. package/dist/esm/utils/onRamps.js +0 -30
  67. package/dist/esm/utils/polling.js +0 -21
  68. package/dist/esm/utils/url.js +0 -66
  69. package/dist/esm/utils/wallet.js +0 -64
@@ -1,73 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
- return new (P || (P = Promise))(function (resolve, reject) {
28
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
- step((generator = generator.apply(thisArg, _arguments || [])).next());
32
- });
33
- };
34
- Object.defineProperty(exports, "__esModule", { value: true });
35
- exports.retrieve = exports.upload = void 0;
36
- const crypto_1 = require("crypto");
37
- const ecies_js_1 = require("@celo/utils/lib/ecies.js");
38
- const buffer_1 = require("buffer");
39
- const eutil = __importStar(require("ethereumjs-util"));
40
- function upload(message, userManagementClient) {
41
- return __awaiter(this, void 0, void 0, function* () {
42
- let secret;
43
- let publicKeyUint8Array;
44
- while (true) {
45
- try {
46
- secret = (0, crypto_1.randomBytes)(32).toString('hex');
47
- // privateToPublic throws error when private key is larger than group order
48
- // so we want to keep trying until we get a valid private key
49
- publicKeyUint8Array = eutil.privateToPublic(buffer_1.Buffer.from(secret, 'hex'));
50
- break;
51
- }
52
- catch (e) {
53
- continue;
54
- }
55
- }
56
- const pubkey = buffer_1.Buffer.from(publicKeyUint8Array);
57
- const data = (0, ecies_js_1.Encrypt)(pubkey, buffer_1.Buffer.from(message, 'ucs2')).toString('base64');
58
- const { data: { id }, } = yield userManagementClient.tempTrasmissionInit(data);
59
- return encodeURIComponent(id + '|' + secret);
60
- });
61
- }
62
- exports.upload = upload;
63
- function retrieve(uriEncodedMessage, userManagementClient) {
64
- return __awaiter(this, void 0, void 0, function* () {
65
- const [id, secret] = decodeURIComponent(uriEncodedMessage).split('|');
66
- const response = yield userManagementClient.tempTrasmission(id);
67
- const data = response.data.message;
68
- const buf = buffer_1.Buffer.from(data, 'base64');
69
- const res = buffer_1.Buffer.from((0, ecies_js_1.Decrypt)(buffer_1.Buffer.from(secret, 'hex'), buf).buffer).toString('ucs2');
70
- return res;
71
- });
72
- }
73
- exports.retrieve = retrieve;
@@ -1,22 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.EnabledFlow = exports.Environment = void 0;
4
- const user_management_client_1 = require("@getpara/user-management-client");
5
- var Environment;
6
- (function (Environment) {
7
- // Internal Environments
8
- Environment["DEV"] = "DEV";
9
- Environment["SANDBOX"] = "SANDBOX";
10
- Environment["BETA"] = "BETA";
11
- Environment["PROD"] = "PROD";
12
- // Customer-Facing Environments
13
- // NOTE: these resolve to the corresponding internal environments for convenience
14
- Environment["DEVELOPMENT"] = "BETA";
15
- Environment["PRODUCTION"] = "PROD";
16
- })(Environment || (exports.Environment = Environment = {}));
17
- var EnabledFlow;
18
- (function (EnabledFlow) {
19
- EnabledFlow["BUY"] = "BUY";
20
- EnabledFlow["RECEIVE"] = "RECEIVE";
21
- EnabledFlow["WITHDRAW"] = "WITHDRAW";
22
- })(EnabledFlow || (exports.EnabledFlow = EnabledFlow = {}));
@@ -1,17 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ParaEvent = void 0;
4
- const EVENT_PREFIX = 'para';
5
- var ParaEvent;
6
- (function (ParaEvent) {
7
- ParaEvent["LOGIN_EVENT"] = "paraLogin";
8
- ParaEvent["ACCOUNT_CREATION_EVENT"] = "paraAccountCreation";
9
- ParaEvent["ACCOUNT_SETUP_EVENT"] = "paraAccountSetup";
10
- ParaEvent["LOGOUT_EVENT"] = "paraLogout";
11
- ParaEvent["SIGN_MESSAGE_EVENT"] = "paraSignMessage";
12
- ParaEvent["SIGN_TRANSACTION_EVENT"] = "paraSignTransaction";
13
- ParaEvent["EXTERNAL_WALLET_CHANGE_EVENT"] = "paraExternalWalletChange";
14
- ParaEvent["WALLETS_CHANGE_EVENT"] = "paraWalletsChange";
15
- ParaEvent["WALLET_CREATED"] = "paraWalletCreated";
16
- ParaEvent["PREGEN_WALLET_CLAIMED"] = "paraPregenWalletClaimed";
17
- })(ParaEvent || (exports.ParaEvent = ParaEvent = {}));
@@ -1,30 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.OnRampPurchaseStatus = exports.OnRampProvider = exports.OnRampAsset = exports.Network = void 0;
18
- __exportStar(require("./config.js"), exports);
19
- __exportStar(require("./wallet.js"), exports);
20
- __exportStar(require("./params.js"), exports);
21
- __exportStar(require("./theme.js"), exports);
22
- __exportStar(require("./onRamps.js"), exports);
23
- __exportStar(require("./popup.js"), exports);
24
- __exportStar(require("./recovery.js"), exports);
25
- __exportStar(require("./events.js"), exports);
26
- var user_management_client_1 = require("@getpara/user-management-client");
27
- Object.defineProperty(exports, "Network", { enumerable: true, get: function () { return user_management_client_1.Network; } });
28
- Object.defineProperty(exports, "OnRampAsset", { enumerable: true, get: function () { return user_management_client_1.OnRampAsset; } });
29
- Object.defineProperty(exports, "OnRampProvider", { enumerable: true, get: function () { return user_management_client_1.OnRampProvider; } });
30
- Object.defineProperty(exports, "OnRampPurchaseStatus", { enumerable: true, get: function () { return user_management_client_1.OnRampPurchaseStatus; } });
@@ -1,10 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.OnRampMethod = void 0;
4
- var OnRampMethod;
5
- (function (OnRampMethod) {
6
- OnRampMethod["ACH"] = "ACH";
7
- OnRampMethod["DEBIT"] = "Debit";
8
- OnRampMethod["CREDIT"] = "Credit";
9
- OnRampMethod["APPLE_PAY"] = "Apple Pay";
10
- })(OnRampMethod || (exports.OnRampMethod = OnRampMethod = {}));
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PopupType = void 0;
4
- var PopupType;
5
- (function (PopupType) {
6
- PopupType["SIGN_TRANSACTION_REVIEW"] = "SIGN_TRANSACTION_REVIEW";
7
- PopupType["SIGN_MESSAGE_REVIEW"] = "SIGN_MESSAGE_REVIEW";
8
- PopupType["LOGIN_PASSKEY"] = "LOGIN_PASSKEY";
9
- PopupType["CREATE_PASSKEY"] = "CREATE_PASSKEY";
10
- PopupType["OAUTH"] = "OAUTH";
11
- PopupType["ON_RAMP_TRANSACTION"] = "ON_RAMP_TRANSACTION";
12
- })(PopupType || (exports.PopupType = PopupType = {}));
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RecoveryStatus = void 0;
4
- // Make sure to keep this in sync with capsule-org/src/entities/recoveryAttemptEntity.ts
5
- var RecoveryStatus;
6
- (function (RecoveryStatus) {
7
- RecoveryStatus["INITIATED"] = "INITIATED";
8
- RecoveryStatus["READY"] = "READY";
9
- RecoveryStatus["EXPIRED"] = "EXPIRED";
10
- RecoveryStatus["FINISHED"] = "FINISHED";
11
- RecoveryStatus["CANCELLED"] = "CANCELLED";
12
- })(RecoveryStatus || (exports.RecoveryStatus = RecoveryStatus = {}));
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,9 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PregenIdentifierType = void 0;
4
- /** @deprecated */
5
- var PregenIdentifierType;
6
- (function (PregenIdentifierType) {
7
- PregenIdentifierType["EMAIL"] = "EMAIL";
8
- PregenIdentifierType["PHONE"] = "PHONE";
9
- })(PregenIdentifierType || (exports.PregenIdentifierType = PregenIdentifierType = {}));
@@ -1,9 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.dispatchEvent = void 0;
4
- function dispatchEvent(type, data, error) {
5
- typeof window !== 'undefined' &&
6
- !!window.dispatchEvent &&
7
- window.dispatchEvent(new CustomEvent(type, { detail: Object.assign({ data }, (error && { error: new Error(error) })) }));
8
- }
9
- exports.dispatchEvent = dispatchEvent;
@@ -1,81 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.normalizePhoneNumber = exports.stringToPhoneNumber = exports.truncateAddress = exports.getCosmosAddress = exports.decimalToHex = exports.hexToDecimal = exports.hexToUint8Array = exports.hexToSignature = exports.hexStringToBase64 = void 0;
7
- const encoding_1 = require("@cosmjs/encoding");
8
- const sha256_1 = require("@noble/hashes/sha256");
9
- const ripemd160_1 = require("@noble/hashes/ripemd160");
10
- const elliptic_1 = __importDefault(require("elliptic"));
11
- const libphonenumber_js_1 = __importDefault(require("libphonenumber-js"));
12
- const secp256k1 = new elliptic_1.default.ec('secp256k1');
13
- function hexStringToBase64(hexString) {
14
- if (hexString.substring(0, 2) === '0x') {
15
- hexString = hexString.substring(2);
16
- }
17
- return Buffer.from(hexString, 'hex').toString('base64');
18
- }
19
- exports.hexStringToBase64 = hexStringToBase64;
20
- function hexToSignature(hexSig) {
21
- return {
22
- r: `0x${hexSig.slice(2, 66)}`,
23
- s: `0x${hexSig.slice(66, 130)}`,
24
- v: BigInt(hexSig.slice(130, 132)),
25
- };
26
- }
27
- exports.hexToSignature = hexToSignature;
28
- function hexToUint8Array(hex) {
29
- if (hex.startsWith('0x')) {
30
- hex = hex.slice(2);
31
- }
32
- return new Uint8Array(Buffer.from(hex, 'hex'));
33
- }
34
- exports.hexToUint8Array = hexToUint8Array;
35
- function hexToDecimal(hex) {
36
- if (hex.startsWith('0x')) {
37
- hex = hex.slice(2);
38
- }
39
- return `${parseInt(hex, 16)}`;
40
- }
41
- exports.hexToDecimal = hexToDecimal;
42
- function decimalToHex(decimal) {
43
- return `0x${parseInt(decimal).toString(16)}`;
44
- }
45
- exports.decimalToHex = decimalToHex;
46
- function compressPubkey(pubkey) {
47
- switch (pubkey.length) {
48
- case 33:
49
- return pubkey;
50
- case 65:
51
- return Uint8Array.from(secp256k1.keyFromPublic(pubkey).getPublic(true, 'array'));
52
- default:
53
- throw new Error('Invalid pubkey length');
54
- }
55
- }
56
- function rawSecp256k1PubkeyToRawAddress(pubkeyData) {
57
- if (pubkeyData.length !== 33) {
58
- throw new Error(`Invalid Secp256k1 pubkey length (compressed): ${pubkeyData.length}`);
59
- }
60
- return (0, ripemd160_1.ripemd160)((0, sha256_1.sha256)(pubkeyData));
61
- }
62
- function getCosmosAddress(publicKey, prefix) {
63
- const uncompressedPublicKey = new Uint8Array(Buffer.from(publicKey.startsWith('0x') ? publicKey.slice(2) : publicKey, 'hex'));
64
- const compressedPublicKey = compressPubkey(uncompressedPublicKey);
65
- return (0, encoding_1.toBech32)(prefix, rawSecp256k1PubkeyToRawAddress(compressedPublicKey));
66
- }
67
- exports.getCosmosAddress = getCosmosAddress;
68
- function truncateAddress(str, addressType, { prefix = addressType === 'COSMOS' ? 'cosmos' : undefined } = {}) {
69
- const headLength = (addressType === 'COSMOS' ? prefix.length : addressType === 'SOLANA' ? 0 : 2) + 4;
70
- return `${str.slice(0, headLength)}...${str.slice(-4)}`;
71
- }
72
- exports.truncateAddress = truncateAddress;
73
- function stringToPhoneNumber(str) {
74
- var _a;
75
- return (_a = (0, libphonenumber_js_1.default)(str)) === null || _a === void 0 ? void 0 : _a.formatInternational().replace(/[^\d+]/g, '');
76
- }
77
- exports.stringToPhoneNumber = stringToPhoneNumber;
78
- function normalizePhoneNumber(countryCode, number) {
79
- return stringToPhoneNumber(`${countryCode[0] !== '+' ? '+' : ''}${countryCode}${number}`);
80
- }
81
- exports.normalizePhoneNumber = normalizePhoneNumber;
@@ -1,22 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./events.js"), exports);
18
- __exportStar(require("./formatting.js"), exports);
19
- __exportStar(require("./onRamps.js"), exports);
20
- __exportStar(require("./polling.js"), exports);
21
- __exportStar(require("./url.js"), exports);
22
- __exportStar(require("./wallet.js"), exports);
@@ -1,36 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getOnRampAssets = exports.getOnRampNetworks = exports.toAssetInfoArray = void 0;
4
- function toAssetInfoArray(data) {
5
- const result = [];
6
- Object.keys(data).forEach(walletType => {
7
- const networks = data[walletType];
8
- Object.keys(networks).forEach(network => {
9
- const assets = networks[network];
10
- Object.keys(assets).forEach(asset => {
11
- const providerInfo = assets[asset];
12
- result.push([walletType, network, asset, providerInfo]);
13
- });
14
- });
15
- });
16
- return result;
17
- }
18
- exports.toAssetInfoArray = toAssetInfoArray;
19
- function getOnRampNetworks(data, { walletType, allowed } = {}) {
20
- return [
21
- ...new Set(toAssetInfoArray(data)
22
- .filter(([type, network]) => (!walletType || type === walletType) && (!allowed || allowed.includes(network)))
23
- .map(([_, network]) => network)),
24
- ];
25
- }
26
- exports.getOnRampNetworks = getOnRampNetworks;
27
- function getOnRampAssets(data, { walletType, network, allowed, } = {}) {
28
- return [
29
- ...new Set(toAssetInfoArray(data)
30
- .filter(([t, n, a]) => (!walletType || t === walletType) &&
31
- (!network || n === network) &&
32
- (!Array.isArray(allowed) || allowed.includes(a)))
33
- .map(([, , asset]) => asset)),
34
- ];
35
- }
36
- exports.getOnRampAssets = getOnRampAssets;
@@ -1,25 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.waitUntilTrue = void 0;
13
- function waitUntilTrue(condition, timeoutMs, intervalMs) {
14
- return __awaiter(this, void 0, void 0, function* () {
15
- const start = Date.now();
16
- while (Date.now() - start < timeoutMs) {
17
- if (yield condition()) {
18
- return true;
19
- }
20
- yield new Promise(resolve => setTimeout(resolve, intervalMs));
21
- }
22
- return false;
23
- });
24
- }
25
- exports.waitUntilTrue = waitUntilTrue;
@@ -1,74 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.constructUrl = exports.getParaConnectBaseUrl = exports.getParaConnectDomain = exports.getPortalBaseURL = exports.getPortalDomain = void 0;
4
- const index_js_1 = require("../types/index.js");
5
- function getPortalDomain(env, isE2E) {
6
- if (isE2E) {
7
- return `localhost`;
8
- }
9
- switch (env) {
10
- case index_js_1.Environment.DEV:
11
- return 'localhost';
12
- case index_js_1.Environment.SANDBOX:
13
- return 'app.sandbox.usecapsule.com';
14
- case index_js_1.Environment.BETA:
15
- return 'app.beta.usecapsule.com';
16
- case index_js_1.Environment.PROD:
17
- return 'app.usecapsule.com';
18
- default:
19
- throw new Error(`env: ${env} not supported`);
20
- }
21
- }
22
- exports.getPortalDomain = getPortalDomain;
23
- function getPortalBaseURL({ env, isE2E }, useLocalIp, isForWasm) {
24
- if (isE2E) {
25
- if (isForWasm) {
26
- return `https://app.sandbox.usecapsule.com`;
27
- }
28
- return `http://localhost:3003`;
29
- }
30
- const domain = getPortalDomain(env);
31
- if (env === index_js_1.Environment.DEV) {
32
- if (useLocalIp) {
33
- return `http://127.0.0.1:3003`;
34
- }
35
- return `http://${domain}:3003`;
36
- }
37
- return `https://${domain}`;
38
- }
39
- exports.getPortalBaseURL = getPortalBaseURL;
40
- function getParaConnectDomain(env) {
41
- switch (env) {
42
- case index_js_1.Environment.DEV:
43
- return 'localhost';
44
- case index_js_1.Environment.SANDBOX:
45
- return 'connect.sandbox.getpara.com';
46
- case index_js_1.Environment.BETA:
47
- return 'connect.beta.getpara.com';
48
- case index_js_1.Environment.PROD:
49
- return 'connect.getpara.com';
50
- default:
51
- throw new Error(`env: ${env} not supported`);
52
- }
53
- }
54
- exports.getParaConnectDomain = getParaConnectDomain;
55
- function getParaConnectBaseUrl({ env }, useLocalIp) {
56
- const domain = getParaConnectDomain(env);
57
- if (env === index_js_1.Environment.DEV) {
58
- if (useLocalIp) {
59
- return `http://127.0.0.1:3008`;
60
- }
61
- return `http://${domain}:3008`;
62
- }
63
- return `https://${domain}`;
64
- }
65
- exports.getParaConnectBaseUrl = getParaConnectBaseUrl;
66
- function constructUrl({ base, path, params = {}, }) {
67
- const url = new URL(path, base);
68
- Object.entries(params).forEach(([key, value]) => {
69
- if (!!value && value !== 'undefined' && value !== 'null')
70
- url.searchParams.set(key, value.toString());
71
- });
72
- return url.toString();
73
- }
74
- exports.constructUrl = constructUrl;
@@ -1,74 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.migrateWallet = exports.entityToWallet = exports.getEquivalentTypes = exports.getWalletTypes = exports.getSchemes = exports.isWalletSupported = exports.isPregenIdentifierMatch = exports.WalletSchemeTypeMap = void 0;
4
- const user_management_client_1 = require("@getpara/user-management-client");
5
- const formatting_js_1 = require("./formatting.js");
6
- exports.WalletSchemeTypeMap = {
7
- [user_management_client_1.WalletScheme.DKLS]: {
8
- [user_management_client_1.WalletType.EVM]: true,
9
- [user_management_client_1.WalletType.COSMOS]: true,
10
- },
11
- [user_management_client_1.WalletScheme.CGGMP]: {
12
- [user_management_client_1.WalletType.EVM]: true,
13
- [user_management_client_1.WalletType.COSMOS]: true,
14
- },
15
- [user_management_client_1.WalletScheme.ED25519]: {
16
- [user_management_client_1.WalletType.SOLANA]: true,
17
- },
18
- };
19
- function isPregenIdentifierMatch(a, b, type) {
20
- if (!a || !b) {
21
- return false;
22
- }
23
- switch (type) {
24
- case 'EMAIL':
25
- return a.toLowerCase() === b.toLowerCase();
26
- case 'PHONE':
27
- return (0, formatting_js_1.stringToPhoneNumber)(a) === (0, formatting_js_1.stringToPhoneNumber)(b);
28
- case 'CUSTOM_ID':
29
- return a === b;
30
- default:
31
- return a.replace(/^@/g, '').toLowerCase() === b.replace(/^@/g, '').toLowerCase();
32
- }
33
- }
34
- exports.isPregenIdentifierMatch = isPregenIdentifierMatch;
35
- function isWalletSupported(types, wallet) {
36
- return types.some((walletType) => !!exports.WalletSchemeTypeMap[wallet.scheme][walletType]);
37
- }
38
- exports.isWalletSupported = isWalletSupported;
39
- function getSchemes(types) {
40
- return Object.keys(exports.WalletSchemeTypeMap).filter(scheme => {
41
- if (scheme === user_management_client_1.WalletScheme.CGGMP) {
42
- return false;
43
- }
44
- return (Array.isArray(types) ? types : Object.keys(types)).some(type => exports.WalletSchemeTypeMap[scheme][type]);
45
- });
46
- }
47
- exports.getSchemes = getSchemes;
48
- function getWalletTypes(schemes) {
49
- return [
50
- ...new Set(schemes.reduce((acc, scheme) => {
51
- return [...acc, ...Object.keys(exports.WalletSchemeTypeMap[scheme]).filter(type => exports.WalletSchemeTypeMap[scheme][type])];
52
- }, [])),
53
- ];
54
- }
55
- exports.getWalletTypes = getWalletTypes;
56
- function getEquivalentTypes(types) {
57
- return getWalletTypes(getSchemes((Array.isArray(types) ? types : [types]).map(t => user_management_client_1.WalletType[t])));
58
- }
59
- exports.getEquivalentTypes = getEquivalentTypes;
60
- function entityToWallet(w) {
61
- return Object.assign(Object.assign({}, w), { scheme: w.scheme, type: w.type, pregenIdentifierType: w.pregenIdentifierType });
62
- }
63
- exports.entityToWallet = entityToWallet;
64
- function migrateWallet(obj) {
65
- if (['USER', 'PREGEN'].includes(obj.type)) {
66
- obj.isPregen = obj.type === 'PREGEN';
67
- obj.type = obj.scheme === user_management_client_1.WalletScheme.ED25519 ? user_management_client_1.WalletType.SOLANA : user_management_client_1.WalletType.EVM;
68
- }
69
- if (!!obj.scheme && !obj.type) {
70
- obj.type = obj.scheme === user_management_client_1.WalletScheme.ED25519 ? user_management_client_1.WalletType.SOLANA : user_management_client_1.WalletType.EVM;
71
- }
72
- return obj;
73
- }
74
- exports.migrateWallet = migrateWallet;