mailgun.js 12.0.1 → 12.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/Types/index.js CHANGED
@@ -375,6 +375,7 @@ function bind(fn, thisArg) {
375
375
 
376
376
  const {toString} = Object.prototype;
377
377
  const {getPrototypeOf} = Object;
378
+ const {iterator, toStringTag} = Symbol;
378
379
 
379
380
  const kindOf = (cache => thing => {
380
381
  const str = toString.call(thing);
@@ -501,7 +502,7 @@ const isPlainObject = (val) => {
501
502
  }
502
503
 
503
504
  const prototype = getPrototypeOf(val);
504
- return (prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null) && !(Symbol.toStringTag in val) && !(Symbol.iterator in val);
505
+ return (prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null) && !(toStringTag in val) && !(iterator in val);
505
506
  };
506
507
 
507
508
  /**
@@ -852,13 +853,13 @@ const isTypedArray = (TypedArray => {
852
853
  * @returns {void}
853
854
  */
854
855
  const forEachEntry = (obj, fn) => {
855
- const generator = obj && obj[Symbol.iterator];
856
+ const generator = obj && obj[iterator];
856
857
 
857
- const iterator = generator.call(obj);
858
+ const _iterator = generator.call(obj);
858
859
 
859
860
  let result;
860
861
 
861
- while ((result = iterator.next()) && !result.done) {
862
+ while ((result = _iterator.next()) && !result.done) {
862
863
  const pair = result.value;
863
864
  fn.call(obj, pair[0], pair[1]);
864
865
  }
@@ -971,26 +972,6 @@ const toFiniteNumber = (value, defaultValue) => {
971
972
  return value != null && Number.isFinite(value = +value) ? value : defaultValue;
972
973
  };
973
974
 
974
- const ALPHA = 'abcdefghijklmnopqrstuvwxyz';
975
-
976
- const DIGIT = '0123456789';
977
-
978
- const ALPHABET = {
979
- DIGIT,
980
- ALPHA,
981
- ALPHA_DIGIT: ALPHA + ALPHA.toUpperCase() + DIGIT
982
- };
983
-
984
- const generateString = (size = 16, alphabet = ALPHABET.ALPHA_DIGIT) => {
985
- let str = '';
986
- const {length} = alphabet;
987
- while (size--) {
988
- str += alphabet[Math.random() * length|0];
989
- }
990
-
991
- return str;
992
- };
993
-
994
975
  /**
995
976
  * If the thing is a FormData object, return true, otherwise return false.
996
977
  *
@@ -999,7 +980,7 @@ const generateString = (size = 16, alphabet = ALPHABET.ALPHA_DIGIT) => {
999
980
  * @returns {boolean}
1000
981
  */
1001
982
  function isSpecCompliantForm(thing) {
1002
- return !!(thing && isFunction(thing.append) && thing[Symbol.toStringTag] === 'FormData' && thing[Symbol.iterator]);
983
+ return !!(thing && isFunction(thing.append) && thing[toStringTag] === 'FormData' && thing[iterator]);
1003
984
  }
1004
985
 
1005
986
  const toJSONObject = (obj) => {
@@ -1068,6 +1049,10 @@ const asap = typeof queueMicrotask !== 'undefined' ?
1068
1049
 
1069
1050
  // *********************
1070
1051
 
1052
+
1053
+ const isIterable = (thing) => thing != null && isFunction(thing[iterator]);
1054
+
1055
+
1071
1056
  var utils$1 = {
1072
1057
  isArray,
1073
1058
  isArrayBuffer,
@@ -1118,14 +1103,13 @@ var utils$1 = {
1118
1103
  findKey,
1119
1104
  global: _global,
1120
1105
  isContextDefined,
1121
- ALPHABET,
1122
- generateString,
1123
1106
  isSpecCompliantForm,
1124
1107
  toJSONObject,
1125
1108
  isAsyncFn,
1126
1109
  isThenable,
1127
1110
  setImmediate: _setImmediate,
1128
- asap
1111
+ asap,
1112
+ isIterable
1129
1113
  };
1130
1114
 
1131
1115
  /**
@@ -1344,6 +1328,10 @@ function toFormData$1(obj, formData, options) {
1344
1328
  return value.toISOString();
1345
1329
  }
1346
1330
 
1331
+ if (utils$1.isBoolean(value)) {
1332
+ return value.toString();
1333
+ }
1334
+
1347
1335
  if (!useBlob && utils$1.isBlob(value)) {
1348
1336
  throw new AxiosError$1('Blob is not supported. Use a Buffer instead.');
1349
1337
  }
@@ -2106,10 +2094,18 @@ let AxiosHeaders$1 = class AxiosHeaders {
2106
2094
  setHeaders(header, valueOrRewrite);
2107
2095
  } else if(utils$1.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
2108
2096
  setHeaders(parseHeaders(header), valueOrRewrite);
2109
- } else if (utils$1.isHeaders(header)) {
2110
- for (const [key, value] of header.entries()) {
2111
- setHeader(value, key, rewrite);
2097
+ } else if (utils$1.isObject(header) && utils$1.isIterable(header)) {
2098
+ let obj = {}, dest, key;
2099
+ for (const entry of header) {
2100
+ if (!utils$1.isArray(entry)) {
2101
+ throw TypeError('Object iterator must return a key-value pair');
2102
+ }
2103
+
2104
+ obj[key = entry[0]] = (dest = obj[key]) ?
2105
+ (utils$1.isArray(dest) ? [...dest, entry[1]] : [dest, entry[1]]) : entry[1];
2112
2106
  }
2107
+
2108
+ setHeaders(obj, valueOrRewrite);
2113
2109
  } else {
2114
2110
  header != null && setHeader(valueOrRewrite, header, rewrite);
2115
2111
  }
@@ -2251,6 +2247,10 @@ let AxiosHeaders$1 = class AxiosHeaders {
2251
2247
  return Object.entries(this.toJSON()).map(([header, value]) => header + ': ' + value).join('\n');
2252
2248
  }
2253
2249
 
2250
+ getSetCookie() {
2251
+ return this.get("set-cookie") || [];
2252
+ }
2253
+
2254
2254
  get [Symbol.toStringTag]() {
2255
2255
  return 'AxiosHeaders';
2256
2256
  }
@@ -2606,8 +2606,9 @@ function combineURLs(baseURL, relativeURL) {
2606
2606
  *
2607
2607
  * @returns {string} The combined full path
2608
2608
  */
2609
- function buildFullPath(baseURL, requestedURL) {
2610
- if (baseURL && !isAbsoluteURL(requestedURL)) {
2609
+ function buildFullPath(baseURL, requestedURL, allowAbsoluteUrls) {
2610
+ let isRelativeUrl = !isAbsoluteURL(requestedURL);
2611
+ if (baseURL && (isRelativeUrl || allowAbsoluteUrls == false)) {
2611
2612
  return combineURLs(baseURL, requestedURL);
2612
2613
  }
2613
2614
  return requestedURL;
@@ -2722,7 +2723,7 @@ var resolveConfig = (config) => {
2722
2723
 
2723
2724
  newConfig.headers = headers = AxiosHeaders$1.from(headers);
2724
2725
 
2725
- newConfig.url = buildURL(buildFullPath(newConfig.baseURL, newConfig.url), config.params, config.paramsSerializer);
2726
+ newConfig.url = buildURL(buildFullPath(newConfig.baseURL, newConfig.url, newConfig.allowAbsoluteUrls), config.params, config.paramsSerializer);
2726
2727
 
2727
2728
  // HTTP basic authentication
2728
2729
  if (auth) {
@@ -3239,7 +3240,7 @@ var fetchAdapter = isFetchSupported && (async (config) => {
3239
3240
  credentials: isCredentialsSupported ? withCredentials : undefined
3240
3241
  });
3241
3242
 
3242
- let response = await fetch(request);
3243
+ let response = await fetch(request, fetchOptions);
3243
3244
 
3244
3245
  const isStreamResponse = supportsResponseStream && (responseType === 'stream' || responseType === 'response');
3245
3246
 
@@ -3285,7 +3286,7 @@ var fetchAdapter = isFetchSupported && (async (config) => {
3285
3286
  } catch (err) {
3286
3287
  unsubscribe && unsubscribe();
3287
3288
 
3288
- if (err && err.name === 'TypeError' && /fetch/i.test(err.message)) {
3289
+ if (err && err.name === 'TypeError' && /Load failed|fetch/i.test(err.message)) {
3289
3290
  throw Object.assign(
3290
3291
  new AxiosError$1('Network Error', AxiosError$1.ERR_NETWORK, config, request),
3291
3292
  {
@@ -3445,7 +3446,7 @@ function dispatchRequest(config) {
3445
3446
  });
3446
3447
  }
3447
3448
 
3448
- const VERSION$1 = "1.7.9";
3449
+ const VERSION$1 = "1.10.0";
3449
3450
 
3450
3451
  const validators$1 = {};
3451
3452
 
@@ -3553,7 +3554,7 @@ const validators = validator.validators;
3553
3554
  */
3554
3555
  let Axios$1 = class Axios {
3555
3556
  constructor(instanceConfig) {
3556
- this.defaults = instanceConfig;
3557
+ this.defaults = instanceConfig || {};
3557
3558
  this.interceptors = {
3558
3559
  request: new InterceptorManager(),
3559
3560
  response: new InterceptorManager()
@@ -3630,6 +3631,13 @@ let Axios$1 = class Axios {
3630
3631
  }
3631
3632
  }
3632
3633
 
3634
+ // Set config.allowAbsoluteUrls
3635
+ if (config.allowAbsoluteUrls !== undefined) ; else if (this.defaults.allowAbsoluteUrls !== undefined) {
3636
+ config.allowAbsoluteUrls = this.defaults.allowAbsoluteUrls;
3637
+ } else {
3638
+ config.allowAbsoluteUrls = true;
3639
+ }
3640
+
3633
3641
  validator.assertOptions(config, {
3634
3642
  baseUrl: validators.spelling('baseURL'),
3635
3643
  withXsrfToken: validators.spelling('withXSRFToken')
@@ -3725,7 +3733,7 @@ let Axios$1 = class Axios {
3725
3733
 
3726
3734
  getUri(config) {
3727
3735
  config = mergeConfig$1(this.defaults, config);
3728
- const fullPath = buildFullPath(config.baseURL, config.url);
3736
+ const fullPath = buildFullPath(config.baseURL, config.url, config.allowAbsoluteUrls);
3729
3737
  return buildURL(fullPath, config.params, config.paramsSerializer);
3730
3738
  }
3731
3739
  };
@@ -4405,7 +4413,7 @@ var Request$1 = /** @class */ (function () {
4405
4413
  this.username = options.username;
4406
4414
  this.key = options.key;
4407
4415
  this.url = options.url;
4408
- this.timeout = options.timeout;
4416
+ this.timeout = options.timeout || 60000; // Default timeout is 60 seconds
4409
4417
  this.headers = this.makeHeadersFromObject(options.headers);
4410
4418
  this.formDataBuilder = new FormDataBuilder(formData);
4411
4419
  this.maxBodyLength = 52428800; // 50 MB
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mailgun.js",
3
- "version": "12.0.1",
3
+ "version": "12.0.3",
4
4
  "author": "Mailgun",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -57,7 +57,7 @@
57
57
  }
58
58
  },
59
59
  "dependencies": {
60
- "axios": "^1.7.4",
60
+ "axios": "^1.10.0",
61
61
  "base-64": "^1.0.0",
62
62
  "url-join": "^4.0.1"
63
63
  },
package/version.md CHANGED
@@ -1 +1 @@
1
- 12.0.1
1
+ 12.0.3