All files / lib/esm/Model Revision.js

0% Statements 0/8
100% Branches 0/0
0% Functions 0/4
0% Lines 0/8

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                                                         
import Credential from "./Credential";
import { Base64 } from "js-base64";
export default class Revision extends Credential {
    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 = 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;
    }
}