@azure/communication-call-automation
Version:
Azure client library for Azure Communication Call Automation services
57 lines (56 loc) • 2.21 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 recordingUrlValidator_exports = {};
__export(recordingUrlValidator_exports, {
validateRecordingUrl: () => validateRecordingUrl
});
module.exports = __toCommonJS(recordingUrlValidator_exports);
const ALLOWED_HOST_SUFFIXES = [
".asm.skype.com",
".asyncgw.teams.microsoft.com",
".ams.gov.teams.microsoft.us"
];
function validateRecordingUrl(recordingUrl, parameterName) {
if (!recordingUrl) {
throw new TypeError(`${parameterName} cannot be null or undefined.`);
}
let parsedUrl;
try {
parsedUrl = new URL(recordingUrl);
} catch (error) {
throw new Error(`${parameterName} must be a valid absolute URI.`);
}
if (!parsedUrl.protocol) {
throw new Error(`${parameterName} must be an absolute URI.`);
}
if (parsedUrl.protocol.toLowerCase() !== "https:") {
throw new Error(`${parameterName} must use HTTPS scheme for security.`);
}
const host = parsedUrl.hostname.toLowerCase();
const isValidEndpoint = ALLOWED_HOST_SUFFIXES.some((suffix) => host.endsWith(suffix));
if (!isValidEndpoint) {
throw new Error(
`${parameterName} host '${host}' is not a valid Azure Communication Services recording endpoint. Only URLs pointing to *.asm.skype.com, *.asyncgw.teams.microsoft.com are allowed.`
);
}
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
validateRecordingUrl
});
//# sourceMappingURL=recordingUrlValidator.js.map