@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.
Files changed (66) hide show
  1. package/dist/cjs/ParaCore.js +1516 -382
  2. package/dist/cjs/constants.js +13 -1
  3. package/dist/cjs/index.js +35 -3
  4. package/dist/cjs/shares/KeyContainer.js +3 -3
  5. package/dist/cjs/shares/enclave.js +266 -0
  6. package/dist/cjs/shares/shareDistribution.js +16 -1
  7. package/dist/cjs/transmission/transmissionUtils.js +4 -3
  8. package/dist/cjs/types/{theme.js → assets.js} +2 -2
  9. package/dist/cjs/types/{onRamps.js → auth.js} +12 -12
  10. package/dist/cjs/types/coreApi.js +23 -3
  11. package/dist/cjs/types/events.js +2 -0
  12. package/dist/cjs/types/index.js +2 -21
  13. package/dist/cjs/types/popup.js +1 -0
  14. package/dist/cjs/utils/config.js +108 -0
  15. package/dist/cjs/utils/formatting.js +4 -0
  16. package/dist/cjs/utils/index.js +5 -1
  17. package/dist/cjs/utils/onRamps.js +2 -3
  18. package/dist/cjs/utils/wallet.js +18 -0
  19. package/dist/cjs/{types/recovery.js → utils/window.js} +17 -13
  20. package/dist/esm/ParaCore.js +1525 -388
  21. package/dist/esm/constants.js +9 -1
  22. package/dist/esm/index.js +36 -5
  23. package/dist/esm/shares/KeyContainer.js +3 -3
  24. package/dist/esm/shares/enclave.js +226 -0
  25. package/dist/esm/shares/shareDistribution.js +16 -1
  26. package/dist/esm/transmission/transmissionUtils.js +4 -3
  27. package/dist/esm/types/auth.js +11 -0
  28. package/dist/esm/types/coreApi.js +21 -2
  29. package/dist/esm/types/events.js +2 -0
  30. package/dist/esm/types/index.js +1 -16
  31. package/dist/esm/types/popup.js +1 -0
  32. package/dist/esm/utils/config.js +86 -0
  33. package/dist/esm/utils/formatting.js +2 -0
  34. package/dist/esm/utils/index.js +2 -0
  35. package/dist/esm/utils/onRamps.js +2 -3
  36. package/dist/esm/utils/wallet.js +17 -0
  37. package/dist/esm/utils/window.js +16 -0
  38. package/dist/types/ParaCore.d.ts +142 -57
  39. package/dist/types/PlatformUtils.d.ts +2 -3
  40. package/dist/types/constants.d.ts +18 -14
  41. package/dist/types/index.d.ts +6 -4
  42. package/dist/types/shares/KeyContainer.d.ts +0 -2
  43. package/dist/types/shares/enclave.d.ts +81 -0
  44. package/dist/types/shares/shareDistribution.d.ts +4 -2
  45. package/dist/types/types/assets.d.ts +14 -0
  46. package/dist/types/types/auth.d.ts +16 -0
  47. package/dist/types/types/config.d.ts +11 -2
  48. package/dist/types/types/coreApi.d.ts +133 -37
  49. package/dist/types/types/events.d.ts +7 -2
  50. package/dist/types/types/index.d.ts +1 -4
  51. package/dist/types/types/methods.d.ts +94 -15
  52. package/dist/types/types/popup.d.ts +2 -1
  53. package/dist/types/types/wallet.d.ts +11 -4
  54. package/dist/types/utils/config.d.ts +7 -0
  55. package/dist/types/utils/formatting.d.ts +2 -0
  56. package/dist/types/utils/index.d.ts +2 -0
  57. package/dist/types/utils/onRamps.d.ts +9 -10
  58. package/dist/types/utils/wallet.d.ts +1 -0
  59. package/dist/types/utils/window.d.ts +2 -0
  60. package/package.json +23 -23
  61. package/dist/esm/types/onRamps.js +0 -11
  62. package/dist/esm/types/recovery.js +0 -12
  63. package/dist/types/types/onRamps.d.ts +0 -10
  64. package/dist/types/types/recovery.d.ts +0 -7
  65. package/dist/types/types/theme.d.ts +0 -12
  66. /package/dist/esm/types/{theme.js → assets.js} +0 -0
@@ -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 { Theme } from './theme.js';
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, TelegramAuthResponse, VerifiedAuth, VerifyExternalWalletParams, WalletEntity, WalletParams, TWalletType } from '@getpara/user-management-client';
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, AuthMethod, ServerAuthStateSignup, ServerAuthStateLogin, ServerAuthStateDone } 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, NewCredentialUrlParams, AuthStateDone } from './methods.js';
3
3
  import { ParaCore } from '../ParaCore.js';
4
4
  import { FullSignatureRes, Wallet } from './wallet.js';
5
- 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"];
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", "addCredential", "exportPrivateKey"];
7
+ export declare const PARA_INTERNAL_METHODS: readonly ["linkAccount", "unlinkAccount", "verifyEmailOrPhoneLink", "verifyOAuthLink", "verifyFarcasterLink", "verifyTelegramLink", "verifyExternalWalletLink", "accountLinkInProgress", "prepareLogin", "sendLoginCode", "supportedUserAuthMethods"];
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,13 @@ export type CoreMethods = Record<CoreMethodName, {
94
118
  getOAuthUrl: {
95
119
  params: OAuthUrlParams & {
96
120
  sessionLookupId?: string;
121
+ encryptionKey?: string;
122
+ portalCallbackParams?: Record<string, string>;
97
123
  };
98
124
  response: string;
99
125
  };
100
126
  verifyOAuth: {
101
- params: AuthStateBaseParams & OAuthUrlParams & PollParams & {
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
- };
127
+ params: AuthStateBaseParams & OAuthParams;
112
128
  response: OAuthResponse;
113
129
  };
114
130
  getFarcasterConnectUri: {
@@ -116,26 +132,11 @@ export type CoreMethods = Record<CoreMethodName, {
116
132
  response: string;
117
133
  };
118
134
  verifyFarcaster: {
119
- params: AuthStateBaseParams & PollParams & {
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
- };
135
+ params: AuthStateBaseParams & FarcasterParams;
130
136
  response: OAuthResponse;
131
137
  };
132
138
  verifyTelegram: {
133
- params: AuthStateBaseParams & {
134
- /**
135
- * The response received from the Telegram login bot.
136
- */
137
- telegramAuthResponse: TelegramAuthResponse;
138
- };
139
+ params: AuthStateBaseParams & TelegramParams;
139
140
  response: OAuthResponse;
140
141
  };
141
142
  loginExternalWallet: {
@@ -143,16 +144,30 @@ export type CoreMethods = Record<CoreMethodName, {
143
144
  /**
144
145
  * The external wallet information to use for login.
145
146
  */
146
- externalWallet: ExternalWalletInfo;
147
+ externalWallet: ExternalWalletInfo | ExternalWalletInfo[];
148
+ /**
149
+ * The chain ID used to generate the SIWE message.
150
+ */
151
+ chainId?: string;
152
+ /**
153
+ * The URI used to generate the SIWE message.
154
+ */
155
+ uri?: string;
147
156
  };
148
157
  response: AuthStateVerifyOrLogin;
149
158
  };
150
159
  verifyExternalWallet: {
151
- params: AuthStateBaseParams & VerifyExternalWalletParams;
152
- response: AuthStateSignup;
160
+ params: (AuthStateBaseParams & {
161
+ serverAuthState: ServerAuthStateSignup | ServerAuthStateLogin | ServerAuthStateDone;
162
+ }) | (AuthStateBaseParams & VerifyExternalWalletParams & {
163
+ serverAuthState?: undefined;
164
+ });
165
+ response: AuthStateSignup | AuthStateLogin | AuthStateDone;
153
166
  };
154
167
  resendVerificationCode: {
155
- params: void;
168
+ params: {
169
+ type?: 'SIGNUP' | 'LINK_ACCOUNT' | 'LOGIN';
170
+ } | undefined;
156
171
  response: void;
157
172
  };
158
173
  logout: {
@@ -469,7 +484,88 @@ export type CoreMethods = Record<CoreMethodName, {
469
484
  params: GetWalletBalanceParams;
470
485
  response: GetWalletBalanceResponse;
471
486
  };
487
+ issueJwt: {
488
+ params: IssueJwtParams;
489
+ response: IssueJwtResponse;
490
+ };
491
+ getLinkedAccounts: {
492
+ params: {
493
+ withMetadata?: boolean;
494
+ };
495
+ response: LinkedAccounts & {
496
+ userId: string;
497
+ };
498
+ };
499
+ addCredential: {
500
+ params: Pick<NewCredentialUrlParams, 'authMethod'>;
501
+ response: Promise<string>;
502
+ };
503
+ exportPrivateKey: {
504
+ params: {
505
+ walletId?: string;
506
+ shouldOpenPopup?: boolean;
507
+ } | undefined;
508
+ response: {
509
+ popupWindow?: Window;
510
+ url: string;
511
+ };
512
+ };
513
+ };
514
+ export type InternalMethods = {
515
+ linkAccount: {
516
+ params: {
517
+ auth: VerifiedAuth;
518
+ } | {
519
+ externalWallet: ExternalWalletInfo;
520
+ } | {
521
+ type: TLinkedAccountType | 'X';
522
+ };
523
+ response: AccountLinkInProgress;
524
+ };
525
+ unlinkAccount: {
526
+ params: {
527
+ linkedAccountId: string;
528
+ };
529
+ response: LinkedAccounts;
530
+ };
531
+ verifyEmailOrPhoneLink: {
532
+ params: {
533
+ verificationCode?: string;
534
+ };
535
+ response: LinkedAccounts;
536
+ };
537
+ verifyOAuthLink: {
538
+ params: OAuthParams;
539
+ response: LinkedAccounts;
540
+ };
541
+ verifyFarcasterLink: {
542
+ params: FarcasterParams;
543
+ response: LinkedAccounts;
544
+ };
545
+ verifyTelegramLink: {
546
+ params: TelegramParams;
547
+ response: LinkedAccounts;
548
+ };
549
+ verifyExternalWalletLink: {
550
+ params: Omit<VerifyExternalWalletParams, 'externalWallet'>;
551
+ response: LinkedAccounts;
552
+ };
553
+ prepareLogin: {
554
+ params: void;
555
+ response: string;
556
+ };
557
+ sendLoginCode: {
558
+ params: void;
559
+ response: void;
560
+ };
561
+ supportedUserAuthMethods: {
562
+ params: void;
563
+ response: Promise<Set<AuthMethod>>;
564
+ };
472
565
  };
473
566
  export type CoreInterface = {
474
- [key in keyof CoreMethods]: CoreMethod<key>;
567
+ [key in keyof CoreMethods]: Partial<CoreMethod<key>>;
568
+ };
569
+ export type InternalInterface = {
570
+ [key in keyof InternalMethods]: Partial<InternalMethod<key>>;
475
571
  };
@@ -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, TAuthMethod, 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' | 'switchWallets' | 'addNewCredential' | 'exportPrivateKey' | 'loginExternalWallet' | 'connectExternalWallet';
18
16
  export type PortalUrlOptions = {
19
17
  params?: Record<string, string | undefined | null>;
20
18
  isForNewDevice?: boolean;
@@ -24,12 +22,19 @@ 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;
29
+ addNewCredentialType?: TAuthMethod;
30
+ addNewCredentialPasswordId?: string;
31
+ addNewCredentialPasskeyId?: string;
27
32
  };
28
33
  export type WithAuthMethod = {
29
34
  /**
30
- * Which authorization method to use for the URL, either `'passkey'` or `'passwprd'`.
35
+ * Which authorization method to use for the URL, either `'PASSKEY'`, `'PASSWORD'` or `'PIN'`.
31
36
  */
32
- authMethod?: Uppercase<AuthMethod>;
37
+ authMethod?: Uppercase<TAuthMethod>;
33
38
  };
34
39
  export type WithCustomTheme = {
35
40
  /**
@@ -49,6 +54,12 @@ export type WithShorten = {
49
54
  */
50
55
  shorten?: boolean;
51
56
  };
57
+ export type WithIsPasskeySupported = {
58
+ /**
59
+ * Whether the current device supports WebAuth passkeys.
60
+ */
61
+ isPasskeySupported: boolean;
62
+ };
52
63
  export type PollParams = {
53
64
  /**
54
65
  * A callback function that will be invoked on each method poll.
@@ -59,14 +70,37 @@ export type PollParams = {
59
70
  */
60
71
  onCancel?: () => void;
61
72
  };
73
+ export type FarcasterParams = PollParams & {
74
+ /**
75
+ * A function returning a boolean, indicating whether the Farcaster login process should be cancelled.
76
+ */
77
+ isCanceled?: () => boolean;
78
+ /**
79
+ * A callback function that will be invoked with the Farcaster Connect URI when it is available.
80
+ * You will need to display the URI as a QR code.
81
+ */
82
+ onConnectUri?: (uri: string) => void;
83
+ serverAuthState?: VerifyThirdPartyAuth;
84
+ };
85
+ export type TelegramParams = {
86
+ /**
87
+ * The response received from the Telegram login bot.
88
+ */
89
+ telegramAuthResponse?: TelegramAuthResponse;
90
+ serverAuthState?: VerifyThirdPartyAuth;
91
+ };
62
92
  export type LoginUrlParams = WithAuthMethod & WithCustomTheme & WithShorten & {
63
93
  sessionId?: string;
64
94
  };
65
- export type NewCredentialUrlParams = WithAuthMethod & WithCustomTheme & WithShorten & {
95
+ export type NewCredentialUrlParams = WithCustomTheme & WithShorten & {
66
96
  /**
67
97
  * Whether the URL is meant to add a passkey for a previous user on a new device. Defaults to `false`.
68
98
  */
69
99
  isForNewDevice?: boolean;
100
+ /**
101
+ * The authentication method to add.
102
+ */
103
+ authMethod?: TAuthMethod;
70
104
  };
71
105
  export type OAuthUrlParams = {
72
106
  /**
@@ -74,13 +108,35 @@ export type OAuthUrlParams = {
74
108
  */
75
109
  method: Exclude<TOAuthMethod, 'TELEGRAM' | 'FARCASTER'>;
76
110
  /**
77
- * The deeplink URL to redirect to after OAuth is complete.
111
+ * The app scheme to redirect to after OAuth is complete.
112
+ */
113
+ appScheme?: string;
114
+ };
115
+ export type OAuthParams = OAuthUrlParams & PollParams & {
116
+ /**
117
+ * A function returning a boolean, indicating whether the OAuth process should be cancelled.
78
118
  */
79
- deeplinkUrl?: string;
119
+ isCanceled?: () => boolean;
120
+ /**
121
+ * A callback function that will be invoked with the OAuth URL when it is available.
122
+ * For example, you can use this to open the URL in a new window or tab.
123
+ *
124
+ * You should pass one of `onOAuthUrl` or `onOAuthPopup`, not both.
125
+ */
126
+ onOAuthUrl?: (url: string) => void;
127
+ /**
128
+ * A callback function that will be invoked with the OAuth popup window when it is available.
129
+ * If supplied, a window will automatically be opened for you if running on an applicable platform.
130
+ *
131
+ * You should pass one of `onOAuthUrl` or `onOAuthPopup`, not both.
132
+ */
133
+ onOAuthPopup?: (popup: Window) => void;
80
134
  };
81
135
  export type AuthStateBaseParams = WithCustomTheme & WithUseShortUrls;
82
- export type AuthStateVerify = ServerAuthStateVerify;
83
- export type AuthStateLogin = Omit<ServerAuthStateLogin, 'loginAuthMethods'> & {
136
+ export type AuthStateVerify = ServerAuthStateVerify & {
137
+ loginUrl?: string;
138
+ };
139
+ export type AuthStateLogin = Omit<ServerAuthStateLogin, 'loginAuthMethods'> & WithIsPasskeySupported & {
84
140
  /**
85
141
  * 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
142
  */
@@ -93,8 +149,16 @@ export type AuthStateLogin = Omit<ServerAuthStateLogin, 'loginAuthMethods'> & {
93
149
  * A Para Portal URL for logging in via a password.
94
150
  */
95
151
  passwordUrl?: string;
152
+ /**
153
+ * A Para Portal URL for logging in via a PIN.
154
+ */
155
+ pinUrl?: string;
156
+ /**
157
+ * Supported login auth methods for this session.
158
+ */
159
+ loginAuthMethods?: TAuthMethod[];
96
160
  };
97
- export type AuthStateSignup = Omit<ServerAuthStateSignup, 'signupAuthMethods'> & {
161
+ export type AuthStateSignup = Omit<ServerAuthStateSignup, 'signupAuthMethods'> & WithIsPasskeySupported & {
98
162
  /**
99
163
  * A Para Portal URL for creating a new WebAuth passkey.
100
164
  */
@@ -103,6 +167,10 @@ export type AuthStateSignup = Omit<ServerAuthStateSignup, 'signupAuthMethods'> &
103
167
  * A Para Portal URL for creating a new user password.
104
168
  */
105
169
  passwordUrl?: string;
170
+ /**
171
+ * A Para Portal URL for creating a new user PIN.
172
+ */
173
+ pinUrl?: string;
106
174
  /**
107
175
  * The Para system ID for the newly generated passkey.
108
176
  */
@@ -111,11 +179,22 @@ export type AuthStateSignup = Omit<ServerAuthStateSignup, 'signupAuthMethods'> &
111
179
  * The Para system ID for the newly generated password.
112
180
  */
113
181
  passwordId?: string;
182
+ /**
183
+ * The Para system ID for the newly generated PIN.
184
+ */
185
+ pinId?: string;
186
+ /**
187
+ * Supported signup auth methods for this session.
188
+ */
189
+ signupAuthMethods?: TAuthMethod[];
190
+ };
191
+ export type AuthStateDone = Omit<ServerAuthStateDone, 'authMethods'> & {
192
+ authMethods: TAuthMethod[];
114
193
  };
115
194
  export type AuthStateVerifyOrLogin = AuthStateVerify | AuthStateLogin;
116
- export type AuthStateSignupOrLogin = AuthStateSignup | AuthStateLogin;
117
- export type OAuthResponse = AuthStateSignupOrLogin;
118
- export type AuthState = AuthStateVerify | AuthStateLogin | AuthStateSignup;
195
+ export type AuthStateSignupOrLoginOrDone = AuthStateSignup | AuthStateLogin | AuthStateDone;
196
+ export type OAuthResponse = AuthStateSignupOrLoginOrDone;
197
+ export type AuthState = AuthStateVerify | AuthStateLogin | AuthStateSignup | AuthStateDone;
119
198
  export type Verify2faParams = {
120
199
  auth: VerifiedAuth;
121
200
  verificationCode: string;
@@ -4,5 +4,6 @@ export declare enum PopupType {
4
4
  LOGIN_PASSKEY = "LOGIN_PASSKEY",
5
5
  CREATE_PASSKEY = "CREATE_PASSKEY",
6
6
  OAUTH = "OAUTH",
7
- ON_RAMP_TRANSACTION = "ON_RAMP_TRANSACTION"
7
+ ON_RAMP_TRANSACTION = "ON_RAMP_TRANSACTION",
8
+ EXPORT_PRIVATE_KEY = "EXPORT_PRIVATE_KEY"
8
9
  }
@@ -1,5 +1,5 @@
1
- import { EmbeddedWalletType, ExternalWalletType, PartnerEntity, TPregenIdentifierType, TWalletScheme } from '@getpara/user-management-client';
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' | 'sharesPersisted'> {
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?: EmbeddedWalletType | ExternalWalletType;
11
+ type?: TWalletType;
12
12
  isPregen?: boolean;
13
13
  pregenIdentifier?: string;
14
14
  pregenIdentifierType?: TPregenIdentifierType;
@@ -20,9 +20,16 @@ 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
  }
29
+ export type AvailableWallet = Pick<Wallet, 'id' | 'type' | 'name' | 'address' | 'partner' | 'ensName' | 'ensAvatar' | 'isExternal' | 'externalProviderId' | 'isExternalConnectionOnly'> & {
30
+ addressShort?: string;
31
+ displayName?: string;
32
+ };
26
33
  /** @deprecated */
27
34
  export declare enum PregenIdentifierType {
28
35
  EMAIL = "EMAIL",
@@ -39,4 +46,4 @@ export interface DeniedSignatureResWithUrl extends DeniedSignatureRes {
39
46
  }
40
47
  export type SignatureRes = SuccessfulSignatureRes | DeniedSignatureRes;
41
48
  export type FullSignatureRes = SuccessfulSignatureRes | DeniedSignatureResWithUrl;
42
- export type ExternalWalletConnectionType = 'NONE' | 'CONNECTION_ONLY' | 'AUTHENTICATED';
49
+ 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;
@@ -10,6 +10,8 @@ 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;
@@ -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';
@@ -9,3 +10,4 @@ export * from './polling.js';
9
10
  export * from './types.js';
10
11
  export * from './url.js';
11
12
  export * from './wallet.js';
13
+ export * from './window.js';
@@ -1,19 +1,18 @@
1
- import { Network, OnRampAsset, OnRampProvider, OnRampPurchaseType, TWalletType } from '@getpara/user-management-client';
2
- import { OnRampAssetInfoRow, OnRampAssetInfo } from '../types/index.js';
1
+ import { TNetwork, TOnRampAsset, OnRampProvider, OnRampPurchaseType, OnRampAssetInfoRow, OnRampAssetInfo, TWalletType } from '@getpara/user-management-client';
3
2
  export declare function toAssetInfoArray(data: OnRampAssetInfo): OnRampAssetInfoRow[];
4
3
  export declare function getOnRampNetworks(data: OnRampAssetInfo, { walletType, allowed, assets, providers, action, }?: {
5
4
  walletType?: TWalletType;
6
- allowed?: Network[];
7
- assets?: OnRampAsset[];
5
+ allowed?: TNetwork[];
6
+ assets?: TOnRampAsset[];
8
7
  providers?: OnRampProvider[];
9
8
  action?: OnRampPurchaseType;
10
- }): Network[];
9
+ }): TNetwork[];
11
10
  export declare function getOnRampAssets(data: OnRampAssetInfo, { walletType, network, allowed, providers, action, }?: {
12
11
  walletType?: TWalletType;
13
- network?: Network;
14
- allowed?: OnRampAsset[];
12
+ network?: TNetwork;
13
+ allowed?: TOnRampAsset[];
15
14
  providers?: OnRampProvider[];
16
15
  action?: OnRampPurchaseType;
17
- }): OnRampAsset[];
18
- export declare const NETWORK_PREFIXES: Partial<Record<Network, string>>;
19
- export declare function getNetworkPrefix(network: Network): string | undefined;
16
+ }): TOnRampAsset[];
17
+ export declare const NETWORK_PREFIXES: Partial<Record<TNetwork, string>>;
18
+ export declare function getNetworkPrefix(network: TNetwork): string | undefined;
@@ -11,3 +11,4 @@ export declare function migrateWallet(obj: Record<string, unknown>): Wallet;
11
11
  export declare function supportedWalletTypesEq(a: SupportedWalletTypes, b: SupportedWalletTypes): boolean;
12
12
  export declare function mergeCurrentWalletIds(original: CurrentWalletIds, additional: CurrentWalletIds): CurrentWalletIds;
13
13
  export declare function newUuid(): string;
14
+ export declare function currentWalletIdsEq(a: CurrentWalletIds | undefined, b: CurrentWalletIds | undefined): boolean;
@@ -0,0 +1,2 @@
1
+ import { Ctx, Environment } from '../types/index.js';
2
+ export declare function isPortal(ctx: Ctx, env?: Environment): boolean;