@getpara/core-sdk 2.0.0-alpha.52 → 2.0.0-alpha.54

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 (65) hide show
  1. package/dist/cjs/ParaCore.js +280 -69
  2. package/dist/cjs/constants.js +7 -1
  3. package/dist/cjs/index.js +8 -2
  4. package/dist/cjs/shares/enclave.js +266 -0
  5. package/dist/cjs/shares/shareDistribution.js +16 -1
  6. package/dist/cjs/types/{theme.js → assets.js} +2 -2
  7. package/dist/cjs/types/events.js +2 -0
  8. package/dist/cjs/types/index.js +0 -21
  9. package/dist/cjs/utils/formatting.js +41 -0
  10. package/dist/cjs/utils/onRamps.js +2 -3
  11. package/dist/cjs/utils/wallet.js +3 -0
  12. package/dist/esm/ParaCore.js +282 -72
  13. package/dist/esm/{chunk-7B52C2XE.js → chunk-W5CT3TVS.js} +2 -0
  14. package/dist/esm/constants.js +6 -2
  15. package/dist/esm/cryptography/utils.js +1 -1
  16. package/dist/esm/errors.js +1 -1
  17. package/dist/esm/external/mpcComputationClient.js +1 -1
  18. package/dist/esm/external/userManagementClient.js +1 -1
  19. package/dist/esm/index.js +9 -4
  20. package/dist/esm/shares/KeyContainer.js +1 -1
  21. package/dist/esm/shares/enclave.js +226 -0
  22. package/dist/esm/shares/recovery.js +1 -1
  23. package/dist/esm/shares/shareDistribution.js +17 -2
  24. package/dist/esm/transmission/transmissionUtils.js +1 -1
  25. package/dist/esm/types/auth.js +1 -1
  26. package/dist/esm/types/config.js +1 -1
  27. package/dist/esm/types/coreApi.js +1 -1
  28. package/dist/esm/types/events.js +3 -1
  29. package/dist/esm/types/index.js +0 -16
  30. package/dist/esm/types/popup.js +1 -1
  31. package/dist/esm/types/wallet.js +1 -1
  32. package/dist/esm/utils/autobind.js +1 -1
  33. package/dist/esm/utils/events.js +1 -1
  34. package/dist/esm/utils/formatting.js +41 -1
  35. package/dist/esm/utils/json.js +1 -1
  36. package/dist/esm/utils/listeners.js +1 -1
  37. package/dist/esm/utils/onRamps.js +3 -4
  38. package/dist/esm/utils/phone.js +1 -1
  39. package/dist/esm/utils/polling.js +1 -1
  40. package/dist/esm/utils/types.js +1 -1
  41. package/dist/esm/utils/url.js +1 -1
  42. package/dist/esm/utils/wallet.js +4 -1
  43. package/dist/types/ParaCore.d.ts +27 -3
  44. package/dist/types/constants.d.ts +2 -0
  45. package/dist/types/index.d.ts +4 -3
  46. package/dist/types/shares/enclave.d.ts +81 -0
  47. package/dist/types/shares/shareDistribution.d.ts +4 -2
  48. package/dist/types/types/assets.d.ts +14 -0
  49. package/dist/types/types/config.d.ts +3 -2
  50. package/dist/types/types/coreApi.d.ts +1 -0
  51. package/dist/types/types/events.d.ts +7 -2
  52. package/dist/types/types/index.d.ts +0 -4
  53. package/dist/types/types/methods.d.ts +15 -9
  54. package/dist/types/types/wallet.d.ts +3 -3
  55. package/dist/types/utils/formatting.d.ts +10 -1
  56. package/dist/types/utils/onRamps.d.ts +9 -10
  57. package/package.json +3 -3
  58. package/dist/cjs/types/onRamps.js +0 -33
  59. package/dist/cjs/types/recovery.js +0 -34
  60. package/dist/esm/types/onRamps.js +0 -11
  61. package/dist/esm/types/recovery.js +0 -12
  62. package/dist/types/types/onRamps.d.ts +0 -10
  63. package/dist/types/types/recovery.d.ts +0 -7
  64. package/dist/types/types/theme.d.ts +0 -12
  65. /package/dist/esm/types/{theme.js → assets.js} +0 -0
@@ -7,6 +7,7 @@ var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
7
  var __typeError = (msg) => {
8
8
  throw TypeError(msg);
9
9
  };
10
+ var __pow = Math.pow;
10
11
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
11
12
  var __spreadValues = (a, b) => {
12
13
  for (var prop in b || (b = {}))
@@ -59,6 +60,7 @@ var __async = (__this, __arguments, generator) => {
59
60
  };
60
61
 
61
62
  export {
63
+ __pow,
62
64
  __spreadValues,
63
65
  __spreadProps,
64
66
  __objRest,
@@ -1,5 +1,5 @@
1
- import "./chunk-7B52C2XE.js";
2
- const PARA_CORE_VERSION = "2.0.0-alpha.52";
1
+ import "./chunk-W5CT3TVS.js";
2
+ const PARA_CORE_VERSION = "2.0.0-alpha.54";
3
3
  const PREFIX = "@CAPSULE/";
4
4
  const PARA_PREFIX = "@PARA/";
5
5
  const LOCAL_STORAGE_AUTH_INFO = `${PREFIX}authInfo`;
@@ -15,6 +15,8 @@ const LOCAL_STORAGE_WALLETS = `${PREFIX}wallets`;
15
15
  const LOCAL_STORAGE_EXTERNAL_WALLETS = `${PREFIX}externalWallets`;
16
16
  const LOCAL_STORAGE_CURRENT_WALLET_IDS = `${PREFIX}currentWalletIds`;
17
17
  const LOCAL_STORAGE_SESSION_COOKIE = `${PREFIX}sessionCookie`;
18
+ const LOCAL_STORAGE_ENCLAVE_JWT = `${PREFIX}enclaveJwt`;
19
+ const LOCAL_STORAGE_ENCLAVE_REFRESH_JWT = `${PREFIX}enclaveRefreshJwt`;
18
20
  const SESSION_STORAGE_LOGIN_ENCRYPTION_KEY_PAIR = `${PREFIX}loginEncryptionKeyPair`;
19
21
  const POLLING_INTERVAL_MS = 2e3;
20
22
  const SHORT_POLLING_INTERVAL_MS = 1e3;
@@ -29,6 +31,8 @@ export {
29
31
  LOCAL_STORAGE_CURRENT_WALLET_IDS,
30
32
  LOCAL_STORAGE_ED25519_WALLETS,
31
33
  LOCAL_STORAGE_EMAIL,
34
+ LOCAL_STORAGE_ENCLAVE_JWT,
35
+ LOCAL_STORAGE_ENCLAVE_REFRESH_JWT,
32
36
  LOCAL_STORAGE_EXTERNAL_WALLETS,
33
37
  LOCAL_STORAGE_EXTERNAL_WALLET_USER_ID,
34
38
  LOCAL_STORAGE_FARCASTER_USERNAME,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  __async
3
- } from "../chunk-7B52C2XE.js";
3
+ } from "../chunk-W5CT3TVS.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-7B52C2XE.js";
1
+ import "./chunk-W5CT3TVS.js";
2
2
  class TransactionReviewError extends Error {
3
3
  constructor(transactionReviewUrl) {
4
4
  super("transaction review error");
@@ -1,4 +1,4 @@
1
- import "../chunk-7B52C2XE.js";
1
+ import "../chunk-W5CT3TVS.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-7B52C2XE.js";
1
+ import "../chunk-W5CT3TVS.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,7 +1,8 @@
1
- import "./chunk-7B52C2XE.js";
1
+ import "./chunk-W5CT3TVS.js";
2
2
  import { ParaCore } from "./ParaCore.js";
3
3
  import {
4
4
  AuthMethod,
5
+ AuthMethodStatus,
5
6
  EmailTheme,
6
7
  Network,
7
8
  WalletType,
@@ -10,7 +11,10 @@ import {
10
11
  OnRampPurchaseType,
11
12
  OnRampProvider,
12
13
  OnRampPurchaseStatus,
14
+ OnRampMethod,
13
15
  OAuthMethod,
16
+ RecoveryStatus,
17
+ ThemeMode,
14
18
  NON_ED25519,
15
19
  PREGEN_IDENTIFIER_TYPES,
16
20
  WALLET_TYPES,
@@ -23,16 +27,14 @@ import {
23
27
  COSMOS_WALLETS
24
28
  } from "@getpara/user-management-client";
25
29
  import {
26
- OnRampMethod,
27
30
  PopupType,
28
31
  PregenIdentifierType,
29
- RecoveryStatus,
30
32
  AccountLinkError
31
33
  } from "./types/index.js";
32
34
  export * from "./types/coreApi.js";
33
35
  export * from "./types/events.js";
34
36
  export * from "./types/config.js";
35
- import { getPortalDomain, entityToWallet, constructUrl, shortenUrl } from "./utils/index.js";
37
+ import { getPortalDomain, dispatchEvent, entityToWallet, constructUrl, shortenUrl } from "./utils/index.js";
36
38
  import { PREFIX, PARA_PREFIX } from "./constants.js";
37
39
  import { distributeNewShare } from "./shares/shareDistribution.js";
38
40
  import { KeyContainer } from "./shares/KeyContainer.js";
@@ -70,6 +72,7 @@ var src_default = ParaCore;
70
72
  export {
71
73
  AccountLinkError,
72
74
  AuthMethod,
75
+ AuthMethodStatus,
73
76
  COSMOS_WALLETS,
74
77
  EVM_WALLETS,
75
78
  EXTERNAL_WALLET_TYPES,
@@ -92,6 +95,7 @@ export {
92
95
  RecoveryStatus,
93
96
  SOLANA_WALLETS,
94
97
  PREFIX as STORAGE_PREFIX,
98
+ ThemeMode,
95
99
  WALLET_SCHEMES,
96
100
  WALLET_TYPES,
97
101
  WalletScheme,
@@ -103,6 +107,7 @@ export {
103
107
  decryptWithKeyPair,
104
108
  decryptWithPrivateKey,
105
109
  src_default as default,
110
+ dispatchEvent,
106
111
  distributeNewShare,
107
112
  encodePrivateKeyToPemHex,
108
113
  encryptPrivateKey,
@@ -1,4 +1,4 @@
1
- import "../chunk-7B52C2XE.js";
1
+ import "../chunk-W5CT3TVS.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";
@@ -0,0 +1,226 @@
1
+ import {
2
+ __async
3
+ } from "../chunk-W5CT3TVS.js";
4
+ class EnclaveClient {
5
+ constructor({
6
+ userManagementClient,
7
+ retrieveJwt,
8
+ persistJwt,
9
+ retrieveRefreshJwt,
10
+ persistRefreshJwt
11
+ }) {
12
+ this.enclavePublicKey = null;
13
+ this.frontendKeyPair = null;
14
+ this.userManagementClient = userManagementClient;
15
+ this.retrieveJwt = retrieveJwt;
16
+ this.persistJwt = persistJwt;
17
+ this.retrieveRefreshJwt = retrieveRefreshJwt;
18
+ this.persistRefreshJwt = persistRefreshJwt;
19
+ }
20
+ refreshJwt() {
21
+ return __async(this, null, function* () {
22
+ const frontendKeyPair = yield this.generateFrontendKeyPair();
23
+ const responsePublicKeyPEM = yield this.exportPublicKeyToPEM(frontendKeyPair.publicKey);
24
+ const payload = {
25
+ refreshJwt: this.retrieveRefreshJwt(),
26
+ responsePublicKey: responsePublicKeyPEM
27
+ };
28
+ const encryptedPayload = yield this.encryptForEnclave(JSON.stringify(payload));
29
+ const response = yield this.userManagementClient.refreshEnclaveJwt(JSON.stringify(encryptedPayload));
30
+ const decryptedResponse = yield this.decryptForFrontend(JSON.parse(response.payload));
31
+ this.persistJwt(decryptedResponse.jwt);
32
+ this.persistRefreshJwt(decryptedResponse.refreshJwt);
33
+ });
34
+ }
35
+ withJwtRefreshRetry(fn) {
36
+ return __async(this, null, function* () {
37
+ try {
38
+ return yield fn();
39
+ } catch (error) {
40
+ yield this.refreshJwt();
41
+ return yield fn();
42
+ }
43
+ });
44
+ }
45
+ issueEnclaveJwt() {
46
+ return __async(this, null, function* () {
47
+ const frontendKeyPair = yield this.generateFrontendKeyPair();
48
+ const responsePublicKeyPEM = yield this.exportPublicKeyToPEM(frontendKeyPair.publicKey);
49
+ const payload = {
50
+ responsePublicKey: responsePublicKeyPEM
51
+ };
52
+ const encryptedPayload = yield this.encryptForEnclave(JSON.stringify(payload));
53
+ const response = yield this.userManagementClient.issueEnclaveJwt(JSON.stringify(encryptedPayload));
54
+ const decryptedResponse = yield this.decryptForFrontend(JSON.parse(response));
55
+ this.persistJwt(decryptedResponse.jwt);
56
+ });
57
+ }
58
+ /**
59
+ * Generate a P-256 keypair for the frontend to receive encrypted responses
60
+ */
61
+ generateFrontendKeyPair() {
62
+ return __async(this, null, function* () {
63
+ if (this.frontendKeyPair) {
64
+ return this.frontendKeyPair;
65
+ }
66
+ this.frontendKeyPair = yield crypto.subtle.generateKey({ name: "ECDH", namedCurve: "P-256" }, true, ["deriveBits"]);
67
+ return this.frontendKeyPair;
68
+ });
69
+ }
70
+ /**
71
+ * Get the enclave's public key from the user-management service
72
+ */
73
+ getEnclavePublicKey() {
74
+ return __async(this, null, function* () {
75
+ if (this.enclavePublicKey) {
76
+ return this.enclavePublicKey;
77
+ }
78
+ const response = yield this.userManagementClient.getEnclavePublicKey();
79
+ this.enclavePublicKey = response.publicKey;
80
+ return this.enclavePublicKey;
81
+ });
82
+ }
83
+ /**
84
+ * Import a PEM-formatted public key for use with Web Crypto API
85
+ */
86
+ importPublicKeyFromPEM(pemString) {
87
+ return __async(this, null, function* () {
88
+ const pemContents = pemString.replace("-----BEGIN PUBLIC KEY-----", "").replace("-----END PUBLIC KEY-----", "").replace(/\s/g, "");
89
+ const keyData = Uint8Array.from(atob(pemContents), (c) => c.charCodeAt(0));
90
+ return yield crypto.subtle.importKey("spki", keyData, { name: "ECDH", namedCurve: "P-256" }, false, []);
91
+ });
92
+ }
93
+ /**
94
+ * Export a public key to PEM format
95
+ */
96
+ exportPublicKeyToPEM(publicKey) {
97
+ return __async(this, null, function* () {
98
+ const exported = yield crypto.subtle.exportKey("spki", publicKey);
99
+ const exportedAsBase64 = btoa(String.fromCharCode(...new Uint8Array(exported)));
100
+ return `-----BEGIN PUBLIC KEY-----
101
+ ${exportedAsBase64}
102
+ -----END PUBLIC KEY-----`;
103
+ });
104
+ }
105
+ /**
106
+ * Encrypt data using P-256 ECIES for the enclave
107
+ */
108
+ encryptForEnclave(plaintext) {
109
+ return __async(this, null, function* () {
110
+ const enclavePublicKeyPEM = yield this.getEnclavePublicKey();
111
+ const enclavePublicKey = yield this.importPublicKeyFromPEM(enclavePublicKeyPEM);
112
+ const ephemeralKeyPair = yield crypto.subtle.generateKey({ name: "ECDH", namedCurve: "P-256" }, true, ["deriveBits"]);
113
+ const sharedSecretBits = yield crypto.subtle.deriveBits(
114
+ { name: "ECDH", public: enclavePublicKey },
115
+ ephemeralKeyPair.privateKey,
116
+ 256
117
+ // 32 bytes = 256 bits
118
+ );
119
+ const encryptionKeyBuffer = yield crypto.subtle.digest("SHA-256", sharedSecretBits);
120
+ const encryptionKey = yield crypto.subtle.importKey("raw", encryptionKeyBuffer, { name: "AES-GCM" }, false, ["encrypt"]);
121
+ const iv = crypto.getRandomValues(new Uint8Array(12));
122
+ const encrypted = yield crypto.subtle.encrypt(
123
+ { name: "AES-GCM", iv },
124
+ encryptionKey,
125
+ new TextEncoder().encode(plaintext)
126
+ );
127
+ const encryptedArray = new Uint8Array(encrypted);
128
+ const combined = new Uint8Array(iv.length + encryptedArray.length);
129
+ combined.set(iv);
130
+ combined.set(encryptedArray, iv.length);
131
+ const ephemeralPublicKeyBuffer = yield crypto.subtle.exportKey("spki", ephemeralKeyPair.publicKey);
132
+ return {
133
+ encryptedData: btoa(String.fromCharCode(...combined)),
134
+ keyId: "",
135
+ // Will be set by the enclave
136
+ algorithm: "ECIES-P256-AES256-SHA256",
137
+ ephemeral: btoa(String.fromCharCode(...new Uint8Array(ephemeralPublicKeyBuffer)))
138
+ };
139
+ });
140
+ }
141
+ /**
142
+ * Decrypt response encrypted for the frontend
143
+ */
144
+ decryptForFrontend(encryptedPayload) {
145
+ return __async(this, null, function* () {
146
+ if (!this.frontendKeyPair) {
147
+ throw new Error("Frontend keypair not available");
148
+ }
149
+ const encryptedData = Uint8Array.from(atob(encryptedPayload.encryptedData), (c) => c.charCodeAt(0));
150
+ const ephemeralPublicKeyData = Uint8Array.from(atob(encryptedPayload.ephemeral), (c) => c.charCodeAt(0));
151
+ const ephemeralPublicKey = yield crypto.subtle.importKey(
152
+ "spki",
153
+ ephemeralPublicKeyData,
154
+ { name: "ECDH", namedCurve: "P-256" },
155
+ false,
156
+ []
157
+ );
158
+ const sharedSecretBits = yield crypto.subtle.deriveBits(
159
+ { name: "ECDH", public: ephemeralPublicKey },
160
+ this.frontendKeyPair.privateKey,
161
+ 256
162
+ );
163
+ const encryptionKeyBuffer = yield crypto.subtle.digest("SHA-256", sharedSecretBits);
164
+ const encryptionKey = yield crypto.subtle.importKey("raw", encryptionKeyBuffer, { name: "AES-GCM" }, false, ["decrypt"]);
165
+ const iv = encryptedData.slice(0, 12);
166
+ const ciphertext = encryptedData.slice(12);
167
+ const decrypted = yield crypto.subtle.decrypt({ name: "AES-GCM", iv }, encryptionKey, ciphertext);
168
+ return JSON.parse(new TextDecoder().decode(decrypted));
169
+ });
170
+ }
171
+ /**
172
+ * Persist key shares to the enclave
173
+ * @param shares Array of share data to persist
174
+ */
175
+ persistShares(shares) {
176
+ return __async(this, null, function* () {
177
+ const payload = {
178
+ shares,
179
+ jwt: this.retrieveJwt()
180
+ };
181
+ const encryptedPayload = yield this.encryptForEnclave(JSON.stringify(payload));
182
+ const encryptedPayloadStr = JSON.stringify(encryptedPayload);
183
+ return yield this.userManagementClient.persistEnclaveShares(encryptedPayloadStr);
184
+ });
185
+ }
186
+ /**
187
+ * Retrieve key shares from the enclave
188
+ * @param query Query parameters for finding shares (single query or array of queries)
189
+ */
190
+ retrieveShares(query) {
191
+ return __async(this, null, function* () {
192
+ yield this.issueEnclaveJwt();
193
+ const frontendKeyPair = yield this.generateFrontendKeyPair();
194
+ const responsePublicKeyPEM = yield this.exportPublicKeyToPEM(frontendKeyPair.publicKey);
195
+ const fullQuery = query.map((q) => ({
196
+ userId: q.userId
197
+ }));
198
+ const payload = {
199
+ query: fullQuery,
200
+ responsePublicKey: responsePublicKeyPEM,
201
+ jwt: this.retrieveJwt()
202
+ };
203
+ const encryptedPayload = yield this.encryptForEnclave(JSON.stringify(payload));
204
+ const encryptedPayloadStr = JSON.stringify(encryptedPayload);
205
+ const response = yield this.userManagementClient.retrieveEnclaveShares(encryptedPayloadStr);
206
+ const encryptedResponse = JSON.parse(response.payload);
207
+ const decryptedData = yield this.decryptForFrontend(encryptedResponse);
208
+ return decryptedData.shares;
209
+ });
210
+ }
211
+ retrieveSharesWithRetry(query) {
212
+ return __async(this, null, function* () {
213
+ return yield this.withJwtRefreshRetry(() => __async(this, null, function* () {
214
+ return this.retrieveShares(query);
215
+ }));
216
+ });
217
+ }
218
+ persistSharesWithRetry(shares) {
219
+ return __async(this, null, function* () {
220
+ return yield this.persistShares(shares);
221
+ });
222
+ }
223
+ }
224
+ export {
225
+ EnclaveClient
226
+ };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  __async,
3
3
  __spreadValues
4
- } from "../chunk-7B52C2XE.js";
4
+ } from "../chunk-W5CT3TVS.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-7B52C2XE.js";
3
+ } from "../chunk-W5CT3TVS.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";
@@ -13,8 +13,23 @@ function distributeNewShare(_0) {
13
13
  ignoreRedistributingBackupEncryptedShare = false,
14
14
  emailProps = {},
15
15
  partnerId,
16
- protocolId
16
+ protocolId,
17
+ isEnclaveUser,
18
+ walletScheme
17
19
  }) {
20
+ if (isEnclaveUser) {
21
+ yield ctx.enclaveClient.persistSharesWithRetry([
22
+ {
23
+ userId,
24
+ walletId,
25
+ walletScheme,
26
+ signer: userShare,
27
+ partnerId,
28
+ protocolId
29
+ }
30
+ ]);
31
+ return "";
32
+ }
18
33
  const publicKeysRes = yield ctx.client.getSessionPublicKeys(userId);
19
34
  const biometricEncryptedShares = publicKeysRes.data.keys.map((key) => {
20
35
  if (!key.publicKey) {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  __async
3
- } from "../chunk-7B52C2XE.js";
3
+ } from "../chunk-W5CT3TVS.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-7B52C2XE.js";
1
+ import "../chunk-W5CT3TVS.js";
2
2
  var AccountLinkError = /* @__PURE__ */ ((AccountLinkError2) => {
3
3
  AccountLinkError2["NotAuthenticated"] = "No user is currently authenticated";
4
4
  AccountLinkError2["Conflict"] = "Account already linked";
@@ -1,4 +1,4 @@
1
- import "../chunk-7B52C2XE.js";
1
+ import "../chunk-W5CT3TVS.js";
2
2
  var Environment = /* @__PURE__ */ ((Environment2) => {
3
3
  Environment2["DEV"] = "DEV";
4
4
  Environment2["SANDBOX"] = "SANDBOX";
@@ -1,4 +1,4 @@
1
- import "../chunk-7B52C2XE.js";
1
+ import "../chunk-W5CT3TVS.js";
2
2
  const PARA_CORE_METHODS = [
3
3
  "getAuthInfo",
4
4
  "signUpOrLogIn",
@@ -1,4 +1,4 @@
1
- import "../chunk-7B52C2XE.js";
1
+ import "../chunk-W5CT3TVS.js";
2
2
  const EVENT_PREFIX = "para";
3
3
  var ParaEvent = ((ParaEvent2) => {
4
4
  ParaEvent2["LOGIN_EVENT"] = `${EVENT_PREFIX}Login`;
@@ -12,6 +12,8 @@ var ParaEvent = ((ParaEvent2) => {
12
12
  ParaEvent2["WALLET_CREATED"] = `${EVENT_PREFIX}WalletCreated`;
13
13
  ParaEvent2["PREGEN_WALLET_CLAIMED"] = `${EVENT_PREFIX}PregenWalletClaimed`;
14
14
  ParaEvent2["GUEST_WALLETS_CREATED"] = `${EVENT_PREFIX}GuestWalletsCreated`;
15
+ ParaEvent2["ASSET_TRANSFERRED"] = `${EVENT_PREFIX}AssetTransferred`;
16
+ ParaEvent2["ONRAMP_TRANSACTION_COMPLETE"] = `${EVENT_PREFIX}OnRampTransactionComplete`;
15
17
  return ParaEvent2;
16
18
  })(ParaEvent || {});
17
19
  export {
@@ -1,23 +1,7 @@
1
- import "../chunk-7B52C2XE.js";
2
1
  export * from "./auth.js";
3
2
  export * from "./config.js";
4
3
  export * from "./coreApi.js";
5
4
  export * from "./wallet.js";
6
5
  export * from "./methods.js";
7
- export * from "./theme.js";
8
- export * from "./onRamps.js";
9
6
  export * from "./popup.js";
10
- export * from "./recovery.js";
11
7
  export * from "./events.js";
12
- import {
13
- Network,
14
- OnRampAsset,
15
- OnRampProvider,
16
- OnRampPurchaseStatus
17
- } from "@getpara/user-management-client";
18
- export {
19
- Network,
20
- OnRampAsset,
21
- OnRampProvider,
22
- OnRampPurchaseStatus
23
- };
@@ -1,4 +1,4 @@
1
- import "../chunk-7B52C2XE.js";
1
+ import "../chunk-W5CT3TVS.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-7B52C2XE.js";
1
+ import "../chunk-W5CT3TVS.js";
2
2
  var PregenIdentifierType = /* @__PURE__ */ ((PregenIdentifierType2) => {
3
3
  PregenIdentifierType2["EMAIL"] = "EMAIL";
4
4
  PregenIdentifierType2["PHONE"] = "PHONE";
@@ -1,4 +1,4 @@
1
- import "../chunk-7B52C2XE.js";
1
+ import "../chunk-W5CT3TVS.js";
2
2
  function autoBind(instance) {
3
3
  let proto = instance;
4
4
  while (proto && proto !== Object.prototype) {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  __spreadValues
3
- } from "../chunk-7B52C2XE.js";
3
+ } from "../chunk-W5CT3TVS.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,6 @@
1
- import "../chunk-7B52C2XE.js";
1
+ import {
2
+ __pow
3
+ } from "../chunk-W5CT3TVS.js";
2
4
  import { toBech32 } from "@cosmjs/encoding";
3
5
  import { sha256 } from "@noble/hashes/sha256";
4
6
  import { ripemd160 } from "@noble/hashes/ripemd160";
@@ -63,9 +65,47 @@ function truncateAddress(str, addressType, {
63
65
  const margin = targetLength !== void 0 ? (targetLength - minimum) / 2 : 4;
64
66
  return `${str.slice(0, minimum + margin)}...${str.slice(-1 * margin)}`;
65
67
  }
68
+ function formatCurrency(value, { fallback = "" } = {}) {
69
+ if (!value) {
70
+ return fallback;
71
+ }
72
+ const formatter = new Intl.NumberFormat("en-US", {
73
+ style: "currency",
74
+ currency: value.currency
75
+ });
76
+ const zeroFormatter = new Intl.NumberFormat("en-US", {
77
+ style: "currency",
78
+ currency: value.currency,
79
+ maximumFractionDigits: 0
80
+ });
81
+ return Math.abs(value.value) < 0.01 ? zeroFormatter.format(0) : formatter.format(value.value);
82
+ }
83
+ const zeroAssetFormatter = new Intl.NumberFormat("en-US", {
84
+ style: "decimal",
85
+ maximumFractionDigits: 0,
86
+ minimumFractionDigits: 0
87
+ });
88
+ function formatAssetQuantity({
89
+ quantity,
90
+ symbol = "",
91
+ decimals,
92
+ fallback = ""
93
+ }) {
94
+ if (!quantity) {
95
+ return fallback;
96
+ }
97
+ const formatter = new Intl.NumberFormat("en-US", {
98
+ style: "decimal",
99
+ maximumFractionDigits: decimals != null ? decimals : Math.abs(quantity) < 1e-3 ? 6 : 3,
100
+ minimumFractionDigits: decimals != null ? decimals : 3
101
+ });
102
+ return `${Math.abs(quantity) < __pow(10, -1 * (decimals != null ? decimals : 6)) ? zeroAssetFormatter.format(0) : formatter.format(quantity)}${symbol && symbol.length > 0 ? ` ${symbol}` : ""}`;
103
+ }
66
104
  export {
67
105
  compressPubkey,
68
106
  decimalToHex,
107
+ formatAssetQuantity,
108
+ formatCurrency,
69
109
  getCosmosAddress,
70
110
  hexStringToBase64,
71
111
  hexToDecimal,
@@ -1,4 +1,4 @@
1
- import "../chunk-7B52C2XE.js";
1
+ import "../chunk-W5CT3TVS.js";
2
2
  function jsonParse(data, validate) {
3
3
  try {
4
4
  const res = JSON.parse(data);
@@ -1,4 +1,4 @@
1
- import "../chunk-7B52C2XE.js";
1
+ import "../chunk-W5CT3TVS.js";
2
2
  import * as constants from "../constants.js";
3
3
  function storageListener(e) {
4
4
  if (!e.url.includes(window.location.origin)) {
@@ -1,5 +1,4 @@
1
- import "../chunk-7B52C2XE.js";
2
- import { Network } from "@getpara/user-management-client";
1
+ import "../chunk-W5CT3TVS.js";
3
2
  function toAssetInfoArray(data) {
4
3
  const result = [];
5
4
  Object.keys(data).forEach((walletType) => {
@@ -51,8 +50,8 @@ function getOnRampAssets(data, {
51
50
  ];
52
51
  }
53
52
  const NETWORK_PREFIXES = {
54
- [Network.COSMOS]: "cosmos",
55
- [Network.NOBLE]: "noble"
53
+ COSMOS: "cosmos",
54
+ NOBLE: "noble"
56
55
  };
57
56
  function getNetworkPrefix(network) {
58
57
  return NETWORK_PREFIXES[network];
@@ -1,4 +1,4 @@
1
- import "../chunk-7B52C2XE.js";
1
+ import "../chunk-W5CT3TVS.js";
2
2
  import parsePhoneNumberFromString from "libphonenumber-js";
3
3
  function formatPhoneNumber(phone, countryCode, { forDisplay = false } = {}) {
4
4
  phone = phone.toString();
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  __async
3
- } from "../chunk-7B52C2XE.js";
3
+ } from "../chunk-W5CT3TVS.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-7B52C2XE.js";
1
+ import "../chunk-W5CT3TVS.js";
2
2
  function isServerAuthState(obj) {
3
3
  return "stage" in obj;
4
4
  }
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  __async
3
- } from "../chunk-7B52C2XE.js";
3
+ } from "../chunk-W5CT3TVS.js";
4
4
  import { upload } from "../transmission/transmissionUtils.js";
5
5
  import { Environment } from "../types/index.js";
6
6
  function getPortalDomain(env, isE2E) {
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  __spreadProps,
3
3
  __spreadValues
4
- } from "../chunk-7B52C2XE.js";
4
+ } from "../chunk-W5CT3TVS.js";
5
5
  import * as uuid from "uuid";
6
6
  import { formatPhoneNumber } from "./phone.js";
7
7
  const WalletSchemeTypeMap = {
@@ -59,7 +59,10 @@ function getEquivalentTypes(types) {
59
59
  return getWalletTypes(getSchemes(Array.isArray(types) ? types : [types]));
60
60
  }
61
61
  function entityToWallet(w) {
62
+ var _a;
62
63
  return __spreadProps(__spreadValues({}, w), {
64
+ createdAt: typeof w.createdAt === "string" ? w.createdAt : w.createdAt.toISOString(),
65
+ lastUsedAt: typeof w.lastUsedAt === "string" ? w.lastUsedAt : (_a = w.lastUsedAt) == null ? void 0 : _a.toISOString(),
63
66
  scheme: w.scheme,
64
67
  type: w.type,
65
68
  pregenIdentifierType: w.pregenIdentifierType