@getpara/user-management-client 1.11.0 → 2.0.0-alpha.10
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.
- package/dist/cjs/client.js +55 -38
- package/dist/cjs/index.js +3 -1
- package/dist/cjs/types/auth.js +18 -0
- package/dist/cjs/types/wallet.js +9 -2
- package/dist/cjs/utils.js +175 -25
- package/dist/esm/client.js +56 -39
- package/dist/esm/index.js +1 -0
- package/dist/esm/types/auth.js +16 -0
- package/dist/esm/types/wallet.js +7 -2
- package/dist/esm/utils.js +140 -25
- package/dist/types/client.d.ts +56 -55
- package/dist/types/index.d.ts +1 -0
- package/dist/types/types/auth.d.ts +132 -11
- package/dist/types/types/onRamp.d.ts +3 -3
- package/dist/types/types/partner.d.ts +7 -0
- package/dist/types/types/wallet.d.ts +16 -4
- package/dist/types/utils.d.ts +44 -9
- package/package.json +2 -2
package/dist/types/client.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AxiosResponse } from 'axios';
|
|
2
|
-
import { AccountMetadata, Auth,
|
|
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
|
|
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:
|
|
99
|
-
type:
|
|
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?:
|
|
117
|
-
type:
|
|
91
|
+
scheme?: TWalletScheme;
|
|
92
|
+
type: TWalletType;
|
|
118
93
|
cosmosPrefix?: string;
|
|
119
94
|
}
|
|
120
95
|
interface claimPreGenWalletsBody {
|
|
@@ -141,7 +116,7 @@ interface sessionPasswordBody {
|
|
|
141
116
|
encryptedWalletPrivateKey?: string;
|
|
142
117
|
encryptionKeyHash?: string;
|
|
143
118
|
}
|
|
144
|
-
type
|
|
119
|
+
export type SDKType = 'WEB' | 'SERVER' | 'BRIDGE' | 'REACT_NATIVE';
|
|
145
120
|
export type VerifyTelegramRes = {
|
|
146
121
|
isValid: true;
|
|
147
122
|
userId: string;
|
|
@@ -157,20 +132,35 @@ export declare const handleResponseError: (error: any) => never;
|
|
|
157
132
|
declare class Client {
|
|
158
133
|
private baseRequest;
|
|
159
134
|
constructor({ userManagementHost, apiKey, partnerId, version, opts, retrieveSessionCookie, persistSessionCookie, }: ClientConfig);
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
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
|
+
*/
|
|
164
151
|
verifyEmail: (userId: string, body: verifyBody) => Promise<any>;
|
|
152
|
+
/**
|
|
153
|
+
* @deprecated
|
|
154
|
+
*/
|
|
165
155
|
verifyPhone: (userId: string, body: verifyBody) => Promise<any>;
|
|
166
|
-
verifyExternalWallet: (userId: string, body:
|
|
156
|
+
verifyExternalWallet: (userId: string, body: VerifyExternalWalletParams) => Promise<ServerAuthStateSignup>;
|
|
167
157
|
addSessionPublicKey: (userId: string, body: sessionPublicKeyBody) => Promise<any>;
|
|
168
158
|
getSessionPublicKeys: (userId: string) => Promise<any>;
|
|
169
|
-
getBiometricLocationHints: (
|
|
159
|
+
getBiometricLocationHints: (auth: PrimaryAuth) => Promise<BiometricLocationHint[]>;
|
|
170
160
|
getSessionPublicKey: (userId: string, biometricId: string) => Promise<any>;
|
|
171
161
|
patchSessionPublicKey: (partnerId: string, userId: string, biometricId: string, body: sessionPublicKeyBody) => Promise<any>;
|
|
172
|
-
getWebChallenge: (auth?: Auth) => Promise<getWebChallengeRes>;
|
|
173
|
-
touchSession: (regenerate?: boolean) => Promise<
|
|
162
|
+
getWebChallenge: (auth?: PrimaryAuth | Auth<"userId">) => Promise<getWebChallengeRes>;
|
|
163
|
+
touchSession: (regenerate?: boolean) => Promise<SessionInfo>;
|
|
174
164
|
sessionOrigin: (sessionLookupId: string) => Promise<{
|
|
175
165
|
origin?: string;
|
|
176
166
|
}>;
|
|
@@ -179,12 +169,12 @@ declare class Client {
|
|
|
179
169
|
verifySessionChallenge: (userId: string, body: verifySessionChallengeBody) => Promise<any>;
|
|
180
170
|
createWallet: (userId: string, body?: createWalletBody) => Promise<createWalletRes>;
|
|
181
171
|
createPregenWallet: (body?: createPregenWalletBody) => Promise<createWalletRes>;
|
|
182
|
-
getPregenWallets:
|
|
172
|
+
getPregenWallets: (pregenIds: PregenIds, isPortal?: boolean, userId?: string) => Promise<{
|
|
183
173
|
wallets: WalletEntity[];
|
|
184
|
-
}
|
|
185
|
-
claimPregenWallets:
|
|
186
|
-
walletIds
|
|
187
|
-
}
|
|
174
|
+
}>;
|
|
175
|
+
claimPregenWallets: (body?: claimPreGenWalletsBody) => Promise<{
|
|
176
|
+
walletIds: string[];
|
|
177
|
+
}>;
|
|
188
178
|
sendTransaction: (userId: string, walletId: string, body: sendTransactionBody) => Promise<any>;
|
|
189
179
|
signTransaction: (userId: string, walletId: string, body: signTransactionBody) => Promise<any>;
|
|
190
180
|
refreshKeys: (userId: string, walletId: string, oldPartnerId?: string, newPartnerId?: string, keyShareProtocolId?: string) => Promise<any>;
|
|
@@ -199,7 +189,7 @@ declare class Client {
|
|
|
199
189
|
logout: () => Promise<any>;
|
|
200
190
|
recoveryVerification: (email: string, verificationCode: string) => Promise<any>;
|
|
201
191
|
recoveryInit: (email: string) => Promise<any>;
|
|
202
|
-
preSignMessage: (userId: string, walletId: string, message: string, scheme?:
|
|
192
|
+
preSignMessage: (userId: string, walletId: string, message: string, scheme?: TWalletScheme, cosmosSignDoc?: string) => Promise<any>;
|
|
203
193
|
deleteSelf: (userId: string) => Promise<any>;
|
|
204
194
|
uploadKeyshares(userId: string, walletId: string, encryptedKeyshares: EncryptedKeyShare[]): Promise<any>;
|
|
205
195
|
uploadUserKeyShares(userId: string, encryptedKeyshares: (EncryptedKeyShare & {
|
|
@@ -226,10 +216,10 @@ declare class Client {
|
|
|
226
216
|
cancelRecoveryAttempt(email: string): Promise<AxiosResponse<any, any>>;
|
|
227
217
|
check2FAStatus(userId: string): Promise<AxiosResponse<any, any>>;
|
|
228
218
|
enable2FA(userId: string, verificationCode: string): Promise<AxiosResponse<any, any>>;
|
|
229
|
-
setup2FA(userId: string): Promise<
|
|
219
|
+
setup2FA(userId: string): Promise<Setup2faResponse>;
|
|
230
220
|
initializeRecovery(email: string): Promise<AxiosResponse<any, any>>;
|
|
231
221
|
initializeFarcasterLogin(): Promise<AxiosResponse<any, any>>;
|
|
232
|
-
getFarcasterAuthStatus(): Promise<
|
|
222
|
+
getFarcasterAuthStatus(): Promise<VerifyFarcasterResponse>;
|
|
233
223
|
initializeRecoveryForPhone(phone: string, countryCode: string): Promise<AxiosResponse<any, any>>;
|
|
234
224
|
finalizeRecovery(userId: string, walletId: string): Promise<AxiosResponse<any, any>>;
|
|
235
225
|
recoverUserShares(userId: string, walletId: string): Promise<AxiosResponse<{
|
|
@@ -248,8 +238,11 @@ declare class Client {
|
|
|
248
238
|
}, any>>;
|
|
249
239
|
verifyEmailForRecovery(email: string, verificationCode: string): Promise<AxiosResponse<any, any>>;
|
|
250
240
|
verifyPhoneForRecovery(phone: string, countryCode: string, verificationCode: string): Promise<AxiosResponse<any, any>>;
|
|
251
|
-
verify2FA(
|
|
252
|
-
|
|
241
|
+
verify2FA(auth: VerifiedAuth, verificationCode: string): Promise<any>;
|
|
242
|
+
/**
|
|
243
|
+
* @deprecated
|
|
244
|
+
*/
|
|
245
|
+
verify2FAForPhone(phone: AuthIdentifier<'phone'>, verificationCode: string): Promise<AxiosResponse<any, any>>;
|
|
253
246
|
tempTrasmissionInit(message: string, userId?: string): Promise<AxiosResponse<any, any>>;
|
|
254
247
|
tempTrasmission(id: string): Promise<AxiosResponse<any, any>>;
|
|
255
248
|
getPartner(partnerId: string): Promise<AxiosResponse<any, any>>;
|
|
@@ -272,7 +265,7 @@ declare class Client {
|
|
|
272
265
|
} & WalletParams): Promise<AxiosResponse<OnRampPurchase, any>>;
|
|
273
266
|
signMoonPayUrl(userId: string, { url, type, cosmosPrefix, testMode, walletId, externalWalletAddress, }: {
|
|
274
267
|
url: string;
|
|
275
|
-
type:
|
|
268
|
+
type: TWalletType;
|
|
276
269
|
cosmosPrefix: string;
|
|
277
270
|
testMode?: boolean;
|
|
278
271
|
walletId?: string;
|
|
@@ -291,7 +284,7 @@ declare class Client {
|
|
|
291
284
|
contractAddress?: string;
|
|
292
285
|
testMode?: boolean;
|
|
293
286
|
walletId: string;
|
|
294
|
-
walletType:
|
|
287
|
+
walletType: TWalletType;
|
|
295
288
|
destinationAddress: string;
|
|
296
289
|
sourceAddress?: string;
|
|
297
290
|
assetQuantity: string | number;
|
|
@@ -304,7 +297,7 @@ declare class Client {
|
|
|
304
297
|
sourceAddress?: string;
|
|
305
298
|
network: Network;
|
|
306
299
|
walletId: string;
|
|
307
|
-
walletType:
|
|
300
|
+
walletType: TWalletType;
|
|
308
301
|
}): Promise<ReturnType>;
|
|
309
302
|
distributeParaShare({ userId, walletId, ...rest }: {
|
|
310
303
|
userId: string;
|
|
@@ -343,10 +336,18 @@ declare class Client {
|
|
|
343
336
|
getAccountMetadata(userId: string, partnerId: string): Promise<{
|
|
344
337
|
accountMetadata: AccountMetadata;
|
|
345
338
|
}>;
|
|
346
|
-
getWalletBalance: ({
|
|
347
|
-
userId: string;
|
|
339
|
+
getWalletBalance: ({ walletId, rpcUrl }: {
|
|
348
340
|
walletId: string;
|
|
349
341
|
rpcUrl?: string;
|
|
350
342
|
}) => Promise<GetWalletBalanceRes>;
|
|
343
|
+
trackError: (opts: {
|
|
344
|
+
methodName: string;
|
|
345
|
+
error: {
|
|
346
|
+
name: string;
|
|
347
|
+
message: string;
|
|
348
|
+
};
|
|
349
|
+
sdkType: SDKType;
|
|
350
|
+
userId: string;
|
|
351
|
+
}) => Promise<void>;
|
|
351
352
|
}
|
|
352
353
|
export default Client;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,11 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
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:
|
|
6
|
-
publicKeyIdentifier: string;
|
|
11
|
+
identifier: AuthIdentifier<T>;
|
|
7
12
|
};
|
|
8
|
-
export type
|
|
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 '
|
|
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:
|
|
33
|
+
farcasterUsername: AuthIdentifier<'farcaster'>;
|
|
25
34
|
} : T extends 'telegram' ? {
|
|
26
|
-
telegramUserId:
|
|
35
|
+
telegramUserId: AuthIdentifier<'telegram'>;
|
|
27
36
|
} : T extends 'externalWallet' ? {
|
|
28
|
-
externalWalletAddress:
|
|
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:
|
|
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
|
|
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,
|
|
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?:
|
|
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<
|
|
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
|
|
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:
|
|
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<
|
|
61
|
-
export declare const NON_ED25519:
|
|
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
|
+
}[];
|
package/dist/types/utils.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import { Auth, AuthParams,
|
|
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
|
|
12
|
-
export declare function
|
|
13
|
-
export declare function
|
|
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
|
-
}):
|
|
22
|
-
export declare function
|
|
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": "
|
|
3
|
+
"version": "2.0.0-alpha.10",
|
|
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": "
|
|
35
|
+
"gitHead": "92904c321f1dd8101046d8d2d70aa341bac99842"
|
|
36
36
|
}
|