@getpara/core-sdk 2.0.0-alpha.7 → 2.0.0-alpha.70
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 +1516 -382
- package/dist/cjs/constants.js +13 -1
- package/dist/cjs/index.js +35 -3
- package/dist/cjs/shares/KeyContainer.js +3 -3
- package/dist/cjs/shares/enclave.js +266 -0
- package/dist/cjs/shares/shareDistribution.js +16 -1
- package/dist/cjs/transmission/transmissionUtils.js +4 -3
- package/dist/cjs/types/{theme.js → assets.js} +2 -2
- package/dist/cjs/types/{onRamps.js → auth.js} +12 -12
- package/dist/cjs/types/coreApi.js +23 -3
- package/dist/cjs/types/events.js +2 -0
- package/dist/cjs/types/index.js +2 -21
- package/dist/cjs/types/popup.js +1 -0
- package/dist/cjs/utils/config.js +108 -0
- package/dist/cjs/utils/formatting.js +4 -0
- package/dist/cjs/utils/index.js +5 -1
- package/dist/cjs/utils/onRamps.js +2 -3
- package/dist/cjs/utils/wallet.js +18 -0
- package/dist/cjs/{types/recovery.js → utils/window.js} +17 -13
- package/dist/esm/ParaCore.js +1525 -388
- package/dist/esm/constants.js +9 -1
- package/dist/esm/index.js +36 -5
- package/dist/esm/shares/KeyContainer.js +3 -3
- package/dist/esm/shares/enclave.js +226 -0
- package/dist/esm/shares/shareDistribution.js +16 -1
- package/dist/esm/transmission/transmissionUtils.js +4 -3
- package/dist/esm/types/auth.js +11 -0
- package/dist/esm/types/coreApi.js +21 -2
- package/dist/esm/types/events.js +2 -0
- package/dist/esm/types/index.js +1 -16
- package/dist/esm/types/popup.js +1 -0
- package/dist/esm/utils/config.js +86 -0
- package/dist/esm/utils/formatting.js +2 -0
- package/dist/esm/utils/index.js +2 -0
- package/dist/esm/utils/onRamps.js +2 -3
- package/dist/esm/utils/wallet.js +17 -0
- package/dist/esm/utils/window.js +16 -0
- package/dist/types/ParaCore.d.ts +142 -57
- package/dist/types/PlatformUtils.d.ts +2 -3
- package/dist/types/constants.d.ts +18 -14
- package/dist/types/index.d.ts +6 -4
- package/dist/types/shares/KeyContainer.d.ts +0 -2
- package/dist/types/shares/enclave.d.ts +81 -0
- package/dist/types/shares/shareDistribution.d.ts +4 -2
- package/dist/types/types/assets.d.ts +14 -0
- package/dist/types/types/auth.d.ts +16 -0
- package/dist/types/types/config.d.ts +11 -2
- package/dist/types/types/coreApi.d.ts +133 -37
- package/dist/types/types/events.d.ts +7 -2
- package/dist/types/types/index.d.ts +1 -4
- package/dist/types/types/methods.d.ts +94 -15
- package/dist/types/types/popup.d.ts +2 -1
- package/dist/types/types/wallet.d.ts +11 -4
- package/dist/types/utils/config.d.ts +7 -0
- package/dist/types/utils/formatting.d.ts +2 -0
- package/dist/types/utils/index.d.ts +2 -0
- package/dist/types/utils/onRamps.d.ts +9 -10
- package/dist/types/utils/wallet.d.ts +1 -0
- package/dist/types/utils/window.d.ts +2 -0
- package/package.json +23 -23
- package/dist/esm/types/onRamps.js +0 -11
- package/dist/esm/types/recovery.js +0 -12
- package/dist/types/types/onRamps.d.ts +0 -10
- package/dist/types/types/recovery.d.ts +0 -7
- package/dist/types/types/theme.d.ts +0 -12
- /package/dist/esm/types/{theme.js → assets.js} +0 -0
package/dist/esm/utils/wallet.js
CHANGED
|
@@ -59,7 +59,10 @@ function getEquivalentTypes(types) {
|
|
|
59
59
|
return getWalletTypes(getSchemes(Array.isArray(types) ? types : [types]));
|
|
60
60
|
}
|
|
61
61
|
function entityToWallet(w) {
|
|
62
|
+
var _a;
|
|
62
63
|
return __spreadProps(__spreadValues({}, w), {
|
|
64
|
+
createdAt: typeof w.createdAt === "string" ? w.createdAt : w.createdAt.toISOString(),
|
|
65
|
+
lastUsedAt: typeof w.lastUsedAt === "string" ? w.lastUsedAt : (_a = w.lastUsedAt) == null ? void 0 : _a.toISOString(),
|
|
63
66
|
scheme: w.scheme,
|
|
64
67
|
type: w.type,
|
|
65
68
|
pregenIdentifierType: w.pregenIdentifierType
|
|
@@ -88,8 +91,22 @@ function mergeCurrentWalletIds(original, additional) {
|
|
|
88
91
|
function newUuid() {
|
|
89
92
|
return uuid.v4();
|
|
90
93
|
}
|
|
94
|
+
function currentWalletIdsEq(a, b) {
|
|
95
|
+
if (!a && !b) return true;
|
|
96
|
+
if (!a || !b) return false;
|
|
97
|
+
const aKeys = Object.keys(a);
|
|
98
|
+
const bKeys = Object.keys(b);
|
|
99
|
+
if (aKeys.length !== bKeys.length) return false;
|
|
100
|
+
return aKeys.every((key) => {
|
|
101
|
+
var _a, _b;
|
|
102
|
+
const aIds = ((_a = a[key]) == null ? void 0 : _a.sort()) || [];
|
|
103
|
+
const bIds = ((_b = b[key]) == null ? void 0 : _b.sort()) || [];
|
|
104
|
+
return aIds.length === bIds.length && aIds.every((id, index) => id === bIds[index]);
|
|
105
|
+
});
|
|
106
|
+
}
|
|
91
107
|
export {
|
|
92
108
|
WalletSchemeTypeMap,
|
|
109
|
+
currentWalletIdsEq,
|
|
93
110
|
entityToWallet,
|
|
94
111
|
getEquivalentTypes,
|
|
95
112
|
getSchemes,
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import "../chunk-7B52C2XE.js";
|
|
2
|
+
import { getPortalBaseURL } from "./url.js";
|
|
3
|
+
function isPortal(ctx, env) {
|
|
4
|
+
var _a, _b;
|
|
5
|
+
if (typeof window === "undefined") return false;
|
|
6
|
+
const normalizedUrl = (_b = (_a = window.location) == null ? void 0 : _a.host) == null ? void 0 : _b.replace("getpara", "usecapsule");
|
|
7
|
+
const isOnPortalDomain = getPortalBaseURL(env ? { env } : ctx).includes(normalizedUrl);
|
|
8
|
+
if (!isOnPortalDomain) return false;
|
|
9
|
+
const isInIframe = window.parent !== window && !window.opener;
|
|
10
|
+
const isInPopup = window.opener && window.parent === window;
|
|
11
|
+
const isDirectAccess = window.parent === window && !window.opener;
|
|
12
|
+
return isInIframe || isInPopup || isDirectAccess;
|
|
13
|
+
}
|
|
14
|
+
export {
|
|
15
|
+
isPortal
|
|
16
|
+
};
|
package/dist/types/ParaCore.d.ts
CHANGED
|
@@ -1,12 +1,17 @@
|
|
|
1
|
-
import { AuthMethod, AuthExtras, CurrentWalletIds, EmailTheme, TWalletType, PregenIds, BiometricLocationHint, Auth, SupportedWalletTypes, AuthIdentifier, AuthType, ExternalWalletInfo, PrimaryAuthInfo, SessionInfo, PrimaryAuth, PrimaryAuthType, AccountMetadata } from '@getpara/user-management-client';
|
|
1
|
+
import { AuthMethod, AuthExtras, CurrentWalletIds, EmailTheme, PartnerEntity, TWalletType, PregenIds, BiometricLocationHint, Auth, SupportedWalletTypes, AuthIdentifier, AuthType, ExternalWalletInfo, ServerAuthStateLogin, ServerAuthStateSignup, PrimaryAuthInfo, SessionInfo, PrimaryAuth, PrimaryAuthType, AccountMetadata, LinkedAccounts, VerifyLinkParams, VerifyExternalWalletParams, SupportedAccountLinks, OnRampPurchase, BalancesConfig, Theme, ServerAuthStateDone } from '@getpara/user-management-client';
|
|
2
2
|
import type { pki as pkiType } from 'node-forge';
|
|
3
|
-
import { Ctx, Environment,
|
|
3
|
+
import { Ctx, Environment, WalletFilters, Wallet, PortalUrlOptions, ConstructorOpts, CoreAuthInfo, PortalUrlType, CoreMethodParams, CoreMethodResponse, NewCredentialUrlParams, LoginUrlParams, CoreInterface, ExternalWalletConnectionType, AccountLinkInProgress, InternalMethodParams, InternalMethodResponse, AvailableWallet } from './types/index.js';
|
|
4
4
|
import { PlatformUtils } from './PlatformUtils.js';
|
|
5
5
|
export declare abstract class ParaCore implements CoreInterface {
|
|
6
6
|
#private;
|
|
7
|
+
popupWindow: Window | null;
|
|
7
8
|
static version?: string;
|
|
8
9
|
ctx: Ctx;
|
|
10
|
+
protected isSwitchingWallets: boolean;
|
|
9
11
|
protected isNativePasskey: boolean;
|
|
12
|
+
protected isPartnerOptional?: boolean;
|
|
13
|
+
protected setModalError(_error?: string): void;
|
|
14
|
+
isReady: boolean;
|
|
10
15
|
get authInfo(): CoreAuthInfo | undefined;
|
|
11
16
|
get email(): AuthIdentifier<'email'> | undefined;
|
|
12
17
|
get phone(): AuthIdentifier<'phone'> | undefined;
|
|
@@ -14,18 +19,27 @@ export declare abstract class ParaCore implements CoreInterface {
|
|
|
14
19
|
get telegramUserId(): AuthIdentifier<'telegram'> | undefined;
|
|
15
20
|
get externalWalletWithParaAuth(): Wallet | undefined;
|
|
16
21
|
get externalWalletConnectionType(): ExternalWalletConnectionType;
|
|
22
|
+
protected partner?: PartnerEntity;
|
|
17
23
|
userId?: string;
|
|
24
|
+
accountLinkInProgress: AccountLinkInProgress | undefined;
|
|
18
25
|
private sessionCookie?;
|
|
26
|
+
isEnclaveUser: boolean;
|
|
27
|
+
private enclaveJwt?;
|
|
28
|
+
private enclaveRefreshJwt?;
|
|
19
29
|
private isAwaitingAccountCreation;
|
|
20
30
|
private isAwaitingLogin;
|
|
21
31
|
private isAwaitingFarcaster;
|
|
22
32
|
private isAwaitingOAuth;
|
|
33
|
+
private isWorkerInitialized;
|
|
23
34
|
get isEmail(): boolean;
|
|
24
35
|
get isPhone(): boolean;
|
|
25
36
|
get isFarcaster(): boolean;
|
|
26
37
|
get isTelegram(): boolean;
|
|
27
38
|
get isExternalWalletAuth(): boolean;
|
|
39
|
+
get isExternalWalletWithVerification(): boolean;
|
|
28
40
|
get partnerId(): string | undefined;
|
|
41
|
+
protected get partnerName(): string | undefined;
|
|
42
|
+
protected get partnerLogo(): string | undefined;
|
|
29
43
|
/**
|
|
30
44
|
* The IDs of the currently active wallets, for each supported wallet type. Any signer integrations will default to the first viable wallet ID in this dictionary.
|
|
31
45
|
*/
|
|
@@ -111,7 +125,7 @@ export declare abstract class ParaCore implements CoreInterface {
|
|
|
111
125
|
portalPrimaryButtonTextColor?: string;
|
|
112
126
|
/**
|
|
113
127
|
* Theme to use for the portal
|
|
114
|
-
*
|
|
128
|
+
* WARNING: This theme will override portal options set within the developer portal.
|
|
115
129
|
*/
|
|
116
130
|
portalTheme?: Theme;
|
|
117
131
|
/**
|
|
@@ -119,11 +133,18 @@ export declare abstract class ParaCore implements CoreInterface {
|
|
|
119
133
|
*/
|
|
120
134
|
externalWalletConnectionOnly?: boolean;
|
|
121
135
|
private disableProviderModal?;
|
|
136
|
+
private fetchPregenWalletsOverride?;
|
|
122
137
|
get isNoWalletConfig(): boolean;
|
|
123
138
|
get supportedWalletTypes(): SupportedWalletTypes;
|
|
124
139
|
get cosmosPrefix(): string | undefined;
|
|
140
|
+
get supportedAccountLinks(): SupportedAccountLinks;
|
|
125
141
|
get isWalletTypeEnabled(): Partial<Record<TWalletType, boolean>>;
|
|
126
|
-
|
|
142
|
+
protected onRampPopup: {
|
|
143
|
+
window: Window;
|
|
144
|
+
onRampPurchase: OnRampPurchase;
|
|
145
|
+
} | undefined;
|
|
146
|
+
protected platformUtils: PlatformUtils;
|
|
147
|
+
protected nonPersistedStorageKeys: string[];
|
|
127
148
|
private localStorageGetItem;
|
|
128
149
|
private localStorageSetItem;
|
|
129
150
|
private localStorageRemoveItem;
|
|
@@ -132,14 +153,18 @@ export declare abstract class ParaCore implements CoreInterface {
|
|
|
132
153
|
private sessionStorageRemoveItem;
|
|
133
154
|
retrieveSessionCookie: () => string | undefined;
|
|
134
155
|
persistSessionCookie: (cookie: string) => void;
|
|
156
|
+
retrieveEnclaveJwt: () => string;
|
|
157
|
+
persistEnclaveJwt: (jwt: string) => void;
|
|
158
|
+
retrieveEnclaveRefreshJwt: () => string;
|
|
159
|
+
persistEnclaveRefreshJwt: (jwt: string) => void;
|
|
135
160
|
/**
|
|
136
161
|
* Remove all local storage and prefixed session storage.
|
|
137
162
|
* @param {'local' | 'session' | 'secure' | 'all'} type - Type of storage to clear. Defaults to 'all'.
|
|
138
163
|
*/
|
|
139
|
-
clearStorage: (type?: CoreMethodParams<
|
|
164
|
+
clearStorage: (type?: CoreMethodParams<"clearStorage">) => CoreMethodResponse<"clearStorage">;
|
|
140
165
|
private convertBigInt;
|
|
141
166
|
private convertEncryptionKeyPair;
|
|
142
|
-
|
|
167
|
+
protected isPortal(envOverride?: Environment): boolean;
|
|
143
168
|
private isParaConnect;
|
|
144
169
|
private requireApiKey;
|
|
145
170
|
private isWalletSupported;
|
|
@@ -147,6 +172,7 @@ export declare abstract class ParaCore implements CoreInterface {
|
|
|
147
172
|
private isPregenWalletUnclaimed;
|
|
148
173
|
private isPregenWalletClaimable;
|
|
149
174
|
private isWalletUsable;
|
|
175
|
+
private truncateAddress;
|
|
150
176
|
/**
|
|
151
177
|
* Returns the formatted address for the desired wallet ID, depending on your app settings.
|
|
152
178
|
* @param {string} walletId the ID of the wallet address to display.
|
|
@@ -171,25 +197,30 @@ export declare abstract class ParaCore implements CoreInterface {
|
|
|
171
197
|
getWallets(): Record<string, Wallet>;
|
|
172
198
|
getAddress(walletId?: string): string | undefined;
|
|
173
199
|
protected abstract getPlatformUtils(): PlatformUtils;
|
|
200
|
+
abstract isPasskeySupported(): Promise<boolean>;
|
|
174
201
|
protected constructPortalUrl(type: PortalUrlType, opts?: PortalUrlOptions): Promise<string>;
|
|
202
|
+
static resolveEnvironment(env: Environment | undefined, apiKey: string | undefined): Environment;
|
|
175
203
|
/**
|
|
176
204
|
* Constructs a new `ParaCore` instance.
|
|
177
|
-
* @param env - `Environment` to use.
|
|
205
|
+
* @param env - `Environment` to use. Optional if the apiKey contains an environment prefix (e.g., "prod_your_api_key"). Updated API keys can be found at https://developer.getpara.com.
|
|
178
206
|
* @param apiKey - API key to use.
|
|
179
207
|
* @param opts - Additional constructor options; see `ConstructorOpts`.
|
|
180
208
|
* @returns - A new ParaCore instance.
|
|
181
209
|
*/
|
|
182
|
-
constructor(env: Environment, apiKey: string, opts?: ConstructorOpts);
|
|
210
|
+
constructor(env: Environment | undefined, apiKey: string, opts?: ConstructorOpts);
|
|
211
|
+
constructor(apiKey: string, opts?: ConstructorOpts);
|
|
183
212
|
private trackError;
|
|
184
213
|
private wrapMethodsWithErrorTracking;
|
|
185
214
|
private initializeFromStorage;
|
|
186
215
|
private updateAuthInfoFromStorage;
|
|
216
|
+
private updateEnclaveJwtFromStorage;
|
|
187
217
|
private updateUserIdFromStorage;
|
|
188
218
|
private updateWalletsFromStorage;
|
|
189
219
|
private updateWalletIdsFromStorage;
|
|
190
220
|
private updateSessionCookieFromStorage;
|
|
191
221
|
private updateLoginEncryptionKeyPairFromStorage;
|
|
192
222
|
private updateExternalWalletsFromStorage;
|
|
223
|
+
protected initializeWorker: () => Promise<void>;
|
|
193
224
|
touchSession(regenerate?: boolean): Promise<SessionInfo>;
|
|
194
225
|
private getVerificationEmailProps;
|
|
195
226
|
private getBackupKitEmailProps;
|
|
@@ -199,11 +230,29 @@ export declare abstract class ParaCore implements CoreInterface {
|
|
|
199
230
|
* Init only needs to be called for storage that is async.
|
|
200
231
|
*/
|
|
201
232
|
init(): Promise<void>;
|
|
233
|
+
/**
|
|
234
|
+
* Call this method to perform initial setup for the `ParaCore` instance.
|
|
235
|
+
*
|
|
236
|
+
* This method will be called automatically if you use the React `ParaProvider` or when you call any methods that request an updated session.
|
|
237
|
+
*/
|
|
238
|
+
abstract ready(): Promise<void>;
|
|
202
239
|
protected setAuth(auth: PrimaryAuth, { extras, userId }?: {
|
|
203
240
|
extras?: AuthExtras;
|
|
204
241
|
userId?: string;
|
|
205
242
|
}): Promise<typeof this.authInfo>;
|
|
206
|
-
|
|
243
|
+
/**
|
|
244
|
+
* Display an error message in the modal (if available)
|
|
245
|
+
* @internal
|
|
246
|
+
*/
|
|
247
|
+
protected displayModalError(error?: string): void;
|
|
248
|
+
/**
|
|
249
|
+
* Handle specific touchSession errors with user-friendly messages
|
|
250
|
+
* @private
|
|
251
|
+
*/
|
|
252
|
+
private handleTouchSessionError;
|
|
253
|
+
protected assertUserId({ allowGuestMode }?: {
|
|
254
|
+
allowGuestMode?: boolean;
|
|
255
|
+
}): string;
|
|
207
256
|
protected assertIsAuthSet(allowed?: AuthType[]): PrimaryAuthInfo;
|
|
208
257
|
/**
|
|
209
258
|
* Sets the email associated with the `ParaCore` instance.
|
|
@@ -231,7 +280,8 @@ export declare abstract class ParaCore implements CoreInterface {
|
|
|
231
280
|
* @param externalAddress - External wallet address to set.
|
|
232
281
|
* @param externalType - Type of external wallet to set.
|
|
233
282
|
*/
|
|
234
|
-
setExternalWallet(
|
|
283
|
+
setExternalWallet(externalWallet: ExternalWalletInfo[] | ExternalWalletInfo): Promise<void>;
|
|
284
|
+
protected addExternalWallets(externalWallets: ExternalWalletInfo[]): Promise<void>;
|
|
235
285
|
/**
|
|
236
286
|
* Sets the user id associated with the `ParaCore` instance.
|
|
237
287
|
* @param userId - User id to set.
|
|
@@ -244,9 +294,9 @@ export declare abstract class ParaCore implements CoreInterface {
|
|
|
244
294
|
setWallets(wallets: Record<string, Wallet>): Promise<void>;
|
|
245
295
|
/**
|
|
246
296
|
* Sets the external wallets associated with the `ParaCore` instance.
|
|
247
|
-
* @param externalWallets - External wallets to set.
|
|
297
|
+
* @param externalWallets - External wallets to set, or a function that modifies the current wallets.
|
|
248
298
|
*/
|
|
249
|
-
setExternalWallets(externalWallets: Record<string, Wallet>): Promise<void>;
|
|
299
|
+
setExternalWallets(externalWallets: Record<string, Wallet> | ((current: Record<string, Wallet>) => Record<string, Wallet>)): Promise<void>;
|
|
250
300
|
/**
|
|
251
301
|
* Sets the login encryption key pair associated with the `ParaCore` instance.
|
|
252
302
|
* @param keyPair - Encryption key pair generated from loginEncryptionKey.
|
|
@@ -282,6 +332,7 @@ export declare abstract class ParaCore implements CoreInterface {
|
|
|
282
332
|
/**
|
|
283
333
|
* Fetches the most recent OAuth account metadata for the signed-in user.
|
|
284
334
|
* If applicable, this will include the user's most recent metadata from their Google, Apple, Facebook, X, Discord, Farcaster, or Telegram account, the last time they signed in to your app.
|
|
335
|
+
* @deprecated use `para.getLinkedAccounts({ withMetadata: true })` instead.
|
|
285
336
|
* @returns {Promise<AccountMetadata>} the user's account metadata.
|
|
286
337
|
*/
|
|
287
338
|
getAccountMetadata(): Promise<AccountMetadata>;
|
|
@@ -302,7 +353,7 @@ export declare abstract class ParaCore implements CoreInterface {
|
|
|
302
353
|
*/
|
|
303
354
|
findWalletByAddress(address: string, filter?: WalletFilters | undefined): any;
|
|
304
355
|
findWallet(idOrAddress?: string, overrideType?: TWalletType, filter?: WalletFilters): Omit<Wallet, 'signer'> | undefined;
|
|
305
|
-
get availableWallets():
|
|
356
|
+
get availableWallets(): AvailableWallet[];
|
|
306
357
|
/**
|
|
307
358
|
* Retrieves all usable wallets with the provided type (`'EVM' | 'COSMOS' | 'SOLANA'`)
|
|
308
359
|
* @param {string} type the wallet type to filter by.
|
|
@@ -331,7 +382,7 @@ export declare abstract class ParaCore implements CoreInterface {
|
|
|
331
382
|
* @returns {WalletEntity[]} wallets that were fetched.
|
|
332
383
|
*/
|
|
333
384
|
fetchWallets(): CoreMethodResponse<'fetchWallets'>;
|
|
334
|
-
|
|
385
|
+
protected populateWalletAddresses(): Promise<void>;
|
|
335
386
|
private populatePregenWalletAddresses;
|
|
336
387
|
/**
|
|
337
388
|
* Logs in or creates a new user using an external wallet address.
|
|
@@ -340,15 +391,22 @@ export declare abstract class ParaCore implements CoreInterface {
|
|
|
340
391
|
* @param {TWalletType} opts.type type of external wallet to use for identification.
|
|
341
392
|
* @param {string} opts.provider the name of the provider for the external wallet.
|
|
342
393
|
*/
|
|
343
|
-
loginExternalWallet({ externalWallet, ...urlOptions }: CoreMethodParams<'loginExternalWallet'>): CoreMethodResponse<'loginExternalWallet'>;
|
|
344
|
-
verifyExternalWallet(
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
394
|
+
loginExternalWallet({ externalWallet, chainId, uri, ...urlOptions }: CoreMethodParams<'loginExternalWallet'>): CoreMethodResponse<'loginExternalWallet'>;
|
|
395
|
+
verifyExternalWallet(params: {
|
|
396
|
+
serverAuthState: ServerAuthStateSignup | ServerAuthStateLogin | ServerAuthStateDone;
|
|
397
|
+
} & Omit<CoreMethodParams<'verifyExternalWallet'>, keyof VerifyExternalWalletParams>): CoreMethodResponse<'verifyExternalWallet'>;
|
|
398
|
+
verifyExternalWallet(params: VerifyExternalWalletParams & {
|
|
399
|
+
serverAuthState?: undefined;
|
|
400
|
+
} & Omit<CoreMethodParams<'verifyExternalWallet'>, 'serverAuthState'>): CoreMethodResponse<'verifyExternalWallet'>;
|
|
401
|
+
protected verifyExternalWalletLink(opts: InternalMethodParams<'verifyExternalWalletLink'>): InternalMethodResponse<'verifyExternalWalletLink'>;
|
|
402
|
+
protected verifyTelegramProcess(opts: CoreMethodParams<'verifyTelegram'> & {
|
|
403
|
+
isLinkAccount: false;
|
|
404
|
+
}): CoreMethodResponse<'verifyTelegram'>;
|
|
405
|
+
protected verifyTelegramProcess(opts: InternalMethodParams<'verifyTelegramLink'> & {
|
|
406
|
+
isLinkAccount: true;
|
|
407
|
+
}): InternalMethodResponse<'verifyTelegramLink'>;
|
|
408
|
+
verifyTelegram(opts: CoreMethodParams<'verifyTelegram'>): CoreMethodResponse<'verifyTelegram'>;
|
|
409
|
+
protected verifyTelegramLink(opts: InternalMethodParams<'verifyTelegramLink'>): InternalMethodResponse<'verifyTelegramLink'>;
|
|
352
410
|
/**
|
|
353
411
|
* Performs 2FA verification.
|
|
354
412
|
* @param {Object} opts the options object
|
|
@@ -371,7 +429,7 @@ export declare abstract class ParaCore implements CoreInterface {
|
|
|
371
429
|
/**
|
|
372
430
|
* Resend a verification email for the current user.
|
|
373
431
|
*/
|
|
374
|
-
resendVerificationCode(): CoreMethodResponse<'resendVerificationCode'>;
|
|
432
|
+
resendVerificationCode({ type: reason, }: CoreMethodParams<'resendVerificationCode'>): CoreMethodResponse<'resendVerificationCode'>;
|
|
375
433
|
/**
|
|
376
434
|
* Checks if the current session is active.
|
|
377
435
|
* @returns `true` if active, `false` otherwise
|
|
@@ -383,7 +441,15 @@ export declare abstract class ParaCore implements CoreInterface {
|
|
|
383
441
|
**/
|
|
384
442
|
isFullyLoggedIn(): CoreMethodResponse<'isFullyLoggedIn'>;
|
|
385
443
|
get isGuestMode(): boolean;
|
|
444
|
+
/**
|
|
445
|
+
* Get the auth methods available to an existing user
|
|
446
|
+
* @deprecated Use supportedUserAuthMethods instead
|
|
447
|
+
*/
|
|
386
448
|
protected supportedAuthMethods(auth: Auth<PrimaryAuthType | 'userId'>): Promise<Set<AuthMethod>>;
|
|
449
|
+
/**
|
|
450
|
+
* Get the auth methods available to an existing user
|
|
451
|
+
*/
|
|
452
|
+
protected supportedUserAuthMethods(): Promise<Set<AuthMethod>>;
|
|
387
453
|
/**
|
|
388
454
|
* Get hints associated with the users stored biometrics.
|
|
389
455
|
* @deprecated
|
|
@@ -396,35 +462,30 @@ export declare abstract class ParaCore implements CoreInterface {
|
|
|
396
462
|
waitForSignup({ isCanceled, onCancel, onPoll, }: CoreMethodParams<'waitForSignup'>): CoreMethodResponse<'waitForSignup'>;
|
|
397
463
|
waitForWalletCreation({ isCanceled, onCancel, }?: CoreMethodParams<'waitForWalletCreation'>): CoreMethodResponse<'waitForWalletCreation'>;
|
|
398
464
|
/**
|
|
399
|
-
* Initiates a Farcaster login attempt and
|
|
465
|
+
* Initiates a Farcaster login attempt and returns the URL for the user to connect.
|
|
400
466
|
* You can create a QR code with this URI that works with Farcaster's mobile app.
|
|
401
467
|
* @return {string} the Farcaster connect URI
|
|
402
468
|
*/
|
|
403
|
-
getFarcasterConnectUri(
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
* @param {Object} opts the options object.
|
|
424
|
-
* @param {Window} [opts.popupWindow] the popup window being used for login.
|
|
425
|
-
* @return {Object} `{ email?: string; isError?: boolean; userExists: boolean; }` the result data
|
|
426
|
-
*/
|
|
427
|
-
verifyOAuth({ method, deeplinkUrl, isCanceled, onCancel, onPoll, onOAuthUrl, ...urlOptions }: CoreMethodParams<'verifyOAuth'>): CoreMethodResponse<'verifyOAuth'>;
|
|
469
|
+
getFarcasterConnectUri({ appScheme }?: {
|
|
470
|
+
appScheme?: string;
|
|
471
|
+
}): CoreMethodResponse<'getFarcasterConnectUri'>;
|
|
472
|
+
protected verifyFarcasterProcess(opts: CoreMethodParams<'verifyFarcaster'> & {
|
|
473
|
+
isLinkAccount: false;
|
|
474
|
+
}): CoreMethodResponse<'verifyFarcaster'>;
|
|
475
|
+
protected verifyFarcasterProcess(opts: InternalMethodParams<'verifyFarcasterLink'> & {
|
|
476
|
+
isLinkAccount: true;
|
|
477
|
+
}): InternalMethodResponse<'verifyFarcasterLink'>;
|
|
478
|
+
verifyFarcaster(opts: CoreMethodParams<'verifyFarcaster'>): CoreMethodResponse<'verifyFarcaster'>;
|
|
479
|
+
protected verifyFarcasterLink(opts: InternalMethodParams<'verifyFarcasterLink'>): InternalMethodResponse<'verifyFarcasterLink'>;
|
|
480
|
+
getOAuthUrl(opts: CoreMethodParams<'getOAuthUrl'>): CoreMethodResponse<'getOAuthUrl'>;
|
|
481
|
+
protected verifyOAuthProcess(_: InternalMethodParams<'verifyOAuthLink'> & {
|
|
482
|
+
isLinkAccount: true;
|
|
483
|
+
}): InternalMethodResponse<'verifyOAuthLink'>;
|
|
484
|
+
protected verifyOAuthProcess(_: CoreMethodParams<'verifyOAuth'> & {
|
|
485
|
+
isLinkAccount: false;
|
|
486
|
+
}): CoreMethodResponse<'verifyOAuth'>;
|
|
487
|
+
verifyOAuth(opts: CoreMethodParams<'verifyOAuth'>): CoreMethodResponse<'verifyOAuth'>;
|
|
488
|
+
protected verifyOAuthLink(opts: InternalMethodParams<'verifyOAuthLink'>): InternalMethodResponse<'verifyOAuthLink'>;
|
|
428
489
|
/**
|
|
429
490
|
* Waits for the session to be active and sets up the user.
|
|
430
491
|
*
|
|
@@ -433,7 +494,15 @@ export declare abstract class ParaCore implements CoreInterface {
|
|
|
433
494
|
* @param {boolean} [opts.skipSessionRefresh] whether to skip refreshing the session.
|
|
434
495
|
* @returns {Object} `{ isComplete: boolean; isError: boolean; needsWallet: boolean; partnerId: string; }` the result data
|
|
435
496
|
**/
|
|
436
|
-
waitForLogin(
|
|
497
|
+
waitForLogin(args: CoreMethodParams<'waitForLogin'>): CoreMethodResponse<'waitForLogin'>;
|
|
498
|
+
protected waitForWalletSwitching(args: CoreMethodParams<'waitForLogin'>): CoreMethodResponse<'waitForLogin'>;
|
|
499
|
+
/**
|
|
500
|
+
* Gets the switch wallets URL for wallet selection.
|
|
501
|
+
* The authMethod is automatically included in the URL if available.
|
|
502
|
+
*
|
|
503
|
+
* @returns {Promise<{ url: string; authMethod: TAuthMethod }>} The switch wallets URL and authMethod
|
|
504
|
+
*/
|
|
505
|
+
protected getSwitchWalletsUrl(): Promise<string>;
|
|
437
506
|
/**
|
|
438
507
|
* Updates the session with the user management server, possibly
|
|
439
508
|
* opening a popup to refresh the session.
|
|
@@ -495,7 +564,7 @@ export declare abstract class ParaCore implements CoreInterface {
|
|
|
495
564
|
*
|
|
496
565
|
* @deprecated alias for `createWalletPerType`
|
|
497
566
|
**/
|
|
498
|
-
createWalletPerMissingType: ({ skipDistribute, types, }?: CoreMethodParams<
|
|
567
|
+
createWalletPerMissingType: ({ skipDistribute, types, }?: CoreMethodParams<"createWalletPerType">) => CoreMethodResponse<"createWalletPerType">;
|
|
499
568
|
/**
|
|
500
569
|
* Creates several new wallets with the desired types. If no types are provided, this method
|
|
501
570
|
* will create one for each of the non-optional types specified in the instance's `supportedWalletTypes`
|
|
@@ -587,7 +656,7 @@ export declare abstract class ParaCore implements CoreInterface {
|
|
|
587
656
|
setUserShare(base64Wallets: CoreMethodParams<'setUserShare'>): CoreMethodResponse<'setUserShare'>;
|
|
588
657
|
private getTransactionReviewUrl;
|
|
589
658
|
private getOnRampTransactionUrl;
|
|
590
|
-
getWalletBalance: ({ walletId, rpcUrl, }: CoreMethodParams<
|
|
659
|
+
getWalletBalance: ({ walletId, rpcUrl, }: CoreMethodParams<"getWalletBalance">) => CoreMethodResponse<"getWalletBalance">;
|
|
591
660
|
/**
|
|
592
661
|
* Signs a message using one of the current wallets.
|
|
593
662
|
*
|
|
@@ -640,6 +709,7 @@ export declare abstract class ParaCore implements CoreInterface {
|
|
|
640
709
|
* @returns {Promise<string>} the ID
|
|
641
710
|
**/
|
|
642
711
|
getVerificationToken(): CoreMethodResponse<'getVerificationToken'>;
|
|
712
|
+
issueJwt({ keyIndex }?: CoreMethodParams<'issueJwt'>): CoreMethodResponse<'issueJwt'>;
|
|
643
713
|
/**
|
|
644
714
|
* Logs the user out.
|
|
645
715
|
* @param {Object} opts the options object.
|
|
@@ -648,20 +718,21 @@ export declare abstract class ParaCore implements CoreInterface {
|
|
|
648
718
|
logout({ clearPregenWallets }?: {
|
|
649
719
|
clearPregenWallets?: boolean;
|
|
650
720
|
}): Promise<void>;
|
|
651
|
-
|
|
652
|
-
protected getSupportedCreateAuthMethods(): Promise<Set<AuthMethod>>;
|
|
721
|
+
protected get toStringAdditions(): Record<string, unknown>;
|
|
653
722
|
/**
|
|
654
723
|
* Converts to a string, removing sensitive data when logging this class.
|
|
655
724
|
*
|
|
656
725
|
* Doesn't work for all types of logging.
|
|
657
726
|
**/
|
|
658
727
|
toString(): string;
|
|
659
|
-
protected
|
|
728
|
+
protected devLog(...s: any[]): void;
|
|
729
|
+
protected getNewCredentialAndUrl({ authMethod: optsAuthMethod, isForNewDevice, portalTheme, shorten, }?: NewCredentialUrlParams): Promise<{
|
|
660
730
|
credentialId: string;
|
|
661
731
|
url?: string;
|
|
662
732
|
}>;
|
|
733
|
+
addCredential({ authMethod }: Pick<NewCredentialUrlParams, 'authMethod'>): Promise<string>;
|
|
663
734
|
/**
|
|
664
|
-
* Returns a Para Portal URL for logging in with a WebAuth passkey or
|
|
735
|
+
* Returns a Para Portal URL for logging in with a WebAuth passkey, password, PIN or OTP.
|
|
665
736
|
* @param {Object} opts the options object
|
|
666
737
|
* @param {String} opts.auth - the user auth to sign up or log in with, in the form ` { email: string } | { phone: `+${number}` } `
|
|
667
738
|
* @param {boolean} opts.useShortUrls - whether to shorten the generated portal URLs
|
|
@@ -669,6 +740,20 @@ export declare abstract class ParaCore implements CoreInterface {
|
|
|
669
740
|
* @returns {SignUpOrLogInResponse} an object in the form of either: `{ stage: 'verify' }` or `{ stage: 'login'; passkeyUrl?: string; passwordUrl?: string; biometricHints?: BiometricLocationHint[] }`
|
|
670
741
|
*/
|
|
671
742
|
protected getLoginUrl({ authMethod, shorten, portalTheme, sessionId, }: LoginUrlParams): Promise<string>;
|
|
743
|
+
protected prepareLogin(): InternalMethodResponse<'prepareLogin'>;
|
|
672
744
|
signUpOrLogIn({ auth, ...urlOptions }: CoreMethodParams<'signUpOrLogIn'>): CoreMethodResponse<'signUpOrLogIn'>;
|
|
673
745
|
verifyNewAccount({ verificationCode, ...urlOptions }: CoreMethodParams<'verifyNewAccount'>): CoreMethodResponse<'verifyNewAccount'>;
|
|
746
|
+
getLinkedAccounts({ withMetadata, }?: CoreMethodParams<'getLinkedAccounts'>): CoreMethodResponse<'getLinkedAccounts'>;
|
|
747
|
+
protected linkAccount(opts: InternalMethodParams<'linkAccount'>): InternalMethodResponse<'linkAccount'>;
|
|
748
|
+
protected unlinkAccount({ linkedAccountId, }: InternalMethodParams<'unlinkAccount'>): InternalMethodResponse<'unlinkAccount'>;
|
|
749
|
+
protected verifyLink({ accountLinkInProgress, ...opts }?: {
|
|
750
|
+
accountLinkInProgress?: AccountLinkInProgress;
|
|
751
|
+
} & Partial<Pick<VerifyLinkParams, 'verificationCode' | 'telegramAuthResponse'> & VerifyExternalWalletParams>): Promise<LinkedAccounts>;
|
|
752
|
+
protected verifyEmailOrPhoneLink({ verificationCode, }: InternalMethodParams<'verifyEmailOrPhoneLink'>): InternalMethodResponse<'verifyEmailOrPhoneLink'>;
|
|
753
|
+
protected getProfileBalance({ config, refetch }?: {
|
|
754
|
+
config?: BalancesConfig;
|
|
755
|
+
refetch?: boolean;
|
|
756
|
+
}): Promise<import("@getpara/user-management-client").ProfileBalance>;
|
|
757
|
+
protected sendLoginCode(): Promise<void>;
|
|
758
|
+
exportPrivateKey(args?: CoreMethodParams<'exportPrivateKey'>): CoreMethodResponse<'exportPrivateKey'>;
|
|
674
759
|
}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/// <reference types="node" />
|
|
3
1
|
import { BackupKitEmailProps, TPregenIdentifierType, TWalletType, SDKType } from '@getpara/user-management-client';
|
|
4
2
|
import { Ctx, PopupType, SignatureRes } from './types/index.js';
|
|
5
3
|
import { StorageUtils } from './StorageUtils.js';
|
|
@@ -44,5 +42,6 @@ export interface PlatformUtils {
|
|
|
44
42
|
disableProviderModal?: boolean;
|
|
45
43
|
openPopup(popupUrl: string, opts?: {
|
|
46
44
|
type: PopupType;
|
|
47
|
-
}): Window
|
|
45
|
+
}): Promise<Window>;
|
|
46
|
+
initializeWorker(ctx: Ctx): Promise<void>;
|
|
48
47
|
}
|
|
@@ -1,20 +1,24 @@
|
|
|
1
1
|
export declare const PARA_CORE_VERSION: string;
|
|
2
2
|
export declare const PREFIX = "@CAPSULE/";
|
|
3
|
-
export declare const
|
|
4
|
-
export declare const
|
|
5
|
-
export declare const
|
|
6
|
-
export declare const
|
|
7
|
-
export declare const
|
|
8
|
-
export declare const
|
|
9
|
-
export declare const
|
|
10
|
-
export declare const
|
|
11
|
-
export declare const
|
|
12
|
-
export declare const
|
|
13
|
-
export declare const
|
|
14
|
-
export declare const
|
|
15
|
-
export declare const
|
|
16
|
-
export declare const
|
|
3
|
+
export declare const PARA_PREFIX = "@PARA/";
|
|
4
|
+
export declare const LOCAL_STORAGE_AUTH_INFO = "@CAPSULE/authInfo";
|
|
5
|
+
export declare const LOCAL_STORAGE_EMAIL = "@CAPSULE/e-mail";
|
|
6
|
+
export declare const LOCAL_STORAGE_PHONE = "@CAPSULE/phone";
|
|
7
|
+
export declare const LOCAL_STORAGE_COUNTRY_CODE = "@CAPSULE/countryCode";
|
|
8
|
+
export declare const LOCAL_STORAGE_FARCASTER_USERNAME = "@CAPSULE/farcasterUsername";
|
|
9
|
+
export declare const LOCAL_STORAGE_TELEGRAM_USER_ID = "@CAPSULE/telegramUserId";
|
|
10
|
+
export declare const LOCAL_STORAGE_EXTERNAL_WALLET_USER_ID = "@CAPSULE/externalWalletUserId";
|
|
11
|
+
export declare const LOCAL_STORAGE_USER_ID = "@CAPSULE/userId";
|
|
12
|
+
export declare const LOCAL_STORAGE_ED25519_WALLETS = "@CAPSULE/ed25519Wallets";
|
|
13
|
+
export declare const LOCAL_STORAGE_WALLETS = "@CAPSULE/wallets";
|
|
14
|
+
export declare const LOCAL_STORAGE_EXTERNAL_WALLETS = "@CAPSULE/externalWallets";
|
|
15
|
+
export declare const LOCAL_STORAGE_CURRENT_WALLET_IDS = "@CAPSULE/currentWalletIds";
|
|
16
|
+
export declare const LOCAL_STORAGE_SESSION_COOKIE = "@CAPSULE/sessionCookie";
|
|
17
|
+
export declare const LOCAL_STORAGE_ENCLAVE_JWT = "@CAPSULE/enclaveJwt";
|
|
18
|
+
export declare const LOCAL_STORAGE_ENCLAVE_REFRESH_JWT = "@CAPSULE/enclaveRefreshJwt";
|
|
19
|
+
export declare const SESSION_STORAGE_LOGIN_ENCRYPTION_KEY_PAIR = "@CAPSULE/loginEncryptionKeyPair";
|
|
17
20
|
export declare const POLLING_INTERVAL_MS = 2000;
|
|
18
21
|
export declare const SHORT_POLLING_INTERVAL_MS = 1000;
|
|
19
22
|
export declare const POLLING_TIMEOUT_MS = 300000;
|
|
20
23
|
export declare const EXTERNAL_WALLET_CONNECTION_ONLY_USER_ID = "EXTERNAL_WALLET_CONNECTION_ONLY";
|
|
24
|
+
export declare const ACCOUNT_LINK_CONFLICT = "Account already linked";
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { ParaCore } from './ParaCore.js';
|
|
2
|
-
export { type AuthInfo, type PrimaryAuthInfo, type VerifiedAuthInfo, AuthMethod, type AuthExtras, type CurrentWalletIds, EmailTheme, type PartnerEntity, type WalletEntity, Network, WalletType, type TWalletType, WalletScheme, type TWalletScheme, OnRampAsset, OnRampPurchaseType, OnRampProvider, OnRampPurchaseStatus, type OnRampConfig, type
|
|
3
|
-
export {
|
|
2
|
+
export { type Auth, type AuthInfo, type PrimaryAuthInfo, type VerifiedAuthInfo, type VerifiedAuth, AuthMethod, type TAuthMethod, AuthMethodStatus, type AuthExtras, type CurrentWalletIds, EmailTheme, type PartnerEntity, type WalletEntity, Network, type TNetwork, WalletType, type TWalletType, WalletScheme, type TWalletScheme, OnRampAsset, type TOnRampAsset, OnRampPurchaseType, OnRampProvider, OnRampPurchaseStatus, type OnRampConfig, type OnRampAssets, type OnRampPurchase, type OnRampAssetInfo, type ProviderAssetInfo, OnRampMethod, type Theme, OAuthMethod, type TOAuthMethod, type TLinkedAccountType, type SupportedAccountLinks, type SupportedWalletTypes, type TPregenIdentifierType, type PregenIds, type LinkedAccount, type LinkedAccounts, type TExternalWallet, type ExternalWalletInfo, type PregenAuth, type Setup2faResponse, type TelegramAuthResponse, type VerifyExternalWalletParams, type AssetMetadata, type AssetMetadataIndexed, type AssetValue, type BalancesConfig, type WalletBalance, type ProfileBalance, type OfframpDepositRequest, type WalletWithMetadata, RecoveryStatus, ThemeMode, NON_ED25519, PREGEN_IDENTIFIER_TYPES, WALLET_TYPES, WALLET_SCHEMES, OAUTH_METHODS, LINKED_ACCOUNT_TYPES, EXTERNAL_WALLET_TYPES, EVM_WALLETS, SOLANA_WALLETS, COSMOS_WALLETS, formatAssetQuantity, formatCurrency, } from '@getpara/user-management-client';
|
|
3
|
+
export { PopupType, PregenIdentifierType, type AuthStateSignup, type AuthStateVerify, type AuthStateLogin, type AuthState, type OAuthResponse, type CoreAuthInfo, type SignatureRes, type FullSignatureRes, type SuccessfulSignatureRes, type DeniedSignatureRes, type DeniedSignatureResWithUrl, type Wallet, type AvailableWallet, type GetWalletBalanceParams, type AccountLinkInProgress, AccountLinkError, type InternalInterface, } from './types/index.js';
|
|
4
4
|
export * from './types/coreApi.js';
|
|
5
5
|
export * from './types/events.js';
|
|
6
6
|
export * from './types/config.js';
|
|
7
|
-
export { getPortalDomain, entityToWallet, constructUrl, shortenUrl } from './utils/index.js';
|
|
8
|
-
export { PREFIX as STORAGE_PREFIX } from './constants.js';
|
|
7
|
+
export { getPortalDomain, dispatchEvent, entityToWallet, constructUrl, shortenUrl, isPortal } from './utils/index.js';
|
|
8
|
+
export { PREFIX as STORAGE_PREFIX, PARA_PREFIX as PARA_STORAGE_PREFIX, LOCAL_STORAGE_CURRENT_WALLET_IDS, LOCAL_STORAGE_WALLETS, } from './constants.js';
|
|
9
9
|
export { distributeNewShare } from './shares/shareDistribution.js';
|
|
10
10
|
export { KeyContainer } from './shares/KeyContainer.js';
|
|
11
11
|
export type { PlatformUtils } from './PlatformUtils.js';
|
|
@@ -18,9 +18,11 @@ export * from './errors.js';
|
|
|
18
18
|
export * from './utils/formatting.js';
|
|
19
19
|
export * from './utils/polling.js';
|
|
20
20
|
export * from './utils/phone.js';
|
|
21
|
+
export * from './utils/config.js';
|
|
21
22
|
export { isWalletSupported } from './utils/wallet.js';
|
|
22
23
|
export { getNetworkPrefix, getOnRampAssets, getOnRampNetworks, toAssetInfoArray } from './utils/onRamps.js';
|
|
23
24
|
export { getPortalBaseURL } from './utils/url.js';
|
|
24
25
|
export { retrieve as transmissionUtilsRetrieve } from './transmission/transmissionUtils.js';
|
|
26
|
+
export type { ShareData } from './shares/enclave.js';
|
|
25
27
|
export declare const paraVersion: string;
|
|
26
28
|
export default ParaCore;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import UserManagementClient from '@getpara/user-management-client';
|
|
2
|
+
export interface ShareData {
|
|
3
|
+
userId: string;
|
|
4
|
+
walletId: string;
|
|
5
|
+
walletScheme: string;
|
|
6
|
+
partnerId?: string;
|
|
7
|
+
protocolId?: string;
|
|
8
|
+
signer: string;
|
|
9
|
+
createdAt?: string;
|
|
10
|
+
updatedAt?: string;
|
|
11
|
+
}
|
|
12
|
+
export interface ShareQuery {
|
|
13
|
+
userId: string;
|
|
14
|
+
walletId?: string;
|
|
15
|
+
partnerId?: string;
|
|
16
|
+
}
|
|
17
|
+
export interface EncryptedPayload {
|
|
18
|
+
encryptedData: string;
|
|
19
|
+
keyId: string;
|
|
20
|
+
algorithm: string;
|
|
21
|
+
ephemeral: string;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Enclave client for secure key share operations
|
|
25
|
+
* Handles encryption/decryption and communication with the enclave service
|
|
26
|
+
*/
|
|
27
|
+
export declare class EnclaveClient {
|
|
28
|
+
private userManagementClient;
|
|
29
|
+
private enclavePublicKey;
|
|
30
|
+
private frontendKeyPair;
|
|
31
|
+
private retrieveJwt;
|
|
32
|
+
private persistJwt;
|
|
33
|
+
private retrieveRefreshJwt;
|
|
34
|
+
private persistRefreshJwt;
|
|
35
|
+
constructor({ userManagementClient, retrieveJwt, persistJwt, retrieveRefreshJwt, persistRefreshJwt, }: {
|
|
36
|
+
userManagementClient: UserManagementClient;
|
|
37
|
+
retrieveJwt: () => string;
|
|
38
|
+
persistJwt: (jwt: string) => void;
|
|
39
|
+
retrieveRefreshJwt: () => string;
|
|
40
|
+
persistRefreshJwt: (refreshJwt: string) => void;
|
|
41
|
+
});
|
|
42
|
+
private refreshJwt;
|
|
43
|
+
private withJwtRefreshRetry;
|
|
44
|
+
issueEnclaveJwt(): Promise<void>;
|
|
45
|
+
/**
|
|
46
|
+
* Generate a P-256 keypair for the frontend to receive encrypted responses
|
|
47
|
+
*/
|
|
48
|
+
private generateFrontendKeyPair;
|
|
49
|
+
/**
|
|
50
|
+
* Get the enclave's public key from the user-management service
|
|
51
|
+
*/
|
|
52
|
+
private getEnclavePublicKey;
|
|
53
|
+
/**
|
|
54
|
+
* Import a PEM-formatted public key for use with Web Crypto API
|
|
55
|
+
*/
|
|
56
|
+
private importPublicKeyFromPEM;
|
|
57
|
+
/**
|
|
58
|
+
* Export a public key to PEM format
|
|
59
|
+
*/
|
|
60
|
+
private exportPublicKeyToPEM;
|
|
61
|
+
/**
|
|
62
|
+
* Encrypt data using P-256 ECIES for the enclave
|
|
63
|
+
*/
|
|
64
|
+
private encryptForEnclave;
|
|
65
|
+
/**
|
|
66
|
+
* Decrypt response encrypted for the frontend
|
|
67
|
+
*/
|
|
68
|
+
private decryptForFrontend;
|
|
69
|
+
/**
|
|
70
|
+
* Persist key shares to the enclave
|
|
71
|
+
* @param shares Array of share data to persist
|
|
72
|
+
*/
|
|
73
|
+
private persistShares;
|
|
74
|
+
/**
|
|
75
|
+
* Retrieve key shares from the enclave
|
|
76
|
+
* @param query Query parameters for finding shares (single query or array of queries)
|
|
77
|
+
*/
|
|
78
|
+
private retrieveShares;
|
|
79
|
+
retrieveSharesWithRetry(query: ShareQuery[]): Promise<ShareData[]>;
|
|
80
|
+
persistSharesWithRetry(shares: ShareData[]): Promise<any>;
|
|
81
|
+
}
|