@openeudi/openid4vp 0.12.0 → 0.13.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 +51 -3
- package/dist/index.cjs +620 -84
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +112 -7
- package/dist/index.d.ts +112 -7
- package/dist/index.js +621 -86
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -267,8 +267,9 @@ declare class StaticTrustStore implements TrustStore {
|
|
|
267
267
|
}
|
|
268
268
|
/**
|
|
269
269
|
* Combines multiple `TrustStore` instances. Children are queried in parallel;
|
|
270
|
-
* results concatenate in child-order; duplicate anchors
|
|
271
|
-
*
|
|
270
|
+
* results concatenate in child-order; duplicate anchors (byte-identical DER)
|
|
271
|
+
* are dropped, first occurrence wins. Distinct certificates that share a key
|
|
272
|
+
* (e.g. a re-issued root) are both kept, so neither validity window is lost.
|
|
272
273
|
*/
|
|
273
274
|
declare class CompositeTrustStore implements TrustStore {
|
|
274
275
|
private readonly stores;
|
|
@@ -330,7 +331,9 @@ interface PresentationResult {
|
|
|
330
331
|
interface ParseOptions {
|
|
331
332
|
/**
|
|
332
333
|
* DER-encoded issuer leaf certificates used for byte-equality trust check.
|
|
333
|
-
* Kept for 0.4.0 compatibility.
|
|
334
|
+
* Kept for 0.4.0 compatibility. No chain building: a credential signed by a
|
|
335
|
+
* document signer issued under a listed root (e.g. an IACA) is rejected on
|
|
336
|
+
* this path — use `trustStore` for that.
|
|
334
337
|
* @deprecated since 0.5.0. Use `trustStore: new StaticTrustStore([...])`
|
|
335
338
|
* with root/intermediate CAs for RFC 5280 chain validation. Scheduled
|
|
336
339
|
* for removal in 1.0.0.
|
|
@@ -371,6 +374,15 @@ interface ParseOptions {
|
|
|
371
374
|
* Trust anchor resolver. When provided, the library performs RFC 5280
|
|
372
375
|
* chain validation and ignores `trustedCertificates`. When unset, the
|
|
373
376
|
* library falls back to 0.4.0 byte-equality against `trustedCertificates`.
|
|
377
|
+
*
|
|
378
|
+
* The credential's signer certificate (`x5c[0]` / `x5chain[0]`) is trusted
|
|
379
|
+
* when it either IS an anchor (byte-identical DER) or chains to one through
|
|
380
|
+
* verified signatures, using the remaining `x5c` / `x5chain` entries as
|
|
381
|
+
* untrusted path candidates. Anchors may be roots such as an ISO 18013-5
|
|
382
|
+
* IACA, or the document-signer certificate itself. For `mso_mdoc`, built
|
|
383
|
+
* chains must also satisfy the ISO 18013-5 Annex B certificate profile
|
|
384
|
+
* (DS EKU `1.0.18013.5.1.2`, mandatory keyUsage). Every certificate must be
|
|
385
|
+
* valid now and at the credential's issuance time (MSO `signed` / `iat`).
|
|
374
386
|
*/
|
|
375
387
|
trustStore?: TrustStore;
|
|
376
388
|
/**
|
|
@@ -378,7 +390,13 @@ interface ParseOptions {
|
|
|
378
390
|
* ship in 0.5.0 workstream A.2 — passing them today throws.
|
|
379
391
|
*/
|
|
380
392
|
revocationPolicy?: 'skip' | 'prefer' | 'require';
|
|
381
|
-
/**
|
|
393
|
+
/**
|
|
394
|
+
* HTTP transport for CRL/OCSP/LOTL fetches. Defaults to a guarded fetcher
|
|
395
|
+
* (`createGuardedFetcher({ allowHttp: true })`): no private/loopback/metadata
|
|
396
|
+
* targets, manual re-validated redirects (max 3), 15 s timeout, 16 MiB cap.
|
|
397
|
+
* A caller-supplied fetcher replaces those guards entirely — wrap it with
|
|
398
|
+
* `createGuardedFetcher({ fetch: yourFetcher })` to keep them.
|
|
399
|
+
*/
|
|
382
400
|
fetcher?: Fetcher;
|
|
383
401
|
/** Cache for CRL/OCSP/LOTL artefacts. Defaults to `new InMemoryCache()`. */
|
|
384
402
|
cache?: Cache;
|
|
@@ -405,6 +423,15 @@ interface ParseOptions {
|
|
|
405
423
|
* secure path.
|
|
406
424
|
*/
|
|
407
425
|
trustedIssuerJwks?: JsonWebKey[];
|
|
426
|
+
/**
|
|
427
|
+
* Accept the legacy `vc+sd-jwt` media type in the SD-JWT VC issuer JWT's
|
|
428
|
+
* `typ` header, in addition to `dc+sd-jwt`. Default `false`.
|
|
429
|
+
*
|
|
430
|
+
* @deprecated draft-ietf-oauth-sd-jwt-vc-19 removed `vc+sd-jwt`; only
|
|
431
|
+
* `dc+sd-jwt` is conformant. This exists solely to keep interoperating
|
|
432
|
+
* with wallets that have not migrated yet and will be removed in 1.0.0.
|
|
433
|
+
*/
|
|
434
|
+
allowLegacyVcSdJwtTyp?: boolean;
|
|
408
435
|
}
|
|
409
436
|
interface ICredentialParser {
|
|
410
437
|
readonly format: CredentialFormat;
|
|
@@ -628,7 +655,7 @@ declare abstract class OpenID4VPError extends Error {
|
|
|
628
655
|
declare class TrustAnchorNotFoundError extends OpenID4VPError {
|
|
629
656
|
readonly code: "trust_anchor_not_found";
|
|
630
657
|
}
|
|
631
|
-
type ChainErrorReason = 'signature' | 'validity' | 'name_constraints' | 'key_usage' | 'basic_constraints' | 'path_length' | 'algorithm_disallowed' | 'aki_ski_mismatch';
|
|
658
|
+
type ChainErrorReason = 'signature' | 'validity' | 'name_constraints' | 'key_usage' | 'extended_key_usage' | 'basic_constraints' | 'path_length' | 'algorithm_disallowed' | 'aki_ski_mismatch';
|
|
632
659
|
declare class CertificateChainError extends OpenID4VPError {
|
|
633
660
|
readonly code: "chain_invalid";
|
|
634
661
|
readonly reason: ChainErrorReason;
|
|
@@ -707,6 +734,84 @@ declare class MultipleCredentialsNotSupportedError extends OpenID4VPError {
|
|
|
707
734
|
readonly presentationCount: number;
|
|
708
735
|
constructor(entryCount: number, presentationCount: number);
|
|
709
736
|
}
|
|
737
|
+
type GuardedFetchRejectReason = 'invalid_url' | 'insecure_scheme' | 'private_address' | 'dns_resolution_failed' | 'too_many_redirects' | 'invalid_redirect' | 'response_too_large' | 'timeout';
|
|
738
|
+
/**
|
|
739
|
+
* A request was refused (or cut off) by the guarded fetcher before an
|
|
740
|
+
* untrusted endpoint could be reached or could exhaust resources.
|
|
741
|
+
*/
|
|
742
|
+
declare class GuardedFetchError extends OpenID4VPError {
|
|
743
|
+
readonly code: "guarded_fetch_rejected";
|
|
744
|
+
readonly reason: GuardedFetchRejectReason;
|
|
745
|
+
readonly url: string;
|
|
746
|
+
constructor(reason: GuardedFetchRejectReason, message: string, options: {
|
|
747
|
+
url: string;
|
|
748
|
+
cause?: Error;
|
|
749
|
+
});
|
|
750
|
+
}
|
|
751
|
+
|
|
752
|
+
/**
|
|
753
|
+
* Resolves a hostname to every IP address it currently maps to. Must return
|
|
754
|
+
* all records (A and AAAA): the guard rejects the host if ANY of them is
|
|
755
|
+
* non-public, and treats an empty result as a resolution failure.
|
|
756
|
+
*/
|
|
757
|
+
type HostLookup = (hostname: string) => Promise<readonly string[]>;
|
|
758
|
+
interface GuardedFetcherOptions {
|
|
759
|
+
/**
|
|
760
|
+
* Underlying transport. Defaults to `globalThis.fetch`, resolved at call
|
|
761
|
+
* time. Must honour `redirect: 'manual'` and expose the `Location` header
|
|
762
|
+
* of 3xx responses (Node's fetch/undici does; browsers return an opaque
|
|
763
|
+
* redirect, which the guard rejects).
|
|
764
|
+
*/
|
|
765
|
+
fetch?: Fetcher;
|
|
766
|
+
/**
|
|
767
|
+
* DNS resolver used for the private-address check. Defaults to
|
|
768
|
+
* `node:dns` `lookup(host, { all: true })` when available. In runtimes
|
|
769
|
+
* without `node:dns` (browsers, some edge workers) only IP-literal and
|
|
770
|
+
* `localhost` targets are checked — inject a resolver there if needed.
|
|
771
|
+
*/
|
|
772
|
+
lookup?: HostLookup;
|
|
773
|
+
/** Permit `http:` targets. Default `false` (SD-JWT VC draft-19: HTTPS only). */
|
|
774
|
+
allowHttp?: boolean;
|
|
775
|
+
/** Permit loopback / private / link-local / metadata targets. Default `false`. */
|
|
776
|
+
allowPrivateNetworks?: boolean;
|
|
777
|
+
/** Maximum redirects followed; every hop is re-validated. Default 3. */
|
|
778
|
+
maxRedirects?: number;
|
|
779
|
+
/** Wall-clock budget for the whole exchange (DNS, redirects, body). Default 15 000 ms. */
|
|
780
|
+
timeoutMs?: number;
|
|
781
|
+
/** Maximum response body size, enforced while streaming. Default 16 MiB. */
|
|
782
|
+
maxResponseBytes?: number;
|
|
783
|
+
}
|
|
784
|
+
declare const GUARDED_FETCH_DEFAULTS: {
|
|
785
|
+
readonly maxRedirects: 3;
|
|
786
|
+
readonly timeoutMs: 15000;
|
|
787
|
+
readonly maxResponseBytes: number;
|
|
788
|
+
};
|
|
789
|
+
/**
|
|
790
|
+
* Builds a {@link Fetcher} that applies the HTTP-retrieval rules of
|
|
791
|
+
* draft-ietf-oauth-sd-jwt-vc-19 to every request:
|
|
792
|
+
*
|
|
793
|
+
* - HTTPS only (unless `allowHttp`), and never an https → http downgrade
|
|
794
|
+
* - no loopback / private / link-local / cloud-metadata targets, checked
|
|
795
|
+
* on the URL host AND every address it resolves to (IPv4, IPv6,
|
|
796
|
+
* IPv4-mapped/compatible, NAT64, 6to4)
|
|
797
|
+
* - redirects handled manually, bounded, and re-validated hop by hop
|
|
798
|
+
* - a single timeout covering DNS, every hop and the body
|
|
799
|
+
* - a response-size cap enforced while streaming
|
|
800
|
+
*
|
|
801
|
+
* **DNS rebinding.** The guard resolves the host, validates the addresses,
|
|
802
|
+
* then hands the *hostname* to the transport, which resolves it again. An
|
|
803
|
+
* attacker-controlled DNS server can answer differently the second time
|
|
804
|
+
* (TOCTOU). Closing that gap requires pinning the validated address at the
|
|
805
|
+
* socket layer, which `fetch` does not expose portably. Deployments that
|
|
806
|
+
* dereference attacker-influenced URLs should additionally route egress
|
|
807
|
+
* through a filtering proxy or inject a transport whose connector validates
|
|
808
|
+
* the connected address (e.g. an undici `Agent` with a checking
|
|
809
|
+
* `connect.lookup`).
|
|
810
|
+
*
|
|
811
|
+
* Caching is out of scope here: the trust module caches CRL/OCSP/LOTL
|
|
812
|
+
* artefacts through its own {@link Cache} plug.
|
|
813
|
+
*/
|
|
814
|
+
declare function createGuardedFetcher(options?: GuardedFetcherOptions): Fetcher;
|
|
710
815
|
|
|
711
816
|
interface LotlTrustStoreOptions {
|
|
712
817
|
/** Override the bundled signing anchors. Empty is rejected. */
|
|
@@ -745,6 +850,6 @@ declare class LotlTrustStore implements TrustStore {
|
|
|
745
850
|
private refresh;
|
|
746
851
|
}
|
|
747
852
|
|
|
748
|
-
declare const VERSION = "0.
|
|
853
|
+
declare const VERSION = "0.13.0";
|
|
749
854
|
|
|
750
|
-
export { type AuthorizationRequest, type AuthorizationRequestInput, type AuthorizationResponse, type Cache, CertificateChainError, type ChainErrorReason, CompositeTrustStore, type CredentialClaims, type CredentialFormat, type CredentialSetQueryInput, DecryptionFailedError, type EncryptedResponse, ExpiredCredentialError, type Fetcher, HAIP_DOCTYPE_NAMESPACES, type HaipQueryInput, type HaipValidationCode, HaipValidationError, type ICredentialParser, InMemoryCache, InvalidSignatureError, type IssuerInfo, type LotlAnchorMetadata, LotlConfigurationError, LotlFetchError, LotlSignatureError, LotlTrustStore, type LotlTrustStoreOptions, MalformedCredentialError, MdocParser, MissingDecryptionKeyError, MissingVerifierEncryptionKeyError, MultipleCredentialsNotSupportedError, NonceValidationError, OpenID4VPError, type ParseOptions, type PresentationResult, RevocationCheckFailedError, RevokedCertificateError, SdJwtParser, type SignedAuthorizationRequest, type SignedAuthorizationRequestInput, SignedRequestBuildError, type SignedRequestBuildErrorCode, StaticTrustStore, type TrustAnchor, TrustAnchorNotFoundError, type TrustStore, type TrustStoreHint, type TrustStoreInput, UnsupportedFormatError, UnsupportedJweError, VERSION, type VerifyAuthorizationResponseOptions, type VerifyOptions, type VerifyResult, buildCredentialSetQuery, buildHaipQuery, buildOid4vpSessionTranscript, buildOpenID4VPHandoverSessionTranscript, createAuthorizationRequest, createSignedAuthorizationRequest, decryptAuthorizationResponse, isHaipQuery, parsePresentation, validateCredentialSetQuery, validateHaipQuery, verifyAuthorizationResponse, verifyPresentation };
|
|
855
|
+
export { type AuthorizationRequest, type AuthorizationRequestInput, type AuthorizationResponse, type Cache, CertificateChainError, type ChainErrorReason, CompositeTrustStore, type CredentialClaims, type CredentialFormat, type CredentialSetQueryInput, DecryptionFailedError, type EncryptedResponse, ExpiredCredentialError, type Fetcher, GUARDED_FETCH_DEFAULTS, GuardedFetchError, type GuardedFetchRejectReason, type GuardedFetcherOptions, HAIP_DOCTYPE_NAMESPACES, type HaipQueryInput, type HaipValidationCode, HaipValidationError, type HostLookup, type ICredentialParser, InMemoryCache, InvalidSignatureError, type IssuerInfo, type LotlAnchorMetadata, LotlConfigurationError, LotlFetchError, LotlSignatureError, LotlTrustStore, type LotlTrustStoreOptions, MalformedCredentialError, MdocParser, MissingDecryptionKeyError, MissingVerifierEncryptionKeyError, MultipleCredentialsNotSupportedError, NonceValidationError, OpenID4VPError, type ParseOptions, type PresentationResult, RevocationCheckFailedError, RevokedCertificateError, SdJwtParser, type SignedAuthorizationRequest, type SignedAuthorizationRequestInput, SignedRequestBuildError, type SignedRequestBuildErrorCode, StaticTrustStore, type TrustAnchor, TrustAnchorNotFoundError, type TrustStore, type TrustStoreHint, type TrustStoreInput, UnsupportedFormatError, UnsupportedJweError, VERSION, type VerifyAuthorizationResponseOptions, type VerifyOptions, type VerifyResult, buildCredentialSetQuery, buildHaipQuery, buildOid4vpSessionTranscript, buildOpenID4VPHandoverSessionTranscript, createAuthorizationRequest, createGuardedFetcher, createSignedAuthorizationRequest, decryptAuthorizationResponse, isHaipQuery, parsePresentation, validateCredentialSetQuery, validateHaipQuery, verifyAuthorizationResponse, verifyPresentation };
|
package/dist/index.d.ts
CHANGED
|
@@ -267,8 +267,9 @@ declare class StaticTrustStore implements TrustStore {
|
|
|
267
267
|
}
|
|
268
268
|
/**
|
|
269
269
|
* Combines multiple `TrustStore` instances. Children are queried in parallel;
|
|
270
|
-
* results concatenate in child-order; duplicate anchors
|
|
271
|
-
*
|
|
270
|
+
* results concatenate in child-order; duplicate anchors (byte-identical DER)
|
|
271
|
+
* are dropped, first occurrence wins. Distinct certificates that share a key
|
|
272
|
+
* (e.g. a re-issued root) are both kept, so neither validity window is lost.
|
|
272
273
|
*/
|
|
273
274
|
declare class CompositeTrustStore implements TrustStore {
|
|
274
275
|
private readonly stores;
|
|
@@ -330,7 +331,9 @@ interface PresentationResult {
|
|
|
330
331
|
interface ParseOptions {
|
|
331
332
|
/**
|
|
332
333
|
* DER-encoded issuer leaf certificates used for byte-equality trust check.
|
|
333
|
-
* Kept for 0.4.0 compatibility.
|
|
334
|
+
* Kept for 0.4.0 compatibility. No chain building: a credential signed by a
|
|
335
|
+
* document signer issued under a listed root (e.g. an IACA) is rejected on
|
|
336
|
+
* this path — use `trustStore` for that.
|
|
334
337
|
* @deprecated since 0.5.0. Use `trustStore: new StaticTrustStore([...])`
|
|
335
338
|
* with root/intermediate CAs for RFC 5280 chain validation. Scheduled
|
|
336
339
|
* for removal in 1.0.0.
|
|
@@ -371,6 +374,15 @@ interface ParseOptions {
|
|
|
371
374
|
* Trust anchor resolver. When provided, the library performs RFC 5280
|
|
372
375
|
* chain validation and ignores `trustedCertificates`. When unset, the
|
|
373
376
|
* library falls back to 0.4.0 byte-equality against `trustedCertificates`.
|
|
377
|
+
*
|
|
378
|
+
* The credential's signer certificate (`x5c[0]` / `x5chain[0]`) is trusted
|
|
379
|
+
* when it either IS an anchor (byte-identical DER) or chains to one through
|
|
380
|
+
* verified signatures, using the remaining `x5c` / `x5chain` entries as
|
|
381
|
+
* untrusted path candidates. Anchors may be roots such as an ISO 18013-5
|
|
382
|
+
* IACA, or the document-signer certificate itself. For `mso_mdoc`, built
|
|
383
|
+
* chains must also satisfy the ISO 18013-5 Annex B certificate profile
|
|
384
|
+
* (DS EKU `1.0.18013.5.1.2`, mandatory keyUsage). Every certificate must be
|
|
385
|
+
* valid now and at the credential's issuance time (MSO `signed` / `iat`).
|
|
374
386
|
*/
|
|
375
387
|
trustStore?: TrustStore;
|
|
376
388
|
/**
|
|
@@ -378,7 +390,13 @@ interface ParseOptions {
|
|
|
378
390
|
* ship in 0.5.0 workstream A.2 — passing them today throws.
|
|
379
391
|
*/
|
|
380
392
|
revocationPolicy?: 'skip' | 'prefer' | 'require';
|
|
381
|
-
/**
|
|
393
|
+
/**
|
|
394
|
+
* HTTP transport for CRL/OCSP/LOTL fetches. Defaults to a guarded fetcher
|
|
395
|
+
* (`createGuardedFetcher({ allowHttp: true })`): no private/loopback/metadata
|
|
396
|
+
* targets, manual re-validated redirects (max 3), 15 s timeout, 16 MiB cap.
|
|
397
|
+
* A caller-supplied fetcher replaces those guards entirely — wrap it with
|
|
398
|
+
* `createGuardedFetcher({ fetch: yourFetcher })` to keep them.
|
|
399
|
+
*/
|
|
382
400
|
fetcher?: Fetcher;
|
|
383
401
|
/** Cache for CRL/OCSP/LOTL artefacts. Defaults to `new InMemoryCache()`. */
|
|
384
402
|
cache?: Cache;
|
|
@@ -405,6 +423,15 @@ interface ParseOptions {
|
|
|
405
423
|
* secure path.
|
|
406
424
|
*/
|
|
407
425
|
trustedIssuerJwks?: JsonWebKey[];
|
|
426
|
+
/**
|
|
427
|
+
* Accept the legacy `vc+sd-jwt` media type in the SD-JWT VC issuer JWT's
|
|
428
|
+
* `typ` header, in addition to `dc+sd-jwt`. Default `false`.
|
|
429
|
+
*
|
|
430
|
+
* @deprecated draft-ietf-oauth-sd-jwt-vc-19 removed `vc+sd-jwt`; only
|
|
431
|
+
* `dc+sd-jwt` is conformant. This exists solely to keep interoperating
|
|
432
|
+
* with wallets that have not migrated yet and will be removed in 1.0.0.
|
|
433
|
+
*/
|
|
434
|
+
allowLegacyVcSdJwtTyp?: boolean;
|
|
408
435
|
}
|
|
409
436
|
interface ICredentialParser {
|
|
410
437
|
readonly format: CredentialFormat;
|
|
@@ -628,7 +655,7 @@ declare abstract class OpenID4VPError extends Error {
|
|
|
628
655
|
declare class TrustAnchorNotFoundError extends OpenID4VPError {
|
|
629
656
|
readonly code: "trust_anchor_not_found";
|
|
630
657
|
}
|
|
631
|
-
type ChainErrorReason = 'signature' | 'validity' | 'name_constraints' | 'key_usage' | 'basic_constraints' | 'path_length' | 'algorithm_disallowed' | 'aki_ski_mismatch';
|
|
658
|
+
type ChainErrorReason = 'signature' | 'validity' | 'name_constraints' | 'key_usage' | 'extended_key_usage' | 'basic_constraints' | 'path_length' | 'algorithm_disallowed' | 'aki_ski_mismatch';
|
|
632
659
|
declare class CertificateChainError extends OpenID4VPError {
|
|
633
660
|
readonly code: "chain_invalid";
|
|
634
661
|
readonly reason: ChainErrorReason;
|
|
@@ -707,6 +734,84 @@ declare class MultipleCredentialsNotSupportedError extends OpenID4VPError {
|
|
|
707
734
|
readonly presentationCount: number;
|
|
708
735
|
constructor(entryCount: number, presentationCount: number);
|
|
709
736
|
}
|
|
737
|
+
type GuardedFetchRejectReason = 'invalid_url' | 'insecure_scheme' | 'private_address' | 'dns_resolution_failed' | 'too_many_redirects' | 'invalid_redirect' | 'response_too_large' | 'timeout';
|
|
738
|
+
/**
|
|
739
|
+
* A request was refused (or cut off) by the guarded fetcher before an
|
|
740
|
+
* untrusted endpoint could be reached or could exhaust resources.
|
|
741
|
+
*/
|
|
742
|
+
declare class GuardedFetchError extends OpenID4VPError {
|
|
743
|
+
readonly code: "guarded_fetch_rejected";
|
|
744
|
+
readonly reason: GuardedFetchRejectReason;
|
|
745
|
+
readonly url: string;
|
|
746
|
+
constructor(reason: GuardedFetchRejectReason, message: string, options: {
|
|
747
|
+
url: string;
|
|
748
|
+
cause?: Error;
|
|
749
|
+
});
|
|
750
|
+
}
|
|
751
|
+
|
|
752
|
+
/**
|
|
753
|
+
* Resolves a hostname to every IP address it currently maps to. Must return
|
|
754
|
+
* all records (A and AAAA): the guard rejects the host if ANY of them is
|
|
755
|
+
* non-public, and treats an empty result as a resolution failure.
|
|
756
|
+
*/
|
|
757
|
+
type HostLookup = (hostname: string) => Promise<readonly string[]>;
|
|
758
|
+
interface GuardedFetcherOptions {
|
|
759
|
+
/**
|
|
760
|
+
* Underlying transport. Defaults to `globalThis.fetch`, resolved at call
|
|
761
|
+
* time. Must honour `redirect: 'manual'` and expose the `Location` header
|
|
762
|
+
* of 3xx responses (Node's fetch/undici does; browsers return an opaque
|
|
763
|
+
* redirect, which the guard rejects).
|
|
764
|
+
*/
|
|
765
|
+
fetch?: Fetcher;
|
|
766
|
+
/**
|
|
767
|
+
* DNS resolver used for the private-address check. Defaults to
|
|
768
|
+
* `node:dns` `lookup(host, { all: true })` when available. In runtimes
|
|
769
|
+
* without `node:dns` (browsers, some edge workers) only IP-literal and
|
|
770
|
+
* `localhost` targets are checked — inject a resolver there if needed.
|
|
771
|
+
*/
|
|
772
|
+
lookup?: HostLookup;
|
|
773
|
+
/** Permit `http:` targets. Default `false` (SD-JWT VC draft-19: HTTPS only). */
|
|
774
|
+
allowHttp?: boolean;
|
|
775
|
+
/** Permit loopback / private / link-local / metadata targets. Default `false`. */
|
|
776
|
+
allowPrivateNetworks?: boolean;
|
|
777
|
+
/** Maximum redirects followed; every hop is re-validated. Default 3. */
|
|
778
|
+
maxRedirects?: number;
|
|
779
|
+
/** Wall-clock budget for the whole exchange (DNS, redirects, body). Default 15 000 ms. */
|
|
780
|
+
timeoutMs?: number;
|
|
781
|
+
/** Maximum response body size, enforced while streaming. Default 16 MiB. */
|
|
782
|
+
maxResponseBytes?: number;
|
|
783
|
+
}
|
|
784
|
+
declare const GUARDED_FETCH_DEFAULTS: {
|
|
785
|
+
readonly maxRedirects: 3;
|
|
786
|
+
readonly timeoutMs: 15000;
|
|
787
|
+
readonly maxResponseBytes: number;
|
|
788
|
+
};
|
|
789
|
+
/**
|
|
790
|
+
* Builds a {@link Fetcher} that applies the HTTP-retrieval rules of
|
|
791
|
+
* draft-ietf-oauth-sd-jwt-vc-19 to every request:
|
|
792
|
+
*
|
|
793
|
+
* - HTTPS only (unless `allowHttp`), and never an https → http downgrade
|
|
794
|
+
* - no loopback / private / link-local / cloud-metadata targets, checked
|
|
795
|
+
* on the URL host AND every address it resolves to (IPv4, IPv6,
|
|
796
|
+
* IPv4-mapped/compatible, NAT64, 6to4)
|
|
797
|
+
* - redirects handled manually, bounded, and re-validated hop by hop
|
|
798
|
+
* - a single timeout covering DNS, every hop and the body
|
|
799
|
+
* - a response-size cap enforced while streaming
|
|
800
|
+
*
|
|
801
|
+
* **DNS rebinding.** The guard resolves the host, validates the addresses,
|
|
802
|
+
* then hands the *hostname* to the transport, which resolves it again. An
|
|
803
|
+
* attacker-controlled DNS server can answer differently the second time
|
|
804
|
+
* (TOCTOU). Closing that gap requires pinning the validated address at the
|
|
805
|
+
* socket layer, which `fetch` does not expose portably. Deployments that
|
|
806
|
+
* dereference attacker-influenced URLs should additionally route egress
|
|
807
|
+
* through a filtering proxy or inject a transport whose connector validates
|
|
808
|
+
* the connected address (e.g. an undici `Agent` with a checking
|
|
809
|
+
* `connect.lookup`).
|
|
810
|
+
*
|
|
811
|
+
* Caching is out of scope here: the trust module caches CRL/OCSP/LOTL
|
|
812
|
+
* artefacts through its own {@link Cache} plug.
|
|
813
|
+
*/
|
|
814
|
+
declare function createGuardedFetcher(options?: GuardedFetcherOptions): Fetcher;
|
|
710
815
|
|
|
711
816
|
interface LotlTrustStoreOptions {
|
|
712
817
|
/** Override the bundled signing anchors. Empty is rejected. */
|
|
@@ -745,6 +850,6 @@ declare class LotlTrustStore implements TrustStore {
|
|
|
745
850
|
private refresh;
|
|
746
851
|
}
|
|
747
852
|
|
|
748
|
-
declare const VERSION = "0.
|
|
853
|
+
declare const VERSION = "0.13.0";
|
|
749
854
|
|
|
750
|
-
export { type AuthorizationRequest, type AuthorizationRequestInput, type AuthorizationResponse, type Cache, CertificateChainError, type ChainErrorReason, CompositeTrustStore, type CredentialClaims, type CredentialFormat, type CredentialSetQueryInput, DecryptionFailedError, type EncryptedResponse, ExpiredCredentialError, type Fetcher, HAIP_DOCTYPE_NAMESPACES, type HaipQueryInput, type HaipValidationCode, HaipValidationError, type ICredentialParser, InMemoryCache, InvalidSignatureError, type IssuerInfo, type LotlAnchorMetadata, LotlConfigurationError, LotlFetchError, LotlSignatureError, LotlTrustStore, type LotlTrustStoreOptions, MalformedCredentialError, MdocParser, MissingDecryptionKeyError, MissingVerifierEncryptionKeyError, MultipleCredentialsNotSupportedError, NonceValidationError, OpenID4VPError, type ParseOptions, type PresentationResult, RevocationCheckFailedError, RevokedCertificateError, SdJwtParser, type SignedAuthorizationRequest, type SignedAuthorizationRequestInput, SignedRequestBuildError, type SignedRequestBuildErrorCode, StaticTrustStore, type TrustAnchor, TrustAnchorNotFoundError, type TrustStore, type TrustStoreHint, type TrustStoreInput, UnsupportedFormatError, UnsupportedJweError, VERSION, type VerifyAuthorizationResponseOptions, type VerifyOptions, type VerifyResult, buildCredentialSetQuery, buildHaipQuery, buildOid4vpSessionTranscript, buildOpenID4VPHandoverSessionTranscript, createAuthorizationRequest, createSignedAuthorizationRequest, decryptAuthorizationResponse, isHaipQuery, parsePresentation, validateCredentialSetQuery, validateHaipQuery, verifyAuthorizationResponse, verifyPresentation };
|
|
855
|
+
export { type AuthorizationRequest, type AuthorizationRequestInput, type AuthorizationResponse, type Cache, CertificateChainError, type ChainErrorReason, CompositeTrustStore, type CredentialClaims, type CredentialFormat, type CredentialSetQueryInput, DecryptionFailedError, type EncryptedResponse, ExpiredCredentialError, type Fetcher, GUARDED_FETCH_DEFAULTS, GuardedFetchError, type GuardedFetchRejectReason, type GuardedFetcherOptions, HAIP_DOCTYPE_NAMESPACES, type HaipQueryInput, type HaipValidationCode, HaipValidationError, type HostLookup, type ICredentialParser, InMemoryCache, InvalidSignatureError, type IssuerInfo, type LotlAnchorMetadata, LotlConfigurationError, LotlFetchError, LotlSignatureError, LotlTrustStore, type LotlTrustStoreOptions, MalformedCredentialError, MdocParser, MissingDecryptionKeyError, MissingVerifierEncryptionKeyError, MultipleCredentialsNotSupportedError, NonceValidationError, OpenID4VPError, type ParseOptions, type PresentationResult, RevocationCheckFailedError, RevokedCertificateError, SdJwtParser, type SignedAuthorizationRequest, type SignedAuthorizationRequestInput, SignedRequestBuildError, type SignedRequestBuildErrorCode, StaticTrustStore, type TrustAnchor, TrustAnchorNotFoundError, type TrustStore, type TrustStoreHint, type TrustStoreInput, UnsupportedFormatError, UnsupportedJweError, VERSION, type VerifyAuthorizationResponseOptions, type VerifyOptions, type VerifyResult, buildCredentialSetQuery, buildHaipQuery, buildOid4vpSessionTranscript, buildOpenID4VPHandoverSessionTranscript, createAuthorizationRequest, createGuardedFetcher, createSignedAuthorizationRequest, decryptAuthorizationResponse, isHaipQuery, parsePresentation, validateCredentialSetQuery, validateHaipQuery, verifyAuthorizationResponse, verifyPresentation };
|