@azure/communication-common 2.3.2-alpha.20250317.3 → 2.3.2-alpha.20250320.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. package/README.md +0 -48
  2. package/dist/browser/azureCommunicationTokenCredential.d.ts +0 -6
  3. package/dist/browser/azureCommunicationTokenCredential.d.ts.map +1 -1
  4. package/dist/browser/azureCommunicationTokenCredential.js +4 -8
  5. package/dist/browser/azureCommunicationTokenCredential.js.map +1 -1
  6. package/dist/browser/credential/clientArguments.d.ts.map +1 -1
  7. package/dist/browser/credential/connectionString.d.ts.map +1 -1
  8. package/dist/browser/credential/cryptoUtils-browser.d.mts.map +1 -1
  9. package/dist/browser/credential/encodeUtils.browser.d.ts.map +1 -1
  10. package/dist/browser/identifierModelSerializer.d.ts.map +1 -1
  11. package/dist/browser/identifierModels.d.ts.map +1 -1
  12. package/dist/browser/index.d.ts +1 -1
  13. package/dist/browser/index.d.ts.map +1 -1
  14. package/dist/browser/index.js +1 -0
  15. package/dist/browser/index.js.map +1 -1
  16. package/dist/browser/tokenParser.d.ts.map +1 -1
  17. package/dist/commonjs/azureCommunicationTokenCredential.d.ts +0 -6
  18. package/dist/commonjs/azureCommunicationTokenCredential.d.ts.map +1 -1
  19. package/dist/commonjs/azureCommunicationTokenCredential.js +4 -8
  20. package/dist/commonjs/azureCommunicationTokenCredential.js.map +1 -1
  21. package/dist/commonjs/credential/clientArguments.d.ts.map +1 -1
  22. package/dist/commonjs/credential/connectionString.d.ts.map +1 -1
  23. package/dist/commonjs/credential/cryptoUtils.d.ts.map +1 -1
  24. package/dist/commonjs/credential/encodeUtils.browser.d.ts.map +1 -1
  25. package/dist/commonjs/identifierModelSerializer.d.ts.map +1 -1
  26. package/dist/commonjs/identifierModels.d.ts.map +1 -1
  27. package/dist/commonjs/index.d.ts +1 -1
  28. package/dist/commonjs/index.d.ts.map +1 -1
  29. package/dist/commonjs/index.js +1 -0
  30. package/dist/commonjs/index.js.map +1 -1
  31. package/dist/commonjs/tokenParser.d.ts.map +1 -1
  32. package/dist/commonjs/tsdoc-metadata.json +1 -1
  33. package/dist/esm/azureCommunicationTokenCredential.d.ts +0 -6
  34. package/dist/esm/azureCommunicationTokenCredential.d.ts.map +1 -1
  35. package/dist/esm/azureCommunicationTokenCredential.js +4 -8
  36. package/dist/esm/azureCommunicationTokenCredential.js.map +1 -1
  37. package/dist/esm/credential/clientArguments.d.ts.map +1 -1
  38. package/dist/esm/credential/connectionString.d.ts.map +1 -1
  39. package/dist/esm/credential/cryptoUtils.d.ts.map +1 -1
  40. package/dist/esm/credential/encodeUtils.browser.d.ts.map +1 -1
  41. package/dist/esm/identifierModelSerializer.d.ts.map +1 -1
  42. package/dist/esm/identifierModels.d.ts.map +1 -1
  43. package/dist/esm/index.d.ts +1 -1
  44. package/dist/esm/index.d.ts.map +1 -1
  45. package/dist/esm/index.js +1 -0
  46. package/dist/esm/index.js.map +1 -1
  47. package/dist/esm/tokenParser.d.ts.map +1 -1
  48. package/dist/react-native/azureCommunicationTokenCredential.d.ts +0 -6
  49. package/dist/react-native/azureCommunicationTokenCredential.d.ts.map +1 -1
  50. package/dist/react-native/azureCommunicationTokenCredential.js +4 -8
  51. package/dist/react-native/azureCommunicationTokenCredential.js.map +1 -1
  52. package/dist/react-native/credential/clientArguments.d.ts.map +1 -1
  53. package/dist/react-native/credential/connectionString.d.ts.map +1 -1
  54. package/dist/react-native/credential/cryptoUtils.d.ts.map +1 -1
  55. package/dist/react-native/credential/encodeUtils.browser.d.ts.map +1 -1
  56. package/dist/react-native/identifierModelSerializer.d.ts.map +1 -1
  57. package/dist/react-native/identifierModels.d.ts.map +1 -1
  58. package/dist/react-native/index.d.ts +1 -1
  59. package/dist/react-native/index.d.ts.map +1 -1
  60. package/dist/react-native/index.js +1 -0
  61. package/dist/react-native/index.js.map +1 -1
  62. package/dist/react-native/tokenParser.d.ts.map +1 -1
  63. package/package.json +6 -9
  64. package/dist/browser/entraTokenCredential.d.ts +0 -44
  65. package/dist/browser/entraTokenCredential.d.ts.map +0 -1
  66. package/dist/browser/entraTokenCredential.js +0 -120
  67. package/dist/browser/entraTokenCredential.js.map +0 -1
  68. package/dist/commonjs/entraTokenCredential.d.ts +0 -44
  69. package/dist/commonjs/entraTokenCredential.d.ts.map +0 -1
  70. package/dist/commonjs/entraTokenCredential.js +0 -124
  71. package/dist/commonjs/entraTokenCredential.js.map +0 -1
  72. package/dist/esm/entraTokenCredential.d.ts +0 -44
  73. package/dist/esm/entraTokenCredential.d.ts.map +0 -1
  74. package/dist/esm/entraTokenCredential.js +0 -120
  75. package/dist/esm/entraTokenCredential.js.map +0 -1
  76. package/dist/react-native/entraTokenCredential.d.ts +0 -44
  77. package/dist/react-native/entraTokenCredential.d.ts.map +0 -1
  78. package/dist/react-native/entraTokenCredential.js +0 -120
  79. package/dist/react-native/entraTokenCredential.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAMlC,OAAO,EAAE,iCAAiC,EAAE,MAAM,wCAAwC,CAAC;AAG3F,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,gCAAgC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nexport {\n CommunicationTokenCredential,\n CommunicationGetTokenOptions,\n} from \"./communicationTokenCredential.js\";\nexport { AzureCommunicationTokenCredential } from \"./azureCommunicationTokenCredential.js\";\nexport { CommunicationTokenRefreshOptions } from \"./autoRefreshTokenCredential.js\";\nexport { EntraCommunicationTokenCredentialOptions } from \"./entraTokenCredential.js\";\nexport * from \"./credential/index.js\";\nexport * from \"./identifierModels.js\";\nexport * from \"./identifierModelSerializer.js\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAMlC,OAAO,EAAE,iCAAiC,EAAE,MAAM,wCAAwC,CAAC;AAC3F,cAAc,uBAAuB,CAAC;AAEtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,gCAAgC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nexport {\n CommunicationTokenCredential,\n CommunicationGetTokenOptions,\n} from \"./communicationTokenCredential.js\";\nexport { AzureCommunicationTokenCredential } from \"./azureCommunicationTokenCredential.js\";\nexport * from \"./credential/index.js\";\nexport { CommunicationTokenRefreshOptions } from \"./autoRefreshTokenCredential.js\";\nexport * from \"./credential/index.js\";\nexport * from \"./identifierModels.js\";\nexport * from \"./identifierModelSerializer.js\";\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"tokenParser.d.ts","sourceRoot":"","sources":["../../src/tokenParser.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAOpD,eAAO,MAAM,UAAU,UAAW,MAAM,KAAG,WAM1C,CAAC"}
1
+ {"version":3,"file":"tokenParser.d.ts","sourceRoot":"","sources":["../../src/tokenParser.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAOpD,eAAO,MAAM,UAAU,GAAI,OAAO,MAAM,KAAG,WAM1C,CAAC"}
@@ -1,7 +1,6 @@
1
1
  import { type CommunicationTokenRefreshOptions } from "./autoRefreshTokenCredential.js";
2
2
  import type { CommunicationGetTokenOptions, CommunicationTokenCredential } from "./communicationTokenCredential.js";
3
3
  import type { AccessToken } from "@azure/core-auth";
4
- import { type EntraCommunicationTokenCredentialOptions } from "./entraTokenCredential.js";
5
4
  /**
6
5
  * The CommunicationTokenCredential implementation with support for proactive token refresh.
7
6
  */
@@ -19,11 +18,6 @@ export declare class AzureCommunicationTokenCredential implements CommunicationT
19
18
  * @param refreshOptions - Options to configure refresh and opt-in to proactive refreshing.
20
19
  */
21
20
  constructor(refreshOptions: CommunicationTokenRefreshOptions);
22
- /**
23
- * Creates an instance of CommunicationTokenCredential with an Entra ID token credential. In most cases, you might want to use InteractiveBrowserCredential to sign in your user.
24
- * @param entraOptions - Options to configure the Entra ID token credential.
25
- */
26
- constructor(entraOptions: EntraCommunicationTokenCredentialOptions);
27
21
  /**
28
22
  * Gets an `AccessToken` for the user. Throws if already disposed.
29
23
  * @param abortSignal - An implementation of `AbortSignalLike` to cancel the operation.
@@ -1 +1 @@
1
- {"version":3,"file":"azureCommunicationTokenCredential.d.ts","sourceRoot":"","sources":["../../src/azureCommunicationTokenCredential.ts"],"names":[],"mappings":"AAGA,OAAO,EAEL,KAAK,gCAAgC,EACtC,MAAM,iCAAiC,CAAC;AACzC,OAAO,KAAK,EACV,4BAA4B,EAC5B,4BAA4B,EAE7B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAGpD,OAAO,EACL,KAAK,wCAAwC,EAE9C,MAAM,2BAA2B,CAAC;AAEnC;;GAEG;AAEH,qBAAa,iCAAkC,YAAW,4BAA4B;IACpF,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAkB;IAClD,OAAO,CAAC,QAAQ,CAAS;IAEzB;;;OAGG;gBACS,KAAK,EAAE,MAAM;IACzB;;;;OAIG;gBACS,cAAc,EAAE,gCAAgC;IAC5D;;;OAGG;gBACS,YAAY,EAAE,wCAAwC;IAkBlE;;;OAGG;IACU,QAAQ,CAAC,OAAO,CAAC,EAAE,4BAA4B,GAAG,OAAO,CAAC,WAAW,CAAC;IAOnF;;OAEG;IACI,OAAO,IAAI,IAAI;IAKtB,OAAO,CAAC,eAAe;CAKxB"}
1
+ {"version":3,"file":"azureCommunicationTokenCredential.d.ts","sourceRoot":"","sources":["../../src/azureCommunicationTokenCredential.ts"],"names":[],"mappings":"AAGA,OAAO,EAEL,KAAK,gCAAgC,EACtC,MAAM,iCAAiC,CAAC;AACzC,OAAO,KAAK,EACV,4BAA4B,EAC5B,4BAA4B,EAE7B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAIpD;;GAEG;AAEH,qBAAa,iCAAkC,YAAW,4BAA4B;IACpF,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAkB;IAClD,OAAO,CAAC,QAAQ,CAAS;IAEzB;;;OAGG;gBACS,KAAK,EAAE,MAAM;IACzB;;;;OAIG;gBACS,cAAc,EAAE,gCAAgC;IAS5D;;;OAGG;IACU,QAAQ,CAAC,OAAO,CAAC,EAAE,4BAA4B,GAAG,OAAO,CAAC,WAAW,CAAC;IAOnF;;OAEG;IACI,OAAO,IAAI,IAAI;IAKtB,OAAO,CAAC,eAAe;CAKxB"}
@@ -3,21 +3,17 @@
3
3
  import { AutoRefreshTokenCredential, } from "./autoRefreshTokenCredential.js";
4
4
  import { StaticTokenCredential } from "./staticTokenCredential.js";
5
5
  import { parseToken } from "./tokenParser.js";
6
- import { EntraTokenCredential, } from "./entraTokenCredential.js";
7
6
  /**
8
7
  * The CommunicationTokenCredential implementation with support for proactive token refresh.
9
8
  */
10
9
  export class AzureCommunicationTokenCredential {
11
- constructor(tokenOrRefreshOptionsOrEntraOptions) {
10
+ constructor(tokenOrRefreshOptions) {
12
11
  this.disposed = false;
13
- if (typeof tokenOrRefreshOptionsOrEntraOptions === "string") {
14
- this.tokenCredential = new StaticTokenCredential(parseToken(tokenOrRefreshOptionsOrEntraOptions));
15
- }
16
- else if ("tokenRefresher" in tokenOrRefreshOptionsOrEntraOptions) {
17
- this.tokenCredential = new AutoRefreshTokenCredential(tokenOrRefreshOptionsOrEntraOptions);
12
+ if (typeof tokenOrRefreshOptions === "string") {
13
+ this.tokenCredential = new StaticTokenCredential(parseToken(tokenOrRefreshOptions));
18
14
  }
19
15
  else {
20
- this.tokenCredential = new EntraTokenCredential(tokenOrRefreshOptionsOrEntraOptions);
16
+ this.tokenCredential = new AutoRefreshTokenCredential(tokenOrRefreshOptions);
21
17
  }
22
18
  }
23
19
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"azureCommunicationTokenCredential.js","sourceRoot":"","sources":["../../src/azureCommunicationTokenCredential.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EACL,0BAA0B,GAE3B,MAAM,iCAAiC,CAAC;AAOzC,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAEL,oBAAoB,GACrB,MAAM,2BAA2B,CAAC;AAEnC;;GAEG;AAEH,MAAM,OAAO,iCAAiC;IAoB5C,YACE,mCAG4C;QAtBtC,aAAQ,GAAG,KAAK,CAAC;QAwBvB,IAAI,OAAO,mCAAmC,KAAK,QAAQ,EAAE,CAAC;YAC5D,IAAI,CAAC,eAAe,GAAG,IAAI,qBAAqB,CAC9C,UAAU,CAAC,mCAAmC,CAAC,CAChD,CAAC;QACJ,CAAC;aAAM,IAAI,gBAAgB,IAAI,mCAAmC,EAAE,CAAC;YACnE,IAAI,CAAC,eAAe,GAAG,IAAI,0BAA0B,CAAC,mCAAmC,CAAC,CAAC;QAC7F,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,eAAe,GAAG,IAAI,oBAAoB,CAAC,mCAAmC,CAAC,CAAC;QACvF,CAAC;IACH,CAAC;IAED;;;OAGG;IACI,KAAK,CAAC,QAAQ,CAAC,OAAsC;QAC1D,IAAI,CAAC,eAAe,EAAE,CAAC;QACvB,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;QAC3D,IAAI,CAAC,eAAe,EAAE,CAAC;QACvB,OAAO,KAAK,CAAC;IACf,CAAC;IAED;;OAEG;IACI,OAAO;QACZ,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;QACrB,IAAI,CAAC,eAAe,CAAC,OAAO,EAAE,CAAC;IACjC,CAAC;IAEO,eAAe;QACrB,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAClB,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;QACjD,CAAC;IACH,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport {\n AutoRefreshTokenCredential,\n type CommunicationTokenRefreshOptions,\n} from \"./autoRefreshTokenCredential.js\";\nimport type {\n CommunicationGetTokenOptions,\n CommunicationTokenCredential,\n TokenCredential,\n} from \"./communicationTokenCredential.js\";\nimport type { AccessToken } from \"@azure/core-auth\";\nimport { StaticTokenCredential } from \"./staticTokenCredential.js\";\nimport { parseToken } from \"./tokenParser.js\";\nimport {\n type EntraCommunicationTokenCredentialOptions,\n EntraTokenCredential,\n} from \"./entraTokenCredential.js\";\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 /**\n * Creates an instance of CommunicationTokenCredential with an Entra ID token credential. In most cases, you might want to use InteractiveBrowserCredential to sign in your user.\n * @param entraOptions - Options to configure the Entra ID token credential.\n */\n constructor(entraOptions: EntraCommunicationTokenCredentialOptions);\n constructor(\n tokenOrRefreshOptionsOrEntraOptions:\n | string\n | CommunicationTokenRefreshOptions\n | EntraCommunicationTokenCredentialOptions,\n ) {\n if (typeof tokenOrRefreshOptionsOrEntraOptions === \"string\") {\n this.tokenCredential = new StaticTokenCredential(\n parseToken(tokenOrRefreshOptionsOrEntraOptions),\n );\n } else if (\"tokenRefresher\" in tokenOrRefreshOptionsOrEntraOptions) {\n this.tokenCredential = new AutoRefreshTokenCredential(tokenOrRefreshOptionsOrEntraOptions);\n } else {\n this.tokenCredential = new EntraTokenCredential(tokenOrRefreshOptionsOrEntraOptions);\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"]}
1
+ {"version":3,"file":"azureCommunicationTokenCredential.js","sourceRoot":"","sources":["../../src/azureCommunicationTokenCredential.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EACL,0BAA0B,GAE3B,MAAM,iCAAiC,CAAC;AAOzC,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C;;GAEG;AAEH,MAAM,OAAO,iCAAiC;IAe5C,YAAY,qBAAgE;QAbpE,aAAQ,GAAG,KAAK,CAAC;QAcvB,IAAI,OAAO,qBAAqB,KAAK,QAAQ,EAAE,CAAC;YAC9C,IAAI,CAAC,eAAe,GAAG,IAAI,qBAAqB,CAAC,UAAU,CAAC,qBAAqB,CAAC,CAAC,CAAC;QACtF,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,eAAe,GAAG,IAAI,0BAA0B,CAAC,qBAAqB,CAAC,CAAC;QAC/E,CAAC;IACH,CAAC;IAED;;;OAGG;IACI,KAAK,CAAC,QAAQ,CAAC,OAAsC;QAC1D,IAAI,CAAC,eAAe,EAAE,CAAC;QACvB,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;QAC3D,IAAI,CAAC,eAAe,EAAE,CAAC;QACvB,OAAO,KAAK,CAAC;IACf,CAAC;IAED;;OAEG;IACI,OAAO;QACZ,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;QACrB,IAAI,CAAC,eAAe,CAAC,OAAO,EAAE,CAAC;IACjC,CAAC;IAEO,eAAe;QACrB,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAClB,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;QACjD,CAAC;IACH,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport {\n AutoRefreshTokenCredential,\n type CommunicationTokenRefreshOptions,\n} from \"./autoRefreshTokenCredential.js\";\nimport type {\n CommunicationGetTokenOptions,\n CommunicationTokenCredential,\n TokenCredential,\n} from \"./communicationTokenCredential.js\";\nimport type { AccessToken } from \"@azure/core-auth\";\nimport { StaticTokenCredential } from \"./staticTokenCredential.js\";\nimport { parseToken } from \"./tokenParser.js\";\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"]}
@@ -1 +1 @@
1
- {"version":3,"file":"clientArguments.d.ts","sourceRoot":"","sources":["../../../src/credential/clientArguments.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,eAAe,EAAqB,MAAM,kBAAkB,CAAC;AAoB/F;;;;GAIG;AACH,eAAO,MAAM,eAAe,eAAgB,OAAO,KAAG,UAAU,IAAI,aAUnE,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B,GAAG,EAAE,MAAM,CAAC;IACZ,UAAU,EAAE,eAAe,GAAG,aAAa,CAAC;CAC7C,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,oBAAoB,0BACR,MAAM,wBACP,OAAO,KAC5B,iBASF,CAAC"}
1
+ {"version":3,"file":"clientArguments.d.ts","sourceRoot":"","sources":["../../../src/credential/clientArguments.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,eAAe,EAAqB,MAAM,kBAAkB,CAAC;AAoB/F;;;;GAIG;AACH,eAAO,MAAM,eAAe,GAAI,YAAY,OAAO,KAAG,UAAU,IAAI,aAUnE,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B,GAAG,EAAE,MAAM,CAAC;IACZ,UAAU,EAAE,eAAe,GAAG,aAAa,CAAC;CAC7C,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,oBAAoB,GAC/B,uBAAuB,MAAM,EAC7B,sBAAsB,OAAO,KAC5B,iBASF,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"connectionString.d.ts","sourceRoot":"","sources":["../../../src/credential/connectionString.ts"],"names":[],"mappings":"AAGA,OAAO,EAAsB,KAAK,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAC1E;;;;GAIG;AACH,MAAM,WAAW,kBAAkB;IACjC;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,UAAU,EAAE,aAAa,CAAC;CAC3B;AAYD;;;;;;GAMG;AACH,eAAO,MAAM,qBAAqB,qBAAsB,MAAM,KAAG,kBAOhE,CAAC"}
1
+ {"version":3,"file":"connectionString.d.ts","sourceRoot":"","sources":["../../../src/credential/connectionString.ts"],"names":[],"mappings":"AAGA,OAAO,EAAsB,KAAK,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAC1E;;;;GAIG;AACH,MAAM,WAAW,kBAAkB;IACjC;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,UAAU,EAAE,aAAa,CAAC;CAC3B;AAYD;;;;;;GAMG;AACH,eAAO,MAAM,qBAAqB,GAAI,kBAAkB,MAAM,KAAG,kBAOhE,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"cryptoUtils.d.ts","sourceRoot":"","sources":["../../../src/credential/cryptoUtils.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,OAAO,YAAmB,MAAM,KAAG,OAAO,CAAC,MAAM,CACP,CAAC;AAExD,eAAO,MAAM,OAAO,WAAkB,MAAM,WAAW,MAAM,KAAG,OAAO,CAAC,MAAM,CAI7E,CAAC"}
1
+ {"version":3,"file":"cryptoUtils.d.ts","sourceRoot":"","sources":["../../../src/credential/cryptoUtils.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,OAAO,GAAU,SAAS,MAAM,KAAG,OAAO,CAAC,MAAM,CACP,CAAC;AAExD,eAAO,MAAM,OAAO,GAAU,QAAQ,MAAM,EAAE,SAAS,MAAM,KAAG,OAAO,CAAC,MAAM,CAI7E,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"encodeUtils.browser.d.ts","sourceRoot":"","sources":["../../../src/credential/encodeUtils.browser.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,UAAU,QAAS,MAAM,KAAG,UAA2C,CAAC;AAErF,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,CAM5D;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,WAAW,GAAG,MAAM,CAOvD"}
1
+ {"version":3,"file":"encodeUtils.browser.d.ts","sourceRoot":"","sources":["../../../src/credential/encodeUtils.browser.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,UAAU,GAAI,KAAK,MAAM,KAAG,UAA2C,CAAC;AAErF,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,CAM5D;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,WAAW,GAAG,MAAM,CAOvD"}
@@ -1 +1 @@
1
- {"version":3,"file":"identifierModelSerializer.d.ts","sourceRoot":"","sources":["../../src/identifierModelSerializer.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,KAAK,uBAAuB,EAC5B,KAAK,2BAA2B,EAGjC,MAAM,uBAAuB,CAAC;AAE/B;;;GAGG;AACH,MAAM,WAAW,iCAAiC;IAChD;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,iBAAiB,CAAC,EAAE,qCAAqC,CAAC;IAC1D;;OAEG;IACH,WAAW,CAAC,EAAE,+BAA+B,CAAC;IAC9C;;OAEG;IACH,kBAAkB,CAAC,EAAE,sCAAsC,CAAC;I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H,eAAO,MAAM,yBAAyB,GAAI,OAAO,MAAM,KAAG,2BAsCzD,CAAC"}
@@ -1,7 +1,7 @@
1
1
  export { CommunicationTokenCredential, CommunicationGetTokenOptions, } from "./communicationTokenCredential.js";
2
2
  export { AzureCommunicationTokenCredential } from "./azureCommunicationTokenCredential.js";
3
+ export * from "./credential/index.js";
3
4
  export { CommunicationTokenRefreshOptions } from "./autoRefreshTokenCredential.js";
4
- export { EntraCommunicationTokenCredentialOptions } from "./entraTokenCredential.js";
5
5
  export * from "./credential/index.js";
6
6
  export * from "./identifierModels.js";
7
7
  export * from "./identifierModelSerializer.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,4BAA4B,EAC5B,4BAA4B,GAC7B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,iCAAiC,EAAE,MAAM,wCAAwC,CAAC;AAC3F,OAAO,EAAE,gCAAgC,EAAE,MAAM,iCAAiC,CAAC;AACnF,OAAO,EAAE,wCAAwC,EAAE,MAAM,2BAA2B,CAAC;AACrF,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,gCAAgC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,4BAA4B,EAC5B,4BAA4B,GAC7B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,iCAAiC,EAAE,MAAM,wCAAwC,CAAC;AAC3F,cAAc,uBAAuB,CAAC;AACtC,OAAO,EAAE,gCAAgC,EAAE,MAAM,iCAAiC,CAAC;AACnF,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,gCAAgC,CAAC"}
@@ -2,6 +2,7 @@
2
2
  // Licensed under the MIT License.
3
3
  export { AzureCommunicationTokenCredential } from "./azureCommunicationTokenCredential.js";
4
4
  export * from "./credential/index.js";
5
+ export * from "./credential/index.js";
5
6
  export * from "./identifierModels.js";
6
7
  export * from "./identifierModelSerializer.js";
7
8
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAMlC,OAAO,EAAE,iCAAiC,EAAE,MAAM,wCAAwC,CAAC;AAG3F,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,gCAAgC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nexport {\n CommunicationTokenCredential,\n CommunicationGetTokenOptions,\n} from \"./communicationTokenCredential.js\";\nexport { AzureCommunicationTokenCredential } from \"./azureCommunicationTokenCredential.js\";\nexport { CommunicationTokenRefreshOptions } from \"./autoRefreshTokenCredential.js\";\nexport { EntraCommunicationTokenCredentialOptions } from \"./entraTokenCredential.js\";\nexport * from \"./credential/index.js\";\nexport * from \"./identifierModels.js\";\nexport * from \"./identifierModelSerializer.js\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAMlC,OAAO,EAAE,iCAAiC,EAAE,MAAM,wCAAwC,CAAC;AAC3F,cAAc,uBAAuB,CAAC;AAEtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,gCAAgC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nexport {\n CommunicationTokenCredential,\n CommunicationGetTokenOptions,\n} from \"./communicationTokenCredential.js\";\nexport { AzureCommunicationTokenCredential } from \"./azureCommunicationTokenCredential.js\";\nexport * from \"./credential/index.js\";\nexport { CommunicationTokenRefreshOptions } from \"./autoRefreshTokenCredential.js\";\nexport * from \"./credential/index.js\";\nexport * from \"./identifierModels.js\";\nexport * from \"./identifierModelSerializer.js\";\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"tokenParser.d.ts","sourceRoot":"","sources":["../../src/tokenParser.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAOpD,eAAO,MAAM,UAAU,UAAW,MAAM,KAAG,WAM1C,CAAC"}
1
+ {"version":3,"file":"tokenParser.d.ts","sourceRoot":"","sources":["../../src/tokenParser.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAOpD,eAAO,MAAM,UAAU,GAAI,OAAO,MAAM,KAAG,WAM1C,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@azure/communication-common",
3
- "version": "2.3.2-alpha.20250317.3",
3
+ "version": "2.3.2-alpha.20250320.1",
4
4
  "description": "Common package for Azure Communication services.",
5
5
  "sdk-type": "client",
6
6
  "main": "./dist/commonjs/index.js",
@@ -59,8 +59,7 @@
59
59
  "dependencies": {
60
60
  "@azure/abort-controller": "^2.1.2",
61
61
  "@azure/core-auth": "^1.9.0",
62
- "@azure-rest/core-client": "^2.3.3",
63
- "@azure/core-rest-pipeline": "^1.17.0",
62
+ "@azure/core-rest-pipeline": "^1.18.2",
64
63
  "@azure/core-tracing": "^1.2.0",
65
64
  "@azure/core-util": "^1.11.0",
66
65
  "events": "^3.3.0",
@@ -70,18 +69,16 @@
70
69
  "devDependencies": {
71
70
  "@azure-tools/test-utils-vitest": ">=1.0.0-alpha <1.0.0-alphb",
72
71
  "@azure/dev-tool": ">=1.0.0-alpha <1.0.0-alphb",
73
- "@azure/identity": "~4.3.0",
74
72
  "@azure/eslint-plugin-azure-sdk": ">=3.0.0-alpha <3.0.0-alphb",
75
73
  "@azure/logger": "^1.1.4",
76
74
  "@types/node": "^18.0.0",
77
- "@vitest/browser": "^3.0.3",
78
- "@vitest/coverage-istanbul": "^3.0.3",
75
+ "@vitest/browser": "^3.0.9",
76
+ "@vitest/coverage-istanbul": "^3.0.9",
79
77
  "eslint": "^9.9.0",
80
78
  "mockdate": "^3.0.5",
81
- "nock": "14.0.1",
82
79
  "playwright": "^1.48.0",
83
- "typescript": "~5.7.2",
84
- "vitest": "^3.0.3"
80
+ "typescript": "~5.8.2",
81
+ "vitest": "^3.0.9"
85
82
  },
86
83
  "type": "module",
87
84
  "tshy": {
@@ -1,44 +0,0 @@
1
- import { type AccessToken, type TokenCredential } from "@azure/core-auth";
2
- import { type TokenCredential as AcsTokenCredential, type CommunicationGetTokenOptions } from "./communicationTokenCredential.js";
3
- export interface ExchangeTokenResponse {
4
- identity: string;
5
- accessToken: {
6
- token: string;
7
- expiresOn: string;
8
- };
9
- }
10
- /**
11
- * The Entra Communication Token Options.
12
- */
13
- export interface EntraCommunicationTokenCredentialOptions {
14
- /**
15
- * The Azure Communication Service resource endpoint URL, e.g. https://myResource.communication.azure.com.
16
- */
17
- resourceEndpoint: string;
18
- /**
19
- * The Entra ID token credential.
20
- */
21
- tokenCredential: TokenCredential;
22
- /**
23
- * The scopes for retrieving the Entra ID access token.
24
- */
25
- scopes?: string[];
26
- }
27
- /**
28
- * Represents a credential that exchanges an Entra token for an Azure Communication Services (ACS) token, enabling access to ACS resources.
29
- */
30
- export declare class EntraTokenCredential implements AcsTokenCredential {
31
- private options;
32
- private isPending;
33
- private result;
34
- private client;
35
- private httpClient;
36
- constructor(options: EntraCommunicationTokenCredentialOptions);
37
- getToken(options?: CommunicationGetTokenOptions): Promise<AccessToken>;
38
- private getTokenInternal;
39
- dispose(): void;
40
- private exchangeEntraToken;
41
- private createRequestUri;
42
- private determineEndpointAndApiVersion;
43
- }
44
- //# sourceMappingURL=entraTokenCredential.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"entraTokenCredential.d.ts","sourceRoot":"","sources":["../../src/entraTokenCredential.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAC1E,OAAO,EACL,KAAK,eAAe,IAAI,kBAAkB,EAC1C,KAAK,4BAA4B,EAClC,MAAM,mCAAmC,CAAC;AAiB3C,MAAM,WAAW,qBAAqB;IACpC,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE;QACX,KAAK,EAAE,MAAM,CAAC;QACd,SAAS,EAAE,MAAM,CAAC;KACnB,CAAC;CACH;AAED;;GAEG;AACH,MAAM,WAAW,wCAAwC;IACvD;;OAEG;IACH,gBAAgB,EAAE,MAAM,CAAC;IACzB;;OAEG;IACH,eAAe,EAAE,eAAe,CAAC;IACjC;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;CACnB;AAED;;GAEG;AACH,qBAAa,oBAAqB,YAAW,kBAAkB;IASjD,OAAO,CAAC,OAAO;IAR3B,OAAO,CAAC,SAAS,CAA8B;IAC/C,OAAO,CAAC,MAAM,CAGZ;IACF,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,UAAU,CAAa;gBAEX,OAAO,EAAE,wCAAwC;IAYxD,QAAQ,CAAC,OAAO,CAAC,EAAE,4BAA4B,GAAG,OAAO,CAAC,WAAW,CAAC;YAoBrE,gBAAgB;IAmCvB,OAAO,IAAI,IAAI;YAOR,kBAAkB;IA8BhC,OAAO,CAAC,gBAAgB;IAMxB,OAAO,CAAC,8BAA8B;CAiBvC"}
@@ -1,120 +0,0 @@
1
- // Copyright (c) Microsoft Corporation.
2
- // Licensed under the MIT License.
3
- import { getClient } from "@azure-rest/core-client";
4
- import { createDefaultHttpClient, createHttpHeaders, createPipelineRequest, } from "@azure/core-rest-pipeline";
5
- const TeamsExtensionScopePrefix = "https://auth.msft.communication.azure.com/";
6
- const CommunicationClientsScopePrefix = "https://communication.azure.com/clients/";
7
- const TeamsExtensionEndpoint = "/access/teamsPhone/:exchangeAccessToken";
8
- const TeamsExtensionApiVersion = "2025-03-02-preview";
9
- const CommunicationClientsEndpoint = "/access/entra/:exchangeAccessToken";
10
- const CommunicationClientsApiVersion = "2024-04-01-preview";
11
- /**
12
- * Represents a credential that exchanges an Entra token for an Azure Communication Services (ACS) token, enabling access to ACS resources.
13
- */
14
- export class EntraTokenCredential {
15
- constructor(options) {
16
- this.options = options;
17
- this.result = {
18
- entraToken: undefined,
19
- acsToken: { token: "", expiresOnTimestamp: 0 },
20
- };
21
- this.client = getClient(options.resourceEndpoint);
22
- this.httpClient = createDefaultHttpClient();
23
- this.options = options;
24
- this.options.scopes = this.options.scopes || [
25
- "https://communication.azure.com/clients/.default",
26
- ];
27
- // immediately fetch the token to pre-warm
28
- this.isPending = this.getToken();
29
- }
30
- async getToken(options) {
31
- var _a;
32
- if ((_a = options === null || options === void 0 ? void 0 : options.abortSignal) === null || _a === void 0 ? void 0 : _a.aborted) {
33
- return { token: "", expiresOnTimestamp: 0 };
34
- }
35
- // we're awaiting the token fetch, so we don't want to start another one
36
- // however, we're ignoring the new abortSignal, unfortunately
37
- if (!this.isPending) {
38
- this.isPending = this.getTokenInternal(options);
39
- }
40
- try {
41
- await this.isPending;
42
- }
43
- finally {
44
- this.isPending = null;
45
- }
46
- return this.result.acsToken;
47
- }
48
- async getTokenInternal(options) {
49
- const getTokenOptions = (options === null || options === void 0 ? void 0 : options.abortSignal) ? { abortSignal: options.abortSignal } : undefined;
50
- const token = await this.options.tokenCredential.getToken(this.options.scopes
51
- ? this.options.scopes
52
- : ["https://communication.azure.com/clients/.default"], getTokenOptions);
53
- const currentDateTime = new Date();
54
- const tokenExpiresOn = new Date(this.result.acsToken.expiresOnTimestamp);
55
- if (token === null) {
56
- this.result = {
57
- entraToken: undefined,
58
- acsToken: { token: "", expiresOnTimestamp: 0 },
59
- };
60
- }
61
- else if (this.result.acsToken.token === "" ||
62
- token.token !== this.result.entraToken ||
63
- tokenExpiresOn < currentDateTime) {
64
- const acsToken = await this.exchangeEntraToken(this.options.resourceEndpoint, token.token, getTokenOptions);
65
- this.result = {
66
- entraToken: token.token,
67
- acsToken,
68
- };
69
- }
70
- return this.result.acsToken;
71
- }
72
- dispose() {
73
- this.result = {
74
- entraToken: undefined,
75
- acsToken: { token: "", expiresOnTimestamp: 0 },
76
- };
77
- }
78
- async exchangeEntraToken(resourceEndpoint, entraToken, options) {
79
- const request = createPipelineRequest({
80
- url: this.createRequestUri(resourceEndpoint),
81
- method: "POST",
82
- headers: createHttpHeaders({
83
- Authorization: `Bearer ${entraToken}`,
84
- "Content-Type": "application/json",
85
- Accept: "application/json",
86
- }),
87
- abortSignal: options === null || options === void 0 ? void 0 : options.abortSignal,
88
- body: JSON.stringify({}),
89
- });
90
- const response = await this.client.pipeline.sendRequest(this.httpClient, request);
91
- if (response.status !== 200 || !response.bodyAsText) {
92
- throw new Error(`Service request failed. Status: ${response.status}, Body: ${response.bodyAsText}`);
93
- }
94
- const json = JSON.parse(response.bodyAsText);
95
- return {
96
- token: json.accessToken.token,
97
- expiresOnTimestamp: Date.parse(json.accessToken.expiresOn),
98
- };
99
- }
100
- createRequestUri(resourceEndpoint) {
101
- const [endpoint, apiVersion] = this.determineEndpointAndApiVersion();
102
- const requestUri = `${resourceEndpoint}${endpoint}?api-version=${apiVersion}`;
103
- return requestUri;
104
- }
105
- determineEndpointAndApiVersion() {
106
- if (!this.options.scopes || this.options.scopes.length === 0) {
107
- throw new Error(`Scopes validation failed. Ensure all scopes start with either {TeamsExtensionScopePrefix} or {CommunicationClientsScopePrefix}.`);
108
- }
109
- else if (this.options.scopes.every((scope) => scope.startsWith(TeamsExtensionScopePrefix))) {
110
- return [TeamsExtensionEndpoint, TeamsExtensionApiVersion];
111
- }
112
- else if (this.options.scopes.every((scope) => scope.startsWith(CommunicationClientsScopePrefix))) {
113
- return [CommunicationClientsEndpoint, CommunicationClientsApiVersion];
114
- }
115
- else {
116
- throw new Error(`Scopes validation failed. Ensure all scopes start with either {TeamsExtensionScopePrefix} or {CommunicationClientsScopePrefix}.`);
117
- }
118
- }
119
- }
120
- //# sourceMappingURL=entraTokenCredential.js.map
@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,CAAC;QACxE,CAAC;aAAM,CAAC;YACN,MAAM,IAAI,KAAK,CACb,iIAAiI,CAClI,CAAC;QACJ,CAAC;IACH,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { type AccessToken, type TokenCredential } from \"@azure/core-auth\";\nimport {\n type TokenCredential as AcsTokenCredential,\n type CommunicationGetTokenOptions,\n} from \"./communicationTokenCredential.js\";\nimport { type AbortSignalLike } from \"@azure/abort-controller\";\nimport { type Client, getClient } from \"@azure-rest/core-client\";\nimport {\n type HttpClient,\n createDefaultHttpClient,\n createHttpHeaders,\n createPipelineRequest,\n} from \"@azure/core-rest-pipeline\";\n\nconst TeamsExtensionScopePrefix = \"https://auth.msft.communication.azure.com/\";\nconst CommunicationClientsScopePrefix = \"https://communication.azure.com/clients/\";\nconst TeamsExtensionEndpoint = \"/access/teamsPhone/:exchangeAccessToken\";\nconst TeamsExtensionApiVersion = \"2025-03-02-preview\";\nconst CommunicationClientsEndpoint = \"/access/entra/:exchangeAccessToken\";\nconst CommunicationClientsApiVersion = \"2024-04-01-preview\";\n\nexport interface ExchangeTokenResponse {\n identity: string;\n accessToken: {\n token: string;\n expiresOn: string;\n };\n}\n\n/**\n * The Entra Communication Token Options.\n */\nexport interface EntraCommunicationTokenCredentialOptions {\n /**\n * The Azure Communication Service resource endpoint URL, e.g. https://myResource.communication.azure.com.\n */\n resourceEndpoint: string;\n /**\n * The Entra ID token credential.\n */\n tokenCredential: TokenCredential;\n /**\n * The scopes for retrieving the Entra ID access token.\n */\n scopes?: string[];\n}\n\n/**\n * Represents a credential that exchanges an Entra token for an Azure Communication Services (ACS) token, enabling access to ACS resources.\n */\nexport class EntraTokenCredential implements AcsTokenCredential {\n private isPending: Promise<AccessToken> | null;\n private result = {\n entraToken: undefined as string | undefined,\n acsToken: { token: \"\", expiresOnTimestamp: 0 },\n };\n private client: Client;\n private httpClient: HttpClient;\n\n constructor(private options: EntraCommunicationTokenCredentialOptions) {\n this.client = getClient(options.resourceEndpoint);\n this.httpClient = createDefaultHttpClient();\n this.options = options;\n this.options.scopes = this.options.scopes || [\n \"https://communication.azure.com/clients/.default\",\n ];\n\n // immediately fetch the token to pre-warm\n this.isPending = this.getToken();\n }\n\n public async getToken(options?: CommunicationGetTokenOptions): Promise<AccessToken> {\n if (options?.abortSignal?.aborted) {\n return { token: \"\", expiresOnTimestamp: 0 };\n }\n\n // we're awaiting the token fetch, so we don't want to start another one\n // however, we're ignoring the new abortSignal, unfortunately\n if (!this.isPending) {\n this.isPending = this.getTokenInternal(options);\n }\n\n try {\n await this.isPending;\n } finally {\n this.isPending = null;\n }\n\n return this.result.acsToken;\n }\n\n private async getTokenInternal(options?: CommunicationGetTokenOptions): Promise<AccessToken> {\n const getTokenOptions = options?.abortSignal ? { abortSignal: options.abortSignal } : undefined;\n const token = await this.options.tokenCredential.getToken(\n this.options.scopes\n ? this.options.scopes\n : [\"https://communication.azure.com/clients/.default\"],\n getTokenOptions,\n );\n const currentDateTime = new Date();\n const tokenExpiresOn = new Date(this.result.acsToken.expiresOnTimestamp);\n\n if (token === null) {\n this.result = {\n entraToken: undefined,\n acsToken: { token: \"\", expiresOnTimestamp: 0 },\n };\n } else if (\n this.result.acsToken.token === \"\" ||\n token.token !== this.result.entraToken ||\n tokenExpiresOn < currentDateTime\n ) {\n const acsToken = await this.exchangeEntraToken(\n this.options.resourceEndpoint,\n token.token,\n getTokenOptions,\n );\n this.result = {\n entraToken: token.token,\n acsToken,\n };\n }\n\n return this.result.acsToken;\n }\n\n public dispose(): void {\n this.result = {\n entraToken: undefined,\n acsToken: { token: \"\", expiresOnTimestamp: 0 },\n };\n }\n\n private async exchangeEntraToken(\n resourceEndpoint: string,\n entraToken: string,\n options?: { abortSignal: AbortSignalLike },\n ): Promise<AccessToken> {\n const request = createPipelineRequest({\n url: this.createRequestUri(resourceEndpoint),\n method: \"POST\",\n headers: createHttpHeaders({\n Authorization: `Bearer ${entraToken}`,\n \"Content-Type\": \"application/json\",\n Accept: \"application/json\",\n }),\n abortSignal: options?.abortSignal,\n body: JSON.stringify({}),\n });\n const response = await this.client.pipeline.sendRequest(this.httpClient, request);\n\n if (response.status !== 200 || !response.bodyAsText) {\n throw new Error(\n `Service request failed. Status: ${response.status}, Body: ${response.bodyAsText}`,\n );\n }\n const json = JSON.parse(response.bodyAsText) as ExchangeTokenResponse;\n return {\n token: json.accessToken.token,\n expiresOnTimestamp: Date.parse(json.accessToken.expiresOn),\n };\n }\n\n private createRequestUri(resourceEndpoint: string): string {\n const [endpoint, apiVersion] = this.determineEndpointAndApiVersion();\n const requestUri = `${resourceEndpoint}${endpoint}?api-version=${apiVersion}`;\n return requestUri;\n }\n\n private determineEndpointAndApiVersion(): [string, string] {\n if (!this.options.scopes || this.options.scopes.length === 0) {\n throw new Error(\n `Scopes validation failed. Ensure all scopes start with either {TeamsExtensionScopePrefix} or {CommunicationClientsScopePrefix}.`,\n );\n } else if (this.options.scopes.every((scope) => scope.startsWith(TeamsExtensionScopePrefix))) {\n return [TeamsExtensionEndpoint, TeamsExtensionApiVersion];\n } else if (\n this.options.scopes.every((scope) => scope.startsWith(CommunicationClientsScopePrefix))\n ) {\n return [CommunicationClientsEndpoint, CommunicationClientsApiVersion];\n } else {\n throw new Error(\n `Scopes validation failed. Ensure all scopes start with either {TeamsExtensionScopePrefix} or {CommunicationClientsScopePrefix}.`,\n );\n }\n }\n}\n"]}
@@ -1,44 +0,0 @@
1
- import { type AccessToken, type TokenCredential } from "@azure/core-auth";
2
- import { type TokenCredential as AcsTokenCredential, type CommunicationGetTokenOptions } from "./communicationTokenCredential.js";
3
- export interface ExchangeTokenResponse {
4
- identity: string;
5
- accessToken: {
6
- token: string;
7
- expiresOn: string;
8
- };
9
- }
10
- /**
11
- * The Entra Communication Token Options.
12
- */
13
- export interface EntraCommunicationTokenCredentialOptions {
14
- /**
15
- * The Azure Communication Service resource endpoint URL, e.g. https://myResource.communication.azure.com.
16
- */
17
- resourceEndpoint: string;
18
- /**
19
- * The Entra ID token credential.
20
- */
21
- tokenCredential: TokenCredential;
22
- /**
23
- * The scopes for retrieving the Entra ID access token.
24
- */
25
- scopes?: string[];
26
- }
27
- /**
28
- * Represents a credential that exchanges an Entra token for an Azure Communication Services (ACS) token, enabling access to ACS resources.
29
- */
30
- export declare class EntraTokenCredential implements AcsTokenCredential {
31
- private options;
32
- private isPending;
33
- private result;
34
- private client;
35
- private httpClient;
36
- constructor(options: EntraCommunicationTokenCredentialOptions);
37
- getToken(options?: CommunicationGetTokenOptions): Promise<AccessToken>;
38
- private getTokenInternal;
39
- dispose(): void;
40
- private exchangeEntraToken;
41
- private createRequestUri;
42
- private determineEndpointAndApiVersion;
43
- }
44
- //# sourceMappingURL=entraTokenCredential.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"entraTokenCredential.d.ts","sourceRoot":"","sources":["../../src/entraTokenCredential.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAC1E,OAAO,EACL,KAAK,eAAe,IAAI,kBAAkB,EAC1C,KAAK,4BAA4B,EAClC,MAAM,mCAAmC,CAAC;AAiB3C,MAAM,WAAW,qBAAqB;IACpC,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE;QACX,KAAK,EAAE,MAAM,CAAC;QACd,SAAS,EAAE,MAAM,CAAC;KACnB,CAAC;CACH;AAED;;GAEG;AACH,MAAM,WAAW,wCAAwC;IACvD;;OAEG;IACH,gBAAgB,EAAE,MAAM,CAAC;IACzB;;OAEG;IACH,eAAe,EAAE,eAAe,CAAC;IACjC;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;CACnB;AAED;;GAEG;AACH,qBAAa,oBAAqB,YAAW,kBAAkB;IASjD,OAAO,CAAC,OAAO;IAR3B,OAAO,CAAC,SAAS,CAA8B;IAC/C,OAAO,CAAC,MAAM,CAGZ;IACF,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,UAAU,CAAa;gBAEX,OAAO,EAAE,wCAAwC;IAYxD,QAAQ,CAAC,OAAO,CAAC,EAAE,4BAA4B,GAAG,OAAO,CAAC,WAAW,CAAC;YAoBrE,gBAAgB;IAmCvB,OAAO,IAAI,IAAI;YAOR,kBAAkB;IA8BhC,OAAO,CAAC,gBAAgB;IAMxB,OAAO,CAAC,8BAA8B;CAiBvC"}
@@ -1,124 +0,0 @@
1
- "use strict";
2
- // Copyright (c) Microsoft Corporation.
3
- // Licensed under the MIT License.
4
- Object.defineProperty(exports, "__esModule", { value: true });
5
- exports.EntraTokenCredential = void 0;
6
- const core_client_1 = require("@azure-rest/core-client");
7
- const core_rest_pipeline_1 = require("@azure/core-rest-pipeline");
8
- const TeamsExtensionScopePrefix = "https://auth.msft.communication.azure.com/";
9
- const CommunicationClientsScopePrefix = "https://communication.azure.com/clients/";
10
- const TeamsExtensionEndpoint = "/access/teamsPhone/:exchangeAccessToken";
11
- const TeamsExtensionApiVersion = "2025-03-02-preview";
12
- const CommunicationClientsEndpoint = "/access/entra/:exchangeAccessToken";
13
- const CommunicationClientsApiVersion = "2024-04-01-preview";
14
- /**
15
- * Represents a credential that exchanges an Entra token for an Azure Communication Services (ACS) token, enabling access to ACS resources.
16
- */
17
- class EntraTokenCredential {
18
- constructor(options) {
19
- this.options = options;
20
- this.result = {
21
- entraToken: undefined,
22
- acsToken: { token: "", expiresOnTimestamp: 0 },
23
- };
24
- this.client = (0, core_client_1.getClient)(options.resourceEndpoint);
25
- this.httpClient = (0, core_rest_pipeline_1.createDefaultHttpClient)();
26
- this.options = options;
27
- this.options.scopes = this.options.scopes || [
28
- "https://communication.azure.com/clients/.default",
29
- ];
30
- // immediately fetch the token to pre-warm
31
- this.isPending = this.getToken();
32
- }
33
- async getToken(options) {
34
- var _a;
35
- if ((_a = options === null || options === void 0 ? void 0 : options.abortSignal) === null || _a === void 0 ? void 0 : _a.aborted) {
36
- return { token: "", expiresOnTimestamp: 0 };
37
- }
38
- // we're awaiting the token fetch, so we don't want to start another one
39
- // however, we're ignoring the new abortSignal, unfortunately
40
- if (!this.isPending) {
41
- this.isPending = this.getTokenInternal(options);
42
- }
43
- try {
44
- await this.isPending;
45
- }
46
- finally {
47
- this.isPending = null;
48
- }
49
- return this.result.acsToken;
50
- }
51
- async getTokenInternal(options) {
52
- const getTokenOptions = (options === null || options === void 0 ? void 0 : options.abortSignal) ? { abortSignal: options.abortSignal } : undefined;
53
- const token = await this.options.tokenCredential.getToken(this.options.scopes
54
- ? this.options.scopes
55
- : ["https://communication.azure.com/clients/.default"], getTokenOptions);
56
- const currentDateTime = new Date();
57
- const tokenExpiresOn = new Date(this.result.acsToken.expiresOnTimestamp);
58
- if (token === null) {
59
- this.result = {
60
- entraToken: undefined,
61
- acsToken: { token: "", expiresOnTimestamp: 0 },
62
- };
63
- }
64
- else if (this.result.acsToken.token === "" ||
65
- token.token !== this.result.entraToken ||
66
- tokenExpiresOn < currentDateTime) {
67
- const acsToken = await this.exchangeEntraToken(this.options.resourceEndpoint, token.token, getTokenOptions);
68
- this.result = {
69
- entraToken: token.token,
70
- acsToken,
71
- };
72
- }
73
- return this.result.acsToken;
74
- }
75
- dispose() {
76
- this.result = {
77
- entraToken: undefined,
78
- acsToken: { token: "", expiresOnTimestamp: 0 },
79
- };
80
- }
81
- async exchangeEntraToken(resourceEndpoint, entraToken, options) {
82
- const request = (0, core_rest_pipeline_1.createPipelineRequest)({
83
- url: this.createRequestUri(resourceEndpoint),
84
- method: "POST",
85
- headers: (0, core_rest_pipeline_1.createHttpHeaders)({
86
- Authorization: `Bearer ${entraToken}`,
87
- "Content-Type": "application/json",
88
- Accept: "application/json",
89
- }),
90
- abortSignal: options === null || options === void 0 ? void 0 : options.abortSignal,
91
- body: JSON.stringify({}),
92
- });
93
- const response = await this.client.pipeline.sendRequest(this.httpClient, request);
94
- if (response.status !== 200 || !response.bodyAsText) {
95
- throw new Error(`Service request failed. Status: ${response.status}, Body: ${response.bodyAsText}`);
96
- }
97
- const json = JSON.parse(response.bodyAsText);
98
- return {
99
- token: json.accessToken.token,
100
- expiresOnTimestamp: Date.parse(json.accessToken.expiresOn),
101
- };
102
- }
103
- createRequestUri(resourceEndpoint) {
104
- const [endpoint, apiVersion] = this.determineEndpointAndApiVersion();
105
- const requestUri = `${resourceEndpoint}${endpoint}?api-version=${apiVersion}`;
106
- return requestUri;
107
- }
108
- determineEndpointAndApiVersion() {
109
- if (!this.options.scopes || this.options.scopes.length === 0) {
110
- throw new Error(`Scopes validation failed. Ensure all scopes start with either {TeamsExtensionScopePrefix} or {CommunicationClientsScopePrefix}.`);
111
- }
112
- else if (this.options.scopes.every((scope) => scope.startsWith(TeamsExtensionScopePrefix))) {
113
- return [TeamsExtensionEndpoint, TeamsExtensionApiVersion];
114
- }
115
- else if (this.options.scopes.every((scope) => scope.startsWith(CommunicationClientsScopePrefix))) {
116
- return [CommunicationClientsEndpoint, CommunicationClientsApiVersion];
117
- }
118
- else {
119
- throw new Error(`Scopes validation failed. Ensure all scopes start with either {TeamsExtensionScopePrefix} or {CommunicationClientsScopePrefix}.`);
120
- }
121
- }
122
- }
123
- exports.EntraTokenCredential = EntraTokenCredential;
124
- //# sourceMappingURL=entraTokenCredential.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"entraTokenCredential.js","sourceRoot":"","sources":["../../src/entraTokenCredential.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAQlC,yDAAiE;AACjE,kEAKmC;AAEnC,MAAM,yBAAyB,GAAG,4CAA4C,CAAC;AAC/E,MAAM,+BAA+B,GAAG,0CAA0C,CAAC;AACnF,MAAM,sBAAsB,GAAG,yCAAyC,CAAC;AACzE,MAAM,wBAAwB,GAAG,oBAAoB,CAAC;AACtD,MAAM,4BAA4B,GAAG,oCAAoC,CAAC;AAC1E,MAAM,8BAA8B,GAAG,oBAAoB,CAAC;AA4B5D;;GAEG;AACH,MAAa,oBAAoB;IAS/B,YAAoB,OAA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GAAG,gBAAgB,GAAG,QAAQ,gBAAgB,UAAU,EAAE,CAAC;QAC9E,OAAO,UAAU,CAAC;IACpB,CAAC;IAEO,8BAA8B;QACpC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC7D,MAAM,IAAI,KAAK,CACb,iIAAiI,CAClI,CAAC;QACJ,CAAC;aAAM,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,UAAU,CAAC,yBAAyB,CAAC,CAAC,EAAE,CAAC;YAC7F,OAAO,CAAC,sBAAsB,EAAE,wBAAwB,CAAC,CAAC;QAC5D,CAAC;aAAM,IACL,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,UAAU,CAAC,+BAA+B,CAAC,CAAC,EACvF,CAAC;YACD,OAAO,CAAC,4BAA4B,EAAE,8BAA8B,CAAC,CAAC;QACxE,CAAC;aAAM,CAAC;YACN,MAAM,IAAI,KAAK,CACb,iIAAiI,CAClI,CAAC;QACJ,CAAC;IACH,CAAC;CACF;AAxID,oDAwIC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { type AccessToken, type TokenCredential } from \"@azure/core-auth\";\nimport {\n type TokenCredential as AcsTokenCredential,\n type CommunicationGetTokenOptions,\n} from \"./communicationTokenCredential.js\";\nimport { type AbortSignalLike } from \"@azure/abort-controller\";\nimport { type Client, getClient } from \"@azure-rest/core-client\";\nimport {\n type HttpClient,\n createDefaultHttpClient,\n createHttpHeaders,\n createPipelineRequest,\n} from \"@azure/core-rest-pipeline\";\n\nconst TeamsExtensionScopePrefix = \"https://auth.msft.communication.azure.com/\";\nconst CommunicationClientsScopePrefix = \"https://communication.azure.com/clients/\";\nconst TeamsExtensionEndpoint = \"/access/teamsPhone/:exchangeAccessToken\";\nconst TeamsExtensionApiVersion = \"2025-03-02-preview\";\nconst CommunicationClientsEndpoint = \"/access/entra/:exchangeAccessToken\";\nconst CommunicationClientsApiVersion = \"2024-04-01-preview\";\n\nexport interface ExchangeTokenResponse {\n identity: string;\n accessToken: {\n token: string;\n expiresOn: string;\n };\n}\n\n/**\n * The Entra Communication Token Options.\n */\nexport interface EntraCommunicationTokenCredentialOptions {\n /**\n * The Azure Communication Service resource endpoint URL, e.g. https://myResource.communication.azure.com.\n */\n resourceEndpoint: string;\n /**\n * The Entra ID token credential.\n */\n tokenCredential: TokenCredential;\n /**\n * The scopes for retrieving the Entra ID access token.\n */\n scopes?: string[];\n}\n\n/**\n * Represents a credential that exchanges an Entra token for an Azure Communication Services (ACS) token, enabling access to ACS resources.\n */\nexport class EntraTokenCredential implements AcsTokenCredential {\n private isPending: Promise<AccessToken> | null;\n private result = {\n entraToken: undefined as string | undefined,\n acsToken: { token: \"\", expiresOnTimestamp: 0 },\n };\n private client: Client;\n private httpClient: HttpClient;\n\n constructor(private options: EntraCommunicationTokenCredentialOptions) {\n this.client = getClient(options.resourceEndpoint);\n this.httpClient = createDefaultHttpClient();\n this.options = options;\n this.options.scopes = this.options.scopes || [\n \"https://communication.azure.com/clients/.default\",\n ];\n\n // immediately fetch the token to pre-warm\n this.isPending = this.getToken();\n }\n\n public async getToken(options?: CommunicationGetTokenOptions): Promise<AccessToken> {\n if (options?.abortSignal?.aborted) {\n return { token: \"\", expiresOnTimestamp: 0 };\n }\n\n // we're awaiting the token fetch, so we don't want to start another one\n // however, we're ignoring the new abortSignal, unfortunately\n if (!this.isPending) {\n this.isPending = this.getTokenInternal(options);\n }\n\n try {\n await this.isPending;\n } finally {\n this.isPending = null;\n }\n\n return this.result.acsToken;\n }\n\n private async getTokenInternal(options?: CommunicationGetTokenOptions): Promise<AccessToken> {\n const getTokenOptions = options?.abortSignal ? { abortSignal: options.abortSignal } : undefined;\n const token = await this.options.tokenCredential.getToken(\n this.options.scopes\n ? this.options.scopes\n : [\"https://communication.azure.com/clients/.default\"],\n getTokenOptions,\n );\n const currentDateTime = new Date();\n const tokenExpiresOn = new Date(this.result.acsToken.expiresOnTimestamp);\n\n if (token === null) {\n this.result = {\n entraToken: undefined,\n acsToken: { token: \"\", expiresOnTimestamp: 0 },\n };\n } else if (\n this.result.acsToken.token === \"\" ||\n token.token !== this.result.entraToken ||\n tokenExpiresOn < currentDateTime\n ) {\n const acsToken = await this.exchangeEntraToken(\n this.options.resourceEndpoint,\n token.token,\n getTokenOptions,\n );\n this.result = {\n entraToken: token.token,\n acsToken,\n };\n }\n\n return this.result.acsToken;\n }\n\n public dispose(): void {\n this.result = {\n entraToken: undefined,\n acsToken: { token: \"\", expiresOnTimestamp: 0 },\n };\n }\n\n private async exchangeEntraToken(\n resourceEndpoint: string,\n entraToken: string,\n options?: { abortSignal: AbortSignalLike },\n ): Promise<AccessToken> {\n const request = createPipelineRequest({\n url: this.createRequestUri(resourceEndpoint),\n method: \"POST\",\n headers: createHttpHeaders({\n Authorization: `Bearer ${entraToken}`,\n \"Content-Type\": \"application/json\",\n Accept: \"application/json\",\n }),\n abortSignal: options?.abortSignal,\n body: JSON.stringify({}),\n });\n const response = await this.client.pipeline.sendRequest(this.httpClient, request);\n\n if (response.status !== 200 || !response.bodyAsText) {\n throw new Error(\n `Service request failed. Status: ${response.status}, Body: ${response.bodyAsText}`,\n );\n }\n const json = JSON.parse(response.bodyAsText) as ExchangeTokenResponse;\n return {\n token: json.accessToken.token,\n expiresOnTimestamp: Date.parse(json.accessToken.expiresOn),\n };\n }\n\n private createRequestUri(resourceEndpoint: string): string {\n const [endpoint, apiVersion] = this.determineEndpointAndApiVersion();\n const requestUri = `${resourceEndpoint}${endpoint}?api-version=${apiVersion}`;\n return requestUri;\n }\n\n private determineEndpointAndApiVersion(): [string, string] {\n if (!this.options.scopes || this.options.scopes.length === 0) {\n throw new Error(\n `Scopes validation failed. Ensure all scopes start with either {TeamsExtensionScopePrefix} or {CommunicationClientsScopePrefix}.`,\n );\n } else if (this.options.scopes.every((scope) => scope.startsWith(TeamsExtensionScopePrefix))) {\n return [TeamsExtensionEndpoint, TeamsExtensionApiVersion];\n } else if (\n this.options.scopes.every((scope) => scope.startsWith(CommunicationClientsScopePrefix))\n ) {\n return [CommunicationClientsEndpoint, CommunicationClientsApiVersion];\n } else {\n throw new Error(\n `Scopes validation failed. Ensure all scopes start with either {TeamsExtensionScopePrefix} or {CommunicationClientsScopePrefix}.`,\n );\n }\n }\n}\n"]}