UNPKG

@aviarytech/didcomm-protocols.present-proof

Version:
47 lines 2.12 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.PresentationMessageHandler = exports.PresentationMessage = exports.PRESENTATION_TYPE = void 0; const crypto_core_1 = require("@aviarytech/crypto-core"); exports.PRESENTATION_TYPE = "https://didcomm.org/present-proof/3.0/presentation"; class PresentationMessage { constructor(from, to, thid, attachments) { this.repudiable = false; const id = crypto_core_1.sha256pow(from, crypto_core_1.sha256(exports.PRESENTATION_TYPE).slice(0, 4), "")[0] .rotation; this.payload = { id, from, type: exports.PRESENTATION_TYPE, thid, to, created_time: new Date().toISOString(), body: {}, attachments, }; } } exports.PresentationMessage = PresentationMessage; class PresentationMessageHandler { constructor(callback) { this.type = exports.PRESENTATION_TYPE; this.callback = callback; } handle(props) { return __awaiter(this, void 0, void 0, function* () { console.log(`Presentation Received: ${props.message.payload.id}, sent at ${props.message.payload.created_time}`); yield this.callback(props.message, props.didcomm); return true; }); } } exports.PresentationMessageHandler = PresentationMessageHandler; //# sourceMappingURL=present.js.map