@authrim/core 0.1.3 → 0.1.4
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 +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2917 -435
- package/dist/index.d.ts +2917 -435
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -394,6 +394,32 @@ interface OIDCDiscoveryDocument {
|
|
|
394
394
|
introspection_endpoint_auth_signing_alg_values_supported?: string[];
|
|
395
395
|
/** Code challenge methods supported (OPTIONAL) */
|
|
396
396
|
code_challenge_methods_supported?: string[];
|
|
397
|
+
/** Pushed Authorization Request endpoint (OPTIONAL) */
|
|
398
|
+
pushed_authorization_request_endpoint?: string;
|
|
399
|
+
/** Whether PAR is required (OPTIONAL) */
|
|
400
|
+
require_pushed_authorization_requests?: boolean;
|
|
401
|
+
/** Device Authorization endpoint (OPTIONAL) */
|
|
402
|
+
device_authorization_endpoint?: string;
|
|
403
|
+
/** DPoP signing algorithms supported (OPTIONAL) */
|
|
404
|
+
dpop_signing_alg_values_supported?: string[];
|
|
405
|
+
/** Whether signed request object is required (OPTIONAL) */
|
|
406
|
+
require_signed_request_object?: boolean;
|
|
407
|
+
/** Authorization response signing algorithms supported (OPTIONAL) */
|
|
408
|
+
authorization_signing_alg_values_supported?: string[];
|
|
409
|
+
/** Authorization response encryption algorithms supported (OPTIONAL) */
|
|
410
|
+
authorization_encryption_alg_values_supported?: string[];
|
|
411
|
+
/** Authorization response encryption enc values supported (OPTIONAL) */
|
|
412
|
+
authorization_encryption_enc_values_supported?: string[];
|
|
413
|
+
/** Check session iframe URL (OPTIONAL) */
|
|
414
|
+
check_session_iframe?: string;
|
|
415
|
+
/** Whether front-channel logout is supported (OPTIONAL) */
|
|
416
|
+
frontchannel_logout_supported?: boolean;
|
|
417
|
+
/** Whether session ID is required in front-channel logout (OPTIONAL) */
|
|
418
|
+
frontchannel_logout_session_supported?: boolean;
|
|
419
|
+
/** Whether back-channel logout is supported (OPTIONAL) */
|
|
420
|
+
backchannel_logout_supported?: boolean;
|
|
421
|
+
/** Whether session ID is required in back-channel logout (OPTIONAL) */
|
|
422
|
+
backchannel_logout_session_supported?: boolean;
|
|
397
423
|
/** Flow Engine support indicator (OPTIONAL, Authrim-specific) */
|
|
398
424
|
flow_engine_supported?: boolean;
|
|
399
425
|
[key: string]: unknown;
|
|
@@ -599,9 +625,16 @@ interface TokenExchangeResult {
|
|
|
599
625
|
*/
|
|
600
626
|
type AuthrimErrorUserAction = 'retry' | 'reauthenticate' | 'contact_support' | 'check_network' | 'none';
|
|
601
627
|
/**
|
|
602
|
-
* Error severity level
|
|
628
|
+
* Error severity level (legacy - 3 levels)
|
|
603
629
|
*/
|
|
604
630
|
type AuthrimErrorSeverity = 'fatal' | 'error' | 'warning';
|
|
631
|
+
/**
|
|
632
|
+
* Error remediation action
|
|
633
|
+
*
|
|
634
|
+
* Specifies what action should be taken to recover from an error.
|
|
635
|
+
* Separated from severity for clearer decision making.
|
|
636
|
+
*/
|
|
637
|
+
type AuthrimErrorRemediation = 'retry' | 'reauthenticate' | 'switch_flow' | 'contact_support' | 'none';
|
|
605
638
|
/**
|
|
606
639
|
* Error metadata for recovery information
|
|
607
640
|
*/
|
|
@@ -622,7 +655,7 @@ interface AuthrimErrorMeta {
|
|
|
622
655
|
/**
|
|
623
656
|
* Error codes used by the SDK
|
|
624
657
|
*/
|
|
625
|
-
type AuthrimErrorCode = 'invalid_request' | 'unauthorized_client' | 'access_denied' | 'unsupported_response_type' | 'invalid_scope' | 'server_error' | 'temporarily_unavailable' | 'invalid_grant' | 'invalid_token' | 'invalid_state' | 'expired_state' | 'invalid_nonce' | 'nonce_mismatch' | 'session_expired' | 'session_check_failed' | 'network_error' | 'timeout_error' | 'discovery_error' | 'discovery_mismatch' | 'configuration_error' | 'storage_error' | 'flow_engine_error' | 'no_tokens' | 'token_expired' | 'token_error' | 'refresh_error' | 'token_exchange_error' | 'oauth_error' | 'missing_code' | 'missing_state' | 'not_initialized' | 'no_discovery' | 'no_userinfo_endpoint' | 'userinfo_error' | 'introspection_error' | 'revocation_error' | 'no_introspection_endpoint' | 'no_revocation_endpoint' | 'login_required' | 'interaction_required' | 'consent_required' | 'account_selection_required' | 'dom_not_ready' | 'state_mismatch' | 'popup_blocked' | 'popup_closed' | 'invalid_response' | 'passkey_not_found' | 'passkey_verification_failed' | 'passkey_not_supported' | 'passkey_cancelled' | 'passkey_invalid_credential' | 'email_code_invalid' | 'email_code_expired' | 'email_code_too_many_attempts' | 'challenge_expired' | 'challenge_invalid' | 'auth_code_invalid' | 'auth_code_expired' | 'pkce_mismatch' | 'origin_not_allowed' | 'mfa_required' | 'email_verification_required' | 'consent_required_direct' | 'rate_limited' | 'event_handler_error';
|
|
658
|
+
type AuthrimErrorCode = 'invalid_request' | 'unauthorized_client' | 'access_denied' | 'unsupported_response_type' | 'invalid_scope' | 'server_error' | 'temporarily_unavailable' | 'invalid_grant' | 'invalid_token' | 'invalid_state' | 'expired_state' | 'invalid_nonce' | 'nonce_mismatch' | 'missing_nonce' | 'missing_id_token' | 'session_expired' | 'session_check_failed' | 'network_error' | 'timeout_error' | 'discovery_error' | 'discovery_mismatch' | 'configuration_error' | 'storage_error' | 'flow_engine_error' | 'no_tokens' | 'token_expired' | 'token_error' | 'refresh_error' | 'token_exchange_error' | 'oauth_error' | 'missing_code' | 'missing_state' | 'not_initialized' | 'no_discovery' | 'no_userinfo_endpoint' | 'userinfo_error' | 'introspection_error' | 'revocation_error' | 'no_introspection_endpoint' | 'no_revocation_endpoint' | 'login_required' | 'interaction_required' | 'consent_required' | 'account_selection_required' | 'dom_not_ready' | 'state_mismatch' | 'popup_blocked' | 'popup_closed' | 'invalid_response' | 'invalid_callback' | 'passkey_not_found' | 'passkey_verification_failed' | 'passkey_not_supported' | 'passkey_cancelled' | 'passkey_invalid_credential' | 'email_code_invalid' | 'email_code_expired' | 'email_code_too_many_attempts' | 'challenge_expired' | 'challenge_invalid' | 'auth_code_invalid' | 'auth_code_expired' | 'pkce_mismatch' | 'origin_not_allowed' | 'mfa_required' | 'email_verification_required' | 'consent_required_direct' | 'rate_limited' | 'event_handler_error' | 'par_required' | 'no_par_endpoint' | 'par_error' | 'par_request_uri_expired' | 'no_device_authorization_endpoint' | 'device_authorization_error' | 'device_authorization_pending' | 'device_slow_down' | 'device_authorization_expired' | 'device_access_denied' | 'client_credentials_error' | 'invalid_client_authentication' | 'insecure_client_auth' | 'dpop_key_generation_error' | 'dpop_proof_generation_error' | 'dpop_nonce_required' | 'jar_signing_error' | 'jar_required' | 'jarm_validation_error' | 'jarm_signature_invalid' | 'operation_cancelled' | 'invalid_return_to';
|
|
626
659
|
/**
|
|
627
660
|
* Options for creating an AuthrimError
|
|
628
661
|
*/
|
|
@@ -665,82 +698,456 @@ declare class AuthrimError extends Error {
|
|
|
665
698
|
* Get error metadata for a given error code
|
|
666
699
|
*/
|
|
667
700
|
declare function getErrorMeta(code: AuthrimErrorCode): AuthrimErrorMeta;
|
|
701
|
+
/**
|
|
702
|
+
* Error classification result
|
|
703
|
+
*/
|
|
704
|
+
interface ErrorClassification {
|
|
705
|
+
/** Severity: recoverable or fatal */
|
|
706
|
+
severity: 'recoverable' | 'fatal';
|
|
707
|
+
/** Recommended remediation action */
|
|
708
|
+
remediation: AuthrimErrorRemediation;
|
|
709
|
+
}
|
|
710
|
+
/**
|
|
711
|
+
* Classify an error by severity and remediation
|
|
712
|
+
*
|
|
713
|
+
* This provides a simplified 2-axis classification for UI decision making:
|
|
714
|
+
* - severity: Is this recoverable or fatal?
|
|
715
|
+
* - remediation: What action should be taken?
|
|
716
|
+
*/
|
|
717
|
+
declare function classifyError(error: AuthrimError): ErrorClassification;
|
|
718
|
+
/**
|
|
719
|
+
* Check if an error is retryable based on classification
|
|
720
|
+
*/
|
|
721
|
+
declare function isRetryableError(error: AuthrimError): boolean;
|
|
722
|
+
/**
|
|
723
|
+
* Event emitter interface for error emission
|
|
724
|
+
*
|
|
725
|
+
* Minimal interface required by emitClassifiedError
|
|
726
|
+
*/
|
|
727
|
+
interface ErrorEventEmitter {
|
|
728
|
+
emit(event: 'error', payload: {
|
|
729
|
+
error: AuthrimError;
|
|
730
|
+
severity: 'recoverable' | 'fatal';
|
|
731
|
+
remediation: AuthrimErrorRemediation;
|
|
732
|
+
context: string;
|
|
733
|
+
timestamp: number;
|
|
734
|
+
source: 'core' | 'web';
|
|
735
|
+
operationId?: string;
|
|
736
|
+
}): void;
|
|
737
|
+
emit(event: 'error:recoverable', payload: {
|
|
738
|
+
error: AuthrimError;
|
|
739
|
+
severity: 'recoverable';
|
|
740
|
+
remediation: AuthrimErrorRemediation;
|
|
741
|
+
context: string;
|
|
742
|
+
timestamp: number;
|
|
743
|
+
source: 'core' | 'web';
|
|
744
|
+
operationId?: string;
|
|
745
|
+
}): void;
|
|
746
|
+
emit(event: 'error:fatal', payload: {
|
|
747
|
+
error: AuthrimError;
|
|
748
|
+
severity: 'fatal';
|
|
749
|
+
remediation: AuthrimErrorRemediation;
|
|
750
|
+
context: string;
|
|
751
|
+
timestamp: number;
|
|
752
|
+
source: 'core' | 'web';
|
|
753
|
+
operationId?: string;
|
|
754
|
+
}): void;
|
|
755
|
+
}
|
|
756
|
+
/**
|
|
757
|
+
* Options for emitting classified errors
|
|
758
|
+
*/
|
|
759
|
+
interface EmitClassifiedErrorOptions {
|
|
760
|
+
/** Operation context where the error occurred */
|
|
761
|
+
context: string;
|
|
762
|
+
/** Operation tracking ID */
|
|
763
|
+
operationId?: string;
|
|
764
|
+
/** Event source (defaults to 'core') */
|
|
765
|
+
source?: 'core' | 'web';
|
|
766
|
+
}
|
|
767
|
+
/**
|
|
768
|
+
* Emit error events with proper classification
|
|
769
|
+
*
|
|
770
|
+
* Emits three events:
|
|
771
|
+
* 1. 'error' - Legacy event for backward compatibility
|
|
772
|
+
* 2. 'error:recoverable' - If severity is recoverable
|
|
773
|
+
* 3. 'error:fatal' - If severity is fatal
|
|
774
|
+
*
|
|
775
|
+
* @param emitter - Event emitter instance
|
|
776
|
+
* @param error - The error to emit
|
|
777
|
+
* @param options - Emission options (context, operationId, source)
|
|
778
|
+
*/
|
|
779
|
+
declare function emitClassifiedError(emitter: ErrorEventEmitter, error: AuthrimError, options: EmitClassifiedErrorOptions): void;
|
|
668
780
|
|
|
669
781
|
/**
|
|
670
782
|
* Event Types
|
|
783
|
+
*
|
|
784
|
+
* Unified event system for SDK observability.
|
|
785
|
+
* All events follow the namespace convention: auth:*, token:*, session:*, state:*, error:*, warning:*, debug:*
|
|
671
786
|
*/
|
|
672
787
|
|
|
673
788
|
/**
|
|
674
|
-
*
|
|
789
|
+
* Base event payload - all events include these fields
|
|
675
790
|
*/
|
|
676
|
-
interface
|
|
677
|
-
|
|
791
|
+
interface BaseEventPayload {
|
|
792
|
+
/** Event timestamp (Date.now()) */
|
|
793
|
+
timestamp: number;
|
|
794
|
+
/** Event source */
|
|
795
|
+
source: 'core' | 'web';
|
|
796
|
+
/** Operation tracking ID (maintained from redirect start to callback complete) */
|
|
797
|
+
operationId?: string;
|
|
678
798
|
}
|
|
679
799
|
/**
|
|
680
|
-
*
|
|
800
|
+
* SDK initialization complete
|
|
681
801
|
*/
|
|
682
|
-
interface
|
|
683
|
-
|
|
802
|
+
interface AuthInitEvent extends BaseEventPayload {
|
|
803
|
+
/** Client ID */
|
|
804
|
+
clientId: string;
|
|
805
|
+
/** Issuer URL */
|
|
806
|
+
issuer: string;
|
|
807
|
+
}
|
|
808
|
+
/**
|
|
809
|
+
* Auth redirecting event data
|
|
810
|
+
*/
|
|
811
|
+
interface AuthRedirectingEvent extends BaseEventPayload {
|
|
812
|
+
/** Authorization URL */
|
|
813
|
+
url: string;
|
|
814
|
+
}
|
|
815
|
+
/**
|
|
816
|
+
* Auth callback received
|
|
817
|
+
*/
|
|
818
|
+
interface AuthCallbackEvent extends BaseEventPayload {
|
|
819
|
+
/** Authorization code */
|
|
820
|
+
code: string;
|
|
821
|
+
/** State parameter */
|
|
822
|
+
state: string;
|
|
823
|
+
}
|
|
824
|
+
/**
|
|
825
|
+
* Callback processing started
|
|
826
|
+
*/
|
|
827
|
+
interface AuthCallbackProcessingEvent extends BaseEventPayload {
|
|
828
|
+
/** State parameter being processed */
|
|
829
|
+
state: string;
|
|
830
|
+
}
|
|
831
|
+
/**
|
|
832
|
+
* Callback processing complete
|
|
833
|
+
*/
|
|
834
|
+
interface AuthCallbackCompleteEvent extends BaseEventPayload {
|
|
835
|
+
/** Whether authentication was successful */
|
|
836
|
+
success: boolean;
|
|
837
|
+
}
|
|
838
|
+
/**
|
|
839
|
+
* Login complete
|
|
840
|
+
*/
|
|
841
|
+
interface AuthLoginCompleteEvent extends BaseEventPayload {
|
|
842
|
+
/** Authentication method used */
|
|
843
|
+
method: 'redirect' | 'popup' | 'silent' | 'passkey' | 'email_code' | 'social';
|
|
844
|
+
/** User info (if available) */
|
|
845
|
+
user?: UserInfo;
|
|
846
|
+
}
|
|
847
|
+
/**
|
|
848
|
+
* Logout complete
|
|
849
|
+
*/
|
|
850
|
+
interface AuthLogoutCompleteEvent extends BaseEventPayload {
|
|
851
|
+
/** Logout method */
|
|
852
|
+
method: 'local' | 'redirect' | 'front_channel' | 'back_channel';
|
|
853
|
+
}
|
|
854
|
+
/**
|
|
855
|
+
* Re-authentication required
|
|
856
|
+
*/
|
|
857
|
+
interface AuthRequiredEvent extends BaseEventPayload {
|
|
858
|
+
/** Reason for re-authentication */
|
|
859
|
+
reason: 'refresh_failed' | 'session_expired' | 'token_revoked' | 'user_action';
|
|
860
|
+
}
|
|
861
|
+
/**
|
|
862
|
+
* Popup blocked by browser (Web SDK only)
|
|
863
|
+
*/
|
|
864
|
+
interface AuthPopupBlockedEvent extends BaseEventPayload {
|
|
865
|
+
/** Intended popup URL */
|
|
866
|
+
url?: string;
|
|
684
867
|
}
|
|
685
868
|
/**
|
|
686
|
-
*
|
|
869
|
+
* Flow fallback occurred (e.g., popup → redirect)
|
|
687
870
|
*/
|
|
688
|
-
interface
|
|
871
|
+
interface AuthFallbackEvent extends BaseEventPayload {
|
|
872
|
+
/** Original flow */
|
|
873
|
+
from: 'popup' | 'silent' | 'iframe';
|
|
874
|
+
/** Fallback flow */
|
|
875
|
+
to: 'redirect';
|
|
876
|
+
/** Reason for fallback */
|
|
877
|
+
reason: 'popup_blocked' | 'iframe_timeout' | 'silent_failed';
|
|
878
|
+
}
|
|
879
|
+
/**
|
|
880
|
+
* Token refresh starting
|
|
881
|
+
*/
|
|
882
|
+
interface TokenRefreshingEvent extends BaseEventPayload {
|
|
883
|
+
/** Reason for refresh */
|
|
884
|
+
reason: 'expiring' | 'manual' | 'on_demand' | 'background';
|
|
885
|
+
}
|
|
886
|
+
/**
|
|
887
|
+
* Token refresh succeeded
|
|
888
|
+
*/
|
|
889
|
+
interface TokenRefreshedEvent extends BaseEventPayload {
|
|
890
|
+
/** Whether access token is present */
|
|
891
|
+
hasAccessToken: boolean;
|
|
892
|
+
/** Whether refresh token is present */
|
|
893
|
+
hasRefreshToken: boolean;
|
|
894
|
+
/** Whether ID token is present */
|
|
895
|
+
hasIdToken: boolean;
|
|
896
|
+
/** Token expiration timestamp (epoch seconds) */
|
|
897
|
+
expiresAt: number;
|
|
898
|
+
}
|
|
899
|
+
/**
|
|
900
|
+
* Token refresh failed
|
|
901
|
+
*/
|
|
902
|
+
interface TokenRefreshFailedEvent extends BaseEventPayload {
|
|
903
|
+
/** Error that caused the failure */
|
|
689
904
|
error: AuthrimError;
|
|
905
|
+
/** Whether retry is possible */
|
|
906
|
+
willRetry: boolean;
|
|
907
|
+
/** Retry attempt number (0 = first attempt) */
|
|
908
|
+
attempt: number;
|
|
690
909
|
}
|
|
691
910
|
/**
|
|
692
|
-
* Token
|
|
911
|
+
* Token expiring soon (warning)
|
|
693
912
|
*/
|
|
694
|
-
interface
|
|
695
|
-
|
|
696
|
-
|
|
913
|
+
interface TokenExpiringEvent extends BaseEventPayload {
|
|
914
|
+
/** Token expiration timestamp (epoch seconds) */
|
|
915
|
+
expiresAt: number;
|
|
916
|
+
/** Remaining time in seconds */
|
|
917
|
+
expiresIn: number;
|
|
918
|
+
}
|
|
919
|
+
/**
|
|
920
|
+
* Token expired
|
|
921
|
+
*/
|
|
922
|
+
interface TokenExpiredEvent extends BaseEventPayload {
|
|
923
|
+
/** Token expiration timestamp (epoch seconds) */
|
|
924
|
+
expiredAt: number;
|
|
925
|
+
/** Whether refresh token is available */
|
|
926
|
+
hasRefreshToken: boolean;
|
|
927
|
+
}
|
|
928
|
+
/**
|
|
929
|
+
* Token error
|
|
930
|
+
*/
|
|
931
|
+
interface TokenErrorEvent extends BaseEventPayload {
|
|
932
|
+
/** Error details */
|
|
933
|
+
error: AuthrimError;
|
|
934
|
+
/** Operation context */
|
|
935
|
+
context: 'refresh' | 'exchange' | 'validation' | 'storage';
|
|
936
|
+
}
|
|
937
|
+
/**
|
|
938
|
+
* Token exchanged (RFC 8693)
|
|
939
|
+
*/
|
|
940
|
+
interface TokenExchangedEvent extends BaseEventPayload {
|
|
941
|
+
/** Whether new access token is present */
|
|
942
|
+
hasAccessToken: boolean;
|
|
943
|
+
/** Whether new refresh token is present */
|
|
944
|
+
hasRefreshToken: boolean;
|
|
945
|
+
/** Issued token type URI */
|
|
697
946
|
issuedTokenType: TokenTypeUri | string;
|
|
698
947
|
}
|
|
699
948
|
/**
|
|
700
|
-
* Session started
|
|
949
|
+
* Session started
|
|
701
950
|
*/
|
|
702
|
-
interface SessionStartedEvent {
|
|
951
|
+
interface SessionStartedEvent extends BaseEventPayload {
|
|
952
|
+
/** User info */
|
|
703
953
|
user: UserInfo;
|
|
704
954
|
}
|
|
705
955
|
/**
|
|
706
|
-
* Session ended
|
|
956
|
+
* Session ended
|
|
707
957
|
*/
|
|
708
|
-
interface SessionEndedEvent {
|
|
958
|
+
interface SessionEndedEvent extends BaseEventPayload {
|
|
959
|
+
/** Reason for session end */
|
|
709
960
|
reason: 'logout' | 'expired' | 'revoked';
|
|
710
961
|
}
|
|
711
962
|
/**
|
|
712
|
-
*
|
|
963
|
+
* Session changed (general)
|
|
713
964
|
*/
|
|
714
|
-
interface
|
|
715
|
-
|
|
965
|
+
interface SessionChangedEvent extends BaseEventPayload {
|
|
966
|
+
/** Whether user is authenticated */
|
|
967
|
+
isAuthenticated: boolean;
|
|
968
|
+
/** User info (if authenticated) */
|
|
969
|
+
user?: UserInfo;
|
|
716
970
|
}
|
|
717
971
|
/**
|
|
718
|
-
*
|
|
972
|
+
* Tab synchronization event (Web SDK only)
|
|
719
973
|
*/
|
|
720
|
-
interface
|
|
721
|
-
|
|
722
|
-
|
|
974
|
+
interface SessionSyncEvent extends BaseEventPayload {
|
|
975
|
+
/** Sync action */
|
|
976
|
+
action: 'login' | 'logout' | 'refresh' | 'leader_change';
|
|
977
|
+
/** Source tab ID */
|
|
978
|
+
sourceTabId?: string;
|
|
979
|
+
}
|
|
980
|
+
/**
|
|
981
|
+
* Logout broadcast from another tab (Web SDK only)
|
|
982
|
+
*/
|
|
983
|
+
interface SessionLogoutBroadcastEvent extends BaseEventPayload {
|
|
984
|
+
/** Source tab ID */
|
|
985
|
+
sourceTabId?: string;
|
|
723
986
|
}
|
|
724
987
|
/**
|
|
725
|
-
*
|
|
988
|
+
* Auth state type
|
|
989
|
+
*/
|
|
990
|
+
type AuthState$1 = 'idle' | 'initializing' | 'authenticated' | 'unauthenticated' | 'authenticating' | 'refreshing' | 'logging_out' | 'error';
|
|
991
|
+
/**
|
|
992
|
+
* Auth state snapshot
|
|
993
|
+
*/
|
|
994
|
+
interface AuthStateSnapshot {
|
|
995
|
+
/** Current state */
|
|
996
|
+
state: AuthState$1;
|
|
997
|
+
/** Previous state */
|
|
998
|
+
previousState: AuthState$1 | null;
|
|
999
|
+
/** Snapshot timestamp */
|
|
1000
|
+
timestamp: number;
|
|
1001
|
+
/** Current operation ID */
|
|
1002
|
+
operationId: string | null;
|
|
1003
|
+
/** State context */
|
|
1004
|
+
context: {
|
|
1005
|
+
/** Whether user is authenticated */
|
|
1006
|
+
isAuthenticated: boolean;
|
|
1007
|
+
/** Token expiration timestamp (epoch seconds) */
|
|
1008
|
+
tokenExpiresAt: number | null;
|
|
1009
|
+
/** Last error */
|
|
1010
|
+
lastError: AuthrimError | null;
|
|
1011
|
+
/** Pending operation description */
|
|
1012
|
+
pendingOperation: string | null;
|
|
1013
|
+
};
|
|
1014
|
+
}
|
|
1015
|
+
/**
|
|
1016
|
+
* State change event
|
|
1017
|
+
*/
|
|
1018
|
+
interface StateChangeEvent extends BaseEventPayload {
|
|
1019
|
+
/** Previous state */
|
|
1020
|
+
from: AuthState$1;
|
|
1021
|
+
/** New state */
|
|
1022
|
+
to: AuthState$1;
|
|
1023
|
+
/** Full state snapshot */
|
|
1024
|
+
snapshot: AuthStateSnapshot;
|
|
1025
|
+
}
|
|
1026
|
+
/**
|
|
1027
|
+
* Error severity for event classification
|
|
1028
|
+
*/
|
|
1029
|
+
type ErrorSeverity = 'recoverable' | 'fatal';
|
|
1030
|
+
/**
|
|
1031
|
+
* Error event payload (extended)
|
|
1032
|
+
*/
|
|
1033
|
+
interface ErrorEventPayload extends BaseEventPayload {
|
|
1034
|
+
/** Error instance */
|
|
1035
|
+
error: AuthrimError;
|
|
1036
|
+
/** Error severity */
|
|
1037
|
+
severity: ErrorSeverity;
|
|
1038
|
+
/** Recommended remediation */
|
|
1039
|
+
remediation: AuthrimErrorRemediation;
|
|
1040
|
+
/** Operation context where error occurred */
|
|
1041
|
+
context: string;
|
|
1042
|
+
}
|
|
1043
|
+
/**
|
|
1044
|
+
* Legacy error event (backward compatibility)
|
|
726
1045
|
*/
|
|
727
1046
|
interface ErrorEvent {
|
|
728
1047
|
error: AuthrimError;
|
|
729
1048
|
context: string;
|
|
730
1049
|
}
|
|
1050
|
+
/**
|
|
1051
|
+
* Recoverable error event
|
|
1052
|
+
*/
|
|
1053
|
+
interface ErrorRecoverableEvent extends ErrorEventPayload {
|
|
1054
|
+
severity: 'recoverable';
|
|
1055
|
+
}
|
|
1056
|
+
/**
|
|
1057
|
+
* Fatal error event
|
|
1058
|
+
*/
|
|
1059
|
+
interface ErrorFatalEvent extends ErrorEventPayload {
|
|
1060
|
+
severity: 'fatal';
|
|
1061
|
+
}
|
|
1062
|
+
/**
|
|
1063
|
+
* ITP environment detected warning (Web SDK only)
|
|
1064
|
+
*/
|
|
1065
|
+
interface WarningITPEvent extends BaseEventPayload {
|
|
1066
|
+
/** Warning message */
|
|
1067
|
+
message: string;
|
|
1068
|
+
/** Detected browser */
|
|
1069
|
+
browser: 'safari' | 'webkit' | 'unknown';
|
|
1070
|
+
/** Recommended action */
|
|
1071
|
+
recommendation: 'use_redirect' | 'use_popup' | 'normal';
|
|
1072
|
+
}
|
|
1073
|
+
/**
|
|
1074
|
+
* Storage fallback warning
|
|
1075
|
+
*
|
|
1076
|
+
* Fired when:
|
|
1077
|
+
* - localStorage → sessionStorage fallback
|
|
1078
|
+
* - sessionStorage → memory fallback
|
|
1079
|
+
*/
|
|
1080
|
+
interface WarningStorageFallbackEvent extends BaseEventPayload {
|
|
1081
|
+
/** Original storage type */
|
|
1082
|
+
from: 'localStorage' | 'sessionStorage';
|
|
1083
|
+
/** Fallback storage type */
|
|
1084
|
+
to: 'sessionStorage' | 'memory';
|
|
1085
|
+
/** Reason for fallback */
|
|
1086
|
+
reason: 'not_available' | 'quota_exceeded' | 'private_mode' | 'security_error';
|
|
1087
|
+
}
|
|
1088
|
+
/**
|
|
1089
|
+
* Private browsing mode detected warning (Web SDK only)
|
|
1090
|
+
*/
|
|
1091
|
+
interface WarningPrivateModeEvent extends BaseEventPayload {
|
|
1092
|
+
/** Detected browser */
|
|
1093
|
+
browser: 'safari' | 'firefox' | 'chrome' | 'edge' | 'unknown';
|
|
1094
|
+
/** Storage limitations */
|
|
1095
|
+
limitations: string[];
|
|
1096
|
+
}
|
|
1097
|
+
/**
|
|
1098
|
+
* Timeline event entry
|
|
1099
|
+
*/
|
|
1100
|
+
interface TimelineEntry {
|
|
1101
|
+
/** Event type */
|
|
1102
|
+
type: string;
|
|
1103
|
+
/** Event timestamp */
|
|
1104
|
+
timestamp: number;
|
|
1105
|
+
/** Operation ID */
|
|
1106
|
+
operationId?: string;
|
|
1107
|
+
/** Redacted event data */
|
|
1108
|
+
data?: Record<string, unknown>;
|
|
1109
|
+
}
|
|
1110
|
+
/**
|
|
1111
|
+
* Debug timeline event
|
|
1112
|
+
*/
|
|
1113
|
+
interface DebugTimelineEvent extends BaseEventPayload {
|
|
1114
|
+
/** Timeline entry */
|
|
1115
|
+
entry: TimelineEntry;
|
|
1116
|
+
}
|
|
731
1117
|
/**
|
|
732
1118
|
* All Authrim events
|
|
733
1119
|
*/
|
|
734
1120
|
interface AuthrimEvents {
|
|
1121
|
+
'auth:init': AuthInitEvent;
|
|
1122
|
+
'auth:redirecting': AuthRedirectingEvent;
|
|
1123
|
+
'auth:callback': AuthCallbackEvent;
|
|
1124
|
+
'auth:callback:processing': AuthCallbackProcessingEvent;
|
|
1125
|
+
'auth:callback:complete': AuthCallbackCompleteEvent;
|
|
1126
|
+
'auth:login:complete': AuthLoginCompleteEvent;
|
|
1127
|
+
'auth:logout:complete': AuthLogoutCompleteEvent;
|
|
1128
|
+
'auth:required': AuthRequiredEvent;
|
|
1129
|
+
'auth:popup_blocked': AuthPopupBlockedEvent;
|
|
1130
|
+
'auth:fallback': AuthFallbackEvent;
|
|
1131
|
+
'token:refreshing': TokenRefreshingEvent;
|
|
735
1132
|
'token:refreshed': TokenRefreshedEvent;
|
|
1133
|
+
'token:refresh:failed': TokenRefreshFailedEvent;
|
|
1134
|
+
'token:expiring': TokenExpiringEvent;
|
|
736
1135
|
'token:expired': TokenExpiredEvent;
|
|
737
1136
|
'token:error': TokenErrorEvent;
|
|
738
1137
|
'token:exchanged': TokenExchangedEvent;
|
|
739
1138
|
'session:started': SessionStartedEvent;
|
|
740
1139
|
'session:ended': SessionEndedEvent;
|
|
741
|
-
'
|
|
742
|
-
'
|
|
743
|
-
|
|
1140
|
+
'session:changed': SessionChangedEvent;
|
|
1141
|
+
'session:sync': SessionSyncEvent;
|
|
1142
|
+
'session:logout:broadcast': SessionLogoutBroadcastEvent;
|
|
1143
|
+
'state:change': StateChangeEvent;
|
|
1144
|
+
'error': ErrorEvent;
|
|
1145
|
+
'error:recoverable': ErrorRecoverableEvent;
|
|
1146
|
+
'error:fatal': ErrorFatalEvent;
|
|
1147
|
+
'warning:itp': WarningITPEvent;
|
|
1148
|
+
'warning:storage_fallback': WarningStorageFallbackEvent;
|
|
1149
|
+
'warning:private_mode': WarningPrivateModeEvent;
|
|
1150
|
+
'debug:timeline': DebugTimelineEvent;
|
|
744
1151
|
}
|
|
745
1152
|
/**
|
|
746
1153
|
* Event names
|
|
@@ -750,136 +1157,434 @@ type AuthrimEventName = keyof AuthrimEvents;
|
|
|
750
1157
|
* Event handler type
|
|
751
1158
|
*/
|
|
752
1159
|
type AuthrimEventHandler<T extends AuthrimEventName> = (event: AuthrimEvents[T]) => void;
|
|
753
|
-
|
|
754
1160
|
/**
|
|
755
|
-
*
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
1161
|
+
* Events emitted by Core SDK
|
|
1162
|
+
*/
|
|
1163
|
+
type CoreEventName = 'auth:init' | 'auth:redirecting' | 'auth:callback' | 'auth:callback:processing' | 'auth:callback:complete' | 'auth:login:complete' | 'auth:logout:complete' | 'auth:required' | 'token:refreshing' | 'token:refreshed' | 'token:refresh:failed' | 'token:expiring' | 'token:expired' | 'token:error' | 'token:exchanged' | 'session:started' | 'session:ended' | 'session:changed' | 'state:change' | 'error' | 'error:recoverable' | 'error:fatal' | 'debug:timeline';
|
|
1164
|
+
/**
|
|
1165
|
+
* Events emitted by Web SDK only
|
|
759
1166
|
*/
|
|
1167
|
+
type WebOnlyEventName = 'auth:popup_blocked' | 'auth:fallback' | 'session:sync' | 'session:logout:broadcast' | 'warning:itp' | 'warning:storage_fallback' | 'warning:private_mode';
|
|
760
1168
|
|
|
761
1169
|
/**
|
|
762
|
-
*
|
|
1170
|
+
* Device Authorization Flow Types
|
|
1171
|
+
* RFC 8628: OAuth 2.0 Device Authorization Grant
|
|
1172
|
+
*
|
|
1173
|
+
* Used for devices with limited input capabilities (TVs, CLI tools, IoT devices).
|
|
763
1174
|
*/
|
|
764
|
-
interface AuthState {
|
|
765
|
-
/** State parameter (CSRF protection) */
|
|
766
|
-
state: string;
|
|
767
|
-
/** Nonce parameter (replay attack prevention) */
|
|
768
|
-
nonce: string;
|
|
769
|
-
/** PKCE code verifier */
|
|
770
|
-
codeVerifier: string;
|
|
771
|
-
/** Redirect URI used for this auth request */
|
|
772
|
-
redirectUri: string;
|
|
773
|
-
/** Timestamp when state was created */
|
|
774
|
-
createdAt: number;
|
|
775
|
-
/** Timestamp when state expires */
|
|
776
|
-
expiresAt: number;
|
|
777
|
-
}
|
|
778
1175
|
/**
|
|
779
|
-
*
|
|
1176
|
+
* Device authorization response from the server (RFC 8628 §3.2)
|
|
780
1177
|
*/
|
|
781
|
-
interface
|
|
782
|
-
/**
|
|
783
|
-
|
|
784
|
-
/**
|
|
785
|
-
|
|
786
|
-
/**
|
|
787
|
-
|
|
1178
|
+
interface DeviceAuthorizationResponse {
|
|
1179
|
+
/** Device verification code (for token requests) */
|
|
1180
|
+
device_code: string;
|
|
1181
|
+
/** User-facing code to enter at verification_uri */
|
|
1182
|
+
user_code: string;
|
|
1183
|
+
/** URI where the user should go to enter the code */
|
|
1184
|
+
verification_uri: string;
|
|
1185
|
+
/** Complete URI with user_code embedded (optional) */
|
|
1186
|
+
verification_uri_complete?: string;
|
|
1187
|
+
/** Lifetime of device_code and user_code in seconds */
|
|
1188
|
+
expires_in: number;
|
|
1189
|
+
/** Minimum polling interval in seconds (default: 5) */
|
|
1190
|
+
interval?: number;
|
|
788
1191
|
}
|
|
789
1192
|
/**
|
|
790
|
-
*
|
|
791
|
-
*/
|
|
792
|
-
|
|
793
|
-
/**
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
/**
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
/**
|
|
802
|
-
|
|
803
|
-
*/
|
|
804
|
-
readonly idToken: (issuerHash: string, clientIdHash: string) => string;
|
|
1193
|
+
* Device flow state maintained by the client
|
|
1194
|
+
*/
|
|
1195
|
+
interface DeviceFlowState {
|
|
1196
|
+
/** Device code (used for polling) */
|
|
1197
|
+
deviceCode: string;
|
|
1198
|
+
/** User code (displayed to user) */
|
|
1199
|
+
userCode: string;
|
|
1200
|
+
/** Verification URI (user goes here) */
|
|
1201
|
+
verificationUri: string;
|
|
1202
|
+
/** Complete verification URI with code (if provided) */
|
|
1203
|
+
verificationUriComplete?: string;
|
|
1204
|
+
/** Absolute expiration time (epoch seconds) */
|
|
1205
|
+
expiresAt: number;
|
|
805
1206
|
/**
|
|
806
|
-
*
|
|
1207
|
+
* Polling interval in seconds (RFC 8628)
|
|
1208
|
+
*
|
|
1209
|
+
* IMPORTANT: This value is in SECONDS, not milliseconds.
|
|
1210
|
+
* When using with setTimeout, multiply by 1000.
|
|
807
1211
|
*/
|
|
808
|
-
|
|
809
|
-
}
|
|
1212
|
+
interval: number;
|
|
1213
|
+
}
|
|
810
1214
|
/**
|
|
811
|
-
*
|
|
1215
|
+
* Poll result from Device Flow
|
|
1216
|
+
*
|
|
1217
|
+
* Core SDK returns "facts" only - UX events are the responsibility
|
|
1218
|
+
* of upper-layer SDKs (web/react/svelte).
|
|
812
1219
|
*/
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
private static readonly DEFAULT_TTL_SECONDS;
|
|
820
|
-
/** Entropy bytes for state/nonce generation (256 bits = 32 bytes) */
|
|
821
|
-
private static readonly ENTROPY_BYTES;
|
|
822
|
-
constructor(crypto: CryptoProvider, storage: AuthrimStorage, issuerHash: string, clientIdHash: string);
|
|
823
|
-
/**
|
|
824
|
-
* Generate and store auth state
|
|
825
|
-
*
|
|
826
|
-
* Creates state, nonce, stores them with the code verifier.
|
|
827
|
-
*
|
|
828
|
-
* @param options - Generation options
|
|
829
|
-
* @returns Generated state string
|
|
830
|
-
*/
|
|
831
|
-
generateAuthState(options: GenerateAuthStateOptions): Promise<AuthState>;
|
|
1220
|
+
type DeviceFlowPollResult = DeviceFlowPendingResult | DeviceFlowCompletedResult | DeviceFlowSlowDownResult | DeviceFlowExpiredResult | DeviceFlowAccessDeniedResult;
|
|
1221
|
+
/**
|
|
1222
|
+
* Authorization pending - user hasn't completed auth yet
|
|
1223
|
+
*/
|
|
1224
|
+
interface DeviceFlowPendingResult {
|
|
1225
|
+
status: 'pending';
|
|
832
1226
|
/**
|
|
833
|
-
*
|
|
834
|
-
*
|
|
835
|
-
* Retrieves, validates, and ALWAYS deletes the state (success or failure).
|
|
836
|
-
* This ensures replay attack prevention and GC.
|
|
1227
|
+
* Seconds until next poll attempt (RFC 8628)
|
|
837
1228
|
*
|
|
838
|
-
*
|
|
839
|
-
*
|
|
840
|
-
* @throws AuthrimError if state is invalid or expired
|
|
1229
|
+
* IMPORTANT: This value is in SECONDS.
|
|
1230
|
+
* Use `retryAfter * 1000` for setTimeout in JavaScript.
|
|
841
1231
|
*/
|
|
842
|
-
|
|
1232
|
+
retryAfter: number;
|
|
1233
|
+
}
|
|
1234
|
+
/**
|
|
1235
|
+
* Authorization completed - tokens received
|
|
1236
|
+
*/
|
|
1237
|
+
interface DeviceFlowCompletedResult {
|
|
1238
|
+
status: 'completed';
|
|
1239
|
+
/** Received tokens */
|
|
1240
|
+
tokens: TokenSet;
|
|
1241
|
+
}
|
|
1242
|
+
/**
|
|
1243
|
+
* Slow down - polling too fast
|
|
1244
|
+
*/
|
|
1245
|
+
interface DeviceFlowSlowDownResult {
|
|
1246
|
+
status: 'slow_down';
|
|
843
1247
|
/**
|
|
844
|
-
*
|
|
845
|
-
*
|
|
846
|
-
* This is a best-effort cleanup. Only works if storage.getAll() is available.
|
|
847
|
-
* The primary GC mechanism is validateAndConsumeState()'s finally delete.
|
|
1248
|
+
* New interval in seconds (server-specified)
|
|
848
1249
|
*
|
|
849
|
-
*
|
|
1250
|
+
* IMPORTANT: This value is in SECONDS.
|
|
1251
|
+
* The polling interval should be increased to this value.
|
|
850
1252
|
*/
|
|
851
|
-
|
|
1253
|
+
retryAfter: number;
|
|
852
1254
|
}
|
|
853
|
-
|
|
854
1255
|
/**
|
|
855
|
-
*
|
|
856
|
-
*
|
|
857
|
-
* Implements RFC 7636 for Authorization Code Flow security.
|
|
858
|
-
* https://tools.ietf.org/html/rfc7636
|
|
1256
|
+
* Device code expired - user needs to start over
|
|
859
1257
|
*/
|
|
860
|
-
|
|
1258
|
+
interface DeviceFlowExpiredResult {
|
|
1259
|
+
status: 'expired';
|
|
1260
|
+
}
|
|
861
1261
|
/**
|
|
862
|
-
*
|
|
1262
|
+
* Access denied - user denied the authorization request
|
|
863
1263
|
*/
|
|
864
|
-
|
|
1264
|
+
interface DeviceFlowAccessDeniedResult {
|
|
1265
|
+
status: 'access_denied';
|
|
1266
|
+
}
|
|
865
1267
|
/**
|
|
866
|
-
*
|
|
1268
|
+
* Options for starting device authorization
|
|
867
1269
|
*/
|
|
868
|
-
interface
|
|
869
|
-
/**
|
|
870
|
-
|
|
871
|
-
/**
|
|
872
|
-
|
|
873
|
-
/** Challenge method used */
|
|
874
|
-
codeChallengeMethod: CodeChallengeMethod;
|
|
1270
|
+
interface DeviceFlowStartOptions {
|
|
1271
|
+
/** Scopes to request */
|
|
1272
|
+
scope?: string;
|
|
1273
|
+
/** Additional parameters */
|
|
1274
|
+
extraParams?: Record<string, string>;
|
|
875
1275
|
}
|
|
1276
|
+
|
|
876
1277
|
/**
|
|
877
|
-
*
|
|
1278
|
+
* PAR (Pushed Authorization Request) Types
|
|
1279
|
+
* RFC 9126: OAuth 2.0 Pushed Authorization Requests
|
|
878
1280
|
*/
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
1281
|
+
/**
|
|
1282
|
+
* PAR request parameters
|
|
1283
|
+
*/
|
|
1284
|
+
interface PARRequest {
|
|
1285
|
+
/** Redirect URI (required) */
|
|
1286
|
+
redirectUri: string;
|
|
1287
|
+
/** Scopes to request (default: 'openid profile') */
|
|
1288
|
+
scope?: string;
|
|
1289
|
+
/**
|
|
1290
|
+
* Response type (default: 'code')
|
|
1291
|
+
*
|
|
1292
|
+
* Use 'none' for session check without token issuance
|
|
1293
|
+
* (OAuth 2.0 Multiple Response Types 1.0 §5)
|
|
1294
|
+
*/
|
|
1295
|
+
responseType?: 'code' | 'none';
|
|
1296
|
+
/** State parameter for CSRF protection */
|
|
1297
|
+
state: string;
|
|
1298
|
+
/** Nonce for replay attack prevention */
|
|
1299
|
+
nonce: string;
|
|
1300
|
+
/** PKCE code challenge */
|
|
1301
|
+
codeChallenge: string;
|
|
1302
|
+
/** PKCE code challenge method (always S256) */
|
|
1303
|
+
codeChallengeMethod: 'S256';
|
|
1304
|
+
/** Prompt behavior */
|
|
1305
|
+
prompt?: 'none' | 'login' | 'consent' | 'select_account';
|
|
1306
|
+
/** Hint about the login identifier */
|
|
1307
|
+
loginHint?: string;
|
|
1308
|
+
/** Requested Authentication Context Class Reference values */
|
|
1309
|
+
acrValues?: string;
|
|
1310
|
+
/** Additional custom parameters */
|
|
1311
|
+
extraParams?: Record<string, string>;
|
|
1312
|
+
}
|
|
1313
|
+
/**
|
|
1314
|
+
* PAR response from the server (RFC 9126 §2.2)
|
|
1315
|
+
*/
|
|
1316
|
+
interface PARResponse {
|
|
1317
|
+
/** The request URI to use in authorization request */
|
|
1318
|
+
request_uri: string;
|
|
1319
|
+
/** Lifetime of the request URI in seconds */
|
|
1320
|
+
expires_in: number;
|
|
1321
|
+
}
|
|
1322
|
+
/**
|
|
1323
|
+
* PAR result returned by PARClient
|
|
1324
|
+
*/
|
|
1325
|
+
interface PARResult {
|
|
1326
|
+
/** The request URI to use in authorization request */
|
|
1327
|
+
requestUri: string;
|
|
1328
|
+
/** Absolute expiration time (epoch seconds) */
|
|
1329
|
+
expiresAt: number;
|
|
1330
|
+
}
|
|
1331
|
+
/**
|
|
1332
|
+
* Options for PAR client
|
|
1333
|
+
*/
|
|
1334
|
+
interface PARClientOptions {
|
|
1335
|
+
/** Additional headers to include in PAR request */
|
|
1336
|
+
headers?: Record<string, string>;
|
|
1337
|
+
}
|
|
1338
|
+
|
|
1339
|
+
/**
|
|
1340
|
+
* Event Emitter
|
|
1341
|
+
*
|
|
1342
|
+
* Simple typed event emitter for SDK events.
|
|
1343
|
+
*/
|
|
1344
|
+
|
|
1345
|
+
/**
|
|
1346
|
+
* Typed Event Emitter
|
|
1347
|
+
*/
|
|
1348
|
+
declare class EventEmitter {
|
|
1349
|
+
private listeners;
|
|
1350
|
+
/**
|
|
1351
|
+
* Subscribe to an event
|
|
1352
|
+
*
|
|
1353
|
+
* @param event - Event name
|
|
1354
|
+
* @param handler - Event handler
|
|
1355
|
+
* @returns Unsubscribe function
|
|
1356
|
+
*/
|
|
1357
|
+
on<T extends AuthrimEventName>(event: T, handler: AuthrimEventHandler<T>): () => void;
|
|
1358
|
+
/**
|
|
1359
|
+
* Subscribe to an event (one-time)
|
|
1360
|
+
*
|
|
1361
|
+
* @param event - Event name
|
|
1362
|
+
* @param handler - Event handler
|
|
1363
|
+
* @returns Unsubscribe function
|
|
1364
|
+
*/
|
|
1365
|
+
once<T extends AuthrimEventName>(event: T, handler: AuthrimEventHandler<T>): () => void;
|
|
1366
|
+
/**
|
|
1367
|
+
* Unsubscribe from an event
|
|
1368
|
+
*
|
|
1369
|
+
* @param event - Event name
|
|
1370
|
+
* @param handler - Event handler to remove
|
|
1371
|
+
*/
|
|
1372
|
+
off<T extends AuthrimEventName>(event: T, handler: AuthrimEventHandler<T>): void;
|
|
1373
|
+
/**
|
|
1374
|
+
* Emit an event
|
|
1375
|
+
*
|
|
1376
|
+
* @param event - Event name
|
|
1377
|
+
* @param data - Event data
|
|
1378
|
+
*/
|
|
1379
|
+
emit<T extends AuthrimEventName>(event: T, data: AuthrimEvents[T]): void;
|
|
1380
|
+
/**
|
|
1381
|
+
* Remove all listeners for an event (or all events)
|
|
1382
|
+
*
|
|
1383
|
+
* @param event - Event name (optional, removes all if not specified)
|
|
1384
|
+
*/
|
|
1385
|
+
removeAllListeners(event?: AuthrimEventName): void;
|
|
1386
|
+
/**
|
|
1387
|
+
* Get the number of listeners for an event
|
|
1388
|
+
*
|
|
1389
|
+
* @param event - Event name
|
|
1390
|
+
* @returns Number of listeners
|
|
1391
|
+
*/
|
|
1392
|
+
listenerCount(event: AuthrimEventName): number;
|
|
1393
|
+
}
|
|
1394
|
+
|
|
1395
|
+
/**
|
|
1396
|
+
* State/Nonce Manager
|
|
1397
|
+
*
|
|
1398
|
+
* Manages CSRF protection (state) and replay attack prevention (nonce)
|
|
1399
|
+
* for Authorization Code Flow.
|
|
1400
|
+
*/
|
|
1401
|
+
|
|
1402
|
+
/**
|
|
1403
|
+
* Auth state stored in storage
|
|
1404
|
+
*/
|
|
1405
|
+
interface AuthState {
|
|
1406
|
+
/** State parameter (CSRF protection) */
|
|
1407
|
+
state: string;
|
|
1408
|
+
/** Nonce parameter (replay attack prevention) */
|
|
1409
|
+
nonce: string;
|
|
1410
|
+
/** PKCE code verifier */
|
|
1411
|
+
codeVerifier: string;
|
|
1412
|
+
/** Redirect URI used for this auth request */
|
|
1413
|
+
redirectUri: string;
|
|
1414
|
+
/** Requested scope (for validation) */
|
|
1415
|
+
scope: string;
|
|
1416
|
+
/** Timestamp when state was created */
|
|
1417
|
+
createdAt: number;
|
|
1418
|
+
/** Timestamp when state expires */
|
|
1419
|
+
expiresAt: number;
|
|
1420
|
+
/** Return URL after authentication (validated) */
|
|
1421
|
+
returnTo?: string;
|
|
1422
|
+
/** Operation tracking ID (for event correlation) */
|
|
1423
|
+
operationId: string;
|
|
1424
|
+
}
|
|
1425
|
+
/**
|
|
1426
|
+
* ReturnTo URL policy
|
|
1427
|
+
*
|
|
1428
|
+
* Controls which returnTo URLs are accepted to prevent open redirect attacks.
|
|
1429
|
+
*/
|
|
1430
|
+
type ReturnToPolicy = 'relative_only' | 'same_origin' | 'allowlist';
|
|
1431
|
+
/**
|
|
1432
|
+
* ReturnTo URL options
|
|
1433
|
+
*/
|
|
1434
|
+
interface ReturnToOptions {
|
|
1435
|
+
/** Validation policy */
|
|
1436
|
+
policy: ReturnToPolicy;
|
|
1437
|
+
/** Allowed origins (required when policy is 'allowlist') */
|
|
1438
|
+
allowedOrigins?: string[];
|
|
1439
|
+
/** Current origin for same_origin check (required in non-browser environments) */
|
|
1440
|
+
currentOrigin?: string;
|
|
1441
|
+
}
|
|
1442
|
+
/**
|
|
1443
|
+
* Options for generating auth state
|
|
1444
|
+
*/
|
|
1445
|
+
interface GenerateAuthStateOptions {
|
|
1446
|
+
/** Redirect URI for this auth request */
|
|
1447
|
+
redirectUri: string;
|
|
1448
|
+
/** Code verifier for PKCE */
|
|
1449
|
+
codeVerifier: string;
|
|
1450
|
+
/** Requested scope (for validation) */
|
|
1451
|
+
scope: string;
|
|
1452
|
+
/** TTL in seconds (default: 600 = 10 minutes) */
|
|
1453
|
+
ttlSeconds?: number;
|
|
1454
|
+
/** Return URL after authentication */
|
|
1455
|
+
returnTo?: string;
|
|
1456
|
+
/** ReturnTo URL validation options */
|
|
1457
|
+
returnToOptions?: ReturnToOptions;
|
|
1458
|
+
}
|
|
1459
|
+
/**
|
|
1460
|
+
* Storage keys factory
|
|
1461
|
+
*/
|
|
1462
|
+
declare const STORAGE_KEYS: {
|
|
1463
|
+
/**
|
|
1464
|
+
* Auth state key (state-specific)
|
|
1465
|
+
*/
|
|
1466
|
+
readonly authState: (issuerHash: string, clientIdHash: string, state: string) => string;
|
|
1467
|
+
/**
|
|
1468
|
+
* Token storage key
|
|
1469
|
+
*/
|
|
1470
|
+
readonly tokens: (issuerHash: string, clientIdHash: string) => string;
|
|
1471
|
+
/**
|
|
1472
|
+
* ID token storage key
|
|
1473
|
+
*/
|
|
1474
|
+
readonly idToken: (issuerHash: string, clientIdHash: string) => string;
|
|
1475
|
+
/**
|
|
1476
|
+
* Auth state prefix for cleanup
|
|
1477
|
+
*/
|
|
1478
|
+
readonly authStatePrefix: (issuerHash: string, clientIdHash: string) => string;
|
|
1479
|
+
};
|
|
1480
|
+
/**
|
|
1481
|
+
* State Manager
|
|
1482
|
+
*/
|
|
1483
|
+
declare class StateManager {
|
|
1484
|
+
private readonly crypto;
|
|
1485
|
+
private readonly storage;
|
|
1486
|
+
private readonly issuerHash;
|
|
1487
|
+
private readonly clientIdHash;
|
|
1488
|
+
/** Default TTL: 10 minutes */
|
|
1489
|
+
private static readonly DEFAULT_TTL_SECONDS;
|
|
1490
|
+
/** Entropy bytes for state/nonce generation (256 bits = 32 bytes) */
|
|
1491
|
+
private static readonly ENTROPY_BYTES;
|
|
1492
|
+
/** Entropy bytes for operationId (128 bits = 16 bytes, enough for tracking) */
|
|
1493
|
+
private static readonly OPERATION_ID_BYTES;
|
|
1494
|
+
/** Auto cleanup interval (5 minutes) */
|
|
1495
|
+
private static readonly DEFAULT_CLEANUP_INTERVAL_MS;
|
|
1496
|
+
/** Cleanup interval handle */
|
|
1497
|
+
private cleanupInterval;
|
|
1498
|
+
constructor(crypto: CryptoProvider, storage: AuthrimStorage, issuerHash: string, clientIdHash: string);
|
|
1499
|
+
/**
|
|
1500
|
+
* Generate and store auth state
|
|
1501
|
+
*
|
|
1502
|
+
* Creates state, nonce, stores them with the code verifier.
|
|
1503
|
+
*
|
|
1504
|
+
* @param options - Generation options
|
|
1505
|
+
* @returns Generated state string
|
|
1506
|
+
*/
|
|
1507
|
+
generateAuthState(options: GenerateAuthStateOptions): Promise<AuthState>;
|
|
1508
|
+
/**
|
|
1509
|
+
* Validate returnTo URL against policy (Open Redirect Protection)
|
|
1510
|
+
*
|
|
1511
|
+
* @param returnTo - URL to validate
|
|
1512
|
+
* @param options - Validation options
|
|
1513
|
+
* @returns Validated URL
|
|
1514
|
+
* @throws AuthrimError if URL is invalid
|
|
1515
|
+
*/
|
|
1516
|
+
private validateReturnTo;
|
|
1517
|
+
/**
|
|
1518
|
+
* Validate and consume state
|
|
1519
|
+
*
|
|
1520
|
+
* Retrieves, validates, and ALWAYS deletes the state (success or failure).
|
|
1521
|
+
* This ensures replay attack prevention and GC.
|
|
1522
|
+
*
|
|
1523
|
+
* @param state - State parameter from callback
|
|
1524
|
+
* @returns Auth state if valid
|
|
1525
|
+
* @throws AuthrimError if state is invalid or expired
|
|
1526
|
+
*/
|
|
1527
|
+
validateAndConsumeState(state: string): Promise<AuthState>;
|
|
1528
|
+
/**
|
|
1529
|
+
* Clean up expired states
|
|
1530
|
+
*
|
|
1531
|
+
* This is a best-effort cleanup. Only works if storage.getAll() is available.
|
|
1532
|
+
* The primary GC mechanism is validateAndConsumeState()'s finally delete.
|
|
1533
|
+
*
|
|
1534
|
+
* Safe to call at startup or periodically.
|
|
1535
|
+
*/
|
|
1536
|
+
cleanupExpiredStates(): Promise<void>;
|
|
1537
|
+
/**
|
|
1538
|
+
* Start automatic cleanup of expired states
|
|
1539
|
+
*
|
|
1540
|
+
* Runs cleanup every 5 minutes by default.
|
|
1541
|
+
*
|
|
1542
|
+
* @param intervalMs - Cleanup interval in milliseconds (default: 300000 = 5 minutes)
|
|
1543
|
+
*/
|
|
1544
|
+
startAutoCleanup(intervalMs?: number): void;
|
|
1545
|
+
/**
|
|
1546
|
+
* Stop automatic cleanup
|
|
1547
|
+
*/
|
|
1548
|
+
stopAutoCleanup(): void;
|
|
1549
|
+
/**
|
|
1550
|
+
* Get the number of stored auth states
|
|
1551
|
+
*
|
|
1552
|
+
* Only works if storage.getAll() is available.
|
|
1553
|
+
*
|
|
1554
|
+
* @returns Number of stored states, or -1 if not supported
|
|
1555
|
+
*/
|
|
1556
|
+
getStoredStateCount(): Promise<number>;
|
|
1557
|
+
}
|
|
1558
|
+
|
|
1559
|
+
/**
|
|
1560
|
+
* PKCE (Proof Key for Code Exchange) Helper
|
|
1561
|
+
*
|
|
1562
|
+
* Implements RFC 7636 for Authorization Code Flow security.
|
|
1563
|
+
* https://tools.ietf.org/html/rfc7636
|
|
1564
|
+
*/
|
|
1565
|
+
|
|
1566
|
+
/**
|
|
1567
|
+
* PKCE challenge method
|
|
1568
|
+
*/
|
|
1569
|
+
type CodeChallengeMethod = 'S256' | 'plain';
|
|
1570
|
+
/**
|
|
1571
|
+
* PKCE pair (verifier and challenge)
|
|
1572
|
+
*/
|
|
1573
|
+
interface PKCEPair {
|
|
1574
|
+
/** Code verifier (high-entropy random string) */
|
|
1575
|
+
codeVerifier: string;
|
|
1576
|
+
/** Code challenge (derived from verifier) */
|
|
1577
|
+
codeChallenge: string;
|
|
1578
|
+
/** Challenge method used */
|
|
1579
|
+
codeChallengeMethod: CodeChallengeMethod;
|
|
1580
|
+
}
|
|
1581
|
+
/**
|
|
1582
|
+
* PKCE Helper class
|
|
1583
|
+
*/
|
|
1584
|
+
declare class PKCEHelper {
|
|
1585
|
+
private readonly crypto;
|
|
1586
|
+
constructor(crypto: CryptoProvider);
|
|
1587
|
+
/**
|
|
883
1588
|
* Generate a PKCE pair (verifier + challenge)
|
|
884
1589
|
*
|
|
885
1590
|
* Uses S256 method (SHA-256 hash, base64url-encoded).
|
|
@@ -917,6 +1622,13 @@ interface BuildAuthorizationUrlOptions {
|
|
|
917
1622
|
redirectUri: string;
|
|
918
1623
|
/** Scopes to request (default: 'openid profile') */
|
|
919
1624
|
scope?: string;
|
|
1625
|
+
/**
|
|
1626
|
+
* Response type (default: 'code')
|
|
1627
|
+
*
|
|
1628
|
+
* Use 'none' for session check without token issuance
|
|
1629
|
+
* (OAuth 2.0 Multiple Response Types 1.0 §5)
|
|
1630
|
+
*/
|
|
1631
|
+
responseType?: 'code' | 'none';
|
|
920
1632
|
/** Prompt behavior */
|
|
921
1633
|
prompt?: 'none' | 'login' | 'consent' | 'select_account';
|
|
922
1634
|
/** Hint about the login identifier */
|
|
@@ -933,6 +1645,23 @@ interface BuildAuthorizationUrlOptions {
|
|
|
933
1645
|
* (e.g., cookie, server-side session)
|
|
934
1646
|
*/
|
|
935
1647
|
exposeState?: boolean;
|
|
1648
|
+
/**
|
|
1649
|
+
* Use PAR (Pushed Authorization Request - RFC 9126)
|
|
1650
|
+
*
|
|
1651
|
+
* When true, authorization parameters are first pushed to the PAR endpoint,
|
|
1652
|
+
* and the resulting request_uri is used in the authorization URL.
|
|
1653
|
+
*
|
|
1654
|
+
* Required when server sets require_pushed_authorization_requests=true.
|
|
1655
|
+
*/
|
|
1656
|
+
usePar?: boolean;
|
|
1657
|
+
/**
|
|
1658
|
+
* Use JAR (JWT Secured Authorization Request - RFC 9101)
|
|
1659
|
+
*
|
|
1660
|
+
* When true, authorization parameters are encoded in a signed JWT.
|
|
1661
|
+
*
|
|
1662
|
+
* Required when server sets require_signed_request_object=true.
|
|
1663
|
+
*/
|
|
1664
|
+
useJar?: boolean;
|
|
936
1665
|
}
|
|
937
1666
|
/**
|
|
938
1667
|
* Result of buildAuthorizationUrl
|
|
@@ -968,6 +1697,8 @@ interface ExchangeCodeOptions {
|
|
|
968
1697
|
codeVerifier: string;
|
|
969
1698
|
/** Nonce to validate in ID token */
|
|
970
1699
|
nonce: string;
|
|
1700
|
+
/** Requested scope (for validation) */
|
|
1701
|
+
scope: string;
|
|
971
1702
|
}
|
|
972
1703
|
/**
|
|
973
1704
|
* Authorization Code Flow helper
|
|
@@ -984,6 +1715,7 @@ declare class AuthorizationCodeFlow {
|
|
|
984
1715
|
* @param pkce - PKCE pair
|
|
985
1716
|
* @param options - Authorization options
|
|
986
1717
|
* @returns Authorization URL result
|
|
1718
|
+
* @throws AuthrimError with code 'par_required' if server requires PAR but usePar is not enabled
|
|
987
1719
|
*/
|
|
988
1720
|
buildAuthorizationUrl(discovery: OIDCDiscoveryDocument, authState: AuthState, pkce: PKCEPair, options: BuildAuthorizationUrlOptions): AuthorizationUrlResult;
|
|
989
1721
|
/**
|
|
@@ -1181,70 +1913,14 @@ declare class TokenRevoker {
|
|
|
1181
1913
|
}
|
|
1182
1914
|
|
|
1183
1915
|
/**
|
|
1184
|
-
*
|
|
1916
|
+
* Logout Handler
|
|
1185
1917
|
*
|
|
1186
|
-
*
|
|
1918
|
+
* Implements RP-Initiated Logout (OpenID Connect RP-Initiated Logout 1.0)
|
|
1919
|
+
* https://openid.net/specs/openid-connect-rpinitiated-1_0.html
|
|
1187
1920
|
*/
|
|
1188
1921
|
|
|
1189
1922
|
/**
|
|
1190
|
-
*
|
|
1191
|
-
*/
|
|
1192
|
-
declare class EventEmitter {
|
|
1193
|
-
private listeners;
|
|
1194
|
-
/**
|
|
1195
|
-
* Subscribe to an event
|
|
1196
|
-
*
|
|
1197
|
-
* @param event - Event name
|
|
1198
|
-
* @param handler - Event handler
|
|
1199
|
-
* @returns Unsubscribe function
|
|
1200
|
-
*/
|
|
1201
|
-
on<T extends AuthrimEventName>(event: T, handler: AuthrimEventHandler<T>): () => void;
|
|
1202
|
-
/**
|
|
1203
|
-
* Subscribe to an event (one-time)
|
|
1204
|
-
*
|
|
1205
|
-
* @param event - Event name
|
|
1206
|
-
* @param handler - Event handler
|
|
1207
|
-
* @returns Unsubscribe function
|
|
1208
|
-
*/
|
|
1209
|
-
once<T extends AuthrimEventName>(event: T, handler: AuthrimEventHandler<T>): () => void;
|
|
1210
|
-
/**
|
|
1211
|
-
* Unsubscribe from an event
|
|
1212
|
-
*
|
|
1213
|
-
* @param event - Event name
|
|
1214
|
-
* @param handler - Event handler to remove
|
|
1215
|
-
*/
|
|
1216
|
-
off<T extends AuthrimEventName>(event: T, handler: AuthrimEventHandler<T>): void;
|
|
1217
|
-
/**
|
|
1218
|
-
* Emit an event
|
|
1219
|
-
*
|
|
1220
|
-
* @param event - Event name
|
|
1221
|
-
* @param data - Event data
|
|
1222
|
-
*/
|
|
1223
|
-
emit<T extends AuthrimEventName>(event: T, data: AuthrimEvents[T]): void;
|
|
1224
|
-
/**
|
|
1225
|
-
* Remove all listeners for an event (or all events)
|
|
1226
|
-
*
|
|
1227
|
-
* @param event - Event name (optional, removes all if not specified)
|
|
1228
|
-
*/
|
|
1229
|
-
removeAllListeners(event?: AuthrimEventName): void;
|
|
1230
|
-
/**
|
|
1231
|
-
* Get the number of listeners for an event
|
|
1232
|
-
*
|
|
1233
|
-
* @param event - Event name
|
|
1234
|
-
* @returns Number of listeners
|
|
1235
|
-
*/
|
|
1236
|
-
listenerCount(event: AuthrimEventName): number;
|
|
1237
|
-
}
|
|
1238
|
-
|
|
1239
|
-
/**
|
|
1240
|
-
* Logout Handler
|
|
1241
|
-
*
|
|
1242
|
-
* Implements RP-Initiated Logout (OpenID Connect RP-Initiated Logout 1.0)
|
|
1243
|
-
* https://openid.net/specs/openid-connect-rpinitiated-1_0.html
|
|
1244
|
-
*/
|
|
1245
|
-
|
|
1246
|
-
/**
|
|
1247
|
-
* Logout options
|
|
1923
|
+
* Logout options
|
|
1248
1924
|
*/
|
|
1249
1925
|
interface LogoutOptions {
|
|
1250
1926
|
/** URI to redirect to after logout */
|
|
@@ -1360,6 +2036,12 @@ declare class AuthrimClient {
|
|
|
1360
2036
|
private stateManager;
|
|
1361
2037
|
/** Authorization code flow helper */
|
|
1362
2038
|
private readonly authCodeFlow;
|
|
2039
|
+
/** PAR client */
|
|
2040
|
+
private readonly parClient;
|
|
2041
|
+
/** Device Flow client */
|
|
2042
|
+
private readonly deviceFlowClient;
|
|
2043
|
+
/** DPoP manager (lazily initialized) */
|
|
2044
|
+
private dpopManager;
|
|
1363
2045
|
/** Token manager (initialized in initialize()) */
|
|
1364
2046
|
private tokenManager;
|
|
1365
2047
|
/** Logout handler (initialized in initialize()) */
|
|
@@ -1378,6 +2060,10 @@ declare class AuthrimClient {
|
|
|
1378
2060
|
private readonly normalizedIssuer;
|
|
1379
2061
|
/** Whether the client has been initialized */
|
|
1380
2062
|
private initialized;
|
|
2063
|
+
/**
|
|
2064
|
+
* Get the event emitter for subscribing to SDK events
|
|
2065
|
+
*/
|
|
2066
|
+
get eventEmitter(): EventEmitter;
|
|
1381
2067
|
/**
|
|
1382
2068
|
* Create a new Authrim client
|
|
1383
2069
|
*
|
|
@@ -1420,6 +2106,144 @@ declare class AuthrimClient {
|
|
|
1420
2106
|
* @returns Token set
|
|
1421
2107
|
*/
|
|
1422
2108
|
handleCallback(callbackUrl: string): Promise<TokenSet>;
|
|
2109
|
+
/**
|
|
2110
|
+
* PAR API accessor
|
|
2111
|
+
*
|
|
2112
|
+
* Provides access to Pushed Authorization Request functionality.
|
|
2113
|
+
* PAR allows pushing authorization request parameters to a dedicated endpoint,
|
|
2114
|
+
* receiving a request_uri to use in the authorization URL.
|
|
2115
|
+
*/
|
|
2116
|
+
get par(): {
|
|
2117
|
+
/**
|
|
2118
|
+
* Push authorization request and get request_uri
|
|
2119
|
+
*
|
|
2120
|
+
* @param options - Authorization options
|
|
2121
|
+
* @returns PAR result with request_uri and expiration
|
|
2122
|
+
*/
|
|
2123
|
+
push: (options: BuildAuthorizationUrlOptions) => Promise<PARResult>;
|
|
2124
|
+
/**
|
|
2125
|
+
* Build authorization URL using request_uri from PAR
|
|
2126
|
+
*
|
|
2127
|
+
* @param requestUri - Request URI from PAR response
|
|
2128
|
+
* @returns Authorization URL
|
|
2129
|
+
*/
|
|
2130
|
+
buildAuthorizationUrl: (requestUri: string) => Promise<string>;
|
|
2131
|
+
/**
|
|
2132
|
+
* Check if PAR is available
|
|
2133
|
+
*
|
|
2134
|
+
* @returns True if PAR endpoint is available
|
|
2135
|
+
*/
|
|
2136
|
+
isAvailable: () => Promise<boolean>;
|
|
2137
|
+
/**
|
|
2138
|
+
* Check if PAR is required by the server
|
|
2139
|
+
*
|
|
2140
|
+
* @returns True if server requires PAR
|
|
2141
|
+
*/
|
|
2142
|
+
isRequired: () => Promise<boolean>;
|
|
2143
|
+
};
|
|
2144
|
+
/**
|
|
2145
|
+
* Device Flow API accessor
|
|
2146
|
+
*
|
|
2147
|
+
* Provides access to Device Authorization Grant functionality.
|
|
2148
|
+
* Used for devices with limited input capabilities (TVs, CLIs, IoT).
|
|
2149
|
+
*/
|
|
2150
|
+
get deviceFlow(): {
|
|
2151
|
+
/**
|
|
2152
|
+
* Start device authorization
|
|
2153
|
+
*
|
|
2154
|
+
* @param options - Start options (scope, etc.)
|
|
2155
|
+
* @returns Device flow state with codes and URIs
|
|
2156
|
+
*/
|
|
2157
|
+
start: (options?: DeviceFlowStartOptions) => Promise<DeviceFlowState>;
|
|
2158
|
+
/**
|
|
2159
|
+
* Poll once for token
|
|
2160
|
+
*
|
|
2161
|
+
* @param state - Device flow state
|
|
2162
|
+
* @returns Poll result
|
|
2163
|
+
*/
|
|
2164
|
+
pollOnce: (state: DeviceFlowState) => Promise<DeviceFlowPollResult>;
|
|
2165
|
+
/**
|
|
2166
|
+
* Poll until complete or expired
|
|
2167
|
+
*
|
|
2168
|
+
* @param state - Device flow state
|
|
2169
|
+
* @param options - Polling options (signal for abort)
|
|
2170
|
+
* @returns Token set on success
|
|
2171
|
+
*/
|
|
2172
|
+
pollUntilComplete: (state: DeviceFlowState, options?: {
|
|
2173
|
+
signal?: AbortSignal;
|
|
2174
|
+
}) => Promise<TokenSet>;
|
|
2175
|
+
/**
|
|
2176
|
+
* Check if Device Flow is available
|
|
2177
|
+
*
|
|
2178
|
+
* @returns True if device authorization endpoint is available
|
|
2179
|
+
*/
|
|
2180
|
+
isAvailable: () => Promise<boolean>;
|
|
2181
|
+
};
|
|
2182
|
+
/**
|
|
2183
|
+
* DPoP API accessor
|
|
2184
|
+
*
|
|
2185
|
+
* Provides access to DPoP (Demonstrating Proof of Possession) functionality.
|
|
2186
|
+
* DPoP binds access tokens to a cryptographic key held by the client,
|
|
2187
|
+
* preventing token theft and replay attacks.
|
|
2188
|
+
*
|
|
2189
|
+
* NOTE: The CryptoProvider must implement DPoPCryptoProvider interface
|
|
2190
|
+
* for DPoP to be available.
|
|
2191
|
+
*
|
|
2192
|
+
* @returns DPoP API accessor, or undefined if not supported
|
|
2193
|
+
*/
|
|
2194
|
+
get dpop(): {
|
|
2195
|
+
/**
|
|
2196
|
+
* Initialize DPoP (generates or retrieves key pair)
|
|
2197
|
+
*/
|
|
2198
|
+
initialize: () => Promise<void>;
|
|
2199
|
+
/**
|
|
2200
|
+
* Check if DPoP is initialized
|
|
2201
|
+
*/
|
|
2202
|
+
isInitialized: () => boolean;
|
|
2203
|
+
/**
|
|
2204
|
+
* Generate a DPoP proof for a request
|
|
2205
|
+
*
|
|
2206
|
+
* @param method - HTTP method (GET, POST, etc.)
|
|
2207
|
+
* @param uri - Full request URI
|
|
2208
|
+
* @param options - Additional options (access token hash, nonce)
|
|
2209
|
+
* @returns Signed DPoP proof JWT
|
|
2210
|
+
*/
|
|
2211
|
+
generateProof: (method: string, uri: string, options?: {
|
|
2212
|
+
accessTokenHash?: string;
|
|
2213
|
+
nonce?: string;
|
|
2214
|
+
}) => Promise<string>;
|
|
2215
|
+
/**
|
|
2216
|
+
* Handle DPoP-Nonce response from server
|
|
2217
|
+
*
|
|
2218
|
+
* @param nonce - Server-provided nonce
|
|
2219
|
+
*/
|
|
2220
|
+
handleNonceResponse: (nonce: string) => void;
|
|
2221
|
+
/**
|
|
2222
|
+
* Calculate access token hash for ath claim
|
|
2223
|
+
*
|
|
2224
|
+
* @param accessToken - Access token to hash
|
|
2225
|
+
* @returns Base64url-encoded SHA-256 hash
|
|
2226
|
+
*/
|
|
2227
|
+
calculateAccessTokenHash: (accessToken: string) => Promise<string>;
|
|
2228
|
+
/**
|
|
2229
|
+
* Get the public key JWK
|
|
2230
|
+
*/
|
|
2231
|
+
getPublicKeyJwk: () => JWK | null;
|
|
2232
|
+
/**
|
|
2233
|
+
* Get the JWK thumbprint
|
|
2234
|
+
*/
|
|
2235
|
+
getThumbprint: () => string | null;
|
|
2236
|
+
/**
|
|
2237
|
+
* Clear DPoP key pair (call on logout)
|
|
2238
|
+
*/
|
|
2239
|
+
clear: () => Promise<void>;
|
|
2240
|
+
/**
|
|
2241
|
+
* Check if DPoP is supported by the server
|
|
2242
|
+
*
|
|
2243
|
+
* @returns True if server advertises DPoP support
|
|
2244
|
+
*/
|
|
2245
|
+
isServerSupported: () => Promise<boolean>;
|
|
2246
|
+
} | undefined;
|
|
1423
2247
|
/**
|
|
1424
2248
|
* Token API accessor
|
|
1425
2249
|
*/
|
|
@@ -1623,6 +2447,13 @@ interface SilentAuthOptions {
|
|
|
1623
2447
|
redirectUri: string;
|
|
1624
2448
|
/** Scopes to request (default: 'openid') */
|
|
1625
2449
|
scope?: string;
|
|
2450
|
+
/**
|
|
2451
|
+
* Response type (default: 'code')
|
|
2452
|
+
*
|
|
2453
|
+
* Use 'none' for session check without token issuance
|
|
2454
|
+
* (OAuth 2.0 Multiple Response Types 1.0 §5)
|
|
2455
|
+
*/
|
|
2456
|
+
responseType?: 'code' | 'none';
|
|
1626
2457
|
/** Hint about the login identifier */
|
|
1627
2458
|
loginHint?: string;
|
|
1628
2459
|
/** ID token hint (helps IdP identify the user) */
|
|
@@ -1714,263 +2545,1864 @@ declare class SilentAuthHandler {
|
|
|
1714
2545
|
}
|
|
1715
2546
|
|
|
1716
2547
|
/**
|
|
1717
|
-
*
|
|
2548
|
+
* PAR (Pushed Authorization Request) Client
|
|
2549
|
+
* RFC 9126: OAuth 2.0 Pushed Authorization Requests
|
|
1718
2550
|
*
|
|
1719
|
-
*
|
|
1720
|
-
*
|
|
2551
|
+
* PAR allows the client to push the authorization request payload
|
|
2552
|
+
* to the authorization server via a direct POST request, receiving
|
|
2553
|
+
* a request_uri to use in the authorization URL.
|
|
2554
|
+
*
|
|
2555
|
+
* Benefits:
|
|
2556
|
+
* - Integrity protection of authorization request
|
|
2557
|
+
* - Confidentiality of authorization request parameters
|
|
2558
|
+
* - Support for large request parameters
|
|
2559
|
+
* - Required for FAPI 2.0 compliance
|
|
1721
2560
|
*/
|
|
1722
2561
|
|
|
1723
2562
|
/**
|
|
1724
|
-
*
|
|
2563
|
+
* PAR Client
|
|
2564
|
+
*
|
|
2565
|
+
* Handles Pushed Authorization Requests per RFC 9126.
|
|
1725
2566
|
*/
|
|
1726
|
-
|
|
2567
|
+
declare class PARClient {
|
|
2568
|
+
private readonly http;
|
|
2569
|
+
private readonly clientId;
|
|
2570
|
+
private readonly options?;
|
|
2571
|
+
constructor(http: HttpClient, clientId: string, options?: PARClientOptions | undefined);
|
|
2572
|
+
/**
|
|
2573
|
+
* Push authorization request to the server
|
|
2574
|
+
*
|
|
2575
|
+
* @param discovery - OIDC discovery document
|
|
2576
|
+
* @param request - PAR request parameters
|
|
2577
|
+
* @returns PAR result with request_uri and expiration
|
|
2578
|
+
* @throws AuthrimError with code 'no_par_endpoint' if PAR endpoint not available
|
|
2579
|
+
* @throws AuthrimError with code 'par_error' if PAR request fails
|
|
2580
|
+
*/
|
|
2581
|
+
pushAuthorizationRequest(discovery: OIDCDiscoveryDocument, request: PARRequest): Promise<PARResult>;
|
|
2582
|
+
/**
|
|
2583
|
+
* Build authorization URL using request_uri from PAR
|
|
2584
|
+
*
|
|
2585
|
+
* @param discovery - OIDC discovery document
|
|
2586
|
+
* @param requestUri - Request URI from PAR response
|
|
2587
|
+
* @returns Authorization URL
|
|
2588
|
+
*/
|
|
2589
|
+
buildAuthorizationUrlWithPar(discovery: OIDCDiscoveryDocument, requestUri: string): string;
|
|
2590
|
+
}
|
|
2591
|
+
|
|
2592
|
+
/**
|
|
2593
|
+
* Client Authentication Types
|
|
2594
|
+
* RFC 6749 §2.3, RFC 7521, RFC 7523
|
|
2595
|
+
*/
|
|
2596
|
+
/**
|
|
2597
|
+
* Client authentication methods
|
|
2598
|
+
*/
|
|
2599
|
+
type ClientAuthMethod = 'client_secret_basic' | 'client_secret_post' | 'private_key_jwt' | 'none';
|
|
2600
|
+
/**
|
|
2601
|
+
* Client secret credentials (Basic or POST)
|
|
2602
|
+
*/
|
|
2603
|
+
interface ClientSecretCredentials {
|
|
2604
|
+
/** Authentication method */
|
|
2605
|
+
method: 'client_secret_basic' | 'client_secret_post';
|
|
2606
|
+
/** Client secret */
|
|
2607
|
+
clientSecret: string;
|
|
2608
|
+
}
|
|
2609
|
+
/**
|
|
2610
|
+
* Private key JWT credentials (RFC 7523)
|
|
2611
|
+
*/
|
|
2612
|
+
interface PrivateKeyJwtCredentials {
|
|
2613
|
+
/** Authentication method */
|
|
2614
|
+
method: 'private_key_jwt';
|
|
2615
|
+
/**
|
|
2616
|
+
* Function to sign JWT assertions
|
|
2617
|
+
*
|
|
2618
|
+
* @param claims - JWT claims to sign
|
|
2619
|
+
* @returns Signed JWT string
|
|
2620
|
+
*/
|
|
2621
|
+
signJwt: (claims: Record<string, unknown>) => Promise<string>;
|
|
2622
|
+
/** Key ID to include in JWT header */
|
|
2623
|
+
keyId?: string;
|
|
2624
|
+
}
|
|
2625
|
+
/**
|
|
2626
|
+
* No client authentication (public client)
|
|
2627
|
+
*
|
|
2628
|
+
* SECURITY: method='none' requires explicit opt-in via dangerouslyAllowInsecure
|
|
2629
|
+
* to ensure developers consciously choose to use public client authentication.
|
|
2630
|
+
*/
|
|
2631
|
+
interface NoClientCredentials {
|
|
2632
|
+
/** Authentication method */
|
|
2633
|
+
method: 'none';
|
|
2634
|
+
/**
|
|
2635
|
+
* Required flag to acknowledge insecure client authentication
|
|
2636
|
+
*
|
|
2637
|
+
* Setting this to true acknowledges that:
|
|
2638
|
+
* - The client cannot be authenticated securely
|
|
2639
|
+
* - This should only be used for public clients (browser apps, native apps)
|
|
2640
|
+
* - Tokens may be exposed to the user
|
|
2641
|
+
*/
|
|
2642
|
+
dangerouslyAllowInsecure: true;
|
|
2643
|
+
}
|
|
2644
|
+
/**
|
|
2645
|
+
* Union type for all client credentials
|
|
2646
|
+
*/
|
|
2647
|
+
type ClientCredentials = ClientSecretCredentials | PrivateKeyJwtCredentials | NoClientCredentials;
|
|
2648
|
+
/**
|
|
2649
|
+
* JWT assertion claims for client authentication
|
|
2650
|
+
*/
|
|
2651
|
+
interface ClientAssertionClaims extends Record<string, unknown> {
|
|
2652
|
+
/** Issuer (client_id) */
|
|
2653
|
+
iss: string;
|
|
2654
|
+
/** Subject (client_id) */
|
|
2655
|
+
sub: string;
|
|
2656
|
+
/** Audience (token endpoint URL) */
|
|
2657
|
+
aud: string;
|
|
2658
|
+
/** JWT ID (unique identifier) */
|
|
2659
|
+
jti: string;
|
|
2660
|
+
/** Expiration time (epoch seconds) */
|
|
2661
|
+
exp: number;
|
|
2662
|
+
/** Issued at time (epoch seconds) */
|
|
2663
|
+
iat: number;
|
|
2664
|
+
}
|
|
2665
|
+
|
|
2666
|
+
/**
|
|
2667
|
+
* Client Authentication Utilities
|
|
2668
|
+
* RFC 6749 §2.3, RFC 7521, RFC 7523
|
|
2669
|
+
*
|
|
2670
|
+
* Provides utilities for building client authentication headers and body parameters
|
|
2671
|
+
* for various authentication methods.
|
|
2672
|
+
*/
|
|
2673
|
+
|
|
2674
|
+
/**
|
|
2675
|
+
* Client authentication result
|
|
2676
|
+
*/
|
|
2677
|
+
interface ClientAuthResult {
|
|
2678
|
+
/** Headers to include in the request */
|
|
2679
|
+
headers: Record<string, string>;
|
|
2680
|
+
/** Body parameters to include in the request */
|
|
2681
|
+
bodyParams: Record<string, string>;
|
|
2682
|
+
}
|
|
2683
|
+
/**
|
|
2684
|
+
* Build client authentication headers and body parameters
|
|
2685
|
+
*
|
|
2686
|
+
* @param credentials - Client credentials configuration
|
|
2687
|
+
* @param clientId - Client ID
|
|
2688
|
+
* @param tokenEndpoint - Token endpoint URL (used as audience for private_key_jwt)
|
|
2689
|
+
* @returns Headers and body parameters for authentication
|
|
2690
|
+
* @throws AuthrimError with code 'insecure_client_auth' if method='none' without dangerouslyAllowInsecure
|
|
2691
|
+
* @throws AuthrimError with code 'invalid_client_authentication' for invalid credentials
|
|
2692
|
+
*/
|
|
2693
|
+
declare function buildClientAuthentication(credentials: ClientCredentials, clientId: string, tokenEndpoint: string): Promise<ClientAuthResult>;
|
|
2694
|
+
|
|
2695
|
+
/**
|
|
2696
|
+
* Client Credentials Flow
|
|
2697
|
+
* RFC 6749 §4.4
|
|
2698
|
+
*
|
|
2699
|
+
* The client credentials grant is used for machine-to-machine (M2M) authentication
|
|
2700
|
+
* where no user is involved. The client authenticates directly with the authorization
|
|
2701
|
+
* server using its own credentials.
|
|
2702
|
+
*
|
|
2703
|
+
* IMPORTANT: This flow should only be used in secure environments (server-side)
|
|
2704
|
+
* where client credentials can be kept confidential.
|
|
2705
|
+
*/
|
|
2706
|
+
|
|
2707
|
+
/**
|
|
2708
|
+
* Options for ClientCredentialsClient constructor
|
|
2709
|
+
*/
|
|
2710
|
+
interface ClientCredentialsClientOptions {
|
|
1727
2711
|
/** HTTP client */
|
|
1728
2712
|
http: HttpClient;
|
|
1729
|
-
/** Storage provider */
|
|
1730
|
-
storage: AuthrimStorage;
|
|
1731
2713
|
/** Client ID */
|
|
1732
2714
|
clientId: string;
|
|
1733
|
-
/**
|
|
1734
|
-
|
|
1735
|
-
/** Client ID hash for storage keys */
|
|
1736
|
-
clientIdHash: string;
|
|
1737
|
-
/** Refresh skew in seconds (default: 30) */
|
|
1738
|
-
refreshSkewSeconds?: number;
|
|
1739
|
-
/** Event emitter for token events */
|
|
1740
|
-
eventEmitter?: EventEmitter;
|
|
2715
|
+
/** Client credentials */
|
|
2716
|
+
credentials: ClientCredentials;
|
|
1741
2717
|
}
|
|
1742
2718
|
/**
|
|
1743
|
-
*
|
|
2719
|
+
* Options for getting a token
|
|
2720
|
+
*/
|
|
2721
|
+
interface ClientCredentialsTokenOptions {
|
|
2722
|
+
/** Scopes to request */
|
|
2723
|
+
scope?: string;
|
|
2724
|
+
/** Target audience (resource server identifier) */
|
|
2725
|
+
audience?: string;
|
|
2726
|
+
/** Additional parameters */
|
|
2727
|
+
extraParams?: Record<string, string>;
|
|
2728
|
+
}
|
|
2729
|
+
/**
|
|
2730
|
+
* Client Credentials Flow Client
|
|
1744
2731
|
*
|
|
1745
|
-
* Handles
|
|
1746
|
-
* concurrent request coalescing.
|
|
2732
|
+
* Handles machine-to-machine authentication using the client credentials grant.
|
|
1747
2733
|
*/
|
|
1748
|
-
declare class
|
|
2734
|
+
declare class ClientCredentialsClient {
|
|
1749
2735
|
private readonly http;
|
|
1750
|
-
private readonly storage;
|
|
1751
2736
|
private readonly clientId;
|
|
1752
|
-
private readonly
|
|
1753
|
-
|
|
1754
|
-
private readonly refreshSkewSeconds;
|
|
1755
|
-
private readonly eventEmitter?;
|
|
1756
|
-
/** In-flight refresh promise for request coalescing */
|
|
1757
|
-
private refreshPromise;
|
|
1758
|
-
/** Discovery document (set externally) */
|
|
1759
|
-
private discovery;
|
|
1760
|
-
/** Default refresh skew: 30 seconds */
|
|
1761
|
-
private static readonly DEFAULT_REFRESH_SKEW_SECONDS;
|
|
1762
|
-
constructor(options: TokenManagerOptions);
|
|
2737
|
+
private readonly credentials;
|
|
2738
|
+
constructor(options: ClientCredentialsClientOptions);
|
|
1763
2739
|
/**
|
|
1764
|
-
*
|
|
2740
|
+
* Get an access token using client credentials
|
|
2741
|
+
*
|
|
2742
|
+
* @param discovery - OIDC discovery document
|
|
2743
|
+
* @param options - Token request options
|
|
2744
|
+
* @returns Token set
|
|
2745
|
+
* @throws AuthrimError with code 'client_credentials_error' if token request fails
|
|
1765
2746
|
*/
|
|
1766
|
-
|
|
2747
|
+
getToken(discovery: OIDCDiscoveryDocument, options?: ClientCredentialsTokenOptions): Promise<TokenSet>;
|
|
2748
|
+
}
|
|
2749
|
+
|
|
2750
|
+
/**
|
|
2751
|
+
* Device Authorization Flow
|
|
2752
|
+
* RFC 8628: OAuth 2.0 Device Authorization Grant
|
|
2753
|
+
*
|
|
2754
|
+
* Used for devices with limited input capabilities where the user
|
|
2755
|
+
* authenticates on a separate device (phone, computer).
|
|
2756
|
+
*
|
|
2757
|
+
* Flow:
|
|
2758
|
+
* 1. Client requests device code from authorization server
|
|
2759
|
+
* 2. User goes to verification URI and enters user code
|
|
2760
|
+
* 3. Client polls token endpoint until user completes auth
|
|
2761
|
+
*
|
|
2762
|
+
* NOTE: This core SDK returns "facts" only - UX events like
|
|
2763
|
+
* 'device:started' or 'device:pending' are the responsibility
|
|
2764
|
+
* of upper-layer SDKs (web/react/svelte).
|
|
2765
|
+
*/
|
|
2766
|
+
|
|
2767
|
+
/**
|
|
2768
|
+
* Device Flow Client
|
|
2769
|
+
*
|
|
2770
|
+
* Handles the OAuth 2.0 Device Authorization Grant (RFC 8628).
|
|
2771
|
+
*/
|
|
2772
|
+
declare class DeviceFlowClient {
|
|
2773
|
+
private readonly http;
|
|
2774
|
+
private readonly clientId;
|
|
2775
|
+
constructor(http: HttpClient, clientId: string);
|
|
1767
2776
|
/**
|
|
1768
|
-
*
|
|
2777
|
+
* Start device authorization
|
|
2778
|
+
*
|
|
2779
|
+
* Requests a device code and user code from the authorization server.
|
|
2780
|
+
*
|
|
2781
|
+
* @param discovery - OIDC discovery document
|
|
2782
|
+
* @param options - Start options (scope, etc.)
|
|
2783
|
+
* @returns Device flow state with codes and URIs
|
|
2784
|
+
* @throws AuthrimError with code 'no_device_authorization_endpoint' if endpoint not available
|
|
2785
|
+
* @throws AuthrimError with code 'device_authorization_error' if request fails
|
|
1769
2786
|
*/
|
|
1770
|
-
|
|
2787
|
+
startDeviceAuthorization(discovery: OIDCDiscoveryDocument, options?: DeviceFlowStartOptions): Promise<DeviceFlowState>;
|
|
1771
2788
|
/**
|
|
1772
|
-
*
|
|
2789
|
+
* Poll the token endpoint once
|
|
2790
|
+
*
|
|
2791
|
+
* Returns the current state of the authorization:
|
|
2792
|
+
* - 'pending': User hasn't completed auth yet
|
|
2793
|
+
* - 'completed': Auth complete, tokens received
|
|
2794
|
+
* - 'slow_down': Polling too fast, increase interval
|
|
2795
|
+
* - 'expired': Device code expired
|
|
2796
|
+
* - 'access_denied': User denied the request
|
|
2797
|
+
*
|
|
2798
|
+
* @param discovery - OIDC discovery document
|
|
2799
|
+
* @param state - Device flow state from startDeviceAuthorization
|
|
2800
|
+
* @returns Poll result
|
|
1773
2801
|
*/
|
|
1774
|
-
|
|
2802
|
+
pollOnce(discovery: OIDCDiscoveryDocument, state: DeviceFlowState): Promise<DeviceFlowPollResult>;
|
|
1775
2803
|
/**
|
|
1776
|
-
*
|
|
2804
|
+
* Poll until authorization is complete or expires
|
|
1777
2805
|
*
|
|
1778
|
-
*
|
|
2806
|
+
* Automatically handles polling interval and retries.
|
|
2807
|
+
*
|
|
2808
|
+
* @param discovery - OIDC discovery document
|
|
2809
|
+
* @param state - Device flow state from startDeviceAuthorization
|
|
2810
|
+
* @param options - Polling options
|
|
2811
|
+
* @returns Token set on success
|
|
2812
|
+
* @throws AuthrimError with code 'device_authorization_expired' if device code expires
|
|
2813
|
+
* @throws AuthrimError with code 'device_access_denied' if user denies authorization
|
|
1779
2814
|
*/
|
|
1780
|
-
|
|
2815
|
+
pollUntilComplete(discovery: OIDCDiscoveryDocument, state: DeviceFlowState, options?: {
|
|
2816
|
+
signal?: AbortSignal;
|
|
2817
|
+
}): Promise<TokenSet>;
|
|
1781
2818
|
/**
|
|
1782
|
-
*
|
|
1783
|
-
*
|
|
2819
|
+
* Sleep for a given number of milliseconds
|
|
2820
|
+
* @param ms - Milliseconds to sleep
|
|
2821
|
+
* @param signal - Optional abort signal
|
|
2822
|
+
*/
|
|
2823
|
+
private sleep;
|
|
2824
|
+
}
|
|
2825
|
+
|
|
2826
|
+
/**
|
|
2827
|
+
* DPoP (Demonstrating Proof of Possession) Types
|
|
2828
|
+
* RFC 9449: OAuth 2.0 Demonstrating Proof of Possession (DPoP)
|
|
2829
|
+
*
|
|
2830
|
+
* DPoP provides a mechanism for sender-constraining access tokens
|
|
2831
|
+
* to a particular client by binding tokens to a cryptographic key.
|
|
2832
|
+
*/
|
|
2833
|
+
/**
|
|
2834
|
+
* JSON Web Key (JWK) format
|
|
2835
|
+
*
|
|
2836
|
+
* Subset of the Web Crypto API JWK interface.
|
|
2837
|
+
* Defined here for platform-agnostic support.
|
|
2838
|
+
*/
|
|
2839
|
+
interface JWK {
|
|
2840
|
+
/** Key type (e.g., 'EC', 'RSA') */
|
|
2841
|
+
kty?: string;
|
|
2842
|
+
/** Key ID */
|
|
2843
|
+
kid?: string;
|
|
2844
|
+
/** Algorithm */
|
|
2845
|
+
alg?: string;
|
|
2846
|
+
/** Public key use */
|
|
2847
|
+
use?: string;
|
|
2848
|
+
/** Key operations */
|
|
2849
|
+
key_ops?: string[];
|
|
2850
|
+
/** Extractable flag */
|
|
2851
|
+
ext?: boolean;
|
|
2852
|
+
/** Curve name */
|
|
2853
|
+
crv?: string;
|
|
2854
|
+
/** X coordinate (base64url) */
|
|
2855
|
+
x?: string;
|
|
2856
|
+
/** Y coordinate (base64url) */
|
|
2857
|
+
y?: string;
|
|
2858
|
+
/** Private key value (base64url) - should not be exported */
|
|
2859
|
+
d?: string;
|
|
2860
|
+
/** Modulus (base64url) */
|
|
2861
|
+
n?: string;
|
|
2862
|
+
/** Public exponent (base64url) */
|
|
2863
|
+
e?: string;
|
|
2864
|
+
[key: string]: unknown;
|
|
2865
|
+
}
|
|
2866
|
+
/**
|
|
2867
|
+
* DPoP key pair interface
|
|
2868
|
+
*
|
|
2869
|
+
* Represents an asymmetric key pair used for DPoP proofs.
|
|
2870
|
+
*/
|
|
2871
|
+
interface DPoPKeyPair {
|
|
2872
|
+
/** Algorithm identifier (e.g., 'ES256', 'RS256') */
|
|
2873
|
+
algorithm: string;
|
|
2874
|
+
/** JWK thumbprint of the public key (base64url encoded) */
|
|
2875
|
+
thumbprint: string;
|
|
2876
|
+
/** Public key in JWK format */
|
|
2877
|
+
publicKeyJwk: JWK;
|
|
2878
|
+
/**
|
|
2879
|
+
* Sign data with the private key
|
|
2880
|
+
*
|
|
2881
|
+
* @param data - Data to sign
|
|
2882
|
+
* @returns Signature
|
|
2883
|
+
*/
|
|
2884
|
+
sign(data: Uint8Array): Promise<Uint8Array>;
|
|
2885
|
+
}
|
|
2886
|
+
/**
|
|
2887
|
+
* DPoP proof JWT header
|
|
2888
|
+
*/
|
|
2889
|
+
interface DPoPProofHeader {
|
|
2890
|
+
/** Type (always 'dpop+jwt') */
|
|
2891
|
+
typ: 'dpop+jwt';
|
|
2892
|
+
/** Algorithm */
|
|
2893
|
+
alg: string;
|
|
2894
|
+
/** Public key in JWK format */
|
|
2895
|
+
jwk: JWK;
|
|
2896
|
+
}
|
|
2897
|
+
/**
|
|
2898
|
+
* DPoP proof JWT claims
|
|
2899
|
+
*/
|
|
2900
|
+
interface DPoPProofClaims {
|
|
2901
|
+
/** Unique identifier for the proof */
|
|
2902
|
+
jti: string;
|
|
2903
|
+
/** HTTP method of the request */
|
|
2904
|
+
htm: string;
|
|
2905
|
+
/** HTTP URI of the request (without query and fragment) */
|
|
2906
|
+
htu: string;
|
|
2907
|
+
/** Issued at time (epoch seconds) */
|
|
2908
|
+
iat: number;
|
|
2909
|
+
/** Access token hash (when binding to access token) */
|
|
2910
|
+
ath?: string;
|
|
2911
|
+
/** Server-provided nonce (when server requires it) */
|
|
2912
|
+
nonce?: string;
|
|
2913
|
+
}
|
|
2914
|
+
/**
|
|
2915
|
+
* Options for generating a DPoP proof
|
|
2916
|
+
*/
|
|
2917
|
+
interface DPoPProofOptions {
|
|
2918
|
+
/** Hash of the access token (base64url(SHA-256(access_token))) */
|
|
2919
|
+
accessTokenHash?: string;
|
|
2920
|
+
/** Server-provided nonce */
|
|
2921
|
+
nonce?: string;
|
|
2922
|
+
}
|
|
2923
|
+
/**
|
|
2924
|
+
* DPoP Manager configuration
|
|
2925
|
+
*/
|
|
2926
|
+
interface DPoPManagerConfig {
|
|
2927
|
+
/** Preferred algorithm (default: 'ES256') */
|
|
2928
|
+
algorithm?: string;
|
|
2929
|
+
}
|
|
2930
|
+
/**
|
|
2931
|
+
* Extended CryptoProvider interface with DPoP support
|
|
2932
|
+
*
|
|
2933
|
+
* This extends the base CryptoProvider with optional DPoP methods.
|
|
2934
|
+
* Implementations that support DPoP should implement these methods.
|
|
2935
|
+
*/
|
|
2936
|
+
interface DPoPCryptoProvider {
|
|
2937
|
+
/**
|
|
2938
|
+
* Generate a new DPoP key pair
|
|
2939
|
+
*
|
|
2940
|
+
* @param algorithm - Preferred algorithm (default: 'ES256')
|
|
2941
|
+
* @returns Generated key pair
|
|
2942
|
+
*/
|
|
2943
|
+
generateDPoPKeyPair?(algorithm?: string): Promise<DPoPKeyPair>;
|
|
2944
|
+
/**
|
|
2945
|
+
* Get the current DPoP key pair
|
|
2946
|
+
*
|
|
2947
|
+
* Returns null if no key pair has been generated.
|
|
2948
|
+
*
|
|
2949
|
+
* @returns Current key pair or null
|
|
2950
|
+
*/
|
|
2951
|
+
getDPoPKeyPair?(): Promise<DPoPKeyPair | null>;
|
|
2952
|
+
/**
|
|
2953
|
+
* Clear the DPoP key pair
|
|
2954
|
+
*
|
|
2955
|
+
* Should be called on logout to clean up key material.
|
|
2956
|
+
*/
|
|
2957
|
+
clearDPoPKeyPair?(): Promise<void>;
|
|
2958
|
+
}
|
|
2959
|
+
|
|
2960
|
+
/**
|
|
2961
|
+
* DPoP Manager
|
|
2962
|
+
* RFC 9449: OAuth 2.0 Demonstrating Proof of Possession (DPoP)
|
|
2963
|
+
*
|
|
2964
|
+
* DPoP provides sender-constrained access tokens by binding them
|
|
2965
|
+
* to a cryptographic key held by the client. This prevents token theft
|
|
2966
|
+
* and replay attacks.
|
|
2967
|
+
*
|
|
2968
|
+
* NOTE: DPoP proofs are required for:
|
|
2969
|
+
* - Token requests (authorization code exchange, refresh)
|
|
2970
|
+
* - PAR requests
|
|
2971
|
+
* - UserInfo requests
|
|
2972
|
+
* - Any protected resource request
|
|
2973
|
+
*
|
|
2974
|
+
* Future consideration: HttpClient-level middleware for automatic DPoP proof attachment.
|
|
2975
|
+
*/
|
|
2976
|
+
|
|
2977
|
+
/**
|
|
2978
|
+
* DPoP Manager
|
|
2979
|
+
*
|
|
2980
|
+
* Manages DPoP key pairs and generates DPoP proofs for requests.
|
|
2981
|
+
*/
|
|
2982
|
+
declare class DPoPManager {
|
|
2983
|
+
private readonly crypto;
|
|
2984
|
+
private readonly config;
|
|
2985
|
+
private keyPair;
|
|
2986
|
+
private serverNonce;
|
|
2987
|
+
constructor(crypto: CryptoProvider & DPoPCryptoProvider, config?: DPoPManagerConfig);
|
|
2988
|
+
/**
|
|
2989
|
+
* Initialize the DPoP manager
|
|
2990
|
+
*
|
|
2991
|
+
* Generates or retrieves a DPoP key pair.
|
|
2992
|
+
*
|
|
2993
|
+
* @throws AuthrimError with code 'dpop_key_generation_error' if key generation fails
|
|
2994
|
+
*/
|
|
2995
|
+
initialize(): Promise<void>;
|
|
2996
|
+
/**
|
|
2997
|
+
* Check if DPoP is initialized
|
|
2998
|
+
*/
|
|
2999
|
+
isInitialized(): boolean;
|
|
3000
|
+
/**
|
|
3001
|
+
* Generate a DPoP proof
|
|
3002
|
+
*
|
|
3003
|
+
* Creates a signed JWT proof for the specified HTTP method and URI.
|
|
3004
|
+
*
|
|
3005
|
+
* @param method - HTTP method (GET, POST, etc.)
|
|
3006
|
+
* @param uri - Full request URI (https://example.com/path)
|
|
3007
|
+
* @param options - Additional options (access token hash, nonce)
|
|
3008
|
+
* @returns Signed DPoP proof JWT
|
|
3009
|
+
* @throws AuthrimError with code 'dpop_proof_generation_error' if proof generation fails
|
|
3010
|
+
*/
|
|
3011
|
+
generateProof(method: string, uri: string, options?: DPoPProofOptions): Promise<string>;
|
|
3012
|
+
/**
|
|
3013
|
+
* Handle a DPoP-Nonce response from the server
|
|
3014
|
+
*
|
|
3015
|
+
* When the server returns a use_dpop_nonce error or includes
|
|
3016
|
+
* a DPoP-Nonce header, this method stores the nonce for future proofs.
|
|
3017
|
+
*
|
|
3018
|
+
* @param nonce - Server-provided nonce value
|
|
3019
|
+
*/
|
|
3020
|
+
handleNonceResponse(nonce: string): void;
|
|
3021
|
+
/**
|
|
3022
|
+
* Get the current server nonce
|
|
3023
|
+
*/
|
|
3024
|
+
getServerNonce(): string | null;
|
|
3025
|
+
/**
|
|
3026
|
+
* Clear the server nonce
|
|
3027
|
+
*/
|
|
3028
|
+
clearServerNonce(): void;
|
|
3029
|
+
/**
|
|
3030
|
+
* Get the public key JWK
|
|
3031
|
+
*
|
|
3032
|
+
* @returns Public key in JWK format, or null if not initialized
|
|
3033
|
+
*/
|
|
3034
|
+
getPublicKeyJwk(): JWK | null;
|
|
3035
|
+
/**
|
|
3036
|
+
* Get the JWK thumbprint
|
|
3037
|
+
*
|
|
3038
|
+
* @returns Base64url-encoded thumbprint, or null if not initialized
|
|
3039
|
+
*/
|
|
3040
|
+
getThumbprint(): string | null;
|
|
3041
|
+
/**
|
|
3042
|
+
* Calculate access token hash for ath claim
|
|
3043
|
+
*
|
|
3044
|
+
* @param accessToken - Access token to hash
|
|
3045
|
+
* @returns Base64url-encoded SHA-256 hash
|
|
3046
|
+
*/
|
|
3047
|
+
calculateAccessTokenHash(accessToken: string): Promise<string>;
|
|
3048
|
+
/**
|
|
3049
|
+
* Clear the DPoP key pair
|
|
3050
|
+
*
|
|
3051
|
+
* Should be called on logout to clean up key material.
|
|
3052
|
+
*/
|
|
3053
|
+
clear(): Promise<void>;
|
|
3054
|
+
/**
|
|
3055
|
+
* Generate a unique JWT ID (jti)
|
|
3056
|
+
*/
|
|
3057
|
+
private generateJti;
|
|
3058
|
+
}
|
|
3059
|
+
|
|
3060
|
+
/**
|
|
3061
|
+
* JAR (JWT Secured Authorization Request) Types
|
|
3062
|
+
* RFC 9101: The OAuth 2.0 Authorization Framework: JWT-Secured Authorization Request (JAR)
|
|
3063
|
+
*
|
|
3064
|
+
* JAR allows authorization request parameters to be encoded in a
|
|
3065
|
+
* signed JWT, providing integrity protection and non-repudiation.
|
|
3066
|
+
*/
|
|
3067
|
+
/**
|
|
3068
|
+
* JAR request object claims
|
|
3069
|
+
*/
|
|
3070
|
+
interface JARRequestObjectClaims {
|
|
3071
|
+
/** Issuer (client_id) */
|
|
3072
|
+
iss: string;
|
|
3073
|
+
/** Audience (authorization server issuer) */
|
|
3074
|
+
aud: string;
|
|
3075
|
+
/** Response type */
|
|
3076
|
+
response_type: string;
|
|
3077
|
+
/** Client ID */
|
|
3078
|
+
client_id: string;
|
|
3079
|
+
/** Redirect URI */
|
|
3080
|
+
redirect_uri: string;
|
|
3081
|
+
/** Scope */
|
|
3082
|
+
scope: string;
|
|
3083
|
+
/** State */
|
|
3084
|
+
state: string;
|
|
3085
|
+
/** Nonce */
|
|
3086
|
+
nonce: string;
|
|
3087
|
+
/** PKCE code challenge */
|
|
3088
|
+
code_challenge: string;
|
|
3089
|
+
/** PKCE code challenge method */
|
|
3090
|
+
code_challenge_method: string;
|
|
3091
|
+
/** Issued at time (epoch seconds) */
|
|
3092
|
+
iat: number;
|
|
3093
|
+
/** Expiration time (epoch seconds) */
|
|
3094
|
+
exp: number;
|
|
3095
|
+
/** JWT ID (optional but recommended) */
|
|
3096
|
+
jti?: string;
|
|
3097
|
+
/** Not before time (optional) */
|
|
3098
|
+
nbf?: number;
|
|
3099
|
+
/** Prompt */
|
|
3100
|
+
prompt?: string;
|
|
3101
|
+
/** Login hint */
|
|
3102
|
+
login_hint?: string;
|
|
3103
|
+
/** ACR values */
|
|
3104
|
+
acr_values?: string;
|
|
3105
|
+
[key: string]: unknown;
|
|
3106
|
+
}
|
|
3107
|
+
/**
|
|
3108
|
+
* JAR Builder configuration
|
|
3109
|
+
*/
|
|
3110
|
+
interface JARBuilderConfig {
|
|
3111
|
+
/**
|
|
3112
|
+
* Function to sign JWT
|
|
3113
|
+
*
|
|
3114
|
+
* @param header - JWT header object
|
|
3115
|
+
* @param claims - JWT claims object
|
|
3116
|
+
* @returns Signed JWT string
|
|
3117
|
+
*/
|
|
3118
|
+
signJwt: (header: object, claims: object) => Promise<string>;
|
|
3119
|
+
/** Key ID to include in JWT header */
|
|
3120
|
+
keyId?: string;
|
|
3121
|
+
/** Lifetime of the request object in seconds (default: 300) */
|
|
3122
|
+
lifetime?: number;
|
|
3123
|
+
/** Algorithm for signing (e.g., 'RS256', 'ES256') */
|
|
3124
|
+
algorithm?: string;
|
|
3125
|
+
}
|
|
3126
|
+
/**
|
|
3127
|
+
* Options for building a request object
|
|
3128
|
+
*/
|
|
3129
|
+
interface JARRequestOptions {
|
|
3130
|
+
/** Client ID */
|
|
3131
|
+
clientId: string;
|
|
3132
|
+
/** Authorization server issuer */
|
|
3133
|
+
issuer: string;
|
|
3134
|
+
/** Response type (default: 'code') */
|
|
3135
|
+
responseType?: string;
|
|
3136
|
+
/** Redirect URI */
|
|
3137
|
+
redirectUri: string;
|
|
3138
|
+
/** Scope */
|
|
3139
|
+
scope: string;
|
|
3140
|
+
/** State */
|
|
3141
|
+
state: string;
|
|
3142
|
+
/** Nonce */
|
|
3143
|
+
nonce: string;
|
|
3144
|
+
/** PKCE code challenge */
|
|
3145
|
+
codeChallenge: string;
|
|
3146
|
+
/** PKCE code challenge method */
|
|
3147
|
+
codeChallengeMethod: string;
|
|
3148
|
+
/** Prompt */
|
|
3149
|
+
prompt?: string;
|
|
3150
|
+
/** Login hint */
|
|
3151
|
+
loginHint?: string;
|
|
3152
|
+
/** ACR values */
|
|
3153
|
+
acrValues?: string;
|
|
3154
|
+
/** Additional claims */
|
|
3155
|
+
extraClaims?: Record<string, unknown>;
|
|
3156
|
+
}
|
|
3157
|
+
|
|
3158
|
+
/**
|
|
3159
|
+
* JAR Builder
|
|
3160
|
+
* RFC 9101: JWT-Secured Authorization Request (JAR)
|
|
3161
|
+
*
|
|
3162
|
+
* JAR provides a way to send authorization request parameters
|
|
3163
|
+
* in a signed (and optionally encrypted) JWT, ensuring:
|
|
3164
|
+
* - Integrity protection of parameters
|
|
3165
|
+
* - Non-repudiation
|
|
3166
|
+
* - Confidentiality (when encrypted)
|
|
3167
|
+
*
|
|
3168
|
+
* The signed JWT is sent as the 'request' parameter in the authorization URL,
|
|
3169
|
+
* or can be passed by reference using the 'request_uri' parameter (with PAR).
|
|
3170
|
+
*/
|
|
3171
|
+
|
|
3172
|
+
/**
|
|
3173
|
+
* JAR Builder
|
|
3174
|
+
*
|
|
3175
|
+
* Builds signed JWT request objects for authorization requests.
|
|
3176
|
+
*/
|
|
3177
|
+
declare class JARBuilder {
|
|
3178
|
+
private readonly config;
|
|
3179
|
+
constructor(config: JARBuilderConfig);
|
|
3180
|
+
/**
|
|
3181
|
+
* Build a signed request object
|
|
3182
|
+
*
|
|
3183
|
+
* @param options - Request options
|
|
3184
|
+
* @returns Signed JWT request object
|
|
3185
|
+
* @throws AuthrimError with code 'jar_signing_error' if signing fails
|
|
3186
|
+
*/
|
|
3187
|
+
buildRequestObject(options: JARRequestOptions): Promise<string>;
|
|
3188
|
+
/**
|
|
3189
|
+
* Generate a unique JWT ID (jti)
|
|
3190
|
+
*/
|
|
3191
|
+
private generateJti;
|
|
3192
|
+
}
|
|
3193
|
+
/**
|
|
3194
|
+
* Check if JAR is required by the authorization server
|
|
3195
|
+
*
|
|
3196
|
+
* @param discovery - OIDC discovery document
|
|
3197
|
+
* @returns True if require_signed_request_object is true
|
|
3198
|
+
*/
|
|
3199
|
+
declare function isJarRequired(discovery: {
|
|
3200
|
+
require_signed_request_object?: boolean;
|
|
3201
|
+
}): boolean;
|
|
3202
|
+
|
|
3203
|
+
/**
|
|
3204
|
+
* JARM (JWT Secured Authorization Response Mode) Types
|
|
3205
|
+
* Financial-grade API (FAPI) / OpenID Connect
|
|
3206
|
+
*
|
|
3207
|
+
* JARM provides a way for authorization servers to return authorization
|
|
3208
|
+
* response parameters in a signed (and optionally encrypted) JWT.
|
|
3209
|
+
* This provides integrity protection and authenticity verification.
|
|
3210
|
+
*/
|
|
3211
|
+
/**
|
|
3212
|
+
* JARM response JWT claims
|
|
3213
|
+
*/
|
|
3214
|
+
interface JARMResponseClaims {
|
|
3215
|
+
/** Issuer (authorization server) */
|
|
3216
|
+
iss: string;
|
|
3217
|
+
/** Audience (client_id) */
|
|
3218
|
+
aud: string;
|
|
3219
|
+
/** Expiration time (epoch seconds) */
|
|
3220
|
+
exp: number;
|
|
3221
|
+
/** Issued at time (optional) */
|
|
3222
|
+
iat?: number;
|
|
3223
|
+
/** Authorization code */
|
|
3224
|
+
code?: string;
|
|
3225
|
+
/** State parameter */
|
|
3226
|
+
state?: string;
|
|
3227
|
+
/** Error code */
|
|
3228
|
+
error?: string;
|
|
3229
|
+
/** Error description */
|
|
3230
|
+
error_description?: string;
|
|
3231
|
+
/** Error URI */
|
|
3232
|
+
error_uri?: string;
|
|
3233
|
+
[key: string]: unknown;
|
|
3234
|
+
}
|
|
3235
|
+
/**
|
|
3236
|
+
* JARM validation options
|
|
3237
|
+
*/
|
|
3238
|
+
interface JARMValidationOptions {
|
|
3239
|
+
/** Expected state value */
|
|
3240
|
+
expectedState: string;
|
|
3241
|
+
/** Client ID (audience) */
|
|
3242
|
+
clientId: string;
|
|
3243
|
+
/** Clock skew tolerance in seconds (default: 60) */
|
|
3244
|
+
clockSkewSeconds?: number;
|
|
3245
|
+
}
|
|
3246
|
+
/**
|
|
3247
|
+
* JARM validation result
|
|
3248
|
+
*/
|
|
3249
|
+
interface JARMValidationResult {
|
|
3250
|
+
/** Authorization code (if present) */
|
|
3251
|
+
code: string;
|
|
3252
|
+
/** State parameter */
|
|
3253
|
+
state: string;
|
|
3254
|
+
}
|
|
3255
|
+
/**
|
|
3256
|
+
* JARM Validator configuration
|
|
3257
|
+
*/
|
|
3258
|
+
interface JARMValidatorConfig {
|
|
3259
|
+
/**
|
|
3260
|
+
* Function to verify JWT signature
|
|
3261
|
+
*
|
|
3262
|
+
* Should verify the signature using the authorization server's public keys
|
|
3263
|
+
* (typically from JWKS endpoint) and return the decoded claims.
|
|
3264
|
+
*
|
|
3265
|
+
* @param jwt - The JWT string to verify
|
|
3266
|
+
* @param issuer - Expected issuer
|
|
3267
|
+
* @returns Decoded and verified claims
|
|
3268
|
+
* @throws Error if signature verification fails
|
|
3269
|
+
*/
|
|
3270
|
+
verifyJwt: (jwt: string, issuer: string) => Promise<JARMResponseClaims>;
|
|
3271
|
+
}
|
|
3272
|
+
|
|
3273
|
+
/**
|
|
3274
|
+
* JARM Validator
|
|
3275
|
+
* JWT Secured Authorization Response Mode (JARM)
|
|
3276
|
+
*
|
|
3277
|
+
* JARM allows authorization servers to return authorization response
|
|
3278
|
+
* parameters in a signed JWT, providing:
|
|
3279
|
+
* - Response integrity protection
|
|
3280
|
+
* - Response authenticity verification
|
|
3281
|
+
* - Confidentiality (when encrypted)
|
|
3282
|
+
*
|
|
3283
|
+
* The response JWT is returned in the 'response' parameter of the
|
|
3284
|
+
* authorization callback.
|
|
3285
|
+
*/
|
|
3286
|
+
|
|
3287
|
+
/**
|
|
3288
|
+
* JARM Validator
|
|
3289
|
+
*
|
|
3290
|
+
* Validates JWT-secured authorization responses.
|
|
3291
|
+
*/
|
|
3292
|
+
declare class JARMValidator {
|
|
3293
|
+
private readonly config;
|
|
3294
|
+
constructor(config: JARMValidatorConfig);
|
|
3295
|
+
/**
|
|
3296
|
+
* Validate a JARM response
|
|
3297
|
+
*
|
|
3298
|
+
* @param discovery - OIDC discovery document
|
|
3299
|
+
* @param response - The JWT response string from the 'response' parameter
|
|
3300
|
+
* @param options - Validation options
|
|
3301
|
+
* @returns Validated authorization code and state
|
|
3302
|
+
* @throws AuthrimError with code 'jarm_validation_error' if validation fails
|
|
3303
|
+
* @throws AuthrimError with code 'jarm_signature_invalid' if signature verification fails
|
|
3304
|
+
*/
|
|
3305
|
+
validateResponse(discovery: OIDCDiscoveryDocument, response: string, options: JARMValidationOptions): Promise<JARMValidationResult>;
|
|
3306
|
+
/**
|
|
3307
|
+
* Parse a JARM response from callback URL
|
|
3308
|
+
*
|
|
3309
|
+
* Extracts the 'response' parameter from the callback URL.
|
|
3310
|
+
*
|
|
3311
|
+
* @param callbackUrl - Full callback URL or query string
|
|
3312
|
+
* @returns The response JWT, or null if not present
|
|
3313
|
+
*/
|
|
3314
|
+
static extractResponseFromCallback(callbackUrl: string): string | null;
|
|
3315
|
+
}
|
|
3316
|
+
|
|
3317
|
+
/**
|
|
3318
|
+
* Session Management Types
|
|
3319
|
+
* OpenID Connect Session Management 1.0
|
|
3320
|
+
*
|
|
3321
|
+
* These types support session management via check_session_iframe
|
|
3322
|
+
* and related specifications.
|
|
3323
|
+
*
|
|
3324
|
+
* NOTE: Actual implementation of session management (postMessage communication,
|
|
3325
|
+
* iframe handling) is the responsibility of the web SDK (@authrim/web).
|
|
3326
|
+
* Core SDK only provides type definitions.
|
|
3327
|
+
*/
|
|
3328
|
+
/**
|
|
3329
|
+
* Session state from check_session_iframe
|
|
3330
|
+
*/
|
|
3331
|
+
type SessionState = string;
|
|
3332
|
+
/**
|
|
3333
|
+
* Check session iframe message
|
|
3334
|
+
*
|
|
3335
|
+
* Format: "client_id session_state"
|
|
3336
|
+
*/
|
|
3337
|
+
interface CheckSessionMessage {
|
|
3338
|
+
/** Client ID */
|
|
3339
|
+
clientId: string;
|
|
3340
|
+
/** Session state from authentication response */
|
|
3341
|
+
sessionState: SessionState;
|
|
3342
|
+
}
|
|
3343
|
+
/**
|
|
3344
|
+
* Check session iframe response
|
|
3345
|
+
*/
|
|
3346
|
+
type CheckSessionResponse = 'changed' | 'unchanged' | 'error';
|
|
3347
|
+
/**
|
|
3348
|
+
* Session management configuration
|
|
3349
|
+
*/
|
|
3350
|
+
interface SessionManagementConfig {
|
|
3351
|
+
/** check_session_iframe URL from discovery */
|
|
3352
|
+
checkSessionIframe?: string;
|
|
3353
|
+
/** Polling interval in milliseconds (default: 2000) */
|
|
3354
|
+
pollIntervalMs?: number;
|
|
3355
|
+
/** Whether session management is enabled */
|
|
3356
|
+
enabled: boolean;
|
|
3357
|
+
}
|
|
3358
|
+
/**
|
|
3359
|
+
* Session change event
|
|
3360
|
+
*/
|
|
3361
|
+
interface SessionChangeEvent {
|
|
3362
|
+
/** Previous session state */
|
|
3363
|
+
previousState: SessionState | null;
|
|
3364
|
+
/** Current session state */
|
|
3365
|
+
currentState: SessionState | null;
|
|
3366
|
+
/** Whether the session is still valid */
|
|
3367
|
+
isValid: boolean;
|
|
3368
|
+
}
|
|
3369
|
+
/**
|
|
3370
|
+
* Front-Channel Logout Types
|
|
3371
|
+
* OpenID Connect Front-Channel Logout 1.0
|
|
3372
|
+
*
|
|
3373
|
+
* Front-channel logout allows the OP to notify RPs of logout events
|
|
3374
|
+
* via browser redirects.
|
|
3375
|
+
*
|
|
3376
|
+
* NOTE: Actual implementation of front-channel logout (iframe handling)
|
|
3377
|
+
* is the responsibility of the web SDK (@authrim/web).
|
|
3378
|
+
* Core SDK only provides type definitions.
|
|
3379
|
+
*/
|
|
3380
|
+
/**
|
|
3381
|
+
* Front-channel logout request parameters
|
|
3382
|
+
*/
|
|
3383
|
+
interface FrontChannelLogoutParams {
|
|
3384
|
+
/** Issuer identifier */
|
|
3385
|
+
iss?: string;
|
|
3386
|
+
/** Session ID */
|
|
3387
|
+
sid?: string;
|
|
3388
|
+
}
|
|
3389
|
+
/**
|
|
3390
|
+
* Front-channel logout URL builder options
|
|
3391
|
+
*/
|
|
3392
|
+
interface FrontChannelLogoutUrlOptions {
|
|
3393
|
+
/** Base logout URI registered with the OP */
|
|
3394
|
+
logoutUri: string;
|
|
3395
|
+
/** Whether to include issuer parameter */
|
|
3396
|
+
includeIssuer?: boolean;
|
|
3397
|
+
/** Whether to include session ID parameter */
|
|
3398
|
+
includeSessionId?: boolean;
|
|
3399
|
+
}
|
|
3400
|
+
/**
|
|
3401
|
+
* Back-Channel Logout Types
|
|
3402
|
+
* OpenID Connect Back-Channel Logout 1.0
|
|
3403
|
+
*
|
|
3404
|
+
* Back-channel logout allows the OP to notify RPs of logout events
|
|
3405
|
+
* via direct HTTP calls (server-to-server).
|
|
3406
|
+
*
|
|
3407
|
+
* NOTE: This is typically handled server-side, not in the browser.
|
|
3408
|
+
* Included here for completeness of type definitions.
|
|
3409
|
+
*/
|
|
3410
|
+
/**
|
|
3411
|
+
* Logout token claims (for back-channel logout)
|
|
3412
|
+
*/
|
|
3413
|
+
interface LogoutTokenClaims {
|
|
3414
|
+
/** Issuer */
|
|
3415
|
+
iss: string;
|
|
3416
|
+
/** Subject */
|
|
3417
|
+
sub?: string;
|
|
3418
|
+
/** Audience */
|
|
3419
|
+
aud: string | string[];
|
|
3420
|
+
/** Issued at time */
|
|
3421
|
+
iat: number;
|
|
3422
|
+
/** JWT ID */
|
|
3423
|
+
jti: string;
|
|
3424
|
+
/** Events claim (must contain logout event) */
|
|
3425
|
+
events: {
|
|
3426
|
+
'http://schemas.openid.net/event/backchannel-logout': Record<string, never>;
|
|
3427
|
+
};
|
|
3428
|
+
/** Session ID (if back-channel logout session is supported) */
|
|
3429
|
+
sid?: string;
|
|
3430
|
+
}
|
|
3431
|
+
|
|
3432
|
+
/**
|
|
3433
|
+
* Token Manager
|
|
3434
|
+
*
|
|
3435
|
+
* Manages token storage, retrieval, and automatic refresh.
|
|
3436
|
+
* Implements in-flight request coalescing for concurrent refresh requests.
|
|
3437
|
+
*/
|
|
3438
|
+
|
|
3439
|
+
/**
|
|
3440
|
+
* Token manager options
|
|
3441
|
+
*/
|
|
3442
|
+
interface TokenManagerOptions {
|
|
3443
|
+
/** HTTP client */
|
|
3444
|
+
http: HttpClient;
|
|
3445
|
+
/** Storage provider */
|
|
3446
|
+
storage: AuthrimStorage;
|
|
3447
|
+
/** Client ID */
|
|
3448
|
+
clientId: string;
|
|
3449
|
+
/** Issuer hash for storage keys */
|
|
3450
|
+
issuerHash: string;
|
|
3451
|
+
/** Client ID hash for storage keys */
|
|
3452
|
+
clientIdHash: string;
|
|
3453
|
+
/** Refresh skew in seconds (default: 30) */
|
|
3454
|
+
refreshSkewSeconds?: number;
|
|
3455
|
+
/** Event emitter for token events */
|
|
3456
|
+
eventEmitter?: EventEmitter;
|
|
3457
|
+
/** Token expiring warning threshold in seconds (default: 300 = 5 minutes) */
|
|
3458
|
+
expiringThresholdSeconds?: number;
|
|
3459
|
+
/** Jitter for expiring event in milliseconds (default: 30000 = ±30 seconds) */
|
|
3460
|
+
expiringJitterMs?: number;
|
|
3461
|
+
}
|
|
3462
|
+
/**
|
|
3463
|
+
* Token Manager
|
|
3464
|
+
*
|
|
3465
|
+
* Handles token storage, retrieval, and automatic refresh with
|
|
3466
|
+
* concurrent request coalescing.
|
|
3467
|
+
*/
|
|
3468
|
+
declare class TokenManager {
|
|
3469
|
+
private readonly http;
|
|
3470
|
+
private readonly storage;
|
|
3471
|
+
private readonly clientId;
|
|
3472
|
+
private readonly issuerHash;
|
|
3473
|
+
private readonly clientIdHash;
|
|
3474
|
+
private readonly refreshSkewSeconds;
|
|
3475
|
+
private readonly eventEmitter?;
|
|
3476
|
+
private readonly expiringThresholdMs;
|
|
3477
|
+
private readonly expiringJitterMs;
|
|
3478
|
+
/** In-flight refresh promise for request coalescing */
|
|
3479
|
+
private refreshPromise;
|
|
3480
|
+
/** Discovery document (set externally) */
|
|
3481
|
+
private discovery;
|
|
3482
|
+
/** Timer for token expiring event */
|
|
3483
|
+
private expiringTimeout;
|
|
3484
|
+
/** Whether this tab is the leader for refresh scheduling */
|
|
3485
|
+
private isLeaderTab;
|
|
3486
|
+
/** Current operation ID for event tracking */
|
|
3487
|
+
private currentOperationId;
|
|
3488
|
+
/** Default refresh skew: 30 seconds */
|
|
3489
|
+
private static readonly DEFAULT_REFRESH_SKEW_SECONDS;
|
|
3490
|
+
/** Default expiring threshold: 5 minutes */
|
|
3491
|
+
private static readonly DEFAULT_EXPIRING_THRESHOLD_SECONDS;
|
|
3492
|
+
/** Default expiring jitter: ±30 seconds */
|
|
3493
|
+
private static readonly DEFAULT_EXPIRING_JITTER_MS;
|
|
3494
|
+
constructor(options: TokenManagerOptions);
|
|
3495
|
+
/**
|
|
3496
|
+
* Set discovery document
|
|
3497
|
+
*/
|
|
3498
|
+
setDiscovery(discovery: OIDCDiscoveryDocument): void;
|
|
3499
|
+
/**
|
|
3500
|
+
* Get storage key for tokens
|
|
3501
|
+
*/
|
|
3502
|
+
private get tokenKey();
|
|
3503
|
+
/**
|
|
3504
|
+
* Get storage key for ID token
|
|
3505
|
+
*/
|
|
3506
|
+
private get idTokenKey();
|
|
3507
|
+
/**
|
|
3508
|
+
* Get current tokens from storage
|
|
3509
|
+
*
|
|
3510
|
+
* @returns Token set or null if not found
|
|
3511
|
+
*/
|
|
3512
|
+
getTokens(): Promise<TokenSet | null>;
|
|
3513
|
+
/**
|
|
3514
|
+
* Save tokens to storage
|
|
3515
|
+
*
|
|
1784
3516
|
* @param tokens - Token set to save
|
|
1785
3517
|
*/
|
|
1786
|
-
saveTokens(tokens: TokenSet): Promise<void>;
|
|
3518
|
+
saveTokens(tokens: TokenSet): Promise<void>;
|
|
3519
|
+
/**
|
|
3520
|
+
* Schedule token:expiring event with jitter
|
|
3521
|
+
*
|
|
3522
|
+
* @param expiresAt - Token expiration timestamp (epoch seconds)
|
|
3523
|
+
*/
|
|
3524
|
+
private scheduleExpiringEvent;
|
|
3525
|
+
/**
|
|
3526
|
+
* Set leader tab status
|
|
3527
|
+
*
|
|
3528
|
+
* When not the leader, expiring event scheduling is disabled
|
|
3529
|
+
* to prevent multiple tabs from triggering simultaneous refreshes.
|
|
3530
|
+
*
|
|
3531
|
+
* @param isLeader - Whether this tab is the leader
|
|
3532
|
+
*/
|
|
3533
|
+
setLeaderTab(isLeader: boolean): void;
|
|
3534
|
+
/**
|
|
3535
|
+
* Set current operation ID for event tracking
|
|
3536
|
+
*/
|
|
3537
|
+
setOperationId(operationId: string | null): void;
|
|
3538
|
+
/**
|
|
3539
|
+
* Get current operation ID
|
|
3540
|
+
*/
|
|
3541
|
+
getOperationId(): string | null;
|
|
3542
|
+
/**
|
|
3543
|
+
* Clear all tokens from storage
|
|
3544
|
+
*/
|
|
3545
|
+
clearTokens(): Promise<void>;
|
|
3546
|
+
/**
|
|
3547
|
+
* Get access token, refreshing if necessary
|
|
3548
|
+
*
|
|
3549
|
+
* This method coalesces concurrent refresh requests - if multiple
|
|
3550
|
+
* calls are made while a refresh is in-flight, they all share the
|
|
3551
|
+
* same refresh operation.
|
|
3552
|
+
*
|
|
3553
|
+
* @returns Access token
|
|
3554
|
+
* @throws AuthrimError if no tokens available or refresh fails
|
|
3555
|
+
*/
|
|
3556
|
+
getAccessToken(): Promise<string>;
|
|
3557
|
+
/**
|
|
3558
|
+
* Get ID token
|
|
3559
|
+
*
|
|
3560
|
+
* @returns ID token or null
|
|
3561
|
+
*/
|
|
3562
|
+
getIdToken(): Promise<string | null>;
|
|
3563
|
+
/**
|
|
3564
|
+
* Check if token needs refresh
|
|
3565
|
+
*
|
|
3566
|
+
* @param tokens - Token set to check
|
|
3567
|
+
* @returns True if token should be refreshed
|
|
3568
|
+
*/
|
|
3569
|
+
private shouldRefresh;
|
|
3570
|
+
/**
|
|
3571
|
+
* Refresh token with in-flight request coalescing
|
|
3572
|
+
*
|
|
3573
|
+
* If a refresh is already in progress, wait for it instead of
|
|
3574
|
+
* starting a new one.
|
|
3575
|
+
*
|
|
3576
|
+
* @param refreshToken - Refresh token to use
|
|
3577
|
+
* @param reason - Reason for refresh
|
|
3578
|
+
* @returns Access token from new token set
|
|
3579
|
+
*/
|
|
3580
|
+
private refreshWithLock;
|
|
3581
|
+
/**
|
|
3582
|
+
* Manually refresh tokens
|
|
3583
|
+
*
|
|
3584
|
+
* @returns New token set
|
|
3585
|
+
* @throws AuthrimError if refresh fails
|
|
3586
|
+
*/
|
|
3587
|
+
refresh(): Promise<TokenSet>;
|
|
3588
|
+
/**
|
|
3589
|
+
* Perform refresh with retry for network errors
|
|
3590
|
+
*
|
|
3591
|
+
* @param refreshToken - Refresh token to use
|
|
3592
|
+
* @param reason - Reason for refresh
|
|
3593
|
+
* @param attempt - Current retry attempt (0-indexed)
|
|
3594
|
+
* @returns New token set
|
|
3595
|
+
*/
|
|
3596
|
+
private doRefreshWithRetry;
|
|
3597
|
+
/**
|
|
3598
|
+
* Perform the actual token refresh
|
|
3599
|
+
*
|
|
3600
|
+
* @param refreshToken - Refresh token to use
|
|
3601
|
+
* @returns New token set
|
|
3602
|
+
*/
|
|
3603
|
+
private doRefresh;
|
|
3604
|
+
/**
|
|
3605
|
+
* Check if user is authenticated
|
|
3606
|
+
*
|
|
3607
|
+
* @returns True if valid tokens exist
|
|
3608
|
+
*/
|
|
3609
|
+
isAuthenticated(): Promise<boolean>;
|
|
3610
|
+
/**
|
|
3611
|
+
* Exchange a token using RFC 8693 Token Exchange
|
|
3612
|
+
*
|
|
3613
|
+
* This allows exchanging tokens for different audiences or scopes,
|
|
3614
|
+
* delegation scenarios, and cross-service token acquisition.
|
|
3615
|
+
*
|
|
3616
|
+
* @param request - Token exchange request parameters
|
|
3617
|
+
* @returns Token exchange result with new tokens and issued token type
|
|
3618
|
+
* @throws AuthrimError if exchange fails
|
|
3619
|
+
*/
|
|
3620
|
+
exchangeToken(request: TokenExchangeRequest): Promise<TokenExchangeResult>;
|
|
3621
|
+
/**
|
|
3622
|
+
* Map short token type to URI (RFC 8693)
|
|
3623
|
+
*/
|
|
3624
|
+
private mapTokenTypeToUri;
|
|
3625
|
+
/**
|
|
3626
|
+
* Clean up resources
|
|
3627
|
+
*/
|
|
3628
|
+
destroy(): void;
|
|
3629
|
+
}
|
|
3630
|
+
|
|
3631
|
+
/**
|
|
3632
|
+
* Auto Refresh Scheduler
|
|
3633
|
+
*
|
|
3634
|
+
* Automatically refreshes tokens before they expire.
|
|
3635
|
+
* Supports cancellation via AbortController.
|
|
3636
|
+
*/
|
|
3637
|
+
|
|
3638
|
+
/**
|
|
3639
|
+
* Auto refresh options
|
|
3640
|
+
*/
|
|
3641
|
+
interface AutoRefreshOptions {
|
|
3642
|
+
/** Refresh threshold in seconds before expiry (default: 60) */
|
|
3643
|
+
thresholdSeconds?: number;
|
|
3644
|
+
/** Check interval in milliseconds (default: 30000 = 30 seconds) */
|
|
3645
|
+
checkIntervalMs?: number;
|
|
3646
|
+
/** Event emitter for logging/debugging */
|
|
3647
|
+
eventEmitter?: EventEmitter;
|
|
3648
|
+
}
|
|
3649
|
+
/**
|
|
3650
|
+
* Auto Refresh Scheduler
|
|
3651
|
+
*
|
|
3652
|
+
* Schedules automatic token refresh before expiration.
|
|
3653
|
+
* Can be stopped and started as needed.
|
|
3654
|
+
*/
|
|
3655
|
+
declare class AutoRefreshScheduler {
|
|
3656
|
+
private tokenManager;
|
|
3657
|
+
private options;
|
|
3658
|
+
private checkInterval;
|
|
3659
|
+
private abortController;
|
|
3660
|
+
private isRunning;
|
|
3661
|
+
/** Default refresh threshold: 60 seconds */
|
|
3662
|
+
private static readonly DEFAULT_THRESHOLD_SECONDS;
|
|
3663
|
+
/** Default check interval: 30 seconds */
|
|
3664
|
+
private static readonly DEFAULT_CHECK_INTERVAL_MS;
|
|
3665
|
+
constructor(options?: AutoRefreshOptions);
|
|
3666
|
+
/**
|
|
3667
|
+
* Start auto-refresh scheduling
|
|
3668
|
+
*
|
|
3669
|
+
* @param tokenManager - Token manager instance
|
|
3670
|
+
*/
|
|
3671
|
+
start(tokenManager: TokenManager): void;
|
|
3672
|
+
/**
|
|
3673
|
+
* Stop auto-refresh scheduling
|
|
3674
|
+
*/
|
|
3675
|
+
stop(): void;
|
|
3676
|
+
/**
|
|
3677
|
+
* Check if scheduler is running
|
|
3678
|
+
*/
|
|
3679
|
+
get running(): boolean;
|
|
3680
|
+
/**
|
|
3681
|
+
* Get the abort signal for external cancellation support
|
|
3682
|
+
*/
|
|
3683
|
+
get signal(): AbortSignal | null;
|
|
3684
|
+
/**
|
|
3685
|
+
* Check if token needs refresh and perform if needed
|
|
3686
|
+
*/
|
|
3687
|
+
private checkAndRefresh;
|
|
3688
|
+
/**
|
|
3689
|
+
* Force an immediate refresh check
|
|
3690
|
+
*/
|
|
3691
|
+
forceCheck(): Promise<void>;
|
|
3692
|
+
}
|
|
3693
|
+
|
|
3694
|
+
/**
|
|
3695
|
+
* Token API Client
|
|
3696
|
+
*
|
|
3697
|
+
* Provides session verification against the authorization server.
|
|
3698
|
+
* Uses the UserInfo endpoint or custom session check endpoint.
|
|
3699
|
+
*/
|
|
3700
|
+
|
|
3701
|
+
/**
|
|
3702
|
+
* Session check result
|
|
3703
|
+
*/
|
|
3704
|
+
interface SessionCheckResult {
|
|
3705
|
+
/** Whether session is valid */
|
|
3706
|
+
valid: boolean;
|
|
3707
|
+
/** User info if session is valid */
|
|
3708
|
+
user?: UserInfo;
|
|
3709
|
+
/** Error if session is invalid */
|
|
3710
|
+
error?: AuthrimError;
|
|
3711
|
+
}
|
|
3712
|
+
/**
|
|
3713
|
+
* Token API client options
|
|
3714
|
+
*/
|
|
3715
|
+
interface TokenApiClientOptions {
|
|
3716
|
+
/** HTTP client */
|
|
3717
|
+
http: HttpClient;
|
|
3718
|
+
}
|
|
3719
|
+
/**
|
|
3720
|
+
* Token API Client
|
|
3721
|
+
*
|
|
3722
|
+
* Verifies session status with the authorization server.
|
|
3723
|
+
*/
|
|
3724
|
+
declare class TokenApiClient {
|
|
3725
|
+
private readonly http;
|
|
3726
|
+
constructor(options: TokenApiClientOptions);
|
|
3727
|
+
/**
|
|
3728
|
+
* Check session validity by calling UserInfo endpoint
|
|
3729
|
+
*
|
|
3730
|
+
* @param discovery - OIDC discovery document
|
|
3731
|
+
* @param accessToken - Access token to verify
|
|
3732
|
+
* @returns Session check result
|
|
3733
|
+
*/
|
|
3734
|
+
checkSession(discovery: OIDCDiscoveryDocument, accessToken: string): Promise<SessionCheckResult>;
|
|
3735
|
+
/**
|
|
3736
|
+
* Get user info from the authorization server
|
|
3737
|
+
*
|
|
3738
|
+
* @param discovery - OIDC discovery document
|
|
3739
|
+
* @param accessToken - Access token
|
|
3740
|
+
* @returns User info
|
|
3741
|
+
* @throws AuthrimError if request fails
|
|
3742
|
+
*/
|
|
3743
|
+
getUserInfo(discovery: OIDCDiscoveryDocument, accessToken: string): Promise<UserInfo>;
|
|
3744
|
+
}
|
|
3745
|
+
|
|
3746
|
+
/**
|
|
3747
|
+
* Session Manager
|
|
3748
|
+
*
|
|
3749
|
+
* Coordinates session-related operations including checking
|
|
3750
|
+
* session status and retrieving user information.
|
|
3751
|
+
*/
|
|
3752
|
+
|
|
3753
|
+
/**
|
|
3754
|
+
* Session manager options
|
|
3755
|
+
*/
|
|
3756
|
+
interface SessionManagerOptions {
|
|
3757
|
+
/** Token manager */
|
|
3758
|
+
tokenManager: TokenManager;
|
|
3759
|
+
/** Token API client */
|
|
3760
|
+
tokenApiClient: TokenApiClient;
|
|
3761
|
+
}
|
|
3762
|
+
/**
|
|
3763
|
+
* Session Manager
|
|
3764
|
+
*/
|
|
3765
|
+
declare class SessionManager {
|
|
3766
|
+
private readonly tokenManager;
|
|
3767
|
+
private readonly tokenApiClient;
|
|
3768
|
+
/** Discovery document */
|
|
3769
|
+
private discovery;
|
|
3770
|
+
constructor(options: SessionManagerOptions);
|
|
3771
|
+
/**
|
|
3772
|
+
* Set discovery document
|
|
3773
|
+
*/
|
|
3774
|
+
setDiscovery(discovery: OIDCDiscoveryDocument): void;
|
|
1787
3775
|
/**
|
|
1788
|
-
*
|
|
3776
|
+
* Check if user is authenticated locally
|
|
3777
|
+
*
|
|
3778
|
+
* This checks if valid tokens exist in storage.
|
|
3779
|
+
* Does not verify with the authorization server.
|
|
3780
|
+
*
|
|
3781
|
+
* @returns True if tokens exist
|
|
1789
3782
|
*/
|
|
1790
|
-
|
|
3783
|
+
isAuthenticated(): Promise<boolean>;
|
|
3784
|
+
/**
|
|
3785
|
+
* Check session validity with authorization server
|
|
3786
|
+
*
|
|
3787
|
+
* Calls the UserInfo endpoint to verify the session is still valid.
|
|
3788
|
+
*
|
|
3789
|
+
* @returns Session check result
|
|
3790
|
+
*/
|
|
3791
|
+
checkSession(): Promise<SessionCheckResult>;
|
|
3792
|
+
/**
|
|
3793
|
+
* Get user information
|
|
3794
|
+
*
|
|
3795
|
+
* Fetches user info from the UserInfo endpoint.
|
|
3796
|
+
*
|
|
3797
|
+
* @returns User info
|
|
3798
|
+
* @throws AuthrimError if not authenticated or request fails
|
|
3799
|
+
*/
|
|
3800
|
+
getUser(): Promise<UserInfo>;
|
|
3801
|
+
}
|
|
3802
|
+
|
|
3803
|
+
/**
|
|
3804
|
+
* Session State Calculator
|
|
3805
|
+
*
|
|
3806
|
+
* Implements OIDC Session Management 1.0 specification
|
|
3807
|
+
* https://openid.net/specs/openid-connect-session-1_0.html
|
|
3808
|
+
*
|
|
3809
|
+
* session_state = hash(client_id + " " + origin + " " + browser_state + salt) + "." + salt
|
|
3810
|
+
*/
|
|
3811
|
+
|
|
3812
|
+
/**
|
|
3813
|
+
* Parameters for calculating session_state
|
|
3814
|
+
*/
|
|
3815
|
+
interface SessionStateParams {
|
|
3816
|
+
/** OAuth client_id */
|
|
3817
|
+
clientId: string;
|
|
3818
|
+
/** RP origin (e.g., "https://example.com") */
|
|
3819
|
+
origin: string;
|
|
3820
|
+
/**
|
|
3821
|
+
* OP-managed browser state (opaque value)
|
|
3822
|
+
*
|
|
3823
|
+
* Per OIDC Session Management 1.0 spec, this is called "browser_state" but is actually
|
|
3824
|
+
* an opaque value managed by the OP to identify the session at the OP.
|
|
3825
|
+
* It is NOT a value managed by the RP's browser.
|
|
3826
|
+
*/
|
|
3827
|
+
opBrowserState: string;
|
|
3828
|
+
/** Optional salt (generated if not provided) */
|
|
3829
|
+
salt?: string;
|
|
3830
|
+
}
|
|
3831
|
+
/**
|
|
3832
|
+
* Result of session_state calculation
|
|
3833
|
+
*/
|
|
3834
|
+
interface SessionStateResult {
|
|
3835
|
+
/** Full session_state value (hash.salt) */
|
|
3836
|
+
sessionState: string;
|
|
3837
|
+
/** Hash portion of session_state */
|
|
3838
|
+
hash: string;
|
|
3839
|
+
/** Salt used in calculation */
|
|
3840
|
+
salt: string;
|
|
3841
|
+
}
|
|
3842
|
+
/**
|
|
3843
|
+
* Options for SessionStateCalculator
|
|
3844
|
+
*/
|
|
3845
|
+
interface SessionStateCalculatorOptions {
|
|
3846
|
+
/** Crypto provider for hashing */
|
|
3847
|
+
crypto: CryptoProvider;
|
|
3848
|
+
}
|
|
3849
|
+
/**
|
|
3850
|
+
* Session State Calculator
|
|
3851
|
+
*
|
|
3852
|
+
* Calculates and validates session_state values per OIDC Session Management 1.0.
|
|
3853
|
+
*
|
|
3854
|
+
* Usage (OP side - calculating session_state to include in auth response):
|
|
3855
|
+
* ```typescript
|
|
3856
|
+
* const calculator = new SessionStateCalculator({ crypto });
|
|
3857
|
+
* const result = await calculator.calculate({
|
|
3858
|
+
* clientId: 'my-client',
|
|
3859
|
+
* origin: 'https://rp.example.com',
|
|
3860
|
+
* opBrowserState: 'op-session-id-xyz'
|
|
3861
|
+
* });
|
|
3862
|
+
* // result.sessionState -> include in auth response
|
|
3863
|
+
* ```
|
|
3864
|
+
*
|
|
3865
|
+
* Usage (RP check_session_iframe - validating session state):
|
|
3866
|
+
* ```typescript
|
|
3867
|
+
* const isValid = await calculator.validate(sessionState, {
|
|
3868
|
+
* clientId: 'my-client',
|
|
3869
|
+
* origin: 'https://rp.example.com',
|
|
3870
|
+
* opBrowserState: 'op-session-id-xyz'
|
|
3871
|
+
* });
|
|
3872
|
+
* ```
|
|
3873
|
+
*/
|
|
3874
|
+
declare class SessionStateCalculator {
|
|
3875
|
+
private readonly crypto;
|
|
3876
|
+
constructor(options: SessionStateCalculatorOptions);
|
|
3877
|
+
/**
|
|
3878
|
+
* Calculate session_state
|
|
3879
|
+
*
|
|
3880
|
+
* Per OIDC Session Management 1.0:
|
|
3881
|
+
* session_state = hash(client_id + " " + origin + " " + browser_state + salt) + "." + salt
|
|
3882
|
+
*
|
|
3883
|
+
* @param params - Parameters for calculation
|
|
3884
|
+
* @returns Session state result
|
|
3885
|
+
*/
|
|
3886
|
+
calculate(params: SessionStateParams): Promise<SessionStateResult>;
|
|
3887
|
+
/**
|
|
3888
|
+
* Validate session_state
|
|
3889
|
+
*
|
|
3890
|
+
* Uses constant-time comparison to prevent timing attacks.
|
|
3891
|
+
*
|
|
3892
|
+
* @param sessionState - session_state value to validate
|
|
3893
|
+
* @param params - Parameters that should match (without salt, extracted from sessionState)
|
|
3894
|
+
* @returns true if valid
|
|
3895
|
+
*/
|
|
3896
|
+
validate(sessionState: string, params: Omit<SessionStateParams, 'salt'>): Promise<boolean>;
|
|
3897
|
+
/**
|
|
3898
|
+
* Parse session_state into hash and salt components
|
|
3899
|
+
*
|
|
3900
|
+
* @param sessionState - session_state value to parse
|
|
3901
|
+
* @returns Parsed components or null if invalid format
|
|
3902
|
+
*/
|
|
3903
|
+
parse(sessionState: string): {
|
|
3904
|
+
hash: string;
|
|
3905
|
+
salt: string;
|
|
3906
|
+
} | null;
|
|
3907
|
+
}
|
|
3908
|
+
|
|
3909
|
+
/**
|
|
3910
|
+
* Front-Channel Logout URL Builder
|
|
3911
|
+
*
|
|
3912
|
+
* Implements OpenID Connect Front-Channel Logout 1.0
|
|
3913
|
+
* https://openid.net/specs/openid-connect-frontchannel-1_0.html
|
|
3914
|
+
*
|
|
3915
|
+
* Front-channel logout allows the OP to notify RPs of logout events
|
|
3916
|
+
* via browser redirects (iframes loaded by the OP's logout page).
|
|
3917
|
+
*/
|
|
3918
|
+
|
|
3919
|
+
/**
|
|
3920
|
+
* Result of building a front-channel logout URL
|
|
3921
|
+
*/
|
|
3922
|
+
interface FrontChannelLogoutUrlResult {
|
|
3923
|
+
/** Complete logout URL with query parameters */
|
|
3924
|
+
url: string;
|
|
3925
|
+
/** Parameters included in the URL */
|
|
3926
|
+
params: FrontChannelLogoutParams;
|
|
3927
|
+
}
|
|
3928
|
+
/**
|
|
3929
|
+
* Parameters for building a front-channel logout URL
|
|
3930
|
+
*/
|
|
3931
|
+
interface FrontChannelLogoutBuildParams {
|
|
3932
|
+
/** Issuer identifier to include (optional) */
|
|
3933
|
+
iss?: string;
|
|
3934
|
+
/** Session ID to include (optional) */
|
|
3935
|
+
sid?: string;
|
|
3936
|
+
}
|
|
3937
|
+
/**
|
|
3938
|
+
* Validation options for front-channel logout requests
|
|
3939
|
+
*/
|
|
3940
|
+
interface FrontChannelLogoutValidationOptions {
|
|
3941
|
+
/** Expected issuer (for validation) */
|
|
3942
|
+
issuer?: string;
|
|
3943
|
+
/** Expected session ID (for validation) */
|
|
3944
|
+
sessionId?: string;
|
|
3945
|
+
/** Require issuer parameter */
|
|
3946
|
+
requireIss?: boolean;
|
|
3947
|
+
/** Require session ID parameter */
|
|
3948
|
+
requireSid?: boolean;
|
|
3949
|
+
}
|
|
3950
|
+
/**
|
|
3951
|
+
* Result of front-channel logout request validation
|
|
3952
|
+
*/
|
|
3953
|
+
interface FrontChannelLogoutValidationResult {
|
|
3954
|
+
/** Whether the request is valid */
|
|
3955
|
+
valid: boolean;
|
|
3956
|
+
/** Parsed parameters (if valid) */
|
|
3957
|
+
params?: FrontChannelLogoutParams;
|
|
3958
|
+
/** Error message (if invalid) */
|
|
3959
|
+
error?: string;
|
|
3960
|
+
}
|
|
3961
|
+
/**
|
|
3962
|
+
* Front-Channel Logout URL Builder
|
|
3963
|
+
*
|
|
3964
|
+
* Builds and validates front-channel logout URLs per OIDC Front-Channel Logout 1.0.
|
|
3965
|
+
*
|
|
3966
|
+
* Usage (OP side - building logout URL to load in iframe):
|
|
3967
|
+
* ```typescript
|
|
3968
|
+
* const builder = new FrontChannelLogoutUrlBuilder();
|
|
3969
|
+
* const result = builder.build(
|
|
3970
|
+
* { logoutUri: 'https://rp.example.com/logout', includeIssuer: true, includeSessionId: true },
|
|
3971
|
+
* { iss: 'https://op.example.com', sid: 'session-123' }
|
|
3972
|
+
* );
|
|
3973
|
+
* // result.url -> load in iframe
|
|
3974
|
+
* ```
|
|
3975
|
+
*
|
|
3976
|
+
* Usage (RP side - validating incoming logout request):
|
|
3977
|
+
* ```typescript
|
|
3978
|
+
* const result = builder.validateRequest(window.location.href, {
|
|
3979
|
+
* issuer: 'https://op.example.com',
|
|
3980
|
+
* requireIss: true
|
|
3981
|
+
* });
|
|
3982
|
+
* if (result.valid) {
|
|
3983
|
+
* // Perform local logout
|
|
3984
|
+
* }
|
|
3985
|
+
* ```
|
|
3986
|
+
*/
|
|
3987
|
+
declare class FrontChannelLogoutUrlBuilder {
|
|
3988
|
+
/**
|
|
3989
|
+
* Build a front-channel logout URL
|
|
3990
|
+
*
|
|
3991
|
+
* @param options - URL configuration options
|
|
3992
|
+
* @param params - Parameters to include in the URL
|
|
3993
|
+
* @returns Built URL and included parameters
|
|
3994
|
+
*/
|
|
3995
|
+
build(options: FrontChannelLogoutUrlOptions, params: FrontChannelLogoutBuildParams): FrontChannelLogoutUrlResult;
|
|
3996
|
+
/**
|
|
3997
|
+
* Parse parameters from a front-channel logout URL
|
|
3998
|
+
*
|
|
3999
|
+
* @param url - URL or URL string to parse
|
|
4000
|
+
* @returns Parsed parameters
|
|
4001
|
+
*/
|
|
4002
|
+
parseParams(url: string | URL): FrontChannelLogoutParams;
|
|
4003
|
+
/**
|
|
4004
|
+
* Validate a front-channel logout request
|
|
4005
|
+
*
|
|
4006
|
+
* Uses constant-time comparison for security-sensitive values to prevent timing attacks.
|
|
4007
|
+
*
|
|
4008
|
+
* @param url - URL to validate
|
|
4009
|
+
* @param expected - Expected values and requirements
|
|
4010
|
+
* @returns Validation result
|
|
4011
|
+
*/
|
|
4012
|
+
validateRequest(url: string | URL, expected?: FrontChannelLogoutValidationOptions): FrontChannelLogoutValidationResult;
|
|
4013
|
+
}
|
|
4014
|
+
|
|
4015
|
+
/**
|
|
4016
|
+
* JWT Utilities
|
|
4017
|
+
*
|
|
4018
|
+
* Note: This module only provides decoding (parsing) functionality.
|
|
4019
|
+
* JWT signature verification MUST be performed by the server.
|
|
4020
|
+
* Never trust decoded JWT claims without server-side verification.
|
|
4021
|
+
*/
|
|
4022
|
+
|
|
4023
|
+
/**
|
|
4024
|
+
* JWT Header
|
|
4025
|
+
*/
|
|
4026
|
+
interface JwtHeader {
|
|
4027
|
+
alg: string;
|
|
4028
|
+
typ?: string;
|
|
4029
|
+
kid?: string;
|
|
4030
|
+
[key: string]: unknown;
|
|
4031
|
+
}
|
|
4032
|
+
/**
|
|
4033
|
+
* Decoded JWT structure
|
|
4034
|
+
*/
|
|
4035
|
+
interface DecodedJwt<T = Record<string, unknown>> {
|
|
4036
|
+
header: JwtHeader;
|
|
4037
|
+
payload: T;
|
|
4038
|
+
signature: string;
|
|
4039
|
+
}
|
|
4040
|
+
/**
|
|
4041
|
+
* Decode a JWT without verifying the signature
|
|
4042
|
+
*
|
|
4043
|
+
* WARNING: This function does NOT verify the JWT signature.
|
|
4044
|
+
* Use this only for reading claims after the token has been
|
|
4045
|
+
* validated by the authorization server.
|
|
4046
|
+
*
|
|
4047
|
+
* @param jwt - JWT string to decode
|
|
4048
|
+
* @returns Decoded JWT parts
|
|
4049
|
+
* @throws Error if the JWT format is invalid
|
|
4050
|
+
*/
|
|
4051
|
+
declare function decodeJwt<T = Record<string, unknown>>(jwt: string): DecodedJwt<T>;
|
|
4052
|
+
/**
|
|
4053
|
+
* Decode an ID token and extract claims
|
|
4054
|
+
*
|
|
4055
|
+
* WARNING: This function does NOT verify the ID token.
|
|
4056
|
+
* The token MUST be verified by the authorization server before use.
|
|
4057
|
+
*
|
|
4058
|
+
* @param idToken - ID token string
|
|
4059
|
+
* @returns ID token claims
|
|
4060
|
+
*/
|
|
4061
|
+
declare function decodeIdToken(idToken: string): IdTokenClaims;
|
|
4062
|
+
/**
|
|
4063
|
+
* Check if a JWT is expired
|
|
4064
|
+
*
|
|
4065
|
+
* @param jwt - Decoded JWT payload with exp claim
|
|
4066
|
+
* @param skewSeconds - Clock skew tolerance in seconds (default: 0)
|
|
4067
|
+
* @returns true if expired
|
|
4068
|
+
*/
|
|
4069
|
+
declare function isJwtExpired(payload: {
|
|
4070
|
+
exp?: number;
|
|
4071
|
+
}, skewSeconds?: number): boolean;
|
|
4072
|
+
/**
|
|
4073
|
+
* Get the nonce claim from an ID token
|
|
4074
|
+
*
|
|
4075
|
+
* @param idToken - ID token string
|
|
4076
|
+
* @returns nonce value or undefined
|
|
4077
|
+
*/
|
|
4078
|
+
declare function getIdTokenNonce(idToken: string): string | undefined;
|
|
4079
|
+
|
|
4080
|
+
/**
|
|
4081
|
+
* Back-Channel Logout Validator
|
|
4082
|
+
*
|
|
4083
|
+
* Implements OpenID Connect Back-Channel Logout 1.0
|
|
4084
|
+
* https://openid.net/specs/openid-connect-backchannel-1_0.html
|
|
4085
|
+
*
|
|
4086
|
+
* Back-channel logout allows the OP to notify RPs of logout events
|
|
4087
|
+
* via direct HTTP calls (server-to-server).
|
|
4088
|
+
*
|
|
4089
|
+
* NOTE: This validator performs claims validation only.
|
|
4090
|
+
* JWT signature verification MUST be performed separately using JWKS.
|
|
4091
|
+
*/
|
|
4092
|
+
|
|
4093
|
+
/**
|
|
4094
|
+
* Back-channel logout event URI
|
|
4095
|
+
*/
|
|
4096
|
+
declare const BACKCHANNEL_LOGOUT_EVENT = "http://schemas.openid.net/event/backchannel-logout";
|
|
4097
|
+
/**
|
|
4098
|
+
* Back-channel logout validation error codes
|
|
4099
|
+
*/
|
|
4100
|
+
type BackChannelLogoutErrorCode = 'invalid_format' | 'invalid_issuer' | 'invalid_audience' | 'invalid_events' | 'expired' | 'not_yet_valid' | 'missing_sub_and_sid' | 'sub_mismatch' | 'sid_mismatch' | 'missing_jti' | 'nonce_present';
|
|
4101
|
+
/**
|
|
4102
|
+
* Options for validating a logout token
|
|
4103
|
+
*/
|
|
4104
|
+
interface BackChannelLogoutValidationOptions {
|
|
4105
|
+
/** Expected issuer */
|
|
4106
|
+
issuer: string;
|
|
4107
|
+
/** Expected audience (client_id) */
|
|
4108
|
+
audience: string;
|
|
4109
|
+
/** Maximum age in seconds (default: 60) */
|
|
4110
|
+
maxAge?: number;
|
|
4111
|
+
/** Clock skew tolerance in seconds (default: 30) */
|
|
4112
|
+
clockSkew?: number;
|
|
4113
|
+
/** Expected session ID (optional) */
|
|
4114
|
+
expectedSid?: string;
|
|
4115
|
+
/** Expected subject (optional) */
|
|
4116
|
+
expectedSub?: string;
|
|
4117
|
+
}
|
|
4118
|
+
/**
|
|
4119
|
+
* Result of back-channel logout token validation
|
|
4120
|
+
*/
|
|
4121
|
+
interface BackChannelLogoutValidationResult {
|
|
4122
|
+
/** Whether the token is valid */
|
|
4123
|
+
valid: boolean;
|
|
4124
|
+
/** Validated claims (if valid) */
|
|
4125
|
+
claims?: LogoutTokenClaims;
|
|
4126
|
+
/** JWT header (if valid) */
|
|
4127
|
+
header?: JwtHeader;
|
|
4128
|
+
/** Error message (if invalid) */
|
|
4129
|
+
error?: string;
|
|
4130
|
+
/** Error code (if invalid) */
|
|
4131
|
+
errorCode?: BackChannelLogoutErrorCode;
|
|
4132
|
+
}
|
|
4133
|
+
/**
|
|
4134
|
+
* Back-Channel Logout Validator
|
|
4135
|
+
*
|
|
4136
|
+
* Validates logout_token JWTs per OIDC Back-Channel Logout 1.0.
|
|
4137
|
+
*
|
|
4138
|
+
* ## Security Notes
|
|
4139
|
+
*
|
|
4140
|
+
* 1. **JWT Signature Verification**: This class performs claims validation only.
|
|
4141
|
+
* JWT signature verification MUST be performed separately using JWKS
|
|
4142
|
+
* before calling validate().
|
|
4143
|
+
*
|
|
4144
|
+
* 2. **JTI Replay Protection**: This validator checks for jti presence only.
|
|
4145
|
+
* The application MUST implement jti replay protection by:
|
|
4146
|
+
* - Storing used jti values (at least until token expiry + clock skew)
|
|
4147
|
+
* - Rejecting tokens with previously-used jti values
|
|
4148
|
+
*
|
|
4149
|
+
* Usage (Node.js server receiving back-channel logout request):
|
|
4150
|
+
* ```typescript
|
|
4151
|
+
* // 1. Receive logout_token from POST body
|
|
4152
|
+
* const logoutToken = req.body.logout_token;
|
|
4153
|
+
*
|
|
4154
|
+
* // 2. Verify JWT signature using JWKS (not shown - use jose or similar)
|
|
4155
|
+
* await verifyJwtSignature(logoutToken, jwks);
|
|
4156
|
+
*
|
|
4157
|
+
* // 3. Validate claims
|
|
4158
|
+
* const validator = new BackChannelLogoutValidator();
|
|
4159
|
+
* const result = validator.validate(logoutToken, {
|
|
4160
|
+
* issuer: 'https://op.example.com',
|
|
4161
|
+
* audience: 'my-client-id'
|
|
4162
|
+
* });
|
|
4163
|
+
*
|
|
4164
|
+
* if (!result.valid) {
|
|
4165
|
+
* return res.status(400).send('Invalid logout token');
|
|
4166
|
+
* }
|
|
4167
|
+
*
|
|
4168
|
+
* // 4. Check for jti replay (application responsibility)
|
|
4169
|
+
* if (await jtiStore.has(result.claims.jti)) {
|
|
4170
|
+
* return res.status(400).send('Token replay detected');
|
|
4171
|
+
* }
|
|
4172
|
+
* await jtiStore.set(result.claims.jti, true, maxAge + clockSkew);
|
|
4173
|
+
*
|
|
4174
|
+
* // 5. Perform logout for sub and/or sid
|
|
4175
|
+
* await logoutUser(result.claims.sub, result.claims.sid);
|
|
4176
|
+
* ```
|
|
4177
|
+
*/
|
|
4178
|
+
declare class BackChannelLogoutValidator {
|
|
4179
|
+
/**
|
|
4180
|
+
* Validate a logout_token
|
|
4181
|
+
*
|
|
4182
|
+
* Per OIDC Back-Channel Logout 1.0, the logout_token MUST:
|
|
4183
|
+
* - Be a valid JWT
|
|
4184
|
+
* - Contain iss, aud, iat, jti claims
|
|
4185
|
+
* - Contain events claim with back-channel logout event
|
|
4186
|
+
* - Contain either sub or sid (or both)
|
|
4187
|
+
* - NOT contain a nonce claim
|
|
4188
|
+
*
|
|
4189
|
+
* @param logoutToken - JWT logout token to validate
|
|
4190
|
+
* @param options - Validation options
|
|
4191
|
+
* @returns Validation result
|
|
4192
|
+
*/
|
|
4193
|
+
validate(logoutToken: string, options: BackChannelLogoutValidationOptions): BackChannelLogoutValidationResult;
|
|
4194
|
+
/**
|
|
4195
|
+
* Extract claims from a logout token without validation
|
|
4196
|
+
*
|
|
4197
|
+
* Useful for inspecting the token before/during validation.
|
|
4198
|
+
*
|
|
4199
|
+
* @param logoutToken - JWT logout token
|
|
4200
|
+
* @returns Claims or null if invalid format
|
|
4201
|
+
*/
|
|
4202
|
+
extractClaims(logoutToken: string): LogoutTokenClaims | null;
|
|
4203
|
+
/**
|
|
4204
|
+
* Extract header from a logout token without validation
|
|
4205
|
+
*
|
|
4206
|
+
* Useful for getting kid to select the correct JWKS key.
|
|
4207
|
+
*
|
|
4208
|
+
* @param logoutToken - JWT logout token
|
|
4209
|
+
* @returns Header or null if invalid format
|
|
4210
|
+
*/
|
|
4211
|
+
extractHeader(logoutToken: string): JwtHeader | null;
|
|
4212
|
+
}
|
|
4213
|
+
|
|
4214
|
+
/**
|
|
4215
|
+
* Debug Module Types
|
|
4216
|
+
*
|
|
4217
|
+
* Types for debugging and observability features.
|
|
4218
|
+
*/
|
|
4219
|
+
/**
|
|
4220
|
+
* Debug options for SDK initialization
|
|
4221
|
+
*/
|
|
4222
|
+
interface DebugOptions {
|
|
4223
|
+
/** Enable debug mode */
|
|
4224
|
+
enabled: boolean;
|
|
4225
|
+
/** Enable verbose logging */
|
|
4226
|
+
verbose?: boolean;
|
|
4227
|
+
/** Include timestamps in logs */
|
|
4228
|
+
logTimestamps?: boolean;
|
|
4229
|
+
/** Custom logger implementation */
|
|
4230
|
+
logger?: DebugLogger;
|
|
4231
|
+
/** Maximum events to keep in timeline (default: 100) */
|
|
4232
|
+
maxTimelineEvents?: number;
|
|
4233
|
+
/** Redaction level for sensitive data */
|
|
4234
|
+
redactLevel?: RedactLevel;
|
|
4235
|
+
}
|
|
4236
|
+
/**
|
|
4237
|
+
* Debug logger interface
|
|
4238
|
+
*/
|
|
4239
|
+
interface DebugLogger {
|
|
4240
|
+
/** Log a message with optional data */
|
|
4241
|
+
log(level: DebugLogLevel, message: string, data?: unknown): void;
|
|
4242
|
+
}
|
|
4243
|
+
/**
|
|
4244
|
+
* Debug log levels
|
|
4245
|
+
*/
|
|
4246
|
+
type DebugLogLevel = 'debug' | 'info' | 'warn' | 'error';
|
|
4247
|
+
/**
|
|
4248
|
+
* Redaction level for sensitive data
|
|
4249
|
+
*
|
|
4250
|
+
* - 'default': Mask token values, keep structure
|
|
4251
|
+
* - 'none': No redaction (only for development)
|
|
4252
|
+
* - 'aggressive': Mask tokens and URL parameters
|
|
4253
|
+
*/
|
|
4254
|
+
type RedactLevel = 'default' | 'none' | 'aggressive';
|
|
4255
|
+
|
|
4256
|
+
/**
|
|
4257
|
+
* Event Timeline
|
|
4258
|
+
*
|
|
4259
|
+
* Records SDK events for debugging and observability.
|
|
4260
|
+
* All sensitive data is automatically redacted.
|
|
4261
|
+
*/
|
|
4262
|
+
|
|
4263
|
+
/**
|
|
4264
|
+
* Event Timeline for debugging
|
|
4265
|
+
*
|
|
4266
|
+
* Records events with automatic redaction of sensitive data.
|
|
4267
|
+
* Safe to use in production - no sensitive data is stored.
|
|
4268
|
+
*/
|
|
4269
|
+
declare class EventTimeline {
|
|
4270
|
+
private entries;
|
|
4271
|
+
private maxEvents;
|
|
4272
|
+
private redactLevel;
|
|
4273
|
+
constructor(options?: {
|
|
4274
|
+
maxEvents?: number;
|
|
4275
|
+
redactLevel?: RedactLevel;
|
|
4276
|
+
});
|
|
1791
4277
|
/**
|
|
1792
|
-
*
|
|
4278
|
+
* Record an event to the timeline
|
|
1793
4279
|
*
|
|
1794
|
-
*
|
|
1795
|
-
* calls are made while a refresh is in-flight, they all share the
|
|
1796
|
-
* same refresh operation.
|
|
4280
|
+
* Data is automatically redacted based on redact level.
|
|
1797
4281
|
*
|
|
1798
|
-
* @
|
|
1799
|
-
* @
|
|
4282
|
+
* @param type - Event type
|
|
4283
|
+
* @param data - Event data (will be redacted)
|
|
4284
|
+
* @param options - Recording options
|
|
1800
4285
|
*/
|
|
1801
|
-
|
|
4286
|
+
record(type: string, data?: unknown, options?: {
|
|
4287
|
+
operationId?: string;
|
|
4288
|
+
redact?: RedactLevel;
|
|
4289
|
+
}): void;
|
|
1802
4290
|
/**
|
|
1803
|
-
* Get
|
|
4291
|
+
* Get recent entries
|
|
1804
4292
|
*
|
|
1805
|
-
* @
|
|
4293
|
+
* @param count - Number of entries to return (default: all)
|
|
4294
|
+
* @returns Recent timeline entries
|
|
1806
4295
|
*/
|
|
1807
|
-
|
|
4296
|
+
getRecent(count?: number): TimelineEntry[];
|
|
1808
4297
|
/**
|
|
1809
|
-
*
|
|
4298
|
+
* Get entries for a specific operation
|
|
1810
4299
|
*
|
|
1811
|
-
* @param
|
|
1812
|
-
* @returns
|
|
4300
|
+
* @param operationId - Operation ID to filter by
|
|
4301
|
+
* @returns Entries for the operation
|
|
1813
4302
|
*/
|
|
1814
|
-
|
|
4303
|
+
getByOperationId(operationId: string): TimelineEntry[];
|
|
1815
4304
|
/**
|
|
1816
|
-
*
|
|
1817
|
-
*
|
|
1818
|
-
* If a refresh is already in progress, wait for it instead of
|
|
1819
|
-
* starting a new one.
|
|
4305
|
+
* Get entries by event type
|
|
1820
4306
|
*
|
|
1821
|
-
* @param
|
|
1822
|
-
* @returns
|
|
4307
|
+
* @param type - Event type to filter by
|
|
4308
|
+
* @returns Entries matching the type
|
|
1823
4309
|
*/
|
|
1824
|
-
|
|
4310
|
+
getByType(type: string): TimelineEntry[];
|
|
1825
4311
|
/**
|
|
1826
|
-
*
|
|
1827
|
-
*
|
|
1828
|
-
* @param refreshToken - Refresh token to use
|
|
1829
|
-
* @param attemptedRetry - Internal flag to prevent infinite recursion (do not pass externally)
|
|
1830
|
-
* @returns New token set
|
|
4312
|
+
* Clear all entries
|
|
1831
4313
|
*/
|
|
1832
|
-
|
|
4314
|
+
clear(): void;
|
|
1833
4315
|
/**
|
|
1834
|
-
*
|
|
1835
|
-
*
|
|
1836
|
-
* @param refreshToken - Refresh token to use
|
|
1837
|
-
* @returns New token set
|
|
4316
|
+
* Get entry count
|
|
1838
4317
|
*/
|
|
1839
|
-
|
|
4318
|
+
get length(): number;
|
|
1840
4319
|
/**
|
|
1841
|
-
*
|
|
4320
|
+
* Convert timeline to JSON string (for export/logging)
|
|
1842
4321
|
*/
|
|
1843
|
-
|
|
4322
|
+
toJSON(): string;
|
|
1844
4323
|
/**
|
|
1845
|
-
*
|
|
1846
|
-
*
|
|
1847
|
-
* @returns True if valid tokens exist
|
|
4324
|
+
* Set redaction level
|
|
1848
4325
|
*/
|
|
1849
|
-
|
|
4326
|
+
setRedactLevel(level: RedactLevel): void;
|
|
1850
4327
|
/**
|
|
1851
|
-
*
|
|
1852
|
-
*
|
|
1853
|
-
* This allows exchanging tokens for different audiences or scopes,
|
|
1854
|
-
* delegation scenarios, and cross-service token acquisition.
|
|
1855
|
-
*
|
|
1856
|
-
* @param request - Token exchange request parameters
|
|
1857
|
-
* @returns Token exchange result with new tokens and issued token type
|
|
1858
|
-
* @throws AuthrimError if exchange fails
|
|
4328
|
+
* Redact sensitive data from event payload
|
|
1859
4329
|
*/
|
|
1860
|
-
|
|
4330
|
+
private redactData;
|
|
1861
4331
|
/**
|
|
1862
|
-
*
|
|
4332
|
+
* Deep redact an object
|
|
1863
4333
|
*/
|
|
1864
|
-
private
|
|
4334
|
+
private deepRedact;
|
|
4335
|
+
/**
|
|
4336
|
+
* Check if a key is sensitive
|
|
4337
|
+
*/
|
|
4338
|
+
private isSensitiveKey;
|
|
4339
|
+
/**
|
|
4340
|
+
* Redact sensitive URL parameters
|
|
4341
|
+
*/
|
|
4342
|
+
private redactUrl;
|
|
1865
4343
|
}
|
|
1866
4344
|
|
|
1867
4345
|
/**
|
|
1868
|
-
*
|
|
4346
|
+
* Debug Logger
|
|
1869
4347
|
*
|
|
1870
|
-
*
|
|
1871
|
-
* Uses the UserInfo endpoint or custom session check endpoint.
|
|
4348
|
+
* Platform-agnostic logging infrastructure for SDK debugging.
|
|
1872
4349
|
*/
|
|
1873
4350
|
|
|
1874
4351
|
/**
|
|
1875
|
-
*
|
|
4352
|
+
* Create a console-based debug logger
|
|
4353
|
+
*
|
|
4354
|
+
* This logger writes to console with Authrim-prefixed messages.
|
|
4355
|
+
* Safe to use with any console implementation.
|
|
1876
4356
|
*/
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
/** User info if session is valid */
|
|
1881
|
-
user?: UserInfo;
|
|
1882
|
-
/** Error if session is invalid */
|
|
1883
|
-
error?: AuthrimError;
|
|
1884
|
-
}
|
|
4357
|
+
declare function createConsoleLogger(options?: {
|
|
4358
|
+
timestamps?: boolean;
|
|
4359
|
+
}): DebugLogger;
|
|
1885
4360
|
/**
|
|
1886
|
-
*
|
|
4361
|
+
* No-op logger for when debug mode is disabled
|
|
1887
4362
|
*/
|
|
1888
|
-
|
|
1889
|
-
/** HTTP client */
|
|
1890
|
-
http: HttpClient;
|
|
1891
|
-
}
|
|
4363
|
+
declare const noopLogger: DebugLogger;
|
|
1892
4364
|
/**
|
|
1893
|
-
*
|
|
1894
|
-
*
|
|
1895
|
-
* Verifies session status with the authorization server.
|
|
4365
|
+
* Create a debug logger based on options
|
|
1896
4366
|
*/
|
|
1897
|
-
declare
|
|
1898
|
-
|
|
1899
|
-
|
|
4367
|
+
declare function createDebugLogger(options: DebugOptions): DebugLogger;
|
|
4368
|
+
/**
|
|
4369
|
+
* Debug context for tracking operations
|
|
4370
|
+
*/
|
|
4371
|
+
declare class DebugContext {
|
|
4372
|
+
private logger;
|
|
4373
|
+
private verbose;
|
|
4374
|
+
private operationId;
|
|
4375
|
+
constructor(logger: DebugLogger, options?: {
|
|
4376
|
+
verbose?: boolean;
|
|
4377
|
+
});
|
|
1900
4378
|
/**
|
|
1901
|
-
*
|
|
1902
|
-
*
|
|
1903
|
-
* @param discovery - OIDC discovery document
|
|
1904
|
-
* @param accessToken - Access token to verify
|
|
1905
|
-
* @returns Session check result
|
|
4379
|
+
* Set current operation ID for log correlation
|
|
1906
4380
|
*/
|
|
1907
|
-
|
|
4381
|
+
setOperationId(id: string | null): void;
|
|
1908
4382
|
/**
|
|
1909
|
-
* Get
|
|
1910
|
-
*
|
|
1911
|
-
* @param discovery - OIDC discovery document
|
|
1912
|
-
* @param accessToken - Access token
|
|
1913
|
-
* @returns User info
|
|
1914
|
-
* @throws AuthrimError if request fails
|
|
4383
|
+
* Get current operation ID
|
|
1915
4384
|
*/
|
|
1916
|
-
|
|
1917
|
-
}
|
|
1918
|
-
|
|
1919
|
-
/**
|
|
1920
|
-
* Session Manager
|
|
1921
|
-
*
|
|
1922
|
-
* Coordinates session-related operations including checking
|
|
1923
|
-
* session status and retrieving user information.
|
|
1924
|
-
*/
|
|
1925
|
-
|
|
1926
|
-
/**
|
|
1927
|
-
* Session manager options
|
|
1928
|
-
*/
|
|
1929
|
-
interface SessionManagerOptions {
|
|
1930
|
-
/** Token manager */
|
|
1931
|
-
tokenManager: TokenManager;
|
|
1932
|
-
/** Token API client */
|
|
1933
|
-
tokenApiClient: TokenApiClient;
|
|
1934
|
-
}
|
|
1935
|
-
/**
|
|
1936
|
-
* Session Manager
|
|
1937
|
-
*/
|
|
1938
|
-
declare class SessionManager {
|
|
1939
|
-
private readonly tokenManager;
|
|
1940
|
-
private readonly tokenApiClient;
|
|
1941
|
-
/** Discovery document */
|
|
1942
|
-
private discovery;
|
|
1943
|
-
constructor(options: SessionManagerOptions);
|
|
4385
|
+
getOperationId(): string | null;
|
|
1944
4386
|
/**
|
|
1945
|
-
*
|
|
4387
|
+
* Log a debug message (verbose mode only)
|
|
1946
4388
|
*/
|
|
1947
|
-
|
|
4389
|
+
debug(message: string, data?: unknown): void;
|
|
1948
4390
|
/**
|
|
1949
|
-
*
|
|
1950
|
-
*
|
|
1951
|
-
* This checks if valid tokens exist in storage.
|
|
1952
|
-
* Does not verify with the authorization server.
|
|
1953
|
-
*
|
|
1954
|
-
* @returns True if tokens exist
|
|
4391
|
+
* Log an info message
|
|
1955
4392
|
*/
|
|
1956
|
-
|
|
4393
|
+
info(message: string, data?: unknown): void;
|
|
1957
4394
|
/**
|
|
1958
|
-
*
|
|
1959
|
-
*
|
|
1960
|
-
* Calls the UserInfo endpoint to verify the session is still valid.
|
|
1961
|
-
*
|
|
1962
|
-
* @returns Session check result
|
|
4395
|
+
* Log a warning message
|
|
1963
4396
|
*/
|
|
1964
|
-
|
|
4397
|
+
warn(message: string, data?: unknown): void;
|
|
1965
4398
|
/**
|
|
1966
|
-
*
|
|
1967
|
-
*
|
|
1968
|
-
* Fetches user info from the UserInfo endpoint.
|
|
1969
|
-
*
|
|
1970
|
-
* @returns User info
|
|
1971
|
-
* @throws AuthrimError if not authenticated or request fails
|
|
4399
|
+
* Log an error message
|
|
1972
4400
|
*/
|
|
1973
|
-
|
|
4401
|
+
error(message: string, data?: unknown): void;
|
|
4402
|
+
/**
|
|
4403
|
+
* Format message with operation ID if available
|
|
4404
|
+
*/
|
|
4405
|
+
private formatMessage;
|
|
1974
4406
|
}
|
|
1975
4407
|
|
|
1976
4408
|
/**
|
|
@@ -2008,71 +4440,6 @@ declare function stringToBase64url(str: string): string;
|
|
|
2008
4440
|
*/
|
|
2009
4441
|
declare function base64urlToString(base64url: string): string;
|
|
2010
4442
|
|
|
2011
|
-
/**
|
|
2012
|
-
* JWT Utilities
|
|
2013
|
-
*
|
|
2014
|
-
* Note: This module only provides decoding (parsing) functionality.
|
|
2015
|
-
* JWT signature verification MUST be performed by the server.
|
|
2016
|
-
* Never trust decoded JWT claims without server-side verification.
|
|
2017
|
-
*/
|
|
2018
|
-
|
|
2019
|
-
/**
|
|
2020
|
-
* JWT Header
|
|
2021
|
-
*/
|
|
2022
|
-
interface JwtHeader {
|
|
2023
|
-
alg: string;
|
|
2024
|
-
typ?: string;
|
|
2025
|
-
kid?: string;
|
|
2026
|
-
[key: string]: unknown;
|
|
2027
|
-
}
|
|
2028
|
-
/**
|
|
2029
|
-
* Decoded JWT structure
|
|
2030
|
-
*/
|
|
2031
|
-
interface DecodedJwt<T = Record<string, unknown>> {
|
|
2032
|
-
header: JwtHeader;
|
|
2033
|
-
payload: T;
|
|
2034
|
-
signature: string;
|
|
2035
|
-
}
|
|
2036
|
-
/**
|
|
2037
|
-
* Decode a JWT without verifying the signature
|
|
2038
|
-
*
|
|
2039
|
-
* WARNING: This function does NOT verify the JWT signature.
|
|
2040
|
-
* Use this only for reading claims after the token has been
|
|
2041
|
-
* validated by the authorization server.
|
|
2042
|
-
*
|
|
2043
|
-
* @param jwt - JWT string to decode
|
|
2044
|
-
* @returns Decoded JWT parts
|
|
2045
|
-
* @throws Error if the JWT format is invalid
|
|
2046
|
-
*/
|
|
2047
|
-
declare function decodeJwt<T = Record<string, unknown>>(jwt: string): DecodedJwt<T>;
|
|
2048
|
-
/**
|
|
2049
|
-
* Decode an ID token and extract claims
|
|
2050
|
-
*
|
|
2051
|
-
* WARNING: This function does NOT verify the ID token.
|
|
2052
|
-
* The token MUST be verified by the authorization server before use.
|
|
2053
|
-
*
|
|
2054
|
-
* @param idToken - ID token string
|
|
2055
|
-
* @returns ID token claims
|
|
2056
|
-
*/
|
|
2057
|
-
declare function decodeIdToken(idToken: string): IdTokenClaims;
|
|
2058
|
-
/**
|
|
2059
|
-
* Check if a JWT is expired
|
|
2060
|
-
*
|
|
2061
|
-
* @param jwt - Decoded JWT payload with exp claim
|
|
2062
|
-
* @param skewSeconds - Clock skew tolerance in seconds (default: 0)
|
|
2063
|
-
* @returns true if expired
|
|
2064
|
-
*/
|
|
2065
|
-
declare function isJwtExpired(payload: {
|
|
2066
|
-
exp?: number;
|
|
2067
|
-
}, skewSeconds?: number): boolean;
|
|
2068
|
-
/**
|
|
2069
|
-
* Get the nonce claim from an ID token
|
|
2070
|
-
*
|
|
2071
|
-
* @param idToken - ID token string
|
|
2072
|
-
* @returns nonce value or undefined
|
|
2073
|
-
*/
|
|
2074
|
-
declare function getIdTokenNonce(idToken: string): string | undefined;
|
|
2075
|
-
|
|
2076
4443
|
/**
|
|
2077
4444
|
* Hash Utilities
|
|
2078
4445
|
*
|
|
@@ -2121,6 +4488,121 @@ declare function calculateDsHash(deviceSecret: string, crypto: CryptoProvider):
|
|
|
2121
4488
|
*/
|
|
2122
4489
|
declare function timingSafeEqual(a: string, b: string): boolean;
|
|
2123
4490
|
|
|
4491
|
+
/**
|
|
4492
|
+
* Cancellation Utilities
|
|
4493
|
+
*
|
|
4494
|
+
* Provides AbortController-based cancellation for async operations.
|
|
4495
|
+
*/
|
|
4496
|
+
/**
|
|
4497
|
+
* Wrap a promise with AbortSignal support
|
|
4498
|
+
*
|
|
4499
|
+
* If the signal is aborted, the promise will reject with an
|
|
4500
|
+
* 'operation_cancelled' error which is recoverable and retryable.
|
|
4501
|
+
*
|
|
4502
|
+
* @param promise - Promise to wrap
|
|
4503
|
+
* @param signal - AbortSignal to use for cancellation
|
|
4504
|
+
* @returns Promise that can be cancelled
|
|
4505
|
+
*/
|
|
4506
|
+
declare function withAbortSignal<T>(promise: Promise<T>, signal: AbortSignal): Promise<T>;
|
|
4507
|
+
/**
|
|
4508
|
+
* Create a cancellable operation wrapper
|
|
4509
|
+
*
|
|
4510
|
+
* Returns an object with the promise and a cancel function.
|
|
4511
|
+
* Useful for creating operations that can be externally cancelled.
|
|
4512
|
+
*
|
|
4513
|
+
* @param fn - Async function to execute
|
|
4514
|
+
* @returns Object with promise and cancel function
|
|
4515
|
+
*/
|
|
4516
|
+
declare function createCancellableOperation<T>(fn: (signal: AbortSignal) => Promise<T>): {
|
|
4517
|
+
promise: Promise<T>;
|
|
4518
|
+
cancel: () => void;
|
|
4519
|
+
signal: AbortSignal;
|
|
4520
|
+
};
|
|
4521
|
+
/**
|
|
4522
|
+
* Check if an error is a cancellation error
|
|
4523
|
+
*/
|
|
4524
|
+
declare function isCancellationError(error: unknown): boolean;
|
|
4525
|
+
/**
|
|
4526
|
+
* Race multiple promises with cancellation support
|
|
4527
|
+
*
|
|
4528
|
+
* When one promise resolves, other operations are cancelled.
|
|
4529
|
+
*
|
|
4530
|
+
* @param operations - Array of operations with their signals
|
|
4531
|
+
* @returns Result of the first successful operation
|
|
4532
|
+
*/
|
|
4533
|
+
declare function raceWithCancellation<T>(operations: Array<{
|
|
4534
|
+
promise: Promise<T>;
|
|
4535
|
+
cancel: () => void;
|
|
4536
|
+
}>): Promise<T>;
|
|
4537
|
+
|
|
4538
|
+
/**
|
|
4539
|
+
* Retry Utilities
|
|
4540
|
+
*
|
|
4541
|
+
* Provides exponential backoff retry logic with jitter.
|
|
4542
|
+
*/
|
|
4543
|
+
/**
|
|
4544
|
+
* Retry options
|
|
4545
|
+
*/
|
|
4546
|
+
interface RetryOptions {
|
|
4547
|
+
/** Maximum number of retry attempts (default: 3) */
|
|
4548
|
+
maxRetries?: number;
|
|
4549
|
+
/** Base delay in milliseconds (default: 1000) */
|
|
4550
|
+
baseDelayMs?: number;
|
|
4551
|
+
/** Maximum delay in milliseconds (default: 30000) */
|
|
4552
|
+
maxDelayMs?: number;
|
|
4553
|
+
/** Enable jitter for delay randomization (default: true) */
|
|
4554
|
+
jitter?: boolean;
|
|
4555
|
+
/** AbortSignal for cancellation */
|
|
4556
|
+
signal?: AbortSignal;
|
|
4557
|
+
/** Custom retry condition (default: check isRetryableError) */
|
|
4558
|
+
shouldRetry?: (error: unknown, attempt: number) => boolean;
|
|
4559
|
+
/** Callback for each retry attempt */
|
|
4560
|
+
onRetry?: (error: unknown, attempt: number, delayMs: number) => void;
|
|
4561
|
+
}
|
|
4562
|
+
/**
|
|
4563
|
+
* Calculate delay with exponential backoff and optional jitter
|
|
4564
|
+
*
|
|
4565
|
+
* @param attempt - Current attempt number (0-indexed)
|
|
4566
|
+
* @param baseDelayMs - Base delay in milliseconds
|
|
4567
|
+
* @param maxDelayMs - Maximum delay in milliseconds
|
|
4568
|
+
* @param jitter - Whether to add jitter
|
|
4569
|
+
* @returns Delay in milliseconds
|
|
4570
|
+
*/
|
|
4571
|
+
declare function calculateBackoffDelay(attempt: number, baseDelayMs: number, maxDelayMs: number, jitter: boolean): number;
|
|
4572
|
+
/**
|
|
4573
|
+
* Sleep for a specified duration
|
|
4574
|
+
*
|
|
4575
|
+
* @param ms - Duration in milliseconds
|
|
4576
|
+
* @param signal - Optional AbortSignal for cancellation
|
|
4577
|
+
*/
|
|
4578
|
+
declare function sleep(ms: number, signal?: AbortSignal): Promise<void>;
|
|
4579
|
+
/**
|
|
4580
|
+
* Execute a function with exponential backoff retry
|
|
4581
|
+
*
|
|
4582
|
+
* @param fn - Function to execute
|
|
4583
|
+
* @param options - Retry options
|
|
4584
|
+
* @returns Result of the function
|
|
4585
|
+
*/
|
|
4586
|
+
declare function withRetry<T>(fn: () => Promise<T>, options?: RetryOptions): Promise<T>;
|
|
4587
|
+
/**
|
|
4588
|
+
* Create a retry function with preset options
|
|
4589
|
+
*
|
|
4590
|
+
* Useful for creating specialized retry functions for specific use cases.
|
|
4591
|
+
*
|
|
4592
|
+
* @param defaultOptions - Default options for all retries
|
|
4593
|
+
* @returns Retry function with preset options
|
|
4594
|
+
*/
|
|
4595
|
+
declare function createRetryFunction(defaultOptions: RetryOptions): <T>(fn: () => Promise<T>, options?: RetryOptions) => Promise<T>;
|
|
4596
|
+
/**
|
|
4597
|
+
* Extract Retry-After header value
|
|
4598
|
+
*
|
|
4599
|
+
* Supports both HTTP-date and delay-seconds formats.
|
|
4600
|
+
*
|
|
4601
|
+
* @param headers - Response headers
|
|
4602
|
+
* @returns Delay in milliseconds, or null if not found
|
|
4603
|
+
*/
|
|
4604
|
+
declare function parseRetryAfterHeader(headers: Headers | Record<string, string>): number | null;
|
|
4605
|
+
|
|
2124
4606
|
/**
|
|
2125
4607
|
* Direct Authentication API Types
|
|
2126
4608
|
*
|
|
@@ -2675,4 +5157,4 @@ interface DirectAuthClient {
|
|
|
2675
5157
|
session: SessionAuth;
|
|
2676
5158
|
}
|
|
2677
5159
|
|
|
2678
|
-
export { type AddressClaim, type AttestationConveyancePreferenceType, type AuthCallbackEvent, type AuthRedirectingEvent, type AuthResult, type AuthState, type AuthenticationExtensionsClientInputsType, type AuthenticatorAssertionResponseJSON, type AuthenticatorAttachmentType, type AuthenticatorAttestationResponseJSON, type AuthenticatorSelectionCriteriaType, type AuthenticatorTransportType, AuthorizationCodeFlow, type AuthorizationContext, type AuthorizationUrlResult, AuthrimClient, type AuthrimClientConfig, AuthrimError, type AuthrimErrorCode, type AuthrimErrorMeta, type AuthrimErrorOptions, type AuthrimErrorSeverity, type AuthrimErrorUserAction, type AuthrimEventHandler, type AuthrimEventName, type AuthrimEvents, type AuthrimStorage, type BuildAuthorizationUrlOptions, type COSEAlgorithmIdentifier, type CodeChallengeMethod, type CryptoProvider, type DecodedJwt, type DirectAuthClient, type DirectAuthClientConfig, type DirectAuthError, type DirectAuthLogoutOptions, type DirectAuthTokenRequest, type DirectAuthTokenResponse, DiscoveryClient, type EmailCodeAuth, type EmailCodeSendOptions, type EmailCodeSendRequest, type EmailCodeSendResponse, type EmailCodeSendResult, type EmailCodeVerifyOptions, type EmailCodeVerifyRequest, type EmailCodeVerifyResponse, type EndpointOverrides, type ErrorEvent, EventEmitter, type ExchangeCodeOptions, type GenerateAuthStateOptions, type HashOptions, type HttpClient, type HttpOptions, type HttpResponse, type IntrospectTokenOptions, type IntrospectionResponse, type IntrospectionTokenTypeHint, type JwtHeader, LogoutHandler, type LogoutHandlerOptions, type LogoutOptions, type LogoutResult, type MfaMethod, type NextAction, type OAuthErrorResponse, type OIDCDiscoveryDocument, PKCEHelper, type PKCEPair, type PasskeyAuth, type PasskeyCredential, type PasskeyLoginFinishRequest, type PasskeyLoginFinishResponse, type PasskeyLoginOptions, type PasskeyLoginStartRequest, type PasskeyLoginStartResponse, type PasskeyRegisterOptions, type PasskeySignUpOptions, type PasskeySignupFinishRequest, type PasskeySignupFinishResponse, type PasskeySignupStartRequest, type PasskeySignupStartResponse, type PublicKeyCredentialCreationOptionsJSON, type PublicKeyCredentialDescriptorJSON, type PublicKeyCredentialParametersType, type PublicKeyCredentialRequestOptionsJSON, type PublicKeyCredentialRpEntityType, type PublicKeyCredentialType, type PublicKeyCredentialUserEntityJSON, type ResidentKeyRequirementType, type ResolvedConfig, type RevokeTokenOptions, STORAGE_KEYS, type Session, type SessionAuth, type SessionCheckResult, type SessionEndedEvent, SessionManager, type SessionManagerOptions, type SessionStartedEvent, SilentAuthHandler, type SilentAuthOptions, type SilentAuthResult, type SilentAuthUrlResult, type SocialAuth, type SocialLoginOptions, type SocialProvider, type StandardClaims, StateManager, TOKEN_TYPE_URIS, TokenApiClient, type TokenApiClientOptions, type TokenErrorEvent, type TokenExchangeRequest, type TokenExchangeResponse, type TokenExchangeResult, type TokenExchangedEvent, type TokenExpiredEvent, TokenIntrospector, type TokenIntrospectorOptions, TokenManager, type TokenManagerOptions, type TokenRefreshedEvent, type TokenResponse, TokenRevoker, type TokenRevokerOptions, type TokenSet, type TokenTypeHint, type TokenTypeUri, type User, type UserInfo, type UserVerificationRequirementType, base64urlDecode, base64urlEncode, base64urlToString, calculateDsHash, createAuthrimClient, decodeIdToken, decodeJwt, getErrorMeta, getIdTokenNonce, isJwtExpired, normalizeIssuer, resolveConfig, stringToBase64url, timingSafeEqual };
|
|
5160
|
+
export { type AddressClaim, type AttestationConveyancePreferenceType, type AuthCallbackCompleteEvent, type AuthCallbackEvent, type AuthCallbackProcessingEvent, type AuthFallbackEvent, type AuthInitEvent, type AuthLoginCompleteEvent, type AuthLogoutCompleteEvent, type AuthPopupBlockedEvent, type AuthRedirectingEvent, type AuthRequiredEvent, type AuthResult, type AuthState, type AuthStateSnapshot, type AuthState$1 as AuthStateType, type AuthenticationExtensionsClientInputsType, type AuthenticatorAssertionResponseJSON, type AuthenticatorAttachmentType, type AuthenticatorAttestationResponseJSON, type AuthenticatorSelectionCriteriaType, type AuthenticatorTransportType, AuthorizationCodeFlow, type AuthorizationContext, type AuthorizationUrlResult, AuthrimClient, type AuthrimClientConfig, AuthrimError, type AuthrimErrorCode, type AuthrimErrorMeta, type AuthrimErrorOptions, type AuthrimErrorRemediation, type AuthrimErrorSeverity, type AuthrimErrorUserAction, type AuthrimEventHandler, type AuthrimEventName, type AuthrimEvents, type AuthrimStorage, type AutoRefreshOptions, AutoRefreshScheduler, BACKCHANNEL_LOGOUT_EVENT, type BackChannelLogoutErrorCode, type BackChannelLogoutValidationOptions, type BackChannelLogoutValidationResult, BackChannelLogoutValidator, type BaseEventPayload, type BuildAuthorizationUrlOptions, type COSEAlgorithmIdentifier, type CheckSessionMessage, type CheckSessionResponse, type ClientAssertionClaims, type ClientAuthMethod, type ClientAuthResult, type ClientCredentials, ClientCredentialsClient, type ClientCredentialsClientOptions, type ClientCredentialsTokenOptions, type ClientSecretCredentials, type CodeChallengeMethod, type CoreEventName, type CryptoProvider, type DPoPCryptoProvider, type DPoPKeyPair, DPoPManager, type DPoPManagerConfig, type DPoPProofClaims, type DPoPProofHeader, type DPoPProofOptions, DebugContext, type DebugLogLevel, type DebugLogger, type DebugOptions, type DebugTimelineEvent, type DecodedJwt, type DeviceAuthorizationResponse, type DeviceFlowAccessDeniedResult, DeviceFlowClient, type DeviceFlowCompletedResult, type DeviceFlowExpiredResult, type DeviceFlowPendingResult, type DeviceFlowPollResult, type DeviceFlowSlowDownResult, type DeviceFlowStartOptions, type DeviceFlowState, type DirectAuthClient, type DirectAuthClientConfig, type DirectAuthError, type DirectAuthLogoutOptions, type DirectAuthTokenRequest, type DirectAuthTokenResponse, DiscoveryClient, type EmailCodeAuth, type EmailCodeSendOptions, type EmailCodeSendRequest, type EmailCodeSendResponse, type EmailCodeSendResult, type EmailCodeVerifyOptions, type EmailCodeVerifyRequest, type EmailCodeVerifyResponse, type EmitClassifiedErrorOptions, type EndpointOverrides, type ErrorClassification, type ErrorEvent, type ErrorEventEmitter, type ErrorEventPayload, type ErrorFatalEvent, type ErrorRecoverableEvent, type ErrorSeverity, EventEmitter, EventTimeline, type ExchangeCodeOptions, type FrontChannelLogoutBuildParams, type FrontChannelLogoutParams, FrontChannelLogoutUrlBuilder, type FrontChannelLogoutUrlOptions, type FrontChannelLogoutUrlResult, type FrontChannelLogoutValidationOptions, type FrontChannelLogoutValidationResult, type GenerateAuthStateOptions, type HashOptions, type HttpClient, type HttpOptions, type HttpResponse, type IntrospectTokenOptions, type IntrospectionResponse, type IntrospectionTokenTypeHint, JARBuilder, type JARBuilderConfig, type JARMResponseClaims, type JARMValidationOptions, type JARMValidationResult, JARMValidator, type JARMValidatorConfig, type JARRequestObjectClaims, type JARRequestOptions, type JWK, type JwtHeader, LogoutHandler, type LogoutHandlerOptions, type LogoutOptions, type LogoutResult, type LogoutTokenClaims, type MfaMethod, type NextAction, type NoClientCredentials, type OAuthErrorResponse, type OIDCDiscoveryDocument, PARClient, type PARClientOptions, type PARRequest, type PARResponse, type PARResult, PKCEHelper, type PKCEPair, type PasskeyAuth, type PasskeyCredential, type PasskeyLoginFinishRequest, type PasskeyLoginFinishResponse, type PasskeyLoginOptions, type PasskeyLoginStartRequest, type PasskeyLoginStartResponse, type PasskeyRegisterOptions, type PasskeySignUpOptions, type PasskeySignupFinishRequest, type PasskeySignupFinishResponse, type PasskeySignupStartRequest, type PasskeySignupStartResponse, type PrivateKeyJwtCredentials, type PublicKeyCredentialCreationOptionsJSON, type PublicKeyCredentialDescriptorJSON, type PublicKeyCredentialParametersType, type PublicKeyCredentialRequestOptionsJSON, type PublicKeyCredentialRpEntityType, type PublicKeyCredentialType, type PublicKeyCredentialUserEntityJSON, type RedactLevel, type ResidentKeyRequirementType, type ResolvedConfig, type RetryOptions, type RevokeTokenOptions, STORAGE_KEYS, type Session, type SessionAuth, type SessionChangeEvent, type SessionChangedEvent, type SessionCheckResult, type SessionEndedEvent, type SessionLogoutBroadcastEvent, type SessionManagementConfig, SessionManager, type SessionManagerOptions, type SessionStartedEvent, type SessionState, SessionStateCalculator, type SessionStateCalculatorOptions, type SessionStateParams, type SessionStateResult, type SessionSyncEvent, SilentAuthHandler, type SilentAuthOptions, type SilentAuthResult, type SilentAuthUrlResult, type SocialAuth, type SocialLoginOptions, type SocialProvider, type StandardClaims, type StateChangeEvent, StateManager, TOKEN_TYPE_URIS, type TimelineEntry, TokenApiClient, type TokenApiClientOptions, type TokenErrorEvent, type TokenExchangeRequest, type TokenExchangeResponse, type TokenExchangeResult, type TokenExchangedEvent, type TokenExpiredEvent, type TokenExpiringEvent, TokenIntrospector, type TokenIntrospectorOptions, TokenManager, type TokenManagerOptions, type TokenRefreshFailedEvent, type TokenRefreshedEvent, type TokenRefreshingEvent, type TokenResponse, TokenRevoker, type TokenRevokerOptions, type TokenSet, type TokenTypeHint, type TokenTypeUri, type User, type UserInfo, type UserVerificationRequirementType, type WarningITPEvent, type WarningPrivateModeEvent, type WarningStorageFallbackEvent, type WebOnlyEventName, base64urlDecode, base64urlEncode, base64urlToString, buildClientAuthentication, calculateBackoffDelay, calculateDsHash, classifyError, createAuthrimClient, createCancellableOperation, createConsoleLogger, createDebugLogger, createRetryFunction, decodeIdToken, decodeJwt, emitClassifiedError, getErrorMeta, getIdTokenNonce, isCancellationError, isJarRequired, isJwtExpired, isRetryableError, noopLogger, normalizeIssuer, parseRetryAfterHeader, raceWithCancellation, resolveConfig, sleep, stringToBase64url, timingSafeEqual, withAbortSignal, withRetry };
|