@azure/communication-common 3.0.0-alpha.20230828.1 → 3.0.0-alpha.20230915.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/index.js +32 -51
- package/dist/index.js.map +1 -1
- package/dist-esm/src/identifierModelSerializer.js +15 -17
- package/dist-esm/src/identifierModelSerializer.js.map +1 -1
- package/dist-esm/src/identifierModels.js +16 -33
- package/dist-esm/src/identifierModels.js.map +1 -1
- package/package.json +2 -2
- package/types/communication-common.d.ts +20 -28
package/dist/index.js
CHANGED
|
@@ -338,12 +338,12 @@ const isMicrosoftTeamsUserIdentifier = (identifier) => {
|
|
|
338
338
|
return typeof identifier.microsoftTeamsUserId === "string";
|
|
339
339
|
};
|
|
340
340
|
/**
|
|
341
|
-
* Tests an Identifier to determine whether it implements
|
|
341
|
+
* Tests an Identifier to determine whether it implements MicrosoftTeamsAppIdentifier.
|
|
342
342
|
*
|
|
343
343
|
* @param identifier - The assumed available to be tested.
|
|
344
344
|
*/
|
|
345
|
-
const
|
|
346
|
-
return typeof identifier.
|
|
345
|
+
const isMicrosoftTeamsAppIdentifier = (identifier) => {
|
|
346
|
+
return typeof identifier.teamsAppId === "string";
|
|
347
347
|
};
|
|
348
348
|
/**
|
|
349
349
|
* Tests an Identifier to determine whether it implements UnknownIdentifier.
|
|
@@ -368,8 +368,8 @@ const getIdentifierKind = (identifier) => {
|
|
|
368
368
|
if (isMicrosoftTeamsUserIdentifier(identifier)) {
|
|
369
369
|
return Object.assign(Object.assign({}, identifier), { kind: "microsoftTeamsUser" });
|
|
370
370
|
}
|
|
371
|
-
if (
|
|
372
|
-
return Object.assign(Object.assign({}, identifier), { kind: "
|
|
371
|
+
if (isMicrosoftTeamsAppIdentifier(identifier)) {
|
|
372
|
+
return Object.assign(Object.assign({}, identifier), { kind: "microsoftTeamsApp" });
|
|
373
373
|
}
|
|
374
374
|
return Object.assign(Object.assign({}, identifier), { kind: "unknown" });
|
|
375
375
|
};
|
|
@@ -399,26 +399,17 @@ const getIdentifierRawId = (identifier) => {
|
|
|
399
399
|
}
|
|
400
400
|
return `8:orgid:${microsoftTeamsUserId}`;
|
|
401
401
|
}
|
|
402
|
-
case "
|
|
403
|
-
const {
|
|
402
|
+
case "microsoftTeamsApp": {
|
|
403
|
+
const { teamsAppId, rawId, cloud } = identifierKind;
|
|
404
404
|
if (rawId)
|
|
405
405
|
return rawId;
|
|
406
|
-
if (!isResourceAccountConfigured) {
|
|
407
|
-
switch (cloud) {
|
|
408
|
-
case "dod":
|
|
409
|
-
return `28:dod-global:${botId}`;
|
|
410
|
-
case "gcch":
|
|
411
|
-
return `28:gcch-global:${botId}`;
|
|
412
|
-
}
|
|
413
|
-
return `28:${botId}`;
|
|
414
|
-
}
|
|
415
406
|
switch (cloud) {
|
|
416
407
|
case "dod":
|
|
417
|
-
return `28:dod:${
|
|
408
|
+
return `28:dod:${teamsAppId}`;
|
|
418
409
|
case "gcch":
|
|
419
|
-
return `28:gcch:${
|
|
410
|
+
return `28:gcch:${teamsAppId}`;
|
|
420
411
|
}
|
|
421
|
-
return `28:orgid:${
|
|
412
|
+
return `28:orgid:${teamsAppId}`;
|
|
422
413
|
}
|
|
423
414
|
case "phoneNumber": {
|
|
424
415
|
const { phoneNumber, rawId } = identifierKind;
|
|
@@ -431,12 +422,11 @@ const getIdentifierRawId = (identifier) => {
|
|
|
431
422
|
}
|
|
432
423
|
}
|
|
433
424
|
};
|
|
434
|
-
const
|
|
425
|
+
const buildMicrosoftTeamsAppIdentifier = (teamsAppId, cloud) => {
|
|
435
426
|
return {
|
|
436
|
-
kind: "
|
|
437
|
-
|
|
427
|
+
kind: "microsoftTeamsApp",
|
|
428
|
+
teamsAppId: teamsAppId,
|
|
438
429
|
cloud: cloud,
|
|
439
|
-
isResourceAccountConfigured: isResourceAccountConfigured,
|
|
440
430
|
};
|
|
441
431
|
};
|
|
442
432
|
const buildMicrosoftTeamsUserIdentifier = (id, cloud, isAnonymous) => {
|
|
@@ -458,9 +448,6 @@ const createIdentifierFromRawId = (rawId) => {
|
|
|
458
448
|
}
|
|
459
449
|
const segments = rawId.split(":");
|
|
460
450
|
if (segments.length !== 3) {
|
|
461
|
-
if (segments.length === 2 && segments[0] === "28") {
|
|
462
|
-
return buildMicrosoftBotIdentifier(segments[1], "public", false);
|
|
463
|
-
}
|
|
464
451
|
return { kind: "unknown", id: rawId };
|
|
465
452
|
}
|
|
466
453
|
const prefix = `${segments[0]}:${segments[1]}:`;
|
|
@@ -479,16 +466,12 @@ const createIdentifierFromRawId = (rawId) => {
|
|
|
479
466
|
case "8:dod-acs:":
|
|
480
467
|
case "8:gcch-acs:":
|
|
481
468
|
return { kind: "communicationUser", communicationUserId: rawId };
|
|
482
|
-
case "28:gcch-global:":
|
|
483
|
-
return buildMicrosoftBotIdentifier(suffix, "gcch", false);
|
|
484
469
|
case "28:orgid:":
|
|
485
|
-
return
|
|
486
|
-
case "28:dod-global:":
|
|
487
|
-
return buildMicrosoftBotIdentifier(suffix, "dod", false);
|
|
470
|
+
return buildMicrosoftTeamsAppIdentifier(suffix, "public");
|
|
488
471
|
case "28:gcch:":
|
|
489
|
-
return
|
|
472
|
+
return buildMicrosoftTeamsAppIdentifier(suffix, "gcch");
|
|
490
473
|
case "28:dod:":
|
|
491
|
-
return
|
|
474
|
+
return buildMicrosoftTeamsAppIdentifier(suffix, "dod");
|
|
492
475
|
}
|
|
493
476
|
return { kind: "unknown", id: rawId };
|
|
494
477
|
};
|
|
@@ -510,8 +493,8 @@ const assertMaximumOneNestedModel = (identifier) => {
|
|
|
510
493
|
if (identifier.microsoftTeamsUser !== undefined) {
|
|
511
494
|
presentProperties.push("microsoftTeamsUser");
|
|
512
495
|
}
|
|
513
|
-
if (identifier.
|
|
514
|
-
presentProperties.push("
|
|
496
|
+
if (identifier.microsoftTeamsApp !== undefined) {
|
|
497
|
+
presentProperties.push("microsoftTeamsApp");
|
|
515
498
|
}
|
|
516
499
|
if (identifier.phoneNumber !== undefined) {
|
|
517
500
|
presentProperties.push("phoneNumber");
|
|
@@ -526,7 +509,7 @@ const assertMaximumOneNestedModel = (identifier) => {
|
|
|
526
509
|
* @param identifier - The CommunicationIdentifier to be serialized.
|
|
527
510
|
*/
|
|
528
511
|
const serializeCommunicationIdentifier = (identifier) => {
|
|
529
|
-
var _a, _b, _c, _d, _e, _f
|
|
512
|
+
var _a, _b, _c, _d, _e, _f;
|
|
530
513
|
const identifierKind = getIdentifierKind(identifier);
|
|
531
514
|
switch (identifierKind.kind) {
|
|
532
515
|
case "communicationUser":
|
|
@@ -550,13 +533,12 @@ const serializeCommunicationIdentifier = (identifier) => {
|
|
|
550
533
|
cloud: (_d = identifierKind.cloud) !== null && _d !== void 0 ? _d : "public",
|
|
551
534
|
},
|
|
552
535
|
};
|
|
553
|
-
case "
|
|
536
|
+
case "microsoftTeamsApp":
|
|
554
537
|
return {
|
|
555
538
|
rawId: (_e = identifierKind.rawId) !== null && _e !== void 0 ? _e : getIdentifierRawId(identifierKind),
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
cloud: (_g = identifierKind.cloud) !== null && _g !== void 0 ? _g : "public",
|
|
539
|
+
microsoftTeamsApp: {
|
|
540
|
+
teamsAppId: identifierKind.teamsAppId,
|
|
541
|
+
cloud: (_f = identifierKind.cloud) !== null && _f !== void 0 ? _f : "public",
|
|
560
542
|
},
|
|
561
543
|
};
|
|
562
544
|
case "unknown":
|
|
@@ -575,8 +557,8 @@ const getKind = (serializedIdentifier) => {
|
|
|
575
557
|
if (serializedIdentifier.microsoftTeamsUser) {
|
|
576
558
|
return "microsoftTeamsUser";
|
|
577
559
|
}
|
|
578
|
-
if (serializedIdentifier.
|
|
579
|
-
return "
|
|
560
|
+
if (serializedIdentifier.microsoftTeamsApp) {
|
|
561
|
+
return "microsoftTeamsApp";
|
|
580
562
|
}
|
|
581
563
|
return "unknown";
|
|
582
564
|
};
|
|
@@ -588,7 +570,7 @@ const getKind = (serializedIdentifier) => {
|
|
|
588
570
|
const deserializeCommunicationIdentifier = (serializedIdentifier) => {
|
|
589
571
|
var _a;
|
|
590
572
|
assertMaximumOneNestedModel(serializedIdentifier);
|
|
591
|
-
const { communicationUser, microsoftTeamsUser,
|
|
573
|
+
const { communicationUser, microsoftTeamsUser, microsoftTeamsApp, phoneNumber } = serializedIdentifier;
|
|
592
574
|
const kind = (_a = serializedIdentifier.kind) !== null && _a !== void 0 ? _a : getKind(serializedIdentifier);
|
|
593
575
|
if (kind === "communicationUser" && communicationUser) {
|
|
594
576
|
return {
|
|
@@ -612,13 +594,12 @@ const deserializeCommunicationIdentifier = (serializedIdentifier) => {
|
|
|
612
594
|
rawId: assertNotNullOrUndefined({ microsoftTeamsUser: serializedIdentifier }, "rawId"),
|
|
613
595
|
};
|
|
614
596
|
}
|
|
615
|
-
if (kind === "
|
|
597
|
+
if (kind === "microsoftTeamsApp" && microsoftTeamsApp) {
|
|
616
598
|
return {
|
|
617
|
-
kind: "
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
rawId: assertNotNullOrUndefined({ microsoftBot: serializedIdentifier }, "rawId"),
|
|
599
|
+
kind: "microsoftTeamsApp",
|
|
600
|
+
teamsAppId: assertNotNullOrUndefined({ microsoftTeamsApp }, "teamsAppId"),
|
|
601
|
+
cloud: assertNotNullOrUndefined({ microsoftTeamsApp }, "cloud"),
|
|
602
|
+
rawId: assertNotNullOrUndefined({ microsoftTeamsApp: serializedIdentifier }, "rawId"),
|
|
622
603
|
};
|
|
623
604
|
}
|
|
624
605
|
return {
|
|
@@ -636,7 +617,7 @@ exports.getIdentifierKind = getIdentifierKind;
|
|
|
636
617
|
exports.getIdentifierRawId = getIdentifierRawId;
|
|
637
618
|
exports.isCommunicationUserIdentifier = isCommunicationUserIdentifier;
|
|
638
619
|
exports.isKeyCredential = isKeyCredential;
|
|
639
|
-
exports.
|
|
620
|
+
exports.isMicrosoftTeamsAppIdentifier = isMicrosoftTeamsAppIdentifier;
|
|
640
621
|
exports.isMicrosoftTeamsUserIdentifier = isMicrosoftTeamsUserIdentifier;
|
|
641
622
|
exports.isPhoneNumberIdentifier = isPhoneNumberIdentifier;
|
|
642
623
|
exports.isUnknownIdentifier = isUnknownIdentifier;
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/tokenParser.ts","../src/autoRefreshTokenCredential.ts","../src/staticTokenCredential.ts","../src/azureCommunicationTokenCredential.ts","../src/credential/cryptoUtils.ts","../src/credential/communicationAccessKeyCredentialPolicy.ts","../src/credential/communicationAuthPolicy.ts","../src/credential/connectionString.ts","../src/credential/clientArguments.ts","../src/identifierModels.ts","../src/identifierModelSerializer.ts"],"sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { AccessToken } from \"@azure/core-auth\";\nimport jwtDecode from \"jwt-decode\";\n\ninterface JwtToken {\n exp: number;\n}\n\nexport const parseToken = (token: string): AccessToken => {\n const { exp } = jwtDecode<JwtToken>(token);\n return {\n token,\n expiresOnTimestamp: exp * 1000,\n };\n};\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { CommunicationGetTokenOptions, TokenCredential } from \"./communicationTokenCredential\";\nimport { AbortSignalLike } from \"@azure/abort-controller\";\nimport { AccessToken } from \"@azure/core-auth\";\nimport { parseToken } from \"./tokenParser\";\n\n/**\n * Options for auto-refreshing a Communication Token credential.\n */\nexport interface CommunicationTokenRefreshOptions {\n /**\n * Callback function that returns a string JWT token acquired from the Communication Identity API.\n * The returned token must be valid (expiration date must be in the future).\n */\n tokenRefresher: (abortSignal?: AbortSignalLike) => Promise<string>;\n\n /**\n * Optional token to initialize.\n */\n token?: string;\n\n /**\n * Indicates whether the token should be proactively renewed prior to expiry or only renew on demand.\n * By default false.\n */\n refreshProactively?: boolean;\n}\n\nconst expiredToken = { token: \"\", expiresOnTimestamp: -10 };\nconst minutesToMs = (minutes: number): number => minutes * 1000 * 60;\nconst defaultExpiringSoonInterval = minutesToMs(10);\nconst defaultRefreshAfterLifetimePercentage = 0.5;\n\nexport class AutoRefreshTokenCredential implements TokenCredential {\n private readonly refresh: (abortSignal?: AbortSignalLike) => Promise<string>;\n private readonly refreshProactively: boolean;\n private readonly expiringSoonIntervalInMs: number = defaultExpiringSoonInterval;\n private readonly refreshAfterLifetimePercentage = defaultRefreshAfterLifetimePercentage;\n\n private currentToken: AccessToken;\n private activeTimeout: ReturnType<typeof setTimeout> | undefined;\n private activeTokenFetching: Promise<string> | null = null;\n private activeTokenUpdating: Promise<void> | null = null;\n private disposed = false;\n\n constructor(refreshArgs: CommunicationTokenRefreshOptions) {\n const { tokenRefresher, token, refreshProactively } = refreshArgs;\n\n this.refresh = tokenRefresher;\n this.currentToken = token ? parseToken(token) : expiredToken;\n this.refreshProactively = refreshProactively ?? false;\n\n if (this.refreshProactively) {\n this.scheduleRefresh();\n }\n }\n\n public async getToken(options?: CommunicationGetTokenOptions): Promise<AccessToken> {\n if (!this.isTokenExpiringSoon(this.currentToken)) {\n return this.currentToken;\n }\n\n if (!this.isTokenValid(this.currentToken)) {\n const updatePromise = this.updateTokenAndReschedule(options?.abortSignal);\n await updatePromise;\n }\n\n return this.currentToken;\n }\n\n public dispose(): void {\n this.disposed = true;\n this.activeTokenFetching = null;\n this.activeTokenUpdating = null;\n this.currentToken = expiredToken;\n if (this.activeTimeout) {\n clearTimeout(this.activeTimeout);\n }\n }\n\n private async updateTokenAndReschedule(abortSignal?: AbortSignalLike): Promise<void> {\n if (this.activeTokenUpdating) {\n return this.activeTokenUpdating;\n }\n this.activeTokenUpdating = this.refreshTokenAndReschedule(abortSignal);\n try {\n await this.activeTokenUpdating;\n } finally {\n this.activeTokenUpdating = null;\n }\n }\n\n private async refreshTokenAndReschedule(abortSignal?: AbortSignalLike): Promise<void> {\n const newToken = await this.refreshToken(abortSignal);\n\n if (!this.isTokenValid(newToken)) {\n throw new Error(\"The token returned from the tokenRefresher is expired.\");\n }\n\n this.currentToken = newToken;\n if (this.refreshProactively) {\n this.scheduleRefresh();\n }\n }\n\n private async refreshToken(abortSignal?: AbortSignalLike): Promise<AccessToken> {\n try {\n if (!this.activeTokenFetching) {\n this.activeTokenFetching = this.refresh(abortSignal);\n }\n return parseToken(await this.activeTokenFetching);\n } finally {\n this.activeTokenFetching = null;\n }\n }\n\n private scheduleRefresh(): void {\n if (this.disposed) {\n return;\n }\n if (this.activeTimeout) {\n clearTimeout(this.activeTimeout);\n }\n const tokenTtlInMs = this.currentToken.expiresOnTimestamp - Date.now();\n let timespanInMs = null;\n\n if (this.isTokenExpiringSoon(this.currentToken)) {\n // Schedule the next refresh for when it reaches a certain percentage of the remaining lifetime.\n timespanInMs = tokenTtlInMs * this.refreshAfterLifetimePercentage;\n } else {\n // Schedule the next refresh for when it gets in to the soon-to-expire window.\n timespanInMs = tokenTtlInMs - this.expiringSoonIntervalInMs;\n }\n\n this.activeTimeout = setTimeout(() => this.updateTokenAndReschedule(), timespanInMs);\n }\n\n private isTokenValid(token: AccessToken): boolean {\n return token && Date.now() < token.expiresOnTimestamp;\n }\n\n private isTokenExpiringSoon(token: AccessToken): boolean {\n return !token || Date.now() >= token.expiresOnTimestamp - this.expiringSoonIntervalInMs;\n }\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { AccessToken } from \"@azure/core-auth\";\nimport { TokenCredential } from \"./communicationTokenCredential\";\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","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n AutoRefreshTokenCredential,\n CommunicationTokenRefreshOptions,\n} from \"./autoRefreshTokenCredential\";\nimport {\n CommunicationGetTokenOptions,\n CommunicationTokenCredential,\n TokenCredential,\n} from \"./communicationTokenCredential\";\nimport { AccessToken } from \"@azure/core-auth\";\nimport { StaticTokenCredential } from \"./staticTokenCredential\";\nimport { parseToken } from \"./tokenParser\";\n\n/**\n * The CommunicationTokenCredential implementation with support for proactive token refresh.\n */\n\nexport class AzureCommunicationTokenCredential implements CommunicationTokenCredential {\n private readonly tokenCredential: TokenCredential;\n private disposed = false;\n\n /**\n * Creates an instance of CommunicationTokenCredential with a static token and no proactive refreshing.\n * @param token - A user access token issued by Communication Services.\n */\n constructor(token: string);\n /**\n * Creates an instance of CommunicationTokenCredential with a lambda to get a token and options\n * to configure proactive refreshing.\n * @param refreshOptions - Options to configure refresh and opt-in to proactive refreshing.\n */\n constructor(refreshOptions: CommunicationTokenRefreshOptions);\n constructor(tokenOrRefreshOptions: string | CommunicationTokenRefreshOptions) {\n if (typeof tokenOrRefreshOptions === \"string\") {\n this.tokenCredential = new StaticTokenCredential(parseToken(tokenOrRefreshOptions));\n } else {\n this.tokenCredential = new AutoRefreshTokenCredential(tokenOrRefreshOptions);\n }\n }\n\n /**\n * Gets an `AccessToken` for the user. Throws if already disposed.\n * @param abortSignal - An implementation of `AbortSignalLike` to cancel the operation.\n */\n public async getToken(options?: CommunicationGetTokenOptions): Promise<AccessToken> {\n this.throwIfDisposed();\n const token = await this.tokenCredential.getToken(options);\n this.throwIfDisposed();\n return token;\n }\n\n /**\n * Disposes the CommunicationTokenCredential and cancels any internal auto-refresh operation.\n */\n public dispose(): void {\n this.disposed = true;\n this.tokenCredential.dispose();\n }\n\n private throwIfDisposed(): void {\n if (this.disposed) {\n throw new Error(\"User credential is disposed\");\n }\n }\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { createHash, createHmac } from \"crypto\";\n\nexport const shaHash = async (content: string): Promise<string> =>\n createHash(\"sha256\").update(content).digest(\"base64\");\n\nexport const shaHMAC = async (secret: string, content: string): Promise<string> => {\n const decodedSecret = Buffer.from(secret, \"base64\");\n\n return createHmac(\"sha256\", decodedSecret).update(content).digest(\"base64\");\n};\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n PipelinePolicy,\n PipelineRequest,\n PipelineResponse,\n SendRequest,\n} from \"@azure/core-rest-pipeline\";\nimport { shaHMAC, shaHash } from \"./cryptoUtils\";\nimport { KeyCredential } from \"@azure/core-auth\";\nimport { isNode } from \"@azure/core-util\";\n\n/**\n * CommunicationKeyCredentialPolicy provides a means of signing requests made through\n * the SmsClient.\n */\nconst communicationAccessKeyCredentialPolicy = \"CommunicationAccessKeyCredentialPolicy\";\n\n/**\n * Creates an HTTP pipeline policy to authenticate a request using a `KeyCredential`.\n * @hidden\n *\n * @param credential - The key credential.\n */\nexport function createCommunicationAccessKeyCredentialPolicy(\n credential: KeyCredential\n): PipelinePolicy {\n return {\n name: communicationAccessKeyCredentialPolicy,\n async sendRequest(request: PipelineRequest, next: SendRequest): Promise<PipelineResponse> {\n const verb = request.method.toUpperCase();\n const utcNow = new Date().toUTCString();\n const contentHash = await shaHash(request.body?.toString() || \"\");\n const dateHeader = \"x-ms-date\";\n const signedHeaders = `${dateHeader};host;x-ms-content-sha256`;\n\n const url = new URL(request.url);\n const query = url.searchParams.toString();\n const urlPathAndQuery = query ? `${url.pathname}?${query}` : url.pathname;\n const port = url.port;\n const hostAndPort = port ? `${url.host}:${port}` : url.host;\n\n const stringToSign = `${verb}\\n${urlPathAndQuery}\\n${utcNow};${hostAndPort};${contentHash}`;\n const signature = await shaHMAC(credential.key, stringToSign);\n\n if (isNode) {\n request.headers.set(\"Host\", hostAndPort || \"\");\n }\n\n request.headers.set(dateHeader, utcNow);\n request.headers.set(\"x-ms-content-sha256\", contentHash);\n request.headers.set(\n \"Authorization\",\n `HMAC-SHA256 SignedHeaders=${signedHeaders}&Signature=${signature}`\n );\n return next(request);\n },\n };\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n BearerTokenAuthenticationPolicyOptions,\n PipelinePolicy,\n bearerTokenAuthenticationPolicy,\n} from \"@azure/core-rest-pipeline\";\nimport { KeyCredential, TokenCredential, isTokenCredential } from \"@azure/core-auth\";\nimport { createCommunicationAccessKeyCredentialPolicy } from \"./communicationAccessKeyCredentialPolicy\";\n/**\n * Creates a pipeline policy to authenticate request based\n * on the credential passed in.\n * @hidden\n *\n * @param credential - The KeyCredential or TokenCredential.\n */\nexport function createCommunicationAuthPolicy(\n credential: KeyCredential | TokenCredential\n): PipelinePolicy {\n if (isTokenCredential(credential)) {\n const policyOptions: BearerTokenAuthenticationPolicyOptions = {\n credential: credential,\n scopes: [\"https://communication.azure.com//.default\"],\n };\n return bearerTokenAuthenticationPolicy(policyOptions);\n } else {\n return createCommunicationAccessKeyCredentialPolicy(credential);\n }\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { AzureKeyCredential, KeyCredential } from \"@azure/core-auth\";\n/**\n * Represents different properties of connection string\n * using format \"/endpoint=(.*);accesskey=(.*)\".\n * @hidden\n */\nexport interface EndpointCredential {\n /**\n * The endpoint as string\n */\n endpoint: string;\n /**\n * The access key represented as a KeyCredential object\n */\n credential: KeyCredential;\n}\n\n// TODO: update when connection string format is finalized\nconst CONNECTION_STRING_REGEX = /endpoint=(.*);accesskey=(.*)/i;\n\nconst tryParseConnectionString = (s: string): EndpointCredential | undefined => {\n const match = s.match(CONNECTION_STRING_REGEX);\n if (match?.[1] && match[2]) {\n return { endpoint: match[1], credential: new AzureKeyCredential(match[2]) };\n }\n return undefined;\n};\n/**\n * Returns an EndpointCredential to easily access properties of the connection string.\n * @hidden\n *\n * @param connectionString - The connection string to parse\n * @returns Object to access the endpoint and the credentials\n */\nexport const parseConnectionString = (connectionString: string): EndpointCredential => {\n const parsedConnectionString = tryParseConnectionString(connectionString);\n if (parsedConnectionString) {\n return parsedConnectionString;\n } else {\n throw new Error(`Invalid connection string ${connectionString}`);\n }\n};\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { KeyCredential, TokenCredential, isTokenCredential } from \"@azure/core-auth\";\nimport { parseConnectionString } from \"./connectionString\";\n\nconst isValidEndpoint = (host: string): boolean => {\n const url = new URL(host);\n\n return (\n !!url.protocol?.match(/^http[s]?/) &&\n url.host !== undefined &&\n url.host !== \"\" &&\n (url.pathname === undefined || url.pathname === \"\" || url.pathname === \"/\")\n );\n};\n\nconst assertValidEndpoint = (host: string): void => {\n if (!isValidEndpoint(host)) {\n throw new Error(`Invalid endpoint url ${host}`);\n }\n};\n\n/**\n * Checks whether a value is a KeyCredential.\n *\n * @param credential - The credential being checked.\n */\nexport const isKeyCredential = (credential: unknown): credential is KeyCredential => {\n const castCredential = credential as {\n key: unknown;\n getToken: unknown;\n };\n return (\n castCredential &&\n typeof castCredential.key === \"string\" &&\n castCredential.getToken === undefined\n );\n};\n\n/**\n * The URL and credential from parsing the arguments of a communication client.\n * @hidden\n */\nexport type UrlWithCredential = {\n url: string;\n credential: TokenCredential | KeyCredential;\n};\n\n/**\n * Parses arguments passed to a communication client.\n * @hidden\n */\nexport const parseClientArguments = (\n connectionStringOrUrl: string,\n credentialOrOptions?: unknown\n): UrlWithCredential => {\n if (isKeyCredential(credentialOrOptions) || isTokenCredential(credentialOrOptions)) {\n assertValidEndpoint(connectionStringOrUrl);\n return { url: connectionStringOrUrl, credential: credentialOrOptions };\n } else {\n const { endpoint: host, credential } = parseConnectionString(connectionStringOrUrl);\n assertValidEndpoint(host);\n return { url: host, credential };\n }\n};\n","// 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 | MicrosoftBotIdentifier\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 bot.\n */\nexport interface MicrosoftBotIdentifier {\n /**\n * Optional raw id of the Microsoft bot.\n */\n rawId?: string;\n\n /**\n * The unique Microsoft app ID for the bot as registered with the Bot Framework.\n */\n botId: string;\n\n /**\n * True (or missing) if the bot is global and no resource account is configured and false if the bot is tenantized.\n */\n isResourceAccountConfigured?: boolean;\n\n /**\n * The cloud that the Microsoft bot 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 MicrosoftBotIdentifier.\n *\n * @param identifier - The assumed available to be tested.\n */\nexport const isMicrosoftBotIdentifier = (\n identifier: CommunicationIdentifier\n): identifier is MicrosoftBotIdentifier => {\n return typeof (identifier as any).botId === \"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 | MicrosoftBotKind\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 MicrosoftBotIdentifier.\n */\nexport interface MicrosoftBotKind extends MicrosoftBotIdentifier {\n /**\n * The identifier kind.\n */\n kind: \"microsoftBot\";\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 (isMicrosoftBotIdentifier(identifier)) {\n return { ...identifier, kind: \"microsoftBot\" };\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 \"microsoftBot\": {\n const { botId, rawId, cloud, isResourceAccountConfigured } = identifierKind;\n if (rawId) return rawId;\n if (!isResourceAccountConfigured) {\n switch (cloud) {\n case \"dod\":\n return `28:dod-global:${botId}`;\n case \"gcch\":\n return `28:gcch-global:${botId}`;\n }\n return `28:${botId}`;\n }\n switch (cloud) {\n case \"dod\":\n return `28:dod:${botId}`;\n case \"gcch\":\n return `28:gcch:${botId}`;\n }\n return `28:orgid:${botId}`;\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 buildMicrosoftBotIdentifier = (\n id: string,\n cloud: \"public\" | \"dod\" | \"gcch\",\n isResourceAccountConfigured: boolean\n): CommunicationIdentifierKind => {\n return {\n kind: \"microsoftBot\",\n botId: id,\n cloud: cloud,\n isResourceAccountConfigured: isResourceAccountConfigured,\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 if (segments.length === 2 && segments[0] === \"28\") {\n return buildMicrosoftBotIdentifier(segments[1], \"public\", false);\n }\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:gcch-global:\":\n return buildMicrosoftBotIdentifier(suffix, \"gcch\", false);\n case \"28:orgid:\":\n return buildMicrosoftBotIdentifier(suffix, \"public\", true);\n case \"28:dod-global:\":\n return buildMicrosoftBotIdentifier(suffix, \"dod\", false);\n case \"28:gcch:\":\n return buildMicrosoftBotIdentifier(suffix, \"gcch\", true);\n case \"28:dod:\":\n return buildMicrosoftBotIdentifier(suffix, \"dod\", true);\n }\n return { kind: \"unknown\", id: rawId };\n};\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n CommunicationIdentifier,\n CommunicationIdentifierKind,\n getIdentifierKind,\n getIdentifierRawId,\n} from \"./identifierModels\";\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 bot.\n */\n microsoftBot?: SerializedMicrosoftBotIdentifier;\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 bot.\n */\nexport interface SerializedMicrosoftBotIdentifier {\n /**\n * Id of the Microsoft bot.\n */\n botId: string;\n /**\n * True (or missing) if the bot is global and no resource account is configured and false if the bot is tenantized.\n */\n isResourceAccountConfigured?: boolean;\n /**\n * The cloud that the Microsoft bot 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.microsoftBot !== undefined) {\n presentProperties.push(\"microsoftBot\");\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 \"microsoftBot\":\n return {\n rawId: identifierKind.rawId ?? getIdentifierRawId(identifierKind),\n microsoftBot: {\n botId: identifierKind.botId,\n isResourceAccountConfigured: identifierKind.isResourceAccountConfigured ?? true,\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.microsoftBot) {\n return \"microsoftBot\";\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, microsoftBot, phoneNumber } = 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 === \"microsoftBot\" && microsoftBot) {\n return {\n kind: \"microsoftBot\",\n botId: assertNotNullOrUndefined({ microsoftBot }, \"botId\"),\n isResourceAccountConfigured: assertNotNullOrUndefined(\n { microsoftBot },\n \"isResourceAccountConfigured\"\n ),\n cloud: assertNotNullOrUndefined({ microsoftBot }, \"cloud\"),\n rawId: assertNotNullOrUndefined({ microsoftBot: serializedIdentifier }, \"rawId\"),\n };\n }\n return {\n kind: \"unknown\",\n id: assertNotNullOrUndefined({ unknown: serializedIdentifier }, \"rawId\"),\n };\n};\n"],"names":["jwtDecode","createHash","createHmac","isNode","isTokenCredential","bearerTokenAuthenticationPolicy","AzureKeyCredential"],"mappings":";;;;;;;;;;;;;;AAAA;AAUO,MAAM,UAAU,GAAG,CAAC,KAAa,KAAiB;IACvD,MAAM,EAAE,GAAG,EAAE,GAAGA,6BAAS,CAAW,KAAK,CAAC,CAAC;IAC3C,O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ACL,QAAA,IAAI,EAAE,SAAS;QACf,EAAE,EAAE,wBAAwB,CAAC,EAAE,OAAO,EAAE,oBAAoB,EAAE,EAAE,OAAO,CAAC;KACzE,CAAC;AACJ;;;;;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/tokenParser.ts","../src/autoRefreshTokenCredential.ts","../src/staticTokenCredential.ts","../src/azureCommunicationTokenCredential.ts","../src/credential/cryptoUtils.ts","../src/credential/communicationAccessKeyCredentialPolicy.ts","../src/credential/communicationAuthPolicy.ts","../src/credential/connectionString.ts","../src/credential/clientArguments.ts","../src/identifierModels.ts","../src/identifierModelSerializer.ts"],"sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { AccessToken } from \"@azure/core-auth\";\nimport jwtDecode from \"jwt-decode\";\n\ninterface JwtToken {\n exp: number;\n}\n\nexport const parseToken = (token: string): AccessToken => {\n const { exp } = jwtDecode<JwtToken>(token);\n return {\n token,\n expiresOnTimestamp: exp * 1000,\n };\n};\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { CommunicationGetTokenOptions, TokenCredential } from \"./communicationTokenCredential\";\nimport { AbortSignalLike } from \"@azure/abort-controller\";\nimport { AccessToken } from \"@azure/core-auth\";\nimport { parseToken } from \"./tokenParser\";\n\n/**\n * Options for auto-refreshing a Communication Token credential.\n */\nexport interface CommunicationTokenRefreshOptions {\n /**\n * Callback function that returns a string JWT token acquired from the Communication Identity API.\n * The returned token must be valid (expiration date must be in the future).\n */\n tokenRefresher: (abortSignal?: AbortSignalLike) => Promise<string>;\n\n /**\n * Optional token to initialize.\n */\n token?: string;\n\n /**\n * Indicates whether the token should be proactively renewed prior to expiry or only renew on demand.\n * By default false.\n */\n refreshProactively?: boolean;\n}\n\nconst expiredToken = { token: \"\", expiresOnTimestamp: -10 };\nconst minutesToMs = (minutes: number): number => minutes * 1000 * 60;\nconst defaultExpiringSoonInterval = minutesToMs(10);\nconst defaultRefreshAfterLifetimePercentage = 0.5;\n\nexport class AutoRefreshTokenCredential implements TokenCredential {\n private readonly refresh: (abortSignal?: AbortSignalLike) => Promise<string>;\n private readonly refreshProactively: boolean;\n private readonly expiringSoonIntervalInMs: number = defaultExpiringSoonInterval;\n private readonly refreshAfterLifetimePercentage = defaultRefreshAfterLifetimePercentage;\n\n private currentToken: AccessToken;\n private activeTimeout: ReturnType<typeof setTimeout> | undefined;\n private activeTokenFetching: Promise<string> | null = null;\n private activeTokenUpdating: Promise<void> | null = null;\n private disposed = false;\n\n constructor(refreshArgs: CommunicationTokenRefreshOptions) {\n const { tokenRefresher, token, refreshProactively } = refreshArgs;\n\n this.refresh = tokenRefresher;\n this.currentToken = token ? parseToken(token) : expiredToken;\n this.refreshProactively = refreshProactively ?? false;\n\n if (this.refreshProactively) {\n this.scheduleRefresh();\n }\n }\n\n public async getToken(options?: CommunicationGetTokenOptions): Promise<AccessToken> {\n if (!this.isTokenExpiringSoon(this.currentToken)) {\n return this.currentToken;\n }\n\n if (!this.isTokenValid(this.currentToken)) {\n const updatePromise = this.updateTokenAndReschedule(options?.abortSignal);\n await updatePromise;\n }\n\n return this.currentToken;\n }\n\n public dispose(): void {\n this.disposed = true;\n this.activeTokenFetching = null;\n this.activeTokenUpdating = null;\n this.currentToken = expiredToken;\n if (this.activeTimeout) {\n clearTimeout(this.activeTimeout);\n }\n }\n\n private async updateTokenAndReschedule(abortSignal?: AbortSignalLike): Promise<void> {\n if (this.activeTokenUpdating) {\n return this.activeTokenUpdating;\n }\n this.activeTokenUpdating = this.refreshTokenAndReschedule(abortSignal);\n try {\n await this.activeTokenUpdating;\n } finally {\n this.activeTokenUpdating = null;\n }\n }\n\n private async refreshTokenAndReschedule(abortSignal?: AbortSignalLike): Promise<void> {\n const newToken = await this.refreshToken(abortSignal);\n\n if (!this.isTokenValid(newToken)) {\n throw new Error(\"The token returned from the tokenRefresher is expired.\");\n }\n\n this.currentToken = newToken;\n if (this.refreshProactively) {\n this.scheduleRefresh();\n }\n }\n\n private async refreshToken(abortSignal?: AbortSignalLike): Promise<AccessToken> {\n try {\n if (!this.activeTokenFetching) {\n this.activeTokenFetching = this.refresh(abortSignal);\n }\n return parseToken(await this.activeTokenFetching);\n } finally {\n this.activeTokenFetching = null;\n }\n }\n\n private scheduleRefresh(): void {\n if (this.disposed) {\n return;\n }\n if (this.activeTimeout) {\n clearTimeout(this.activeTimeout);\n }\n const tokenTtlInMs = this.currentToken.expiresOnTimestamp - Date.now();\n let timespanInMs = null;\n\n if (this.isTokenExpiringSoon(this.currentToken)) {\n // Schedule the next refresh for when it reaches a certain percentage of the remaining lifetime.\n timespanInMs = tokenTtlInMs * this.refreshAfterLifetimePercentage;\n } else {\n // Schedule the next refresh for when it gets in to the soon-to-expire window.\n timespanInMs = tokenTtlInMs - this.expiringSoonIntervalInMs;\n }\n\n this.activeTimeout = setTimeout(() => this.updateTokenAndReschedule(), timespanInMs);\n }\n\n private isTokenValid(token: AccessToken): boolean {\n return token && Date.now() < token.expiresOnTimestamp;\n }\n\n private isTokenExpiringSoon(token: AccessToken): boolean {\n return !token || Date.now() >= token.expiresOnTimestamp - this.expiringSoonIntervalInMs;\n }\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { AccessToken } from \"@azure/core-auth\";\nimport { TokenCredential } from \"./communicationTokenCredential\";\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","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n AutoRefreshTokenCredential,\n CommunicationTokenRefreshOptions,\n} from \"./autoRefreshTokenCredential\";\nimport {\n CommunicationGetTokenOptions,\n CommunicationTokenCredential,\n TokenCredential,\n} from \"./communicationTokenCredential\";\nimport { AccessToken } from \"@azure/core-auth\";\nimport { StaticTokenCredential } from \"./staticTokenCredential\";\nimport { parseToken } from \"./tokenParser\";\n\n/**\n * The CommunicationTokenCredential implementation with support for proactive token refresh.\n */\n\nexport class AzureCommunicationTokenCredential implements CommunicationTokenCredential {\n private readonly tokenCredential: TokenCredential;\n private disposed = false;\n\n /**\n * Creates an instance of CommunicationTokenCredential with a static token and no proactive refreshing.\n * @param token - A user access token issued by Communication Services.\n */\n constructor(token: string);\n /**\n * Creates an instance of CommunicationTokenCredential with a lambda to get a token and options\n * to configure proactive refreshing.\n * @param refreshOptions - Options to configure refresh and opt-in to proactive refreshing.\n */\n constructor(refreshOptions: CommunicationTokenRefreshOptions);\n constructor(tokenOrRefreshOptions: string | CommunicationTokenRefreshOptions) {\n if (typeof tokenOrRefreshOptions === \"string\") {\n this.tokenCredential = new StaticTokenCredential(parseToken(tokenOrRefreshOptions));\n } else {\n this.tokenCredential = new AutoRefreshTokenCredential(tokenOrRefreshOptions);\n }\n }\n\n /**\n * Gets an `AccessToken` for the user. Throws if already disposed.\n * @param abortSignal - An implementation of `AbortSignalLike` to cancel the operation.\n */\n public async getToken(options?: CommunicationGetTokenOptions): Promise<AccessToken> {\n this.throwIfDisposed();\n const token = await this.tokenCredential.getToken(options);\n this.throwIfDisposed();\n return token;\n }\n\n /**\n * Disposes the CommunicationTokenCredential and cancels any internal auto-refresh operation.\n */\n public dispose(): void {\n this.disposed = true;\n this.tokenCredential.dispose();\n }\n\n private throwIfDisposed(): void {\n if (this.disposed) {\n throw new Error(\"User credential is disposed\");\n }\n }\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { createHash, createHmac } from \"crypto\";\n\nexport const shaHash = async (content: string): Promise<string> =>\n createHash(\"sha256\").update(content).digest(\"base64\");\n\nexport const shaHMAC = async (secret: string, content: string): Promise<string> => {\n const decodedSecret = Buffer.from(secret, \"base64\");\n\n return createHmac(\"sha256\", decodedSecret).update(content).digest(\"base64\");\n};\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n PipelinePolicy,\n PipelineRequest,\n PipelineResponse,\n SendRequest,\n} from \"@azure/core-rest-pipeline\";\nimport { shaHMAC, shaHash } from \"./cryptoUtils\";\nimport { KeyCredential } from \"@azure/core-auth\";\nimport { isNode } from \"@azure/core-util\";\n\n/**\n * CommunicationKeyCredentialPolicy provides a means of signing requests made through\n * the SmsClient.\n */\nconst communicationAccessKeyCredentialPolicy = \"CommunicationAccessKeyCredentialPolicy\";\n\n/**\n * Creates an HTTP pipeline policy to authenticate a request using a `KeyCredential`.\n * @hidden\n *\n * @param credential - The key credential.\n */\nexport function createCommunicationAccessKeyCredentialPolicy(\n credential: KeyCredential\n): PipelinePolicy {\n return {\n name: communicationAccessKeyCredentialPolicy,\n async sendRequest(request: PipelineRequest, next: SendRequest): Promise<PipelineResponse> {\n const verb = request.method.toUpperCase();\n const utcNow = new Date().toUTCString();\n const contentHash = await shaHash(request.body?.toString() || \"\");\n const dateHeader = \"x-ms-date\";\n const signedHeaders = `${dateHeader};host;x-ms-content-sha256`;\n\n const url = new URL(request.url);\n const query = url.searchParams.toString();\n const urlPathAndQuery = query ? `${url.pathname}?${query}` : url.pathname;\n const port = url.port;\n const hostAndPort = port ? `${url.host}:${port}` : url.host;\n\n const stringToSign = `${verb}\\n${urlPathAndQuery}\\n${utcNow};${hostAndPort};${contentHash}`;\n const signature = await shaHMAC(credential.key, stringToSign);\n\n if (isNode) {\n request.headers.set(\"Host\", hostAndPort || \"\");\n }\n\n request.headers.set(dateHeader, utcNow);\n request.headers.set(\"x-ms-content-sha256\", contentHash);\n request.headers.set(\n \"Authorization\",\n `HMAC-SHA256 SignedHeaders=${signedHeaders}&Signature=${signature}`\n );\n return next(request);\n },\n };\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n BearerTokenAuthenticationPolicyOptions,\n PipelinePolicy,\n bearerTokenAuthenticationPolicy,\n} from \"@azure/core-rest-pipeline\";\nimport { KeyCredential, TokenCredential, isTokenCredential } from \"@azure/core-auth\";\nimport { createCommunicationAccessKeyCredentialPolicy } from \"./communicationAccessKeyCredentialPolicy\";\n/**\n * Creates a pipeline policy to authenticate request based\n * on the credential passed in.\n * @hidden\n *\n * @param credential - The KeyCredential or TokenCredential.\n */\nexport function createCommunicationAuthPolicy(\n credential: KeyCredential | TokenCredential\n): PipelinePolicy {\n if (isTokenCredential(credential)) {\n const policyOptions: BearerTokenAuthenticationPolicyOptions = {\n credential: credential,\n scopes: [\"https://communication.azure.com//.default\"],\n };\n return bearerTokenAuthenticationPolicy(policyOptions);\n } else {\n return createCommunicationAccessKeyCredentialPolicy(credential);\n }\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { AzureKeyCredential, KeyCredential } from \"@azure/core-auth\";\n/**\n * Represents different properties of connection string\n * using format \"/endpoint=(.*);accesskey=(.*)\".\n * @hidden\n */\nexport interface EndpointCredential {\n /**\n * The endpoint as string\n */\n endpoint: string;\n /**\n * The access key represented as a KeyCredential object\n */\n credential: KeyCredential;\n}\n\n// TODO: update when connection string format is finalized\nconst CONNECTION_STRING_REGEX = /endpoint=(.*);accesskey=(.*)/i;\n\nconst tryParseConnectionString = (s: string): EndpointCredential | undefined => {\n const match = s.match(CONNECTION_STRING_REGEX);\n if (match?.[1] && match[2]) {\n return { endpoint: match[1], credential: new AzureKeyCredential(match[2]) };\n }\n return undefined;\n};\n/**\n * Returns an EndpointCredential to easily access properties of the connection string.\n * @hidden\n *\n * @param connectionString - The connection string to parse\n * @returns Object to access the endpoint and the credentials\n */\nexport const parseConnectionString = (connectionString: string): EndpointCredential => {\n const parsedConnectionString = tryParseConnectionString(connectionString);\n if (parsedConnectionString) {\n return parsedConnectionString;\n } else {\n throw new Error(`Invalid connection string ${connectionString}`);\n }\n};\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { KeyCredential, TokenCredential, isTokenCredential } from \"@azure/core-auth\";\nimport { parseConnectionString } from \"./connectionString\";\n\nconst isValidEndpoint = (host: string): boolean => {\n const url = new URL(host);\n\n return (\n !!url.protocol?.match(/^http[s]?/) &&\n url.host !== undefined &&\n url.host !== \"\" &&\n (url.pathname === undefined || url.pathname === \"\" || url.pathname === \"/\")\n );\n};\n\nconst assertValidEndpoint = (host: string): void => {\n if (!isValidEndpoint(host)) {\n throw new Error(`Invalid endpoint url ${host}`);\n }\n};\n\n/**\n * Checks whether a value is a KeyCredential.\n *\n * @param credential - The credential being checked.\n */\nexport const isKeyCredential = (credential: unknown): credential is KeyCredential => {\n const castCredential = credential as {\n key: unknown;\n getToken: unknown;\n };\n return (\n castCredential &&\n typeof castCredential.key === \"string\" &&\n castCredential.getToken === undefined\n );\n};\n\n/**\n * The URL and credential from parsing the arguments of a communication client.\n * @hidden\n */\nexport type UrlWithCredential = {\n url: string;\n credential: TokenCredential | KeyCredential;\n};\n\n/**\n * Parses arguments passed to a communication client.\n * @hidden\n */\nexport const parseClientArguments = (\n connectionStringOrUrl: string,\n credentialOrOptions?: unknown\n): UrlWithCredential => {\n if (isKeyCredential(credentialOrOptions) || isTokenCredential(credentialOrOptions)) {\n assertValidEndpoint(connectionStringOrUrl);\n return { url: connectionStringOrUrl, credential: credentialOrOptions };\n } else {\n const { endpoint: host, credential } = parseConnectionString(connectionStringOrUrl);\n assertValidEndpoint(host);\n return { url: host, credential };\n }\n};\n","// 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","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n CommunicationIdentifier,\n CommunicationIdentifierKind,\n getIdentifierKind,\n getIdentifierRawId,\n} from \"./identifierModels\";\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 teamsAppId: 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 teamsAppId: 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 }, \"teamsAppId\"),\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"],"names":["jwtDecode","createHash","createHmac","isNode","isTokenCredential","bearerTokenAuthenticationPolicy","AzureKeyCredential"],"mappings":";;;;;;;;;;;;;;AAAA;AAUO,MAAM,UAAU,GAAG,CAAC,KAAa,KAAiB;IACvD,MAAM,EAAE,GAAG,EAAE,GAAGA,6BAAS,CAAW,KAAK,CAAC,CAAC;IAC3C,OAAO;QACL,KAAK;QACL,kBAAkB,EAAE,GAAG,GAAG,IAAI;KAC/B,CAAC;AACJ,CAAC;;AChBD;AA8BA,MAAM,YAAY,GAAG,EAAE,KAAK,EAAE,EAAE,EAAE,kBAAkB,EAAE,CAAC,EAAE,EAAE,CAAC;AAC5D,MAAM,WAAW,GAAG,CAAC,OAAe,KAAa,OAAO,GAAG,IAAI,GAAG,EAAE,CAAC;AACrE,MAAM,2BAA2B,GAAG,WAAW,CAAC,EAAE,CAAC,CAAC;AACpD,MAAM,qCAAqC,GAAG,GAAG,CAAC;MAErC,0BAA0B,CAAA;AAYrC,IAAA,WAAA,CAAY,WAA6C,EAAA;QATxC,IAAwB,CAAA,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AoB,EAAE,EAAE,OAAO,CAAC;KACzE,CAAC;AACJ;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -17,8 +17,8 @@ const assertMaximumOneNestedModel = (identifier) => {
|
|
|
17
17
|
if (identifier.microsoftTeamsUser !== undefined) {
|
|
18
18
|
presentProperties.push("microsoftTeamsUser");
|
|
19
19
|
}
|
|
20
|
-
if (identifier.
|
|
21
|
-
presentProperties.push("
|
|
20
|
+
if (identifier.microsoftTeamsApp !== undefined) {
|
|
21
|
+
presentProperties.push("microsoftTeamsApp");
|
|
22
22
|
}
|
|
23
23
|
if (identifier.phoneNumber !== undefined) {
|
|
24
24
|
presentProperties.push("phoneNumber");
|
|
@@ -33,7 +33,7 @@ const assertMaximumOneNestedModel = (identifier) => {
|
|
|
33
33
|
* @param identifier - The CommunicationIdentifier to be serialized.
|
|
34
34
|
*/
|
|
35
35
|
export const serializeCommunicationIdentifier = (identifier) => {
|
|
36
|
-
var _a, _b, _c, _d, _e, _f
|
|
36
|
+
var _a, _b, _c, _d, _e, _f;
|
|
37
37
|
const identifierKind = getIdentifierKind(identifier);
|
|
38
38
|
switch (identifierKind.kind) {
|
|
39
39
|
case "communicationUser":
|
|
@@ -57,13 +57,12 @@ export const serializeCommunicationIdentifier = (identifier) => {
|
|
|
57
57
|
cloud: (_d = identifierKind.cloud) !== null && _d !== void 0 ? _d : "public",
|
|
58
58
|
},
|
|
59
59
|
};
|
|
60
|
-
case "
|
|
60
|
+
case "microsoftTeamsApp":
|
|
61
61
|
return {
|
|
62
62
|
rawId: (_e = identifierKind.rawId) !== null && _e !== void 0 ? _e : getIdentifierRawId(identifierKind),
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
cloud: (_g = identifierKind.cloud) !== null && _g !== void 0 ? _g : "public",
|
|
63
|
+
microsoftTeamsApp: {
|
|
64
|
+
teamsAppId: identifierKind.teamsAppId,
|
|
65
|
+
cloud: (_f = identifierKind.cloud) !== null && _f !== void 0 ? _f : "public",
|
|
67
66
|
},
|
|
68
67
|
};
|
|
69
68
|
case "unknown":
|
|
@@ -82,8 +81,8 @@ const getKind = (serializedIdentifier) => {
|
|
|
82
81
|
if (serializedIdentifier.microsoftTeamsUser) {
|
|
83
82
|
return "microsoftTeamsUser";
|
|
84
83
|
}
|
|
85
|
-
if (serializedIdentifier.
|
|
86
|
-
return "
|
|
84
|
+
if (serializedIdentifier.microsoftTeamsApp) {
|
|
85
|
+
return "microsoftTeamsApp";
|
|
87
86
|
}
|
|
88
87
|
return "unknown";
|
|
89
88
|
};
|
|
@@ -95,7 +94,7 @@ const getKind = (serializedIdentifier) => {
|
|
|
95
94
|
export const deserializeCommunicationIdentifier = (serializedIdentifier) => {
|
|
96
95
|
var _a;
|
|
97
96
|
assertMaximumOneNestedModel(serializedIdentifier);
|
|
98
|
-
const { communicationUser, microsoftTeamsUser,
|
|
97
|
+
const { communicationUser, microsoftTeamsUser, microsoftTeamsApp, phoneNumber } = serializedIdentifier;
|
|
99
98
|
const kind = (_a = serializedIdentifier.kind) !== null && _a !== void 0 ? _a : getKind(serializedIdentifier);
|
|
100
99
|
if (kind === "communicationUser" && communicationUser) {
|
|
101
100
|
return {
|
|
@@ -119,13 +118,12 @@ export const deserializeCommunicationIdentifier = (serializedIdentifier) => {
|
|
|
119
118
|
rawId: assertNotNullOrUndefined({ microsoftTeamsUser: serializedIdentifier }, "rawId"),
|
|
120
119
|
};
|
|
121
120
|
}
|
|
122
|
-
if (kind === "
|
|
121
|
+
if (kind === "microsoftTeamsApp" && microsoftTeamsApp) {
|
|
123
122
|
return {
|
|
124
|
-
kind: "
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
rawId: assertNotNullOrUndefined({ microsoftBot: serializedIdentifier }, "rawId"),
|
|
123
|
+
kind: "microsoftTeamsApp",
|
|
124
|
+
teamsAppId: assertNotNullOrUndefined({ microsoftTeamsApp }, "teamsAppId"),
|
|
125
|
+
cloud: assertNotNullOrUndefined({ microsoftTeamsApp }, "cloud"),
|
|
126
|
+
rawId: assertNotNullOrUndefined({ microsoftTeamsApp: serializedIdentifier }, "rawId"),
|
|
129
127
|
};
|
|
130
128
|
}
|
|
131
129
|
return {
|
|
@@ -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,oBAAoB,CAAC;AAmG5B,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;QAClB,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC;KACrB;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;QAC9C,iBAAiB,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;KAC7C;IACD,IAAI,UAAU,CAAC,kBAAkB,KAAK,SAAS,EAAE;QAC/C,iBAAiB,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;KAC9C;IACD,IAAI,UAAU,CAAC,YAAY,KAAK,SAAS,EAAE;QACzC,iBAAiB,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;KACxC;IACD,IAAI,UAAU,CAAC,WAAW,KAAK,SAAS,EAAE;QACxC,iBAAiB,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;KACvC;IAC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,OAAO,CAAC;YAC/D,KAAK,EAAE,wBAAwB,CAAC,EAAE,WAAW,EAAE,oBAAoB,EAAE,EAAE,OAAO,CAAC;SAChF,CAAC;KACH;IACD,IAAI,IAAI,KAAK,oBAAoB,IAAI,kBAAkB,EAAE;QACvD,OAAO;YACL,IAAI,EAAE,oBAAoB;YAC1B,oBAAoB,EAAE,wBAAwB,CAAC,EAAE,kBAAkB,EAAE,EAAE,QAAQ,CAAC;YAChF,WAAW,EAAE,wBAAwB,CAAC,EAAE,kBAAkB,EAAE,EAAE,aAAa,CAAC;YAC5E,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;KACH;IACD,IAAI,IAAI,KAAK,cAAc,IAAI,YAAY,EAAE;QAC3C,OAAO;YACL,IAAI,EAAE,cAAc;YACpB,KAAK,EAAE,wBAAwB,CAAC,EAAE,YAAY,EAAE,EAAE,OAAO,CAAC;YAC1D,2BAA2B,EAAE,wBAAwB,CACnD,EAAE,YAAY,EAAE,EAChB,6BAA6B,CAC9B;YACD,KAAK,EAAE,wBAAwB,CAAC,EAAE,YAAY,EAAE,EAAE,OAAO,CAAC;YAC1D,KAAK,EAAE,wBAAwB,CAAC,EAAE,YAAY,EAAE,oBAAoB,EAAE,EAAE,OAAO,CAAC;SACjF,CAAC;KACH;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 CommunicationIdentifier,\n CommunicationIdentifierKind,\n getIdentifierKind,\n getIdentifierRawId,\n} from \"./identifierModels\";\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 bot.\n */\n microsoftBot?: SerializedMicrosoftBotIdentifier;\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 bot.\n */\nexport interface SerializedMicrosoftBotIdentifier {\n /**\n * Id of the Microsoft bot.\n */\n botId: string;\n /**\n * True (or missing) if the bot is global and no resource account is configured and false if the bot is tenantized.\n */\n isResourceAccountConfigured?: boolean;\n /**\n * The cloud that the Microsoft bot 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.microsoftBot !== undefined) {\n presentProperties.push(\"microsoftBot\");\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 \"microsoftBot\":\n return {\n rawId: identifierKind.rawId ?? getIdentifierRawId(identifierKind),\n microsoftBot: {\n botId: identifierKind.botId,\n isResourceAccountConfigured: identifierKind.isResourceAccountConfigured ?? true,\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.microsoftBot) {\n return \"microsoftBot\";\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, microsoftBot, phoneNumber } = 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 === \"microsoftBot\" && microsoftBot) {\n return {\n kind: \"microsoftBot\",\n botId: assertNotNullOrUndefined({ microsoftBot }, \"botId\"),\n isResourceAccountConfigured: assertNotNullOrUndefined(\n { microsoftBot },\n \"isResourceAccountConfigured\"\n ),\n cloud: assertNotNullOrUndefined({ microsoftBot }, \"cloud\"),\n rawId: assertNotNullOrUndefined({ microsoftBot: 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,oBAAoB,CAAC;AAgG5B,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;QAClB,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC;KACrB;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;QAC9C,iBAAiB,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;KAC7C;IACD,IAAI,UAAU,CAAC,kBAAkB,KAAK,S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,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n CommunicationIdentifier,\n CommunicationIdentifierKind,\n getIdentifierKind,\n getIdentifierRawId,\n} from \"./identifierModels\";\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 teamsAppId: 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 teamsAppId: 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 }, \"teamsAppId\"),\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"]}
|
|
@@ -25,12 +25,12 @@ export const isMicrosoftTeamsUserIdentifier = (identifier) => {
|
|
|
25
25
|
return typeof identifier.microsoftTeamsUserId === "string";
|
|
26
26
|
};
|
|
27
27
|
/**
|
|
28
|
-
* Tests an Identifier to determine whether it implements
|
|
28
|
+
* Tests an Identifier to determine whether it implements MicrosoftTeamsAppIdentifier.
|
|
29
29
|
*
|
|
30
30
|
* @param identifier - The assumed available to be tested.
|
|
31
31
|
*/
|
|
32
|
-
export const
|
|
33
|
-
return typeof identifier.
|
|
32
|
+
export const isMicrosoftTeamsAppIdentifier = (identifier) => {
|
|
33
|
+
return typeof identifier.teamsAppId === "string";
|
|
34
34
|
};
|
|
35
35
|
/**
|
|
36
36
|
* Tests an Identifier to determine whether it implements UnknownIdentifier.
|
|
@@ -55,8 +55,8 @@ export const getIdentifierKind = (identifier) => {
|
|
|
55
55
|
if (isMicrosoftTeamsUserIdentifier(identifier)) {
|
|
56
56
|
return Object.assign(Object.assign({}, identifier), { kind: "microsoftTeamsUser" });
|
|
57
57
|
}
|
|
58
|
-
if (
|
|
59
|
-
return Object.assign(Object.assign({}, identifier), { kind: "
|
|
58
|
+
if (isMicrosoftTeamsAppIdentifier(identifier)) {
|
|
59
|
+
return Object.assign(Object.assign({}, identifier), { kind: "microsoftTeamsApp" });
|
|
60
60
|
}
|
|
61
61
|
return Object.assign(Object.assign({}, identifier), { kind: "unknown" });
|
|
62
62
|
};
|
|
@@ -86,26 +86,17 @@ export const getIdentifierRawId = (identifier) => {
|
|
|
86
86
|
}
|
|
87
87
|
return `8:orgid:${microsoftTeamsUserId}`;
|
|
88
88
|
}
|
|
89
|
-
case "
|
|
90
|
-
const {
|
|
89
|
+
case "microsoftTeamsApp": {
|
|
90
|
+
const { teamsAppId, rawId, cloud } = identifierKind;
|
|
91
91
|
if (rawId)
|
|
92
92
|
return rawId;
|
|
93
|
-
if (!isResourceAccountConfigured) {
|
|
94
|
-
switch (cloud) {
|
|
95
|
-
case "dod":
|
|
96
|
-
return `28:dod-global:${botId}`;
|
|
97
|
-
case "gcch":
|
|
98
|
-
return `28:gcch-global:${botId}`;
|
|
99
|
-
}
|
|
100
|
-
return `28:${botId}`;
|
|
101
|
-
}
|
|
102
93
|
switch (cloud) {
|
|
103
94
|
case "dod":
|
|
104
|
-
return `28:dod:${
|
|
95
|
+
return `28:dod:${teamsAppId}`;
|
|
105
96
|
case "gcch":
|
|
106
|
-
return `28:gcch:${
|
|
97
|
+
return `28:gcch:${teamsAppId}`;
|
|
107
98
|
}
|
|
108
|
-
return `28:orgid:${
|
|
99
|
+
return `28:orgid:${teamsAppId}`;
|
|
109
100
|
}
|
|
110
101
|
case "phoneNumber": {
|
|
111
102
|
const { phoneNumber, rawId } = identifierKind;
|
|
@@ -118,12 +109,11 @@ export const getIdentifierRawId = (identifier) => {
|
|
|
118
109
|
}
|
|
119
110
|
}
|
|
120
111
|
};
|
|
121
|
-
const
|
|
112
|
+
const buildMicrosoftTeamsAppIdentifier = (teamsAppId, cloud) => {
|
|
122
113
|
return {
|
|
123
|
-
kind: "
|
|
124
|
-
|
|
114
|
+
kind: "microsoftTeamsApp",
|
|
115
|
+
teamsAppId: teamsAppId,
|
|
125
116
|
cloud: cloud,
|
|
126
|
-
isResourceAccountConfigured: isResourceAccountConfigured,
|
|
127
117
|
};
|
|
128
118
|
};
|
|
129
119
|
const buildMicrosoftTeamsUserIdentifier = (id, cloud, isAnonymous) => {
|
|
@@ -145,9 +135,6 @@ export const createIdentifierFromRawId = (rawId) => {
|
|
|
145
135
|
}
|
|
146
136
|
const segments = rawId.split(":");
|
|
147
137
|
if (segments.length !== 3) {
|
|
148
|
-
if (segments.length === 2 && segments[0] === "28") {
|
|
149
|
-
return buildMicrosoftBotIdentifier(segments[1], "public", false);
|
|
150
|
-
}
|
|
151
138
|
return { kind: "unknown", id: rawId };
|
|
152
139
|
}
|
|
153
140
|
const prefix = `${segments[0]}:${segments[1]}:`;
|
|
@@ -166,16 +153,12 @@ export const createIdentifierFromRawId = (rawId) => {
|
|
|
166
153
|
case "8:dod-acs:":
|
|
167
154
|
case "8:gcch-acs:":
|
|
168
155
|
return { kind: "communicationUser", communicationUserId: rawId };
|
|
169
|
-
case "28:gcch-global:":
|
|
170
|
-
return buildMicrosoftBotIdentifier(suffix, "gcch", false);
|
|
171
156
|
case "28:orgid:":
|
|
172
|
-
return
|
|
173
|
-
case "28:dod-global:":
|
|
174
|
-
return buildMicrosoftBotIdentifier(suffix, "dod", false);
|
|
157
|
+
return buildMicrosoftTeamsAppIdentifier(suffix, "public");
|
|
175
158
|
case "28:gcch:":
|
|
176
|
-
return
|
|
159
|
+
return buildMicrosoftTeamsAppIdentifier(suffix, "gcch");
|
|
177
160
|
case "28:dod:":
|
|
178
|
-
return
|
|
161
|
+
return buildMicrosoftTeamsAppIdentifier(suffix, "dod");
|
|
179
162
|
}
|
|
180
163
|
return { kind: "unknown", id: rawId };
|
|
181
164
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"identifierModels.js","sourceRoot":"","sources":["../../src/identifierModels.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;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AAE,KAAK,CAAC,CAAC;QAC3D,KAAK,UAAU;YACb,OAAO,2BAA2B,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;QAC3D,KAAK,SAAS;YACZ,OAAO,2BAA2B,CAAC,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;KAC3D;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 | MicrosoftBotIdentifier\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 bot.\n */\nexport interface MicrosoftBotIdentifier {\n /**\n * Optional raw id of the Microsoft bot.\n */\n rawId?: string;\n\n /**\n * The unique Microsoft app ID for the bot as registered with the Bot Framework.\n */\n botId: string;\n\n /**\n * True (or missing) if the bot is global and no resource account is configured and false if the bot is tenantized.\n */\n isResourceAccountConfigured?: boolean;\n\n /**\n * The cloud that the Microsoft bot 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 MicrosoftBotIdentifier.\n *\n * @param identifier - The assumed available to be tested.\n */\nexport const isMicrosoftBotIdentifier = (\n identifier: CommunicationIdentifier\n): identifier is MicrosoftBotIdentifier => {\n return typeof (identifier as any).botId === \"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 | MicrosoftBotKind\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 MicrosoftBotIdentifier.\n */\nexport interface MicrosoftBotKind extends MicrosoftBotIdentifier {\n /**\n * The identifier kind.\n */\n kind: \"microsoftBot\";\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 (isMicrosoftBotIdentifier(identifier)) {\n return { ...identifier, kind: \"microsoftBot\" };\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 \"microsoftBot\": {\n const { botId, rawId, cloud, isResourceAccountConfigured } = identifierKind;\n if (rawId) return rawId;\n if (!isResourceAccountConfigured) {\n switch (cloud) {\n case \"dod\":\n return `28:dod-global:${botId}`;\n case \"gcch\":\n return `28:gcch-global:${botId}`;\n }\n return `28:${botId}`;\n }\n switch (cloud) {\n case \"dod\":\n return `28:dod:${botId}`;\n case \"gcch\":\n return `28:gcch:${botId}`;\n }\n return `28:orgid:${botId}`;\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 buildMicrosoftBotIdentifier = (\n id: string,\n cloud: \"public\" | \"dod\" | \"gcch\",\n isResourceAccountConfigured: boolean\n): CommunicationIdentifierKind => {\n return {\n kind: \"microsoftBot\",\n botId: id,\n cloud: cloud,\n isResourceAccountConfigured: isResourceAccountConfigured,\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 if (segments.length === 2 && segments[0] === \"28\") {\n return buildMicrosoftBotIdentifier(segments[1], \"public\", false);\n }\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:gcch-global:\":\n return buildMicrosoftBotIdentifier(suffix, \"gcch\", false);\n case \"28:orgid:\":\n return buildMicrosoftBotIdentifier(suffix, \"public\", true);\n case \"28:dod-global:\":\n return buildMicrosoftBotIdentifier(suffix, \"dod\", false);\n case \"28:gcch:\":\n return buildMicrosoftBotIdentifier(suffix, \"gcch\", true);\n case \"28:dod:\":\n return buildMicrosoftBotIdentifier(suffix, \"dod\", true);\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;AA2FlC;;;;GAIG;AACH,MA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AI,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;QACzF,KAAK,UAAU;YACb,OAAO,iCAAiC,CAAC,MAAM,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC;QACpE,KAAK,QAAQ;YACX,OAAO,iCAAiC,CAAC,MAAM,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;QACjE,KAAK,SAAS;YACZ,OAAO,iCAAiC,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;QAClE,KAAK,QAAQ,CAAC;QACd,KAAK,UAAU,CAAC;QAChB,KAAK,YAAY,CAAC;QAClB,KAAK,aAAa;YAChB,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;KAC1D;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"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@azure/communication-common",
|
|
3
|
-
"version": "3.0.0-alpha.
|
|
3
|
+
"version": "3.0.0-alpha.20230915.1",
|
|
4
4
|
"description": "Common package for Azure Communication services.",
|
|
5
5
|
"sdk-type": "client",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"test:node": "npm run build:test && npm run unit-test:node && npm run integration-test:node",
|
|
33
33
|
"test": "npm run build:test && npm run unit-test && npm run integration-test",
|
|
34
34
|
"unit-test:browser": "karma start --single-run",
|
|
35
|
-
"unit-test:node": "
|
|
35
|
+
"unit-test:node": "dev-tool run test:node-ts-input --no-test-proxy=true",
|
|
36
36
|
"unit-test": "npm run unit-test:node && npm run unit-test:browser"
|
|
37
37
|
},
|
|
38
38
|
"files": [
|
|
@@ -46,12 +46,12 @@ export declare interface CommunicationGetTokenOptions {
|
|
|
46
46
|
/**
|
|
47
47
|
* Identifies a communication participant.
|
|
48
48
|
*/
|
|
49
|
-
export declare type CommunicationIdentifier = CommunicationUserIdentifier | PhoneNumberIdentifier | MicrosoftTeamsUserIdentifier |
|
|
49
|
+
export declare type CommunicationIdentifier = CommunicationUserIdentifier | PhoneNumberIdentifier | MicrosoftTeamsUserIdentifier | MicrosoftTeamsAppIdentifier | UnknownIdentifier;
|
|
50
50
|
|
|
51
51
|
/**
|
|
52
52
|
* The CommunicationIdentifierKind is a discriminated union that adds a property `kind` to an Identifier.
|
|
53
53
|
*/
|
|
54
|
-
export declare type CommunicationIdentifierKind = CommunicationUserKind | PhoneNumberKind | MicrosoftTeamsUserKind |
|
|
54
|
+
export declare type CommunicationIdentifierKind = CommunicationUserKind | PhoneNumberKind | MicrosoftTeamsUserKind | MicrosoftTeamsAppKind | UnknownIdentifierKind;
|
|
55
55
|
|
|
56
56
|
/**
|
|
57
57
|
* The Azure Communication Services token credential.
|
|
@@ -184,11 +184,11 @@ export declare const isCommunicationUserIdentifier: (identifier: CommunicationId
|
|
|
184
184
|
export declare const isKeyCredential: (credential: unknown) => credential is KeyCredential;
|
|
185
185
|
|
|
186
186
|
/**
|
|
187
|
-
* Tests an Identifier to determine whether it implements
|
|
187
|
+
* Tests an Identifier to determine whether it implements MicrosoftTeamsAppIdentifier.
|
|
188
188
|
*
|
|
189
189
|
* @param identifier - The assumed available to be tested.
|
|
190
190
|
*/
|
|
191
|
-
export declare const
|
|
191
|
+
export declare const isMicrosoftTeamsAppIdentifier: (identifier: CommunicationIdentifier) => identifier is MicrosoftTeamsAppIdentifier;
|
|
192
192
|
|
|
193
193
|
/**
|
|
194
194
|
* Tests an Identifier to determine whether it implements MicrosoftTeamsUserIdentifier.
|
|
@@ -212,35 +212,31 @@ export declare const isPhoneNumberIdentifier: (identifier: CommunicationIdentifi
|
|
|
212
212
|
export declare const isUnknownIdentifier: (identifier: CommunicationIdentifier) => identifier is UnknownIdentifier;
|
|
213
213
|
|
|
214
214
|
/**
|
|
215
|
-
* A Microsoft
|
|
215
|
+
* A Microsoft Teams App.
|
|
216
216
|
*/
|
|
217
|
-
export declare interface
|
|
217
|
+
export declare interface MicrosoftTeamsAppIdentifier {
|
|
218
218
|
/**
|
|
219
|
-
* Optional raw id of the Microsoft
|
|
219
|
+
* Optional raw id of the Microsoft Teams App.
|
|
220
220
|
*/
|
|
221
221
|
rawId?: string;
|
|
222
222
|
/**
|
|
223
|
-
* The unique Microsoft app ID
|
|
223
|
+
* The unique Microsoft Teams app ID.
|
|
224
224
|
*/
|
|
225
|
-
|
|
225
|
+
teamsAppId: string;
|
|
226
226
|
/**
|
|
227
|
-
*
|
|
228
|
-
*/
|
|
229
|
-
isResourceAccountConfigured?: boolean;
|
|
230
|
-
/**
|
|
231
|
-
* The cloud that the Microsoft bot belongs to. If missing, the cloud is "public".
|
|
227
|
+
* The cloud that the Microsoft Temas App belongs to. If missing, the cloud is "public".
|
|
232
228
|
*/
|
|
233
229
|
cloud?: "public" | "dod" | "gcch";
|
|
234
230
|
}
|
|
235
231
|
|
|
236
232
|
/**
|
|
237
|
-
* IdentifierKind for a
|
|
233
|
+
* IdentifierKind for a MicrosoftTeamsAppIdentifier.
|
|
238
234
|
*/
|
|
239
|
-
export declare interface
|
|
235
|
+
export declare interface MicrosoftTeamsAppKind extends MicrosoftTeamsAppIdentifier {
|
|
240
236
|
/**
|
|
241
237
|
* The identifier kind.
|
|
242
238
|
*/
|
|
243
|
-
kind: "
|
|
239
|
+
kind: "microsoftTeamsApp";
|
|
244
240
|
}
|
|
245
241
|
|
|
246
242
|
/**
|
|
@@ -353,9 +349,9 @@ export declare interface SerializedCommunicationIdentifier {
|
|
|
353
349
|
*/
|
|
354
350
|
microsoftTeamsUser?: SerializedMicrosoftTeamsUserIdentifier;
|
|
355
351
|
/**
|
|
356
|
-
* The Microsoft
|
|
352
|
+
* The Microsoft Teams App.
|
|
357
353
|
*/
|
|
358
|
-
|
|
354
|
+
microsoftTeamsApp?: SerializedMicrosoftTeamsAppIdentifier;
|
|
359
355
|
}
|
|
360
356
|
|
|
361
357
|
/**
|
|
@@ -371,19 +367,15 @@ export declare interface SerializedCommunicationUserIdentifier {
|
|
|
371
367
|
|
|
372
368
|
/**
|
|
373
369
|
* @hidden
|
|
374
|
-
* A Microsoft
|
|
370
|
+
* A Microsoft Teams App.
|
|
375
371
|
*/
|
|
376
|
-
export declare interface
|
|
377
|
-
/**
|
|
378
|
-
* Id of the Microsoft bot.
|
|
379
|
-
*/
|
|
380
|
-
botId: string;
|
|
372
|
+
export declare interface SerializedMicrosoftTeamsAppIdentifier {
|
|
381
373
|
/**
|
|
382
|
-
*
|
|
374
|
+
* Id of the Microsoft Teams App.
|
|
383
375
|
*/
|
|
384
|
-
|
|
376
|
+
teamsAppId: string;
|
|
385
377
|
/**
|
|
386
|
-
* The cloud that the Microsoft
|
|
378
|
+
* The cloud that the Microsoft Teams App belongs to. By default 'public' if missing.
|
|
387
379
|
*/
|
|
388
380
|
cloud?: SerializedCommunicationCloudEnvironment;
|
|
389
381
|
}
|