@getpara/user-management-client 1.12.0 → 2.0.0-alpha.11

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.
@@ -1,5 +1,5 @@
1
1
  import { AxiosResponse } from 'axios';
2
- import { AccountMetadata, Auth, AuthMethod, AuthParams, BackupKitEmailProps, BiometricLocationHint, Chain, CurrentWalletIds, EncryptedKeyShare, EncryptorType, KeyShareType, Network, OnRampAsset, OnRampConfig, OnRampProvider, OnRampPurchase, OnRampPurchaseCreateParams, OnRampPurchaseUpdateParams, PasswordStatus, PregenIds, PublicKeyStatus, PublicKeyType, TelegramAuthResponse, TPregenIdentifierType, VerificationEmailProps, WalletEntity, WalletParams, WalletScheme, WalletType } from './types/index.js';
2
+ import { AccountMetadata, Auth, AuthIdentifier, AuthMethod, BackupKitEmailProps, BiometricLocationHint, Chain, CurrentWalletIds, EncryptedKeyShare, EncryptorType, ExternalWalletInfo, LoginExternalWalletResponse, KeyShareType, Network, OnRampAsset, OnRampConfig, OnRampProvider, OnRampPurchase, OnRampPurchaseCreateParams, OnRampPurchaseUpdateParams, PasswordStatus, PregenIds, PrimaryAuth, PublicKeyStatus, PublicKeyType, ServerAuthStateSignup, SessionInfo, Setup2faResponse, SignUpOrLogInResponse, TelegramAuthResponse, TPregenIdentifierType, VerificationEmailProps, VerifiedAuth, VerifyFarcasterResponse, VerifyTelegramResponse, VerifyThirdPartyAuth, WalletEntity, WalletParams, TWalletScheme, TWalletType, VerifyExternalWalletParams } from './types/index.js';
3
3
  interface ConfigOpts {
4
4
  useFetchAdapter?: boolean;
5
5
  }
@@ -7,30 +7,11 @@ type ClientConfig = {
7
7
  userManagementHost: string;
8
8
  version?: string;
9
9
  partnerId?: string;
10
- apiKey?: string;
10
+ apiKey: string;
11
11
  opts?: ConfigOpts;
12
12
  retrieveSessionCookie?: () => string | undefined;
13
13
  persistSessionCookie?: (cookie: string) => void;
14
14
  };
15
- interface createUserBody {
16
- email: string;
17
- }
18
- interface createUserBodyForPhone {
19
- phone: string;
20
- countryCode: string;
21
- }
22
- interface ExternalWalletLoginBody {
23
- externalAddress: string;
24
- type: 'EVM' | 'SOLANA' | 'COSMOS';
25
- externalWalletProvider?: string;
26
- shouldTrackUser?: boolean;
27
- }
28
- export interface ExternalWalletLoginRes {
29
- userId: string;
30
- userExists: boolean;
31
- isVerified: boolean;
32
- signatureVerificationMessage: string;
33
- }
34
15
  interface createUserIdRes {
35
16
  protocolId: string;
36
17
  userId: string;
@@ -38,12 +19,6 @@ interface createUserIdRes {
38
19
  interface verifyBody {
39
20
  verificationCode: string;
40
21
  }
41
- interface verifyExternalWalletBody {
42
- address: string;
43
- signedMessage: string;
44
- cosmosPublicKeyHex?: string;
45
- cosmosSigner?: string;
46
- }
47
22
  interface getWebChallengeRes {
48
23
  challenge: string;
49
24
  allowedPublicKeys?: string[];
@@ -95,8 +70,8 @@ interface PasswordEntity {
95
70
  }
96
71
  interface createWalletBody {
97
72
  useTwoSigners?: boolean;
98
- scheme: WalletScheme;
99
- type: WalletType;
73
+ scheme: TWalletScheme;
74
+ type: TWalletType;
100
75
  cosmosPrefix?: string;
101
76
  }
102
77
  interface updatePregenWalletBody {
@@ -113,8 +88,8 @@ interface GetWalletBalanceRes {
113
88
  interface createPregenWalletBody {
114
89
  pregenIdentifier: string;
115
90
  pregenIdentifierType: TPregenIdentifierType;
116
- scheme?: WalletScheme;
117
- type: WalletType;
91
+ scheme?: TWalletScheme;
92
+ type: TWalletType;
118
93
  cosmosPrefix?: string;
119
94
  }
120
95
  interface claimPreGenWalletsBody {
@@ -141,7 +116,6 @@ interface sessionPasswordBody {
141
116
  encryptedWalletPrivateKey?: string;
142
117
  encryptionKeyHash?: string;
143
118
  }
144
- type BiometricLocationHintParams = AuthParams;
145
119
  export type SDKType = 'WEB' | 'SERVER' | 'BRIDGE' | 'REACT_NATIVE';
146
120
  export type VerifyTelegramRes = {
147
121
  isValid: true;
@@ -158,20 +132,35 @@ export declare const handleResponseError: (error: any) => never;
158
132
  declare class Client {
159
133
  private baseRequest;
160
134
  constructor({ userManagementHost, apiKey, partnerId, version, opts, retrieveSessionCookie, persistSessionCookie, }: ClientConfig);
161
- createUser: (body: (createUserBody | createUserBodyForPhone) & VerificationEmailProps) => Promise<createUserIdRes>;
162
- checkUserExists: (auth: Auth<"email" | "phone">) => Promise<any>;
163
- verifyTelegram: (authObject: TelegramAuthResponse) => Promise<VerifyTelegramRes>;
164
- externalWalletLogin: (body: ExternalWalletLoginBody) => Promise<ExternalWalletLoginRes>;
135
+ signUpOrLogIn: (body: VerifiedAuth & VerificationEmailProps) => Promise<SignUpOrLogInResponse>;
136
+ /**
137
+ * @deprecated
138
+ */
139
+ createUser: (body: VerifiedAuth & VerificationEmailProps) => Promise<createUserIdRes>;
140
+ checkUserExists: (auth: VerifiedAuth) => Promise<any>;
141
+ verifyTelegram: (authObject: TelegramAuthResponse) => Promise<VerifyTelegramResponse>;
142
+ verifyOAuth: () => Promise<VerifyThirdPartyAuth | null>;
143
+ loginExternalWallet: ({ externalWallet, shouldTrackUser, }: {
144
+ externalWallet: ExternalWalletInfo;
145
+ shouldTrackUser?: boolean;
146
+ }) => Promise<LoginExternalWalletResponse>;
147
+ verifyNewAccount: (userId: string, body: verifyBody) => Promise<ServerAuthStateSignup>;
148
+ /**
149
+ * @deprecated
150
+ */
165
151
  verifyEmail: (userId: string, body: verifyBody) => Promise<any>;
152
+ /**
153
+ * @deprecated
154
+ */
166
155
  verifyPhone: (userId: string, body: verifyBody) => Promise<any>;
167
- verifyExternalWallet: (userId: string, body: verifyExternalWalletBody) => Promise<any>;
156
+ verifyExternalWallet: (userId: string, body: VerifyExternalWalletParams) => Promise<ServerAuthStateSignup>;
168
157
  addSessionPublicKey: (userId: string, body: sessionPublicKeyBody) => Promise<any>;
169
158
  getSessionPublicKeys: (userId: string) => Promise<any>;
170
- getBiometricLocationHints: (params: BiometricLocationHintParams) => Promise<BiometricLocationHint[]>;
159
+ getBiometricLocationHints: (auth: PrimaryAuth) => Promise<BiometricLocationHint[]>;
171
160
  getSessionPublicKey: (userId: string, biometricId: string) => Promise<any>;
172
161
  patchSessionPublicKey: (partnerId: string, userId: string, biometricId: string, body: sessionPublicKeyBody) => Promise<any>;
173
- getWebChallenge: (auth?: Auth) => Promise<getWebChallengeRes>;
174
- touchSession: (regenerate?: boolean) => Promise<any>;
162
+ getWebChallenge: (auth?: PrimaryAuth | Auth<"userId">) => Promise<getWebChallengeRes>;
163
+ touchSession: (regenerate?: boolean) => Promise<SessionInfo>;
175
164
  sessionOrigin: (sessionLookupId: string) => Promise<{
176
165
  origin?: string;
177
166
  }>;
@@ -180,12 +169,12 @@ declare class Client {
180
169
  verifySessionChallenge: (userId: string, body: verifySessionChallengeBody) => Promise<any>;
181
170
  createWallet: (userId: string, body?: createWalletBody) => Promise<createWalletRes>;
182
171
  createPregenWallet: (body?: createPregenWalletBody) => Promise<createWalletRes>;
183
- getPregenWallets: <ReturnType = {
172
+ getPregenWallets: (pregenIds: PregenIds, isPortal?: boolean, userId?: string) => Promise<{
184
173
  wallets: WalletEntity[];
185
- }>(pregenIds: PregenIds, isPortal?: boolean, userId?: string) => Promise<ReturnType>;
186
- claimPregenWallets: <ReturnType = {
187
- walletIds?: string[];
188
- }>(body?: claimPreGenWalletsBody) => Promise<ReturnType>;
174
+ }>;
175
+ claimPregenWallets: (body?: claimPreGenWalletsBody) => Promise<{
176
+ walletIds: string[];
177
+ }>;
189
178
  sendTransaction: (userId: string, walletId: string, body: sendTransactionBody) => Promise<any>;
190
179
  signTransaction: (userId: string, walletId: string, body: signTransactionBody) => Promise<any>;
191
180
  refreshKeys: (userId: string, walletId: string, oldPartnerId?: string, newPartnerId?: string, keyShareProtocolId?: string) => Promise<any>;
@@ -200,7 +189,7 @@ declare class Client {
200
189
  logout: () => Promise<any>;
201
190
  recoveryVerification: (email: string, verificationCode: string) => Promise<any>;
202
191
  recoveryInit: (email: string) => Promise<any>;
203
- preSignMessage: (userId: string, walletId: string, message: string, scheme?: WalletScheme, cosmosSignDoc?: string) => Promise<any>;
192
+ preSignMessage: (userId: string, walletId: string, message: string, scheme?: TWalletScheme, cosmosSignDoc?: string) => Promise<any>;
204
193
  deleteSelf: (userId: string) => Promise<any>;
205
194
  uploadKeyshares(userId: string, walletId: string, encryptedKeyshares: EncryptedKeyShare[]): Promise<any>;
206
195
  uploadUserKeyShares(userId: string, encryptedKeyshares: (EncryptedKeyShare & {
@@ -227,10 +216,10 @@ declare class Client {
227
216
  cancelRecoveryAttempt(email: string): Promise<AxiosResponse<any, any>>;
228
217
  check2FAStatus(userId: string): Promise<AxiosResponse<any, any>>;
229
218
  enable2FA(userId: string, verificationCode: string): Promise<AxiosResponse<any, any>>;
230
- setup2FA(userId: string): Promise<AxiosResponse<any, any>>;
219
+ setup2FA(userId: string): Promise<Setup2faResponse>;
231
220
  initializeRecovery(email: string): Promise<AxiosResponse<any, any>>;
232
221
  initializeFarcasterLogin(): Promise<AxiosResponse<any, any>>;
233
- getFarcasterAuthStatus(): Promise<AxiosResponse<any, any>>;
222
+ getFarcasterAuthStatus(): Promise<VerifyFarcasterResponse>;
234
223
  initializeRecoveryForPhone(phone: string, countryCode: string): Promise<AxiosResponse<any, any>>;
235
224
  finalizeRecovery(userId: string, walletId: string): Promise<AxiosResponse<any, any>>;
236
225
  recoverUserShares(userId: string, walletId: string): Promise<AxiosResponse<{
@@ -249,8 +238,11 @@ declare class Client {
249
238
  }, any>>;
250
239
  verifyEmailForRecovery(email: string, verificationCode: string): Promise<AxiosResponse<any, any>>;
251
240
  verifyPhoneForRecovery(phone: string, countryCode: string, verificationCode: string): Promise<AxiosResponse<any, any>>;
252
- verify2FA(email: string, verificationCode: string): Promise<AxiosResponse<any, any>>;
253
- verify2FAForPhone(phone: string, countryCode: string, verificationCode: string): Promise<AxiosResponse<any, any>>;
241
+ verify2FA(auth: VerifiedAuth, verificationCode: string): Promise<any>;
242
+ /**
243
+ * @deprecated
244
+ */
245
+ verify2FAForPhone(phone: AuthIdentifier<'phone'>, verificationCode: string): Promise<AxiosResponse<any, any>>;
254
246
  tempTrasmissionInit(message: string, userId?: string): Promise<AxiosResponse<any, any>>;
255
247
  tempTrasmission(id: string): Promise<AxiosResponse<any, any>>;
256
248
  getPartner(partnerId: string): Promise<AxiosResponse<any, any>>;
@@ -273,7 +265,7 @@ declare class Client {
273
265
  } & WalletParams): Promise<AxiosResponse<OnRampPurchase, any>>;
274
266
  signMoonPayUrl(userId: string, { url, type, cosmosPrefix, testMode, walletId, externalWalletAddress, }: {
275
267
  url: string;
276
- type: WalletType;
268
+ type: TWalletType;
277
269
  cosmosPrefix: string;
278
270
  testMode?: boolean;
279
271
  walletId?: string;
@@ -292,7 +284,7 @@ declare class Client {
292
284
  contractAddress?: string;
293
285
  testMode?: boolean;
294
286
  walletId: string;
295
- walletType: WalletType;
287
+ walletType: TWalletType;
296
288
  destinationAddress: string;
297
289
  sourceAddress?: string;
298
290
  assetQuantity: string | number;
@@ -305,7 +297,7 @@ declare class Client {
305
297
  sourceAddress?: string;
306
298
  network: Network;
307
299
  walletId: string;
308
- walletType: WalletType;
300
+ walletType: TWalletType;
309
301
  }): Promise<ReturnType>;
310
302
  distributeParaShare({ userId, walletId, ...rest }: {
311
303
  userId: string;
@@ -344,8 +336,7 @@ declare class Client {
344
336
  getAccountMetadata(userId: string, partnerId: string): Promise<{
345
337
  accountMetadata: AccountMetadata;
346
338
  }>;
347
- getWalletBalance: ({ userId, walletId, rpcUrl, }: {
348
- userId: string;
339
+ getWalletBalance: ({ walletId, rpcUrl }: {
349
340
  walletId: string;
350
341
  rpcUrl?: string;
351
342
  }) => Promise<GetWalletBalanceRes>;
@@ -1,5 +1,6 @@
1
1
  export * from './client.js';
2
2
  export * from './types/index.js';
3
3
  export * from './utils.js';
4
+ export * from './error.js';
4
5
  import Client from './client.js';
5
6
  export default Client;
@@ -1,11 +1,18 @@
1
- export type AuthType = 'email' | 'phone' | 'farcaster' | 'telegram' | 'userId' | 'externalWallet';
2
- export type $ExtractAuth<T extends AuthType> = {
1
+ import { CurrentWalletIds, ExternalWalletType, SupportedWalletTypes } from './wallet.js';
2
+ export declare const AUTH_TYPES: readonly ["email", "phone", "phoneLegacy", "farcaster", "telegram", "userId", "externalWallet", "discord", "x", "customId", "guestId"];
3
+ export type AuthType = 'email' | 'phone' | 'phoneLegacy' | 'farcaster' | 'telegram' | 'userId' | 'externalWallet' | 'discord' | 'x' | 'customId' | 'guestId';
4
+ export type PrimaryAuthType = Extract<AuthType, 'email' | 'phone' | 'farcaster' | 'telegram' | 'externalWallet'>;
5
+ export type VerifiedAuthType = Extract<PrimaryAuthType, 'email' | 'phone' | 'externalWallet'>;
6
+ export type PregenAuthType = Exclude<PrimaryAuthType, 'externalWallet'> | Extract<AuthType, 'discord' | 'x' | 'customId'>;
7
+ export type AuthIdentifier<T extends AuthType | never> = T extends 'phone' ? `+${number}` : string;
8
+ export type AuthInfo<T extends Exclude<AuthType, 'phoneLegacy'> = Exclude<AuthType, 'phoneLegacy'>> = {
3
9
  auth: Auth<T>;
4
10
  authType: T;
5
- identifier: string;
6
- publicKeyIdentifier: string;
11
+ identifier: AuthIdentifier<T>;
7
12
  };
8
- export type ExtractAuth = $ExtractAuth<'email'> | $ExtractAuth<'phone'> | $ExtractAuth<'farcaster'> | $ExtractAuth<'telegram'> | $ExtractAuth<'userId'> | $ExtractAuth<'externalWallet'>;
13
+ export type PrimaryAuthInfo = AuthInfo<PrimaryAuthType>;
14
+ export type VerifiedAuthInfo = AuthInfo<VerifiedAuthType>;
15
+ export type PregenAuthInfo = AuthInfo<PregenAuthType>;
9
16
  export type AuthParams = Record<string, any> & {
10
17
  email?: string;
11
18
  phone?: string;
@@ -17,17 +24,49 @@ export type AuthParams = Record<string, any> & {
17
24
  };
18
25
  export type Auth<T extends AuthType = AuthType> = T extends 'email' ? {
19
26
  email: string;
20
- } : T extends 'phone' ? {
27
+ } : T extends 'phoneLegacy' ? {
21
28
  phone: string;
22
29
  countryCode: string;
30
+ } : T extends 'phone' ? {
31
+ phone: AuthIdentifier<'phone'>;
23
32
  } : T extends 'farcaster' ? {
24
- farcasterUsername: string;
33
+ farcasterUsername: AuthIdentifier<'farcaster'>;
25
34
  } : T extends 'telegram' ? {
26
- telegramUserId: string;
35
+ telegramUserId: AuthIdentifier<'telegram'>;
27
36
  } : T extends 'externalWallet' ? {
28
- externalWalletAddress: string;
37
+ externalWalletAddress: AuthIdentifier<'externalWallet'>;
38
+ } : T extends 'x' ? {
39
+ xUsername: AuthIdentifier<'x'>;
40
+ } : T extends 'discord' ? {
41
+ discordUsername: AuthIdentifier<'discord'>;
42
+ } : T extends 'customId' ? {
43
+ customId: AuthIdentifier<'customId'>;
44
+ } : T extends 'guestId' ? {
45
+ guestId: AuthIdentifier<'guestId'>;
29
46
  } : {
30
- userId: string;
47
+ userId: AuthIdentifier<'userId'>;
48
+ };
49
+ export type PrimaryAuth = Auth<PrimaryAuthType>;
50
+ export type VerifiedAuth = Auth<VerifiedAuthType>;
51
+ export type PregenAuth = Auth<PregenAuthType>;
52
+ export type PregenOrGuestAuth = Auth<PregenAuthType | 'guestId'>;
53
+ export type AuthExtras = {
54
+ /**
55
+ * The current user's third-party username.
56
+ */
57
+ username?: string;
58
+ /**
59
+ * The current user's third-party display name.
60
+ */
61
+ displayName?: string;
62
+ /**
63
+ * The current user's third-party profile picture URL.
64
+ */
65
+ pfpUrl?: string;
66
+ /**
67
+ * The current user's external wallet information.
68
+ */
69
+ externalWallet?: ExternalWalletInfo;
31
70
  };
32
71
  export declare enum EncryptorType {
33
72
  USER = "USER",
@@ -61,6 +100,7 @@ export interface EncryptedKeyShare {
61
100
  partnerId?: string;
62
101
  protocolId?: string;
63
102
  }
103
+ /** @deprecated use the string union type `TOAuthMethod` instead */
64
104
  export declare enum OAuthMethod {
65
105
  GOOGLE = "GOOGLE",
66
106
  TWITTER = "TWITTER",
@@ -70,6 +110,8 @@ export declare enum OAuthMethod {
70
110
  FARCASTER = "FARCASTER",
71
111
  TELEGRAM = "TELEGRAM"
72
112
  }
113
+ export declare const OAUTH_METHODS: readonly ["GOOGLE", "TWITTER", "APPLE", "DISCORD", "FACEBOOK", "FARCASTER", "TELEGRAM"];
114
+ export type TOAuthMethod = (typeof OAUTH_METHODS)[number];
73
115
  export declare enum AuthMethod {
74
116
  PASSWORD = "PASSWORD",
75
117
  PASSKEY = "PASSKEY"
@@ -87,7 +129,86 @@ export type TelegramAuthResponse = {
87
129
  photo_url?: string;
88
130
  username?: string;
89
131
  };
90
- export type AccountMetadataKey = Lowercase<Exclude<OAuthMethod, OAuthMethod.TWITTER> | 'X'>;
132
+ export type SessionInfo = {
133
+ userId?: string;
134
+ sessionId?: string;
135
+ sessionLookupId?: string;
136
+ partnerId: string;
137
+ biometricVerifiedAt?: number;
138
+ currentWalletIds?: CurrentWalletIds;
139
+ needsWallet?: boolean;
140
+ isAuthenticated?: boolean;
141
+ supportedWalletTypes: SupportedWalletTypes;
142
+ cosmosPrefix?: string;
143
+ origin?: string;
144
+ email?: string;
145
+ };
146
+ export type ServerAuthStateBase = AuthExtras & {
147
+ auth: PrimaryAuth;
148
+ userId: string;
149
+ };
150
+ export type ServerAuthStateVerify = ServerAuthStateBase & {
151
+ stage: 'verify';
152
+ signatureVerificationMessage?: string;
153
+ };
154
+ export type ServerAuthStateSignup = ServerAuthStateBase & {
155
+ stage: 'signup';
156
+ signupAuthMethods: AuthMethod[];
157
+ };
158
+ export type ServerAuthStateLogin = ServerAuthStateBase & {
159
+ stage: 'login';
160
+ biometricHints?: BiometricLocationHint[];
161
+ loginAuthMethods: AuthMethod[];
162
+ };
163
+ export type VerifyThirdPartyAuth = ServerAuthStateSignup | ServerAuthStateLogin;
164
+ export type ExternalWalletInfo = {
165
+ address: string;
166
+ type: ExternalWalletType;
167
+ provider?: string;
168
+ addressBech32?: string;
169
+ withFullParaAuth?: boolean;
170
+ ensName?: string | null;
171
+ ensAvatar?: string | null;
172
+ };
173
+ export type VerifyExternalWalletParams = {
174
+ /**
175
+ * The external wallet information to verify.
176
+ */
177
+ externalWallet: ExternalWalletInfo;
178
+ /**
179
+ * The signature of the signed verification string.
180
+ */
181
+ signedMessage: string;
182
+ /**
183
+ * For Cosmos wallets, the wallet's public key as a hex string.
184
+ */
185
+ cosmosPublicKeyHex?: string;
186
+ /**
187
+ * For Cosmos wallets, the base64 signer string.
188
+ */
189
+ cosmosSigner?: string;
190
+ };
191
+ export type LoginExternalWalletResponse = ServerAuthStateLogin | (ServerAuthStateVerify & {
192
+ signatureVerificationMessage: string;
193
+ });
194
+ export type VerifyTelegramResponse = VerifyThirdPartyAuth;
195
+ export type VerifyFarcasterResponse = VerifyThirdPartyAuth | Record<string, never>;
196
+ export type ServerAuthState = ServerAuthStateVerify | ServerAuthStateSignup | ServerAuthStateLogin;
197
+ export type SignUpOrLogInResponse = ServerAuthStateVerify | ServerAuthStateLogin;
198
+ export type Setup2faResponse = {
199
+ /**
200
+ * Indicates whether 2FA has already been set up for the current user.
201
+ */
202
+ isSetup: true;
203
+ uri: undefined;
204
+ } | {
205
+ isSetup?: false;
206
+ /**
207
+ * A URI for the user to set up two-factor authentication.
208
+ */
209
+ uri: string;
210
+ };
211
+ export type AccountMetadataKey = Lowercase<Exclude<TOAuthMethod, 'TWITTER'> | 'X'>;
91
212
  export type AccountMetadata = Partial<Record<AccountMetadataKey, {
92
213
  date: Date;
93
214
  metadata: Record<string, any>;
@@ -1,4 +1,4 @@
1
- import { Network, WalletType } from './wallet.js';
1
+ import { Network, TWalletType } from './wallet.js';
2
2
  export declare enum OnRampProvider {
3
3
  RAMP = "RAMP",
4
4
  STRIPE = "STRIPE",
@@ -30,7 +30,7 @@ export interface OnRampPurchase {
30
30
  userId: string;
31
31
  type?: OnRampPurchaseType;
32
32
  walletId?: string | null;
33
- walletType?: WalletType;
33
+ walletType?: TWalletType;
34
34
  externalWalletAddress?: string | null;
35
35
  address?: string | null;
36
36
  status?: OnRampPurchaseStatus;
@@ -51,7 +51,7 @@ export type OnRampPurchaseCreateParams = Omit<OnRampPurchase, 'id' | 'userId'> &
51
51
  };
52
52
  export type OnRampPurchaseUpdateParams = Omit<OnRampPurchase, 'id' | 'userId'>;
53
53
  type ProviderAssetInfo = [string, Partial<Record<OnRampPurchaseType, boolean>>];
54
- export type OnRampAssetInfo = Record<WalletType, Partial<Record<Network, Partial<Record<OnRampAsset, Partial<Record<OnRampProvider, ProviderAssetInfo>>>>>>>;
54
+ export type OnRampAssetInfo = Record<TWalletType, Partial<Record<Network, Partial<Record<OnRampAsset, Partial<Record<OnRampProvider, ProviderAssetInfo>>>>>>>;
55
55
  export type OnRampAllowedAssets = Partial<Record<Network, true | OnRampAsset[]>>;
56
56
  export type OnRampConfig = {
57
57
  isBuyEnabled: boolean;
@@ -1,6 +1,9 @@
1
+ import { AuthMethod } from './auth.js';
2
+ import { SupportedWalletTypes } from './wallet.js';
1
3
  export interface PartnerEntity {
2
4
  id: string;
3
5
  displayName: string;
6
+ apiKey?: string;
4
7
  logoUrl?: string;
5
8
  iconUrl?: string;
6
9
  portalHeaderLogoUrl?: string;
@@ -10,4 +13,8 @@ export interface PartnerEntity {
10
13
  accentColor?: string;
11
14
  font?: string;
12
15
  themeMode?: 'light' | 'dark';
16
+ portalUrl?: string;
17
+ supportedAuthMethods?: AuthMethod[];
18
+ supportedWalletTypes?: SupportedWalletTypes;
19
+ cosmosPrefix?: string;
13
20
  }
@@ -1,14 +1,20 @@
1
1
  import { PartnerEntity } from './partner.js';
2
+ /** @deprecated use the string union type `TWalletScheme` instead */
2
3
  export declare enum WalletScheme {
3
4
  DKLS = "DKLS",
4
5
  CGGMP = "CGGMP",
5
6
  ED25519 = "ED25519"
6
7
  }
8
+ export declare const WALLET_SCHEMES: readonly ["DKLS", "CGGMP", "ED25519"];
9
+ export type TWalletScheme = (typeof WALLET_SCHEMES)[number];
10
+ /** @deprecated use the string union type `TWalletType` instead */
7
11
  export declare enum WalletType {
8
12
  EVM = "EVM",
9
13
  SOLANA = "SOLANA",
10
14
  COSMOS = "COSMOS"
11
15
  }
16
+ export declare const WALLET_TYPES: readonly ["EVM", "SOLANA", "COSMOS"];
17
+ export type TWalletType = (typeof WALLET_TYPES)[number];
12
18
  export declare enum Chain {
13
19
  ETH = "ETH",
14
20
  CELO = "CELO",
@@ -32,7 +38,9 @@ export type WalletParams = Partial<{
32
38
  walletId?: string;
33
39
  externalWalletAddress?: string;
34
40
  }>;
35
- export declare const PREGEN_IDENTIFIER_TYPES: readonly ["EMAIL", "PHONE", "CUSTOM_ID", "GUEST_ID", "DISCORD", "TWITTER", "TELEGRAM"];
41
+ export type EmbeddedWalletType = Exclude<TWalletType, never>;
42
+ export type ExternalWalletType = Exclude<TWalletType, never>;
43
+ export declare const PREGEN_IDENTIFIER_TYPES: readonly ["EMAIL", "PHONE", "CUSTOM_ID", "GUEST_ID", "DISCORD", "TWITTER", "TELEGRAM", "FARCASTER"];
36
44
  export type TPregenIdentifierType = (typeof PREGEN_IDENTIFIER_TYPES)[number];
37
45
  export type PregenIds = Partial<Record<TPregenIdentifierType, string[]>>;
38
46
  export interface WalletEntity {
@@ -48,7 +56,7 @@ export interface WalletEntity {
48
56
  partner?: PartnerEntity;
49
57
  publicKey: string | null;
50
58
  scheme: string;
51
- type: WalletType;
59
+ type: TWalletType;
52
60
  updatedAt: string;
53
61
  userId: string | null;
54
62
  lastUsedAt: string | null;
@@ -57,5 +65,9 @@ export interface WalletEntity {
57
65
  ensName?: string | null;
58
66
  ensAvatar?: string | null;
59
67
  }
60
- export type CurrentWalletIds = Partial<Record<WalletType, string[]>>;
61
- export declare const NON_ED25519: WalletScheme[];
68
+ export type CurrentWalletIds = Partial<Record<TWalletType, string[]>>;
69
+ export declare const NON_ED25519: string[];
70
+ export type SupportedWalletTypes = {
71
+ type: TWalletType;
72
+ optional?: boolean;
73
+ }[];
@@ -1,4 +1,6 @@
1
- import { Auth, AuthParams, ExtractAuth, WalletParams, WalletRef } from './types/index.js';
1
+ import { Auth, AuthInfo, AuthParams, PrimaryAuth, PrimaryAuthInfo, VerifiedAuth, WalletParams, WalletRef } from './types/index.js';
2
+ import { AccountMetadata, AccountMetadataKey, PregenAuth, PregenAuthInfo, PregenOrGuestAuth } from './types/auth.js';
3
+ import { PregenIds, TPregenIdentifierType } from './types/wallet.js';
2
4
  export declare function isWalletId(params: WalletParams): params is {
3
5
  walletId: string;
4
6
  };
@@ -6,18 +8,51 @@ export declare function isExternalWalletAddress(params: WalletParams): params is
6
8
  externalWalletAddress: string;
7
9
  };
8
10
  export declare function extractWalletRef(params: WalletParams): [WalletRef, string];
9
- export declare function isEmail(params: AuthParams): params is Auth<'email'>;
10
- export declare function isPhone(params: AuthParams): params is Auth<'phone'>;
11
- export declare function isFarcaster(params: AuthParams): params is Auth<'farcaster'>;
12
- export declare function isTelegram(params: AuthParams): params is Auth<'telegram'>;
13
- export declare function isUserId(params: AuthParams): params is Auth<'userId'>;
14
- export declare function isExternalWallet(params: AuthParams): params is Auth<'externalWallet'>;
11
+ export declare function isEmail(params: AuthParams | undefined): params is Auth<'email'>;
12
+ export declare function isPhone(params: AuthParams | undefined): params is Auth<'phone'>;
13
+ export declare function isPhoneLegacy(params: AuthParams | undefined): params is Auth<'phoneLegacy'>;
14
+ export declare function isFarcaster(params: AuthParams | undefined): params is Auth<'farcaster'>;
15
+ export declare function isTelegram(params: AuthParams | undefined): params is Auth<'telegram'>;
16
+ export declare function isExternalWallet(params: AuthParams | undefined): params is Auth<'externalWallet'>;
17
+ export declare function isX(params: AuthParams | undefined): params is Auth<'x'>;
18
+ export declare function isDiscord(params: AuthParams | undefined): params is Auth<'discord'>;
19
+ export declare function isCustomId(params: AuthParams | undefined): params is Auth<'customId'>;
20
+ export declare function isGuestId(params: AuthParams | undefined): params is Auth<'guestId'>;
21
+ export declare function isUserId(params: AuthParams | undefined): params is Auth<'userId'>;
22
+ export declare function isPrimary(params: AuthParams | undefined): params is PrimaryAuth;
23
+ export declare function isVerifiedAuth(params: AuthParams | undefined): params is VerifiedAuth;
24
+ export declare function isPregenAuth(params: AuthParams | undefined): params is PregenAuth;
15
25
  type ExtractAuthOpts = {
16
26
  allowUserId?: boolean;
27
+ allowPregen?: boolean;
17
28
  isRequired?: boolean;
18
29
  };
30
+ export declare function extractAuthInfo(obj: AuthParams): PrimaryAuthInfo | undefined;
19
31
  export declare function extractAuthInfo(obj: AuthParams, opts: ExtractAuthOpts & {
32
+ allowUserId: false | undefined;
33
+ }): PrimaryAuthInfo | undefined;
34
+ export declare function extractAuthInfo(obj: AuthParams, opts: ExtractAuthOpts & {
35
+ isRequired: true;
36
+ allowPregen?: undefined | false;
37
+ }): PrimaryAuthInfo;
38
+ export declare function extractAuthInfo(obj: AuthParams, opts: ExtractAuthOpts & {
39
+ allowUserId: true;
40
+ }): PrimaryAuthInfo | AuthInfo<'userId'> | undefined;
41
+ export declare function extractAuthInfo(obj: AuthParams, opts: ExtractAuthOpts & {
42
+ allowUserId: true;
43
+ isRequired: true;
44
+ }): PrimaryAuthInfo | AuthInfo<'userId'>;
45
+ export declare function extractAuthInfo(obj: AuthParams, opts: ExtractAuthOpts & {
46
+ allowPregen: true;
47
+ }): PregenAuthInfo | undefined;
48
+ export declare function extractAuthInfo(obj: AuthParams, opts: ExtractAuthOpts & {
49
+ allowPregen: true;
20
50
  isRequired: true;
21
- }): ExtractAuth;
22
- export declare function extractAuthInfo(obj: AuthParams, opts?: ExtractAuthOpts): ExtractAuth | undefined;
51
+ }): PregenAuthInfo;
52
+ export declare function toPregenTypeAndId(auth: PregenOrGuestAuth): [TPregenIdentifierType, string];
53
+ export declare function toPregenIds(auth: PregenAuth): PregenIds;
54
+ export declare function fromAccountMetadata(obj: Partial<Record<AccountMetadataKey, {
55
+ date: string;
56
+ metadata: object;
57
+ }>> | undefined): AccountMetadata;
23
58
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getpara/user-management-client",
3
- "version": "1.12.0",
3
+ "version": "2.0.0-alpha.11",
4
4
  "main": "dist/cjs/index.js",
5
5
  "module": "dist/esm/index.js",
6
6
  "types": "dist/types/index.d.ts",
@@ -32,5 +32,5 @@
32
32
  "require": "./dist/cjs/index.js"
33
33
  }
34
34
  },
35
- "gitHead": "748afcf08c9d307a2d3eaf0716f73132f3eb8529"
35
+ "gitHead": "e877dc4237cc4cc3a233f3d4166cc8f5a1942900"
36
36
  }