Estructura inicial del proyecto

This commit is contained in:
2026-06-02 16:57:08 +00:00
commit 8b306b9afc
9864 changed files with 1435687 additions and 0 deletions

View File

@ -0,0 +1,41 @@
/*! @azure/msal-node v5.2.2 2026-05-19 */
'use strict';
import { Constants } from '@azure/msal-common/node';
import { CACHE } from '../utils/Constants.mjs';
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/
function generateCredentialKey(credential) {
const familyId = (credential.credentialType === Constants.CredentialType.REFRESH_TOKEN &&
credential.familyId) ||
credential.clientId;
const scheme = credential.tokenType &&
credential.tokenType.toLowerCase() !==
Constants.AuthenticationScheme.BEARER.toLowerCase()
? credential.tokenType.toLowerCase()
: "";
const credentialKey = [
credential.homeAccountId,
credential.environment,
credential.credentialType,
familyId,
credential.realm || "",
credential.target || "",
scheme,
];
return credentialKey.join(CACHE.KEY_SEPARATOR).toLowerCase();
}
function generateAccountKey(account) {
const homeTenantId = account.homeAccountId.split(".")[1];
const accountKey = [
account.homeAccountId,
account.environment,
homeTenantId || account.tenantId || "",
];
return accountKey.join(CACHE.KEY_SEPARATOR).toLowerCase();
}
export { generateAccountKey, generateCredentialKey };
//# sourceMappingURL=CacheHelpers.mjs.map

View File

@ -0,0 +1 @@
{"version":3,"file":"CacheHelpers.mjs","sources":["../../src/cache/CacheHelpers.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;AAAA;;;AAGG;AASG,SAAU,qBAAqB,CAAC,UAA4B,EAAA;IAC9D,MAAM,QAAQ,GACV,CAAC,UAAU,CAAC,cAAc,KAAK,SAAS,CAAC,cAAc,CAAC,aAAa;QACjE,UAAU,CAAC,QAAQ;QACvB,UAAU,CAAC,QAAQ,CAAC;AACxB,IAAA,MAAM,MAAM,GACR,UAAU,CAAC,SAAS;AACpB,QAAA,UAAU,CAAC,SAAS,CAAC,WAAW,EAAE;AAC9B,YAAA,SAAS,CAAC,oBAAoB,CAAC,MAAM,CAAC,WAAW,EAAE;AACnD,UAAE,UAAU,CAAC,SAAS,CAAC,WAAW,EAAE;UAClC,EAAE,CAAC;AACb,IAAA,MAAM,aAAa,GAAG;AAClB,QAAA,UAAU,CAAC,aAAa;AACxB,QAAA,UAAU,CAAC,WAAW;AACtB,QAAA,UAAU,CAAC,cAAc;QACzB,QAAQ;QACR,UAAU,CAAC,KAAK,IAAI,EAAE;QACtB,UAAU,CAAC,MAAM,IAAI,EAAE;QACvB,MAAM;KACT,CAAC;IAEF,OAAO,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,WAAW,EAAE,CAAC;AACjE,CAAC;AAEK,SAAU,kBAAkB,CAAC,OAAoB,EAAA;AACnD,IAAA,MAAM,YAAY,GAAG,OAAO,CAAC,aAAa,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;AACzD,IAAA,MAAM,UAAU,GAAG;AACf,QAAA,OAAO,CAAC,aAAa;AACrB,QAAA,OAAO,CAAC,WAAW;AACnB,QAAA,YAAY,IAAI,OAAO,CAAC,QAAQ,IAAI,EAAE;KACzC,CAAC;IAEF,OAAO,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,WAAW,EAAE,CAAC;AAC9D;;;;"}

View File

@ -0,0 +1,431 @@
/*! @azure/msal-node v5.2.2 2026-05-19 */
'use strict';
import { CacheManager, StubPerformanceClient, AccountEntityUtils, CacheHelpers } from '@azure/msal-common/node';
import { Deserializer } from './serializer/Deserializer.mjs';
import { Serializer } from './serializer/Serializer.mjs';
import { generateCredentialKey, generateAccountKey } from './CacheHelpers.mjs';
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/
/**
* This class implements Storage for node, reading cache from user specified storage location or an extension library
* @public
*/
class NodeStorage extends CacheManager {
constructor(logger, clientId, cryptoImpl, staticAuthorityOptions) {
super(clientId, cryptoImpl, logger, new StubPerformanceClient(), staticAuthorityOptions);
this.cache = {};
this.changeEmitters = [];
this.logger = logger;
}
/**
* Queue up callbacks
* @param func - a callback function for cache change indication
*/
registerChangeEmitter(func) {
this.changeEmitters.push(func);
}
/**
* Invoke the callback when cache changes
*/
emitChange() {
this.changeEmitters.forEach((func) => func.call(null));
}
/**
* Converts cacheKVStore to InMemoryCache
* @param cache - key value store
*/
cacheToInMemoryCache(cache) {
const inMemoryCache = {
accounts: {},
idTokens: {},
accessTokens: {},
refreshTokens: {},
appMetadata: {},
};
for (const key in cache) {
const value = cache[key];
if (typeof value !== "object") {
continue;
}
if (AccountEntityUtils.isAccountEntity(value)) {
inMemoryCache.accounts[key] = value;
}
else if (CacheHelpers.isIdTokenEntity(value)) {
inMemoryCache.idTokens[key] = value;
}
else if (CacheHelpers.isAccessTokenEntity(value)) {
inMemoryCache.accessTokens[key] = value;
}
else if (CacheHelpers.isRefreshTokenEntity(value)) {
inMemoryCache.refreshTokens[key] = value;
}
else if (CacheHelpers.isAppMetadataEntity(key, value)) {
inMemoryCache.appMetadata[key] = value;
}
else {
continue;
}
}
return inMemoryCache;
}
/**
* converts inMemoryCache to CacheKVStore
* @param inMemoryCache - kvstore map for inmemory
*/
inMemoryCacheToCache(inMemoryCache) {
// convert in memory cache to a flat Key-Value map
let cache = this.getCache();
cache = {
...cache,
...inMemoryCache.accounts,
...inMemoryCache.idTokens,
...inMemoryCache.accessTokens,
...inMemoryCache.refreshTokens,
...inMemoryCache.appMetadata,
};
// convert in memory cache to a flat Key-Value map
return cache;
}
/**
* gets the current in memory cache for the client
*/
getInMemoryCache() {
this.logger.trace("Getting in-memory cache", "");
// convert the cache key value store to inMemoryCache
const inMemoryCache = this.cacheToInMemoryCache(this.getCache());
return inMemoryCache;
}
/**
* sets the current in memory cache for the client
* @param inMemoryCache - key value map in memory
*/
setInMemoryCache(inMemoryCache) {
this.logger.trace("Setting in-memory cache", "");
// convert and append the inMemoryCache to cacheKVStore
const cache = this.inMemoryCacheToCache(inMemoryCache);
this.setCache(cache);
this.emitChange();
}
/**
* get the current cache key-value store
*/
getCache() {
this.logger.trace("Getting cache key-value store", "");
return this.cache;
}
/**
* sets the current cache (key value store)
* @param cacheMap - key value map
*/
setCache(cache) {
this.logger.trace("Setting cache key value store", "");
this.cache = cache;
// mark change in cache
this.emitChange();
}
/**
* Gets cache item with given key.
* @param key - lookup key for the cache entry
*/
getItem(key) {
this.logger.tracePii(`Item key: ${key}`, "");
// read cache
const cache = this.getCache();
return cache[key];
}
/**
* Gets cache item with given key-value
* @param key - lookup key for the cache entry
* @param value - value of the cache entry
*/
setItem(key, value) {
this.logger.tracePii(`Item key: ${key}`, "");
// read cache
const cache = this.getCache();
cache[key] = value;
// write to cache
this.setCache(cache);
}
generateCredentialKey(credential) {
return generateCredentialKey(credential);
}
generateAccountKey(account) {
return generateAccountKey(account);
}
getAccountKeys() {
const inMemoryCache = this.getInMemoryCache();
const accountKeys = Object.keys(inMemoryCache.accounts);
return accountKeys;
}
getTokenKeys() {
const inMemoryCache = this.getInMemoryCache();
const tokenKeys = {
idToken: Object.keys(inMemoryCache.idTokens),
accessToken: Object.keys(inMemoryCache.accessTokens),
refreshToken: Object.keys(inMemoryCache.refreshTokens),
};
return tokenKeys;
}
/**
* Reads account from cache, builds it into an account entity and returns it.
* @param accountKey - lookup key to fetch cache type AccountEntity
* @returns
*/
getAccount(accountKey) {
const cachedAccount = this.getItem(accountKey);
return cachedAccount && typeof cachedAccount === "object"
? { ...cachedAccount }
: null;
}
/**
* set account entity
* @param account - cache value to be set of type AccountEntity
*/
async setAccount(account) {
const accountKey = this.generateAccountKey(AccountEntityUtils.getAccountInfo(account));
this.setItem(accountKey, account);
}
/**
* fetch the idToken credential
* @param idTokenKey - lookup key to fetch cache type IdTokenEntity
*/
getIdTokenCredential(idTokenKey) {
const idToken = this.getItem(idTokenKey);
if (CacheHelpers.isIdTokenEntity(idToken)) {
return idToken;
}
return null;
}
/**
* set idToken credential
* @param idToken - cache value to be set of type IdTokenEntity
*/
async setIdTokenCredential(idToken) {
const idTokenKey = this.generateCredentialKey(idToken);
this.setItem(idTokenKey, idToken);
}
/**
* fetch the accessToken credential
* @param accessTokenKey - lookup key to fetch cache type AccessTokenEntity
*/
getAccessTokenCredential(accessTokenKey) {
const accessToken = this.getItem(accessTokenKey);
if (CacheHelpers.isAccessTokenEntity(accessToken)) {
return accessToken;
}
return null;
}
/**
* set accessToken credential
* @param accessToken - cache value to be set of type AccessTokenEntity
*/
async setAccessTokenCredential(accessToken) {
const accessTokenKey = this.generateCredentialKey(accessToken);
this.setItem(accessTokenKey, accessToken);
}
/**
* fetch the refreshToken credential
* @param refreshTokenKey - lookup key to fetch cache type RefreshTokenEntity
*/
getRefreshTokenCredential(refreshTokenKey) {
const refreshToken = this.getItem(refreshTokenKey);
if (CacheHelpers.isRefreshTokenEntity(refreshToken)) {
return refreshToken;
}
return null;
}
/**
* set refreshToken credential
* @param refreshToken - cache value to be set of type RefreshTokenEntity
*/
async setRefreshTokenCredential(refreshToken) {
const refreshTokenKey = this.generateCredentialKey(refreshToken);
this.setItem(refreshTokenKey, refreshToken);
}
/**
* fetch appMetadata entity from the platform cache
* @param appMetadataKey - lookup key to fetch cache type AppMetadataEntity
*/
getAppMetadata(appMetadataKey) {
const appMetadata = this.getItem(appMetadataKey);
if (CacheHelpers.isAppMetadataEntity(appMetadataKey, appMetadata)) {
return appMetadata;
}
return null;
}
/**
* set appMetadata entity to the platform cache
* @param appMetadata - cache value to be set of type AppMetadataEntity
*/
setAppMetadata(appMetadata) {
const appMetadataKey = CacheHelpers.generateAppMetadataKey(appMetadata);
this.setItem(appMetadataKey, appMetadata);
}
/**
* fetch server telemetry entity from the platform cache
* @param serverTelemetrykey - lookup key to fetch cache type ServerTelemetryEntity
*/
getServerTelemetry(serverTelemetrykey) {
const serverTelemetryEntity = this.getItem(serverTelemetrykey);
if (serverTelemetryEntity &&
CacheHelpers.isServerTelemetryEntity(serverTelemetrykey, serverTelemetryEntity)) {
return serverTelemetryEntity;
}
return null;
}
/**
* set server telemetry entity to the platform cache
* @param serverTelemetryKey - lookup key to fetch cache type ServerTelemetryEntity
* @param serverTelemetry - cache value to be set of type ServerTelemetryEntity
*/
setServerTelemetry(serverTelemetryKey, serverTelemetry) {
this.setItem(serverTelemetryKey, serverTelemetry);
}
/**
* fetch authority metadata entity from the platform cache
* @param key - lookup key to fetch cache type AuthorityMetadataEntity
*/
getAuthorityMetadata(key) {
const authorityMetadataEntity = this.getItem(key);
if (authorityMetadataEntity &&
CacheHelpers.isAuthorityMetadataEntity(key, authorityMetadataEntity)) {
return authorityMetadataEntity;
}
return null;
}
/**
* Get all authority metadata keys
*/
getAuthorityMetadataKeys() {
return this.getKeys().filter((key) => {
return this.isAuthorityMetadata(key);
});
}
/**
* set authority metadata entity to the platform cache
* @param key - lookup key to fetch cache type AuthorityMetadataEntity
* @param metadata - cache value to be set of type AuthorityMetadataEntity
*/
setAuthorityMetadata(key, metadata) {
this.setItem(key, metadata);
}
/**
* fetch throttling entity from the platform cache
* @param throttlingCacheKey - lookup key to fetch cache type ThrottlingEntity
*/
getThrottlingCache(throttlingCacheKey) {
const throttlingCache = this.getItem(throttlingCacheKey);
if (throttlingCache &&
CacheHelpers.isThrottlingEntity(throttlingCacheKey, throttlingCache)) {
return throttlingCache;
}
return null;
}
/**
* set throttling entity to the platform cache
* @param throttlingCacheKey - lookup key to fetch cache type ThrottlingEntity
* @param throttlingCache - cache value to be set of type ThrottlingEntity
*/
setThrottlingCache(throttlingCacheKey, throttlingCache) {
this.setItem(throttlingCacheKey, throttlingCache);
}
/**
* Removes the cache item from memory with the given key.
* @param key - lookup key to remove a cache entity
* @param inMemory - key value map of the cache
*/
removeItem(key) {
this.logger.tracePii(`Item key: ${key}`, "");
// read inMemoryCache
let result = false;
const cache = this.getCache();
if (!!cache[key]) {
delete cache[key];
result = true;
}
// write to the cache after removal
if (result) {
this.setCache(cache);
this.emitChange();
}
return result;
}
/**
* Remove account entity from the platform cache if it's outdated
* @param accountKey - lookup key to fetch cache type AccountEntity
*/
removeOutdatedAccount(accountKey) {
this.removeItem(accountKey);
}
/**
* Checks whether key is in cache.
* @param key - look up key for a cache entity
*/
containsKey(key) {
return this.getKeys().includes(key);
}
/**
* Gets all keys in window.
*/
getKeys() {
this.logger.trace("Retrieving all cache keys", "");
// read cache
const cache = this.getCache();
return [...Object.keys(cache)];
}
/**
* Clears all cache entries created by MSAL except authority metadata..
*/
clear() {
this.logger.trace("Clearing cache entries created by MSAL", "");
// read inMemoryCache
const cacheKeys = this.getKeys();
// delete each element
cacheKeys.forEach((key) => {
if (this.isAuthorityMetadata(key)) {
return;
}
this.removeItem(key);
});
this.emitChange();
}
/**
* Initialize in memory cache from an exisiting cache vault
* @param cache - blob formatted cache (JSON)
*/
static generateInMemoryCache(cache) {
return Deserializer.deserializeAllCache(Deserializer.deserializeJSONBlob(cache));
}
/**
* retrieves the final JSON
* @param inMemoryCache - itemised cache read from the JSON
*/
static generateJsonCache(inMemoryCache) {
return Serializer.serializeAllCache(inMemoryCache);
}
/**
* Updates a credential's cache key if the current cache key is outdated
*/
updateCredentialCacheKey(currentCacheKey, credential) {
const updatedCacheKey = this.generateCredentialKey(credential);
if (currentCacheKey !== updatedCacheKey) {
const cacheItem = this.getItem(currentCacheKey);
if (cacheItem) {
this.removeItem(currentCacheKey);
this.setItem(updatedCacheKey, cacheItem);
this.logger.verbose(`Updated an outdated ${credential.credentialType} cache key`, "");
return updatedCacheKey;
}
else {
this.logger.error(`Attempted to update an outdated ${credential.credentialType} cache key but no item matching the outdated key was found in storage`, "");
}
}
return currentCacheKey;
}
}
export { NodeStorage };
//# sourceMappingURL=NodeStorage.mjs.map

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,300 @@
/*! @azure/msal-node v5.2.2 2026-05-19 */
'use strict';
import { NodeStorage } from './NodeStorage.mjs';
import { TokenCacheContext } from '@azure/msal-common/node';
import { Deserializer } from './serializer/Deserializer.mjs';
import { Serializer } from './serializer/Serializer.mjs';
import { GuidGenerator } from '../crypto/GuidGenerator.mjs';
import { CryptoProvider } from '../crypto/CryptoProvider.mjs';
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/
const defaultSerializedCache = {
Account: {},
IdToken: {},
AccessToken: {},
RefreshToken: {},
AppMetadata: {},
};
/**
* In-memory token cache manager
* @public
*/
class TokenCache {
constructor(storage, logger, cachePlugin) {
this.cacheHasChanged = false;
this.storage = storage;
this.storage.registerChangeEmitter(this.handleChangeEvent.bind(this));
if (cachePlugin) {
this.persistence = cachePlugin;
}
this.logger = logger;
}
/**
* Set to true if cache state has changed since last time serialize or writeToPersistence was called
*/
hasChanged() {
return this.cacheHasChanged;
}
/**
* Serializes in memory cache to JSON
*/
serialize() {
this.logger.trace("Serializing in-memory cache", "");
let finalState = Serializer.serializeAllCache(this.storage.getInMemoryCache());
// if cacheSnapshot not null or empty, merge
if (this.cacheSnapshot) {
this.logger.trace("Reading cache snapshot from disk", "");
finalState = this.mergeState(JSON.parse(this.cacheSnapshot), finalState);
}
else {
this.logger.trace("No cache snapshot to merge", "");
}
this.cacheHasChanged = false;
return JSON.stringify(finalState);
}
/**
* Deserializes JSON to in-memory cache. JSON should be in MSAL cache schema format
* @param cache - blob formatted cache
*/
deserialize(cache) {
this.logger.trace("Deserializing JSON to in-memory cache", "");
this.cacheSnapshot = cache;
if (this.cacheSnapshot) {
this.logger.trace("Reading cache snapshot from disk", "");
const deserializedCache = Deserializer.deserializeAllCache(this.overlayDefaults(JSON.parse(this.cacheSnapshot)));
this.storage.setInMemoryCache(deserializedCache);
}
else {
this.logger.trace("No cache snapshot to deserialize", "");
}
}
/**
* Fetches the cache key-value map
*/
getKVStore() {
return this.storage.getCache();
}
/**
* Gets cache snapshot in CacheKVStore format
*/
getCacheSnapshot() {
const deserializedPersistentStorage = NodeStorage.generateInMemoryCache(this.cacheSnapshot);
return this.storage.inMemoryCacheToCache(deserializedPersistentStorage);
}
/**
* API that retrieves all accounts currently in cache to the user
*/
async getAllAccounts(correlationId = new CryptoProvider().createNewGuid()) {
this.logger.trace("getAllAccounts called", correlationId);
let cacheContext;
try {
if (this.persistence) {
cacheContext = new TokenCacheContext(this, false);
await this.persistence.beforeCacheAccess(cacheContext);
}
return this.storage.getAllAccounts({}, correlationId);
}
finally {
if (this.persistence && cacheContext) {
await this.persistence.afterCacheAccess(cacheContext);
}
}
}
/**
* Returns the signed in account matching homeAccountId.
* (the account object is created at the time of successful login)
* or null when no matching account is found
* @param homeAccountId - unique identifier for an account (uid.utid)
*/
async getAccountByHomeId(homeAccountId) {
const allAccounts = await this.getAllAccounts();
if (homeAccountId && allAccounts && allAccounts.length) {
return (allAccounts.filter((accountObj) => accountObj.homeAccountId === homeAccountId)[0] || null);
}
else {
return null;
}
}
/**
* Returns the signed in account matching localAccountId.
* (the account object is created at the time of successful login)
* or null when no matching account is found
* @param localAccountId - unique identifier of an account (sub/obj when homeAccountId cannot be populated)
*/
async getAccountByLocalId(localAccountId) {
const allAccounts = await this.getAllAccounts();
if (localAccountId && allAccounts && allAccounts.length) {
return (allAccounts.filter((accountObj) => accountObj.localAccountId === localAccountId)[0] || null);
}
else {
return null;
}
}
/**
* API to remove a specific account and the relevant data from cache
* @param account - AccountInfo passed by the user
*/
async removeAccount(account, correlationId) {
this.logger.trace("removeAccount called", correlationId || "");
let cacheContext;
try {
if (this.persistence) {
cacheContext = new TokenCacheContext(this, true);
await this.persistence.beforeCacheAccess(cacheContext);
}
this.storage.removeAccount(account, correlationId || new GuidGenerator().generateGuid());
}
finally {
if (this.persistence && cacheContext) {
await this.persistence.afterCacheAccess(cacheContext);
}
}
}
/**
* Overwrites in-memory cache with persistent cache
*/
async overwriteCache() {
if (!this.persistence) {
this.logger.info("No persistence layer specified, cache cannot be overwritten", "");
return;
}
this.logger.info("Overwriting in-memory cache with persistent cache", "");
this.storage.clear();
const cacheContext = new TokenCacheContext(this, false);
await this.persistence.beforeCacheAccess(cacheContext);
const cacheSnapshot = this.getCacheSnapshot();
this.storage.setCache(cacheSnapshot);
await this.persistence.afterCacheAccess(cacheContext);
}
/**
* Called when the cache has changed state.
*/
handleChangeEvent() {
this.cacheHasChanged = true;
}
/**
* Merge in memory cache with the cache snapshot.
* @param oldState - cache before changes
* @param currentState - current cache state in the library
*/
mergeState(oldState, currentState) {
this.logger.trace("Merging in-memory cache with cache snapshot", "");
const stateAfterRemoval = this.mergeRemovals(oldState, currentState);
return this.mergeUpdates(stateAfterRemoval, currentState);
}
/**
* Deep update of oldState based on newState values
* @param oldState - cache before changes
* @param newState - updated cache
*/
mergeUpdates(oldState, newState) {
Object.keys(newState).forEach((newKey) => {
const newValue = newState[newKey];
// if oldState does not contain value but newValue does, add it
if (!oldState.hasOwnProperty(newKey)) {
if (newValue !== null) {
oldState[newKey] = newValue;
}
}
else {
// both oldState and newState contain the key, do deep update
const newValueNotNull = newValue !== null;
const newValueIsObject = typeof newValue === "object";
const newValueIsNotArray = !Array.isArray(newValue);
const oldStateNotUndefinedOrNull = typeof oldState[newKey] !== "undefined" &&
oldState[newKey] !== null;
if (newValueNotNull &&
newValueIsObject &&
newValueIsNotArray &&
oldStateNotUndefinedOrNull) {
this.mergeUpdates(oldState[newKey], newValue);
}
else {
oldState[newKey] = newValue;
}
}
});
return oldState;
}
/**
* Removes entities in oldState that the were removed from newState. If there are any unknown values in root of
* oldState that are not recognized, they are left untouched.
* @param oldState - cache before changes
* @param newState - updated cache
*/
mergeRemovals(oldState, newState) {
this.logger.trace("Remove updated entries in cache", "");
const accounts = oldState.Account
? this.mergeRemovalsDict(oldState.Account, newState.Account)
: oldState.Account;
const accessTokens = oldState.AccessToken
? this.mergeRemovalsDict(oldState.AccessToken, newState.AccessToken)
: oldState.AccessToken;
const refreshTokens = oldState.RefreshToken
? this.mergeRemovalsDict(oldState.RefreshToken, newState.RefreshToken)
: oldState.RefreshToken;
const idTokens = oldState.IdToken
? this.mergeRemovalsDict(oldState.IdToken, newState.IdToken)
: oldState.IdToken;
const appMetadata = oldState.AppMetadata
? this.mergeRemovalsDict(oldState.AppMetadata, newState.AppMetadata)
: oldState.AppMetadata;
return {
...oldState,
Account: accounts,
AccessToken: accessTokens,
RefreshToken: refreshTokens,
IdToken: idTokens,
AppMetadata: appMetadata,
};
}
/**
* Helper to merge new cache with the old one
* @param oldState - cache before changes
* @param newState - updated cache
*/
mergeRemovalsDict(oldState, newState) {
const finalState = { ...oldState };
Object.keys(oldState).forEach((oldKey) => {
if (!newState || !newState.hasOwnProperty(oldKey)) {
delete finalState[oldKey];
}
});
return finalState;
}
/**
* Helper to overlay as a part of cache merge
* @param passedInCache - cache read from the blob
*/
overlayDefaults(passedInCache) {
this.logger.trace("Overlaying input cache with the default cache", "");
return {
Account: {
...defaultSerializedCache.Account,
...passedInCache.Account,
},
IdToken: {
...defaultSerializedCache.IdToken,
...passedInCache.IdToken,
},
AccessToken: {
...defaultSerializedCache.AccessToken,
...passedInCache.AccessToken,
},
RefreshToken: {
...defaultSerializedCache.RefreshToken,
...passedInCache.RefreshToken,
},
AppMetadata: {
...defaultSerializedCache.AppMetadata,
...passedInCache.AppMetadata,
},
};
}
}
export { TokenCache };
//# sourceMappingURL=TokenCache.mjs.map

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,49 @@
/*! @azure/msal-node v5.2.2 2026-05-19 */
'use strict';
import { AccountEntityUtils } from '@azure/msal-common/node';
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/
/**
* Cache plugin that serializes data to the cache and deserializes data from the cache
* @public
*/
class DistributedCachePlugin {
constructor(client, partitionManager) {
this.client = client;
this.partitionManager = partitionManager;
}
/**
* Deserializes the cache before accessing it
* @param cacheContext - TokenCacheContext
*/
async beforeCacheAccess(cacheContext) {
const partitionKey = await this.partitionManager.getKey();
const cacheData = await this.client.get(partitionKey);
cacheContext.tokenCache.deserialize(cacheData);
}
/**
* Serializes the cache after accessing it
* @param cacheContext - TokenCacheContext
*/
async afterCacheAccess(cacheContext) {
if (cacheContext.cacheHasChanged) {
const kvStore = cacheContext.tokenCache.getKVStore();
const accountEntities = Object.values(kvStore).filter((value) => AccountEntityUtils.isAccountEntity(value));
let partitionKey;
if (accountEntities.length > 0) {
const accountEntity = accountEntities[0];
partitionKey = await this.partitionManager.extractKey(accountEntity);
}
else {
partitionKey = await this.partitionManager.getKey();
}
await this.client.set(partitionKey, cacheContext.tokenCache.serialize());
}
}
}
export { DistributedCachePlugin };
//# sourceMappingURL=DistributedCachePlugin.mjs.map

View File

@ -0,0 +1 @@
{"version":3,"file":"DistributedCachePlugin.mjs","sources":["../../../src/cache/distributed/DistributedCachePlugin.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;AAAA;;;AAGG;AAYH;;;AAGG;MACU,sBAAsB,CAAA;IAI/B,WAAY,CAAA,MAAoB,EAAE,gBAAmC,EAAA;AACjE,QAAA,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;AACrB,QAAA,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;KAC5C;AAED;;;AAGG;IACI,MAAM,iBAAiB,CAC1B,YAA+B,EAAA;QAE/B,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAC,MAAM,EAAE,CAAC;QAC1D,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;AACtD,QAAA,YAAY,CAAC,UAAU,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;KAClD;AAED;;;AAGG;IACI,MAAM,gBAAgB,CACzB,YAA+B,EAAA;QAE/B,IAAI,YAAY,CAAC,eAAe,EAAE;YAC9B,MAAM,OAAO,GACT,YAAY,CAAC,UAChB,CAAC,UAAU,EAAE,CAAC;YACf,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,KAAK,KACxD,kBAAkB,CAAC,eAAe,CAAC,KAAe,CAAC,CACtD,CAAC;AAEF,YAAA,IAAI,YAAoB,CAAC;AACzB,YAAA,IAAI,eAAe,CAAC,MAAM,GAAG,CAAC,EAAE;AAC5B,gBAAA,MAAM,aAAa,GAAG,eAAe,CAAC,CAAC,CAAkB,CAAC;gBAC1D,YAAY,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAC,UAAU,CACjD,aAAa,CAChB,CAAC;AACL,aAAA;AAAM,iBAAA;gBACH,YAAY,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAC,MAAM,EAAE,CAAC;AACvD,aAAA;AAED,YAAA,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CACjB,YAAY,EACZ,YAAY,CAAC,UAAU,CAAC,SAAS,EAAE,CACtC,CAAC;AACL,SAAA;KACJ;AACJ;;;;"}

View File

@ -0,0 +1,178 @@
/*! @azure/msal-node v5.2.2 2026-05-19 */
'use strict';
import { CacheManager } from '@azure/msal-common/node';
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/
/**
* This class deserializes cache entities read from the file into in-memory object types defined internally
* @internal
*/
class Deserializer {
/**
* Parse the JSON blob in memory and deserialize the content
* @param cachedJson - JSON blob cache
*/
static deserializeJSONBlob(jsonFile) {
const deserializedCache = !jsonFile ? {} : JSON.parse(jsonFile);
return deserializedCache;
}
/**
* Deserializes accounts to AccountEntity objects
* @param accounts - accounts of type SerializedAccountEntity
*/
static deserializeAccounts(accounts) {
const accountObjects = {};
if (accounts) {
Object.keys(accounts).map(function (key) {
const serializedAcc = accounts[key];
const mappedAcc = {
homeAccountId: serializedAcc.home_account_id,
environment: serializedAcc.environment,
realm: serializedAcc.realm,
localAccountId: serializedAcc.local_account_id,
username: serializedAcc.username,
authorityType: serializedAcc.authority_type,
name: serializedAcc.name,
clientInfo: serializedAcc.client_info,
lastModificationTime: serializedAcc.last_modification_time,
lastModificationApp: serializedAcc.last_modification_app,
tenantProfiles: serializedAcc.tenantProfiles?.map((serializedTenantProfile) => {
return JSON.parse(serializedTenantProfile);
}),
lastUpdatedAt: Date.now().toString(),
};
const account = {};
CacheManager.toObject(account, mappedAcc);
accountObjects[key] = account;
});
}
return accountObjects;
}
/**
* Deserializes id tokens to IdTokenEntity objects
* @param idTokens - credentials of type SerializedIdTokenEntity
*/
static deserializeIdTokens(idTokens) {
const idObjects = {};
if (idTokens) {
Object.keys(idTokens).map(function (key) {
const serializedIdT = idTokens[key];
const idToken = {
homeAccountId: serializedIdT.home_account_id,
environment: serializedIdT.environment,
credentialType: serializedIdT.credential_type,
clientId: serializedIdT.client_id,
secret: serializedIdT.secret,
realm: serializedIdT.realm,
lastUpdatedAt: Date.now().toString(),
};
idObjects[key] = idToken;
});
}
return idObjects;
}
/**
* Deserializes access tokens to AccessTokenEntity objects
* @param accessTokens - access tokens of type SerializedAccessTokenEntity
*/
static deserializeAccessTokens(accessTokens) {
const atObjects = {};
if (accessTokens) {
Object.keys(accessTokens).map(function (key) {
const serializedAT = accessTokens[key];
const accessToken = {
homeAccountId: serializedAT.home_account_id,
environment: serializedAT.environment,
credentialType: serializedAT.credential_type,
clientId: serializedAT.client_id,
secret: serializedAT.secret,
realm: serializedAT.realm,
target: serializedAT.target,
cachedAt: serializedAT.cached_at,
expiresOn: serializedAT.expires_on,
extendedExpiresOn: serializedAT.extended_expires_on,
refreshOn: serializedAT.refresh_on,
keyId: serializedAT.key_id,
tokenType: serializedAT.token_type,
userAssertionHash: serializedAT.userAssertionHash,
resource: serializedAT.resource,
lastUpdatedAt: Date.now().toString(),
};
atObjects[key] = accessToken;
});
}
return atObjects;
}
/**
* Deserializes refresh tokens to RefreshTokenEntity objects
* @param refreshTokens - refresh tokens of type SerializedRefreshTokenEntity
*/
static deserializeRefreshTokens(refreshTokens) {
const rtObjects = {};
if (refreshTokens) {
Object.keys(refreshTokens).map(function (key) {
const serializedRT = refreshTokens[key];
const refreshToken = {
homeAccountId: serializedRT.home_account_id,
environment: serializedRT.environment,
credentialType: serializedRT.credential_type,
clientId: serializedRT.client_id,
secret: serializedRT.secret,
familyId: serializedRT.family_id,
target: serializedRT.target,
realm: serializedRT.realm,
lastUpdatedAt: Date.now().toString(),
};
rtObjects[key] = refreshToken;
});
}
return rtObjects;
}
/**
* Deserializes appMetadata to AppMetaData objects
* @param appMetadata - app metadata of type SerializedAppMetadataEntity
*/
static deserializeAppMetadata(appMetadata) {
const appMetadataObjects = {};
if (appMetadata) {
Object.keys(appMetadata).map(function (key) {
const serializedAmdt = appMetadata[key];
appMetadataObjects[key] = {
clientId: serializedAmdt.client_id,
environment: serializedAmdt.environment,
familyId: serializedAmdt.family_id,
};
});
}
return appMetadataObjects;
}
/**
* Deserialize an inMemory Cache
* @param jsonCache - JSON blob cache
*/
static deserializeAllCache(jsonCache) {
return {
accounts: jsonCache.Account
? this.deserializeAccounts(jsonCache.Account)
: {},
idTokens: jsonCache.IdToken
? this.deserializeIdTokens(jsonCache.IdToken)
: {},
accessTokens: jsonCache.AccessToken
? this.deserializeAccessTokens(jsonCache.AccessToken)
: {},
refreshTokens: jsonCache.RefreshToken
? this.deserializeRefreshTokens(jsonCache.RefreshToken)
: {},
appMetadata: jsonCache.AppMetadata
? this.deserializeAppMetadata(jsonCache.AppMetadata)
: {},
};
}
}
export { Deserializer };
//# sourceMappingURL=Deserializer.mjs.map

View File

@ -0,0 +1 @@
{"version":3,"file":"Deserializer.mjs","sources":["../../../src/cache/serializer/Deserializer.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;AAAA;;;AAGG;AAyBH;;;AAGG;MACU,YAAY,CAAA;AACrB;;;AAGG;IACH,OAAO,mBAAmB,CAAC,QAAgB,EAAA;AACvC,QAAA,MAAM,iBAAiB,GAAG,CAAC,QAAQ,GAAG,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;AAChE,QAAA,OAAO,iBAAiB,CAAC;KAC5B;AAED;;;AAGG;IACH,OAAO,mBAAmB,CACtB,QAAiD,EAAA;QAEjD,MAAM,cAAc,GAAiB,EAAE,CAAC;AACxC,QAAA,IAAI,QAAQ,EAAE;YACV,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,UAAU,GAAG,EAA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EAAE;YACb,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,GAAG,CAAC,UAAU,GAAG,EAAA;AACtC,gBAAA,MAAM,cAAc,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC;gBACxC,kBAAkB,CAAC,GAAG,CAAC,GAAG;oBACtB,QAAQ,EAAE,cAAc,CAAC,SAAS;oBAClC,WAAW,EAAE,cAAc,CAAC,WAAW;oBACvC,QAAQ,EAAE,cAAc,CAAC,SAAS;iBACrC,CAAC;AACN,aAAC,CAAC,CAAC;AACN,SAAA;AAED,QAAA,OAAO,kBAAkB,CAAC;KAC7B;AAED;;;AAGG;IACH,OAAO,mBAAmB,CAAC,SAAoB,EAAA;QAC3C,OAAO;YACH,QAAQ,EAAE,SAAS,CAAC,OAAO;kBACrB,IAAI,CAAC,mBAAmB,CAAC,SAAS,CAAC,OAAO,CAAC;AAC7C,kBAAE,EAAE;YACR,QAAQ,EAAE,SAAS,CAAC,OAAO;kBACrB,IAAI,CAAC,mBAAmB,CAAC,SAAS,CAAC,OAAO,CAAC;AAC7C,kBAAE,EAAE;YACR,YAAY,EAAE,SAAS,CAAC,WAAW;kBAC7B,IAAI,CAAC,uBAAuB,CAAC,SAAS,CAAC,WAAW,CAAC;AACrD,kBAAE,EAAE;YACR,aAAa,EAAE,SAAS,CAAC,YAAY;kBAC/B,IAAI,CAAC,wBAAwB,CAAC,SAAS,CAAC,YAAY,CAAC;AACvD,kBAAE,EAAE;YACR,WAAW,EAAE,SAAS,CAAC,WAAW;kBAC5B,IAAI,CAAC,sBAAsB,CAAC,SAAS,CAAC,WAAW,CAAC;AACpD,kBAAE,EAAE;SACX,CAAC;KACL;AACJ;;;;"}

View File

@ -0,0 +1,145 @@
/*! @azure/msal-node v5.2.2 2026-05-19 */
'use strict';
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/
/**
* This class serializes cache entities to be saved into in-memory object types defined internally
* @internal
*/
class Serializer {
/**
* serialize the JSON blob
* @param data - JSON blob cache
*/
static serializeJSONBlob(data) {
return JSON.stringify(data);
}
/**
* Serialize Accounts
* @param accCache - cache of accounts
*/
static serializeAccounts(accCache) {
const accounts = {};
Object.keys(accCache).map(function (key) {
const accountEntity = accCache[key];
accounts[key] = {
home_account_id: accountEntity.homeAccountId,
environment: accountEntity.environment,
realm: accountEntity.realm,
local_account_id: accountEntity.localAccountId,
username: accountEntity.username,
authority_type: accountEntity.authorityType,
name: accountEntity.name,
client_info: accountEntity.clientInfo,
last_modification_time: accountEntity.lastModificationTime,
last_modification_app: accountEntity.lastModificationApp,
tenantProfiles: accountEntity.tenantProfiles?.map((tenantProfile) => {
return JSON.stringify(tenantProfile);
}),
};
});
return accounts;
}
/**
* Serialize IdTokens
* @param idTCache - cache of ID tokens
*/
static serializeIdTokens(idTCache) {
const idTokens = {};
Object.keys(idTCache).map(function (key) {
const idTEntity = idTCache[key];
idTokens[key] = {
home_account_id: idTEntity.homeAccountId,
environment: idTEntity.environment,
credential_type: idTEntity.credentialType,
client_id: idTEntity.clientId,
secret: idTEntity.secret,
realm: idTEntity.realm,
};
});
return idTokens;
}
/**
* Serializes AccessTokens
* @param atCache - cache of access tokens
*/
static serializeAccessTokens(atCache) {
const accessTokens = {};
Object.keys(atCache).map(function (key) {
const atEntity = atCache[key];
accessTokens[key] = {
home_account_id: atEntity.homeAccountId,
environment: atEntity.environment,
credential_type: atEntity.credentialType,
client_id: atEntity.clientId,
secret: atEntity.secret,
realm: atEntity.realm,
target: atEntity.target,
cached_at: atEntity.cachedAt,
expires_on: atEntity.expiresOn,
extended_expires_on: atEntity.extendedExpiresOn,
refresh_on: atEntity.refreshOn,
key_id: atEntity.keyId,
token_type: atEntity.tokenType,
userAssertionHash: atEntity.userAssertionHash,
resource: atEntity.resource,
};
});
return accessTokens;
}
/**
* Serialize refreshTokens
* @param rtCache - cache of refresh tokens
*/
static serializeRefreshTokens(rtCache) {
const refreshTokens = {};
Object.keys(rtCache).map(function (key) {
const rtEntity = rtCache[key];
refreshTokens[key] = {
home_account_id: rtEntity.homeAccountId,
environment: rtEntity.environment,
credential_type: rtEntity.credentialType,
client_id: rtEntity.clientId,
secret: rtEntity.secret,
family_id: rtEntity.familyId,
target: rtEntity.target,
realm: rtEntity.realm,
};
});
return refreshTokens;
}
/**
* Serialize amdtCache
* @param amdtCache - cache of app metadata
*/
static serializeAppMetadata(amdtCache) {
const appMetadata = {};
Object.keys(amdtCache).map(function (key) {
const amdtEntity = amdtCache[key];
appMetadata[key] = {
client_id: amdtEntity.clientId,
environment: amdtEntity.environment,
family_id: amdtEntity.familyId,
};
});
return appMetadata;
}
/**
* Serialize the cache
* @param inMemCache - itemised cache read from the JSON
*/
static serializeAllCache(inMemCache) {
return {
Account: this.serializeAccounts(inMemCache.accounts),
IdToken: this.serializeIdTokens(inMemCache.idTokens),
AccessToken: this.serializeAccessTokens(inMemCache.accessTokens),
RefreshToken: this.serializeRefreshTokens(inMemCache.refreshTokens),
AppMetadata: this.serializeAppMetadata(inMemCache.appMetadata),
};
}
}
export { Serializer };
//# sourceMappingURL=Serializer.mjs.map

View File

@ -0,0 +1 @@
{"version":3,"file":"Serializer.mjs","sources":["../../../src/cache/serializer/Serializer.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAAA;;;AAGG;AAmBH;;;AAGG;MACU,UAAU,CAAA;AACnB;;;AAGG;IACH,OAAO,iBAAiB,CAAC,IAAe,EAAA;AACpC,QAAA,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;KAC/B;AAED;;;AAGG;IACH,OAAO,iBAAiB,CACpB,QAAsB,EAAA;QAEtB,MAAM,QAAQ,GAA4C,EAAE,CAAC;QAC7D,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,UAAU,GAAG,EAAA;AACnC,YAAA,MAAM,aAAa,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC;YACpC,QAAQ,CAAC,GAAG,CAAC,GAAG;gBACZ,eAAe,EAAE,aA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