@getpara/core-sdk 2.0.0-dev.0 → 2.0.0-dev.2

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 (100) hide show
  1. package/dist/cjs/ParaCore.js +3378 -0
  2. package/dist/cjs/PlatformUtils.js +15 -0
  3. package/dist/cjs/StorageUtils.js +15 -0
  4. package/dist/cjs/constants.js +87 -0
  5. package/dist/cjs/cryptography/utils.js +350 -0
  6. package/dist/cjs/errors.js +51 -0
  7. package/dist/cjs/external/mpcComputationClient.js +62 -0
  8. package/dist/cjs/external/userManagementClient.js +106 -0
  9. package/dist/cjs/index.js +102 -4080
  10. package/dist/cjs/package.json +3 -0
  11. package/dist/cjs/shares/KeyContainer.js +89 -0
  12. package/dist/cjs/shares/recovery.js +127 -0
  13. package/dist/cjs/shares/shareDistribution.js +104 -0
  14. package/dist/cjs/transmission/transmissionUtils.js +93 -0
  15. package/dist/cjs/types/auth.js +33 -0
  16. package/dist/cjs/types/config.js +43 -0
  17. package/dist/cjs/types/coreApi.js +89 -0
  18. package/dist/cjs/types/events.js +41 -0
  19. package/dist/cjs/types/index.js +54 -0
  20. package/dist/cjs/types/methods.js +15 -0
  21. package/dist/cjs/types/onRamps.js +33 -0
  22. package/dist/cjs/types/popup.js +35 -0
  23. package/dist/cjs/types/recovery.js +34 -0
  24. package/dist/cjs/types/theme.js +15 -0
  25. package/dist/cjs/types/wallet.js +31 -0
  26. package/dist/cjs/utils/autobind.js +41 -0
  27. package/dist/cjs/utils/events.js +45 -0
  28. package/dist/cjs/utils/formatting.js +116 -0
  29. package/dist/cjs/utils/index.js +41 -0
  30. package/dist/cjs/utils/json.js +37 -0
  31. package/dist/cjs/utils/listeners.js +71 -0
  32. package/dist/cjs/utils/onRamps.js +92 -0
  33. package/dist/cjs/utils/phone.js +73 -0
  34. package/dist/cjs/utils/polling.js +58 -0
  35. package/dist/cjs/utils/types.js +29 -0
  36. package/dist/cjs/utils/url.js +135 -0
  37. package/dist/cjs/utils/wallet.js +159 -0
  38. package/dist/esm/ParaCore.js +3343 -0
  39. package/dist/esm/PlatformUtils.js +0 -0
  40. package/dist/esm/StorageUtils.js +0 -0
  41. package/dist/esm/chunk-7B52C2XE.js +70 -0
  42. package/dist/esm/constants.js +45 -0
  43. package/dist/esm/cryptography/utils.js +282 -0
  44. package/dist/esm/errors.js +27 -0
  45. package/dist/esm/external/mpcComputationClient.js +30 -0
  46. package/dist/esm/external/userManagementClient.js +71 -0
  47. package/dist/esm/index.js +78 -4049
  48. package/dist/esm/package.json +4 -0
  49. package/dist/esm/shares/KeyContainer.js +57 -0
  50. package/dist/esm/shares/recovery.js +74 -0
  51. package/dist/esm/shares/shareDistribution.js +64 -0
  52. package/dist/esm/transmission/transmissionUtils.js +42 -0
  53. package/dist/esm/types/auth.js +11 -0
  54. package/dist/esm/types/config.js +20 -0
  55. package/dist/esm/types/coreApi.js +66 -0
  56. package/dist/esm/types/events.js +19 -0
  57. package/dist/esm/types/index.js +23 -0
  58. package/dist/esm/types/methods.js +0 -0
  59. package/dist/esm/types/onRamps.js +11 -0
  60. package/dist/esm/types/popup.js +13 -0
  61. package/dist/esm/types/recovery.js +12 -0
  62. package/dist/esm/types/theme.js +0 -0
  63. package/dist/esm/types/wallet.js +9 -0
  64. package/dist/esm/utils/autobind.js +19 -0
  65. package/dist/esm/utils/events.js +11 -0
  66. package/dist/esm/utils/formatting.js +76 -0
  67. package/dist/esm/utils/index.js +11 -0
  68. package/dist/esm/utils/json.js +15 -0
  69. package/dist/esm/utils/listeners.js +38 -0
  70. package/dist/esm/utils/onRamps.js +66 -0
  71. package/dist/esm/utils/phone.js +39 -0
  72. package/dist/esm/utils/polling.js +18 -0
  73. package/dist/esm/utils/types.js +7 -0
  74. package/dist/esm/utils/url.js +90 -0
  75. package/dist/esm/utils/wallet.js +103 -0
  76. package/dist/types/ParaCore.d.ts +140 -367
  77. package/dist/types/PlatformUtils.d.ts +4 -5
  78. package/dist/types/constants.d.ts +17 -13
  79. package/dist/types/index.d.ts +5 -4
  80. package/dist/types/shares/KeyContainer.d.ts +0 -2
  81. package/dist/types/types/auth.d.ts +16 -0
  82. package/dist/types/types/config.d.ts +12 -5
  83. package/dist/types/types/coreApi.d.ts +531 -0
  84. package/dist/types/types/events.d.ts +4 -1
  85. package/dist/types/types/index.d.ts +2 -0
  86. package/dist/types/types/methods.d.ts +145 -42
  87. package/dist/types/types/onRamps.d.ts +3 -3
  88. package/dist/types/types/wallet.d.ts +8 -4
  89. package/dist/types/utils/formatting.d.ts +5 -2
  90. package/dist/types/utils/index.d.ts +1 -0
  91. package/dist/types/utils/onRamps.d.ts +12 -5
  92. package/dist/types/utils/phone.d.ts +6 -2
  93. package/dist/types/utils/types.d.ts +2 -0
  94. package/dist/types/utils/url.d.ts +2 -1
  95. package/dist/types/utils/wallet.d.ts +9 -7
  96. package/package.json +27 -26
  97. package/dist/cjs/index.js.br +0 -0
  98. package/dist/cjs/index.js.gz +0 -0
  99. package/dist/esm/index.js.br +0 -0
  100. package/dist/esm/index.js.gz +0 -0
@@ -0,0 +1,4 @@
1
+ {
2
+ "type": "module",
3
+ "sideEffects": false
4
+ }
@@ -0,0 +1,57 @@
1
+ import "../chunk-7B52C2XE.js";
2
+ import { Encrypt as ECIESEncrypt, Decrypt as ECIESDecrypt } from "@celo/utils/lib/ecies.js";
3
+ import * as eutil from "@ethereumjs/util";
4
+ import * as forge from "node-forge";
5
+ class KeyContainer {
6
+ constructor(walletId, keyshare, address) {
7
+ this.walletId = walletId;
8
+ this.keyshare = keyshare;
9
+ this.address = address;
10
+ this.backupDecryptionKey = Buffer.from(forge.random.getBytesSync(32), "binary").toString("hex");
11
+ }
12
+ static buildFrom(serializedContainer) {
13
+ try {
14
+ const parsedObject = JSON.parse(serializedContainer);
15
+ return Object.assign(new KeyContainer("", "", ""), parsedObject);
16
+ } catch (e) {
17
+ const container = new KeyContainer("", "", "");
18
+ container.backupDecryptionKey = serializedContainer.split("|")[0];
19
+ return container;
20
+ }
21
+ }
22
+ getPublicEncryptionKey() {
23
+ return Buffer.from(eutil.privateToPublic(Buffer.from(this.backupDecryptionKey, "hex")));
24
+ }
25
+ getPublicEncryptionKeyHex() {
26
+ return this.getPublicEncryptionKey().toString("hex");
27
+ }
28
+ encryptForSelf(backup) {
29
+ try {
30
+ const pubkey = this.getPublicEncryptionKey();
31
+ const data = ECIESEncrypt(pubkey, Buffer.from(backup, "ucs2")).toString("base64");
32
+ return data;
33
+ } catch (error) {
34
+ throw Error("Error encrypting backup");
35
+ }
36
+ }
37
+ static encryptWithPublicKey(publicKey, backup) {
38
+ try {
39
+ const data = ECIESEncrypt(publicKey, Buffer.from(backup, "ucs2")).toString("base64");
40
+ return data;
41
+ } catch (error) {
42
+ throw Error("Error encrypting backup");
43
+ }
44
+ }
45
+ decrypt(encryptedBackup) {
46
+ try {
47
+ const buf = Buffer.from(encryptedBackup, "base64");
48
+ const data = ECIESDecrypt(Buffer.from(this.backupDecryptionKey, "hex"), buf);
49
+ return Buffer.from(data.buffer).toString("ucs2");
50
+ } catch (error) {
51
+ throw Error("Error decrypting backup");
52
+ }
53
+ }
54
+ }
55
+ export {
56
+ KeyContainer
57
+ };
@@ -0,0 +1,74 @@
1
+ import {
2
+ __async,
3
+ __spreadValues
4
+ } from "../chunk-7B52C2XE.js";
5
+ import { EncryptorType, KeyShareType } from "@getpara/user-management-client";
6
+ import { KeyContainer } from "./KeyContainer.js";
7
+ function sendRecoveryForShare(_0) {
8
+ return __async(this, arguments, function* ({
9
+ ctx,
10
+ userId,
11
+ walletId,
12
+ otherEncryptedShares = [],
13
+ userSigner,
14
+ ignoreRedistributingBackupEncryptedShare = false,
15
+ emailProps = {},
16
+ forceRefresh = false
17
+ }) {
18
+ if (ignoreRedistributingBackupEncryptedShare) {
19
+ yield ctx.client.uploadUserKeyShares(
20
+ userId,
21
+ otherEncryptedShares.map((share) => __spreadValues({
22
+ walletId
23
+ }, share))
24
+ );
25
+ return "";
26
+ }
27
+ let userBackupKeyShareOptsArr;
28
+ let recoveryPrivateKeyContainer;
29
+ const { recoveryPublicKeys } = yield ctx.client.getRecoveryPublicKeys(userId);
30
+ if (forceRefresh || !(recoveryPublicKeys == null ? void 0 : recoveryPublicKeys.length)) {
31
+ recoveryPrivateKeyContainer = new KeyContainer(walletId, "", "");
32
+ const { recoveryPublicKeys: recoveryPublicKeys2 } = yield ctx.client.persistRecoveryPublicKeys(userId, [
33
+ recoveryPrivateKeyContainer.getPublicEncryptionKeyHex()
34
+ ]);
35
+ const encryptedUserBackup = recoveryPrivateKeyContainer.encryptForSelf(userSigner);
36
+ userBackupKeyShareOptsArr = [
37
+ {
38
+ walletId,
39
+ encryptedShare: encryptedUserBackup,
40
+ type: KeyShareType.USER,
41
+ encryptor: EncryptorType.RECOVERY,
42
+ recoveryPublicKeyId: recoveryPublicKeys2[0].id
43
+ }
44
+ ];
45
+ } else {
46
+ userBackupKeyShareOptsArr = recoveryPublicKeys.map((recoveryPublicKey) => {
47
+ const { id: recoveryPublicKeyId, publicKey } = recoveryPublicKey;
48
+ const encryptedUserBackup = KeyContainer.encryptWithPublicKey(Buffer.from(publicKey, "hex"), userSigner);
49
+ return {
50
+ walletId,
51
+ encryptedShare: encryptedUserBackup,
52
+ type: KeyShareType.USER,
53
+ encryptor: EncryptorType.RECOVERY,
54
+ recoveryPublicKeyId
55
+ };
56
+ });
57
+ }
58
+ yield ctx.client.uploadUserKeyShares(userId, [
59
+ ...otherEncryptedShares.map((share) => __spreadValues({
60
+ walletId
61
+ }, share)),
62
+ ...ignoreRedistributingBackupEncryptedShare ? [] : userBackupKeyShareOptsArr
63
+ ]);
64
+ yield ctx.client.distributeParaShare(__spreadValues({
65
+ userId,
66
+ walletId,
67
+ useDKLS: ctx.useDKLS
68
+ }, emailProps));
69
+ return recoveryPrivateKeyContainer ? JSON.stringify(recoveryPrivateKeyContainer) : "";
70
+ });
71
+ }
72
+ export {
73
+ sendRecoveryForShare
74
+ };
@@ -0,0 +1,64 @@
1
+ import {
2
+ __async
3
+ } from "../chunk-7B52C2XE.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
+ };
@@ -0,0 +1,42 @@
1
+ import {
2
+ __async
3
+ } from "../chunk-7B52C2XE.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
+ };
@@ -0,0 +1,11 @@
1
+ import "../chunk-7B52C2XE.js";
2
+ var AccountLinkError = /* @__PURE__ */ ((AccountLinkError2) => {
3
+ AccountLinkError2["NotAuthenticated"] = "No user is currently authenticated";
4
+ AccountLinkError2["Conflict"] = "Account already linked";
5
+ AccountLinkError2["Canceled"] = "Account linking was canceled";
6
+ AccountLinkError2["Unknown"] = "An unknown error occurred";
7
+ return AccountLinkError2;
8
+ })(AccountLinkError || {});
9
+ export {
10
+ AccountLinkError
11
+ };
@@ -0,0 +1,20 @@
1
+ import "../chunk-7B52C2XE.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
+ };
@@ -0,0 +1,66 @@
1
+ import "../chunk-7B52C2XE.js";
2
+ const PARA_CORE_METHODS = [
3
+ "getAuthInfo",
4
+ "signUpOrLogIn",
5
+ "verifyNewAccount",
6
+ "waitForLogin",
7
+ "waitForSignup",
8
+ "waitForWalletCreation",
9
+ "getOAuthUrl",
10
+ "verifyOAuth",
11
+ "getFarcasterConnectUri",
12
+ "verifyFarcaster",
13
+ "verifyTelegram",
14
+ "resendVerificationCode",
15
+ "loginExternalWallet",
16
+ "verifyExternalWallet",
17
+ "setup2fa",
18
+ "enable2fa",
19
+ "verify2fa",
20
+ "logout",
21
+ "clearStorage",
22
+ "isSessionActive",
23
+ "isFullyLoggedIn",
24
+ "refreshSession",
25
+ "keepSessionAlive",
26
+ "exportSession",
27
+ "importSession",
28
+ "getVerificationToken",
29
+ "getWallets",
30
+ "getWalletsByType",
31
+ "fetchWallets",
32
+ "createWallet",
33
+ "createWalletPerType",
34
+ "getPregenWallets",
35
+ "hasPregenWallet",
36
+ "updatePregenWalletIdentifier",
37
+ "createPregenWallet",
38
+ "createPregenWalletPerType",
39
+ "claimPregenWallets",
40
+ "createGuestWallets",
41
+ "distributeNewWalletShare",
42
+ "getUserShare",
43
+ "setUserShare",
44
+ "refreshShare",
45
+ "signMessage",
46
+ "signTransaction",
47
+ "initiateOnRampTransaction",
48
+ "getWalletBalance",
49
+ "issueJwt",
50
+ "getLinkedAccounts",
51
+ "accountLinkInProgress"
52
+ ];
53
+ const PARA_INTERNAL_METHODS = [
54
+ "linkAccount",
55
+ "unlinkAccount",
56
+ "verifyEmailOrPhoneLink",
57
+ "verifyOAuthLink",
58
+ "verifyFarcasterLink",
59
+ "verifyTelegramLink",
60
+ "verifyExternalWalletLink",
61
+ "accountLinkInProgress"
62
+ ];
63
+ export {
64
+ PARA_CORE_METHODS,
65
+ PARA_INTERNAL_METHODS
66
+ };
@@ -0,0 +1,19 @@
1
+ import "../chunk-7B52C2XE.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
+ ParaEvent2["GUEST_WALLETS_CREATED"] = `${EVENT_PREFIX}GuestWalletsCreated`;
15
+ return ParaEvent2;
16
+ })(ParaEvent || {});
17
+ export {
18
+ ParaEvent
19
+ };
@@ -0,0 +1,23 @@
1
+ import "../chunk-7B52C2XE.js";
2
+ export * from "./auth.js";
3
+ export * from "./config.js";
4
+ export * from "./coreApi.js";
5
+ export * from "./wallet.js";
6
+ export * from "./methods.js";
7
+ export * from "./theme.js";
8
+ export * from "./onRamps.js";
9
+ export * from "./popup.js";
10
+ export * from "./recovery.js";
11
+ 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
+ };
File without changes
@@ -0,0 +1,11 @@
1
+ import "../chunk-7B52C2XE.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
+ };
@@ -0,0 +1,13 @@
1
+ import "../chunk-7B52C2XE.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
+ };
@@ -0,0 +1,12 @@
1
+ import "../chunk-7B52C2XE.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
@@ -0,0 +1,9 @@
1
+ import "../chunk-7B52C2XE.js";
2
+ var PregenIdentifierType = /* @__PURE__ */ ((PregenIdentifierType2) => {
3
+ PregenIdentifierType2["EMAIL"] = "EMAIL";
4
+ PregenIdentifierType2["PHONE"] = "PHONE";
5
+ return PregenIdentifierType2;
6
+ })(PregenIdentifierType || {});
7
+ export {
8
+ PregenIdentifierType
9
+ };
@@ -0,0 +1,19 @@
1
+ import "../chunk-7B52C2XE.js";
2
+ function autoBind(instance) {
3
+ let proto = instance;
4
+ while (proto && proto !== Object.prototype) {
5
+ for (const key of Object.getOwnPropertyNames(proto)) {
6
+ const value = instance[key];
7
+ if (typeof value === "function" && key !== "constructor") {
8
+ try {
9
+ instance[key] = value.bind(instance);
10
+ } catch (e) {
11
+ }
12
+ }
13
+ }
14
+ proto = Object.getPrototypeOf(proto);
15
+ }
16
+ }
17
+ export {
18
+ autoBind
19
+ };
@@ -0,0 +1,11 @@
1
+ import {
2
+ __spreadValues
3
+ } from "../chunk-7B52C2XE.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
+ };
@@ -0,0 +1,76 @@
1
+ import "../chunk-7B52C2XE.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
+ const secp256k1 = new elliptic.ec("secp256k1");
7
+ function hexStringToBase64(hexString) {
8
+ if (hexString.substring(0, 2) === "0x") {
9
+ hexString = hexString.substring(2);
10
+ }
11
+ return Buffer.from(hexString, "hex").toString("base64");
12
+ }
13
+ function hexToSignature(hexSig) {
14
+ return {
15
+ r: `0x${hexSig.slice(2, 66)}`,
16
+ s: `0x${hexSig.slice(66, 130)}`,
17
+ v: BigInt(hexSig.slice(130, 132))
18
+ };
19
+ }
20
+ function hexToUint8Array(hex) {
21
+ if (hex.startsWith("0x")) {
22
+ hex = hex.slice(2);
23
+ }
24
+ return new Uint8Array(Buffer.from(hex, "hex"));
25
+ }
26
+ function hexToDecimal(hex) {
27
+ if (hex.startsWith("0x")) {
28
+ hex = hex.slice(2);
29
+ }
30
+ return `${parseInt(hex, 16)}`;
31
+ }
32
+ function decimalToHex(decimal) {
33
+ return `0x${parseInt(decimal).toString(16)}`;
34
+ }
35
+ function compressPubkey(pubkey) {
36
+ switch (pubkey.length) {
37
+ case 33:
38
+ return pubkey;
39
+ case 65:
40
+ return Uint8Array.from(secp256k1.keyFromPublic(pubkey).getPublic(true, "array"));
41
+ default:
42
+ throw new Error("Invalid pubkey length");
43
+ }
44
+ }
45
+ function rawSecp256k1PubkeyToRawAddress(pubkeyData) {
46
+ if (pubkeyData.length !== 33) {
47
+ throw new Error(`Invalid Secp256k1 pubkey length (compressed): ${pubkeyData.length}`);
48
+ }
49
+ return ripemd160(sha256(pubkeyData));
50
+ }
51
+ function getCosmosAddress(publicKey, prefix) {
52
+ const uncompressedPublicKey = new Uint8Array(
53
+ Buffer.from(publicKey.startsWith("0x") ? publicKey.slice(2) : publicKey, "hex")
54
+ );
55
+ const compressedPublicKey = compressPubkey(uncompressedPublicKey);
56
+ return toBech32(prefix, rawSecp256k1PubkeyToRawAddress(compressedPublicKey));
57
+ }
58
+ function truncateAddress(str, addressType, {
59
+ prefix = addressType === "COSMOS" ? "cosmos" : void 0,
60
+ targetLength
61
+ } = {}) {
62
+ const minimum = addressType === "COSMOS" ? prefix.length : addressType === "EVM" ? 2 : 0;
63
+ const margin = targetLength !== void 0 ? (targetLength - minimum) / 2 : 4;
64
+ return `${str.slice(0, minimum + margin)}...${str.slice(-1 * margin)}`;
65
+ }
66
+ export {
67
+ compressPubkey,
68
+ decimalToHex,
69
+ getCosmosAddress,
70
+ hexStringToBase64,
71
+ hexToDecimal,
72
+ hexToSignature,
73
+ hexToUint8Array,
74
+ rawSecp256k1PubkeyToRawAddress,
75
+ truncateAddress
76
+ };
@@ -0,0 +1,11 @@
1
+ export * from "./autobind.js";
2
+ export * from "./events.js";
3
+ export * from "./formatting.js";
4
+ export * from "./json.js";
5
+ export * from "./listeners.js";
6
+ export * from "./onRamps.js";
7
+ export * from "./phone.js";
8
+ export * from "./polling.js";
9
+ export * from "./types.js";
10
+ export * from "./url.js";
11
+ export * from "./wallet.js";
@@ -0,0 +1,15 @@
1
+ import "../chunk-7B52C2XE.js";
2
+ function jsonParse(data, validate) {
3
+ try {
4
+ const res = JSON.parse(data);
5
+ if (validate && !validate(res)) {
6
+ return void 0;
7
+ }
8
+ return res;
9
+ } catch (e) {
10
+ return void 0;
11
+ }
12
+ }
13
+ export {
14
+ jsonParse
15
+ };
@@ -0,0 +1,38 @@
1
+ import "../chunk-7B52C2XE.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_AUTH_INFO) {
23
+ this.updateAuthInfoFromStorage();
24
+ }
25
+ if (e.key === constants.LOCAL_STORAGE_USER_ID) {
26
+ this.updateUserIdFromStorage();
27
+ }
28
+ }
29
+ function setupListeners() {
30
+ if (typeof window !== "undefined" && window.addEventListener && window.location) {
31
+ window.removeEventListener("storage", storageListener.bind(this));
32
+ window.addEventListener("storage", storageListener.bind(this));
33
+ }
34
+ }
35
+ export {
36
+ setupListeners,
37
+ storageListener
38
+ };