All files / lib/Model Revision.js

0% Statements 0/14
0% Branches 0/7
0% Functions 0/5
0% Lines 0/14

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                                                                     
"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;
        revision.credential_data = js_base64_1.Base64.btoa(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.
     */
    clone() {
        const newCredential = new Revision(this.vault, this.server, this.encryptedData);
        newCredential.encryptedSharedCredentialEncryptionKey = this.encryptedSharedCredentialEncryptionKey;
        return newCredential;
    }
}
exports.default = Revision;