@bajetech/digitalbits-wallet-sdk
Version:
A library to make it easier to write wallets that interact with the DigitalBits blockchain
60 lines • 2.03 kB
JavaScript
import { __awaiter, __generator } from "tslib";
import { KeyType } from "../constants/keys";
import { IdentityEncrypter } from "./IdentityEncrypter";
import { testEncrypter } from "../PluginTesting";
var key = {
id: "PURIFIER",
type: KeyType.plaintextKey,
publicKey: "AVACYN",
privateKey: "ARCHANGEL",
};
var encryptedKey = {
id: "PURIFIER",
encryptedBlob: JSON.stringify({
type: KeyType.plaintextKey,
publicKey: "AVACYN",
privateKey: "ARCHANGEL",
}),
encrypterName: "IdentityEncrypter",
salt: "identity",
};
it("encrypts to itself", function () { return __awaiter(void 0, void 0, void 0, function () {
var _a;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
_a = expect;
return [4 /*yield*/, IdentityEncrypter.encryptKey({ key: key, password: "" })];
case 1:
_a.apply(void 0, [_b.sent()]).toEqual(encryptedKey);
return [2 /*return*/];
}
});
}); });
it("decrypts to itself", function () { return __awaiter(void 0, void 0, void 0, function () {
var _a;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
_a = expect;
return [4 /*yield*/, IdentityEncrypter.decryptKey({ encryptedKey: encryptedKey, password: "" })];
case 1:
_a.apply(void 0, [_b.sent()]).toEqual(key);
return [2 /*return*/];
}
});
}); });
it("passes PluginTesting", function () { return __awaiter(void 0, void 0, void 0, function () {
var _a;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
_a = expect;
return [4 /*yield*/, testEncrypter(IdentityEncrypter)];
case 1:
_a.apply(void 0, [_b.sent()]).toEqual(true);
return [2 /*return*/];
}
});
}); });
//# sourceMappingURL=IdentityEncrypter.test.js.map