Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | 1x 1x 1x 1x 1x 2x 2x 2x 1x | "use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const Credential_1 = __importDefault(require("./Credential"));
const js_base64_1 = require("js-base64");
class Revision extends Credential_1.default {
ENCRYPTED_FIELDS = ['description', 'username', 'password', 'files', 'custom_fields', 'otp', 'email', 'tags', 'url', 'compromised'];
static updateRevision(revision, server) {
const credentialGUID = revision.credential_data.guid;
// Plain fields such as label are part of this JSON. Encode it as UTF-8 base64.
// The server restores it with base64_decode + json_decode, which reads these bytes as UTF-8.
revision.credential_data = js_base64_1.Base64.encode(JSON.stringify(revision.credential_data));
return server.postJson('/credentials/' + credentialGUID + '/revision/' + revision.revision_id, revision, () => {
}, 'PATCH');
}
/**
* Create a revision object based on its encrypted data.
* @param data
* @param vault
* @param server
*/
static fromData(data, vault, server) {
return new Revision(vault, server, data);
}
/**
* Creates a local 100% clone of the current credential. The clone contains only encrypted data.
* Ciphertext is copied onto a new object, so later writes on the clone cannot mutate this instance.
*/
clone() {
const newCredential = new Revision(this.vault, this.server, { ...this.encryptedData });
newCredential.encryptedSharedCredentialEncryptionKey = this.encryptedSharedCredentialEncryptionKey;
return newCredential;
}
}
exports.default = Revision;
|