eocene-auth-sdk 0.4.0 → 0.5.0

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 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,41 @@ 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
+ };
71
+ type WaasRecoveryEmailBindRequestResult = {
72
+ ok: true;
73
+ channel: 'email';
74
+ maskedTarget: string;
75
+ expiresInSec: number;
76
+ cooldownSec: number;
77
+ devCode?: string;
78
+ };
79
+ type WaasRecoveryEmailBindConfirmResult = {
80
+ ok: true;
81
+ recoveryEmail: string;
82
+ maskedEmail: string;
83
+ recovery?: WaasWalletRecoveryStatus;
84
+ };
50
85
  type WaasClientOptions = {
51
86
  controlBaseUrl: string;
52
87
  /**
@@ -65,6 +100,7 @@ type DeviceState = {
65
100
  address?: string;
66
101
  epoch?: number;
67
102
  passwordEnabled?: boolean;
103
+ recovery?: WaasWalletRecoveryStatus;
68
104
  };
69
105
  /**
70
106
  * Browser/Node SDK for custodial eocene-worker.
@@ -97,15 +133,26 @@ declare class WaasClient {
97
133
  address: string;
98
134
  epoch: number;
99
135
  passwordEnabled: boolean;
136
+ recovery?: WaasWalletRecoveryStatus;
100
137
  } | null;
101
138
  }>;
102
- ensureWallet(): Promise<{
139
+ ensureWallet(opts?: {
140
+ telegramInitData?: string;
141
+ }): Promise<{
103
142
  walletId: string;
104
143
  address: string;
105
144
  passwordEnabled: boolean;
145
+ recovery?: WaasWalletRecoveryStatus;
106
146
  }>;
107
- setPassword(password: string, currentPassword?: string): Promise<void>;
147
+ setPassword(password: string, currentPassword?: string, recoveryBind?: {
148
+ recoveryEmail?: string;
149
+ recoveryCode?: string;
150
+ }): Promise<void>;
151
+ requestRecoveryEmailBind(email: string): Promise<WaasRecoveryEmailBindRequestResult>;
152
+ confirmRecoveryEmailBind(code: string, email?: string): Promise<WaasRecoveryEmailBindConfirmResult>;
108
153
  clearPassword(password: string): Promise<void>;
154
+ requestPasswordReset(channel?: WaasPasswordResetChannel): Promise<WaasPasswordResetRequestResult>;
155
+ confirmPasswordReset(code: string, newPassword?: string | null): Promise<WaasPasswordResetConfirmResult>;
109
156
  signMessage(message: string, opts?: {
110
157
  password?: string;
111
158
  }): Promise<{
@@ -175,6 +222,7 @@ type AuthSdkLabels = {
175
222
  signReject: string;
176
223
  signPasswordLabel: string;
177
224
  signPasswordPlaceholder: string;
225
+ signForgotPassword: string;
178
226
  signSetPasswordOptional: string;
179
227
  signSetPasswordButton: string;
180
228
  signPasswordIncorrect: string;
@@ -205,6 +253,29 @@ type AuthSdkLabels = {
205
253
  passwordSettingsDisabledHint: string;
206
254
  passwordSettingsChange: string;
207
255
  passwordSettingsClear: string;
256
+ passwordSettingsReset: string;
257
+ passwordSettingsResetHint: string;
258
+ passwordSettingsSendCode: string;
259
+ passwordSettingsSendingCode: string;
260
+ passwordSettingsResendCode: string;
261
+ passwordSettingsResendCooldown: string;
262
+ passwordSettingsCodeSentEmail: string;
263
+ passwordSettingsCodeSentTelegram: string;
264
+ passwordSettingsCodeLabel: string;
265
+ passwordSettingsCodePlaceholder: string;
266
+ passwordSettingsResetConfirm: string;
267
+ passwordSettingsResetClearConfirm: string;
268
+ passwordSettingsResetCodeInvalid: string;
269
+ passwordSettingsResetCodeExpired: string;
270
+ passwordSettingsResetCodeLocked: string;
271
+ passwordSettingsResetCooldown: string;
272
+ passwordSettingsResetChannelUnavailable: string;
273
+ passwordSettingsResetDeliveryFailed: string;
274
+ passwordSettingsBindEmailLabel: string;
275
+ passwordSettingsBindEmailPlaceholder: string;
276
+ passwordSettingsBindEmailHint: string;
277
+ passwordSettingsRecoveryRequired: string;
278
+ passwordSettingsInvalidRecoveryEmail: string;
208
279
  passwordSettingsCurrentLabel: string;
209
280
  passwordSettingsCurrentPlaceholder: string;
210
281
  passwordSettingsNewLabel: string;
@@ -234,15 +305,36 @@ type SignApprovalProps = {
234
305
  onReject: () => void;
235
306
  /** Shown when wallet has no password yet — opens SetPasswordModal. */
236
307
  onOpenSetPassword?: () => void;
308
+ /** Shown when wallet has a password — opens SetPasswordModal in reset mode. */
309
+ onOpenResetPassword?: () => void;
310
+ };
311
+ type PasswordSettingsMode = 'set' | 'clear' | 'reset';
312
+ type PasswordResetSentInfo = {
313
+ channel: WaasPasswordResetChannel;
314
+ maskedTarget: string;
315
+ cooldownSec: number;
316
+ sentAt: number;
237
317
  };
238
318
  type PasswordSettingsProps = {
239
319
  open: boolean;
240
320
  passwordEnabled: boolean;
321
+ initialMode?: PasswordSettingsMode;
322
+ recovery?: WaasWalletRecoveryStatus | null;
241
323
  labels: AuthSdkLabels;
242
324
  busy: boolean;
325
+ sendingResetCode?: boolean;
326
+ resetSent?: PasswordResetSentInfo | null;
327
+ sendingRecoveryBindCode?: boolean;
328
+ recoveryBindSent?: PasswordResetSentInfo | null;
243
329
  error: string | null;
244
- onSubmitSet: (password: string, currentPassword?: string) => Promise<void>;
330
+ onSubmitSet: (password: string, currentPassword?: string, recoveryBind?: {
331
+ recoveryEmail?: string;
332
+ recoveryCode?: string;
333
+ }) => Promise<void>;
245
334
  onSubmitClear: (password: string) => Promise<void>;
335
+ onRequestResetCode?: (channel?: WaasPasswordResetChannel) => Promise<void>;
336
+ onSubmitReset?: (code: string, newPassword?: string | null) => Promise<void>;
337
+ onRequestRecoveryEmailBind?: (email: string) => Promise<void>;
246
338
  onClose: () => void;
247
339
  };
248
340
  type LoginPanelProps = {
@@ -295,6 +387,7 @@ type AuthUser = {
295
387
  address?: string;
296
388
  walletId?: string;
297
389
  passwordEnabled?: boolean;
390
+ recovery?: WaasWalletRecoveryStatus;
298
391
  };
299
392
  type AuthLoginResult = {
300
393
  address: string;
@@ -363,8 +456,15 @@ declare class AuthClient {
363
456
  restoreSession(): Promise<boolean>;
364
457
  private performRestoreSession;
365
458
  logout(): void;
366
- setPassword(password: string, currentPassword?: string): Promise<void>;
459
+ setPassword(password: string, currentPassword?: string, recoveryBind?: {
460
+ recoveryEmail?: string;
461
+ recoveryCode?: string;
462
+ }): Promise<void>;
367
463
  clearPassword(password: string): Promise<void>;
464
+ requestRecoveryEmailBind(email: string): Promise<WaasRecoveryEmailBindRequestResult>;
465
+ confirmRecoveryEmailBind(code: string, email?: string): Promise<WaasRecoveryEmailBindConfirmResult>;
466
+ requestPasswordReset(channel?: WaasPasswordResetChannel): Promise<WaasPasswordResetRequestResult>;
467
+ confirmPasswordReset(code: string, newPassword?: string | null): Promise<WaasPasswordResetConfirmResult>;
368
468
  }
369
469
 
370
470
  /**
@@ -394,6 +494,8 @@ type AuthContextValue = {
394
494
  address: string | undefined;
395
495
  user: AuthUser | null;
396
496
  passwordEnabled: boolean;
497
+ /** Increments whenever setPassword, clearPassword, or confirmPasswordReset succeeds. */
498
+ passwordVersion: number;
397
499
  login: (args: {
398
500
  method: AuthSocialMethod;
399
501
  }) => Promise<AuthLoginResult>;
@@ -407,9 +509,16 @@ type AuthContextValue = {
407
509
  takeOAuthReturnPath: () => string | null;
408
510
  getProvider: () => WaasEip1193Provider;
409
511
  getConnectorShim: () => AuthConnectorShim;
410
- setPassword: (password: string, currentPassword?: string) => Promise<void>;
512
+ setPassword: (password: string, currentPassword?: string, recoveryBind?: {
513
+ recoveryEmail?: string;
514
+ recoveryCode?: string;
515
+ }) => Promise<void>;
411
516
  clearPassword: (password: string) => Promise<void>;
412
- openPasswordSettings: () => void;
517
+ requestPasswordReset: (channel?: WaasPasswordResetChannel) => Promise<WaasPasswordResetRequestResult>;
518
+ confirmPasswordReset: (code: string, newPassword?: string | null) => Promise<WaasPasswordResetConfirmResult>;
519
+ requestRecoveryEmailBind: (email: string) => Promise<WaasRecoveryEmailBindRequestResult>;
520
+ confirmRecoveryEmailBind: (code: string, email?: string) => Promise<WaasRecoveryEmailBindConfirmResult>;
521
+ openPasswordSettings: (initialMode?: PasswordSettingsMode) => void;
413
522
  closePasswordSettings: () => void;
414
523
  client: AuthClient;
415
524
  labels: AuthSdkLabels;
@@ -453,9 +562,9 @@ declare function AuthOAuthCallback({ hashOrSearch, onWalletReady, children, onBa
453
562
  /** Build AuthSdkConfig from Vite `VITE_EOCENE_*` (and unprefixed / legacy WAAS aliases). */
454
563
  declare function authConfigFromViteEnv(env?: object): AuthSdkConfig;
455
564
 
456
- declare function SignConfirmModal({ open, request, labels, password, busy, error, locked, onPasswordChange, onApprove, onReject, onOpenSetPassword, }: SignApprovalProps): react.JSX.Element | null;
565
+ declare function SignConfirmModal({ open, request, labels, password, busy, error, locked, onPasswordChange, onApprove, onReject, onOpenSetPassword, onOpenResetPassword, }: SignApprovalProps): react.JSX.Element | null;
457
566
 
458
- declare function SetPasswordModal({ open, passwordEnabled, labels, busy, error, onSubmitSet, onSubmitClear, onClose, }: PasswordSettingsProps): react.JSX.Element | null;
567
+ declare function SetPasswordModal({ open, passwordEnabled, initialMode, recovery, labels, busy, sendingResetCode, resetSent, sendingRecoveryBindCode, recoveryBindSent, error, onSubmitSet, onSubmitClear, onRequestResetCode, onSubmitReset, onRequestRecoveryEmailBind, onClose, }: PasswordSettingsProps): react.JSX.Element | null;
459
568
 
460
569
  /**
461
570
  * EOCENE Research mark and lockup. Inline SVG (no asset fetch); transparent
@@ -470,4 +579,4 @@ declare function EoceneWordmark({ className, markSize, }: {
470
579
  markSize?: number;
471
580
  }): react.JSX.Element;
472
581
 
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 };
582
+ 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 };