@sd-jwt/sd-jwt-vc 0.20.1 → 0.21.0-alpha-20260916100413

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 (43) hide show
  1. package/LICENSE +2 -2
  2. package/README.md +31 -98
  3. package/dist/index.cjs +575 -0
  4. package/dist/index.cjs.map +1 -0
  5. package/dist/index.d.cts +909 -0
  6. package/dist/index.d.mts +820 -814
  7. package/dist/index.mjs +527 -725
  8. package/dist/index.mjs.map +1 -0
  9. package/package.json +33 -54
  10. package/CHANGELOG.md +0 -39
  11. package/dist/index.d.ts +0 -903
  12. package/dist/index.js +0 -773
  13. package/src/index.ts +0 -7
  14. package/src/sd-jwt-vc-config.ts +0 -25
  15. package/src/sd-jwt-vc-instance.ts +0 -679
  16. package/src/sd-jwt-vc-payload.ts +0 -23
  17. package/src/sd-jwt-vc-status-reference.ts +0 -9
  18. package/src/sd-jwt-vc-type-metadata-format.ts +0 -271
  19. package/src/sd-jwt-vc-vct.ts +0 -6
  20. package/src/test/index.spec.ts +0 -180
  21. package/src/test/vct.spec.ts +0 -699
  22. package/src/verification-result.ts +0 -16
  23. package/test/app-e2e.spec.ts +0 -286
  24. package/test/array_data_types.json +0 -31
  25. package/test/array_full_sd.json +0 -21
  26. package/test/array_in_sd.json +0 -13
  27. package/test/array_nested_in_plain.json +0 -29
  28. package/test/array_none_disclosed.json +0 -17
  29. package/test/array_of_nulls.json +0 -15
  30. package/test/array_of_objects.json +0 -65
  31. package/test/array_of_scalars.json +0 -19
  32. package/test/array_recursive_sd.json +0 -35
  33. package/test/array_recursive_sd_some_disclosed.json +0 -63
  34. package/test/complex.json +0 -43
  35. package/test/header_mod.json +0 -48
  36. package/test/json_serialization.json +0 -48
  37. package/test/key_binding.json +0 -48
  38. package/test/no_sd.json +0 -36
  39. package/test/object_data_types.json +0 -62
  40. package/test/recursions.json +0 -117
  41. package/test/tsconfig.json +0 -4
  42. package/tsconfig.json +0 -7
  43. package/vitest.config.mts +0 -4
package/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Apache License
1
+ Apache License
2
2
  Version 2.0, January 2004
3
3
  http://www.apache.org/licenses/
4
4
 
@@ -198,4 +198,4 @@
198
198
  distributed under the License is distributed on an "AS IS" BASIS,
199
199
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
200
  See the License for the specific language governing permissions and
201
- limitations under the License.
201
+ limitations under the License.
package/README.md CHANGED
@@ -1,36 +1,24 @@
1
- ![License](https://img.shields.io/github/license/openwallet-foundation/sd-jwt-js.svg)
2
- ![NPM](https://img.shields.io/npm/v/%40sd-jwt%2Fsd-jwt-vc)
3
- ![Release](https://img.shields.io/github/v/release/openwallet-foundation/sd-jwt-js)
4
- ![Stars](https://img.shields.io/github/stars/openwallet-foundation/sd-jwt-js)
1
+ # @sd-jwt/sd-jwt-vc
5
2
 
6
- # SD-JWT Implementation in JavaScript (TypeScript)
3
+ [![npm version](https://img.shields.io/npm/v/@sd-jwt/sd-jwt-vc)](https://npmjs.com/package/@sd-jwt/sd-jwt-vc)
4
+ [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://github.com/openwallet-foundation-labs/identity-common-ts/blob/main/LICENSE)
7
5
 
8
- ## SD-JWT-VC
6
+ Implementation of [SD-JWT-based Verifiable Credentials (SD-JWT VC) — draft-ietf-oauth-sd-jwt-vc-15](https://www.ietf.org/archive/id/draft-ietf-oauth-sd-jwt-vc-15.html), built on top of [`@sd-jwt/core`](../sd-jwt-core) ([RFC 9901](https://www.rfc-editor.org/rfc/rfc9901.html)).
9
7
 
10
- ### About
11
-
12
- Implementation of [SD-JWT-based Verifiable Credentials (SD-JWT VC) — draft-ietf-oauth-sd-jwt-vc-15](https://www.ietf.org/archive/id/draft-ietf-oauth-sd-jwt-vc-15.html), built on top of `@sd-jwt/core` ([RFC 9901](https://www.rfc-editor.org/rfc/rfc9901.html)).
13
-
14
- Check the detail description in our github [repo](https://github.com/openwallet-foundation/sd-jwt-js).
15
-
16
- ### Installation
17
-
18
- To install this project, run the following command:
8
+ ## Installation
19
9
 
20
10
  ```bash
21
- # using npm
11
+ # Using npm
22
12
  npm install @sd-jwt/sd-jwt-vc
23
13
 
24
- # using yarn
25
- yarn add @sd-jwt/sd-jwt-vc
14
+ # Using pnpm
15
+ pnpm add @sd-jwt/sd-jwt-vc
26
16
 
27
- # using pnpm
28
- pnpm install @sd-jwt/sd-jwt-vc
17
+ # Using yarn
18
+ yarn add @sd-jwt/sd-jwt-vc
29
19
  ```
30
20
 
31
- Ensure you have Node.js installed as a prerequisite.
32
-
33
- ### Usage
21
+ ## Usage
34
22
 
35
23
  Here's a basic example of how to use this library:
36
24
 
@@ -81,93 +69,38 @@ const presentation = await sdjwt.present(credential, presentationFrame);
81
69
  const verified = await sdjwt.verify(presentation);
82
70
  ```
83
71
 
84
- Check out more details in our [documentation](https://github.com/openwallet-foundation/sd-jwt-js/tree/main/docs) or [examples](https://github.com/openwallet-foundation/sd-jwt-js/tree/main/examples)
72
+ ## Examples
85
73
 
86
- ### Revocation
74
+ Runnable examples are available in [`examples/sd-jwt/sd-jwt-vc`](../../examples/sd-jwt/sd-jwt-vc). Run them from the repository root:
87
75
 
88
- To add revocation capabilities, you can use the `@owf/token-status-list` library to create a JWT Status List and include it in the SD-JWT-VC.
89
-
90
- You can pass a dedicated `statusVerifier` function in the configuration to verify the signature of the payload of the JWT of the statuslist. If no function is provided, it will fallback to the verifier that is also used for the sd-jwt-vc.
91
-
92
- ### Type Metadata
93
-
94
- By setting the `loadTypeMetadataFormat` to `true` like this:
95
-
96
- ```typescript
97
- const sdjwt = new SDJwtVcInstance({
98
- signer,
99
- signAlg: 'EdDSA',
100
- verifier,
101
- hasher: digest,
102
- hashAlg: 'sha-256',
103
- saltGenerator: generateSalt,
104
- loadTypeMetadataFormat: true,
105
- });
76
+ ```bash
77
+ pnpm tsx examples/sd-jwt/sd-jwt-vc/basic.ts
106
78
  ```
107
79
 
108
- The library will load the type metadata format based on the `vct` value according to the [SD-JWT-VC specification](https://www.ietf.org/archive/id/draft-ietf-oauth-sd-jwt-vc-15.html#name-sd-jwt-vc-type-metadata) and validate this schema.
80
+ See the [SD-JWT examples overview](../../examples/sd-jwt/README.md) for the full list.
109
81
 
110
- Since at this point the display is not yet implemented, the library will only validate the schema and return the type metadata format. In the future the values of the type metadata can be fetched via a function call.
82
+ ## Dependencies
111
83
 
112
- ### Verification
84
+ - [@sd-jwt/core](https://www.npmjs.com/package/@sd-jwt/core)
85
+ - [@owf/token-status-list](https://www.npmjs.com/package/@owf/token-status-list)
86
+ - [zod](https://www.npmjs.com/package/zod)
113
87
 
114
- The library provides two verification approaches:
88
+ ## Platform Support
115
89
 
116
- #### Standard Verification (Fail-Fast)
90
+ This library is **platform agnostic** and works in:
117
91
 
118
- The `verify()` method throws an error immediately when the first validation failure is encountered:
92
+ - ✅ Node.js (>=20)
93
+ - ✅ Browsers (modern browsers with ES2020 support)
94
+ - ✅ React Native
119
95
 
120
- ```typescript
121
- try {
122
- const result = await sdjwt.verify(presentation);
123
- console.log('Verified payload:', result.payload);
124
- } catch (error) {
125
- console.error('Verification failed:', error.message);
126
- }
127
- ```
96
+ A global `TextEncoder` and `TextDecoder` must be available. See the [React Native notes](../identity-common/README.md#react-native) if you need a polyfill.
128
97
 
129
- #### Safe Verification (Collect All Errors)
98
+ Cryptographic operations (signing, verification, hashing, salt generation) are provided as callbacks. [`@owf/crypto`](https://github.com/openwallet-foundation-labs/identity-common-ts/tree/main/packages/crypto) provides Web Crypto based implementations.
130
99
 
131
- The `safeVerify()` method collects all validation errors instead of failing on the first one. This is useful when you want to show users all issues with a credential at once, including signature, status (revocation), and VCT metadata validation:
100
+ ## Contributing
132
101
 
133
- ```typescript
134
- import type { SafeVerifyResult, VerificationError } from '@sd-jwt/core';
135
-
136
- const result = await sdjwt.safeVerify(presentation);
137
-
138
- if (result.success) {
139
- // Verification succeeded
140
- console.log('Verified payload:', result.payload);
141
- console.log('Header:', result.header);
142
- if (result.kb) {
143
- console.log('Key binding:', result.kb);
144
- }
145
- if (result.typeMetadata) {
146
- console.log('Type metadata:', result.typeMetadata);
147
- }
148
- } else {
149
- // Verification failed - inspect all errors
150
- for (const error of result.errors) {
151
- console.error(`[${error.code}] ${error.message}`);
152
- if (error.details) {
153
- console.error('Details:', error.details);
154
- }
155
- }
156
- }
157
- ```
102
+ See the [Contributing Guide](https://github.com/openwallet-foundation-labs/identity-common-ts/blob/main/CONTRIBUTING.md) for details on how to contribute to this project.
158
103
 
159
- ##### SD-JWT-VC Specific Error Codes
104
+ ## License
160
105
 
161
- In addition to the [core error codes](../core/README.md#error-codes), `safeVerify()` in SD-JWT-VC can return:
162
-
163
- | Code | Description |
164
- |------|-------------|
165
- | `STATUS_VERIFICATION_FAILED` | Status list fetch or verification failed |
166
- | `STATUS_INVALID` | Credential status indicates revocation |
167
- | `VCT_VERIFICATION_FAILED` | VCT type metadata fetch or validation failed |
168
-
169
- ### Dependencies
170
-
171
- - [@sd-jwt/core](https://www.npmjs.com/package/@sd-jwt/core)
172
- - [@owf/token-status-list](https://www.npmjs.com/package/@owf/token-status-list)
173
- - [zod](https://www.npmjs.com/package/zod)
106
+ This project is licensed under the [Apache License Version 2.0](https://github.com/openwallet-foundation-labs/identity-common-ts/blob/main/LICENSE) (Apache-2.0).