@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.
- package/LICENSE +2 -2
- package/README.md +31 -98
- package/dist/index.cjs +575 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +909 -0
- package/dist/index.d.mts +820 -814
- package/dist/index.mjs +527 -725
- package/dist/index.mjs.map +1 -0
- package/package.json +33 -54
- package/CHANGELOG.md +0 -39
- package/dist/index.d.ts +0 -903
- package/dist/index.js +0 -773
- package/src/index.ts +0 -7
- package/src/sd-jwt-vc-config.ts +0 -25
- package/src/sd-jwt-vc-instance.ts +0 -679
- package/src/sd-jwt-vc-payload.ts +0 -23
- package/src/sd-jwt-vc-status-reference.ts +0 -9
- package/src/sd-jwt-vc-type-metadata-format.ts +0 -271
- package/src/sd-jwt-vc-vct.ts +0 -6
- package/src/test/index.spec.ts +0 -180
- package/src/test/vct.spec.ts +0 -699
- package/src/verification-result.ts +0 -16
- package/test/app-e2e.spec.ts +0 -286
- package/test/array_data_types.json +0 -31
- package/test/array_full_sd.json +0 -21
- package/test/array_in_sd.json +0 -13
- package/test/array_nested_in_plain.json +0 -29
- package/test/array_none_disclosed.json +0 -17
- package/test/array_of_nulls.json +0 -15
- package/test/array_of_objects.json +0 -65
- package/test/array_of_scalars.json +0 -19
- package/test/array_recursive_sd.json +0 -35
- package/test/array_recursive_sd_some_disclosed.json +0 -63
- package/test/complex.json +0 -43
- package/test/header_mod.json +0 -48
- package/test/json_serialization.json +0 -48
- package/test/key_binding.json +0 -48
- package/test/no_sd.json +0 -36
- package/test/object_data_types.json +0 -62
- package/test/recursions.json +0 -117
- package/test/tsconfig.json +0 -4
- package/tsconfig.json +0 -7
- package/vitest.config.mts +0 -4
package/LICENSE
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
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
|
-
|
|
2
|
-

|
|
3
|
-

|
|
4
|
-

|
|
1
|
+
# @sd-jwt/sd-jwt-vc
|
|
5
2
|
|
|
6
|
-
|
|
3
|
+
[](https://npmjs.com/package/@sd-jwt/sd-jwt-vc)
|
|
4
|
+
[](https://github.com/openwallet-foundation-labs/identity-common-ts/blob/main/LICENSE)
|
|
7
5
|
|
|
8
|
-
|
|
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
|
-
|
|
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
|
-
#
|
|
11
|
+
# Using npm
|
|
22
12
|
npm install @sd-jwt/sd-jwt-vc
|
|
23
13
|
|
|
24
|
-
#
|
|
25
|
-
|
|
14
|
+
# Using pnpm
|
|
15
|
+
pnpm add @sd-jwt/sd-jwt-vc
|
|
26
16
|
|
|
27
|
-
#
|
|
28
|
-
|
|
17
|
+
# Using yarn
|
|
18
|
+
yarn add @sd-jwt/sd-jwt-vc
|
|
29
19
|
```
|
|
30
20
|
|
|
31
|
-
|
|
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
|
-
|
|
72
|
+
## Examples
|
|
85
73
|
|
|
86
|
-
|
|
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
|
-
|
|
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
|
-
|
|
80
|
+
See the [SD-JWT examples overview](../../examples/sd-jwt/README.md) for the full list.
|
|
109
81
|
|
|
110
|
-
|
|
82
|
+
## Dependencies
|
|
111
83
|
|
|
112
|
-
|
|
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
|
-
|
|
88
|
+
## Platform Support
|
|
115
89
|
|
|
116
|
-
|
|
90
|
+
This library is **platform agnostic** and works in:
|
|
117
91
|
|
|
118
|
-
|
|
92
|
+
- ✅ Node.js (>=20)
|
|
93
|
+
- ✅ Browsers (modern browsers with ES2020 support)
|
|
94
|
+
- ✅ React Native
|
|
119
95
|
|
|
120
|
-
|
|
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
|
-
|
|
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
|
-
|
|
100
|
+
## Contributing
|
|
132
101
|
|
|
133
|
-
|
|
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
|
-
|
|
104
|
+
## License
|
|
160
105
|
|
|
161
|
-
|
|
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).
|