@azure/msal-node 2.0.2 → 2.2.0-alpha.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/README.md +3 -1
- package/dist/cache/ITokenCache.d.ts +15 -15
- package/dist/cache/NodeStorage.cjs +401 -401
- package/dist/cache/NodeStorage.cjs.map +1 -1
- package/dist/cache/NodeStorage.d.ts +182 -182
- package/dist/cache/NodeStorage.d.ts.map +1 -1
- package/dist/cache/NodeStorage.mjs +401 -401
- package/dist/cache/NodeStorage.mjs.map +1 -1
- package/dist/cache/TokenCache.cjs +265 -269
- package/dist/cache/TokenCache.cjs.map +1 -1
- package/dist/cache/TokenCache.d.ts +90 -90
- package/dist/cache/TokenCache.d.ts.map +1 -1
- package/dist/cache/TokenCache.mjs +266 -270
- package/dist/cache/TokenCache.mjs.map +1 -1
- package/dist/cache/distributed/DistributedCachePlugin.cjs +26 -26
- package/dist/cache/distributed/DistributedCachePlugin.cjs.map +1 -1
- package/dist/cache/distributed/DistributedCachePlugin.d.ts +10 -10
- package/dist/cache/distributed/DistributedCachePlugin.d.ts.map +1 -1
- package/dist/cache/distributed/DistributedCachePlugin.mjs +26 -26
- package/dist/cache/distributed/DistributedCachePlugin.mjs.map +1 -1
- package/dist/cache/distributed/ICacheClient.d.ts +17 -17
- package/dist/cache/distributed/IPartitionManager.d.ts +28 -28
- package/dist/cache/serializer/Deserializer.cjs +173 -175
- package/dist/cache/serializer/Deserializer.cjs.map +1 -1
- package/dist/cache/serializer/Deserializer.d.ts +42 -42
- package/dist/cache/serializer/Deserializer.d.ts.map +1 -1
- package/dist/cache/serializer/Deserializer.mjs +174 -176
- package/dist/cache/serializer/Deserializer.mjs.map +1 -1
- package/dist/cache/serializer/Serializer.cjs +134 -134
- package/dist/cache/serializer/Serializer.cjs.map +1 -1
- package/dist/cache/serializer/Serializer.d.ts +39 -39
- package/dist/cache/serializer/Serializer.d.ts.map +1 -1
- package/dist/cache/serializer/Serializer.mjs +134 -134
- package/dist/cache/serializer/Serializer.mjs.map +1 -1
- package/dist/cache/serializer/SerializerTypes.d.ts +101 -101
- package/dist/client/ClientApplication.cjs +333 -333
- package/dist/client/ClientApplication.cjs.map +1 -1
- package/dist/client/ClientApplication.d.ts +142 -142
- package/dist/client/ClientApplication.d.ts.map +1 -1
- package/dist/client/ClientApplication.mjs +334 -334
- package/dist/client/ClientApplication.mjs.map +1 -1
- package/dist/client/ClientAssertion.cjs +116 -116
- package/dist/client/ClientAssertion.cjs.map +1 -1
- package/dist/client/ClientAssertion.d.ts +46 -46
- package/dist/client/ClientAssertion.d.ts.map +1 -1
- package/dist/client/ClientAssertion.mjs +117 -117
- package/dist/client/ClientAssertion.mjs.map +1 -1
- package/dist/client/ClientCredentialClient.cjs +189 -168
- package/dist/client/ClientCredentialClient.cjs.map +1 -1
- package/dist/client/ClientCredentialClient.d.ts +33 -33
- package/dist/client/ClientCredentialClient.d.ts.map +1 -1
- package/dist/client/ClientCredentialClient.mjs +190 -169
- package/dist/client/ClientCredentialClient.mjs.map +1 -1
- package/dist/client/ConfidentialClientApplication.cjs +163 -164
- package/dist/client/ConfidentialClientApplication.cjs.map +1 -1
- package/dist/client/ConfidentialClientApplication.d.ts +58 -58
- package/dist/client/ConfidentialClientApplication.d.ts.map +1 -1
- package/dist/client/ConfidentialClientApplication.mjs +164 -165
- package/dist/client/ConfidentialClientApplication.mjs.map +1 -1
- package/dist/client/DeviceCodeClient.cjs +207 -207
- package/dist/client/DeviceCodeClient.cjs.map +1 -1
- package/dist/client/DeviceCodeClient.d.ts +53 -53
- package/dist/client/DeviceCodeClient.d.ts.map +1 -1
- package/dist/client/DeviceCodeClient.mjs +208 -208
- package/dist/client/DeviceCodeClient.mjs.map +1 -1
- package/dist/client/IConfidentialClientApplication.d.ts +39 -39
- package/dist/client/IConfidentialClientApplication.d.ts.map +1 -1
- package/dist/client/IPublicClientApplication.d.ts +42 -42
- package/dist/client/IPublicClientApplication.d.ts.map +1 -1
- package/dist/client/OnBehalfOfClient.cjs +203 -204
- package/dist/client/OnBehalfOfClient.cjs.map +1 -1
- package/dist/client/OnBehalfOfClient.d.ts +47 -47
- package/dist/client/OnBehalfOfClient.d.ts.map +1 -1
- package/dist/client/OnBehalfOfClient.mjs +204 -205
- package/dist/client/OnBehalfOfClient.mjs.map +1 -1
- package/dist/client/PublicClientApplication.cjs +229 -175
- package/dist/client/PublicClientApplication.cjs.map +1 -1
- package/dist/client/PublicClientApplication.d.ts +71 -65
- package/dist/client/PublicClientApplication.d.ts.map +1 -1
- package/dist/client/PublicClientApplication.mjs +232 -178
- package/dist/client/PublicClientApplication.mjs.map +1 -1
- package/dist/client/UsernamePasswordClient.cjs +95 -95
- package/dist/client/UsernamePasswordClient.cjs.map +1 -1
- package/dist/client/UsernamePasswordClient.d.ts +25 -25
- package/dist/client/UsernamePasswordClient.d.ts.map +1 -1
- package/dist/client/UsernamePasswordClient.mjs +95 -95
- package/dist/client/UsernamePasswordClient.mjs.map +1 -1
- package/dist/config/Configuration.cjs +72 -72
- package/dist/config/Configuration.cjs.map +1 -1
- package/dist/config/Configuration.d.ts +107 -107
- package/dist/config/Configuration.mjs +72 -72
- package/dist/config/Configuration.mjs.map +1 -1
- package/dist/crypto/CryptoProvider.cjs +75 -75
- package/dist/crypto/CryptoProvider.cjs.map +1 -1
- package/dist/crypto/CryptoProvider.d.ts +52 -52
- package/dist/crypto/CryptoProvider.mjs +75 -75
- package/dist/crypto/CryptoProvider.mjs.map +1 -1
- package/dist/crypto/GuidGenerator.cjs +22 -22
- package/dist/crypto/GuidGenerator.cjs.map +1 -1
- package/dist/crypto/GuidGenerator.d.ts +14 -14
- package/dist/crypto/GuidGenerator.mjs +22 -22
- package/dist/crypto/GuidGenerator.mjs.map +1 -1
- package/dist/crypto/HashUtils.cjs +13 -13
- package/dist/crypto/HashUtils.cjs.map +1 -1
- package/dist/crypto/HashUtils.d.ts +8 -8
- package/dist/crypto/HashUtils.mjs +13 -13
- package/dist/crypto/HashUtils.mjs.map +1 -1
- package/dist/crypto/PkceGenerator.cjs +49 -49
- package/dist/crypto/PkceGenerator.cjs.map +1 -1
- package/dist/crypto/PkceGenerator.d.ts +22 -22
- package/dist/crypto/PkceGenerator.mjs +49 -49
- package/dist/crypto/PkceGenerator.mjs.map +1 -1
- package/dist/error/NodeAuthError.cjs +85 -85
- package/dist/error/NodeAuthError.cjs.map +1 -1
- package/dist/error/NodeAuthError.d.ts +65 -65
- package/dist/error/NodeAuthError.mjs +85 -85
- package/dist/error/NodeAuthError.mjs.map +1 -1
- package/dist/index.cjs +17 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +42 -42
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/internals.cjs +8 -8
- package/dist/internals.cjs.map +1 -1
- package/dist/internals.d.ts +6 -6
- package/dist/internals.d.ts.map +1 -1
- package/dist/internals.mjs +8 -8
- package/dist/internals.mjs.map +1 -1
- package/dist/network/HttpClient.cjs +277 -276
- package/dist/network/HttpClient.cjs.map +1 -1
- package/dist/network/HttpClient.d.ts +25 -25
- package/dist/network/HttpClient.d.ts.map +1 -1
- package/dist/network/HttpClient.mjs +278 -277
- package/dist/network/HttpClient.mjs.map +1 -1
- package/dist/network/ILoopbackClient.d.ts +10 -10
- package/dist/network/LoopbackClient.cjs +75 -84
- package/dist/network/LoopbackClient.cjs.map +1 -1
- package/dist/network/LoopbackClient.d.ts +21 -21
- package/dist/network/LoopbackClient.d.ts.map +1 -1
- package/dist/network/LoopbackClient.mjs +77 -86
- package/dist/network/LoopbackClient.mjs.map +1 -1
- package/dist/packageMetadata.cjs +4 -4
- package/dist/packageMetadata.cjs.map +1 -1
- package/dist/packageMetadata.d.ts +2 -2
- package/dist/packageMetadata.mjs +4 -4
- package/dist/packageMetadata.mjs.map +1 -1
- package/dist/request/AuthorizationCodeRequest.d.ts +21 -21
- package/dist/request/AuthorizationUrlRequest.d.ts +33 -33
- package/dist/request/ClientCredentialRequest.d.ts +14 -14
- package/dist/request/DeviceCodeRequest.d.ts +15 -15
- package/dist/request/InteractiveRequest.d.ts +22 -22
- package/dist/request/InteractiveRequest.d.ts.map +1 -1
- package/dist/request/OnBehalfOfRequest.d.ts +14 -14
- package/dist/request/RefreshTokenRequest.d.ts +17 -17
- package/dist/request/SignOutRequest.d.ts +5 -5
- package/dist/request/SilentFlowRequest.d.ts +16 -16
- package/dist/request/UsernamePasswordRequest.d.ts +19 -19
- package/dist/utils/Constants.cjs +80 -90
- package/dist/utils/Constants.cjs.map +1 -1
- package/dist/utils/Constants.d.ts +86 -96
- package/dist/utils/Constants.d.ts.map +1 -1
- package/dist/utils/Constants.mjs +81 -90
- package/dist/utils/Constants.mjs.map +1 -1
- package/dist/utils/EncodingUtils.cjs +44 -44
- package/dist/utils/EncodingUtils.cjs.map +1 -1
- package/dist/utils/EncodingUtils.d.ts +26 -26
- package/dist/utils/EncodingUtils.mjs +44 -44
- package/dist/utils/EncodingUtils.mjs.map +1 -1
- package/dist/utils/NetworkUtils.cjs +38 -38
- package/dist/utils/NetworkUtils.cjs.map +1 -1
- package/dist/utils/NetworkUtils.d.ts +5 -5
- package/dist/utils/NetworkUtils.mjs +38 -38
- package/dist/utils/NetworkUtils.mjs.map +1 -1
- package/package.json +8 -5
- package/src/cache/ITokenCache.ts +24 -0
- package/src/cache/NodeStorage.ts +533 -0
- package/src/cache/TokenCache.ts +358 -0
- package/src/cache/distributed/DistributedCachePlugin.ts +56 -0
- package/src/cache/distributed/ICacheClient.ts +23 -0
- package/src/cache/distributed/IPartitionManager.ts +35 -0
- package/src/cache/serializer/Deserializer.ts +218 -0
- package/src/cache/serializer/Serializer.ts +173 -0
- package/src/cache/serializer/SerializerTypes.ts +121 -0
- package/src/client/ClientApplication.ts +596 -0
- package/src/client/ClientAssertion.ts +165 -0
- package/src/client/ClientCredentialClient.ts +346 -0
- package/src/client/ConfidentialClientApplication.ts +268 -0
- package/src/client/DeviceCodeClient.ts +369 -0
- package/src/client/IConfidentialClientApplication.ts +72 -0
- package/src/client/IPublicClientApplication.ts +72 -0
- package/src/client/OnBehalfOfClient.ts +368 -0
- package/src/client/PublicClientApplication.ts +339 -0
- package/src/client/UsernamePasswordClient.ts +180 -0
- package/src/config/Configuration.ts +201 -0
- package/src/crypto/CryptoProvider.ts +98 -0
- package/src/crypto/GuidGenerator.ts +28 -0
- package/src/crypto/HashUtils.ts +17 -0
- package/src/crypto/PkceGenerator.ts +63 -0
- package/src/error/NodeAuthError.ts +117 -0
- package/src/index.ts +125 -0
- package/src/internals.ts +12 -0
- package/src/network/HttpClient.ts +425 -0
- package/src/network/ILoopbackClient.ts +19 -0
- package/src/network/LoopbackClient.ts +110 -0
- package/src/packageMetadata.ts +3 -0
- package/src/request/AuthorizationCodeRequest.ts +39 -0
- package/src/request/AuthorizationUrlRequest.ts +50 -0
- package/src/request/ClientCredentialRequest.ts +29 -0
- package/src/request/DeviceCodeRequest.ts +34 -0
- package/src/request/InteractiveRequest.ts +39 -0
- package/src/request/OnBehalfOfRequest.ts +30 -0
- package/src/request/RefreshTokenRequest.ts +34 -0
- package/src/request/SignOutRequest.ts +11 -0
- package/src/request/SilentFlowRequest.ts +32 -0
- package/src/request/UsernamePasswordRequest.ts +36 -0
- package/src/utils/Constants.ts +103 -0
- package/src/utils/EncodingUtils.ts +50 -0
- package/src/utils/NetworkUtils.ts +49 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
CommonDeviceCodeRequest,
|
|
8
|
+
DeviceCodeResponse,
|
|
9
|
+
} from "@azure/msal-common";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Parameters for Oauth2 device code flow.
|
|
13
|
+
* - scopes - Array of scopes the application is requesting access to.
|
|
14
|
+
* - authority: - URL of the authority, the security token service (STS) from which MSAL will acquire tokens. If authority is set on client application object, this will override that value. Overriding the value will cause for authority validation to happen each time. If the same authority will be used for all request, set on the application object instead of the requests.
|
|
15
|
+
* - correlationId - Unique GUID set per request to trace a request end-to-end for telemetry purposes.
|
|
16
|
+
* - deviceCodeCallback - Callback containing device code response. Message should be shown to end user. End user can then navigate to the verification_uri, input the user_code, and input credentials.
|
|
17
|
+
* - cancel - Boolean to cancel polling of device code endpoint. While the user authenticates on a separate device, MSAL polls the the token endpoint of security token service for the interval specified in the device code response (usually 15 minutes). To stop polling and cancel the request, set cancel=true.
|
|
18
|
+
* - extraQueryParameters - String to string map of custom query parameters added to the query string
|
|
19
|
+
* @public
|
|
20
|
+
*/
|
|
21
|
+
export type DeviceCodeRequest = Partial<
|
|
22
|
+
Omit<
|
|
23
|
+
CommonDeviceCodeRequest,
|
|
24
|
+
| "scopes"
|
|
25
|
+
| "deviceCodeCallback"
|
|
26
|
+
| "resourceRequestMethod"
|
|
27
|
+
| "resourceRequestUri"
|
|
28
|
+
| "requestedClaimsHash"
|
|
29
|
+
| "storeInCache"
|
|
30
|
+
>
|
|
31
|
+
> & {
|
|
32
|
+
scopes: Array<string>;
|
|
33
|
+
deviceCodeCallback: (response: DeviceCodeResponse) => void;
|
|
34
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { ILoopbackClient } from "../network/ILoopbackClient.js";
|
|
7
|
+
import { AuthorizationUrlRequest } from "./AuthorizationUrlRequest.js";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Request object passed by user to configure acquireTokenInteractive API
|
|
11
|
+
*
|
|
12
|
+
* - openBrowser - Function to open a browser instance on user's system.
|
|
13
|
+
* - scopes - Array of scopes the application is requesting access to.
|
|
14
|
+
* - successTemplate: - Template to be displayed on the opened browser instance upon successful token acquisition.
|
|
15
|
+
* - errorTemplate - Template to be displayed on the opened browser instance upon token acquisition failure.
|
|
16
|
+
* - windowHandle - Used in native broker flows to properly parent the native broker window
|
|
17
|
+
* - loopbackClient - Custom implementation for a loopback server to listen for authorization code response.
|
|
18
|
+
* @public
|
|
19
|
+
*/
|
|
20
|
+
export type InteractiveRequest = Pick<
|
|
21
|
+
AuthorizationUrlRequest,
|
|
22
|
+
| "authority"
|
|
23
|
+
| "correlationId"
|
|
24
|
+
| "claims"
|
|
25
|
+
| "azureCloudOptions"
|
|
26
|
+
| "account"
|
|
27
|
+
| "extraQueryParameters"
|
|
28
|
+
| "tokenQueryParameters"
|
|
29
|
+
| "extraScopesToConsent"
|
|
30
|
+
| "loginHint"
|
|
31
|
+
| "prompt"
|
|
32
|
+
> & {
|
|
33
|
+
openBrowser: (url: string) => Promise<void>;
|
|
34
|
+
scopes?: Array<string>;
|
|
35
|
+
successTemplate?: string;
|
|
36
|
+
errorTemplate?: string;
|
|
37
|
+
windowHandle?: Buffer; // Relevant only to brokered requests
|
|
38
|
+
loopbackClient?: ILoopbackClient;
|
|
39
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { CommonOnBehalfOfRequest } from "@azure/msal-common";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* - scopes - Array of scopes the application is requesting access to.
|
|
10
|
+
* - authority - URL of the authority, the security token service (STS) from which MSAL will acquire tokens.
|
|
11
|
+
* - correlationId - Unique GUID set per request to trace a request end-to-end for telemetry purposes.
|
|
12
|
+
* - oboAssertion - The access token that was sent to the middle-tier API. This token must have an audience of the app making this OBO request.
|
|
13
|
+
* - skipCache - Skip token cache lookup and force request to authority to get a a new token. Defaults to false.
|
|
14
|
+
* - tokenQueryParameters - String to string map of custom query parameters added to the /token call
|
|
15
|
+
* @public
|
|
16
|
+
*/
|
|
17
|
+
export type OnBehalfOfRequest = Partial<
|
|
18
|
+
Omit<
|
|
19
|
+
CommonOnBehalfOfRequest,
|
|
20
|
+
| "oboAssertion"
|
|
21
|
+
| "scopes"
|
|
22
|
+
| "resourceRequestMethod"
|
|
23
|
+
| "resourceRequestUri"
|
|
24
|
+
| "requestedClaimsHash"
|
|
25
|
+
| "storeInCache"
|
|
26
|
+
>
|
|
27
|
+
> & {
|
|
28
|
+
oboAssertion: string;
|
|
29
|
+
scopes: Array<string>;
|
|
30
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { CommonRefreshTokenRequest } from "@azure/msal-common";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* CommonRefreshTokenRequest
|
|
10
|
+
* - scopes - Array of scopes the application is requesting access to.
|
|
11
|
+
* - claims - A stringified claims request which will be added to all /authorize and /token calls
|
|
12
|
+
* - authority - URL of the authority, the security token service (STS) from which MSAL will acquire tokens.
|
|
13
|
+
* - correlationId - Unique GUID set per request to trace a request end-to-end for telemetry purposes.
|
|
14
|
+
* - refreshToken - A refresh token returned from a previous request to the Identity provider.
|
|
15
|
+
* - tokenQueryParameters - String to string map of custom query parameters added to the /token call
|
|
16
|
+
* - forceCache - Force MSAL to cache a refresh token flow response when there is no account in the cache. Used for migration scenarios.
|
|
17
|
+
* @public
|
|
18
|
+
*/
|
|
19
|
+
export type RefreshTokenRequest = Partial<
|
|
20
|
+
Omit<
|
|
21
|
+
CommonRefreshTokenRequest,
|
|
22
|
+
| "scopes"
|
|
23
|
+
| "refreshToken"
|
|
24
|
+
| "authenticationScheme"
|
|
25
|
+
| "resourceRequestMethod"
|
|
26
|
+
| "resourceRequestUri"
|
|
27
|
+
| "requestedClaimsHash"
|
|
28
|
+
| "storeInCache"
|
|
29
|
+
>
|
|
30
|
+
> & {
|
|
31
|
+
scopes: Array<string>;
|
|
32
|
+
refreshToken: string;
|
|
33
|
+
forceCache?: boolean;
|
|
34
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { AccountInfo, CommonSilentFlowRequest } from "@azure/msal-common";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* SilentFlow parameters passed by the user to retrieve credentials silently
|
|
10
|
+
* - scopes - Array of scopes the application is requesting access to.
|
|
11
|
+
* - claims - A stringified claims request which will be added to all /authorize and /token calls. When included on a silent request, cache lookup will be skipped and token will be refreshed.
|
|
12
|
+
* - authority - Url of the authority which the application acquires tokens from.
|
|
13
|
+
* - correlationId - Unique GUID set per request to trace a request end-to-end for telemetry purposes.
|
|
14
|
+
* - tokenQueryParameters - String to string map of custom query parameters added to the /token call
|
|
15
|
+
* - account - Account entity to lookup the credentials.
|
|
16
|
+
* - forceRefresh - Forces silent requests to make network calls if true.
|
|
17
|
+
* @public
|
|
18
|
+
*/
|
|
19
|
+
export type SilentFlowRequest = Partial<
|
|
20
|
+
Omit<
|
|
21
|
+
CommonSilentFlowRequest,
|
|
22
|
+
| "account"
|
|
23
|
+
| "scopes"
|
|
24
|
+
| "resourceRequestMethod"
|
|
25
|
+
| "resourceRequestUri"
|
|
26
|
+
| "requestedClaimsHash"
|
|
27
|
+
| "storeInCache"
|
|
28
|
+
>
|
|
29
|
+
> & {
|
|
30
|
+
account: AccountInfo;
|
|
31
|
+
scopes: Array<string>;
|
|
32
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { CommonUsernamePasswordRequest } from "@azure/msal-common";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* UsernamePassword parameters passed by the user to retrieve credentials
|
|
10
|
+
* Note: The latest OAuth 2.0 Security Best Current Practice disallows the password grant entirely. This flow is added for internal testing.
|
|
11
|
+
*
|
|
12
|
+
* - scopes - Array of scopes the application is requesting access to.
|
|
13
|
+
* - claims - A stringified claims request which will be added to all /authorize and /token calls. When included on a silent request, cache lookup will be skipped and token will be refreshed.
|
|
14
|
+
* - authority - Url of the authority which the application acquires tokens from.
|
|
15
|
+
* - correlationId - Unique GUID set per request to trace a request end-to-end for telemetry purposes.
|
|
16
|
+
* - username - username of the client
|
|
17
|
+
* - password - credentials
|
|
18
|
+
* - tokenQueryParameters - String to string map of custom query parameters added to the /token call
|
|
19
|
+
* @public
|
|
20
|
+
*/
|
|
21
|
+
export type UsernamePasswordRequest = Partial<
|
|
22
|
+
Omit<
|
|
23
|
+
CommonUsernamePasswordRequest,
|
|
24
|
+
| "scopes"
|
|
25
|
+
| "resourceRequestMethod"
|
|
26
|
+
| "resourceRequestUri"
|
|
27
|
+
| "username"
|
|
28
|
+
| "password"
|
|
29
|
+
| "requestedClaimsHash"
|
|
30
|
+
| "storeInCache"
|
|
31
|
+
>
|
|
32
|
+
> & {
|
|
33
|
+
scopes: Array<string>;
|
|
34
|
+
username: string;
|
|
35
|
+
password: string;
|
|
36
|
+
};
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* http methods
|
|
8
|
+
*/
|
|
9
|
+
export const HttpMethod = {
|
|
10
|
+
GET: "get",
|
|
11
|
+
POST: "post",
|
|
12
|
+
} as const;
|
|
13
|
+
export type HttpMethod = (typeof HttpMethod)[keyof typeof HttpMethod];
|
|
14
|
+
|
|
15
|
+
export const ProxyStatus = {
|
|
16
|
+
SUCCESS_RANGE_START: 200,
|
|
17
|
+
SUCCESS_RANGE_END: 299,
|
|
18
|
+
SERVER_ERROR: 500,
|
|
19
|
+
} as const;
|
|
20
|
+
export type ProxyStatus = (typeof ProxyStatus)[keyof typeof ProxyStatus];
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Constants used for region discovery
|
|
24
|
+
*/
|
|
25
|
+
export const REGION_ENVIRONMENT_VARIABLE = "REGION_NAME";
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Constant used for PKCE
|
|
29
|
+
*/
|
|
30
|
+
export const RANDOM_OCTET_SIZE = 32;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Constants used in PKCE
|
|
34
|
+
*/
|
|
35
|
+
export const Hash = {
|
|
36
|
+
SHA256: "sha256",
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Constants for encoding schemes
|
|
41
|
+
*/
|
|
42
|
+
export const CharSet = {
|
|
43
|
+
CV_CHARSET:
|
|
44
|
+
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~",
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Cache Constants
|
|
49
|
+
*/
|
|
50
|
+
export const CACHE = {
|
|
51
|
+
FILE_CACHE: "fileCache",
|
|
52
|
+
EXTENSION_LIB: "extenstion_library",
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Constants
|
|
57
|
+
*/
|
|
58
|
+
export const Constants = {
|
|
59
|
+
MSAL_SKU: "msal.js.node",
|
|
60
|
+
JWT_BEARER_ASSERTION_TYPE:
|
|
61
|
+
"urn:ietf:params:oauth:client-assertion-type:jwt-bearer",
|
|
62
|
+
AUTHORIZATION_PENDING: "authorization_pending",
|
|
63
|
+
HTTP_PROTOCOL: "http://",
|
|
64
|
+
LOCALHOST: "localhost",
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* API Codes for Telemetry purposes.
|
|
69
|
+
* Before adding a new code you must claim it in the MSAL Telemetry tracker as these number spaces are shared across all MSALs
|
|
70
|
+
* 0-99 Silent Flow
|
|
71
|
+
* 600-699 Device Code Flow
|
|
72
|
+
* 800-899 Auth Code Flow
|
|
73
|
+
*/
|
|
74
|
+
export const ApiId = {
|
|
75
|
+
acquireTokenSilent: 62,
|
|
76
|
+
acquireTokenByUsernamePassword: 371,
|
|
77
|
+
acquireTokenByDeviceCode: 671,
|
|
78
|
+
acquireTokenByClientCredential: 771,
|
|
79
|
+
acquireTokenByCode: 871,
|
|
80
|
+
acquireTokenByRefreshToken: 872,
|
|
81
|
+
};
|
|
82
|
+
export type ApiId = (typeof ApiId)[keyof typeof ApiId];
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* JWT constants
|
|
86
|
+
*/
|
|
87
|
+
export const JwtConstants = {
|
|
88
|
+
ALGORITHM: "alg",
|
|
89
|
+
RSA_256: "RS256",
|
|
90
|
+
X5T: "x5t",
|
|
91
|
+
X5C: "x5c",
|
|
92
|
+
AUDIENCE: "aud",
|
|
93
|
+
EXPIRATION_TIME: "exp",
|
|
94
|
+
ISSUER: "iss",
|
|
95
|
+
SUBJECT: "sub",
|
|
96
|
+
NOT_BEFORE: "nbf",
|
|
97
|
+
JWT_ID: "jti",
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
export const LOOPBACK_SERVER_CONSTANTS = {
|
|
101
|
+
INTERVAL_MS: 100,
|
|
102
|
+
TIMEOUT_MS: 5000,
|
|
103
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { Constants } from "@azure/msal-common";
|
|
7
|
+
|
|
8
|
+
export class EncodingUtils {
|
|
9
|
+
/**
|
|
10
|
+
* 'utf8': Multibyte encoded Unicode characters. Many web pages and other document formats use UTF-8.
|
|
11
|
+
* 'base64': Base64 encoding.
|
|
12
|
+
*
|
|
13
|
+
* @param str text
|
|
14
|
+
*/
|
|
15
|
+
static base64Encode(str: string, encoding?: BufferEncoding): string {
|
|
16
|
+
return Buffer.from(str, encoding).toString("base64");
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* encode a URL
|
|
21
|
+
* @param str
|
|
22
|
+
*/
|
|
23
|
+
static base64EncodeUrl(str: string, encoding?: BufferEncoding): string {
|
|
24
|
+
return EncodingUtils.base64Encode(str, encoding)
|
|
25
|
+
.replace(/=/g, Constants.EMPTY_STRING)
|
|
26
|
+
.replace(/\+/g, "-")
|
|
27
|
+
.replace(/\//g, "_");
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* 'utf8': Multibyte encoded Unicode characters. Many web pages and other document formats use UTF-8.
|
|
32
|
+
* 'base64': Base64 encoding.
|
|
33
|
+
*
|
|
34
|
+
* @param base64Str Base64 encoded text
|
|
35
|
+
*/
|
|
36
|
+
static base64Decode(base64Str: string): string {
|
|
37
|
+
return Buffer.from(base64Str, "base64").toString("utf8");
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* @param base64Str Base64 encoded Url
|
|
42
|
+
*/
|
|
43
|
+
static base64DecodeUrl(base64Str: string): string {
|
|
44
|
+
let str = base64Str.replace(/-/g, "+").replace(/_/g, "/");
|
|
45
|
+
while (str.length % 4) {
|
|
46
|
+
str += "=";
|
|
47
|
+
}
|
|
48
|
+
return EncodingUtils.base64Decode(str);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { NetworkResponse, UrlToHttpRequestOptions } from "@azure/msal-common";
|
|
7
|
+
|
|
8
|
+
export class NetworkUtils {
|
|
9
|
+
static getNetworkResponse<T>(
|
|
10
|
+
headers: Record<string, string>,
|
|
11
|
+
body: T,
|
|
12
|
+
statusCode: number
|
|
13
|
+
): NetworkResponse<T> {
|
|
14
|
+
return {
|
|
15
|
+
headers: headers,
|
|
16
|
+
body: body,
|
|
17
|
+
status: statusCode,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/*
|
|
22
|
+
* Utility function that converts a URL object into an ordinary options object as expected by the
|
|
23
|
+
* http.request and https.request APIs.
|
|
24
|
+
* https://github.com/nodejs/node/blob/main/lib/internal/url.js#L1090
|
|
25
|
+
*/
|
|
26
|
+
static urlToHttpOptions(url: URL): UrlToHttpRequestOptions {
|
|
27
|
+
const options: UrlToHttpRequestOptions = {
|
|
28
|
+
protocol: url.protocol,
|
|
29
|
+
hostname:
|
|
30
|
+
url.hostname && url.hostname.startsWith("[")
|
|
31
|
+
? url.hostname.slice(1, -1)
|
|
32
|
+
: url.hostname,
|
|
33
|
+
hash: url.hash,
|
|
34
|
+
search: url.search,
|
|
35
|
+
pathname: url.pathname,
|
|
36
|
+
path: `${url.pathname || ""}${url.search || ""}`,
|
|
37
|
+
href: url.href,
|
|
38
|
+
};
|
|
39
|
+
if (url.port !== "") {
|
|
40
|
+
options.port = Number(url.port);
|
|
41
|
+
}
|
|
42
|
+
if (url.username || url.password) {
|
|
43
|
+
options.auth = `${decodeURIComponent(
|
|
44
|
+
url.username
|
|
45
|
+
)}:${decodeURIComponent(url.password)}`;
|
|
46
|
+
}
|
|
47
|
+
return options;
|
|
48
|
+
}
|
|
49
|
+
}
|