@web-ts-toolkit/express-oidc-vault 0.50.0 → 0.52.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +210 -340
- package/index.d.mts +45 -65
- package/index.d.ts +45 -65
- package/index.js +114 -48
- package/index.mjs +114 -48
- package/package.json +11 -1
- package/wire.d.mts +76 -0
- package/wire.d.ts +76 -0
- package/wire.js +18 -0
- package/wire.mjs +0 -0
package/index.d.mts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { Request, Response, RequestHandler, Router } from 'express';
|
|
2
2
|
import { KeyObject } from 'node:crypto';
|
|
3
3
|
import { JWK } from 'jose';
|
|
4
|
+
import { OidcVaultUserProfile, OidcVaultTokenIssueResult, OidcVaultSessionTransport } from './wire.mjs';
|
|
5
|
+
export { OidcVaultExchangeResult, OidcVaultLoginInitiationInput, OidcVaultLoginInitiationResult, OidcVaultLogoutResult } from './wire.mjs';
|
|
4
6
|
|
|
5
7
|
type OidcVaultRouteName = 'login' | 'callback' | 'exchange' | 'refresh' | 'logout' | 'backchannel-logout';
|
|
6
8
|
/** Enabling the option defaults to `optional`; omitting it keeps bearer behavior. */
|
|
@@ -41,6 +43,8 @@ interface OidcVaultDpopNonceOptions {
|
|
|
41
43
|
* Signature verification precedes claims; strict iat validity is
|
|
42
44
|
* nowSeconds - age - skew < iat <= nowSeconds + skew. APIs additionally match
|
|
43
45
|
* original verified cnf.jkt and SHA-256 ath of the ASCII access token.
|
|
46
|
+
* Independent failure overrides below run their checks and log to console.warn
|
|
47
|
+
* before continuing. Environment defaults are captured at middleware construction.
|
|
44
48
|
*/
|
|
45
49
|
interface OidcVaultDpopProofOptions {
|
|
46
50
|
/** Nonempty asymmetric allowlist; default `['ES256']` (P-256). RSA proofs require 2048–4096 bits. */
|
|
@@ -51,6 +55,24 @@ interface OidcVaultDpopProofOptions {
|
|
|
51
55
|
clockSkewSeconds?: number;
|
|
52
56
|
/** Off by default. Challenges are at most 512 bytes; retry once with a fresh proof, never reuse its JTI. */
|
|
53
57
|
nonce?: false | OidcVaultDpopNonceOptions;
|
|
58
|
+
/**
|
|
59
|
+
* Step 6: log failed method/normalized URL checks and continue.
|
|
60
|
+
* Defaults to OIDC_VAULT_DPOP_IGNORE_TARGET_FAILURE === 'true'; otherwise false.
|
|
61
|
+
* An explicit boolean overrides the environment for this vault/API policy.
|
|
62
|
+
*/
|
|
63
|
+
ignoreTargetFailure?: boolean;
|
|
64
|
+
/**
|
|
65
|
+
* Step 7: log failed proof age/skew checks and continue, retaining replay tracking
|
|
66
|
+
* with a bounded expiry from the current time. A failed clock uses Date.now.
|
|
67
|
+
* Defaults to OIDC_VAULT_DPOP_IGNORE_FRESHNESS_FAILURE === 'true'; otherwise false.
|
|
68
|
+
*/
|
|
69
|
+
ignoreFreshnessFailure?: boolean;
|
|
70
|
+
/**
|
|
71
|
+
* Step 8: attempt atomic replay reservation, log duplicate/admission/provider
|
|
72
|
+
* failures, and continue. Successful reservations retain their normal lifetime.
|
|
73
|
+
* Defaults to OIDC_VAULT_DPOP_IGNORE_REPLAY_FAILURE === 'true'; otherwise false.
|
|
74
|
+
*/
|
|
75
|
+
ignoreReplayFailure?: boolean;
|
|
54
76
|
}
|
|
55
77
|
/**
|
|
56
78
|
* Opt-in sender constraint. `optional` permits legacy unbound records without
|
|
@@ -94,13 +116,6 @@ interface OidcVaultApiDeviceBindingOptions extends OidcVaultDeviceBindingOptions
|
|
|
94
116
|
/** Epoch-millisecond clock for proof age/nonce/replay; default Date.now. Shared instances need synchronized clocks. */
|
|
95
117
|
now?: () => number;
|
|
96
118
|
}
|
|
97
|
-
interface OidcVaultUserProfile {
|
|
98
|
-
sub: string;
|
|
99
|
-
email?: string;
|
|
100
|
-
name?: string;
|
|
101
|
-
preferredUsername?: string;
|
|
102
|
-
[key: string]: unknown;
|
|
103
|
-
}
|
|
104
119
|
/**
|
|
105
120
|
* Stored session identity. Exchange, refresh, and logout compare each defined
|
|
106
121
|
* field verbatim against resolved middleware config before use. Opt-in/guarded
|
|
@@ -273,10 +288,11 @@ interface OidcVaultDpopReplayStore {
|
|
|
273
288
|
/**
|
|
274
289
|
* Reserve once through expiry. Duplicate/invalid/expired input returns false
|
|
275
290
|
* without extending expiry or allocating state. Capacity/provider failures
|
|
276
|
-
* throw; callers
|
|
291
|
+
* throw; callers fail closed by default, never evict live reservations. Built-ins
|
|
277
292
|
* default to 100000 entries per shared namespace. Expired entries awaiting
|
|
278
293
|
* bounded cleanup may conservatively occupy capacity. Duplicate detection
|
|
279
294
|
* precedes capacity rejection; capacity throws `OidcVaultDpopReplayCapacityError`.
|
|
295
|
+
* A proof policy with ignoreReplayFailure logs a failed admission and continues.
|
|
280
296
|
*/
|
|
281
297
|
reserveDpopProof(input: ReserveDpopProofInput): Promise<boolean>;
|
|
282
298
|
}
|
|
@@ -494,19 +510,6 @@ interface IssueTokenInput {
|
|
|
494
510
|
*/
|
|
495
511
|
deviceBinding?: Readonly<OidcVaultVerifiedDpopBinding>;
|
|
496
512
|
}
|
|
497
|
-
/**
|
|
498
|
-
* Local application credentials returned by `OidcVaultTokenIssuer.issue`.
|
|
499
|
-
* Runtime validation copies only these fields into a fresh result; additional
|
|
500
|
-
* properties are ignored and cannot override the response's session ID/user.
|
|
501
|
-
*/
|
|
502
|
-
interface OidcVaultTokenIssueResult {
|
|
503
|
-
/** Nonempty opaque token for unbound issuance; bound issuance requires a compact signed JWT with matching `cnf.jkt`. */
|
|
504
|
-
accessToken: string;
|
|
505
|
-
/** Token lifetime in seconds: a finite, nonnegative safe integer (zero is valid). */
|
|
506
|
-
expiresIn: number;
|
|
507
|
-
/** Exact `DPoP` is required when bound. Unbound permits only `Bearer` or omission; omitted/undefined stays absent in JSON. */
|
|
508
|
-
tokenType?: 'Bearer' | 'DPoP';
|
|
509
|
-
}
|
|
510
513
|
/**
|
|
511
514
|
* Trusted application token issuer for exchange and refresh. Return a non-null,
|
|
512
515
|
* non-array object satisfying `OidcVaultTokenIssueResult`; only its declared
|
|
@@ -533,7 +536,7 @@ interface OidcVaultAccessTokenValidationResult {
|
|
|
533
536
|
/** Verified sender constraint. Legacy adapters may omit it only for genuinely unbound credentials. */
|
|
534
537
|
confirmation?: OidcVaultAccessTokenConfirmation | null;
|
|
535
538
|
}
|
|
536
|
-
/**
|
|
539
|
+
/** Exact one-field confirmation: canonical RFC 7638 SHA-256 thumbprint from verified token/introspection data, never from a proof alone. */
|
|
537
540
|
interface OidcVaultAccessTokenConfirmation {
|
|
538
541
|
jkt: string;
|
|
539
542
|
}
|
|
@@ -607,13 +610,18 @@ interface OidcVaultAccessTokenMiddlewareOptions {
|
|
|
607
610
|
interface OidcVaultAuthenticatedRequest extends Request {
|
|
608
611
|
auth?: OidcVaultAuthContext;
|
|
609
612
|
}
|
|
610
|
-
/**
|
|
613
|
+
/**
|
|
614
|
+
* Local JWT verification options, independent of the asymmetric DPoP proof
|
|
615
|
+
* policy; captured at construction. JWTs with cnf require the supported exact
|
|
616
|
+
* jkt profile and a nonnegative safe-integer exp with safe milliseconds in both
|
|
617
|
+
* validator methods. Unbound JWTs retain JOSE's optional-exp behavior.
|
|
618
|
+
*/
|
|
611
619
|
interface OidcVaultJwtAccessTokenValidatorOptions {
|
|
612
620
|
key: CryptoKey | KeyObject | JWK | Uint8Array;
|
|
613
621
|
issuer?: string;
|
|
614
622
|
audience?: string | string[];
|
|
615
623
|
algorithms?: string[];
|
|
616
|
-
/**
|
|
624
|
+
/** JOSE verification and bound-JWT profile/expiry checks precede this mapper. Original cnf is snapshotted; mapper-supplied confirmation/deviceBinding is ignored. */
|
|
617
625
|
mapClaims?(claims: Record<string, unknown>): OidcVaultAccessTokenValidationResult;
|
|
618
626
|
}
|
|
619
627
|
declare module 'express-serve-static-core' {
|
|
@@ -645,50 +653,10 @@ interface OidcVaultConfig {
|
|
|
645
653
|
clientSecret?: string;
|
|
646
654
|
scopes?: string;
|
|
647
655
|
}
|
|
648
|
-
interface OidcVaultLogoutResult {
|
|
649
|
-
/**
|
|
650
|
-
* Successful logout commits revocation before upstream work and clears the
|
|
651
|
-
* session cookie under cookie transport. Built-in live handles and unexpired
|
|
652
|
-
* aliases authenticate the surviving lineage's provider/original binding;
|
|
653
|
-
* wrong identity, missing/wrong/stale/replayed proof, or disabled acceptance
|
|
654
|
-
* of a bound lineage fails without deleting or clearing. No currently live
|
|
655
|
-
* target is idempotent success without deletion or proof reservation. Aliases
|
|
656
|
-
* grant revocation only, not refresh authentication or upstream redirects.
|
|
657
|
-
* Old custom bearer stores without revocation context retain legacy alias
|
|
658
|
-
* deletion behavior. Stateless application access tokens are not invalidated.
|
|
659
|
-
* Local-only logout (`redirect` unset or `false`) never contacts the provider.
|
|
660
|
-
* Redirected logout (`redirect: true`)
|
|
661
|
-
* treats the upstream end-session redirect as best-effort: when provider
|
|
662
|
-
* discovery fails or no `endSessionEndpoint` is available, the route still
|
|
663
|
-
* returns this local success. Discovery errors reach `onError` without
|
|
664
|
-
* undoing revocation or skipping the live session's `onLogout` notification.
|
|
665
|
-
*/
|
|
666
|
-
loggedOut: true;
|
|
667
|
-
}
|
|
668
656
|
interface OidcVaultBackchannelLogoutResult {
|
|
669
657
|
loggedOut: true;
|
|
670
658
|
revokedSessions: number;
|
|
671
659
|
}
|
|
672
|
-
interface OidcVaultExchangeResult extends Partial<OidcVaultTokenIssueResult> {
|
|
673
|
-
/** Authoritative vault handle in body transport; omitted from cookie-transport JSON. */
|
|
674
|
-
sessionId?: string;
|
|
675
|
-
/** Session profile; extra token-issuer result properties cannot override it. */
|
|
676
|
-
user?: OidcVaultUserProfile;
|
|
677
|
-
}
|
|
678
|
-
/** JSON body for opt-in `POST <basePath>/login`; proof/key and recognition signals belong in their configured headers, not the body. */
|
|
679
|
-
interface OidcVaultLoginInitiationInput {
|
|
680
|
-
/** Optional destination on the configured frontend origin. Query-string returnTo is ignored by POST login. */
|
|
681
|
-
returnTo?: string;
|
|
682
|
-
}
|
|
683
|
-
/**
|
|
684
|
-
* Exact successful POST-login JSON. Navigate to this URL after storing a proof
|
|
685
|
-
* key when DPoP is enabled. Use credentials: 'include' even with body session
|
|
686
|
-
* transport: initiation sets a temporary HttpOnly transaction cookie.
|
|
687
|
-
*/
|
|
688
|
-
interface OidcVaultLoginInitiationResult {
|
|
689
|
-
authorizationUrl: string;
|
|
690
|
-
}
|
|
691
|
-
type OidcVaultSessionTransport = 'body' | 'cookie';
|
|
692
660
|
type OidcVaultCookieDeploymentMode = 'same-origin' | 'same-site' | 'cross-site';
|
|
693
661
|
type OidcVaultCookieSameSite = 'lax' | 'strict' | 'none';
|
|
694
662
|
/**
|
|
@@ -937,6 +905,10 @@ declare const OIDC_VAULT_ROUTE_PATHS: Record<OidcVaultRouteName, string>;
|
|
|
937
905
|
* callbacks/validator methods, URLs, algorithms and secret bytes; the replay
|
|
938
906
|
* store remains the shared atomic service. Responses carry no-store and fixed
|
|
939
907
|
* errors; onError privately observes originals and cannot override failures.
|
|
908
|
+
* The independent OIDC_VAULT_DPOP_IGNORE_TARGET_FAILURE,
|
|
909
|
+
* OIDC_VAULT_DPOP_IGNORE_FRESHNESS_FAILURE and OIDC_VAULT_DPOP_IGNORE_REPLAY_FAILURE
|
|
910
|
+
* environment defaults are captured at construction; ignored failures log to
|
|
911
|
+
* console.warn. Explicit deviceBinding booleans override those defaults.
|
|
940
912
|
*/
|
|
941
913
|
declare function createOidcVaultAccessTokenMiddleware(options: OidcVaultAccessTokenMiddlewareOptions): RequestHandler;
|
|
942
914
|
|
|
@@ -946,6 +918,10 @@ declare function createOidcVaultAccessTokenMiddleware(options: OidcVaultAccessTo
|
|
|
946
918
|
* the sender constraint. The request-aware result always has confirmation
|
|
947
919
|
* (null only for genuinely unbound JWTs). Legacy unbound results omit it;
|
|
948
920
|
* bound results report it so binding-disabled vault middleware refuses downgrade.
|
|
921
|
+
* Bound JWTs additionally require canonical compact encoding and a nonnegative
|
|
922
|
+
* safe-integer exp with safe milliseconds, checked before mapClaims in both
|
|
923
|
+
* methods. JOSE verifies signature/expiry and configured issuer/audience first. Unbound
|
|
924
|
+
* JWTs retain JOSE's generic optional-exp contract.
|
|
949
925
|
* Proof/target/ath/nonce/replay enforcement belongs to the API middleware.
|
|
950
926
|
* Construction captures options and copies secret/JWK/allowlist containers.
|
|
951
927
|
*/
|
|
@@ -985,7 +961,11 @@ declare function normalizeOidcVaultBasePath(value?: string): string;
|
|
|
985
961
|
* an enabled nonce secret is copied into private owned storage. Separate opt-in
|
|
986
962
|
* `fingerprintRecognition` settings are detached/frozen; recognition enrolls
|
|
987
963
|
* only at POST login and checks exchange/refresh before credential mutation.
|
|
964
|
+
* The independent OIDC_VAULT_DPOP_IGNORE_TARGET_FAILURE,
|
|
965
|
+
* OIDC_VAULT_DPOP_IGNORE_FRESHNESS_FAILURE and OIDC_VAULT_DPOP_IGNORE_REPLAY_FAILURE
|
|
966
|
+
* environment defaults are captured with the proof policy. Ignored failures
|
|
967
|
+
* log to console.warn; explicit deviceBinding booleans override those defaults.
|
|
988
968
|
*/
|
|
989
969
|
declare function createOidcVaultMiddleware(options: OidcVaultOptions): Router;
|
|
990
970
|
|
|
991
|
-
export { type AuthorizationTransaction, type AuthorizationTransactionInput, type ConsumeAuthorizationTransactionIfMatchesInput, type ConsumeBackchannelLogoutTokenJtiInput, type ConsumeExchangeCodeIfMatchesInput, DEFAULT_AUTHORIZATION_TRANSACTION_TTL_MS, DEFAULT_EXCHANGE_CODE_TTL_MS, DEFAULT_OIDC_SCOPES, DEFAULT_OIDC_VAULT_BASE_PATH, DEFAULT_OIDC_VAULT_REQUEST_BODY_LIMIT, type DeleteSessionsByLogicalSessionIdInput, type DeleteSessionsByProviderSessionIdInput, type DeleteSessionsBySubjectInput, type ExchangeCodeRecord, type ExchangeCodeRecordInput, type IssueTokenInput, OIDC_VAULT_ROUTE_PATHS, OIDC_VAULT_URL_ENCODED_PARAMETER_LIMIT, type OidcVaultAccessTokenConfirmation, type OidcVaultAccessTokenMiddlewareErrorContext, type OidcVaultAccessTokenMiddlewareOptions, type OidcVaultAccessTokenRequestInput, type OidcVaultAccessTokenValidationResult, type OidcVaultAccessTokenValidator, type OidcVaultApiDeviceBindingOptions, type OidcVaultAuthContext, type OidcVaultAuthenticatedRequest, type OidcVaultBackchannelLogoutResult, type OidcVaultConfig, type OidcVaultConfigMode, type OidcVaultCookieDeploymentMode, type OidcVaultCookieOptions, type OidcVaultCookieSameSite, type OidcVaultDeviceBindingMode, type OidcVaultDeviceBindingOptions, type OidcVaultDeviceBindingStoreProvider, type OidcVaultDpopAlgorithm, type OidcVaultDpopBinding, type OidcVaultDpopNonceOptions, type OidcVaultDpopProofOptions, OidcVaultDpopReplayCapacityError, type OidcVaultDpopReplayStore, type OidcVaultEnv, type OidcVaultErrorContext, type
|
|
971
|
+
export { type AuthorizationTransaction, type AuthorizationTransactionInput, type ConsumeAuthorizationTransactionIfMatchesInput, type ConsumeBackchannelLogoutTokenJtiInput, type ConsumeExchangeCodeIfMatchesInput, DEFAULT_AUTHORIZATION_TRANSACTION_TTL_MS, DEFAULT_EXCHANGE_CODE_TTL_MS, DEFAULT_OIDC_SCOPES, DEFAULT_OIDC_VAULT_BASE_PATH, DEFAULT_OIDC_VAULT_REQUEST_BODY_LIMIT, type DeleteSessionsByLogicalSessionIdInput, type DeleteSessionsByProviderSessionIdInput, type DeleteSessionsBySubjectInput, type ExchangeCodeRecord, type ExchangeCodeRecordInput, type IssueTokenInput, OIDC_VAULT_ROUTE_PATHS, OIDC_VAULT_URL_ENCODED_PARAMETER_LIMIT, type OidcVaultAccessTokenConfirmation, type OidcVaultAccessTokenMiddlewareErrorContext, type OidcVaultAccessTokenMiddlewareOptions, type OidcVaultAccessTokenRequestInput, type OidcVaultAccessTokenValidationResult, type OidcVaultAccessTokenValidator, type OidcVaultApiDeviceBindingOptions, type OidcVaultAuthContext, type OidcVaultAuthenticatedRequest, type OidcVaultBackchannelLogoutResult, type OidcVaultConfig, type OidcVaultConfigMode, type OidcVaultCookieDeploymentMode, type OidcVaultCookieOptions, type OidcVaultCookieSameSite, type OidcVaultDeviceBindingMode, type OidcVaultDeviceBindingOptions, type OidcVaultDeviceBindingStoreProvider, type OidcVaultDpopAlgorithm, type OidcVaultDpopBinding, type OidcVaultDpopNonceOptions, type OidcVaultDpopProofOptions, OidcVaultDpopReplayCapacityError, type OidcVaultDpopReplayStore, type OidcVaultEnv, type OidcVaultErrorContext, type OidcVaultFingerprintRecognitionOptions, type OidcVaultHookContext, type OidcVaultHooks, type OidcVaultJwtAccessTokenValidatorOptions, type OidcVaultOptions, type OidcVaultProviderMetadata, type OidcVaultRecordBindingMatch, type OidcVaultRequestAwareAccessTokenValidationResult, type OidcVaultRequestAwareAccessTokenValidator, type OidcVaultResolvedConfig, type OidcVaultRouteName, type OidcVaultSession, type OidcVaultSessionInput, type OidcVaultSessionRevocationContext, OidcVaultSessionTransport, OidcVaultStoreConflictError, type OidcVaultStoreProvider, OidcVaultTokenIssueResult, type OidcVaultTokenIssuer, type OidcVaultTransactionCookieOptions, OidcVaultUserProfile, type OidcVaultVerifiedDpopBinding, type ReserveDpopProofInput, type RotateSessionInput, createOidcVaultAccessTokenMiddleware, createOidcVaultJwtAccessTokenValidator, createOidcVaultMiddleware, normalizeOidcVaultBasePath, resolveOidcVaultConfig, resolveOidcVaultConfigFromEnv };
|
package/index.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { Request, Response, RequestHandler, Router } from 'express';
|
|
2
2
|
import { KeyObject } from 'node:crypto';
|
|
3
3
|
import { JWK } from 'jose';
|
|
4
|
+
import { OidcVaultUserProfile, OidcVaultTokenIssueResult, OidcVaultSessionTransport } from './wire.js';
|
|
5
|
+
export { OidcVaultExchangeResult, OidcVaultLoginInitiationInput, OidcVaultLoginInitiationResult, OidcVaultLogoutResult } from './wire.js';
|
|
4
6
|
|
|
5
7
|
type OidcVaultRouteName = 'login' | 'callback' | 'exchange' | 'refresh' | 'logout' | 'backchannel-logout';
|
|
6
8
|
/** Enabling the option defaults to `optional`; omitting it keeps bearer behavior. */
|
|
@@ -41,6 +43,8 @@ interface OidcVaultDpopNonceOptions {
|
|
|
41
43
|
* Signature verification precedes claims; strict iat validity is
|
|
42
44
|
* nowSeconds - age - skew < iat <= nowSeconds + skew. APIs additionally match
|
|
43
45
|
* original verified cnf.jkt and SHA-256 ath of the ASCII access token.
|
|
46
|
+
* Independent failure overrides below run their checks and log to console.warn
|
|
47
|
+
* before continuing. Environment defaults are captured at middleware construction.
|
|
44
48
|
*/
|
|
45
49
|
interface OidcVaultDpopProofOptions {
|
|
46
50
|
/** Nonempty asymmetric allowlist; default `['ES256']` (P-256). RSA proofs require 2048–4096 bits. */
|
|
@@ -51,6 +55,24 @@ interface OidcVaultDpopProofOptions {
|
|
|
51
55
|
clockSkewSeconds?: number;
|
|
52
56
|
/** Off by default. Challenges are at most 512 bytes; retry once with a fresh proof, never reuse its JTI. */
|
|
53
57
|
nonce?: false | OidcVaultDpopNonceOptions;
|
|
58
|
+
/**
|
|
59
|
+
* Step 6: log failed method/normalized URL checks and continue.
|
|
60
|
+
* Defaults to OIDC_VAULT_DPOP_IGNORE_TARGET_FAILURE === 'true'; otherwise false.
|
|
61
|
+
* An explicit boolean overrides the environment for this vault/API policy.
|
|
62
|
+
*/
|
|
63
|
+
ignoreTargetFailure?: boolean;
|
|
64
|
+
/**
|
|
65
|
+
* Step 7: log failed proof age/skew checks and continue, retaining replay tracking
|
|
66
|
+
* with a bounded expiry from the current time. A failed clock uses Date.now.
|
|
67
|
+
* Defaults to OIDC_VAULT_DPOP_IGNORE_FRESHNESS_FAILURE === 'true'; otherwise false.
|
|
68
|
+
*/
|
|
69
|
+
ignoreFreshnessFailure?: boolean;
|
|
70
|
+
/**
|
|
71
|
+
* Step 8: attempt atomic replay reservation, log duplicate/admission/provider
|
|
72
|
+
* failures, and continue. Successful reservations retain their normal lifetime.
|
|
73
|
+
* Defaults to OIDC_VAULT_DPOP_IGNORE_REPLAY_FAILURE === 'true'; otherwise false.
|
|
74
|
+
*/
|
|
75
|
+
ignoreReplayFailure?: boolean;
|
|
54
76
|
}
|
|
55
77
|
/**
|
|
56
78
|
* Opt-in sender constraint. `optional` permits legacy unbound records without
|
|
@@ -94,13 +116,6 @@ interface OidcVaultApiDeviceBindingOptions extends OidcVaultDeviceBindingOptions
|
|
|
94
116
|
/** Epoch-millisecond clock for proof age/nonce/replay; default Date.now. Shared instances need synchronized clocks. */
|
|
95
117
|
now?: () => number;
|
|
96
118
|
}
|
|
97
|
-
interface OidcVaultUserProfile {
|
|
98
|
-
sub: string;
|
|
99
|
-
email?: string;
|
|
100
|
-
name?: string;
|
|
101
|
-
preferredUsername?: string;
|
|
102
|
-
[key: string]: unknown;
|
|
103
|
-
}
|
|
104
119
|
/**
|
|
105
120
|
* Stored session identity. Exchange, refresh, and logout compare each defined
|
|
106
121
|
* field verbatim against resolved middleware config before use. Opt-in/guarded
|
|
@@ -273,10 +288,11 @@ interface OidcVaultDpopReplayStore {
|
|
|
273
288
|
/**
|
|
274
289
|
* Reserve once through expiry. Duplicate/invalid/expired input returns false
|
|
275
290
|
* without extending expiry or allocating state. Capacity/provider failures
|
|
276
|
-
* throw; callers
|
|
291
|
+
* throw; callers fail closed by default, never evict live reservations. Built-ins
|
|
277
292
|
* default to 100000 entries per shared namespace. Expired entries awaiting
|
|
278
293
|
* bounded cleanup may conservatively occupy capacity. Duplicate detection
|
|
279
294
|
* precedes capacity rejection; capacity throws `OidcVaultDpopReplayCapacityError`.
|
|
295
|
+
* A proof policy with ignoreReplayFailure logs a failed admission and continues.
|
|
280
296
|
*/
|
|
281
297
|
reserveDpopProof(input: ReserveDpopProofInput): Promise<boolean>;
|
|
282
298
|
}
|
|
@@ -494,19 +510,6 @@ interface IssueTokenInput {
|
|
|
494
510
|
*/
|
|
495
511
|
deviceBinding?: Readonly<OidcVaultVerifiedDpopBinding>;
|
|
496
512
|
}
|
|
497
|
-
/**
|
|
498
|
-
* Local application credentials returned by `OidcVaultTokenIssuer.issue`.
|
|
499
|
-
* Runtime validation copies only these fields into a fresh result; additional
|
|
500
|
-
* properties are ignored and cannot override the response's session ID/user.
|
|
501
|
-
*/
|
|
502
|
-
interface OidcVaultTokenIssueResult {
|
|
503
|
-
/** Nonempty opaque token for unbound issuance; bound issuance requires a compact signed JWT with matching `cnf.jkt`. */
|
|
504
|
-
accessToken: string;
|
|
505
|
-
/** Token lifetime in seconds: a finite, nonnegative safe integer (zero is valid). */
|
|
506
|
-
expiresIn: number;
|
|
507
|
-
/** Exact `DPoP` is required when bound. Unbound permits only `Bearer` or omission; omitted/undefined stays absent in JSON. */
|
|
508
|
-
tokenType?: 'Bearer' | 'DPoP';
|
|
509
|
-
}
|
|
510
513
|
/**
|
|
511
514
|
* Trusted application token issuer for exchange and refresh. Return a non-null,
|
|
512
515
|
* non-array object satisfying `OidcVaultTokenIssueResult`; only its declared
|
|
@@ -533,7 +536,7 @@ interface OidcVaultAccessTokenValidationResult {
|
|
|
533
536
|
/** Verified sender constraint. Legacy adapters may omit it only for genuinely unbound credentials. */
|
|
534
537
|
confirmation?: OidcVaultAccessTokenConfirmation | null;
|
|
535
538
|
}
|
|
536
|
-
/**
|
|
539
|
+
/** Exact one-field confirmation: canonical RFC 7638 SHA-256 thumbprint from verified token/introspection data, never from a proof alone. */
|
|
537
540
|
interface OidcVaultAccessTokenConfirmation {
|
|
538
541
|
jkt: string;
|
|
539
542
|
}
|
|
@@ -607,13 +610,18 @@ interface OidcVaultAccessTokenMiddlewareOptions {
|
|
|
607
610
|
interface OidcVaultAuthenticatedRequest extends Request {
|
|
608
611
|
auth?: OidcVaultAuthContext;
|
|
609
612
|
}
|
|
610
|
-
/**
|
|
613
|
+
/**
|
|
614
|
+
* Local JWT verification options, independent of the asymmetric DPoP proof
|
|
615
|
+
* policy; captured at construction. JWTs with cnf require the supported exact
|
|
616
|
+
* jkt profile and a nonnegative safe-integer exp with safe milliseconds in both
|
|
617
|
+
* validator methods. Unbound JWTs retain JOSE's optional-exp behavior.
|
|
618
|
+
*/
|
|
611
619
|
interface OidcVaultJwtAccessTokenValidatorOptions {
|
|
612
620
|
key: CryptoKey | KeyObject | JWK | Uint8Array;
|
|
613
621
|
issuer?: string;
|
|
614
622
|
audience?: string | string[];
|
|
615
623
|
algorithms?: string[];
|
|
616
|
-
/**
|
|
624
|
+
/** JOSE verification and bound-JWT profile/expiry checks precede this mapper. Original cnf is snapshotted; mapper-supplied confirmation/deviceBinding is ignored. */
|
|
617
625
|
mapClaims?(claims: Record<string, unknown>): OidcVaultAccessTokenValidationResult;
|
|
618
626
|
}
|
|
619
627
|
declare module 'express-serve-static-core' {
|
|
@@ -645,50 +653,10 @@ interface OidcVaultConfig {
|
|
|
645
653
|
clientSecret?: string;
|
|
646
654
|
scopes?: string;
|
|
647
655
|
}
|
|
648
|
-
interface OidcVaultLogoutResult {
|
|
649
|
-
/**
|
|
650
|
-
* Successful logout commits revocation before upstream work and clears the
|
|
651
|
-
* session cookie under cookie transport. Built-in live handles and unexpired
|
|
652
|
-
* aliases authenticate the surviving lineage's provider/original binding;
|
|
653
|
-
* wrong identity, missing/wrong/stale/replayed proof, or disabled acceptance
|
|
654
|
-
* of a bound lineage fails without deleting or clearing. No currently live
|
|
655
|
-
* target is idempotent success without deletion or proof reservation. Aliases
|
|
656
|
-
* grant revocation only, not refresh authentication or upstream redirects.
|
|
657
|
-
* Old custom bearer stores without revocation context retain legacy alias
|
|
658
|
-
* deletion behavior. Stateless application access tokens are not invalidated.
|
|
659
|
-
* Local-only logout (`redirect` unset or `false`) never contacts the provider.
|
|
660
|
-
* Redirected logout (`redirect: true`)
|
|
661
|
-
* treats the upstream end-session redirect as best-effort: when provider
|
|
662
|
-
* discovery fails or no `endSessionEndpoint` is available, the route still
|
|
663
|
-
* returns this local success. Discovery errors reach `onError` without
|
|
664
|
-
* undoing revocation or skipping the live session's `onLogout` notification.
|
|
665
|
-
*/
|
|
666
|
-
loggedOut: true;
|
|
667
|
-
}
|
|
668
656
|
interface OidcVaultBackchannelLogoutResult {
|
|
669
657
|
loggedOut: true;
|
|
670
658
|
revokedSessions: number;
|
|
671
659
|
}
|
|
672
|
-
interface OidcVaultExchangeResult extends Partial<OidcVaultTokenIssueResult> {
|
|
673
|
-
/** Authoritative vault handle in body transport; omitted from cookie-transport JSON. */
|
|
674
|
-
sessionId?: string;
|
|
675
|
-
/** Session profile; extra token-issuer result properties cannot override it. */
|
|
676
|
-
user?: OidcVaultUserProfile;
|
|
677
|
-
}
|
|
678
|
-
/** JSON body for opt-in `POST <basePath>/login`; proof/key and recognition signals belong in their configured headers, not the body. */
|
|
679
|
-
interface OidcVaultLoginInitiationInput {
|
|
680
|
-
/** Optional destination on the configured frontend origin. Query-string returnTo is ignored by POST login. */
|
|
681
|
-
returnTo?: string;
|
|
682
|
-
}
|
|
683
|
-
/**
|
|
684
|
-
* Exact successful POST-login JSON. Navigate to this URL after storing a proof
|
|
685
|
-
* key when DPoP is enabled. Use credentials: 'include' even with body session
|
|
686
|
-
* transport: initiation sets a temporary HttpOnly transaction cookie.
|
|
687
|
-
*/
|
|
688
|
-
interface OidcVaultLoginInitiationResult {
|
|
689
|
-
authorizationUrl: string;
|
|
690
|
-
}
|
|
691
|
-
type OidcVaultSessionTransport = 'body' | 'cookie';
|
|
692
660
|
type OidcVaultCookieDeploymentMode = 'same-origin' | 'same-site' | 'cross-site';
|
|
693
661
|
type OidcVaultCookieSameSite = 'lax' | 'strict' | 'none';
|
|
694
662
|
/**
|
|
@@ -937,6 +905,10 @@ declare const OIDC_VAULT_ROUTE_PATHS: Record<OidcVaultRouteName, string>;
|
|
|
937
905
|
* callbacks/validator methods, URLs, algorithms and secret bytes; the replay
|
|
938
906
|
* store remains the shared atomic service. Responses carry no-store and fixed
|
|
939
907
|
* errors; onError privately observes originals and cannot override failures.
|
|
908
|
+
* The independent OIDC_VAULT_DPOP_IGNORE_TARGET_FAILURE,
|
|
909
|
+
* OIDC_VAULT_DPOP_IGNORE_FRESHNESS_FAILURE and OIDC_VAULT_DPOP_IGNORE_REPLAY_FAILURE
|
|
910
|
+
* environment defaults are captured at construction; ignored failures log to
|
|
911
|
+
* console.warn. Explicit deviceBinding booleans override those defaults.
|
|
940
912
|
*/
|
|
941
913
|
declare function createOidcVaultAccessTokenMiddleware(options: OidcVaultAccessTokenMiddlewareOptions): RequestHandler;
|
|
942
914
|
|
|
@@ -946,6 +918,10 @@ declare function createOidcVaultAccessTokenMiddleware(options: OidcVaultAccessTo
|
|
|
946
918
|
* the sender constraint. The request-aware result always has confirmation
|
|
947
919
|
* (null only for genuinely unbound JWTs). Legacy unbound results omit it;
|
|
948
920
|
* bound results report it so binding-disabled vault middleware refuses downgrade.
|
|
921
|
+
* Bound JWTs additionally require canonical compact encoding and a nonnegative
|
|
922
|
+
* safe-integer exp with safe milliseconds, checked before mapClaims in both
|
|
923
|
+
* methods. JOSE verifies signature/expiry and configured issuer/audience first. Unbound
|
|
924
|
+
* JWTs retain JOSE's generic optional-exp contract.
|
|
949
925
|
* Proof/target/ath/nonce/replay enforcement belongs to the API middleware.
|
|
950
926
|
* Construction captures options and copies secret/JWK/allowlist containers.
|
|
951
927
|
*/
|
|
@@ -985,7 +961,11 @@ declare function normalizeOidcVaultBasePath(value?: string): string;
|
|
|
985
961
|
* an enabled nonce secret is copied into private owned storage. Separate opt-in
|
|
986
962
|
* `fingerprintRecognition` settings are detached/frozen; recognition enrolls
|
|
987
963
|
* only at POST login and checks exchange/refresh before credential mutation.
|
|
964
|
+
* The independent OIDC_VAULT_DPOP_IGNORE_TARGET_FAILURE,
|
|
965
|
+
* OIDC_VAULT_DPOP_IGNORE_FRESHNESS_FAILURE and OIDC_VAULT_DPOP_IGNORE_REPLAY_FAILURE
|
|
966
|
+
* environment defaults are captured with the proof policy. Ignored failures
|
|
967
|
+
* log to console.warn; explicit deviceBinding booleans override those defaults.
|
|
988
968
|
*/
|
|
989
969
|
declare function createOidcVaultMiddleware(options: OidcVaultOptions): Router;
|
|
990
970
|
|
|
991
|
-
export { type AuthorizationTransaction, type AuthorizationTransactionInput, type ConsumeAuthorizationTransactionIfMatchesInput, type ConsumeBackchannelLogoutTokenJtiInput, type ConsumeExchangeCodeIfMatchesInput, DEFAULT_AUTHORIZATION_TRANSACTION_TTL_MS, DEFAULT_EXCHANGE_CODE_TTL_MS, DEFAULT_OIDC_SCOPES, DEFAULT_OIDC_VAULT_BASE_PATH, DEFAULT_OIDC_VAULT_REQUEST_BODY_LIMIT, type DeleteSessionsByLogicalSessionIdInput, type DeleteSessionsByProviderSessionIdInput, type DeleteSessionsBySubjectInput, type ExchangeCodeRecord, type ExchangeCodeRecordInput, type IssueTokenInput, OIDC_VAULT_ROUTE_PATHS, OIDC_VAULT_URL_ENCODED_PARAMETER_LIMIT, type OidcVaultAccessTokenConfirmation, type OidcVaultAccessTokenMiddlewareErrorContext, type OidcVaultAccessTokenMiddlewareOptions, type OidcVaultAccessTokenRequestInput, type OidcVaultAccessTokenValidationResult, type OidcVaultAccessTokenValidator, type OidcVaultApiDeviceBindingOptions, type OidcVaultAuthContext, type OidcVaultAuthenticatedRequest, type OidcVaultBackchannelLogoutResult, type OidcVaultConfig, type OidcVaultConfigMode, type OidcVaultCookieDeploymentMode, type OidcVaultCookieOptions, type OidcVaultCookieSameSite, type OidcVaultDeviceBindingMode, type OidcVaultDeviceBindingOptions, type OidcVaultDeviceBindingStoreProvider, type OidcVaultDpopAlgorithm, type OidcVaultDpopBinding, type OidcVaultDpopNonceOptions, type OidcVaultDpopProofOptions, OidcVaultDpopReplayCapacityError, type OidcVaultDpopReplayStore, type OidcVaultEnv, type OidcVaultErrorContext, type
|
|
971
|
+
export { type AuthorizationTransaction, type AuthorizationTransactionInput, type ConsumeAuthorizationTransactionIfMatchesInput, type ConsumeBackchannelLogoutTokenJtiInput, type ConsumeExchangeCodeIfMatchesInput, DEFAULT_AUTHORIZATION_TRANSACTION_TTL_MS, DEFAULT_EXCHANGE_CODE_TTL_MS, DEFAULT_OIDC_SCOPES, DEFAULT_OIDC_VAULT_BASE_PATH, DEFAULT_OIDC_VAULT_REQUEST_BODY_LIMIT, type DeleteSessionsByLogicalSessionIdInput, type DeleteSessionsByProviderSessionIdInput, type DeleteSessionsBySubjectInput, type ExchangeCodeRecord, type ExchangeCodeRecordInput, type IssueTokenInput, OIDC_VAULT_ROUTE_PATHS, OIDC_VAULT_URL_ENCODED_PARAMETER_LIMIT, type OidcVaultAccessTokenConfirmation, type OidcVaultAccessTokenMiddlewareErrorContext, type OidcVaultAccessTokenMiddlewareOptions, type OidcVaultAccessTokenRequestInput, type OidcVaultAccessTokenValidationResult, type OidcVaultAccessTokenValidator, type OidcVaultApiDeviceBindingOptions, type OidcVaultAuthContext, type OidcVaultAuthenticatedRequest, type OidcVaultBackchannelLogoutResult, type OidcVaultConfig, type OidcVaultConfigMode, type OidcVaultCookieDeploymentMode, type OidcVaultCookieOptions, type OidcVaultCookieSameSite, type OidcVaultDeviceBindingMode, type OidcVaultDeviceBindingOptions, type OidcVaultDeviceBindingStoreProvider, type OidcVaultDpopAlgorithm, type OidcVaultDpopBinding, type OidcVaultDpopNonceOptions, type OidcVaultDpopProofOptions, OidcVaultDpopReplayCapacityError, type OidcVaultDpopReplayStore, type OidcVaultEnv, type OidcVaultErrorContext, type OidcVaultFingerprintRecognitionOptions, type OidcVaultHookContext, type OidcVaultHooks, type OidcVaultJwtAccessTokenValidatorOptions, type OidcVaultOptions, type OidcVaultProviderMetadata, type OidcVaultRecordBindingMatch, type OidcVaultRequestAwareAccessTokenValidationResult, type OidcVaultRequestAwareAccessTokenValidator, type OidcVaultResolvedConfig, type OidcVaultRouteName, type OidcVaultSession, type OidcVaultSessionInput, type OidcVaultSessionRevocationContext, OidcVaultSessionTransport, OidcVaultStoreConflictError, type OidcVaultStoreProvider, OidcVaultTokenIssueResult, type OidcVaultTokenIssuer, type OidcVaultTransactionCookieOptions, OidcVaultUserProfile, type OidcVaultVerifiedDpopBinding, type ReserveDpopProofInput, type RotateSessionInput, createOidcVaultAccessTokenMiddleware, createOidcVaultJwtAccessTokenValidator, createOidcVaultMiddleware, normalizeOidcVaultBasePath, resolveOidcVaultConfig, resolveOidcVaultConfigFromEnv };
|