@azure/msal-node 1.12.1 → 1.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/ClientApplication.d.ts +3 -2
- package/dist/client/ClientApplication.d.ts.map +1 -1
- package/dist/client/IConfidentialClientApplication.d.ts +1 -1
- package/dist/client/IConfidentialClientApplication.d.ts.map +1 -1
- package/dist/client/IPublicClientApplication.d.ts +4 -1
- package/dist/client/IPublicClientApplication.d.ts.map +1 -1
- package/dist/client/PublicClientApplication.d.ts +5 -0
- package/dist/client/PublicClientApplication.d.ts.map +1 -1
- package/dist/error/NodeAuthError.d.ts +58 -0
- package/dist/error/NodeAuthError.d.ts.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/msal-node.cjs.development.js +252 -4
- package/dist/msal-node.cjs.development.js.map +1 -1
- package/dist/msal-node.cjs.production.min.js +1 -1
- package/dist/msal-node.cjs.production.min.js.map +1 -1
- package/dist/msal-node.esm.js +251 -4
- package/dist/msal-node.esm.js.map +1 -1
- package/dist/network/LoopbackClient.d.ts +21 -0
- package/dist/network/LoopbackClient.d.ts.map +1 -0
- package/dist/packageMetadata.d.ts +1 -1
- package/dist/request/InteractiveRequest.d.ts +8 -0
- package/dist/request/InteractiveRequest.d.ts.map +1 -0
- package/dist/utils/Constants.d.ts +10 -0
- package/dist/utils/Constants.d.ts.map +1 -1
- package/package.json +2 -2
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ClientConfiguration, AuthenticationResult, BaseAuthRequest, Logger, ServerTelemetryManager, AzureRegionConfiguration, AzureCloudOptions, AuthorizationCodePayload } from "@azure/msal-common";
|
|
2
2
|
import { Configuration, NodeConfiguration } from "../config/Configuration";
|
|
3
|
+
import { CryptoProvider } from "../crypto/CryptoProvider";
|
|
3
4
|
import { NodeStorage } from "../cache/NodeStorage";
|
|
4
5
|
import { TokenCache } from "../cache/TokenCache";
|
|
5
6
|
import { ClientAssertion } from "./ClientAssertion";
|
|
@@ -13,7 +14,7 @@ import { UsernamePasswordRequest } from "../request/UsernamePasswordRequest";
|
|
|
13
14
|
* @public
|
|
14
15
|
*/
|
|
15
16
|
export declare abstract class ClientApplication {
|
|
16
|
-
|
|
17
|
+
protected readonly cryptoProvider: CryptoProvider;
|
|
17
18
|
private tokenCache;
|
|
18
19
|
/**
|
|
19
20
|
* Platform storage object
|
|
@@ -57,7 +58,7 @@ export declare abstract class ClientApplication {
|
|
|
57
58
|
* Authorization Code flow. Ensure that values for redirectUri and scopes in AuthorizationCodeUrlRequest and
|
|
58
59
|
* AuthorizationCodeRequest are the same.
|
|
59
60
|
*/
|
|
60
|
-
acquireTokenByCode(request: AuthorizationCodeRequest, authCodePayLoad?: AuthorizationCodePayload): Promise<AuthenticationResult
|
|
61
|
+
acquireTokenByCode(request: AuthorizationCodeRequest, authCodePayLoad?: AuthorizationCodePayload): Promise<AuthenticationResult>;
|
|
61
62
|
/**
|
|
62
63
|
* Acquires a token by exchanging the refresh token provided for a new set of tokens.
|
|
63
64
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ClientApplication.d.ts","sourceRoot":"","sources":["../src/client/ClientApplication.ts"],"names":[],"mappings":"AAKA,OAAO,EAEH,mBAAmB,EAEnB,oBAAoB,EAGpB,eAAe,EAEf,MAAM,EACN,sBAAsB,EAYtB,wBAAwB,EAExB,iBAAiB,EACjB,wBAAwB,EAG3B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,aAAa,EAAyB,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"ClientApplication.d.ts","sourceRoot":"","sources":["../src/client/ClientApplication.ts"],"names":[],"mappings":"AAKA,OAAO,EAEH,mBAAmB,EAEnB,oBAAoB,EAGpB,eAAe,EAEf,MAAM,EACN,sBAAsB,EAYtB,wBAAwB,EAExB,iBAAiB,EACjB,wBAAwB,EAG3B,MAAM,oBAAoB,CA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G,0BAA0B,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC;IA+BpG;;;;;;;OAOG;IACG,kBAAkB,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC;IA8B1F;;;;;;;;;OASG;IACG,8BAA8B,CAAC,OAAO,EAAE,uBAAuB,GAAG,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC;IA2B5G;;OAEG;IACH,aAAa,IAAI,UAAU;IAK3B;;OAEG;IACH,SAAS,IAAI,MAAM;IAInB;;;OAGG;IACH,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAI/B;;;;OAIG;cACa,6BAA6B,CACzC,SAAS,EAAE,MAAM,EACjB,oBAAoB,CAAC,EAAE,MAAM,EAC7B,sBAAsB,CAAC,EAAE,sBAAsB,EAC/C,wBAAwB,CAAC,EAAE,wBAAwB,EACnD,iBAAiB,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAoDxE,OAAO,CAAC,kBAAkB;IAO1B;;;OAGG;cACa,qBAAqB,CAAC,WAAW,EAAE,OAAO,CAAC,eAAe,CAAC,GAAG,OAAO,CAAC,eAAe,CAAC;IAsBtG;;;;;OAKG;IACH,SAAS,CAAC,gCAAgC,CAAC,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,OAAO,GAAG,sBAAsB;IAWhI;;;;OAIG;YACW,eAAe;IAkB7B;;OAEG;IACH,UAAU,IAAI,IAAI;CAGrB"}
|
|
@@ -15,7 +15,7 @@ export interface IConfidentialClientApplication {
|
|
|
15
15
|
/** Creates the URL of the authorization request */
|
|
16
16
|
getAuthCodeUrl(request: AuthorizationUrlRequest): Promise<string>;
|
|
17
17
|
/** Acquires a token by exchanging the authorization code received from the first step of OAuth 2.0 Authorization Code Flow */
|
|
18
|
-
acquireTokenByCode(request: AuthorizationCodeRequest): Promise<AuthenticationResult
|
|
18
|
+
acquireTokenByCode(request: AuthorizationCodeRequest): Promise<AuthenticationResult>;
|
|
19
19
|
/** Acquires a token silently when a user specifies the account the token is requested for */
|
|
20
20
|
acquireTokenSilent(request: SilentFlowRequest): Promise<AuthenticationResult | null>;
|
|
21
21
|
/** Acquires a token by exchanging the refresh token provided for a new set of tokens */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IConfidentialClientApplication.d.ts","sourceRoot":"","sources":["../src/client/IConfidentialClientApplication.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACrF,OAAO,EAAE,wBAAwB,EAAE,MAAM,qCAAqC,CAAC;AAC/E,OAAO,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AAC7E,OAAO,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AAC7E,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AACrE,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AAC7E,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEjD;;;GAGG;AACH,MAAM,WAAW,8BAA8B;IAE3C,mDAAmD;IACnD,cAAc,CAAC,OAAO,EAAE,uBAAuB,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAElE,+HAA+H;IAC/H,kBAAkB,CAAC,OAAO,EAAE,wBAAwB,GAAG,OAAO,CAAC,oBAAoB,
|
|
1
|
+
{"version":3,"file":"IConfidentialClientApplication.d.ts","sourceRoot":"","sources":["../src/client/IConfidentialClientApplication.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,EAAE,M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Aa,IAAI,UAAU,CAAC;IAE5B,kCAAkC;IAClC,SAAS,IAAI,MAAM,CAAC;IAEpB,gGAAgG;IAChG,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAEhC,sBAAsB;IACtB,UAAU,IAAI,IAAI,CAAC;IAEnB,0FAA0F;IAC1F,mBAAmB,CAAC,QAAQ,EAAE,iBAAiB,GAAG,IAAI,CAAA;CACzD"}
|
|
@@ -6,6 +6,7 @@ import { RefreshTokenRequest } from "../request/RefreshTokenRequest";
|
|
|
6
6
|
import { SilentFlowRequest } from "../request/SilentFlowRequest";
|
|
7
7
|
import { UsernamePasswordRequest } from "../request/UsernamePasswordRequest";
|
|
8
8
|
import { TokenCache } from "../cache/TokenCache";
|
|
9
|
+
import { InteractiveRequest } from "../request/InteractiveRequest";
|
|
9
10
|
/**
|
|
10
11
|
* Interface for the PublicClientApplication class defining the public API signatures
|
|
11
12
|
* @public
|
|
@@ -14,7 +15,9 @@ export interface IPublicClientApplication {
|
|
|
14
15
|
/** Creates the URL of the authorization request */
|
|
15
16
|
getAuthCodeUrl(request: AuthorizationUrlRequest): Promise<string>;
|
|
16
17
|
/** Acquires a token by exchanging the authorization code received from the first step of OAuth 2.0 Authorization Code Flow */
|
|
17
|
-
acquireTokenByCode(request: AuthorizationCodeRequest): Promise<AuthenticationResult
|
|
18
|
+
acquireTokenByCode(request: AuthorizationCodeRequest): Promise<AuthenticationResult>;
|
|
19
|
+
/** Acquires a token interactively */
|
|
20
|
+
acquireTokenInteractive(request: InteractiveRequest): Promise<AuthenticationResult>;
|
|
18
21
|
/** Acquires a token silently when a user specifies the account the token is requested for */
|
|
19
22
|
acquireTokenSilent(request: SilentFlowRequest): Promise<AuthenticationResult | null>;
|
|
20
23
|
/** Acquires a token by exchanging the refresh token provided for a new set of tokens */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IPublicClientApplication.d.ts","sourceRoot":"","sources":["../src/client/IPublicClientApplication.ts"],"names":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AC,oBAAoB,CAAC,CAAC;IAErF,qCAAqC;IACrC,uBAAuB,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;IAEpF,6FAA6F;IAC7F,kBAAkB,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC,CAAC;IAErF,wFAAwF;IACxF,0BAA0B,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC,CAAC;IAE/F,0EAA0E;IAC1E,wBAAwB,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC,CAAC;IAE3F,kHAAkH;IAClH,8BAA8B,CAAC,OAAO,EAAE,uBAAuB,GAAG,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC,CAAC;IAEvG,+CAA+C;IAC/C,aAAa,IAAI,UAAU,CAAC;IAE5B,kCAAkC;IAClC,SAAS,IAAI,MAAM,CAAC;IAEpB,gGAAgG;IAChG,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAEhC,sBAAsB;IACtB,UAAU,IAAI,IAAI,CAAC;CACtB"}
|
|
@@ -3,6 +3,7 @@ import { Configuration } from "../config/Configuration";
|
|
|
3
3
|
import { ClientApplication } from "./ClientApplication";
|
|
4
4
|
import { IPublicClientApplication } from "./IPublicClientApplication";
|
|
5
5
|
import { DeviceCodeRequest } from "../request/DeviceCodeRequest";
|
|
6
|
+
import { InteractiveRequest } from "../request/InteractiveRequest";
|
|
6
7
|
/**
|
|
7
8
|
* This class is to be used to acquire tokens for public client applications (desktop, mobile). Public client applications
|
|
8
9
|
* are not trusted to safely store application secrets, and therefore can only request tokens in the name of an user.
|
|
@@ -37,5 +38,9 @@ export declare class PublicClientApplication extends ClientApplication implement
|
|
|
37
38
|
* until the end-user completes input of credentials.
|
|
38
39
|
*/
|
|
39
40
|
acquireTokenByDeviceCode(request: DeviceCodeRequest): Promise<AuthenticationResult | null>;
|
|
41
|
+
/**
|
|
42
|
+
* Acquires a token by requesting an Authorization code then exchanging it for a token.
|
|
43
|
+
*/
|
|
44
|
+
acquireTokenInteractive(request: InteractiveRequest): Promise<AuthenticationResult>;
|
|
40
45
|
}
|
|
41
46
|
//# sourceMappingURL=PublicClientApplication.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PublicClientApplication.d.ts","sourceRoot":"","sources":["../src/client/PublicClientApplication.ts"],"names":[],"mappings":"AAMA,OAAO,EAEH,oBAAoB,
|
|
1
|
+
{"version":3,"file":"PublicClientApplication.d.ts","sourceRoot":"","sources":["../src/client/PublicClientApplication.ts"],"names":[],"mappings":"AAMA,OAAO,EAEH,oBAAoB,EAQvB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAGjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAInE;;;;GAIG;AACH,qBAAa,uBAAwB,SAAQ,iBAAkB,YAAW,wBAAwB;IAC9F;;;;;;;;;;;;;;;;OAgBG;gBACS,aAAa,EAAE,aAAa;IAIxC;;;;;;;;OAQG;IACU,wBAAwB,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC;IAwBvG;;OAEG;IACG,uBAAuB,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,oBAAoB,CAAC;CAuC5F"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { AuthError } from "@azure/msal-common";
|
|
2
|
+
/**
|
|
3
|
+
* NodeAuthErrorMessage class containing string constants used by error codes and messages.
|
|
4
|
+
*/
|
|
5
|
+
export declare const NodeAuthErrorMessage: {
|
|
6
|
+
invalidLoopbackAddressType: {
|
|
7
|
+
code: string;
|
|
8
|
+
desc: string;
|
|
9
|
+
};
|
|
10
|
+
unableToLoadRedirectUri: {
|
|
11
|
+
code: string;
|
|
12
|
+
desc: string;
|
|
13
|
+
};
|
|
14
|
+
noAuthCodeInResponse: {
|
|
15
|
+
code: string;
|
|
16
|
+
desc: string;
|
|
17
|
+
};
|
|
18
|
+
noLoopbackServerExists: {
|
|
19
|
+
code: string;
|
|
20
|
+
desc: string;
|
|
21
|
+
};
|
|
22
|
+
loopbackServerAlreadyExists: {
|
|
23
|
+
code: string;
|
|
24
|
+
desc: string;
|
|
25
|
+
};
|
|
26
|
+
loopbackServerTimeout: {
|
|
27
|
+
code: string;
|
|
28
|
+
desc: string;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
export declare class NodeAuthError extends AuthError {
|
|
32
|
+
constructor(errorCode: string, errorMessage?: string);
|
|
33
|
+
/**
|
|
34
|
+
* Creates an error thrown if loopback server address is of type string.
|
|
35
|
+
*/
|
|
36
|
+
static createInvalidLoopbackAddressTypeError(): NodeAuthError;
|
|
37
|
+
/**
|
|
38
|
+
* Creates an error thrown if the loopback server is unable to get a url.
|
|
39
|
+
*/
|
|
40
|
+
static createUnableToLoadRedirectUrlError(): NodeAuthError;
|
|
41
|
+
/**
|
|
42
|
+
* Creates an error thrown if the server response does not contain an auth code.
|
|
43
|
+
*/
|
|
44
|
+
static createNoAuthCodeInResponseError(): NodeAuthError;
|
|
45
|
+
/**
|
|
46
|
+
* Creates an error thrown if the loopback server has not been spun up yet.
|
|
47
|
+
*/
|
|
48
|
+
static createNoLoopbackServerExistsError(): NodeAuthError;
|
|
49
|
+
/**
|
|
50
|
+
* Creates an error thrown if a loopback server already exists when attempting to create another one.
|
|
51
|
+
*/
|
|
52
|
+
static createLoopbackServerAlreadyExistsError(): NodeAuthError;
|
|
53
|
+
/**
|
|
54
|
+
* Creates an error thrown if the loopback server times out registering the auth code listener.
|
|
55
|
+
*/
|
|
56
|
+
static createLoopbackServerTimeoutError(): NodeAuthError;
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=NodeAuthError.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NodeAuthError.d.ts","sourceRoot":"","sources":["../src/error/NodeAuthError.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAE/C;;GAEG;AACH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;CAyBhC,CAAC;AAEF,qBAAa,aAAc,SAAQ,SAAS;gBAC5B,SAAS,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM;IAKpD;;OAEG;IACH,MAAM,CAAC,qCAAqC,IAAI,aAAa;IAK7D;;OAEG;IACH,MAAM,CAAC,kCAAkC,IAAI,aAAa;IAK1D;;OAEG;IACH,MAAM,CAAC,+BAA+B,IAAI,aAAa;IAKvD;;OAEG;IACH,MAAM,CAAC,iCAAiC,IAAI,aAAa;IAKzD;;OAEG;IACH,MAAM,CAAC,sCAAsC,IAAI,aAAa;IAK9D;;OAEG;IACH,MAAM,CAAC,gCAAgC,IAAI,aAAa;CAI3D"}
|
package/dist/index.d.ts
CHANGED
|
@@ -25,6 +25,7 @@ export type { OnBehalfOfRequest } from "./request/OnBehalfOfRequest";
|
|
|
25
25
|
export type { UsernamePasswordRequest } from "./request/UsernamePasswordRequest";
|
|
26
26
|
export type { RefreshTokenRequest } from "./request/RefreshTokenRequest";
|
|
27
27
|
export type { SilentFlowRequest } from "./request/SilentFlowRequest";
|
|
28
|
+
export type { InteractiveRequest } from "./request/InteractiveRequest";
|
|
28
29
|
export { PromptValue, ResponseMode, AuthorizationCodePayload, AuthenticationResult, AccountInfo, ValidCacheType, AuthError, AuthErrorMessage, ClientAuthError, ClientAuthErrorMessage, ClientConfigurationError, ClientConfigurationErrorMessage, InteractionRequiredAuthError, InteractionRequiredAuthErrorMessage, ServerError, INetworkModule, NetworkRequestOptions, NetworkResponse, Logger, LogLevel, ProtocolMode, ICachePlugin, TokenCacheContext, ISerializableTokenCache, AzureCloudInstance, AzureCloudOptions, IAppTokenProvider, AppTokenProviderParameters, AppTokenProviderResult } from "@azure/msal-common";
|
|
29
30
|
export { version } from "./packageMetadata";
|
|
30
31
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":"AAKA;;;GAGG;AAGH,OAAO,EAAE,wBAAwB,EAAE,MAAM,mCAAmC,CAAC;AAC7E,OAAO,EAAE,8BAA8B,EAAE,MAAM,yCAAyC,CAAC;AACzF,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,MAAM,uCAAuC,CAAC;AAG1E,OAAO,EAAE,uBAAuB,EAAE,MAAM,kCAAkC,CAAC;AAC3E,OAAO,EAAE,6BAA6B,EAAE,MAAM,wCAAwC,CAAC;AACvF,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,qBAAqB,EAAE,eAAe,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAChI,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAG3D,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,aAAa,EAAE,uBAAuB,EAAE,uBAAuB,EAAE,2BAA2B,EAAE,2BAA2B,EAAE,4BAA4B,EAAE,MAAM,oCAAoC,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,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC"}
|
|
@@ -5,7 +5,8 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
|
|
6
6
|
|
|
7
7
|
var msalCommon = require('@azure/msal-common');
|
|
8
|
-
var http =
|
|
8
|
+
var http = require('http');
|
|
9
|
+
var http__default = _interopDefault(http);
|
|
9
10
|
var https = _interopDefault(require('https'));
|
|
10
11
|
var uuid = require('uuid');
|
|
11
12
|
var crypto = _interopDefault(require('crypto'));
|
|
@@ -25,6 +26,13 @@ var HttpMethod;
|
|
|
25
26
|
HttpMethod["GET"] = "get";
|
|
26
27
|
HttpMethod["POST"] = "post";
|
|
27
28
|
})(HttpMethod || (HttpMethod = {}));
|
|
29
|
+
|
|
30
|
+
var HttpStatus;
|
|
31
|
+
|
|
32
|
+
(function (HttpStatus) {
|
|
33
|
+
HttpStatus[HttpStatus["OK"] = 200] = "OK";
|
|
34
|
+
HttpStatus[HttpStatus["REDIRECT"] = 302] = "REDIRECT";
|
|
35
|
+
})(HttpStatus || (HttpStatus = {}));
|
|
28
36
|
/**
|
|
29
37
|
* Constants used for region discovery
|
|
30
38
|
*/
|
|
@@ -57,7 +65,9 @@ const CharSet = {
|
|
|
57
65
|
const Constants = {
|
|
58
66
|
MSAL_SKU: "msal.js.node",
|
|
59
67
|
JWT_BEARER_ASSERTION_TYPE: "urn:ietf:params:oauth:client-assertion-type:jwt-bearer",
|
|
60
|
-
AUTHORIZATION_PENDING: "authorization_pending"
|
|
68
|
+
AUTHORIZATION_PENDING: "authorization_pending",
|
|
69
|
+
HTTP_PROTOCOL: "http://",
|
|
70
|
+
LOCALHOST: "localhost"
|
|
61
71
|
};
|
|
62
72
|
/**
|
|
63
73
|
* API Codes for Telemetry purposes.
|
|
@@ -94,6 +104,10 @@ const JwtConstants = {
|
|
|
94
104
|
NOT_BEFORE: "nbf",
|
|
95
105
|
JWT_ID: "jti"
|
|
96
106
|
};
|
|
107
|
+
const LOOPBACK_SERVER_CONSTANTS = {
|
|
108
|
+
INTERVAL_MS: 100,
|
|
109
|
+
TIMEOUT_MS: 5000
|
|
110
|
+
};
|
|
97
111
|
|
|
98
112
|
/*
|
|
99
113
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -160,7 +174,7 @@ const networkRequestViaProxy = (url, httpMethod, options, timeout) => {
|
|
|
160
174
|
|
|
161
175
|
const outgoingRequestString = `${httpMethod.toUpperCase()} ${destinationUrl.href} HTTP/1.1\r\n` + `Host: ${destinationUrl.host}\r\n` + "Connection: close\r\n" + postRequestStringContent + "\r\n";
|
|
162
176
|
return new Promise((resolve, reject) => {
|
|
163
|
-
const request =
|
|
177
|
+
const request = http__default.request(tunnelRequestOptions);
|
|
164
178
|
|
|
165
179
|
if (tunnelRequestOptions.timeout) {
|
|
166
180
|
request.on("timeout", () => {
|
|
@@ -1758,7 +1772,7 @@ class TokenCache {
|
|
|
1758
1772
|
|
|
1759
1773
|
/* eslint-disable header/header */
|
|
1760
1774
|
const name = "@azure/msal-node";
|
|
1761
|
-
const version = "1.
|
|
1775
|
+
const version = "1.13.0";
|
|
1762
1776
|
|
|
1763
1777
|
/*
|
|
1764
1778
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -2087,6 +2101,192 @@ class ClientApplication {
|
|
|
2087
2101
|
|
|
2088
2102
|
}
|
|
2089
2103
|
|
|
2104
|
+
/*
|
|
2105
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2106
|
+
* Licensed under the MIT License.
|
|
2107
|
+
*/
|
|
2108
|
+
/**
|
|
2109
|
+
* NodeAuthErrorMessage class containing string constants used by error codes and messages.
|
|
2110
|
+
*/
|
|
2111
|
+
|
|
2112
|
+
const NodeAuthErrorMessage = {
|
|
2113
|
+
invalidLoopbackAddressType: {
|
|
2114
|
+
code: "invalid_loopback_server_address_type",
|
|
2115
|
+
desc: "Loopback server address is not type string. This is unexpected."
|
|
2116
|
+
},
|
|
2117
|
+
unableToLoadRedirectUri: {
|
|
2118
|
+
code: "unable_to_load_redirectUrl",
|
|
2119
|
+
desc: "Loopback server callback was invoked without a url. This is unexpected."
|
|
2120
|
+
},
|
|
2121
|
+
noAuthCodeInResponse: {
|
|
2122
|
+
code: "no_auth_code_in_response",
|
|
2123
|
+
desc: "No auth code found in the server response. Please check your network trace to determine what happened."
|
|
2124
|
+
},
|
|
2125
|
+
noLoopbackServerExists: {
|
|
2126
|
+
code: "no_loopback_server_exists",
|
|
2127
|
+
desc: "No loopback server exists yet."
|
|
2128
|
+
},
|
|
2129
|
+
loopbackServerAlreadyExists: {
|
|
2130
|
+
code: "loopback_server_already_exists",
|
|
2131
|
+
desc: "Loopback server already exists. Cannot create another."
|
|
2132
|
+
},
|
|
2133
|
+
loopbackServerTimeout: {
|
|
2134
|
+
code: "loopback_server_timeout",
|
|
2135
|
+
desc: "Timed out waiting for auth code listener to be registered."
|
|
2136
|
+
}
|
|
2137
|
+
};
|
|
2138
|
+
class NodeAuthError extends msalCommon.AuthError {
|
|
2139
|
+
constructor(errorCode, errorMessage) {
|
|
2140
|
+
super(errorCode, errorMessage);
|
|
2141
|
+
this.name = "NodeAuthError";
|
|
2142
|
+
}
|
|
2143
|
+
/**
|
|
2144
|
+
* Creates an error thrown if loopback server address is of type string.
|
|
2145
|
+
*/
|
|
2146
|
+
|
|
2147
|
+
|
|
2148
|
+
static createInvalidLoopbackAddressTypeError() {
|
|
2149
|
+
return new NodeAuthError(NodeAuthErrorMessage.invalidLoopbackAddressType.code, `${NodeAuthErrorMessage.invalidLoopbackAddressType.desc}`);
|
|
2150
|
+
}
|
|
2151
|
+
/**
|
|
2152
|
+
* Creates an error thrown if the loopback server is unable to get a url.
|
|
2153
|
+
*/
|
|
2154
|
+
|
|
2155
|
+
|
|
2156
|
+
static createUnableToLoadRedirectUrlError() {
|
|
2157
|
+
return new NodeAuthError(NodeAuthErrorMessage.unableToLoadRedirectUri.code, `${NodeAuthErrorMessage.unableToLoadRedirectUri.desc}`);
|
|
2158
|
+
}
|
|
2159
|
+
/**
|
|
2160
|
+
* Creates an error thrown if the server response does not contain an auth code.
|
|
2161
|
+
*/
|
|
2162
|
+
|
|
2163
|
+
|
|
2164
|
+
static createNoAuthCodeInResponseError() {
|
|
2165
|
+
return new NodeAuthError(NodeAuthErrorMessage.noAuthCodeInResponse.code, `${NodeAuthErrorMessage.noAuthCodeInResponse.desc}`);
|
|
2166
|
+
}
|
|
2167
|
+
/**
|
|
2168
|
+
* Creates an error thrown if the loopback server has not been spun up yet.
|
|
2169
|
+
*/
|
|
2170
|
+
|
|
2171
|
+
|
|
2172
|
+
static createNoLoopbackServerExistsError() {
|
|
2173
|
+
return new NodeAuthError(NodeAuthErrorMessage.noLoopbackServerExists.code, `${NodeAuthErrorMessage.noLoopbackServerExists.desc}`);
|
|
2174
|
+
}
|
|
2175
|
+
/**
|
|
2176
|
+
* Creates an error thrown if a loopback server already exists when attempting to create another one.
|
|
2177
|
+
*/
|
|
2178
|
+
|
|
2179
|
+
|
|
2180
|
+
static createLoopbackServerAlreadyExistsError() {
|
|
2181
|
+
return new NodeAuthError(NodeAuthErrorMessage.loopbackServerAlreadyExists.code, `${NodeAuthErrorMessage.loopbackServerAlreadyExists.desc}`);
|
|
2182
|
+
}
|
|
2183
|
+
/**
|
|
2184
|
+
* Creates an error thrown if the loopback server times out registering the auth code listener.
|
|
2185
|
+
*/
|
|
2186
|
+
|
|
2187
|
+
|
|
2188
|
+
static createLoopbackServerTimeoutError() {
|
|
2189
|
+
return new NodeAuthError(NodeAuthErrorMessage.loopbackServerTimeout.code, `${NodeAuthErrorMessage.loopbackServerTimeout.desc}`);
|
|
2190
|
+
}
|
|
2191
|
+
|
|
2192
|
+
}
|
|
2193
|
+
|
|
2194
|
+
/*
|
|
2195
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2196
|
+
* Licensed under the MIT License.
|
|
2197
|
+
*/
|
|
2198
|
+
class LoopbackClient {
|
|
2199
|
+
/**
|
|
2200
|
+
* Spins up a loopback server which returns the server response when the localhost redirectUri is hit
|
|
2201
|
+
* @param successTemplate
|
|
2202
|
+
* @param errorTemplate
|
|
2203
|
+
* @returns
|
|
2204
|
+
*/
|
|
2205
|
+
async listenForAuthCode(successTemplate, errorTemplate) {
|
|
2206
|
+
if (!!this.server) {
|
|
2207
|
+
throw NodeAuthError.createLoopbackServerAlreadyExistsError();
|
|
2208
|
+
}
|
|
2209
|
+
|
|
2210
|
+
const authCodeListener = new Promise((resolve, reject) => {
|
|
2211
|
+
this.server = http.createServer(async (req, res) => {
|
|
2212
|
+
const url = req.url;
|
|
2213
|
+
|
|
2214
|
+
if (!url) {
|
|
2215
|
+
res.end(errorTemplate || "Error occurred loading redirectUrl");
|
|
2216
|
+
reject(NodeAuthError.createUnableToLoadRedirectUrlError());
|
|
2217
|
+
return;
|
|
2218
|
+
} else if (url === msalCommon.Constants.FORWARD_SLASH) {
|
|
2219
|
+
res.end(successTemplate || "Auth code was successfully acquired. You can close this window now.");
|
|
2220
|
+
return;
|
|
2221
|
+
}
|
|
2222
|
+
|
|
2223
|
+
const authCodeResponse = msalCommon.UrlString.getDeserializedQueryString(url);
|
|
2224
|
+
|
|
2225
|
+
if (authCodeResponse.code) {
|
|
2226
|
+
const redirectUri = await this.getRedirectUri();
|
|
2227
|
+
res.writeHead(HttpStatus.REDIRECT, {
|
|
2228
|
+
location: redirectUri
|
|
2229
|
+
}); // Prevent auth code from being saved in the browser history
|
|
2230
|
+
|
|
2231
|
+
res.end();
|
|
2232
|
+
}
|
|
2233
|
+
|
|
2234
|
+
resolve(authCodeResponse);
|
|
2235
|
+
});
|
|
2236
|
+
this.server.listen(0); // Listen on any available port
|
|
2237
|
+
}); // Wait for server to be listening
|
|
2238
|
+
|
|
2239
|
+
await new Promise(resolve => {
|
|
2240
|
+
let ticks = 0;
|
|
2241
|
+
const id = setInterval(() => {
|
|
2242
|
+
if (LOOPBACK_SERVER_CONSTANTS.TIMEOUT_MS / LOOPBACK_SERVER_CONSTANTS.INTERVAL_MS < ticks) {
|
|
2243
|
+
throw NodeAuthError.createLoopbackServerTimeoutError();
|
|
2244
|
+
}
|
|
2245
|
+
|
|
2246
|
+
if (this.server.listening) {
|
|
2247
|
+
clearInterval(id);
|
|
2248
|
+
resolve();
|
|
2249
|
+
}
|
|
2250
|
+
|
|
2251
|
+
ticks++;
|
|
2252
|
+
}, LOOPBACK_SERVER_CONSTANTS.INTERVAL_MS);
|
|
2253
|
+
});
|
|
2254
|
+
return authCodeListener;
|
|
2255
|
+
}
|
|
2256
|
+
/**
|
|
2257
|
+
* Get the port that the loopback server is running on
|
|
2258
|
+
* @returns
|
|
2259
|
+
*/
|
|
2260
|
+
|
|
2261
|
+
|
|
2262
|
+
getRedirectUri() {
|
|
2263
|
+
if (!this.server) {
|
|
2264
|
+
throw NodeAuthError.createNoLoopbackServerExistsError();
|
|
2265
|
+
}
|
|
2266
|
+
|
|
2267
|
+
const address = this.server.address();
|
|
2268
|
+
|
|
2269
|
+
if (!address || typeof address === "string" || !address.port) {
|
|
2270
|
+
this.closeServer();
|
|
2271
|
+
throw NodeAuthError.createInvalidLoopbackAddressTypeError();
|
|
2272
|
+
}
|
|
2273
|
+
|
|
2274
|
+
const port = address && address.port;
|
|
2275
|
+
return `${Constants.HTTP_PROTOCOL}${Constants.LOCALHOST}:${port}`;
|
|
2276
|
+
}
|
|
2277
|
+
/**
|
|
2278
|
+
* Close the loopback server
|
|
2279
|
+
*/
|
|
2280
|
+
|
|
2281
|
+
|
|
2282
|
+
closeServer() {
|
|
2283
|
+
if (!!this.server) {
|
|
2284
|
+
this.server.close();
|
|
2285
|
+
}
|
|
2286
|
+
}
|
|
2287
|
+
|
|
2288
|
+
}
|
|
2289
|
+
|
|
2090
2290
|
/*
|
|
2091
2291
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2092
2292
|
* Licensed under the MIT License.
|
|
@@ -2148,6 +2348,54 @@ class PublicClientApplication extends ClientApplication {
|
|
|
2148
2348
|
throw e;
|
|
2149
2349
|
}
|
|
2150
2350
|
}
|
|
2351
|
+
/**
|
|
2352
|
+
* Acquires a token by requesting an Authorization code then exchanging it for a token.
|
|
2353
|
+
*/
|
|
2354
|
+
|
|
2355
|
+
|
|
2356
|
+
async acquireTokenInteractive(request) {
|
|
2357
|
+
const {
|
|
2358
|
+
verifier,
|
|
2359
|
+
challenge
|
|
2360
|
+
} = await this.cryptoProvider.generatePkceCodes();
|
|
2361
|
+
const {
|
|
2362
|
+
openBrowser,
|
|
2363
|
+
successTemplate,
|
|
2364
|
+
errorTemplate,
|
|
2365
|
+
...remainingProperties
|
|
2366
|
+
} = request;
|
|
2367
|
+
const loopbackClient = new LoopbackClient();
|
|
2368
|
+
const authCodeListener = loopbackClient.listenForAuthCode(successTemplate, errorTemplate);
|
|
2369
|
+
const redirectUri = loopbackClient.getRedirectUri();
|
|
2370
|
+
const validRequest = { ...remainingProperties,
|
|
2371
|
+
scopes: request.scopes || [],
|
|
2372
|
+
redirectUri: redirectUri,
|
|
2373
|
+
responseMode: msalCommon.ResponseMode.QUERY,
|
|
2374
|
+
codeChallenge: challenge,
|
|
2375
|
+
codeChallengeMethod: msalCommon.CodeChallengeMethodValues.S256
|
|
2376
|
+
};
|
|
2377
|
+
const authCodeUrl = await this.getAuthCodeUrl(validRequest);
|
|
2378
|
+
await openBrowser(authCodeUrl);
|
|
2379
|
+
const authCodeResponse = await authCodeListener.finally(() => {
|
|
2380
|
+
loopbackClient.closeServer();
|
|
2381
|
+
});
|
|
2382
|
+
|
|
2383
|
+
if (authCodeResponse.error) {
|
|
2384
|
+
throw new msalCommon.ServerError(authCodeResponse.error, authCodeResponse.error_description, authCodeResponse.suberror);
|
|
2385
|
+
} else if (!authCodeResponse.code) {
|
|
2386
|
+
throw NodeAuthError.createNoAuthCodeInResponseError();
|
|
2387
|
+
}
|
|
2388
|
+
|
|
2389
|
+
const clientInfo = authCodeResponse.client_info;
|
|
2390
|
+
const tokenRequest = {
|
|
2391
|
+
code: authCodeResponse.code,
|
|
2392
|
+
scopes: msalCommon.OIDC_DEFAULT_SCOPES,
|
|
2393
|
+
redirectUri: validRequest.redirectUri,
|
|
2394
|
+
codeVerifier: verifier,
|
|
2395
|
+
clientInfo: clientInfo || msalCommon.Constants.EMPTY_STRING
|
|
2396
|
+
};
|
|
2397
|
+
return this.acquireTokenByCode(tokenRequest);
|
|
2398
|
+
}
|
|
2151
2399
|
|
|
2152
2400
|
}
|
|
2153
2401
|
|