Socket
Socket
Sign inDemoInstall

@azure/communication-common

Package Overview
Dependencies
Maintainers
1
Versions
214
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@azure/communication-common - npm Package Compare versions

Comparing version 2.2.1-alpha.20230310.2 to 3.0.0-alpha.20230327.5

2

dist-esm/src/credential/communicationAccessKeyCredentialPolicy.js

@@ -27,3 +27,3 @@ // Copyright (c) Microsoft Corporation.

const url = new URL(request.url);
const query = url.searchParams;
const query = url.searchParams.toString();
const urlPathAndQuery = query ? `${url.pathname}?${query}` : url.pathname;

@@ -30,0 +30,0 @@ const port = url.port;

@@ -28,2 +28,10 @@ // Copyright (c) Microsoft Corporation.

/**
* Tests an Identifier to determine whether it implements MicrosoftBotIdentifier.
*
* @param identifier - The assumed available to be tested.
*/
export const isMicrosoftBotIdentifier = (identifier) => {
return typeof identifier.botId === "string";
};
/**
* Tests an Identifier to determine whether it implements UnknownIdentifier.

@@ -51,2 +59,5 @@ *

}
if (isMicrosoftBotIdentifier(identifier)) {
return Object.assign(Object.assign({}, identifier), { kind: "microsoftBot" });
}
return Object.assign(Object.assign({}, identifier), { kind: "unknown" });

@@ -80,2 +91,23 @@ };

}
case "microsoftBot": {
const { botId, rawId, cloud, isResourceAccountConfigured } = identifierKind;
if (rawId)
return rawId;
if (!isResourceAccountConfigured) {
switch (cloud) {
case "dod":
return `28:dod-global:${botId}`;
case "gcch":
return `28:gcch-global:${botId}`;
}
return `28:${botId}`;
}
switch (cloud) {
case "dod":
return `28:dod:${botId}`;
case "gcch":
return `28:gcch:${botId}`;
}
return `28:orgid:${botId}`;
}
case "phoneNumber": {

@@ -92,2 +124,18 @@ const { phoneNumber, rawId } = identifierKind;

};
const buildMicrosoftBotIdentifier = (id, cloud, isResourceAccountConfigured) => {
return {
kind: "microsoftBot",
botId: id,
cloud: cloud,
isResourceAccountConfigured: isResourceAccountConfigured,
};
};
const buildMicrosoftTeamsUserIdentifier = (id, cloud, isAnonymous) => {
return {
kind: "microsoftTeamsUser",
microsoftTeamsUserId: id,
isAnonymous: isAnonymous,
cloud: cloud,
};
};
/**

@@ -103,6 +151,10 @@ * Creates a CommunicationIdentifierKind from a given rawId. When storing rawIds use this function to restore the identifier that was encoded in the rawId.

const segments = rawId.split(":");
if (segments.length < 3)
if (segments.length !== 3) {
if (segments.length === 2 && segments[0] === "28") {
return buildMicrosoftBotIdentifier(segments[1], "public", false);
}
return { kind: "unknown", id: rawId };
}
const prefix = `${segments[0]}:${segments[1]}:`;
const suffix = rawId.substring(prefix.length);
const suffix = segments[2];
switch (prefix) {

@@ -112,22 +164,7 @@ case "8:teamsvisitor:":

case "8:orgid:":
return {
kind: "microsoftTeamsUser",
microsoftTeamsUserId: suffix,
isAnonymous: false,
cloud: "public",
};
return buildMicrosoftTeamsUserIdentifier(suffix, "public", false);
case "8:dod:":
return {
kind: "microsoftTeamsUser",
microsoftTeamsUserId: suffix,
isAnonymous: false,
cloud: "dod",
};
return buildMicrosoftTeamsUserIdentifier(suffix, "dod", false);
case "8:gcch:":
return {
kind: "microsoftTeamsUser",
microsoftTeamsUserId: suffix,
isAnonymous: false,
cloud: "gcch",
};
return buildMicrosoftTeamsUserIdentifier(suffix, "gcch", false);
case "8:acs:":

@@ -138,2 +175,12 @@ case "8:spool:":

return { kind: "communicationUser", communicationUserId: rawId };
case "28:gcch-global:":
return buildMicrosoftBotIdentifier(suffix, "gcch", false);
case "28:orgid:":
return buildMicrosoftBotIdentifier(suffix, "public", true);
case "28:dod-global:":
return buildMicrosoftBotIdentifier(suffix, "dod", false);
case "28:gcch:":
return buildMicrosoftBotIdentifier(suffix, "gcch", true);
case "28:dod:":
return buildMicrosoftBotIdentifier(suffix, "dod", true);
}

@@ -140,0 +187,0 @@ return { kind: "unknown", id: rawId };

@@ -20,2 +20,5 @@ // Copyright (c) Microsoft Corporation.

}
if (identifier.microsoftBot !== undefined) {
presentProperties.push("microsoftBot");
}
if (identifier.phoneNumber !== undefined) {

@@ -34,3 +37,3 @@ presentProperties.push("phoneNumber");

export const serializeCommunicationIdentifier = (identifier) => {
var _a, _b, _c, _d;
var _a, _b, _c, _d, _e, _f, _g;
const identifierKind = getIdentifierKind(identifier);

@@ -59,2 +62,11 @@ switch (identifierKind.kind) {

};
case "microsoftBot":
return {
rawId: (_e = identifierKind.rawId) !== null && _e !== void 0 ? _e : getIdentifierRawId(identifierKind),
microsoftBot: {
botId: identifierKind.botId,
isResourceAccountConfigured: (_f = identifierKind.isResourceAccountConfigured) !== null && _f !== void 0 ? _f : true,
cloud: (_g = identifierKind.cloud) !== null && _g !== void 0 ? _g : "public",
},
};
case "unknown":

@@ -76,2 +88,5 @@ return { rawId: identifierKind.id };

}
if (serializedIdentifier.microsoftBot) {
return "microsoftBot";
}
return "unknown";

@@ -87,3 +102,3 @@ };

assertMaximumOneNestedModel(serializedIdentifier);
const { communicationUser, microsoftTeamsUser, phoneNumber } = serializedIdentifier;
const { communicationUser, microsoftTeamsUser, microsoftBot, phoneNumber } = serializedIdentifier;
const kind = (_a = serializedIdentifier.kind) !== null && _a !== void 0 ? _a : getKind(serializedIdentifier);

@@ -112,2 +127,11 @@ if (kind === "communicationUser" && communicationUser) {

}
if (kind === "microsoftBot" && microsoftBot) {
return {
kind: "microsoftBot",
botId: assertNotNullOrUndefined({ microsoftBot }, "botId"),
isResourceAccountConfigured: assertNotNullOrUndefined({ microsoftBot }, "isResourceAccountConfigured"),
cloud: assertNotNullOrUndefined({ microsoftBot }, "cloud"),
rawId: assertNotNullOrUndefined({ microsoftBot: serializedIdentifier }, "rawId"),
};
}
return {

@@ -114,0 +138,0 @@ kind: "unknown",

@@ -208,3 +208,3 @@ 'use strict';

const url = new URL(request.url);
const query = url.searchParams;
const query = url.searchParams.toString();
const urlPathAndQuery = query ? `${url.pathname}?${query}` : url.pathname;

@@ -342,2 +342,10 @@ const port = url.port;

/**
* Tests an Identifier to determine whether it implements MicrosoftBotIdentifier.
*
* @param identifier - The assumed available to be tested.
*/
const isMicrosoftBotIdentifier = (identifier) => {
return typeof identifier.botId === "string";
};
/**
* Tests an Identifier to determine whether it implements UnknownIdentifier.

@@ -365,2 +373,5 @@ *

}
if (isMicrosoftBotIdentifier(identifier)) {
return Object.assign(Object.assign({}, identifier), { kind: "microsoftBot" });
}
return Object.assign(Object.assign({}, identifier), { kind: "unknown" });

@@ -394,2 +405,23 @@ };

}
case "microsoftBot": {
const { botId, rawId, cloud, isResourceAccountConfigured } = identifierKind;
if (rawId)
return rawId;
if (!isResourceAccountConfigured) {
switch (cloud) {
case "dod":
return `28:dod-global:${botId}`;
case "gcch":
return `28:gcch-global:${botId}`;
}
return `28:${botId}`;
}
switch (cloud) {
case "dod":
return `28:dod:${botId}`;
case "gcch":
return `28:gcch:${botId}`;
}
return `28:orgid:${botId}`;
}
case "phoneNumber": {

@@ -406,2 +438,18 @@ const { phoneNumber, rawId } = identifierKind;

};
const buildMicrosoftBotIdentifier = (id, cloud, isResourceAccountConfigured) => {
return {
kind: "microsoftBot",
botId: id,
cloud: cloud,
isResourceAccountConfigured: isResourceAccountConfigured,
};
};
const buildMicrosoftTeamsUserIdentifier = (id, cloud, isAnonymous) => {
return {
kind: "microsoftTeamsUser",
microsoftTeamsUserId: id,
isAnonymous: isAnonymous,
cloud: cloud,
};
};
/**

@@ -417,6 +465,10 @@ * Creates a CommunicationIdentifierKind from a given rawId. When storing rawIds use this function to restore the identifier that was encoded in the rawId.

const segments = rawId.split(":");
if (segments.length < 3)
if (segments.length !== 3) {
if (segments.length === 2 && segments[0] === "28") {
return buildMicrosoftBotIdentifier(segments[1], "public", false);
}
return { kind: "unknown", id: rawId };
}
const prefix = `${segments[0]}:${segments[1]}:`;
const suffix = rawId.substring(prefix.length);
const suffix = segments[2];
switch (prefix) {

@@ -426,22 +478,7 @@ case "8:teamsvisitor:":

case "8:orgid:":
return {
kind: "microsoftTeamsUser",
microsoftTeamsUserId: suffix,
isAnonymous: false,
cloud: "public",
};
return buildMicrosoftTeamsUserIdentifier(suffix, "public", false);
case "8:dod:":
return {
kind: "microsoftTeamsUser",
microsoftTeamsUserId: suffix,
isAnonymous: false,
cloud: "dod",
};
return buildMicrosoftTeamsUserIdentifier(suffix, "dod", false);
case "8:gcch:":
return {
kind: "microsoftTeamsUser",
microsoftTeamsUserId: suffix,
isAnonymous: false,
cloud: "gcch",
};
return buildMicrosoftTeamsUserIdentifier(suffix, "gcch", false);
case "8:acs:":

@@ -452,2 +489,12 @@ case "8:spool:":

return { kind: "communicationUser", communicationUserId: rawId };
case "28:gcch-global:":
return buildMicrosoftBotIdentifier(suffix, "gcch", false);
case "28:orgid:":
return buildMicrosoftBotIdentifier(suffix, "public", true);
case "28:dod-global:":
return buildMicrosoftBotIdentifier(suffix, "dod", false);
case "28:gcch:":
return buildMicrosoftBotIdentifier(suffix, "gcch", true);
case "28:dod:":
return buildMicrosoftBotIdentifier(suffix, "dod", true);
}

@@ -474,2 +521,5 @@ return { kind: "unknown", id: rawId };

}
if (identifier.microsoftBot !== undefined) {
presentProperties.push("microsoftBot");
}
if (identifier.phoneNumber !== undefined) {

@@ -488,3 +538,3 @@ presentProperties.push("phoneNumber");

const serializeCommunicationIdentifier = (identifier) => {
var _a, _b, _c, _d;
var _a, _b, _c, _d, _e, _f, _g;
const identifierKind = getIdentifierKind(identifier);

@@ -513,2 +563,11 @@ switch (identifierKind.kind) {

};
case "microsoftBot":
return {
rawId: (_e = identifierKind.rawId) !== null && _e !== void 0 ? _e : getIdentifierRawId(identifierKind),
microsoftBot: {
botId: identifierKind.botId,
isResourceAccountConfigured: (_f = identifierKind.isResourceAccountConfigured) !== null && _f !== void 0 ? _f : true,
cloud: (_g = identifierKind.cloud) !== null && _g !== void 0 ? _g : "public",
},
};
case "unknown":

@@ -530,2 +589,5 @@ return { rawId: identifierKind.id };

}
if (serializedIdentifier.microsoftBot) {
return "microsoftBot";
}
return "unknown";

@@ -541,3 +603,3 @@ };

assertMaximumOneNestedModel(serializedIdentifier);
const { communicationUser, microsoftTeamsUser, phoneNumber } = serializedIdentifier;
const { communicationUser, microsoftTeamsUser, microsoftBot, phoneNumber } = serializedIdentifier;
const kind = (_a = serializedIdentifier.kind) !== null && _a !== void 0 ? _a : getKind(serializedIdentifier);

@@ -566,2 +628,11 @@ if (kind === "communicationUser" && communicationUser) {

}
if (kind === "microsoftBot" && microsoftBot) {
return {
kind: "microsoftBot",
botId: assertNotNullOrUndefined({ microsoftBot }, "botId"),
isResourceAccountConfigured: assertNotNullOrUndefined({ microsoftBot }, "isResourceAccountConfigured"),
cloud: assertNotNullOrUndefined({ microsoftBot }, "cloud"),
rawId: assertNotNullOrUndefined({ microsoftBot: serializedIdentifier }, "rawId"),
};
}
return {

@@ -582,2 +653,3 @@ kind: "unknown",

exports.isKeyCredential = isKeyCredential;
exports.isMicrosoftBotIdentifier = isMicrosoftBotIdentifier;
exports.isMicrosoftTeamsUserIdentifier = isMicrosoftTeamsUserIdentifier;

@@ -584,0 +656,0 @@ exports.isPhoneNumberIdentifier = isPhoneNumberIdentifier;

{
"name": "@azure/communication-common",
"version": "2.2.1-alpha.20230310.2",
"version": "3.0.0-alpha.20230327.5",
"description": "Common package for Azure Communication services.",

@@ -104,4 +104,5 @@ "sdk-type": "client",

"typescript": "~4.8.0",
"util": "^0.12.1"
"util": "^0.12.1",
"mockdate": "^3.0.5"
}
}

@@ -49,3 +49,3 @@ import { AbortSignalLike } from '@azure/abort-controller';

*/
export declare type CommunicationIdentifier = CommunicationUserIdentifier | PhoneNumberIdentifier | MicrosoftTeamsUserIdentifier | UnknownIdentifier;
export declare type CommunicationIdentifier = CommunicationUserIdentifier | PhoneNumberIdentifier | MicrosoftTeamsUserIdentifier | MicrosoftBotIdentifier | UnknownIdentifier;

@@ -55,3 +55,3 @@ /**

*/
export declare type CommunicationIdentifierKind = CommunicationUserKind | PhoneNumberKind | MicrosoftTeamsUserKind | UnknownIdentifierKind;
export declare type CommunicationIdentifierKind = CommunicationUserKind | PhoneNumberKind | MicrosoftTeamsUserKind | MicrosoftBotKind | UnknownIdentifierKind;

@@ -189,2 +189,9 @@ /**

/**
* Tests an Identifier to determine whether it implements MicrosoftBotIdentifier.
*
* @param identifier - The assumed available to be tested.
*/
export declare const isMicrosoftBotIdentifier: (identifier: CommunicationIdentifier) => identifier is MicrosoftBotIdentifier;
/**
* Tests an Identifier to determine whether it implements MicrosoftTeamsUserIdentifier.

@@ -211,2 +218,34 @@ *

/**
* A Microsoft bot.
*/
export declare interface MicrosoftBotIdentifier {
/**
* Optional raw id of the Microsoft bot.
*/
rawId?: string;
/**
* The unique Microsoft app ID for the bot as registered with the Bot Framework.
*/
botId: string;
/**
* True (or missing) if the bot is global and no resource account is configured and false if the bot is tenantized.
*/
isResourceAccountConfigured?: boolean;
/**
* The cloud that the Microsoft bot belongs to. If missing, the cloud is "public".
*/
cloud?: "public" | "dod" | "gcch";
}
/**
* IdentifierKind for a MicrosoftBotIdentifier.
*/
export declare interface MicrosoftBotKind extends MicrosoftBotIdentifier {
/**
* The identifier kind.
*/
kind: "microsoftBot";
}
/**
* A Microsoft Teams user.

@@ -320,2 +359,6 @@ */

microsoftTeamsUser?: SerializedMicrosoftTeamsUserIdentifier;
/**
* The Microsoft bot.
*/
microsoftBot?: SerializedMicrosoftBotIdentifier;
}

@@ -336,2 +379,21 @@

* @hidden
* A Microsoft bot.
*/
export declare interface SerializedMicrosoftBotIdentifier {
/**
* Id of the Microsoft bot.
*/
botId: string;
/**
* True (or missing) if the bot is global and no resource account is configured and false if the bot is tenantized.
*/
isResourceAccountConfigured?: boolean;
/**
* The cloud that the Microsoft bot belongs to. By default 'public' if missing.
*/
cloud?: SerializedCommunicationCloudEnvironment;
}
/**
* @hidden
* A Microsoft Teams user.

@@ -338,0 +400,0 @@ */

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc