UNPKG

web-enc-at-rest

Version:
34 lines (33 loc) 1.47 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.setCredentialProof = exports.getCredentialProof = exports.setDeriveKeySalt = exports.getDeriveKeySalt = void 0; const base64Util_1 = require("./base64Util"); const WEAR_PREFIX = 'WEAR_keyGen_'; const DERIVE_KEY_SALT = `${WEAR_PREFIX}deriveKeySalt`; const CREDENTIAL_PROOF = `${WEAR_PREFIX}credentialProof`; function getDeriveKeySalt() { const value = globalThis.localStorage.getItem(DERIVE_KEY_SALT); return value === null ? null : (0, base64Util_1.base64ToBytes)(value); } exports.getDeriveKeySalt = getDeriveKeySalt; function setDeriveKeySalt(deriveKeySalt) { if (deriveKeySalt === null) { globalThis.localStorage.removeItem(DERIVE_KEY_SALT); return; } globalThis.localStorage.setItem(DERIVE_KEY_SALT, (0, base64Util_1.bytesToBase64)(deriveKeySalt)); } exports.setDeriveKeySalt = setDeriveKeySalt; function getCredentialProof() { const value = globalThis.localStorage.getItem(CREDENTIAL_PROOF); return value === null ? null : (0, base64Util_1.base64ToBytes)(value); } exports.getCredentialProof = getCredentialProof; function setCredentialProof(credentialProof) { if (credentialProof === null) { globalThis.localStorage.removeItem(CREDENTIAL_PROOF); return; } globalThis.localStorage.setItem(CREDENTIAL_PROOF, (0, base64Util_1.bytesToBase64)(credentialProof)); } exports.setCredentialProof = setCredentialProof;