@learncard/openid4vc-plugin 0.0.1
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/LICENSE +21 -0
- package/README.md +592 -0
- package/dist/dcql/adapt.d.ts +80 -0
- package/dist/dcql/adapt.d.ts.map +1 -0
- package/dist/dcql/build.d.ts +122 -0
- package/dist/dcql/build.d.ts.map +1 -0
- package/dist/dcql/compose.d.ts +78 -0
- package/dist/dcql/compose.d.ts.map +1 -0
- package/dist/dcql/index.d.ts +18 -0
- package/dist/dcql/index.d.ts.map +1 -0
- package/dist/dcql/parse.d.ts +16 -0
- package/dist/dcql/parse.d.ts.map +1 -0
- package/dist/dcql/respond.d.ts +115 -0
- package/dist/dcql/respond.d.ts.map +1 -0
- package/dist/dcql/select.d.ts +63 -0
- package/dist/dcql/select.d.ts.map +1 -0
- package/dist/dcql/types.d.ts +93 -0
- package/dist/dcql/types.d.ts.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/offer/index.d.ts +4 -0
- package/dist/offer/index.d.ts.map +1 -0
- package/dist/offer/normalize.d.ts +15 -0
- package/dist/offer/normalize.d.ts.map +1 -0
- package/dist/offer/parse.d.ts +24 -0
- package/dist/offer/parse.d.ts.map +1 -0
- package/dist/offer/types.d.ts +92 -0
- package/dist/offer/types.d.ts.map +1 -0
- package/dist/openid4vc-plugin.cjs.development.js +27402 -0
- package/dist/openid4vc-plugin.cjs.development.js.map +7 -0
- package/dist/openid4vc-plugin.cjs.production.min.js +146 -0
- package/dist/openid4vc-plugin.cjs.production.min.js.map +7 -0
- package/dist/openid4vc-plugin.esm.js +27396 -0
- package/dist/openid4vc-plugin.esm.js.map +7 -0
- package/dist/plugin.d.ts +12 -0
- package/dist/plugin.d.ts.map +1 -0
- package/dist/siop/index.d.ts +11 -0
- package/dist/siop/index.d.ts.map +1 -0
- package/dist/siop/sign.d.ts +92 -0
- package/dist/siop/sign.d.ts.map +1 -0
- package/dist/types.d.ts +359 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/vci/accept.d.ts +24 -0
- package/dist/vci/accept.d.ts.map +1 -0
- package/dist/vci/auth-code.d.ts +148 -0
- package/dist/vci/auth-code.d.ts.map +1 -0
- package/dist/vci/decode.d.ts +65 -0
- package/dist/vci/decode.d.ts.map +1 -0
- package/dist/vci/errors.d.ts +22 -0
- package/dist/vci/errors.d.ts.map +1 -0
- package/dist/vci/index.d.ts +12 -0
- package/dist/vci/index.d.ts.map +1 -0
- package/dist/vci/metadata.d.ts +25 -0
- package/dist/vci/metadata.d.ts.map +1 -0
- package/dist/vci/pkce.d.ts +85 -0
- package/dist/vci/pkce.d.ts.map +1 -0
- package/dist/vci/proof.d.ts +43 -0
- package/dist/vci/proof.d.ts.map +1 -0
- package/dist/vci/request.d.ts +48 -0
- package/dist/vci/request.d.ts.map +1 -0
- package/dist/vci/store.d.ts +89 -0
- package/dist/vci/store.d.ts.map +1 -0
- package/dist/vci/token.d.ts +16 -0
- package/dist/vci/token.d.ts.map +1 -0
- package/dist/vci/types.d.ts +156 -0
- package/dist/vci/types.d.ts.map +1 -0
- package/dist/vp/client-id-prefix.d.ts +115 -0
- package/dist/vp/client-id-prefix.d.ts.map +1 -0
- package/dist/vp/encrypt.d.ts +221 -0
- package/dist/vp/encrypt.d.ts.map +1 -0
- package/dist/vp/index.d.ts +27 -0
- package/dist/vp/index.d.ts.map +1 -0
- package/dist/vp/parse.d.ts +60 -0
- package/dist/vp/parse.d.ts.map +1 -0
- package/dist/vp/pex.d.ts +83 -0
- package/dist/vp/pex.d.ts.map +1 -0
- package/dist/vp/present.d.ts +126 -0
- package/dist/vp/present.d.ts.map +1 -0
- package/dist/vp/request-object.d.ts +99 -0
- package/dist/vp/request-object.d.ts.map +1 -0
- package/dist/vp/select.d.ts +137 -0
- package/dist/vp/select.d.ts.map +1 -0
- package/dist/vp/sign.d.ts +125 -0
- package/dist/vp/sign.d.ts.map +1 -0
- package/dist/vp/submit.d.ts +175 -0
- package/dist/vp/submit.d.ts.map +1 -0
- package/dist/vp/types.d.ts +255 -0
- package/dist/vp/types.d.ts.map +1 -0
- package/package.json +52 -0
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Domain types for the OID4VCI pre-authorized_code flow.
|
|
3
|
+
*
|
|
4
|
+
* Kept intentionally narrow — we only type the fields the wallet actually
|
|
5
|
+
* consumes. Issuer metadata carries many optional display/branding fields
|
|
6
|
+
* that we pass through as `unknown` rather than over-specifying.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Minimal Credential Issuer Metadata shape.
|
|
10
|
+
*
|
|
11
|
+
* Per Draft 13 §11.2, issuers publish this at
|
|
12
|
+
* `${credential_issuer}/.well-known/openid-credential-issuer`.
|
|
13
|
+
*/
|
|
14
|
+
export interface CredentialIssuerMetadata {
|
|
15
|
+
/** MUST match the `credential_issuer` from the offer. */
|
|
16
|
+
credential_issuer: string;
|
|
17
|
+
/** Endpoint to POST credential requests to. Required. */
|
|
18
|
+
credential_endpoint: string;
|
|
19
|
+
/** Optional endpoint for notification of credential acceptance. */
|
|
20
|
+
notification_endpoint?: string;
|
|
21
|
+
/**
|
|
22
|
+
* Authorization servers delegated for token issuance. If omitted, the
|
|
23
|
+
* issuer itself is the AS and exposes token/auth endpoints directly.
|
|
24
|
+
*/
|
|
25
|
+
authorization_servers?: string[];
|
|
26
|
+
/**
|
|
27
|
+
* Deferred endpoint — not used in Slice 2; credentials returned
|
|
28
|
+
* synchronously from the credential endpoint.
|
|
29
|
+
*/
|
|
30
|
+
deferred_credential_endpoint?: string;
|
|
31
|
+
/**
|
|
32
|
+
* Credential configurations keyed by configuration id. Values are left
|
|
33
|
+
* as `unknown` for now; Slice 5 will narrow the `ldp_vc` + `jwt_vc_json`
|
|
34
|
+
* shapes when we start honoring `types` and `credential_definition`.
|
|
35
|
+
*/
|
|
36
|
+
credential_configurations_supported?: Record<string, unknown>;
|
|
37
|
+
/** Pass-through catch-all for fields we don't consume. */
|
|
38
|
+
[k: string]: unknown;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Minimal Authorization Server Metadata (RFC 8414 + OID4VCI extensions).
|
|
42
|
+
*
|
|
43
|
+
* Fetched from `${auth_server}/.well-known/oauth-authorization-server`
|
|
44
|
+
* (preferred) or `/.well-known/openid-configuration` (fallback).
|
|
45
|
+
*/
|
|
46
|
+
export interface AuthorizationServerMetadata {
|
|
47
|
+
issuer: string;
|
|
48
|
+
/** Required for pre-authorized_code flow. */
|
|
49
|
+
token_endpoint: string;
|
|
50
|
+
authorization_endpoint?: string;
|
|
51
|
+
/**
|
|
52
|
+
* OID4VCI extension — if present and `true`, the AS supports
|
|
53
|
+
* `pre-authorized_code` as a grant type.
|
|
54
|
+
*/
|
|
55
|
+
'pre-authorized_grant_anonymous_access_supported'?: boolean;
|
|
56
|
+
grant_types_supported?: string[];
|
|
57
|
+
[k: string]: unknown;
|
|
58
|
+
}
|
|
59
|
+
/** Successful response from the token endpoint. */
|
|
60
|
+
export interface TokenResponse {
|
|
61
|
+
access_token: string;
|
|
62
|
+
token_type: 'Bearer' | 'DPoP' | string;
|
|
63
|
+
expires_in?: number;
|
|
64
|
+
/** Nonce the wallet must echo in its proof-of-possession JWT. */
|
|
65
|
+
c_nonce?: string;
|
|
66
|
+
c_nonce_expires_in?: number;
|
|
67
|
+
/**
|
|
68
|
+
* If the token endpoint returned authorization details, the wallet
|
|
69
|
+
* should use them to shape the credential request. We pass them
|
|
70
|
+
* through but do not enforce them in Slice 2.
|
|
71
|
+
*/
|
|
72
|
+
authorization_details?: unknown;
|
|
73
|
+
[k: string]: unknown;
|
|
74
|
+
}
|
|
75
|
+
/** RFC 6749 §5.2 error body. */
|
|
76
|
+
export interface OAuthErrorBody {
|
|
77
|
+
error: string;
|
|
78
|
+
error_description?: string;
|
|
79
|
+
error_uri?: string;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Body of a successful credential request response. Either
|
|
83
|
+
* - `credential` present (synchronous issuance), or
|
|
84
|
+
* - `transaction_id` present (deferred issuance — not yet supported).
|
|
85
|
+
*
|
|
86
|
+
* Slice 2 only handles synchronous jwt_vc_json; other branches surface
|
|
87
|
+
* `unsupported_format` for the caller to handle.
|
|
88
|
+
*/
|
|
89
|
+
export interface CredentialResponseBody {
|
|
90
|
+
credential?: unknown;
|
|
91
|
+
credentials?: Array<{
|
|
92
|
+
credential: unknown;
|
|
93
|
+
[k: string]: unknown;
|
|
94
|
+
}>;
|
|
95
|
+
transaction_id?: string;
|
|
96
|
+
c_nonce?: string;
|
|
97
|
+
c_nonce_expires_in?: number;
|
|
98
|
+
notification_id?: string;
|
|
99
|
+
[k: string]: unknown;
|
|
100
|
+
}
|
|
101
|
+
/** Result of {@link acceptCredentialOffer} — what the caller actually cares about. */
|
|
102
|
+
export interface AcceptedCredentialResult {
|
|
103
|
+
/** One entry per credential returned by the issuer. */
|
|
104
|
+
credentials: Array<{
|
|
105
|
+
/** `jwt_vc_json`, `ldp_vc`, etc. */
|
|
106
|
+
format: string;
|
|
107
|
+
/** The raw credential payload — a JWT string for jwt_vc_json, a JSON object for ldp_vc. */
|
|
108
|
+
credential: unknown;
|
|
109
|
+
/** The configuration id from the offer that produced this credential. */
|
|
110
|
+
configuration_id: string;
|
|
111
|
+
}>;
|
|
112
|
+
/** Issuer-supplied id the wallet should echo in a notification POST. */
|
|
113
|
+
notification_id?: string;
|
|
114
|
+
/** Fresh nonce from the credential response, if rotated. */
|
|
115
|
+
c_nonce?: string;
|
|
116
|
+
c_nonce_expires_in?: number;
|
|
117
|
+
}
|
|
118
|
+
/** A signer capable of producing JWS detached / compact signatures. */
|
|
119
|
+
export interface ProofJwtSigner {
|
|
120
|
+
/** JWS `alg` — e.g. `EdDSA`, `ES256`. */
|
|
121
|
+
alg: string;
|
|
122
|
+
/** Verification-method URL for the `kid` header (e.g. `did:key:z6M...#z6M...`). */
|
|
123
|
+
kid: string;
|
|
124
|
+
/**
|
|
125
|
+
* Produce a compact JWS over the given header + payload.
|
|
126
|
+
*
|
|
127
|
+
* Implementations MUST merge `alg` and `kid` / other header members
|
|
128
|
+
* the caller supplies (e.g. `typ: openid4vci-proof+jwt`).
|
|
129
|
+
*/
|
|
130
|
+
sign: (header: Record<string, unknown>, payload: Record<string, unknown>) => Promise<string>;
|
|
131
|
+
}
|
|
132
|
+
/** Options for accepting a credential offer via the pre-authorized code grant. */
|
|
133
|
+
export interface AcceptCredentialOfferOptions {
|
|
134
|
+
/**
|
|
135
|
+
* Transaction code the user entered, if the offer required one
|
|
136
|
+
* (offer's `tx_code` field is present).
|
|
137
|
+
*/
|
|
138
|
+
txCode?: string;
|
|
139
|
+
/**
|
|
140
|
+
* Optional override of the signer. Defaults to a signer backed by the
|
|
141
|
+
* LearnCard's Ed25519 keypair.
|
|
142
|
+
*/
|
|
143
|
+
signer?: ProofJwtSigner;
|
|
144
|
+
/**
|
|
145
|
+
* Client identifier presented to the authorization server. Most
|
|
146
|
+
* pre-authorized flows accept anonymous clients, but some AS's
|
|
147
|
+
* require one.
|
|
148
|
+
*/
|
|
149
|
+
clientId?: string;
|
|
150
|
+
/**
|
|
151
|
+
* Subset of `credential_configuration_ids` from the offer to actually
|
|
152
|
+
* request. Defaults to all of them.
|
|
153
|
+
*/
|
|
154
|
+
configurationIds?: string[];
|
|
155
|
+
}
|
|
156
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/vci/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;;GAKG;AACH,MAAM,WAAW,wBAAwB;IACrC,yDAAyD;IACzD,iBAAiB,EAAE,MAAM,CAAC;IAC1B,yDAAyD;IACzD,mBAAmB,EAAE,MAAM,CAAC;IAC5B,mEAAmE;IACnE,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B;;;OAGG;IACH,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**
|
|
2
|
+
* **OID4VP 1.0 §5.10 — Client Identifier Prefix derivation.**
|
|
3
|
+
*
|
|
4
|
+
* The prefix tells the wallet *how to verify* a verifier's identity:
|
|
5
|
+
*
|
|
6
|
+
* - `pre-registered` — the verifier is in the wallet's local registry;
|
|
7
|
+
* `client_id` is whatever ID the registration agreed on (an opaque
|
|
8
|
+
* string, often a slug).
|
|
9
|
+
* - `redirect_uri` — the verifier's identity IS its redirect URL;
|
|
10
|
+
* no signed Request Object permitted (no key to verify against).
|
|
11
|
+
* - `https` — `client_id` is the verifier's HTTPS URL; verifier
|
|
12
|
+
* metadata (and its signing key) is fetched from
|
|
13
|
+
* `<client_id>/.well-known/openid-federation`.
|
|
14
|
+
* - `did` — `client_id` is a DID URL; signing key resolves through
|
|
15
|
+
* the DID document.
|
|
16
|
+
* - `verifier_attestation` — the verifier carries a self-attesting
|
|
17
|
+
* JWT in the JWS header (cnf claim).
|
|
18
|
+
* - `x509_san_dns` — the JWS `x5c` chain's leaf cert binds to the
|
|
19
|
+
* hostname half of `client_id` via DNS SAN.
|
|
20
|
+
* - `x509_hash` — same as above but the binding is a hash match
|
|
21
|
+
* against `client_id` rather than a DNS name.
|
|
22
|
+
*
|
|
23
|
+
* # Two encoding styles to handle
|
|
24
|
+
*
|
|
25
|
+
* Wallets see both forms in the wild:
|
|
26
|
+
*
|
|
27
|
+
* - **Draft 22 / earlier** ships `client_id_scheme` as a *separate*
|
|
28
|
+
* parameter (URL or signed claim) and `client_id` is the bare
|
|
29
|
+
* identifier:
|
|
30
|
+
*
|
|
31
|
+
* client_id=did:jwk:eyJhbGc...
|
|
32
|
+
* client_id_scheme=did
|
|
33
|
+
*
|
|
34
|
+
* - **OID4VP 1.0** packs the prefix *inline* in `client_id` as
|
|
35
|
+
* `<prefix>:<value>`:
|
|
36
|
+
*
|
|
37
|
+
* client_id=x509_san_dns:verifier.example.com
|
|
38
|
+
* client_id=did:jwk:eyJhbGc... (prefix `did` is
|
|
39
|
+
* implicit; the DID
|
|
40
|
+
* URI scheme IS the
|
|
41
|
+
* prefix)
|
|
42
|
+
* client_id=Verifier (no prefix → defaults
|
|
43
|
+
* to pre-registered)
|
|
44
|
+
*
|
|
45
|
+
* `deriveClientIdPrefix` accepts both styles and returns a normalized
|
|
46
|
+
* `{ prefix, value }` so downstream verification code doesn't care
|
|
47
|
+
* which encoding the verifier picked.
|
|
48
|
+
*
|
|
49
|
+
* # Why this lives in its own module
|
|
50
|
+
*
|
|
51
|
+
* This logic is **the security perimeter** for verifier identity:
|
|
52
|
+
* every signed Request Object's trust binding chains off the prefix
|
|
53
|
+
* we derive here. Keeping it in one tested module (rather than
|
|
54
|
+
* inlining the string-munging in `request-object.ts`) means:
|
|
55
|
+
*
|
|
56
|
+
* 1. The test surface is one cohesive matrix instead of being
|
|
57
|
+
* smeared across the JAR verifier's tests.
|
|
58
|
+
* 2. URI-mode (`by_value`) and Request-Object-mode (`by_reference`)
|
|
59
|
+
* share exactly the same derivation, so we can't drift between
|
|
60
|
+
* them.
|
|
61
|
+
* 3. Adding a new prefix in the future (e.g. `web_origin` from a
|
|
62
|
+
* future spec rev) is a one-line addition here, not a sweep.
|
|
63
|
+
*/
|
|
64
|
+
/**
|
|
65
|
+
* The OID4VP 1.0 client-identifier prefixes the plugin recognizes.
|
|
66
|
+
* `did` includes the legacy `decentralized_identifier` synonym some
|
|
67
|
+
* implementations emit; both normalize to `did`.
|
|
68
|
+
*/
|
|
69
|
+
export type ClientIdPrefix = 'pre-registered' | 'redirect_uri' | 'https' | 'did' | 'verifier_attestation' | 'x509_san_dns' | 'x509_hash';
|
|
70
|
+
export declare const KNOWN_CLIENT_ID_PREFIXES: readonly ClientIdPrefix[];
|
|
71
|
+
export interface DerivedClientId {
|
|
72
|
+
/** Normalized prefix that downstream verification keys off. */
|
|
73
|
+
prefix: ClientIdPrefix;
|
|
74
|
+
/**
|
|
75
|
+
* The post-prefix portion of `client_id` — the actual verifier
|
|
76
|
+
* identifier (DNS name, DID, URL, registered slug, …). Equal to
|
|
77
|
+
* `clientId` when no prefix was inline (e.g. `pre-registered`).
|
|
78
|
+
*/
|
|
79
|
+
value: string;
|
|
80
|
+
/**
|
|
81
|
+
* `true` when the prefix was inferred (legacy draft-22 form, OR
|
|
82
|
+
* a DID URI encoding the `did` prefix implicitly, OR the
|
|
83
|
+
* `pre-registered` default for a bare client_id). Useful for
|
|
84
|
+
* logging / interop diagnostics; verification logic shouldn't
|
|
85
|
+
* branch on it.
|
|
86
|
+
*/
|
|
87
|
+
inferred: boolean;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Derive the client-id prefix from a verifier's `client_id` plus an
|
|
91
|
+
* optional legacy `client_id_scheme` parameter.
|
|
92
|
+
*
|
|
93
|
+
* Resolution order:
|
|
94
|
+
*
|
|
95
|
+
* 1. **Legacy `client_id_scheme` wins** when supplied (draft-22
|
|
96
|
+
* semantics). The full `client_id` is the value. Validates that
|
|
97
|
+
* the supplied scheme is one we recognize.
|
|
98
|
+
* 2. **Explicit prefix in `client_id`**: if `client_id` starts with
|
|
99
|
+
* `<prefix>:` for any prefix that requires explicit encoding
|
|
100
|
+
* (everything except `pre-registered`, `did`, and `https`,
|
|
101
|
+
* which have implicit forms), strip and use it.
|
|
102
|
+
* 3. **`https://` URL** → prefix `https`, value = full URL.
|
|
103
|
+
* 4. **`did:` URI** → prefix `did`, value = full DID (the DID's
|
|
104
|
+
* own colon-delimited form encodes the prefix implicitly).
|
|
105
|
+
* 5. **Fallback** → `pre-registered`, value = `client_id` verbatim.
|
|
106
|
+
*
|
|
107
|
+
* Throws nothing — returns a value for every input. Spec violations
|
|
108
|
+
* (e.g. caller-supplied `client_id_scheme=garbage`) bubble up as
|
|
109
|
+
* `prefix: pre-registered` with a `legacySchemeIgnored` diagnostic
|
|
110
|
+
* the caller can surface; this keeps the function pure and lets the
|
|
111
|
+
* security-critical "is this prefix one I know how to verify"
|
|
112
|
+
* decision happen at the JAR verifier where the trust context lives.
|
|
113
|
+
*/
|
|
114
|
+
export declare const deriveClientIdPrefix: (clientId: string, legacyScheme?: string) => DerivedClientId;
|
|
115
|
+
//# sourceMappingURL=client-id-prefix.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client-id-prefix.d.ts","sourceRoot":"","sources":["../../src/vp/client-id-prefix.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8DG;AAEH;;;;GAIG;AACH,MAAM,MAAM,cAAc,GACpB,gBAAgB,GAChB,cAAc,GACd,OAAO,GACP,KAAK,GACL,sBAAsB,GACtB,cAAc,GACd,WAAW,CAAC;AAElB,eAAO,MAAM,wBAAwB,EAAE,SAAS,cAAc,EAQ7D,CAAC;AAEF,MAAM,WAAW,eAAe;IAC5B,+DAA+D;IAC/D,MAAM,EAAE,cAAc,CAAC;IAEvB;;;;OAIG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;;;;;OAMG;IACH,QAAQ,EAAE,OAAO,CAAC;CACrB;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,oBAAoB,aACnB,MAAM,iBACD,MAAM,KACtB,eAgFF,CAAC"}
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Slice 7d — **`direct_post.jwt` response encryption (JARM)**.
|
|
3
|
+
*
|
|
4
|
+
* OID4VP §8.3 lets the verifier ask the wallet to send the
|
|
5
|
+
* Authorization Response as a single signed-and/or-encrypted JOSE
|
|
6
|
+
* blob (JARM) instead of as cleartext form fields. The wire shape:
|
|
7
|
+
*
|
|
8
|
+
* POST {response_uri}
|
|
9
|
+
* Content-Type: application/x-www-form-urlencoded
|
|
10
|
+
*
|
|
11
|
+
* response={JOSE blob}
|
|
12
|
+
*
|
|
13
|
+
* where `{JOSE blob}` is one of:
|
|
14
|
+
*
|
|
15
|
+
* - **JWE only** — the response object packed as a compact JWE.
|
|
16
|
+
* - **JWS only** — the response object signed as a compact JWS.
|
|
17
|
+
* Rare in practice; OID4VP §8.3 mandates encryption when the
|
|
18
|
+
* verifier publishes encryption keys.
|
|
19
|
+
* - **Nested JWS-in-JWE** — the response object is signed by the
|
|
20
|
+
* wallet (outer authorship binding), then the JWS is encrypted
|
|
21
|
+
* to the verifier's enc key (transport confidentiality). This
|
|
22
|
+
* is the EUDI-flavored production shape.
|
|
23
|
+
*
|
|
24
|
+
* The plaintext payload (whether the JWE plaintext or the JWS
|
|
25
|
+
* payload) is a JSON object carrying the same fields that
|
|
26
|
+
* `direct_post` cleartext would send as form parameters:
|
|
27
|
+
*
|
|
28
|
+
* {
|
|
29
|
+
* "vp_token": "<jws>" | { "<query_id>": "..." },
|
|
30
|
+
* "presentation_submission": { ... }, // PEX only
|
|
31
|
+
* "state": "...", // when Auth Request had it
|
|
32
|
+
* "id_token": "..." // SIOPv2 only
|
|
33
|
+
* }
|
|
34
|
+
*
|
|
35
|
+
* # What this module does
|
|
36
|
+
*
|
|
37
|
+
* `encryptResponseObject` takes the plaintext payload + the
|
|
38
|
+
* verifier's `client_metadata` and returns the compact JOSE string
|
|
39
|
+
* suitable to put in the `response` form field.
|
|
40
|
+
*
|
|
41
|
+
* - Picks an encryption key from `client_metadata.jwks` (or fetches
|
|
42
|
+
* `client_metadata.jwks_uri` when only the URL is supplied) per
|
|
43
|
+
* OID4VP §8.3 paragraphs 2-4: a key with `use: "enc"` (or no
|
|
44
|
+
* `use` claim) whose `alg` (or none) matches the verifier's
|
|
45
|
+
* `authorization_encrypted_response_alg`.
|
|
46
|
+
* - Negotiates the JWE algorithms from
|
|
47
|
+
* `authorization_encrypted_response_alg` (key wrap) and
|
|
48
|
+
* `authorization_encrypted_response_enc` (content encryption).
|
|
49
|
+
* Falls back to the spec-recommended `ECDH-ES` + `A256GCM` if the
|
|
50
|
+
* verifier didn't declare specific algorithms.
|
|
51
|
+
* - Sets the `apv` JWE protected header to the base64url-encoding
|
|
52
|
+
* of the verifier's `nonce` from the Authorization Request, per
|
|
53
|
+
* OID4VP §8.3 paragraph 6 (mandatory for ECDH-ES KDFs to bind
|
|
54
|
+
* the encryption to the session). Optionally sets `apu` if the
|
|
55
|
+
* caller provides a wallet-side nonce.
|
|
56
|
+
* - When the verifier ALSO declared
|
|
57
|
+
* `authorization_signed_response_alg`, signs the payload first
|
|
58
|
+
* with the wallet's signing key and encrypts the resulting JWS
|
|
59
|
+
* instead of the raw JSON. The inner JWS protected header
|
|
60
|
+
* carries the wallet's `kid`/`alg` so the verifier can identify
|
|
61
|
+
* who authored the response.
|
|
62
|
+
*
|
|
63
|
+
* # What this module does NOT do
|
|
64
|
+
*
|
|
65
|
+
* - **Network I/O is injected.** When the verifier publishes its
|
|
66
|
+
* keys via `jwks_uri` (instead of inline `jwks`), the caller
|
|
67
|
+
* passes a `fetchImpl` so the module stays testable.
|
|
68
|
+
* - **Wallet signing is injected.** The optional inner JWS uses a
|
|
69
|
+
* caller-supplied signer (the same one that signs vp_token JWTs);
|
|
70
|
+
* this module never touches the wallet's keystore directly.
|
|
71
|
+
* - **Decryption.** Wallets only encrypt outbound responses; the
|
|
72
|
+
* verifier handles decryption. The Sphereon test harness has its
|
|
73
|
+
* own decryption shim mirroring this module's encrypt shape so
|
|
74
|
+
* interop tests can round-trip.
|
|
75
|
+
*
|
|
76
|
+
* # Why this is its own module
|
|
77
|
+
*
|
|
78
|
+
* Encryption is the security perimeter for response confidentiality —
|
|
79
|
+
* a bug here leaks every claim the wallet ever discloses. Keeping it
|
|
80
|
+
* in one tested module (rather than inlining JWE building inside
|
|
81
|
+
* `submit.ts`) means:
|
|
82
|
+
*
|
|
83
|
+
* 1. The unit-test surface is one cohesive matrix of algorithm
|
|
84
|
+
* negotiations, key-selection edge cases, and nonce-binding
|
|
85
|
+
* assertions, not smeared across the transport's tests.
|
|
86
|
+
* 2. The transport (`submit.ts`) stays a pure HTTP layer; whether
|
|
87
|
+
* the response is cleartext or JOSE is a one-line dispatch
|
|
88
|
+
* based on `response_mode`.
|
|
89
|
+
* 3. Future work (e.g. signed-only JARM responses for low-privacy
|
|
90
|
+
* use cases, or post-quantum KEM algorithms) lands here without
|
|
91
|
+
* touching the wire layer.
|
|
92
|
+
*/
|
|
93
|
+
import { type JWK } from 'jose';
|
|
94
|
+
import type { ProofJwtSigner } from '../vci/types';
|
|
95
|
+
/**
|
|
96
|
+
* The plaintext response object — same fields the cleartext
|
|
97
|
+
* `direct_post` mode sends as form parameters, packed into a single
|
|
98
|
+
* JSON object that becomes the JWE plaintext (or the JWS payload
|
|
99
|
+
* when nested signing is in use).
|
|
100
|
+
*/
|
|
101
|
+
export interface ResponseObjectPayload {
|
|
102
|
+
/**
|
|
103
|
+
* Signed VP token. Three shapes are accepted (mirrors the
|
|
104
|
+
* `submit.ts` `VpToken` discriminator):
|
|
105
|
+
* - PEX `jwt_vp_json` → compact JWS string
|
|
106
|
+
* - PEX `ldp_vp` → signed VP JSON object
|
|
107
|
+
* - DCQL response → JSON object keyed by credential_query_id
|
|
108
|
+
*/
|
|
109
|
+
vp_token: string | Record<string, unknown>;
|
|
110
|
+
/**
|
|
111
|
+
* DIF PEX v2 Presentation Submission. Required for PEX flows;
|
|
112
|
+
* MUST be omitted for DCQL flows (which embed routing in the
|
|
113
|
+
* vp_token keying).
|
|
114
|
+
*/
|
|
115
|
+
presentation_submission?: Record<string, unknown>;
|
|
116
|
+
/**
|
|
117
|
+
* Verifier's `state` echoed back so it can correlate the response
|
|
118
|
+
* with the pending session. Omitted when the Auth Request didn't
|
|
119
|
+
* carry one.
|
|
120
|
+
*/
|
|
121
|
+
state?: string;
|
|
122
|
+
/**
|
|
123
|
+
* SIOPv2 ID token. Required when the verifier asked for
|
|
124
|
+
* `response_type=vp_token id_token`; must be omitted otherwise.
|
|
125
|
+
*/
|
|
126
|
+
id_token?: string;
|
|
127
|
+
/**
|
|
128
|
+
* Pass-through for any extension fields a future spec rev (or a
|
|
129
|
+
* vendor-specific deployment) requires the wallet to echo. Kept
|
|
130
|
+
* as `unknown` so we don't silently corrupt unfamiliar shapes.
|
|
131
|
+
*/
|
|
132
|
+
[extra: string]: unknown;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Subset of `client_metadata` (OID4VP §5.6) that JARM cares about.
|
|
136
|
+
* Loose by design — the spec lets verifiers add fields, and we only
|
|
137
|
+
* validate the ones that drive cryptographic decisions.
|
|
138
|
+
*/
|
|
139
|
+
export interface JarmClientMetadata {
|
|
140
|
+
/** Inline JWKS — preferred over `jwks_uri` when both are present. */
|
|
141
|
+
jwks?: {
|
|
142
|
+
keys: JWK[];
|
|
143
|
+
};
|
|
144
|
+
/** URL form of `jwks` — fetched lazily when no inline jwks is set. */
|
|
145
|
+
jwks_uri?: string;
|
|
146
|
+
/**
|
|
147
|
+
* JWE key-wrap algorithm the verifier expects. Common values:
|
|
148
|
+
* `ECDH-ES`, `ECDH-ES+A256KW`, `RSA-OAEP-256`. When omitted the
|
|
149
|
+
* spec recommends `ECDH-ES` (§8.3 paragraph 4).
|
|
150
|
+
*/
|
|
151
|
+
authorization_encrypted_response_alg?: string;
|
|
152
|
+
/**
|
|
153
|
+
* JWE content-encryption algorithm. Common values: `A256GCM`,
|
|
154
|
+
* `A128CBC-HS256`. Spec default: `A256GCM`.
|
|
155
|
+
*/
|
|
156
|
+
authorization_encrypted_response_enc?: string;
|
|
157
|
+
/**
|
|
158
|
+
* Optional outer-JWS algorithm. When set, the wallet MUST sign
|
|
159
|
+
* the payload first with this alg before encrypting. When unset,
|
|
160
|
+
* the JWE plaintext is the raw JSON payload (no nested signing).
|
|
161
|
+
*/
|
|
162
|
+
authorization_signed_response_alg?: string;
|
|
163
|
+
}
|
|
164
|
+
export interface EncryptResponseObjectOptions {
|
|
165
|
+
/**
|
|
166
|
+
* Plaintext response-object payload. Stringified (JSON) and
|
|
167
|
+
* either signed-then-encrypted or encrypted directly depending
|
|
168
|
+
* on `clientMetadata.authorization_signed_response_alg`.
|
|
169
|
+
*/
|
|
170
|
+
payload: ResponseObjectPayload;
|
|
171
|
+
/** Verifier's `client_metadata` from the Authorization Request. */
|
|
172
|
+
clientMetadata: JarmClientMetadata;
|
|
173
|
+
/**
|
|
174
|
+
* Verifier's `nonce` from the Authorization Request — base64url-
|
|
175
|
+
* encoded and placed in the JWE protected header's `apv` field
|
|
176
|
+
* per OID4VP §8.3 paragraph 6. Required: omitting it produces a
|
|
177
|
+
* JWE the verifier MUST reject for ECDH-ES key wrap.
|
|
178
|
+
*/
|
|
179
|
+
verifierNonce: string;
|
|
180
|
+
/**
|
|
181
|
+
* Optional wallet-side nonce, base64url-encoded into the JWE's
|
|
182
|
+
* `apu` field. Useful for ECDH-1PU flows where the wallet binds
|
|
183
|
+
* its own key to the session; OID4VP doesn't mandate it.
|
|
184
|
+
*/
|
|
185
|
+
walletNonce?: string;
|
|
186
|
+
/**
|
|
187
|
+
* Wallet's signer — reuses the same `ProofJwtSigner` shape used
|
|
188
|
+
* by VCI proof-of-possession and outer VP signing, so callers can
|
|
189
|
+
* thread their existing signer through unchanged. Required only
|
|
190
|
+
* when `clientMetadata.authorization_signed_response_alg` is set
|
|
191
|
+
* (nested JWS-in-JWE mode); ignored otherwise.
|
|
192
|
+
*/
|
|
193
|
+
signer?: ProofJwtSigner;
|
|
194
|
+
/**
|
|
195
|
+
* Override fetch — defaults to `globalThis.fetch`. Only consulted
|
|
196
|
+
* when the verifier supplied `jwks_uri` instead of inline `jwks`.
|
|
197
|
+
*/
|
|
198
|
+
fetchImpl?: typeof fetch;
|
|
199
|
+
}
|
|
200
|
+
export type JarmEncryptErrorCode = 'no_encryption_key' | 'invalid_jwks' | 'jwks_fetch_failed' | 'unsupported_alg' | 'missing_signer' | 'sign_failed' | 'encrypt_failed';
|
|
201
|
+
export declare class JarmEncryptError extends Error {
|
|
202
|
+
readonly code: JarmEncryptErrorCode;
|
|
203
|
+
constructor(code: JarmEncryptErrorCode, message: string, extra?: {
|
|
204
|
+
cause?: unknown;
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Default JWE algorithms when the verifier didn't declare any. The
|
|
209
|
+
* spec leaves the choice to the verifier; we pick the
|
|
210
|
+
* spec-recommended pair so a verifier that fails to advertise
|
|
211
|
+
* algorithms still gets something it's likely to accept.
|
|
212
|
+
*/
|
|
213
|
+
export declare const DEFAULT_JWE_ALG = "ECDH-ES";
|
|
214
|
+
export declare const DEFAULT_JWE_ENC = "A256GCM";
|
|
215
|
+
/**
|
|
216
|
+
* Build the JOSE blob to put in the `response` form field for a
|
|
217
|
+
* `direct_post.jwt` submission. See the module docstring for the
|
|
218
|
+
* full algorithm + edge-case matrix.
|
|
219
|
+
*/
|
|
220
|
+
export declare const encryptResponseObject: (options: EncryptResponseObjectOptions) => Promise<string>;
|
|
221
|
+
//# sourceMappingURL=encrypt.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"encrypt.d.ts","sourceRoot":"","sources":["../../src/vp/encrypt.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2FG;AACH,OAAO,EAA6B,KAAK,GAAG,EAAE,MAAM,MAAM,CAAC;AAE3D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAMnD;;;;;GAKG;AACH,MAAM,WAAW,qBAAqB;IAClC;;;;;;OAMG;IACH,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAE3C;;;;OAIG;IACH,uBAAuB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAElD;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;;;OAIG;IACH,CAAC,KAAK,EAAE,MAAM,GAAG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1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OpenID4VP (Verifier-side → Wallet holder) surface.
|
|
3
|
+
*
|
|
4
|
+
* The verify / present half of OpenID4VC: parse Authorization Requests,
|
|
5
|
+
* match the holder's credentials against DIF PEX v2 Presentation
|
|
6
|
+
* Definitions, and build the DIF PEX Presentation Submission. Signing
|
|
7
|
+
* the resulting vp_token and posting it to the verifier lives in Slice 7.
|
|
8
|
+
*/
|
|
9
|
+
export { parseAuthorizationRequestUri, resolvePresentationDefinitionByReference, resolveAuthorizationRequest, } from './parse';
|
|
10
|
+
export type { ResolveAuthorizationRequestOptions } from './parse';
|
|
11
|
+
export { verifyAndDecodeRequestObject, RequestObjectError, builtInDidResolver, } from './request-object';
|
|
12
|
+
export type { RequestObjectErrorCode, VerifyRequestObjectOptions, DidResolver, DidDocument, VerificationMethod, } from './request-object';
|
|
13
|
+
export { selectCredentials, buildPresentationSubmission, inferCredentialFormat, } from './select';
|
|
14
|
+
export { evaluateField, matchInputDescriptor, queryJsonPath, satisfiesFilter, } from './pex';
|
|
15
|
+
export type { AuthorizationRequest, ParsedAuthorizationRequest, PresentationDefinition, InputDescriptor, Constraints, Field, SubmissionRequirement, ClaimFormatDesignation, VpErrorCode, } from './types';
|
|
16
|
+
export { VpError } from './types';
|
|
17
|
+
export type { CandidateCredential, DescriptorCandidate, DescriptorSelection, SelectionResult, SelectedDescriptor, PresentationSubmission, PresentationSubmissionDescriptor, } from './select';
|
|
18
|
+
export type { DescriptorMatch, FieldMatch } from './pex';
|
|
19
|
+
export { buildPresentation, BuildPresentationError } from './present';
|
|
20
|
+
export type { VpFormat, ChosenCredential, BuildPresentationOptions, PreparedPresentation, BuildPresentationErrorCode, } from './present';
|
|
21
|
+
export { signPresentation, VpSignError } from './sign';
|
|
22
|
+
export type { VpToken, LdpVpSigner, SignPresentationOptions, SignPresentationHelpers, SignPresentationResult, VpSignErrorCode, } from './sign';
|
|
23
|
+
export { submitPresentation, VpSubmitError } from './submit';
|
|
24
|
+
export type { SubmitPresentationOptions, SubmitPresentationResult, VpSubmitErrorCode, } from './submit';
|
|
25
|
+
export { encryptResponseObject, JarmEncryptError, DEFAULT_JWE_ALG, DEFAULT_JWE_ENC, } from './encrypt';
|
|
26
|
+
export type { EncryptResponseObjectOptions, JarmClientMetadata, JarmEncryptErrorCode, ResponseObjectPayload, } from './encrypt';
|
|
27
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/vp/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EACH,4BAA4B,EAC5B,wCAAwC,EACxC,2BAA2B,GAC9B,MAAM,SAAS,CAAC;AAEjB,YAAY,EAAE,kCAAkC,EAAE,MAAM,SAAS,CAAC;AAElE,OAAO,EACH,4BAA4B,EAC5B,kBAAkB,EAClB,kBAAkB,GACrB,MAAM,kBAAkB,CAAC;AAE1B,YAAY,EACR,sBAAsB,EACtB,0BAA0B,EAC1B,WAAW,EACX,WAAW,EACX,kBAAkB,GACrB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACH,iBAAiB,EACjB,2BAA2B,EAC3B,qBAAqB,GACxB,MAAM,UAAU,CAAC;AAElB,OAAO,EACH,aAAa,EACb,oBAAoB,EACpB,aAAa,EACb,eAAe,GAClB,MAAM,OAAO,CAAC;AAEf,YAAY,EACR,oBAAoB,EACpB,0BAA0B,EAC1B,sBAAsB,EACtB,eAAe,EACf,WAAW,EACX,KAAK,EACL,qBAAqB,EACrB,sBAAsB,EACtB,WAAW,GACd,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAElC,YAAY,EACR,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACnB,eAAe,EACf,kBAAkB,EAClB,sBAAsB,EACtB,gCAAgC,GACnC,MAAM,UAAU,CAAC;AAElB,YAAY,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAEzD,OAAO,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAC;AAEtE,YAAY,EACR,QAAQ,EACR,gBAAgB,EAChB,wBAAwB,EACxB,oBAAoB,EACpB,0BAA0B,GAC7B,MAAM,WAAW,CAAC;AAEnB,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAEvD,YAAY,EACR,OAAO,EACP,WAAW,EACX,uBAAuB,EACvB,uBAAuB,EACvB,sBAAsB,EACtB,eAAe,GAClB,MAAM,QAAQ,CAAC;AAEhB,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAE7D,YAAY,EACR,yBAAyB,EACzB,wBAAwB,EACxB,iBAAiB,GACpB,MAAM,UAAU,CAAC;AAElB,OAAO,EACH,qBAAqB,EACrB,gBAAgB,EAChB,eAAe,EACf,eAAe,GAClB,MAAM,WAAW,CAAC;AAEnB,YAAY,EACR,4BAA4B,EAC5B,kBAAkB,EAClB,oBAAoB,EACpB,qBAAqB,GACxB,MAAM,WAAW,CAAC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { AuthorizationRequest, ParsedAuthorizationRequest, PresentationDefinition } from './types';
|
|
2
|
+
import { DidResolver } from './request-object';
|
|
3
|
+
/**
|
|
4
|
+
* Parse an OpenID4VP Authorization Request URI without hitting the network.
|
|
5
|
+
*
|
|
6
|
+
* Accepts every shape wallets see in the wild:
|
|
7
|
+
* - `openid4vp://?client_id=...&presentation_definition=...`
|
|
8
|
+
* - `haip://?client_id=...` (EUDI-flavored deeplinks)
|
|
9
|
+
* - `openid-vc://?client_id=...` (Draft 11/13 legacy scheme)
|
|
10
|
+
* - `https://verifier.example/authorize?client_id=...` (web flow)
|
|
11
|
+
* - Signed Request Objects via `request=<JWS>` or `request_uri=<https url>`
|
|
12
|
+
* — both are returned as a `by_reference_*` variant for Slice 7 to
|
|
13
|
+
* verify + decode.
|
|
14
|
+
*
|
|
15
|
+
* When the request arrives with a signed Request Object, every other
|
|
16
|
+
* parameter in the URI is spec-mandated to be ignored in favor of the
|
|
17
|
+
* JWS claims, so we punt immediately without validating them here.
|
|
18
|
+
*/
|
|
19
|
+
export declare const parseAuthorizationRequestUri: (input: string) => ParsedAuthorizationRequest;
|
|
20
|
+
/**
|
|
21
|
+
* Fetch a `presentation_definition_uri` and parse it as a DIF PEX v2
|
|
22
|
+
* Presentation Definition. Caller is responsible for validating the
|
|
23
|
+
* returned shape against their own trust policy (allow-listed hosts,
|
|
24
|
+
* size limits, etc.).
|
|
25
|
+
*/
|
|
26
|
+
export declare const resolvePresentationDefinitionByReference: (uri: string, fetchImpl?: typeof fetch) => Promise<PresentationDefinition>;
|
|
27
|
+
/**
|
|
28
|
+
* Options consumed by {@link resolveAuthorizationRequest} for signed
|
|
29
|
+
* Request Object verification (Slice 7.5). The caller (typically the
|
|
30
|
+
* plugin) wires DID resolver + X.509 roots from plugin config.
|
|
31
|
+
*/
|
|
32
|
+
export interface ResolveAuthorizationRequestOptions {
|
|
33
|
+
/** DID resolver for `client_id_scheme=did`. Defaults to built-in did:jwk + did:web. */
|
|
34
|
+
didResolver?: DidResolver;
|
|
35
|
+
/** Trust anchors for `client_id_scheme=x509_san_dns`. PEM-encoded. */
|
|
36
|
+
trustedX509Roots?: readonly string[];
|
|
37
|
+
/** **Dev-only.** Accept x509 chains without a trusted root. */
|
|
38
|
+
unsafeAllowSelfSigned?: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* **Dev-only escape hatch.** Skip JWS signature verification on
|
|
41
|
+
* the Request Object entirely (still parses claims). For
|
|
42
|
+
* interop testing against verifiers whose signing keys are
|
|
43
|
+
* pre-shared out-of-band — production wallets MUST leave this
|
|
44
|
+
* off. See `request-object.ts` for the full warning.
|
|
45
|
+
*/
|
|
46
|
+
unsafeSkipRequestObjectSignatureVerification?: boolean;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* End-to-end: parse the URI, resolve signed Request Objects (per
|
|
50
|
+
* Slice 7.5), and inline `presentation_definition_uri` if needed, so
|
|
51
|
+
* the caller gets a single fully-resolved {@link AuthorizationRequest}.
|
|
52
|
+
*
|
|
53
|
+
* Signed Request Objects are verified according to their
|
|
54
|
+
* `client_id_scheme` (`did`, `x509_san_dns`). Schemes we don't support
|
|
55
|
+
* — or a `redirect_uri` scheme that illegitimately carries a signed
|
|
56
|
+
* Request Object — bubble up as {@link RequestObjectError} with a
|
|
57
|
+
* typed code.
|
|
58
|
+
*/
|
|
59
|
+
export declare const resolveAuthorizationRequest: (input: string, fetchImpl?: typeof fetch, options?: ResolveAuthorizationRequestOptions) => Promise<AuthorizationRequest>;
|
|
60
|
+
//# sourceMappingURL=parse.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse.d.ts","sourceRoot":"","sources":["../../src/vp/parse.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,oBAAoB,EACpB,0BAA0B,EAC1B,sBAAsB,EAEzB,MAAM,SAAS,CAAC;AACjB,OAAO,EAEH,WAAW,EACd,MAAM,kBAAkB,CAAC;AAK1B;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,4BAA4B,UAC9B,MAAM,KACd,0BA+BF,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,wCAAwC,QAC5C,MAAM,cACA,OAAO,KAAK,KACxB,OAAO,CAAC,sBAAsB,CA+ChC,CAAC;AAEF;;;;GAIG;AACH,MAAM,WAAW,kCAAkC;IAC/C,uFAAuF;IACvF,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,sEAAsE;IACtE,gBAAgB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACrC,+DAA+D;IAC/D,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC;;;;;;OAMG;IACH,4CAA4C,CAAC,EAAE,OAAO,CAAC;CAC1D;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,2BAA2B,UAC7B,MAAM,cACF,OAAO,KAAK,YACd,kCAAkC,KAC5C,OAAO,CAAC,oBAAoB,CA2C9B,CAAC"}
|