decane-connect-kit 2.0.0 → 2.0.2

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.cts CHANGED
@@ -316,6 +316,12 @@ interface DecaneConnect {
316
316
  verifyEmailCode(email: string, code: string): Promise<ConnectResult>;
317
317
  unlock(): Promise<void>;
318
318
  isUnlocked(): boolean;
319
+ /**
320
+ * True when the user's identity is known from a previous visit but there is
321
+ * no live session, so unlock() cannot succeed and they must sign in again.
322
+ * Check this before offering an "Unlock" action.
323
+ */
324
+ needsReconnect(): boolean;
319
325
  sessionExpiresAt(): number | null;
320
326
  signMessage(req: SignMessageRequest): Promise<string>;
321
327
  sendTransaction(req: SendTransactionRequest): Promise<string>;
@@ -401,6 +407,22 @@ declare class SessionExpiredError extends DecaneConnectError {
401
407
  declare class UnlockRequiredError extends DecaneConnectError {
402
408
  constructor();
403
409
  }
410
+ /**
411
+ * unlock() was called after a page reload (or any other loss of the in-memory
412
+ * auth state). We still know *who* the user is — their identity and addresses
413
+ * are persisted — but unlock() needs a live JWT to open a TEE session, and
414
+ * JWTs are deliberately never persisted. So there is no unlock() that can
415
+ * succeed here; the user has to re-authenticate.
416
+ *
417
+ * This is its own error type rather than a generic CallSequenceError because
418
+ * it is a *routing* signal, not a programming mistake: the correct response is
419
+ * to show the sign-in UI, which callers can only do reliably if they can tell
420
+ * this case apart from "you never called connect()". Prefer checking
421
+ * needsReconnect() up front so this never has to be caught at all.
422
+ */
423
+ declare class ReconnectRequiredError extends DecaneConnectError {
424
+ constructor();
425
+ }
404
426
  declare class UserCancelledError extends DecaneConnectError {
405
427
  constructor();
406
428
  }
@@ -558,6 +580,16 @@ interface SocialAuthState {
558
580
  isNewUser: boolean;
559
581
  isUnlocked: boolean;
560
582
  sessionExpiresAt: number | null;
583
+ /**
584
+ * True when `addresses` came from persisted (localStorage) identity only,
585
+ * with no live session. This is NOT the same as "locked" — every unlock()
586
+ * requires a fresh, valid JWT to open a TEE session, and JWTs are
587
+ * deliberately never persisted (short-lived, security-sensitive), so
588
+ * there is no legitimate "just unlock" path in this state. A consumer
589
+ * should route this into a full reconnect (connectWithGoogle() /
590
+ * connectWithEmail()), not unlock() — which will always throw here.
591
+ */
592
+ needsReconnect: boolean;
561
593
  }
562
594
  interface DecaneKitProps {
563
595
  config?: DecaneConfig;
@@ -572,8 +604,24 @@ interface SocialWalletModalProps {
572
604
  socialAuth: SocialAuthState;
573
605
  onUnlock: () => Promise<void>;
574
606
  onDisconnect: () => Promise<void>;
607
+ onGoogleSignIn: () => Promise<void>;
608
+ onEmailStart: (email: string) => Promise<{
609
+ codeRequired: true;
610
+ }>;
611
+ onEmailVerify: (email: string, code: string) => Promise<void>;
612
+ authMethods?: Array<"google" | "email">;
613
+ onRotateShares: (opts: {
614
+ password: string;
615
+ passwordHint?: string;
616
+ }) => Promise<RecoveryShareFile>;
617
+ onExportPortableBackup: (opts: {
618
+ password: string;
619
+ passwordHint?: string;
620
+ }) => Promise<PortableBackup>;
621
+ rpcUrls?: Record<string, string>;
622
+ chains?: string[];
575
623
  }
576
- declare function SocialWalletModal({ open, onClose, theme, socialAuth, onUnlock, onDisconnect, }: SocialWalletModalProps): React.ReactPortal | null;
624
+ declare function SocialWalletModal({ open, onClose, theme, socialAuth, onUnlock, onDisconnect, onGoogleSignIn, onEmailStart, onEmailVerify, authMethods, onRotateShares, onExportPortableBackup, rpcUrls, chains, }: SocialWalletModalProps): React.ReactPortal | null;
577
625
 
578
626
  declare function useSocialAuth(): {
579
627
  isConnected: boolean;
@@ -584,6 +632,7 @@ declare function useSocialAuth(): {
584
632
  solana?: string;
585
633
  } | null;
586
634
  sessionExpiresAt: number | null;
635
+ needsReconnect: boolean;
587
636
  googleLoading: boolean;
588
637
  emailLoading: boolean;
589
638
  error: string | null;
@@ -605,6 +654,7 @@ declare function useSocialWallet(): {
605
654
  solana?: string;
606
655
  } | null;
607
656
  sessionExpiresAt: number | null;
657
+ needsReconnect: boolean;
608
658
  modalOpen: boolean;
609
659
  openModal: () => void;
610
660
  closeModal: () => void;
@@ -620,6 +670,17 @@ declare function useSocialWallet(): {
620
670
  gasPrice?: bigint;
621
671
  }) => Promise<string>;
622
672
  signSolanaTransaction: (tx: Uint8Array) => Promise<Uint8Array<ArrayBufferLike>>;
673
+ rotateShares: (opts: {
674
+ password: string;
675
+ passwordHint?: string;
676
+ }) => Promise<RecoveryShareFile>;
677
+ exportPortableBackup: (opts: {
678
+ password: string;
679
+ passwordHint?: string;
680
+ }) => Promise<PortableBackup>;
681
+ hasRecoveryShare: () => Promise<boolean>;
682
+ shouldPromptRecovery: () => Promise<boolean>;
683
+ dismissRecoveryPrompt: () => Promise<void>;
623
684
  loading: boolean;
624
685
  error: string | null;
625
686
  clearError: () => void;
@@ -696,4 +757,4 @@ declare function useSignTypedData(): {
696
757
  reset: () => void;
697
758
  };
698
759
 
699
- export { type ActiveSession, AttestationError, type AuthResult, BUILT_IN_CHAINS, type CAIP25Method, type CAIP25SessionRequest, type CAIP25SessionResult, CHAINS, CallSequenceError, type Chain, type ChainDescriptor, type ChainId, type ChainScope, type ChainSupport, type ChainType, type ConnectMode, type ConnectResult, type DecaneConfig, type DecaneConnect, type DecaneConnectConfig, DecaneConnectError, DecaneError, DecaneErrorCode, DecaneKit, type DecaneProvider, ExportNotAuthorizedError, InvalidApiKeyError, InvalidPinError, InvalidRecoveryFileError, NetworkError, NewDeviceError, OriginNotAllowedError, type PortableBackup, PromptPinNotConfiguredError, RecoveryFailedError, type RecoveryProgress, type RecoveryShareFile, RecoveryWalletMismatchError, type SdkEvent, type SendTransactionRequest, SessionExpiredError, ShareCorruptedError, type SignMessageRequest, type SocialAuthState, type SocialConfig, SocialWalletModal, type Theme, type TxParams, type UnifiedWalletAccount, UnlockRequiredError, UserCancelledError, WalletSelector, WebAuthnNotSupportedError, type WrappedShareMeta, WrongPasswordError, createDecane, createDecaneConnect, startEmailAuth, useChainSwitch, useDecane, useSendTransaction, useSignMessage, useSignTypedData, useSocialAuth, useSocialWallet, useWalletSelector, verifyEmailCode };
760
+ export { type ActiveSession, AttestationError, type AuthResult, BUILT_IN_CHAINS, type CAIP25Method, type CAIP25SessionRequest, type CAIP25SessionResult, CHAINS, CallSequenceError, type Chain, type ChainDescriptor, type ChainId, type ChainScope, type ChainSupport, type ChainType, type ConnectMode, type ConnectResult, type DecaneConfig, type DecaneConnect, type DecaneConnectConfig, DecaneConnectError, DecaneError, DecaneErrorCode, DecaneKit, type DecaneProvider, ExportNotAuthorizedError, InvalidApiKeyError, InvalidPinError, InvalidRecoveryFileError, NetworkError, NewDeviceError, OriginNotAllowedError, type PortableBackup, PromptPinNotConfiguredError, ReconnectRequiredError, RecoveryFailedError, type RecoveryProgress, type RecoveryShareFile, RecoveryWalletMismatchError, type SdkEvent, type SendTransactionRequest, SessionExpiredError, ShareCorruptedError, type SignMessageRequest, type SocialAuthState, type SocialConfig, SocialWalletModal, type Theme, type TxParams, type UnifiedWalletAccount, UnlockRequiredError, UserCancelledError, WalletSelector, WebAuthnNotSupportedError, type WrappedShareMeta, WrongPasswordError, createDecane, createDecaneConnect, startEmailAuth, useChainSwitch, useDecane, useSendTransaction, useSignMessage, useSignTypedData, useSocialAuth, useSocialWallet, useWalletSelector, verifyEmailCode };
package/dist/index.d.ts CHANGED
@@ -316,6 +316,12 @@ interface DecaneConnect {
316
316
  verifyEmailCode(email: string, code: string): Promise<ConnectResult>;
317
317
  unlock(): Promise<void>;
318
318
  isUnlocked(): boolean;
319
+ /**
320
+ * True when the user's identity is known from a previous visit but there is
321
+ * no live session, so unlock() cannot succeed and they must sign in again.
322
+ * Check this before offering an "Unlock" action.
323
+ */
324
+ needsReconnect(): boolean;
319
325
  sessionExpiresAt(): number | null;
320
326
  signMessage(req: SignMessageRequest): Promise<string>;
321
327
  sendTransaction(req: SendTransactionRequest): Promise<string>;
@@ -401,6 +407,22 @@ declare class SessionExpiredError extends DecaneConnectError {
401
407
  declare class UnlockRequiredError extends DecaneConnectError {
402
408
  constructor();
403
409
  }
410
+ /**
411
+ * unlock() was called after a page reload (or any other loss of the in-memory
412
+ * auth state). We still know *who* the user is — their identity and addresses
413
+ * are persisted — but unlock() needs a live JWT to open a TEE session, and
414
+ * JWTs are deliberately never persisted. So there is no unlock() that can
415
+ * succeed here; the user has to re-authenticate.
416
+ *
417
+ * This is its own error type rather than a generic CallSequenceError because
418
+ * it is a *routing* signal, not a programming mistake: the correct response is
419
+ * to show the sign-in UI, which callers can only do reliably if they can tell
420
+ * this case apart from "you never called connect()". Prefer checking
421
+ * needsReconnect() up front so this never has to be caught at all.
422
+ */
423
+ declare class ReconnectRequiredError extends DecaneConnectError {
424
+ constructor();
425
+ }
404
426
  declare class UserCancelledError extends DecaneConnectError {
405
427
  constructor();
406
428
  }
@@ -558,6 +580,16 @@ interface SocialAuthState {
558
580
  isNewUser: boolean;
559
581
  isUnlocked: boolean;
560
582
  sessionExpiresAt: number | null;
583
+ /**
584
+ * True when `addresses` came from persisted (localStorage) identity only,
585
+ * with no live session. This is NOT the same as "locked" — every unlock()
586
+ * requires a fresh, valid JWT to open a TEE session, and JWTs are
587
+ * deliberately never persisted (short-lived, security-sensitive), so
588
+ * there is no legitimate "just unlock" path in this state. A consumer
589
+ * should route this into a full reconnect (connectWithGoogle() /
590
+ * connectWithEmail()), not unlock() — which will always throw here.
591
+ */
592
+ needsReconnect: boolean;
561
593
  }
562
594
  interface DecaneKitProps {
563
595
  config?: DecaneConfig;
@@ -572,8 +604,24 @@ interface SocialWalletModalProps {
572
604
  socialAuth: SocialAuthState;
573
605
  onUnlock: () => Promise<void>;
574
606
  onDisconnect: () => Promise<void>;
607
+ onGoogleSignIn: () => Promise<void>;
608
+ onEmailStart: (email: string) => Promise<{
609
+ codeRequired: true;
610
+ }>;
611
+ onEmailVerify: (email: string, code: string) => Promise<void>;
612
+ authMethods?: Array<"google" | "email">;
613
+ onRotateShares: (opts: {
614
+ password: string;
615
+ passwordHint?: string;
616
+ }) => Promise<RecoveryShareFile>;
617
+ onExportPortableBackup: (opts: {
618
+ password: string;
619
+ passwordHint?: string;
620
+ }) => Promise<PortableBackup>;
621
+ rpcUrls?: Record<string, string>;
622
+ chains?: string[];
575
623
  }
576
- declare function SocialWalletModal({ open, onClose, theme, socialAuth, onUnlock, onDisconnect, }: SocialWalletModalProps): React.ReactPortal | null;
624
+ declare function SocialWalletModal({ open, onClose, theme, socialAuth, onUnlock, onDisconnect, onGoogleSignIn, onEmailStart, onEmailVerify, authMethods, onRotateShares, onExportPortableBackup, rpcUrls, chains, }: SocialWalletModalProps): React.ReactPortal | null;
577
625
 
578
626
  declare function useSocialAuth(): {
579
627
  isConnected: boolean;
@@ -584,6 +632,7 @@ declare function useSocialAuth(): {
584
632
  solana?: string;
585
633
  } | null;
586
634
  sessionExpiresAt: number | null;
635
+ needsReconnect: boolean;
587
636
  googleLoading: boolean;
588
637
  emailLoading: boolean;
589
638
  error: string | null;
@@ -605,6 +654,7 @@ declare function useSocialWallet(): {
605
654
  solana?: string;
606
655
  } | null;
607
656
  sessionExpiresAt: number | null;
657
+ needsReconnect: boolean;
608
658
  modalOpen: boolean;
609
659
  openModal: () => void;
610
660
  closeModal: () => void;
@@ -620,6 +670,17 @@ declare function useSocialWallet(): {
620
670
  gasPrice?: bigint;
621
671
  }) => Promise<string>;
622
672
  signSolanaTransaction: (tx: Uint8Array) => Promise<Uint8Array<ArrayBufferLike>>;
673
+ rotateShares: (opts: {
674
+ password: string;
675
+ passwordHint?: string;
676
+ }) => Promise<RecoveryShareFile>;
677
+ exportPortableBackup: (opts: {
678
+ password: string;
679
+ passwordHint?: string;
680
+ }) => Promise<PortableBackup>;
681
+ hasRecoveryShare: () => Promise<boolean>;
682
+ shouldPromptRecovery: () => Promise<boolean>;
683
+ dismissRecoveryPrompt: () => Promise<void>;
623
684
  loading: boolean;
624
685
  error: string | null;
625
686
  clearError: () => void;
@@ -696,4 +757,4 @@ declare function useSignTypedData(): {
696
757
  reset: () => void;
697
758
  };
698
759
 
699
- export { type ActiveSession, AttestationError, type AuthResult, BUILT_IN_CHAINS, type CAIP25Method, type CAIP25SessionRequest, type CAIP25SessionResult, CHAINS, CallSequenceError, type Chain, type ChainDescriptor, type ChainId, type ChainScope, type ChainSupport, type ChainType, type ConnectMode, type ConnectResult, type DecaneConfig, type DecaneConnect, type DecaneConnectConfig, DecaneConnectError, DecaneError, DecaneErrorCode, DecaneKit, type DecaneProvider, ExportNotAuthorizedError, InvalidApiKeyError, InvalidPinError, InvalidRecoveryFileError, NetworkError, NewDeviceError, OriginNotAllowedError, type PortableBackup, PromptPinNotConfiguredError, RecoveryFailedError, type RecoveryProgress, type RecoveryShareFile, RecoveryWalletMismatchError, type SdkEvent, type SendTransactionRequest, SessionExpiredError, ShareCorruptedError, type SignMessageRequest, type SocialAuthState, type SocialConfig, SocialWalletModal, type Theme, type TxParams, type UnifiedWalletAccount, UnlockRequiredError, UserCancelledError, WalletSelector, WebAuthnNotSupportedError, type WrappedShareMeta, WrongPasswordError, createDecane, createDecaneConnect, startEmailAuth, useChainSwitch, useDecane, useSendTransaction, useSignMessage, useSignTypedData, useSocialAuth, useSocialWallet, useWalletSelector, verifyEmailCode };
760
+ export { type ActiveSession, AttestationError, type AuthResult, BUILT_IN_CHAINS, type CAIP25Method, type CAIP25SessionRequest, type CAIP25SessionResult, CHAINS, CallSequenceError, type Chain, type ChainDescriptor, type ChainId, type ChainScope, type ChainSupport, type ChainType, type ConnectMode, type ConnectResult, type DecaneConfig, type DecaneConnect, type DecaneConnectConfig, DecaneConnectError, DecaneError, DecaneErrorCode, DecaneKit, type DecaneProvider, ExportNotAuthorizedError, InvalidApiKeyError, InvalidPinError, InvalidRecoveryFileError, NetworkError, NewDeviceError, OriginNotAllowedError, type PortableBackup, PromptPinNotConfiguredError, ReconnectRequiredError, RecoveryFailedError, type RecoveryProgress, type RecoveryShareFile, RecoveryWalletMismatchError, type SdkEvent, type SendTransactionRequest, SessionExpiredError, ShareCorruptedError, type SignMessageRequest, type SocialAuthState, type SocialConfig, SocialWalletModal, type Theme, type TxParams, type UnifiedWalletAccount, UnlockRequiredError, UserCancelledError, WalletSelector, WebAuthnNotSupportedError, type WrappedShareMeta, WrongPasswordError, createDecane, createDecaneConnect, startEmailAuth, useChainSwitch, useDecane, useSendTransaction, useSignMessage, useSignTypedData, useSocialAuth, useSocialWallet, useWalletSelector, verifyEmailCode };