@sphereon/oid4vc-common
Advanced tools
Comparing version 0.16.1-next.26 to 0.16.1-next.29
@@ -25,2 +25,15 @@ "use strict"; | ||
exports.getDidJwtVerifier = getDidJwtVerifier; | ||
const getIssuer = (type, payload) => { | ||
// For 'request-object' the `iss` value is not required so we map the issuer to client_id | ||
if (type === 'request-object') { | ||
if (!payload.client_id) { | ||
throw new Error('Missing required field client_id in request object JWT'); | ||
} | ||
return payload.client_id; | ||
} | ||
if (typeof payload.iss !== 'string') { | ||
throw new Error(`Received an invalid JWT. '${type}' contains an invalid iss claim or it is missing.`); | ||
} | ||
return payload.iss; | ||
}; | ||
const getX5cVerifier = (jwt, options) => { | ||
@@ -35,6 +48,9 @@ const { type } = options; | ||
} | ||
if (typeof jwt.payload.iss !== 'string') { | ||
throw new Error(`Received an invalid JWT. '${type}' contains an invalid iss claim.`); | ||
} | ||
return { method: 'x5c', x5c: jwt.header.x5c, issuer: jwt.payload.iss, type: type, alg: jwt.header.alg }; | ||
return { | ||
method: 'x5c', | ||
x5c: jwt.header.x5c, | ||
issuer: getIssuer(type, jwt.payload), | ||
type: type, | ||
alg: jwt.header.alg, | ||
}; | ||
}; | ||
@@ -41,0 +57,0 @@ exports.getX5cVerifier = getX5cVerifier; |
@@ -69,2 +69,17 @@ import { JWK, JwtHeader, JwtPayload, SigningAlgo } from '..'; | ||
const getIssuer = (type: JwtType, payload: JwtPayload): string => { | ||
// For 'request-object' the `iss` value is not required so we map the issuer to client_id | ||
if (type === 'request-object') { | ||
if (!payload.client_id) { | ||
throw new Error('Missing required field client_id in request object JWT'); | ||
} | ||
return payload.client_id as string; | ||
} | ||
if (typeof payload.iss !== 'string') { | ||
throw new Error(`Received an invalid JWT. '${type}' contains an invalid iss claim or it is missing.`); | ||
} | ||
return payload.iss; | ||
}; | ||
export const getX5cVerifier = (jwt: { header: JwtHeader; payload: JwtPayload }, options: { type: JwtType }): X5cJwtVerifier => { | ||
@@ -79,7 +94,9 @@ const { type } = options; | ||
if (typeof jwt.payload.iss !== 'string') { | ||
throw new Error(`Received an invalid JWT. '${type}' contains an invalid iss claim.`); | ||
} | ||
return { method: 'x5c', x5c: jwt.header.x5c, issuer: jwt.payload.iss, type: type, alg: jwt.header.alg }; | ||
return { | ||
method: 'x5c', | ||
x5c: jwt.header.x5c, | ||
issuer: getIssuer(type, jwt.payload), | ||
type: type, | ||
alg: jwt.header.alg, | ||
}; | ||
}; | ||
@@ -86,0 +103,0 @@ |
{ | ||
"name": "@sphereon/oid4vc-common", | ||
"version": "0.16.1-next.26+0a6c8e3", | ||
"version": "0.16.1-next.29+b9236ad", | ||
"description": "OpenID 4 Verifiable Credentials Common", | ||
@@ -55,3 +55,3 @@ "source": "lib/index.ts", | ||
}, | ||
"gitHead": "0a6c8e3b94ddf6a3942ec03eaf2fabbf4100ff41" | ||
"gitHead": "b9236ad206b2d438c9a8a5dcbe3c6a1df91f7ed8" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
98248
1454