did-jwt-vc
Advanced tools
Comparing version 3.1.3 to 3.1.4
@@ -73,4 +73,2 @@ import { decodeJWT, JWT_ERROR, verifyJWT, createJWT } from 'did-jwt'; | ||
function normalizeJwtCredentialPayload(input, removeOriginalFields = true) { | ||
var _input$vc, _input$credentialSubj, _result$vc2, _input$vc2; | ||
let result = deepCopy(input); | ||
@@ -84,6 +82,6 @@ | ||
result.credentialSubject = { ...input.credentialSubject, | ||
...((_input$vc = input.vc) == null ? void 0 : _input$vc.credentialSubject) | ||
...input.vc?.credentialSubject | ||
}; | ||
if (input.sub && !((_input$credentialSubj = input.credentialSubject) != null && _input$credentialSubj.id) && result.credentialSubject) { | ||
if (input.sub && !input.credentialSubject?.id && result.credentialSubject) { | ||
result.credentialSubject.id = input.sub; | ||
@@ -97,10 +95,6 @@ | ||
if (removeOriginalFields) { | ||
var _result$vc; | ||
(_result$vc = result.vc) == null ? true : delete _result$vc.credentialSubject; | ||
delete result.vc?.credentialSubject; | ||
} | ||
if (typeof input.issuer === 'undefined' || typeof input.issuer === 'object') { | ||
var _input$issuer; | ||
result.issuer = cleanUndefined({ | ||
@@ -111,3 +105,3 @@ id: input.iss, | ||
if (removeOriginalFields && !((_input$issuer = input.issuer) != null && _input$issuer.id)) { | ||
if (removeOriginalFields && !input.issuer?.id) { | ||
delete result.iss; | ||
@@ -125,9 +119,7 @@ } | ||
const types = [...asArray(result.type), ...asArray((_result$vc2 = result.vc) == null ? void 0 : _result$vc2.type)].filter(notEmpty); | ||
const types = [...asArray(result.type), ...asArray(result.vc?.type)].filter(notEmpty); | ||
result.type = [...new Set(types)]; | ||
if (removeOriginalFields) { | ||
var _result$vc3; | ||
(_result$vc3 = result.vc) == null ? true : delete _result$vc3.type; | ||
delete result.vc?.type; | ||
} | ||
@@ -147,10 +139,8 @@ | ||
const contextArray = [...asArray(input.context), ...asArray(input['@context']), ...asArray((_input$vc2 = input.vc) == null ? void 0 : _input$vc2['@context'])].filter(notEmpty); | ||
const contextArray = [...asArray(input.context), ...asArray(input['@context']), ...asArray(input.vc?.['@context'])].filter(notEmpty); | ||
result['@context'] = [...new Set(contextArray)]; | ||
if (removeOriginalFields) { | ||
var _result$vc4; | ||
delete result.context; | ||
(_result$vc4 = result.vc) == null ? true : delete _result$vc4['@context']; | ||
delete result.vc?.['@context']; | ||
} | ||
@@ -213,4 +203,2 @@ | ||
function normalizeCredential(input, removeOriginalFields = true) { | ||
var _input$proof; | ||
if (typeof input === 'string') { | ||
@@ -230,3 +218,3 @@ if (JWT_FORMAT.test(input)) { | ||
} | ||
} else if ((_input$proof = input.proof) != null && _input$proof.jwt) { | ||
} else if (input.proof?.jwt) { | ||
// TODO: test that it correctly propagates app specific proof properties | ||
@@ -253,4 +241,2 @@ return deepCopy({ ...normalizeJwtCredential(input.proof.jwt, removeOriginalFields), | ||
function transformCredentialInput(input, removeOriginalFields = true) { | ||
var _input$vc3, _input$vc4, _input$vc5; | ||
if (Array.isArray(input.credentialSubject)) throw Error('credentialSubject of type array not supported'); | ||
@@ -264,10 +250,8 @@ const result = deepCopy({ | ||
const credentialSubject = { ...input.credentialSubject, | ||
...((_input$vc3 = input.vc) == null ? void 0 : _input$vc3.credentialSubject) | ||
...input.vc?.credentialSubject | ||
}; | ||
if (!input.sub) { | ||
var _input$credentialSubj2; | ||
result.sub = input.credentialSubject?.id; | ||
result.sub = (_input$credentialSubj2 = input.credentialSubject) == null ? void 0 : _input$credentialSubj2.id; | ||
if (removeOriginalFields) { | ||
@@ -278,3 +262,3 @@ delete credentialSubject.id; | ||
const contextEntries = [...asArray(input.context), ...asArray(input['@context']), ...asArray((_input$vc4 = input.vc) == null ? void 0 : _input$vc4['@context'])].filter(notEmpty); | ||
const contextEntries = [...asArray(input.context), ...asArray(input['@context']), ...asArray(input.vc?.['@context'])].filter(notEmpty); | ||
result.vc['@context'] = [...new Set(contextEntries)]; | ||
@@ -287,3 +271,3 @@ | ||
const types = [...asArray(input.type), ...asArray((_input$vc5 = input.vc) == null ? void 0 : _input$vc5.type)].filter(notEmpty); | ||
const types = [...asArray(input.type), ...asArray(input.vc?.type)].filter(notEmpty); | ||
result.vc.type = [...new Set(types)]; | ||
@@ -329,6 +313,4 @@ | ||
if (typeof input.issuer === 'object') { | ||
var _input$issuer2; | ||
result.iss = input.issuer?.id; | ||
result.iss = (_input$issuer2 = input.issuer) == null ? void 0 : _input$issuer2.id; | ||
if (removeOriginalFields) { | ||
@@ -372,6 +354,4 @@ delete result.issuer.id; | ||
function normalizeJwtPresentationPayload(input, removeOriginalFields = true) { | ||
var _input$vp, _input$vp2, _input$vp3; | ||
const result = deepCopy(input); | ||
result.verifiableCredential = [...asArray(input.verifiableCredential), ...asArray((_input$vp = input.vp) == null ? void 0 : _input$vp.verifiableCredential)].filter(notEmpty); | ||
result.verifiableCredential = [...asArray(input.verifiableCredential), ...asArray(input.vp?.verifiableCredential)].filter(notEmpty); | ||
result.verifiableCredential = result.verifiableCredential.map(cred => { | ||
@@ -382,5 +362,3 @@ return normalizeCredential(cred, removeOriginalFields); | ||
if (removeOriginalFields) { | ||
var _result$vp; | ||
(_result$vp = result.vp) == null ? true : delete _result$vp.verifiableCredential; | ||
delete result.vp?.verifiableCredential; | ||
} | ||
@@ -413,19 +391,15 @@ | ||
const types = [...asArray(input.type), ...asArray((_input$vp2 = input.vp) == null ? void 0 : _input$vp2.type)].filter(notEmpty); | ||
const types = [...asArray(input.type), ...asArray(input.vp?.type)].filter(notEmpty); | ||
result.type = [...new Set(types)]; | ||
if (removeOriginalFields) { | ||
var _result$vp2; | ||
(_result$vp2 = result.vp) == null ? true : delete _result$vp2.type; | ||
delete result.vp?.type; | ||
} | ||
const contexts = [...asArray(input.context), ...asArray(input['@context']), ...asArray((_input$vp3 = input.vp) == null ? void 0 : _input$vp3['@context'])].filter(notEmpty); | ||
const contexts = [...asArray(input.context), ...asArray(input['@context']), ...asArray(input.vp?.['@context'])].filter(notEmpty); | ||
result['@context'] = [...new Set(contexts)]; | ||
if (removeOriginalFields) { | ||
var _result$vp3; | ||
delete result.context; | ||
(_result$vp3 = result.vp) == null ? true : delete _result$vp3['@context']; | ||
delete result.vp?.['@context']; | ||
} | ||
@@ -485,4 +459,2 @@ | ||
function normalizePresentation(input, removeOriginalFields = true) { | ||
var _input$proof2; | ||
if (typeof input === 'string') { | ||
@@ -502,3 +474,3 @@ if (JWT_FORMAT.test(input)) { | ||
} | ||
} else if ((_input$proof2 = input.proof) != null && _input$proof2.jwt) { | ||
} else if (input.proof?.jwt) { | ||
// TODO: test that it correctly propagates app specific proof properties | ||
@@ -525,4 +497,2 @@ return { ...normalizeJwtPresentation(input.proof.jwt, removeOriginalFields), | ||
function transformPresentationInput(input, removeOriginalFields = true) { | ||
var _input$vp4, _input$vp5, _result$vp4; | ||
const result = deepCopy({ | ||
@@ -534,3 +504,3 @@ vp: { ...input.vp | ||
result.vp = result.vp; | ||
const contextEntries = [...asArray(input.context), ...asArray(input['@context']), ...asArray((_input$vp4 = input.vp) == null ? void 0 : _input$vp4['@context'])].filter(notEmpty); | ||
const contextEntries = [...asArray(input.context), ...asArray(input['@context']), ...asArray(input.vp?.['@context'])].filter(notEmpty); | ||
result.vp['@context'] = [...new Set(contextEntries)]; | ||
@@ -543,3 +513,3 @@ | ||
const types = [...asArray(input.type), ...asArray((_input$vp5 = input.vp) == null ? void 0 : _input$vp5.type)].filter(notEmpty); | ||
const types = [...asArray(input.type), ...asArray(input.vp?.type)].filter(notEmpty); | ||
result.vp.type = [...new Set(types)]; | ||
@@ -583,9 +553,5 @@ | ||
if (result.verifiableCredential || (_result$vp4 = result.vp) != null && _result$vp4.verifiableCredential) { | ||
var _result$vp5; | ||
result.vp.verifiableCredential = [...asArray(result.verifiableCredential), ...asArray((_result$vp5 = result.vp) == null ? void 0 : _result$vp5.verifiableCredential)].filter(notEmpty).map(credential => { | ||
var _credential$proof; | ||
if (typeof credential === 'object' && (_credential$proof = credential.proof) != null && _credential$proof.jwt) { | ||
if (result.verifiableCredential || result.vp?.verifiableCredential) { | ||
result.vp.verifiableCredential = [...asArray(result.verifiableCredential), ...asArray(result.vp?.verifiableCredential)].filter(notEmpty).map(credential => { | ||
if (typeof credential === 'object' && credential.proof?.jwt) { | ||
return credential.proof.jwt; | ||
@@ -720,10 +686,8 @@ } else { | ||
try { | ||
var _options6, _options6$policies, _options7, _options7$policies, _options8; | ||
const nbf = ((_options6 = options) == null ? void 0 : (_options6$policies = _options6.policies) == null ? void 0 : _options6$policies.issuanceDate) === false ? false : undefined; | ||
const exp = ((_options7 = options) == null ? void 0 : (_options7$policies = _options7.policies) == null ? void 0 : _options7$policies.expirationDate) === false ? false : undefined; | ||
const nbf = options?.policies?.issuanceDate === false ? false : undefined; | ||
const exp = options?.policies?.expirationDate === false ? false : undefined; | ||
options = { | ||
audience: options.domain, | ||
...options, | ||
policies: { ...((_options8 = options) == null ? void 0 : _options8.policies), | ||
policies: { ...options?.policies, | ||
nbf, | ||
@@ -738,8 +702,6 @@ exp, | ||
})).then(function (verified) { | ||
var _options9, _options10, _options10$policies; | ||
verifyPresentationPayloadOptions(verified.payload, options); | ||
verified.verifiablePresentation = normalizePresentation(verified.jwt, (_options9 = options) == null ? void 0 : _options9.removeOriginalFields); | ||
verified.verifiablePresentation = normalizePresentation(verified.jwt, options?.removeOriginalFields); | ||
if (((_options10 = options) == null ? void 0 : (_options10$policies = _options10.policies) == null ? void 0 : _options10$policies.format) !== false) { | ||
if (options?.policies?.format !== false) { | ||
validatePresentationPayload(verified.verifiablePresentation); | ||
@@ -767,8 +729,6 @@ } | ||
try { | ||
var _options, _options$policies, _options2, _options2$policies, _options3; | ||
const nbf = ((_options = options) == null ? void 0 : (_options$policies = _options.policies) == null ? void 0 : _options$policies.issuanceDate) === false ? false : undefined; | ||
const exp = ((_options2 = options) == null ? void 0 : (_options2$policies = _options2.policies) == null ? void 0 : _options2$policies.expirationDate) === false ? false : undefined; | ||
const nbf = options?.policies?.issuanceDate === false ? false : undefined; | ||
const exp = options?.policies?.expirationDate === false ? false : undefined; | ||
options = { ...options, | ||
policies: { ...((_options3 = options) == null ? void 0 : _options3.policies), | ||
policies: { ...options?.policies, | ||
nbf, | ||
@@ -783,7 +743,5 @@ exp, | ||
})).then(function (verified) { | ||
var _options4, _options5, _options5$policies; | ||
verified.verifiableCredential = normalizeCredential(verified.jwt, options?.removeOriginalFields); | ||
verified.verifiableCredential = normalizeCredential(verified.jwt, (_options4 = options) == null ? void 0 : _options4.removeOriginalFields); | ||
if (((_options5 = options) == null ? void 0 : (_options5$policies = _options5.policies) == null ? void 0 : _options5$policies.format) !== false) { | ||
if (options?.policies?.format !== false) { | ||
validateCredentialPayload(verified.verifiableCredential); | ||
@@ -825,7 +783,5 @@ } | ||
try { | ||
var _options$header2; | ||
const parsedPayload = { | ||
iat: undefined, | ||
...transformPresentationInput(payload, options == null ? void 0 : options.removeOriginalFields) | ||
...transformPresentationInput(payload, options?.removeOriginalFields) | ||
}; // add challenge to nonce | ||
@@ -848,3 +804,3 @@ | ||
}, { ...options.header, | ||
alg: holder.alg || ((_options$header2 = options.header) == null ? void 0 : _options$header2.alg) || JWT_ALG | ||
alg: holder.alg || options.header?.alg || JWT_ALG | ||
})); | ||
@@ -874,4 +830,2 @@ } catch (e) { | ||
try { | ||
var _options$header; | ||
const parsedPayload = { | ||
@@ -886,3 +840,3 @@ iat: undefined, | ||
}, { ...options.header, | ||
alg: issuer.alg || ((_options$header = options.header) == null ? void 0 : _options$header.alg) || JWT_ALG | ||
alg: issuer.alg || options.header?.alg || JWT_ALG | ||
})); | ||
@@ -889,0 +843,0 @@ } catch (e) { |
@@ -76,4 +76,2 @@ (function (global, factory) { | ||
function normalizeJwtCredentialPayload(input, removeOriginalFields = true) { | ||
var _input$vc, _input$credentialSubj, _result$vc2, _input$vc2; | ||
let result = deepCopy(input); | ||
@@ -87,6 +85,6 @@ | ||
result.credentialSubject = { ...input.credentialSubject, | ||
...((_input$vc = input.vc) == null ? void 0 : _input$vc.credentialSubject) | ||
...input.vc?.credentialSubject | ||
}; | ||
if (input.sub && !((_input$credentialSubj = input.credentialSubject) != null && _input$credentialSubj.id) && result.credentialSubject) { | ||
if (input.sub && !input.credentialSubject?.id && result.credentialSubject) { | ||
result.credentialSubject.id = input.sub; | ||
@@ -100,10 +98,6 @@ | ||
if (removeOriginalFields) { | ||
var _result$vc; | ||
(_result$vc = result.vc) == null ? true : delete _result$vc.credentialSubject; | ||
delete result.vc?.credentialSubject; | ||
} | ||
if (typeof input.issuer === 'undefined' || typeof input.issuer === 'object') { | ||
var _input$issuer; | ||
result.issuer = cleanUndefined({ | ||
@@ -114,3 +108,3 @@ id: input.iss, | ||
if (removeOriginalFields && !((_input$issuer = input.issuer) != null && _input$issuer.id)) { | ||
if (removeOriginalFields && !input.issuer?.id) { | ||
delete result.iss; | ||
@@ -128,9 +122,7 @@ } | ||
const types = [...asArray(result.type), ...asArray((_result$vc2 = result.vc) == null ? void 0 : _result$vc2.type)].filter(notEmpty); | ||
const types = [...asArray(result.type), ...asArray(result.vc?.type)].filter(notEmpty); | ||
result.type = [...new Set(types)]; | ||
if (removeOriginalFields) { | ||
var _result$vc3; | ||
(_result$vc3 = result.vc) == null ? true : delete _result$vc3.type; | ||
delete result.vc?.type; | ||
} | ||
@@ -150,10 +142,8 @@ | ||
const contextArray = [...asArray(input.context), ...asArray(input['@context']), ...asArray((_input$vc2 = input.vc) == null ? void 0 : _input$vc2['@context'])].filter(notEmpty); | ||
const contextArray = [...asArray(input.context), ...asArray(input['@context']), ...asArray(input.vc?.['@context'])].filter(notEmpty); | ||
result['@context'] = [...new Set(contextArray)]; | ||
if (removeOriginalFields) { | ||
var _result$vc4; | ||
delete result.context; | ||
(_result$vc4 = result.vc) == null ? true : delete _result$vc4['@context']; | ||
delete result.vc?.['@context']; | ||
} | ||
@@ -216,4 +206,2 @@ | ||
function normalizeCredential(input, removeOriginalFields = true) { | ||
var _input$proof; | ||
if (typeof input === 'string') { | ||
@@ -233,3 +221,3 @@ if (JWT_FORMAT.test(input)) { | ||
} | ||
} else if ((_input$proof = input.proof) != null && _input$proof.jwt) { | ||
} else if (input.proof?.jwt) { | ||
// TODO: test that it correctly propagates app specific proof properties | ||
@@ -256,4 +244,2 @@ return deepCopy({ ...normalizeJwtCredential(input.proof.jwt, removeOriginalFields), | ||
function transformCredentialInput(input, removeOriginalFields = true) { | ||
var _input$vc3, _input$vc4, _input$vc5; | ||
if (Array.isArray(input.credentialSubject)) throw Error('credentialSubject of type array not supported'); | ||
@@ -267,10 +253,8 @@ const result = deepCopy({ | ||
const credentialSubject = { ...input.credentialSubject, | ||
...((_input$vc3 = input.vc) == null ? void 0 : _input$vc3.credentialSubject) | ||
...input.vc?.credentialSubject | ||
}; | ||
if (!input.sub) { | ||
var _input$credentialSubj2; | ||
result.sub = input.credentialSubject?.id; | ||
result.sub = (_input$credentialSubj2 = input.credentialSubject) == null ? void 0 : _input$credentialSubj2.id; | ||
if (removeOriginalFields) { | ||
@@ -281,3 +265,3 @@ delete credentialSubject.id; | ||
const contextEntries = [...asArray(input.context), ...asArray(input['@context']), ...asArray((_input$vc4 = input.vc) == null ? void 0 : _input$vc4['@context'])].filter(notEmpty); | ||
const contextEntries = [...asArray(input.context), ...asArray(input['@context']), ...asArray(input.vc?.['@context'])].filter(notEmpty); | ||
result.vc['@context'] = [...new Set(contextEntries)]; | ||
@@ -290,3 +274,3 @@ | ||
const types = [...asArray(input.type), ...asArray((_input$vc5 = input.vc) == null ? void 0 : _input$vc5.type)].filter(notEmpty); | ||
const types = [...asArray(input.type), ...asArray(input.vc?.type)].filter(notEmpty); | ||
result.vc.type = [...new Set(types)]; | ||
@@ -332,6 +316,4 @@ | ||
if (typeof input.issuer === 'object') { | ||
var _input$issuer2; | ||
result.iss = input.issuer?.id; | ||
result.iss = (_input$issuer2 = input.issuer) == null ? void 0 : _input$issuer2.id; | ||
if (removeOriginalFields) { | ||
@@ -375,6 +357,4 @@ delete result.issuer.id; | ||
function normalizeJwtPresentationPayload(input, removeOriginalFields = true) { | ||
var _input$vp, _input$vp2, _input$vp3; | ||
const result = deepCopy(input); | ||
result.verifiableCredential = [...asArray(input.verifiableCredential), ...asArray((_input$vp = input.vp) == null ? void 0 : _input$vp.verifiableCredential)].filter(notEmpty); | ||
result.verifiableCredential = [...asArray(input.verifiableCredential), ...asArray(input.vp?.verifiableCredential)].filter(notEmpty); | ||
result.verifiableCredential = result.verifiableCredential.map(cred => { | ||
@@ -385,5 +365,3 @@ return normalizeCredential(cred, removeOriginalFields); | ||
if (removeOriginalFields) { | ||
var _result$vp; | ||
(_result$vp = result.vp) == null ? true : delete _result$vp.verifiableCredential; | ||
delete result.vp?.verifiableCredential; | ||
} | ||
@@ -416,19 +394,15 @@ | ||
const types = [...asArray(input.type), ...asArray((_input$vp2 = input.vp) == null ? void 0 : _input$vp2.type)].filter(notEmpty); | ||
const types = [...asArray(input.type), ...asArray(input.vp?.type)].filter(notEmpty); | ||
result.type = [...new Set(types)]; | ||
if (removeOriginalFields) { | ||
var _result$vp2; | ||
(_result$vp2 = result.vp) == null ? true : delete _result$vp2.type; | ||
delete result.vp?.type; | ||
} | ||
const contexts = [...asArray(input.context), ...asArray(input['@context']), ...asArray((_input$vp3 = input.vp) == null ? void 0 : _input$vp3['@context'])].filter(notEmpty); | ||
const contexts = [...asArray(input.context), ...asArray(input['@context']), ...asArray(input.vp?.['@context'])].filter(notEmpty); | ||
result['@context'] = [...new Set(contexts)]; | ||
if (removeOriginalFields) { | ||
var _result$vp3; | ||
delete result.context; | ||
(_result$vp3 = result.vp) == null ? true : delete _result$vp3['@context']; | ||
delete result.vp?.['@context']; | ||
} | ||
@@ -488,4 +462,2 @@ | ||
function normalizePresentation(input, removeOriginalFields = true) { | ||
var _input$proof2; | ||
if (typeof input === 'string') { | ||
@@ -505,3 +477,3 @@ if (JWT_FORMAT.test(input)) { | ||
} | ||
} else if ((_input$proof2 = input.proof) != null && _input$proof2.jwt) { | ||
} else if (input.proof?.jwt) { | ||
// TODO: test that it correctly propagates app specific proof properties | ||
@@ -528,4 +500,2 @@ return { ...normalizeJwtPresentation(input.proof.jwt, removeOriginalFields), | ||
function transformPresentationInput(input, removeOriginalFields = true) { | ||
var _input$vp4, _input$vp5, _result$vp4; | ||
const result = deepCopy({ | ||
@@ -537,3 +507,3 @@ vp: { ...input.vp | ||
result.vp = result.vp; | ||
const contextEntries = [...asArray(input.context), ...asArray(input['@context']), ...asArray((_input$vp4 = input.vp) == null ? void 0 : _input$vp4['@context'])].filter(notEmpty); | ||
const contextEntries = [...asArray(input.context), ...asArray(input['@context']), ...asArray(input.vp?.['@context'])].filter(notEmpty); | ||
result.vp['@context'] = [...new Set(contextEntries)]; | ||
@@ -546,3 +516,3 @@ | ||
const types = [...asArray(input.type), ...asArray((_input$vp5 = input.vp) == null ? void 0 : _input$vp5.type)].filter(notEmpty); | ||
const types = [...asArray(input.type), ...asArray(input.vp?.type)].filter(notEmpty); | ||
result.vp.type = [...new Set(types)]; | ||
@@ -586,9 +556,5 @@ | ||
if (result.verifiableCredential || (_result$vp4 = result.vp) != null && _result$vp4.verifiableCredential) { | ||
var _result$vp5; | ||
result.vp.verifiableCredential = [...asArray(result.verifiableCredential), ...asArray((_result$vp5 = result.vp) == null ? void 0 : _result$vp5.verifiableCredential)].filter(notEmpty).map(credential => { | ||
var _credential$proof; | ||
if (typeof credential === 'object' && (_credential$proof = credential.proof) != null && _credential$proof.jwt) { | ||
if (result.verifiableCredential || result.vp?.verifiableCredential) { | ||
result.vp.verifiableCredential = [...asArray(result.verifiableCredential), ...asArray(result.vp?.verifiableCredential)].filter(notEmpty).map(credential => { | ||
if (typeof credential === 'object' && credential.proof?.jwt) { | ||
return credential.proof.jwt; | ||
@@ -723,10 +689,8 @@ } else { | ||
try { | ||
var _options6, _options6$policies, _options7, _options7$policies, _options8; | ||
const nbf = ((_options6 = options) == null ? void 0 : (_options6$policies = _options6.policies) == null ? void 0 : _options6$policies.issuanceDate) === false ? false : undefined; | ||
const exp = ((_options7 = options) == null ? void 0 : (_options7$policies = _options7.policies) == null ? void 0 : _options7$policies.expirationDate) === false ? false : undefined; | ||
const nbf = options?.policies?.issuanceDate === false ? false : undefined; | ||
const exp = options?.policies?.expirationDate === false ? false : undefined; | ||
options = { | ||
audience: options.domain, | ||
...options, | ||
policies: { ...((_options8 = options) == null ? void 0 : _options8.policies), | ||
policies: { ...options?.policies, | ||
nbf, | ||
@@ -741,8 +705,6 @@ exp, | ||
})).then(function (verified) { | ||
var _options9, _options10, _options10$policies; | ||
verifyPresentationPayloadOptions(verified.payload, options); | ||
verified.verifiablePresentation = normalizePresentation(verified.jwt, (_options9 = options) == null ? void 0 : _options9.removeOriginalFields); | ||
verified.verifiablePresentation = normalizePresentation(verified.jwt, options?.removeOriginalFields); | ||
if (((_options10 = options) == null ? void 0 : (_options10$policies = _options10.policies) == null ? void 0 : _options10$policies.format) !== false) { | ||
if (options?.policies?.format !== false) { | ||
validatePresentationPayload(verified.verifiablePresentation); | ||
@@ -770,8 +732,6 @@ } | ||
try { | ||
var _options, _options$policies, _options2, _options2$policies, _options3; | ||
const nbf = ((_options = options) == null ? void 0 : (_options$policies = _options.policies) == null ? void 0 : _options$policies.issuanceDate) === false ? false : undefined; | ||
const exp = ((_options2 = options) == null ? void 0 : (_options2$policies = _options2.policies) == null ? void 0 : _options2$policies.expirationDate) === false ? false : undefined; | ||
const nbf = options?.policies?.issuanceDate === false ? false : undefined; | ||
const exp = options?.policies?.expirationDate === false ? false : undefined; | ||
options = { ...options, | ||
policies: { ...((_options3 = options) == null ? void 0 : _options3.policies), | ||
policies: { ...options?.policies, | ||
nbf, | ||
@@ -786,7 +746,5 @@ exp, | ||
})).then(function (verified) { | ||
var _options4, _options5, _options5$policies; | ||
verified.verifiableCredential = normalizeCredential(verified.jwt, options?.removeOriginalFields); | ||
verified.verifiableCredential = normalizeCredential(verified.jwt, (_options4 = options) == null ? void 0 : _options4.removeOriginalFields); | ||
if (((_options5 = options) == null ? void 0 : (_options5$policies = _options5.policies) == null ? void 0 : _options5$policies.format) !== false) { | ||
if (options?.policies?.format !== false) { | ||
validateCredentialPayload(verified.verifiableCredential); | ||
@@ -828,7 +786,5 @@ } | ||
try { | ||
var _options$header2; | ||
const parsedPayload = { | ||
iat: undefined, | ||
...transformPresentationInput(payload, options == null ? void 0 : options.removeOriginalFields) | ||
...transformPresentationInput(payload, options?.removeOriginalFields) | ||
}; // add challenge to nonce | ||
@@ -851,3 +807,3 @@ | ||
}, { ...options.header, | ||
alg: holder.alg || ((_options$header2 = options.header) == null ? void 0 : _options$header2.alg) || JWT_ALG | ||
alg: holder.alg || options.header?.alg || JWT_ALG | ||
})); | ||
@@ -877,4 +833,2 @@ } catch (e) { | ||
try { | ||
var _options$header; | ||
const parsedPayload = { | ||
@@ -889,3 +843,3 @@ iat: undefined, | ||
}, { ...options.header, | ||
alg: issuer.alg || ((_options$header = options.header) == null ? void 0 : _options$header.alg) || JWT_ALG | ||
alg: issuer.alg || options.header?.alg || JWT_ALG | ||
})); | ||
@@ -892,0 +846,0 @@ } catch (e) { |
{ | ||
"name": "did-jwt-vc", | ||
"version": "3.1.3", | ||
"version": "3.1.4", | ||
"description": "Create and verify W3C Verifiable Credentials and Presentations in JWT format", | ||
@@ -39,3 +39,3 @@ "type": "module", | ||
"dependencies": { | ||
"did-jwt": "^6.11.0", | ||
"did-jwt": "^7.0.0", | ||
"did-resolver": "^4.0.0" | ||
@@ -85,4 +85,4 @@ }, | ||
"engines": { | ||
"node": ">=14" | ||
"node": ">=18" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
611264
6670
+ Added@multiformats/base-x@4.0.1(transitive)
+ Added@noble/ciphers@0.4.1(transitive)
+ Added@noble/curves@1.8.0(transitive)
+ Added@noble/hashes@1.7.0(transitive)
+ Added@scure/base@1.2.1(transitive)
+ Addeddid-jwt@7.4.7(transitive)
+ Addedmultibase@4.0.6(transitive)
- Removed@stablelib/aead@1.0.1(transitive)
- Removed@stablelib/binary@1.0.1(transitive)
- Removed@stablelib/bytes@1.0.1(transitive)
- Removed@stablelib/chacha@1.0.1(transitive)
- Removed@stablelib/chacha20poly1305@1.0.1(transitive)
- Removed@stablelib/constant-time@1.0.1(transitive)
- Removed@stablelib/ed25519@1.0.3(transitive)
- Removed@stablelib/hash@1.0.1(transitive)
- Removed@stablelib/int@1.0.1(transitive)
- Removed@stablelib/keyagreement@1.0.1(transitive)
- Removed@stablelib/poly1305@1.0.1(transitive)
- Removed@stablelib/random@1.0.2(transitive)
- Removed@stablelib/sha256@1.0.1(transitive)
- Removed@stablelib/sha512@1.0.1(transitive)
- Removed@stablelib/wipe@1.0.1(transitive)
- Removed@stablelib/x25519@1.0.3(transitive)
- Removed@stablelib/xchacha20@1.0.1(transitive)
- Removed@stablelib/xchacha20poly1305@1.0.1(transitive)
- Removedbech32@2.0.0(transitive)
- Removedbn.js@4.12.1(transitive)
- Removedbrorand@1.1.0(transitive)
- Removeddid-jwt@6.11.6(transitive)
- Removedelliptic@6.6.1(transitive)
- Removedhash.js@1.1.7(transitive)
- Removedhmac-drbg@1.0.1(transitive)
- Removedinherits@2.0.4(transitive)
- Removedjs-sha3@0.8.0(transitive)
- Removedminimalistic-assert@1.0.1(transitive)
- Removedminimalistic-crypto-utils@1.0.1(transitive)
Updateddid-jwt@^7.0.0