@spfn/auth 0.3.0-beta.22 → 0.3.0-beta.24

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.
Files changed (34) hide show
  1. package/README.md +308 -4
  2. package/dist/client-proof.js +13 -5
  3. package/dist/client-proof.js.map +1 -1
  4. package/dist/client.d.ts +52 -1
  5. package/dist/client.js +40 -0
  6. package/dist/client.js.map +1 -1
  7. package/dist/config.d.ts +120 -0
  8. package/dist/config.js +55 -0
  9. package/dist/config.js.map +1 -1
  10. package/dist/crypto.d.ts +1 -1
  11. package/dist/errors.d.ts +208 -3
  12. package/dist/errors.js +131 -2
  13. package/dist/errors.js.map +1 -1
  14. package/dist/index.d.ts +71 -5
  15. package/dist/index.js +134 -3
  16. package/dist/index.js.map +1 -1
  17. package/dist/{machine-principals-B7N8gux0.d.ts → machine-principals-ZJd9anVT.d.ts} +2045 -886
  18. package/dist/nextjs/api.js +156 -6
  19. package/dist/nextjs/api.js.map +1 -1
  20. package/dist/nextjs/server.d.ts +42 -24
  21. package/dist/nextjs/server.js +72 -5
  22. package/dist/nextjs/server.js.map +1 -1
  23. package/dist/server.d.ts +1033 -598
  24. package/dist/server.js +3239 -1541
  25. package/dist/server.js.map +1 -1
  26. package/dist/{session-Dfwu5g2W.d.ts → session-BbhAGZtA.d.ts} +57 -1
  27. package/dist/{types-DYyhze28.d.ts → types-CTdoTOxM.d.ts} +24 -1
  28. package/migrations/20260918162828_handy_titania/migration.sql +35 -0
  29. package/migrations/20260918162828_handy_titania/snapshot.json +5948 -0
  30. package/migrations/20260918184037_happy_mordo/migration.sql +4 -0
  31. package/migrations/20260918184037_happy_mordo/snapshot.json +6000 -0
  32. package/migrations/20260918184152_dear_rictor/migration.sql +3 -0
  33. package/migrations/20260918184152_dear_rictor/snapshot.json +6039 -0
  34. package/package.json +1 -1
package/dist/errors.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ConflictError, ForbiddenError, NotFoundError, ValidationError, UnauthorizedError, HttpError, ErrorRegistry } from '@spfn/core/errors';
1
+ import { ConflictError, ForbiddenError, NotFoundError, ValidationError, UnauthorizedError, HttpError, BadRequestError, InternalServerError, ErrorRegistry } from '@spfn/core/errors';
2
2
 
3
3
  /**
4
4
  * Authentication & Authorization Error Classes
@@ -605,6 +605,106 @@ declare class LastRecoveryCredentialError extends ConflictError {
605
605
  details?: Record<string, any>;
606
606
  });
607
607
  }
608
+ /**
609
+ * Session Renewal Required Error (401)
610
+ *
611
+ * Minted by the Next.js proxy, not by the backend: a bound session whose key has
612
+ * run out, on a request the proxy therefore does not forward. The browser's
613
+ * answer is to run the passkey ceremony `renewSession()` wraps and retry, which
614
+ * is the one thing a copied cookie cannot do.
615
+ *
616
+ * Registered here so the proxy's 401 arrives as this class rather than as a bare
617
+ * `ApiError` — the refusal is one an app branches on, and `err instanceof` is
618
+ * how every other branch in this package is written.
619
+ */
620
+ declare class SessionRenewalRequiredError extends UnauthorizedError {
621
+ readonly code = "SESSION_RENEWAL_REQUIRED";
622
+ constructor(data?: {
623
+ message?: string;
624
+ details?: Record<string, any>;
625
+ });
626
+ }
627
+ /**
628
+ * Session Renewal Refused Error (401)
629
+ *
630
+ * The one answer `session/renew/options` and `session/renew/verify` give to every
631
+ * refusal: a key id that names nothing, someone else's key, an unbound key, a
632
+ * revoked key, a key past its renewal grace, an inactive account, a spent
633
+ * challenge, an assertion that did not verify, a passkey belonging to another
634
+ * account.
635
+ *
636
+ * One answer on purpose. The routes are public — they have to be, since the
637
+ * session they repair is the one that stopped working — and a refusal that
638
+ * varied would tell an unauthenticated caller whether a key id is live, which is
639
+ * exactly what the cookie-copying adversary holds and would want confirmed.
640
+ */
641
+ declare class SessionRenewalRefusedError extends UnauthorizedError {
642
+ readonly code = "SESSION_RENEWAL_REFUSED";
643
+ constructor(data?: {
644
+ message?: string;
645
+ details?: Record<string, any>;
646
+ });
647
+ }
648
+ /**
649
+ * Session Context Changed Error (401)
650
+ *
651
+ * Minted by the Next.js proxy: a bound session presented from a different
652
+ * browser family than the one it was sealed from. Browsers do not share cookie
653
+ * jars, so a session that moves between two of them moved because somebody
654
+ * copied it — this is the only defence that acts before the bound key runs out,
655
+ * and it is the reason the three session cookies are cleared with the refusal.
656
+ *
657
+ * Only for bound sessions, and only when the request carried a `user-agent` at
658
+ * all. An absent one is no signal rather than a different family: a server
659
+ * component calling the RPC proxy sends none.
660
+ */
661
+ declare class SessionContextChangedError extends UnauthorizedError {
662
+ readonly code = "SESSION_CONTEXT_CHANGED";
663
+ constructor(data?: {
664
+ message?: string;
665
+ details?: Record<string, any>;
666
+ });
667
+ }
668
+ /**
669
+ * Session Binding Unavailable Error (400)
670
+ *
671
+ * Thrown when an account asks to bind its session on a deployment where the
672
+ * backend cannot tell a request through the trusted Next.js proxy from a direct
673
+ * one — `proxy-guard` unconfigured, so `clientType` is never `'web'`.
674
+ *
675
+ * A configuration refusal rather than a security one, which is why it is a 400
676
+ * and why the message names what to set: with nothing to distinguish the proxy,
677
+ * every key would be registered unbound and the setting would be a switch that
678
+ * reports success and protects nothing.
679
+ */
680
+ declare class SessionBindingUnavailableError extends BadRequestError {
681
+ readonly code = "SESSION_BINDING_UNAVAILABLE";
682
+ constructor(data?: {
683
+ message?: string;
684
+ details?: Record<string, any>;
685
+ });
686
+ }
687
+ /**
688
+ * Session Reseal Failed Error (500)
689
+ *
690
+ * Minted by the Next.js proxy when a binding change committed on the backend but
691
+ * the session cookie could not be re-sealed to match it.
692
+ *
693
+ * Answered instead of the route's 200, which is the point: the setting has moved
694
+ * and the cookie has not, and the two disagreeing is the state the whole feature
695
+ * is built to avoid — a bound key with a cookie that says unbound is cleared as
696
+ * an ordinary expired session a day later, and an unbound key with a cookie that
697
+ * says bound asks for a renewal the backend will refuse. The three session
698
+ * cookies go with this refusal, so the repair is a sign-in, which mints a cookie
699
+ * that agrees with the row.
700
+ */
701
+ declare class SessionResealFailedError extends InternalServerError {
702
+ readonly code = "SESSION_RESEAL_FAILED";
703
+ constructor(data?: {
704
+ message?: string;
705
+ details?: Record<string, any>;
706
+ });
707
+ }
608
708
  /**
609
709
  * Passkey Config Error (500)
610
710
  *
@@ -686,6 +786,91 @@ declare class OAuth2GrantNotFoundError extends NotFoundError {
686
786
  details?: Record<string, any>;
687
787
  });
688
788
  }
789
+ /**
790
+ * MFA Already Enrolled Error (409)
791
+ *
792
+ * Thrown when `totp/enroll` is called on an account whose TOTP is already
793
+ * confirmed. Replacing a working second factor is `disable` followed by a fresh
794
+ * enrolment, both step-up gated — an enrol that quietly overwrote a confirmed
795
+ * secret would be a way to swap someone's authenticator for your own.
796
+ */
797
+ declare class MfaAlreadyEnrolledError extends ConflictError {
798
+ constructor(data?: {
799
+ message?: string;
800
+ details?: Record<string, any>;
801
+ });
802
+ }
803
+ /**
804
+ * MFA Not Enrolled Error (400)
805
+ *
806
+ * Thrown when a call needs an enrolment that is not there: `totp/confirm` with
807
+ * no pending secret — including the row its own five failed attempts deleted —
808
+ * or `recovery/regenerate` on an account with no second factor. `disable` is
809
+ * deliberately not one of them; it answers 204 either way, because "make sure
810
+ * MFA is off" has already succeeded.
811
+ */
812
+ declare class MfaNotEnrolledError extends ValidationError {
813
+ constructor(data?: {
814
+ message?: string;
815
+ details?: Record<string, any>;
816
+ });
817
+ }
818
+ /**
819
+ * MFA Verification Failed Error (401)
820
+ *
821
+ * Thrown when a submitted code does not verify: a wrong or stale TOTP, a code
822
+ * from a step already spent, a recovery code that is used, from an older
823
+ * generation or another account's, or an assertion from a passkey the owner
824
+ * never marked as a second factor.
825
+ *
826
+ * One body for all of them. Which one applies describes state the caller is
827
+ * guessing at, and the remedy — look at the authenticator again — is the same.
828
+ */
829
+ declare class MfaVerificationFailedError extends UnauthorizedError {
830
+ constructor(data?: {
831
+ message?: string;
832
+ details?: Record<string, any>;
833
+ });
834
+ }
835
+ /**
836
+ * Step Up Required Error (403)
837
+ *
838
+ * Thrown when an enrolled account asks for a sensitive change from a device
839
+ * whose second factor was last verified longer ago than the step-up window. A
840
+ * stolen session alone therefore cannot change a password, sign every device
841
+ * out, or take the second factor off.
842
+ *
843
+ * 403 and not 401, on the same reasoning as `RecentAuthenticationRequiredError`,
844
+ * which it sits beside: a 401 on an authenticated route is what a web client
845
+ * reads as "the session is gone", so it would sign the user out instead of
846
+ * asking for a code. Clients branch on `code` to send the user to
847
+ * `POST /_auth/mfa/step-up` and retry.
848
+ */
849
+ declare class StepUpRequiredError extends ForbiddenError {
850
+ readonly code = "STEP_UP_REQUIRED";
851
+ constructor(data?: {
852
+ message?: string;
853
+ details?: Record<string, any>;
854
+ });
855
+ }
856
+ /**
857
+ * MFA Config Error (500)
858
+ *
859
+ * Thrown when the at-rest keyring cannot serve a second factor:
860
+ * `SPFN_AUTH_TOKEN_ENCRYPTION_KEYS` is unset, or a stored secret names a key id
861
+ * that has been dropped from it.
862
+ *
863
+ * Deliberately not the 401 a wrong code gets. The two have nothing in common: a
864
+ * wrong code is one person looking at the wrong line of their authenticator,
865
+ * and a broken keyring is every enrolled user locked out at once by a deploy.
866
+ * An operator has to be able to tell them apart from the response alone.
867
+ */
868
+ declare class MfaConfigError extends HttpError {
869
+ constructor(data: {
870
+ message: string;
871
+ details?: Record<string, any>;
872
+ });
873
+ }
689
874
 
690
875
  type authErrors_AccountAlreadyExistsError = AccountAlreadyExistsError;
691
876
  declare const authErrors_AccountAlreadyExistsError: typeof AccountAlreadyExistsError;
@@ -737,6 +922,14 @@ type authErrors_KeyNotFoundError = KeyNotFoundError;
737
922
  declare const authErrors_KeyNotFoundError: typeof KeyNotFoundError;
738
923
  type authErrors_LastRecoveryCredentialError = LastRecoveryCredentialError;
739
924
  declare const authErrors_LastRecoveryCredentialError: typeof LastRecoveryCredentialError;
925
+ type authErrors_MfaAlreadyEnrolledError = MfaAlreadyEnrolledError;
926
+ declare const authErrors_MfaAlreadyEnrolledError: typeof MfaAlreadyEnrolledError;
927
+ type authErrors_MfaConfigError = MfaConfigError;
928
+ declare const authErrors_MfaConfigError: typeof MfaConfigError;
929
+ type authErrors_MfaNotEnrolledError = MfaNotEnrolledError;
930
+ declare const authErrors_MfaNotEnrolledError: typeof MfaNotEnrolledError;
931
+ type authErrors_MfaVerificationFailedError = MfaVerificationFailedError;
932
+ declare const authErrors_MfaVerificationFailedError: typeof MfaVerificationFailedError;
740
933
  type authErrors_NativeSignInUnsupportedError = NativeSignInUnsupportedError;
741
934
  declare const authErrors_NativeSignInUnsupportedError: typeof NativeSignInUnsupportedError;
742
935
  type authErrors_NonceKeyBindingError = NonceKeyBindingError;
@@ -771,6 +964,18 @@ type authErrors_ReservedUsernameError = ReservedUsernameError;
771
964
  declare const authErrors_ReservedUsernameError: typeof ReservedUsernameError;
772
965
  type authErrors_RevokeAllLinkError = RevokeAllLinkError;
773
966
  declare const authErrors_RevokeAllLinkError: typeof RevokeAllLinkError;
967
+ type authErrors_SessionBindingUnavailableError = SessionBindingUnavailableError;
968
+ declare const authErrors_SessionBindingUnavailableError: typeof SessionBindingUnavailableError;
969
+ type authErrors_SessionContextChangedError = SessionContextChangedError;
970
+ declare const authErrors_SessionContextChangedError: typeof SessionContextChangedError;
971
+ type authErrors_SessionRenewalRefusedError = SessionRenewalRefusedError;
972
+ declare const authErrors_SessionRenewalRefusedError: typeof SessionRenewalRefusedError;
973
+ type authErrors_SessionRenewalRequiredError = SessionRenewalRequiredError;
974
+ declare const authErrors_SessionRenewalRequiredError: typeof SessionRenewalRequiredError;
975
+ type authErrors_SessionResealFailedError = SessionResealFailedError;
976
+ declare const authErrors_SessionResealFailedError: typeof SessionResealFailedError;
977
+ type authErrors_StepUpRequiredError = StepUpRequiredError;
978
+ declare const authErrors_StepUpRequiredError: typeof StepUpRequiredError;
774
979
  type authErrors_TokenExpiredError = TokenExpiredError;
775
980
  declare const authErrors_TokenExpiredError: typeof TokenExpiredError;
776
981
  type authErrors_UnverifiedEmailLinkError = UnverifiedEmailLinkError;
@@ -782,7 +987,7 @@ declare const authErrors_VerificationTokenPurposeMismatchError: typeof Verificat
782
987
  type authErrors_VerificationTokenTargetMismatchError = VerificationTokenTargetMismatchError;
783
988
  declare const authErrors_VerificationTokenTargetMismatchError: typeof VerificationTokenTargetMismatchError;
784
989
  declare namespace authErrors {
785
- export { authErrors_AccountAlreadyExistsError as AccountAlreadyExistsError, authErrors_AccountDisabledError as AccountDisabledError, authErrors_AccountPendingDeletionError as AccountPendingDeletionError, authErrors_DeletionAlreadyRequestedError as DeletionAlreadyRequestedError, authErrors_DeletionNotRequestedError as DeletionNotRequestedError, authErrors_DeviceAuthAlreadyHandledError as DeviceAuthAlreadyHandledError, authErrors_DeviceAuthDeniedError as DeviceAuthDeniedError, authErrors_DeviceAuthExpiredError as DeviceAuthExpiredError, authErrors_DeviceAuthNotFoundError as DeviceAuthNotFoundError, authErrors_ImmediateDeletionNotAllowedError as ImmediateDeletionNotAllowedError, authErrors_InsufficientPermissionsError as InsufficientPermissionsError, authErrors_InsufficientRoleError as InsufficientRoleError, authErrors_InvalidCredentialsError as InvalidCredentialsError, authErrors_InvalidKeyFingerprintError as InvalidKeyFingerprintError, authErrors_InvalidSignupLinkError as InvalidSignupLinkError, authErrors_InvalidSignupSetupSessionError as InvalidSignupSetupSessionError, authErrors_InvalidSocialTokenError as InvalidSocialTokenError, authErrors_InvalidTokenError as InvalidTokenError, authErrors_InvalidVerificationCodeError as InvalidVerificationCodeError, authErrors_InvalidVerificationTokenError as InvalidVerificationTokenError, authErrors_KeyAlgorithmMismatchError as KeyAlgorithmMismatchError, authErrors_KeyExpiredError as KeyExpiredError, authErrors_KeyIdAlreadyRegisteredError as KeyIdAlreadyRegisteredError, authErrors_KeyNotFoundError as KeyNotFoundError, authErrors_LastRecoveryCredentialError as LastRecoveryCredentialError, authErrors_NativeSignInUnsupportedError as NativeSignInUnsupportedError, authErrors_NonceKeyBindingError as NonceKeyBindingError, authErrors_OAuth2AuthorizeRedirectError as OAuth2AuthorizeRedirectError, authErrors_OAuth2GrantNotFoundError as OAuth2GrantNotFoundError, authErrors_OAuth2RedirectUriMismatchError as OAuth2RedirectUriMismatchError, authErrors_OAuth2UnknownClientError as OAuth2UnknownClientError, authErrors_PasskeyAlreadyRegisteredError as PasskeyAlreadyRegisteredError, authErrors_PasskeyChallengeError as PasskeyChallengeError, authErrors_PasskeyConfigError as PasskeyConfigError, authErrors_PasskeyNotFoundError as PasskeyNotFoundError, authErrors_PasskeyVerificationError as PasskeyVerificationError, authErrors_PasswordResetLinkError as PasswordResetLinkError, authErrors_PasswordResetSessionError as PasswordResetSessionError, authErrors_RecentAuthenticationRequiredError as RecentAuthenticationRequiredError, authErrors_RegistrationRejectedError as RegistrationRejectedError, authErrors_ReservedUsernameError as ReservedUsernameError, authErrors_RevokeAllLinkError as RevokeAllLinkError, authErrors_TokenExpiredError as TokenExpiredError, authErrors_UnverifiedEmailLinkError as UnverifiedEmailLinkError, authErrors_UsernameAlreadyTakenError as UsernameAlreadyTakenError, authErrors_VerificationTokenPurposeMismatchError as VerificationTokenPurposeMismatchError, authErrors_VerificationTokenTargetMismatchError as VerificationTokenTargetMismatchError };
990
+ export { authErrors_AccountAlreadyExistsError as AccountAlreadyExistsError, authErrors_AccountDisabledError as AccountDisabledError, authErrors_AccountPendingDeletionError as AccountPendingDeletionError, authErrors_DeletionAlreadyRequestedError as DeletionAlreadyRequestedError, authErrors_DeletionNotRequestedError as DeletionNotRequestedError, authErrors_DeviceAuthAlreadyHandledError as DeviceAuthAlreadyHandledError, authErrors_DeviceAuthDeniedError as DeviceAuthDeniedError, authErrors_DeviceAuthExpiredError as DeviceAuthExpiredError, authErrors_DeviceAuthNotFoundError as DeviceAuthNotFoundError, authErrors_ImmediateDeletionNotAllowedError as ImmediateDeletionNotAllowedError, authErrors_InsufficientPermissionsError as InsufficientPermissionsError, authErrors_InsufficientRoleError as InsufficientRoleError, authErrors_InvalidCredentialsError as InvalidCredentialsError, authErrors_InvalidKeyFingerprintError as InvalidKeyFingerprintError, authErrors_InvalidSignupLinkError as InvalidSignupLinkError, authErrors_InvalidSignupSetupSessionError as InvalidSignupSetupSessionError, authErrors_InvalidSocialTokenError as InvalidSocialTokenError, authErrors_InvalidTokenError as InvalidTokenError, authErrors_InvalidVerificationCodeError as InvalidVerificationCodeError, authErrors_InvalidVerificationTokenError as InvalidVerificationTokenError, authErrors_KeyAlgorithmMismatchError as KeyAlgorithmMismatchError, authErrors_KeyExpiredError as KeyExpiredError, authErrors_KeyIdAlreadyRegisteredError as KeyIdAlreadyRegisteredError, authErrors_KeyNotFoundError as KeyNotFoundError, authErrors_LastRecoveryCredentialError as LastRecoveryCredentialError, authErrors_MfaAlreadyEnrolledError as MfaAlreadyEnrolledError, authErrors_MfaConfigError as MfaConfigError, authErrors_MfaNotEnrolledError as MfaNotEnrolledError, authErrors_MfaVerificationFailedError as MfaVerificationFailedError, authErrors_NativeSignInUnsupportedError as NativeSignInUnsupportedError, authErrors_NonceKeyBindingError as NonceKeyBindingError, authErrors_OAuth2AuthorizeRedirectError as OAuth2AuthorizeRedirectError, authErrors_OAuth2GrantNotFoundError as OAuth2GrantNotFoundError, authErrors_OAuth2RedirectUriMismatchError as OAuth2RedirectUriMismatchError, authErrors_OAuth2UnknownClientError as OAuth2UnknownClientError, authErrors_PasskeyAlreadyRegisteredError as PasskeyAlreadyRegisteredError, authErrors_PasskeyChallengeError as PasskeyChallengeError, authErrors_PasskeyConfigError as PasskeyConfigError, authErrors_PasskeyNotFoundError as PasskeyNotFoundError, authErrors_PasskeyVerificationError as PasskeyVerificationError, authErrors_PasswordResetLinkError as PasswordResetLinkError, authErrors_PasswordResetSessionError as PasswordResetSessionError, authErrors_RecentAuthenticationRequiredError as RecentAuthenticationRequiredError, authErrors_RegistrationRejectedError as RegistrationRejectedError, authErrors_ReservedUsernameError as ReservedUsernameError, authErrors_RevokeAllLinkError as RevokeAllLinkError, authErrors_SessionBindingUnavailableError as SessionBindingUnavailableError, authErrors_SessionContextChangedError as SessionContextChangedError, authErrors_SessionRenewalRefusedError as SessionRenewalRefusedError, authErrors_SessionRenewalRequiredError as SessionRenewalRequiredError, authErrors_SessionResealFailedError as SessionResealFailedError, authErrors_StepUpRequiredError as StepUpRequiredError, authErrors_TokenExpiredError as TokenExpiredError, authErrors_UnverifiedEmailLinkError as UnverifiedEmailLinkError, authErrors_UsernameAlreadyTakenError as UsernameAlreadyTakenError, authErrors_VerificationTokenPurposeMismatchError as VerificationTokenPurposeMismatchError, authErrors_VerificationTokenTargetMismatchError as VerificationTokenTargetMismatchError };
786
991
  }
787
992
 
788
993
  /**
@@ -791,4 +996,4 @@ declare namespace authErrors {
791
996
 
792
997
  declare const authErrorRegistry: ErrorRegistry;
793
998
 
794
- export { AccountAlreadyExistsError, AccountDisabledError, AccountPendingDeletionError, authErrors as AuthError, DeletionAlreadyRequestedError, DeletionNotRequestedError, DeviceAuthAlreadyHandledError, DeviceAuthDeniedError, DeviceAuthExpiredError, DeviceAuthNotFoundError, ImmediateDeletionNotAllowedError, InsufficientPermissionsError, InsufficientRoleError, InvalidCredentialsError, InvalidKeyFingerprintError, InvalidSignupLinkError, InvalidSignupSetupSessionError, InvalidSocialTokenError, InvalidTokenError, InvalidVerificationCodeError, InvalidVerificationTokenError, KeyAlgorithmMismatchError, KeyExpiredError, KeyIdAlreadyRegisteredError, KeyNotFoundError, LastRecoveryCredentialError, NativeSignInUnsupportedError, NonceKeyBindingError, OAuth2AuthorizeRedirectError, OAuth2GrantNotFoundError, OAuth2RedirectUriMismatchError, OAuth2UnknownClientError, PasskeyAlreadyRegisteredError, PasskeyChallengeError, PasskeyConfigError, PasskeyNotFoundError, PasskeyVerificationError, PasswordResetLinkError, PasswordResetSessionError, RecentAuthenticationRequiredError, RegistrationRejectedError, ReservedUsernameError, RevokeAllLinkError, TokenExpiredError, UnverifiedEmailLinkError, UsernameAlreadyTakenError, VerificationTokenPurposeMismatchError, VerificationTokenTargetMismatchError, authErrorRegistry };
999
+ export { AccountAlreadyExistsError, AccountDisabledError, AccountPendingDeletionError, authErrors as AuthError, DeletionAlreadyRequestedError, DeletionNotRequestedError, DeviceAuthAlreadyHandledError, DeviceAuthDeniedError, DeviceAuthExpiredError, DeviceAuthNotFoundError, ImmediateDeletionNotAllowedError, InsufficientPermissionsError, InsufficientRoleError, InvalidCredentialsError, InvalidKeyFingerprintError, InvalidSignupLinkError, InvalidSignupSetupSessionError, InvalidSocialTokenError, InvalidTokenError, InvalidVerificationCodeError, InvalidVerificationTokenError, KeyAlgorithmMismatchError, KeyExpiredError, KeyIdAlreadyRegisteredError, KeyNotFoundError, LastRecoveryCredentialError, MfaAlreadyEnrolledError, MfaConfigError, MfaNotEnrolledError, MfaVerificationFailedError, NativeSignInUnsupportedError, NonceKeyBindingError, OAuth2AuthorizeRedirectError, OAuth2GrantNotFoundError, OAuth2RedirectUriMismatchError, OAuth2UnknownClientError, PasskeyAlreadyRegisteredError, PasskeyChallengeError, PasskeyConfigError, PasskeyNotFoundError, PasskeyVerificationError, PasswordResetLinkError, PasswordResetSessionError, RecentAuthenticationRequiredError, RegistrationRejectedError, ReservedUsernameError, RevokeAllLinkError, SessionBindingUnavailableError, SessionContextChangedError, SessionRenewalRefusedError, SessionRenewalRequiredError, SessionResealFailedError, StepUpRequiredError, TokenExpiredError, UnverifiedEmailLinkError, UsernameAlreadyTakenError, VerificationTokenPurposeMismatchError, VerificationTokenTargetMismatchError, authErrorRegistry };
package/dist/errors.js CHANGED
@@ -35,6 +35,10 @@ __export(auth_errors_exports, {
35
35
  KeyIdAlreadyRegisteredError: () => KeyIdAlreadyRegisteredError,
36
36
  KeyNotFoundError: () => KeyNotFoundError,
37
37
  LastRecoveryCredentialError: () => LastRecoveryCredentialError,
38
+ MfaAlreadyEnrolledError: () => MfaAlreadyEnrolledError,
39
+ MfaConfigError: () => MfaConfigError,
40
+ MfaNotEnrolledError: () => MfaNotEnrolledError,
41
+ MfaVerificationFailedError: () => MfaVerificationFailedError,
38
42
  NativeSignInUnsupportedError: () => NativeSignInUnsupportedError,
39
43
  NonceKeyBindingError: () => NonceKeyBindingError,
40
44
  OAuth2AuthorizeRedirectError: () => OAuth2AuthorizeRedirectError,
@@ -52,6 +56,12 @@ __export(auth_errors_exports, {
52
56
  RegistrationRejectedError: () => RegistrationRejectedError,
53
57
  ReservedUsernameError: () => ReservedUsernameError,
54
58
  RevokeAllLinkError: () => RevokeAllLinkError,
59
+ SessionBindingUnavailableError: () => SessionBindingUnavailableError,
60
+ SessionContextChangedError: () => SessionContextChangedError,
61
+ SessionRenewalRefusedError: () => SessionRenewalRefusedError,
62
+ SessionRenewalRequiredError: () => SessionRenewalRequiredError,
63
+ SessionResealFailedError: () => SessionResealFailedError,
64
+ StepUpRequiredError: () => StepUpRequiredError,
55
65
  TokenExpiredError: () => TokenExpiredError,
56
66
  UnverifiedEmailLinkError: () => UnverifiedEmailLinkError,
57
67
  UsernameAlreadyTakenError: () => UsernameAlreadyTakenError,
@@ -59,12 +69,14 @@ __export(auth_errors_exports, {
59
69
  VerificationTokenTargetMismatchError: () => VerificationTokenTargetMismatchError
60
70
  });
61
71
  import {
72
+ BadRequestError,
62
73
  ValidationError,
63
74
  UnauthorizedError,
64
75
  ForbiddenError,
65
76
  ConflictError,
66
77
  NotFoundError,
67
- HttpError
78
+ HttpError,
79
+ InternalServerError
68
80
  } from "@spfn/core/errors";
69
81
  var InvalidCredentialsError = class extends UnauthorizedError {
70
82
  constructor(data = {}) {
@@ -413,6 +425,56 @@ var LastRecoveryCredentialError = class extends ConflictError {
413
425
  this.name = "LastRecoveryCredentialError";
414
426
  }
415
427
  };
428
+ var SessionRenewalRequiredError = class extends UnauthorizedError {
429
+ code = "SESSION_RENEWAL_REQUIRED";
430
+ constructor(data = {}) {
431
+ super({
432
+ message: data.message || "This session needs renewing. Confirm with your passkey to continue.",
433
+ details: data.details
434
+ });
435
+ this.name = "SessionRenewalRequiredError";
436
+ }
437
+ };
438
+ var SessionRenewalRefusedError = class extends UnauthorizedError {
439
+ code = "SESSION_RENEWAL_REFUSED";
440
+ constructor(data = {}) {
441
+ super({
442
+ message: data.message || "This session cannot be renewed. Sign in again.",
443
+ details: data.details
444
+ });
445
+ this.name = "SessionRenewalRefusedError";
446
+ }
447
+ };
448
+ var SessionContextChangedError = class extends UnauthorizedError {
449
+ code = "SESSION_CONTEXT_CHANGED";
450
+ constructor(data = {}) {
451
+ super({
452
+ message: data.message || "This session was started in a different browser. Sign in again.",
453
+ details: data.details
454
+ });
455
+ this.name = "SessionContextChangedError";
456
+ }
457
+ };
458
+ var SessionBindingUnavailableError = class extends BadRequestError {
459
+ code = "SESSION_BINDING_UNAVAILABLE";
460
+ constructor(data = {}) {
461
+ super({
462
+ message: data.message || "Session binding needs a deployment where the backend can recognise the Next.js proxy. Configure proxy-guard (SPFN_PROXY_SIGNATURE_KEYS) and try again.",
463
+ details: data.details
464
+ });
465
+ this.name = "SessionBindingUnavailableError";
466
+ }
467
+ };
468
+ var SessionResealFailedError = class extends InternalServerError {
469
+ code = "SESSION_RESEAL_FAILED";
470
+ constructor(data = {}) {
471
+ super({
472
+ message: data.message || "The setting was changed but this session could not be updated. Sign in again.",
473
+ details: data.details
474
+ });
475
+ this.name = "SessionResealFailedError";
476
+ }
477
+ };
416
478
  var PasskeyConfigError = class extends HttpError {
417
479
  constructor(data) {
418
480
  super({
@@ -461,6 +523,53 @@ var OAuth2GrantNotFoundError = class extends NotFoundError {
461
523
  this.name = "OAuth2GrantNotFoundError";
462
524
  }
463
525
  };
526
+ var MfaAlreadyEnrolledError = class extends ConflictError {
527
+ constructor(data = {}) {
528
+ super({
529
+ message: data.message || "A second factor is already enrolled on this account",
530
+ details: data.details
531
+ });
532
+ this.name = "MfaAlreadyEnrolledError";
533
+ }
534
+ };
535
+ var MfaNotEnrolledError = class extends ValidationError {
536
+ constructor(data = {}) {
537
+ super({
538
+ message: data.message || "No second-factor enrolment is in progress on this account",
539
+ details: data.details
540
+ });
541
+ this.name = "MfaNotEnrolledError";
542
+ }
543
+ };
544
+ var MfaVerificationFailedError = class extends UnauthorizedError {
545
+ constructor(data = {}) {
546
+ super({
547
+ message: data.message || "That code did not verify",
548
+ details: data.details
549
+ });
550
+ this.name = "MfaVerificationFailedError";
551
+ }
552
+ };
553
+ var StepUpRequiredError = class extends ForbiddenError {
554
+ code = "STEP_UP_REQUIRED";
555
+ constructor(data = {}) {
556
+ super({
557
+ message: data.message || "Confirm your second factor before making this change.",
558
+ details: data.details
559
+ });
560
+ this.name = "StepUpRequiredError";
561
+ }
562
+ };
563
+ var MfaConfigError = class extends HttpError {
564
+ constructor(data) {
565
+ super({
566
+ message: data.message,
567
+ statusCode: 500,
568
+ details: data.details
569
+ });
570
+ this.name = "MfaConfigError";
571
+ }
572
+ };
464
573
 
465
574
  // src/errors/index.ts
466
575
  var authErrorRegistry = new ErrorRegistry();
@@ -508,10 +617,20 @@ authErrorRegistry.append([
508
617
  RecentAuthenticationRequiredError,
509
618
  LastRecoveryCredentialError,
510
619
  PasskeyConfigError,
620
+ SessionBindingUnavailableError,
621
+ SessionRenewalRequiredError,
622
+ SessionRenewalRefusedError,
623
+ SessionContextChangedError,
624
+ SessionResealFailedError,
511
625
  OAuth2UnknownClientError,
512
626
  OAuth2RedirectUriMismatchError,
513
627
  OAuth2AuthorizeRedirectError,
514
- OAuth2GrantNotFoundError
628
+ OAuth2GrantNotFoundError,
629
+ MfaAlreadyEnrolledError,
630
+ MfaNotEnrolledError,
631
+ MfaVerificationFailedError,
632
+ StepUpRequiredError,
633
+ MfaConfigError
515
634
  ]);
516
635
  export {
517
636
  AccountAlreadyExistsError,
@@ -540,6 +659,10 @@ export {
540
659
  KeyIdAlreadyRegisteredError,
541
660
  KeyNotFoundError,
542
661
  LastRecoveryCredentialError,
662
+ MfaAlreadyEnrolledError,
663
+ MfaConfigError,
664
+ MfaNotEnrolledError,
665
+ MfaVerificationFailedError,
543
666
  NativeSignInUnsupportedError,
544
667
  NonceKeyBindingError,
545
668
  OAuth2AuthorizeRedirectError,
@@ -557,6 +680,12 @@ export {
557
680
  RegistrationRejectedError,
558
681
  ReservedUsernameError,
559
682
  RevokeAllLinkError,
683
+ SessionBindingUnavailableError,
684
+ SessionContextChangedError,
685
+ SessionRenewalRefusedError,
686
+ SessionRenewalRequiredError,
687
+ SessionResealFailedError,
688
+ StepUpRequiredError,
560
689
  TokenExpiredError,
561
690
  UnverifiedEmailLinkError,
562
691
  UsernameAlreadyTakenError,