@azure/msal-browser 3.1.0 → 3.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (282) hide show
  1. package/dist/app/IPublicClientApplication.d.ts.map +1 -1
  2. package/dist/app/IPublicClientApplication.mjs +20 -19
  3. package/dist/app/IPublicClientApplication.mjs.map +1 -1
  4. package/dist/app/PublicClientApplication.d.ts +14 -6
  5. package/dist/app/PublicClientApplication.d.ts.map +1 -1
  6. package/dist/app/PublicClientApplication.mjs +18 -8
  7. package/dist/app/PublicClientApplication.mjs.map +1 -1
  8. package/dist/app/PublicClientNext.d.ts +274 -0
  9. package/dist/app/PublicClientNext.d.ts.map +1 -0
  10. package/dist/app/PublicClientNext.mjs +362 -0
  11. package/dist/app/PublicClientNext.mjs.map +1 -0
  12. package/dist/broker/nativeBroker/NativeMessageHandler.d.ts +3 -4
  13. package/dist/broker/nativeBroker/NativeMessageHandler.d.ts.map +1 -1
  14. package/dist/broker/nativeBroker/NativeMessageHandler.mjs +13 -13
  15. package/dist/broker/nativeBroker/NativeMessageHandler.mjs.map +1 -1
  16. package/dist/broker/nativeBroker/NativeStatusCodes.d.ts +8 -0
  17. package/dist/broker/nativeBroker/NativeStatusCodes.d.ts.map +1 -0
  18. package/dist/broker/nativeBroker/NativeStatusCodes.mjs +16 -0
  19. package/dist/broker/nativeBroker/NativeStatusCodes.mjs.map +1 -0
  20. package/dist/cache/AsyncMemoryStorage.mjs +1 -1
  21. package/dist/cache/BrowserCacheManager.d.ts +4 -15
  22. package/dist/cache/BrowserCacheManager.d.ts.map +1 -1
  23. package/dist/cache/BrowserCacheManager.mjs +13 -69
  24. package/dist/cache/BrowserCacheManager.mjs.map +1 -1
  25. package/dist/cache/BrowserStorage.d.ts.map +1 -1
  26. package/dist/cache/BrowserStorage.mjs +7 -9
  27. package/dist/cache/BrowserStorage.mjs.map +1 -1
  28. package/dist/cache/CryptoKeyStore.mjs +1 -1
  29. package/dist/cache/DatabaseStorage.mjs +1 -1
  30. package/dist/cache/MemoryStorage.mjs +1 -1
  31. package/dist/cache/TokenCache.mjs +1 -1
  32. package/dist/config/Configuration.d.ts +4 -0
  33. package/dist/config/Configuration.d.ts.map +1 -1
  34. package/dist/config/Configuration.mjs +8 -7
  35. package/dist/config/Configuration.mjs.map +1 -1
  36. package/dist/controllers/ControllerFactory.d.ts +2 -1
  37. package/dist/controllers/ControllerFactory.d.ts.map +1 -1
  38. package/dist/controllers/ControllerFactory.mjs +26 -19
  39. package/dist/controllers/ControllerFactory.mjs.map +1 -1
  40. package/dist/controllers/IController.d.ts +3 -2
  41. package/dist/controllers/IController.d.ts.map +1 -1
  42. package/dist/controllers/NestedAppAuthController.d.ts +96 -0
  43. package/dist/controllers/NestedAppAuthController.d.ts.map +1 -0
  44. package/dist/controllers/NestedAppAuthController.mjs +345 -0
  45. package/dist/controllers/NestedAppAuthController.mjs.map +1 -0
  46. package/dist/controllers/StandardController.d.ts +11 -6
  47. package/dist/controllers/StandardController.d.ts.map +1 -1
  48. package/dist/controllers/StandardController.mjs +67 -45
  49. package/dist/controllers/StandardController.mjs.map +1 -1
  50. package/dist/controllers/UnknownOperatingContextController.d.ts +88 -0
  51. package/dist/controllers/UnknownOperatingContextController.d.ts.map +1 -0
  52. package/dist/controllers/UnknownOperatingContextController.mjs +275 -0
  53. package/dist/controllers/UnknownOperatingContextController.mjs.map +1 -0
  54. package/dist/crypto/BrowserCrypto.d.ts +44 -49
  55. package/dist/crypto/BrowserCrypto.d.ts.map +1 -1
  56. package/dist/crypto/BrowserCrypto.mjs +77 -77
  57. package/dist/crypto/BrowserCrypto.mjs.map +1 -1
  58. package/dist/crypto/CryptoOps.d.ts +1 -7
  59. package/dist/crypto/CryptoOps.d.ts.map +1 -1
  60. package/dist/crypto/CryptoOps.mjs +18 -23
  61. package/dist/crypto/CryptoOps.mjs.map +1 -1
  62. package/dist/crypto/PkceGenerator.d.ts +6 -21
  63. package/dist/crypto/PkceGenerator.d.ts.map +1 -1
  64. package/dist/crypto/PkceGenerator.mjs +45 -46
  65. package/dist/crypto/PkceGenerator.mjs.map +1 -1
  66. package/dist/crypto/SignedHttpRequest.mjs +1 -1
  67. package/dist/encode/Base64Decode.d.ts.map +1 -1
  68. package/dist/encode/Base64Decode.mjs +18 -2
  69. package/dist/encode/Base64Decode.mjs.map +1 -1
  70. package/dist/encode/Base64Encode.mjs +1 -1
  71. package/dist/error/BrowserAuthError.d.ts +10 -1
  72. package/dist/error/BrowserAuthError.d.ts.map +1 -1
  73. package/dist/error/BrowserAuthError.mjs +12 -3
  74. package/dist/error/BrowserAuthError.mjs.map +1 -1
  75. package/dist/error/BrowserAuthErrorCodes.d.ts +1 -0
  76. package/dist/error/BrowserAuthErrorCodes.d.ts.map +1 -1
  77. package/dist/error/BrowserAuthErrorCodes.mjs +3 -2
  78. package/dist/error/BrowserAuthErrorCodes.mjs.map +1 -1
  79. package/dist/error/BrowserConfigurationAuthError.d.ts +9 -46
  80. package/dist/error/BrowserConfigurationAuthError.d.ts.map +1 -1
  81. package/dist/error/BrowserConfigurationAuthError.mjs +20 -73
  82. package/dist/error/BrowserConfigurationAuthError.mjs.map +1 -1
  83. package/dist/error/BrowserConfigurationAuthErrorCodes.d.ts +4 -0
  84. package/dist/error/BrowserConfigurationAuthErrorCodes.d.ts.map +1 -0
  85. package/dist/error/BrowserConfigurationAuthErrorCodes.mjs +12 -0
  86. package/dist/error/BrowserConfigurationAuthErrorCodes.mjs.map +1 -0
  87. package/dist/error/NativeAuthError.d.ts +17 -45
  88. package/dist/error/NativeAuthError.d.ts.map +1 -1
  89. package/dist/error/NativeAuthError.mjs +47 -78
  90. package/dist/error/NativeAuthError.mjs.map +1 -1
  91. package/dist/error/NativeAuthErrorCodes.d.ts +3 -0
  92. package/dist/error/NativeAuthErrorCodes.d.ts.map +1 -0
  93. package/dist/error/NativeAuthErrorCodes.mjs +11 -0
  94. package/dist/error/NativeAuthErrorCodes.mjs.map +1 -0
  95. package/dist/error/NestedAppAuthError.d.ts +15 -0
  96. package/dist/error/NestedAppAuthError.d.ts.map +1 -0
  97. package/dist/error/NestedAppAuthError.mjs +30 -0
  98. package/dist/error/NestedAppAuthError.mjs.map +1 -0
  99. package/dist/event/EventHandler.d.ts.map +1 -1
  100. package/dist/event/EventHandler.mjs +3 -2
  101. package/dist/event/EventHandler.mjs.map +1 -1
  102. package/dist/event/EventMessage.mjs +1 -1
  103. package/dist/event/EventType.mjs +1 -1
  104. package/dist/index.d.ts +5 -7
  105. package/dist/index.d.ts.map +1 -1
  106. package/dist/index.mjs +7 -3
  107. package/dist/index.mjs.map +1 -1
  108. package/dist/interaction_client/BaseInteractionClient.d.ts.map +1 -1
  109. package/dist/interaction_client/BaseInteractionClient.mjs +10 -11
  110. package/dist/interaction_client/BaseInteractionClient.mjs.map +1 -1
  111. package/dist/interaction_client/HybridSpaAuthorizationCodeClient.mjs +1 -1
  112. package/dist/interaction_client/NativeInteractionClient.d.ts.map +1 -1
  113. package/dist/interaction_client/NativeInteractionClient.mjs +26 -13
  114. package/dist/interaction_client/NativeInteractionClient.mjs.map +1 -1
  115. package/dist/interaction_client/PopupClient.d.ts.map +1 -1
  116. package/dist/interaction_client/PopupClient.mjs +5 -4
  117. package/dist/interaction_client/PopupClient.mjs.map +1 -1
  118. package/dist/interaction_client/RedirectClient.mjs +7 -7
  119. package/dist/interaction_client/SilentAuthCodeClient.d.ts.map +1 -1
  120. package/dist/interaction_client/SilentAuthCodeClient.mjs +7 -10
  121. package/dist/interaction_client/SilentAuthCodeClient.mjs.map +1 -1
  122. package/dist/interaction_client/SilentCacheClient.d.ts.map +1 -1
  123. package/dist/interaction_client/SilentCacheClient.mjs +11 -18
  124. package/dist/interaction_client/SilentCacheClient.mjs.map +1 -1
  125. package/dist/interaction_client/SilentIframeClient.d.ts.map +1 -1
  126. package/dist/interaction_client/SilentIframeClient.mjs +27 -13
  127. package/dist/interaction_client/SilentIframeClient.mjs.map +1 -1
  128. package/dist/interaction_client/SilentRefreshClient.d.ts.map +1 -1
  129. package/dist/interaction_client/SilentRefreshClient.mjs +8 -18
  130. package/dist/interaction_client/SilentRefreshClient.mjs.map +1 -1
  131. package/dist/interaction_client/StandardInteractionClient.d.ts.map +1 -1
  132. package/dist/interaction_client/StandardInteractionClient.mjs +16 -37
  133. package/dist/interaction_client/StandardInteractionClient.mjs.map +1 -1
  134. package/dist/interaction_handler/InteractionHandler.d.ts.map +1 -1
  135. package/dist/interaction_handler/InteractionHandler.mjs +6 -9
  136. package/dist/interaction_handler/InteractionHandler.mjs.map +1 -1
  137. package/dist/interaction_handler/RedirectHandler.d.ts.map +1 -1
  138. package/dist/interaction_handler/RedirectHandler.mjs +3 -3
  139. package/dist/interaction_handler/RedirectHandler.mjs.map +1 -1
  140. package/dist/interaction_handler/SilentHandler.d.ts +13 -47
  141. package/dist/interaction_handler/SilentHandler.d.ts.map +1 -1
  142. package/dist/interaction_handler/SilentHandler.mjs +120 -156
  143. package/dist/interaction_handler/SilentHandler.mjs.map +1 -1
  144. package/dist/naa/AccountInfo.d.ts +13 -0
  145. package/dist/naa/AccountInfo.d.ts.map +1 -0
  146. package/dist/naa/AccountRequests.d.ts +10 -0
  147. package/dist/naa/AccountRequests.d.ts.map +1 -0
  148. package/dist/naa/AuthBridge.d.ts +6 -0
  149. package/dist/naa/AuthBridge.d.ts.map +1 -0
  150. package/dist/naa/BridgeCapabilities.d.ts +4 -0
  151. package/dist/naa/BridgeCapabilities.d.ts.map +1 -0
  152. package/dist/naa/BridgeError.d.ts +10 -0
  153. package/dist/naa/BridgeError.d.ts.map +1 -0
  154. package/dist/naa/BridgeError.mjs +12 -0
  155. package/dist/naa/BridgeError.mjs.map +1 -0
  156. package/dist/naa/BridgeProxy.d.ts +72 -0
  157. package/dist/naa/BridgeProxy.d.ts.map +1 -0
  158. package/dist/naa/BridgeProxy.mjs +154 -0
  159. package/dist/naa/BridgeProxy.mjs.map +1 -0
  160. package/dist/naa/BridgeRequest.d.ts +7 -0
  161. package/dist/naa/BridgeRequest.d.ts.map +1 -0
  162. package/dist/naa/BridgeRequestEnvelope.d.ts +14 -0
  163. package/dist/naa/BridgeRequestEnvelope.d.ts.map +1 -0
  164. package/dist/naa/BridgeResponseEnvelope.d.ts +11 -0
  165. package/dist/naa/BridgeResponseEnvelope.d.ts.map +1 -0
  166. package/dist/naa/BridgeStatusCode.d.ts +11 -0
  167. package/dist/naa/BridgeStatusCode.d.ts.map +1 -0
  168. package/dist/naa/BridgeStatusCode.mjs +20 -0
  169. package/dist/naa/BridgeStatusCode.mjs.map +1 -0
  170. package/dist/naa/IBridgeProxy.d.ts +11 -0
  171. package/dist/naa/IBridgeProxy.d.ts.map +1 -0
  172. package/dist/naa/InitializeBridgeResponse.d.ts +7 -0
  173. package/dist/naa/InitializeBridgeResponse.d.ts.map +1 -0
  174. package/dist/naa/TokenRequest.d.ts +22 -0
  175. package/dist/naa/TokenRequest.d.ts.map +1 -0
  176. package/dist/naa/TokenResponse.d.ts +17 -0
  177. package/dist/naa/TokenResponse.d.ts.map +1 -0
  178. package/dist/naa/mapping/NestedAppAuthAdapter.d.ts +26 -0
  179. package/dist/naa/mapping/NestedAppAuthAdapter.d.ts.map +1 -0
  180. package/dist/naa/mapping/NestedAppAuthAdapter.mjs +178 -0
  181. package/dist/naa/mapping/NestedAppAuthAdapter.mjs.map +1 -0
  182. package/dist/navigation/NavigationClient.mjs +1 -1
  183. package/dist/network/FetchClient.mjs +1 -1
  184. package/dist/operatingcontext/BaseOperatingContext.mjs +1 -1
  185. package/dist/operatingcontext/StandardOperatingContext.mjs +1 -1
  186. package/dist/operatingcontext/TeamsAppOperatingContext.d.ts +7 -0
  187. package/dist/operatingcontext/TeamsAppOperatingContext.d.ts.map +1 -1
  188. package/dist/operatingcontext/TeamsAppOperatingContext.mjs +45 -4
  189. package/dist/operatingcontext/TeamsAppOperatingContext.mjs.map +1 -1
  190. package/dist/operatingcontext/UnknownOperatingContext.d.ts +26 -0
  191. package/dist/operatingcontext/UnknownOperatingContext.d.ts.map +1 -0
  192. package/dist/operatingcontext/UnknownOperatingContext.mjs +49 -0
  193. package/dist/operatingcontext/UnknownOperatingContext.mjs.map +1 -0
  194. package/dist/packageMetadata.d.ts +1 -1
  195. package/dist/packageMetadata.mjs +2 -2
  196. package/dist/telemetry/BrowserPerformanceClient.mjs +1 -1
  197. package/dist/telemetry/BrowserPerformanceMeasurement.mjs +1 -1
  198. package/dist/utils/BrowserConstants.mjs +1 -1
  199. package/dist/utils/BrowserProtocolUtils.d.ts.map +1 -1
  200. package/dist/utils/BrowserProtocolUtils.mjs +3 -3
  201. package/dist/utils/BrowserProtocolUtils.mjs.map +1 -1
  202. package/dist/utils/BrowserUtils.d.ts +54 -53
  203. package/dist/utils/BrowserUtils.d.ts.map +1 -1
  204. package/dist/utils/BrowserUtils.mjs +114 -102
  205. package/dist/utils/BrowserUtils.mjs.map +1 -1
  206. package/lib/msal-browser.cjs +61 -18042
  207. package/lib/msal-browser.cjs.map +1 -1
  208. package/lib/msal-browser.js +13593 -12505
  209. package/lib/msal-browser.js.map +1 -1
  210. package/lib/msal-browser.min.js +66 -65
  211. package/package.json +2 -2
  212. package/src/app/IPublicClientApplication.ts +55 -18
  213. package/src/app/PublicClientApplication.ts +19 -7
  214. package/src/app/PublicClientNext.ts +442 -0
  215. package/src/broker/nativeBroker/NativeMessageHandler.ts +12 -15
  216. package/src/broker/nativeBroker/NativeStatusCodes.ts +13 -0
  217. package/src/cache/BrowserCacheManager.ts +29 -103
  218. package/src/cache/BrowserStorage.ts +9 -11
  219. package/src/config/Configuration.ts +21 -8
  220. package/src/controllers/ControllerFactory.ts +36 -25
  221. package/src/controllers/IController.ts +4 -1
  222. package/src/controllers/NestedAppAuthController.ts +525 -0
  223. package/src/controllers/StandardController.ts +163 -98
  224. package/src/controllers/UnknownOperatingContextController.ts +383 -0
  225. package/src/crypto/BrowserCrypto.ts +119 -103
  226. package/src/crypto/CryptoOps.ts +18 -27
  227. package/src/crypto/PkceGenerator.ts +93 -54
  228. package/src/encode/Base64Decode.ts +21 -1
  229. package/src/error/BrowserAuthError.ts +13 -1
  230. package/src/error/BrowserAuthErrorCodes.ts +1 -0
  231. package/src/error/BrowserConfigurationAuthError.ts +33 -102
  232. package/src/error/BrowserConfigurationAuthErrorCodes.ts +9 -0
  233. package/src/error/NativeAuthError.ts +73 -101
  234. package/src/error/NativeAuthErrorCodes.ts +7 -0
  235. package/src/error/NestedAppAuthError.ts +32 -0
  236. package/src/event/EventHandler.ts +2 -1
  237. package/src/index.ts +8 -10
  238. package/src/interaction_client/BaseInteractionClient.ts +14 -8
  239. package/src/interaction_client/NativeInteractionClient.ts +48 -14
  240. package/src/interaction_client/PopupClient.ts +2 -1
  241. package/src/interaction_client/RedirectClient.ts +1 -1
  242. package/src/interaction_client/SilentAuthCodeClient.ts +22 -19
  243. package/src/interaction_client/SilentCacheClient.ts +28 -28
  244. package/src/interaction_client/SilentIframeClient.ts +54 -18
  245. package/src/interaction_client/SilentRefreshClient.ts +26 -28
  246. package/src/interaction_client/StandardInteractionClient.ts +37 -68
  247. package/src/interaction_handler/InteractionHandler.ts +20 -15
  248. package/src/interaction_handler/RedirectHandler.ts +6 -2
  249. package/src/interaction_handler/SilentHandler.ts +177 -230
  250. package/src/naa/AccountInfo.ts +17 -0
  251. package/src/naa/AccountRequests.ts +16 -0
  252. package/src/naa/AuthBridge.ts +16 -0
  253. package/src/naa/BridgeCapabilities.ts +8 -0
  254. package/src/naa/BridgeError.ts +18 -0
  255. package/src/naa/BridgeProxy.ts +230 -0
  256. package/src/naa/BridgeRequest.ts +12 -0
  257. package/src/naa/BridgeRequestEnvelope.ts +46 -0
  258. package/src/naa/BridgeResponseEnvelope.ts +21 -0
  259. package/src/naa/BridgeStatusCode.ts +15 -0
  260. package/src/naa/IBridgeProxy.ts +25 -0
  261. package/src/naa/InitializeBridgeResponse.ts +12 -0
  262. package/src/naa/TokenRequest.ts +26 -0
  263. package/src/naa/TokenResponse.ts +61 -0
  264. package/src/naa/mapping/NestedAppAuthAdapter.ts +252 -0
  265. package/src/operatingcontext/TeamsAppOperatingContext.ts +43 -3
  266. package/src/operatingcontext/UnknownOperatingContext.ts +48 -0
  267. package/src/packageMetadata.ts +1 -1
  268. package/src/utils/BrowserProtocolUtils.ts +3 -2
  269. package/src/utils/BrowserUtils.ts +133 -125
  270. package/dist/crypto/ISubtleCrypto.d.ts +0 -10
  271. package/dist/crypto/ISubtleCrypto.d.ts.map +0 -1
  272. package/dist/crypto/ModernBrowserCrypto.d.ts +0 -10
  273. package/dist/crypto/ModernBrowserCrypto.d.ts.map +0 -1
  274. package/dist/crypto/ModernBrowserCrypto.mjs +0 -31
  275. package/dist/crypto/ModernBrowserCrypto.mjs.map +0 -1
  276. package/dist/utils/BrowserStringUtils.d.ts +0 -22
  277. package/dist/utils/BrowserStringUtils.d.ts.map +0 -1
  278. package/dist/utils/BrowserStringUtils.mjs +0 -144
  279. package/dist/utils/BrowserStringUtils.mjs.map +0 -1
  280. package/src/crypto/ISubtleCrypto.ts +0 -30
  281. package/src/crypto/ModernBrowserCrypto.ts +0 -69
  282. package/src/utils/BrowserStringUtils.ts +0 -143
@@ -3,7 +3,7 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
- import { Constants, UrlString } from "@azure/msal-common";
6
+ import { UrlString } from "@azure/msal-common";
7
7
  import {
8
8
  createBrowserAuthError,
9
9
  BrowserAuthErrorCodes,
@@ -11,146 +11,154 @@ import {
11
11
  import { InteractionType, BrowserConstants } from "./BrowserConstants";
12
12
 
13
13
  /**
14
- * Utility class for browser specific functions
14
+ * Clears hash from window url.
15
15
  */
16
- export class BrowserUtils {
17
- // #region Window Navigation and URL management
18
-
19
- /**
20
- * Clears hash from window url.
21
- */
22
- static clearHash(contentWindow: Window): void {
23
- // Office.js sets history.replaceState to null
24
- contentWindow.location.hash = Constants.EMPTY_STRING;
25
- if (typeof contentWindow.history.replaceState === "function") {
26
- // Full removes "#" from url
27
- contentWindow.history.replaceState(
28
- null,
29
- Constants.EMPTY_STRING,
30
- `${contentWindow.location.origin}${contentWindow.location.pathname}${contentWindow.location.search}`
31
- );
32
- }
16
+ export function clearHash(contentWindow: Window): void {
17
+ // Office.js sets history.replaceState to null
18
+ contentWindow.location.hash = "";
19
+ if (typeof contentWindow.history.replaceState === "function") {
20
+ // Full removes "#" from url
21
+ contentWindow.history.replaceState(
22
+ null,
23
+ "",
24
+ `${contentWindow.location.origin}${contentWindow.location.pathname}${contentWindow.location.search}`
25
+ );
33
26
  }
27
+ }
34
28
 
35
- /**
36
- * Replaces current hash with hash from provided url
37
- */
38
- static replaceHash(url: string): void {
39
- const urlParts = url.split("#");
40
- urlParts.shift(); // Remove part before the hash
41
- window.location.hash =
42
- urlParts.length > 0 ? urlParts.join("#") : Constants.EMPTY_STRING;
43
- }
29
+ /**
30
+ * Replaces current hash with hash from provided url
31
+ */
32
+ export function replaceHash(url: string): void {
33
+ const urlParts = url.split("#");
34
+ urlParts.shift(); // Remove part before the hash
35
+ window.location.hash = urlParts.length > 0 ? urlParts.join("#") : "";
36
+ }
44
37
 
45
- /**
46
- * Returns boolean of whether the current window is in an iframe or not.
47
- */
48
- static isInIframe(): boolean {
49
- return window.parent !== window;
50
- }
38
+ /**
39
+ * Returns boolean of whether the current window is in an iframe or not.
40
+ */
41
+ export function isInIframe(): boolean {
42
+ return window.parent !== window;
43
+ }
51
44
 
52
- /**
53
- * Returns boolean of whether or not the current window is a popup opened by msal
54
- */
55
- static isInPopup(): boolean {
56
- return (
57
- typeof window !== "undefined" &&
58
- !!window.opener &&
59
- window.opener !== window &&
60
- typeof window.name === "string" &&
61
- window.name.indexOf(`${BrowserConstants.POPUP_NAME_PREFIX}.`) === 0
62
- );
63
- }
45
+ /**
46
+ * Returns boolean of whether or not the current window is a popup opened by msal
47
+ */
48
+ export function isInPopup(): boolean {
49
+ return (
50
+ typeof window !== "undefined" &&
51
+ !!window.opener &&
52
+ window.opener !== window &&
53
+ typeof window.name === "string" &&
54
+ window.name.indexOf(`${BrowserConstants.POPUP_NAME_PREFIX}.`) === 0
55
+ );
56
+ }
64
57
 
65
- // #endregion
58
+ // #endregion
66
59
 
67
- /**
68
- * Returns current window URL as redirect uri
69
- */
70
- static getCurrentUri(): string {
71
- return window.location.href.split("?")[0].split("#")[0];
72
- }
60
+ /**
61
+ * Returns current window URL as redirect uri
62
+ */
63
+ export function getCurrentUri(): string {
64
+ return window.location.href.split("?")[0].split("#")[0];
65
+ }
73
66
 
74
- /**
75
- * Gets the homepage url for the current window location.
76
- */
77
- static getHomepage(): string {
78
- const currentUrl = new UrlString(window.location.href);
79
- const urlComponents = currentUrl.getUrlComponents();
80
- return `${urlComponents.Protocol}//${urlComponents.HostNameAndPort}/`;
81
- }
67
+ /**
68
+ * Gets the homepage url for the current window location.
69
+ */
70
+ export function getHomepage(): string {
71
+ const currentUrl = new UrlString(window.location.href);
72
+ const urlComponents = currentUrl.getUrlComponents();
73
+ return `${urlComponents.Protocol}//${urlComponents.HostNameAndPort}/`;
74
+ }
82
75
 
83
- /**
84
- * Throws error if we have completed an auth and are
85
- * attempting another auth request inside an iframe.
86
- */
87
- static blockReloadInHiddenIframes(): void {
88
- const isResponseHash = UrlString.hashContainsKnownProperties(
89
- window.location.hash
90
- );
91
- // return an error if called from the hidden iframe created by the msal js silent calls
92
- if (isResponseHash && BrowserUtils.isInIframe()) {
93
- throw createBrowserAuthError(
94
- BrowserAuthErrorCodes.blockIframeReload
95
- );
96
- }
76
+ /**
77
+ * Throws error if we have completed an auth and are
78
+ * attempting another auth request inside an iframe.
79
+ */
80
+ export function blockReloadInHiddenIframes(): void {
81
+ const isResponseHash = UrlString.hashContainsKnownProperties(
82
+ window.location.hash
83
+ );
84
+ // return an error if called from the hidden iframe created by the msal js silent calls
85
+ if (isResponseHash && isInIframe()) {
86
+ throw createBrowserAuthError(BrowserAuthErrorCodes.blockIframeReload);
97
87
  }
88
+ }
98
89
 
99
- /**
100
- * Block redirect operations in iframes unless explicitly allowed
101
- * @param interactionType Interaction type for the request
102
- * @param allowRedirectInIframe Config value to allow redirects when app is inside an iframe
103
- */
104
- static blockRedirectInIframe(
105
- interactionType: InteractionType,
106
- allowRedirectInIframe: boolean
107
- ): void {
108
- const isIframedApp = BrowserUtils.isInIframe();
109
- if (
110
- interactionType === InteractionType.Redirect &&
111
- isIframedApp &&
112
- !allowRedirectInIframe
113
- ) {
114
- // If we are not in top frame, we shouldn't redirect. This is also handled by the service.
115
- throw createBrowserAuthError(
116
- BrowserAuthErrorCodes.redirectInIframe
117
- );
118
- }
90
+ /**
91
+ * Block redirect operations in iframes unless explicitly allowed
92
+ * @param interactionType Interaction type for the request
93
+ * @param allowRedirectInIframe Config value to allow redirects when app is inside an iframe
94
+ */
95
+ export function blockRedirectInIframe(
96
+ interactionType: InteractionType,
97
+ allowRedirectInIframe: boolean
98
+ ): void {
99
+ const isIframedApp = isInIframe();
100
+ if (
101
+ interactionType === InteractionType.Redirect &&
102
+ isIframedApp &&
103
+ !allowRedirectInIframe
104
+ ) {
105
+ // If we are not in top frame, we shouldn't redirect. This is also handled by the service.
106
+ throw createBrowserAuthError(BrowserAuthErrorCodes.redirectInIframe);
119
107
  }
108
+ }
120
109
 
121
- /**
122
- * Block redirectUri loaded in popup from calling AcquireToken APIs
123
- */
124
- static blockAcquireTokenInPopups(): void {
125
- // Popups opened by msal popup APIs are given a name that starts with "msal."
126
- if (BrowserUtils.isInPopup()) {
127
- throw createBrowserAuthError(
128
- BrowserAuthErrorCodes.blockNestedPopups
129
- );
130
- }
110
+ /**
111
+ * Block redirectUri loaded in popup from calling AcquireToken APIs
112
+ */
113
+ export function blockAcquireTokenInPopups(): void {
114
+ // Popups opened by msal popup APIs are given a name that starts with "msal."
115
+ if (isInPopup()) {
116
+ throw createBrowserAuthError(BrowserAuthErrorCodes.blockNestedPopups);
131
117
  }
118
+ }
132
119
 
133
- /**
134
- * Throws error if token requests are made in non-browser environment
135
- * @param isBrowserEnvironment Flag indicating if environment is a browser.
136
- */
137
- static blockNonBrowserEnvironment(isBrowserEnvironment: boolean): void {
138
- if (!isBrowserEnvironment) {
139
- throw createBrowserAuthError(
140
- BrowserAuthErrorCodes.nonBrowserEnvironment
141
- );
142
- }
120
+ /**
121
+ * Throws error if token requests are made in non-browser environment
122
+ * @param isBrowserEnvironment Flag indicating if environment is a browser.
123
+ */
124
+ export function blockNonBrowserEnvironment(
125
+ isBrowserEnvironment: boolean
126
+ ): void {
127
+ if (!isBrowserEnvironment) {
128
+ throw createBrowserAuthError(
129
+ BrowserAuthErrorCodes.nonBrowserEnvironment
130
+ );
143
131
  }
132
+ }
144
133
 
145
- /**
146
- * Throws error if initialize hasn't been called
147
- * @param initialized
148
- */
149
- static blockAPICallsBeforeInitialize(initialized: boolean): void {
150
- if (!initialized) {
151
- throw createBrowserAuthError(
152
- BrowserAuthErrorCodes.uninitializedPublicClientApplication
153
- );
154
- }
134
+ /**
135
+ * Throws error if initialize hasn't been called
136
+ * @param initialized
137
+ */
138
+ export function blockAPICallsBeforeInitialize(initialized: boolean): void {
139
+ if (!initialized) {
140
+ throw createBrowserAuthError(
141
+ BrowserAuthErrorCodes.uninitializedPublicClientApplication
142
+ );
155
143
  }
156
144
  }
145
+
146
+ /**
147
+ * Adds a preconnect link element to the header which begins DNS resolution and SSL connection in anticipation of the /token request
148
+ * @param loginDomain Authority domain, including https protocol e.g. https://login.microsoftonline.com
149
+ * @returns
150
+ */
151
+ export function preconnect(authority: string): void {
152
+ const link = document.createElement("link");
153
+ link.rel = "preconnect";
154
+ link.href = new URL(authority).origin;
155
+ link.crossOrigin = "anonymous";
156
+ document.head.appendChild(link);
157
+
158
+ // The browser will close connection if not used within a few seconds, remove element from the header after 10s
159
+ window.setTimeout(() => {
160
+ try {
161
+ document.head.removeChild(link);
162
+ } catch {}
163
+ }, 10000); // 10s Timeout
164
+ }
@@ -1,10 +0,0 @@
1
- export interface ISubtleCrypto {
2
- initPrng?(entropy: Uint8Array): void;
3
- getRandomValues(dataBuffer: Uint8Array): Uint8Array;
4
- generateKey(algorithm: RsaHashedKeyGenParams, extractable: boolean, keyUsages: KeyUsage[]): Promise<CryptoKeyPair>;
5
- exportKey(key: CryptoKey): Promise<JsonWebKey>;
6
- importKey(keyData: JsonWebKey, algorithm: RsaHashedImportParams, extractable: boolean, keyUsages: KeyUsage[]): Promise<CryptoKey>;
7
- sign(algorithm: AlgorithmIdentifier, key: CryptoKey, data: ArrayBuffer): Promise<ArrayBuffer>;
8
- digest(algorithm: AlgorithmIdentifier, data: Uint8Array): Promise<ArrayBuffer>;
9
- }
10
- //# sourceMappingURL=ISubtleCrypto.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ISubtleCrypto.d.ts","sourceRoot":"","sources":["../../src/crypto/ISubtleCrypto.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,aAAa;IAC1B,QAAQ,CAAC,CAAC,OAAO,EAAE,UAAU,GAAG,IAAI,CAAC;IACrC,eAAe,CAAC,UAAU,EAAE,UAAU,GAAG,UAAU,CAAC;IACpD,WAAW,CACP,SAAS,EAAE,qBAAqB,EAChC,WAAW,EAAE,OAAO,EACpB,SAAS,EAAE,QAAQ,EAAE,GACtB,OAAO,CAAC,aAAa,CAAC,CAAC;IAC1B,SAAS,CAAC,GAAG,EAAE,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;IAC/C,SAAS,CACL,OAAO,EAAE,UAAU,EACnB,SAAS,EAAE,qBAAqB,EAChC,WAAW,EAAE,OAAO,EACpB,SAAS,EAAE,QAAQ,EAAE,GACtB,OAAO,CAAC,SAAS,CAAC,CAAC;IACtB,IAAI,CACA,SAAS,EAAE,mBAAmB,EAC9B,GAAG,EAAE,SAAS,EACd,IAAI,EAAE,WAAW,GAClB,OAAO,CAAC,WAAW,CAAC,CAAC;IACxB,MAAM,CACF,SAAS,EAAE,mBAAmB,EAC9B,IAAI,EAAE,UAAU,GACjB,OAAO,CAAC,WAAW,CAAC,CAAC;CAC3B"}
@@ -1,10 +0,0 @@
1
- import { ISubtleCrypto } from "./ISubtleCrypto";
2
- export declare class ModernBrowserCrypto implements ISubtleCrypto {
3
- getRandomValues(dataBuffer: Uint8Array): Uint8Array;
4
- generateKey(algorithm: RsaHashedKeyGenParams, extractable: boolean, keyUsages: KeyUsage[]): Promise<CryptoKeyPair>;
5
- exportKey(key: CryptoKey): Promise<JsonWebKey>;
6
- importKey(keyData: JsonWebKey, algorithm: RsaHashedImportParams, extractable: boolean, keyUsages: KeyUsage[]): Promise<CryptoKey>;
7
- sign(algorithm: AlgorithmIdentifier, key: CryptoKey, data: ArrayBuffer): Promise<ArrayBuffer>;
8
- digest(algorithm: AlgorithmIdentifier, data: Uint8Array): Promise<ArrayBuffer>;
9
- }
10
- //# sourceMappingURL=ModernBrowserCrypto.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ModernBrowserCrypto.d.ts","sourceRoot":"","sources":["../../src/crypto/ModernBrowserCrypto.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,qBAAa,mBAAoB,YAAW,aAAa;IACrD,eAAe,CAAC,UAAU,EAAE,UAAU,GAAG,UAAU;IAI7C,WAAW,CACb,SAAS,EAAE,qBAAqB,EAChC,WAAW,EAAE,OAAO,EACpB,SAAS,EAAE,QAAQ,EAAE,GACtB,OAAO,CAAC,aAAa,CAAC;IAQnB,SAAS,CAAC,GAAG,EAAE,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC;IAO9C,SAAS,CACX,OAAO,EAAE,UAAU,EACnB,SAAS,EAAE,qBAAqB,EAChC,WAAW,EAAE,OAAO,EACpB,SAAS,EAAE,QAAQ,EAAE,GACtB,OAAO,CAAC,SAAS,CAAC;IAUf,IAAI,CACN,SAAS,EAAE,mBAAmB,EAC9B,GAAG,EAAE,SAAS,EACd,IAAI,EAAE,WAAW,GAClB,OAAO,CAAC,WAAW,CAAC;IAQjB,MAAM,CACR,SAAS,EAAE,mBAAmB,EAC9B,IAAI,EAAE,UAAU,GACjB,OAAO,CAAC,WAAW,CAAC;CAM1B"}
@@ -1,31 +0,0 @@
1
- /*! @azure/msal-browser v3.1.0 2023-09-05 */
2
- 'use strict';
3
- import { KEY_FORMAT_JWK } from '../utils/BrowserConstants.mjs';
4
-
5
- /*
6
- * Copyright (c) Microsoft Corporation. All rights reserved.
7
- * Licensed under the MIT License.
8
- */
9
- class ModernBrowserCrypto {
10
- getRandomValues(dataBuffer) {
11
- return window.crypto.getRandomValues(dataBuffer);
12
- }
13
- async generateKey(algorithm, extractable, keyUsages) {
14
- return window.crypto.subtle.generateKey(algorithm, extractable, keyUsages);
15
- }
16
- async exportKey(key) {
17
- return window.crypto.subtle.exportKey(KEY_FORMAT_JWK, key);
18
- }
19
- async importKey(keyData, algorithm, extractable, keyUsages) {
20
- return window.crypto.subtle.importKey(KEY_FORMAT_JWK, keyData, algorithm, extractable, keyUsages);
21
- }
22
- async sign(algorithm, key, data) {
23
- return window.crypto.subtle.sign(algorithm, key, data);
24
- }
25
- async digest(algorithm, data) {
26
- return window.crypto.subtle.digest(algorithm, data);
27
- }
28
- }
29
-
30
- export { ModernBrowserCrypto };
31
- //# sourceMappingURL=ModernBrowserCrypto.mjs.map
@@ -1 +0,0 @@
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,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.1.0 2023-09-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,30 +0,0 @@
1
- /*
2
- * Copyright (c) Microsoft Corporation. All rights reserved.
3
- * Licensed under the MIT License.
4
- */
5
-
6
- export interface ISubtleCrypto {
7
- initPrng?(entropy: Uint8Array): void;
8
- getRandomValues(dataBuffer: Uint8Array): Uint8Array;
9
- generateKey(
10
- algorithm: RsaHashedKeyGenParams,
11
- extractable: boolean,
12
- keyUsages: KeyUsage[]
13
- ): Promise<CryptoKeyPair>;
14
- exportKey(key: CryptoKey): Promise<JsonWebKey>;
15
- importKey(
16
- keyData: JsonWebKey,
17
- algorithm: RsaHashedImportParams,
18
- extractable: boolean,
19
- keyUsages: KeyUsage[]
20
- ): Promise<CryptoKey>;
21
- sign(
22
- algorithm: AlgorithmIdentifier,
23
- key: CryptoKey,
24
- data: ArrayBuffer
25
- ): Promise<ArrayBuffer>;
26
- digest(
27
- algorithm: AlgorithmIdentifier,
28
- data: Uint8Array
29
- ): Promise<ArrayBuffer>;
30
- }
@@ -1,69 +0,0 @@
1
- /*
2
- * Copyright (c) Microsoft Corporation. All rights reserved.
3
- * Licensed under the MIT License.
4
- */
5
-
6
- import { KEY_FORMAT_JWK } from "../utils/BrowserConstants";
7
- import { ISubtleCrypto } from "./ISubtleCrypto";
8
-
9
- export class ModernBrowserCrypto implements ISubtleCrypto {
10
- getRandomValues(dataBuffer: Uint8Array): Uint8Array {
11
- return window.crypto.getRandomValues(dataBuffer);
12
- }
13
-
14
- async generateKey(
15
- algorithm: RsaHashedKeyGenParams,
16
- extractable: boolean,
17
- keyUsages: KeyUsage[]
18
- ): Promise<CryptoKeyPair> {
19
- return window.crypto.subtle.generateKey(
20
- algorithm,
21
- extractable,
22
- keyUsages
23
- ) as Promise<CryptoKeyPair>;
24
- }
25
-
26
- async exportKey(key: CryptoKey): Promise<JsonWebKey> {
27
- return window.crypto.subtle.exportKey(
28
- KEY_FORMAT_JWK,
29
- key
30
- ) as Promise<JsonWebKey>;
31
- }
32
-
33
- async importKey(
34
- keyData: JsonWebKey,
35
- algorithm: RsaHashedImportParams,
36
- extractable: boolean,
37
- keyUsages: KeyUsage[]
38
- ): Promise<CryptoKey> {
39
- return window.crypto.subtle.importKey(
40
- KEY_FORMAT_JWK,
41
- keyData,
42
- algorithm,
43
- extractable,
44
- keyUsages
45
- ) as Promise<CryptoKey>;
46
- }
47
-
48
- async sign(
49
- algorithm: AlgorithmIdentifier,
50
- key: CryptoKey,
51
- data: ArrayBuffer
52
- ): Promise<ArrayBuffer> {
53
- return window.crypto.subtle.sign(
54
- algorithm,
55
- key,
56
- data
57
- ) as Promise<ArrayBuffer>;
58
- }
59
-
60
- async digest(
61
- algorithm: AlgorithmIdentifier,
62
- data: Uint8Array
63
- ): Promise<ArrayBuffer> {
64
- return window.crypto.subtle.digest(
65
- algorithm,
66
- data
67
- ) as Promise<ArrayBuffer>;
68
- }
69
- }