Socket
Socket
Sign inDemoInstall

@azure/communication-common

Package Overview
Dependencies
Maintainers
3
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 1.0.0-alpha.20210126.1 to 1.0.0-alpha.20210205.1

9

CHANGELOG.md
# Release History
## 1.0.0-beta.5 (Unreleased)
### Breaking Changes
- Removed `CallingApplicationIdentifier` and `isCallingApplicationIdentifier`.
- Removed `id` from `CommunicationUserIdentifier`.
- Renamed `id` to `rawId` in `PhoneNumberIdentifier`.
- Renamed `id` to `rawId` in `MicrosoftTeamsUserIdentifier`.
## 1.0.0-beta.4 (2021-01-25)

@@ -4,0 +13,0 @@

11

dist-esm/src/identifierModels.js

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

/**
* Tests an Identifier to determine whether it implements MicrosoftTeamsUserIdentifier.
*
* @param identifier The assumed CallingApplicationIdentifier to be tested.
*/
export const isCallingApplicationIdentifier = (identifier) => {
return typeof identifier.callingApplicationId === "string";
};
/**
* Tests an Identifier to determine whether it implements UnknownIdentifier.

@@ -56,5 +48,2 @@ *

}
if (isCallingApplicationIdentifier(identifier)) {
return Object.assign(Object.assign({}, identifier), { kind: "callingApplication" });
}
if (isMicrosoftTeamsUserIdentifier(identifier)) {

@@ -61,0 +50,0 @@ return Object.assign(Object.assign({}, identifier), { kind: "microsoftTeamsUser" });

101

dist-esm/src/identifierModelSerializer.js
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
import { __rest } from "tslib";
import { getIdentifierKind } from "./identifierModels";
const addIdIfExisting = (identifier, id) => {
return id === undefined ? identifier : Object.assign(Object.assign({}, identifier), { id });
};
/**

@@ -17,16 +15,15 @@ * @internal

case "communicationUser":
return { kind: "communicationUser", id: identifierKind.communicationUserId };
case "callingApplication":
return { kind: "callingApplication", id: identifierKind.callingApplicationId };
return { communicationUser: { id: identifierKind.communicationUserId } };
case "phoneNumber":
return addIdIfExisting({ kind: "phoneNumber", phoneNumber: identifierKind.phoneNumber }, identifierKind.id);
return addRawIdIfExisting({ phoneNumber: { value: identifierKind.phoneNumber } }, identifierKind.rawId);
case "microsoftTeamsUser":
return addIdIfExisting({
kind: "microsoftTeamsUser",
microsoftTeamsUserId: identifierKind.microsoftTeamsUserId,
isAnonymous: (_a = identifierKind.isAnonymous) !== null && _a !== void 0 ? _a : false,
cloud: (_b = identifierKind.cloud) !== null && _b !== void 0 ? _b : "public"
}, identifierKind.id);
return addRawIdIfExisting({
microsoftTeamsUser: {
userId: identifierKind.microsoftTeamsUserId,
isAnonymous: (_a = identifierKind.isAnonymous) !== null && _a !== void 0 ? _a : false,
cloud: (_b = identifierKind.cloud) !== null && _b !== void 0 ? _b : "public"
}
}, identifierKind.rawId);
case "unknown":
return { kind: "unknown", id: identifierKind.id };
return { rawId: identifierKind.id };
default:

@@ -42,41 +39,49 @@ throw new Error(`Can't serialize an identifier with kind ${identifierKind.kind}`);

export const _deserializeCommunicationIdentifier = (serializedIdentifier) => {
switch (serializedIdentifier.kind) {
case "communicationUser":
return {
kind: "communicationUser",
communicationUserId: assertNotNullOrUndefined(serializedIdentifier, "id"),
id: assertNotNullOrUndefined(serializedIdentifier, "id")
};
case "callingApplication":
return {
kind: "callingApplication",
callingApplicationId: assertNotNullOrUndefined(serializedIdentifier, "id"),
id: assertNotNullOrUndefined(serializedIdentifier, "id")
};
case "phoneNumber":
return {
kind: "phoneNumber",
phoneNumber: assertNotNullOrUndefined(serializedIdentifier, "phoneNumber"),
id: assertNotNullOrUndefined(serializedIdentifier, "id")
};
case "microsoftTeamsUser":
return {
kind: "microsoftTeamsUser",
microsoftTeamsUserId: assertNotNullOrUndefined(serializedIdentifier, "microsoftTeamsUserId"),
isAnonymous: assertNotNullOrUndefined(serializedIdentifier, "isAnonymous"),
cloud: assertNotNullOrUndefined(serializedIdentifier, "cloud"),
id: assertNotNullOrUndefined(serializedIdentifier, "id")
};
case "unknown":
return { kind: "unknown", id: assertNotNullOrUndefined(serializedIdentifier, "id") };
default:
return { kind: "unknown", id: assertNotNullOrUndefined(serializedIdentifier, "id") };
assertMaximumOneNestedModel(serializedIdentifier);
const { communicationUser, microsoftTeamsUser, phoneNumber } = serializedIdentifier;
if (communicationUser) {
return {
kind: "communicationUser",
communicationUserId: assertNotNullOrUndefined({ communicationUser }, "id")
};
}
if (phoneNumber) {
return {
kind: "phoneNumber",
phoneNumber: assertNotNullOrUndefined({ phoneNumber }, "value"),
rawId: assertNotNullOrUndefined({ phoneNumber: serializedIdentifier }, "rawId")
};
}
if (microsoftTeamsUser) {
return {
kind: "microsoftTeamsUser",
microsoftTeamsUserId: assertNotNullOrUndefined({ microsoftTeamsUser }, "userId"),
isAnonymous: assertNotNullOrUndefined({ microsoftTeamsUser }, "isAnonymous"),
cloud: assertNotNullOrUndefined({ microsoftTeamsUser }, "cloud"),
rawId: assertNotNullOrUndefined({ microsoftTeamsUser: serializedIdentifier }, "rawId")
};
}
return {
kind: "unknown",
id: assertNotNullOrUndefined({ unknown: serializedIdentifier }, "rawId")
};
};
const addRawIdIfExisting = (identifier, rawId) => {
return rawId === undefined ? identifier : Object.assign(Object.assign({}, identifier), { rawId: rawId });
};
const assertNotNullOrUndefined = (obj, prop) => {
if (prop in obj) {
return obj[prop];
const subObjName = Object.keys(obj)[0];
const subObj = obj[subObjName];
if (prop in subObj) {
return subObj[prop];
}
throw new Error(`Property ${prop} is required for identifier of kind ${obj.kind}.`);
throw new Error(`Property ${prop} is required for identifier of type ${subObjName}.`);
};
const assertMaximumOneNestedModel = (identifier) => {
const { rawId } = identifier, props = __rest(identifier, ["rawId"]);
const keys = Object.keys(props);
if (keys.length > 1) {
throw new Error(`Only one of the properties in ${JSON.stringify(keys)} should be present.`);
}
};
//# sourceMappingURL=identifierModelSerializer.js.map

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

/**
* Tests an Identifier to determine whether it implements MicrosoftTeamsUserIdentifier.
*
* @param identifier The assumed CallingApplicationIdentifier to be tested.
*/
const isCallingApplicationIdentifier = (identifier) => {
return typeof identifier.callingApplicationId === "string";
};
/**
* Tests an Identifier to determine whether it implements UnknownIdentifier.

@@ -393,5 +385,2 @@ *

}
if (isCallingApplicationIdentifier(identifier)) {
return Object.assign(Object.assign({}, identifier), { kind: "callingApplication" });
}
if (isMicrosoftTeamsUserIdentifier(identifier)) {

@@ -404,5 +393,2 @@ return Object.assign(Object.assign({}, identifier), { kind: "microsoftTeamsUser" });

// Copyright (c) Microsoft Corporation.
const addIdIfExisting = (identifier, id) => {
return id === undefined ? identifier : Object.assign(Object.assign({}, identifier), { id });
};
/**

@@ -418,16 +404,15 @@ * @internal

case "communicationUser":
return { kind: "communicationUser", id: identifierKind.communicationUserId };
case "callingApplication":
return { kind: "callingApplication", id: identifierKind.callingApplicationId };
return { communicationUser: { id: identifierKind.communicationUserId } };
case "phoneNumber":
return addIdIfExisting({ kind: "phoneNumber", phoneNumber: identifierKind.phoneNumber }, identifierKind.id);
return addRawIdIfExisting({ phoneNumber: { value: identifierKind.phoneNumber } }, identifierKind.rawId);
case "microsoftTeamsUser":
return addIdIfExisting({
kind: "microsoftTeamsUser",
microsoftTeamsUserId: identifierKind.microsoftTeamsUserId,
isAnonymous: (_a = identifierKind.isAnonymous) !== null && _a !== void 0 ? _a : false,
cloud: (_b = identifierKind.cloud) !== null && _b !== void 0 ? _b : "public"
}, identifierKind.id);
return addRawIdIfExisting({
microsoftTeamsUser: {
userId: identifierKind.microsoftTeamsUserId,
isAnonymous: (_a = identifierKind.isAnonymous) !== null && _a !== void 0 ? _a : false,
cloud: (_b = identifierKind.cloud) !== null && _b !== void 0 ? _b : "public"
}
}, identifierKind.rawId);
case "unknown":
return { kind: "unknown", id: identifierKind.id };
return { rawId: identifierKind.id };
default:

@@ -443,41 +428,49 @@ throw new Error(`Can't serialize an identifier with kind ${identifierKind.kind}`);

const _deserializeCommunicationIdentifier = (serializedIdentifier) => {
switch (serializedIdentifier.kind) {
case "communicationUser":
return {
kind: "communicationUser",
communicationUserId: assertNotNullOrUndefined(serializedIdentifier, "id"),
id: assertNotNullOrUndefined(serializedIdentifier, "id")
};
case "callingApplication":
return {
kind: "callingApplication",
callingApplicationId: assertNotNullOrUndefined(serializedIdentifier, "id"),
id: assertNotNullOrUndefined(serializedIdentifier, "id")
};
case "phoneNumber":
return {
kind: "phoneNumber",
phoneNumber: assertNotNullOrUndefined(serializedIdentifier, "phoneNumber"),
id: assertNotNullOrUndefined(serializedIdentifier, "id")
};
case "microsoftTeamsUser":
return {
kind: "microsoftTeamsUser",
microsoftTeamsUserId: assertNotNullOrUndefined(serializedIdentifier, "microsoftTeamsUserId"),
isAnonymous: assertNotNullOrUndefined(serializedIdentifier, "isAnonymous"),
cloud: assertNotNullOrUndefined(serializedIdentifier, "cloud"),
id: assertNotNullOrUndefined(serializedIdentifier, "id")
};
case "unknown":
return { kind: "unknown", id: assertNotNullOrUndefined(serializedIdentifier, "id") };
default:
return { kind: "unknown", id: assertNotNullOrUndefined(serializedIdentifier, "id") };
assertMaximumOneNestedModel(serializedIdentifier);
const { communicationUser, microsoftTeamsUser, phoneNumber } = serializedIdentifier;
if (communicationUser) {
return {
kind: "communicationUser",
communicationUserId: assertNotNullOrUndefined({ communicationUser }, "id")
};
}
if (phoneNumber) {
return {
kind: "phoneNumber",
phoneNumber: assertNotNullOrUndefined({ phoneNumber }, "value"),
rawId: assertNotNullOrUndefined({ phoneNumber: serializedIdentifier }, "rawId")
};
}
if (microsoftTeamsUser) {
return {
kind: "microsoftTeamsUser",
microsoftTeamsUserId: assertNotNullOrUndefined({ microsoftTeamsUser }, "userId"),
isAnonymous: assertNotNullOrUndefined({ microsoftTeamsUser }, "isAnonymous"),
cloud: assertNotNullOrUndefined({ microsoftTeamsUser }, "cloud"),
rawId: assertNotNullOrUndefined({ microsoftTeamsUser: serializedIdentifier }, "rawId")
};
}
return {
kind: "unknown",
id: assertNotNullOrUndefined({ unknown: serializedIdentifier }, "rawId")
};
};
const addRawIdIfExisting = (identifier, rawId) => {
return rawId === undefined ? identifier : Object.assign(Object.assign({}, identifier), { rawId: rawId });
};
const assertNotNullOrUndefined = (obj, prop) => {
if (prop in obj) {
return obj[prop];
const subObjName = Object.keys(obj)[0];
const subObj = obj[subObjName];
if (prop in subObj) {
return subObj[prop];
}
throw new Error(`Property ${prop} is required for identifier of kind ${obj.kind}.`);
throw new Error(`Property ${prop} is required for identifier of type ${subObjName}.`);
};
const assertMaximumOneNestedModel = (identifier) => {
const props = tslib.__rest(identifier, ["rawId"]);
const keys = Object.keys(props);
if (keys.length > 1) {
throw new Error(`Only one of the properties in ${JSON.stringify(keys)} should be present.`);
}
};

@@ -490,3 +483,2 @@ exports.AzureCommunicationTokenCredential = AzureCommunicationTokenCredential;

exports.getIdentifierKind = getIdentifierKind;
exports.isCallingApplicationIdentifier = isCallingApplicationIdentifier;
exports.isCommunicationUserIdentifier = isCommunicationUserIdentifier;

@@ -493,0 +485,0 @@ exports.isKeyCredential = isKeyCredential;

{
"name": "@azure/communication-common",
"version": "1.0.0-alpha.20210126.1",
"version": "1.0.0-alpha.20210205.1",
"description": "Common package for Azure Communication services.",

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

@@ -37,25 +37,5 @@ import { AbortSignalLike } from '@azure/core-http';

/**
* A calling application, i.e. a non-human participant in communication.
*/
export declare interface CallingApplicationIdentifier extends WithOptionalFullId {
/**
* Id of the CallingApplication.
*/
callingApplicationId: string;
}
/**
* IdentifierKind for a CallingApplicationIdentifier.
*/
export declare interface CallingApplicationKind extends CallingApplicationIdentifier {
/**
* The identifier kind.
*/
kind: "callingApplication";
}
/**
* Identifies a communication participant.
*/
export declare type CommunicationIdentifier = CommunicationUserIdentifier | PhoneNumberIdentifier | CallingApplicationIdentifier | MicrosoftTeamsUserIdentifier | UnknownIdentifier;
export declare type CommunicationIdentifier = CommunicationUserIdentifier | PhoneNumberIdentifier | MicrosoftTeamsUserIdentifier | UnknownIdentifier;

@@ -65,3 +45,3 @@ /**

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

@@ -105,3 +85,3 @@ /**

*/
export declare interface CommunicationUserIdentifier extends WithOptionalFullId {
export declare interface CommunicationUserIdentifier {
/**

@@ -164,9 +144,2 @@ * Id of the CommunicationUser as returned from the Communication Service.

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

@@ -209,3 +182,3 @@ *

*/
export declare interface MicrosoftTeamsUserIdentifier extends WithOptionalFullId {
export declare interface MicrosoftTeamsUserIdentifier extends WithOptionalRawId {
/**

@@ -254,3 +227,3 @@ * Id of the Microsoft Teams user. If the user isn't anonymous, the id is the AAD object id of the user.

*/
export declare interface PhoneNumberIdentifier extends WithOptionalFullId {
export declare interface PhoneNumberIdentifier extends WithOptionalRawId {
/**

@@ -278,4 +251,8 @@ * The phone number in E.164 format.

/* Excluded from this release type: _SerializedCommunicationIdentifierKind */
/* Excluded from this release type: _SerializedCommunicationUserIdentifier */
/* Excluded from this release type: _SerializedMicrosoftTeamsUserIdentifier */
/* Excluded from this release type: _SerializedPhoneNumberIdentifier */
/**

@@ -309,9 +286,9 @@ * An unknown identifier that doesn't fit any of the other identifier types.

export declare interface WithOptionalFullId {
export declare interface WithOptionalRawId {
/**
* Optional full id of the identifier.
* Optional raw id of the identifier.
*/
id?: string;
rawId?: string;
}
export { }

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