@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
@@ -24,6 +24,8 @@ __export(constants_exports, {
24
24
  LOCAL_STORAGE_CURRENT_WALLET_IDS: () => LOCAL_STORAGE_CURRENT_WALLET_IDS,
25
25
  LOCAL_STORAGE_ED25519_WALLETS: () => LOCAL_STORAGE_ED25519_WALLETS,
26
26
  LOCAL_STORAGE_EMAIL: () => LOCAL_STORAGE_EMAIL,
27
+ LOCAL_STORAGE_ENCLAVE_JWT: () => LOCAL_STORAGE_ENCLAVE_JWT,
28
+ LOCAL_STORAGE_ENCLAVE_REFRESH_JWT: () => LOCAL_STORAGE_ENCLAVE_REFRESH_JWT,
27
29
  LOCAL_STORAGE_EXTERNAL_WALLETS: () => LOCAL_STORAGE_EXTERNAL_WALLETS,
28
30
  LOCAL_STORAGE_EXTERNAL_WALLET_USER_ID: () => LOCAL_STORAGE_EXTERNAL_WALLET_USER_ID,
29
31
  LOCAL_STORAGE_FARCASTER_USERNAME: () => LOCAL_STORAGE_FARCASTER_USERNAME,
@@ -41,7 +43,7 @@ __export(constants_exports, {
41
43
  SHORT_POLLING_INTERVAL_MS: () => SHORT_POLLING_INTERVAL_MS
42
44
  });
43
45
  module.exports = __toCommonJS(constants_exports);
44
- const PARA_CORE_VERSION = "2.0.0-alpha.52";
46
+ const PARA_CORE_VERSION = "2.0.0-alpha.54";
45
47
  const PREFIX = "@CAPSULE/";
46
48
  const PARA_PREFIX = "@PARA/";
47
49
  const LOCAL_STORAGE_AUTH_INFO = `${PREFIX}authInfo`;
@@ -57,6 +59,8 @@ const LOCAL_STORAGE_WALLETS = `${PREFIX}wallets`;
57
59
  const LOCAL_STORAGE_EXTERNAL_WALLETS = `${PREFIX}externalWallets`;
58
60
  const LOCAL_STORAGE_CURRENT_WALLET_IDS = `${PREFIX}currentWalletIds`;
59
61
  const LOCAL_STORAGE_SESSION_COOKIE = `${PREFIX}sessionCookie`;
62
+ const LOCAL_STORAGE_ENCLAVE_JWT = `${PREFIX}enclaveJwt`;
63
+ const LOCAL_STORAGE_ENCLAVE_REFRESH_JWT = `${PREFIX}enclaveRefreshJwt`;
60
64
  const SESSION_STORAGE_LOGIN_ENCRYPTION_KEY_PAIR = `${PREFIX}loginEncryptionKeyPair`;
61
65
  const POLLING_INTERVAL_MS = 2e3;
62
66
  const SHORT_POLLING_INTERVAL_MS = 1e3;
@@ -72,6 +76,8 @@ const ACCOUNT_LINK_CONFLICT = "Account already linked";
72
76
  LOCAL_STORAGE_CURRENT_WALLET_IDS,
73
77
  LOCAL_STORAGE_ED25519_WALLETS,
74
78
  LOCAL_STORAGE_EMAIL,
79
+ LOCAL_STORAGE_ENCLAVE_JWT,
80
+ LOCAL_STORAGE_ENCLAVE_REFRESH_JWT,
75
81
  LOCAL_STORAGE_EXTERNAL_WALLETS,
76
82
  LOCAL_STORAGE_EXTERNAL_WALLET_USER_ID,
77
83
  LOCAL_STORAGE_FARCASTER_USERNAME,
package/dist/cjs/index.js CHANGED
@@ -30,6 +30,7 @@ var src_exports = {};
30
30
  __export(src_exports, {
31
31
  AccountLinkError: () => import_types.AccountLinkError,
32
32
  AuthMethod: () => import_user_management_client.AuthMethod,
33
+ AuthMethodStatus: () => import_user_management_client.AuthMethodStatus,
33
34
  COSMOS_WALLETS: () => import_user_management_client.COSMOS_WALLETS,
34
35
  EVM_WALLETS: () => import_user_management_client.EVM_WALLETS,
35
36
  EXTERNAL_WALLET_TYPES: () => import_user_management_client.EXTERNAL_WALLET_TYPES,
@@ -41,7 +42,7 @@ __export(src_exports, {
41
42
  OAUTH_METHODS: () => import_user_management_client.OAUTH_METHODS,
42
43
  OAuthMethod: () => import_user_management_client.OAuthMethod,
43
44
  OnRampAsset: () => import_user_management_client.OnRampAsset,
44
- OnRampMethod: () => import_types.OnRampMethod,
45
+ OnRampMethod: () => import_user_management_client.OnRampMethod,
45
46
  OnRampProvider: () => import_user_management_client.OnRampProvider,
46
47
  OnRampPurchaseStatus: () => import_user_management_client.OnRampPurchaseStatus,
47
48
  OnRampPurchaseType: () => import_user_management_client.OnRampPurchaseType,
@@ -49,9 +50,10 @@ __export(src_exports, {
49
50
  PREGEN_IDENTIFIER_TYPES: () => import_user_management_client.PREGEN_IDENTIFIER_TYPES,
50
51
  PopupType: () => import_types.PopupType,
51
52
  PregenIdentifierType: () => import_types.PregenIdentifierType,
52
- RecoveryStatus: () => import_types.RecoveryStatus,
53
+ RecoveryStatus: () => import_user_management_client.RecoveryStatus,
53
54
  SOLANA_WALLETS: () => import_user_management_client.SOLANA_WALLETS,
54
55
  STORAGE_PREFIX: () => import_constants.PREFIX,
56
+ ThemeMode: () => import_user_management_client.ThemeMode,
55
57
  WALLET_SCHEMES: () => import_user_management_client.WALLET_SCHEMES,
56
58
  WALLET_TYPES: () => import_user_management_client.WALLET_TYPES,
57
59
  WalletScheme: () => import_user_management_client.WalletScheme,
@@ -63,6 +65,7 @@ __export(src_exports, {
63
65
  decryptWithKeyPair: () => import_utils2.decryptWithKeyPair,
64
66
  decryptWithPrivateKey: () => import_utils2.decryptWithPrivateKey,
65
67
  default: () => src_default,
68
+ dispatchEvent: () => import_utils.dispatchEvent,
66
69
  distributeNewShare: () => import_shareDistribution.distributeNewShare,
67
70
  encodePrivateKeyToPemHex: () => import_utils2.encodePrivateKeyToPemHex,
68
71
  encryptPrivateKey: () => import_utils2.encryptPrivateKey,
@@ -119,6 +122,7 @@ var src_default = import_ParaCore.ParaCore;
119
122
  0 && (module.exports = {
120
123
  AccountLinkError,
121
124
  AuthMethod,
125
+ AuthMethodStatus,
122
126
  COSMOS_WALLETS,
123
127
  EVM_WALLETS,
124
128
  EXTERNAL_WALLET_TYPES,
@@ -141,6 +145,7 @@ var src_default = import_ParaCore.ParaCore;
141
145
  RecoveryStatus,
142
146
  SOLANA_WALLETS,
143
147
  STORAGE_PREFIX,
148
+ ThemeMode,
144
149
  WALLET_SCHEMES,
145
150
  WALLET_TYPES,
146
151
  WalletScheme,
@@ -151,6 +156,7 @@ var src_default = import_ParaCore.ParaCore;
151
156
  decryptPrivateKeyWithPassword,
152
157
  decryptWithKeyPair,
153
158
  decryptWithPrivateKey,
159
+ dispatchEvent,
154
160
  distributeNewShare,
155
161
  encodePrivateKeyToPemHex,
156
162
  encryptPrivateKey,
@@ -0,0 +1,266 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var __async = (__this, __arguments, generator) => {
19
+ return new Promise((resolve, reject) => {
20
+ var fulfilled = (value) => {
21
+ try {
22
+ step(generator.next(value));
23
+ } catch (e) {
24
+ reject(e);
25
+ }
26
+ };
27
+ var rejected = (value) => {
28
+ try {
29
+ step(generator.throw(value));
30
+ } catch (e) {
31
+ reject(e);
32
+ }
33
+ };
34
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
35
+ step((generator = generator.apply(__this, __arguments)).next());
36
+ });
37
+ };
38
+ var enclave_exports = {};
39
+ __export(enclave_exports, {
40
+ EnclaveClient: () => EnclaveClient
41
+ });
42
+ module.exports = __toCommonJS(enclave_exports);
43
+ class EnclaveClient {
44
+ constructor({
45
+ userManagementClient,
46
+ retrieveJwt,
47
+ persistJwt,
48
+ retrieveRefreshJwt,
49
+ persistRefreshJwt
50
+ }) {
51
+ this.enclavePublicKey = null;
52
+ this.frontendKeyPair = null;
53
+ this.userManagementClient = userManagementClient;
54
+ this.retrieveJwt = retrieveJwt;
55
+ this.persistJwt = persistJwt;
56
+ this.retrieveRefreshJwt = retrieveRefreshJwt;
57
+ this.persistRefreshJwt = persistRefreshJwt;
58
+ }
59
+ refreshJwt() {
60
+ return __async(this, null, function* () {
61
+ const frontendKeyPair = yield this.generateFrontendKeyPair();
62
+ const responsePublicKeyPEM = yield this.exportPublicKeyToPEM(frontendKeyPair.publicKey);
63
+ const payload = {
64
+ refreshJwt: this.retrieveRefreshJwt(),
65
+ responsePublicKey: responsePublicKeyPEM
66
+ };
67
+ const encryptedPayload = yield this.encryptForEnclave(JSON.stringify(payload));
68
+ const response = yield this.userManagementClient.refreshEnclaveJwt(JSON.stringify(encryptedPayload));
69
+ const decryptedResponse = yield this.decryptForFrontend(JSON.parse(response.payload));
70
+ this.persistJwt(decryptedResponse.jwt);
71
+ this.persistRefreshJwt(decryptedResponse.refreshJwt);
72
+ });
73
+ }
74
+ withJwtRefreshRetry(fn) {
75
+ return __async(this, null, function* () {
76
+ try {
77
+ return yield fn();
78
+ } catch (error) {
79
+ yield this.refreshJwt();
80
+ return yield fn();
81
+ }
82
+ });
83
+ }
84
+ issueEnclaveJwt() {
85
+ return __async(this, null, function* () {
86
+ const frontendKeyPair = yield this.generateFrontendKeyPair();
87
+ const responsePublicKeyPEM = yield this.exportPublicKeyToPEM(frontendKeyPair.publicKey);
88
+ const payload = {
89
+ responsePublicKey: responsePublicKeyPEM
90
+ };
91
+ const encryptedPayload = yield this.encryptForEnclave(JSON.stringify(payload));
92
+ const response = yield this.userManagementClient.issueEnclaveJwt(JSON.stringify(encryptedPayload));
93
+ const decryptedResponse = yield this.decryptForFrontend(JSON.parse(response));
94
+ this.persistJwt(decryptedResponse.jwt);
95
+ });
96
+ }
97
+ /**
98
+ * Generate a P-256 keypair for the frontend to receive encrypted responses
99
+ */
100
+ generateFrontendKeyPair() {
101
+ return __async(this, null, function* () {
102
+ if (this.frontendKeyPair) {
103
+ return this.frontendKeyPair;
104
+ }
105
+ this.frontendKeyPair = yield crypto.subtle.generateKey({ name: "ECDH", namedCurve: "P-256" }, true, ["deriveBits"]);
106
+ return this.frontendKeyPair;
107
+ });
108
+ }
109
+ /**
110
+ * Get the enclave's public key from the user-management service
111
+ */
112
+ getEnclavePublicKey() {
113
+ return __async(this, null, function* () {
114
+ if (this.enclavePublicKey) {
115
+ return this.enclavePublicKey;
116
+ }
117
+ const response = yield this.userManagementClient.getEnclavePublicKey();
118
+ this.enclavePublicKey = response.publicKey;
119
+ return this.enclavePublicKey;
120
+ });
121
+ }
122
+ /**
123
+ * Import a PEM-formatted public key for use with Web Crypto API
124
+ */
125
+ importPublicKeyFromPEM(pemString) {
126
+ return __async(this, null, function* () {
127
+ const pemContents = pemString.replace("-----BEGIN PUBLIC KEY-----", "").replace("-----END PUBLIC KEY-----", "").replace(/\s/g, "");
128
+ const keyData = Uint8Array.from(atob(pemContents), (c) => c.charCodeAt(0));
129
+ return yield crypto.subtle.importKey("spki", keyData, { name: "ECDH", namedCurve: "P-256" }, false, []);
130
+ });
131
+ }
132
+ /**
133
+ * Export a public key to PEM format
134
+ */
135
+ exportPublicKeyToPEM(publicKey) {
136
+ return __async(this, null, function* () {
137
+ const exported = yield crypto.subtle.exportKey("spki", publicKey);
138
+ const exportedAsBase64 = btoa(String.fromCharCode(...new Uint8Array(exported)));
139
+ return `-----BEGIN PUBLIC KEY-----
140
+ ${exportedAsBase64}
141
+ -----END PUBLIC KEY-----`;
142
+ });
143
+ }
144
+ /**
145
+ * Encrypt data using P-256 ECIES for the enclave
146
+ */
147
+ encryptForEnclave(plaintext) {
148
+ return __async(this, null, function* () {
149
+ const enclavePublicKeyPEM = yield this.getEnclavePublicKey();
150
+ const enclavePublicKey = yield this.importPublicKeyFromPEM(enclavePublicKeyPEM);
151
+ const ephemeralKeyPair = yield crypto.subtle.generateKey({ name: "ECDH", namedCurve: "P-256" }, true, ["deriveBits"]);
152
+ const sharedSecretBits = yield crypto.subtle.deriveBits(
153
+ { name: "ECDH", public: enclavePublicKey },
154
+ ephemeralKeyPair.privateKey,
155
+ 256
156
+ // 32 bytes = 256 bits
157
+ );
158
+ const encryptionKeyBuffer = yield crypto.subtle.digest("SHA-256", sharedSecretBits);
159
+ const encryptionKey = yield crypto.subtle.importKey("raw", encryptionKeyBuffer, { name: "AES-GCM" }, false, ["encrypt"]);
160
+ const iv = crypto.getRandomValues(new Uint8Array(12));
161
+ const encrypted = yield crypto.subtle.encrypt(
162
+ { name: "AES-GCM", iv },
163
+ encryptionKey,
164
+ new TextEncoder().encode(plaintext)
165
+ );
166
+ const encryptedArray = new Uint8Array(encrypted);
167
+ const combined = new Uint8Array(iv.length + encryptedArray.length);
168
+ combined.set(iv);
169
+ combined.set(encryptedArray, iv.length);
170
+ const ephemeralPublicKeyBuffer = yield crypto.subtle.exportKey("spki", ephemeralKeyPair.publicKey);
171
+ return {
172
+ encryptedData: btoa(String.fromCharCode(...combined)),
173
+ keyId: "",
174
+ // Will be set by the enclave
175
+ algorithm: "ECIES-P256-AES256-SHA256",
176
+ ephemeral: btoa(String.fromCharCode(...new Uint8Array(ephemeralPublicKeyBuffer)))
177
+ };
178
+ });
179
+ }
180
+ /**
181
+ * Decrypt response encrypted for the frontend
182
+ */
183
+ decryptForFrontend(encryptedPayload) {
184
+ return __async(this, null, function* () {
185
+ if (!this.frontendKeyPair) {
186
+ throw new Error("Frontend keypair not available");
187
+ }
188
+ const encryptedData = Uint8Array.from(atob(encryptedPayload.encryptedData), (c) => c.charCodeAt(0));
189
+ const ephemeralPublicKeyData = Uint8Array.from(atob(encryptedPayload.ephemeral), (c) => c.charCodeAt(0));
190
+ const ephemeralPublicKey = yield crypto.subtle.importKey(
191
+ "spki",
192
+ ephemeralPublicKeyData,
193
+ { name: "ECDH", namedCurve: "P-256" },
194
+ false,
195
+ []
196
+ );
197
+ const sharedSecretBits = yield crypto.subtle.deriveBits(
198
+ { name: "ECDH", public: ephemeralPublicKey },
199
+ this.frontendKeyPair.privateKey,
200
+ 256
201
+ );
202
+ const encryptionKeyBuffer = yield crypto.subtle.digest("SHA-256", sharedSecretBits);
203
+ const encryptionKey = yield crypto.subtle.importKey("raw", encryptionKeyBuffer, { name: "AES-GCM" }, false, ["decrypt"]);
204
+ const iv = encryptedData.slice(0, 12);
205
+ const ciphertext = encryptedData.slice(12);
206
+ const decrypted = yield crypto.subtle.decrypt({ name: "AES-GCM", iv }, encryptionKey, ciphertext);
207
+ return JSON.parse(new TextDecoder().decode(decrypted));
208
+ });
209
+ }
210
+ /**
211
+ * Persist key shares to the enclave
212
+ * @param shares Array of share data to persist
213
+ */
214
+ persistShares(shares) {
215
+ return __async(this, null, function* () {
216
+ const payload = {
217
+ shares,
218
+ jwt: this.retrieveJwt()
219
+ };
220
+ const encryptedPayload = yield this.encryptForEnclave(JSON.stringify(payload));
221
+ const encryptedPayloadStr = JSON.stringify(encryptedPayload);
222
+ return yield this.userManagementClient.persistEnclaveShares(encryptedPayloadStr);
223
+ });
224
+ }
225
+ /**
226
+ * Retrieve key shares from the enclave
227
+ * @param query Query parameters for finding shares (single query or array of queries)
228
+ */
229
+ retrieveShares(query) {
230
+ return __async(this, null, function* () {
231
+ yield this.issueEnclaveJwt();
232
+ const frontendKeyPair = yield this.generateFrontendKeyPair();
233
+ const responsePublicKeyPEM = yield this.exportPublicKeyToPEM(frontendKeyPair.publicKey);
234
+ const fullQuery = query.map((q) => ({
235
+ userId: q.userId
236
+ }));
237
+ const payload = {
238
+ query: fullQuery,
239
+ responsePublicKey: responsePublicKeyPEM,
240
+ jwt: this.retrieveJwt()
241
+ };
242
+ const encryptedPayload = yield this.encryptForEnclave(JSON.stringify(payload));
243
+ const encryptedPayloadStr = JSON.stringify(encryptedPayload);
244
+ const response = yield this.userManagementClient.retrieveEnclaveShares(encryptedPayloadStr);
245
+ const encryptedResponse = JSON.parse(response.payload);
246
+ const decryptedData = yield this.decryptForFrontend(encryptedResponse);
247
+ return decryptedData.shares;
248
+ });
249
+ }
250
+ retrieveSharesWithRetry(query) {
251
+ return __async(this, null, function* () {
252
+ return yield this.withJwtRefreshRetry(() => __async(this, null, function* () {
253
+ return this.retrieveShares(query);
254
+ }));
255
+ });
256
+ }
257
+ persistSharesWithRetry(shares) {
258
+ return __async(this, null, function* () {
259
+ return yield this.persistShares(shares);
260
+ });
261
+ }
262
+ }
263
+ // Annotate the CommonJS export names for ESM import in node:
264
+ 0 && (module.exports = {
265
+ EnclaveClient
266
+ });
@@ -52,8 +52,23 @@ function distributeNewShare(_0) {
52
52
  ignoreRedistributingBackupEncryptedShare = false,
53
53
  emailProps = {},
54
54
  partnerId,
55
- protocolId
55
+ protocolId,
56
+ isEnclaveUser,
57
+ walletScheme
56
58
  }) {
59
+ if (isEnclaveUser) {
60
+ yield ctx.enclaveClient.persistSharesWithRetry([
61
+ {
62
+ userId,
63
+ walletId,
64
+ walletScheme,
65
+ signer: userShare,
66
+ partnerId,
67
+ protocolId
68
+ }
69
+ ]);
70
+ return "";
71
+ }
57
72
  const publicKeysRes = yield ctx.client.getSessionPublicKeys(userId);
58
73
  const biometricEncryptedShares = publicKeysRes.data.keys.map((key) => {
59
74
  if (!key.publicKey) {
@@ -11,5 +11,5 @@ var __copyProps = (to, from, except, desc) => {
11
11
  return to;
12
12
  };
13
13
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
14
- var theme_exports = {};
15
- module.exports = __toCommonJS(theme_exports);
14
+ var assets_exports = {};
15
+ module.exports = __toCommonJS(assets_exports);
@@ -33,6 +33,8 @@ var ParaEvent = ((ParaEvent2) => {
33
33
  ParaEvent2["WALLET_CREATED"] = `${EVENT_PREFIX}WalletCreated`;
34
34
  ParaEvent2["PREGEN_WALLET_CLAIMED"] = `${EVENT_PREFIX}PregenWalletClaimed`;
35
35
  ParaEvent2["GUEST_WALLETS_CREATED"] = `${EVENT_PREFIX}GuestWalletsCreated`;
36
+ ParaEvent2["ASSET_TRANSFERRED"] = `${EVENT_PREFIX}AssetTransferred`;
37
+ ParaEvent2["ONRAMP_TRANSACTION_COMPLETE"] = `${EVENT_PREFIX}OnRampTransactionComplete`;
36
38
  return ParaEvent2;
37
39
  })(ParaEvent || {});
38
40
  // Annotate the CommonJS export names for ESM import in node:
@@ -2,10 +2,6 @@ var __defProp = Object.defineProperty;
2
2
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
4
4
  var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
5
  var __copyProps = (to, from, except, desc) => {
10
6
  if (from && typeof from === "object" || typeof from === "function") {
11
7
  for (let key of __getOwnPropNames(from))
@@ -17,38 +13,21 @@ var __copyProps = (to, from, except, desc) => {
17
13
  var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
18
14
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
15
  var types_exports = {};
20
- __export(types_exports, {
21
- Network: () => import_user_management_client.Network,
22
- OnRampAsset: () => import_user_management_client.OnRampAsset,
23
- OnRampProvider: () => import_user_management_client.OnRampProvider,
24
- OnRampPurchaseStatus: () => import_user_management_client.OnRampPurchaseStatus
25
- });
26
16
  module.exports = __toCommonJS(types_exports);
27
17
  __reExport(types_exports, require("./auth.js"), module.exports);
28
18
  __reExport(types_exports, require("./config.js"), module.exports);
29
19
  __reExport(types_exports, require("./coreApi.js"), module.exports);
30
20
  __reExport(types_exports, require("./wallet.js"), module.exports);
31
21
  __reExport(types_exports, require("./methods.js"), module.exports);
32
- __reExport(types_exports, require("./theme.js"), module.exports);
33
- __reExport(types_exports, require("./onRamps.js"), module.exports);
34
22
  __reExport(types_exports, require("./popup.js"), module.exports);
35
- __reExport(types_exports, require("./recovery.js"), module.exports);
36
23
  __reExport(types_exports, require("./events.js"), module.exports);
37
- var import_user_management_client = require("@getpara/user-management-client");
38
24
  // Annotate the CommonJS export names for ESM import in node:
39
25
  0 && (module.exports = {
40
- Network,
41
- OnRampAsset,
42
- OnRampProvider,
43
- OnRampPurchaseStatus,
44
26
  ...require("./auth.js"),
45
27
  ...require("./config.js"),
46
28
  ...require("./coreApi.js"),
47
29
  ...require("./wallet.js"),
48
30
  ...require("./methods.js"),
49
- ...require("./theme.js"),
50
- ...require("./onRamps.js"),
51
31
  ...require("./popup.js"),
52
- ...require("./recovery.js"),
53
32
  ...require("./events.js")
54
33
  });
@@ -4,6 +4,7 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
5
  var __getProtoOf = Object.getPrototypeOf;
6
6
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __pow = Math.pow;
7
8
  var __export = (target, all) => {
8
9
  for (var name in all)
9
10
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -29,6 +30,8 @@ var formatting_exports = {};
29
30
  __export(formatting_exports, {
30
31
  compressPubkey: () => compressPubkey,
31
32
  decimalToHex: () => decimalToHex,
33
+ formatAssetQuantity: () => formatAssetQuantity,
34
+ formatCurrency: () => formatCurrency,
32
35
  getCosmosAddress: () => getCosmosAddress,
33
36
  hexStringToBase64: () => hexStringToBase64,
34
37
  hexToDecimal: () => hexToDecimal,
@@ -102,10 +105,48 @@ function truncateAddress(str, addressType, {
102
105
  const margin = targetLength !== void 0 ? (targetLength - minimum) / 2 : 4;
103
106
  return `${str.slice(0, minimum + margin)}...${str.slice(-1 * margin)}`;
104
107
  }
108
+ function formatCurrency(value, { fallback = "" } = {}) {
109
+ if (!value) {
110
+ return fallback;
111
+ }
112
+ const formatter = new Intl.NumberFormat("en-US", {
113
+ style: "currency",
114
+ currency: value.currency
115
+ });
116
+ const zeroFormatter = new Intl.NumberFormat("en-US", {
117
+ style: "currency",
118
+ currency: value.currency,
119
+ maximumFractionDigits: 0
120
+ });
121
+ return Math.abs(value.value) < 0.01 ? zeroFormatter.format(0) : formatter.format(value.value);
122
+ }
123
+ const zeroAssetFormatter = new Intl.NumberFormat("en-US", {
124
+ style: "decimal",
125
+ maximumFractionDigits: 0,
126
+ minimumFractionDigits: 0
127
+ });
128
+ function formatAssetQuantity({
129
+ quantity,
130
+ symbol = "",
131
+ decimals,
132
+ fallback = ""
133
+ }) {
134
+ if (!quantity) {
135
+ return fallback;
136
+ }
137
+ const formatter = new Intl.NumberFormat("en-US", {
138
+ style: "decimal",
139
+ maximumFractionDigits: decimals != null ? decimals : Math.abs(quantity) < 1e-3 ? 6 : 3,
140
+ minimumFractionDigits: decimals != null ? decimals : 3
141
+ });
142
+ return `${Math.abs(quantity) < __pow(10, -1 * (decimals != null ? decimals : 6)) ? zeroAssetFormatter.format(0) : formatter.format(quantity)}${symbol && symbol.length > 0 ? ` ${symbol}` : ""}`;
143
+ }
105
144
  // Annotate the CommonJS export names for ESM import in node:
106
145
  0 && (module.exports = {
107
146
  compressPubkey,
108
147
  decimalToHex,
148
+ formatAssetQuantity,
149
+ formatCurrency,
109
150
  getCosmosAddress,
110
151
  hexStringToBase64,
111
152
  hexToDecimal,
@@ -24,7 +24,6 @@ __export(onRamps_exports, {
24
24
  toAssetInfoArray: () => toAssetInfoArray
25
25
  });
26
26
  module.exports = __toCommonJS(onRamps_exports);
27
- var import_user_management_client = require("@getpara/user-management-client");
28
27
  function toAssetInfoArray(data) {
29
28
  const result = [];
30
29
  Object.keys(data).forEach((walletType) => {
@@ -76,8 +75,8 @@ function getOnRampAssets(data, {
76
75
  ];
77
76
  }
78
77
  const NETWORK_PREFIXES = {
79
- [import_user_management_client.Network.COSMOS]: "cosmos",
80
- [import_user_management_client.Network.NOBLE]: "noble"
78
+ COSMOS: "cosmos",
79
+ NOBLE: "noble"
81
80
  };
82
81
  function getNetworkPrefix(network) {
83
82
  return NETWORK_PREFIXES[network];
@@ -114,7 +114,10 @@ function getEquivalentTypes(types) {
114
114
  return getWalletTypes(getSchemes(Array.isArray(types) ? types : [types]));
115
115
  }
116
116
  function entityToWallet(w) {
117
+ var _a;
117
118
  return __spreadProps(__spreadValues({}, w), {
119
+ createdAt: typeof w.createdAt === "string" ? w.createdAt : w.createdAt.toISOString(),
120
+ lastUsedAt: typeof w.lastUsedAt === "string" ? w.lastUsedAt : (_a = w.lastUsedAt) == null ? void 0 : _a.toISOString(),
118
121
  scheme: w.scheme,
119
122
  type: w.type,
120
123
  pregenIdentifierType: w.pregenIdentifierType