|
@@ -136,6 +136,18 @@ class BankClient {
|
|
|
return uploadResponse.hash;
|
|
return uploadResponse.hash;
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
+ appendBank(bankLink, itemHash) {
|
|
|
|
|
+ return __awaiter(this, void 0, void 0, function* () {
|
|
|
|
|
+ const payload = yield this.makePlaintextPayload(itemHash);
|
|
|
|
|
+ const { address, topic } = this.parseBankLink(bankLink);
|
|
|
|
|
+ const topicURL = this.urlBase + '/bank/private/' + encodeURIComponent(address) + '/' + encodeURIComponent(topic);
|
|
|
|
|
+ yield this.webClient.requestJSON({
|
|
|
|
|
+ body: payload,
|
|
|
|
|
+ method: 'POST',
|
|
|
|
|
+ url: topicURL
|
|
|
|
|
+ });
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
getPriv() {
|
|
getPriv() {
|
|
|
if (!this.privateKey) {
|
|
if (!this.privateKey) {
|
|
|
throw new Error('missing private key');
|
|
throw new Error('missing private key');
|
|
@@ -170,6 +182,16 @@ class BankClient {
|
|
|
}));
|
|
}));
|
|
|
}));
|
|
}));
|
|
|
}
|
|
}
|
|
|
|
|
+ parseBankLink(bankLink) {
|
|
|
|
|
+ if (!bankLink.startsWith('bank:')) {
|
|
|
|
|
+ throw new Error('address must start with bank:');
|
|
|
|
|
+ }
|
|
|
|
|
+ const [address, topic] = bankLink.substring(5).split('/');
|
|
|
|
|
+ if (!address || !topic) {
|
|
|
|
|
+ throw new Error('cannot parse address and topic');
|
|
|
|
|
+ }
|
|
|
|
|
+ return { address, topic };
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
exports.BankClient = BankClient;
|
|
exports.BankClient = BankClient;
|
|
|
//# sourceMappingURL=index.js.map
|
|
//# sourceMappingURL=index.js.map
|