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 3.0.0-alpha.20230904.1 to 3.0.0-alpha.20230915.1

49

dist-esm/src/identifierModels.js

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

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

@@ -59,4 +59,4 @@ /**

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

@@ -91,22 +91,13 @@ return Object.assign(Object.assign({}, identifier), { kind: "unknown" });

}
case "microsoftBot": {
const { botId, rawId, cloud, isResourceAccountConfigured } = identifierKind;
case "microsoftTeamsApp": {
const { teamsAppId, rawId, cloud } = 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}`;
return `28:dod:${teamsAppId}`;
case "gcch":
return `28:gcch:${botId}`;
return `28:gcch:${teamsAppId}`;
}
return `28:orgid:${botId}`;
return `28:orgid:${teamsAppId}`;
}

@@ -124,8 +115,7 @@ case "phoneNumber": {

};
const buildMicrosoftBotIdentifier = (id, cloud, isResourceAccountConfigured) => {
const buildMicrosoftTeamsAppIdentifier = (teamsAppId, cloud) => {
return {
kind: "microsoftBot",
botId: id,
kind: "microsoftTeamsApp",
teamsAppId: teamsAppId,
cloud: cloud,
isResourceAccountConfigured: isResourceAccountConfigured,
};

@@ -152,5 +142,2 @@ };

if (segments.length !== 3) {
if (segments.length === 2 && segments[0] === "28") {
return buildMicrosoftBotIdentifier(segments[1], "public", false);
}
return { kind: "unknown", id: rawId };

@@ -174,12 +161,8 @@ }

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);
return buildMicrosoftTeamsAppIdentifier(suffix, "public");
case "28:gcch:":
return buildMicrosoftBotIdentifier(suffix, "gcch", true);
return buildMicrosoftTeamsAppIdentifier(suffix, "gcch");
case "28:dod:":
return buildMicrosoftBotIdentifier(suffix, "dod", true);
return buildMicrosoftTeamsAppIdentifier(suffix, "dod");
}

@@ -186,0 +169,0 @@ return { kind: "unknown", id: rawId };

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

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

@@ -37,3 +37,3 @@ if (identifier.phoneNumber !== undefined) {

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

@@ -62,9 +62,8 @@ switch (identifierKind.kind) {

};
case "microsoftBot":
case "microsoftTeamsApp":
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",
microsoftTeamsApp: {
teamsAppId: identifierKind.teamsAppId,
cloud: (_f = identifierKind.cloud) !== null && _f !== void 0 ? _f : "public",
},

@@ -88,4 +87,4 @@ };

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

@@ -102,3 +101,3 @@ return "unknown";

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

@@ -127,9 +126,8 @@ if (kind === "communicationUser" && communicationUser) {

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

@@ -136,0 +134,0 @@ }

@@ -341,8 +341,8 @@ 'use strict';

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

@@ -372,4 +372,4 @@ /**

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

@@ -404,22 +404,13 @@ return Object.assign(Object.assign({}, identifier), { kind: "unknown" });

}
case "microsoftBot": {
const { botId, rawId, cloud, isResourceAccountConfigured } = identifierKind;
case "microsoftTeamsApp": {
const { teamsAppId, rawId, cloud } = 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}`;
return `28:dod:${teamsAppId}`;
case "gcch":
return `28:gcch:${botId}`;
return `28:gcch:${teamsAppId}`;
}
return `28:orgid:${botId}`;
return `28:orgid:${teamsAppId}`;
}

@@ -437,8 +428,7 @@ case "phoneNumber": {

};
const buildMicrosoftBotIdentifier = (id, cloud, isResourceAccountConfigured) => {
const buildMicrosoftTeamsAppIdentifier = (teamsAppId, cloud) => {
return {
kind: "microsoftBot",
botId: id,
kind: "microsoftTeamsApp",
teamsAppId: teamsAppId,
cloud: cloud,
isResourceAccountConfigured: isResourceAccountConfigured,
};

@@ -465,5 +455,2 @@ };

if (segments.length !== 3) {
if (segments.length === 2 && segments[0] === "28") {
return buildMicrosoftBotIdentifier(segments[1], "public", false);
}
return { kind: "unknown", id: rawId };

@@ -487,12 +474,8 @@ }

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);
return buildMicrosoftTeamsAppIdentifier(suffix, "public");
case "28:gcch:":
return buildMicrosoftBotIdentifier(suffix, "gcch", true);
return buildMicrosoftTeamsAppIdentifier(suffix, "gcch");
case "28:dod:":
return buildMicrosoftBotIdentifier(suffix, "dod", true);
return buildMicrosoftTeamsAppIdentifier(suffix, "dod");
}

@@ -519,4 +502,4 @@ return { kind: "unknown", id: rawId };

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

@@ -536,3 +519,3 @@ if (identifier.phoneNumber !== undefined) {

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

@@ -561,9 +544,8 @@ switch (identifierKind.kind) {

};
case "microsoftBot":
case "microsoftTeamsApp":
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",
microsoftTeamsApp: {
teamsAppId: identifierKind.teamsAppId,
cloud: (_f = identifierKind.cloud) !== null && _f !== void 0 ? _f : "public",
},

@@ -587,4 +569,4 @@ };

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

@@ -601,3 +583,3 @@ return "unknown";

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

@@ -626,9 +608,8 @@ if (kind === "communicationUser" && communicationUser) {

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

@@ -651,3 +632,3 @@ }

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

@@ -654,0 +635,0 @@ exports.isPhoneNumberIdentifier = isPhoneNumberIdentifier;

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

@@ -5,0 +5,0 @@ "sdk-type": "client",

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

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

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

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

@@ -189,7 +189,7 @@ /**

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

@@ -218,20 +218,16 @@ /**

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

@@ -241,9 +237,9 @@ }

/**
* IdentifierKind for a MicrosoftBotIdentifier.
* IdentifierKind for a MicrosoftTeamsAppIdentifier.
*/
export declare interface MicrosoftBotKind extends MicrosoftBotIdentifier {
export declare interface MicrosoftTeamsAppKind extends MicrosoftTeamsAppIdentifier {
/**
* The identifier kind.
*/
kind: "microsoftBot";
kind: "microsoftTeamsApp";
}

@@ -361,5 +357,5 @@

/**
* The Microsoft bot.
* The Microsoft Teams App.
*/
microsoftBot?: SerializedMicrosoftBotIdentifier;
microsoftTeamsApp?: SerializedMicrosoftTeamsAppIdentifier;
}

@@ -380,16 +376,12 @@

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

@@ -396,0 +388,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

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