@azure/msal-browser 3.19.1 → 3.21.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 (211) hide show
  1. package/dist/app/IPublicClientApplication.d.ts +53 -53
  2. package/dist/app/IPublicClientApplication.mjs +105 -105
  3. package/dist/app/PublicClientApplication.d.ts +293 -293
  4. package/dist/app/PublicClientApplication.mjs +364 -364
  5. package/dist/app/PublicClientNext.d.ts +276 -276
  6. package/dist/app/PublicClientNext.mjs +354 -354
  7. package/dist/broker/nativeBroker/NativeMessageHandler.d.ts +62 -62
  8. package/dist/broker/nativeBroker/NativeMessageHandler.mjs +254 -254
  9. package/dist/broker/nativeBroker/NativeRequest.d.ts +45 -45
  10. package/dist/broker/nativeBroker/NativeResponse.d.ts +48 -48
  11. package/dist/broker/nativeBroker/NativeStatusCodes.d.ts +7 -7
  12. package/dist/broker/nativeBroker/NativeStatusCodes.mjs +11 -11
  13. package/dist/cache/AccountManager.d.ts +48 -48
  14. package/dist/cache/AccountManager.mjs +126 -126
  15. package/dist/cache/AsyncMemoryStorage.d.ts +50 -50
  16. package/dist/cache/AsyncMemoryStorage.mjs +131 -131
  17. package/dist/cache/BrowserCacheManager.d.ts +410 -385
  18. package/dist/cache/BrowserCacheManager.d.ts.map +1 -1
  19. package/dist/cache/BrowserCacheManager.mjs +1364 -1294
  20. package/dist/cache/BrowserCacheManager.mjs.map +1 -1
  21. package/dist/cache/BrowserStorage.d.ts +11 -11
  22. package/dist/cache/BrowserStorage.mjs +32 -32
  23. package/dist/cache/DatabaseStorage.d.ts +56 -56
  24. package/dist/cache/DatabaseStorage.mjs +200 -200
  25. package/dist/cache/IAsyncStorage.d.ts +27 -27
  26. package/dist/cache/ITokenCache.d.ts +11 -11
  27. package/dist/cache/IWindowStorage.d.ts +27 -27
  28. package/dist/cache/MemoryStorage.d.ts +11 -11
  29. package/dist/cache/MemoryStorage.mjs +31 -31
  30. package/dist/cache/TokenCache.d.ts +77 -77
  31. package/dist/cache/TokenCache.mjs +195 -195
  32. package/dist/config/Configuration.d.ts +213 -208
  33. package/dist/config/Configuration.d.ts.map +1 -1
  34. package/dist/config/Configuration.mjs +128 -128
  35. package/dist/config/Configuration.mjs.map +1 -1
  36. package/dist/controllers/ControllerFactory.d.ts +5 -5
  37. package/dist/controllers/ControllerFactory.mjs +25 -25
  38. package/dist/controllers/IController.d.ts +60 -60
  39. package/dist/controllers/NestedAppAuthController.d.ts +202 -202
  40. package/dist/controllers/NestedAppAuthController.mjs +473 -473
  41. package/dist/controllers/StandardController.d.ts +405 -405
  42. package/dist/controllers/StandardController.d.ts.map +1 -1
  43. package/dist/controllers/StandardController.mjs +1334 -1316
  44. package/dist/controllers/StandardController.mjs.map +1 -1
  45. package/dist/controllers/UnknownOperatingContextController.d.ts +86 -86
  46. package/dist/controllers/UnknownOperatingContextController.mjs +256 -256
  47. package/dist/crypto/BrowserCrypto.d.ts +52 -52
  48. package/dist/crypto/BrowserCrypto.mjs +151 -151
  49. package/dist/crypto/CryptoOps.d.ts +74 -74
  50. package/dist/crypto/CryptoOps.mjs +176 -176
  51. package/dist/crypto/PkceGenerator.d.ts +8 -8
  52. package/dist/crypto/PkceGenerator.mjs +54 -54
  53. package/dist/crypto/SignedHttpRequest.d.ts +30 -30
  54. package/dist/crypto/SignedHttpRequest.mjs +39 -39
  55. package/dist/encode/Base64Decode.d.ts +9 -9
  56. package/dist/encode/Base64Decode.mjs +36 -36
  57. package/dist/encode/Base64Encode.d.ts +19 -19
  58. package/dist/encode/Base64Encode.mjs +43 -43
  59. package/dist/error/BrowserAuthError.d.ts +256 -255
  60. package/dist/error/BrowserAuthError.d.ts.map +1 -1
  61. package/dist/error/BrowserAuthError.mjs +265 -264
  62. package/dist/error/BrowserAuthError.mjs.map +1 -1
  63. package/dist/error/BrowserAuthErrorCodes.d.ts +47 -46
  64. package/dist/error/BrowserAuthErrorCodes.d.ts.map +1 -1
  65. package/dist/error/BrowserAuthErrorCodes.mjs +53 -52
  66. package/dist/error/BrowserAuthErrorCodes.mjs.map +1 -1
  67. package/dist/error/BrowserConfigurationAuthError.d.ts +33 -33
  68. package/dist/error/BrowserConfigurationAuthError.mjs +40 -40
  69. package/dist/error/BrowserConfigurationAuthError.mjs.map +1 -1
  70. package/dist/error/BrowserConfigurationAuthErrorCodes.d.ts +3 -3
  71. package/dist/error/BrowserConfigurationAuthErrorCodes.mjs +7 -7
  72. package/dist/error/NativeAuthError.d.ts +29 -29
  73. package/dist/error/NativeAuthError.mjs +60 -60
  74. package/dist/error/NativeAuthErrorCodes.d.ts +2 -2
  75. package/dist/error/NativeAuthErrorCodes.mjs +6 -6
  76. package/dist/error/NestedAppAuthError.d.ts +14 -14
  77. package/dist/error/NestedAppAuthError.mjs +23 -23
  78. package/dist/event/EventHandler.d.ts +41 -41
  79. package/dist/event/EventHandler.mjs +125 -125
  80. package/dist/event/EventMessage.d.ts +25 -25
  81. package/dist/event/EventMessage.mjs +68 -68
  82. package/dist/event/EventType.d.ts +29 -29
  83. package/dist/event/EventType.mjs +32 -32
  84. package/dist/index.d.ts +40 -40
  85. package/dist/index.mjs +1 -1
  86. package/dist/interaction_client/BaseInteractionClient.d.ts +50 -50
  87. package/dist/interaction_client/BaseInteractionClient.mjs +106 -106
  88. package/dist/interaction_client/HybridSpaAuthorizationCodeClient.d.ts +4 -4
  89. package/dist/interaction_client/HybridSpaAuthorizationCodeClient.mjs +10 -10
  90. package/dist/interaction_client/NativeInteractionClient.d.ts +151 -143
  91. package/dist/interaction_client/NativeInteractionClient.d.ts.map +1 -1
  92. package/dist/interaction_client/NativeInteractionClient.mjs +624 -584
  93. package/dist/interaction_client/NativeInteractionClient.mjs.map +1 -1
  94. package/dist/interaction_client/PopupClient.d.ts +118 -105
  95. package/dist/interaction_client/PopupClient.d.ts.map +1 -1
  96. package/dist/interaction_client/PopupClient.mjs +460 -434
  97. package/dist/interaction_client/PopupClient.mjs.map +1 -1
  98. package/dist/interaction_client/RedirectClient.d.ts +50 -50
  99. package/dist/interaction_client/RedirectClient.d.ts.map +1 -1
  100. package/dist/interaction_client/RedirectClient.mjs +349 -317
  101. package/dist/interaction_client/RedirectClient.mjs.map +1 -1
  102. package/dist/interaction_client/SilentAuthCodeClient.d.ts +23 -23
  103. package/dist/interaction_client/SilentAuthCodeClient.mjs +57 -57
  104. package/dist/interaction_client/SilentCacheClient.d.ts +16 -16
  105. package/dist/interaction_client/SilentCacheClient.mjs +42 -42
  106. package/dist/interaction_client/SilentIframeClient.d.ts +32 -32
  107. package/dist/interaction_client/SilentIframeClient.d.ts.map +1 -1
  108. package/dist/interaction_client/SilentIframeClient.mjs +111 -101
  109. package/dist/interaction_client/SilentIframeClient.mjs.map +1 -1
  110. package/dist/interaction_client/SilentRefreshClient.d.ts +20 -20
  111. package/dist/interaction_client/SilentRefreshClient.mjs +47 -47
  112. package/dist/interaction_client/StandardInteractionClient.d.ts +48 -48
  113. package/dist/interaction_client/StandardInteractionClient.mjs +199 -199
  114. package/dist/interaction_handler/InteractionHandler.d.ts +33 -33
  115. package/dist/interaction_handler/InteractionHandler.mjs +93 -93
  116. package/dist/interaction_handler/RedirectHandler.d.ts +32 -32
  117. package/dist/interaction_handler/RedirectHandler.d.ts.map +1 -1
  118. package/dist/interaction_handler/RedirectHandler.mjs +135 -134
  119. package/dist/interaction_handler/RedirectHandler.mjs.map +1 -1
  120. package/dist/interaction_handler/SilentHandler.d.ts +13 -13
  121. package/dist/interaction_handler/SilentHandler.mjs +134 -134
  122. package/dist/naa/AccountInfo.d.ts +11 -11
  123. package/dist/naa/AuthBridge.d.ts +8 -8
  124. package/dist/naa/AuthResult.d.ts +6 -6
  125. package/dist/naa/BridgeAccountContext.d.ts +12 -12
  126. package/dist/naa/BridgeCapabilities.d.ts +3 -3
  127. package/dist/naa/BridgeError.d.ts +9 -9
  128. package/dist/naa/BridgeError.mjs +7 -7
  129. package/dist/naa/BridgeProxy.d.ts +67 -67
  130. package/dist/naa/BridgeProxy.d.ts.map +1 -1
  131. package/dist/naa/BridgeProxy.mjs +153 -148
  132. package/dist/naa/BridgeProxy.mjs.map +1 -1
  133. package/dist/naa/BridgeRequest.d.ts +7 -7
  134. package/dist/naa/BridgeRequestEnvelope.d.ts +12 -12
  135. package/dist/naa/BridgeResponseEnvelope.d.ts +13 -13
  136. package/dist/naa/BridgeStatusCode.d.ts +11 -11
  137. package/dist/naa/BridgeStatusCode.mjs +14 -14
  138. package/dist/naa/IBridgeProxy.d.ts +10 -10
  139. package/dist/naa/InitContext.d.ts +8 -8
  140. package/dist/naa/TokenRequest.d.ts +18 -18
  141. package/dist/naa/TokenResponse.d.ts +13 -13
  142. package/dist/naa/mapping/NestedAppAuthAdapter.d.ts +35 -35
  143. package/dist/naa/mapping/NestedAppAuthAdapter.mjs +179 -179
  144. package/dist/navigation/INavigationClient.d.ts +16 -16
  145. package/dist/navigation/NavigationClient.d.ts +22 -22
  146. package/dist/navigation/NavigationClient.mjs +40 -40
  147. package/dist/navigation/NavigationOptions.d.ts +12 -12
  148. package/dist/network/FetchClient.d.ts +26 -26
  149. package/dist/network/FetchClient.mjs +99 -99
  150. package/dist/operatingcontext/BaseOperatingContext.d.ts +41 -41
  151. package/dist/operatingcontext/BaseOperatingContext.mjs +94 -94
  152. package/dist/operatingcontext/NestedAppOperatingContext.d.ts +34 -34
  153. package/dist/operatingcontext/NestedAppOperatingContext.mjs +71 -71
  154. package/dist/operatingcontext/StandardOperatingContext.d.ts +25 -25
  155. package/dist/operatingcontext/StandardOperatingContext.mjs +43 -43
  156. package/dist/operatingcontext/UnknownOperatingContext.d.ts +25 -25
  157. package/dist/operatingcontext/UnknownOperatingContext.mjs +42 -42
  158. package/dist/packageMetadata.d.ts +2 -2
  159. package/dist/packageMetadata.mjs +4 -4
  160. package/dist/request/AuthorizationCodeRequest.d.ts +8 -8
  161. package/dist/request/AuthorizationUrlRequest.d.ts +8 -8
  162. package/dist/request/ClearCacheRequest.d.ts +10 -10
  163. package/dist/request/EndSessionPopupRequest.d.ts +18 -18
  164. package/dist/request/EndSessionRequest.d.ts +15 -15
  165. package/dist/request/InitializeApplicationRequest.d.ts +8 -8
  166. package/dist/request/PopupRequest.d.ts +34 -34
  167. package/dist/request/PopupWindowAttributes.d.ts +15 -15
  168. package/dist/request/RedirectRequest.d.ts +40 -35
  169. package/dist/request/RedirectRequest.d.ts.map +1 -1
  170. package/dist/request/RequestHelpers.d.ts +13 -13
  171. package/dist/request/RequestHelpers.mjs +53 -53
  172. package/dist/request/SilentRequest.d.ts +33 -33
  173. package/dist/request/SsoSilentRequest.d.ts +29 -29
  174. package/dist/response/AuthenticationResult.d.ts +4 -4
  175. package/dist/response/ResponseHandler.d.ts +7 -7
  176. package/dist/response/ResponseHandler.mjs +36 -36
  177. package/dist/telemetry/BrowserPerformanceClient.d.ts +38 -34
  178. package/dist/telemetry/BrowserPerformanceClient.d.ts.map +1 -1
  179. package/dist/telemetry/BrowserPerformanceClient.mjs +163 -163
  180. package/dist/telemetry/BrowserPerformanceClient.mjs.map +1 -1
  181. package/dist/telemetry/BrowserPerformanceMeasurement.d.ts +21 -21
  182. package/dist/telemetry/BrowserPerformanceMeasurement.mjs +92 -92
  183. package/dist/utils/BrowserConstants.d.ts +182 -180
  184. package/dist/utils/BrowserConstants.d.ts.map +1 -1
  185. package/dist/utils/BrowserConstants.mjs +214 -212
  186. package/dist/utils/BrowserConstants.mjs.map +1 -1
  187. package/dist/utils/BrowserProtocolUtils.d.ts +11 -11
  188. package/dist/utils/BrowserProtocolUtils.mjs +21 -21
  189. package/dist/utils/BrowserUtils.d.ts +75 -75
  190. package/dist/utils/BrowserUtils.mjs +157 -157
  191. package/lib/msal-browser.cjs +19028 -18759
  192. package/lib/msal-browser.cjs.map +1 -1
  193. package/lib/msal-browser.js +19028 -18759
  194. package/lib/msal-browser.js.map +1 -1
  195. package/lib/msal-browser.min.js +65 -65
  196. package/package.json +2 -2
  197. package/src/cache/BrowserCacheManager.ts +95 -0
  198. package/src/config/Configuration.ts +9 -1
  199. package/src/controllers/StandardController.ts +30 -12
  200. package/src/error/BrowserAuthError.ts +2 -0
  201. package/src/error/BrowserAuthErrorCodes.ts +1 -0
  202. package/src/interaction_client/NativeInteractionClient.ts +105 -54
  203. package/src/interaction_client/PopupClient.ts +202 -117
  204. package/src/interaction_client/RedirectClient.ts +62 -2
  205. package/src/interaction_client/SilentIframeClient.ts +41 -3
  206. package/src/interaction_handler/RedirectHandler.ts +1 -0
  207. package/src/naa/BridgeProxy.ts +7 -2
  208. package/src/packageMetadata.ts +1 -1
  209. package/src/request/RedirectRequest.ts +5 -0
  210. package/src/telemetry/BrowserPerformanceClient.ts +1 -1
  211. package/src/utils/BrowserConstants.ts +2 -0
@@ -1,386 +1,411 @@
1
- import { CommonAuthorizationCodeRequest, ICrypto, AccountEntity, IdTokenEntity, AccessTokenEntity, RefreshTokenEntity, AppMetadataEntity, CacheManager, ServerTelemetryEntity, ThrottlingEntity, Logger, AuthorityMetadataEntity, AccountInfo, ValidCredentialType, TokenKeys, CredentialType, CacheRecord, IPerformanceClient, StaticAuthorityOptions, StoreInCache } from "@azure/msal-common";
2
- import { CacheOptions } from "../config/Configuration";
3
- import { BrowserCacheLocation, InteractionType } from "../utils/BrowserConstants";
4
- import { MemoryStorage } from "./MemoryStorage";
5
- import { IWindowStorage } from "./IWindowStorage";
6
- import { NativeTokenRequest } from "../broker/nativeBroker/NativeRequest";
7
- import { AuthenticationResult } from "../response/AuthenticationResult";
8
- import { SilentRequest } from "../request/SilentRequest";
9
- import { SsoSilentRequest } from "../request/SsoSilentRequest";
10
- import { RedirectRequest } from "../request/RedirectRequest";
11
- import { PopupRequest } from "../request/PopupRequest";
12
- /**
13
- * This class implements the cache storage interface for MSAL through browser local or session storage.
14
- * Cookies are only used if storeAuthStateInCookie is true, and are only used for
15
- * parameters such as state and nonce, generally.
16
- */
17
- export declare class BrowserCacheManager extends CacheManager {
18
- protected cacheConfig: Required<CacheOptions>;
19
- protected browserStorage: IWindowStorage<string>;
20
- protected internalStorage: MemoryStorage<string>;
21
- protected temporaryCacheStorage: IWindowStorage<string>;
22
- protected logger: Logger;
23
- protected performanceClient?: IPerformanceClient;
24
- protected readonly COOKIE_LIFE_MULTIPLIER: number;
25
- constructor(clientId: string, cacheConfig: Required<CacheOptions>, cryptoImpl: ICrypto, logger: Logger, staticAuthorityOptions?: StaticAuthorityOptions, performanceClient?: IPerformanceClient);
26
- /**
27
- * Returns a window storage class implementing the IWindowStorage interface that corresponds to the configured cacheLocation.
28
- * @param cacheLocation
29
- */
30
- protected setupBrowserStorage(cacheLocation: BrowserCacheLocation | string): IWindowStorage<string>;
31
- /**
32
- * Returns a window storage class implementing the IWindowStorage interface that corresponds to the configured temporaryCacheLocation.
33
- * @param temporaryCacheLocation
34
- * @param cacheLocation
35
- */
36
- protected setupTemporaryCacheStorage(temporaryCacheLocation: BrowserCacheLocation | string, cacheLocation: BrowserCacheLocation | string): IWindowStorage<string>;
37
- /**
38
- * Migrate all old cache entries to new schema. No rollback supported.
39
- * @param storeAuthStateInCookie
40
- */
41
- protected migrateCacheEntries(): void;
42
- /**
43
- * Searches all cache entries for MSAL accounts and creates the account key map
44
- * This is used to migrate users from older versions of MSAL which did not create the map.
45
- * @returns
46
- */
47
- private createKeyMaps;
48
- /**
49
- * Parses passed value as JSON object, JSON.parse() will throw an error.
50
- * @param input
51
- */
52
- protected validateAndParseJson(jsonValue: string): object | null;
53
- /**
54
- * fetches the entry from the browser storage based off the key
55
- * @param key
56
- */
57
- getItem(key: string): string | null;
58
- /**
59
- * sets the entry in the browser storage
60
- * @param key
61
- * @param value
62
- */
63
- setItem(key: string, value: string): void;
64
- /**
65
- * fetch the account entity from the platform cache
66
- * @param accountKey
67
- */
68
- getAccount(accountKey: string, logger?: Logger): AccountEntity | null;
69
- /**
70
- * Reads account from cache, deserializes it into an account entity and returns it.
71
- * If account is not found from the key, returns null and removes key from map.
72
- * @param accountKey
73
- * @returns
74
- */
75
- getCachedAccountEntity(accountKey: string): AccountEntity | null;
76
- /**
77
- * set account entity in the platform cache
78
- * @param account
79
- */
80
- setAccount(account: AccountEntity): void;
81
- /**
82
- * Returns the array of account keys currently cached
83
- * @returns
84
- */
85
- getAccountKeys(): Array<string>;
86
- /**
87
- * Add a new account to the key map
88
- * @param key
89
- */
90
- addAccountKeyToMap(key: string): void;
91
- /**
92
- * Remove an account from the key map
93
- * @param key
94
- */
95
- removeAccountKeyFromMap(key: string): void;
96
- /**
97
- * Extends inherited removeAccount function to include removal of the account key from the map
98
- * @param key
99
- */
100
- removeAccount(key: string): Promise<void>;
101
- /**
102
- * Remove account entity from the platform cache if it's outdated
103
- * @param accountKey
104
- */
105
- removeOutdatedAccount(accountKey: string): void;
106
- /**
107
- * Removes given idToken from the cache and from the key map
108
- * @param key
109
- */
110
- removeIdToken(key: string): void;
111
- /**
112
- * Removes given accessToken from the cache and from the key map
113
- * @param key
114
- */
115
- removeAccessToken(key: string): Promise<void>;
116
- /**
117
- * Removes given refreshToken from the cache and from the key map
118
- * @param key
119
- */
120
- removeRefreshToken(key: string): void;
121
- /**
122
- * Gets the keys for the cached tokens associated with this clientId
123
- * @returns
124
- */
125
- getTokenKeys(): TokenKeys;
126
- /**
127
- * Adds the given key to the token key map
128
- * @param key
129
- * @param type
130
- */
131
- addTokenKey(key: string, type: CredentialType): void;
132
- /**
133
- * Removes the given key from the token key map
134
- * @param key
135
- * @param type
136
- */
137
- removeTokenKey(key: string, type: CredentialType): void;
138
- /**
139
- * generates idToken entity from a string
140
- * @param idTokenKey
141
- */
142
- getIdTokenCredential(idTokenKey: string): IdTokenEntity | null;
143
- /**
144
- * set IdToken credential to the platform cache
145
- * @param idToken
146
- */
147
- setIdTokenCredential(idToken: IdTokenEntity): void;
148
- /**
149
- * generates accessToken entity from a string
150
- * @param key
151
- */
152
- getAccessTokenCredential(accessTokenKey: string): AccessTokenEntity | null;
153
- /**
154
- * set accessToken credential to the platform cache
155
- * @param accessToken
156
- */
157
- setAccessTokenCredential(accessToken: AccessTokenEntity): void;
158
- /**
159
- * generates refreshToken entity from a string
160
- * @param refreshTokenKey
161
- */
162
- getRefreshTokenCredential(refreshTokenKey: string): RefreshTokenEntity | null;
163
- /**
164
- * set refreshToken credential to the platform cache
165
- * @param refreshToken
166
- */
167
- setRefreshTokenCredential(refreshToken: RefreshTokenEntity): void;
168
- /**
169
- * fetch appMetadata entity from the platform cache
170
- * @param appMetadataKey
171
- */
172
- getAppMetadata(appMetadataKey: string): AppMetadataEntity | null;
173
- /**
174
- * set appMetadata entity to the platform cache
175
- * @param appMetadata
176
- */
177
- setAppMetadata(appMetadata: AppMetadataEntity): void;
178
- /**
179
- * fetch server telemetry entity from the platform cache
180
- * @param serverTelemetryKey
181
- */
182
- getServerTelemetry(serverTelemetryKey: string): ServerTelemetryEntity | null;
183
- /**
184
- * set server telemetry entity to the platform cache
185
- * @param serverTelemetryKey
186
- * @param serverTelemetry
187
- */
188
- setServerTelemetry(serverTelemetryKey: string, serverTelemetry: ServerTelemetryEntity): void;
189
- /**
190
- *
191
- */
192
- getAuthorityMetadata(key: string): AuthorityMetadataEntity | null;
193
- /**
194
- *
195
- */
196
- getAuthorityMetadataKeys(): Array<string>;
197
- /**
198
- * Sets wrapper metadata in memory
199
- * @param wrapperSKU
200
- * @param wrapperVersion
201
- */
202
- setWrapperMetadata(wrapperSKU: string, wrapperVersion: string): void;
203
- /**
204
- * Returns wrapper metadata from in-memory storage
205
- */
206
- getWrapperMetadata(): [string, string];
207
- /**
208
- *
209
- * @param entity
210
- */
211
- setAuthorityMetadata(key: string, entity: AuthorityMetadataEntity): void;
212
- /**
213
- * Gets the active account
214
- */
215
- getActiveAccount(): AccountInfo | null;
216
- /**
217
- * Sets the active account's localAccountId in cache
218
- * @param account
219
- */
220
- setActiveAccount(account: AccountInfo | null): void;
221
- /**
222
- * fetch throttling entity from the platform cache
223
- * @param throttlingCacheKey
224
- */
225
- getThrottlingCache(throttlingCacheKey: string): ThrottlingEntity | null;
226
- /**
227
- * set throttling entity to the platform cache
228
- * @param throttlingCacheKey
229
- * @param throttlingCache
230
- */
231
- setThrottlingCache(throttlingCacheKey: string, throttlingCache: ThrottlingEntity): void;
232
- /**
233
- * Gets cache item with given key.
234
- * Will retrieve from cookies if storeAuthStateInCookie is set to true.
235
- * @param key
236
- */
237
- getTemporaryCache(cacheKey: string, generateKey?: boolean): string | null;
238
- /**
239
- * Sets the cache item with the key and value given.
240
- * Stores in cookie if storeAuthStateInCookie is set to true.
241
- * This can cause cookie overflow if used incorrectly.
242
- * @param key
243
- * @param value
244
- */
245
- setTemporaryCache(cacheKey: string, value: string, generateKey?: boolean): void;
246
- /**
247
- * Removes the cache item with the given key.
248
- * @param key
249
- */
250
- removeItem(key: string): void;
251
- /**
252
- * Removes the temporary cache item with the given key.
253
- * Will also clear the cookie item if storeAuthStateInCookie is set to true.
254
- * @param key
255
- */
256
- removeTemporaryItem(key: string): void;
257
- /**
258
- * Gets all keys in window.
259
- */
260
- getKeys(): string[];
261
- /**
262
- * Clears all cache entries created by MSAL.
263
- */
264
- clear(): Promise<void>;
265
- /**
266
- * Clears all access tokes that have claims prior to saving the current one
267
- * @param performanceClient {IPerformanceClient}
268
- * @param correlationId {string} correlation id
269
- * @returns
270
- */
271
- clearTokensAndKeysWithClaims(performanceClient: IPerformanceClient, correlationId: string): Promise<void>;
272
- /**
273
- * Add value to cookies
274
- * @param cookieName
275
- * @param cookieValue
276
- * @param expires
277
- * @deprecated
278
- */
279
- setItemCookie(cookieName: string, cookieValue: string, expires?: number): void;
280
- /**
281
- * Get one item by key from cookies
282
- * @param cookieName
283
- * @deprecated
284
- */
285
- getItemCookie(cookieName: string): string;
286
- /**
287
- * Clear all msal-related cookies currently set in the browser. Should only be used to clear temporary cache items.
288
- * @deprecated
289
- */
290
- clearMsalCookies(): void;
291
- /**
292
- * Clear an item in the cookies by key
293
- * @param cookieName
294
- * @deprecated
295
- */
296
- clearItemCookie(cookieName: string): void;
297
- /**
298
- * Get cookie expiration time
299
- * @param cookieLifeDays
300
- * @deprecated
301
- */
302
- getCookieExpirationTime(cookieLifeDays: number): string;
303
- /**
304
- * Prepend msal.<client-id> to each key; Skip for any JSON object as Key (defined schemas do not need the key appended: AccessToken Keys or the upcoming schema)
305
- * @param key
306
- * @param addInstanceId
307
- */
308
- generateCacheKey(key: string): string;
309
- /**
310
- * Create authorityKey to cache authority
311
- * @param state
312
- */
313
- generateAuthorityKey(stateString: string): string;
314
- /**
315
- * Create Nonce key to cache nonce
316
- * @param state
317
- */
318
- generateNonceKey(stateString: string): string;
319
- /**
320
- * Creates full cache key for the request state
321
- * @param stateString State string for the request
322
- */
323
- generateStateKey(stateString: string): string;
324
- /**
325
- * Gets the cached authority based on the cached state. Returns empty if no cached state found.
326
- */
327
- getCachedAuthority(cachedState: string): string | null;
328
- /**
329
- * Updates account, authority, and state in cache
330
- * @param serverAuthenticationRequest
331
- * @param account
332
- */
333
- updateCacheEntries(state: string, nonce: string, authorityInstance: string, loginHint: string, account: AccountInfo | null): void;
334
- /**
335
- * Reset all temporary cache items
336
- * @param state
337
- */
338
- resetRequestCache(state: string): void;
339
- /**
340
- * Removes temporary cache for the provided state
341
- * @param stateString
342
- */
343
- cleanRequestByState(stateString: string): void;
344
- /**
345
- * Looks in temporary cache for any state values with the provided interactionType and removes all temporary cache items for that state
346
- * Used in scenarios where temp cache needs to be cleaned but state is not known, such as clicking browser back button.
347
- * @param interactionType
348
- */
349
- cleanRequestByInteractionType(interactionType: InteractionType): void;
350
- cacheCodeRequest(authCodeRequest: CommonAuthorizationCodeRequest): void;
351
- /**
352
- * Gets the token exchange parameters from the cache. Throws an error if nothing is found.
353
- */
354
- getCachedRequest(state: string): CommonAuthorizationCodeRequest;
355
- /**
356
- * Gets cached native request for redirect flows
357
- */
358
- getCachedNativeRequest(): NativeTokenRequest | null;
359
- isInteractionInProgress(matchClientId?: boolean): boolean;
360
- getInteractionInProgress(): string | null;
361
- setInteractionInProgress(inProgress: boolean): void;
362
- /**
363
- * Returns username retrieved from ADAL or MSAL v1 idToken
364
- * @deprecated
365
- */
366
- getLegacyLoginHint(): string | null;
367
- /**
368
- * Updates a credential's cache key if the current cache key is outdated
369
- */
370
- updateCredentialCacheKey(currentCacheKey: string, credential: ValidCredentialType): string;
371
- /**
372
- * Builds credential entities from AuthenticationResult object and saves the resulting credentials to the cache
373
- * @param result
374
- * @param request
375
- */
376
- hydrateCache(result: AuthenticationResult, request: SilentRequest | SsoSilentRequest | RedirectRequest | PopupRequest): Promise<void>;
377
- /**
378
- * saves a cache record
379
- * @param cacheRecord {CacheRecord}
380
- * @param storeInCache {?StoreInCache}
381
- * @param correlationId {?string} correlation id
382
- */
383
- saveCacheRecord(cacheRecord: CacheRecord, storeInCache?: StoreInCache, correlationId?: string): Promise<void>;
384
- }
385
- export declare const DEFAULT_BROWSER_CACHE_MANAGER: (clientId: string, logger: Logger) => BrowserCacheManager;
1
+ import { CommonAuthorizationCodeRequest, ICrypto, AccountEntity, IdTokenEntity, AccessTokenEntity, RefreshTokenEntity, AppMetadataEntity, CacheManager, ServerTelemetryEntity, ThrottlingEntity, Logger, AuthorityMetadataEntity, AccountInfo, ValidCredentialType, TokenKeys, CredentialType, CacheRecord, IPerformanceClient, StaticAuthorityOptions, StoreInCache } from "@azure/msal-common";
2
+ import { CacheOptions } from "../config/Configuration";
3
+ import { BrowserCacheLocation, InteractionType } from "../utils/BrowserConstants";
4
+ import { MemoryStorage } from "./MemoryStorage";
5
+ import { IWindowStorage } from "./IWindowStorage";
6
+ import { NativeTokenRequest } from "../broker/nativeBroker/NativeRequest";
7
+ import { AuthenticationResult } from "../response/AuthenticationResult";
8
+ import { SilentRequest } from "../request/SilentRequest";
9
+ import { SsoSilentRequest } from "../request/SsoSilentRequest";
10
+ import { RedirectRequest } from "../request/RedirectRequest";
11
+ import { PopupRequest } from "../request/PopupRequest";
12
+ /**
13
+ * This class implements the cache storage interface for MSAL through browser local or session storage.
14
+ * Cookies are only used if storeAuthStateInCookie is true, and are only used for
15
+ * parameters such as state and nonce, generally.
16
+ */
17
+ export declare class BrowserCacheManager extends CacheManager {
18
+ protected cacheConfig: Required<CacheOptions>;
19
+ protected browserStorage: IWindowStorage<string>;
20
+ protected internalStorage: MemoryStorage<string>;
21
+ protected temporaryCacheStorage: IWindowStorage<string>;
22
+ protected logger: Logger;
23
+ protected performanceClient?: IPerformanceClient;
24
+ protected readonly COOKIE_LIFE_MULTIPLIER: number;
25
+ constructor(clientId: string, cacheConfig: Required<CacheOptions>, cryptoImpl: ICrypto, logger: Logger, staticAuthorityOptions?: StaticAuthorityOptions, performanceClient?: IPerformanceClient);
26
+ /**
27
+ * Returns a window storage class implementing the IWindowStorage interface that corresponds to the configured cacheLocation.
28
+ * @param cacheLocation
29
+ */
30
+ protected setupBrowserStorage(cacheLocation: BrowserCacheLocation | string): IWindowStorage<string>;
31
+ /**
32
+ * Returns a window storage class implementing the IWindowStorage interface that corresponds to the configured temporaryCacheLocation.
33
+ * @param temporaryCacheLocation
34
+ * @param cacheLocation
35
+ */
36
+ protected setupTemporaryCacheStorage(temporaryCacheLocation: BrowserCacheLocation | string, cacheLocation: BrowserCacheLocation | string): IWindowStorage<string>;
37
+ /**
38
+ * Migrate all old cache entries to new schema. No rollback supported.
39
+ * @param storeAuthStateInCookie
40
+ */
41
+ protected migrateCacheEntries(): void;
42
+ /**
43
+ * Searches all cache entries for MSAL accounts and creates the account key map
44
+ * This is used to migrate users from older versions of MSAL which did not create the map.
45
+ * @returns
46
+ */
47
+ private createKeyMaps;
48
+ /**
49
+ * Parses passed value as JSON object, JSON.parse() will throw an error.
50
+ * @param input
51
+ */
52
+ protected validateAndParseJson(jsonValue: string): object | null;
53
+ /**
54
+ * fetches the entry from the browser storage based off the key
55
+ * @param key
56
+ */
57
+ getItem(key: string): string | null;
58
+ /**
59
+ * sets the entry in the browser storage
60
+ * @param key
61
+ * @param value
62
+ */
63
+ setItem(key: string, value: string): void;
64
+ /**
65
+ * fetch the account entity from the platform cache
66
+ * @param accountKey
67
+ */
68
+ getAccount(accountKey: string, logger?: Logger): AccountEntity | null;
69
+ /**
70
+ * Reads account from cache, deserializes it into an account entity and returns it.
71
+ * If account is not found from the key, returns null and removes key from map.
72
+ * @param accountKey
73
+ * @returns
74
+ */
75
+ getCachedAccountEntity(accountKey: string): AccountEntity | null;
76
+ /**
77
+ * set account entity in the platform cache
78
+ * @param account
79
+ */
80
+ setAccount(account: AccountEntity): void;
81
+ /**
82
+ * Returns the array of account keys currently cached
83
+ * @returns
84
+ */
85
+ getAccountKeys(): Array<string>;
86
+ /**
87
+ * Add a new account to the key map
88
+ * @param key
89
+ */
90
+ addAccountKeyToMap(key: string): void;
91
+ /**
92
+ * Remove an account from the key map
93
+ * @param key
94
+ */
95
+ removeAccountKeyFromMap(key: string): void;
96
+ /**
97
+ * Extends inherited removeAccount function to include removal of the account key from the map
98
+ * @param key
99
+ */
100
+ removeAccount(key: string): Promise<void>;
101
+ /**
102
+ * Remove account entity from the platform cache if it's outdated
103
+ * @param accountKey
104
+ */
105
+ removeOutdatedAccount(accountKey: string): void;
106
+ /**
107
+ * Removes given idToken from the cache and from the key map
108
+ * @param key
109
+ */
110
+ removeIdToken(key: string): void;
111
+ /**
112
+ * Removes given accessToken from the cache and from the key map
113
+ * @param key
114
+ */
115
+ removeAccessToken(key: string): Promise<void>;
116
+ /**
117
+ * Removes given refreshToken from the cache and from the key map
118
+ * @param key
119
+ */
120
+ removeRefreshToken(key: string): void;
121
+ /**
122
+ * Gets the keys for the cached tokens associated with this clientId
123
+ * @returns
124
+ */
125
+ getTokenKeys(): TokenKeys;
126
+ /**
127
+ * Adds the given key to the token key map
128
+ * @param key
129
+ * @param type
130
+ */
131
+ addTokenKey(key: string, type: CredentialType): void;
132
+ /**
133
+ * Removes the given key from the token key map
134
+ * @param key
135
+ * @param type
136
+ */
137
+ removeTokenKey(key: string, type: CredentialType): void;
138
+ /**
139
+ * generates idToken entity from a string
140
+ * @param idTokenKey
141
+ */
142
+ getIdTokenCredential(idTokenKey: string): IdTokenEntity | null;
143
+ /**
144
+ * set IdToken credential to the platform cache
145
+ * @param idToken
146
+ */
147
+ setIdTokenCredential(idToken: IdTokenEntity): void;
148
+ /**
149
+ * generates accessToken entity from a string
150
+ * @param key
151
+ */
152
+ getAccessTokenCredential(accessTokenKey: string): AccessTokenEntity | null;
153
+ /**
154
+ * set accessToken credential to the platform cache
155
+ * @param accessToken
156
+ */
157
+ setAccessTokenCredential(accessToken: AccessTokenEntity): void;
158
+ /**
159
+ * generates refreshToken entity from a string
160
+ * @param refreshTokenKey
161
+ */
162
+ getRefreshTokenCredential(refreshTokenKey: string): RefreshTokenEntity | null;
163
+ /**
164
+ * set refreshToken credential to the platform cache
165
+ * @param refreshToken
166
+ */
167
+ setRefreshTokenCredential(refreshToken: RefreshTokenEntity): void;
168
+ /**
169
+ * fetch appMetadata entity from the platform cache
170
+ * @param appMetadataKey
171
+ */
172
+ getAppMetadata(appMetadataKey: string): AppMetadataEntity | null;
173
+ /**
174
+ * set appMetadata entity to the platform cache
175
+ * @param appMetadata
176
+ */
177
+ setAppMetadata(appMetadata: AppMetadataEntity): void;
178
+ /**
179
+ * fetch server telemetry entity from the platform cache
180
+ * @param serverTelemetryKey
181
+ */
182
+ getServerTelemetry(serverTelemetryKey: string): ServerTelemetryEntity | null;
183
+ /**
184
+ * set server telemetry entity to the platform cache
185
+ * @param serverTelemetryKey
186
+ * @param serverTelemetry
187
+ */
188
+ setServerTelemetry(serverTelemetryKey: string, serverTelemetry: ServerTelemetryEntity): void;
189
+ /**
190
+ *
191
+ */
192
+ getAuthorityMetadata(key: string): AuthorityMetadataEntity | null;
193
+ /**
194
+ *
195
+ */
196
+ getAuthorityMetadataKeys(): Array<string>;
197
+ /**
198
+ * Sets wrapper metadata in memory
199
+ * @param wrapperSKU
200
+ * @param wrapperVersion
201
+ */
202
+ setWrapperMetadata(wrapperSKU: string, wrapperVersion: string): void;
203
+ /**
204
+ * Returns wrapper metadata from in-memory storage
205
+ */
206
+ getWrapperMetadata(): [string, string];
207
+ /**
208
+ *
209
+ * @param entity
210
+ */
211
+ setAuthorityMetadata(key: string, entity: AuthorityMetadataEntity): void;
212
+ /**
213
+ * Gets the active account
214
+ */
215
+ getActiveAccount(): AccountInfo | null;
216
+ /**
217
+ * Sets the active account's localAccountId in cache
218
+ * @param account
219
+ */
220
+ setActiveAccount(account: AccountInfo | null): void;
221
+ /**
222
+ * fetch throttling entity from the platform cache
223
+ * @param throttlingCacheKey
224
+ */
225
+ getThrottlingCache(throttlingCacheKey: string): ThrottlingEntity | null;
226
+ /**
227
+ * set throttling entity to the platform cache
228
+ * @param throttlingCacheKey
229
+ * @param throttlingCache
230
+ */
231
+ setThrottlingCache(throttlingCacheKey: string, throttlingCache: ThrottlingEntity): void;
232
+ /**
233
+ * Gets cache item with given key.
234
+ * Will retrieve from cookies if storeAuthStateInCookie is set to true.
235
+ * @param key
236
+ */
237
+ getTemporaryCache(cacheKey: string, generateKey?: boolean): string | null;
238
+ /**
239
+ * Sets the cache item with the key and value given.
240
+ * Stores in cookie if storeAuthStateInCookie is set to true.
241
+ * This can cause cookie overflow if used incorrectly.
242
+ * @param key
243
+ * @param value
244
+ */
245
+ setTemporaryCache(cacheKey: string, value: string, generateKey?: boolean): void;
246
+ /**
247
+ * Removes the cache item with the given key.
248
+ * @param key
249
+ */
250
+ removeItem(key: string): void;
251
+ /**
252
+ * Removes the temporary cache item with the given key.
253
+ * Will also clear the cookie item if storeAuthStateInCookie is set to true.
254
+ * @param key
255
+ */
256
+ removeTemporaryItem(key: string): void;
257
+ /**
258
+ * Gets all keys in window.
259
+ */
260
+ getKeys(): string[];
261
+ /**
262
+ * Clears all cache entries created by MSAL.
263
+ */
264
+ clear(): Promise<void>;
265
+ /**
266
+ * Clears all access tokes that have claims prior to saving the current one
267
+ * @param performanceClient {IPerformanceClient}
268
+ * @param correlationId {string} correlation id
269
+ * @returns
270
+ */
271
+ clearTokensAndKeysWithClaims(performanceClient: IPerformanceClient, correlationId: string): Promise<void>;
272
+ /**
273
+ * Add value to cookies
274
+ * @param cookieName
275
+ * @param cookieValue
276
+ * @param expires
277
+ * @deprecated
278
+ */
279
+ setItemCookie(cookieName: string, cookieValue: string, expires?: number): void;
280
+ /**
281
+ * Get one item by key from cookies
282
+ * @param cookieName
283
+ * @deprecated
284
+ */
285
+ getItemCookie(cookieName: string): string;
286
+ /**
287
+ * Clear all msal-related cookies currently set in the browser. Should only be used to clear temporary cache items.
288
+ * @deprecated
289
+ */
290
+ clearMsalCookies(): void;
291
+ /**
292
+ * Clear an item in the cookies by key
293
+ * @param cookieName
294
+ * @deprecated
295
+ */
296
+ clearItemCookie(cookieName: string): void;
297
+ /**
298
+ * Get cookie expiration time
299
+ * @param cookieLifeDays
300
+ * @deprecated
301
+ */
302
+ getCookieExpirationTime(cookieLifeDays: number): string;
303
+ /**
304
+ * Prepend msal.<client-id> to each key; Skip for any JSON object as Key (defined schemas do not need the key appended: AccessToken Keys or the upcoming schema)
305
+ * @param key
306
+ * @param addInstanceId
307
+ */
308
+ generateCacheKey(key: string): string;
309
+ /**
310
+ * Create authorityKey to cache authority
311
+ * @param state
312
+ */
313
+ generateAuthorityKey(stateString: string): string;
314
+ /**
315
+ * Create Nonce key to cache nonce
316
+ * @param state
317
+ */
318
+ generateNonceKey(stateString: string): string;
319
+ /**
320
+ * Creates full cache key for the request state
321
+ * @param stateString State string for the request
322
+ */
323
+ generateStateKey(stateString: string): string;
324
+ /**
325
+ * Gets the cached authority based on the cached state. Returns empty if no cached state found.
326
+ */
327
+ getCachedAuthority(cachedState: string): string | null;
328
+ /**
329
+ * Updates account, authority, and state in cache
330
+ * @param serverAuthenticationRequest
331
+ * @param account
332
+ */
333
+ updateCacheEntries(state: string, nonce: string, authorityInstance: string, loginHint: string, account: AccountInfo | null): void;
334
+ /**
335
+ * Reset all temporary cache items
336
+ * @param state
337
+ */
338
+ resetRequestCache(state: string): void;
339
+ /**
340
+ * Removes temporary cache for the provided state
341
+ * @param stateString
342
+ */
343
+ cleanRequestByState(stateString: string): void;
344
+ /**
345
+ * Looks in temporary cache for any state values with the provided interactionType and removes all temporary cache items for that state
346
+ * Used in scenarios where temp cache needs to be cleaned but state is not known, such as clicking browser back button.
347
+ * @param interactionType
348
+ */
349
+ cleanRequestByInteractionType(interactionType: InteractionType): void;
350
+ /**
351
+ * Create request retry key to cache retry status
352
+ */
353
+ generateRequestRetriedKey(): string;
354
+ /**
355
+ * Gets the request retry value from the cache
356
+ */
357
+ getRequestRetried(): number | null;
358
+ /**
359
+ * Sets the request retry value to "retried" in the cache
360
+ */
361
+ setRequestRetried(): void;
362
+ /**
363
+ * Removes all request retry values in the cache
364
+ */
365
+ removeRequestRetried(): void;
366
+ /**
367
+ * Caches the redirectRequest in the cache
368
+ * @param redirectRequest
369
+ */
370
+ cacheRedirectRequest(redirectRequest: RedirectRequest): void;
371
+ /**
372
+ * Gets redirect request from the cache. Logs an error and returns undefined if nothing is found.
373
+ */
374
+ getCachedRedirectRequest(): RedirectRequest | undefined;
375
+ cacheCodeRequest(authCodeRequest: CommonAuthorizationCodeRequest): void;
376
+ /**
377
+ * Gets the token exchange parameters from the cache. Throws an error if nothing is found.
378
+ */
379
+ getCachedRequest(state: string): CommonAuthorizationCodeRequest;
380
+ /**
381
+ * Gets cached native request for redirect flows
382
+ */
383
+ getCachedNativeRequest(): NativeTokenRequest | null;
384
+ isInteractionInProgress(matchClientId?: boolean): boolean;
385
+ getInteractionInProgress(): string | null;
386
+ setInteractionInProgress(inProgress: boolean): void;
387
+ /**
388
+ * Returns username retrieved from ADAL or MSAL v1 idToken
389
+ * @deprecated
390
+ */
391
+ getLegacyLoginHint(): string | null;
392
+ /**
393
+ * Updates a credential's cache key if the current cache key is outdated
394
+ */
395
+ updateCredentialCacheKey(currentCacheKey: string, credential: ValidCredentialType): string;
396
+ /**
397
+ * Builds credential entities from AuthenticationResult object and saves the resulting credentials to the cache
398
+ * @param result
399
+ * @param request
400
+ */
401
+ hydrateCache(result: AuthenticationResult, request: SilentRequest | SsoSilentRequest | RedirectRequest | PopupRequest): Promise<void>;
402
+ /**
403
+ * saves a cache record
404
+ * @param cacheRecord {CacheRecord}
405
+ * @param storeInCache {?StoreInCache}
406
+ * @param correlationId {?string} correlation id
407
+ */
408
+ saveCacheRecord(cacheRecord: CacheRecord, storeInCache?: StoreInCache, correlationId?: string): Promise<void>;
409
+ }
410
+ export declare const DEFAULT_BROWSER_CACHE_MANAGER: (clientId: string, logger: Logger) => BrowserCacheManager;
386
411
  //# sourceMappingURL=BrowserCacheManager.d.ts.map