@learncard/credential-library 1.0.17 → 2.0.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.
Files changed (37) hide show
  1. package/README.md +58 -3
  2. package/dist/__tests__/sd-jwt-vc.test.d.ts +2 -0
  3. package/dist/__tests__/sd-jwt-vc.test.d.ts.map +1 -0
  4. package/dist/credential-library.cjs.development.js +8951 -272
  5. package/dist/credential-library.cjs.development.js.map +3 -3
  6. package/dist/credential-library.cjs.production.min.js +1 -1
  7. package/dist/credential-library.cjs.production.min.js.map +4 -4
  8. package/dist/credential-library.esm.js +8951 -272
  9. package/dist/credential-library.esm.js.map +3 -3
  10. package/dist/fixtures/clr/demo-isd-diploma-assessments.d.ts +3 -0
  11. package/dist/fixtures/clr/demo-isd-diploma-assessments.d.ts.map +1 -0
  12. package/dist/fixtures/index.d.ts +5 -3
  13. package/dist/fixtures/index.d.ts.map +1 -1
  14. package/dist/fixtures/sd-jwt-vc/course-completion.d.ts +3 -0
  15. package/dist/fixtures/sd-jwt-vc/course-completion.d.ts.map +1 -0
  16. package/dist/index.d.ts +4 -2
  17. package/dist/index.d.ts.map +1 -1
  18. package/dist/materialize-sd-jwt-vc.d.ts +21 -0
  19. package/dist/materialize-sd-jwt-vc.d.ts.map +1 -0
  20. package/dist/prepare.d.ts +2 -2
  21. package/dist/prepare.d.ts.map +1 -1
  22. package/dist/registry.d.ts +11 -9
  23. package/dist/registry.d.ts.map +1 -1
  24. package/dist/types.d.ts +31 -5
  25. package/dist/types.d.ts.map +1 -1
  26. package/package.json +7 -4
  27. package/src/__tests__/issuance.test.ts +5 -2
  28. package/src/__tests__/registry.test.ts +195 -7
  29. package/src/__tests__/sd-jwt-vc.test.ts +220 -0
  30. package/src/fixtures/clr/demo-isd-diploma-assessments.ts +9183 -0
  31. package/src/fixtures/index.ts +12 -2
  32. package/src/fixtures/sd-jwt-vc/course-completion.ts +27 -0
  33. package/src/index.ts +17 -0
  34. package/src/materialize-sd-jwt-vc.ts +159 -0
  35. package/src/prepare.ts +9 -2
  36. package/src/registry.ts +88 -27
  37. package/src/types.ts +51 -10
package/README.md CHANGED
@@ -91,6 +91,45 @@ const signed = await wallet.invoke.issueCredential(unsigned);
91
91
  - **Fresh UUIDs** — regenerates all `urn:uuid:` ids (disable with `freshIds: false`)
92
92
  - **Timestamps** — sets `validFrom`/`issuanceDate` to now (or a custom value)
93
93
 
94
+ ### Materializing an SD-JWT VC Fixture
95
+
96
+ SD-JWT VC fixtures are synthetic templates. Query and narrow them through the
97
+ same registry API, then materialize one with signing capability supplied by the
98
+ caller:
99
+
100
+ ```typescript
101
+ import {
102
+ getFixtures,
103
+ getFixture,
104
+ isSdJwtVcFixture,
105
+ materializeSdJwtVcFixture,
106
+ } from '@learncard/credential-library';
107
+
108
+ const sdJwtCourses = getFixtures({
109
+ kind: 'sd-jwt-vc',
110
+ profile: 'course',
111
+ features: ['selective-disclosure'],
112
+ });
113
+ const fixture = getFixture('sd-jwt-vc/course-completion');
114
+ if (!isSdJwtVcFixture(fixture)) throw new Error('Expected SD-JWT VC fixture');
115
+
116
+ const result = await materializeSdJwtVcFixture(fixture, {
117
+ issuerDid,
118
+ issuerKid,
119
+ issuerSigner,
120
+ holderPublicJwk,
121
+ });
122
+
123
+ await wallet.store.LearnCloud.uploadEncrypted(result.envelope);
124
+ ```
125
+
126
+ The fixture contains no issuer private key and does not sign itself. Callers
127
+ must provide the issuer DID, key ID, signing function, and an Ed25519 public
128
+ holder key. The returned envelope is canonical `{ format: 'dc+sd-jwt', data:
129
+ compact }`; `result.compact` contains the issuer-signed SD-JWT VC only and never
130
+ stores a KB-JWT. A KB-JWT is created later, when a holder presents the
131
+ credential to a verifier with an audience and nonce.
132
+
94
133
  ## Query API Reference
95
134
 
96
135
  | Function | Description |
@@ -101,8 +140,8 @@ const signed = await wallet.invoke.issueCredential(unsigned);
101
140
  | `getFixtures(filter)` | Returns fixtures matching the filter |
102
141
  | `getValidFixtures(filter?)` | Shorthand for `getFixtures({ ...filter, validity: 'valid' })` |
103
142
  | `getInvalidFixtures(filter?)` | Shorthand for `getFixtures({ ...filter, validity: ['invalid', 'tampered'] })` |
104
- | `getUnsignedFixtures(filter?)` | Returns only unsigned fixtures |
105
- | `getSignedFixtures(filter?)` | Returns only signed fixtures |
143
+ | `getUnsignedFixtures(filter?)` | Returns only unsigned W3C VC fixtures |
144
+ | `getSignedFixtures(filter?)` | Returns only signed W3C VC fixtures |
106
145
  | `getStats()` | Returns counts grouped by spec, profile, validity, and signed status |
107
146
  | `prepareFixture(fixture, options)` | Clones a fixture and patches DIDs, UUIDs, and timestamps |
108
147
  | `prepareFixtureById(id, options)` | Combines `getFixture` + `prepareFixture` |
@@ -113,6 +152,7 @@ All filter fields are optional. Array fields accept a single value or an array.
113
152
 
114
153
  | Field | Type | Behavior |
115
154
  | ------------- | ------------------------------------------ | ----------------------------------- |
155
+ | `kind` | `FixtureKind \| FixtureKind[]` | Match `w3c-vc` or `sd-jwt-vc` |
116
156
  | `spec` | `CredentialSpec \| CredentialSpec[]` | Match any of the given specs |
117
157
  | `profile` | `CredentialProfile \| CredentialProfile[]` | Match any of the given profiles |
118
158
  | `features` | `CredentialFeature[]` | Must have **all** of these features |
@@ -164,16 +204,26 @@ The `examples/credential-viewer` app has a **New Fixture** button that provides
164
204
  - Test Issue button (requires wallet connection)
165
205
  - Saves the `.ts` file and updates the index automatically
166
206
 
207
+ The form creates W3C VC fixtures only. Add SD-JWT VC template fixtures manually so
208
+ their `kind`, reserved ID/spec pairing, and materialization template remain explicit.
209
+
167
210
  See the [Credential Viewer README](../../examples/credential-viewer/README.md) for details.
168
211
 
169
212
  ## Fixture Metadata
170
213
 
214
+ `kind` identifies the fixture's runtime shape: W3C VC fixtures use
215
+ `kind: 'w3c-vc'` (or omit it for backwards compatibility) and contain a
216
+ `credential` object, while `kind: 'sd-jwt-vc'` fixtures contain a materializable
217
+ `template`. SD-JWT VC templates also use `spec: 'sd-jwt-vc'` and reserve the
218
+ `sd-jwt-vc/` ID prefix.
219
+
171
220
  | Field | Type | Description |
172
221
  | ------------- | --------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
173
222
  | `id` | `string` | Unique identifier, e.g. `obv3/minimal-badge` |
223
+ | `kind` | `FixtureKind?` | Runtime shape: `w3c-vc` (default when omitted) or `sd-jwt-vc` |
174
224
  | `name` | `string` | Human-readable name |
175
225
  | `description` | `string` | What this fixture tests/demonstrates |
176
- | `spec` | `CredentialSpec` | `vc-v1`, `vc-v2`, `obv3`, `clr-v2`, `europass`, `custom` |
226
+ | `spec` | `CredentialSpec` | `vc-v1`, `vc-v2`, `obv3`, `clr-v2`, `europass`, `sd-jwt-vc`, `custom` |
177
227
  | `profile` | `CredentialProfile` | `badge`, `diploma`, `certificate`, `id`, `membership`, `license`, `micro-credential`, `course`, `degree`, `boost`, `boost-id`, `delegate`, `endorsement`, `learner-record`, `generic` |
178
228
  | `features` | `CredentialFeature[]` | Features exercised: `evidence`, `alignment`, `endorsement`, `expiration`, `status`, `multiple-subjects`, `image`, `results`, `skills`, `display`, `associations`, `nested-credentials`, etc. |
179
229
  | `source` | `FixtureSource` | `spec-example`, `plugfest`, `real-world`, `synthetic` |
@@ -230,6 +280,11 @@ See the [Credential Viewer README](../../examples/credential-viewer/README.md) f
230
280
  - `boost/community-award` — Community leadership award boost
231
281
  - `boost/delegate` — Organization delegate credential
232
282
 
283
+ ### SD-JWT VCs (1)
284
+
285
+ - `sd-jwt-vc/course-completion` — Synthetic, holder-bound course completion
286
+ credential with selective disclosure and Digital Credentials API metadata
287
+
233
288
  ### Invalid / Negative Tests (3)
234
289
 
235
290
  - `invalid/missing-context` — No @context
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=sd-jwt-vc.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sd-jwt-vc.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/sd-jwt-vc.test.ts"],"names":[],"mappings":""}