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
17
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 1.14.1 to 1.14.2

dist/esm/utils/clean-url.d.ts

1

dist/esm/index.d.ts

@@ -13,1 +13,2 @@ export * from "./request";

export * from "./utils/append-custom-params";
export * from "./utils/clean-url";

@@ -13,2 +13,3 @@ /* Copyright (c) 2018 Environmental Systems Research Institute, Inc.

export * from "./utils/append-custom-params";
export * from "./utils/clean-url";
//# sourceMappingURL=index.js.map

4

dist/esm/utils/get-portal-url.js

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

import { cleanUrl } from "./clean-url";
/**

@@ -12,6 +13,7 @@ * Helper that returns the appropriate portal url for a given request. `requestOptions.portal` is given

if (requestOptions.portal) {
return requestOptions.portal;
return cleanUrl(requestOptions.portal);
}
// if auth was passed, use that portal
if (requestOptions.authentication) {
// the portal url is already scrubbed in the auth package
return requestOptions.authentication.portal;

@@ -18,0 +20,0 @@ }

@@ -16,2 +16,3 @@ "use strict";

tslib_1.__exportStar(require("./utils/append-custom-params"), exports);
tslib_1.__exportStar(require("./utils/clean-url"), exports);
//# sourceMappingURL=index.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var clean_url_1 = require("./clean-url");
/**

@@ -14,6 +15,7 @@ * Helper that returns the appropriate portal url for a given request. `requestOptions.portal` is given

if (requestOptions.portal) {
return requestOptions.portal;
return clean_url_1.cleanUrl(requestOptions.portal);
}
// if auth was passed, use that portal
if (requestOptions.authentication) {
// the portal url is already scrubbed in the auth package
return requestOptions.authentication.portal;

@@ -20,0 +22,0 @@ }

/* @preserve
* @esri/arcgis-rest-request - v1.14.1 - Apache-2.0
* @esri/arcgis-rest-request - v1.14.2 - Apache-2.0
* Copyright (c) 2017-2018 Esri, Inc.
* Wed Nov 21 2018 15:56:17 GMT-0800 (Pacific Standard Time)
* Tue Nov 27 2018 11:20:28 GMT-0800 (Pacific Standard Time)
*/

@@ -485,3 +485,18 @@ (function (global, factory) {

/* Copyright (c) 2018 Environmental Systems Research Institute, Inc.
* Apache-2.0 */
/**
* Helper method to ensure that user supplied urls don't include whitespace or a trailing slash.
*/
function cleanUrl(url) {
// trim leading and trailing spaces, but not spaces inside the url
url = url.trim();
// remove the trailing slash to the url if one was included
if (url[url.length - 1] === "/") {
url = url.slice(0, -1);
}
return url;
}
/**
* Helper that returns the appropriate portal url for a given request. `requestOptions.portal` is given

@@ -497,6 +512,7 @@ * precedence over `authentication.portal`. If neither are present, `www.arcgis.com/sharing/rest` is returned.

if (requestOptions.portal) {
return requestOptions.portal;
return cleanUrl(requestOptions.portal);
}
// if auth was passed, use that portal
if (requestOptions.authentication) {
// the portal url is already scrubbed in the auth package
return requestOptions.authentication.portal;

@@ -572,2 +588,3 @@ }

exports.appendCustomParams = appendCustomParams;
exports.cleanUrl = cleanUrl;

@@ -574,0 +591,0 @@ Object.defineProperty(exports, '__esModule', { value: true });

/* @preserve
* @esri/arcgis-rest-request - v1.14.1 - Apache-2.0
* @esri/arcgis-rest-request - v1.14.2 - Apache-2.0
* Copyright (c) 2017-2018 Esri, Inc.
* Wed Nov 21 2018 15:56:22 GMT-0800 (Pacific Standard Time)
* Tue Nov 27 2018 11:20:31 GMT-0800 (Pacific Standard Time)
*/
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(e.arcgisRest=e.arcgisRest||{})}(this,function(e){"use strict";var t=function(e,r){return(t=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,r)};var r=function(){return(r=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 o(e){return Object.keys(e).some(function(t){var r=e[t];if(!r)return!1;switch(r.constructor.name){case"Array":case"Object":case"Date":case"Function":case"Boolean":case"String":case"Number":return!1;default:return!0}})}function n(e){var t={};return Object.keys(e).forEach(function(r){var o=e[r];if(o||0===o||"boolean"==typeof o||"string"==typeof o){var n;switch(o.constructor.name){case"Array":n=o[0]&&o[0].constructor&&"Object"===o[0].constructor.name?JSON.stringify(o):o.join(",");break;case"Object":n=JSON.stringify(o);break;case"Date":n=o.valueOf();break;case"Function":n=null;break;case"Boolean":n=o+"";break;default:n=o}(n||0===n||"string"==typeof n)&&(t[r]=n)}}),t}function a(e,t){return encodeURIComponent(e)+"="+encodeURIComponent(t)}function s(e){var t=n(e);return Object.keys(t).map(function(e){return a(e,t[e])}).join("&")}function c(e){var t=o(e),r=n(e);if(t){var a=new FormData;return Object.keys(r).forEach(function(e){if("undefined"!=typeof Blob&&r[e]instanceof Blob){var t=r.fileName||r[e].name||e;a.append(e,r[e],t)}else a.append(e,r[e])}),a}return s(e)}var i=function(){return 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 u(e,t){void 0===t&&(t={params:{f:"json"}});var n=r({httpMethod:"POST"},t),a=[],u=[];if(n.fetch||"undefined"==typeof fetch?(a.push("`fetch`"),u.push("`isomorphic-fetch`")):n.fetch=fetch.bind(Function("return this")()),"undefined"==typeof Promise&&(a.push("`Promise`"),u.push("`es6-promise`")),"undefined"==typeof FormData&&(a.push("`FormData`"),u.push("`isomorphic-form-data`")),!n.fetch||"undefined"==typeof Promise||"undefined"==typeof FormData)throw new Error("`arcgis-rest-request` requires global variables for `fetch`, `Promise` and `FormData` to be present in the global scope. You are missing "+a.join(", ")+". We recommend installing the "+u.join(", ")+" modules at the root of your application to add these to the global scope. See https://bit.ly/2KNwWaJ for more info.");var f=n.httpMethod,h=n.authentication,d=r({f:"json"},t.params),l={method:f,credentials:"same-origin"};return(h?h.getToken(e,{fetch:n.fetch}):Promise.resolve("")).then(function(t){if(t.length&&(d.token=t),"GET"===l.method){var r=""===s(d)?e:e+"?"+s(d);n.maxUrlLength&&r.length>n.maxUrlLength?l.method="POST":e=r}return"POST"===l.method&&(l.body=c(d)),l.headers={},"undefined"==typeof window&&(l.headers.referer="@esri/arcgis-rest"),o(d)||(l.headers["Content-Type"]="application/x-www-form-urlencoded"),n.fetch(e,l)}).then(function(t){if(!t.ok){var r=t.status,o=t.statusText;throw new i(o,"HTTP "+r,t,e,n)}switch(d.f){case"json":case"geojson":return t.json();case"html":case"text":return t.text();case"image":case"zip":default:return t.blob()}}).then(function(t){return"json"===d.f||"geojson"===d.f?p(t,e,d,n):t})}i.prototype=Object.create(Error.prototype),i.prototype.constructor=i;var f,h=function(e){function o(t,r,o,n,a){void 0===t&&(t="AUTHENTICATION_ERROR"),void 0===r&&(r="AUTHENTICATION_ERROR_CODE");var s=e.call(this,t,r,o,n,a)||this;return s.name="ArcGISAuthError",s.message="AUTHENTICATION_ERROR_CODE"===r?t:r+": "+t,s}return function(e,r){function o(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(o.prototype=r.prototype,new o)}(o,e),o.prototype.retry=function(e,t){var o=this;void 0===t&&(t=3);var n=0,a=function(s,c){e(o.url,o.options).then(function(e){var t=r({},o.options,{authentication:e});return n+=1,u(o.url,t)}).then(function(e){s(e)}).catch(function(e){"ArcGISAuthError"===e.name&&n<t?a(s,c):"ArcGISAuthError"===e.name&&n>=t?c(o):c(e)})};return new Promise(function(e,t){a(e,t)})},o}(i);function p(e,t,r,o){if(e.code>=400){var n=e.message,a=e.code;throw new i(n,a,e,t,o)}if(e.error){var s=e.error,c=(n=s.message,a=s.code,s.messageCode),u=c||a||"UNKNOWN_ERROR_CODE";if(498===a||499===a||"GWM_0003"===c)throw new h(n,u,e,t,o);throw new i(n,u,e,t,o)}if("failed"===e.status||"failure"===e.status){n=void 0,a="UNKNOWN_ERROR_CODE";try{n=JSON.parse(e.statusMessage).message,a=JSON.parse(e.statusMessage).code}catch(t){n=e.statusMessage||e.message}throw new i(n,a,e,t,o)}return e}function d(e){return void 0===e&&(e={}),e.portal?e.portal:e.authentication?e.authentication.portal:"https://www.arcgis.com/sharing/rest"}function l(e,t){var o=e||"self";return u(d(t)+"/portals/"+o,r({httpMethod:"GET"},t))}(f=e.ErrorTypes||(e.ErrorTypes={})).ArcGISRequestError="ArcGISRequestError",f.ArcGISAuthError="ArcGISAuthError",e.request=u,e.ArcGISAuthError=h,e.checkForErrors=p,e.encodeFormData=c,e.encodeParam=a,e.encodeQueryString=s,e.warn=function(e){console&&console.warn&&console.warn.apply(console,[e])},e.ArcGISRequestError=i,e.requiresFormData=o,e.processParams=n,e.getSelf=function(e){return l(null,e)},e.getPortal=l,e.getPortalUrl=d,e.appendCustomParams=function(e,t){Object.keys(e).forEach(function(r){"url"!==r&&"params"!==r&&"authentication"!==r&&"httpMethod"!==r&&"fetch"!==r&&"portal"!==r&&"maxUrlLength"!==r&&"endpoint"!==r&&"decodeValues"!==r&&(t.params[r]=e[r])})},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.arcgisRest=e.arcgisRest||{})}(this,function(e){"use strict";var t=function(e,r){return(t=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,r)};var r=function(){return(r=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 o(e){return Object.keys(e).some(function(t){var r=e[t];if(!r)return!1;switch(r.constructor.name){case"Array":case"Object":case"Date":case"Function":case"Boolean":case"String":case"Number":return!1;default:return!0}})}function n(e){var t={};return Object.keys(e).forEach(function(r){var o=e[r];if(o||0===o||"boolean"==typeof o||"string"==typeof o){var n;switch(o.constructor.name){case"Array":n=o[0]&&o[0].constructor&&"Object"===o[0].constructor.name?JSON.stringify(o):o.join(",");break;case"Object":n=JSON.stringify(o);break;case"Date":n=o.valueOf();break;case"Function":n=null;break;case"Boolean":n=o+"";break;default:n=o}(n||0===n||"string"==typeof n)&&(t[r]=n)}}),t}function a(e,t){return encodeURIComponent(e)+"="+encodeURIComponent(t)}function s(e){var t=n(e);return Object.keys(t).map(function(e){return a(e,t[e])}).join("&")}function c(e){var t=o(e),r=n(e);if(t){var a=new FormData;return Object.keys(r).forEach(function(e){if("undefined"!=typeof Blob&&r[e]instanceof Blob){var t=r.fileName||r[e].name||e;a.append(e,r[e],t)}else a.append(e,r[e])}),a}return s(e)}var i=function(){return 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 u(e,t){void 0===t&&(t={params:{f:"json"}});var n=r({httpMethod:"POST"},t),a=[],u=[];if(n.fetch||"undefined"==typeof fetch?(a.push("`fetch`"),u.push("`isomorphic-fetch`")):n.fetch=fetch.bind(Function("return this")()),"undefined"==typeof Promise&&(a.push("`Promise`"),u.push("`es6-promise`")),"undefined"==typeof FormData&&(a.push("`FormData`"),u.push("`isomorphic-form-data`")),!n.fetch||"undefined"==typeof Promise||"undefined"==typeof FormData)throw new Error("`arcgis-rest-request` requires global variables for `fetch`, `Promise` and `FormData` to be present in the global scope. You are missing "+a.join(", ")+". We recommend installing the "+u.join(", ")+" modules at the root of your application to add these to the global scope. See https://bit.ly/2KNwWaJ for more info.");var f=n.httpMethod,h=n.authentication,l=r({f:"json"},t.params),d={method:f,credentials:"same-origin"};return(h?h.getToken(e,{fetch:n.fetch}):Promise.resolve("")).then(function(t){if(t.length&&(l.token=t),"GET"===d.method){var r=""===s(l)?e:e+"?"+s(l);n.maxUrlLength&&r.length>n.maxUrlLength?d.method="POST":e=r}return"POST"===d.method&&(d.body=c(l)),d.headers={},"undefined"==typeof window&&(d.headers.referer="@esri/arcgis-rest"),o(l)||(d.headers["Content-Type"]="application/x-www-form-urlencoded"),n.fetch(e,d)}).then(function(t){if(!t.ok){var r=t.status,o=t.statusText;throw new i(o,"HTTP "+r,t,e,n)}switch(l.f){case"json":case"geojson":return t.json();case"html":case"text":return t.text();case"image":case"zip":default:return t.blob()}}).then(function(t){return"json"===l.f||"geojson"===l.f?p(t,e,l,n):t})}i.prototype=Object.create(Error.prototype),i.prototype.constructor=i;var f,h=function(e){function o(t,r,o,n,a){void 0===t&&(t="AUTHENTICATION_ERROR"),void 0===r&&(r="AUTHENTICATION_ERROR_CODE");var s=e.call(this,t,r,o,n,a)||this;return s.name="ArcGISAuthError",s.message="AUTHENTICATION_ERROR_CODE"===r?t:r+": "+t,s}return function(e,r){function o(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(o.prototype=r.prototype,new o)}(o,e),o.prototype.retry=function(e,t){var o=this;void 0===t&&(t=3);var n=0,a=function(s,c){e(o.url,o.options).then(function(e){var t=r({},o.options,{authentication:e});return n+=1,u(o.url,t)}).then(function(e){s(e)}).catch(function(e){"ArcGISAuthError"===e.name&&n<t?a(s,c):"ArcGISAuthError"===e.name&&n>=t?c(o):c(e)})};return new Promise(function(e,t){a(e,t)})},o}(i);function p(e,t,r,o){if(e.code>=400){var n=e.message,a=e.code;throw new i(n,a,e,t,o)}if(e.error){var s=e.error,c=(n=s.message,a=s.code,s.messageCode),u=c||a||"UNKNOWN_ERROR_CODE";if(498===a||499===a||"GWM_0003"===c)throw new h(n,u,e,t,o);throw new i(n,u,e,t,o)}if("failed"===e.status||"failure"===e.status){n=void 0,a="UNKNOWN_ERROR_CODE";try{n=JSON.parse(e.statusMessage).message,a=JSON.parse(e.statusMessage).code}catch(t){n=e.statusMessage||e.message}throw new i(n,a,e,t,o)}return e}function l(e){return"/"===(e=e.trim())[e.length-1]&&(e=e.slice(0,-1)),e}function d(e){return void 0===e&&(e={}),e.portal?l(e.portal):e.authentication?e.authentication.portal:"https://www.arcgis.com/sharing/rest"}function m(e,t){var o=e||"self";return u(d(t)+"/portals/"+o,r({httpMethod:"GET"},t))}(f=e.ErrorTypes||(e.ErrorTypes={})).ArcGISRequestError="ArcGISRequestError",f.ArcGISAuthError="ArcGISAuthError",e.request=u,e.ArcGISAuthError=h,e.checkForErrors=p,e.encodeFormData=c,e.encodeParam=a,e.encodeQueryString=s,e.warn=function(e){console&&console.warn&&console.warn.apply(console,[e])},e.ArcGISRequestError=i,e.requiresFormData=o,e.processParams=n,e.getSelf=function(e){return m(null,e)},e.getPortal=m,e.getPortalUrl=d,e.appendCustomParams=function(e,t){Object.keys(e).forEach(function(r){"url"!==r&&"params"!==r&&"authentication"!==r&&"httpMethod"!==r&&"fetch"!==r&&"portal"!==r&&"maxUrlLength"!==r&&"endpoint"!==r&&"decodeValues"!==r&&(t.params[r]=e[r])})},e.cleanUrl=l,Object.defineProperty(e,"__esModule",{value:!0})});
//# sourceMappingURL=request.umd.min.js.map
{
"name": "@esri/arcgis-rest-request",
"version": "1.14.1",
"version": "1.14.2",
"description": "Common methods and utilities for @esri/arcgis-rest-* 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

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