@vidos-id/openid4vc-issuer 0.0.0-test1
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 +148 -0
- package/dist/index.d.mts +593 -0
- package/dist/index.mjs +670 -0
- package/package.json +46 -0
package/README.md
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
# @vidos-id/openid4vc-issuer
|
|
2
|
+
|
|
3
|
+
Minimal demo issuer library for holder-bound `dc+sd-jwt` credentials.
|
|
4
|
+
|
|
5
|
+
For the CLI wrapper, see [`@vidos-id/openid4vc-issuer-cli`](../issuer-cli/). For the installed CLI flow, see the [root README](../../). For development, the CLI bin can be run with `bun packages/issuer-cli/src/index.ts`.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
Configure GitHub Packages in the consuming repo:
|
|
10
|
+
|
|
11
|
+
```ini
|
|
12
|
+
@vidos-id:registry=https://npm.pkg.github.com
|
|
13
|
+
//npm.pkg.github.com/:_authToken=${GITHUB_PACKAGES_TOKEN}
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Install with your preferred package manager:
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
# bun
|
|
20
|
+
bun add @vidos-id/openid4vc-issuer
|
|
21
|
+
|
|
22
|
+
# npm
|
|
23
|
+
npm install @vidos-id/openid4vc-issuer
|
|
24
|
+
|
|
25
|
+
# pnpm
|
|
26
|
+
pnpm add @vidos-id/openid4vc-issuer
|
|
27
|
+
|
|
28
|
+
# yarn
|
|
29
|
+
yarn add @vidos-id/openid4vc-issuer
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
This package is currently published as raw TypeScript and is intended for Bun-based consumers.
|
|
33
|
+
|
|
34
|
+
## Features
|
|
35
|
+
|
|
36
|
+
- issuer metadata + JWKS output
|
|
37
|
+
- pre-authorized grant + credential offer creation
|
|
38
|
+
- `openid-credential-offer://` serialization helpers for both `credential_offer` and `credential_offer_uri`
|
|
39
|
+
- token exchange + nonce issuance
|
|
40
|
+
- proof JWT validation with `typ=openid4vci-proof+jwt`
|
|
41
|
+
- claim-set driven issuance
|
|
42
|
+
- token status list creation, signing, and status updates
|
|
43
|
+
- issuer key and certificate generation for demo trust bootstrapping
|
|
44
|
+
- multi-algorithm support: ES256, ES384, EdDSA
|
|
45
|
+
|
|
46
|
+
## Specs
|
|
47
|
+
|
|
48
|
+
- SD-JWT VC: https://datatracker.ietf.org/doc/html/draft-ietf-oauth-sd-jwt-vc-15
|
|
49
|
+
- OpenID4VP: https://openid.net/specs/openid-4-verifiable-presentations-1_0.html
|
|
50
|
+
- OpenID4VCI: https://openid.net/specs/openid-4-verifiable-credential-issuance-1_0.html
|
|
51
|
+
|
|
52
|
+
This package implements a deliberately small internal/demo subset of those specs.
|
|
53
|
+
|
|
54
|
+
Supported OID4VCI subset:
|
|
55
|
+
|
|
56
|
+
- by-value credential offers and by-reference `credential_offer_uri`
|
|
57
|
+
- pre-authorized-code flow only
|
|
58
|
+
- single `dc+sd-jwt` issuance only
|
|
59
|
+
- storage-agnostic request/response helpers for embedding in your own server
|
|
60
|
+
|
|
61
|
+
Out of scope:
|
|
62
|
+
|
|
63
|
+
- authorization-code flow
|
|
64
|
+
- DPoP
|
|
65
|
+
- wallet attestation / key attestation
|
|
66
|
+
- `tx_code`, deferred issuance, encrypted responses, batch issuance
|
|
67
|
+
|
|
68
|
+
## Example
|
|
69
|
+
|
|
70
|
+
```ts
|
|
71
|
+
import { createIssuer, generateIssuerTrustMaterial } from "@vidos-id/openid4vc-issuer";
|
|
72
|
+
|
|
73
|
+
const trust = await generateIssuerTrustMaterial({ alg: "ES256" });
|
|
74
|
+
|
|
75
|
+
const issuer = createIssuer({
|
|
76
|
+
issuer: "https://issuer.example",
|
|
77
|
+
signingKey: {
|
|
78
|
+
alg: trust.alg,
|
|
79
|
+
privateJwk: trust.privateJwk,
|
|
80
|
+
publicJwk: trust.publicJwk,
|
|
81
|
+
},
|
|
82
|
+
credentialConfigurationsSupported: {
|
|
83
|
+
person: {
|
|
84
|
+
format: "dc+sd-jwt",
|
|
85
|
+
vct: "https://example.com/PersonCredential",
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
const offer = issuer.createCredentialOffer({
|
|
91
|
+
credential_configuration_id: "person",
|
|
92
|
+
claims: { given_name: "Ada", family_name: "Lovelace" },
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
const offerUri = issuer.createCredentialOfferUri({
|
|
96
|
+
credential_configuration_id: "person",
|
|
97
|
+
claims: { given_name: "Ada", family_name: "Lovelace" },
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
const offerReferenceUri = issuer.createCredentialOfferReferenceUri(
|
|
101
|
+
"https://issuer.example/offers/person-1"
|
|
102
|
+
);
|
|
103
|
+
|
|
104
|
+
const statusList = issuer.createStatusList({
|
|
105
|
+
uri: "https://issuer.example/status-lists/1",
|
|
106
|
+
bits: 2,
|
|
107
|
+
ttl: 300,
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
const allocatedStatus = issuer.allocateCredentialStatus({ statusList });
|
|
111
|
+
|
|
112
|
+
await db.saveGrant(offer.preAuthorizedGrant.preAuthorizedCode, offer.preAuthorizedGrant);
|
|
113
|
+
|
|
114
|
+
const token = issuer.exchangePreAuthorizedCode({
|
|
115
|
+
tokenRequest: {
|
|
116
|
+
grant_type: "urn:ietf:params:oauth:grant-type:pre-authorized_code",
|
|
117
|
+
"pre-authorized_code": offer.preAuthorizedGrant.preAuthorizedCode,
|
|
118
|
+
},
|
|
119
|
+
preAuthorizedGrant: await db.readGrant(offer.preAuthorizedGrant.preAuthorizedCode),
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
await db.saveAccessToken(token.accessTokenRecord.accessToken, token.accessTokenRecord);
|
|
123
|
+
|
|
124
|
+
const issued = await issuer.issueCredential({
|
|
125
|
+
accessToken: await db.readAccessToken(token.accessTokenRecord.accessToken),
|
|
126
|
+
credential_configuration_id: "person",
|
|
127
|
+
status: allocatedStatus.credentialStatus,
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
const statusListJwt = await issuer.createStatusListToken(allocatedStatus.updatedStatusList);
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
For holder binding, the wallet provides its public JWK via a proof JWT -- see the [`@vidos-id/openid4vc-wallet`](../wallet/) library and [`scripts/demo-e2e.ts`](../../scripts/demo-e2e.ts) for the full flow.
|
|
134
|
+
|
|
135
|
+
Host applications own HTTP routing and persistence. The issuer helpers return updated grant, access-token, and nonce records so your server can store them however it wants.
|
|
136
|
+
|
|
137
|
+
Credential offer delivery options:
|
|
138
|
+
|
|
139
|
+
- `issuer.createCredentialOffer(...)` returns the offer JSON document that you can embed directly or serve from your own endpoint
|
|
140
|
+
- `issuer.createCredentialOfferUri(...)` wraps that JSON by value in `openid-credential-offer://?credential_offer=...`
|
|
141
|
+
- `issuer.createCredentialOfferReferenceUri("https://issuer.example/offers/person-1")` creates `openid-credential-offer://?credential_offer_uri=...`
|
|
142
|
+
- when using `credential_offer_uri`, your application is responsible for hosting the offer JSON at that URL
|
|
143
|
+
|
|
144
|
+
## Test
|
|
145
|
+
|
|
146
|
+
```bash
|
|
147
|
+
bun test packages/issuer/src/issuer.test.ts
|
|
148
|
+
```
|