@azure/msal-browser 3.0.2 → 3.2.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/app/IPublicClientApplication.d.ts +2 -0
- package/dist/app/IPublicClientApplication.d.ts.map +1 -1
- package/dist/app/IPublicClientApplication.mjs +22 -18
- package/dist/app/IPublicClientApplication.mjs.map +1 -1
- package/dist/app/PublicClientApplication.d.ts +20 -6
- package/dist/app/PublicClientApplication.d.ts.map +1 -1
- package/dist/app/PublicClientApplication.mjs +24 -7
- package/dist/app/PublicClientApplication.mjs.map +1 -1
- package/dist/broker/nativeBroker/NativeMessageHandler.d.ts +3 -4
- package/dist/broker/nativeBroker/NativeMessageHandler.d.ts.map +1 -1
- package/dist/broker/nativeBroker/NativeMessageHandler.mjs +17 -16
- package/dist/broker/nativeBroker/NativeMessageHandler.mjs.map +1 -1
- package/dist/broker/nativeBroker/NativeStatusCodes.d.ts +8 -0
- package/dist/broker/nativeBroker/NativeStatusCodes.d.ts.map +1 -0
- package/dist/broker/nativeBroker/NativeStatusCodes.mjs +16 -0
- package/dist/broker/nativeBroker/NativeStatusCodes.mjs.map +1 -0
- package/dist/cache/AsyncMemoryStorage.mjs +4 -3
- package/dist/cache/AsyncMemoryStorage.mjs.map +1 -1
- package/dist/cache/BrowserCacheManager.d.ts +10 -3
- package/dist/cache/BrowserCacheManager.d.ts.map +1 -1
- package/dist/cache/BrowserCacheManager.mjs +58 -29
- package/dist/cache/BrowserCacheManager.mjs.map +1 -1
- package/dist/cache/BrowserStorage.d.ts.map +1 -1
- package/dist/cache/BrowserStorage.mjs +7 -9
- package/dist/cache/BrowserStorage.mjs.map +1 -1
- package/dist/cache/CryptoKeyStore.mjs +1 -1
- package/dist/cache/CryptoKeyStore.mjs.map +1 -1
- package/dist/cache/DatabaseStorage.d.ts.map +1 -1
- package/dist/cache/DatabaseStorage.mjs +9 -8
- package/dist/cache/DatabaseStorage.mjs.map +1 -1
- package/dist/cache/MemoryStorage.mjs +1 -1
- package/dist/cache/MemoryStorage.mjs.map +1 -1
- package/dist/cache/TokenCache.d.ts.map +1 -1
- package/dist/cache/TokenCache.mjs +30 -30
- package/dist/cache/TokenCache.mjs.map +1 -1
- package/dist/config/Configuration.d.ts +1 -0
- package/dist/config/Configuration.d.ts.map +1 -1
- package/dist/config/Configuration.mjs +12 -16
- package/dist/config/Configuration.mjs.map +1 -1
- package/dist/controllers/ControllerFactory.mjs +1 -1
- package/dist/controllers/ControllerFactory.mjs.map +1 -1
- package/dist/controllers/IController.d.ts +5 -28
- package/dist/controllers/IController.d.ts.map +1 -1
- package/dist/controllers/StandardController.d.ts +17 -31
- package/dist/controllers/StandardController.d.ts.map +1 -1
- package/dist/controllers/StandardController.mjs +78 -83
- package/dist/controllers/StandardController.mjs.map +1 -1
- package/dist/crypto/BrowserCrypto.d.ts +44 -49
- package/dist/crypto/BrowserCrypto.d.ts.map +1 -1
- package/dist/crypto/BrowserCrypto.mjs +78 -77
- package/dist/crypto/BrowserCrypto.mjs.map +1 -1
- package/dist/crypto/CryptoOps.d.ts +1 -10
- package/dist/crypto/CryptoOps.d.ts.map +1 -1
- package/dist/crypto/CryptoOps.mjs +23 -34
- package/dist/crypto/CryptoOps.mjs.map +1 -1
- package/dist/crypto/PkceGenerator.d.ts +6 -22
- package/dist/crypto/PkceGenerator.d.ts.map +1 -1
- package/dist/crypto/PkceGenerator.mjs +48 -49
- package/dist/crypto/PkceGenerator.mjs.map +1 -1
- package/dist/crypto/SignedHttpRequest.mjs +1 -1
- package/dist/crypto/SignedHttpRequest.mjs.map +1 -1
- package/dist/encode/Base64Decode.d.ts +6 -19
- package/dist/encode/Base64Decode.d.ts.map +1 -1
- package/dist/encode/Base64Decode.mjs +31 -68
- package/dist/encode/Base64Decode.mjs.map +1 -1
- package/dist/encode/Base64Encode.d.ts +15 -27
- package/dist/encode/Base64Encode.d.ts.map +1 -1
- package/dist/encode/Base64Encode.mjs +36 -75
- package/dist/encode/Base64Encode.mjs.map +1 -1
- package/dist/error/BrowserAuthError.d.ts +63 -195
- package/dist/error/BrowserAuthError.d.ts.map +1 -1
- package/dist/error/BrowserAuthError.mjs +159 -381
- package/dist/error/BrowserAuthError.mjs.map +1 -1
- package/dist/error/BrowserAuthErrorCodes.d.ts +46 -0
- package/dist/error/BrowserAuthErrorCodes.d.ts.map +1 -0
- package/dist/error/BrowserAuthErrorCodes.mjs +54 -0
- package/dist/error/BrowserAuthErrorCodes.mjs.map +1 -0
- package/dist/error/BrowserConfigurationAuthError.d.ts +9 -46
- package/dist/error/BrowserConfigurationAuthError.d.ts.map +1 -1
- package/dist/error/BrowserConfigurationAuthError.mjs +20 -73
- package/dist/error/BrowserConfigurationAuthError.mjs.map +1 -1
- package/dist/error/BrowserConfigurationAuthErrorCodes.d.ts +4 -0
- package/dist/error/BrowserConfigurationAuthErrorCodes.d.ts.map +1 -0
- package/dist/error/BrowserConfigurationAuthErrorCodes.mjs +12 -0
- package/dist/error/BrowserConfigurationAuthErrorCodes.mjs.map +1 -0
- package/dist/error/NativeAuthError.d.ts +17 -45
- package/dist/error/NativeAuthError.d.ts.map +1 -1
- package/dist/error/NativeAuthError.mjs +49 -79
- package/dist/error/NativeAuthError.mjs.map +1 -1
- package/dist/error/NativeAuthErrorCodes.d.ts +3 -0
- package/dist/error/NativeAuthErrorCodes.d.ts.map +1 -0
- package/dist/error/NativeAuthErrorCodes.mjs +11 -0
- package/dist/error/NativeAuthErrorCodes.mjs.map +1 -0
- package/dist/event/EventHandler.d.ts.map +1 -1
- package/dist/event/EventHandler.mjs +3 -2
- package/dist/event/EventHandler.mjs.map +1 -1
- package/dist/event/EventMessage.mjs +1 -1
- package/dist/event/EventMessage.mjs.map +1 -1
- package/dist/event/EventType.mjs +1 -1
- package/dist/event/EventType.mjs.map +1 -1
- package/dist/index.d.ts +6 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +8 -4
- package/dist/index.mjs.map +1 -1
- package/dist/interaction_client/BaseInteractionClient.d.ts +2 -1
- package/dist/interaction_client/BaseInteractionClient.d.ts.map +1 -1
- package/dist/interaction_client/BaseInteractionClient.mjs +7 -8
- package/dist/interaction_client/BaseInteractionClient.mjs.map +1 -1
- package/dist/interaction_client/HybridSpaAuthorizationCodeClient.mjs +1 -1
- package/dist/interaction_client/HybridSpaAuthorizationCodeClient.mjs.map +1 -1
- package/dist/interaction_client/NativeInteractionClient.d.ts +4 -10
- package/dist/interaction_client/NativeInteractionClient.d.ts.map +1 -1
- package/dist/interaction_client/NativeInteractionClient.mjs +32 -38
- package/dist/interaction_client/NativeInteractionClient.mjs.map +1 -1
- package/dist/interaction_client/PopupClient.d.ts.map +1 -1
- package/dist/interaction_client/PopupClient.mjs +16 -15
- package/dist/interaction_client/PopupClient.mjs.map +1 -1
- package/dist/interaction_client/RedirectClient.d.ts.map +1 -1
- package/dist/interaction_client/RedirectClient.mjs +7 -6
- package/dist/interaction_client/RedirectClient.mjs.map +1 -1
- package/dist/interaction_client/SilentAuthCodeClient.d.ts.map +1 -1
- package/dist/interaction_client/SilentAuthCodeClient.mjs +9 -11
- package/dist/interaction_client/SilentAuthCodeClient.mjs.map +1 -1
- package/dist/interaction_client/SilentCacheClient.d.ts +4 -2
- package/dist/interaction_client/SilentCacheClient.d.ts.map +1 -1
- package/dist/interaction_client/SilentCacheClient.mjs +19 -25
- package/dist/interaction_client/SilentCacheClient.mjs.map +1 -1
- package/dist/interaction_client/SilentIframeClient.d.ts.map +1 -1
- package/dist/interaction_client/SilentIframeClient.mjs +20 -47
- package/dist/interaction_client/SilentIframeClient.mjs.map +1 -1
- package/dist/interaction_client/SilentRefreshClient.d.ts.map +1 -1
- package/dist/interaction_client/SilentRefreshClient.mjs +11 -20
- package/dist/interaction_client/SilentRefreshClient.mjs.map +1 -1
- package/dist/interaction_client/StandardInteractionClient.d.ts.map +1 -1
- package/dist/interaction_client/StandardInteractionClient.mjs +18 -38
- package/dist/interaction_client/StandardInteractionClient.mjs.map +1 -1
- package/dist/interaction_handler/InteractionHandler.d.ts.map +1 -1
- package/dist/interaction_handler/InteractionHandler.mjs +13 -16
- package/dist/interaction_handler/InteractionHandler.mjs.map +1 -1
- package/dist/interaction_handler/RedirectHandler.d.ts.map +1 -1
- package/dist/interaction_handler/RedirectHandler.mjs +12 -11
- package/dist/interaction_handler/RedirectHandler.mjs.map +1 -1
- package/dist/interaction_handler/SilentHandler.d.ts.map +1 -1
- package/dist/interaction_handler/SilentHandler.mjs +11 -11
- package/dist/interaction_handler/SilentHandler.mjs.map +1 -1
- package/dist/navigation/NavigationClient.mjs +1 -1
- package/dist/navigation/NavigationClient.mjs.map +1 -1
- package/dist/network/FetchClient.d.ts.map +1 -1
- package/dist/network/FetchClient.mjs +9 -8
- package/dist/network/FetchClient.mjs.map +1 -1
- package/dist/operatingcontext/BaseOperatingContext.mjs +1 -1
- package/dist/operatingcontext/BaseOperatingContext.mjs.map +1 -1
- package/dist/operatingcontext/StandardOperatingContext.mjs +1 -1
- package/dist/operatingcontext/StandardOperatingContext.mjs.map +1 -1
- package/dist/operatingcontext/TeamsAppOperatingContext.mjs +1 -1
- package/dist/operatingcontext/TeamsAppOperatingContext.mjs.map +1 -1
- package/dist/packageMetadata.d.ts +1 -1
- package/dist/packageMetadata.mjs +2 -2
- package/dist/packageMetadata.mjs.map +1 -1
- package/dist/request/ClearCacheRequest.d.ts +11 -0
- package/dist/request/ClearCacheRequest.d.ts.map +1 -0
- package/dist/telemetry/BrowserPerformanceClient.d.ts +2 -4
- package/dist/telemetry/BrowserPerformanceClient.d.ts.map +1 -1
- package/dist/telemetry/BrowserPerformanceClient.mjs +2 -6
- package/dist/telemetry/BrowserPerformanceClient.mjs.map +1 -1
- package/dist/telemetry/BrowserPerformanceMeasurement.mjs +1 -1
- package/dist/telemetry/BrowserPerformanceMeasurement.mjs.map +1 -1
- package/dist/utils/BrowserConstants.mjs +1 -1
- package/dist/utils/BrowserConstants.mjs.map +1 -1
- package/dist/utils/BrowserProtocolUtils.d.ts.map +1 -1
- package/dist/utils/BrowserProtocolUtils.mjs +4 -4
- package/dist/utils/BrowserProtocolUtils.mjs.map +1 -1
- package/dist/utils/BrowserStringUtils.mjs +1 -1
- package/dist/utils/BrowserStringUtils.mjs.map +1 -1
- package/dist/utils/BrowserUtils.d.ts +0 -9
- package/dist/utils/BrowserUtils.d.ts.map +1 -1
- package/dist/utils/BrowserUtils.mjs +8 -33
- package/dist/utils/BrowserUtils.mjs.map +1 -1
- package/lib/msal-browser.cjs +8729 -9566
- package/lib/msal-browser.cjs.map +1 -1
- package/lib/msal-browser.js +8729 -9566
- package/lib/msal-browser.js.map +1 -1
- package/lib/msal-browser.min.js +68 -62
- package/package.json +7 -5
- package/src/app/IPublicClientApplication.ts +236 -0
- package/src/app/PublicClientApplication.ts +417 -0
- package/src/broker/nativeBroker/NativeMessageHandler.ts +416 -0
- package/src/broker/nativeBroker/NativeRequest.ts +52 -0
- package/src/broker/nativeBroker/NativeResponse.ts +56 -0
- package/src/broker/nativeBroker/NativeStatusCodes.ts +13 -0
- package/src/cache/AsyncMemoryStorage.ts +158 -0
- package/src/cache/BrowserCacheManager.ts +2009 -0
- package/src/cache/BrowserStorage.ts +52 -0
- package/src/cache/CryptoKeyStore.ts +63 -0
- package/src/cache/DatabaseStorage.ts +287 -0
- package/src/cache/IAsyncMemoryStorage.ts +36 -0
- package/src/cache/ITokenCache.ts +21 -0
- package/src/cache/IWindowStorage.ts +36 -0
- package/src/cache/MemoryStorage.ts +42 -0
- package/src/cache/TokenCache.ts +484 -0
- package/src/config/Configuration.ts +383 -0
- package/src/controllers/ControllerFactory.ts +55 -0
- package/src/controllers/IController.ts +134 -0
- package/src/controllers/StandardController.ts +2170 -0
- package/src/crypto/BrowserCrypto.ts +151 -0
- package/src/crypto/CryptoOps.ts +235 -0
- package/src/crypto/PkceGenerator.ts +115 -0
- package/src/crypto/SignedHttpRequest.ts +76 -0
- package/src/encode/Base64Decode.ts +46 -0
- package/src/encode/Base64Encode.ts +52 -0
- package/src/error/BrowserAuthError.ts +352 -0
- package/src/error/BrowserAuthErrorCodes.ts +57 -0
- package/src/error/BrowserConfigurationAuthError.ts +64 -0
- package/src/error/BrowserConfigurationAuthErrorCodes.ts +9 -0
- package/src/error/NativeAuthError.ts +113 -0
- package/src/error/NativeAuthErrorCodes.ts +7 -0
- package/src/event/EventHandler.ts +177 -0
- package/src/event/EventMessage.ts +125 -0
- package/src/event/EventType.ts +33 -0
- package/src/index.ts +157 -0
- package/src/interaction_client/BaseInteractionClient.ts +307 -0
- package/src/interaction_client/HybridSpaAuthorizationCodeClient.ts +16 -0
- package/src/interaction_client/NativeInteractionClient.ts +925 -0
- package/src/interaction_client/PopupClient.ts +926 -0
- package/src/interaction_client/RedirectClient.ts +616 -0
- package/src/interaction_client/SilentAuthCodeClient.ts +165 -0
- package/src/interaction_client/SilentCacheClient.ts +125 -0
- package/src/interaction_client/SilentIframeClient.ts +301 -0
- package/src/interaction_client/SilentRefreshClient.ts +118 -0
- package/src/interaction_client/StandardInteractionClient.ts +450 -0
- package/src/interaction_handler/InteractionHandler.ts +251 -0
- package/src/interaction_handler/RedirectHandler.ts +229 -0
- package/src/interaction_handler/SilentHandler.ts +269 -0
- package/src/navigation/INavigationClient.ts +23 -0
- package/src/navigation/NavigationClient.ts +55 -0
- package/src/navigation/NavigationOptions.ts +18 -0
- package/src/network/FetchClient.ts +130 -0
- package/src/operatingcontext/BaseOperatingContext.ts +82 -0
- package/src/operatingcontext/StandardOperatingContext.ts +49 -0
- package/src/operatingcontext/TeamsAppOperatingContext.ts +48 -0
- package/src/packageMetadata.ts +3 -0
- package/src/request/AuthorizationCodeRequest.ts +19 -0
- package/src/request/AuthorizationUrlRequest.ts +17 -0
- package/src/request/ClearCacheRequest.ts +16 -0
- package/src/request/EndSessionPopupRequest.ts +26 -0
- package/src/request/EndSessionRequest.ts +23 -0
- package/src/request/PopupRequest.ts +51 -0
- package/src/request/PopupWindowAttributes.ts +22 -0
- package/src/request/RedirectRequest.ts +51 -0
- package/src/request/SilentRequest.ts +49 -0
- package/src/request/SsoSilentRequest.ts +44 -0
- package/src/response/AuthenticationResult.ts +13 -0
- package/src/telemetry/BrowserPerformanceClient.ts +226 -0
- package/src/telemetry/BrowserPerformanceMeasurement.ts +144 -0
- package/src/utils/BrowserConstants.ts +241 -0
- package/src/utils/BrowserProtocolUtils.ts +58 -0
- package/src/utils/BrowserStringUtils.ts +143 -0
- package/src/utils/BrowserUtils.ts +156 -0
- package/dist/crypto/GuidGenerator.d.ts +0 -13
- package/dist/crypto/GuidGenerator.d.ts.map +0 -1
- package/dist/crypto/GuidGenerator.mjs +0 -104
- package/dist/crypto/GuidGenerator.mjs.map +0 -1
- package/dist/crypto/ISubtleCrypto.d.ts +0 -10
- package/dist/crypto/ISubtleCrypto.d.ts.map +0 -1
- package/dist/crypto/ModernBrowserCrypto.d.ts +0 -10
- package/dist/crypto/ModernBrowserCrypto.d.ts.map +0 -1
- package/dist/crypto/ModernBrowserCrypto.mjs +0 -31
- package/dist/crypto/ModernBrowserCrypto.mjs.map +0 -1
- package/dist/internals.d.ts +0 -23
- package/dist/internals.d.ts.map +0 -1
- package/dist/internals.mjs +0 -28
- package/dist/internals.mjs.map +0 -1
- package/dist/network/XhrClient.d.ts +0 -41
- package/dist/network/XhrClient.d.ts.map +0 -1
- package/dist/network/XhrClient.mjs +0 -125
- package/dist/network/XhrClient.mjs.map +0 -1
- package/dist/utils/MathUtils.d.ts +0 -12
- package/dist/utils/MathUtils.d.ts.map +0 -1
- package/dist/utils/MathUtils.mjs +0 -26
- package/dist/utils/MathUtils.mjs.map +0 -1
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { IPerformanceMeasurement, SubMeasurement } from "@azure/msal-common";
|
|
7
|
+
|
|
8
|
+
export class BrowserPerformanceMeasurement implements IPerformanceMeasurement {
|
|
9
|
+
private readonly measureName: string;
|
|
10
|
+
private readonly correlationId: string;
|
|
11
|
+
private readonly startMark: string;
|
|
12
|
+
private readonly endMark: string;
|
|
13
|
+
|
|
14
|
+
constructor(name: string, correlationId: string) {
|
|
15
|
+
this.correlationId = correlationId;
|
|
16
|
+
this.measureName = BrowserPerformanceMeasurement.makeMeasureName(
|
|
17
|
+
name,
|
|
18
|
+
correlationId
|
|
19
|
+
);
|
|
20
|
+
this.startMark = BrowserPerformanceMeasurement.makeStartMark(
|
|
21
|
+
name,
|
|
22
|
+
correlationId
|
|
23
|
+
);
|
|
24
|
+
this.endMark = BrowserPerformanceMeasurement.makeEndMark(
|
|
25
|
+
name,
|
|
26
|
+
correlationId
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
private static makeMeasureName(name: string, correlationId: string) {
|
|
31
|
+
return `msal.measure.${name}.${correlationId}`;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
private static makeStartMark(name: string, correlationId: string) {
|
|
35
|
+
return `msal.start.${name}.${correlationId}`;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
private static makeEndMark(name: string, correlationId: string) {
|
|
39
|
+
return `msal.end.${name}.${correlationId}`;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
static supportsBrowserPerformance(): boolean {
|
|
43
|
+
return (
|
|
44
|
+
typeof window !== "undefined" &&
|
|
45
|
+
typeof window.performance !== "undefined" &&
|
|
46
|
+
typeof window.performance.mark === "function" &&
|
|
47
|
+
typeof window.performance.measure === "function" &&
|
|
48
|
+
typeof window.performance.clearMarks === "function" &&
|
|
49
|
+
typeof window.performance.clearMeasures === "function" &&
|
|
50
|
+
typeof window.performance.getEntriesByName === "function"
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Flush browser marks and measurements.
|
|
56
|
+
* @param {string} correlationId
|
|
57
|
+
* @param {SubMeasurement} measurements
|
|
58
|
+
*/
|
|
59
|
+
public static flushMeasurements(
|
|
60
|
+
correlationId: string,
|
|
61
|
+
measurements: SubMeasurement[]
|
|
62
|
+
): void {
|
|
63
|
+
if (BrowserPerformanceMeasurement.supportsBrowserPerformance()) {
|
|
64
|
+
try {
|
|
65
|
+
measurements.forEach((measurement) => {
|
|
66
|
+
const measureName =
|
|
67
|
+
BrowserPerformanceMeasurement.makeMeasureName(
|
|
68
|
+
measurement.name,
|
|
69
|
+
correlationId
|
|
70
|
+
);
|
|
71
|
+
const entriesForMeasurement =
|
|
72
|
+
window.performance.getEntriesByName(
|
|
73
|
+
measureName,
|
|
74
|
+
"measure"
|
|
75
|
+
);
|
|
76
|
+
if (entriesForMeasurement.length > 0) {
|
|
77
|
+
window.performance.clearMeasures(measureName);
|
|
78
|
+
window.performance.clearMarks(
|
|
79
|
+
BrowserPerformanceMeasurement.makeStartMark(
|
|
80
|
+
measureName,
|
|
81
|
+
correlationId
|
|
82
|
+
)
|
|
83
|
+
);
|
|
84
|
+
window.performance.clearMarks(
|
|
85
|
+
BrowserPerformanceMeasurement.makeEndMark(
|
|
86
|
+
measureName,
|
|
87
|
+
correlationId
|
|
88
|
+
)
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
} catch (e) {
|
|
93
|
+
// Silently catch and return null
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
startMeasurement(): void {
|
|
99
|
+
if (BrowserPerformanceMeasurement.supportsBrowserPerformance()) {
|
|
100
|
+
try {
|
|
101
|
+
window.performance.mark(this.startMark);
|
|
102
|
+
} catch (e) {
|
|
103
|
+
// Silently catch
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
endMeasurement(): void {
|
|
109
|
+
if (BrowserPerformanceMeasurement.supportsBrowserPerformance()) {
|
|
110
|
+
try {
|
|
111
|
+
window.performance.mark(this.endMark);
|
|
112
|
+
window.performance.measure(
|
|
113
|
+
this.measureName,
|
|
114
|
+
this.startMark,
|
|
115
|
+
this.endMark
|
|
116
|
+
);
|
|
117
|
+
} catch (e) {
|
|
118
|
+
// Silently catch
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
flushMeasurement(): number | null {
|
|
124
|
+
if (BrowserPerformanceMeasurement.supportsBrowserPerformance()) {
|
|
125
|
+
try {
|
|
126
|
+
const entriesForMeasurement =
|
|
127
|
+
window.performance.getEntriesByName(
|
|
128
|
+
this.measureName,
|
|
129
|
+
"measure"
|
|
130
|
+
);
|
|
131
|
+
if (entriesForMeasurement.length > 0) {
|
|
132
|
+
const durationMs = entriesForMeasurement[0].duration;
|
|
133
|
+
window.performance.clearMeasures(this.measureName);
|
|
134
|
+
window.performance.clearMarks(this.startMark);
|
|
135
|
+
window.performance.clearMarks(this.endMark);
|
|
136
|
+
return durationMs;
|
|
137
|
+
}
|
|
138
|
+
} catch (e) {
|
|
139
|
+
// Silently catch and return null
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
return null;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { OIDC_DEFAULT_SCOPES } from "@azure/msal-common";
|
|
7
|
+
import { PopupRequest } from "../request/PopupRequest";
|
|
8
|
+
import { RedirectRequest } from "../request/RedirectRequest";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Constants
|
|
12
|
+
*/
|
|
13
|
+
export const BrowserConstants = {
|
|
14
|
+
/**
|
|
15
|
+
* Interaction in progress cache value
|
|
16
|
+
*/
|
|
17
|
+
INTERACTION_IN_PROGRESS_VALUE: "interaction_in_progress",
|
|
18
|
+
/**
|
|
19
|
+
* Invalid grant error code
|
|
20
|
+
*/
|
|
21
|
+
INVALID_GRANT_ERROR: "invalid_grant",
|
|
22
|
+
/**
|
|
23
|
+
* Default popup window width
|
|
24
|
+
*/
|
|
25
|
+
POPUP_WIDTH: 483,
|
|
26
|
+
/**
|
|
27
|
+
* Default popup window height
|
|
28
|
+
*/
|
|
29
|
+
POPUP_HEIGHT: 600,
|
|
30
|
+
/**
|
|
31
|
+
* Name of the popup window starts with
|
|
32
|
+
*/
|
|
33
|
+
POPUP_NAME_PREFIX: "msal",
|
|
34
|
+
/**
|
|
35
|
+
* Default popup monitor poll interval in milliseconds
|
|
36
|
+
*/
|
|
37
|
+
DEFAULT_POLL_INTERVAL_MS: 30,
|
|
38
|
+
/**
|
|
39
|
+
* Msal-browser SKU
|
|
40
|
+
*/
|
|
41
|
+
MSAL_SKU: "msal.js.browser",
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export const NativeConstants = {
|
|
45
|
+
CHANNEL_ID: "53ee284d-920a-4b59-9d30-a60315b26836",
|
|
46
|
+
PREFERRED_EXTENSION_ID: "ppnbnpeolgkicgegkbkbjmhlideopiji",
|
|
47
|
+
MATS_TELEMETRY: "MATS",
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export const NativeExtensionMethod = {
|
|
51
|
+
HandshakeRequest: "Handshake",
|
|
52
|
+
HandshakeResponse: "HandshakeResponse",
|
|
53
|
+
GetToken: "GetToken",
|
|
54
|
+
Response: "Response",
|
|
55
|
+
} as const;
|
|
56
|
+
export type NativeExtensionMethod =
|
|
57
|
+
(typeof NativeExtensionMethod)[keyof typeof NativeExtensionMethod];
|
|
58
|
+
|
|
59
|
+
export const BrowserCacheLocation = {
|
|
60
|
+
LocalStorage: "localStorage",
|
|
61
|
+
SessionStorage: "sessionStorage",
|
|
62
|
+
MemoryStorage: "memoryStorage",
|
|
63
|
+
} as const;
|
|
64
|
+
export type BrowserCacheLocation =
|
|
65
|
+
(typeof BrowserCacheLocation)[keyof typeof BrowserCacheLocation];
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* HTTP Request types supported by MSAL.
|
|
69
|
+
*/
|
|
70
|
+
export const HTTP_REQUEST_TYPE = {
|
|
71
|
+
GET: "GET",
|
|
72
|
+
POST: "POST",
|
|
73
|
+
} as const;
|
|
74
|
+
export type HTTP_REQUEST_TYPE =
|
|
75
|
+
(typeof HTTP_REQUEST_TYPE)[keyof typeof HTTP_REQUEST_TYPE];
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Temporary cache keys for MSAL, deleted after any request.
|
|
79
|
+
*/
|
|
80
|
+
export const TemporaryCacheKeys = {
|
|
81
|
+
AUTHORITY: "authority",
|
|
82
|
+
ACQUIRE_TOKEN_ACCOUNT: "acquireToken.account",
|
|
83
|
+
SESSION_STATE: "session.state",
|
|
84
|
+
REQUEST_STATE: "request.state",
|
|
85
|
+
NONCE_IDTOKEN: "nonce.id_token",
|
|
86
|
+
ORIGIN_URI: "request.origin",
|
|
87
|
+
RENEW_STATUS: "token.renew.status",
|
|
88
|
+
URL_HASH: "urlHash",
|
|
89
|
+
REQUEST_PARAMS: "request.params",
|
|
90
|
+
SCOPES: "scopes",
|
|
91
|
+
INTERACTION_STATUS_KEY: "interaction.status",
|
|
92
|
+
CCS_CREDENTIAL: "ccs.credential",
|
|
93
|
+
CORRELATION_ID: "request.correlationId",
|
|
94
|
+
NATIVE_REQUEST: "request.native",
|
|
95
|
+
REDIRECT_CONTEXT: "request.redirect.context",
|
|
96
|
+
} as const;
|
|
97
|
+
export type TemporaryCacheKeys =
|
|
98
|
+
(typeof TemporaryCacheKeys)[keyof typeof TemporaryCacheKeys];
|
|
99
|
+
|
|
100
|
+
export const StaticCacheKeys = {
|
|
101
|
+
ACCOUNT_KEYS: "msal.account.keys",
|
|
102
|
+
TOKEN_KEYS: "msal.token.keys",
|
|
103
|
+
} as const;
|
|
104
|
+
export type StaticCacheKeys =
|
|
105
|
+
(typeof StaticCacheKeys)[keyof typeof StaticCacheKeys];
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Cache keys stored in-memory
|
|
109
|
+
*/
|
|
110
|
+
export const InMemoryCacheKeys = {
|
|
111
|
+
WRAPPER_SKU: "wrapper.sku",
|
|
112
|
+
WRAPPER_VER: "wrapper.version",
|
|
113
|
+
} as const;
|
|
114
|
+
export type InMemoryCacheKeys =
|
|
115
|
+
(typeof InMemoryCacheKeys)[keyof typeof InMemoryCacheKeys];
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* API Codes for Telemetry purposes.
|
|
119
|
+
* Before adding a new code you must claim it in the MSAL Telemetry tracker as these number spaces are shared across all MSALs
|
|
120
|
+
* 0-99 Silent Flow
|
|
121
|
+
* 800-899 Auth Code Flow
|
|
122
|
+
*/
|
|
123
|
+
export const ApiId = {
|
|
124
|
+
acquireTokenRedirect: 861,
|
|
125
|
+
acquireTokenPopup: 862,
|
|
126
|
+
ssoSilent: 863,
|
|
127
|
+
acquireTokenSilent_authCode: 864,
|
|
128
|
+
handleRedirectPromise: 865,
|
|
129
|
+
acquireTokenByCode: 866,
|
|
130
|
+
acquireTokenSilent_silentFlow: 61,
|
|
131
|
+
logout: 961,
|
|
132
|
+
logoutPopup: 962,
|
|
133
|
+
} as const;
|
|
134
|
+
export type ApiId = (typeof ApiId)[keyof typeof ApiId];
|
|
135
|
+
|
|
136
|
+
/*
|
|
137
|
+
* Interaction type of the API - used for state and telemetry
|
|
138
|
+
*/
|
|
139
|
+
export enum InteractionType {
|
|
140
|
+
Redirect = "redirect",
|
|
141
|
+
Popup = "popup",
|
|
142
|
+
Silent = "silent",
|
|
143
|
+
None = "none",
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Types of interaction currently in progress.
|
|
148
|
+
* Used in events in wrapper libraries to invoke functions when certain interaction is in progress or all interactions are complete.
|
|
149
|
+
*/
|
|
150
|
+
export const InteractionStatus = {
|
|
151
|
+
/**
|
|
152
|
+
* Initial status before interaction occurs
|
|
153
|
+
*/
|
|
154
|
+
Startup: "startup",
|
|
155
|
+
/**
|
|
156
|
+
* Status set when all login calls occuring
|
|
157
|
+
*/
|
|
158
|
+
Login: "login",
|
|
159
|
+
/**
|
|
160
|
+
* Status set when logout call occuring
|
|
161
|
+
*/
|
|
162
|
+
Logout: "logout",
|
|
163
|
+
/**
|
|
164
|
+
* Status set for acquireToken calls
|
|
165
|
+
*/
|
|
166
|
+
AcquireToken: "acquireToken",
|
|
167
|
+
/**
|
|
168
|
+
* Status set for ssoSilent calls
|
|
169
|
+
*/
|
|
170
|
+
SsoSilent: "ssoSilent",
|
|
171
|
+
/**
|
|
172
|
+
* Status set when handleRedirect in progress
|
|
173
|
+
*/
|
|
174
|
+
HandleRedirect: "handleRedirect",
|
|
175
|
+
/**
|
|
176
|
+
* Status set when interaction is complete
|
|
177
|
+
*/
|
|
178
|
+
None: "none",
|
|
179
|
+
} as const;
|
|
180
|
+
export type InteractionStatus =
|
|
181
|
+
(typeof InteractionStatus)[keyof typeof InteractionStatus];
|
|
182
|
+
|
|
183
|
+
export const DEFAULT_REQUEST: RedirectRequest | PopupRequest = {
|
|
184
|
+
scopes: OIDC_DEFAULT_SCOPES,
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* JWK Key Format string (Type MUST be defined for window crypto APIs)
|
|
189
|
+
*/
|
|
190
|
+
export const KEY_FORMAT_JWK = "jwk";
|
|
191
|
+
|
|
192
|
+
// Supported wrapper SKUs
|
|
193
|
+
export const WrapperSKU = {
|
|
194
|
+
React: "@azure/msal-react",
|
|
195
|
+
Angular: "@azure/msal-angular",
|
|
196
|
+
} as const;
|
|
197
|
+
export type WrapperSKU = (typeof WrapperSKU)[keyof typeof WrapperSKU];
|
|
198
|
+
|
|
199
|
+
// DatabaseStorage Constants
|
|
200
|
+
export const DB_NAME = "msal.db";
|
|
201
|
+
export const DB_VERSION = 1;
|
|
202
|
+
export const DB_TABLE_NAME = `${DB_NAME}.keys`;
|
|
203
|
+
|
|
204
|
+
export const CacheLookupPolicy = {
|
|
205
|
+
/*
|
|
206
|
+
* acquireTokenSilent will attempt to retrieve an access token from the cache. If the access token is expired
|
|
207
|
+
* or cannot be found the refresh token will be used to acquire a new one. Finally, if the refresh token
|
|
208
|
+
* is expired acquireTokenSilent will attempt to acquire new access and refresh tokens.
|
|
209
|
+
*/
|
|
210
|
+
Default: 0, // 0 is falsy, is equivalent to not passing in a CacheLookupPolicy
|
|
211
|
+
/*
|
|
212
|
+
* acquireTokenSilent will only look for access tokens in the cache. It will not attempt to renew access or
|
|
213
|
+
* refresh tokens.
|
|
214
|
+
*/
|
|
215
|
+
AccessToken: 1,
|
|
216
|
+
/*
|
|
217
|
+
* acquireTokenSilent will attempt to retrieve an access token from the cache. If the access token is expired or
|
|
218
|
+
* cannot be found, the refresh token will be used to acquire a new one. If the refresh token is expired, it
|
|
219
|
+
* will not be renewed and acquireTokenSilent will fail.
|
|
220
|
+
*/
|
|
221
|
+
AccessTokenAndRefreshToken: 2,
|
|
222
|
+
/*
|
|
223
|
+
* acquireTokenSilent will not attempt to retrieve access tokens from the cache and will instead attempt to
|
|
224
|
+
* exchange the cached refresh token for a new access token. If the refresh token is expired, it will not be
|
|
225
|
+
* renewed and acquireTokenSilent will fail.
|
|
226
|
+
*/
|
|
227
|
+
RefreshToken: 3,
|
|
228
|
+
/*
|
|
229
|
+
* acquireTokenSilent will not look in the cache for the access token. It will go directly to network with the
|
|
230
|
+
* cached refresh token. If the refresh token is expired an attempt will be made to renew it. This is equivalent to
|
|
231
|
+
* setting "forceRefresh: true".
|
|
232
|
+
*/
|
|
233
|
+
RefreshTokenAndNetwork: 4,
|
|
234
|
+
/*
|
|
235
|
+
* acquireTokenSilent will attempt to renew both access and refresh tokens. It will not look in the cache. This will
|
|
236
|
+
* always fail if 3rd party cookies are blocked by the browser.
|
|
237
|
+
*/
|
|
238
|
+
Skip: 5,
|
|
239
|
+
} as const;
|
|
240
|
+
export type CacheLookupPolicy =
|
|
241
|
+
(typeof CacheLookupPolicy)[keyof typeof CacheLookupPolicy];
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { InteractionType } from "./BrowserConstants";
|
|
7
|
+
import {
|
|
8
|
+
ICrypto,
|
|
9
|
+
RequestStateObject,
|
|
10
|
+
ProtocolUtils,
|
|
11
|
+
ServerAuthorizationCodeResponse,
|
|
12
|
+
UrlString,
|
|
13
|
+
createClientAuthError,
|
|
14
|
+
ClientAuthErrorCodes,
|
|
15
|
+
} from "@azure/msal-common";
|
|
16
|
+
|
|
17
|
+
export type BrowserStateObject = {
|
|
18
|
+
interactionType: InteractionType;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export class BrowserProtocolUtils {
|
|
22
|
+
/**
|
|
23
|
+
* Extracts the BrowserStateObject from the state string.
|
|
24
|
+
* @param browserCrypto
|
|
25
|
+
* @param state
|
|
26
|
+
*/
|
|
27
|
+
static extractBrowserRequestState(
|
|
28
|
+
browserCrypto: ICrypto,
|
|
29
|
+
state: string
|
|
30
|
+
): BrowserStateObject | null {
|
|
31
|
+
if (!state) {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
try {
|
|
36
|
+
const requestStateObj: RequestStateObject =
|
|
37
|
+
ProtocolUtils.parseRequestState(browserCrypto, state);
|
|
38
|
+
return requestStateObj.libraryState.meta as BrowserStateObject;
|
|
39
|
+
} catch (e) {
|
|
40
|
+
throw createClientAuthError(ClientAuthErrorCodes.invalidState);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Parses properties of server response from url hash
|
|
46
|
+
* @param locationHash Hash from url
|
|
47
|
+
*/
|
|
48
|
+
static parseServerResponseFromHash(
|
|
49
|
+
locationHash: string
|
|
50
|
+
): ServerAuthorizationCodeResponse {
|
|
51
|
+
if (!locationHash) {
|
|
52
|
+
return {};
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const hashUrlString = new UrlString(locationHash);
|
|
56
|
+
return UrlString.getDeserializedHash(hashUrlString.getHash());
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -0,0 +1,143 @@
|
|
|
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
|
+
/**
|
|
9
|
+
* Utility functions for strings in a browser. See here for implementation details:
|
|
10
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/WindowBase64/Base64_encoding_and_decoding#Solution_2_%E2%80%93_JavaScript's_UTF-16_%3E_UTF-8_%3E_base64
|
|
11
|
+
*/
|
|
12
|
+
export class BrowserStringUtils {
|
|
13
|
+
/**
|
|
14
|
+
* Converts string to Uint8Array
|
|
15
|
+
* @param sDOMStr
|
|
16
|
+
*/
|
|
17
|
+
static stringToUtf8Arr(sDOMStr: string): Uint8Array {
|
|
18
|
+
let nChr;
|
|
19
|
+
let nArrLen = 0;
|
|
20
|
+
const nStrLen = sDOMStr.length;
|
|
21
|
+
/* mapping... */
|
|
22
|
+
for (let nMapIdx = 0; nMapIdx < nStrLen; nMapIdx++) {
|
|
23
|
+
nChr = sDOMStr.charCodeAt(nMapIdx);
|
|
24
|
+
nArrLen +=
|
|
25
|
+
nChr < 0x80
|
|
26
|
+
? 1
|
|
27
|
+
: nChr < 0x800
|
|
28
|
+
? 2
|
|
29
|
+
: nChr < 0x10000
|
|
30
|
+
? 3
|
|
31
|
+
: nChr < 0x200000
|
|
32
|
+
? 4
|
|
33
|
+
: nChr < 0x4000000
|
|
34
|
+
? 5
|
|
35
|
+
: 6;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const aBytes = new Uint8Array(nArrLen);
|
|
39
|
+
|
|
40
|
+
/* transcription... */
|
|
41
|
+
|
|
42
|
+
for (let nIdx = 0, nChrIdx = 0; nIdx < nArrLen; nChrIdx++) {
|
|
43
|
+
nChr = sDOMStr.charCodeAt(nChrIdx);
|
|
44
|
+
if (nChr < 128) {
|
|
45
|
+
/* one byte */
|
|
46
|
+
aBytes[nIdx++] = nChr;
|
|
47
|
+
} else if (nChr < 0x800) {
|
|
48
|
+
/* two bytes */
|
|
49
|
+
aBytes[nIdx++] = 192 + (nChr >>> 6);
|
|
50
|
+
aBytes[nIdx++] = 128 + (nChr & 63);
|
|
51
|
+
} else if (nChr < 0x10000) {
|
|
52
|
+
/* three bytes */
|
|
53
|
+
aBytes[nIdx++] = 224 + (nChr >>> 12);
|
|
54
|
+
aBytes[nIdx++] = 128 + ((nChr >>> 6) & 63);
|
|
55
|
+
aBytes[nIdx++] = 128 + (nChr & 63);
|
|
56
|
+
} else if (nChr < 0x200000) {
|
|
57
|
+
/* four bytes */
|
|
58
|
+
aBytes[nIdx++] = 240 + (nChr >>> 18);
|
|
59
|
+
aBytes[nIdx++] = 128 + ((nChr >>> 12) & 63);
|
|
60
|
+
aBytes[nIdx++] = 128 + ((nChr >>> 6) & 63);
|
|
61
|
+
aBytes[nIdx++] = 128 + (nChr & 63);
|
|
62
|
+
} else if (nChr < 0x4000000) {
|
|
63
|
+
/* five bytes */
|
|
64
|
+
aBytes[nIdx++] = 248 + (nChr >>> 24);
|
|
65
|
+
aBytes[nIdx++] = 128 + ((nChr >>> 18) & 63);
|
|
66
|
+
aBytes[nIdx++] = 128 + ((nChr >>> 12) & 63);
|
|
67
|
+
aBytes[nIdx++] = 128 + ((nChr >>> 6) & 63);
|
|
68
|
+
aBytes[nIdx++] = 128 + (nChr & 63);
|
|
69
|
+
} /* if (nChr <= 0x7fffffff) */ else {
|
|
70
|
+
/* six bytes */
|
|
71
|
+
aBytes[nIdx++] = 252 + (nChr >>> 30);
|
|
72
|
+
aBytes[nIdx++] = 128 + ((nChr >>> 24) & 63);
|
|
73
|
+
aBytes[nIdx++] = 128 + ((nChr >>> 18) & 63);
|
|
74
|
+
aBytes[nIdx++] = 128 + ((nChr >>> 12) & 63);
|
|
75
|
+
aBytes[nIdx++] = 128 + ((nChr >>> 6) & 63);
|
|
76
|
+
aBytes[nIdx++] = 128 + (nChr & 63);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
return aBytes;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Converts Uint8Array to a string
|
|
85
|
+
* @param aBytes
|
|
86
|
+
*/
|
|
87
|
+
static utf8ArrToString(aBytes: Uint8Array): string {
|
|
88
|
+
let sView = Constants.EMPTY_STRING;
|
|
89
|
+
for (let nPart, nLen = aBytes.length, nIdx = 0; nIdx < nLen; nIdx++) {
|
|
90
|
+
nPart = aBytes[nIdx];
|
|
91
|
+
sView += String.fromCharCode(
|
|
92
|
+
nPart > 251 && nPart < 254 && nIdx + 5 < nLen /* six bytes */
|
|
93
|
+
? /* (nPart - 252 << 30) may be not so safe in ECMAScript! So...: */
|
|
94
|
+
(nPart - 252) * 1073741824 +
|
|
95
|
+
((aBytes[++nIdx] - 128) << 24) +
|
|
96
|
+
((aBytes[++nIdx] - 128) << 18) +
|
|
97
|
+
((aBytes[++nIdx] - 128) << 12) +
|
|
98
|
+
((aBytes[++nIdx] - 128) << 6) +
|
|
99
|
+
aBytes[++nIdx] -
|
|
100
|
+
128
|
|
101
|
+
: nPart > 247 &&
|
|
102
|
+
nPart < 252 &&
|
|
103
|
+
nIdx + 4 < nLen /* five bytes */
|
|
104
|
+
? ((nPart - 248) << 24) +
|
|
105
|
+
((aBytes[++nIdx] - 128) << 18) +
|
|
106
|
+
((aBytes[++nIdx] - 128) << 12) +
|
|
107
|
+
((aBytes[++nIdx] - 128) << 6) +
|
|
108
|
+
aBytes[++nIdx] -
|
|
109
|
+
128
|
|
110
|
+
: nPart > 239 &&
|
|
111
|
+
nPart < 248 &&
|
|
112
|
+
nIdx + 3 < nLen /* four bytes */
|
|
113
|
+
? ((nPart - 240) << 18) +
|
|
114
|
+
((aBytes[++nIdx] - 128) << 12) +
|
|
115
|
+
((aBytes[++nIdx] - 128) << 6) +
|
|
116
|
+
aBytes[++nIdx] -
|
|
117
|
+
128
|
|
118
|
+
: nPart > 223 &&
|
|
119
|
+
nPart < 240 &&
|
|
120
|
+
nIdx + 2 < nLen /* three bytes */
|
|
121
|
+
? ((nPart - 224) << 12) +
|
|
122
|
+
((aBytes[++nIdx] - 128) << 6) +
|
|
123
|
+
aBytes[++nIdx] -
|
|
124
|
+
128
|
|
125
|
+
: nPart > 191 &&
|
|
126
|
+
nPart < 224 &&
|
|
127
|
+
nIdx + 1 < nLen /* two bytes */
|
|
128
|
+
? ((nPart - 192) << 6) + aBytes[++nIdx] - 128
|
|
129
|
+
: /* nPart < 127 ? */ /* one byte */
|
|
130
|
+
nPart
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
return sView;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Returns stringified jwk.
|
|
138
|
+
* @param jwk
|
|
139
|
+
*/
|
|
140
|
+
static getSortedObjectString(obj: object): string {
|
|
141
|
+
return JSON.stringify(obj, Object.keys(obj).sort());
|
|
142
|
+
}
|
|
143
|
+
}
|