UNPKG

@azure/keyvault-certificates

Version:
72 lines (71 loc) 2.28 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 utils_exports = {}; __export(utils_exports, { base64ToUint8Array: () => base64ToUint8Array, parseCertificateBytes: () => parseCertificateBytes, stringToUint8Array: () => stringToUint8Array, toAscii: () => toAscii, toBase64: () => toBase64 }); module.exports = __toCommonJS(utils_exports); var import_core_util = require("@azure/core-util"); function toBase64(bytes) { if (import_core_util.isNode) { return Buffer.from(bytes).toString("base64"); } else { return btoa(String.fromCharCode.apply(null, bytes)); } } function toAscii(bytes) { if (import_core_util.isNode) { return Buffer.from(bytes).toString("ascii"); } else { return new TextDecoder("ascii").decode(bytes); } } function stringToUint8Array(value) { if (import_core_util.isNode) { return Buffer.from(value); } else { return new TextEncoder().encode(value); } } function base64ToUint8Array(value) { if (import_core_util.isNode) { return Buffer.from(value, "base64"); } else { return Uint8Array.from(atob(value), (c) => c.charCodeAt(0)); } } function parseCertificateBytes(certificateBytes, contentType) { if (contentType === "application/x-pem-file") { return toAscii(certificateBytes); } else { return toBase64(certificateBytes); } } // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { base64ToUint8Array, parseCertificateBytes, stringToUint8Array, toAscii, toBase64 }); //# sourceMappingURL=utils.js.map