@azure/identity 1.0.0-preview.1 → 1.0.0-preview.2
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.
Potentially problematic release.
This version of @azure/identity might be problematic. Click here for more details.
- package/CHANGELOG.md +24 -0
- package/README.md +50 -23
- package/browser/identity.js +9828 -0
- package/browser/identity.js.map +1 -0
- package/browser/identity.min.js +2 -0
- package/browser/identity.min.js.map +1 -0
- package/dist/index.js +475 -205
- package/dist/index.js.map +1 -1
- package/dist-esm/src/client/errors.d.ts +1 -1
- package/dist-esm/src/client/errors.d.ts.map +1 -1
- package/dist-esm/src/client/errors.js +9 -1
- package/dist-esm/src/client/errors.js.map +1 -1
- package/dist-esm/src/client/identityClient.d.ts +20 -17
- package/dist-esm/src/client/identityClient.d.ts.map +1 -1
- package/dist-esm/src/client/identityClient.js +42 -206
- package/dist-esm/src/client/identityClient.js.map +1 -1
- package/dist-esm/src/credentials/clientCertificateCredential.browser.d.ts +7 -0
- package/dist-esm/src/credentials/clientCertificateCredential.browser.d.ts.map +1 -0
- package/dist-esm/src/credentials/clientCertificateCredential.browser.js +12 -0
- package/dist-esm/src/credentials/clientCertificateCredential.browser.js.map +1 -0
- package/dist-esm/src/credentials/clientCertificateCredential.d.ts +5 -5
- package/dist-esm/src/credentials/clientCertificateCredential.d.ts.map +1 -1
- package/dist-esm/src/credentials/clientCertificateCredential.js +59 -5
- package/dist-esm/src/credentials/clientCertificateCredential.js.map +1 -1
- package/dist-esm/src/credentials/clientSecretCredential.d.ts +3 -3
- package/dist-esm/src/credentials/clientSecretCredential.d.ts.map +1 -1
- package/dist-esm/src/credentials/clientSecretCredential.js +27 -4
- package/dist-esm/src/credentials/clientSecretCredential.js.map +1 -1
- package/dist-esm/src/credentials/deviceCodeCredential.browser.d.ts +7 -0
- package/dist-esm/src/credentials/deviceCodeCredential.browser.d.ts.map +1 -0
- package/dist-esm/src/credentials/deviceCodeCredential.browser.js +12 -0
- package/dist-esm/src/credentials/deviceCodeCredential.browser.js.map +1 -0
- package/dist-esm/src/credentials/deviceCodeCredential.d.ts +67 -0
- package/dist-esm/src/credentials/deviceCodeCredential.d.ts.map +1 -0
- package/dist-esm/src/credentials/deviceCodeCredential.js +139 -0
- package/dist-esm/src/credentials/deviceCodeCredential.js.map +1 -0
- package/dist-esm/src/credentials/environmentCredential.browser.d.ts +7 -0
- package/dist-esm/src/credentials/environmentCredential.browser.d.ts.map +1 -0
- package/dist-esm/src/credentials/environmentCredential.browser.js +12 -0
- package/dist-esm/src/credentials/environmentCredential.browser.js.map +1 -0
- package/dist-esm/src/credentials/environmentCredential.d.ts.map +1 -1
- package/dist-esm/src/credentials/environmentCredential.js +0 -4
- package/dist-esm/src/credentials/environmentCredential.js.map +1 -1
- package/dist-esm/src/credentials/interactiveBrowserCredential.browser.d.ts +32 -0
- package/dist-esm/src/credentials/interactiveBrowserCredential.browser.d.ts.map +1 -0
- package/dist-esm/src/credentials/interactiveBrowserCredential.browser.js +112 -0
- package/dist-esm/src/credentials/interactiveBrowserCredential.browser.js.map +1 -0
- package/dist-esm/src/credentials/interactiveBrowserCredential.d.ts +12 -0
- package/dist-esm/src/credentials/interactiveBrowserCredential.d.ts.map +1 -0
- package/dist-esm/src/credentials/interactiveBrowserCredential.js +17 -0
- package/dist-esm/src/credentials/interactiveBrowserCredential.js.map +1 -0
- package/dist-esm/src/credentials/interactiveBrowserCredentialOptions.d.ts +24 -0
- package/dist-esm/src/credentials/interactiveBrowserCredentialOptions.d.ts.map +1 -0
- package/dist-esm/src/credentials/interactiveBrowserCredentialOptions.js +3 -0
- package/dist-esm/src/credentials/interactiveBrowserCredentialOptions.js.map +1 -0
- package/dist-esm/src/credentials/managedIdentityCredential.browser.d.ts +7 -0
- package/dist-esm/src/credentials/managedIdentityCredential.browser.d.ts.map +1 -0
- package/dist-esm/src/credentials/managedIdentityCredential.browser.js +15 -0
- package/dist-esm/src/credentials/managedIdentityCredential.browser.js.map +1 -0
- package/dist-esm/src/credentials/managedIdentityCredential.d.ts +10 -1
- package/dist-esm/src/credentials/managedIdentityCredential.d.ts.map +1 -1
- package/dist-esm/src/credentials/managedIdentityCredential.js +144 -2
- package/dist-esm/src/credentials/managedIdentityCredential.js.map +1 -1
- package/dist-esm/src/credentials/usernamePasswordCredential.d.ts +39 -0
- package/dist-esm/src/credentials/usernamePasswordCredential.d.ts.map +1 -0
- package/dist-esm/src/credentials/usernamePasswordCredential.js +67 -0
- package/dist-esm/src/credentials/usernamePasswordCredential.js.map +1 -0
- package/dist-esm/src/index.d.ts +4 -0
- package/dist-esm/src/index.d.ts.map +1 -1
- package/dist-esm/src/index.js +3 -0
- package/dist-esm/src/index.js.map +1 -1
- package/package.json +32 -14
- package/src/client/errors.ts +11 -3
- package/src/client/identityClient.ts +64 -246
- package/src/credentials/clientCertificateCredential.browser.ts +27 -0
- package/src/credentials/clientCertificateCredential.ts +72 -22
- package/src/credentials/clientSecretCredential.ts +32 -17
- package/src/credentials/deviceCodeCredential.browser.ts +27 -0
- package/src/credentials/deviceCodeCredential.ts +203 -0
- package/src/credentials/environmentCredential.browser.ts +19 -0
- package/src/credentials/environmentCredential.ts +5 -9
- package/src/credentials/interactiveBrowserCredential.browser.ts +134 -0
- package/src/credentials/interactiveBrowserCredential.ts +31 -0
- package/src/credentials/interactiveBrowserCredentialOptions.ts +30 -0
- package/src/credentials/managedIdentityCredential.browser.ts +22 -0
- package/src/credentials/managedIdentityCredential.ts +179 -8
- package/src/credentials/usernamePasswordCredential.ts +83 -0
- package/src/index.ts +4 -0
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { TokenCredential, GetTokenOptions, AccessToken } from "@azure/core-http";
|
|
2
|
+
import { IdentityClientOptions } from "../client/identityClient";
|
|
3
|
+
/**
|
|
4
|
+
* An internal interface that contains the verbatim devicecode response.
|
|
5
|
+
* This interface does not get exported from the public interface of the
|
|
6
|
+
* library.
|
|
7
|
+
*/
|
|
8
|
+
export interface DeviceCodeResponse {
|
|
9
|
+
device_code: string;
|
|
10
|
+
user_code: string;
|
|
11
|
+
verification_uri: string;
|
|
12
|
+
expires_in: number;
|
|
13
|
+
interval: number;
|
|
14
|
+
message: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Provides the user code and verification URI where the code must be
|
|
18
|
+
* entered. Also provides a message to display to the user which
|
|
19
|
+
* contains an instruction with these details.
|
|
20
|
+
*/
|
|
21
|
+
export interface DeviceCodeDetails {
|
|
22
|
+
userCode: string;
|
|
23
|
+
verificationUri: string;
|
|
24
|
+
message: string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Defines the signature of a callback which will be passed to
|
|
28
|
+
* DeviceCodeCredential for the purpose of displaying authentication
|
|
29
|
+
* details to the user.
|
|
30
|
+
*/
|
|
31
|
+
export declare type DeviceCodePromptCallback = (deviceCodeDetails: DeviceCodeDetails) => void;
|
|
32
|
+
/**
|
|
33
|
+
* Enables authentication to Azure Active Directory using a device code
|
|
34
|
+
* that the user can enter into https://microsoft.com/devicelogin.
|
|
35
|
+
*/
|
|
36
|
+
export declare class DeviceCodeCredential implements TokenCredential {
|
|
37
|
+
private identityClient;
|
|
38
|
+
private tenantId;
|
|
39
|
+
private clientId;
|
|
40
|
+
private userPromptCallback;
|
|
41
|
+
private lastTokenResponse;
|
|
42
|
+
/**
|
|
43
|
+
* Creates an instance of DeviceCodeCredential with the details needed
|
|
44
|
+
* to initiate the device code authorization flow with Azure Active Directory.
|
|
45
|
+
*
|
|
46
|
+
* @param tenantId The Azure Active Directory tenant (directory) ID or name.
|
|
47
|
+
* @param clientId The client (application) ID of an App Registration in the tenant.
|
|
48
|
+
* @param userPromptCallback A callback function that will be invoked to show
|
|
49
|
+
{@link DeviceCodeDetails} to the user.
|
|
50
|
+
* @param options Options for configuring the client which makes the authentication request.
|
|
51
|
+
*/
|
|
52
|
+
constructor(tenantId: string, clientId: string, userPromptCallback: DeviceCodePromptCallback, options?: IdentityClientOptions);
|
|
53
|
+
private sendDeviceCodeRequest;
|
|
54
|
+
private pollForToken;
|
|
55
|
+
/**
|
|
56
|
+
* Authenticates with Azure Active Directory and returns an {@link AccessToken} if
|
|
57
|
+
* successful. If authentication cannot be performed at this time, this method may
|
|
58
|
+
* return null. If an error occurs during authentication, an {@link AuthenticationError}
|
|
59
|
+
* containing failure details will be thrown.
|
|
60
|
+
*
|
|
61
|
+
* @param scopes The list of scopes for which the token will have access.
|
|
62
|
+
* @param options The options used to configure any requests this
|
|
63
|
+
* TokenCredential implementation might make.
|
|
64
|
+
*/
|
|
65
|
+
getToken(scopes: string | string[], options?: GetTokenOptions): Promise<AccessToken | null>;
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=deviceCodeCredential.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deviceCodeCredential.d.ts","sourceRoot":"","sources":["../../../src/credentials/deviceCodeCredential.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,WAAW,EAAS,MAAM,kBAAkB,CAAC;AACxF,OAAO,EAAE,qBAAqB,EAAiC,MAAM,0BAA0B,CAAC;AAGhG;;;;GAIG;AACH,MAAM,WAAW,kBAAkB;IACjC,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,gBAAgB,EAAE,MAAM,CAAC;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAA;CAChB;AAED;;;;GAIG;AACH,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,MAAM,CAAC;IACjB,eAAe,EAAE,MAAM,CAAC;IACxB,OAAO,EAAE,MAAM,CAAA;CAChB;AAED;;;;GAIG;AACH,oBAAY,wBAAwB,GAAG,CAAC,iBAAiB,EAAE,iBAAiB,KAAK,IAAI,CAAC;AAEtF;;;GAGG;AACH,qBAAa,oBAAqB,YAAW,eAAe;IAC1D,OAAO,CAAC,cAAc,CAAiB;IACvC,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,kBAAkB,CAA2B;IACrD,OAAO,CAAC,iBAAiB,CAA8B;IAEvD;;;;;;;;;OASG;gBAED,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,kBAAkB,EAAE,wBAAwB,EAC5C,OAAO,CAAC,EAAE,qBAAqB;YAQnB,qBAAqB;YA4BrB,YAAY;IAsD1B;;;;;;;;;OASG;IACU,QAAQ,CACnB,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,EACzB,OAAO,CAAC,EAAE,eAAe,GACxB,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC;CAkC/B"}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation.
|
|
2
|
+
// Licensed under the MIT License.
|
|
3
|
+
import * as tslib_1 from "tslib";
|
|
4
|
+
import qs from "qs";
|
|
5
|
+
import { delay } from "@azure/core-http";
|
|
6
|
+
import { IdentityClient } from "../client/identityClient";
|
|
7
|
+
import { AuthenticationError } from "../client/errors";
|
|
8
|
+
/**
|
|
9
|
+
* Enables authentication to Azure Active Directory using a device code
|
|
10
|
+
* that the user can enter into https://microsoft.com/devicelogin.
|
|
11
|
+
*/
|
|
12
|
+
export class DeviceCodeCredential {
|
|
13
|
+
/**
|
|
14
|
+
* Creates an instance of DeviceCodeCredential with the details needed
|
|
15
|
+
* to initiate the device code authorization flow with Azure Active Directory.
|
|
16
|
+
*
|
|
17
|
+
* @param tenantId The Azure Active Directory tenant (directory) ID or name.
|
|
18
|
+
* @param clientId The client (application) ID of an App Registration in the tenant.
|
|
19
|
+
* @param userPromptCallback A callback function that will be invoked to show
|
|
20
|
+
{@link DeviceCodeDetails} to the user.
|
|
21
|
+
* @param options Options for configuring the client which makes the authentication request.
|
|
22
|
+
*/
|
|
23
|
+
constructor(tenantId, clientId, userPromptCallback, options) {
|
|
24
|
+
this.lastTokenResponse = null;
|
|
25
|
+
this.identityClient = new IdentityClient(options);
|
|
26
|
+
this.tenantId = tenantId;
|
|
27
|
+
this.clientId = clientId;
|
|
28
|
+
this.userPromptCallback = userPromptCallback;
|
|
29
|
+
}
|
|
30
|
+
sendDeviceCodeRequest(scope, options) {
|
|
31
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
32
|
+
const webResource = this.identityClient.createWebResource({
|
|
33
|
+
url: `${this.identityClient.authorityHost}/${this.tenantId}/oauth2/v2.0/devicecode`,
|
|
34
|
+
method: "POST",
|
|
35
|
+
disableJsonStringifyOnBody: true,
|
|
36
|
+
deserializationMapper: undefined,
|
|
37
|
+
body: qs.stringify({
|
|
38
|
+
client_id: this.clientId,
|
|
39
|
+
scope
|
|
40
|
+
}),
|
|
41
|
+
headers: {
|
|
42
|
+
Accept: "application/json",
|
|
43
|
+
"Content-Type": "application/x-www-form-urlencoded"
|
|
44
|
+
},
|
|
45
|
+
abortSignal: options && options.abortSignal
|
|
46
|
+
});
|
|
47
|
+
const response = yield this.identityClient.sendRequest(webResource);
|
|
48
|
+
if (!(response.status === 200 || response.status === 201)) {
|
|
49
|
+
throw new AuthenticationError(response.status, response.bodyAsText);
|
|
50
|
+
}
|
|
51
|
+
return response.parsedBody;
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
pollForToken(deviceCodeResponse, options) {
|
|
55
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
56
|
+
let tokenResponse = null;
|
|
57
|
+
const webResource = this.identityClient.createWebResource({
|
|
58
|
+
url: `${this.identityClient.authorityHost}/${this.tenantId}/oauth2/v2.0/token`,
|
|
59
|
+
method: "POST",
|
|
60
|
+
disableJsonStringifyOnBody: true,
|
|
61
|
+
deserializationMapper: undefined,
|
|
62
|
+
body: qs.stringify({
|
|
63
|
+
grant_type: "urn:ietf:params:oauth:grant-type:device_code",
|
|
64
|
+
client_id: this.clientId,
|
|
65
|
+
device_code: deviceCodeResponse.device_code
|
|
66
|
+
}),
|
|
67
|
+
headers: {
|
|
68
|
+
Accept: "application/json",
|
|
69
|
+
"Content-Type": "application/x-www-form-urlencoded"
|
|
70
|
+
},
|
|
71
|
+
abortSignal: options && options.abortSignal
|
|
72
|
+
});
|
|
73
|
+
while (tokenResponse === null) {
|
|
74
|
+
try {
|
|
75
|
+
yield delay(deviceCodeResponse.interval * 1000);
|
|
76
|
+
// Check the abort signal before sending the request
|
|
77
|
+
if (options && options.abortSignal && options.abortSignal.aborted) {
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
tokenResponse = yield this.identityClient.sendTokenRequest(webResource);
|
|
81
|
+
}
|
|
82
|
+
catch (err) {
|
|
83
|
+
if (err instanceof AuthenticationError) {
|
|
84
|
+
switch (err.errorResponse.error) {
|
|
85
|
+
case "authorization_pending":
|
|
86
|
+
break;
|
|
87
|
+
case "authorization_declined":
|
|
88
|
+
return null;
|
|
89
|
+
case "expired_token":
|
|
90
|
+
throw err;
|
|
91
|
+
case "bad_verification_code":
|
|
92
|
+
throw err;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
throw err;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return tokenResponse;
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Authenticates with Azure Active Directory and returns an {@link AccessToken} if
|
|
105
|
+
* successful. If authentication cannot be performed at this time, this method may
|
|
106
|
+
* return null. If an error occurs during authentication, an {@link AuthenticationError}
|
|
107
|
+
* containing failure details will be thrown.
|
|
108
|
+
*
|
|
109
|
+
* @param scopes The list of scopes for which the token will have access.
|
|
110
|
+
* @param options The options used to configure any requests this
|
|
111
|
+
* TokenCredential implementation might make.
|
|
112
|
+
*/
|
|
113
|
+
getToken(scopes, options) {
|
|
114
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
115
|
+
let tokenResponse = null;
|
|
116
|
+
let scopeString = typeof scopes === "string" ? scopes : scopes.join(" ");
|
|
117
|
+
if (scopeString.indexOf("offline_access") < 0) {
|
|
118
|
+
scopeString += " offline_access";
|
|
119
|
+
}
|
|
120
|
+
// Try to use the refresh token first
|
|
121
|
+
if (this.lastTokenResponse && this.lastTokenResponse.refreshToken) {
|
|
122
|
+
tokenResponse = yield this.identityClient.refreshAccessToken(this.tenantId, this.clientId, scopeString, this.lastTokenResponse.refreshToken, undefined, // clientSecret not needed for device code auth
|
|
123
|
+
undefined, options);
|
|
124
|
+
}
|
|
125
|
+
if (tokenResponse === null) {
|
|
126
|
+
const deviceCodeResponse = yield this.sendDeviceCodeRequest(scopeString, options);
|
|
127
|
+
this.userPromptCallback({
|
|
128
|
+
userCode: deviceCodeResponse.user_code,
|
|
129
|
+
verificationUri: deviceCodeResponse.verification_uri,
|
|
130
|
+
message: deviceCodeResponse.message
|
|
131
|
+
});
|
|
132
|
+
tokenResponse = yield this.pollForToken(deviceCodeResponse, options);
|
|
133
|
+
}
|
|
134
|
+
this.lastTokenResponse = tokenResponse;
|
|
135
|
+
return (tokenResponse && tokenResponse.accessToken) || null;
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
//# sourceMappingURL=deviceCodeCredential.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deviceCodeCredential.js","sourceRoot":"","sources":["../../../src/credentials/deviceCodeCredential.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;;AAElC,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAiD,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACxF,OAAO,EAAyB,cAAc,EAAiB,MAAM,0BAA0B,CAAC;AAChG,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAkCvD;;;GAGG;AACH,MAAM,OAAO,oBAAoB;IAO/B;;;;;;;;;OASG;IACH,YACE,QAAgB,EAChB,QAAgB,EAChB,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
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { AccessToken, TokenCredential, GetTokenOptions } from "@azure/core-http";
|
|
2
|
+
import { IdentityClientOptions } from "../client/identityClient";
|
|
3
|
+
export declare class EnvironmentCredential implements TokenCredential {
|
|
4
|
+
constructor(options?: IdentityClientOptions);
|
|
5
|
+
getToken(scopes: string | string[], options?: GetTokenOptions): Promise<AccessToken | null>;
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=environmentCredential.browser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"environmentCredential.browser.d.ts","sourceRoot":"","sources":["../../../src/credentials/environmentCredential.browser.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACjF,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAIjE,qBAAa,qBAAsB,YAAW,eAAe;gBAC/C,OAAO,CAAC,EAAE,qBAAqB;IAI3C,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,EAAE,OAAO,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC;CAG5F"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation.
|
|
2
|
+
// Licensed under the MIT License.
|
|
3
|
+
const BrowserNotSupportedError = new Error("EnvironmentCredential is not supported in the browser.");
|
|
4
|
+
export class EnvironmentCredential {
|
|
5
|
+
constructor(options) {
|
|
6
|
+
throw BrowserNotSupportedError;
|
|
7
|
+
}
|
|
8
|
+
getToken(scopes, options) {
|
|
9
|
+
throw BrowserNotSupportedError;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=environmentCredential.browser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"environmentCredential.browser.js","sourceRoot":"","sources":["../../../src/credentials/environmentCredential.browser.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAOlC,MAAM,wBAAwB,GAAG,IAAI,KAAK,CAAC,wDAAwD,CAAC,CAAC;AAErG,MAAM,OAAO,qBAAqB;IAChC,YAAY,OAA+B;QACzC,MAAM,wBAAwB,CAAC;IACjC,CAAC;IAED,QAAQ,CAAC,MAAyB,EAAE,OAAyB;QAC3D,MAAM,wBAAwB,CAAC;IACjC,CAAC;CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"environmentCredential.d.ts","sourceRoot":"","sources":["../../../src/credentials/environmentCredential.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,eAAe,
|
|
1
|
+
{"version":3,"file":"environmentCredential.d.ts","sourceRoot":"","sources":["../../../src/credentials/environmentCredential.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACjF,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAGjE;;;;;;;;;;;GAWG;AACH,qBAAa,qBAAsB,YAAW,eAAe;IAC3D,OAAO,CAAC,WAAW,CAAC,CAA8B;IAClD;;;;;;;OAOG;gBACS,OAAO,CAAC,EAAE,qBAAqB;IAU3C;;;;;;;;;OASG;IACH,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,EAAE,OAAO,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC;CAO5F"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
// Copyright (c) Microsoft Corporation.
|
|
2
2
|
// Licensed under the MIT License.
|
|
3
|
-
import { isNode } from "@azure/core-http";
|
|
4
3
|
import { ClientSecretCredential } from "./clientSecretCredential";
|
|
5
4
|
/**
|
|
6
5
|
* Enables authentication to Azure Active Directory using client secret
|
|
@@ -25,9 +24,6 @@ export class EnvironmentCredential {
|
|
|
25
24
|
*/
|
|
26
25
|
constructor(options) {
|
|
27
26
|
this._credential = undefined;
|
|
28
|
-
if (!isNode) {
|
|
29
|
-
throw "EnvironmentCredential is only supported when running in Node.js.";
|
|
30
|
-
}
|
|
31
27
|
const tenantId = process.env.AZURE_TENANT_ID, clientId = process.env.AZURE_CLIENT_ID, clientSecret = process.env.AZURE_CLIENT_SECRET;
|
|
32
28
|
if (tenantId && clientId && clientSecret) {
|
|
33
29
|
this._credential = new ClientSecretCredential(tenantId, clientId, clientSecret, options);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"environmentCredential.js","sourceRoot":"","sources":["../../../src/credentials/environmentCredential.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;
|
|
1
|
+
{"version":3,"file":"environmentCredential.js","sourceRoot":"","sources":["../../../src/credentials/environmentCredential.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAIlC,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAElE;;;;;;;;;;;GAWG;AACH,MAAM,OAAO,qBAAqB;IAEhC;;;;;;;OAOG;IACH,YAAY,OAA+B;QATnC,gBAAW,GAAqB,SAAS,CAAC;QAUhD,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,eAAe,EAC1C,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,eAAe,EACtC,YAAY,GAAG,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC;QAEjD,IAAI,QAAQ,IAAI,QAAQ,IAAI,YAAY,EAAE;YACxC,IAAI,CAAC,WAAW,GAAG,IAAI,sBAAsB,CAAC,QAAQ,EAAE,QAAQ,EAAE,YAAY,EAAE,OAAO,CAAC,CAAC;SAC1F;IACH,CAAC;IAED;;;;;;;;;OASG;IACH,QAAQ,CAAC,MAAyB,EAAE,OAAyB;QAC3D,IAAI,IAAI,CAAC,WAAW,EAAE;YACpB,OAAO,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;SACnD;QAED,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/B,CAAC;CACF"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { AccessToken, TokenCredential, GetTokenOptions } from "@azure/core-http";
|
|
2
|
+
import { InteractiveBrowserCredentialOptions } from "./interactiveBrowserCredentialOptions";
|
|
3
|
+
/**
|
|
4
|
+
* Enables authentication to Azure Active Directory inside of the web browser
|
|
5
|
+
* using the interactive login flow, either via browser redirects or a popup
|
|
6
|
+
* window.
|
|
7
|
+
*/
|
|
8
|
+
export declare class InteractiveBrowserCredential implements TokenCredential {
|
|
9
|
+
private loginStyle;
|
|
10
|
+
private msalConfig;
|
|
11
|
+
private msalObject;
|
|
12
|
+
/**
|
|
13
|
+
* Creates an instance of the InteractiveBrowserCredential with the
|
|
14
|
+
* details needed to authenticate against Azure Active Directory with
|
|
15
|
+
* a user identity.
|
|
16
|
+
*
|
|
17
|
+
* @param tenantId The Azure Active Directory tenant (directory) ID.
|
|
18
|
+
* @param clientId The client (application) ID of an App Registration in the tenant.
|
|
19
|
+
* @param options Options for configuring the client which makes the authentication request.
|
|
20
|
+
*/
|
|
21
|
+
constructor(tenantId: string, clientId: string, options?: InteractiveBrowserCredentialOptions);
|
|
22
|
+
private login;
|
|
23
|
+
private acquireToken;
|
|
24
|
+
/**
|
|
25
|
+
*
|
|
26
|
+
* @param scopes The list of scopes for which the token will have access.
|
|
27
|
+
* @param options The options used to configure any requests this
|
|
28
|
+
* TokenCredential implementation might make.
|
|
29
|
+
*/
|
|
30
|
+
getToken(scopes: string | string[], options?: GetTokenOptions): Promise<AccessToken | null>;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=interactiveBrowserCredential.browser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interactiveBrowserCredential.browser.d.ts","sourceRoot":"","sources":["../../../src/credentials/interactiveBrowserCredential.browser.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAEjF,OAAO,EAAqB,mCAAmC,EAAE,MAAM,uCAAuC,CAAC;AAE/G;;;;GAIG;AACH,qBAAa,4BAA6B,YAAW,eAAe;IAClE,OAAO,CAAC,UAAU,CAAoB;IACtC,OAAO,CAAC,UAAU,CAAqB;IACvC,OAAO,CAAC,UAAU,CAA4B;IAE9C;;;;;;;;OAQG;gBAED,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE,mCAAmC;IAyB/C,OAAO,CAAC,KAAK;YAcC,YAAY;IAqC1B;;;;;OAKG;IACG,QAAQ,CACZ,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,EACzB,OAAO,CAAC,EAAE,eAAe,GACxB,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC;CAkB/B"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation.
|
|
2
|
+
// Licensed under the MIT License.
|
|
3
|
+
import * as tslib_1 from "tslib";
|
|
4
|
+
import * as msal from "msal";
|
|
5
|
+
import { IdentityClient } from "../client/identityClient";
|
|
6
|
+
/**
|
|
7
|
+
* Enables authentication to Azure Active Directory inside of the web browser
|
|
8
|
+
* using the interactive login flow, either via browser redirects or a popup
|
|
9
|
+
* window.
|
|
10
|
+
*/
|
|
11
|
+
export class InteractiveBrowserCredential {
|
|
12
|
+
/**
|
|
13
|
+
* Creates an instance of the InteractiveBrowserCredential with the
|
|
14
|
+
* details needed to authenticate against Azure Active Directory with
|
|
15
|
+
* a user identity.
|
|
16
|
+
*
|
|
17
|
+
* @param tenantId The Azure Active Directory tenant (directory) ID.
|
|
18
|
+
* @param clientId The client (application) ID of an App Registration in the tenant.
|
|
19
|
+
* @param options Options for configuring the client which makes the authentication request.
|
|
20
|
+
*/
|
|
21
|
+
constructor(tenantId, clientId, options) {
|
|
22
|
+
options = Object.assign({}, IdentityClient.getDefaultOptions(), options);
|
|
23
|
+
this.loginStyle = options.loginStyle || "popup";
|
|
24
|
+
if (["redirect", "popup"].indexOf(this.loginStyle) === -1) {
|
|
25
|
+
throw new Error(`Invalid loginStyle: ${options.loginStyle}`);
|
|
26
|
+
}
|
|
27
|
+
this.msalConfig = {
|
|
28
|
+
auth: Object.assign({ clientId: clientId, authority: `${options.authorityHost}/${tenantId}` }, options.redirectUri && { redirectUri: options.redirectUri }, options.postLogoutRedirectUri && { redirectUri: options.postLogoutRedirectUri }),
|
|
29
|
+
cache: {
|
|
30
|
+
cacheLocation: "localStorage",
|
|
31
|
+
storeAuthStateInCookie: true
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
this.msalObject = new msal.UserAgentApplication(this.msalConfig);
|
|
35
|
+
}
|
|
36
|
+
login() {
|
|
37
|
+
switch (this.loginStyle) {
|
|
38
|
+
case "redirect": {
|
|
39
|
+
const loginPromise = new Promise((resolve, reject) => {
|
|
40
|
+
this.msalObject.handleRedirectCallback(resolve, reject);
|
|
41
|
+
});
|
|
42
|
+
this.msalObject.loginRedirect();
|
|
43
|
+
return loginPromise;
|
|
44
|
+
}
|
|
45
|
+
case "popup":
|
|
46
|
+
return this.msalObject.loginPopup();
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
acquireToken(authParams) {
|
|
50
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
51
|
+
let authResponse;
|
|
52
|
+
try {
|
|
53
|
+
authResponse = yield this.msalObject.acquireTokenSilent(authParams);
|
|
54
|
+
}
|
|
55
|
+
catch (err) {
|
|
56
|
+
if (err instanceof msal.AuthError) {
|
|
57
|
+
switch (err.errorCode) {
|
|
58
|
+
case "consent_required":
|
|
59
|
+
case "interaction_required":
|
|
60
|
+
case "login_required":
|
|
61
|
+
break;
|
|
62
|
+
default:
|
|
63
|
+
throw err;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
let authPromise;
|
|
68
|
+
if (authResponse === undefined) {
|
|
69
|
+
switch (this.loginStyle) {
|
|
70
|
+
case "redirect":
|
|
71
|
+
authPromise = new Promise((resolve, reject) => {
|
|
72
|
+
this.msalObject.handleRedirectCallback(resolve, reject);
|
|
73
|
+
});
|
|
74
|
+
this.msalObject.acquireTokenRedirect(authParams);
|
|
75
|
+
break;
|
|
76
|
+
case "popup":
|
|
77
|
+
authPromise = this.msalObject.acquireTokenPopup(authParams);
|
|
78
|
+
break;
|
|
79
|
+
}
|
|
80
|
+
authResponse = authPromise && (yield authPromise);
|
|
81
|
+
}
|
|
82
|
+
return authResponse;
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
*
|
|
87
|
+
* @param scopes The list of scopes for which the token will have access.
|
|
88
|
+
* @param options The options used to configure any requests this
|
|
89
|
+
* TokenCredential implementation might make.
|
|
90
|
+
*/
|
|
91
|
+
getToken(scopes, options // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
92
|
+
) {
|
|
93
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
94
|
+
if (!this.msalObject.getAccount()) {
|
|
95
|
+
yield this.login();
|
|
96
|
+
}
|
|
97
|
+
const authResponse = yield this.acquireToken({
|
|
98
|
+
scopes: Array.isArray(scopes) ? scopes : scopes.split(',')
|
|
99
|
+
});
|
|
100
|
+
if (authResponse) {
|
|
101
|
+
return {
|
|
102
|
+
token: authResponse.accessToken,
|
|
103
|
+
expiresOnTimestamp: authResponse.expiresOn.getTime()
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
return null;
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
//# sourceMappingURL=interactiveBrowserCredential.browser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interactiveBrowserCredential.browser.js","sourceRoot":"","sources":["../../../src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AAY,CAAC;QACtB,CAAC;KAAA;IAED;;;;;OAKG;IACG,QAAQ,CACZ,MAAyB,EACzB,OAAyB,CAAC,wDAAwD;;;YAElF,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,UAAU,EAAE,EAAE;gBACjC,MAAM,IAAI,CAAC,KAAK,EAAE,CAAC;aACpB;YAED,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC;gBAC3C,MAAM,EAAE,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC;aAC3D,CAAC,CAAC;YAEH,IAAI,YAAY,EAAE;gBAChB,OAAO;oBACL,KAAK,EAAE,YAAY,CAAC,WAAW;oBAC/B,kBAAkB,EAAE,YAAY,CAAC,SAAS,CAAC,OAAO,EAAE;iBACrD,CAAC;aACH;iBAAM;gBACL,OAAO,IAAI,CAAC;aACb;QACH,CAAC;KAAA;CACF"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { TokenCredential, GetTokenOptions, AccessToken } from "@azure/core-http";
|
|
2
|
+
import { InteractiveBrowserCredentialOptions } from "./interactiveBrowserCredentialOptions";
|
|
3
|
+
/**
|
|
4
|
+
* Enables authentication to Azure Active Directory inside of the web browser
|
|
5
|
+
* using the interactive login flow, either via browser redirects or a popup
|
|
6
|
+
* window. This credential is not currently supported in Node.js.
|
|
7
|
+
*/
|
|
8
|
+
export declare class InteractiveBrowserCredential implements TokenCredential {
|
|
9
|
+
constructor(tenantId: string, clientId: string, options?: InteractiveBrowserCredentialOptions);
|
|
10
|
+
getToken(scopes: string | string[], options?: GetTokenOptions): Promise<AccessToken | null>;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=interactiveBrowserCredential.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interactiveBrowserCredential.d.ts","sourceRoot":"","sources":["../../../src/credentials/interactiveBrowserCredential.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACjF,OAAO,EAAE,mCAAmC,EAAE,MAAM,uCAAuC,CAAC;AAI5F;;;;GAIG;AACH,qBAAa,4BAA6B,YAAW,eAAe;gBAEhE,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE,mCAAmC;IAKxC,QAAQ,CACb,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,EACzB,OAAO,CAAC,EAAE,eAAe,GACxB,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC;CAG/B"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation.
|
|
2
|
+
// Licensed under the MIT License.
|
|
3
|
+
const BrowserNotSupportedError = new Error("InteractiveBrowserCredential is not supported in Node.js.");
|
|
4
|
+
/**
|
|
5
|
+
* Enables authentication to Azure Active Directory inside of the web browser
|
|
6
|
+
* using the interactive login flow, either via browser redirects or a popup
|
|
7
|
+
* window. This credential is not currently supported in Node.js.
|
|
8
|
+
*/
|
|
9
|
+
export class InteractiveBrowserCredential {
|
|
10
|
+
constructor(tenantId, clientId, options) {
|
|
11
|
+
throw BrowserNotSupportedError;
|
|
12
|
+
}
|
|
13
|
+
getToken(scopes, options) {
|
|
14
|
+
throw BrowserNotSupportedError;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=interactiveBrowserCredential.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interactiveBrowserCredential.js","sourceRoot":"","sources":["../../../src/credentials/interactiveBrowserCredential.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAOlC,MAAM,wBAAwB,GAAG,IAAI,KAAK,CAAC,2DAA2D,CAAC,CAAC;AAExG;;;;GAIG;AACH,MAAM,OAAO,4BAA4B;IACvC,YACE,QAAgB,EAChB,QAAgB,EAChB,OAA6C;QAE7C,MAAM,wBAAwB,CAAC;IACjC,CAAC;IAEM,QAAQ,CACb,MAAyB,EACzB,OAAyB;QAEzB,MAAM,wBAAwB,CAAC;IACjC,CAAC;CACF"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { IdentityClientOptions } from "../client/identityClient";
|
|
2
|
+
export declare type BrowserLoginStyle = "redirect" | "popup";
|
|
3
|
+
/**
|
|
4
|
+
* Defines options for the InteractiveBrowserCredential class.
|
|
5
|
+
*/
|
|
6
|
+
export interface InteractiveBrowserCredentialOptions extends IdentityClientOptions {
|
|
7
|
+
/**
|
|
8
|
+
* Specifies whether a redirect or a popup window should be used to
|
|
9
|
+
* initiate the user authentication flow. Possible values are "redirect"
|
|
10
|
+
* or "popup" (default).
|
|
11
|
+
*/
|
|
12
|
+
loginStyle?: BrowserLoginStyle;
|
|
13
|
+
/**
|
|
14
|
+
* Gets the redirect URI of the application. This should be same as the value
|
|
15
|
+
* in the application registration portal. Defaults to `window.location.href`.
|
|
16
|
+
*/
|
|
17
|
+
redirectUri?: string | (() => string);
|
|
18
|
+
/**
|
|
19
|
+
* Gets the URI to which the user will be redirected when logging out.
|
|
20
|
+
* Defaults to `window.location.href`.
|
|
21
|
+
*/
|
|
22
|
+
postLogoutRedirectUri?: string | (() => string);
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=interactiveBrowserCredentialOptions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interactiveBrowserCredentialOptions.d.ts","sourceRoot":"","sources":["../../../src/credentials/interactiveBrowserCredentialOptions.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAEjE,oBAAY,iBAAiB,GAAG,UAAU,GAAG,OAAO,CAAC;AAErD;;GAEG;AACH,MAAM,WAAW,mCAAoC,SAAQ,qBAAqB;IAChF;;;;OAIG;IACH,UAAU,CAAC,EAAE,iBAAiB,CAAC;IAE/B;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,GAAG,CAAC,MAAM,MAAM,CAAC,CAAC;IAEtC;;;OAGG;IACH,qBAAqB,CAAC,EAAE,MAAM,GAAG,CAAC,MAAM,MAAM,CAAC,CAAC;CACjD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interactiveBrowserCredentialOptions.js","sourceRoot":"","sources":["../../../src/credentials/interactiveBrowserCredentialOptions.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { AccessToken, GetTokenOptions, TokenCredential } from "@azure/core-http";
|
|
2
|
+
import { IdentityClientOptions } from "../client/identityClient";
|
|
3
|
+
export declare class ManagedIdentityCredential implements TokenCredential {
|
|
4
|
+
constructor(clientId?: string, options?: IdentityClientOptions);
|
|
5
|
+
getToken(scopes: string | string[], options?: GetTokenOptions): Promise<AccessToken | null>;
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=managedIdentityCredential.browser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"managedIdentityCredential.browser.d.ts","sourceRoot":"","sources":["../../../src/credentials/managedIdentityCredential.browser.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACjF,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAIjE,qBAAa,yBAA0B,YAAW,eAAe;gBACnD,QAAQ,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,qBAAqB;IAIjD,QAAQ,CACnB,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,EACzB,OAAO,CAAC,EAAE,eAAe,GACxB,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC;CAG/B"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation.
|
|
2
|
+
// Licensed under the MIT License.
|
|
3
|
+
import * as tslib_1 from "tslib";
|
|
4
|
+
const BrowserNotSupportedError = new Error("ManagedIdentityCredential is not supported in the browser.");
|
|
5
|
+
export class ManagedIdentityCredential {
|
|
6
|
+
constructor(clientId, options) {
|
|
7
|
+
throw BrowserNotSupportedError;
|
|
8
|
+
}
|
|
9
|
+
getToken(scopes, options) {
|
|
10
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
11
|
+
throw BrowserNotSupportedError;
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=managedIdentityCredential.browser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"managedIdentityCredential.browser.js","sourceRoot":"","sources":["../../../src/credentials/managedIdentityCredential.browser.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;;AAOlC,MAAM,wBAAwB,GAAG,IAAI,KAAK,CAAC,4DAA4D,CAAC,CAAC;AAEzG,MAAM,OAAO,yBAAyB;IACpC,YAAY,QAAiB,EAAE,OAA+B;QAC5D,MAAM,wBAAwB,CAAC;IACjC,CAAC;IAEY,QAAQ,CACnB,MAAyB,EACzB,OAAyB;;YAEzB,MAAM,wBAAwB,CAAC;QACjC,CAAC;KAAA;CACF"}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { AccessToken, GetTokenOptions, TokenCredential } from "@azure/core-http";
|
|
2
2
|
import { IdentityClientOptions } from "../client/identityClient";
|
|
3
|
+
export declare const ImdsEndpoint = "http://169.254.169.254/metadata/identity/oauth2/token";
|
|
4
|
+
export declare const ImdsApiVersion = "2018-02-01";
|
|
5
|
+
export declare const AppServiceMsiApiVersion = "2017-09-01";
|
|
3
6
|
/**
|
|
4
7
|
* Attempts authentication using a managed identity that has been assigned
|
|
5
8
|
* to the deployment environment. This authentication type works in Azure VMs,
|
|
@@ -11,9 +14,15 @@ import { IdentityClientOptions } from "../client/identityClient";
|
|
|
11
14
|
*/
|
|
12
15
|
export declare class ManagedIdentityCredential implements TokenCredential {
|
|
13
16
|
private identityClient;
|
|
14
|
-
private
|
|
17
|
+
private clientId;
|
|
15
18
|
private isEndpointUnavailable;
|
|
16
19
|
constructor(clientId?: string, options?: IdentityClientOptions);
|
|
20
|
+
private mapScopesToResource;
|
|
21
|
+
private createImdsAuthRequest;
|
|
22
|
+
private createAppServiceMsiAuthRequest;
|
|
23
|
+
private createCloudShellMsiAuthRequest;
|
|
24
|
+
private pingImdsEndpoint;
|
|
25
|
+
private authenticateManagedIdentity;
|
|
17
26
|
/**
|
|
18
27
|
* Authenticates with Azure Active Directory and returns an {@link AccessToken} if
|
|
19
28
|
* successful. If authentication cannot be performed at this time, this method may
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"managedIdentityCredential.d.ts","sourceRoot":"","sources":["../../../src/credentials/managedIdentityCredential.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"managedIdentityCredential.d.ts","sourceRoot":"","sources":["../../../src/credentials/managedIdentityCredential.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,WAAW,EACX,eAAe,EAGf,eAAe,EAChB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,qBAAqB,EAAkB,MAAM,0BAA0B,CAAC;AAGjF,eAAO,MAAM,YAAY,0DAA0D,CAAC;AACpF,eAAO,MAAM,cAAc,eAAe,CAAC;AAC3C,eAAO,MAAM,uBAAuB,eAAe,CAAC;AAEpD;;;;;;;;GAQG;AACH,qBAAa,yBAA0B,YAAW,eAAe;IAC/D,OAAO,CAAC,cAAc,CAAiB;IACvC,OAAO,CAAC,QAAQ,CAAqB;IACrC,OAAO,CAAC,qBAAqB,CAAwB;gBAEzC,QAAQ,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,qBAAqB;IAK9D,OAAO,CAAC,mBAAmB;IAmB3B,OAAO,CAAC,qBAAqB;IAqB7B,OAAO,CAAC,8BAA8B;IAqBtC,OAAO,CAAC,8BAA8B;YAqBxB,gBAAgB;YA6BhB,2BAA2B;IAgDzC;;;;;;;;;OASG;IACU,QAAQ,CACnB,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,EACzB,OAAO,CAAC,EAAE,eAAe,GACxB,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC;CAsB/B"}
|