@ixo/credentials-kit 0.0.0-stage → 0.1.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/README.md +469 -2
- package/dist/chunk-2SF56NEJ.js +1053 -0
- package/dist/chunk-2SF56NEJ.js.map +1 -0
- package/dist/chunk-46VRPQPD.js +176 -0
- package/dist/chunk-46VRPQPD.js.map +1 -0
- package/dist/chunk-AQ3IINHC.js +138 -0
- package/dist/chunk-AQ3IINHC.js.map +1 -0
- package/dist/chunk-FSKCDHZ7.js +613 -0
- package/dist/chunk-FSKCDHZ7.js.map +1 -0
- package/dist/chunk-I6GBYFIJ.js +89 -0
- package/dist/chunk-I6GBYFIJ.js.map +1 -0
- package/dist/chunk-JBUX6V2Q.js +210 -0
- package/dist/chunk-JBUX6V2Q.js.map +1 -0
- package/dist/chunk-Q3MZNMCK.js +183 -0
- package/dist/chunk-Q3MZNMCK.js.map +1 -0
- package/dist/chunk-RKKRO4ZK.js +133 -0
- package/dist/chunk-RKKRO4ZK.js.map +1 -0
- package/dist/chunk-STMMFNVW.js +391 -0
- package/dist/chunk-STMMFNVW.js.map +1 -0
- package/dist/chunk-VXKONZK4.js +189 -0
- package/dist/chunk-VXKONZK4.js.map +1 -0
- package/dist/chunk-WIEGZFUO.js +337 -0
- package/dist/chunk-WIEGZFUO.js.map +1 -0
- package/dist/chunk-WND2LZ4O.js +66 -0
- package/dist/chunk-WND2LZ4O.js.map +1 -0
- package/dist/chunk-XREZY53L.js +260 -0
- package/dist/chunk-XREZY53L.js.map +1 -0
- package/dist/chunk-ZZY4WGQ6.js +13 -0
- package/dist/chunk-ZZY4WGQ6.js.map +1 -0
- package/dist/did.d.ts +182 -0
- package/dist/did.js +6 -0
- package/dist/did.js.map +1 -0
- package/dist/display.d.ts +117 -0
- package/dist/display.js +5 -0
- package/dist/display.js.map +1 -0
- package/dist/errors-BKQmNpXX.d.ts +11 -0
- package/dist/holder.d.ts +85 -0
- package/dist/holder.js +8 -0
- package/dist/holder.js.map +1 -0
- package/dist/http-BhuJ_-RZ.d.ts +25 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -0
- package/dist/jose.d.ts +134 -0
- package/dist/jose.js +4 -0
- package/dist/jose.js.map +1 -0
- package/dist/oid4vci.d.ts +428 -0
- package/dist/oid4vci.js +11 -0
- package/dist/oid4vci.js.map +1 -0
- package/dist/oid4vp.d.ts +416 -0
- package/dist/oid4vp.js +11 -0
- package/dist/oid4vp.js.map +1 -0
- package/dist/profile.d.ts +218 -0
- package/dist/profile.js +4 -0
- package/dist/profile.js.map +1 -0
- package/dist/sdjwt.d.ts +133 -0
- package/dist/sdjwt.js +5 -0
- package/dist/sdjwt.js.map +1 -0
- package/dist/sender.d.ts +8 -0
- package/dist/sender.js +7 -0
- package/dist/sender.js.map +1 -0
- package/dist/status.d.ts +108 -0
- package/dist/status.js +7 -0
- package/dist/status.js.map +1 -0
- package/dist/util-DOTEZgTt.d.ts +3 -0
- package/dist/verify.d.ts +144 -0
- package/dist/verify.js +9 -0
- package/dist/verify.js.map +1 -0
- package/dist/webhook.d.ts +62 -0
- package/dist/webhook.js +7 -0
- package/dist/webhook.js.map +1 -0
- package/package.json +168 -4
|
@@ -0,0 +1,428 @@
|
|
|
1
|
+
import { DidResolver } from './did.js';
|
|
2
|
+
import { CredentialsKitError } from './index.js';
|
|
3
|
+
import { FetchLike, HostPolicy } from './did.js';
|
|
4
|
+
import { Signer, Ed25519PublicJwk, Ed25519JwsAlg } from './jose.js';
|
|
5
|
+
import { PRE_AUTHORIZED_CODE_GRANT } from './profile.js';
|
|
6
|
+
import { VerifyIssuedCredentialOptions, VerifiedPresentation } from './verify.js';
|
|
7
|
+
import './util-DOTEZgTt.js';
|
|
8
|
+
import './display.js';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* `@ixo/credentials-kit/oid4vci` — OpenID for Verifiable Credential Issuance 1.0, pre-authorized
|
|
12
|
+
* code flow only, `dc+sd-jwt` only, `jwt` key proofs (EdDSA, key named by a DID URL `kid`).
|
|
13
|
+
*
|
|
14
|
+
* Wallet flow (`redeemOffer`):
|
|
15
|
+
* 1. issuer metadata GET <host>/.well-known/openid-credential-issuer[<path>] (§12.2.2)
|
|
16
|
+
* 2. AS metadata GET <host>/.well-known/oauth-authorization-server[<path>] (RFC 8414 §3;
|
|
17
|
+
* the AS is the credential issuer unless `authorization_servers` says otherwise, §12.2.4)
|
|
18
|
+
* 3. token POST token_endpoint, form: grant_type=urn:ietf:params:oauth:grant-type:
|
|
19
|
+
* pre-authorized_code & pre-authorized_code=… [& tx_code=…] (§6.1)
|
|
20
|
+
* 4. nonce POST nonce_endpoint → { c_nonce } (§7)
|
|
21
|
+
* 5. credential POST credential_endpoint, Bearer, JSON { credential_configuration_id
|
|
22
|
+
* (or credential_identifier), proofs: { jwt: [ proof ] } } (§8.2)
|
|
23
|
+
* → 200 { credentials: [{ credential }], notification_id? }
|
|
24
|
+
* | 202 { transaction_id, interval } (§8.3)
|
|
25
|
+
* 6. deferred POST deferred_credential_endpoint { transaction_id } (§9)
|
|
26
|
+
* 7. notification POST notification_endpoint { notification_id, event } (§11)
|
|
27
|
+
*
|
|
28
|
+
* Proof JWT (Appendix F.1): header { typ: 'openid4vci-proof+jwt', alg: 'EdDSA' (or 'Ed25519'
|
|
29
|
+
* when that is the only one the issuer lists), kid: <DID URL> } (never `jwk` or `x5c`), payload
|
|
30
|
+
* { aud: <credential issuer identifier>, iat, nonce: c_nonce } (no `iss`: anonymous
|
|
31
|
+
* pre-authorized access). The wallet refuses an offer whose configuration does not list
|
|
32
|
+
* `did:<method of the holder DID>` in `cryptographic_binding_methods_supported` (when present).
|
|
33
|
+
*
|
|
34
|
+
* The wallet checks every credential it receives with `verifyIssuedCredential` before returning
|
|
35
|
+
* it (RFC 9901 §7.2; opt out with `verify: false`).
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
interface Display {
|
|
39
|
+
name: string;
|
|
40
|
+
locale?: string;
|
|
41
|
+
description?: string;
|
|
42
|
+
logo?: {
|
|
43
|
+
uri: string;
|
|
44
|
+
alt_text?: string;
|
|
45
|
+
};
|
|
46
|
+
background_color?: string;
|
|
47
|
+
text_color?: string;
|
|
48
|
+
}
|
|
49
|
+
interface ClaimDescription {
|
|
50
|
+
path: (string | number | null)[];
|
|
51
|
+
mandatory?: boolean;
|
|
52
|
+
display?: {
|
|
53
|
+
name?: string;
|
|
54
|
+
locale?: string;
|
|
55
|
+
}[];
|
|
56
|
+
}
|
|
57
|
+
interface CredentialConfiguration {
|
|
58
|
+
format: 'dc+sd-jwt';
|
|
59
|
+
vct: string;
|
|
60
|
+
scope?: string;
|
|
61
|
+
cryptographic_binding_methods_supported?: string[];
|
|
62
|
+
credential_signing_alg_values_supported?: string[];
|
|
63
|
+
proof_types_supported?: Record<string, {
|
|
64
|
+
proof_signing_alg_values_supported: string[];
|
|
65
|
+
}>;
|
|
66
|
+
credential_metadata?: {
|
|
67
|
+
display?: Display[];
|
|
68
|
+
claims?: ClaimDescription[];
|
|
69
|
+
};
|
|
70
|
+
[name: string]: unknown;
|
|
71
|
+
}
|
|
72
|
+
interface CredentialIssuerMetadata {
|
|
73
|
+
credential_issuer: string;
|
|
74
|
+
authorization_servers?: string[];
|
|
75
|
+
credential_endpoint: string;
|
|
76
|
+
nonce_endpoint?: string;
|
|
77
|
+
deferred_credential_endpoint?: string;
|
|
78
|
+
notification_endpoint?: string;
|
|
79
|
+
display?: Display[];
|
|
80
|
+
credential_configurations_supported: Record<string, CredentialConfiguration>;
|
|
81
|
+
[name: string]: unknown;
|
|
82
|
+
}
|
|
83
|
+
/** RFC 8414 metadata, as much of it as the pre-authorized code flow needs. */
|
|
84
|
+
interface AuthorizationServerMetadata {
|
|
85
|
+
issuer: string;
|
|
86
|
+
token_endpoint: string;
|
|
87
|
+
grant_types_supported?: string[];
|
|
88
|
+
token_endpoint_auth_methods_supported?: string[];
|
|
89
|
+
'pre-authorized_grant_anonymous_access_supported'?: boolean;
|
|
90
|
+
[name: string]: unknown;
|
|
91
|
+
}
|
|
92
|
+
interface TxCode {
|
|
93
|
+
input_mode?: 'numeric' | 'text';
|
|
94
|
+
length?: number;
|
|
95
|
+
description?: string;
|
|
96
|
+
}
|
|
97
|
+
interface PreAuthorizedCodeGrant {
|
|
98
|
+
'pre-authorized_code': string;
|
|
99
|
+
tx_code?: TxCode;
|
|
100
|
+
authorization_server?: string;
|
|
101
|
+
}
|
|
102
|
+
interface CredentialOffer {
|
|
103
|
+
credential_issuer: string;
|
|
104
|
+
credential_configuration_ids: string[];
|
|
105
|
+
grants: {
|
|
106
|
+
'urn:ietf:params:oauth:grant-type:pre-authorized_code': PreAuthorizedCodeGrant;
|
|
107
|
+
[grant: string]: unknown;
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
/** Form parameters of the token request (§6.1). */
|
|
111
|
+
interface TokenRequest {
|
|
112
|
+
grant_type: typeof PRE_AUTHORIZED_CODE_GRANT;
|
|
113
|
+
'pre-authorized_code': string;
|
|
114
|
+
tx_code?: string;
|
|
115
|
+
}
|
|
116
|
+
interface TokenResponse {
|
|
117
|
+
access_token: string;
|
|
118
|
+
token_type: string;
|
|
119
|
+
expires_in?: number;
|
|
120
|
+
authorization_details?: {
|
|
121
|
+
type: 'openid_credential';
|
|
122
|
+
credential_configuration_id: string;
|
|
123
|
+
credential_identifiers: string[];
|
|
124
|
+
}[];
|
|
125
|
+
}
|
|
126
|
+
interface NonceResponse {
|
|
127
|
+
c_nonce: string;
|
|
128
|
+
}
|
|
129
|
+
type CredentialRequest = {
|
|
130
|
+
credential_configuration_id: string;
|
|
131
|
+
proofs: {
|
|
132
|
+
jwt: string[];
|
|
133
|
+
};
|
|
134
|
+
} | {
|
|
135
|
+
credential_identifier: string;
|
|
136
|
+
proofs: {
|
|
137
|
+
jwt: string[];
|
|
138
|
+
};
|
|
139
|
+
};
|
|
140
|
+
interface CredentialResponse {
|
|
141
|
+
credentials: {
|
|
142
|
+
credential: string;
|
|
143
|
+
}[];
|
|
144
|
+
notification_id?: string;
|
|
145
|
+
}
|
|
146
|
+
interface DeferredCredentialResponse {
|
|
147
|
+
transaction_id: string;
|
|
148
|
+
interval: number;
|
|
149
|
+
}
|
|
150
|
+
interface DeferredCredentialRequest {
|
|
151
|
+
transaction_id: string;
|
|
152
|
+
}
|
|
153
|
+
type NotificationEvent = 'credential_accepted' | 'credential_failure' | 'credential_deleted';
|
|
154
|
+
interface NotificationRequest {
|
|
155
|
+
notification_id: string;
|
|
156
|
+
event: NotificationEvent;
|
|
157
|
+
event_description?: string;
|
|
158
|
+
}
|
|
159
|
+
/** Error response of the token, credential, deferred and notification endpoints. */
|
|
160
|
+
interface OAuthErrorResponse {
|
|
161
|
+
error: string;
|
|
162
|
+
error_description?: string;
|
|
163
|
+
}
|
|
164
|
+
type Oid4vciErrorCode = 'invalid_offer' | 'unsupported_offer' | 'invalid_metadata' | 'issuer_unavailable' | 'tx_code_unsupported' | 'token_error' | 'issuer_error' | 'invalid_response' | 'invalid_proof' | 'invalid_nonce' | 'invalid_credential';
|
|
165
|
+
declare class Oid4vciError extends CredentialsKitError {
|
|
166
|
+
readonly code: Oid4vciErrorCode;
|
|
167
|
+
/** The OAuth / OpenID4VCI error code the server answered (sanitised), when there was one. */
|
|
168
|
+
readonly oauthError?: string;
|
|
169
|
+
/**
|
|
170
|
+
* For `invalid_proof` / `invalid_nonce`: a constant cause for logs. For `invalid_credential`:
|
|
171
|
+
* the `verifyIssuedCredential` failure code (`bad_signature`, `wrong_subject`, …).
|
|
172
|
+
*/
|
|
173
|
+
readonly reason?: string;
|
|
174
|
+
constructor(code: Oid4vciErrorCode, extra?: {
|
|
175
|
+
oauthError?: string;
|
|
176
|
+
reason?: string;
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* The Credential Issuer Metadata URL (§12.2.2): `/.well-known/openid-credential-issuer` inserted
|
|
181
|
+
* between the host and the identifier's path (`https://h/identity` →
|
|
182
|
+
* `https://h/.well-known/openid-credential-issuer/identity`).
|
|
183
|
+
*/
|
|
184
|
+
declare function issuerMetadataUrl(credentialIssuer: string): string;
|
|
185
|
+
/** The RFC 8414 Authorization Server Metadata URL, built the same way. */
|
|
186
|
+
declare function authorizationServerMetadataUrl(issuer: string): string;
|
|
187
|
+
interface IssuerConfigurationInput {
|
|
188
|
+
vct: string;
|
|
189
|
+
display?: Display[];
|
|
190
|
+
claims?: ClaimDescription[];
|
|
191
|
+
}
|
|
192
|
+
interface BuildIssuerMetadataInput {
|
|
193
|
+
/** The Credential Issuer Identifier (https URL, no query or fragment). */
|
|
194
|
+
credentialIssuer: string;
|
|
195
|
+
/** Keyed by credential configuration id. */
|
|
196
|
+
configurations: Record<string, IssuerConfigurationInput>;
|
|
197
|
+
display?: Display[];
|
|
198
|
+
/** Omit when the issuer is its own Authorization Server (the usual case). */
|
|
199
|
+
authorizationServers?: string[];
|
|
200
|
+
/**
|
|
201
|
+
* Publish each configuration's id as its `scope` (§12.2.4). Default false: `scope` is for the
|
|
202
|
+
* authorization code flow, which the pre-authorized-only profile does not offer.
|
|
203
|
+
*/
|
|
204
|
+
includeScope?: boolean;
|
|
205
|
+
/**
|
|
206
|
+
* Endpoint URLs. Default: `<credentialIssuer>/oid4vci/{credential,nonce,notification}` (the
|
|
207
|
+
* layout Self uses). The deferred endpoint is published only when given.
|
|
208
|
+
*/
|
|
209
|
+
endpoints?: {
|
|
210
|
+
credential?: string;
|
|
211
|
+
nonce?: string;
|
|
212
|
+
deferred?: string;
|
|
213
|
+
notification?: string;
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Credential Issuer Metadata (§12.2.4) for `dc+sd-jwt` configurations with Ed25519 DID-bound
|
|
218
|
+
* proofs. Signing algorithms are listed as `["EdDSA", "Ed25519"]` (the JWS name the kit signs
|
|
219
|
+
* with, and the fully-specified RFC 9864 name it also accepts).
|
|
220
|
+
*/
|
|
221
|
+
declare function buildIssuerMetadata(input: BuildIssuerMetadataInput): CredentialIssuerMetadata;
|
|
222
|
+
/**
|
|
223
|
+
* RFC 8414 metadata for an issuer that is its own Authorization Server and supports only the
|
|
224
|
+
* pre-authorized code grant, anonymously (OpenID4VCI §12.3). Serve it at
|
|
225
|
+
* `authorizationServerMetadataUrl(credentialIssuer)`. Default token endpoint:
|
|
226
|
+
* `<credentialIssuer>/oid4vci/token`.
|
|
227
|
+
*/
|
|
228
|
+
declare function buildAuthorizationServerMetadata(input: {
|
|
229
|
+
issuer: string;
|
|
230
|
+
tokenEndpoint?: string;
|
|
231
|
+
}): AuthorizationServerMetadata;
|
|
232
|
+
/** A pre-authorized code credential offer (§4.1.1). */
|
|
233
|
+
declare function buildCredentialOffer(input: {
|
|
234
|
+
credentialIssuer: string;
|
|
235
|
+
configurationIds: string[];
|
|
236
|
+
preAuthorizedCode: string;
|
|
237
|
+
txCode?: TxCode;
|
|
238
|
+
}): CredentialOffer;
|
|
239
|
+
/**
|
|
240
|
+
* Validate a credential offer object: https `credential_issuer` on a public host (http only on a
|
|
241
|
+
* loopback host with `allowHttp` + `allowLocal`), no query or fragment, non-empty unique
|
|
242
|
+
* `credential_configuration_ids`, and a pre-authorized code grant with a non-empty code. Returns
|
|
243
|
+
* it normalised (only known members); throws `Oid4vciError('invalid_offer')`, or
|
|
244
|
+
* `unsupported_offer` for a well-formed offer with no pre-authorized code grant (e.g. only
|
|
245
|
+
* `authorization_code`).
|
|
246
|
+
*/
|
|
247
|
+
declare function validateCredentialOffer(v: unknown, opts?: HostPolicy): CredentialOffer;
|
|
248
|
+
interface VerifiedProof {
|
|
249
|
+
/** The holder DID the proof key belongs to (`kid` without its fragment). */
|
|
250
|
+
did: string;
|
|
251
|
+
kid: string;
|
|
252
|
+
publicKey: Uint8Array;
|
|
253
|
+
jwk: Ed25519PublicJwk;
|
|
254
|
+
/** The proof's `nonce`, when it has one. */
|
|
255
|
+
nonce?: string;
|
|
256
|
+
}
|
|
257
|
+
interface VerifyProofJwtOptions {
|
|
258
|
+
/** The Credential Issuer Identifier: the proof's `aud` must equal it. */
|
|
259
|
+
audience: string;
|
|
260
|
+
/**
|
|
261
|
+
* The expected c_nonce, or a check for it (e.g. a stateless signed nonce). Omit only when the
|
|
262
|
+
* issuer has no nonce endpoint.
|
|
263
|
+
*/
|
|
264
|
+
nonce?: string | ((nonce: string) => boolean | Promise<boolean>);
|
|
265
|
+
resolver: DidResolver;
|
|
266
|
+
/** ms since the epoch; default `Date.now()`. */
|
|
267
|
+
now?: number;
|
|
268
|
+
/** Oldest acceptable `iat`, in seconds before now (default 300). */
|
|
269
|
+
maxAgeSeconds?: number;
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* Verify an OpenID4VCI `jwt` key proof (Appendix F.1). The key must be an Ed25519 key listed
|
|
273
|
+
* under `authentication` on the DID document the `kid` names, controlled by that DID. The
|
|
274
|
+
* signature is checked before `opts.nonce` is called, so a single-use nonce store is consulted
|
|
275
|
+
* (and consumed) only for a proof the holder really signed. Returns
|
|
276
|
+
* the DID and key; the CALLER then enforces subject binding (the DID is the offer's subject) and
|
|
277
|
+
* binds `cnf` to exactly `jwk`. Throws `Oid4vciError` with code `invalid_proof` or
|
|
278
|
+
* `invalid_nonce` (the spec's error codes, ready for the error response) and a `reason`;
|
|
279
|
+
* `ResolverUnavailable` propagates.
|
|
280
|
+
*/
|
|
281
|
+
declare function verifyProofJwt(jwt: string, opts: VerifyProofJwtOptions): Promise<VerifiedProof>;
|
|
282
|
+
/** A `jwt` key proof for `audience` (the Credential Issuer Identifier) with the issuer's c_nonce. */
|
|
283
|
+
declare function createProofJwt(input: {
|
|
284
|
+
signer: Signer;
|
|
285
|
+
audience: string;
|
|
286
|
+
nonce?: string;
|
|
287
|
+
/** ms since the epoch; default `Date.now()`. */
|
|
288
|
+
now?: number;
|
|
289
|
+
/** Default `EdDSA`. */
|
|
290
|
+
alg?: Ed25519JwsAlg;
|
|
291
|
+
}): Promise<string>;
|
|
292
|
+
/** Fetch and check Credential Issuer Metadata (`credential_issuer` must match exactly, §12.2.4). */
|
|
293
|
+
declare function fetchIssuerMetadata(credentialIssuer: string, opts: {
|
|
294
|
+
fetch: FetchLike;
|
|
295
|
+
timeoutMs?: number;
|
|
296
|
+
} & HostPolicy): Promise<CredentialIssuerMetadata>;
|
|
297
|
+
/**
|
|
298
|
+
* GET a credential offer by reference (§4.1.3): https only (http on loopback with `allowHttp`),
|
|
299
|
+
* no redirects, timeout, 64 KiB cap, `application/json`; never cached. Returns the validated
|
|
300
|
+
* offer; throws `Oid4vciError` (`invalid_offer`, `issuer_unavailable`, `issuer_error`).
|
|
301
|
+
*/
|
|
302
|
+
declare function fetchCredentialOffer(credentialOfferUri: string, opts: {
|
|
303
|
+
fetch: FetchLike;
|
|
304
|
+
timeoutMs?: number;
|
|
305
|
+
} & HostPolicy): Promise<CredentialOffer>;
|
|
306
|
+
interface IssuedResult {
|
|
307
|
+
status: 'issued';
|
|
308
|
+
/** The SD-JWT VC as issued (`<jwt>~<disclosures>~`). */
|
|
309
|
+
credential: string;
|
|
310
|
+
notificationId?: string;
|
|
311
|
+
/** Needed for `sendNotification`. */
|
|
312
|
+
accessToken: string;
|
|
313
|
+
notificationEndpoint?: string;
|
|
314
|
+
/** What `verifyIssuedCredential` found (absent only with `verify: false`). */
|
|
315
|
+
verified?: VerifiedPresentation;
|
|
316
|
+
}
|
|
317
|
+
interface DeferredResult {
|
|
318
|
+
status: 'deferred';
|
|
319
|
+
transactionId: string;
|
|
320
|
+
/** Seconds to wait before polling. */
|
|
321
|
+
interval: number;
|
|
322
|
+
accessToken: string;
|
|
323
|
+
deferredEndpoint: string;
|
|
324
|
+
notificationEndpoint?: string;
|
|
325
|
+
/**
|
|
326
|
+
* What to check the credential against when it arrives: pass it to `pollDeferred` as
|
|
327
|
+
* `verification` (null with `verify: false`).
|
|
328
|
+
*/
|
|
329
|
+
verification: Omit<VerifyIssuedCredentialOptions, 'now'> | null;
|
|
330
|
+
}
|
|
331
|
+
interface RedeemOfferInput {
|
|
332
|
+
/** The offer by value (validated here; a `CredentialOffer` or the raw JSON). */
|
|
333
|
+
offer?: unknown;
|
|
334
|
+
/**
|
|
335
|
+
* The offer by reference (§4.1.3): fetched here on every call, never cached (each fetch mints a
|
|
336
|
+
* fresh, single-use pre-authorized code). Give exactly one of `offer` / `credentialOfferUri`.
|
|
337
|
+
*/
|
|
338
|
+
credentialOfferUri?: string;
|
|
339
|
+
/**
|
|
340
|
+
* The holder key (its `kid` is a DID URL of the holder; the issuer binds `cnf` to it). When it
|
|
341
|
+
* carries `publicKey` (an `Ed25519Signer`) that key is the expected `cnf`; otherwise the key
|
|
342
|
+
* `kid` names under `authentication` on the holder's DID document is.
|
|
343
|
+
*/
|
|
344
|
+
signer: Signer & {
|
|
345
|
+
publicKey?: Uint8Array;
|
|
346
|
+
};
|
|
347
|
+
fetch: FetchLike;
|
|
348
|
+
/**
|
|
349
|
+
* Resolves the issuer's DID (and the holder's, when the signer has no `publicKey`) to check the
|
|
350
|
+
* credential. Required unless `verify: false`.
|
|
351
|
+
*/
|
|
352
|
+
resolver?: DidResolver;
|
|
353
|
+
/**
|
|
354
|
+
* The DID the credential's `iss` must be (e.g. the DID that deposited the offer). REQUIRED
|
|
355
|
+
* unless `verify: false` (`TypeError` otherwise). `false` accepts ANY issuer whose own DID
|
|
356
|
+
* document signs the credential: UNSAFE, since anyone can then mint a credential of your types
|
|
357
|
+
* (an offer link the person opened is enough). Use it only when you judge `out.verified.issuer`
|
|
358
|
+
* yourself before storing or showing anything.
|
|
359
|
+
*/
|
|
360
|
+
expectedIssuer?: string | false;
|
|
361
|
+
/**
|
|
362
|
+
* Default true: check the credential with `verifyIssuedCredential` (signature, `iss`, `sub` =
|
|
363
|
+
* the holder DID, `cnf` = the holder key, `vct` = the offered configuration's, validity,
|
|
364
|
+
* disclosures). A credential that fails is NOT returned: `Oid4vciError('invalid_credential')`
|
|
365
|
+
* (and a best-effort `credential_failure` notification to the issuer).
|
|
366
|
+
*/
|
|
367
|
+
verify?: boolean;
|
|
368
|
+
/** Allow http on loopback hosts (local development only; needs `allowLocal`). */
|
|
369
|
+
allowHttp?: boolean;
|
|
370
|
+
/** Allow loopback / private / local-name hosts (local development only). */
|
|
371
|
+
allowLocal?: boolean;
|
|
372
|
+
/** ms since the epoch (proof `iat`, validity); default `Date.now()`. */
|
|
373
|
+
now?: number;
|
|
374
|
+
timeoutMs?: number;
|
|
375
|
+
}
|
|
376
|
+
/**
|
|
377
|
+
* Redeem a pre-authorized code offer (by value, or fetched from `credentialOfferUri`) for ONE
|
|
378
|
+
* credential configuration (the offer must name exactly one; one that needs a `tx_code` is
|
|
379
|
+
* refused with `tx_code_unsupported`): issuer metadata → OAuth server metadata (token endpoint)
|
|
380
|
+
* → token (anonymous: no `client_id`) → nonce → credential (one retry with a fresh nonce on
|
|
381
|
+
* `invalid_nonce`) → `verifyIssuedCredential` (unless `verify: false`). Returns the checked
|
|
382
|
+
* credential, or the deferred transaction. Throws `Oid4vciError` (`invalid_credential` for a
|
|
383
|
+
* credential that does not check out), `VerificationUnavailable` / `ResolverUnavailable` when a
|
|
384
|
+
* DID document needed for the check cannot be read, and `TypeError` without `resolver` or
|
|
385
|
+
* `expectedIssuer` (unless `verify: false`). Store only what this returns, with
|
|
386
|
+
* `credentialRecordFromSdJwt`.
|
|
387
|
+
*/
|
|
388
|
+
declare function redeemOffer(input: RedeemOfferInput): Promise<IssuedResult | DeferredResult>;
|
|
389
|
+
/**
|
|
390
|
+
* Poll the Deferred Credential Endpoint once (§9). `verification` is the `DeferredResult`'s:
|
|
391
|
+
* an issued credential is checked with `verifyIssuedCredential` and refused with
|
|
392
|
+
* `Oid4vciError('invalid_credential')` when it fails; pass `false` only to opt out explicitly.
|
|
393
|
+
*/
|
|
394
|
+
declare function pollDeferred(input: {
|
|
395
|
+
deferredEndpoint: string;
|
|
396
|
+
accessToken: string;
|
|
397
|
+
transactionId: string;
|
|
398
|
+
verification: Omit<VerifyIssuedCredentialOptions, 'now'> | false;
|
|
399
|
+
fetch: FetchLike;
|
|
400
|
+
timeoutMs?: number;
|
|
401
|
+
/** ms since the epoch (validity); default `Date.now()`. */
|
|
402
|
+
now?: number;
|
|
403
|
+
} & HostPolicy): Promise<{
|
|
404
|
+
status: 'issued';
|
|
405
|
+
credential: string;
|
|
406
|
+
notificationId?: string;
|
|
407
|
+
verified?: VerifiedPresentation;
|
|
408
|
+
} | {
|
|
409
|
+
status: 'deferred';
|
|
410
|
+
transactionId: string;
|
|
411
|
+
interval: number;
|
|
412
|
+
}>;
|
|
413
|
+
/** Tell the issuer what happened to the credential (§11). Throws `Oid4vciError` on refusal. */
|
|
414
|
+
declare function sendNotification(input: {
|
|
415
|
+
notificationEndpoint: string;
|
|
416
|
+
accessToken: string;
|
|
417
|
+
notificationId: string;
|
|
418
|
+
event: NotificationEvent;
|
|
419
|
+
/** ASCII without `"` and `\` (§11.1). */
|
|
420
|
+
eventDescription?: string;
|
|
421
|
+
fetch: FetchLike;
|
|
422
|
+
allowHttp?: boolean;
|
|
423
|
+
allowLocal?: boolean;
|
|
424
|
+
timeoutMs?: number;
|
|
425
|
+
}): Promise<void>;
|
|
426
|
+
|
|
427
|
+
export { Oid4vciError, authorizationServerMetadataUrl, buildAuthorizationServerMetadata, buildCredentialOffer, buildIssuerMetadata, createProofJwt, fetchCredentialOffer, fetchIssuerMetadata, issuerMetadataUrl, pollDeferred, redeemOffer, sendNotification, validateCredentialOffer, verifyProofJwt };
|
|
428
|
+
export type { AuthorizationServerMetadata, BuildIssuerMetadataInput, ClaimDescription, CredentialConfiguration, CredentialIssuerMetadata, CredentialOffer, CredentialRequest, CredentialResponse, DeferredCredentialRequest, DeferredCredentialResponse, DeferredResult, Display, IssuedResult, IssuerConfigurationInput, NonceResponse, NotificationEvent, NotificationRequest, OAuthErrorResponse, Oid4vciErrorCode, PreAuthorizedCodeGrant, RedeemOfferInput, TokenRequest, TokenResponse, TxCode, VerifiedProof, VerifyProofJwtOptions };
|
package/dist/oid4vci.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { Oid4vciError, authorizationServerMetadataUrl, buildAuthorizationServerMetadata, buildCredentialOffer, buildIssuerMetadata, createProofJwt, fetchCredentialOffer, fetchIssuerMetadata, issuerMetadataUrl, pollDeferred, redeemOffer, sendNotification, validateCredentialOffer, verifyProofJwt } from './chunk-FSKCDHZ7.js';
|
|
2
|
+
import './chunk-I6GBYFIJ.js';
|
|
3
|
+
import './chunk-STMMFNVW.js';
|
|
4
|
+
import './chunk-XREZY53L.js';
|
|
5
|
+
import './chunk-JBUX6V2Q.js';
|
|
6
|
+
import './chunk-WIEGZFUO.js';
|
|
7
|
+
import './chunk-Q3MZNMCK.js';
|
|
8
|
+
import './chunk-VXKONZK4.js';
|
|
9
|
+
import './chunk-AQ3IINHC.js';
|
|
10
|
+
//# sourceMappingURL=oid4vci.js.map
|
|
11
|
+
//# sourceMappingURL=oid4vci.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"oid4vci.js"}
|