@openeudi/openid4vp 0.3.0 → 0.4.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/dist/index.d.ts CHANGED
@@ -1,3 +1,36 @@
1
+ import { DcqlQuery, TrustedAuthoritiesQuery, DcqlMatchResult, DcqlSubmission } from '@openeudi/dcql';
2
+ export { DcqlMatchError, DcqlMatchResult, DcqlQuery, DcqlSubmission, DcqlValidationError, DcqlValidationErrorCode } from '@openeudi/dcql';
3
+
4
+ interface AuthorizationRequestInput {
5
+ clientId: string;
6
+ responseUri: string;
7
+ nonce: string;
8
+ state?: string;
9
+ responseMode?: 'direct_post' | 'direct_post.jwt';
10
+ }
11
+ interface AuthorizationRequest {
12
+ uri: string;
13
+ dcqlQuery: DcqlQuery;
14
+ nonce: string;
15
+ state: string;
16
+ }
17
+
18
+ declare function createAuthorizationRequest(input: AuthorizationRequestInput, query: DcqlQuery): AuthorizationRequest;
19
+
20
+ interface HaipQueryInput {
21
+ credentialId: string;
22
+ format: 'dc+sd-jwt' | 'mso_mdoc';
23
+ vctValues?: string[];
24
+ doctypeValue?: string;
25
+ claims: string[];
26
+ trustedAuthorities?: TrustedAuthoritiesQuery[];
27
+ }
28
+
29
+ declare const HAIP_DOCTYPE_NAMESPACES: Record<string, string>;
30
+ declare function buildHaipQuery(input: HaipQueryInput): DcqlQuery;
31
+ declare function validateHaipQuery(query: DcqlQuery): void;
32
+ declare function isHaipQuery(query: DcqlQuery): boolean;
33
+
1
34
  interface IssuerInfo {
2
35
  certificate: Uint8Array;
3
36
  country: string;
@@ -20,21 +53,15 @@ interface PresentationResult {
20
53
  claims: CredentialClaims;
21
54
  issuer: IssuerInfo;
22
55
  error?: string;
23
- }
24
-
25
- interface AuthorizationRequestInput {
26
- requestedAttributes: string[];
27
- acceptedFormats: CredentialFormat[];
28
- responseUri: string;
29
- nonce: string;
30
- clientId: string;
31
- state?: string;
32
- }
33
- interface AuthorizationRequest {
34
- uri: string;
35
- presentationDefinition: object;
36
- nonce: string;
37
- state: string;
56
+ /** SD-JWT type (Verifiable Credential Type URI). Populated for `sd-jwt-vc` format. */
57
+ vct?: string;
58
+ /** mDOC docType (ISO 18013-5). Populated for `mdoc` format. */
59
+ docType?: string;
60
+ /**
61
+ * mDOC claims grouped by namespace. Populated for `mdoc` format.
62
+ * DCQL claim paths address this shape: `['org.iso.18013.5.1', 'age_over_18']`.
63
+ */
64
+ namespacedClaims?: Record<string, Record<string, unknown>>;
38
65
  }
39
66
 
40
67
  interface ParseOptions {
@@ -65,6 +92,29 @@ interface ICredentialParser {
65
92
  parse(vpToken: unknown, options: ParseOptions): Promise<PresentationResult>;
66
93
  }
67
94
 
95
+ declare function parsePresentation(vpToken: unknown, options: ParseOptions): Promise<PresentationResult>;
96
+
97
+ type VerifyOptions = ParseOptions;
98
+ interface VerifyResult {
99
+ parsed: PresentationResult;
100
+ match: DcqlMatchResult;
101
+ submission: DcqlSubmission | null;
102
+ valid: boolean;
103
+ }
104
+
105
+ /**
106
+ * Parses a VP token, then matches it against a DCQL query.
107
+ *
108
+ * Cryptographic / structural parser failures still throw (via `parsePresentation`).
109
+ * Query-level mismatches are surfaced as `match.unmatched` entries so callers can
110
+ * show per-claim diagnostics.
111
+ *
112
+ * @param vpToken raw VP token (SD-JWT string or mDOC Uint8Array)
113
+ * @param query DCQL query describing the required credential(s)
114
+ * @param options parse + verify options (nonce, trusted issuers, etc.)
115
+ */
116
+ declare function verifyPresentation(vpToken: unknown, query: DcqlQuery, options: VerifyOptions): Promise<VerifyResult>;
117
+
68
118
  /**
69
119
  * SD-JWT VC credential parser.
70
120
  *
@@ -124,11 +174,13 @@ declare class MalformedCredentialError extends Error {
124
174
  declare class NonceValidationError extends Error {
125
175
  constructor(message?: string);
126
176
  }
177
+ type HaipValidationCode = 'EMPTY_QUERY' | 'UNSUPPORTED_FORMAT' | 'MISSING_SDJWT_META' | 'MISSING_MDOC_META' | 'NO_CLAIMS' | 'CLAIM_SETS_DISALLOWED' | 'CREDENTIAL_SETS_DISALLOWED';
178
+ declare class HaipValidationError extends Error {
179
+ readonly code: HaipValidationCode;
180
+ readonly credentialId?: string;
181
+ constructor(code: HaipValidationCode, message: string, credentialId?: string);
182
+ }
127
183
 
128
- declare function createAuthorizationRequest(input: AuthorizationRequestInput): AuthorizationRequest;
129
-
130
- declare function parsePresentation(vpToken: unknown, options: ParseOptions): Promise<PresentationResult>;
131
-
132
- declare const VERSION = "0.3.0";
184
+ declare const VERSION = "0.4.0";
133
185
 
134
- export { type AuthorizationRequest, type AuthorizationRequestInput, type CredentialClaims, type CredentialFormat, ExpiredCredentialError, type ICredentialParser, InvalidSignatureError, type IssuerInfo, MalformedCredentialError, MdocParser, NonceValidationError, type ParseOptions, type PresentationResult, SdJwtParser, UnsupportedFormatError, VERSION, createAuthorizationRequest, parsePresentation };
186
+ export { type AuthorizationRequest, type AuthorizationRequestInput, type CredentialClaims, type CredentialFormat, ExpiredCredentialError, HAIP_DOCTYPE_NAMESPACES, type HaipQueryInput, type HaipValidationCode, HaipValidationError, type ICredentialParser, InvalidSignatureError, type IssuerInfo, MalformedCredentialError, MdocParser, NonceValidationError, type ParseOptions, type PresentationResult, SdJwtParser, UnsupportedFormatError, VERSION, type VerifyOptions, type VerifyResult, buildHaipQuery, createAuthorizationRequest, isHaipQuery, parsePresentation, validateHaipQuery, verifyPresentation };