@azure/msal-browser 3.2.0 → 3.4.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.mjs +1 -1
- package/dist/app/PublicClientApplication.d.ts.map +1 -1
- package/dist/app/PublicClientApplication.mjs +3 -4
- package/dist/app/PublicClientApplication.mjs.map +1 -1
- package/dist/app/PublicClientNext.d.ts +274 -0
- package/dist/app/PublicClientNext.d.ts.map +1 -0
- package/dist/app/PublicClientNext.mjs +360 -0
- package/dist/app/PublicClientNext.mjs.map +1 -0
- package/dist/broker/nativeBroker/NativeMessageHandler.mjs +1 -1
- package/dist/broker/nativeBroker/NativeStatusCodes.mjs +1 -1
- package/dist/cache/AsyncMemoryStorage.mjs +1 -1
- package/dist/cache/BrowserCacheManager.d.ts +2 -13
- package/dist/cache/BrowserCacheManager.d.ts.map +1 -1
- package/dist/cache/BrowserCacheManager.mjs +26 -83
- package/dist/cache/BrowserCacheManager.mjs.map +1 -1
- package/dist/cache/BrowserStorage.mjs +1 -1
- package/dist/cache/CryptoKeyStore.mjs +1 -1
- package/dist/cache/DatabaseStorage.mjs +1 -1
- package/dist/cache/MemoryStorage.mjs +1 -1
- package/dist/cache/TokenCache.d.ts.map +1 -1
- package/dist/cache/TokenCache.mjs +5 -5
- package/dist/cache/TokenCache.mjs.map +1 -1
- package/dist/config/Configuration.d.ts +4 -0
- package/dist/config/Configuration.d.ts.map +1 -1
- package/dist/config/Configuration.mjs +2 -1
- package/dist/config/Configuration.mjs.map +1 -1
- package/dist/controllers/ControllerFactory.d.ts +2 -7
- package/dist/controllers/ControllerFactory.d.ts.map +1 -1
- package/dist/controllers/ControllerFactory.mjs +24 -34
- package/dist/controllers/ControllerFactory.mjs.map +1 -1
- package/dist/controllers/IController.d.ts +1 -2
- package/dist/controllers/IController.d.ts.map +1 -1
- package/dist/controllers/NestedAppAuthController.d.ts +96 -0
- package/dist/controllers/NestedAppAuthController.d.ts.map +1 -0
- package/dist/controllers/NestedAppAuthController.mjs +345 -0
- package/dist/controllers/NestedAppAuthController.mjs.map +1 -0
- package/dist/controllers/StandardController.d.ts +4 -4
- package/dist/controllers/StandardController.d.ts.map +1 -1
- package/dist/controllers/StandardController.mjs +43 -42
- package/dist/controllers/StandardController.mjs.map +1 -1
- package/dist/controllers/UnknownOperatingContextController.d.ts +88 -0
- package/dist/controllers/UnknownOperatingContextController.d.ts.map +1 -0
- package/dist/controllers/UnknownOperatingContextController.mjs +275 -0
- package/dist/controllers/UnknownOperatingContextController.mjs.map +1 -0
- package/dist/crypto/BrowserCrypto.d.ts.map +1 -1
- package/dist/crypto/BrowserCrypto.mjs +3 -3
- package/dist/crypto/BrowserCrypto.mjs.map +1 -1
- package/dist/crypto/CryptoOps.d.ts.map +1 -1
- package/dist/crypto/CryptoOps.mjs +8 -5
- package/dist/crypto/CryptoOps.mjs.map +1 -1
- package/dist/crypto/PkceGenerator.mjs +1 -1
- package/dist/crypto/SignedHttpRequest.mjs +1 -1
- package/dist/encode/Base64Decode.mjs +1 -1
- package/dist/encode/Base64Encode.mjs +1 -1
- package/dist/error/BrowserAuthError.mjs +1 -1
- package/dist/error/BrowserAuthErrorCodes.mjs +1 -1
- package/dist/error/BrowserConfigurationAuthError.mjs +1 -1
- package/dist/error/BrowserConfigurationAuthErrorCodes.mjs +1 -1
- package/dist/error/NativeAuthError.mjs +1 -1
- package/dist/error/NativeAuthErrorCodes.mjs +1 -1
- package/dist/error/NestedAppAuthError.d.ts +15 -0
- package/dist/error/NestedAppAuthError.d.ts.map +1 -0
- package/dist/error/NestedAppAuthError.mjs +30 -0
- package/dist/error/NestedAppAuthError.mjs.map +1 -0
- package/dist/event/EventHandler.mjs +1 -1
- package/dist/event/EventMessage.mjs +1 -1
- package/dist/event/EventType.mjs +1 -1
- package/dist/index.d.ts +3 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +4 -2
- package/dist/index.mjs.map +1 -1
- package/dist/interaction_client/BaseInteractionClient.mjs +4 -4
- package/dist/interaction_client/HybridSpaAuthorizationCodeClient.mjs +1 -1
- package/dist/interaction_client/NativeInteractionClient.d.ts.map +1 -1
- package/dist/interaction_client/NativeInteractionClient.mjs +18 -7
- package/dist/interaction_client/NativeInteractionClient.mjs.map +1 -1
- package/dist/interaction_client/PopupClient.d.ts +1 -2
- package/dist/interaction_client/PopupClient.d.ts.map +1 -1
- package/dist/interaction_client/PopupClient.mjs +13 -25
- 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 +17 -25
- 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 +6 -8
- package/dist/interaction_client/SilentAuthCodeClient.mjs.map +1 -1
- package/dist/interaction_client/SilentCacheClient.d.ts.map +1 -1
- package/dist/interaction_client/SilentCacheClient.mjs +4 -3
- 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 +28 -19
- 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 +2 -12
- package/dist/interaction_client/SilentRefreshClient.mjs.map +1 -1
- package/dist/interaction_client/StandardInteractionClient.mjs +5 -5
- package/dist/interaction_handler/InteractionHandler.d.ts +6 -13
- package/dist/interaction_handler/InteractionHandler.d.ts.map +1 -1
- package/dist/interaction_handler/InteractionHandler.mjs +29 -56
- package/dist/interaction_handler/InteractionHandler.mjs.map +1 -1
- package/dist/interaction_handler/RedirectHandler.d.ts +14 -7
- package/dist/interaction_handler/RedirectHandler.d.ts.map +1 -1
- package/dist/interaction_handler/RedirectHandler.mjs +28 -9
- package/dist/interaction_handler/RedirectHandler.mjs.map +1 -1
- package/dist/interaction_handler/SilentHandler.d.ts +13 -47
- package/dist/interaction_handler/SilentHandler.d.ts.map +1 -1
- package/dist/interaction_handler/SilentHandler.mjs +120 -155
- package/dist/interaction_handler/SilentHandler.mjs.map +1 -1
- package/dist/naa/AccountInfo.d.ts +13 -0
- package/dist/naa/AccountInfo.d.ts.map +1 -0
- package/dist/naa/AccountRequests.d.ts +10 -0
- package/dist/naa/AccountRequests.d.ts.map +1 -0
- package/dist/naa/AuthBridge.d.ts +6 -0
- package/dist/naa/AuthBridge.d.ts.map +1 -0
- package/dist/naa/BridgeCapabilities.d.ts +4 -0
- package/dist/naa/BridgeCapabilities.d.ts.map +1 -0
- package/dist/naa/BridgeError.d.ts +10 -0
- package/dist/naa/BridgeError.d.ts.map +1 -0
- package/dist/naa/BridgeError.mjs +12 -0
- package/dist/naa/BridgeError.mjs.map +1 -0
- package/dist/naa/BridgeProxy.d.ts +72 -0
- package/dist/naa/BridgeProxy.d.ts.map +1 -0
- package/dist/naa/BridgeProxy.mjs +154 -0
- package/dist/naa/BridgeProxy.mjs.map +1 -0
- package/dist/naa/BridgeRequest.d.ts +7 -0
- package/dist/naa/BridgeRequest.d.ts.map +1 -0
- package/dist/naa/BridgeRequestEnvelope.d.ts +14 -0
- package/dist/naa/BridgeRequestEnvelope.d.ts.map +1 -0
- package/dist/naa/BridgeResponseEnvelope.d.ts +11 -0
- package/dist/naa/BridgeResponseEnvelope.d.ts.map +1 -0
- package/dist/naa/BridgeStatusCode.d.ts +11 -0
- package/dist/naa/BridgeStatusCode.d.ts.map +1 -0
- package/dist/naa/BridgeStatusCode.mjs +20 -0
- package/dist/naa/BridgeStatusCode.mjs.map +1 -0
- package/dist/naa/IBridgeProxy.d.ts +11 -0
- package/dist/naa/IBridgeProxy.d.ts.map +1 -0
- package/dist/naa/InitializeBridgeResponse.d.ts +7 -0
- package/dist/naa/InitializeBridgeResponse.d.ts.map +1 -0
- package/dist/naa/TokenRequest.d.ts +22 -0
- package/dist/naa/TokenRequest.d.ts.map +1 -0
- package/dist/naa/TokenResponse.d.ts +17 -0
- package/dist/naa/TokenResponse.d.ts.map +1 -0
- package/dist/naa/mapping/NestedAppAuthAdapter.d.ts +26 -0
- package/dist/naa/mapping/NestedAppAuthAdapter.d.ts.map +1 -0
- package/dist/naa/mapping/NestedAppAuthAdapter.mjs +178 -0
- package/dist/naa/mapping/NestedAppAuthAdapter.mjs.map +1 -0
- package/dist/navigation/NavigationClient.mjs +1 -1
- package/dist/network/FetchClient.mjs +1 -1
- package/dist/operatingcontext/BaseOperatingContext.mjs +1 -1
- package/dist/operatingcontext/StandardOperatingContext.mjs +1 -1
- package/dist/operatingcontext/TeamsAppOperatingContext.d.ts +7 -0
- package/dist/operatingcontext/TeamsAppOperatingContext.d.ts.map +1 -1
- package/dist/operatingcontext/TeamsAppOperatingContext.mjs +45 -4
- package/dist/operatingcontext/TeamsAppOperatingContext.mjs.map +1 -1
- package/dist/operatingcontext/UnknownOperatingContext.d.ts +26 -0
- package/dist/operatingcontext/UnknownOperatingContext.d.ts.map +1 -0
- package/dist/operatingcontext/UnknownOperatingContext.mjs +49 -0
- package/dist/operatingcontext/UnknownOperatingContext.mjs.map +1 -0
- package/dist/packageMetadata.d.ts +1 -1
- package/dist/packageMetadata.mjs +2 -2
- package/dist/telemetry/BrowserPerformanceClient.mjs +1 -1
- package/dist/telemetry/BrowserPerformanceMeasurement.mjs +1 -1
- package/dist/utils/BrowserConstants.mjs +1 -1
- package/dist/utils/BrowserProtocolUtils.mjs +1 -1
- package/dist/utils/BrowserUtils.d.ts +54 -53
- package/dist/utils/BrowserUtils.d.ts.map +1 -1
- package/dist/utils/BrowserUtils.mjs +114 -102
- package/dist/utils/BrowserUtils.mjs.map +1 -1
- package/lib/msal-browser.cjs +13221 -12385
- package/lib/msal-browser.cjs.map +1 -1
- package/lib/msal-browser.js +13221 -12385
- package/lib/msal-browser.js.map +1 -1
- package/lib/msal-browser.min.js +67 -68
- package/package.json +2 -2
- package/src/app/PublicClientApplication.ts +4 -3
- package/src/app/PublicClientNext.ts +444 -0
- package/src/cache/BrowserCacheManager.ts +33 -140
- package/src/cache/TokenCache.ts +5 -4
- package/src/config/Configuration.ts +5 -0
- package/src/controllers/ControllerFactory.ts +35 -43
- package/src/controllers/IController.ts +0 -6
- package/src/controllers/NestedAppAuthController.ts +525 -0
- package/src/controllers/StandardController.ts +50 -52
- package/src/controllers/UnknownOperatingContextController.ts +383 -0
- package/src/crypto/BrowserCrypto.ts +2 -2
- package/src/crypto/CryptoOps.ts +8 -5
- package/src/error/NestedAppAuthError.ts +32 -0
- package/src/index.ts +3 -10
- package/src/interaction_client/BaseInteractionClient.ts +1 -1
- package/src/interaction_client/NativeInteractionClient.ts +23 -6
- package/src/interaction_client/PopupClient.ts +41 -61
- package/src/interaction_client/RedirectClient.ts +42 -47
- package/src/interaction_client/SilentAuthCodeClient.ts +6 -16
- package/src/interaction_client/SilentCacheClient.ts +11 -3
- package/src/interaction_client/SilentIframeClient.ts +54 -34
- package/src/interaction_client/SilentRefreshClient.ts +5 -19
- package/src/interaction_client/StandardInteractionClient.ts +1 -1
- package/src/interaction_handler/InteractionHandler.ts +34 -104
- package/src/interaction_handler/RedirectHandler.ts +48 -22
- package/src/interaction_handler/SilentHandler.ts +177 -233
- package/src/naa/AccountInfo.ts +17 -0
- package/src/naa/AccountRequests.ts +16 -0
- package/src/naa/AuthBridge.ts +16 -0
- package/src/naa/BridgeCapabilities.ts +8 -0
- package/src/naa/BridgeError.ts +18 -0
- package/src/naa/BridgeProxy.ts +230 -0
- package/src/naa/BridgeRequest.ts +12 -0
- package/src/naa/BridgeRequestEnvelope.ts +46 -0
- package/src/naa/BridgeResponseEnvelope.ts +21 -0
- package/src/naa/BridgeStatusCode.ts +15 -0
- package/src/naa/IBridgeProxy.ts +25 -0
- package/src/naa/InitializeBridgeResponse.ts +12 -0
- package/src/naa/TokenRequest.ts +26 -0
- package/src/naa/TokenResponse.ts +61 -0
- package/src/naa/mapping/NestedAppAuthAdapter.ts +252 -0
- package/src/operatingcontext/TeamsAppOperatingContext.ts +43 -3
- package/src/operatingcontext/UnknownOperatingContext.ts +48 -0
- package/src/packageMetadata.ts +1 -1
- package/src/utils/BrowserUtils.ts +133 -125
- package/dist/utils/BrowserStringUtils.d.ts +0 -22
- package/dist/utils/BrowserStringUtils.d.ts.map +0 -1
- package/dist/utils/BrowserStringUtils.mjs +0 -144
- package/dist/utils/BrowserStringUtils.mjs.map +0 -1
- package/src/utils/BrowserStringUtils.ts +0 -143
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Utility functions for strings in a browser. See here for implementation details:
|
|
3
|
-
* 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
|
|
4
|
-
*/
|
|
5
|
-
export declare class BrowserStringUtils {
|
|
6
|
-
/**
|
|
7
|
-
* Converts string to Uint8Array
|
|
8
|
-
* @param sDOMStr
|
|
9
|
-
*/
|
|
10
|
-
static stringToUtf8Arr(sDOMStr: string): Uint8Array;
|
|
11
|
-
/**
|
|
12
|
-
* Converts Uint8Array to a string
|
|
13
|
-
* @param aBytes
|
|
14
|
-
*/
|
|
15
|
-
static utf8ArrToString(aBytes: Uint8Array): string;
|
|
16
|
-
/**
|
|
17
|
-
* Returns stringified jwk.
|
|
18
|
-
* @param jwk
|
|
19
|
-
*/
|
|
20
|
-
static getSortedObjectString(obj: object): string;
|
|
21
|
-
}
|
|
22
|
-
//# sourceMappingURL=BrowserStringUtils.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"BrowserStringUtils.d.ts","sourceRoot":"","sources":["../../src/utils/BrowserStringUtils.ts"],"names":[],"mappings":"AAOA;;;GAGG;AACH,qBAAa,kBAAkB;IAC3B;;;OAGG;IACH,MAAM,CAAC,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,UAAU;IAkEnD;;;OAGG;IACH,MAAM,CAAC,eAAe,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM;IAiDlD;;;OAGG;IACH,MAAM,CAAC,qBAAqB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;CAGpD"}
|
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
/*! @azure/msal-browser v3.2.0 2023-10-05 */
|
|
2
|
-
'use strict';
|
|
3
|
-
import { Constants } from '@azure/msal-common';
|
|
4
|
-
|
|
5
|
-
/*
|
|
6
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
7
|
-
* Licensed under the MIT License.
|
|
8
|
-
*/
|
|
9
|
-
/**
|
|
10
|
-
* Utility functions for strings in a browser. See here for implementation details:
|
|
11
|
-
* 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
|
|
12
|
-
*/
|
|
13
|
-
class BrowserStringUtils {
|
|
14
|
-
/**
|
|
15
|
-
* Converts string to Uint8Array
|
|
16
|
-
* @param sDOMStr
|
|
17
|
-
*/
|
|
18
|
-
static stringToUtf8Arr(sDOMStr) {
|
|
19
|
-
let nChr;
|
|
20
|
-
let nArrLen = 0;
|
|
21
|
-
const nStrLen = sDOMStr.length;
|
|
22
|
-
/* mapping... */
|
|
23
|
-
for (let nMapIdx = 0; nMapIdx < nStrLen; nMapIdx++) {
|
|
24
|
-
nChr = sDOMStr.charCodeAt(nMapIdx);
|
|
25
|
-
nArrLen +=
|
|
26
|
-
nChr < 0x80
|
|
27
|
-
? 1
|
|
28
|
-
: nChr < 0x800
|
|
29
|
-
? 2
|
|
30
|
-
: nChr < 0x10000
|
|
31
|
-
? 3
|
|
32
|
-
: nChr < 0x200000
|
|
33
|
-
? 4
|
|
34
|
-
: nChr < 0x4000000
|
|
35
|
-
? 5
|
|
36
|
-
: 6;
|
|
37
|
-
}
|
|
38
|
-
const aBytes = new Uint8Array(nArrLen);
|
|
39
|
-
/* transcription... */
|
|
40
|
-
for (let nIdx = 0, nChrIdx = 0; nIdx < nArrLen; nChrIdx++) {
|
|
41
|
-
nChr = sDOMStr.charCodeAt(nChrIdx);
|
|
42
|
-
if (nChr < 128) {
|
|
43
|
-
/* one byte */
|
|
44
|
-
aBytes[nIdx++] = nChr;
|
|
45
|
-
}
|
|
46
|
-
else if (nChr < 0x800) {
|
|
47
|
-
/* two bytes */
|
|
48
|
-
aBytes[nIdx++] = 192 + (nChr >>> 6);
|
|
49
|
-
aBytes[nIdx++] = 128 + (nChr & 63);
|
|
50
|
-
}
|
|
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
|
-
}
|
|
57
|
-
else if (nChr < 0x200000) {
|
|
58
|
-
/* four bytes */
|
|
59
|
-
aBytes[nIdx++] = 240 + (nChr >>> 18);
|
|
60
|
-
aBytes[nIdx++] = 128 + ((nChr >>> 12) & 63);
|
|
61
|
-
aBytes[nIdx++] = 128 + ((nChr >>> 6) & 63);
|
|
62
|
-
aBytes[nIdx++] = 128 + (nChr & 63);
|
|
63
|
-
}
|
|
64
|
-
else if (nChr < 0x4000000) {
|
|
65
|
-
/* five bytes */
|
|
66
|
-
aBytes[nIdx++] = 248 + (nChr >>> 24);
|
|
67
|
-
aBytes[nIdx++] = 128 + ((nChr >>> 18) & 63);
|
|
68
|
-
aBytes[nIdx++] = 128 + ((nChr >>> 12) & 63);
|
|
69
|
-
aBytes[nIdx++] = 128 + ((nChr >>> 6) & 63);
|
|
70
|
-
aBytes[nIdx++] = 128 + (nChr & 63);
|
|
71
|
-
} /* if (nChr <= 0x7fffffff) */
|
|
72
|
-
else {
|
|
73
|
-
/* six bytes */
|
|
74
|
-
aBytes[nIdx++] = 252 + (nChr >>> 30);
|
|
75
|
-
aBytes[nIdx++] = 128 + ((nChr >>> 24) & 63);
|
|
76
|
-
aBytes[nIdx++] = 128 + ((nChr >>> 18) & 63);
|
|
77
|
-
aBytes[nIdx++] = 128 + ((nChr >>> 12) & 63);
|
|
78
|
-
aBytes[nIdx++] = 128 + ((nChr >>> 6) & 63);
|
|
79
|
-
aBytes[nIdx++] = 128 + (nChr & 63);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
return aBytes;
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* Converts Uint8Array to a string
|
|
86
|
-
* @param aBytes
|
|
87
|
-
*/
|
|
88
|
-
static utf8ArrToString(aBytes) {
|
|
89
|
-
let sView = Constants.EMPTY_STRING;
|
|
90
|
-
for (let nPart, nLen = aBytes.length, nIdx = 0; nIdx < nLen; nIdx++) {
|
|
91
|
-
nPart = aBytes[nIdx];
|
|
92
|
-
sView += String.fromCharCode(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
|
-
return sView;
|
|
133
|
-
}
|
|
134
|
-
/**
|
|
135
|
-
* Returns stringified jwk.
|
|
136
|
-
* @param jwk
|
|
137
|
-
*/
|
|
138
|
-
static getSortedObjectString(obj) {
|
|
139
|
-
return JSON.stringify(obj, Object.keys(obj).sort());
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
export { BrowserStringUtils };
|
|
144
|
-
//# sourceMappingURL=BrowserStringUtils.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"BrowserStringUtils.mjs","sources":["../../src/utils/BrowserStringUtils.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;AAOA;;;AAGG;AAEC;;;AAGG;AACH,MAAsB;AAkEtB;;;AAGG;AACH,IAAA,OAAO,eAAe,CAAC,OAAQ,EAAA;AAiD/B,QAAA,IAAA,IAAA,CAAA;;;AAGG;AACH,QAAA,KAA4B,IAAA,OAAA,GAAA,CAAA,EAAA,OAAM,GAAA,OAAS,EAAM,OAAA,EAAA,EAAA;AAGpD,YAAA,IAAA,GAAA,OAAA,CAAA,UAAA,CAAA,OAAA,CAAA,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,143 +0,0 @@
|
|
|
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
|
-
}
|