@klayr-did/klayr-verifiable-credentials
Version:
A library for working with W3C verifiable credentials (VC) and verifiable presentations (VP) using Klayr DID
20 lines • 1.05 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getPresentationsHash = exports.preprocessPresentation = void 0;
const credentials_context_1 = require("credentials-context");
const util_1 = require("./util");
const cryptography = require("@klayr/cryptography");
const codec_1 = require("../codec");
function preprocessPresentation(presentation) {
presentation['@context'] = (0, util_1.preprocessRequired)(presentation['@context'], credentials_context_1.CREDENTIALS_CONTEXT_V1_URL);
presentation.type = (0, util_1.preprocessRequired)(presentation.type, 'VerifiablePresentation');
if (presentation.id === undefined) {
presentation.id = `urn:sha256:${getPresentationsHash(presentation).toString('hex')}`;
}
}
exports.preprocessPresentation = preprocessPresentation;
function getPresentationsHash(presentation) {
return cryptography.utils.hash((0, codec_1.encodePresentation)(presentation));
}
exports.getPresentationsHash = getPresentationsHash;
//# sourceMappingURL=presentation.js.map