@getpara/core-sdk 2.0.0-alpha.3 → 2.0.0-alpha.6
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.
- package/dist/cjs/ParaCore.js +3028 -0
- package/dist/cjs/PlatformUtils.js +15 -0
- package/dist/cjs/StorageUtils.js +15 -0
- package/dist/cjs/constants.js +84 -0
- package/dist/cjs/cryptography/utils.js +350 -0
- package/dist/cjs/errors.js +51 -0
- package/dist/cjs/external/mpcComputationClient.js +62 -0
- package/dist/cjs/external/userManagementClient.js +106 -0
- package/dist/cjs/index.js +85 -4001
- package/dist/cjs/package.json +3 -0
- package/dist/cjs/shares/KeyContainer.js +89 -0
- package/dist/cjs/shares/recovery.js +127 -0
- package/dist/cjs/shares/shareDistribution.js +104 -0
- package/dist/cjs/transmission/transmissionUtils.js +93 -0
- package/dist/cjs/types/config.js +43 -0
- package/dist/cjs/types/coreApi.js +74 -0
- package/dist/cjs/types/events.js +41 -0
- package/dist/cjs/types/index.js +52 -0
- package/dist/cjs/types/methods.js +15 -0
- package/dist/cjs/types/onRamps.js +33 -0
- package/dist/cjs/types/popup.js +35 -0
- package/dist/cjs/types/recovery.js +34 -0
- package/dist/cjs/types/theme.js +15 -0
- package/dist/cjs/types/wallet.js +31 -0
- package/dist/cjs/utils/autobind.js +41 -0
- package/dist/cjs/utils/events.js +45 -0
- package/dist/cjs/utils/formatting.js +112 -0
- package/dist/cjs/utils/index.js +41 -0
- package/dist/cjs/utils/json.js +37 -0
- package/dist/cjs/utils/listeners.js +71 -0
- package/dist/cjs/utils/onRamps.js +92 -0
- package/dist/cjs/utils/phone.js +73 -0
- package/dist/cjs/utils/polling.js +58 -0
- package/dist/cjs/utils/types.js +29 -0
- package/dist/cjs/utils/url.js +135 -0
- package/dist/cjs/utils/wallet.js +159 -0
- package/dist/esm/ParaCore.js +2990 -0
- package/dist/esm/PlatformUtils.js +0 -0
- package/dist/esm/StorageUtils.js +0 -0
- package/dist/esm/chunk-7B52C2XE.js +70 -0
- package/dist/esm/constants.js +43 -0
- package/dist/esm/cryptography/utils.js +282 -0
- package/dist/esm/errors.js +27 -0
- package/dist/esm/external/mpcComputationClient.js +30 -0
- package/dist/esm/external/userManagementClient.js +71 -0
- package/dist/esm/index.js +58 -3965
- package/dist/esm/package.json +4 -0
- package/dist/esm/shares/KeyContainer.js +57 -0
- package/dist/esm/shares/recovery.js +74 -0
- package/dist/esm/shares/shareDistribution.js +64 -0
- package/dist/esm/transmission/transmissionUtils.js +42 -0
- package/dist/esm/types/config.js +20 -0
- package/dist/esm/types/coreApi.js +52 -0
- package/dist/esm/types/events.js +19 -0
- package/dist/esm/types/index.js +22 -0
- package/dist/esm/types/methods.js +0 -0
- package/dist/esm/types/onRamps.js +11 -0
- package/dist/esm/types/popup.js +13 -0
- package/dist/esm/types/recovery.js +12 -0
- package/dist/esm/types/theme.js +0 -0
- package/dist/esm/types/wallet.js +9 -0
- package/dist/esm/utils/autobind.js +19 -0
- package/dist/esm/utils/events.js +11 -0
- package/dist/esm/utils/formatting.js +74 -0
- package/dist/esm/utils/index.js +11 -0
- package/dist/esm/utils/json.js +15 -0
- package/dist/esm/utils/listeners.js +38 -0
- package/dist/esm/utils/onRamps.js +66 -0
- package/dist/esm/utils/phone.js +39 -0
- package/dist/esm/utils/polling.js +18 -0
- package/dist/esm/utils/types.js +7 -0
- package/dist/esm/utils/url.js +90 -0
- package/dist/esm/utils/wallet.js +103 -0
- package/dist/types/ParaCore.d.ts +157 -126
- package/dist/types/PlatformUtils.d.ts +4 -3
- package/dist/types/constants.d.ts +2 -0
- package/dist/types/index.d.ts +3 -3
- package/dist/types/types/config.d.ts +4 -5
- package/dist/types/types/coreApi.d.ts +47 -9
- package/dist/types/types/events.d.ts +4 -1
- package/dist/types/types/methods.d.ts +9 -4
- package/dist/types/types/onRamps.d.ts +3 -3
- package/dist/types/types/wallet.d.ts +4 -2
- package/dist/types/utils/formatting.d.ts +3 -2
- package/dist/types/utils/onRamps.d.ts +12 -5
- package/dist/types/utils/phone.d.ts +4 -0
- package/dist/types/utils/wallet.d.ts +8 -7
- package/package.json +7 -7
- package/dist/cjs/index.js.br +0 -0
- package/dist/cjs/index.js.gz +0 -0
- package/dist/esm/index.js.br +0 -0
- package/dist/esm/index.js.gz +0 -0
|
@@ -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,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,52 @@
|
|
|
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
|
+
];
|
|
50
|
+
export {
|
|
51
|
+
PARA_CORE_METHODS
|
|
52
|
+
};
|
|
@@ -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,22 @@
|
|
|
1
|
+
import "../chunk-7B52C2XE.js";
|
|
2
|
+
export * from "./config.js";
|
|
3
|
+
export * from "./coreApi.js";
|
|
4
|
+
export * from "./wallet.js";
|
|
5
|
+
export * from "./methods.js";
|
|
6
|
+
export * from "./theme.js";
|
|
7
|
+
export * from "./onRamps.js";
|
|
8
|
+
export * from "./popup.js";
|
|
9
|
+
export * from "./recovery.js";
|
|
10
|
+
export * from "./events.js";
|
|
11
|
+
import {
|
|
12
|
+
Network,
|
|
13
|
+
OnRampAsset,
|
|
14
|
+
OnRampProvider,
|
|
15
|
+
OnRampPurchaseStatus
|
|
16
|
+
} from "@getpara/user-management-client";
|
|
17
|
+
export {
|
|
18
|
+
Network,
|
|
19
|
+
OnRampAsset,
|
|
20
|
+
OnRampProvider,
|
|
21
|
+
OnRampPurchaseStatus
|
|
22
|
+
};
|
|
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,74 @@
|
|
|
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
|
+
decimalToHex,
|
|
68
|
+
getCosmosAddress,
|
|
69
|
+
hexStringToBase64,
|
|
70
|
+
hexToDecimal,
|
|
71
|
+
hexToSignature,
|
|
72
|
+
hexToUint8Array,
|
|
73
|
+
truncateAddress
|
|
74
|
+
};
|
|
@@ -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
|
+
};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import "../chunk-7B52C2XE.js";
|
|
2
|
+
import { Network } from "@getpara/user-management-client";
|
|
3
|
+
function toAssetInfoArray(data) {
|
|
4
|
+
const result = [];
|
|
5
|
+
Object.keys(data).forEach((walletType) => {
|
|
6
|
+
const networks = data[walletType];
|
|
7
|
+
Object.keys(networks).forEach((network) => {
|
|
8
|
+
const assets = networks[network];
|
|
9
|
+
Object.keys(assets).forEach((asset) => {
|
|
10
|
+
const providerInfo = assets[asset];
|
|
11
|
+
result.push([walletType, network, asset, providerInfo]);
|
|
12
|
+
});
|
|
13
|
+
});
|
|
14
|
+
});
|
|
15
|
+
return result;
|
|
16
|
+
}
|
|
17
|
+
function getOnRampNetworks(data, {
|
|
18
|
+
walletType,
|
|
19
|
+
allowed,
|
|
20
|
+
assets,
|
|
21
|
+
providers,
|
|
22
|
+
action
|
|
23
|
+
} = {}) {
|
|
24
|
+
return [
|
|
25
|
+
...new Set(
|
|
26
|
+
toAssetInfoArray(data).filter(
|
|
27
|
+
([type, network, asset, providerInfo]) => (!walletType || type === walletType) && (!allowed || allowed.includes(network)) && (!assets || assets.includes(asset)) && (!providers || providers.some((provider) => {
|
|
28
|
+
var _a;
|
|
29
|
+
return ((_a = providerInfo[provider]) == null ? void 0 : _a[1]) && (!action || providerInfo[provider][1][action]);
|
|
30
|
+
}))
|
|
31
|
+
).map(([_, network]) => network)
|
|
32
|
+
)
|
|
33
|
+
];
|
|
34
|
+
}
|
|
35
|
+
function getOnRampAssets(data, {
|
|
36
|
+
walletType,
|
|
37
|
+
network,
|
|
38
|
+
allowed,
|
|
39
|
+
providers,
|
|
40
|
+
action
|
|
41
|
+
} = {}) {
|
|
42
|
+
return [
|
|
43
|
+
...new Set(
|
|
44
|
+
toAssetInfoArray(data).filter(
|
|
45
|
+
([t, n, a, p]) => (!walletType || t === walletType) && (!network || n === network) && (!Array.isArray(allowed) || allowed.includes(a)) && (!providers || providers.some((provider) => {
|
|
46
|
+
var _a;
|
|
47
|
+
return ((_a = p[provider]) == null ? void 0 : _a[1]) && (!action || p[provider][1][action]);
|
|
48
|
+
}))
|
|
49
|
+
).map(([, , asset]) => asset)
|
|
50
|
+
)
|
|
51
|
+
];
|
|
52
|
+
}
|
|
53
|
+
const NETWORK_PREFIXES = {
|
|
54
|
+
[Network.COSMOS]: "cosmos",
|
|
55
|
+
[Network.NOBLE]: "noble"
|
|
56
|
+
};
|
|
57
|
+
function getNetworkPrefix(network) {
|
|
58
|
+
return NETWORK_PREFIXES[network];
|
|
59
|
+
}
|
|
60
|
+
export {
|
|
61
|
+
NETWORK_PREFIXES,
|
|
62
|
+
getNetworkPrefix,
|
|
63
|
+
getOnRampAssets,
|
|
64
|
+
getOnRampNetworks,
|
|
65
|
+
toAssetInfoArray
|
|
66
|
+
};
|