@azure/msal-common 15.2.0 → 15.3.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/account/AccountInfo.mjs +1 -1
- package/dist/account/AuthToken.mjs +1 -1
- package/dist/account/CcsCredential.mjs +1 -1
- package/dist/account/ClientInfo.mjs +1 -1
- package/dist/account/TokenClaims.mjs +1 -1
- package/dist/authority/Authority.mjs +1 -1
- package/dist/authority/AuthorityFactory.mjs +1 -1
- package/dist/authority/AuthorityMetadata.mjs +1 -1
- package/dist/authority/AuthorityOptions.mjs +1 -1
- package/dist/authority/AuthorityType.mjs +1 -1
- package/dist/authority/CloudInstanceDiscoveryErrorResponse.mjs +1 -1
- package/dist/authority/CloudInstanceDiscoveryResponse.mjs +1 -1
- package/dist/authority/OpenIdConfigResponse.mjs +1 -1
- package/dist/authority/ProtocolMode.mjs +1 -1
- package/dist/authority/RegionDiscovery.mjs +1 -1
- package/dist/cache/CacheManager.mjs +1 -1
- package/dist/cache/entities/AccountEntity.mjs +1 -1
- package/dist/cache/persistence/TokenCacheContext.mjs +1 -1
- package/dist/cache/utils/CacheHelpers.mjs +1 -1
- package/dist/client/AuthorizationCodeClient.d.ts +0 -31
- package/dist/client/AuthorizationCodeClient.d.ts.map +1 -1
- package/dist/client/AuthorizationCodeClient.mjs +43 -258
- package/dist/client/AuthorizationCodeClient.mjs.map +1 -1
- package/dist/client/BaseClient.d.ts.map +1 -1
- package/dist/client/BaseClient.mjs +9 -10
- package/dist/client/BaseClient.mjs.map +1 -1
- package/dist/client/RefreshTokenClient.d.ts.map +1 -1
- package/dist/client/RefreshTokenClient.mjs +29 -41
- package/dist/client/RefreshTokenClient.mjs.map +1 -1
- package/dist/client/SilentFlowClient.mjs +1 -1
- package/dist/config/ClientConfiguration.mjs +1 -1
- package/dist/constants/AADServerParamKeys.d.ts +1 -0
- package/dist/constants/AADServerParamKeys.d.ts.map +1 -1
- package/dist/constants/AADServerParamKeys.mjs +4 -3
- package/dist/constants/AADServerParamKeys.mjs.map +1 -1
- package/dist/crypto/ICrypto.mjs +1 -1
- package/dist/crypto/JoseHeader.mjs +1 -1
- package/dist/crypto/PopTokenGenerator.mjs +1 -1
- package/dist/error/AuthError.mjs +1 -1
- package/dist/error/AuthErrorCodes.mjs +1 -1
- package/dist/error/CacheError.mjs +1 -1
- package/dist/error/CacheErrorCodes.mjs +1 -1
- package/dist/error/ClientAuthError.mjs +1 -1
- package/dist/error/ClientAuthErrorCodes.mjs +1 -1
- package/dist/error/ClientConfigurationError.mjs +1 -1
- package/dist/error/ClientConfigurationErrorCodes.mjs +1 -1
- package/dist/error/InteractionRequiredAuthError.mjs +1 -1
- package/dist/error/InteractionRequiredAuthErrorCodes.mjs +1 -1
- package/dist/error/JoseHeaderError.mjs +1 -1
- package/dist/error/JoseHeaderErrorCodes.mjs +1 -1
- package/dist/error/NetworkError.mjs +1 -1
- package/dist/error/ServerError.mjs +1 -1
- package/dist/exports-common.d.ts +4 -3
- package/dist/exports-common.d.ts.map +1 -1
- package/dist/index-browser.mjs +6 -2
- package/dist/index-browser.mjs.map +1 -1
- package/dist/index-node.mjs +6 -2
- package/dist/index-node.mjs.map +1 -1
- package/dist/index.mjs +6 -2
- package/dist/index.mjs.map +1 -1
- package/dist/logger/Logger.mjs +1 -1
- package/dist/network/INetworkModule.mjs +1 -1
- package/dist/network/RequestThumbprint.d.ts +3 -0
- package/dist/network/RequestThumbprint.d.ts.map +1 -1
- package/dist/network/RequestThumbprint.mjs +24 -0
- package/dist/network/RequestThumbprint.mjs.map +1 -0
- package/dist/network/ThrottlingUtils.d.ts.map +1 -1
- package/dist/network/ThrottlingUtils.mjs +3 -13
- package/dist/network/ThrottlingUtils.mjs.map +1 -1
- package/dist/packageMetadata.d.ts +1 -1
- package/dist/packageMetadata.mjs +2 -2
- package/dist/protocol/Authorize.d.ts +37 -0
- package/dist/protocol/Authorize.d.ts.map +1 -0
- package/dist/protocol/Authorize.mjs +237 -0
- package/dist/protocol/Authorize.mjs.map +1 -0
- package/dist/request/AuthenticationHeaderParser.mjs +1 -1
- package/dist/request/BaseAuthRequest.d.ts +2 -0
- package/dist/request/BaseAuthRequest.d.ts.map +1 -1
- package/dist/request/CommonAuthorizationCodeRequest.d.ts +0 -2
- package/dist/request/CommonAuthorizationCodeRequest.d.ts.map +1 -1
- package/dist/request/CommonDeviceCodeRequest.d.ts +1 -1
- package/dist/request/CommonDeviceCodeRequest.d.ts.map +1 -1
- package/dist/request/CommonRefreshTokenRequest.d.ts +0 -2
- package/dist/request/CommonRefreshTokenRequest.d.ts.map +1 -1
- package/dist/request/CommonSilentFlowRequest.d.ts +0 -3
- package/dist/request/CommonSilentFlowRequest.d.ts.map +1 -1
- package/dist/request/RequestParameterBuilder.d.ts +206 -218
- package/dist/request/RequestParameterBuilder.d.ts.map +1 -1
- package/dist/request/RequestParameterBuilder.mjs +356 -369
- package/dist/request/RequestParameterBuilder.mjs.map +1 -1
- package/dist/request/RequestValidator.mjs +1 -1
- package/dist/request/ScopeSet.mjs +1 -1
- package/dist/response/AuthorizeResponse.d.ts +72 -0
- package/dist/response/AuthorizeResponse.d.ts.map +1 -0
- package/dist/response/ResponseHandler.d.ts +0 -8
- package/dist/response/ResponseHandler.d.ts.map +1 -1
- package/dist/response/ResponseHandler.mjs +7 -52
- package/dist/response/ResponseHandler.mjs.map +1 -1
- package/dist/telemetry/performance/PerformanceClient.mjs +1 -1
- package/dist/telemetry/performance/PerformanceEvent.d.ts +1 -2
- package/dist/telemetry/performance/PerformanceEvent.d.ts.map +1 -1
- package/dist/telemetry/performance/PerformanceEvent.mjs +2 -11
- package/dist/telemetry/performance/PerformanceEvent.mjs.map +1 -1
- package/dist/telemetry/performance/StubPerformanceClient.mjs +1 -1
- package/dist/telemetry/server/ServerTelemetryManager.mjs +1 -1
- package/dist/url/UrlString.mjs +1 -1
- package/dist/utils/ClientAssertionUtils.mjs +1 -1
- package/dist/utils/Constants.mjs +1 -1
- package/dist/utils/FunctionWrappers.mjs +1 -1
- package/dist/utils/ProtocolUtils.mjs +1 -1
- package/dist/utils/StringUtils.mjs +1 -1
- package/dist/utils/TimeUtils.d.ts +10 -0
- package/dist/utils/TimeUtils.d.ts.map +1 -1
- package/dist/utils/TimeUtils.mjs +20 -2
- package/dist/utils/TimeUtils.mjs.map +1 -1
- package/dist/utils/UrlUtils.d.ts +6 -2
- package/dist/utils/UrlUtils.d.ts.map +1 -1
- package/dist/utils/UrlUtils.mjs +12 -2
- package/dist/utils/UrlUtils.mjs.map +1 -1
- package/lib/index-browser.cjs +4 -2
- package/lib/index-browser.cjs.map +1 -1
- package/lib/{index-node-0IMDqzO0.js → index-node-BjtDFnOl.js} +828 -805
- package/lib/index-node-BjtDFnOl.js.map +1 -0
- package/lib/index-node.cjs +4 -2
- package/lib/index-node.cjs.map +1 -1
- package/lib/index.cjs +4 -2
- package/lib/index.cjs.map +1 -1
- package/lib/types/client/AuthorizationCodeClient.d.ts +0 -31
- package/lib/types/client/AuthorizationCodeClient.d.ts.map +1 -1
- package/lib/types/client/BaseClient.d.ts.map +1 -1
- package/lib/types/client/RefreshTokenClient.d.ts.map +1 -1
- package/lib/types/constants/AADServerParamKeys.d.ts +1 -0
- package/lib/types/constants/AADServerParamKeys.d.ts.map +1 -1
- package/lib/types/exports-common.d.ts +4 -3
- package/lib/types/exports-common.d.ts.map +1 -1
- package/lib/types/network/RequestThumbprint.d.ts +3 -0
- package/lib/types/network/RequestThumbprint.d.ts.map +1 -1
- package/lib/types/network/ThrottlingUtils.d.ts.map +1 -1
- package/lib/types/packageMetadata.d.ts +1 -1
- package/lib/types/protocol/Authorize.d.ts +37 -0
- package/lib/types/protocol/Authorize.d.ts.map +1 -0
- package/lib/types/request/BaseAuthRequest.d.ts +2 -0
- package/lib/types/request/BaseAuthRequest.d.ts.map +1 -1
- package/lib/types/request/CommonAuthorizationCodeRequest.d.ts +0 -2
- package/lib/types/request/CommonAuthorizationCodeRequest.d.ts.map +1 -1
- package/lib/types/request/CommonDeviceCodeRequest.d.ts +1 -1
- package/lib/types/request/CommonDeviceCodeRequest.d.ts.map +1 -1
- package/lib/types/request/CommonRefreshTokenRequest.d.ts +0 -2
- package/lib/types/request/CommonRefreshTokenRequest.d.ts.map +1 -1
- package/lib/types/request/CommonSilentFlowRequest.d.ts +0 -3
- package/lib/types/request/CommonSilentFlowRequest.d.ts.map +1 -1
- package/lib/types/request/RequestParameterBuilder.d.ts +206 -218
- package/lib/types/request/RequestParameterBuilder.d.ts.map +1 -1
- package/lib/types/response/AuthorizeResponse.d.ts +72 -0
- package/lib/types/response/AuthorizeResponse.d.ts.map +1 -0
- package/lib/types/response/ResponseHandler.d.ts +0 -8
- package/lib/types/response/ResponseHandler.d.ts.map +1 -1
- package/lib/types/telemetry/performance/PerformanceEvent.d.ts +1 -2
- package/lib/types/telemetry/performance/PerformanceEvent.d.ts.map +1 -1
- package/lib/types/utils/TimeUtils.d.ts +10 -0
- package/lib/types/utils/TimeUtils.d.ts.map +1 -1
- package/lib/types/utils/UrlUtils.d.ts +6 -2
- package/lib/types/utils/UrlUtils.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/client/AuthorizationCodeClient.ts +89 -409
- package/src/client/BaseClient.ts +20 -12
- package/src/client/RefreshTokenClient.ts +66 -44
- package/src/constants/AADServerParamKeys.ts +1 -0
- package/src/exports-common.ts +8 -3
- package/src/network/RequestThumbprint.ts +23 -0
- package/src/network/ThrottlingUtils.ts +9 -14
- package/src/packageMetadata.ts +1 -1
- package/src/protocol/Authorize.ts +409 -0
- package/src/request/BaseAuthRequest.ts +2 -0
- package/src/request/CommonAuthorizationCodeRequest.ts +0 -2
- package/src/request/CommonDeviceCodeRequest.ts +1 -1
- package/src/request/CommonRefreshTokenRequest.ts +0 -2
- package/src/request/CommonSilentFlowRequest.ts +0 -3
- package/src/request/RequestParameterBuilder.ts +508 -543
- package/src/response/AuthorizeResponse.ts +76 -0
- package/src/response/ResponseHandler.ts +8 -104
- package/src/telemetry/performance/PerformanceEvent.ts +1 -11
- package/src/utils/TimeUtils.ts +20 -0
- package/src/utils/UrlUtils.ts +18 -4
- package/dist/response/ServerAuthorizationCodeResponse.d.ts +0 -27
- package/dist/response/ServerAuthorizationCodeResponse.d.ts.map +0 -1
- package/lib/index-node-0IMDqzO0.js.map +0 -1
- package/lib/types/response/ServerAuthorizationCodeResponse.d.ts +0 -27
- package/lib/types/response/ServerAuthorizationCodeResponse.d.ts.map +0 -1
- package/src/response/ServerAuthorizationCodeResponse.ts +0 -34
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Response properties that may be returned by the /authorize endpoint
|
|
8
|
+
*/
|
|
9
|
+
export type AuthorizeResponse = {
|
|
10
|
+
/**
|
|
11
|
+
* Authorization Code to be exchanged for tokens
|
|
12
|
+
*/
|
|
13
|
+
code?: string;
|
|
14
|
+
/**
|
|
15
|
+
* Client info object containing UserId and TenantId
|
|
16
|
+
*/
|
|
17
|
+
client_info?: string;
|
|
18
|
+
/**
|
|
19
|
+
* State string, should match what was sent on request
|
|
20
|
+
*/
|
|
21
|
+
state?: string;
|
|
22
|
+
/**
|
|
23
|
+
* Cloud instance returned when application is instance aware
|
|
24
|
+
*/
|
|
25
|
+
cloud_instance_name?: string;
|
|
26
|
+
/**
|
|
27
|
+
* Cloud instance hostname returned when application is instance aware
|
|
28
|
+
*/
|
|
29
|
+
cloud_instance_host_name?: string;
|
|
30
|
+
/**
|
|
31
|
+
* AAD Graph hostname returned when application is instance aware
|
|
32
|
+
* https://docs.microsoft.com/en-us/azure/active-directory/develop/active-directory-graph-api
|
|
33
|
+
*/
|
|
34
|
+
cloud_graph_host_name?: string;
|
|
35
|
+
/**
|
|
36
|
+
* Microsoft Graph hostname returned when application is instance aware
|
|
37
|
+
* https://docs.microsoft.com/en-us/graph/overview
|
|
38
|
+
*/
|
|
39
|
+
msgraph_host?: string;
|
|
40
|
+
/**
|
|
41
|
+
* Server error code
|
|
42
|
+
*/
|
|
43
|
+
error?: string;
|
|
44
|
+
/**
|
|
45
|
+
* Server error URI
|
|
46
|
+
*/
|
|
47
|
+
error_uri?: string;
|
|
48
|
+
/**
|
|
49
|
+
* Server error description
|
|
50
|
+
*/
|
|
51
|
+
error_description?: string;
|
|
52
|
+
/**
|
|
53
|
+
* Server Sub-Error
|
|
54
|
+
*/
|
|
55
|
+
suberror?: string;
|
|
56
|
+
/**
|
|
57
|
+
* Timestamp of request
|
|
58
|
+
*/
|
|
59
|
+
timestamp?: string;
|
|
60
|
+
/**
|
|
61
|
+
* Trace Id used to look up request in logs
|
|
62
|
+
*/
|
|
63
|
+
trace_id?: string;
|
|
64
|
+
/**
|
|
65
|
+
* Correlation ID use to look up request in logs
|
|
66
|
+
*/
|
|
67
|
+
correlation_id?: string;
|
|
68
|
+
/**
|
|
69
|
+
* Claims
|
|
70
|
+
*/
|
|
71
|
+
claims?: string;
|
|
72
|
+
/**
|
|
73
|
+
* AccountId for the user, returned when platform broker is available to use
|
|
74
|
+
*/
|
|
75
|
+
accountId?: string;
|
|
76
|
+
};
|
|
@@ -9,7 +9,6 @@ import {
|
|
|
9
9
|
ClientAuthErrorCodes,
|
|
10
10
|
createClientAuthError,
|
|
11
11
|
} from "../error/ClientAuthError.js";
|
|
12
|
-
import { ServerAuthorizationCodeResponse } from "./ServerAuthorizationCodeResponse.js";
|
|
13
12
|
import { Logger } from "../logger/Logger.js";
|
|
14
13
|
import { ServerError } from "../error/ServerError.js";
|
|
15
14
|
import { ScopeSet } from "../request/ScopeSet.js";
|
|
@@ -52,19 +51,7 @@ import {
|
|
|
52
51
|
updateAccountTenantProfileData,
|
|
53
52
|
} from "../account/AccountInfo.js";
|
|
54
53
|
import * as CacheHelpers from "../cache/utils/CacheHelpers.js";
|
|
55
|
-
|
|
56
|
-
function parseServerErrorNo(
|
|
57
|
-
serverResponse: ServerAuthorizationCodeResponse
|
|
58
|
-
): string | undefined {
|
|
59
|
-
const errorCodePrefix = "code=";
|
|
60
|
-
const errorCodePrefixIndex =
|
|
61
|
-
serverResponse.error_uri?.lastIndexOf(errorCodePrefix);
|
|
62
|
-
return errorCodePrefixIndex && errorCodePrefixIndex >= 0
|
|
63
|
-
? serverResponse.error_uri?.substring(
|
|
64
|
-
errorCodePrefixIndex + errorCodePrefix.length
|
|
65
|
-
)
|
|
66
|
-
: undefined;
|
|
67
|
-
}
|
|
54
|
+
import * as TimeUtils from "../utils/TimeUtils.js";
|
|
68
55
|
|
|
69
56
|
/**
|
|
70
57
|
* Class that handles response parsing.
|
|
@@ -98,90 +85,6 @@ export class ResponseHandler {
|
|
|
98
85
|
this.performanceClient = performanceClient;
|
|
99
86
|
}
|
|
100
87
|
|
|
101
|
-
/**
|
|
102
|
-
* Function which validates server authorization code response.
|
|
103
|
-
* @param serverResponseHash
|
|
104
|
-
* @param requestState
|
|
105
|
-
* @param cryptoObj
|
|
106
|
-
*/
|
|
107
|
-
validateServerAuthorizationCodeResponse(
|
|
108
|
-
serverResponse: ServerAuthorizationCodeResponse,
|
|
109
|
-
requestState: string
|
|
110
|
-
): void {
|
|
111
|
-
if (!serverResponse.state || !requestState) {
|
|
112
|
-
throw serverResponse.state
|
|
113
|
-
? createClientAuthError(
|
|
114
|
-
ClientAuthErrorCodes.stateNotFound,
|
|
115
|
-
"Cached State"
|
|
116
|
-
)
|
|
117
|
-
: createClientAuthError(
|
|
118
|
-
ClientAuthErrorCodes.stateNotFound,
|
|
119
|
-
"Server State"
|
|
120
|
-
);
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
let decodedServerResponseState: string;
|
|
124
|
-
let decodedRequestState: string;
|
|
125
|
-
|
|
126
|
-
try {
|
|
127
|
-
decodedServerResponseState = decodeURIComponent(
|
|
128
|
-
serverResponse.state
|
|
129
|
-
);
|
|
130
|
-
} catch (e) {
|
|
131
|
-
throw createClientAuthError(
|
|
132
|
-
ClientAuthErrorCodes.invalidState,
|
|
133
|
-
serverResponse.state
|
|
134
|
-
);
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
try {
|
|
138
|
-
decodedRequestState = decodeURIComponent(requestState);
|
|
139
|
-
} catch (e) {
|
|
140
|
-
throw createClientAuthError(
|
|
141
|
-
ClientAuthErrorCodes.invalidState,
|
|
142
|
-
serverResponse.state
|
|
143
|
-
);
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
if (decodedServerResponseState !== decodedRequestState) {
|
|
147
|
-
throw createClientAuthError(ClientAuthErrorCodes.stateMismatch);
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
// Check for error
|
|
151
|
-
if (
|
|
152
|
-
serverResponse.error ||
|
|
153
|
-
serverResponse.error_description ||
|
|
154
|
-
serverResponse.suberror
|
|
155
|
-
) {
|
|
156
|
-
const serverErrorNo = parseServerErrorNo(serverResponse);
|
|
157
|
-
if (
|
|
158
|
-
isInteractionRequiredError(
|
|
159
|
-
serverResponse.error,
|
|
160
|
-
serverResponse.error_description,
|
|
161
|
-
serverResponse.suberror
|
|
162
|
-
)
|
|
163
|
-
) {
|
|
164
|
-
throw new InteractionRequiredAuthError(
|
|
165
|
-
serverResponse.error || "",
|
|
166
|
-
serverResponse.error_description,
|
|
167
|
-
serverResponse.suberror,
|
|
168
|
-
serverResponse.timestamp || "",
|
|
169
|
-
serverResponse.trace_id || "",
|
|
170
|
-
serverResponse.correlation_id || "",
|
|
171
|
-
serverResponse.claims || "",
|
|
172
|
-
serverErrorNo
|
|
173
|
-
);
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
throw new ServerError(
|
|
177
|
-
serverResponse.error || "",
|
|
178
|
-
serverResponse.error_description,
|
|
179
|
-
serverResponse.suberror,
|
|
180
|
-
serverErrorNo
|
|
181
|
-
);
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
|
|
185
88
|
/**
|
|
186
89
|
* Function which validates server authorization token response.
|
|
187
90
|
* @param serverResponse
|
|
@@ -632,15 +535,16 @@ export class ResponseHandler {
|
|
|
632
535
|
responseScopes = ScopeSet.fromString(
|
|
633
536
|
cacheRecord.accessToken.target
|
|
634
537
|
).asArray();
|
|
635
|
-
expiresOn
|
|
636
|
-
|
|
538
|
+
// Access token expiresOn cached in seconds, converting to Date for AuthenticationResult
|
|
539
|
+
expiresOn = TimeUtils.toDateFromSeconds(
|
|
540
|
+
cacheRecord.accessToken.expiresOn
|
|
637
541
|
);
|
|
638
|
-
extExpiresOn =
|
|
639
|
-
|
|
542
|
+
extExpiresOn = TimeUtils.toDateFromSeconds(
|
|
543
|
+
cacheRecord.accessToken.extendedExpiresOn
|
|
640
544
|
);
|
|
641
545
|
if (cacheRecord.accessToken.refreshOn) {
|
|
642
|
-
refreshOn =
|
|
643
|
-
|
|
546
|
+
refreshOn = TimeUtils.toDateFromSeconds(
|
|
547
|
+
cacheRecord.accessToken.refreshOn
|
|
644
548
|
);
|
|
645
549
|
}
|
|
646
550
|
}
|
|
@@ -214,13 +214,12 @@ export const PerformanceEvents = {
|
|
|
214
214
|
"standardInteractionClientGetClientConfiguration",
|
|
215
215
|
StandardInteractionClientInitializeAuthorizationRequest:
|
|
216
216
|
"standardInteractionClientInitializeAuthorizationRequest",
|
|
217
|
-
StandardInteractionClientInitializeAuthorizationCodeRequest:
|
|
218
|
-
"standardInteractionClientInitializeAuthorizationCodeRequest",
|
|
219
217
|
|
|
220
218
|
/**
|
|
221
219
|
* getAuthCodeUrl API (msal-browser and msal-node).
|
|
222
220
|
*/
|
|
223
221
|
GetAuthCodeUrl: "getAuthCodeUrl",
|
|
222
|
+
GetStandardParams: "getStandardParams",
|
|
224
223
|
|
|
225
224
|
/**
|
|
226
225
|
* Functions from InteractionHandler (msal-browser)
|
|
@@ -235,7 +234,6 @@ export const PerformanceEvents = {
|
|
|
235
234
|
AuthClientAcquireToken: "authClientAcquireToken",
|
|
236
235
|
AuthClientExecuteTokenRequest: "authClientExecuteTokenRequest",
|
|
237
236
|
AuthClientCreateTokenRequestBody: "authClientCreateTokenRequestBody",
|
|
238
|
-
AuthClientCreateQueryString: "authClientCreateQueryString",
|
|
239
237
|
|
|
240
238
|
/**
|
|
241
239
|
* Generate functions in PopTokenGenerator (msal-common)
|
|
@@ -433,10 +431,6 @@ export const PerformanceEventAbbreviations: ReadonlyMap<string, string> =
|
|
|
433
431
|
PerformanceEvents.StandardInteractionClientInitializeAuthorizationRequest,
|
|
434
432
|
"StdIntClientInitAuthReq",
|
|
435
433
|
],
|
|
436
|
-
[
|
|
437
|
-
PerformanceEvents.StandardInteractionClientInitializeAuthorizationCodeRequest,
|
|
438
|
-
"StdIntClientInitAuthCodeReq",
|
|
439
|
-
],
|
|
440
434
|
|
|
441
435
|
[PerformanceEvents.GetAuthCodeUrl, "GetAuthCodeUrl"],
|
|
442
436
|
|
|
@@ -453,10 +447,6 @@ export const PerformanceEventAbbreviations: ReadonlyMap<string, string> =
|
|
|
453
447
|
PerformanceEvents.AuthClientCreateTokenRequestBody,
|
|
454
448
|
"AuthClientCreateTReqBody",
|
|
455
449
|
],
|
|
456
|
-
[
|
|
457
|
-
PerformanceEvents.AuthClientCreateQueryString,
|
|
458
|
-
"AuthClientCreateQueryStr",
|
|
459
|
-
],
|
|
460
450
|
[PerformanceEvents.PopTokenGenerateCnf, "PopTGenCnf"],
|
|
461
451
|
[PerformanceEvents.PopTokenGenerateKid, "PopTGenKid"],
|
|
462
452
|
[PerformanceEvents.HandleServerTokenResponse, "HandleServerTRes"],
|
package/src/utils/TimeUtils.ts
CHANGED
|
@@ -15,6 +15,26 @@ export function nowSeconds(): number {
|
|
|
15
15
|
return Math.round(new Date().getTime() / 1000.0);
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
+
/**
|
|
19
|
+
* Converts JS Date object to seconds
|
|
20
|
+
* @param date Date
|
|
21
|
+
*/
|
|
22
|
+
export function toSecondsFromDate(date: Date): number {
|
|
23
|
+
// Convert date to seconds
|
|
24
|
+
return date.getTime() / 1000;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Convert seconds to JS Date object. Seconds can be in a number or string format or undefined (will still return a date).
|
|
29
|
+
* @param seconds
|
|
30
|
+
*/
|
|
31
|
+
export function toDateFromSeconds(seconds: number | string | undefined): Date {
|
|
32
|
+
if (seconds) {
|
|
33
|
+
return new Date(Number(seconds) * 1000);
|
|
34
|
+
}
|
|
35
|
+
return new Date();
|
|
36
|
+
}
|
|
37
|
+
|
|
18
38
|
/**
|
|
19
39
|
* check if a token is expired based on given UTC time in seconds.
|
|
20
40
|
* @param expiresOn
|
package/src/utils/UrlUtils.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import { AuthorizeResponse } from "../response/AuthorizeResponse.js";
|
|
7
7
|
import {
|
|
8
8
|
ClientAuthErrorCodes,
|
|
9
9
|
createClientAuthError,
|
|
@@ -31,7 +31,7 @@ export function stripLeadingHashOrQuery(responseString: string): string {
|
|
|
31
31
|
*/
|
|
32
32
|
export function getDeserializedResponse(
|
|
33
33
|
responseString: string
|
|
34
|
-
):
|
|
34
|
+
): AuthorizeResponse | null {
|
|
35
35
|
// Check if given hash is empty
|
|
36
36
|
if (!responseString || responseString.indexOf("=") < 0) {
|
|
37
37
|
return null;
|
|
@@ -40,8 +40,9 @@ export function getDeserializedResponse(
|
|
|
40
40
|
// Strip the # or ? symbol if present
|
|
41
41
|
const normalizedResponse = stripLeadingHashOrQuery(responseString);
|
|
42
42
|
// If # symbol was not present, above will return empty string, so give original hash value
|
|
43
|
-
const deserializedHash:
|
|
44
|
-
|
|
43
|
+
const deserializedHash: AuthorizeResponse = Object.fromEntries(
|
|
44
|
+
new URLSearchParams(normalizedResponse)
|
|
45
|
+
);
|
|
45
46
|
|
|
46
47
|
// Check for known response properties
|
|
47
48
|
if (
|
|
@@ -58,3 +59,16 @@ export function getDeserializedResponse(
|
|
|
58
59
|
|
|
59
60
|
return null;
|
|
60
61
|
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Utility to create a URL from the params map
|
|
65
|
+
*/
|
|
66
|
+
export function mapToQueryString(parameters: Map<string, string>): string {
|
|
67
|
+
const queryParameterArray: Array<string> = new Array<string>();
|
|
68
|
+
|
|
69
|
+
parameters.forEach((value, key) => {
|
|
70
|
+
queryParameterArray.push(`${key}=${encodeURIComponent(value)}`);
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
return queryParameterArray.join("&");
|
|
74
|
+
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Deserialized response object from server authorization code request.
|
|
3
|
-
* - code: authorization code from server
|
|
4
|
-
* - client_info: client info object
|
|
5
|
-
* - state: OAuth2 request state
|
|
6
|
-
* - error: error sent back in hash
|
|
7
|
-
* - error: description
|
|
8
|
-
*/
|
|
9
|
-
export type ServerAuthorizationCodeResponse = {
|
|
10
|
-
code?: string;
|
|
11
|
-
client_info?: string;
|
|
12
|
-
state?: string;
|
|
13
|
-
cloud_instance_name?: string;
|
|
14
|
-
cloud_instance_host_name?: string;
|
|
15
|
-
cloud_graph_host_name?: string;
|
|
16
|
-
msgraph_host?: string;
|
|
17
|
-
error?: string;
|
|
18
|
-
error_uri?: string;
|
|
19
|
-
error_description?: string;
|
|
20
|
-
suberror?: string;
|
|
21
|
-
timestamp?: string;
|
|
22
|
-
trace_id?: string;
|
|
23
|
-
correlation_id?: string;
|
|
24
|
-
claims?: string;
|
|
25
|
-
accountId?: string;
|
|
26
|
-
};
|
|
27
|
-
//# sourceMappingURL=ServerAuthorizationCodeResponse.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ServerAuthorizationCodeResponse.d.ts","sourceRoot":"","sources":["../../src/response/ServerAuthorizationCodeResponse.ts"],"names":[],"mappings":"AAKA;;;;;;;GAOG;AACH,MAAM,MAAM,+BAA+B,GAAG;IAE1C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAClC,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC"}
|