UNPKG

one

Version:

One is a React framework for web, iOS, and Android apps.

37 lines (34 loc) • 1.11 kB
import { createAesApi } from "./aes.mjs"; import { createDigestApi } from "./digest-api.mjs"; import { formatUuidV4, installCryptoPolyfill } from "./random.mjs"; import { webAesEngine, webDigestSource } from "./web.mjs"; function fill(bytes) { const getRandomValues = globalThis.crypto?.getRandomValues; if (typeof getRandomValues !== "function") { throw new Error("secure random: web crypto is unavailable in this browser."); } getRandomValues.call(globalThis.crypto, bytes); } const source = { fill, randomUUID() { const bytes = new Uint8Array(16); fill(bytes); return formatUuidV4(bytes); } }; function installCrypto() { installCryptoPolyfill(source); } const aes = createAesApi(webAesEngine); const digestApi = createDigestApi(webDigestSource); const AESEncryptionKey = aes.AESEncryptionKey; const AESSealedData = aes.AESSealedData; const Crypto = Object.freeze({ digest: digestApi.digest, digestString: digestApi.digestString, aesEncrypt: aes.aesEncrypt, aesDecrypt: aes.aesDecrypt }); export { AESEncryptionKey, AESSealedData, Crypto, installCrypto }; //# sourceMappingURL=index.mjs.map