@getpara/core-sdk 1.8.0 → 2.0.0-alpha.3

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 (86) hide show
  1. package/dist/cjs/index.js +4000 -76
  2. package/dist/cjs/index.js.br +0 -0
  3. package/dist/cjs/index.js.gz +0 -0
  4. package/dist/esm/index.js +3964 -53
  5. package/dist/esm/index.js.br +0 -0
  6. package/dist/esm/index.js.gz +0 -0
  7. package/dist/types/ParaCore.d.ts +178 -489
  8. package/dist/types/constants.d.ts +2 -1
  9. package/dist/types/external/userManagementClient.d.ts +1 -1
  10. package/dist/types/index.d.ts +5 -3
  11. package/dist/types/types/config.d.ts +1 -19
  12. package/dist/types/types/coreApi.d.ts +437 -0
  13. package/dist/types/types/index.d.ts +2 -1
  14. package/dist/types/types/methods.d.ts +143 -0
  15. package/dist/types/types/wallet.d.ts +2 -4
  16. package/dist/types/utils/autobind.d.ts +1 -0
  17. package/dist/types/utils/formatting.d.ts +0 -2
  18. package/dist/types/utils/index.d.ts +5 -0
  19. package/dist/types/utils/json.d.ts +1 -0
  20. package/dist/types/utils/phone.d.ts +7 -0
  21. package/dist/types/utils/types.d.ts +2 -0
  22. package/dist/types/utils/url.d.ts +2 -1
  23. package/dist/types/utils/wallet.d.ts +4 -2
  24. package/package.json +6 -5
  25. package/dist/cjs/ParaCore.js +0 -2964
  26. package/dist/cjs/PlatformUtils.js +0 -15
  27. package/dist/cjs/StorageUtils.js +0 -15
  28. package/dist/cjs/constants.js +0 -75
  29. package/dist/cjs/cryptography/utils.js +0 -350
  30. package/dist/cjs/errors.js +0 -51
  31. package/dist/cjs/external/mpcComputationClient.js +0 -62
  32. package/dist/cjs/external/userManagementClient.js +0 -106
  33. package/dist/cjs/package.json +0 -3
  34. package/dist/cjs/shares/KeyContainer.js +0 -89
  35. package/dist/cjs/shares/recovery.js +0 -127
  36. package/dist/cjs/shares/shareDistribution.js +0 -104
  37. package/dist/cjs/transmission/transmissionUtils.js +0 -93
  38. package/dist/cjs/types/config.js +0 -43
  39. package/dist/cjs/types/events.js +0 -40
  40. package/dist/cjs/types/index.js +0 -50
  41. package/dist/cjs/types/onRamps.js +0 -33
  42. package/dist/cjs/types/params.js +0 -15
  43. package/dist/cjs/types/popup.js +0 -35
  44. package/dist/cjs/types/recovery.js +0 -34
  45. package/dist/cjs/types/theme.js +0 -15
  46. package/dist/cjs/types/wallet.js +0 -31
  47. package/dist/cjs/utils/events.js +0 -45
  48. package/dist/cjs/utils/formatting.js +0 -120
  49. package/dist/cjs/utils/index.js +0 -31
  50. package/dist/cjs/utils/listeners.js +0 -80
  51. package/dist/cjs/utils/onRamps.js +0 -64
  52. package/dist/cjs/utils/polling.js +0 -58
  53. package/dist/cjs/utils/url.js +0 -103
  54. package/dist/cjs/utils/wallet.js +0 -130
  55. package/dist/esm/ParaCore.js +0 -2913
  56. package/dist/esm/PlatformUtils.js +0 -0
  57. package/dist/esm/StorageUtils.js +0 -0
  58. package/dist/esm/chunk-UICEQADR.js +0 -68
  59. package/dist/esm/constants.js +0 -37
  60. package/dist/esm/cryptography/utils.js +0 -282
  61. package/dist/esm/errors.js +0 -27
  62. package/dist/esm/external/mpcComputationClient.js +0 -30
  63. package/dist/esm/external/userManagementClient.js +0 -71
  64. package/dist/esm/package.json +0 -4
  65. package/dist/esm/shares/KeyContainer.js +0 -57
  66. package/dist/esm/shares/recovery.js +0 -74
  67. package/dist/esm/shares/shareDistribution.js +0 -64
  68. package/dist/esm/transmission/transmissionUtils.js +0 -42
  69. package/dist/esm/types/config.js +0 -20
  70. package/dist/esm/types/events.js +0 -18
  71. package/dist/esm/types/index.js +0 -21
  72. package/dist/esm/types/onRamps.js +0 -11
  73. package/dist/esm/types/params.js +0 -0
  74. package/dist/esm/types/popup.js +0 -13
  75. package/dist/esm/types/recovery.js +0 -12
  76. package/dist/esm/types/theme.js +0 -0
  77. package/dist/esm/types/wallet.js +0 -9
  78. package/dist/esm/utils/events.js +0 -11
  79. package/dist/esm/utils/formatting.js +0 -80
  80. package/dist/esm/utils/index.js +0 -6
  81. package/dist/esm/utils/listeners.js +0 -47
  82. package/dist/esm/utils/onRamps.js +0 -40
  83. package/dist/esm/utils/polling.js +0 -18
  84. package/dist/esm/utils/url.js +0 -77
  85. package/dist/esm/utils/wallet.js +0 -87
  86. package/dist/types/types/params.d.ts +0 -70
@@ -1,64 +0,0 @@
1
- import {
2
- __async
3
- } from "../chunk-UICEQADR.js";
4
- import { EncryptorType, KeyShareType } from "@getpara/user-management-client";
5
- import { encryptWithDerivedPublicKey } from "../cryptography/utils.js";
6
- import { sendRecoveryForShare } from "./recovery.js";
7
- function distributeNewShare(_0) {
8
- return __async(this, arguments, function* ({
9
- ctx,
10
- userId,
11
- walletId,
12
- userShare,
13
- ignoreRedistributingBackupEncryptedShare = false,
14
- emailProps = {},
15
- partnerId,
16
- protocolId
17
- }) {
18
- const publicKeysRes = yield ctx.client.getSessionPublicKeys(userId);
19
- const biometricEncryptedShares = publicKeysRes.data.keys.map((key) => {
20
- if (!key.publicKey) {
21
- return;
22
- }
23
- const { encryptedMessageHex, encryptedKeyHex } = encryptWithDerivedPublicKey(key.sigDerivedPublicKey, userShare);
24
- return {
25
- encryptedShare: encryptedMessageHex,
26
- encryptedKey: encryptedKeyHex,
27
- type: KeyShareType.USER,
28
- encryptor: EncryptorType.BIOMETRICS,
29
- biometricPublicKey: key.sigDerivedPublicKey,
30
- partnerId,
31
- protocolId
32
- };
33
- }).filter(Boolean);
34
- const passwords = yield ctx.client.getPasswords({ userId });
35
- const passwordEncryptedShares = passwords.map((password) => {
36
- if (password.status === "PENDING") {
37
- return;
38
- }
39
- const { encryptedMessageHex, encryptedKeyHex } = encryptWithDerivedPublicKey(password.sigDerivedPublicKey, userShare);
40
- return {
41
- encryptedShare: encryptedMessageHex,
42
- encryptedKey: encryptedKeyHex,
43
- type: KeyShareType.USER,
44
- encryptor: EncryptorType.PASSWORD,
45
- passwordId: password.id,
46
- partnerId,
47
- protocolId
48
- };
49
- }).filter(Boolean);
50
- const allEncryptedShares = [...biometricEncryptedShares, ...passwordEncryptedShares];
51
- return yield sendRecoveryForShare({
52
- ctx,
53
- userId,
54
- walletId,
55
- otherEncryptedShares: allEncryptedShares,
56
- userSigner: userShare,
57
- ignoreRedistributingBackupEncryptedShare,
58
- emailProps
59
- });
60
- });
61
- }
62
- export {
63
- distributeNewShare
64
- };
@@ -1,42 +0,0 @@
1
- import {
2
- __async
3
- } from "../chunk-UICEQADR.js";
4
- import { Encrypt as ECIESEncrypt, Decrypt as ECIESDecrypt } from "@celo/utils/lib/ecies.js";
5
- import { Buffer } from "buffer";
6
- import * as eutil from "@ethereumjs/util";
7
- import { randomBytes } from "crypto";
8
- function upload(message, userManagementClient) {
9
- return __async(this, null, function* () {
10
- let secret;
11
- let publicKeyUint8Array;
12
- while (true) {
13
- try {
14
- secret = randomBytes(32).toString("hex");
15
- publicKeyUint8Array = eutil.privateToPublic(Buffer.from(secret, "hex"));
16
- break;
17
- } catch (e) {
18
- continue;
19
- }
20
- }
21
- const pubkey = Buffer.from(publicKeyUint8Array);
22
- const data = ECIESEncrypt(pubkey, Buffer.from(message, "ucs2")).toString("base64");
23
- const {
24
- data: { id }
25
- } = yield userManagementClient.tempTrasmissionInit(data);
26
- return encodeURIComponent(id + "|" + secret);
27
- });
28
- }
29
- function retrieve(uriEncodedMessage, userManagementClient) {
30
- return __async(this, null, function* () {
31
- const [id, secret] = decodeURIComponent(uriEncodedMessage).split("|");
32
- const response = yield userManagementClient.tempTrasmission(id);
33
- const data = response.data.message;
34
- const buf = Buffer.from(data, "base64");
35
- const res = Buffer.from(ECIESDecrypt(Buffer.from(secret, "hex"), buf).buffer).toString("ucs2");
36
- return res;
37
- });
38
- }
39
- export {
40
- retrieve,
41
- upload
42
- };
@@ -1,20 +0,0 @@
1
- import "../chunk-UICEQADR.js";
2
- var Environment = /* @__PURE__ */ ((Environment2) => {
3
- Environment2["DEV"] = "DEV";
4
- Environment2["SANDBOX"] = "SANDBOX";
5
- Environment2["BETA"] = "BETA";
6
- Environment2["PROD"] = "PROD";
7
- Environment2["DEVELOPMENT"] = "BETA";
8
- Environment2["PRODUCTION"] = "PROD";
9
- return Environment2;
10
- })(Environment || {});
11
- var EnabledFlow = /* @__PURE__ */ ((EnabledFlow2) => {
12
- EnabledFlow2["BUY"] = "BUY";
13
- EnabledFlow2["RECEIVE"] = "RECEIVE";
14
- EnabledFlow2["WITHDRAW"] = "WITHDRAW";
15
- return EnabledFlow2;
16
- })(EnabledFlow || {});
17
- export {
18
- EnabledFlow,
19
- Environment
20
- };
@@ -1,18 +0,0 @@
1
- import "../chunk-UICEQADR.js";
2
- const EVENT_PREFIX = "para";
3
- var ParaEvent = ((ParaEvent2) => {
4
- ParaEvent2["LOGIN_EVENT"] = `${EVENT_PREFIX}Login`;
5
- ParaEvent2["ACCOUNT_CREATION_EVENT"] = `${EVENT_PREFIX}AccountCreation`;
6
- ParaEvent2["ACCOUNT_SETUP_EVENT"] = `${EVENT_PREFIX}AccountSetup`;
7
- ParaEvent2["LOGOUT_EVENT"] = `${EVENT_PREFIX}Logout`;
8
- ParaEvent2["SIGN_MESSAGE_EVENT"] = `${EVENT_PREFIX}SignMessage`;
9
- ParaEvent2["SIGN_TRANSACTION_EVENT"] = `${EVENT_PREFIX}SignTransaction`;
10
- ParaEvent2["EXTERNAL_WALLET_CHANGE_EVENT"] = `${EVENT_PREFIX}ExternalWalletChange`;
11
- ParaEvent2["WALLETS_CHANGE_EVENT"] = `${EVENT_PREFIX}WalletsChange`;
12
- ParaEvent2["WALLET_CREATED"] = `${EVENT_PREFIX}WalletCreated`;
13
- ParaEvent2["PREGEN_WALLET_CLAIMED"] = `${EVENT_PREFIX}PregenWalletClaimed`;
14
- return ParaEvent2;
15
- })(ParaEvent || {});
16
- export {
17
- ParaEvent
18
- };
@@ -1,21 +0,0 @@
1
- import "../chunk-UICEQADR.js";
2
- export * from "./config.js";
3
- export * from "./wallet.js";
4
- export * from "./params.js";
5
- export * from "./theme.js";
6
- export * from "./onRamps.js";
7
- export * from "./popup.js";
8
- export * from "./recovery.js";
9
- export * from "./events.js";
10
- import {
11
- Network,
12
- OnRampAsset,
13
- OnRampProvider,
14
- OnRampPurchaseStatus
15
- } from "@getpara/user-management-client";
16
- export {
17
- Network,
18
- OnRampAsset,
19
- OnRampProvider,
20
- OnRampPurchaseStatus
21
- };
@@ -1,11 +0,0 @@
1
- import "../chunk-UICEQADR.js";
2
- var OnRampMethod = /* @__PURE__ */ ((OnRampMethod2) => {
3
- OnRampMethod2["ACH"] = "ACH";
4
- OnRampMethod2["DEBIT"] = "Debit";
5
- OnRampMethod2["CREDIT"] = "Credit";
6
- OnRampMethod2["APPLE_PAY"] = "Apple Pay";
7
- return OnRampMethod2;
8
- })(OnRampMethod || {});
9
- export {
10
- OnRampMethod
11
- };
File without changes
@@ -1,13 +0,0 @@
1
- import "../chunk-UICEQADR.js";
2
- var PopupType = /* @__PURE__ */ ((PopupType2) => {
3
- PopupType2["SIGN_TRANSACTION_REVIEW"] = "SIGN_TRANSACTION_REVIEW";
4
- PopupType2["SIGN_MESSAGE_REVIEW"] = "SIGN_MESSAGE_REVIEW";
5
- PopupType2["LOGIN_PASSKEY"] = "LOGIN_PASSKEY";
6
- PopupType2["CREATE_PASSKEY"] = "CREATE_PASSKEY";
7
- PopupType2["OAUTH"] = "OAUTH";
8
- PopupType2["ON_RAMP_TRANSACTION"] = "ON_RAMP_TRANSACTION";
9
- return PopupType2;
10
- })(PopupType || {});
11
- export {
12
- PopupType
13
- };
@@ -1,12 +0,0 @@
1
- import "../chunk-UICEQADR.js";
2
- var RecoveryStatus = /* @__PURE__ */ ((RecoveryStatus2) => {
3
- RecoveryStatus2["INITIATED"] = "INITIATED";
4
- RecoveryStatus2["READY"] = "READY";
5
- RecoveryStatus2["EXPIRED"] = "EXPIRED";
6
- RecoveryStatus2["FINISHED"] = "FINISHED";
7
- RecoveryStatus2["CANCELLED"] = "CANCELLED";
8
- return RecoveryStatus2;
9
- })(RecoveryStatus || {});
10
- export {
11
- RecoveryStatus
12
- };
File without changes
@@ -1,9 +0,0 @@
1
- import "../chunk-UICEQADR.js";
2
- var PregenIdentifierType = /* @__PURE__ */ ((PregenIdentifierType2) => {
3
- PregenIdentifierType2["EMAIL"] = "EMAIL";
4
- PregenIdentifierType2["PHONE"] = "PHONE";
5
- return PregenIdentifierType2;
6
- })(PregenIdentifierType || {});
7
- export {
8
- PregenIdentifierType
9
- };
@@ -1,11 +0,0 @@
1
- import {
2
- __spreadValues
3
- } from "../chunk-UICEQADR.js";
4
- function dispatchEvent(type, data, error) {
5
- typeof window !== "undefined" && !!window.dispatchEvent && window.dispatchEvent(
6
- new CustomEvent(type, { detail: __spreadValues({ data }, error && { error: new Error(error) }) })
7
- );
8
- }
9
- export {
10
- dispatchEvent
11
- };
@@ -1,80 +0,0 @@
1
- import "../chunk-UICEQADR.js";
2
- import { toBech32 } from "@cosmjs/encoding";
3
- import { sha256 } from "@noble/hashes/sha256";
4
- import { ripemd160 } from "@noble/hashes/ripemd160";
5
- import elliptic from "elliptic";
6
- import parsePhoneNumberFromString from "libphonenumber-js";
7
- const secp256k1 = new elliptic.ec("secp256k1");
8
- function hexStringToBase64(hexString) {
9
- if (hexString.substring(0, 2) === "0x") {
10
- hexString = hexString.substring(2);
11
- }
12
- return Buffer.from(hexString, "hex").toString("base64");
13
- }
14
- function hexToSignature(hexSig) {
15
- return {
16
- r: `0x${hexSig.slice(2, 66)}`,
17
- s: `0x${hexSig.slice(66, 130)}`,
18
- v: BigInt(hexSig.slice(130, 132))
19
- };
20
- }
21
- function hexToUint8Array(hex) {
22
- if (hex.startsWith("0x")) {
23
- hex = hex.slice(2);
24
- }
25
- return new Uint8Array(Buffer.from(hex, "hex"));
26
- }
27
- function hexToDecimal(hex) {
28
- if (hex.startsWith("0x")) {
29
- hex = hex.slice(2);
30
- }
31
- return `${parseInt(hex, 16)}`;
32
- }
33
- function decimalToHex(decimal) {
34
- return `0x${parseInt(decimal).toString(16)}`;
35
- }
36
- function compressPubkey(pubkey) {
37
- switch (pubkey.length) {
38
- case 33:
39
- return pubkey;
40
- case 65:
41
- return Uint8Array.from(secp256k1.keyFromPublic(pubkey).getPublic(true, "array"));
42
- default:
43
- throw new Error("Invalid pubkey length");
44
- }
45
- }
46
- function rawSecp256k1PubkeyToRawAddress(pubkeyData) {
47
- if (pubkeyData.length !== 33) {
48
- throw new Error(`Invalid Secp256k1 pubkey length (compressed): ${pubkeyData.length}`);
49
- }
50
- return ripemd160(sha256(pubkeyData));
51
- }
52
- function getCosmosAddress(publicKey, prefix) {
53
- const uncompressedPublicKey = new Uint8Array(
54
- Buffer.from(publicKey.startsWith("0x") ? publicKey.slice(2) : publicKey, "hex")
55
- );
56
- const compressedPublicKey = compressPubkey(uncompressedPublicKey);
57
- return toBech32(prefix, rawSecp256k1PubkeyToRawAddress(compressedPublicKey));
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)}`;
62
- }
63
- function stringToPhoneNumber(str) {
64
- var _a;
65
- return (_a = parsePhoneNumberFromString(str)) == null ? void 0 : _a.formatInternational().replace(/[^\d+]/g, "");
66
- }
67
- function normalizePhoneNumber(countryCode, number) {
68
- return stringToPhoneNumber(`${countryCode[0] !== "+" ? "+" : ""}${countryCode}${number}`);
69
- }
70
- export {
71
- decimalToHex,
72
- getCosmosAddress,
73
- hexStringToBase64,
74
- hexToDecimal,
75
- hexToSignature,
76
- hexToUint8Array,
77
- normalizePhoneNumber,
78
- stringToPhoneNumber,
79
- truncateAddress
80
- };
@@ -1,6 +0,0 @@
1
- export * from "./events.js";
2
- export * from "./formatting.js";
3
- export * from "./onRamps.js";
4
- export * from "./polling.js";
5
- export * from "./url.js";
6
- export * from "./wallet.js";
@@ -1,47 +0,0 @@
1
- import "../chunk-UICEQADR.js";
2
- import * as constants from "../constants.js";
3
- function storageListener(e) {
4
- if (!e.url.includes(window.location.origin)) {
5
- return;
6
- }
7
- if (e.key === constants.LOCAL_STORAGE_EXTERNAL_WALLETS) {
8
- this.updateExternalWalletsFromStorage();
9
- }
10
- if (e.key === constants.SESSION_STORAGE_LOGIN_ENCRYPTION_KEY_PAIR) {
11
- this.updateLoginEncryptionKeyPairFromStorage();
12
- }
13
- if (e.key === constants.LOCAL_STORAGE_SESSION_COOKIE) {
14
- this.updateSessionCookieFromStorage();
15
- }
16
- if (e.key === constants.LOCAL_STORAGE_CURRENT_WALLET_IDS) {
17
- this.updateWalletIdsFromStorage();
18
- }
19
- if (e.key === constants.LOCAL_STORAGE_WALLETS || e.key === constants.LOCAL_STORAGE_ED25519_WALLETS) {
20
- this.updateWalletsFromStorage();
21
- }
22
- if (e.key === constants.LOCAL_STORAGE_EMAIL) {
23
- this.updateEmailFromStorage();
24
- }
25
- if (e.key === constants.LOCAL_STORAGE_COUNTRY_CODE) {
26
- this.updateCountryCodeFromStorage();
27
- }
28
- if (e.key === constants.LOCAL_STORAGE_PHONE) {
29
- this.updatePhoneFromStorage();
30
- }
31
- if (e.key === constants.LOCAL_STORAGE_USER_ID) {
32
- this.updateUserIdFromStorage();
33
- }
34
- if (e.key === constants.LOCAL_STORAGE_TELEGRAM_USER_ID) {
35
- this.updateTelegramUserIdFromStorage();
36
- }
37
- }
38
- function setupListeners() {
39
- if (typeof window !== "undefined" && window.addEventListener && window.location) {
40
- window.removeEventListener("storage", storageListener.bind(this));
41
- window.addEventListener("storage", storageListener.bind(this));
42
- }
43
- }
44
- export {
45
- setupListeners,
46
- storageListener
47
- };
@@ -1,40 +0,0 @@
1
- import "../chunk-UICEQADR.js";
2
- function toAssetInfoArray(data) {
3
- const result = [];
4
- Object.keys(data).forEach((walletType) => {
5
- const networks = data[walletType];
6
- Object.keys(networks).forEach((network) => {
7
- const assets = networks[network];
8
- Object.keys(assets).forEach((asset) => {
9
- const providerInfo = assets[asset];
10
- result.push([walletType, network, asset, providerInfo]);
11
- });
12
- });
13
- });
14
- return result;
15
- }
16
- function getOnRampNetworks(data, { walletType, allowed } = {}) {
17
- return [
18
- ...new Set(
19
- toAssetInfoArray(data).filter(([type, network]) => (!walletType || type === walletType) && (!allowed || allowed.includes(network))).map(([_, network]) => network)
20
- )
21
- ];
22
- }
23
- function getOnRampAssets(data, {
24
- walletType,
25
- network,
26
- allowed
27
- } = {}) {
28
- return [
29
- ...new Set(
30
- toAssetInfoArray(data).filter(
31
- ([t, n, a]) => (!walletType || t === walletType) && (!network || n === network) && (!Array.isArray(allowed) || allowed.includes(a))
32
- ).map(([, , asset]) => asset)
33
- )
34
- ];
35
- }
36
- export {
37
- getOnRampAssets,
38
- getOnRampNetworks,
39
- toAssetInfoArray
40
- };
@@ -1,18 +0,0 @@
1
- import {
2
- __async
3
- } from "../chunk-UICEQADR.js";
4
- function waitUntilTrue(condition, timeoutMs, intervalMs) {
5
- return __async(this, null, function* () {
6
- const start = Date.now();
7
- while (Date.now() - start < timeoutMs) {
8
- if (yield condition()) {
9
- return true;
10
- }
11
- yield new Promise((resolve) => setTimeout(resolve, intervalMs));
12
- }
13
- return false;
14
- });
15
- }
16
- export {
17
- waitUntilTrue
18
- };
@@ -1,77 +0,0 @@
1
- import "../chunk-UICEQADR.js";
2
- import { Environment } from "../types/index.js";
3
- function getPortalDomain(env, isE2E) {
4
- if (isE2E) {
5
- return `localhost`;
6
- }
7
- switch (env) {
8
- case Environment.DEV:
9
- return "localhost";
10
- case Environment.SANDBOX:
11
- return "app.sandbox.usecapsule.com";
12
- case Environment.BETA:
13
- return "app.beta.usecapsule.com";
14
- case Environment.PROD:
15
- return "app.usecapsule.com";
16
- default:
17
- throw new Error(`env: ${env} not supported`);
18
- }
19
- }
20
- function getPortalBaseURL({ env, isE2E }, useLocalIp, isForWasm) {
21
- if (isE2E) {
22
- if (isForWasm) {
23
- return `https://app.sandbox.usecapsule.com`;
24
- }
25
- return `http://localhost:3003`;
26
- }
27
- const domain = getPortalDomain(env);
28
- if (env === Environment.DEV) {
29
- if (useLocalIp) {
30
- return `http://127.0.0.1:3003`;
31
- }
32
- return `http://${domain}:3003`;
33
- }
34
- return `https://${domain}`;
35
- }
36
- function getParaConnectDomain(env) {
37
- switch (env) {
38
- case Environment.DEV:
39
- return "localhost";
40
- case Environment.SANDBOX:
41
- return "connect.sandbox.getpara.com";
42
- case Environment.BETA:
43
- return "connect.beta.getpara.com";
44
- case Environment.PROD:
45
- return "connect.getpara.com";
46
- default:
47
- throw new Error(`env: ${env} not supported`);
48
- }
49
- }
50
- function getParaConnectBaseUrl({ env }, useLocalIp) {
51
- const domain = getParaConnectDomain(env);
52
- if (env === Environment.DEV) {
53
- if (useLocalIp) {
54
- return `http://127.0.0.1:3008`;
55
- }
56
- return `http://${domain}:3008`;
57
- }
58
- return `https://${domain}`;
59
- }
60
- function constructUrl({
61
- base,
62
- path,
63
- params = {}
64
- }) {
65
- const url = new URL(path, base);
66
- Object.entries(params).forEach(([key, value]) => {
67
- if (!!value && value !== "undefined" && value !== "null") url.searchParams.set(key, value.toString());
68
- });
69
- return url.toString();
70
- }
71
- export {
72
- constructUrl,
73
- getParaConnectBaseUrl,
74
- getParaConnectDomain,
75
- getPortalBaseURL,
76
- getPortalDomain
77
- };
@@ -1,87 +0,0 @@
1
- import {
2
- __spreadProps,
3
- __spreadValues
4
- } from "../chunk-UICEQADR.js";
5
- import { WalletScheme, WalletType } from "@getpara/user-management-client";
6
- import { stringToPhoneNumber } from "./formatting.js";
7
- const WalletSchemeTypeMap = {
8
- [WalletScheme.DKLS]: {
9
- [WalletType.EVM]: true,
10
- [WalletType.COSMOS]: true
11
- },
12
- [WalletScheme.CGGMP]: {
13
- [WalletType.EVM]: true,
14
- [WalletType.COSMOS]: true
15
- },
16
- [WalletScheme.ED25519]: {
17
- [WalletType.SOLANA]: true
18
- }
19
- };
20
- function isPregenIdentifierMatch(a, b, type) {
21
- if (!a || !b) {
22
- return false;
23
- }
24
- switch (type) {
25
- case "EMAIL":
26
- return a.toLowerCase() === b.toLowerCase();
27
- case "PHONE":
28
- return stringToPhoneNumber(a) === stringToPhoneNumber(b);
29
- case "CUSTOM_ID":
30
- return a === b;
31
- default:
32
- return a.replace(/^@/g, "").toLowerCase() === b.replace(/^@/g, "").toLowerCase();
33
- }
34
- }
35
- function isWalletSupported(types, wallet) {
36
- return types.some((walletType) => {
37
- var _a;
38
- return !!((_a = WalletSchemeTypeMap[wallet == null ? void 0 : wallet.scheme]) == null ? void 0 : _a[walletType]);
39
- });
40
- }
41
- function getSchemes(types) {
42
- return Object.keys(WalletSchemeTypeMap).filter((scheme) => {
43
- if (scheme === WalletScheme.CGGMP) {
44
- return false;
45
- }
46
- return (Array.isArray(types) ? types : Object.keys(types)).some((type) => WalletSchemeTypeMap[scheme][type]);
47
- });
48
- }
49
- function getWalletTypes(schemes) {
50
- return [
51
- ...new Set(
52
- schemes.reduce((acc, scheme) => {
53
- return [...acc, ...Object.keys(WalletSchemeTypeMap[scheme]).filter((type) => WalletSchemeTypeMap[scheme][type])];
54
- }, [])
55
- )
56
- ];
57
- }
58
- function getEquivalentTypes(types) {
59
- return getWalletTypes(getSchemes((Array.isArray(types) ? types : [types]).map((t) => WalletType[t])));
60
- }
61
- function entityToWallet(w) {
62
- return __spreadProps(__spreadValues({}, w), {
63
- scheme: w.scheme,
64
- type: w.type,
65
- pregenIdentifierType: w.pregenIdentifierType
66
- });
67
- }
68
- function migrateWallet(obj) {
69
- if (["USER", "PREGEN"].includes(obj.type)) {
70
- obj.isPregen = obj.type === "PREGEN";
71
- obj.type = obj.scheme === WalletScheme.ED25519 ? WalletType.SOLANA : WalletType.EVM;
72
- }
73
- if (!!obj.scheme && !obj.type) {
74
- obj.type = obj.scheme === WalletScheme.ED25519 ? WalletType.SOLANA : WalletType.EVM;
75
- }
76
- return obj;
77
- }
78
- export {
79
- WalletSchemeTypeMap,
80
- entityToWallet,
81
- getEquivalentTypes,
82
- getSchemes,
83
- getWalletTypes,
84
- isPregenIdentifierMatch,
85
- isWalletSupported,
86
- migrateWallet
87
- };
@@ -1,70 +0,0 @@
1
- import { AuthType, WalletType } from '@getpara/user-management-client';
2
- import { Theme } from './theme.js';
3
- export type EmbeddedWalletType = Exclude<WalletType, never>;
4
- export type ExternalWalletType = Exclude<WalletType, never>;
5
- export type ExternalWalletInfo = {
6
- address: string;
7
- type: ExternalWalletType;
8
- provider?: string;
9
- addressBech32?: string;
10
- ensName?: string | null;
11
- ensAvatar?: string | null;
12
- withFullParaAuth?: boolean;
13
- };
14
- export type VerifyExternalWallet = {
15
- signedMessage: string;
16
- cosmosPublicKeyHex?: string;
17
- cosmosSigner?: string;
18
- };
19
- export type PortalUrlOptions = {
20
- params?: Record<string, string | undefined | null>;
21
- authType?: AuthType;
22
- isForNewDevice?: boolean;
23
- loginEncryptionPublicKey?: string;
24
- newDeviceSessionId?: string;
25
- newDeviceEncryptionKey?: string;
26
- partnerId?: string;
27
- sessionId?: string;
28
- theme?: Theme;
29
- pathId?: string;
30
- displayName?: string;
31
- pfpUrl?: string;
32
- };
33
- export type GetWebAuthUrlForLoginParams = {
34
- /**
35
- * The session ID for the URL.
36
- */
37
- sessionId: string;
38
- /**
39
- * Either 'email' | 'phone' | 'farcaster' | 'telegram'
40
- */
41
- authType?: AuthType;
42
- /**
43
- * The public key to use for encrypting the login encryption key.
44
- */
45
- loginEncryptionPublicKey: string;
46
- /**
47
- * The partner ID for the URL.
48
- */
49
- partnerId?: string;
50
- /**
51
- * The session ID for the new device being registered.
52
- */
53
- newDeviceSessionId?: string;
54
- /**
55
- * The public key for the new device being registered.
56
- */
57
- newDeviceEncryptionKey?: string;
58
- /**
59
- * The Telegram or Farcaster display name for the user.
60
- */
61
- displayName?: string;
62
- /**
63
- * The Telegram or Farcaster URL for the user's profile picture.
64
- */
65
- pfpUrl?: string;
66
- };
67
- export type GetWalletBalanceParams = {
68
- walletId: string;
69
- rpcUrl?: string;
70
- };