eocene-auth-sdk 0.4.0 → 0.5.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.d.ts +123 -10
- package/dist/index.js +664 -47
- package/dist/index.js.map +1 -1
- package/dist/styles.css +73 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { ComponentType, ReactNode, SVGProps } from 'react';
|
|
3
3
|
|
|
4
|
-
type WaasErrorCode = 'password_invalid' | 'password_locked' | 'password_required' | 'password_too_short' | 'plan_user_limit' | 'plan_project_limit' | 'session_expired' | 'rate_limited' | 'unknown';
|
|
4
|
+
type WaasErrorCode = 'password_invalid' | 'password_locked' | 'password_required' | 'password_too_short' | 'password_not_enabled' | 'recovery_contact_required' | 'invalid_recovery_email' | 'reset_cooldown' | 'reset_code_invalid' | 'reset_code_expired' | 'reset_code_locked' | 'reset_channel_unavailable' | 'reset_delivery_failed' | 'plan_user_limit' | 'plan_project_limit' | 'session_expired' | 'rate_limited' | 'unknown';
|
|
5
5
|
type Json = Record<string, unknown>;
|
|
6
6
|
declare class WaasHttpError extends Error {
|
|
7
7
|
readonly status: number;
|
|
@@ -47,6 +47,43 @@ type WaasSignApprovalResult = boolean | {
|
|
|
47
47
|
password?: string;
|
|
48
48
|
};
|
|
49
49
|
|
|
50
|
+
type WaasPasswordResetChannel = 'email' | 'telegram';
|
|
51
|
+
type WaasWalletRecoveryStatus = {
|
|
52
|
+
hasRecovery: boolean;
|
|
53
|
+
channels: WaasPasswordResetChannel[];
|
|
54
|
+
defaultChannel: WaasPasswordResetChannel | null;
|
|
55
|
+
maskedEmail: string | null;
|
|
56
|
+
maskedTelegram: string | null;
|
|
57
|
+
};
|
|
58
|
+
type WaasPasswordResetRequestResult = {
|
|
59
|
+
ok: true;
|
|
60
|
+
channel: WaasPasswordResetChannel;
|
|
61
|
+
availableChannels?: WaasPasswordResetChannel[];
|
|
62
|
+
maskedTarget: string;
|
|
63
|
+
expiresInSec: number;
|
|
64
|
+
cooldownSec: number;
|
|
65
|
+
devCode?: string;
|
|
66
|
+
};
|
|
67
|
+
type WaasPasswordResetConfirmResult = {
|
|
68
|
+
ok: true;
|
|
69
|
+
passwordEnabled: boolean;
|
|
70
|
+
recoveryEmail?: string;
|
|
71
|
+
recovery?: WaasWalletRecoveryStatus;
|
|
72
|
+
};
|
|
73
|
+
type WaasRecoveryEmailBindRequestResult = {
|
|
74
|
+
ok: true;
|
|
75
|
+
channel: 'email';
|
|
76
|
+
maskedTarget: string;
|
|
77
|
+
expiresInSec: number;
|
|
78
|
+
cooldownSec: number;
|
|
79
|
+
devCode?: string;
|
|
80
|
+
};
|
|
81
|
+
type WaasRecoveryEmailBindConfirmResult = {
|
|
82
|
+
ok: true;
|
|
83
|
+
recoveryEmail: string;
|
|
84
|
+
maskedEmail: string;
|
|
85
|
+
recovery?: WaasWalletRecoveryStatus;
|
|
86
|
+
};
|
|
50
87
|
type WaasClientOptions = {
|
|
51
88
|
controlBaseUrl: string;
|
|
52
89
|
/**
|
|
@@ -65,6 +102,7 @@ type DeviceState = {
|
|
|
65
102
|
address?: string;
|
|
66
103
|
epoch?: number;
|
|
67
104
|
passwordEnabled?: boolean;
|
|
105
|
+
recovery?: WaasWalletRecoveryStatus;
|
|
68
106
|
};
|
|
69
107
|
/**
|
|
70
108
|
* Browser/Node SDK for custodial eocene-worker.
|
|
@@ -97,15 +135,26 @@ declare class WaasClient {
|
|
|
97
135
|
address: string;
|
|
98
136
|
epoch: number;
|
|
99
137
|
passwordEnabled: boolean;
|
|
138
|
+
recovery?: WaasWalletRecoveryStatus;
|
|
100
139
|
} | null;
|
|
101
140
|
}>;
|
|
102
|
-
ensureWallet(
|
|
141
|
+
ensureWallet(opts?: {
|
|
142
|
+
telegramInitData?: string;
|
|
143
|
+
}): Promise<{
|
|
103
144
|
walletId: string;
|
|
104
145
|
address: string;
|
|
105
146
|
passwordEnabled: boolean;
|
|
147
|
+
recovery?: WaasWalletRecoveryStatus;
|
|
106
148
|
}>;
|
|
107
|
-
setPassword(password: string, currentPassword?: string
|
|
149
|
+
setPassword(password: string, currentPassword?: string, recoveryBind?: {
|
|
150
|
+
recoveryEmail?: string;
|
|
151
|
+
recoveryCode?: string;
|
|
152
|
+
}): Promise<void>;
|
|
153
|
+
requestRecoveryEmailBind(email: string): Promise<WaasRecoveryEmailBindRequestResult>;
|
|
154
|
+
confirmRecoveryEmailBind(code: string, email?: string): Promise<WaasRecoveryEmailBindConfirmResult>;
|
|
108
155
|
clearPassword(password: string): Promise<void>;
|
|
156
|
+
requestPasswordReset(channel?: WaasPasswordResetChannel, email?: string): Promise<WaasPasswordResetRequestResult>;
|
|
157
|
+
confirmPasswordReset(code: string, newPassword?: string | null): Promise<WaasPasswordResetConfirmResult>;
|
|
109
158
|
signMessage(message: string, opts?: {
|
|
110
159
|
password?: string;
|
|
111
160
|
}): Promise<{
|
|
@@ -175,6 +224,7 @@ type AuthSdkLabels = {
|
|
|
175
224
|
signReject: string;
|
|
176
225
|
signPasswordLabel: string;
|
|
177
226
|
signPasswordPlaceholder: string;
|
|
227
|
+
signForgotPassword: string;
|
|
178
228
|
signSetPasswordOptional: string;
|
|
179
229
|
signSetPasswordButton: string;
|
|
180
230
|
signPasswordIncorrect: string;
|
|
@@ -205,6 +255,29 @@ type AuthSdkLabels = {
|
|
|
205
255
|
passwordSettingsDisabledHint: string;
|
|
206
256
|
passwordSettingsChange: string;
|
|
207
257
|
passwordSettingsClear: string;
|
|
258
|
+
passwordSettingsReset: string;
|
|
259
|
+
passwordSettingsResetHint: string;
|
|
260
|
+
passwordSettingsSendCode: string;
|
|
261
|
+
passwordSettingsSendingCode: string;
|
|
262
|
+
passwordSettingsResendCode: string;
|
|
263
|
+
passwordSettingsResendCooldown: string;
|
|
264
|
+
passwordSettingsCodeSentEmail: string;
|
|
265
|
+
passwordSettingsCodeSentTelegram: string;
|
|
266
|
+
passwordSettingsCodeLabel: string;
|
|
267
|
+
passwordSettingsCodePlaceholder: string;
|
|
268
|
+
passwordSettingsResetConfirm: string;
|
|
269
|
+
passwordSettingsResetClearConfirm: string;
|
|
270
|
+
passwordSettingsResetCodeInvalid: string;
|
|
271
|
+
passwordSettingsResetCodeExpired: string;
|
|
272
|
+
passwordSettingsResetCodeLocked: string;
|
|
273
|
+
passwordSettingsResetCooldown: string;
|
|
274
|
+
passwordSettingsResetChannelUnavailable: string;
|
|
275
|
+
passwordSettingsResetDeliveryFailed: string;
|
|
276
|
+
passwordSettingsBindEmailLabel: string;
|
|
277
|
+
passwordSettingsBindEmailPlaceholder: string;
|
|
278
|
+
passwordSettingsBindEmailHint: string;
|
|
279
|
+
passwordSettingsRecoveryRequired: string;
|
|
280
|
+
passwordSettingsInvalidRecoveryEmail: string;
|
|
208
281
|
passwordSettingsCurrentLabel: string;
|
|
209
282
|
passwordSettingsCurrentPlaceholder: string;
|
|
210
283
|
passwordSettingsNewLabel: string;
|
|
@@ -234,15 +307,37 @@ type SignApprovalProps = {
|
|
|
234
307
|
onReject: () => void;
|
|
235
308
|
/** Shown when wallet has no password yet — opens SetPasswordModal. */
|
|
236
309
|
onOpenSetPassword?: () => void;
|
|
310
|
+
/** Shown when wallet has a password — opens SetPasswordModal in reset mode. */
|
|
311
|
+
onOpenResetPassword?: () => void;
|
|
312
|
+
};
|
|
313
|
+
type PasswordSettingsMode = 'set' | 'clear' | 'reset';
|
|
314
|
+
type PasswordResetSentInfo = {
|
|
315
|
+
channel: WaasPasswordResetChannel;
|
|
316
|
+
maskedTarget: string;
|
|
317
|
+
cooldownSec: number;
|
|
318
|
+
sentAt: number;
|
|
237
319
|
};
|
|
238
320
|
type PasswordSettingsProps = {
|
|
239
321
|
open: boolean;
|
|
240
322
|
passwordEnabled: boolean;
|
|
323
|
+
initialMode?: PasswordSettingsMode;
|
|
324
|
+
recovery?: WaasWalletRecoveryStatus | null;
|
|
241
325
|
labels: AuthSdkLabels;
|
|
242
326
|
busy: boolean;
|
|
327
|
+
sendingResetCode?: boolean;
|
|
328
|
+
resetSent?: PasswordResetSentInfo | null;
|
|
329
|
+
sendingRecoveryBindCode?: boolean;
|
|
330
|
+
recoveryBindSent?: PasswordResetSentInfo | null;
|
|
243
331
|
error: string | null;
|
|
244
|
-
onSubmitSet: (password: string, currentPassword?: string
|
|
332
|
+
onSubmitSet: (password: string, currentPassword?: string, recoveryBind?: {
|
|
333
|
+
recoveryEmail?: string;
|
|
334
|
+
recoveryCode?: string;
|
|
335
|
+
}) => Promise<void>;
|
|
245
336
|
onSubmitClear: (password: string) => Promise<void>;
|
|
337
|
+
onRequestResetCode?: (channel?: WaasPasswordResetChannel, email?: string) => Promise<void>;
|
|
338
|
+
onSubmitReset?: (code: string, newPassword?: string | null) => Promise<void>;
|
|
339
|
+
onRequestRecoveryEmailBind?: (email: string) => Promise<void>;
|
|
340
|
+
onConfirmRecoveryEmailBind?: (code: string, email?: string) => Promise<void>;
|
|
246
341
|
onClose: () => void;
|
|
247
342
|
};
|
|
248
343
|
type LoginPanelProps = {
|
|
@@ -295,6 +390,7 @@ type AuthUser = {
|
|
|
295
390
|
address?: string;
|
|
296
391
|
walletId?: string;
|
|
297
392
|
passwordEnabled?: boolean;
|
|
393
|
+
recovery?: WaasWalletRecoveryStatus;
|
|
298
394
|
};
|
|
299
395
|
type AuthLoginResult = {
|
|
300
396
|
address: string;
|
|
@@ -363,8 +459,16 @@ declare class AuthClient {
|
|
|
363
459
|
restoreSession(): Promise<boolean>;
|
|
364
460
|
private performRestoreSession;
|
|
365
461
|
logout(): void;
|
|
366
|
-
setPassword(password: string, currentPassword?: string
|
|
462
|
+
setPassword(password: string, currentPassword?: string, recoveryBind?: {
|
|
463
|
+
recoveryEmail?: string;
|
|
464
|
+
recoveryCode?: string;
|
|
465
|
+
}): Promise<void>;
|
|
367
466
|
clearPassword(password: string): Promise<void>;
|
|
467
|
+
requestRecoveryEmailBind(email: string): Promise<WaasRecoveryEmailBindRequestResult>;
|
|
468
|
+
confirmRecoveryEmailBind(code: string, email?: string): Promise<WaasRecoveryEmailBindConfirmResult>;
|
|
469
|
+
requestPasswordReset(channel?: WaasPasswordResetChannel, email?: string): Promise<WaasPasswordResetRequestResult>;
|
|
470
|
+
confirmPasswordReset(code: string, newPassword?: string | null): Promise<WaasPasswordResetConfirmResult>;
|
|
471
|
+
refreshUser(): Promise<AuthUser | null>;
|
|
368
472
|
}
|
|
369
473
|
|
|
370
474
|
/**
|
|
@@ -394,6 +498,8 @@ type AuthContextValue = {
|
|
|
394
498
|
address: string | undefined;
|
|
395
499
|
user: AuthUser | null;
|
|
396
500
|
passwordEnabled: boolean;
|
|
501
|
+
/** Increments whenever setPassword, clearPassword, or confirmPasswordReset succeeds. */
|
|
502
|
+
passwordVersion: number;
|
|
397
503
|
login: (args: {
|
|
398
504
|
method: AuthSocialMethod;
|
|
399
505
|
}) => Promise<AuthLoginResult>;
|
|
@@ -407,9 +513,16 @@ type AuthContextValue = {
|
|
|
407
513
|
takeOAuthReturnPath: () => string | null;
|
|
408
514
|
getProvider: () => WaasEip1193Provider;
|
|
409
515
|
getConnectorShim: () => AuthConnectorShim;
|
|
410
|
-
setPassword: (password: string, currentPassword?: string
|
|
516
|
+
setPassword: (password: string, currentPassword?: string, recoveryBind?: {
|
|
517
|
+
recoveryEmail?: string;
|
|
518
|
+
recoveryCode?: string;
|
|
519
|
+
}) => Promise<void>;
|
|
411
520
|
clearPassword: (password: string) => Promise<void>;
|
|
412
|
-
|
|
521
|
+
requestPasswordReset: (channel?: WaasPasswordResetChannel, email?: string) => Promise<WaasPasswordResetRequestResult>;
|
|
522
|
+
confirmPasswordReset: (code: string, newPassword?: string | null) => Promise<WaasPasswordResetConfirmResult>;
|
|
523
|
+
requestRecoveryEmailBind: (email: string) => Promise<WaasRecoveryEmailBindRequestResult>;
|
|
524
|
+
confirmRecoveryEmailBind: (code: string, email?: string) => Promise<WaasRecoveryEmailBindConfirmResult>;
|
|
525
|
+
openPasswordSettings: (initialMode?: PasswordSettingsMode) => void;
|
|
413
526
|
closePasswordSettings: () => void;
|
|
414
527
|
client: AuthClient;
|
|
415
528
|
labels: AuthSdkLabels;
|
|
@@ -453,9 +566,9 @@ declare function AuthOAuthCallback({ hashOrSearch, onWalletReady, children, onBa
|
|
|
453
566
|
/** Build AuthSdkConfig from Vite `VITE_EOCENE_*` (and unprefixed / legacy WAAS aliases). */
|
|
454
567
|
declare function authConfigFromViteEnv(env?: object): AuthSdkConfig;
|
|
455
568
|
|
|
456
|
-
declare function SignConfirmModal({ open, request, labels, password, busy, error, locked, onPasswordChange, onApprove, onReject, onOpenSetPassword, }: SignApprovalProps): react.JSX.Element | null;
|
|
569
|
+
declare function SignConfirmModal({ open, request, labels, password, busy, error, locked, onPasswordChange, onApprove, onReject, onOpenSetPassword, onOpenResetPassword, }: SignApprovalProps): react.JSX.Element | null;
|
|
457
570
|
|
|
458
|
-
declare function SetPasswordModal({ open, passwordEnabled, labels, busy, error, onSubmitSet, onSubmitClear, onClose, }: PasswordSettingsProps): react.JSX.Element | null;
|
|
571
|
+
declare function SetPasswordModal({ open, passwordEnabled, initialMode, recovery, labels, busy, sendingResetCode, resetSent, sendingRecoveryBindCode, recoveryBindSent, error, onSubmitSet, onSubmitClear, onRequestResetCode, onSubmitReset, onRequestRecoveryEmailBind, onConfirmRecoveryEmailBind, onClose, }: PasswordSettingsProps): react.JSX.Element | null;
|
|
459
572
|
|
|
460
573
|
/**
|
|
461
574
|
* EOCENE Research mark and lockup. Inline SVG (no asset fetch); transparent
|
|
@@ -470,4 +583,4 @@ declare function EoceneWordmark({ className, markSize, }: {
|
|
|
470
583
|
markSize?: number;
|
|
471
584
|
}): react.JSX.Element;
|
|
472
585
|
|
|
473
|
-
export { AuthClient, type AuthConnectorShim, type AuthContextValue, AuthLoginPanel, type AuthLoginResult, AuthOAuthCallback, type AuthOAuthCallbackProps, AuthProvider, type AuthProviderProps, type AuthSdkComponents, type AuthSdkConfig, type AuthSdkLabels, type AuthSocialMethod, type AuthUser, DEFAULT_CONTROL_BASE_URL, DEFAULT_LABELS, DEFAULT_OAUTH_PENDING_KEY, DEFAULT_STORAGE_KEY, EoceneMark, EoceneWordmark, type LoginPanelProps, type PasswordSettingsProps, SetPasswordModal, type SignApprovalProps, SignConfirmModal, type WaasEip1193Provider, WaasHttpError, type WaasSignApprovalRequest, type WaasSignApprovalResult, type WaasSignAuthError, authConfigFromViteEnv, createAuthEip1193Provider, getTelegramInitData, isTelegramMiniApp, isWaasHttpError, resolveControlAbsoluteUrl, useAuthContext as useAuth };
|
|
586
|
+
export { AuthClient, type AuthConnectorShim, type AuthContextValue, AuthLoginPanel, type AuthLoginResult, AuthOAuthCallback, type AuthOAuthCallbackProps, AuthProvider, type AuthProviderProps, type AuthSdkComponents, type AuthSdkConfig, type AuthSdkLabels, type AuthSocialMethod, type AuthUser, DEFAULT_CONTROL_BASE_URL, DEFAULT_LABELS, DEFAULT_OAUTH_PENDING_KEY, DEFAULT_STORAGE_KEY, EoceneMark, EoceneWordmark, type LoginPanelProps, type PasswordResetSentInfo, type PasswordSettingsMode, type PasswordSettingsProps, SetPasswordModal, type SignApprovalProps, SignConfirmModal, type WaasEip1193Provider, WaasHttpError, type WaasPasswordResetChannel, type WaasPasswordResetConfirmResult, type WaasPasswordResetRequestResult, type WaasRecoveryEmailBindConfirmResult, type WaasRecoveryEmailBindRequestResult, type WaasSignApprovalRequest, type WaasSignApprovalResult, type WaasSignAuthError, type WaasWalletRecoveryStatus, authConfigFromViteEnv, createAuthEip1193Provider, getTelegramInitData, isTelegramMiniApp, isWaasHttpError, resolveControlAbsoluteUrl, useAuthContext as useAuth };
|