@nhost/nhost-js 0.3.3 → 0.3.7
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/LICENSE +21 -0
- package/README.md +4 -4
- package/dist/{cjs/clients → clients}/functions.d.ts +2 -2
- package/dist/{esm/clients → clients}/graphql.d.ts +2 -2
- package/dist/{cjs/core → core}/index.d.ts +0 -0
- package/dist/{esm/core → core}/nhost-client.d.ts +3 -12
- package/dist/index.d.ts +4 -0
- package/dist/index.es.js +4507 -0
- package/dist/index.umd.js +4 -0
- package/dist/{cjs/types.d.ts → types.d.ts} +5 -5
- package/package.json +45 -33
- package/src/index.ts +6 -0
- package/dist/cjs/clients/functions.js +0 -113
- package/dist/cjs/clients/functions.js.map +0 -1
- package/dist/cjs/clients/graphql.d.ts +0 -15
- package/dist/cjs/clients/graphql.js +0 -133
- package/dist/cjs/clients/graphql.js.map +0 -1
- package/dist/cjs/core/index.js +0 -14
- package/dist/cjs/core/index.js.map +0 -1
- package/dist/cjs/core/nhost-client.d.ts +0 -28
- package/dist/cjs/core/nhost-client.js +0 -59
- package/dist/cjs/core/nhost-client.js.map +0 -1
- package/dist/cjs/index.d.ts +0 -1
- package/dist/cjs/index.js +0 -14
- package/dist/cjs/index.js.map +0 -1
- package/dist/cjs/types.js +0 -3
- package/dist/cjs/types.js.map +0 -1
- package/dist/esm/clients/functions.d.ts +0 -13
- package/dist/esm/clients/functions.js +0 -107
- package/dist/esm/clients/functions.js.map +0 -1
- package/dist/esm/clients/graphql.js +0 -127
- package/dist/esm/clients/graphql.js.map +0 -1
- package/dist/esm/core/index.d.ts +0 -1
- package/dist/esm/core/index.js +0 -2
- package/dist/esm/core/index.js.map +0 -1
- package/dist/esm/core/nhost-client.js +0 -56
- package/dist/esm/core/nhost-client.js.map +0 -1
- package/dist/esm/index.d.ts +0 -1
- package/dist/esm/index.js +0 -2
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/types.d.ts +0 -19
- package/dist/esm/types.js +0 -2
- package/dist/esm/types.js.map +0 -1
package/dist/index.es.js
ADDED
|
@@ -0,0 +1,4507 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
var __defProp$1 = Object.defineProperty;
|
|
21
|
+
var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
|
|
22
|
+
var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
|
|
23
|
+
var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
|
|
24
|
+
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
25
|
+
var __spreadValues$1 = (a, b) => {
|
|
26
|
+
for (var prop in b || (b = {}))
|
|
27
|
+
if (__hasOwnProp$1.call(b, prop))
|
|
28
|
+
__defNormalProp$1(a, prop, b[prop]);
|
|
29
|
+
if (__getOwnPropSymbols$1)
|
|
30
|
+
for (var prop of __getOwnPropSymbols$1(b)) {
|
|
31
|
+
if (__propIsEnum$1.call(b, prop))
|
|
32
|
+
__defNormalProp$1(a, prop, b[prop]);
|
|
33
|
+
}
|
|
34
|
+
return a;
|
|
35
|
+
};
|
|
36
|
+
var axios$2$2 = { exports: {} };
|
|
37
|
+
var bind$2$2 = function bind(fn, thisArg) {
|
|
38
|
+
return function wrap() {
|
|
39
|
+
var args = new Array(arguments.length);
|
|
40
|
+
for (var i = 0; i < args.length; i++) {
|
|
41
|
+
args[i] = arguments[i];
|
|
42
|
+
}
|
|
43
|
+
return fn.apply(thisArg, args);
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
var bind$1$2 = bind$2$2;
|
|
47
|
+
var toString$2 = Object.prototype.toString;
|
|
48
|
+
function isArray$2(val) {
|
|
49
|
+
return Array.isArray(val);
|
|
50
|
+
}
|
|
51
|
+
function isUndefined$2(val) {
|
|
52
|
+
return typeof val === "undefined";
|
|
53
|
+
}
|
|
54
|
+
function isBuffer$2(val) {
|
|
55
|
+
return val !== null && !isUndefined$2(val) && val.constructor !== null && !isUndefined$2(val.constructor) && typeof val.constructor.isBuffer === "function" && val.constructor.isBuffer(val);
|
|
56
|
+
}
|
|
57
|
+
function isArrayBuffer$2(val) {
|
|
58
|
+
return toString$2.call(val) === "[object ArrayBuffer]";
|
|
59
|
+
}
|
|
60
|
+
function isFormData$2(val) {
|
|
61
|
+
return toString$2.call(val) === "[object FormData]";
|
|
62
|
+
}
|
|
63
|
+
function isArrayBufferView$2(val) {
|
|
64
|
+
var result;
|
|
65
|
+
if (typeof ArrayBuffer !== "undefined" && ArrayBuffer.isView) {
|
|
66
|
+
result = ArrayBuffer.isView(val);
|
|
67
|
+
} else {
|
|
68
|
+
result = val && val.buffer && isArrayBuffer$2(val.buffer);
|
|
69
|
+
}
|
|
70
|
+
return result;
|
|
71
|
+
}
|
|
72
|
+
function isString$2(val) {
|
|
73
|
+
return typeof val === "string";
|
|
74
|
+
}
|
|
75
|
+
function isNumber$2(val) {
|
|
76
|
+
return typeof val === "number";
|
|
77
|
+
}
|
|
78
|
+
function isObject$2(val) {
|
|
79
|
+
return val !== null && typeof val === "object";
|
|
80
|
+
}
|
|
81
|
+
function isPlainObject$2(val) {
|
|
82
|
+
if (toString$2.call(val) !== "[object Object]") {
|
|
83
|
+
return false;
|
|
84
|
+
}
|
|
85
|
+
var prototype = Object.getPrototypeOf(val);
|
|
86
|
+
return prototype === null || prototype === Object.prototype;
|
|
87
|
+
}
|
|
88
|
+
function isDate$2(val) {
|
|
89
|
+
return toString$2.call(val) === "[object Date]";
|
|
90
|
+
}
|
|
91
|
+
function isFile$2(val) {
|
|
92
|
+
return toString$2.call(val) === "[object File]";
|
|
93
|
+
}
|
|
94
|
+
function isBlob$2(val) {
|
|
95
|
+
return toString$2.call(val) === "[object Blob]";
|
|
96
|
+
}
|
|
97
|
+
function isFunction$2(val) {
|
|
98
|
+
return toString$2.call(val) === "[object Function]";
|
|
99
|
+
}
|
|
100
|
+
function isStream$2(val) {
|
|
101
|
+
return isObject$2(val) && isFunction$2(val.pipe);
|
|
102
|
+
}
|
|
103
|
+
function isURLSearchParams$2(val) {
|
|
104
|
+
return toString$2.call(val) === "[object URLSearchParams]";
|
|
105
|
+
}
|
|
106
|
+
function trim$2(str) {
|
|
107
|
+
return str.trim ? str.trim() : str.replace(/^\s+|\s+$/g, "");
|
|
108
|
+
}
|
|
109
|
+
function isStandardBrowserEnv$2() {
|
|
110
|
+
if (typeof navigator !== "undefined" && (navigator.product === "ReactNative" || navigator.product === "NativeScript" || navigator.product === "NS")) {
|
|
111
|
+
return false;
|
|
112
|
+
}
|
|
113
|
+
return typeof window !== "undefined" && typeof document !== "undefined";
|
|
114
|
+
}
|
|
115
|
+
function forEach$2(obj, fn) {
|
|
116
|
+
if (obj === null || typeof obj === "undefined") {
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
if (typeof obj !== "object") {
|
|
120
|
+
obj = [obj];
|
|
121
|
+
}
|
|
122
|
+
if (isArray$2(obj)) {
|
|
123
|
+
for (var i = 0, l = obj.length; i < l; i++) {
|
|
124
|
+
fn.call(null, obj[i], i, obj);
|
|
125
|
+
}
|
|
126
|
+
} else {
|
|
127
|
+
for (var key in obj) {
|
|
128
|
+
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
129
|
+
fn.call(null, obj[key], key, obj);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
function merge$2() {
|
|
135
|
+
var result = {};
|
|
136
|
+
function assignValue(val, key) {
|
|
137
|
+
if (isPlainObject$2(result[key]) && isPlainObject$2(val)) {
|
|
138
|
+
result[key] = merge$2(result[key], val);
|
|
139
|
+
} else if (isPlainObject$2(val)) {
|
|
140
|
+
result[key] = merge$2({}, val);
|
|
141
|
+
} else if (isArray$2(val)) {
|
|
142
|
+
result[key] = val.slice();
|
|
143
|
+
} else {
|
|
144
|
+
result[key] = val;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
for (var i = 0, l = arguments.length; i < l; i++) {
|
|
148
|
+
forEach$2(arguments[i], assignValue);
|
|
149
|
+
}
|
|
150
|
+
return result;
|
|
151
|
+
}
|
|
152
|
+
function extend$2(a, b, thisArg) {
|
|
153
|
+
forEach$2(b, function assignValue(val, key) {
|
|
154
|
+
if (thisArg && typeof val === "function") {
|
|
155
|
+
a[key] = bind$1$2(val, thisArg);
|
|
156
|
+
} else {
|
|
157
|
+
a[key] = val;
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
return a;
|
|
161
|
+
}
|
|
162
|
+
function stripBOM$2(content) {
|
|
163
|
+
if (content.charCodeAt(0) === 65279) {
|
|
164
|
+
content = content.slice(1);
|
|
165
|
+
}
|
|
166
|
+
return content;
|
|
167
|
+
}
|
|
168
|
+
var utils$e$1 = {
|
|
169
|
+
isArray: isArray$2,
|
|
170
|
+
isArrayBuffer: isArrayBuffer$2,
|
|
171
|
+
isBuffer: isBuffer$2,
|
|
172
|
+
isFormData: isFormData$2,
|
|
173
|
+
isArrayBufferView: isArrayBufferView$2,
|
|
174
|
+
isString: isString$2,
|
|
175
|
+
isNumber: isNumber$2,
|
|
176
|
+
isObject: isObject$2,
|
|
177
|
+
isPlainObject: isPlainObject$2,
|
|
178
|
+
isUndefined: isUndefined$2,
|
|
179
|
+
isDate: isDate$2,
|
|
180
|
+
isFile: isFile$2,
|
|
181
|
+
isBlob: isBlob$2,
|
|
182
|
+
isFunction: isFunction$2,
|
|
183
|
+
isStream: isStream$2,
|
|
184
|
+
isURLSearchParams: isURLSearchParams$2,
|
|
185
|
+
isStandardBrowserEnv: isStandardBrowserEnv$2,
|
|
186
|
+
forEach: forEach$2,
|
|
187
|
+
merge: merge$2,
|
|
188
|
+
extend: extend$2,
|
|
189
|
+
trim: trim$2,
|
|
190
|
+
stripBOM: stripBOM$2
|
|
191
|
+
};
|
|
192
|
+
var utils$d$2 = utils$e$1;
|
|
193
|
+
function encode$2(val) {
|
|
194
|
+
return encodeURIComponent(val).replace(/%3A/gi, ":").replace(/%24/g, "$").replace(/%2C/gi, ",").replace(/%20/g, "+").replace(/%5B/gi, "[").replace(/%5D/gi, "]");
|
|
195
|
+
}
|
|
196
|
+
var buildURL$2$2 = function buildURL(url, params, paramsSerializer) {
|
|
197
|
+
if (!params) {
|
|
198
|
+
return url;
|
|
199
|
+
}
|
|
200
|
+
var serializedParams;
|
|
201
|
+
if (paramsSerializer) {
|
|
202
|
+
serializedParams = paramsSerializer(params);
|
|
203
|
+
} else if (utils$d$2.isURLSearchParams(params)) {
|
|
204
|
+
serializedParams = params.toString();
|
|
205
|
+
} else {
|
|
206
|
+
var parts = [];
|
|
207
|
+
utils$d$2.forEach(params, function serialize(val, key) {
|
|
208
|
+
if (val === null || typeof val === "undefined") {
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
211
|
+
if (utils$d$2.isArray(val)) {
|
|
212
|
+
key = key + "[]";
|
|
213
|
+
} else {
|
|
214
|
+
val = [val];
|
|
215
|
+
}
|
|
216
|
+
utils$d$2.forEach(val, function parseValue(v) {
|
|
217
|
+
if (utils$d$2.isDate(v)) {
|
|
218
|
+
v = v.toISOString();
|
|
219
|
+
} else if (utils$d$2.isObject(v)) {
|
|
220
|
+
v = JSON.stringify(v);
|
|
221
|
+
}
|
|
222
|
+
parts.push(encode$2(key) + "=" + encode$2(v));
|
|
223
|
+
});
|
|
224
|
+
});
|
|
225
|
+
serializedParams = parts.join("&");
|
|
226
|
+
}
|
|
227
|
+
if (serializedParams) {
|
|
228
|
+
var hashmarkIndex = url.indexOf("#");
|
|
229
|
+
if (hashmarkIndex !== -1) {
|
|
230
|
+
url = url.slice(0, hashmarkIndex);
|
|
231
|
+
}
|
|
232
|
+
url += (url.indexOf("?") === -1 ? "?" : "&") + serializedParams;
|
|
233
|
+
}
|
|
234
|
+
return url;
|
|
235
|
+
};
|
|
236
|
+
var utils$c$2 = utils$e$1;
|
|
237
|
+
function InterceptorManager$1$2() {
|
|
238
|
+
this.handlers = [];
|
|
239
|
+
}
|
|
240
|
+
InterceptorManager$1$2.prototype.use = function use(fulfilled, rejected, options) {
|
|
241
|
+
this.handlers.push({
|
|
242
|
+
fulfilled,
|
|
243
|
+
rejected,
|
|
244
|
+
synchronous: options ? options.synchronous : false,
|
|
245
|
+
runWhen: options ? options.runWhen : null
|
|
246
|
+
});
|
|
247
|
+
return this.handlers.length - 1;
|
|
248
|
+
};
|
|
249
|
+
InterceptorManager$1$2.prototype.eject = function eject(id) {
|
|
250
|
+
if (this.handlers[id]) {
|
|
251
|
+
this.handlers[id] = null;
|
|
252
|
+
}
|
|
253
|
+
};
|
|
254
|
+
InterceptorManager$1$2.prototype.forEach = function forEach2(fn) {
|
|
255
|
+
utils$c$2.forEach(this.handlers, function forEachHandler(h) {
|
|
256
|
+
if (h !== null) {
|
|
257
|
+
fn(h);
|
|
258
|
+
}
|
|
259
|
+
});
|
|
260
|
+
};
|
|
261
|
+
var InterceptorManager_1$2 = InterceptorManager$1$2;
|
|
262
|
+
var utils$b$2 = utils$e$1;
|
|
263
|
+
var normalizeHeaderName$1$2 = function normalizeHeaderName(headers, normalizedName) {
|
|
264
|
+
utils$b$2.forEach(headers, function processHeader(value, name2) {
|
|
265
|
+
if (name2 !== normalizedName && name2.toUpperCase() === normalizedName.toUpperCase()) {
|
|
266
|
+
headers[normalizedName] = value;
|
|
267
|
+
delete headers[name2];
|
|
268
|
+
}
|
|
269
|
+
});
|
|
270
|
+
};
|
|
271
|
+
var enhanceError$2$2 = function enhanceError(error, config, code, request22, response) {
|
|
272
|
+
error.config = config;
|
|
273
|
+
if (code) {
|
|
274
|
+
error.code = code;
|
|
275
|
+
}
|
|
276
|
+
error.request = request22;
|
|
277
|
+
error.response = response;
|
|
278
|
+
error.isAxiosError = true;
|
|
279
|
+
error.toJSON = function toJSON() {
|
|
280
|
+
return {
|
|
281
|
+
message: this.message,
|
|
282
|
+
name: this.name,
|
|
283
|
+
description: this.description,
|
|
284
|
+
number: this.number,
|
|
285
|
+
fileName: this.fileName,
|
|
286
|
+
lineNumber: this.lineNumber,
|
|
287
|
+
columnNumber: this.columnNumber,
|
|
288
|
+
stack: this.stack,
|
|
289
|
+
config: this.config,
|
|
290
|
+
code: this.code,
|
|
291
|
+
status: this.response && this.response.status ? this.response.status : null
|
|
292
|
+
};
|
|
293
|
+
};
|
|
294
|
+
return error;
|
|
295
|
+
};
|
|
296
|
+
var enhanceError$1$2 = enhanceError$2$2;
|
|
297
|
+
var createError$2$2 = function createError(message, config, code, request22, response) {
|
|
298
|
+
var error = new Error(message);
|
|
299
|
+
return enhanceError$1$2(error, config, code, request22, response);
|
|
300
|
+
};
|
|
301
|
+
var createError$1$2 = createError$2$2;
|
|
302
|
+
var settle$1$2 = function settle(resolve, reject, response) {
|
|
303
|
+
var validateStatus22 = response.config.validateStatus;
|
|
304
|
+
if (!response.status || !validateStatus22 || validateStatus22(response.status)) {
|
|
305
|
+
resolve(response);
|
|
306
|
+
} else {
|
|
307
|
+
reject(createError$1$2("Request failed with status code " + response.status, response.config, null, response.request, response));
|
|
308
|
+
}
|
|
309
|
+
};
|
|
310
|
+
var utils$a$2 = utils$e$1;
|
|
311
|
+
var cookies$1$2 = utils$a$2.isStandardBrowserEnv() ? function standardBrowserEnv() {
|
|
312
|
+
return {
|
|
313
|
+
write: function write(name2, value, expires, path, domain, secure) {
|
|
314
|
+
var cookie = [];
|
|
315
|
+
cookie.push(name2 + "=" + encodeURIComponent(value));
|
|
316
|
+
if (utils$a$2.isNumber(expires)) {
|
|
317
|
+
cookie.push("expires=" + new Date(expires).toGMTString());
|
|
318
|
+
}
|
|
319
|
+
if (utils$a$2.isString(path)) {
|
|
320
|
+
cookie.push("path=" + path);
|
|
321
|
+
}
|
|
322
|
+
if (utils$a$2.isString(domain)) {
|
|
323
|
+
cookie.push("domain=" + domain);
|
|
324
|
+
}
|
|
325
|
+
if (secure === true) {
|
|
326
|
+
cookie.push("secure");
|
|
327
|
+
}
|
|
328
|
+
document.cookie = cookie.join("; ");
|
|
329
|
+
},
|
|
330
|
+
read: function read(name2) {
|
|
331
|
+
var match = document.cookie.match(new RegExp("(^|;\\s*)(" + name2 + ")=([^;]*)"));
|
|
332
|
+
return match ? decodeURIComponent(match[3]) : null;
|
|
333
|
+
},
|
|
334
|
+
remove: function remove(name2) {
|
|
335
|
+
this.write(name2, "", Date.now() - 864e5);
|
|
336
|
+
}
|
|
337
|
+
};
|
|
338
|
+
}() : function nonStandardBrowserEnv() {
|
|
339
|
+
return {
|
|
340
|
+
write: function write() {
|
|
341
|
+
},
|
|
342
|
+
read: function read() {
|
|
343
|
+
return null;
|
|
344
|
+
},
|
|
345
|
+
remove: function remove() {
|
|
346
|
+
}
|
|
347
|
+
};
|
|
348
|
+
}();
|
|
349
|
+
var isAbsoluteURL$1$2 = function isAbsoluteURL(url) {
|
|
350
|
+
return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
|
|
351
|
+
};
|
|
352
|
+
var combineURLs$1$2 = function combineURLs(baseURL, relativeURL) {
|
|
353
|
+
return relativeURL ? baseURL.replace(/\/+$/, "") + "/" + relativeURL.replace(/^\/+/, "") : baseURL;
|
|
354
|
+
};
|
|
355
|
+
var isAbsoluteURL2$1 = isAbsoluteURL$1$2;
|
|
356
|
+
var combineURLs2$1 = combineURLs$1$2;
|
|
357
|
+
var buildFullPath$1$2 = function buildFullPath(baseURL, requestedURL) {
|
|
358
|
+
if (baseURL && !isAbsoluteURL2$1(requestedURL)) {
|
|
359
|
+
return combineURLs2$1(baseURL, requestedURL);
|
|
360
|
+
}
|
|
361
|
+
return requestedURL;
|
|
362
|
+
};
|
|
363
|
+
var utils$9$2 = utils$e$1;
|
|
364
|
+
var ignoreDuplicateOf$2 = [
|
|
365
|
+
"age",
|
|
366
|
+
"authorization",
|
|
367
|
+
"content-length",
|
|
368
|
+
"content-type",
|
|
369
|
+
"etag",
|
|
370
|
+
"expires",
|
|
371
|
+
"from",
|
|
372
|
+
"host",
|
|
373
|
+
"if-modified-since",
|
|
374
|
+
"if-unmodified-since",
|
|
375
|
+
"last-modified",
|
|
376
|
+
"location",
|
|
377
|
+
"max-forwards",
|
|
378
|
+
"proxy-authorization",
|
|
379
|
+
"referer",
|
|
380
|
+
"retry-after",
|
|
381
|
+
"user-agent"
|
|
382
|
+
];
|
|
383
|
+
var parseHeaders$1$2 = function parseHeaders(headers) {
|
|
384
|
+
var parsed = {};
|
|
385
|
+
var key;
|
|
386
|
+
var val;
|
|
387
|
+
var i;
|
|
388
|
+
if (!headers) {
|
|
389
|
+
return parsed;
|
|
390
|
+
}
|
|
391
|
+
utils$9$2.forEach(headers.split("\n"), function parser(line) {
|
|
392
|
+
i = line.indexOf(":");
|
|
393
|
+
key = utils$9$2.trim(line.substr(0, i)).toLowerCase();
|
|
394
|
+
val = utils$9$2.trim(line.substr(i + 1));
|
|
395
|
+
if (key) {
|
|
396
|
+
if (parsed[key] && ignoreDuplicateOf$2.indexOf(key) >= 0) {
|
|
397
|
+
return;
|
|
398
|
+
}
|
|
399
|
+
if (key === "set-cookie") {
|
|
400
|
+
parsed[key] = (parsed[key] ? parsed[key] : []).concat([val]);
|
|
401
|
+
} else {
|
|
402
|
+
parsed[key] = parsed[key] ? parsed[key] + ", " + val : val;
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
});
|
|
406
|
+
return parsed;
|
|
407
|
+
};
|
|
408
|
+
var utils$8$2 = utils$e$1;
|
|
409
|
+
var isURLSameOrigin$1$2 = utils$8$2.isStandardBrowserEnv() ? function standardBrowserEnv2() {
|
|
410
|
+
var msie = /(msie|trident)/i.test(navigator.userAgent);
|
|
411
|
+
var urlParsingNode = document.createElement("a");
|
|
412
|
+
var originURL;
|
|
413
|
+
function resolveURL(url) {
|
|
414
|
+
var href = url;
|
|
415
|
+
if (msie) {
|
|
416
|
+
urlParsingNode.setAttribute("href", href);
|
|
417
|
+
href = urlParsingNode.href;
|
|
418
|
+
}
|
|
419
|
+
urlParsingNode.setAttribute("href", href);
|
|
420
|
+
return {
|
|
421
|
+
href: urlParsingNode.href,
|
|
422
|
+
protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, "") : "",
|
|
423
|
+
host: urlParsingNode.host,
|
|
424
|
+
search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, "") : "",
|
|
425
|
+
hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, "") : "",
|
|
426
|
+
hostname: urlParsingNode.hostname,
|
|
427
|
+
port: urlParsingNode.port,
|
|
428
|
+
pathname: urlParsingNode.pathname.charAt(0) === "/" ? urlParsingNode.pathname : "/" + urlParsingNode.pathname
|
|
429
|
+
};
|
|
430
|
+
}
|
|
431
|
+
originURL = resolveURL(window.location.href);
|
|
432
|
+
return function isURLSameOrigin2(requestURL) {
|
|
433
|
+
var parsed = utils$8$2.isString(requestURL) ? resolveURL(requestURL) : requestURL;
|
|
434
|
+
return parsed.protocol === originURL.protocol && parsed.host === originURL.host;
|
|
435
|
+
};
|
|
436
|
+
}() : function nonStandardBrowserEnv2() {
|
|
437
|
+
return function isURLSameOrigin2() {
|
|
438
|
+
return true;
|
|
439
|
+
};
|
|
440
|
+
}();
|
|
441
|
+
function Cancel$3$1(message) {
|
|
442
|
+
this.message = message;
|
|
443
|
+
}
|
|
444
|
+
Cancel$3$1.prototype.toString = function toString2() {
|
|
445
|
+
return "Cancel" + (this.message ? ": " + this.message : "");
|
|
446
|
+
};
|
|
447
|
+
Cancel$3$1.prototype.__CANCEL__ = true;
|
|
448
|
+
var Cancel_1$2 = Cancel$3$1;
|
|
449
|
+
var utils$7$2 = utils$e$1;
|
|
450
|
+
var settle2$1 = settle$1$2;
|
|
451
|
+
var cookies$3 = cookies$1$2;
|
|
452
|
+
var buildURL$1$2 = buildURL$2$2;
|
|
453
|
+
var buildFullPath2$1 = buildFullPath$1$2;
|
|
454
|
+
var parseHeaders2$1 = parseHeaders$1$2;
|
|
455
|
+
var isURLSameOrigin$3 = isURLSameOrigin$1$2;
|
|
456
|
+
var createError2$1 = createError$2$2;
|
|
457
|
+
var defaults$4$1 = defaults_1$2;
|
|
458
|
+
var Cancel$2$1 = Cancel_1$2;
|
|
459
|
+
var xhr$2 = function xhrAdapter(config) {
|
|
460
|
+
return new Promise(function dispatchXhrRequest(resolve, reject) {
|
|
461
|
+
var requestData = config.data;
|
|
462
|
+
var requestHeaders = config.headers;
|
|
463
|
+
var responseType = config.responseType;
|
|
464
|
+
var onCanceled;
|
|
465
|
+
function done() {
|
|
466
|
+
if (config.cancelToken) {
|
|
467
|
+
config.cancelToken.unsubscribe(onCanceled);
|
|
468
|
+
}
|
|
469
|
+
if (config.signal) {
|
|
470
|
+
config.signal.removeEventListener("abort", onCanceled);
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
if (utils$7$2.isFormData(requestData)) {
|
|
474
|
+
delete requestHeaders["Content-Type"];
|
|
475
|
+
}
|
|
476
|
+
var request22 = new XMLHttpRequest();
|
|
477
|
+
if (config.auth) {
|
|
478
|
+
var username = config.auth.username || "";
|
|
479
|
+
var password = config.auth.password ? unescape(encodeURIComponent(config.auth.password)) : "";
|
|
480
|
+
requestHeaders.Authorization = "Basic " + btoa(username + ":" + password);
|
|
481
|
+
}
|
|
482
|
+
var fullPath = buildFullPath2$1(config.baseURL, config.url);
|
|
483
|
+
request22.open(config.method.toUpperCase(), buildURL$1$2(fullPath, config.params, config.paramsSerializer), true);
|
|
484
|
+
request22.timeout = config.timeout;
|
|
485
|
+
function onloadend() {
|
|
486
|
+
if (!request22) {
|
|
487
|
+
return;
|
|
488
|
+
}
|
|
489
|
+
var responseHeaders = "getAllResponseHeaders" in request22 ? parseHeaders2$1(request22.getAllResponseHeaders()) : null;
|
|
490
|
+
var responseData = !responseType || responseType === "text" || responseType === "json" ? request22.responseText : request22.response;
|
|
491
|
+
var response = {
|
|
492
|
+
data: responseData,
|
|
493
|
+
status: request22.status,
|
|
494
|
+
statusText: request22.statusText,
|
|
495
|
+
headers: responseHeaders,
|
|
496
|
+
config,
|
|
497
|
+
request: request22
|
|
498
|
+
};
|
|
499
|
+
settle2$1(function _resolve(value) {
|
|
500
|
+
resolve(value);
|
|
501
|
+
done();
|
|
502
|
+
}, function _reject(err) {
|
|
503
|
+
reject(err);
|
|
504
|
+
done();
|
|
505
|
+
}, response);
|
|
506
|
+
request22 = null;
|
|
507
|
+
}
|
|
508
|
+
if ("onloadend" in request22) {
|
|
509
|
+
request22.onloadend = onloadend;
|
|
510
|
+
} else {
|
|
511
|
+
request22.onreadystatechange = function handleLoad() {
|
|
512
|
+
if (!request22 || request22.readyState !== 4) {
|
|
513
|
+
return;
|
|
514
|
+
}
|
|
515
|
+
if (request22.status === 0 && !(request22.responseURL && request22.responseURL.indexOf("file:") === 0)) {
|
|
516
|
+
return;
|
|
517
|
+
}
|
|
518
|
+
setTimeout(onloadend);
|
|
519
|
+
};
|
|
520
|
+
}
|
|
521
|
+
request22.onabort = function handleAbort() {
|
|
522
|
+
if (!request22) {
|
|
523
|
+
return;
|
|
524
|
+
}
|
|
525
|
+
reject(createError2$1("Request aborted", config, "ECONNABORTED", request22));
|
|
526
|
+
request22 = null;
|
|
527
|
+
};
|
|
528
|
+
request22.onerror = function handleError() {
|
|
529
|
+
reject(createError2$1("Network Error", config, null, request22));
|
|
530
|
+
request22 = null;
|
|
531
|
+
};
|
|
532
|
+
request22.ontimeout = function handleTimeout() {
|
|
533
|
+
var timeoutErrorMessage = config.timeout ? "timeout of " + config.timeout + "ms exceeded" : "timeout exceeded";
|
|
534
|
+
var transitional22 = config.transitional || defaults$4$1.transitional;
|
|
535
|
+
if (config.timeoutErrorMessage) {
|
|
536
|
+
timeoutErrorMessage = config.timeoutErrorMessage;
|
|
537
|
+
}
|
|
538
|
+
reject(createError2$1(timeoutErrorMessage, config, transitional22.clarifyTimeoutError ? "ETIMEDOUT" : "ECONNABORTED", request22));
|
|
539
|
+
request22 = null;
|
|
540
|
+
};
|
|
541
|
+
if (utils$7$2.isStandardBrowserEnv()) {
|
|
542
|
+
var xsrfValue = (config.withCredentials || isURLSameOrigin$3(fullPath)) && config.xsrfCookieName ? cookies$3.read(config.xsrfCookieName) : void 0;
|
|
543
|
+
if (xsrfValue) {
|
|
544
|
+
requestHeaders[config.xsrfHeaderName] = xsrfValue;
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
if ("setRequestHeader" in request22) {
|
|
548
|
+
utils$7$2.forEach(requestHeaders, function setRequestHeader(val, key) {
|
|
549
|
+
if (typeof requestData === "undefined" && key.toLowerCase() === "content-type") {
|
|
550
|
+
delete requestHeaders[key];
|
|
551
|
+
} else {
|
|
552
|
+
request22.setRequestHeader(key, val);
|
|
553
|
+
}
|
|
554
|
+
});
|
|
555
|
+
}
|
|
556
|
+
if (!utils$7$2.isUndefined(config.withCredentials)) {
|
|
557
|
+
request22.withCredentials = !!config.withCredentials;
|
|
558
|
+
}
|
|
559
|
+
if (responseType && responseType !== "json") {
|
|
560
|
+
request22.responseType = config.responseType;
|
|
561
|
+
}
|
|
562
|
+
if (typeof config.onDownloadProgress === "function") {
|
|
563
|
+
request22.addEventListener("progress", config.onDownloadProgress);
|
|
564
|
+
}
|
|
565
|
+
if (typeof config.onUploadProgress === "function" && request22.upload) {
|
|
566
|
+
request22.upload.addEventListener("progress", config.onUploadProgress);
|
|
567
|
+
}
|
|
568
|
+
if (config.cancelToken || config.signal) {
|
|
569
|
+
onCanceled = function(cancel) {
|
|
570
|
+
if (!request22) {
|
|
571
|
+
return;
|
|
572
|
+
}
|
|
573
|
+
reject(!cancel || cancel && cancel.type ? new Cancel$2$1("canceled") : cancel);
|
|
574
|
+
request22.abort();
|
|
575
|
+
request22 = null;
|
|
576
|
+
};
|
|
577
|
+
config.cancelToken && config.cancelToken.subscribe(onCanceled);
|
|
578
|
+
if (config.signal) {
|
|
579
|
+
config.signal.aborted ? onCanceled() : config.signal.addEventListener("abort", onCanceled);
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
if (!requestData) {
|
|
583
|
+
requestData = null;
|
|
584
|
+
}
|
|
585
|
+
request22.send(requestData);
|
|
586
|
+
});
|
|
587
|
+
};
|
|
588
|
+
var utils$6$2 = utils$e$1;
|
|
589
|
+
var normalizeHeaderName2$1 = normalizeHeaderName$1$2;
|
|
590
|
+
var enhanceError2$1 = enhanceError$2$2;
|
|
591
|
+
var DEFAULT_CONTENT_TYPE$2 = {
|
|
592
|
+
"Content-Type": "application/x-www-form-urlencoded"
|
|
593
|
+
};
|
|
594
|
+
function setContentTypeIfUnset$2(headers, value) {
|
|
595
|
+
if (!utils$6$2.isUndefined(headers) && utils$6$2.isUndefined(headers["Content-Type"])) {
|
|
596
|
+
headers["Content-Type"] = value;
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
function getDefaultAdapter$2() {
|
|
600
|
+
var adapter;
|
|
601
|
+
if (typeof XMLHttpRequest !== "undefined") {
|
|
602
|
+
adapter = xhr$2;
|
|
603
|
+
} else if (typeof process !== "undefined" && Object.prototype.toString.call(process) === "[object process]") {
|
|
604
|
+
adapter = xhr$2;
|
|
605
|
+
}
|
|
606
|
+
return adapter;
|
|
607
|
+
}
|
|
608
|
+
function stringifySafely$2(rawValue, parser, encoder) {
|
|
609
|
+
if (utils$6$2.isString(rawValue)) {
|
|
610
|
+
try {
|
|
611
|
+
(parser || JSON.parse)(rawValue);
|
|
612
|
+
return utils$6$2.trim(rawValue);
|
|
613
|
+
} catch (e) {
|
|
614
|
+
if (e.name !== "SyntaxError") {
|
|
615
|
+
throw e;
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
return (encoder || JSON.stringify)(rawValue);
|
|
620
|
+
}
|
|
621
|
+
var defaults$3$2 = {
|
|
622
|
+
transitional: {
|
|
623
|
+
silentJSONParsing: true,
|
|
624
|
+
forcedJSONParsing: true,
|
|
625
|
+
clarifyTimeoutError: false
|
|
626
|
+
},
|
|
627
|
+
adapter: getDefaultAdapter$2(),
|
|
628
|
+
transformRequest: [function transformRequest(data2, headers) {
|
|
629
|
+
normalizeHeaderName2$1(headers, "Accept");
|
|
630
|
+
normalizeHeaderName2$1(headers, "Content-Type");
|
|
631
|
+
if (utils$6$2.isFormData(data2) || utils$6$2.isArrayBuffer(data2) || utils$6$2.isBuffer(data2) || utils$6$2.isStream(data2) || utils$6$2.isFile(data2) || utils$6$2.isBlob(data2)) {
|
|
632
|
+
return data2;
|
|
633
|
+
}
|
|
634
|
+
if (utils$6$2.isArrayBufferView(data2)) {
|
|
635
|
+
return data2.buffer;
|
|
636
|
+
}
|
|
637
|
+
if (utils$6$2.isURLSearchParams(data2)) {
|
|
638
|
+
setContentTypeIfUnset$2(headers, "application/x-www-form-urlencoded;charset=utf-8");
|
|
639
|
+
return data2.toString();
|
|
640
|
+
}
|
|
641
|
+
if (utils$6$2.isObject(data2) || headers && headers["Content-Type"] === "application/json") {
|
|
642
|
+
setContentTypeIfUnset$2(headers, "application/json");
|
|
643
|
+
return stringifySafely$2(data2);
|
|
644
|
+
}
|
|
645
|
+
return data2;
|
|
646
|
+
}],
|
|
647
|
+
transformResponse: [function transformResponse(data2) {
|
|
648
|
+
var transitional22 = this.transitional || defaults$3$2.transitional;
|
|
649
|
+
var silentJSONParsing = transitional22 && transitional22.silentJSONParsing;
|
|
650
|
+
var forcedJSONParsing = transitional22 && transitional22.forcedJSONParsing;
|
|
651
|
+
var strictJSONParsing = !silentJSONParsing && this.responseType === "json";
|
|
652
|
+
if (strictJSONParsing || forcedJSONParsing && utils$6$2.isString(data2) && data2.length) {
|
|
653
|
+
try {
|
|
654
|
+
return JSON.parse(data2);
|
|
655
|
+
} catch (e) {
|
|
656
|
+
if (strictJSONParsing) {
|
|
657
|
+
if (e.name === "SyntaxError") {
|
|
658
|
+
throw enhanceError2$1(e, this, "E_JSON_PARSE");
|
|
659
|
+
}
|
|
660
|
+
throw e;
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
return data2;
|
|
665
|
+
}],
|
|
666
|
+
timeout: 0,
|
|
667
|
+
xsrfCookieName: "XSRF-TOKEN",
|
|
668
|
+
xsrfHeaderName: "X-XSRF-TOKEN",
|
|
669
|
+
maxContentLength: -1,
|
|
670
|
+
maxBodyLength: -1,
|
|
671
|
+
validateStatus: function validateStatus(status) {
|
|
672
|
+
return status >= 200 && status < 300;
|
|
673
|
+
},
|
|
674
|
+
headers: {
|
|
675
|
+
common: {
|
|
676
|
+
"Accept": "application/json, text/plain, */*"
|
|
677
|
+
}
|
|
678
|
+
}
|
|
679
|
+
};
|
|
680
|
+
utils$6$2.forEach(["delete", "get", "head"], function forEachMethodNoData(method) {
|
|
681
|
+
defaults$3$2.headers[method] = {};
|
|
682
|
+
});
|
|
683
|
+
utils$6$2.forEach(["post", "put", "patch"], function forEachMethodWithData(method) {
|
|
684
|
+
defaults$3$2.headers[method] = utils$6$2.merge(DEFAULT_CONTENT_TYPE$2);
|
|
685
|
+
});
|
|
686
|
+
var defaults_1$2 = defaults$3$2;
|
|
687
|
+
var utils$5$2 = utils$e$1;
|
|
688
|
+
var defaults$2$2 = defaults_1$2;
|
|
689
|
+
var transformData$1$2 = function transformData(data2, headers, fns) {
|
|
690
|
+
var context = this || defaults$2$2;
|
|
691
|
+
utils$5$2.forEach(fns, function transform(fn) {
|
|
692
|
+
data2 = fn.call(context, data2, headers);
|
|
693
|
+
});
|
|
694
|
+
return data2;
|
|
695
|
+
};
|
|
696
|
+
var isCancel$1$2 = function isCancel(value) {
|
|
697
|
+
return !!(value && value.__CANCEL__);
|
|
698
|
+
};
|
|
699
|
+
var utils$4$2 = utils$e$1;
|
|
700
|
+
var transformData2$1 = transformData$1$2;
|
|
701
|
+
var isCancel2$1 = isCancel$1$2;
|
|
702
|
+
var defaults$1$2 = defaults_1$2;
|
|
703
|
+
var Cancel$1$2 = Cancel_1$2;
|
|
704
|
+
function throwIfCancellationRequested$2(config) {
|
|
705
|
+
if (config.cancelToken) {
|
|
706
|
+
config.cancelToken.throwIfRequested();
|
|
707
|
+
}
|
|
708
|
+
if (config.signal && config.signal.aborted) {
|
|
709
|
+
throw new Cancel$1$2("canceled");
|
|
710
|
+
}
|
|
711
|
+
}
|
|
712
|
+
var dispatchRequest$1$2 = function dispatchRequest(config) {
|
|
713
|
+
throwIfCancellationRequested$2(config);
|
|
714
|
+
config.headers = config.headers || {};
|
|
715
|
+
config.data = transformData2$1.call(config, config.data, config.headers, config.transformRequest);
|
|
716
|
+
config.headers = utils$4$2.merge(config.headers.common || {}, config.headers[config.method] || {}, config.headers);
|
|
717
|
+
utils$4$2.forEach(["delete", "get", "head", "post", "put", "patch", "common"], function cleanHeaderConfig(method) {
|
|
718
|
+
delete config.headers[method];
|
|
719
|
+
});
|
|
720
|
+
var adapter = config.adapter || defaults$1$2.adapter;
|
|
721
|
+
return adapter(config).then(function onAdapterResolution(response) {
|
|
722
|
+
throwIfCancellationRequested$2(config);
|
|
723
|
+
response.data = transformData2$1.call(config, response.data, response.headers, config.transformResponse);
|
|
724
|
+
return response;
|
|
725
|
+
}, function onAdapterRejection(reason) {
|
|
726
|
+
if (!isCancel2$1(reason)) {
|
|
727
|
+
throwIfCancellationRequested$2(config);
|
|
728
|
+
if (reason && reason.response) {
|
|
729
|
+
reason.response.data = transformData2$1.call(config, reason.response.data, reason.response.headers, config.transformResponse);
|
|
730
|
+
}
|
|
731
|
+
}
|
|
732
|
+
return Promise.reject(reason);
|
|
733
|
+
});
|
|
734
|
+
};
|
|
735
|
+
var utils$3$2 = utils$e$1;
|
|
736
|
+
var mergeConfig$2$2 = function mergeConfig(config1, config2) {
|
|
737
|
+
config2 = config2 || {};
|
|
738
|
+
var config = {};
|
|
739
|
+
function getMergedValue(target, source22) {
|
|
740
|
+
if (utils$3$2.isPlainObject(target) && utils$3$2.isPlainObject(source22)) {
|
|
741
|
+
return utils$3$2.merge(target, source22);
|
|
742
|
+
} else if (utils$3$2.isPlainObject(source22)) {
|
|
743
|
+
return utils$3$2.merge({}, source22);
|
|
744
|
+
} else if (utils$3$2.isArray(source22)) {
|
|
745
|
+
return source22.slice();
|
|
746
|
+
}
|
|
747
|
+
return source22;
|
|
748
|
+
}
|
|
749
|
+
function mergeDeepProperties(prop) {
|
|
750
|
+
if (!utils$3$2.isUndefined(config2[prop])) {
|
|
751
|
+
return getMergedValue(config1[prop], config2[prop]);
|
|
752
|
+
} else if (!utils$3$2.isUndefined(config1[prop])) {
|
|
753
|
+
return getMergedValue(void 0, config1[prop]);
|
|
754
|
+
}
|
|
755
|
+
}
|
|
756
|
+
function valueFromConfig2(prop) {
|
|
757
|
+
if (!utils$3$2.isUndefined(config2[prop])) {
|
|
758
|
+
return getMergedValue(void 0, config2[prop]);
|
|
759
|
+
}
|
|
760
|
+
}
|
|
761
|
+
function defaultToConfig2(prop) {
|
|
762
|
+
if (!utils$3$2.isUndefined(config2[prop])) {
|
|
763
|
+
return getMergedValue(void 0, config2[prop]);
|
|
764
|
+
} else if (!utils$3$2.isUndefined(config1[prop])) {
|
|
765
|
+
return getMergedValue(void 0, config1[prop]);
|
|
766
|
+
}
|
|
767
|
+
}
|
|
768
|
+
function mergeDirectKeys(prop) {
|
|
769
|
+
if (prop in config2) {
|
|
770
|
+
return getMergedValue(config1[prop], config2[prop]);
|
|
771
|
+
} else if (prop in config1) {
|
|
772
|
+
return getMergedValue(void 0, config1[prop]);
|
|
773
|
+
}
|
|
774
|
+
}
|
|
775
|
+
var mergeMap = {
|
|
776
|
+
"url": valueFromConfig2,
|
|
777
|
+
"method": valueFromConfig2,
|
|
778
|
+
"data": valueFromConfig2,
|
|
779
|
+
"baseURL": defaultToConfig2,
|
|
780
|
+
"transformRequest": defaultToConfig2,
|
|
781
|
+
"transformResponse": defaultToConfig2,
|
|
782
|
+
"paramsSerializer": defaultToConfig2,
|
|
783
|
+
"timeout": defaultToConfig2,
|
|
784
|
+
"timeoutMessage": defaultToConfig2,
|
|
785
|
+
"withCredentials": defaultToConfig2,
|
|
786
|
+
"adapter": defaultToConfig2,
|
|
787
|
+
"responseType": defaultToConfig2,
|
|
788
|
+
"xsrfCookieName": defaultToConfig2,
|
|
789
|
+
"xsrfHeaderName": defaultToConfig2,
|
|
790
|
+
"onUploadProgress": defaultToConfig2,
|
|
791
|
+
"onDownloadProgress": defaultToConfig2,
|
|
792
|
+
"decompress": defaultToConfig2,
|
|
793
|
+
"maxContentLength": defaultToConfig2,
|
|
794
|
+
"maxBodyLength": defaultToConfig2,
|
|
795
|
+
"transport": defaultToConfig2,
|
|
796
|
+
"httpAgent": defaultToConfig2,
|
|
797
|
+
"httpsAgent": defaultToConfig2,
|
|
798
|
+
"cancelToken": defaultToConfig2,
|
|
799
|
+
"socketPath": defaultToConfig2,
|
|
800
|
+
"responseEncoding": defaultToConfig2,
|
|
801
|
+
"validateStatus": mergeDirectKeys
|
|
802
|
+
};
|
|
803
|
+
utils$3$2.forEach(Object.keys(config1).concat(Object.keys(config2)), function computeConfigValue(prop) {
|
|
804
|
+
var merge2 = mergeMap[prop] || mergeDeepProperties;
|
|
805
|
+
var configValue = merge2(prop);
|
|
806
|
+
utils$3$2.isUndefined(configValue) && merge2 !== mergeDirectKeys || (config[prop] = configValue);
|
|
807
|
+
});
|
|
808
|
+
return config;
|
|
809
|
+
};
|
|
810
|
+
var data$1 = {
|
|
811
|
+
"version": "0.25.0"
|
|
812
|
+
};
|
|
813
|
+
var VERSION$1 = data$1.version;
|
|
814
|
+
var validators$1$2 = {};
|
|
815
|
+
["object", "boolean", "number", "function", "string", "symbol"].forEach(function(type, i) {
|
|
816
|
+
validators$1$2[type] = function validator2(thing) {
|
|
817
|
+
return typeof thing === type || "a" + (i < 1 ? "n " : " ") + type;
|
|
818
|
+
};
|
|
819
|
+
});
|
|
820
|
+
var deprecatedWarnings$2 = {};
|
|
821
|
+
validators$1$2.transitional = function transitional(validator2, version2, message) {
|
|
822
|
+
function formatMessage(opt, desc) {
|
|
823
|
+
return "[Axios v" + VERSION$1 + "] Transitional option '" + opt + "'" + desc + (message ? ". " + message : "");
|
|
824
|
+
}
|
|
825
|
+
return function(value, opt, opts) {
|
|
826
|
+
if (validator2 === false) {
|
|
827
|
+
throw new Error(formatMessage(opt, " has been removed" + (version2 ? " in " + version2 : "")));
|
|
828
|
+
}
|
|
829
|
+
if (version2 && !deprecatedWarnings$2[opt]) {
|
|
830
|
+
deprecatedWarnings$2[opt] = true;
|
|
831
|
+
console.warn(formatMessage(opt, " has been deprecated since v" + version2 + " and will be removed in the near future"));
|
|
832
|
+
}
|
|
833
|
+
return validator2 ? validator2(value, opt, opts) : true;
|
|
834
|
+
};
|
|
835
|
+
};
|
|
836
|
+
function assertOptions$2(options, schema, allowUnknown) {
|
|
837
|
+
if (typeof options !== "object") {
|
|
838
|
+
throw new TypeError("options must be an object");
|
|
839
|
+
}
|
|
840
|
+
var keys = Object.keys(options);
|
|
841
|
+
var i = keys.length;
|
|
842
|
+
while (i-- > 0) {
|
|
843
|
+
var opt = keys[i];
|
|
844
|
+
var validator2 = schema[opt];
|
|
845
|
+
if (validator2) {
|
|
846
|
+
var value = options[opt];
|
|
847
|
+
var result = value === void 0 || validator2(value, opt, options);
|
|
848
|
+
if (result !== true) {
|
|
849
|
+
throw new TypeError("option " + opt + " must be " + result);
|
|
850
|
+
}
|
|
851
|
+
continue;
|
|
852
|
+
}
|
|
853
|
+
if (allowUnknown !== true) {
|
|
854
|
+
throw Error("Unknown option " + opt);
|
|
855
|
+
}
|
|
856
|
+
}
|
|
857
|
+
}
|
|
858
|
+
var validator$1$2 = {
|
|
859
|
+
assertOptions: assertOptions$2,
|
|
860
|
+
validators: validators$1$2
|
|
861
|
+
};
|
|
862
|
+
var utils$2$2 = utils$e$1;
|
|
863
|
+
var buildURL2$1 = buildURL$2$2;
|
|
864
|
+
var InterceptorManager$3 = InterceptorManager_1$2;
|
|
865
|
+
var dispatchRequest2$1 = dispatchRequest$1$2;
|
|
866
|
+
var mergeConfig$1$2 = mergeConfig$2$2;
|
|
867
|
+
var validator$3 = validator$1$2;
|
|
868
|
+
var validators$3 = validator$3.validators;
|
|
869
|
+
function Axios$1$2(instanceConfig) {
|
|
870
|
+
this.defaults = instanceConfig;
|
|
871
|
+
this.interceptors = {
|
|
872
|
+
request: new InterceptorManager$3(),
|
|
873
|
+
response: new InterceptorManager$3()
|
|
874
|
+
};
|
|
875
|
+
}
|
|
876
|
+
Axios$1$2.prototype.request = function request(configOrUrl, config) {
|
|
877
|
+
if (typeof configOrUrl === "string") {
|
|
878
|
+
config = config || {};
|
|
879
|
+
config.url = configOrUrl;
|
|
880
|
+
} else {
|
|
881
|
+
config = configOrUrl || {};
|
|
882
|
+
}
|
|
883
|
+
if (!config.url) {
|
|
884
|
+
throw new Error("Provided config url is not valid");
|
|
885
|
+
}
|
|
886
|
+
config = mergeConfig$1$2(this.defaults, config);
|
|
887
|
+
if (config.method) {
|
|
888
|
+
config.method = config.method.toLowerCase();
|
|
889
|
+
} else if (this.defaults.method) {
|
|
890
|
+
config.method = this.defaults.method.toLowerCase();
|
|
891
|
+
} else {
|
|
892
|
+
config.method = "get";
|
|
893
|
+
}
|
|
894
|
+
var transitional22 = config.transitional;
|
|
895
|
+
if (transitional22 !== void 0) {
|
|
896
|
+
validator$3.assertOptions(transitional22, {
|
|
897
|
+
silentJSONParsing: validators$3.transitional(validators$3.boolean),
|
|
898
|
+
forcedJSONParsing: validators$3.transitional(validators$3.boolean),
|
|
899
|
+
clarifyTimeoutError: validators$3.transitional(validators$3.boolean)
|
|
900
|
+
}, false);
|
|
901
|
+
}
|
|
902
|
+
var requestInterceptorChain = [];
|
|
903
|
+
var synchronousRequestInterceptors = true;
|
|
904
|
+
this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
|
|
905
|
+
if (typeof interceptor.runWhen === "function" && interceptor.runWhen(config) === false) {
|
|
906
|
+
return;
|
|
907
|
+
}
|
|
908
|
+
synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous;
|
|
909
|
+
requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected);
|
|
910
|
+
});
|
|
911
|
+
var responseInterceptorChain = [];
|
|
912
|
+
this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
|
|
913
|
+
responseInterceptorChain.push(interceptor.fulfilled, interceptor.rejected);
|
|
914
|
+
});
|
|
915
|
+
var promise;
|
|
916
|
+
if (!synchronousRequestInterceptors) {
|
|
917
|
+
var chain = [dispatchRequest2$1, void 0];
|
|
918
|
+
Array.prototype.unshift.apply(chain, requestInterceptorChain);
|
|
919
|
+
chain = chain.concat(responseInterceptorChain);
|
|
920
|
+
promise = Promise.resolve(config);
|
|
921
|
+
while (chain.length) {
|
|
922
|
+
promise = promise.then(chain.shift(), chain.shift());
|
|
923
|
+
}
|
|
924
|
+
return promise;
|
|
925
|
+
}
|
|
926
|
+
var newConfig = config;
|
|
927
|
+
while (requestInterceptorChain.length) {
|
|
928
|
+
var onFulfilled = requestInterceptorChain.shift();
|
|
929
|
+
var onRejected = requestInterceptorChain.shift();
|
|
930
|
+
try {
|
|
931
|
+
newConfig = onFulfilled(newConfig);
|
|
932
|
+
} catch (error) {
|
|
933
|
+
onRejected(error);
|
|
934
|
+
break;
|
|
935
|
+
}
|
|
936
|
+
}
|
|
937
|
+
try {
|
|
938
|
+
promise = dispatchRequest2$1(newConfig);
|
|
939
|
+
} catch (error) {
|
|
940
|
+
return Promise.reject(error);
|
|
941
|
+
}
|
|
942
|
+
while (responseInterceptorChain.length) {
|
|
943
|
+
promise = promise.then(responseInterceptorChain.shift(), responseInterceptorChain.shift());
|
|
944
|
+
}
|
|
945
|
+
return promise;
|
|
946
|
+
};
|
|
947
|
+
Axios$1$2.prototype.getUri = function getUri(config) {
|
|
948
|
+
if (!config.url) {
|
|
949
|
+
throw new Error("Provided config url is not valid");
|
|
950
|
+
}
|
|
951
|
+
config = mergeConfig$1$2(this.defaults, config);
|
|
952
|
+
return buildURL2$1(config.url, config.params, config.paramsSerializer).replace(/^\?/, "");
|
|
953
|
+
};
|
|
954
|
+
utils$2$2.forEach(["delete", "get", "head", "options"], function forEachMethodNoData2(method) {
|
|
955
|
+
Axios$1$2.prototype[method] = function(url, config) {
|
|
956
|
+
return this.request(mergeConfig$1$2(config || {}, {
|
|
957
|
+
method,
|
|
958
|
+
url,
|
|
959
|
+
data: (config || {}).data
|
|
960
|
+
}));
|
|
961
|
+
};
|
|
962
|
+
});
|
|
963
|
+
utils$2$2.forEach(["post", "put", "patch"], function forEachMethodWithData2(method) {
|
|
964
|
+
Axios$1$2.prototype[method] = function(url, data2, config) {
|
|
965
|
+
return this.request(mergeConfig$1$2(config || {}, {
|
|
966
|
+
method,
|
|
967
|
+
url,
|
|
968
|
+
data: data2
|
|
969
|
+
}));
|
|
970
|
+
};
|
|
971
|
+
});
|
|
972
|
+
var Axios_1$2 = Axios$1$2;
|
|
973
|
+
var Cancel$5 = Cancel_1$2;
|
|
974
|
+
function CancelToken$2(executor) {
|
|
975
|
+
if (typeof executor !== "function") {
|
|
976
|
+
throw new TypeError("executor must be a function.");
|
|
977
|
+
}
|
|
978
|
+
var resolvePromise;
|
|
979
|
+
this.promise = new Promise(function promiseExecutor(resolve) {
|
|
980
|
+
resolvePromise = resolve;
|
|
981
|
+
});
|
|
982
|
+
var token2 = this;
|
|
983
|
+
this.promise.then(function(cancel) {
|
|
984
|
+
if (!token2._listeners)
|
|
985
|
+
return;
|
|
986
|
+
var i;
|
|
987
|
+
var l = token2._listeners.length;
|
|
988
|
+
for (i = 0; i < l; i++) {
|
|
989
|
+
token2._listeners[i](cancel);
|
|
990
|
+
}
|
|
991
|
+
token2._listeners = null;
|
|
992
|
+
});
|
|
993
|
+
this.promise.then = function(onfulfilled) {
|
|
994
|
+
var _resolve;
|
|
995
|
+
var promise = new Promise(function(resolve) {
|
|
996
|
+
token2.subscribe(resolve);
|
|
997
|
+
_resolve = resolve;
|
|
998
|
+
}).then(onfulfilled);
|
|
999
|
+
promise.cancel = function reject() {
|
|
1000
|
+
token2.unsubscribe(_resolve);
|
|
1001
|
+
};
|
|
1002
|
+
return promise;
|
|
1003
|
+
};
|
|
1004
|
+
executor(function cancel(message) {
|
|
1005
|
+
if (token2.reason) {
|
|
1006
|
+
return;
|
|
1007
|
+
}
|
|
1008
|
+
token2.reason = new Cancel$5(message);
|
|
1009
|
+
resolvePromise(token2.reason);
|
|
1010
|
+
});
|
|
1011
|
+
}
|
|
1012
|
+
CancelToken$2.prototype.throwIfRequested = function throwIfRequested() {
|
|
1013
|
+
if (this.reason) {
|
|
1014
|
+
throw this.reason;
|
|
1015
|
+
}
|
|
1016
|
+
};
|
|
1017
|
+
CancelToken$2.prototype.subscribe = function subscribe(listener) {
|
|
1018
|
+
if (this.reason) {
|
|
1019
|
+
listener(this.reason);
|
|
1020
|
+
return;
|
|
1021
|
+
}
|
|
1022
|
+
if (this._listeners) {
|
|
1023
|
+
this._listeners.push(listener);
|
|
1024
|
+
} else {
|
|
1025
|
+
this._listeners = [listener];
|
|
1026
|
+
}
|
|
1027
|
+
};
|
|
1028
|
+
CancelToken$2.prototype.unsubscribe = function unsubscribe(listener) {
|
|
1029
|
+
if (!this._listeners) {
|
|
1030
|
+
return;
|
|
1031
|
+
}
|
|
1032
|
+
var index = this._listeners.indexOf(listener);
|
|
1033
|
+
if (index !== -1) {
|
|
1034
|
+
this._listeners.splice(index, 1);
|
|
1035
|
+
}
|
|
1036
|
+
};
|
|
1037
|
+
CancelToken$2.source = function source() {
|
|
1038
|
+
var cancel;
|
|
1039
|
+
var token2 = new CancelToken$2(function executor(c) {
|
|
1040
|
+
cancel = c;
|
|
1041
|
+
});
|
|
1042
|
+
return {
|
|
1043
|
+
token: token2,
|
|
1044
|
+
cancel
|
|
1045
|
+
};
|
|
1046
|
+
};
|
|
1047
|
+
var CancelToken_1$2 = CancelToken$2;
|
|
1048
|
+
var spread$2 = function spread2(callback) {
|
|
1049
|
+
return function wrap(arr) {
|
|
1050
|
+
return callback.apply(null, arr);
|
|
1051
|
+
};
|
|
1052
|
+
};
|
|
1053
|
+
var utils$1$2 = utils$e$1;
|
|
1054
|
+
var isAxiosError$2 = function isAxiosError2(payload) {
|
|
1055
|
+
return utils$1$2.isObject(payload) && payload.isAxiosError === true;
|
|
1056
|
+
};
|
|
1057
|
+
var utils$f = utils$e$1;
|
|
1058
|
+
var bind2$1 = bind$2$2;
|
|
1059
|
+
var Axios$3 = Axios_1$2;
|
|
1060
|
+
var mergeConfig2$1 = mergeConfig$2$2;
|
|
1061
|
+
var defaults$6 = defaults_1$2;
|
|
1062
|
+
function createInstance$2(defaultConfig) {
|
|
1063
|
+
var context = new Axios$3(defaultConfig);
|
|
1064
|
+
var instance = bind2$1(Axios$3.prototype.request, context);
|
|
1065
|
+
utils$f.extend(instance, Axios$3.prototype, context);
|
|
1066
|
+
utils$f.extend(instance, context);
|
|
1067
|
+
instance.create = function create2(instanceConfig) {
|
|
1068
|
+
return createInstance$2(mergeConfig2$1(defaultConfig, instanceConfig));
|
|
1069
|
+
};
|
|
1070
|
+
return instance;
|
|
1071
|
+
}
|
|
1072
|
+
var axios$1$2 = createInstance$2(defaults$6);
|
|
1073
|
+
axios$1$2.Axios = Axios$3;
|
|
1074
|
+
axios$1$2.Cancel = Cancel_1$2;
|
|
1075
|
+
axios$1$2.CancelToken = CancelToken_1$2;
|
|
1076
|
+
axios$1$2.isCancel = isCancel$1$2;
|
|
1077
|
+
axios$1$2.VERSION = data$1.version;
|
|
1078
|
+
axios$1$2.all = function all(promises) {
|
|
1079
|
+
return Promise.all(promises);
|
|
1080
|
+
};
|
|
1081
|
+
axios$1$2.spread = spread$2;
|
|
1082
|
+
axios$1$2.isAxiosError = isAxiosError$2;
|
|
1083
|
+
axios$2$2.exports = axios$1$2;
|
|
1084
|
+
axios$2$2.exports.default = axios$1$2;
|
|
1085
|
+
var axios$4 = axios$2$2.exports;
|
|
1086
|
+
const SERVER_ERROR_CODE = 500;
|
|
1087
|
+
class HasuraAuthApi {
|
|
1088
|
+
constructor({ url = "" }) {
|
|
1089
|
+
this.url = url;
|
|
1090
|
+
this.httpClient = axios$4.create({
|
|
1091
|
+
baseURL: this.url
|
|
1092
|
+
});
|
|
1093
|
+
this.httpClient.interceptors.response.use((response) => response, (error) => {
|
|
1094
|
+
var _a, _b, _c, _d, _e, _f;
|
|
1095
|
+
return Promise.reject({
|
|
1096
|
+
message: (_d = (_c = (_b = (_a = error.response) == null ? void 0 : _a.data) == null ? void 0 : _b.message) != null ? _c : error.message) != null ? _d : JSON.stringify(error),
|
|
1097
|
+
status: (_f = (_e = error.response) == null ? void 0 : _e.status) != null ? _f : SERVER_ERROR_CODE
|
|
1098
|
+
});
|
|
1099
|
+
});
|
|
1100
|
+
}
|
|
1101
|
+
async signUpEmailPassword(params) {
|
|
1102
|
+
try {
|
|
1103
|
+
const res = await this.httpClient.post("/signup/email-password", params);
|
|
1104
|
+
return { data: res.data, error: null };
|
|
1105
|
+
} catch (error) {
|
|
1106
|
+
return { data: null, error };
|
|
1107
|
+
}
|
|
1108
|
+
}
|
|
1109
|
+
async signInEmailPassword(params) {
|
|
1110
|
+
try {
|
|
1111
|
+
const res = await this.httpClient.post("/signin/email-password", params);
|
|
1112
|
+
return { data: res.data, error: null };
|
|
1113
|
+
} catch (error) {
|
|
1114
|
+
return { data: null, error };
|
|
1115
|
+
}
|
|
1116
|
+
}
|
|
1117
|
+
async signInPasswordlessEmail(params) {
|
|
1118
|
+
try {
|
|
1119
|
+
const res = await this.httpClient.post("/signin/passwordless/email", params);
|
|
1120
|
+
return { data: res.data, error: null };
|
|
1121
|
+
} catch (error) {
|
|
1122
|
+
return { data: null, error };
|
|
1123
|
+
}
|
|
1124
|
+
}
|
|
1125
|
+
async signInPasswordlessSms(params) {
|
|
1126
|
+
try {
|
|
1127
|
+
const res = await this.httpClient.post("/signin/passwordless/sms", params);
|
|
1128
|
+
return { data: res.data, error: null };
|
|
1129
|
+
} catch (error) {
|
|
1130
|
+
return { data: null, error };
|
|
1131
|
+
}
|
|
1132
|
+
}
|
|
1133
|
+
async signInPasswordlessSmsOtp(params) {
|
|
1134
|
+
try {
|
|
1135
|
+
const res = await this.httpClient.post("/signin/passwordless/sms/otp", params);
|
|
1136
|
+
return { data: res.data, error: null };
|
|
1137
|
+
} catch (error) {
|
|
1138
|
+
return { data: null, error };
|
|
1139
|
+
}
|
|
1140
|
+
}
|
|
1141
|
+
async signOut(params) {
|
|
1142
|
+
try {
|
|
1143
|
+
await this.httpClient.post("/signout", params);
|
|
1144
|
+
return { error: null };
|
|
1145
|
+
} catch (error) {
|
|
1146
|
+
return { error };
|
|
1147
|
+
}
|
|
1148
|
+
}
|
|
1149
|
+
async refreshToken(params) {
|
|
1150
|
+
try {
|
|
1151
|
+
const res = await this.httpClient.post("/token", params);
|
|
1152
|
+
return { error: null, session: res.data };
|
|
1153
|
+
} catch (error) {
|
|
1154
|
+
return { error, session: null };
|
|
1155
|
+
}
|
|
1156
|
+
}
|
|
1157
|
+
async resetPassword(params) {
|
|
1158
|
+
try {
|
|
1159
|
+
await this.httpClient.post("/user/password/reset", params);
|
|
1160
|
+
return { error: null };
|
|
1161
|
+
} catch (error) {
|
|
1162
|
+
return { error };
|
|
1163
|
+
}
|
|
1164
|
+
}
|
|
1165
|
+
async changePassword(params) {
|
|
1166
|
+
try {
|
|
1167
|
+
await this.httpClient.post("/user/password", params, {
|
|
1168
|
+
headers: __spreadValues$1({}, this.generateAuthHeaders())
|
|
1169
|
+
});
|
|
1170
|
+
return { error: null };
|
|
1171
|
+
} catch (error) {
|
|
1172
|
+
return { error };
|
|
1173
|
+
}
|
|
1174
|
+
}
|
|
1175
|
+
async sendVerificationEmail(params) {
|
|
1176
|
+
try {
|
|
1177
|
+
await this.httpClient.post("/user/email/send-verification-email", params);
|
|
1178
|
+
return { error: null };
|
|
1179
|
+
} catch (error) {
|
|
1180
|
+
return { error };
|
|
1181
|
+
}
|
|
1182
|
+
}
|
|
1183
|
+
async changeEmail(params) {
|
|
1184
|
+
try {
|
|
1185
|
+
await this.httpClient.post("/user/email/change", params, {
|
|
1186
|
+
headers: __spreadValues$1({}, this.generateAuthHeaders())
|
|
1187
|
+
});
|
|
1188
|
+
return { error: null };
|
|
1189
|
+
} catch (error) {
|
|
1190
|
+
return { error };
|
|
1191
|
+
}
|
|
1192
|
+
}
|
|
1193
|
+
async deanonymize(params) {
|
|
1194
|
+
try {
|
|
1195
|
+
await this.httpClient.post("/user/deanonymize", params);
|
|
1196
|
+
return { error: null };
|
|
1197
|
+
} catch (error) {
|
|
1198
|
+
return { error };
|
|
1199
|
+
}
|
|
1200
|
+
}
|
|
1201
|
+
async verifyEmail(params) {
|
|
1202
|
+
try {
|
|
1203
|
+
const res = await this.httpClient.post("/user/email/verify", params);
|
|
1204
|
+
return { data: res.data, error: null };
|
|
1205
|
+
} catch (error) {
|
|
1206
|
+
return { data: null, error };
|
|
1207
|
+
}
|
|
1208
|
+
}
|
|
1209
|
+
setAccessToken(accessToken) {
|
|
1210
|
+
this.accessToken = accessToken;
|
|
1211
|
+
}
|
|
1212
|
+
generateAuthHeaders() {
|
|
1213
|
+
if (!this.accessToken) {
|
|
1214
|
+
return null;
|
|
1215
|
+
}
|
|
1216
|
+
return {
|
|
1217
|
+
Authorization: `Bearer ${this.accessToken}`
|
|
1218
|
+
};
|
|
1219
|
+
}
|
|
1220
|
+
}
|
|
1221
|
+
var queryString = {};
|
|
1222
|
+
var strictUriEncode = (str) => encodeURIComponent(str).replace(/[!'()*]/g, (x) => `%${x.charCodeAt(0).toString(16).toUpperCase()}`);
|
|
1223
|
+
var token = "%[a-f0-9]{2}";
|
|
1224
|
+
var singleMatcher = new RegExp(token, "gi");
|
|
1225
|
+
var multiMatcher = new RegExp("(" + token + ")+", "gi");
|
|
1226
|
+
function decodeComponents(components, split) {
|
|
1227
|
+
try {
|
|
1228
|
+
return decodeURIComponent(components.join(""));
|
|
1229
|
+
} catch (err) {
|
|
1230
|
+
}
|
|
1231
|
+
if (components.length === 1) {
|
|
1232
|
+
return components;
|
|
1233
|
+
}
|
|
1234
|
+
split = split || 1;
|
|
1235
|
+
var left = components.slice(0, split);
|
|
1236
|
+
var right = components.slice(split);
|
|
1237
|
+
return Array.prototype.concat.call([], decodeComponents(left), decodeComponents(right));
|
|
1238
|
+
}
|
|
1239
|
+
function decode(input) {
|
|
1240
|
+
try {
|
|
1241
|
+
return decodeURIComponent(input);
|
|
1242
|
+
} catch (err) {
|
|
1243
|
+
var tokens = input.match(singleMatcher);
|
|
1244
|
+
for (var i = 1; i < tokens.length; i++) {
|
|
1245
|
+
input = decodeComponents(tokens, i).join("");
|
|
1246
|
+
tokens = input.match(singleMatcher);
|
|
1247
|
+
}
|
|
1248
|
+
return input;
|
|
1249
|
+
}
|
|
1250
|
+
}
|
|
1251
|
+
function customDecodeURIComponent(input) {
|
|
1252
|
+
var replaceMap = {
|
|
1253
|
+
"%FE%FF": "\uFFFD\uFFFD",
|
|
1254
|
+
"%FF%FE": "\uFFFD\uFFFD"
|
|
1255
|
+
};
|
|
1256
|
+
var match = multiMatcher.exec(input);
|
|
1257
|
+
while (match) {
|
|
1258
|
+
try {
|
|
1259
|
+
replaceMap[match[0]] = decodeURIComponent(match[0]);
|
|
1260
|
+
} catch (err) {
|
|
1261
|
+
var result = decode(match[0]);
|
|
1262
|
+
if (result !== match[0]) {
|
|
1263
|
+
replaceMap[match[0]] = result;
|
|
1264
|
+
}
|
|
1265
|
+
}
|
|
1266
|
+
match = multiMatcher.exec(input);
|
|
1267
|
+
}
|
|
1268
|
+
replaceMap["%C2"] = "\uFFFD";
|
|
1269
|
+
var entries = Object.keys(replaceMap);
|
|
1270
|
+
for (var i = 0; i < entries.length; i++) {
|
|
1271
|
+
var key = entries[i];
|
|
1272
|
+
input = input.replace(new RegExp(key, "g"), replaceMap[key]);
|
|
1273
|
+
}
|
|
1274
|
+
return input;
|
|
1275
|
+
}
|
|
1276
|
+
var decodeUriComponent = function(encodedURI) {
|
|
1277
|
+
if (typeof encodedURI !== "string") {
|
|
1278
|
+
throw new TypeError("Expected `encodedURI` to be of type `string`, got `" + typeof encodedURI + "`");
|
|
1279
|
+
}
|
|
1280
|
+
try {
|
|
1281
|
+
encodedURI = encodedURI.replace(/\+/g, " ");
|
|
1282
|
+
return decodeURIComponent(encodedURI);
|
|
1283
|
+
} catch (err) {
|
|
1284
|
+
return customDecodeURIComponent(encodedURI);
|
|
1285
|
+
}
|
|
1286
|
+
};
|
|
1287
|
+
var splitOnFirst = (string, separator) => {
|
|
1288
|
+
if (!(typeof string === "string" && typeof separator === "string")) {
|
|
1289
|
+
throw new TypeError("Expected the arguments to be of type `string`");
|
|
1290
|
+
}
|
|
1291
|
+
if (separator === "") {
|
|
1292
|
+
return [string];
|
|
1293
|
+
}
|
|
1294
|
+
const separatorIndex = string.indexOf(separator);
|
|
1295
|
+
if (separatorIndex === -1) {
|
|
1296
|
+
return [string];
|
|
1297
|
+
}
|
|
1298
|
+
return [
|
|
1299
|
+
string.slice(0, separatorIndex),
|
|
1300
|
+
string.slice(separatorIndex + separator.length)
|
|
1301
|
+
];
|
|
1302
|
+
};
|
|
1303
|
+
var filterObj = function(obj, predicate) {
|
|
1304
|
+
var ret = {};
|
|
1305
|
+
var keys = Object.keys(obj);
|
|
1306
|
+
var isArr = Array.isArray(predicate);
|
|
1307
|
+
for (var i = 0; i < keys.length; i++) {
|
|
1308
|
+
var key = keys[i];
|
|
1309
|
+
var val = obj[key];
|
|
1310
|
+
if (isArr ? predicate.indexOf(key) !== -1 : predicate(key, val, obj)) {
|
|
1311
|
+
ret[key] = val;
|
|
1312
|
+
}
|
|
1313
|
+
}
|
|
1314
|
+
return ret;
|
|
1315
|
+
};
|
|
1316
|
+
(function(exports) {
|
|
1317
|
+
const strictUriEncode$1 = strictUriEncode;
|
|
1318
|
+
const decodeComponent = decodeUriComponent;
|
|
1319
|
+
const splitOnFirst$1 = splitOnFirst;
|
|
1320
|
+
const filterObject = filterObj;
|
|
1321
|
+
const isNullOrUndefined = (value) => value === null || value === void 0;
|
|
1322
|
+
const encodeFragmentIdentifier = Symbol("encodeFragmentIdentifier");
|
|
1323
|
+
function encoderForArrayFormat(options) {
|
|
1324
|
+
switch (options.arrayFormat) {
|
|
1325
|
+
case "index":
|
|
1326
|
+
return (key) => (result, value) => {
|
|
1327
|
+
const index = result.length;
|
|
1328
|
+
if (value === void 0 || options.skipNull && value === null || options.skipEmptyString && value === "") {
|
|
1329
|
+
return result;
|
|
1330
|
+
}
|
|
1331
|
+
if (value === null) {
|
|
1332
|
+
return [...result, [encode2(key, options), "[", index, "]"].join("")];
|
|
1333
|
+
}
|
|
1334
|
+
return [
|
|
1335
|
+
...result,
|
|
1336
|
+
[encode2(key, options), "[", encode2(index, options), "]=", encode2(value, options)].join("")
|
|
1337
|
+
];
|
|
1338
|
+
};
|
|
1339
|
+
case "bracket":
|
|
1340
|
+
return (key) => (result, value) => {
|
|
1341
|
+
if (value === void 0 || options.skipNull && value === null || options.skipEmptyString && value === "") {
|
|
1342
|
+
return result;
|
|
1343
|
+
}
|
|
1344
|
+
if (value === null) {
|
|
1345
|
+
return [...result, [encode2(key, options), "[]"].join("")];
|
|
1346
|
+
}
|
|
1347
|
+
return [...result, [encode2(key, options), "[]=", encode2(value, options)].join("")];
|
|
1348
|
+
};
|
|
1349
|
+
case "colon-list-separator":
|
|
1350
|
+
return (key) => (result, value) => {
|
|
1351
|
+
if (value === void 0 || options.skipNull && value === null || options.skipEmptyString && value === "") {
|
|
1352
|
+
return result;
|
|
1353
|
+
}
|
|
1354
|
+
if (value === null) {
|
|
1355
|
+
return [...result, [encode2(key, options), ":list="].join("")];
|
|
1356
|
+
}
|
|
1357
|
+
return [...result, [encode2(key, options), ":list=", encode2(value, options)].join("")];
|
|
1358
|
+
};
|
|
1359
|
+
case "comma":
|
|
1360
|
+
case "separator":
|
|
1361
|
+
case "bracket-separator": {
|
|
1362
|
+
const keyValueSep = options.arrayFormat === "bracket-separator" ? "[]=" : "=";
|
|
1363
|
+
return (key) => (result, value) => {
|
|
1364
|
+
if (value === void 0 || options.skipNull && value === null || options.skipEmptyString && value === "") {
|
|
1365
|
+
return result;
|
|
1366
|
+
}
|
|
1367
|
+
value = value === null ? "" : value;
|
|
1368
|
+
if (result.length === 0) {
|
|
1369
|
+
return [[encode2(key, options), keyValueSep, encode2(value, options)].join("")];
|
|
1370
|
+
}
|
|
1371
|
+
return [[result, encode2(value, options)].join(options.arrayFormatSeparator)];
|
|
1372
|
+
};
|
|
1373
|
+
}
|
|
1374
|
+
default:
|
|
1375
|
+
return (key) => (result, value) => {
|
|
1376
|
+
if (value === void 0 || options.skipNull && value === null || options.skipEmptyString && value === "") {
|
|
1377
|
+
return result;
|
|
1378
|
+
}
|
|
1379
|
+
if (value === null) {
|
|
1380
|
+
return [...result, encode2(key, options)];
|
|
1381
|
+
}
|
|
1382
|
+
return [...result, [encode2(key, options), "=", encode2(value, options)].join("")];
|
|
1383
|
+
};
|
|
1384
|
+
}
|
|
1385
|
+
}
|
|
1386
|
+
function parserForArrayFormat(options) {
|
|
1387
|
+
let result;
|
|
1388
|
+
switch (options.arrayFormat) {
|
|
1389
|
+
case "index":
|
|
1390
|
+
return (key, value, accumulator) => {
|
|
1391
|
+
result = /\[(\d*)\]$/.exec(key);
|
|
1392
|
+
key = key.replace(/\[\d*\]$/, "");
|
|
1393
|
+
if (!result) {
|
|
1394
|
+
accumulator[key] = value;
|
|
1395
|
+
return;
|
|
1396
|
+
}
|
|
1397
|
+
if (accumulator[key] === void 0) {
|
|
1398
|
+
accumulator[key] = {};
|
|
1399
|
+
}
|
|
1400
|
+
accumulator[key][result[1]] = value;
|
|
1401
|
+
};
|
|
1402
|
+
case "bracket":
|
|
1403
|
+
return (key, value, accumulator) => {
|
|
1404
|
+
result = /(\[\])$/.exec(key);
|
|
1405
|
+
key = key.replace(/\[\]$/, "");
|
|
1406
|
+
if (!result) {
|
|
1407
|
+
accumulator[key] = value;
|
|
1408
|
+
return;
|
|
1409
|
+
}
|
|
1410
|
+
if (accumulator[key] === void 0) {
|
|
1411
|
+
accumulator[key] = [value];
|
|
1412
|
+
return;
|
|
1413
|
+
}
|
|
1414
|
+
accumulator[key] = [].concat(accumulator[key], value);
|
|
1415
|
+
};
|
|
1416
|
+
case "colon-list-separator":
|
|
1417
|
+
return (key, value, accumulator) => {
|
|
1418
|
+
result = /(:list)$/.exec(key);
|
|
1419
|
+
key = key.replace(/:list$/, "");
|
|
1420
|
+
if (!result) {
|
|
1421
|
+
accumulator[key] = value;
|
|
1422
|
+
return;
|
|
1423
|
+
}
|
|
1424
|
+
if (accumulator[key] === void 0) {
|
|
1425
|
+
accumulator[key] = [value];
|
|
1426
|
+
return;
|
|
1427
|
+
}
|
|
1428
|
+
accumulator[key] = [].concat(accumulator[key], value);
|
|
1429
|
+
};
|
|
1430
|
+
case "comma":
|
|
1431
|
+
case "separator":
|
|
1432
|
+
return (key, value, accumulator) => {
|
|
1433
|
+
const isArray2 = typeof value === "string" && value.includes(options.arrayFormatSeparator);
|
|
1434
|
+
const isEncodedArray = typeof value === "string" && !isArray2 && decode2(value, options).includes(options.arrayFormatSeparator);
|
|
1435
|
+
value = isEncodedArray ? decode2(value, options) : value;
|
|
1436
|
+
const newValue = isArray2 || isEncodedArray ? value.split(options.arrayFormatSeparator).map((item) => decode2(item, options)) : value === null ? value : decode2(value, options);
|
|
1437
|
+
accumulator[key] = newValue;
|
|
1438
|
+
};
|
|
1439
|
+
case "bracket-separator":
|
|
1440
|
+
return (key, value, accumulator) => {
|
|
1441
|
+
const isArray2 = /(\[\])$/.test(key);
|
|
1442
|
+
key = key.replace(/\[\]$/, "");
|
|
1443
|
+
if (!isArray2) {
|
|
1444
|
+
accumulator[key] = value ? decode2(value, options) : value;
|
|
1445
|
+
return;
|
|
1446
|
+
}
|
|
1447
|
+
const arrayValue = value === null ? [] : value.split(options.arrayFormatSeparator).map((item) => decode2(item, options));
|
|
1448
|
+
if (accumulator[key] === void 0) {
|
|
1449
|
+
accumulator[key] = arrayValue;
|
|
1450
|
+
return;
|
|
1451
|
+
}
|
|
1452
|
+
accumulator[key] = [].concat(accumulator[key], arrayValue);
|
|
1453
|
+
};
|
|
1454
|
+
default:
|
|
1455
|
+
return (key, value, accumulator) => {
|
|
1456
|
+
if (accumulator[key] === void 0) {
|
|
1457
|
+
accumulator[key] = value;
|
|
1458
|
+
return;
|
|
1459
|
+
}
|
|
1460
|
+
accumulator[key] = [].concat(accumulator[key], value);
|
|
1461
|
+
};
|
|
1462
|
+
}
|
|
1463
|
+
}
|
|
1464
|
+
function validateArrayFormatSeparator(value) {
|
|
1465
|
+
if (typeof value !== "string" || value.length !== 1) {
|
|
1466
|
+
throw new TypeError("arrayFormatSeparator must be single character string");
|
|
1467
|
+
}
|
|
1468
|
+
}
|
|
1469
|
+
function encode2(value, options) {
|
|
1470
|
+
if (options.encode) {
|
|
1471
|
+
return options.strict ? strictUriEncode$1(value) : encodeURIComponent(value);
|
|
1472
|
+
}
|
|
1473
|
+
return value;
|
|
1474
|
+
}
|
|
1475
|
+
function decode2(value, options) {
|
|
1476
|
+
if (options.decode) {
|
|
1477
|
+
return decodeComponent(value);
|
|
1478
|
+
}
|
|
1479
|
+
return value;
|
|
1480
|
+
}
|
|
1481
|
+
function keysSorter(input) {
|
|
1482
|
+
if (Array.isArray(input)) {
|
|
1483
|
+
return input.sort();
|
|
1484
|
+
}
|
|
1485
|
+
if (typeof input === "object") {
|
|
1486
|
+
return keysSorter(Object.keys(input)).sort((a, b) => Number(a) - Number(b)).map((key) => input[key]);
|
|
1487
|
+
}
|
|
1488
|
+
return input;
|
|
1489
|
+
}
|
|
1490
|
+
function removeHash(input) {
|
|
1491
|
+
const hashStart = input.indexOf("#");
|
|
1492
|
+
if (hashStart !== -1) {
|
|
1493
|
+
input = input.slice(0, hashStart);
|
|
1494
|
+
}
|
|
1495
|
+
return input;
|
|
1496
|
+
}
|
|
1497
|
+
function getHash(url) {
|
|
1498
|
+
let hash = "";
|
|
1499
|
+
const hashStart = url.indexOf("#");
|
|
1500
|
+
if (hashStart !== -1) {
|
|
1501
|
+
hash = url.slice(hashStart);
|
|
1502
|
+
}
|
|
1503
|
+
return hash;
|
|
1504
|
+
}
|
|
1505
|
+
function extract(input) {
|
|
1506
|
+
input = removeHash(input);
|
|
1507
|
+
const queryStart = input.indexOf("?");
|
|
1508
|
+
if (queryStart === -1) {
|
|
1509
|
+
return "";
|
|
1510
|
+
}
|
|
1511
|
+
return input.slice(queryStart + 1);
|
|
1512
|
+
}
|
|
1513
|
+
function parseValue(value, options) {
|
|
1514
|
+
if (options.parseNumbers && !Number.isNaN(Number(value)) && (typeof value === "string" && value.trim() !== "")) {
|
|
1515
|
+
value = Number(value);
|
|
1516
|
+
} else if (options.parseBooleans && value !== null && (value.toLowerCase() === "true" || value.toLowerCase() === "false")) {
|
|
1517
|
+
value = value.toLowerCase() === "true";
|
|
1518
|
+
}
|
|
1519
|
+
return value;
|
|
1520
|
+
}
|
|
1521
|
+
function parse(query, options) {
|
|
1522
|
+
options = Object.assign({
|
|
1523
|
+
decode: true,
|
|
1524
|
+
sort: true,
|
|
1525
|
+
arrayFormat: "none",
|
|
1526
|
+
arrayFormatSeparator: ",",
|
|
1527
|
+
parseNumbers: false,
|
|
1528
|
+
parseBooleans: false
|
|
1529
|
+
}, options);
|
|
1530
|
+
validateArrayFormatSeparator(options.arrayFormatSeparator);
|
|
1531
|
+
const formatter = parserForArrayFormat(options);
|
|
1532
|
+
const ret = Object.create(null);
|
|
1533
|
+
if (typeof query !== "string") {
|
|
1534
|
+
return ret;
|
|
1535
|
+
}
|
|
1536
|
+
query = query.trim().replace(/^[?#&]/, "");
|
|
1537
|
+
if (!query) {
|
|
1538
|
+
return ret;
|
|
1539
|
+
}
|
|
1540
|
+
for (const param of query.split("&")) {
|
|
1541
|
+
if (param === "") {
|
|
1542
|
+
continue;
|
|
1543
|
+
}
|
|
1544
|
+
let [key, value] = splitOnFirst$1(options.decode ? param.replace(/\+/g, " ") : param, "=");
|
|
1545
|
+
value = value === void 0 ? null : ["comma", "separator", "bracket-separator"].includes(options.arrayFormat) ? value : decode2(value, options);
|
|
1546
|
+
formatter(decode2(key, options), value, ret);
|
|
1547
|
+
}
|
|
1548
|
+
for (const key of Object.keys(ret)) {
|
|
1549
|
+
const value = ret[key];
|
|
1550
|
+
if (typeof value === "object" && value !== null) {
|
|
1551
|
+
for (const k of Object.keys(value)) {
|
|
1552
|
+
value[k] = parseValue(value[k], options);
|
|
1553
|
+
}
|
|
1554
|
+
} else {
|
|
1555
|
+
ret[key] = parseValue(value, options);
|
|
1556
|
+
}
|
|
1557
|
+
}
|
|
1558
|
+
if (options.sort === false) {
|
|
1559
|
+
return ret;
|
|
1560
|
+
}
|
|
1561
|
+
return (options.sort === true ? Object.keys(ret).sort() : Object.keys(ret).sort(options.sort)).reduce((result, key) => {
|
|
1562
|
+
const value = ret[key];
|
|
1563
|
+
if (Boolean(value) && typeof value === "object" && !Array.isArray(value)) {
|
|
1564
|
+
result[key] = keysSorter(value);
|
|
1565
|
+
} else {
|
|
1566
|
+
result[key] = value;
|
|
1567
|
+
}
|
|
1568
|
+
return result;
|
|
1569
|
+
}, Object.create(null));
|
|
1570
|
+
}
|
|
1571
|
+
exports.extract = extract;
|
|
1572
|
+
exports.parse = parse;
|
|
1573
|
+
exports.stringify = (object, options) => {
|
|
1574
|
+
if (!object) {
|
|
1575
|
+
return "";
|
|
1576
|
+
}
|
|
1577
|
+
options = Object.assign({
|
|
1578
|
+
encode: true,
|
|
1579
|
+
strict: true,
|
|
1580
|
+
arrayFormat: "none",
|
|
1581
|
+
arrayFormatSeparator: ","
|
|
1582
|
+
}, options);
|
|
1583
|
+
validateArrayFormatSeparator(options.arrayFormatSeparator);
|
|
1584
|
+
const shouldFilter = (key) => options.skipNull && isNullOrUndefined(object[key]) || options.skipEmptyString && object[key] === "";
|
|
1585
|
+
const formatter = encoderForArrayFormat(options);
|
|
1586
|
+
const objectCopy = {};
|
|
1587
|
+
for (const key of Object.keys(object)) {
|
|
1588
|
+
if (!shouldFilter(key)) {
|
|
1589
|
+
objectCopy[key] = object[key];
|
|
1590
|
+
}
|
|
1591
|
+
}
|
|
1592
|
+
const keys = Object.keys(objectCopy);
|
|
1593
|
+
if (options.sort !== false) {
|
|
1594
|
+
keys.sort(options.sort);
|
|
1595
|
+
}
|
|
1596
|
+
return keys.map((key) => {
|
|
1597
|
+
const value = object[key];
|
|
1598
|
+
if (value === void 0) {
|
|
1599
|
+
return "";
|
|
1600
|
+
}
|
|
1601
|
+
if (value === null) {
|
|
1602
|
+
return encode2(key, options);
|
|
1603
|
+
}
|
|
1604
|
+
if (Array.isArray(value)) {
|
|
1605
|
+
if (value.length === 0 && options.arrayFormat === "bracket-separator") {
|
|
1606
|
+
return encode2(key, options) + "[]";
|
|
1607
|
+
}
|
|
1608
|
+
return value.reduce(formatter(key), []).join("&");
|
|
1609
|
+
}
|
|
1610
|
+
return encode2(key, options) + "=" + encode2(value, options);
|
|
1611
|
+
}).filter((x) => x.length > 0).join("&");
|
|
1612
|
+
};
|
|
1613
|
+
exports.parseUrl = (url, options) => {
|
|
1614
|
+
options = Object.assign({
|
|
1615
|
+
decode: true
|
|
1616
|
+
}, options);
|
|
1617
|
+
const [url_, hash] = splitOnFirst$1(url, "#");
|
|
1618
|
+
return Object.assign({
|
|
1619
|
+
url: url_.split("?")[0] || "",
|
|
1620
|
+
query: parse(extract(url), options)
|
|
1621
|
+
}, options && options.parseFragmentIdentifier && hash ? { fragmentIdentifier: decode2(hash, options) } : {});
|
|
1622
|
+
};
|
|
1623
|
+
exports.stringifyUrl = (object, options) => {
|
|
1624
|
+
options = Object.assign({
|
|
1625
|
+
encode: true,
|
|
1626
|
+
strict: true,
|
|
1627
|
+
[encodeFragmentIdentifier]: true
|
|
1628
|
+
}, options);
|
|
1629
|
+
const url = removeHash(object.url).split("?")[0] || "";
|
|
1630
|
+
const queryFromUrl = exports.extract(object.url);
|
|
1631
|
+
const parsedQueryFromUrl = exports.parse(queryFromUrl, { sort: false });
|
|
1632
|
+
const query = Object.assign(parsedQueryFromUrl, object.query);
|
|
1633
|
+
let queryString2 = exports.stringify(query, options);
|
|
1634
|
+
if (queryString2) {
|
|
1635
|
+
queryString2 = `?${queryString2}`;
|
|
1636
|
+
}
|
|
1637
|
+
let hash = getHash(object.url);
|
|
1638
|
+
if (object.fragmentIdentifier) {
|
|
1639
|
+
hash = `#${options[encodeFragmentIdentifier] ? encode2(object.fragmentIdentifier, options) : object.fragmentIdentifier}`;
|
|
1640
|
+
}
|
|
1641
|
+
return `${url}${queryString2}${hash}`;
|
|
1642
|
+
};
|
|
1643
|
+
exports.pick = (input, filter, options) => {
|
|
1644
|
+
options = Object.assign({
|
|
1645
|
+
parseFragmentIdentifier: true,
|
|
1646
|
+
[encodeFragmentIdentifier]: false
|
|
1647
|
+
}, options);
|
|
1648
|
+
const { url, query, fragmentIdentifier } = exports.parseUrl(input, options);
|
|
1649
|
+
return exports.stringifyUrl({
|
|
1650
|
+
url,
|
|
1651
|
+
query: filterObject(query, filter),
|
|
1652
|
+
fragmentIdentifier
|
|
1653
|
+
}, options);
|
|
1654
|
+
};
|
|
1655
|
+
exports.exclude = (input, filter, options) => {
|
|
1656
|
+
const exclusionFilter = Array.isArray(filter) ? (key) => !filter.includes(key) : (key, value) => !filter(key, value);
|
|
1657
|
+
return exports.pick(input, exclusionFilter, options);
|
|
1658
|
+
};
|
|
1659
|
+
})(queryString);
|
|
1660
|
+
const NHOST_REFRESH_TOKEN = "nhostRefreshToken";
|
|
1661
|
+
const isBrowser = () => typeof window !== "undefined";
|
|
1662
|
+
class inMemoryLocalStorage {
|
|
1663
|
+
constructor() {
|
|
1664
|
+
this.memory = {};
|
|
1665
|
+
}
|
|
1666
|
+
setItem(key, value) {
|
|
1667
|
+
this.memory[key] = value;
|
|
1668
|
+
}
|
|
1669
|
+
getItem(key) {
|
|
1670
|
+
return this.memory[key];
|
|
1671
|
+
}
|
|
1672
|
+
removeItem(key) {
|
|
1673
|
+
delete this.memory[key];
|
|
1674
|
+
}
|
|
1675
|
+
}
|
|
1676
|
+
class HasuraAuthClient {
|
|
1677
|
+
constructor({
|
|
1678
|
+
url,
|
|
1679
|
+
autoRefreshToken = true,
|
|
1680
|
+
autoLogin = true,
|
|
1681
|
+
refreshIntervalTime,
|
|
1682
|
+
clientStorage,
|
|
1683
|
+
clientStorageType = "web"
|
|
1684
|
+
}) {
|
|
1685
|
+
this.refreshIntervalTime = refreshIntervalTime;
|
|
1686
|
+
if (!clientStorage) {
|
|
1687
|
+
this.clientStorage = isBrowser() ? localStorage : new inMemoryLocalStorage();
|
|
1688
|
+
} else {
|
|
1689
|
+
this.clientStorage = clientStorage;
|
|
1690
|
+
}
|
|
1691
|
+
this.clientStorageType = clientStorageType;
|
|
1692
|
+
this.onTokenChangedFunctions = [];
|
|
1693
|
+
this.onAuthChangedFunctions = [];
|
|
1694
|
+
this.refreshInterval;
|
|
1695
|
+
this.refreshSleepCheckInterval = 0;
|
|
1696
|
+
this.refreshIntervalSleepCheckLastSample = Date.now();
|
|
1697
|
+
this.sampleRate = 2e3;
|
|
1698
|
+
this.url = url;
|
|
1699
|
+
this.autoRefreshToken = autoRefreshToken;
|
|
1700
|
+
this.initAuthLoading = true;
|
|
1701
|
+
this.session = null;
|
|
1702
|
+
this.api = new HasuraAuthApi({ url: this.url });
|
|
1703
|
+
let refreshToken = null;
|
|
1704
|
+
let autoLoginFromQueryParameters = false;
|
|
1705
|
+
if (autoLogin && isBrowser() && window.location) {
|
|
1706
|
+
const urlParams = queryString.parse(window.location.toString().split("#")[1]);
|
|
1707
|
+
if ("refreshToken" in urlParams) {
|
|
1708
|
+
refreshToken = urlParams.refreshToken;
|
|
1709
|
+
}
|
|
1710
|
+
if ("otp" in urlParams && "email" in urlParams) {
|
|
1711
|
+
const { otp, email } = urlParams;
|
|
1712
|
+
this.signIn({
|
|
1713
|
+
otp,
|
|
1714
|
+
email
|
|
1715
|
+
});
|
|
1716
|
+
autoLoginFromQueryParameters = true;
|
|
1717
|
+
}
|
|
1718
|
+
}
|
|
1719
|
+
if (!autoLoginFromQueryParameters && autoLogin) {
|
|
1720
|
+
this._autoLogin(refreshToken);
|
|
1721
|
+
} else if (refreshToken) {
|
|
1722
|
+
this._setItem(NHOST_REFRESH_TOKEN, refreshToken);
|
|
1723
|
+
}
|
|
1724
|
+
}
|
|
1725
|
+
async signUp(params) {
|
|
1726
|
+
const { email, password } = params;
|
|
1727
|
+
if (email && password) {
|
|
1728
|
+
const { data: data2, error } = await this.api.signUpEmailPassword(params);
|
|
1729
|
+
if (error) {
|
|
1730
|
+
return { session: null, error };
|
|
1731
|
+
}
|
|
1732
|
+
if (!data2) {
|
|
1733
|
+
return {
|
|
1734
|
+
session: null,
|
|
1735
|
+
error: { message: "An error occurred on sign up.", status: 500 }
|
|
1736
|
+
};
|
|
1737
|
+
}
|
|
1738
|
+
const { session } = data2;
|
|
1739
|
+
if (session) {
|
|
1740
|
+
await this._setSession(session);
|
|
1741
|
+
}
|
|
1742
|
+
return { session, error: null };
|
|
1743
|
+
}
|
|
1744
|
+
return {
|
|
1745
|
+
session: null,
|
|
1746
|
+
error: { message: "Incorrect parameters", status: 500 }
|
|
1747
|
+
};
|
|
1748
|
+
}
|
|
1749
|
+
async signIn(params) {
|
|
1750
|
+
if ("provider" in params) {
|
|
1751
|
+
const { provider } = params;
|
|
1752
|
+
const providerUrl = `${this.url}/signin/provider/${provider}`;
|
|
1753
|
+
if (isBrowser()) {
|
|
1754
|
+
window.location.href = providerUrl;
|
|
1755
|
+
}
|
|
1756
|
+
return { providerUrl, provider, session: null, mfa: null, error: null };
|
|
1757
|
+
}
|
|
1758
|
+
if ("email" in params && "password" in params) {
|
|
1759
|
+
const { data: data2, error } = await this.api.signInEmailPassword(params);
|
|
1760
|
+
if (error) {
|
|
1761
|
+
return { session: null, mfa: null, error };
|
|
1762
|
+
}
|
|
1763
|
+
if (!data2) {
|
|
1764
|
+
return {
|
|
1765
|
+
session: null,
|
|
1766
|
+
mfa: null,
|
|
1767
|
+
error: { message: "Incorrect Data", status: 500 }
|
|
1768
|
+
};
|
|
1769
|
+
}
|
|
1770
|
+
const { session, mfa } = data2;
|
|
1771
|
+
if (session) {
|
|
1772
|
+
await this._setSession(session);
|
|
1773
|
+
}
|
|
1774
|
+
return { session, mfa, error: null };
|
|
1775
|
+
}
|
|
1776
|
+
if ("email" in params && !("otp" in params)) {
|
|
1777
|
+
const { error } = await this.api.signInPasswordlessEmail(params);
|
|
1778
|
+
if (error) {
|
|
1779
|
+
return { session: null, mfa: null, error };
|
|
1780
|
+
}
|
|
1781
|
+
return { session: null, mfa: null, error: null };
|
|
1782
|
+
}
|
|
1783
|
+
if ("phoneNumber" in params && !("otp" in params)) {
|
|
1784
|
+
const { error } = await this.api.signInPasswordlessSms(params);
|
|
1785
|
+
if (error) {
|
|
1786
|
+
return { session: null, mfa: null, error };
|
|
1787
|
+
}
|
|
1788
|
+
return { session: null, mfa: null, error: null };
|
|
1789
|
+
}
|
|
1790
|
+
if ("otp" in params) {
|
|
1791
|
+
const { data: data2, error } = await this.api.signInPasswordlessSmsOtp(params);
|
|
1792
|
+
if (error) {
|
|
1793
|
+
return { session: null, mfa: null, error };
|
|
1794
|
+
}
|
|
1795
|
+
if (!data2) {
|
|
1796
|
+
return {
|
|
1797
|
+
session: null,
|
|
1798
|
+
mfa: null,
|
|
1799
|
+
error: { message: "Incorrect data", status: 500 }
|
|
1800
|
+
};
|
|
1801
|
+
}
|
|
1802
|
+
const { session, mfa } = data2;
|
|
1803
|
+
if (session) {
|
|
1804
|
+
await this._setSession(session);
|
|
1805
|
+
}
|
|
1806
|
+
return { session, mfa, error: null };
|
|
1807
|
+
}
|
|
1808
|
+
return {
|
|
1809
|
+
session: null,
|
|
1810
|
+
mfa: null,
|
|
1811
|
+
error: { message: "Incorrect parameters", status: 500 }
|
|
1812
|
+
};
|
|
1813
|
+
}
|
|
1814
|
+
async signOut(params) {
|
|
1815
|
+
const refreshToken = await this._getItem(NHOST_REFRESH_TOKEN);
|
|
1816
|
+
this._clearSession();
|
|
1817
|
+
const { error } = await this.api.signOut({
|
|
1818
|
+
refreshToken,
|
|
1819
|
+
all: params == null ? void 0 : params.all
|
|
1820
|
+
});
|
|
1821
|
+
return { error };
|
|
1822
|
+
}
|
|
1823
|
+
async verifyEmail(params) {
|
|
1824
|
+
const { data: data2, error } = await this.api.verifyEmail(params);
|
|
1825
|
+
return { data: data2, error };
|
|
1826
|
+
}
|
|
1827
|
+
async resetPassword(params) {
|
|
1828
|
+
const { error } = await this.api.resetPassword(params);
|
|
1829
|
+
return { error };
|
|
1830
|
+
}
|
|
1831
|
+
async changePassword(params) {
|
|
1832
|
+
const { error } = await this.api.changePassword(params);
|
|
1833
|
+
return { error };
|
|
1834
|
+
}
|
|
1835
|
+
async sendVerificationEmail(params) {
|
|
1836
|
+
const { error } = await this.api.sendVerificationEmail(params);
|
|
1837
|
+
return { error };
|
|
1838
|
+
}
|
|
1839
|
+
async changeEmail(params) {
|
|
1840
|
+
const { error } = await this.api.changeEmail(params);
|
|
1841
|
+
return { error };
|
|
1842
|
+
}
|
|
1843
|
+
async deanonymize(params) {
|
|
1844
|
+
const { error } = await this.api.deanonymize(params);
|
|
1845
|
+
return { error };
|
|
1846
|
+
}
|
|
1847
|
+
onTokenChanged(fn) {
|
|
1848
|
+
this.onTokenChangedFunctions.push(fn);
|
|
1849
|
+
const index = this.onTokenChangedFunctions.length - 1;
|
|
1850
|
+
const unsubscribe22 = () => {
|
|
1851
|
+
try {
|
|
1852
|
+
this.onTokenChangedFunctions[index] = () => {
|
|
1853
|
+
};
|
|
1854
|
+
} catch {
|
|
1855
|
+
console.warn("Unable to unsubscribe onTokenChanged function. Maybe the functions is already unsubscribed?");
|
|
1856
|
+
}
|
|
1857
|
+
};
|
|
1858
|
+
return unsubscribe22;
|
|
1859
|
+
}
|
|
1860
|
+
onAuthStateChanged(fn) {
|
|
1861
|
+
this.onAuthChangedFunctions.push(fn);
|
|
1862
|
+
const index = this.onAuthChangedFunctions.length - 1;
|
|
1863
|
+
const unsubscribe22 = () => {
|
|
1864
|
+
try {
|
|
1865
|
+
this.onAuthChangedFunctions[index] = () => {
|
|
1866
|
+
};
|
|
1867
|
+
} catch {
|
|
1868
|
+
console.warn("Unable to unsubscribe onAuthStateChanged function. Maybe you already did?");
|
|
1869
|
+
}
|
|
1870
|
+
};
|
|
1871
|
+
return unsubscribe22;
|
|
1872
|
+
}
|
|
1873
|
+
isAuthenticated() {
|
|
1874
|
+
return this.session !== null;
|
|
1875
|
+
}
|
|
1876
|
+
async isAuthenticatedAsync() {
|
|
1877
|
+
return new Promise((resolve) => {
|
|
1878
|
+
if (!this.initAuthLoading) {
|
|
1879
|
+
resolve(this.isAuthenticated());
|
|
1880
|
+
} else {
|
|
1881
|
+
const unsubscribe22 = this.onAuthStateChanged((event, _session) => {
|
|
1882
|
+
resolve(event === "SIGNED_IN");
|
|
1883
|
+
unsubscribe22();
|
|
1884
|
+
});
|
|
1885
|
+
}
|
|
1886
|
+
});
|
|
1887
|
+
}
|
|
1888
|
+
getAuthenticationStatus() {
|
|
1889
|
+
if (this.initAuthLoading)
|
|
1890
|
+
return { isAuthenticated: false, isLoading: true };
|
|
1891
|
+
return { isAuthenticated: this.session !== null, isLoading: false };
|
|
1892
|
+
}
|
|
1893
|
+
getJWTToken() {
|
|
1894
|
+
return this.getAccessToken();
|
|
1895
|
+
}
|
|
1896
|
+
getAccessToken() {
|
|
1897
|
+
if (!this.session) {
|
|
1898
|
+
return void 0;
|
|
1899
|
+
}
|
|
1900
|
+
return this.session.accessToken;
|
|
1901
|
+
}
|
|
1902
|
+
async refreshSession(refreshToken) {
|
|
1903
|
+
const refreshTokenToUse = refreshToken || await this._getItem(NHOST_REFRESH_TOKEN);
|
|
1904
|
+
if (!refreshTokenToUse) {
|
|
1905
|
+
console.warn("no refresh token found. No way of refreshing session");
|
|
1906
|
+
}
|
|
1907
|
+
return this._refreshTokens(refreshTokenToUse);
|
|
1908
|
+
}
|
|
1909
|
+
getSession() {
|
|
1910
|
+
return this.session;
|
|
1911
|
+
}
|
|
1912
|
+
getUser() {
|
|
1913
|
+
return this.session ? this.session.user : null;
|
|
1914
|
+
}
|
|
1915
|
+
async _setItem(key, value) {
|
|
1916
|
+
if (typeof value !== "string") {
|
|
1917
|
+
console.error(`value is not of type "string"`);
|
|
1918
|
+
return;
|
|
1919
|
+
}
|
|
1920
|
+
switch (this.clientStorageType) {
|
|
1921
|
+
case "web":
|
|
1922
|
+
if (typeof this.clientStorage.setItem !== "function") {
|
|
1923
|
+
console.error(`this.clientStorage.setItem is not a function`);
|
|
1924
|
+
break;
|
|
1925
|
+
}
|
|
1926
|
+
this.clientStorage.setItem(key, value);
|
|
1927
|
+
break;
|
|
1928
|
+
case "custom":
|
|
1929
|
+
case "react-native":
|
|
1930
|
+
if (typeof this.clientStorage.setItem !== "function") {
|
|
1931
|
+
console.error(`this.clientStorage.setItem is not a function`);
|
|
1932
|
+
break;
|
|
1933
|
+
}
|
|
1934
|
+
await this.clientStorage.setItem(key, value);
|
|
1935
|
+
break;
|
|
1936
|
+
case "capacitor":
|
|
1937
|
+
if (typeof this.clientStorage.set !== "function") {
|
|
1938
|
+
console.error(`this.clientStorage.set is not a function`);
|
|
1939
|
+
break;
|
|
1940
|
+
}
|
|
1941
|
+
await this.clientStorage.set({ key, value });
|
|
1942
|
+
break;
|
|
1943
|
+
case "expo-secure-storage":
|
|
1944
|
+
if (typeof this.clientStorage.setItemAsync !== "function") {
|
|
1945
|
+
console.error(`this.clientStorage.setItemAsync is not a function`);
|
|
1946
|
+
break;
|
|
1947
|
+
}
|
|
1948
|
+
this.clientStorage.setItemAsync(key, value);
|
|
1949
|
+
break;
|
|
1950
|
+
}
|
|
1951
|
+
}
|
|
1952
|
+
async _getItem(key) {
|
|
1953
|
+
switch (this.clientStorageType) {
|
|
1954
|
+
case "web":
|
|
1955
|
+
if (typeof this.clientStorage.getItem !== "function") {
|
|
1956
|
+
console.error(`this.clientStorage.getItem is not a function`);
|
|
1957
|
+
break;
|
|
1958
|
+
}
|
|
1959
|
+
return this.clientStorage.getItem(key);
|
|
1960
|
+
case "custom":
|
|
1961
|
+
case "react-native":
|
|
1962
|
+
if (typeof this.clientStorage.getItem !== "function") {
|
|
1963
|
+
console.error(`this.clientStorage.getItem is not a function`);
|
|
1964
|
+
break;
|
|
1965
|
+
}
|
|
1966
|
+
return await this.clientStorage.getItem(key);
|
|
1967
|
+
case "capacitor":
|
|
1968
|
+
if (typeof this.clientStorage.get !== "function") {
|
|
1969
|
+
console.error(`this.clientStorage.get is not a function`);
|
|
1970
|
+
break;
|
|
1971
|
+
}
|
|
1972
|
+
const res = await this.clientStorage.get({ key });
|
|
1973
|
+
return res.value;
|
|
1974
|
+
case "expo-secure-storage":
|
|
1975
|
+
if (typeof this.clientStorage.getItemAsync !== "function") {
|
|
1976
|
+
console.error(`this.clientStorage.getItemAsync is not a function`);
|
|
1977
|
+
break;
|
|
1978
|
+
}
|
|
1979
|
+
return this.clientStorage.getItemAsync(key);
|
|
1980
|
+
default:
|
|
1981
|
+
return "";
|
|
1982
|
+
}
|
|
1983
|
+
return "";
|
|
1984
|
+
}
|
|
1985
|
+
async _removeItem(key) {
|
|
1986
|
+
switch (this.clientStorageType) {
|
|
1987
|
+
case "web":
|
|
1988
|
+
if (typeof this.clientStorage.removeItem !== "function") {
|
|
1989
|
+
console.error(`this.clientStorage.removeItem is not a function`);
|
|
1990
|
+
break;
|
|
1991
|
+
}
|
|
1992
|
+
return void this.clientStorage.removeItem(key);
|
|
1993
|
+
case "custom":
|
|
1994
|
+
case "react-native":
|
|
1995
|
+
if (typeof this.clientStorage.removeItem !== "function") {
|
|
1996
|
+
console.error(`this.clientStorage.removeItem is not a function`);
|
|
1997
|
+
break;
|
|
1998
|
+
}
|
|
1999
|
+
return void this.clientStorage.removeItem(key);
|
|
2000
|
+
case "capacitor":
|
|
2001
|
+
if (typeof this.clientStorage.remove !== "function") {
|
|
2002
|
+
console.error(`this.clientStorage.remove is not a function`);
|
|
2003
|
+
break;
|
|
2004
|
+
}
|
|
2005
|
+
await this.clientStorage.remove({ key });
|
|
2006
|
+
break;
|
|
2007
|
+
case "expo-secure-storage":
|
|
2008
|
+
if (typeof this.clientStorage.deleteItemAsync !== "function") {
|
|
2009
|
+
console.error(`this.clientStorage.deleteItemAsync is not a function`);
|
|
2010
|
+
break;
|
|
2011
|
+
}
|
|
2012
|
+
this.clientStorage.deleteItemAsync(key);
|
|
2013
|
+
break;
|
|
2014
|
+
}
|
|
2015
|
+
}
|
|
2016
|
+
_autoLogin(refreshToken) {
|
|
2017
|
+
if (!isBrowser()) {
|
|
2018
|
+
return;
|
|
2019
|
+
}
|
|
2020
|
+
this._refreshTokens(refreshToken);
|
|
2021
|
+
}
|
|
2022
|
+
async _refreshTokens(paramRefreshToken) {
|
|
2023
|
+
const refreshToken = paramRefreshToken || await this._getItem(NHOST_REFRESH_TOKEN);
|
|
2024
|
+
if (!refreshToken) {
|
|
2025
|
+
setTimeout(async () => {
|
|
2026
|
+
await this._clearSession();
|
|
2027
|
+
}, 0);
|
|
2028
|
+
return;
|
|
2029
|
+
}
|
|
2030
|
+
try {
|
|
2031
|
+
const { session, error } = await this.api.refreshToken({ refreshToken });
|
|
2032
|
+
if (error && error.status === 401) {
|
|
2033
|
+
await this._clearSession();
|
|
2034
|
+
return;
|
|
2035
|
+
}
|
|
2036
|
+
if (!session)
|
|
2037
|
+
throw new Error("Invalid session data");
|
|
2038
|
+
await this._setSession(session);
|
|
2039
|
+
this.tokenChanged();
|
|
2040
|
+
} catch {
|
|
2041
|
+
}
|
|
2042
|
+
}
|
|
2043
|
+
tokenChanged() {
|
|
2044
|
+
for (const tokenChangedFunction of this.onTokenChangedFunctions) {
|
|
2045
|
+
tokenChangedFunction(this.session);
|
|
2046
|
+
}
|
|
2047
|
+
}
|
|
2048
|
+
authStateChanged({
|
|
2049
|
+
event,
|
|
2050
|
+
session
|
|
2051
|
+
}) {
|
|
2052
|
+
if (event === "SIGNED_IN" && session) {
|
|
2053
|
+
this.api.setAccessToken(session.accessToken);
|
|
2054
|
+
} else {
|
|
2055
|
+
this.api.setAccessToken(void 0);
|
|
2056
|
+
}
|
|
2057
|
+
for (const authChangedFunction of this.onAuthChangedFunctions) {
|
|
2058
|
+
authChangedFunction(event, session);
|
|
2059
|
+
}
|
|
2060
|
+
}
|
|
2061
|
+
async _clearSession() {
|
|
2062
|
+
const { isLoading, isAuthenticated } = this.getAuthenticationStatus();
|
|
2063
|
+
this.session = null;
|
|
2064
|
+
this.initAuthLoading = false;
|
|
2065
|
+
await this._removeItem(NHOST_REFRESH_TOKEN);
|
|
2066
|
+
if (isLoading || isAuthenticated) {
|
|
2067
|
+
clearInterval(this.refreshInterval);
|
|
2068
|
+
clearInterval(this.refreshSleepCheckInterval);
|
|
2069
|
+
this.authStateChanged({ event: "SIGNED_OUT", session: null });
|
|
2070
|
+
}
|
|
2071
|
+
}
|
|
2072
|
+
async _setSession(session) {
|
|
2073
|
+
const { isAuthenticated } = this.getAuthenticationStatus();
|
|
2074
|
+
this.session = session;
|
|
2075
|
+
await this._setItem(NHOST_REFRESH_TOKEN, session.refreshToken);
|
|
2076
|
+
if (this.autoRefreshToken && !isAuthenticated) {
|
|
2077
|
+
const JWTExpiresIn = session.accessTokenExpiresIn;
|
|
2078
|
+
const refreshIntervalTime = this.refreshIntervalTime ? this.refreshIntervalTime : Math.max(1, JWTExpiresIn - 1);
|
|
2079
|
+
this.refreshInterval = setInterval(async () => {
|
|
2080
|
+
const refreshToken = await this._getItem(NHOST_REFRESH_TOKEN);
|
|
2081
|
+
await this._refreshTokens(refreshToken);
|
|
2082
|
+
}, refreshIntervalTime * 1e3);
|
|
2083
|
+
this.refreshIntervalSleepCheckLastSample = Date.now();
|
|
2084
|
+
this.refreshSleepCheckInterval = setInterval(async () => {
|
|
2085
|
+
if (Date.now() - this.refreshIntervalSleepCheckLastSample >= this.sampleRate * 2) {
|
|
2086
|
+
const refreshToken = await this._getItem(NHOST_REFRESH_TOKEN);
|
|
2087
|
+
await this._refreshTokens(refreshToken);
|
|
2088
|
+
}
|
|
2089
|
+
this.refreshIntervalSleepCheckLastSample = Date.now();
|
|
2090
|
+
}, this.sampleRate);
|
|
2091
|
+
this.authStateChanged({ event: "SIGNED_IN", session: this.session });
|
|
2092
|
+
}
|
|
2093
|
+
this.initAuthLoading = false;
|
|
2094
|
+
}
|
|
2095
|
+
}
|
|
2096
|
+
var __defProp2 = Object.defineProperty;
|
|
2097
|
+
var __defProps2 = Object.defineProperties;
|
|
2098
|
+
var __getOwnPropDescs2 = Object.getOwnPropertyDescriptors;
|
|
2099
|
+
var __getOwnPropSymbols2 = Object.getOwnPropertySymbols;
|
|
2100
|
+
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
|
|
2101
|
+
var __propIsEnum2 = Object.prototype.propertyIsEnumerable;
|
|
2102
|
+
var __defNormalProp2 = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
2103
|
+
var __spreadValues2 = (a, b) => {
|
|
2104
|
+
for (var prop in b || (b = {}))
|
|
2105
|
+
if (__hasOwnProp2.call(b, prop))
|
|
2106
|
+
__defNormalProp2(a, prop, b[prop]);
|
|
2107
|
+
if (__getOwnPropSymbols2)
|
|
2108
|
+
for (var prop of __getOwnPropSymbols2(b)) {
|
|
2109
|
+
if (__propIsEnum2.call(b, prop))
|
|
2110
|
+
__defNormalProp2(a, prop, b[prop]);
|
|
2111
|
+
}
|
|
2112
|
+
return a;
|
|
2113
|
+
};
|
|
2114
|
+
var __spreadProps2 = (a, b) => __defProps2(a, __getOwnPropDescs2(b));
|
|
2115
|
+
var axios$2$1 = { exports: {} };
|
|
2116
|
+
var bind$2$1 = function bind2(fn, thisArg) {
|
|
2117
|
+
return function wrap() {
|
|
2118
|
+
var args = new Array(arguments.length);
|
|
2119
|
+
for (var i = 0; i < args.length; i++) {
|
|
2120
|
+
args[i] = arguments[i];
|
|
2121
|
+
}
|
|
2122
|
+
return fn.apply(thisArg, args);
|
|
2123
|
+
};
|
|
2124
|
+
};
|
|
2125
|
+
var bind$1$1 = bind$2$1;
|
|
2126
|
+
var toString$1 = Object.prototype.toString;
|
|
2127
|
+
function isArray$1(val) {
|
|
2128
|
+
return toString$1.call(val) === "[object Array]";
|
|
2129
|
+
}
|
|
2130
|
+
function isUndefined$1(val) {
|
|
2131
|
+
return typeof val === "undefined";
|
|
2132
|
+
}
|
|
2133
|
+
function isBuffer$1(val) {
|
|
2134
|
+
return val !== null && !isUndefined$1(val) && val.constructor !== null && !isUndefined$1(val.constructor) && typeof val.constructor.isBuffer === "function" && val.constructor.isBuffer(val);
|
|
2135
|
+
}
|
|
2136
|
+
function isArrayBuffer$1(val) {
|
|
2137
|
+
return toString$1.call(val) === "[object ArrayBuffer]";
|
|
2138
|
+
}
|
|
2139
|
+
function isFormData$1(val) {
|
|
2140
|
+
return typeof FormData !== "undefined" && val instanceof FormData;
|
|
2141
|
+
}
|
|
2142
|
+
function isArrayBufferView$1(val) {
|
|
2143
|
+
var result;
|
|
2144
|
+
if (typeof ArrayBuffer !== "undefined" && ArrayBuffer.isView) {
|
|
2145
|
+
result = ArrayBuffer.isView(val);
|
|
2146
|
+
} else {
|
|
2147
|
+
result = val && val.buffer && val.buffer instanceof ArrayBuffer;
|
|
2148
|
+
}
|
|
2149
|
+
return result;
|
|
2150
|
+
}
|
|
2151
|
+
function isString$1(val) {
|
|
2152
|
+
return typeof val === "string";
|
|
2153
|
+
}
|
|
2154
|
+
function isNumber$1(val) {
|
|
2155
|
+
return typeof val === "number";
|
|
2156
|
+
}
|
|
2157
|
+
function isObject$1(val) {
|
|
2158
|
+
return val !== null && typeof val === "object";
|
|
2159
|
+
}
|
|
2160
|
+
function isPlainObject$1(val) {
|
|
2161
|
+
if (toString$1.call(val) !== "[object Object]") {
|
|
2162
|
+
return false;
|
|
2163
|
+
}
|
|
2164
|
+
var prototype = Object.getPrototypeOf(val);
|
|
2165
|
+
return prototype === null || prototype === Object.prototype;
|
|
2166
|
+
}
|
|
2167
|
+
function isDate$1(val) {
|
|
2168
|
+
return toString$1.call(val) === "[object Date]";
|
|
2169
|
+
}
|
|
2170
|
+
function isFile$1(val) {
|
|
2171
|
+
return toString$1.call(val) === "[object File]";
|
|
2172
|
+
}
|
|
2173
|
+
function isBlob$1(val) {
|
|
2174
|
+
return toString$1.call(val) === "[object Blob]";
|
|
2175
|
+
}
|
|
2176
|
+
function isFunction$1(val) {
|
|
2177
|
+
return toString$1.call(val) === "[object Function]";
|
|
2178
|
+
}
|
|
2179
|
+
function isStream$1(val) {
|
|
2180
|
+
return isObject$1(val) && isFunction$1(val.pipe);
|
|
2181
|
+
}
|
|
2182
|
+
function isURLSearchParams$1(val) {
|
|
2183
|
+
return typeof URLSearchParams !== "undefined" && val instanceof URLSearchParams;
|
|
2184
|
+
}
|
|
2185
|
+
function trim$1(str) {
|
|
2186
|
+
return str.trim ? str.trim() : str.replace(/^\s+|\s+$/g, "");
|
|
2187
|
+
}
|
|
2188
|
+
function isStandardBrowserEnv$1() {
|
|
2189
|
+
if (typeof navigator !== "undefined" && (navigator.product === "ReactNative" || navigator.product === "NativeScript" || navigator.product === "NS")) {
|
|
2190
|
+
return false;
|
|
2191
|
+
}
|
|
2192
|
+
return typeof window !== "undefined" && typeof document !== "undefined";
|
|
2193
|
+
}
|
|
2194
|
+
function forEach$1(obj, fn) {
|
|
2195
|
+
if (obj === null || typeof obj === "undefined") {
|
|
2196
|
+
return;
|
|
2197
|
+
}
|
|
2198
|
+
if (typeof obj !== "object") {
|
|
2199
|
+
obj = [obj];
|
|
2200
|
+
}
|
|
2201
|
+
if (isArray$1(obj)) {
|
|
2202
|
+
for (var i = 0, l = obj.length; i < l; i++) {
|
|
2203
|
+
fn.call(null, obj[i], i, obj);
|
|
2204
|
+
}
|
|
2205
|
+
} else {
|
|
2206
|
+
for (var key in obj) {
|
|
2207
|
+
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
2208
|
+
fn.call(null, obj[key], key, obj);
|
|
2209
|
+
}
|
|
2210
|
+
}
|
|
2211
|
+
}
|
|
2212
|
+
}
|
|
2213
|
+
function merge$1() {
|
|
2214
|
+
var result = {};
|
|
2215
|
+
function assignValue(val, key) {
|
|
2216
|
+
if (isPlainObject$1(result[key]) && isPlainObject$1(val)) {
|
|
2217
|
+
result[key] = merge$1(result[key], val);
|
|
2218
|
+
} else if (isPlainObject$1(val)) {
|
|
2219
|
+
result[key] = merge$1({}, val);
|
|
2220
|
+
} else if (isArray$1(val)) {
|
|
2221
|
+
result[key] = val.slice();
|
|
2222
|
+
} else {
|
|
2223
|
+
result[key] = val;
|
|
2224
|
+
}
|
|
2225
|
+
}
|
|
2226
|
+
for (var i = 0, l = arguments.length; i < l; i++) {
|
|
2227
|
+
forEach$1(arguments[i], assignValue);
|
|
2228
|
+
}
|
|
2229
|
+
return result;
|
|
2230
|
+
}
|
|
2231
|
+
function extend$1(a, b, thisArg) {
|
|
2232
|
+
forEach$1(b, function assignValue(val, key) {
|
|
2233
|
+
if (thisArg && typeof val === "function") {
|
|
2234
|
+
a[key] = bind$1$1(val, thisArg);
|
|
2235
|
+
} else {
|
|
2236
|
+
a[key] = val;
|
|
2237
|
+
}
|
|
2238
|
+
});
|
|
2239
|
+
return a;
|
|
2240
|
+
}
|
|
2241
|
+
function stripBOM$1(content) {
|
|
2242
|
+
if (content.charCodeAt(0) === 65279) {
|
|
2243
|
+
content = content.slice(1);
|
|
2244
|
+
}
|
|
2245
|
+
return content;
|
|
2246
|
+
}
|
|
2247
|
+
var utils$d$1 = {
|
|
2248
|
+
isArray: isArray$1,
|
|
2249
|
+
isArrayBuffer: isArrayBuffer$1,
|
|
2250
|
+
isBuffer: isBuffer$1,
|
|
2251
|
+
isFormData: isFormData$1,
|
|
2252
|
+
isArrayBufferView: isArrayBufferView$1,
|
|
2253
|
+
isString: isString$1,
|
|
2254
|
+
isNumber: isNumber$1,
|
|
2255
|
+
isObject: isObject$1,
|
|
2256
|
+
isPlainObject: isPlainObject$1,
|
|
2257
|
+
isUndefined: isUndefined$1,
|
|
2258
|
+
isDate: isDate$1,
|
|
2259
|
+
isFile: isFile$1,
|
|
2260
|
+
isBlob: isBlob$1,
|
|
2261
|
+
isFunction: isFunction$1,
|
|
2262
|
+
isStream: isStream$1,
|
|
2263
|
+
isURLSearchParams: isURLSearchParams$1,
|
|
2264
|
+
isStandardBrowserEnv: isStandardBrowserEnv$1,
|
|
2265
|
+
forEach: forEach$1,
|
|
2266
|
+
merge: merge$1,
|
|
2267
|
+
extend: extend$1,
|
|
2268
|
+
trim: trim$1,
|
|
2269
|
+
stripBOM: stripBOM$1
|
|
2270
|
+
};
|
|
2271
|
+
var utils$c$1 = utils$d$1;
|
|
2272
|
+
function encode$1(val) {
|
|
2273
|
+
return encodeURIComponent(val).replace(/%3A/gi, ":").replace(/%24/g, "$").replace(/%2C/gi, ",").replace(/%20/g, "+").replace(/%5B/gi, "[").replace(/%5D/gi, "]");
|
|
2274
|
+
}
|
|
2275
|
+
var buildURL$2$1 = function buildURL2(url, params, paramsSerializer) {
|
|
2276
|
+
if (!params) {
|
|
2277
|
+
return url;
|
|
2278
|
+
}
|
|
2279
|
+
var serializedParams;
|
|
2280
|
+
if (paramsSerializer) {
|
|
2281
|
+
serializedParams = paramsSerializer(params);
|
|
2282
|
+
} else if (utils$c$1.isURLSearchParams(params)) {
|
|
2283
|
+
serializedParams = params.toString();
|
|
2284
|
+
} else {
|
|
2285
|
+
var parts = [];
|
|
2286
|
+
utils$c$1.forEach(params, function serialize(val, key) {
|
|
2287
|
+
if (val === null || typeof val === "undefined") {
|
|
2288
|
+
return;
|
|
2289
|
+
}
|
|
2290
|
+
if (utils$c$1.isArray(val)) {
|
|
2291
|
+
key = key + "[]";
|
|
2292
|
+
} else {
|
|
2293
|
+
val = [val];
|
|
2294
|
+
}
|
|
2295
|
+
utils$c$1.forEach(val, function parseValue(v) {
|
|
2296
|
+
if (utils$c$1.isDate(v)) {
|
|
2297
|
+
v = v.toISOString();
|
|
2298
|
+
} else if (utils$c$1.isObject(v)) {
|
|
2299
|
+
v = JSON.stringify(v);
|
|
2300
|
+
}
|
|
2301
|
+
parts.push(encode$1(key) + "=" + encode$1(v));
|
|
2302
|
+
});
|
|
2303
|
+
});
|
|
2304
|
+
serializedParams = parts.join("&");
|
|
2305
|
+
}
|
|
2306
|
+
if (serializedParams) {
|
|
2307
|
+
var hashmarkIndex = url.indexOf("#");
|
|
2308
|
+
if (hashmarkIndex !== -1) {
|
|
2309
|
+
url = url.slice(0, hashmarkIndex);
|
|
2310
|
+
}
|
|
2311
|
+
url += (url.indexOf("?") === -1 ? "?" : "&") + serializedParams;
|
|
2312
|
+
}
|
|
2313
|
+
return url;
|
|
2314
|
+
};
|
|
2315
|
+
var utils$b$1 = utils$d$1;
|
|
2316
|
+
function InterceptorManager$1$1() {
|
|
2317
|
+
this.handlers = [];
|
|
2318
|
+
}
|
|
2319
|
+
InterceptorManager$1$1.prototype.use = function use2(fulfilled, rejected, options) {
|
|
2320
|
+
this.handlers.push({
|
|
2321
|
+
fulfilled,
|
|
2322
|
+
rejected,
|
|
2323
|
+
synchronous: options ? options.synchronous : false,
|
|
2324
|
+
runWhen: options ? options.runWhen : null
|
|
2325
|
+
});
|
|
2326
|
+
return this.handlers.length - 1;
|
|
2327
|
+
};
|
|
2328
|
+
InterceptorManager$1$1.prototype.eject = function eject2(id) {
|
|
2329
|
+
if (this.handlers[id]) {
|
|
2330
|
+
this.handlers[id] = null;
|
|
2331
|
+
}
|
|
2332
|
+
};
|
|
2333
|
+
InterceptorManager$1$1.prototype.forEach = function forEach22(fn) {
|
|
2334
|
+
utils$b$1.forEach(this.handlers, function forEachHandler(h) {
|
|
2335
|
+
if (h !== null) {
|
|
2336
|
+
fn(h);
|
|
2337
|
+
}
|
|
2338
|
+
});
|
|
2339
|
+
};
|
|
2340
|
+
var InterceptorManager_1$1 = InterceptorManager$1$1;
|
|
2341
|
+
var utils$a$1 = utils$d$1;
|
|
2342
|
+
var normalizeHeaderName$1$1 = function normalizeHeaderName2(headers, normalizedName) {
|
|
2343
|
+
utils$a$1.forEach(headers, function processHeader(value, name2) {
|
|
2344
|
+
if (name2 !== normalizedName && name2.toUpperCase() === normalizedName.toUpperCase()) {
|
|
2345
|
+
headers[normalizedName] = value;
|
|
2346
|
+
delete headers[name2];
|
|
2347
|
+
}
|
|
2348
|
+
});
|
|
2349
|
+
};
|
|
2350
|
+
var enhanceError$2$1 = function enhanceError2(error, config, code, request22, response) {
|
|
2351
|
+
error.config = config;
|
|
2352
|
+
if (code) {
|
|
2353
|
+
error.code = code;
|
|
2354
|
+
}
|
|
2355
|
+
error.request = request22;
|
|
2356
|
+
error.response = response;
|
|
2357
|
+
error.isAxiosError = true;
|
|
2358
|
+
error.toJSON = function toJSON() {
|
|
2359
|
+
return {
|
|
2360
|
+
message: this.message,
|
|
2361
|
+
name: this.name,
|
|
2362
|
+
description: this.description,
|
|
2363
|
+
number: this.number,
|
|
2364
|
+
fileName: this.fileName,
|
|
2365
|
+
lineNumber: this.lineNumber,
|
|
2366
|
+
columnNumber: this.columnNumber,
|
|
2367
|
+
stack: this.stack,
|
|
2368
|
+
config: this.config,
|
|
2369
|
+
code: this.code
|
|
2370
|
+
};
|
|
2371
|
+
};
|
|
2372
|
+
return error;
|
|
2373
|
+
};
|
|
2374
|
+
var enhanceError$1$1 = enhanceError$2$1;
|
|
2375
|
+
var createError$2$1 = function createError2(message, config, code, request22, response) {
|
|
2376
|
+
var error = new Error(message);
|
|
2377
|
+
return enhanceError$1$1(error, config, code, request22, response);
|
|
2378
|
+
};
|
|
2379
|
+
var createError$1$1 = createError$2$1;
|
|
2380
|
+
var settle$1$1 = function settle2(resolve, reject, response) {
|
|
2381
|
+
var validateStatus22 = response.config.validateStatus;
|
|
2382
|
+
if (!response.status || !validateStatus22 || validateStatus22(response.status)) {
|
|
2383
|
+
resolve(response);
|
|
2384
|
+
} else {
|
|
2385
|
+
reject(createError$1$1("Request failed with status code " + response.status, response.config, null, response.request, response));
|
|
2386
|
+
}
|
|
2387
|
+
};
|
|
2388
|
+
var utils$9$1 = utils$d$1;
|
|
2389
|
+
var cookies$1$1 = utils$9$1.isStandardBrowserEnv() ? function standardBrowserEnv3() {
|
|
2390
|
+
return {
|
|
2391
|
+
write: function write(name2, value, expires, path, domain, secure) {
|
|
2392
|
+
var cookie = [];
|
|
2393
|
+
cookie.push(name2 + "=" + encodeURIComponent(value));
|
|
2394
|
+
if (utils$9$1.isNumber(expires)) {
|
|
2395
|
+
cookie.push("expires=" + new Date(expires).toGMTString());
|
|
2396
|
+
}
|
|
2397
|
+
if (utils$9$1.isString(path)) {
|
|
2398
|
+
cookie.push("path=" + path);
|
|
2399
|
+
}
|
|
2400
|
+
if (utils$9$1.isString(domain)) {
|
|
2401
|
+
cookie.push("domain=" + domain);
|
|
2402
|
+
}
|
|
2403
|
+
if (secure === true) {
|
|
2404
|
+
cookie.push("secure");
|
|
2405
|
+
}
|
|
2406
|
+
document.cookie = cookie.join("; ");
|
|
2407
|
+
},
|
|
2408
|
+
read: function read(name2) {
|
|
2409
|
+
var match = document.cookie.match(new RegExp("(^|;\\s*)(" + name2 + ")=([^;]*)"));
|
|
2410
|
+
return match ? decodeURIComponent(match[3]) : null;
|
|
2411
|
+
},
|
|
2412
|
+
remove: function remove(name2) {
|
|
2413
|
+
this.write(name2, "", Date.now() - 864e5);
|
|
2414
|
+
}
|
|
2415
|
+
};
|
|
2416
|
+
}() : function nonStandardBrowserEnv3() {
|
|
2417
|
+
return {
|
|
2418
|
+
write: function write() {
|
|
2419
|
+
},
|
|
2420
|
+
read: function read() {
|
|
2421
|
+
return null;
|
|
2422
|
+
},
|
|
2423
|
+
remove: function remove() {
|
|
2424
|
+
}
|
|
2425
|
+
};
|
|
2426
|
+
}();
|
|
2427
|
+
var isAbsoluteURL$1$1 = function isAbsoluteURL2(url) {
|
|
2428
|
+
return /^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(url);
|
|
2429
|
+
};
|
|
2430
|
+
var combineURLs$1$1 = function combineURLs2(baseURL, relativeURL) {
|
|
2431
|
+
return relativeURL ? baseURL.replace(/\/+$/, "") + "/" + relativeURL.replace(/^\/+/, "") : baseURL;
|
|
2432
|
+
};
|
|
2433
|
+
var isAbsoluteURL22 = isAbsoluteURL$1$1;
|
|
2434
|
+
var combineURLs22 = combineURLs$1$1;
|
|
2435
|
+
var buildFullPath$1$1 = function buildFullPath2(baseURL, requestedURL) {
|
|
2436
|
+
if (baseURL && !isAbsoluteURL22(requestedURL)) {
|
|
2437
|
+
return combineURLs22(baseURL, requestedURL);
|
|
2438
|
+
}
|
|
2439
|
+
return requestedURL;
|
|
2440
|
+
};
|
|
2441
|
+
var utils$8$1 = utils$d$1;
|
|
2442
|
+
var ignoreDuplicateOf$1 = [
|
|
2443
|
+
"age",
|
|
2444
|
+
"authorization",
|
|
2445
|
+
"content-length",
|
|
2446
|
+
"content-type",
|
|
2447
|
+
"etag",
|
|
2448
|
+
"expires",
|
|
2449
|
+
"from",
|
|
2450
|
+
"host",
|
|
2451
|
+
"if-modified-since",
|
|
2452
|
+
"if-unmodified-since",
|
|
2453
|
+
"last-modified",
|
|
2454
|
+
"location",
|
|
2455
|
+
"max-forwards",
|
|
2456
|
+
"proxy-authorization",
|
|
2457
|
+
"referer",
|
|
2458
|
+
"retry-after",
|
|
2459
|
+
"user-agent"
|
|
2460
|
+
];
|
|
2461
|
+
var parseHeaders$1$1 = function parseHeaders2(headers) {
|
|
2462
|
+
var parsed = {};
|
|
2463
|
+
var key;
|
|
2464
|
+
var val;
|
|
2465
|
+
var i;
|
|
2466
|
+
if (!headers) {
|
|
2467
|
+
return parsed;
|
|
2468
|
+
}
|
|
2469
|
+
utils$8$1.forEach(headers.split("\n"), function parser(line) {
|
|
2470
|
+
i = line.indexOf(":");
|
|
2471
|
+
key = utils$8$1.trim(line.substr(0, i)).toLowerCase();
|
|
2472
|
+
val = utils$8$1.trim(line.substr(i + 1));
|
|
2473
|
+
if (key) {
|
|
2474
|
+
if (parsed[key] && ignoreDuplicateOf$1.indexOf(key) >= 0) {
|
|
2475
|
+
return;
|
|
2476
|
+
}
|
|
2477
|
+
if (key === "set-cookie") {
|
|
2478
|
+
parsed[key] = (parsed[key] ? parsed[key] : []).concat([val]);
|
|
2479
|
+
} else {
|
|
2480
|
+
parsed[key] = parsed[key] ? parsed[key] + ", " + val : val;
|
|
2481
|
+
}
|
|
2482
|
+
}
|
|
2483
|
+
});
|
|
2484
|
+
return parsed;
|
|
2485
|
+
};
|
|
2486
|
+
var utils$7$1 = utils$d$1;
|
|
2487
|
+
var isURLSameOrigin$1$1 = utils$7$1.isStandardBrowserEnv() ? function standardBrowserEnv22() {
|
|
2488
|
+
var msie = /(msie|trident)/i.test(navigator.userAgent);
|
|
2489
|
+
var urlParsingNode = document.createElement("a");
|
|
2490
|
+
var originURL;
|
|
2491
|
+
function resolveURL(url) {
|
|
2492
|
+
var href = url;
|
|
2493
|
+
if (msie) {
|
|
2494
|
+
urlParsingNode.setAttribute("href", href);
|
|
2495
|
+
href = urlParsingNode.href;
|
|
2496
|
+
}
|
|
2497
|
+
urlParsingNode.setAttribute("href", href);
|
|
2498
|
+
return {
|
|
2499
|
+
href: urlParsingNode.href,
|
|
2500
|
+
protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, "") : "",
|
|
2501
|
+
host: urlParsingNode.host,
|
|
2502
|
+
search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, "") : "",
|
|
2503
|
+
hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, "") : "",
|
|
2504
|
+
hostname: urlParsingNode.hostname,
|
|
2505
|
+
port: urlParsingNode.port,
|
|
2506
|
+
pathname: urlParsingNode.pathname.charAt(0) === "/" ? urlParsingNode.pathname : "/" + urlParsingNode.pathname
|
|
2507
|
+
};
|
|
2508
|
+
}
|
|
2509
|
+
originURL = resolveURL(window.location.href);
|
|
2510
|
+
return function isURLSameOrigin2(requestURL) {
|
|
2511
|
+
var parsed = utils$7$1.isString(requestURL) ? resolveURL(requestURL) : requestURL;
|
|
2512
|
+
return parsed.protocol === originURL.protocol && parsed.host === originURL.host;
|
|
2513
|
+
};
|
|
2514
|
+
}() : function nonStandardBrowserEnv22() {
|
|
2515
|
+
return function isURLSameOrigin2() {
|
|
2516
|
+
return true;
|
|
2517
|
+
};
|
|
2518
|
+
}();
|
|
2519
|
+
var utils$6$1 = utils$d$1;
|
|
2520
|
+
var settle22 = settle$1$1;
|
|
2521
|
+
var cookies$2 = cookies$1$1;
|
|
2522
|
+
var buildURL$1$1 = buildURL$2$1;
|
|
2523
|
+
var buildFullPath22 = buildFullPath$1$1;
|
|
2524
|
+
var parseHeaders22 = parseHeaders$1$1;
|
|
2525
|
+
var isURLSameOrigin$2 = isURLSameOrigin$1$1;
|
|
2526
|
+
var createError22 = createError$2$1;
|
|
2527
|
+
var xhr$1 = function xhrAdapter2(config) {
|
|
2528
|
+
return new Promise(function dispatchXhrRequest(resolve, reject) {
|
|
2529
|
+
var requestData = config.data;
|
|
2530
|
+
var requestHeaders = config.headers;
|
|
2531
|
+
var responseType = config.responseType;
|
|
2532
|
+
if (utils$6$1.isFormData(requestData)) {
|
|
2533
|
+
delete requestHeaders["Content-Type"];
|
|
2534
|
+
}
|
|
2535
|
+
var request22 = new XMLHttpRequest();
|
|
2536
|
+
if (config.auth) {
|
|
2537
|
+
var username = config.auth.username || "";
|
|
2538
|
+
var password = config.auth.password ? unescape(encodeURIComponent(config.auth.password)) : "";
|
|
2539
|
+
requestHeaders.Authorization = "Basic " + btoa(username + ":" + password);
|
|
2540
|
+
}
|
|
2541
|
+
var fullPath = buildFullPath22(config.baseURL, config.url);
|
|
2542
|
+
request22.open(config.method.toUpperCase(), buildURL$1$1(fullPath, config.params, config.paramsSerializer), true);
|
|
2543
|
+
request22.timeout = config.timeout;
|
|
2544
|
+
function onloadend() {
|
|
2545
|
+
if (!request22) {
|
|
2546
|
+
return;
|
|
2547
|
+
}
|
|
2548
|
+
var responseHeaders = "getAllResponseHeaders" in request22 ? parseHeaders22(request22.getAllResponseHeaders()) : null;
|
|
2549
|
+
var responseData = !responseType || responseType === "text" || responseType === "json" ? request22.responseText : request22.response;
|
|
2550
|
+
var response = {
|
|
2551
|
+
data: responseData,
|
|
2552
|
+
status: request22.status,
|
|
2553
|
+
statusText: request22.statusText,
|
|
2554
|
+
headers: responseHeaders,
|
|
2555
|
+
config,
|
|
2556
|
+
request: request22
|
|
2557
|
+
};
|
|
2558
|
+
settle22(resolve, reject, response);
|
|
2559
|
+
request22 = null;
|
|
2560
|
+
}
|
|
2561
|
+
if ("onloadend" in request22) {
|
|
2562
|
+
request22.onloadend = onloadend;
|
|
2563
|
+
} else {
|
|
2564
|
+
request22.onreadystatechange = function handleLoad() {
|
|
2565
|
+
if (!request22 || request22.readyState !== 4) {
|
|
2566
|
+
return;
|
|
2567
|
+
}
|
|
2568
|
+
if (request22.status === 0 && !(request22.responseURL && request22.responseURL.indexOf("file:") === 0)) {
|
|
2569
|
+
return;
|
|
2570
|
+
}
|
|
2571
|
+
setTimeout(onloadend);
|
|
2572
|
+
};
|
|
2573
|
+
}
|
|
2574
|
+
request22.onabort = function handleAbort() {
|
|
2575
|
+
if (!request22) {
|
|
2576
|
+
return;
|
|
2577
|
+
}
|
|
2578
|
+
reject(createError22("Request aborted", config, "ECONNABORTED", request22));
|
|
2579
|
+
request22 = null;
|
|
2580
|
+
};
|
|
2581
|
+
request22.onerror = function handleError() {
|
|
2582
|
+
reject(createError22("Network Error", config, null, request22));
|
|
2583
|
+
request22 = null;
|
|
2584
|
+
};
|
|
2585
|
+
request22.ontimeout = function handleTimeout() {
|
|
2586
|
+
var timeoutErrorMessage = "timeout of " + config.timeout + "ms exceeded";
|
|
2587
|
+
if (config.timeoutErrorMessage) {
|
|
2588
|
+
timeoutErrorMessage = config.timeoutErrorMessage;
|
|
2589
|
+
}
|
|
2590
|
+
reject(createError22(timeoutErrorMessage, config, config.transitional && config.transitional.clarifyTimeoutError ? "ETIMEDOUT" : "ECONNABORTED", request22));
|
|
2591
|
+
request22 = null;
|
|
2592
|
+
};
|
|
2593
|
+
if (utils$6$1.isStandardBrowserEnv()) {
|
|
2594
|
+
var xsrfValue = (config.withCredentials || isURLSameOrigin$2(fullPath)) && config.xsrfCookieName ? cookies$2.read(config.xsrfCookieName) : void 0;
|
|
2595
|
+
if (xsrfValue) {
|
|
2596
|
+
requestHeaders[config.xsrfHeaderName] = xsrfValue;
|
|
2597
|
+
}
|
|
2598
|
+
}
|
|
2599
|
+
if ("setRequestHeader" in request22) {
|
|
2600
|
+
utils$6$1.forEach(requestHeaders, function setRequestHeader(val, key) {
|
|
2601
|
+
if (typeof requestData === "undefined" && key.toLowerCase() === "content-type") {
|
|
2602
|
+
delete requestHeaders[key];
|
|
2603
|
+
} else {
|
|
2604
|
+
request22.setRequestHeader(key, val);
|
|
2605
|
+
}
|
|
2606
|
+
});
|
|
2607
|
+
}
|
|
2608
|
+
if (!utils$6$1.isUndefined(config.withCredentials)) {
|
|
2609
|
+
request22.withCredentials = !!config.withCredentials;
|
|
2610
|
+
}
|
|
2611
|
+
if (responseType && responseType !== "json") {
|
|
2612
|
+
request22.responseType = config.responseType;
|
|
2613
|
+
}
|
|
2614
|
+
if (typeof config.onDownloadProgress === "function") {
|
|
2615
|
+
request22.addEventListener("progress", config.onDownloadProgress);
|
|
2616
|
+
}
|
|
2617
|
+
if (typeof config.onUploadProgress === "function" && request22.upload) {
|
|
2618
|
+
request22.upload.addEventListener("progress", config.onUploadProgress);
|
|
2619
|
+
}
|
|
2620
|
+
if (config.cancelToken) {
|
|
2621
|
+
config.cancelToken.promise.then(function onCanceled(cancel) {
|
|
2622
|
+
if (!request22) {
|
|
2623
|
+
return;
|
|
2624
|
+
}
|
|
2625
|
+
request22.abort();
|
|
2626
|
+
reject(cancel);
|
|
2627
|
+
request22 = null;
|
|
2628
|
+
});
|
|
2629
|
+
}
|
|
2630
|
+
if (!requestData) {
|
|
2631
|
+
requestData = null;
|
|
2632
|
+
}
|
|
2633
|
+
request22.send(requestData);
|
|
2634
|
+
});
|
|
2635
|
+
};
|
|
2636
|
+
var utils$5$1 = utils$d$1;
|
|
2637
|
+
var normalizeHeaderName22 = normalizeHeaderName$1$1;
|
|
2638
|
+
var enhanceError22 = enhanceError$2$1;
|
|
2639
|
+
var DEFAULT_CONTENT_TYPE$1 = {
|
|
2640
|
+
"Content-Type": "application/x-www-form-urlencoded"
|
|
2641
|
+
};
|
|
2642
|
+
function setContentTypeIfUnset$1(headers, value) {
|
|
2643
|
+
if (!utils$5$1.isUndefined(headers) && utils$5$1.isUndefined(headers["Content-Type"])) {
|
|
2644
|
+
headers["Content-Type"] = value;
|
|
2645
|
+
}
|
|
2646
|
+
}
|
|
2647
|
+
function getDefaultAdapter$1() {
|
|
2648
|
+
var adapter;
|
|
2649
|
+
if (typeof XMLHttpRequest !== "undefined") {
|
|
2650
|
+
adapter = xhr$1;
|
|
2651
|
+
} else if (typeof process !== "undefined" && Object.prototype.toString.call(process) === "[object process]") {
|
|
2652
|
+
adapter = xhr$1;
|
|
2653
|
+
}
|
|
2654
|
+
return adapter;
|
|
2655
|
+
}
|
|
2656
|
+
function stringifySafely$1(rawValue, parser, encoder) {
|
|
2657
|
+
if (utils$5$1.isString(rawValue)) {
|
|
2658
|
+
try {
|
|
2659
|
+
(parser || JSON.parse)(rawValue);
|
|
2660
|
+
return utils$5$1.trim(rawValue);
|
|
2661
|
+
} catch (e) {
|
|
2662
|
+
if (e.name !== "SyntaxError") {
|
|
2663
|
+
throw e;
|
|
2664
|
+
}
|
|
2665
|
+
}
|
|
2666
|
+
}
|
|
2667
|
+
return (encoder || JSON.stringify)(rawValue);
|
|
2668
|
+
}
|
|
2669
|
+
var defaults$3$1 = {
|
|
2670
|
+
transitional: {
|
|
2671
|
+
silentJSONParsing: true,
|
|
2672
|
+
forcedJSONParsing: true,
|
|
2673
|
+
clarifyTimeoutError: false
|
|
2674
|
+
},
|
|
2675
|
+
adapter: getDefaultAdapter$1(),
|
|
2676
|
+
transformRequest: [function transformRequest2(data2, headers) {
|
|
2677
|
+
normalizeHeaderName22(headers, "Accept");
|
|
2678
|
+
normalizeHeaderName22(headers, "Content-Type");
|
|
2679
|
+
if (utils$5$1.isFormData(data2) || utils$5$1.isArrayBuffer(data2) || utils$5$1.isBuffer(data2) || utils$5$1.isStream(data2) || utils$5$1.isFile(data2) || utils$5$1.isBlob(data2)) {
|
|
2680
|
+
return data2;
|
|
2681
|
+
}
|
|
2682
|
+
if (utils$5$1.isArrayBufferView(data2)) {
|
|
2683
|
+
return data2.buffer;
|
|
2684
|
+
}
|
|
2685
|
+
if (utils$5$1.isURLSearchParams(data2)) {
|
|
2686
|
+
setContentTypeIfUnset$1(headers, "application/x-www-form-urlencoded;charset=utf-8");
|
|
2687
|
+
return data2.toString();
|
|
2688
|
+
}
|
|
2689
|
+
if (utils$5$1.isObject(data2) || headers && headers["Content-Type"] === "application/json") {
|
|
2690
|
+
setContentTypeIfUnset$1(headers, "application/json");
|
|
2691
|
+
return stringifySafely$1(data2);
|
|
2692
|
+
}
|
|
2693
|
+
return data2;
|
|
2694
|
+
}],
|
|
2695
|
+
transformResponse: [function transformResponse2(data2) {
|
|
2696
|
+
var transitional22 = this.transitional;
|
|
2697
|
+
var silentJSONParsing = transitional22 && transitional22.silentJSONParsing;
|
|
2698
|
+
var forcedJSONParsing = transitional22 && transitional22.forcedJSONParsing;
|
|
2699
|
+
var strictJSONParsing = !silentJSONParsing && this.responseType === "json";
|
|
2700
|
+
if (strictJSONParsing || forcedJSONParsing && utils$5$1.isString(data2) && data2.length) {
|
|
2701
|
+
try {
|
|
2702
|
+
return JSON.parse(data2);
|
|
2703
|
+
} catch (e) {
|
|
2704
|
+
if (strictJSONParsing) {
|
|
2705
|
+
if (e.name === "SyntaxError") {
|
|
2706
|
+
throw enhanceError22(e, this, "E_JSON_PARSE");
|
|
2707
|
+
}
|
|
2708
|
+
throw e;
|
|
2709
|
+
}
|
|
2710
|
+
}
|
|
2711
|
+
}
|
|
2712
|
+
return data2;
|
|
2713
|
+
}],
|
|
2714
|
+
timeout: 0,
|
|
2715
|
+
xsrfCookieName: "XSRF-TOKEN",
|
|
2716
|
+
xsrfHeaderName: "X-XSRF-TOKEN",
|
|
2717
|
+
maxContentLength: -1,
|
|
2718
|
+
maxBodyLength: -1,
|
|
2719
|
+
validateStatus: function validateStatus2(status) {
|
|
2720
|
+
return status >= 200 && status < 300;
|
|
2721
|
+
}
|
|
2722
|
+
};
|
|
2723
|
+
defaults$3$1.headers = {
|
|
2724
|
+
common: {
|
|
2725
|
+
"Accept": "application/json, text/plain, */*"
|
|
2726
|
+
}
|
|
2727
|
+
};
|
|
2728
|
+
utils$5$1.forEach(["delete", "get", "head"], function forEachMethodNoData3(method) {
|
|
2729
|
+
defaults$3$1.headers[method] = {};
|
|
2730
|
+
});
|
|
2731
|
+
utils$5$1.forEach(["post", "put", "patch"], function forEachMethodWithData3(method) {
|
|
2732
|
+
defaults$3$1.headers[method] = utils$5$1.merge(DEFAULT_CONTENT_TYPE$1);
|
|
2733
|
+
});
|
|
2734
|
+
var defaults_1$1 = defaults$3$1;
|
|
2735
|
+
var utils$4$1 = utils$d$1;
|
|
2736
|
+
var defaults$2$1 = defaults_1$1;
|
|
2737
|
+
var transformData$1$1 = function transformData2(data2, headers, fns) {
|
|
2738
|
+
var context = this || defaults$2$1;
|
|
2739
|
+
utils$4$1.forEach(fns, function transform(fn) {
|
|
2740
|
+
data2 = fn.call(context, data2, headers);
|
|
2741
|
+
});
|
|
2742
|
+
return data2;
|
|
2743
|
+
};
|
|
2744
|
+
var isCancel$1$1 = function isCancel2(value) {
|
|
2745
|
+
return !!(value && value.__CANCEL__);
|
|
2746
|
+
};
|
|
2747
|
+
var utils$3$1 = utils$d$1;
|
|
2748
|
+
var transformData22 = transformData$1$1;
|
|
2749
|
+
var isCancel22 = isCancel$1$1;
|
|
2750
|
+
var defaults$1$1 = defaults_1$1;
|
|
2751
|
+
function throwIfCancellationRequested$1(config) {
|
|
2752
|
+
if (config.cancelToken) {
|
|
2753
|
+
config.cancelToken.throwIfRequested();
|
|
2754
|
+
}
|
|
2755
|
+
}
|
|
2756
|
+
var dispatchRequest$1$1 = function dispatchRequest2(config) {
|
|
2757
|
+
throwIfCancellationRequested$1(config);
|
|
2758
|
+
config.headers = config.headers || {};
|
|
2759
|
+
config.data = transformData22.call(config, config.data, config.headers, config.transformRequest);
|
|
2760
|
+
config.headers = utils$3$1.merge(config.headers.common || {}, config.headers[config.method] || {}, config.headers);
|
|
2761
|
+
utils$3$1.forEach(["delete", "get", "head", "post", "put", "patch", "common"], function cleanHeaderConfig(method) {
|
|
2762
|
+
delete config.headers[method];
|
|
2763
|
+
});
|
|
2764
|
+
var adapter = config.adapter || defaults$1$1.adapter;
|
|
2765
|
+
return adapter(config).then(function onAdapterResolution(response) {
|
|
2766
|
+
throwIfCancellationRequested$1(config);
|
|
2767
|
+
response.data = transformData22.call(config, response.data, response.headers, config.transformResponse);
|
|
2768
|
+
return response;
|
|
2769
|
+
}, function onAdapterRejection(reason) {
|
|
2770
|
+
if (!isCancel22(reason)) {
|
|
2771
|
+
throwIfCancellationRequested$1(config);
|
|
2772
|
+
if (reason && reason.response) {
|
|
2773
|
+
reason.response.data = transformData22.call(config, reason.response.data, reason.response.headers, config.transformResponse);
|
|
2774
|
+
}
|
|
2775
|
+
}
|
|
2776
|
+
return Promise.reject(reason);
|
|
2777
|
+
});
|
|
2778
|
+
};
|
|
2779
|
+
var utils$2$1 = utils$d$1;
|
|
2780
|
+
var mergeConfig$2$1 = function mergeConfig2(config1, config2) {
|
|
2781
|
+
config2 = config2 || {};
|
|
2782
|
+
var config = {};
|
|
2783
|
+
var valueFromConfig2Keys = ["url", "method", "data"];
|
|
2784
|
+
var mergeDeepPropertiesKeys = ["headers", "auth", "proxy", "params"];
|
|
2785
|
+
var defaultToConfig2Keys = [
|
|
2786
|
+
"baseURL",
|
|
2787
|
+
"transformRequest",
|
|
2788
|
+
"transformResponse",
|
|
2789
|
+
"paramsSerializer",
|
|
2790
|
+
"timeout",
|
|
2791
|
+
"timeoutMessage",
|
|
2792
|
+
"withCredentials",
|
|
2793
|
+
"adapter",
|
|
2794
|
+
"responseType",
|
|
2795
|
+
"xsrfCookieName",
|
|
2796
|
+
"xsrfHeaderName",
|
|
2797
|
+
"onUploadProgress",
|
|
2798
|
+
"onDownloadProgress",
|
|
2799
|
+
"decompress",
|
|
2800
|
+
"maxContentLength",
|
|
2801
|
+
"maxBodyLength",
|
|
2802
|
+
"maxRedirects",
|
|
2803
|
+
"transport",
|
|
2804
|
+
"httpAgent",
|
|
2805
|
+
"httpsAgent",
|
|
2806
|
+
"cancelToken",
|
|
2807
|
+
"socketPath",
|
|
2808
|
+
"responseEncoding"
|
|
2809
|
+
];
|
|
2810
|
+
var directMergeKeys = ["validateStatus"];
|
|
2811
|
+
function getMergedValue(target, source22) {
|
|
2812
|
+
if (utils$2$1.isPlainObject(target) && utils$2$1.isPlainObject(source22)) {
|
|
2813
|
+
return utils$2$1.merge(target, source22);
|
|
2814
|
+
} else if (utils$2$1.isPlainObject(source22)) {
|
|
2815
|
+
return utils$2$1.merge({}, source22);
|
|
2816
|
+
} else if (utils$2$1.isArray(source22)) {
|
|
2817
|
+
return source22.slice();
|
|
2818
|
+
}
|
|
2819
|
+
return source22;
|
|
2820
|
+
}
|
|
2821
|
+
function mergeDeepProperties(prop) {
|
|
2822
|
+
if (!utils$2$1.isUndefined(config2[prop])) {
|
|
2823
|
+
config[prop] = getMergedValue(config1[prop], config2[prop]);
|
|
2824
|
+
} else if (!utils$2$1.isUndefined(config1[prop])) {
|
|
2825
|
+
config[prop] = getMergedValue(void 0, config1[prop]);
|
|
2826
|
+
}
|
|
2827
|
+
}
|
|
2828
|
+
utils$2$1.forEach(valueFromConfig2Keys, function valueFromConfig2(prop) {
|
|
2829
|
+
if (!utils$2$1.isUndefined(config2[prop])) {
|
|
2830
|
+
config[prop] = getMergedValue(void 0, config2[prop]);
|
|
2831
|
+
}
|
|
2832
|
+
});
|
|
2833
|
+
utils$2$1.forEach(mergeDeepPropertiesKeys, mergeDeepProperties);
|
|
2834
|
+
utils$2$1.forEach(defaultToConfig2Keys, function defaultToConfig2(prop) {
|
|
2835
|
+
if (!utils$2$1.isUndefined(config2[prop])) {
|
|
2836
|
+
config[prop] = getMergedValue(void 0, config2[prop]);
|
|
2837
|
+
} else if (!utils$2$1.isUndefined(config1[prop])) {
|
|
2838
|
+
config[prop] = getMergedValue(void 0, config1[prop]);
|
|
2839
|
+
}
|
|
2840
|
+
});
|
|
2841
|
+
utils$2$1.forEach(directMergeKeys, function merge2(prop) {
|
|
2842
|
+
if (prop in config2) {
|
|
2843
|
+
config[prop] = getMergedValue(config1[prop], config2[prop]);
|
|
2844
|
+
} else if (prop in config1) {
|
|
2845
|
+
config[prop] = getMergedValue(void 0, config1[prop]);
|
|
2846
|
+
}
|
|
2847
|
+
});
|
|
2848
|
+
var axiosKeys = valueFromConfig2Keys.concat(mergeDeepPropertiesKeys).concat(defaultToConfig2Keys).concat(directMergeKeys);
|
|
2849
|
+
var otherKeys = Object.keys(config1).concat(Object.keys(config2)).filter(function filterAxiosKeys(key) {
|
|
2850
|
+
return axiosKeys.indexOf(key) === -1;
|
|
2851
|
+
});
|
|
2852
|
+
utils$2$1.forEach(otherKeys, mergeDeepProperties);
|
|
2853
|
+
return config;
|
|
2854
|
+
};
|
|
2855
|
+
const name = "axios";
|
|
2856
|
+
const version = "0.21.4";
|
|
2857
|
+
const description = "Promise based HTTP client for the browser and node.js";
|
|
2858
|
+
const main = "index.js";
|
|
2859
|
+
const scripts = {
|
|
2860
|
+
test: "grunt test",
|
|
2861
|
+
start: "node ./sandbox/server.js",
|
|
2862
|
+
build: "NODE_ENV=production grunt build",
|
|
2863
|
+
preversion: "npm test",
|
|
2864
|
+
version: "npm run build && grunt version && git add -A dist && git add CHANGELOG.md bower.json package.json",
|
|
2865
|
+
postversion: "git push && git push --tags",
|
|
2866
|
+
examples: "node ./examples/server.js",
|
|
2867
|
+
coveralls: "cat coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js",
|
|
2868
|
+
fix: "eslint --fix lib/**/*.js"
|
|
2869
|
+
};
|
|
2870
|
+
const repository = {
|
|
2871
|
+
type: "git",
|
|
2872
|
+
url: "https://github.com/axios/axios.git"
|
|
2873
|
+
};
|
|
2874
|
+
const keywords = [
|
|
2875
|
+
"xhr",
|
|
2876
|
+
"http",
|
|
2877
|
+
"ajax",
|
|
2878
|
+
"promise",
|
|
2879
|
+
"node"
|
|
2880
|
+
];
|
|
2881
|
+
const author = "Matt Zabriskie";
|
|
2882
|
+
const license = "MIT";
|
|
2883
|
+
const bugs = {
|
|
2884
|
+
url: "https://github.com/axios/axios/issues"
|
|
2885
|
+
};
|
|
2886
|
+
const homepage = "https://axios-http.com";
|
|
2887
|
+
const devDependencies = {
|
|
2888
|
+
coveralls: "^3.0.0",
|
|
2889
|
+
"es6-promise": "^4.2.4",
|
|
2890
|
+
grunt: "^1.3.0",
|
|
2891
|
+
"grunt-banner": "^0.6.0",
|
|
2892
|
+
"grunt-cli": "^1.2.0",
|
|
2893
|
+
"grunt-contrib-clean": "^1.1.0",
|
|
2894
|
+
"grunt-contrib-watch": "^1.0.0",
|
|
2895
|
+
"grunt-eslint": "^23.0.0",
|
|
2896
|
+
"grunt-karma": "^4.0.0",
|
|
2897
|
+
"grunt-mocha-test": "^0.13.3",
|
|
2898
|
+
"grunt-ts": "^6.0.0-beta.19",
|
|
2899
|
+
"grunt-webpack": "^4.0.2",
|
|
2900
|
+
"istanbul-instrumenter-loader": "^1.0.0",
|
|
2901
|
+
"jasmine-core": "^2.4.1",
|
|
2902
|
+
karma: "^6.3.2",
|
|
2903
|
+
"karma-chrome-launcher": "^3.1.0",
|
|
2904
|
+
"karma-firefox-launcher": "^2.1.0",
|
|
2905
|
+
"karma-jasmine": "^1.1.1",
|
|
2906
|
+
"karma-jasmine-ajax": "^0.1.13",
|
|
2907
|
+
"karma-safari-launcher": "^1.0.0",
|
|
2908
|
+
"karma-sauce-launcher": "^4.3.6",
|
|
2909
|
+
"karma-sinon": "^1.0.5",
|
|
2910
|
+
"karma-sourcemap-loader": "^0.3.8",
|
|
2911
|
+
"karma-webpack": "^4.0.2",
|
|
2912
|
+
"load-grunt-tasks": "^3.5.2",
|
|
2913
|
+
minimist: "^1.2.0",
|
|
2914
|
+
mocha: "^8.2.1",
|
|
2915
|
+
sinon: "^4.5.0",
|
|
2916
|
+
"terser-webpack-plugin": "^4.2.3",
|
|
2917
|
+
typescript: "^4.0.5",
|
|
2918
|
+
"url-search-params": "^0.10.0",
|
|
2919
|
+
webpack: "^4.44.2",
|
|
2920
|
+
"webpack-dev-server": "^3.11.0"
|
|
2921
|
+
};
|
|
2922
|
+
const browser = {
|
|
2923
|
+
"./lib/adapters/http.js": "./lib/adapters/xhr.js"
|
|
2924
|
+
};
|
|
2925
|
+
const jsdelivr = "dist/axios.min.js";
|
|
2926
|
+
const unpkg = "dist/axios.min.js";
|
|
2927
|
+
const typings = "./index.d.ts";
|
|
2928
|
+
const dependencies = {
|
|
2929
|
+
"follow-redirects": "^1.14.0"
|
|
2930
|
+
};
|
|
2931
|
+
const bundlesize = [
|
|
2932
|
+
{
|
|
2933
|
+
path: "./dist/axios.min.js",
|
|
2934
|
+
threshold: "5kB"
|
|
2935
|
+
}
|
|
2936
|
+
];
|
|
2937
|
+
var require$$0 = {
|
|
2938
|
+
name,
|
|
2939
|
+
version,
|
|
2940
|
+
description,
|
|
2941
|
+
main,
|
|
2942
|
+
scripts,
|
|
2943
|
+
repository,
|
|
2944
|
+
keywords,
|
|
2945
|
+
author,
|
|
2946
|
+
license,
|
|
2947
|
+
bugs,
|
|
2948
|
+
homepage,
|
|
2949
|
+
devDependencies,
|
|
2950
|
+
browser,
|
|
2951
|
+
jsdelivr,
|
|
2952
|
+
unpkg,
|
|
2953
|
+
typings,
|
|
2954
|
+
dependencies,
|
|
2955
|
+
bundlesize
|
|
2956
|
+
};
|
|
2957
|
+
var pkg = require$$0;
|
|
2958
|
+
var validators$1$1 = {};
|
|
2959
|
+
["object", "boolean", "number", "function", "string", "symbol"].forEach(function(type, i) {
|
|
2960
|
+
validators$1$1[type] = function validator2(thing) {
|
|
2961
|
+
return typeof thing === type || "a" + (i < 1 ? "n " : " ") + type;
|
|
2962
|
+
};
|
|
2963
|
+
});
|
|
2964
|
+
var deprecatedWarnings$1 = {};
|
|
2965
|
+
var currentVerArr = pkg.version.split(".");
|
|
2966
|
+
function isOlderVersion(version2, thanVersion) {
|
|
2967
|
+
var pkgVersionArr = thanVersion ? thanVersion.split(".") : currentVerArr;
|
|
2968
|
+
var destVer = version2.split(".");
|
|
2969
|
+
for (var i = 0; i < 3; i++) {
|
|
2970
|
+
if (pkgVersionArr[i] > destVer[i]) {
|
|
2971
|
+
return true;
|
|
2972
|
+
} else if (pkgVersionArr[i] < destVer[i]) {
|
|
2973
|
+
return false;
|
|
2974
|
+
}
|
|
2975
|
+
}
|
|
2976
|
+
return false;
|
|
2977
|
+
}
|
|
2978
|
+
validators$1$1.transitional = function transitional2(validator2, version2, message) {
|
|
2979
|
+
var isDeprecated = version2 && isOlderVersion(version2);
|
|
2980
|
+
function formatMessage(opt, desc) {
|
|
2981
|
+
return "[Axios v" + pkg.version + "] Transitional option '" + opt + "'" + desc + (message ? ". " + message : "");
|
|
2982
|
+
}
|
|
2983
|
+
return function(value, opt, opts) {
|
|
2984
|
+
if (validator2 === false) {
|
|
2985
|
+
throw new Error(formatMessage(opt, " has been removed in " + version2));
|
|
2986
|
+
}
|
|
2987
|
+
if (isDeprecated && !deprecatedWarnings$1[opt]) {
|
|
2988
|
+
deprecatedWarnings$1[opt] = true;
|
|
2989
|
+
console.warn(formatMessage(opt, " has been deprecated since v" + version2 + " and will be removed in the near future"));
|
|
2990
|
+
}
|
|
2991
|
+
return validator2 ? validator2(value, opt, opts) : true;
|
|
2992
|
+
};
|
|
2993
|
+
};
|
|
2994
|
+
function assertOptions$1(options, schema, allowUnknown) {
|
|
2995
|
+
if (typeof options !== "object") {
|
|
2996
|
+
throw new TypeError("options must be an object");
|
|
2997
|
+
}
|
|
2998
|
+
var keys = Object.keys(options);
|
|
2999
|
+
var i = keys.length;
|
|
3000
|
+
while (i-- > 0) {
|
|
3001
|
+
var opt = keys[i];
|
|
3002
|
+
var validator2 = schema[opt];
|
|
3003
|
+
if (validator2) {
|
|
3004
|
+
var value = options[opt];
|
|
3005
|
+
var result = value === void 0 || validator2(value, opt, options);
|
|
3006
|
+
if (result !== true) {
|
|
3007
|
+
throw new TypeError("option " + opt + " must be " + result);
|
|
3008
|
+
}
|
|
3009
|
+
continue;
|
|
3010
|
+
}
|
|
3011
|
+
if (allowUnknown !== true) {
|
|
3012
|
+
throw Error("Unknown option " + opt);
|
|
3013
|
+
}
|
|
3014
|
+
}
|
|
3015
|
+
}
|
|
3016
|
+
var validator$1$1 = {
|
|
3017
|
+
isOlderVersion,
|
|
3018
|
+
assertOptions: assertOptions$1,
|
|
3019
|
+
validators: validators$1$1
|
|
3020
|
+
};
|
|
3021
|
+
var utils$1$1 = utils$d$1;
|
|
3022
|
+
var buildURL22 = buildURL$2$1;
|
|
3023
|
+
var InterceptorManager$2 = InterceptorManager_1$1;
|
|
3024
|
+
var dispatchRequest22 = dispatchRequest$1$1;
|
|
3025
|
+
var mergeConfig$1$1 = mergeConfig$2$1;
|
|
3026
|
+
var validator$2 = validator$1$1;
|
|
3027
|
+
var validators$2 = validator$2.validators;
|
|
3028
|
+
function Axios$1$1(instanceConfig) {
|
|
3029
|
+
this.defaults = instanceConfig;
|
|
3030
|
+
this.interceptors = {
|
|
3031
|
+
request: new InterceptorManager$2(),
|
|
3032
|
+
response: new InterceptorManager$2()
|
|
3033
|
+
};
|
|
3034
|
+
}
|
|
3035
|
+
Axios$1$1.prototype.request = function request2(config) {
|
|
3036
|
+
if (typeof config === "string") {
|
|
3037
|
+
config = arguments[1] || {};
|
|
3038
|
+
config.url = arguments[0];
|
|
3039
|
+
} else {
|
|
3040
|
+
config = config || {};
|
|
3041
|
+
}
|
|
3042
|
+
config = mergeConfig$1$1(this.defaults, config);
|
|
3043
|
+
if (config.method) {
|
|
3044
|
+
config.method = config.method.toLowerCase();
|
|
3045
|
+
} else if (this.defaults.method) {
|
|
3046
|
+
config.method = this.defaults.method.toLowerCase();
|
|
3047
|
+
} else {
|
|
3048
|
+
config.method = "get";
|
|
3049
|
+
}
|
|
3050
|
+
var transitional22 = config.transitional;
|
|
3051
|
+
if (transitional22 !== void 0) {
|
|
3052
|
+
validator$2.assertOptions(transitional22, {
|
|
3053
|
+
silentJSONParsing: validators$2.transitional(validators$2.boolean, "1.0.0"),
|
|
3054
|
+
forcedJSONParsing: validators$2.transitional(validators$2.boolean, "1.0.0"),
|
|
3055
|
+
clarifyTimeoutError: validators$2.transitional(validators$2.boolean, "1.0.0")
|
|
3056
|
+
}, false);
|
|
3057
|
+
}
|
|
3058
|
+
var requestInterceptorChain = [];
|
|
3059
|
+
var synchronousRequestInterceptors = true;
|
|
3060
|
+
this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
|
|
3061
|
+
if (typeof interceptor.runWhen === "function" && interceptor.runWhen(config) === false) {
|
|
3062
|
+
return;
|
|
3063
|
+
}
|
|
3064
|
+
synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous;
|
|
3065
|
+
requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected);
|
|
3066
|
+
});
|
|
3067
|
+
var responseInterceptorChain = [];
|
|
3068
|
+
this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
|
|
3069
|
+
responseInterceptorChain.push(interceptor.fulfilled, interceptor.rejected);
|
|
3070
|
+
});
|
|
3071
|
+
var promise;
|
|
3072
|
+
if (!synchronousRequestInterceptors) {
|
|
3073
|
+
var chain = [dispatchRequest22, void 0];
|
|
3074
|
+
Array.prototype.unshift.apply(chain, requestInterceptorChain);
|
|
3075
|
+
chain = chain.concat(responseInterceptorChain);
|
|
3076
|
+
promise = Promise.resolve(config);
|
|
3077
|
+
while (chain.length) {
|
|
3078
|
+
promise = promise.then(chain.shift(), chain.shift());
|
|
3079
|
+
}
|
|
3080
|
+
return promise;
|
|
3081
|
+
}
|
|
3082
|
+
var newConfig = config;
|
|
3083
|
+
while (requestInterceptorChain.length) {
|
|
3084
|
+
var onFulfilled = requestInterceptorChain.shift();
|
|
3085
|
+
var onRejected = requestInterceptorChain.shift();
|
|
3086
|
+
try {
|
|
3087
|
+
newConfig = onFulfilled(newConfig);
|
|
3088
|
+
} catch (error) {
|
|
3089
|
+
onRejected(error);
|
|
3090
|
+
break;
|
|
3091
|
+
}
|
|
3092
|
+
}
|
|
3093
|
+
try {
|
|
3094
|
+
promise = dispatchRequest22(newConfig);
|
|
3095
|
+
} catch (error) {
|
|
3096
|
+
return Promise.reject(error);
|
|
3097
|
+
}
|
|
3098
|
+
while (responseInterceptorChain.length) {
|
|
3099
|
+
promise = promise.then(responseInterceptorChain.shift(), responseInterceptorChain.shift());
|
|
3100
|
+
}
|
|
3101
|
+
return promise;
|
|
3102
|
+
};
|
|
3103
|
+
Axios$1$1.prototype.getUri = function getUri2(config) {
|
|
3104
|
+
config = mergeConfig$1$1(this.defaults, config);
|
|
3105
|
+
return buildURL22(config.url, config.params, config.paramsSerializer).replace(/^\?/, "");
|
|
3106
|
+
};
|
|
3107
|
+
utils$1$1.forEach(["delete", "get", "head", "options"], function forEachMethodNoData22(method) {
|
|
3108
|
+
Axios$1$1.prototype[method] = function(url, config) {
|
|
3109
|
+
return this.request(mergeConfig$1$1(config || {}, {
|
|
3110
|
+
method,
|
|
3111
|
+
url,
|
|
3112
|
+
data: (config || {}).data
|
|
3113
|
+
}));
|
|
3114
|
+
};
|
|
3115
|
+
});
|
|
3116
|
+
utils$1$1.forEach(["post", "put", "patch"], function forEachMethodWithData22(method) {
|
|
3117
|
+
Axios$1$1.prototype[method] = function(url, data2, config) {
|
|
3118
|
+
return this.request(mergeConfig$1$1(config || {}, {
|
|
3119
|
+
method,
|
|
3120
|
+
url,
|
|
3121
|
+
data: data2
|
|
3122
|
+
}));
|
|
3123
|
+
};
|
|
3124
|
+
});
|
|
3125
|
+
var Axios_1$1 = Axios$1$1;
|
|
3126
|
+
function Cancel$1$1(message) {
|
|
3127
|
+
this.message = message;
|
|
3128
|
+
}
|
|
3129
|
+
Cancel$1$1.prototype.toString = function toString22() {
|
|
3130
|
+
return "Cancel" + (this.message ? ": " + this.message : "");
|
|
3131
|
+
};
|
|
3132
|
+
Cancel$1$1.prototype.__CANCEL__ = true;
|
|
3133
|
+
var Cancel_1$1 = Cancel$1$1;
|
|
3134
|
+
var Cancel$4 = Cancel_1$1;
|
|
3135
|
+
function CancelToken$1(executor) {
|
|
3136
|
+
if (typeof executor !== "function") {
|
|
3137
|
+
throw new TypeError("executor must be a function.");
|
|
3138
|
+
}
|
|
3139
|
+
var resolvePromise;
|
|
3140
|
+
this.promise = new Promise(function promiseExecutor(resolve) {
|
|
3141
|
+
resolvePromise = resolve;
|
|
3142
|
+
});
|
|
3143
|
+
var token2 = this;
|
|
3144
|
+
executor(function cancel(message) {
|
|
3145
|
+
if (token2.reason) {
|
|
3146
|
+
return;
|
|
3147
|
+
}
|
|
3148
|
+
token2.reason = new Cancel$4(message);
|
|
3149
|
+
resolvePromise(token2.reason);
|
|
3150
|
+
});
|
|
3151
|
+
}
|
|
3152
|
+
CancelToken$1.prototype.throwIfRequested = function throwIfRequested2() {
|
|
3153
|
+
if (this.reason) {
|
|
3154
|
+
throw this.reason;
|
|
3155
|
+
}
|
|
3156
|
+
};
|
|
3157
|
+
CancelToken$1.source = function source2() {
|
|
3158
|
+
var cancel;
|
|
3159
|
+
var token2 = new CancelToken$1(function executor(c) {
|
|
3160
|
+
cancel = c;
|
|
3161
|
+
});
|
|
3162
|
+
return {
|
|
3163
|
+
token: token2,
|
|
3164
|
+
cancel
|
|
3165
|
+
};
|
|
3166
|
+
};
|
|
3167
|
+
var CancelToken_1$1 = CancelToken$1;
|
|
3168
|
+
var spread$1 = function spread22(callback) {
|
|
3169
|
+
return function wrap(arr) {
|
|
3170
|
+
return callback.apply(null, arr);
|
|
3171
|
+
};
|
|
3172
|
+
};
|
|
3173
|
+
var isAxiosError$1 = function isAxiosError22(payload) {
|
|
3174
|
+
return typeof payload === "object" && payload.isAxiosError === true;
|
|
3175
|
+
};
|
|
3176
|
+
var utils$e = utils$d$1;
|
|
3177
|
+
var bind22 = bind$2$1;
|
|
3178
|
+
var Axios$2 = Axios_1$1;
|
|
3179
|
+
var mergeConfig22 = mergeConfig$2$1;
|
|
3180
|
+
var defaults$5 = defaults_1$1;
|
|
3181
|
+
function createInstance$1(defaultConfig) {
|
|
3182
|
+
var context = new Axios$2(defaultConfig);
|
|
3183
|
+
var instance = bind22(Axios$2.prototype.request, context);
|
|
3184
|
+
utils$e.extend(instance, Axios$2.prototype, context);
|
|
3185
|
+
utils$e.extend(instance, context);
|
|
3186
|
+
return instance;
|
|
3187
|
+
}
|
|
3188
|
+
var axios$1$1 = createInstance$1(defaults$5);
|
|
3189
|
+
axios$1$1.Axios = Axios$2;
|
|
3190
|
+
axios$1$1.create = function create(instanceConfig) {
|
|
3191
|
+
return createInstance$1(mergeConfig22(axios$1$1.defaults, instanceConfig));
|
|
3192
|
+
};
|
|
3193
|
+
axios$1$1.Cancel = Cancel_1$1;
|
|
3194
|
+
axios$1$1.CancelToken = CancelToken_1$1;
|
|
3195
|
+
axios$1$1.isCancel = isCancel$1$1;
|
|
3196
|
+
axios$1$1.all = function all2(promises) {
|
|
3197
|
+
return Promise.all(promises);
|
|
3198
|
+
};
|
|
3199
|
+
axios$1$1.spread = spread$1;
|
|
3200
|
+
axios$1$1.isAxiosError = isAxiosError$1;
|
|
3201
|
+
axios$2$1.exports = axios$1$1;
|
|
3202
|
+
axios$2$1.exports.default = axios$1$1;
|
|
3203
|
+
var axios$3 = axios$2$1.exports;
|
|
3204
|
+
class HasuraStorageApi {
|
|
3205
|
+
constructor({ url }) {
|
|
3206
|
+
this.url = url;
|
|
3207
|
+
this.httpClient = axios$3.create({
|
|
3208
|
+
baseURL: this.url
|
|
3209
|
+
});
|
|
3210
|
+
}
|
|
3211
|
+
async upload(params) {
|
|
3212
|
+
try {
|
|
3213
|
+
const res = await this.httpClient.post("/files", params.file, {
|
|
3214
|
+
headers: __spreadValues2(__spreadValues2({}, this.generateUploadHeaders(params)), this.generateAuthHeaders())
|
|
3215
|
+
});
|
|
3216
|
+
return { fileMetadata: res.data, error: null };
|
|
3217
|
+
} catch (error) {
|
|
3218
|
+
return { fileMetadata: null, error };
|
|
3219
|
+
}
|
|
3220
|
+
}
|
|
3221
|
+
async getPresignedUrl(params) {
|
|
3222
|
+
try {
|
|
3223
|
+
const { fileId } = params;
|
|
3224
|
+
const res = await this.httpClient.get(`/files/${fileId}/presignedurl`, {
|
|
3225
|
+
headers: __spreadValues2({}, this.generateAuthHeaders())
|
|
3226
|
+
});
|
|
3227
|
+
return { presignedUrl: res.data, error: null };
|
|
3228
|
+
} catch (error) {
|
|
3229
|
+
return { presignedUrl: null, error };
|
|
3230
|
+
}
|
|
3231
|
+
}
|
|
3232
|
+
async delete(params) {
|
|
3233
|
+
try {
|
|
3234
|
+
const { fileId } = params;
|
|
3235
|
+
await this.httpClient.delete(`/files/${fileId}`, {
|
|
3236
|
+
headers: __spreadValues2({}, this.generateAuthHeaders())
|
|
3237
|
+
});
|
|
3238
|
+
return { error: null };
|
|
3239
|
+
} catch (error) {
|
|
3240
|
+
return { error };
|
|
3241
|
+
}
|
|
3242
|
+
}
|
|
3243
|
+
setAccessToken(accessToken) {
|
|
3244
|
+
this.accessToken = accessToken;
|
|
3245
|
+
}
|
|
3246
|
+
generateUploadHeaders(params) {
|
|
3247
|
+
const { bucketId, name: name2, id } = params;
|
|
3248
|
+
const uploadheaders = {};
|
|
3249
|
+
if (bucketId) {
|
|
3250
|
+
uploadheaders["x-nhost-bucket-id"] = bucketId;
|
|
3251
|
+
}
|
|
3252
|
+
if (id) {
|
|
3253
|
+
uploadheaders["x-nhost-file-id"] = id;
|
|
3254
|
+
}
|
|
3255
|
+
if (name2) {
|
|
3256
|
+
uploadheaders["x-nhost-file-name"] = name2;
|
|
3257
|
+
}
|
|
3258
|
+
return uploadheaders;
|
|
3259
|
+
}
|
|
3260
|
+
generateAuthHeaders() {
|
|
3261
|
+
if (!this.accessToken) {
|
|
3262
|
+
return null;
|
|
3263
|
+
}
|
|
3264
|
+
return {
|
|
3265
|
+
Authorization: `Bearer ${this.accessToken}`
|
|
3266
|
+
};
|
|
3267
|
+
}
|
|
3268
|
+
}
|
|
3269
|
+
class HasuraStorageClient {
|
|
3270
|
+
constructor({ url }) {
|
|
3271
|
+
this.url = url;
|
|
3272
|
+
this.api = new HasuraStorageApi({ url });
|
|
3273
|
+
}
|
|
3274
|
+
async upload(params) {
|
|
3275
|
+
const file = new FormData();
|
|
3276
|
+
file.append("file", params.file);
|
|
3277
|
+
const { fileMetadata, error } = await this.api.upload(__spreadProps2(__spreadValues2({}, params), {
|
|
3278
|
+
file
|
|
3279
|
+
}));
|
|
3280
|
+
if (error) {
|
|
3281
|
+
return { fileMetadata: null, error };
|
|
3282
|
+
}
|
|
3283
|
+
if (!fileMetadata) {
|
|
3284
|
+
return { fileMetadata: null, error: new Error("Invalid file returned") };
|
|
3285
|
+
}
|
|
3286
|
+
return { fileMetadata, error: null };
|
|
3287
|
+
}
|
|
3288
|
+
getUrl(params) {
|
|
3289
|
+
const { fileId } = params;
|
|
3290
|
+
return `${this.url}/files/${fileId}`;
|
|
3291
|
+
}
|
|
3292
|
+
async getPresignedUrl(params) {
|
|
3293
|
+
const { presignedUrl, error } = await this.api.getPresignedUrl(params);
|
|
3294
|
+
if (error) {
|
|
3295
|
+
return { presignedUrl: null, error };
|
|
3296
|
+
}
|
|
3297
|
+
if (!presignedUrl) {
|
|
3298
|
+
return { presignedUrl: null, error: new Error("Invalid file id") };
|
|
3299
|
+
}
|
|
3300
|
+
return { presignedUrl, error: null };
|
|
3301
|
+
}
|
|
3302
|
+
async delete(params) {
|
|
3303
|
+
const { error } = await this.api.delete(params);
|
|
3304
|
+
if (error) {
|
|
3305
|
+
return { error };
|
|
3306
|
+
}
|
|
3307
|
+
return { error: null };
|
|
3308
|
+
}
|
|
3309
|
+
setAccessToken(accessToken) {
|
|
3310
|
+
this.api.setAccessToken(accessToken);
|
|
3311
|
+
}
|
|
3312
|
+
}
|
|
3313
|
+
var axios$2 = { exports: {} };
|
|
3314
|
+
var bind$2 = function bind3(fn, thisArg) {
|
|
3315
|
+
return function wrap() {
|
|
3316
|
+
var args = new Array(arguments.length);
|
|
3317
|
+
for (var i = 0; i < args.length; i++) {
|
|
3318
|
+
args[i] = arguments[i];
|
|
3319
|
+
}
|
|
3320
|
+
return fn.apply(thisArg, args);
|
|
3321
|
+
};
|
|
3322
|
+
};
|
|
3323
|
+
var bind$1 = bind$2;
|
|
3324
|
+
var toString = Object.prototype.toString;
|
|
3325
|
+
function isArray(val) {
|
|
3326
|
+
return toString.call(val) === "[object Array]";
|
|
3327
|
+
}
|
|
3328
|
+
function isUndefined(val) {
|
|
3329
|
+
return typeof val === "undefined";
|
|
3330
|
+
}
|
|
3331
|
+
function isBuffer(val) {
|
|
3332
|
+
return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor) && typeof val.constructor.isBuffer === "function" && val.constructor.isBuffer(val);
|
|
3333
|
+
}
|
|
3334
|
+
function isArrayBuffer(val) {
|
|
3335
|
+
return toString.call(val) === "[object ArrayBuffer]";
|
|
3336
|
+
}
|
|
3337
|
+
function isFormData(val) {
|
|
3338
|
+
return typeof FormData !== "undefined" && val instanceof FormData;
|
|
3339
|
+
}
|
|
3340
|
+
function isArrayBufferView(val) {
|
|
3341
|
+
var result;
|
|
3342
|
+
if (typeof ArrayBuffer !== "undefined" && ArrayBuffer.isView) {
|
|
3343
|
+
result = ArrayBuffer.isView(val);
|
|
3344
|
+
} else {
|
|
3345
|
+
result = val && val.buffer && val.buffer instanceof ArrayBuffer;
|
|
3346
|
+
}
|
|
3347
|
+
return result;
|
|
3348
|
+
}
|
|
3349
|
+
function isString(val) {
|
|
3350
|
+
return typeof val === "string";
|
|
3351
|
+
}
|
|
3352
|
+
function isNumber(val) {
|
|
3353
|
+
return typeof val === "number";
|
|
3354
|
+
}
|
|
3355
|
+
function isObject(val) {
|
|
3356
|
+
return val !== null && typeof val === "object";
|
|
3357
|
+
}
|
|
3358
|
+
function isPlainObject(val) {
|
|
3359
|
+
if (toString.call(val) !== "[object Object]") {
|
|
3360
|
+
return false;
|
|
3361
|
+
}
|
|
3362
|
+
var prototype = Object.getPrototypeOf(val);
|
|
3363
|
+
return prototype === null || prototype === Object.prototype;
|
|
3364
|
+
}
|
|
3365
|
+
function isDate(val) {
|
|
3366
|
+
return toString.call(val) === "[object Date]";
|
|
3367
|
+
}
|
|
3368
|
+
function isFile(val) {
|
|
3369
|
+
return toString.call(val) === "[object File]";
|
|
3370
|
+
}
|
|
3371
|
+
function isBlob(val) {
|
|
3372
|
+
return toString.call(val) === "[object Blob]";
|
|
3373
|
+
}
|
|
3374
|
+
function isFunction(val) {
|
|
3375
|
+
return toString.call(val) === "[object Function]";
|
|
3376
|
+
}
|
|
3377
|
+
function isStream(val) {
|
|
3378
|
+
return isObject(val) && isFunction(val.pipe);
|
|
3379
|
+
}
|
|
3380
|
+
function isURLSearchParams(val) {
|
|
3381
|
+
return typeof URLSearchParams !== "undefined" && val instanceof URLSearchParams;
|
|
3382
|
+
}
|
|
3383
|
+
function trim(str) {
|
|
3384
|
+
return str.trim ? str.trim() : str.replace(/^\s+|\s+$/g, "");
|
|
3385
|
+
}
|
|
3386
|
+
function isStandardBrowserEnv() {
|
|
3387
|
+
if (typeof navigator !== "undefined" && (navigator.product === "ReactNative" || navigator.product === "NativeScript" || navigator.product === "NS")) {
|
|
3388
|
+
return false;
|
|
3389
|
+
}
|
|
3390
|
+
return typeof window !== "undefined" && typeof document !== "undefined";
|
|
3391
|
+
}
|
|
3392
|
+
function forEach(obj, fn) {
|
|
3393
|
+
if (obj === null || typeof obj === "undefined") {
|
|
3394
|
+
return;
|
|
3395
|
+
}
|
|
3396
|
+
if (typeof obj !== "object") {
|
|
3397
|
+
obj = [obj];
|
|
3398
|
+
}
|
|
3399
|
+
if (isArray(obj)) {
|
|
3400
|
+
for (var i = 0, l = obj.length; i < l; i++) {
|
|
3401
|
+
fn.call(null, obj[i], i, obj);
|
|
3402
|
+
}
|
|
3403
|
+
} else {
|
|
3404
|
+
for (var key in obj) {
|
|
3405
|
+
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
3406
|
+
fn.call(null, obj[key], key, obj);
|
|
3407
|
+
}
|
|
3408
|
+
}
|
|
3409
|
+
}
|
|
3410
|
+
}
|
|
3411
|
+
function merge() {
|
|
3412
|
+
var result = {};
|
|
3413
|
+
function assignValue(val, key) {
|
|
3414
|
+
if (isPlainObject(result[key]) && isPlainObject(val)) {
|
|
3415
|
+
result[key] = merge(result[key], val);
|
|
3416
|
+
} else if (isPlainObject(val)) {
|
|
3417
|
+
result[key] = merge({}, val);
|
|
3418
|
+
} else if (isArray(val)) {
|
|
3419
|
+
result[key] = val.slice();
|
|
3420
|
+
} else {
|
|
3421
|
+
result[key] = val;
|
|
3422
|
+
}
|
|
3423
|
+
}
|
|
3424
|
+
for (var i = 0, l = arguments.length; i < l; i++) {
|
|
3425
|
+
forEach(arguments[i], assignValue);
|
|
3426
|
+
}
|
|
3427
|
+
return result;
|
|
3428
|
+
}
|
|
3429
|
+
function extend(a, b, thisArg) {
|
|
3430
|
+
forEach(b, function assignValue(val, key) {
|
|
3431
|
+
if (thisArg && typeof val === "function") {
|
|
3432
|
+
a[key] = bind$1(val, thisArg);
|
|
3433
|
+
} else {
|
|
3434
|
+
a[key] = val;
|
|
3435
|
+
}
|
|
3436
|
+
});
|
|
3437
|
+
return a;
|
|
3438
|
+
}
|
|
3439
|
+
function stripBOM(content) {
|
|
3440
|
+
if (content.charCodeAt(0) === 65279) {
|
|
3441
|
+
content = content.slice(1);
|
|
3442
|
+
}
|
|
3443
|
+
return content;
|
|
3444
|
+
}
|
|
3445
|
+
var utils$d = {
|
|
3446
|
+
isArray,
|
|
3447
|
+
isArrayBuffer,
|
|
3448
|
+
isBuffer,
|
|
3449
|
+
isFormData,
|
|
3450
|
+
isArrayBufferView,
|
|
3451
|
+
isString,
|
|
3452
|
+
isNumber,
|
|
3453
|
+
isObject,
|
|
3454
|
+
isPlainObject,
|
|
3455
|
+
isUndefined,
|
|
3456
|
+
isDate,
|
|
3457
|
+
isFile,
|
|
3458
|
+
isBlob,
|
|
3459
|
+
isFunction,
|
|
3460
|
+
isStream,
|
|
3461
|
+
isURLSearchParams,
|
|
3462
|
+
isStandardBrowserEnv,
|
|
3463
|
+
forEach,
|
|
3464
|
+
merge,
|
|
3465
|
+
extend,
|
|
3466
|
+
trim,
|
|
3467
|
+
stripBOM
|
|
3468
|
+
};
|
|
3469
|
+
var utils$c = utils$d;
|
|
3470
|
+
function encode(val) {
|
|
3471
|
+
return encodeURIComponent(val).replace(/%3A/gi, ":").replace(/%24/g, "$").replace(/%2C/gi, ",").replace(/%20/g, "+").replace(/%5B/gi, "[").replace(/%5D/gi, "]");
|
|
3472
|
+
}
|
|
3473
|
+
var buildURL$2 = function buildURL3(url, params, paramsSerializer) {
|
|
3474
|
+
if (!params) {
|
|
3475
|
+
return url;
|
|
3476
|
+
}
|
|
3477
|
+
var serializedParams;
|
|
3478
|
+
if (paramsSerializer) {
|
|
3479
|
+
serializedParams = paramsSerializer(params);
|
|
3480
|
+
} else if (utils$c.isURLSearchParams(params)) {
|
|
3481
|
+
serializedParams = params.toString();
|
|
3482
|
+
} else {
|
|
3483
|
+
var parts = [];
|
|
3484
|
+
utils$c.forEach(params, function serialize(val, key) {
|
|
3485
|
+
if (val === null || typeof val === "undefined") {
|
|
3486
|
+
return;
|
|
3487
|
+
}
|
|
3488
|
+
if (utils$c.isArray(val)) {
|
|
3489
|
+
key = key + "[]";
|
|
3490
|
+
} else {
|
|
3491
|
+
val = [val];
|
|
3492
|
+
}
|
|
3493
|
+
utils$c.forEach(val, function parseValue(v) {
|
|
3494
|
+
if (utils$c.isDate(v)) {
|
|
3495
|
+
v = v.toISOString();
|
|
3496
|
+
} else if (utils$c.isObject(v)) {
|
|
3497
|
+
v = JSON.stringify(v);
|
|
3498
|
+
}
|
|
3499
|
+
parts.push(encode(key) + "=" + encode(v));
|
|
3500
|
+
});
|
|
3501
|
+
});
|
|
3502
|
+
serializedParams = parts.join("&");
|
|
3503
|
+
}
|
|
3504
|
+
if (serializedParams) {
|
|
3505
|
+
var hashmarkIndex = url.indexOf("#");
|
|
3506
|
+
if (hashmarkIndex !== -1) {
|
|
3507
|
+
url = url.slice(0, hashmarkIndex);
|
|
3508
|
+
}
|
|
3509
|
+
url += (url.indexOf("?") === -1 ? "?" : "&") + serializedParams;
|
|
3510
|
+
}
|
|
3511
|
+
return url;
|
|
3512
|
+
};
|
|
3513
|
+
var utils$b = utils$d;
|
|
3514
|
+
function InterceptorManager$1() {
|
|
3515
|
+
this.handlers = [];
|
|
3516
|
+
}
|
|
3517
|
+
InterceptorManager$1.prototype.use = function use3(fulfilled, rejected, options) {
|
|
3518
|
+
this.handlers.push({
|
|
3519
|
+
fulfilled,
|
|
3520
|
+
rejected,
|
|
3521
|
+
synchronous: options ? options.synchronous : false,
|
|
3522
|
+
runWhen: options ? options.runWhen : null
|
|
3523
|
+
});
|
|
3524
|
+
return this.handlers.length - 1;
|
|
3525
|
+
};
|
|
3526
|
+
InterceptorManager$1.prototype.eject = function eject3(id) {
|
|
3527
|
+
if (this.handlers[id]) {
|
|
3528
|
+
this.handlers[id] = null;
|
|
3529
|
+
}
|
|
3530
|
+
};
|
|
3531
|
+
InterceptorManager$1.prototype.forEach = function forEach3(fn) {
|
|
3532
|
+
utils$b.forEach(this.handlers, function forEachHandler(h) {
|
|
3533
|
+
if (h !== null) {
|
|
3534
|
+
fn(h);
|
|
3535
|
+
}
|
|
3536
|
+
});
|
|
3537
|
+
};
|
|
3538
|
+
var InterceptorManager_1 = InterceptorManager$1;
|
|
3539
|
+
var utils$a = utils$d;
|
|
3540
|
+
var normalizeHeaderName$1 = function normalizeHeaderName3(headers, normalizedName) {
|
|
3541
|
+
utils$a.forEach(headers, function processHeader(value, name2) {
|
|
3542
|
+
if (name2 !== normalizedName && name2.toUpperCase() === normalizedName.toUpperCase()) {
|
|
3543
|
+
headers[normalizedName] = value;
|
|
3544
|
+
delete headers[name2];
|
|
3545
|
+
}
|
|
3546
|
+
});
|
|
3547
|
+
};
|
|
3548
|
+
var enhanceError$2 = function enhanceError3(error, config, code, request4, response) {
|
|
3549
|
+
error.config = config;
|
|
3550
|
+
if (code) {
|
|
3551
|
+
error.code = code;
|
|
3552
|
+
}
|
|
3553
|
+
error.request = request4;
|
|
3554
|
+
error.response = response;
|
|
3555
|
+
error.isAxiosError = true;
|
|
3556
|
+
error.toJSON = function toJSON() {
|
|
3557
|
+
return {
|
|
3558
|
+
message: this.message,
|
|
3559
|
+
name: this.name,
|
|
3560
|
+
description: this.description,
|
|
3561
|
+
number: this.number,
|
|
3562
|
+
fileName: this.fileName,
|
|
3563
|
+
lineNumber: this.lineNumber,
|
|
3564
|
+
columnNumber: this.columnNumber,
|
|
3565
|
+
stack: this.stack,
|
|
3566
|
+
config: this.config,
|
|
3567
|
+
code: this.code,
|
|
3568
|
+
status: this.response && this.response.status ? this.response.status : null
|
|
3569
|
+
};
|
|
3570
|
+
};
|
|
3571
|
+
return error;
|
|
3572
|
+
};
|
|
3573
|
+
var enhanceError$1 = enhanceError$2;
|
|
3574
|
+
var createError$2 = function createError3(message, config, code, request4, response) {
|
|
3575
|
+
var error = new Error(message);
|
|
3576
|
+
return enhanceError$1(error, config, code, request4, response);
|
|
3577
|
+
};
|
|
3578
|
+
var createError$1 = createError$2;
|
|
3579
|
+
var settle$1 = function settle3(resolve, reject, response) {
|
|
3580
|
+
var validateStatus4 = response.config.validateStatus;
|
|
3581
|
+
if (!response.status || !validateStatus4 || validateStatus4(response.status)) {
|
|
3582
|
+
resolve(response);
|
|
3583
|
+
} else {
|
|
3584
|
+
reject(createError$1("Request failed with status code " + response.status, response.config, null, response.request, response));
|
|
3585
|
+
}
|
|
3586
|
+
};
|
|
3587
|
+
var utils$9 = utils$d;
|
|
3588
|
+
var cookies$1 = utils$9.isStandardBrowserEnv() ? function standardBrowserEnv4() {
|
|
3589
|
+
return {
|
|
3590
|
+
write: function write(name2, value, expires, path, domain, secure) {
|
|
3591
|
+
var cookie = [];
|
|
3592
|
+
cookie.push(name2 + "=" + encodeURIComponent(value));
|
|
3593
|
+
if (utils$9.isNumber(expires)) {
|
|
3594
|
+
cookie.push("expires=" + new Date(expires).toGMTString());
|
|
3595
|
+
}
|
|
3596
|
+
if (utils$9.isString(path)) {
|
|
3597
|
+
cookie.push("path=" + path);
|
|
3598
|
+
}
|
|
3599
|
+
if (utils$9.isString(domain)) {
|
|
3600
|
+
cookie.push("domain=" + domain);
|
|
3601
|
+
}
|
|
3602
|
+
if (secure === true) {
|
|
3603
|
+
cookie.push("secure");
|
|
3604
|
+
}
|
|
3605
|
+
document.cookie = cookie.join("; ");
|
|
3606
|
+
},
|
|
3607
|
+
read: function read(name2) {
|
|
3608
|
+
var match = document.cookie.match(new RegExp("(^|;\\s*)(" + name2 + ")=([^;]*)"));
|
|
3609
|
+
return match ? decodeURIComponent(match[3]) : null;
|
|
3610
|
+
},
|
|
3611
|
+
remove: function remove(name2) {
|
|
3612
|
+
this.write(name2, "", Date.now() - 864e5);
|
|
3613
|
+
}
|
|
3614
|
+
};
|
|
3615
|
+
}() : function nonStandardBrowserEnv4() {
|
|
3616
|
+
return {
|
|
3617
|
+
write: function write() {
|
|
3618
|
+
},
|
|
3619
|
+
read: function read() {
|
|
3620
|
+
return null;
|
|
3621
|
+
},
|
|
3622
|
+
remove: function remove() {
|
|
3623
|
+
}
|
|
3624
|
+
};
|
|
3625
|
+
}();
|
|
3626
|
+
var isAbsoluteURL$1 = function isAbsoluteURL3(url) {
|
|
3627
|
+
return /^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(url);
|
|
3628
|
+
};
|
|
3629
|
+
var combineURLs$1 = function combineURLs3(baseURL, relativeURL) {
|
|
3630
|
+
return relativeURL ? baseURL.replace(/\/+$/, "") + "/" + relativeURL.replace(/^\/+/, "") : baseURL;
|
|
3631
|
+
};
|
|
3632
|
+
var isAbsoluteURL4 = isAbsoluteURL$1;
|
|
3633
|
+
var combineURLs4 = combineURLs$1;
|
|
3634
|
+
var buildFullPath$1 = function buildFullPath3(baseURL, requestedURL) {
|
|
3635
|
+
if (baseURL && !isAbsoluteURL4(requestedURL)) {
|
|
3636
|
+
return combineURLs4(baseURL, requestedURL);
|
|
3637
|
+
}
|
|
3638
|
+
return requestedURL;
|
|
3639
|
+
};
|
|
3640
|
+
var utils$8 = utils$d;
|
|
3641
|
+
var ignoreDuplicateOf = [
|
|
3642
|
+
"age",
|
|
3643
|
+
"authorization",
|
|
3644
|
+
"content-length",
|
|
3645
|
+
"content-type",
|
|
3646
|
+
"etag",
|
|
3647
|
+
"expires",
|
|
3648
|
+
"from",
|
|
3649
|
+
"host",
|
|
3650
|
+
"if-modified-since",
|
|
3651
|
+
"if-unmodified-since",
|
|
3652
|
+
"last-modified",
|
|
3653
|
+
"location",
|
|
3654
|
+
"max-forwards",
|
|
3655
|
+
"proxy-authorization",
|
|
3656
|
+
"referer",
|
|
3657
|
+
"retry-after",
|
|
3658
|
+
"user-agent"
|
|
3659
|
+
];
|
|
3660
|
+
var parseHeaders$1 = function parseHeaders3(headers) {
|
|
3661
|
+
var parsed = {};
|
|
3662
|
+
var key;
|
|
3663
|
+
var val;
|
|
3664
|
+
var i;
|
|
3665
|
+
if (!headers) {
|
|
3666
|
+
return parsed;
|
|
3667
|
+
}
|
|
3668
|
+
utils$8.forEach(headers.split("\n"), function parser(line) {
|
|
3669
|
+
i = line.indexOf(":");
|
|
3670
|
+
key = utils$8.trim(line.substr(0, i)).toLowerCase();
|
|
3671
|
+
val = utils$8.trim(line.substr(i + 1));
|
|
3672
|
+
if (key) {
|
|
3673
|
+
if (parsed[key] && ignoreDuplicateOf.indexOf(key) >= 0) {
|
|
3674
|
+
return;
|
|
3675
|
+
}
|
|
3676
|
+
if (key === "set-cookie") {
|
|
3677
|
+
parsed[key] = (parsed[key] ? parsed[key] : []).concat([val]);
|
|
3678
|
+
} else {
|
|
3679
|
+
parsed[key] = parsed[key] ? parsed[key] + ", " + val : val;
|
|
3680
|
+
}
|
|
3681
|
+
}
|
|
3682
|
+
});
|
|
3683
|
+
return parsed;
|
|
3684
|
+
};
|
|
3685
|
+
var utils$7 = utils$d;
|
|
3686
|
+
var isURLSameOrigin$1 = utils$7.isStandardBrowserEnv() ? function standardBrowserEnv5() {
|
|
3687
|
+
var msie = /(msie|trident)/i.test(navigator.userAgent);
|
|
3688
|
+
var urlParsingNode = document.createElement("a");
|
|
3689
|
+
var originURL;
|
|
3690
|
+
function resolveURL(url) {
|
|
3691
|
+
var href = url;
|
|
3692
|
+
if (msie) {
|
|
3693
|
+
urlParsingNode.setAttribute("href", href);
|
|
3694
|
+
href = urlParsingNode.href;
|
|
3695
|
+
}
|
|
3696
|
+
urlParsingNode.setAttribute("href", href);
|
|
3697
|
+
return {
|
|
3698
|
+
href: urlParsingNode.href,
|
|
3699
|
+
protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, "") : "",
|
|
3700
|
+
host: urlParsingNode.host,
|
|
3701
|
+
search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, "") : "",
|
|
3702
|
+
hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, "") : "",
|
|
3703
|
+
hostname: urlParsingNode.hostname,
|
|
3704
|
+
port: urlParsingNode.port,
|
|
3705
|
+
pathname: urlParsingNode.pathname.charAt(0) === "/" ? urlParsingNode.pathname : "/" + urlParsingNode.pathname
|
|
3706
|
+
};
|
|
3707
|
+
}
|
|
3708
|
+
originURL = resolveURL(window.location.href);
|
|
3709
|
+
return function isURLSameOrigin2(requestURL) {
|
|
3710
|
+
var parsed = utils$7.isString(requestURL) ? resolveURL(requestURL) : requestURL;
|
|
3711
|
+
return parsed.protocol === originURL.protocol && parsed.host === originURL.host;
|
|
3712
|
+
};
|
|
3713
|
+
}() : function nonStandardBrowserEnv5() {
|
|
3714
|
+
return function isURLSameOrigin2() {
|
|
3715
|
+
return true;
|
|
3716
|
+
};
|
|
3717
|
+
}();
|
|
3718
|
+
function Cancel$3(message) {
|
|
3719
|
+
this.message = message;
|
|
3720
|
+
}
|
|
3721
|
+
Cancel$3.prototype.toString = function toString3() {
|
|
3722
|
+
return "Cancel" + (this.message ? ": " + this.message : "");
|
|
3723
|
+
};
|
|
3724
|
+
Cancel$3.prototype.__CANCEL__ = true;
|
|
3725
|
+
var Cancel_1 = Cancel$3;
|
|
3726
|
+
var utils$6 = utils$d;
|
|
3727
|
+
var settle4 = settle$1;
|
|
3728
|
+
var cookies = cookies$1;
|
|
3729
|
+
var buildURL$1 = buildURL$2;
|
|
3730
|
+
var buildFullPath4 = buildFullPath$1;
|
|
3731
|
+
var parseHeaders4 = parseHeaders$1;
|
|
3732
|
+
var isURLSameOrigin = isURLSameOrigin$1;
|
|
3733
|
+
var createError4 = createError$2;
|
|
3734
|
+
var defaults$4 = defaults_1;
|
|
3735
|
+
var Cancel$2 = Cancel_1;
|
|
3736
|
+
var xhr = function xhrAdapter3(config) {
|
|
3737
|
+
return new Promise(function dispatchXhrRequest(resolve, reject) {
|
|
3738
|
+
var requestData = config.data;
|
|
3739
|
+
var requestHeaders = config.headers;
|
|
3740
|
+
var responseType = config.responseType;
|
|
3741
|
+
var onCanceled;
|
|
3742
|
+
function done() {
|
|
3743
|
+
if (config.cancelToken) {
|
|
3744
|
+
config.cancelToken.unsubscribe(onCanceled);
|
|
3745
|
+
}
|
|
3746
|
+
if (config.signal) {
|
|
3747
|
+
config.signal.removeEventListener("abort", onCanceled);
|
|
3748
|
+
}
|
|
3749
|
+
}
|
|
3750
|
+
if (utils$6.isFormData(requestData)) {
|
|
3751
|
+
delete requestHeaders["Content-Type"];
|
|
3752
|
+
}
|
|
3753
|
+
var request4 = new XMLHttpRequest();
|
|
3754
|
+
if (config.auth) {
|
|
3755
|
+
var username = config.auth.username || "";
|
|
3756
|
+
var password = config.auth.password ? unescape(encodeURIComponent(config.auth.password)) : "";
|
|
3757
|
+
requestHeaders.Authorization = "Basic " + btoa(username + ":" + password);
|
|
3758
|
+
}
|
|
3759
|
+
var fullPath = buildFullPath4(config.baseURL, config.url);
|
|
3760
|
+
request4.open(config.method.toUpperCase(), buildURL$1(fullPath, config.params, config.paramsSerializer), true);
|
|
3761
|
+
request4.timeout = config.timeout;
|
|
3762
|
+
function onloadend() {
|
|
3763
|
+
if (!request4) {
|
|
3764
|
+
return;
|
|
3765
|
+
}
|
|
3766
|
+
var responseHeaders = "getAllResponseHeaders" in request4 ? parseHeaders4(request4.getAllResponseHeaders()) : null;
|
|
3767
|
+
var responseData = !responseType || responseType === "text" || responseType === "json" ? request4.responseText : request4.response;
|
|
3768
|
+
var response = {
|
|
3769
|
+
data: responseData,
|
|
3770
|
+
status: request4.status,
|
|
3771
|
+
statusText: request4.statusText,
|
|
3772
|
+
headers: responseHeaders,
|
|
3773
|
+
config,
|
|
3774
|
+
request: request4
|
|
3775
|
+
};
|
|
3776
|
+
settle4(function _resolve(value) {
|
|
3777
|
+
resolve(value);
|
|
3778
|
+
done();
|
|
3779
|
+
}, function _reject(err) {
|
|
3780
|
+
reject(err);
|
|
3781
|
+
done();
|
|
3782
|
+
}, response);
|
|
3783
|
+
request4 = null;
|
|
3784
|
+
}
|
|
3785
|
+
if ("onloadend" in request4) {
|
|
3786
|
+
request4.onloadend = onloadend;
|
|
3787
|
+
} else {
|
|
3788
|
+
request4.onreadystatechange = function handleLoad() {
|
|
3789
|
+
if (!request4 || request4.readyState !== 4) {
|
|
3790
|
+
return;
|
|
3791
|
+
}
|
|
3792
|
+
if (request4.status === 0 && !(request4.responseURL && request4.responseURL.indexOf("file:") === 0)) {
|
|
3793
|
+
return;
|
|
3794
|
+
}
|
|
3795
|
+
setTimeout(onloadend);
|
|
3796
|
+
};
|
|
3797
|
+
}
|
|
3798
|
+
request4.onabort = function handleAbort() {
|
|
3799
|
+
if (!request4) {
|
|
3800
|
+
return;
|
|
3801
|
+
}
|
|
3802
|
+
reject(createError4("Request aborted", config, "ECONNABORTED", request4));
|
|
3803
|
+
request4 = null;
|
|
3804
|
+
};
|
|
3805
|
+
request4.onerror = function handleError() {
|
|
3806
|
+
reject(createError4("Network Error", config, null, request4));
|
|
3807
|
+
request4 = null;
|
|
3808
|
+
};
|
|
3809
|
+
request4.ontimeout = function handleTimeout() {
|
|
3810
|
+
var timeoutErrorMessage = config.timeout ? "timeout of " + config.timeout + "ms exceeded" : "timeout exceeded";
|
|
3811
|
+
var transitional4 = config.transitional || defaults$4.transitional;
|
|
3812
|
+
if (config.timeoutErrorMessage) {
|
|
3813
|
+
timeoutErrorMessage = config.timeoutErrorMessage;
|
|
3814
|
+
}
|
|
3815
|
+
reject(createError4(timeoutErrorMessage, config, transitional4.clarifyTimeoutError ? "ETIMEDOUT" : "ECONNABORTED", request4));
|
|
3816
|
+
request4 = null;
|
|
3817
|
+
};
|
|
3818
|
+
if (utils$6.isStandardBrowserEnv()) {
|
|
3819
|
+
var xsrfValue = (config.withCredentials || isURLSameOrigin(fullPath)) && config.xsrfCookieName ? cookies.read(config.xsrfCookieName) : void 0;
|
|
3820
|
+
if (xsrfValue) {
|
|
3821
|
+
requestHeaders[config.xsrfHeaderName] = xsrfValue;
|
|
3822
|
+
}
|
|
3823
|
+
}
|
|
3824
|
+
if ("setRequestHeader" in request4) {
|
|
3825
|
+
utils$6.forEach(requestHeaders, function setRequestHeader(val, key) {
|
|
3826
|
+
if (typeof requestData === "undefined" && key.toLowerCase() === "content-type") {
|
|
3827
|
+
delete requestHeaders[key];
|
|
3828
|
+
} else {
|
|
3829
|
+
request4.setRequestHeader(key, val);
|
|
3830
|
+
}
|
|
3831
|
+
});
|
|
3832
|
+
}
|
|
3833
|
+
if (!utils$6.isUndefined(config.withCredentials)) {
|
|
3834
|
+
request4.withCredentials = !!config.withCredentials;
|
|
3835
|
+
}
|
|
3836
|
+
if (responseType && responseType !== "json") {
|
|
3837
|
+
request4.responseType = config.responseType;
|
|
3838
|
+
}
|
|
3839
|
+
if (typeof config.onDownloadProgress === "function") {
|
|
3840
|
+
request4.addEventListener("progress", config.onDownloadProgress);
|
|
3841
|
+
}
|
|
3842
|
+
if (typeof config.onUploadProgress === "function" && request4.upload) {
|
|
3843
|
+
request4.upload.addEventListener("progress", config.onUploadProgress);
|
|
3844
|
+
}
|
|
3845
|
+
if (config.cancelToken || config.signal) {
|
|
3846
|
+
onCanceled = function(cancel) {
|
|
3847
|
+
if (!request4) {
|
|
3848
|
+
return;
|
|
3849
|
+
}
|
|
3850
|
+
reject(!cancel || cancel && cancel.type ? new Cancel$2("canceled") : cancel);
|
|
3851
|
+
request4.abort();
|
|
3852
|
+
request4 = null;
|
|
3853
|
+
};
|
|
3854
|
+
config.cancelToken && config.cancelToken.subscribe(onCanceled);
|
|
3855
|
+
if (config.signal) {
|
|
3856
|
+
config.signal.aborted ? onCanceled() : config.signal.addEventListener("abort", onCanceled);
|
|
3857
|
+
}
|
|
3858
|
+
}
|
|
3859
|
+
if (!requestData) {
|
|
3860
|
+
requestData = null;
|
|
3861
|
+
}
|
|
3862
|
+
request4.send(requestData);
|
|
3863
|
+
});
|
|
3864
|
+
};
|
|
3865
|
+
var utils$5 = utils$d;
|
|
3866
|
+
var normalizeHeaderName4 = normalizeHeaderName$1;
|
|
3867
|
+
var enhanceError4 = enhanceError$2;
|
|
3868
|
+
var DEFAULT_CONTENT_TYPE = {
|
|
3869
|
+
"Content-Type": "application/x-www-form-urlencoded"
|
|
3870
|
+
};
|
|
3871
|
+
function setContentTypeIfUnset(headers, value) {
|
|
3872
|
+
if (!utils$5.isUndefined(headers) && utils$5.isUndefined(headers["Content-Type"])) {
|
|
3873
|
+
headers["Content-Type"] = value;
|
|
3874
|
+
}
|
|
3875
|
+
}
|
|
3876
|
+
function getDefaultAdapter() {
|
|
3877
|
+
var adapter;
|
|
3878
|
+
if (typeof XMLHttpRequest !== "undefined") {
|
|
3879
|
+
adapter = xhr;
|
|
3880
|
+
} else if (typeof process !== "undefined" && Object.prototype.toString.call(process) === "[object process]") {
|
|
3881
|
+
adapter = xhr;
|
|
3882
|
+
}
|
|
3883
|
+
return adapter;
|
|
3884
|
+
}
|
|
3885
|
+
function stringifySafely(rawValue, parser, encoder) {
|
|
3886
|
+
if (utils$5.isString(rawValue)) {
|
|
3887
|
+
try {
|
|
3888
|
+
(parser || JSON.parse)(rawValue);
|
|
3889
|
+
return utils$5.trim(rawValue);
|
|
3890
|
+
} catch (e) {
|
|
3891
|
+
if (e.name !== "SyntaxError") {
|
|
3892
|
+
throw e;
|
|
3893
|
+
}
|
|
3894
|
+
}
|
|
3895
|
+
}
|
|
3896
|
+
return (encoder || JSON.stringify)(rawValue);
|
|
3897
|
+
}
|
|
3898
|
+
var defaults$3 = {
|
|
3899
|
+
transitional: {
|
|
3900
|
+
silentJSONParsing: true,
|
|
3901
|
+
forcedJSONParsing: true,
|
|
3902
|
+
clarifyTimeoutError: false
|
|
3903
|
+
},
|
|
3904
|
+
adapter: getDefaultAdapter(),
|
|
3905
|
+
transformRequest: [function transformRequest3(data2, headers) {
|
|
3906
|
+
normalizeHeaderName4(headers, "Accept");
|
|
3907
|
+
normalizeHeaderName4(headers, "Content-Type");
|
|
3908
|
+
if (utils$5.isFormData(data2) || utils$5.isArrayBuffer(data2) || utils$5.isBuffer(data2) || utils$5.isStream(data2) || utils$5.isFile(data2) || utils$5.isBlob(data2)) {
|
|
3909
|
+
return data2;
|
|
3910
|
+
}
|
|
3911
|
+
if (utils$5.isArrayBufferView(data2)) {
|
|
3912
|
+
return data2.buffer;
|
|
3913
|
+
}
|
|
3914
|
+
if (utils$5.isURLSearchParams(data2)) {
|
|
3915
|
+
setContentTypeIfUnset(headers, "application/x-www-form-urlencoded;charset=utf-8");
|
|
3916
|
+
return data2.toString();
|
|
3917
|
+
}
|
|
3918
|
+
if (utils$5.isObject(data2) || headers && headers["Content-Type"] === "application/json") {
|
|
3919
|
+
setContentTypeIfUnset(headers, "application/json");
|
|
3920
|
+
return stringifySafely(data2);
|
|
3921
|
+
}
|
|
3922
|
+
return data2;
|
|
3923
|
+
}],
|
|
3924
|
+
transformResponse: [function transformResponse3(data2) {
|
|
3925
|
+
var transitional4 = this.transitional || defaults$3.transitional;
|
|
3926
|
+
var silentJSONParsing = transitional4 && transitional4.silentJSONParsing;
|
|
3927
|
+
var forcedJSONParsing = transitional4 && transitional4.forcedJSONParsing;
|
|
3928
|
+
var strictJSONParsing = !silentJSONParsing && this.responseType === "json";
|
|
3929
|
+
if (strictJSONParsing || forcedJSONParsing && utils$5.isString(data2) && data2.length) {
|
|
3930
|
+
try {
|
|
3931
|
+
return JSON.parse(data2);
|
|
3932
|
+
} catch (e) {
|
|
3933
|
+
if (strictJSONParsing) {
|
|
3934
|
+
if (e.name === "SyntaxError") {
|
|
3935
|
+
throw enhanceError4(e, this, "E_JSON_PARSE");
|
|
3936
|
+
}
|
|
3937
|
+
throw e;
|
|
3938
|
+
}
|
|
3939
|
+
}
|
|
3940
|
+
}
|
|
3941
|
+
return data2;
|
|
3942
|
+
}],
|
|
3943
|
+
timeout: 0,
|
|
3944
|
+
xsrfCookieName: "XSRF-TOKEN",
|
|
3945
|
+
xsrfHeaderName: "X-XSRF-TOKEN",
|
|
3946
|
+
maxContentLength: -1,
|
|
3947
|
+
maxBodyLength: -1,
|
|
3948
|
+
validateStatus: function validateStatus3(status) {
|
|
3949
|
+
return status >= 200 && status < 300;
|
|
3950
|
+
},
|
|
3951
|
+
headers: {
|
|
3952
|
+
common: {
|
|
3953
|
+
"Accept": "application/json, text/plain, */*"
|
|
3954
|
+
}
|
|
3955
|
+
}
|
|
3956
|
+
};
|
|
3957
|
+
utils$5.forEach(["delete", "get", "head"], function forEachMethodNoData4(method) {
|
|
3958
|
+
defaults$3.headers[method] = {};
|
|
3959
|
+
});
|
|
3960
|
+
utils$5.forEach(["post", "put", "patch"], function forEachMethodWithData4(method) {
|
|
3961
|
+
defaults$3.headers[method] = utils$5.merge(DEFAULT_CONTENT_TYPE);
|
|
3962
|
+
});
|
|
3963
|
+
var defaults_1 = defaults$3;
|
|
3964
|
+
var utils$4 = utils$d;
|
|
3965
|
+
var defaults$2 = defaults_1;
|
|
3966
|
+
var transformData$1 = function transformData3(data2, headers, fns) {
|
|
3967
|
+
var context = this || defaults$2;
|
|
3968
|
+
utils$4.forEach(fns, function transform(fn) {
|
|
3969
|
+
data2 = fn.call(context, data2, headers);
|
|
3970
|
+
});
|
|
3971
|
+
return data2;
|
|
3972
|
+
};
|
|
3973
|
+
var isCancel$1 = function isCancel3(value) {
|
|
3974
|
+
return !!(value && value.__CANCEL__);
|
|
3975
|
+
};
|
|
3976
|
+
var utils$3 = utils$d;
|
|
3977
|
+
var transformData4 = transformData$1;
|
|
3978
|
+
var isCancel4 = isCancel$1;
|
|
3979
|
+
var defaults$1 = defaults_1;
|
|
3980
|
+
var Cancel$1 = Cancel_1;
|
|
3981
|
+
function throwIfCancellationRequested(config) {
|
|
3982
|
+
if (config.cancelToken) {
|
|
3983
|
+
config.cancelToken.throwIfRequested();
|
|
3984
|
+
}
|
|
3985
|
+
if (config.signal && config.signal.aborted) {
|
|
3986
|
+
throw new Cancel$1("canceled");
|
|
3987
|
+
}
|
|
3988
|
+
}
|
|
3989
|
+
var dispatchRequest$1 = function dispatchRequest3(config) {
|
|
3990
|
+
throwIfCancellationRequested(config);
|
|
3991
|
+
config.headers = config.headers || {};
|
|
3992
|
+
config.data = transformData4.call(config, config.data, config.headers, config.transformRequest);
|
|
3993
|
+
config.headers = utils$3.merge(config.headers.common || {}, config.headers[config.method] || {}, config.headers);
|
|
3994
|
+
utils$3.forEach(["delete", "get", "head", "post", "put", "patch", "common"], function cleanHeaderConfig(method) {
|
|
3995
|
+
delete config.headers[method];
|
|
3996
|
+
});
|
|
3997
|
+
var adapter = config.adapter || defaults$1.adapter;
|
|
3998
|
+
return adapter(config).then(function onAdapterResolution(response) {
|
|
3999
|
+
throwIfCancellationRequested(config);
|
|
4000
|
+
response.data = transformData4.call(config, response.data, response.headers, config.transformResponse);
|
|
4001
|
+
return response;
|
|
4002
|
+
}, function onAdapterRejection(reason) {
|
|
4003
|
+
if (!isCancel4(reason)) {
|
|
4004
|
+
throwIfCancellationRequested(config);
|
|
4005
|
+
if (reason && reason.response) {
|
|
4006
|
+
reason.response.data = transformData4.call(config, reason.response.data, reason.response.headers, config.transformResponse);
|
|
4007
|
+
}
|
|
4008
|
+
}
|
|
4009
|
+
return Promise.reject(reason);
|
|
4010
|
+
});
|
|
4011
|
+
};
|
|
4012
|
+
var utils$2 = utils$d;
|
|
4013
|
+
var mergeConfig$2 = function mergeConfig3(config1, config2) {
|
|
4014
|
+
config2 = config2 || {};
|
|
4015
|
+
var config = {};
|
|
4016
|
+
function getMergedValue(target, source4) {
|
|
4017
|
+
if (utils$2.isPlainObject(target) && utils$2.isPlainObject(source4)) {
|
|
4018
|
+
return utils$2.merge(target, source4);
|
|
4019
|
+
} else if (utils$2.isPlainObject(source4)) {
|
|
4020
|
+
return utils$2.merge({}, source4);
|
|
4021
|
+
} else if (utils$2.isArray(source4)) {
|
|
4022
|
+
return source4.slice();
|
|
4023
|
+
}
|
|
4024
|
+
return source4;
|
|
4025
|
+
}
|
|
4026
|
+
function mergeDeepProperties(prop) {
|
|
4027
|
+
if (!utils$2.isUndefined(config2[prop])) {
|
|
4028
|
+
return getMergedValue(config1[prop], config2[prop]);
|
|
4029
|
+
} else if (!utils$2.isUndefined(config1[prop])) {
|
|
4030
|
+
return getMergedValue(void 0, config1[prop]);
|
|
4031
|
+
}
|
|
4032
|
+
}
|
|
4033
|
+
function valueFromConfig2(prop) {
|
|
4034
|
+
if (!utils$2.isUndefined(config2[prop])) {
|
|
4035
|
+
return getMergedValue(void 0, config2[prop]);
|
|
4036
|
+
}
|
|
4037
|
+
}
|
|
4038
|
+
function defaultToConfig2(prop) {
|
|
4039
|
+
if (!utils$2.isUndefined(config2[prop])) {
|
|
4040
|
+
return getMergedValue(void 0, config2[prop]);
|
|
4041
|
+
} else if (!utils$2.isUndefined(config1[prop])) {
|
|
4042
|
+
return getMergedValue(void 0, config1[prop]);
|
|
4043
|
+
}
|
|
4044
|
+
}
|
|
4045
|
+
function mergeDirectKeys(prop) {
|
|
4046
|
+
if (prop in config2) {
|
|
4047
|
+
return getMergedValue(config1[prop], config2[prop]);
|
|
4048
|
+
} else if (prop in config1) {
|
|
4049
|
+
return getMergedValue(void 0, config1[prop]);
|
|
4050
|
+
}
|
|
4051
|
+
}
|
|
4052
|
+
var mergeMap = {
|
|
4053
|
+
"url": valueFromConfig2,
|
|
4054
|
+
"method": valueFromConfig2,
|
|
4055
|
+
"data": valueFromConfig2,
|
|
4056
|
+
"baseURL": defaultToConfig2,
|
|
4057
|
+
"transformRequest": defaultToConfig2,
|
|
4058
|
+
"transformResponse": defaultToConfig2,
|
|
4059
|
+
"paramsSerializer": defaultToConfig2,
|
|
4060
|
+
"timeout": defaultToConfig2,
|
|
4061
|
+
"timeoutMessage": defaultToConfig2,
|
|
4062
|
+
"withCredentials": defaultToConfig2,
|
|
4063
|
+
"adapter": defaultToConfig2,
|
|
4064
|
+
"responseType": defaultToConfig2,
|
|
4065
|
+
"xsrfCookieName": defaultToConfig2,
|
|
4066
|
+
"xsrfHeaderName": defaultToConfig2,
|
|
4067
|
+
"onUploadProgress": defaultToConfig2,
|
|
4068
|
+
"onDownloadProgress": defaultToConfig2,
|
|
4069
|
+
"decompress": defaultToConfig2,
|
|
4070
|
+
"maxContentLength": defaultToConfig2,
|
|
4071
|
+
"maxBodyLength": defaultToConfig2,
|
|
4072
|
+
"transport": defaultToConfig2,
|
|
4073
|
+
"httpAgent": defaultToConfig2,
|
|
4074
|
+
"httpsAgent": defaultToConfig2,
|
|
4075
|
+
"cancelToken": defaultToConfig2,
|
|
4076
|
+
"socketPath": defaultToConfig2,
|
|
4077
|
+
"responseEncoding": defaultToConfig2,
|
|
4078
|
+
"validateStatus": mergeDirectKeys
|
|
4079
|
+
};
|
|
4080
|
+
utils$2.forEach(Object.keys(config1).concat(Object.keys(config2)), function computeConfigValue(prop) {
|
|
4081
|
+
var merge2 = mergeMap[prop] || mergeDeepProperties;
|
|
4082
|
+
var configValue = merge2(prop);
|
|
4083
|
+
utils$2.isUndefined(configValue) && merge2 !== mergeDirectKeys || (config[prop] = configValue);
|
|
4084
|
+
});
|
|
4085
|
+
return config;
|
|
4086
|
+
};
|
|
4087
|
+
var data = {
|
|
4088
|
+
"version": "0.23.0"
|
|
4089
|
+
};
|
|
4090
|
+
var VERSION = data.version;
|
|
4091
|
+
var validators$1 = {};
|
|
4092
|
+
["object", "boolean", "number", "function", "string", "symbol"].forEach(function(type, i) {
|
|
4093
|
+
validators$1[type] = function validator2(thing) {
|
|
4094
|
+
return typeof thing === type || "a" + (i < 1 ? "n " : " ") + type;
|
|
4095
|
+
};
|
|
4096
|
+
});
|
|
4097
|
+
var deprecatedWarnings = {};
|
|
4098
|
+
validators$1.transitional = function transitional3(validator2, version2, message) {
|
|
4099
|
+
function formatMessage(opt, desc) {
|
|
4100
|
+
return "[Axios v" + VERSION + "] Transitional option '" + opt + "'" + desc + (message ? ". " + message : "");
|
|
4101
|
+
}
|
|
4102
|
+
return function(value, opt, opts) {
|
|
4103
|
+
if (validator2 === false) {
|
|
4104
|
+
throw new Error(formatMessage(opt, " has been removed" + (version2 ? " in " + version2 : "")));
|
|
4105
|
+
}
|
|
4106
|
+
if (version2 && !deprecatedWarnings[opt]) {
|
|
4107
|
+
deprecatedWarnings[opt] = true;
|
|
4108
|
+
console.warn(formatMessage(opt, " has been deprecated since v" + version2 + " and will be removed in the near future"));
|
|
4109
|
+
}
|
|
4110
|
+
return validator2 ? validator2(value, opt, opts) : true;
|
|
4111
|
+
};
|
|
4112
|
+
};
|
|
4113
|
+
function assertOptions(options, schema, allowUnknown) {
|
|
4114
|
+
if (typeof options !== "object") {
|
|
4115
|
+
throw new TypeError("options must be an object");
|
|
4116
|
+
}
|
|
4117
|
+
var keys = Object.keys(options);
|
|
4118
|
+
var i = keys.length;
|
|
4119
|
+
while (i-- > 0) {
|
|
4120
|
+
var opt = keys[i];
|
|
4121
|
+
var validator2 = schema[opt];
|
|
4122
|
+
if (validator2) {
|
|
4123
|
+
var value = options[opt];
|
|
4124
|
+
var result = value === void 0 || validator2(value, opt, options);
|
|
4125
|
+
if (result !== true) {
|
|
4126
|
+
throw new TypeError("option " + opt + " must be " + result);
|
|
4127
|
+
}
|
|
4128
|
+
continue;
|
|
4129
|
+
}
|
|
4130
|
+
if (allowUnknown !== true) {
|
|
4131
|
+
throw Error("Unknown option " + opt);
|
|
4132
|
+
}
|
|
4133
|
+
}
|
|
4134
|
+
}
|
|
4135
|
+
var validator$1 = {
|
|
4136
|
+
assertOptions,
|
|
4137
|
+
validators: validators$1
|
|
4138
|
+
};
|
|
4139
|
+
var utils$1 = utils$d;
|
|
4140
|
+
var buildURL4 = buildURL$2;
|
|
4141
|
+
var InterceptorManager = InterceptorManager_1;
|
|
4142
|
+
var dispatchRequest4 = dispatchRequest$1;
|
|
4143
|
+
var mergeConfig$1 = mergeConfig$2;
|
|
4144
|
+
var validator = validator$1;
|
|
4145
|
+
var validators = validator.validators;
|
|
4146
|
+
function Axios$1(instanceConfig) {
|
|
4147
|
+
this.defaults = instanceConfig;
|
|
4148
|
+
this.interceptors = {
|
|
4149
|
+
request: new InterceptorManager(),
|
|
4150
|
+
response: new InterceptorManager()
|
|
4151
|
+
};
|
|
4152
|
+
}
|
|
4153
|
+
Axios$1.prototype.request = function request3(config) {
|
|
4154
|
+
if (typeof config === "string") {
|
|
4155
|
+
config = arguments[1] || {};
|
|
4156
|
+
config.url = arguments[0];
|
|
4157
|
+
} else {
|
|
4158
|
+
config = config || {};
|
|
4159
|
+
}
|
|
4160
|
+
config = mergeConfig$1(this.defaults, config);
|
|
4161
|
+
if (config.method) {
|
|
4162
|
+
config.method = config.method.toLowerCase();
|
|
4163
|
+
} else if (this.defaults.method) {
|
|
4164
|
+
config.method = this.defaults.method.toLowerCase();
|
|
4165
|
+
} else {
|
|
4166
|
+
config.method = "get";
|
|
4167
|
+
}
|
|
4168
|
+
var transitional4 = config.transitional;
|
|
4169
|
+
if (transitional4 !== void 0) {
|
|
4170
|
+
validator.assertOptions(transitional4, {
|
|
4171
|
+
silentJSONParsing: validators.transitional(validators.boolean),
|
|
4172
|
+
forcedJSONParsing: validators.transitional(validators.boolean),
|
|
4173
|
+
clarifyTimeoutError: validators.transitional(validators.boolean)
|
|
4174
|
+
}, false);
|
|
4175
|
+
}
|
|
4176
|
+
var requestInterceptorChain = [];
|
|
4177
|
+
var synchronousRequestInterceptors = true;
|
|
4178
|
+
this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
|
|
4179
|
+
if (typeof interceptor.runWhen === "function" && interceptor.runWhen(config) === false) {
|
|
4180
|
+
return;
|
|
4181
|
+
}
|
|
4182
|
+
synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous;
|
|
4183
|
+
requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected);
|
|
4184
|
+
});
|
|
4185
|
+
var responseInterceptorChain = [];
|
|
4186
|
+
this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
|
|
4187
|
+
responseInterceptorChain.push(interceptor.fulfilled, interceptor.rejected);
|
|
4188
|
+
});
|
|
4189
|
+
var promise;
|
|
4190
|
+
if (!synchronousRequestInterceptors) {
|
|
4191
|
+
var chain = [dispatchRequest4, void 0];
|
|
4192
|
+
Array.prototype.unshift.apply(chain, requestInterceptorChain);
|
|
4193
|
+
chain = chain.concat(responseInterceptorChain);
|
|
4194
|
+
promise = Promise.resolve(config);
|
|
4195
|
+
while (chain.length) {
|
|
4196
|
+
promise = promise.then(chain.shift(), chain.shift());
|
|
4197
|
+
}
|
|
4198
|
+
return promise;
|
|
4199
|
+
}
|
|
4200
|
+
var newConfig = config;
|
|
4201
|
+
while (requestInterceptorChain.length) {
|
|
4202
|
+
var onFulfilled = requestInterceptorChain.shift();
|
|
4203
|
+
var onRejected = requestInterceptorChain.shift();
|
|
4204
|
+
try {
|
|
4205
|
+
newConfig = onFulfilled(newConfig);
|
|
4206
|
+
} catch (error) {
|
|
4207
|
+
onRejected(error);
|
|
4208
|
+
break;
|
|
4209
|
+
}
|
|
4210
|
+
}
|
|
4211
|
+
try {
|
|
4212
|
+
promise = dispatchRequest4(newConfig);
|
|
4213
|
+
} catch (error) {
|
|
4214
|
+
return Promise.reject(error);
|
|
4215
|
+
}
|
|
4216
|
+
while (responseInterceptorChain.length) {
|
|
4217
|
+
promise = promise.then(responseInterceptorChain.shift(), responseInterceptorChain.shift());
|
|
4218
|
+
}
|
|
4219
|
+
return promise;
|
|
4220
|
+
};
|
|
4221
|
+
Axios$1.prototype.getUri = function getUri3(config) {
|
|
4222
|
+
config = mergeConfig$1(this.defaults, config);
|
|
4223
|
+
return buildURL4(config.url, config.params, config.paramsSerializer).replace(/^\?/, "");
|
|
4224
|
+
};
|
|
4225
|
+
utils$1.forEach(["delete", "get", "head", "options"], function forEachMethodNoData5(method) {
|
|
4226
|
+
Axios$1.prototype[method] = function(url, config) {
|
|
4227
|
+
return this.request(mergeConfig$1(config || {}, {
|
|
4228
|
+
method,
|
|
4229
|
+
url,
|
|
4230
|
+
data: (config || {}).data
|
|
4231
|
+
}));
|
|
4232
|
+
};
|
|
4233
|
+
});
|
|
4234
|
+
utils$1.forEach(["post", "put", "patch"], function forEachMethodWithData5(method) {
|
|
4235
|
+
Axios$1.prototype[method] = function(url, data2, config) {
|
|
4236
|
+
return this.request(mergeConfig$1(config || {}, {
|
|
4237
|
+
method,
|
|
4238
|
+
url,
|
|
4239
|
+
data: data2
|
|
4240
|
+
}));
|
|
4241
|
+
};
|
|
4242
|
+
});
|
|
4243
|
+
var Axios_1 = Axios$1;
|
|
4244
|
+
var Cancel = Cancel_1;
|
|
4245
|
+
function CancelToken(executor) {
|
|
4246
|
+
if (typeof executor !== "function") {
|
|
4247
|
+
throw new TypeError("executor must be a function.");
|
|
4248
|
+
}
|
|
4249
|
+
var resolvePromise;
|
|
4250
|
+
this.promise = new Promise(function promiseExecutor(resolve) {
|
|
4251
|
+
resolvePromise = resolve;
|
|
4252
|
+
});
|
|
4253
|
+
var token2 = this;
|
|
4254
|
+
this.promise.then(function(cancel) {
|
|
4255
|
+
if (!token2._listeners)
|
|
4256
|
+
return;
|
|
4257
|
+
var i;
|
|
4258
|
+
var l = token2._listeners.length;
|
|
4259
|
+
for (i = 0; i < l; i++) {
|
|
4260
|
+
token2._listeners[i](cancel);
|
|
4261
|
+
}
|
|
4262
|
+
token2._listeners = null;
|
|
4263
|
+
});
|
|
4264
|
+
this.promise.then = function(onfulfilled) {
|
|
4265
|
+
var _resolve;
|
|
4266
|
+
var promise = new Promise(function(resolve) {
|
|
4267
|
+
token2.subscribe(resolve);
|
|
4268
|
+
_resolve = resolve;
|
|
4269
|
+
}).then(onfulfilled);
|
|
4270
|
+
promise.cancel = function reject() {
|
|
4271
|
+
token2.unsubscribe(_resolve);
|
|
4272
|
+
};
|
|
4273
|
+
return promise;
|
|
4274
|
+
};
|
|
4275
|
+
executor(function cancel(message) {
|
|
4276
|
+
if (token2.reason) {
|
|
4277
|
+
return;
|
|
4278
|
+
}
|
|
4279
|
+
token2.reason = new Cancel(message);
|
|
4280
|
+
resolvePromise(token2.reason);
|
|
4281
|
+
});
|
|
4282
|
+
}
|
|
4283
|
+
CancelToken.prototype.throwIfRequested = function throwIfRequested3() {
|
|
4284
|
+
if (this.reason) {
|
|
4285
|
+
throw this.reason;
|
|
4286
|
+
}
|
|
4287
|
+
};
|
|
4288
|
+
CancelToken.prototype.subscribe = function subscribe2(listener) {
|
|
4289
|
+
if (this.reason) {
|
|
4290
|
+
listener(this.reason);
|
|
4291
|
+
return;
|
|
4292
|
+
}
|
|
4293
|
+
if (this._listeners) {
|
|
4294
|
+
this._listeners.push(listener);
|
|
4295
|
+
} else {
|
|
4296
|
+
this._listeners = [listener];
|
|
4297
|
+
}
|
|
4298
|
+
};
|
|
4299
|
+
CancelToken.prototype.unsubscribe = function unsubscribe2(listener) {
|
|
4300
|
+
if (!this._listeners) {
|
|
4301
|
+
return;
|
|
4302
|
+
}
|
|
4303
|
+
var index = this._listeners.indexOf(listener);
|
|
4304
|
+
if (index !== -1) {
|
|
4305
|
+
this._listeners.splice(index, 1);
|
|
4306
|
+
}
|
|
4307
|
+
};
|
|
4308
|
+
CancelToken.source = function source3() {
|
|
4309
|
+
var cancel;
|
|
4310
|
+
var token2 = new CancelToken(function executor(c) {
|
|
4311
|
+
cancel = c;
|
|
4312
|
+
});
|
|
4313
|
+
return {
|
|
4314
|
+
token: token2,
|
|
4315
|
+
cancel
|
|
4316
|
+
};
|
|
4317
|
+
};
|
|
4318
|
+
var CancelToken_1 = CancelToken;
|
|
4319
|
+
var spread = function spread3(callback) {
|
|
4320
|
+
return function wrap(arr) {
|
|
4321
|
+
return callback.apply(null, arr);
|
|
4322
|
+
};
|
|
4323
|
+
};
|
|
4324
|
+
var isAxiosError = function isAxiosError3(payload) {
|
|
4325
|
+
return typeof payload === "object" && payload.isAxiosError === true;
|
|
4326
|
+
};
|
|
4327
|
+
var utils = utils$d;
|
|
4328
|
+
var bind4 = bind$2;
|
|
4329
|
+
var Axios = Axios_1;
|
|
4330
|
+
var mergeConfig4 = mergeConfig$2;
|
|
4331
|
+
var defaults = defaults_1;
|
|
4332
|
+
function createInstance(defaultConfig) {
|
|
4333
|
+
var context = new Axios(defaultConfig);
|
|
4334
|
+
var instance = bind4(Axios.prototype.request, context);
|
|
4335
|
+
utils.extend(instance, Axios.prototype, context);
|
|
4336
|
+
utils.extend(instance, context);
|
|
4337
|
+
instance.create = function create2(instanceConfig) {
|
|
4338
|
+
return createInstance(mergeConfig4(defaultConfig, instanceConfig));
|
|
4339
|
+
};
|
|
4340
|
+
return instance;
|
|
4341
|
+
}
|
|
4342
|
+
var axios$1 = createInstance(defaults);
|
|
4343
|
+
axios$1.Axios = Axios;
|
|
4344
|
+
axios$1.Cancel = Cancel_1;
|
|
4345
|
+
axios$1.CancelToken = CancelToken_1;
|
|
4346
|
+
axios$1.isCancel = isCancel$1;
|
|
4347
|
+
axios$1.VERSION = data.version;
|
|
4348
|
+
axios$1.all = function all3(promises) {
|
|
4349
|
+
return Promise.all(promises);
|
|
4350
|
+
};
|
|
4351
|
+
axios$1.spread = spread;
|
|
4352
|
+
axios$1.isAxiosError = isAxiosError;
|
|
4353
|
+
axios$2.exports = axios$1;
|
|
4354
|
+
axios$2.exports.default = axios$1;
|
|
4355
|
+
var axios = axios$2.exports;
|
|
4356
|
+
class NhostFunctionsClient {
|
|
4357
|
+
constructor(params) {
|
|
4358
|
+
const { url } = params;
|
|
4359
|
+
this.accessToken = null;
|
|
4360
|
+
this.instance = axios.create({
|
|
4361
|
+
baseURL: url
|
|
4362
|
+
});
|
|
4363
|
+
}
|
|
4364
|
+
async call(url, data2, config) {
|
|
4365
|
+
const headers = __spreadValues(__spreadValues({}, this.generateAccessTokenHeaders()), config == null ? void 0 : config.headers);
|
|
4366
|
+
let res;
|
|
4367
|
+
try {
|
|
4368
|
+
res = await this.instance.post(url, data2, __spreadProps(__spreadValues({}, config), { headers }));
|
|
4369
|
+
} catch (error) {
|
|
4370
|
+
if (error instanceof Error) {
|
|
4371
|
+
return { res: null, error };
|
|
4372
|
+
}
|
|
4373
|
+
}
|
|
4374
|
+
if (!res) {
|
|
4375
|
+
return {
|
|
4376
|
+
res: null,
|
|
4377
|
+
error: new Error("Unable to make post request to funtion")
|
|
4378
|
+
};
|
|
4379
|
+
}
|
|
4380
|
+
return { res, error: null };
|
|
4381
|
+
}
|
|
4382
|
+
setAccessToken(accessToken) {
|
|
4383
|
+
if (!accessToken) {
|
|
4384
|
+
this.accessToken = null;
|
|
4385
|
+
return;
|
|
4386
|
+
}
|
|
4387
|
+
this.accessToken = accessToken;
|
|
4388
|
+
}
|
|
4389
|
+
generateAccessTokenHeaders() {
|
|
4390
|
+
if (!this.accessToken) {
|
|
4391
|
+
return;
|
|
4392
|
+
}
|
|
4393
|
+
return {
|
|
4394
|
+
Authorization: `Bearer ${this.accessToken}`
|
|
4395
|
+
};
|
|
4396
|
+
}
|
|
4397
|
+
}
|
|
4398
|
+
class NhostGraphqlClient {
|
|
4399
|
+
constructor(params) {
|
|
4400
|
+
const { url } = params;
|
|
4401
|
+
this.url = url;
|
|
4402
|
+
this.accessToken = null;
|
|
4403
|
+
this.instance = axios.create({
|
|
4404
|
+
baseURL: url
|
|
4405
|
+
});
|
|
4406
|
+
}
|
|
4407
|
+
async request(document2, variables, config) {
|
|
4408
|
+
const headers = __spreadValues(__spreadValues({}, config == null ? void 0 : config.headers), this.generateAccessTokenHeaders());
|
|
4409
|
+
const operationName = "";
|
|
4410
|
+
let responseData;
|
|
4411
|
+
try {
|
|
4412
|
+
const res = await this.instance.post("", {
|
|
4413
|
+
operationName: operationName || void 0,
|
|
4414
|
+
query: document2,
|
|
4415
|
+
variables
|
|
4416
|
+
}, __spreadProps(__spreadValues({}, config), { headers }));
|
|
4417
|
+
responseData = res.data;
|
|
4418
|
+
} catch (error) {
|
|
4419
|
+
if (error instanceof Error) {
|
|
4420
|
+
return { data: null, error };
|
|
4421
|
+
}
|
|
4422
|
+
console.error(error);
|
|
4423
|
+
return {
|
|
4424
|
+
data: null,
|
|
4425
|
+
error: new Error("Unable to get do GraphQL request")
|
|
4426
|
+
};
|
|
4427
|
+
}
|
|
4428
|
+
if (typeof responseData !== "object" || Array.isArray(responseData) || responseData === null) {
|
|
4429
|
+
return {
|
|
4430
|
+
data: null,
|
|
4431
|
+
error: new Error("incorrect response data from GraphQL server")
|
|
4432
|
+
};
|
|
4433
|
+
}
|
|
4434
|
+
responseData = responseData;
|
|
4435
|
+
if (responseData.errors) {
|
|
4436
|
+
return {
|
|
4437
|
+
data: null,
|
|
4438
|
+
error: responseData.errors
|
|
4439
|
+
};
|
|
4440
|
+
}
|
|
4441
|
+
return { data: responseData.data, error: null };
|
|
4442
|
+
}
|
|
4443
|
+
getUrl() {
|
|
4444
|
+
return this.url;
|
|
4445
|
+
}
|
|
4446
|
+
setAccessToken(accessToken) {
|
|
4447
|
+
if (!accessToken) {
|
|
4448
|
+
this.accessToken = null;
|
|
4449
|
+
return;
|
|
4450
|
+
}
|
|
4451
|
+
this.accessToken = accessToken;
|
|
4452
|
+
}
|
|
4453
|
+
generateAccessTokenHeaders() {
|
|
4454
|
+
if (!this.accessToken) {
|
|
4455
|
+
return;
|
|
4456
|
+
}
|
|
4457
|
+
return {
|
|
4458
|
+
Authorization: `Bearer ${this.accessToken}`
|
|
4459
|
+
};
|
|
4460
|
+
}
|
|
4461
|
+
}
|
|
4462
|
+
class NhostClient {
|
|
4463
|
+
constructor(params) {
|
|
4464
|
+
if (!params.backendUrl)
|
|
4465
|
+
throw new Error("Please specify a `backendUrl`. Docs: [todo]!");
|
|
4466
|
+
const {
|
|
4467
|
+
backendUrl,
|
|
4468
|
+
refreshIntervalTime,
|
|
4469
|
+
clientStorage,
|
|
4470
|
+
clientStorageType,
|
|
4471
|
+
autoRefreshToken,
|
|
4472
|
+
autoLogin
|
|
4473
|
+
} = params;
|
|
4474
|
+
this.auth = new HasuraAuthClient({
|
|
4475
|
+
url: `${backendUrl}/v1/auth`,
|
|
4476
|
+
refreshIntervalTime,
|
|
4477
|
+
clientStorage,
|
|
4478
|
+
clientStorageType,
|
|
4479
|
+
autoRefreshToken,
|
|
4480
|
+
autoLogin
|
|
4481
|
+
});
|
|
4482
|
+
this.storage = new HasuraStorageClient({
|
|
4483
|
+
url: `${backendUrl}/v1/storage`
|
|
4484
|
+
});
|
|
4485
|
+
this.functions = new NhostFunctionsClient({
|
|
4486
|
+
url: `${backendUrl}/v1/functions`
|
|
4487
|
+
});
|
|
4488
|
+
this.graphql = new NhostGraphqlClient({
|
|
4489
|
+
url: `${backendUrl}/v1/graphql`
|
|
4490
|
+
});
|
|
4491
|
+
this.storage.setAccessToken(this.auth.getAccessToken());
|
|
4492
|
+
this.functions.setAccessToken(this.auth.getAccessToken());
|
|
4493
|
+
this.graphql.setAccessToken(this.auth.getAccessToken());
|
|
4494
|
+
this.auth.onAuthStateChanged((_event, session) => {
|
|
4495
|
+
this.storage.setAccessToken(session == null ? void 0 : session.accessToken);
|
|
4496
|
+
this.functions.setAccessToken(session == null ? void 0 : session.accessToken);
|
|
4497
|
+
this.graphql.setAccessToken(session == null ? void 0 : session.accessToken);
|
|
4498
|
+
});
|
|
4499
|
+
this.auth.onTokenChanged((session) => {
|
|
4500
|
+
this.storage.setAccessToken(session == null ? void 0 : session.accessToken);
|
|
4501
|
+
this.functions.setAccessToken(session == null ? void 0 : session.accessToken);
|
|
4502
|
+
this.graphql.setAccessToken(session == null ? void 0 : session.accessToken);
|
|
4503
|
+
});
|
|
4504
|
+
}
|
|
4505
|
+
}
|
|
4506
|
+
const createClient = (config) => new NhostClient(config);
|
|
4507
|
+
export { NhostClient, createClient };
|