@govuk-pay/pay-js-commons 5.0.3 → 6.0.2
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/README.md
CHANGED
|
@@ -166,11 +166,27 @@ Or a pence value can be converted to GBP
|
|
|
166
166
|
</dl>
|
|
167
167
|
```
|
|
168
168
|
|
|
169
|
-
|
|
169
|
+
## Axios base client
|
|
170
170
|
|
|
171
|
-
Used in our Node.js apps to call
|
|
171
|
+
Used in our Node.js apps to call APIs such as connector or ledger.
|
|
172
172
|
|
|
173
|
-
Uses the NPM Axios library.
|
|
173
|
+
Uses the NPM [Axios](https://www.npmjs.com/package/axios) library.
|
|
174
|
+
|
|
175
|
+
The base client provides the following configuration options:
|
|
176
|
+
* onRequestStart - Callback function before starting a API request. Mainly used for logging.
|
|
177
|
+
* onSuccessResponse - Callback function when request has completed successfully.
|
|
178
|
+
* onFailureResponse - Callback function when request has failed.
|
|
179
|
+
* acceptAllStatusCodes - `boolean`
|
|
180
|
+
* By default all non 2xx responses are considered failed requests.
|
|
181
|
+
* Set this to `true` and all status codes are considered a successful request. You code will then need to handle the response appropriately. Currently, only `pay-frontend` requires this to be set to `true`.
|
|
182
|
+
|
|
183
|
+
### Built in in retry functionality
|
|
184
|
+
|
|
185
|
+
If a `GET` request provides a response with the error message `ECONNRESET` - the the Axios base client will automatically try that request another 2 times - 3 times in total.
|
|
186
|
+
|
|
187
|
+
By default, on each failed request, it will call the `onFailureResponse` callback.
|
|
188
|
+
|
|
189
|
+
If `acceptAllStatusCodes=true`, then it will call the `onSuccessResponse` callback.
|
|
174
190
|
|
|
175
191
|
## Releasing
|
|
176
192
|
|
|
@@ -1,4 +1,153 @@
|
|
|
1
1
|
(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
|
|
2
|
+
/*! js-cookie v3.0.5 | MIT */
|
|
3
|
+
;
|
|
4
|
+
(function (global, factory) {
|
|
5
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
|
6
|
+
typeof define === 'function' && define.amd ? define(factory) :
|
|
7
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, (function () {
|
|
8
|
+
var current = global.Cookies;
|
|
9
|
+
var exports = global.Cookies = factory();
|
|
10
|
+
exports.noConflict = function () { global.Cookies = current; return exports; };
|
|
11
|
+
})());
|
|
12
|
+
})(this, (function () { 'use strict';
|
|
13
|
+
|
|
14
|
+
/* eslint-disable no-var */
|
|
15
|
+
function assign (target) {
|
|
16
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
17
|
+
var source = arguments[i];
|
|
18
|
+
for (var key in source) {
|
|
19
|
+
target[key] = source[key];
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return target
|
|
23
|
+
}
|
|
24
|
+
/* eslint-enable no-var */
|
|
25
|
+
|
|
26
|
+
/* eslint-disable no-var */
|
|
27
|
+
var defaultConverter = {
|
|
28
|
+
read: function (value) {
|
|
29
|
+
if (value[0] === '"') {
|
|
30
|
+
value = value.slice(1, -1);
|
|
31
|
+
}
|
|
32
|
+
return value.replace(/(%[\dA-F]{2})+/gi, decodeURIComponent)
|
|
33
|
+
},
|
|
34
|
+
write: function (value) {
|
|
35
|
+
return encodeURIComponent(value).replace(
|
|
36
|
+
/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,
|
|
37
|
+
decodeURIComponent
|
|
38
|
+
)
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
/* eslint-enable no-var */
|
|
42
|
+
|
|
43
|
+
/* eslint-disable no-var */
|
|
44
|
+
|
|
45
|
+
function init (converter, defaultAttributes) {
|
|
46
|
+
function set (name, value, attributes) {
|
|
47
|
+
if (typeof document === 'undefined') {
|
|
48
|
+
return
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
attributes = assign({}, defaultAttributes, attributes);
|
|
52
|
+
|
|
53
|
+
if (typeof attributes.expires === 'number') {
|
|
54
|
+
attributes.expires = new Date(Date.now() + attributes.expires * 864e5);
|
|
55
|
+
}
|
|
56
|
+
if (attributes.expires) {
|
|
57
|
+
attributes.expires = attributes.expires.toUTCString();
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
name = encodeURIComponent(name)
|
|
61
|
+
.replace(/%(2[346B]|5E|60|7C)/g, decodeURIComponent)
|
|
62
|
+
.replace(/[()]/g, escape);
|
|
63
|
+
|
|
64
|
+
var stringifiedAttributes = '';
|
|
65
|
+
for (var attributeName in attributes) {
|
|
66
|
+
if (!attributes[attributeName]) {
|
|
67
|
+
continue
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
stringifiedAttributes += '; ' + attributeName;
|
|
71
|
+
|
|
72
|
+
if (attributes[attributeName] === true) {
|
|
73
|
+
continue
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// Considers RFC 6265 section 5.2:
|
|
77
|
+
// ...
|
|
78
|
+
// 3. If the remaining unparsed-attributes contains a %x3B (";")
|
|
79
|
+
// character:
|
|
80
|
+
// Consume the characters of the unparsed-attributes up to,
|
|
81
|
+
// not including, the first %x3B (";") character.
|
|
82
|
+
// ...
|
|
83
|
+
stringifiedAttributes += '=' + attributes[attributeName].split(';')[0];
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return (document.cookie =
|
|
87
|
+
name + '=' + converter.write(value, name) + stringifiedAttributes)
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function get (name) {
|
|
91
|
+
if (typeof document === 'undefined' || (arguments.length && !name)) {
|
|
92
|
+
return
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// To prevent the for loop in the first place assign an empty array
|
|
96
|
+
// in case there are no cookies at all.
|
|
97
|
+
var cookies = document.cookie ? document.cookie.split('; ') : [];
|
|
98
|
+
var jar = {};
|
|
99
|
+
for (var i = 0; i < cookies.length; i++) {
|
|
100
|
+
var parts = cookies[i].split('=');
|
|
101
|
+
var value = parts.slice(1).join('=');
|
|
102
|
+
|
|
103
|
+
try {
|
|
104
|
+
var found = decodeURIComponent(parts[0]);
|
|
105
|
+
jar[found] = converter.read(value, found);
|
|
106
|
+
|
|
107
|
+
if (name === found) {
|
|
108
|
+
break
|
|
109
|
+
}
|
|
110
|
+
} catch (e) {}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
return name ? jar[name] : jar
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
return Object.create(
|
|
117
|
+
{
|
|
118
|
+
set,
|
|
119
|
+
get,
|
|
120
|
+
remove: function (name, attributes) {
|
|
121
|
+
set(
|
|
122
|
+
name,
|
|
123
|
+
'',
|
|
124
|
+
assign({}, attributes, {
|
|
125
|
+
expires: -1
|
|
126
|
+
})
|
|
127
|
+
);
|
|
128
|
+
},
|
|
129
|
+
withAttributes: function (attributes) {
|
|
130
|
+
return init(this.converter, assign({}, this.attributes, attributes))
|
|
131
|
+
},
|
|
132
|
+
withConverter: function (converter) {
|
|
133
|
+
return init(assign({}, this.converter, converter), this.attributes)
|
|
134
|
+
}
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
attributes: { value: Object.freeze(defaultAttributes) },
|
|
138
|
+
converter: { value: Object.freeze(converter) }
|
|
139
|
+
}
|
|
140
|
+
)
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
var api = init(defaultConverter, { path: '/' });
|
|
144
|
+
/* eslint-enable no-var */
|
|
145
|
+
|
|
146
|
+
return api;
|
|
147
|
+
|
|
148
|
+
}));
|
|
149
|
+
|
|
150
|
+
},{}],2:[function(require,module,exports){
|
|
2
151
|
(function (process){(function (){
|
|
3
152
|
// 'path' module extracted from Node.js v8.11.1 (only the posix part)
|
|
4
153
|
// transplited with Babel
|
|
@@ -531,156 +680,7 @@ posix.posix = posix;
|
|
|
531
680
|
module.exports = posix;
|
|
532
681
|
|
|
533
682
|
}).call(this)}).call(this,require('_process'))
|
|
534
|
-
},{"_process":3}],
|
|
535
|
-
/*! js-cookie v3.0.5 | MIT */
|
|
536
|
-
;
|
|
537
|
-
(function (global, factory) {
|
|
538
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
|
539
|
-
typeof define === 'function' && define.amd ? define(factory) :
|
|
540
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, (function () {
|
|
541
|
-
var current = global.Cookies;
|
|
542
|
-
var exports = global.Cookies = factory();
|
|
543
|
-
exports.noConflict = function () { global.Cookies = current; return exports; };
|
|
544
|
-
})());
|
|
545
|
-
})(this, (function () { 'use strict';
|
|
546
|
-
|
|
547
|
-
/* eslint-disable no-var */
|
|
548
|
-
function assign (target) {
|
|
549
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
550
|
-
var source = arguments[i];
|
|
551
|
-
for (var key in source) {
|
|
552
|
-
target[key] = source[key];
|
|
553
|
-
}
|
|
554
|
-
}
|
|
555
|
-
return target
|
|
556
|
-
}
|
|
557
|
-
/* eslint-enable no-var */
|
|
558
|
-
|
|
559
|
-
/* eslint-disable no-var */
|
|
560
|
-
var defaultConverter = {
|
|
561
|
-
read: function (value) {
|
|
562
|
-
if (value[0] === '"') {
|
|
563
|
-
value = value.slice(1, -1);
|
|
564
|
-
}
|
|
565
|
-
return value.replace(/(%[\dA-F]{2})+/gi, decodeURIComponent)
|
|
566
|
-
},
|
|
567
|
-
write: function (value) {
|
|
568
|
-
return encodeURIComponent(value).replace(
|
|
569
|
-
/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,
|
|
570
|
-
decodeURIComponent
|
|
571
|
-
)
|
|
572
|
-
}
|
|
573
|
-
};
|
|
574
|
-
/* eslint-enable no-var */
|
|
575
|
-
|
|
576
|
-
/* eslint-disable no-var */
|
|
577
|
-
|
|
578
|
-
function init (converter, defaultAttributes) {
|
|
579
|
-
function set (name, value, attributes) {
|
|
580
|
-
if (typeof document === 'undefined') {
|
|
581
|
-
return
|
|
582
|
-
}
|
|
583
|
-
|
|
584
|
-
attributes = assign({}, defaultAttributes, attributes);
|
|
585
|
-
|
|
586
|
-
if (typeof attributes.expires === 'number') {
|
|
587
|
-
attributes.expires = new Date(Date.now() + attributes.expires * 864e5);
|
|
588
|
-
}
|
|
589
|
-
if (attributes.expires) {
|
|
590
|
-
attributes.expires = attributes.expires.toUTCString();
|
|
591
|
-
}
|
|
592
|
-
|
|
593
|
-
name = encodeURIComponent(name)
|
|
594
|
-
.replace(/%(2[346B]|5E|60|7C)/g, decodeURIComponent)
|
|
595
|
-
.replace(/[()]/g, escape);
|
|
596
|
-
|
|
597
|
-
var stringifiedAttributes = '';
|
|
598
|
-
for (var attributeName in attributes) {
|
|
599
|
-
if (!attributes[attributeName]) {
|
|
600
|
-
continue
|
|
601
|
-
}
|
|
602
|
-
|
|
603
|
-
stringifiedAttributes += '; ' + attributeName;
|
|
604
|
-
|
|
605
|
-
if (attributes[attributeName] === true) {
|
|
606
|
-
continue
|
|
607
|
-
}
|
|
608
|
-
|
|
609
|
-
// Considers RFC 6265 section 5.2:
|
|
610
|
-
// ...
|
|
611
|
-
// 3. If the remaining unparsed-attributes contains a %x3B (";")
|
|
612
|
-
// character:
|
|
613
|
-
// Consume the characters of the unparsed-attributes up to,
|
|
614
|
-
// not including, the first %x3B (";") character.
|
|
615
|
-
// ...
|
|
616
|
-
stringifiedAttributes += '=' + attributes[attributeName].split(';')[0];
|
|
617
|
-
}
|
|
618
|
-
|
|
619
|
-
return (document.cookie =
|
|
620
|
-
name + '=' + converter.write(value, name) + stringifiedAttributes)
|
|
621
|
-
}
|
|
622
|
-
|
|
623
|
-
function get (name) {
|
|
624
|
-
if (typeof document === 'undefined' || (arguments.length && !name)) {
|
|
625
|
-
return
|
|
626
|
-
}
|
|
627
|
-
|
|
628
|
-
// To prevent the for loop in the first place assign an empty array
|
|
629
|
-
// in case there are no cookies at all.
|
|
630
|
-
var cookies = document.cookie ? document.cookie.split('; ') : [];
|
|
631
|
-
var jar = {};
|
|
632
|
-
for (var i = 0; i < cookies.length; i++) {
|
|
633
|
-
var parts = cookies[i].split('=');
|
|
634
|
-
var value = parts.slice(1).join('=');
|
|
635
|
-
|
|
636
|
-
try {
|
|
637
|
-
var found = decodeURIComponent(parts[0]);
|
|
638
|
-
jar[found] = converter.read(value, found);
|
|
639
|
-
|
|
640
|
-
if (name === found) {
|
|
641
|
-
break
|
|
642
|
-
}
|
|
643
|
-
} catch (e) {}
|
|
644
|
-
}
|
|
645
|
-
|
|
646
|
-
return name ? jar[name] : jar
|
|
647
|
-
}
|
|
648
|
-
|
|
649
|
-
return Object.create(
|
|
650
|
-
{
|
|
651
|
-
set,
|
|
652
|
-
get,
|
|
653
|
-
remove: function (name, attributes) {
|
|
654
|
-
set(
|
|
655
|
-
name,
|
|
656
|
-
'',
|
|
657
|
-
assign({}, attributes, {
|
|
658
|
-
expires: -1
|
|
659
|
-
})
|
|
660
|
-
);
|
|
661
|
-
},
|
|
662
|
-
withAttributes: function (attributes) {
|
|
663
|
-
return init(this.converter, assign({}, this.attributes, attributes))
|
|
664
|
-
},
|
|
665
|
-
withConverter: function (converter) {
|
|
666
|
-
return init(assign({}, this.converter, converter), this.attributes)
|
|
667
|
-
}
|
|
668
|
-
},
|
|
669
|
-
{
|
|
670
|
-
attributes: { value: Object.freeze(defaultAttributes) },
|
|
671
|
-
converter: { value: Object.freeze(converter) }
|
|
672
|
-
}
|
|
673
|
-
)
|
|
674
|
-
}
|
|
675
|
-
|
|
676
|
-
var api = init(defaultConverter, { path: '/' });
|
|
677
|
-
/* eslint-enable no-var */
|
|
678
|
-
|
|
679
|
-
return api;
|
|
680
|
-
|
|
681
|
-
}));
|
|
682
|
-
|
|
683
|
-
},{}],3:[function(require,module,exports){
|
|
683
|
+
},{"_process":3}],3:[function(require,module,exports){
|
|
684
684
|
// shim for using process in browser
|
|
685
685
|
var process = module.exports = {};
|
|
686
686
|
|
|
@@ -961,7 +961,7 @@ module.exports = {
|
|
|
961
961
|
showBannerIfConsentNotSet: showBannerIfConsentNotSet
|
|
962
962
|
};
|
|
963
963
|
|
|
964
|
-
},{"js-cookie":
|
|
964
|
+
},{"js-cookie":1,"path":2}],5:[function(require,module,exports){
|
|
965
965
|
"use strict";
|
|
966
966
|
|
|
967
967
|
var cookies = require('./cookies/validate');
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
function _typeof(
|
|
4
|
-
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
|
|
5
|
-
function asyncGeneratorStep(
|
|
6
|
-
function _asyncToGenerator(
|
|
7
|
-
function _slicedToArray(
|
|
3
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
4
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
5
|
+
function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
|
|
6
|
+
function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
|
|
7
|
+
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
8
8
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
9
|
-
function _unsupportedIterableToArray(
|
|
10
|
-
function _arrayLikeToArray(
|
|
11
|
-
function _iterableToArrayLimit(
|
|
12
|
-
function _arrayWithHoles(
|
|
13
|
-
function ownKeys(
|
|
14
|
-
function _objectSpread(
|
|
15
|
-
function _defineProperty(
|
|
16
|
-
function _classCallCheck(
|
|
17
|
-
function _defineProperties(
|
|
18
|
-
function _createClass(
|
|
19
|
-
function _toPropertyKey(
|
|
20
|
-
function _toPrimitive(
|
|
9
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
10
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
11
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
12
|
+
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
13
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
14
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
15
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
16
|
+
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
17
|
+
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
|
|
18
|
+
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
19
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
20
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
21
21
|
var http = require('http');
|
|
22
22
|
var https = require('https');
|
|
23
23
|
var axios = require('axios');
|
|
@@ -32,11 +32,11 @@ var Client = /*#__PURE__*/function () {
|
|
|
32
32
|
/**
|
|
33
33
|
* Configure the client. Should only be called once.
|
|
34
34
|
*/
|
|
35
|
-
_createClass(Client, [{
|
|
35
|
+
return _createClass(Client, [{
|
|
36
36
|
key: "configure",
|
|
37
37
|
value: function configure(baseURL, options) {
|
|
38
38
|
var _this = this;
|
|
39
|
-
|
|
39
|
+
var axiosConfigOptions = {
|
|
40
40
|
baseURL: baseURL,
|
|
41
41
|
timeout: 60 * 1000,
|
|
42
42
|
maxContentLength: 50 * 1000 * 1000,
|
|
@@ -49,9 +49,15 @@ var Client = /*#__PURE__*/function () {
|
|
|
49
49
|
}),
|
|
50
50
|
headers: {
|
|
51
51
|
'Content-Type': 'application/json',
|
|
52
|
-
|
|
52
|
+
Accept: 'application/json'
|
|
53
53
|
}
|
|
54
|
-
}
|
|
54
|
+
};
|
|
55
|
+
if (options.acceptAllStatusCodes) {
|
|
56
|
+
axiosConfigOptions.validateStatus = function (status) {
|
|
57
|
+
return status;
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
this._axios = axios.create(axiosConfigOptions);
|
|
55
61
|
this._axios.interceptors.request.use(function (config) {
|
|
56
62
|
var requestContext = _objectSpread({
|
|
57
63
|
service: _this._app,
|
|
@@ -78,54 +84,95 @@ var Client = /*#__PURE__*/function () {
|
|
|
78
84
|
}
|
|
79
85
|
});
|
|
80
86
|
});
|
|
81
|
-
this._axios.interceptors.response.use(function (
|
|
82
|
-
var
|
|
83
|
-
|
|
84
|
-
responseTime: Date.now() - response.config.metadata.start,
|
|
85
|
-
method: response.config.method,
|
|
86
|
-
params: response.config.params,
|
|
87
|
-
status: response.status,
|
|
88
|
-
url: response.config.url,
|
|
89
|
-
description: response.config.description,
|
|
90
|
-
additionalLoggingFields: response.config.additionalLoggingFields
|
|
91
|
-
};
|
|
92
|
-
if (options.onSuccessResponse) {
|
|
93
|
-
options.onSuccessResponse(responseContext);
|
|
94
|
-
}
|
|
95
|
-
return response;
|
|
96
|
-
}, /*#__PURE__*/function () {
|
|
97
|
-
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(error) {
|
|
98
|
-
var config, errors, errorContext, retryCount;
|
|
87
|
+
this._axios.interceptors.response.use( /*#__PURE__*/function () {
|
|
88
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(response) {
|
|
89
|
+
var responseContext, retryCount;
|
|
99
90
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
100
91
|
while (1) switch (_context.prev = _context.next) {
|
|
92
|
+
case 0:
|
|
93
|
+
responseContext = {
|
|
94
|
+
service: _this._app,
|
|
95
|
+
responseTime: Date.now() - response.config.metadata.start,
|
|
96
|
+
method: response.config.method,
|
|
97
|
+
params: response.config.params,
|
|
98
|
+
status: response.status,
|
|
99
|
+
url: response.config.url,
|
|
100
|
+
description: response.config.description,
|
|
101
|
+
additionalLoggingFields: response.config.additionalLoggingFields,
|
|
102
|
+
code: response.status,
|
|
103
|
+
errorIdentifier: response.data && response.data.error_identifier ? response.data.error_identifier : null,
|
|
104
|
+
reason: response.data && response.data.reason ? response.data.reason : null,
|
|
105
|
+
message: response.data && response.data.message ? response.data.message : null
|
|
106
|
+
};
|
|
107
|
+
if (!(response.config.method === 'get' && response.data.code === 'ECONNRESET')) {
|
|
108
|
+
_context.next = 9;
|
|
109
|
+
break;
|
|
110
|
+
}
|
|
111
|
+
retryCount = response.config.retryCount || 0;
|
|
112
|
+
if (!(retryCount < 2)) {
|
|
113
|
+
_context.next = 9;
|
|
114
|
+
break;
|
|
115
|
+
}
|
|
116
|
+
response.config.retryCount = retryCount + 1;
|
|
117
|
+
if (options.onSuccessResponse) {
|
|
118
|
+
options.onSuccessResponse(responseContext);
|
|
119
|
+
}
|
|
120
|
+
_context.next = 8;
|
|
121
|
+
return new Promise(function (resolve) {
|
|
122
|
+
return setTimeout(resolve, 500);
|
|
123
|
+
});
|
|
124
|
+
case 8:
|
|
125
|
+
return _context.abrupt("return", _this._axios(response.config));
|
|
126
|
+
case 9:
|
|
127
|
+
if (options.onSuccessResponse) {
|
|
128
|
+
options.onSuccessResponse(responseContext);
|
|
129
|
+
}
|
|
130
|
+
return _context.abrupt("return", response);
|
|
131
|
+
case 11:
|
|
132
|
+
case "end":
|
|
133
|
+
return _context.stop();
|
|
134
|
+
}
|
|
135
|
+
}, _callee);
|
|
136
|
+
}));
|
|
137
|
+
return function (_x) {
|
|
138
|
+
return _ref3.apply(this, arguments);
|
|
139
|
+
};
|
|
140
|
+
}(), /*#__PURE__*/function () {
|
|
141
|
+
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(error) {
|
|
142
|
+
var config, message, errorContext, errorCode, retryCount;
|
|
143
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
144
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
101
145
|
case 0:
|
|
102
146
|
config = error.config || {};
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
147
|
+
if (error.response && error.response.data && error.response.data.errors) {
|
|
148
|
+
message = error.response.data.errors.join(', ');
|
|
149
|
+
} else if (error.response && error.response.data && error.response.data.message) {
|
|
150
|
+
message = error.response.data.message;
|
|
151
|
+
} else {
|
|
152
|
+
message = 'Unknown error';
|
|
106
153
|
}
|
|
107
154
|
errorContext = {
|
|
108
155
|
service: _this._app,
|
|
109
156
|
responseTime: Date.now() - (config.metadata && config.metadata.start),
|
|
110
157
|
method: config.method,
|
|
111
|
-
|
|
112
|
-
status: error.response && error.response.status,
|
|
158
|
+
status: error.response && error.response.status || error.status,
|
|
113
159
|
url: config.url,
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
160
|
+
params: config.params,
|
|
161
|
+
code: error.response && error.response.data && error.response.data.code || error.code,
|
|
162
|
+
message: message,
|
|
163
|
+
reason: error.response && error.response.data && error.response.data.reason || 'Unknown reason',
|
|
118
164
|
description: config.description,
|
|
119
|
-
additionalLoggingFields: config.additionalLoggingFields
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
165
|
+
additionalLoggingFields: config.additionalLoggingFields,
|
|
166
|
+
errorIdentifier: error.response && error.response.data && error.response.data.error_identifier
|
|
167
|
+
};
|
|
168
|
+
errorCode = error.response && error.response.data && error.response.data.code;
|
|
169
|
+
if (!(config.method === 'get' && errorCode === 'ECONNRESET')) {
|
|
170
|
+
_context2.next = 12;
|
|
124
171
|
break;
|
|
125
172
|
}
|
|
126
173
|
retryCount = config.retryCount || 0;
|
|
127
174
|
if (!(retryCount < 2)) {
|
|
128
|
-
|
|
175
|
+
_context2.next = 12;
|
|
129
176
|
break;
|
|
130
177
|
}
|
|
131
178
|
config.retryCount = retryCount + 1;
|
|
@@ -133,12 +180,12 @@ var Client = /*#__PURE__*/function () {
|
|
|
133
180
|
errorContext.retry = true;
|
|
134
181
|
options.onFailureResponse(errorContext);
|
|
135
182
|
}
|
|
136
|
-
|
|
183
|
+
_context2.next = 11;
|
|
137
184
|
return new Promise(function (resolve) {
|
|
138
185
|
return setTimeout(resolve, 500);
|
|
139
186
|
});
|
|
140
187
|
case 11:
|
|
141
|
-
return
|
|
188
|
+
return _context2.abrupt("return", _this._axios(config));
|
|
142
189
|
case 12:
|
|
143
190
|
if (options.onFailureResponse) {
|
|
144
191
|
options.onFailureResponse(errorContext);
|
|
@@ -146,12 +193,12 @@ var Client = /*#__PURE__*/function () {
|
|
|
146
193
|
throw new RESTClientError(errorContext.message, errorContext.service, errorContext.status, errorContext.errorIdentifier, errorContext.reason);
|
|
147
194
|
case 14:
|
|
148
195
|
case "end":
|
|
149
|
-
return
|
|
196
|
+
return _context2.stop();
|
|
150
197
|
}
|
|
151
|
-
},
|
|
198
|
+
}, _callee2);
|
|
152
199
|
}));
|
|
153
200
|
return function (_x2) {
|
|
154
|
-
return
|
|
201
|
+
return _ref4.apply(this, arguments);
|
|
155
202
|
};
|
|
156
203
|
}());
|
|
157
204
|
}
|
|
@@ -190,7 +237,6 @@ var Client = /*#__PURE__*/function () {
|
|
|
190
237
|
return this._axios.delete(url, this._getConfigWithDescription(config, description));
|
|
191
238
|
}
|
|
192
239
|
}]);
|
|
193
|
-
return Client;
|
|
194
240
|
}();
|
|
195
241
|
module.exports = {
|
|
196
242
|
Client: Client
|
|
@@ -1,28 +1,26 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
function _typeof(
|
|
4
|
-
function _defineProperties(
|
|
5
|
-
function _createClass(
|
|
6
|
-
function _toPropertyKey(
|
|
7
|
-
function _toPrimitive(
|
|
8
|
-
function _classCallCheck(
|
|
9
|
-
function
|
|
10
|
-
function
|
|
11
|
-
function
|
|
12
|
-
function
|
|
13
|
-
function _wrapNativeSuper(
|
|
14
|
-
function _construct(
|
|
15
|
-
function _isNativeReflectConstruct() {
|
|
16
|
-
function _isNativeFunction(
|
|
17
|
-
function _setPrototypeOf(
|
|
18
|
-
function _getPrototypeOf(
|
|
3
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
4
|
+
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
|
|
5
|
+
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
6
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
7
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
8
|
+
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
9
|
+
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
10
|
+
function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
|
|
11
|
+
function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
|
|
12
|
+
function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }
|
|
13
|
+
function _wrapNativeSuper(t) { var r = "function" == typeof Map ? new Map() : void 0; return _wrapNativeSuper = function _wrapNativeSuper(t) { if (null === t || !_isNativeFunction(t)) return t; if ("function" != typeof t) throw new TypeError("Super expression must either be null or a function"); if (void 0 !== r) { if (r.has(t)) return r.get(t); r.set(t, Wrapper); } function Wrapper() { return _construct(t, arguments, _getPrototypeOf(this).constructor); } return Wrapper.prototype = Object.create(t.prototype, { constructor: { value: Wrapper, enumerable: !1, writable: !0, configurable: !0 } }), _setPrototypeOf(Wrapper, t); }, _wrapNativeSuper(t); }
|
|
14
|
+
function _construct(t, e, r) { if (_isNativeReflectConstruct()) return Reflect.construct.apply(null, arguments); var o = [null]; o.push.apply(o, e); var p = new (t.bind.apply(t, o))(); return r && _setPrototypeOf(p, r.prototype), p; }
|
|
15
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
16
|
+
function _isNativeFunction(t) { try { return -1 !== Function.toString.call(t).indexOf("[native code]"); } catch (n) { return "function" == typeof t; } }
|
|
17
|
+
function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
|
|
18
|
+
function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
|
|
19
19
|
var RESTClientError = /*#__PURE__*/function (_Error) {
|
|
20
|
-
_inherits(RESTClientError, _Error);
|
|
21
|
-
var _super = _createSuper(RESTClientError);
|
|
22
20
|
function RESTClientError(message, service, errorCode, errorIdentifier, reason) {
|
|
23
21
|
var _this;
|
|
24
22
|
_classCallCheck(this, RESTClientError);
|
|
25
|
-
_this =
|
|
23
|
+
_this = _callSuper(this, RESTClientError, [message]);
|
|
26
24
|
_this.name = _this.constructor.name;
|
|
27
25
|
_this.service = service;
|
|
28
26
|
_this.errorCode = errorCode;
|
|
@@ -30,55 +28,51 @@ var RESTClientError = /*#__PURE__*/function (_Error) {
|
|
|
30
28
|
_this.reason = reason;
|
|
31
29
|
return _this;
|
|
32
30
|
}
|
|
31
|
+
_inherits(RESTClientError, _Error);
|
|
33
32
|
return _createClass(RESTClientError);
|
|
34
33
|
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
35
34
|
var DomainError = /*#__PURE__*/function (_Error2) {
|
|
36
|
-
_inherits(DomainError, _Error2);
|
|
37
|
-
var _super2 = _createSuper(DomainError);
|
|
38
35
|
function DomainError(message) {
|
|
39
36
|
var _this2;
|
|
40
37
|
_classCallCheck(this, DomainError);
|
|
41
|
-
_this2 =
|
|
38
|
+
_this2 = _callSuper(this, DomainError, [message]);
|
|
42
39
|
_this2.name = _this2.constructor.name;
|
|
43
|
-
Error.captureStackTrace(
|
|
40
|
+
Error.captureStackTrace(_this2, _this2.constructor);
|
|
44
41
|
return _this2;
|
|
45
42
|
}
|
|
43
|
+
_inherits(DomainError, _Error2);
|
|
46
44
|
return _createClass(DomainError);
|
|
47
45
|
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
48
46
|
var NotFoundError = /*#__PURE__*/function (_DomainError) {
|
|
49
|
-
_inherits(NotFoundError, _DomainError);
|
|
50
|
-
var _super3 = _createSuper(NotFoundError);
|
|
51
47
|
function NotFoundError() {
|
|
52
48
|
_classCallCheck(this, NotFoundError);
|
|
53
|
-
return
|
|
49
|
+
return _callSuper(this, NotFoundError, arguments);
|
|
54
50
|
}
|
|
51
|
+
_inherits(NotFoundError, _DomainError);
|
|
55
52
|
return _createClass(NotFoundError);
|
|
56
53
|
}(DomainError);
|
|
57
54
|
var AccountCannotTakePaymentsError = /*#__PURE__*/function (_DomainError2) {
|
|
58
|
-
_inherits(AccountCannotTakePaymentsError, _DomainError2);
|
|
59
|
-
var _super4 = _createSuper(AccountCannotTakePaymentsError);
|
|
60
55
|
function AccountCannotTakePaymentsError() {
|
|
61
56
|
_classCallCheck(this, AccountCannotTakePaymentsError);
|
|
62
|
-
return
|
|
57
|
+
return _callSuper(this, AccountCannotTakePaymentsError, arguments);
|
|
63
58
|
}
|
|
59
|
+
_inherits(AccountCannotTakePaymentsError, _DomainError2);
|
|
64
60
|
return _createClass(AccountCannotTakePaymentsError);
|
|
65
61
|
}(DomainError);
|
|
66
62
|
var InvalidPrefilledAmountError = /*#__PURE__*/function (_DomainError3) {
|
|
67
|
-
_inherits(InvalidPrefilledAmountError, _DomainError3);
|
|
68
|
-
var _super5 = _createSuper(InvalidPrefilledAmountError);
|
|
69
63
|
function InvalidPrefilledAmountError() {
|
|
70
64
|
_classCallCheck(this, InvalidPrefilledAmountError);
|
|
71
|
-
return
|
|
65
|
+
return _callSuper(this, InvalidPrefilledAmountError, arguments);
|
|
72
66
|
}
|
|
67
|
+
_inherits(InvalidPrefilledAmountError, _DomainError3);
|
|
73
68
|
return _createClass(InvalidPrefilledAmountError);
|
|
74
69
|
}(DomainError);
|
|
75
70
|
var InvalidPrefilledReferenceError = /*#__PURE__*/function (_DomainError4) {
|
|
76
|
-
_inherits(InvalidPrefilledReferenceError, _DomainError4);
|
|
77
|
-
var _super6 = _createSuper(InvalidPrefilledReferenceError);
|
|
78
71
|
function InvalidPrefilledReferenceError() {
|
|
79
72
|
_classCallCheck(this, InvalidPrefilledReferenceError);
|
|
80
|
-
return
|
|
73
|
+
return _callSuper(this, InvalidPrefilledReferenceError, arguments);
|
|
81
74
|
}
|
|
75
|
+
_inherits(InvalidPrefilledReferenceError, _DomainError4);
|
|
82
76
|
return _createClass(InvalidPrefilledReferenceError);
|
|
83
77
|
}(DomainError);
|
|
84
78
|
module.exports = {
|