@sphereon/oid4vc-common 0.17.1-feature.esm.cjs.26 → 0.17.1-feature.esm.cjs.31
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/dist/index.cjs +9 -29
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +7 -17
- package/dist/index.js.map +1 -1
- package/package.json +8 -10
package/dist/index.cjs
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
2
|
var __defProp = Object.defineProperty;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
6
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
9
7
|
var __export = (target, all) => {
|
|
@@ -18,14 +16,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
16
|
}
|
|
19
17
|
return to;
|
|
20
18
|
};
|
|
21
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
-
mod
|
|
28
|
-
));
|
|
29
19
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
20
|
|
|
31
21
|
// lib/index.ts
|
|
@@ -59,7 +49,7 @@ __export(index_exports, {
|
|
|
59
49
|
verifyResourceDPoP: () => verifyResourceDPoP
|
|
60
50
|
});
|
|
61
51
|
module.exports = __toCommonJS(index_exports);
|
|
62
|
-
var
|
|
52
|
+
var import_ssi_types2 = require("@sphereon/ssi-types");
|
|
63
53
|
|
|
64
54
|
// lib/jwt/Jwt.types.ts
|
|
65
55
|
var SigningAlgo = /* @__PURE__ */ function(SigningAlgo2) {
|
|
@@ -72,22 +62,12 @@ var SigningAlgo = /* @__PURE__ */ function(SigningAlgo2) {
|
|
|
72
62
|
}({});
|
|
73
63
|
|
|
74
64
|
// lib/jwt/JwkThumbprint.ts
|
|
75
|
-
var
|
|
65
|
+
var import_uint8arrays = require("uint8arrays");
|
|
76
66
|
|
|
77
67
|
// lib/hasher.ts
|
|
78
|
-
var
|
|
79
|
-
var u8a = __toESM(require("uint8arrays"), 1);
|
|
80
|
-
var supportedAlgorithms = [
|
|
81
|
-
"sha256",
|
|
82
|
-
"sha384",
|
|
83
|
-
"sha512"
|
|
84
|
-
];
|
|
68
|
+
var import_ssi_types = require("@sphereon/ssi-types");
|
|
85
69
|
var defaultHasher = /* @__PURE__ */ __name((data, algorithm) => {
|
|
86
|
-
|
|
87
|
-
if (!supportedAlgorithms.includes(sanitizedAlgorithm)) {
|
|
88
|
-
throw new Error(`Unsupported hashing algorithm ${algorithm}`);
|
|
89
|
-
}
|
|
90
|
-
return new Uint8Array((0, import_sha.default)(sanitizedAlgorithm).update(typeof data === "string" ? u8a.fromString(data) : data).digest());
|
|
70
|
+
return (0, import_ssi_types.shaHasher)(data, algorithm);
|
|
91
71
|
}, "defaultHasher");
|
|
92
72
|
|
|
93
73
|
// lib/jwt/JwkThumbprint.ts
|
|
@@ -145,7 +125,7 @@ async function calculateJwkThumbprint(jwk, digestAlgorithm) {
|
|
|
145
125
|
default:
|
|
146
126
|
throw Error('"kty" (Key Type) Parameter missing or unsupported');
|
|
147
127
|
}
|
|
148
|
-
return
|
|
128
|
+
return (0, import_uint8arrays.toString)(defaultHasher(JSON.stringify(components), algorithm), "base64url");
|
|
149
129
|
}
|
|
150
130
|
__name(calculateJwkThumbprint, "calculateJwkThumbprint");
|
|
151
131
|
async function getDigestAlgorithmFromJwkThumbprintUri(uri) {
|
|
@@ -300,7 +280,7 @@ var checkExp = /* @__PURE__ */ __name((input) => {
|
|
|
300
280
|
|
|
301
281
|
// lib/dpop/DPoP.ts
|
|
302
282
|
var import_jwt_decode2 = require("jwt-decode");
|
|
303
|
-
var
|
|
283
|
+
var import_uint8arrays2 = require("uint8arrays");
|
|
304
284
|
var import_uuid = require("uuid");
|
|
305
285
|
var dpopTokenRequestNonceError = "use_dpop_nonce";
|
|
306
286
|
function getCreateDPoPOptions(createDPoPClientOpts, endPointUrl, resourceRequestOpts) {
|
|
@@ -323,7 +303,7 @@ async function createDPoP(options) {
|
|
|
323
303
|
if (jwtPayloadProps.accessToken && (jwtPayloadProps.accessToken?.startsWith("DPoP ") || jwtPayloadProps.accessToken?.startsWith("Bearer "))) {
|
|
324
304
|
throw new Error("expected access token without scheme");
|
|
325
305
|
}
|
|
326
|
-
const ath = jwtPayloadProps.accessToken ?
|
|
306
|
+
const ath = jwtPayloadProps.accessToken ? (0, import_uint8arrays2.toString)(defaultHasher(jwtPayloadProps.accessToken, "sha256"), "base64url") : void 0;
|
|
327
307
|
return createJwtCallback({
|
|
328
308
|
method: "jwk",
|
|
329
309
|
type: "dpop",
|
|
@@ -413,7 +393,7 @@ async function verifyDPoP(request, options) {
|
|
|
413
393
|
throw new Error("invalid_dpop_proof. Invalid authorization header.");
|
|
414
394
|
}
|
|
415
395
|
const accessToken = authorizationHeader.replace("DPoP ", "");
|
|
416
|
-
const expectedAth =
|
|
396
|
+
const expectedAth = (0, import_uint8arrays2.toString)(defaultHasher(accessToken, "sha256"), "base64url");
|
|
417
397
|
if (dPoPPayload.ath !== expectedAth) {
|
|
418
398
|
throw new Error("invalid_dpop_proof. Invalid ath claim");
|
|
419
399
|
}
|
|
@@ -451,7 +431,7 @@ __name(verifyResourceDPoP, "verifyResourceDPoP");
|
|
|
451
431
|
|
|
452
432
|
// lib/index.ts
|
|
453
433
|
var import_uuid2 = require("uuid");
|
|
454
|
-
var VCI_LOGGERS =
|
|
434
|
+
var VCI_LOGGERS = import_ssi_types2.Loggers.DEFAULT;
|
|
455
435
|
var VCI_LOG_COMMON = VCI_LOGGERS.get("sphereon:oid4vci:common");
|
|
456
436
|
// Annotate the CommonJS export names for ESM import in node:
|
|
457
437
|
0 && (module.exports = {
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../lib/index.ts","../lib/jwt/Jwt.types.ts","../lib/jwt/JwkThumbprint.ts","../lib/hasher.ts","../lib/jwt/JwtVerifier.ts","../lib/jwt/jwtUtils.ts","../lib/dpop/DPoP.ts"],"sourcesContent":["import { Loggers } from '@sphereon/ssi-types';\n\nexport const VCI_LOGGERS = Loggers.DEFAULT;\nexport const VCI_LOG_COMMON = VCI_LOGGERS.get('sphereon:oid4vci:common');\n\nexport * from './types';\nexport * from './jwt';\nexport * from './dpop';\nexport * from './oauth';\n\nexport { v4 as uuidv4 } from 'uuid';\nexport { defaultHasher } from './hasher';\n","import { JwtHeader as jwtDecodeJwtHeader, JwtPayload as jwtDecodePayload } from 'jwt-decode';\n\nimport { JWK } from './Jwk.types';\n\nexport type JwtHeader = jwtDecodeJwtHeader & {\n alg?: string;\n x5c?: string[];\n kid?: string;\n jwk?: JWK;\n jwt?: string;\n} & Record<string, unknown>;\n\nexport type JwtPayload = jwtDecodePayload & {\n client_id?: string;\n nonce?: string;\n request_uri?: string;\n client_id_scheme?: string;\n} & Record<string, unknown>;\n\nexport enum SigningAlgo {\n EDDSA = 'EdDSA',\n RS256 = 'RS256',\n PS256 = 'PS256',\n ES256 = 'ES256',\n ES256K = 'ES256K',\n}\n","// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nimport * as u8a from 'uint8arrays';\n\nimport { defaultHasher } from '../hasher';\nimport { DigestAlgorithm } from '../types';\n\nimport { JWK } from './Jwk.types';\n\nconst check = (value: unknown, description: string) => {\n if (typeof value !== 'string' || !value) {\n throw Error(`${description} missing or invalid`);\n }\n};\n\nexport async function calculateJwkThumbprint(jwk: JWK, digestAlgorithm?: DigestAlgorithm): Promise<string> {\n if (!jwk || typeof jwk !== 'object') {\n throw new TypeError('JWK must be an object');\n }\n const algorithm = digestAlgorithm ?? 'sha256';\n if (algorithm !== 'sha256' && algorithm !== 'sha384' && algorithm !== 'sha512') {\n throw new TypeError('digestAlgorithm must one of \"sha256\", \"sha384\", or \"sha512\"');\n }\n let components;\n switch (jwk.kty) {\n case 'EC':\n check(jwk.crv, '\"crv\" (Curve) Parameter');\n check(jwk.x, '\"x\" (X Coordinate) Parameter');\n check(jwk.y, '\"y\" (Y Coordinate) Parameter');\n components = { crv: jwk.crv, kty: jwk.kty, x: jwk.x, y: jwk.y };\n break;\n case 'OKP':\n check(jwk.crv, '\"crv\" (Subtype of Key Pair) Parameter');\n check(jwk.x, '\"x\" (Public Key) Parameter');\n components = { crv: jwk.crv, kty: jwk.kty, x: jwk.x };\n break;\n case 'RSA':\n check(jwk.e, '\"e\" (Exponent) Parameter');\n check(jwk.n, '\"n\" (Modulus) Parameter');\n components = { e: jwk.e, kty: jwk.kty, n: jwk.n };\n break;\n case 'oct':\n check(jwk.k, '\"k\" (Key Value) Parameter');\n components = { k: jwk.k, kty: jwk.kty };\n break;\n default:\n throw Error('\"kty\" (Key Type) Parameter missing or unsupported');\n }\n return u8a.toString(defaultHasher(JSON.stringify(components), algorithm), 'base64url');\n}\n\nexport async function getDigestAlgorithmFromJwkThumbprintUri(uri: string): Promise<DigestAlgorithm> {\n const match = uri.match(/^urn:ietf:params:oauth:jwk-thumbprint:sha-(\\w+):/);\n if (!match) {\n throw new Error(`Invalid JWK thumbprint URI structure ${uri}`);\n }\n const algorithm = `sha${match[1]}` as DigestAlgorithm;\n if (algorithm !== 'sha256' && algorithm !== 'sha384' && algorithm !== 'sha512') {\n throw new Error(`Invalid JWK thumbprint URI digest algorithm ${uri}`);\n }\n return algorithm;\n}\n\nexport async function calculateJwkThumbprintUri(jwk: JWK, digestAlgorithm: DigestAlgorithm = 'sha256'): Promise<string> {\n const thumbprint = await calculateJwkThumbprint(jwk, digestAlgorithm);\n return `urn:ietf:params:oauth:jwk-thumbprint:sha-${digestAlgorithm.slice(-3)}:${thumbprint}`;\n}\n","import { HasherSync } from '@sphereon/ssi-types';\nimport sha from 'sha.js';\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nimport * as u8a from 'uint8arrays';\n\nconst supportedAlgorithms = ['sha256', 'sha384', 'sha512'] as const;\ntype SupportedAlgorithms = (typeof supportedAlgorithms)[number];\n\nexport const defaultHasher: HasherSync = (data, algorithm) => {\n const sanitizedAlgorithm = algorithm.toLowerCase().replace(/[-_]/g, '');\n if (!supportedAlgorithms.includes(sanitizedAlgorithm as SupportedAlgorithms)) {\n throw new Error(`Unsupported hashing algorithm ${algorithm}`);\n }\n\n return new Uint8Array(\n sha(sanitizedAlgorithm as SupportedAlgorithms)\n .update(typeof data === 'string' ? u8a.fromString(data) : data)\n .digest(),\n );\n};\n","import { JWK } from './Jwk.types';\nimport { JwtHeader, JwtPayload, SigningAlgo } from './Jwt.types';\nimport { JwtProtectionMethod, JwtType } from './jwtUtils';\n\nexport interface JwtVerifierBase {\n type: JwtType;\n method: JwtProtectionMethod;\n}\n\nexport interface DidJwtVerifier extends JwtVerifierBase {\n method: 'did';\n\n alg: SigningAlgo | string;\n didUrl: string;\n}\n\nexport interface X5cJwtVerifier extends JwtVerifierBase {\n method: 'x5c';\n\n alg: SigningAlgo | string;\n\n /**\n *\n * Array of base64-encoded certificate strings in the DER-format.\n *\n * The certificate containing the public key corresponding to the key used to digitally sign the JWS MUST be the first certificate.\n */\n x5c: Array<string>;\n\n /**\n * The jwt issuer\n */\n issuer: string;\n}\n\nexport interface OpenIdFederationJwtVerifier extends JwtVerifierBase {\n method: 'openid-federation';\n\n /**\n * The OpenId federation Entity\n */\n entityId: string;\n}\n\nexport interface JwkJwtVerifier extends JwtVerifierBase {\n method: 'jwk';\n alg: SigningAlgo | string;\n\n jwk: JWK;\n}\n\nexport interface CustomJwtVerifier extends JwtVerifierBase {\n method: 'custom';\n}\n\nexport type JwtVerifier = DidJwtVerifier | X5cJwtVerifier | CustomJwtVerifier | JwkJwtVerifier | OpenIdFederationJwtVerifier;\n\nexport const getDidJwtVerifier = (jwt: { header: JwtHeader; payload: JwtPayload }, options: { type: JwtType }): DidJwtVerifier => {\n const { type } = options;\n if (!jwt.header.kid) throw new Error(`Received an invalid JWT. Missing kid header.`);\n if (!jwt.header.alg) throw new Error(`Received an invalid JWT. Missing alg header.`);\n\n if (!jwt.header.kid.includes('#')) {\n throw new Error(`Received an invalid JWT.. '${type}' contains an invalid kid header.`);\n }\n return { method: 'did', didUrl: jwt.header.kid, type: type, alg: jwt.header.alg };\n};\n\nconst getIssuer = (type: JwtType, payload: JwtPayload): string => {\n // For 'request-object' the `iss` value is not required so we map the issuer to client_id\n if (type === 'request-object') {\n if (!payload.client_id) {\n throw new Error('Missing required field client_id in request object JWT');\n }\n return payload.client_id as string;\n }\n\n if (typeof payload.iss !== 'string') {\n throw new Error(`Received an invalid JWT. '${type}' contains an invalid iss claim or it is missing.`);\n }\n return payload.iss;\n};\n\nexport const getX5cVerifier = (jwt: { header: JwtHeader; payload: JwtPayload }, options: { type: JwtType }): X5cJwtVerifier => {\n const { type } = options;\n if (!jwt.header.x5c) throw new Error(`Received an invalid JWT. Missing x5c header.`);\n if (!jwt.header.alg) throw new Error(`Received an invalid JWT. Missing alg header.`);\n\n if (!Array.isArray(jwt.header.x5c) || jwt.header.x5c.length === 0 || !jwt.header.x5c.every((cert) => typeof cert === 'string')) {\n throw new Error(`Received an invalid JWT.. '${type}' contains an invalid x5c header.`);\n }\n\n return {\n method: 'x5c',\n x5c: jwt.header.x5c,\n issuer: getIssuer(type, jwt.payload),\n type: type,\n alg: jwt.header.alg,\n };\n};\n\nexport const getJwkVerifier = async (jwt: { header: JwtHeader; payload: JwtPayload }, options: { type: JwtType }): Promise<JwkJwtVerifier> => {\n const { type } = options;\n if (!jwt.header.jwk) throw new Error(`Received an invalid JWT. Missing jwk header.`);\n if (!jwt.header.alg) throw new Error(`Received an invalid JWT. Missing alg header.`);\n\n if (typeof jwt.header.jwk !== 'object') {\n throw new Error(`Received an invalid JWT. '${type}' contains an invalid jwk header.`);\n }\n\n return { method: 'jwk', type, jwk: jwt.header.jwk, alg: jwt.header.alg };\n};\n\nexport const getJwtVerifierWithContext = async (\n jwt: { header: JwtHeader; payload: JwtPayload },\n options: { type: JwtType },\n): Promise<JwtVerifier> => {\n const { header, payload } = jwt;\n\n if (header.kid?.startsWith('did:')) return getDidJwtVerifier({ header, payload }, options);\n else if (jwt.header.x5c) return getX5cVerifier({ header, payload }, options);\n else if (jwt.header.jwk) return getJwkVerifier({ header, payload }, options);\n\n return { method: 'custom', type: options.type };\n};\n\nexport type VerifyJwtCallbackBase<T extends JwtVerifier> = (\n jwtVerifier: T,\n jwt: { header: JwtHeader; payload: JwtPayload; raw: string },\n) => Promise<boolean>;\n","import { jwtDecode } from 'jwt-decode';\n\nimport { JwtHeader, JwtPayload } from './Jwt.types';\n\nexport type JwtType = 'id-token' | 'request-object' | 'verifier-attestation' | 'dpop';\n\nexport type JwtProtectionMethod = 'did' | 'x5c' | 'jwk' | 'openid-federation' | 'custom';\n\nexport function parseJWT<Header = JwtHeader, Payload = JwtPayload>(jwt: string) {\n const header = jwtDecode<Header>(jwt, { header: true });\n const payload = jwtDecode<Payload>(jwt, { header: false });\n\n if (!payload || !header) {\n throw new Error('Jwt Payload and/or Header could not be parsed');\n }\n return { header, payload };\n}\n\n/**\n * The maximum allowed clock skew time in seconds. If an time based validation\n * is performed against current time (`now`), the validation can be of by the skew\n * time.\n *\n * See https://datatracker.ietf.org/doc/html/rfc7519#section-4.1.5\n */\nconst DEFAULT_SKEW_TIME = 60;\n\nexport function getNowSkewed(now?: number, skewTime?: number) {\n const _now = now ? now : epochTime();\n const _skewTime = skewTime ? skewTime : DEFAULT_SKEW_TIME;\n\n return {\n nowSkewedPast: _now - _skewTime,\n nowSkewedFuture: _now + _skewTime,\n };\n}\n\n/**\n * Returns the current unix timestamp in seconds.\n */\nexport function epochTime() {\n return Math.floor(Date.now() / 1000);\n}\n\nexport const BASE64_URL_REGEX = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/;\n\nexport const isJws = (jws: string) => {\n const jwsParts = jws.split('.');\n return jwsParts.length === 3 && jwsParts.every((part) => BASE64_URL_REGEX.test(part));\n};\nexport const isJwe = (jwe: string) => {\n const jweParts = jwe.split('.');\n return jweParts.length === 5 && jweParts.every((part) => BASE64_URL_REGEX.test(part));\n};\n\nexport const decodeProtectedHeader = (jwt: string) => {\n return jwtDecode(jwt, { header: true });\n};\n\nexport const decodeJwt = (jwt: string): JwtPayload => {\n return jwtDecode(jwt, { header: false });\n};\n\nexport const checkExp = (input: {\n exp: number;\n now?: number; // The number of milliseconds elapsed since midnight, January 1, 1970 Universal Coordinated Time (UTC).\n clockSkew?: number;\n}) => {\n const { exp, now, clockSkew } = input;\n return exp < (now ?? Date.now() / 1000) - (clockSkew ?? 120);\n};\n","import { jwtDecode } from 'jwt-decode';\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nimport * as u8a from 'uint8arrays';\nimport { v4 as uuidv4 } from 'uuid';\n\nimport { defaultHasher } from '../hasher';\nimport {\n calculateJwkThumbprint,\n CreateJwtCallback,\n epochTime,\n getNowSkewed,\n JWK,\n JwtHeader,\n JwtIssuerJwk,\n JwtPayload,\n parseJWT,\n SigningAlgo,\n VerifyJwtCallbackBase,\n} from '../jwt';\n\nexport const dpopTokenRequestNonceError = 'use_dpop_nonce';\n\nexport interface DPoPJwtIssuerWithContext extends JwtIssuerJwk {\n type: 'dpop';\n dPoPSigningAlgValuesSupported?: string[];\n}\n\nexport type DPoPJwtPayloadProps = {\n htu: string;\n iat: number;\n htm: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'HEAD' | 'OPTIONS' | 'TRACE' | 'CONNECT' | 'PATCH';\n ath?: string;\n nonce?: string;\n jti: string;\n};\nexport type DPoPJwtHeaderProps = { typ: 'dpop+jwt'; alg: SigningAlgo; jwk: JWK };\nexport type CreateDPoPJwtPayloadProps = Omit<DPoPJwtPayloadProps, 'iat' | 'jti' | 'ath'> & { accessToken?: string };\n\nexport interface CreateDPoPOpts<JwtPayloadProps = CreateDPoPJwtPayloadProps> {\n createJwtCallback: CreateJwtCallback<DPoPJwtIssuerWithContext>;\n jwtIssuer: Omit<JwtIssuerJwk, 'method' | 'type'>;\n jwtPayloadProps: Record<string, unknown> & JwtPayloadProps;\n dPoPSigningAlgValuesSupported?: (string | SigningAlgo)[];\n}\n\nexport type CreateDPoPClientOpts = CreateDPoPOpts<Omit<CreateDPoPJwtPayloadProps, 'htm' | 'htu'>>;\n\nexport function getCreateDPoPOptions(\n createDPoPClientOpts: CreateDPoPClientOpts,\n endPointUrl: string,\n resourceRequestOpts?: { accessToken: string },\n): CreateDPoPOpts {\n const htu = endPointUrl.split('?')[0].split('#')[0];\n return {\n ...createDPoPClientOpts,\n jwtPayloadProps: {\n ...createDPoPClientOpts.jwtPayloadProps,\n htu,\n htm: 'POST',\n ...(resourceRequestOpts && { accessToken: resourceRequestOpts.accessToken }),\n },\n };\n}\n\nexport async function createDPoP(options: CreateDPoPOpts): Promise<string> {\n const { createJwtCallback, jwtIssuer, jwtPayloadProps, dPoPSigningAlgValuesSupported } = options;\n\n if (jwtPayloadProps.accessToken && (jwtPayloadProps.accessToken?.startsWith('DPoP ') || jwtPayloadProps.accessToken?.startsWith('Bearer '))) {\n throw new Error('expected access token without scheme');\n }\n\n const ath = jwtPayloadProps.accessToken ? u8a.toString(defaultHasher(jwtPayloadProps.accessToken, 'sha256'), 'base64url') : undefined;\n return createJwtCallback(\n { method: 'jwk', type: 'dpop', alg: jwtIssuer.alg, jwk: jwtIssuer.jwk, dPoPSigningAlgValuesSupported },\n {\n header: { ...jwtIssuer, typ: 'dpop+jwt', alg: jwtIssuer.alg, jwk: jwtIssuer.jwk },\n payload: {\n ...jwtPayloadProps,\n iat: epochTime(),\n jti: uuidv4(),\n ...(ath && { ath }),\n },\n },\n );\n}\n\nexport type DPoPVerifyJwtCallback = VerifyJwtCallbackBase<JwtIssuerJwk & { type: 'dpop' }>;\nexport interface DPoPVerifyOptions {\n expectedNonce?: string;\n acceptedAlgorithms?: (string | SigningAlgo)[];\n // defaults to 300 seconds (5 minutes)\n maxIatAgeInSeconds?: number;\n expectAccessToken?: boolean;\n jwtVerifyCallback: DPoPVerifyJwtCallback;\n now?: number;\n}\n\nexport async function verifyDPoP(\n request: { headers: Record<string, string | string[] | undefined>; fullUrl: string } & Pick<Request, 'method'>,\n options: DPoPVerifyOptions,\n) {\n // There is not more than one DPoP HTTP request header field.\n const dpop = request.headers['dpop'];\n if (!dpop || typeof dpop !== 'string') {\n throw new Error('missing or invalid dpop header. Expected compact JWT');\n }\n\n // The DPoP HTTP request header field value is a single and well-formed JWT.\n const { header: dPoPHeader, payload: dPoPPayload } = parseJWT<JwtHeader, JwtPayload & Partial<DPoPJwtPayloadProps>>(dpop);\n\n // Ensure all required header claims are present\n if (dPoPHeader.typ !== 'dpop+jwt' || !dPoPHeader.alg || !dPoPHeader.jwk || typeof dPoPHeader.jwk !== 'object' || dPoPHeader.jwk.d) {\n throw new Error('invalid_dpop_proof. Invalid header claims');\n }\n\n // Ensure all required payload claims are present\n if (!dPoPPayload.htm || !dPoPPayload.htu || !dPoPPayload.iat || !dPoPPayload.jti) {\n throw new Error('invalid_dpop_proof. Missing required claims');\n }\n\n // Validate alg is supported\n if (options?.acceptedAlgorithms && !options.acceptedAlgorithms.includes(dPoPHeader.alg)) {\n throw new Error(`invalid_dpop_proof. Invalid 'alg' claim '${dPoPHeader.alg}'. Only ${options.acceptedAlgorithms.join(', ')} are supported.`);\n }\n\n // Validate nonce if provided\n if ((options?.expectedNonce && !dPoPPayload.nonce) || dPoPPayload.nonce !== options.expectedNonce) {\n throw new Error('invalid_dpop_proof. Nonce mismatch');\n }\n\n // Verify JWT signature\n try {\n const verificationResult = await options.jwtVerifyCallback(\n {\n method: 'jwk',\n type: 'dpop',\n jwk: dPoPHeader.jwk,\n alg: dPoPHeader.alg,\n },\n {\n header: dPoPHeader,\n payload: dPoPPayload,\n raw: dpop,\n },\n );\n\n if (!verificationResult) {\n throw new Error('invalid_dpop_proof. Invalid JWT signature');\n }\n } catch (error: unknown) {\n throw new Error('invalid_dpop_proof. Invalid JWT signature. ' + (error instanceof Error ? error.message : 'Unknown error'));\n }\n\n // Validate htm claim\n if (dPoPPayload.htm !== request.method) {\n throw new Error(`invalid_dpop_proof. Invalid htm claim. Must match request method '${request.method}'`);\n }\n\n // The htu claim matches the HTTP URI value for the HTTP request in which the JWT was received, ignoring any query and fragment parts.\n const currentUri = request.fullUrl.split('?')[0].split('#')[0];\n if (dPoPPayload.htu !== currentUri) {\n throw new Error('invalid_dpop_proof. Invalid htu claim');\n }\n\n // Validate nonce if provided\n if ((options.expectedNonce && dPoPPayload.nonce !== options.expectedNonce) || (!options.expectedNonce && dPoPPayload.nonce)) {\n throw new Error('invalid_dpop_proof. Nonce mismatch');\n }\n\n // Validate iat claim\n const { nowSkewedPast, nowSkewedFuture } = getNowSkewed(options.now);\n if (\n // iat claim is too far in the future\n nowSkewedPast - (options.maxIatAgeInSeconds ?? 60) > dPoPPayload.iat ||\n // iat claim is too old\n nowSkewedFuture + (options.maxIatAgeInSeconds ?? 60) < dPoPPayload.iat\n ) {\n // 5 minute window\n throw new Error('invalid_dpop_proof. Invalid iat claim');\n }\n\n // If access token is present, validate ath claim\n const authorizationHeader = request.headers.authorization;\n if (!options.expectAccessToken && authorizationHeader) {\n throw new Error('invalid_dpop_proof. Received an unexpected authorization header.');\n }\n\n if (options.expectAccessToken) {\n if (!dPoPPayload.ath) {\n throw new Error('invalid_dpop_proof. Missing expected ath claim.');\n }\n\n // validate that the DPOP proof is made for the provided access token\n if (!authorizationHeader || typeof authorizationHeader !== 'string' || !authorizationHeader.startsWith('DPoP ')) {\n throw new Error('invalid_dpop_proof. Invalid authorization header.');\n }\n\n const accessToken = authorizationHeader.replace('DPoP ', '');\n const expectedAth = u8a.toString(defaultHasher(accessToken, 'sha256'), 'base64url');\n if (dPoPPayload.ath !== expectedAth) {\n throw new Error('invalid_dpop_proof. Invalid ath claim');\n }\n\n // validate that the access token is signed with the same key as the DPOP proof\n const accessTokenPayload = jwtDecode<JwtPayload & { cnf?: { jkt?: string } }>(accessToken, { header: false });\n if (!accessTokenPayload.cnf?.jkt) {\n throw new Error('invalid_dpop_proof. Access token is missing the jkt claim');\n }\n\n const thumprint = await calculateJwkThumbprint(dPoPHeader.jwk, 'sha256');\n if (accessTokenPayload.cnf?.jkt !== thumprint) {\n throw new Error('invalid_dpop_proof. JwkThumbprint mismatch');\n }\n }\n\n // If all validations pass, return the dpop jwk\n return dPoPHeader.jwk;\n}\n\n/**\n * DPoP verifications for resource requests\n * For Bearer token compatibility jwt's must have a token_type claim\n * The access token itself must be validated before using this method\n * If the token_type is not DPoP, then the request is not a DPoP request\n * and we don't need to verify the DPoP proof\n */\nexport async function verifyResourceDPoP(\n request: { headers: Record<string, string | string[] | undefined>; fullUrl: string } & Pick<Request, 'method'>,\n options: Omit<DPoPVerifyOptions, 'expectAccessToken'>,\n) {\n if (!request.headers.authorization || typeof request.headers.authorization !== 'string') {\n throw new Error('Received an invalid resource request. Missing authorization header.');\n }\n const tokenPayload = jwtDecode<JwtPayload & { token_type?: string }>(request.headers.authorization, { header: false });\n const tokenType = tokenPayload.token_type;\n\n if (tokenType !== 'DPoP') {\n return;\n }\n\n return verifyDPoP(request, { ...options, expectAccessToken: true });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uBAAwB;;;ACmBjB,I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AACxB;EACF;AAEA,SAAOtC,WAAWC,SAAS;IAAE,GAAGtB;IAASgD,mBAAmB;EAAK,CAAA;AACnE;AAfsBS;;;ANzNtB,IAAAI,eAA6B;AARtB,IAAMC,cAAcC,yBAAQC;AAC5B,IAAMC,iBAAiBH,YAAYI,IAAI,yBAAA;","names":["SigningAlgo","u8a","supportedAlgorithms","defaultHasher","data","algorithm","sanitizedAlgorithm","toLowerCase","replace","includes","Error","Uint8Array","sha","update","fromString","digest","check","value","description","Error","calculateJwkThumbprint","jwk","digestAlgorithm","TypeError","algorithm","components","kty","crv","x","y","e","n","k","toString","defaultHasher","JSON","stringify","getDigestAlgorithmFromJwkThumbprintUri","uri","match","calculateJwkThumbprintUri","thumbprint","slice","getDidJwtVerifier","jwt","options","type","header","kid","Error","alg","includes","method","didUrl","getIssuer","payload","client_id","iss","getX5cVerifier","x5c","Array","isArray","length","every","cert","issuer","getJwkVerifier","jwk","getJwtVerifierWithContext","startsWith","parseJWT","jwt","header","jwtDecode","payload","Error","DEFAULT_SKEW_TIME","getNowSkewed","now","skewTime","_now","epochTime","_skewTime","nowSkewedPast","nowSkewedFuture","Math","floor","Date","BASE64_URL_REGEX","isJws","jws","jwsParts","split","length","every","part","test","isJwe","jwe","jweParts","decodeProtectedHeader","decodeJwt","checkExp","input","exp","clockSkew","import_jwt_decode","u8a","dpopTokenRequestNonceError","getCreateDPoPOptions","createDPoPClientOpts","endPointUrl","resourceRequestOpts","htu","split","jwtPayloadProps","htm","accessToken","createDPoP","options","createJwtCallback","jwtIssuer","dPoPSigningAlgValuesSupported","startsWith","Error","ath","toString","defaultHasher","undefined","method","type","alg","jwk","header","typ","payload","iat","epochTime","jti","uuidv4","verifyDPoP","request","dpop","headers","dPoPHeader","dPoPPayload","parseJWT","d","acceptedAlgorithms","includes","join","expectedNonce","nonce","verificationResult","jwtVerifyCallback","raw","error","message","currentUri","fullUrl","nowSkewedPast","nowSkewedFuture","getNowSkewed","now","maxIatAgeInSeconds","authorizationHeader","authorization","expectAccessToken","replace","expectedAth","accessTokenPayload","jwtDecode","cnf","jkt","thumprint","calculateJwkThumbprint","verifyResourceDPoP","tokenPayload","tokenType","token_type","import_uuid","VCI_LOGGERS","Loggers","DEFAULT","VCI_LOG_COMMON","get"]}
|
|
1
|
+
{"version":3,"sources":["../lib/index.ts","../lib/jwt/Jwt.types.ts","../lib/jwt/JwkThumbprint.ts","../lib/hasher.ts","../lib/jwt/JwtVerifier.ts","../lib/jwt/jwtUtils.ts","../lib/dpop/DPoP.ts"],"sourcesContent":["import { Loggers } from '@sphereon/ssi-types'\n\nexport const VCI_LOGGERS = Loggers.DEFAULT\nexport const VCI_LOG_COMMON = VCI_LOGGERS.get('sphereon:oid4vci:common')\n\nexport * from './types'\nexport * from './jwt'\nexport * from './dpop'\nexport * from './oauth'\n\nexport { v4 as uuidv4 } from 'uuid'\nexport { defaultHasher } from './hasher'\n","import { JwtHeader as jwtDecodeJwtHeader, JwtPayload as jwtDecodePayload } from 'jwt-decode'\n\nimport { JWK } from './Jwk.types'\n\nexport type JwtHeader = jwtDecodeJwtHeader & {\n alg?: string\n x5c?: string[]\n kid?: string\n jwk?: JWK\n jwt?: string\n} & Record<string, unknown>\n\nexport type JwtPayload = jwtDecodePayload & {\n client_id?: string\n nonce?: string\n request_uri?: string\n client_id_scheme?: string\n} & Record<string, unknown>\n\nexport enum SigningAlgo {\n EDDSA = 'EdDSA',\n RS256 = 'RS256',\n PS256 = 'PS256',\n ES256 = 'ES256',\n ES256K = 'ES256K',\n}\n","import { toString } from 'uint8arrays'\n\nimport { defaultHasher } from '../hasher'\nimport { DigestAlgorithm } from '../types'\n\nimport { JWK } from './Jwk.types'\n\nconst check = (value: unknown, description: string) => {\n if (typeof value !== 'string' || !value) {\n throw Error(`${description} missing or invalid`)\n }\n}\n\nexport async function calculateJwkThumbprint(jwk: JWK, digestAlgorithm?: DigestAlgorithm): Promise<string> {\n if (!jwk || typeof jwk !== 'object') {\n throw new TypeError('JWK must be an object')\n }\n const algorithm = digestAlgorithm ?? 'sha256'\n if (algorithm !== 'sha256' && algorithm !== 'sha384' && algorithm !== 'sha512') {\n throw new TypeError('digestAlgorithm must one of \"sha256\", \"sha384\", or \"sha512\"')\n }\n let components\n switch (jwk.kty) {\n case 'EC':\n check(jwk.crv, '\"crv\" (Curve) Parameter')\n check(jwk.x, '\"x\" (X Coordinate) Parameter')\n check(jwk.y, '\"y\" (Y Coordinate) Parameter')\n components = { crv: jwk.crv, kty: jwk.kty, x: jwk.x, y: jwk.y }\n break\n case 'OKP':\n check(jwk.crv, '\"crv\" (Subtype of Key Pair) Parameter')\n check(jwk.x, '\"x\" (Public Key) Parameter')\n components = { crv: jwk.crv, kty: jwk.kty, x: jwk.x }\n break\n case 'RSA':\n check(jwk.e, '\"e\" (Exponent) Parameter')\n check(jwk.n, '\"n\" (Modulus) Parameter')\n components = { e: jwk.e, kty: jwk.kty, n: jwk.n }\n break\n case 'oct':\n check(jwk.k, '\"k\" (Key Value) Parameter')\n components = { k: jwk.k, kty: jwk.kty }\n break\n default:\n throw Error('\"kty\" (Key Type) Parameter missing or unsupported')\n }\n return toString(defaultHasher(JSON.stringify(components), algorithm), 'base64url')\n}\n\nexport async function getDigestAlgorithmFromJwkThumbprintUri(uri: string): Promise<DigestAlgorithm> {\n const match = uri.match(/^urn:ietf:params:oauth:jwk-thumbprint:sha-(\\w+):/)\n if (!match) {\n throw new Error(`Invalid JWK thumbprint URI structure ${uri}`)\n }\n const algorithm = `sha${match[1]}` as DigestAlgorithm\n if (algorithm !== 'sha256' && algorithm !== 'sha384' && algorithm !== 'sha512') {\n throw new Error(`Invalid JWK thumbprint URI digest algorithm ${uri}`)\n }\n return algorithm\n}\n\nexport async function calculateJwkThumbprintUri(jwk: JWK, digestAlgorithm: DigestAlgorithm = 'sha256'): Promise<string> {\n const thumbprint = await calculateJwkThumbprint(jwk, digestAlgorithm)\n return `urn:ietf:params:oauth:jwk-thumbprint:sha-${digestAlgorithm.slice(-3)}:${thumbprint}`\n}\n","import { HasherSync, shaHasher } from '@sphereon/ssi-types'\n\nexport const defaultHasher: HasherSync = (data: string | ArrayBuffer, algorithm: string) => {\n return shaHasher(data, algorithm)\n}\n","import { JWK } from './Jwk.types'\nimport { JwtHeader, JwtPayload, SigningAlgo } from './Jwt.types'\nimport { JwtProtectionMethod, JwtType } from './jwtUtils'\n\nexport interface JwtVerifierBase {\n type: JwtType\n method: JwtProtectionMethod\n}\n\nexport interface DidJwtVerifier extends JwtVerifierBase {\n method: 'did'\n\n alg: SigningAlgo | string\n didUrl: string\n}\n\nexport interface X5cJwtVerifier extends JwtVerifierBase {\n method: 'x5c'\n\n alg: SigningAlgo | string\n\n /**\n *\n * Array of base64-encoded certificate strings in the DER-format.\n *\n * The certificate containing the public key corresponding to the key used to digitally sign the JWS MUST be the first certificate.\n */\n x5c: Array<string>\n\n /**\n * The jwt issuer\n */\n issuer: string\n}\n\nexport interface OpenIdFederationJwtVerifier extends JwtVerifierBase {\n method: 'openid-federation'\n\n /**\n * The OpenId federation Entity\n */\n entityId: string\n}\n\nexport interface JwkJwtVerifier extends JwtVerifierBase {\n method: 'jwk'\n alg: SigningAlgo | string\n\n jwk: JWK\n}\n\nexport interface CustomJwtVerifier extends JwtVerifierBase {\n method: 'custom'\n}\n\nexport type JwtVerifier = DidJwtVerifier | X5cJwtVerifier | CustomJwtVerifier | JwkJwtVerifier | OpenIdFederationJwtVerifier\n\nexport const getDidJwtVerifier = (jwt: { header: JwtHeader; payload: JwtPayload }, options: { type: JwtType }): DidJwtVerifier => {\n const { type } = options\n if (!jwt.header.kid) throw new Error(`Received an invalid JWT. Missing kid header.`)\n if (!jwt.header.alg) throw new Error(`Received an invalid JWT. Missing alg header.`)\n\n if (!jwt.header.kid.includes('#')) {\n throw new Error(`Received an invalid JWT.. '${type}' contains an invalid kid header.`)\n }\n return { method: 'did', didUrl: jwt.header.kid, type: type, alg: jwt.header.alg }\n}\n\nconst getIssuer = (type: JwtType, payload: JwtPayload): string => {\n // For 'request-object' the `iss` value is not required so we map the issuer to client_id\n if (type === 'request-object') {\n if (!payload.client_id) {\n throw new Error('Missing required field client_id in request object JWT')\n }\n return payload.client_id as string\n }\n\n if (typeof payload.iss !== 'string') {\n throw new Error(`Received an invalid JWT. '${type}' contains an invalid iss claim or it is missing.`)\n }\n return payload.iss\n}\n\nexport const getX5cVerifier = (jwt: { header: JwtHeader; payload: JwtPayload }, options: { type: JwtType }): X5cJwtVerifier => {\n const { type } = options\n if (!jwt.header.x5c) throw new Error(`Received an invalid JWT. Missing x5c header.`)\n if (!jwt.header.alg) throw new Error(`Received an invalid JWT. Missing alg header.`)\n\n if (!Array.isArray(jwt.header.x5c) || jwt.header.x5c.length === 0 || !jwt.header.x5c.every((cert) => typeof cert === 'string')) {\n throw new Error(`Received an invalid JWT.. '${type}' contains an invalid x5c header.`)\n }\n\n return {\n method: 'x5c',\n x5c: jwt.header.x5c,\n issuer: getIssuer(type, jwt.payload),\n type: type,\n alg: jwt.header.alg,\n }\n}\n\nexport const getJwkVerifier = async (jwt: { header: JwtHeader; payload: JwtPayload }, options: { type: JwtType }): Promise<JwkJwtVerifier> => {\n const { type } = options\n if (!jwt.header.jwk) throw new Error(`Received an invalid JWT. Missing jwk header.`)\n if (!jwt.header.alg) throw new Error(`Received an invalid JWT. Missing alg header.`)\n\n if (typeof jwt.header.jwk !== 'object') {\n throw new Error(`Received an invalid JWT. '${type}' contains an invalid jwk header.`)\n }\n\n return { method: 'jwk', type, jwk: jwt.header.jwk, alg: jwt.header.alg }\n}\n\nexport const getJwtVerifierWithContext = async (\n jwt: { header: JwtHeader; payload: JwtPayload },\n options: { type: JwtType },\n): Promise<JwtVerifier> => {\n const { header, payload } = jwt\n\n if (header.kid?.startsWith('did:')) return getDidJwtVerifier({ header, payload }, options)\n else if (jwt.header.x5c) return getX5cVerifier({ header, payload }, options)\n else if (jwt.header.jwk) return getJwkVerifier({ header, payload }, options)\n\n return { method: 'custom', type: options.type }\n}\n\nexport type VerifyJwtCallbackBase<T extends JwtVerifier> = (\n jwtVerifier: T,\n jwt: { header: JwtHeader; payload: JwtPayload; raw: string },\n) => Promise<boolean>\n","import { jwtDecode } from 'jwt-decode'\n\nimport { JwtHeader, JwtPayload } from './Jwt.types'\n\nexport type JwtType = 'id-token' | 'request-object' | 'verifier-attestation' | 'dpop'\n\nexport type JwtProtectionMethod = 'did' | 'x5c' | 'jwk' | 'openid-federation' | 'custom'\n\nexport function parseJWT<Header = JwtHeader, Payload = JwtPayload>(jwt: string) {\n const header = jwtDecode<Header>(jwt, { header: true })\n const payload = jwtDecode<Payload>(jwt, { header: false })\n\n if (!payload || !header) {\n throw new Error('Jwt Payload and/or Header could not be parsed')\n }\n return { header, payload }\n}\n\n/**\n * The maximum allowed clock skew time in seconds. If an time based validation\n * is performed against current time (`now`), the validation can be of by the skew\n * time.\n *\n * See https://datatracker.ietf.org/doc/html/rfc7519#section-4.1.5\n */\nconst DEFAULT_SKEW_TIME = 60\n\nexport function getNowSkewed(now?: number, skewTime?: number) {\n const _now = now ? now : epochTime()\n const _skewTime = skewTime ? skewTime : DEFAULT_SKEW_TIME\n\n return {\n nowSkewedPast: _now - _skewTime,\n nowSkewedFuture: _now + _skewTime,\n }\n}\n\n/**\n * Returns the current unix timestamp in seconds.\n */\nexport function epochTime() {\n return Math.floor(Date.now() / 1000)\n}\n\nexport const BASE64_URL_REGEX = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/\n\nexport const isJws = (jws: string) => {\n const jwsParts = jws.split('.')\n return jwsParts.length === 3 && jwsParts.every((part) => BASE64_URL_REGEX.test(part))\n}\nexport const isJwe = (jwe: string) => {\n const jweParts = jwe.split('.')\n return jweParts.length === 5 && jweParts.every((part) => BASE64_URL_REGEX.test(part))\n}\n\nexport const decodeProtectedHeader = (jwt: string) => {\n return jwtDecode(jwt, { header: true })\n}\n\nexport const decodeJwt = (jwt: string): JwtPayload => {\n return jwtDecode(jwt, { header: false })\n}\n\nexport const checkExp = (input: {\n exp: number\n now?: number // The number of milliseconds elapsed since midnight, January 1, 1970 Universal Coordinated Time (UTC).\n clockSkew?: number\n}) => {\n const { exp, now, clockSkew } = input\n return exp < (now ?? Date.now() / 1000) - (clockSkew ?? 120)\n}\n","import { jwtDecode } from 'jwt-decode'\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nimport { fromString, toString } from 'uint8arrays'\nimport { v4 as uuidv4 } from 'uuid'\n\nimport { defaultHasher } from '../hasher'\nimport {\n calculateJwkThumbprint,\n CreateJwtCallback,\n epochTime,\n getNowSkewed,\n JWK,\n JwtHeader,\n JwtIssuerJwk,\n JwtPayload,\n parseJWT,\n SigningAlgo,\n VerifyJwtCallbackBase,\n} from '../jwt'\n\nexport const dpopTokenRequestNonceError = 'use_dpop_nonce'\n\nexport interface DPoPJwtIssuerWithContext extends JwtIssuerJwk {\n type: 'dpop'\n dPoPSigningAlgValuesSupported?: string[]\n}\n\nexport type DPoPJwtPayloadProps = {\n htu: string\n iat: number\n htm: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'HEAD' | 'OPTIONS' | 'TRACE' | 'CONNECT' | 'PATCH'\n ath?: string\n nonce?: string\n jti: string\n}\nexport type DPoPJwtHeaderProps = { typ: 'dpop+jwt'; alg: SigningAlgo; jwk: JWK }\nexport type CreateDPoPJwtPayloadProps = Omit<DPoPJwtPayloadProps, 'iat' | 'jti' | 'ath'> & { accessToken?: string }\n\nexport interface CreateDPoPOpts<JwtPayloadProps = CreateDPoPJwtPayloadProps> {\n createJwtCallback: CreateJwtCallback<DPoPJwtIssuerWithContext>\n jwtIssuer: Omit<JwtIssuerJwk, 'method' | 'type'>\n jwtPayloadProps: Record<string, unknown> & JwtPayloadProps\n dPoPSigningAlgValuesSupported?: (string | SigningAlgo)[]\n}\n\nexport type CreateDPoPClientOpts = CreateDPoPOpts<Omit<CreateDPoPJwtPayloadProps, 'htm' | 'htu'>>\n\nexport function getCreateDPoPOptions(\n createDPoPClientOpts: CreateDPoPClientOpts,\n endPointUrl: string,\n resourceRequestOpts?: { accessToken: string },\n): CreateDPoPOpts {\n const htu = endPointUrl.split('?')[0].split('#')[0]\n return {\n ...createDPoPClientOpts,\n jwtPayloadProps: {\n ...createDPoPClientOpts.jwtPayloadProps,\n htu,\n htm: 'POST',\n ...(resourceRequestOpts && { accessToken: resourceRequestOpts.accessToken }),\n },\n }\n}\n\nexport async function createDPoP(options: CreateDPoPOpts): Promise<string> {\n const { createJwtCallback, jwtIssuer, jwtPayloadProps, dPoPSigningAlgValuesSupported } = options\n\n if (jwtPayloadProps.accessToken && (jwtPayloadProps.accessToken?.startsWith('DPoP ') || jwtPayloadProps.accessToken?.startsWith('Bearer '))) {\n throw new Error('expected access token without scheme')\n }\n\n const ath = jwtPayloadProps.accessToken ? toString(defaultHasher(jwtPayloadProps.accessToken, 'sha256'), 'base64url') : undefined\n return createJwtCallback(\n { method: 'jwk', type: 'dpop', alg: jwtIssuer.alg, jwk: jwtIssuer.jwk, dPoPSigningAlgValuesSupported },\n {\n header: { ...jwtIssuer, typ: 'dpop+jwt', alg: jwtIssuer.alg, jwk: jwtIssuer.jwk },\n payload: {\n ...jwtPayloadProps,\n iat: epochTime(),\n jti: uuidv4(),\n ...(ath && { ath }),\n },\n },\n )\n}\n\nexport type DPoPVerifyJwtCallback = VerifyJwtCallbackBase<JwtIssuerJwk & { type: 'dpop' }>\nexport interface DPoPVerifyOptions {\n expectedNonce?: string\n acceptedAlgorithms?: (string | SigningAlgo)[]\n // defaults to 300 seconds (5 minutes)\n maxIatAgeInSeconds?: number\n expectAccessToken?: boolean\n jwtVerifyCallback: DPoPVerifyJwtCallback\n now?: number\n}\n\nexport async function verifyDPoP(\n request: { headers: Record<string, string | string[] | undefined>; fullUrl: string } & Pick<Request, 'method'>,\n options: DPoPVerifyOptions,\n) {\n // There is not more than one DPoP HTTP request header field.\n const dpop = request.headers['dpop']\n if (!dpop || typeof dpop !== 'string') {\n throw new Error('missing or invalid dpop header. Expected compact JWT')\n }\n\n // The DPoP HTTP request header field value is a single and well-formed JWT.\n const { header: dPoPHeader, payload: dPoPPayload } = parseJWT<JwtHeader, JwtPayload & Partial<DPoPJwtPayloadProps>>(dpop)\n\n // Ensure all required header claims are present\n if (dPoPHeader.typ !== 'dpop+jwt' || !dPoPHeader.alg || !dPoPHeader.jwk || typeof dPoPHeader.jwk !== 'object' || dPoPHeader.jwk.d) {\n throw new Error('invalid_dpop_proof. Invalid header claims')\n }\n\n // Ensure all required payload claims are present\n if (!dPoPPayload.htm || !dPoPPayload.htu || !dPoPPayload.iat || !dPoPPayload.jti) {\n throw new Error('invalid_dpop_proof. Missing required claims')\n }\n\n // Validate alg is supported\n if (options?.acceptedAlgorithms && !options.acceptedAlgorithms.includes(dPoPHeader.alg)) {\n throw new Error(`invalid_dpop_proof. Invalid 'alg' claim '${dPoPHeader.alg}'. Only ${options.acceptedAlgorithms.join(', ')} are supported.`)\n }\n\n // Validate nonce if provided\n if ((options?.expectedNonce && !dPoPPayload.nonce) || dPoPPayload.nonce !== options.expectedNonce) {\n throw new Error('invalid_dpop_proof. Nonce mismatch')\n }\n\n // Verify JWT signature\n try {\n const verificationResult = await options.jwtVerifyCallback(\n {\n method: 'jwk',\n type: 'dpop',\n jwk: dPoPHeader.jwk,\n alg: dPoPHeader.alg,\n },\n {\n header: dPoPHeader,\n payload: dPoPPayload,\n raw: dpop,\n },\n )\n\n if (!verificationResult) {\n throw new Error('invalid_dpop_proof. Invalid JWT signature')\n }\n } catch (error: unknown) {\n throw new Error('invalid_dpop_proof. Invalid JWT signature. ' + (error instanceof Error ? error.message : 'Unknown error'))\n }\n\n // Validate htm claim\n if (dPoPPayload.htm !== request.method) {\n throw new Error(`invalid_dpop_proof. Invalid htm claim. Must match request method '${request.method}'`)\n }\n\n // The htu claim matches the HTTP URI value for the HTTP request in which the JWT was received, ignoring any query and fragment parts.\n const currentUri = request.fullUrl.split('?')[0].split('#')[0]\n if (dPoPPayload.htu !== currentUri) {\n throw new Error('invalid_dpop_proof. Invalid htu claim')\n }\n\n // Validate nonce if provided\n if ((options.expectedNonce && dPoPPayload.nonce !== options.expectedNonce) || (!options.expectedNonce && dPoPPayload.nonce)) {\n throw new Error('invalid_dpop_proof. Nonce mismatch')\n }\n\n // Validate iat claim\n const { nowSkewedPast, nowSkewedFuture } = getNowSkewed(options.now)\n if (\n // iat claim is too far in the future\n nowSkewedPast - (options.maxIatAgeInSeconds ?? 60) > dPoPPayload.iat ||\n // iat claim is too old\n nowSkewedFuture + (options.maxIatAgeInSeconds ?? 60) < dPoPPayload.iat\n ) {\n // 5 minute window\n throw new Error('invalid_dpop_proof. Invalid iat claim')\n }\n\n // If access token is present, validate ath claim\n const authorizationHeader = request.headers.authorization\n if (!options.expectAccessToken && authorizationHeader) {\n throw new Error('invalid_dpop_proof. Received an unexpected authorization header.')\n }\n\n if (options.expectAccessToken) {\n if (!dPoPPayload.ath) {\n throw new Error('invalid_dpop_proof. Missing expected ath claim.')\n }\n\n // validate that the DPOP proof is made for the provided access token\n if (!authorizationHeader || typeof authorizationHeader !== 'string' || !authorizationHeader.startsWith('DPoP ')) {\n throw new Error('invalid_dpop_proof. Invalid authorization header.')\n }\n\n const accessToken = authorizationHeader.replace('DPoP ', '')\n const expectedAth = toString(defaultHasher(accessToken, 'sha256'), 'base64url')\n if (dPoPPayload.ath !== expectedAth) {\n throw new Error('invalid_dpop_proof. Invalid ath claim')\n }\n\n // validate that the access token is signed with the same key as the DPOP proof\n const accessTokenPayload = jwtDecode<JwtPayload & { cnf?: { jkt?: string } }>(accessToken, { header: false })\n if (!accessTokenPayload.cnf?.jkt) {\n throw new Error('invalid_dpop_proof. Access token is missing the jkt claim')\n }\n\n const thumprint = await calculateJwkThumbprint(dPoPHeader.jwk, 'sha256')\n if (accessTokenPayload.cnf?.jkt !== thumprint) {\n throw new Error('invalid_dpop_proof. JwkThumbprint mismatch')\n }\n }\n\n // If all validations pass, return the dpop jwk\n return dPoPHeader.jwk\n}\n\n/**\n * DPoP verifications for resource requests\n * For Bearer token compatibility jwt's must have a token_type claim\n * The access token itself must be validated before using this method\n * If the token_type is not DPoP, then the request is not a DPoP request\n * and we don't need to verify the DPoP proof\n */\nexport async function verifyResourceDPoP(\n request: { headers: Record<string, string | string[] | undefined>; fullUrl: string } & Pick<Request, 'method'>,\n options: Omit<DPoPVerifyOptions, 'expectAccessToken'>,\n) {\n if (!request.headers.authorization || typeof request.headers.authorization !== 'string') {\n throw new Error('Received an invalid resource request. Missing authorization header.')\n }\n const tokenPayload = jwtDecode<JwtPayload & { token_type?: string }>(request.headers.authorization, { header: false })\n const tokenType = tokenPayload.token_type\n\n if (tokenType !== 'DPoP') {\n return\n }\n\n return verifyDPoP(request, { ...options, expectAccessToken: true })\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,oBAAwB;;;ACmBjB,IAAKC,cAAAA,yBAAAA,cAAAA;;;;;;SAAAA;;;;ACnBZ,yBAAyB;;;ACAzB,uBAAsC;AAE/B,IAAMC,gBAA4B,wBAACC,MAA4BC,cAAAA;AACpE,aAAOC,4BAAUF,MAAMC,SAAAA;AACzB,GAFyC;;;ADKzC,IAAME,QAAQ,wBAACC,OAAgBC,gBAAAA;AAC7B,MAAI,OAAOD,UAAU,YAAY,CAACA,OAAO;AACvC,UAAME,MAAM,GAAGD,WAAAA,qBAAgC;EACjD;AACF,GAJc;AAMd,eAAsBE,uBAAuBC,KAAUC,iBAAiC;AACtF,MAAI,CAACD,OAAO,OAAOA,QAAQ,UAAU;AACnC,UAAM,IAAIE,UAAU,uBAAA;EACtB;AACA,QAAMC,YAAYF,mBAAmB;AACrC,MAAIE,cAAc,YAAYA,cAAc,YAAYA,cAAc,UAAU;AAC9E,UAAM,IAAID,UAAU,6DAAA;EACtB;AACA,MAAIE;AACJ,UAAQJ,IAAIK,KAAG;IACb,KAAK;AACHV,YAAMK,IAAIM,KAA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SACAtB,SAAqD;AAErD,MAAI,CAACsB,QAAQE,QAAQuB,iBAAiB,OAAOzB,QAAQE,QAAQuB,kBAAkB,UAAU;AACvF,UAAM,IAAI1C,MAAM,qEAAA;EAClB;AACA,QAAMqD,mBAAeN,8BAAgD9B,QAAQE,QAAQuB,eAAe;IAAEjC,QAAQ;EAAM,CAAA;AACpH,QAAM6C,YAAYD,aAAaE;AAE/B,MAAID,cAAc,QAAQ;AACxB;EACF;AAEA,SAAOtC,WAAWC,SAAS;IAAE,GAAGtB;IAASgD,mBAAmB;EAAK,CAAA;AACnE;AAfsBS;;;ANzNtB,IAAAI,eAA6B;AARtB,IAAMC,cAAcC,0BAAQC;AAC5B,IAAMC,iBAAiBH,YAAYI,IAAI,yBAAA;","names":["import_ssi_types","SigningAlgo","defaultHasher","data","algorithm","shaHasher","check","value","description","Error","calculateJwkThumbprint","jwk","digestAlgorithm","TypeError","algorithm","components","kty","crv","x","y","e","n","k","toString","defaultHasher","JSON","stringify","getDigestAlgorithmFromJwkThumbprintUri","uri","match","calculateJwkThumbprintUri","thumbprint","slice","getDidJwtVerifier","jwt","options","type","header","kid","Error","alg","includes","method","didUrl","getIssuer","payload","client_id","iss","getX5cVerifier","x5c","Array","isArray","length","every","cert","issuer","getJwkVerifier","jwk","getJwtVerifierWithContext","startsWith","parseJWT","jwt","header","jwtDecode","payload","Error","DEFAULT_SKEW_TIME","getNowSkewed","now","skewTime","_now","epochTime","_skewTime","nowSkewedPast","nowSkewedFuture","Math","floor","Date","BASE64_URL_REGEX","isJws","jws","jwsParts","split","length","every","part","test","isJwe","jwe","jweParts","decodeProtectedHeader","decodeJwt","checkExp","input","exp","clockSkew","import_jwt_decode","import_uint8arrays","dpopTokenRequestNonceError","getCreateDPoPOptions","createDPoPClientOpts","endPointUrl","resourceRequestOpts","htu","split","jwtPayloadProps","htm","accessToken","createDPoP","options","createJwtCallback","jwtIssuer","dPoPSigningAlgValuesSupported","startsWith","Error","ath","toString","defaultHasher","undefined","method","type","alg","jwk","header","typ","payload","iat","epochTime","jti","uuidv4","verifyDPoP","request","dpop","headers","dPoPHeader","dPoPPayload","parseJWT","d","acceptedAlgorithms","includes","join","expectedNonce","nonce","verificationResult","jwtVerifyCallback","raw","error","message","currentUri","fullUrl","nowSkewedPast","nowSkewedFuture","getNowSkewed","now","maxIatAgeInSeconds","authorizationHeader","authorization","expectAccessToken","replace","expectedAth","accessTokenPayload","jwtDecode","cnf","jkt","thumprint","calculateJwkThumbprint","verifyResourceDPoP","tokenPayload","tokenType","token_type","import_uuid","VCI_LOGGERS","Loggers","DEFAULT","VCI_LOG_COMMON","get"]}
|
package/dist/index.js
CHANGED
|
@@ -15,22 +15,12 @@ var SigningAlgo = /* @__PURE__ */ function(SigningAlgo2) {
|
|
|
15
15
|
}({});
|
|
16
16
|
|
|
17
17
|
// lib/jwt/JwkThumbprint.ts
|
|
18
|
-
import
|
|
18
|
+
import { toString } from "uint8arrays";
|
|
19
19
|
|
|
20
20
|
// lib/hasher.ts
|
|
21
|
-
import
|
|
22
|
-
import * as u8a from "uint8arrays";
|
|
23
|
-
var supportedAlgorithms = [
|
|
24
|
-
"sha256",
|
|
25
|
-
"sha384",
|
|
26
|
-
"sha512"
|
|
27
|
-
];
|
|
21
|
+
import { shaHasher } from "@sphereon/ssi-types";
|
|
28
22
|
var defaultHasher = /* @__PURE__ */ __name((data, algorithm) => {
|
|
29
|
-
|
|
30
|
-
if (!supportedAlgorithms.includes(sanitizedAlgorithm)) {
|
|
31
|
-
throw new Error(`Unsupported hashing algorithm ${algorithm}`);
|
|
32
|
-
}
|
|
33
|
-
return new Uint8Array(sha(sanitizedAlgorithm).update(typeof data === "string" ? u8a.fromString(data) : data).digest());
|
|
23
|
+
return shaHasher(data, algorithm);
|
|
34
24
|
}, "defaultHasher");
|
|
35
25
|
|
|
36
26
|
// lib/jwt/JwkThumbprint.ts
|
|
@@ -88,7 +78,7 @@ async function calculateJwkThumbprint(jwk, digestAlgorithm) {
|
|
|
88
78
|
default:
|
|
89
79
|
throw Error('"kty" (Key Type) Parameter missing or unsupported');
|
|
90
80
|
}
|
|
91
|
-
return
|
|
81
|
+
return toString(defaultHasher(JSON.stringify(components), algorithm), "base64url");
|
|
92
82
|
}
|
|
93
83
|
__name(calculateJwkThumbprint, "calculateJwkThumbprint");
|
|
94
84
|
async function getDigestAlgorithmFromJwkThumbprintUri(uri) {
|
|
@@ -243,7 +233,7 @@ var checkExp = /* @__PURE__ */ __name((input) => {
|
|
|
243
233
|
|
|
244
234
|
// lib/dpop/DPoP.ts
|
|
245
235
|
import { jwtDecode as jwtDecode2 } from "jwt-decode";
|
|
246
|
-
import
|
|
236
|
+
import { toString as toString2 } from "uint8arrays";
|
|
247
237
|
import { v4 as uuidv4 } from "uuid";
|
|
248
238
|
var dpopTokenRequestNonceError = "use_dpop_nonce";
|
|
249
239
|
function getCreateDPoPOptions(createDPoPClientOpts, endPointUrl, resourceRequestOpts) {
|
|
@@ -266,7 +256,7 @@ async function createDPoP(options) {
|
|
|
266
256
|
if (jwtPayloadProps.accessToken && (jwtPayloadProps.accessToken?.startsWith("DPoP ") || jwtPayloadProps.accessToken?.startsWith("Bearer "))) {
|
|
267
257
|
throw new Error("expected access token without scheme");
|
|
268
258
|
}
|
|
269
|
-
const ath = jwtPayloadProps.accessToken ?
|
|
259
|
+
const ath = jwtPayloadProps.accessToken ? toString2(defaultHasher(jwtPayloadProps.accessToken, "sha256"), "base64url") : void 0;
|
|
270
260
|
return createJwtCallback({
|
|
271
261
|
method: "jwk",
|
|
272
262
|
type: "dpop",
|
|
@@ -356,7 +346,7 @@ async function verifyDPoP(request, options) {
|
|
|
356
346
|
throw new Error("invalid_dpop_proof. Invalid authorization header.");
|
|
357
347
|
}
|
|
358
348
|
const accessToken = authorizationHeader.replace("DPoP ", "");
|
|
359
|
-
const expectedAth =
|
|
349
|
+
const expectedAth = toString2(defaultHasher(accessToken, "sha256"), "base64url");
|
|
360
350
|
if (dPoPPayload.ath !== expectedAth) {
|
|
361
351
|
throw new Error("invalid_dpop_proof. Invalid ath claim");
|
|
362
352
|
}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../lib/index.ts","../lib/jwt/Jwt.types.ts","../lib/jwt/JwkThumbprint.ts","../lib/hasher.ts","../lib/jwt/JwtVerifier.ts","../lib/jwt/jwtUtils.ts","../lib/dpop/DPoP.ts"],"sourcesContent":["import { Loggers } from '@sphereon/ssi-types';\n\nexport const VCI_LOGGERS = Loggers.DEFAULT;\nexport const VCI_LOG_COMMON = VCI_LOGGERS.get('sphereon:oid4vci:common');\n\nexport * from './types';\nexport * from './jwt';\nexport * from './dpop';\nexport * from './oauth';\n\nexport { v4 as uuidv4 } from 'uuid';\nexport { defaultHasher } from './hasher';\n","import { JwtHeader as jwtDecodeJwtHeader, JwtPayload as jwtDecodePayload } from 'jwt-decode';\n\nimport { JWK } from './Jwk.types';\n\nexport type JwtHeader = jwtDecodeJwtHeader & {\n alg?: string;\n x5c?: string[];\n kid?: string;\n jwk?: JWK;\n jwt?: string;\n} & Record<string, unknown>;\n\nexport type JwtPayload = jwtDecodePayload & {\n client_id?: string;\n nonce?: string;\n request_uri?: string;\n client_id_scheme?: string;\n} & Record<string, unknown>;\n\nexport enum SigningAlgo {\n EDDSA = 'EdDSA',\n RS256 = 'RS256',\n PS256 = 'PS256',\n ES256 = 'ES256',\n ES256K = 'ES256K',\n}\n","// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nimport * as u8a from 'uint8arrays';\n\nimport { defaultHasher } from '../hasher';\nimport { DigestAlgorithm } from '../types';\n\nimport { JWK } from './Jwk.types';\n\nconst check = (value: unknown, description: string) => {\n if (typeof value !== 'string' || !value) {\n throw Error(`${description} missing or invalid`);\n }\n};\n\nexport async function calculateJwkThumbprint(jwk: JWK, digestAlgorithm?: DigestAlgorithm): Promise<string> {\n if (!jwk || typeof jwk !== 'object') {\n throw new TypeError('JWK must be an object');\n }\n const algorithm = digestAlgorithm ?? 'sha256';\n if (algorithm !== 'sha256' && algorithm !== 'sha384' && algorithm !== 'sha512') {\n throw new TypeError('digestAlgorithm must one of \"sha256\", \"sha384\", or \"sha512\"');\n }\n let components;\n switch (jwk.kty) {\n case 'EC':\n check(jwk.crv, '\"crv\" (Curve) Parameter');\n check(jwk.x, '\"x\" (X Coordinate) Parameter');\n check(jwk.y, '\"y\" (Y Coordinate) Parameter');\n components = { crv: jwk.crv, kty: jwk.kty, x: jwk.x, y: jwk.y };\n break;\n case 'OKP':\n check(jwk.crv, '\"crv\" (Subtype of Key Pair) Parameter');\n check(jwk.x, '\"x\" (Public Key) Parameter');\n components = { crv: jwk.crv, kty: jwk.kty, x: jwk.x };\n break;\n case 'RSA':\n check(jwk.e, '\"e\" (Exponent) Parameter');\n check(jwk.n, '\"n\" (Modulus) Parameter');\n components = { e: jwk.e, kty: jwk.kty, n: jwk.n };\n break;\n case 'oct':\n check(jwk.k, '\"k\" (Key Value) Parameter');\n components = { k: jwk.k, kty: jwk.kty };\n break;\n default:\n throw Error('\"kty\" (Key Type) Parameter missing or unsupported');\n }\n return u8a.toString(defaultHasher(JSON.stringify(components), algorithm), 'base64url');\n}\n\nexport async function getDigestAlgorithmFromJwkThumbprintUri(uri: string): Promise<DigestAlgorithm> {\n const match = uri.match(/^urn:ietf:params:oauth:jwk-thumbprint:sha-(\\w+):/);\n if (!match) {\n throw new Error(`Invalid JWK thumbprint URI structure ${uri}`);\n }\n const algorithm = `sha${match[1]}` as DigestAlgorithm;\n if (algorithm !== 'sha256' && algorithm !== 'sha384' && algorithm !== 'sha512') {\n throw new Error(`Invalid JWK thumbprint URI digest algorithm ${uri}`);\n }\n return algorithm;\n}\n\nexport async function calculateJwkThumbprintUri(jwk: JWK, digestAlgorithm: DigestAlgorithm = 'sha256'): Promise<string> {\n const thumbprint = await calculateJwkThumbprint(jwk, digestAlgorithm);\n return `urn:ietf:params:oauth:jwk-thumbprint:sha-${digestAlgorithm.slice(-3)}:${thumbprint}`;\n}\n","import { HasherSync } from '@sphereon/ssi-types';\nimport sha from 'sha.js';\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nimport * as u8a from 'uint8arrays';\n\nconst supportedAlgorithms = ['sha256', 'sha384', 'sha512'] as const;\ntype SupportedAlgorithms = (typeof supportedAlgorithms)[number];\n\nexport const defaultHasher: HasherSync = (data, algorithm) => {\n const sanitizedAlgorithm = algorithm.toLowerCase().replace(/[-_]/g, '');\n if (!supportedAlgorithms.includes(sanitizedAlgorithm as SupportedAlgorithms)) {\n throw new Error(`Unsupported hashing algorithm ${algorithm}`);\n }\n\n return new Uint8Array(\n sha(sanitizedAlgorithm as SupportedAlgorithms)\n .update(typeof data === 'string' ? u8a.fromString(data) : data)\n .digest(),\n );\n};\n","import { JWK } from './Jwk.types';\nimport { JwtHeader, JwtPayload, SigningAlgo } from './Jwt.types';\nimport { JwtProtectionMethod, JwtType } from './jwtUtils';\n\nexport interface JwtVerifierBase {\n type: JwtType;\n method: JwtProtectionMethod;\n}\n\nexport interface DidJwtVerifier extends JwtVerifierBase {\n method: 'did';\n\n alg: SigningAlgo | string;\n didUrl: string;\n}\n\nexport interface X5cJwtVerifier extends JwtVerifierBase {\n method: 'x5c';\n\n alg: SigningAlgo | string;\n\n /**\n *\n * Array of base64-encoded certificate strings in the DER-format.\n *\n * The certificate containing the public key corresponding to the key used to digitally sign the JWS MUST be the first certificate.\n */\n x5c: Array<string>;\n\n /**\n * The jwt issuer\n */\n issuer: string;\n}\n\nexport interface OpenIdFederationJwtVerifier extends JwtVerifierBase {\n method: 'openid-federation';\n\n /**\n * The OpenId federation Entity\n */\n entityId: string;\n}\n\nexport interface JwkJwtVerifier extends JwtVerifierBase {\n method: 'jwk';\n alg: SigningAlgo | string;\n\n jwk: JWK;\n}\n\nexport interface CustomJwtVerifier extends JwtVerifierBase {\n method: 'custom';\n}\n\nexport type JwtVerifier = DidJwtVerifier | X5cJwtVerifier | CustomJwtVerifier | JwkJwtVerifier | OpenIdFederationJwtVerifier;\n\nexport const getDidJwtVerifier = (jwt: { header: JwtHeader; payload: JwtPayload }, options: { type: JwtType }): DidJwtVerifier => {\n const { type } = options;\n if (!jwt.header.kid) throw new Error(`Received an invalid JWT. Missing kid header.`);\n if (!jwt.header.alg) throw new Error(`Received an invalid JWT. Missing alg header.`);\n\n if (!jwt.header.kid.includes('#')) {\n throw new Error(`Received an invalid JWT.. '${type}' contains an invalid kid header.`);\n }\n return { method: 'did', didUrl: jwt.header.kid, type: type, alg: jwt.header.alg };\n};\n\nconst getIssuer = (type: JwtType, payload: JwtPayload): string => {\n // For 'request-object' the `iss` value is not required so we map the issuer to client_id\n if (type === 'request-object') {\n if (!payload.client_id) {\n throw new Error('Missing required field client_id in request object JWT');\n }\n return payload.client_id as string;\n }\n\n if (typeof payload.iss !== 'string') {\n throw new Error(`Received an invalid JWT. '${type}' contains an invalid iss claim or it is missing.`);\n }\n return payload.iss;\n};\n\nexport const getX5cVerifier = (jwt: { header: JwtHeader; payload: JwtPayload }, options: { type: JwtType }): X5cJwtVerifier => {\n const { type } = options;\n if (!jwt.header.x5c) throw new Error(`Received an invalid JWT. Missing x5c header.`);\n if (!jwt.header.alg) throw new Error(`Received an invalid JWT. Missing alg header.`);\n\n if (!Array.isArray(jwt.header.x5c) || jwt.header.x5c.length === 0 || !jwt.header.x5c.every((cert) => typeof cert === 'string')) {\n throw new Error(`Received an invalid JWT.. '${type}' contains an invalid x5c header.`);\n }\n\n return {\n method: 'x5c',\n x5c: jwt.header.x5c,\n issuer: getIssuer(type, jwt.payload),\n type: type,\n alg: jwt.header.alg,\n };\n};\n\nexport const getJwkVerifier = async (jwt: { header: JwtHeader; payload: JwtPayload }, options: { type: JwtType }): Promise<JwkJwtVerifier> => {\n const { type } = options;\n if (!jwt.header.jwk) throw new Error(`Received an invalid JWT. Missing jwk header.`);\n if (!jwt.header.alg) throw new Error(`Received an invalid JWT. Missing alg header.`);\n\n if (typeof jwt.header.jwk !== 'object') {\n throw new Error(`Received an invalid JWT. '${type}' contains an invalid jwk header.`);\n }\n\n return { method: 'jwk', type, jwk: jwt.header.jwk, alg: jwt.header.alg };\n};\n\nexport const getJwtVerifierWithContext = async (\n jwt: { header: JwtHeader; payload: JwtPayload },\n options: { type: JwtType },\n): Promise<JwtVerifier> => {\n const { header, payload } = jwt;\n\n if (header.kid?.startsWith('did:')) return getDidJwtVerifier({ header, payload }, options);\n else if (jwt.header.x5c) return getX5cVerifier({ header, payload }, options);\n else if (jwt.header.jwk) return getJwkVerifier({ header, payload }, options);\n\n return { method: 'custom', type: options.type };\n};\n\nexport type VerifyJwtCallbackBase<T extends JwtVerifier> = (\n jwtVerifier: T,\n jwt: { header: JwtHeader; payload: JwtPayload; raw: string },\n) => Promise<boolean>;\n","import { jwtDecode } from 'jwt-decode';\n\nimport { JwtHeader, JwtPayload } from './Jwt.types';\n\nexport type JwtType = 'id-token' | 'request-object' | 'verifier-attestation' | 'dpop';\n\nexport type JwtProtectionMethod = 'did' | 'x5c' | 'jwk' | 'openid-federation' | 'custom';\n\nexport function parseJWT<Header = JwtHeader, Payload = JwtPayload>(jwt: string) {\n const header = jwtDecode<Header>(jwt, { header: true });\n const payload = jwtDecode<Payload>(jwt, { header: false });\n\n if (!payload || !header) {\n throw new Error('Jwt Payload and/or Header could not be parsed');\n }\n return { header, payload };\n}\n\n/**\n * The maximum allowed clock skew time in seconds. If an time based validation\n * is performed against current time (`now`), the validation can be of by the skew\n * time.\n *\n * See https://datatracker.ietf.org/doc/html/rfc7519#section-4.1.5\n */\nconst DEFAULT_SKEW_TIME = 60;\n\nexport function getNowSkewed(now?: number, skewTime?: number) {\n const _now = now ? now : epochTime();\n const _skewTime = skewTime ? skewTime : DEFAULT_SKEW_TIME;\n\n return {\n nowSkewedPast: _now - _skewTime,\n nowSkewedFuture: _now + _skewTime,\n };\n}\n\n/**\n * Returns the current unix timestamp in seconds.\n */\nexport function epochTime() {\n return Math.floor(Date.now() / 1000);\n}\n\nexport const BASE64_URL_REGEX = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/;\n\nexport const isJws = (jws: string) => {\n const jwsParts = jws.split('.');\n return jwsParts.length === 3 && jwsParts.every((part) => BASE64_URL_REGEX.test(part));\n};\nexport const isJwe = (jwe: string) => {\n const jweParts = jwe.split('.');\n return jweParts.length === 5 && jweParts.every((part) => BASE64_URL_REGEX.test(part));\n};\n\nexport const decodeProtectedHeader = (jwt: string) => {\n return jwtDecode(jwt, { header: true });\n};\n\nexport const decodeJwt = (jwt: string): JwtPayload => {\n return jwtDecode(jwt, { header: false });\n};\n\nexport const checkExp = (input: {\n exp: number;\n now?: number; // The number of milliseconds elapsed since midnight, January 1, 1970 Universal Coordinated Time (UTC).\n clockSkew?: number;\n}) => {\n const { exp, now, clockSkew } = input;\n return exp < (now ?? Date.now() / 1000) - (clockSkew ?? 120);\n};\n","import { jwtDecode } from 'jwt-decode';\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nimport * as u8a from 'uint8arrays';\nimport { v4 as uuidv4 } from 'uuid';\n\nimport { defaultHasher } from '../hasher';\nimport {\n calculateJwkThumbprint,\n CreateJwtCallback,\n epochTime,\n getNowSkewed,\n JWK,\n JwtHeader,\n JwtIssuerJwk,\n JwtPayload,\n parseJWT,\n SigningAlgo,\n VerifyJwtCallbackBase,\n} from '../jwt';\n\nexport const dpopTokenRequestNonceError = 'use_dpop_nonce';\n\nexport interface DPoPJwtIssuerWithContext extends JwtIssuerJwk {\n type: 'dpop';\n dPoPSigningAlgValuesSupported?: string[];\n}\n\nexport type DPoPJwtPayloadProps = {\n htu: string;\n iat: number;\n htm: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'HEAD' | 'OPTIONS' | 'TRACE' | 'CONNECT' | 'PATCH';\n ath?: string;\n nonce?: string;\n jti: string;\n};\nexport type DPoPJwtHeaderProps = { typ: 'dpop+jwt'; alg: SigningAlgo; jwk: JWK };\nexport type CreateDPoPJwtPayloadProps = Omit<DPoPJwtPayloadProps, 'iat' | 'jti' | 'ath'> & { accessToken?: string };\n\nexport interface CreateDPoPOpts<JwtPayloadProps = CreateDPoPJwtPayloadProps> {\n createJwtCallback: CreateJwtCallback<DPoPJwtIssuerWithContext>;\n jwtIssuer: Omit<JwtIssuerJwk, 'method' | 'type'>;\n jwtPayloadProps: Record<string, unknown> & JwtPayloadProps;\n dPoPSigningAlgValuesSupported?: (string | SigningAlgo)[];\n}\n\nexport type CreateDPoPClientOpts = CreateDPoPOpts<Omit<CreateDPoPJwtPayloadProps, 'htm' | 'htu'>>;\n\nexport function getCreateDPoPOptions(\n createDPoPClientOpts: CreateDPoPClientOpts,\n endPointUrl: string,\n resourceRequestOpts?: { accessToken: string },\n): CreateDPoPOpts {\n const htu = endPointUrl.split('?')[0].split('#')[0];\n return {\n ...createDPoPClientOpts,\n jwtPayloadProps: {\n ...createDPoPClientOpts.jwtPayloadProps,\n htu,\n htm: 'POST',\n ...(resourceRequestOpts && { accessToken: resourceRequestOpts.accessToken }),\n },\n };\n}\n\nexport async function createDPoP(options: CreateDPoPOpts): Promise<string> {\n const { createJwtCallback, jwtIssuer, jwtPayloadProps, dPoPSigningAlgValuesSupported } = options;\n\n if (jwtPayloadProps.accessToken && (jwtPayloadProps.accessToken?.startsWith('DPoP ') || jwtPayloadProps.accessToken?.startsWith('Bearer '))) {\n throw new Error('expected access token without scheme');\n }\n\n const ath = jwtPayloadProps.accessToken ? u8a.toString(defaultHasher(jwtPayloadProps.accessToken, 'sha256'), 'base64url') : undefined;\n return createJwtCallback(\n { method: 'jwk', type: 'dpop', alg: jwtIssuer.alg, jwk: jwtIssuer.jwk, dPoPSigningAlgValuesSupported },\n {\n header: { ...jwtIssuer, typ: 'dpop+jwt', alg: jwtIssuer.alg, jwk: jwtIssuer.jwk },\n payload: {\n ...jwtPayloadProps,\n iat: epochTime(),\n jti: uuidv4(),\n ...(ath && { ath }),\n },\n },\n );\n}\n\nexport type DPoPVerifyJwtCallback = VerifyJwtCallbackBase<JwtIssuerJwk & { type: 'dpop' }>;\nexport interface DPoPVerifyOptions {\n expectedNonce?: string;\n acceptedAlgorithms?: (string | SigningAlgo)[];\n // defaults to 300 seconds (5 minutes)\n maxIatAgeInSeconds?: number;\n expectAccessToken?: boolean;\n jwtVerifyCallback: DPoPVerifyJwtCallback;\n now?: number;\n}\n\nexport async function verifyDPoP(\n request: { headers: Record<string, string | string[] | undefined>; fullUrl: string } & Pick<Request, 'method'>,\n options: DPoPVerifyOptions,\n) {\n // There is not more than one DPoP HTTP request header field.\n const dpop = request.headers['dpop'];\n if (!dpop || typeof dpop !== 'string') {\n throw new Error('missing or invalid dpop header. Expected compact JWT');\n }\n\n // The DPoP HTTP request header field value is a single and well-formed JWT.\n const { header: dPoPHeader, payload: dPoPPayload } = parseJWT<JwtHeader, JwtPayload & Partial<DPoPJwtPayloadProps>>(dpop);\n\n // Ensure all required header claims are present\n if (dPoPHeader.typ !== 'dpop+jwt' || !dPoPHeader.alg || !dPoPHeader.jwk || typeof dPoPHeader.jwk !== 'object' || dPoPHeader.jwk.d) {\n throw new Error('invalid_dpop_proof. Invalid header claims');\n }\n\n // Ensure all required payload claims are present\n if (!dPoPPayload.htm || !dPoPPayload.htu || !dPoPPayload.iat || !dPoPPayload.jti) {\n throw new Error('invalid_dpop_proof. Missing required claims');\n }\n\n // Validate alg is supported\n if (options?.acceptedAlgorithms && !options.acceptedAlgorithms.includes(dPoPHeader.alg)) {\n throw new Error(`invalid_dpop_proof. Invalid 'alg' claim '${dPoPHeader.alg}'. Only ${options.acceptedAlgorithms.join(', ')} are supported.`);\n }\n\n // Validate nonce if provided\n if ((options?.expectedNonce && !dPoPPayload.nonce) || dPoPPayload.nonce !== options.expectedNonce) {\n throw new Error('invalid_dpop_proof. Nonce mismatch');\n }\n\n // Verify JWT signature\n try {\n const verificationResult = await options.jwtVerifyCallback(\n {\n method: 'jwk',\n type: 'dpop',\n jwk: dPoPHeader.jwk,\n alg: dPoPHeader.alg,\n },\n {\n header: dPoPHeader,\n payload: dPoPPayload,\n raw: dpop,\n },\n );\n\n if (!verificationResult) {\n throw new Error('invalid_dpop_proof. Invalid JWT signature');\n }\n } catch (error: unknown) {\n throw new Error('invalid_dpop_proof. Invalid JWT signature. ' + (error instanceof Error ? error.message : 'Unknown error'));\n }\n\n // Validate htm claim\n if (dPoPPayload.htm !== request.method) {\n throw new Error(`invalid_dpop_proof. Invalid htm claim. Must match request method '${request.method}'`);\n }\n\n // The htu claim matches the HTTP URI value for the HTTP request in which the JWT was received, ignoring any query and fragment parts.\n const currentUri = request.fullUrl.split('?')[0].split('#')[0];\n if (dPoPPayload.htu !== currentUri) {\n throw new Error('invalid_dpop_proof. Invalid htu claim');\n }\n\n // Validate nonce if provided\n if ((options.expectedNonce && dPoPPayload.nonce !== options.expectedNonce) || (!options.expectedNonce && dPoPPayload.nonce)) {\n throw new Error('invalid_dpop_proof. Nonce mismatch');\n }\n\n // Validate iat claim\n const { nowSkewedPast, nowSkewedFuture } = getNowSkewed(options.now);\n if (\n // iat claim is too far in the future\n nowSkewedPast - (options.maxIatAgeInSeconds ?? 60) > dPoPPayload.iat ||\n // iat claim is too old\n nowSkewedFuture + (options.maxIatAgeInSeconds ?? 60) < dPoPPayload.iat\n ) {\n // 5 minute window\n throw new Error('invalid_dpop_proof. Invalid iat claim');\n }\n\n // If access token is present, validate ath claim\n const authorizationHeader = request.headers.authorization;\n if (!options.expectAccessToken && authorizationHeader) {\n throw new Error('invalid_dpop_proof. Received an unexpected authorization header.');\n }\n\n if (options.expectAccessToken) {\n if (!dPoPPayload.ath) {\n throw new Error('invalid_dpop_proof. Missing expected ath claim.');\n }\n\n // validate that the DPOP proof is made for the provided access token\n if (!authorizationHeader || typeof authorizationHeader !== 'string' || !authorizationHeader.startsWith('DPoP ')) {\n throw new Error('invalid_dpop_proof. Invalid authorization header.');\n }\n\n const accessToken = authorizationHeader.replace('DPoP ', '');\n const expectedAth = u8a.toString(defaultHasher(accessToken, 'sha256'), 'base64url');\n if (dPoPPayload.ath !== expectedAth) {\n throw new Error('invalid_dpop_proof. Invalid ath claim');\n }\n\n // validate that the access token is signed with the same key as the DPOP proof\n const accessTokenPayload = jwtDecode<JwtPayload & { cnf?: { jkt?: string } }>(accessToken, { header: false });\n if (!accessTokenPayload.cnf?.jkt) {\n throw new Error('invalid_dpop_proof. Access token is missing the jkt claim');\n }\n\n const thumprint = await calculateJwkThumbprint(dPoPHeader.jwk, 'sha256');\n if (accessTokenPayload.cnf?.jkt !== thumprint) {\n throw new Error('invalid_dpop_proof. JwkThumbprint mismatch');\n }\n }\n\n // If all validations pass, return the dpop jwk\n return dPoPHeader.jwk;\n}\n\n/**\n * DPoP verifications for resource requests\n * For Bearer token compatibility jwt's must have a token_type claim\n * The access token itself must be validated before using this method\n * If the token_type is not DPoP, then the request is not a DPoP request\n * and we don't need to verify the DPoP proof\n */\nexport async function verifyResourceDPoP(\n request: { headers: Record<string, string | string[] | undefined>; fullUrl: string } & Pick<Request, 'method'>,\n options: Omit<DPoPVerifyOptions, 'expectAccessToken'>,\n) {\n if (!request.headers.authorization || typeof request.headers.authorization !== 'string') {\n throw new Error('Received an invalid resource request. Missing authorization header.');\n }\n const tokenPayload = jwtDecode<JwtPayload & { token_type?: string }>(request.headers.authorization, { header: false });\n const tokenType = tokenPayload.token_type;\n\n if (tokenType !== 'DPoP') {\n return;\n }\n\n return verifyDPoP(request, { ...options, expectAccessToken: true });\n}\n"],"mappings":";;;;AAAA,SAASA,eAAe;;;ACmBjB,IAAKC,cAAAA,yBAAAA,cAAAA;;;;;;SAAAA;;;;ACjBZ,YAAYC,UAAS;;;ACDrB,OAAOC,SAAS;AAGhB,YAAYC,SAAS;AAErB,IAAMC,sBAAsB;EAAC;EAAU;EAAU;;AAG1C,IAAMC,gBAA4B,wBAACC,MAAMC,cAAAA;AAC9C,QAAMC,qBAAqBD,UAAUE,YAAW,EAAGC,QAAQ,SAAS,EAAA;AACpE,MAAI,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orithm","toLowerCase","replace","includes","Error","Uint8Array","sha","update","fromString","digest","check","value","description","Error","calculateJwkThumbprint","jwk","digestAlgorithm","TypeError","algorithm","components","kty","crv","x","y","e","n","k","toString","defaultHasher","JSON","stringify","getDigestAlgorithmFromJwkThumbprintUri","uri","match","calculateJwkThumbprintUri","thumbprint","slice","getDidJwtVerifier","jwt","options","type","header","kid","Error","alg","includes","method","didUrl","getIssuer","payload","client_id","iss","getX5cVerifier","x5c","Array","isArray","length","every","cert","issuer","getJwkVerifier","jwk","getJwtVerifierWithContext","startsWith","jwtDecode","parseJWT","jwt","header","jwtDecode","payload","Error","DEFAULT_SKEW_TIME","getNowSkewed","now","skewTime","_now","epochTime","_skewTime","nowSkewedPast","nowSkewedFuture","Math","floor","Date","BASE64_URL_REGEX","isJws","jws","jwsParts","split","length","every","part","test","isJwe","jwe","jweParts","decodeProtectedHeader","decodeJwt","checkExp","input","exp","clockSkew","jwtDecode","u8a","v4","uuidv4","dpopTokenRequestNonceError","getCreateDPoPOptions","createDPoPClientOpts","endPointUrl","resourceRequestOpts","htu","split","jwtPayloadProps","htm","accessToken","createDPoP","options","createJwtCallback","jwtIssuer","dPoPSigningAlgValuesSupported","startsWith","Error","ath","toString","defaultHasher","undefined","method","type","alg","jwk","header","typ","payload","iat","epochTime","jti","uuidv4","verifyDPoP","request","dpop","headers","dPoPHeader","dPoPPayload","parseJWT","d","acceptedAlgorithms","includes","join","expectedNonce","nonce","verificationResult","jwtVerifyCallback","raw","error","message","currentUri","fullUrl","nowSkewedPast","nowSkewedFuture","getNowSkewed","now","maxIatAgeInSeconds","authorizationHeader","authorization","expectAccessToken","replace","expectedAth","accessTokenPayload","jwtDecode","cnf","jkt","thumprint","calculateJwkThumbprint","verifyResourceDPoP","tokenPayload","tokenType","token_type","uuidv4","VCI_LOGGERS","Loggers","DEFAULT","VCI_LOG_COMMON","get"]}
|
|
1
|
+
{"version":3,"sources":["../lib/index.ts","../lib/jwt/Jwt.types.ts","../lib/jwt/JwkThumbprint.ts","../lib/hasher.ts","../lib/jwt/JwtVerifier.ts","../lib/jwt/jwtUtils.ts","../lib/dpop/DPoP.ts"],"sourcesContent":["import { Loggers } from '@sphereon/ssi-types'\n\nexport const VCI_LOGGERS = Loggers.DEFAULT\nexport const VCI_LOG_COMMON = VCI_LOGGERS.get('sphereon:oid4vci:common')\n\nexport * from './types'\nexport * from './jwt'\nexport * from './dpop'\nexport * from './oauth'\n\nexport { v4 as uuidv4 } from 'uuid'\nexport { defaultHasher } from './hasher'\n","import { JwtHeader as jwtDecodeJwtHeader, JwtPayload as jwtDecodePayload } from 'jwt-decode'\n\nimport { JWK } from './Jwk.types'\n\nexport type JwtHeader = jwtDecodeJwtHeader & {\n alg?: string\n x5c?: string[]\n kid?: string\n jwk?: JWK\n jwt?: string\n} & Record<string, unknown>\n\nexport type JwtPayload = jwtDecodePayload & {\n client_id?: string\n nonce?: string\n request_uri?: string\n client_id_scheme?: string\n} & Record<string, unknown>\n\nexport enum SigningAlgo {\n EDDSA = 'EdDSA',\n RS256 = 'RS256',\n PS256 = 'PS256',\n ES256 = 'ES256',\n ES256K = 'ES256K',\n}\n","import { toString } from 'uint8arrays'\n\nimport { defaultHasher } from '../hasher'\nimport { DigestAlgorithm } from '../types'\n\nimport { JWK } from './Jwk.types'\n\nconst check = (value: unknown, description: string) => {\n if (typeof value !== 'string' || !value) {\n throw Error(`${description} missing or invalid`)\n }\n}\n\nexport async function calculateJwkThumbprint(jwk: JWK, digestAlgorithm?: DigestAlgorithm): Promise<string> {\n if (!jwk || typeof jwk !== 'object') {\n throw new TypeError('JWK must be an object')\n }\n const algorithm = digestAlgorithm ?? 'sha256'\n if (algorithm !== 'sha256' && algorithm !== 'sha384' && algorithm !== 'sha512') {\n throw new TypeError('digestAlgorithm must one of \"sha256\", \"sha384\", or \"sha512\"')\n }\n let components\n switch (jwk.kty) {\n case 'EC':\n check(jwk.crv, '\"crv\" (Curve) Parameter')\n check(jwk.x, '\"x\" (X Coordinate) Parameter')\n check(jwk.y, '\"y\" (Y Coordinate) Parameter')\n components = { crv: jwk.crv, kty: jwk.kty, x: jwk.x, y: jwk.y }\n break\n case 'OKP':\n check(jwk.crv, '\"crv\" (Subtype of Key Pair) Parameter')\n check(jwk.x, '\"x\" (Public Key) Parameter')\n components = { crv: jwk.crv, kty: jwk.kty, x: jwk.x }\n break\n case 'RSA':\n check(jwk.e, '\"e\" (Exponent) Parameter')\n check(jwk.n, '\"n\" (Modulus) Parameter')\n components = { e: jwk.e, kty: jwk.kty, n: jwk.n }\n break\n case 'oct':\n check(jwk.k, '\"k\" (Key Value) Parameter')\n components = { k: jwk.k, kty: jwk.kty }\n break\n default:\n throw Error('\"kty\" (Key Type) Parameter missing or unsupported')\n }\n return toString(defaultHasher(JSON.stringify(components), algorithm), 'base64url')\n}\n\nexport async function getDigestAlgorithmFromJwkThumbprintUri(uri: string): Promise<DigestAlgorithm> {\n const match = uri.match(/^urn:ietf:params:oauth:jwk-thumbprint:sha-(\\w+):/)\n if (!match) {\n throw new Error(`Invalid JWK thumbprint URI structure ${uri}`)\n }\n const algorithm = `sha${match[1]}` as DigestAlgorithm\n if (algorithm !== 'sha256' && algorithm !== 'sha384' && algorithm !== 'sha512') {\n throw new Error(`Invalid JWK thumbprint URI digest algorithm ${uri}`)\n }\n return algorithm\n}\n\nexport async function calculateJwkThumbprintUri(jwk: JWK, digestAlgorithm: DigestAlgorithm = 'sha256'): Promise<string> {\n const thumbprint = await calculateJwkThumbprint(jwk, digestAlgorithm)\n return `urn:ietf:params:oauth:jwk-thumbprint:sha-${digestAlgorithm.slice(-3)}:${thumbprint}`\n}\n","import { HasherSync, shaHasher } from '@sphereon/ssi-types'\n\nexport const defaultHasher: HasherSync = (data: string | ArrayBuffer, algorithm: string) => {\n return shaHasher(data, algorithm)\n}\n","import { JWK } from './Jwk.types'\nimport { JwtHeader, JwtPayload, SigningAlgo } from './Jwt.types'\nimport { JwtProtectionMethod, JwtType } from './jwtUtils'\n\nexport interface JwtVerifierBase {\n type: JwtType\n method: JwtProtectionMethod\n}\n\nexport interface DidJwtVerifier extends JwtVerifierBase {\n method: 'did'\n\n alg: SigningAlgo | string\n didUrl: string\n}\n\nexport interface X5cJwtVerifier extends JwtVerifierBase {\n method: 'x5c'\n\n alg: SigningAlgo | string\n\n /**\n *\n * Array of base64-encoded certificate strings in the DER-format.\n *\n * The certificate containing the public key corresponding to the key used to digitally sign the JWS MUST be the first certificate.\n */\n x5c: Array<string>\n\n /**\n * The jwt issuer\n */\n issuer: string\n}\n\nexport interface OpenIdFederationJwtVerifier extends JwtVerifierBase {\n method: 'openid-federation'\n\n /**\n * The OpenId federation Entity\n */\n entityId: string\n}\n\nexport interface JwkJwtVerifier extends JwtVerifierBase {\n method: 'jwk'\n alg: SigningAlgo | string\n\n jwk: JWK\n}\n\nexport interface CustomJwtVerifier extends JwtVerifierBase {\n method: 'custom'\n}\n\nexport type JwtVerifier = DidJwtVerifier | X5cJwtVerifier | CustomJwtVerifier | JwkJwtVerifier | OpenIdFederationJwtVerifier\n\nexport const getDidJwtVerifier = (jwt: { header: JwtHeader; payload: JwtPayload }, options: { type: JwtType }): DidJwtVerifier => {\n const { type } = options\n if (!jwt.header.kid) throw new Error(`Received an invalid JWT. Missing kid header.`)\n if (!jwt.header.alg) throw new Error(`Received an invalid JWT. Missing alg header.`)\n\n if (!jwt.header.kid.includes('#')) {\n throw new Error(`Received an invalid JWT.. '${type}' contains an invalid kid header.`)\n }\n return { method: 'did', didUrl: jwt.header.kid, type: type, alg: jwt.header.alg }\n}\n\nconst getIssuer = (type: JwtType, payload: JwtPayload): string => {\n // For 'request-object' the `iss` value is not required so we map the issuer to client_id\n if (type === 'request-object') {\n if (!payload.client_id) {\n throw new Error('Missing required field client_id in request object JWT')\n }\n return payload.client_id as string\n }\n\n if (typeof payload.iss !== 'string') {\n throw new Error(`Received an invalid JWT. '${type}' contains an invalid iss claim or it is missing.`)\n }\n return payload.iss\n}\n\nexport const getX5cVerifier = (jwt: { header: JwtHeader; payload: JwtPayload }, options: { type: JwtType }): X5cJwtVerifier => {\n const { type } = options\n if (!jwt.header.x5c) throw new Error(`Received an invalid JWT. Missing x5c header.`)\n if (!jwt.header.alg) throw new Error(`Received an invalid JWT. Missing alg header.`)\n\n if (!Array.isArray(jwt.header.x5c) || jwt.header.x5c.length === 0 || !jwt.header.x5c.every((cert) => typeof cert === 'string')) {\n throw new Error(`Received an invalid JWT.. '${type}' contains an invalid x5c header.`)\n }\n\n return {\n method: 'x5c',\n x5c: jwt.header.x5c,\n issuer: getIssuer(type, jwt.payload),\n type: type,\n alg: jwt.header.alg,\n }\n}\n\nexport const getJwkVerifier = async (jwt: { header: JwtHeader; payload: JwtPayload }, options: { type: JwtType }): Promise<JwkJwtVerifier> => {\n const { type } = options\n if (!jwt.header.jwk) throw new Error(`Received an invalid JWT. Missing jwk header.`)\n if (!jwt.header.alg) throw new Error(`Received an invalid JWT. Missing alg header.`)\n\n if (typeof jwt.header.jwk !== 'object') {\n throw new Error(`Received an invalid JWT. '${type}' contains an invalid jwk header.`)\n }\n\n return { method: 'jwk', type, jwk: jwt.header.jwk, alg: jwt.header.alg }\n}\n\nexport const getJwtVerifierWithContext = async (\n jwt: { header: JwtHeader; payload: JwtPayload },\n options: { type: JwtType },\n): Promise<JwtVerifier> => {\n const { header, payload } = jwt\n\n if (header.kid?.startsWith('did:')) return getDidJwtVerifier({ header, payload }, options)\n else if (jwt.header.x5c) return getX5cVerifier({ header, payload }, options)\n else if (jwt.header.jwk) return getJwkVerifier({ header, payload }, options)\n\n return { method: 'custom', type: options.type }\n}\n\nexport type VerifyJwtCallbackBase<T extends JwtVerifier> = (\n jwtVerifier: T,\n jwt: { header: JwtHeader; payload: JwtPayload; raw: string },\n) => Promise<boolean>\n","import { jwtDecode } from 'jwt-decode'\n\nimport { JwtHeader, JwtPayload } from './Jwt.types'\n\nexport type JwtType = 'id-token' | 'request-object' | 'verifier-attestation' | 'dpop'\n\nexport type JwtProtectionMethod = 'did' | 'x5c' | 'jwk' | 'openid-federation' | 'custom'\n\nexport function parseJWT<Header = JwtHeader, Payload = JwtPayload>(jwt: string) {\n const header = jwtDecode<Header>(jwt, { header: true })\n const payload = jwtDecode<Payload>(jwt, { header: false })\n\n if (!payload || !header) {\n throw new Error('Jwt Payload and/or Header could not be parsed')\n }\n return { header, payload }\n}\n\n/**\n * The maximum allowed clock skew time in seconds. If an time based validation\n * is performed against current time (`now`), the validation can be of by the skew\n * time.\n *\n * See https://datatracker.ietf.org/doc/html/rfc7519#section-4.1.5\n */\nconst DEFAULT_SKEW_TIME = 60\n\nexport function getNowSkewed(now?: number, skewTime?: number) {\n const _now = now ? now : epochTime()\n const _skewTime = skewTime ? skewTime : DEFAULT_SKEW_TIME\n\n return {\n nowSkewedPast: _now - _skewTime,\n nowSkewedFuture: _now + _skewTime,\n }\n}\n\n/**\n * Returns the current unix timestamp in seconds.\n */\nexport function epochTime() {\n return Math.floor(Date.now() / 1000)\n}\n\nexport const BASE64_URL_REGEX = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/\n\nexport const isJws = (jws: string) => {\n const jwsParts = jws.split('.')\n return jwsParts.length === 3 && jwsParts.every((part) => BASE64_URL_REGEX.test(part))\n}\nexport const isJwe = (jwe: string) => {\n const jweParts = jwe.split('.')\n return jweParts.length === 5 && jweParts.every((part) => BASE64_URL_REGEX.test(part))\n}\n\nexport const decodeProtectedHeader = (jwt: string) => {\n return jwtDecode(jwt, { header: true })\n}\n\nexport const decodeJwt = (jwt: string): JwtPayload => {\n return jwtDecode(jwt, { header: false })\n}\n\nexport const checkExp = (input: {\n exp: number\n now?: number // The number of milliseconds elapsed since midnight, January 1, 1970 Universal Coordinated Time (UTC).\n clockSkew?: number\n}) => {\n const { exp, now, clockSkew } = input\n return exp < (now ?? Date.now() / 1000) - (clockSkew ?? 120)\n}\n","import { jwtDecode } from 'jwt-decode'\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nimport { fromString, toString } from 'uint8arrays'\nimport { v4 as uuidv4 } from 'uuid'\n\nimport { defaultHasher } from '../hasher'\nimport {\n calculateJwkThumbprint,\n CreateJwtCallback,\n epochTime,\n getNowSkewed,\n JWK,\n JwtHeader,\n JwtIssuerJwk,\n JwtPayload,\n parseJWT,\n SigningAlgo,\n VerifyJwtCallbackBase,\n} from '../jwt'\n\nexport const dpopTokenRequestNonceError = 'use_dpop_nonce'\n\nexport interface DPoPJwtIssuerWithContext extends JwtIssuerJwk {\n type: 'dpop'\n dPoPSigningAlgValuesSupported?: string[]\n}\n\nexport type DPoPJwtPayloadProps = {\n htu: string\n iat: number\n htm: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'HEAD' | 'OPTIONS' | 'TRACE' | 'CONNECT' | 'PATCH'\n ath?: string\n nonce?: string\n jti: string\n}\nexport type DPoPJwtHeaderProps = { typ: 'dpop+jwt'; alg: SigningAlgo; jwk: JWK }\nexport type CreateDPoPJwtPayloadProps = Omit<DPoPJwtPayloadProps, 'iat' | 'jti' | 'ath'> & { accessToken?: string }\n\nexport interface CreateDPoPOpts<JwtPayloadProps = CreateDPoPJwtPayloadProps> {\n createJwtCallback: CreateJwtCallback<DPoPJwtIssuerWithContext>\n jwtIssuer: Omit<JwtIssuerJwk, 'method' | 'type'>\n jwtPayloadProps: Record<string, unknown> & JwtPayloadProps\n dPoPSigningAlgValuesSupported?: (string | SigningAlgo)[]\n}\n\nexport type CreateDPoPClientOpts = CreateDPoPOpts<Omit<CreateDPoPJwtPayloadProps, 'htm' | 'htu'>>\n\nexport function getCreateDPoPOptions(\n createDPoPClientOpts: CreateDPoPClientOpts,\n endPointUrl: string,\n resourceRequestOpts?: { accessToken: string },\n): CreateDPoPOpts {\n const htu = endPointUrl.split('?')[0].split('#')[0]\n return {\n ...createDPoPClientOpts,\n jwtPayloadProps: {\n ...createDPoPClientOpts.jwtPayloadProps,\n htu,\n htm: 'POST',\n ...(resourceRequestOpts && { accessToken: resourceRequestOpts.accessToken }),\n },\n }\n}\n\nexport async function createDPoP(options: CreateDPoPOpts): Promise<string> {\n const { createJwtCallback, jwtIssuer, jwtPayloadProps, dPoPSigningAlgValuesSupported } = options\n\n if (jwtPayloadProps.accessToken && (jwtPayloadProps.accessToken?.startsWith('DPoP ') || jwtPayloadProps.accessToken?.startsWith('Bearer '))) {\n throw new Error('expected access token without scheme')\n }\n\n const ath = jwtPayloadProps.accessToken ? toString(defaultHasher(jwtPayloadProps.accessToken, 'sha256'), 'base64url') : undefined\n return createJwtCallback(\n { method: 'jwk', type: 'dpop', alg: jwtIssuer.alg, jwk: jwtIssuer.jwk, dPoPSigningAlgValuesSupported },\n {\n header: { ...jwtIssuer, typ: 'dpop+jwt', alg: jwtIssuer.alg, jwk: jwtIssuer.jwk },\n payload: {\n ...jwtPayloadProps,\n iat: epochTime(),\n jti: uuidv4(),\n ...(ath && { ath }),\n },\n },\n )\n}\n\nexport type DPoPVerifyJwtCallback = VerifyJwtCallbackBase<JwtIssuerJwk & { type: 'dpop' }>\nexport interface DPoPVerifyOptions {\n expectedNonce?: string\n acceptedAlgorithms?: (string | SigningAlgo)[]\n // defaults to 300 seconds (5 minutes)\n maxIatAgeInSeconds?: number\n expectAccessToken?: boolean\n jwtVerifyCallback: DPoPVerifyJwtCallback\n now?: number\n}\n\nexport async function verifyDPoP(\n request: { headers: Record<string, string | string[] | undefined>; fullUrl: string } & Pick<Request, 'method'>,\n options: DPoPVerifyOptions,\n) {\n // There is not more than one DPoP HTTP request header field.\n const dpop = request.headers['dpop']\n if (!dpop || typeof dpop !== 'string') {\n throw new Error('missing or invalid dpop header. Expected compact JWT')\n }\n\n // The DPoP HTTP request header field value is a single and well-formed JWT.\n const { header: dPoPHeader, payload: dPoPPayload } = parseJWT<JwtHeader, JwtPayload & Partial<DPoPJwtPayloadProps>>(dpop)\n\n // Ensure all required header claims are present\n if (dPoPHeader.typ !== 'dpop+jwt' || !dPoPHeader.alg || !dPoPHeader.jwk || typeof dPoPHeader.jwk !== 'object' || dPoPHeader.jwk.d) {\n throw new Error('invalid_dpop_proof. Invalid header claims')\n }\n\n // Ensure all required payload claims are present\n if (!dPoPPayload.htm || !dPoPPayload.htu || !dPoPPayload.iat || !dPoPPayload.jti) {\n throw new Error('invalid_dpop_proof. Missing required claims')\n }\n\n // Validate alg is supported\n if (options?.acceptedAlgorithms && !options.acceptedAlgorithms.includes(dPoPHeader.alg)) {\n throw new Error(`invalid_dpop_proof. Invalid 'alg' claim '${dPoPHeader.alg}'. Only ${options.acceptedAlgorithms.join(', ')} are supported.`)\n }\n\n // Validate nonce if provided\n if ((options?.expectedNonce && !dPoPPayload.nonce) || dPoPPayload.nonce !== options.expectedNonce) {\n throw new Error('invalid_dpop_proof. Nonce mismatch')\n }\n\n // Verify JWT signature\n try {\n const verificationResult = await options.jwtVerifyCallback(\n {\n method: 'jwk',\n type: 'dpop',\n jwk: dPoPHeader.jwk,\n alg: dPoPHeader.alg,\n },\n {\n header: dPoPHeader,\n payload: dPoPPayload,\n raw: dpop,\n },\n )\n\n if (!verificationResult) {\n throw new Error('invalid_dpop_proof. Invalid JWT signature')\n }\n } catch (error: unknown) {\n throw new Error('invalid_dpop_proof. Invalid JWT signature. ' + (error instanceof Error ? error.message : 'Unknown error'))\n }\n\n // Validate htm claim\n if (dPoPPayload.htm !== request.method) {\n throw new Error(`invalid_dpop_proof. Invalid htm claim. Must match request method '${request.method}'`)\n }\n\n // The htu claim matches the HTTP URI value for the HTTP request in which the JWT was received, ignoring any query and fragment parts.\n const currentUri = request.fullUrl.split('?')[0].split('#')[0]\n if (dPoPPayload.htu !== currentUri) {\n throw new Error('invalid_dpop_proof. Invalid htu claim')\n }\n\n // Validate nonce if provided\n if ((options.expectedNonce && dPoPPayload.nonce !== options.expectedNonce) || (!options.expectedNonce && dPoPPayload.nonce)) {\n throw new Error('invalid_dpop_proof. Nonce mismatch')\n }\n\n // Validate iat claim\n const { nowSkewedPast, nowSkewedFuture } = getNowSkewed(options.now)\n if (\n // iat claim is too far in the future\n nowSkewedPast - (options.maxIatAgeInSeconds ?? 60) > dPoPPayload.iat ||\n // iat claim is too old\n nowSkewedFuture + (options.maxIatAgeInSeconds ?? 60) < dPoPPayload.iat\n ) {\n // 5 minute window\n throw new Error('invalid_dpop_proof. Invalid iat claim')\n }\n\n // If access token is present, validate ath claim\n const authorizationHeader = request.headers.authorization\n if (!options.expectAccessToken && authorizationHeader) {\n throw new Error('invalid_dpop_proof. Received an unexpected authorization header.')\n }\n\n if (options.expectAccessToken) {\n if (!dPoPPayload.ath) {\n throw new Error('invalid_dpop_proof. Missing expected ath claim.')\n }\n\n // validate that the DPOP proof is made for the provided access token\n if (!authorizationHeader || typeof authorizationHeader !== 'string' || !authorizationHeader.startsWith('DPoP ')) {\n throw new Error('invalid_dpop_proof. Invalid authorization header.')\n }\n\n const accessToken = authorizationHeader.replace('DPoP ', '')\n const expectedAth = toString(defaultHasher(accessToken, 'sha256'), 'base64url')\n if (dPoPPayload.ath !== expectedAth) {\n throw new Error('invalid_dpop_proof. Invalid ath claim')\n }\n\n // validate that the access token is signed with the same key as the DPOP proof\n const accessTokenPayload = jwtDecode<JwtPayload & { cnf?: { jkt?: string } }>(accessToken, { header: false })\n if (!accessTokenPayload.cnf?.jkt) {\n throw new Error('invalid_dpop_proof. Access token is missing the jkt claim')\n }\n\n const thumprint = await calculateJwkThumbprint(dPoPHeader.jwk, 'sha256')\n if (accessTokenPayload.cnf?.jkt !== thumprint) {\n throw new Error('invalid_dpop_proof. JwkThumbprint mismatch')\n }\n }\n\n // If all validations pass, return the dpop jwk\n return dPoPHeader.jwk\n}\n\n/**\n * DPoP verifications for resource requests\n * For Bearer token compatibility jwt's must have a token_type claim\n * The access token itself must be validated before using this method\n * If the token_type is not DPoP, then the request is not a DPoP request\n * and we don't need to verify the DPoP proof\n */\nexport async function verifyResourceDPoP(\n request: { headers: Record<string, string | string[] | undefined>; fullUrl: string } & Pick<Request, 'method'>,\n options: Omit<DPoPVerifyOptions, 'expectAccessToken'>,\n) {\n if (!request.headers.authorization || typeof request.headers.authorization !== 'string') {\n throw new Error('Received an invalid resource request. Missing authorization header.')\n }\n const tokenPayload = jwtDecode<JwtPayload & { token_type?: string }>(request.headers.authorization, { header: false })\n const tokenType = tokenPayload.token_type\n\n if (tokenType !== 'DPoP') {\n return\n }\n\n return verifyDPoP(request, { ...options, expectAccessToken: true })\n}\n"],"mappings":";;;;AAAA,SAASA,eAAe;;;ACmBjB,IAAKC,cAAAA,yBAAAA,cAAAA;;;;;;SAAAA;;;;ACnBZ,SAASC,gBAAgB;;;ACAzB,SAAqBC,iBAAiB;AAE/B,IAAMC,gBAA4B,wBAACC,MAA4BC,cAAAA;AACpE,SAAOC,UAAUF,MAAMC,SAAAA;AACzB,GAFyC;;;ADKzC,IAAME,QAAQ,wBAACC,OAAgBC,gBAAAA;AAC7B,MAAI,OAAOD,UAAU,YAAY,CAACA,OAAO;AACvC,UAAME,MAAM,GAAGD,WAAAA,qBAAgC;EACjD;AACF,GAJc;AAMd,eAAsBE,uBAAuBC,KAAUC,iBAAiC;AACtF,MAAI,CAACD,OAAO,OAAOA,QAAQ,UAAU;AACnC,UAAM,IAAIE,UAAU,uBAAA;EACtB;AACA,QAAMC,YAAYF,mBAAmB;AACrC,MAAIE,cAAc,YAAYA,cAAc,YAAYA,cAAc,UAAU;AAC9E,UAAM,IAAID,UAAU,6DAAA;EACtB;AACA,MAAIE;AACJ,UAAQJ,IAAIK,KAAG;IACb,KAAK;AACHV,YAAMK,IAAIM,KAAK,yBAAA;AACfX,YAAMK,IAAIO,GAAG,8BAAA;AACbZ,YAAMK,IAAIQ,GAAG,8BAAA;AACbJ,mBAAa;QAAEE,KAAKN,IAAIM;QAAKD,KAAKL,IAAIK;QAAKE,GAAGP,IAAIO;QAAGC,GAAGR,IAAIQ;MAAE;AAC9D;IACF,KAAK;AACHb,YAAMK,IAAIM,KAAK,uCAAA;AACfX,YAAMK,IAAIO,GAAG,4BAAA;AACbH,mBAAa;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B;EACF;AAEA,SAAOtC,WAAWC,SAAS;IAAE,GAAGtB;IAASgD,mBAAmB;EAAK,CAAA;AACnE;AAfsBS;;;ANzNtB,SAAeI,UAAc;AARtB,IAAMC,cAAcC,QAAQC;AAC5B,IAAMC,iBAAiBH,YAAYI,IAAI,yBAAA;","names":["Loggers","SigningAlgo","toString","shaHasher","defaultHasher","data","algorithm","shaHasher","check","value","description","Error","calculateJwkThumbprint","jwk","digestAlgorithm","TypeError","algorithm","components","kty","crv","x","y","e","n","k","toString","defaultHasher","JSON","stringify","getDigestAlgorithmFromJwkThumbprintUri","uri","match","calculateJwkThumbprintUri","thumbprint","slice","getDidJwtVerifier","jwt","options","type","header","kid","Error","alg","includes","method","didUrl","getIssuer","payload","client_id","iss","getX5cVerifier","x5c","Array","isArray","length","every","cert","issuer","getJwkVerifier","jwk","getJwtVerifierWithContext","startsWith","jwtDecode","parseJWT","jwt","header","jwtDecode","payload","Error","DEFAULT_SKEW_TIME","getNowSkewed","now","skewTime","_now","epochTime","_skewTime","nowSkewedPast","nowSkewedFuture","Math","floor","Date","BASE64_URL_REGEX","isJws","jws","jwsParts","split","length","every","part","test","isJwe","jwe","jweParts","decodeProtectedHeader","decodeJwt","checkExp","input","exp","clockSkew","jwtDecode","toString","v4","uuidv4","dpopTokenRequestNonceError","getCreateDPoPOptions","createDPoPClientOpts","endPointUrl","resourceRequestOpts","htu","split","jwtPayloadProps","htm","accessToken","createDPoP","options","createJwtCallback","jwtIssuer","dPoPSigningAlgValuesSupported","startsWith","Error","ath","toString","defaultHasher","undefined","method","type","alg","jwk","header","typ","payload","iat","epochTime","jti","uuidv4","verifyDPoP","request","dpop","headers","dPoPHeader","dPoPPayload","parseJWT","d","acceptedAlgorithms","includes","join","expectedNonce","nonce","verificationResult","jwtVerifyCallback","raw","error","message","currentUri","fullUrl","nowSkewedPast","nowSkewedFuture","getNowSkewed","now","maxIatAgeInSeconds","authorizationHeader","authorization","expectAccessToken","replace","expectedAth","accessTokenPayload","jwtDecode","cnf","jkt","thumprint","calculateJwkThumbprint","verifyResourceDPoP","tokenPayload","tokenType","token_type","uuidv4","VCI_LOGGERS","Loggers","DEFAULT","VCI_LOG_COMMON","get"]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sphereon/oid4vc-common",
|
|
3
|
-
"version": "0.17.1-feature.esm.cjs.
|
|
3
|
+
"version": "0.17.1-feature.esm.cjs.31+b8ff6cb",
|
|
4
4
|
"description": "OpenID 4 Verifiable Credentials Common",
|
|
5
|
+
"source": "./src/index.ts",
|
|
5
6
|
"type": "module",
|
|
6
7
|
"main": "./dist/index.cjs",
|
|
7
8
|
"module": "./dist/index.js",
|
|
@@ -23,12 +24,10 @@
|
|
|
23
24
|
"dependencies": {
|
|
24
25
|
"@sphereon/ssi-types": "^0.33",
|
|
25
26
|
"jwt-decode": "^4.0.0",
|
|
26
|
-
"
|
|
27
|
-
"uint8arrays": "3.1.1",
|
|
27
|
+
"uint8arrays": "^5.1.0",
|
|
28
28
|
"uuid": "^9.0.0"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@types/sha.js": "^2.4.4",
|
|
32
31
|
"@types/uuid": "^9.0.1",
|
|
33
32
|
"typescript": "5.8.3"
|
|
34
33
|
},
|
|
@@ -36,12 +35,11 @@
|
|
|
36
35
|
"node": ">=20"
|
|
37
36
|
},
|
|
38
37
|
"files": [
|
|
39
|
-
"
|
|
38
|
+
"src",
|
|
39
|
+
"dist",
|
|
40
|
+
"README.md",
|
|
41
|
+
"LICENSE.md"
|
|
40
42
|
],
|
|
41
|
-
"prettier": {
|
|
42
|
-
"singleQuote": true,
|
|
43
|
-
"printWidth": 150
|
|
44
|
-
},
|
|
45
43
|
"keywords": [
|
|
46
44
|
"Sphereon",
|
|
47
45
|
"Verifiable Credentials",
|
|
@@ -61,5 +59,5 @@
|
|
|
61
59
|
"publishConfig": {
|
|
62
60
|
"access": "public"
|
|
63
61
|
},
|
|
64
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "b8ff6cb8c7ca78acfc2dffab080ac03ea24ee8d5"
|
|
65
63
|
}
|