@massalabs/wallet-provider 0.0.0 → 0.0.1-dev.20230424074402
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -5
- package/bundle.js +3738 -0
- package/dist/account/Account.d.ts +80 -0
- package/dist/account/Account.js +139 -0
- package/dist/account/Account.js.map +1 -0
- package/dist/account/AccountBalance.d.ts +13 -0
- package/dist/account/AccountBalance.js +3 -0
- package/dist/account/AccountBalance.js.map +1 -0
- package/dist/account/AccountSign.d.ts +15 -0
- package/dist/account/AccountSign.js +3 -0
- package/dist/account/AccountSign.js.map +1 -0
- package/dist/account/IAccount.d.ts +16 -0
- package/dist/account/IAccount.js +3 -0
- package/dist/account/IAccount.js.map +1 -0
- package/dist/account/IAccountDetails.d.ts +7 -0
- package/dist/account/IAccountDetails.js +3 -0
- package/dist/account/IAccountDetails.js.map +1 -0
- package/dist/account/IAccountRolls.d.ts +7 -0
- package/dist/account/IAccountRolls.js +3 -0
- package/dist/account/IAccountRolls.js.map +1 -0
- package/dist/account/IAccountSendTransaction.d.ts +8 -0
- package/dist/account/IAccountSendTransaction.js +3 -0
- package/dist/account/IAccountSendTransaction.js.map +1 -0
- package/dist/account/index.d.ts +7 -0
- package/dist/account/index.js +6 -0
- package/dist/account/index.js.map +1 -0
- package/dist/connector/Connector.d.ts +79 -0
- package/dist/connector/Connector.js +164 -0
- package/dist/connector/Connector.js.map +1 -0
- package/dist/connector/ICustomEventMessageRequest.d.ts +9 -0
- package/dist/connector/ICustomEventMessageRequest.js +3 -0
- package/dist/connector/ICustomEventMessageRequest.js.map +1 -0
- package/dist/connector/ICustomEventMessageResponse.d.ts +10 -0
- package/dist/connector/ICustomEventMessageResponse.js +3 -0
- package/dist/connector/ICustomEventMessageResponse.js.map +1 -0
- package/dist/connector/IRegisterEvent.d.ts +7 -0
- package/dist/connector/IRegisterEvent.js +3 -0
- package/dist/connector/IRegisterEvent.js.map +1 -0
- package/dist/connector/index.d.ts +4 -0
- package/dist/connector/index.js +6 -0
- package/dist/connector/index.js.map +1 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.js +41 -0
- package/dist/index.js.map +1 -0
- package/dist/provider/AccountDeletion.d.ts +23 -0
- package/dist/provider/AccountDeletion.js +14 -0
- package/dist/provider/AccountDeletion.js.map +1 -0
- package/dist/provider/AccountImport.d.ts +25 -0
- package/dist/provider/AccountImport.js +14 -0
- package/dist/provider/AccountImport.js.map +1 -0
- package/dist/provider/AccoutGeneration.d.ts +7 -0
- package/dist/provider/AccoutGeneration.js +3 -0
- package/dist/provider/AccoutGeneration.js.map +1 -0
- package/dist/provider/IProvider.d.ts +15 -0
- package/dist/provider/IProvider.js +3 -0
- package/dist/provider/IProvider.js.map +1 -0
- package/dist/provider/Provider.d.ts +67 -0
- package/dist/provider/Provider.js +126 -0
- package/dist/provider/Provider.js.map +1 -0
- package/dist/provider/index.d.ts +4 -0
- package/dist/provider/index.js +10 -0
- package/dist/provider/index.js.map +1 -0
- package/dist/thyra/RequestHandler.d.ts +35 -0
- package/dist/thyra/RequestHandler.js +103 -0
- package/dist/thyra/RequestHandler.js.map +1 -0
- package/dist/thyra/ThyraAccount.d.ts +77 -0
- package/dist/thyra/ThyraAccount.js +132 -0
- package/dist/thyra/ThyraAccount.js.map +1 -0
- package/dist/thyra/ThyraDiscovery.d.ts +69 -0
- package/dist/thyra/ThyraDiscovery.js +107 -0
- package/dist/thyra/ThyraDiscovery.js.map +1 -0
- package/dist/thyra/ThyraProvider.d.ts +87 -0
- package/dist/thyra/ThyraProvider.js +137 -0
- package/dist/thyra/ThyraProvider.js.map +1 -0
- package/dist/utils/time.d.ts +76 -0
- package/dist/utils/time.js +120 -0
- package/dist/utils/time.js.map +1 -0
- package/package.json +6 -2
package/bundle.js
ADDED
|
@@ -0,0 +1,3738 @@
|
|
|
1
|
+
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.wallet = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.Account = void 0;
|
|
5
|
+
const Connector_1 = require("../connector/Connector");
|
|
6
|
+
const __1 = require("..");
|
|
7
|
+
/**
|
|
8
|
+
* This module contains the Account class. It is responsible for representing an account in the wallet.
|
|
9
|
+
*
|
|
10
|
+
* @remarks
|
|
11
|
+
* This class provides methods to interact with the account's {@link balance} and to {@link sign} messages.
|
|
12
|
+
*
|
|
13
|
+
*/
|
|
14
|
+
class Account {
|
|
15
|
+
/**
|
|
16
|
+
* This constructor takes an object of type IAccountDetails and a providerName string as its arguments.
|
|
17
|
+
*
|
|
18
|
+
* @param address - The address of the account.
|
|
19
|
+
* @param name - The name of the account.
|
|
20
|
+
* @param providerName - The name of the provider.
|
|
21
|
+
* @returns An instance of the Account class.
|
|
22
|
+
*
|
|
23
|
+
* @remarks
|
|
24
|
+
* - The Account constructor takes an object of type IAccountDetails and a providerName string as its arguments.
|
|
25
|
+
* - The IAccountDetails object contains the account's address and name.
|
|
26
|
+
* - The providerName string identifies the provider that is used to interact with the blockchain.
|
|
27
|
+
*/
|
|
28
|
+
constructor({ address, name }, providerName) {
|
|
29
|
+
this._address = address;
|
|
30
|
+
this._name = name;
|
|
31
|
+
this._providerName = providerName;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* @returns The address of the account.
|
|
35
|
+
*/
|
|
36
|
+
address() {
|
|
37
|
+
return this._address;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* @returns The name of the account.
|
|
41
|
+
*/
|
|
42
|
+
name() {
|
|
43
|
+
return this._name;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* @returns The name of the provider.
|
|
47
|
+
*/
|
|
48
|
+
providerName() {
|
|
49
|
+
return this._providerName;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* This method aims to retrieve the account's balance.
|
|
53
|
+
*
|
|
54
|
+
* @returns A promise that resolves to an object of type IAccountBalanceResponse. It contains the account's balance.
|
|
55
|
+
*/
|
|
56
|
+
async balance() {
|
|
57
|
+
return new Promise((resolve, reject) => {
|
|
58
|
+
Connector_1.connector.sendMessageToContentScript(this._providerName, __1.AvailableCommands.AccountBalance, { address: this._address }, (result, err) => {
|
|
59
|
+
if (err)
|
|
60
|
+
return reject(err);
|
|
61
|
+
return resolve(result);
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* This method aims to sign a message.
|
|
67
|
+
*
|
|
68
|
+
* @param data - The message to be signed.
|
|
69
|
+
* @returns An IAccountSignResponse object. It contains the signature of the message.
|
|
70
|
+
*/
|
|
71
|
+
async sign(data) {
|
|
72
|
+
return new Promise((resolve, reject) => {
|
|
73
|
+
Connector_1.connector.sendMessageToContentScript(this._providerName, __1.AvailableCommands.AccountSign, { address: this._address, data }, (result, err) => {
|
|
74
|
+
if (err)
|
|
75
|
+
return reject(err);
|
|
76
|
+
return resolve(result);
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* This method aims to buy rolls on behalf of the sender.
|
|
82
|
+
*
|
|
83
|
+
* @param amount - The amount of rolls to be purchased
|
|
84
|
+
* @param fee - The fee to be paid for the transaction execution by the node..
|
|
85
|
+
* @returns An ITransactionDetails object. It contains the operationId on the network.
|
|
86
|
+
*/
|
|
87
|
+
async buyRolls(amount, fee) {
|
|
88
|
+
return new Promise((resolve, reject) => {
|
|
89
|
+
Connector_1.connector.sendMessageToContentScript(this._providerName, __1.AvailableCommands.AccountBuyRolls, {
|
|
90
|
+
amount: amount.toString(),
|
|
91
|
+
fee: fee.toString(),
|
|
92
|
+
}, (result, err) => {
|
|
93
|
+
if (err)
|
|
94
|
+
return reject(err);
|
|
95
|
+
return resolve(result);
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* This method aims to sell rolls on behalf of the sender.
|
|
101
|
+
*
|
|
102
|
+
* @param amount - The amount of rolls to be sold.
|
|
103
|
+
* @param fee - The fee to be paid for the transaction execution by the node..
|
|
104
|
+
* @returns An ITransactionDetails object. It contains the operationId on the network.
|
|
105
|
+
*/
|
|
106
|
+
async sellRolls(amount, fee) {
|
|
107
|
+
return new Promise((resolve, reject) => {
|
|
108
|
+
Connector_1.connector.sendMessageToContentScript(this._providerName, __1.AvailableCommands.AccountSellRolls, {
|
|
109
|
+
amount: amount.toString(),
|
|
110
|
+
fee: fee.toString(),
|
|
111
|
+
}, (result, err) => {
|
|
112
|
+
if (err)
|
|
113
|
+
return reject(err);
|
|
114
|
+
return resolve(result);
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* This method aims to transfer MAS on behalf of the sender to a recipient.
|
|
120
|
+
*
|
|
121
|
+
* @param amount - The amount of MAS to be transferred.
|
|
122
|
+
* @param fee - The fee to be paid for the transaction execution by the node..
|
|
123
|
+
* @returns An ITransactionDetails object. It contains the operationId on the network.
|
|
124
|
+
*/
|
|
125
|
+
async sendTransaction(amount, recipientAddress, fee) {
|
|
126
|
+
return new Promise((resolve, reject) => {
|
|
127
|
+
Connector_1.connector.sendMessageToContentScript(this._providerName, __1.AvailableCommands.AccountSendTransaction, {
|
|
128
|
+
amount: amount.toString(),
|
|
129
|
+
recipientAddress,
|
|
130
|
+
fee: fee.toString(),
|
|
131
|
+
}, (result, err) => {
|
|
132
|
+
if (err)
|
|
133
|
+
return reject(err);
|
|
134
|
+
return resolve(result);
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
exports.Account = Account;
|
|
140
|
+
|
|
141
|
+
},{"..":4,"../connector/Connector":3}],2:[function(require,module,exports){
|
|
142
|
+
"use strict";
|
|
143
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
144
|
+
exports.Account = void 0;
|
|
145
|
+
var Account_1 = require("./Account");
|
|
146
|
+
Object.defineProperty(exports, "Account", { enumerable: true, get: function () { return Account_1.Account; } });
|
|
147
|
+
|
|
148
|
+
},{"./Account":1}],3:[function(require,module,exports){
|
|
149
|
+
"use strict";
|
|
150
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
151
|
+
exports.connector = void 0;
|
|
152
|
+
/**
|
|
153
|
+
* This file defines a TypeScript module named connector.
|
|
154
|
+
* It is the tool that allows the 'provider' and 'account' objects to communicate with the web page script.
|
|
155
|
+
*
|
|
156
|
+
* @remarks
|
|
157
|
+
* - If you are only looking to use our library, the connector object will not be useful to you.
|
|
158
|
+
* - If you want to work on this repo, you will probably be interested in this object
|
|
159
|
+
*
|
|
160
|
+
*/
|
|
161
|
+
const uid_1 = require("uid");
|
|
162
|
+
const __1 = require("..");
|
|
163
|
+
const ThyraDiscovery_1 = require("../thyra/ThyraDiscovery");
|
|
164
|
+
const ThyraProvider_1 = require("../thyra/ThyraProvider");
|
|
165
|
+
/**
|
|
166
|
+
* A constant string that is used to identify the HTML element that is used for
|
|
167
|
+
* communication between the web page script and the content script.
|
|
168
|
+
*/
|
|
169
|
+
const MASSA_WINDOW_OBJECT = 'massaWalletProvider';
|
|
170
|
+
/**
|
|
171
|
+
* This class enables communication with the content script by sending and receiving messages.
|
|
172
|
+
* @remarks
|
|
173
|
+
* - This class is used to send messages to the content script and to receive messages from the content script.
|
|
174
|
+
* - It is used to send messages to the content script and to receive messages from the content script.
|
|
175
|
+
*
|
|
176
|
+
*/
|
|
177
|
+
class Connector {
|
|
178
|
+
/**
|
|
179
|
+
* Connector constructor
|
|
180
|
+
*
|
|
181
|
+
* @remarks
|
|
182
|
+
* - The Connector constructor takes no arguments.
|
|
183
|
+
* - It creates a Map object that is used to store pending requests.
|
|
184
|
+
* - It creates an HTML element that is used to communicate with the content script.
|
|
185
|
+
* - It adds an event listener to the HTML element that is used to communicate with the content script.
|
|
186
|
+
*
|
|
187
|
+
* @returns An instance of the Connector class.
|
|
188
|
+
*
|
|
189
|
+
*/
|
|
190
|
+
constructor() {
|
|
191
|
+
this.registeredProviders = {};
|
|
192
|
+
this.pendingRequests = new Map();
|
|
193
|
+
this.register();
|
|
194
|
+
// start listening to messages from content script
|
|
195
|
+
document
|
|
196
|
+
.getElementById(MASSA_WINDOW_OBJECT)
|
|
197
|
+
.addEventListener('message', this.handleResponseFromContentScript.bind(this));
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* This method adds a register listener in the web page.
|
|
201
|
+
* It listens to the 'register' event.
|
|
202
|
+
*
|
|
203
|
+
* @returns void
|
|
204
|
+
*
|
|
205
|
+
* @remarks
|
|
206
|
+
* - It is used to register a new provider.
|
|
207
|
+
* - This method creates a new HTML element and a listener that listens to the register event.
|
|
208
|
+
*
|
|
209
|
+
*/
|
|
210
|
+
register() {
|
|
211
|
+
// global event target to use for all wallet provider
|
|
212
|
+
if (!document.getElementById(MASSA_WINDOW_OBJECT)) {
|
|
213
|
+
const inv = document.createElement('p');
|
|
214
|
+
inv.id = MASSA_WINDOW_OBJECT;
|
|
215
|
+
inv.setAttribute('style', 'display:none');
|
|
216
|
+
document.body.appendChild(inv);
|
|
217
|
+
}
|
|
218
|
+
// add an invisible HTML element and set a listener to it like the following
|
|
219
|
+
// hook up register handler
|
|
220
|
+
document
|
|
221
|
+
.getElementById(MASSA_WINDOW_OBJECT)
|
|
222
|
+
.addEventListener('register', (evt) => {
|
|
223
|
+
const payload = evt.detail;
|
|
224
|
+
const providerEventTargetName = `${MASSA_WINDOW_OBJECT}_${payload.providerName}`;
|
|
225
|
+
this.registeredProviders[payload.providerName] =
|
|
226
|
+
providerEventTargetName;
|
|
227
|
+
});
|
|
228
|
+
// start thyra discovery
|
|
229
|
+
this.thyraListener = new ThyraDiscovery_1.ThyraDiscovery(1000);
|
|
230
|
+
this.thyraListener.startListening();
|
|
231
|
+
this.thyraListener.on(ThyraDiscovery_1.ON_THYRA_DISCOVERED, () => {
|
|
232
|
+
this.registeredProviders[ThyraProvider_1.THYRA_PROVIDER_NAME] = `${MASSA_WINDOW_OBJECT}_${ThyraProvider_1.THYRA_PROVIDER_NAME}`;
|
|
233
|
+
});
|
|
234
|
+
this.thyraListener.on(ThyraDiscovery_1.ON_THYRA_DISCONNECTED, () => {
|
|
235
|
+
delete this.registeredProviders[ThyraProvider_1.THYRA_PROVIDER_NAME];
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* This method sends a message from the webpage script to the content script.
|
|
240
|
+
*
|
|
241
|
+
* @remarks
|
|
242
|
+
* Sends a message to the content script using the specified provider name, command, and parameters,
|
|
243
|
+
*
|
|
244
|
+
* @privateRemarks
|
|
245
|
+
* This method registers the response callback with a unique ID.
|
|
246
|
+
*
|
|
247
|
+
* @param providerName - The name of the provider.
|
|
248
|
+
* @param command - The command that is sent to the content script (among the {@link AvailableCommands}).
|
|
249
|
+
* @param params - The parameters that are sent to the content script.
|
|
250
|
+
* @param responseCallback - The callback function that is called when the content script sends a response.
|
|
251
|
+
* @returns void
|
|
252
|
+
*
|
|
253
|
+
*/
|
|
254
|
+
sendMessageToContentScript(providerName, command, params, responseCallback) {
|
|
255
|
+
if (!Object.values(__1.AvailableCommands).includes(command)) {
|
|
256
|
+
throw new Error(`Unknown command ${command}`);
|
|
257
|
+
}
|
|
258
|
+
const requestId = (0, uid_1.uid)();
|
|
259
|
+
const eventMessageRequest = {
|
|
260
|
+
params,
|
|
261
|
+
requestId,
|
|
262
|
+
};
|
|
263
|
+
this.pendingRequests.set(requestId, responseCallback);
|
|
264
|
+
// dispatch an event to the specific provider event target
|
|
265
|
+
const specificProviderEventTarget = document.getElementById(`${this.registeredProviders[providerName]}`);
|
|
266
|
+
if (!specificProviderEventTarget) {
|
|
267
|
+
throw new Error(`Registered provider with name ${providerName} does not exist`);
|
|
268
|
+
}
|
|
269
|
+
const isDispatched = specificProviderEventTarget.dispatchEvent(new CustomEvent(command, { detail: eventMessageRequest }));
|
|
270
|
+
if (!isDispatched) {
|
|
271
|
+
throw new Error(`Could not dispatch a message to ${this.registeredProviders[providerName]}`);
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* This method returns the registered providers.
|
|
276
|
+
*
|
|
277
|
+
* @returns The registered provider associated with its unique key.
|
|
278
|
+
*
|
|
279
|
+
*/
|
|
280
|
+
getWalletProviders() {
|
|
281
|
+
return this.registeredProviders;
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* This method handles the response from the content script by
|
|
285
|
+
* calling the response callback with the response and error objects.
|
|
286
|
+
*
|
|
287
|
+
* @param event - The event that is sent from the content script.
|
|
288
|
+
* @returns void
|
|
289
|
+
*
|
|
290
|
+
*/
|
|
291
|
+
handleResponseFromContentScript(event) {
|
|
292
|
+
const { result, error, requestId } = event.detail;
|
|
293
|
+
const responseCallback = this.pendingRequests.get(requestId);
|
|
294
|
+
if (responseCallback) {
|
|
295
|
+
if (error) {
|
|
296
|
+
responseCallback(null, new Error(error.message));
|
|
297
|
+
}
|
|
298
|
+
else {
|
|
299
|
+
responseCallback(result, null);
|
|
300
|
+
}
|
|
301
|
+
const deleted = this.pendingRequests.delete(requestId);
|
|
302
|
+
if (!deleted) {
|
|
303
|
+
console.error(`Error deleting a pending request with id ${requestId}`);
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
else {
|
|
307
|
+
console.error(`Request Id ${requestId} not found in response callback map`);
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
exports.connector = new Connector();
|
|
312
|
+
|
|
313
|
+
},{"..":4,"../thyra/ThyraDiscovery":11,"../thyra/ThyraProvider":12,"uid":46}],4:[function(require,module,exports){
|
|
314
|
+
"use strict";
|
|
315
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
316
|
+
exports.Provider = exports.EAccountImportResponse = exports.EAccountDeletionResponse = exports.Account = exports.providers = exports.AvailableCommands = void 0;
|
|
317
|
+
const Connector_1 = require("./connector/Connector");
|
|
318
|
+
const Provider_1 = require("./provider/Provider");
|
|
319
|
+
const ThyraProvider_1 = require("./thyra/ThyraProvider");
|
|
320
|
+
var AvailableCommands;
|
|
321
|
+
(function (AvailableCommands) {
|
|
322
|
+
AvailableCommands["ProviderListAccounts"] = "LIST_ACCOUNTS";
|
|
323
|
+
AvailableCommands["ProviderDeleteAccount"] = "DELETE_ACCOUNT";
|
|
324
|
+
AvailableCommands["ProviderImportAccount"] = "IMPORT_ACCOUNT";
|
|
325
|
+
AvailableCommands["ProviderGetNodesUrls"] = "GET_NODES_URLS";
|
|
326
|
+
AvailableCommands["AccountBalance"] = "ACCOUNT_BALANCE";
|
|
327
|
+
AvailableCommands["AccountSign"] = "ACCOUNT_SIGN";
|
|
328
|
+
AvailableCommands["ProviderGenerateNewAccount"] = "GENERATE_NEW_ACCOUNT";
|
|
329
|
+
AvailableCommands["AccountSellRolls"] = "ACCOUNT_SELL_ROLLS";
|
|
330
|
+
AvailableCommands["AccountBuyRolls"] = "ACCOUNT_BUY_ROLLS";
|
|
331
|
+
AvailableCommands["AccountSendTransaction"] = "ACCOUNT_SEND_TRANSACTION";
|
|
332
|
+
})(AvailableCommands = exports.AvailableCommands || (exports.AvailableCommands = {}));
|
|
333
|
+
function providers() {
|
|
334
|
+
let providers = [];
|
|
335
|
+
for (const providerName of Object.keys(Connector_1.connector.getWalletProviders())) {
|
|
336
|
+
if (providerName === ThyraProvider_1.THYRA_PROVIDER_NAME) {
|
|
337
|
+
const p = new ThyraProvider_1.ThyraProvider();
|
|
338
|
+
providers.push(p);
|
|
339
|
+
}
|
|
340
|
+
else {
|
|
341
|
+
const p = new Provider_1.Provider(providerName);
|
|
342
|
+
providers.push(p);
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
return providers;
|
|
346
|
+
}
|
|
347
|
+
exports.providers = providers;
|
|
348
|
+
var account_1 = require("./account");
|
|
349
|
+
Object.defineProperty(exports, "Account", { enumerable: true, get: function () { return account_1.Account; } });
|
|
350
|
+
var provider_1 = require("./provider");
|
|
351
|
+
Object.defineProperty(exports, "EAccountDeletionResponse", { enumerable: true, get: function () { return provider_1.EAccountDeletionResponse; } });
|
|
352
|
+
Object.defineProperty(exports, "EAccountImportResponse", { enumerable: true, get: function () { return provider_1.EAccountImportResponse; } });
|
|
353
|
+
Object.defineProperty(exports, "Provider", { enumerable: true, get: function () { return provider_1.Provider; } });
|
|
354
|
+
|
|
355
|
+
},{"./account":2,"./connector/Connector":3,"./provider":8,"./provider/Provider":7,"./thyra/ThyraProvider":12}],5:[function(require,module,exports){
|
|
356
|
+
"use strict";
|
|
357
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
358
|
+
exports.EAccountDeletionResponse = void 0;
|
|
359
|
+
/**
|
|
360
|
+
* This enum represents the possible responses from the content script
|
|
361
|
+
* in response to an account deletion request.
|
|
362
|
+
*/
|
|
363
|
+
var EAccountDeletionResponse;
|
|
364
|
+
(function (EAccountDeletionResponse) {
|
|
365
|
+
EAccountDeletionResponse[EAccountDeletionResponse["OK"] = 0] = "OK";
|
|
366
|
+
EAccountDeletionResponse[EAccountDeletionResponse["REFUSED"] = 1] = "REFUSED";
|
|
367
|
+
EAccountDeletionResponse[EAccountDeletionResponse["ERROR"] = 2] = "ERROR";
|
|
368
|
+
})(EAccountDeletionResponse = exports.EAccountDeletionResponse || (exports.EAccountDeletionResponse = {}));
|
|
369
|
+
|
|
370
|
+
},{}],6:[function(require,module,exports){
|
|
371
|
+
"use strict";
|
|
372
|
+
|
|
373
|
+
Object.defineProperty(exports, "__esModule", {
|
|
374
|
+
value: true
|
|
375
|
+
});
|
|
376
|
+
exports.EAccountImportResponse = void 0;
|
|
377
|
+
/**
|
|
378
|
+
* This enum represents the possible responses from the content script
|
|
379
|
+
* in response to an account import request.
|
|
380
|
+
*/
|
|
381
|
+
var EAccountImportResponse;
|
|
382
|
+
(function (EAccountImportResponse) {
|
|
383
|
+
EAccountImportResponse[EAccountImportResponse["OK"] = 0] = "OK";
|
|
384
|
+
EAccountImportResponse[EAccountImportResponse["REFUSED"] = 1] = "REFUSED";
|
|
385
|
+
EAccountImportResponse[EAccountImportResponse["ERROR"] = 2] = "ERROR";
|
|
386
|
+
})(EAccountImportResponse = exports.EAccountImportResponse || (exports.EAccountImportResponse = {}));
|
|
387
|
+
|
|
388
|
+
},{}],7:[function(require,module,exports){
|
|
389
|
+
"use strict";
|
|
390
|
+
|
|
391
|
+
Object.defineProperty(exports, "__esModule", {
|
|
392
|
+
value: true
|
|
393
|
+
});
|
|
394
|
+
exports.Provider = void 0;
|
|
395
|
+
const Connector_1 = require("../connector/Connector");
|
|
396
|
+
const Account_1 = require("../account/Account");
|
|
397
|
+
const __1 = require("..");
|
|
398
|
+
/**
|
|
399
|
+
* The Provider class provides a simple and intuitive interface for interacting with a specific
|
|
400
|
+
* wallet service.
|
|
401
|
+
*
|
|
402
|
+
*/
|
|
403
|
+
class Provider {
|
|
404
|
+
/**
|
|
405
|
+
* Provider constructor
|
|
406
|
+
*
|
|
407
|
+
* @param providerName - The name of the provider.
|
|
408
|
+
* @returns An instance of the Provider class.
|
|
409
|
+
*/
|
|
410
|
+
constructor(providerName) {
|
|
411
|
+
this.providerName = providerName;
|
|
412
|
+
}
|
|
413
|
+
/**
|
|
414
|
+
* This method returns the name of the provider.
|
|
415
|
+
* @returns The name of the provider.
|
|
416
|
+
*/
|
|
417
|
+
name() {
|
|
418
|
+
return this.providerName;
|
|
419
|
+
}
|
|
420
|
+
/**
|
|
421
|
+
* This method sends a message to the content script to get the list of accounts for the provider.
|
|
422
|
+
* It returns a Promise that resolves to an array of Account instances.
|
|
423
|
+
*
|
|
424
|
+
* @returns A promise that resolves to an array of Account instances.
|
|
425
|
+
*/
|
|
426
|
+
async accounts() {
|
|
427
|
+
const providersPromise = new Promise((resolve, reject) => {
|
|
428
|
+
Connector_1.connector.sendMessageToContentScript(this.providerName, __1.AvailableCommands.ProviderListAccounts, {}, (result, err) => {
|
|
429
|
+
if (err) return reject(err);
|
|
430
|
+
return resolve(result);
|
|
431
|
+
});
|
|
432
|
+
});
|
|
433
|
+
const providerAccounts = await providersPromise;
|
|
434
|
+
let accounts = [];
|
|
435
|
+
for (const providerAccount of providerAccounts) {
|
|
436
|
+
const accInstance = new Account_1.Account(providerAccount, this.providerName);
|
|
437
|
+
accounts.push(accInstance);
|
|
438
|
+
}
|
|
439
|
+
return accounts;
|
|
440
|
+
}
|
|
441
|
+
/**
|
|
442
|
+
* This method sends a message to the content script to import an account with the given publicKey and privateKey.
|
|
443
|
+
*
|
|
444
|
+
* @remarks
|
|
445
|
+
* - The IAccountImportResponse object contains the address of the imported account.
|
|
446
|
+
* - The address is generated from the public key.
|
|
447
|
+
*
|
|
448
|
+
* @param publicKey - The public key of the account.
|
|
449
|
+
* @param privateKey - The private key of the account.
|
|
450
|
+
* @returns a Promise that resolves to an instance of IAccountImportResponse.
|
|
451
|
+
*
|
|
452
|
+
*/
|
|
453
|
+
async importAccount(publicKey, privateKey) {
|
|
454
|
+
const accountImportRequest = {
|
|
455
|
+
publicKey,
|
|
456
|
+
privateKey
|
|
457
|
+
};
|
|
458
|
+
return new Promise((resolve, reject) => {
|
|
459
|
+
Connector_1.connector.sendMessageToContentScript(this.providerName, __1.AvailableCommands.ProviderImportAccount, accountImportRequest, (result, err) => {
|
|
460
|
+
if (err) return reject(err);
|
|
461
|
+
return resolve(result);
|
|
462
|
+
});
|
|
463
|
+
});
|
|
464
|
+
}
|
|
465
|
+
/**
|
|
466
|
+
* This method sends a message to the content script to delete the account associated with the given address.
|
|
467
|
+
*
|
|
468
|
+
* @param address - The address of the account.
|
|
469
|
+
* @returns a Promise that resolves to an instance of IAccountDeletionResponse.
|
|
470
|
+
*/
|
|
471
|
+
async deleteAccount(address) {
|
|
472
|
+
const accountDeletionRequest = {
|
|
473
|
+
address
|
|
474
|
+
};
|
|
475
|
+
return new Promise((resolve, reject) => {
|
|
476
|
+
Connector_1.connector.sendMessageToContentScript(this.providerName, __1.AvailableCommands.ProviderDeleteAccount, accountDeletionRequest, (result, err) => {
|
|
477
|
+
if (err) return reject(err);
|
|
478
|
+
return resolve(result);
|
|
479
|
+
});
|
|
480
|
+
});
|
|
481
|
+
}
|
|
482
|
+
/**
|
|
483
|
+
* This method sends a message to the content script to get the list of nodes urls
|
|
484
|
+
* used to connect the front end to the Massa network.
|
|
485
|
+
*
|
|
486
|
+
* @returns a Promise that resolves to an array of nodes urls (string).
|
|
487
|
+
*
|
|
488
|
+
*/
|
|
489
|
+
async getNodesUrls() {
|
|
490
|
+
return new Promise((resolve, reject) => {
|
|
491
|
+
Connector_1.connector.sendMessageToContentScript(this.providerName, __1.AvailableCommands.ProviderGetNodesUrls, {}, (result, err) => {
|
|
492
|
+
if (err) return reject(err);
|
|
493
|
+
return resolve(result);
|
|
494
|
+
});
|
|
495
|
+
});
|
|
496
|
+
}
|
|
497
|
+
/**
|
|
498
|
+
* This method generates a new account by a given name and adds it to the wallet.
|
|
499
|
+
*
|
|
500
|
+
* @param name - The account name
|
|
501
|
+
* @returns a Promise that resolves to an instance of IAccountDetails.
|
|
502
|
+
*/
|
|
503
|
+
async generateNewAccount(name) {
|
|
504
|
+
const accountGenerationRequest = {
|
|
505
|
+
name
|
|
506
|
+
};
|
|
507
|
+
return new Promise((resolve, reject) => {
|
|
508
|
+
Connector_1.connector.sendMessageToContentScript(this.providerName, __1.AvailableCommands.ProviderGenerateNewAccount, accountGenerationRequest, (result, err) => {
|
|
509
|
+
if (err) return reject(err);
|
|
510
|
+
return resolve(result);
|
|
511
|
+
});
|
|
512
|
+
});
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
exports.Provider = Provider;
|
|
516
|
+
|
|
517
|
+
},{"..":4,"../account/Account":1,"../connector/Connector":3}],8:[function(require,module,exports){
|
|
518
|
+
"use strict";
|
|
519
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
520
|
+
exports.Provider = exports.EAccountImportResponse = exports.EAccountDeletionResponse = void 0;
|
|
521
|
+
var AccountDeletion_1 = require("./AccountDeletion");
|
|
522
|
+
Object.defineProperty(exports, "EAccountDeletionResponse", { enumerable: true, get: function () { return AccountDeletion_1.EAccountDeletionResponse; } });
|
|
523
|
+
var AccountImport_1 = require("./AccountImport");
|
|
524
|
+
Object.defineProperty(exports, "EAccountImportResponse", { enumerable: true, get: function () { return AccountImport_1.EAccountImportResponse; } });
|
|
525
|
+
var Provider_1 = require("./Provider");
|
|
526
|
+
Object.defineProperty(exports, "Provider", { enumerable: true, get: function () { return Provider_1.Provider; } });
|
|
527
|
+
|
|
528
|
+
},{"./AccountDeletion":5,"./AccountImport":6,"./Provider":7}],9:[function(require,module,exports){
|
|
529
|
+
"use strict";
|
|
530
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
531
|
+
exports.deleteRequest = exports.postRequest = exports.getRequest = void 0;
|
|
532
|
+
/**
|
|
533
|
+
* This file defines a TypeScript module with methods for performing GET, POST and DELETE http requests.
|
|
534
|
+
*
|
|
535
|
+
* @remarks
|
|
536
|
+
* - The methods implemented here are quite generic and might be useful in other contexts too
|
|
537
|
+
* but have been particularly developed for making http calls specific to Thyra's server API
|
|
538
|
+
* - If you want to work on this repo, you will probably be interested in this object
|
|
539
|
+
*
|
|
540
|
+
*/
|
|
541
|
+
const axios_1 = require("axios");
|
|
542
|
+
const requestHeaders = {
|
|
543
|
+
Accept: 'application/json,text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
|
|
544
|
+
'Access-Control-Allow-Origin': '*',
|
|
545
|
+
'Access-Control-Allow-Credentials': true,
|
|
546
|
+
'Access-Control-Allow-Methods': 'GET,PUT,POST,DELETE,PATCH,OPTIONS',
|
|
547
|
+
'Content-Type': 'application/json',
|
|
548
|
+
'Access-Control-Allow-Headers': 'Accept,authorization,Authorization,Content-Type',
|
|
549
|
+
};
|
|
550
|
+
/**
|
|
551
|
+
* This method makes a GET request to an http rest point.
|
|
552
|
+
*
|
|
553
|
+
*
|
|
554
|
+
* @param url - The url to call.
|
|
555
|
+
* @returns a Promise that resolves to an instance of JsonRpcResponseData.
|
|
556
|
+
*
|
|
557
|
+
*/
|
|
558
|
+
async function getRequest(url) {
|
|
559
|
+
let resp = null;
|
|
560
|
+
try {
|
|
561
|
+
resp = await axios_1.default.get(url, requestHeaders);
|
|
562
|
+
}
|
|
563
|
+
catch (ex) {
|
|
564
|
+
return {
|
|
565
|
+
isError: true,
|
|
566
|
+
result: null,
|
|
567
|
+
error: new Error('Axios Error: ' + String(ex)),
|
|
568
|
+
};
|
|
569
|
+
}
|
|
570
|
+
return {
|
|
571
|
+
isError: false,
|
|
572
|
+
result: resp.data,
|
|
573
|
+
error: null,
|
|
574
|
+
};
|
|
575
|
+
}
|
|
576
|
+
exports.getRequest = getRequest;
|
|
577
|
+
/**
|
|
578
|
+
* This method makes a POST request to an http rest point.
|
|
579
|
+
*
|
|
580
|
+
*
|
|
581
|
+
* @param url - The url to call.
|
|
582
|
+
* @returns a Promise that resolves to an instance of JsonRpcResponseData.
|
|
583
|
+
*
|
|
584
|
+
*/
|
|
585
|
+
async function postRequest(url, body) {
|
|
586
|
+
let resp = null;
|
|
587
|
+
try {
|
|
588
|
+
resp = await axios_1.default.post(url, body, requestHeaders);
|
|
589
|
+
}
|
|
590
|
+
catch (ex) {
|
|
591
|
+
return {
|
|
592
|
+
isError: true,
|
|
593
|
+
result: null,
|
|
594
|
+
error: new Error('Axios error: ' + String(ex)),
|
|
595
|
+
};
|
|
596
|
+
}
|
|
597
|
+
return {
|
|
598
|
+
isError: false,
|
|
599
|
+
result: resp.data,
|
|
600
|
+
error: null,
|
|
601
|
+
};
|
|
602
|
+
}
|
|
603
|
+
exports.postRequest = postRequest;
|
|
604
|
+
/**
|
|
605
|
+
* This method makes a DELETE request to an http rest point.
|
|
606
|
+
*
|
|
607
|
+
*
|
|
608
|
+
* @param url - The url to call.
|
|
609
|
+
* @returns a Promise that resolves to an instance of JsonRpcResponseData.
|
|
610
|
+
*
|
|
611
|
+
*/
|
|
612
|
+
async function deleteRequest(url) {
|
|
613
|
+
let resp = null;
|
|
614
|
+
try {
|
|
615
|
+
resp = await axios_1.default.delete(url, requestHeaders);
|
|
616
|
+
}
|
|
617
|
+
catch (ex) {
|
|
618
|
+
return {
|
|
619
|
+
isError: true,
|
|
620
|
+
result: null,
|
|
621
|
+
error: new Error('Axios Error: ' + String(ex)),
|
|
622
|
+
};
|
|
623
|
+
}
|
|
624
|
+
return {
|
|
625
|
+
isError: false,
|
|
626
|
+
result: resp.data,
|
|
627
|
+
error: null,
|
|
628
|
+
};
|
|
629
|
+
}
|
|
630
|
+
exports.deleteRequest = deleteRequest;
|
|
631
|
+
|
|
632
|
+
},{"axios":14}],10:[function(require,module,exports){
|
|
633
|
+
"use strict";
|
|
634
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
635
|
+
exports.ThyraAccount = void 0;
|
|
636
|
+
const RequestHandler_1 = require("./RequestHandler");
|
|
637
|
+
const ThyraProvider_1 = require("./ThyraProvider");
|
|
638
|
+
/**
|
|
639
|
+
* The Thyra's account balance url
|
|
640
|
+
*/
|
|
641
|
+
const THYRA_BALANCE_URL = `https://my.massa/massa/addresses?attributes=balance&addresses`;
|
|
642
|
+
/**
|
|
643
|
+
* This module contains the ThyraAccount class. It is responsible for representing an account in the Thyra wallet.
|
|
644
|
+
*
|
|
645
|
+
* @remarks
|
|
646
|
+
* This class provides methods to interact with Thyra account's {@link balance} and to {@link sign} messages.
|
|
647
|
+
*
|
|
648
|
+
*/
|
|
649
|
+
class ThyraAccount {
|
|
650
|
+
/**
|
|
651
|
+
* This constructor takes an object of type IAccountDetails and a providerName string as its arguments.
|
|
652
|
+
*
|
|
653
|
+
* @param address - The address of the account.
|
|
654
|
+
* @param name - The name of the account.
|
|
655
|
+
* @param providerName - The name of the provider.
|
|
656
|
+
* @returns An instance of the Account class.
|
|
657
|
+
*
|
|
658
|
+
* @remarks
|
|
659
|
+
* - The Account constructor takes an object of type IAccountDetails and a providerName string as its arguments.
|
|
660
|
+
* - The IAccountDetails object contains the account's address and name.
|
|
661
|
+
* - The providerName string identifies the provider that is used to interact with the blockchain.
|
|
662
|
+
*/
|
|
663
|
+
constructor({ address, name }, providerName) {
|
|
664
|
+
this._address = address;
|
|
665
|
+
this._name = name;
|
|
666
|
+
this._providerName = providerName;
|
|
667
|
+
}
|
|
668
|
+
/**
|
|
669
|
+
* @returns The address of the account.
|
|
670
|
+
*/
|
|
671
|
+
address() {
|
|
672
|
+
return this._address;
|
|
673
|
+
}
|
|
674
|
+
/**
|
|
675
|
+
* @returns The name of the account.
|
|
676
|
+
*/
|
|
677
|
+
name() {
|
|
678
|
+
return this._name;
|
|
679
|
+
}
|
|
680
|
+
/**
|
|
681
|
+
* @returns The name of the provider.
|
|
682
|
+
*/
|
|
683
|
+
providerName() {
|
|
684
|
+
return this._providerName;
|
|
685
|
+
}
|
|
686
|
+
/**
|
|
687
|
+
* This method aims to retrieve the account's balance.
|
|
688
|
+
*
|
|
689
|
+
* @returns A promise that resolves to an object of type IAccountBalanceResponse. It contains the account's balance.
|
|
690
|
+
*/
|
|
691
|
+
async balance() {
|
|
692
|
+
let signOpResponse = null;
|
|
693
|
+
try {
|
|
694
|
+
signOpResponse = await (0, RequestHandler_1.getRequest)(`${THYRA_BALANCE_URL}=${this._address}`);
|
|
695
|
+
}
|
|
696
|
+
catch (ex) {
|
|
697
|
+
console.error(`Thyra account balance error`);
|
|
698
|
+
throw ex;
|
|
699
|
+
}
|
|
700
|
+
if (signOpResponse.isError || signOpResponse.error) {
|
|
701
|
+
throw signOpResponse.error;
|
|
702
|
+
}
|
|
703
|
+
const balance = signOpResponse.result.addressesAttributes[this._address].balance;
|
|
704
|
+
return {
|
|
705
|
+
finalBalance: balance.final,
|
|
706
|
+
candidateBalance: balance.pending,
|
|
707
|
+
};
|
|
708
|
+
}
|
|
709
|
+
/**
|
|
710
|
+
* This method aims to sign a message.
|
|
711
|
+
*
|
|
712
|
+
* @param data - The message to be signed.
|
|
713
|
+
* @returns An IAccountSignResponse object. It contains the signature of the message.
|
|
714
|
+
*/
|
|
715
|
+
async sign(data) {
|
|
716
|
+
let signOpResponse = null;
|
|
717
|
+
try {
|
|
718
|
+
signOpResponse = await (0, RequestHandler_1.postRequest)(`${ThyraProvider_1.THYRA_ACCOUNTS_URL}/${this._name}/signOperation`, {
|
|
719
|
+
operation: data,
|
|
720
|
+
batch: false,
|
|
721
|
+
});
|
|
722
|
+
}
|
|
723
|
+
catch (ex) {
|
|
724
|
+
console.error(`Thyra account signing error`);
|
|
725
|
+
throw ex;
|
|
726
|
+
}
|
|
727
|
+
if (signOpResponse.isError || signOpResponse.error) {
|
|
728
|
+
throw signOpResponse.error;
|
|
729
|
+
}
|
|
730
|
+
return signOpResponse.result;
|
|
731
|
+
}
|
|
732
|
+
/**
|
|
733
|
+
* This method aims to buy rolls on behalf of the sender.
|
|
734
|
+
*
|
|
735
|
+
* @param amount - The amount of rolls to be bought.
|
|
736
|
+
* @param fee - The fee to be paid for the transaction execution by the node.
|
|
737
|
+
* @returns An ITransactionDetails object. It contains the operationId on the network.
|
|
738
|
+
*/
|
|
739
|
+
buyRolls(amount, fee) {
|
|
740
|
+
throw new Error('Method not implemented.');
|
|
741
|
+
}
|
|
742
|
+
/**
|
|
743
|
+
* This method aims to sell rolls on behalf of the sender.
|
|
744
|
+
*
|
|
745
|
+
* @param amount - The amount of rolls to be sold.
|
|
746
|
+
* @param fee - The fee to be paid for the transaction execution by the node.
|
|
747
|
+
* @returns An ITransactionDetails object. It contains the operationId on the network.
|
|
748
|
+
*/
|
|
749
|
+
sellRolls(amount, fee) {
|
|
750
|
+
throw new Error('Method not implemented.');
|
|
751
|
+
}
|
|
752
|
+
/**
|
|
753
|
+
* This method aims to transfer MAS on behalf of the sender to a recipient.
|
|
754
|
+
*
|
|
755
|
+
* @param amount - The amount of MAS to be transferred.
|
|
756
|
+
* @param fee - The fee to be paid for the transaction execution by the node.
|
|
757
|
+
* @returns An ITransactionDetails object. It contains the operationId on the network.
|
|
758
|
+
*/
|
|
759
|
+
sendTransaction(amount, recipientAddress, fee) {
|
|
760
|
+
throw new Error('Method not implemented.');
|
|
761
|
+
}
|
|
762
|
+
}
|
|
763
|
+
exports.ThyraAccount = ThyraAccount;
|
|
764
|
+
|
|
765
|
+
},{"./RequestHandler":9,"./ThyraProvider":12}],11:[function(require,module,exports){
|
|
766
|
+
"use strict";
|
|
767
|
+
/**
|
|
768
|
+
* This file defines a TypeScript class named ThyraDiscovery.
|
|
769
|
+
* The class is being used to recursively search for a connection to Thyra's server
|
|
770
|
+
* and if so report this via emitting messages.
|
|
771
|
+
*
|
|
772
|
+
* @remarks
|
|
773
|
+
* - If you are only looking to use our library, the connector ThyraDiscovery will not be useful to you.
|
|
774
|
+
* - If you want to work on this repo, you will probably be interested in this object
|
|
775
|
+
*
|
|
776
|
+
*/
|
|
777
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
778
|
+
exports.ThyraDiscovery = exports.ON_THYRA_DISCONNECTED = exports.ON_THYRA_DISCOVERED = exports.THYRA_DISCOVERY_URL = void 0;
|
|
779
|
+
const events_1 = require("events");
|
|
780
|
+
const time_1 = require("../utils/time");
|
|
781
|
+
const RequestHandler_1 = require("./RequestHandler");
|
|
782
|
+
/**
|
|
783
|
+
* Url used for the thyra discovery and pinging the thyra server's index.html
|
|
784
|
+
*/
|
|
785
|
+
exports.THYRA_DISCOVERY_URL = 'https://my.massa/thyra/home/index.html';
|
|
786
|
+
/**
|
|
787
|
+
* A message emitted on successful Thyra discovery
|
|
788
|
+
*/
|
|
789
|
+
exports.ON_THYRA_DISCOVERED = 'ON_THYRA_DISCOVERED';
|
|
790
|
+
/**
|
|
791
|
+
* A message emitted on Thyra disconnect
|
|
792
|
+
*/
|
|
793
|
+
exports.ON_THYRA_DISCONNECTED = 'ON_THYRA_DISCONNECTED';
|
|
794
|
+
/**
|
|
795
|
+
* This file defines a TypeScript class named ThyraDiscovery.
|
|
796
|
+
* The class is being used to recursively ping Thyra's server
|
|
797
|
+
* and if a response is received emit a message so Thyra can be enlisted as a wallet provider in the `Connector` class.
|
|
798
|
+
*/
|
|
799
|
+
class ThyraDiscovery extends events_1.EventEmitter {
|
|
800
|
+
/**
|
|
801
|
+
* ThyraDiscovery constructor
|
|
802
|
+
*
|
|
803
|
+
* @param pollIntervalMillis - Polling interval defined in milliseconds
|
|
804
|
+
*
|
|
805
|
+
* @remarks
|
|
806
|
+
* - It creates a timeout using the given `pollIntervalMillis` argument on every trigger of which
|
|
807
|
+
* the Thyra pinging is triggered and if a successful response is fetched,
|
|
808
|
+
* a message `ON_THYRA_DISCOVERED` is emitted that Thyra has been discovered
|
|
809
|
+
* as a wallet provider upon which the `Connector` class will enlist Thyra as a wallet provider
|
|
810
|
+
* - If once found, but then disconnected the following message `ON_THYRA_DISCONNECTED` is being emitted
|
|
811
|
+
* so that the `Connector` class delists Thyra as a wallet provider
|
|
812
|
+
*
|
|
813
|
+
* @returns An instance of the ThyraDiscovery class.
|
|
814
|
+
*
|
|
815
|
+
*/
|
|
816
|
+
constructor(pollIntervalMillis) {
|
|
817
|
+
super();
|
|
818
|
+
this.pollIntervalMillis = pollIntervalMillis;
|
|
819
|
+
this.timeoutId = null;
|
|
820
|
+
this.isDiscovered = false;
|
|
821
|
+
// bind class methods
|
|
822
|
+
this.callback = this.callback.bind(this);
|
|
823
|
+
this.stopListening = this.stopListening.bind(this);
|
|
824
|
+
this.startListening = this.startListening.bind(this);
|
|
825
|
+
}
|
|
826
|
+
/**
|
|
827
|
+
* A callback method that triggers a ping of the Thyra's server
|
|
828
|
+
*
|
|
829
|
+
* @returns void
|
|
830
|
+
*/
|
|
831
|
+
async callback() {
|
|
832
|
+
let resp = null;
|
|
833
|
+
try {
|
|
834
|
+
resp = await (0, RequestHandler_1.getRequest)(exports.THYRA_DISCOVERY_URL);
|
|
835
|
+
}
|
|
836
|
+
catch (ex) {
|
|
837
|
+
console.error(`Error calling ${exports.THYRA_DISCOVERY_URL}`);
|
|
838
|
+
}
|
|
839
|
+
if (!resp.isError && !resp.error) {
|
|
840
|
+
this.isDiscovered = true;
|
|
841
|
+
this.emit(exports.ON_THYRA_DISCOVERED);
|
|
842
|
+
}
|
|
843
|
+
if ((resp.isError || resp.error) && this.isDiscovered) {
|
|
844
|
+
this.emit(exports.ON_THYRA_DISCONNECTED);
|
|
845
|
+
}
|
|
846
|
+
// reset the interval
|
|
847
|
+
this.timeoutId = new time_1.Timeout(this.pollIntervalMillis, () => this.callback());
|
|
848
|
+
}
|
|
849
|
+
/**
|
|
850
|
+
* A method to stop listening for a connection to Thyra's server
|
|
851
|
+
*
|
|
852
|
+
* @returns void
|
|
853
|
+
*/
|
|
854
|
+
stopListening() {
|
|
855
|
+
if (this.timeoutId)
|
|
856
|
+
this.timeoutId.clear();
|
|
857
|
+
}
|
|
858
|
+
/**
|
|
859
|
+
* A method to start listening for a connection to Thyra's server.
|
|
860
|
+
*
|
|
861
|
+
* @returns void
|
|
862
|
+
*/
|
|
863
|
+
startListening() {
|
|
864
|
+
const that = this;
|
|
865
|
+
if (this.timeoutId) {
|
|
866
|
+
return;
|
|
867
|
+
}
|
|
868
|
+
this.timeoutId = new time_1.Timeout(this.pollIntervalMillis, () => that.callback());
|
|
869
|
+
}
|
|
870
|
+
}
|
|
871
|
+
exports.ThyraDiscovery = ThyraDiscovery;
|
|
872
|
+
|
|
873
|
+
},{"../utils/time":13,"./RequestHandler":9,"events":44}],12:[function(require,module,exports){
|
|
874
|
+
"use strict";
|
|
875
|
+
|
|
876
|
+
Object.defineProperty(exports, "__esModule", {
|
|
877
|
+
value: true
|
|
878
|
+
});
|
|
879
|
+
exports.ThyraProvider = exports.THYRA_PROVIDER_NAME = exports.THYRA_IMPORT_ACCOUNTS_URL = exports.THYRA_ACCOUNTS_URL = void 0;
|
|
880
|
+
const AccountDeletion_1 = require("../provider/AccountDeletion");
|
|
881
|
+
const RequestHandler_1 = require("./RequestHandler");
|
|
882
|
+
const ThyraAccount_1 = require("./ThyraAccount");
|
|
883
|
+
/**
|
|
884
|
+
* The Thyra accounts url
|
|
885
|
+
*/
|
|
886
|
+
exports.THYRA_ACCOUNTS_URL = 'https://my.massa/thyra/plugin/massalabs/wallet/rest/wallet';
|
|
887
|
+
/**
|
|
888
|
+
* Thyra's url for importing accounts
|
|
889
|
+
*/
|
|
890
|
+
exports.THYRA_IMPORT_ACCOUNTS_URL = `${exports.THYRA_ACCOUNTS_URL}/import/`;
|
|
891
|
+
/**
|
|
892
|
+
* Thyra's wallet provider name
|
|
893
|
+
*/
|
|
894
|
+
exports.THYRA_PROVIDER_NAME = 'THYRA';
|
|
895
|
+
/**
|
|
896
|
+
* This class provides an implementation for communicating with the Thyra wallet provider.
|
|
897
|
+
* @remarks
|
|
898
|
+
* This class is used as a proxy to the Thyra server for exchanging message over https calls.
|
|
899
|
+
*/
|
|
900
|
+
class ThyraProvider {
|
|
901
|
+
/**
|
|
902
|
+
* Provider constructor
|
|
903
|
+
*
|
|
904
|
+
* @param providerName - The name of the provider.
|
|
905
|
+
* @returns An instance of the Provider class.
|
|
906
|
+
*/
|
|
907
|
+
constructor() {
|
|
908
|
+
this.providerName = exports.THYRA_PROVIDER_NAME;
|
|
909
|
+
}
|
|
910
|
+
/**
|
|
911
|
+
* This method returns the name of the provider.
|
|
912
|
+
* @returns The name of the provider.
|
|
913
|
+
*/
|
|
914
|
+
name() {
|
|
915
|
+
return this.providerName;
|
|
916
|
+
}
|
|
917
|
+
/**
|
|
918
|
+
* This method sends a message to the Thyra server to get the list of accounts for the provider.
|
|
919
|
+
* It returns a Promise that resolves to an array of Account instances.
|
|
920
|
+
*
|
|
921
|
+
* @returns A promise that resolves to an array of Account instances.
|
|
922
|
+
*/
|
|
923
|
+
async accounts() {
|
|
924
|
+
let thyraAccountsResponse = null;
|
|
925
|
+
try {
|
|
926
|
+
thyraAccountsResponse = await (0, RequestHandler_1.getRequest)(exports.THYRA_ACCOUNTS_URL);
|
|
927
|
+
} catch (ex) {
|
|
928
|
+
console.error(`Thyra accounts retrieval error`);
|
|
929
|
+
throw ex;
|
|
930
|
+
}
|
|
931
|
+
if (thyraAccountsResponse.isError || thyraAccountsResponse.error) {
|
|
932
|
+
throw thyraAccountsResponse.error.message;
|
|
933
|
+
}
|
|
934
|
+
return thyraAccountsResponse.result.map(thyraAccount => {
|
|
935
|
+
return new ThyraAccount_1.ThyraAccount({
|
|
936
|
+
address: thyraAccount.address,
|
|
937
|
+
name: thyraAccount.nickname
|
|
938
|
+
}, this.providerName);
|
|
939
|
+
});
|
|
940
|
+
}
|
|
941
|
+
/**
|
|
942
|
+
* This method makes an http call to the Thyra server to import an account with the given publicKey and privateKey.
|
|
943
|
+
*
|
|
944
|
+
* @remarks This method in not yet implemented and depends on `massalabs/thyra-plugin-wallet#82` to be merged first
|
|
945
|
+
*
|
|
946
|
+
* @param publicKey - The public key of the account.
|
|
947
|
+
* @param privateKey - The private key of the account.
|
|
948
|
+
* @returns a Promise that resolves to an instance of IAccountImportResponse.
|
|
949
|
+
*
|
|
950
|
+
*/
|
|
951
|
+
async importAccount(publicKey, privateKey) {
|
|
952
|
+
// TODO: once massalabs/thyra-plugin-wallet#82 is merged, to be updated here
|
|
953
|
+
throw new Error(`Unimplemented method!`);
|
|
954
|
+
}
|
|
955
|
+
/**
|
|
956
|
+
* This method sends an http call to the Thyra server to delete the account associated with the given address.
|
|
957
|
+
*
|
|
958
|
+
* @param address - The address of the account.
|
|
959
|
+
* @returns a Promise that resolves to an instance of IAccountDeletionResponse.
|
|
960
|
+
*/
|
|
961
|
+
async deleteAccount(address) {
|
|
962
|
+
// get all accounts
|
|
963
|
+
let allAccounts = null;
|
|
964
|
+
try {
|
|
965
|
+
allAccounts = await (0, RequestHandler_1.getRequest)(exports.THYRA_ACCOUNTS_URL);
|
|
966
|
+
} catch (ex) {
|
|
967
|
+
console.error(`Thyra accounts retrieval error`);
|
|
968
|
+
throw ex;
|
|
969
|
+
}
|
|
970
|
+
if (allAccounts.isError || allAccounts.error) {
|
|
971
|
+
throw allAccounts.error.message;
|
|
972
|
+
}
|
|
973
|
+
// find the account with the desired address
|
|
974
|
+
const accountToDelete = allAccounts.result.find(account => account.address.toLowerCase() === address.toLowerCase());
|
|
975
|
+
// delete the account in question
|
|
976
|
+
let thyraAccountsResponse = null;
|
|
977
|
+
try {
|
|
978
|
+
thyraAccountsResponse = await (0, RequestHandler_1.deleteRequest)(`${exports.THYRA_ACCOUNTS_URL}/${accountToDelete.nickname}`);
|
|
979
|
+
} catch (ex) {
|
|
980
|
+
console.error(`Thyra accounts deletion error`, ex);
|
|
981
|
+
return {
|
|
982
|
+
response: AccountDeletion_1.EAccountDeletionResponse.ERROR
|
|
983
|
+
};
|
|
984
|
+
}
|
|
985
|
+
if (thyraAccountsResponse.isError || thyraAccountsResponse.error) {
|
|
986
|
+
console.error(`Thyra accounts deletion error`, thyraAccountsResponse.error.message);
|
|
987
|
+
return {
|
|
988
|
+
response: AccountDeletion_1.EAccountDeletionResponse.ERROR
|
|
989
|
+
};
|
|
990
|
+
}
|
|
991
|
+
return {
|
|
992
|
+
response: AccountDeletion_1.EAccountDeletionResponse.OK
|
|
993
|
+
};
|
|
994
|
+
}
|
|
995
|
+
/**
|
|
996
|
+
* This method sends an http call to the Thyra server to obtain node urls.
|
|
997
|
+
*
|
|
998
|
+
* @returns a Promise that resolves to a list of node urls.
|
|
999
|
+
*/
|
|
1000
|
+
async getNodesUrls() {
|
|
1001
|
+
throw new Error('Method not implemented.');
|
|
1002
|
+
}
|
|
1003
|
+
/**
|
|
1004
|
+
* This method sends an http call to the Thyra server to create a new random account.
|
|
1005
|
+
*
|
|
1006
|
+
* @returns a Promise that resolves to the details of the newly generated account.
|
|
1007
|
+
*/
|
|
1008
|
+
async generateNewAccount(name) {
|
|
1009
|
+
throw new Error('Method not implemented.');
|
|
1010
|
+
}
|
|
1011
|
+
}
|
|
1012
|
+
exports.ThyraProvider = ThyraProvider;
|
|
1013
|
+
|
|
1014
|
+
},{"../provider/AccountDeletion":5,"./RequestHandler":9,"./ThyraAccount":10}],13:[function(require,module,exports){
|
|
1015
|
+
"use strict";
|
|
1016
|
+
/**
|
|
1017
|
+
* This file defines a TypeScript module with various time-related Typescript methods.
|
|
1018
|
+
*
|
|
1019
|
+
* @remarks
|
|
1020
|
+
* - The classes and their methods implemented here are quite generic and might be useful in other contexts too
|
|
1021
|
+
* but have been particularly developed for the purposes of this library
|
|
1022
|
+
* - If you want to work on this repo, you will probably be interested in this object
|
|
1023
|
+
*
|
|
1024
|
+
*/
|
|
1025
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1026
|
+
exports.withTimeoutRejection = exports.wait = exports.Interval = exports.Timeout = void 0;
|
|
1027
|
+
/**
|
|
1028
|
+
* This class provides an implementation of a timer calling a callback hook after it ticks.
|
|
1029
|
+
* @remarks
|
|
1030
|
+
* The timer is being resetted only after the execution of the callback method has finished
|
|
1031
|
+
*/
|
|
1032
|
+
class Timeout {
|
|
1033
|
+
/**
|
|
1034
|
+
* Timeout constructor
|
|
1035
|
+
*
|
|
1036
|
+
* @param timeoutMil - The number of milliseconds for the timeout.
|
|
1037
|
+
* @param callback - a callback to execute.
|
|
1038
|
+
* @returns An instance of the Timeout class.
|
|
1039
|
+
*/
|
|
1040
|
+
constructor(timeoutMil, callback) {
|
|
1041
|
+
this.clear = this.clear.bind(this);
|
|
1042
|
+
const that = this;
|
|
1043
|
+
this.isCleared = false;
|
|
1044
|
+
this.isCalled = false;
|
|
1045
|
+
this.timeoutHook = setTimeout(() => {
|
|
1046
|
+
if (!that.isCleared) {
|
|
1047
|
+
this.isCalled = true;
|
|
1048
|
+
callback();
|
|
1049
|
+
}
|
|
1050
|
+
}, timeoutMil);
|
|
1051
|
+
}
|
|
1052
|
+
/**
|
|
1053
|
+
* A method to clear the timeout
|
|
1054
|
+
*
|
|
1055
|
+
* @returns void
|
|
1056
|
+
*/
|
|
1057
|
+
clear() {
|
|
1058
|
+
if (!this.isCleared) {
|
|
1059
|
+
clearTimeout(this.timeoutHook);
|
|
1060
|
+
this.isCleared = true;
|
|
1061
|
+
}
|
|
1062
|
+
}
|
|
1063
|
+
}
|
|
1064
|
+
exports.Timeout = Timeout;
|
|
1065
|
+
/**
|
|
1066
|
+
* This class provides an implementation of a continuous timer calling a callback hook after every given milliseconds.
|
|
1067
|
+
* @remarks
|
|
1068
|
+
* The timer is being resetted every given milliseconds
|
|
1069
|
+
* irregardless whether the execution of the method is still running or not
|
|
1070
|
+
*/
|
|
1071
|
+
class Interval {
|
|
1072
|
+
/**
|
|
1073
|
+
* Interval constructor
|
|
1074
|
+
*
|
|
1075
|
+
* @param timeoutMil - The number of milliseconds for the interval.
|
|
1076
|
+
* @param callback - a callback to execute.
|
|
1077
|
+
* @returns An instance of the Interval class.
|
|
1078
|
+
*/
|
|
1079
|
+
constructor(timeoutMil, callback) {
|
|
1080
|
+
this.clear = this.clear.bind(this);
|
|
1081
|
+
const that = this;
|
|
1082
|
+
this.isCleared = false;
|
|
1083
|
+
this.isCalled = false;
|
|
1084
|
+
this.intervalHook = setInterval(() => {
|
|
1085
|
+
if (!that.isCleared) {
|
|
1086
|
+
this.isCalled = true;
|
|
1087
|
+
callback();
|
|
1088
|
+
}
|
|
1089
|
+
}, timeoutMil);
|
|
1090
|
+
}
|
|
1091
|
+
/**
|
|
1092
|
+
* A method to clear the interval
|
|
1093
|
+
*
|
|
1094
|
+
* @returns void
|
|
1095
|
+
*/
|
|
1096
|
+
clear() {
|
|
1097
|
+
if (!this.isCleared) {
|
|
1098
|
+
clearInterval(this.intervalHook);
|
|
1099
|
+
this.isCleared = true;
|
|
1100
|
+
}
|
|
1101
|
+
}
|
|
1102
|
+
}
|
|
1103
|
+
exports.Interval = Interval;
|
|
1104
|
+
/**
|
|
1105
|
+
* A function that waits pauses the execution loop for a number of milliseconds
|
|
1106
|
+
*
|
|
1107
|
+
* @param timeMilli - The number of milliseconds to wait.
|
|
1108
|
+
* @returns void
|
|
1109
|
+
*/
|
|
1110
|
+
const wait = async (timeMilli) => {
|
|
1111
|
+
return new Promise((resolve, reject) => {
|
|
1112
|
+
const timeout = new Timeout(timeMilli, () => {
|
|
1113
|
+
timeout.clear();
|
|
1114
|
+
return resolve();
|
|
1115
|
+
});
|
|
1116
|
+
});
|
|
1117
|
+
};
|
|
1118
|
+
exports.wait = wait;
|
|
1119
|
+
/**
|
|
1120
|
+
* A function that awaits a promise with a timeout.
|
|
1121
|
+
*
|
|
1122
|
+
* @param promise - a promise to execute.
|
|
1123
|
+
* @param timeoutMs - The number of milliseconds to wait before a timeout.
|
|
1124
|
+
* @returns void
|
|
1125
|
+
*
|
|
1126
|
+
* @remarks
|
|
1127
|
+
* The promise is being polled with a timeout. Once the timeout is reached, if not fulfilled, the error is thrown.
|
|
1128
|
+
*/
|
|
1129
|
+
async function withTimeoutRejection(promise, timeoutMs) {
|
|
1130
|
+
const sleep = new Promise((resolve, reject) => setTimeout(() => reject(new Error(`Timeout of ${timeoutMs} has passed and promise did not resolve`)), timeoutMs));
|
|
1131
|
+
return Promise.race([promise, sleep]);
|
|
1132
|
+
}
|
|
1133
|
+
exports.withTimeoutRejection = withTimeoutRejection;
|
|
1134
|
+
|
|
1135
|
+
},{}],14:[function(require,module,exports){
|
|
1136
|
+
module.exports = require('./lib/axios');
|
|
1137
|
+
},{"./lib/axios":16}],15:[function(require,module,exports){
|
|
1138
|
+
'use strict';
|
|
1139
|
+
|
|
1140
|
+
var utils = require('./../utils');
|
|
1141
|
+
var settle = require('./../core/settle');
|
|
1142
|
+
var cookies = require('./../helpers/cookies');
|
|
1143
|
+
var buildURL = require('./../helpers/buildURL');
|
|
1144
|
+
var buildFullPath = require('../core/buildFullPath');
|
|
1145
|
+
var parseHeaders = require('./../helpers/parseHeaders');
|
|
1146
|
+
var isURLSameOrigin = require('./../helpers/isURLSameOrigin');
|
|
1147
|
+
var createError = require('../core/createError');
|
|
1148
|
+
var transitionalDefaults = require('../defaults/transitional');
|
|
1149
|
+
var Cancel = require('../cancel/Cancel');
|
|
1150
|
+
|
|
1151
|
+
module.exports = function xhrAdapter(config) {
|
|
1152
|
+
return new Promise(function dispatchXhrRequest(resolve, reject) {
|
|
1153
|
+
var requestData = config.data;
|
|
1154
|
+
var requestHeaders = config.headers;
|
|
1155
|
+
var responseType = config.responseType;
|
|
1156
|
+
var onCanceled;
|
|
1157
|
+
function done() {
|
|
1158
|
+
if (config.cancelToken) {
|
|
1159
|
+
config.cancelToken.unsubscribe(onCanceled);
|
|
1160
|
+
}
|
|
1161
|
+
|
|
1162
|
+
if (config.signal) {
|
|
1163
|
+
config.signal.removeEventListener('abort', onCanceled);
|
|
1164
|
+
}
|
|
1165
|
+
}
|
|
1166
|
+
|
|
1167
|
+
if (utils.isFormData(requestData)) {
|
|
1168
|
+
delete requestHeaders['Content-Type']; // Let the browser set it
|
|
1169
|
+
}
|
|
1170
|
+
|
|
1171
|
+
var request = new XMLHttpRequest();
|
|
1172
|
+
|
|
1173
|
+
// HTTP basic authentication
|
|
1174
|
+
if (config.auth) {
|
|
1175
|
+
var username = config.auth.username || '';
|
|
1176
|
+
var password = config.auth.password ? unescape(encodeURIComponent(config.auth.password)) : '';
|
|
1177
|
+
requestHeaders.Authorization = 'Basic ' + btoa(username + ':' + password);
|
|
1178
|
+
}
|
|
1179
|
+
|
|
1180
|
+
var fullPath = buildFullPath(config.baseURL, config.url);
|
|
1181
|
+
request.open(config.method.toUpperCase(), buildURL(fullPath, config.params, config.paramsSerializer), true);
|
|
1182
|
+
|
|
1183
|
+
// Set the request timeout in MS
|
|
1184
|
+
request.timeout = config.timeout;
|
|
1185
|
+
|
|
1186
|
+
function onloadend() {
|
|
1187
|
+
if (!request) {
|
|
1188
|
+
return;
|
|
1189
|
+
}
|
|
1190
|
+
// Prepare the response
|
|
1191
|
+
var responseHeaders = 'getAllResponseHeaders' in request ? parseHeaders(request.getAllResponseHeaders()) : null;
|
|
1192
|
+
var responseData = !responseType || responseType === 'text' || responseType === 'json' ?
|
|
1193
|
+
request.responseText : request.response;
|
|
1194
|
+
var response = {
|
|
1195
|
+
data: responseData,
|
|
1196
|
+
status: request.status,
|
|
1197
|
+
statusText: request.statusText,
|
|
1198
|
+
headers: responseHeaders,
|
|
1199
|
+
config: config,
|
|
1200
|
+
request: request
|
|
1201
|
+
};
|
|
1202
|
+
|
|
1203
|
+
settle(function _resolve(value) {
|
|
1204
|
+
resolve(value);
|
|
1205
|
+
done();
|
|
1206
|
+
}, function _reject(err) {
|
|
1207
|
+
reject(err);
|
|
1208
|
+
done();
|
|
1209
|
+
}, response);
|
|
1210
|
+
|
|
1211
|
+
// Clean up request
|
|
1212
|
+
request = null;
|
|
1213
|
+
}
|
|
1214
|
+
|
|
1215
|
+
if ('onloadend' in request) {
|
|
1216
|
+
// Use onloadend if available
|
|
1217
|
+
request.onloadend = onloadend;
|
|
1218
|
+
} else {
|
|
1219
|
+
// Listen for ready state to emulate onloadend
|
|
1220
|
+
request.onreadystatechange = function handleLoad() {
|
|
1221
|
+
if (!request || request.readyState !== 4) {
|
|
1222
|
+
return;
|
|
1223
|
+
}
|
|
1224
|
+
|
|
1225
|
+
// The request errored out and we didn't get a response, this will be
|
|
1226
|
+
// handled by onerror instead
|
|
1227
|
+
// With one exception: request that using file: protocol, most browsers
|
|
1228
|
+
// will return status as 0 even though it's a successful request
|
|
1229
|
+
if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) {
|
|
1230
|
+
return;
|
|
1231
|
+
}
|
|
1232
|
+
// readystate handler is calling before onerror or ontimeout handlers,
|
|
1233
|
+
// so we should call onloadend on the next 'tick'
|
|
1234
|
+
setTimeout(onloadend);
|
|
1235
|
+
};
|
|
1236
|
+
}
|
|
1237
|
+
|
|
1238
|
+
// Handle browser request cancellation (as opposed to a manual cancellation)
|
|
1239
|
+
request.onabort = function handleAbort() {
|
|
1240
|
+
if (!request) {
|
|
1241
|
+
return;
|
|
1242
|
+
}
|
|
1243
|
+
|
|
1244
|
+
reject(createError('Request aborted', config, 'ECONNABORTED', request));
|
|
1245
|
+
|
|
1246
|
+
// Clean up request
|
|
1247
|
+
request = null;
|
|
1248
|
+
};
|
|
1249
|
+
|
|
1250
|
+
// Handle low level network errors
|
|
1251
|
+
request.onerror = function handleError() {
|
|
1252
|
+
// Real errors are hidden from us by the browser
|
|
1253
|
+
// onerror should only fire if it's a network error
|
|
1254
|
+
reject(createError('Network Error', config, null, request));
|
|
1255
|
+
|
|
1256
|
+
// Clean up request
|
|
1257
|
+
request = null;
|
|
1258
|
+
};
|
|
1259
|
+
|
|
1260
|
+
// Handle timeout
|
|
1261
|
+
request.ontimeout = function handleTimeout() {
|
|
1262
|
+
var timeoutErrorMessage = config.timeout ? 'timeout of ' + config.timeout + 'ms exceeded' : 'timeout exceeded';
|
|
1263
|
+
var transitional = config.transitional || transitionalDefaults;
|
|
1264
|
+
if (config.timeoutErrorMessage) {
|
|
1265
|
+
timeoutErrorMessage = config.timeoutErrorMessage;
|
|
1266
|
+
}
|
|
1267
|
+
reject(createError(
|
|
1268
|
+
timeoutErrorMessage,
|
|
1269
|
+
config,
|
|
1270
|
+
transitional.clarifyTimeoutError ? 'ETIMEDOUT' : 'ECONNABORTED',
|
|
1271
|
+
request));
|
|
1272
|
+
|
|
1273
|
+
// Clean up request
|
|
1274
|
+
request = null;
|
|
1275
|
+
};
|
|
1276
|
+
|
|
1277
|
+
// Add xsrf header
|
|
1278
|
+
// This is only done if running in a standard browser environment.
|
|
1279
|
+
// Specifically not if we're in a web worker, or react-native.
|
|
1280
|
+
if (utils.isStandardBrowserEnv()) {
|
|
1281
|
+
// Add xsrf header
|
|
1282
|
+
var xsrfValue = (config.withCredentials || isURLSameOrigin(fullPath)) && config.xsrfCookieName ?
|
|
1283
|
+
cookies.read(config.xsrfCookieName) :
|
|
1284
|
+
undefined;
|
|
1285
|
+
|
|
1286
|
+
if (xsrfValue) {
|
|
1287
|
+
requestHeaders[config.xsrfHeaderName] = xsrfValue;
|
|
1288
|
+
}
|
|
1289
|
+
}
|
|
1290
|
+
|
|
1291
|
+
// Add headers to the request
|
|
1292
|
+
if ('setRequestHeader' in request) {
|
|
1293
|
+
utils.forEach(requestHeaders, function setRequestHeader(val, key) {
|
|
1294
|
+
if (typeof requestData === 'undefined' && key.toLowerCase() === 'content-type') {
|
|
1295
|
+
// Remove Content-Type if data is undefined
|
|
1296
|
+
delete requestHeaders[key];
|
|
1297
|
+
} else {
|
|
1298
|
+
// Otherwise add header to the request
|
|
1299
|
+
request.setRequestHeader(key, val);
|
|
1300
|
+
}
|
|
1301
|
+
});
|
|
1302
|
+
}
|
|
1303
|
+
|
|
1304
|
+
// Add withCredentials to request if needed
|
|
1305
|
+
if (!utils.isUndefined(config.withCredentials)) {
|
|
1306
|
+
request.withCredentials = !!config.withCredentials;
|
|
1307
|
+
}
|
|
1308
|
+
|
|
1309
|
+
// Add responseType to request if needed
|
|
1310
|
+
if (responseType && responseType !== 'json') {
|
|
1311
|
+
request.responseType = config.responseType;
|
|
1312
|
+
}
|
|
1313
|
+
|
|
1314
|
+
// Handle progress if needed
|
|
1315
|
+
if (typeof config.onDownloadProgress === 'function') {
|
|
1316
|
+
request.addEventListener('progress', config.onDownloadProgress);
|
|
1317
|
+
}
|
|
1318
|
+
|
|
1319
|
+
// Not all browsers support upload events
|
|
1320
|
+
if (typeof config.onUploadProgress === 'function' && request.upload) {
|
|
1321
|
+
request.upload.addEventListener('progress', config.onUploadProgress);
|
|
1322
|
+
}
|
|
1323
|
+
|
|
1324
|
+
if (config.cancelToken || config.signal) {
|
|
1325
|
+
// Handle cancellation
|
|
1326
|
+
// eslint-disable-next-line func-names
|
|
1327
|
+
onCanceled = function(cancel) {
|
|
1328
|
+
if (!request) {
|
|
1329
|
+
return;
|
|
1330
|
+
}
|
|
1331
|
+
reject(!cancel || (cancel && cancel.type) ? new Cancel('canceled') : cancel);
|
|
1332
|
+
request.abort();
|
|
1333
|
+
request = null;
|
|
1334
|
+
};
|
|
1335
|
+
|
|
1336
|
+
config.cancelToken && config.cancelToken.subscribe(onCanceled);
|
|
1337
|
+
if (config.signal) {
|
|
1338
|
+
config.signal.aborted ? onCanceled() : config.signal.addEventListener('abort', onCanceled);
|
|
1339
|
+
}
|
|
1340
|
+
}
|
|
1341
|
+
|
|
1342
|
+
if (!requestData) {
|
|
1343
|
+
requestData = null;
|
|
1344
|
+
}
|
|
1345
|
+
|
|
1346
|
+
// Send the request
|
|
1347
|
+
request.send(requestData);
|
|
1348
|
+
});
|
|
1349
|
+
};
|
|
1350
|
+
|
|
1351
|
+
},{"../cancel/Cancel":17,"../core/buildFullPath":22,"../core/createError":23,"../defaults/transitional":30,"./../core/settle":27,"./../helpers/buildURL":33,"./../helpers/cookies":35,"./../helpers/isURLSameOrigin":38,"./../helpers/parseHeaders":40,"./../utils":43}],16:[function(require,module,exports){
|
|
1352
|
+
'use strict';
|
|
1353
|
+
|
|
1354
|
+
var utils = require('./utils');
|
|
1355
|
+
var bind = require('./helpers/bind');
|
|
1356
|
+
var Axios = require('./core/Axios');
|
|
1357
|
+
var mergeConfig = require('./core/mergeConfig');
|
|
1358
|
+
var defaults = require('./defaults');
|
|
1359
|
+
|
|
1360
|
+
/**
|
|
1361
|
+
* Create an instance of Axios
|
|
1362
|
+
*
|
|
1363
|
+
* @param {Object} defaultConfig The default config for the instance
|
|
1364
|
+
* @return {Axios} A new instance of Axios
|
|
1365
|
+
*/
|
|
1366
|
+
function createInstance(defaultConfig) {
|
|
1367
|
+
var context = new Axios(defaultConfig);
|
|
1368
|
+
var instance = bind(Axios.prototype.request, context);
|
|
1369
|
+
|
|
1370
|
+
// Copy axios.prototype to instance
|
|
1371
|
+
utils.extend(instance, Axios.prototype, context);
|
|
1372
|
+
|
|
1373
|
+
// Copy context to instance
|
|
1374
|
+
utils.extend(instance, context);
|
|
1375
|
+
|
|
1376
|
+
// Factory for creating new instances
|
|
1377
|
+
instance.create = function create(instanceConfig) {
|
|
1378
|
+
return createInstance(mergeConfig(defaultConfig, instanceConfig));
|
|
1379
|
+
};
|
|
1380
|
+
return instance;
|
|
1381
|
+
}
|
|
1382
|
+
|
|
1383
|
+
// Create the default instance to be exported
|
|
1384
|
+
var axios = createInstance(defaults);
|
|
1385
|
+
|
|
1386
|
+
// Expose Axios class to allow class inheritance
|
|
1387
|
+
axios.Axios = Axios;
|
|
1388
|
+
|
|
1389
|
+
// Expose Cancel & CancelToken
|
|
1390
|
+
axios.Cancel = require('./cancel/Cancel');
|
|
1391
|
+
axios.CancelToken = require('./cancel/CancelToken');
|
|
1392
|
+
axios.isCancel = require('./cancel/isCancel');
|
|
1393
|
+
axios.VERSION = require('./env/data').version;
|
|
1394
|
+
|
|
1395
|
+
// Expose all/spread
|
|
1396
|
+
axios.all = function all(promises) {
|
|
1397
|
+
return Promise.all(promises);
|
|
1398
|
+
};
|
|
1399
|
+
axios.spread = require('./helpers/spread');
|
|
1400
|
+
|
|
1401
|
+
// Expose isAxiosError
|
|
1402
|
+
axios.isAxiosError = require('./helpers/isAxiosError');
|
|
1403
|
+
module.exports = axios;
|
|
1404
|
+
|
|
1405
|
+
// Allow use of default import syntax in TypeScript
|
|
1406
|
+
module.exports.default = axios;
|
|
1407
|
+
|
|
1408
|
+
},{"./cancel/Cancel":17,"./cancel/CancelToken":18,"./cancel/isCancel":19,"./core/Axios":20,"./core/mergeConfig":26,"./defaults":29,"./env/data":31,"./helpers/bind":32,"./helpers/isAxiosError":37,"./helpers/spread":41,"./utils":43}],17:[function(require,module,exports){
|
|
1409
|
+
'use strict';
|
|
1410
|
+
|
|
1411
|
+
/**
|
|
1412
|
+
* A `Cancel` is an object that is thrown when an operation is canceled.
|
|
1413
|
+
*
|
|
1414
|
+
* @class
|
|
1415
|
+
* @param {string=} message The message.
|
|
1416
|
+
*/
|
|
1417
|
+
function Cancel(message) {
|
|
1418
|
+
this.message = message;
|
|
1419
|
+
}
|
|
1420
|
+
|
|
1421
|
+
Cancel.prototype.toString = function toString() {
|
|
1422
|
+
return 'Cancel' + (this.message ? ': ' + this.message : '');
|
|
1423
|
+
};
|
|
1424
|
+
|
|
1425
|
+
Cancel.prototype.__CANCEL__ = true;
|
|
1426
|
+
|
|
1427
|
+
module.exports = Cancel;
|
|
1428
|
+
|
|
1429
|
+
},{}],18:[function(require,module,exports){
|
|
1430
|
+
'use strict';
|
|
1431
|
+
|
|
1432
|
+
var Cancel = require('./Cancel');
|
|
1433
|
+
|
|
1434
|
+
/**
|
|
1435
|
+
* A `CancelToken` is an object that can be used to request cancellation of an operation.
|
|
1436
|
+
*
|
|
1437
|
+
* @class
|
|
1438
|
+
* @param {Function} executor The executor function.
|
|
1439
|
+
*/
|
|
1440
|
+
function CancelToken(executor) {
|
|
1441
|
+
if (typeof executor !== 'function') {
|
|
1442
|
+
throw new TypeError('executor must be a function.');
|
|
1443
|
+
}
|
|
1444
|
+
|
|
1445
|
+
var resolvePromise;
|
|
1446
|
+
|
|
1447
|
+
this.promise = new Promise(function promiseExecutor(resolve) {
|
|
1448
|
+
resolvePromise = resolve;
|
|
1449
|
+
});
|
|
1450
|
+
|
|
1451
|
+
var token = this;
|
|
1452
|
+
|
|
1453
|
+
// eslint-disable-next-line func-names
|
|
1454
|
+
this.promise.then(function(cancel) {
|
|
1455
|
+
if (!token._listeners) return;
|
|
1456
|
+
|
|
1457
|
+
var i;
|
|
1458
|
+
var l = token._listeners.length;
|
|
1459
|
+
|
|
1460
|
+
for (i = 0; i < l; i++) {
|
|
1461
|
+
token._listeners[i](cancel);
|
|
1462
|
+
}
|
|
1463
|
+
token._listeners = null;
|
|
1464
|
+
});
|
|
1465
|
+
|
|
1466
|
+
// eslint-disable-next-line func-names
|
|
1467
|
+
this.promise.then = function(onfulfilled) {
|
|
1468
|
+
var _resolve;
|
|
1469
|
+
// eslint-disable-next-line func-names
|
|
1470
|
+
var promise = new Promise(function(resolve) {
|
|
1471
|
+
token.subscribe(resolve);
|
|
1472
|
+
_resolve = resolve;
|
|
1473
|
+
}).then(onfulfilled);
|
|
1474
|
+
|
|
1475
|
+
promise.cancel = function reject() {
|
|
1476
|
+
token.unsubscribe(_resolve);
|
|
1477
|
+
};
|
|
1478
|
+
|
|
1479
|
+
return promise;
|
|
1480
|
+
};
|
|
1481
|
+
|
|
1482
|
+
executor(function cancel(message) {
|
|
1483
|
+
if (token.reason) {
|
|
1484
|
+
// Cancellation has already been requested
|
|
1485
|
+
return;
|
|
1486
|
+
}
|
|
1487
|
+
|
|
1488
|
+
token.reason = new Cancel(message);
|
|
1489
|
+
resolvePromise(token.reason);
|
|
1490
|
+
});
|
|
1491
|
+
}
|
|
1492
|
+
|
|
1493
|
+
/**
|
|
1494
|
+
* Throws a `Cancel` if cancellation has been requested.
|
|
1495
|
+
*/
|
|
1496
|
+
CancelToken.prototype.throwIfRequested = function throwIfRequested() {
|
|
1497
|
+
if (this.reason) {
|
|
1498
|
+
throw this.reason;
|
|
1499
|
+
}
|
|
1500
|
+
};
|
|
1501
|
+
|
|
1502
|
+
/**
|
|
1503
|
+
* Subscribe to the cancel signal
|
|
1504
|
+
*/
|
|
1505
|
+
|
|
1506
|
+
CancelToken.prototype.subscribe = function subscribe(listener) {
|
|
1507
|
+
if (this.reason) {
|
|
1508
|
+
listener(this.reason);
|
|
1509
|
+
return;
|
|
1510
|
+
}
|
|
1511
|
+
|
|
1512
|
+
if (this._listeners) {
|
|
1513
|
+
this._listeners.push(listener);
|
|
1514
|
+
} else {
|
|
1515
|
+
this._listeners = [listener];
|
|
1516
|
+
}
|
|
1517
|
+
};
|
|
1518
|
+
|
|
1519
|
+
/**
|
|
1520
|
+
* Unsubscribe from the cancel signal
|
|
1521
|
+
*/
|
|
1522
|
+
|
|
1523
|
+
CancelToken.prototype.unsubscribe = function unsubscribe(listener) {
|
|
1524
|
+
if (!this._listeners) {
|
|
1525
|
+
return;
|
|
1526
|
+
}
|
|
1527
|
+
var index = this._listeners.indexOf(listener);
|
|
1528
|
+
if (index !== -1) {
|
|
1529
|
+
this._listeners.splice(index, 1);
|
|
1530
|
+
}
|
|
1531
|
+
};
|
|
1532
|
+
|
|
1533
|
+
/**
|
|
1534
|
+
* Returns an object that contains a new `CancelToken` and a function that, when called,
|
|
1535
|
+
* cancels the `CancelToken`.
|
|
1536
|
+
*/
|
|
1537
|
+
CancelToken.source = function source() {
|
|
1538
|
+
var cancel;
|
|
1539
|
+
var token = new CancelToken(function executor(c) {
|
|
1540
|
+
cancel = c;
|
|
1541
|
+
});
|
|
1542
|
+
return {
|
|
1543
|
+
token: token,
|
|
1544
|
+
cancel: cancel
|
|
1545
|
+
};
|
|
1546
|
+
};
|
|
1547
|
+
|
|
1548
|
+
module.exports = CancelToken;
|
|
1549
|
+
|
|
1550
|
+
},{"./Cancel":17}],19:[function(require,module,exports){
|
|
1551
|
+
'use strict';
|
|
1552
|
+
|
|
1553
|
+
module.exports = function isCancel(value) {
|
|
1554
|
+
return !!(value && value.__CANCEL__);
|
|
1555
|
+
};
|
|
1556
|
+
|
|
1557
|
+
},{}],20:[function(require,module,exports){
|
|
1558
|
+
'use strict';
|
|
1559
|
+
|
|
1560
|
+
var utils = require('./../utils');
|
|
1561
|
+
var buildURL = require('../helpers/buildURL');
|
|
1562
|
+
var InterceptorManager = require('./InterceptorManager');
|
|
1563
|
+
var dispatchRequest = require('./dispatchRequest');
|
|
1564
|
+
var mergeConfig = require('./mergeConfig');
|
|
1565
|
+
var validator = require('../helpers/validator');
|
|
1566
|
+
|
|
1567
|
+
var validators = validator.validators;
|
|
1568
|
+
/**
|
|
1569
|
+
* Create a new instance of Axios
|
|
1570
|
+
*
|
|
1571
|
+
* @param {Object} instanceConfig The default config for the instance
|
|
1572
|
+
*/
|
|
1573
|
+
function Axios(instanceConfig) {
|
|
1574
|
+
this.defaults = instanceConfig;
|
|
1575
|
+
this.interceptors = {
|
|
1576
|
+
request: new InterceptorManager(),
|
|
1577
|
+
response: new InterceptorManager()
|
|
1578
|
+
};
|
|
1579
|
+
}
|
|
1580
|
+
|
|
1581
|
+
/**
|
|
1582
|
+
* Dispatch a request
|
|
1583
|
+
*
|
|
1584
|
+
* @param {Object} config The config specific for this request (merged with this.defaults)
|
|
1585
|
+
*/
|
|
1586
|
+
Axios.prototype.request = function request(configOrUrl, config) {
|
|
1587
|
+
/*eslint no-param-reassign:0*/
|
|
1588
|
+
// Allow for axios('example/url'[, config]) a la fetch API
|
|
1589
|
+
if (typeof configOrUrl === 'string') {
|
|
1590
|
+
config = config || {};
|
|
1591
|
+
config.url = configOrUrl;
|
|
1592
|
+
} else {
|
|
1593
|
+
config = configOrUrl || {};
|
|
1594
|
+
}
|
|
1595
|
+
|
|
1596
|
+
config = mergeConfig(this.defaults, config);
|
|
1597
|
+
|
|
1598
|
+
// Set config.method
|
|
1599
|
+
if (config.method) {
|
|
1600
|
+
config.method = config.method.toLowerCase();
|
|
1601
|
+
} else if (this.defaults.method) {
|
|
1602
|
+
config.method = this.defaults.method.toLowerCase();
|
|
1603
|
+
} else {
|
|
1604
|
+
config.method = 'get';
|
|
1605
|
+
}
|
|
1606
|
+
|
|
1607
|
+
var transitional = config.transitional;
|
|
1608
|
+
|
|
1609
|
+
if (transitional !== undefined) {
|
|
1610
|
+
validator.assertOptions(transitional, {
|
|
1611
|
+
silentJSONParsing: validators.transitional(validators.boolean),
|
|
1612
|
+
forcedJSONParsing: validators.transitional(validators.boolean),
|
|
1613
|
+
clarifyTimeoutError: validators.transitional(validators.boolean)
|
|
1614
|
+
}, false);
|
|
1615
|
+
}
|
|
1616
|
+
|
|
1617
|
+
// filter out skipped interceptors
|
|
1618
|
+
var requestInterceptorChain = [];
|
|
1619
|
+
var synchronousRequestInterceptors = true;
|
|
1620
|
+
this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
|
|
1621
|
+
if (typeof interceptor.runWhen === 'function' && interceptor.runWhen(config) === false) {
|
|
1622
|
+
return;
|
|
1623
|
+
}
|
|
1624
|
+
|
|
1625
|
+
synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous;
|
|
1626
|
+
|
|
1627
|
+
requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected);
|
|
1628
|
+
});
|
|
1629
|
+
|
|
1630
|
+
var responseInterceptorChain = [];
|
|
1631
|
+
this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
|
|
1632
|
+
responseInterceptorChain.push(interceptor.fulfilled, interceptor.rejected);
|
|
1633
|
+
});
|
|
1634
|
+
|
|
1635
|
+
var promise;
|
|
1636
|
+
|
|
1637
|
+
if (!synchronousRequestInterceptors) {
|
|
1638
|
+
var chain = [dispatchRequest, undefined];
|
|
1639
|
+
|
|
1640
|
+
Array.prototype.unshift.apply(chain, requestInterceptorChain);
|
|
1641
|
+
chain = chain.concat(responseInterceptorChain);
|
|
1642
|
+
|
|
1643
|
+
promise = Promise.resolve(config);
|
|
1644
|
+
while (chain.length) {
|
|
1645
|
+
promise = promise.then(chain.shift(), chain.shift());
|
|
1646
|
+
}
|
|
1647
|
+
|
|
1648
|
+
return promise;
|
|
1649
|
+
}
|
|
1650
|
+
|
|
1651
|
+
|
|
1652
|
+
var newConfig = config;
|
|
1653
|
+
while (requestInterceptorChain.length) {
|
|
1654
|
+
var onFulfilled = requestInterceptorChain.shift();
|
|
1655
|
+
var onRejected = requestInterceptorChain.shift();
|
|
1656
|
+
try {
|
|
1657
|
+
newConfig = onFulfilled(newConfig);
|
|
1658
|
+
} catch (error) {
|
|
1659
|
+
onRejected(error);
|
|
1660
|
+
break;
|
|
1661
|
+
}
|
|
1662
|
+
}
|
|
1663
|
+
|
|
1664
|
+
try {
|
|
1665
|
+
promise = dispatchRequest(newConfig);
|
|
1666
|
+
} catch (error) {
|
|
1667
|
+
return Promise.reject(error);
|
|
1668
|
+
}
|
|
1669
|
+
|
|
1670
|
+
while (responseInterceptorChain.length) {
|
|
1671
|
+
promise = promise.then(responseInterceptorChain.shift(), responseInterceptorChain.shift());
|
|
1672
|
+
}
|
|
1673
|
+
|
|
1674
|
+
return promise;
|
|
1675
|
+
};
|
|
1676
|
+
|
|
1677
|
+
Axios.prototype.getUri = function getUri(config) {
|
|
1678
|
+
config = mergeConfig(this.defaults, config);
|
|
1679
|
+
return buildURL(config.url, config.params, config.paramsSerializer).replace(/^\?/, '');
|
|
1680
|
+
};
|
|
1681
|
+
|
|
1682
|
+
// Provide aliases for supported request methods
|
|
1683
|
+
utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
|
|
1684
|
+
/*eslint func-names:0*/
|
|
1685
|
+
Axios.prototype[method] = function(url, config) {
|
|
1686
|
+
return this.request(mergeConfig(config || {}, {
|
|
1687
|
+
method: method,
|
|
1688
|
+
url: url,
|
|
1689
|
+
data: (config || {}).data
|
|
1690
|
+
}));
|
|
1691
|
+
};
|
|
1692
|
+
});
|
|
1693
|
+
|
|
1694
|
+
utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
|
|
1695
|
+
/*eslint func-names:0*/
|
|
1696
|
+
Axios.prototype[method] = function(url, data, config) {
|
|
1697
|
+
return this.request(mergeConfig(config || {}, {
|
|
1698
|
+
method: method,
|
|
1699
|
+
url: url,
|
|
1700
|
+
data: data
|
|
1701
|
+
}));
|
|
1702
|
+
};
|
|
1703
|
+
});
|
|
1704
|
+
|
|
1705
|
+
module.exports = Axios;
|
|
1706
|
+
|
|
1707
|
+
},{"../helpers/buildURL":33,"../helpers/validator":42,"./../utils":43,"./InterceptorManager":21,"./dispatchRequest":24,"./mergeConfig":26}],21:[function(require,module,exports){
|
|
1708
|
+
'use strict';
|
|
1709
|
+
|
|
1710
|
+
var utils = require('./../utils');
|
|
1711
|
+
|
|
1712
|
+
function InterceptorManager() {
|
|
1713
|
+
this.handlers = [];
|
|
1714
|
+
}
|
|
1715
|
+
|
|
1716
|
+
/**
|
|
1717
|
+
* Add a new interceptor to the stack
|
|
1718
|
+
*
|
|
1719
|
+
* @param {Function} fulfilled The function to handle `then` for a `Promise`
|
|
1720
|
+
* @param {Function} rejected The function to handle `reject` for a `Promise`
|
|
1721
|
+
*
|
|
1722
|
+
* @return {Number} An ID used to remove interceptor later
|
|
1723
|
+
*/
|
|
1724
|
+
InterceptorManager.prototype.use = function use(fulfilled, rejected, options) {
|
|
1725
|
+
this.handlers.push({
|
|
1726
|
+
fulfilled: fulfilled,
|
|
1727
|
+
rejected: rejected,
|
|
1728
|
+
synchronous: options ? options.synchronous : false,
|
|
1729
|
+
runWhen: options ? options.runWhen : null
|
|
1730
|
+
});
|
|
1731
|
+
return this.handlers.length - 1;
|
|
1732
|
+
};
|
|
1733
|
+
|
|
1734
|
+
/**
|
|
1735
|
+
* Remove an interceptor from the stack
|
|
1736
|
+
*
|
|
1737
|
+
* @param {Number} id The ID that was returned by `use`
|
|
1738
|
+
*/
|
|
1739
|
+
InterceptorManager.prototype.eject = function eject(id) {
|
|
1740
|
+
if (this.handlers[id]) {
|
|
1741
|
+
this.handlers[id] = null;
|
|
1742
|
+
}
|
|
1743
|
+
};
|
|
1744
|
+
|
|
1745
|
+
/**
|
|
1746
|
+
* Iterate over all the registered interceptors
|
|
1747
|
+
*
|
|
1748
|
+
* This method is particularly useful for skipping over any
|
|
1749
|
+
* interceptors that may have become `null` calling `eject`.
|
|
1750
|
+
*
|
|
1751
|
+
* @param {Function} fn The function to call for each interceptor
|
|
1752
|
+
*/
|
|
1753
|
+
InterceptorManager.prototype.forEach = function forEach(fn) {
|
|
1754
|
+
utils.forEach(this.handlers, function forEachHandler(h) {
|
|
1755
|
+
if (h !== null) {
|
|
1756
|
+
fn(h);
|
|
1757
|
+
}
|
|
1758
|
+
});
|
|
1759
|
+
};
|
|
1760
|
+
|
|
1761
|
+
module.exports = InterceptorManager;
|
|
1762
|
+
|
|
1763
|
+
},{"./../utils":43}],22:[function(require,module,exports){
|
|
1764
|
+
'use strict';
|
|
1765
|
+
|
|
1766
|
+
var isAbsoluteURL = require('../helpers/isAbsoluteURL');
|
|
1767
|
+
var combineURLs = require('../helpers/combineURLs');
|
|
1768
|
+
|
|
1769
|
+
/**
|
|
1770
|
+
* Creates a new URL by combining the baseURL with the requestedURL,
|
|
1771
|
+
* only when the requestedURL is not already an absolute URL.
|
|
1772
|
+
* If the requestURL is absolute, this function returns the requestedURL untouched.
|
|
1773
|
+
*
|
|
1774
|
+
* @param {string} baseURL The base URL
|
|
1775
|
+
* @param {string} requestedURL Absolute or relative URL to combine
|
|
1776
|
+
* @returns {string} The combined full path
|
|
1777
|
+
*/
|
|
1778
|
+
module.exports = function buildFullPath(baseURL, requestedURL) {
|
|
1779
|
+
if (baseURL && !isAbsoluteURL(requestedURL)) {
|
|
1780
|
+
return combineURLs(baseURL, requestedURL);
|
|
1781
|
+
}
|
|
1782
|
+
return requestedURL;
|
|
1783
|
+
};
|
|
1784
|
+
|
|
1785
|
+
},{"../helpers/combineURLs":34,"../helpers/isAbsoluteURL":36}],23:[function(require,module,exports){
|
|
1786
|
+
'use strict';
|
|
1787
|
+
|
|
1788
|
+
var enhanceError = require('./enhanceError');
|
|
1789
|
+
|
|
1790
|
+
/**
|
|
1791
|
+
* Create an Error with the specified message, config, error code, request and response.
|
|
1792
|
+
*
|
|
1793
|
+
* @param {string} message The error message.
|
|
1794
|
+
* @param {Object} config The config.
|
|
1795
|
+
* @param {string} [code] The error code (for example, 'ECONNABORTED').
|
|
1796
|
+
* @param {Object} [request] The request.
|
|
1797
|
+
* @param {Object} [response] The response.
|
|
1798
|
+
* @returns {Error} The created error.
|
|
1799
|
+
*/
|
|
1800
|
+
module.exports = function createError(message, config, code, request, response) {
|
|
1801
|
+
var error = new Error(message);
|
|
1802
|
+
return enhanceError(error, config, code, request, response);
|
|
1803
|
+
};
|
|
1804
|
+
|
|
1805
|
+
},{"./enhanceError":25}],24:[function(require,module,exports){
|
|
1806
|
+
'use strict';
|
|
1807
|
+
|
|
1808
|
+
var utils = require('./../utils');
|
|
1809
|
+
var transformData = require('./transformData');
|
|
1810
|
+
var isCancel = require('../cancel/isCancel');
|
|
1811
|
+
var defaults = require('../defaults');
|
|
1812
|
+
var Cancel = require('../cancel/Cancel');
|
|
1813
|
+
|
|
1814
|
+
/**
|
|
1815
|
+
* Throws a `Cancel` if cancellation has been requested.
|
|
1816
|
+
*/
|
|
1817
|
+
function throwIfCancellationRequested(config) {
|
|
1818
|
+
if (config.cancelToken) {
|
|
1819
|
+
config.cancelToken.throwIfRequested();
|
|
1820
|
+
}
|
|
1821
|
+
|
|
1822
|
+
if (config.signal && config.signal.aborted) {
|
|
1823
|
+
throw new Cancel('canceled');
|
|
1824
|
+
}
|
|
1825
|
+
}
|
|
1826
|
+
|
|
1827
|
+
/**
|
|
1828
|
+
* Dispatch a request to the server using the configured adapter.
|
|
1829
|
+
*
|
|
1830
|
+
* @param {object} config The config that is to be used for the request
|
|
1831
|
+
* @returns {Promise} The Promise to be fulfilled
|
|
1832
|
+
*/
|
|
1833
|
+
module.exports = function dispatchRequest(config) {
|
|
1834
|
+
throwIfCancellationRequested(config);
|
|
1835
|
+
|
|
1836
|
+
// Ensure headers exist
|
|
1837
|
+
config.headers = config.headers || {};
|
|
1838
|
+
|
|
1839
|
+
// Transform request data
|
|
1840
|
+
config.data = transformData.call(
|
|
1841
|
+
config,
|
|
1842
|
+
config.data,
|
|
1843
|
+
config.headers,
|
|
1844
|
+
config.transformRequest
|
|
1845
|
+
);
|
|
1846
|
+
|
|
1847
|
+
// Flatten headers
|
|
1848
|
+
config.headers = utils.merge(
|
|
1849
|
+
config.headers.common || {},
|
|
1850
|
+
config.headers[config.method] || {},
|
|
1851
|
+
config.headers
|
|
1852
|
+
);
|
|
1853
|
+
|
|
1854
|
+
utils.forEach(
|
|
1855
|
+
['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
|
|
1856
|
+
function cleanHeaderConfig(method) {
|
|
1857
|
+
delete config.headers[method];
|
|
1858
|
+
}
|
|
1859
|
+
);
|
|
1860
|
+
|
|
1861
|
+
var adapter = config.adapter || defaults.adapter;
|
|
1862
|
+
|
|
1863
|
+
return adapter(config).then(function onAdapterResolution(response) {
|
|
1864
|
+
throwIfCancellationRequested(config);
|
|
1865
|
+
|
|
1866
|
+
// Transform response data
|
|
1867
|
+
response.data = transformData.call(
|
|
1868
|
+
config,
|
|
1869
|
+
response.data,
|
|
1870
|
+
response.headers,
|
|
1871
|
+
config.transformResponse
|
|
1872
|
+
);
|
|
1873
|
+
|
|
1874
|
+
return response;
|
|
1875
|
+
}, function onAdapterRejection(reason) {
|
|
1876
|
+
if (!isCancel(reason)) {
|
|
1877
|
+
throwIfCancellationRequested(config);
|
|
1878
|
+
|
|
1879
|
+
// Transform response data
|
|
1880
|
+
if (reason && reason.response) {
|
|
1881
|
+
reason.response.data = transformData.call(
|
|
1882
|
+
config,
|
|
1883
|
+
reason.response.data,
|
|
1884
|
+
reason.response.headers,
|
|
1885
|
+
config.transformResponse
|
|
1886
|
+
);
|
|
1887
|
+
}
|
|
1888
|
+
}
|
|
1889
|
+
|
|
1890
|
+
return Promise.reject(reason);
|
|
1891
|
+
});
|
|
1892
|
+
};
|
|
1893
|
+
|
|
1894
|
+
},{"../cancel/Cancel":17,"../cancel/isCancel":19,"../defaults":29,"./../utils":43,"./transformData":28}],25:[function(require,module,exports){
|
|
1895
|
+
'use strict';
|
|
1896
|
+
|
|
1897
|
+
/**
|
|
1898
|
+
* Update an Error with the specified config, error code, and response.
|
|
1899
|
+
*
|
|
1900
|
+
* @param {Error} error The error to update.
|
|
1901
|
+
* @param {Object} config The config.
|
|
1902
|
+
* @param {string} [code] The error code (for example, 'ECONNABORTED').
|
|
1903
|
+
* @param {Object} [request] The request.
|
|
1904
|
+
* @param {Object} [response] The response.
|
|
1905
|
+
* @returns {Error} The error.
|
|
1906
|
+
*/
|
|
1907
|
+
module.exports = function enhanceError(error, config, code, request, response) {
|
|
1908
|
+
error.config = config;
|
|
1909
|
+
if (code) {
|
|
1910
|
+
error.code = code;
|
|
1911
|
+
}
|
|
1912
|
+
|
|
1913
|
+
error.request = request;
|
|
1914
|
+
error.response = response;
|
|
1915
|
+
error.isAxiosError = true;
|
|
1916
|
+
|
|
1917
|
+
error.toJSON = function toJSON() {
|
|
1918
|
+
return {
|
|
1919
|
+
// Standard
|
|
1920
|
+
message: this.message,
|
|
1921
|
+
name: this.name,
|
|
1922
|
+
// Microsoft
|
|
1923
|
+
description: this.description,
|
|
1924
|
+
number: this.number,
|
|
1925
|
+
// Mozilla
|
|
1926
|
+
fileName: this.fileName,
|
|
1927
|
+
lineNumber: this.lineNumber,
|
|
1928
|
+
columnNumber: this.columnNumber,
|
|
1929
|
+
stack: this.stack,
|
|
1930
|
+
// Axios
|
|
1931
|
+
config: this.config,
|
|
1932
|
+
code: this.code,
|
|
1933
|
+
status: this.response && this.response.status ? this.response.status : null
|
|
1934
|
+
};
|
|
1935
|
+
};
|
|
1936
|
+
return error;
|
|
1937
|
+
};
|
|
1938
|
+
|
|
1939
|
+
},{}],26:[function(require,module,exports){
|
|
1940
|
+
'use strict';
|
|
1941
|
+
|
|
1942
|
+
var utils = require('../utils');
|
|
1943
|
+
|
|
1944
|
+
/**
|
|
1945
|
+
* Config-specific merge-function which creates a new config-object
|
|
1946
|
+
* by merging two configuration objects together.
|
|
1947
|
+
*
|
|
1948
|
+
* @param {Object} config1
|
|
1949
|
+
* @param {Object} config2
|
|
1950
|
+
* @returns {Object} New object resulting from merging config2 to config1
|
|
1951
|
+
*/
|
|
1952
|
+
module.exports = function mergeConfig(config1, config2) {
|
|
1953
|
+
// eslint-disable-next-line no-param-reassign
|
|
1954
|
+
config2 = config2 || {};
|
|
1955
|
+
var config = {};
|
|
1956
|
+
|
|
1957
|
+
function getMergedValue(target, source) {
|
|
1958
|
+
if (utils.isPlainObject(target) && utils.isPlainObject(source)) {
|
|
1959
|
+
return utils.merge(target, source);
|
|
1960
|
+
} else if (utils.isPlainObject(source)) {
|
|
1961
|
+
return utils.merge({}, source);
|
|
1962
|
+
} else if (utils.isArray(source)) {
|
|
1963
|
+
return source.slice();
|
|
1964
|
+
}
|
|
1965
|
+
return source;
|
|
1966
|
+
}
|
|
1967
|
+
|
|
1968
|
+
// eslint-disable-next-line consistent-return
|
|
1969
|
+
function mergeDeepProperties(prop) {
|
|
1970
|
+
if (!utils.isUndefined(config2[prop])) {
|
|
1971
|
+
return getMergedValue(config1[prop], config2[prop]);
|
|
1972
|
+
} else if (!utils.isUndefined(config1[prop])) {
|
|
1973
|
+
return getMergedValue(undefined, config1[prop]);
|
|
1974
|
+
}
|
|
1975
|
+
}
|
|
1976
|
+
|
|
1977
|
+
// eslint-disable-next-line consistent-return
|
|
1978
|
+
function valueFromConfig2(prop) {
|
|
1979
|
+
if (!utils.isUndefined(config2[prop])) {
|
|
1980
|
+
return getMergedValue(undefined, config2[prop]);
|
|
1981
|
+
}
|
|
1982
|
+
}
|
|
1983
|
+
|
|
1984
|
+
// eslint-disable-next-line consistent-return
|
|
1985
|
+
function defaultToConfig2(prop) {
|
|
1986
|
+
if (!utils.isUndefined(config2[prop])) {
|
|
1987
|
+
return getMergedValue(undefined, config2[prop]);
|
|
1988
|
+
} else if (!utils.isUndefined(config1[prop])) {
|
|
1989
|
+
return getMergedValue(undefined, config1[prop]);
|
|
1990
|
+
}
|
|
1991
|
+
}
|
|
1992
|
+
|
|
1993
|
+
// eslint-disable-next-line consistent-return
|
|
1994
|
+
function mergeDirectKeys(prop) {
|
|
1995
|
+
if (prop in config2) {
|
|
1996
|
+
return getMergedValue(config1[prop], config2[prop]);
|
|
1997
|
+
} else if (prop in config1) {
|
|
1998
|
+
return getMergedValue(undefined, config1[prop]);
|
|
1999
|
+
}
|
|
2000
|
+
}
|
|
2001
|
+
|
|
2002
|
+
var mergeMap = {
|
|
2003
|
+
'url': valueFromConfig2,
|
|
2004
|
+
'method': valueFromConfig2,
|
|
2005
|
+
'data': valueFromConfig2,
|
|
2006
|
+
'baseURL': defaultToConfig2,
|
|
2007
|
+
'transformRequest': defaultToConfig2,
|
|
2008
|
+
'transformResponse': defaultToConfig2,
|
|
2009
|
+
'paramsSerializer': defaultToConfig2,
|
|
2010
|
+
'timeout': defaultToConfig2,
|
|
2011
|
+
'timeoutMessage': defaultToConfig2,
|
|
2012
|
+
'withCredentials': defaultToConfig2,
|
|
2013
|
+
'adapter': defaultToConfig2,
|
|
2014
|
+
'responseType': defaultToConfig2,
|
|
2015
|
+
'xsrfCookieName': defaultToConfig2,
|
|
2016
|
+
'xsrfHeaderName': defaultToConfig2,
|
|
2017
|
+
'onUploadProgress': defaultToConfig2,
|
|
2018
|
+
'onDownloadProgress': defaultToConfig2,
|
|
2019
|
+
'decompress': defaultToConfig2,
|
|
2020
|
+
'maxContentLength': defaultToConfig2,
|
|
2021
|
+
'maxBodyLength': defaultToConfig2,
|
|
2022
|
+
'transport': defaultToConfig2,
|
|
2023
|
+
'httpAgent': defaultToConfig2,
|
|
2024
|
+
'httpsAgent': defaultToConfig2,
|
|
2025
|
+
'cancelToken': defaultToConfig2,
|
|
2026
|
+
'socketPath': defaultToConfig2,
|
|
2027
|
+
'responseEncoding': defaultToConfig2,
|
|
2028
|
+
'validateStatus': mergeDirectKeys
|
|
2029
|
+
};
|
|
2030
|
+
|
|
2031
|
+
utils.forEach(Object.keys(config1).concat(Object.keys(config2)), function computeConfigValue(prop) {
|
|
2032
|
+
var merge = mergeMap[prop] || mergeDeepProperties;
|
|
2033
|
+
var configValue = merge(prop);
|
|
2034
|
+
(utils.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
|
|
2035
|
+
});
|
|
2036
|
+
|
|
2037
|
+
return config;
|
|
2038
|
+
};
|
|
2039
|
+
|
|
2040
|
+
},{"../utils":43}],27:[function(require,module,exports){
|
|
2041
|
+
'use strict';
|
|
2042
|
+
|
|
2043
|
+
var createError = require('./createError');
|
|
2044
|
+
|
|
2045
|
+
/**
|
|
2046
|
+
* Resolve or reject a Promise based on response status.
|
|
2047
|
+
*
|
|
2048
|
+
* @param {Function} resolve A function that resolves the promise.
|
|
2049
|
+
* @param {Function} reject A function that rejects the promise.
|
|
2050
|
+
* @param {object} response The response.
|
|
2051
|
+
*/
|
|
2052
|
+
module.exports = function settle(resolve, reject, response) {
|
|
2053
|
+
var validateStatus = response.config.validateStatus;
|
|
2054
|
+
if (!response.status || !validateStatus || validateStatus(response.status)) {
|
|
2055
|
+
resolve(response);
|
|
2056
|
+
} else {
|
|
2057
|
+
reject(createError(
|
|
2058
|
+
'Request failed with status code ' + response.status,
|
|
2059
|
+
response.config,
|
|
2060
|
+
null,
|
|
2061
|
+
response.request,
|
|
2062
|
+
response
|
|
2063
|
+
));
|
|
2064
|
+
}
|
|
2065
|
+
};
|
|
2066
|
+
|
|
2067
|
+
},{"./createError":23}],28:[function(require,module,exports){
|
|
2068
|
+
'use strict';
|
|
2069
|
+
|
|
2070
|
+
var utils = require('./../utils');
|
|
2071
|
+
var defaults = require('../defaults');
|
|
2072
|
+
|
|
2073
|
+
/**
|
|
2074
|
+
* Transform the data for a request or a response
|
|
2075
|
+
*
|
|
2076
|
+
* @param {Object|String} data The data to be transformed
|
|
2077
|
+
* @param {Array} headers The headers for the request or response
|
|
2078
|
+
* @param {Array|Function} fns A single function or Array of functions
|
|
2079
|
+
* @returns {*} The resulting transformed data
|
|
2080
|
+
*/
|
|
2081
|
+
module.exports = function transformData(data, headers, fns) {
|
|
2082
|
+
var context = this || defaults;
|
|
2083
|
+
/*eslint no-param-reassign:0*/
|
|
2084
|
+
utils.forEach(fns, function transform(fn) {
|
|
2085
|
+
data = fn.call(context, data, headers);
|
|
2086
|
+
});
|
|
2087
|
+
|
|
2088
|
+
return data;
|
|
2089
|
+
};
|
|
2090
|
+
|
|
2091
|
+
},{"../defaults":29,"./../utils":43}],29:[function(require,module,exports){
|
|
2092
|
+
(function (process){(function (){
|
|
2093
|
+
'use strict';
|
|
2094
|
+
|
|
2095
|
+
var utils = require('../utils');
|
|
2096
|
+
var normalizeHeaderName = require('../helpers/normalizeHeaderName');
|
|
2097
|
+
var enhanceError = require('../core/enhanceError');
|
|
2098
|
+
var transitionalDefaults = require('./transitional');
|
|
2099
|
+
|
|
2100
|
+
var DEFAULT_CONTENT_TYPE = {
|
|
2101
|
+
'Content-Type': 'application/x-www-form-urlencoded'
|
|
2102
|
+
};
|
|
2103
|
+
|
|
2104
|
+
function setContentTypeIfUnset(headers, value) {
|
|
2105
|
+
if (!utils.isUndefined(headers) && utils.isUndefined(headers['Content-Type'])) {
|
|
2106
|
+
headers['Content-Type'] = value;
|
|
2107
|
+
}
|
|
2108
|
+
}
|
|
2109
|
+
|
|
2110
|
+
function getDefaultAdapter() {
|
|
2111
|
+
var adapter;
|
|
2112
|
+
if (typeof XMLHttpRequest !== 'undefined') {
|
|
2113
|
+
// For browsers use XHR adapter
|
|
2114
|
+
adapter = require('../adapters/xhr');
|
|
2115
|
+
} else if (typeof process !== 'undefined' && Object.prototype.toString.call(process) === '[object process]') {
|
|
2116
|
+
// For node use HTTP adapter
|
|
2117
|
+
adapter = require('../adapters/http');
|
|
2118
|
+
}
|
|
2119
|
+
return adapter;
|
|
2120
|
+
}
|
|
2121
|
+
|
|
2122
|
+
function stringifySafely(rawValue, parser, encoder) {
|
|
2123
|
+
if (utils.isString(rawValue)) {
|
|
2124
|
+
try {
|
|
2125
|
+
(parser || JSON.parse)(rawValue);
|
|
2126
|
+
return utils.trim(rawValue);
|
|
2127
|
+
} catch (e) {
|
|
2128
|
+
if (e.name !== 'SyntaxError') {
|
|
2129
|
+
throw e;
|
|
2130
|
+
}
|
|
2131
|
+
}
|
|
2132
|
+
}
|
|
2133
|
+
|
|
2134
|
+
return (encoder || JSON.stringify)(rawValue);
|
|
2135
|
+
}
|
|
2136
|
+
|
|
2137
|
+
var defaults = {
|
|
2138
|
+
|
|
2139
|
+
transitional: transitionalDefaults,
|
|
2140
|
+
|
|
2141
|
+
adapter: getDefaultAdapter(),
|
|
2142
|
+
|
|
2143
|
+
transformRequest: [function transformRequest(data, headers) {
|
|
2144
|
+
normalizeHeaderName(headers, 'Accept');
|
|
2145
|
+
normalizeHeaderName(headers, 'Content-Type');
|
|
2146
|
+
|
|
2147
|
+
if (utils.isFormData(data) ||
|
|
2148
|
+
utils.isArrayBuffer(data) ||
|
|
2149
|
+
utils.isBuffer(data) ||
|
|
2150
|
+
utils.isStream(data) ||
|
|
2151
|
+
utils.isFile(data) ||
|
|
2152
|
+
utils.isBlob(data)
|
|
2153
|
+
) {
|
|
2154
|
+
return data;
|
|
2155
|
+
}
|
|
2156
|
+
if (utils.isArrayBufferView(data)) {
|
|
2157
|
+
return data.buffer;
|
|
2158
|
+
}
|
|
2159
|
+
if (utils.isURLSearchParams(data)) {
|
|
2160
|
+
setContentTypeIfUnset(headers, 'application/x-www-form-urlencoded;charset=utf-8');
|
|
2161
|
+
return data.toString();
|
|
2162
|
+
}
|
|
2163
|
+
if (utils.isObject(data) || (headers && headers['Content-Type'] === 'application/json')) {
|
|
2164
|
+
setContentTypeIfUnset(headers, 'application/json');
|
|
2165
|
+
return stringifySafely(data);
|
|
2166
|
+
}
|
|
2167
|
+
return data;
|
|
2168
|
+
}],
|
|
2169
|
+
|
|
2170
|
+
transformResponse: [function transformResponse(data) {
|
|
2171
|
+
var transitional = this.transitional || defaults.transitional;
|
|
2172
|
+
var silentJSONParsing = transitional && transitional.silentJSONParsing;
|
|
2173
|
+
var forcedJSONParsing = transitional && transitional.forcedJSONParsing;
|
|
2174
|
+
var strictJSONParsing = !silentJSONParsing && this.responseType === 'json';
|
|
2175
|
+
|
|
2176
|
+
if (strictJSONParsing || (forcedJSONParsing && utils.isString(data) && data.length)) {
|
|
2177
|
+
try {
|
|
2178
|
+
return JSON.parse(data);
|
|
2179
|
+
} catch (e) {
|
|
2180
|
+
if (strictJSONParsing) {
|
|
2181
|
+
if (e.name === 'SyntaxError') {
|
|
2182
|
+
throw enhanceError(e, this, 'E_JSON_PARSE');
|
|
2183
|
+
}
|
|
2184
|
+
throw e;
|
|
2185
|
+
}
|
|
2186
|
+
}
|
|
2187
|
+
}
|
|
2188
|
+
|
|
2189
|
+
return data;
|
|
2190
|
+
}],
|
|
2191
|
+
|
|
2192
|
+
/**
|
|
2193
|
+
* A timeout in milliseconds to abort a request. If set to 0 (default) a
|
|
2194
|
+
* timeout is not created.
|
|
2195
|
+
*/
|
|
2196
|
+
timeout: 0,
|
|
2197
|
+
|
|
2198
|
+
xsrfCookieName: 'XSRF-TOKEN',
|
|
2199
|
+
xsrfHeaderName: 'X-XSRF-TOKEN',
|
|
2200
|
+
|
|
2201
|
+
maxContentLength: -1,
|
|
2202
|
+
maxBodyLength: -1,
|
|
2203
|
+
|
|
2204
|
+
validateStatus: function validateStatus(status) {
|
|
2205
|
+
return status >= 200 && status < 300;
|
|
2206
|
+
},
|
|
2207
|
+
|
|
2208
|
+
headers: {
|
|
2209
|
+
common: {
|
|
2210
|
+
'Accept': 'application/json, text/plain, */*'
|
|
2211
|
+
}
|
|
2212
|
+
}
|
|
2213
|
+
};
|
|
2214
|
+
|
|
2215
|
+
utils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) {
|
|
2216
|
+
defaults.headers[method] = {};
|
|
2217
|
+
});
|
|
2218
|
+
|
|
2219
|
+
utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
|
|
2220
|
+
defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE);
|
|
2221
|
+
});
|
|
2222
|
+
|
|
2223
|
+
module.exports = defaults;
|
|
2224
|
+
|
|
2225
|
+
}).call(this)}).call(this,require('_process'))
|
|
2226
|
+
},{"../adapters/http":15,"../adapters/xhr":15,"../core/enhanceError":25,"../helpers/normalizeHeaderName":39,"../utils":43,"./transitional":30,"_process":45}],30:[function(require,module,exports){
|
|
2227
|
+
'use strict';
|
|
2228
|
+
|
|
2229
|
+
module.exports = {
|
|
2230
|
+
silentJSONParsing: true,
|
|
2231
|
+
forcedJSONParsing: true,
|
|
2232
|
+
clarifyTimeoutError: false
|
|
2233
|
+
};
|
|
2234
|
+
|
|
2235
|
+
},{}],31:[function(require,module,exports){
|
|
2236
|
+
module.exports = {
|
|
2237
|
+
"version": "0.26.1"
|
|
2238
|
+
};
|
|
2239
|
+
},{}],32:[function(require,module,exports){
|
|
2240
|
+
'use strict';
|
|
2241
|
+
|
|
2242
|
+
module.exports = function bind(fn, thisArg) {
|
|
2243
|
+
return function wrap() {
|
|
2244
|
+
var args = new Array(arguments.length);
|
|
2245
|
+
for (var i = 0; i < args.length; i++) {
|
|
2246
|
+
args[i] = arguments[i];
|
|
2247
|
+
}
|
|
2248
|
+
return fn.apply(thisArg, args);
|
|
2249
|
+
};
|
|
2250
|
+
};
|
|
2251
|
+
|
|
2252
|
+
},{}],33:[function(require,module,exports){
|
|
2253
|
+
'use strict';
|
|
2254
|
+
|
|
2255
|
+
var utils = require('./../utils');
|
|
2256
|
+
|
|
2257
|
+
function encode(val) {
|
|
2258
|
+
return encodeURIComponent(val).
|
|
2259
|
+
replace(/%3A/gi, ':').
|
|
2260
|
+
replace(/%24/g, '$').
|
|
2261
|
+
replace(/%2C/gi, ',').
|
|
2262
|
+
replace(/%20/g, '+').
|
|
2263
|
+
replace(/%5B/gi, '[').
|
|
2264
|
+
replace(/%5D/gi, ']');
|
|
2265
|
+
}
|
|
2266
|
+
|
|
2267
|
+
/**
|
|
2268
|
+
* Build a URL by appending params to the end
|
|
2269
|
+
*
|
|
2270
|
+
* @param {string} url The base of the url (e.g., http://www.google.com)
|
|
2271
|
+
* @param {object} [params] The params to be appended
|
|
2272
|
+
* @returns {string} The formatted url
|
|
2273
|
+
*/
|
|
2274
|
+
module.exports = function buildURL(url, params, paramsSerializer) {
|
|
2275
|
+
/*eslint no-param-reassign:0*/
|
|
2276
|
+
if (!params) {
|
|
2277
|
+
return url;
|
|
2278
|
+
}
|
|
2279
|
+
|
|
2280
|
+
var serializedParams;
|
|
2281
|
+
if (paramsSerializer) {
|
|
2282
|
+
serializedParams = paramsSerializer(params);
|
|
2283
|
+
} else if (utils.isURLSearchParams(params)) {
|
|
2284
|
+
serializedParams = params.toString();
|
|
2285
|
+
} else {
|
|
2286
|
+
var parts = [];
|
|
2287
|
+
|
|
2288
|
+
utils.forEach(params, function serialize(val, key) {
|
|
2289
|
+
if (val === null || typeof val === 'undefined') {
|
|
2290
|
+
return;
|
|
2291
|
+
}
|
|
2292
|
+
|
|
2293
|
+
if (utils.isArray(val)) {
|
|
2294
|
+
key = key + '[]';
|
|
2295
|
+
} else {
|
|
2296
|
+
val = [val];
|
|
2297
|
+
}
|
|
2298
|
+
|
|
2299
|
+
utils.forEach(val, function parseValue(v) {
|
|
2300
|
+
if (utils.isDate(v)) {
|
|
2301
|
+
v = v.toISOString();
|
|
2302
|
+
} else if (utils.isObject(v)) {
|
|
2303
|
+
v = JSON.stringify(v);
|
|
2304
|
+
}
|
|
2305
|
+
parts.push(encode(key) + '=' + encode(v));
|
|
2306
|
+
});
|
|
2307
|
+
});
|
|
2308
|
+
|
|
2309
|
+
serializedParams = parts.join('&');
|
|
2310
|
+
}
|
|
2311
|
+
|
|
2312
|
+
if (serializedParams) {
|
|
2313
|
+
var hashmarkIndex = url.indexOf('#');
|
|
2314
|
+
if (hashmarkIndex !== -1) {
|
|
2315
|
+
url = url.slice(0, hashmarkIndex);
|
|
2316
|
+
}
|
|
2317
|
+
|
|
2318
|
+
url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
|
|
2319
|
+
}
|
|
2320
|
+
|
|
2321
|
+
return url;
|
|
2322
|
+
};
|
|
2323
|
+
|
|
2324
|
+
},{"./../utils":43}],34:[function(require,module,exports){
|
|
2325
|
+
'use strict';
|
|
2326
|
+
|
|
2327
|
+
/**
|
|
2328
|
+
* Creates a new URL by combining the specified URLs
|
|
2329
|
+
*
|
|
2330
|
+
* @param {string} baseURL The base URL
|
|
2331
|
+
* @param {string} relativeURL The relative URL
|
|
2332
|
+
* @returns {string} The combined URL
|
|
2333
|
+
*/
|
|
2334
|
+
module.exports = function combineURLs(baseURL, relativeURL) {
|
|
2335
|
+
return relativeURL
|
|
2336
|
+
? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '')
|
|
2337
|
+
: baseURL;
|
|
2338
|
+
};
|
|
2339
|
+
|
|
2340
|
+
},{}],35:[function(require,module,exports){
|
|
2341
|
+
'use strict';
|
|
2342
|
+
|
|
2343
|
+
var utils = require('./../utils');
|
|
2344
|
+
|
|
2345
|
+
module.exports = (
|
|
2346
|
+
utils.isStandardBrowserEnv() ?
|
|
2347
|
+
|
|
2348
|
+
// Standard browser envs support document.cookie
|
|
2349
|
+
(function standardBrowserEnv() {
|
|
2350
|
+
return {
|
|
2351
|
+
write: function write(name, value, expires, path, domain, secure) {
|
|
2352
|
+
var cookie = [];
|
|
2353
|
+
cookie.push(name + '=' + encodeURIComponent(value));
|
|
2354
|
+
|
|
2355
|
+
if (utils.isNumber(expires)) {
|
|
2356
|
+
cookie.push('expires=' + new Date(expires).toGMTString());
|
|
2357
|
+
}
|
|
2358
|
+
|
|
2359
|
+
if (utils.isString(path)) {
|
|
2360
|
+
cookie.push('path=' + path);
|
|
2361
|
+
}
|
|
2362
|
+
|
|
2363
|
+
if (utils.isString(domain)) {
|
|
2364
|
+
cookie.push('domain=' + domain);
|
|
2365
|
+
}
|
|
2366
|
+
|
|
2367
|
+
if (secure === true) {
|
|
2368
|
+
cookie.push('secure');
|
|
2369
|
+
}
|
|
2370
|
+
|
|
2371
|
+
document.cookie = cookie.join('; ');
|
|
2372
|
+
},
|
|
2373
|
+
|
|
2374
|
+
read: function read(name) {
|
|
2375
|
+
var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
|
|
2376
|
+
return (match ? decodeURIComponent(match[3]) : null);
|
|
2377
|
+
},
|
|
2378
|
+
|
|
2379
|
+
remove: function remove(name) {
|
|
2380
|
+
this.write(name, '', Date.now() - 86400000);
|
|
2381
|
+
}
|
|
2382
|
+
};
|
|
2383
|
+
})() :
|
|
2384
|
+
|
|
2385
|
+
// Non standard browser env (web workers, react-native) lack needed support.
|
|
2386
|
+
(function nonStandardBrowserEnv() {
|
|
2387
|
+
return {
|
|
2388
|
+
write: function write() {},
|
|
2389
|
+
read: function read() { return null; },
|
|
2390
|
+
remove: function remove() {}
|
|
2391
|
+
};
|
|
2392
|
+
})()
|
|
2393
|
+
);
|
|
2394
|
+
|
|
2395
|
+
},{"./../utils":43}],36:[function(require,module,exports){
|
|
2396
|
+
'use strict';
|
|
2397
|
+
|
|
2398
|
+
/**
|
|
2399
|
+
* Determines whether the specified URL is absolute
|
|
2400
|
+
*
|
|
2401
|
+
* @param {string} url The URL to test
|
|
2402
|
+
* @returns {boolean} True if the specified URL is absolute, otherwise false
|
|
2403
|
+
*/
|
|
2404
|
+
module.exports = function isAbsoluteURL(url) {
|
|
2405
|
+
// A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
|
|
2406
|
+
// RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
|
|
2407
|
+
// by any combination of letters, digits, plus, period, or hyphen.
|
|
2408
|
+
return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
|
|
2409
|
+
};
|
|
2410
|
+
|
|
2411
|
+
},{}],37:[function(require,module,exports){
|
|
2412
|
+
'use strict';
|
|
2413
|
+
|
|
2414
|
+
var utils = require('./../utils');
|
|
2415
|
+
|
|
2416
|
+
/**
|
|
2417
|
+
* Determines whether the payload is an error thrown by Axios
|
|
2418
|
+
*
|
|
2419
|
+
* @param {*} payload The value to test
|
|
2420
|
+
* @returns {boolean} True if the payload is an error thrown by Axios, otherwise false
|
|
2421
|
+
*/
|
|
2422
|
+
module.exports = function isAxiosError(payload) {
|
|
2423
|
+
return utils.isObject(payload) && (payload.isAxiosError === true);
|
|
2424
|
+
};
|
|
2425
|
+
|
|
2426
|
+
},{"./../utils":43}],38:[function(require,module,exports){
|
|
2427
|
+
'use strict';
|
|
2428
|
+
|
|
2429
|
+
var utils = require('./../utils');
|
|
2430
|
+
|
|
2431
|
+
module.exports = (
|
|
2432
|
+
utils.isStandardBrowserEnv() ?
|
|
2433
|
+
|
|
2434
|
+
// Standard browser envs have full support of the APIs needed to test
|
|
2435
|
+
// whether the request URL is of the same origin as current location.
|
|
2436
|
+
(function standardBrowserEnv() {
|
|
2437
|
+
var msie = /(msie|trident)/i.test(navigator.userAgent);
|
|
2438
|
+
var urlParsingNode = document.createElement('a');
|
|
2439
|
+
var originURL;
|
|
2440
|
+
|
|
2441
|
+
/**
|
|
2442
|
+
* Parse a URL to discover it's components
|
|
2443
|
+
*
|
|
2444
|
+
* @param {String} url The URL to be parsed
|
|
2445
|
+
* @returns {Object}
|
|
2446
|
+
*/
|
|
2447
|
+
function resolveURL(url) {
|
|
2448
|
+
var href = url;
|
|
2449
|
+
|
|
2450
|
+
if (msie) {
|
|
2451
|
+
// IE needs attribute set twice to normalize properties
|
|
2452
|
+
urlParsingNode.setAttribute('href', href);
|
|
2453
|
+
href = urlParsingNode.href;
|
|
2454
|
+
}
|
|
2455
|
+
|
|
2456
|
+
urlParsingNode.setAttribute('href', href);
|
|
2457
|
+
|
|
2458
|
+
// urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
|
|
2459
|
+
return {
|
|
2460
|
+
href: urlParsingNode.href,
|
|
2461
|
+
protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
|
|
2462
|
+
host: urlParsingNode.host,
|
|
2463
|
+
search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
|
|
2464
|
+
hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
|
|
2465
|
+
hostname: urlParsingNode.hostname,
|
|
2466
|
+
port: urlParsingNode.port,
|
|
2467
|
+
pathname: (urlParsingNode.pathname.charAt(0) === '/') ?
|
|
2468
|
+
urlParsingNode.pathname :
|
|
2469
|
+
'/' + urlParsingNode.pathname
|
|
2470
|
+
};
|
|
2471
|
+
}
|
|
2472
|
+
|
|
2473
|
+
originURL = resolveURL(window.location.href);
|
|
2474
|
+
|
|
2475
|
+
/**
|
|
2476
|
+
* Determine if a URL shares the same origin as the current location
|
|
2477
|
+
*
|
|
2478
|
+
* @param {String} requestURL The URL to test
|
|
2479
|
+
* @returns {boolean} True if URL shares the same origin, otherwise false
|
|
2480
|
+
*/
|
|
2481
|
+
return function isURLSameOrigin(requestURL) {
|
|
2482
|
+
var parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
|
|
2483
|
+
return (parsed.protocol === originURL.protocol &&
|
|
2484
|
+
parsed.host === originURL.host);
|
|
2485
|
+
};
|
|
2486
|
+
})() :
|
|
2487
|
+
|
|
2488
|
+
// Non standard browser envs (web workers, react-native) lack needed support.
|
|
2489
|
+
(function nonStandardBrowserEnv() {
|
|
2490
|
+
return function isURLSameOrigin() {
|
|
2491
|
+
return true;
|
|
2492
|
+
};
|
|
2493
|
+
})()
|
|
2494
|
+
);
|
|
2495
|
+
|
|
2496
|
+
},{"./../utils":43}],39:[function(require,module,exports){
|
|
2497
|
+
'use strict';
|
|
2498
|
+
|
|
2499
|
+
var utils = require('../utils');
|
|
2500
|
+
|
|
2501
|
+
module.exports = function normalizeHeaderName(headers, normalizedName) {
|
|
2502
|
+
utils.forEach(headers, function processHeader(value, name) {
|
|
2503
|
+
if (name !== normalizedName && name.toUpperCase() === normalizedName.toUpperCase()) {
|
|
2504
|
+
headers[normalizedName] = value;
|
|
2505
|
+
delete headers[name];
|
|
2506
|
+
}
|
|
2507
|
+
});
|
|
2508
|
+
};
|
|
2509
|
+
|
|
2510
|
+
},{"../utils":43}],40:[function(require,module,exports){
|
|
2511
|
+
'use strict';
|
|
2512
|
+
|
|
2513
|
+
var utils = require('./../utils');
|
|
2514
|
+
|
|
2515
|
+
// Headers whose duplicates are ignored by node
|
|
2516
|
+
// c.f. https://nodejs.org/api/http.html#http_message_headers
|
|
2517
|
+
var ignoreDuplicateOf = [
|
|
2518
|
+
'age', 'authorization', 'content-length', 'content-type', 'etag',
|
|
2519
|
+
'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since',
|
|
2520
|
+
'last-modified', 'location', 'max-forwards', 'proxy-authorization',
|
|
2521
|
+
'referer', 'retry-after', 'user-agent'
|
|
2522
|
+
];
|
|
2523
|
+
|
|
2524
|
+
/**
|
|
2525
|
+
* Parse headers into an object
|
|
2526
|
+
*
|
|
2527
|
+
* ```
|
|
2528
|
+
* Date: Wed, 27 Aug 2014 08:58:49 GMT
|
|
2529
|
+
* Content-Type: application/json
|
|
2530
|
+
* Connection: keep-alive
|
|
2531
|
+
* Transfer-Encoding: chunked
|
|
2532
|
+
* ```
|
|
2533
|
+
*
|
|
2534
|
+
* @param {String} headers Headers needing to be parsed
|
|
2535
|
+
* @returns {Object} Headers parsed into an object
|
|
2536
|
+
*/
|
|
2537
|
+
module.exports = function parseHeaders(headers) {
|
|
2538
|
+
var parsed = {};
|
|
2539
|
+
var key;
|
|
2540
|
+
var val;
|
|
2541
|
+
var i;
|
|
2542
|
+
|
|
2543
|
+
if (!headers) { return parsed; }
|
|
2544
|
+
|
|
2545
|
+
utils.forEach(headers.split('\n'), function parser(line) {
|
|
2546
|
+
i = line.indexOf(':');
|
|
2547
|
+
key = utils.trim(line.substr(0, i)).toLowerCase();
|
|
2548
|
+
val = utils.trim(line.substr(i + 1));
|
|
2549
|
+
|
|
2550
|
+
if (key) {
|
|
2551
|
+
if (parsed[key] && ignoreDuplicateOf.indexOf(key) >= 0) {
|
|
2552
|
+
return;
|
|
2553
|
+
}
|
|
2554
|
+
if (key === 'set-cookie') {
|
|
2555
|
+
parsed[key] = (parsed[key] ? parsed[key] : []).concat([val]);
|
|
2556
|
+
} else {
|
|
2557
|
+
parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
|
|
2558
|
+
}
|
|
2559
|
+
}
|
|
2560
|
+
});
|
|
2561
|
+
|
|
2562
|
+
return parsed;
|
|
2563
|
+
};
|
|
2564
|
+
|
|
2565
|
+
},{"./../utils":43}],41:[function(require,module,exports){
|
|
2566
|
+
'use strict';
|
|
2567
|
+
|
|
2568
|
+
/**
|
|
2569
|
+
* Syntactic sugar for invoking a function and expanding an array for arguments.
|
|
2570
|
+
*
|
|
2571
|
+
* Common use case would be to use `Function.prototype.apply`.
|
|
2572
|
+
*
|
|
2573
|
+
* ```js
|
|
2574
|
+
* function f(x, y, z) {}
|
|
2575
|
+
* var args = [1, 2, 3];
|
|
2576
|
+
* f.apply(null, args);
|
|
2577
|
+
* ```
|
|
2578
|
+
*
|
|
2579
|
+
* With `spread` this example can be re-written.
|
|
2580
|
+
*
|
|
2581
|
+
* ```js
|
|
2582
|
+
* spread(function(x, y, z) {})([1, 2, 3]);
|
|
2583
|
+
* ```
|
|
2584
|
+
*
|
|
2585
|
+
* @param {Function} callback
|
|
2586
|
+
* @returns {Function}
|
|
2587
|
+
*/
|
|
2588
|
+
module.exports = function spread(callback) {
|
|
2589
|
+
return function wrap(arr) {
|
|
2590
|
+
return callback.apply(null, arr);
|
|
2591
|
+
};
|
|
2592
|
+
};
|
|
2593
|
+
|
|
2594
|
+
},{}],42:[function(require,module,exports){
|
|
2595
|
+
'use strict';
|
|
2596
|
+
|
|
2597
|
+
var VERSION = require('../env/data').version;
|
|
2598
|
+
|
|
2599
|
+
var validators = {};
|
|
2600
|
+
|
|
2601
|
+
// eslint-disable-next-line func-names
|
|
2602
|
+
['object', 'boolean', 'number', 'function', 'string', 'symbol'].forEach(function(type, i) {
|
|
2603
|
+
validators[type] = function validator(thing) {
|
|
2604
|
+
return typeof thing === type || 'a' + (i < 1 ? 'n ' : ' ') + type;
|
|
2605
|
+
};
|
|
2606
|
+
});
|
|
2607
|
+
|
|
2608
|
+
var deprecatedWarnings = {};
|
|
2609
|
+
|
|
2610
|
+
/**
|
|
2611
|
+
* Transitional option validator
|
|
2612
|
+
* @param {function|boolean?} validator - set to false if the transitional option has been removed
|
|
2613
|
+
* @param {string?} version - deprecated version / removed since version
|
|
2614
|
+
* @param {string?} message - some message with additional info
|
|
2615
|
+
* @returns {function}
|
|
2616
|
+
*/
|
|
2617
|
+
validators.transitional = function transitional(validator, version, message) {
|
|
2618
|
+
function formatMessage(opt, desc) {
|
|
2619
|
+
return '[Axios v' + VERSION + '] Transitional option \'' + opt + '\'' + desc + (message ? '. ' + message : '');
|
|
2620
|
+
}
|
|
2621
|
+
|
|
2622
|
+
// eslint-disable-next-line func-names
|
|
2623
|
+
return function(value, opt, opts) {
|
|
2624
|
+
if (validator === false) {
|
|
2625
|
+
throw new Error(formatMessage(opt, ' has been removed' + (version ? ' in ' + version : '')));
|
|
2626
|
+
}
|
|
2627
|
+
|
|
2628
|
+
if (version && !deprecatedWarnings[opt]) {
|
|
2629
|
+
deprecatedWarnings[opt] = true;
|
|
2630
|
+
// eslint-disable-next-line no-console
|
|
2631
|
+
console.warn(
|
|
2632
|
+
formatMessage(
|
|
2633
|
+
opt,
|
|
2634
|
+
' has been deprecated since v' + version + ' and will be removed in the near future'
|
|
2635
|
+
)
|
|
2636
|
+
);
|
|
2637
|
+
}
|
|
2638
|
+
|
|
2639
|
+
return validator ? validator(value, opt, opts) : true;
|
|
2640
|
+
};
|
|
2641
|
+
};
|
|
2642
|
+
|
|
2643
|
+
/**
|
|
2644
|
+
* Assert object's properties type
|
|
2645
|
+
* @param {object} options
|
|
2646
|
+
* @param {object} schema
|
|
2647
|
+
* @param {boolean?} allowUnknown
|
|
2648
|
+
*/
|
|
2649
|
+
|
|
2650
|
+
function assertOptions(options, schema, allowUnknown) {
|
|
2651
|
+
if (typeof options !== 'object') {
|
|
2652
|
+
throw new TypeError('options must be an object');
|
|
2653
|
+
}
|
|
2654
|
+
var keys = Object.keys(options);
|
|
2655
|
+
var i = keys.length;
|
|
2656
|
+
while (i-- > 0) {
|
|
2657
|
+
var opt = keys[i];
|
|
2658
|
+
var validator = schema[opt];
|
|
2659
|
+
if (validator) {
|
|
2660
|
+
var value = options[opt];
|
|
2661
|
+
var result = value === undefined || validator(value, opt, options);
|
|
2662
|
+
if (result !== true) {
|
|
2663
|
+
throw new TypeError('option ' + opt + ' must be ' + result);
|
|
2664
|
+
}
|
|
2665
|
+
continue;
|
|
2666
|
+
}
|
|
2667
|
+
if (allowUnknown !== true) {
|
|
2668
|
+
throw Error('Unknown option ' + opt);
|
|
2669
|
+
}
|
|
2670
|
+
}
|
|
2671
|
+
}
|
|
2672
|
+
|
|
2673
|
+
module.exports = {
|
|
2674
|
+
assertOptions: assertOptions,
|
|
2675
|
+
validators: validators
|
|
2676
|
+
};
|
|
2677
|
+
|
|
2678
|
+
},{"../env/data":31}],43:[function(require,module,exports){
|
|
2679
|
+
'use strict';
|
|
2680
|
+
|
|
2681
|
+
var bind = require('./helpers/bind');
|
|
2682
|
+
|
|
2683
|
+
// utils is a library of generic helper functions non-specific to axios
|
|
2684
|
+
|
|
2685
|
+
var toString = Object.prototype.toString;
|
|
2686
|
+
|
|
2687
|
+
/**
|
|
2688
|
+
* Determine if a value is an Array
|
|
2689
|
+
*
|
|
2690
|
+
* @param {Object} val The value to test
|
|
2691
|
+
* @returns {boolean} True if value is an Array, otherwise false
|
|
2692
|
+
*/
|
|
2693
|
+
function isArray(val) {
|
|
2694
|
+
return Array.isArray(val);
|
|
2695
|
+
}
|
|
2696
|
+
|
|
2697
|
+
/**
|
|
2698
|
+
* Determine if a value is undefined
|
|
2699
|
+
*
|
|
2700
|
+
* @param {Object} val The value to test
|
|
2701
|
+
* @returns {boolean} True if the value is undefined, otherwise false
|
|
2702
|
+
*/
|
|
2703
|
+
function isUndefined(val) {
|
|
2704
|
+
return typeof val === 'undefined';
|
|
2705
|
+
}
|
|
2706
|
+
|
|
2707
|
+
/**
|
|
2708
|
+
* Determine if a value is a Buffer
|
|
2709
|
+
*
|
|
2710
|
+
* @param {Object} val The value to test
|
|
2711
|
+
* @returns {boolean} True if value is a Buffer, otherwise false
|
|
2712
|
+
*/
|
|
2713
|
+
function isBuffer(val) {
|
|
2714
|
+
return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor)
|
|
2715
|
+
&& typeof val.constructor.isBuffer === 'function' && val.constructor.isBuffer(val);
|
|
2716
|
+
}
|
|
2717
|
+
|
|
2718
|
+
/**
|
|
2719
|
+
* Determine if a value is an ArrayBuffer
|
|
2720
|
+
*
|
|
2721
|
+
* @param {Object} val The value to test
|
|
2722
|
+
* @returns {boolean} True if value is an ArrayBuffer, otherwise false
|
|
2723
|
+
*/
|
|
2724
|
+
function isArrayBuffer(val) {
|
|
2725
|
+
return toString.call(val) === '[object ArrayBuffer]';
|
|
2726
|
+
}
|
|
2727
|
+
|
|
2728
|
+
/**
|
|
2729
|
+
* Determine if a value is a FormData
|
|
2730
|
+
*
|
|
2731
|
+
* @param {Object} val The value to test
|
|
2732
|
+
* @returns {boolean} True if value is an FormData, otherwise false
|
|
2733
|
+
*/
|
|
2734
|
+
function isFormData(val) {
|
|
2735
|
+
return toString.call(val) === '[object FormData]';
|
|
2736
|
+
}
|
|
2737
|
+
|
|
2738
|
+
/**
|
|
2739
|
+
* Determine if a value is a view on an ArrayBuffer
|
|
2740
|
+
*
|
|
2741
|
+
* @param {Object} val The value to test
|
|
2742
|
+
* @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false
|
|
2743
|
+
*/
|
|
2744
|
+
function isArrayBufferView(val) {
|
|
2745
|
+
var result;
|
|
2746
|
+
if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) {
|
|
2747
|
+
result = ArrayBuffer.isView(val);
|
|
2748
|
+
} else {
|
|
2749
|
+
result = (val) && (val.buffer) && (isArrayBuffer(val.buffer));
|
|
2750
|
+
}
|
|
2751
|
+
return result;
|
|
2752
|
+
}
|
|
2753
|
+
|
|
2754
|
+
/**
|
|
2755
|
+
* Determine if a value is a String
|
|
2756
|
+
*
|
|
2757
|
+
* @param {Object} val The value to test
|
|
2758
|
+
* @returns {boolean} True if value is a String, otherwise false
|
|
2759
|
+
*/
|
|
2760
|
+
function isString(val) {
|
|
2761
|
+
return typeof val === 'string';
|
|
2762
|
+
}
|
|
2763
|
+
|
|
2764
|
+
/**
|
|
2765
|
+
* Determine if a value is a Number
|
|
2766
|
+
*
|
|
2767
|
+
* @param {Object} val The value to test
|
|
2768
|
+
* @returns {boolean} True if value is a Number, otherwise false
|
|
2769
|
+
*/
|
|
2770
|
+
function isNumber(val) {
|
|
2771
|
+
return typeof val === 'number';
|
|
2772
|
+
}
|
|
2773
|
+
|
|
2774
|
+
/**
|
|
2775
|
+
* Determine if a value is an Object
|
|
2776
|
+
*
|
|
2777
|
+
* @param {Object} val The value to test
|
|
2778
|
+
* @returns {boolean} True if value is an Object, otherwise false
|
|
2779
|
+
*/
|
|
2780
|
+
function isObject(val) {
|
|
2781
|
+
return val !== null && typeof val === 'object';
|
|
2782
|
+
}
|
|
2783
|
+
|
|
2784
|
+
/**
|
|
2785
|
+
* Determine if a value is a plain Object
|
|
2786
|
+
*
|
|
2787
|
+
* @param {Object} val The value to test
|
|
2788
|
+
* @return {boolean} True if value is a plain Object, otherwise false
|
|
2789
|
+
*/
|
|
2790
|
+
function isPlainObject(val) {
|
|
2791
|
+
if (toString.call(val) !== '[object Object]') {
|
|
2792
|
+
return false;
|
|
2793
|
+
}
|
|
2794
|
+
|
|
2795
|
+
var prototype = Object.getPrototypeOf(val);
|
|
2796
|
+
return prototype === null || prototype === Object.prototype;
|
|
2797
|
+
}
|
|
2798
|
+
|
|
2799
|
+
/**
|
|
2800
|
+
* Determine if a value is a Date
|
|
2801
|
+
*
|
|
2802
|
+
* @param {Object} val The value to test
|
|
2803
|
+
* @returns {boolean} True if value is a Date, otherwise false
|
|
2804
|
+
*/
|
|
2805
|
+
function isDate(val) {
|
|
2806
|
+
return toString.call(val) === '[object Date]';
|
|
2807
|
+
}
|
|
2808
|
+
|
|
2809
|
+
/**
|
|
2810
|
+
* Determine if a value is a File
|
|
2811
|
+
*
|
|
2812
|
+
* @param {Object} val The value to test
|
|
2813
|
+
* @returns {boolean} True if value is a File, otherwise false
|
|
2814
|
+
*/
|
|
2815
|
+
function isFile(val) {
|
|
2816
|
+
return toString.call(val) === '[object File]';
|
|
2817
|
+
}
|
|
2818
|
+
|
|
2819
|
+
/**
|
|
2820
|
+
* Determine if a value is a Blob
|
|
2821
|
+
*
|
|
2822
|
+
* @param {Object} val The value to test
|
|
2823
|
+
* @returns {boolean} True if value is a Blob, otherwise false
|
|
2824
|
+
*/
|
|
2825
|
+
function isBlob(val) {
|
|
2826
|
+
return toString.call(val) === '[object Blob]';
|
|
2827
|
+
}
|
|
2828
|
+
|
|
2829
|
+
/**
|
|
2830
|
+
* Determine if a value is a Function
|
|
2831
|
+
*
|
|
2832
|
+
* @param {Object} val The value to test
|
|
2833
|
+
* @returns {boolean} True if value is a Function, otherwise false
|
|
2834
|
+
*/
|
|
2835
|
+
function isFunction(val) {
|
|
2836
|
+
return toString.call(val) === '[object Function]';
|
|
2837
|
+
}
|
|
2838
|
+
|
|
2839
|
+
/**
|
|
2840
|
+
* Determine if a value is a Stream
|
|
2841
|
+
*
|
|
2842
|
+
* @param {Object} val The value to test
|
|
2843
|
+
* @returns {boolean} True if value is a Stream, otherwise false
|
|
2844
|
+
*/
|
|
2845
|
+
function isStream(val) {
|
|
2846
|
+
return isObject(val) && isFunction(val.pipe);
|
|
2847
|
+
}
|
|
2848
|
+
|
|
2849
|
+
/**
|
|
2850
|
+
* Determine if a value is a URLSearchParams object
|
|
2851
|
+
*
|
|
2852
|
+
* @param {Object} val The value to test
|
|
2853
|
+
* @returns {boolean} True if value is a URLSearchParams object, otherwise false
|
|
2854
|
+
*/
|
|
2855
|
+
function isURLSearchParams(val) {
|
|
2856
|
+
return toString.call(val) === '[object URLSearchParams]';
|
|
2857
|
+
}
|
|
2858
|
+
|
|
2859
|
+
/**
|
|
2860
|
+
* Trim excess whitespace off the beginning and end of a string
|
|
2861
|
+
*
|
|
2862
|
+
* @param {String} str The String to trim
|
|
2863
|
+
* @returns {String} The String freed of excess whitespace
|
|
2864
|
+
*/
|
|
2865
|
+
function trim(str) {
|
|
2866
|
+
return str.trim ? str.trim() : str.replace(/^\s+|\s+$/g, '');
|
|
2867
|
+
}
|
|
2868
|
+
|
|
2869
|
+
/**
|
|
2870
|
+
* Determine if we're running in a standard browser environment
|
|
2871
|
+
*
|
|
2872
|
+
* This allows axios to run in a web worker, and react-native.
|
|
2873
|
+
* Both environments support XMLHttpRequest, but not fully standard globals.
|
|
2874
|
+
*
|
|
2875
|
+
* web workers:
|
|
2876
|
+
* typeof window -> undefined
|
|
2877
|
+
* typeof document -> undefined
|
|
2878
|
+
*
|
|
2879
|
+
* react-native:
|
|
2880
|
+
* navigator.product -> 'ReactNative'
|
|
2881
|
+
* nativescript
|
|
2882
|
+
* navigator.product -> 'NativeScript' or 'NS'
|
|
2883
|
+
*/
|
|
2884
|
+
function isStandardBrowserEnv() {
|
|
2885
|
+
if (typeof navigator !== 'undefined' && (navigator.product === 'ReactNative' ||
|
|
2886
|
+
navigator.product === 'NativeScript' ||
|
|
2887
|
+
navigator.product === 'NS')) {
|
|
2888
|
+
return false;
|
|
2889
|
+
}
|
|
2890
|
+
return (
|
|
2891
|
+
typeof window !== 'undefined' &&
|
|
2892
|
+
typeof document !== 'undefined'
|
|
2893
|
+
);
|
|
2894
|
+
}
|
|
2895
|
+
|
|
2896
|
+
/**
|
|
2897
|
+
* Iterate over an Array or an Object invoking a function for each item.
|
|
2898
|
+
*
|
|
2899
|
+
* If `obj` is an Array callback will be called passing
|
|
2900
|
+
* the value, index, and complete array for each item.
|
|
2901
|
+
*
|
|
2902
|
+
* If 'obj' is an Object callback will be called passing
|
|
2903
|
+
* the value, key, and complete object for each property.
|
|
2904
|
+
*
|
|
2905
|
+
* @param {Object|Array} obj The object to iterate
|
|
2906
|
+
* @param {Function} fn The callback to invoke for each item
|
|
2907
|
+
*/
|
|
2908
|
+
function forEach(obj, fn) {
|
|
2909
|
+
// Don't bother if no value provided
|
|
2910
|
+
if (obj === null || typeof obj === 'undefined') {
|
|
2911
|
+
return;
|
|
2912
|
+
}
|
|
2913
|
+
|
|
2914
|
+
// Force an array if not already something iterable
|
|
2915
|
+
if (typeof obj !== 'object') {
|
|
2916
|
+
/*eslint no-param-reassign:0*/
|
|
2917
|
+
obj = [obj];
|
|
2918
|
+
}
|
|
2919
|
+
|
|
2920
|
+
if (isArray(obj)) {
|
|
2921
|
+
// Iterate over array values
|
|
2922
|
+
for (var i = 0, l = obj.length; i < l; i++) {
|
|
2923
|
+
fn.call(null, obj[i], i, obj);
|
|
2924
|
+
}
|
|
2925
|
+
} else {
|
|
2926
|
+
// Iterate over object keys
|
|
2927
|
+
for (var key in obj) {
|
|
2928
|
+
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
2929
|
+
fn.call(null, obj[key], key, obj);
|
|
2930
|
+
}
|
|
2931
|
+
}
|
|
2932
|
+
}
|
|
2933
|
+
}
|
|
2934
|
+
|
|
2935
|
+
/**
|
|
2936
|
+
* Accepts varargs expecting each argument to be an object, then
|
|
2937
|
+
* immutably merges the properties of each object and returns result.
|
|
2938
|
+
*
|
|
2939
|
+
* When multiple objects contain the same key the later object in
|
|
2940
|
+
* the arguments list will take precedence.
|
|
2941
|
+
*
|
|
2942
|
+
* Example:
|
|
2943
|
+
*
|
|
2944
|
+
* ```js
|
|
2945
|
+
* var result = merge({foo: 123}, {foo: 456});
|
|
2946
|
+
* console.log(result.foo); // outputs 456
|
|
2947
|
+
* ```
|
|
2948
|
+
*
|
|
2949
|
+
* @param {Object} obj1 Object to merge
|
|
2950
|
+
* @returns {Object} Result of all merge properties
|
|
2951
|
+
*/
|
|
2952
|
+
function merge(/* obj1, obj2, obj3, ... */) {
|
|
2953
|
+
var result = {};
|
|
2954
|
+
function assignValue(val, key) {
|
|
2955
|
+
if (isPlainObject(result[key]) && isPlainObject(val)) {
|
|
2956
|
+
result[key] = merge(result[key], val);
|
|
2957
|
+
} else if (isPlainObject(val)) {
|
|
2958
|
+
result[key] = merge({}, val);
|
|
2959
|
+
} else if (isArray(val)) {
|
|
2960
|
+
result[key] = val.slice();
|
|
2961
|
+
} else {
|
|
2962
|
+
result[key] = val;
|
|
2963
|
+
}
|
|
2964
|
+
}
|
|
2965
|
+
|
|
2966
|
+
for (var i = 0, l = arguments.length; i < l; i++) {
|
|
2967
|
+
forEach(arguments[i], assignValue);
|
|
2968
|
+
}
|
|
2969
|
+
return result;
|
|
2970
|
+
}
|
|
2971
|
+
|
|
2972
|
+
/**
|
|
2973
|
+
* Extends object a by mutably adding to it the properties of object b.
|
|
2974
|
+
*
|
|
2975
|
+
* @param {Object} a The object to be extended
|
|
2976
|
+
* @param {Object} b The object to copy properties from
|
|
2977
|
+
* @param {Object} thisArg The object to bind function to
|
|
2978
|
+
* @return {Object} The resulting value of object a
|
|
2979
|
+
*/
|
|
2980
|
+
function extend(a, b, thisArg) {
|
|
2981
|
+
forEach(b, function assignValue(val, key) {
|
|
2982
|
+
if (thisArg && typeof val === 'function') {
|
|
2983
|
+
a[key] = bind(val, thisArg);
|
|
2984
|
+
} else {
|
|
2985
|
+
a[key] = val;
|
|
2986
|
+
}
|
|
2987
|
+
});
|
|
2988
|
+
return a;
|
|
2989
|
+
}
|
|
2990
|
+
|
|
2991
|
+
/**
|
|
2992
|
+
* Remove byte order marker. This catches EF BB BF (the UTF-8 BOM)
|
|
2993
|
+
*
|
|
2994
|
+
* @param {string} content with BOM
|
|
2995
|
+
* @return {string} content value without BOM
|
|
2996
|
+
*/
|
|
2997
|
+
function stripBOM(content) {
|
|
2998
|
+
if (content.charCodeAt(0) === 0xFEFF) {
|
|
2999
|
+
content = content.slice(1);
|
|
3000
|
+
}
|
|
3001
|
+
return content;
|
|
3002
|
+
}
|
|
3003
|
+
|
|
3004
|
+
module.exports = {
|
|
3005
|
+
isArray: isArray,
|
|
3006
|
+
isArrayBuffer: isArrayBuffer,
|
|
3007
|
+
isBuffer: isBuffer,
|
|
3008
|
+
isFormData: isFormData,
|
|
3009
|
+
isArrayBufferView: isArrayBufferView,
|
|
3010
|
+
isString: isString,
|
|
3011
|
+
isNumber: isNumber,
|
|
3012
|
+
isObject: isObject,
|
|
3013
|
+
isPlainObject: isPlainObject,
|
|
3014
|
+
isUndefined: isUndefined,
|
|
3015
|
+
isDate: isDate,
|
|
3016
|
+
isFile: isFile,
|
|
3017
|
+
isBlob: isBlob,
|
|
3018
|
+
isFunction: isFunction,
|
|
3019
|
+
isStream: isStream,
|
|
3020
|
+
isURLSearchParams: isURLSearchParams,
|
|
3021
|
+
isStandardBrowserEnv: isStandardBrowserEnv,
|
|
3022
|
+
forEach: forEach,
|
|
3023
|
+
merge: merge,
|
|
3024
|
+
extend: extend,
|
|
3025
|
+
trim: trim,
|
|
3026
|
+
stripBOM: stripBOM
|
|
3027
|
+
};
|
|
3028
|
+
|
|
3029
|
+
},{"./helpers/bind":32}],44:[function(require,module,exports){
|
|
3030
|
+
// Copyright Joyent, Inc. and other Node contributors.
|
|
3031
|
+
//
|
|
3032
|
+
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
3033
|
+
// copy of this software and associated documentation files (the
|
|
3034
|
+
// "Software"), to deal in the Software without restriction, including
|
|
3035
|
+
// without limitation the rights to use, copy, modify, merge, publish,
|
|
3036
|
+
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
|
3037
|
+
// persons to whom the Software is furnished to do so, subject to the
|
|
3038
|
+
// following conditions:
|
|
3039
|
+
//
|
|
3040
|
+
// The above copyright notice and this permission notice shall be included
|
|
3041
|
+
// in all copies or substantial portions of the Software.
|
|
3042
|
+
//
|
|
3043
|
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
3044
|
+
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
3045
|
+
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
|
3046
|
+
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
3047
|
+
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
3048
|
+
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|
3049
|
+
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
3050
|
+
|
|
3051
|
+
'use strict';
|
|
3052
|
+
|
|
3053
|
+
var R = typeof Reflect === 'object' ? Reflect : null
|
|
3054
|
+
var ReflectApply = R && typeof R.apply === 'function'
|
|
3055
|
+
? R.apply
|
|
3056
|
+
: function ReflectApply(target, receiver, args) {
|
|
3057
|
+
return Function.prototype.apply.call(target, receiver, args);
|
|
3058
|
+
}
|
|
3059
|
+
|
|
3060
|
+
var ReflectOwnKeys
|
|
3061
|
+
if (R && typeof R.ownKeys === 'function') {
|
|
3062
|
+
ReflectOwnKeys = R.ownKeys
|
|
3063
|
+
} else if (Object.getOwnPropertySymbols) {
|
|
3064
|
+
ReflectOwnKeys = function ReflectOwnKeys(target) {
|
|
3065
|
+
return Object.getOwnPropertyNames(target)
|
|
3066
|
+
.concat(Object.getOwnPropertySymbols(target));
|
|
3067
|
+
};
|
|
3068
|
+
} else {
|
|
3069
|
+
ReflectOwnKeys = function ReflectOwnKeys(target) {
|
|
3070
|
+
return Object.getOwnPropertyNames(target);
|
|
3071
|
+
};
|
|
3072
|
+
}
|
|
3073
|
+
|
|
3074
|
+
function ProcessEmitWarning(warning) {
|
|
3075
|
+
if (console && console.warn) console.warn(warning);
|
|
3076
|
+
}
|
|
3077
|
+
|
|
3078
|
+
var NumberIsNaN = Number.isNaN || function NumberIsNaN(value) {
|
|
3079
|
+
return value !== value;
|
|
3080
|
+
}
|
|
3081
|
+
|
|
3082
|
+
function EventEmitter() {
|
|
3083
|
+
EventEmitter.init.call(this);
|
|
3084
|
+
}
|
|
3085
|
+
module.exports = EventEmitter;
|
|
3086
|
+
module.exports.once = once;
|
|
3087
|
+
|
|
3088
|
+
// Backwards-compat with node 0.10.x
|
|
3089
|
+
EventEmitter.EventEmitter = EventEmitter;
|
|
3090
|
+
|
|
3091
|
+
EventEmitter.prototype._events = undefined;
|
|
3092
|
+
EventEmitter.prototype._eventsCount = 0;
|
|
3093
|
+
EventEmitter.prototype._maxListeners = undefined;
|
|
3094
|
+
|
|
3095
|
+
// By default EventEmitters will print a warning if more than 10 listeners are
|
|
3096
|
+
// added to it. This is a useful default which helps finding memory leaks.
|
|
3097
|
+
var defaultMaxListeners = 10;
|
|
3098
|
+
|
|
3099
|
+
function checkListener(listener) {
|
|
3100
|
+
if (typeof listener !== 'function') {
|
|
3101
|
+
throw new TypeError('The "listener" argument must be of type Function. Received type ' + typeof listener);
|
|
3102
|
+
}
|
|
3103
|
+
}
|
|
3104
|
+
|
|
3105
|
+
Object.defineProperty(EventEmitter, 'defaultMaxListeners', {
|
|
3106
|
+
enumerable: true,
|
|
3107
|
+
get: function() {
|
|
3108
|
+
return defaultMaxListeners;
|
|
3109
|
+
},
|
|
3110
|
+
set: function(arg) {
|
|
3111
|
+
if (typeof arg !== 'number' || arg < 0 || NumberIsNaN(arg)) {
|
|
3112
|
+
throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received ' + arg + '.');
|
|
3113
|
+
}
|
|
3114
|
+
defaultMaxListeners = arg;
|
|
3115
|
+
}
|
|
3116
|
+
});
|
|
3117
|
+
|
|
3118
|
+
EventEmitter.init = function() {
|
|
3119
|
+
|
|
3120
|
+
if (this._events === undefined ||
|
|
3121
|
+
this._events === Object.getPrototypeOf(this)._events) {
|
|
3122
|
+
this._events = Object.create(null);
|
|
3123
|
+
this._eventsCount = 0;
|
|
3124
|
+
}
|
|
3125
|
+
|
|
3126
|
+
this._maxListeners = this._maxListeners || undefined;
|
|
3127
|
+
};
|
|
3128
|
+
|
|
3129
|
+
// Obviously not all Emitters should be limited to 10. This function allows
|
|
3130
|
+
// that to be increased. Set to zero for unlimited.
|
|
3131
|
+
EventEmitter.prototype.setMaxListeners = function setMaxListeners(n) {
|
|
3132
|
+
if (typeof n !== 'number' || n < 0 || NumberIsNaN(n)) {
|
|
3133
|
+
throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received ' + n + '.');
|
|
3134
|
+
}
|
|
3135
|
+
this._maxListeners = n;
|
|
3136
|
+
return this;
|
|
3137
|
+
};
|
|
3138
|
+
|
|
3139
|
+
function _getMaxListeners(that) {
|
|
3140
|
+
if (that._maxListeners === undefined)
|
|
3141
|
+
return EventEmitter.defaultMaxListeners;
|
|
3142
|
+
return that._maxListeners;
|
|
3143
|
+
}
|
|
3144
|
+
|
|
3145
|
+
EventEmitter.prototype.getMaxListeners = function getMaxListeners() {
|
|
3146
|
+
return _getMaxListeners(this);
|
|
3147
|
+
};
|
|
3148
|
+
|
|
3149
|
+
EventEmitter.prototype.emit = function emit(type) {
|
|
3150
|
+
var args = [];
|
|
3151
|
+
for (var i = 1; i < arguments.length; i++) args.push(arguments[i]);
|
|
3152
|
+
var doError = (type === 'error');
|
|
3153
|
+
|
|
3154
|
+
var events = this._events;
|
|
3155
|
+
if (events !== undefined)
|
|
3156
|
+
doError = (doError && events.error === undefined);
|
|
3157
|
+
else if (!doError)
|
|
3158
|
+
return false;
|
|
3159
|
+
|
|
3160
|
+
// If there is no 'error' event listener then throw.
|
|
3161
|
+
if (doError) {
|
|
3162
|
+
var er;
|
|
3163
|
+
if (args.length > 0)
|
|
3164
|
+
er = args[0];
|
|
3165
|
+
if (er instanceof Error) {
|
|
3166
|
+
// Note: The comments on the `throw` lines are intentional, they show
|
|
3167
|
+
// up in Node's output if this results in an unhandled exception.
|
|
3168
|
+
throw er; // Unhandled 'error' event
|
|
3169
|
+
}
|
|
3170
|
+
// At least give some kind of context to the user
|
|
3171
|
+
var err = new Error('Unhandled error.' + (er ? ' (' + er.message + ')' : ''));
|
|
3172
|
+
err.context = er;
|
|
3173
|
+
throw err; // Unhandled 'error' event
|
|
3174
|
+
}
|
|
3175
|
+
|
|
3176
|
+
var handler = events[type];
|
|
3177
|
+
|
|
3178
|
+
if (handler === undefined)
|
|
3179
|
+
return false;
|
|
3180
|
+
|
|
3181
|
+
if (typeof handler === 'function') {
|
|
3182
|
+
ReflectApply(handler, this, args);
|
|
3183
|
+
} else {
|
|
3184
|
+
var len = handler.length;
|
|
3185
|
+
var listeners = arrayClone(handler, len);
|
|
3186
|
+
for (var i = 0; i < len; ++i)
|
|
3187
|
+
ReflectApply(listeners[i], this, args);
|
|
3188
|
+
}
|
|
3189
|
+
|
|
3190
|
+
return true;
|
|
3191
|
+
};
|
|
3192
|
+
|
|
3193
|
+
function _addListener(target, type, listener, prepend) {
|
|
3194
|
+
var m;
|
|
3195
|
+
var events;
|
|
3196
|
+
var existing;
|
|
3197
|
+
|
|
3198
|
+
checkListener(listener);
|
|
3199
|
+
|
|
3200
|
+
events = target._events;
|
|
3201
|
+
if (events === undefined) {
|
|
3202
|
+
events = target._events = Object.create(null);
|
|
3203
|
+
target._eventsCount = 0;
|
|
3204
|
+
} else {
|
|
3205
|
+
// To avoid recursion in the case that type === "newListener"! Before
|
|
3206
|
+
// adding it to the listeners, first emit "newListener".
|
|
3207
|
+
if (events.newListener !== undefined) {
|
|
3208
|
+
target.emit('newListener', type,
|
|
3209
|
+
listener.listener ? listener.listener : listener);
|
|
3210
|
+
|
|
3211
|
+
// Re-assign `events` because a newListener handler could have caused the
|
|
3212
|
+
// this._events to be assigned to a new object
|
|
3213
|
+
events = target._events;
|
|
3214
|
+
}
|
|
3215
|
+
existing = events[type];
|
|
3216
|
+
}
|
|
3217
|
+
|
|
3218
|
+
if (existing === undefined) {
|
|
3219
|
+
// Optimize the case of one listener. Don't need the extra array object.
|
|
3220
|
+
existing = events[type] = listener;
|
|
3221
|
+
++target._eventsCount;
|
|
3222
|
+
} else {
|
|
3223
|
+
if (typeof existing === 'function') {
|
|
3224
|
+
// Adding the second element, need to change to array.
|
|
3225
|
+
existing = events[type] =
|
|
3226
|
+
prepend ? [listener, existing] : [existing, listener];
|
|
3227
|
+
// If we've already got an array, just append.
|
|
3228
|
+
} else if (prepend) {
|
|
3229
|
+
existing.unshift(listener);
|
|
3230
|
+
} else {
|
|
3231
|
+
existing.push(listener);
|
|
3232
|
+
}
|
|
3233
|
+
|
|
3234
|
+
// Check for listener leak
|
|
3235
|
+
m = _getMaxListeners(target);
|
|
3236
|
+
if (m > 0 && existing.length > m && !existing.warned) {
|
|
3237
|
+
existing.warned = true;
|
|
3238
|
+
// No error code for this since it is a Warning
|
|
3239
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
3240
|
+
var w = new Error('Possible EventEmitter memory leak detected. ' +
|
|
3241
|
+
existing.length + ' ' + String(type) + ' listeners ' +
|
|
3242
|
+
'added. Use emitter.setMaxListeners() to ' +
|
|
3243
|
+
'increase limit');
|
|
3244
|
+
w.name = 'MaxListenersExceededWarning';
|
|
3245
|
+
w.emitter = target;
|
|
3246
|
+
w.type = type;
|
|
3247
|
+
w.count = existing.length;
|
|
3248
|
+
ProcessEmitWarning(w);
|
|
3249
|
+
}
|
|
3250
|
+
}
|
|
3251
|
+
|
|
3252
|
+
return target;
|
|
3253
|
+
}
|
|
3254
|
+
|
|
3255
|
+
EventEmitter.prototype.addListener = function addListener(type, listener) {
|
|
3256
|
+
return _addListener(this, type, listener, false);
|
|
3257
|
+
};
|
|
3258
|
+
|
|
3259
|
+
EventEmitter.prototype.on = EventEmitter.prototype.addListener;
|
|
3260
|
+
|
|
3261
|
+
EventEmitter.prototype.prependListener =
|
|
3262
|
+
function prependListener(type, listener) {
|
|
3263
|
+
return _addListener(this, type, listener, true);
|
|
3264
|
+
};
|
|
3265
|
+
|
|
3266
|
+
function onceWrapper() {
|
|
3267
|
+
if (!this.fired) {
|
|
3268
|
+
this.target.removeListener(this.type, this.wrapFn);
|
|
3269
|
+
this.fired = true;
|
|
3270
|
+
if (arguments.length === 0)
|
|
3271
|
+
return this.listener.call(this.target);
|
|
3272
|
+
return this.listener.apply(this.target, arguments);
|
|
3273
|
+
}
|
|
3274
|
+
}
|
|
3275
|
+
|
|
3276
|
+
function _onceWrap(target, type, listener) {
|
|
3277
|
+
var state = { fired: false, wrapFn: undefined, target: target, type: type, listener: listener };
|
|
3278
|
+
var wrapped = onceWrapper.bind(state);
|
|
3279
|
+
wrapped.listener = listener;
|
|
3280
|
+
state.wrapFn = wrapped;
|
|
3281
|
+
return wrapped;
|
|
3282
|
+
}
|
|
3283
|
+
|
|
3284
|
+
EventEmitter.prototype.once = function once(type, listener) {
|
|
3285
|
+
checkListener(listener);
|
|
3286
|
+
this.on(type, _onceWrap(this, type, listener));
|
|
3287
|
+
return this;
|
|
3288
|
+
};
|
|
3289
|
+
|
|
3290
|
+
EventEmitter.prototype.prependOnceListener =
|
|
3291
|
+
function prependOnceListener(type, listener) {
|
|
3292
|
+
checkListener(listener);
|
|
3293
|
+
this.prependListener(type, _onceWrap(this, type, listener));
|
|
3294
|
+
return this;
|
|
3295
|
+
};
|
|
3296
|
+
|
|
3297
|
+
// Emits a 'removeListener' event if and only if the listener was removed.
|
|
3298
|
+
EventEmitter.prototype.removeListener =
|
|
3299
|
+
function removeListener(type, listener) {
|
|
3300
|
+
var list, events, position, i, originalListener;
|
|
3301
|
+
|
|
3302
|
+
checkListener(listener);
|
|
3303
|
+
|
|
3304
|
+
events = this._events;
|
|
3305
|
+
if (events === undefined)
|
|
3306
|
+
return this;
|
|
3307
|
+
|
|
3308
|
+
list = events[type];
|
|
3309
|
+
if (list === undefined)
|
|
3310
|
+
return this;
|
|
3311
|
+
|
|
3312
|
+
if (list === listener || list.listener === listener) {
|
|
3313
|
+
if (--this._eventsCount === 0)
|
|
3314
|
+
this._events = Object.create(null);
|
|
3315
|
+
else {
|
|
3316
|
+
delete events[type];
|
|
3317
|
+
if (events.removeListener)
|
|
3318
|
+
this.emit('removeListener', type, list.listener || listener);
|
|
3319
|
+
}
|
|
3320
|
+
} else if (typeof list !== 'function') {
|
|
3321
|
+
position = -1;
|
|
3322
|
+
|
|
3323
|
+
for (i = list.length - 1; i >= 0; i--) {
|
|
3324
|
+
if (list[i] === listener || list[i].listener === listener) {
|
|
3325
|
+
originalListener = list[i].listener;
|
|
3326
|
+
position = i;
|
|
3327
|
+
break;
|
|
3328
|
+
}
|
|
3329
|
+
}
|
|
3330
|
+
|
|
3331
|
+
if (position < 0)
|
|
3332
|
+
return this;
|
|
3333
|
+
|
|
3334
|
+
if (position === 0)
|
|
3335
|
+
list.shift();
|
|
3336
|
+
else {
|
|
3337
|
+
spliceOne(list, position);
|
|
3338
|
+
}
|
|
3339
|
+
|
|
3340
|
+
if (list.length === 1)
|
|
3341
|
+
events[type] = list[0];
|
|
3342
|
+
|
|
3343
|
+
if (events.removeListener !== undefined)
|
|
3344
|
+
this.emit('removeListener', type, originalListener || listener);
|
|
3345
|
+
}
|
|
3346
|
+
|
|
3347
|
+
return this;
|
|
3348
|
+
};
|
|
3349
|
+
|
|
3350
|
+
EventEmitter.prototype.off = EventEmitter.prototype.removeListener;
|
|
3351
|
+
|
|
3352
|
+
EventEmitter.prototype.removeAllListeners =
|
|
3353
|
+
function removeAllListeners(type) {
|
|
3354
|
+
var listeners, events, i;
|
|
3355
|
+
|
|
3356
|
+
events = this._events;
|
|
3357
|
+
if (events === undefined)
|
|
3358
|
+
return this;
|
|
3359
|
+
|
|
3360
|
+
// not listening for removeListener, no need to emit
|
|
3361
|
+
if (events.removeListener === undefined) {
|
|
3362
|
+
if (arguments.length === 0) {
|
|
3363
|
+
this._events = Object.create(null);
|
|
3364
|
+
this._eventsCount = 0;
|
|
3365
|
+
} else if (events[type] !== undefined) {
|
|
3366
|
+
if (--this._eventsCount === 0)
|
|
3367
|
+
this._events = Object.create(null);
|
|
3368
|
+
else
|
|
3369
|
+
delete events[type];
|
|
3370
|
+
}
|
|
3371
|
+
return this;
|
|
3372
|
+
}
|
|
3373
|
+
|
|
3374
|
+
// emit removeListener for all listeners on all events
|
|
3375
|
+
if (arguments.length === 0) {
|
|
3376
|
+
var keys = Object.keys(events);
|
|
3377
|
+
var key;
|
|
3378
|
+
for (i = 0; i < keys.length; ++i) {
|
|
3379
|
+
key = keys[i];
|
|
3380
|
+
if (key === 'removeListener') continue;
|
|
3381
|
+
this.removeAllListeners(key);
|
|
3382
|
+
}
|
|
3383
|
+
this.removeAllListeners('removeListener');
|
|
3384
|
+
this._events = Object.create(null);
|
|
3385
|
+
this._eventsCount = 0;
|
|
3386
|
+
return this;
|
|
3387
|
+
}
|
|
3388
|
+
|
|
3389
|
+
listeners = events[type];
|
|
3390
|
+
|
|
3391
|
+
if (typeof listeners === 'function') {
|
|
3392
|
+
this.removeListener(type, listeners);
|
|
3393
|
+
} else if (listeners !== undefined) {
|
|
3394
|
+
// LIFO order
|
|
3395
|
+
for (i = listeners.length - 1; i >= 0; i--) {
|
|
3396
|
+
this.removeListener(type, listeners[i]);
|
|
3397
|
+
}
|
|
3398
|
+
}
|
|
3399
|
+
|
|
3400
|
+
return this;
|
|
3401
|
+
};
|
|
3402
|
+
|
|
3403
|
+
function _listeners(target, type, unwrap) {
|
|
3404
|
+
var events = target._events;
|
|
3405
|
+
|
|
3406
|
+
if (events === undefined)
|
|
3407
|
+
return [];
|
|
3408
|
+
|
|
3409
|
+
var evlistener = events[type];
|
|
3410
|
+
if (evlistener === undefined)
|
|
3411
|
+
return [];
|
|
3412
|
+
|
|
3413
|
+
if (typeof evlistener === 'function')
|
|
3414
|
+
return unwrap ? [evlistener.listener || evlistener] : [evlistener];
|
|
3415
|
+
|
|
3416
|
+
return unwrap ?
|
|
3417
|
+
unwrapListeners(evlistener) : arrayClone(evlistener, evlistener.length);
|
|
3418
|
+
}
|
|
3419
|
+
|
|
3420
|
+
EventEmitter.prototype.listeners = function listeners(type) {
|
|
3421
|
+
return _listeners(this, type, true);
|
|
3422
|
+
};
|
|
3423
|
+
|
|
3424
|
+
EventEmitter.prototype.rawListeners = function rawListeners(type) {
|
|
3425
|
+
return _listeners(this, type, false);
|
|
3426
|
+
};
|
|
3427
|
+
|
|
3428
|
+
EventEmitter.listenerCount = function(emitter, type) {
|
|
3429
|
+
if (typeof emitter.listenerCount === 'function') {
|
|
3430
|
+
return emitter.listenerCount(type);
|
|
3431
|
+
} else {
|
|
3432
|
+
return listenerCount.call(emitter, type);
|
|
3433
|
+
}
|
|
3434
|
+
};
|
|
3435
|
+
|
|
3436
|
+
EventEmitter.prototype.listenerCount = listenerCount;
|
|
3437
|
+
function listenerCount(type) {
|
|
3438
|
+
var events = this._events;
|
|
3439
|
+
|
|
3440
|
+
if (events !== undefined) {
|
|
3441
|
+
var evlistener = events[type];
|
|
3442
|
+
|
|
3443
|
+
if (typeof evlistener === 'function') {
|
|
3444
|
+
return 1;
|
|
3445
|
+
} else if (evlistener !== undefined) {
|
|
3446
|
+
return evlistener.length;
|
|
3447
|
+
}
|
|
3448
|
+
}
|
|
3449
|
+
|
|
3450
|
+
return 0;
|
|
3451
|
+
}
|
|
3452
|
+
|
|
3453
|
+
EventEmitter.prototype.eventNames = function eventNames() {
|
|
3454
|
+
return this._eventsCount > 0 ? ReflectOwnKeys(this._events) : [];
|
|
3455
|
+
};
|
|
3456
|
+
|
|
3457
|
+
function arrayClone(arr, n) {
|
|
3458
|
+
var copy = new Array(n);
|
|
3459
|
+
for (var i = 0; i < n; ++i)
|
|
3460
|
+
copy[i] = arr[i];
|
|
3461
|
+
return copy;
|
|
3462
|
+
}
|
|
3463
|
+
|
|
3464
|
+
function spliceOne(list, index) {
|
|
3465
|
+
for (; index + 1 < list.length; index++)
|
|
3466
|
+
list[index] = list[index + 1];
|
|
3467
|
+
list.pop();
|
|
3468
|
+
}
|
|
3469
|
+
|
|
3470
|
+
function unwrapListeners(arr) {
|
|
3471
|
+
var ret = new Array(arr.length);
|
|
3472
|
+
for (var i = 0; i < ret.length; ++i) {
|
|
3473
|
+
ret[i] = arr[i].listener || arr[i];
|
|
3474
|
+
}
|
|
3475
|
+
return ret;
|
|
3476
|
+
}
|
|
3477
|
+
|
|
3478
|
+
function once(emitter, name) {
|
|
3479
|
+
return new Promise(function (resolve, reject) {
|
|
3480
|
+
function errorListener(err) {
|
|
3481
|
+
emitter.removeListener(name, resolver);
|
|
3482
|
+
reject(err);
|
|
3483
|
+
}
|
|
3484
|
+
|
|
3485
|
+
function resolver() {
|
|
3486
|
+
if (typeof emitter.removeListener === 'function') {
|
|
3487
|
+
emitter.removeListener('error', errorListener);
|
|
3488
|
+
}
|
|
3489
|
+
resolve([].slice.call(arguments));
|
|
3490
|
+
};
|
|
3491
|
+
|
|
3492
|
+
eventTargetAgnosticAddListener(emitter, name, resolver, { once: true });
|
|
3493
|
+
if (name !== 'error') {
|
|
3494
|
+
addErrorHandlerIfEventEmitter(emitter, errorListener, { once: true });
|
|
3495
|
+
}
|
|
3496
|
+
});
|
|
3497
|
+
}
|
|
3498
|
+
|
|
3499
|
+
function addErrorHandlerIfEventEmitter(emitter, handler, flags) {
|
|
3500
|
+
if (typeof emitter.on === 'function') {
|
|
3501
|
+
eventTargetAgnosticAddListener(emitter, 'error', handler, flags);
|
|
3502
|
+
}
|
|
3503
|
+
}
|
|
3504
|
+
|
|
3505
|
+
function eventTargetAgnosticAddListener(emitter, name, listener, flags) {
|
|
3506
|
+
if (typeof emitter.on === 'function') {
|
|
3507
|
+
if (flags.once) {
|
|
3508
|
+
emitter.once(name, listener);
|
|
3509
|
+
} else {
|
|
3510
|
+
emitter.on(name, listener);
|
|
3511
|
+
}
|
|
3512
|
+
} else if (typeof emitter.addEventListener === 'function') {
|
|
3513
|
+
// EventTarget does not have `error` event semantics like Node
|
|
3514
|
+
// EventEmitters, we do not listen for `error` events here.
|
|
3515
|
+
emitter.addEventListener(name, function wrapListener(arg) {
|
|
3516
|
+
// IE does not have builtin `{ once: true }` support so we
|
|
3517
|
+
// have to do it manually.
|
|
3518
|
+
if (flags.once) {
|
|
3519
|
+
emitter.removeEventListener(name, wrapListener);
|
|
3520
|
+
}
|
|
3521
|
+
listener(arg);
|
|
3522
|
+
});
|
|
3523
|
+
} else {
|
|
3524
|
+
throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type ' + typeof emitter);
|
|
3525
|
+
}
|
|
3526
|
+
}
|
|
3527
|
+
|
|
3528
|
+
},{}],45:[function(require,module,exports){
|
|
3529
|
+
// shim for using process in browser
|
|
3530
|
+
var process = module.exports = {};
|
|
3531
|
+
|
|
3532
|
+
// cached from whatever global is present so that test runners that stub it
|
|
3533
|
+
// don't break things. But we need to wrap it in a try catch in case it is
|
|
3534
|
+
// wrapped in strict mode code which doesn't define any globals. It's inside a
|
|
3535
|
+
// function because try/catches deoptimize in certain engines.
|
|
3536
|
+
|
|
3537
|
+
var cachedSetTimeout;
|
|
3538
|
+
var cachedClearTimeout;
|
|
3539
|
+
|
|
3540
|
+
function defaultSetTimout() {
|
|
3541
|
+
throw new Error('setTimeout has not been defined');
|
|
3542
|
+
}
|
|
3543
|
+
function defaultClearTimeout () {
|
|
3544
|
+
throw new Error('clearTimeout has not been defined');
|
|
3545
|
+
}
|
|
3546
|
+
(function () {
|
|
3547
|
+
try {
|
|
3548
|
+
if (typeof setTimeout === 'function') {
|
|
3549
|
+
cachedSetTimeout = setTimeout;
|
|
3550
|
+
} else {
|
|
3551
|
+
cachedSetTimeout = defaultSetTimout;
|
|
3552
|
+
}
|
|
3553
|
+
} catch (e) {
|
|
3554
|
+
cachedSetTimeout = defaultSetTimout;
|
|
3555
|
+
}
|
|
3556
|
+
try {
|
|
3557
|
+
if (typeof clearTimeout === 'function') {
|
|
3558
|
+
cachedClearTimeout = clearTimeout;
|
|
3559
|
+
} else {
|
|
3560
|
+
cachedClearTimeout = defaultClearTimeout;
|
|
3561
|
+
}
|
|
3562
|
+
} catch (e) {
|
|
3563
|
+
cachedClearTimeout = defaultClearTimeout;
|
|
3564
|
+
}
|
|
3565
|
+
} ())
|
|
3566
|
+
function runTimeout(fun) {
|
|
3567
|
+
if (cachedSetTimeout === setTimeout) {
|
|
3568
|
+
//normal enviroments in sane situations
|
|
3569
|
+
return setTimeout(fun, 0);
|
|
3570
|
+
}
|
|
3571
|
+
// if setTimeout wasn't available but was latter defined
|
|
3572
|
+
if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
|
|
3573
|
+
cachedSetTimeout = setTimeout;
|
|
3574
|
+
return setTimeout(fun, 0);
|
|
3575
|
+
}
|
|
3576
|
+
try {
|
|
3577
|
+
// when when somebody has screwed with setTimeout but no I.E. maddness
|
|
3578
|
+
return cachedSetTimeout(fun, 0);
|
|
3579
|
+
} catch(e){
|
|
3580
|
+
try {
|
|
3581
|
+
// When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
|
|
3582
|
+
return cachedSetTimeout.call(null, fun, 0);
|
|
3583
|
+
} catch(e){
|
|
3584
|
+
// same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
|
|
3585
|
+
return cachedSetTimeout.call(this, fun, 0);
|
|
3586
|
+
}
|
|
3587
|
+
}
|
|
3588
|
+
|
|
3589
|
+
|
|
3590
|
+
}
|
|
3591
|
+
function runClearTimeout(marker) {
|
|
3592
|
+
if (cachedClearTimeout === clearTimeout) {
|
|
3593
|
+
//normal enviroments in sane situations
|
|
3594
|
+
return clearTimeout(marker);
|
|
3595
|
+
}
|
|
3596
|
+
// if clearTimeout wasn't available but was latter defined
|
|
3597
|
+
if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
|
|
3598
|
+
cachedClearTimeout = clearTimeout;
|
|
3599
|
+
return clearTimeout(marker);
|
|
3600
|
+
}
|
|
3601
|
+
try {
|
|
3602
|
+
// when when somebody has screwed with setTimeout but no I.E. maddness
|
|
3603
|
+
return cachedClearTimeout(marker);
|
|
3604
|
+
} catch (e){
|
|
3605
|
+
try {
|
|
3606
|
+
// When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
|
|
3607
|
+
return cachedClearTimeout.call(null, marker);
|
|
3608
|
+
} catch (e){
|
|
3609
|
+
// same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
|
|
3610
|
+
// Some versions of I.E. have different rules for clearTimeout vs setTimeout
|
|
3611
|
+
return cachedClearTimeout.call(this, marker);
|
|
3612
|
+
}
|
|
3613
|
+
}
|
|
3614
|
+
|
|
3615
|
+
|
|
3616
|
+
|
|
3617
|
+
}
|
|
3618
|
+
var queue = [];
|
|
3619
|
+
var draining = false;
|
|
3620
|
+
var currentQueue;
|
|
3621
|
+
var queueIndex = -1;
|
|
3622
|
+
|
|
3623
|
+
function cleanUpNextTick() {
|
|
3624
|
+
if (!draining || !currentQueue) {
|
|
3625
|
+
return;
|
|
3626
|
+
}
|
|
3627
|
+
draining = false;
|
|
3628
|
+
if (currentQueue.length) {
|
|
3629
|
+
queue = currentQueue.concat(queue);
|
|
3630
|
+
} else {
|
|
3631
|
+
queueIndex = -1;
|
|
3632
|
+
}
|
|
3633
|
+
if (queue.length) {
|
|
3634
|
+
drainQueue();
|
|
3635
|
+
}
|
|
3636
|
+
}
|
|
3637
|
+
|
|
3638
|
+
function drainQueue() {
|
|
3639
|
+
if (draining) {
|
|
3640
|
+
return;
|
|
3641
|
+
}
|
|
3642
|
+
var timeout = runTimeout(cleanUpNextTick);
|
|
3643
|
+
draining = true;
|
|
3644
|
+
|
|
3645
|
+
var len = queue.length;
|
|
3646
|
+
while(len) {
|
|
3647
|
+
currentQueue = queue;
|
|
3648
|
+
queue = [];
|
|
3649
|
+
while (++queueIndex < len) {
|
|
3650
|
+
if (currentQueue) {
|
|
3651
|
+
currentQueue[queueIndex].run();
|
|
3652
|
+
}
|
|
3653
|
+
}
|
|
3654
|
+
queueIndex = -1;
|
|
3655
|
+
len = queue.length;
|
|
3656
|
+
}
|
|
3657
|
+
currentQueue = null;
|
|
3658
|
+
draining = false;
|
|
3659
|
+
runClearTimeout(timeout);
|
|
3660
|
+
}
|
|
3661
|
+
|
|
3662
|
+
process.nextTick = function (fun) {
|
|
3663
|
+
var args = new Array(arguments.length - 1);
|
|
3664
|
+
if (arguments.length > 1) {
|
|
3665
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
3666
|
+
args[i - 1] = arguments[i];
|
|
3667
|
+
}
|
|
3668
|
+
}
|
|
3669
|
+
queue.push(new Item(fun, args));
|
|
3670
|
+
if (queue.length === 1 && !draining) {
|
|
3671
|
+
runTimeout(drainQueue);
|
|
3672
|
+
}
|
|
3673
|
+
};
|
|
3674
|
+
|
|
3675
|
+
// v8 likes predictible objects
|
|
3676
|
+
function Item(fun, array) {
|
|
3677
|
+
this.fun = fun;
|
|
3678
|
+
this.array = array;
|
|
3679
|
+
}
|
|
3680
|
+
Item.prototype.run = function () {
|
|
3681
|
+
this.fun.apply(null, this.array);
|
|
3682
|
+
};
|
|
3683
|
+
process.title = 'browser';
|
|
3684
|
+
process.browser = true;
|
|
3685
|
+
process.env = {};
|
|
3686
|
+
process.argv = [];
|
|
3687
|
+
process.version = ''; // empty string to avoid regexp issues
|
|
3688
|
+
process.versions = {};
|
|
3689
|
+
|
|
3690
|
+
function noop() {}
|
|
3691
|
+
|
|
3692
|
+
process.on = noop;
|
|
3693
|
+
process.addListener = noop;
|
|
3694
|
+
process.once = noop;
|
|
3695
|
+
process.off = noop;
|
|
3696
|
+
process.removeListener = noop;
|
|
3697
|
+
process.removeAllListeners = noop;
|
|
3698
|
+
process.emit = noop;
|
|
3699
|
+
process.prependListener = noop;
|
|
3700
|
+
process.prependOnceListener = noop;
|
|
3701
|
+
|
|
3702
|
+
process.listeners = function (name) { return [] }
|
|
3703
|
+
|
|
3704
|
+
process.binding = function (name) {
|
|
3705
|
+
throw new Error('process.binding is not supported');
|
|
3706
|
+
};
|
|
3707
|
+
|
|
3708
|
+
process.cwd = function () { return '/' };
|
|
3709
|
+
process.chdir = function (dir) {
|
|
3710
|
+
throw new Error('process.chdir is not supported');
|
|
3711
|
+
};
|
|
3712
|
+
process.umask = function() { return 0; };
|
|
3713
|
+
|
|
3714
|
+
},{}],46:[function(require,module,exports){
|
|
3715
|
+
"use strict";
|
|
3716
|
+
|
|
3717
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3718
|
+
value: true
|
|
3719
|
+
});
|
|
3720
|
+
exports.uid = uid;
|
|
3721
|
+
var IDX = 256,
|
|
3722
|
+
HEX = [],
|
|
3723
|
+
SIZE = 256,
|
|
3724
|
+
BUFFER;
|
|
3725
|
+
while (IDX--) HEX[IDX] = (IDX + 256).toString(16).substring(1);
|
|
3726
|
+
function uid(len) {
|
|
3727
|
+
var i = 0,
|
|
3728
|
+
tmp = len || 11;
|
|
3729
|
+
if (!BUFFER || IDX + tmp > SIZE * 2) {
|
|
3730
|
+
for (BUFFER = '', IDX = 0; i < SIZE; i++) {
|
|
3731
|
+
BUFFER += HEX[Math.random() * 256 | 0];
|
|
3732
|
+
}
|
|
3733
|
+
}
|
|
3734
|
+
return BUFFER.substring(IDX, IDX++ + tmp);
|
|
3735
|
+
}
|
|
3736
|
+
|
|
3737
|
+
},{}]},{},[4])(4)
|
|
3738
|
+
});
|