@aviarytech/didcomm-protocols.present-proof
Version:
DIDComm Present Proof Protocol
46 lines • 2.22 kB
JavaScript
;
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.RequestPresentationMessageHandler = exports.RequestPresentationMessage = exports.REQUEST_PRESENTATION_TYPE = void 0;
const crypto_core_1 = require("@aviarytech/crypto-core");
exports.REQUEST_PRESENTATION_TYPE = "https://didcomm.org/present-proof/3.0/request-presentation";
class RequestPresentationMessage {
constructor(from, to, thid, attachments) {
this.repudiable = false;
const id = crypto_core_1.sha256pow(from, crypto_core_1.sha256(exports.REQUEST_PRESENTATION_TYPE).slice(0, 4), "")[0].rotation;
this.payload = {
id,
from,
type: exports.REQUEST_PRESENTATION_TYPE,
thid,
to,
created_time: new Date().toISOString(),
body: {},
attachments,
};
}
}
exports.RequestPresentationMessage = RequestPresentationMessage;
class RequestPresentationMessageHandler {
constructor(callback) {
this.type = exports.REQUEST_PRESENTATION_TYPE;
this.callback = callback;
}
handle(props) {
return __awaiter(this, void 0, void 0, function* () {
console.log(`Request Presentation Received: ${props.message.payload.id}, sent at ${props.message.payload.created_time}`);
yield this.callback(props.message, props.didcomm);
return true;
});
}
}
exports.RequestPresentationMessageHandler = RequestPresentationMessageHandler;
//# sourceMappingURL=request.js.map