@aviarytech/didcomm-protocols.trust-ping
Version:
DIDComm Trust Ping Protocol
43 lines • 2.12 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.DefaultTrustPingMessageHandler = exports.TRUST_PING_PING_TYPE = void 0;
const sha256_1 = require("../utils/sha256");
const trust_ping_response_1 = require("./trust-ping-response");
exports.TRUST_PING_PING_TYPE = "https://didcomm.org/trust_ping/1.0/ping";
class DefaultTrustPingMessageHandler {
constructor() {
this.type = exports.TRUST_PING_PING_TYPE;
}
handle(props) {
return __awaiter(this, void 0, void 0, function* () {
const { payload } = props.message;
if (payload.body.response_requested) {
if (!payload.from) {
console.error(`Error in Trust Ping Protocol: response requested but "from" property not included`);
return false;
}
const responseMessage = {
payload: {
id: sha256_1.sha256(payload.id),
thid: payload.id,
type: trust_ping_response_1.TRUST_PING_RESPONSE_PING_TYPE,
},
repudiable: false,
};
return yield props.didcomm.sendMessage(payload.from, responseMessage);
}
return true;
});
}
}
exports.DefaultTrustPingMessageHandler = DefaultTrustPingMessageHandler;
//# sourceMappingURL=trust-ping.js.map