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

@esri/arcgis-rest-request

Package Overview
Dependencies
Maintainers
6
Versions
130
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

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

Comparing version 2.12.1 to 2.13.0

14

dist/esm/request.js

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

}
// Custom headers to add to request. IRequestOptions.headers with merge over requestHeaders.
var requestHeaders = {};
if (fetchOptions.method === "GET") {
// Prevents token from being passed in query params when hideToken option is used.
if (params.token && options.hideToken) {
requestHeaders["X-Esri-Authorization"] = "Bearer " + params.token;
delete params.token;
}
// encode the parameters into the query string

@@ -230,2 +237,7 @@ var queryParams = encodeQueryString(params);

fetchOptions.method = "POST";
// Add token back to body with other params instead of header
if (token.length && options.hideToken) {
params.token = token;
delete requestHeaders["X-Esri-Authorization"];
}
}

@@ -245,3 +257,3 @@ else {

// Mixin headers from request options
fetchOptions.headers = tslib_1.__assign({}, options.headers);
fetchOptions.headers = tslib_1.__assign({}, requestHeaders, options.headers);
/* istanbul ignore next - karma reports coverage on browser tests only */

@@ -248,0 +260,0 @@ if (typeof window === "undefined" && !fetchOptions.headers.referer) {

@@ -25,2 +25,7 @@ import { HTTPMethods } from "./HTTPMethods";

/**
* Prevents the token from being passed in a URL Query param that is saved in browser history.
* Instead, the token will be passed in POST request body or through X-Esri-Authorization header
*/
hideToken?: boolean;
/**
* Base url for the portal you want to make the request to. Defaults to 'https://www.arcgis.com/sharing/rest'.

@@ -27,0 +32,0 @@ */

@@ -223,3 +223,10 @@ "use strict";

}
// Custom headers to add to request. IRequestOptions.headers with merge over requestHeaders.
var requestHeaders = {};
if (fetchOptions.method === "GET") {
// Prevents token from being passed in query params when hideToken option is used.
if (params.token && options.hideToken) {
requestHeaders["X-Esri-Authorization"] = "Bearer " + params.token;
delete params.token;
}
// encode the parameters into the query string

@@ -234,2 +241,7 @@ var queryParams = encode_query_string_1.encodeQueryString(params);

fetchOptions.method = "POST";
// Add token back to body with other params instead of header
if (token.length && options.hideToken) {
params.token = token;
delete requestHeaders["X-Esri-Authorization"];
}
}

@@ -249,3 +261,3 @@ else {

// Mixin headers from request options
fetchOptions.headers = tslib_1.__assign({}, options.headers);
fetchOptions.headers = tslib_1.__assign({}, requestHeaders, options.headers);
/* istanbul ignore next - karma reports coverage on browser tests only */

@@ -252,0 +264,0 @@ if (typeof window === "undefined" && !fetchOptions.headers.referer) {

/* @preserve
* @esri/arcgis-rest-request - v2.12.1 - Apache-2.0
* @esri/arcgis-rest-request - v2.13.0 - Apache-2.0
* Copyright (c) 2017-2020 Esri, Inc.
* Sun May 03 2020 09:43:59 GMT-0700 (Pacific Daylight Time)
* Wed May 06 2020 21:29:28 GMT-0700 (Pacific Daylight Time)
*/

@@ -457,3 +457,10 @@ (function (global, factory) {

}
// Custom headers to add to request. IRequestOptions.headers with merge over requestHeaders.
var requestHeaders = {};
if (fetchOptions.method === "GET") {
// Prevents token from being passed in query params when hideToken option is used.
if (params.token && options.hideToken) {
requestHeaders["X-Esri-Authorization"] = "Bearer " + params.token;
delete params.token;
}
// encode the parameters into the query string

@@ -468,2 +475,7 @@ var queryParams = encodeQueryString(params);

fetchOptions.method = "POST";
// Add token back to body with other params instead of header
if (token.length && options.hideToken) {
params.token = token;
delete requestHeaders["X-Esri-Authorization"];
}
}

@@ -483,3 +495,3 @@ else {

// Mixin headers from request options
fetchOptions.headers = __assign({}, options.headers);
fetchOptions.headers = __assign({}, requestHeaders, options.headers);
/* istanbul ignore next - karma reports coverage on browser tests only */

@@ -486,0 +498,0 @@ if (typeof window === "undefined" && !fetchOptions.headers.referer) {

6

dist/umd/request.umd.min.js
/* @preserve
* @esri/arcgis-rest-request - v2.12.1 - Apache-2.0
* @esri/arcgis-rest-request - v2.13.0 - Apache-2.0
* Copyright (c) 2017-2020 Esri, Inc.
* Sun May 03 2020 09:44:01 GMT-0700 (Pacific Daylight Time)
* Wed May 06 2020 21:29:29 GMT-0700 (Pacific Daylight Time)
*/
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).arcgisRest=e.arcgisRest||{})}(this,function(e){"use strict";var r=function(e,t){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)};var h=function(){return(h=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};function p(r){return Object.keys(r).some(function(e){var t=r[e];if(!t)return!1;switch(t&&t.toParam&&(t=t.toParam()),t.constructor.name){case"Array":case"Object":case"Date":case"Function":case"Boolean":case"String":case"Number":return!1;default:return!0}})}function a(n){var o={};return Object.keys(n).forEach(function(e){var t=n[e];if(t&&t.toParam&&(t=t.toParam()),t||0===t||"boolean"==typeof t||"string"==typeof t){var r;switch(t.constructor.name){case"Array":r=t[0]&&t[0].constructor&&"Object"===t[0].constructor.name?JSON.stringify(t):t.join(",");break;case"Object":r=JSON.stringify(t);break;case"Date":r=t.valueOf();break;case"Function":r=null;break;case"Boolean":r=t+"";break;default:r=t}!r&&0!==r&&"string"!=typeof r||(o[e]=r)}}),o}function n(e,t){return encodeURIComponent(e)+"="+encodeURIComponent(t)}function d(e){var t=a(e);return Object.keys(t).map(function(e){return n(e,t[e])}).join("&")}function l(e,t){var r=p(e)||t,n=a(e);if(r){var o=new FormData;return Object.keys(n).forEach(function(e){if("undefined"!=typeof Blob&&n[e]instanceof Blob){var t=n.fileName||n[e].name||e;o.append(e,n[e],t)}else o.append(e,n[e])}),o}return d(e)}var m=function(e,t,r,n,o){e=e||"UNKNOWN_ERROR",t=t||"UNKNOWN_ERROR_CODE",this.name="ArcGISRequestError",this.message="UNKNOWN_ERROR_CODE"===t?e:t+": "+e,this.originalMessage=e,this.code=t,this.response=r,this.url=n,this.options=o};function o(e){console&&console.warn&&console.warn.apply(console,[e])}m.prototype=Object.create(Error.prototype),m.prototype.constructor=m;var O="@esri/arcgis-rest-js",y={httpMethod:"POST",params:{f:"json"}};var t,s,i,c,f=(r(t=v,s=i=m),void(t.prototype=null===s?Object.create(s):(u.prototype=s.prototype,new u)),v.prototype.retry=function(e,n){var o=this;void 0===n&&(n=3);var a=0,s=function(t,r){e(o.url,o.options).then(function(e){var t=h({},o.options,{authentication:e});return a+=1,E(o.url,t)}).then(function(e){t(e)}).catch(function(e){"ArcGISAuthError"===e.name&&a<n?s(t,r):"ArcGISAuthError"===e.name&&n<=a?r(o):r(e)})};return new Promise(function(e,t){s(e,t)})},v);function u(){this.constructor=t}function v(e,t,r,n,o){void 0===e&&(e="AUTHENTICATION_ERROR"),void 0===t&&(t="AUTHENTICATION_ERROR_CODE");var a=i.call(this,e,t,r,n,o)||this;return a.name="ArcGISAuthError",a.message="AUTHENTICATION_ERROR_CODE"===t?e:t+": "+e,a}function g(t,e,r,n,o){if(400<=t.code){var a=t.message,s=t.code;throw new m(a,s,t,e,n)}if(t.error){var i=t.error,c=(a=i.message,s=i.code,i.messageCode),u=c||s||"UNKNOWN_ERROR_CODE";if(498===s||499===s||"GWM_0003"===c||400===s&&"Unable to generate token."===a)throw o||new f(a,u,t,e,n);throw new m(a,u,t,e,n)}if("failed"!==t.status&&"failure"!==t.status)return t;a=void 0,s="UNKNOWN_ERROR_CODE";try{a=JSON.parse(t.statusMessage).message,s=JSON.parse(t.statusMessage).code}catch(e){a=t.statusMessage||t.message}throw new m(a,s,t,e,n)}function E(n,e){void 0===e&&(e={params:{f:"json"}});var o=h({httpMethod:"POST"},y,e,{params:h({},y.params,e.params),headers:h({},y.headers,e.headers)}),t=[],r=[];if(o.fetch||"undefined"==typeof fetch?(t.push("`fetch`"),r.push("`node-fetch`")):o.fetch=fetch.bind(Function("return this")()),"undefined"==typeof Promise&&(t.push("`Promise`"),r.push("`es6-promise`")),"undefined"==typeof FormData&&(t.push("`FormData`"),r.push("`isomorphic-form-data`")),!o.fetch||"undefined"==typeof Promise||"undefined"==typeof FormData)throw new Error("`arcgis-rest-request` requires a `fetch` implementation and global variables for `Promise` and `FormData` to be present in the global scope. You are missing "+t.join(", ")+". We recommend installing the "+r.join(", ")+" modules at the root of your application to add these to the global scope. See https://bit.ly/2KNwWaJ for more info.");var a=o.httpMethod,s=o.authentication,i=o.rawResponse,c=h({f:"json"},o.params),u=null,f={method:a,credentials:"same-origin"};return(s?s.getToken(n,{fetch:o.fetch}).catch(function(e){return e.url=n,e.options=o,u=e,Promise.resolve("")}):Promise.resolve("")).then(function(e){if(e.length&&(c.token=e),"GET"===f.method){var t=""===d(c)?n:n+"?"+d(c);o.maxUrlLength&&t.length>o.maxUrlLength?f.method="POST":n=t}var r=new RegExp("/items/.+/updateResources").test(n);return"POST"===f.method&&(f.body=l(c,r)),f.headers=h({},o.headers),"undefined"!=typeof window||f.headers.referer||(f.headers.referer=O),p(c)||r||(f.headers["Content-Type"]="application/x-www-form-urlencoded"),o.fetch(n,f)}).then(function(e){if(!e.ok){var t=e.status,r=e.statusText;throw new m(r,"HTTP "+t,e,n,o)}if(i)return e;switch(c.f){case"json":case"geojson":return e.json();case"html":case"text":return e.text();default:return e.blob()}}).then(function(e){if("json"!==c.f&&"geojson"!==c.f||i)return e;var t=g(e,n,0,o,u);if(u){var r=n.toLowerCase().split(/\/rest(\/admin)?\/services\//)[0];o.authentication.trustedServers[r]={token:[],expires:new Date(Date.now()+864e5)},u=null}return t})}(c=e.ErrorTypes||(e.ErrorTypes={})).ArcGISRequestError="ArcGISRequestError",c.ArcGISAuthError="ArcGISAuthError",e.ArcGISAuthError=f,e.ArcGISRequestError=m,e.NODEJS_DEFAULT_REFERER_HEADER=O,e.appendCustomParams=function(r,e,t){var n=h({params:{}},t,r);return n.params=e.reduce(function(e,t){return!r[t]&&"boolean"!=typeof r[t]||(e[t]=r[t]),e},n.params),["params","httpMethod","rawResponse","authentication","portal","fetch","maxUrlLength","headers"].reduce(function(e,t){return n[t]&&(e[t]=n[t]),e},{})},e.checkForErrors=g,e.cleanUrl=function(e){return"/"===(e=e.trim())[e.length-1]&&(e=e.slice(0,-1)),e},e.encodeFormData=l,e.encodeParam=n,e.encodeQueryString=d,e.processParams=a,e.request=E,e.requiresFormData=p,e.setDefaultRequestOptions=function(e,t){e.authentication&&!t&&o("You should not set `authentication` as a default in a shared environment such as a web server which will process multiple users requests. You can call `setDefaultRequestOptions` with `true` as a second argument to disable this warning."),y=e},e.warn=o,Object.defineProperty(e,"__esModule",{value:!0})});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).arcgisRest=e.arcgisRest||{})}(this,function(e){"use strict";var r=function(e,t){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)};var h=function(){return(h=Object.assign||function(e){for(var t,r=1,o=arguments.length;r<o;r++)for(var n in t=arguments[r])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e}).apply(this,arguments)};function p(r){return Object.keys(r).some(function(e){var t=r[e];if(!t)return!1;switch(t&&t.toParam&&(t=t.toParam()),t.constructor.name){case"Array":case"Object":case"Date":case"Function":case"Boolean":case"String":case"Number":return!1;default:return!0}})}function a(o){var n={};return Object.keys(o).forEach(function(e){var t=o[e];if(t&&t.toParam&&(t=t.toParam()),t||0===t||"boolean"==typeof t||"string"==typeof t){var r;switch(t.constructor.name){case"Array":r=t[0]&&t[0].constructor&&"Object"===t[0].constructor.name?JSON.stringify(t):t.join(",");break;case"Object":r=JSON.stringify(t);break;case"Date":r=t.valueOf();break;case"Function":r=null;break;case"Boolean":r=t+"";break;default:r=t}!r&&0!==r&&"string"!=typeof r||(n[e]=r)}}),n}function o(e,t){return encodeURIComponent(e)+"="+encodeURIComponent(t)}function d(e){var t=a(e);return Object.keys(t).map(function(e){return o(e,t[e])}).join("&")}function l(e,t){var r=p(e)||t,o=a(e);if(r){var n=new FormData;return Object.keys(o).forEach(function(e){if("undefined"!=typeof Blob&&o[e]instanceof Blob){var t=o.fileName||o[e].name||e;n.append(e,o[e],t)}else n.append(e,o[e])}),n}return d(e)}var m=function(e,t,r,o,n){e=e||"UNKNOWN_ERROR",t=t||"UNKNOWN_ERROR_CODE",this.name="ArcGISRequestError",this.message="UNKNOWN_ERROR_CODE"===t?e:t+": "+e,this.originalMessage=e,this.code=t,this.response=r,this.url=o,this.options=n};function n(e){console&&console.warn&&console.warn.apply(console,[e])}m.prototype=Object.create(Error.prototype),m.prototype.constructor=m;var O="@esri/arcgis-rest-js",v={httpMethod:"POST",params:{f:"json"}};var t,s,i,c,f=(r(t=y,s=i=m),void(t.prototype=null===s?Object.create(s):(u.prototype=s.prototype,new u)),y.prototype.retry=function(e,o){var n=this;void 0===o&&(o=3);var a=0,s=function(t,r){e(n.url,n.options).then(function(e){var t=h({},n.options,{authentication:e});return a+=1,g(n.url,t)}).then(function(e){t(e)}).catch(function(e){"ArcGISAuthError"===e.name&&a<o?s(t,r):"ArcGISAuthError"===e.name&&o<=a?r(n):r(e)})};return new Promise(function(e,t){s(e,t)})},y);function u(){this.constructor=t}function y(e,t,r,o,n){void 0===e&&(e="AUTHENTICATION_ERROR"),void 0===t&&(t="AUTHENTICATION_ERROR_CODE");var a=i.call(this,e,t,r,o,n)||this;return a.name="ArcGISAuthError",a.message="AUTHENTICATION_ERROR_CODE"===t?e:t+": "+e,a}function E(t,e,r,o,n){if(400<=t.code){var a=t.message,s=t.code;throw new m(a,s,t,e,o)}if(t.error){var i=t.error,c=(a=i.message,s=i.code,i.messageCode),u=c||s||"UNKNOWN_ERROR_CODE";if(498===s||499===s||"GWM_0003"===c||400===s&&"Unable to generate token."===a)throw n||new f(a,u,t,e,o);throw new m(a,u,t,e,o)}if("failed"!==t.status&&"failure"!==t.status)return t;a=void 0,s="UNKNOWN_ERROR_CODE";try{a=JSON.parse(t.statusMessage).message,s=JSON.parse(t.statusMessage).code}catch(e){a=t.statusMessage||t.message}throw new m(a,s,t,e,o)}function g(n,e){void 0===e&&(e={params:{f:"json"}});var a=h({httpMethod:"POST"},v,e,{params:h({},v.params,e.params),headers:h({},v.headers,e.headers)}),t=[],r=[];if(a.fetch||"undefined"==typeof fetch?(t.push("`fetch`"),r.push("`node-fetch`")):a.fetch=fetch.bind(Function("return this")()),"undefined"==typeof Promise&&(t.push("`Promise`"),r.push("`es6-promise`")),"undefined"==typeof FormData&&(t.push("`FormData`"),r.push("`isomorphic-form-data`")),!a.fetch||"undefined"==typeof Promise||"undefined"==typeof FormData)throw new Error("`arcgis-rest-request` requires a `fetch` implementation and global variables for `Promise` and `FormData` to be present in the global scope. You are missing "+t.join(", ")+". We recommend installing the "+r.join(", ")+" modules at the root of your application to add these to the global scope. See https://bit.ly/2KNwWaJ for more info.");var o=a.httpMethod,s=a.authentication,i=a.rawResponse,c=h({f:"json"},a.params),u=null,f={method:o,credentials:"same-origin"};return(s?s.getToken(n,{fetch:a.fetch}).catch(function(e){return e.url=n,e.options=a,u=e,Promise.resolve("")}):Promise.resolve("")).then(function(e){e.length&&(c.token=e);var t={};if("GET"===f.method){c.token&&a.hideToken&&(t["X-Esri-Authorization"]="Bearer "+c.token,delete c.token);var r=""===d(c)?n:n+"?"+d(c);a.maxUrlLength&&r.length>a.maxUrlLength?(f.method="POST",e.length&&a.hideToken&&(c.token=e,delete t["X-Esri-Authorization"])):n=r}var o=new RegExp("/items/.+/updateResources").test(n);return"POST"===f.method&&(f.body=l(c,o)),f.headers=h({},t,a.headers),"undefined"!=typeof window||f.headers.referer||(f.headers.referer=O),p(c)||o||(f.headers["Content-Type"]="application/x-www-form-urlencoded"),a.fetch(n,f)}).then(function(e){if(!e.ok){var t=e.status,r=e.statusText;throw new m(r,"HTTP "+t,e,n,a)}if(i)return e;switch(c.f){case"json":case"geojson":return e.json();case"html":case"text":return e.text();default:return e.blob()}}).then(function(e){if("json"!==c.f&&"geojson"!==c.f||i)return e;var t=E(e,n,0,a,u);if(u){var r=n.toLowerCase().split(/\/rest(\/admin)?\/services\//)[0];a.authentication.trustedServers[r]={token:[],expires:new Date(Date.now()+864e5)},u=null}return t})}(c=e.ErrorTypes||(e.ErrorTypes={})).ArcGISRequestError="ArcGISRequestError",c.ArcGISAuthError="ArcGISAuthError",e.ArcGISAuthError=f,e.ArcGISRequestError=m,e.NODEJS_DEFAULT_REFERER_HEADER=O,e.appendCustomParams=function(r,e,t){var o=h({params:{}},t,r);return o.params=e.reduce(function(e,t){return!r[t]&&"boolean"!=typeof r[t]||(e[t]=r[t]),e},o.params),["params","httpMethod","rawResponse","authentication","portal","fetch","maxUrlLength","headers"].reduce(function(e,t){return o[t]&&(e[t]=o[t]),e},{})},e.checkForErrors=E,e.cleanUrl=function(e){return"/"===(e=e.trim())[e.length-1]&&(e=e.slice(0,-1)),e},e.encodeFormData=l,e.encodeParam=o,e.encodeQueryString=d,e.processParams=a,e.request=g,e.requiresFormData=p,e.setDefaultRequestOptions=function(e,t){e.authentication&&!t&&n("You should not set `authentication` as a default in a shared environment such as a web server which will process multiple users requests. You can call `setDefaultRequestOptions` with `true` as a second argument to disable this warning."),v=e},e.warn=n,Object.defineProperty(e,"__esModule",{value:!0})});
//# sourceMappingURL=request.umd.min.js.map
{
"name": "@esri/arcgis-rest-request",
"version": "2.12.1",
"version": "2.13.0",
"description": "Common methods and utilities for @esri/arcgis-rest-js packages.",

@@ -5,0 +5,0 @@ "main": "dist/node/index.js",

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