@azure/msal-node 1.12.0 → 1.14.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 +13 -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 +66 -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 +295 -5
- 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 +294 -5
- 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/AuthorizationCodeRequest.d.ts +2 -0
- package/dist/request/AuthorizationCodeRequest.d.ts.map +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
|
*
|
|
@@ -90,6 +91,16 @@ export declare abstract class ClientApplication {
|
|
|
90
91
|
* Gets the token cache for the application.
|
|
91
92
|
*/
|
|
92
93
|
getTokenCache(): TokenCache;
|
|
94
|
+
/**
|
|
95
|
+
* Validates OIDC state by comparing the user cached state with the state received from the server.
|
|
96
|
+
*
|
|
97
|
+
* This API is provided for scenarios where you would use OAuth2.0 state parameter to mitigate against
|
|
98
|
+
* CSRF attacks.
|
|
99
|
+
* For more information about state, visit https://datatracker.ietf.org/doc/html/rfc6819#section-3.6.
|
|
100
|
+
* @param state
|
|
101
|
+
* @param cachedState
|
|
102
|
+
*/
|
|
103
|
+
protected validateState(state: string, cachedState: string): void;
|
|
93
104
|
/**
|
|
94
105
|
* Returns the logger instance
|
|
95
106
|
*/
|
|
@@ -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,
|
|
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,EAI3B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,aAAa,EAAyB,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAClG,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAEnD,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AAC7E,OAAO,EAAE,wBAAwB,EAAE,MAAM,qCAAqC,CAAC;AAC/E,OAAO,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AACrE,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAEjE,OAAO,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AAG7E;;;GAGG;AACH,8BAAsB,iBAAiB;IAEnC,SAAS,CAAC,QAAQ,CAAC,cAAc,EAAE,cAAc,CAAC;IAClD,OAAO,CAAC,UAAU,CAAa;IAE/B;;OAEG;IACH,SAAS,CAAC,OAAO,EAAE,WAAW,CAAC;IAC/B;;OAEG;IACH,SAAS,CAAC,MAAM,EAAE,MAAM,C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AO,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,mBA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C;IAErF,8FAA8F;IAC9F,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,mFAAmF;IACnF,8BAA8B,CAAC,OAAO,EAAE,uBAAuB,GAAG,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC,CAAC;IAEvG,6DAA6D;IAC7D,sBAAsB,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC,CAAC;IAEzF,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;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":[],"mappings":"AAKA,OAAO,EAAE,oBAAoB,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAClE,OAAO,EAAE,wBAAwB,EAAE,MAAM,qCAAqC,CAAC;AAC/E,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;
|
|
1
|
+
{"version":3,"file":"IPublicClientApplication.d.ts","sourceRoot":"","sources":["../src/client/IPublicClientApplication.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,oBAAoB,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAClE,OAAO,EAAE,wBAAwB,EAAE,MAAM,qCAAqC,CAAC;AAC/E,OA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AAC,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,66 @@
|
|
|
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
|
+
stateNotFoundError: {
|
|
31
|
+
code: string;
|
|
32
|
+
desc: string;
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
export declare class NodeAuthError extends AuthError {
|
|
36
|
+
constructor(errorCode: string, errorMessage?: string);
|
|
37
|
+
/**
|
|
38
|
+
* Creates an error thrown if loopback server address is of type string.
|
|
39
|
+
*/
|
|
40
|
+
static createInvalidLoopbackAddressTypeError(): NodeAuthError;
|
|
41
|
+
/**
|
|
42
|
+
* Creates an error thrown if the loopback server is unable to get a url.
|
|
43
|
+
*/
|
|
44
|
+
static createUnableToLoadRedirectUrlError(): NodeAuthError;
|
|
45
|
+
/**
|
|
46
|
+
* Creates an error thrown if the server response does not contain an auth code.
|
|
47
|
+
*/
|
|
48
|
+
static createNoAuthCodeInResponseError(): NodeAuthError;
|
|
49
|
+
/**
|
|
50
|
+
* Creates an error thrown if the loopback server has not been spun up yet.
|
|
51
|
+
*/
|
|
52
|
+
static createNoLoopbackServerExistsError(): NodeAuthError;
|
|
53
|
+
/**
|
|
54
|
+
* Creates an error thrown if a loopback server already exists when attempting to create another one.
|
|
55
|
+
*/
|
|
56
|
+
static createLoopbackServerAlreadyExistsError(): NodeAuthError;
|
|
57
|
+
/**
|
|
58
|
+
* Creates an error thrown if the loopback server times out registering the auth code listener.
|
|
59
|
+
*/
|
|
60
|
+
static createLoopbackServerTimeoutError(): NodeAuthError;
|
|
61
|
+
/**
|
|
62
|
+
* Creates an error thrown when the state is not present.
|
|
63
|
+
*/
|
|
64
|
+
static createStateNotFoundError(): NodeAuthError;
|
|
65
|
+
}
|
|
66
|
+
//# 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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6BhC,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;IAKxD;;OAEG;IACH,MAAM,CAAC,wBAAwB,IAAI,aAAa;CAGnD"}
|
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,wBAA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YAAY,EAAE,uBAAuB,EAAE,MAAM,mCAAmC,CAAC;AACjF,YAAY,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AACrE,YAAY,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AACrE,YAAY,EAAE,uBAAuB,EAAE,MAAM,mCAAmC,CAAC;AACjF,YAAY,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACzE,YAAY,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AACrE,YAAY,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAGvE,OAAO,EAEH,WAAW,EACX,YAAY,EACZ,wBAAwB,EAExB,oBAAoB,EAEpB,WAAW,EACX,cAAc,EAEd,SAAS,EACT,gBAAgB,EAChB,eAAe,EACf,sBAAsB,EACtB,wBAAwB,EACxB,+BAA+B,EAC/B,4BAA4B,EAC5B,mCAAmC,EACnC,WAAW,EAEX,cAAc,EACd,qBAAqB,EACrB,eAAe,EAEf,MAAM,EACN,QAAQ,EAER,YAAY,EACZ,YAAY,EACZ,iBAAiB,EACjB,uBAAuB,EAEvB,kBAAkB,EAClB,iBAAiB,EAEjB,iBAAiB,EACjB,0BAA0B,EAC1B,sBAAsB,EACzB,MAAM,oBAAoB,CAAC;AAE5B,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,109 @@ 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.14.0";
|
|
1776
|
+
|
|
1777
|
+
/*
|
|
1778
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
1779
|
+
* Licensed under the MIT License.
|
|
1780
|
+
*/
|
|
1781
|
+
/**
|
|
1782
|
+
* NodeAuthErrorMessage class containing string constants used by error codes and messages.
|
|
1783
|
+
*/
|
|
1784
|
+
|
|
1785
|
+
const NodeAuthErrorMessage = {
|
|
1786
|
+
invalidLoopbackAddressType: {
|
|
1787
|
+
code: "invalid_loopback_server_address_type",
|
|
1788
|
+
desc: "Loopback server address is not type string. This is unexpected."
|
|
1789
|
+
},
|
|
1790
|
+
unableToLoadRedirectUri: {
|
|
1791
|
+
code: "unable_to_load_redirectUrl",
|
|
1792
|
+
desc: "Loopback server callback was invoked without a url. This is unexpected."
|
|
1793
|
+
},
|
|
1794
|
+
noAuthCodeInResponse: {
|
|
1795
|
+
code: "no_auth_code_in_response",
|
|
1796
|
+
desc: "No auth code found in the server response. Please check your network trace to determine what happened."
|
|
1797
|
+
},
|
|
1798
|
+
noLoopbackServerExists: {
|
|
1799
|
+
code: "no_loopback_server_exists",
|
|
1800
|
+
desc: "No loopback server exists yet."
|
|
1801
|
+
},
|
|
1802
|
+
loopbackServerAlreadyExists: {
|
|
1803
|
+
code: "loopback_server_already_exists",
|
|
1804
|
+
desc: "Loopback server already exists. Cannot create another."
|
|
1805
|
+
},
|
|
1806
|
+
loopbackServerTimeout: {
|
|
1807
|
+
code: "loopback_server_timeout",
|
|
1808
|
+
desc: "Timed out waiting for auth code listener to be registered."
|
|
1809
|
+
},
|
|
1810
|
+
stateNotFoundError: {
|
|
1811
|
+
code: "state_not_found",
|
|
1812
|
+
desc: "State not found. Please verify that the request originated from msal."
|
|
1813
|
+
}
|
|
1814
|
+
};
|
|
1815
|
+
class NodeAuthError extends msalCommon.AuthError {
|
|
1816
|
+
constructor(errorCode, errorMessage) {
|
|
1817
|
+
super(errorCode, errorMessage);
|
|
1818
|
+
this.name = "NodeAuthError";
|
|
1819
|
+
}
|
|
1820
|
+
/**
|
|
1821
|
+
* Creates an error thrown if loopback server address is of type string.
|
|
1822
|
+
*/
|
|
1823
|
+
|
|
1824
|
+
|
|
1825
|
+
static createInvalidLoopbackAddressTypeError() {
|
|
1826
|
+
return new NodeAuthError(NodeAuthErrorMessage.invalidLoopbackAddressType.code, `${NodeAuthErrorMessage.invalidLoopbackAddressType.desc}`);
|
|
1827
|
+
}
|
|
1828
|
+
/**
|
|
1829
|
+
* Creates an error thrown if the loopback server is unable to get a url.
|
|
1830
|
+
*/
|
|
1831
|
+
|
|
1832
|
+
|
|
1833
|
+
static createUnableToLoadRedirectUrlError() {
|
|
1834
|
+
return new NodeAuthError(NodeAuthErrorMessage.unableToLoadRedirectUri.code, `${NodeAuthErrorMessage.unableToLoadRedirectUri.desc}`);
|
|
1835
|
+
}
|
|
1836
|
+
/**
|
|
1837
|
+
* Creates an error thrown if the server response does not contain an auth code.
|
|
1838
|
+
*/
|
|
1839
|
+
|
|
1840
|
+
|
|
1841
|
+
static createNoAuthCodeInResponseError() {
|
|
1842
|
+
return new NodeAuthError(NodeAuthErrorMessage.noAuthCodeInResponse.code, `${NodeAuthErrorMessage.noAuthCodeInResponse.desc}`);
|
|
1843
|
+
}
|
|
1844
|
+
/**
|
|
1845
|
+
* Creates an error thrown if the loopback server has not been spun up yet.
|
|
1846
|
+
*/
|
|
1847
|
+
|
|
1848
|
+
|
|
1849
|
+
static createNoLoopbackServerExistsError() {
|
|
1850
|
+
return new NodeAuthError(NodeAuthErrorMessage.noLoopbackServerExists.code, `${NodeAuthErrorMessage.noLoopbackServerExists.desc}`);
|
|
1851
|
+
}
|
|
1852
|
+
/**
|
|
1853
|
+
* Creates an error thrown if a loopback server already exists when attempting to create another one.
|
|
1854
|
+
*/
|
|
1855
|
+
|
|
1856
|
+
|
|
1857
|
+
static createLoopbackServerAlreadyExistsError() {
|
|
1858
|
+
return new NodeAuthError(NodeAuthErrorMessage.loopbackServerAlreadyExists.code, `${NodeAuthErrorMessage.loopbackServerAlreadyExists.desc}`);
|
|
1859
|
+
}
|
|
1860
|
+
/**
|
|
1861
|
+
* Creates an error thrown if the loopback server times out registering the auth code listener.
|
|
1862
|
+
*/
|
|
1863
|
+
|
|
1864
|
+
|
|
1865
|
+
static createLoopbackServerTimeoutError() {
|
|
1866
|
+
return new NodeAuthError(NodeAuthErrorMessage.loopbackServerTimeout.code, `${NodeAuthErrorMessage.loopbackServerTimeout.desc}`);
|
|
1867
|
+
}
|
|
1868
|
+
/**
|
|
1869
|
+
* Creates an error thrown when the state is not present.
|
|
1870
|
+
*/
|
|
1871
|
+
|
|
1872
|
+
|
|
1873
|
+
static createStateNotFoundError() {
|
|
1874
|
+
return new NodeAuthError(NodeAuthErrorMessage.stateNotFoundError.code, NodeAuthErrorMessage.stateNotFoundError.desc);
|
|
1875
|
+
}
|
|
1876
|
+
|
|
1877
|
+
}
|
|
1762
1878
|
|
|
1763
1879
|
/*
|
|
1764
1880
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -1814,7 +1930,17 @@ class ClientApplication {
|
|
|
1814
1930
|
|
|
1815
1931
|
|
|
1816
1932
|
async acquireTokenByCode(request, authCodePayLoad) {
|
|
1817
|
-
this.logger.info("acquireTokenByCode called"
|
|
1933
|
+
this.logger.info("acquireTokenByCode called");
|
|
1934
|
+
|
|
1935
|
+
if (request.state && authCodePayLoad) {
|
|
1936
|
+
this.logger.info("acquireTokenByCode - validating state");
|
|
1937
|
+
this.validateState(request.state, authCodePayLoad.state || ""); // eslint-disable-next-line no-param-reassign
|
|
1938
|
+
|
|
1939
|
+
authCodePayLoad = { ...authCodePayLoad,
|
|
1940
|
+
state: ""
|
|
1941
|
+
};
|
|
1942
|
+
}
|
|
1943
|
+
|
|
1818
1944
|
const validRequest = { ...request,
|
|
1819
1945
|
...(await this.initializeBaseRequest(request)),
|
|
1820
1946
|
authenticationScheme: msalCommon.AuthenticationScheme.BEARER
|
|
@@ -1939,6 +2065,26 @@ class ClientApplication {
|
|
|
1939
2065
|
this.logger.info("getTokenCache called");
|
|
1940
2066
|
return this.tokenCache;
|
|
1941
2067
|
}
|
|
2068
|
+
/**
|
|
2069
|
+
* Validates OIDC state by comparing the user cached state with the state received from the server.
|
|
2070
|
+
*
|
|
2071
|
+
* This API is provided for scenarios where you would use OAuth2.0 state parameter to mitigate against
|
|
2072
|
+
* CSRF attacks.
|
|
2073
|
+
* For more information about state, visit https://datatracker.ietf.org/doc/html/rfc6819#section-3.6.
|
|
2074
|
+
* @param state
|
|
2075
|
+
* @param cachedState
|
|
2076
|
+
*/
|
|
2077
|
+
|
|
2078
|
+
|
|
2079
|
+
validateState(state, cachedState) {
|
|
2080
|
+
if (!state) {
|
|
2081
|
+
throw NodeAuthError.createStateNotFoundError();
|
|
2082
|
+
}
|
|
2083
|
+
|
|
2084
|
+
if (state !== cachedState) {
|
|
2085
|
+
throw msalCommon.ClientAuthError.createStateMismatchError();
|
|
2086
|
+
}
|
|
2087
|
+
}
|
|
1942
2088
|
/**
|
|
1943
2089
|
* Returns the logger instance
|
|
1944
2090
|
*/
|
|
@@ -2087,6 +2233,102 @@ class ClientApplication {
|
|
|
2087
2233
|
|
|
2088
2234
|
}
|
|
2089
2235
|
|
|
2236
|
+
/*
|
|
2237
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2238
|
+
* Licensed under the MIT License.
|
|
2239
|
+
*/
|
|
2240
|
+
class LoopbackClient {
|
|
2241
|
+
/**
|
|
2242
|
+
* Spins up a loopback server which returns the server response when the localhost redirectUri is hit
|
|
2243
|
+
* @param successTemplate
|
|
2244
|
+
* @param errorTemplate
|
|
2245
|
+
* @returns
|
|
2246
|
+
*/
|
|
2247
|
+
async listenForAuthCode(successTemplate, errorTemplate) {
|
|
2248
|
+
if (!!this.server) {
|
|
2249
|
+
throw NodeAuthError.createLoopbackServerAlreadyExistsError();
|
|
2250
|
+
}
|
|
2251
|
+
|
|
2252
|
+
const authCodeListener = new Promise((resolve, reject) => {
|
|
2253
|
+
this.server = http.createServer(async (req, res) => {
|
|
2254
|
+
const url = req.url;
|
|
2255
|
+
|
|
2256
|
+
if (!url) {
|
|
2257
|
+
res.end(errorTemplate || "Error occurred loading redirectUrl");
|
|
2258
|
+
reject(NodeAuthError.createUnableToLoadRedirectUrlError());
|
|
2259
|
+
return;
|
|
2260
|
+
} else if (url === msalCommon.Constants.FORWARD_SLASH) {
|
|
2261
|
+
res.end(successTemplate || "Auth code was successfully acquired. You can close this window now.");
|
|
2262
|
+
return;
|
|
2263
|
+
}
|
|
2264
|
+
|
|
2265
|
+
const authCodeResponse = msalCommon.UrlString.getDeserializedQueryString(url);
|
|
2266
|
+
|
|
2267
|
+
if (authCodeResponse.code) {
|
|
2268
|
+
const redirectUri = await this.getRedirectUri();
|
|
2269
|
+
res.writeHead(HttpStatus.REDIRECT, {
|
|
2270
|
+
location: redirectUri
|
|
2271
|
+
}); // Prevent auth code from being saved in the browser history
|
|
2272
|
+
|
|
2273
|
+
res.end();
|
|
2274
|
+
}
|
|
2275
|
+
|
|
2276
|
+
resolve(authCodeResponse);
|
|
2277
|
+
});
|
|
2278
|
+
this.server.listen(0); // Listen on any available port
|
|
2279
|
+
}); // Wait for server to be listening
|
|
2280
|
+
|
|
2281
|
+
await new Promise(resolve => {
|
|
2282
|
+
let ticks = 0;
|
|
2283
|
+
const id = setInterval(() => {
|
|
2284
|
+
if (LOOPBACK_SERVER_CONSTANTS.TIMEOUT_MS / LOOPBACK_SERVER_CONSTANTS.INTERVAL_MS < ticks) {
|
|
2285
|
+
throw NodeAuthError.createLoopbackServerTimeoutError();
|
|
2286
|
+
}
|
|
2287
|
+
|
|
2288
|
+
if (this.server.listening) {
|
|
2289
|
+
clearInterval(id);
|
|
2290
|
+
resolve();
|
|
2291
|
+
}
|
|
2292
|
+
|
|
2293
|
+
ticks++;
|
|
2294
|
+
}, LOOPBACK_SERVER_CONSTANTS.INTERVAL_MS);
|
|
2295
|
+
});
|
|
2296
|
+
return authCodeListener;
|
|
2297
|
+
}
|
|
2298
|
+
/**
|
|
2299
|
+
* Get the port that the loopback server is running on
|
|
2300
|
+
* @returns
|
|
2301
|
+
*/
|
|
2302
|
+
|
|
2303
|
+
|
|
2304
|
+
getRedirectUri() {
|
|
2305
|
+
if (!this.server) {
|
|
2306
|
+
throw NodeAuthError.createNoLoopbackServerExistsError();
|
|
2307
|
+
}
|
|
2308
|
+
|
|
2309
|
+
const address = this.server.address();
|
|
2310
|
+
|
|
2311
|
+
if (!address || typeof address === "string" || !address.port) {
|
|
2312
|
+
this.closeServer();
|
|
2313
|
+
throw NodeAuthError.createInvalidLoopbackAddressTypeError();
|
|
2314
|
+
}
|
|
2315
|
+
|
|
2316
|
+
const port = address && address.port;
|
|
2317
|
+
return `${Constants.HTTP_PROTOCOL}${Constants.LOCALHOST}:${port}`;
|
|
2318
|
+
}
|
|
2319
|
+
/**
|
|
2320
|
+
* Close the loopback server
|
|
2321
|
+
*/
|
|
2322
|
+
|
|
2323
|
+
|
|
2324
|
+
closeServer() {
|
|
2325
|
+
if (!!this.server) {
|
|
2326
|
+
this.server.close();
|
|
2327
|
+
}
|
|
2328
|
+
}
|
|
2329
|
+
|
|
2330
|
+
}
|
|
2331
|
+
|
|
2090
2332
|
/*
|
|
2091
2333
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2092
2334
|
* Licensed under the MIT License.
|
|
@@ -2148,6 +2390,54 @@ class PublicClientApplication extends ClientApplication {
|
|
|
2148
2390
|
throw e;
|
|
2149
2391
|
}
|
|
2150
2392
|
}
|
|
2393
|
+
/**
|
|
2394
|
+
* Acquires a token by requesting an Authorization code then exchanging it for a token.
|
|
2395
|
+
*/
|
|
2396
|
+
|
|
2397
|
+
|
|
2398
|
+
async acquireTokenInteractive(request) {
|
|
2399
|
+
const {
|
|
2400
|
+
verifier,
|
|
2401
|
+
challenge
|
|
2402
|
+
} = await this.cryptoProvider.generatePkceCodes();
|
|
2403
|
+
const {
|
|
2404
|
+
openBrowser,
|
|
2405
|
+
successTemplate,
|
|
2406
|
+
errorTemplate,
|
|
2407
|
+
...remainingProperties
|
|
2408
|
+
} = request;
|
|
2409
|
+
const loopbackClient = new LoopbackClient();
|
|
2410
|
+
const authCodeListener = loopbackClient.listenForAuthCode(successTemplate, errorTemplate);
|
|
2411
|
+
const redirectUri = loopbackClient.getRedirectUri();
|
|
2412
|
+
const validRequest = { ...remainingProperties,
|
|
2413
|
+
scopes: request.scopes || [],
|
|
2414
|
+
redirectUri: redirectUri,
|
|
2415
|
+
responseMode: msalCommon.ResponseMode.QUERY,
|
|
2416
|
+
codeChallenge: challenge,
|
|
2417
|
+
codeChallengeMethod: msalCommon.CodeChallengeMethodValues.S256
|
|
2418
|
+
};
|
|
2419
|
+
const authCodeUrl = await this.getAuthCodeUrl(validRequest);
|
|
2420
|
+
await openBrowser(authCodeUrl);
|
|
2421
|
+
const authCodeResponse = await authCodeListener.finally(() => {
|
|
2422
|
+
loopbackClient.closeServer();
|
|
2423
|
+
});
|
|
2424
|
+
|
|
2425
|
+
if (authCodeResponse.error) {
|
|
2426
|
+
throw new msalCommon.ServerError(authCodeResponse.error, authCodeResponse.error_description, authCodeResponse.suberror);
|
|
2427
|
+
} else if (!authCodeResponse.code) {
|
|
2428
|
+
throw NodeAuthError.createNoAuthCodeInResponseError();
|
|
2429
|
+
}
|
|
2430
|
+
|
|
2431
|
+
const clientInfo = authCodeResponse.client_info;
|
|
2432
|
+
const tokenRequest = {
|
|
2433
|
+
code: authCodeResponse.code,
|
|
2434
|
+
scopes: msalCommon.OIDC_DEFAULT_SCOPES,
|
|
2435
|
+
redirectUri: validRequest.redirectUri,
|
|
2436
|
+
codeVerifier: verifier,
|
|
2437
|
+
clientInfo: clientInfo || msalCommon.Constants.EMPTY_STRING
|
|
2438
|
+
};
|
|
2439
|
+
return this.acquireTokenByCode(tokenRequest);
|
|
2440
|
+
}
|
|
2151
2441
|
|
|
2152
2442
|
}
|
|
2153
2443
|
|