full site update
This commit is contained in:
15
node_modules/astro/dist/core/encryption.js
generated
vendored
15
node_modules/astro/dist/core/encryption.js
generated
vendored
@@ -1,4 +1,5 @@
|
||||
import { decodeBase64, decodeHex, encodeBase64, encodeHexUpperCase } from "@oslojs/encoding";
|
||||
import { ALGORITHMS } from "./csp/config.js";
|
||||
const ALGORITHM = "AES-GCM";
|
||||
async function createKey() {
|
||||
const key = await crypto.subtle.generateKey(
|
||||
@@ -27,10 +28,6 @@ async function getEnvironmentKey() {
|
||||
const encodedKey = getEncodedEnvironmentKey();
|
||||
return decodeKey(encodedKey);
|
||||
}
|
||||
async function importKey(bytes) {
|
||||
const key = await crypto.subtle.importKey("raw", bytes, ALGORITHM, true, ["encrypt", "decrypt"]);
|
||||
return key;
|
||||
}
|
||||
async function encodeKey(key) {
|
||||
const exported = await crypto.subtle.exportKey("raw", key);
|
||||
const encodedKey = encodeBase64(new Uint8Array(exported));
|
||||
@@ -70,14 +67,18 @@ async function decryptString(key, encoded) {
|
||||
const decryptedString = decoder.decode(decryptedBuffer);
|
||||
return decryptedString;
|
||||
}
|
||||
async function generateCspDigest(data, algorithm) {
|
||||
const hashBuffer = await crypto.subtle.digest(algorithm, encoder.encode(data));
|
||||
const hash = encodeBase64(new Uint8Array(hashBuffer));
|
||||
return `${ALGORITHMS[algorithm]}${hash}`;
|
||||
}
|
||||
export {
|
||||
createKey,
|
||||
decodeKey,
|
||||
decryptString,
|
||||
encodeKey,
|
||||
encryptString,
|
||||
getEncodedEnvironmentKey,
|
||||
generateCspDigest,
|
||||
getEnvironmentKey,
|
||||
hasEnvironmentKey,
|
||||
importKey
|
||||
hasEnvironmentKey
|
||||
};
|
||||
|
Reference in New Issue
Block a user