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
import { compareSync } from "bcryptjs";
import { encryptBaseMixin } from "@theme/mixins/encrypt";
export const globalEncryptMixin = encryptBaseMixin.extend({
data: () => ({
globalEncryptPassword: "",
}),
computed: {
isGlobalEncrypted() {
if (this.encryptOptions.status === "global" &&
this.encryptOptions.global) {
const { global } = this.encryptOptions;
const globalPasswords = typeof global === "string" ? [global] : global;
// none of the password matches
return !globalPasswords.some((globalPassword) => compareSync(this.globalEncryptPassword, globalPassword));
}
return false;
},
},
mounted() {
const globalPassword = localStorage.getItem("globalPassword");
if (globalPassword)
this.globalEncryptPassword = globalPassword;
},
methods: {
checkGlobalPassword(globalPassword) {
const { global } = this.encryptOptions;
const globalPasswords = typeof global === "string" ? [global] : global;
if (
// some of the password matches
globalPasswords.some((password) => compareSync(globalPassword, password))) {
this.globalEncryptPassword = globalPassword;
localStorage.setItem("globalPassword", globalPassword);
}
},
},
});
//# sourceMappingURL=globalEncrypt.js.map