UNPKG

@azure/cosmos

Version:
60 lines (59 loc) 2.87 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 EncryptionManager_exports = {}; __export(EncryptionManager_exports, { EncryptionManager: () => EncryptionManager }); module.exports = __toCommonJS(EncryptionManager_exports); var import_ProtectedDataEncryptionKeyCache = require("./Cache/ProtectedDataEncryptionKeyCache.js"); var import_KeyEncryptionKeyCache = require("./Cache/KeyEncryptionKeyCache.js"); var import_EncryptionSettingsCache = require("./Cache/EncryptionSettingsCache.js"); var import_ClientEncryptionKeyPropertiesCache = require("./Cache/ClientEncryptionKeyPropertiesCache.js"); var import_EncryptionKeyStoreProvider = require("./EncryptionKeyStoreProvider.js"); var import_constants = require("../common/constants.js"); class EncryptionManager { cacheTimeToLive; encryptionKeyStoreProvider; protectedDataEncryptionKeyCache; keyEncryptionKeyCache; encryptionSettingsCache; clientEncryptionKeyPropertiesCache; constructor(encryptionKeyResolver, cacheTimeToLive) { this.cacheTimeToLive = cacheTimeToLive !== void 0 ? cacheTimeToLive : import_constants.Constants.DefaultEncryptionCacheTimeToLiveInSeconds; const cacheTtlInMs = this.getCacheTTlInMs(); this.encryptionKeyStoreProvider = new import_EncryptionKeyStoreProvider.EncryptionKeyStoreProvider( encryptionKeyResolver, cacheTtlInMs ); this.protectedDataEncryptionKeyCache = new import_ProtectedDataEncryptionKeyCache.ProtectedDataEncryptionKeyCache(cacheTtlInMs); this.keyEncryptionKeyCache = new import_KeyEncryptionKeyCache.KeyEncryptionKeyCache(); this.encryptionSettingsCache = new import_EncryptionSettingsCache.EncryptionSettingsCache(); this.clientEncryptionKeyPropertiesCache = new import_ClientEncryptionKeyPropertiesCache.ClientEncryptionKeyPropertiesCache(); } /** * Converts the EncryptionTimeToLive instance to a number (milliseconds). */ getCacheTTlInMs() { const millisecondsPerSecond = 1e3; return Number(this.cacheTimeToLive * millisecondsPerSecond); } } // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { EncryptionManager });