@getpara/core-sdk 2.0.0-alpha.53 → 2.0.0-alpha.55

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.
Files changed (57) hide show
  1. package/dist/cjs/ParaCore.js +213 -60
  2. package/dist/cjs/constants.js +7 -1
  3. package/dist/cjs/index.js +5 -1
  4. package/dist/cjs/shares/enclave.js +266 -0
  5. package/dist/cjs/shares/shareDistribution.js +16 -1
  6. package/dist/cjs/types/assets.js +15 -0
  7. package/dist/cjs/types/events.js +2 -0
  8. package/dist/cjs/utils/config.js +108 -0
  9. package/dist/cjs/utils/formatting.js +42 -0
  10. package/dist/cjs/utils/index.js +2 -0
  11. package/dist/esm/ParaCore.js +214 -61
  12. package/dist/esm/{chunk-7B52C2XE.js → chunk-W5CT3TVS.js} +2 -0
  13. package/dist/esm/constants.js +6 -2
  14. package/dist/esm/cryptography/utils.js +1 -1
  15. package/dist/esm/errors.js +1 -1
  16. package/dist/esm/external/mpcComputationClient.js +1 -1
  17. package/dist/esm/external/userManagementClient.js +1 -1
  18. package/dist/esm/index.js +4 -2
  19. package/dist/esm/shares/KeyContainer.js +1 -1
  20. package/dist/esm/shares/enclave.js +226 -0
  21. package/dist/esm/shares/recovery.js +1 -1
  22. package/dist/esm/shares/shareDistribution.js +17 -2
  23. package/dist/esm/transmission/transmissionUtils.js +1 -1
  24. package/dist/esm/types/assets.js +0 -0
  25. package/dist/esm/types/auth.js +1 -1
  26. package/dist/esm/types/config.js +1 -1
  27. package/dist/esm/types/coreApi.js +1 -1
  28. package/dist/esm/types/events.js +3 -1
  29. package/dist/esm/types/popup.js +1 -1
  30. package/dist/esm/types/wallet.js +1 -1
  31. package/dist/esm/utils/autobind.js +1 -1
  32. package/dist/esm/utils/config.js +86 -0
  33. package/dist/esm/utils/events.js +1 -1
  34. package/dist/esm/utils/formatting.js +42 -1
  35. package/dist/esm/utils/index.js +1 -0
  36. package/dist/esm/utils/json.js +1 -1
  37. package/dist/esm/utils/listeners.js +1 -1
  38. package/dist/esm/utils/onRamps.js +1 -1
  39. package/dist/esm/utils/phone.js +1 -1
  40. package/dist/esm/utils/polling.js +1 -1
  41. package/dist/esm/utils/types.js +1 -1
  42. package/dist/esm/utils/url.js +1 -1
  43. package/dist/esm/utils/wallet.js +1 -1
  44. package/dist/types/ParaCore.d.ts +15 -2
  45. package/dist/types/constants.d.ts +2 -0
  46. package/dist/types/index.d.ts +4 -2
  47. package/dist/types/shares/enclave.d.ts +81 -0
  48. package/dist/types/shares/shareDistribution.d.ts +4 -2
  49. package/dist/types/types/assets.d.ts +14 -0
  50. package/dist/types/types/config.d.ts +2 -0
  51. package/dist/types/types/coreApi.d.ts +1 -0
  52. package/dist/types/types/events.d.ts +7 -2
  53. package/dist/types/types/methods.d.ts +15 -7
  54. package/dist/types/utils/config.d.ts +7 -0
  55. package/dist/types/utils/formatting.d.ts +10 -1
  56. package/dist/types/utils/index.d.ts +1 -0
  57. package/package.json +3 -3
@@ -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
+ };
@@ -1,5 +1,6 @@
1
1
  import { AxiosInstance } from 'axios';
2
2
  import Client, { EmailTheme, Network, OnRampAsset, OnRampProvider, PregenAuth, TWalletScheme, TWalletType, Theme } from '@getpara/user-management-client';
3
+ import { EnclaveClient } from '../shares/enclave.js';
3
4
  export declare enum Environment {
4
5
  DEV = "DEV",
5
6
  SANDBOX = "SANDBOX",
@@ -12,6 +13,7 @@ export interface Ctx {
12
13
  env: Environment;
13
14
  apiKey: string;
14
15
  client: Client;
16
+ enclaveClient?: EnclaveClient;
15
17
  disableWorkers?: boolean;
16
18
  offloadMPCComputationURL?: string;
17
19
  mpcComputationClient?: AxiosInstance;
@@ -118,6 +118,7 @@ export type CoreMethods = Record<CoreMethodName, {
118
118
  getOAuthUrl: {
119
119
  params: OAuthUrlParams & {
120
120
  sessionLookupId?: string;
121
+ encryptionKey?: string;
121
122
  };
122
123
  response: string;
123
124
  };
@@ -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,4 +1,4 @@
1
- import { PrimaryAuthInfo, ServerAuthStateLogin, ServerAuthStateSignup, AuthMethod, ServerAuthStateVerify, VerifiedAuth, AuthExtras, RecoveryStatus, Theme, TOAuthMethod, TWalletType, TelegramAuthResponse } from '@getpara/user-management-client';
1
+ import { PrimaryAuthInfo, ServerAuthStateLogin, ServerAuthStateSignup, AuthMethod, ServerAuthStateVerify, VerifiedAuth, AuthExtras, RecoveryStatus, Theme, TOAuthMethod, TWalletType, TelegramAuthResponse, VerifyThirdPartyAuth, ServerAuthStateDone } from '@getpara/user-management-client';
2
2
  import { Wallet } from './wallet.js';
3
3
  type Device = {
4
4
  sessionId: string;
@@ -12,7 +12,7 @@ export type VerifyExternalWalletV1 = {
12
12
  cosmosPublicKeyHex?: string;
13
13
  cosmosSigner?: string;
14
14
  };
15
- export type PortalUrlType = 'createAuth' | 'createPassword' | 'loginAuth' | 'loginPassword' | 'txReview' | 'onRamp' | 'telegramLogin' | 'createPIN' | 'loginPIN';
15
+ export type PortalUrlType = 'createAuth' | 'createPassword' | 'loginAuth' | 'loginPassword' | 'txReview' | 'onRamp' | 'telegramLogin' | 'createPIN' | 'loginPIN' | 'oAuth' | 'oAuthCallback' | 'loginOTP' | 'telegramLoginVerify' | 'loginFarcaster';
16
16
  export type PortalUrlOptions = {
17
17
  params?: Record<string, string | undefined | null>;
18
18
  isForNewDevice?: boolean;
@@ -23,6 +23,9 @@ export type PortalUrlOptions = {
23
23
  pathId?: string;
24
24
  shorten?: boolean;
25
25
  isEmbedded?: boolean;
26
+ oAuthMethod?: OAuthUrlParams['method'];
27
+ appScheme?: string;
28
+ encryptionKey?: string;
26
29
  };
27
30
  export type WithAuthMethod = {
28
31
  /**
@@ -74,12 +77,14 @@ export type FarcasterParams = PollParams & {
74
77
  * You will need to display the URI as a QR code.
75
78
  */
76
79
  onConnectUri?: (uri: string) => void;
80
+ serverAuthState?: VerifyThirdPartyAuth;
77
81
  };
78
82
  export type TelegramParams = {
79
83
  /**
80
84
  * The response received from the Telegram login bot.
81
85
  */
82
- telegramAuthResponse: TelegramAuthResponse;
86
+ telegramAuthResponse?: TelegramAuthResponse;
87
+ serverAuthState?: VerifyThirdPartyAuth;
83
88
  };
84
89
  export type LoginUrlParams = WithAuthMethod & WithCustomTheme & WithShorten & {
85
90
  sessionId?: string;
@@ -121,7 +126,9 @@ export type OAuthParams = OAuthUrlParams & PollParams & {
121
126
  onOAuthPopup?: (popup: Window) => void;
122
127
  };
123
128
  export type AuthStateBaseParams = WithCustomTheme & WithUseShortUrls;
124
- export type AuthStateVerify = ServerAuthStateVerify;
129
+ export type AuthStateVerify = ServerAuthStateVerify & {
130
+ loginUrl?: string;
131
+ };
125
132
  export type AuthStateLogin = Omit<ServerAuthStateLogin, 'loginAuthMethods'> & WithIsPasskeySupported & {
126
133
  /**
127
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.
@@ -166,10 +173,11 @@ export type AuthStateSignup = Omit<ServerAuthStateSignup, 'signupAuthMethods'> &
166
173
  */
167
174
  pinId?: string;
168
175
  };
176
+ export type AuthStateDone = ServerAuthStateDone;
169
177
  export type AuthStateVerifyOrLogin = AuthStateVerify | AuthStateLogin;
170
- export type AuthStateSignupOrLogin = AuthStateSignup | AuthStateLogin;
171
- export type OAuthResponse = AuthStateSignupOrLogin;
172
- export type AuthState = AuthStateVerify | AuthStateLogin | AuthStateSignup;
178
+ export type AuthStateSignupOrLoginOrDone = AuthStateSignup | AuthStateLogin | AuthStateDone;
179
+ export type OAuthResponse = AuthStateSignupOrLoginOrDone;
180
+ export type AuthState = AuthStateVerify | AuthStateLogin | AuthStateSignup | AuthStateDone;
173
181
  export type Verify2faParams = {
174
182
  auth: VerifiedAuth;
175
183
  verificationCode: string;
@@ -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;
@@ -17,3 +17,12 @@ export declare function truncateAddress(str: string, addressType: TWalletType, {
17
17
  prefix?: string;
18
18
  targetLength?: number;
19
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;
@@ -1,4 +1,5 @@
1
1
  export * from './autobind.js';
2
+ export * from './config.js';
2
3
  export * from './events.js';
3
4
  export * from './formatting.js';
4
5
  export * from './json.js';
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@getpara/core-sdk",
3
- "version": "2.0.0-alpha.53",
3
+ "version": "2.0.0-alpha.55",
4
4
  "dependencies": {
5
5
  "@celo/utils": "^8.0.2",
6
6
  "@cosmjs/encoding": "^0.32.4",
7
7
  "@ethereumjs/util": "^9.1.0",
8
- "@getpara/user-management-client": "2.0.0-alpha.53",
8
+ "@getpara/user-management-client": "2.0.0-alpha.55",
9
9
  "@noble/hashes": "^1.5.0",
10
10
  "base64url": "^3.0.1",
11
11
  "libphonenumber-js": "^1.11.7",
@@ -27,7 +27,7 @@
27
27
  "dist",
28
28
  "package.json"
29
29
  ],
30
- "gitHead": "ad18fa268a41b0e4c080fa8349553fb546983513",
30
+ "gitHead": "370bc842fc70118826e3b75815ba923c50f28100",
31
31
  "main": "dist/cjs/index.js",
32
32
  "module": "dist/esm/index.js",
33
33
  "scripts": {