UNPKG

one

Version:

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

61 lines (60 loc) • 2.08 kB
var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); var crypto_exports = {}; __export(crypto_exports, { AESEncryptionKey: () => AESEncryptionKey, AESSealedData: () => AESSealedData, Crypto: () => Crypto, installCrypto: () => installCrypto }); module.exports = __toCommonJS(crypto_exports); var import_aes = require("./aes.cjs"); var import_digest_api = require("./digest-api.cjs"); var import_random = require("./random.cjs"); var import_web = require("./web.cjs"); 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 (0, import_random.formatUuidV4)(bytes); } }; function installCrypto() { (0, import_random.installCryptoPolyfill)(source); } const aes = (0, import_aes.createAesApi)(import_web.webAesEngine); const digestApi = (0, import_digest_api.createDigestApi)(import_web.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 });