@azure/communication-common 2.2.1 → 2.3.0
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 +75 -22
- package/dist/index.js.map +1 -1
- package/dist-esm/src/identifierModelSerializer.js +24 -2
- package/dist-esm/src/identifierModelSerializer.js.map +1 -1
- package/dist-esm/src/identifierModels.js +50 -20
- package/dist-esm/src/identifierModels.js.map +1 -1
- package/package.json +11 -9
- package/types/communication-common.d.ts +56 -2
package/dist/index.js
CHANGED
|
@@ -337,6 +337,14 @@ const isPhoneNumberIdentifier = (identifier) => {
|
|
|
337
337
|
const isMicrosoftTeamsUserIdentifier = (identifier) => {
|
|
338
338
|
return typeof identifier.microsoftTeamsUserId === "string";
|
|
339
339
|
};
|
|
340
|
+
/**
|
|
341
|
+
* Tests an Identifier to determine whether it implements MicrosoftTeamsAppIdentifier.
|
|
342
|
+
*
|
|
343
|
+
* @param identifier - The assumed available to be tested.
|
|
344
|
+
*/
|
|
345
|
+
const isMicrosoftTeamsAppIdentifier = (identifier) => {
|
|
346
|
+
return typeof identifier.teamsAppId === "string";
|
|
347
|
+
};
|
|
340
348
|
/**
|
|
341
349
|
* Tests an Identifier to determine whether it implements UnknownIdentifier.
|
|
342
350
|
*
|
|
@@ -360,6 +368,9 @@ const getIdentifierKind = (identifier) => {
|
|
|
360
368
|
if (isMicrosoftTeamsUserIdentifier(identifier)) {
|
|
361
369
|
return Object.assign(Object.assign({}, identifier), { kind: "microsoftTeamsUser" });
|
|
362
370
|
}
|
|
371
|
+
if (isMicrosoftTeamsAppIdentifier(identifier)) {
|
|
372
|
+
return Object.assign(Object.assign({}, identifier), { kind: "microsoftTeamsApp" });
|
|
373
|
+
}
|
|
363
374
|
return Object.assign(Object.assign({}, identifier), { kind: "unknown" });
|
|
364
375
|
};
|
|
365
376
|
/**
|
|
@@ -388,6 +399,18 @@ const getIdentifierRawId = (identifier) => {
|
|
|
388
399
|
}
|
|
389
400
|
return `8:orgid:${microsoftTeamsUserId}`;
|
|
390
401
|
}
|
|
402
|
+
case "microsoftTeamsApp": {
|
|
403
|
+
const { teamsAppId, rawId, cloud } = identifierKind;
|
|
404
|
+
if (rawId)
|
|
405
|
+
return rawId;
|
|
406
|
+
switch (cloud) {
|
|
407
|
+
case "dod":
|
|
408
|
+
return `28:dod:${teamsAppId}`;
|
|
409
|
+
case "gcch":
|
|
410
|
+
return `28:gcch:${teamsAppId}`;
|
|
411
|
+
}
|
|
412
|
+
return `28:orgid:${teamsAppId}`;
|
|
413
|
+
}
|
|
391
414
|
case "phoneNumber": {
|
|
392
415
|
const { phoneNumber, rawId } = identifierKind;
|
|
393
416
|
if (rawId)
|
|
@@ -399,6 +422,21 @@ const getIdentifierRawId = (identifier) => {
|
|
|
399
422
|
}
|
|
400
423
|
}
|
|
401
424
|
};
|
|
425
|
+
const buildMicrosoftTeamsAppIdentifier = (teamsAppId, cloud) => {
|
|
426
|
+
return {
|
|
427
|
+
kind: "microsoftTeamsApp",
|
|
428
|
+
teamsAppId: teamsAppId,
|
|
429
|
+
cloud: cloud,
|
|
430
|
+
};
|
|
431
|
+
};
|
|
432
|
+
const buildMicrosoftTeamsUserIdentifier = (id, cloud, isAnonymous) => {
|
|
433
|
+
return {
|
|
434
|
+
kind: "microsoftTeamsUser",
|
|
435
|
+
microsoftTeamsUserId: id,
|
|
436
|
+
isAnonymous: isAnonymous,
|
|
437
|
+
cloud: cloud,
|
|
438
|
+
};
|
|
439
|
+
};
|
|
402
440
|
/**
|
|
403
441
|
* Creates a CommunicationIdentifierKind from a given rawId. When storing rawIds use this function to restore the identifier that was encoded in the rawId.
|
|
404
442
|
*
|
|
@@ -409,39 +447,31 @@ const createIdentifierFromRawId = (rawId) => {
|
|
|
409
447
|
return { kind: "phoneNumber", phoneNumber: `${rawId.substring("4:".length)}` };
|
|
410
448
|
}
|
|
411
449
|
const segments = rawId.split(":");
|
|
412
|
-
if (segments.length
|
|
450
|
+
if (segments.length !== 3) {
|
|
413
451
|
return { kind: "unknown", id: rawId };
|
|
452
|
+
}
|
|
414
453
|
const prefix = `${segments[0]}:${segments[1]}:`;
|
|
415
|
-
const suffix =
|
|
454
|
+
const suffix = segments[2];
|
|
416
455
|
switch (prefix) {
|
|
417
456
|
case "8:teamsvisitor:":
|
|
418
457
|
return { kind: "microsoftTeamsUser", microsoftTeamsUserId: suffix, isAnonymous: true };
|
|
419
458
|
case "8:orgid:":
|
|
420
|
-
return
|
|
421
|
-
kind: "microsoftTeamsUser",
|
|
422
|
-
microsoftTeamsUserId: suffix,
|
|
423
|
-
isAnonymous: false,
|
|
424
|
-
cloud: "public",
|
|
425
|
-
};
|
|
459
|
+
return buildMicrosoftTeamsUserIdentifier(suffix, "public", false);
|
|
426
460
|
case "8:dod:":
|
|
427
|
-
return
|
|
428
|
-
kind: "microsoftTeamsUser",
|
|
429
|
-
microsoftTeamsUserId: suffix,
|
|
430
|
-
isAnonymous: false,
|
|
431
|
-
cloud: "dod",
|
|
432
|
-
};
|
|
461
|
+
return buildMicrosoftTeamsUserIdentifier(suffix, "dod", false);
|
|
433
462
|
case "8:gcch:":
|
|
434
|
-
return
|
|
435
|
-
kind: "microsoftTeamsUser",
|
|
436
|
-
microsoftTeamsUserId: suffix,
|
|
437
|
-
isAnonymous: false,
|
|
438
|
-
cloud: "gcch",
|
|
439
|
-
};
|
|
463
|
+
return buildMicrosoftTeamsUserIdentifier(suffix, "gcch", false);
|
|
440
464
|
case "8:acs:":
|
|
441
465
|
case "8:spool:":
|
|
442
466
|
case "8:dod-acs:":
|
|
443
467
|
case "8:gcch-acs:":
|
|
444
468
|
return { kind: "communicationUser", communicationUserId: rawId };
|
|
469
|
+
case "28:orgid:":
|
|
470
|
+
return buildMicrosoftTeamsAppIdentifier(suffix, "public");
|
|
471
|
+
case "28:gcch:":
|
|
472
|
+
return buildMicrosoftTeamsAppIdentifier(suffix, "gcch");
|
|
473
|
+
case "28:dod:":
|
|
474
|
+
return buildMicrosoftTeamsAppIdentifier(suffix, "dod");
|
|
445
475
|
}
|
|
446
476
|
return { kind: "unknown", id: rawId };
|
|
447
477
|
};
|
|
@@ -463,6 +493,9 @@ const assertMaximumOneNestedModel = (identifier) => {
|
|
|
463
493
|
if (identifier.microsoftTeamsUser !== undefined) {
|
|
464
494
|
presentProperties.push("microsoftTeamsUser");
|
|
465
495
|
}
|
|
496
|
+
if (identifier.microsoftTeamsApp !== undefined) {
|
|
497
|
+
presentProperties.push("microsoftTeamsApp");
|
|
498
|
+
}
|
|
466
499
|
if (identifier.phoneNumber !== undefined) {
|
|
467
500
|
presentProperties.push("phoneNumber");
|
|
468
501
|
}
|
|
@@ -476,7 +509,7 @@ const assertMaximumOneNestedModel = (identifier) => {
|
|
|
476
509
|
* @param identifier - The CommunicationIdentifier to be serialized.
|
|
477
510
|
*/
|
|
478
511
|
const serializeCommunicationIdentifier = (identifier) => {
|
|
479
|
-
var _a, _b, _c, _d;
|
|
512
|
+
var _a, _b, _c, _d, _e, _f;
|
|
480
513
|
const identifierKind = getIdentifierKind(identifier);
|
|
481
514
|
switch (identifierKind.kind) {
|
|
482
515
|
case "communicationUser":
|
|
@@ -500,6 +533,14 @@ const serializeCommunicationIdentifier = (identifier) => {
|
|
|
500
533
|
cloud: (_d = identifierKind.cloud) !== null && _d !== void 0 ? _d : "public",
|
|
501
534
|
},
|
|
502
535
|
};
|
|
536
|
+
case "microsoftTeamsApp":
|
|
537
|
+
return {
|
|
538
|
+
rawId: (_e = identifierKind.rawId) !== null && _e !== void 0 ? _e : getIdentifierRawId(identifierKind),
|
|
539
|
+
microsoftTeamsApp: {
|
|
540
|
+
teamsAppId: identifierKind.teamsAppId,
|
|
541
|
+
cloud: (_f = identifierKind.cloud) !== null && _f !== void 0 ? _f : "public",
|
|
542
|
+
},
|
|
543
|
+
};
|
|
503
544
|
case "unknown":
|
|
504
545
|
return { rawId: identifierKind.id };
|
|
505
546
|
default:
|
|
@@ -516,6 +557,9 @@ const getKind = (serializedIdentifier) => {
|
|
|
516
557
|
if (serializedIdentifier.microsoftTeamsUser) {
|
|
517
558
|
return "microsoftTeamsUser";
|
|
518
559
|
}
|
|
560
|
+
if (serializedIdentifier.microsoftTeamsApp) {
|
|
561
|
+
return "microsoftTeamsApp";
|
|
562
|
+
}
|
|
519
563
|
return "unknown";
|
|
520
564
|
};
|
|
521
565
|
/**
|
|
@@ -526,7 +570,7 @@ const getKind = (serializedIdentifier) => {
|
|
|
526
570
|
const deserializeCommunicationIdentifier = (serializedIdentifier) => {
|
|
527
571
|
var _a;
|
|
528
572
|
assertMaximumOneNestedModel(serializedIdentifier);
|
|
529
|
-
const { communicationUser, microsoftTeamsUser, phoneNumber } = serializedIdentifier;
|
|
573
|
+
const { communicationUser, microsoftTeamsUser, microsoftTeamsApp, phoneNumber } = serializedIdentifier;
|
|
530
574
|
const kind = (_a = serializedIdentifier.kind) !== null && _a !== void 0 ? _a : getKind(serializedIdentifier);
|
|
531
575
|
if (kind === "communicationUser" && communicationUser) {
|
|
532
576
|
return {
|
|
@@ -550,6 +594,14 @@ const deserializeCommunicationIdentifier = (serializedIdentifier) => {
|
|
|
550
594
|
rawId: assertNotNullOrUndefined({ microsoftTeamsUser: serializedIdentifier }, "rawId"),
|
|
551
595
|
};
|
|
552
596
|
}
|
|
597
|
+
if (kind === "microsoftTeamsApp" && microsoftTeamsApp) {
|
|
598
|
+
return {
|
|
599
|
+
kind: "microsoftTeamsApp",
|
|
600
|
+
teamsAppId: assertNotNullOrUndefined({ microsoftTeamsApp }, "teamsAppId"),
|
|
601
|
+
cloud: assertNotNullOrUndefined({ microsoftTeamsApp }, "cloud"),
|
|
602
|
+
rawId: assertNotNullOrUndefined({ microsoftTeamsApp: serializedIdentifier }, "rawId"),
|
|
603
|
+
};
|
|
604
|
+
}
|
|
553
605
|
return {
|
|
554
606
|
kind: "unknown",
|
|
555
607
|
id: assertNotNullOrUndefined({ unknown: serializedIdentifier }, "rawId"),
|
|
@@ -565,6 +617,7 @@ exports.getIdentifierKind = getIdentifierKind;
|
|
|
565
617
|
exports.getIdentifierRawId = getIdentifierRawId;
|
|
566
618
|
exports.isCommunicationUserIdentifier = isCommunicationUserIdentifier;
|
|
567
619
|
exports.isKeyCredential = isKeyCredential;
|
|
620
|
+
exports.isMicrosoftTeamsAppIdentifier = isMicrosoftTeamsAppIdentifier;
|
|
568
621
|
exports.isMicrosoftTeamsUserIdentifier = isMicrosoftTeamsUserIdentifier;
|
|
569
622
|
exports.isPhoneNumberIdentifier = isPhoneNumberIdentifier;
|
|
570
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 | 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 * 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 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 | 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 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 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 \"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\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) return { kind: \"unknown\", id: rawId };\n\n const prefix = `${segments[0]}:${segments[1]}:`;\n const suffix = rawId.substring(prefix.length);\n\n switch (prefix) {\n case \"8:teamsvisitor:\":\n return { kind: \"microsoftTeamsUser\", microsoftTeamsUserId: suffix, isAnonymous: true };\n case \"8:orgid:\":\n return {\n kind: \"microsoftTeamsUser\",\n microsoftTeamsUserId: suffix,\n isAnonymous: false,\n cloud: \"public\",\n };\n case \"8:dod:\":\n return {\n kind: \"microsoftTeamsUser\",\n microsoftTeamsUserId: suffix,\n isAnonymous: false,\n cloud: \"dod\",\n };\n case \"8:gcch:\":\n return {\n kind: \"microsoftTeamsUser\",\n microsoftTeamsUserId: suffix,\n isAnonymous: false,\n cloud: \"gcch\",\n };\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 }\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\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 * 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.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 \"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 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, 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 return {\n kind: \"unknown\",\n id: assertNotNullOrUndefined({ unknown: serializedIdentifier }, \"rawId\"),\n };\n};\n"],"names":["jw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BAAoB,CAAC,CAAC;AAExE,IAAA,IAAI,IAAI,KAAK,mBAAmB,IAAI,iBAAiB,EAAE;QACrD,OAAO;AACL,YAAA,IAAI,EAAE,mBAAmB;YACzB,mBAAmB,EAAE,wBAAwB,CAAC,EAAE,iBAAiB,EAAE,EAAE,IAAI,CAAC;SAC3E,CAAC;AACH,KAAA;AACD,IAAA,IAAI,IAAI,KAAK,aAAa,IAAI,WAAW,EAAE;QACzC,OAAO;AACL,YAAA,IAAI,EAAE,aAAa;YACnB,WAAW,EAAE,wBAAwB,CAAC,EAAE,WAAW,EAAE,EAAE,OAAO,CAAC;YAC/D,KAAK,EAAE,wBAAwB,CAAC,EAAE,WAAW,EAAE,oBAAoB,EAAE,EAAE,OAAO,CAAC;SAChF,CAAC;AACH,KAAA;AACD,IAAA,IAAI,IAAI,KAAK,oBAAoB,IAAI,kBAAkB,EAAE;QACvD,OAAO;AACL,YAAA,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;AACH,KAAA;IACD,OAAO;AACL,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,wBAAA,GAAW,2BAA2B,CAAC;QAC/D,IAA8B,CAAA,8BAAA,GAAG,qCAAqC,CAAC;QAIhF,IAAmB,CAAA,mBAAA,GAA2B,IAAI,CAAC;QACnD,IAAmB,CAAA,mBAAA,GAAyB,IAAI,CAAC;QACjD,IAAQ,CAAA,QAAA,GAAG,KAAK,CAAC;QAGvB,MAAM,EAAE,cAAc,EAAE,KAAK,EAAE,kBAAkB,EAAE,GAAG,WAAW,CAAC;AAElE,QAAA,IAAI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BAAoB,EAAE,EAAE,OAAO,CAAC;SAChF,CAAC;AACH,KAAA;AACD,IAAA,IAAI,IAAI,KAAK,oBAAoB,IAAI,kBAAkB,EAAE;QACvD,OAAO;AACL,YAAA,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;AACH,KAAA;AACD,IAAA,IAAI,IAAI,KAAK,mBAAmB,IAAI,iBAAiB,EAAE;QACrD,OAAO;AACL,YAAA,IAAI,EAAE,mBAAmB;YACzB,UAAU,EAAE,wBAAwB,CAAC,EAAE,iBAAiB,EAAE,EAAE,YAAY,CAAC;YACzE,KAAK,EAAE,wBAAwB,CAAC,EAAE,iBAAiB,EAAE,EAAE,OAAO,CAAC;YAC/D,KAAK,EAAE,wBAAwB,CAAC,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,EAAE,OAAO,CAAC;SACtF,CAAC;AACH,KAAA;IACD,OAAO;AACL,QAAA,IAAI,EAAE,SAAS;QACf,EAAE,EAAE,wBAAwB,CAAC,EAAE,OAAO,EAAE,oBAAoB,EAAE,EAAE,OAAO,CAAC;KACzE,CAAC;AACJ;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -17,6 +17,9 @@ const assertMaximumOneNestedModel = (identifier) => {
|
|
|
17
17
|
if (identifier.microsoftTeamsUser !== undefined) {
|
|
18
18
|
presentProperties.push("microsoftTeamsUser");
|
|
19
19
|
}
|
|
20
|
+
if (identifier.microsoftTeamsApp !== undefined) {
|
|
21
|
+
presentProperties.push("microsoftTeamsApp");
|
|
22
|
+
}
|
|
20
23
|
if (identifier.phoneNumber !== undefined) {
|
|
21
24
|
presentProperties.push("phoneNumber");
|
|
22
25
|
}
|
|
@@ -30,7 +33,7 @@ const assertMaximumOneNestedModel = (identifier) => {
|
|
|
30
33
|
* @param identifier - The CommunicationIdentifier to be serialized.
|
|
31
34
|
*/
|
|
32
35
|
export const serializeCommunicationIdentifier = (identifier) => {
|
|
33
|
-
var _a, _b, _c, _d;
|
|
36
|
+
var _a, _b, _c, _d, _e, _f;
|
|
34
37
|
const identifierKind = getIdentifierKind(identifier);
|
|
35
38
|
switch (identifierKind.kind) {
|
|
36
39
|
case "communicationUser":
|
|
@@ -54,6 +57,14 @@ export const serializeCommunicationIdentifier = (identifier) => {
|
|
|
54
57
|
cloud: (_d = identifierKind.cloud) !== null && _d !== void 0 ? _d : "public",
|
|
55
58
|
},
|
|
56
59
|
};
|
|
60
|
+
case "microsoftTeamsApp":
|
|
61
|
+
return {
|
|
62
|
+
rawId: (_e = identifierKind.rawId) !== null && _e !== void 0 ? _e : getIdentifierRawId(identifierKind),
|
|
63
|
+
microsoftTeamsApp: {
|
|
64
|
+
teamsAppId: identifierKind.teamsAppId,
|
|
65
|
+
cloud: (_f = identifierKind.cloud) !== null && _f !== void 0 ? _f : "public",
|
|
66
|
+
},
|
|
67
|
+
};
|
|
57
68
|
case "unknown":
|
|
58
69
|
return { rawId: identifierKind.id };
|
|
59
70
|
default:
|
|
@@ -70,6 +81,9 @@ const getKind = (serializedIdentifier) => {
|
|
|
70
81
|
if (serializedIdentifier.microsoftTeamsUser) {
|
|
71
82
|
return "microsoftTeamsUser";
|
|
72
83
|
}
|
|
84
|
+
if (serializedIdentifier.microsoftTeamsApp) {
|
|
85
|
+
return "microsoftTeamsApp";
|
|
86
|
+
}
|
|
73
87
|
return "unknown";
|
|
74
88
|
};
|
|
75
89
|
/**
|
|
@@ -80,7 +94,7 @@ const getKind = (serializedIdentifier) => {
|
|
|
80
94
|
export const deserializeCommunicationIdentifier = (serializedIdentifier) => {
|
|
81
95
|
var _a;
|
|
82
96
|
assertMaximumOneNestedModel(serializedIdentifier);
|
|
83
|
-
const { communicationUser, microsoftTeamsUser, phoneNumber } = serializedIdentifier;
|
|
97
|
+
const { communicationUser, microsoftTeamsUser, microsoftTeamsApp, phoneNumber } = serializedIdentifier;
|
|
84
98
|
const kind = (_a = serializedIdentifier.kind) !== null && _a !== void 0 ? _a : getKind(serializedIdentifier);
|
|
85
99
|
if (kind === "communicationUser" && communicationUser) {
|
|
86
100
|
return {
|
|
@@ -104,6 +118,14 @@ export const deserializeCommunicationIdentifier = (serializedIdentifier) => {
|
|
|
104
118
|
rawId: assertNotNullOrUndefined({ microsoftTeamsUser: serializedIdentifier }, "rawId"),
|
|
105
119
|
};
|
|
106
120
|
}
|
|
121
|
+
if (kind === "microsoftTeamsApp" && microsoftTeamsApp) {
|
|
122
|
+
return {
|
|
123
|
+
kind: "microsoftTeamsApp",
|
|
124
|
+
teamsAppId: assertNotNullOrUndefined({ microsoftTeamsApp }, "teamsAppId"),
|
|
125
|
+
cloud: assertNotNullOrUndefined({ microsoftTeamsApp }, "cloud"),
|
|
126
|
+
rawId: assertNotNullOrUndefined({ microsoftTeamsApp: serializedIdentifier }, "rawId"),
|
|
127
|
+
};
|
|
128
|
+
}
|
|
107
129
|
return {
|
|
108
130
|
kind: "unknown",
|
|
109
131
|
id: assertNotNullOrUndefined({ unknown: serializedIdentifier }, "rawId"),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"identifierModelSerializer.js","sourceRoot":"","sources":["../../src/identifierModelSerializer.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAGL,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,oBAAoB,CAAC;AA4E5B,MAAM,wBAAwB,GAAG,CAK/B,GAAM,EACN,IAAO,EACsB,EAAE;IAC/B,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CA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BAAiB,EAAE;QACrD,OAAO;YACL,IAAI,EAAE,mBAAmB;YACzB,mBAAmB,EAAE,wBAAwB,CAAC,EAAE,iBAAiB,EAAE,EAAE,IAAI,CAAC;SAC3E,CAAC;KACH;IACD,IAAI,IAAI,KAAK,aAAa,IAAI,WAAW,EAAE;QACzC,OAAO;YACL,IAAI,EAAE,aAAa;YACnB,WAAW,EAAE,wBAAwB,CAAC,EAAE,WAAW,EAAE,EAAE,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,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\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 * 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.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 \"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 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, 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 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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B,EAAE,EAAE,OAAO,CAAC;YAC/D,KAAK,EAAE,wBAAwB,CAAC,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,EAAE,OAAO,CAAC;SACtF,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 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"]}
|
|
@@ -24,6 +24,14 @@ export const isPhoneNumberIdentifier = (identifier) => {
|
|
|
24
24
|
export const isMicrosoftTeamsUserIdentifier = (identifier) => {
|
|
25
25
|
return typeof identifier.microsoftTeamsUserId === "string";
|
|
26
26
|
};
|
|
27
|
+
/**
|
|
28
|
+
* Tests an Identifier to determine whether it implements MicrosoftTeamsAppIdentifier.
|
|
29
|
+
*
|
|
30
|
+
* @param identifier - The assumed available to be tested.
|
|
31
|
+
*/
|
|
32
|
+
export const isMicrosoftTeamsAppIdentifier = (identifier) => {
|
|
33
|
+
return typeof identifier.teamsAppId === "string";
|
|
34
|
+
};
|
|
27
35
|
/**
|
|
28
36
|
* Tests an Identifier to determine whether it implements UnknownIdentifier.
|
|
29
37
|
*
|
|
@@ -47,6 +55,9 @@ export const getIdentifierKind = (identifier) => {
|
|
|
47
55
|
if (isMicrosoftTeamsUserIdentifier(identifier)) {
|
|
48
56
|
return Object.assign(Object.assign({}, identifier), { kind: "microsoftTeamsUser" });
|
|
49
57
|
}
|
|
58
|
+
if (isMicrosoftTeamsAppIdentifier(identifier)) {
|
|
59
|
+
return Object.assign(Object.assign({}, identifier), { kind: "microsoftTeamsApp" });
|
|
60
|
+
}
|
|
50
61
|
return Object.assign(Object.assign({}, identifier), { kind: "unknown" });
|
|
51
62
|
};
|
|
52
63
|
/**
|
|
@@ -75,6 +86,18 @@ export const getIdentifierRawId = (identifier) => {
|
|
|
75
86
|
}
|
|
76
87
|
return `8:orgid:${microsoftTeamsUserId}`;
|
|
77
88
|
}
|
|
89
|
+
case "microsoftTeamsApp": {
|
|
90
|
+
const { teamsAppId, rawId, cloud } = identifierKind;
|
|
91
|
+
if (rawId)
|
|
92
|
+
return rawId;
|
|
93
|
+
switch (cloud) {
|
|
94
|
+
case "dod":
|
|
95
|
+
return `28:dod:${teamsAppId}`;
|
|
96
|
+
case "gcch":
|
|
97
|
+
return `28:gcch:${teamsAppId}`;
|
|
98
|
+
}
|
|
99
|
+
return `28:orgid:${teamsAppId}`;
|
|
100
|
+
}
|
|
78
101
|
case "phoneNumber": {
|
|
79
102
|
const { phoneNumber, rawId } = identifierKind;
|
|
80
103
|
if (rawId)
|
|
@@ -86,6 +109,21 @@ export const getIdentifierRawId = (identifier) => {
|
|
|
86
109
|
}
|
|
87
110
|
}
|
|
88
111
|
};
|
|
112
|
+
const buildMicrosoftTeamsAppIdentifier = (teamsAppId, cloud) => {
|
|
113
|
+
return {
|
|
114
|
+
kind: "microsoftTeamsApp",
|
|
115
|
+
teamsAppId: teamsAppId,
|
|
116
|
+
cloud: cloud,
|
|
117
|
+
};
|
|
118
|
+
};
|
|
119
|
+
const buildMicrosoftTeamsUserIdentifier = (id, cloud, isAnonymous) => {
|
|
120
|
+
return {
|
|
121
|
+
kind: "microsoftTeamsUser",
|
|
122
|
+
microsoftTeamsUserId: id,
|
|
123
|
+
isAnonymous: isAnonymous,
|
|
124
|
+
cloud: cloud,
|
|
125
|
+
};
|
|
126
|
+
};
|
|
89
127
|
/**
|
|
90
128
|
* Creates a CommunicationIdentifierKind from a given rawId. When storing rawIds use this function to restore the identifier that was encoded in the rawId.
|
|
91
129
|
*
|
|
@@ -96,39 +134,31 @@ export const createIdentifierFromRawId = (rawId) => {
|
|
|
96
134
|
return { kind: "phoneNumber", phoneNumber: `${rawId.substring("4:".length)}` };
|
|
97
135
|
}
|
|
98
136
|
const segments = rawId.split(":");
|
|
99
|
-
if (segments.length
|
|
137
|
+
if (segments.length !== 3) {
|
|
100
138
|
return { kind: "unknown", id: rawId };
|
|
139
|
+
}
|
|
101
140
|
const prefix = `${segments[0]}:${segments[1]}:`;
|
|
102
|
-
const suffix =
|
|
141
|
+
const suffix = segments[2];
|
|
103
142
|
switch (prefix) {
|
|
104
143
|
case "8:teamsvisitor:":
|
|
105
144
|
return { kind: "microsoftTeamsUser", microsoftTeamsUserId: suffix, isAnonymous: true };
|
|
106
145
|
case "8:orgid:":
|
|
107
|
-
return
|
|
108
|
-
kind: "microsoftTeamsUser",
|
|
109
|
-
microsoftTeamsUserId: suffix,
|
|
110
|
-
isAnonymous: false,
|
|
111
|
-
cloud: "public",
|
|
112
|
-
};
|
|
146
|
+
return buildMicrosoftTeamsUserIdentifier(suffix, "public", false);
|
|
113
147
|
case "8:dod:":
|
|
114
|
-
return
|
|
115
|
-
kind: "microsoftTeamsUser",
|
|
116
|
-
microsoftTeamsUserId: suffix,
|
|
117
|
-
isAnonymous: false,
|
|
118
|
-
cloud: "dod",
|
|
119
|
-
};
|
|
148
|
+
return buildMicrosoftTeamsUserIdentifier(suffix, "dod", false);
|
|
120
149
|
case "8:gcch:":
|
|
121
|
-
return
|
|
122
|
-
kind: "microsoftTeamsUser",
|
|
123
|
-
microsoftTeamsUserId: suffix,
|
|
124
|
-
isAnonymous: false,
|
|
125
|
-
cloud: "gcch",
|
|
126
|
-
};
|
|
150
|
+
return buildMicrosoftTeamsUserIdentifier(suffix, "gcch", false);
|
|
127
151
|
case "8:acs:":
|
|
128
152
|
case "8:spool:":
|
|
129
153
|
case "8:dod-acs:":
|
|
130
154
|
case "8:gcch-acs:":
|
|
131
155
|
return { kind: "communicationUser", communicationUserId: rawId };
|
|
156
|
+
case "28:orgid:":
|
|
157
|
+
return buildMicrosoftTeamsAppIdentifier(suffix, "public");
|
|
158
|
+
case "28:gcch:":
|
|
159
|
+
return buildMicrosoftTeamsAppIdentifier(suffix, "gcch");
|
|
160
|
+
case "28:dod:":
|
|
161
|
+
return buildMicrosoftTeamsAppIdentifier(suffix, "dod");
|
|
132
162
|
}
|
|
133
163
|
return { kind: "unknown", id: rawId };
|
|
134
164
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"identifierModels.js","sourceRoot":"","sources":["../../src/identifierModels.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAsElC;;;;GAIG;AACH,MAAM,CAAC,MAAM,6BAA6B,GAAG,CAC3C,UAAmC,EACQ,EAAE;IAC7C,OAAO,OAAQ,UAAkB,CAAC,mBAAmB,KAAK,QAAQ,CAAC;AACrE,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,CACrC,UAAmC,EACE,EAAE;IACvC,OAAO,OAAQ,UAAkB,CAAC,WAAW,KAAK,QAAQ,CAAC;AAC7D,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,8BAA8B,GAAG,CAC5C,UAAmC,EACS,EAAE;IAC9C,OAAO,OAAQ,UAAkB,CAAC,oBAAoB,KAAK,QAAQ,CAAC;AACtE,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CACjC,UAAmC,EACF,EAAE;IACnC,OAAO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E,oBAAoB;gBAC1B,oBAAoB,EAAE,MAAM;gBAC5B,WAAW,EAAE,KAAK;gBAClB,KAAK,EAAE,KAAK;aACb,CAAC;QACJ,KAAK,SAAS;YACZ,OAAO;gBACL,IAAI,EAAE,oBAAoB;gBAC1B,oBAAoB,EAAE,MAAM;gBAC5B,WAAW,EAAE,KAAK;gBAClB,KAAK,EAAE,MAAM;aACd,CAAC;QACJ,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;KACpE;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 | 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 * 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 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 | 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 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 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 \"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\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) return { kind: \"unknown\", id: rawId };\n\n const prefix = `${segments[0]}:${segments[1]}:`;\n const suffix = rawId.substring(prefix.length);\n\n switch (prefix) {\n case \"8:teamsvisitor:\":\n return { kind: \"microsoftTeamsUser\", microsoftTeamsUserId: suffix, isAnonymous: true };\n case \"8:orgid:\":\n return {\n kind: \"microsoftTeamsUser\",\n microsoftTeamsUserId: suffix,\n isAnonymous: false,\n cloud: \"public\",\n };\n case \"8:dod:\":\n return {\n kind: \"microsoftTeamsUser\",\n microsoftTeamsUserId: suffix,\n isAnonymous: false,\n cloud: \"dod\",\n };\n case \"8:gcch:\":\n return {\n kind: \"microsoftTeamsUser\",\n microsoftTeamsUserId: suffix,\n isAnonymous: false,\n cloud: \"gcch\",\n };\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 }\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,MAAM,CAAC,MAAM,6BAA6B,GAAG,CAC3C,UAAmC,EACQ,EAAE;IAC7C,OAAO,OAAQ,UAAkB,CAAC,mBAAmB,KAAK,QAAQ,CAAC;AACrE,CAAC,CAAC;AAEF;;;;GAIG;A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K,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": "2.
|
|
3
|
+
"version": "2.3.0",
|
|
4
4
|
"description": "Common package for Azure Communication services.",
|
|
5
5
|
"sdk-type": "client",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"extract-api": "tsc -p . && api-extractor run --local",
|
|
24
24
|
"format": "prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"*.{js,json}\"",
|
|
25
25
|
"integration-test:browser": "karma start --single-run",
|
|
26
|
-
"integration-test:node": "
|
|
26
|
+
"integration-test:node": "dev-tool run test:node-js-input -- --timeout 5000000 'dist-esm/test/**/*.spec.js'",
|
|
27
27
|
"integration-test": "npm run integration-test:node && npm run integration-test:browser",
|
|
28
28
|
"lint:fix": "eslint package.json api-extractor.json README.md src test --ext .ts,.javascript,.js --fix --fix-type [problem,suggestion]",
|
|
29
29
|
"lint": "eslint package.json api-extractor.json README.md src test --ext .ts,.javascript,.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": [
|
|
@@ -77,9 +77,9 @@
|
|
|
77
77
|
"@microsoft/api-extractor": "^7.31.1",
|
|
78
78
|
"@types/chai-as-promised": "^7.1.0",
|
|
79
79
|
"@types/chai": "^4.1.6",
|
|
80
|
-
"@types/mocha": "^
|
|
80
|
+
"@types/mocha": "^10.0.0",
|
|
81
81
|
"@types/node": "^14.0.0",
|
|
82
|
-
"@types/sinon": "^
|
|
82
|
+
"@types/sinon": "^10.0.0",
|
|
83
83
|
"chai-as-promised": "^7.1.1",
|
|
84
84
|
"chai": "^4.2.0",
|
|
85
85
|
"cross-env": "^7.0.2",
|
|
@@ -95,13 +95,15 @@
|
|
|
95
95
|
"karma-sourcemap-loader": "^0.3.8",
|
|
96
96
|
"karma": "^6.2.0",
|
|
97
97
|
"mocha-junit-reporter": "^2.0.0",
|
|
98
|
-
"mocha": "^
|
|
98
|
+
"mocha": "^10.0.0",
|
|
99
99
|
"nyc": "^15.0.0",
|
|
100
100
|
"prettier": "^2.5.1",
|
|
101
101
|
"rimraf": "^3.0.0",
|
|
102
|
-
"sinon": "^
|
|
103
|
-
"typescript": "~
|
|
102
|
+
"sinon": "^15.0.0",
|
|
103
|
+
"typescript": "~5.0.0",
|
|
104
104
|
"util": "^0.12.1",
|
|
105
|
-
"mockdate": "^3.0.5"
|
|
105
|
+
"mockdate": "^3.0.5",
|
|
106
|
+
"ts-node": "^10.0.0",
|
|
107
|
+
"esm": "^3.2.18"
|
|
106
108
|
}
|
|
107
109
|
}
|
|
@@ -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 | UnknownIdentifier;
|
|
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 | UnknownIdentifierKind;
|
|
54
|
+
export declare type CommunicationIdentifierKind = CommunicationUserKind | PhoneNumberKind | MicrosoftTeamsUserKind | MicrosoftTeamsAppKind | UnknownIdentifierKind;
|
|
55
55
|
|
|
56
56
|
/**
|
|
57
57
|
* The Azure Communication Services token credential.
|
|
@@ -183,6 +183,13 @@ export declare const isCommunicationUserIdentifier: (identifier: CommunicationId
|
|
|
183
183
|
*/
|
|
184
184
|
export declare const isKeyCredential: (credential: unknown) => credential is KeyCredential;
|
|
185
185
|
|
|
186
|
+
/**
|
|
187
|
+
* Tests an Identifier to determine whether it implements MicrosoftTeamsAppIdentifier.
|
|
188
|
+
*
|
|
189
|
+
* @param identifier - The assumed available to be tested.
|
|
190
|
+
*/
|
|
191
|
+
export declare const isMicrosoftTeamsAppIdentifier: (identifier: CommunicationIdentifier) => identifier is MicrosoftTeamsAppIdentifier;
|
|
192
|
+
|
|
186
193
|
/**
|
|
187
194
|
* Tests an Identifier to determine whether it implements MicrosoftTeamsUserIdentifier.
|
|
188
195
|
*
|
|
@@ -204,6 +211,34 @@ export declare const isPhoneNumberIdentifier: (identifier: CommunicationIdentifi
|
|
|
204
211
|
*/
|
|
205
212
|
export declare const isUnknownIdentifier: (identifier: CommunicationIdentifier) => identifier is UnknownIdentifier;
|
|
206
213
|
|
|
214
|
+
/**
|
|
215
|
+
* A Microsoft Teams App.
|
|
216
|
+
*/
|
|
217
|
+
export declare interface MicrosoftTeamsAppIdentifier {
|
|
218
|
+
/**
|
|
219
|
+
* Optional raw id of the Microsoft Teams App.
|
|
220
|
+
*/
|
|
221
|
+
rawId?: string;
|
|
222
|
+
/**
|
|
223
|
+
* The unique Microsoft Teams app ID.
|
|
224
|
+
*/
|
|
225
|
+
teamsAppId: string;
|
|
226
|
+
/**
|
|
227
|
+
* The cloud that the Microsoft Temas App belongs to. If missing, the cloud is "public".
|
|
228
|
+
*/
|
|
229
|
+
cloud?: "public" | "dod" | "gcch";
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* IdentifierKind for a MicrosoftTeamsAppIdentifier.
|
|
234
|
+
*/
|
|
235
|
+
export declare interface MicrosoftTeamsAppKind extends MicrosoftTeamsAppIdentifier {
|
|
236
|
+
/**
|
|
237
|
+
* The identifier kind.
|
|
238
|
+
*/
|
|
239
|
+
kind: "microsoftTeamsApp";
|
|
240
|
+
}
|
|
241
|
+
|
|
207
242
|
/**
|
|
208
243
|
* A Microsoft Teams user.
|
|
209
244
|
*/
|
|
@@ -313,6 +348,10 @@ export declare interface SerializedCommunicationIdentifier {
|
|
|
313
348
|
* The Microsoft Teams user.
|
|
314
349
|
*/
|
|
315
350
|
microsoftTeamsUser?: SerializedMicrosoftTeamsUserIdentifier;
|
|
351
|
+
/**
|
|
352
|
+
* The Microsoft Teams App.
|
|
353
|
+
*/
|
|
354
|
+
microsoftTeamsApp?: SerializedMicrosoftTeamsAppIdentifier;
|
|
316
355
|
}
|
|
317
356
|
|
|
318
357
|
/**
|
|
@@ -326,6 +365,21 @@ export declare interface SerializedCommunicationUserIdentifier {
|
|
|
326
365
|
id: string;
|
|
327
366
|
}
|
|
328
367
|
|
|
368
|
+
/**
|
|
369
|
+
* @hidden
|
|
370
|
+
* A Microsoft Teams App.
|
|
371
|
+
*/
|
|
372
|
+
export declare interface SerializedMicrosoftTeamsAppIdentifier {
|
|
373
|
+
/**
|
|
374
|
+
* Id of the Microsoft Teams App.
|
|
375
|
+
*/
|
|
376
|
+
teamsAppId: string;
|
|
377
|
+
/**
|
|
378
|
+
* The cloud that the Microsoft Teams App belongs to. By default 'public' if missing.
|
|
379
|
+
*/
|
|
380
|
+
cloud?: SerializedCommunicationCloudEnvironment;
|
|
381
|
+
}
|
|
382
|
+
|
|
329
383
|
/**
|
|
330
384
|
* @hidden
|
|
331
385
|
* A Microsoft Teams user.
|