@sphereon/ssi-types
Advanced tools
Comparing version 0.8.1-unstable.200 to 0.8.1-unstable.201
@@ -220,14 +220,18 @@ "use strict"; | ||
static toExternalVerifiableCredential(verifiableCredential) { | ||
if (!verifiableCredential.proof.type) { | ||
throw new Error('Verifiable credential proof is missing a type'); | ||
let proof; | ||
if (verifiableCredential.proof) { | ||
if (!verifiableCredential.proof.type) { | ||
throw new Error('Verifiable credential proof is missing a type'); | ||
} | ||
if (!verifiableCredential.proof.created) { | ||
throw new Error('Verifiable credential proof is missing a created date'); | ||
} | ||
if (!verifiableCredential.proof.proofPurpose) { | ||
throw new Error('Verifiable credential proof is missing a proof purpose'); | ||
} | ||
if (!verifiableCredential.proof.verificationMethod) { | ||
throw new Error('Verifiable credential proof is missing a verification method'); | ||
} | ||
proof = Object.assign(Object.assign({}, verifiableCredential.proof), { type: verifiableCredential.proof.type, created: verifiableCredential.proof.created, proofPurpose: verifiableCredential.proof.proofPurpose, verificationMethod: verifiableCredential.proof.verificationMethod }); | ||
} | ||
if (!verifiableCredential.proof.created) { | ||
throw new Error('Verifiable credential proof is missing a created date'); | ||
} | ||
if (!verifiableCredential.proof.proofPurpose) { | ||
throw new Error('Verifiable credential proof is missing a proof purpose'); | ||
} | ||
if (!verifiableCredential.proof.verificationMethod) { | ||
throw new Error('Verifiable credential proof is missing a verification method'); | ||
} | ||
return Object.assign(Object.assign({}, verifiableCredential), { type: verifiableCredential.type | ||
@@ -237,3 +241,3 @@ ? typeof verifiableCredential.type === 'string' | ||
: verifiableCredential.type | ||
: ['VerifiableCredential'], proof: Object.assign(Object.assign({}, verifiableCredential.proof), { type: verifiableCredential.proof.type, created: verifiableCredential.proof.created, proofPurpose: verifiableCredential.proof.proofPurpose, verificationMethod: verifiableCredential.proof.verificationMethod }) }); | ||
: ['VerifiableCredential'], proof }); | ||
} | ||
@@ -240,0 +244,0 @@ } |
{ | ||
"name": "@sphereon/ssi-types", | ||
"description": "SSI Common Types", | ||
"version": "0.8.1-unstable.200+559efe2", | ||
"version": "0.8.1-unstable.201+f04345b", | ||
"main": "dist/index.js", | ||
@@ -41,3 +41,3 @@ "types": "dist/index.d.ts", | ||
], | ||
"gitHead": "559efe254d9b5780b8cd10ca8e70875c3c835ca0" | ||
"gitHead": "f04345b97ff9a78a3dff096599f0b675b3239a3e" | ||
} |
@@ -277,16 +277,26 @@ import { | ||
static toExternalVerifiableCredential(verifiableCredential: any): IVerifiableCredential { | ||
if (!verifiableCredential.proof.type) { | ||
throw new Error('Verifiable credential proof is missing a type') | ||
} | ||
let proof | ||
if (verifiableCredential.proof) { | ||
if (!verifiableCredential.proof.type) { | ||
throw new Error('Verifiable credential proof is missing a type') | ||
} | ||
if (!verifiableCredential.proof.created) { | ||
throw new Error('Verifiable credential proof is missing a created date') | ||
} | ||
if (!verifiableCredential.proof.created) { | ||
throw new Error('Verifiable credential proof is missing a created date') | ||
} | ||
if (!verifiableCredential.proof.proofPurpose) { | ||
throw new Error('Verifiable credential proof is missing a proof purpose') | ||
} | ||
if (!verifiableCredential.proof.proofPurpose) { | ||
throw new Error('Verifiable credential proof is missing a proof purpose') | ||
} | ||
if (!verifiableCredential.proof.verificationMethod) { | ||
throw new Error('Verifiable credential proof is missing a verification method') | ||
if (!verifiableCredential.proof.verificationMethod) { | ||
throw new Error('Verifiable credential proof is missing a verification method') | ||
} | ||
proof = { | ||
...verifiableCredential.proof, | ||
type: verifiableCredential.proof.type, | ||
created: verifiableCredential.proof.created, | ||
proofPurpose: verifiableCredential.proof.proofPurpose, | ||
verificationMethod: verifiableCredential.proof.verificationMethod, | ||
} | ||
} | ||
@@ -301,11 +311,5 @@ | ||
: ['VerifiableCredential'], | ||
proof: { | ||
...verifiableCredential.proof, | ||
type: verifiableCredential.proof.type, | ||
created: verifiableCredential.proof.created, | ||
proofPurpose: verifiableCredential.proof.proofPurpose, | ||
verificationMethod: verifiableCredential.proof.verificationMethod, | ||
}, | ||
proof, | ||
} | ||
} | ||
} |
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
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
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
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
90806
1295