@azure/msal-node
Advanced tools
Comparing version 1.3.0 to 1.3.1
@@ -5,2 +5,55 @@ { | ||
{ | ||
"date": "Tue, 07 Sep 2021 23:22:24 GMT", | ||
"tag": "@azure/msal-node_v1.3.1", | ||
"version": "1.3.1", | ||
"comments": { | ||
"patch": [ | ||
{ | ||
"comment": "Add removeTokenBindingKey missing method to Node's CryptoProvider #3500", | ||
"author": "hemoral@microsoft.com", | ||
"commit": "6592652877f31405c8ed73a66f03eada90a78c0a", | ||
"package": "@azure/msal-node" | ||
}, | ||
{ | ||
"comment": "Add correlationId to errors #3930", | ||
"author": "thomas.norling@microsoft.com", | ||
"commit": "b16839505be79b646f131f09d747adb90a613176", | ||
"package": "@azure/msal-node" | ||
}, | ||
{ | ||
"comment": "Remove non-null assertions #3994", | ||
"author": "thomas.norling@microsoft.com", | ||
"commit": "17cbef3c32f01e526e33964df21b0cda19e632b9", | ||
"package": "@azure/msal-node" | ||
}, | ||
{ | ||
"comment": "Add correlationId to AuthenticationResult type #3947", | ||
"author": "thomas.norling@microsoft.com", | ||
"commit": "1752261b00e773d5187f8d0a9520bdf5f95ee8d6", | ||
"package": "@azure/msal-node" | ||
}, | ||
{ | ||
"comment": "Fixes biased code verifier generation #3993", | ||
"author": "thomas.norling@microsoft.com", | ||
"commit": "80434004e06dc11f3770ba84e5ead1c45f449156", | ||
"package": "@azure/msal-node" | ||
} | ||
], | ||
"none": [ | ||
{ | ||
"comment": "Fix accesstoken_with_authscheme implementation #3910", | ||
"author": "hemoral@microsoft.com", | ||
"commit": "9aceb4219ebad900277aa6a59ca1ff93c5a21e0a", | ||
"package": "@azure/msal-node" | ||
}, | ||
{ | ||
"comment": "patch fix", | ||
"author": "ellymakuba@microsoft.com", | ||
"commit": "6f6c1fa9987d62a68583c513c4baabe4041eaf17", | ||
"package": "@azure/msal-node" | ||
} | ||
] | ||
} | ||
}, | ||
{ | ||
"date": "Thu, 22 Jul 2021 22:50:22 GMT", | ||
@@ -7,0 +60,0 @@ "tag": "@azure/msal-node_v1.3.0", |
# Change Log - @azure/msal-node | ||
This log was last generated on Thu, 22 Jul 2021 22:50:22 GMT and should not be manually modified. | ||
This log was last generated on Tue, 07 Sep 2021 23:22:24 GMT and should not be manually modified. | ||
<!-- Start content --> | ||
## 1.3.1 | ||
Tue, 07 Sep 2021 23:22:24 GMT | ||
### Patches | ||
- Add removeTokenBindingKey missing method to Node's CryptoProvider #3500 (hemoral@microsoft.com) | ||
- Add correlationId to errors #3930 (thomas.norling@microsoft.com) | ||
- Remove non-null assertions #3994 (thomas.norling@microsoft.com) | ||
- Add correlationId to AuthenticationResult type #3947 (thomas.norling@microsoft.com) | ||
- Fixes biased code verifier generation #3993 (thomas.norling@microsoft.com) | ||
## 1.3.0 | ||
@@ -8,0 +20,0 @@ |
@@ -165,3 +165,3 @@ import { AccountEntity, IdTokenEntity, AccessTokenEntity, RefreshTokenEntity, AppMetadataEntity, ServerTelemetryEntity, ThrottlingEntity, CacheManager, Logger, ValidCacheType, ICrypto, AuthorityMetadataEntity } from "@azure/msal-common"; | ||
*/ | ||
clear(): void; | ||
clear(): Promise<void>; | ||
/** | ||
@@ -168,0 +168,0 @@ * Initialize in memory cache from an exisiting cache vault |
import { ClientConfiguration, AuthenticationResult, BaseAuthRequest, Logger, ServerTelemetryManager, AzureRegionConfiguration } from "@azure/msal-common"; | ||
import { Configuration } from "../config/Configuration"; | ||
import { Configuration, NodeConfiguration } from "../config/Configuration"; | ||
import { NodeStorage } from "../cache/NodeStorage"; | ||
@@ -29,3 +29,3 @@ import { TokenCache } from "../cache/TokenCache"; | ||
*/ | ||
protected config: Configuration; | ||
protected config: NodeConfiguration; | ||
/** | ||
@@ -32,0 +32,0 @@ * Client assertion passed by the user for confidential client flows |
@@ -61,2 +61,7 @@ import { LoggerOptions, INetworkModule, ProtocolMode, ICachePlugin } from "@azure/msal-common"; | ||
}; | ||
export declare type NodeConfiguration = { | ||
auth: Required<NodeAuthOptions>; | ||
cache: CacheOptions; | ||
system: Required<NodeSystemOptions>; | ||
}; | ||
/** | ||
@@ -72,3 +77,3 @@ * Sets the default options when not explicitly configured from app developer | ||
*/ | ||
export declare function buildAppConfiguration({ auth, cache, system, }: Configuration): Configuration; | ||
export declare function buildAppConfiguration({ auth, cache, system, }: Configuration): NodeConfiguration; | ||
//# sourceMappingURL=Configuration.d.ts.map |
@@ -34,2 +34,11 @@ import { ICrypto, PkceCodes } from "@azure/msal-common"; | ||
/** | ||
* Removes cryptographic keypair from key store matching the keyId passed in | ||
* @param kid | ||
*/ | ||
removeTokenBindingKey(): Promise<boolean>; | ||
/** | ||
* Removes all cryptographic keys from Keystore | ||
*/ | ||
clearKeystore(): Promise<boolean>; | ||
/** | ||
* Signs the given object as a jwt payload with private key retrieved by given kid - currently not implemented for node | ||
@@ -36,0 +45,0 @@ */ |
@@ -25,8 +25,3 @@ import { PkceCodes } from "@azure/msal-common"; | ||
private sha256; | ||
/** | ||
* Accepted characters; reference: https://tools.ietf.org/html/rfc7636#section-4.1 | ||
* @param buffer | ||
*/ | ||
private bufferToCVString; | ||
} | ||
//# sourceMappingURL=PkceGenerator.d.ts.map |
@@ -1,2 +0,2 @@ | ||
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t,i=require("@azure/msal-common"),r=e(require("axios")),n=require("uuid"),a=e(require("crypto")),s=require("jsonwebtoken");!function(e){e.GET="get",e.POST="post"}(t||(t={}));const o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~";var c;!function(e){e[e.acquireTokenSilent=62]="acquireTokenSilent",e[e.acquireTokenByUsernamePassword=371]="acquireTokenByUsernamePassword",e[e.acquireTokenByDeviceCode=671]="acquireTokenByDeviceCode",e[e.acquireTokenByClientCredential=771]="acquireTokenByClientCredential",e[e.acquireTokenByCode=871]="acquireTokenByCode",e[e.acquireTokenByRefreshToken=872]="acquireTokenByRefreshToken"}(c||(c={}));class l{async sendGetRequestAsync(e,i){const n={method:t.GET,url:e,headers:i&&i.headers,validateStatus:()=>!0},a=await r(n);return{headers:a.headers,body:a.data,status:a.status}}async sendPostRequestAsync(e,i,n){const a={method:t.POST,url:e,data:i&&i.body||"",timeout:n,headers:i&&i.headers,validateStatus:()=>!0},s=await r(a);return{headers:s.headers,body:s.data,status:s.status}}}const h={clientId:"",authority:i.Constants.DEFAULT_AUTHORITY,clientSecret:"",clientAssertion:"",clientCertificate:{thumbprint:"",privateKey:"",x5c:""},knownAuthorities:[],cloudDiscoveryMetadata:"",authorityMetadata:"",clientCapabilities:[],protocolMode:i.ProtocolMode.AAD},u={},d={loggerOptions:{loggerCallback:()=>{},piiLoggingEnabled:!1,logLevel:i.LogLevel.Info},networkClient:class{static getNetworkClient(){return new l}}.getNetworkClient()};function g({auth:e,cache:t,system:i}){return{auth:{...h,...e},cache:{...u,...t},system:{...d,...i}}}class p{static base64Encode(e,t){return Buffer.from(e,t).toString("base64")}static base64EncodeUrl(e,t){return p.base64Encode(e,t).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}static base64Decode(e){return Buffer.from(e,"base64").toString("utf8")}static base64DecodeUrl(e){let t=e.replace(/-/g,"+").replace(/_/g,"/");for(;t.length%4;)t+="=";return p.base64Decode(t)}}class y{async generatePkceCodes(){const e=this.generateCodeVerifier();return{verifier:e,challenge:this.generateCodeChallengeFromVerifier(e)}}generateCodeVerifier(){const e=a.randomBytes(32),t=this.bufferToCVString(e);return p.base64EncodeUrl(t)}generateCodeChallengeFromVerifier(e){return p.base64EncodeUrl(this.sha256(e).toString("base64"),"base64")}sha256(e){return a.createHash("sha256").update(e).digest()}bufferToCVString(e){const t=[];for(let i=0;i<e.byteLength;i+=1)t.push(o[e[i]%o.length]);return t.join("")}}class m{constructor(){this.pkceGenerator=new y}createNewGuid(){return class{static generateGuid(){return n.v4()}static isGuid(e){return/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(e)}}.generateGuid()}base64Encode(e){return p.base64Encode(e)}base64Decode(e){return p.base64Decode(e)}generatePkceCodes(){return this.pkceGenerator.generatePkceCodes()}getPublicKeyThumbprint(){throw new Error("Method not implemented.")}signJwt(){throw new Error("Method not implemented.")}}class f{static deserializeJSONBlob(e){return i.StringUtils.isEmpty(e)?{}:JSON.parse(e)}static deserializeAccounts(e){const t={};return e&&Object.keys(e).map((function(r){const n=e[r],a={homeAccountId:n.home_account_id,environment:n.environment,realm:n.realm,localAccountId:n.local_account_id,username:n.username,authorityType:n.authority_type,name:n.name,clientInfo:n.client_info,lastModificationTime:n.last_modification_time,lastModificationApp:n.last_modification_app},s=new i.AccountEntity;i.CacheManager.toObject(s,a),t[r]=s})),t}static deserializeIdTokens(e){const t={};return e&&Object.keys(e).map((function(r){const n=e[r],a={homeAccountId:n.home_account_id,environment:n.environment,credentialType:n.credential_type,clientId:n.client_id,secret:n.secret,realm:n.realm},s=new i.IdTokenEntity;i.CacheManager.toObject(s,a),t[r]=s})),t}static deserializeAccessTokens(e){const t={};return e&&Object.keys(e).map((function(r){const n=e[r],a={homeAccountId:n.home_account_id,environment:n.environment,credentialType:n.credential_type,clientId:n.client_id,secret:n.secret,realm:n.realm,target:n.target,cachedAt:n.cached_at,expiresOn:n.expires_on,extendedExpiresOn:n.extended_expires_on,refreshOn:n.refresh_on,keyId:n.key_id,tokenType:n.token_type},s=new i.AccessTokenEntity;i.CacheManager.toObject(s,a),t[r]=s})),t}static deserializeRefreshTokens(e){const t={};return e&&Object.keys(e).map((function(r){const n=e[r],a={homeAccountId:n.home_account_id,environment:n.environment,credentialType:n.credential_type,clientId:n.client_id,secret:n.secret,familyId:n.family_id,target:n.target,realm:n.realm},s=new i.RefreshTokenEntity;i.CacheManager.toObject(s,a),t[r]=s})),t}static deserializeAppMetadata(e){const t={};return e&&Object.keys(e).map((function(r){const n=e[r],a={clientId:n.client_id,environment:n.environment,familyId:n.family_id},s=new i.AppMetadataEntity;i.CacheManager.toObject(s,a),t[r]=s})),t}static deserializeAllCache(e){return{accounts:e.Account?this.deserializeAccounts(e.Account):{},idTokens:e.IdToken?this.deserializeIdTokens(e.IdToken):{},accessTokens:e.AccessToken?this.deserializeAccessTokens(e.AccessToken):{},refreshTokens:e.RefreshToken?this.deserializeRefreshTokens(e.RefreshToken):{},appMetadata:e.AppMetadata?this.deserializeAppMetadata(e.AppMetadata):{}}}}class C{static serializeJSONBlob(e){return JSON.stringify(e)}static serializeAccounts(e){const t={};return Object.keys(e).map((function(i){const r=e[i];t[i]={home_account_id:r.homeAccountId,environment:r.environment,realm:r.realm,local_account_id:r.localAccountId,username:r.username,authority_type:r.authorityType,name:r.name,client_info:r.clientInfo,last_modification_time:r.lastModificationTime,last_modification_app:r.lastModificationApp}})),t}static serializeIdTokens(e){const t={};return Object.keys(e).map((function(i){const r=e[i];t[i]={home_account_id:r.homeAccountId,environment:r.environment,credential_type:r.credentialType,client_id:r.clientId,secret:r.secret,realm:r.realm}})),t}static serializeAccessTokens(e){const t={};return Object.keys(e).map((function(i){const r=e[i];t[i]={home_account_id:r.homeAccountId,environment:r.environment,credential_type:r.credentialType,client_id:r.clientId,secret:r.secret,realm:r.realm,target:r.target,cached_at:r.cachedAt,expires_on:r.expiresOn,extended_expires_on:r.extendedExpiresOn,refresh_on:r.refreshOn,key_id:r.keyId,token_type:r.tokenType}})),t}static serializeRefreshTokens(e){const t={};return Object.keys(e).map((function(i){const r=e[i];t[i]={home_account_id:r.homeAccountId,environment:r.environment,credential_type:r.credentialType,client_id:r.clientId,secret:r.secret,family_id:r.familyId,target:r.target,realm:r.realm}})),t}static serializeAppMetadata(e){const t={};return Object.keys(e).map((function(i){const r=e[i];t[i]={client_id:r.clientId,environment:r.environment,family_id:r.familyId}})),t}static serializeAllCache(e){return{Account:this.serializeAccounts(e.accounts),IdToken:this.serializeIdTokens(e.idTokens),AccessToken:this.serializeAccessTokens(e.accessTokens),RefreshToken:this.serializeRefreshTokens(e.refreshTokens),AppMetadata:this.serializeAppMetadata(e.appMetadata)}}}class A extends i.CacheManager{constructor(e,t,i){super(t,i),this.cache={},this.changeEmitters=[],this.logger=e}registerChangeEmitter(e){this.changeEmitters.push(e)}emitChange(){this.changeEmitters.forEach(e=>e.call(null))}cacheToInMemoryCache(e){const t={accounts:{},idTokens:{},accessTokens:{},refreshTokens:{},appMetadata:{}};for(const r in e)if(e[r]instanceof i.AccountEntity)t.accounts[r]=e[r];else if(e[r]instanceof i.IdTokenEntity)t.idTokens[r]=e[r];else if(e[r]instanceof i.AccessTokenEntity)t.accessTokens[r]=e[r];else if(e[r]instanceof i.RefreshTokenEntity)t.refreshTokens[r]=e[r];else{if(!(e[r]instanceof i.AppMetadataEntity))continue;t.appMetadata[r]=e[r]}return t}inMemoryCacheToCache(e){let t=this.getCache();return t={...e.accounts,...e.idTokens,...e.accessTokens,...e.refreshTokens,...e.appMetadata},t}getInMemoryCache(){return this.logger.trace("Getting in-memory cache"),this.cacheToInMemoryCache(this.getCache())}setInMemoryCache(e){this.logger.trace("Setting in-memory cache");const t=this.inMemoryCacheToCache(e);this.setCache(t),this.emitChange()}getCache(){return this.logger.trace("Getting cache key-value store"),this.cache}setCache(e){this.logger.trace("Setting cache key value store"),this.cache=e,this.emitChange()}getItem(e){return this.logger.tracePii("Item key: "+e),this.getCache()[e]}setItem(e,t){this.logger.tracePii("Item key: "+e);const i=this.getCache();i[e]=t,this.setCache(i)}getAccount(e){const t=this.getItem(e);return i.AccountEntity.isAccountEntity(t)?t:null}setAccount(e){const t=e.generateAccountKey();this.setItem(t,e)}getIdTokenCredential(e){const t=this.getItem(e);return i.IdTokenEntity.isIdTokenEntity(t)?t:null}setIdTokenCredential(e){const t=e.generateCredentialKey();this.setItem(t,e)}getAccessTokenCredential(e){const t=this.getItem(e);return i.AccessTokenEntity.isAccessTokenEntity(t)?t:null}setAccessTokenCredential(e){const t=e.generateCredentialKey();this.setItem(t,e)}getRefreshTokenCredential(e){const t=this.getItem(e);return i.RefreshTokenEntity.isRefreshTokenEntity(t)?t:null}setRefreshTokenCredential(e){const t=e.generateCredentialKey();this.setItem(t,e)}getAppMetadata(e){const t=this.getItem(e);return i.AppMetadataEntity.isAppMetadataEntity(e,t)?t:null}setAppMetadata(e){const t=e.generateAppMetadataKey();this.setItem(t,e)}getServerTelemetry(e){const t=this.getItem(e);return t&&i.ServerTelemetryEntity.isServerTelemetryEntity(e,t)?t:null}setServerTelemetry(e,t){this.setItem(e,t)}getAuthorityMetadata(e){const t=this.getItem(e);return t&&i.AuthorityMetadataEntity.isAuthorityMetadataEntity(e,t)?t:null}getAuthorityMetadataKeys(){return this.getKeys().filter(e=>this.isAuthorityMetadata(e))}setAuthorityMetadata(e,t){this.setItem(e,t)}getThrottlingCache(e){const t=this.getItem(e);return t&&i.ThrottlingEntity.isThrottlingEntity(e,t)?t:null}setThrottlingCache(e,t){this.setItem(e,t)}removeItem(e){this.logger.tracePii("Item key: "+e);let t=!1;const i=this.getCache();return i[e]&&(delete i[e],t=!0),t&&(this.setCache(i),this.emitChange()),t}containsKey(e){return this.getKeys().includes(e)}getKeys(){this.logger.trace("Retrieving all cache keys");const e=this.getCache();return[...Object.keys(e)]}clear(){this.logger.trace("Clearing cache entries created by MSAL"),this.getKeys().forEach(e=>{this.removeItem(e)}),this.emitChange()}static generateInMemoryCache(e){return f.deserializeAllCache(f.deserializeJSONBlob(e))}static generateJsonCache(e){return C.serializeAllCache(e)}}const k={},T={},I={},b={},v={};class E{constructor(e,t,i){this.cacheHasChanged=!1,this.storage=e,this.storage.registerChangeEmitter(this.handleChangeEvent.bind(this)),i&&(this.persistence=i),this.logger=t}hasChanged(){return this.cacheHasChanged}serialize(){this.logger.trace("Serializing in-memory cache");let e=C.serializeAllCache(this.storage.getInMemoryCache());return i.StringUtils.isEmpty(this.cacheSnapshot)?this.logger.trace("No cache snapshot to merge"):(this.logger.trace("Reading cache snapshot from disk"),e=this.mergeState(JSON.parse(this.cacheSnapshot),e)),this.cacheHasChanged=!1,JSON.stringify(e)}deserialize(e){if(this.logger.trace("Deserializing JSON to in-memory cache"),this.cacheSnapshot=e,i.StringUtils.isEmpty(this.cacheSnapshot))this.logger.trace("No cache snapshot to deserialize");else{this.logger.trace("Reading cache snapshot from disk");const e=f.deserializeAllCache(this.overlayDefaults(JSON.parse(this.cacheSnapshot)));this.storage.setInMemoryCache(e)}}getKVStore(){return this.storage.getCache()}async getAllAccounts(){let e;this.logger.trace("getAllAccounts called");try{return this.persistence&&(e=new i.TokenCacheContext(this,!1),await this.persistence.beforeCacheAccess(e)),this.storage.getAllAccounts()}finally{this.persistence&&e&&await this.persistence.afterCacheAccess(e)}}async getAccountByHomeId(e){const t=await this.getAllAccounts();return!i.StringUtils.isEmpty(e)&&t&&t.length&&t.filter(t=>t.homeAccountId===e)[0]||null}async getAccountByLocalId(e){const t=await this.getAllAccounts();return!i.StringUtils.isEmpty(e)&&t&&t.length&&t.filter(t=>t.localAccountId===e)[0]||null}async removeAccount(e){let t;this.logger.trace("removeAccount called");try{this.persistence&&(t=new i.TokenCacheContext(this,!0),await this.persistence.beforeCacheAccess(t)),this.storage.removeAccount(i.AccountEntity.generateAccountCacheKey(e))}finally{this.persistence&&t&&await this.persistence.afterCacheAccess(t)}}handleChangeEvent(){this.cacheHasChanged=!0}mergeState(e,t){this.logger.trace("Merging in-memory cache with cache snapshot");const i=this.mergeRemovals(e,t);return this.mergeUpdates(i,t)}mergeUpdates(e,t){return Object.keys(t).forEach(i=>{const r=t[i];if(e.hasOwnProperty(i)){const t=null!==r,n="object"==typeof r,a=!Array.isArray(r),s=null!=e[i];t&&n&&a&&s?this.mergeUpdates(e[i],r):e[i]=r}else null!==r&&(e[i]=r)}),e}mergeRemovals(e,t){this.logger.trace("Remove updated entries in cache");const i=e.Account?this.mergeRemovalsDict(e.Account,t.Account):e.Account,r=e.AccessToken?this.mergeRemovalsDict(e.AccessToken,t.AccessToken):e.AccessToken,n=e.RefreshToken?this.mergeRemovalsDict(e.RefreshToken,t.RefreshToken):e.RefreshToken,a=e.IdToken?this.mergeRemovalsDict(e.IdToken,t.IdToken):e.IdToken,s=e.AppMetadata?this.mergeRemovalsDict(e.AppMetadata,t.AppMetadata):e.AppMetadata;return{...e,Account:i,AccessToken:r,RefreshToken:n,IdToken:a,AppMetadata:s}}mergeRemovalsDict(e,t){const i={...e};return Object.keys(e).forEach(e=>{t&&t.hasOwnProperty(e)||delete i[e]}),i}overlayDefaults(e){return this.logger.trace("Overlaying input cache with the default cache"),{Account:{...k,...e.Account},IdToken:{...T,...e.IdToken},AccessToken:{...I,...e.AccessToken},RefreshToken:{...b,...e.RefreshToken},AppMetadata:{...v,...e.AppMetadata}}}}class w{constructor(e){this.config=g(e),this.cryptoProvider=new m,this.logger=new i.Logger(this.config.system.loggerOptions,"@azure/msal-node","1.3.0"),this.storage=new A(this.logger,this.config.auth.clientId,this.cryptoProvider),this.tokenCache=new E(this.storage,this.logger,this.config.cache.cachePlugin)}async getAuthCodeUrl(e){this.logger.info("getAuthCodeUrl called",e.correlationId);const t={...e,...this.initializeBaseRequest(e),responseMode:e.responseMode||i.ResponseMode.QUERY,authenticationScheme:i.AuthenticationScheme.BEARER},r=await this.buildOauthClientConfiguration(t.authority,t.correlationId),n=new i.AuthorizationCodeClient(r);return this.logger.verbose("Auth code client created",t.correlationId),n.getAuthCodeUrl(t)}async acquireTokenByCode(e){this.logger.info("acquireTokenByCode called",e.correlationId);const t={...e,...this.initializeBaseRequest(e),authenticationScheme:i.AuthenticationScheme.BEARER},r=this.initializeServerTelemetryManager(c.acquireTokenByCode,t.correlationId);try{const e=await this.buildOauthClientConfiguration(t.authority,t.correlationId,r),n=new i.AuthorizationCodeClient(e);return this.logger.verbose("Auth code client created",t.correlationId),n.acquireToken(t)}catch(e){throw r.cacheFailedRequest(e),e}}async acquireTokenByRefreshToken(e){this.logger.info("acquireTokenByRefreshToken called",e.correlationId);const t={...e,...this.initializeBaseRequest(e),authenticationScheme:i.AuthenticationScheme.BEARER},r=this.initializeServerTelemetryManager(c.acquireTokenByRefreshToken,t.correlationId);try{const e=await this.buildOauthClientConfiguration(t.authority,t.correlationId,r),n=new i.RefreshTokenClient(e);return this.logger.verbose("Refresh token client created",t.correlationId),n.acquireToken(t)}catch(e){throw r.cacheFailedRequest(e),e}}async acquireTokenSilent(e){const t={...e,...this.initializeBaseRequest(e),forceRefresh:e.forceRefresh||!1},r=this.initializeServerTelemetryManager(c.acquireTokenSilent,t.correlationId,t.forceRefresh);try{const e=await this.buildOauthClientConfiguration(t.authority,t.correlationId,r),n=new i.SilentFlowClient(e);return this.logger.verbose("Silent flow client created",t.correlationId),n.acquireToken(t)}catch(e){throw r.cacheFailedRequest(e),e}}async acquireTokenByUsernamePassword(e){this.logger.info("acquireTokenByUsernamePassword called",e.correlationId);const t={...e,...this.initializeBaseRequest(e)},r=this.initializeServerTelemetryManager(c.acquireTokenByUsernamePassword,t.correlationId);try{const e=await this.buildOauthClientConfiguration(t.authority,t.correlationId,r),n=new i.UsernamePasswordClient(e);return this.logger.verbose("Username password client created",t.correlationId),n.acquireToken(t)}catch(e){throw r.cacheFailedRequest(e),e}}getTokenCache(){return this.logger.info("getTokenCache called"),this.tokenCache}getLogger(){return this.logger}setLogger(e){this.logger=e}async buildOauthClientConfiguration(e,t,i,r){this.logger.verbose("buildOauthClientConfiguration called",t),this.logger.verbose("building oauth client configuration with the authority: "+e,t);const n=await this.createAuthority(e,r,t);return null==i||i.updateRegionDiscoveryMetadata(n.regionDiscoveryMetadata),{authOptions:{clientId:this.config.auth.clientId,authority:n,clientCapabilities:this.config.auth.clientCapabilities},loggerOptions:{logLevel:this.config.system.loggerOptions.logLevel,loggerCallback:this.config.system.loggerOptions.loggerCallback,piiLoggingEnabled:this.config.system.loggerOptions.piiLoggingEnabled,correlationId:t},cryptoInterface:this.cryptoProvider,networkInterface:this.config.system.networkClient,storageInterface:this.storage,serverTelemetryManager:i,clientCredentials:{clientSecret:this.clientSecret,clientAssertion:this.clientAssertion?this.getClientAssertion(n):void 0},libraryInfo:{sku:"msal.js.node",version:"1.3.0",cpu:process.arch||"",os:process.platform||""},persistencePlugin:this.config.cache.cachePlugin,serializableCache:this.tokenCache}}getClientAssertion(e){return{assertion:this.clientAssertion.getJwt(this.cryptoProvider,this.config.auth.clientId,e.tokenEndpoint),assertionType:"urn:ietf:params:oauth:client-assertion-type:jwt-bearer"}}initializeBaseRequest(e){return this.logger.verbose("initializeRequestScopes called",e.correlationId),e.authenticationScheme&&e.authenticationScheme===i.AuthenticationScheme.POP&&this.logger.verbose("Authentication Scheme 'pop' is not supported yet, setting Authentication Scheme to 'Bearer' for request",e.correlationId),e.authenticationScheme=i.AuthenticationScheme.BEARER,{...e,scopes:[...e&&e.scopes||[],...i.OIDC_DEFAULT_SCOPES],correlationId:e&&e.correlationId||this.cryptoProvider.createNewGuid(),authority:e.authority||this.config.auth.authority}}initializeServerTelemetryManager(e,t,r){return new i.ServerTelemetryManager({clientId:this.config.auth.clientId,correlationId:t,apiId:e,forceRefresh:r||!1},this.storage)}async createAuthority(e,t,r){this.logger.verbose("createAuthority called",r);const n={protocolMode:this.config.auth.protocolMode,knownAuthorities:this.config.auth.knownAuthorities,cloudDiscoveryMetadata:this.config.auth.cloudDiscoveryMetadata,authorityMetadata:this.config.auth.authorityMetadata,azureRegionConfiguration:t};return await i.AuthorityFactory.createDiscoveredInstance(e,this.config.system.networkClient,this.storage,n)}}class M{static fromAssertion(e){const t=new M;return t.jwt=e,t}static fromCertificate(e,t,i){const r=new M;return r.privateKey=t,r.thumbprint=e,i&&(r.publicCertificate=this.parseCertificate(i)),r}getJwt(e,t,r){if(this.privateKey&&this.thumbprint)return this.jwt&&!this.isExpired()&&t===this.issuer&&r===this.jwtAudience?this.jwt:this.createJwt(e,t,r);if(this.jwt)return this.jwt;throw i.ClientAuthError.createInvalidAssertionError()}createJwt(e,t,r){this.issuer=t,this.jwtAudience=r;const n=i.TimeUtils.nowSeconds();this.expirationTime=n+600;const a={alg:"RS256",x5t:p.base64EncodeUrl(this.thumbprint,"hex")};this.publicCertificate&&Object.assign(a,{x5c:this.publicCertificate});const o={aud:this.jwtAudience,exp:this.expirationTime,iss:this.issuer,sub:this.issuer,nbf:n,jti:e.createNewGuid()};return this.jwt=s.sign(o,this.privateKey,{header:a}),this.jwt}isExpired(){return this.expirationTime<i.TimeUtils.nowSeconds()}static parseCertificate(e){const t=/-----BEGIN CERTIFICATE-----\n(.+?)\n-----END CERTIFICATE-----/gs,i=[];let r;for(;null!==(r=t.exec(e));)i.push(r[1].replace(/\n/,""));return i}}Object.defineProperty(exports,"AuthError",{enumerable:!0,get:function(){return i.AuthError}}),Object.defineProperty(exports,"AuthErrorMessage",{enumerable:!0,get:function(){return i.AuthErrorMessage}}),Object.defineProperty(exports,"ClientAuthError",{enumerable:!0,get:function(){return i.ClientAuthError}}),Object.defineProperty(exports,"ClientAuthErrorMessage",{enumerable:!0,get:function(){return i.ClientAuthErrorMessage}}),Object.defineProperty(exports,"ClientConfigurationError",{enumerable:!0,get:function(){return i.ClientConfigurationError}}),Object.defineProperty(exports,"ClientConfigurationErrorMessage",{enumerable:!0,get:function(){return i.ClientConfigurationErrorMessage}}),Object.defineProperty(exports,"InteractionRequiredAuthError",{enumerable:!0,get:function(){return i.InteractionRequiredAuthError}}),Object.defineProperty(exports,"LogLevel",{enumerable:!0,get:function(){return i.LogLevel}}),Object.defineProperty(exports,"Logger",{enumerable:!0,get:function(){return i.Logger}}),Object.defineProperty(exports,"PromptValue",{enumerable:!0,get:function(){return i.PromptValue}}),Object.defineProperty(exports,"ProtocolMode",{enumerable:!0,get:function(){return i.ProtocolMode}}),Object.defineProperty(exports,"ResponseMode",{enumerable:!0,get:function(){return i.ResponseMode}}),Object.defineProperty(exports,"ServerError",{enumerable:!0,get:function(){return i.ServerError}}),Object.defineProperty(exports,"TokenCacheContext",{enumerable:!0,get:function(){return i.TokenCacheContext}}),exports.ClientApplication=w,exports.ClientAssertion=M,exports.ConfidentialClientApplication=class extends w{constructor(e){super(e),this.setClientCredential(this.config)}async acquireTokenByClientCredential(e){this.logger.info("acquireTokenByClientCredential called",e.correlationId);const t={...e,...this.initializeBaseRequest(e)},r={azureRegion:t.azureRegion,environmentRegion:process.env.REGION_NAME},n=this.initializeServerTelemetryManager(c.acquireTokenByClientCredential,t.correlationId,t.skipCache);try{const e=await this.buildOauthClientConfiguration(t.authority,t.correlationId,n,r),a=new i.ClientCredentialClient(e);return this.logger.verbose("Client credential client created",t.correlationId),a.acquireToken(t)}catch(e){throw n.cacheFailedRequest(e),e}}async acquireTokenOnBehalfOf(e){this.logger.info("acquireTokenOnBehalfOf called",e.correlationId);const t={...e,...this.initializeBaseRequest(e)},r=await this.buildOauthClientConfiguration(t.authority,t.correlationId),n=new i.OnBehalfOfClient(r);return this.logger.verbose("On behalf of client created",t.correlationId),n.acquireToken(t)}setClientCredential(e){const t=!i.StringUtils.isEmpty(e.auth.clientSecret),r=!i.StringUtils.isEmpty(e.auth.clientAssertion),n=e.auth.clientCertificate,a=!i.StringUtils.isEmpty(n.thumbprint)||!i.StringUtils.isEmpty(n.privateKey);if(t&&r||r&&a||t&&a)throw i.ClientAuthError.createInvalidCredentialError();if(t)this.clientSecret=e.auth.clientSecret;else if(r)this.clientAssertion=M.fromAssertion(e.auth.clientAssertion);else{if(!a)throw i.ClientAuthError.createInvalidCredentialError();var s;this.clientAssertion=M.fromCertificate(n.thumbprint,n.privateKey,null==(s=e.auth.clientCertificate)?void 0:s.x5c)}}},exports.CryptoProvider=m,exports.NodeStorage=A,exports.PublicClientApplication=class extends w{constructor(e){super(e)}async acquireTokenByDeviceCode(e){this.logger.info("acquireTokenByDeviceCode called",e.correlationId);const t=Object.assign(e,this.initializeBaseRequest(e)),r=this.initializeServerTelemetryManager(c.acquireTokenByDeviceCode,t.correlationId);try{const e=await this.buildOauthClientConfiguration(t.authority,t.correlationId,r),n=new i.DeviceCodeClient(e);return this.logger.verbose("Device code client created",t.correlationId),n.acquireToken(t)}catch(e){throw r.cacheFailedRequest(e),e}}},exports.TokenCache=E,exports.buildAppConfiguration=g; | ||
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t,i=require("@azure/msal-common"),r=e(require("axios")),n=require("uuid"),o=e(require("crypto")),a=require("jsonwebtoken");!function(e){e.GET="get",e.POST="post"}(t||(t={}));const s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~";var c;!function(e){e[e.acquireTokenSilent=62]="acquireTokenSilent",e[e.acquireTokenByUsernamePassword=371]="acquireTokenByUsernamePassword",e[e.acquireTokenByDeviceCode=671]="acquireTokenByDeviceCode",e[e.acquireTokenByClientCredential=771]="acquireTokenByClientCredential",e[e.acquireTokenByCode=871]="acquireTokenByCode",e[e.acquireTokenByRefreshToken=872]="acquireTokenByRefreshToken"}(c||(c={}));class l{async sendGetRequestAsync(e,i){const n={method:t.GET,url:e,headers:i&&i.headers,validateStatus:()=>!0},o=await r(n);return{headers:o.headers,body:o.data,status:o.status}}async sendPostRequestAsync(e,i,n){const o={method:t.POST,url:e,data:i&&i.body||"",timeout:n,headers:i&&i.headers,validateStatus:()=>!0},a=await r(o);return{headers:a.headers,body:a.data,status:a.status}}}const h={clientId:"",authority:i.Constants.DEFAULT_AUTHORITY,clientSecret:"",clientAssertion:"",clientCertificate:{thumbprint:"",privateKey:"",x5c:""},knownAuthorities:[],cloudDiscoveryMetadata:"",authorityMetadata:"",clientCapabilities:[],protocolMode:i.ProtocolMode.AAD},u={},d={loggerOptions:{loggerCallback:()=>{},piiLoggingEnabled:!1,logLevel:i.LogLevel.Info},networkClient:class{static getNetworkClient(){return new l}}.getNetworkClient()};function g({auth:e,cache:t,system:i}){return{auth:{...h,...e},cache:{...u,...t},system:{...d,...i}}}class p{static base64Encode(e,t){return Buffer.from(e,t).toString("base64")}static base64EncodeUrl(e,t){return p.base64Encode(e,t).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}static base64Decode(e){return Buffer.from(e,"base64").toString("utf8")}static base64DecodeUrl(e){let t=e.replace(/-/g,"+").replace(/_/g,"/");for(;t.length%4;)t+="=";return p.base64Decode(t)}}class y{async generatePkceCodes(){const e=this.generateCodeVerifier();return{verifier:e,challenge:this.generateCodeChallengeFromVerifier(e)}}generateCodeVerifier(){const e=[],t=256-256%s.length;for(;e.length<=32;){const i=o.randomBytes(1)[0];i>=t||e.push(s[i%s.length])}const i=e.join("");return p.base64EncodeUrl(i)}generateCodeChallengeFromVerifier(e){return p.base64EncodeUrl(this.sha256(e).toString("base64"),"base64")}sha256(e){return o.createHash("sha256").update(e).digest()}}class m{constructor(){this.pkceGenerator=new y}createNewGuid(){return class{static generateGuid(){return n.v4()}static isGuid(e){return/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(e)}}.generateGuid()}base64Encode(e){return p.base64Encode(e)}base64Decode(e){return p.base64Decode(e)}generatePkceCodes(){return this.pkceGenerator.generatePkceCodes()}getPublicKeyThumbprint(){throw new Error("Method not implemented.")}removeTokenBindingKey(){throw new Error("Method not implemented.")}clearKeystore(){throw new Error("Method not implemented.")}signJwt(){throw new Error("Method not implemented.")}}class f{static deserializeJSONBlob(e){return i.StringUtils.isEmpty(e)?{}:JSON.parse(e)}static deserializeAccounts(e){const t={};return e&&Object.keys(e).map((function(r){const n=e[r],o={homeAccountId:n.home_account_id,environment:n.environment,realm:n.realm,localAccountId:n.local_account_id,username:n.username,authorityType:n.authority_type,name:n.name,clientInfo:n.client_info,lastModificationTime:n.last_modification_time,lastModificationApp:n.last_modification_app},a=new i.AccountEntity;i.CacheManager.toObject(a,o),t[r]=a})),t}static deserializeIdTokens(e){const t={};return e&&Object.keys(e).map((function(r){const n=e[r],o={homeAccountId:n.home_account_id,environment:n.environment,credentialType:n.credential_type,clientId:n.client_id,secret:n.secret,realm:n.realm},a=new i.IdTokenEntity;i.CacheManager.toObject(a,o),t[r]=a})),t}static deserializeAccessTokens(e){const t={};return e&&Object.keys(e).map((function(r){const n=e[r],o={homeAccountId:n.home_account_id,environment:n.environment,credentialType:n.credential_type,clientId:n.client_id,secret:n.secret,realm:n.realm,target:n.target,cachedAt:n.cached_at,expiresOn:n.expires_on,extendedExpiresOn:n.extended_expires_on,refreshOn:n.refresh_on,keyId:n.key_id,tokenType:n.token_type},a=new i.AccessTokenEntity;i.CacheManager.toObject(a,o),t[r]=a})),t}static deserializeRefreshTokens(e){const t={};return e&&Object.keys(e).map((function(r){const n=e[r],o={homeAccountId:n.home_account_id,environment:n.environment,credentialType:n.credential_type,clientId:n.client_id,secret:n.secret,familyId:n.family_id,target:n.target,realm:n.realm},a=new i.RefreshTokenEntity;i.CacheManager.toObject(a,o),t[r]=a})),t}static deserializeAppMetadata(e){const t={};return e&&Object.keys(e).map((function(r){const n=e[r],o={clientId:n.client_id,environment:n.environment,familyId:n.family_id},a=new i.AppMetadataEntity;i.CacheManager.toObject(a,o),t[r]=a})),t}static deserializeAllCache(e){return{accounts:e.Account?this.deserializeAccounts(e.Account):{},idTokens:e.IdToken?this.deserializeIdTokens(e.IdToken):{},accessTokens:e.AccessToken?this.deserializeAccessTokens(e.AccessToken):{},refreshTokens:e.RefreshToken?this.deserializeRefreshTokens(e.RefreshToken):{},appMetadata:e.AppMetadata?this.deserializeAppMetadata(e.AppMetadata):{}}}}class C{static serializeJSONBlob(e){return JSON.stringify(e)}static serializeAccounts(e){const t={};return Object.keys(e).map((function(i){const r=e[i];t[i]={home_account_id:r.homeAccountId,environment:r.environment,realm:r.realm,local_account_id:r.localAccountId,username:r.username,authority_type:r.authorityType,name:r.name,client_info:r.clientInfo,last_modification_time:r.lastModificationTime,last_modification_app:r.lastModificationApp}})),t}static serializeIdTokens(e){const t={};return Object.keys(e).map((function(i){const r=e[i];t[i]={home_account_id:r.homeAccountId,environment:r.environment,credential_type:r.credentialType,client_id:r.clientId,secret:r.secret,realm:r.realm}})),t}static serializeAccessTokens(e){const t={};return Object.keys(e).map((function(i){const r=e[i];t[i]={home_account_id:r.homeAccountId,environment:r.environment,credential_type:r.credentialType,client_id:r.clientId,secret:r.secret,realm:r.realm,target:r.target,cached_at:r.cachedAt,expires_on:r.expiresOn,extended_expires_on:r.extendedExpiresOn,refresh_on:r.refreshOn,key_id:r.keyId,token_type:r.tokenType}})),t}static serializeRefreshTokens(e){const t={};return Object.keys(e).map((function(i){const r=e[i];t[i]={home_account_id:r.homeAccountId,environment:r.environment,credential_type:r.credentialType,client_id:r.clientId,secret:r.secret,family_id:r.familyId,target:r.target,realm:r.realm}})),t}static serializeAppMetadata(e){const t={};return Object.keys(e).map((function(i){const r=e[i];t[i]={client_id:r.clientId,environment:r.environment,family_id:r.familyId}})),t}static serializeAllCache(e){return{Account:this.serializeAccounts(e.accounts),IdToken:this.serializeIdTokens(e.idTokens),AccessToken:this.serializeAccessTokens(e.accessTokens),RefreshToken:this.serializeRefreshTokens(e.refreshTokens),AppMetadata:this.serializeAppMetadata(e.appMetadata)}}}class A extends i.CacheManager{constructor(e,t,i){super(t,i),this.cache={},this.changeEmitters=[],this.logger=e}registerChangeEmitter(e){this.changeEmitters.push(e)}emitChange(){this.changeEmitters.forEach(e=>e.call(null))}cacheToInMemoryCache(e){const t={accounts:{},idTokens:{},accessTokens:{},refreshTokens:{},appMetadata:{}};for(const r in e)if(e[r]instanceof i.AccountEntity)t.accounts[r]=e[r];else if(e[r]instanceof i.IdTokenEntity)t.idTokens[r]=e[r];else if(e[r]instanceof i.AccessTokenEntity)t.accessTokens[r]=e[r];else if(e[r]instanceof i.RefreshTokenEntity)t.refreshTokens[r]=e[r];else{if(!(e[r]instanceof i.AppMetadataEntity))continue;t.appMetadata[r]=e[r]}return t}inMemoryCacheToCache(e){let t=this.getCache();return t={...e.accounts,...e.idTokens,...e.accessTokens,...e.refreshTokens,...e.appMetadata},t}getInMemoryCache(){return this.logger.trace("Getting in-memory cache"),this.cacheToInMemoryCache(this.getCache())}setInMemoryCache(e){this.logger.trace("Setting in-memory cache");const t=this.inMemoryCacheToCache(e);this.setCache(t),this.emitChange()}getCache(){return this.logger.trace("Getting cache key-value store"),this.cache}setCache(e){this.logger.trace("Setting cache key value store"),this.cache=e,this.emitChange()}getItem(e){return this.logger.tracePii("Item key: "+e),this.getCache()[e]}setItem(e,t){this.logger.tracePii("Item key: "+e);const i=this.getCache();i[e]=t,this.setCache(i)}getAccount(e){const t=this.getItem(e);return i.AccountEntity.isAccountEntity(t)?t:null}setAccount(e){const t=e.generateAccountKey();this.setItem(t,e)}getIdTokenCredential(e){const t=this.getItem(e);return i.IdTokenEntity.isIdTokenEntity(t)?t:null}setIdTokenCredential(e){const t=e.generateCredentialKey();this.setItem(t,e)}getAccessTokenCredential(e){const t=this.getItem(e);return i.AccessTokenEntity.isAccessTokenEntity(t)?t:null}setAccessTokenCredential(e){const t=e.generateCredentialKey();this.setItem(t,e)}getRefreshTokenCredential(e){const t=this.getItem(e);return i.RefreshTokenEntity.isRefreshTokenEntity(t)?t:null}setRefreshTokenCredential(e){const t=e.generateCredentialKey();this.setItem(t,e)}getAppMetadata(e){const t=this.getItem(e);return i.AppMetadataEntity.isAppMetadataEntity(e,t)?t:null}setAppMetadata(e){const t=e.generateAppMetadataKey();this.setItem(t,e)}getServerTelemetry(e){const t=this.getItem(e);return t&&i.ServerTelemetryEntity.isServerTelemetryEntity(e,t)?t:null}setServerTelemetry(e,t){this.setItem(e,t)}getAuthorityMetadata(e){const t=this.getItem(e);return t&&i.AuthorityMetadataEntity.isAuthorityMetadataEntity(e,t)?t:null}getAuthorityMetadataKeys(){return this.getKeys().filter(e=>this.isAuthorityMetadata(e))}setAuthorityMetadata(e,t){this.setItem(e,t)}getThrottlingCache(e){const t=this.getItem(e);return t&&i.ThrottlingEntity.isThrottlingEntity(e,t)?t:null}setThrottlingCache(e,t){this.setItem(e,t)}removeItem(e){this.logger.tracePii("Item key: "+e);let t=!1;const i=this.getCache();return i[e]&&(delete i[e],t=!0),t&&(this.setCache(i),this.emitChange()),t}containsKey(e){return this.getKeys().includes(e)}getKeys(){this.logger.trace("Retrieving all cache keys");const e=this.getCache();return[...Object.keys(e)]}async clear(){this.logger.trace("Clearing cache entries created by MSAL"),this.getKeys().forEach(e=>{this.removeItem(e)}),this.emitChange()}static generateInMemoryCache(e){return f.deserializeAllCache(f.deserializeJSONBlob(e))}static generateJsonCache(e){return C.serializeAllCache(e)}}const k={},T={},I={},b={},v={};class E{constructor(e,t,i){this.cacheHasChanged=!1,this.storage=e,this.storage.registerChangeEmitter(this.handleChangeEvent.bind(this)),i&&(this.persistence=i),this.logger=t}hasChanged(){return this.cacheHasChanged}serialize(){this.logger.trace("Serializing in-memory cache");let e=C.serializeAllCache(this.storage.getInMemoryCache());return i.StringUtils.isEmpty(this.cacheSnapshot)?this.logger.trace("No cache snapshot to merge"):(this.logger.trace("Reading cache snapshot from disk"),e=this.mergeState(JSON.parse(this.cacheSnapshot),e)),this.cacheHasChanged=!1,JSON.stringify(e)}deserialize(e){if(this.logger.trace("Deserializing JSON to in-memory cache"),this.cacheSnapshot=e,i.StringUtils.isEmpty(this.cacheSnapshot))this.logger.trace("No cache snapshot to deserialize");else{this.logger.trace("Reading cache snapshot from disk");const e=f.deserializeAllCache(this.overlayDefaults(JSON.parse(this.cacheSnapshot)));this.storage.setInMemoryCache(e)}}getKVStore(){return this.storage.getCache()}async getAllAccounts(){let e;this.logger.trace("getAllAccounts called");try{return this.persistence&&(e=new i.TokenCacheContext(this,!1),await this.persistence.beforeCacheAccess(e)),this.storage.getAllAccounts()}finally{this.persistence&&e&&await this.persistence.afterCacheAccess(e)}}async getAccountByHomeId(e){const t=await this.getAllAccounts();return!i.StringUtils.isEmpty(e)&&t&&t.length&&t.filter(t=>t.homeAccountId===e)[0]||null}async getAccountByLocalId(e){const t=await this.getAllAccounts();return!i.StringUtils.isEmpty(e)&&t&&t.length&&t.filter(t=>t.localAccountId===e)[0]||null}async removeAccount(e){let t;this.logger.trace("removeAccount called");try{this.persistence&&(t=new i.TokenCacheContext(this,!0),await this.persistence.beforeCacheAccess(t)),await this.storage.removeAccount(i.AccountEntity.generateAccountCacheKey(e))}finally{this.persistence&&t&&await this.persistence.afterCacheAccess(t)}}handleChangeEvent(){this.cacheHasChanged=!0}mergeState(e,t){this.logger.trace("Merging in-memory cache with cache snapshot");const i=this.mergeRemovals(e,t);return this.mergeUpdates(i,t)}mergeUpdates(e,t){return Object.keys(t).forEach(i=>{const r=t[i];if(e.hasOwnProperty(i)){const t=null!==r,n="object"==typeof r,o=!Array.isArray(r),a=null!=e[i];t&&n&&o&&a?this.mergeUpdates(e[i],r):e[i]=r}else null!==r&&(e[i]=r)}),e}mergeRemovals(e,t){this.logger.trace("Remove updated entries in cache");const i=e.Account?this.mergeRemovalsDict(e.Account,t.Account):e.Account,r=e.AccessToken?this.mergeRemovalsDict(e.AccessToken,t.AccessToken):e.AccessToken,n=e.RefreshToken?this.mergeRemovalsDict(e.RefreshToken,t.RefreshToken):e.RefreshToken,o=e.IdToken?this.mergeRemovalsDict(e.IdToken,t.IdToken):e.IdToken,a=e.AppMetadata?this.mergeRemovalsDict(e.AppMetadata,t.AppMetadata):e.AppMetadata;return{...e,Account:i,AccessToken:r,RefreshToken:n,IdToken:o,AppMetadata:a}}mergeRemovalsDict(e,t){const i={...e};return Object.keys(e).forEach(e=>{t&&t.hasOwnProperty(e)||delete i[e]}),i}overlayDefaults(e){return this.logger.trace("Overlaying input cache with the default cache"),{Account:{...k,...e.Account},IdToken:{...T,...e.IdToken},AccessToken:{...I,...e.AccessToken},RefreshToken:{...b,...e.RefreshToken},AppMetadata:{...v,...e.AppMetadata}}}}class w{constructor(e){this.config=g(e),this.cryptoProvider=new m,this.logger=new i.Logger(this.config.system.loggerOptions,"@azure/msal-node","1.3.1"),this.storage=new A(this.logger,this.config.auth.clientId,this.cryptoProvider),this.tokenCache=new E(this.storage,this.logger,this.config.cache.cachePlugin)}async getAuthCodeUrl(e){this.logger.info("getAuthCodeUrl called",e.correlationId);const t={...e,...this.initializeBaseRequest(e),responseMode:e.responseMode||i.ResponseMode.QUERY,authenticationScheme:i.AuthenticationScheme.BEARER},r=await this.buildOauthClientConfiguration(t.authority,t.correlationId),n=new i.AuthorizationCodeClient(r);return this.logger.verbose("Auth code client created",t.correlationId),n.getAuthCodeUrl(t)}async acquireTokenByCode(e){this.logger.info("acquireTokenByCode called",e.correlationId);const t={...e,...this.initializeBaseRequest(e),authenticationScheme:i.AuthenticationScheme.BEARER},r=this.initializeServerTelemetryManager(c.acquireTokenByCode,t.correlationId);try{const e=await this.buildOauthClientConfiguration(t.authority,t.correlationId,r),n=new i.AuthorizationCodeClient(e);return this.logger.verbose("Auth code client created",t.correlationId),n.acquireToken(t)}catch(e){throw e instanceof i.AuthError&&e.setCorrelationId(t.correlationId),r.cacheFailedRequest(e),e}}async acquireTokenByRefreshToken(e){this.logger.info("acquireTokenByRefreshToken called",e.correlationId);const t={...e,...this.initializeBaseRequest(e),authenticationScheme:i.AuthenticationScheme.BEARER},r=this.initializeServerTelemetryManager(c.acquireTokenByRefreshToken,t.correlationId);try{const e=await this.buildOauthClientConfiguration(t.authority,t.correlationId,r),n=new i.RefreshTokenClient(e);return this.logger.verbose("Refresh token client created",t.correlationId),n.acquireToken(t)}catch(e){throw e instanceof i.AuthError&&e.setCorrelationId(t.correlationId),r.cacheFailedRequest(e),e}}async acquireTokenSilent(e){const t={...e,...this.initializeBaseRequest(e),forceRefresh:e.forceRefresh||!1},r=this.initializeServerTelemetryManager(c.acquireTokenSilent,t.correlationId,t.forceRefresh);try{const e=await this.buildOauthClientConfiguration(t.authority,t.correlationId,r),n=new i.SilentFlowClient(e);return this.logger.verbose("Silent flow client created",t.correlationId),n.acquireToken(t)}catch(e){throw e instanceof i.AuthError&&e.setCorrelationId(t.correlationId),r.cacheFailedRequest(e),e}}async acquireTokenByUsernamePassword(e){this.logger.info("acquireTokenByUsernamePassword called",e.correlationId);const t={...e,...this.initializeBaseRequest(e)},r=this.initializeServerTelemetryManager(c.acquireTokenByUsernamePassword,t.correlationId);try{const e=await this.buildOauthClientConfiguration(t.authority,t.correlationId,r),n=new i.UsernamePasswordClient(e);return this.logger.verbose("Username password client created",t.correlationId),n.acquireToken(t)}catch(e){throw e instanceof i.AuthError&&e.setCorrelationId(t.correlationId),r.cacheFailedRequest(e),e}}getTokenCache(){return this.logger.info("getTokenCache called"),this.tokenCache}getLogger(){return this.logger}setLogger(e){this.logger=e}async buildOauthClientConfiguration(e,t,i,r){this.logger.verbose("buildOauthClientConfiguration called",t),this.logger.verbose("building oauth client configuration with the authority: "+e,t);const n=await this.createAuthority(e,r,t);return null==i||i.updateRegionDiscoveryMetadata(n.regionDiscoveryMetadata),{authOptions:{clientId:this.config.auth.clientId,authority:n,clientCapabilities:this.config.auth.clientCapabilities},loggerOptions:{logLevel:this.config.system.loggerOptions.logLevel,loggerCallback:this.config.system.loggerOptions.loggerCallback,piiLoggingEnabled:this.config.system.loggerOptions.piiLoggingEnabled,correlationId:t},cryptoInterface:this.cryptoProvider,networkInterface:this.config.system.networkClient,storageInterface:this.storage,serverTelemetryManager:i,clientCredentials:{clientSecret:this.clientSecret,clientAssertion:this.clientAssertion?this.getClientAssertion(n):void 0},libraryInfo:{sku:"msal.js.node",version:"1.3.1",cpu:process.arch||"",os:process.platform||""},persistencePlugin:this.config.cache.cachePlugin,serializableCache:this.tokenCache}}getClientAssertion(e){return{assertion:this.clientAssertion.getJwt(this.cryptoProvider,this.config.auth.clientId,e.tokenEndpoint),assertionType:"urn:ietf:params:oauth:client-assertion-type:jwt-bearer"}}initializeBaseRequest(e){return this.logger.verbose("initializeRequestScopes called",e.correlationId),e.authenticationScheme&&e.authenticationScheme===i.AuthenticationScheme.POP&&this.logger.verbose("Authentication Scheme 'pop' is not supported yet, setting Authentication Scheme to 'Bearer' for request",e.correlationId),e.authenticationScheme=i.AuthenticationScheme.BEARER,{...e,scopes:[...e&&e.scopes||[],...i.OIDC_DEFAULT_SCOPES],correlationId:e&&e.correlationId||this.cryptoProvider.createNewGuid(),authority:e.authority||this.config.auth.authority}}initializeServerTelemetryManager(e,t,r){return new i.ServerTelemetryManager({clientId:this.config.auth.clientId,correlationId:t,apiId:e,forceRefresh:r||!1},this.storage)}async createAuthority(e,t,r){this.logger.verbose("createAuthority called",r);const n={protocolMode:this.config.auth.protocolMode,knownAuthorities:this.config.auth.knownAuthorities,cloudDiscoveryMetadata:this.config.auth.cloudDiscoveryMetadata,authorityMetadata:this.config.auth.authorityMetadata,azureRegionConfiguration:t};return await i.AuthorityFactory.createDiscoveredInstance(e,this.config.system.networkClient,this.storage,n)}}class M{static fromAssertion(e){const t=new M;return t.jwt=e,t}static fromCertificate(e,t,i){const r=new M;return r.privateKey=t,r.thumbprint=e,i&&(r.publicCertificate=this.parseCertificate(i)),r}getJwt(e,t,r){if(this.privateKey&&this.thumbprint)return this.jwt&&!this.isExpired()&&t===this.issuer&&r===this.jwtAudience?this.jwt:this.createJwt(e,t,r);if(this.jwt)return this.jwt;throw i.ClientAuthError.createInvalidAssertionError()}createJwt(e,t,r){this.issuer=t,this.jwtAudience=r;const n=i.TimeUtils.nowSeconds();this.expirationTime=n+600;const o={alg:"RS256",x5t:p.base64EncodeUrl(this.thumbprint,"hex")};this.publicCertificate&&Object.assign(o,{x5c:this.publicCertificate});const s={aud:this.jwtAudience,exp:this.expirationTime,iss:this.issuer,sub:this.issuer,nbf:n,jti:e.createNewGuid()};return this.jwt=a.sign(s,this.privateKey,{header:o}),this.jwt}isExpired(){return this.expirationTime<i.TimeUtils.nowSeconds()}static parseCertificate(e){const t=/-----BEGIN CERTIFICATE-----\n(.+?)\n-----END CERTIFICATE-----/gs,i=[];let r;for(;null!==(r=t.exec(e));)i.push(r[1].replace(/\n/,""));return i}}Object.defineProperty(exports,"AuthError",{enumerable:!0,get:function(){return i.AuthError}}),Object.defineProperty(exports,"AuthErrorMessage",{enumerable:!0,get:function(){return i.AuthErrorMessage}}),Object.defineProperty(exports,"ClientAuthError",{enumerable:!0,get:function(){return i.ClientAuthError}}),Object.defineProperty(exports,"ClientAuthErrorMessage",{enumerable:!0,get:function(){return i.ClientAuthErrorMessage}}),Object.defineProperty(exports,"ClientConfigurationError",{enumerable:!0,get:function(){return i.ClientConfigurationError}}),Object.defineProperty(exports,"ClientConfigurationErrorMessage",{enumerable:!0,get:function(){return i.ClientConfigurationErrorMessage}}),Object.defineProperty(exports,"InteractionRequiredAuthError",{enumerable:!0,get:function(){return i.InteractionRequiredAuthError}}),Object.defineProperty(exports,"LogLevel",{enumerable:!0,get:function(){return i.LogLevel}}),Object.defineProperty(exports,"Logger",{enumerable:!0,get:function(){return i.Logger}}),Object.defineProperty(exports,"PromptValue",{enumerable:!0,get:function(){return i.PromptValue}}),Object.defineProperty(exports,"ProtocolMode",{enumerable:!0,get:function(){return i.ProtocolMode}}),Object.defineProperty(exports,"ResponseMode",{enumerable:!0,get:function(){return i.ResponseMode}}),Object.defineProperty(exports,"ServerError",{enumerable:!0,get:function(){return i.ServerError}}),Object.defineProperty(exports,"TokenCacheContext",{enumerable:!0,get:function(){return i.TokenCacheContext}}),exports.ClientApplication=w,exports.ClientAssertion=M,exports.ConfidentialClientApplication=class extends w{constructor(e){super(e),this.setClientCredential(this.config)}async acquireTokenByClientCredential(e){this.logger.info("acquireTokenByClientCredential called",e.correlationId);const t={...e,...this.initializeBaseRequest(e)},r={azureRegion:t.azureRegion,environmentRegion:process.env.REGION_NAME},n=this.initializeServerTelemetryManager(c.acquireTokenByClientCredential,t.correlationId,t.skipCache);try{const e=await this.buildOauthClientConfiguration(t.authority,t.correlationId,n,r),o=new i.ClientCredentialClient(e);return this.logger.verbose("Client credential client created",t.correlationId),o.acquireToken(t)}catch(e){throw e instanceof i.AuthError&&e.setCorrelationId(t.correlationId),n.cacheFailedRequest(e),e}}async acquireTokenOnBehalfOf(e){this.logger.info("acquireTokenOnBehalfOf called",e.correlationId);const t={...e,...this.initializeBaseRequest(e)};try{const e=await this.buildOauthClientConfiguration(t.authority,t.correlationId),r=new i.OnBehalfOfClient(e);return this.logger.verbose("On behalf of client created",t.correlationId),r.acquireToken(t)}catch(e){throw e instanceof i.AuthError&&e.setCorrelationId(t.correlationId),e}}setClientCredential(e){const t=!i.StringUtils.isEmpty(e.auth.clientSecret),r=!i.StringUtils.isEmpty(e.auth.clientAssertion),n=e.auth.clientCertificate||{thumbprint:"",privateKey:""},o=!i.StringUtils.isEmpty(n.thumbprint)||!i.StringUtils.isEmpty(n.privateKey);if(t&&r||r&&o||t&&o)throw i.ClientAuthError.createInvalidCredentialError();if(e.auth.clientSecret)this.clientSecret=e.auth.clientSecret;else if(e.auth.clientAssertion)this.clientAssertion=M.fromAssertion(e.auth.clientAssertion);else{if(!o)throw i.ClientAuthError.createInvalidCredentialError();var a;this.clientAssertion=M.fromCertificate(n.thumbprint,n.privateKey,null==(a=e.auth.clientCertificate)?void 0:a.x5c)}}},exports.CryptoProvider=m,exports.NodeStorage=A,exports.PublicClientApplication=class extends w{constructor(e){super(e)}async acquireTokenByDeviceCode(e){this.logger.info("acquireTokenByDeviceCode called",e.correlationId);const t=Object.assign(e,this.initializeBaseRequest(e)),r=this.initializeServerTelemetryManager(c.acquireTokenByDeviceCode,t.correlationId);try{const e=await this.buildOauthClientConfiguration(t.authority,t.correlationId,r),n=new i.DeviceCodeClient(e);return this.logger.verbose("Device code client created",t.correlationId),n.acquireToken(t)}catch(e){throw e instanceof i.AuthError&&e.setCorrelationId(t.correlationId),r.cacheFailedRequest(e),e}}},exports.TokenCache=E,exports.buildAppConfiguration=g; | ||
//# sourceMappingURL=msal-node.cjs.production.min.js.map |
export declare const name = "@azure/msal-node"; | ||
export declare const version = "1.3.0"; | ||
export declare const version = "1.3.1"; | ||
//# sourceMappingURL=packageMetadata.d.ts.map |
{ | ||
"name": "@azure/msal-node", | ||
"version": "1.3.0", | ||
"version": "1.3.1", | ||
"author": { | ||
@@ -69,3 +69,3 @@ "name": "Microsoft", | ||
"dependencies": { | ||
"@azure/msal-common": "^4.5.0", | ||
"@azure/msal-common": "^5.0.0", | ||
"axios": "^0.21.1", | ||
@@ -72,0 +72,0 @@ "jsonwebtoken": "^8.5.1", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
714755
5917
+ Added@azure/msal-common@5.2.0(transitive)
- Removed@azure/msal-common@4.5.1(transitive)
Updated@azure/msal-common@^5.0.0