@getpara/core-sdk 1.2.0 → 1.3.1
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/.!4351!index.js.br +0 -0
- package/dist/cjs/.!4353!index.js.gz +0 -0
- package/dist/cjs/index.js +2 -97
- package/dist/cjs/index.js.br +0 -0
- package/dist/cjs/index.js.gz +0 -0
- package/dist/esm/.!4345!index.js.br +0 -0
- package/dist/esm/.!4347!index.js.gz +0 -0
- package/dist/esm/index.js +2 -23
- package/dist/esm/index.js.br +0 -0
- package/dist/esm/index.js.gz +0 -0
- package/package.json +7 -7
- package/dist/cjs/ParaCore.js +0 -2620
- package/dist/cjs/PlatformUtils.js +0 -2
- package/dist/cjs/StorageUtils.js +0 -2
- package/dist/cjs/constants.js +0 -20
- package/dist/cjs/cryptography/utils.js +0 -251
- package/dist/cjs/errors.js +0 -27
- package/dist/cjs/external/mpcComputationClient.js +0 -33
- package/dist/cjs/external/userManagementClient.js +0 -66
- package/dist/cjs/package.json +0 -1
- package/dist/cjs/shares/KeyContainer.js +0 -84
- package/dist/cjs/shares/recovery.js +0 -62
- package/dist/cjs/shares/shareDistribution.js +0 -67
- package/dist/cjs/transmission/transmissionUtils.js +0 -73
- package/dist/cjs/types/config.js +0 -22
- package/dist/cjs/types/events.js +0 -17
- package/dist/cjs/types/index.js +0 -30
- package/dist/cjs/types/onRamps.js +0 -10
- package/dist/cjs/types/params.js +0 -2
- package/dist/cjs/types/popup.js +0 -12
- package/dist/cjs/types/recovery.js +0 -12
- package/dist/cjs/types/theme.js +0 -2
- package/dist/cjs/types/wallet.js +0 -9
- package/dist/cjs/utils/events.js +0 -9
- package/dist/cjs/utils/formatting.js +0 -81
- package/dist/cjs/utils/index.js +0 -22
- package/dist/cjs/utils/onRamps.js +0 -36
- package/dist/cjs/utils/polling.js +0 -25
- package/dist/cjs/utils/url.js +0 -74
- package/dist/cjs/utils/wallet.js +0 -74
- package/dist/esm/ParaCore.js +0 -2590
- package/dist/esm/PlatformUtils.js +0 -1
- package/dist/esm/StorageUtils.js +0 -1
- package/dist/esm/constants.js +0 -17
- package/dist/esm/cryptography/utils.js +0 -226
- package/dist/esm/errors.js +0 -21
- package/dist/esm/external/mpcComputationClient.js +0 -26
- package/dist/esm/external/userManagementClient.js +0 -56
- package/dist/esm/package.json +0 -1
- package/dist/esm/shares/KeyContainer.js +0 -57
- package/dist/esm/shares/recovery.js +0 -58
- package/dist/esm/shares/shareDistribution.js +0 -63
- package/dist/esm/transmission/transmissionUtils.js +0 -45
- package/dist/esm/types/config.js +0 -19
- package/dist/esm/types/events.js +0 -14
- package/dist/esm/types/index.js +0 -9
- package/dist/esm/types/onRamps.js +0 -7
- package/dist/esm/types/params.js +0 -1
- package/dist/esm/types/popup.js +0 -9
- package/dist/esm/types/recovery.js +0 -9
- package/dist/esm/types/theme.js +0 -1
- package/dist/esm/types/wallet.js +0 -6
- package/dist/esm/utils/events.js +0 -5
- package/dist/esm/utils/formatting.js +0 -66
- package/dist/esm/utils/index.js +0 -6
- package/dist/esm/utils/onRamps.js +0 -30
- package/dist/esm/utils/polling.js +0 -21
- package/dist/esm/utils/url.js +0 -66
- package/dist/esm/utils/wallet.js +0 -64
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
// Make sure to keep this in sync with capsule-org/src/entities/recoveryAttemptEntity.ts
|
|
2
|
-
export var RecoveryStatus;
|
|
3
|
-
(function (RecoveryStatus) {
|
|
4
|
-
RecoveryStatus["INITIATED"] = "INITIATED";
|
|
5
|
-
RecoveryStatus["READY"] = "READY";
|
|
6
|
-
RecoveryStatus["EXPIRED"] = "EXPIRED";
|
|
7
|
-
RecoveryStatus["FINISHED"] = "FINISHED";
|
|
8
|
-
RecoveryStatus["CANCELLED"] = "CANCELLED";
|
|
9
|
-
})(RecoveryStatus || (RecoveryStatus = {}));
|
package/dist/esm/types/theme.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/esm/types/wallet.js
DELETED
package/dist/esm/utils/events.js
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { toBech32 } from '@cosmjs/encoding';
|
|
2
|
-
import { sha256 } from '@noble/hashes/sha256';
|
|
3
|
-
import { ripemd160 } from '@noble/hashes/ripemd160';
|
|
4
|
-
import elliptic from 'elliptic';
|
|
5
|
-
import parsePhoneNumberFromString from 'libphonenumber-js';
|
|
6
|
-
const secp256k1 = new elliptic.ec('secp256k1');
|
|
7
|
-
export 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
|
-
export 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
|
-
export function hexToUint8Array(hex) {
|
|
21
|
-
if (hex.startsWith('0x')) {
|
|
22
|
-
hex = hex.slice(2);
|
|
23
|
-
}
|
|
24
|
-
return new Uint8Array(Buffer.from(hex, 'hex'));
|
|
25
|
-
}
|
|
26
|
-
export function hexToDecimal(hex) {
|
|
27
|
-
if (hex.startsWith('0x')) {
|
|
28
|
-
hex = hex.slice(2);
|
|
29
|
-
}
|
|
30
|
-
return `${parseInt(hex, 16)}`;
|
|
31
|
-
}
|
|
32
|
-
export 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
|
-
export function getCosmosAddress(publicKey, prefix) {
|
|
52
|
-
const uncompressedPublicKey = new Uint8Array(Buffer.from(publicKey.startsWith('0x') ? publicKey.slice(2) : publicKey, 'hex'));
|
|
53
|
-
const compressedPublicKey = compressPubkey(uncompressedPublicKey);
|
|
54
|
-
return toBech32(prefix, rawSecp256k1PubkeyToRawAddress(compressedPublicKey));
|
|
55
|
-
}
|
|
56
|
-
export function truncateAddress(str, addressType, { prefix = addressType === 'COSMOS' ? 'cosmos' : undefined } = {}) {
|
|
57
|
-
const headLength = (addressType === 'COSMOS' ? prefix.length : addressType === 'SOLANA' ? 0 : 2) + 4;
|
|
58
|
-
return `${str.slice(0, headLength)}...${str.slice(-4)}`;
|
|
59
|
-
}
|
|
60
|
-
export function stringToPhoneNumber(str) {
|
|
61
|
-
var _a;
|
|
62
|
-
return (_a = parsePhoneNumberFromString(str)) === null || _a === void 0 ? void 0 : _a.formatInternational().replace(/[^\d+]/g, '');
|
|
63
|
-
}
|
|
64
|
-
export function normalizePhoneNumber(countryCode, number) {
|
|
65
|
-
return stringToPhoneNumber(`${countryCode[0] !== '+' ? '+' : ''}${countryCode}${number}`);
|
|
66
|
-
}
|
package/dist/esm/utils/index.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
export function toAssetInfoArray(data) {
|
|
2
|
-
const result = [];
|
|
3
|
-
Object.keys(data).forEach(walletType => {
|
|
4
|
-
const networks = data[walletType];
|
|
5
|
-
Object.keys(networks).forEach(network => {
|
|
6
|
-
const assets = networks[network];
|
|
7
|
-
Object.keys(assets).forEach(asset => {
|
|
8
|
-
const providerInfo = assets[asset];
|
|
9
|
-
result.push([walletType, network, asset, providerInfo]);
|
|
10
|
-
});
|
|
11
|
-
});
|
|
12
|
-
});
|
|
13
|
-
return result;
|
|
14
|
-
}
|
|
15
|
-
export function getOnRampNetworks(data, { walletType, allowed } = {}) {
|
|
16
|
-
return [
|
|
17
|
-
...new Set(toAssetInfoArray(data)
|
|
18
|
-
.filter(([type, network]) => (!walletType || type === walletType) && (!allowed || allowed.includes(network)))
|
|
19
|
-
.map(([_, network]) => network)),
|
|
20
|
-
];
|
|
21
|
-
}
|
|
22
|
-
export function getOnRampAssets(data, { walletType, network, allowed, } = {}) {
|
|
23
|
-
return [
|
|
24
|
-
...new Set(toAssetInfoArray(data)
|
|
25
|
-
.filter(([t, n, a]) => (!walletType || t === walletType) &&
|
|
26
|
-
(!network || n === network) &&
|
|
27
|
-
(!Array.isArray(allowed) || allowed.includes(a)))
|
|
28
|
-
.map(([, , asset]) => asset)),
|
|
29
|
-
];
|
|
30
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
export function waitUntilTrue(condition, timeoutMs, intervalMs) {
|
|
11
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
12
|
-
const start = Date.now();
|
|
13
|
-
while (Date.now() - start < timeoutMs) {
|
|
14
|
-
if (yield condition()) {
|
|
15
|
-
return true;
|
|
16
|
-
}
|
|
17
|
-
yield new Promise(resolve => setTimeout(resolve, intervalMs));
|
|
18
|
-
}
|
|
19
|
-
return false;
|
|
20
|
-
});
|
|
21
|
-
}
|
package/dist/esm/utils/url.js
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { Environment } from '../types/index.js';
|
|
2
|
-
export function getPortalDomain(env, isE2E) {
|
|
3
|
-
if (isE2E) {
|
|
4
|
-
return `localhost`;
|
|
5
|
-
}
|
|
6
|
-
switch (env) {
|
|
7
|
-
case Environment.DEV:
|
|
8
|
-
return 'localhost';
|
|
9
|
-
case Environment.SANDBOX:
|
|
10
|
-
return 'app.sandbox.usecapsule.com';
|
|
11
|
-
case Environment.BETA:
|
|
12
|
-
return 'app.beta.usecapsule.com';
|
|
13
|
-
case Environment.PROD:
|
|
14
|
-
return 'app.usecapsule.com';
|
|
15
|
-
default:
|
|
16
|
-
throw new Error(`env: ${env} not supported`);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
export function getPortalBaseURL({ env, isE2E }, useLocalIp, isForWasm) {
|
|
20
|
-
if (isE2E) {
|
|
21
|
-
if (isForWasm) {
|
|
22
|
-
return `https://app.sandbox.usecapsule.com`;
|
|
23
|
-
}
|
|
24
|
-
return `http://localhost:3003`;
|
|
25
|
-
}
|
|
26
|
-
const domain = getPortalDomain(env);
|
|
27
|
-
if (env === Environment.DEV) {
|
|
28
|
-
if (useLocalIp) {
|
|
29
|
-
return `http://127.0.0.1:3003`;
|
|
30
|
-
}
|
|
31
|
-
return `http://${domain}:3003`;
|
|
32
|
-
}
|
|
33
|
-
return `https://${domain}`;
|
|
34
|
-
}
|
|
35
|
-
export function getParaConnectDomain(env) {
|
|
36
|
-
switch (env) {
|
|
37
|
-
case Environment.DEV:
|
|
38
|
-
return 'localhost';
|
|
39
|
-
case Environment.SANDBOX:
|
|
40
|
-
return 'connect.sandbox.getpara.com';
|
|
41
|
-
case Environment.BETA:
|
|
42
|
-
return 'connect.beta.getpara.com';
|
|
43
|
-
case Environment.PROD:
|
|
44
|
-
return 'connect.getpara.com';
|
|
45
|
-
default:
|
|
46
|
-
throw new Error(`env: ${env} not supported`);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
export function getParaConnectBaseUrl({ env }, useLocalIp) {
|
|
50
|
-
const domain = getParaConnectDomain(env);
|
|
51
|
-
if (env === Environment.DEV) {
|
|
52
|
-
if (useLocalIp) {
|
|
53
|
-
return `http://127.0.0.1:3008`;
|
|
54
|
-
}
|
|
55
|
-
return `http://${domain}:3008`;
|
|
56
|
-
}
|
|
57
|
-
return `https://${domain}`;
|
|
58
|
-
}
|
|
59
|
-
export function constructUrl({ base, path, params = {}, }) {
|
|
60
|
-
const url = new URL(path, base);
|
|
61
|
-
Object.entries(params).forEach(([key, value]) => {
|
|
62
|
-
if (!!value && value !== 'undefined' && value !== 'null')
|
|
63
|
-
url.searchParams.set(key, value.toString());
|
|
64
|
-
});
|
|
65
|
-
return url.toString();
|
|
66
|
-
}
|
package/dist/esm/utils/wallet.js
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { WalletScheme, WalletType } from '@getpara/user-management-client';
|
|
2
|
-
import { stringToPhoneNumber } from './formatting.js';
|
|
3
|
-
export const WalletSchemeTypeMap = {
|
|
4
|
-
[WalletScheme.DKLS]: {
|
|
5
|
-
[WalletType.EVM]: true,
|
|
6
|
-
[WalletType.COSMOS]: true,
|
|
7
|
-
},
|
|
8
|
-
[WalletScheme.CGGMP]: {
|
|
9
|
-
[WalletType.EVM]: true,
|
|
10
|
-
[WalletType.COSMOS]: true,
|
|
11
|
-
},
|
|
12
|
-
[WalletScheme.ED25519]: {
|
|
13
|
-
[WalletType.SOLANA]: true,
|
|
14
|
-
},
|
|
15
|
-
};
|
|
16
|
-
export function isPregenIdentifierMatch(a, b, type) {
|
|
17
|
-
if (!a || !b) {
|
|
18
|
-
return false;
|
|
19
|
-
}
|
|
20
|
-
switch (type) {
|
|
21
|
-
case 'EMAIL':
|
|
22
|
-
return a.toLowerCase() === b.toLowerCase();
|
|
23
|
-
case 'PHONE':
|
|
24
|
-
return stringToPhoneNumber(a) === stringToPhoneNumber(b);
|
|
25
|
-
case 'CUSTOM_ID':
|
|
26
|
-
return a === b;
|
|
27
|
-
default:
|
|
28
|
-
return a.replace(/^@/g, '').toLowerCase() === b.replace(/^@/g, '').toLowerCase();
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
export function isWalletSupported(types, wallet) {
|
|
32
|
-
return types.some((walletType) => !!WalletSchemeTypeMap[wallet.scheme][walletType]);
|
|
33
|
-
}
|
|
34
|
-
export function getSchemes(types) {
|
|
35
|
-
return Object.keys(WalletSchemeTypeMap).filter(scheme => {
|
|
36
|
-
if (scheme === WalletScheme.CGGMP) {
|
|
37
|
-
return false;
|
|
38
|
-
}
|
|
39
|
-
return (Array.isArray(types) ? types : Object.keys(types)).some(type => WalletSchemeTypeMap[scheme][type]);
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
export function getWalletTypes(schemes) {
|
|
43
|
-
return [
|
|
44
|
-
...new Set(schemes.reduce((acc, scheme) => {
|
|
45
|
-
return [...acc, ...Object.keys(WalletSchemeTypeMap[scheme]).filter(type => WalletSchemeTypeMap[scheme][type])];
|
|
46
|
-
}, [])),
|
|
47
|
-
];
|
|
48
|
-
}
|
|
49
|
-
export function getEquivalentTypes(types) {
|
|
50
|
-
return getWalletTypes(getSchemes((Array.isArray(types) ? types : [types]).map(t => WalletType[t])));
|
|
51
|
-
}
|
|
52
|
-
export function entityToWallet(w) {
|
|
53
|
-
return Object.assign(Object.assign({}, w), { scheme: w.scheme, type: w.type, pregenIdentifierType: w.pregenIdentifierType });
|
|
54
|
-
}
|
|
55
|
-
export function migrateWallet(obj) {
|
|
56
|
-
if (['USER', 'PREGEN'].includes(obj.type)) {
|
|
57
|
-
obj.isPregen = obj.type === 'PREGEN';
|
|
58
|
-
obj.type = obj.scheme === WalletScheme.ED25519 ? WalletType.SOLANA : WalletType.EVM;
|
|
59
|
-
}
|
|
60
|
-
if (!!obj.scheme && !obj.type) {
|
|
61
|
-
obj.type = obj.scheme === WalletScheme.ED25519 ? WalletType.SOLANA : WalletType.EVM;
|
|
62
|
-
}
|
|
63
|
-
return obj;
|
|
64
|
-
}
|