@azure/communication-common 2.3.2-alpha.20250122.7 → 2.3.2-alpha.20250127.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +34 -49
- package/dist/browser/azureCommunicationTokenCredential.d.ts +0 -6
- package/dist/browser/azureCommunicationTokenCredential.d.ts.map +1 -1
- package/dist/browser/azureCommunicationTokenCredential.js +4 -8
- package/dist/browser/azureCommunicationTokenCredential.js.map +1 -1
- package/dist/browser/index.d.ts +1 -1
- package/dist/browser/index.d.ts.map +1 -1
- package/dist/browser/index.js +1 -0
- package/dist/browser/index.js.map +1 -1
- package/dist/commonjs/azureCommunicationTokenCredential.d.ts +0 -6
- package/dist/commonjs/azureCommunicationTokenCredential.d.ts.map +1 -1
- package/dist/commonjs/azureCommunicationTokenCredential.js +4 -8
- package/dist/commonjs/azureCommunicationTokenCredential.js.map +1 -1
- package/dist/commonjs/index.d.ts +1 -1
- package/dist/commonjs/index.d.ts.map +1 -1
- package/dist/commonjs/index.js +1 -0
- package/dist/commonjs/index.js.map +1 -1
- package/dist/esm/azureCommunicationTokenCredential.d.ts +0 -6
- package/dist/esm/azureCommunicationTokenCredential.d.ts.map +1 -1
- package/dist/esm/azureCommunicationTokenCredential.js +4 -8
- package/dist/esm/azureCommunicationTokenCredential.js.map +1 -1
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/react-native/azureCommunicationTokenCredential.d.ts +0 -6
- package/dist/react-native/azureCommunicationTokenCredential.d.ts.map +1 -1
- package/dist/react-native/azureCommunicationTokenCredential.js +4 -8
- package/dist/react-native/azureCommunicationTokenCredential.js.map +1 -1
- package/dist/react-native/index.d.ts +1 -1
- package/dist/react-native/index.d.ts.map +1 -1
- package/dist/react-native/index.js +1 -0
- package/dist/react-native/index.js.map +1 -1
- package/package.json +11 -25
- package/dist/browser/entraTokenCredential.d.ts +0 -45
- package/dist/browser/entraTokenCredential.d.ts.map +0 -1
- package/dist/browser/entraTokenCredential.js +0 -120
- package/dist/browser/entraTokenCredential.js.map +0 -1
- package/dist/commonjs/entraTokenCredential.d.ts +0 -45
- package/dist/commonjs/entraTokenCredential.d.ts.map +0 -1
- package/dist/commonjs/entraTokenCredential.js +0 -124
- package/dist/commonjs/entraTokenCredential.js.map +0 -1
- package/dist/esm/entraTokenCredential.d.ts +0 -45
- package/dist/esm/entraTokenCredential.d.ts.map +0 -1
- package/dist/esm/entraTokenCredential.js +0 -120
- package/dist/esm/entraTokenCredential.js.map +0 -1
- package/dist/react-native/entraTokenCredential.d.ts +0 -45
- package/dist/react-native/entraTokenCredential.d.ts.map +0 -1
- package/dist/react-native/entraTokenCredential.js +0 -120
- package/dist/react-native/entraTokenCredential.js.map +0 -1
package/README.md
CHANGED
|
@@ -8,7 +8,6 @@ This package contains common code for Azure Communication Service libraries.
|
|
|
8
8
|
|
|
9
9
|
- An [Azure subscription][azure_sub].
|
|
10
10
|
- An existing Communication Services resource. If you need to create the resource, you can use the [Azure Portal][azure_portal], the [Azure PowerShell][azure_powershell], or the [Azure CLI][azure_cli].
|
|
11
|
-
- Having the @azure/identity package installed.
|
|
12
11
|
|
|
13
12
|
### Installing
|
|
14
13
|
|
|
@@ -16,10 +15,6 @@ This package contains common code for Azure Communication Service libraries.
|
|
|
16
15
|
npm install @azure/communication-common
|
|
17
16
|
```
|
|
18
17
|
|
|
19
|
-
```bash
|
|
20
|
-
npm install @azure/identity
|
|
21
|
-
```
|
|
22
|
-
|
|
23
18
|
### Browser support
|
|
24
19
|
|
|
25
20
|
#### JavaScript Bundle
|
|
@@ -38,7 +33,6 @@ Depending on your scenario, you may want to initialize the `AzureCommunicationTo
|
|
|
38
33
|
|
|
39
34
|
- a static token (suitable for short-lived clients used to e.g. send one-off Chat messages) or
|
|
40
35
|
- a callback function that ensures a continuous authentication state during communications (ideal e.g. for long Calling sessions).
|
|
41
|
-
- a token credential capable of obtaining an Entra user token. You can provide any implementation of [TokenCredential interface](https://learn.microsoft.com/es-mx/javascript/api/@azure/core-auth/tokencredential?view=azure-node-latest). It is suitable for scenarios where Entra user access tokens are needed to authenticate with Communication Services.
|
|
42
36
|
|
|
43
37
|
The tokens supplied to the `AzureCommunicationTokenCredential` either through the constructor or via the token refresher callback can be obtained using the Azure Communication Identity library.
|
|
44
38
|
|
|
@@ -48,7 +42,9 @@ The tokens supplied to the `AzureCommunicationTokenCredential` either through th
|
|
|
48
42
|
|
|
49
43
|
For a short-lived clients, refreshing the token upon expiry is not necessary and the `AzureCommunicationTokenCredential` may be instantiated with a static token.
|
|
50
44
|
|
|
51
|
-
```
|
|
45
|
+
```ts snippet:ReadmeSampleCredentialStaticToken
|
|
46
|
+
import { AzureCommunicationTokenCredential } from "@azure/communication-common";
|
|
47
|
+
|
|
52
48
|
const tokenCredential = new AzureCommunicationTokenCredential(
|
|
53
49
|
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjM2MDB9.adM-ddBZZlQ1WlN3pdPBOF5G4Wh9iZpxNP_fSvpF4cWs",
|
|
54
50
|
);
|
|
@@ -58,7 +54,14 @@ const tokenCredential = new AzureCommunicationTokenCredential(
|
|
|
58
54
|
|
|
59
55
|
Here we assume that we have a function `fetchTokenFromMyServerForUser` that makes a network request to retrieve a JWT token string for a user. We pass it into the credential to fetch a token for Bob from our own server. Our server would use the Azure Communication Identity library to issue tokens. It's necessary that the `fetchTokenFromMyServerForUser` function returns a valid token (with an expiration date set in the future) at all times.
|
|
60
56
|
|
|
61
|
-
```
|
|
57
|
+
```ts snippet:ReadmeSampleCredentialCallback
|
|
58
|
+
import { AzureCommunicationTokenCredential } from "@azure/communication-common";
|
|
59
|
+
|
|
60
|
+
function fetchTokenFromMyServerForUser(user: string): Promise<string> {
|
|
61
|
+
// Your custom implementation to fetch a token for the user
|
|
62
|
+
return Promise.resolve("some-unique-token-for-" + user);
|
|
63
|
+
}
|
|
64
|
+
|
|
62
65
|
const tokenCredential = new AzureCommunicationTokenCredential({
|
|
63
66
|
tokenRefresher: async () => fetchTokenFromMyServerForUser("bob@contoso.com"),
|
|
64
67
|
});
|
|
@@ -68,7 +71,14 @@ const tokenCredential = new AzureCommunicationTokenCredential({
|
|
|
68
71
|
|
|
69
72
|
Setting `refreshProactively` to true will call your `tokenRefresher` function when the token is close to expiry.
|
|
70
73
|
|
|
71
|
-
```
|
|
74
|
+
```ts snippet:ReadmeSampleCredentialProactiveRefresh
|
|
75
|
+
import { AzureCommunicationTokenCredential } from "@azure/communication-common";
|
|
76
|
+
|
|
77
|
+
function fetchTokenFromMyServerForUser(user: string): Promise<string> {
|
|
78
|
+
// Your custom implementation to fetch a token for the user
|
|
79
|
+
return Promise.resolve("some-unique-token-for-" + user);
|
|
80
|
+
}
|
|
81
|
+
|
|
72
82
|
const tokenCredential = new AzureCommunicationTokenCredential({
|
|
73
83
|
tokenRefresher: async () => fetchTokenFromMyServerForUser("bob@contoso.com"),
|
|
74
84
|
refreshProactively: true,
|
|
@@ -79,7 +89,14 @@ const tokenCredential = new AzureCommunicationTokenCredential({
|
|
|
79
89
|
|
|
80
90
|
Passing `initialToken` is an optional optimization to skip the first call to `tokenRefresher`. You can use this to separate the boot from your application from subsequent token refresh cycles.
|
|
81
91
|
|
|
82
|
-
```
|
|
92
|
+
```ts snippet:ReadmeSampleCredentialProactiveRefreshWithInitialToken
|
|
93
|
+
import { AzureCommunicationTokenCredential } from "@azure/communication-common";
|
|
94
|
+
|
|
95
|
+
function fetchTokenFromMyServerForUser(user: string): Promise<string> {
|
|
96
|
+
// Your custom implementation to fetch a token for the user
|
|
97
|
+
return Promise.resolve("some-unique-token-for-" + user);
|
|
98
|
+
}
|
|
99
|
+
|
|
83
100
|
const tokenCredential = new AzureCommunicationTokenCredential({
|
|
84
101
|
tokenRefresher: async () => fetchTokenFromMyServerForUser("bob@contoso.com"),
|
|
85
102
|
refreshProactively: true,
|
|
@@ -88,51 +105,19 @@ const tokenCredential = new AzureCommunicationTokenCredential({
|
|
|
88
105
|
});
|
|
89
106
|
```
|
|
90
107
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
For scenarios where an Entra user can be used with Communication Services, you need to initialize any implementation of [TokenCredential interface](https://learn.microsoft.com/es-mx/javascript/api/@azure/core-auth/tokencredential?view=azure-node-latest) and provide it to the ``EntraCommunicationTokenCredentialOptions``.
|
|
94
|
-
Along with this, you must provide the URI of the Azure Communication Services resource and the scopes required for the Entra user token. These scopes determine the permissions granted to the token.
|
|
95
|
-
If the scopes are not provided, by default, it sets the scopes to `https://communication.azure.com/clients/.default`.
|
|
96
|
-
|
|
97
|
-
```typescript
|
|
98
|
-
const options: InteractiveBrowserCredentialInBrowserOptions = {
|
|
99
|
-
tenantId: "<your-tenant-id>",
|
|
100
|
-
clientId: "<your-client-id>",
|
|
101
|
-
redirectUri: "<your-redirect-uri>",
|
|
102
|
-
};
|
|
103
|
-
const entraTokenCredential = new InteractiveBrowserCredential(options);
|
|
104
|
-
|
|
105
|
-
const entraTokenCredentialOptions: EntraCommunicationTokenCredentialOptions = {
|
|
106
|
-
resourceEndpoint: "https://<your-resource>.communication.azure.com",
|
|
107
|
-
tokenCredential: entraTokenCredential,
|
|
108
|
-
scopes: ["https://communication.azure.com/clients/VoIP"]
|
|
109
|
-
};
|
|
108
|
+
## Troubleshooting
|
|
110
109
|
|
|
111
|
-
|
|
112
|
-
```
|
|
110
|
+
- **Invalid token specified**: Make sure the token you are passing to the `AzureCommunicationTokenCredential` constructor or to the `tokenRefresher` callback is a bare JWT token string. E.g. if you're using the [Azure Communication Identity library][invalid_token_sdk] or [REST API][invalid_token_rest] to obtain the token, make sure you're passing just the `token` part of the response object.
|
|
113
111
|
|
|
114
|
-
|
|
115
|
-
This requires providing the `https://auth.msft.communication.azure.com/TeamsExtension.ManageCalls` scope.
|
|
112
|
+
### Logging
|
|
116
113
|
|
|
117
|
-
|
|
118
|
-
const options: InteractiveBrowserCredentialInBrowserOptions = {
|
|
119
|
-
tenantId: "<your-tenant-id>",
|
|
120
|
-
clientId: "<your-client-id>",
|
|
121
|
-
redirectUri: "<your-redirect-uri>",
|
|
122
|
-
};
|
|
123
|
-
const entraTokenCredential = new InteractiveBrowserCredential(options);
|
|
114
|
+
Enabling logging may help uncover useful information about failures. In order to see a log of HTTP requests and responses, set the `AZURE_LOG_LEVEL` environment variable to `info`. Alternatively, logging can be enabled at runtime by calling `setLogLevel` in the `@azure/logger`:
|
|
124
115
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
tokenCredential: entraTokenCredential,
|
|
128
|
-
scopes: ["https://auth.msft.communication.azure.com/TeamsExtension.ManageCalls"]
|
|
129
|
-
};
|
|
116
|
+
```ts snippet:SetLogLevel
|
|
117
|
+
import { setLogLevel } from "@azure/logger";
|
|
130
118
|
|
|
131
|
-
|
|
119
|
+
setLogLevel("info");
|
|
132
120
|
```
|
|
133
|
-
## Troubleshooting
|
|
134
|
-
|
|
135
|
-
- **Invalid token specified**: Make sure the token you are passing to the `AzureCommunicationTokenCredential` constructor or to the `tokenRefresher` callback is a bare JWT token string. E.g. if you're using the [Azure Communication Identity library][invalid_token_sdk] or [REST API][invalid_token_rest] to obtain the token, make sure you're passing just the `token` part of the response object.
|
|
136
121
|
|
|
137
122
|
## Next steps
|
|
138
123
|
|
|
@@ -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;
|
|
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(
|
|
10
|
+
constructor(tokenOrRefreshOptions) {
|
|
12
11
|
this.disposed = false;
|
|
13
|
-
if (typeof
|
|
14
|
-
this.tokenCredential = new StaticTokenCredential(parseToken(
|
|
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
|
|
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;
|
|
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"]}
|
package/dist/browser/index.d.ts
CHANGED
|
@@ -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,
|
|
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"}
|
package/dist/browser/index.js
CHANGED
|
@@ -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;
|
|
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,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;
|
|
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"}
|
|
@@ -6,21 +6,17 @@ exports.AzureCommunicationTokenCredential = void 0;
|
|
|
6
6
|
const autoRefreshTokenCredential_js_1 = require("./autoRefreshTokenCredential.js");
|
|
7
7
|
const staticTokenCredential_js_1 = require("./staticTokenCredential.js");
|
|
8
8
|
const tokenParser_js_1 = require("./tokenParser.js");
|
|
9
|
-
const entraTokenCredential_js_1 = require("./entraTokenCredential.js");
|
|
10
9
|
/**
|
|
11
10
|
* The CommunicationTokenCredential implementation with support for proactive token refresh.
|
|
12
11
|
*/
|
|
13
12
|
class AzureCommunicationTokenCredential {
|
|
14
|
-
constructor(
|
|
13
|
+
constructor(tokenOrRefreshOptions) {
|
|
15
14
|
this.disposed = false;
|
|
16
|
-
if (typeof
|
|
17
|
-
this.tokenCredential = new staticTokenCredential_js_1.StaticTokenCredential((0, tokenParser_js_1.parseToken)(
|
|
18
|
-
}
|
|
19
|
-
else if ("tokenRefresher" in tokenOrRefreshOptionsOrEntraOptions) {
|
|
20
|
-
this.tokenCredential = new autoRefreshTokenCredential_js_1.AutoRefreshTokenCredential(tokenOrRefreshOptionsOrEntraOptions);
|
|
15
|
+
if (typeof tokenOrRefreshOptions === "string") {
|
|
16
|
+
this.tokenCredential = new staticTokenCredential_js_1.StaticTokenCredential((0, tokenParser_js_1.parseToken)(tokenOrRefreshOptions));
|
|
21
17
|
}
|
|
22
18
|
else {
|
|
23
|
-
this.tokenCredential = new
|
|
19
|
+
this.tokenCredential = new autoRefreshTokenCredential_js_1.AutoRefreshTokenCredential(tokenOrRefreshOptions);
|
|
24
20
|
}
|
|
25
21
|
}
|
|
26
22
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"azureCommunicationTokenCredential.js","sourceRoot":"","sources":["../../src/azureCommunicationTokenCredential.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAElC,mFAGyC;AAOzC,yEAAmE;AACnE,qDAA8C;
|
|
1
|
+
{"version":3,"file":"azureCommunicationTokenCredential.js","sourceRoot":"","sources":["../../src/azureCommunicationTokenCredential.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAElC,mFAGyC;AAOzC,yEAAmE;AACnE,qDAA8C;AAE9C;;GAEG;AAEH,MAAa,iCAAiC;IAe5C,YAAY,qBAAgE;QAbpE,aAAQ,GAAG,KAAK,CAAC;QAcvB,IAAI,OAAO,qBAAqB,KAAK,QAAQ,EAAE,CAAC;YAC9C,IAAI,CAAC,eAAe,GAAG,IAAI,gDAAqB,CAAC,IAAA,2BAAU,EAAC,qBAAqB,CAAC,CAAC,CAAC;QACtF,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,eAAe,GAAG,IAAI,0DAA0B,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;AA/CD,8EA+CC","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"]}
|
package/dist/commonjs/index.d.ts
CHANGED
|
@@ -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,
|
|
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"}
|
package/dist/commonjs/index.js
CHANGED
|
@@ -7,6 +7,7 @@ const tslib_1 = require("tslib");
|
|
|
7
7
|
var azureCommunicationTokenCredential_js_1 = require("./azureCommunicationTokenCredential.js");
|
|
8
8
|
Object.defineProperty(exports, "AzureCommunicationTokenCredential", { enumerable: true, get: function () { return azureCommunicationTokenCredential_js_1.AzureCommunicationTokenCredential; } });
|
|
9
9
|
tslib_1.__exportStar(require("./credential/index.js"), exports);
|
|
10
|
+
tslib_1.__exportStar(require("./credential/index.js"), exports);
|
|
10
11
|
tslib_1.__exportStar(require("./identifierModels.js"), exports);
|
|
11
12
|
tslib_1.__exportStar(require("./identifierModelSerializer.js"), exports);
|
|
12
13
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;;AAMlC,+FAA2F;AAAlF,yJAAA,iCAAiC,OAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;;AAMlC,+FAA2F;AAAlF,yJAAA,iCAAiC,OAAA;AAC1C,gEAAsC;AAEtC,gEAAsC;AACtC,gEAAsC;AACtC,yEAA+C","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,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;
|
|
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(
|
|
10
|
+
constructor(tokenOrRefreshOptions) {
|
|
12
11
|
this.disposed = false;
|
|
13
|
-
if (typeof
|
|
14
|
-
this.tokenCredential = new StaticTokenCredential(parseToken(
|
|
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
|
|
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;
|
|
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"]}
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -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";
|
package/dist/esm/index.d.ts.map
CHANGED
|
@@ -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,
|
|
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"}
|
package/dist/esm/index.js
CHANGED
|
@@ -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
|
package/dist/esm/index.js.map
CHANGED
|
@@ -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;
|
|
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,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;
|
|
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(
|
|
10
|
+
constructor(tokenOrRefreshOptions) {
|
|
12
11
|
this.disposed = false;
|
|
13
|
-
if (typeof
|
|
14
|
-
this.tokenCredential = new StaticTokenCredential(parseToken(
|
|
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
|
|
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;
|
|
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,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,
|
|
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;
|
|
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"]}
|