@azure/communication-common 2.2.1-alpha.20230310.1 → 3.0.0-alpha.20230327.5
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 +95 -23
- package/dist/index.js.map +1 -1
- package/dist-esm/src/credential/communicationAccessKeyCredentialPolicy.js +1 -1
- package/dist-esm/src/credential/communicationAccessKeyCredentialPolicy.js.map +1 -1
- package/dist-esm/src/identifierModelSerializer.js +26 -2
- package/dist-esm/src/identifierModelSerializer.js.map +1 -1
- package/dist-esm/src/identifierModels.js +67 -20
- package/dist-esm/src/identifierModels.js.map +1 -1
- package/package.json +3 -4
- package/types/communication-common.d.ts +64 -2
package/dist/index.js
CHANGED
|
@@ -205,7 +205,7 @@ function createCommunicationAccessKeyCredentialPolicy(credential) {
|
|
|
205
205
|
const dateHeader = "x-ms-date";
|
|
206
206
|
const signedHeaders = `${dateHeader};host;x-ms-content-sha256`;
|
|
207
207
|
const url = new URL(request.url);
|
|
208
|
-
const query = url.searchParams;
|
|
208
|
+
const query = url.searchParams.toString();
|
|
209
209
|
const urlPathAndQuery = query ? `${url.pathname}?${query}` : url.pathname;
|
|
210
210
|
const port = url.port;
|
|
211
211
|
const hostAndPort = port ? `${url.host}:${port}` : url.host;
|
|
@@ -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 MicrosoftBotIdentifier.
|
|
342
|
+
*
|
|
343
|
+
* @param identifier - The assumed available to be tested.
|
|
344
|
+
*/
|
|
345
|
+
const isMicrosoftBotIdentifier = (identifier) => {
|
|
346
|
+
return typeof identifier.botId === "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 (isMicrosoftBotIdentifier(identifier)) {
|
|
372
|
+
return Object.assign(Object.assign({}, identifier), { kind: "microsoftBot" });
|
|
373
|
+
}
|
|
363
374
|
return Object.assign(Object.assign({}, identifier), { kind: "unknown" });
|
|
364
375
|
};
|
|
365
376
|
/**
|
|
@@ -388,6 +399,27 @@ const getIdentifierRawId = (identifier) => {
|
|
|
388
399
|
}
|
|
389
400
|
return `8:orgid:${microsoftTeamsUserId}`;
|
|
390
401
|
}
|
|
402
|
+
case "microsoftBot": {
|
|
403
|
+
const { botId, rawId, cloud, isResourceAccountConfigured } = identifierKind;
|
|
404
|
+
if (rawId)
|
|
405
|
+
return rawId;
|
|
406
|
+
if (!isResourceAccountConfigured) {
|
|
407
|
+
switch (cloud) {
|
|
408
|
+
case "dod":
|
|
409
|
+
return `28:dod-global:${botId}`;
|
|
410
|
+
case "gcch":
|
|
411
|
+
return `28:gcch-global:${botId}`;
|
|
412
|
+
}
|
|
413
|
+
return `28:${botId}`;
|
|
414
|
+
}
|
|
415
|
+
switch (cloud) {
|
|
416
|
+
case "dod":
|
|
417
|
+
return `28:dod:${botId}`;
|
|
418
|
+
case "gcch":
|
|
419
|
+
return `28:gcch:${botId}`;
|
|
420
|
+
}
|
|
421
|
+
return `28:orgid:${botId}`;
|
|
422
|
+
}
|
|
391
423
|
case "phoneNumber": {
|
|
392
424
|
const { phoneNumber, rawId } = identifierKind;
|
|
393
425
|
if (rawId)
|
|
@@ -399,6 +431,22 @@ const getIdentifierRawId = (identifier) => {
|
|
|
399
431
|
}
|
|
400
432
|
}
|
|
401
433
|
};
|
|
434
|
+
const buildMicrosoftBotIdentifier = (id, cloud, isResourceAccountConfigured) => {
|
|
435
|
+
return {
|
|
436
|
+
kind: "microsoftBot",
|
|
437
|
+
botId: id,
|
|
438
|
+
cloud: cloud,
|
|
439
|
+
isResourceAccountConfigured: isResourceAccountConfigured,
|
|
440
|
+
};
|
|
441
|
+
};
|
|
442
|
+
const buildMicrosoftTeamsUserIdentifier = (id, cloud, isAnonymous) => {
|
|
443
|
+
return {
|
|
444
|
+
kind: "microsoftTeamsUser",
|
|
445
|
+
microsoftTeamsUserId: id,
|
|
446
|
+
isAnonymous: isAnonymous,
|
|
447
|
+
cloud: cloud,
|
|
448
|
+
};
|
|
449
|
+
};
|
|
402
450
|
/**
|
|
403
451
|
* Creates a CommunicationIdentifierKind from a given rawId. When storing rawIds use this function to restore the identifier that was encoded in the rawId.
|
|
404
452
|
*
|
|
@@ -409,39 +457,38 @@ const createIdentifierFromRawId = (rawId) => {
|
|
|
409
457
|
return { kind: "phoneNumber", phoneNumber: `${rawId.substring("4:".length)}` };
|
|
410
458
|
}
|
|
411
459
|
const segments = rawId.split(":");
|
|
412
|
-
if (segments.length
|
|
460
|
+
if (segments.length !== 3) {
|
|
461
|
+
if (segments.length === 2 && segments[0] === "28") {
|
|
462
|
+
return buildMicrosoftBotIdentifier(segments[1], "public", false);
|
|
463
|
+
}
|
|
413
464
|
return { kind: "unknown", id: rawId };
|
|
465
|
+
}
|
|
414
466
|
const prefix = `${segments[0]}:${segments[1]}:`;
|
|
415
|
-
const suffix =
|
|
467
|
+
const suffix = segments[2];
|
|
416
468
|
switch (prefix) {
|
|
417
469
|
case "8:teamsvisitor:":
|
|
418
470
|
return { kind: "microsoftTeamsUser", microsoftTeamsUserId: suffix, isAnonymous: true };
|
|
419
471
|
case "8:orgid:":
|
|
420
|
-
return
|
|
421
|
-
kind: "microsoftTeamsUser",
|
|
422
|
-
microsoftTeamsUserId: suffix,
|
|
423
|
-
isAnonymous: false,
|
|
424
|
-
cloud: "public",
|
|
425
|
-
};
|
|
472
|
+
return buildMicrosoftTeamsUserIdentifier(suffix, "public", false);
|
|
426
473
|
case "8:dod:":
|
|
427
|
-
return
|
|
428
|
-
kind: "microsoftTeamsUser",
|
|
429
|
-
microsoftTeamsUserId: suffix,
|
|
430
|
-
isAnonymous: false,
|
|
431
|
-
cloud: "dod",
|
|
432
|
-
};
|
|
474
|
+
return buildMicrosoftTeamsUserIdentifier(suffix, "dod", false);
|
|
433
475
|
case "8:gcch:":
|
|
434
|
-
return
|
|
435
|
-
kind: "microsoftTeamsUser",
|
|
436
|
-
microsoftTeamsUserId: suffix,
|
|
437
|
-
isAnonymous: false,
|
|
438
|
-
cloud: "gcch",
|
|
439
|
-
};
|
|
476
|
+
return buildMicrosoftTeamsUserIdentifier(suffix, "gcch", false);
|
|
440
477
|
case "8:acs:":
|
|
441
478
|
case "8:spool:":
|
|
442
479
|
case "8:dod-acs:":
|
|
443
480
|
case "8:gcch-acs:":
|
|
444
481
|
return { kind: "communicationUser", communicationUserId: rawId };
|
|
482
|
+
case "28:gcch-global:":
|
|
483
|
+
return buildMicrosoftBotIdentifier(suffix, "gcch", false);
|
|
484
|
+
case "28:orgid:":
|
|
485
|
+
return buildMicrosoftBotIdentifier(suffix, "public", true);
|
|
486
|
+
case "28:dod-global:":
|
|
487
|
+
return buildMicrosoftBotIdentifier(suffix, "dod", false);
|
|
488
|
+
case "28:gcch:":
|
|
489
|
+
return buildMicrosoftBotIdentifier(suffix, "gcch", true);
|
|
490
|
+
case "28:dod:":
|
|
491
|
+
return buildMicrosoftBotIdentifier(suffix, "dod", true);
|
|
445
492
|
}
|
|
446
493
|
return { kind: "unknown", id: rawId };
|
|
447
494
|
};
|
|
@@ -463,6 +510,9 @@ const assertMaximumOneNestedModel = (identifier) => {
|
|
|
463
510
|
if (identifier.microsoftTeamsUser !== undefined) {
|
|
464
511
|
presentProperties.push("microsoftTeamsUser");
|
|
465
512
|
}
|
|
513
|
+
if (identifier.microsoftBot !== undefined) {
|
|
514
|
+
presentProperties.push("microsoftBot");
|
|
515
|
+
}
|
|
466
516
|
if (identifier.phoneNumber !== undefined) {
|
|
467
517
|
presentProperties.push("phoneNumber");
|
|
468
518
|
}
|
|
@@ -476,7 +526,7 @@ const assertMaximumOneNestedModel = (identifier) => {
|
|
|
476
526
|
* @param identifier - The CommunicationIdentifier to be serialized.
|
|
477
527
|
*/
|
|
478
528
|
const serializeCommunicationIdentifier = (identifier) => {
|
|
479
|
-
var _a, _b, _c, _d;
|
|
529
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
480
530
|
const identifierKind = getIdentifierKind(identifier);
|
|
481
531
|
switch (identifierKind.kind) {
|
|
482
532
|
case "communicationUser":
|
|
@@ -500,6 +550,15 @@ const serializeCommunicationIdentifier = (identifier) => {
|
|
|
500
550
|
cloud: (_d = identifierKind.cloud) !== null && _d !== void 0 ? _d : "public",
|
|
501
551
|
},
|
|
502
552
|
};
|
|
553
|
+
case "microsoftBot":
|
|
554
|
+
return {
|
|
555
|
+
rawId: (_e = identifierKind.rawId) !== null && _e !== void 0 ? _e : getIdentifierRawId(identifierKind),
|
|
556
|
+
microsoftBot: {
|
|
557
|
+
botId: identifierKind.botId,
|
|
558
|
+
isResourceAccountConfigured: (_f = identifierKind.isResourceAccountConfigured) !== null && _f !== void 0 ? _f : true,
|
|
559
|
+
cloud: (_g = identifierKind.cloud) !== null && _g !== void 0 ? _g : "public",
|
|
560
|
+
},
|
|
561
|
+
};
|
|
503
562
|
case "unknown":
|
|
504
563
|
return { rawId: identifierKind.id };
|
|
505
564
|
default:
|
|
@@ -516,6 +575,9 @@ const getKind = (serializedIdentifier) => {
|
|
|
516
575
|
if (serializedIdentifier.microsoftTeamsUser) {
|
|
517
576
|
return "microsoftTeamsUser";
|
|
518
577
|
}
|
|
578
|
+
if (serializedIdentifier.microsoftBot) {
|
|
579
|
+
return "microsoftBot";
|
|
580
|
+
}
|
|
519
581
|
return "unknown";
|
|
520
582
|
};
|
|
521
583
|
/**
|
|
@@ -526,7 +588,7 @@ const getKind = (serializedIdentifier) => {
|
|
|
526
588
|
const deserializeCommunicationIdentifier = (serializedIdentifier) => {
|
|
527
589
|
var _a;
|
|
528
590
|
assertMaximumOneNestedModel(serializedIdentifier);
|
|
529
|
-
const { communicationUser, microsoftTeamsUser, phoneNumber } = serializedIdentifier;
|
|
591
|
+
const { communicationUser, microsoftTeamsUser, microsoftBot, phoneNumber } = serializedIdentifier;
|
|
530
592
|
const kind = (_a = serializedIdentifier.kind) !== null && _a !== void 0 ? _a : getKind(serializedIdentifier);
|
|
531
593
|
if (kind === "communicationUser" && communicationUser) {
|
|
532
594
|
return {
|
|
@@ -550,6 +612,15 @@ const deserializeCommunicationIdentifier = (serializedIdentifier) => {
|
|
|
550
612
|
rawId: assertNotNullOrUndefined({ microsoftTeamsUser: serializedIdentifier }, "rawId"),
|
|
551
613
|
};
|
|
552
614
|
}
|
|
615
|
+
if (kind === "microsoftBot" && microsoftBot) {
|
|
616
|
+
return {
|
|
617
|
+
kind: "microsoftBot",
|
|
618
|
+
botId: assertNotNullOrUndefined({ microsoftBot }, "botId"),
|
|
619
|
+
isResourceAccountConfigured: assertNotNullOrUndefined({ microsoftBot }, "isResourceAccountConfigured"),
|
|
620
|
+
cloud: assertNotNullOrUndefined({ microsoftBot }, "cloud"),
|
|
621
|
+
rawId: assertNotNullOrUndefined({ microsoftBot: serializedIdentifier }, "rawId"),
|
|
622
|
+
};
|
|
623
|
+
}
|
|
553
624
|
return {
|
|
554
625
|
kind: "unknown",
|
|
555
626
|
id: assertNotNullOrUndefined({ unknown: serializedIdentifier }, "rawId"),
|
|
@@ -565,6 +636,7 @@ exports.getIdentifierKind = getIdentifierKind;
|
|
|
565
636
|
exports.getIdentifierRawId = getIdentifierRawId;
|
|
566
637
|
exports.isCommunicationUserIdentifier = isCommunicationUserIdentifier;
|
|
567
638
|
exports.isKeyCredential = isKeyCredential;
|
|
639
|
+
exports.isMicrosoftBotIdentifier = isMicrosoftBotIdentifier;
|
|
568
640
|
exports.isMicrosoftTeamsUserIdentifier = isMicrosoftTeamsUserIdentifier;
|
|
569
641
|
exports.isPhoneNumberIdentifier = isPhoneNumberIdentifier;
|
|
570
642
|
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;\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":["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;K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O;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 | MicrosoftBotIdentifier\n | UnknownIdentifier;\n\n/**\n * An Azure Communication user.\n */\nexport interface CommunicationUserIdentifier {\n /**\n * Id of the CommunicationUser as returned from the Communication Service.\n */\n communicationUserId: string;\n}\n\n/**\n * A phone number.\n */\nexport interface PhoneNumberIdentifier {\n /**\n * Optional raw id of the phone number.\n */\n rawId?: string;\n /**\n * The phone number in E.164 format.\n */\n phoneNumber: string;\n}\n\n/**\n * A Microsoft Teams user.\n */\nexport interface MicrosoftTeamsUserIdentifier {\n /**\n * Optional raw id of the Microsoft Teams user.\n */\n rawId?: string;\n\n /**\n * Id of the Microsoft Teams user. If the user isn't anonymous, the id is the AAD object id of the user.\n */\n microsoftTeamsUserId: string;\n\n /**\n * True if the user is anonymous, for example when joining a meeting with a share link. If missing, the user is not anonymous.\n */\n isAnonymous?: boolean;\n\n /**\n * The cloud that the Microsoft Teams user belongs to. If missing, the cloud is \"public\".\n */\n cloud?: \"public\" | \"dod\" | \"gcch\";\n}\n\n/**\n * A Microsoft bot.\n */\nexport interface MicrosoftBotIdentifier {\n /**\n * Optional raw id of the Microsoft bot.\n */\n rawId?: string;\n\n /**\n * The unique Microsoft app ID for the bot as registered with the Bot Framework.\n */\n botId: string;\n\n /**\n * True (or missing) if the bot is global and no resource account is configured and false if the bot is tenantized.\n */\n isResourceAccountConfigured?: boolean;\n\n /**\n * The cloud that the Microsoft bot belongs to. If missing, the cloud is \"public\".\n */\n cloud?: \"public\" | \"dod\" | \"gcch\";\n}\n\n/**\n * An unknown identifier that doesn't fit any of the other identifier types.\n */\nexport interface UnknownIdentifier {\n /**\n * Id of the UnknownIdentifier.\n */\n id: string;\n}\n\n/**\n * Tests an Identifier to determine whether it implements CommunicationUserIdentifier.\n *\n * @param identifier - The assumed CommunicationUserIdentifier to be tested.\n */\nexport const isCommunicationUserIdentifier = (\n identifier: CommunicationIdentifier\n): identifier is CommunicationUserIdentifier => {\n return typeof (identifier as any).communicationUserId === \"string\";\n};\n\n/**\n * Tests an Identifier to determine whether it implements PhoneNumberIdentifier.\n *\n * @param identifier - The assumed PhoneNumberIdentifier to be tested.\n */\nexport const isPhoneNumberIdentifier = (\n identifier: CommunicationIdentifier\n): identifier is PhoneNumberIdentifier => {\n return typeof (identifier as any).phoneNumber === \"string\";\n};\n\n/**\n * Tests an Identifier to determine whether it implements MicrosoftTeamsUserIdentifier.\n *\n * @param identifier - The assumed available to be tested.\n */\nexport const isMicrosoftTeamsUserIdentifier = (\n identifier: CommunicationIdentifier\n): identifier is MicrosoftTeamsUserIdentifier => {\n return typeof (identifier as any).microsoftTeamsUserId === \"string\";\n};\n\n/**\n * Tests an Identifier to determine whether it implements MicrosoftBotIdentifier.\n *\n * @param identifier - The assumed available to be tested.\n */\nexport const isMicrosoftBotIdentifier = (\n identifier: CommunicationIdentifier\n): identifier is MicrosoftBotIdentifier => {\n return typeof (identifier as any).botId === \"string\";\n};\n\n/**\n * Tests an Identifier to determine whether it implements UnknownIdentifier.\n *\n * @param identifier - The assumed UnknownIdentifier to be tested.\n */\nexport const isUnknownIdentifier = (\n identifier: CommunicationIdentifier\n): identifier is UnknownIdentifier => {\n return typeof (identifier as any).id === \"string\";\n};\n\n/**\n * The CommunicationIdentifierKind is a discriminated union that adds a property `kind` to an Identifier.\n */\nexport type CommunicationIdentifierKind =\n | CommunicationUserKind\n | PhoneNumberKind\n | MicrosoftTeamsUserKind\n | MicrosoftBotKind\n | UnknownIdentifierKind;\n\n/**\n * IdentifierKind for a CommunicationUserIdentifier.\n */\nexport interface CommunicationUserKind extends CommunicationUserIdentifier {\n /**\n * The identifier kind.\n */\n kind: \"communicationUser\";\n}\n\n/**\n * IdentifierKind for a PhoneNumberIdentifier.\n */\nexport interface PhoneNumberKind extends PhoneNumberIdentifier {\n /**\n * The identifier kind.\n */\n kind: \"phoneNumber\";\n}\n\n/**\n * IdentifierKind for a MicrosoftTeamsUserIdentifier.\n */\nexport interface MicrosoftTeamsUserKind extends MicrosoftTeamsUserIdentifier {\n /**\n * The identifier kind.\n */\n kind: \"microsoftTeamsUser\";\n}\n\n/**\n * IdentifierKind for a MicrosoftBotIdentifier.\n */\nexport interface MicrosoftBotKind extends MicrosoftBotIdentifier {\n /**\n * The identifier kind.\n */\n kind: \"microsoftBot\";\n}\n\n/**\n * IdentifierKind for UnknownIdentifier.\n */\nexport interface UnknownIdentifierKind extends UnknownIdentifier {\n /**\n * The identifier kind.\n */\n kind: \"unknown\";\n}\n\n/**\n * Returns the CommunicationIdentifierKind for a given CommunicationIdentifier. Returns undefined if the kind couldn't be inferred.\n *\n * @param identifier - The identifier whose kind is to be inferred.\n */\nexport const getIdentifierKind = (\n identifier: CommunicationIdentifier\n): CommunicationIdentifierKind => {\n if (isCommunicationUserIdentifier(identifier)) {\n return { ...identifier, kind: \"communicationUser\" };\n }\n if (isPhoneNumberIdentifier(identifier)) {\n return { ...identifier, kind: \"phoneNumber\" };\n }\n if (isMicrosoftTeamsUserIdentifier(identifier)) {\n return { ...identifier, kind: \"microsoftTeamsUser\" };\n }\n if (isMicrosoftBotIdentifier(identifier)) {\n return { ...identifier, kind: \"microsoftBot\" };\n }\n return { ...identifier, kind: \"unknown\" };\n};\n\n/**\n * Returns the rawId for a given CommunicationIdentifier. You can use the rawId for encoding the identifier and then use it as a key in a database.\n *\n * @param identifier - The identifier to be translated to its rawId.\n */\nexport const getIdentifierRawId = (identifier: CommunicationIdentifier): string => {\n const identifierKind = getIdentifierKind(identifier);\n switch (identifierKind.kind) {\n case \"communicationUser\":\n return identifierKind.communicationUserId;\n case \"microsoftTeamsUser\": {\n const { microsoftTeamsUserId, rawId, cloud, isAnonymous } = identifierKind;\n if (rawId) return rawId;\n if (isAnonymous) return `8:teamsvisitor:${microsoftTeamsUserId}`;\n switch (cloud) {\n case \"dod\":\n return `8:dod:${microsoftTeamsUserId}`;\n case \"gcch\":\n return `8:gcch:${microsoftTeamsUserId}`;\n case \"public\":\n return `8:orgid:${microsoftTeamsUserId}`;\n }\n return `8:orgid:${microsoftTeamsUserId}`;\n }\n case \"microsoftBot\": {\n const { botId, rawId, cloud, isResourceAccountConfigured } = identifierKind;\n if (rawId) return rawId;\n if (!isResourceAccountConfigured) {\n switch (cloud) {\n case \"dod\":\n return `28:dod-global:${botId}`;\n case \"gcch\":\n return `28:gcch-global:${botId}`;\n }\n return `28:${botId}`;\n }\n switch (cloud) {\n case \"dod\":\n return `28:dod:${botId}`;\n case \"gcch\":\n return `28:gcch:${botId}`;\n }\n return `28:orgid:${botId}`;\n }\n case \"phoneNumber\": {\n const { phoneNumber, rawId } = identifierKind;\n if (rawId) return rawId;\n return `4:${phoneNumber}`;\n }\n case \"unknown\": {\n return identifierKind.id;\n }\n }\n};\n\nconst buildMicrosoftBotIdentifier = (\n id: string,\n cloud: \"public\" | \"dod\" | \"gcch\",\n isResourceAccountConfigured: boolean\n): CommunicationIdentifierKind => {\n return {\n kind: \"microsoftBot\",\n botId: id,\n cloud: cloud,\n isResourceAccountConfigured: isResourceAccountConfigured,\n };\n};\n\nconst buildMicrosoftTeamsUserIdentifier = (\n id: string,\n cloud: \"public\" | \"dod\" | \"gcch\",\n isAnonymous: boolean\n): CommunicationIdentifierKind => {\n return {\n kind: \"microsoftTeamsUser\",\n microsoftTeamsUserId: id,\n isAnonymous: isAnonymous,\n cloud: cloud,\n };\n};\n\n/**\n * Creates a CommunicationIdentifierKind from a given rawId. When storing rawIds use this function to restore the identifier that was encoded in the rawId.\n *\n * @param rawId - The rawId to be translated to its identifier representation.\n */\nexport const createIdentifierFromRawId = (rawId: string): CommunicationIdentifierKind => {\n if (rawId.startsWith(\"4:\")) {\n return { kind: \"phoneNumber\", phoneNumber: `${rawId.substring(\"4:\".length)}` };\n }\n\n const segments = rawId.split(\":\");\n if (segments.length !== 3) {\n if (segments.length === 2 && segments[0] === \"28\") {\n return buildMicrosoftBotIdentifier(segments[1], \"public\", false);\n }\n return { kind: \"unknown\", id: rawId };\n }\n\n const prefix = `${segments[0]}:${segments[1]}:`;\n const suffix = segments[2];\n\n switch (prefix) {\n case \"8:teamsvisitor:\":\n return { kind: \"microsoftTeamsUser\", microsoftTeamsUserId: suffix, isAnonymous: true };\n case \"8:orgid:\":\n return buildMicrosoftTeamsUserIdentifier(suffix, \"public\", false);\n case \"8:dod:\":\n return buildMicrosoftTeamsUserIdentifier(suffix, \"dod\", false);\n case \"8:gcch:\":\n return buildMicrosoftTeamsUserIdentifier(suffix, \"gcch\", false);\n case \"8:acs:\":\n case \"8:spool:\":\n case \"8:dod-acs:\":\n case \"8:gcch-acs:\":\n return { kind: \"communicationUser\", communicationUserId: rawId };\n case \"28:gcch-global:\":\n return buildMicrosoftBotIdentifier(suffix, \"gcch\", false);\n case \"28:orgid:\":\n return buildMicrosoftBotIdentifier(suffix, \"public\", true);\n case \"28:dod-global:\":\n return buildMicrosoftBotIdentifier(suffix, \"dod\", false);\n case \"28:gcch:\":\n return buildMicrosoftBotIdentifier(suffix, \"gcch\", true);\n case \"28:dod:\":\n return buildMicrosoftBotIdentifier(suffix, \"dod\", true);\n }\n return { kind: \"unknown\", id: rawId };\n};\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n CommunicationIdentifier,\n CommunicationIdentifierKind,\n getIdentifierKind,\n getIdentifierRawId,\n} from \"./identifierModels\";\n\n/**\n * @hidden\n * Identifies a participant in Azure Communication services. A participant is, for example, a phone number or an Azure communication user. This model must be interpreted as a union: Apart from rawId, at most one further property may be set.\n */\nexport interface SerializedCommunicationIdentifier {\n /**\n * Kind of the identifier, optional.\n */\n kind?: string;\n /**\n * Raw Id of the identifier. Optional in requests, required in responses.\n */\n rawId?: string;\n /**\n * The communication user.\n */\n communicationUser?: SerializedCommunicationUserIdentifier;\n /**\n * The phone number.\n */\n phoneNumber?: SerializedPhoneNumberIdentifier;\n /**\n * The Microsoft Teams user.\n */\n microsoftTeamsUser?: SerializedMicrosoftTeamsUserIdentifier;\n /**\n * The Microsoft bot.\n */\n microsoftBot?: SerializedMicrosoftBotIdentifier;\n}\n\n/**\n * @hidden\n * A user that got created with an Azure Communication Services resource.\n */\nexport interface SerializedCommunicationUserIdentifier {\n /**\n * The Id of the communication user.\n */\n id: string;\n}\n\n/**\n * @hidden\n * A phone number.\n */\nexport interface SerializedPhoneNumberIdentifier {\n /**\n * The phone number in E.164 format.\n */\n value: string;\n}\n\n/**\n * @hidden\n * A Microsoft Teams user.\n */\nexport interface SerializedMicrosoftTeamsUserIdentifier {\n /**\n * The Id of the Microsoft Teams user. If not anonymous, this is the AAD object Id of the user.\n */\n userId: string;\n /**\n * True if the Microsoft Teams user is anonymous. By default false if missing.\n */\n isAnonymous?: boolean;\n /**\n * The cloud that the Microsoft Teams user belongs to. By default 'public' if missing.\n */\n cloud?: SerializedCommunicationCloudEnvironment;\n}\n\n/**\n * @hidden\n * A Microsoft bot.\n */\nexport interface SerializedMicrosoftBotIdentifier {\n /**\n * Id of the Microsoft bot.\n */\n botId: string;\n /**\n * True (or missing) if the bot is global and no resource account is configured and false if the bot is tenantized.\n */\n isResourceAccountConfigured?: boolean;\n /**\n * The cloud that the Microsoft bot belongs to. By default 'public' if missing.\n */\n cloud?: SerializedCommunicationCloudEnvironment;\n}\n\n/**\n * @hidden\n * Defines values for CommunicationCloudEnvironmentModel.\n */\nexport type SerializedCommunicationCloudEnvironment = \"public\" | \"dod\" | \"gcch\";\n\nconst assertNotNullOrUndefined = <\n T extends Record<string, unknown>,\n P extends keyof T,\n Q extends string & keyof T[P]\n>(\n obj: T,\n prop: Q\n): Required<Required<T>[P]>[Q] => {\n const subObjName = Object.keys(obj)[0];\n const subObj = (obj as any)[subObjName];\n if (prop in subObj) {\n return subObj[prop];\n }\n throw new Error(`Property ${prop} is required for identifier of type ${subObjName}.`);\n};\n\nconst assertMaximumOneNestedModel = (identifier: SerializedCommunicationIdentifier): void => {\n const presentProperties: string[] = [];\n if (identifier.communicationUser !== undefined) {\n presentProperties.push(\"communicationUser\");\n }\n if (identifier.microsoftTeamsUser !== undefined) {\n presentProperties.push(\"microsoftTeamsUser\");\n }\n if (identifier.microsoftBot !== undefined) {\n presentProperties.push(\"microsoftBot\");\n }\n if (identifier.phoneNumber !== undefined) {\n presentProperties.push(\"phoneNumber\");\n }\n if (presentProperties.length > 1) {\n throw new Error(\n `Only one of the properties in ${JSON.stringify(presentProperties)} should be present.`\n );\n }\n};\n\n/**\n * @hidden\n * Translates a CommunicationIdentifier to its serialized format for sending a request.\n * @param identifier - The CommunicationIdentifier to be serialized.\n */\nexport const serializeCommunicationIdentifier = (\n identifier: CommunicationIdentifier\n): SerializedCommunicationIdentifier => {\n const identifierKind = getIdentifierKind(identifier);\n switch (identifierKind.kind) {\n case \"communicationUser\":\n return {\n rawId: getIdentifierRawId(identifierKind),\n communicationUser: { id: identifierKind.communicationUserId },\n };\n case \"phoneNumber\":\n return {\n rawId: identifierKind.rawId ?? getIdentifierRawId(identifierKind),\n phoneNumber: {\n value: identifierKind.phoneNumber,\n },\n };\n case \"microsoftTeamsUser\":\n return {\n rawId: identifierKind.rawId ?? getIdentifierRawId(identifierKind),\n microsoftTeamsUser: {\n userId: identifierKind.microsoftTeamsUserId,\n isAnonymous: identifierKind.isAnonymous ?? false,\n cloud: identifierKind.cloud ?? \"public\",\n },\n };\n case \"microsoftBot\":\n return {\n rawId: identifierKind.rawId ?? getIdentifierRawId(identifierKind),\n microsoftBot: {\n botId: identifierKind.botId,\n isResourceAccountConfigured: identifierKind.isResourceAccountConfigured ?? true,\n cloud: identifierKind.cloud ?? \"public\",\n },\n };\n case \"unknown\":\n return { rawId: identifierKind.id };\n default:\n throw new Error(`Can't serialize an identifier with kind ${(identifierKind as any).kind}`);\n }\n};\n\nconst getKind = (serializedIdentifier: SerializedCommunicationIdentifier): string => {\n if (serializedIdentifier.communicationUser) {\n return \"communicationUser\";\n }\n\n if (serializedIdentifier.phoneNumber) {\n return \"phoneNumber\";\n }\n\n if (serializedIdentifier.microsoftTeamsUser) {\n return \"microsoftTeamsUser\";\n }\n\n if (serializedIdentifier.microsoftBot) {\n return \"microsoftBot\";\n }\n\n return \"unknown\";\n};\n\n/**\n * @hidden\n * Translates the serialized format of a communication identifier to CommunicationIdentifier.\n * @param serializedIdentifier - The SerializedCommunicationIdentifier to be deserialized.\n */\nexport const deserializeCommunicationIdentifier = (\n serializedIdentifier: SerializedCommunicationIdentifier\n): CommunicationIdentifierKind => {\n assertMaximumOneNestedModel(serializedIdentifier);\n\n const { communicationUser, microsoftTeamsUser, microsoftBot, phoneNumber } = serializedIdentifier;\n const kind = serializedIdentifier.kind ?? getKind(serializedIdentifier);\n\n if (kind === \"communicationUser\" && communicationUser) {\n return {\n kind: \"communicationUser\",\n communicationUserId: assertNotNullOrUndefined({ communicationUser }, \"id\"),\n };\n }\n if (kind === \"phoneNumber\" && phoneNumber) {\n return {\n kind: \"phoneNumber\",\n phoneNumber: assertNotNullOrUndefined({ phoneNumber }, \"value\"),\n rawId: assertNotNullOrUndefined({ phoneNumber: serializedIdentifier }, \"rawId\"),\n };\n }\n if (kind === \"microsoftTeamsUser\" && microsoftTeamsUser) {\n return {\n kind: \"microsoftTeamsUser\",\n microsoftTeamsUserId: assertNotNullOrUndefined({ microsoftTeamsUser }, \"userId\"),\n isAnonymous: assertNotNullOrUndefined({ microsoftTeamsUser }, \"isAnonymous\"),\n cloud: assertNotNullOrUndefined({ microsoftTeamsUser }, \"cloud\"),\n rawId: assertNotNullOrUndefined({ microsoftTeamsUser: serializedIdentifier }, \"rawId\"),\n };\n }\n if (kind === \"microsoftBot\" && microsoftBot) {\n return {\n kind: \"microsoftBot\",\n botId: assertNotNullOrUndefined({ microsoftBot }, \"botId\"),\n isResourceAccountConfigured: assertNotNullOrUndefined(\n { microsoftBot },\n \"isResourceAccountConfigured\"\n ),\n cloud: assertNotNullOrUndefined({ microsoftBot }, \"cloud\"),\n rawId: assertNotNullOrUndefined({ microsoftBot: serializedIdentifier }, \"rawId\"),\n };\n }\n return {\n kind: \"unknown\",\n id: assertNotNullOrUndefined({ unknown: serializedIdentifier }, \"rawId\"),\n };\n};\n"],"names":["jwtDecode","createHash","createHmac","isNode","isTokenCredential","bearerTokenAuthenticationPolicy","AzureKeyCredential"],"mappings":";;;;;;;;;;;;;;AAAA;AAUO,MAAM,UAAU,GAAG,CAAC,KAAa,KAAiB;IACvD,MAAM,EAAE,GAAG,EAAE,GAAGA,6BAAS,CAAW,KAAK,CAAC,CAAC;IAC3C,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,Q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AAC;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,cAAc,IAAI,YAAY,EAAE;QAC3C,OAAO;AACL,YAAA,IAAI,EAAE,cAAc;YACpB,KAAK,EAAE,wBAAwB,CAAC,EAAE,YAAY,EAAE,EAAE,OAAO,CAAC;YAC1D,2BAA2B,EAAE,wBAAwB,CACnD,EAAE,YAAY,EAAE,EAChB,6BAA6B,CAC9B;YACD,KAAK,EAAE,wBAAwB,CAAC,EAAE,YAAY,EAAE,EAAE,OAAO,CAAC;YAC1D,KAAK,EAAE,wBAAwB,CAAC,EAAE,YAAY,EAAE,oBAAoB,EAAE,EAAE,OAAO,CAAC;SACjF,CAAC;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;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -24,7 +24,7 @@ export function createCommunicationAccessKeyCredentialPolicy(credential) {
|
|
|
24
24
|
const dateHeader = "x-ms-date";
|
|
25
25
|
const signedHeaders = `${dateHeader};host;x-ms-content-sha256`;
|
|
26
26
|
const url = new URL(request.url);
|
|
27
|
-
const query = url.searchParams;
|
|
27
|
+
const query = url.searchParams.toString();
|
|
28
28
|
const urlPathAndQuery = query ? `${url.pathname}?${query}` : url.pathname;
|
|
29
29
|
const port = url.port;
|
|
30
30
|
const hostAndPort = port ? `${url.host}:${port}` : url.host;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"communicationAccessKeyCredentialPolicy.js","sourceRoot":"","sources":["../../../src/credential/communicationAccessKeyCredentialPolicy.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAQlC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAEjD,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAE1C;;;GAGG;AACH,MAAM,sCAAsC,GAAG,wCAAwC,CAAC;AAExF;;;;;GAKG;AACH,MAAM,UAAU,4CAA4C,CAC1D,UAAyB;IAEzB,OAAO;QACL,IAAI,EAAE,sCAAsC;QAC5C,KAAK,CAAC,WAAW,CAAC,OAAwB,EAAE,IAAiB;;YAC3D,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC;YAC1C,MAAM,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;YACxC,MAAM,WAAW,GAAG,MAAM,OAAO,CAAC,CAAA,MAAA,OAAO,CAAC,IAAI,0CAAE,QAAQ,EAAE,KAAI,EAAE,CAAC,CAAC;YAClE,MAAM,UAAU,GAAG,WAAW,CAAC;YAC/B,MAAM,aAAa,GAAG,GAAG,UAAU,2BAA2B,CAAC;YAE/D,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;YACjC,MAAM,KAAK,GAAG,GAAG,CAAC,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"communicationAccessKeyCredentialPolicy.js","sourceRoot":"","sources":["../../../src/credential/communicationAccessKeyCredentialPolicy.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAQlC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAEjD,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAE1C;;;GAGG;AACH,MAAM,sCAAsC,GAAG,wCAAwC,CAAC;AAExF;;;;;GAKG;AACH,MAAM,UAAU,4CAA4C,CAC1D,UAAyB;IAEzB,OAAO;QACL,IAAI,EAAE,sCAAsC;QAC5C,KA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O,CAAC,GAAG,CAAC,qBAAqB,EAAE,WAAW,CAAC,CAAC;YACxD,OAAO,CAAC,OAAO,CAAC,GAAG,CACjB,eAAe,EACf,6BAA6B,aAAa,cAAc,SAAS,EAAE,CACpE,CAAC;YACF,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC;QACvB,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["// 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"]}
|
|
@@ -17,6 +17,9 @@ const assertMaximumOneNestedModel = (identifier) => {
|
|
|
17
17
|
if (identifier.microsoftTeamsUser !== undefined) {
|
|
18
18
|
presentProperties.push("microsoftTeamsUser");
|
|
19
19
|
}
|
|
20
|
+
if (identifier.microsoftBot !== undefined) {
|
|
21
|
+
presentProperties.push("microsoftBot");
|
|
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, _g;
|
|
34
37
|
const identifierKind = getIdentifierKind(identifier);
|
|
35
38
|
switch (identifierKind.kind) {
|
|
36
39
|
case "communicationUser":
|
|
@@ -54,6 +57,15 @@ export const serializeCommunicationIdentifier = (identifier) => {
|
|
|
54
57
|
cloud: (_d = identifierKind.cloud) !== null && _d !== void 0 ? _d : "public",
|
|
55
58
|
},
|
|
56
59
|
};
|
|
60
|
+
case "microsoftBot":
|
|
61
|
+
return {
|
|
62
|
+
rawId: (_e = identifierKind.rawId) !== null && _e !== void 0 ? _e : getIdentifierRawId(identifierKind),
|
|
63
|
+
microsoftBot: {
|
|
64
|
+
botId: identifierKind.botId,
|
|
65
|
+
isResourceAccountConfigured: (_f = identifierKind.isResourceAccountConfigured) !== null && _f !== void 0 ? _f : true,
|
|
66
|
+
cloud: (_g = identifierKind.cloud) !== null && _g !== void 0 ? _g : "public",
|
|
67
|
+
},
|
|
68
|
+
};
|
|
57
69
|
case "unknown":
|
|
58
70
|
return { rawId: identifierKind.id };
|
|
59
71
|
default:
|
|
@@ -70,6 +82,9 @@ const getKind = (serializedIdentifier) => {
|
|
|
70
82
|
if (serializedIdentifier.microsoftTeamsUser) {
|
|
71
83
|
return "microsoftTeamsUser";
|
|
72
84
|
}
|
|
85
|
+
if (serializedIdentifier.microsoftBot) {
|
|
86
|
+
return "microsoftBot";
|
|
87
|
+
}
|
|
73
88
|
return "unknown";
|
|
74
89
|
};
|
|
75
90
|
/**
|
|
@@ -80,7 +95,7 @@ const getKind = (serializedIdentifier) => {
|
|
|
80
95
|
export const deserializeCommunicationIdentifier = (serializedIdentifier) => {
|
|
81
96
|
var _a;
|
|
82
97
|
assertMaximumOneNestedModel(serializedIdentifier);
|
|
83
|
-
const { communicationUser, microsoftTeamsUser, phoneNumber } = serializedIdentifier;
|
|
98
|
+
const { communicationUser, microsoftTeamsUser, microsoftBot, phoneNumber } = serializedIdentifier;
|
|
84
99
|
const kind = (_a = serializedIdentifier.kind) !== null && _a !== void 0 ? _a : getKind(serializedIdentifier);
|
|
85
100
|
if (kind === "communicationUser" && communicationUser) {
|
|
86
101
|
return {
|
|
@@ -104,6 +119,15 @@ export const deserializeCommunicationIdentifier = (serializedIdentifier) => {
|
|
|
104
119
|
rawId: assertNotNullOrUndefined({ microsoftTeamsUser: serializedIdentifier }, "rawId"),
|
|
105
120
|
};
|
|
106
121
|
}
|
|
122
|
+
if (kind === "microsoftBot" && microsoftBot) {
|
|
123
|
+
return {
|
|
124
|
+
kind: "microsoftBot",
|
|
125
|
+
botId: assertNotNullOrUndefined({ microsoftBot }, "botId"),
|
|
126
|
+
isResourceAccountConfigured: assertNotNullOrUndefined({ microsoftBot }, "isResourceAccountConfigured"),
|
|
127
|
+
cloud: assertNotNullOrUndefined({ microsoftBot }, "cloud"),
|
|
128
|
+
rawId: assertNotNullOrUndefined({ microsoftBot: serializedIdentifier }, "rawId"),
|
|
129
|
+
};
|
|
130
|
+
}
|
|
107
131
|
return {
|
|
108
132
|
kind: "unknown",
|
|
109
133
|
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,CAAC,CAAC;IACvC,MAAM,MAAM,GAAI,GAAW,CAAC,UAAU,CAAC,CAAC;IACxC,IAAI,IAAI,IAAI,MAAM,EAAE;QAClB,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC;KACrB;IACD,MAAM,IAAI,KAAK,CAAC,YAAY,IAAI,uCAAuC,UAAU,GAAG,CAAC,CAAC;AACxF,CAAC,CAAC;AAEF,MAAM,2BAA2B,GAAG,CAAC,UAA6C,EAAQ,EAAE;IAC1F,MAAM,iBAAiB,GAAa,EAAE,CAAC;IACvC,IAAI,UAAU,CAAC,iBAAiB,KAAK,SAAS,EAAE;QAC9C,iBAAiB,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;KAC7C;IACD,IAAI,UAAU,CAAC,kBAAkB,KAAK,SAAS,EAAE;QAC/C,iBAAiB,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;KAC9C;IACD,IAAI,UAAU,CAAC,WAAW,KAAK,SAAS,EAAE;QACxC,iBAAiB,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;KACvC;IACD,IAAI,iBAAiB,CAAC,MAAM,GAAG,CAAC,EAAE;QAChC,MAAM,IAAI,KAAK,CACb,iCAAiC,IAAI,CAAC,SAAS,CAAC,iBAAiB,CAAC,qBAAqB,CACxF,CAAC;KACH;AACH,CAAC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,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,EA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AAC;YAChF,WAAW,EAAE,wBAAwB,CAAC,EAAE,kBAAkB,EAAE,EAAE,aAAa,CAAC;YAC5E,KAAK,EAAE,wBAAwB,CAAC,EAAE,kBAAkB,EAAE,EAAE,OAAO,CAAC;YAChE,KAAK,EAAE,wBAAwB,CAAC,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,EAAE,OAAO,CAAC;SACvF,CAAC;KACH;IACD,IAAI,IAAI,KAAK,cAAc,IAAI,YAAY,EAAE;QAC3C,OAAO;YACL,IAAI,EAAE,cAAc;YACpB,KAAK,EAAE,wBAAwB,CAAC,EAAE,YAAY,EAAE,EAAE,OAAO,CAAC;YAC1D,2BAA2B,EAAE,wBAAwB,CACnD,EAAE,YAAY,EAAE,EAChB,6BAA6B,CAC9B;YACD,KAAK,EAAE,wBAAwB,CAAC,EAAE,YAAY,EAAE,EAAE,OAAO,CAAC;YAC1D,KAAK,EAAE,wBAAwB,CAAC,EAAE,YAAY,EAAE,oBAAoB,EAAE,EAAE,OAAO,CAAC;SACjF,CAAC;KACH;IACD,OAAO;QACL,IAAI,EAAE,SAAS;QACf,EAAE,EAAE,wBAAwB,CAAC,EAAE,OAAO,EAAE,oBAAoB,EAAE,EAAE,OAAO,CAAC;KACzE,CAAC;AACJ,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n CommunicationIdentifier,\n CommunicationIdentifierKind,\n getIdentifierKind,\n getIdentifierRawId,\n} from \"./identifierModels\";\n\n/**\n * @hidden\n * Identifies a participant in Azure Communication services. A participant is, for example, a phone number or an Azure communication user. This model must be interpreted as a union: Apart from rawId, at most one further property may be set.\n */\nexport interface SerializedCommunicationIdentifier {\n /**\n * Kind of the identifier, optional.\n */\n kind?: string;\n /**\n * Raw Id of the identifier. Optional in requests, required in responses.\n */\n rawId?: string;\n /**\n * The communication user.\n */\n communicationUser?: SerializedCommunicationUserIdentifier;\n /**\n * The phone number.\n */\n phoneNumber?: SerializedPhoneNumberIdentifier;\n /**\n * The Microsoft Teams user.\n */\n microsoftTeamsUser?: SerializedMicrosoftTeamsUserIdentifier;\n /**\n * The Microsoft bot.\n */\n microsoftBot?: SerializedMicrosoftBotIdentifier;\n}\n\n/**\n * @hidden\n * A user that got created with an Azure Communication Services resource.\n */\nexport interface SerializedCommunicationUserIdentifier {\n /**\n * The Id of the communication user.\n */\n id: string;\n}\n\n/**\n * @hidden\n * A phone number.\n */\nexport interface SerializedPhoneNumberIdentifier {\n /**\n * The phone number in E.164 format.\n */\n value: string;\n}\n\n/**\n * @hidden\n * A Microsoft Teams user.\n */\nexport interface SerializedMicrosoftTeamsUserIdentifier {\n /**\n * The Id of the Microsoft Teams user. If not anonymous, this is the AAD object Id of the user.\n */\n userId: string;\n /**\n * True if the Microsoft Teams user is anonymous. By default false if missing.\n */\n isAnonymous?: boolean;\n /**\n * The cloud that the Microsoft Teams user belongs to. By default 'public' if missing.\n */\n cloud?: SerializedCommunicationCloudEnvironment;\n}\n\n/**\n * @hidden\n * A Microsoft bot.\n */\nexport interface SerializedMicrosoftBotIdentifier {\n /**\n * Id of the Microsoft bot.\n */\n botId: string;\n /**\n * True (or missing) if the bot is global and no resource account is configured and false if the bot is tenantized.\n */\n isResourceAccountConfigured?: boolean;\n /**\n * The cloud that the Microsoft bot belongs to. By default 'public' if missing.\n */\n cloud?: SerializedCommunicationCloudEnvironment;\n}\n\n/**\n * @hidden\n * Defines values for CommunicationCloudEnvironmentModel.\n */\nexport type SerializedCommunicationCloudEnvironment = \"public\" | \"dod\" | \"gcch\";\n\nconst assertNotNullOrUndefined = <\n T extends Record<string, unknown>,\n P extends keyof T,\n Q extends string & keyof T[P]\n>(\n obj: T,\n prop: Q\n): Required<Required<T>[P]>[Q] => {\n const subObjName = Object.keys(obj)[0];\n const subObj = (obj as any)[subObjName];\n if (prop in subObj) {\n return subObj[prop];\n }\n throw new Error(`Property ${prop} is required for identifier of type ${subObjName}.`);\n};\n\nconst assertMaximumOneNestedModel = (identifier: SerializedCommunicationIdentifier): void => {\n const presentProperties: string[] = [];\n if (identifier.communicationUser !== undefined) {\n presentProperties.push(\"communicationUser\");\n }\n if (identifier.microsoftTeamsUser !== undefined) {\n presentProperties.push(\"microsoftTeamsUser\");\n }\n if (identifier.microsoftBot !== undefined) {\n presentProperties.push(\"microsoftBot\");\n }\n if (identifier.phoneNumber !== undefined) {\n presentProperties.push(\"phoneNumber\");\n }\n if (presentProperties.length > 1) {\n throw new Error(\n `Only one of the properties in ${JSON.stringify(presentProperties)} should be present.`\n );\n }\n};\n\n/**\n * @hidden\n * Translates a CommunicationIdentifier to its serialized format for sending a request.\n * @param identifier - The CommunicationIdentifier to be serialized.\n */\nexport const serializeCommunicationIdentifier = (\n identifier: CommunicationIdentifier\n): SerializedCommunicationIdentifier => {\n const identifierKind = getIdentifierKind(identifier);\n switch (identifierKind.kind) {\n case \"communicationUser\":\n return {\n rawId: getIdentifierRawId(identifierKind),\n communicationUser: { id: identifierKind.communicationUserId },\n };\n case \"phoneNumber\":\n return {\n rawId: identifierKind.rawId ?? getIdentifierRawId(identifierKind),\n phoneNumber: {\n value: identifierKind.phoneNumber,\n },\n };\n case \"microsoftTeamsUser\":\n return {\n rawId: identifierKind.rawId ?? getIdentifierRawId(identifierKind),\n microsoftTeamsUser: {\n userId: identifierKind.microsoftTeamsUserId,\n isAnonymous: identifierKind.isAnonymous ?? false,\n cloud: identifierKind.cloud ?? \"public\",\n },\n };\n case \"microsoftBot\":\n return {\n rawId: identifierKind.rawId ?? getIdentifierRawId(identifierKind),\n microsoftBot: {\n botId: identifierKind.botId,\n isResourceAccountConfigured: identifierKind.isResourceAccountConfigured ?? true,\n cloud: identifierKind.cloud ?? \"public\",\n },\n };\n case \"unknown\":\n return { rawId: identifierKind.id };\n default:\n throw new Error(`Can't serialize an identifier with kind ${(identifierKind as any).kind}`);\n }\n};\n\nconst getKind = (serializedIdentifier: SerializedCommunicationIdentifier): string => {\n if (serializedIdentifier.communicationUser) {\n return \"communicationUser\";\n }\n\n if (serializedIdentifier.phoneNumber) {\n return \"phoneNumber\";\n }\n\n if (serializedIdentifier.microsoftTeamsUser) {\n return \"microsoftTeamsUser\";\n }\n\n if (serializedIdentifier.microsoftBot) {\n return \"microsoftBot\";\n }\n\n return \"unknown\";\n};\n\n/**\n * @hidden\n * Translates the serialized format of a communication identifier to CommunicationIdentifier.\n * @param serializedIdentifier - The SerializedCommunicationIdentifier to be deserialized.\n */\nexport const deserializeCommunicationIdentifier = (\n serializedIdentifier: SerializedCommunicationIdentifier\n): CommunicationIdentifierKind => {\n assertMaximumOneNestedModel(serializedIdentifier);\n\n const { communicationUser, microsoftTeamsUser, microsoftBot, phoneNumber } = serializedIdentifier;\n const kind = serializedIdentifier.kind ?? getKind(serializedIdentifier);\n\n if (kind === \"communicationUser\" && communicationUser) {\n return {\n kind: \"communicationUser\",\n communicationUserId: assertNotNullOrUndefined({ communicationUser }, \"id\"),\n };\n }\n if (kind === \"phoneNumber\" && phoneNumber) {\n return {\n kind: \"phoneNumber\",\n phoneNumber: assertNotNullOrUndefined({ phoneNumber }, \"value\"),\n rawId: assertNotNullOrUndefined({ phoneNumber: serializedIdentifier }, \"rawId\"),\n };\n }\n if (kind === \"microsoftTeamsUser\" && microsoftTeamsUser) {\n return {\n kind: \"microsoftTeamsUser\",\n microsoftTeamsUserId: assertNotNullOrUndefined({ microsoftTeamsUser }, \"userId\"),\n isAnonymous: assertNotNullOrUndefined({ microsoftTeamsUser }, \"isAnonymous\"),\n cloud: assertNotNullOrUndefined({ microsoftTeamsUser }, \"cloud\"),\n rawId: assertNotNullOrUndefined({ microsoftTeamsUser: serializedIdentifier }, \"rawId\"),\n };\n }\n if (kind === \"microsoftBot\" && microsoftBot) {\n return {\n kind: \"microsoftBot\",\n botId: assertNotNullOrUndefined({ microsoftBot }, \"botId\"),\n isResourceAccountConfigured: assertNotNullOrUndefined(\n { microsoftBot },\n \"isResourceAccountConfigured\"\n ),\n cloud: assertNotNullOrUndefined({ microsoftBot }, \"cloud\"),\n rawId: assertNotNullOrUndefined({ microsoftBot: serializedIdentifier }, \"rawId\"),\n };\n }\n return {\n kind: \"unknown\",\n id: assertNotNullOrUndefined({ unknown: serializedIdentifier }, \"rawId\"),\n };\n};\n"]}
|
|
@@ -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 MicrosoftBotIdentifier.
|
|
29
|
+
*
|
|
30
|
+
* @param identifier - The assumed available to be tested.
|
|
31
|
+
*/
|
|
32
|
+
export const isMicrosoftBotIdentifier = (identifier) => {
|
|
33
|
+
return typeof identifier.botId === "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 (isMicrosoftBotIdentifier(identifier)) {
|
|
59
|
+
return Object.assign(Object.assign({}, identifier), { kind: "microsoftBot" });
|
|
60
|
+
}
|
|
50
61
|
return Object.assign(Object.assign({}, identifier), { kind: "unknown" });
|
|
51
62
|
};
|
|
52
63
|
/**
|
|
@@ -75,6 +86,27 @@ export const getIdentifierRawId = (identifier) => {
|
|
|
75
86
|
}
|
|
76
87
|
return `8:orgid:${microsoftTeamsUserId}`;
|
|
77
88
|
}
|
|
89
|
+
case "microsoftBot": {
|
|
90
|
+
const { botId, rawId, cloud, isResourceAccountConfigured } = identifierKind;
|
|
91
|
+
if (rawId)
|
|
92
|
+
return rawId;
|
|
93
|
+
if (!isResourceAccountConfigured) {
|
|
94
|
+
switch (cloud) {
|
|
95
|
+
case "dod":
|
|
96
|
+
return `28:dod-global:${botId}`;
|
|
97
|
+
case "gcch":
|
|
98
|
+
return `28:gcch-global:${botId}`;
|
|
99
|
+
}
|
|
100
|
+
return `28:${botId}`;
|
|
101
|
+
}
|
|
102
|
+
switch (cloud) {
|
|
103
|
+
case "dod":
|
|
104
|
+
return `28:dod:${botId}`;
|
|
105
|
+
case "gcch":
|
|
106
|
+
return `28:gcch:${botId}`;
|
|
107
|
+
}
|
|
108
|
+
return `28:orgid:${botId}`;
|
|
109
|
+
}
|
|
78
110
|
case "phoneNumber": {
|
|
79
111
|
const { phoneNumber, rawId } = identifierKind;
|
|
80
112
|
if (rawId)
|
|
@@ -86,6 +118,22 @@ export const getIdentifierRawId = (identifier) => {
|
|
|
86
118
|
}
|
|
87
119
|
}
|
|
88
120
|
};
|
|
121
|
+
const buildMicrosoftBotIdentifier = (id, cloud, isResourceAccountConfigured) => {
|
|
122
|
+
return {
|
|
123
|
+
kind: "microsoftBot",
|
|
124
|
+
botId: id,
|
|
125
|
+
cloud: cloud,
|
|
126
|
+
isResourceAccountConfigured: isResourceAccountConfigured,
|
|
127
|
+
};
|
|
128
|
+
};
|
|
129
|
+
const buildMicrosoftTeamsUserIdentifier = (id, cloud, isAnonymous) => {
|
|
130
|
+
return {
|
|
131
|
+
kind: "microsoftTeamsUser",
|
|
132
|
+
microsoftTeamsUserId: id,
|
|
133
|
+
isAnonymous: isAnonymous,
|
|
134
|
+
cloud: cloud,
|
|
135
|
+
};
|
|
136
|
+
};
|
|
89
137
|
/**
|
|
90
138
|
* Creates a CommunicationIdentifierKind from a given rawId. When storing rawIds use this function to restore the identifier that was encoded in the rawId.
|
|
91
139
|
*
|
|
@@ -96,39 +144,38 @@ export const createIdentifierFromRawId = (rawId) => {
|
|
|
96
144
|
return { kind: "phoneNumber", phoneNumber: `${rawId.substring("4:".length)}` };
|
|
97
145
|
}
|
|
98
146
|
const segments = rawId.split(":");
|
|
99
|
-
if (segments.length
|
|
147
|
+
if (segments.length !== 3) {
|
|
148
|
+
if (segments.length === 2 && segments[0] === "28") {
|
|
149
|
+
return buildMicrosoftBotIdentifier(segments[1], "public", false);
|
|
150
|
+
}
|
|
100
151
|
return { kind: "unknown", id: rawId };
|
|
152
|
+
}
|
|
101
153
|
const prefix = `${segments[0]}:${segments[1]}:`;
|
|
102
|
-
const suffix =
|
|
154
|
+
const suffix = segments[2];
|
|
103
155
|
switch (prefix) {
|
|
104
156
|
case "8:teamsvisitor:":
|
|
105
157
|
return { kind: "microsoftTeamsUser", microsoftTeamsUserId: suffix, isAnonymous: true };
|
|
106
158
|
case "8:orgid:":
|
|
107
|
-
return
|
|
108
|
-
kind: "microsoftTeamsUser",
|
|
109
|
-
microsoftTeamsUserId: suffix,
|
|
110
|
-
isAnonymous: false,
|
|
111
|
-
cloud: "public",
|
|
112
|
-
};
|
|
159
|
+
return buildMicrosoftTeamsUserIdentifier(suffix, "public", false);
|
|
113
160
|
case "8:dod:":
|
|
114
|
-
return
|
|
115
|
-
kind: "microsoftTeamsUser",
|
|
116
|
-
microsoftTeamsUserId: suffix,
|
|
117
|
-
isAnonymous: false,
|
|
118
|
-
cloud: "dod",
|
|
119
|
-
};
|
|
161
|
+
return buildMicrosoftTeamsUserIdentifier(suffix, "dod", false);
|
|
120
162
|
case "8:gcch:":
|
|
121
|
-
return
|
|
122
|
-
kind: "microsoftTeamsUser",
|
|
123
|
-
microsoftTeamsUserId: suffix,
|
|
124
|
-
isAnonymous: false,
|
|
125
|
-
cloud: "gcch",
|
|
126
|
-
};
|
|
163
|
+
return buildMicrosoftTeamsUserIdentifier(suffix, "gcch", false);
|
|
127
164
|
case "8:acs:":
|
|
128
165
|
case "8:spool:":
|
|
129
166
|
case "8:dod-acs:":
|
|
130
167
|
case "8:gcch-acs:":
|
|
131
168
|
return { kind: "communicationUser", communicationUserId: rawId };
|
|
169
|
+
case "28:gcch-global:":
|
|
170
|
+
return buildMicrosoftBotIdentifier(suffix, "gcch", false);
|
|
171
|
+
case "28:orgid:":
|
|
172
|
+
return buildMicrosoftBotIdentifier(suffix, "public", true);
|
|
173
|
+
case "28:dod-global:":
|
|
174
|
+
return buildMicrosoftBotIdentifier(suffix, "dod", false);
|
|
175
|
+
case "28:gcch:":
|
|
176
|
+
return buildMicrosoftBotIdentifier(suffix, "gcch", true);
|
|
177
|
+
case "28:dod:":
|
|
178
|
+
return buildMicrosoftBotIdentifier(suffix, "dod", true);
|
|
132
179
|
}
|
|
133
180
|
return { kind: "unknown", id: rawId };
|
|
134
181
|
};
|
|
@@ -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,OAAQ,UAAkB,CAAC,EAAE,KAAK,QAAQ,CAAC;AACpD,CAAC,CAAC;AAmDF;;;;GAIG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAC/B,UAAmC,EACN,EAAE;IAC/B,IAAI,6BAA6B,CAAC,UAAU,CAAC,EAAE;QAC7C,uC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W,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;AAgGlC;;;;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,UA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AAG,QAAQ,CAAC,CAAC,CAAC,CAAC;IAE3B,QAAQ,MAAM,EAAE;QACd,KAAK,iBAAiB;YACpB,OAAO,EAAE,IAAI,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;QACzF,KAAK,UAAU;YACb,OAAO,iCAAiC,CAAC,MAAM,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC;QACpE,KAAK,QAAQ;YACX,OAAO,iCAAiC,CAAC,MAAM,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;QACjE,KAAK,SAAS;YACZ,OAAO,iCAAiC,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;QAClE,KAAK,QAAQ,CAAC;QACd,KAAK,UAAU,CAAC;QAChB,KAAK,YAAY,CAAC;QAClB,KAAK,aAAa;YAChB,OAAO,EAAE,IAAI,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,KAAK,EAAE,CAAC;QACnE,KAAK,iBAAiB;YACpB,OAAO,2BAA2B,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;QAC5D,KAAK,WAAW;YACd,OAAO,2BAA2B,CAAC,MAAM,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAC;QAC7D,KAAK,gBAAgB;YACnB,OAAO,2BAA2B,CAAC,MAAM,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;QAC3D,KAAK,UAAU;YACb,OAAO,2BAA2B,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;QAC3D,KAAK,SAAS;YACZ,OAAO,2BAA2B,CAAC,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;KAC3D;IACD,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC;AACxC,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n/**\n * Identifies a communication participant.\n */\nexport type CommunicationIdentifier =\n | CommunicationUserIdentifier\n | PhoneNumberIdentifier\n | MicrosoftTeamsUserIdentifier\n | MicrosoftBotIdentifier\n | UnknownIdentifier;\n\n/**\n * An Azure Communication user.\n */\nexport interface CommunicationUserIdentifier {\n /**\n * Id of the CommunicationUser as returned from the Communication Service.\n */\n communicationUserId: string;\n}\n\n/**\n * A phone number.\n */\nexport interface PhoneNumberIdentifier {\n /**\n * Optional raw id of the phone number.\n */\n rawId?: string;\n /**\n * The phone number in E.164 format.\n */\n phoneNumber: string;\n}\n\n/**\n * A Microsoft Teams user.\n */\nexport interface MicrosoftTeamsUserIdentifier {\n /**\n * Optional raw id of the Microsoft Teams user.\n */\n rawId?: string;\n\n /**\n * Id of the Microsoft Teams user. If the user isn't anonymous, the id is the AAD object id of the user.\n */\n microsoftTeamsUserId: string;\n\n /**\n * True if the user is anonymous, for example when joining a meeting with a share link. If missing, the user is not anonymous.\n */\n isAnonymous?: boolean;\n\n /**\n * The cloud that the Microsoft Teams user belongs to. If missing, the cloud is \"public\".\n */\n cloud?: \"public\" | \"dod\" | \"gcch\";\n}\n\n/**\n * A Microsoft bot.\n */\nexport interface MicrosoftBotIdentifier {\n /**\n * Optional raw id of the Microsoft bot.\n */\n rawId?: string;\n\n /**\n * The unique Microsoft app ID for the bot as registered with the Bot Framework.\n */\n botId: string;\n\n /**\n * True (or missing) if the bot is global and no resource account is configured and false if the bot is tenantized.\n */\n isResourceAccountConfigured?: boolean;\n\n /**\n * The cloud that the Microsoft bot belongs to. If missing, the cloud is \"public\".\n */\n cloud?: \"public\" | \"dod\" | \"gcch\";\n}\n\n/**\n * An unknown identifier that doesn't fit any of the other identifier types.\n */\nexport interface UnknownIdentifier {\n /**\n * Id of the UnknownIdentifier.\n */\n id: string;\n}\n\n/**\n * Tests an Identifier to determine whether it implements CommunicationUserIdentifier.\n *\n * @param identifier - The assumed CommunicationUserIdentifier to be tested.\n */\nexport const isCommunicationUserIdentifier = (\n identifier: CommunicationIdentifier\n): identifier is CommunicationUserIdentifier => {\n return typeof (identifier as any).communicationUserId === \"string\";\n};\n\n/**\n * Tests an Identifier to determine whether it implements PhoneNumberIdentifier.\n *\n * @param identifier - The assumed PhoneNumberIdentifier to be tested.\n */\nexport const isPhoneNumberIdentifier = (\n identifier: CommunicationIdentifier\n): identifier is PhoneNumberIdentifier => {\n return typeof (identifier as any).phoneNumber === \"string\";\n};\n\n/**\n * Tests an Identifier to determine whether it implements MicrosoftTeamsUserIdentifier.\n *\n * @param identifier - The assumed available to be tested.\n */\nexport const isMicrosoftTeamsUserIdentifier = (\n identifier: CommunicationIdentifier\n): identifier is MicrosoftTeamsUserIdentifier => {\n return typeof (identifier as any).microsoftTeamsUserId === \"string\";\n};\n\n/**\n * Tests an Identifier to determine whether it implements MicrosoftBotIdentifier.\n *\n * @param identifier - The assumed available to be tested.\n */\nexport const isMicrosoftBotIdentifier = (\n identifier: CommunicationIdentifier\n): identifier is MicrosoftBotIdentifier => {\n return typeof (identifier as any).botId === \"string\";\n};\n\n/**\n * Tests an Identifier to determine whether it implements UnknownIdentifier.\n *\n * @param identifier - The assumed UnknownIdentifier to be tested.\n */\nexport const isUnknownIdentifier = (\n identifier: CommunicationIdentifier\n): identifier is UnknownIdentifier => {\n return typeof (identifier as any).id === \"string\";\n};\n\n/**\n * The CommunicationIdentifierKind is a discriminated union that adds a property `kind` to an Identifier.\n */\nexport type CommunicationIdentifierKind =\n | CommunicationUserKind\n | PhoneNumberKind\n | MicrosoftTeamsUserKind\n | MicrosoftBotKind\n | UnknownIdentifierKind;\n\n/**\n * IdentifierKind for a CommunicationUserIdentifier.\n */\nexport interface CommunicationUserKind extends CommunicationUserIdentifier {\n /**\n * The identifier kind.\n */\n kind: \"communicationUser\";\n}\n\n/**\n * IdentifierKind for a PhoneNumberIdentifier.\n */\nexport interface PhoneNumberKind extends PhoneNumberIdentifier {\n /**\n * The identifier kind.\n */\n kind: \"phoneNumber\";\n}\n\n/**\n * IdentifierKind for a MicrosoftTeamsUserIdentifier.\n */\nexport interface MicrosoftTeamsUserKind extends MicrosoftTeamsUserIdentifier {\n /**\n * The identifier kind.\n */\n kind: \"microsoftTeamsUser\";\n}\n\n/**\n * IdentifierKind for a MicrosoftBotIdentifier.\n */\nexport interface MicrosoftBotKind extends MicrosoftBotIdentifier {\n /**\n * The identifier kind.\n */\n kind: \"microsoftBot\";\n}\n\n/**\n * IdentifierKind for UnknownIdentifier.\n */\nexport interface UnknownIdentifierKind extends UnknownIdentifier {\n /**\n * The identifier kind.\n */\n kind: \"unknown\";\n}\n\n/**\n * Returns the CommunicationIdentifierKind for a given CommunicationIdentifier. Returns undefined if the kind couldn't be inferred.\n *\n * @param identifier - The identifier whose kind is to be inferred.\n */\nexport const getIdentifierKind = (\n identifier: CommunicationIdentifier\n): CommunicationIdentifierKind => {\n if (isCommunicationUserIdentifier(identifier)) {\n return { ...identifier, kind: \"communicationUser\" };\n }\n if (isPhoneNumberIdentifier(identifier)) {\n return { ...identifier, kind: \"phoneNumber\" };\n }\n if (isMicrosoftTeamsUserIdentifier(identifier)) {\n return { ...identifier, kind: \"microsoftTeamsUser\" };\n }\n if (isMicrosoftBotIdentifier(identifier)) {\n return { ...identifier, kind: \"microsoftBot\" };\n }\n return { ...identifier, kind: \"unknown\" };\n};\n\n/**\n * Returns the rawId for a given CommunicationIdentifier. You can use the rawId for encoding the identifier and then use it as a key in a database.\n *\n * @param identifier - The identifier to be translated to its rawId.\n */\nexport const getIdentifierRawId = (identifier: CommunicationIdentifier): string => {\n const identifierKind = getIdentifierKind(identifier);\n switch (identifierKind.kind) {\n case \"communicationUser\":\n return identifierKind.communicationUserId;\n case \"microsoftTeamsUser\": {\n const { microsoftTeamsUserId, rawId, cloud, isAnonymous } = identifierKind;\n if (rawId) return rawId;\n if (isAnonymous) return `8:teamsvisitor:${microsoftTeamsUserId}`;\n switch (cloud) {\n case \"dod\":\n return `8:dod:${microsoftTeamsUserId}`;\n case \"gcch\":\n return `8:gcch:${microsoftTeamsUserId}`;\n case \"public\":\n return `8:orgid:${microsoftTeamsUserId}`;\n }\n return `8:orgid:${microsoftTeamsUserId}`;\n }\n case \"microsoftBot\": {\n const { botId, rawId, cloud, isResourceAccountConfigured } = identifierKind;\n if (rawId) return rawId;\n if (!isResourceAccountConfigured) {\n switch (cloud) {\n case \"dod\":\n return `28:dod-global:${botId}`;\n case \"gcch\":\n return `28:gcch-global:${botId}`;\n }\n return `28:${botId}`;\n }\n switch (cloud) {\n case \"dod\":\n return `28:dod:${botId}`;\n case \"gcch\":\n return `28:gcch:${botId}`;\n }\n return `28:orgid:${botId}`;\n }\n case \"phoneNumber\": {\n const { phoneNumber, rawId } = identifierKind;\n if (rawId) return rawId;\n return `4:${phoneNumber}`;\n }\n case \"unknown\": {\n return identifierKind.id;\n }\n }\n};\n\nconst buildMicrosoftBotIdentifier = (\n id: string,\n cloud: \"public\" | \"dod\" | \"gcch\",\n isResourceAccountConfigured: boolean\n): CommunicationIdentifierKind => {\n return {\n kind: \"microsoftBot\",\n botId: id,\n cloud: cloud,\n isResourceAccountConfigured: isResourceAccountConfigured,\n };\n};\n\nconst buildMicrosoftTeamsUserIdentifier = (\n id: string,\n cloud: \"public\" | \"dod\" | \"gcch\",\n isAnonymous: boolean\n): CommunicationIdentifierKind => {\n return {\n kind: \"microsoftTeamsUser\",\n microsoftTeamsUserId: id,\n isAnonymous: isAnonymous,\n cloud: cloud,\n };\n};\n\n/**\n * Creates a CommunicationIdentifierKind from a given rawId. When storing rawIds use this function to restore the identifier that was encoded in the rawId.\n *\n * @param rawId - The rawId to be translated to its identifier representation.\n */\nexport const createIdentifierFromRawId = (rawId: string): CommunicationIdentifierKind => {\n if (rawId.startsWith(\"4:\")) {\n return { kind: \"phoneNumber\", phoneNumber: `${rawId.substring(\"4:\".length)}` };\n }\n\n const segments = rawId.split(\":\");\n if (segments.length !== 3) {\n if (segments.length === 2 && segments[0] === \"28\") {\n return buildMicrosoftBotIdentifier(segments[1], \"public\", false);\n }\n return { kind: \"unknown\", id: rawId };\n }\n\n const prefix = `${segments[0]}:${segments[1]}:`;\n const suffix = segments[2];\n\n switch (prefix) {\n case \"8:teamsvisitor:\":\n return { kind: \"microsoftTeamsUser\", microsoftTeamsUserId: suffix, isAnonymous: true };\n case \"8:orgid:\":\n return buildMicrosoftTeamsUserIdentifier(suffix, \"public\", false);\n case \"8:dod:\":\n return buildMicrosoftTeamsUserIdentifier(suffix, \"dod\", false);\n case \"8:gcch:\":\n return buildMicrosoftTeamsUserIdentifier(suffix, \"gcch\", false);\n case \"8:acs:\":\n case \"8:spool:\":\n case \"8:dod-acs:\":\n case \"8:gcch-acs:\":\n return { kind: \"communicationUser\", communicationUserId: rawId };\n case \"28:gcch-global:\":\n return buildMicrosoftBotIdentifier(suffix, \"gcch\", false);\n case \"28:orgid:\":\n return buildMicrosoftBotIdentifier(suffix, \"public\", true);\n case \"28:dod-global:\":\n return buildMicrosoftBotIdentifier(suffix, \"dod\", false);\n case \"28:gcch:\":\n return buildMicrosoftBotIdentifier(suffix, \"gcch\", true);\n case \"28:dod:\":\n return buildMicrosoftBotIdentifier(suffix, \"dod\", true);\n }\n return { kind: \"unknown\", id: rawId };\n};\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@azure/communication-common",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0-alpha.20230327.5",
|
|
4
4
|
"description": "Common package for Azure Communication services.",
|
|
5
5
|
"sdk-type": "client",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -87,10 +87,8 @@
|
|
|
87
87
|
"inherits": "^2.0.3",
|
|
88
88
|
"karma-chrome-launcher": "^3.0.0",
|
|
89
89
|
"karma-coverage": "^2.0.0",
|
|
90
|
-
"karma-edge-launcher": "^0.4.2",
|
|
91
90
|
"karma-env-preprocessor": "^0.1.1",
|
|
92
91
|
"karma-firefox-launcher": "^1.1.0",
|
|
93
|
-
"karma-ie-launcher": "^1.0.0",
|
|
94
92
|
"karma-junit-reporter": "^2.0.1",
|
|
95
93
|
"karma-mocha-reporter": "^2.2.5",
|
|
96
94
|
"karma-mocha": "^2.0.1",
|
|
@@ -103,6 +101,7 @@
|
|
|
103
101
|
"rimraf": "^3.0.0",
|
|
104
102
|
"sinon": "^9.0.2",
|
|
105
103
|
"typescript": "~4.8.0",
|
|
106
|
-
"util": "^0.12.1"
|
|
104
|
+
"util": "^0.12.1",
|
|
105
|
+
"mockdate": "^3.0.5"
|
|
107
106
|
}
|
|
108
107
|
}
|
|
@@ -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 | MicrosoftBotIdentifier | 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 | MicrosoftBotKind | 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 MicrosoftBotIdentifier.
|
|
188
|
+
*
|
|
189
|
+
* @param identifier - The assumed available to be tested.
|
|
190
|
+
*/
|
|
191
|
+
export declare const isMicrosoftBotIdentifier: (identifier: CommunicationIdentifier) => identifier is MicrosoftBotIdentifier;
|
|
192
|
+
|
|
186
193
|
/**
|
|
187
194
|
* Tests an Identifier to determine whether it implements MicrosoftTeamsUserIdentifier.
|
|
188
195
|
*
|
|
@@ -204,6 +211,38 @@ 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 bot.
|
|
216
|
+
*/
|
|
217
|
+
export declare interface MicrosoftBotIdentifier {
|
|
218
|
+
/**
|
|
219
|
+
* Optional raw id of the Microsoft bot.
|
|
220
|
+
*/
|
|
221
|
+
rawId?: string;
|
|
222
|
+
/**
|
|
223
|
+
* The unique Microsoft app ID for the bot as registered with the Bot Framework.
|
|
224
|
+
*/
|
|
225
|
+
botId: string;
|
|
226
|
+
/**
|
|
227
|
+
* True (or missing) if the bot is global and no resource account is configured and false if the bot is tenantized.
|
|
228
|
+
*/
|
|
229
|
+
isResourceAccountConfigured?: boolean;
|
|
230
|
+
/**
|
|
231
|
+
* The cloud that the Microsoft bot belongs to. If missing, the cloud is "public".
|
|
232
|
+
*/
|
|
233
|
+
cloud?: "public" | "dod" | "gcch";
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* IdentifierKind for a MicrosoftBotIdentifier.
|
|
238
|
+
*/
|
|
239
|
+
export declare interface MicrosoftBotKind extends MicrosoftBotIdentifier {
|
|
240
|
+
/**
|
|
241
|
+
* The identifier kind.
|
|
242
|
+
*/
|
|
243
|
+
kind: "microsoftBot";
|
|
244
|
+
}
|
|
245
|
+
|
|
207
246
|
/**
|
|
208
247
|
* A Microsoft Teams user.
|
|
209
248
|
*/
|
|
@@ -313,6 +352,10 @@ export declare interface SerializedCommunicationIdentifier {
|
|
|
313
352
|
* The Microsoft Teams user.
|
|
314
353
|
*/
|
|
315
354
|
microsoftTeamsUser?: SerializedMicrosoftTeamsUserIdentifier;
|
|
355
|
+
/**
|
|
356
|
+
* The Microsoft bot.
|
|
357
|
+
*/
|
|
358
|
+
microsoftBot?: SerializedMicrosoftBotIdentifier;
|
|
316
359
|
}
|
|
317
360
|
|
|
318
361
|
/**
|
|
@@ -326,6 +369,25 @@ export declare interface SerializedCommunicationUserIdentifier {
|
|
|
326
369
|
id: string;
|
|
327
370
|
}
|
|
328
371
|
|
|
372
|
+
/**
|
|
373
|
+
* @hidden
|
|
374
|
+
* A Microsoft bot.
|
|
375
|
+
*/
|
|
376
|
+
export declare interface SerializedMicrosoftBotIdentifier {
|
|
377
|
+
/**
|
|
378
|
+
* Id of the Microsoft bot.
|
|
379
|
+
*/
|
|
380
|
+
botId: string;
|
|
381
|
+
/**
|
|
382
|
+
* True (or missing) if the bot is global and no resource account is configured and false if the bot is tenantized.
|
|
383
|
+
*/
|
|
384
|
+
isResourceAccountConfigured?: boolean;
|
|
385
|
+
/**
|
|
386
|
+
* The cloud that the Microsoft bot belongs to. By default 'public' if missing.
|
|
387
|
+
*/
|
|
388
|
+
cloud?: SerializedCommunicationCloudEnvironment;
|
|
389
|
+
}
|
|
390
|
+
|
|
329
391
|
/**
|
|
330
392
|
* @hidden
|
|
331
393
|
* A Microsoft Teams user.
|