@getpara/core-sdk 1.0.2 → 1.2.0
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 +140 -224
- package/dist/cjs/constants.js +20 -0
- package/dist/cjs/cryptography/utils.js +2 -2
- package/dist/cjs/external/userManagementClient.js +14 -14
- package/dist/cjs/index.js +28 -12
- package/dist/cjs/types/config.js +22 -0
- package/dist/cjs/types/index.js +11 -2
- package/dist/cjs/types/onRamps.js +10 -0
- package/dist/cjs/types/recovery.js +12 -0
- package/dist/cjs/types/wallet.js +9 -0
- package/dist/cjs/utils/events.js +9 -0
- package/dist/cjs/utils/{formattingUtils.js → formatting.js} +11 -1
- package/dist/cjs/utils/index.js +22 -0
- package/dist/cjs/utils/onRamps.js +36 -0
- package/dist/cjs/utils/url.js +74 -0
- package/dist/cjs/utils/wallet.js +74 -0
- package/dist/esm/ParaCore.js +89 -166
- package/dist/esm/constants.js +17 -0
- package/dist/esm/cryptography/utils.js +1 -1
- package/dist/esm/external/userManagementClient.js +1 -1
- package/dist/esm/index.js +12 -8
- package/dist/esm/types/config.js +19 -0
- package/dist/esm/types/index.js +6 -2
- package/dist/esm/types/onRamps.js +7 -0
- package/dist/esm/types/recovery.js +9 -0
- package/dist/esm/types/wallet.js +6 -0
- package/dist/esm/utils/events.js +5 -0
- package/dist/esm/utils/{formattingUtils.js → formatting.js} +8 -0
- package/dist/esm/utils/index.js +6 -0
- package/dist/esm/utils/onRamps.js +30 -0
- package/dist/esm/utils/url.js +66 -0
- package/dist/esm/utils/wallet.js +64 -0
- package/dist/types/ParaCore.d.ts +12 -168
- package/dist/types/PlatformUtils.d.ts +1 -3
- package/dist/types/constants.d.ts +17 -0
- package/dist/types/cryptography/utils.d.ts +1 -1
- package/dist/types/external/userManagementClient.d.ts +1 -1
- package/dist/types/index.d.ts +12 -10
- package/dist/types/shares/recovery.d.ts +1 -1
- package/dist/types/shares/shareDistribution.d.ts +1 -1
- package/dist/types/types/config.d.ts +162 -0
- package/dist/types/types/events.d.ts +10 -10
- package/dist/types/types/index.d.ts +6 -2
- package/dist/types/types/onRamps.d.ts +10 -0
- package/dist/types/types/recovery.d.ts +7 -0
- package/dist/types/types/wallet.d.ts +39 -0
- package/dist/types/utils/events.d.ts +2 -0
- package/dist/types/utils/{formattingUtils.d.ts → formatting.d.ts} +3 -1
- package/dist/types/utils/index.d.ts +6 -0
- package/dist/types/utils/onRamps.d.ts +12 -0
- package/dist/types/utils/url.d.ts +15 -0
- package/dist/types/utils/wallet.d.ts +10 -0
- package/package.json +3 -3
- package/dist/cjs/definitions.js +0 -153
- package/dist/cjs/types/walletTypes.js +0 -2
- package/dist/esm/definitions.js +0 -140
- package/dist/esm/types/walletTypes.js +0 -1
- package/dist/types/definitions.d.ts +0 -86
- package/dist/types/types/walletTypes.d.ts +0 -11
- /package/dist/cjs/types/{popupTypes.js → popup.js} +0 -0
- /package/dist/cjs/utils/{pollingUtils.js → polling.js} +0 -0
- /package/dist/esm/types/{popupTypes.js → popup.js} +0 -0
- /package/dist/esm/utils/{pollingUtils.js → polling.js} +0 -0
- /package/dist/types/types/{popupTypes.d.ts → popup.d.ts} +0 -0
- /package/dist/types/utils/{pollingUtils.d.ts → polling.d.ts} +0 -0
|
@@ -2,6 +2,7 @@ import { toBech32 } from '@cosmjs/encoding';
|
|
|
2
2
|
import { sha256 } from '@noble/hashes/sha256';
|
|
3
3
|
import { ripemd160 } from '@noble/hashes/ripemd160';
|
|
4
4
|
import elliptic from 'elliptic';
|
|
5
|
+
import parsePhoneNumberFromString from 'libphonenumber-js';
|
|
5
6
|
const secp256k1 = new elliptic.ec('secp256k1');
|
|
6
7
|
export function hexStringToBase64(hexString) {
|
|
7
8
|
if (hexString.substring(0, 2) === '0x') {
|
|
@@ -56,3 +57,10 @@ export function truncateAddress(str, addressType, { prefix = addressType === 'CO
|
|
|
56
57
|
const headLength = (addressType === 'COSMOS' ? prefix.length : addressType === 'SOLANA' ? 0 : 2) + 4;
|
|
57
58
|
return `${str.slice(0, headLength)}...${str.slice(-4)}`;
|
|
58
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
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
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
|
+
}
|
package/dist/types/ParaCore.d.ts
CHANGED
|
@@ -1,170 +1,8 @@
|
|
|
1
|
-
import Client, { AuthMethod,
|
|
1
|
+
import Client, { AuthMethod, BackupKitEmailProps, CurrentWalletIds, EmailTheme, WalletEntity, WalletType, WalletParams, OAuthMethod, OnRampPurchaseCreateParams, OnRampPurchase, TPregenIdentifierType, PregenIds, BiometricLocationHint, TelegramAuthResponse, VerifyTelegramRes, Auth } from '@getpara/user-management-client';
|
|
2
2
|
import type { pki as pkiType } from 'node-forge';
|
|
3
|
-
import { Ctx, Environment, WalletFilters, WalletTypeProp } from './
|
|
4
|
-
import { Theme, FullSignatureRes, EmbeddedWalletType, ExternalWalletType, ExternalWalletInfo, GetWebAuthUrlForLoginParams, AccountSetupResp, LoginResp } from './types/index.js';
|
|
3
|
+
import { Ctx, Environment, Theme, FullSignatureRes, ExternalWalletInfo, GetWebAuthUrlForLoginParams, AccountSetupResponse, LoginResponse, WalletFilters, WalletTypeProp, Wallet, SupportedWalletTypes, PortalUrlOptions, ConstructorOpts, RecoveryStatus } from './types/index.js';
|
|
5
4
|
import { PlatformUtils } from './PlatformUtils.js';
|
|
6
5
|
import { CountryCallingCode } from 'libphonenumber-js';
|
|
7
|
-
export declare function entityToWallet(w: WalletEntity): Omit<Wallet, 'signer'>;
|
|
8
|
-
export type SupportedWalletTypeConfig = {
|
|
9
|
-
optional?: boolean;
|
|
10
|
-
};
|
|
11
|
-
export type deprecated__SupportedWalletTypesOpt = {
|
|
12
|
-
[WalletType.EVM]?: boolean | SupportedWalletTypeConfig;
|
|
13
|
-
[WalletType.SOLANA]?: boolean | SupportedWalletTypeConfig;
|
|
14
|
-
[WalletType.COSMOS]?: boolean | (SupportedWalletTypeConfig & {
|
|
15
|
-
prefix?: string;
|
|
16
|
-
});
|
|
17
|
-
};
|
|
18
|
-
export type SupportedWalletTypes = {
|
|
19
|
-
type: WalletType;
|
|
20
|
-
optional?: boolean;
|
|
21
|
-
}[];
|
|
22
|
-
export declare enum RecoveryStatus {
|
|
23
|
-
INITIATED = "INITIATED",
|
|
24
|
-
READY = "READY",
|
|
25
|
-
EXPIRED = "EXPIRED",
|
|
26
|
-
FINISHED = "FINISHED",
|
|
27
|
-
CANCELLED = "CANCELLED"
|
|
28
|
-
}
|
|
29
|
-
/** @deprecated */
|
|
30
|
-
export declare enum PregenIdentifierType {
|
|
31
|
-
EMAIL = "EMAIL",
|
|
32
|
-
PHONE = "PHONE"
|
|
33
|
-
}
|
|
34
|
-
export interface Wallet {
|
|
35
|
-
createdAt?: string;
|
|
36
|
-
id: string;
|
|
37
|
-
name?: string;
|
|
38
|
-
signer: string;
|
|
39
|
-
address?: string;
|
|
40
|
-
addressSecondary?: string;
|
|
41
|
-
publicKey?: string;
|
|
42
|
-
scheme?: WalletScheme;
|
|
43
|
-
type?: EmbeddedWalletType | ExternalWalletType;
|
|
44
|
-
isPregen?: boolean;
|
|
45
|
-
pregenIdentifier?: string;
|
|
46
|
-
pregenIdentifierType?: TPregenIdentifierType;
|
|
47
|
-
userId?: string;
|
|
48
|
-
partnerId?: string;
|
|
49
|
-
partner?: PartnerEntity;
|
|
50
|
-
lastUsedAt?: string;
|
|
51
|
-
lastUsedPartner?: PartnerEntity;
|
|
52
|
-
lastUsedPartnerId?: string;
|
|
53
|
-
isExternal?: boolean;
|
|
54
|
-
}
|
|
55
|
-
export interface ConstructorOpts {
|
|
56
|
-
useStorageOverrides?: boolean;
|
|
57
|
-
disableWorkers?: boolean;
|
|
58
|
-
offloadMPCComputationURL?: string;
|
|
59
|
-
useLocalFiles?: boolean;
|
|
60
|
-
localStorageGetItemOverride?: (key: string) => Promise<string | null>;
|
|
61
|
-
localStorageSetItemOverride?: (key: string, value: string) => Promise<void>;
|
|
62
|
-
sessionStorageGetItemOverride?: (key: string) => Promise<string | null>;
|
|
63
|
-
sessionStorageSetItemOverride?: (key: string, value: string) => Promise<void>;
|
|
64
|
-
sessionStorageRemoveItemOverride?: (key: string) => Promise<void>;
|
|
65
|
-
clearStorageOverride?: () => Promise<void>;
|
|
66
|
-
/**
|
|
67
|
-
* Hex color to use in the portal for the background color.
|
|
68
|
-
* @deprecated use portalTheme instead
|
|
69
|
-
*/
|
|
70
|
-
portalBackgroundColor?: string;
|
|
71
|
-
/**
|
|
72
|
-
* Hex color to use in the portal for the primary button.
|
|
73
|
-
* @deprecated use portalTheme instead
|
|
74
|
-
*/
|
|
75
|
-
portalPrimaryButtonColor?: string;
|
|
76
|
-
/**
|
|
77
|
-
* Hex text color to use in the portal.
|
|
78
|
-
* @deprecated use portalTheme instead
|
|
79
|
-
*/
|
|
80
|
-
portalTextColor?: string;
|
|
81
|
-
/**
|
|
82
|
-
* Hex color to use in the portal for the primary button text.
|
|
83
|
-
* @deprecated use portalTheme instead
|
|
84
|
-
*/
|
|
85
|
-
portalPrimaryButtonTextColor?: string;
|
|
86
|
-
/**
|
|
87
|
-
* Theme to use for the portal
|
|
88
|
-
* @deprecated configure theming through the developer portal
|
|
89
|
-
*/
|
|
90
|
-
portalTheme?: Theme;
|
|
91
|
-
useDKLSForCreation?: boolean;
|
|
92
|
-
disableWebSockets?: boolean;
|
|
93
|
-
wasmOverride?: ArrayBuffer;
|
|
94
|
-
/**
|
|
95
|
-
* Base theme for the emails sent from this Para instance.
|
|
96
|
-
* @default - dark
|
|
97
|
-
* @deprecated configure theming through the developer portal
|
|
98
|
-
*/
|
|
99
|
-
emailTheme?: EmailTheme;
|
|
100
|
-
/**
|
|
101
|
-
* Hex color to use as the primary color in the emails.
|
|
102
|
-
* @default - #FE452B
|
|
103
|
-
* @deprecated configure theming through the developer portal
|
|
104
|
-
*/
|
|
105
|
-
emailPrimaryColor?: string;
|
|
106
|
-
/**
|
|
107
|
-
* Linkedin URL to link to in the emails. Should be a secure URL string starting with https://www.linkedin.com/company/.
|
|
108
|
-
* @deprecated configure this through the developer portal
|
|
109
|
-
*/
|
|
110
|
-
linkedinUrl?: string;
|
|
111
|
-
/**
|
|
112
|
-
* Github URL to link to in the emails. Should be a secure URL string starting with https://github.com/.
|
|
113
|
-
* @deprecated configure this through the developer portal
|
|
114
|
-
*/
|
|
115
|
-
githubUrl?: string;
|
|
116
|
-
/**
|
|
117
|
-
* X (Twitter) URL to link to in the emails. Should be a secure URL string starting with https://twitter.com/.
|
|
118
|
-
* @deprecated configure this through the developer portal
|
|
119
|
-
*/
|
|
120
|
-
xUrl?: string;
|
|
121
|
-
/**
|
|
122
|
-
* Support URL to link to in the emails. This can be a secure https URL or a mailto: string. Will default to using the stored application URL is nothing is provided here.
|
|
123
|
-
* @deprecated homepageUrl will be used for this, configure it through the developer portal
|
|
124
|
-
*/
|
|
125
|
-
supportUrl?: string;
|
|
126
|
-
/**
|
|
127
|
-
* URL for your home landing page. Should be a secure URL string starting with https://.
|
|
128
|
-
* @deprecated configure this through the developer portal
|
|
129
|
-
*/
|
|
130
|
-
homepageUrl?: string;
|
|
131
|
-
/**
|
|
132
|
-
* Which type of wallet your application supports, in the form `{ [WalletType]: true }`. Currently allowed values for `WalletType` are `'EVM'`, `'SOLANA'`, or `'COSMOS'`.
|
|
133
|
-
*
|
|
134
|
-
* To specify which prefix to use for new Cosmos wallets, pass `{ COSMOS: { prefix: 'your-prefix' } }`. Defaults to `'cosmos'`.
|
|
135
|
-
* @deprecated Configure your app's supported wallet types in the Para Developer Portal.
|
|
136
|
-
*/
|
|
137
|
-
supportedWalletTypes?: deprecated__SupportedWalletTypesOpt;
|
|
138
|
-
/**
|
|
139
|
-
* If `true`, the SDK will use the device's temporary session storage instead of saving user and wallet data to local storage.
|
|
140
|
-
*/
|
|
141
|
-
useSessionStorage?: boolean;
|
|
142
|
-
/**
|
|
143
|
-
* Partner ID set in the Para Portal to track analytics for legacy SDK versions. This variable is unused outside of the Para Portal.
|
|
144
|
-
*/
|
|
145
|
-
portalPartnerId?: string;
|
|
146
|
-
}
|
|
147
|
-
type PortalUrlOptions = {
|
|
148
|
-
params?: Record<string, string | undefined | null>;
|
|
149
|
-
authType?: AuthType;
|
|
150
|
-
isForNewDevice?: boolean;
|
|
151
|
-
loginEncryptionPublicKey?: string;
|
|
152
|
-
newDeviceSessionId?: string;
|
|
153
|
-
newDeviceEncryptionKey?: string;
|
|
154
|
-
partnerId?: string;
|
|
155
|
-
sessionId?: string;
|
|
156
|
-
theme?: Theme;
|
|
157
|
-
pathId?: string;
|
|
158
|
-
displayName?: string;
|
|
159
|
-
pfpUrl?: string;
|
|
160
|
-
};
|
|
161
|
-
export declare const PREFIX = "@CAPSULE/";
|
|
162
|
-
export declare function stringToPhoneNumber(str: string): string;
|
|
163
|
-
export declare function normalizePhoneNumber(countryCode: string, number: string): string | undefined;
|
|
164
|
-
export declare function isWalletSupported(types: WalletType[], wallet: Omit<Wallet, 'signer'>): boolean;
|
|
165
|
-
export declare function getWalletTypes(schemes: WalletScheme[]): WalletType[];
|
|
166
|
-
export declare function getEquivalentTypes(types: WalletTypeProp[] | WalletTypeProp): WalletType[];
|
|
167
|
-
export declare function isCosmosRequired(supportedWalletTypes: SupportedWalletTypes): boolean;
|
|
168
6
|
export declare abstract class ParaCore {
|
|
169
7
|
#private;
|
|
170
8
|
static version?: string;
|
|
@@ -705,7 +543,7 @@ export declare abstract class ParaCore {
|
|
|
705
543
|
* Waits for the session to be active.
|
|
706
544
|
**/
|
|
707
545
|
waitForAccountCreation(): Promise<boolean>;
|
|
708
|
-
waitForPasskeyAndCreateWallet(): Promise<
|
|
546
|
+
waitForPasskeyAndCreateWallet(): Promise<AccountSetupResponse>;
|
|
709
547
|
/**
|
|
710
548
|
* Initiates a Farcaster login attempt and return the URI for the user to connect.
|
|
711
549
|
* You can create a QR code with this URI that works with Farcaster's mobile app.
|
|
@@ -727,10 +565,12 @@ export declare abstract class ParaCore {
|
|
|
727
565
|
*
|
|
728
566
|
* @param {Object} opts the options object
|
|
729
567
|
* @param {OAuthMethod} opts.method the third-party service to use for OAuth.
|
|
568
|
+
* @param {string} [opts.deeplinkUrl] the deeplink to redirect to after the OAuth flow. This is for mobile only.
|
|
730
569
|
* @returns {string} the URL for the user to log in with OAuth.
|
|
731
570
|
*/
|
|
732
|
-
getOAuthURL({ method }: {
|
|
571
|
+
getOAuthURL({ method, deeplinkUrl }: {
|
|
733
572
|
method: OAuthMethod;
|
|
573
|
+
deeplinkUrl?: string;
|
|
734
574
|
}): Promise<string>;
|
|
735
575
|
/**
|
|
736
576
|
* Awaits the response from a user's attempt to log in with OAuth.
|
|
@@ -758,7 +598,7 @@ export declare abstract class ParaCore {
|
|
|
758
598
|
waitForLoginAndSetup({ popupWindow, skipSessionRefresh, }?: {
|
|
759
599
|
popupWindow?: Window;
|
|
760
600
|
skipSessionRefresh?: boolean;
|
|
761
|
-
}): Promise<
|
|
601
|
+
}): Promise<LoginResponse>;
|
|
762
602
|
/**
|
|
763
603
|
* Updates the session with the user management server, possibly
|
|
764
604
|
* opening a popup to refresh the session.
|
|
@@ -1063,6 +903,11 @@ export declare abstract class ParaCore {
|
|
|
1063
903
|
protected exitFarcaster(): void;
|
|
1064
904
|
protected exitOAuth(): void;
|
|
1065
905
|
protected exitLoops(): void;
|
|
906
|
+
/**
|
|
907
|
+
* Retrieves a token to verify the current session.
|
|
908
|
+
* @returns {Promise<string>} the ID
|
|
909
|
+
**/
|
|
910
|
+
getVerificationToken(): Promise<string>;
|
|
1066
911
|
/**
|
|
1067
912
|
* Logs the user out.
|
|
1068
913
|
* @param {Object} opts the options object.
|
|
@@ -1079,4 +924,3 @@ export declare abstract class ParaCore {
|
|
|
1079
924
|
**/
|
|
1080
925
|
toString(): string;
|
|
1081
926
|
}
|
|
1082
|
-
export {};
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { BackupKitEmailProps, TPregenIdentifierType, WalletType } from '@getpara/user-management-client';
|
|
3
|
-
import { Ctx } from './
|
|
4
|
-
import { SignatureRes } from './types/walletTypes.js';
|
|
3
|
+
import { Ctx, PopupType, SignatureRes } from './types/index.js';
|
|
5
4
|
import { StorageUtils } from './StorageUtils.js';
|
|
6
|
-
import { PopupType } from './types/popupTypes.js';
|
|
7
5
|
export interface PlatformUtils {
|
|
8
6
|
getPrivateKey(ctx: Ctx, userId: string, walletId: string, share: string, sessionCookie: string): Promise<string>;
|
|
9
7
|
keygen(ctx: Ctx, userId: string, type: Exclude<WalletType, WalletType.SOLANA>, secretKey: string | null, // should be acceptable as null in RN as we don't pre-gen them
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export declare const PARA_CORE_VERSION: string;
|
|
2
|
+
export declare const PREFIX = "@CAPSULE/";
|
|
3
|
+
export declare const LOCAL_STORAGE_EMAIL: string;
|
|
4
|
+
export declare const LOCAL_STORAGE_PHONE: string;
|
|
5
|
+
export declare const LOCAL_STORAGE_COUNTRY_CODE: string;
|
|
6
|
+
export declare const LOCAL_STORAGE_FARCASTER_USERNAME: string;
|
|
7
|
+
export declare const LOCAL_STORAGE_TELEGRAM_USER_ID: string;
|
|
8
|
+
export declare const LOCAL_STORAGE_USER_ID: string;
|
|
9
|
+
export declare const LOCAL_STORAGE_ED25519_WALLETS: string;
|
|
10
|
+
export declare const LOCAL_STORAGE_WALLETS: string;
|
|
11
|
+
export declare const LOCAL_STORAGE_EXTERNAL_WALLETS: string;
|
|
12
|
+
export declare const LOCAL_STORAGE_CURRENT_WALLET_IDS: string;
|
|
13
|
+
export declare const LOCAL_STORAGE_CURRENT_EXTERNAL_WALLET_ADDRESSES: string;
|
|
14
|
+
export declare const LOCAL_STORAGE_SESSION_COOKIE: string;
|
|
15
|
+
export declare const SESSION_STORAGE_LOGIN_ENCRYPTION_KEY_PAIR: string;
|
|
16
|
+
export declare const POLLING_INTERVAL_MS = 2000;
|
|
17
|
+
export declare const SHORT_POLLING_INTERVAL_MS = 1000;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Client from '@getpara/user-management-client';
|
|
2
|
-
import { Environment } from '../
|
|
2
|
+
import { Environment } from '../types/index.js';
|
|
3
3
|
export declare function getBaseOAuthUrl(env: Environment): string;
|
|
4
4
|
export declare function getBaseUrl(env: Environment): string;
|
|
5
5
|
export declare function getBaseMPCNetworkUrl(env: Environment, useWebsocket?: boolean): string;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,22 +1,24 @@
|
|
|
1
|
-
import { ParaCore
|
|
2
|
-
export { AuthMethod, type CurrentWalletIds, EmailTheme, type PartnerEntity, type WalletEntity, WalletType, WalletScheme, OnRampPurchaseType, type OnRampConfig, type OnRampAllowedAssets, OAuthMethod, type TPregenIdentifierType, type PregenIds, NON_ED25519, PREGEN_IDENTIFIER_TYPES, } from '@getpara/user-management-client';
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export * from './types/
|
|
1
|
+
import { ParaCore } from './ParaCore.js';
|
|
2
|
+
export { AuthMethod, type CurrentWalletIds, EmailTheme, type PartnerEntity, type WalletEntity, Network, WalletType, WalletScheme, OnRampAsset, OnRampPurchaseType, OnRampProvider, OnRampPurchaseStatus, type OnRampConfig, type OnRampAllowedAssets, type OnRampPurchase, OAuthMethod, type TPregenIdentifierType, type PregenIds, NON_ED25519, PREGEN_IDENTIFIER_TYPES, } from '@getpara/user-management-client';
|
|
3
|
+
export { OnRampMethod, PopupType, PregenIdentifierType, RecoveryStatus, type ProviderAssetInfo, type SignatureRes, type FullSignatureRes, type SuccessfulSignatureRes, type DeniedSignatureRes, type DeniedSignatureResWithUrl, type OnRampAssetInfo, type Theme, type Wallet, } from './types/index.js';
|
|
4
|
+
export * from './types/events.js';
|
|
5
|
+
export * from './types/config.js';
|
|
6
|
+
export { getPortalDomain, stringToPhoneNumber, entityToWallet } from './utils/index.js';
|
|
7
|
+
export { PREFIX as STORAGE_PREFIX } from './constants.js';
|
|
6
8
|
export { distributeNewShare } from './shares/shareDistribution.js';
|
|
7
9
|
export { KeyContainer } from './shares/KeyContainer.js';
|
|
8
|
-
export { RecoveryStatus, stringToPhoneNumber, entityToWallet } from './ParaCore.js';
|
|
9
|
-
export type { Wallet, ConstructorOpts, SupportedWalletTypes } from './ParaCore.js';
|
|
10
10
|
export type { PlatformUtils } from './PlatformUtils.js';
|
|
11
11
|
export type { StorageUtils } from './StorageUtils.js';
|
|
12
12
|
export { getBaseUrl, initClient } from './external/userManagementClient.js';
|
|
13
13
|
export * as mpcComputationClient from './external/mpcComputationClient.js';
|
|
14
14
|
export { decryptWithKeyPair, decryptWithPrivateKey, getAsymmetricKeyPair, getPublicKeyHex, encryptWithDerivedPublicKey, encodePrivateKeyToPemHex, getDerivedPrivateKeyAndDecrypt, getPublicKeyFromSignature, getSHA256HashHex, encryptPrivateKey, decryptPrivateKey, decryptPrivateKeyAndDecryptShare, hashPasswordWithSalt, encryptPrivateKeyWithPassword, decryptPrivateKeyWithPassword, publicKeyFromHex, } from './cryptography/utils.js';
|
|
15
15
|
export * from './external/userManagementClient.js';
|
|
16
|
-
export * from './utils/pollingUtils.js';
|
|
17
16
|
export * from './errors.js';
|
|
18
|
-
export * from './utils/
|
|
17
|
+
export * from './utils/formatting.js';
|
|
18
|
+
export * from './utils/polling.js';
|
|
19
|
+
export { isWalletSupported } from './utils/wallet.js';
|
|
20
|
+
export { getOnRampAssets, getOnRampNetworks, toAssetInfoArray } from './utils/onRamps.js';
|
|
21
|
+
export { getPortalBaseURL } from './utils/url.js';
|
|
19
22
|
export { retrieve as transmissionUtilsRetrieve } from './transmission/transmissionUtils.js';
|
|
20
|
-
export { STORAGE_PREFIX, PregenIdentifierType, isWalletSupported };
|
|
21
23
|
export declare const paraVersion: string;
|
|
22
24
|
export default ParaCore;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BackupKitEmailProps, EncryptedKeyShare } from '@getpara/user-management-client';
|
|
2
|
-
import { Ctx } from '../
|
|
2
|
+
import { Ctx } from '../types/index.js';
|
|
3
3
|
export declare function sendRecoveryForShare({ ctx, userId, walletId, otherEncryptedShares, userSigner, ignoreRedistributingBackupEncryptedShare, emailProps, forceRefresh, }: {
|
|
4
4
|
ctx: Ctx;
|
|
5
5
|
userId: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BackupKitEmailProps } from '@getpara/user-management-client';
|
|
2
|
-
import { Ctx } from '../
|
|
2
|
+
import { Ctx } from '../types/index.js';
|
|
3
3
|
export declare function distributeNewShare({ ctx, userId, walletId, userShare, ignoreRedistributingBackupEncryptedShare, emailProps, partnerId, protocolId, }: {
|
|
4
4
|
ctx: Ctx;
|
|
5
5
|
userId: string;
|