@getpara/core-sdk 2.0.0-alpha.6 → 2.0.0-alpha.61
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 +1038 -248
- package/dist/cjs/constants.js +13 -1
- package/dist/cjs/index.js +31 -3
- package/dist/cjs/shares/enclave.js +266 -0
- package/dist/cjs/shares/shareDistribution.js +16 -1
- 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 +20 -3
- package/dist/cjs/types/events.js +2 -0
- package/dist/cjs/types/index.js +2 -21
- package/dist/cjs/utils/config.js +108 -0
- package/dist/cjs/utils/formatting.js +46 -0
- package/dist/cjs/utils/index.js +2 -0
- package/dist/cjs/utils/onRamps.js +2 -3
- package/dist/cjs/utils/wallet.js +3 -0
- package/dist/esm/ParaCore.js +1045 -254
- package/dist/esm/{chunk-7B52C2XE.js → chunk-W5CT3TVS.js} +2 -0
- package/dist/esm/constants.js +10 -2
- package/dist/esm/cryptography/utils.js +1 -1
- package/dist/esm/errors.js +1 -1
- package/dist/esm/external/mpcComputationClient.js +1 -1
- package/dist/esm/external/userManagementClient.js +1 -1
- package/dist/esm/index.js +31 -6
- package/dist/esm/shares/KeyContainer.js +1 -1
- package/dist/esm/shares/enclave.js +226 -0
- package/dist/esm/shares/recovery.js +1 -1
- package/dist/esm/shares/shareDistribution.js +17 -2
- package/dist/esm/transmission/transmissionUtils.js +1 -1
- package/dist/esm/types/auth.js +11 -0
- package/dist/esm/types/config.js +1 -1
- package/dist/esm/types/coreApi.js +19 -3
- package/dist/esm/types/events.js +3 -1
- package/dist/esm/types/index.js +1 -16
- package/dist/esm/types/popup.js +1 -1
- package/dist/esm/types/wallet.js +1 -1
- package/dist/esm/utils/autobind.js +1 -1
- package/dist/esm/utils/config.js +86 -0
- package/dist/esm/utils/events.js +1 -1
- package/dist/esm/utils/formatting.js +44 -1
- package/dist/esm/utils/index.js +1 -0
- package/dist/esm/utils/json.js +1 -1
- package/dist/esm/utils/listeners.js +1 -1
- package/dist/esm/utils/onRamps.js +3 -4
- package/dist/esm/utils/phone.js +1 -1
- package/dist/esm/utils/polling.js +1 -1
- package/dist/esm/utils/types.js +1 -1
- package/dist/esm/utils/url.js +1 -1
- package/dist/esm/utils/wallet.js +4 -1
- package/dist/types/ParaCore.d.ts +115 -52
- 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 +101 -36
- 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 +85 -13
- package/dist/types/types/wallet.d.ts +7 -4
- package/dist/types/utils/config.d.ts +7 -0
- package/dist/types/utils/formatting.d.ts +12 -1
- package/dist/types/utils/index.d.ts +1 -0
- package/dist/types/utils/onRamps.d.ts +9 -10
- package/package.json +23 -23
- package/dist/cjs/types/recovery.js +0 -34
- 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
|
@@ -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
|
+
private issueEnclaveJwt;
|
|
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
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { BackupKitEmailProps } from '@getpara/user-management-client';
|
|
1
|
+
import { BackupKitEmailProps, TWalletScheme } from '@getpara/user-management-client';
|
|
2
2
|
import { Ctx } from '../types/index.js';
|
|
3
|
-
export declare function distributeNewShare({ ctx, userId, walletId, userShare, ignoreRedistributingBackupEncryptedShare, emailProps, partnerId, protocolId, }: {
|
|
3
|
+
export declare function distributeNewShare({ ctx, userId, walletId, userShare, ignoreRedistributingBackupEncryptedShare, emailProps, partnerId, protocolId, isEnclaveUser, walletScheme, }: {
|
|
4
4
|
ctx: Ctx;
|
|
5
5
|
userId: string;
|
|
6
6
|
walletId: string;
|
|
@@ -9,4 +9,6 @@ export declare function distributeNewShare({ ctx, userId, walletId, userShare, i
|
|
|
9
9
|
emailProps?: BackupKitEmailProps;
|
|
10
10
|
partnerId?: string;
|
|
11
11
|
protocolId?: string;
|
|
12
|
+
isEnclaveUser: boolean;
|
|
13
|
+
walletScheme: TWalletScheme;
|
|
12
14
|
}): Promise<string>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { TNetwork, TOnRampAsset } from '@getpara/user-management-client';
|
|
2
|
+
import { Wallet } from './wallet.js';
|
|
3
|
+
export type AssetTransferType = 'INBOUND' | 'OUTBOUND';
|
|
4
|
+
export type AssetTransfer = {
|
|
5
|
+
wallet: Omit<Wallet, 'signer'>;
|
|
6
|
+
type: AssetTransferType;
|
|
7
|
+
sourceAddress: string;
|
|
8
|
+
destinationAddress: string;
|
|
9
|
+
asset: TOnRampAsset;
|
|
10
|
+
network: TNetwork;
|
|
11
|
+
quantity: string;
|
|
12
|
+
chainId?: string;
|
|
13
|
+
contractAddress?: string;
|
|
14
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ExternalWalletInfo, TLinkedAccountType } from '@getpara/user-management-client';
|
|
2
|
+
export type AccountLinkInProgress = {
|
|
3
|
+
id: string;
|
|
4
|
+
type: TLinkedAccountType;
|
|
5
|
+
identifier?: string;
|
|
6
|
+
isComplete: boolean;
|
|
7
|
+
externalWallet?: ExternalWalletInfo & {
|
|
8
|
+
signatureVerificationMessage: string;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
export declare enum AccountLinkError {
|
|
12
|
+
NotAuthenticated = "No user is currently authenticated",
|
|
13
|
+
Conflict = "Account already linked",
|
|
14
|
+
Canceled = "Account linking was canceled",
|
|
15
|
+
Unknown = "An unknown error occurred"
|
|
16
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AxiosInstance } from 'axios';
|
|
2
|
-
import Client, { EmailTheme, Network, OnRampAsset, OnRampProvider, TWalletScheme, TWalletType } from '@getpara/user-management-client';
|
|
3
|
-
import {
|
|
2
|
+
import Client, { EmailTheme, Network, OnRampAsset, OnRampProvider, PregenAuth, TWalletScheme, TWalletType, Theme } from '@getpara/user-management-client';
|
|
3
|
+
import { EnclaveClient } from '../shares/enclave.js';
|
|
4
4
|
export declare enum Environment {
|
|
5
5
|
DEV = "DEV",
|
|
6
6
|
SANDBOX = "SANDBOX",
|
|
@@ -13,6 +13,7 @@ export interface Ctx {
|
|
|
13
13
|
env: Environment;
|
|
14
14
|
apiKey: string;
|
|
15
15
|
client: Client;
|
|
16
|
+
enclaveClient?: EnclaveClient;
|
|
16
17
|
disableWorkers?: boolean;
|
|
17
18
|
offloadMPCComputationURL?: string;
|
|
18
19
|
mpcComputationClient?: AxiosInstance;
|
|
@@ -140,4 +141,12 @@ export interface ConstructorOpts {
|
|
|
140
141
|
* Partner ID set in the Para Portal to track analytics for legacy SDK versions. This variable is unused outside of the Para Portal.
|
|
141
142
|
*/
|
|
142
143
|
portalPartnerId?: string;
|
|
144
|
+
/**
|
|
145
|
+
* An optional function that fetches the pregenerated wallets for a given identifier so a user can claim them on account creation.
|
|
146
|
+
*/
|
|
147
|
+
fetchPregenWalletsOverride?: (opts: {
|
|
148
|
+
pregenId: PregenAuth;
|
|
149
|
+
}) => Promise<{
|
|
150
|
+
userShare?: string;
|
|
151
|
+
}>;
|
|
143
152
|
}
|
|
@@ -1,24 +1,48 @@
|
|
|
1
|
-
import { BackupKitEmailProps, CurrentWalletIds, ExternalWalletInfo, OnRampPurchase, OnRampPurchaseCreateParams, PregenAuth, Setup2faResponse,
|
|
2
|
-
import { AuthStateLogin, AuthStateVerify, OAuthResponse, AuthStateBaseParams, WithCustomTheme, WithUseShortUrls, Verify2faResponse, AuthStateSignup, AuthStateVerifyOrLogin, OAuthUrlParams, StorageType, PollParams, CoreAuthInfo, GetWalletBalanceParams, GetWalletBalanceResponse } from './methods.js';
|
|
1
|
+
import { BackupKitEmailProps, CurrentWalletIds, ExternalWalletInfo, OnRampPurchase, OnRampPurchaseCreateParams, PregenAuth, Setup2faResponse, VerifiedAuth, VerifyExternalWalletParams, WalletEntity, WalletParams, TWalletType, IssueJwtParams, IssueJwtResponse, TLinkedAccountType, LinkedAccounts } from '@getpara/user-management-client';
|
|
2
|
+
import { AuthStateLogin, AuthStateVerify, OAuthResponse, AuthStateBaseParams, WithCustomTheme, WithUseShortUrls, Verify2faResponse, AuthStateSignup, AuthStateVerifyOrLogin, OAuthUrlParams, StorageType, PollParams, CoreAuthInfo, GetWalletBalanceParams, GetWalletBalanceResponse, FarcasterParams, TelegramParams, OAuthParams } from './methods.js';
|
|
3
3
|
import { ParaCore } from '../ParaCore.js';
|
|
4
4
|
import { FullSignatureRes, Wallet } from './wallet.js';
|
|
5
|
-
|
|
5
|
+
import { AccountLinkInProgress } from './auth.js';
|
|
6
|
+
export declare const PARA_CORE_METHODS: readonly ["getAuthInfo", "signUpOrLogIn", "verifyNewAccount", "waitForLogin", "waitForSignup", "waitForWalletCreation", "getOAuthUrl", "verifyOAuth", "getFarcasterConnectUri", "verifyFarcaster", "verifyTelegram", "resendVerificationCode", "loginExternalWallet", "verifyExternalWallet", "setup2fa", "enable2fa", "verify2fa", "logout", "clearStorage", "isSessionActive", "isFullyLoggedIn", "refreshSession", "keepSessionAlive", "exportSession", "importSession", "getVerificationToken", "getWallets", "getWalletsByType", "fetchWallets", "createWallet", "createWalletPerType", "getPregenWallets", "hasPregenWallet", "updatePregenWalletIdentifier", "createPregenWallet", "createPregenWalletPerType", "claimPregenWallets", "createGuestWallets", "distributeNewWalletShare", "getUserShare", "setUserShare", "refreshShare", "signMessage", "signTransaction", "initiateOnRampTransaction", "getWalletBalance", "issueJwt", "getLinkedAccounts", "accountLinkInProgress"];
|
|
7
|
+
export declare const PARA_INTERNAL_METHODS: readonly ["linkAccount", "unlinkAccount", "verifyEmailOrPhoneLink", "verifyOAuthLink", "verifyFarcasterLink", "verifyTelegramLink", "verifyExternalWalletLink", "accountLinkInProgress", "prepareLogin", "sendLoginCode"];
|
|
6
8
|
export type CoreMethodName = (typeof PARA_CORE_METHODS)[number];
|
|
7
9
|
export type CoreMethodParams<method extends CoreMethodName & keyof CoreMethods> = CoreMethods[method] extends {
|
|
8
10
|
params: infer P;
|
|
9
11
|
} ? P : never;
|
|
12
|
+
export type CoreMethodIsGetter<method extends CoreMethodName & keyof CoreMethods> = CoreMethods[method] extends {
|
|
13
|
+
isGetter: true;
|
|
14
|
+
} ? true : false;
|
|
10
15
|
export type CoreMethodResponse<method extends CoreMethodName & keyof CoreMethods> = CoreMethods[method] extends {
|
|
11
16
|
response: infer R;
|
|
12
17
|
} ? CoreMethods[method] extends {
|
|
13
18
|
sync: true;
|
|
14
19
|
} ? R : Promise<R> : void;
|
|
15
|
-
export type CoreMethod<method extends CoreMethodName & keyof CoreMethods> = CoreMethodParams<method> extends void | never ? () => CoreMethodResponse<method> : (_?: CoreMethodParams<method>) => CoreMethodResponse<method>;
|
|
20
|
+
export type CoreMethod<method extends CoreMethodName & keyof CoreMethods> = CoreMethodIsGetter<method> extends true ? Awaited<CoreMethodResponse<method>> : CoreMethodParams<method> extends void | never ? () => CoreMethodResponse<method> : (_?: CoreMethodParams<method>) => CoreMethodResponse<method>;
|
|
16
21
|
export type CoreAction<method extends CoreMethodName & keyof CoreMethods> = CoreMethodParams<method> extends void | never ? (_?: ParaCore) => CoreMethodResponse<method> : (_?: ParaCore, __?: CoreMethodParams<method>) => CoreMethodResponse<method>;
|
|
22
|
+
export type InternalMethodName = (typeof PARA_INTERNAL_METHODS)[number];
|
|
23
|
+
export type InternalMethodParams<method extends InternalMethodName & keyof InternalMethods> = InternalMethods[method] extends {
|
|
24
|
+
params: infer P;
|
|
25
|
+
} ? P : never;
|
|
26
|
+
export type InternalMethodIsGetter<method extends InternalMethodName & keyof InternalMethods> = InternalMethods[method] extends {
|
|
27
|
+
isGetter: true;
|
|
28
|
+
} ? true : false;
|
|
29
|
+
export type InternalMethodResponse<method extends InternalMethodName & keyof InternalMethods> = InternalMethods[method] extends {
|
|
30
|
+
response: infer R;
|
|
31
|
+
} ? InternalMethods[method] extends {
|
|
32
|
+
sync: true;
|
|
33
|
+
} ? R : Promise<R> : void;
|
|
34
|
+
export type InternalMethod<method extends InternalMethodName & keyof InternalMethods> = InternalMethodIsGetter<method> extends true ? Awaited<InternalMethodResponse<method>> : InternalMethodParams<method> extends void | never ? () => InternalMethodResponse<method> : (_?: InternalMethodParams<method>) => InternalMethodResponse<method>;
|
|
35
|
+
export type InternalAction<method extends InternalMethodName & keyof InternalMethods> = InternalMethodParams<method> extends void | never ? (_?: ParaCore) => InternalMethodResponse<method> : (_?: ParaCore, __?: InternalMethodParams<method>) => InternalMethodResponse<method>;
|
|
17
36
|
export type CoreMethods = Record<CoreMethodName, {
|
|
18
37
|
params?: unknown;
|
|
19
38
|
response?: unknown;
|
|
20
39
|
sync?: true;
|
|
21
40
|
}> & {
|
|
41
|
+
accountLinkInProgress: {
|
|
42
|
+
params: never;
|
|
43
|
+
response: AccountLinkInProgress;
|
|
44
|
+
isGetter: true;
|
|
45
|
+
};
|
|
22
46
|
getAuthInfo: {
|
|
23
47
|
params: void;
|
|
24
48
|
response: CoreAuthInfo | undefined;
|
|
@@ -94,21 +118,12 @@ export type CoreMethods = Record<CoreMethodName, {
|
|
|
94
118
|
getOAuthUrl: {
|
|
95
119
|
params: OAuthUrlParams & {
|
|
96
120
|
sessionLookupId?: string;
|
|
121
|
+
encryptionKey?: string;
|
|
97
122
|
};
|
|
98
123
|
response: string;
|
|
99
124
|
};
|
|
100
125
|
verifyOAuth: {
|
|
101
|
-
params: AuthStateBaseParams &
|
|
102
|
-
/**
|
|
103
|
-
* A function returning a boolean, indicating whether the OAuth process should be cancelled.
|
|
104
|
-
*/
|
|
105
|
-
isCanceled?: () => boolean;
|
|
106
|
-
/**
|
|
107
|
-
* A callback function that will be invoked with the OAuth URL when it is available.
|
|
108
|
-
* For example, you can use this to open the URL in a new window or tab.
|
|
109
|
-
*/
|
|
110
|
-
onOAuthUrl?: (url: string) => void;
|
|
111
|
-
};
|
|
126
|
+
params: AuthStateBaseParams & OAuthParams;
|
|
112
127
|
response: OAuthResponse;
|
|
113
128
|
};
|
|
114
129
|
getFarcasterConnectUri: {
|
|
@@ -116,26 +131,11 @@ export type CoreMethods = Record<CoreMethodName, {
|
|
|
116
131
|
response: string;
|
|
117
132
|
};
|
|
118
133
|
verifyFarcaster: {
|
|
119
|
-
params: AuthStateBaseParams &
|
|
120
|
-
/**
|
|
121
|
-
* A function returning a boolean, indicating whether the Farcaster login process should be cancelled.
|
|
122
|
-
*/
|
|
123
|
-
isCanceled?: () => boolean;
|
|
124
|
-
/**
|
|
125
|
-
* A callback function that will be invoked with the Farcaster Connect URI when it is available.
|
|
126
|
-
* You will need to display the URI as a QR code.
|
|
127
|
-
*/
|
|
128
|
-
onConnectUri?: (uri: string) => void;
|
|
129
|
-
};
|
|
134
|
+
params: AuthStateBaseParams & FarcasterParams;
|
|
130
135
|
response: OAuthResponse;
|
|
131
136
|
};
|
|
132
137
|
verifyTelegram: {
|
|
133
|
-
params: AuthStateBaseParams &
|
|
134
|
-
/**
|
|
135
|
-
* The response received from the Telegram login bot.
|
|
136
|
-
*/
|
|
137
|
-
telegramAuthResponse: TelegramAuthResponse;
|
|
138
|
-
};
|
|
138
|
+
params: AuthStateBaseParams & TelegramParams;
|
|
139
139
|
response: OAuthResponse;
|
|
140
140
|
};
|
|
141
141
|
loginExternalWallet: {
|
|
@@ -143,16 +143,18 @@ export type CoreMethods = Record<CoreMethodName, {
|
|
|
143
143
|
/**
|
|
144
144
|
* The external wallet information to use for login.
|
|
145
145
|
*/
|
|
146
|
-
externalWallet: ExternalWalletInfo;
|
|
146
|
+
externalWallet: ExternalWalletInfo | ExternalWalletInfo[];
|
|
147
147
|
};
|
|
148
148
|
response: AuthStateVerifyOrLogin;
|
|
149
149
|
};
|
|
150
150
|
verifyExternalWallet: {
|
|
151
151
|
params: AuthStateBaseParams & VerifyExternalWalletParams;
|
|
152
|
-
response: AuthStateSignup;
|
|
152
|
+
response: AuthStateSignup | AuthStateLogin;
|
|
153
153
|
};
|
|
154
154
|
resendVerificationCode: {
|
|
155
|
-
params:
|
|
155
|
+
params: {
|
|
156
|
+
type?: 'SIGNUP' | 'LINK_ACCOUNT' | 'LOGIN';
|
|
157
|
+
} | undefined;
|
|
156
158
|
response: void;
|
|
157
159
|
};
|
|
158
160
|
logout: {
|
|
@@ -469,7 +471,70 @@ export type CoreMethods = Record<CoreMethodName, {
|
|
|
469
471
|
params: GetWalletBalanceParams;
|
|
470
472
|
response: GetWalletBalanceResponse;
|
|
471
473
|
};
|
|
474
|
+
issueJwt: {
|
|
475
|
+
params: IssueJwtParams;
|
|
476
|
+
response: IssueJwtResponse;
|
|
477
|
+
};
|
|
478
|
+
getLinkedAccounts: {
|
|
479
|
+
params: {
|
|
480
|
+
withMetadata?: boolean;
|
|
481
|
+
};
|
|
482
|
+
response: LinkedAccounts & {
|
|
483
|
+
userId: string;
|
|
484
|
+
};
|
|
485
|
+
};
|
|
486
|
+
};
|
|
487
|
+
export type InternalMethods = {
|
|
488
|
+
linkAccount: {
|
|
489
|
+
params: {
|
|
490
|
+
auth: VerifiedAuth;
|
|
491
|
+
} | {
|
|
492
|
+
externalWallet: ExternalWalletInfo;
|
|
493
|
+
} | {
|
|
494
|
+
type: TLinkedAccountType | 'X';
|
|
495
|
+
};
|
|
496
|
+
response: AccountLinkInProgress;
|
|
497
|
+
};
|
|
498
|
+
unlinkAccount: {
|
|
499
|
+
params: {
|
|
500
|
+
linkedAccountId: string;
|
|
501
|
+
};
|
|
502
|
+
response: LinkedAccounts;
|
|
503
|
+
};
|
|
504
|
+
verifyEmailOrPhoneLink: {
|
|
505
|
+
params: {
|
|
506
|
+
verificationCode?: string;
|
|
507
|
+
};
|
|
508
|
+
response: LinkedAccounts;
|
|
509
|
+
};
|
|
510
|
+
verifyOAuthLink: {
|
|
511
|
+
params: OAuthParams;
|
|
512
|
+
response: LinkedAccounts;
|
|
513
|
+
};
|
|
514
|
+
verifyFarcasterLink: {
|
|
515
|
+
params: FarcasterParams;
|
|
516
|
+
response: LinkedAccounts;
|
|
517
|
+
};
|
|
518
|
+
verifyTelegramLink: {
|
|
519
|
+
params: TelegramParams;
|
|
520
|
+
response: LinkedAccounts;
|
|
521
|
+
};
|
|
522
|
+
verifyExternalWalletLink: {
|
|
523
|
+
params: Omit<VerifyExternalWalletParams, 'externalWallet'>;
|
|
524
|
+
response: LinkedAccounts;
|
|
525
|
+
};
|
|
526
|
+
prepareLogin: {
|
|
527
|
+
params: void;
|
|
528
|
+
response: string;
|
|
529
|
+
};
|
|
530
|
+
sendLoginCode: {
|
|
531
|
+
params: void;
|
|
532
|
+
response: void;
|
|
533
|
+
};
|
|
472
534
|
};
|
|
473
535
|
export type CoreInterface = {
|
|
474
|
-
[key in keyof CoreMethods]: CoreMethod<key
|
|
536
|
+
[key in keyof CoreMethods]: Partial<CoreMethod<key>>;
|
|
537
|
+
};
|
|
538
|
+
export type InternalInterface = {
|
|
539
|
+
[key in keyof InternalMethods]: Partial<InternalMethod<key>>;
|
|
475
540
|
};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { CurrentWalletIds } from '@getpara/user-management-client';
|
|
1
|
+
import { CurrentWalletIds, OnRampPurchase } from '@getpara/user-management-client';
|
|
2
2
|
import { FullSignatureRes } from './wallet.js';
|
|
3
3
|
import { Wallet } from './wallet.js';
|
|
4
4
|
import { CoreMethodResponse } from './coreApi.js';
|
|
5
|
+
import { AssetTransfer } from './assets.js';
|
|
5
6
|
export declare enum ParaEvent {
|
|
6
7
|
LOGIN_EVENT = "paraLogin",
|
|
7
8
|
ACCOUNT_CREATION_EVENT = "paraAccountCreation",
|
|
@@ -13,7 +14,9 @@ export declare enum ParaEvent {
|
|
|
13
14
|
WALLETS_CHANGE_EVENT = "paraWalletsChange",
|
|
14
15
|
WALLET_CREATED = "paraWalletCreated",
|
|
15
16
|
PREGEN_WALLET_CLAIMED = "paraPregenWalletClaimed",
|
|
16
|
-
GUEST_WALLETS_CREATED = "paraGuestWalletsCreated"
|
|
17
|
+
GUEST_WALLETS_CREATED = "paraGuestWalletsCreated",
|
|
18
|
+
ASSET_TRANSFERRED = "paraAssetTransferred",
|
|
19
|
+
ONRAMP_TRANSACTION_COMPLETE = "paraOnRampTransactionComplete"
|
|
17
20
|
}
|
|
18
21
|
export type BaseEvent<T> = {
|
|
19
22
|
data: T;
|
|
@@ -48,3 +51,5 @@ export type PregenWalletClaimedResponse = {
|
|
|
48
51
|
};
|
|
49
52
|
export type PregenWalletClaimedEvent = CustomEventInit<BaseEvent<WalletCreatedResponse>>;
|
|
50
53
|
export type GuestWalletsCreatedEvent = CustomEventInit<BaseEvent<CoreMethodResponse<'createGuestWallets'>>>;
|
|
54
|
+
export type AssetTransferredEvent = CustomEventInit<BaseEvent<AssetTransfer>>;
|
|
55
|
+
export type OnRampTransactionCompleteResponse = CustomEventInit<BaseEvent<OnRampPurchase>>;
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
+
export * from './auth.js';
|
|
1
2
|
export * from './config.js';
|
|
2
3
|
export * from './coreApi.js';
|
|
3
4
|
export * from './wallet.js';
|
|
4
5
|
export * from './methods.js';
|
|
5
|
-
export * from './theme.js';
|
|
6
|
-
export * from './onRamps.js';
|
|
7
6
|
export * from './popup.js';
|
|
8
|
-
export * from './recovery.js';
|
|
9
7
|
export * from './events.js';
|
|
10
|
-
export { Network, OnRampAsset, OnRampProvider, OnRampPurchaseStatus, type OnRampPurchase, } from '@getpara/user-management-client';
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import { PrimaryAuthInfo, ServerAuthStateLogin, ServerAuthStateSignup, AuthMethod, ServerAuthStateVerify, VerifiedAuth, AuthExtras, TOAuthMethod, TWalletType } from '@getpara/user-management-client';
|
|
2
|
-
import { Theme } from './theme.js';
|
|
3
|
-
import { RecoveryStatus } from './recovery.js';
|
|
1
|
+
import { PrimaryAuthInfo, ServerAuthStateLogin, ServerAuthStateSignup, AuthMethod, ServerAuthStateVerify, VerifiedAuth, AuthExtras, RecoveryStatus, Theme, TOAuthMethod, TWalletType, TelegramAuthResponse, VerifyThirdPartyAuth, ServerAuthStateDone } from '@getpara/user-management-client';
|
|
4
2
|
import { Wallet } from './wallet.js';
|
|
5
3
|
type Device = {
|
|
6
4
|
sessionId: string;
|
|
@@ -14,7 +12,7 @@ export type VerifyExternalWalletV1 = {
|
|
|
14
12
|
cosmosPublicKeyHex?: string;
|
|
15
13
|
cosmosSigner?: string;
|
|
16
14
|
};
|
|
17
|
-
export type PortalUrlType = 'createAuth' | 'createPassword' | 'loginAuth' | 'loginPassword' | 'txReview' | 'onRamp';
|
|
15
|
+
export type PortalUrlType = 'createAuth' | 'createPassword' | 'loginAuth' | 'loginPassword' | 'txReview' | 'onRamp' | 'telegramLogin' | 'createPIN' | 'loginPIN' | 'oAuth' | 'oAuthCallback' | 'loginOTP' | 'telegramLoginVerify' | 'loginFarcaster';
|
|
18
16
|
export type PortalUrlOptions = {
|
|
19
17
|
params?: Record<string, string | undefined | null>;
|
|
20
18
|
isForNewDevice?: boolean;
|
|
@@ -24,10 +22,14 @@ export type PortalUrlOptions = {
|
|
|
24
22
|
portalTheme?: Theme;
|
|
25
23
|
pathId?: string;
|
|
26
24
|
shorten?: boolean;
|
|
25
|
+
isEmbedded?: boolean;
|
|
26
|
+
oAuthMethod?: OAuthUrlParams['method'];
|
|
27
|
+
appScheme?: string;
|
|
28
|
+
encryptionKey?: string;
|
|
27
29
|
};
|
|
28
30
|
export type WithAuthMethod = {
|
|
29
31
|
/**
|
|
30
|
-
* Which authorization method to use for the URL, either `'passkey'` or `'
|
|
32
|
+
* Which authorization method to use for the URL, either `'passkey'` or `'password'`.
|
|
31
33
|
*/
|
|
32
34
|
authMethod?: Uppercase<AuthMethod>;
|
|
33
35
|
};
|
|
@@ -49,6 +51,12 @@ export type WithShorten = {
|
|
|
49
51
|
*/
|
|
50
52
|
shorten?: boolean;
|
|
51
53
|
};
|
|
54
|
+
export type WithIsPasskeySupported = {
|
|
55
|
+
/**
|
|
56
|
+
* Whether the current device supports WebAuth passkeys.
|
|
57
|
+
*/
|
|
58
|
+
isPasskeySupported: boolean;
|
|
59
|
+
};
|
|
52
60
|
export type PollParams = {
|
|
53
61
|
/**
|
|
54
62
|
* A callback function that will be invoked on each method poll.
|
|
@@ -59,6 +67,25 @@ export type PollParams = {
|
|
|
59
67
|
*/
|
|
60
68
|
onCancel?: () => void;
|
|
61
69
|
};
|
|
70
|
+
export type FarcasterParams = PollParams & {
|
|
71
|
+
/**
|
|
72
|
+
* A function returning a boolean, indicating whether the Farcaster login process should be cancelled.
|
|
73
|
+
*/
|
|
74
|
+
isCanceled?: () => boolean;
|
|
75
|
+
/**
|
|
76
|
+
* A callback function that will be invoked with the Farcaster Connect URI when it is available.
|
|
77
|
+
* You will need to display the URI as a QR code.
|
|
78
|
+
*/
|
|
79
|
+
onConnectUri?: (uri: string) => void;
|
|
80
|
+
serverAuthState?: VerifyThirdPartyAuth;
|
|
81
|
+
};
|
|
82
|
+
export type TelegramParams = {
|
|
83
|
+
/**
|
|
84
|
+
* The response received from the Telegram login bot.
|
|
85
|
+
*/
|
|
86
|
+
telegramAuthResponse?: TelegramAuthResponse;
|
|
87
|
+
serverAuthState?: VerifyThirdPartyAuth;
|
|
88
|
+
};
|
|
62
89
|
export type LoginUrlParams = WithAuthMethod & WithCustomTheme & WithShorten & {
|
|
63
90
|
sessionId?: string;
|
|
64
91
|
};
|
|
@@ -74,13 +101,35 @@ export type OAuthUrlParams = {
|
|
|
74
101
|
*/
|
|
75
102
|
method: Exclude<TOAuthMethod, 'TELEGRAM' | 'FARCASTER'>;
|
|
76
103
|
/**
|
|
77
|
-
* The
|
|
104
|
+
* The app scheme to redirect to after OAuth is complete.
|
|
105
|
+
*/
|
|
106
|
+
appScheme?: string;
|
|
107
|
+
};
|
|
108
|
+
export type OAuthParams = OAuthUrlParams & PollParams & {
|
|
109
|
+
/**
|
|
110
|
+
* A function returning a boolean, indicating whether the OAuth process should be cancelled.
|
|
111
|
+
*/
|
|
112
|
+
isCanceled?: () => boolean;
|
|
113
|
+
/**
|
|
114
|
+
* A callback function that will be invoked with the OAuth URL when it is available.
|
|
115
|
+
* For example, you can use this to open the URL in a new window or tab.
|
|
116
|
+
*
|
|
117
|
+
* You should pass one of `onOAuthUrl` or `onOAuthPopup`, not both.
|
|
118
|
+
*/
|
|
119
|
+
onOAuthUrl?: (url: string) => void;
|
|
120
|
+
/**
|
|
121
|
+
* A callback function that will be invoked with the OAuth popup window when it is available.
|
|
122
|
+
* If supplied, a window will automatically be opened for you if running on an applicable platform.
|
|
123
|
+
*
|
|
124
|
+
* You should pass one of `onOAuthUrl` or `onOAuthPopup`, not both.
|
|
78
125
|
*/
|
|
79
|
-
|
|
126
|
+
onOAuthPopup?: (popup: Window) => void;
|
|
80
127
|
};
|
|
81
128
|
export type AuthStateBaseParams = WithCustomTheme & WithUseShortUrls;
|
|
82
|
-
export type AuthStateVerify = ServerAuthStateVerify
|
|
83
|
-
|
|
129
|
+
export type AuthStateVerify = ServerAuthStateVerify & {
|
|
130
|
+
loginUrl?: string;
|
|
131
|
+
};
|
|
132
|
+
export type AuthStateLogin = Omit<ServerAuthStateLogin, 'loginAuthMethods'> & WithIsPasskeySupported & {
|
|
84
133
|
/**
|
|
85
134
|
* A Para Portal URL for logging in via a WebAuth passkey. For best compatibility, you should open this URL in a new window or tab.
|
|
86
135
|
*/
|
|
@@ -93,8 +142,16 @@ export type AuthStateLogin = Omit<ServerAuthStateLogin, 'loginAuthMethods'> & {
|
|
|
93
142
|
* A Para Portal URL for logging in via a password.
|
|
94
143
|
*/
|
|
95
144
|
passwordUrl?: string;
|
|
145
|
+
/**
|
|
146
|
+
* A Para Portal URL for logging in via a PIN.
|
|
147
|
+
*/
|
|
148
|
+
pinUrl?: string;
|
|
149
|
+
/**
|
|
150
|
+
* Supported login auth methods for this session.
|
|
151
|
+
*/
|
|
152
|
+
loginAuthMethods?: AuthMethod[];
|
|
96
153
|
};
|
|
97
|
-
export type AuthStateSignup = Omit<ServerAuthStateSignup, 'signupAuthMethods'> & {
|
|
154
|
+
export type AuthStateSignup = Omit<ServerAuthStateSignup, 'signupAuthMethods'> & WithIsPasskeySupported & {
|
|
98
155
|
/**
|
|
99
156
|
* A Para Portal URL for creating a new WebAuth passkey.
|
|
100
157
|
*/
|
|
@@ -103,6 +160,10 @@ export type AuthStateSignup = Omit<ServerAuthStateSignup, 'signupAuthMethods'> &
|
|
|
103
160
|
* A Para Portal URL for creating a new user password.
|
|
104
161
|
*/
|
|
105
162
|
passwordUrl?: string;
|
|
163
|
+
/**
|
|
164
|
+
* A Para Portal URL for creating a new user PIN.
|
|
165
|
+
*/
|
|
166
|
+
pinUrl?: string;
|
|
106
167
|
/**
|
|
107
168
|
* The Para system ID for the newly generated passkey.
|
|
108
169
|
*/
|
|
@@ -111,11 +172,22 @@ export type AuthStateSignup = Omit<ServerAuthStateSignup, 'signupAuthMethods'> &
|
|
|
111
172
|
* The Para system ID for the newly generated password.
|
|
112
173
|
*/
|
|
113
174
|
passwordId?: string;
|
|
175
|
+
/**
|
|
176
|
+
* The Para system ID for the newly generated PIN.
|
|
177
|
+
*/
|
|
178
|
+
pinId?: string;
|
|
179
|
+
/**
|
|
180
|
+
* Supported signup auth methods for this session.
|
|
181
|
+
*/
|
|
182
|
+
signupAuthMethods?: AuthMethod[];
|
|
183
|
+
};
|
|
184
|
+
export type AuthStateDone = Omit<ServerAuthStateDone, 'authMethods'> & {
|
|
185
|
+
authMethods: AuthMethod[];
|
|
114
186
|
};
|
|
115
187
|
export type AuthStateVerifyOrLogin = AuthStateVerify | AuthStateLogin;
|
|
116
|
-
export type
|
|
117
|
-
export type OAuthResponse =
|
|
118
|
-
export type AuthState = AuthStateVerify | AuthStateLogin | AuthStateSignup;
|
|
188
|
+
export type AuthStateSignupOrLoginOrDone = AuthStateSignup | AuthStateLogin | AuthStateDone;
|
|
189
|
+
export type OAuthResponse = AuthStateSignupOrLoginOrDone;
|
|
190
|
+
export type AuthState = AuthStateVerify | AuthStateLogin | AuthStateSignup | AuthStateDone;
|
|
119
191
|
export type Verify2faParams = {
|
|
120
192
|
auth: VerifiedAuth;
|
|
121
193
|
verificationCode: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export interface Wallet {
|
|
1
|
+
import { IWalletEntity, PartnerEntity, TPregenIdentifierType, TWalletScheme, TWalletType } from '@getpara/user-management-client';
|
|
2
|
+
export interface Wallet extends Omit<IWalletEntity, 'createdAt' | 'updatedAt' | 'lastUsedAt' | 'scheme' | 'type' | 'userId' | 'keyGenComplete'> {
|
|
3
3
|
createdAt?: string;
|
|
4
4
|
id: string;
|
|
5
5
|
name?: string;
|
|
@@ -8,7 +8,7 @@ export interface Wallet {
|
|
|
8
8
|
addressSecondary?: string;
|
|
9
9
|
publicKey?: string;
|
|
10
10
|
scheme?: TWalletScheme;
|
|
11
|
-
type?:
|
|
11
|
+
type?: TWalletType;
|
|
12
12
|
isPregen?: boolean;
|
|
13
13
|
pregenIdentifier?: string;
|
|
14
14
|
pregenIdentifierType?: TPregenIdentifierType;
|
|
@@ -20,6 +20,9 @@ export interface Wallet {
|
|
|
20
20
|
lastUsedPartnerId?: string;
|
|
21
21
|
isExternal?: boolean;
|
|
22
22
|
isExternalWithParaAuth?: boolean;
|
|
23
|
+
externalProviderId?: string;
|
|
24
|
+
isExternalWithVerification?: boolean;
|
|
25
|
+
isExternalConnectionOnly?: boolean;
|
|
23
26
|
ensName?: string | null;
|
|
24
27
|
ensAvatar?: string | null;
|
|
25
28
|
}
|
|
@@ -39,4 +42,4 @@ export interface DeniedSignatureResWithUrl extends DeniedSignatureRes {
|
|
|
39
42
|
}
|
|
40
43
|
export type SignatureRes = SuccessfulSignatureRes | DeniedSignatureRes;
|
|
41
44
|
export type FullSignatureRes = SuccessfulSignatureRes | DeniedSignatureResWithUrl;
|
|
42
|
-
export type ExternalWalletConnectionType = 'NONE' | 'CONNECTION_ONLY' | 'AUTHENTICATED';
|
|
45
|
+
export type ExternalWalletConnectionType = 'NONE' | 'CONNECTION_ONLY' | 'AUTHENTICATED' | 'VERIFICATION';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { BalancesConfig } from '@getpara/user-management-client';
|
|
2
|
+
/**
|
|
3
|
+
* Validates if an object is a valid BalancesConfig
|
|
4
|
+
* @param obj - The object to validate
|
|
5
|
+
* @returns True if the object is a valid BalancesConfig, false otherwise
|
|
6
|
+
*/
|
|
7
|
+
export declare function validateBalancesConfig(obj: any): obj is BalancesConfig;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TWalletType } from '@getpara/user-management-client';
|
|
1
|
+
import { AssetValue, TWalletType } from '@getpara/user-management-client';
|
|
2
2
|
export type Hex = `0x${string}`;
|
|
3
3
|
export interface Signature {
|
|
4
4
|
r: Hex;
|
|
@@ -10,8 +10,19 @@ export declare function hexToSignature(hexSig: string): Signature;
|
|
|
10
10
|
export declare function hexToUint8Array(hex: string): Uint8Array;
|
|
11
11
|
export declare function hexToDecimal(hex: string): string;
|
|
12
12
|
export declare function decimalToHex(decimal: string): Hex;
|
|
13
|
+
export declare function compressPubkey(pubkey: Uint8Array): Uint8Array;
|
|
14
|
+
export declare function rawSecp256k1PubkeyToRawAddress(pubkeyData: Uint8Array): Uint8Array;
|
|
13
15
|
export declare function getCosmosAddress(publicKey: string, prefix: string): string;
|
|
14
16
|
export declare function truncateAddress(str: string, addressType: TWalletType, { prefix, targetLength, }?: {
|
|
15
17
|
prefix?: string;
|
|
16
18
|
targetLength?: number;
|
|
17
19
|
}): string;
|
|
20
|
+
export declare function formatCurrency(value?: AssetValue, { fallback }?: {
|
|
21
|
+
fallback?: string;
|
|
22
|
+
}): string;
|
|
23
|
+
export declare function formatAssetQuantity({ quantity, symbol, decimals, fallback, }: {
|
|
24
|
+
quantity?: number;
|
|
25
|
+
symbol?: string;
|
|
26
|
+
decimals?: number;
|
|
27
|
+
fallback?: string;
|
|
28
|
+
}): string;
|