@digitalbazaar/oid4-client 4.2.0 → 4.4.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.
- package/lib/OID4Client.js +88 -27
- package/lib/authorizationRequest.js +344 -0
- package/lib/authorizationResponse.js +312 -0
- package/lib/convert.js +440 -0
- package/lib/index.js +3 -2
- package/lib/oid4vp.js +20 -836
- package/lib/util.js +50 -1
- package/package.json +8 -9
package/lib/util.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* Copyright (c) 2022-
|
|
2
|
+
* Copyright (c) 2022-2025 Digital Bazaar, Inc. All rights reserved.
|
|
3
3
|
*/
|
|
4
4
|
import * as base64url from 'base64url-universal';
|
|
5
5
|
import {httpClient} from '@digitalbazaar/http-client';
|
|
@@ -21,6 +21,12 @@ export function assertOptional(x, name, type) {
|
|
|
21
21
|
return assert(x, name, type, true);
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
+
export function createNamedError({message, name, cause} = {}) {
|
|
25
|
+
const error = new Error(message, {cause});
|
|
26
|
+
error.name = name;
|
|
27
|
+
return error;
|
|
28
|
+
}
|
|
29
|
+
|
|
24
30
|
export async function discoverIssuer({issuerConfigUrl, agent} = {}) {
|
|
25
31
|
try {
|
|
26
32
|
assert(issuerConfigUrl, 'issuerConfigUrl', 'string');
|
|
@@ -251,6 +257,49 @@ export async function robustDiscoverIssuer({issuer, agent} = {}) {
|
|
|
251
257
|
throw error;
|
|
252
258
|
}
|
|
253
259
|
|
|
260
|
+
export function selectJwk({keys, kid, alg, kty, crv, use} = {}) {
|
|
261
|
+
/* Example JWKs "keys":
|
|
262
|
+
"jwks": {
|
|
263
|
+
"keys": [
|
|
264
|
+
{
|
|
265
|
+
"kty": "EC",
|
|
266
|
+
"use": "enc",
|
|
267
|
+
"crv": "P-256",
|
|
268
|
+
"x": "...",
|
|
269
|
+
"y": "...",
|
|
270
|
+
"alg": "ECDH-ES",
|
|
271
|
+
"kid": "..."
|
|
272
|
+
}
|
|
273
|
+
]
|
|
274
|
+
} */
|
|
275
|
+
if(!Array.isArray(keys)) {
|
|
276
|
+
return;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
// match `kid` exactly if given
|
|
280
|
+
if(kid !== undefined) {
|
|
281
|
+
return keys.find(jwk => jwk?.kid === kid);
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
return keys.find(jwk => {
|
|
285
|
+
// default unspecified search values to whatever is in `jwk`
|
|
286
|
+
const alg1 = alg ?? jwk.alg;
|
|
287
|
+
const kty1 = kty ?? jwk.kty;
|
|
288
|
+
const crv1 = crv ?? jwk.crv;
|
|
289
|
+
const use1 = use ?? jwk.use;
|
|
290
|
+
const {
|
|
291
|
+
// default missing `alg` value in `jwk` to search value
|
|
292
|
+
alg: alg2 = alg1,
|
|
293
|
+
kty: kty2,
|
|
294
|
+
crv: crv2,
|
|
295
|
+
// default missing `use` value in `jwk` to search value
|
|
296
|
+
use: use2 = use1
|
|
297
|
+
} = jwk;
|
|
298
|
+
// return if `jwk` matches computed values
|
|
299
|
+
return alg1 === alg2 && kty1 === kty2 && crv1 === crv2 && use1 === use2;
|
|
300
|
+
});
|
|
301
|
+
}
|
|
302
|
+
|
|
254
303
|
export async function signJWT({payload, protectedHeader, signer} = {}) {
|
|
255
304
|
// encode payload and protected header
|
|
256
305
|
const b64Payload = base64url.encode(JSON.stringify(payload));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@digitalbazaar/oid4-client",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.4.0",
|
|
4
4
|
"description": "An OID4 (VC + VP) client",
|
|
5
5
|
"homepage": "https://github.com/digitalbazaar/oid4-client",
|
|
6
6
|
"author": {
|
|
@@ -25,15 +25,14 @@
|
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@digitalbazaar/http-client": "^4.0.0",
|
|
27
27
|
"base64url-universal": "^2.0.0",
|
|
28
|
-
"jose": "^
|
|
29
|
-
"jsonpath-plus": "^10.
|
|
30
|
-
"jsonpointer": "^5.0.1"
|
|
31
|
-
"uuid": "^10.0.0"
|
|
28
|
+
"jose": "^6.0.13",
|
|
29
|
+
"jsonpath-plus": "^10.3.0",
|
|
30
|
+
"jsonpointer": "^5.0.1"
|
|
32
31
|
},
|
|
33
32
|
"devDependencies": {
|
|
34
|
-
"c8": "^
|
|
33
|
+
"c8": "^10.1.3",
|
|
35
34
|
"chai": "^4.3.6",
|
|
36
|
-
"cross-env": "^
|
|
35
|
+
"cross-env": "^10.0.0",
|
|
37
36
|
"eslint": "^8.41.0",
|
|
38
37
|
"eslint-config-digitalbazaar": "^5.0.1",
|
|
39
38
|
"eslint-plugin-jsdoc": "^50.4.1",
|
|
@@ -49,7 +48,7 @@
|
|
|
49
48
|
"karma-webpack": "^5.0.0",
|
|
50
49
|
"mocha": "^10.0.0",
|
|
51
50
|
"mocha-lcov-reporter": "^1.3.0",
|
|
52
|
-
"webpack": "^5.
|
|
51
|
+
"webpack": "^5.101.3"
|
|
53
52
|
},
|
|
54
53
|
"c8": {
|
|
55
54
|
"reporter": [
|
|
@@ -59,7 +58,7 @@
|
|
|
59
58
|
]
|
|
60
59
|
},
|
|
61
60
|
"engines": {
|
|
62
|
-
"node": ">=
|
|
61
|
+
"node": ">=20"
|
|
63
62
|
},
|
|
64
63
|
"keywords": [
|
|
65
64
|
"OID4",
|