@getpara/user-management-client 1.7.1 → 2.0.0-alpha.3
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/index.js +196 -75
- package/dist/cjs/index.js.br +0 -0
- package/dist/cjs/index.js.gz +0 -0
- package/dist/esm/index.js +184 -74
- package/dist/esm/index.js.br +0 -0
- package/dist/esm/index.js.gz +0 -0
- package/dist/types/client.d.ts +38 -49
- package/dist/types/index.d.ts +1 -0
- package/dist/types/types/auth.d.ts +123 -15
- package/dist/types/types/partner.d.ts +7 -0
- package/dist/types/types/wallet.d.ts +7 -4
- package/dist/types/utils.d.ts +39 -9
- package/package.json +2 -2
- package/dist/cjs/package.json +0 -3
- package/dist/esm/package.json +0 -4
|
@@ -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"];
|
|
3
|
+
export type AuthType = 'email' | 'phone' | 'phoneLegacy' | 'farcaster' | 'telegram' | 'userId' | 'externalWallet' | 'discord' | 'x' | 'customId';
|
|
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,46 @@ 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'>;
|
|
29
44
|
} : {
|
|
30
|
-
userId:
|
|
45
|
+
userId: AuthIdentifier<'userId'>;
|
|
46
|
+
};
|
|
47
|
+
export type PrimaryAuth = Auth<PrimaryAuthType>;
|
|
48
|
+
export type VerifiedAuth = Auth<VerifiedAuthType>;
|
|
49
|
+
export type PregenAuth = Auth<PregenAuthType>;
|
|
50
|
+
export type AuthExtras = {
|
|
51
|
+
/**
|
|
52
|
+
* The current user's third-party username.
|
|
53
|
+
*/
|
|
54
|
+
username?: string;
|
|
55
|
+
/**
|
|
56
|
+
* The current user's third-party display name.
|
|
57
|
+
*/
|
|
58
|
+
displayName?: string;
|
|
59
|
+
/**
|
|
60
|
+
* The current user's third-party profile picture URL.
|
|
61
|
+
*/
|
|
62
|
+
pfpUrl?: string;
|
|
63
|
+
/**
|
|
64
|
+
* The current user's external wallet information.
|
|
65
|
+
*/
|
|
66
|
+
externalWallet?: ExternalWalletInfo;
|
|
31
67
|
};
|
|
32
68
|
export declare enum EncryptorType {
|
|
33
69
|
USER = "USER",
|
|
@@ -87,8 +123,80 @@ export type TelegramAuthResponse = {
|
|
|
87
123
|
photo_url?: string;
|
|
88
124
|
username?: string;
|
|
89
125
|
};
|
|
90
|
-
export type
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
126
|
+
export type SessionInfo = {
|
|
127
|
+
userId?: string;
|
|
128
|
+
sessionId?: string;
|
|
129
|
+
sessionLookupId?: string;
|
|
130
|
+
partnerId: string;
|
|
131
|
+
biometricVerifiedAt?: number;
|
|
132
|
+
currentWalletIds?: CurrentWalletIds;
|
|
133
|
+
needsWallet?: boolean;
|
|
134
|
+
isAuthenticated?: boolean;
|
|
135
|
+
supportedWalletTypes: SupportedWalletTypes;
|
|
136
|
+
cosmosPrefix?: string;
|
|
137
|
+
origin?: string;
|
|
138
|
+
email?: string;
|
|
139
|
+
};
|
|
140
|
+
export type ServerAuthStateBase = AuthExtras & {
|
|
141
|
+
auth: PrimaryAuth;
|
|
142
|
+
userId: string;
|
|
143
|
+
};
|
|
144
|
+
export type ServerAuthStateVerify = ServerAuthStateBase & {
|
|
145
|
+
stage: 'verify';
|
|
146
|
+
signatureVerificationMessage?: string;
|
|
147
|
+
};
|
|
148
|
+
export type ServerAuthStateSignup = ServerAuthStateBase & {
|
|
149
|
+
stage: 'signup';
|
|
150
|
+
signupAuthMethods: AuthMethod[];
|
|
151
|
+
};
|
|
152
|
+
export type ServerAuthStateLogin = ServerAuthStateBase & {
|
|
153
|
+
stage: 'login';
|
|
154
|
+
biometricHints?: BiometricLocationHint[];
|
|
155
|
+
loginAuthMethods: AuthMethod[];
|
|
156
|
+
};
|
|
157
|
+
export type VerifyThirdPartyAuth = ServerAuthStateSignup | ServerAuthStateLogin;
|
|
158
|
+
export type ExternalWalletInfo = {
|
|
159
|
+
address: string;
|
|
160
|
+
type: ExternalWalletType;
|
|
161
|
+
provider?: string;
|
|
162
|
+
addressBech32?: string;
|
|
163
|
+
withFullParaAuth?: boolean;
|
|
164
|
+
};
|
|
165
|
+
export type VerifyExternalWalletParams = {
|
|
166
|
+
/**
|
|
167
|
+
* The external wallet information to verify.
|
|
168
|
+
*/
|
|
169
|
+
externalWallet: ExternalWalletInfo;
|
|
170
|
+
/**
|
|
171
|
+
* The signature of the signed verification string.
|
|
172
|
+
*/
|
|
173
|
+
signedMessage: string;
|
|
174
|
+
/**
|
|
175
|
+
* For Cosmos wallets, the wallet's public key as a hex string.
|
|
176
|
+
*/
|
|
177
|
+
cosmosPublicKeyHex?: string;
|
|
178
|
+
/**
|
|
179
|
+
* For Cosmos wallets, the base64 signer string.
|
|
180
|
+
*/
|
|
181
|
+
cosmosSigner?: string;
|
|
182
|
+
};
|
|
183
|
+
export type LoginExternalWalletResponse = ServerAuthStateLogin | (ServerAuthStateVerify & {
|
|
184
|
+
signatureVerificationMessage: string;
|
|
185
|
+
});
|
|
186
|
+
export type VerifyTelegramResponse = VerifyThirdPartyAuth;
|
|
187
|
+
export type VerifyFarcasterResponse = VerifyThirdPartyAuth | Record<string, never>;
|
|
188
|
+
export type ServerAuthState = ServerAuthStateVerify | ServerAuthStateSignup | ServerAuthStateLogin;
|
|
189
|
+
export type SignUpOrLogInResponse = ServerAuthStateVerify | ServerAuthStateLogin;
|
|
190
|
+
export type Setup2faResponse = {
|
|
191
|
+
/**
|
|
192
|
+
* Indicates whether 2FA has already been set up for the current user.
|
|
193
|
+
*/
|
|
194
|
+
isSetup: true;
|
|
195
|
+
uri: undefined;
|
|
196
|
+
} | {
|
|
197
|
+
isSetup?: false;
|
|
198
|
+
/**
|
|
199
|
+
* A URI for the user to set up two-factor authentication.
|
|
200
|
+
*/
|
|
201
|
+
uri: string;
|
|
202
|
+
};
|
|
@@ -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,4 +1,3 @@
|
|
|
1
|
-
import { OAuthMethod } from './auth.js';
|
|
2
1
|
import { PartnerEntity } from './partner.js';
|
|
3
2
|
export declare enum WalletScheme {
|
|
4
3
|
DKLS = "DKLS",
|
|
@@ -32,7 +31,9 @@ export type WalletParams = Partial<{
|
|
|
32
31
|
walletId?: string;
|
|
33
32
|
externalWalletAddress?: string;
|
|
34
33
|
}>;
|
|
35
|
-
export
|
|
34
|
+
export type EmbeddedWalletType = Exclude<WalletType, never>;
|
|
35
|
+
export type ExternalWalletType = Exclude<WalletType, never>;
|
|
36
|
+
export declare const PREGEN_IDENTIFIER_TYPES: readonly ["EMAIL", "PHONE", "CUSTOM_ID", "DISCORD", "TWITTER", "TELEGRAM", "FARCASTER"];
|
|
36
37
|
export type TPregenIdentifierType = (typeof PREGEN_IDENTIFIER_TYPES)[number];
|
|
37
38
|
export type PregenIds = Partial<Record<TPregenIdentifierType, string[]>>;
|
|
38
39
|
export interface WalletEntity {
|
|
@@ -54,8 +55,10 @@ export interface WalletEntity {
|
|
|
54
55
|
lastUsedAt: string | null;
|
|
55
56
|
lastUsedPartnerId?: string;
|
|
56
57
|
lastUsedPartner?: PartnerEntity;
|
|
57
|
-
ensName?: string | null;
|
|
58
|
-
ensAvatar?: string | null;
|
|
59
58
|
}
|
|
60
59
|
export type CurrentWalletIds = Partial<Record<WalletType, string[]>>;
|
|
61
60
|
export declare const NON_ED25519: WalletScheme[];
|
|
61
|
+
export type SupportedWalletTypes = {
|
|
62
|
+
type: WalletType;
|
|
63
|
+
optional?: boolean;
|
|
64
|
+
}[];
|
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 { PregenAuth, PregenAuthInfo } 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,46 @@ 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 isUserId(params: AuthParams | undefined): params is Auth<'userId'>;
|
|
21
|
+
export declare function isPrimary(params: AuthParams | undefined): params is PrimaryAuth;
|
|
22
|
+
export declare function isVerifiedAuth(params: AuthParams | undefined): params is VerifiedAuth;
|
|
23
|
+
export declare function isPregenAuth(params: AuthParams | undefined): params is PregenAuth;
|
|
15
24
|
type ExtractAuthOpts = {
|
|
16
25
|
allowUserId?: boolean;
|
|
26
|
+
allowPregen?: boolean;
|
|
17
27
|
isRequired?: boolean;
|
|
18
28
|
};
|
|
29
|
+
export declare function extractAuthInfo(obj: AuthParams): PrimaryAuthInfo | undefined;
|
|
19
30
|
export declare function extractAuthInfo(obj: AuthParams, opts: ExtractAuthOpts & {
|
|
31
|
+
allowUserId: false | undefined;
|
|
32
|
+
}): PrimaryAuthInfo | undefined;
|
|
33
|
+
export declare function extractAuthInfo(obj: AuthParams, opts: ExtractAuthOpts & {
|
|
34
|
+
isRequired: true;
|
|
35
|
+
allowPregen?: undefined | false;
|
|
36
|
+
}): PrimaryAuthInfo;
|
|
37
|
+
export declare function extractAuthInfo(obj: AuthParams, opts: ExtractAuthOpts & {
|
|
38
|
+
allowUserId: true;
|
|
39
|
+
}): PrimaryAuthInfo | AuthInfo<'userId'> | undefined;
|
|
40
|
+
export declare function extractAuthInfo(obj: AuthParams, opts: ExtractAuthOpts & {
|
|
41
|
+
allowUserId: true;
|
|
42
|
+
isRequired: true;
|
|
43
|
+
}): PrimaryAuthInfo | AuthInfo<'userId'>;
|
|
44
|
+
export declare function extractAuthInfo(obj: AuthParams, opts: ExtractAuthOpts & {
|
|
45
|
+
allowPregen: true;
|
|
46
|
+
}): PregenAuthInfo | undefined;
|
|
47
|
+
export declare function extractAuthInfo(obj: AuthParams, opts: ExtractAuthOpts & {
|
|
48
|
+
allowPregen: true;
|
|
20
49
|
isRequired: true;
|
|
21
|
-
}):
|
|
22
|
-
export declare function
|
|
50
|
+
}): PregenAuthInfo;
|
|
51
|
+
export declare function toPregenTypeAndId(auth: PregenAuth): [TPregenIdentifierType, string];
|
|
52
|
+
export declare function toPregenIds(auth: PregenAuth): PregenIds;
|
|
23
53
|
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.3",
|
|
4
4
|
"main": "dist/cjs/index.js",
|
|
5
5
|
"module": "dist/esm/index.js",
|
|
6
6
|
"types": "dist/types/index.d.ts",
|
|
@@ -33,5 +33,5 @@
|
|
|
33
33
|
"require": "./dist/cjs/index.js"
|
|
34
34
|
}
|
|
35
35
|
},
|
|
36
|
-
"gitHead": "
|
|
36
|
+
"gitHead": "77a1e04b06258842ca9c81e3db2a2b0092517659"
|
|
37
37
|
}
|
package/dist/cjs/package.json
DELETED
package/dist/esm/package.json
DELETED