New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@arcblock/vc

Package Overview
Dependencies
Maintainers
2
Versions
509
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@arcblock/vc - npm Package Compare versions

Comparing version 1.1.4 to 1.2.2

40

lib/index.js

@@ -13,3 +13,3 @@ /**

const { toTypeInfo, isValid, isFromPublicKey, fromPublicKeyHash } = require('@arcblock/did');
const { toBase58, toBase64, fromBase64 } = require('@arcblock/forge-util');
const { toBase58, toBase64, fromBase64, fromBase58 } = require('@arcblock/forge-util');

@@ -169,5 +169,43 @@ // eslint-disable-next-line

/**
* Verify that the Presentation is valid
* - It is signed by VC's owner
* - It contain chanllege
* - It has valid signature by the issuer
* - It is not expired
*
* @param {object} presentation - the presentation object
* @param {Array} trustedIssuers - list of issuer did
* @param {String} challenge - Random byte you want
* @throws {Error}
* @returns {boolean}
*/
function verifyPresentation({ presentation, trustedIssuers, challenge }) {
if (!presentation.challenge || challenge !== presentation.challenge) {
throw Error('unsafe response');
}
const vcArray = Array.isArray(presentation.verifiableCredential)
? presentation.verifiableCredential
: [presentation.verifiableCredential];
const proofArray = Array.isArray(presentation.proof) ? presentation.proof : [presentation.proof];
const clone = cloneDeep(presentation);
delete clone.proof;
vcArray.forEach(vcString => {
const vc = JSON.parse(vcString);
const proof = proofArray.find(tmpProof => isFromPublicKey(vc.credentialSubject.id, tmpProof.pk));
if (!proof) throw Error('VC cannot be proof');
const signature = proof.jws;
const recipience = fromPublicKey(fromBase58(proof.pk), toTypeInfo(vc.credentialSubject.id));
if (recipience.verify(stringify(clone), fromBase64(signature)) !== true) {
throw Error('presentation signature not valid');
}
verify({ vc, ownerDid: vc.credentialSubject.id, trustedIssuers });
});
return true;
}
module.exports = {
create,
verify,
verifyPresentation,
};

4

package.json
{
"name": "@arcblock/vc",
"version": "1.1.4",
"version": "1.2.2",
"description": "Javascript lib to work with ArcBlock Verifiable Credentials",

@@ -58,3 +58,3 @@ "keywords": [

},
"gitHead": "d9ffc9a387ed62986049871c7f3210c02bda7169"
"gitHead": "0644561ed13b9e270b375f082acfddd0ae443e9c"
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc