@azure/communication-common 2.3.2-alpha.20250314.1 → 2.3.2-alpha.20250317.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/identifierModelSerializer.d.ts +35 -1
- package/dist/browser/identifierModelSerializer.d.ts.map +1 -1
- package/dist/browser/identifierModelSerializer.js +42 -8
- package/dist/browser/identifierModelSerializer.js.map +1 -1
- package/dist/browser/identifierModels.d.ts +52 -4
- package/dist/browser/identifierModels.d.ts.map +1 -1
- package/dist/browser/identifierModels.js +60 -2
- package/dist/browser/identifierModels.js.map +1 -1
- package/dist/commonjs/identifierModelSerializer.d.ts +35 -1
- package/dist/commonjs/identifierModelSerializer.d.ts.map +1 -1
- package/dist/commonjs/identifierModelSerializer.js +42 -8
- package/dist/commonjs/identifierModelSerializer.js.map +1 -1
- package/dist/commonjs/identifierModels.d.ts +52 -4
- package/dist/commonjs/identifierModels.d.ts.map +1 -1
- package/dist/commonjs/identifierModels.js +62 -3
- package/dist/commonjs/identifierModels.js.map +1 -1
- package/dist/esm/identifierModelSerializer.d.ts +35 -1
- package/dist/esm/identifierModelSerializer.d.ts.map +1 -1
- package/dist/esm/identifierModelSerializer.js +42 -8
- package/dist/esm/identifierModelSerializer.js.map +1 -1
- package/dist/esm/identifierModels.d.ts +52 -4
- package/dist/esm/identifierModels.d.ts.map +1 -1
- package/dist/esm/identifierModels.js +60 -2
- package/dist/esm/identifierModels.js.map +1 -1
- package/dist/react-native/identifierModelSerializer.d.ts +35 -1
- package/dist/react-native/identifierModelSerializer.d.ts.map +1 -1
- package/dist/react-native/identifierModelSerializer.js +42 -8
- package/dist/react-native/identifierModelSerializer.js.map +1 -1
- package/dist/react-native/identifierModels.d.ts +52 -4
- package/dist/react-native/identifierModels.d.ts.map +1 -1
- package/dist/react-native/identifierModels.js +60 -2
- package/dist/react-native/identifierModels.js.map +1 -1
- package/package.json +1 -1
|
@@ -28,6 +28,10 @@ export interface SerializedCommunicationIdentifier {
|
|
|
28
28
|
* The Microsoft Teams App.
|
|
29
29
|
*/
|
|
30
30
|
microsoftTeamsApp?: SerializedMicrosoftTeamsAppIdentifier;
|
|
31
|
+
/**
|
|
32
|
+
* The Microsoft Teams Extension user.
|
|
33
|
+
*/
|
|
34
|
+
teamsExtensionUser?: SerializedTeamsExtensionUserIdentifier;
|
|
31
35
|
}
|
|
32
36
|
/**
|
|
33
37
|
* @hidden
|
|
@@ -48,6 +52,14 @@ export interface SerializedPhoneNumberIdentifier {
|
|
|
48
52
|
* The phone number in E.164 format.
|
|
49
53
|
*/
|
|
50
54
|
value: string;
|
|
55
|
+
/**
|
|
56
|
+
* The asserted Id is set on a phone number that is already in the same call to distinguish from other connections made through the same number.
|
|
57
|
+
*/
|
|
58
|
+
assertedId?: string;
|
|
59
|
+
/**
|
|
60
|
+
* True if the phone number is anonymous.
|
|
61
|
+
*/
|
|
62
|
+
isAnonymous?: boolean;
|
|
51
63
|
}
|
|
52
64
|
/**
|
|
53
65
|
* @hidden
|
|
@@ -55,7 +67,7 @@ export interface SerializedPhoneNumberIdentifier {
|
|
|
55
67
|
*/
|
|
56
68
|
export interface SerializedMicrosoftTeamsUserIdentifier {
|
|
57
69
|
/**
|
|
58
|
-
* The Id of the Microsoft Teams user. If not anonymous, this is the
|
|
70
|
+
* The Id of the Microsoft Teams user. If not anonymous, this is the Entra ID object Id of the user.
|
|
59
71
|
*/
|
|
60
72
|
userId: string;
|
|
61
73
|
/**
|
|
@@ -81,6 +93,28 @@ export interface SerializedMicrosoftTeamsAppIdentifier {
|
|
|
81
93
|
*/
|
|
82
94
|
cloud?: SerializedCommunicationCloudEnvironment;
|
|
83
95
|
}
|
|
96
|
+
/**
|
|
97
|
+
* @hidden
|
|
98
|
+
* A Microsoft Teams Phone user who is using the Azure Communication Services resource to extend their Teams Phone set up.
|
|
99
|
+
*/
|
|
100
|
+
export interface SerializedTeamsExtensionUserIdentifier {
|
|
101
|
+
/**
|
|
102
|
+
* The Id of the Microsoft Teams Extension user, i.e. the Entra ID object Id of the user.
|
|
103
|
+
*/
|
|
104
|
+
userId: string;
|
|
105
|
+
/**
|
|
106
|
+
* The tenant Id of the Microsoft Teams Extension user.
|
|
107
|
+
*/
|
|
108
|
+
tenantId: string;
|
|
109
|
+
/**
|
|
110
|
+
* The Azure Communication Services resource Id.
|
|
111
|
+
*/
|
|
112
|
+
resourceId: string;
|
|
113
|
+
/**
|
|
114
|
+
* The cloud that the Microsoft Teams Extension user belongs to. If missing, the cloud is "public".
|
|
115
|
+
*/
|
|
116
|
+
cloud?: SerializedCommunicationCloudEnvironment;
|
|
117
|
+
}
|
|
84
118
|
/**
|
|
85
119
|
* @hidden
|
|
86
120
|
* Defines values for CommunicationCloudEnvironmentModel.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"identifierModelSerializer.d.ts","sourceRoot":"","sources":["../../src/identifierModelSerializer.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,KAAK,uBAAuB,EAC5B,KAAK,2BAA2B,EAGjC,MAAM,uBAAuB,CAAC;AAE/B;;;GAGG;AACH,MAAM,WAAW,iCAAiC;IAChD;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,iBAAiB,CAAC,EAAE,qCAAqC,CAAC;IAC1D;;OAEG;IACH,WAAW,CAAC,EAAE,+BAA+B,CAAC;IAC9C;;OAEG;IACH,kBAAkB,CAAC,EAAE,sCAAsC,CAAC;IAC5D;;OAEG;IACH,iBAAiB,CAAC,EAAE,qCAAqC,CAAC;
|
|
1
|
+
{"version":3,"file":"identifierModelSerializer.d.ts","sourceRoot":"","sources":["../../src/identifierModelSerializer.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,KAAK,uBAAuB,EAC5B,KAAK,2BAA2B,EAGjC,MAAM,uBAAuB,CAAC;AAE/B;;;GAGG;AACH,MAAM,WAAW,iCAAiC;IAChD;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AG,KAAK,GAAG,MAAM,CAAC;AA0ChF;;;;GAIG;AACH,eAAO,MAAM,gCAAgC,eAC/B,uBAAuB,KAClC,iCAiDF,CAAC;AA0BF;;;;GAIG;AACH,eAAO,MAAM,kCAAkC,yBACvB,iCAAiC,KACtD,2BAwDF,CAAC"}
|
|
@@ -23,6 +23,9 @@ const assertMaximumOneNestedModel = (identifier) => {
|
|
|
23
23
|
if (identifier.phoneNumber !== undefined) {
|
|
24
24
|
presentProperties.push("phoneNumber");
|
|
25
25
|
}
|
|
26
|
+
if (identifier.teamsExtensionUser !== undefined) {
|
|
27
|
+
presentProperties.push("teamsExtensionUser");
|
|
28
|
+
}
|
|
26
29
|
if (presentProperties.length > 1) {
|
|
27
30
|
throw new Error(`Only one of the properties in ${JSON.stringify(presentProperties)} should be present.`);
|
|
28
31
|
}
|
|
@@ -33,7 +36,7 @@ const assertMaximumOneNestedModel = (identifier) => {
|
|
|
33
36
|
* @param identifier - The CommunicationIdentifier to be serialized.
|
|
34
37
|
*/
|
|
35
38
|
export const serializeCommunicationIdentifier = (identifier) => {
|
|
36
|
-
var _a, _b, _c, _d, _e, _f;
|
|
39
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
37
40
|
const identifierKind = getIdentifierKind(identifier);
|
|
38
41
|
switch (identifierKind.kind) {
|
|
39
42
|
case "communicationUser":
|
|
@@ -46,23 +49,35 @@ export const serializeCommunicationIdentifier = (identifier) => {
|
|
|
46
49
|
rawId: (_a = identifierKind.rawId) !== null && _a !== void 0 ? _a : getIdentifierRawId(identifierKind),
|
|
47
50
|
phoneNumber: {
|
|
48
51
|
value: identifierKind.phoneNumber,
|
|
52
|
+
isAnonymous: (_b = identifierKind.isAnonymous) !== null && _b !== void 0 ? _b : false,
|
|
53
|
+
assertedId: identifierKind.assertedId,
|
|
49
54
|
},
|
|
50
55
|
};
|
|
51
56
|
case "microsoftTeamsUser":
|
|
52
57
|
return {
|
|
53
|
-
rawId: (
|
|
58
|
+
rawId: (_c = identifierKind.rawId) !== null && _c !== void 0 ? _c : getIdentifierRawId(identifierKind),
|
|
54
59
|
microsoftTeamsUser: {
|
|
55
60
|
userId: identifierKind.microsoftTeamsUserId,
|
|
56
|
-
isAnonymous: (
|
|
57
|
-
cloud: (
|
|
61
|
+
isAnonymous: (_d = identifierKind.isAnonymous) !== null && _d !== void 0 ? _d : false,
|
|
62
|
+
cloud: (_e = identifierKind.cloud) !== null && _e !== void 0 ? _e : "public",
|
|
58
63
|
},
|
|
59
64
|
};
|
|
60
65
|
case "microsoftTeamsApp":
|
|
61
66
|
return {
|
|
62
|
-
rawId: (
|
|
67
|
+
rawId: (_f = identifierKind.rawId) !== null && _f !== void 0 ? _f : getIdentifierRawId(identifierKind),
|
|
63
68
|
microsoftTeamsApp: {
|
|
64
69
|
appId: identifierKind.teamsAppId,
|
|
65
|
-
cloud: (
|
|
70
|
+
cloud: (_g = identifierKind.cloud) !== null && _g !== void 0 ? _g : "public",
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
case "teamsExtensionUser":
|
|
74
|
+
return {
|
|
75
|
+
rawId: (_h = identifierKind.rawId) !== null && _h !== void 0 ? _h : getIdentifierRawId(identifierKind),
|
|
76
|
+
teamsExtensionUser: {
|
|
77
|
+
userId: identifierKind.userId,
|
|
78
|
+
tenantId: identifierKind.tenantId,
|
|
79
|
+
resourceId: identifierKind.resourceId,
|
|
80
|
+
cloud: (_j = identifierKind.cloud) !== null && _j !== void 0 ? _j : "public",
|
|
66
81
|
},
|
|
67
82
|
};
|
|
68
83
|
case "unknown":
|
|
@@ -84,6 +99,9 @@ const getKind = (serializedIdentifier) => {
|
|
|
84
99
|
if (serializedIdentifier.microsoftTeamsApp) {
|
|
85
100
|
return "microsoftTeamsApp";
|
|
86
101
|
}
|
|
102
|
+
if (serializedIdentifier.teamsExtensionUser) {
|
|
103
|
+
return "teamsExtensionUser";
|
|
104
|
+
}
|
|
87
105
|
return "unknown";
|
|
88
106
|
};
|
|
89
107
|
/**
|
|
@@ -92,9 +110,13 @@ const getKind = (serializedIdentifier) => {
|
|
|
92
110
|
* @param serializedIdentifier - The SerializedCommunicationIdentifier to be deserialized.
|
|
93
111
|
*/
|
|
94
112
|
export const deserializeCommunicationIdentifier = (serializedIdentifier) => {
|
|
95
|
-
var _a;
|
|
113
|
+
var _a, _b;
|
|
96
114
|
assertMaximumOneNestedModel(serializedIdentifier);
|
|
97
|
-
const
|
|
115
|
+
const communicationUser = serializedIdentifier.communicationUser;
|
|
116
|
+
const microsoftTeamsUser = serializedIdentifier.microsoftTeamsUser;
|
|
117
|
+
const microsoftTeamsApp = serializedIdentifier.microsoftTeamsApp;
|
|
118
|
+
const phoneNumber = serializedIdentifier.phoneNumber;
|
|
119
|
+
const teamsExtensionUser = serializedIdentifier.teamsExtensionUser;
|
|
98
120
|
const kind = (_a = serializedIdentifier.kind) !== null && _a !== void 0 ? _a : getKind(serializedIdentifier);
|
|
99
121
|
if (kind === "communicationUser" && communicationUser) {
|
|
100
122
|
return {
|
|
@@ -107,6 +129,8 @@ export const deserializeCommunicationIdentifier = (serializedIdentifier) => {
|
|
|
107
129
|
kind: "phoneNumber",
|
|
108
130
|
phoneNumber: assertNotNullOrUndefined({ phoneNumber }, "value"),
|
|
109
131
|
rawId: assertNotNullOrUndefined({ phoneNumber: serializedIdentifier }, "rawId"),
|
|
132
|
+
isAnonymous: (_b = phoneNumber.isAnonymous) !== null && _b !== void 0 ? _b : false,
|
|
133
|
+
assertedId: phoneNumber.assertedId,
|
|
110
134
|
};
|
|
111
135
|
}
|
|
112
136
|
if (kind === "microsoftTeamsUser" && microsoftTeamsUser) {
|
|
@@ -126,6 +150,16 @@ export const deserializeCommunicationIdentifier = (serializedIdentifier) => {
|
|
|
126
150
|
rawId: assertNotNullOrUndefined({ microsoftTeamsApp: serializedIdentifier }, "rawId"),
|
|
127
151
|
};
|
|
128
152
|
}
|
|
153
|
+
if (kind === "teamsExtensionUser" && teamsExtensionUser) {
|
|
154
|
+
return {
|
|
155
|
+
kind: "teamsExtensionUser",
|
|
156
|
+
userId: assertNotNullOrUndefined({ teamsExtensionUser }, "userId"),
|
|
157
|
+
tenantId: assertNotNullOrUndefined({ teamsExtensionUser }, "tenantId"),
|
|
158
|
+
resourceId: assertNotNullOrUndefined({ teamsExtensionUser }, "resourceId"),
|
|
159
|
+
cloud: assertNotNullOrUndefined({ teamsExtensionUser }, "cloud"),
|
|
160
|
+
rawId: assertNotNullOrUndefined({ teamsExtensionUser: serializedIdentifier }, "rawId"),
|
|
161
|
+
};
|
|
162
|
+
}
|
|
129
163
|
return {
|
|
130
164
|
kind: "unknown",
|
|
131
165
|
id: assertNotNullOrUndefined({ unknown: serializedIdentifier }, "rawId"),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"identifierModelSerializer.js","sourceRoot":"","sources":["../../src/identifierModelSerializer.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAGL,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,uBAAuB,CAAC;AAgG/B,MAAM,wBAAwB,GAAG,CAK/B,GAAM,EACN,IAAO,EACsB,EAAE;IAC/B,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IACvC,MAAM,MAAM,GAAI,GAAW,CAAC,UAAU,CAAC,CAAC;IACxC,IAAI,IAAI,IAAI,MAAM,EAAE,CAAC;QACnB,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC;IACtB,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,YAAY,IAAI,uCAAuC,UAAU,GAAG,CAAC,CAAC;AACxF,CAAC,CAAC;AAEF,MAAM,2BAA2B,GAAG,CAAC,UAA6C,EAAQ,EAAE;IAC1F,MAAM,iBAAiB,GAAa,EAAE,CAAC;IACvC,IAAI,UAAU,CAAC,iBAAiB,KAAK,SAAS,EAAE,CAAC;QAC/C,iBAAiB,CAAC,IAAI,CAAC,mBAAmB,C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,wBAAwB,CAAC,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,EAAE,OAAO,CAAC;SACtF,CAAC;IACJ,CAAC;IACD,OAAO;QACL,IAAI,EAAE,SAAS;QACf,EAAE,EAAE,wBAAwB,CAAC,EAAE,OAAO,EAAE,oBAAoB,EAAE,EAAE,OAAO,CAAC;KACzE,CAAC;AACJ,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport {\n type CommunicationIdentifier,\n type CommunicationIdentifierKind,\n getIdentifierKind,\n getIdentifierRawId,\n} from \"./identifierModels.js\";\n\n/**\n * @hidden\n * Identifies a participant in Azure Communication services. A participant is, for example, a phone number or an Azure communication user. This model must be interpreted as a union: Apart from rawId, at most one further property may be set.\n */\nexport interface SerializedCommunicationIdentifier {\n /**\n * Kind of the identifier, optional.\n */\n kind?: string;\n /**\n * Raw Id of the identifier. Optional in requests, required in responses.\n */\n rawId?: string;\n /**\n * The communication user.\n */\n communicationUser?: SerializedCommunicationUserIdentifier;\n /**\n * The phone number.\n */\n phoneNumber?: SerializedPhoneNumberIdentifier;\n /**\n * The Microsoft Teams user.\n */\n microsoftTeamsUser?: SerializedMicrosoftTeamsUserIdentifier;\n /**\n * The Microsoft Teams App.\n */\n microsoftTeamsApp?: SerializedMicrosoftTeamsAppIdentifier;\n}\n\n/**\n * @hidden\n * A user that got created with an Azure Communication Services resource.\n */\nexport interface SerializedCommunicationUserIdentifier {\n /**\n * The Id of the communication user.\n */\n id: string;\n}\n\n/**\n * @hidden\n * A phone number.\n */\nexport interface SerializedPhoneNumberIdentifier {\n /**\n * The phone number in E.164 format.\n */\n value: string;\n}\n\n/**\n * @hidden\n * A Microsoft Teams user.\n */\nexport interface SerializedMicrosoftTeamsUserIdentifier {\n /**\n * The Id of the Microsoft Teams user. If not anonymous, this is the AAD object Id of the user.\n */\n userId: string;\n /**\n * True if the Microsoft Teams user is anonymous. By default false if missing.\n */\n isAnonymous?: boolean;\n /**\n * The cloud that the Microsoft Teams user belongs to. By default 'public' if missing.\n */\n cloud?: SerializedCommunicationCloudEnvironment;\n}\n\n/**\n * @hidden\n * A Microsoft Teams App.\n */\nexport interface SerializedMicrosoftTeamsAppIdentifier {\n /**\n * Id of the Microsoft Teams App.\n */\n appId: string;\n\n /**\n * The cloud that the Microsoft Teams App belongs to. By default 'public' if missing.\n */\n cloud?: SerializedCommunicationCloudEnvironment;\n}\n\n/**\n * @hidden\n * Defines values for CommunicationCloudEnvironmentModel.\n */\nexport type SerializedCommunicationCloudEnvironment = \"public\" | \"dod\" | \"gcch\";\n\nconst assertNotNullOrUndefined = <\n T extends Record<string, unknown>,\n P extends keyof T,\n Q extends string & keyof T[P],\n>(\n obj: T,\n prop: Q,\n): Required<Required<T>[P]>[Q] => {\n const subObjName = Object.keys(obj)[0];\n const subObj = (obj as any)[subObjName];\n if (prop in subObj) {\n return subObj[prop];\n }\n throw new Error(`Property ${prop} is required for identifier of type ${subObjName}.`);\n};\n\nconst assertMaximumOneNestedModel = (identifier: SerializedCommunicationIdentifier): void => {\n const presentProperties: string[] = [];\n if (identifier.communicationUser !== undefined) {\n presentProperties.push(\"communicationUser\");\n }\n if (identifier.microsoftTeamsUser !== undefined) {\n presentProperties.push(\"microsoftTeamsUser\");\n }\n if (identifier.microsoftTeamsApp !== undefined) {\n presentProperties.push(\"microsoftTeamsApp\");\n }\n if (identifier.phoneNumber !== undefined) {\n presentProperties.push(\"phoneNumber\");\n }\n if (presentProperties.length > 1) {\n throw new Error(\n `Only one of the properties in ${JSON.stringify(presentProperties)} should be present.`,\n );\n }\n};\n\n/**\n * @hidden\n * Translates a CommunicationIdentifier to its serialized format for sending a request.\n * @param identifier - The CommunicationIdentifier to be serialized.\n */\nexport const serializeCommunicationIdentifier = (\n identifier: CommunicationIdentifier,\n): SerializedCommunicationIdentifier => {\n const identifierKind = getIdentifierKind(identifier);\n switch (identifierKind.kind) {\n case \"communicationUser\":\n return {\n rawId: getIdentifierRawId(identifierKind),\n communicationUser: { id: identifierKind.communicationUserId },\n };\n case \"phoneNumber\":\n return {\n rawId: identifierKind.rawId ?? getIdentifierRawId(identifierKind),\n phoneNumber: {\n value: identifierKind.phoneNumber,\n },\n };\n case \"microsoftTeamsUser\":\n return {\n rawId: identifierKind.rawId ?? getIdentifierRawId(identifierKind),\n microsoftTeamsUser: {\n userId: identifierKind.microsoftTeamsUserId,\n isAnonymous: identifierKind.isAnonymous ?? false,\n cloud: identifierKind.cloud ?? \"public\",\n },\n };\n case \"microsoftTeamsApp\":\n return {\n rawId: identifierKind.rawId ?? getIdentifierRawId(identifierKind),\n microsoftTeamsApp: {\n appId: identifierKind.teamsAppId,\n cloud: identifierKind.cloud ?? \"public\",\n },\n };\n case \"unknown\":\n return { rawId: identifierKind.id };\n default:\n throw new Error(`Can't serialize an identifier with kind ${(identifierKind as any).kind}`);\n }\n};\n\nconst getKind = (serializedIdentifier: SerializedCommunicationIdentifier): string => {\n if (serializedIdentifier.communicationUser) {\n return \"communicationUser\";\n }\n\n if (serializedIdentifier.phoneNumber) {\n return \"phoneNumber\";\n }\n\n if (serializedIdentifier.microsoftTeamsUser) {\n return \"microsoftTeamsUser\";\n }\n\n if (serializedIdentifier.microsoftTeamsApp) {\n return \"microsoftTeamsApp\";\n }\n\n return \"unknown\";\n};\n\n/**\n * @hidden\n * Translates the serialized format of a communication identifier to CommunicationIdentifier.\n * @param serializedIdentifier - The SerializedCommunicationIdentifier to be deserialized.\n */\nexport const deserializeCommunicationIdentifier = (\n serializedIdentifier: SerializedCommunicationIdentifier,\n): CommunicationIdentifierKind => {\n assertMaximumOneNestedModel(serializedIdentifier);\n\n const { communicationUser, microsoftTeamsUser, microsoftTeamsApp, phoneNumber } =\n serializedIdentifier;\n const kind = serializedIdentifier.kind ?? getKind(serializedIdentifier);\n\n if (kind === \"communicationUser\" && communicationUser) {\n return {\n kind: \"communicationUser\",\n communicationUserId: assertNotNullOrUndefined({ communicationUser }, \"id\"),\n };\n }\n if (kind === \"phoneNumber\" && phoneNumber) {\n return {\n kind: \"phoneNumber\",\n phoneNumber: assertNotNullOrUndefined({ phoneNumber }, \"value\"),\n rawId: assertNotNullOrUndefined({ phoneNumber: serializedIdentifier }, \"rawId\"),\n };\n }\n if (kind === \"microsoftTeamsUser\" && microsoftTeamsUser) {\n return {\n kind: \"microsoftTeamsUser\",\n microsoftTeamsUserId: assertNotNullOrUndefined({ microsoftTeamsUser }, \"userId\"),\n isAnonymous: assertNotNullOrUndefined({ microsoftTeamsUser }, \"isAnonymous\"),\n cloud: assertNotNullOrUndefined({ microsoftTeamsUser }, \"cloud\"),\n rawId: assertNotNullOrUndefined({ microsoftTeamsUser: serializedIdentifier }, \"rawId\"),\n };\n }\n if (kind === \"microsoftTeamsApp\" && microsoftTeamsApp) {\n return {\n kind: \"microsoftTeamsApp\",\n teamsAppId: assertNotNullOrUndefined({ microsoftTeamsApp }, \"appId\"),\n cloud: assertNotNullOrUndefined({ microsoftTeamsApp }, \"cloud\"),\n rawId: assertNotNullOrUndefined({ microsoftTeamsApp: serializedIdentifier }, \"rawId\"),\n };\n }\n return {\n kind: \"unknown\",\n id: assertNotNullOrUndefined({ unknown: serializedIdentifier }, \"rawId\"),\n };\n};\n"]}
|
|
1
|
+
{"version":3,"file":"identifierModelSerializer.js","sourceRoot":"","sources":["../../src/identifierModelSerializer.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAGL,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,uBAAuB,CAAC;AAsI/B,MAAM,wBAAwB,GAAG,CAK/B,GAAM,EACN,IAAO,EACsB,EAAE;IAC/B,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IACvC,MAAM,MAAM,GAAI,GAAW,CAAC,UAAU,CAAC,CAAC;IACxC,IAAI,IAAI,IAAI,MAAM,EAAE,CAAC;QACnB,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC;IACtB,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E,EAAE,OAAO,CAAC;SACtF,CAAC;IACJ,CAAC;IACD,IAAI,IAAI,KAAK,oBAAoB,IAAI,kBAAkB,EAAE,CAAC;QACxD,OAAO;YACL,IAAI,EAAE,oBAAoB;YAC1B,MAAM,EAAE,wBAAwB,CAAC,EAAE,kBAAkB,EAAE,EAAE,QAAQ,CAAC;YAClE,QAAQ,EAAE,wBAAwB,CAAC,EAAE,kBAAkB,EAAE,EAAE,UAAU,CAAC;YACtE,UAAU,EAAE,wBAAwB,CAAC,EAAE,kBAAkB,EAAE,EAAE,YAAY,CAAC;YAC1E,KAAK,EAAE,wBAAwB,CAAC,EAAE,kBAAkB,EAAE,EAAE,OAAO,CAAC;YAChE,KAAK,EAAE,wBAAwB,CAAC,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,EAAE,OAAO,CAAC;SACvF,CAAC;IACJ,CAAC;IACD,OAAO;QACL,IAAI,EAAE,SAAS;QACf,EAAE,EAAE,wBAAwB,CAAC,EAAE,OAAO,EAAE,oBAAoB,EAAE,EAAE,OAAO,CAAC;KACzE,CAAC;AACJ,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport {\n type CommunicationIdentifier,\n type CommunicationIdentifierKind,\n getIdentifierKind,\n getIdentifierRawId,\n} from \"./identifierModels.js\";\n\n/**\n * @hidden\n * Identifies a participant in Azure Communication services. A participant is, for example, a phone number or an Azure communication user. This model must be interpreted as a union: Apart from rawId, at most one further property may be set.\n */\nexport interface SerializedCommunicationIdentifier {\n /**\n * Kind of the identifier, optional.\n */\n kind?: string;\n /**\n * Raw Id of the identifier. Optional in requests, required in responses.\n */\n rawId?: string;\n /**\n * The communication user.\n */\n communicationUser?: SerializedCommunicationUserIdentifier;\n /**\n * The phone number.\n */\n phoneNumber?: SerializedPhoneNumberIdentifier;\n /**\n * The Microsoft Teams user.\n */\n microsoftTeamsUser?: SerializedMicrosoftTeamsUserIdentifier;\n /**\n * The Microsoft Teams App.\n */\n microsoftTeamsApp?: SerializedMicrosoftTeamsAppIdentifier;\n /**\n * The Microsoft Teams Extension user.\n */\n teamsExtensionUser?: SerializedTeamsExtensionUserIdentifier;\n}\n\n/**\n * @hidden\n * A user that got created with an Azure Communication Services resource.\n */\nexport interface SerializedCommunicationUserIdentifier {\n /**\n * The Id of the communication user.\n */\n id: string;\n}\n\n/**\n * @hidden\n * A phone number.\n */\nexport interface SerializedPhoneNumberIdentifier {\n /**\n * The phone number in E.164 format.\n */\n value: string;\n /**\n * The asserted Id is set on a phone number that is already in the same call to distinguish from other connections made through the same number.\n */\n assertedId?: string;\n /**\n * True if the phone number is anonymous.\n */\n isAnonymous?: boolean;\n}\n\n/**\n * @hidden\n * A Microsoft Teams user.\n */\nexport interface SerializedMicrosoftTeamsUserIdentifier {\n /**\n * The Id of the Microsoft Teams user. If not anonymous, this is the Entra ID object Id of the user.\n */\n userId: string;\n /**\n * True if the Microsoft Teams user is anonymous. By default false if missing.\n */\n isAnonymous?: boolean;\n /**\n * The cloud that the Microsoft Teams user belongs to. By default 'public' if missing.\n */\n cloud?: SerializedCommunicationCloudEnvironment;\n}\n\n/**\n * @hidden\n * A Microsoft Teams App.\n */\nexport interface SerializedMicrosoftTeamsAppIdentifier {\n /**\n * Id of the Microsoft Teams App.\n */\n appId: string;\n\n /**\n * The cloud that the Microsoft Teams App belongs to. By default 'public' if missing.\n */\n cloud?: SerializedCommunicationCloudEnvironment;\n}\n\n/**\n * @hidden\n * A Microsoft Teams Phone user who is using the Azure Communication Services resource to extend their Teams Phone set up.\n */\nexport interface SerializedTeamsExtensionUserIdentifier {\n /**\n * The Id of the Microsoft Teams Extension user, i.e. the Entra ID object Id of the user.\n */\n userId: string;\n\n /**\n * The tenant Id of the Microsoft Teams Extension user.\n */\n tenantId: string;\n\n /**\n * The Azure Communication Services resource Id.\n */\n resourceId: string;\n\n /**\n * The cloud that the Microsoft Teams Extension user belongs to. If missing, the cloud is \"public\".\n */\n cloud?: SerializedCommunicationCloudEnvironment;\n}\n\n/**\n * @hidden\n * Defines values for CommunicationCloudEnvironmentModel.\n */\nexport type SerializedCommunicationCloudEnvironment = \"public\" | \"dod\" | \"gcch\";\n\nconst assertNotNullOrUndefined = <\n T extends Record<string, unknown>,\n P extends keyof T,\n Q extends string & keyof T[P],\n>(\n obj: T,\n prop: Q,\n): Required<Required<T>[P]>[Q] => {\n const subObjName = Object.keys(obj)[0];\n const subObj = (obj as any)[subObjName];\n if (prop in subObj) {\n return subObj[prop];\n }\n throw new Error(`Property ${prop} is required for identifier of type ${subObjName}.`);\n};\n\nconst assertMaximumOneNestedModel = (identifier: SerializedCommunicationIdentifier): void => {\n const presentProperties: string[] = [];\n if (identifier.communicationUser !== undefined) {\n presentProperties.push(\"communicationUser\");\n }\n if (identifier.microsoftTeamsUser !== undefined) {\n presentProperties.push(\"microsoftTeamsUser\");\n }\n if (identifier.microsoftTeamsApp !== undefined) {\n presentProperties.push(\"microsoftTeamsApp\");\n }\n if (identifier.phoneNumber !== undefined) {\n presentProperties.push(\"phoneNumber\");\n }\n if (identifier.teamsExtensionUser !== undefined) {\n presentProperties.push(\"teamsExtensionUser\");\n }\n if (presentProperties.length > 1) {\n throw new Error(\n `Only one of the properties in ${JSON.stringify(presentProperties)} should be present.`,\n );\n }\n};\n\n/**\n * @hidden\n * Translates a CommunicationIdentifier to its serialized format for sending a request.\n * @param identifier - The CommunicationIdentifier to be serialized.\n */\nexport const serializeCommunicationIdentifier = (\n identifier: CommunicationIdentifier,\n): SerializedCommunicationIdentifier => {\n const identifierKind = getIdentifierKind(identifier);\n switch (identifierKind.kind) {\n case \"communicationUser\":\n return {\n rawId: getIdentifierRawId(identifierKind),\n communicationUser: { id: identifierKind.communicationUserId },\n };\n case \"phoneNumber\":\n return {\n rawId: identifierKind.rawId ?? getIdentifierRawId(identifierKind),\n phoneNumber: {\n value: identifierKind.phoneNumber,\n isAnonymous: identifierKind.isAnonymous ?? false,\n assertedId: identifierKind.assertedId,\n },\n };\n case \"microsoftTeamsUser\":\n return {\n rawId: identifierKind.rawId ?? getIdentifierRawId(identifierKind),\n microsoftTeamsUser: {\n userId: identifierKind.microsoftTeamsUserId,\n isAnonymous: identifierKind.isAnonymous ?? false,\n cloud: identifierKind.cloud ?? \"public\",\n },\n };\n case \"microsoftTeamsApp\":\n return {\n rawId: identifierKind.rawId ?? getIdentifierRawId(identifierKind),\n microsoftTeamsApp: {\n appId: identifierKind.teamsAppId,\n cloud: identifierKind.cloud ?? \"public\",\n },\n };\n case \"teamsExtensionUser\":\n return {\n rawId: identifierKind.rawId ?? getIdentifierRawId(identifierKind),\n teamsExtensionUser: {\n userId: identifierKind.userId,\n tenantId: identifierKind.tenantId,\n resourceId: identifierKind.resourceId,\n cloud: identifierKind.cloud ?? \"public\",\n },\n };\n case \"unknown\":\n return { rawId: identifierKind.id };\n default:\n throw new Error(`Can't serialize an identifier with kind ${(identifierKind as any).kind}`);\n }\n};\n\nconst getKind = (serializedIdentifier: SerializedCommunicationIdentifier): string => {\n if (serializedIdentifier.communicationUser) {\n return \"communicationUser\";\n }\n\n if (serializedIdentifier.phoneNumber) {\n return \"phoneNumber\";\n }\n\n if (serializedIdentifier.microsoftTeamsUser) {\n return \"microsoftTeamsUser\";\n }\n\n if (serializedIdentifier.microsoftTeamsApp) {\n return \"microsoftTeamsApp\";\n }\n\n if (serializedIdentifier.teamsExtensionUser) {\n return \"teamsExtensionUser\";\n }\n\n return \"unknown\";\n};\n\n/**\n * @hidden\n * Translates the serialized format of a communication identifier to CommunicationIdentifier.\n * @param serializedIdentifier - The SerializedCommunicationIdentifier to be deserialized.\n */\nexport const deserializeCommunicationIdentifier = (\n serializedIdentifier: SerializedCommunicationIdentifier,\n): CommunicationIdentifierKind => {\n assertMaximumOneNestedModel(serializedIdentifier);\n\n const communicationUser = serializedIdentifier.communicationUser;\n const microsoftTeamsUser = serializedIdentifier.microsoftTeamsUser;\n const microsoftTeamsApp = serializedIdentifier.microsoftTeamsApp;\n const phoneNumber = serializedIdentifier.phoneNumber;\n const teamsExtensionUser = serializedIdentifier.teamsExtensionUser;\n const kind = serializedIdentifier.kind ?? getKind(serializedIdentifier);\n\n if (kind === \"communicationUser\" && communicationUser) {\n return {\n kind: \"communicationUser\",\n communicationUserId: assertNotNullOrUndefined({ communicationUser }, \"id\"),\n };\n }\n if (kind === \"phoneNumber\" && phoneNumber) {\n return {\n kind: \"phoneNumber\",\n phoneNumber: assertNotNullOrUndefined({ phoneNumber }, \"value\"),\n rawId: assertNotNullOrUndefined({ phoneNumber: serializedIdentifier }, \"rawId\"),\n isAnonymous: phoneNumber.isAnonymous ?? false,\n assertedId: phoneNumber.assertedId,\n };\n }\n if (kind === \"microsoftTeamsUser\" && microsoftTeamsUser) {\n return {\n kind: \"microsoftTeamsUser\",\n microsoftTeamsUserId: assertNotNullOrUndefined({ microsoftTeamsUser }, \"userId\"),\n isAnonymous: assertNotNullOrUndefined({ microsoftTeamsUser }, \"isAnonymous\"),\n cloud: assertNotNullOrUndefined({ microsoftTeamsUser }, \"cloud\"),\n rawId: assertNotNullOrUndefined({ microsoftTeamsUser: serializedIdentifier }, \"rawId\"),\n };\n }\n if (kind === \"microsoftTeamsApp\" && microsoftTeamsApp) {\n return {\n kind: \"microsoftTeamsApp\",\n teamsAppId: assertNotNullOrUndefined({ microsoftTeamsApp }, \"appId\"),\n cloud: assertNotNullOrUndefined({ microsoftTeamsApp }, \"cloud\"),\n rawId: assertNotNullOrUndefined({ microsoftTeamsApp: serializedIdentifier }, \"rawId\"),\n };\n }\n if (kind === \"teamsExtensionUser\" && teamsExtensionUser) {\n return {\n kind: \"teamsExtensionUser\",\n userId: assertNotNullOrUndefined({ teamsExtensionUser }, \"userId\"),\n tenantId: assertNotNullOrUndefined({ teamsExtensionUser }, \"tenantId\"),\n resourceId: assertNotNullOrUndefined({ teamsExtensionUser }, \"resourceId\"),\n cloud: assertNotNullOrUndefined({ teamsExtensionUser }, \"cloud\"),\n rawId: assertNotNullOrUndefined({ teamsExtensionUser: serializedIdentifier }, \"rawId\"),\n };\n }\n return {\n kind: \"unknown\",\n id: assertNotNullOrUndefined({ unknown: serializedIdentifier }, \"rawId\"),\n };\n};\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Identifies a communication participant.
|
|
3
3
|
*/
|
|
4
|
-
export type CommunicationIdentifier = CommunicationUserIdentifier | PhoneNumberIdentifier | MicrosoftTeamsUserIdentifier | MicrosoftTeamsAppIdentifier | UnknownIdentifier;
|
|
4
|
+
export type CommunicationIdentifier = CommunicationUserIdentifier | PhoneNumberIdentifier | MicrosoftTeamsUserIdentifier | MicrosoftTeamsAppIdentifier | TeamsExtensionUserIdentifier | UnknownIdentifier;
|
|
5
5
|
/**
|
|
6
6
|
* An Azure Communication user.
|
|
7
7
|
*/
|
|
@@ -23,6 +23,14 @@ export interface PhoneNumberIdentifier {
|
|
|
23
23
|
* The phone number in E.164 format.
|
|
24
24
|
*/
|
|
25
25
|
phoneNumber: string;
|
|
26
|
+
/**
|
|
27
|
+
* The asserted Id is set on a phone number that is already in the same call to distinguish from other connections made through the same number.
|
|
28
|
+
*/
|
|
29
|
+
assertedId?: string;
|
|
30
|
+
/**
|
|
31
|
+
* True if the phone number is anonymous.
|
|
32
|
+
*/
|
|
33
|
+
isAnonymous?: boolean;
|
|
26
34
|
}
|
|
27
35
|
/**
|
|
28
36
|
* A Microsoft Teams user.
|
|
@@ -33,7 +41,7 @@ export interface MicrosoftTeamsUserIdentifier {
|
|
|
33
41
|
*/
|
|
34
42
|
rawId?: string;
|
|
35
43
|
/**
|
|
36
|
-
* Id of the Microsoft Teams user. If the user isn't anonymous, the id is the
|
|
44
|
+
* Id of the Microsoft Teams user. If the user isn't anonymous, the id is the Entra ID object id of the user.
|
|
37
45
|
*/
|
|
38
46
|
microsoftTeamsUserId: string;
|
|
39
47
|
/**
|
|
@@ -58,7 +66,32 @@ export interface MicrosoftTeamsAppIdentifier {
|
|
|
58
66
|
*/
|
|
59
67
|
teamsAppId: string;
|
|
60
68
|
/**
|
|
61
|
-
* The cloud that the Microsoft
|
|
69
|
+
* The cloud that the Microsoft Teams App belongs to. If missing, the cloud is "public".
|
|
70
|
+
*/
|
|
71
|
+
cloud?: "public" | "dod" | "gcch";
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* A Microsoft Teams Phone user who is using the Azure Communication Services resource to extend their Teams Phone set up.
|
|
75
|
+
*/
|
|
76
|
+
export interface TeamsExtensionUserIdentifier {
|
|
77
|
+
/**
|
|
78
|
+
* Optional raw id of the Microsoft Teams Extension user.
|
|
79
|
+
*/
|
|
80
|
+
rawId?: string;
|
|
81
|
+
/**
|
|
82
|
+
* The Id of the Microsoft Teams Extension user, i.e. the Entra ID object Id of the user.
|
|
83
|
+
*/
|
|
84
|
+
userId: string;
|
|
85
|
+
/**
|
|
86
|
+
* The tenant Id of the Microsoft Teams Extension user.
|
|
87
|
+
*/
|
|
88
|
+
tenantId: string;
|
|
89
|
+
/**
|
|
90
|
+
* The Azure Communication Services resource Id.
|
|
91
|
+
*/
|
|
92
|
+
resourceId: string;
|
|
93
|
+
/**
|
|
94
|
+
* The cloud that the Microsoft Teams Extension user belongs to. If missing, the cloud is "public".
|
|
62
95
|
*/
|
|
63
96
|
cloud?: "public" | "dod" | "gcch";
|
|
64
97
|
}
|
|
@@ -95,6 +128,12 @@ export declare const isMicrosoftTeamsUserIdentifier: (identifier: CommunicationI
|
|
|
95
128
|
* @param identifier - The assumed available to be tested.
|
|
96
129
|
*/
|
|
97
130
|
export declare const isMicrosoftTeamsAppIdentifier: (identifier: CommunicationIdentifier) => identifier is MicrosoftTeamsAppIdentifier;
|
|
131
|
+
/**
|
|
132
|
+
* Tests an Identifier to determine whether it implements TeamsExtensionUserIdentifier.
|
|
133
|
+
*
|
|
134
|
+
* @param identifier - The assumed available to be tested.
|
|
135
|
+
*/
|
|
136
|
+
export declare const isTeamsExtensionUserIdentifier: (identifier: CommunicationIdentifier) => identifier is TeamsExtensionUserIdentifier;
|
|
98
137
|
/**
|
|
99
138
|
* Tests an Identifier to determine whether it implements UnknownIdentifier.
|
|
100
139
|
*
|
|
@@ -104,7 +143,7 @@ export declare const isUnknownIdentifier: (identifier: CommunicationIdentifier)
|
|
|
104
143
|
/**
|
|
105
144
|
* The CommunicationIdentifierKind is a discriminated union that adds a property `kind` to an Identifier.
|
|
106
145
|
*/
|
|
107
|
-
export type CommunicationIdentifierKind = CommunicationUserKind | PhoneNumberKind | MicrosoftTeamsUserKind | MicrosoftTeamsAppKind | UnknownIdentifierKind;
|
|
146
|
+
export type CommunicationIdentifierKind = CommunicationUserKind | PhoneNumberKind | MicrosoftTeamsUserKind | MicrosoftTeamsAppKind | TeamsExtensionUserKind | UnknownIdentifierKind;
|
|
108
147
|
/**
|
|
109
148
|
* IdentifierKind for a CommunicationUserIdentifier.
|
|
110
149
|
*/
|
|
@@ -141,6 +180,15 @@ export interface MicrosoftTeamsAppKind extends MicrosoftTeamsAppIdentifier {
|
|
|
141
180
|
*/
|
|
142
181
|
kind: "microsoftTeamsApp";
|
|
143
182
|
}
|
|
183
|
+
/**
|
|
184
|
+
* IdentifierKind for a TeamsExtensionUserIdentifier.
|
|
185
|
+
*/
|
|
186
|
+
export interface TeamsExtensionUserKind extends TeamsExtensionUserIdentifier {
|
|
187
|
+
/**
|
|
188
|
+
* The identifier kind.
|
|
189
|
+
*/
|
|
190
|
+
kind: "teamsExtensionUser";
|
|
191
|
+
}
|
|
144
192
|
/**
|
|
145
193
|
* IdentifierKind for UnknownIdentifier.
|
|
146
194
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"identifierModels.d.ts","sourceRoot":"","sources":["../../src/identifierModels.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,MAAM,MAAM,uBAAuB,GAC/B,2BAA2B,GAC3B,qBAAqB,GACrB,4BAA4B,GAC5B,2BAA2B,GAC3B,iBAAiB,CAAC;AAEtB;;GAEG;AACH,MAAM,WAAW,2BAA2B;IAC1C;;O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AAuB,SAAQ,4BAA4B;IAC1E;;OAEG;IACH,IAAI,EAAE,oBAAoB,CAAC;CAC5B;AAED;;GAEG;AACH,MAAM,WAAW,qBAAsB,SAAQ,2BAA2B;IACxE;;OAEG;IACH,IAAI,EAAE,mBAAmB,CAAC;CAC3B;AAED;;GAEG;AACH,MAAM,WAAW,sBAAuB,SAAQ,4BAA4B;IAC1E;;OAEG;IACH,IAAI,EAAE,oBAAoB,CAAC;CAC5B;AAED;;GAEG;AACH,MAAM,WAAW,qBAAsB,SAAQ,iBAAiB;IAC9D;;OAEG;IACH,IAAI,EAAE,SAAS,CAAC;CACjB;AAED;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,eAChB,uBAAuB,KAClC,2BAiBF,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,eAAgB,uBAAuB,KAAG,MAkDxE,CAAC;AA+DF;;;;GAIG;AACH,eAAO,MAAM,yBAAyB,UAAW,MAAM,KAAG,2BAsCzD,CAAC"}
|
|
@@ -32,6 +32,17 @@ export const isMicrosoftTeamsUserIdentifier = (identifier) => {
|
|
|
32
32
|
export const isMicrosoftTeamsAppIdentifier = (identifier) => {
|
|
33
33
|
return typeof identifier.teamsAppId === "string";
|
|
34
34
|
};
|
|
35
|
+
/**
|
|
36
|
+
* Tests an Identifier to determine whether it implements TeamsExtensionUserIdentifier.
|
|
37
|
+
*
|
|
38
|
+
* @param identifier - The assumed available to be tested.
|
|
39
|
+
*/
|
|
40
|
+
export const isTeamsExtensionUserIdentifier = (identifier) => {
|
|
41
|
+
const userIdExists = typeof identifier.userId === "string";
|
|
42
|
+
const tenantIdExists = typeof identifier.tenantId === "string";
|
|
43
|
+
const resourceIdExists = typeof identifier.resourceId === "string";
|
|
44
|
+
return userIdExists && tenantIdExists && resourceIdExists;
|
|
45
|
+
};
|
|
35
46
|
/**
|
|
36
47
|
* Tests an Identifier to determine whether it implements UnknownIdentifier.
|
|
37
48
|
*
|
|
@@ -58,6 +69,9 @@ export const getIdentifierKind = (identifier) => {
|
|
|
58
69
|
if (isMicrosoftTeamsAppIdentifier(identifier)) {
|
|
59
70
|
return Object.assign(Object.assign({}, identifier), { kind: "microsoftTeamsApp" });
|
|
60
71
|
}
|
|
72
|
+
if (isTeamsExtensionUserIdentifier(identifier)) {
|
|
73
|
+
return Object.assign(Object.assign({}, identifier), { kind: "teamsExtensionUser" });
|
|
74
|
+
}
|
|
61
75
|
return Object.assign(Object.assign({}, identifier), { kind: "unknown" });
|
|
62
76
|
};
|
|
63
77
|
/**
|
|
@@ -104,6 +118,18 @@ export const getIdentifierRawId = (identifier) => {
|
|
|
104
118
|
return rawId;
|
|
105
119
|
return `4:${phoneNumber}`;
|
|
106
120
|
}
|
|
121
|
+
case "teamsExtensionUser": {
|
|
122
|
+
const { userId, tenantId, resourceId, rawId, cloud } = identifierKind;
|
|
123
|
+
if (rawId)
|
|
124
|
+
return rawId;
|
|
125
|
+
switch (cloud) {
|
|
126
|
+
case "dod":
|
|
127
|
+
return `8:dod-acs:${resourceId}_${tenantId}_${userId}`;
|
|
128
|
+
case "gcch":
|
|
129
|
+
return `8:gcch-acs:${resourceId}_${tenantId}_${userId}`;
|
|
130
|
+
}
|
|
131
|
+
return `8:acs:${resourceId}_${tenantId}_${userId}`;
|
|
132
|
+
}
|
|
107
133
|
case "unknown": {
|
|
108
134
|
return identifierKind.id;
|
|
109
135
|
}
|
|
@@ -124,6 +150,35 @@ const buildMicrosoftTeamsUserIdentifier = (id, cloud, isAnonymous) => {
|
|
|
124
150
|
cloud: cloud,
|
|
125
151
|
};
|
|
126
152
|
};
|
|
153
|
+
const buildTeamsExtensionUserOrCommunicationUserIdentifier = (rawId, suffix, cloud) => {
|
|
154
|
+
const segments = suffix.split("_");
|
|
155
|
+
if (segments.length !== 3) {
|
|
156
|
+
return { kind: "communicationUser", communicationUserId: rawId };
|
|
157
|
+
}
|
|
158
|
+
const resourceId = segments[0];
|
|
159
|
+
const tenantId = segments[1];
|
|
160
|
+
const userId = segments[2];
|
|
161
|
+
return {
|
|
162
|
+
kind: "teamsExtensionUser",
|
|
163
|
+
userId: userId,
|
|
164
|
+
tenantId: tenantId,
|
|
165
|
+
resourceId: resourceId,
|
|
166
|
+
cloud: cloud,
|
|
167
|
+
};
|
|
168
|
+
};
|
|
169
|
+
const buildPhoneNumberIdentifier = (rawId) => {
|
|
170
|
+
const phoneNumber = rawId.substring("4:".length);
|
|
171
|
+
const isAnonymous = phoneNumber === "anonymous";
|
|
172
|
+
const assertedIdIndex = isAnonymous ? -1 : phoneNumber.lastIndexOf("_") + 1;
|
|
173
|
+
const hasAssertedId = assertedIdIndex > 0 && assertedIdIndex < phoneNumber.length;
|
|
174
|
+
const assertedId = hasAssertedId ? phoneNumber.substring(assertedIdIndex) : undefined;
|
|
175
|
+
return {
|
|
176
|
+
kind: "phoneNumber",
|
|
177
|
+
phoneNumber: phoneNumber,
|
|
178
|
+
isAnonymous: isAnonymous,
|
|
179
|
+
assertedId: assertedId,
|
|
180
|
+
};
|
|
181
|
+
};
|
|
127
182
|
/**
|
|
128
183
|
* Creates a CommunicationIdentifierKind from a given rawId. When storing rawIds use this function to restore the identifier that was encoded in the rawId.
|
|
129
184
|
*
|
|
@@ -131,7 +186,7 @@ const buildMicrosoftTeamsUserIdentifier = (id, cloud, isAnonymous) => {
|
|
|
131
186
|
*/
|
|
132
187
|
export const createIdentifierFromRawId = (rawId) => {
|
|
133
188
|
if (rawId.startsWith("4:")) {
|
|
134
|
-
return
|
|
189
|
+
return buildPhoneNumberIdentifier(rawId);
|
|
135
190
|
}
|
|
136
191
|
const segments = rawId.split(":");
|
|
137
192
|
if (segments.length !== 3) {
|
|
@@ -149,9 +204,12 @@ export const createIdentifierFromRawId = (rawId) => {
|
|
|
149
204
|
case "8:gcch:":
|
|
150
205
|
return buildMicrosoftTeamsUserIdentifier(suffix, "gcch", false);
|
|
151
206
|
case "8:acs:":
|
|
152
|
-
|
|
207
|
+
return buildTeamsExtensionUserOrCommunicationUserIdentifier(rawId, suffix, "public");
|
|
153
208
|
case "8:dod-acs:":
|
|
209
|
+
return buildTeamsExtensionUserOrCommunicationUserIdentifier(rawId, suffix, "dod");
|
|
154
210
|
case "8:gcch-acs:":
|
|
211
|
+
return buildTeamsExtensionUserOrCommunicationUserIdentifier(rawId, suffix, "gcch");
|
|
212
|
+
case "8:spool:":
|
|
155
213
|
return { kind: "communicationUser", communicationUserId: rawId };
|
|
156
214
|
case "28:orgid:":
|
|
157
215
|
return buildMicrosoftTeamsAppIdentifier(suffix, "public");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"identifierModels.js","sourceRoot":"","sources":["../../src/identifierModels.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AA2FlC;;;;GAIG;AACH,MAAM,CAAC,MAAM,6BAA6B,GAAG,CAC3C,UAAmC,EACQ,EAAE;IAC7C,OAAO,OAAQ,UAAkB,CAAC,mBAAmB,KAAK,QAAQ,CAAC;AACrE,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,CACrC,UAAmC,EACE,EAAE;IACvC,OAAO,OAAQ,UAAkB,CAAC,WAAW,KAAK,QAAQ,CAAC;AAC7D,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,8BAA8B,GAAG,CAC5C,UAAmC,EACS,EAAE;IAC9C,OAAO,OAAQ,UAAkB,CAAC,oBAAoB,KAAK,QAAQ,CAAC;AACtE,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,6BAA6B,GAAG,CAC3C,UAAmC,EACQ,EAAE;IAC7C,OAAO,OAAQ,UAAkB,CAAC,UAAU,KAAK,QAAQ,CAAC;AAC5D,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CACjC,UAAmC,EACF,EAAE;IACnC,OAAO,OAAQ,UAAkB,CAAC,EAAE,KAAK,QAAQ,CAAC;AACpD,CAAC,CA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AAK,UAAU;YACb,OAAO,gCAAgC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAC1D,KAAK,SAAS;YACZ,OAAO,gCAAgC,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAC3D,CAAC;IACD,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC;AACxC,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\n/**\n * Identifies a communication participant.\n */\nexport type CommunicationIdentifier =\n | CommunicationUserIdentifier\n | PhoneNumberIdentifier\n | MicrosoftTeamsUserIdentifier\n | MicrosoftTeamsAppIdentifier\n | UnknownIdentifier;\n\n/**\n * An Azure Communication user.\n */\nexport interface CommunicationUserIdentifier {\n /**\n * Id of the CommunicationUser as returned from the Communication Service.\n */\n communicationUserId: string;\n}\n\n/**\n * A phone number.\n */\nexport interface PhoneNumberIdentifier {\n /**\n * Optional raw id of the phone number.\n */\n rawId?: string;\n /**\n * The phone number in E.164 format.\n */\n phoneNumber: string;\n}\n\n/**\n * A Microsoft Teams user.\n */\nexport interface MicrosoftTeamsUserIdentifier {\n /**\n * Optional raw id of the Microsoft Teams user.\n */\n rawId?: string;\n\n /**\n * Id of the Microsoft Teams user. If the user isn't anonymous, the id is the AAD object id of the user.\n */\n microsoftTeamsUserId: string;\n\n /**\n * True if the user is anonymous, for example when joining a meeting with a share link. If missing, the user is not anonymous.\n */\n isAnonymous?: boolean;\n\n /**\n * The cloud that the Microsoft Teams user belongs to. If missing, the cloud is \"public\".\n */\n cloud?: \"public\" | \"dod\" | \"gcch\";\n}\n\n/**\n * A Microsoft Teams App.\n */\nexport interface MicrosoftTeamsAppIdentifier {\n /**\n * Optional raw id of the Microsoft Teams App.\n */\n rawId?: string;\n\n /**\n * The unique Microsoft Teams app ID.\n */\n teamsAppId: string;\n\n /**\n * The cloud that the Microsoft Temas App belongs to. If missing, the cloud is \"public\".\n */\n cloud?: \"public\" | \"dod\" | \"gcch\";\n}\n\n/**\n * An unknown identifier that doesn't fit any of the other identifier types.\n */\nexport interface UnknownIdentifier {\n /**\n * Id of the UnknownIdentifier.\n */\n id: string;\n}\n\n/**\n * Tests an Identifier to determine whether it implements CommunicationUserIdentifier.\n *\n * @param identifier - The assumed CommunicationUserIdentifier to be tested.\n */\nexport const isCommunicationUserIdentifier = (\n identifier: CommunicationIdentifier,\n): identifier is CommunicationUserIdentifier => {\n return typeof (identifier as any).communicationUserId === \"string\";\n};\n\n/**\n * Tests an Identifier to determine whether it implements PhoneNumberIdentifier.\n *\n * @param identifier - The assumed PhoneNumberIdentifier to be tested.\n */\nexport const isPhoneNumberIdentifier = (\n identifier: CommunicationIdentifier,\n): identifier is PhoneNumberIdentifier => {\n return typeof (identifier as any).phoneNumber === \"string\";\n};\n\n/**\n * Tests an Identifier to determine whether it implements MicrosoftTeamsUserIdentifier.\n *\n * @param identifier - The assumed available to be tested.\n */\nexport const isMicrosoftTeamsUserIdentifier = (\n identifier: CommunicationIdentifier,\n): identifier is MicrosoftTeamsUserIdentifier => {\n return typeof (identifier as any).microsoftTeamsUserId === \"string\";\n};\n\n/**\n * Tests an Identifier to determine whether it implements MicrosoftTeamsAppIdentifier.\n *\n * @param identifier - The assumed available to be tested.\n */\nexport const isMicrosoftTeamsAppIdentifier = (\n identifier: CommunicationIdentifier,\n): identifier is MicrosoftTeamsAppIdentifier => {\n return typeof (identifier as any).teamsAppId === \"string\";\n};\n\n/**\n * Tests an Identifier to determine whether it implements UnknownIdentifier.\n *\n * @param identifier - The assumed UnknownIdentifier to be tested.\n */\nexport const isUnknownIdentifier = (\n identifier: CommunicationIdentifier,\n): identifier is UnknownIdentifier => {\n return typeof (identifier as any).id === \"string\";\n};\n\n/**\n * The CommunicationIdentifierKind is a discriminated union that adds a property `kind` to an Identifier.\n */\nexport type CommunicationIdentifierKind =\n | CommunicationUserKind\n | PhoneNumberKind\n | MicrosoftTeamsUserKind\n | MicrosoftTeamsAppKind\n | UnknownIdentifierKind;\n\n/**\n * IdentifierKind for a CommunicationUserIdentifier.\n */\nexport interface CommunicationUserKind extends CommunicationUserIdentifier {\n /**\n * The identifier kind.\n */\n kind: \"communicationUser\";\n}\n\n/**\n * IdentifierKind for a PhoneNumberIdentifier.\n */\nexport interface PhoneNumberKind extends PhoneNumberIdentifier {\n /**\n * The identifier kind.\n */\n kind: \"phoneNumber\";\n}\n\n/**\n * IdentifierKind for a MicrosoftTeamsUserIdentifier.\n */\nexport interface MicrosoftTeamsUserKind extends MicrosoftTeamsUserIdentifier {\n /**\n * The identifier kind.\n */\n kind: \"microsoftTeamsUser\";\n}\n\n/**\n * IdentifierKind for a MicrosoftTeamsAppIdentifier.\n */\nexport interface MicrosoftTeamsAppKind extends MicrosoftTeamsAppIdentifier {\n /**\n * The identifier kind.\n */\n kind: \"microsoftTeamsApp\";\n}\n\n/**\n * IdentifierKind for UnknownIdentifier.\n */\nexport interface UnknownIdentifierKind extends UnknownIdentifier {\n /**\n * The identifier kind.\n */\n kind: \"unknown\";\n}\n\n/**\n * Returns the CommunicationIdentifierKind for a given CommunicationIdentifier. Returns undefined if the kind couldn't be inferred.\n *\n * @param identifier - The identifier whose kind is to be inferred.\n */\nexport const getIdentifierKind = (\n identifier: CommunicationIdentifier,\n): CommunicationIdentifierKind => {\n if (isCommunicationUserIdentifier(identifier)) {\n return { ...identifier, kind: \"communicationUser\" };\n }\n if (isPhoneNumberIdentifier(identifier)) {\n return { ...identifier, kind: \"phoneNumber\" };\n }\n if (isMicrosoftTeamsUserIdentifier(identifier)) {\n return { ...identifier, kind: \"microsoftTeamsUser\" };\n }\n if (isMicrosoftTeamsAppIdentifier(identifier)) {\n return { ...identifier, kind: \"microsoftTeamsApp\" };\n }\n return { ...identifier, kind: \"unknown\" };\n};\n\n/**\n * Returns the rawId for a given CommunicationIdentifier. You can use the rawId for encoding the identifier and then use it as a key in a database.\n *\n * @param identifier - The identifier to be translated to its rawId.\n */\nexport const getIdentifierRawId = (identifier: CommunicationIdentifier): string => {\n const identifierKind = getIdentifierKind(identifier);\n switch (identifierKind.kind) {\n case \"communicationUser\":\n return identifierKind.communicationUserId;\n case \"microsoftTeamsUser\": {\n const { microsoftTeamsUserId, rawId, cloud, isAnonymous } = identifierKind;\n if (rawId) return rawId;\n if (isAnonymous) return `8:teamsvisitor:${microsoftTeamsUserId}`;\n switch (cloud) {\n case \"dod\":\n return `8:dod:${microsoftTeamsUserId}`;\n case \"gcch\":\n return `8:gcch:${microsoftTeamsUserId}`;\n case \"public\":\n return `8:orgid:${microsoftTeamsUserId}`;\n }\n return `8:orgid:${microsoftTeamsUserId}`;\n }\n case \"microsoftTeamsApp\": {\n const { teamsAppId, rawId, cloud } = identifierKind;\n if (rawId) return rawId;\n switch (cloud) {\n case \"dod\":\n return `28:dod:${teamsAppId}`;\n case \"gcch\":\n return `28:gcch:${teamsAppId}`;\n }\n return `28:orgid:${teamsAppId}`;\n }\n case \"phoneNumber\": {\n const { phoneNumber, rawId } = identifierKind;\n if (rawId) return rawId;\n return `4:${phoneNumber}`;\n }\n case \"unknown\": {\n return identifierKind.id;\n }\n }\n};\n\nconst buildMicrosoftTeamsAppIdentifier = (\n teamsAppId: string,\n cloud: \"public\" | \"dod\" | \"gcch\",\n): CommunicationIdentifierKind => {\n return {\n kind: \"microsoftTeamsApp\",\n teamsAppId: teamsAppId,\n cloud: cloud,\n };\n};\n\nconst buildMicrosoftTeamsUserIdentifier = (\n id: string,\n cloud: \"public\" | \"dod\" | \"gcch\",\n isAnonymous: boolean,\n): CommunicationIdentifierKind => {\n return {\n kind: \"microsoftTeamsUser\",\n microsoftTeamsUserId: id,\n isAnonymous: isAnonymous,\n cloud: cloud,\n };\n};\n\n/**\n * Creates a CommunicationIdentifierKind from a given rawId. When storing rawIds use this function to restore the identifier that was encoded in the rawId.\n *\n * @param rawId - The rawId to be translated to its identifier representation.\n */\nexport const createIdentifierFromRawId = (rawId: string): CommunicationIdentifierKind => {\n if (rawId.startsWith(\"4:\")) {\n return { kind: \"phoneNumber\", phoneNumber: `${rawId.substring(\"4:\".length)}` };\n }\n\n const segments = rawId.split(\":\");\n if (segments.length !== 3) {\n return { kind: \"unknown\", id: rawId };\n }\n\n const prefix = `${segments[0]}:${segments[1]}:`;\n const suffix = segments[2];\n\n switch (prefix) {\n case \"8:teamsvisitor:\":\n return { kind: \"microsoftTeamsUser\", microsoftTeamsUserId: suffix, isAnonymous: true };\n case \"8:orgid:\":\n return buildMicrosoftTeamsUserIdentifier(suffix, \"public\", false);\n case \"8:dod:\":\n return buildMicrosoftTeamsUserIdentifier(suffix, \"dod\", false);\n case \"8:gcch:\":\n return buildMicrosoftTeamsUserIdentifier(suffix, \"gcch\", false);\n case \"8:acs:\":\n case \"8:spool:\":\n case \"8:dod-acs:\":\n case \"8:gcch-acs:\":\n return { kind: \"communicationUser\", communicationUserId: rawId };\n case \"28:orgid:\":\n return buildMicrosoftTeamsAppIdentifier(suffix, \"public\");\n case \"28:gcch:\":\n return buildMicrosoftTeamsAppIdentifier(suffix, \"gcch\");\n case \"28:dod:\":\n return buildMicrosoftTeamsAppIdentifier(suffix, \"dod\");\n }\n return { kind: \"unknown\", id: rawId };\n};\n"]}
|
|
1
|
+
{"version":3,"file":"identifierModels.js","sourceRoot":"","sources":["../../src/identifierModels.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAoIlC;;;;GAIG;AACH,MAAM,CAAC,MAAM,6BAA6B,GAAG,CAC3C,UAAmC,EACQ,EAAE;IAC7C,OAAO,OAAQ,UAAkB,CAAC,mBAAmB,KAAK,QAAQ,CAAC;AACrE,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,CACrC,UAAmC,EACE,EAAE;IACvC,OAAO,OAAQ,UAAkB,CAAC,WAAW,KAAK,QAAQ,CAAC;AAC7D,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,8BAA8B,GAAG,CAC5C,UAAmC,EACS,EAAE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oDAAoD,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;QACrF,KAAK,UAAU;YACb,OAAO,EAAE,IAAI,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,KAAK,EAAE,CAAC;QACnE,KAAK,WAAW;YACd,OAAO,gCAAgC,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;QAC5D,KAAK,UAAU;YACb,OAAO,gCAAgC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAC1D,KAAK,SAAS;YACZ,OAAO,gCAAgC,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAC3D,CAAC;IACD,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC;AACxC,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\n/**\n * Identifies a communication participant.\n */\nexport type CommunicationIdentifier =\n | CommunicationUserIdentifier\n | PhoneNumberIdentifier\n | MicrosoftTeamsUserIdentifier\n | MicrosoftTeamsAppIdentifier\n | TeamsExtensionUserIdentifier\n | UnknownIdentifier;\n\n/**\n * An Azure Communication user.\n */\nexport interface CommunicationUserIdentifier {\n /**\n * Id of the CommunicationUser as returned from the Communication Service.\n */\n communicationUserId: string;\n}\n\n/**\n * A phone number.\n */\nexport interface PhoneNumberIdentifier {\n /**\n * Optional raw id of the phone number.\n */\n rawId?: string;\n /**\n * The phone number in E.164 format.\n */\n phoneNumber: string;\n\n /**\n * The asserted Id is set on a phone number that is already in the same call to distinguish from other connections made through the same number.\n */\n assertedId?: string;\n\n /**\n * True if the phone number is anonymous.\n */\n isAnonymous?: boolean;\n}\n\n/**\n * A Microsoft Teams user.\n */\nexport interface MicrosoftTeamsUserIdentifier {\n /**\n * Optional raw id of the Microsoft Teams user.\n */\n rawId?: string;\n\n /**\n * Id of the Microsoft Teams user. If the user isn't anonymous, the id is the Entra ID object id of the user.\n */\n microsoftTeamsUserId: string;\n\n /**\n * True if the user is anonymous, for example when joining a meeting with a share link. If missing, the user is not anonymous.\n */\n isAnonymous?: boolean;\n\n /**\n * The cloud that the Microsoft Teams user belongs to. If missing, the cloud is \"public\".\n */\n cloud?: \"public\" | \"dod\" | \"gcch\";\n}\n\n/**\n * A Microsoft Teams App.\n */\nexport interface MicrosoftTeamsAppIdentifier {\n /**\n * Optional raw id of the Microsoft Teams App.\n */\n rawId?: string;\n\n /**\n * The unique Microsoft Teams app ID.\n */\n teamsAppId: string;\n\n /**\n * The cloud that the Microsoft Teams App belongs to. If missing, the cloud is \"public\".\n */\n cloud?: \"public\" | \"dod\" | \"gcch\";\n}\n\n/**\n * A Microsoft Teams Phone user who is using the Azure Communication Services resource to extend their Teams Phone set up.\n */\nexport interface TeamsExtensionUserIdentifier {\n /**\n * Optional raw id of the Microsoft Teams Extension user.\n */\n rawId?: string;\n\n /**\n * The Id of the Microsoft Teams Extension user, i.e. the Entra ID object Id of the user.\n */\n userId: string;\n\n /**\n * The tenant Id of the Microsoft Teams Extension user.\n */\n tenantId: string;\n\n /**\n * The Azure Communication Services resource Id.\n */\n resourceId: string;\n\n /**\n * The cloud that the Microsoft Teams Extension user belongs to. If missing, the cloud is \"public\".\n */\n cloud?: \"public\" | \"dod\" | \"gcch\";\n}\n\n/**\n * An unknown identifier that doesn't fit any of the other identifier types.\n */\nexport interface UnknownIdentifier {\n /**\n * Id of the UnknownIdentifier.\n */\n id: string;\n}\n\n/**\n * Tests an Identifier to determine whether it implements CommunicationUserIdentifier.\n *\n * @param identifier - The assumed CommunicationUserIdentifier to be tested.\n */\nexport const isCommunicationUserIdentifier = (\n identifier: CommunicationIdentifier,\n): identifier is CommunicationUserIdentifier => {\n return typeof (identifier as any).communicationUserId === \"string\";\n};\n\n/**\n * Tests an Identifier to determine whether it implements PhoneNumberIdentifier.\n *\n * @param identifier - The assumed PhoneNumberIdentifier to be tested.\n */\nexport const isPhoneNumberIdentifier = (\n identifier: CommunicationIdentifier,\n): identifier is PhoneNumberIdentifier => {\n return typeof (identifier as any).phoneNumber === \"string\";\n};\n\n/**\n * Tests an Identifier to determine whether it implements MicrosoftTeamsUserIdentifier.\n *\n * @param identifier - The assumed available to be tested.\n */\nexport const isMicrosoftTeamsUserIdentifier = (\n identifier: CommunicationIdentifier,\n): identifier is MicrosoftTeamsUserIdentifier => {\n return typeof (identifier as any).microsoftTeamsUserId === \"string\";\n};\n\n/**\n * Tests an Identifier to determine whether it implements MicrosoftTeamsAppIdentifier.\n *\n * @param identifier - The assumed available to be tested.\n */\nexport const isMicrosoftTeamsAppIdentifier = (\n identifier: CommunicationIdentifier,\n): identifier is MicrosoftTeamsAppIdentifier => {\n return typeof (identifier as any).teamsAppId === \"string\";\n};\n\n/**\n * Tests an Identifier to determine whether it implements TeamsExtensionUserIdentifier.\n *\n * @param identifier - The assumed available to be tested.\n */\nexport const isTeamsExtensionUserIdentifier = (\n identifier: CommunicationIdentifier,\n): identifier is TeamsExtensionUserIdentifier => {\n const userIdExists = typeof (identifier as any).userId === \"string\";\n const tenantIdExists = typeof (identifier as any).tenantId === \"string\";\n const resourceIdExists = typeof (identifier as any).resourceId === \"string\";\n return userIdExists && tenantIdExists && resourceIdExists;\n};\n\n/**\n * Tests an Identifier to determine whether it implements UnknownIdentifier.\n *\n * @param identifier - The assumed UnknownIdentifier to be tested.\n */\nexport const isUnknownIdentifier = (\n identifier: CommunicationIdentifier,\n): identifier is UnknownIdentifier => {\n return typeof (identifier as any).id === \"string\";\n};\n\n/**\n * The CommunicationIdentifierKind is a discriminated union that adds a property `kind` to an Identifier.\n */\nexport type CommunicationIdentifierKind =\n | CommunicationUserKind\n | PhoneNumberKind\n | MicrosoftTeamsUserKind\n | MicrosoftTeamsAppKind\n | TeamsExtensionUserKind\n | UnknownIdentifierKind;\n\n/**\n * IdentifierKind for a CommunicationUserIdentifier.\n */\nexport interface CommunicationUserKind extends CommunicationUserIdentifier {\n /**\n * The identifier kind.\n */\n kind: \"communicationUser\";\n}\n\n/**\n * IdentifierKind for a PhoneNumberIdentifier.\n */\nexport interface PhoneNumberKind extends PhoneNumberIdentifier {\n /**\n * The identifier kind.\n */\n kind: \"phoneNumber\";\n}\n\n/**\n * IdentifierKind for a MicrosoftTeamsUserIdentifier.\n */\nexport interface MicrosoftTeamsUserKind extends MicrosoftTeamsUserIdentifier {\n /**\n * The identifier kind.\n */\n kind: \"microsoftTeamsUser\";\n}\n\n/**\n * IdentifierKind for a MicrosoftTeamsAppIdentifier.\n */\nexport interface MicrosoftTeamsAppKind extends MicrosoftTeamsAppIdentifier {\n /**\n * The identifier kind.\n */\n kind: \"microsoftTeamsApp\";\n}\n\n/**\n * IdentifierKind for a TeamsExtensionUserIdentifier.\n */\nexport interface TeamsExtensionUserKind extends TeamsExtensionUserIdentifier {\n /**\n * The identifier kind.\n */\n kind: \"teamsExtensionUser\";\n}\n\n/**\n * IdentifierKind for UnknownIdentifier.\n */\nexport interface UnknownIdentifierKind extends UnknownIdentifier {\n /**\n * The identifier kind.\n */\n kind: \"unknown\";\n}\n\n/**\n * Returns the CommunicationIdentifierKind for a given CommunicationIdentifier. Returns undefined if the kind couldn't be inferred.\n *\n * @param identifier - The identifier whose kind is to be inferred.\n */\nexport const getIdentifierKind = (\n identifier: CommunicationIdentifier,\n): CommunicationIdentifierKind => {\n if (isCommunicationUserIdentifier(identifier)) {\n return { ...identifier, kind: \"communicationUser\" };\n }\n if (isPhoneNumberIdentifier(identifier)) {\n return { ...identifier, kind: \"phoneNumber\" };\n }\n if (isMicrosoftTeamsUserIdentifier(identifier)) {\n return { ...identifier, kind: \"microsoftTeamsUser\" };\n }\n if (isMicrosoftTeamsAppIdentifier(identifier)) {\n return { ...identifier, kind: \"microsoftTeamsApp\" };\n }\n if (isTeamsExtensionUserIdentifier(identifier)) {\n return { ...identifier, kind: \"teamsExtensionUser\" };\n }\n return { ...identifier, kind: \"unknown\" };\n};\n\n/**\n * Returns the rawId for a given CommunicationIdentifier. You can use the rawId for encoding the identifier and then use it as a key in a database.\n *\n * @param identifier - The identifier to be translated to its rawId.\n */\nexport const getIdentifierRawId = (identifier: CommunicationIdentifier): string => {\n const identifierKind = getIdentifierKind(identifier);\n switch (identifierKind.kind) {\n case \"communicationUser\":\n return identifierKind.communicationUserId;\n case \"microsoftTeamsUser\": {\n const { microsoftTeamsUserId, rawId, cloud, isAnonymous } = identifierKind;\n if (rawId) return rawId;\n if (isAnonymous) return `8:teamsvisitor:${microsoftTeamsUserId}`;\n switch (cloud) {\n case \"dod\":\n return `8:dod:${microsoftTeamsUserId}`;\n case \"gcch\":\n return `8:gcch:${microsoftTeamsUserId}`;\n case \"public\":\n return `8:orgid:${microsoftTeamsUserId}`;\n }\n return `8:orgid:${microsoftTeamsUserId}`;\n }\n case \"microsoftTeamsApp\": {\n const { teamsAppId, rawId, cloud } = identifierKind;\n if (rawId) return rawId;\n switch (cloud) {\n case \"dod\":\n return `28:dod:${teamsAppId}`;\n case \"gcch\":\n return `28:gcch:${teamsAppId}`;\n }\n return `28:orgid:${teamsAppId}`;\n }\n case \"phoneNumber\": {\n const { phoneNumber, rawId } = identifierKind;\n if (rawId) return rawId;\n return `4:${phoneNumber}`;\n }\n case \"teamsExtensionUser\": {\n const { userId, tenantId, resourceId, rawId, cloud } = identifierKind;\n if (rawId) return rawId;\n switch (cloud) {\n case \"dod\":\n return `8:dod-acs:${resourceId}_${tenantId}_${userId}`;\n case \"gcch\":\n return `8:gcch-acs:${resourceId}_${tenantId}_${userId}`;\n }\n return `8:acs:${resourceId}_${tenantId}_${userId}`;\n }\n case \"unknown\": {\n return identifierKind.id;\n }\n }\n};\n\nconst buildMicrosoftTeamsAppIdentifier = (\n teamsAppId: string,\n cloud: \"public\" | \"dod\" | \"gcch\",\n): CommunicationIdentifierKind => {\n return {\n kind: \"microsoftTeamsApp\",\n teamsAppId: teamsAppId,\n cloud: cloud,\n };\n};\n\nconst buildMicrosoftTeamsUserIdentifier = (\n id: string,\n cloud: \"public\" | \"dod\" | \"gcch\",\n isAnonymous: boolean,\n): CommunicationIdentifierKind => {\n return {\n kind: \"microsoftTeamsUser\",\n microsoftTeamsUserId: id,\n isAnonymous: isAnonymous,\n cloud: cloud,\n };\n};\n\nconst buildTeamsExtensionUserOrCommunicationUserIdentifier = (\n rawId: string,\n suffix: string,\n cloud: \"public\" | \"dod\" | \"gcch\",\n): CommunicationIdentifierKind => {\n const segments = suffix.split(\"_\");\n if (segments.length !== 3) {\n return { kind: \"communicationUser\", communicationUserId: rawId };\n }\n\n const resourceId = segments[0];\n const tenantId = segments[1];\n const userId = segments[2];\n return {\n kind: \"teamsExtensionUser\",\n userId: userId,\n tenantId: tenantId,\n resourceId: resourceId,\n cloud: cloud,\n };\n};\n\nconst buildPhoneNumberIdentifier = (rawId: string): CommunicationIdentifierKind => {\n const phoneNumber = rawId.substring(\"4:\".length);\n const isAnonymous = phoneNumber === \"anonymous\";\n const assertedIdIndex = isAnonymous ? -1 : phoneNumber.lastIndexOf(\"_\") + 1;\n const hasAssertedId = assertedIdIndex > 0 && assertedIdIndex < phoneNumber.length;\n const assertedId = hasAssertedId ? phoneNumber.substring(assertedIdIndex) : undefined;\n\n return {\n kind: \"phoneNumber\",\n phoneNumber: phoneNumber,\n isAnonymous: isAnonymous,\n assertedId: assertedId,\n };\n};\n\n/**\n * Creates a CommunicationIdentifierKind from a given rawId. When storing rawIds use this function to restore the identifier that was encoded in the rawId.\n *\n * @param rawId - The rawId to be translated to its identifier representation.\n */\nexport const createIdentifierFromRawId = (rawId: string): CommunicationIdentifierKind => {\n if (rawId.startsWith(\"4:\")) {\n return buildPhoneNumberIdentifier(rawId);\n }\n\n const segments = rawId.split(\":\");\n if (segments.length !== 3) {\n return { kind: \"unknown\", id: rawId };\n }\n\n const prefix = `${segments[0]}:${segments[1]}:`;\n const suffix = segments[2];\n\n switch (prefix) {\n case \"8:teamsvisitor:\":\n return { kind: \"microsoftTeamsUser\", microsoftTeamsUserId: suffix, isAnonymous: true };\n case \"8:orgid:\":\n return buildMicrosoftTeamsUserIdentifier(suffix, \"public\", false);\n case \"8:dod:\":\n return buildMicrosoftTeamsUserIdentifier(suffix, \"dod\", false);\n case \"8:gcch:\":\n return buildMicrosoftTeamsUserIdentifier(suffix, \"gcch\", false);\n case \"8:acs:\":\n return buildTeamsExtensionUserOrCommunicationUserIdentifier(rawId, suffix, \"public\");\n case \"8:dod-acs:\":\n return buildTeamsExtensionUserOrCommunicationUserIdentifier(rawId, suffix, \"dod\");\n case \"8:gcch-acs:\":\n return buildTeamsExtensionUserOrCommunicationUserIdentifier(rawId, suffix, \"gcch\");\n case \"8:spool:\":\n return { kind: \"communicationUser\", communicationUserId: rawId };\n case \"28:orgid:\":\n return buildMicrosoftTeamsAppIdentifier(suffix, \"public\");\n case \"28:gcch:\":\n return buildMicrosoftTeamsAppIdentifier(suffix, \"gcch\");\n case \"28:dod:\":\n return buildMicrosoftTeamsAppIdentifier(suffix, \"dod\");\n }\n return { kind: \"unknown\", id: rawId };\n};\n"]}
|
|
@@ -28,6 +28,10 @@ export interface SerializedCommunicationIdentifier {
|
|
|
28
28
|
* The Microsoft Teams App.
|
|
29
29
|
*/
|
|
30
30
|
microsoftTeamsApp?: SerializedMicrosoftTeamsAppIdentifier;
|
|
31
|
+
/**
|
|
32
|
+
* The Microsoft Teams Extension user.
|
|
33
|
+
*/
|
|
34
|
+
teamsExtensionUser?: SerializedTeamsExtensionUserIdentifier;
|
|
31
35
|
}
|
|
32
36
|
/**
|
|
33
37
|
* @hidden
|
|
@@ -48,6 +52,14 @@ export interface SerializedPhoneNumberIdentifier {
|
|
|
48
52
|
* The phone number in E.164 format.
|
|
49
53
|
*/
|
|
50
54
|
value: string;
|
|
55
|
+
/**
|
|
56
|
+
* The asserted Id is set on a phone number that is already in the same call to distinguish from other connections made through the same number.
|
|
57
|
+
*/
|
|
58
|
+
assertedId?: string;
|
|
59
|
+
/**
|
|
60
|
+
* True if the phone number is anonymous.
|
|
61
|
+
*/
|
|
62
|
+
isAnonymous?: boolean;
|
|
51
63
|
}
|
|
52
64
|
/**
|
|
53
65
|
* @hidden
|
|
@@ -55,7 +67,7 @@ export interface SerializedPhoneNumberIdentifier {
|
|
|
55
67
|
*/
|
|
56
68
|
export interface SerializedMicrosoftTeamsUserIdentifier {
|
|
57
69
|
/**
|
|
58
|
-
* The Id of the Microsoft Teams user. If not anonymous, this is the
|
|
70
|
+
* The Id of the Microsoft Teams user. If not anonymous, this is the Entra ID object Id of the user.
|
|
59
71
|
*/
|
|
60
72
|
userId: string;
|
|
61
73
|
/**
|
|
@@ -81,6 +93,28 @@ export interface SerializedMicrosoftTeamsAppIdentifier {
|
|
|
81
93
|
*/
|
|
82
94
|
cloud?: SerializedCommunicationCloudEnvironment;
|
|
83
95
|
}
|
|
96
|
+
/**
|
|
97
|
+
* @hidden
|
|
98
|
+
* A Microsoft Teams Phone user who is using the Azure Communication Services resource to extend their Teams Phone set up.
|
|
99
|
+
*/
|
|
100
|
+
export interface SerializedTeamsExtensionUserIdentifier {
|
|
101
|
+
/**
|
|
102
|
+
* The Id of the Microsoft Teams Extension user, i.e. the Entra ID object Id of the user.
|
|
103
|
+
*/
|
|
104
|
+
userId: string;
|
|
105
|
+
/**
|
|
106
|
+
* The tenant Id of the Microsoft Teams Extension user.
|
|
107
|
+
*/
|
|
108
|
+
tenantId: string;
|
|
109
|
+
/**
|
|
110
|
+
* The Azure Communication Services resource Id.
|
|
111
|
+
*/
|
|
112
|
+
resourceId: string;
|
|
113
|
+
/**
|
|
114
|
+
* The cloud that the Microsoft Teams Extension user belongs to. If missing, the cloud is "public".
|
|
115
|
+
*/
|
|
116
|
+
cloud?: SerializedCommunicationCloudEnvironment;
|
|
117
|
+
}
|
|
84
118
|
/**
|
|
85
119
|
* @hidden
|
|
86
120
|
* Defines values for CommunicationCloudEnvironmentModel.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"identifierModelSerializer.d.ts","sourceRoot":"","sources":["../../src/identifierModelSerializer.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,KAAK,uBAAuB,EAC5B,KAAK,2BAA2B,EAGjC,MAAM,uBAAuB,CAAC;AAE/B;;;GAGG;AACH,MAAM,WAAW,iCAAiC;IAChD;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,iBAAiB,CAAC,EAAE,qCAAqC,CAAC;IAC1D;;OAEG;IACH,WAAW,CAAC,EAAE,+BAA+B,CAAC;IAC9C;;OAEG;IACH,kBAAkB,CAAC,EAAE,sCAAsC,CAAC;IAC5D;;OAEG;IACH,iBAAiB,CAAC,EAAE,qCAAqC,CAAC;
|
|
1
|
+
{"version":3,"file":"identifierModelSerializer.d.ts","sourceRoot":"","sources":["../../src/identifierModelSerializer.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,KAAK,uBAAuB,EAC5B,KAAK,2BAA2B,EAGjC,MAAM,uBAAuB,CAAC;AAE/B;;;GAGG;AACH,MAAM,WAAW,iCAAiC;IAChD;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,iBAAiB,CAAC,EAAE,qCAAqC,CAAC;IAC1D;;OAEG;IACH,WAAW,CAAC,EAAE,+BAA+B,CAAC;IAC9C;;OAEG;IACH,kBAAkB,CAAC,EAAE,sCAAsC,CAAC;IAC5D;;OAEG;IACH,iBAAiB,CAAC,EAAE,qCAAqC,CAAC;IAC1D;;OAEG;IACH,kBAAkB,CAAC,EAAE,sCAAsC,CAAC;CAC7D;AAED;;;GAGG;AACH,MAAM,WAAW,qCAAqC;IACpD;;OAEG;IACH,EAAE,EAAE,MAAM,CAAC;CACZ;AAED;;;GAGG;AACH,MAAM,WAAW,+BAA+B;IAC9C;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,WAAW,CAAC,EAAE,OAA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