@forge-connect/react 0.1.0 → 1.0.1
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/index.cjs +3783 -573
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +459 -37
- package/dist/index.d.ts +459 -37
- package/dist/index.js +3674 -434
- package/dist/index.js.map +1 -1
- package/dist/styles.css +1010 -147
- package/package.json +20 -8
package/dist/index.d.ts
CHANGED
|
@@ -2,25 +2,70 @@ import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
|
2
2
|
import * as react from 'react';
|
|
3
3
|
import { ReactNode } from 'react';
|
|
4
4
|
|
|
5
|
-
type OAuthProvider = 'google' | 'discord' | 'twitter' | 'apple';
|
|
5
|
+
type OAuthProvider = 'google' | 'discord' | 'twitter' | 'apple' | 'telegram';
|
|
6
6
|
type Chain = 'solana' | 'ethereum';
|
|
7
|
+
/** A login method entry for the method selector. OAuth providers are individual entries. */
|
|
8
|
+
type LoginMethod = 'email' | 'otp' | 'wallet' | 'passkey' | OAuthProvider;
|
|
9
|
+
/** Wallet display preferences for the wallet connect step. */
|
|
10
|
+
interface WalletConfig {
|
|
11
|
+
/** Wallet adapter names shown first (e.g. ['Phantom', 'Solflare']). */
|
|
12
|
+
preferredWallets?: string[];
|
|
13
|
+
/** If true, only show wallets listed in preferredWallets. Default: false. */
|
|
14
|
+
onlyPreferred?: boolean;
|
|
15
|
+
}
|
|
7
16
|
interface ForgeConnectConfig {
|
|
8
17
|
/** Base URL of the ForgeConnect API */
|
|
9
18
|
apiUrl: string;
|
|
10
|
-
/**
|
|
19
|
+
/**
|
|
20
|
+
* Ordered array of login methods. Controls what shows in the method
|
|
21
|
+
* selector and in what order. Each OAuth provider is a separate entry.
|
|
22
|
+
*
|
|
23
|
+
* @example ['google', 'discord', 'email', 'wallet']
|
|
24
|
+
*
|
|
25
|
+
* When set, this is the single source of truth. Legacy fields
|
|
26
|
+
* (oauthProviders, walletLogin, passwordlessLogin) are ignored.
|
|
27
|
+
*/
|
|
28
|
+
loginMethods?: LoginMethod[];
|
|
29
|
+
/**
|
|
30
|
+
* Skip the method selector and go directly to this login step.
|
|
31
|
+
* Must be present in loginMethods (or enabled via legacy fields).
|
|
32
|
+
*
|
|
33
|
+
* @example 'wallet' // opens directly to wallet connect
|
|
34
|
+
*/
|
|
35
|
+
defaultLoginMethod?: LoginMethod;
|
|
36
|
+
/** Wallet display preferences */
|
|
37
|
+
walletConfig?: WalletConfig;
|
|
38
|
+
/**
|
|
39
|
+
* WebAuthn Relying Party ID for passkeys. Must match the frontend domain
|
|
40
|
+
* (e.g. 'forgeconnect.dev'). Defaults to the server's WEBAUTHN_RP_ID env var.
|
|
41
|
+
*/
|
|
42
|
+
webauthnRpId?: string;
|
|
43
|
+
/**
|
|
44
|
+
* WebAuthn origin for passkeys. Must match the frontend URL with protocol
|
|
45
|
+
* (e.g. 'https://forgeconnect.dev'). Defaults to the server's WEBAUTHN_ORIGIN env var.
|
|
46
|
+
*/
|
|
47
|
+
webauthnOrigin?: string;
|
|
48
|
+
/** @deprecated Use loginMethods instead. */
|
|
11
49
|
oauthProviders?: OAuthProvider[];
|
|
12
|
-
/**
|
|
50
|
+
/** @deprecated Use loginMethods instead. */
|
|
13
51
|
walletLogin?: boolean;
|
|
14
|
-
/**
|
|
52
|
+
/** @deprecated Use loginMethods instead. */
|
|
15
53
|
passwordlessLogin?: boolean;
|
|
16
54
|
/** Appearance customization */
|
|
17
55
|
appearance?: AppearanceConfig;
|
|
18
56
|
}
|
|
19
57
|
interface AppearanceConfig {
|
|
20
|
-
theme?: 'light' | 'dark';
|
|
58
|
+
theme?: 'light' | 'dark' | 'glass';
|
|
21
59
|
accentColor?: string;
|
|
60
|
+
/** URL or imported image source for the modal logo. */
|
|
22
61
|
logo?: string;
|
|
62
|
+
/** ReactNode logo — pass a React component (SVG, etc.) instead of a URL. */
|
|
63
|
+
logoNode?: unknown;
|
|
23
64
|
title?: string;
|
|
65
|
+
/** URL to your Terms of Service page. Shown at the bottom of the modal. */
|
|
66
|
+
termsUrl?: string;
|
|
67
|
+
/** URL to your Privacy Policy page. Shown at the bottom of the modal. */
|
|
68
|
+
privacyUrl?: string;
|
|
24
69
|
}
|
|
25
70
|
interface User {
|
|
26
71
|
id: string;
|
|
@@ -31,11 +76,12 @@ interface User {
|
|
|
31
76
|
createdAt: string;
|
|
32
77
|
updatedAt: string;
|
|
33
78
|
}
|
|
34
|
-
type AuthProvider = 'email' | 'google' | 'twitter' | 'discord' | 'apple' | 'solana_wallet' | 'ethereum_wallet';
|
|
79
|
+
type AuthProvider = 'email' | 'google' | 'twitter' | 'discord' | 'apple' | 'telegram' | 'solana_wallet' | 'ethereum_wallet';
|
|
35
80
|
interface AuthMethod {
|
|
36
81
|
id: string;
|
|
37
82
|
provider: AuthProvider;
|
|
38
83
|
providerId: string;
|
|
84
|
+
providerUsername: string | null;
|
|
39
85
|
isVerified: boolean;
|
|
40
86
|
verifiedAt: string | null;
|
|
41
87
|
createdAt: string;
|
|
@@ -64,36 +110,109 @@ interface AuthState {
|
|
|
64
110
|
user: User | null;
|
|
65
111
|
accessToken: string | null;
|
|
66
112
|
}
|
|
67
|
-
type ModalStep = 'method-select' | 'email-login' | 'email-register' | 'email-otp' | 'wallet-connect' | 'oauth';
|
|
113
|
+
type ModalStep = 'method-select' | 'email-login' | 'email-register' | 'email-otp' | 'wallet-connect' | 'oauth' | 'forgot-password' | 'verify-2fa' | 'success' | 'error';
|
|
68
114
|
interface ModalState {
|
|
69
115
|
isOpen: boolean;
|
|
70
116
|
step: ModalStep;
|
|
71
117
|
}
|
|
72
|
-
|
|
73
|
-
interface
|
|
74
|
-
|
|
75
|
-
children: ReactNode;
|
|
76
|
-
/** Called when user successfully authenticates */
|
|
77
|
-
onLogin?: (user: User) => void;
|
|
78
|
-
/** Called when user logs out */
|
|
79
|
-
onLogout?: () => void;
|
|
80
|
-
}
|
|
81
|
-
declare function ForgeConnectProvider({ config, children, onLogin, onLogout }: ForgeConnectProviderProps): react_jsx_runtime.JSX.Element;
|
|
82
|
-
|
|
83
|
-
interface LoginButtonProps {
|
|
84
|
-
className?: string;
|
|
85
|
-
label?: string;
|
|
118
|
+
type AccountModalTab = 'profile' | 'auth-methods' | 'wallets' | 'sessions';
|
|
119
|
+
interface AccountModalState {
|
|
120
|
+
isOpen: boolean;
|
|
86
121
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
declare function LoginModal(): react_jsx_runtime.JSX.Element;
|
|
90
|
-
|
|
91
|
-
interface ModalOverlayProps {
|
|
122
|
+
interface LinkModalState {
|
|
92
123
|
isOpen: boolean;
|
|
93
|
-
|
|
94
|
-
|
|
124
|
+
/** 'auth' shows only social/email methods, 'wallet' jumps straight to wallet connect. Default: 'auth'. */
|
|
125
|
+
mode?: 'auth' | 'wallet';
|
|
126
|
+
}
|
|
127
|
+
interface TotpSetup {
|
|
128
|
+
secret: string;
|
|
129
|
+
qrCodeDataUrl: string;
|
|
130
|
+
recoveryCodes: string[];
|
|
131
|
+
}
|
|
132
|
+
interface Passkey {
|
|
133
|
+
id: string;
|
|
134
|
+
credentialId: string;
|
|
135
|
+
name: string | null;
|
|
136
|
+
deviceType: string | null;
|
|
137
|
+
backedUp: boolean;
|
|
138
|
+
createdAt: string;
|
|
139
|
+
lastUsedAt: string | null;
|
|
140
|
+
}
|
|
141
|
+
interface TwoFactorStatus {
|
|
142
|
+
enabled: boolean;
|
|
143
|
+
hasPasskeys: boolean;
|
|
144
|
+
}
|
|
145
|
+
interface LoginResponse {
|
|
146
|
+
accessToken: string;
|
|
147
|
+
requires2FA?: boolean;
|
|
148
|
+
challengeToken?: string;
|
|
149
|
+
user?: {
|
|
150
|
+
id: string;
|
|
151
|
+
displayName?: string | null;
|
|
152
|
+
email?: string;
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
interface Role {
|
|
156
|
+
id: string;
|
|
157
|
+
name: string;
|
|
158
|
+
description: string | null;
|
|
159
|
+
permissions: string[];
|
|
160
|
+
isSystem: boolean;
|
|
161
|
+
tenantId: string | null;
|
|
162
|
+
createdBy: string | null;
|
|
163
|
+
createdAt: string;
|
|
164
|
+
userCount?: number;
|
|
165
|
+
}
|
|
166
|
+
interface UserRoleAssignment {
|
|
167
|
+
roleId: string;
|
|
168
|
+
roleName: string;
|
|
169
|
+
permissions: string[];
|
|
170
|
+
isSystem: boolean;
|
|
171
|
+
tenantId: string | null;
|
|
172
|
+
}
|
|
173
|
+
type PermissionDomains = Record<string, string[]>;
|
|
174
|
+
/** A user assigned to a role, including their auth methods. */
|
|
175
|
+
interface RoleUser {
|
|
176
|
+
id: string;
|
|
177
|
+
displayName: string | null;
|
|
178
|
+
primaryEmail: string | null;
|
|
179
|
+
avatarUrl: string | null;
|
|
180
|
+
status: string;
|
|
181
|
+
createdAt: string;
|
|
182
|
+
authMethods: {
|
|
183
|
+
provider: string;
|
|
184
|
+
providerId: string;
|
|
185
|
+
providerUsername: string | null;
|
|
186
|
+
isVerified: boolean | null;
|
|
187
|
+
}[];
|
|
188
|
+
grantedAt: string | null;
|
|
189
|
+
}
|
|
190
|
+
type UserStatus = 'active' | 'suspended' | 'deleted';
|
|
191
|
+
interface PaginatedResponse<T> {
|
|
192
|
+
data: T[];
|
|
193
|
+
page: number;
|
|
194
|
+
limit: number;
|
|
195
|
+
total: number;
|
|
196
|
+
}
|
|
197
|
+
interface AdminUser extends User {
|
|
198
|
+
authMethods: AuthMethod[];
|
|
199
|
+
wallets: Wallet[];
|
|
200
|
+
}
|
|
201
|
+
interface TokenVerificationResult {
|
|
202
|
+
active: boolean;
|
|
203
|
+
user_id?: string;
|
|
204
|
+
tenant_id?: string;
|
|
205
|
+
scopes?: string[];
|
|
206
|
+
role?: string;
|
|
207
|
+
permissions?: string[];
|
|
208
|
+
roles?: {
|
|
209
|
+
name: string;
|
|
210
|
+
permissions: string[];
|
|
211
|
+
}[];
|
|
212
|
+
}
|
|
213
|
+
interface WalletUserResult {
|
|
214
|
+
user_id: string;
|
|
95
215
|
}
|
|
96
|
-
declare function ModalOverlay({ isOpen, onClose, children }: ModalOverlayProps): react.ReactPortal | null;
|
|
97
216
|
|
|
98
217
|
declare class ForgeConnectApiError extends Error {
|
|
99
218
|
readonly status: number;
|
|
@@ -105,8 +224,10 @@ declare function createApiClient(apiUrl: string): {
|
|
|
105
224
|
success: true;
|
|
106
225
|
}>;
|
|
107
226
|
login(email: string, password: string): Promise<{
|
|
108
|
-
accessToken
|
|
109
|
-
|
|
227
|
+
accessToken?: string;
|
|
228
|
+
requires2FA?: boolean;
|
|
229
|
+
challengeToken?: string;
|
|
230
|
+
user?: {
|
|
110
231
|
id: string;
|
|
111
232
|
displayName: string | null;
|
|
112
233
|
email: string;
|
|
@@ -116,18 +237,40 @@ declare function createApiClient(apiUrl: string): {
|
|
|
116
237
|
success: true;
|
|
117
238
|
}>;
|
|
118
239
|
verifyOtp(email: string, code: string): Promise<{
|
|
119
|
-
accessToken
|
|
120
|
-
|
|
240
|
+
accessToken?: string;
|
|
241
|
+
requires2FA?: boolean;
|
|
242
|
+
challengeToken?: string;
|
|
243
|
+
user?: {
|
|
121
244
|
id: string;
|
|
122
245
|
email: string;
|
|
123
246
|
};
|
|
124
247
|
}>;
|
|
125
248
|
walletChallenge(walletAddress: string, chain?: string): Promise<{
|
|
126
249
|
challengeId: string;
|
|
127
|
-
|
|
250
|
+
message: string;
|
|
128
251
|
}>;
|
|
129
252
|
walletVerify(challengeId: string, signature: string, walletAddress: string): Promise<{
|
|
130
|
-
accessToken
|
|
253
|
+
accessToken?: string;
|
|
254
|
+
requires2FA?: boolean;
|
|
255
|
+
challengeToken?: string;
|
|
256
|
+
}>;
|
|
257
|
+
walletChallengeTx(walletAddress: string, chain?: string): Promise<{
|
|
258
|
+
challengeId: string;
|
|
259
|
+
transaction: string;
|
|
260
|
+
}>;
|
|
261
|
+
walletVerifyTx(challengeId: string, signedTransaction: string, walletAddress: string): Promise<{
|
|
262
|
+
accessToken?: string;
|
|
263
|
+
requires2FA?: boolean;
|
|
264
|
+
challengeToken?: string;
|
|
265
|
+
}>;
|
|
266
|
+
exchangeOAuthCode(code: string): Promise<{
|
|
267
|
+
accessToken?: string;
|
|
268
|
+
requires2FA?: boolean;
|
|
269
|
+
challengeToken?: string;
|
|
270
|
+
userId?: string;
|
|
271
|
+
}>;
|
|
272
|
+
createLinkIntent(token: string): Promise<{
|
|
273
|
+
intentToken: string;
|
|
131
274
|
}>;
|
|
132
275
|
refresh(): Promise<{
|
|
133
276
|
accessToken: string;
|
|
@@ -159,10 +302,14 @@ declare function createApiClient(apiUrl: string): {
|
|
|
159
302
|
createdAt: string;
|
|
160
303
|
updatedAt: string;
|
|
161
304
|
}>;
|
|
305
|
+
setPassword(token: string, newPassword: string, currentPassword?: string): Promise<{
|
|
306
|
+
success: true;
|
|
307
|
+
}>;
|
|
162
308
|
getAuthMethods(token: string): Promise<{
|
|
163
309
|
id: string;
|
|
164
310
|
provider: string;
|
|
165
311
|
providerId: string;
|
|
312
|
+
providerUsername: string | null;
|
|
166
313
|
isVerified: boolean;
|
|
167
314
|
verifiedAt: string | null;
|
|
168
315
|
createdAt: string;
|
|
@@ -177,6 +324,12 @@ declare function createApiClient(apiUrl: string): {
|
|
|
177
324
|
}): Promise<{
|
|
178
325
|
success: true;
|
|
179
326
|
}>;
|
|
327
|
+
linkOtpSend(token: string, email: string): Promise<{
|
|
328
|
+
success: true;
|
|
329
|
+
}>;
|
|
330
|
+
linkOtpVerify(token: string, email: string, code: string): Promise<{
|
|
331
|
+
success: true;
|
|
332
|
+
}>;
|
|
180
333
|
unlinkAuthMethod(token: string, id: string): Promise<{
|
|
181
334
|
success: true;
|
|
182
335
|
}>;
|
|
@@ -214,6 +367,107 @@ declare function createApiClient(apiUrl: string): {
|
|
|
214
367
|
revokeSession(token: string, id: string): Promise<{
|
|
215
368
|
success: true;
|
|
216
369
|
}>;
|
|
370
|
+
verifyEmailToken(token: string): Promise<{
|
|
371
|
+
accessToken?: string;
|
|
372
|
+
requires2FA?: boolean;
|
|
373
|
+
challengeToken?: string;
|
|
374
|
+
}>;
|
|
375
|
+
forgotPassword(email: string): Promise<{
|
|
376
|
+
success: true;
|
|
377
|
+
}>;
|
|
378
|
+
resetPassword(token: string, password: string): Promise<{
|
|
379
|
+
success: true;
|
|
380
|
+
}>;
|
|
381
|
+
get2FAStatus(token: string): Promise<{
|
|
382
|
+
enabled: boolean;
|
|
383
|
+
}>;
|
|
384
|
+
setup2FA(token: string): Promise<TotpSetup>;
|
|
385
|
+
enable2FA(token: string, code: string): Promise<{
|
|
386
|
+
success: true;
|
|
387
|
+
}>;
|
|
388
|
+
disable2FA(token: string, code: string): Promise<{
|
|
389
|
+
success: true;
|
|
390
|
+
}>;
|
|
391
|
+
verify2FA(challengeToken: string, code: string): Promise<{
|
|
392
|
+
accessToken: string;
|
|
393
|
+
}>;
|
|
394
|
+
verifyRecoveryCode(challengeToken: string, code: string): Promise<{
|
|
395
|
+
accessToken: string;
|
|
396
|
+
}>;
|
|
397
|
+
regenerateRecoveryCodes(token: string, code: string): Promise<{
|
|
398
|
+
recoveryCodes: string[];
|
|
399
|
+
}>;
|
|
400
|
+
getPasskeys(token: string): Promise<Passkey[]>;
|
|
401
|
+
getPasskeyRegisterOptions(token: string, rpId?: string, origin?: string): Promise<{
|
|
402
|
+
options: any;
|
|
403
|
+
challengeKey: string;
|
|
404
|
+
}>;
|
|
405
|
+
verifyPasskeyRegistration(token: string, challengeKey: string, response: any, name?: string, rpId?: string, origin?: string): Promise<Passkey>;
|
|
406
|
+
getPasskeyLoginOptions(rpId?: string): Promise<{
|
|
407
|
+
options: any;
|
|
408
|
+
challengeKey: string;
|
|
409
|
+
}>;
|
|
410
|
+
verifyPasskeyLogin(challengeKey: string, response: any, rpId?: string, origin?: string): Promise<{
|
|
411
|
+
accessToken: string;
|
|
412
|
+
}>;
|
|
413
|
+
renamePasskey(token: string, id: string, name: string): Promise<Passkey>;
|
|
414
|
+
deletePasskey(token: string, id: string): Promise<{
|
|
415
|
+
success: true;
|
|
416
|
+
}>;
|
|
417
|
+
requestAccountDeletion(token: string): Promise<{
|
|
418
|
+
requiresVerification: boolean;
|
|
419
|
+
}>;
|
|
420
|
+
confirmAccountDeletion(token: string, code?: string): Promise<{
|
|
421
|
+
success: true;
|
|
422
|
+
}>;
|
|
423
|
+
adminListUsers(token: string, params?: {
|
|
424
|
+
page?: number;
|
|
425
|
+
limit?: number;
|
|
426
|
+
search?: string;
|
|
427
|
+
}): Promise<PaginatedResponse<User>>;
|
|
428
|
+
adminGetUser(token: string, id: string): Promise<AdminUser>;
|
|
429
|
+
adminUpdateUserStatus(token: string, id: string, status: UserStatus): Promise<{
|
|
430
|
+
success: true;
|
|
431
|
+
}>;
|
|
432
|
+
adminGetUserSessions(token: string, id: string): Promise<Session[]>;
|
|
433
|
+
adminRevokeUserSessions(token: string, id: string): Promise<{
|
|
434
|
+
success: true;
|
|
435
|
+
}>;
|
|
436
|
+
adminListRoles(token: string, tenantId?: string): Promise<{
|
|
437
|
+
data: Role[];
|
|
438
|
+
}>;
|
|
439
|
+
adminGetRole(token: string, id: string): Promise<Role>;
|
|
440
|
+
adminGetRoleUsers(token: string, id: string): Promise<{
|
|
441
|
+
data: RoleUser[];
|
|
442
|
+
}>;
|
|
443
|
+
adminCreateRole(token: string, data: {
|
|
444
|
+
name: string;
|
|
445
|
+
description?: string;
|
|
446
|
+
permissions: string[];
|
|
447
|
+
tenantId?: string;
|
|
448
|
+
}): Promise<Role>;
|
|
449
|
+
adminUpdateRole(token: string, id: string, data: {
|
|
450
|
+
name?: string;
|
|
451
|
+
description?: string;
|
|
452
|
+
permissions?: string[];
|
|
453
|
+
}): Promise<Role>;
|
|
454
|
+
adminDeleteRole(token: string, id: string): Promise<{
|
|
455
|
+
success: true;
|
|
456
|
+
}>;
|
|
457
|
+
adminGetPermissions(token: string): Promise<{
|
|
458
|
+
domains: PermissionDomains;
|
|
459
|
+
}>;
|
|
460
|
+
adminGetUserRoles(token: string, userId: string, tenantId?: string): Promise<{
|
|
461
|
+
data: UserRoleAssignment[];
|
|
462
|
+
}>;
|
|
463
|
+
adminAssignRole(token: string, userId: string, roleId: string, tenantId?: string): Promise<{
|
|
464
|
+
success: true;
|
|
465
|
+
}>;
|
|
466
|
+
adminRevokeRole(token: string, userId: string, roleId: string, tenantId?: string): Promise<{
|
|
467
|
+
success: true;
|
|
468
|
+
}>;
|
|
469
|
+
serviceVerifyToken(serviceKey: string, accessToken: string, tenantId?: string): Promise<TokenVerificationResult>;
|
|
470
|
+
serviceUserByWallet(serviceKey: string, walletAddress: string, chain?: string): Promise<WalletUserResult>;
|
|
217
471
|
};
|
|
218
472
|
type ApiClient = ReturnType<typeof createApiClient>;
|
|
219
473
|
|
|
@@ -226,17 +480,116 @@ interface ForgeConnectContextValue {
|
|
|
226
480
|
register: (email: string, password: string, displayName?: string) => Promise<void>;
|
|
227
481
|
sendOtp: (email: string) => Promise<void>;
|
|
228
482
|
verifyOtp: (email: string, code: string) => Promise<void>;
|
|
229
|
-
loginWithWallet: (walletAddress: string, signMessage: (message: Uint8Array) => Promise<Uint8Array
|
|
483
|
+
loginWithWallet: (walletAddress: string, signMessage: ((message: Uint8Array) => Promise<Uint8Array>) | undefined, chain?: string, signTransaction?: (txBase64: string) => Promise<string>) => Promise<void>;
|
|
230
484
|
loginWithOAuth: (provider: string) => void;
|
|
485
|
+
loginWithPasskey: () => Promise<void>;
|
|
231
486
|
logout: () => Promise<void>;
|
|
232
487
|
logoutAll: () => Promise<void>;
|
|
488
|
+
forgotPassword: (email: string) => Promise<void>;
|
|
489
|
+
resetPassword: (token: string, password: string) => Promise<void>;
|
|
490
|
+
verifyEmailToken: (token: string) => Promise<void>;
|
|
491
|
+
challengeToken: string | null;
|
|
492
|
+
verify2FA: (code: string) => Promise<void>;
|
|
493
|
+
verifyRecoveryCode: (code: string) => Promise<void>;
|
|
233
494
|
openModal: () => void;
|
|
234
495
|
closeModal: () => void;
|
|
235
496
|
setModalStep: (step: ModalState['step']) => void;
|
|
497
|
+
accountModal: AccountModalState;
|
|
498
|
+
openAccountModal: () => void;
|
|
499
|
+
closeAccountModal: () => void;
|
|
500
|
+
linkModal: LinkModalState;
|
|
501
|
+
openLinkModal: (mode?: 'auth' | 'wallet') => void;
|
|
502
|
+
closeLinkModal: () => void;
|
|
236
503
|
getAccessToken: () => string | null;
|
|
504
|
+
walletAdapter: WalletAdapterContext | null;
|
|
505
|
+
}
|
|
506
|
+
interface WalletAdapterContext {
|
|
507
|
+
publicKey: {
|
|
508
|
+
toBase58(): string;
|
|
509
|
+
} | null;
|
|
510
|
+
signMessage: ((message: Uint8Array) => Promise<Uint8Array>) | undefined;
|
|
511
|
+
signTransaction: ((transaction: any) => Promise<any>) | undefined;
|
|
512
|
+
wallets: Array<{
|
|
513
|
+
adapter: {
|
|
514
|
+
name: string;
|
|
515
|
+
icon: string;
|
|
516
|
+
connected: boolean;
|
|
517
|
+
};
|
|
518
|
+
readyState: string;
|
|
519
|
+
}>;
|
|
520
|
+
select: (name: string) => void;
|
|
521
|
+
connect: () => Promise<void>;
|
|
237
522
|
}
|
|
238
523
|
declare const ForgeConnectContext: react.Context<ForgeConnectContextValue | null>;
|
|
239
524
|
|
|
525
|
+
interface ForgeConnectProviderProps {
|
|
526
|
+
config: ForgeConnectConfig;
|
|
527
|
+
children: ReactNode;
|
|
528
|
+
/** Called when user successfully authenticates */
|
|
529
|
+
onLogin?: (user: User) => void;
|
|
530
|
+
/** Called when user logs out */
|
|
531
|
+
onLogout?: () => void;
|
|
532
|
+
/** Pass `useWallet()` from @solana/wallet-adapter-react to enable wallet login */
|
|
533
|
+
walletAdapter?: WalletAdapterContext | null;
|
|
534
|
+
}
|
|
535
|
+
declare function ForgeConnectProvider({ config, children, onLogin, onLogout, walletAdapter }: ForgeConnectProviderProps): react_jsx_runtime.JSX.Element;
|
|
536
|
+
|
|
537
|
+
interface LoginButtonProps {
|
|
538
|
+
className?: string;
|
|
539
|
+
label?: string;
|
|
540
|
+
}
|
|
541
|
+
declare function LoginButton({ className, label }: LoginButtonProps): react_jsx_runtime.JSX.Element;
|
|
542
|
+
|
|
543
|
+
declare function LoginModal(): react_jsx_runtime.JSX.Element;
|
|
544
|
+
|
|
545
|
+
declare function AccountModal(): react_jsx_runtime.JSX.Element | null;
|
|
546
|
+
|
|
547
|
+
declare function LinkAuthModal(): react_jsx_runtime.JSX.Element | null;
|
|
548
|
+
|
|
549
|
+
interface AccountButtonProps {
|
|
550
|
+
className?: string;
|
|
551
|
+
loginLabel?: string;
|
|
552
|
+
compact?: boolean;
|
|
553
|
+
}
|
|
554
|
+
declare function AccountButton({ className, loginLabel, compact }: AccountButtonProps): react_jsx_runtime.JSX.Element;
|
|
555
|
+
|
|
556
|
+
interface TwoFactorModalProps {
|
|
557
|
+
isOpen: boolean;
|
|
558
|
+
onClose: () => void;
|
|
559
|
+
initialEnabled: boolean;
|
|
560
|
+
onStatusChange: (enabled: boolean) => void;
|
|
561
|
+
}
|
|
562
|
+
declare function TwoFactorModal({ isOpen, onClose, initialEnabled, onStatusChange }: TwoFactorModalProps): react_jsx_runtime.JSX.Element | null;
|
|
563
|
+
|
|
564
|
+
interface PasskeysModalProps {
|
|
565
|
+
isOpen: boolean;
|
|
566
|
+
onClose: () => void;
|
|
567
|
+
onCountChange: (count: number) => void;
|
|
568
|
+
}
|
|
569
|
+
declare function PasskeysModal({ isOpen, onClose, onCountChange }: PasskeysModalProps): react_jsx_runtime.JSX.Element | null;
|
|
570
|
+
|
|
571
|
+
interface DeleteAccountModalProps {
|
|
572
|
+
isOpen: boolean;
|
|
573
|
+
onClose: () => void;
|
|
574
|
+
onDeleted: () => void;
|
|
575
|
+
}
|
|
576
|
+
declare function DeleteAccountModal({ isOpen, onClose, onDeleted }: DeleteAccountModalProps): react_jsx_runtime.JSX.Element | null;
|
|
577
|
+
|
|
578
|
+
interface ModalOverlayProps {
|
|
579
|
+
isOpen: boolean;
|
|
580
|
+
onClose: () => void;
|
|
581
|
+
children: ReactNode;
|
|
582
|
+
}
|
|
583
|
+
declare function ModalOverlay({ isOpen, onClose, children }: ModalOverlayProps): react.ReactPortal | null;
|
|
584
|
+
|
|
585
|
+
interface ErrorViewProps {
|
|
586
|
+
title?: string;
|
|
587
|
+
message?: string;
|
|
588
|
+
onRetry?: () => void;
|
|
589
|
+
onClose?: () => void;
|
|
590
|
+
}
|
|
591
|
+
declare function ErrorView({ title, message, onRetry, onClose, }: ErrorViewProps): react_jsx_runtime.JSX.Element;
|
|
592
|
+
|
|
240
593
|
declare function useForgeConnect(): ForgeConnectContextValue;
|
|
241
594
|
|
|
242
595
|
declare function useUser(): {
|
|
@@ -259,6 +612,7 @@ declare function useUser(): {
|
|
|
259
612
|
id: string;
|
|
260
613
|
provider: string;
|
|
261
614
|
providerId: string;
|
|
615
|
+
providerUsername: string | null;
|
|
262
616
|
isVerified: boolean;
|
|
263
617
|
verifiedAt: string | null;
|
|
264
618
|
createdAt: string;
|
|
@@ -271,7 +625,10 @@ declare function useUser(): {
|
|
|
271
625
|
signature?: string;
|
|
272
626
|
walletAddress?: string;
|
|
273
627
|
}) => Promise<void>;
|
|
628
|
+
linkOtpSend: (email: string) => Promise<void>;
|
|
629
|
+
linkOtpVerify: (email: string, code: string) => Promise<void>;
|
|
274
630
|
unlinkAuthMethod: (id: string) => Promise<void>;
|
|
631
|
+
linkOAuth: (provider: string) => Promise<void>;
|
|
275
632
|
};
|
|
276
633
|
|
|
277
634
|
declare function useWallets(): {
|
|
@@ -291,6 +648,7 @@ declare function useWallets(): {
|
|
|
291
648
|
label?: string;
|
|
292
649
|
isPrimary?: boolean;
|
|
293
650
|
}) => Promise<void>;
|
|
651
|
+
linkWallet: (walletAddress: string, signMessage: (message: Uint8Array) => Promise<Uint8Array>, chain?: string) => Promise<void>;
|
|
294
652
|
};
|
|
295
653
|
|
|
296
654
|
declare function useSessions(): {
|
|
@@ -307,4 +665,68 @@ declare function useSessions(): {
|
|
|
307
665
|
revokeSession: (id: string) => Promise<void>;
|
|
308
666
|
};
|
|
309
667
|
|
|
310
|
-
|
|
668
|
+
declare function useAdmin(): {
|
|
669
|
+
users: PaginatedResponse<User> | null;
|
|
670
|
+
selectedUser: AdminUser | null;
|
|
671
|
+
userSessions: Session[] | null;
|
|
672
|
+
loading: boolean;
|
|
673
|
+
listUsers: (params?: {
|
|
674
|
+
page?: number;
|
|
675
|
+
limit?: number;
|
|
676
|
+
search?: string;
|
|
677
|
+
}) => Promise<PaginatedResponse<User>>;
|
|
678
|
+
getUser: (id: string) => Promise<AdminUser>;
|
|
679
|
+
updateUserStatus: (id: string, status: UserStatus) => Promise<void>;
|
|
680
|
+
getUserSessions: (id: string) => Promise<Session[]>;
|
|
681
|
+
revokeUserSessions: (id: string) => Promise<void>;
|
|
682
|
+
};
|
|
683
|
+
|
|
684
|
+
declare function useRoles(): {
|
|
685
|
+
roles: Role[] | null;
|
|
686
|
+
selectedRole: Role | null;
|
|
687
|
+
roleUsers: RoleUser[] | null;
|
|
688
|
+
userRoleAssignments: UserRoleAssignment[] | null;
|
|
689
|
+
permissionDomains: PermissionDomains | null;
|
|
690
|
+
loading: boolean;
|
|
691
|
+
listRoles: (tenantId?: string) => Promise<Role[]>;
|
|
692
|
+
getRole: (id: string) => Promise<Role>;
|
|
693
|
+
getRoleUsers: (id: string) => Promise<RoleUser[]>;
|
|
694
|
+
createRole: (data: {
|
|
695
|
+
name: string;
|
|
696
|
+
description?: string;
|
|
697
|
+
permissions: string[];
|
|
698
|
+
tenantId?: string;
|
|
699
|
+
}) => Promise<Role>;
|
|
700
|
+
updateRole: (id: string, data: {
|
|
701
|
+
name?: string;
|
|
702
|
+
description?: string;
|
|
703
|
+
permissions?: string[];
|
|
704
|
+
}) => Promise<Role>;
|
|
705
|
+
deleteRole: (id: string) => Promise<void>;
|
|
706
|
+
getPermissions: () => Promise<PermissionDomains>;
|
|
707
|
+
getUserRoles: (userId: string, tenantId?: string) => Promise<UserRoleAssignment[]>;
|
|
708
|
+
assignRole: (userId: string, roleId: string, tenantId?: string) => Promise<void>;
|
|
709
|
+
revokeRole: (userId: string, roleId: string, tenantId?: string) => Promise<void>;
|
|
710
|
+
};
|
|
711
|
+
|
|
712
|
+
/**
|
|
713
|
+
* Client-side permission checking utilities.
|
|
714
|
+
* These mirror the server-side logic for UI gating.
|
|
715
|
+
*/
|
|
716
|
+
/** Check if a single required permission is satisfied by any of the granted permissions. */
|
|
717
|
+
declare function hasPermission(required: string, granted: string[]): boolean;
|
|
718
|
+
/** Check that ALL required permissions are satisfied. */
|
|
719
|
+
declare function hasAllPermissions(required: string[], granted: string[]): boolean;
|
|
720
|
+
/** Check that at least ONE of the required permissions is satisfied. */
|
|
721
|
+
declare function hasAnyPermission(required: string[], granted: string[]): boolean;
|
|
722
|
+
|
|
723
|
+
/** Check if a login method is an OAuth provider. */
|
|
724
|
+
declare function isOAuthMethod(method: LoginMethod): method is OAuthProvider;
|
|
725
|
+
/**
|
|
726
|
+
* Resolve the effective ordered login methods from config.
|
|
727
|
+
* If `loginMethods` is set, uses that directly.
|
|
728
|
+
* Otherwise, falls back to legacy fields for backward compat.
|
|
729
|
+
*/
|
|
730
|
+
declare function resolveLoginMethods(config: ForgeConnectConfig): LoginMethod[];
|
|
731
|
+
|
|
732
|
+
export { AccountButton, AccountModal, type AccountModalState, type AccountModalTab, type AdminUser, type ApiClient, type AppearanceConfig, type AuthMethod, type AuthProvider, type AuthState, type AuthStatus, type Chain, DeleteAccountModal, ErrorView, type ErrorViewProps, ForgeConnectApiError, type ForgeConnectConfig, ForgeConnectContext, type ForgeConnectContextValue, ForgeConnectProvider, LinkAuthModal, type LinkModalState, LoginButton, type LoginMethod, LoginModal, type LoginResponse, ModalOverlay, type ModalState, type ModalStep, type OAuthProvider, type PaginatedResponse, type Passkey, PasskeysModal, type PermissionDomains, type Role, type RoleUser, type Session, type TokenVerificationResult, type TotpSetup, TwoFactorModal, type TwoFactorStatus, type User, type UserRoleAssignment, type UserStatus, type Wallet, type WalletAdapterContext, type WalletConfig, type WalletUserResult, createApiClient, hasAllPermissions, hasAnyPermission, hasPermission, isOAuthMethod, resolveLoginMethods, useAdmin, useForgeConnect, useRoles, useSessions, useUser, useWallets };
|