@azure/msal-browser 3.0.1 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -5
- package/dist/app/IPublicClientApplication.d.ts +6 -2
- package/dist/app/IPublicClientApplication.d.ts.map +1 -1
- package/dist/app/IPublicClientApplication.mjs +4 -1
- package/dist/app/IPublicClientApplication.mjs.map +1 -1
- package/dist/app/PublicClientApplication.d.ts +11 -3
- package/dist/app/PublicClientApplication.d.ts.map +1 -1
- package/dist/app/PublicClientApplication.mjs +10 -2
- package/dist/app/PublicClientApplication.mjs.map +1 -1
- package/dist/broker/nativeBroker/NativeMessageHandler.d.ts.map +1 -1
- package/dist/broker/nativeBroker/NativeMessageHandler.mjs +5 -4
- package/dist/broker/nativeBroker/NativeMessageHandler.mjs.map +1 -1
- package/dist/cache/AsyncMemoryStorage.mjs +4 -3
- package/dist/cache/AsyncMemoryStorage.mjs.map +1 -1
- package/dist/cache/BrowserCacheManager.d.ts +13 -3
- package/dist/cache/BrowserCacheManager.d.ts.map +1 -1
- package/dist/cache/BrowserCacheManager.mjs +54 -26
- package/dist/cache/BrowserCacheManager.mjs.map +1 -1
- package/dist/cache/BrowserStorage.mjs +1 -1
- 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 +3 -0
- package/dist/config/Configuration.d.ts.map +1 -1
- package/dist/config/Configuration.mjs +7 -11
- 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 +11 -18
- package/dist/controllers/IController.d.ts.map +1 -1
- package/dist/controllers/StandardController.d.ts +7 -26
- package/dist/controllers/StandardController.d.ts.map +1 -1
- package/dist/controllers/StandardController.mjs +28 -52
- package/dist/controllers/StandardController.mjs.map +1 -1
- package/dist/crypto/BrowserCrypto.d.ts.map +1 -1
- package/dist/crypto/BrowserCrypto.mjs +4 -3
- package/dist/crypto/BrowserCrypto.mjs.map +1 -1
- package/dist/crypto/CryptoOps.d.ts +0 -3
- package/dist/crypto/CryptoOps.d.ts.map +1 -1
- package/dist/crypto/CryptoOps.mjs +14 -17
- package/dist/crypto/CryptoOps.mjs.map +1 -1
- package/dist/crypto/ModernBrowserCrypto.mjs +1 -1
- package/dist/crypto/ModernBrowserCrypto.mjs.map +1 -1
- package/dist/crypto/PkceGenerator.d.ts +0 -1
- package/dist/crypto/PkceGenerator.d.ts.map +1 -1
- package/dist/crypto/PkceGenerator.mjs +8 -8
- 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 +17 -70
- 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 +54 -195
- package/dist/error/BrowserAuthError.d.ts.map +1 -1
- package/dist/error/BrowserAuthError.mjs +150 -381
- package/dist/error/BrowserAuthError.mjs.map +1 -1
- package/dist/error/BrowserAuthErrorCodes.d.ts +45 -0
- package/dist/error/BrowserAuthErrorCodes.d.ts.map +1 -0
- package/dist/error/BrowserAuthErrorCodes.mjs +53 -0
- package/dist/error/BrowserAuthErrorCodes.mjs.map +1 -0
- package/dist/error/BrowserConfigurationAuthError.mjs +1 -1
- package/dist/error/BrowserConfigurationAuthError.mjs.map +1 -1
- package/dist/error/NativeAuthError.d.ts.map +1 -1
- package/dist/error/NativeAuthError.mjs +5 -4
- package/dist/error/NativeAuthError.mjs.map +1 -1
- package/dist/event/EventHandler.mjs +1 -1
- 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 +9 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +5 -3
- 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 +1 -1
- 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 +22 -30
- 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 +5 -4
- 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 +10 -8
- 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 +4 -3
- 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 +8 -7
- 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 +9 -9
- 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 +11 -10
- 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 +10 -9
- 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 +3 -3
- 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 +6601 -7104
- package/lib/msal-browser.cjs.map +1 -1
- package/lib/msal-browser.js +6601 -7104
- package/lib/msal-browser.js.map +1 -1
- package/lib/msal-browser.min.js +65 -62
- package/package.json +7 -5
- package/src/app/IPublicClientApplication.ts +199 -0
- package/src/app/PublicClientApplication.ts +405 -0
- package/src/broker/nativeBroker/NativeMessageHandler.ts +419 -0
- package/src/broker/nativeBroker/NativeRequest.ts +52 -0
- package/src/broker/nativeBroker/NativeResponse.ts +56 -0
- package/src/cache/AsyncMemoryStorage.ts +158 -0
- package/src/cache/BrowserCacheManager.ts +1994 -0
- package/src/cache/BrowserStorage.ts +54 -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 +375 -0
- package/src/controllers/ControllerFactory.ts +55 -0
- package/src/controllers/IController.ts +131 -0
- package/src/controllers/StandardController.ts +2107 -0
- package/src/crypto/BrowserCrypto.ts +135 -0
- package/src/crypto/CryptoOps.ts +247 -0
- package/src/crypto/ISubtleCrypto.ts +30 -0
- package/src/crypto/ModernBrowserCrypto.ts +69 -0
- package/src/crypto/PkceGenerator.ts +76 -0
- package/src/crypto/SignedHttpRequest.ts +76 -0
- package/src/encode/Base64Decode.ts +26 -0
- package/src/encode/Base64Encode.ts +52 -0
- package/src/error/BrowserAuthError.ts +340 -0
- package/src/error/BrowserAuthErrorCodes.ts +56 -0
- package/src/error/BrowserConfigurationAuthError.ts +133 -0
- package/src/error/NativeAuthError.ts +141 -0
- package/src/event/EventHandler.ts +176 -0
- package/src/event/EventMessage.ts +125 -0
- package/src/event/EventType.ts +33 -0
- package/src/index.ts +152 -0
- package/src/interaction_client/BaseInteractionClient.ts +301 -0
- package/src/interaction_client/HybridSpaAuthorizationCodeClient.ts +16 -0
- package/src/interaction_client/NativeInteractionClient.ts +907 -0
- package/src/interaction_client/PopupClient.ts +926 -0
- package/src/interaction_client/RedirectClient.ts +616 -0
- package/src/interaction_client/SilentAuthCodeClient.ts +163 -0
- package/src/interaction_client/SilentCacheClient.ts +133 -0
- package/src/interaction_client/SilentIframeClient.ts +301 -0
- package/src/interaction_client/SilentRefreshClient.ts +120 -0
- package/src/interaction_client/StandardInteractionClient.ts +481 -0
- package/src/interaction_handler/InteractionHandler.ts +246 -0
- package/src/interaction_handler/RedirectHandler.ts +225 -0
- package/src/interaction_handler/SilentHandler.ts +266 -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 +57 -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/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
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
/*! @azure/msal-browser v3.0
|
|
1
|
+
/*! @azure/msal-browser v3.1.0 2023-09-05 */
|
|
2
2
|
'use strict';
|
|
3
3
|
import { PerformanceEvents, JoseHeader } from '@azure/msal-common';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { Base64Decode } from '../encode/Base64Decode.mjs';
|
|
4
|
+
import { base64Encode, urlEncode, urlEncodeArr } from '../encode/Base64Encode.mjs';
|
|
5
|
+
import { base64Decode } from '../encode/Base64Decode.mjs';
|
|
7
6
|
import { PkceGenerator } from './PkceGenerator.mjs';
|
|
8
7
|
import { BrowserCrypto } from './BrowserCrypto.mjs';
|
|
9
8
|
import { BrowserStringUtils } from '../utils/BrowserStringUtils.mjs';
|
|
10
|
-
import {
|
|
9
|
+
import { createBrowserAuthError } from '../error/BrowserAuthError.mjs';
|
|
11
10
|
import { CryptoKeyStore } from '../cache/CryptoKeyStore.mjs';
|
|
11
|
+
import { cryptoKeyNotFound } from '../error/BrowserAuthErrorCodes.mjs';
|
|
12
12
|
|
|
13
13
|
/*
|
|
14
14
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -23,9 +23,6 @@ class CryptoOps {
|
|
|
23
23
|
this.logger = logger;
|
|
24
24
|
// Browser crypto needs to be validated first before any other classes can be set.
|
|
25
25
|
this.browserCrypto = new BrowserCrypto(this.logger);
|
|
26
|
-
this.b64Encode = new Base64Encode();
|
|
27
|
-
this.b64Decode = new Base64Decode();
|
|
28
|
-
this.guidGenerator = new GuidGenerator(this.browserCrypto);
|
|
29
26
|
this.pkceGenerator = new PkceGenerator(this.browserCrypto);
|
|
30
27
|
this.cache = new CryptoKeyStore(this.logger);
|
|
31
28
|
this.performanceClient = performanceClient;
|
|
@@ -35,21 +32,21 @@ class CryptoOps {
|
|
|
35
32
|
* @returns string (GUID)
|
|
36
33
|
*/
|
|
37
34
|
createNewGuid() {
|
|
38
|
-
return
|
|
35
|
+
return window.crypto.randomUUID();
|
|
39
36
|
}
|
|
40
37
|
/**
|
|
41
38
|
* Encodes input string to base64.
|
|
42
39
|
* @param input
|
|
43
40
|
*/
|
|
44
41
|
base64Encode(input) {
|
|
45
|
-
return
|
|
42
|
+
return base64Encode(input);
|
|
46
43
|
}
|
|
47
44
|
/**
|
|
48
45
|
* Decodes input string from base64.
|
|
49
46
|
* @param input
|
|
50
47
|
*/
|
|
51
48
|
base64Decode(input) {
|
|
52
|
-
return
|
|
49
|
+
return base64Decode(input);
|
|
53
50
|
}
|
|
54
51
|
/**
|
|
55
52
|
* Generates PKCE codes used in Authorization Code Flow.
|
|
@@ -116,30 +113,30 @@ class CryptoOps {
|
|
|
116
113
|
const signJwtMeasurement = this.performanceClient?.startMeasurement(PerformanceEvents.CryptoOptsSignJwt, correlationId);
|
|
117
114
|
const cachedKeyPair = await this.cache.asymmetricKeys.getItem(kid);
|
|
118
115
|
if (!cachedKeyPair) {
|
|
119
|
-
throw
|
|
116
|
+
throw createBrowserAuthError(cryptoKeyNotFound);
|
|
120
117
|
}
|
|
121
118
|
// Get public key as JWK
|
|
122
119
|
const publicKeyJwk = await this.browserCrypto.exportJwk(cachedKeyPair.publicKey);
|
|
123
120
|
const publicKeyJwkString = BrowserStringUtils.getSortedObjectString(publicKeyJwk);
|
|
124
121
|
// Base64URL encode public key thumbprint with keyId only: BASE64URL({ kid: "FULL_PUBLIC_KEY_HASH" })
|
|
125
|
-
const encodedKeyIdThumbprint =
|
|
122
|
+
const encodedKeyIdThumbprint = urlEncode(JSON.stringify({ kid: kid }));
|
|
126
123
|
// Generate header
|
|
127
124
|
const shrHeader = JoseHeader.getShrHeaderString({
|
|
128
125
|
kid: encodedKeyIdThumbprint,
|
|
129
126
|
alg: publicKeyJwk.alg,
|
|
130
127
|
});
|
|
131
|
-
const encodedShrHeader =
|
|
128
|
+
const encodedShrHeader = urlEncode(shrHeader);
|
|
132
129
|
// Generate payload
|
|
133
130
|
payload.cnf = {
|
|
134
131
|
jwk: JSON.parse(publicKeyJwkString),
|
|
135
132
|
};
|
|
136
|
-
const encodedPayload =
|
|
133
|
+
const encodedPayload = urlEncode(JSON.stringify(payload));
|
|
137
134
|
// Form token string
|
|
138
135
|
const tokenString = `${encodedShrHeader}.${encodedPayload}`;
|
|
139
136
|
// Sign token
|
|
140
137
|
const tokenBuffer = BrowserStringUtils.stringToUtf8Arr(tokenString);
|
|
141
138
|
const signatureBuffer = await this.browserCrypto.sign(cachedKeyPair.privateKey, tokenBuffer);
|
|
142
|
-
const encodedSignature =
|
|
139
|
+
const encodedSignature = urlEncodeArr(new Uint8Array(signatureBuffer));
|
|
143
140
|
const signedJwt = `${tokenString}.${encodedSignature}`;
|
|
144
141
|
if (signJwtMeasurement) {
|
|
145
142
|
signJwtMeasurement.end({
|
|
@@ -155,7 +152,7 @@ class CryptoOps {
|
|
|
155
152
|
async hashString(plainText) {
|
|
156
153
|
const hashBuffer = await this.browserCrypto.sha256Digest(plainText);
|
|
157
154
|
const hashBytes = new Uint8Array(hashBuffer);
|
|
158
|
-
return
|
|
155
|
+
return urlEncodeArr(hashBytes);
|
|
159
156
|
}
|
|
160
157
|
}
|
|
161
158
|
CryptoOps.POP_KEY_USAGES = ["sign", "verify"];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CryptoOps.mjs","sources":["../../src/crypto/CryptoOps.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"CryptoOps.mjs","sources":["../../src/crypto/CryptoOps.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;;;;;;AAKA;AAqBA;;;;;;AAgBI;;;AAGG,QAAA,IAAA,CAAA,MAAA,GAAA,MAAA,CAAA;;AAGH,QAAA,IAAQ,CAAA,aAAO,GAAA,IAAc,aAAuC,CAAA,IAAA,CAAA,MAAA,CAAA,CAAA;AACpE,QAAA,IAAQ,CAAA,aAAO,GAAA,IAA4B,aAAA,CAAA,IAAA,CAAA,aAAA,CAAA,CAAA;QACpC,IAAC,MAAsB,GAAA,IAAA,cAAA,CAAA,IAAA,CAAA,MAAA,CAAA,CAAA;AAElB,QAAA,IAAA,CAAA,iBAAc,GAAmB,iBAAC;AAS9C,KAAA;;;AAGG;AACH;AAIA,IAAA,aAAA,GAAA;;;AAGG;AACH;AAIA;;;AAGG,QAAA,OAAA,YAAA,CAAA,KAAA,CAAA,CAAA;AACH,KAAA;AAIA;;AAEG;AACG;AAIN,IAAA,YAAA,CAAA,KAAA,EAAA;;;AAGG;;AAwDH;;;AAGG,KAAA;;AAOH;;AAEG;AACG,IAAA,MAAA,sBAAyB,CAAA,OAAQ,EAAA;AAIvC,QAAA,MAAA,yBAAA,GAAA,IAAA,CAAA,iBAAA,EAAA,gBAAA,CAAA,iBAAA,CAAA,gCAAA,EAAA,OAAA,CAAA,aAAA,CAAA,CAAA;;;;AAIG,QAAA,MAAA,YAAA,GAAA,MAAA,IAAA,CAAA,aAAA,CAAA,SAAA,CAAA,OAAA,CAAA,SAAA,CAAA,CAAA;AACG,QAAA,MACK,kBAAmB,GAAA;AA6D9B,YAAA,CAAA,EAAA,YAAA,CAAA,CAAA;;;AAGG,SAAA,CAAA;QACa,MAAA,eAAY,GAAM,kBAAkB,CAAA,qBAAA,CAAA,kBAAA,CAAA,CAAA;AAOvD,QAAA,MAAA,aAAA,GAAA,MAAA,IAAA,CAAA,UAAA,CAAA,eAAA,CAAA,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModernBrowserCrypto.mjs","sources":["../../src/crypto/ModernBrowserCrypto.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"ModernBrowserCrypto.mjs","sources":["../../src/crypto/ModernBrowserCrypto.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;AAMA;AAEA;AACI;AAIM;AAmBS,MAAA,mBACF,CAAU;AAcjB,IAAA,eACO,CAAE,UAAmB,EAAA;AAW5B,QAAA,OACF,MAAW,CAAA,MAAA,CAAA,eACX,CAAA,UAAM,CAAA,CAAA;AAOb,KAAA;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PkceGenerator.d.ts","sourceRoot":"","sources":["../../src/crypto/PkceGenerator.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"PkceGenerator.d.ts","sourceRoot":"","sources":["../../src/crypto/PkceGenerator.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAM/C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAKhD;;GAEG;AACH,qBAAa,aAAa;IACtB,OAAO,CAAC,SAAS,CAAgB;gBAErB,SAAS,EAAE,aAAa;IAIpC;;OAEG;IACG,aAAa,IAAI,OAAO,CAAC,SAAS,CAAC;IAWzC;;;OAGG;IACH,OAAO,CAAC,oBAAoB;IAa5B;;;OAGG;YACW,iCAAiC;CAclD"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
/*! @azure/msal-browser v3.0
|
|
1
|
+
/*! @azure/msal-browser v3.1.0 2023-09-05 */
|
|
2
2
|
'use strict';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { createBrowserAuthError } from '../error/BrowserAuthError.mjs';
|
|
4
|
+
import { urlEncodeArr } from '../encode/Base64Encode.mjs';
|
|
5
|
+
import { pkceNotCreated } from '../error/BrowserAuthErrorCodes.mjs';
|
|
5
6
|
|
|
6
7
|
/*
|
|
7
8
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -14,7 +15,6 @@ const RANDOM_BYTE_ARR_LENGTH = 32;
|
|
|
14
15
|
*/
|
|
15
16
|
class PkceGenerator {
|
|
16
17
|
constructor(cryptoObj) {
|
|
17
|
-
this.base64Encode = new Base64Encode();
|
|
18
18
|
this.cryptoObj = cryptoObj;
|
|
19
19
|
}
|
|
20
20
|
/**
|
|
@@ -38,11 +38,11 @@ class PkceGenerator {
|
|
|
38
38
|
const buffer = new Uint8Array(RANDOM_BYTE_ARR_LENGTH);
|
|
39
39
|
this.cryptoObj.getRandomValues(buffer);
|
|
40
40
|
// encode verifier as base64
|
|
41
|
-
const pkceCodeVerifierB64 =
|
|
41
|
+
const pkceCodeVerifierB64 = urlEncodeArr(buffer);
|
|
42
42
|
return pkceCodeVerifierB64;
|
|
43
43
|
}
|
|
44
44
|
catch (e) {
|
|
45
|
-
throw
|
|
45
|
+
throw createBrowserAuthError(pkceNotCreated);
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
/**
|
|
@@ -54,10 +54,10 @@ class PkceGenerator {
|
|
|
54
54
|
// hashed verifier
|
|
55
55
|
const pkceHashedCodeVerifier = await this.cryptoObj.sha256Digest(pkceCodeVerifier);
|
|
56
56
|
// encode hash as base64
|
|
57
|
-
return
|
|
57
|
+
return urlEncodeArr(new Uint8Array(pkceHashedCodeVerifier));
|
|
58
58
|
}
|
|
59
59
|
catch (e) {
|
|
60
|
-
throw
|
|
60
|
+
throw createBrowserAuthError(pkceNotCreated);
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
63
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PkceGenerator.mjs","sources":["../../src/crypto/PkceGenerator.ts"],"sourcesContent":[null],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"PkceGenerator.mjs","sources":["../../src/crypto/PkceGenerator.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;AAKA;AAMA;AAKA;;;AAMgB,MAAA,sBAAwB,GAAA,EAAA,CAAA;AAIpC;;AAEG;AACG,MAAA,aAAiB,CAAA;AAWvB,IAAA,WAAA,CAAA,SAAA,EAAA;;;AAGG;AACH;AAaA;;;AAGG,QAAA,MAAA,aAAA,GAAA,MAAA,IAAA,CAAA,iCAAA,CAAA,YAAA,CAAA,CAAA;eAC4C;AAclD,YAAA,QAAA,EAAA,YAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SignedHttpRequest.mjs","sources":["../../src/crypto/SignedHttpRequest.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"SignedHttpRequest.mjs","sources":["../../src/crypto/SignedHttpRequest.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;AAMA;AAQA;;;AAOW,uBAA4C,CAAA;IACnD,yBAAuB,EAAA,UAAA,EAAA;AAGnB,QAAA,MAAA,aAAA,IAAe,UAA2B,IAAA,UAAA,CAAA,aAChC,KAA2B,EAAA,CAAA;AASzC,QAAA,IAAA,CAAA,MAAA,GAAA,IAAA,MAAA,CAAA,aAAA,EAAA,IAAA,EAAA,OAAA,CAAA,CAAA;;;AAGG,QAAA,IAAA,CAAA,aAAA,GAAA,aAAA,CAAA;AACG,KAAA;AAQN;;;;;;AAMG,QAAA,OAAA,GAAA,CAAA;AACG,KAAA;AAaN;;;;AAIG;;AAIN;;;;;;;;;;;;;;;;"}
|
|
@@ -1,23 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Class which exposes APIs to decode base64 strings to plaintext. See here for implementation details:
|
|
3
|
-
* https://developer.mozilla.org/en-US/docs/
|
|
3
|
+
* https://developer.mozilla.org/en-US/docs/Glossary/Base64#the_unicode_problem
|
|
4
4
|
*/
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
decode(input: string): string;
|
|
11
|
-
/**
|
|
12
|
-
* Decodes base64 into Uint8Array
|
|
13
|
-
* @param base64String
|
|
14
|
-
* @param nBlockSize
|
|
15
|
-
*/
|
|
16
|
-
private base64DecToArr;
|
|
17
|
-
/**
|
|
18
|
-
* Base64 string to array decoding helper
|
|
19
|
-
* @param charNum
|
|
20
|
-
*/
|
|
21
|
-
private b64ToUint6;
|
|
22
|
-
}
|
|
5
|
+
/**
|
|
6
|
+
* Returns a URL-safe plaintext decoded string from b64 encoded input.
|
|
7
|
+
* @param input
|
|
8
|
+
*/
|
|
9
|
+
export declare function base64Decode(input: string): string;
|
|
23
10
|
//# sourceMappingURL=Base64Decode.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Base64Decode.d.ts","sourceRoot":"","sources":["../../src/encode/Base64Decode.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Base64Decode.d.ts","sourceRoot":"","sources":["../../src/encode/Base64Decode.ts"],"names":[],"mappings":"AAKA;;;GAGG;AAEH;;;GAGG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAElD"}
|
|
@@ -1,81 +1,28 @@
|
|
|
1
|
-
/*! @azure/msal-browser v3.0
|
|
1
|
+
/*! @azure/msal-browser v3.1.0 2023-09-05 */
|
|
2
2
|
'use strict';
|
|
3
|
-
import { Constants } from '@azure/msal-common';
|
|
4
|
-
import { BrowserStringUtils } from '../utils/BrowserStringUtils.mjs';
|
|
5
|
-
|
|
6
3
|
/*
|
|
7
4
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
8
5
|
* Licensed under the MIT License.
|
|
9
6
|
*/
|
|
10
7
|
/**
|
|
11
8
|
* Class which exposes APIs to decode base64 strings to plaintext. See here for implementation details:
|
|
12
|
-
* https://developer.mozilla.org/en-US/docs/
|
|
9
|
+
* https://developer.mozilla.org/en-US/docs/Glossary/Base64#the_unicode_problem
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Returns a URL-safe plaintext decoded string from b64 encoded input.
|
|
13
|
+
* @param input
|
|
14
|
+
*/
|
|
15
|
+
function base64Decode(input) {
|
|
16
|
+
return new TextDecoder().decode(base64DecToArr(input));
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Decodes base64 into Uint8Array
|
|
20
|
+
* @param base64String
|
|
13
21
|
*/
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
* @param input
|
|
18
|
-
*/
|
|
19
|
-
decode(input) {
|
|
20
|
-
let encodedString = input.replace(/-/g, "+").replace(/_/g, "/");
|
|
21
|
-
switch (encodedString.length % 4) {
|
|
22
|
-
case 0:
|
|
23
|
-
break;
|
|
24
|
-
case 2:
|
|
25
|
-
encodedString += "==";
|
|
26
|
-
break;
|
|
27
|
-
case 3:
|
|
28
|
-
encodedString += "=";
|
|
29
|
-
break;
|
|
30
|
-
default:
|
|
31
|
-
throw new Error("Invalid base64 string");
|
|
32
|
-
}
|
|
33
|
-
const inputUtf8Arr = this.base64DecToArr(encodedString);
|
|
34
|
-
return BrowserStringUtils.utf8ArrToString(inputUtf8Arr);
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Decodes base64 into Uint8Array
|
|
38
|
-
* @param base64String
|
|
39
|
-
* @param nBlockSize
|
|
40
|
-
*/
|
|
41
|
-
base64DecToArr(base64String, nBlockSize) {
|
|
42
|
-
const sB64Enc = base64String.replace(/[^A-Za-z0-9\+\/]/g, Constants.EMPTY_STRING);
|
|
43
|
-
const nInLen = sB64Enc.length;
|
|
44
|
-
const nOutLen = nBlockSize
|
|
45
|
-
? Math.ceil(((nInLen * 3 + 1) >>> 2) / nBlockSize) * nBlockSize
|
|
46
|
-
: (nInLen * 3 + 1) >>> 2;
|
|
47
|
-
const aBytes = new Uint8Array(nOutLen);
|
|
48
|
-
for (let nMod3, nMod4, nUint24 = 0, nOutIdx = 0, nInIdx = 0; nInIdx < nInLen; nInIdx++) {
|
|
49
|
-
nMod4 = nInIdx & 3;
|
|
50
|
-
nUint24 |=
|
|
51
|
-
this.b64ToUint6(sB64Enc.charCodeAt(nInIdx)) << (18 - 6 * nMod4);
|
|
52
|
-
if (nMod4 === 3 || nInLen - nInIdx === 1) {
|
|
53
|
-
for (nMod3 = 0; nMod3 < 3 && nOutIdx < nOutLen; nMod3++, nOutIdx++) {
|
|
54
|
-
aBytes[nOutIdx] = (nUint24 >>> ((16 >>> nMod3) & 24)) & 255;
|
|
55
|
-
}
|
|
56
|
-
nUint24 = 0;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
return aBytes;
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Base64 string to array decoding helper
|
|
63
|
-
* @param charNum
|
|
64
|
-
*/
|
|
65
|
-
b64ToUint6(charNum) {
|
|
66
|
-
return charNum > 64 && charNum < 91
|
|
67
|
-
? charNum - 65
|
|
68
|
-
: charNum > 96 && charNum < 123
|
|
69
|
-
? charNum - 71
|
|
70
|
-
: charNum > 47 && charNum < 58
|
|
71
|
-
? charNum + 4
|
|
72
|
-
: charNum === 43
|
|
73
|
-
? 62
|
|
74
|
-
: charNum === 47
|
|
75
|
-
? 63
|
|
76
|
-
: 0;
|
|
77
|
-
}
|
|
22
|
+
function base64DecToArr(base64String) {
|
|
23
|
+
const binString = atob(base64String);
|
|
24
|
+
return Uint8Array.from(binString, (m) => m.codePointAt(0) || 0);
|
|
78
25
|
}
|
|
79
26
|
|
|
80
|
-
export {
|
|
27
|
+
export { base64Decode };
|
|
81
28
|
//# sourceMappingURL=Base64Decode.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Base64Decode.mjs","sources":["../../src/encode/Base64Decode.ts"],"sourcesContent":[null],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Base64Decode.mjs","sources":["../../src/encode/Base64Decode.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAKA;;;AAGG;AAEH;;;AAGG;AACH;;;;;;;;;;;;;;;;;;"}
|
|
@@ -2,31 +2,19 @@
|
|
|
2
2
|
* Class which exposes APIs to encode plaintext to base64 encoded string. See here for implementation details:
|
|
3
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
4
|
*/
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
encode(input: string): string;
|
|
21
|
-
/**
|
|
22
|
-
* Base64 encode byte array
|
|
23
|
-
* @param aBytes
|
|
24
|
-
*/
|
|
25
|
-
private base64EncArr;
|
|
26
|
-
/**
|
|
27
|
-
* Base64 string to array encoding helper
|
|
28
|
-
* @param nUint6
|
|
29
|
-
*/
|
|
30
|
-
private uint6ToB64;
|
|
31
|
-
}
|
|
5
|
+
/**
|
|
6
|
+
* Returns URL Safe b64 encoded string from a plaintext string.
|
|
7
|
+
* @param input
|
|
8
|
+
*/
|
|
9
|
+
export declare function urlEncode(input: string): string;
|
|
10
|
+
/**
|
|
11
|
+
* Returns URL Safe b64 encoded string from an int8Array.
|
|
12
|
+
* @param inputArr
|
|
13
|
+
*/
|
|
14
|
+
export declare function urlEncodeArr(inputArr: Uint8Array): string;
|
|
15
|
+
/**
|
|
16
|
+
* Returns b64 encoded string from plaintext string.
|
|
17
|
+
* @param input
|
|
18
|
+
*/
|
|
19
|
+
export declare function base64Encode(input: string): string;
|
|
32
20
|
//# sourceMappingURL=Base64Encode.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Base64Encode.d.ts","sourceRoot":"","sources":["../../src/encode/Base64Encode.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Base64Encode.d.ts","sourceRoot":"","sources":["../../src/encode/Base64Encode.ts"],"names":[],"mappings":"AAKA;;;GAGG;AAEH;;;GAGG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAO/C;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,UAAU,GAAG,MAAM,CAKzD;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAElD"}
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
/*! @azure/msal-browser v3.0
|
|
1
|
+
/*! @azure/msal-browser v3.1.0 2023-09-05 */
|
|
2
2
|
'use strict';
|
|
3
|
-
import { Constants } from '@azure/msal-common';
|
|
4
|
-
import { BrowserStringUtils } from '../utils/BrowserStringUtils.mjs';
|
|
5
|
-
|
|
6
3
|
/*
|
|
7
4
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
8
5
|
* Licensed under the MIT License.
|
|
@@ -11,77 +8,41 @@ import { BrowserStringUtils } from '../utils/BrowserStringUtils.mjs';
|
|
|
11
8
|
* Class which exposes APIs to encode plaintext to base64 encoded string. See here for implementation details:
|
|
12
9
|
* 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
|
|
13
10
|
*/
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
encode(input)
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
const eqLen = (3 - (aBytes.length % 3)) % 3;
|
|
49
|
-
let sB64Enc = Constants.EMPTY_STRING;
|
|
50
|
-
for (let nMod3, nLen = aBytes.length, nUint24 = 0, nIdx = 0; nIdx < nLen; nIdx++) {
|
|
51
|
-
nMod3 = nIdx % 3;
|
|
52
|
-
/* Uncomment the following line in order to split the output in lines 76-character long: */
|
|
53
|
-
/*
|
|
54
|
-
*if (nIdx > 0 && (nIdx * 4 / 3) % 76 === 0) { sB64Enc += "\r\n"; }
|
|
55
|
-
*/
|
|
56
|
-
nUint24 |= aBytes[nIdx] << ((16 >>> nMod3) & 24);
|
|
57
|
-
if (nMod3 === 2 || aBytes.length - nIdx === 1) {
|
|
58
|
-
sB64Enc += String.fromCharCode(this.uint6ToB64((nUint24 >>> 18) & 63), this.uint6ToB64((nUint24 >>> 12) & 63), this.uint6ToB64((nUint24 >>> 6) & 63), this.uint6ToB64(nUint24 & 63));
|
|
59
|
-
nUint24 = 0;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
return eqLen === 0
|
|
63
|
-
? sB64Enc
|
|
64
|
-
: sB64Enc.substring(0, sB64Enc.length - eqLen) +
|
|
65
|
-
(eqLen === 1 ? "=" : "==");
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Base64 string to array encoding helper
|
|
69
|
-
* @param nUint6
|
|
70
|
-
*/
|
|
71
|
-
uint6ToB64(nUint6) {
|
|
72
|
-
return nUint6 < 26
|
|
73
|
-
? nUint6 + 65
|
|
74
|
-
: nUint6 < 52
|
|
75
|
-
? nUint6 + 71
|
|
76
|
-
: nUint6 < 62
|
|
77
|
-
? nUint6 - 4
|
|
78
|
-
: nUint6 === 62
|
|
79
|
-
? 43
|
|
80
|
-
: nUint6 === 63
|
|
81
|
-
? 47
|
|
82
|
-
: 65;
|
|
83
|
-
}
|
|
11
|
+
/**
|
|
12
|
+
* Returns URL Safe b64 encoded string from a plaintext string.
|
|
13
|
+
* @param input
|
|
14
|
+
*/
|
|
15
|
+
function urlEncode(input) {
|
|
16
|
+
return encodeURIComponent(base64Encode(input)
|
|
17
|
+
.replace(/=/g, "")
|
|
18
|
+
.replace(/\+/g, "-")
|
|
19
|
+
.replace(/\//g, "_"));
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Returns URL Safe b64 encoded string from an int8Array.
|
|
23
|
+
* @param inputArr
|
|
24
|
+
*/
|
|
25
|
+
function urlEncodeArr(inputArr) {
|
|
26
|
+
return base64EncArr(inputArr)
|
|
27
|
+
.replace(/=/g, "")
|
|
28
|
+
.replace(/\+/g, "-")
|
|
29
|
+
.replace(/\//g, "_");
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Returns b64 encoded string from plaintext string.
|
|
33
|
+
* @param input
|
|
34
|
+
*/
|
|
35
|
+
function base64Encode(input) {
|
|
36
|
+
return base64EncArr(new TextEncoder().encode(input));
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Base64 encode byte array
|
|
40
|
+
* @param aBytes
|
|
41
|
+
*/
|
|
42
|
+
function base64EncArr(aBytes) {
|
|
43
|
+
const binString = Array.from(aBytes, (x) => String.fromCodePoint(x)).join("");
|
|
44
|
+
return btoa(binString);
|
|
84
45
|
}
|
|
85
46
|
|
|
86
|
-
export {
|
|
47
|
+
export { base64Encode, urlEncode, urlEncodeArr };
|
|
87
48
|
//# sourceMappingURL=Base64Encode.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Base64Encode.mjs","sources":["../../src/encode/Base64Encode.ts"],"sourcesContent":[null],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Base64Encode.mjs","sources":["../../src/encode/Base64Encode.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAKA;;;AAGG;AAEH;;;AAGG;AACH;AASA;;;AAGG,SAAA,SAAA,CAAA,KAAA,EAAA;AACH,IAAA,OAAA,+BAA6B,CAAA,KAAoB,CAAA;AAOjD,SAAA,OAAA,CAAA,IAAA,EAAA,EAAA,CAAA;;;AAGG,CAAA;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|