@azure/msal-browser 3.0.2 → 3.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (280) hide show
  1. package/dist/app/IPublicClientApplication.d.ts +2 -0
  2. package/dist/app/IPublicClientApplication.d.ts.map +1 -1
  3. package/dist/app/IPublicClientApplication.mjs +22 -18
  4. package/dist/app/IPublicClientApplication.mjs.map +1 -1
  5. package/dist/app/PublicClientApplication.d.ts +20 -6
  6. package/dist/app/PublicClientApplication.d.ts.map +1 -1
  7. package/dist/app/PublicClientApplication.mjs +24 -7
  8. package/dist/app/PublicClientApplication.mjs.map +1 -1
  9. package/dist/broker/nativeBroker/NativeMessageHandler.d.ts +3 -4
  10. package/dist/broker/nativeBroker/NativeMessageHandler.d.ts.map +1 -1
  11. package/dist/broker/nativeBroker/NativeMessageHandler.mjs +17 -16
  12. package/dist/broker/nativeBroker/NativeMessageHandler.mjs.map +1 -1
  13. package/dist/broker/nativeBroker/NativeStatusCodes.d.ts +8 -0
  14. package/dist/broker/nativeBroker/NativeStatusCodes.d.ts.map +1 -0
  15. package/dist/broker/nativeBroker/NativeStatusCodes.mjs +16 -0
  16. package/dist/broker/nativeBroker/NativeStatusCodes.mjs.map +1 -0
  17. package/dist/cache/AsyncMemoryStorage.mjs +4 -3
  18. package/dist/cache/AsyncMemoryStorage.mjs.map +1 -1
  19. package/dist/cache/BrowserCacheManager.d.ts +10 -3
  20. package/dist/cache/BrowserCacheManager.d.ts.map +1 -1
  21. package/dist/cache/BrowserCacheManager.mjs +58 -29
  22. package/dist/cache/BrowserCacheManager.mjs.map +1 -1
  23. package/dist/cache/BrowserStorage.d.ts.map +1 -1
  24. package/dist/cache/BrowserStorage.mjs +7 -9
  25. package/dist/cache/BrowserStorage.mjs.map +1 -1
  26. package/dist/cache/CryptoKeyStore.mjs +1 -1
  27. package/dist/cache/CryptoKeyStore.mjs.map +1 -1
  28. package/dist/cache/DatabaseStorage.d.ts.map +1 -1
  29. package/dist/cache/DatabaseStorage.mjs +9 -8
  30. package/dist/cache/DatabaseStorage.mjs.map +1 -1
  31. package/dist/cache/MemoryStorage.mjs +1 -1
  32. package/dist/cache/MemoryStorage.mjs.map +1 -1
  33. package/dist/cache/TokenCache.d.ts.map +1 -1
  34. package/dist/cache/TokenCache.mjs +30 -30
  35. package/dist/cache/TokenCache.mjs.map +1 -1
  36. package/dist/config/Configuration.d.ts +1 -0
  37. package/dist/config/Configuration.d.ts.map +1 -1
  38. package/dist/config/Configuration.mjs +12 -16
  39. package/dist/config/Configuration.mjs.map +1 -1
  40. package/dist/controllers/ControllerFactory.mjs +1 -1
  41. package/dist/controllers/ControllerFactory.mjs.map +1 -1
  42. package/dist/controllers/IController.d.ts +5 -28
  43. package/dist/controllers/IController.d.ts.map +1 -1
  44. package/dist/controllers/StandardController.d.ts +17 -31
  45. package/dist/controllers/StandardController.d.ts.map +1 -1
  46. package/dist/controllers/StandardController.mjs +78 -83
  47. package/dist/controllers/StandardController.mjs.map +1 -1
  48. package/dist/crypto/BrowserCrypto.d.ts +44 -49
  49. package/dist/crypto/BrowserCrypto.d.ts.map +1 -1
  50. package/dist/crypto/BrowserCrypto.mjs +78 -77
  51. package/dist/crypto/BrowserCrypto.mjs.map +1 -1
  52. package/dist/crypto/CryptoOps.d.ts +1 -10
  53. package/dist/crypto/CryptoOps.d.ts.map +1 -1
  54. package/dist/crypto/CryptoOps.mjs +23 -34
  55. package/dist/crypto/CryptoOps.mjs.map +1 -1
  56. package/dist/crypto/PkceGenerator.d.ts +6 -22
  57. package/dist/crypto/PkceGenerator.d.ts.map +1 -1
  58. package/dist/crypto/PkceGenerator.mjs +48 -49
  59. package/dist/crypto/PkceGenerator.mjs.map +1 -1
  60. package/dist/crypto/SignedHttpRequest.mjs +1 -1
  61. package/dist/crypto/SignedHttpRequest.mjs.map +1 -1
  62. package/dist/encode/Base64Decode.d.ts +6 -19
  63. package/dist/encode/Base64Decode.d.ts.map +1 -1
  64. package/dist/encode/Base64Decode.mjs +31 -68
  65. package/dist/encode/Base64Decode.mjs.map +1 -1
  66. package/dist/encode/Base64Encode.d.ts +15 -27
  67. package/dist/encode/Base64Encode.d.ts.map +1 -1
  68. package/dist/encode/Base64Encode.mjs +36 -75
  69. package/dist/encode/Base64Encode.mjs.map +1 -1
  70. package/dist/error/BrowserAuthError.d.ts +63 -195
  71. package/dist/error/BrowserAuthError.d.ts.map +1 -1
  72. package/dist/error/BrowserAuthError.mjs +159 -381
  73. package/dist/error/BrowserAuthError.mjs.map +1 -1
  74. package/dist/error/BrowserAuthErrorCodes.d.ts +46 -0
  75. package/dist/error/BrowserAuthErrorCodes.d.ts.map +1 -0
  76. package/dist/error/BrowserAuthErrorCodes.mjs +54 -0
  77. package/dist/error/BrowserAuthErrorCodes.mjs.map +1 -0
  78. package/dist/error/BrowserConfigurationAuthError.d.ts +9 -46
  79. package/dist/error/BrowserConfigurationAuthError.d.ts.map +1 -1
  80. package/dist/error/BrowserConfigurationAuthError.mjs +20 -73
  81. package/dist/error/BrowserConfigurationAuthError.mjs.map +1 -1
  82. package/dist/error/BrowserConfigurationAuthErrorCodes.d.ts +4 -0
  83. package/dist/error/BrowserConfigurationAuthErrorCodes.d.ts.map +1 -0
  84. package/dist/error/BrowserConfigurationAuthErrorCodes.mjs +12 -0
  85. package/dist/error/BrowserConfigurationAuthErrorCodes.mjs.map +1 -0
  86. package/dist/error/NativeAuthError.d.ts +17 -45
  87. package/dist/error/NativeAuthError.d.ts.map +1 -1
  88. package/dist/error/NativeAuthError.mjs +49 -79
  89. package/dist/error/NativeAuthError.mjs.map +1 -1
  90. package/dist/error/NativeAuthErrorCodes.d.ts +3 -0
  91. package/dist/error/NativeAuthErrorCodes.d.ts.map +1 -0
  92. package/dist/error/NativeAuthErrorCodes.mjs +11 -0
  93. package/dist/error/NativeAuthErrorCodes.mjs.map +1 -0
  94. package/dist/event/EventHandler.d.ts.map +1 -1
  95. package/dist/event/EventHandler.mjs +3 -2
  96. package/dist/event/EventHandler.mjs.map +1 -1
  97. package/dist/event/EventMessage.mjs +1 -1
  98. package/dist/event/EventMessage.mjs.map +1 -1
  99. package/dist/event/EventType.mjs +1 -1
  100. package/dist/event/EventType.mjs.map +1 -1
  101. package/dist/index.d.ts +6 -6
  102. package/dist/index.d.ts.map +1 -1
  103. package/dist/index.mjs +8 -4
  104. package/dist/index.mjs.map +1 -1
  105. package/dist/interaction_client/BaseInteractionClient.d.ts +2 -1
  106. package/dist/interaction_client/BaseInteractionClient.d.ts.map +1 -1
  107. package/dist/interaction_client/BaseInteractionClient.mjs +7 -8
  108. package/dist/interaction_client/BaseInteractionClient.mjs.map +1 -1
  109. package/dist/interaction_client/HybridSpaAuthorizationCodeClient.mjs +1 -1
  110. package/dist/interaction_client/HybridSpaAuthorizationCodeClient.mjs.map +1 -1
  111. package/dist/interaction_client/NativeInteractionClient.d.ts +4 -10
  112. package/dist/interaction_client/NativeInteractionClient.d.ts.map +1 -1
  113. package/dist/interaction_client/NativeInteractionClient.mjs +32 -38
  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 +16 -15
  117. package/dist/interaction_client/PopupClient.mjs.map +1 -1
  118. package/dist/interaction_client/RedirectClient.d.ts.map +1 -1
  119. package/dist/interaction_client/RedirectClient.mjs +7 -6
  120. package/dist/interaction_client/RedirectClient.mjs.map +1 -1
  121. package/dist/interaction_client/SilentAuthCodeClient.d.ts.map +1 -1
  122. package/dist/interaction_client/SilentAuthCodeClient.mjs +9 -11
  123. package/dist/interaction_client/SilentAuthCodeClient.mjs.map +1 -1
  124. package/dist/interaction_client/SilentCacheClient.d.ts +4 -2
  125. package/dist/interaction_client/SilentCacheClient.d.ts.map +1 -1
  126. package/dist/interaction_client/SilentCacheClient.mjs +19 -25
  127. package/dist/interaction_client/SilentCacheClient.mjs.map +1 -1
  128. package/dist/interaction_client/SilentIframeClient.d.ts.map +1 -1
  129. package/dist/interaction_client/SilentIframeClient.mjs +20 -47
  130. package/dist/interaction_client/SilentIframeClient.mjs.map +1 -1
  131. package/dist/interaction_client/SilentRefreshClient.d.ts.map +1 -1
  132. package/dist/interaction_client/SilentRefreshClient.mjs +11 -20
  133. package/dist/interaction_client/SilentRefreshClient.mjs.map +1 -1
  134. package/dist/interaction_client/StandardInteractionClient.d.ts.map +1 -1
  135. package/dist/interaction_client/StandardInteractionClient.mjs +18 -38
  136. package/dist/interaction_client/StandardInteractionClient.mjs.map +1 -1
  137. package/dist/interaction_handler/InteractionHandler.d.ts.map +1 -1
  138. package/dist/interaction_handler/InteractionHandler.mjs +13 -16
  139. package/dist/interaction_handler/InteractionHandler.mjs.map +1 -1
  140. package/dist/interaction_handler/RedirectHandler.d.ts.map +1 -1
  141. package/dist/interaction_handler/RedirectHandler.mjs +12 -11
  142. package/dist/interaction_handler/RedirectHandler.mjs.map +1 -1
  143. package/dist/interaction_handler/SilentHandler.d.ts.map +1 -1
  144. package/dist/interaction_handler/SilentHandler.mjs +11 -11
  145. package/dist/interaction_handler/SilentHandler.mjs.map +1 -1
  146. package/dist/navigation/NavigationClient.mjs +1 -1
  147. package/dist/navigation/NavigationClient.mjs.map +1 -1
  148. package/dist/network/FetchClient.d.ts.map +1 -1
  149. package/dist/network/FetchClient.mjs +9 -8
  150. package/dist/network/FetchClient.mjs.map +1 -1
  151. package/dist/operatingcontext/BaseOperatingContext.mjs +1 -1
  152. package/dist/operatingcontext/BaseOperatingContext.mjs.map +1 -1
  153. package/dist/operatingcontext/StandardOperatingContext.mjs +1 -1
  154. package/dist/operatingcontext/StandardOperatingContext.mjs.map +1 -1
  155. package/dist/operatingcontext/TeamsAppOperatingContext.mjs +1 -1
  156. package/dist/operatingcontext/TeamsAppOperatingContext.mjs.map +1 -1
  157. package/dist/packageMetadata.d.ts +1 -1
  158. package/dist/packageMetadata.mjs +2 -2
  159. package/dist/packageMetadata.mjs.map +1 -1
  160. package/dist/request/ClearCacheRequest.d.ts +11 -0
  161. package/dist/request/ClearCacheRequest.d.ts.map +1 -0
  162. package/dist/telemetry/BrowserPerformanceClient.d.ts +2 -4
  163. package/dist/telemetry/BrowserPerformanceClient.d.ts.map +1 -1
  164. package/dist/telemetry/BrowserPerformanceClient.mjs +2 -6
  165. package/dist/telemetry/BrowserPerformanceClient.mjs.map +1 -1
  166. package/dist/telemetry/BrowserPerformanceMeasurement.mjs +1 -1
  167. package/dist/telemetry/BrowserPerformanceMeasurement.mjs.map +1 -1
  168. package/dist/utils/BrowserConstants.mjs +1 -1
  169. package/dist/utils/BrowserConstants.mjs.map +1 -1
  170. package/dist/utils/BrowserProtocolUtils.d.ts.map +1 -1
  171. package/dist/utils/BrowserProtocolUtils.mjs +4 -4
  172. package/dist/utils/BrowserProtocolUtils.mjs.map +1 -1
  173. package/dist/utils/BrowserStringUtils.mjs +1 -1
  174. package/dist/utils/BrowserStringUtils.mjs.map +1 -1
  175. package/dist/utils/BrowserUtils.d.ts +0 -9
  176. package/dist/utils/BrowserUtils.d.ts.map +1 -1
  177. package/dist/utils/BrowserUtils.mjs +8 -33
  178. package/dist/utils/BrowserUtils.mjs.map +1 -1
  179. package/lib/msal-browser.cjs +8729 -9566
  180. package/lib/msal-browser.cjs.map +1 -1
  181. package/lib/msal-browser.js +8729 -9566
  182. package/lib/msal-browser.js.map +1 -1
  183. package/lib/msal-browser.min.js +68 -62
  184. package/package.json +7 -5
  185. package/src/app/IPublicClientApplication.ts +236 -0
  186. package/src/app/PublicClientApplication.ts +417 -0
  187. package/src/broker/nativeBroker/NativeMessageHandler.ts +416 -0
  188. package/src/broker/nativeBroker/NativeRequest.ts +52 -0
  189. package/src/broker/nativeBroker/NativeResponse.ts +56 -0
  190. package/src/broker/nativeBroker/NativeStatusCodes.ts +13 -0
  191. package/src/cache/AsyncMemoryStorage.ts +158 -0
  192. package/src/cache/BrowserCacheManager.ts +2009 -0
  193. package/src/cache/BrowserStorage.ts +52 -0
  194. package/src/cache/CryptoKeyStore.ts +63 -0
  195. package/src/cache/DatabaseStorage.ts +287 -0
  196. package/src/cache/IAsyncMemoryStorage.ts +36 -0
  197. package/src/cache/ITokenCache.ts +21 -0
  198. package/src/cache/IWindowStorage.ts +36 -0
  199. package/src/cache/MemoryStorage.ts +42 -0
  200. package/src/cache/TokenCache.ts +484 -0
  201. package/src/config/Configuration.ts +383 -0
  202. package/src/controllers/ControllerFactory.ts +55 -0
  203. package/src/controllers/IController.ts +134 -0
  204. package/src/controllers/StandardController.ts +2170 -0
  205. package/src/crypto/BrowserCrypto.ts +151 -0
  206. package/src/crypto/CryptoOps.ts +235 -0
  207. package/src/crypto/PkceGenerator.ts +115 -0
  208. package/src/crypto/SignedHttpRequest.ts +76 -0
  209. package/src/encode/Base64Decode.ts +46 -0
  210. package/src/encode/Base64Encode.ts +52 -0
  211. package/src/error/BrowserAuthError.ts +352 -0
  212. package/src/error/BrowserAuthErrorCodes.ts +57 -0
  213. package/src/error/BrowserConfigurationAuthError.ts +64 -0
  214. package/src/error/BrowserConfigurationAuthErrorCodes.ts +9 -0
  215. package/src/error/NativeAuthError.ts +113 -0
  216. package/src/error/NativeAuthErrorCodes.ts +7 -0
  217. package/src/event/EventHandler.ts +177 -0
  218. package/src/event/EventMessage.ts +125 -0
  219. package/src/event/EventType.ts +33 -0
  220. package/src/index.ts +157 -0
  221. package/src/interaction_client/BaseInteractionClient.ts +307 -0
  222. package/src/interaction_client/HybridSpaAuthorizationCodeClient.ts +16 -0
  223. package/src/interaction_client/NativeInteractionClient.ts +925 -0
  224. package/src/interaction_client/PopupClient.ts +926 -0
  225. package/src/interaction_client/RedirectClient.ts +616 -0
  226. package/src/interaction_client/SilentAuthCodeClient.ts +165 -0
  227. package/src/interaction_client/SilentCacheClient.ts +125 -0
  228. package/src/interaction_client/SilentIframeClient.ts +301 -0
  229. package/src/interaction_client/SilentRefreshClient.ts +118 -0
  230. package/src/interaction_client/StandardInteractionClient.ts +450 -0
  231. package/src/interaction_handler/InteractionHandler.ts +251 -0
  232. package/src/interaction_handler/RedirectHandler.ts +229 -0
  233. package/src/interaction_handler/SilentHandler.ts +269 -0
  234. package/src/navigation/INavigationClient.ts +23 -0
  235. package/src/navigation/NavigationClient.ts +55 -0
  236. package/src/navigation/NavigationOptions.ts +18 -0
  237. package/src/network/FetchClient.ts +130 -0
  238. package/src/operatingcontext/BaseOperatingContext.ts +82 -0
  239. package/src/operatingcontext/StandardOperatingContext.ts +49 -0
  240. package/src/operatingcontext/TeamsAppOperatingContext.ts +48 -0
  241. package/src/packageMetadata.ts +3 -0
  242. package/src/request/AuthorizationCodeRequest.ts +19 -0
  243. package/src/request/AuthorizationUrlRequest.ts +17 -0
  244. package/src/request/ClearCacheRequest.ts +16 -0
  245. package/src/request/EndSessionPopupRequest.ts +26 -0
  246. package/src/request/EndSessionRequest.ts +23 -0
  247. package/src/request/PopupRequest.ts +51 -0
  248. package/src/request/PopupWindowAttributes.ts +22 -0
  249. package/src/request/RedirectRequest.ts +51 -0
  250. package/src/request/SilentRequest.ts +49 -0
  251. package/src/request/SsoSilentRequest.ts +44 -0
  252. package/src/response/AuthenticationResult.ts +13 -0
  253. package/src/telemetry/BrowserPerformanceClient.ts +226 -0
  254. package/src/telemetry/BrowserPerformanceMeasurement.ts +144 -0
  255. package/src/utils/BrowserConstants.ts +241 -0
  256. package/src/utils/BrowserProtocolUtils.ts +58 -0
  257. package/src/utils/BrowserStringUtils.ts +143 -0
  258. package/src/utils/BrowserUtils.ts +156 -0
  259. package/dist/crypto/GuidGenerator.d.ts +0 -13
  260. package/dist/crypto/GuidGenerator.d.ts.map +0 -1
  261. package/dist/crypto/GuidGenerator.mjs +0 -104
  262. package/dist/crypto/GuidGenerator.mjs.map +0 -1
  263. package/dist/crypto/ISubtleCrypto.d.ts +0 -10
  264. package/dist/crypto/ISubtleCrypto.d.ts.map +0 -1
  265. package/dist/crypto/ModernBrowserCrypto.d.ts +0 -10
  266. package/dist/crypto/ModernBrowserCrypto.d.ts.map +0 -1
  267. package/dist/crypto/ModernBrowserCrypto.mjs +0 -31
  268. package/dist/crypto/ModernBrowserCrypto.mjs.map +0 -1
  269. package/dist/internals.d.ts +0 -23
  270. package/dist/internals.d.ts.map +0 -1
  271. package/dist/internals.mjs +0 -28
  272. package/dist/internals.mjs.map +0 -1
  273. package/dist/network/XhrClient.d.ts +0 -41
  274. package/dist/network/XhrClient.d.ts.map +0 -1
  275. package/dist/network/XhrClient.mjs +0 -125
  276. package/dist/network/XhrClient.mjs.map +0 -1
  277. package/dist/utils/MathUtils.d.ts +0 -12
  278. package/dist/utils/MathUtils.d.ts.map +0 -1
  279. package/dist/utils/MathUtils.mjs +0 -26
  280. package/dist/utils/MathUtils.mjs.map +0 -1
@@ -0,0 +1,383 @@
1
+ /*
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+
6
+ import {
7
+ SystemOptions,
8
+ LoggerOptions,
9
+ INetworkModule,
10
+ DEFAULT_SYSTEM_OPTIONS,
11
+ Constants,
12
+ ProtocolMode,
13
+ OIDCOptions,
14
+ ServerResponseType,
15
+ LogLevel,
16
+ StubbedNetworkModule,
17
+ AzureCloudInstance,
18
+ AzureCloudOptions,
19
+ ApplicationTelemetry,
20
+ createClientConfigurationError,
21
+ ClientConfigurationErrorCodes,
22
+ IPerformanceClient,
23
+ StubPerformanceClient,
24
+ Logger,
25
+ } from "@azure/msal-common";
26
+ import {
27
+ BrowserCacheLocation,
28
+ BrowserConstants,
29
+ } from "../utils/BrowserConstants";
30
+ import { INavigationClient } from "../navigation/INavigationClient";
31
+ import { NavigationClient } from "../navigation/NavigationClient";
32
+ import { FetchClient } from "../network/FetchClient";
33
+
34
+ // Default timeout for popup windows and iframes in milliseconds
35
+ export const DEFAULT_POPUP_TIMEOUT_MS = 60000;
36
+ export const DEFAULT_IFRAME_TIMEOUT_MS = 6000;
37
+ export const DEFAULT_REDIRECT_TIMEOUT_MS = 30000;
38
+ export const DEFAULT_NATIVE_BROKER_HANDSHAKE_TIMEOUT_MS = 2000;
39
+
40
+ /**
41
+ * Use this to configure the auth options in the Configuration object
42
+ */
43
+ export type BrowserAuthOptions = {
44
+ /**
45
+ * Client ID of your app registered with our Application registration portal : https://portal.azure.com/#blade/Microsoft_AAD_IAM/ActiveDirectoryMenuBlade/RegisteredAppsPreview in Microsoft Identity Platform
46
+ */
47
+ clientId: string;
48
+ /**
49
+ * You can configure a specific authority, defaults to " " or "https://login.microsoftonline.com/common"
50
+ */
51
+ authority?: string;
52
+ /**
53
+ * An array of URIs that are known to be valid. Used in B2C scenarios.
54
+ */
55
+ knownAuthorities?: Array<string>;
56
+ /**
57
+ * A string containing the cloud discovery response. Used in AAD scenarios.
58
+ */
59
+ cloudDiscoveryMetadata?: string;
60
+ /**
61
+ * A string containing the .well-known/openid-configuration endpoint response
62
+ */
63
+ authorityMetadata?: string;
64
+ /**
65
+ * The redirect URI where authentication responses can be received by your application. It must exactly match one of the redirect URIs registered in the Azure portal.
66
+ */
67
+ redirectUri?: string;
68
+ /**
69
+ * The redirect URI where the window navigates after a successful logout.
70
+ */
71
+ postLogoutRedirectUri?: string | null;
72
+ /**
73
+ * Boolean indicating whether to navigate to the original request URL after the auth server navigates to the redirect URL.
74
+ */
75
+ navigateToLoginRequestUrl?: boolean;
76
+ /**
77
+ * Array of capabilities which will be added to the claims.access_token.xms_cc request property on every network request.
78
+ */
79
+ clientCapabilities?: Array<string>;
80
+ /**
81
+ * Enum that represents the protocol that msal follows. Used for configuring proper endpoints.
82
+ */
83
+ protocolMode?: ProtocolMode;
84
+ /**
85
+ * Enum that configures options for the OIDC protocol mode.
86
+ */
87
+ OIDCOptions?: OIDCOptions;
88
+ /**
89
+ * Enum that represents the Azure Cloud to use.
90
+ */
91
+ azureCloudOptions?: AzureCloudOptions;
92
+ /**
93
+ * Flag of whether to use the local metadata cache
94
+ */
95
+ skipAuthorityMetadataCache?: boolean;
96
+ };
97
+
98
+ /** @internal */
99
+ export type InternalAuthOptions = Required<BrowserAuthOptions> & {
100
+ OIDCOptions: Required<OIDCOptions>;
101
+ };
102
+
103
+ /**
104
+ * Use this to configure the below cache configuration options:
105
+ */
106
+ export type CacheOptions = {
107
+ /**
108
+ * Used to specify the cacheLocation user wants to set. Valid values are "localStorage", "sessionStorage" and "memoryStorage".
109
+ */
110
+ cacheLocation?: BrowserCacheLocation | string;
111
+ /**
112
+ * Used to specify the temporaryCacheLocation user wants to set. Valid values are "localStorage", "sessionStorage" and "memoryStorage".
113
+ */
114
+ temporaryCacheLocation?: BrowserCacheLocation | string;
115
+ /**
116
+ * If set, MSAL stores the auth request state required for validation of the auth flows in the browser cookies. By default this flag is set to false.
117
+ */
118
+ storeAuthStateInCookie?: boolean;
119
+ /**
120
+ * If set, MSAL sets the "Secure" flag on cookies so they can only be sent over HTTPS. By default this flag is set to false.
121
+ */
122
+ secureCookies?: boolean;
123
+ /**
124
+ * If set, MSAL will attempt to migrate cache entries from older versions on initialization. By default this flag is set to true if cacheLocation is localStorage, otherwise false.
125
+ */
126
+ cacheMigrationEnabled?: boolean;
127
+ /**
128
+ * Flag that determines whether access tokens are stored based on requested claims
129
+ */
130
+ claimsBasedCachingEnabled?: boolean;
131
+ };
132
+
133
+ export type BrowserSystemOptions = SystemOptions & {
134
+ /**
135
+ * Used to initialize the Logger object (See ClientConfiguration.ts)
136
+ */
137
+ loggerOptions?: LoggerOptions;
138
+ /**
139
+ * Network interface implementation
140
+ */
141
+ networkClient?: INetworkModule;
142
+ /**
143
+ * Override the methods used to navigate to other webpages. Particularly useful if you are using a client-side router
144
+ */
145
+ navigationClient?: INavigationClient;
146
+ /**
147
+ * Sets the timeout for waiting for a response hash in a popup. Will take precedence over loadFrameTimeout if both are set.
148
+ */
149
+ windowHashTimeout?: number;
150
+ /**
151
+ * Sets the timeout for waiting for a response hash in an iframe. Will take precedence over loadFrameTimeout if both are set.
152
+ */
153
+ iframeHashTimeout?: number;
154
+ /**
155
+ * Sets the timeout for waiting for a response hash in an iframe or popup
156
+ */
157
+ loadFrameTimeout?: number;
158
+ /**
159
+ * Maximum time the library should wait for a frame to load
160
+ * @deprecated This was previously needed for older browsers which are no longer supported by MSAL.js. This option will be removed in the next major version
161
+ */
162
+ navigateFrameWait?: number;
163
+ /**
164
+ * Time to wait for redirection to occur before resolving promise
165
+ */
166
+ redirectNavigationTimeout?: number;
167
+ /**
168
+ * Sets whether popups are opened asynchronously. By default, this flag is set to false. When set to false, blank popups are opened before anything else happens. When set to true, popups are opened when making the network request.
169
+ */
170
+ asyncPopups?: boolean;
171
+ /**
172
+ * Flag to enable redirect opertaions when the app is rendered in an iframe (to support scenarios such as embedded B2C login).
173
+ */
174
+ allowRedirectInIframe?: boolean;
175
+ /**
176
+ * Flag to enable native broker support (e.g. acquiring tokens from WAM on Windows)
177
+ */
178
+ allowNativeBroker?: boolean;
179
+ /**
180
+ * Sets the timeout for waiting for the native broker handshake to resolve
181
+ */
182
+ nativeBrokerHandshakeTimeout?: number;
183
+ /**
184
+ * Sets the interval length in milliseconds for polling the location attribute in popup windows (default is 30ms)
185
+ */
186
+ pollIntervalMilliseconds?: number;
187
+ };
188
+
189
+ /**
190
+ * Telemetry Options
191
+ */
192
+ export type BrowserTelemetryOptions = {
193
+ /**
194
+ * Telemetry information sent on request
195
+ * - appName: Unique string name of an application
196
+ * - appVersion: Version of the application using MSAL
197
+ */
198
+ application?: ApplicationTelemetry;
199
+
200
+ client?: IPerformanceClient;
201
+ };
202
+
203
+ /**
204
+ * This object allows you to configure important elements of MSAL functionality and is passed into the constructor of PublicClientApplication
205
+ */
206
+ export type Configuration = {
207
+ /**
208
+ * This is where you configure auth elements like clientID, authority used for authenticating against the Microsoft Identity Platform
209
+ */
210
+ auth: BrowserAuthOptions;
211
+ /**
212
+ * This is where you configure cache location and whether to store cache in cookies
213
+ */
214
+ cache?: CacheOptions;
215
+ /**
216
+ * This is where you can configure the network client, logger, token renewal offset
217
+ */
218
+ system?: BrowserSystemOptions;
219
+ /**
220
+ * This is where you can configure telemetry data and options
221
+ */
222
+ telemetry?: BrowserTelemetryOptions;
223
+ };
224
+
225
+ /** @internal */
226
+ export type BrowserConfiguration = {
227
+ auth: InternalAuthOptions;
228
+ cache: Required<CacheOptions>;
229
+ system: Required<BrowserSystemOptions>;
230
+ telemetry: Required<BrowserTelemetryOptions>;
231
+ };
232
+
233
+ /**
234
+ * MSAL function that sets the default options when not explicitly configured from app developer
235
+ *
236
+ * @param auth
237
+ * @param cache
238
+ * @param system
239
+ *
240
+ * @returns Configuration object
241
+ */
242
+ export function buildConfiguration(
243
+ {
244
+ auth: userInputAuth,
245
+ cache: userInputCache,
246
+ system: userInputSystem,
247
+ telemetry: userInputTelemetry,
248
+ }: Configuration,
249
+ isBrowserEnvironment: boolean
250
+ ): BrowserConfiguration {
251
+ // Default auth options for browser
252
+ const DEFAULT_AUTH_OPTIONS: InternalAuthOptions = {
253
+ clientId: Constants.EMPTY_STRING,
254
+ authority: `${Constants.DEFAULT_AUTHORITY}`,
255
+ knownAuthorities: [],
256
+ cloudDiscoveryMetadata: Constants.EMPTY_STRING,
257
+ authorityMetadata: Constants.EMPTY_STRING,
258
+ redirectUri: Constants.EMPTY_STRING,
259
+ postLogoutRedirectUri: Constants.EMPTY_STRING,
260
+ navigateToLoginRequestUrl: true,
261
+ clientCapabilities: [],
262
+ protocolMode: ProtocolMode.AAD,
263
+ OIDCOptions: {
264
+ serverResponseType: ServerResponseType.FRAGMENT,
265
+ defaultScopes: [
266
+ Constants.OPENID_SCOPE,
267
+ Constants.PROFILE_SCOPE,
268
+ Constants.OFFLINE_ACCESS_SCOPE,
269
+ ],
270
+ },
271
+ azureCloudOptions: {
272
+ azureCloudInstance: AzureCloudInstance.None,
273
+ tenant: Constants.EMPTY_STRING,
274
+ },
275
+ skipAuthorityMetadataCache: false,
276
+ };
277
+
278
+ // Default cache options for browser
279
+ const DEFAULT_CACHE_OPTIONS: Required<CacheOptions> = {
280
+ cacheLocation: BrowserCacheLocation.SessionStorage,
281
+ temporaryCacheLocation: BrowserCacheLocation.SessionStorage,
282
+ storeAuthStateInCookie: false,
283
+ secureCookies: false,
284
+ // Default cache migration to true if cache location is localStorage since entries are preserved across tabs/windows. Migration has little to no benefit in sessionStorage and memoryStorage
285
+ cacheMigrationEnabled:
286
+ userInputCache &&
287
+ userInputCache.cacheLocation === BrowserCacheLocation.LocalStorage
288
+ ? true
289
+ : false,
290
+ claimsBasedCachingEnabled: false,
291
+ };
292
+
293
+ // Default logger options for browser
294
+ const DEFAULT_LOGGER_OPTIONS: LoggerOptions = {
295
+ // eslint-disable-next-line @typescript-eslint/no-empty-function
296
+ loggerCallback: (): void => {
297
+ // allow users to not set logger call back
298
+ },
299
+ logLevel: LogLevel.Info,
300
+ piiLoggingEnabled: false,
301
+ };
302
+
303
+ // Default system options for browser
304
+ const DEFAULT_BROWSER_SYSTEM_OPTIONS: Required<BrowserSystemOptions> = {
305
+ ...DEFAULT_SYSTEM_OPTIONS,
306
+ loggerOptions: DEFAULT_LOGGER_OPTIONS,
307
+ networkClient: isBrowserEnvironment
308
+ ? new FetchClient()
309
+ : StubbedNetworkModule,
310
+ navigationClient: new NavigationClient(),
311
+ loadFrameTimeout: 0,
312
+ // If loadFrameTimeout is provided, use that as default.
313
+ windowHashTimeout:
314
+ userInputSystem?.loadFrameTimeout || DEFAULT_POPUP_TIMEOUT_MS,
315
+ iframeHashTimeout:
316
+ userInputSystem?.loadFrameTimeout || DEFAULT_IFRAME_TIMEOUT_MS,
317
+ navigateFrameWait: 0,
318
+ redirectNavigationTimeout: DEFAULT_REDIRECT_TIMEOUT_MS,
319
+ asyncPopups: false,
320
+ allowRedirectInIframe: false,
321
+ allowNativeBroker: false,
322
+ nativeBrokerHandshakeTimeout:
323
+ userInputSystem?.nativeBrokerHandshakeTimeout ||
324
+ DEFAULT_NATIVE_BROKER_HANDSHAKE_TIMEOUT_MS,
325
+ pollIntervalMilliseconds: BrowserConstants.DEFAULT_POLL_INTERVAL_MS,
326
+ };
327
+
328
+ const providedSystemOptions: Required<BrowserSystemOptions> = {
329
+ ...DEFAULT_BROWSER_SYSTEM_OPTIONS,
330
+ ...userInputSystem,
331
+ loggerOptions: userInputSystem?.loggerOptions || DEFAULT_LOGGER_OPTIONS,
332
+ };
333
+
334
+ const DEFAULT_TELEMETRY_OPTIONS: Required<BrowserTelemetryOptions> = {
335
+ application: {
336
+ appName: Constants.EMPTY_STRING,
337
+ appVersion: Constants.EMPTY_STRING,
338
+ },
339
+ client: new StubPerformanceClient(),
340
+ };
341
+
342
+ // Throw an error if user has set OIDCOptions without being in OIDC protocol mode
343
+ if (
344
+ userInputAuth?.protocolMode !== ProtocolMode.OIDC &&
345
+ userInputAuth?.OIDCOptions
346
+ ) {
347
+ const logger = new Logger(providedSystemOptions.loggerOptions);
348
+ logger.warning(
349
+ JSON.stringify(
350
+ createClientConfigurationError(
351
+ ClientConfigurationErrorCodes.cannotSetOIDCOptions
352
+ )
353
+ )
354
+ );
355
+ }
356
+
357
+ // Throw an error if user has set allowNativeBroker to true without being in AAD protocol mode
358
+ if (
359
+ userInputAuth?.protocolMode &&
360
+ userInputAuth.protocolMode !== ProtocolMode.AAD &&
361
+ providedSystemOptions?.allowNativeBroker
362
+ ) {
363
+ throw createClientConfigurationError(
364
+ ClientConfigurationErrorCodes.cannotAllowNativeBroker
365
+ );
366
+ }
367
+
368
+ const overlayedConfig: BrowserConfiguration = {
369
+ auth: {
370
+ ...DEFAULT_AUTH_OPTIONS,
371
+ ...userInputAuth,
372
+ OIDCOptions: {
373
+ ...DEFAULT_AUTH_OPTIONS.OIDCOptions,
374
+ ...userInputAuth?.OIDCOptions,
375
+ },
376
+ },
377
+ cache: { ...DEFAULT_CACHE_OPTIONS, ...userInputCache },
378
+ system: providedSystemOptions,
379
+ telemetry: { ...DEFAULT_TELEMETRY_OPTIONS, ...userInputTelemetry },
380
+ };
381
+
382
+ return overlayedConfig;
383
+ }
@@ -0,0 +1,55 @@
1
+ /*
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+
6
+ import { TeamsAppOperatingContext } from "../operatingcontext/TeamsAppOperatingContext";
7
+ import { StandardOperatingContext } from "../operatingcontext/StandardOperatingContext";
8
+ import { IController } from "./IController";
9
+ import { Logger } from "@azure/msal-common";
10
+ import { Configuration } from "../config/Configuration";
11
+ import { version, name } from "../packageMetadata";
12
+
13
+ export class ControllerFactory {
14
+ protected config: Configuration;
15
+ protected logger: Logger;
16
+
17
+ constructor(config: Configuration) {
18
+ this.config = config;
19
+ const loggerOptions = {
20
+ loggerCallback: undefined,
21
+ piiLoggingEnabled: false,
22
+ logLevel: undefined,
23
+ correlationId: undefined,
24
+ };
25
+ this.logger = new Logger(loggerOptions, name, version);
26
+ }
27
+
28
+ async createController(): Promise<IController> {
29
+ const standard = new StandardOperatingContext(this.config);
30
+ const metaOS = new TeamsAppOperatingContext(this.config);
31
+
32
+ const operatingContexts = [standard.initialize(), metaOS.initialize()];
33
+
34
+ return Promise.all(operatingContexts).then(async () => {
35
+ if (metaOS.isAvailable()) {
36
+ /*
37
+ * pull down metaos module
38
+ * create associated controller
39
+ */
40
+ // return await StandardController.createController(standard);
41
+ const controller = await import("./StandardController");
42
+ return await controller.StandardController.createController(
43
+ standard
44
+ );
45
+ } else if (standard.isAvailable()) {
46
+ const controller = await import("./StandardController");
47
+ return await controller.StandardController.createController(
48
+ standard
49
+ );
50
+ }
51
+
52
+ throw new Error("No controller found.");
53
+ });
54
+ }
55
+ }
@@ -0,0 +1,134 @@
1
+ /*
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+
6
+ import {
7
+ AccountInfo,
8
+ Logger,
9
+ PerformanceCallbackFunction,
10
+ IPerformanceClient,
11
+ CommonSilentFlowRequest,
12
+ AccountFilter,
13
+ } from "@azure/msal-common";
14
+ import { RedirectRequest } from "../request/RedirectRequest";
15
+ import { PopupRequest } from "../request/PopupRequest";
16
+ import { SilentRequest } from "../request/SilentRequest";
17
+ import { SsoSilentRequest } from "../request/SsoSilentRequest";
18
+ import { EndSessionRequest } from "../request/EndSessionRequest";
19
+ import { ApiId, InteractionType, WrapperSKU } from "../utils/BrowserConstants";
20
+ import { INavigationClient } from "../navigation/INavigationClient";
21
+ import { EndSessionPopupRequest } from "../request/EndSessionPopupRequest";
22
+ import { ITokenCache } from "../cache/ITokenCache";
23
+ import { AuthorizationCodeRequest } from "../request/AuthorizationCodeRequest";
24
+ import { BrowserConfiguration } from "../config/Configuration";
25
+ import { EventHandler } from "../event/EventHandler";
26
+ import { AuthenticationResult } from "../response/AuthenticationResult";
27
+ import { EventCallbackFunction } from "../event/EventMessage";
28
+ import { ClearCacheRequest } from "../request/ClearCacheRequest";
29
+
30
+ export interface IController {
31
+ initialize(): Promise<void>;
32
+
33
+ acquireTokenPopup(request: PopupRequest): Promise<AuthenticationResult>;
34
+
35
+ acquireTokenRedirect(request: RedirectRequest): Promise<void>;
36
+
37
+ acquireTokenSilent(
38
+ silentRequest: SilentRequest
39
+ ): Promise<AuthenticationResult>;
40
+
41
+ acquireTokenByCode(
42
+ request: AuthorizationCodeRequest
43
+ ): Promise<AuthenticationResult>;
44
+
45
+ acquireTokenNative(
46
+ request: PopupRequest | SilentRequest | SsoSilentRequest,
47
+ apiId: ApiId,
48
+ accountId?: string
49
+ ): Promise<AuthenticationResult>;
50
+
51
+ acquireTokenByRefreshToken(
52
+ commonRequest: CommonSilentFlowRequest,
53
+ silentRequest: SilentRequest
54
+ ): Promise<AuthenticationResult>;
55
+
56
+ addEventCallback(callback: EventCallbackFunction): string | null;
57
+
58
+ removeEventCallback(callbackId: string): void;
59
+
60
+ addPerformanceCallback(callback: PerformanceCallbackFunction): string;
61
+
62
+ removePerformanceCallback(callbackId: string): boolean;
63
+
64
+ enableAccountStorageEvents(): void;
65
+
66
+ disableAccountStorageEvents(): void;
67
+
68
+ getAccount(accountFilter: AccountFilter): AccountInfo | null;
69
+
70
+ getAccountByHomeId(homeAccountId: string): AccountInfo | null;
71
+
72
+ getAccountByLocalId(localId: string): AccountInfo | null;
73
+
74
+ getAccountByUsername(userName: string): AccountInfo | null;
75
+
76
+ getAllAccounts(accountFilter?: AccountFilter): AccountInfo[];
77
+
78
+ handleRedirectPromise(hash?: string): Promise<AuthenticationResult | null>;
79
+
80
+ loginPopup(request?: PopupRequest): Promise<AuthenticationResult>;
81
+
82
+ loginRedirect(request?: RedirectRequest): Promise<void>;
83
+
84
+ logout(logoutRequest?: EndSessionRequest): Promise<void>;
85
+
86
+ logoutRedirect(logoutRequest?: EndSessionRequest): Promise<void>;
87
+
88
+ logoutPopup(logoutRequest?: EndSessionPopupRequest): Promise<void>;
89
+
90
+ clearCache(logoutRequest?: ClearCacheRequest): Promise<void>;
91
+
92
+ ssoSilent(request: SsoSilentRequest): Promise<AuthenticationResult>;
93
+
94
+ getTokenCache(): ITokenCache;
95
+
96
+ getLogger(): Logger;
97
+
98
+ setLogger(logger: Logger): void;
99
+
100
+ setActiveAccount(account: AccountInfo | null): void;
101
+
102
+ getActiveAccount(): AccountInfo | null;
103
+
104
+ initializeWrapperLibrary(sku: WrapperSKU, version: string): void;
105
+
106
+ setNavigationClient(navigationClient: INavigationClient): void;
107
+
108
+ /** @internal */
109
+ getConfiguration(): BrowserConfiguration;
110
+
111
+ hydrateCache(
112
+ result: AuthenticationResult,
113
+ request:
114
+ | SilentRequest
115
+ | SsoSilentRequest
116
+ | RedirectRequest
117
+ | PopupRequest
118
+ ): Promise<void>;
119
+
120
+ /** @internal */
121
+ isBrowserEnv(): boolean;
122
+
123
+ /** @internal */
124
+ getPerformanceClient(): IPerformanceClient;
125
+
126
+ /** @internal */
127
+ getEventHandler(): EventHandler;
128
+
129
+ /** @internal */
130
+ preflightBrowserEnvironmentCheck(
131
+ interactionType: InteractionType,
132
+ isAppEmbedded?: boolean
133
+ ): void;
134
+ }