@azure/communication-common
Version:
Common package for Azure Communication services.
45 lines (44 loc) • 1.78 kB
JavaScript
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 connectionString_exports = {};
__export(connectionString_exports, {
parseConnectionString: () => parseConnectionString
});
module.exports = __toCommonJS(connectionString_exports);
var import_core_auth = require("@azure/core-auth");
const CONNECTION_STRING_REGEX = /endpoint=(.*);accesskey=(.*)/i;
const tryParseConnectionString = (s) => {
const match = s.match(CONNECTION_STRING_REGEX);
if (match?.[1] && match[2]) {
return { endpoint: match[1], credential: new import_core_auth.AzureKeyCredential(match[2]) };
}
return void 0;
};
const parseConnectionString = (connectionString) => {
const parsedConnectionString = tryParseConnectionString(connectionString);
if (parsedConnectionString) {
return parsedConnectionString;
} else {
throw new Error(`Invalid connection string ${connectionString}`);
}
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
parseConnectionString
});
//# sourceMappingURL=connectionString.js.map