@getpara/core-sdk 2.0.0-fc.2 → 2.0.0

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 (60) hide show
  1. package/dist/cjs/ParaCore.js +1111 -316
  2. package/dist/cjs/constants.js +10 -1
  3. package/dist/cjs/index.js +23 -3
  4. package/dist/cjs/shares/KeyContainer.js +3 -3
  5. package/dist/cjs/shares/enclave.js +287 -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/coreApi.js +7 -2
  10. package/dist/cjs/types/events.js +2 -0
  11. package/dist/cjs/types/index.js +0 -21
  12. package/dist/cjs/types/popup.js +1 -0
  13. package/dist/cjs/utils/config.js +108 -0
  14. package/dist/cjs/utils/index.js +5 -1
  15. package/dist/cjs/utils/onRamps.js +2 -3
  16. package/dist/cjs/utils/wallet.js +18 -0
  17. package/dist/cjs/{types/onRamps.js → utils/window.js} +17 -12
  18. package/dist/esm/ParaCore.js +1115 -320
  19. package/dist/esm/constants.js +7 -1
  20. package/dist/esm/index.js +24 -5
  21. package/dist/esm/shares/KeyContainer.js +3 -3
  22. package/dist/esm/shares/enclave.js +247 -0
  23. package/dist/esm/shares/shareDistribution.js +16 -1
  24. package/dist/esm/transmission/transmissionUtils.js +4 -3
  25. package/dist/esm/types/coreApi.js +7 -2
  26. package/dist/esm/types/events.js +2 -0
  27. package/dist/esm/types/index.js +0 -16
  28. package/dist/esm/types/popup.js +1 -0
  29. package/dist/esm/utils/config.js +86 -0
  30. package/dist/esm/utils/index.js +2 -0
  31. package/dist/esm/utils/onRamps.js +2 -3
  32. package/dist/esm/utils/wallet.js +17 -0
  33. package/dist/esm/utils/window.js +16 -0
  34. package/dist/types/ParaCore.d.ts +90 -19
  35. package/dist/types/PlatformUtils.d.ts +2 -1
  36. package/dist/types/constants.d.ts +3 -0
  37. package/dist/types/index.d.ts +6 -4
  38. package/dist/types/shares/enclave.d.ts +83 -0
  39. package/dist/types/shares/shareDistribution.d.ts +4 -2
  40. package/dist/types/types/assets.d.ts +14 -0
  41. package/dist/types/types/config.d.ts +3 -2
  42. package/dist/types/types/coreApi.d.ts +47 -7
  43. package/dist/types/types/events.d.ts +7 -2
  44. package/dist/types/types/index.d.ts +0 -4
  45. package/dist/types/types/methods.d.ts +56 -12
  46. package/dist/types/types/popup.d.ts +2 -1
  47. package/dist/types/types/wallet.d.ts +8 -4
  48. package/dist/types/utils/config.d.ts +7 -0
  49. package/dist/types/utils/index.d.ts +2 -0
  50. package/dist/types/utils/onRamps.d.ts +9 -10
  51. package/dist/types/utils/wallet.d.ts +1 -0
  52. package/dist/types/utils/window.d.ts +2 -0
  53. package/package.json +3 -3
  54. package/dist/cjs/types/recovery.js +0 -34
  55. package/dist/esm/types/onRamps.js +0 -11
  56. package/dist/esm/types/recovery.js +0 -12
  57. package/dist/types/types/onRamps.d.ts +0 -10
  58. package/dist/types/types/recovery.d.ts +0 -7
  59. package/dist/types/types/theme.d.ts +0 -12
  60. /package/dist/esm/types/{theme.js → assets.js} +0 -0
@@ -1,6 +1,4 @@
1
- import { PrimaryAuthInfo, ServerAuthStateLogin, ServerAuthStateSignup, AuthMethod, ServerAuthStateVerify, VerifiedAuth, AuthExtras, TOAuthMethod, TWalletType, TelegramAuthResponse } 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' | 'telegramLogin';
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;
@@ -25,12 +23,18 @@ export type PortalUrlOptions = {
25
23
  pathId?: string;
26
24
  shorten?: boolean;
27
25
  isEmbedded?: boolean;
26
+ oAuthMethod?: OAuthUrlParams['method'];
27
+ appScheme?: string;
28
+ encryptionKey?: string;
29
+ addNewCredentialType?: TAuthMethod;
30
+ addNewCredentialPasswordId?: string;
31
+ addNewCredentialPasskeyId?: string;
28
32
  };
29
33
  export type WithAuthMethod = {
30
34
  /**
31
- * 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'`.
32
36
  */
33
- authMethod?: Uppercase<AuthMethod>;
37
+ authMethod?: Uppercase<TAuthMethod>;
34
38
  };
35
39
  export type WithCustomTheme = {
36
40
  /**
@@ -76,21 +80,27 @@ export type FarcasterParams = PollParams & {
76
80
  * You will need to display the URI as a QR code.
77
81
  */
78
82
  onConnectUri?: (uri: string) => void;
83
+ serverAuthState?: VerifyThirdPartyAuth;
79
84
  };
80
85
  export type TelegramParams = {
81
86
  /**
82
87
  * The response received from the Telegram login bot.
83
88
  */
84
- telegramAuthResponse: TelegramAuthResponse;
89
+ telegramAuthResponse?: TelegramAuthResponse;
90
+ serverAuthState?: VerifyThirdPartyAuth;
85
91
  };
86
92
  export type LoginUrlParams = WithAuthMethod & WithCustomTheme & WithShorten & {
87
93
  sessionId?: string;
88
94
  };
89
- export type NewCredentialUrlParams = WithAuthMethod & WithCustomTheme & WithShorten & {
95
+ export type NewCredentialUrlParams = WithCustomTheme & WithShorten & {
90
96
  /**
91
97
  * Whether the URL is meant to add a passkey for a previous user on a new device. Defaults to `false`.
92
98
  */
93
99
  isForNewDevice?: boolean;
100
+ /**
101
+ * The authentication method to add.
102
+ */
103
+ authMethod?: TAuthMethod;
94
104
  };
95
105
  export type OAuthUrlParams = {
96
106
  /**
@@ -110,11 +120,22 @@ export type OAuthParams = OAuthUrlParams & PollParams & {
110
120
  /**
111
121
  * A callback function that will be invoked with the OAuth URL when it is available.
112
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.
113
125
  */
114
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;
115
134
  };
116
135
  export type AuthStateBaseParams = WithCustomTheme & WithUseShortUrls;
117
- export type AuthStateVerify = ServerAuthStateVerify;
136
+ export type AuthStateVerify = ServerAuthStateVerify & {
137
+ loginUrl?: string;
138
+ };
118
139
  export type AuthStateLogin = Omit<ServerAuthStateLogin, 'loginAuthMethods'> & WithIsPasskeySupported & {
119
140
  /**
120
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.
@@ -128,6 +149,14 @@ export type AuthStateLogin = Omit<ServerAuthStateLogin, 'loginAuthMethods'> & Wi
128
149
  * A Para Portal URL for logging in via a password.
129
150
  */
130
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[];
131
160
  };
132
161
  export type AuthStateSignup = Omit<ServerAuthStateSignup, 'signupAuthMethods'> & WithIsPasskeySupported & {
133
162
  /**
@@ -138,6 +167,10 @@ export type AuthStateSignup = Omit<ServerAuthStateSignup, 'signupAuthMethods'> &
138
167
  * A Para Portal URL for creating a new user password.
139
168
  */
140
169
  passwordUrl?: string;
170
+ /**
171
+ * A Para Portal URL for creating a new user PIN.
172
+ */
173
+ pinUrl?: string;
141
174
  /**
142
175
  * The Para system ID for the newly generated passkey.
143
176
  */
@@ -146,11 +179,22 @@ export type AuthStateSignup = Omit<ServerAuthStateSignup, 'signupAuthMethods'> &
146
179
  * The Para system ID for the newly generated password.
147
180
  */
148
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[];
149
193
  };
150
194
  export type AuthStateVerifyOrLogin = AuthStateVerify | AuthStateLogin;
151
- export type AuthStateSignupOrLogin = AuthStateSignup | AuthStateLogin;
152
- export type OAuthResponse = AuthStateSignupOrLogin;
153
- 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;
154
198
  export type Verify2faParams = {
155
199
  auth: VerifiedAuth;
156
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, TExternalWallet, 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,12 +20,16 @@ export interface Wallet {
20
20
  lastUsedPartnerId?: string;
21
21
  isExternal?: boolean;
22
22
  isExternalWithParaAuth?: boolean;
23
- externalProviderId?: TExternalWallet;
23
+ externalProviderId?: string;
24
24
  isExternalWithVerification?: boolean;
25
25
  isExternalConnectionOnly?: boolean;
26
26
  ensName?: string | null;
27
27
  ensAvatar?: string | null;
28
28
  }
29
+ export type AvailableWallet = Pick<Wallet, 'id' | 'type' | 'name' | 'address' | 'partner' | 'ensName' | 'ensAvatar' | 'isExternal' | 'externalProviderId' | 'isExternalConnectionOnly'> & {
30
+ addressShort?: string;
31
+ displayName?: string;
32
+ };
29
33
  /** @deprecated */
30
34
  export declare enum PregenIdentifierType {
31
35
  EMAIL = "EMAIL",
@@ -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,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;
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@getpara/core-sdk",
3
- "version": "2.0.0-fc.2",
3
+ "version": "2.0.0",
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-fc.2",
8
+ "@getpara/user-management-client": "2.0.0",
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": "65106fd9662a2c32b2071a0dea67ef55b3e4e98f",
30
+ "gitHead": "a64b6aa9b3c481a2d955022f621e495fb55e549e",
31
31
  "main": "dist/cjs/index.js",
32
32
  "module": "dist/esm/index.js",
33
33
  "scripts": {
@@ -1,34 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
- var recovery_exports = {};
19
- __export(recovery_exports, {
20
- RecoveryStatus: () => RecoveryStatus
21
- });
22
- module.exports = __toCommonJS(recovery_exports);
23
- var RecoveryStatus = /* @__PURE__ */ ((RecoveryStatus2) => {
24
- RecoveryStatus2["INITIATED"] = "INITIATED";
25
- RecoveryStatus2["READY"] = "READY";
26
- RecoveryStatus2["EXPIRED"] = "EXPIRED";
27
- RecoveryStatus2["FINISHED"] = "FINISHED";
28
- RecoveryStatus2["CANCELLED"] = "CANCELLED";
29
- return RecoveryStatus2;
30
- })(RecoveryStatus || {});
31
- // Annotate the CommonJS export names for ESM import in node:
32
- 0 && (module.exports = {
33
- RecoveryStatus
34
- });
@@ -1,11 +0,0 @@
1
- import "../chunk-7B52C2XE.js";
2
- var OnRampMethod = /* @__PURE__ */ ((OnRampMethod2) => {
3
- OnRampMethod2["ACH"] = "ACH";
4
- OnRampMethod2["DEBIT"] = "Debit";
5
- OnRampMethod2["CREDIT"] = "Credit";
6
- OnRampMethod2["APPLE_PAY"] = "Apple Pay";
7
- return OnRampMethod2;
8
- })(OnRampMethod || {});
9
- export {
10
- OnRampMethod
11
- };
@@ -1,12 +0,0 @@
1
- import "../chunk-7B52C2XE.js";
2
- var RecoveryStatus = /* @__PURE__ */ ((RecoveryStatus2) => {
3
- RecoveryStatus2["INITIATED"] = "INITIATED";
4
- RecoveryStatus2["READY"] = "READY";
5
- RecoveryStatus2["EXPIRED"] = "EXPIRED";
6
- RecoveryStatus2["FINISHED"] = "FINISHED";
7
- RecoveryStatus2["CANCELLED"] = "CANCELLED";
8
- return RecoveryStatus2;
9
- })(RecoveryStatus || {});
10
- export {
11
- RecoveryStatus
12
- };
@@ -1,10 +0,0 @@
1
- import { Network, OnRampAsset, OnRampProvider, OnRampPurchaseType, TWalletType } from '@getpara/user-management-client';
2
- export type ProviderAssetInfo = [string, Partial<Record<OnRampPurchaseType, boolean>>];
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
- export declare enum OnRampMethod {
6
- ACH = "ACH",
7
- DEBIT = "Debit",
8
- CREDIT = "Credit",
9
- APPLE_PAY = "Apple Pay"
10
- }
@@ -1,7 +0,0 @@
1
- export declare enum RecoveryStatus {
2
- INITIATED = "INITIATED",
3
- READY = "READY",
4
- EXPIRED = "EXPIRED",
5
- FINISHED = "FINISHED",
6
- CANCELLED = "CANCELLED"
7
- }
@@ -1,12 +0,0 @@
1
- export type Theme = {
2
- foregroundColor?: string;
3
- backgroundColor?: string;
4
- accentColor?: string;
5
- darkForegroundColor?: string;
6
- darkBackgroundColor?: string;
7
- darkAccentColor?: string;
8
- mode?: 'light' | 'dark';
9
- borderRadius?: BorderRadius;
10
- font?: string;
11
- };
12
- export type BorderRadius = 'none' | 'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'full';
File without changes