@getpara/core-sdk 2.0.0-alpha.3 → 2.0.0-alpha.30

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 (97) hide show
  1. package/dist/cjs/ParaCore.js +3378 -0
  2. package/dist/cjs/PlatformUtils.js +15 -0
  3. package/dist/cjs/StorageUtils.js +15 -0
  4. package/dist/cjs/constants.js +87 -0
  5. package/dist/cjs/cryptography/utils.js +350 -0
  6. package/dist/cjs/errors.js +51 -0
  7. package/dist/cjs/external/mpcComputationClient.js +62 -0
  8. package/dist/cjs/external/userManagementClient.js +106 -0
  9. package/dist/cjs/index.js +100 -3998
  10. package/dist/cjs/package.json +3 -0
  11. package/dist/cjs/shares/KeyContainer.js +89 -0
  12. package/dist/cjs/shares/recovery.js +127 -0
  13. package/dist/cjs/shares/shareDistribution.js +104 -0
  14. package/dist/cjs/transmission/transmissionUtils.js +93 -0
  15. package/dist/cjs/types/auth.js +33 -0
  16. package/dist/cjs/types/config.js +43 -0
  17. package/dist/cjs/types/coreApi.js +89 -0
  18. package/dist/cjs/types/events.js +41 -0
  19. package/dist/cjs/types/index.js +54 -0
  20. package/dist/cjs/types/methods.js +15 -0
  21. package/dist/cjs/types/onRamps.js +33 -0
  22. package/dist/cjs/types/popup.js +35 -0
  23. package/dist/cjs/types/recovery.js +34 -0
  24. package/dist/cjs/types/theme.js +15 -0
  25. package/dist/cjs/types/wallet.js +31 -0
  26. package/dist/cjs/utils/autobind.js +41 -0
  27. package/dist/cjs/utils/events.js +45 -0
  28. package/dist/cjs/utils/formatting.js +116 -0
  29. package/dist/cjs/utils/index.js +41 -0
  30. package/dist/cjs/utils/json.js +37 -0
  31. package/dist/cjs/utils/listeners.js +71 -0
  32. package/dist/cjs/utils/onRamps.js +92 -0
  33. package/dist/cjs/utils/phone.js +73 -0
  34. package/dist/cjs/utils/polling.js +58 -0
  35. package/dist/cjs/utils/types.js +29 -0
  36. package/dist/cjs/utils/url.js +135 -0
  37. package/dist/cjs/utils/wallet.js +159 -0
  38. package/dist/esm/ParaCore.js +3343 -0
  39. package/dist/esm/PlatformUtils.js +0 -0
  40. package/dist/esm/StorageUtils.js +0 -0
  41. package/dist/esm/chunk-7B52C2XE.js +70 -0
  42. package/dist/esm/constants.js +45 -0
  43. package/dist/esm/cryptography/utils.js +282 -0
  44. package/dist/esm/errors.js +27 -0
  45. package/dist/esm/external/mpcComputationClient.js +30 -0
  46. package/dist/esm/external/userManagementClient.js +71 -0
  47. package/dist/esm/index.js +74 -3963
  48. package/dist/esm/package.json +4 -0
  49. package/dist/esm/shares/KeyContainer.js +57 -0
  50. package/dist/esm/shares/recovery.js +74 -0
  51. package/dist/esm/shares/shareDistribution.js +64 -0
  52. package/dist/esm/transmission/transmissionUtils.js +42 -0
  53. package/dist/esm/types/auth.js +11 -0
  54. package/dist/esm/types/config.js +20 -0
  55. package/dist/esm/types/coreApi.js +66 -0
  56. package/dist/esm/types/events.js +19 -0
  57. package/dist/esm/types/index.js +23 -0
  58. package/dist/esm/types/methods.js +0 -0
  59. package/dist/esm/types/onRamps.js +11 -0
  60. package/dist/esm/types/popup.js +13 -0
  61. package/dist/esm/types/recovery.js +12 -0
  62. package/dist/esm/types/theme.js +0 -0
  63. package/dist/esm/types/wallet.js +9 -0
  64. package/dist/esm/utils/autobind.js +19 -0
  65. package/dist/esm/utils/events.js +11 -0
  66. package/dist/esm/utils/formatting.js +76 -0
  67. package/dist/esm/utils/index.js +11 -0
  68. package/dist/esm/utils/json.js +15 -0
  69. package/dist/esm/utils/listeners.js +38 -0
  70. package/dist/esm/utils/onRamps.js +66 -0
  71. package/dist/esm/utils/phone.js +39 -0
  72. package/dist/esm/utils/polling.js +18 -0
  73. package/dist/esm/utils/types.js +7 -0
  74. package/dist/esm/utils/url.js +90 -0
  75. package/dist/esm/utils/wallet.js +103 -0
  76. package/dist/types/ParaCore.d.ts +178 -133
  77. package/dist/types/PlatformUtils.d.ts +4 -5
  78. package/dist/types/constants.d.ts +16 -13
  79. package/dist/types/index.d.ts +3 -3
  80. package/dist/types/shares/KeyContainer.d.ts +0 -2
  81. package/dist/types/types/auth.d.ts +16 -0
  82. package/dist/types/types/config.d.ts +12 -5
  83. package/dist/types/types/coreApi.d.ts +134 -40
  84. package/dist/types/types/events.d.ts +4 -1
  85. package/dist/types/types/index.d.ts +1 -0
  86. package/dist/types/types/methods.d.ts +49 -9
  87. package/dist/types/types/onRamps.d.ts +3 -3
  88. package/dist/types/types/wallet.d.ts +8 -3
  89. package/dist/types/utils/formatting.d.ts +5 -2
  90. package/dist/types/utils/onRamps.d.ts +12 -5
  91. package/dist/types/utils/phone.d.ts +4 -0
  92. package/dist/types/utils/wallet.d.ts +8 -7
  93. package/package.json +26 -26
  94. package/dist/cjs/index.js.br +0 -0
  95. package/dist/cjs/index.js.gz +0 -0
  96. package/dist/esm/index.js.br +0 -0
  97. package/dist/esm/index.js.gz +0 -0
@@ -1,5 +1,5 @@
1
1
  import { AxiosInstance } from 'axios';
2
- import Client, { EmailTheme, Network, OnRampAsset, OnRampProvider, WalletScheme, WalletType } from '@getpara/user-management-client';
2
+ import Client, { EmailTheme, Network, OnRampAsset, OnRampProvider, PregenAuth, TWalletScheme, TWalletType } from '@getpara/user-management-client';
3
3
  import { Theme } from './theme.js';
4
4
  export declare enum Environment {
5
5
  DEV = "DEV",
@@ -25,11 +25,9 @@ export interface Ctx {
25
25
  }
26
26
  export type deprecated__NetworkProp = keyof typeof Network | Network;
27
27
  export type deprecated__OnRampProviderProp = keyof typeof OnRampProvider | OnRampProvider;
28
- export type WalletTypeProp = keyof typeof WalletType | WalletType;
29
- export type WalletSchemeProp = keyof typeof WalletScheme | WalletScheme;
30
28
  export type WalletFilters = {
31
- type?: WalletTypeProp[];
32
- scheme?: WalletSchemeProp[];
29
+ type?: TWalletType[];
30
+ scheme?: TWalletScheme[];
33
31
  forbidPregen?: boolean;
34
32
  };
35
33
  export type deprecated__RampConfig = {
@@ -58,6 +56,7 @@ export type SupportedWalletTypeConfig = {
58
56
  optional?: boolean;
59
57
  };
60
58
  export interface ConstructorOpts {
59
+ externalWalletConnectionOnly?: boolean;
61
60
  useStorageOverrides?: boolean;
62
61
  disableWorkers?: boolean;
63
62
  offloadMPCComputationURL?: string;
@@ -141,4 +140,12 @@ export interface ConstructorOpts {
141
140
  * Partner ID set in the Para Portal to track analytics for legacy SDK versions. This variable is unused outside of the Para Portal.
142
141
  */
143
142
  portalPartnerId?: string;
143
+ /**
144
+ * An optional function that fetches the pregenerated wallets for a given identifier so a user can claim them on account creation.
145
+ */
146
+ fetchPregenWalletsOverride?: (opts: {
147
+ pregenId: PregenAuth;
148
+ }) => Promise<{
149
+ userShare?: string;
150
+ }>;
144
151
  }
@@ -1,24 +1,53 @@
1
- import { BackupKitEmailProps, CurrentWalletIds, ExternalWalletInfo, OnRampPurchase, OnRampPurchaseCreateParams, PregenAuth, Setup2faResponse, TelegramAuthResponse, VerifiedAuth, VerifyExternalWalletParams, WalletEntity, WalletParams, WalletType } from '@getpara/user-management-client';
2
- import { AuthStateLogin, AuthStateVerify, OAuthResponse, AuthStateBaseParams, WithCustomTheme, WithUseShortUrls, Verify2faResponse, AuthStateSignup, AuthStateVerifyOrLogin, OAuthUrlParams, StorageType, PollParams } 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
- export declare const PARA_CORE_METHODS: readonly ["signUpOrLogIn", "verifyNewAccount", "waitForLogin", "waitForSignup", "waitForWalletCreation", "verifyOAuth", "verifyFarcaster", "verifyTelegram", "resendVerificationCode", "loginExternalWallet", "verifyExternalWallet", "setup2fa", "enable2fa", "verify2fa", "logout", "clearStorage", "isSessionActive", "isFullyLoggedIn", "refreshSession", "keepSessionAlive", "exportSession", "importSession", "getVerificationToken", "fetchWallets", "createWallet", "createWalletPerType", "getPregenWallets", "hasPregenWallet", "updatePregenWalletIdentifier", "createPregenWallet", "createPregenWalletPerType", "claimPregenWallets", "distributeNewWalletShare", "getUserShare", "setUserShare", "refreshShare", "signMessage", "signTransaction", "initiateOnRampTransaction"];
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"];
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
+ };
46
+ getAuthInfo: {
47
+ params: void;
48
+ response: CoreAuthInfo | undefined;
49
+ sync: true;
50
+ };
22
51
  signUpOrLogIn: {
23
52
  params: WithCustomTheme & WithUseShortUrls & {
24
53
  /**
@@ -86,41 +115,26 @@ export type CoreMethods = Record<CoreMethodName, {
86
115
  recoverySecret?: string;
87
116
  };
88
117
  };
89
- verifyOAuth: {
90
- params: AuthStateBaseParams & OAuthUrlParams & PollParams & {
91
- /**
92
- * A function returning a boolean, indicating whether the OAuth process should be cancelled.
93
- */
94
- isCanceled?: () => boolean;
95
- /**
96
- * A callback function that will be invoked with the OAuth URL when it is available.
97
- * For example, you can use this to open the URL in a new window or tab.
98
- */
99
- onOAuthUrl?: (url: string) => void;
118
+ getOAuthUrl: {
119
+ params: OAuthUrlParams & {
120
+ sessionLookupId?: string;
100
121
  };
122
+ response: string;
123
+ };
124
+ verifyOAuth: {
125
+ params: AuthStateBaseParams & OAuthParams;
101
126
  response: OAuthResponse;
102
127
  };
128
+ getFarcasterConnectUri: {
129
+ params: void;
130
+ response: string;
131
+ };
103
132
  verifyFarcaster: {
104
- params: AuthStateBaseParams & PollParams & {
105
- /**
106
- * A function returning a boolean, indicating whether the Farcaster login process should be cancelled.
107
- */
108
- isCanceled?: () => boolean;
109
- /**
110
- * A callback function that will be invoked with the Farcaster Connect URI when it is available.
111
- * You will need to display the URI as a QR code.
112
- */
113
- onConnectUri: (uri: string) => void;
114
- };
133
+ params: AuthStateBaseParams & FarcasterParams;
115
134
  response: OAuthResponse;
116
135
  };
117
136
  verifyTelegram: {
118
- params: AuthStateBaseParams & {
119
- /**
120
- * The response received from the Telegram login bot.
121
- */
122
- telegramAuthResponse: TelegramAuthResponse;
123
- };
137
+ params: AuthStateBaseParams & TelegramParams;
124
138
  response: OAuthResponse;
125
139
  };
126
140
  loginExternalWallet: {
@@ -128,7 +142,7 @@ export type CoreMethods = Record<CoreMethodName, {
128
142
  /**
129
143
  * The external wallet information to use for login.
130
144
  */
131
- externalWallet: ExternalWalletInfo;
145
+ externalWallet: ExternalWalletInfo | ExternalWalletInfo[];
132
146
  };
133
147
  response: AuthStateVerifyOrLogin;
134
148
  };
@@ -137,7 +151,9 @@ export type CoreMethods = Record<CoreMethodName, {
137
151
  response: AuthStateSignup;
138
152
  };
139
153
  resendVerificationCode: {
140
- params: void;
154
+ params: {
155
+ type?: 'SIGNUP' | 'LINK_ACCOUNT';
156
+ } | undefined;
141
157
  response: void;
142
158
  };
143
159
  logout: {
@@ -172,7 +188,12 @@ export type CoreMethods = Record<CoreMethodName, {
172
188
  response: boolean;
173
189
  };
174
190
  exportSession: {
175
- params: void;
191
+ params: {
192
+ /**
193
+ * Whether to exclude the wallet signers from the exported session.
194
+ */
195
+ excludeSigners?: boolean;
196
+ };
176
197
  response: string;
177
198
  sync: true;
178
199
  };
@@ -210,13 +231,23 @@ export type CoreMethods = Record<CoreMethodName, {
210
231
  };
211
232
  response: Verify2faResponse;
212
233
  };
234
+ getWallets: {
235
+ params: void;
236
+ response: Record<string, Wallet>;
237
+ sync: true;
238
+ };
239
+ getWalletsByType: {
240
+ params: TWalletType;
241
+ response: Wallet[];
242
+ sync: true;
243
+ };
213
244
  fetchWallets: {
214
245
  params: void;
215
246
  response: WalletEntity[];
216
247
  };
217
248
  createWallet: {
218
249
  params: {
219
- type?: Uppercase<WalletType>;
250
+ type?: Uppercase<TWalletType>;
220
251
  skipDistribute?: boolean;
221
252
  };
222
253
  response: [Wallet, string | undefined];
@@ -226,7 +257,7 @@ export type CoreMethods = Record<CoreMethodName, {
226
257
  /**
227
258
  * Array of the wallet types to create
228
259
  */
229
- types?: Uppercase<WalletType>[];
260
+ types?: Uppercase<TWalletType>[];
230
261
  /**
231
262
  * If `true`, skip distributing the new wallets shares.
232
263
  */
@@ -283,7 +314,7 @@ export type CoreMethods = Record<CoreMethodName, {
283
314
  /**
284
315
  * The type of wallet to create, 'EVM' | 'SOLANA' | 'COSMOS'
285
316
  */
286
- type: WalletType;
317
+ type: TWalletType;
287
318
  /**
288
319
  * The pregen identifier for the wallet, in the form: `{ email: string } | { phone: string } | { telegramUserId: string } | { farcasterUsername: string } | { xUsername: string } | { discordUsername: string } | { customId: string }`
289
320
  */
@@ -296,7 +327,7 @@ export type CoreMethods = Record<CoreMethodName, {
296
327
  /**
297
328
  * The wallet types to create. If not provided, defaults to your application's `supportedWalletTypes` setting.
298
329
  */
299
- types?: WalletType[];
330
+ types?: TWalletType[];
300
331
  /**
301
332
  * The pregen identifier for the wallets, in the form: `{ email: string } | { phone: string } | { telegramUserId: string } | { farcasterUsername: string } | { xUsername: string } | { discordUsername: string } | { customId: string }`
302
333
  */
@@ -313,6 +344,10 @@ export type CoreMethods = Record<CoreMethodName, {
313
344
  };
314
345
  response: string | undefined;
315
346
  };
347
+ createGuestWallets: {
348
+ params: void;
349
+ response: Wallet[];
350
+ };
316
351
  distributeNewWalletShare: {
317
352
  params: {
318
353
  /**
@@ -431,7 +466,66 @@ export type CoreMethods = Record<CoreMethodName, {
431
466
  portalUrl: string;
432
467
  };
433
468
  };
469
+ getWalletBalance: {
470
+ params: GetWalletBalanceParams;
471
+ response: GetWalletBalanceResponse;
472
+ };
473
+ issueJwt: {
474
+ params: IssueJwtParams;
475
+ response: IssueJwtResponse;
476
+ };
477
+ getLinkedAccounts: {
478
+ params: {
479
+ withMetadata?: boolean;
480
+ };
481
+ response: LinkedAccounts & {
482
+ userId: string;
483
+ };
484
+ };
485
+ };
486
+ export type InternalMethods = {
487
+ linkAccount: {
488
+ params: {
489
+ auth: VerifiedAuth;
490
+ } | {
491
+ externalWallet: ExternalWalletInfo;
492
+ } | {
493
+ type: TLinkedAccountType | 'X';
494
+ };
495
+ response: AccountLinkInProgress;
496
+ };
497
+ unlinkAccount: {
498
+ params: {
499
+ linkedAccountId: string;
500
+ };
501
+ response: LinkedAccounts;
502
+ };
503
+ verifyEmailOrPhoneLink: {
504
+ params: {
505
+ verificationCode?: string;
506
+ };
507
+ response: LinkedAccounts;
508
+ };
509
+ verifyOAuthLink: {
510
+ params: OAuthParams;
511
+ response: LinkedAccounts;
512
+ };
513
+ verifyFarcasterLink: {
514
+ params: FarcasterParams;
515
+ response: LinkedAccounts;
516
+ };
517
+ verifyTelegramLink: {
518
+ params: TelegramParams;
519
+ response: LinkedAccounts;
520
+ };
521
+ verifyExternalWalletLink: {
522
+ params: Omit<VerifyExternalWalletParams, 'externalWallet'>;
523
+ response: LinkedAccounts;
524
+ };
434
525
  };
435
526
  export type CoreInterface = {
436
- [key in keyof CoreMethods]: CoreMethod<key>;
527
+ [key in keyof CoreMethods]: Partial<CoreMethod<key>>;
528
+ };
529
+ export type InternalInterface = {
530
+ [key in keyof InternalMethods]: Partial<InternalMethod<key>>;
437
531
  };
@@ -1,6 +1,7 @@
1
1
  import { CurrentWalletIds } from '@getpara/user-management-client';
2
2
  import { FullSignatureRes } from './wallet.js';
3
3
  import { Wallet } from './wallet.js';
4
+ import { CoreMethodResponse } from './coreApi.js';
4
5
  export declare enum ParaEvent {
5
6
  LOGIN_EVENT = "paraLogin",
6
7
  ACCOUNT_CREATION_EVENT = "paraAccountCreation",
@@ -11,7 +12,8 @@ export declare enum ParaEvent {
11
12
  EXTERNAL_WALLET_CHANGE_EVENT = "paraExternalWalletChange",
12
13
  WALLETS_CHANGE_EVENT = "paraWalletsChange",
13
14
  WALLET_CREATED = "paraWalletCreated",
14
- PREGEN_WALLET_CLAIMED = "paraPregenWalletClaimed"
15
+ PREGEN_WALLET_CLAIMED = "paraPregenWalletClaimed",
16
+ GUEST_WALLETS_CREATED = "paraGuestWalletsCreated"
15
17
  }
16
18
  export type BaseEvent<T> = {
17
19
  data: T;
@@ -45,3 +47,4 @@ export type PregenWalletClaimedResponse = {
45
47
  recoverySecret?: string;
46
48
  };
47
49
  export type PregenWalletClaimedEvent = CustomEventInit<BaseEvent<WalletCreatedResponse>>;
50
+ export type GuestWalletsCreatedEvent = CustomEventInit<BaseEvent<CoreMethodResponse<'createGuestWallets'>>>;
@@ -1,3 +1,4 @@
1
+ export * from './auth.js';
1
2
  export * from './config.js';
2
3
  export * from './coreApi.js';
3
4
  export * from './wallet.js';
@@ -1,4 +1,4 @@
1
- import { PrimaryAuthInfo, ServerAuthStateLogin, ServerAuthStateSignup, AuthMethod, ServerAuthStateVerify, VerifiedAuth, AuthExtras, OAuthMethod, WalletType } from '@getpara/user-management-client';
1
+ import { PrimaryAuthInfo, ServerAuthStateLogin, ServerAuthStateSignup, AuthMethod, ServerAuthStateVerify, VerifiedAuth, AuthExtras, TOAuthMethod, TWalletType, TelegramAuthResponse } from '@getpara/user-management-client';
2
2
  import { Theme } from './theme.js';
3
3
  import { RecoveryStatus } from './recovery.js';
4
4
  import { Wallet } from './wallet.js';
@@ -6,15 +6,15 @@ type Device = {
6
6
  sessionId: string;
7
7
  encryptionKey: string;
8
8
  };
9
- export type EmbeddedWalletType = Exclude<WalletType, never>;
10
- export type ExternalWalletType = Exclude<WalletType, never>;
9
+ export type EmbeddedWalletType = Exclude<TWalletType, never>;
10
+ export type ExternalWalletType = Exclude<TWalletType, never>;
11
11
  export type VerifyExternalWalletV1 = {
12
12
  address: string;
13
13
  signedMessage: string;
14
14
  cosmosPublicKeyHex?: string;
15
15
  cosmosSigner?: string;
16
16
  };
17
- export type PortalUrlType = 'createAuth' | 'createPassword' | 'loginAuth' | 'loginPassword' | 'txReview' | 'onRamp';
17
+ export type PortalUrlType = 'createAuth' | 'createPassword' | 'loginAuth' | 'loginPassword' | 'txReview' | 'onRamp' | 'telegramLogin';
18
18
  export type PortalUrlOptions = {
19
19
  params?: Record<string, string | undefined | null>;
20
20
  isForNewDevice?: boolean;
@@ -24,6 +24,7 @@ export type PortalUrlOptions = {
24
24
  portalTheme?: Theme;
25
25
  pathId?: string;
26
26
  shorten?: boolean;
27
+ isEmbedded?: boolean;
27
28
  };
28
29
  export type WithAuthMethod = {
29
30
  /**
@@ -49,6 +50,12 @@ export type WithShorten = {
49
50
  */
50
51
  shorten?: boolean;
51
52
  };
53
+ export type WithIsPasskeySupported = {
54
+ /**
55
+ * Whether the current device supports WebAuth passkeys.
56
+ */
57
+ isPasskeySupported: boolean;
58
+ };
52
59
  export type PollParams = {
53
60
  /**
54
61
  * A callback function that will be invoked on each method poll.
@@ -59,6 +66,23 @@ export type PollParams = {
59
66
  */
60
67
  onCancel?: () => void;
61
68
  };
69
+ export type FarcasterParams = PollParams & {
70
+ /**
71
+ * A function returning a boolean, indicating whether the Farcaster login process should be cancelled.
72
+ */
73
+ isCanceled?: () => boolean;
74
+ /**
75
+ * A callback function that will be invoked with the Farcaster Connect URI when it is available.
76
+ * You will need to display the URI as a QR code.
77
+ */
78
+ onConnectUri?: (uri: string) => void;
79
+ };
80
+ export type TelegramParams = {
81
+ /**
82
+ * The response received from the Telegram login bot.
83
+ */
84
+ telegramAuthResponse: TelegramAuthResponse;
85
+ };
62
86
  export type LoginUrlParams = WithAuthMethod & WithCustomTheme & WithShorten & {
63
87
  sessionId?: string;
64
88
  };
@@ -72,15 +96,26 @@ export type OAuthUrlParams = {
72
96
  /**
73
97
  * The third-party OAuth service.
74
98
  */
75
- method: Exclude<OAuthMethod, 'TELEGRAM' | 'FARCASTER'>;
99
+ method: Exclude<TOAuthMethod, 'TELEGRAM' | 'FARCASTER'>;
100
+ /**
101
+ * The app scheme to redirect to after OAuth is complete.
102
+ */
103
+ appScheme?: string;
104
+ };
105
+ export type OAuthParams = OAuthUrlParams & PollParams & {
106
+ /**
107
+ * A function returning a boolean, indicating whether the OAuth process should be cancelled.
108
+ */
109
+ isCanceled?: () => boolean;
76
110
  /**
77
- * The deeplink URL to redirect to after OAuth is complete.
111
+ * A callback function that will be invoked with the OAuth URL when it is available.
112
+ * For example, you can use this to open the URL in a new window or tab.
78
113
  */
79
- deeplinkUrl?: string;
114
+ onOAuthUrl?: (url: string) => void;
80
115
  };
81
116
  export type AuthStateBaseParams = WithCustomTheme & WithUseShortUrls;
82
117
  export type AuthStateVerify = ServerAuthStateVerify;
83
- export type AuthStateLogin = Omit<ServerAuthStateLogin, 'loginAuthMethods'> & {
118
+ export type AuthStateLogin = Omit<ServerAuthStateLogin, 'loginAuthMethods'> & WithIsPasskeySupported & {
84
119
  /**
85
120
  * 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
121
  */
@@ -94,7 +129,7 @@ export type AuthStateLogin = Omit<ServerAuthStateLogin, 'loginAuthMethods'> & {
94
129
  */
95
130
  passwordUrl?: string;
96
131
  };
97
- export type AuthStateSignup = Omit<ServerAuthStateSignup, 'signupAuthMethods'> & {
132
+ export type AuthStateSignup = Omit<ServerAuthStateSignup, 'signupAuthMethods'> & WithIsPasskeySupported & {
98
133
  /**
99
134
  * A Para Portal URL for creating a new WebAuth passkey.
100
135
  */
@@ -140,4 +175,9 @@ export type Verify2faResponse = {
140
175
  };
141
176
  export type CoreAuthInfo = PrimaryAuthInfo & AuthExtras;
142
177
  export type StorageType = 'local' | 'session' | 'secure' | 'all';
178
+ export type GetWalletBalanceParams = {
179
+ walletId: string;
180
+ rpcUrl?: string;
181
+ };
182
+ export type GetWalletBalanceResponse = Promise<string | undefined>;
143
183
  export {};
@@ -1,7 +1,7 @@
1
- import { Network, OnRampAsset, OnRampProvider, OnRampPurchaseType, WalletType } from '@getpara/user-management-client';
1
+ import { Network, OnRampAsset, OnRampProvider, OnRampPurchaseType, TWalletType } from '@getpara/user-management-client';
2
2
  export type ProviderAssetInfo = [string, Partial<Record<OnRampPurchaseType, boolean>>];
3
- export type OnRampAssetInfo = Record<WalletType, Partial<Record<Network, Partial<Record<OnRampAsset, Partial<Record<OnRampProvider, ProviderAssetInfo>>>>>>>;
4
- export type OnRampAssetInfoRow = [WalletType, Network, OnRampAsset, Partial<Record<OnRampProvider, ProviderAssetInfo>>];
3
+ export type OnRampAssetInfo = Record<TWalletType, Partial<Record<Network, Partial<Record<OnRampAsset, Partial<Record<OnRampProvider, ProviderAssetInfo>>>>>>>;
4
+ export type OnRampAssetInfoRow = [TWalletType, Network, OnRampAsset, Partial<Record<OnRampProvider, ProviderAssetInfo>>];
5
5
  export declare enum OnRampMethod {
6
6
  ACH = "ACH",
7
7
  DEBIT = "Debit",
@@ -1,4 +1,4 @@
1
- import { EmbeddedWalletType, ExternalWalletType, PartnerEntity, TPregenIdentifierType, WalletScheme } from '@getpara/user-management-client';
1
+ import { EmbeddedWalletType, ExternalWalletType, PartnerEntity, TExternalWallet, TPregenIdentifierType, TWalletScheme } from '@getpara/user-management-client';
2
2
  export interface Wallet {
3
3
  createdAt?: string;
4
4
  id: string;
@@ -7,7 +7,7 @@ export interface Wallet {
7
7
  address?: string;
8
8
  addressSecondary?: string;
9
9
  publicKey?: string;
10
- scheme?: WalletScheme;
10
+ scheme?: TWalletScheme;
11
11
  type?: EmbeddedWalletType | ExternalWalletType;
12
12
  isPregen?: boolean;
13
13
  pregenIdentifier?: string;
@@ -20,6 +20,11 @@ export interface Wallet {
20
20
  lastUsedPartnerId?: string;
21
21
  isExternal?: boolean;
22
22
  isExternalWithParaAuth?: boolean;
23
+ externalProviderId?: TExternalWallet;
24
+ isExternalWithVerification?: boolean;
25
+ isExternalConnectionOnly?: boolean;
26
+ ensName?: string | null;
27
+ ensAvatar?: string | null;
23
28
  }
24
29
  /** @deprecated */
25
30
  export declare enum PregenIdentifierType {
@@ -37,4 +42,4 @@ export interface DeniedSignatureResWithUrl extends DeniedSignatureRes {
37
42
  }
38
43
  export type SignatureRes = SuccessfulSignatureRes | DeniedSignatureRes;
39
44
  export type FullSignatureRes = SuccessfulSignatureRes | DeniedSignatureResWithUrl;
40
- export type ExternalWalletConnectionType = 'NONE' | 'CONNECTION_ONLY' | 'AUTHENTICATED';
45
+ export type ExternalWalletConnectionType = 'NONE' | 'CONNECTION_ONLY' | 'AUTHENTICATED' | 'VERIFICATION';
@@ -1,4 +1,4 @@
1
- import { WalletTypeProp } from '../types/index.js';
1
+ import { TWalletType } from '@getpara/user-management-client';
2
2
  export type Hex = `0x${string}`;
3
3
  export interface Signature {
4
4
  r: Hex;
@@ -10,7 +10,10 @@ 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
- export declare function truncateAddress(str: string, addressType: WalletTypeProp, { prefix }?: {
16
+ export declare function truncateAddress(str: string, addressType: TWalletType, { prefix, targetLength, }?: {
15
17
  prefix?: string;
18
+ targetLength?: number;
16
19
  }): string;
@@ -1,12 +1,19 @@
1
- import { Network, OnRampAsset, WalletType } from '@getpara/user-management-client';
1
+ import { Network, OnRampAsset, OnRampProvider, OnRampPurchaseType, TWalletType } from '@getpara/user-management-client';
2
2
  import { OnRampAssetInfoRow, OnRampAssetInfo } from '../types/index.js';
3
3
  export declare function toAssetInfoArray(data: OnRampAssetInfo): OnRampAssetInfoRow[];
4
- export declare function getOnRampNetworks(data: OnRampAssetInfo, { walletType, allowed }?: {
5
- walletType?: WalletType;
4
+ export declare function getOnRampNetworks(data: OnRampAssetInfo, { walletType, allowed, assets, providers, action, }?: {
5
+ walletType?: TWalletType;
6
6
  allowed?: Network[];
7
+ assets?: OnRampAsset[];
8
+ providers?: OnRampProvider[];
9
+ action?: OnRampPurchaseType;
7
10
  }): Network[];
8
- export declare function getOnRampAssets(data: OnRampAssetInfo, { walletType, network, allowed, }?: {
9
- walletType?: WalletType;
11
+ export declare function getOnRampAssets(data: OnRampAssetInfo, { walletType, network, allowed, providers, action, }?: {
12
+ walletType?: TWalletType;
10
13
  network?: Network;
11
14
  allowed?: OnRampAsset[];
15
+ providers?: OnRampProvider[];
16
+ action?: OnRampPurchaseType;
12
17
  }): OnRampAsset[];
18
+ export declare const NETWORK_PREFIXES: Partial<Record<Network, string>>;
19
+ export declare function getNetworkPrefix(network: Network): string | undefined;
@@ -5,3 +5,7 @@ export declare function formatPhoneNumber(phone: string, countryCode: string | u
5
5
  forDisplay: true;
6
6
  }): string | null;
7
7
  export declare function displayPhoneNumber(phone: string, countryCode?: string): string;
8
+ export declare function splitPhoneNumber(phone: `+${number}`): {
9
+ phone: string;
10
+ countryCode: string;
11
+ };
@@ -1,12 +1,13 @@
1
- import { CurrentWalletIds, SupportedWalletTypes, TPregenIdentifierType, WalletEntity, WalletScheme, WalletType } from '@getpara/user-management-client';
2
- import { Wallet, WalletTypeProp } from '../types/index.js';
3
- export declare const WalletSchemeTypeMap: Record<WalletScheme, Partial<Record<WalletType, true>>>;
1
+ import { CurrentWalletIds, SupportedWalletTypes, TPregenIdentifierType, WalletEntity, TWalletScheme, TWalletType } from '@getpara/user-management-client';
2
+ import { Wallet } from '../types/index.js';
3
+ export declare const WalletSchemeTypeMap: Record<TWalletScheme, Partial<Record<TWalletType, true>>>;
4
4
  export declare function isPregenIdentifierMatch(a: string | null | undefined, b: string | null | undefined, type: TPregenIdentifierType): boolean;
5
- export declare function isWalletSupported(types: WalletType[], wallet: Omit<Wallet, 'signer'>): boolean;
6
- export declare function getSchemes(types: WalletTypeProp[] | SupportedWalletTypes): WalletScheme[];
7
- export declare function getWalletTypes(schemes: WalletScheme[]): WalletType[];
8
- export declare function getEquivalentTypes(types: WalletTypeProp[] | WalletTypeProp): WalletType[];
5
+ export declare function isWalletSupported(types: TWalletType[], wallet: Omit<Wallet, 'signer'>): boolean;
6
+ export declare function getSchemes(types: TWalletType[] | SupportedWalletTypes): TWalletScheme[];
7
+ export declare function getWalletTypes(schemes: TWalletScheme[]): TWalletType[];
8
+ export declare function getEquivalentTypes(types: TWalletType[] | TWalletType): TWalletType[];
9
9
  export declare function entityToWallet(w: WalletEntity): Omit<Wallet, 'signer'>;
10
10
  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
+ export declare function newUuid(): string;
package/package.json CHANGED
@@ -1,39 +1,21 @@
1
1
  {
2
2
  "name": "@getpara/core-sdk",
3
- "version": "2.0.0-alpha.3",
4
- "main": "dist/cjs/index.js",
5
- "module": "dist/esm/index.js",
6
- "types": "dist/types/index.d.ts",
7
- "typings": "dist/types/index.d.ts",
8
- "sideEffects": false,
3
+ "version": "2.0.0-alpha.30",
9
4
  "dependencies": {
10
- "@celo/utils": "^8.0.0",
5
+ "@celo/utils": "^8.0.2",
11
6
  "@cosmjs/encoding": "^0.32.4",
12
- "@getpara/user-management-client": "2.0.0-alpha.3",
7
+ "@ethereumjs/util": "^9.1.0",
8
+ "@getpara/user-management-client": "2.0.0-alpha.30",
13
9
  "@noble/hashes": "^1.5.0",
14
10
  "base64url": "^3.0.1",
15
- "ethereumjs-util": "7.1.5",
16
- "libphonenumber-js": "1.11.2",
11
+ "libphonenumber-js": "^1.11.7",
17
12
  "node-forge": "^1.3.1",
18
- "qs": "^6.12.0"
19
- },
20
- "scripts": {
21
- "build": "rm -rf dist && node ./scripts/build.mjs && yarn build:types && yarn post-build",
22
- "old-build": "yarn build:cjs && yarn build:esm && yarn build:types; yarn post-build",
23
- "post-build": "./scripts/set-version.sh",
24
- "build:cjs": "rm -rf dist/cjs && tsc --module commonjs --outDir dist/cjs && printf '{\"type\":\"commonjs\"}' > dist/cjs/package.json",
25
- "build:esm": "rm -rf dist/esm && tsc --module es6 --outDir dist/esm && printf '{\"type\":\"module\",\"sideEffects\":false}' > dist/esm/package.json",
26
- "build:types": "rm -rf dist/types && tsc --module es6 --declarationDir dist/types --emitDeclarationOnly --declaration",
27
- "test": "vitest run --coverage"
13
+ "uuid": "^11.1.0"
28
14
  },
29
15
  "devDependencies": {
30
16
  "@faker-js/faker": "^9.5.1",
31
- "typescript": "5.1.6"
17
+ "typescript": "^5.8.3"
32
18
  },
33
- "files": [
34
- "dist",
35
- "package.json"
36
- ],
37
19
  "exports": {
38
20
  ".": {
39
21
  "types": "./dist/types/index.d.ts",
@@ -41,5 +23,23 @@
41
23
  "require": "./dist/cjs/index.js"
42
24
  }
43
25
  },
44
- "gitHead": "77a1e04b06258842ca9c81e3db2a2b0092517659"
26
+ "files": [
27
+ "dist",
28
+ "package.json"
29
+ ],
30
+ "gitHead": "8b06219b9c248a3fbdbd05dc7501e8042c369301",
31
+ "main": "dist/cjs/index.js",
32
+ "module": "dist/esm/index.js",
33
+ "scripts": {
34
+ "build": "rm -rf dist && node ./scripts/build.mjs && yarn build:types",
35
+ "build:cjs": "rm -rf dist/cjs && tsc --module commonjs --outDir dist/cjs && printf '{\"type\":\"commonjs\"}' > dist/cjs/package.json",
36
+ "build:esm": "rm -rf dist/esm && tsc --module es6 --outDir dist/esm && printf '{\"type\":\"module\",\"sideEffects\":false}' > dist/esm/package.json",
37
+ "build:types": "rm -rf dist/types && tsc --module es6 --declarationDir dist/types --emitDeclarationOnly --declaration",
38
+ "old-build": "yarn build:cjs && yarn build:esm && yarn build:types; yarn post-build",
39
+ "post-build": "./scripts/set-version.sh",
40
+ "test": "vitest run --coverage"
41
+ },
42
+ "sideEffects": false,
43
+ "types": "dist/types/index.d.ts",
44
+ "typings": "dist/types/index.d.ts"
45
45
  }