@openeudi/openid4vp 0.5.0 → 0.7.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 +93 -1
- package/dist/index.cjs +371 -89
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +103 -2
- package/dist/index.d.ts +103 -2
- package/dist/index.js +369 -90
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -15,9 +15,49 @@ interface AuthorizationRequest {
|
|
|
15
15
|
nonce: string;
|
|
16
16
|
state: string;
|
|
17
17
|
}
|
|
18
|
+
interface SignedAuthorizationRequestInput {
|
|
19
|
+
hostname: string;
|
|
20
|
+
requestUri: string;
|
|
21
|
+
responseUri: string;
|
|
22
|
+
nonce: string;
|
|
23
|
+
state?: string;
|
|
24
|
+
responseMode?: 'direct_post' | 'direct_post.jwt';
|
|
25
|
+
signer: CryptoKeyPair;
|
|
26
|
+
signingAlgorithm?: 'ES256' | 'ES384' | 'RS256';
|
|
27
|
+
certificateChain: Uint8Array[];
|
|
28
|
+
encryptionKey?: {
|
|
29
|
+
publicJwk: JsonWebKey;
|
|
30
|
+
supportedEncValues?: string[];
|
|
31
|
+
};
|
|
32
|
+
vpFormatsSupported: Record<string, unknown>;
|
|
33
|
+
}
|
|
34
|
+
interface SignedAuthorizationRequest {
|
|
35
|
+
uri: string;
|
|
36
|
+
requestObject: string;
|
|
37
|
+
dcqlQuery: DcqlQuery;
|
|
38
|
+
nonce: string;
|
|
39
|
+
state: string;
|
|
40
|
+
}
|
|
41
|
+
interface AuthorizationResponse {
|
|
42
|
+
vp_token: Record<string, Array<string | object>>;
|
|
43
|
+
state?: string;
|
|
44
|
+
[key: string]: unknown;
|
|
45
|
+
}
|
|
18
46
|
|
|
19
47
|
declare function createAuthorizationRequest(input: AuthorizationRequestInput, query: DcqlQuery): AuthorizationRequest;
|
|
20
48
|
|
|
49
|
+
/**
|
|
50
|
+
* Build a signed authorization request (JAR) per OpenID4VP 1.0 §5.10 / RFC 9101.
|
|
51
|
+
*
|
|
52
|
+
* Validates that the signing key is bound to the leaf certificate and that the
|
|
53
|
+
* leaf cert's SAN DNSName equals the declared hostname. Emits a short URI
|
|
54
|
+
* carrying only `client_id` + `request_uri`, plus the JWS string the caller
|
|
55
|
+
* must host at `requestUri` with Content-Type `application/oauth-authz-req+jwt`.
|
|
56
|
+
*
|
|
57
|
+
* Client Identifier Prefix is always `x509_san_dns` — other prefixes deferred.
|
|
58
|
+
*/
|
|
59
|
+
declare function createSignedAuthorizationRequest(input: SignedAuthorizationRequestInput, query: DcqlQuery): Promise<SignedAuthorizationRequest>;
|
|
60
|
+
|
|
21
61
|
interface HaipQueryInput {
|
|
22
62
|
credentialId: string;
|
|
23
63
|
format: 'dc+sd-jwt' | 'mso_mdoc';
|
|
@@ -293,6 +333,12 @@ interface VerifyResult {
|
|
|
293
333
|
submission: DcqlSubmission | null;
|
|
294
334
|
valid: boolean;
|
|
295
335
|
}
|
|
336
|
+
interface EncryptedResponse {
|
|
337
|
+
response: string;
|
|
338
|
+
}
|
|
339
|
+
type VerifyAuthorizationResponseOptions = VerifyOptions & {
|
|
340
|
+
decryptionKey?: CryptoKey;
|
|
341
|
+
};
|
|
296
342
|
|
|
297
343
|
/**
|
|
298
344
|
* Parses a VP token, then matches it against a DCQL query.
|
|
@@ -306,6 +352,34 @@ interface VerifyResult {
|
|
|
306
352
|
* @param options parse + verify options (nonce, trusted issuers, etc.)
|
|
307
353
|
*/
|
|
308
354
|
declare function verifyPresentation(vpToken: unknown, query: DcqlQuery, options: VerifyOptions): Promise<VerifyResult>;
|
|
355
|
+
/**
|
|
356
|
+
* Verify an OpenID4VP 1.0 §8.1 Authorization Response envelope.
|
|
357
|
+
*
|
|
358
|
+
* Accepts either the unencrypted envelope (object-keyed `vp_token`) or a
|
|
359
|
+
* JWE-wrapped envelope `{ response: '<JWE>' }` for response_mode =
|
|
360
|
+
* direct_post.jwt. When encrypted, decrypts with `options.decryptionKey`
|
|
361
|
+
* first. For this release only single-credential single-presentation is
|
|
362
|
+
* supported — multi-credential envelopes throw
|
|
363
|
+
* {@link MultipleCredentialsNotSupportedError}. Otherwise delegates the
|
|
364
|
+
* extracted single presentation to the existing {@link verifyPresentation}.
|
|
365
|
+
*
|
|
366
|
+
* Callers MUST compare the envelope's `state` against the value they issued
|
|
367
|
+
* themselves — library is stateless and does not track state.
|
|
368
|
+
*/
|
|
369
|
+
declare function verifyAuthorizationResponse(envelope: AuthorizationResponse | EncryptedResponse, query: DcqlQuery, options: VerifyAuthorizationResponseOptions): Promise<VerifyResult>;
|
|
370
|
+
|
|
371
|
+
/**
|
|
372
|
+
* Decrypt a JWE-wrapped OpenID4VP Authorization Response (response_mode =
|
|
373
|
+
* direct_post.jwt). Returns the inner §8.1 envelope.
|
|
374
|
+
*
|
|
375
|
+
* Supported JWE algorithms (others throw UnsupportedJweError):
|
|
376
|
+
* - alg: ECDH-ES
|
|
377
|
+
* - enc: A128GCM, A256GCM (HAIP requires both)
|
|
378
|
+
*
|
|
379
|
+
* Cryptographic failures (wrong key, tampered ciphertext) throw
|
|
380
|
+
* DecryptionFailedError.
|
|
381
|
+
*/
|
|
382
|
+
declare function decryptAuthorizationResponse(jwe: string, privateKey: CryptoKey): Promise<AuthorizationResponse>;
|
|
309
383
|
|
|
310
384
|
/**
|
|
311
385
|
* SD-JWT VC credential parser.
|
|
@@ -416,6 +490,33 @@ declare class LotlFetchError extends OpenID4VPError {
|
|
|
416
490
|
declare class LotlSignatureError extends OpenID4VPError {
|
|
417
491
|
readonly code: "lotl_signature_invalid";
|
|
418
492
|
}
|
|
493
|
+
type SignedRequestBuildErrorCode = 'empty_cert_chain' | 'hostname_cert_mismatch' | 'signing_key_cert_mismatch' | 'missing_encryption_jwk' | 'missing_encryption_alg' | 'missing_vp_formats' | 'unsupported_signing_alg' | 'empty_supported_enc_values';
|
|
494
|
+
declare class SignedRequestBuildError extends OpenID4VPError {
|
|
495
|
+
readonly code: SignedRequestBuildErrorCode;
|
|
496
|
+
constructor(code: SignedRequestBuildErrorCode, message: string);
|
|
497
|
+
}
|
|
498
|
+
declare class UnsupportedJweError extends OpenID4VPError {
|
|
499
|
+
readonly code: "unsupported_jwe";
|
|
500
|
+
readonly alg: string;
|
|
501
|
+
readonly enc: string;
|
|
502
|
+
constructor(alg: string, enc: string);
|
|
503
|
+
}
|
|
504
|
+
declare class DecryptionFailedError extends OpenID4VPError {
|
|
505
|
+
readonly code: "decryption_failed";
|
|
506
|
+
constructor(message?: string, options?: {
|
|
507
|
+
cause?: Error;
|
|
508
|
+
});
|
|
509
|
+
}
|
|
510
|
+
declare class MissingDecryptionKeyError extends OpenID4VPError {
|
|
511
|
+
readonly code: "missing_decryption_key";
|
|
512
|
+
constructor(message?: string);
|
|
513
|
+
}
|
|
514
|
+
declare class MultipleCredentialsNotSupportedError extends OpenID4VPError {
|
|
515
|
+
readonly code: "multi_credential_unsupported";
|
|
516
|
+
readonly entryCount: number;
|
|
517
|
+
readonly presentationCount: number;
|
|
518
|
+
constructor(entryCount: number, presentationCount: number);
|
|
519
|
+
}
|
|
419
520
|
|
|
420
521
|
interface LotlTrustStoreOptions {
|
|
421
522
|
/** Override the bundled signing anchors. Empty is rejected. */
|
|
@@ -454,6 +555,6 @@ declare class LotlTrustStore implements TrustStore {
|
|
|
454
555
|
private refresh;
|
|
455
556
|
}
|
|
456
557
|
|
|
457
|
-
declare const VERSION = "0.
|
|
558
|
+
declare const VERSION = "0.7.0";
|
|
458
559
|
|
|
459
|
-
export { type AuthorizationRequest, type AuthorizationRequestInput, type Cache, CertificateChainError, type ChainErrorReason, CompositeTrustStore, type CredentialClaims, type CredentialFormat, ExpiredCredentialError, type Fetcher, HAIP_DOCTYPE_NAMESPACES, type HaipQueryInput, type HaipValidationCode, HaipValidationError, type ICredentialParser, InMemoryCache, InvalidSignatureError, type IssuerInfo, type LotlAnchorMetadata, LotlFetchError, LotlSignatureError, LotlTrustStore, type LotlTrustStoreOptions, MalformedCredentialError, MdocParser, NonceValidationError, OpenID4VPError, type ParseOptions, type PresentationResult, RevocationCheckFailedError, RevokedCertificateError, SdJwtParser, StaticTrustStore, type TrustAnchor, TrustAnchorNotFoundError, type TrustStore, type TrustStoreHint, type TrustStoreInput, UnsupportedFormatError, VERSION, type VerifyOptions, type VerifyResult, buildHaipQuery, createAuthorizationRequest, isHaipQuery, parsePresentation, validateHaipQuery, verifyPresentation };
|
|
560
|
+
export { type AuthorizationRequest, type AuthorizationRequestInput, type AuthorizationResponse, type Cache, CertificateChainError, type ChainErrorReason, CompositeTrustStore, type CredentialClaims, type CredentialFormat, DecryptionFailedError, type EncryptedResponse, ExpiredCredentialError, type Fetcher, HAIP_DOCTYPE_NAMESPACES, type HaipQueryInput, type HaipValidationCode, HaipValidationError, type ICredentialParser, InMemoryCache, InvalidSignatureError, type IssuerInfo, type LotlAnchorMetadata, LotlFetchError, LotlSignatureError, LotlTrustStore, type LotlTrustStoreOptions, MalformedCredentialError, MdocParser, MissingDecryptionKeyError, 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, buildHaipQuery, createAuthorizationRequest, createSignedAuthorizationRequest, decryptAuthorizationResponse, isHaipQuery, parsePresentation, validateHaipQuery, verifyAuthorizationResponse, verifyPresentation };
|
package/dist/index.d.ts
CHANGED
|
@@ -15,9 +15,49 @@ interface AuthorizationRequest {
|
|
|
15
15
|
nonce: string;
|
|
16
16
|
state: string;
|
|
17
17
|
}
|
|
18
|
+
interface SignedAuthorizationRequestInput {
|
|
19
|
+
hostname: string;
|
|
20
|
+
requestUri: string;
|
|
21
|
+
responseUri: string;
|
|
22
|
+
nonce: string;
|
|
23
|
+
state?: string;
|
|
24
|
+
responseMode?: 'direct_post' | 'direct_post.jwt';
|
|
25
|
+
signer: CryptoKeyPair;
|
|
26
|
+
signingAlgorithm?: 'ES256' | 'ES384' | 'RS256';
|
|
27
|
+
certificateChain: Uint8Array[];
|
|
28
|
+
encryptionKey?: {
|
|
29
|
+
publicJwk: JsonWebKey;
|
|
30
|
+
supportedEncValues?: string[];
|
|
31
|
+
};
|
|
32
|
+
vpFormatsSupported: Record<string, unknown>;
|
|
33
|
+
}
|
|
34
|
+
interface SignedAuthorizationRequest {
|
|
35
|
+
uri: string;
|
|
36
|
+
requestObject: string;
|
|
37
|
+
dcqlQuery: DcqlQuery;
|
|
38
|
+
nonce: string;
|
|
39
|
+
state: string;
|
|
40
|
+
}
|
|
41
|
+
interface AuthorizationResponse {
|
|
42
|
+
vp_token: Record<string, Array<string | object>>;
|
|
43
|
+
state?: string;
|
|
44
|
+
[key: string]: unknown;
|
|
45
|
+
}
|
|
18
46
|
|
|
19
47
|
declare function createAuthorizationRequest(input: AuthorizationRequestInput, query: DcqlQuery): AuthorizationRequest;
|
|
20
48
|
|
|
49
|
+
/**
|
|
50
|
+
* Build a signed authorization request (JAR) per OpenID4VP 1.0 §5.10 / RFC 9101.
|
|
51
|
+
*
|
|
52
|
+
* Validates that the signing key is bound to the leaf certificate and that the
|
|
53
|
+
* leaf cert's SAN DNSName equals the declared hostname. Emits a short URI
|
|
54
|
+
* carrying only `client_id` + `request_uri`, plus the JWS string the caller
|
|
55
|
+
* must host at `requestUri` with Content-Type `application/oauth-authz-req+jwt`.
|
|
56
|
+
*
|
|
57
|
+
* Client Identifier Prefix is always `x509_san_dns` — other prefixes deferred.
|
|
58
|
+
*/
|
|
59
|
+
declare function createSignedAuthorizationRequest(input: SignedAuthorizationRequestInput, query: DcqlQuery): Promise<SignedAuthorizationRequest>;
|
|
60
|
+
|
|
21
61
|
interface HaipQueryInput {
|
|
22
62
|
credentialId: string;
|
|
23
63
|
format: 'dc+sd-jwt' | 'mso_mdoc';
|
|
@@ -293,6 +333,12 @@ interface VerifyResult {
|
|
|
293
333
|
submission: DcqlSubmission | null;
|
|
294
334
|
valid: boolean;
|
|
295
335
|
}
|
|
336
|
+
interface EncryptedResponse {
|
|
337
|
+
response: string;
|
|
338
|
+
}
|
|
339
|
+
type VerifyAuthorizationResponseOptions = VerifyOptions & {
|
|
340
|
+
decryptionKey?: CryptoKey;
|
|
341
|
+
};
|
|
296
342
|
|
|
297
343
|
/**
|
|
298
344
|
* Parses a VP token, then matches it against a DCQL query.
|
|
@@ -306,6 +352,34 @@ interface VerifyResult {
|
|
|
306
352
|
* @param options parse + verify options (nonce, trusted issuers, etc.)
|
|
307
353
|
*/
|
|
308
354
|
declare function verifyPresentation(vpToken: unknown, query: DcqlQuery, options: VerifyOptions): Promise<VerifyResult>;
|
|
355
|
+
/**
|
|
356
|
+
* Verify an OpenID4VP 1.0 §8.1 Authorization Response envelope.
|
|
357
|
+
*
|
|
358
|
+
* Accepts either the unencrypted envelope (object-keyed `vp_token`) or a
|
|
359
|
+
* JWE-wrapped envelope `{ response: '<JWE>' }` for response_mode =
|
|
360
|
+
* direct_post.jwt. When encrypted, decrypts with `options.decryptionKey`
|
|
361
|
+
* first. For this release only single-credential single-presentation is
|
|
362
|
+
* supported — multi-credential envelopes throw
|
|
363
|
+
* {@link MultipleCredentialsNotSupportedError}. Otherwise delegates the
|
|
364
|
+
* extracted single presentation to the existing {@link verifyPresentation}.
|
|
365
|
+
*
|
|
366
|
+
* Callers MUST compare the envelope's `state` against the value they issued
|
|
367
|
+
* themselves — library is stateless and does not track state.
|
|
368
|
+
*/
|
|
369
|
+
declare function verifyAuthorizationResponse(envelope: AuthorizationResponse | EncryptedResponse, query: DcqlQuery, options: VerifyAuthorizationResponseOptions): Promise<VerifyResult>;
|
|
370
|
+
|
|
371
|
+
/**
|
|
372
|
+
* Decrypt a JWE-wrapped OpenID4VP Authorization Response (response_mode =
|
|
373
|
+
* direct_post.jwt). Returns the inner §8.1 envelope.
|
|
374
|
+
*
|
|
375
|
+
* Supported JWE algorithms (others throw UnsupportedJweError):
|
|
376
|
+
* - alg: ECDH-ES
|
|
377
|
+
* - enc: A128GCM, A256GCM (HAIP requires both)
|
|
378
|
+
*
|
|
379
|
+
* Cryptographic failures (wrong key, tampered ciphertext) throw
|
|
380
|
+
* DecryptionFailedError.
|
|
381
|
+
*/
|
|
382
|
+
declare function decryptAuthorizationResponse(jwe: string, privateKey: CryptoKey): Promise<AuthorizationResponse>;
|
|
309
383
|
|
|
310
384
|
/**
|
|
311
385
|
* SD-JWT VC credential parser.
|
|
@@ -416,6 +490,33 @@ declare class LotlFetchError extends OpenID4VPError {
|
|
|
416
490
|
declare class LotlSignatureError extends OpenID4VPError {
|
|
417
491
|
readonly code: "lotl_signature_invalid";
|
|
418
492
|
}
|
|
493
|
+
type SignedRequestBuildErrorCode = 'empty_cert_chain' | 'hostname_cert_mismatch' | 'signing_key_cert_mismatch' | 'missing_encryption_jwk' | 'missing_encryption_alg' | 'missing_vp_formats' | 'unsupported_signing_alg' | 'empty_supported_enc_values';
|
|
494
|
+
declare class SignedRequestBuildError extends OpenID4VPError {
|
|
495
|
+
readonly code: SignedRequestBuildErrorCode;
|
|
496
|
+
constructor(code: SignedRequestBuildErrorCode, message: string);
|
|
497
|
+
}
|
|
498
|
+
declare class UnsupportedJweError extends OpenID4VPError {
|
|
499
|
+
readonly code: "unsupported_jwe";
|
|
500
|
+
readonly alg: string;
|
|
501
|
+
readonly enc: string;
|
|
502
|
+
constructor(alg: string, enc: string);
|
|
503
|
+
}
|
|
504
|
+
declare class DecryptionFailedError extends OpenID4VPError {
|
|
505
|
+
readonly code: "decryption_failed";
|
|
506
|
+
constructor(message?: string, options?: {
|
|
507
|
+
cause?: Error;
|
|
508
|
+
});
|
|
509
|
+
}
|
|
510
|
+
declare class MissingDecryptionKeyError extends OpenID4VPError {
|
|
511
|
+
readonly code: "missing_decryption_key";
|
|
512
|
+
constructor(message?: string);
|
|
513
|
+
}
|
|
514
|
+
declare class MultipleCredentialsNotSupportedError extends OpenID4VPError {
|
|
515
|
+
readonly code: "multi_credential_unsupported";
|
|
516
|
+
readonly entryCount: number;
|
|
517
|
+
readonly presentationCount: number;
|
|
518
|
+
constructor(entryCount: number, presentationCount: number);
|
|
519
|
+
}
|
|
419
520
|
|
|
420
521
|
interface LotlTrustStoreOptions {
|
|
421
522
|
/** Override the bundled signing anchors. Empty is rejected. */
|
|
@@ -454,6 +555,6 @@ declare class LotlTrustStore implements TrustStore {
|
|
|
454
555
|
private refresh;
|
|
455
556
|
}
|
|
456
557
|
|
|
457
|
-
declare const VERSION = "0.
|
|
558
|
+
declare const VERSION = "0.7.0";
|
|
458
559
|
|
|
459
|
-
export { type AuthorizationRequest, type AuthorizationRequestInput, type Cache, CertificateChainError, type ChainErrorReason, CompositeTrustStore, type CredentialClaims, type CredentialFormat, ExpiredCredentialError, type Fetcher, HAIP_DOCTYPE_NAMESPACES, type HaipQueryInput, type HaipValidationCode, HaipValidationError, type ICredentialParser, InMemoryCache, InvalidSignatureError, type IssuerInfo, type LotlAnchorMetadata, LotlFetchError, LotlSignatureError, LotlTrustStore, type LotlTrustStoreOptions, MalformedCredentialError, MdocParser, NonceValidationError, OpenID4VPError, type ParseOptions, type PresentationResult, RevocationCheckFailedError, RevokedCertificateError, SdJwtParser, StaticTrustStore, type TrustAnchor, TrustAnchorNotFoundError, type TrustStore, type TrustStoreHint, type TrustStoreInput, UnsupportedFormatError, VERSION, type VerifyOptions, type VerifyResult, buildHaipQuery, createAuthorizationRequest, isHaipQuery, parsePresentation, validateHaipQuery, verifyPresentation };
|
|
560
|
+
export { type AuthorizationRequest, type AuthorizationRequestInput, type AuthorizationResponse, type Cache, CertificateChainError, type ChainErrorReason, CompositeTrustStore, type CredentialClaims, type CredentialFormat, DecryptionFailedError, type EncryptedResponse, ExpiredCredentialError, type Fetcher, HAIP_DOCTYPE_NAMESPACES, type HaipQueryInput, type HaipValidationCode, HaipValidationError, type ICredentialParser, InMemoryCache, InvalidSignatureError, type IssuerInfo, type LotlAnchorMetadata, LotlFetchError, LotlSignatureError, LotlTrustStore, type LotlTrustStoreOptions, MalformedCredentialError, MdocParser, MissingDecryptionKeyError, 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, buildHaipQuery, createAuthorizationRequest, createSignedAuthorizationRequest, decryptAuthorizationResponse, isHaipQuery, parsePresentation, validateHaipQuery, verifyAuthorizationResponse, verifyPresentation };
|