UNPKG

@primno/dpapi

Version:

Pre-built version of DPAPI (Data Protection API of Windows). Encrypt and decrypt data.

35 lines (34 loc) 1.19 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.Dpapi = exports.isPlatformSupported = void 0; const path_1 = __importDefault(require("path")); class ErrorWithInnerError extends Error { constructor(message, innerError) { super(message); this.innerError = innerError; } } class UnsupportedPlatformDpapiBindings { constructor(error) { this.error = error; } protectData(dataToEncrypt, optionalEntropy, scope) { throw new ErrorWithInnerError("DPAPI is not supported on this platform.", this.error); } unprotectData(encryptData, optionalEntropy, scope) { throw new ErrorWithInnerError("DPAPI is not supported on this platform.", this.error); } } let dpapi; try { dpapi = require("node-gyp-build")(path_1.default.join(__dirname, "..")); } catch (e) { dpapi = new UnsupportedPlatformDpapiBindings(e); } exports.isPlatformSupported = !(dpapi instanceof UnsupportedPlatformDpapiBindings); exports.Dpapi = dpapi; exports.default = exports.Dpapi;