@azure/msal-browser 3.28.0 → 4.0.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app/IPublicClientApplication.mjs +1 -1
- package/dist/app/PublicClientApplication.mjs +1 -1
- package/dist/app/PublicClientNext.mjs +1 -1
- package/dist/broker/nativeBroker/NativeMessageHandler.mjs +1 -1
- package/dist/broker/nativeBroker/NativeStatusCodes.mjs +1 -1
- package/dist/cache/AccountManager.mjs +1 -1
- package/dist/cache/AsyncMemoryStorage.mjs +1 -1
- package/dist/cache/BrowserCacheManager.d.ts +7 -47
- package/dist/cache/BrowserCacheManager.d.ts.map +1 -1
- package/dist/cache/BrowserCacheManager.mjs +36 -285
- package/dist/cache/BrowserCacheManager.mjs.map +1 -1
- package/dist/cache/CacheHelpers.d.ts +16 -0
- package/dist/cache/CacheHelpers.d.ts.map +1 -0
- package/dist/cache/CacheHelpers.mjs +46 -0
- package/dist/cache/CacheHelpers.mjs.map +1 -0
- package/dist/cache/CookieStorage.d.ts +3 -0
- package/dist/cache/CookieStorage.d.ts.map +1 -1
- package/dist/cache/CookieStorage.mjs +12 -1
- package/dist/cache/CookieStorage.mjs.map +1 -1
- package/dist/cache/DatabaseStorage.mjs +1 -1
- package/dist/cache/ITokenCache.d.ts +1 -1
- package/dist/cache/ITokenCache.d.ts.map +1 -1
- package/dist/cache/IWindowStorage.d.ts +12 -0
- package/dist/cache/IWindowStorage.d.ts.map +1 -1
- package/dist/cache/LocalStorage.d.ts +34 -1
- package/dist/cache/LocalStorage.d.ts.map +1 -1
- package/dist/cache/LocalStorage.mjs +169 -2
- package/dist/cache/LocalStorage.mjs.map +1 -1
- package/dist/cache/MemoryStorage.d.ts +3 -0
- package/dist/cache/MemoryStorage.d.ts.map +1 -1
- package/dist/cache/MemoryStorage.mjs +10 -1
- package/dist/cache/MemoryStorage.mjs.map +1 -1
- package/dist/cache/SessionStorage.d.ts +3 -0
- package/dist/cache/SessionStorage.d.ts.map +1 -1
- package/dist/cache/SessionStorage.mjs +10 -1
- package/dist/cache/SessionStorage.mjs.map +1 -1
- package/dist/cache/TokenCache.d.ts +1 -1
- package/dist/cache/TokenCache.d.ts.map +1 -1
- package/dist/cache/TokenCache.mjs +15 -15
- package/dist/cache/TokenCache.mjs.map +1 -1
- package/dist/config/Configuration.mjs +1 -1
- package/dist/controllers/ControllerFactory.mjs +1 -1
- package/dist/controllers/NestedAppAuthController.d.ts.map +1 -1
- package/dist/controllers/NestedAppAuthController.mjs +4 -4
- package/dist/controllers/NestedAppAuthController.mjs.map +1 -1
- package/dist/controllers/StandardController.d.ts.map +1 -1
- package/dist/controllers/StandardController.mjs +3 -2
- package/dist/controllers/StandardController.mjs.map +1 -1
- package/dist/controllers/UnknownOperatingContextController.mjs +1 -1
- package/dist/crypto/BrowserCrypto.d.ts +27 -0
- package/dist/crypto/BrowserCrypto.d.ts.map +1 -1
- package/dist/crypto/BrowserCrypto.mjs +83 -3
- package/dist/crypto/BrowserCrypto.mjs.map +1 -1
- package/dist/crypto/CryptoOps.mjs +1 -1
- package/dist/crypto/PkceGenerator.mjs +1 -1
- package/dist/crypto/SignedHttpRequest.mjs +1 -1
- package/dist/encode/Base64Decode.d.ts +5 -0
- package/dist/encode/Base64Decode.d.ts.map +1 -1
- package/dist/encode/Base64Decode.mjs +2 -2
- package/dist/encode/Base64Decode.mjs.map +1 -1
- package/dist/encode/Base64Encode.mjs +1 -1
- package/dist/error/BrowserAuthError.mjs +1 -1
- package/dist/error/BrowserAuthErrorCodes.mjs +1 -1
- package/dist/error/BrowserConfigurationAuthError.mjs +1 -1
- package/dist/error/BrowserConfigurationAuthErrorCodes.mjs +1 -1
- package/dist/error/NativeAuthError.mjs +1 -1
- package/dist/error/NativeAuthErrorCodes.mjs +1 -1
- package/dist/error/NestedAppAuthError.mjs +1 -1
- package/dist/event/EventHandler.mjs +1 -1
- package/dist/event/EventMessage.mjs +1 -1
- package/dist/event/EventType.mjs +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +1 -2
- package/dist/index.mjs.map +1 -1
- package/dist/interaction_client/BaseInteractionClient.mjs +1 -1
- package/dist/interaction_client/HybridSpaAuthorizationCodeClient.mjs +1 -1
- package/dist/interaction_client/NativeInteractionClient.d.ts +1 -1
- package/dist/interaction_client/NativeInteractionClient.d.ts.map +1 -1
- package/dist/interaction_client/NativeInteractionClient.mjs +4 -4
- package/dist/interaction_client/NativeInteractionClient.mjs.map +1 -1
- package/dist/interaction_client/PopupClient.mjs +1 -1
- package/dist/interaction_client/RedirectClient.mjs +1 -1
- package/dist/interaction_client/SilentAuthCodeClient.mjs +1 -1
- package/dist/interaction_client/SilentCacheClient.mjs +1 -1
- package/dist/interaction_client/SilentIframeClient.mjs +1 -1
- package/dist/interaction_client/SilentRefreshClient.mjs +1 -1
- package/dist/interaction_client/StandardInteractionClient.d.ts.map +1 -1
- package/dist/interaction_client/StandardInteractionClient.mjs +1 -8
- package/dist/interaction_client/StandardInteractionClient.mjs.map +1 -1
- package/dist/interaction_handler/InteractionHandler.mjs +1 -1
- package/dist/interaction_handler/RedirectHandler.mjs +1 -1
- package/dist/interaction_handler/SilentHandler.mjs +1 -1
- package/dist/naa/BridgeError.mjs +1 -1
- package/dist/naa/BridgeProxy.mjs +1 -1
- package/dist/naa/BridgeStatusCode.mjs +1 -1
- package/dist/naa/mapping/NestedAppAuthAdapter.mjs +1 -1
- package/dist/navigation/NavigationClient.mjs +1 -1
- package/dist/network/FetchClient.mjs +1 -1
- package/dist/operatingcontext/BaseOperatingContext.mjs +1 -1
- package/dist/operatingcontext/NestedAppOperatingContext.mjs +1 -1
- package/dist/operatingcontext/StandardOperatingContext.mjs +1 -1
- package/dist/operatingcontext/UnknownOperatingContext.mjs +1 -1
- package/dist/packageMetadata.d.ts +1 -1
- package/dist/packageMetadata.d.ts.map +1 -1
- package/dist/packageMetadata.mjs +2 -2
- package/dist/request/RequestHelpers.mjs +1 -1
- package/dist/response/ResponseHandler.mjs +1 -1
- package/dist/telemetry/BrowserPerformanceClient.mjs +1 -1
- package/dist/telemetry/BrowserPerformanceMeasurement.mjs +1 -1
- package/dist/utils/BrowserConstants.mjs +1 -1
- package/dist/utils/BrowserProtocolUtils.mjs +1 -1
- package/dist/utils/BrowserUtils.mjs +1 -1
- package/lib/msal-browser.cjs +532 -591
- package/lib/msal-browser.cjs.map +1 -1
- package/lib/msal-browser.js +532 -591
- package/lib/msal-browser.js.map +1 -1
- package/lib/msal-browser.min.js +65 -66
- package/lib/types/cache/BrowserCacheManager.d.ts +7 -47
- package/lib/types/cache/BrowserCacheManager.d.ts.map +1 -1
- package/lib/types/cache/CacheHelpers.d.ts +16 -0
- package/lib/types/cache/CacheHelpers.d.ts.map +1 -0
- package/lib/types/cache/CookieStorage.d.ts +3 -0
- package/lib/types/cache/CookieStorage.d.ts.map +1 -1
- package/lib/types/cache/ITokenCache.d.ts +1 -1
- package/lib/types/cache/ITokenCache.d.ts.map +1 -1
- package/lib/types/cache/IWindowStorage.d.ts +12 -0
- package/lib/types/cache/IWindowStorage.d.ts.map +1 -1
- package/lib/types/cache/LocalStorage.d.ts +34 -1
- package/lib/types/cache/LocalStorage.d.ts.map +1 -1
- package/lib/types/cache/MemoryStorage.d.ts +3 -0
- package/lib/types/cache/MemoryStorage.d.ts.map +1 -1
- package/lib/types/cache/SessionStorage.d.ts +3 -0
- package/lib/types/cache/SessionStorage.d.ts.map +1 -1
- package/lib/types/cache/TokenCache.d.ts +1 -1
- package/lib/types/cache/TokenCache.d.ts.map +1 -1
- package/lib/types/controllers/NestedAppAuthController.d.ts.map +1 -1
- package/lib/types/controllers/StandardController.d.ts.map +1 -1
- package/lib/types/crypto/BrowserCrypto.d.ts +27 -0
- package/lib/types/crypto/BrowserCrypto.d.ts.map +1 -1
- package/lib/types/encode/Base64Decode.d.ts +5 -0
- package/lib/types/encode/Base64Decode.d.ts.map +1 -1
- package/lib/types/index.d.ts +0 -1
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/interaction_client/NativeInteractionClient.d.ts +1 -1
- package/lib/types/interaction_client/NativeInteractionClient.d.ts.map +1 -1
- package/lib/types/interaction_client/StandardInteractionClient.d.ts.map +1 -1
- package/lib/types/packageMetadata.d.ts +1 -1
- package/lib/types/packageMetadata.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/cache/BrowserCacheManager.ts +59 -412
- package/src/cache/CacheHelpers.ts +52 -0
- package/src/cache/CookieStorage.ts +18 -0
- package/src/cache/ITokenCache.ts +1 -1
- package/src/cache/IWindowStorage.ts +14 -0
- package/src/cache/LocalStorage.ts +231 -1
- package/src/cache/MemoryStorage.ts +12 -0
- package/src/cache/SessionStorage.ts +12 -0
- package/src/cache/TokenCache.ts +19 -19
- package/src/controllers/NestedAppAuthController.ts +3 -3
- package/src/controllers/StandardController.ts +3 -1
- package/src/crypto/BrowserCrypto.ts +120 -1
- package/src/encode/Base64Decode.ts +1 -1
- package/src/index.ts +0 -1
- package/src/interaction_client/NativeInteractionClient.ts +3 -3
- package/src/interaction_client/StandardInteractionClient.ts +0 -8
- package/src/packageMetadata.ts +1 -1
- package/dist/cache/BrowserStorage.d.ts +0 -14
- package/dist/cache/BrowserStorage.d.ts.map +0 -1
- package/dist/cache/BrowserStorage.mjs +0 -46
- package/dist/cache/BrowserStorage.mjs.map +0 -1
- package/lib/types/cache/BrowserStorage.d.ts +0 -14
- package/lib/types/cache/BrowserStorage.d.ts.map +0 -1
- package/src/cache/BrowserStorage.ts +0 -52
|
@@ -25,8 +25,6 @@ import {
|
|
|
25
25
|
ActiveAccountFilters,
|
|
26
26
|
CcsCredential,
|
|
27
27
|
CcsCredentialType,
|
|
28
|
-
AuthToken,
|
|
29
|
-
ValidCredentialType,
|
|
30
28
|
TokenKeys,
|
|
31
29
|
CredentialType,
|
|
32
30
|
CacheRecord,
|
|
@@ -66,6 +64,7 @@ import { PopupRequest } from "../request/PopupRequest.js";
|
|
|
66
64
|
import { base64Decode } from "../encode/Base64Decode.js";
|
|
67
65
|
import { base64Encode } from "../encode/Base64Encode.js";
|
|
68
66
|
import { CookieStorage } from "./CookieStorage.js";
|
|
67
|
+
import { getAccountKeys, getTokenKeys } from "./CacheHelpers.js";
|
|
69
68
|
|
|
70
69
|
/**
|
|
71
70
|
* This class implements the cache storage interface for MSAL through browser local or session storage.
|
|
@@ -108,15 +107,13 @@ export class BrowserCacheManager extends CacheManager {
|
|
|
108
107
|
);
|
|
109
108
|
this.cookieStorage = new CookieStorage();
|
|
110
109
|
|
|
111
|
-
// Migrate cache entries from older versions of MSAL.
|
|
112
|
-
if (cacheConfig.cacheMigrationEnabled) {
|
|
113
|
-
this.migrateCacheEntries();
|
|
114
|
-
this.createKeyMaps();
|
|
115
|
-
}
|
|
116
|
-
|
|
117
110
|
this.performanceClient = performanceClient;
|
|
118
111
|
}
|
|
119
112
|
|
|
113
|
+
async initialize(): Promise<void> {
|
|
114
|
+
await this.browserStorage.initialize();
|
|
115
|
+
}
|
|
116
|
+
|
|
120
117
|
/**
|
|
121
118
|
* Returns a window storage class implementing the IWindowStorage interface that corresponds to the configured cacheLocation.
|
|
122
119
|
* @param cacheLocation
|
|
@@ -127,7 +124,7 @@ export class BrowserCacheManager extends CacheManager {
|
|
|
127
124
|
try {
|
|
128
125
|
switch (cacheLocation) {
|
|
129
126
|
case BrowserCacheLocation.LocalStorage:
|
|
130
|
-
return new LocalStorage();
|
|
127
|
+
return new LocalStorage(this.clientId);
|
|
131
128
|
case BrowserCacheLocation.SessionStorage:
|
|
132
129
|
return new SessionStorage();
|
|
133
130
|
case BrowserCacheLocation.MemoryStorage:
|
|
@@ -141,188 +138,6 @@ export class BrowserCacheManager extends CacheManager {
|
|
|
141
138
|
return new MemoryStorage();
|
|
142
139
|
}
|
|
143
140
|
|
|
144
|
-
/**
|
|
145
|
-
* Migrate all old cache entries to new schema. No rollback supported.
|
|
146
|
-
* @param storeAuthStateInCookie
|
|
147
|
-
*/
|
|
148
|
-
protected migrateCacheEntries(): void {
|
|
149
|
-
const idTokenKey = `${Constants.CACHE_PREFIX}.${PersistentCacheKeys.ID_TOKEN}`;
|
|
150
|
-
const clientInfoKey = `${Constants.CACHE_PREFIX}.${PersistentCacheKeys.CLIENT_INFO}`;
|
|
151
|
-
const errorKey = `${Constants.CACHE_PREFIX}.${PersistentCacheKeys.ERROR}`;
|
|
152
|
-
const errorDescKey = `${Constants.CACHE_PREFIX}.${PersistentCacheKeys.ERROR_DESC}`;
|
|
153
|
-
|
|
154
|
-
const idTokenValue = this.browserStorage.getItem(idTokenKey);
|
|
155
|
-
const clientInfoValue = this.browserStorage.getItem(clientInfoKey);
|
|
156
|
-
const errorValue = this.browserStorage.getItem(errorKey);
|
|
157
|
-
const errorDescValue = this.browserStorage.getItem(errorDescKey);
|
|
158
|
-
|
|
159
|
-
const values = [
|
|
160
|
-
idTokenValue,
|
|
161
|
-
clientInfoValue,
|
|
162
|
-
errorValue,
|
|
163
|
-
errorDescValue,
|
|
164
|
-
];
|
|
165
|
-
const keysToMigrate = [
|
|
166
|
-
PersistentCacheKeys.ID_TOKEN,
|
|
167
|
-
PersistentCacheKeys.CLIENT_INFO,
|
|
168
|
-
PersistentCacheKeys.ERROR,
|
|
169
|
-
PersistentCacheKeys.ERROR_DESC,
|
|
170
|
-
];
|
|
171
|
-
|
|
172
|
-
keysToMigrate.forEach((cacheKey: string, index: number) => {
|
|
173
|
-
const value = values[index];
|
|
174
|
-
if (value) {
|
|
175
|
-
this.setTemporaryCache(cacheKey, value, true);
|
|
176
|
-
}
|
|
177
|
-
});
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
/**
|
|
181
|
-
* Searches all cache entries for MSAL accounts and creates the account key map
|
|
182
|
-
* This is used to migrate users from older versions of MSAL which did not create the map.
|
|
183
|
-
* @returns
|
|
184
|
-
*/
|
|
185
|
-
private createKeyMaps(): void {
|
|
186
|
-
this.logger.trace("BrowserCacheManager - createKeyMaps called.");
|
|
187
|
-
const accountKeys = this.getItem(StaticCacheKeys.ACCOUNT_KEYS);
|
|
188
|
-
const tokenKeys = this.getItem(
|
|
189
|
-
`${StaticCacheKeys.TOKEN_KEYS}.${this.clientId}`
|
|
190
|
-
);
|
|
191
|
-
if (accountKeys && tokenKeys) {
|
|
192
|
-
this.logger.verbose(
|
|
193
|
-
"BrowserCacheManager:createKeyMaps - account and token key maps already exist, skipping migration."
|
|
194
|
-
);
|
|
195
|
-
// Key maps already exist, no need to iterate through cache
|
|
196
|
-
return;
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
const allKeys = this.browserStorage.getKeys();
|
|
200
|
-
allKeys.forEach((key) => {
|
|
201
|
-
if (this.isCredentialKey(key)) {
|
|
202
|
-
// Get item, parse, validate and write key to map
|
|
203
|
-
const value = this.getItem(key);
|
|
204
|
-
if (value) {
|
|
205
|
-
const credObj = this.validateAndParseJson(value);
|
|
206
|
-
if (credObj && credObj.hasOwnProperty("credentialType")) {
|
|
207
|
-
switch (credObj["credentialType"]) {
|
|
208
|
-
case CredentialType.ID_TOKEN:
|
|
209
|
-
if (CacheHelpers.isIdTokenEntity(credObj)) {
|
|
210
|
-
this.logger.trace(
|
|
211
|
-
"BrowserCacheManager:createKeyMaps - idToken found, saving key to token key map"
|
|
212
|
-
);
|
|
213
|
-
this.logger.tracePii(
|
|
214
|
-
`BrowserCacheManager:createKeyMaps - idToken with key: ${key} found, saving key to token key map`
|
|
215
|
-
);
|
|
216
|
-
const idTokenEntity =
|
|
217
|
-
credObj as IdTokenEntity;
|
|
218
|
-
const newKey =
|
|
219
|
-
this.updateCredentialCacheKey(
|
|
220
|
-
key,
|
|
221
|
-
idTokenEntity
|
|
222
|
-
);
|
|
223
|
-
this.addTokenKey(
|
|
224
|
-
newKey,
|
|
225
|
-
CredentialType.ID_TOKEN
|
|
226
|
-
);
|
|
227
|
-
return;
|
|
228
|
-
} else {
|
|
229
|
-
this.logger.trace(
|
|
230
|
-
"BrowserCacheManager:createKeyMaps - key found matching idToken schema with value containing idToken credentialType field but value failed IdTokenEntity validation, skipping."
|
|
231
|
-
);
|
|
232
|
-
this.logger.tracePii(
|
|
233
|
-
`BrowserCacheManager:createKeyMaps - failed idToken validation on key: ${key}`
|
|
234
|
-
);
|
|
235
|
-
}
|
|
236
|
-
break;
|
|
237
|
-
case CredentialType.ACCESS_TOKEN:
|
|
238
|
-
case CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME:
|
|
239
|
-
if (CacheHelpers.isAccessTokenEntity(credObj)) {
|
|
240
|
-
this.logger.trace(
|
|
241
|
-
"BrowserCacheManager:createKeyMaps - accessToken found, saving key to token key map"
|
|
242
|
-
);
|
|
243
|
-
this.logger.tracePii(
|
|
244
|
-
`BrowserCacheManager:createKeyMaps - accessToken with key: ${key} found, saving key to token key map`
|
|
245
|
-
);
|
|
246
|
-
const accessTokenEntity =
|
|
247
|
-
credObj as AccessTokenEntity;
|
|
248
|
-
const newKey =
|
|
249
|
-
this.updateCredentialCacheKey(
|
|
250
|
-
key,
|
|
251
|
-
accessTokenEntity
|
|
252
|
-
);
|
|
253
|
-
this.addTokenKey(
|
|
254
|
-
newKey,
|
|
255
|
-
CredentialType.ACCESS_TOKEN
|
|
256
|
-
);
|
|
257
|
-
return;
|
|
258
|
-
} else {
|
|
259
|
-
this.logger.trace(
|
|
260
|
-
"BrowserCacheManager:createKeyMaps - key found matching accessToken schema with value containing accessToken credentialType field but value failed AccessTokenEntity validation, skipping."
|
|
261
|
-
);
|
|
262
|
-
this.logger.tracePii(
|
|
263
|
-
`BrowserCacheManager:createKeyMaps - failed accessToken validation on key: ${key}`
|
|
264
|
-
);
|
|
265
|
-
}
|
|
266
|
-
break;
|
|
267
|
-
case CredentialType.REFRESH_TOKEN:
|
|
268
|
-
if (
|
|
269
|
-
CacheHelpers.isRefreshTokenEntity(credObj)
|
|
270
|
-
) {
|
|
271
|
-
this.logger.trace(
|
|
272
|
-
"BrowserCacheManager:createKeyMaps - refreshToken found, saving key to token key map"
|
|
273
|
-
);
|
|
274
|
-
this.logger.tracePii(
|
|
275
|
-
`BrowserCacheManager:createKeyMaps - refreshToken with key: ${key} found, saving key to token key map`
|
|
276
|
-
);
|
|
277
|
-
const refreshTokenEntity =
|
|
278
|
-
credObj as RefreshTokenEntity;
|
|
279
|
-
const newKey =
|
|
280
|
-
this.updateCredentialCacheKey(
|
|
281
|
-
key,
|
|
282
|
-
refreshTokenEntity
|
|
283
|
-
);
|
|
284
|
-
this.addTokenKey(
|
|
285
|
-
newKey,
|
|
286
|
-
CredentialType.REFRESH_TOKEN
|
|
287
|
-
);
|
|
288
|
-
return;
|
|
289
|
-
} else {
|
|
290
|
-
this.logger.trace(
|
|
291
|
-
"BrowserCacheManager:createKeyMaps - key found matching refreshToken schema with value containing refreshToken credentialType field but value failed RefreshTokenEntity validation, skipping."
|
|
292
|
-
);
|
|
293
|
-
this.logger.tracePii(
|
|
294
|
-
`BrowserCacheManager:createKeyMaps - failed refreshToken validation on key: ${key}`
|
|
295
|
-
);
|
|
296
|
-
}
|
|
297
|
-
break;
|
|
298
|
-
default:
|
|
299
|
-
// If credentialType isn't one of our predefined ones, it may not be an MSAL cache value. Ignore.
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
if (this.isAccountKey(key)) {
|
|
306
|
-
const value = this.getItem(key);
|
|
307
|
-
if (value) {
|
|
308
|
-
const accountObj = this.validateAndParseJson(value);
|
|
309
|
-
if (
|
|
310
|
-
accountObj &&
|
|
311
|
-
AccountEntity.isAccountEntity(accountObj)
|
|
312
|
-
) {
|
|
313
|
-
this.logger.trace(
|
|
314
|
-
"BrowserCacheManager:createKeyMaps - account found, saving key to account key map"
|
|
315
|
-
);
|
|
316
|
-
this.logger.tracePii(
|
|
317
|
-
`BrowserCacheManager:createKeyMaps - account with key: ${key} found, saving key to account key map`
|
|
318
|
-
);
|
|
319
|
-
this.addAccountKeyToMap(key);
|
|
320
|
-
}
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
});
|
|
324
|
-
}
|
|
325
|
-
|
|
326
141
|
/**
|
|
327
142
|
* Parses passed value as JSON object, JSON.parse() will throw an error.
|
|
328
143
|
* @param input
|
|
@@ -344,46 +159,15 @@ export class BrowserCacheManager extends CacheManager {
|
|
|
344
159
|
}
|
|
345
160
|
}
|
|
346
161
|
|
|
347
|
-
/**
|
|
348
|
-
* fetches the entry from the browser storage based off the key
|
|
349
|
-
* @param key
|
|
350
|
-
*/
|
|
351
|
-
getItem(key: string): string | null {
|
|
352
|
-
return this.browserStorage.getItem(key);
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
/**
|
|
356
|
-
* sets the entry in the browser storage
|
|
357
|
-
* @param key
|
|
358
|
-
* @param value
|
|
359
|
-
*/
|
|
360
|
-
setItem(key: string, value: string): void {
|
|
361
|
-
this.browserStorage.setItem(key, value);
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
/**
|
|
365
|
-
* fetch the account entity from the platform cache
|
|
366
|
-
* @param accountKey
|
|
367
|
-
*/
|
|
368
|
-
getAccount(accountKey: string, logger?: Logger): AccountEntity | null {
|
|
369
|
-
this.logger.trace("BrowserCacheManager.getAccount called");
|
|
370
|
-
const accountEntity = this.getCachedAccountEntity(accountKey);
|
|
371
|
-
|
|
372
|
-
return this.updateOutdatedCachedAccount(
|
|
373
|
-
accountKey,
|
|
374
|
-
accountEntity,
|
|
375
|
-
logger
|
|
376
|
-
);
|
|
377
|
-
}
|
|
378
|
-
|
|
379
162
|
/**
|
|
380
163
|
* Reads account from cache, deserializes it into an account entity and returns it.
|
|
381
164
|
* If account is not found from the key, returns null and removes key from map.
|
|
382
165
|
* @param accountKey
|
|
383
166
|
* @returns
|
|
384
167
|
*/
|
|
385
|
-
|
|
386
|
-
|
|
168
|
+
getAccount(accountKey: string): AccountEntity | null {
|
|
169
|
+
this.logger.trace("BrowserCacheManager.getAccount called");
|
|
170
|
+
const serializedAccount = this.browserStorage.getUserData(accountKey);
|
|
387
171
|
if (!serializedAccount) {
|
|
388
172
|
this.removeAccountKeyFromMap(accountKey);
|
|
389
173
|
return null;
|
|
@@ -405,10 +189,10 @@ export class BrowserCacheManager extends CacheManager {
|
|
|
405
189
|
* set account entity in the platform cache
|
|
406
190
|
* @param account
|
|
407
191
|
*/
|
|
408
|
-
setAccount(account: AccountEntity): void {
|
|
192
|
+
async setAccount(account: AccountEntity): Promise<void> {
|
|
409
193
|
this.logger.trace("BrowserCacheManager.setAccount called");
|
|
410
194
|
const key = account.generateAccountKey();
|
|
411
|
-
this.
|
|
195
|
+
await this.browserStorage.setUserData(key, JSON.stringify(account));
|
|
412
196
|
this.addAccountKeyToMap(key);
|
|
413
197
|
}
|
|
414
198
|
|
|
@@ -417,16 +201,7 @@ export class BrowserCacheManager extends CacheManager {
|
|
|
417
201
|
* @returns
|
|
418
202
|
*/
|
|
419
203
|
getAccountKeys(): Array<string> {
|
|
420
|
-
this.
|
|
421
|
-
const accountKeys = this.getItem(StaticCacheKeys.ACCOUNT_KEYS);
|
|
422
|
-
if (accountKeys) {
|
|
423
|
-
return JSON.parse(accountKeys);
|
|
424
|
-
}
|
|
425
|
-
|
|
426
|
-
this.logger.verbose(
|
|
427
|
-
"BrowserCacheManager.getAccountKeys - No account keys found"
|
|
428
|
-
);
|
|
429
|
-
return [];
|
|
204
|
+
return getAccountKeys(this.browserStorage);
|
|
430
205
|
}
|
|
431
206
|
|
|
432
207
|
/**
|
|
@@ -442,7 +217,7 @@ export class BrowserCacheManager extends CacheManager {
|
|
|
442
217
|
if (accountKeys.indexOf(key) === -1) {
|
|
443
218
|
// Only add key if it does not already exist in the map
|
|
444
219
|
accountKeys.push(key);
|
|
445
|
-
this.setItem(
|
|
220
|
+
this.browserStorage.setItem(
|
|
446
221
|
StaticCacheKeys.ACCOUNT_KEYS,
|
|
447
222
|
JSON.stringify(accountKeys)
|
|
448
223
|
);
|
|
@@ -469,7 +244,7 @@ export class BrowserCacheManager extends CacheManager {
|
|
|
469
244
|
const removalIndex = accountKeys.indexOf(key);
|
|
470
245
|
if (removalIndex > -1) {
|
|
471
246
|
accountKeys.splice(removalIndex, 1);
|
|
472
|
-
this.setItem(
|
|
247
|
+
this.browserStorage.setItem(
|
|
473
248
|
StaticCacheKeys.ACCOUNT_KEYS,
|
|
474
249
|
JSON.stringify(accountKeys)
|
|
475
250
|
);
|
|
@@ -492,15 +267,6 @@ export class BrowserCacheManager extends CacheManager {
|
|
|
492
267
|
this.removeAccountKeyFromMap(key);
|
|
493
268
|
}
|
|
494
269
|
|
|
495
|
-
/**
|
|
496
|
-
* Remove account entity from the platform cache if it's outdated
|
|
497
|
-
* @param accountKey
|
|
498
|
-
*/
|
|
499
|
-
removeOutdatedAccount(accountKey: string): void {
|
|
500
|
-
this.removeItem(accountKey);
|
|
501
|
-
this.removeAccountKeyFromMap(accountKey);
|
|
502
|
-
}
|
|
503
|
-
|
|
504
270
|
/**
|
|
505
271
|
* Removes given idToken from the cache and from the key map
|
|
506
272
|
* @param key
|
|
@@ -533,35 +299,7 @@ export class BrowserCacheManager extends CacheManager {
|
|
|
533
299
|
* @returns
|
|
534
300
|
*/
|
|
535
301
|
getTokenKeys(): TokenKeys {
|
|
536
|
-
this.
|
|
537
|
-
const item = this.getItem(
|
|
538
|
-
`${StaticCacheKeys.TOKEN_KEYS}.${this.clientId}`
|
|
539
|
-
);
|
|
540
|
-
if (item) {
|
|
541
|
-
const tokenKeys = this.validateAndParseJson(item);
|
|
542
|
-
if (
|
|
543
|
-
tokenKeys &&
|
|
544
|
-
tokenKeys.hasOwnProperty("idToken") &&
|
|
545
|
-
tokenKeys.hasOwnProperty("accessToken") &&
|
|
546
|
-
tokenKeys.hasOwnProperty("refreshToken")
|
|
547
|
-
) {
|
|
548
|
-
return tokenKeys as TokenKeys;
|
|
549
|
-
} else {
|
|
550
|
-
this.logger.error(
|
|
551
|
-
"BrowserCacheManager.getTokenKeys - Token keys found but in an unknown format. Returning empty key map."
|
|
552
|
-
);
|
|
553
|
-
}
|
|
554
|
-
} else {
|
|
555
|
-
this.logger.verbose(
|
|
556
|
-
"BrowserCacheManager.getTokenKeys - No token keys found"
|
|
557
|
-
);
|
|
558
|
-
}
|
|
559
|
-
|
|
560
|
-
return {
|
|
561
|
-
idToken: [],
|
|
562
|
-
accessToken: [],
|
|
563
|
-
refreshToken: [],
|
|
564
|
-
};
|
|
302
|
+
return getTokenKeys(this.clientId, this.browserStorage);
|
|
565
303
|
}
|
|
566
304
|
|
|
567
305
|
/**
|
|
@@ -607,7 +345,7 @@ export class BrowserCacheManager extends CacheManager {
|
|
|
607
345
|
);
|
|
608
346
|
}
|
|
609
347
|
|
|
610
|
-
this.setItem(
|
|
348
|
+
this.browserStorage.setItem(
|
|
611
349
|
`${StaticCacheKeys.TOKEN_KEYS}.${this.clientId}`,
|
|
612
350
|
JSON.stringify(tokenKeys)
|
|
613
351
|
);
|
|
@@ -680,7 +418,7 @@ export class BrowserCacheManager extends CacheManager {
|
|
|
680
418
|
);
|
|
681
419
|
}
|
|
682
420
|
|
|
683
|
-
this.setItem(
|
|
421
|
+
this.browserStorage.setItem(
|
|
684
422
|
`${StaticCacheKeys.TOKEN_KEYS}.${this.clientId}`,
|
|
685
423
|
JSON.stringify(tokenKeys)
|
|
686
424
|
);
|
|
@@ -691,7 +429,7 @@ export class BrowserCacheManager extends CacheManager {
|
|
|
691
429
|
* @param idTokenKey
|
|
692
430
|
*/
|
|
693
431
|
getIdTokenCredential(idTokenKey: string): IdTokenEntity | null {
|
|
694
|
-
const value = this.
|
|
432
|
+
const value = this.browserStorage.getUserData(idTokenKey);
|
|
695
433
|
if (!value) {
|
|
696
434
|
this.logger.trace(
|
|
697
435
|
"BrowserCacheManager.getIdTokenCredential: called, no cache hit"
|
|
@@ -719,11 +457,14 @@ export class BrowserCacheManager extends CacheManager {
|
|
|
719
457
|
* set IdToken credential to the platform cache
|
|
720
458
|
* @param idToken
|
|
721
459
|
*/
|
|
722
|
-
setIdTokenCredential(idToken: IdTokenEntity): void {
|
|
460
|
+
async setIdTokenCredential(idToken: IdTokenEntity): Promise<void> {
|
|
723
461
|
this.logger.trace("BrowserCacheManager.setIdTokenCredential called");
|
|
724
462
|
const idTokenKey = CacheHelpers.generateCredentialKey(idToken);
|
|
725
463
|
|
|
726
|
-
this.
|
|
464
|
+
await this.browserStorage.setUserData(
|
|
465
|
+
idTokenKey,
|
|
466
|
+
JSON.stringify(idToken)
|
|
467
|
+
);
|
|
727
468
|
|
|
728
469
|
this.addTokenKey(idTokenKey, CredentialType.ID_TOKEN);
|
|
729
470
|
}
|
|
@@ -733,7 +474,7 @@ export class BrowserCacheManager extends CacheManager {
|
|
|
733
474
|
* @param key
|
|
734
475
|
*/
|
|
735
476
|
getAccessTokenCredential(accessTokenKey: string): AccessTokenEntity | null {
|
|
736
|
-
const value = this.
|
|
477
|
+
const value = this.browserStorage.getUserData(accessTokenKey);
|
|
737
478
|
if (!value) {
|
|
738
479
|
this.logger.trace(
|
|
739
480
|
"BrowserCacheManager.getAccessTokenCredential: called, no cache hit"
|
|
@@ -763,12 +504,17 @@ export class BrowserCacheManager extends CacheManager {
|
|
|
763
504
|
* set accessToken credential to the platform cache
|
|
764
505
|
* @param accessToken
|
|
765
506
|
*/
|
|
766
|
-
setAccessTokenCredential(
|
|
507
|
+
async setAccessTokenCredential(
|
|
508
|
+
accessToken: AccessTokenEntity
|
|
509
|
+
): Promise<void> {
|
|
767
510
|
this.logger.trace(
|
|
768
511
|
"BrowserCacheManager.setAccessTokenCredential called"
|
|
769
512
|
);
|
|
770
513
|
const accessTokenKey = CacheHelpers.generateCredentialKey(accessToken);
|
|
771
|
-
this.
|
|
514
|
+
await this.browserStorage.setUserData(
|
|
515
|
+
accessTokenKey,
|
|
516
|
+
JSON.stringify(accessToken)
|
|
517
|
+
);
|
|
772
518
|
|
|
773
519
|
this.addTokenKey(accessTokenKey, CredentialType.ACCESS_TOKEN);
|
|
774
520
|
}
|
|
@@ -780,7 +526,7 @@ export class BrowserCacheManager extends CacheManager {
|
|
|
780
526
|
getRefreshTokenCredential(
|
|
781
527
|
refreshTokenKey: string
|
|
782
528
|
): RefreshTokenEntity | null {
|
|
783
|
-
const value = this.
|
|
529
|
+
const value = this.browserStorage.getUserData(refreshTokenKey);
|
|
784
530
|
if (!value) {
|
|
785
531
|
this.logger.trace(
|
|
786
532
|
"BrowserCacheManager.getRefreshTokenCredential: called, no cache hit"
|
|
@@ -810,13 +556,18 @@ export class BrowserCacheManager extends CacheManager {
|
|
|
810
556
|
* set refreshToken credential to the platform cache
|
|
811
557
|
* @param refreshToken
|
|
812
558
|
*/
|
|
813
|
-
setRefreshTokenCredential(
|
|
559
|
+
async setRefreshTokenCredential(
|
|
560
|
+
refreshToken: RefreshTokenEntity
|
|
561
|
+
): Promise<void> {
|
|
814
562
|
this.logger.trace(
|
|
815
563
|
"BrowserCacheManager.setRefreshTokenCredential called"
|
|
816
564
|
);
|
|
817
565
|
const refreshTokenKey =
|
|
818
566
|
CacheHelpers.generateCredentialKey(refreshToken);
|
|
819
|
-
this.
|
|
567
|
+
await this.browserStorage.setUserData(
|
|
568
|
+
refreshTokenKey,
|
|
569
|
+
JSON.stringify(refreshToken)
|
|
570
|
+
);
|
|
820
571
|
|
|
821
572
|
this.addTokenKey(refreshTokenKey, CredentialType.REFRESH_TOKEN);
|
|
822
573
|
}
|
|
@@ -826,7 +577,7 @@ export class BrowserCacheManager extends CacheManager {
|
|
|
826
577
|
* @param appMetadataKey
|
|
827
578
|
*/
|
|
828
579
|
getAppMetadata(appMetadataKey: string): AppMetadataEntity | null {
|
|
829
|
-
const value = this.getItem(appMetadataKey);
|
|
580
|
+
const value = this.browserStorage.getItem(appMetadataKey);
|
|
830
581
|
if (!value) {
|
|
831
582
|
this.logger.trace(
|
|
832
583
|
"BrowserCacheManager.getAppMetadata: called, no cache hit"
|
|
@@ -856,7 +607,10 @@ export class BrowserCacheManager extends CacheManager {
|
|
|
856
607
|
setAppMetadata(appMetadata: AppMetadataEntity): void {
|
|
857
608
|
this.logger.trace("BrowserCacheManager.setAppMetadata called");
|
|
858
609
|
const appMetadataKey = CacheHelpers.generateAppMetadataKey(appMetadata);
|
|
859
|
-
this.setItem(
|
|
610
|
+
this.browserStorage.setItem(
|
|
611
|
+
appMetadataKey,
|
|
612
|
+
JSON.stringify(appMetadata)
|
|
613
|
+
);
|
|
860
614
|
}
|
|
861
615
|
|
|
862
616
|
/**
|
|
@@ -866,7 +620,7 @@ export class BrowserCacheManager extends CacheManager {
|
|
|
866
620
|
getServerTelemetry(
|
|
867
621
|
serverTelemetryKey: string
|
|
868
622
|
): ServerTelemetryEntity | null {
|
|
869
|
-
const value = this.getItem(serverTelemetryKey);
|
|
623
|
+
const value = this.browserStorage.getItem(serverTelemetryKey);
|
|
870
624
|
if (!value) {
|
|
871
625
|
this.logger.trace(
|
|
872
626
|
"BrowserCacheManager.getServerTelemetry: called, no cache hit"
|
|
@@ -901,7 +655,10 @@ export class BrowserCacheManager extends CacheManager {
|
|
|
901
655
|
serverTelemetry: ServerTelemetryEntity
|
|
902
656
|
): void {
|
|
903
657
|
this.logger.trace("BrowserCacheManager.setServerTelemetry called");
|
|
904
|
-
this.setItem(
|
|
658
|
+
this.browserStorage.setItem(
|
|
659
|
+
serverTelemetryKey,
|
|
660
|
+
JSON.stringify(serverTelemetry)
|
|
661
|
+
);
|
|
905
662
|
}
|
|
906
663
|
|
|
907
664
|
/**
|
|
@@ -980,35 +737,13 @@ export class BrowserCacheManager extends CacheManager {
|
|
|
980
737
|
const activeAccountKeyFilters = this.generateCacheKey(
|
|
981
738
|
PersistentCacheKeys.ACTIVE_ACCOUNT_FILTERS
|
|
982
739
|
);
|
|
983
|
-
const activeAccountValueFilters = this.getItem(
|
|
740
|
+
const activeAccountValueFilters = this.browserStorage.getItem(
|
|
741
|
+
activeAccountKeyFilters
|
|
742
|
+
);
|
|
984
743
|
if (!activeAccountValueFilters) {
|
|
985
|
-
// if new active account cache type isn't found, it's an old version, so look for that instead
|
|
986
744
|
this.logger.trace(
|
|
987
|
-
"BrowserCacheManager.getActiveAccount: No active account filters
|
|
745
|
+
"BrowserCacheManager.getActiveAccount: No active account filters found"
|
|
988
746
|
);
|
|
989
|
-
const activeAccountKeyLocal = this.generateCacheKey(
|
|
990
|
-
PersistentCacheKeys.ACTIVE_ACCOUNT
|
|
991
|
-
);
|
|
992
|
-
const activeAccountValueLocal = this.getItem(activeAccountKeyLocal);
|
|
993
|
-
if (!activeAccountValueLocal) {
|
|
994
|
-
this.logger.trace(
|
|
995
|
-
"BrowserCacheManager.getActiveAccount: No active account found"
|
|
996
|
-
);
|
|
997
|
-
return null;
|
|
998
|
-
}
|
|
999
|
-
const activeAccount = this.getAccountInfoFilteredBy({
|
|
1000
|
-
localAccountId: activeAccountValueLocal,
|
|
1001
|
-
});
|
|
1002
|
-
if (activeAccount) {
|
|
1003
|
-
this.logger.trace(
|
|
1004
|
-
"BrowserCacheManager.getActiveAccount: Legacy active account cache schema found"
|
|
1005
|
-
);
|
|
1006
|
-
this.logger.trace(
|
|
1007
|
-
"BrowserCacheManager.getActiveAccount: Adding active account filters cache schema"
|
|
1008
|
-
);
|
|
1009
|
-
this.setActiveAccount(activeAccount);
|
|
1010
|
-
return activeAccount;
|
|
1011
|
-
}
|
|
1012
747
|
return null;
|
|
1013
748
|
}
|
|
1014
749
|
const activeAccountValueObj = this.validateAndParseJson(
|
|
@@ -1038,9 +773,6 @@ export class BrowserCacheManager extends CacheManager {
|
|
|
1038
773
|
const activeAccountKey = this.generateCacheKey(
|
|
1039
774
|
PersistentCacheKeys.ACTIVE_ACCOUNT_FILTERS
|
|
1040
775
|
);
|
|
1041
|
-
const activeAccountKeyLocal = this.generateCacheKey(
|
|
1042
|
-
PersistentCacheKeys.ACTIVE_ACCOUNT
|
|
1043
|
-
);
|
|
1044
776
|
if (account) {
|
|
1045
777
|
this.logger.verbose("setActiveAccount: Active account set");
|
|
1046
778
|
const activeAccountValue: ActiveAccountFilters = {
|
|
@@ -1052,16 +784,11 @@ export class BrowserCacheManager extends CacheManager {
|
|
|
1052
784
|
activeAccountKey,
|
|
1053
785
|
JSON.stringify(activeAccountValue)
|
|
1054
786
|
);
|
|
1055
|
-
this.browserStorage.setItem(
|
|
1056
|
-
activeAccountKeyLocal,
|
|
1057
|
-
account.localAccountId
|
|
1058
|
-
);
|
|
1059
787
|
} else {
|
|
1060
788
|
this.logger.verbose(
|
|
1061
789
|
"setActiveAccount: No account passed, active account not set"
|
|
1062
790
|
);
|
|
1063
791
|
this.browserStorage.removeItem(activeAccountKey);
|
|
1064
|
-
this.browserStorage.removeItem(activeAccountKeyLocal);
|
|
1065
792
|
}
|
|
1066
793
|
}
|
|
1067
794
|
|
|
@@ -1070,7 +797,7 @@ export class BrowserCacheManager extends CacheManager {
|
|
|
1070
797
|
* @param throttlingCacheKey
|
|
1071
798
|
*/
|
|
1072
799
|
getThrottlingCache(throttlingCacheKey: string): ThrottlingEntity | null {
|
|
1073
|
-
const value = this.getItem(throttlingCacheKey);
|
|
800
|
+
const value = this.browserStorage.getItem(throttlingCacheKey);
|
|
1074
801
|
if (!value) {
|
|
1075
802
|
this.logger.trace(
|
|
1076
803
|
"BrowserCacheManager.getThrottlingCache: called, no cache hit"
|
|
@@ -1106,7 +833,10 @@ export class BrowserCacheManager extends CacheManager {
|
|
|
1106
833
|
throttlingCache: ThrottlingEntity
|
|
1107
834
|
): void {
|
|
1108
835
|
this.logger.trace("BrowserCacheManager.setThrottlingCache called");
|
|
1109
|
-
this.setItem(
|
|
836
|
+
this.browserStorage.setItem(
|
|
837
|
+
throttlingCacheKey,
|
|
838
|
+
JSON.stringify(throttlingCache)
|
|
839
|
+
);
|
|
1110
840
|
}
|
|
1111
841
|
|
|
1112
842
|
/**
|
|
@@ -1287,10 +1017,7 @@ export class BrowserCacheManager extends CacheManager {
|
|
|
1287
1017
|
generateCacheKey(key: string): string {
|
|
1288
1018
|
const generatedKey = this.validateAndParseJson(key);
|
|
1289
1019
|
if (!generatedKey) {
|
|
1290
|
-
if (
|
|
1291
|
-
StringUtils.startsWith(key, Constants.CACHE_PREFIX) ||
|
|
1292
|
-
StringUtils.startsWith(key, PersistentCacheKeys.ADAL_ID_TOKEN)
|
|
1293
|
-
) {
|
|
1020
|
+
if (StringUtils.startsWith(key, Constants.CACHE_PREFIX)) {
|
|
1294
1021
|
return key;
|
|
1295
1022
|
}
|
|
1296
1023
|
return `${Constants.CACHE_PREFIX}.${this.clientId}.${key}`;
|
|
@@ -1621,86 +1348,6 @@ export class BrowserCacheManager extends CacheManager {
|
|
|
1621
1348
|
}
|
|
1622
1349
|
}
|
|
1623
1350
|
|
|
1624
|
-
/**
|
|
1625
|
-
* Returns username retrieved from ADAL or MSAL v1 idToken
|
|
1626
|
-
* @deprecated
|
|
1627
|
-
*/
|
|
1628
|
-
getLegacyLoginHint(): string | null {
|
|
1629
|
-
// Only check for adal/msal token if no SSO params are being used
|
|
1630
|
-
const adalIdTokenString = this.getTemporaryCache(
|
|
1631
|
-
PersistentCacheKeys.ADAL_ID_TOKEN
|
|
1632
|
-
);
|
|
1633
|
-
if (adalIdTokenString) {
|
|
1634
|
-
this.browserStorage.removeItem(PersistentCacheKeys.ADAL_ID_TOKEN);
|
|
1635
|
-
this.logger.verbose("Cached ADAL id token retrieved.");
|
|
1636
|
-
}
|
|
1637
|
-
|
|
1638
|
-
// Check for cached MSAL v1 id token
|
|
1639
|
-
const msalIdTokenString = this.getTemporaryCache(
|
|
1640
|
-
PersistentCacheKeys.ID_TOKEN,
|
|
1641
|
-
true
|
|
1642
|
-
);
|
|
1643
|
-
if (msalIdTokenString) {
|
|
1644
|
-
this.browserStorage.removeItem(
|
|
1645
|
-
this.generateCacheKey(PersistentCacheKeys.ID_TOKEN)
|
|
1646
|
-
);
|
|
1647
|
-
this.logger.verbose("Cached MSAL.js v1 id token retrieved");
|
|
1648
|
-
}
|
|
1649
|
-
|
|
1650
|
-
const cachedIdTokenString = msalIdTokenString || adalIdTokenString;
|
|
1651
|
-
if (cachedIdTokenString) {
|
|
1652
|
-
const idTokenClaims = AuthToken.extractTokenClaims(
|
|
1653
|
-
cachedIdTokenString,
|
|
1654
|
-
base64Decode
|
|
1655
|
-
);
|
|
1656
|
-
if (idTokenClaims.preferred_username) {
|
|
1657
|
-
this.logger.verbose(
|
|
1658
|
-
"No SSO params used and ADAL/MSAL v1 token retrieved, setting ADAL/MSAL v1 preferred_username as loginHint"
|
|
1659
|
-
);
|
|
1660
|
-
return idTokenClaims.preferred_username;
|
|
1661
|
-
} else if (idTokenClaims.upn) {
|
|
1662
|
-
this.logger.verbose(
|
|
1663
|
-
"No SSO params used and ADAL/MSAL v1 token retrieved, setting ADAL/MSAL v1 upn as loginHint"
|
|
1664
|
-
);
|
|
1665
|
-
return idTokenClaims.upn;
|
|
1666
|
-
} else {
|
|
1667
|
-
this.logger.verbose(
|
|
1668
|
-
"No SSO params used and ADAL/MSAL v1 token retrieved, however, no account hint claim found. Enable preferred_username or upn id token claim to get SSO."
|
|
1669
|
-
);
|
|
1670
|
-
}
|
|
1671
|
-
}
|
|
1672
|
-
|
|
1673
|
-
return null;
|
|
1674
|
-
}
|
|
1675
|
-
|
|
1676
|
-
/**
|
|
1677
|
-
* Updates a credential's cache key if the current cache key is outdated
|
|
1678
|
-
*/
|
|
1679
|
-
updateCredentialCacheKey(
|
|
1680
|
-
currentCacheKey: string,
|
|
1681
|
-
credential: ValidCredentialType
|
|
1682
|
-
): string {
|
|
1683
|
-
const updatedCacheKey = CacheHelpers.generateCredentialKey(credential);
|
|
1684
|
-
|
|
1685
|
-
if (currentCacheKey !== updatedCacheKey) {
|
|
1686
|
-
const cacheItem = this.getItem(currentCacheKey);
|
|
1687
|
-
if (cacheItem) {
|
|
1688
|
-
this.browserStorage.removeItem(currentCacheKey);
|
|
1689
|
-
this.setItem(updatedCacheKey, cacheItem);
|
|
1690
|
-
this.logger.verbose(
|
|
1691
|
-
`Updated an outdated ${credential.credentialType} cache key`
|
|
1692
|
-
);
|
|
1693
|
-
return updatedCacheKey;
|
|
1694
|
-
} else {
|
|
1695
|
-
this.logger.error(
|
|
1696
|
-
`Attempted to update an outdated ${credential.credentialType} cache key but no item matching the outdated key was found in storage`
|
|
1697
|
-
);
|
|
1698
|
-
}
|
|
1699
|
-
}
|
|
1700
|
-
|
|
1701
|
-
return currentCacheKey;
|
|
1702
|
-
}
|
|
1703
|
-
|
|
1704
1351
|
/**
|
|
1705
1352
|
* Builds credential entities from AuthenticationResult object and saves the resulting credentials to the cache
|
|
1706
1353
|
* @param result
|