Socket
Socket
Sign inDemoInstall

@azure/communication-common

Package Overview
Dependencies
8
Maintainers
1
Versions
153
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.2.1 to 2.3.0-alpha.20230927.1

70

dist-esm/src/identifierModels.js

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

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

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

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

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

}
case "microsoftTeamsApp": {
const { teamsAppId, rawId, cloud } = identifierKind;
if (rawId)
return rawId;
switch (cloud) {
case "dod":
return `28:dod:${teamsAppId}`;
case "gcch":
return `28:gcch:${teamsAppId}`;
}
return `28:orgid:${teamsAppId}`;
}
case "phoneNumber": {

@@ -92,2 +115,17 @@ const { phoneNumber, rawId } = identifierKind;

};
const buildMicrosoftTeamsAppIdentifier = (teamsAppId, cloud) => {
return {
kind: "microsoftTeamsApp",
teamsAppId: teamsAppId,
cloud: cloud,
};
};
const buildMicrosoftTeamsUserIdentifier = (id, cloud, isAnonymous) => {
return {
kind: "microsoftTeamsUser",
microsoftTeamsUserId: id,
isAnonymous: isAnonymous,
cloud: cloud,
};
};
/**

@@ -103,6 +141,7 @@ * 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) {
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 +151,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 +162,8 @@ case "8:spool:":

return { kind: "communicationUser", communicationUserId: rawId };
case "28:orgid:":
return buildMicrosoftTeamsAppIdentifier(suffix, "public");
case "28:gcch:":
return buildMicrosoftTeamsAppIdentifier(suffix, "gcch");
case "28:dod:":
return buildMicrosoftTeamsAppIdentifier(suffix, "dod");
}

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

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

}
if (identifier.microsoftTeamsApp !== undefined) {
presentProperties.push("microsoftTeamsApp");
}
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;
const identifierKind = getIdentifierKind(identifier);

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

};
case "microsoftTeamsApp":
return {
rawId: (_e = identifierKind.rawId) !== null && _e !== void 0 ? _e : getIdentifierRawId(identifierKind),
microsoftTeamsApp: {
teamsAppId: identifierKind.teamsAppId,
cloud: (_f = identifierKind.cloud) !== null && _f !== void 0 ? _f : "public",
},
};
case "unknown":

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

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

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

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

@@ -112,2 +126,10 @@ if (kind === "communicationUser" && communicationUser) {

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

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

@@ -341,2 +341,10 @@ 'use strict';

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

@@ -364,2 +372,5 @@ *

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

@@ -393,2 +404,14 @@ };

}
case "microsoftTeamsApp": {
const { teamsAppId, rawId, cloud } = identifierKind;
if (rawId)
return rawId;
switch (cloud) {
case "dod":
return `28:dod:${teamsAppId}`;
case "gcch":
return `28:gcch:${teamsAppId}`;
}
return `28:orgid:${teamsAppId}`;
}
case "phoneNumber": {

@@ -405,2 +428,17 @@ const { phoneNumber, rawId } = identifierKind;

};
const buildMicrosoftTeamsAppIdentifier = (teamsAppId, cloud) => {
return {
kind: "microsoftTeamsApp",
teamsAppId: teamsAppId,
cloud: cloud,
};
};
const buildMicrosoftTeamsUserIdentifier = (id, cloud, isAnonymous) => {
return {
kind: "microsoftTeamsUser",
microsoftTeamsUserId: id,
isAnonymous: isAnonymous,
cloud: cloud,
};
};
/**

@@ -416,6 +454,7 @@ * 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) {
return { kind: "unknown", id: rawId };
}
const prefix = `${segments[0]}:${segments[1]}:`;
const suffix = rawId.substring(prefix.length);
const suffix = segments[2];
switch (prefix) {

@@ -425,22 +464,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:":

@@ -451,2 +475,8 @@ case "8:spool:":

return { kind: "communicationUser", communicationUserId: rawId };
case "28:orgid:":
return buildMicrosoftTeamsAppIdentifier(suffix, "public");
case "28:gcch:":
return buildMicrosoftTeamsAppIdentifier(suffix, "gcch");
case "28:dod:":
return buildMicrosoftTeamsAppIdentifier(suffix, "dod");
}

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

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

@@ -487,3 +520,3 @@ presentProperties.push("phoneNumber");

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

@@ -512,2 +545,10 @@ switch (identifierKind.kind) {

};
case "microsoftTeamsApp":
return {
rawId: (_e = identifierKind.rawId) !== null && _e !== void 0 ? _e : getIdentifierRawId(identifierKind),
microsoftTeamsApp: {
teamsAppId: identifierKind.teamsAppId,
cloud: (_f = identifierKind.cloud) !== null && _f !== void 0 ? _f : "public",
},
};
case "unknown":

@@ -529,2 +570,5 @@ return { rawId: identifierKind.id };

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

@@ -540,3 +584,3 @@ };

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

@@ -565,2 +609,10 @@ if (kind === "communicationUser" && communicationUser) {

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

@@ -581,2 +633,3 @@ kind: "unknown",

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

@@ -583,0 +636,0 @@ exports.isPhoneNumberIdentifier = isPhoneNumberIdentifier;

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

@@ -26,3 +26,3 @@ "sdk-type": "client",

"integration-test:browser": "karma start --single-run",
"integration-test:node": "nyc mocha -r esm --require source-map-support/register --reporter ../../../common/tools/mocha-multi-reporter.js --full-trace -t 300000 dist-esm/test/**/*.spec.js dist-esm/test/node/*.spec.js",
"integration-test:node": "dev-tool run test:node-js-input -- --timeout 5000000 'dist-esm/test/**/*.spec.js'",
"integration-test": "npm run integration-test:node && npm run integration-test:browser",

@@ -36,3 +36,3 @@ "lint:fix": "eslint package.json api-extractor.json README.md src test --ext .ts,.javascript,.js --fix --fix-type [problem,suggestion]",

"unit-test:browser": "karma start --single-run",
"unit-test:node": "mocha -r esm -r ts-node/register --reporter ../../../common/tools/mocha-multi-reporter.js --full-trace --exclude \"test/**/browser/*.spec.ts\" \"test/**/*.spec.ts\"",
"unit-test:node": "dev-tool run test:node-ts-input --no-test-proxy=true",
"unit-test": "npm run unit-test:node && npm run unit-test:browser"

@@ -77,10 +77,10 @@ },

"devDependencies": {
"@azure/eslint-plugin-azure-sdk": "^3.0.0",
"@azure/dev-tool": "^1.0.0",
"@azure/eslint-plugin-azure-sdk": ">=3.0.0-alpha <3.0.0-alphb",
"@azure/dev-tool": ">=1.0.0-alpha <1.0.0-alphb",
"@microsoft/api-extractor": "^7.31.1",
"@types/chai-as-promised": "^7.1.0",
"@types/chai": "^4.1.6",
"@types/mocha": "^7.0.2",
"@types/mocha": "^10.0.0",
"@types/node": "^14.0.0",
"@types/sinon": "^9.0.4",
"@types/sinon": "^10.0.0",
"chai-as-promised": "^7.1.1",

@@ -101,11 +101,13 @@ "chai": "^4.2.0",

"mocha-junit-reporter": "^2.0.0",
"mocha": "^7.1.1",
"mocha": "^10.0.0",
"nyc": "^15.0.0",
"prettier": "^2.5.1",
"rimraf": "^3.0.0",
"sinon": "^9.0.2",
"typescript": "~4.8.0",
"sinon": "^15.0.0",
"typescript": "~5.0.0",
"util": "^0.12.1",
"mockdate": "^3.0.5"
"mockdate": "^3.0.5",
"ts-node": "^10.0.0",
"esm": "^3.2.18"
}
}

@@ -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 | MicrosoftTeamsAppIdentifier | UnknownIdentifier;

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

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

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

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

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

/**
* A Microsoft Teams App.
*/
export declare interface MicrosoftTeamsAppIdentifier {
/**
* Optional raw id of the Microsoft Teams App.
*/
rawId?: string;
/**
* The unique Microsoft Teams app ID.
*/
teamsAppId: string;
/**
* The cloud that the Microsoft Temas App belongs to. If missing, the cloud is "public".
*/
cloud?: "public" | "dod" | "gcch";
}
/**
* IdentifierKind for a MicrosoftTeamsAppIdentifier.
*/
export declare interface MicrosoftTeamsAppKind extends MicrosoftTeamsAppIdentifier {
/**
* The identifier kind.
*/
kind: "microsoftTeamsApp";
}
/**
* A Microsoft Teams user.

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

microsoftTeamsUser?: SerializedMicrosoftTeamsUserIdentifier;
/**
* The Microsoft Teams App.
*/
microsoftTeamsApp?: SerializedMicrosoftTeamsAppIdentifier;
}

@@ -336,2 +375,17 @@

* @hidden
* A Microsoft Teams App.
*/
export declare interface SerializedMicrosoftTeamsAppIdentifier {
/**
* Id of the Microsoft Teams App.
*/
teamsAppId: string;
/**
* The cloud that the Microsoft Teams App belongs to. By default 'public' if missing.
*/
cloud?: SerializedCommunicationCloudEnvironment;
}
/**
* @hidden
* A Microsoft Teams user.

@@ -338,0 +392,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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc