UNPKG

azampay

Version:

Azampay NodeJs SDK to help you interact with Azampay API

1,618 lines (1,387 loc) 369 kB
/******/ (() => { // webpackBootstrap /******/ var __webpack_modules__ = ({ /***/ 822: /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { "use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; Object.defineProperty(exports, "__esModule", ({ value: true })); const azampay = __importStar(__nccwpck_require__(957)); exports["default"] = azampay; /***/ }), /***/ 278: /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { "use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; var _a; Object.defineProperty(exports, "__esModule", ({ value: true })); exports.AzamPay = void 0; const axios_1 = __importDefault(__nccwpck_require__(757)); const https = __importStar(__nccwpck_require__(687)); const azampay_enum_1 = __nccwpck_require__(54); const error_helper_1 = __nccwpck_require__(901); https.globalAgent.options.rejectUnauthorized = false; /** * @class Azam Pay request instance. */ class AzamPay { constructor(instance) { this.instance = instance; this.headers = { 'Content-Type': 'application/json', }; /** * @method bankCheckout * @param payload BankCheckout Bank checkout and make payment to requested provider. * @param options Request options for any additional options or independent request methods. * @returns CheckoutResponse or ErrorResponse */ this.bankCheckout = (payload, options) => __awaiter(this, void 0, void 0, function* () { return yield this.getBankCheckout(payload, options); }); /** * @method mnoCheckout * @param payload BankCheckout Bank checkout and make payment to requested provider. * @param options Request options for any additional options or independent request methods. * @returns CheckoutResponse or ErrorResponse */ this.mnoCheckout = (payload, options) => __awaiter(this, void 0, void 0, function* () { return yield this.getMnoCheckout(payload, options); }); /** * @method postCheckout * @param payload Post checkout payload. * @param options Request options for any additional options or independent request methods. * @returns string or ErrorResponse */ this.postCheckout = (payload, options) => __awaiter(this, void 0, void 0, function* () { return yield this.getPostCheckout(payload, options); }); /** * @method disburse * @param payload Disburse payload. * @param options Request options for any additional options or independent request methods. * @returns DisburseResponse or ErrorResponse */ this.disburse = (payload, options) => __awaiter(this, void 0, void 0, function* () { return this.getDisbursement(payload, options); }); /** * @method partners. A method used to retrieve payment partners from Azam Pay * @returns PartnersResponse */ this.partners = (options) => __awaiter(this, void 0, void 0, function* () { return yield this.getPartners(options); }); /** * @method nameLookup This API is used to lookup the name associated with a bank account or Mobile Money account. * @param payload NameLookup payload. * @param options Request options for any additional options or independent request methods. * @returns NameLookupResponse or ErrorResponse */ this.nameLookup = (payload, options) => __awaiter(this, void 0, void 0, function* () { return yield this.getNameLookup(payload, options); }); /** * @method disburse This method allows for the transfer of money from other countries to Tanzania. It requires the authorization token generated above, passed as a header in the request. The request should also contain details of the source, destination, and transfer details. Additionally, the request can include an external reference ID and remarks. * @param payload Disburse payload. * @param options Request options for any additional options or independent request methods. * @returns DisburseResponse or ErrorResponse */ this.transactionStatus = (payload, options) => __awaiter(this, void 0, void 0, function* () { return yield this.getStatus(payload, options); }); this.getStatus = (payload, options) => __awaiter(this, void 0, void 0, function* () { var _b, _c, _d, _e, _f, _g; try { const { data } = yield axios_1.default.get(`${azampay_enum_1.CHECKOUT[(_d = (_c = (_b = this.instance) === null || _b === void 0 ? void 0 : _b.env) !== null && _c !== void 0 ? _c : options === null || options === void 0 ? void 0 : options.env) !== null && _d !== void 0 ? _d : 'SANDBOX']}/azampay/gettransactionstatus?pgReferenceId=${payload.reference}&bankName=${payload.bankName}`, { headers: Object.assign(Object.assign({}, this.headers), { Authorization: `Bearer ${(_g = (_f = (_e = this.instance) === null || _e === void 0 ? void 0 : _e.accessToken) !== null && _f !== void 0 ? _f : options === null || options === void 0 ? void 0 : options.accessToken) !== null && _g !== void 0 ? _g : ''}` }), }); return Object.assign(Object.assign({}, data), { success: true, statusCode: 200 }); } catch (e) { return (0, error_helper_1.sanitizeErrorResponse)(e); } }); this.getPartners = (options) => __awaiter(this, void 0, void 0, function* () { var _h, _j, _k, _l, _m, _o; try { const { data } = yield axios_1.default.get(`${azampay_enum_1.CHECKOUT[(_k = (_j = (_h = this.instance) === null || _h === void 0 ? void 0 : _h.env) !== null && _j !== void 0 ? _j : options === null || options === void 0 ? void 0 : options.env) !== null && _k !== void 0 ? _k : 'SANDBOX']}/api/v1/Partner/GetPaymentPartners`, { headers: Object.assign(Object.assign({}, this.headers), { Authorization: `Bearer ${(_o = (_m = (_l = this.instance) === null || _l === void 0 ? void 0 : _l.accessToken) !== null && _m !== void 0 ? _m : options === null || options === void 0 ? void 0 : options.accessToken) !== null && _o !== void 0 ? _o : ''}` }), }); return { partners: data, success: true, statusCode: 200, }; } catch (e) { return (0, error_helper_1.sanitizeErrorResponse)(e); } }); this.getNameLookup = (payload, options) => __awaiter(this, void 0, void 0, function* () { var _p, _q, _r, _s, _t, _u; try { const { data } = yield axios_1.default.post(`${azampay_enum_1.CHECKOUT[(_r = (_q = (_p = this.instance) === null || _p === void 0 ? void 0 : _p.env) !== null && _q !== void 0 ? _q : options === null || options === void 0 ? void 0 : options.env) !== null && _r !== void 0 ? _r : 'SANDBOX']}/azampay/namelookup`, payload, { headers: Object.assign(Object.assign({}, this.headers), { Authorization: `Bearer ${(_u = (_t = (_s = this.instance) === null || _s === void 0 ? void 0 : _s.accessToken) !== null && _t !== void 0 ? _t : options === null || options === void 0 ? void 0 : options.accessToken) !== null && _u !== void 0 ? _u : ''}` }), }); return Object.assign(Object.assign({}, data), { success: true, statusCode: 200 }); } catch (e) { return (0, error_helper_1.sanitizeErrorResponse)(e); } }); this.getDisbursement = (payload, options) => __awaiter(this, void 0, void 0, function* () { var _v, _w, _x, _y, _z, _0; try { const { data } = yield axios_1.default.post(`${azampay_enum_1.CHECKOUT[(_x = (_w = (_v = this.instance) === null || _v === void 0 ? void 0 : _v.env) !== null && _w !== void 0 ? _w : options === null || options === void 0 ? void 0 : options.env) !== null && _x !== void 0 ? _x : 'SANDBOX']}/azampay/createtransfer`, payload, { headers: Object.assign(Object.assign({}, this.headers), { Authorization: `Bearer ${(_0 = (_z = (_y = this.instance) === null || _y === void 0 ? void 0 : _y.accessToken) !== null && _z !== void 0 ? _z : options === null || options === void 0 ? void 0 : options.accessToken) !== null && _0 !== void 0 ? _0 : ''}` }), }); return Object.assign(Object.assign({}, data), { success: true, statusCode: 200 }); } catch (e) { return (0, error_helper_1.sanitizeErrorResponse)(e); } }); this.getBankCheckout = (payload, options) => __awaiter(this, void 0, void 0, function* () { var _1, _2, _3, _4, _5, _6, _7, _8; try { const { data } = yield axios_1.default.post(`${azampay_enum_1.CHECKOUT[(_3 = (_2 = (_1 = this.instance) === null || _1 === void 0 ? void 0 : _1.env) !== null && _2 !== void 0 ? _2 : options === null || options === void 0 ? void 0 : options.env) !== null && _3 !== void 0 ? _3 : 'SANDBOX']}/azampay/bank/checkout`, payload, { headers: Object.assign(Object.assign({}, this.headers), { Authorization: `Bearer ${(_6 = (_5 = (_4 = this.instance) === null || _4 === void 0 ? void 0 : _4.accessToken) !== null && _5 !== void 0 ? _5 : options === null || options === void 0 ? void 0 : options.accessToken) !== null && _6 !== void 0 ? _6 : ''}`, 'X-API-Key': (_8 = (_7 = this.instance) === null || _7 === void 0 ? void 0 : _7.apiKey) !== null && _8 !== void 0 ? _8 : options === null || options === void 0 ? void 0 : options.apiKey }), }); return Object.assign(Object.assign({}, data), { success: true, statusCode: 200 }); } catch (e) { return (0, error_helper_1.sanitizeErrorResponse)(e); } }); this.getMnoCheckout = (payload, options) => __awaiter(this, void 0, void 0, function* () { var _9, _10, _11, _12, _13, _14, _15, _16; try { const { data } = yield axios_1.default.post(`${azampay_enum_1.CHECKOUT[(_11 = (_10 = (_9 = this.instance) === null || _9 === void 0 ? void 0 : _9.env) !== null && _10 !== void 0 ? _10 : options === null || options === void 0 ? void 0 : options.env) !== null && _11 !== void 0 ? _11 : 'SANDBOX']}/azampay/mno/checkout`, payload, { headers: Object.assign(Object.assign({}, this.headers), { Authorization: `Bearer ${(_14 = (_13 = (_12 = this.instance) === null || _12 === void 0 ? void 0 : _12.accessToken) !== null && _13 !== void 0 ? _13 : options === null || options === void 0 ? void 0 : options.accessToken) !== null && _14 !== void 0 ? _14 : ''}`, 'X-API-Key': (_16 = (_15 = this.instance) === null || _15 === void 0 ? void 0 : _15.apiKey) !== null && _16 !== void 0 ? _16 : options === null || options === void 0 ? void 0 : options.apiKey }), }); return Object.assign(Object.assign({}, data), { success: true, statusCode: 200 }); } catch (e) { return (0, error_helper_1.sanitizeErrorResponse)(e); } }); this.getPostCheckout = (payload, options) => __awaiter(this, void 0, void 0, function* () { var _17, _18, _19; try { const { data } = yield axios_1.default.post(`${azampay_enum_1.CHECKOUT[(_19 = (_18 = (_17 = this.instance) === null || _17 === void 0 ? void 0 : _17.env) !== null && _18 !== void 0 ? _18 : options === null || options === void 0 ? void 0 : options.env) !== null && _19 !== void 0 ? _19 : 'SANDBOX']}/api/v1/Partner/PostCheckout`, payload); return { data, success: true, statusCode: 200 }; } catch (e) { return (0, error_helper_1.sanitizeErrorResponse)(e); } }); } } exports.AzamPay = AzamPay; _a = AzamPay; /** * @method getToken A static method for getting token * @param payload Azam Pay request payload * @returns Access Token and Expiry time */ AzamPay.getToken = (payload) => __awaiter(void 0, void 0, void 0, function* () { var _b; try { const { data } = yield axios_1.default.post(`${azampay_enum_1.AUTHENTICATOR[(_b = payload.env) !== null && _b !== void 0 ? _b : 'SANDBOX']}/AppRegistration/GenerateToken`, { appName: payload.appName, clientId: payload.clientId, clientSecret: payload.clientSecret, }); return Object.assign(Object.assign({}, data), { success: true, statusCode: 200 }); } catch (e) { return (0, error_helper_1.sanitizeErrorResponse)(e); } }); /***/ }), /***/ 957: /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { "use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", ({ value: true })); exports.instance = exports.getToken = void 0; const azampay_1 = __nccwpck_require__(278); /** * @method getToken. Token request method * @param payload * @returns TokenResponse */ const getToken = (payload) => __awaiter(void 0, void 0, void 0, function* () { var _a; const token = yield azampay_1.AzamPay.getToken(payload); if (token.success) { const azamPay = new azampay_1.AzamPay({ accessToken: (_a = token.data) === null || _a === void 0 ? void 0 : _a.accessToken, apiKey: payload === null || payload === void 0 ? void 0 : payload.apiKey, env: payload.env, }); return Object.assign(Object.assign({}, token), { bankCheckout: azamPay.bankCheckout, mnoCheckout: azamPay.mnoCheckout, postCheckout: azamPay.postCheckout, disburse: azamPay.disburse, transactionStatus: azamPay.transactionStatus, nameLookup: azamPay.nameLookup, partners: azamPay.partners }); } return token; }); exports.getToken = getToken; /** * @class Azam Pay request instance. */ exports.instance = azampay_1.AzamPay; /***/ }), /***/ 54: /***/ ((__unused_webpack_module, exports) => { "use strict"; Object.defineProperty(exports, "__esModule", ({ value: true })); exports.REQUESTMETHODS = exports.CHECKOUT = exports.AUTHENTICATOR = void 0; var AUTHENTICATOR; (function (AUTHENTICATOR) { AUTHENTICATOR["SANDBOX"] = "https://authenticator-sandbox.azampay.co.tz"; AUTHENTICATOR["LIVE"] = "https://authenticator.azampay.co.tz"; })(AUTHENTICATOR = exports.AUTHENTICATOR || (exports.AUTHENTICATOR = {})); var CHECKOUT; (function (CHECKOUT) { CHECKOUT["SANDBOX"] = "https://sandbox.azampay.co.tz"; CHECKOUT["LIVE"] = "https://checkout.azampay.co.tz"; })(CHECKOUT = exports.CHECKOUT || (exports.CHECKOUT = {})); var REQUESTMETHODS; (function (REQUESTMETHODS) { REQUESTMETHODS["PUT"] = "PUT"; REQUESTMETHODS["POST"] = "POST"; REQUESTMETHODS["GET"] = "GET"; REQUESTMETHODS["PATCH"] = "PATCH"; REQUESTMETHODS["DELETE"] = "DELETE"; })(REQUESTMETHODS = exports.REQUESTMETHODS || (exports.REQUESTMETHODS = {})); /***/ }), /***/ 901: /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { "use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", ({ value: true })); exports.sanitizeErrorResponse = exports.ErrorMessage = void 0; const axios_1 = __importDefault(__nccwpck_require__(757)); const ErrorMessage = (errors) => { if (typeof errors === 'object') { return Object.keys(errors) .map(key => { if (errors[key] && Array.isArray(errors[key])) { return errors[key]; } if (typeof errors[key] === 'object') { return Object.keys(errors[key]) .map(key => (0, exports.ErrorMessage)(errors[key])) .join(', '); } return errors[key]; }) .join(', '); } return errors; }; exports.ErrorMessage = ErrorMessage; const sanitizedAxiosError = (error, serverError) => { var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x; if (serverError === null || serverError === void 0 ? void 0 : serverError.response) { return Object.assign(Object.assign({}, (_a = serverError === null || serverError === void 0 ? void 0 : serverError.response) === null || _a === void 0 ? void 0 : _a.data), { message: (0, exports.ErrorMessage)((_d = (_c = (_b = serverError === null || serverError === void 0 ? void 0 : serverError.response) === null || _b === void 0 ? void 0 : _b.data) === null || _c === void 0 ? void 0 : _c.errors) !== null && _d !== void 0 ? _d : [ (_j = (_g = (_f = (_e = serverError === null || serverError === void 0 ? void 0 : serverError.response) === null || _e === void 0 ? void 0 : _e.data) === null || _f === void 0 ? void 0 : _f.message) !== null && _g !== void 0 ? _g : (_h = serverError === null || serverError === void 0 ? void 0 : serverError.response) === null || _h === void 0 ? void 0 : _h.statusText) !== null && _j !== void 0 ? _j : error.message, ]), error: (_p = (_m = (_l = (_k = serverError === null || serverError === void 0 ? void 0 : serverError.response) === null || _k === void 0 ? void 0 : _k.data) === null || _l === void 0 ? void 0 : _l.message) !== null && _m !== void 0 ? _m : (_o = serverError === null || serverError === void 0 ? void 0 : serverError.response) === null || _o === void 0 ? void 0 : _o.statusText) !== null && _p !== void 0 ? _p : error.message, code: (serverError === null || serverError === void 0 ? void 0 : serverError.code) || 'FAILED', statusCode: ((_q = serverError === null || serverError === void 0 ? void 0 : serverError.response) === null || _q === void 0 ? void 0 : _q.status) || 400, success: false, mnoCheckout: undefined, data: undefined, bankCheckout: undefined }); } return Object.assign(Object.assign({}, error), { success: false, message: (_t = (_r = serverError === null || serverError === void 0 ? void 0 : serverError.message) !== null && _r !== void 0 ? _r : (_s = error.response) === null || _s === void 0 ? void 0 : _s.statusText) !== null && _t !== void 0 ? _t : error === null || error === void 0 ? void 0 : error.message, error: (_v = (_u = error.response) === null || _u === void 0 ? void 0 : _u.statusText) !== null && _v !== void 0 ? _v : error === null || error === void 0 ? void 0 : error.message, statusCode: (_x = (_w = error.response) === null || _w === void 0 ? void 0 : _w.status) !== null && _x !== void 0 ? _x : 400, code: (serverError === null || serverError === void 0 ? void 0 : serverError.code) || 'FAILED', mnoCheckout: Function, data: null, bankCheckout: null }); }; const sanitizeErrorResponse = (error) => { var _a, _b, _c, _d, _e, _f; const serverError = error; if (axios_1.default.isAxiosError(error)) { return sanitizedAxiosError(error, serverError); } return { success: false, message: (_c = (_b = (_a = serverError === null || serverError === void 0 ? void 0 : serverError.response) === null || _a === void 0 ? void 0 : _a.statusText) !== null && _b !== void 0 ? _b : serverError === null || serverError === void 0 ? void 0 : serverError.message) !== null && _c !== void 0 ? _c : 'Internal server error', error: (_f = (_e = (_d = serverError === null || serverError === void 0 ? void 0 : serverError.response) === null || _d === void 0 ? void 0 : _d.statusText) !== null && _e !== void 0 ? _e : serverError === null || serverError === void 0 ? void 0 : serverError.message) !== null && _f !== void 0 ? _f : 'Internal server error', statusCode: 400, code: 'FAILED', mnoCheckout: undefined, data: undefined, bankCheckout: undefined, }; }; exports.sanitizeErrorResponse = sanitizeErrorResponse; /***/ }), /***/ 812: /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { module.exports = { parallel : __nccwpck_require__(210), serial : __nccwpck_require__(445), serialOrdered : __nccwpck_require__(578) }; /***/ }), /***/ 700: /***/ ((module) => { // API module.exports = abort; /** * Aborts leftover active jobs * * @param {object} state - current state object */ function abort(state) { Object.keys(state.jobs).forEach(clean.bind(state)); // reset leftover jobs state.jobs = {}; } /** * Cleans up leftover job by invoking abort function for the provided job id * * @this state * @param {string|number} key - job id to abort */ function clean(key) { if (typeof this.jobs[key] == 'function') { this.jobs[key](); } } /***/ }), /***/ 794: /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { var defer = __nccwpck_require__(295); // API module.exports = async; /** * Runs provided callback asynchronously * even if callback itself is not * * @param {function} callback - callback to invoke * @returns {function} - augmented callback */ function async(callback) { var isAsync = false; // check if async happened defer(function() { isAsync = true; }); return function async_callback(err, result) { if (isAsync) { callback(err, result); } else { defer(function nextTick_callback() { callback(err, result); }); } }; } /***/ }), /***/ 295: /***/ ((module) => { module.exports = defer; /** * Runs provided function on next iteration of the event loop * * @param {function} fn - function to run */ function defer(fn) { var nextTick = typeof setImmediate == 'function' ? setImmediate : ( typeof process == 'object' && typeof process.nextTick == 'function' ? process.nextTick : null ); if (nextTick) { nextTick(fn); } else { setTimeout(fn, 0); } } /***/ }), /***/ 23: /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { var async = __nccwpck_require__(794) , abort = __nccwpck_require__(700) ; // API module.exports = iterate; /** * Iterates over each job object * * @param {array|object} list - array or object (named list) to iterate over * @param {function} iterator - iterator to run * @param {object} state - current job status * @param {function} callback - invoked when all elements processed */ function iterate(list, iterator, state, callback) { // store current index var key = state['keyedList'] ? state['keyedList'][state.index] : state.index; state.jobs[key] = runJob(iterator, key, list[key], function(error, output) { // don't repeat yourself // skip secondary callbacks if (!(key in state.jobs)) { return; } // clean up jobs delete state.jobs[key]; if (error) { // don't process rest of the results // stop still active jobs // and reset the list abort(state); } else { state.results[key] = output; } // return salvaged results callback(error, state.results); }); } /** * Runs iterator over provided job element * * @param {function} iterator - iterator to invoke * @param {string|number} key - key/index of the element in the list of jobs * @param {mixed} item - job description * @param {function} callback - invoked after iterator is done with the job * @returns {function|mixed} - job abort function or something else */ function runJob(iterator, key, item, callback) { var aborter; // allow shortcut if iterator expects only two arguments if (iterator.length == 2) { aborter = iterator(item, async(callback)); } // otherwise go with full three arguments else { aborter = iterator(item, key, async(callback)); } return aborter; } /***/ }), /***/ 474: /***/ ((module) => { // API module.exports = state; /** * Creates initial state object * for iteration over list * * @param {array|object} list - list to iterate over * @param {function|null} sortMethod - function to use for keys sort, * or `null` to keep them as is * @returns {object} - initial state object */ function state(list, sortMethod) { var isNamedList = !Array.isArray(list) , initState = { index : 0, keyedList: isNamedList || sortMethod ? Object.keys(list) : null, jobs : {}, results : isNamedList ? {} : [], size : isNamedList ? Object.keys(list).length : list.length } ; if (sortMethod) { // sort array keys based on it's values // sort object's keys just on own merit initState.keyedList.sort(isNamedList ? sortMethod : function(a, b) { return sortMethod(list[a], list[b]); }); } return initState; } /***/ }), /***/ 942: /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { var abort = __nccwpck_require__(700) , async = __nccwpck_require__(794) ; // API module.exports = terminator; /** * Terminates jobs in the attached state context * * @this AsyncKitState# * @param {function} callback - final callback to invoke after termination */ function terminator(callback) { if (!Object.keys(this.jobs).length) { return; } // fast forward iteration index this.index = this.size; // abort jobs abort(this); // send back results we have so far async(callback)(null, this.results); } /***/ }), /***/ 210: /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { var iterate = __nccwpck_require__(23) , initState = __nccwpck_require__(474) , terminator = __nccwpck_require__(942) ; // Public API module.exports = parallel; /** * Runs iterator over provided array elements in parallel * * @param {array|object} list - array or object (named list) to iterate over * @param {function} iterator - iterator to run * @param {function} callback - invoked when all elements processed * @returns {function} - jobs terminator */ function parallel(list, iterator, callback) { var state = initState(list); while (state.index < (state['keyedList'] || list).length) { iterate(list, iterator, state, function(error, result) { if (error) { callback(error, result); return; } // looks like it's the last one if (Object.keys(state.jobs).length === 0) { callback(null, state.results); return; } }); state.index++; } return terminator.bind(state, callback); } /***/ }), /***/ 445: /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { var serialOrdered = __nccwpck_require__(578); // Public API module.exports = serial; /** * Runs iterator over provided array elements in series * * @param {array|object} list - array or object (named list) to iterate over * @param {function} iterator - iterator to run * @param {function} callback - invoked when all elements processed * @returns {function} - jobs terminator */ function serial(list, iterator, callback) { return serialOrdered(list, iterator, null, callback); } /***/ }), /***/ 578: /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { var iterate = __nccwpck_require__(23) , initState = __nccwpck_require__(474) , terminator = __nccwpck_require__(942) ; // Public API module.exports = serialOrdered; // sorting helpers module.exports.ascending = ascending; module.exports.descending = descending; /** * Runs iterator over provided sorted array elements in series * * @param {array|object} list - array or object (named list) to iterate over * @param {function} iterator - iterator to run * @param {function} sortMethod - custom sort function * @param {function} callback - invoked when all elements processed * @returns {function} - jobs terminator */ function serialOrdered(list, iterator, sortMethod, callback) { var state = initState(list, sortMethod); iterate(list, iterator, state, function iteratorHandler(error, result) { if (error) { callback(error, result); return; } state.index++; // are we there yet? if (state.index < (state['keyedList'] || list).length) { iterate(list, iterator, state, iteratorHandler); return; } // done here callback(null, state.results); }); return terminator.bind(state, callback); } /* * -- Sort methods */ /** * sort helper to sort array elements in ascending order * * @param {mixed} a - an item to compare * @param {mixed} b - an item to compare * @returns {number} - comparison result */ function ascending(a, b) { return a < b ? -1 : a > b ? 1 : 0; } /** * sort helper to sort array elements in descending order * * @param {mixed} a - an item to compare * @param {mixed} b - an item to compare * @returns {number} - comparison result */ function descending(a, b) { return -1 * ascending(a, b); } /***/ }), /***/ 443: /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { var util = __nccwpck_require__(837); var Stream = (__nccwpck_require__(781).Stream); var DelayedStream = __nccwpck_require__(611); module.exports = CombinedStream; function CombinedStream() { this.writable = false; this.readable = true; this.dataSize = 0; this.maxDataSize = 2 * 1024 * 1024; this.pauseStreams = true; this._released = false; this._streams = []; this._currentStream = null; this._insideLoop = false; this._pendingNext = false; } util.inherits(CombinedStream, Stream); CombinedStream.create = function(options) { var combinedStream = new this(); options = options || {}; for (var option in options) { combinedStream[option] = options[option]; } return combinedStream; }; CombinedStream.isStreamLike = function(stream) { return (typeof stream !== 'function') && (typeof stream !== 'string') && (typeof stream !== 'boolean') && (typeof stream !== 'number') && (!Buffer.isBuffer(stream)); }; CombinedStream.prototype.append = function(stream) { var isStreamLike = CombinedStream.isStreamLike(stream); if (isStreamLike) { if (!(stream instanceof DelayedStream)) { var newStream = DelayedStream.create(stream, { maxDataSize: Infinity, pauseStream: this.pauseStreams, }); stream.on('data', this._checkDataSize.bind(this)); stream = newStream; } this._handleErrors(stream); if (this.pauseStreams) { stream.pause(); } } this._streams.push(stream); return this; }; CombinedStream.prototype.pipe = function(dest, options) { Stream.prototype.pipe.call(this, dest, options); this.resume(); return dest; }; CombinedStream.prototype._getNext = function() { this._currentStream = null; if (this._insideLoop) { this._pendingNext = true; return; // defer call } this._insideLoop = true; try { do { this._pendingNext = false; this._realGetNext(); } while (this._pendingNext); } finally { this._insideLoop = false; } }; CombinedStream.prototype._realGetNext = function() { var stream = this._streams.shift(); if (typeof stream == 'undefined') { this.end(); return; } if (typeof stream !== 'function') { this._pipeNext(stream); return; } var getStream = stream; getStream(function(stream) { var isStreamLike = CombinedStream.isStreamLike(stream); if (isStreamLike) { stream.on('data', this._checkDataSize.bind(this)); this._handleErrors(stream); } this._pipeNext(stream); }.bind(this)); }; CombinedStream.prototype._pipeNext = function(stream) { this._currentStream = stream; var isStreamLike = CombinedStream.isStreamLike(stream); if (isStreamLike) { stream.on('end', this._getNext.bind(this)); stream.pipe(this, {end: false}); return; } var value = stream; this.write(value); this._getNext(); }; CombinedStream.prototype._handleErrors = function(stream) { var self = this; stream.on('error', function(err) { self._emitError(err); }); }; CombinedStream.prototype.write = function(data) { this.emit('data', data); }; CombinedStream.prototype.pause = function() { if (!this.pauseStreams) { return; } if(this.pauseStreams && this._currentStream && typeof(this._currentStream.pause) == 'function') this._currentStream.pause(); this.emit('pause'); }; CombinedStream.prototype.resume = function() { if (!this._released) { this._released = true; this.writable = true; this._getNext(); } if(this.pauseStreams && this._currentStream && typeof(this._currentStream.resume) == 'function') this._currentStream.resume(); this.emit('resume'); }; CombinedStream.prototype.end = function() { this._reset(); this.emit('end'); }; CombinedStream.prototype.destroy = function() { this._reset(); this.emit('close'); }; CombinedStream.prototype._reset = function() { this.writable = false; this._streams = []; this._currentStream = null; }; CombinedStream.prototype._checkDataSize = function() { this._updateDataSize(); if (this.dataSize <= this.maxDataSize) { return; } var message = 'DelayedStream#maxDataSize of ' + this.maxDataSize + ' bytes exceeded.'; this._emitError(new Error(message)); }; CombinedStream.prototype._updateDataSize = function() { this.dataSize = 0; var self = this; this._streams.forEach(function(stream) { if (!stream.dataSize) { return; } self.dataSize += stream.dataSize; }); if (this._currentStream && this._currentStream.dataSize) { this.dataSize += this._currentStream.dataSize; } }; CombinedStream.prototype._emitError = function(err) { this._reset(); this.emit('error', err); }; /***/ }), /***/ 222: /***/ ((module, exports, __nccwpck_require__) => { /* eslint-env browser */ /** * This is the web browser implementation of `debug()`. */ exports.formatArgs = formatArgs; exports.save = save; exports.load = load; exports.useColors = useColors; exports.storage = localstorage(); exports.destroy = (() => { let warned = false; return () => { if (!warned) { warned = true; console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.'); } }; })(); /** * Colors. */ exports.colors = [ '#0000CC', '#0000FF', '#0033CC', '#0033FF', '#0066CC', '#0066FF', '#0099CC', '#0099FF', '#00CC00', '#00CC33', '#00CC66', '#00CC99', '#00CCCC', '#00CCFF', '#3300CC', '#3300FF', '#3333CC', '#3333FF', '#3366CC', '#3366FF', '#3399CC', '#3399FF', '#33CC00', '#33CC33', '#33CC66', '#33CC99', '#33CCCC', '#33CCFF', '#6600CC', '#6600FF', '#6633CC', '#6633FF', '#66CC00', '#66CC33', '#9900CC', '#9900FF', '#9933CC', '#9933FF', '#99CC00', '#99CC33', '#CC0000', '#CC0033', '#CC0066', '#CC0099', '#CC00CC', '#CC00FF', '#CC3300', '#CC3333', '#CC3366', '#CC3399', '#CC33CC', '#CC33FF', '#CC6600', '#CC6633', '#CC9900', '#CC9933', '#CCCC00', '#CCCC33', '#FF0000', '#FF0033', '#FF0066', '#FF0099', '#FF00CC', '#FF00FF', '#FF3300', '#FF3333', '#FF3366', '#FF3399', '#FF33CC', '#FF33FF', '#FF6600', '#FF6633', '#FF9900', '#FF9933', '#FFCC00', '#FFCC33' ]; /** * Currently only WebKit-based Web Inspectors, Firefox >= v31, * and the Firebug extension (any Firefox version) are known * to support "%c" CSS customizations. * * TODO: add a `localStorage` variable to explicitly enable/disable colors */ // eslint-disable-next-line complexity function useColors() { // NB: In an Electron preload script, document will be defined but not fully // initialized. Since we know we're in Chrome, we'll just detect this case // explicitly if (typeof window !== 'undefined' && window.process && (window.process.type === 'renderer' || window.process.__nwjs)) { return true; } // Internet Explorer and Edge do not support colors. if (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) { return false; } // Is webkit? http://stackoverflow.com/a/16459606/376773 // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632 return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) || // Is firebug? http://stackoverflow.com/a/398120/376773 (typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) || // Is firefox >= v31? // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31) || // Double check webkit in userAgent just in case we are in a worker (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)); } /** * Colorize log arguments if enabled. * * @api public */ function formatArgs(args) { args[0] = (this.useColors ? '%c' : '') + this.namespace + (this.useColors ? ' %c' : ' ') + args[0] + (this.useColors ? '%c ' : ' ') + '+' + module.exports.humanize(this.diff); if (!this.useColors) { return; } const c = 'color: ' + this.color; args.splice(1, 0, c, 'color: inherit'); // The final "%c" is somewhat tricky, because there could be other // arguments passed either before or after the %c, so we need to // figure out the correct index to insert the CSS into let index = 0; let lastC = 0; args[0].replace(/%[a-zA-Z%]/g, match => { if (match === '%%') { return; } index++; if (match === '%c') { // We only are interested in the *last* %c // (the user may have provided their own) lastC = index; } }); args.splice(lastC, 0, c); } /** * Invokes `console.debug()` when available. * No-op when `console.debug` is not a "function". * If `console.debug` is not available, falls back * to `console.log`. * * @api public */ exports.log = console.debug || console.log || (() => {}); /** * Save `namespaces`. * * @param {String} namespaces * @api private */ function save(namespaces) { try { if (namespaces) { exports.storage.setItem('debug', namespaces); } else { exports.storage.removeItem('debug'); } } catch (error) { // Swallow // XXX (@Qix-) should we be logging these? } } /** * Load `namespaces`. * * @return {String} returns the previously persisted debug modes * @api private */ function load() { let r; try { r = exports.storage.getItem('debug'); } catch (error) { // Swallow // XXX (@Qix-) should we be logging these? } // If debug isn't set in LS, and we're in Electron, try to load $DEBUG if (!r && typeof process !== 'undefined' && 'env' in process) { r = process.env.DEBUG; } return r; } /** * Localstorage attempts to return the localstorage. * * This is necessary because safari throws * when a user disables cookies/localstorage * and you attempt to access it. * * @return {LocalStorage} * @api private */ function localstorage() { try { // TVMLKit (Apple TV JS Runtime) does not have a window object, just localStorage in the global context // The Browser also has localStorage in the global context. return localStorage; } catch (error) { // Swallow // XXX (@Qix-) should we be logging these? } } module.exports = __nccwpck_require__(243)(exports); const {formatters} = module.exports; /** * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default. */ formatters.j = function (v) { try { return JSON.stringify(v); } catch (error) { return '[UnexpectedJSONParseError]: ' + error.message; } }; /***/ }), /***/ 243: /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { /** * This is the common logic for both the Node.js and web browser * implementations of `debug()`. */ function setup(env) { createDebug.debug = createDebug; createDebug.default = createDebug; createDebug.coerce = coerce; createDebug.disable = disable; createDebug.enable = enable; createDebug.enabled = enabled; createDebug.humanize = __nccwpck_require__(900); createDebug.destroy = destroy; Object.keys(env).forEach(key => { createDebug[key] = env[key]; }); /** * The currently active debug mode names, and names to skip. */ createDebug.names = []; createDebug.skips = []; /** * Map of special "%n" handling functions, for the debug "format" argument. * * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N". */ createDebug.formatters = {}; /** * Selects a color for a debug namespace * @param {String} namespace The namespace string for the debug instance to be colored * @return {Number|String} An ANSI color code for the given namespace * @api private */ function selectColor(namespace) { let hash = 0; for (let i = 0; i < namespace.length; i++) { hash = ((hash << 5) - hash) + namespace.charCodeAt(i); hash |= 0; // Convert to 32bit integer } return createDebug.colors[Math.abs(hash) % createDebug.colors.length]; } createDebug.selectColor = selectColor; /** * Create a debugger with the given `namespace`. * * @param {String} namespace * @return {Function} * @api public */ function createDebug(namespace) { let prevTime; let enableOverride = null; let namespacesCache; let enabledCache; function debug(...args) { // Disabled? if (!debug.enabled) { return; } const self = debug; // Set `diff` timestamp const curr = Number(new Date()); const ms = curr - (prevTime || curr); self.diff = ms; self.prev = prevTime; self.curr = curr; prevTime = curr; args[0] = createDebug.coerce(args[0]); if (typeof args[0] !== 'string') { // Anything else let's inspect with %O args.unshift('%O'); } // Apply any `formatters` transformations let index = 0; args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => { // If we encounter an escaped % then don't increase the array index if (match === '%%') { return '%'; } index++; const formatter = createDebug.formatters[format]; if (typeof formatter === 'function') { const val = args[index]; match = formatter.call(self, val); // Now we need to remove `args[index]` since it's inlined in the `format` args.splice(index, 1); index--; } return match; }); // Apply env-specific formatting (colors, etc.) createDebug.formatArgs.call(self, args); const logFn = self.log || createDebug.log; logFn.apply(self, args); } debug.namespace = namespace; debug.useColors = createDebug.useColors(); debug.color = createDebug.selectColor(namespace); debug.extend = extend; debug.destroy = createDebug.destroy; // XXX Temporary. Will be removed in the next major release. Object.defineProperty(debug, 'enabled', { enumerable: true, configurable: false, get: () => { if (enableOverride !== null) { return enableOverride; } if (namespacesCache !== createDebug.namespaces) { namespacesCache = createDebug.namespaces; enabledCache = createDebug.enabled(namespace); } return enabledCache; }, set: v => { enableOverride = v; } }); // Env-specific initialization logic for debug instances if (typeof createDebug.init === 'function') { createDebug.init(debug); } return debug; } function extend(namespace, delimiter) { const newDebug = createDebug(this.namespace + (typeof delimiter === 'undefined' ? ':' : delimiter) + namespace); newDebug.log = this.log; return newDebug; } /** * Enables a debug mode by namespaces. This can include modes * separated by a colon and wildcards. * * @param {String} namespaces * @api public */ function enable(namespaces) { createDebug.save(namespaces); createDebug.namespaces = namespaces; createDebug.names = []; createDebug.skips = []; let i; const split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/); const len = split.length; for (i = 0; i < len; i++) { if (!split[i]) { // ignore empty strings continue; } namespaces = split[i].replace(/\*/g, '.*?'); if (namespaces[0] === '-') { createDebug.skips.push(new RegExp('^' + namespaces.slice(1) + '$')); } else { createDebug.names.push(new RegExp('^' + namespaces + '$')); } } } /** * Disable debug output. * * @return {String} namespaces * @api public */ function disable() { const namespaces = [ ...createDebug.names.map(toNamespace), ...createDebug.skips.map(toNamespace).map(namespace => '-' + namespace) ].join(','); createDebug.enable(''); return namespaces; } /** * Returns true if the given mode name is enabled, false otherwise. * * @param {String} name * @return {Boolean} * @api public */ function enabled(name) { if (name[name.length - 1] === '*') { return true; } let i; let len; for (i = 0, len = createDebug.skips.length; i < len; i++) { if (createDebug.skips[i].test(name)) { return false; } } for (i = 0, len = createDebug.names.length; i < len; i++) { if (createDebug.names[i].test(name)) { return true; } } return false; } /** * Convert regexp to namespace * * @param {RegExp} regxep * @return {String} namespace * @api private */ function toNamespace(regexp) { return regexp.toString() .substring(2, regexp.toString().length - 2) .replace(/\.\*\?$/, '*'); } /** * Coerce `val`. * * @param {Mixed} val * @return {Mixed} * @api private */ function coerce(val) { if (val instanceof Error) { return val.stack || val.message; } return val; } /** * XXX DO NOT USE. This is a temporary stub function. * XXX It WILL be removed in the next major release. */ function destroy() { console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.'); } createDebug.enable(createDebug.load()); return createDebug; } module.exports = setup; /***/ }), /***/ 237: /***/ ((module, __unused_webpack_exports, __nccwpck_require__)