@azure/msal-node 1.13.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 +10 -0
- package/dist/client/ClientApplication.d.ts.map +1 -1
- package/dist/error/NodeAuthError.d.ts +8 -0
- package/dist/error/NodeAuthError.d.ts.map +1 -1
- package/dist/msal-node.cjs.development.js +134 -92
- 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 +135 -93
- package/dist/msal-node.esm.js.map +1 -1
- 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/package.json +2 -2
package/dist/msal-node.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Constants as Constants$1, ProtocolMode, AzureCloudInstance, LogLevel, StringUtils, AccountEntity, CacheManager, IdTokenEntity, AccessTokenEntity, RefreshTokenEntity, AppMetadataEntity, ServerTelemetryEntity, AuthorityMetadataEntity, ThrottlingEntity, TokenCacheContext, Logger, ResponseMode, AuthenticationScheme, AuthorizationCodeClient,
|
|
1
|
+
import { Constants as Constants$1, ProtocolMode, AzureCloudInstance, LogLevel, StringUtils, AccountEntity, CacheManager, IdTokenEntity, AccessTokenEntity, RefreshTokenEntity, AppMetadataEntity, ServerTelemetryEntity, AuthorityMetadataEntity, ThrottlingEntity, TokenCacheContext, AuthError, Logger, ResponseMode, AuthenticationScheme, AuthorizationCodeClient, RefreshTokenClient, SilentFlowClient, UsernamePasswordClient, ClientAuthError, OIDC_DEFAULT_SCOPES, ServerTelemetryManager, Authority, AuthorityFactory, UrlString, DeviceCodeClient, ServerError, CodeChallengeMethodValues, TimeUtils, ClientCredentialClient, OnBehalfOfClient } from '@azure/msal-common';
|
|
2
2
|
export { AuthError, AuthErrorMessage, AzureCloudInstance, ClientAuthError, ClientAuthErrorMessage, ClientConfigurationError, ClientConfigurationErrorMessage, InteractionRequiredAuthError, InteractionRequiredAuthErrorMessage, LogLevel, Logger, PromptValue, ProtocolMode, ResponseMode, ServerError, TokenCacheContext } from '@azure/msal-common';
|
|
3
3
|
import http, { createServer } from 'http';
|
|
4
4
|
import https from 'https';
|
|
@@ -1766,7 +1766,109 @@ class TokenCache {
|
|
|
1766
1766
|
|
|
1767
1767
|
/* eslint-disable header/header */
|
|
1768
1768
|
const name = "@azure/msal-node";
|
|
1769
|
-
const version = "1.
|
|
1769
|
+
const version = "1.14.0";
|
|
1770
|
+
|
|
1771
|
+
/*
|
|
1772
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
1773
|
+
* Licensed under the MIT License.
|
|
1774
|
+
*/
|
|
1775
|
+
/**
|
|
1776
|
+
* NodeAuthErrorMessage class containing string constants used by error codes and messages.
|
|
1777
|
+
*/
|
|
1778
|
+
|
|
1779
|
+
const NodeAuthErrorMessage = {
|
|
1780
|
+
invalidLoopbackAddressType: {
|
|
1781
|
+
code: "invalid_loopback_server_address_type",
|
|
1782
|
+
desc: "Loopback server address is not type string. This is unexpected."
|
|
1783
|
+
},
|
|
1784
|
+
unableToLoadRedirectUri: {
|
|
1785
|
+
code: "unable_to_load_redirectUrl",
|
|
1786
|
+
desc: "Loopback server callback was invoked without a url. This is unexpected."
|
|
1787
|
+
},
|
|
1788
|
+
noAuthCodeInResponse: {
|
|
1789
|
+
code: "no_auth_code_in_response",
|
|
1790
|
+
desc: "No auth code found in the server response. Please check your network trace to determine what happened."
|
|
1791
|
+
},
|
|
1792
|
+
noLoopbackServerExists: {
|
|
1793
|
+
code: "no_loopback_server_exists",
|
|
1794
|
+
desc: "No loopback server exists yet."
|
|
1795
|
+
},
|
|
1796
|
+
loopbackServerAlreadyExists: {
|
|
1797
|
+
code: "loopback_server_already_exists",
|
|
1798
|
+
desc: "Loopback server already exists. Cannot create another."
|
|
1799
|
+
},
|
|
1800
|
+
loopbackServerTimeout: {
|
|
1801
|
+
code: "loopback_server_timeout",
|
|
1802
|
+
desc: "Timed out waiting for auth code listener to be registered."
|
|
1803
|
+
},
|
|
1804
|
+
stateNotFoundError: {
|
|
1805
|
+
code: "state_not_found",
|
|
1806
|
+
desc: "State not found. Please verify that the request originated from msal."
|
|
1807
|
+
}
|
|
1808
|
+
};
|
|
1809
|
+
class NodeAuthError extends AuthError {
|
|
1810
|
+
constructor(errorCode, errorMessage) {
|
|
1811
|
+
super(errorCode, errorMessage);
|
|
1812
|
+
this.name = "NodeAuthError";
|
|
1813
|
+
}
|
|
1814
|
+
/**
|
|
1815
|
+
* Creates an error thrown if loopback server address is of type string.
|
|
1816
|
+
*/
|
|
1817
|
+
|
|
1818
|
+
|
|
1819
|
+
static createInvalidLoopbackAddressTypeError() {
|
|
1820
|
+
return new NodeAuthError(NodeAuthErrorMessage.invalidLoopbackAddressType.code, `${NodeAuthErrorMessage.invalidLoopbackAddressType.desc}`);
|
|
1821
|
+
}
|
|
1822
|
+
/**
|
|
1823
|
+
* Creates an error thrown if the loopback server is unable to get a url.
|
|
1824
|
+
*/
|
|
1825
|
+
|
|
1826
|
+
|
|
1827
|
+
static createUnableToLoadRedirectUrlError() {
|
|
1828
|
+
return new NodeAuthError(NodeAuthErrorMessage.unableToLoadRedirectUri.code, `${NodeAuthErrorMessage.unableToLoadRedirectUri.desc}`);
|
|
1829
|
+
}
|
|
1830
|
+
/**
|
|
1831
|
+
* Creates an error thrown if the server response does not contain an auth code.
|
|
1832
|
+
*/
|
|
1833
|
+
|
|
1834
|
+
|
|
1835
|
+
static createNoAuthCodeInResponseError() {
|
|
1836
|
+
return new NodeAuthError(NodeAuthErrorMessage.noAuthCodeInResponse.code, `${NodeAuthErrorMessage.noAuthCodeInResponse.desc}`);
|
|
1837
|
+
}
|
|
1838
|
+
/**
|
|
1839
|
+
* Creates an error thrown if the loopback server has not been spun up yet.
|
|
1840
|
+
*/
|
|
1841
|
+
|
|
1842
|
+
|
|
1843
|
+
static createNoLoopbackServerExistsError() {
|
|
1844
|
+
return new NodeAuthError(NodeAuthErrorMessage.noLoopbackServerExists.code, `${NodeAuthErrorMessage.noLoopbackServerExists.desc}`);
|
|
1845
|
+
}
|
|
1846
|
+
/**
|
|
1847
|
+
* Creates an error thrown if a loopback server already exists when attempting to create another one.
|
|
1848
|
+
*/
|
|
1849
|
+
|
|
1850
|
+
|
|
1851
|
+
static createLoopbackServerAlreadyExistsError() {
|
|
1852
|
+
return new NodeAuthError(NodeAuthErrorMessage.loopbackServerAlreadyExists.code, `${NodeAuthErrorMessage.loopbackServerAlreadyExists.desc}`);
|
|
1853
|
+
}
|
|
1854
|
+
/**
|
|
1855
|
+
* Creates an error thrown if the loopback server times out registering the auth code listener.
|
|
1856
|
+
*/
|
|
1857
|
+
|
|
1858
|
+
|
|
1859
|
+
static createLoopbackServerTimeoutError() {
|
|
1860
|
+
return new NodeAuthError(NodeAuthErrorMessage.loopbackServerTimeout.code, `${NodeAuthErrorMessage.loopbackServerTimeout.desc}`);
|
|
1861
|
+
}
|
|
1862
|
+
/**
|
|
1863
|
+
* Creates an error thrown when the state is not present.
|
|
1864
|
+
*/
|
|
1865
|
+
|
|
1866
|
+
|
|
1867
|
+
static createStateNotFoundError() {
|
|
1868
|
+
return new NodeAuthError(NodeAuthErrorMessage.stateNotFoundError.code, NodeAuthErrorMessage.stateNotFoundError.desc);
|
|
1869
|
+
}
|
|
1870
|
+
|
|
1871
|
+
}
|
|
1770
1872
|
|
|
1771
1873
|
/*
|
|
1772
1874
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -1822,7 +1924,17 @@ class ClientApplication {
|
|
|
1822
1924
|
|
|
1823
1925
|
|
|
1824
1926
|
async acquireTokenByCode(request, authCodePayLoad) {
|
|
1825
|
-
this.logger.info("acquireTokenByCode called"
|
|
1927
|
+
this.logger.info("acquireTokenByCode called");
|
|
1928
|
+
|
|
1929
|
+
if (request.state && authCodePayLoad) {
|
|
1930
|
+
this.logger.info("acquireTokenByCode - validating state");
|
|
1931
|
+
this.validateState(request.state, authCodePayLoad.state || ""); // eslint-disable-next-line no-param-reassign
|
|
1932
|
+
|
|
1933
|
+
authCodePayLoad = { ...authCodePayLoad,
|
|
1934
|
+
state: ""
|
|
1935
|
+
};
|
|
1936
|
+
}
|
|
1937
|
+
|
|
1826
1938
|
const validRequest = { ...request,
|
|
1827
1939
|
...(await this.initializeBaseRequest(request)),
|
|
1828
1940
|
authenticationScheme: AuthenticationScheme.BEARER
|
|
@@ -1947,6 +2059,26 @@ class ClientApplication {
|
|
|
1947
2059
|
this.logger.info("getTokenCache called");
|
|
1948
2060
|
return this.tokenCache;
|
|
1949
2061
|
}
|
|
2062
|
+
/**
|
|
2063
|
+
* Validates OIDC state by comparing the user cached state with the state received from the server.
|
|
2064
|
+
*
|
|
2065
|
+
* This API is provided for scenarios where you would use OAuth2.0 state parameter to mitigate against
|
|
2066
|
+
* CSRF attacks.
|
|
2067
|
+
* For more information about state, visit https://datatracker.ietf.org/doc/html/rfc6819#section-3.6.
|
|
2068
|
+
* @param state
|
|
2069
|
+
* @param cachedState
|
|
2070
|
+
*/
|
|
2071
|
+
|
|
2072
|
+
|
|
2073
|
+
validateState(state, cachedState) {
|
|
2074
|
+
if (!state) {
|
|
2075
|
+
throw NodeAuthError.createStateNotFoundError();
|
|
2076
|
+
}
|
|
2077
|
+
|
|
2078
|
+
if (state !== cachedState) {
|
|
2079
|
+
throw ClientAuthError.createStateMismatchError();
|
|
2080
|
+
}
|
|
2081
|
+
}
|
|
1950
2082
|
/**
|
|
1951
2083
|
* Returns the logger instance
|
|
1952
2084
|
*/
|
|
@@ -2095,96 +2227,6 @@ class ClientApplication {
|
|
|
2095
2227
|
|
|
2096
2228
|
}
|
|
2097
2229
|
|
|
2098
|
-
/*
|
|
2099
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2100
|
-
* Licensed under the MIT License.
|
|
2101
|
-
*/
|
|
2102
|
-
/**
|
|
2103
|
-
* NodeAuthErrorMessage class containing string constants used by error codes and messages.
|
|
2104
|
-
*/
|
|
2105
|
-
|
|
2106
|
-
const NodeAuthErrorMessage = {
|
|
2107
|
-
invalidLoopbackAddressType: {
|
|
2108
|
-
code: "invalid_loopback_server_address_type",
|
|
2109
|
-
desc: "Loopback server address is not type string. This is unexpected."
|
|
2110
|
-
},
|
|
2111
|
-
unableToLoadRedirectUri: {
|
|
2112
|
-
code: "unable_to_load_redirectUrl",
|
|
2113
|
-
desc: "Loopback server callback was invoked without a url. This is unexpected."
|
|
2114
|
-
},
|
|
2115
|
-
noAuthCodeInResponse: {
|
|
2116
|
-
code: "no_auth_code_in_response",
|
|
2117
|
-
desc: "No auth code found in the server response. Please check your network trace to determine what happened."
|
|
2118
|
-
},
|
|
2119
|
-
noLoopbackServerExists: {
|
|
2120
|
-
code: "no_loopback_server_exists",
|
|
2121
|
-
desc: "No loopback server exists yet."
|
|
2122
|
-
},
|
|
2123
|
-
loopbackServerAlreadyExists: {
|
|
2124
|
-
code: "loopback_server_already_exists",
|
|
2125
|
-
desc: "Loopback server already exists. Cannot create another."
|
|
2126
|
-
},
|
|
2127
|
-
loopbackServerTimeout: {
|
|
2128
|
-
code: "loopback_server_timeout",
|
|
2129
|
-
desc: "Timed out waiting for auth code listener to be registered."
|
|
2130
|
-
}
|
|
2131
|
-
};
|
|
2132
|
-
class NodeAuthError extends AuthError {
|
|
2133
|
-
constructor(errorCode, errorMessage) {
|
|
2134
|
-
super(errorCode, errorMessage);
|
|
2135
|
-
this.name = "NodeAuthError";
|
|
2136
|
-
}
|
|
2137
|
-
/**
|
|
2138
|
-
* Creates an error thrown if loopback server address is of type string.
|
|
2139
|
-
*/
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
static createInvalidLoopbackAddressTypeError() {
|
|
2143
|
-
return new NodeAuthError(NodeAuthErrorMessage.invalidLoopbackAddressType.code, `${NodeAuthErrorMessage.invalidLoopbackAddressType.desc}`);
|
|
2144
|
-
}
|
|
2145
|
-
/**
|
|
2146
|
-
* Creates an error thrown if the loopback server is unable to get a url.
|
|
2147
|
-
*/
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
static createUnableToLoadRedirectUrlError() {
|
|
2151
|
-
return new NodeAuthError(NodeAuthErrorMessage.unableToLoadRedirectUri.code, `${NodeAuthErrorMessage.unableToLoadRedirectUri.desc}`);
|
|
2152
|
-
}
|
|
2153
|
-
/**
|
|
2154
|
-
* Creates an error thrown if the server response does not contain an auth code.
|
|
2155
|
-
*/
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
static createNoAuthCodeInResponseError() {
|
|
2159
|
-
return new NodeAuthError(NodeAuthErrorMessage.noAuthCodeInResponse.code, `${NodeAuthErrorMessage.noAuthCodeInResponse.desc}`);
|
|
2160
|
-
}
|
|
2161
|
-
/**
|
|
2162
|
-
* Creates an error thrown if the loopback server has not been spun up yet.
|
|
2163
|
-
*/
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
static createNoLoopbackServerExistsError() {
|
|
2167
|
-
return new NodeAuthError(NodeAuthErrorMessage.noLoopbackServerExists.code, `${NodeAuthErrorMessage.noLoopbackServerExists.desc}`);
|
|
2168
|
-
}
|
|
2169
|
-
/**
|
|
2170
|
-
* Creates an error thrown if a loopback server already exists when attempting to create another one.
|
|
2171
|
-
*/
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
static createLoopbackServerAlreadyExistsError() {
|
|
2175
|
-
return new NodeAuthError(NodeAuthErrorMessage.loopbackServerAlreadyExists.code, `${NodeAuthErrorMessage.loopbackServerAlreadyExists.desc}`);
|
|
2176
|
-
}
|
|
2177
|
-
/**
|
|
2178
|
-
* Creates an error thrown if the loopback server times out registering the auth code listener.
|
|
2179
|
-
*/
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
static createLoopbackServerTimeoutError() {
|
|
2183
|
-
return new NodeAuthError(NodeAuthErrorMessage.loopbackServerTimeout.code, `${NodeAuthErrorMessage.loopbackServerTimeout.desc}`);
|
|
2184
|
-
}
|
|
2185
|
-
|
|
2186
|
-
}
|
|
2187
|
-
|
|
2188
2230
|
/*
|
|
2189
2231
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2190
2232
|
* Licensed under the MIT License.
|