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.14 to 1.0.0-alpha.15

35

CHANGELOG.json

@@ -5,2 +5,37 @@ {

{
"date": "Sat, 07 Nov 2020 01:50:14 GMT",
"tag": "@azure/msal-node_v1.0.0-alpha.15",
"version": "1.0.0-alpha.15",
"comments": {
"prerelease": [
{
"comment": "Fixing a bug and adding `localAccountId` in AccountInfo interface (#2516)",
"author": "sameera.gajjarapu@microsoft.com",
"commit": "98f43038608fe66a256dabfff0810476e9e6b3ab",
"package": "@azure/msal-node"
},
{
"comment": "Filtered lookup of IdTokens, AppMetadata; Error handling in Node Storage (#2530)",
"author": "sameera.gajjarapu@microsoft.com",
"commit": "354dd86449d792b7369fb240c5e2cfd70ca73488",
"package": "@azure/msal-node"
},
{
"comment": "Implement Password Grant Flow (#2204)",
"author": "sameera.gajjarapu@microsoft.com",
"commit": "baf6d157e7bbeae439526aee13eb08962974925b",
"package": "@azure/msal-node"
}
],
"none": [
{
"comment": "Build Pipeline Changes (#2406)",
"author": "thomas.norling@microsoft.com",
"commit": "af8459c0d53a4dc2bf495017608c0bb03004d006",
"package": "@azure/msal-node"
}
]
}
},
{
"date": "Mon, 02 Nov 2020 23:33:39 GMT",

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

12

changelog.md
# Change Log - @azure/msal-node
This log was last generated on Mon, 02 Nov 2020 23:33:39 GMT and should not be manually modified.
This log was last generated on Sat, 07 Nov 2020 01:50:14 GMT and should not be manually modified.
<!-- Start content -->
## 1.0.0-alpha.15
Sat, 07 Nov 2020 01:50:14 GMT
### Changes
- Fixing a bug and adding `localAccountId` in AccountInfo interface (#2516) (sameera.gajjarapu@microsoft.com)
- Filtered lookup of IdTokens, AppMetadata; Error handling in Node Storage (#2530) (sameera.gajjarapu@microsoft.com)
- Implement Password Grant Flow (#2204) (sameera.gajjarapu@microsoft.com)
## 1.0.0-alpha.14

@@ -8,0 +18,0 @@

@@ -31,2 +31,16 @@ import { Storage } from "./Storage";

/**
* Returns the signed in account matching homeAccountId.
* (the account object is created at the time of successful login)
* or null when no matching account is found
* @returns {@link AccountInfo} - the account object stored in MSAL
*/
getAccountByHomeId(homeAccountId: string): Promise<AccountInfo | null>;
/**
* Returns the signed in account matching localAccountId.
* (the account object is created at the time of successful login)
* or null when no matching account is found
* @returns {@link AccountInfo} - the account object stored in MSAL
*/
getAccountByLocalId(localAccountId: string): Promise<AccountInfo | null>;
/**
* API to remove a specific account and the relevant data from cache

@@ -33,0 +47,0 @@ * @param account

@@ -1,2 +0,2 @@

import { DeviceCodeRequest, AuthenticationResult } from "@azure/msal-common";
import { DeviceCodeRequest, AuthenticationResult, UsernamePasswordRequest } from "@azure/msal-common";
import { Configuration } from "../config/Configuration";

@@ -37,2 +37,13 @@ import { ClientApplication } from "./ClientApplication";

acquireTokenByDeviceCode(request: DeviceCodeRequest): Promise<AuthenticationResult>;
/**
* Acquires tokens with password grant by exchanging client applications username and password for credentials
*
* The latest OAuth 2.0 Security Best Current Practice disallows the password grant entirely.
* More details on this recommendation at https://tools.ietf.org/html/draft-ietf-oauth-security-topics-13#section-3.4
* Microsoft's documentation and recommendations are at:
* https://docs.microsoft.com/en-us/azure/active-directory/develop/msal-authentication-flows#usernamepassword
*
* @param request
*/
acquireTokenByUsernamePassword(request: UsernamePasswordRequest): Promise<AuthenticationResult>;
}

2

dist/msal-node.cjs.production.min.js

@@ -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=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;
"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.acquireTokenByUsernamePassword=371]="acquireTokenByUsernamePassword",e[e.acquireTokenByDeviceCode=671]="acquireTokenByDeviceCode",e[e.acquireTokenByClientCredential=771]="acquireTokenByClientCredential",e[e.acquireTokenByCode=871]="acquireTokenByCode",e[e.acquireTokenByRefreshToken=872]="acquireTokenByRefreshToken"}(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},m={},p={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({},m,{},t),system:c({},p,{},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}(),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}(),b=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 t&&n.AccountEntity.isAccountEntity(t)?t:null},r.setAccount=function(e){var t=e.generateAccountKey();this.setItem(t,e)},r.getIdTokenCredential=function(e){var t=n.CredentialEntity.getCredentialType(e),r=this.getItem(e);return r&&t===n.CredentialType.ID_TOKEN?r:null},r.setIdTokenCredential=function(e){var t=e.generateCredentialKey();this.setItem(t,e)},r.getAccessTokenCredential=function(e){var t=n.CredentialEntity.getCredentialType(e),r=this.getItem(e);return r&&t===n.CredentialType.ACCESS_TOKEN?r:null},r.setAccessTokenCredential=function(e){var t=e.generateCredentialKey();this.setItem(t,e)},r.getRefreshTokenCredential=function(e){var t=n.CredentialEntity.getCredentialType(e),r=this.getItem(e);return r&&t===n.CredentialType.REFRESH_TOKEN?r:null},r.setRefreshTokenCredential=function(e){var t=e.generateCredentialKey();this.setItem(t,e)},r.getAppMetadata=function(e){var t=this.getItem(e);return t&&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 t&&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 t&&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 b.serializeAllCache(e)},t}(n.CacheManager),E={},P={},O={},w={},S={},_=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=b.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(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.getAccountByHomeId=function(e){try{return Promise.resolve(this.getAllAccounts()).then((function(t){return!n.StringUtils.isEmpty(e)&&t&&t.length&&t.filter((function(t){return t.homeAccountId===e}))[0]||null}))}catch(e){return Promise.reject(e)}},t.getAccountByLocalId=function(e){try{return Promise.resolve(this.getAllAccounts()).then((function(t){return!n.StringUtils.isEmpty(e)&&t&&t.length&&t.filter((function(t){return t.localAccountId===e}))[0]||null}))}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({},P,{},e.IdToken),AccessToken:c({},O,{},e.AccessToken),RefreshToken:c({},w,{},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 _(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.15",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}s(t,e);var r=t.prototype;return r.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)}},r.acquireTokenByUsernamePassword=function(e){try{var t=this;t.logger.info("acquireTokenByUsernamePassword called");var r=t.initializeRequest(e),i=t.initializeServerTelemetryManager(h.acquireTokenByUsernamePassword,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.UsernamePasswordClient(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=A,exports.PublicClientApplication=j,exports.Serializer=b,exports.Storage=I,exports.TokenCache=_,exports.buildAppConfiguration=y;
//# sourceMappingURL=msal-node.cjs.production.min.js.map

@@ -47,6 +47,7 @@ /**

acquireTokenSilent = 62,
acquireTokenByUsernamePassword = 371,
acquireTokenByDeviceCode = 671,
acquireTokenByClientCredential = 771,
acquireTokenByCode = 871,
acquireTokenByRefreshToken = 872,
acquireTokenByDeviceCode = 671,
acquireTokenByClientCredential = 771
acquireTokenByRefreshToken = 872
}

@@ -53,0 +54,0 @@ /**

{
"name": "@azure/msal-node",
"version": "1.0.0-alpha.14",
"version": "1.0.0-alpha.15",
"author": {

@@ -61,9 +61,9 @@ "name": "Microsoft",

"devDependencies": {
"@types/jest": "^25.1.2",
"@types/jest": "^25.2.3",
"@types/jsonwebtoken": "^8.5.0",
"@types/node": "^13.13.4",
"@types/uuid": "^7.0.0",
"@types/jsonwebtoken": "^8.5.0",
"gh-pages": "^3.1.0",
"husky": "^4.2.3",
"tsdx": "^0.13.2",
"tsdx": "^0.14.0",
"tslib": "^1.10.0",

@@ -74,3 +74,3 @@ "typedoc": "^0.17.7",

"dependencies": {
"@azure/msal-common": "^1.6.3",
"@azure/msal-common": "^1.7.0",
"axios": "^0.19.2",

@@ -77,0 +77,0 @@ "jsonwebtoken": "^8.5.1",

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