@azure/communication-common 2.4.1-alpha.20250618.1 → 2.4.1-alpha.20250723.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/autoRefreshTokenCredential.js +11 -7
- package/dist/browser/autoRefreshTokenCredential.js.map +1 -1
- package/dist/browser/azureCommunicationTokenCredential.js +2 -1
- package/dist/browser/azureCommunicationTokenCredential.js.map +1 -1
- package/dist/browser/credential/clientArguments.js +1 -2
- package/dist/browser/credential/clientArguments.js.map +1 -1
- package/dist/browser/credential/communicationAccessKeyCredentialPolicy.js +1 -2
- package/dist/browser/credential/communicationAccessKeyCredentialPolicy.js.map +1 -1
- package/dist/browser/credential/connectionString.js +1 -1
- package/dist/browser/credential/connectionString.js.map +1 -1
- package/dist/browser/entraTokenCredential.js +11 -8
- package/dist/browser/entraTokenCredential.js.map +1 -1
- package/dist/browser/identifierModelSerializer.js +11 -13
- package/dist/browser/identifierModelSerializer.js.map +1 -1
- package/dist/browser/identifierModels.js +6 -6
- package/dist/browser/identifierModels.js.map +1 -1
- package/dist/browser/staticTokenCredential.js +1 -0
- package/dist/browser/staticTokenCredential.js.map +1 -1
- package/dist/commonjs/autoRefreshTokenCredential.js +11 -7
- package/dist/commonjs/autoRefreshTokenCredential.js.map +1 -1
- package/dist/commonjs/azureCommunicationTokenCredential.js +2 -1
- package/dist/commonjs/azureCommunicationTokenCredential.js.map +1 -1
- package/dist/commonjs/credential/clientArguments.js +1 -2
- package/dist/commonjs/credential/clientArguments.js.map +1 -1
- package/dist/commonjs/credential/communicationAccessKeyCredentialPolicy.js +1 -2
- package/dist/commonjs/credential/communicationAccessKeyCredentialPolicy.js.map +1 -1
- package/dist/commonjs/credential/connectionString.js +1 -1
- package/dist/commonjs/credential/connectionString.js.map +1 -1
- package/dist/commonjs/entraTokenCredential.js +11 -8
- package/dist/commonjs/entraTokenCredential.js.map +1 -1
- package/dist/commonjs/identifierModelSerializer.js +11 -13
- package/dist/commonjs/identifierModelSerializer.js.map +1 -1
- package/dist/commonjs/identifierModels.js +6 -6
- package/dist/commonjs/identifierModels.js.map +1 -1
- package/dist/commonjs/staticTokenCredential.js +1 -0
- package/dist/commonjs/staticTokenCredential.js.map +1 -1
- package/dist/commonjs/tsdoc-metadata.json +11 -11
- package/dist/esm/autoRefreshTokenCredential.js +11 -7
- package/dist/esm/autoRefreshTokenCredential.js.map +1 -1
- package/dist/esm/azureCommunicationTokenCredential.js +2 -1
- package/dist/esm/azureCommunicationTokenCredential.js.map +1 -1
- package/dist/esm/credential/clientArguments.js +1 -2
- package/dist/esm/credential/clientArguments.js.map +1 -1
- package/dist/esm/credential/communicationAccessKeyCredentialPolicy.js +1 -2
- package/dist/esm/credential/communicationAccessKeyCredentialPolicy.js.map +1 -1
- package/dist/esm/credential/connectionString.js +1 -1
- package/dist/esm/credential/connectionString.js.map +1 -1
- package/dist/esm/entraTokenCredential.js +11 -8
- package/dist/esm/entraTokenCredential.js.map +1 -1
- package/dist/esm/identifierModelSerializer.js +11 -13
- package/dist/esm/identifierModelSerializer.js.map +1 -1
- package/dist/esm/identifierModels.js +6 -6
- package/dist/esm/identifierModels.js.map +1 -1
- package/dist/esm/staticTokenCredential.js +1 -0
- package/dist/esm/staticTokenCredential.js.map +1 -1
- package/dist/react-native/autoRefreshTokenCredential.js +11 -7
- package/dist/react-native/autoRefreshTokenCredential.js.map +1 -1
- package/dist/react-native/azureCommunicationTokenCredential.js +2 -1
- package/dist/react-native/azureCommunicationTokenCredential.js.map +1 -1
- package/dist/react-native/credential/clientArguments.js +1 -2
- package/dist/react-native/credential/clientArguments.js.map +1 -1
- package/dist/react-native/credential/communicationAccessKeyCredentialPolicy.js +1 -2
- package/dist/react-native/credential/communicationAccessKeyCredentialPolicy.js.map +1 -1
- package/dist/react-native/credential/connectionString.js +1 -1
- package/dist/react-native/credential/connectionString.js.map +1 -1
- package/dist/react-native/entraTokenCredential.js +11 -8
- package/dist/react-native/entraTokenCredential.js.map +1 -1
- package/dist/react-native/identifierModelSerializer.js +11 -13
- package/dist/react-native/identifierModelSerializer.js.map +1 -1
- package/dist/react-native/identifierModels.js +6 -6
- package/dist/react-native/identifierModels.js.map +1 -1
- package/dist/react-native/staticTokenCredential.js +1 -0
- package/dist/react-native/staticTokenCredential.js.map +1 -1
- package/package.json +2 -2
|
@@ -36,7 +36,6 @@ const assertMaximumOneNestedModel = (identifier) => {
|
|
|
36
36
|
* @param identifier - The CommunicationIdentifier to be serialized.
|
|
37
37
|
*/
|
|
38
38
|
export const serializeCommunicationIdentifier = (identifier) => {
|
|
39
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
40
39
|
const identifierKind = getIdentifierKind(identifier);
|
|
41
40
|
switch (identifierKind.kind) {
|
|
42
41
|
case "communicationUser":
|
|
@@ -46,38 +45,38 @@ export const serializeCommunicationIdentifier = (identifier) => {
|
|
|
46
45
|
};
|
|
47
46
|
case "phoneNumber":
|
|
48
47
|
return {
|
|
49
|
-
rawId:
|
|
48
|
+
rawId: identifierKind.rawId ?? getIdentifierRawId(identifierKind),
|
|
50
49
|
phoneNumber: {
|
|
51
50
|
value: identifierKind.phoneNumber,
|
|
52
|
-
isAnonymous:
|
|
51
|
+
isAnonymous: identifierKind.isAnonymous ?? false,
|
|
53
52
|
assertedId: identifierKind.assertedId,
|
|
54
53
|
},
|
|
55
54
|
};
|
|
56
55
|
case "microsoftTeamsUser":
|
|
57
56
|
return {
|
|
58
|
-
rawId:
|
|
57
|
+
rawId: identifierKind.rawId ?? getIdentifierRawId(identifierKind),
|
|
59
58
|
microsoftTeamsUser: {
|
|
60
59
|
userId: identifierKind.microsoftTeamsUserId,
|
|
61
|
-
isAnonymous:
|
|
62
|
-
cloud:
|
|
60
|
+
isAnonymous: identifierKind.isAnonymous ?? false,
|
|
61
|
+
cloud: identifierKind.cloud ?? "public",
|
|
63
62
|
},
|
|
64
63
|
};
|
|
65
64
|
case "microsoftTeamsApp":
|
|
66
65
|
return {
|
|
67
|
-
rawId:
|
|
66
|
+
rawId: identifierKind.rawId ?? getIdentifierRawId(identifierKind),
|
|
68
67
|
microsoftTeamsApp: {
|
|
69
68
|
appId: identifierKind.teamsAppId,
|
|
70
|
-
cloud:
|
|
69
|
+
cloud: identifierKind.cloud ?? "public",
|
|
71
70
|
},
|
|
72
71
|
};
|
|
73
72
|
case "teamsExtensionUser":
|
|
74
73
|
return {
|
|
75
|
-
rawId:
|
|
74
|
+
rawId: identifierKind.rawId ?? getIdentifierRawId(identifierKind),
|
|
76
75
|
teamsExtensionUser: {
|
|
77
76
|
userId: identifierKind.userId,
|
|
78
77
|
tenantId: identifierKind.tenantId,
|
|
79
78
|
resourceId: identifierKind.resourceId,
|
|
80
|
-
cloud:
|
|
79
|
+
cloud: identifierKind.cloud ?? "public",
|
|
81
80
|
},
|
|
82
81
|
};
|
|
83
82
|
case "unknown":
|
|
@@ -110,14 +109,13 @@ const getKind = (serializedIdentifier) => {
|
|
|
110
109
|
* @param serializedIdentifier - The SerializedCommunicationIdentifier to be deserialized.
|
|
111
110
|
*/
|
|
112
111
|
export const deserializeCommunicationIdentifier = (serializedIdentifier) => {
|
|
113
|
-
var _a, _b;
|
|
114
112
|
assertMaximumOneNestedModel(serializedIdentifier);
|
|
115
113
|
const communicationUser = serializedIdentifier.communicationUser;
|
|
116
114
|
const microsoftTeamsUser = serializedIdentifier.microsoftTeamsUser;
|
|
117
115
|
const microsoftTeamsApp = serializedIdentifier.microsoftTeamsApp;
|
|
118
116
|
const phoneNumber = serializedIdentifier.phoneNumber;
|
|
119
117
|
const teamsExtensionUser = serializedIdentifier.teamsExtensionUser;
|
|
120
|
-
const kind =
|
|
118
|
+
const kind = serializedIdentifier.kind ?? getKind(serializedIdentifier);
|
|
121
119
|
if (kind === "communicationUser" && communicationUser) {
|
|
122
120
|
return {
|
|
123
121
|
kind: "communicationUser",
|
|
@@ -129,7 +127,7 @@ export const deserializeCommunicationIdentifier = (serializedIdentifier) => {
|
|
|
129
127
|
kind: "phoneNumber",
|
|
130
128
|
phoneNumber: assertNotNullOrUndefined({ phoneNumber }, "value"),
|
|
131
129
|
rawId: assertNotNullOrUndefined({ phoneNumber: serializedIdentifier }, "rawId"),
|
|
132
|
-
isAnonymous:
|
|
130
|
+
isAnonymous: phoneNumber.isAnonymous ?? false,
|
|
133
131
|
assertedId: phoneNumber.assertedId,
|
|
134
132
|
};
|
|
135
133
|
}
|
|
@@ -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;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,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,CAAC,CAAC;IAC9C,CAAC;IACD,IAAI,UAAU,CAAC,kBAAkB,KAAK,SAAS,EAAE,CAAC;QAChD,iBAAiB,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;IAC/C,CAAC;IACD,IAAI,UAAU,CAAC,iBAAiB,KAAK,SAAS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AE,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
|
+
{"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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iB,EAAE,oBAAoB,EAAE,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"]}
|
|
@@ -58,21 +58,21 @@ export const isUnknownIdentifier = (identifier) => {
|
|
|
58
58
|
*/
|
|
59
59
|
export const getIdentifierKind = (identifier) => {
|
|
60
60
|
if (isCommunicationUserIdentifier(identifier)) {
|
|
61
|
-
return
|
|
61
|
+
return { ...identifier, kind: "communicationUser" };
|
|
62
62
|
}
|
|
63
63
|
if (isPhoneNumberIdentifier(identifier)) {
|
|
64
|
-
return
|
|
64
|
+
return { ...identifier, kind: "phoneNumber" };
|
|
65
65
|
}
|
|
66
66
|
if (isMicrosoftTeamsUserIdentifier(identifier)) {
|
|
67
|
-
return
|
|
67
|
+
return { ...identifier, kind: "microsoftTeamsUser" };
|
|
68
68
|
}
|
|
69
69
|
if (isMicrosoftTeamsAppIdentifier(identifier)) {
|
|
70
|
-
return
|
|
70
|
+
return { ...identifier, kind: "microsoftTeamsApp" };
|
|
71
71
|
}
|
|
72
72
|
if (isTeamsExtensionUserIdentifier(identifier)) {
|
|
73
|
-
return
|
|
73
|
+
return { ...identifier, kind: "teamsExtensionUser" };
|
|
74
74
|
}
|
|
75
|
-
return
|
|
75
|
+
return { ...identifier, kind: "unknown" };
|
|
76
76
|
};
|
|
77
77
|
/**
|
|
78
78
|
* 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.
|
|
@@ -1 +1 @@
|
|
|
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;;;;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KAAK,CAAC,CAAC;QAClE,KAAK,QAAQ;YACX,OAAO,oDAAoD,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC;QACvF,KAAK,YAAY;YACf,OAAO,oDAAoD,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;QACpF,KAAK,aAAa;YAChB,OAAO,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"]}
|
|
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;;;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AoD,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC;QACvF,KAAK,YAAY;YACf,OAAO,oDAAoD,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;QACpF,KAAK,aAAa;YAChB,OAAO,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"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"staticTokenCredential.js","sourceRoot":"","sources":["../../src/staticTokenCredential.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAKlC;;GAEG;AACH,MAAM,OAAO,qBAAqB;
|
|
1
|
+
{"version":3,"file":"staticTokenCredential.js","sourceRoot":"","sources":["../../src/staticTokenCredential.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAKlC;;GAEG;AACH,MAAM,OAAO,qBAAqB;IACH;IAA7B,YAA6B,KAAkB;QAAlB,UAAK,GAAL,KAAK,CAAa;IAAG,CAAC;IAE5C,KAAK,CAAC,QAAQ;QACnB,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAEM,OAAO;QACZ,yBAAyB;IAC3B,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { AccessToken } from \"@azure/core-auth\";\nimport type { TokenCredential } from \"./communicationTokenCredential.js\";\n\n/**\n * StaticTokenCredential\n */\nexport class StaticTokenCredential implements TokenCredential {\n constructor(private readonly token: AccessToken) {}\n\n public async getToken(): Promise<AccessToken> {\n return this.token;\n }\n\n public dispose(): void {\n /* intentionally empty */\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@azure/communication-common",
|
|
3
|
-
"version": "2.4.1-alpha.
|
|
3
|
+
"version": "2.4.1-alpha.20250723.1",
|
|
4
4
|
"description": "Common package for Azure Communication services.",
|
|
5
5
|
"sdk-type": "client",
|
|
6
6
|
"main": "./dist/commonjs/index.js",
|
|
@@ -91,7 +91,7 @@
|
|
|
91
91
|
"react-native"
|
|
92
92
|
],
|
|
93
93
|
"selfLink": false,
|
|
94
|
-
"project": "
|
|
94
|
+
"project": "../../../tsconfig.src.build.json"
|
|
95
95
|
},
|
|
96
96
|
"exports": {
|
|
97
97
|
"./package.json": "./package.json",
|