Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@azure/msal-node

Package Overview
Dependencies
Maintainers
3
Versions
112
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@azure/msal-node - npm Package Compare versions

Comparing version 1.0.0-alpha.13 to 1.0.0-alpha.14

21

CHANGELOG.json

@@ -5,2 +5,23 @@ {

{
"date": "Mon, 02 Nov 2020 23:33:39 GMT",
"tag": "@azure/msal-node_v1.0.0-alpha.14",
"version": "1.0.0-alpha.14",
"comments": {
"prerelease": [
{
"comment": "Add getLogger and setLogger to msal-node (#2520)",
"author": "joarroyo@microsoft.com",
"commit": "6fff8c1ed4d3dab2a74ff4b44a159645a6c2f535",
"package": "@azure/msal-node"
},
{
"comment": "Remove `debug` from the `msal-node` library (#2496)",
"author": "sameera.gajjarapu@microsoft.com",
"commit": "e354c26ae74632943109fb9101319acf6c6a691c",
"package": "@azure/msal-node"
}
]
}
},
{
"date": "Mon, 26 Oct 2020 21:00:29 GMT",

@@ -7,0 +28,0 @@ "tag": "@azure/msal-node_v1.0.0-alpha.13",

11

changelog.md
# Change Log - @azure/msal-node
This log was last generated on Mon, 26 Oct 2020 21:00:29 GMT and should not be manually modified.
This log was last generated on Mon, 02 Nov 2020 23:33:39 GMT and should not be manually modified.
<!-- Start content -->
## 1.0.0-alpha.14
Mon, 02 Nov 2020 23:33:39 GMT
### Changes
- Add getLogger and setLogger to msal-node (#2520) (joarroyo@microsoft.com)
- Remove `debug` from the `msal-node` library (#2496) (sameera.gajjarapu@microsoft.com)
## 1.0.0-alpha.13

@@ -8,0 +17,0 @@

@@ -59,2 +59,11 @@ import { AuthorizationUrlRequest, AuthorizationCodeRequest, ClientConfiguration, RefreshTokenRequest, AuthenticationResult, BaseAuthRequest, SilentFlowRequest, Logger, ServerTelemetryManager } from "@azure/msal-common";

getTokenCache(): TokenCache;
/**
* Returns the logger instance
*/
getLogger(): Logger;
/**
* Replaces the default logger set in configurations with new Logger with new configurations
* @param logger Logger instance
*/
setLogger(logger: Logger): void;
protected buildOauthClientConfiguration(authority?: string, serverTelemetryManager?: ServerTelemetryManager): Promise<ClientConfiguration>;

@@ -61,0 +70,0 @@ private getClientAssertion;

2

dist/index.d.ts

@@ -9,2 +9,2 @@ export { PublicClientApplication } from "./client/PublicClientApplication";

export { CryptoProvider } from "./crypto/CryptoProvider";
export { AuthorizationCodeRequest, AuthorizationUrlRequest, SilentFlowRequest, DeviceCodeRequest, RefreshTokenRequest, ClientCredentialRequest, OnBehalfOfRequest, PromptValue, ResponseMode, AuthenticationResult, AccountInfo, AuthError, AuthErrorMessage, InteractionRequiredAuthError, ServerError, ClientAuthError, ClientAuthErrorMessage, ClientConfigurationError, ClientConfigurationErrorMessage, INetworkModule, NetworkRequestOptions, NetworkResponse, LogLevel, ProtocolMode, ICachePlugin, TokenCacheContext, ISerializableTokenCache } from "@azure/msal-common";
export { AuthorizationCodeRequest, AuthorizationUrlRequest, SilentFlowRequest, DeviceCodeRequest, RefreshTokenRequest, ClientCredentialRequest, OnBehalfOfRequest, PromptValue, ResponseMode, AuthenticationResult, AccountInfo, AuthError, AuthErrorMessage, InteractionRequiredAuthError, ServerError, ClientAuthError, ClientAuthErrorMessage, ClientConfigurationError, ClientConfigurationErrorMessage, INetworkModule, NetworkRequestOptions, NetworkResponse, Logger, LogLevel, ProtocolMode, ICachePlugin, TokenCacheContext, ISerializableTokenCache } from "@azure/msal-common";

@@ -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,n=require("@azure/msal-common"),r=e(require("axios")),i=e(require("debug")),o=require("uuid"),a=e(require("crypto")),c=require("jsonwebtoken");function s(){return(s=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function u(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}function l(e,t){try{var n=e()}catch(e){return t(e)}return n&&n.then?n.then(void 0,t):n}function h(e,t){try{var n=e()}catch(e){return t(!0,e)}return n&&n.then?n.then(t.bind(null,!1),t.bind(null,!0)):t(!1,n)}"undefined"!=typeof Symbol&&(Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator"))),"undefined"!=typeof Symbol&&(Symbol.asyncIterator||(Symbol.asyncIterator=Symbol("Symbol.asyncIterator"))),function(e){e.GET="get",e.POST="post"}(t||(t={}));var f,d="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~";!function(e){e[e.acquireTokenSilent=62]="acquireTokenSilent",e[e.acquireTokenByCode=871]="acquireTokenByCode",e[e.acquireTokenByRefreshToken=872]="acquireTokenByRefreshToken",e[e.acquireTokenByDeviceCode=671]="acquireTokenByDeviceCode",e[e.acquireTokenByClientCredential=771]="acquireTokenByClientCredential"}(f||(f={}));var g=function(){function e(){r.defaults.validateStatus=function(){return!0}}var n=e.prototype;return n.sendGetRequestAsync=function(e,n){try{return Promise.resolve(r({method:t.GET,url:e,headers:n&&n.headers})).then((function(e){return{headers:e.headers,body:e.data,status:e.status}}))}catch(e){return Promise.reject(e)}},n.sendPostRequestAsync=function(e,n){try{return Promise.resolve(r({method:t.POST,url:e,data:n&&n.body||"",headers:n&&n.headers})).then((function(e){return{headers:e.headers,body:e.data,status:e.status}}))}catch(e){return Promise.reject(e)}},e}(),p={clientId:"",authority:"",clientSecret:"",clientAssertion:"",clientCertificate:{thumbprint:"",privateKey:""},knownAuthorities:[],cloudDiscoveryMetadata:"",clientCapabilities:[],protocolMode:n.ProtocolMode.AAD},m={},y={loggerOptions:{loggerCallback:function(e,t,r){i("msal:"+n.LogLevel[e]+(r?"-Pii":""))(t)},piiLoggingEnabled:!1,logLevel:n.LogLevel.Info},networkClient:function(){function e(){}return e.getNetworkClient=function(){return new g},e}().getNetworkClient()};function v(e){var t=e.cache,n=e.system;return{auth:s({},p,{},e.auth),cache:s({},m,{},t),system:s({},y,{},n)}}var C=function(){function e(){}return e.generateGuid=function(){return o.v4()},e.isGuid=function(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)},e}(),T=function(){function e(){}return e.base64Encode=function(e,t){return Buffer.from(e,t).toString("base64")},e.base64EncodeUrl=function(t,n){return e.base64Encode(t,n).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")},e.base64Decode=function(e){return Buffer.from(e,"base64").toString("utf8")},e.base64DecodeUrl=function(t){for(var n=t.replace(/-/g,"+").replace(/_/g,"/");n.length%4;)n+="=";return e.base64Decode(n)},e}(),k=function(){function e(){}var t=e.prototype;return t.generatePkceCodes=function(){try{var e=this.generateCodeVerifier(),t=this.generateCodeChallengeFromVerifier(e);return Promise.resolve({verifier:e,challenge:t})}catch(e){return Promise.reject(e)}},t.generateCodeVerifier=function(){var e=a.randomBytes(32),t=this.bufferToCVString(e);return T.base64EncodeUrl(t)},t.generateCodeChallengeFromVerifier=function(e){return T.base64EncodeUrl(this.sha256(e).toString("ascii"))},t.sha256=function(e){return a.createHash("sha256").update(e).digest()},t.bufferToCVString=function(e){for(var t=[],n=0;n<e.byteLength;n+=1)t.push(d[e[n]%d.length]);return t.join("")},e}(),b=function(){function e(){this.pkceGenerator=new k}var t=e.prototype;return t.createNewGuid=function(){return C.generateGuid()},t.base64Encode=function(e){return T.base64Encode(e)},t.base64Decode=function(e){return T.base64Decode(e)},t.generatePkceCodes=function(){return this.pkceGenerator.generatePkceCodes()},t.getPublicKeyThumbprint=function(){throw new Error("Method not implemented.")},t.signJwt=function(){throw new Error("Method not implemented.")},e}(),A=function(){function e(){}return e.deserializeJSONBlob=function(e){return n.StringUtils.isEmpty(e)?{}:JSON.parse(e)},e.deserializeAccounts=function(e){var t={};return e&&Object.keys(e).map((function(r){var i=e[r],o={homeAccountId:i.home_account_id,environment:i.environment,realm:i.realm,localAccountId:i.local_account_id,username:i.username,authorityType:i.authority_type,name:i.name,clientInfo:i.client_info,lastModificationTime:i.last_modification_time,lastModificationApp:i.last_modification_app},a=new n.AccountEntity;n.CacheManager.toObject(a,o),t[r]=a})),t},e.deserializeIdTokens=function(e){var t={};return e&&Object.keys(e).map((function(r){var i=e[r],o={homeAccountId:i.home_account_id,environment:i.environment,credentialType:i.credential_type,clientId:i.client_id,secret:i.secret,realm:i.realm},a=new n.IdTokenEntity;n.CacheManager.toObject(a,o),t[r]=a})),t},e.deserializeAccessTokens=function(e){var t={};return e&&Object.keys(e).map((function(r){var i=e[r],o={homeAccountId:i.home_account_id,environment:i.environment,credentialType:i.credential_type,clientId:i.client_id,secret:i.secret,realm:i.realm,target:i.target,cachedAt:i.cached_at,expiresOn:i.expires_on,extendedExpiresOn:i.extended_expires_on,refreshOn:i.refresh_on,keyId:i.key_id,tokenType:i.token_type},a=new n.AccessTokenEntity;n.CacheManager.toObject(a,o),t[r]=a})),t},e.deserializeRefreshTokens=function(e){var t={};return e&&Object.keys(e).map((function(r){var i=e[r],o={homeAccountId:i.home_account_id,environment:i.environment,credentialType:i.credential_type,clientId:i.client_id,secret:i.secret,familyId:i.family_id,target:i.target,realm:i.realm},a=new n.RefreshTokenEntity;n.CacheManager.toObject(a,o),t[r]=a})),t},e.deserializeAppMetadata=function(e){var t={};return e&&Object.keys(e).map((function(r){var i=e[r],o={clientId:i.client_id,environment:i.environment,familyId:i.family_id},a=new n.AppMetadataEntity;n.CacheManager.toObject(a,o),t[r]=a})),t},e.deserializeAllCache=function(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):{}}},e}(),I=function(){function e(){}return e.serializeJSONBlob=function(e){return JSON.stringify(e)},e.serializeAccounts=function(e){var t={};return Object.keys(e).map((function(n){var r=e[n];t[n]={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},e.serializeIdTokens=function(e){var t={};return Object.keys(e).map((function(n){var r=e[n];t[n]={home_account_id:r.homeAccountId,environment:r.environment,credential_type:r.credentialType,client_id:r.clientId,secret:r.secret,realm:r.realm}})),t},e.serializeAccessTokens=function(e){var t={};return Object.keys(e).map((function(n){var r=e[n];t[n]={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},e.serializeRefreshTokens=function(e){var t={};return Object.keys(e).map((function(n){var r=e[n];t[n]={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},e.serializeAppMetadata=function(e){var t={};return Object.keys(e).map((function(n){var r=e[n];t[n]={client_id:r.clientId,environment:r.environment,family_id:r.familyId}})),t},e.serializeAllCache=function(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)}},e}(),E=function(e){function t(t){var n;return(n=e.call(this)||this).cache={},n.changeEmitters=[],n.logger=t,n}u(t,e);var r=t.prototype;return r.registerChangeEmitter=function(e){this.changeEmitters.push(e)},r.emitChange=function(){this.changeEmitters.forEach((function(e){return e.call(null)}))},r.cacheToInMemoryCache=function(e){var t={accounts:{},idTokens:{},accessTokens:{},refreshTokens:{},appMetadata:{}};for(var r in e)if(e[r]instanceof n.AccountEntity)t.accounts[r]=e[r];else if(e[r]instanceof n.IdTokenEntity)t.idTokens[r]=e[r];else if(e[r]instanceof n.AccessTokenEntity)t.accessTokens[r]=e[r];else if(e[r]instanceof n.RefreshTokenEntity)t.refreshTokens[r]=e[r];else{if(!(e[r]instanceof n.AppMetadataEntity))continue;t.appMetadata[r]=e[r]}return t},r.inMemoryCacheToCache=function(e){return this.getCache(),s({},e.accounts,{},e.idTokens,{},e.accessTokens,{},e.refreshTokens,{},e.appMetadata)},r.getInMemoryCache=function(){return this.logger.verbose("Getting in-memory cache"),this.cacheToInMemoryCache(this.getCache())},r.setInMemoryCache=function(e){this.logger.verbose("Setting in-memory cache");var t=this.inMemoryCacheToCache(e);this.setCache(t),this.emitChange()},r.getCache=function(){return this.logger.verbose("Getting cache key-value store"),this.cache},r.setCache=function(e){this.logger.verbose("Setting cache key value store"),this.cache=e,this.emitChange()},r.getItem=function(e){return this.logger.verbosePii("Item key: "+e),this.getCache()[e]},r.setItem=function(e,t){this.logger.verbosePii("Item key: "+e);var n=this.getCache();n[e]=t,this.setCache(n)},r.getAccount=function(e){var t=this.getItem(e);return n.AccountEntity.isAccountEntity(t)?t:null},r.setAccount=function(e){var t=e.generateAccountKey();this.setItem(t,e)},r.getIdTokenCredential=function(e){return n.CredentialEntity.getCredentialType(e)===n.CredentialType.ID_TOKEN?this.getItem(e):null},r.setIdTokenCredential=function(e){var t=e.generateCredentialKey();this.setItem(t,e)},r.getAccessTokenCredential=function(e){return n.CredentialEntity.getCredentialType(e)===n.CredentialType.ACCESS_TOKEN?this.getItem(e):null},r.setAccessTokenCredential=function(e){var t=e.generateCredentialKey();this.setItem(t,e)},r.getRefreshTokenCredential=function(e){return n.CredentialEntity.getCredentialType(e)===n.CredentialType.REFRESH_TOKEN?this.getItem(e):null},r.setRefreshTokenCredential=function(e){var t=e.generateCredentialKey();this.setItem(t,e)},r.getAppMetadata=function(e){var t=this.getItem(e);return n.AppMetadataEntity.isAppMetadataEntity(e,t)?t:null},r.setAppMetadata=function(e){var t=e.generateAppMetadataKey();this.setItem(t,e)},r.getServerTelemetry=function(e){var t=this.getItem(e);return n.ServerTelemetryEntity.isServerTelemetryEntity(e,t)?t:null},r.setServerTelemetry=function(e,t){this.setItem(e,t)},r.getThrottlingCache=function(e){var t=this.getItem(e);return n.ThrottlingEntity.isThrottlingEntity(e,t)?t:null},r.setThrottlingCache=function(e,t){this.setItem(e,t)},r.removeItem=function(e){this.logger.verbosePii("Item key: "+e);var t=!1,n=this.getCache();return n[e]&&(delete n[e],t=!0),t&&(this.setCache(n),this.emitChange()),t},r.containsKey=function(e){return this.getKeys().includes(e)},r.getKeys=function(){this.logger.verbose("Retrieving all cache keys");var e=this.getCache();return[].concat(Object.keys(e))},r.clear=function(){var e=this;this.logger.verbose("Clearing cache entries created by MSAL"),this.getKeys().forEach((function(t){e.removeItem(t)})),this.emitChange()},t.generateInMemoryCache=function(e){return A.deserializeAllCache(A.deserializeJSONBlob(e))},t.generateJsonCache=function(e){return I.serializeAllCache(e)},t}(n.CacheManager),O={},P={},_={},S={},w={},M=function(){function e(e,t,n){this.cacheHasChanged=!1,this.storage=e,this.storage.registerChangeEmitter(this.handleChangeEvent.bind(this)),n&&(this.persistence=n),this.logger=t}var t=e.prototype;return t.hasChanged=function(){return this.cacheHasChanged},t.serialize=function(){this.logger.verbose("Serializing in-memory cache");var e=I.serializeAllCache(this.storage.getInMemoryCache());return n.StringUtils.isEmpty(this.cacheSnapshot)?this.logger.verbose("No cache snapshot to merge"):(this.logger.verbose("Reading cache snapshot from disk"),e=this.mergeState(JSON.parse(this.cacheSnapshot),e)),this.cacheHasChanged=!1,JSON.stringify(e)},t.deserialize=function(e){if(this.logger.verbose("Deserializing JSON to in-memory cache"),this.cacheSnapshot=e,n.StringUtils.isEmpty(this.cacheSnapshot))this.logger.verbose("No cache snapshot to deserialize");else{this.logger.verbose("Reading cache snapshot from disk");var t=A.deserializeAllCache(this.overlayDefaults(JSON.parse(this.cacheSnapshot)));this.storage.setInMemoryCache(t)}},t.getAllAccounts=function(){try{var e,t=this;return t.logger.verbose("getAllAccounts called"),Promise.resolve(h((function(){function r(){return t.storage.getAllAccounts()}var i=function(){if(t.persistence)return e=new n.TokenCacheContext(t,!1),Promise.resolve(t.persistence.beforeCacheAccess(e)).then((function(){}))}();return i&&i.then?i.then(r):r()}),(function(n,r){function i(){if(n)throw r;return r}var o=function(){if(t.persistence&&e)return Promise.resolve(t.persistence.afterCacheAccess(e)).then((function(){}))}();return o&&o.then?o.then(i):i()})))}catch(e){return Promise.reject(e)}},t.removeAccount=function(e){try{var t,r=this;r.logger.verbose("removeAccount called");var i=h((function(){function i(){r.storage.removeAccount(n.AccountEntity.generateAccountCacheKey(e))}var o=function(){if(r.persistence)return t=new n.TokenCacheContext(r,!0),Promise.resolve(r.persistence.beforeCacheAccess(t)).then((function(){}))}();return o&&o.then?o.then(i):i()}),(function(e,n){function i(){if(e)throw n;return n}var o=function(){if(r.persistence&&t)return Promise.resolve(r.persistence.afterCacheAccess(t)).then((function(){}))}();return o&&o.then?o.then(i):i()}));return Promise.resolve(i&&i.then?i.then((function(){})):void 0)}catch(e){return Promise.reject(e)}},t.handleChangeEvent=function(){this.cacheHasChanged=!0},t.mergeState=function(e,t){this.logger.verbose("Merging in-memory cache with cache snapshot");var n=this.mergeRemovals(e,t);return this.mergeUpdates(n,t)},t.mergeUpdates=function(e,t){var n=this;return Object.keys(t).forEach((function(r){var i=t[r];if(e.hasOwnProperty(r)){var o=null!==i,a="object"==typeof i,c=!Array.isArray(i);o&&a&&c&&null!=e[r]?n.mergeUpdates(e[r],i):e[r]=i}else null!==i&&(e[r]=i)})),e},t.mergeRemovals=function(e,t){return this.logger.verbose("Remove updated entries in cache"),s({},e,{Account:null!=e.Account?this.mergeRemovalsDict(e.Account,t.Account):e.Account,AccessToken:null!=e.AccessToken?this.mergeRemovalsDict(e.AccessToken,t.AccessToken):e.AccessToken,RefreshToken:null!=e.RefreshToken?this.mergeRemovalsDict(e.RefreshToken,t.RefreshToken):e.RefreshToken,IdToken:null!=e.IdToken?this.mergeRemovalsDict(e.IdToken,t.IdToken):e.IdToken,AppMetadata:null!=e.AppMetadata?this.mergeRemovalsDict(e.AppMetadata,t.AppMetadata):e.AppMetadata})},t.mergeRemovalsDict=function(e,t){var n=s({},e);return Object.keys(e).forEach((function(e){t&&t.hasOwnProperty(e)||delete n[e]})),n},t.overlayDefaults=function(e){return this.logger.verbose("Overlaying input cache with the default cache"),{Account:s({},O,{},e.Account),IdToken:s({},P,{},e.IdToken),AccessToken:s({},_,{},e.AccessToken),RefreshToken:s({},S,{},e.RefreshToken),AppMetadata:s({},w,{},e.AppMetadata)}},e}(),j=function(){function e(e){this.config=v(e),this.logger=new n.Logger(this.config.system.loggerOptions),this.storage=new E(this.logger),this.tokenCache=new M(this.storage,this.logger,this.config.cache.cachePlugin),this.cryptoProvider=new b,n.TrustedAuthority.setTrustedAuthoritiesFromConfig(this.config.auth.knownAuthorities,this.config.auth.cloudDiscoveryMetadata)}var t,r=e.prototype;return r.getAuthCodeUrl=function(e){try{var t=this;return t.logger.info("getAuthCodeUrl called"),Promise.resolve(t.buildOauthClientConfiguration(e.authority)).then((function(r){return t.logger.verbose("Auth client config generated"),new n.AuthorizationCodeClient(r).getAuthCodeUrl(t.initializeRequest(e))}))}catch(e){return Promise.reject(e)}},r.acquireTokenByCode=function(e){try{var t=this;t.logger.info("acquireTokenByCode called");var r=t.initializeRequest(e),i=t.initializeServerTelemetryManager(f.acquireTokenByCode,r.correlationId);return Promise.resolve(l((function(){return Promise.resolve(t.buildOauthClientConfiguration(e.authority,i)).then((function(e){return t.logger.verbose("Auth client config generated"),new n.AuthorizationCodeClient(e).acquireToken(r)}))}),(function(e){throw i.cacheFailedRequest(e),e})))}catch(e){return Promise.reject(e)}},r.acquireTokenByRefreshToken=function(e){try{var t=this;t.logger.info("acquireTokenByRefreshToken called");var r=t.initializeRequest(e),i=t.initializeServerTelemetryManager(f.acquireTokenByRefreshToken,r.correlationId);return Promise.resolve(l((function(){return Promise.resolve(t.buildOauthClientConfiguration(e.authority,i)).then((function(e){return t.logger.verbose("Auth client config generated"),new n.RefreshTokenClient(e).acquireToken(r)}))}),(function(e){throw i.cacheFailedRequest(e),e})))}catch(e){return Promise.reject(e)}},r.acquireTokenSilent=function(e){try{var t=this,r=t.initializeRequest(e),i=t.initializeServerTelemetryManager(f.acquireTokenSilent,r.correlationId,r.forceRefresh);return Promise.resolve(l((function(){return Promise.resolve(t.buildOauthClientConfiguration(e.authority,i)).then((function(e){return new n.SilentFlowClient(e).acquireToken(r)}))}),(function(e){throw i.cacheFailedRequest(e),e})))}catch(e){return Promise.reject(e)}},r.getTokenCache=function(){return this.logger.info("getTokenCache called"),this.tokenCache},r.buildOauthClientConfiguration=function(e,t){try{var n=this;n.logger.verbose("buildOauthClientConfiguration called");var r=n.config.auth.clientId;return Promise.resolve(n.createAuthority(e)).then((function(e){return{authOptions:{clientId:r,authority:e,knownAuthorities:n.config.auth.knownAuthorities,cloudDiscoveryMetadata:n.config.auth.cloudDiscoveryMetadata,clientCapabilities:n.config.auth.clientCapabilities,protocolMode:n.config.auth.protocolMode},loggerOptions:{loggerCallback:n.config.system.loggerOptions.loggerCallback,piiLoggingEnabled:n.config.system.loggerOptions.piiLoggingEnabled},cryptoInterface:n.cryptoProvider,networkInterface:n.config.system.networkClient,storageInterface:n.storage,serverTelemetryManager:t,clientCredentials:{clientSecret:n.clientSecret,clientAssertion:n.clientAssertion?n.getClientAssertion():void 0},libraryInfo:{sku:"msal.js.node",version:"1.0.0-alpha.13",cpu:process.arch||"",os:process.platform||""},persistencePlugin:n.config.cache.cachePlugin,serializableCache:n.tokenCache}}))}catch(e){return Promise.reject(e)}},r.getClientAssertion=function(){return{assertion:this.clientAssertion.getJwt(this.cryptoProvider,this.config.auth.clientId,this._authority.tokenEndpoint),assertionType:"urn:ietf:params:oauth:client-assertion-type:jwt-bearer"}},r.initializeRequest=function(e){return this.logger.verbose("initializeRequestScopes called"),s({},e,{scopes:[].concat(e&&e.scopes||[],[n.Constants.OPENID_SCOPE,n.Constants.PROFILE_SCOPE,n.Constants.OFFLINE_ACCESS_SCOPE]),correlationId:e&&e.correlationId||this.cryptoProvider.createNewGuid()})},r.initializeServerTelemetryManager=function(e,t,r){return new n.ServerTelemetryManager({clientId:this.config.auth.clientId,correlationId:t,apiId:e,forceRefresh:r||!1},this.storage)},r.createAuthority=function(e){try{var t;return this.logger.verbose("createAuthority called"),e?(this.logger.verbose("Authority passed in, creating authority instance"),t=n.AuthorityFactory.createInstance(e,this.config.system.networkClient,this.config.auth.protocolMode)):(this.logger.verbose("No authority passed in request, defaulting to authority set on application object"),t=this.authority),t.discoveryComplete()?Promise.resolve(t):Promise.resolve(l((function(){return Promise.resolve(t.resolveEndpointsAsync()).then((function(){return t}))}),(function(e){throw n.ClientAuthError.createEndpointDiscoveryIncompleteError(e)})))}catch(e){return Promise.reject(e)}},(t=[{key:"authority",get:function(){return this._authority||(this._authority=n.AuthorityFactory.createInstance(this.config.auth.authority||n.Constants.DEFAULT_AUTHORITY,this.config.system.networkClient,this.config.auth.protocolMode)),this._authority}}])&&function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(e.prototype,t),e}(),R=function(e){function t(t){return e.call(this,t)||this}return u(t,e),t.prototype.acquireTokenByDeviceCode=function(e){try{var t=this;t.logger.info("acquireTokenByDeviceCode called");var r=t.initializeRequest(e),i=t.initializeServerTelemetryManager(f.acquireTokenByDeviceCode,r.correlationId);return Promise.resolve(l((function(){return Promise.resolve(t.buildOauthClientConfiguration(e.authority,i)).then((function(e){return t.logger.verbose("Auth client config generated"),new n.DeviceCodeClient(e).acquireToken(r)}))}),(function(e){throw i.cacheFailedRequest(e),e})))}catch(e){return Promise.reject(e)}},t}(j),q=function(){function e(){}e.fromAssertion=function(t){var n=new e;return n.jwt=t,n},e.fromCertificate=function(t,n){var r=new e;return r.privateKey=n,r.thumbprint=t,r};var t=e.prototype;return t.getJwt=function(e,t,r){if(null!=this.privateKey&&null!=this.thumbprint)return null==this.jwt||this.isExpired()||t!=this.issuer||r!=this.jwtAudience?this.createJwt(e,t,r):this.jwt;if(null!=this.jwt)return this.jwt;throw n.ClientAuthError.createInvalidAssertionError()},t.createJwt=function(e,t,r){var i,o;this.issuer=t,this.jwtAudience=r;var a=n.TimeUtils.nowSeconds();this.expirationTime=a+600;var s=((i={}).alg="RS256",i.x5t=T.base64EncodeUrl(this.thumbprint,"hex"),i),u=((o={}).aud=this.jwtAudience,o.exp=this.expirationTime,o.iss=this.issuer,o.sub=this.issuer,o.nbf=a,o.jti=e.createNewGuid(),o);return this.jwt=c.sign(u,this.privateKey,{header:s}),this.jwt},t.isExpired=function(){return this.expirationTime<n.TimeUtils.nowSeconds()},e}(),z=function(e){function t(t){var n;return(n=e.call(this,t)||this).setClientCredential(n.config),n}u(t,e);var r=t.prototype;return r.acquireTokenByClientCredential=function(e){try{var t=this;t.logger.info("acquireTokenByClientCredential called");var r=t.initializeRequest(e),i=t.initializeServerTelemetryManager(f.acquireTokenByClientCredential,r.correlationId,r.skipCache);return Promise.resolve(l((function(){return Promise.resolve(t.buildOauthClientConfiguration(e.authority,i)).then((function(r){return t.logger.verbose("Auth client config generated"),new n.ClientCredentialClient(r).acquireToken(e)}))}),(function(e){throw i.cacheFailedRequest(e),e})))}catch(e){return Promise.reject(e)}},r.acquireTokenOnBehalfOf=function(e){try{var t=this;return t.logger.info("acquireTokenOnBehalfOf called"),Promise.resolve(t.buildOauthClientConfiguration(e.authority)).then((function(r){return t.logger.verbose("Auth client config generated"),new n.OnBehalfOfClient(r).acquireToken(t.initializeRequest(e))}))}catch(e){return Promise.reject(e)}},r.setClientCredential=function(e){var t=!n.StringUtils.isEmpty(e.auth.clientSecret),r=!n.StringUtils.isEmpty(e.auth.clientAssertion),i=e.auth.clientCertificate,o=!n.StringUtils.isEmpty(i.thumbprint)||!n.StringUtils.isEmpty(i.privateKey);if(t&&r||r&&o||t&&o)throw n.ClientAuthError.createInvalidCredentialError();if(t)this.clientSecret=e.auth.clientSecret;else if(r)this.clientAssertion=q.fromAssertion(e.auth.clientAssertion);else{if(!o)throw n.ClientAuthError.createInvalidCredentialError();this.clientAssertion=q.fromCertificate(i.thumbprint,i.privateKey)}},t}(j);Object.defineProperty(exports,"AuthError",{enumerable:!0,get:function(){return n.AuthError}}),Object.defineProperty(exports,"AuthErrorMessage",{enumerable:!0,get:function(){return n.AuthErrorMessage}}),Object.defineProperty(exports,"ClientAuthError",{enumerable:!0,get:function(){return n.ClientAuthError}}),Object.defineProperty(exports,"ClientAuthErrorMessage",{enumerable:!0,get:function(){return n.ClientAuthErrorMessage}}),Object.defineProperty(exports,"ClientConfigurationError",{enumerable:!0,get:function(){return n.ClientConfigurationError}}),Object.defineProperty(exports,"ClientConfigurationErrorMessage",{enumerable:!0,get:function(){return n.ClientConfigurationErrorMessage}}),Object.defineProperty(exports,"InteractionRequiredAuthError",{enumerable:!0,get:function(){return n.InteractionRequiredAuthError}}),Object.defineProperty(exports,"LogLevel",{enumerable:!0,get:function(){return n.LogLevel}}),Object.defineProperty(exports,"PromptValue",{enumerable:!0,get:function(){return n.PromptValue}}),Object.defineProperty(exports,"ProtocolMode",{enumerable:!0,get:function(){return n.ProtocolMode}}),Object.defineProperty(exports,"ResponseMode",{enumerable:!0,get:function(){return n.ResponseMode}}),Object.defineProperty(exports,"ServerError",{enumerable:!0,get:function(){return n.ServerError}}),Object.defineProperty(exports,"TokenCacheContext",{enumerable:!0,get:function(){return n.TokenCacheContext}}),exports.ConfidentialClientApplication=z,exports.CryptoProvider=b,exports.Deserializer=A,exports.PublicClientApplication=R,exports.Serializer=I,exports.Storage=E,exports.TokenCache=M,exports.buildAppConfiguration=v;
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t,n=require("@azure/msal-common"),r=e(require("axios")),i=require("uuid"),o=e(require("crypto")),a=require("jsonwebtoken");function c(){return(c=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function s(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}function u(e,t){try{var n=e()}catch(e){return t(e)}return n&&n.then?n.then(void 0,t):n}function l(e,t){try{var n=e()}catch(e){return t(!0,e)}return n&&n.then?n.then(t.bind(null,!1),t.bind(null,!0)):t(!1,n)}"undefined"!=typeof Symbol&&(Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator"))),"undefined"!=typeof Symbol&&(Symbol.asyncIterator||(Symbol.asyncIterator=Symbol("Symbol.asyncIterator"))),function(e){e.GET="get",e.POST="post"}(t||(t={}));var h,f="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~";!function(e){e[e.acquireTokenSilent=62]="acquireTokenSilent",e[e.acquireTokenByCode=871]="acquireTokenByCode",e[e.acquireTokenByRefreshToken=872]="acquireTokenByRefreshToken",e[e.acquireTokenByDeviceCode=671]="acquireTokenByDeviceCode",e[e.acquireTokenByClientCredential=771]="acquireTokenByClientCredential"}(h||(h={}));var d=function(){function e(){r.defaults.validateStatus=function(){return!0}}var n=e.prototype;return n.sendGetRequestAsync=function(e,n){try{return Promise.resolve(r({method:t.GET,url:e,headers:n&&n.headers})).then((function(e){return{headers:e.headers,body:e.data,status:e.status}}))}catch(e){return Promise.reject(e)}},n.sendPostRequestAsync=function(e,n){try{return Promise.resolve(r({method:t.POST,url:e,data:n&&n.body||"",headers:n&&n.headers})).then((function(e){return{headers:e.headers,body:e.data,status:e.status}}))}catch(e){return Promise.reject(e)}},e}(),g={clientId:"",authority:"",clientSecret:"",clientAssertion:"",clientCertificate:{thumbprint:"",privateKey:""},knownAuthorities:[],cloudDiscoveryMetadata:"",clientCapabilities:[],protocolMode:n.ProtocolMode.AAD},p={},m={loggerOptions:{loggerCallback:function(){},piiLoggingEnabled:!1,logLevel:n.LogLevel.Info},networkClient:function(){function e(){}return e.getNetworkClient=function(){return new d},e}().getNetworkClient()};function y(e){var t=e.cache,n=e.system;return{auth:c({},g,{},e.auth),cache:c({},p,{},t),system:c({},m,{},n)}}var v=function(){function e(){}return e.generateGuid=function(){return i.v4()},e.isGuid=function(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)},e}(),C=function(){function e(){}return e.base64Encode=function(e,t){return Buffer.from(e,t).toString("base64")},e.base64EncodeUrl=function(t,n){return e.base64Encode(t,n).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")},e.base64Decode=function(e){return Buffer.from(e,"base64").toString("utf8")},e.base64DecodeUrl=function(t){for(var n=t.replace(/-/g,"+").replace(/_/g,"/");n.length%4;)n+="=";return e.base64Decode(n)},e}(),T=function(){function e(){}var t=e.prototype;return t.generatePkceCodes=function(){try{var e=this.generateCodeVerifier(),t=this.generateCodeChallengeFromVerifier(e);return Promise.resolve({verifier:e,challenge:t})}catch(e){return Promise.reject(e)}},t.generateCodeVerifier=function(){var e=o.randomBytes(32),t=this.bufferToCVString(e);return C.base64EncodeUrl(t)},t.generateCodeChallengeFromVerifier=function(e){return C.base64EncodeUrl(this.sha256(e).toString("ascii"))},t.sha256=function(e){return o.createHash("sha256").update(e).digest()},t.bufferToCVString=function(e){for(var t=[],n=0;n<e.byteLength;n+=1)t.push(f[e[n]%f.length]);return t.join("")},e}(),k=function(){function e(){this.pkceGenerator=new T}var t=e.prototype;return t.createNewGuid=function(){return v.generateGuid()},t.base64Encode=function(e){return C.base64Encode(e)},t.base64Decode=function(e){return C.base64Decode(e)},t.generatePkceCodes=function(){return this.pkceGenerator.generatePkceCodes()},t.getPublicKeyThumbprint=function(){throw new Error("Method not implemented.")},t.signJwt=function(){throw new Error("Method not implemented.")},e}(),b=function(){function e(){}return e.deserializeJSONBlob=function(e){return n.StringUtils.isEmpty(e)?{}:JSON.parse(e)},e.deserializeAccounts=function(e){var t={};return e&&Object.keys(e).map((function(r){var i=e[r],o={homeAccountId:i.home_account_id,environment:i.environment,realm:i.realm,localAccountId:i.local_account_id,username:i.username,authorityType:i.authority_type,name:i.name,clientInfo:i.client_info,lastModificationTime:i.last_modification_time,lastModificationApp:i.last_modification_app},a=new n.AccountEntity;n.CacheManager.toObject(a,o),t[r]=a})),t},e.deserializeIdTokens=function(e){var t={};return e&&Object.keys(e).map((function(r){var i=e[r],o={homeAccountId:i.home_account_id,environment:i.environment,credentialType:i.credential_type,clientId:i.client_id,secret:i.secret,realm:i.realm},a=new n.IdTokenEntity;n.CacheManager.toObject(a,o),t[r]=a})),t},e.deserializeAccessTokens=function(e){var t={};return e&&Object.keys(e).map((function(r){var i=e[r],o={homeAccountId:i.home_account_id,environment:i.environment,credentialType:i.credential_type,clientId:i.client_id,secret:i.secret,realm:i.realm,target:i.target,cachedAt:i.cached_at,expiresOn:i.expires_on,extendedExpiresOn:i.extended_expires_on,refreshOn:i.refresh_on,keyId:i.key_id,tokenType:i.token_type},a=new n.AccessTokenEntity;n.CacheManager.toObject(a,o),t[r]=a})),t},e.deserializeRefreshTokens=function(e){var t={};return e&&Object.keys(e).map((function(r){var i=e[r],o={homeAccountId:i.home_account_id,environment:i.environment,credentialType:i.credential_type,clientId:i.client_id,secret:i.secret,familyId:i.family_id,target:i.target,realm:i.realm},a=new n.RefreshTokenEntity;n.CacheManager.toObject(a,o),t[r]=a})),t},e.deserializeAppMetadata=function(e){var t={};return e&&Object.keys(e).map((function(r){var i=e[r],o={clientId:i.client_id,environment:i.environment,familyId:i.family_id},a=new n.AppMetadataEntity;n.CacheManager.toObject(a,o),t[r]=a})),t},e.deserializeAllCache=function(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):{}}},e}(),A=function(){function e(){}return e.serializeJSONBlob=function(e){return JSON.stringify(e)},e.serializeAccounts=function(e){var t={};return Object.keys(e).map((function(n){var r=e[n];t[n]={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},e.serializeIdTokens=function(e){var t={};return Object.keys(e).map((function(n){var r=e[n];t[n]={home_account_id:r.homeAccountId,environment:r.environment,credential_type:r.credentialType,client_id:r.clientId,secret:r.secret,realm:r.realm}})),t},e.serializeAccessTokens=function(e){var t={};return Object.keys(e).map((function(n){var r=e[n];t[n]={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},e.serializeRefreshTokens=function(e){var t={};return Object.keys(e).map((function(n){var r=e[n];t[n]={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},e.serializeAppMetadata=function(e){var t={};return Object.keys(e).map((function(n){var r=e[n];t[n]={client_id:r.clientId,environment:r.environment,family_id:r.familyId}})),t},e.serializeAllCache=function(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)}},e}(),I=function(e){function t(t){var n;return(n=e.call(this)||this).cache={},n.changeEmitters=[],n.logger=t,n}s(t,e);var r=t.prototype;return r.registerChangeEmitter=function(e){this.changeEmitters.push(e)},r.emitChange=function(){this.changeEmitters.forEach((function(e){return e.call(null)}))},r.cacheToInMemoryCache=function(e){var t={accounts:{},idTokens:{},accessTokens:{},refreshTokens:{},appMetadata:{}};for(var r in e)if(e[r]instanceof n.AccountEntity)t.accounts[r]=e[r];else if(e[r]instanceof n.IdTokenEntity)t.idTokens[r]=e[r];else if(e[r]instanceof n.AccessTokenEntity)t.accessTokens[r]=e[r];else if(e[r]instanceof n.RefreshTokenEntity)t.refreshTokens[r]=e[r];else{if(!(e[r]instanceof n.AppMetadataEntity))continue;t.appMetadata[r]=e[r]}return t},r.inMemoryCacheToCache=function(e){return this.getCache(),c({},e.accounts,{},e.idTokens,{},e.accessTokens,{},e.refreshTokens,{},e.appMetadata)},r.getInMemoryCache=function(){return this.logger.verbose("Getting in-memory cache"),this.cacheToInMemoryCache(this.getCache())},r.setInMemoryCache=function(e){this.logger.verbose("Setting in-memory cache");var t=this.inMemoryCacheToCache(e);this.setCache(t),this.emitChange()},r.getCache=function(){return this.logger.verbose("Getting cache key-value store"),this.cache},r.setCache=function(e){this.logger.verbose("Setting cache key value store"),this.cache=e,this.emitChange()},r.getItem=function(e){return this.logger.verbosePii("Item key: "+e),this.getCache()[e]},r.setItem=function(e,t){this.logger.verbosePii("Item key: "+e);var n=this.getCache();n[e]=t,this.setCache(n)},r.getAccount=function(e){var t=this.getItem(e);return n.AccountEntity.isAccountEntity(t)?t:null},r.setAccount=function(e){var t=e.generateAccountKey();this.setItem(t,e)},r.getIdTokenCredential=function(e){return n.CredentialEntity.getCredentialType(e)===n.CredentialType.ID_TOKEN?this.getItem(e):null},r.setIdTokenCredential=function(e){var t=e.generateCredentialKey();this.setItem(t,e)},r.getAccessTokenCredential=function(e){return n.CredentialEntity.getCredentialType(e)===n.CredentialType.ACCESS_TOKEN?this.getItem(e):null},r.setAccessTokenCredential=function(e){var t=e.generateCredentialKey();this.setItem(t,e)},r.getRefreshTokenCredential=function(e){return n.CredentialEntity.getCredentialType(e)===n.CredentialType.REFRESH_TOKEN?this.getItem(e):null},r.setRefreshTokenCredential=function(e){var t=e.generateCredentialKey();this.setItem(t,e)},r.getAppMetadata=function(e){var t=this.getItem(e);return n.AppMetadataEntity.isAppMetadataEntity(e,t)?t:null},r.setAppMetadata=function(e){var t=e.generateAppMetadataKey();this.setItem(t,e)},r.getServerTelemetry=function(e){var t=this.getItem(e);return n.ServerTelemetryEntity.isServerTelemetryEntity(e,t)?t:null},r.setServerTelemetry=function(e,t){this.setItem(e,t)},r.getThrottlingCache=function(e){var t=this.getItem(e);return n.ThrottlingEntity.isThrottlingEntity(e,t)?t:null},r.setThrottlingCache=function(e,t){this.setItem(e,t)},r.removeItem=function(e){this.logger.verbosePii("Item key: "+e);var t=!1,n=this.getCache();return n[e]&&(delete n[e],t=!0),t&&(this.setCache(n),this.emitChange()),t},r.containsKey=function(e){return this.getKeys().includes(e)},r.getKeys=function(){this.logger.verbose("Retrieving all cache keys");var e=this.getCache();return[].concat(Object.keys(e))},r.clear=function(){var e=this;this.logger.verbose("Clearing cache entries created by MSAL"),this.getKeys().forEach((function(t){e.removeItem(t)})),this.emitChange()},t.generateInMemoryCache=function(e){return b.deserializeAllCache(b.deserializeJSONBlob(e))},t.generateJsonCache=function(e){return A.serializeAllCache(e)},t}(n.CacheManager),E={},O={},P={},_={},S={},w=function(){function e(e,t,n){this.cacheHasChanged=!1,this.storage=e,this.storage.registerChangeEmitter(this.handleChangeEvent.bind(this)),n&&(this.persistence=n),this.logger=t}var t=e.prototype;return t.hasChanged=function(){return this.cacheHasChanged},t.serialize=function(){this.logger.verbose("Serializing in-memory cache");var e=A.serializeAllCache(this.storage.getInMemoryCache());return n.StringUtils.isEmpty(this.cacheSnapshot)?this.logger.verbose("No cache snapshot to merge"):(this.logger.verbose("Reading cache snapshot from disk"),e=this.mergeState(JSON.parse(this.cacheSnapshot),e)),this.cacheHasChanged=!1,JSON.stringify(e)},t.deserialize=function(e){if(this.logger.verbose("Deserializing JSON to in-memory cache"),this.cacheSnapshot=e,n.StringUtils.isEmpty(this.cacheSnapshot))this.logger.verbose("No cache snapshot to deserialize");else{this.logger.verbose("Reading cache snapshot from disk");var t=b.deserializeAllCache(this.overlayDefaults(JSON.parse(this.cacheSnapshot)));this.storage.setInMemoryCache(t)}},t.getAllAccounts=function(){try{var e,t=this;return t.logger.verbose("getAllAccounts called"),Promise.resolve(l((function(){function r(){return t.storage.getAllAccounts()}var i=function(){if(t.persistence)return e=new n.TokenCacheContext(t,!1),Promise.resolve(t.persistence.beforeCacheAccess(e)).then((function(){}))}();return i&&i.then?i.then(r):r()}),(function(n,r){function i(){if(n)throw r;return r}var o=function(){if(t.persistence&&e)return Promise.resolve(t.persistence.afterCacheAccess(e)).then((function(){}))}();return o&&o.then?o.then(i):i()})))}catch(e){return Promise.reject(e)}},t.removeAccount=function(e){try{var t,r=this;r.logger.verbose("removeAccount called");var i=l((function(){function i(){r.storage.removeAccount(n.AccountEntity.generateAccountCacheKey(e))}var o=function(){if(r.persistence)return t=new n.TokenCacheContext(r,!0),Promise.resolve(r.persistence.beforeCacheAccess(t)).then((function(){}))}();return o&&o.then?o.then(i):i()}),(function(e,n){function i(){if(e)throw n;return n}var o=function(){if(r.persistence&&t)return Promise.resolve(r.persistence.afterCacheAccess(t)).then((function(){}))}();return o&&o.then?o.then(i):i()}));return Promise.resolve(i&&i.then?i.then((function(){})):void 0)}catch(e){return Promise.reject(e)}},t.handleChangeEvent=function(){this.cacheHasChanged=!0},t.mergeState=function(e,t){this.logger.verbose("Merging in-memory cache with cache snapshot");var n=this.mergeRemovals(e,t);return this.mergeUpdates(n,t)},t.mergeUpdates=function(e,t){var n=this;return Object.keys(t).forEach((function(r){var i=t[r];if(e.hasOwnProperty(r)){var o=null!==i,a="object"==typeof i,c=!Array.isArray(i);o&&a&&c&&null!=e[r]?n.mergeUpdates(e[r],i):e[r]=i}else null!==i&&(e[r]=i)})),e},t.mergeRemovals=function(e,t){return this.logger.verbose("Remove updated entries in cache"),c({},e,{Account:null!=e.Account?this.mergeRemovalsDict(e.Account,t.Account):e.Account,AccessToken:null!=e.AccessToken?this.mergeRemovalsDict(e.AccessToken,t.AccessToken):e.AccessToken,RefreshToken:null!=e.RefreshToken?this.mergeRemovalsDict(e.RefreshToken,t.RefreshToken):e.RefreshToken,IdToken:null!=e.IdToken?this.mergeRemovalsDict(e.IdToken,t.IdToken):e.IdToken,AppMetadata:null!=e.AppMetadata?this.mergeRemovalsDict(e.AppMetadata,t.AppMetadata):e.AppMetadata})},t.mergeRemovalsDict=function(e,t){var n=c({},e);return Object.keys(e).forEach((function(e){t&&t.hasOwnProperty(e)||delete n[e]})),n},t.overlayDefaults=function(e){return this.logger.verbose("Overlaying input cache with the default cache"),{Account:c({},E,{},e.Account),IdToken:c({},O,{},e.IdToken),AccessToken:c({},P,{},e.AccessToken),RefreshToken:c({},_,{},e.RefreshToken),AppMetadata:c({},S,{},e.AppMetadata)}},e}(),M=function(){function e(e){this.config=y(e),this.logger=new n.Logger(this.config.system.loggerOptions),this.storage=new I(this.logger),this.tokenCache=new w(this.storage,this.logger,this.config.cache.cachePlugin),this.cryptoProvider=new k,n.TrustedAuthority.setTrustedAuthoritiesFromConfig(this.config.auth.knownAuthorities,this.config.auth.cloudDiscoveryMetadata)}var t,r=e.prototype;return r.getAuthCodeUrl=function(e){try{var t=this;return t.logger.info("getAuthCodeUrl called"),Promise.resolve(t.buildOauthClientConfiguration(e.authority)).then((function(r){return t.logger.verbose("Auth client config generated"),new n.AuthorizationCodeClient(r).getAuthCodeUrl(t.initializeRequest(e))}))}catch(e){return Promise.reject(e)}},r.acquireTokenByCode=function(e){try{var t=this;t.logger.info("acquireTokenByCode called");var r=t.initializeRequest(e),i=t.initializeServerTelemetryManager(h.acquireTokenByCode,r.correlationId);return Promise.resolve(u((function(){return Promise.resolve(t.buildOauthClientConfiguration(e.authority,i)).then((function(e){return t.logger.verbose("Auth client config generated"),new n.AuthorizationCodeClient(e).acquireToken(r)}))}),(function(e){throw i.cacheFailedRequest(e),e})))}catch(e){return Promise.reject(e)}},r.acquireTokenByRefreshToken=function(e){try{var t=this;t.logger.info("acquireTokenByRefreshToken called");var r=t.initializeRequest(e),i=t.initializeServerTelemetryManager(h.acquireTokenByRefreshToken,r.correlationId);return Promise.resolve(u((function(){return Promise.resolve(t.buildOauthClientConfiguration(e.authority,i)).then((function(e){return t.logger.verbose("Auth client config generated"),new n.RefreshTokenClient(e).acquireToken(r)}))}),(function(e){throw i.cacheFailedRequest(e),e})))}catch(e){return Promise.reject(e)}},r.acquireTokenSilent=function(e){try{var t=this,r=t.initializeRequest(e),i=t.initializeServerTelemetryManager(h.acquireTokenSilent,r.correlationId,r.forceRefresh);return Promise.resolve(u((function(){return Promise.resolve(t.buildOauthClientConfiguration(e.authority,i)).then((function(e){return new n.SilentFlowClient(e).acquireToken(r)}))}),(function(e){throw i.cacheFailedRequest(e),e})))}catch(e){return Promise.reject(e)}},r.getTokenCache=function(){return this.logger.info("getTokenCache called"),this.tokenCache},r.getLogger=function(){return this.logger},r.setLogger=function(e){this.logger=e},r.buildOauthClientConfiguration=function(e,t){try{var n=this;n.logger.verbose("buildOauthClientConfiguration called");var r=n.config.auth.clientId;return Promise.resolve(n.createAuthority(e)).then((function(e){return{authOptions:{clientId:r,authority:e,knownAuthorities:n.config.auth.knownAuthorities,cloudDiscoveryMetadata:n.config.auth.cloudDiscoveryMetadata,clientCapabilities:n.config.auth.clientCapabilities,protocolMode:n.config.auth.protocolMode},loggerOptions:{loggerCallback:n.config.system.loggerOptions.loggerCallback,piiLoggingEnabled:n.config.system.loggerOptions.piiLoggingEnabled},cryptoInterface:n.cryptoProvider,networkInterface:n.config.system.networkClient,storageInterface:n.storage,serverTelemetryManager:t,clientCredentials:{clientSecret:n.clientSecret,clientAssertion:n.clientAssertion?n.getClientAssertion():void 0},libraryInfo:{sku:"msal.js.node",version:"1.0.0-alpha.14",cpu:process.arch||"",os:process.platform||""},persistencePlugin:n.config.cache.cachePlugin,serializableCache:n.tokenCache}}))}catch(e){return Promise.reject(e)}},r.getClientAssertion=function(){return{assertion:this.clientAssertion.getJwt(this.cryptoProvider,this.config.auth.clientId,this._authority.tokenEndpoint),assertionType:"urn:ietf:params:oauth:client-assertion-type:jwt-bearer"}},r.initializeRequest=function(e){return this.logger.verbose("initializeRequestScopes called"),c({},e,{scopes:[].concat(e&&e.scopes||[],[n.Constants.OPENID_SCOPE,n.Constants.PROFILE_SCOPE,n.Constants.OFFLINE_ACCESS_SCOPE]),correlationId:e&&e.correlationId||this.cryptoProvider.createNewGuid()})},r.initializeServerTelemetryManager=function(e,t,r){return new n.ServerTelemetryManager({clientId:this.config.auth.clientId,correlationId:t,apiId:e,forceRefresh:r||!1},this.storage)},r.createAuthority=function(e){try{var t;return this.logger.verbose("createAuthority called"),e?(this.logger.verbose("Authority passed in, creating authority instance"),t=n.AuthorityFactory.createInstance(e,this.config.system.networkClient,this.config.auth.protocolMode)):(this.logger.verbose("No authority passed in request, defaulting to authority set on application object"),t=this.authority),t.discoveryComplete()?Promise.resolve(t):Promise.resolve(u((function(){return Promise.resolve(t.resolveEndpointsAsync()).then((function(){return t}))}),(function(e){throw n.ClientAuthError.createEndpointDiscoveryIncompleteError(e)})))}catch(e){return Promise.reject(e)}},(t=[{key:"authority",get:function(){return this._authority||(this._authority=n.AuthorityFactory.createInstance(this.config.auth.authority||n.Constants.DEFAULT_AUTHORITY,this.config.system.networkClient,this.config.auth.protocolMode)),this._authority}}])&&function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(e.prototype,t),e}(),j=function(e){function t(t){return e.call(this,t)||this}return s(t,e),t.prototype.acquireTokenByDeviceCode=function(e){try{var t=this;t.logger.info("acquireTokenByDeviceCode called");var r=t.initializeRequest(e),i=t.initializeServerTelemetryManager(h.acquireTokenByDeviceCode,r.correlationId);return Promise.resolve(u((function(){return Promise.resolve(t.buildOauthClientConfiguration(e.authority,i)).then((function(e){return t.logger.verbose("Auth client config generated"),new n.DeviceCodeClient(e).acquireToken(r)}))}),(function(e){throw i.cacheFailedRequest(e),e})))}catch(e){return Promise.reject(e)}},t}(M),R=function(){function e(){}e.fromAssertion=function(t){var n=new e;return n.jwt=t,n},e.fromCertificate=function(t,n){var r=new e;return r.privateKey=n,r.thumbprint=t,r};var t=e.prototype;return t.getJwt=function(e,t,r){if(null!=this.privateKey&&null!=this.thumbprint)return null==this.jwt||this.isExpired()||t!=this.issuer||r!=this.jwtAudience?this.createJwt(e,t,r):this.jwt;if(null!=this.jwt)return this.jwt;throw n.ClientAuthError.createInvalidAssertionError()},t.createJwt=function(e,t,r){var i,o;this.issuer=t,this.jwtAudience=r;var c=n.TimeUtils.nowSeconds();this.expirationTime=c+600;var s=((i={}).alg="RS256",i.x5t=C.base64EncodeUrl(this.thumbprint,"hex"),i),u=((o={}).aud=this.jwtAudience,o.exp=this.expirationTime,o.iss=this.issuer,o.sub=this.issuer,o.nbf=c,o.jti=e.createNewGuid(),o);return this.jwt=a.sign(u,this.privateKey,{header:s}),this.jwt},t.isExpired=function(){return this.expirationTime<n.TimeUtils.nowSeconds()},e}(),q=function(e){function t(t){var n;return(n=e.call(this,t)||this).setClientCredential(n.config),n}s(t,e);var r=t.prototype;return r.acquireTokenByClientCredential=function(e){try{var t=this;t.logger.info("acquireTokenByClientCredential called");var r=t.initializeRequest(e),i=t.initializeServerTelemetryManager(h.acquireTokenByClientCredential,r.correlationId,r.skipCache);return Promise.resolve(u((function(){return Promise.resolve(t.buildOauthClientConfiguration(e.authority,i)).then((function(r){return t.logger.verbose("Auth client config generated"),new n.ClientCredentialClient(r).acquireToken(e)}))}),(function(e){throw i.cacheFailedRequest(e),e})))}catch(e){return Promise.reject(e)}},r.acquireTokenOnBehalfOf=function(e){try{var t=this;return t.logger.info("acquireTokenOnBehalfOf called"),Promise.resolve(t.buildOauthClientConfiguration(e.authority)).then((function(r){return t.logger.verbose("Auth client config generated"),new n.OnBehalfOfClient(r).acquireToken(t.initializeRequest(e))}))}catch(e){return Promise.reject(e)}},r.setClientCredential=function(e){var t=!n.StringUtils.isEmpty(e.auth.clientSecret),r=!n.StringUtils.isEmpty(e.auth.clientAssertion),i=e.auth.clientCertificate,o=!n.StringUtils.isEmpty(i.thumbprint)||!n.StringUtils.isEmpty(i.privateKey);if(t&&r||r&&o||t&&o)throw n.ClientAuthError.createInvalidCredentialError();if(t)this.clientSecret=e.auth.clientSecret;else if(r)this.clientAssertion=R.fromAssertion(e.auth.clientAssertion);else{if(!o)throw n.ClientAuthError.createInvalidCredentialError();this.clientAssertion=R.fromCertificate(i.thumbprint,i.privateKey)}},t}(M);Object.defineProperty(exports,"AuthError",{enumerable:!0,get:function(){return n.AuthError}}),Object.defineProperty(exports,"AuthErrorMessage",{enumerable:!0,get:function(){return n.AuthErrorMessage}}),Object.defineProperty(exports,"ClientAuthError",{enumerable:!0,get:function(){return n.ClientAuthError}}),Object.defineProperty(exports,"ClientAuthErrorMessage",{enumerable:!0,get:function(){return n.ClientAuthErrorMessage}}),Object.defineProperty(exports,"ClientConfigurationError",{enumerable:!0,get:function(){return n.ClientConfigurationError}}),Object.defineProperty(exports,"ClientConfigurationErrorMessage",{enumerable:!0,get:function(){return n.ClientConfigurationErrorMessage}}),Object.defineProperty(exports,"InteractionRequiredAuthError",{enumerable:!0,get:function(){return n.InteractionRequiredAuthError}}),Object.defineProperty(exports,"LogLevel",{enumerable:!0,get:function(){return n.LogLevel}}),Object.defineProperty(exports,"Logger",{enumerable:!0,get:function(){return n.Logger}}),Object.defineProperty(exports,"PromptValue",{enumerable:!0,get:function(){return n.PromptValue}}),Object.defineProperty(exports,"ProtocolMode",{enumerable:!0,get:function(){return n.ProtocolMode}}),Object.defineProperty(exports,"ResponseMode",{enumerable:!0,get:function(){return n.ResponseMode}}),Object.defineProperty(exports,"ServerError",{enumerable:!0,get:function(){return n.ServerError}}),Object.defineProperty(exports,"TokenCacheContext",{enumerable:!0,get:function(){return n.TokenCacheContext}}),exports.ConfidentialClientApplication=q,exports.CryptoProvider=k,exports.Deserializer=b,exports.PublicClientApplication=j,exports.Serializer=A,exports.Storage=I,exports.TokenCache=w,exports.buildAppConfiguration=y;
//# sourceMappingURL=msal-node.cjs.production.min.js.map
{
"name": "@azure/msal-node",
"version": "1.0.0-alpha.13",
"version": "1.0.0-alpha.14",
"author": {

@@ -61,3 +61,2 @@ "name": "Microsoft",

"devDependencies": {
"@types/debug": "^4.1.5",
"@types/jest": "^25.1.2",

@@ -77,3 +76,2 @@ "@types/node": "^13.13.4",

"axios": "^0.19.2",
"debug": "^4.1.1",
"jsonwebtoken": "^8.5.1",

@@ -80,0 +78,0 @@ "uuid": "^8.3.0"

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc