did-jwt-vc
Advanced tools
Comparing version 2.1.2 to 2.1.3
@@ -0,1 +1,8 @@ | ||
## [2.1.3](https://github.com/decentralized-identity/did-jwt-vc/compare/2.1.2...2.1.3) (2021-06-16) | ||
### Bug Fixes | ||
* w3c additional props should not be overwritten inside JWT ([#78](https://github.com/decentralized-identity/did-jwt-vc/issues/78)) ([d2a5c44](https://github.com/decentralized-identity/did-jwt-vc/commit/d2a5c443f3ca9696fe9e15b9e8d5af8e004851a0)) | ||
## [2.1.2](https://github.com/decentralized-identity/did-jwt-vc/compare/2.1.1...2.1.2) (2021-05-28) | ||
@@ -2,0 +9,0 @@ |
@@ -264,3 +264,4 @@ "use strict"; | ||
function transformCredentialInput(input, removeOriginalFields) { | ||
var _a, _b, _c, _d, _e; | ||
var e_2, _a; | ||
var _b, _c, _d, _e, _f; | ||
if (removeOriginalFields === void 0) { removeOriginalFields = true; } | ||
@@ -270,5 +271,5 @@ if (Array.isArray(input.credentialSubject)) | ||
var result = deepCopy(__assign({ vc: __assign({}, input.vc) }, input)); | ||
var credentialSubject = __assign(__assign({}, input.credentialSubject), (_a = input.vc) === null || _a === void 0 ? void 0 : _a.credentialSubject); | ||
var credentialSubject = __assign(__assign({}, input.credentialSubject), (_b = input.vc) === null || _b === void 0 ? void 0 : _b.credentialSubject); | ||
if (!input.sub) { | ||
result.sub = (_b = input.credentialSubject) === null || _b === void 0 ? void 0 : _b.id; | ||
result.sub = (_c = input.credentialSubject) === null || _c === void 0 ? void 0 : _c.id; | ||
if (removeOriginalFields) { | ||
@@ -278,7 +279,3 @@ delete credentialSubject.id; | ||
} | ||
result.vc.credentialStatus = input.credentialStatus; | ||
if (removeOriginalFields) { | ||
delete result.credentialStatus; | ||
} | ||
var contextEntries = __spreadArray(__spreadArray(__spreadArray([], __read(asArray(input.context))), __read(asArray(input['@context']))), __read(asArray((_c = input.vc) === null || _c === void 0 ? void 0 : _c['@context']))).filter(notEmpty); | ||
var contextEntries = __spreadArray(__spreadArray(__spreadArray([], __read(asArray(input.context))), __read(asArray(input['@context']))), __read(asArray((_d = input.vc) === null || _d === void 0 ? void 0 : _d['@context']))).filter(notEmpty); | ||
result.vc['@context'] = __spreadArray([], __read(new Set(contextEntries))); | ||
@@ -289,3 +286,3 @@ if (removeOriginalFields) { | ||
} | ||
var types = __spreadArray(__spreadArray([], __read(asArray(input.type))), __read(asArray((_d = input.vc) === null || _d === void 0 ? void 0 : _d.type))).filter(notEmpty); | ||
var types = __spreadArray(__spreadArray([], __read(asArray(input.type))), __read(asArray((_e = input.vc) === null || _e === void 0 ? void 0 : _e.type))).filter(notEmpty); | ||
result.vc.type = __spreadArray([], __read(new Set(types))); | ||
@@ -321,3 +318,3 @@ if (removeOriginalFields) { | ||
if (typeof input.issuer === 'object') { | ||
result.iss = (_e = input.issuer) === null || _e === void 0 ? void 0 : _e.id; | ||
result.iss = (_f = input.issuer) === null || _f === void 0 ? void 0 : _f.id; | ||
if (removeOriginalFields) { | ||
@@ -340,3 +337,2 @@ delete result.issuer.id; | ||
} | ||
// additional W3C VC fields to map: | ||
result.vc.credentialSubject = credentialSubject; | ||
@@ -346,9 +342,24 @@ if (removeOriginalFields) { | ||
} | ||
result.vc.evidence = input.evidence; | ||
if (removeOriginalFields) { | ||
delete result.evidence; | ||
// additional W3C VC fields to map: | ||
// these may exist at the top-level of a W3C credential, but should be moved inside vc when transforming to JWT | ||
var additionalPropNames = ['evidence', 'termsOfUse', 'refreshService', 'credentialSchema', 'credentialStatus']; | ||
try { | ||
for (var additionalPropNames_1 = __values(additionalPropNames), additionalPropNames_1_1 = additionalPropNames_1.next(); !additionalPropNames_1_1.done; additionalPropNames_1_1 = additionalPropNames_1.next()) { | ||
var prop = additionalPropNames_1_1.value; | ||
if (input[prop]) { | ||
if (!result.vc[prop]) { | ||
result.vc[prop] = input[prop]; | ||
} | ||
if (removeOriginalFields) { | ||
delete result[prop]; | ||
} | ||
} | ||
} | ||
} | ||
result.vc.termsOfUse = input.termsOfUse; | ||
if (removeOriginalFields) { | ||
delete result.termsOfUse; | ||
catch (e_2_1) { e_2 = { error: e_2_1 }; } | ||
finally { | ||
try { | ||
if (additionalPropNames_1_1 && !additionalPropNames_1_1.done && (_a = additionalPropNames_1.return)) _a.call(additionalPropNames_1); | ||
} | ||
finally { if (e_2) throw e_2.error; } | ||
} | ||
@@ -355,0 +366,0 @@ return result; |
{ | ||
"name": "did-jwt-vc", | ||
"version": "2.1.2", | ||
"version": "2.1.3", | ||
"description": "Create and verify W3C Verifiable Credentials and Presentations in JWT format", | ||
@@ -58,12 +58,12 @@ "main": "lib/index.js", | ||
"@semantic-release/git": "9.0.0", | ||
"@types/faker": "5.5.5", | ||
"@types/faker": "5.5.6", | ||
"@types/jest": "26.0.23", | ||
"@types/node": "14.17.1", | ||
"@types/node": "14.17.3", | ||
"codecov": "3.8.2", | ||
"ethr-did": "2.1.4", | ||
"faker": "5.5.3", | ||
"jest": "27.0.1", | ||
"prettier": "2.3.0", | ||
"semantic-release": "17.4.3", | ||
"ts-jest": "27.0.1", | ||
"jest": "27.0.4", | ||
"prettier": "2.3.1", | ||
"semantic-release": "17.4.4", | ||
"ts-jest": "27.0.3", | ||
"tslint": "6.1.3", | ||
@@ -70,0 +70,0 @@ "tslint-config-prettier": "1.18.0", |
@@ -255,7 +255,2 @@ import { | ||
result.vc.credentialStatus = input.credentialStatus | ||
if (removeOriginalFields) { | ||
delete result.credentialStatus | ||
} | ||
const contextEntries = [ | ||
@@ -324,3 +319,2 @@ ...asArray(input.context), | ||
// additional W3C VC fields to map: | ||
result.vc.credentialSubject = credentialSubject | ||
@@ -331,10 +325,15 @@ if (removeOriginalFields) { | ||
result.vc.evidence = input.evidence | ||
if (removeOriginalFields) { | ||
delete result.evidence | ||
} | ||
// additional W3C VC fields to map: | ||
// these may exist at the top-level of a W3C credential, but should be moved inside vc when transforming to JWT | ||
const additionalPropNames = ['evidence', 'termsOfUse', 'refreshService', 'credentialSchema', 'credentialStatus'] | ||
result.vc.termsOfUse = input.termsOfUse | ||
if (removeOriginalFields) { | ||
delete result.termsOfUse | ||
for (let prop of additionalPropNames) { | ||
if (input[prop]) { | ||
if (!result.vc[prop]) { | ||
result.vc[prop] = input[prop] | ||
} | ||
if (removeOriginalFields) { | ||
delete result[prop] | ||
} | ||
} | ||
} | ||
@@ -341,0 +340,0 @@ |
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 too big to display
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
265122
4358