@esri/arcgis-rest-request
Advanced tools
Comparing version 3.2.0 to 3.2.1
@@ -314,4 +314,4 @@ /* Copyright (c) 2017-2018 Environmental Systems Research Institute, Inc. | ||
if (originalAuthError) { | ||
/* if the request was made to an unfederated service that | ||
didnt require authentication, add the base url and a dummy token | ||
/* If the request was made to an unfederated service that | ||
didn't require authentication, add the base url and a dummy token | ||
to the list of trusted servers to avoid another federation check | ||
@@ -318,0 +318,0 @@ in the event of a repeat request */ |
@@ -319,4 +319,4 @@ "use strict"; | ||
if (originalAuthError) { | ||
/* if the request was made to an unfederated service that | ||
didnt require authentication, add the base url and a dummy token | ||
/* If the request was made to an unfederated service that | ||
didn't require authentication, add the base url and a dummy token | ||
to the list of trusted servers to avoid another federation check | ||
@@ -323,0 +323,0 @@ in the event of a repeat request */ |
/* @preserve | ||
* @esri/arcgis-rest-request - v3.2.0 - Apache-2.0 | ||
* @esri/arcgis-rest-request - v3.2.1 - Apache-2.0 | ||
* Copyright (c) 2017-2021 Esri, Inc. | ||
* Fri Jul 09 2021 07:37:25 GMT-0700 (Pacific Daylight Time) | ||
* Fri Jul 09 2021 09:38:54 GMT-0700 (Pacific Daylight Time) | ||
*/ | ||
@@ -564,4 +564,4 @@ (function (global, factory) { | ||
if (originalAuthError) { | ||
/* if the request was made to an unfederated service that | ||
didnt require authentication, add the base url and a dummy token | ||
/* If the request was made to an unfederated service that | ||
didn't require authentication, add the base url and a dummy token | ||
to the list of trusted servers to avoid another federation check | ||
@@ -568,0 +568,0 @@ in the event of a repeat request */ |
/* @preserve | ||
* @esri/arcgis-rest-request - v3.2.0 - Apache-2.0 | ||
* @esri/arcgis-rest-request - v3.2.1 - Apache-2.0 | ||
* Copyright (c) 2017-2021 Esri, Inc. | ||
* Fri Jul 09 2021 07:37:27 GMT-0700 (Pacific Daylight Time) | ||
* Fri Jul 09 2021 09:38:55 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="undefined"!=typeof globalThis?globalThis: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)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])})(e,t)};var u=function(){return(u=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 f(t){return Object.keys(t).some(function(e){e=t[e];if(!e)return!1;switch(e&&e.toParam&&(e=e.toParam()),e.constructor.name){case"Array":case"Object":case"Date":case"Function":case"Boolean":case"String":case"Number":return!1;default:return!0}})}function o(o){var a={};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){switch(t.constructor.name){case"Array":var r=null===(r=null===(r=t[0])||void 0===r?void 0:r.constructor)||void 0===r?void 0:r.name,n="Array"===r?t:"Object"===r?JSON.stringify(t):t.join(",");break;case"Object":n=JSON.stringify(t);break;case"Date":n=t.valueOf();break;case"Function":n=null;break;case"Boolean":n=t+"";break;default:n=t}(n||0===n||"string"==typeof n||Array.isArray(n))&&(a[e]=n)}}),a}function n(t,e){return Array.isArray(e)&&e[0]&&Array.isArray(e[0])?e.map(function(e){return n(t,e)}).join("&"):encodeURIComponent(t)+"="+encodeURIComponent(e)}function d(e){var t=o(e);return Object.keys(t).map(function(e){return n(e,t[e])}).join("&")}function h(e,t){var t=f(e)||t,r=o(e);if(t){var n=new FormData;return Object.keys(r).forEach(function(e){var t;"undefined"!=typeof Blob&&r[e]instanceof Blob?(t=r.fileName||r[e].name||e,n.append(e,r[e],t)):n.append(e,r[e])}),n}return d(e)}var p=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 a(e){console&&console.warn&&console.warn.apply(console,[e])}p.prototype=Object.create(Error.prototype),p.prototype.constructor=p;var l="@esri/arcgis-rest-js",m={httpMethod:"POST",params:{f:"json"}};var s,t,i,c,y=(r(t=g,i=s=p),t.prototype=null===i?Object.create(i):(O.prototype=i.prototype,new O),g.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){e=u(u({},o.options),{authentication:e});return a+=1,E(o.url,e)}).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)})},g);function O(){this.constructor=t}function g(e,t,r,n,o){void 0===e&&(e="AUTHENTICATION_ERROR"),void 0===t&&(t="AUTHENTICATION_ERROR_CODE");o=s.call(this,e,t,r,n,o)||this;return o.name="ArcGISAuthError",o.message="AUTHENTICATION_ERROR_CODE"===t?e:t+": "+e,o}function v(t,e,r,n,o){if(400<=t.code){var a=t.message,s=t.code;throw new p(a,s,t,e,n)}if(t.error){var i=t.error,a=i.message,s=i.code,c=i.messageCode,i=c||s||"UNKNOWN_ERROR_CODE";if(498===s||499===s||"GWM_0003"===c||400===s&&"Unable to generate token."===a)throw o||new y(a,i,t,e,n);throw new p(a,i,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 p(a,s,t,e,n)}function E(n,e){void 0===e&&(e={params:{f:"json"}});var o=u(u(u({httpMethod:"POST"},m),e),{params:u(u({},m.params),e.params),headers:u(u({},m.headers),e.headers)}),t=[],e=[];if(o.fetch||"undefined"==typeof fetch?(t.push("`fetch`"),e.push("`node-fetch`")):o.fetch=fetch.bind(Function("return this")()),"undefined"==typeof Promise&&(t.push("`Promise`"),e.push("`es6-promise`")),"undefined"==typeof FormData&&(t.push("`FormData`"),e.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 "+e.join(", ")+" modules at the root of your application to add these to the global scope. See https://bit.ly/2KNwWaJ for more info.");var e=o.httpMethod,a=o.authentication,s=o.rawResponse,i=u({f:"json"},o.params),r=null,c={method:e,credentials:o.credentials||"same-origin"};return o.headers&&o.headers["X-Esri-Auth-Client-Id"]&&-1<n.indexOf("/oauth2/platformSelf")&&(c.credentials="include"),(a?a.getToken(n,{fetch:o.fetch}).catch(function(e){return e.url=n,e.options=o,r=e,Promise.resolve("")}):Promise.resolve("")).then(function(e){e.length&&(i.token=e),a&&a.getDomainCredentials&&(c.credentials=a.getDomainCredentials(n));var t={};"GET"===c.method&&(i.token&&o.hideToken&&"undefined"==typeof window&&(t["X-Esri-Authorization"]="Bearer "+i.token,delete i.token),r=""===d(i)?n:n+"?"+d(i),o.maxUrlLength&&r.length>o.maxUrlLength||i.token&&o.hideToken?(c.method="POST",e.length&&o.hideToken&&(i.token=e,delete t["X-Esri-Authorization"])):n=r);var r=new RegExp("/items/.+/updateResources").test(n);return"POST"===c.method&&(c.body=h(i,r)),c.headers=u(u({},t),o.headers),"undefined"!=typeof window||c.headers.referer||(c.headers.referer=l),f(i)||r||(c.headers["Content-Type"]="application/x-www-form-urlencoded"),o.fetch(n,c)}).then(function(e){if(!e.ok){var t=e.status,r=e.statusText;throw new p(r,"HTTP "+t,e,n,o)}if(s)return e;switch(i.f){case"json":case"geojson":return e.json();case"html":case"text":return e.text();default:return e.blob()}}).then(function(e){if("json"!==i.f&&"geojson"!==i.f||s)return e;var t=v(e,n,0,o,r);return r&&(e=n.toLowerCase().split(/\/rest(\/admin)?\/services\//)[0],o.authentication.federatedServers[e]={token:[],expires:new Date(Date.now()+864e5)},r=null),t})}function R(e){var t=e.split("="),e=t[0],t=t[1];return{key:decodeURIComponent(e),value:decodeURIComponent(t)}}(c=e.ErrorTypes||(e.ErrorTypes={})).ArcGISRequestError="ArcGISRequestError",c.ArcGISAuthError="ArcGISAuthError",e.ArcGISAuthError=y,e.ArcGISRequestError=p,e.NODEJS_DEFAULT_REFERER_HEADER=l,e.appendCustomParams=function(r,e,t){var n=u(u({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=v,e.cleanUrl=function(e){return"string"!=typeof e||"/"===(e=e.trim())[e.length-1]&&(e=e.slice(0,-1)),e},e.decodeParam=R,e.decodeQueryString=function(e){return e.replace(/^#/,"").split("&").reduce(function(e,t){var r=R(t),t=r.key,r=r.value;return e[t]=r,e},{})},e.encodeFormData=h,e.encodeParam=n,e.encodeQueryString=d,e.processParams=o,e.request=E,e.requiresFormData=f,e.setDefaultRequestOptions=function(e,t){e.authentication&&!t&&a("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."),m=e},e.warn=a,Object.defineProperty(e,"__esModule",{value:!0})}); | ||
//# sourceMappingURL=request.umd.min.js.map |
{ | ||
"name": "@esri/arcgis-rest-request", | ||
"version": "3.2.0", | ||
"version": "3.2.1", | ||
"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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
238255