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 | 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;
// 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 = 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;
}
}
|