heimdall-tide
Version:
SDK for communicating with a Tide Enclave
57 lines • 2.15 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ApprovalEnclave = void 0;
const heimdall_1 = require("../heimdall");
class ApprovalEnclave extends heimdall_1.Heimdall {
constructor() {
super(...arguments);
this.name = "approval";
this._windowType = heimdall_1.windowType.Popup;
}
init(data, enclaveUrl) {
this.acceptedAdminIds = data;
this.enclaveUrl = new URL(enclaveUrl);
this.initDone = this.open();
return this;
}
async getAuthorizerAuthentication() {
await this.initDone;
// ready to accept reply
const pre_response = this.recieve("authentication");
// send to enclave
this.send({
type: "authentication",
message: "pretty please"
});
// wait for response - this does not mean that enclave it closed, just that the admin has responded to the approval request from the enclave
return await pre_response;
}
async getAuthorizerApproval(draftToApprove, modelId, expiry, encoding = "bytes", authflow = "") {
await this.initDone;
// ready to accept reply
const pre_response = this.recieve("approval");
// send to enclave
this.send({
type: "approval",
message: {
draftToAuthorize: {
data: draftToApprove,
encoding: encoding
},
modelId: modelId,
expiry: expiry,
authflow: authflow
}
});
// wait for response - this does not mean that enclave it closed, just that the admin has responded to the approval request from the enclave
return await pre_response;
}
getOrkUrl() {
// how to create approval ork url for openinging enclave?
this.enclaveUrl.searchParams.set("type", "approval");
this.enclaveUrl.searchParams.set("acceptedIds", JSON.stringify(this.acceptedAdminIds));
return this.enclaveUrl;
}
}
exports.ApprovalEnclave = ApprovalEnclave;
//# sourceMappingURL=ApprovalEnclave.js.map