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

@esri/arcgis-rest-auth

Package Overview
Dependencies
Maintainers
16
Versions
118
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@esri/arcgis-rest-auth - npm Package Compare versions

Comparing version 1.5.1 to 1.6.0

2

dist/esm/UserSession.d.ts

@@ -133,3 +133,3 @@ /// <reference types="node" />

* in `request`. This class also includes several
* helper methods for authenticating users with OAuth 2.0 in both browser and
* helper methods for authenticating users with [OAuth 2.0](https://developers.arcgis.com/documentation/core-concepts/security-and-authentication/browser-based-user-logins/) in both browser and
* server applications.

@@ -136,0 +136,0 @@ *

@@ -28,3 +28,3 @@ /* Copyright (c) 2017 Environmental Systems Research Institute, Inc.

* in `request`. This class also includes several
* helper methods for authenticating users with OAuth 2.0 in both browser and
* helper methods for authenticating users with [OAuth 2.0](https://developers.arcgis.com/documentation/core-concepts/security-and-authentication/browser-based-user-logins/) in both browser and
* server applications.

@@ -323,3 +323,3 @@ *

UserSession.prototype.getToken = function (url) {
if (/^https?:\/\/www\.arcgis\.com\/sharing\/rest\/?/.test(this.portal) &&
if (/^https?:\/\/\S+\.arcgis\.com\/sharing\/rest/.test(this.portal) &&
/^https?:\/\/\S+\.arcgis\.com.+/.test(url)) {

@@ -326,0 +326,0 @@ return this.getFreshToken();

@@ -30,3 +30,3 @@ "use strict";

* in `request`. This class also includes several
* helper methods for authenticating users with OAuth 2.0 in both browser and
* helper methods for authenticating users with [OAuth 2.0](https://developers.arcgis.com/documentation/core-concepts/security-and-authentication/browser-based-user-logins/) in both browser and
* server applications.

@@ -325,3 +325,3 @@ *

UserSession.prototype.getToken = function (url) {
if (/^https?:\/\/www\.arcgis\.com\/sharing\/rest\/?/.test(this.portal) &&
if (/^https?:\/\/\S+\.arcgis\.com\/sharing\/rest/.test(this.portal) &&
/^https?:\/\/\S+\.arcgis\.com.+/.test(url)) {

@@ -328,0 +328,0 @@ return this.getFreshToken();

/* @preserve
* @esri/arcgis-rest-auth - v1.5.1 - Thu Jul 12 2018 08:28:46 GMT-0700 (PDT)
* @esri/arcgis-rest-auth - v1.6.0 - Fri Jul 27 2018 15:12:37 GMT-0700 (PDT)
* Copyright (c) 2017 - 2018 Environmental Systems Research Institute, Inc.

@@ -135,3 +135,3 @@ * Apache-2.0

* in `request`. This class also includes several
* helper methods for authenticating users with OAuth 2.0 in both browser and
* helper methods for authenticating users with [OAuth 2.0](https://developers.arcgis.com/documentation/core-concepts/security-and-authentication/browser-based-user-logins/) in both browser and
* server applications.

@@ -430,3 +430,3 @@ *

UserSession.prototype.getToken = function (url) {
if (/^https?:\/\/www\.arcgis\.com\/sharing\/rest\/?/.test(this.portal) &&
if (/^https?:\/\/\S+\.arcgis\.com\/sharing\/rest/.test(this.portal) &&
/^https?:\/\/\S+\.arcgis\.com.+/.test(url)) {

@@ -433,0 +433,0 @@ return this.getFreshToken();

/* @preserve
* @esri/arcgis-rest-auth - v1.5.1 - Thu Jul 12 2018 08:28:48 GMT-0700 (PDT)
* @esri/arcgis-rest-auth - v1.6.0 - Fri Jul 27 2018 15:12:39 GMT-0700 (PDT)
* Copyright (c) 2017 - 2018 Environmental Systems Research Institute, Inc.
* Apache-2.0
*/
!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("@esri/arcgis-rest-request")):"function"==typeof define&&define.amd?define(["exports","@esri/arcgis-rest-request"],r):r(e.arcgisRest=e.arcgisRest||{},e.arcgisRest)}(this,function(e,r){"use strict";function t(e,t){return r.request(e,{params:t}).then(function(e){var r={token:e.access_token,username:e.username,expires:new Date(Date.now()+(60*e.expires_in*1e3-6e4))};return e.refresh_token&&(r.refreshToken=e.refresh_token),r})}var n=function(){function e(e){this.clientId=e.clientId,this.clientSecret=e.clientSecret,this.token=e.token,this.expires=e.expires,this.portal="https://www.arcgis.com/sharing/rest",this.duration=e.duration||20160}return e.prototype.getToken=function(e){return this.token&&this.expires&&this.expires.getTime()>Date.now()?Promise.resolve(this.token):this._pendingTokenRequest?this._pendingTokenRequest:(this._pendingTokenRequest=this.refreshToken(),this._pendingTokenRequest)},e.prototype.refreshToken=function(){var e=this;return t(this.portal+"/oauth2/token/",{client_id:this.clientId,client_secret:this.clientSecret,grant_type:"client_credentials"}).then(function(r){return e._pendingTokenRequest=null,e.token=r.token,e.expires=r.expires,r.token})},e.prototype.refreshSession=function(){var e=this;return this.refreshToken().then(function(){return e})},e}(),o=Object.assign||function(e){for(var r,t=1,n=arguments.length;t<n;t++)for(var o in r=arguments[t])Object.prototype.hasOwnProperty.call(r,o)&&(e[o]=r[o]);return e};function i(e,t){return"undefined"!=typeof window&&window.location&&window.location.host?t.referer=window.location.host:t.referer="@esri.arcgis-rest-auth",r.request(e,{params:t})}var s=function(){function e(e){this.clientId=e.clientId,this._refreshToken=e.refreshToken,this._refreshTokenExpires=e.refreshTokenExpires,this.username=e.username,this.password=e.password,this._token=e.token,this._tokenExpires=e.tokenExpires,this.portal=e.portal||"https://www.arcgis.com/sharing/rest",this.provider=e.provider||"arcgis",this.tokenDuration=e.tokenDuration||20160,this.redirectUri=e.redirectUri,this.refreshTokenTTL=e.refreshTokenTTL||1440,this.trustedServers={},this._pendingTokenRequests={}}return Object.defineProperty(e.prototype,"token",{get:function(){return this._token},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"tokenExpires",{get:function(){return this._tokenExpires},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"refreshToken",{get:function(){return this._refreshToken},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"refreshTokenExpires",{get:function(){return this._refreshTokenExpires},enumerable:!0,configurable:!0}),e.beginOAuth2=function(t,n){void 0===n&&(n=window);var i,s=o({portal:"https://www.arcgis.com/sharing/rest",provider:"arcgis",duration:20160,popup:!0,state:t.clientId,locale:""},t),a=s.portal,h=s.provider,u=s.clientId,p=s.duration,c=s.redirectUri,f=s.popup,k=s.state,d=s.locale;if(i="arcgis"===h?a+"/oauth2/authorize?client_id="+u+"&response_type=token&expiration="+p+"&redirect_uri="+encodeURIComponent(c)+"&state="+k+"&locale="+d:a+"/oauth2/social/authorize?client_id="+u+"&socialLoginProviderName="+h+"&autoAccountCreateForSocial=true&response_type=token&expiration="+p+"&redirect_uri="+encodeURIComponent(c)+"&state="+k+"&locale="+d,f){var l,T=((l={promise:null,resolve:null,reject:null}).promise=new Promise(function(e,r){l.resolve=e,l.reject=r}),l);return n["__ESRI_REST_AUTH_HANDLER_"+u]=function(t,n){if(t){var o=JSON.parse(t);T.reject(new r.ArcGISAuthError(o.errorMessage,o.error))}else if(n){var i=JSON.parse(n);T.resolve(new e({clientId:u,portal:a,token:i.token,tokenExpires:new Date(i.expires),username:i.username}))}},n.open(i,"oauth-window","height=400,width=600,menubar=no,location=yes,resizable=yes,scrollbars=yes,status=yes"),T.promise}n.location.href=i},e.completeOAuth2=function(t,n){void 0===n&&(n=window);var i=o({portal:"https://www.arcgis.com/sharing/rest"},t),s=i.portal,a=i.clientId;function h(t,o){if(n.opener&&n.opener.parent)return n.opener.parent["__ESRI_REST_AUTH_HANDLER_"+a](t?JSON.stringify(t):void 0,JSON.stringify(o)),void n.close();if(n!==n.parent)return n.parent["__ESRI_REST_AUTH_HANDLER_"+a](t?JSON.stringify(t):void 0,JSON.stringify(o)),void n.close();if(t)throw new r.ArcGISAuthError(t.errorMessage,t.error);return new e({clientId:a,portal:s,token:o.token,tokenExpires:o.expires,username:o.username})}var u=n.location.href.match(/access_token=(.+)&expires_in=(.+)&username=([^&]+)/);if(!u){var p=n.location.href.match(/error=(.+)&error_description=(.+)/);return h({error:p[1],errorMessage:decodeURIComponent(p[2])})}return h(void 0,{token:u[1],expires:new Date(Date.now()+1e3*parseInt(u[2],10)-6e4),username:decodeURIComponent(u[3])})},e.authorize=function(e,r){var t=o({portal:"https://arcgis.com/sharing/rest",duration:20160},e),n=t.portal,i=t.clientId,s=t.duration,a=t.redirectUri;r.writeHead(301,{Location:n+"/oauth2/authorize?client_id="+i+"&duration="+s+"&response_type=code&redirect_uri="+encodeURIComponent(a)}),r.end()},e.exchangeAuthorizationCode=function(r,n){var i=o({portal:"https://www.arcgis.com/sharing/rest",duration:20160,refreshTokenTTL:1440},r),s=i.portal,a=i.clientId,h=(i.duration,i.redirectUri),u=i.refreshTokenTTL;return t(s+"/oauth2/token",{grant_type:"authorization_code",client_id:a,redirect_uri:h,code:n}).then(function(r){return new e({clientId:a,portal:s,redirectUri:h,refreshToken:r.refreshToken,refreshTokenTTL:u,refreshTokenExpires:new Date(Date.now()+1e3*(u-1)),token:r.token,tokenExpires:r.expires,username:r.username})})},e.deserialize=function(r){var t=JSON.parse(r);return new e({clientId:t.clientId,refreshToken:t.refreshToken,refreshTokenExpires:new Date(t.refreshTokenExpires),username:t.username,password:t.password,token:t.token,tokenExpires:new Date(t.tokenExpires),portal:t.portal,tokenDuration:t.tokenDuration,redirectUri:t.redirectUri,refreshTokenTTL:t.refreshTokenTTL})},e.fromCredential=function(r){return new e({portal:r.server+"/sharing/rest",token:r.token,username:r.userId,tokenExpires:new Date(r.expires)})},e.prototype.toCredential=function(){return{expires:this.tokenExpires.getTime(),server:this.portal,ssl:!0,token:this.token,userId:this.username}},e.prototype.getUser=function(){var e=this;if(this._user&&this._user.username===this.username)return new Promise(function(r){return r(e._user)});var t=this.portal+"/community/users/"+encodeURIComponent(this.username);return r.request(t,{httpMethod:"GET",authentication:this}).then(function(r){return e._user=r,r})},e.prototype.getToken=function(e){return/^https?:\/\/www\.arcgis\.com\/sharing\/rest\/?/.test(this.portal)&&/^https?:\/\/\S+\.arcgis\.com.+/.test(e)?this.getFreshToken():new RegExp(this.portal).test(e)?this.getFreshToken():this.getTokenForServer(e)},e.prototype.toJSON=function(){return{clientId:this.clientId,refreshToken:this.refreshToken,refreshTokenExpires:this.refreshTokenExpires,username:this.username,password:this.password,token:this.token,tokenExpires:this.tokenExpires,portal:this.portal,tokenDuration:this.tokenDuration,redirectUri:this.redirectUri,refreshTokenTTL:this.refreshTokenTTL}},e.prototype.serialize=function(){return JSON.stringify(this)},e.prototype.refreshSession=function(){return this.username&&this.password?this.refreshWithUsernameAndPassword():this.clientId&&this.refreshToken?this.refreshWithRefreshToken():Promise.reject(new r.ArcGISAuthError("Unable to refresh token."))},e.prototype.getTokenForServer=function(e){var t=this,n=e.split("/rest/services/")[0],o=this.trustedServers[n];return o&&o.expires.getTime()>Date.now()?Promise.resolve(o.token):this._pendingTokenRequests[n]?this._pendingTokenRequests[n]:(this._pendingTokenRequests[n]=r.request(n+"/rest/info").then(function(e){return e.owningSystemUrl}).then(function(n){if(!n||!new RegExp(n).test(t.portal))throw new r.ArcGISAuthError(e+" is not federated with "+t.portal+".","NOT_FEDERATED");return r.request(n+"/sharing/rest/info")}).then(function(e){return e.authInfo.tokenServicesUrl}).then(function(r){return t.token?i(r,{token:t.token,serverUrl:e,expiration:t.tokenDuration}):i(r,{username:t.username,password:t.password,expiration:t.tokenDuration}).then(function(e){return t._token=e.token,t._tokenExpires=new Date(e.expires),e})}).then(function(e){return t.trustedServers[n]={expires:new Date(e.expires),token:e.token},e.token}),this._pendingTokenRequests[n])},e.prototype.getFreshToken=function(){var e=this;return this.token&&this.tokenExpires&&this.tokenExpires.getTime()>Date.now()?Promise.resolve(this.token):(this._pendingTokenRequests[this.portal]||(this._pendingTokenRequests[this.portal]=this.refreshSession().then(function(r){return e._pendingTokenRequests[e.portal]=null,r.token})),this._pendingTokenRequests[this.portal])},e.prototype.refreshWithUsernameAndPassword=function(){var e=this;return i(this.portal+"/generateToken",{username:this.username,password:this.password,expiration:this.tokenDuration}).then(function(r){return e._token=r.token,e._tokenExpires=new Date(r.expires),e})},e.prototype.refreshWithRefreshToken=function(){var e=this;return this.refreshToken&&this.refreshTokenExpires&&this.refreshTokenExpires.getTime()<Date.now()?this.refreshRefreshToken():t(this.portal+"/oauth2/token",{client_id:this.clientId,refresh_token:this.refreshToken,grant_type:"refresh_token"}).then(function(r){return e._token=r.token,e._tokenExpires=r.expires,e})},e.prototype.refreshRefreshToken=function(){var e=this;return t(this.portal+"/oauth2/token",{client_id:this.clientId,refresh_token:this.refreshToken,redirect_uri:this.redirectUri,grant_type:"exchange_refresh_token"}).then(function(r){return e._token=r.token,e._tokenExpires=r.expires,e._refreshToken=r.refreshToken,e._refreshTokenExpires=new Date(Date.now()+60*(e.refreshTokenTTL-1)*1e3),e})},e}();e.ApplicationSession=n,e.UserSession=s,e.fetchToken=t,e.generateToken=i,Object.defineProperty(e,"__esModule",{value:!0})});
!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("@esri/arcgis-rest-request")):"function"==typeof define&&define.amd?define(["exports","@esri/arcgis-rest-request"],r):r(e.arcgisRest=e.arcgisRest||{},e.arcgisRest)}(this,function(e,r){"use strict";function t(e,t){return r.request(e,{params:t}).then(function(e){var r={token:e.access_token,username:e.username,expires:new Date(Date.now()+(60*e.expires_in*1e3-6e4))};return e.refresh_token&&(r.refreshToken=e.refresh_token),r})}var n=function(){function e(e){this.clientId=e.clientId,this.clientSecret=e.clientSecret,this.token=e.token,this.expires=e.expires,this.portal="https://www.arcgis.com/sharing/rest",this.duration=e.duration||20160}return e.prototype.getToken=function(e){return this.token&&this.expires&&this.expires.getTime()>Date.now()?Promise.resolve(this.token):this._pendingTokenRequest?this._pendingTokenRequest:(this._pendingTokenRequest=this.refreshToken(),this._pendingTokenRequest)},e.prototype.refreshToken=function(){var e=this;return t(this.portal+"/oauth2/token/",{client_id:this.clientId,client_secret:this.clientSecret,grant_type:"client_credentials"}).then(function(r){return e._pendingTokenRequest=null,e.token=r.token,e.expires=r.expires,r.token})},e.prototype.refreshSession=function(){var e=this;return this.refreshToken().then(function(){return e})},e}(),o=Object.assign||function(e){for(var r,t=1,n=arguments.length;t<n;t++)for(var o in r=arguments[t])Object.prototype.hasOwnProperty.call(r,o)&&(e[o]=r[o]);return e};function i(e,t){return"undefined"!=typeof window&&window.location&&window.location.host?t.referer=window.location.host:t.referer="@esri.arcgis-rest-auth",r.request(e,{params:t})}var s=function(){function e(e){this.clientId=e.clientId,this._refreshToken=e.refreshToken,this._refreshTokenExpires=e.refreshTokenExpires,this.username=e.username,this.password=e.password,this._token=e.token,this._tokenExpires=e.tokenExpires,this.portal=e.portal||"https://www.arcgis.com/sharing/rest",this.provider=e.provider||"arcgis",this.tokenDuration=e.tokenDuration||20160,this.redirectUri=e.redirectUri,this.refreshTokenTTL=e.refreshTokenTTL||1440,this.trustedServers={},this._pendingTokenRequests={}}return Object.defineProperty(e.prototype,"token",{get:function(){return this._token},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"tokenExpires",{get:function(){return this._tokenExpires},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"refreshToken",{get:function(){return this._refreshToken},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"refreshTokenExpires",{get:function(){return this._refreshTokenExpires},enumerable:!0,configurable:!0}),e.beginOAuth2=function(t,n){void 0===n&&(n=window);var i,s=o({portal:"https://www.arcgis.com/sharing/rest",provider:"arcgis",duration:20160,popup:!0,state:t.clientId,locale:""},t),a=s.portal,h=s.provider,u=s.clientId,p=s.duration,c=s.redirectUri,f=s.popup,k=s.state,d=s.locale;if(i="arcgis"===h?a+"/oauth2/authorize?client_id="+u+"&response_type=token&expiration="+p+"&redirect_uri="+encodeURIComponent(c)+"&state="+k+"&locale="+d:a+"/oauth2/social/authorize?client_id="+u+"&socialLoginProviderName="+h+"&autoAccountCreateForSocial=true&response_type=token&expiration="+p+"&redirect_uri="+encodeURIComponent(c)+"&state="+k+"&locale="+d,f){var l,T=((l={promise:null,resolve:null,reject:null}).promise=new Promise(function(e,r){l.resolve=e,l.reject=r}),l);return n["__ESRI_REST_AUTH_HANDLER_"+u]=function(t,n){if(t){var o=JSON.parse(t);T.reject(new r.ArcGISAuthError(o.errorMessage,o.error))}else if(n){var i=JSON.parse(n);T.resolve(new e({clientId:u,portal:a,token:i.token,tokenExpires:new Date(i.expires),username:i.username}))}},n.open(i,"oauth-window","height=400,width=600,menubar=no,location=yes,resizable=yes,scrollbars=yes,status=yes"),T.promise}n.location.href=i},e.completeOAuth2=function(t,n){void 0===n&&(n=window);var i=o({portal:"https://www.arcgis.com/sharing/rest"},t),s=i.portal,a=i.clientId;function h(t,o){if(n.opener&&n.opener.parent)return n.opener.parent["__ESRI_REST_AUTH_HANDLER_"+a](t?JSON.stringify(t):void 0,JSON.stringify(o)),void n.close();if(n!==n.parent)return n.parent["__ESRI_REST_AUTH_HANDLER_"+a](t?JSON.stringify(t):void 0,JSON.stringify(o)),void n.close();if(t)throw new r.ArcGISAuthError(t.errorMessage,t.error);return new e({clientId:a,portal:s,token:o.token,tokenExpires:o.expires,username:o.username})}var u=n.location.href.match(/access_token=(.+)&expires_in=(.+)&username=([^&]+)/);if(!u){var p=n.location.href.match(/error=(.+)&error_description=(.+)/);return h({error:p[1],errorMessage:decodeURIComponent(p[2])})}return h(void 0,{token:u[1],expires:new Date(Date.now()+1e3*parseInt(u[2],10)-6e4),username:decodeURIComponent(u[3])})},e.authorize=function(e,r){var t=o({portal:"https://arcgis.com/sharing/rest",duration:20160},e),n=t.portal,i=t.clientId,s=t.duration,a=t.redirectUri;r.writeHead(301,{Location:n+"/oauth2/authorize?client_id="+i+"&duration="+s+"&response_type=code&redirect_uri="+encodeURIComponent(a)}),r.end()},e.exchangeAuthorizationCode=function(r,n){var i=o({portal:"https://www.arcgis.com/sharing/rest",duration:20160,refreshTokenTTL:1440},r),s=i.portal,a=i.clientId,h=(i.duration,i.redirectUri),u=i.refreshTokenTTL;return t(s+"/oauth2/token",{grant_type:"authorization_code",client_id:a,redirect_uri:h,code:n}).then(function(r){return new e({clientId:a,portal:s,redirectUri:h,refreshToken:r.refreshToken,refreshTokenTTL:u,refreshTokenExpires:new Date(Date.now()+1e3*(u-1)),token:r.token,tokenExpires:r.expires,username:r.username})})},e.deserialize=function(r){var t=JSON.parse(r);return new e({clientId:t.clientId,refreshToken:t.refreshToken,refreshTokenExpires:new Date(t.refreshTokenExpires),username:t.username,password:t.password,token:t.token,tokenExpires:new Date(t.tokenExpires),portal:t.portal,tokenDuration:t.tokenDuration,redirectUri:t.redirectUri,refreshTokenTTL:t.refreshTokenTTL})},e.fromCredential=function(r){return new e({portal:r.server+"/sharing/rest",token:r.token,username:r.userId,tokenExpires:new Date(r.expires)})},e.prototype.toCredential=function(){return{expires:this.tokenExpires.getTime(),server:this.portal,ssl:!0,token:this.token,userId:this.username}},e.prototype.getUser=function(){var e=this;if(this._user&&this._user.username===this.username)return new Promise(function(r){return r(e._user)});var t=this.portal+"/community/users/"+encodeURIComponent(this.username);return r.request(t,{httpMethod:"GET",authentication:this}).then(function(r){return e._user=r,r})},e.prototype.getToken=function(e){return/^https?:\/\/\S+\.arcgis\.com\/sharing\/rest/.test(this.portal)&&/^https?:\/\/\S+\.arcgis\.com.+/.test(e)?this.getFreshToken():new RegExp(this.portal).test(e)?this.getFreshToken():this.getTokenForServer(e)},e.prototype.toJSON=function(){return{clientId:this.clientId,refreshToken:this.refreshToken,refreshTokenExpires:this.refreshTokenExpires,username:this.username,password:this.password,token:this.token,tokenExpires:this.tokenExpires,portal:this.portal,tokenDuration:this.tokenDuration,redirectUri:this.redirectUri,refreshTokenTTL:this.refreshTokenTTL}},e.prototype.serialize=function(){return JSON.stringify(this)},e.prototype.refreshSession=function(){return this.username&&this.password?this.refreshWithUsernameAndPassword():this.clientId&&this.refreshToken?this.refreshWithRefreshToken():Promise.reject(new r.ArcGISAuthError("Unable to refresh token."))},e.prototype.getTokenForServer=function(e){var t=this,n=e.split("/rest/services/")[0],o=this.trustedServers[n];return o&&o.expires.getTime()>Date.now()?Promise.resolve(o.token):this._pendingTokenRequests[n]?this._pendingTokenRequests[n]:(this._pendingTokenRequests[n]=r.request(n+"/rest/info").then(function(e){return e.owningSystemUrl}).then(function(n){if(!n||!new RegExp(n).test(t.portal))throw new r.ArcGISAuthError(e+" is not federated with "+t.portal+".","NOT_FEDERATED");return r.request(n+"/sharing/rest/info")}).then(function(e){return e.authInfo.tokenServicesUrl}).then(function(r){return t.token?i(r,{token:t.token,serverUrl:e,expiration:t.tokenDuration}):i(r,{username:t.username,password:t.password,expiration:t.tokenDuration}).then(function(e){return t._token=e.token,t._tokenExpires=new Date(e.expires),e})}).then(function(e){return t.trustedServers[n]={expires:new Date(e.expires),token:e.token},e.token}),this._pendingTokenRequests[n])},e.prototype.getFreshToken=function(){var e=this;return this.token&&this.tokenExpires&&this.tokenExpires.getTime()>Date.now()?Promise.resolve(this.token):(this._pendingTokenRequests[this.portal]||(this._pendingTokenRequests[this.portal]=this.refreshSession().then(function(r){return e._pendingTokenRequests[e.portal]=null,r.token})),this._pendingTokenRequests[this.portal])},e.prototype.refreshWithUsernameAndPassword=function(){var e=this;return i(this.portal+"/generateToken",{username:this.username,password:this.password,expiration:this.tokenDuration}).then(function(r){return e._token=r.token,e._tokenExpires=new Date(r.expires),e})},e.prototype.refreshWithRefreshToken=function(){var e=this;return this.refreshToken&&this.refreshTokenExpires&&this.refreshTokenExpires.getTime()<Date.now()?this.refreshRefreshToken():t(this.portal+"/oauth2/token",{client_id:this.clientId,refresh_token:this.refreshToken,grant_type:"refresh_token"}).then(function(r){return e._token=r.token,e._tokenExpires=r.expires,e})},e.prototype.refreshRefreshToken=function(){var e=this;return t(this.portal+"/oauth2/token",{client_id:this.clientId,refresh_token:this.refreshToken,redirect_uri:this.redirectUri,grant_type:"exchange_refresh_token"}).then(function(r){return e._token=r.token,e._tokenExpires=r.expires,e._refreshToken=r.refreshToken,e._refreshTokenExpires=new Date(Date.now()+60*(e.refreshTokenTTL-1)*1e3),e})},e}();e.ApplicationSession=n,e.UserSession=s,e.fetchToken=t,e.generateToken=i,Object.defineProperty(e,"__esModule",{value:!0})});
//# sourceMappingURL=auth.umd.min.js.map
{
"name": "@esri/arcgis-rest-auth",
"version": "1.5.1",
"version": "1.6.0",
"description": "Authentication helpers for @esri/arcgis-rest-*.",

@@ -22,4 +22,4 @@ "main": "dist/node/index.js",

"devDependencies": {
"@esri/arcgis-rest-common-types": "^1.5.1",
"@esri/arcgis-rest-request": "^1.5.1"
"@esri/arcgis-rest-common-types": "^1.6.0",
"@esri/arcgis-rest-request": "^1.6.0"
},

@@ -26,0 +26,0 @@ "scripts": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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