jscrambler 6.4.21 → 6.4.24

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/dist/client.js CHANGED
@@ -1,5 +1,10 @@
1
1
  "use strict";
2
2
 
3
+ require("core-js/modules/es.symbol.description.js");
4
+ require("core-js/modules/web.dom-collections.iterator.js");
5
+ require("core-js/modules/es.regexp.exec.js");
6
+ require("core-js/modules/es.string.replace.js");
7
+ require("core-js/modules/es.string.trim.js");
3
8
  var _lodash = _interopRequireDefault(require("lodash.defaults"));
4
9
  var _fs = _interopRequireDefault(require("fs"));
5
10
  var _lodash2 = _interopRequireDefault(require("lodash.keys"));
@@ -15,38 +20,21 @@ var _generateSignedParams = _interopRequireDefault(require("./generate-signed-pa
15
20
  var _constants = require("./constants");
16
21
  var _package = require("../package.json");
17
22
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
18
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
19
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
20
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
21
- function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
22
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
23
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
24
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
25
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
26
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
27
- function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
28
- function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
29
- function _wrapNativeSuper(Class) { var _cache = typeof Map === "function" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== "function") { throw new TypeError("Super expression must either be null or a function"); } if (typeof _cache !== "undefined") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); }
30
- function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct.bind(); } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }
31
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
32
- function _isNativeFunction(fn) { return Function.toString.call(fn).indexOf("[native code]") !== -1; }
33
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
34
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
35
- var debug = !!process.env.DEBUG;
36
- var metrics = !!process.env.METRICS;
37
- var noCompression = !!process.env.NO_COMPRESSION;
38
- var ClientError = /*#__PURE__*/function (_Error) {
39
- _inherits(ClientError, _Error);
40
- var _super = _createSuper(ClientError);
41
- function ClientError(message, statusCode) {
42
- var _this;
43
- _classCallCheck(this, ClientError);
44
- _this = _super.call(this, message);
45
- _this.statusCode = statusCode;
46
- return _this;
23
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
24
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
25
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
26
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
27
+ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
28
+ const debug = !!process.env.DEBUG;
29
+ const metrics = !!process.env.METRICS;
30
+ const noCompression = !!process.env.NO_COMPRESSION;
31
+ class ClientError extends Error {
32
+ constructor(message, statusCode) {
33
+ super(message);
34
+ this.statusCode = statusCode;
47
35
  }
48
- return _createClass(ClientError);
49
- }( /*#__PURE__*/_wrapNativeSuper(Error));
36
+ }
37
+
50
38
  /**
51
39
  * @class JScramblerClient
52
40
  * @param {Object} options
@@ -59,6 +47,7 @@ var ClientError = /*#__PURE__*/function (_Error) {
59
47
  * @author Jscrambler
60
48
  * @license MIT <http://opensource.org/licenses/MIT>
61
49
  */
50
+
62
51
  function JScramblerClient(options) {
63
52
  // Sluggish hack for backwards compatibility
64
53
  if (options && !options.keys && (options.accessKey || options.secretKey)) {
@@ -72,13 +61,14 @@ function JScramblerClient(options) {
72
61
  * @member
73
62
  */
74
63
  this.options = (0, _lodash.default)(options || {}, _config.default);
75
- var _this$options = this.options,
76
- jscramblerVersion = _this$options.jscramblerVersion,
77
- clientId = _this$options.clientId;
64
+ const {
65
+ jscramblerVersion,
66
+ clientId
67
+ } = this.options;
78
68
  this.axiosInstance = _axios.default.create({
79
69
  headers: {
80
- jscramblerVersion: jscramblerVersion,
81
- clientId: clientId
70
+ jscramblerVersion,
71
+ clientId
82
72
  },
83
73
  transformRequest: _axios.default.defaults.transformRequest.concat(function (data, headers) {
84
74
  // gzip request with more than 1KiB
@@ -110,7 +100,7 @@ JScramblerClient.prototype.delete = function (path, params) {
110
100
  * @param {Callback} callback
111
101
  */
112
102
  JScramblerClient.prototype.get = function (path, params) {
113
- var isJSON = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
103
+ let isJSON = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
114
104
  return this.request('GET', path, params, isJSON);
115
105
  };
116
106
  /**
@@ -121,10 +111,9 @@ JScramblerClient.prototype.get = function (path, params) {
121
111
  * @param {Callback} callback
122
112
  */
123
113
  JScramblerClient.prototype.request = function (method, path) {
124
- var _this2 = this;
125
- var params = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
126
- var isJSON = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
127
- var signedData;
114
+ let params = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
115
+ let isJSON = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
116
+ let signedData;
128
117
  if (this.options.useHeaderAuth) {
129
118
  if (!this.token) {
130
119
  throw new Error('Generating auth token when useHeaderAuth === true is not yet supported. You need to set the jscramblerClient token property explicitly.');
@@ -141,8 +130,8 @@ JScramblerClient.prototype.request = function (method, path) {
141
130
  }
142
131
  }
143
132
  }
144
- var _keys = (0, _lodash2.default)(params);
145
- for (var i = 0, l = _keys.length; i < l; i++) {
133
+ const _keys = (0, _lodash2.default)(params);
134
+ for (let i = 0, l = _keys.length; i < l; i++) {
146
135
  if (params[_keys[i]] instanceof Array) {
147
136
  params[_keys[i]] = params[_keys[i]].join(',');
148
137
  }
@@ -154,10 +143,11 @@ JScramblerClient.prototype.request = function (method, path) {
154
143
  } else {
155
144
  signedData = params;
156
145
  }
157
- var _this$options2 = this.options,
158
- protocol = _this$options2.protocol,
159
- port = _this$options2.port,
160
- proxy = _this$options2.proxy;
146
+ let {
147
+ protocol,
148
+ port,
149
+ proxy
150
+ } = this.options;
161
151
  if (!port && !protocol) {
162
152
  port = 443;
163
153
  protocol = 'https';
@@ -168,34 +158,37 @@ JScramblerClient.prototype.request = function (method, path) {
168
158
  if (!protocol) {
169
159
  protocol = port === 443 ? 'https' : 'http';
170
160
  }
171
- var formattedUrl = _url.default.format({
161
+ const formattedUrl = _url.default.format({
172
162
  hostname: this.options.host,
173
- port: port,
163
+ port,
174
164
  pathname: this.options.basePath + path,
175
- protocol: protocol
165
+ protocol
176
166
  });
177
- var data;
178
- var settings = {};
167
+ let data;
168
+ const settings = {};
179
169
 
180
170
  // Internal CA
181
- var agentOptions = {};
171
+ let agentOptions = {};
182
172
  if (this.options.cafile) {
183
173
  agentOptions = {
184
174
  ca: _fs.default.readFileSync(this.options.cafile)
185
175
  };
186
176
  }
187
- if (proxy || _typeof(proxy) === 'object') {
188
- var host = proxy.host,
189
- _proxy$port = proxy.port,
190
- _port = _proxy$port === void 0 ? 8080 : _proxy$port,
191
- auth = proxy.auth;
177
+ if (proxy || typeof proxy === 'object') {
178
+ const {
179
+ host,
180
+ port = 8080,
181
+ auth
182
+ } = proxy;
192
183
  if (!host) {
193
184
  throw new Error('Required *proxy.host* not provided');
194
185
  }
195
- var formattedAuth = undefined;
186
+ let formattedAuth = undefined;
196
187
  if (auth) {
197
- var username = auth.username,
198
- password = auth.password;
188
+ const {
189
+ username,
190
+ password
191
+ } = auth;
199
192
  if (!username || !password) {
200
193
  throw new Error('Required *proxy.auth* username or/and password not provided');
201
194
  }
@@ -207,15 +200,15 @@ JScramblerClient.prototype.request = function (method, path) {
207
200
  * options.
208
201
  */
209
202
  if (agentOptions.ca) {
210
- var oriCallback = _httpsProxyAgent.default.prototype.callback;
203
+ const oriCallback = _httpsProxyAgent.default.prototype.callback;
211
204
  _httpsProxyAgent.default.prototype.callback = function (req, opts) {
212
205
  return oriCallback.call(this, req, _objectSpread(_objectSpread({}, opts), agentOptions));
213
206
  };
214
207
  }
215
208
  settings.proxy = false;
216
- var proxyConfig = _objectSpread({
217
- host: host,
218
- port: _port,
209
+ const proxyConfig = _objectSpread({
210
+ host,
211
+ port,
219
212
  auth: formattedAuth
220
213
  }, agentOptions);
221
214
  settings.httpsAgent = new _httpsProxyAgent.default(proxyConfig);
@@ -227,7 +220,7 @@ JScramblerClient.prototype.request = function (method, path) {
227
220
  if (!isJSON) {
228
221
  settings.responseType = 'arraybuffer';
229
222
  }
230
- var promise;
223
+ let promise;
231
224
  if (method === 'GET' || method === 'DELETE') {
232
225
  settings.params = signedData;
233
226
  promise = this.axiosInstance[method.toLowerCase()](formattedUrl, settings);
@@ -235,27 +228,27 @@ JScramblerClient.prototype.request = function (method, path) {
235
228
  data = signedData;
236
229
  promise = this.axiosInstance[method.toLowerCase()](formattedUrl, data, settings);
237
230
  }
238
- var start = Date.now();
239
- return promise.then(function (res) {
231
+ const start = Date.now();
232
+ return promise.then(res => {
240
233
  if (metrics || debug) {
241
234
  console.log("".concat(method, " ").concat(path, " ").concat(((data || settings.params).query || '').split('(')[0].trim().replace(' ', '-'), " ").concat(JSON.stringify(data || settings.params).length, "B ").concat(Date.now() - start, "ms"));
242
235
  }
243
236
  return res.data;
244
- }).catch(function (err) {
245
- var errorMessage = 'Unexpected Response: ';
246
- var statusCode = 500;
237
+ }).catch(err => {
238
+ let errorMessage = 'Unexpected Response: ';
239
+ let statusCode = 500;
247
240
  if (err.response) {
248
241
  if (debug) {
249
242
  console.error(err.response);
250
243
  }
251
244
  errorMessage += "".concat(err.response.status, " ").concat(err.response.statusText);
252
245
  statusCode = err.response.status;
253
- var incompatibleApi = false;
246
+ let incompatibleApi = false;
254
247
  if (statusCode === _constants.HTTP_STATUS_CODES.UNAUTHORIZED && /Invalid Signature/i.test(err.response.data.message)) {
255
248
  incompatibleApi = err.response.data.errorCode !== _constants.JSCRAMBLER_ERROR_CODES.INVALID_SIGNATURE;
256
249
  }
257
250
  if (incompatibleApi) {
258
- errorMessage = "Incompatible jscrambler CLI version (".concat(_package.version, "). Please downgrade to: \n\t$ npm install ").concat(_constants.CLIENT_PACKAGES[_this2.options.clientId], "@5");
251
+ errorMessage = "Incompatible jscrambler CLI version (".concat(_package.version, "). Please downgrade to: \n\t$ npm install ").concat(_constants.CLIENT_PACKAGES[this.options.clientId], "@5");
259
252
  } else if (
260
253
  // For when we have API error messages
261
254
  err.response.data && err.response.data.error && err.response.data.message) {
@@ -286,12 +279,12 @@ JScramblerClient.prototype.post = function (path, params) {
286
279
  JScramblerClient.prototype.patch = function (path, params) {
287
280
  return this.request('PATCH', path, params);
288
281
  };
289
- var _token;
282
+ let _token;
290
283
  Object.defineProperty(JScramblerClient.prototype, 'token', {
291
- get: function get() {
284
+ get() {
292
285
  return _token;
293
286
  },
294
- set: function set(value) {
287
+ set(value) {
295
288
  _token = value;
296
289
  if (value) {
297
290
  if (this.options.useHeaderAuth) {
package/dist/config.js CHANGED
@@ -9,7 +9,7 @@ var _constants = require("./constants");
9
9
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
10
  // Load RC configuration if present. Pass `[]` as last argument to avoid
11
11
  // getting variables from `argv`.
12
- var config = (0, _rc.default)('jscrambler', {
12
+ const config = (0, _rc.default)('jscrambler', {
13
13
  keys: {},
14
14
  host: 'api4.jscrambler.com',
15
15
  basePath: '',
@@ -19,5 +19,4 @@ var config = (0, _rc.default)('jscrambler', {
19
19
  utc: true,
20
20
  maxRetries: 5
21
21
  }, []);
22
- var _default = config;
23
- exports.default = _default;
22
+ var _default = exports.default = config;
package/dist/constants.js CHANGED
@@ -4,21 +4,17 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.JSCRAMBLER_ERROR_CODES = exports.HTTP_STATUS_CODES = exports.CLIENT_PACKAGES = exports.CLIENT_IDS = void 0;
7
- var _Object$freeze;
8
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
9
- var HTTP_STATUS_CODES = Object.freeze({
7
+ const HTTP_STATUS_CODES = exports.HTTP_STATUS_CODES = Object.freeze({
10
8
  UNAUTHORIZED: 401,
11
9
  FORBIDDEN: 403,
12
10
  NOT_FOUND: 404,
13
11
  SERVICE_UNAVAILABLE: 503,
14
12
  GATEWAY_TIMEOUT: 504
15
13
  });
16
- exports.HTTP_STATUS_CODES = HTTP_STATUS_CODES;
17
- var JSCRAMBLER_ERROR_CODES = Object.freeze({
14
+ const JSCRAMBLER_ERROR_CODES = exports.JSCRAMBLER_ERROR_CODES = Object.freeze({
18
15
  INVALID_SIGNATURE: '254'
19
16
  });
20
- exports.JSCRAMBLER_ERROR_CODES = JSCRAMBLER_ERROR_CODES;
21
- var CLIENT_IDS = Object.freeze({
17
+ const CLIENT_IDS = exports.CLIENT_IDS = Object.freeze({
22
18
  CLI: 0,
23
19
  APP: 1,
24
20
  WEBPACK: 2,
@@ -27,6 +23,12 @@ var CLIENT_IDS = Object.freeze({
27
23
  EMBER: 5,
28
24
  METRO: 6
29
25
  });
30
- exports.CLIENT_IDS = CLIENT_IDS;
31
- var CLIENT_PACKAGES = Object.freeze((_Object$freeze = {}, _defineProperty(_Object$freeze, CLIENT_IDS.CLI, 'jscrambler'), _defineProperty(_Object$freeze, CLIENT_IDS.APP, 'app'), _defineProperty(_Object$freeze, CLIENT_IDS.WEBPACK, 'jscrambler-webpack-plugin'), _defineProperty(_Object$freeze, CLIENT_IDS.GULP, 'gulp-jscrambler'), _defineProperty(_Object$freeze, CLIENT_IDS.GRUNT, 'grunt-jscrambler'), _defineProperty(_Object$freeze, CLIENT_IDS.EMBER, 'ember-cli-jscrambler'), _defineProperty(_Object$freeze, CLIENT_IDS.METRO, 'jscrambler-metro-plugin'), _Object$freeze));
32
- exports.CLIENT_PACKAGES = CLIENT_PACKAGES;
26
+ const CLIENT_PACKAGES = exports.CLIENT_PACKAGES = Object.freeze({
27
+ [CLIENT_IDS.CLI]: 'jscrambler',
28
+ [CLIENT_IDS.APP]: 'app',
29
+ [CLIENT_IDS.WEBPACK]: 'jscrambler-webpack-plugin',
30
+ [CLIENT_IDS.GULP]: 'gulp-jscrambler',
31
+ [CLIENT_IDS.GRUNT]: 'grunt-jscrambler',
32
+ [CLIENT_IDS.EMBER]: 'ember-cli-jscrambler',
33
+ [CLIENT_IDS.METRO]: 'jscrambler-metro-plugin'
34
+ });
@@ -4,16 +4,18 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = signedParams;
7
+ require("core-js/modules/es.array.sort.js");
8
+ require("core-js/modules/es.regexp.exec.js");
9
+ require("core-js/modules/es.string.replace.js");
7
10
  var _lodash = _interopRequireDefault(require("lodash.clone"));
8
11
  var _crypto = _interopRequireDefault(require("crypto"));
9
12
  var _lodash2 = _interopRequireDefault(require("lodash.defaults"));
10
13
  var _lodash3 = _interopRequireDefault(require("lodash.keys"));
11
14
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
- function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
13
- var debug = !!process.env.DEBUG;
15
+ const debug = !!process.env.DEBUG;
14
16
  function signedParams(method, path, host, keys) {
15
- var params = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
16
- var utc = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : true;
17
+ let params = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
18
+ let utc = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : true;
17
19
  params = (0, _lodash2.default)((0, _lodash.default)(params), {
18
20
  access_key: keys.accessKey,
19
21
  timestamp: utc.toString() !== 'false' ? new Date().toISOString() : new Date().toLocaleString()
@@ -22,19 +24,19 @@ function signedParams(method, path, host, keys) {
22
24
  return params;
23
25
  }
24
26
  function generateHmacSignature(method, path, host, keys, params) {
25
- var paramsCopy = (0, _lodash.default)(params);
26
- var signatureData = "".concat(method.toUpperCase(), ";").concat(host.toLowerCase(), ";").concat(path, ";").concat(buildSortedQuery(paramsCopy));
27
+ const paramsCopy = (0, _lodash.default)(params);
28
+ const signatureData = "".concat(method.toUpperCase(), ";").concat(host.toLowerCase(), ";").concat(path, ";").concat(buildSortedQuery(paramsCopy));
27
29
  debug && console.log("Signature data: ".concat(signatureData));
28
- var hmac = _crypto.default.createHmac('sha256', keys.secretKey.toUpperCase());
30
+ const hmac = _crypto.default.createHmac('sha256', keys.secretKey.toUpperCase());
29
31
  hmac.update(signatureData);
30
32
  return hmac.digest('base64');
31
33
  }
32
34
  function buildSortedQuery(params) {
33
35
  // Sorted keys
34
- var _keys = (0, _lodash3.default)(params).sort();
35
- var query = '';
36
- for (var i = 0, l = _keys.length; i < l; i++) {
37
- var value = _typeof(params[_keys[i]]) === 'object' ? JSON.stringify(params[_keys[i]]) : params[_keys[i]];
36
+ const _keys = (0, _lodash3.default)(params).sort();
37
+ let query = '';
38
+ for (let i = 0, l = _keys.length; i < l; i++) {
39
+ const value = typeof params[_keys[i]] === 'object' ? JSON.stringify(params[_keys[i]]) : params[_keys[i]];
38
40
  query += "".concat(encodeURIComponent(_keys[i]), "=").concat(encodeURIComponent(value), "&");
39
41
  }
40
42
  query = query.replace(/\*/g, '%2A').replace(/[!'()]/g, escape).replace(/%7E/g, '~').replace(/\+/g, '%20');
@@ -1,53 +1,26 @@
1
1
  "use strict";
2
2
 
3
+ require("core-js/modules/web.dom-collections.iterator.js");
3
4
  Object.defineProperty(exports, "__esModule", {
4
5
  value: true
5
6
  });
6
7
  exports.default = _default;
7
8
  var introspection = _interopRequireWildcard(require("./introspection"));
8
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
9
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
10
- function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var method = delegate.iterator[context.method]; if (undefined === method) { if (context.delegate = null, "throw" === context.method) { if (delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel; context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method"); } return ContinueSentinel; } var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
11
- function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
12
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
13
- function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
14
- function getIntrospection(_x, _x2) {
15
- return _getIntrospection.apply(this, arguments);
16
- }
17
- function _getIntrospection() {
18
- _getIntrospection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(client, typeName) {
19
- var _introspection;
20
- return _regeneratorRuntime().wrap(function _callee$(_context) {
21
- while (1) {
22
- switch (_context.prev = _context.next) {
23
- case 0:
24
- _context.prev = 0;
25
- _context.next = 3;
26
- return introspection.type(client, typeName);
27
- case 3:
28
- _introspection = _context.sent;
29
- _context.next = 8;
30
- break;
31
- case 6:
32
- _context.prev = 6;
33
- _context.t0 = _context["catch"](0);
34
- case 8:
35
- return _context.abrupt("return", _introspection);
36
- case 9:
37
- case "end":
38
- return _context.stop();
39
- }
40
- }
41
- }, _callee, null, [[0, 6]]);
42
- }));
43
- return _getIntrospection.apply(this, arguments);
9
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
10
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
11
+ async function getIntrospection(client, typeName) {
12
+ let _introspection;
13
+ try {
14
+ _introspection = await introspection.type(client, typeName);
15
+ } catch (e) {}
16
+ return _introspection;
44
17
  }
45
18
  function fragmentToQL(fragment) {
46
- var iterate = function iterate(i) {
47
- return Object.keys(i).map(function (key) {
19
+ const iterate = i => {
20
+ return Object.keys(i).map(key => {
48
21
  var result;
49
- var value = i[key];
50
- if (_typeof(value) === 'object') {
22
+ const value = i[key];
23
+ if (typeof value === 'object') {
51
24
  result = "".concat(key, " { ").concat(iterate(value), " }");
52
25
  } else {
53
26
  result = key;
@@ -58,13 +31,11 @@ function fragmentToQL(fragment) {
58
31
  return iterate(fragment);
59
32
  }
60
33
  function getAvaliableFragments(a, b) {
61
- var fragment = {};
62
- Object.keys(b).forEach(function (field) {
63
- var _field = a.find(function (f) {
64
- return f.name === field;
65
- });
34
+ const fragment = {};
35
+ Object.keys(b).forEach(field => {
36
+ const _field = a.find(f => f.name === field);
66
37
  if (_field) {
67
- if (_typeof(b[field]) === 'object' && _field.type.ofType.kind === 'OBJECT') {
38
+ if (typeof b[field] === 'object' && _field.type.ofType.kind === 'OBJECT') {
68
39
  fragment[field] = b[field];
69
40
  } else {
70
41
  fragment[field] = 1;
@@ -73,7 +44,7 @@ function getAvaliableFragments(a, b) {
73
44
  });
74
45
  return fragment;
75
46
  }
76
- var protectionFields = {
47
+ const protectionFields = {
77
48
  _id: 1,
78
49
  state: 1,
79
50
  bail: 1,
@@ -86,66 +57,37 @@ var protectionFields = {
86
57
  hasForcedDateLock: 1,
87
58
  parameters: 1
88
59
  };
89
- var deprecationFields = {
60
+ const deprecationFields = {
90
61
  type: 1,
91
62
  entity: 1
92
63
  };
93
- var sourceFields = {
64
+ const sourceFields = {
94
65
  filename: 1,
95
66
  isSource: 1
96
67
  };
97
- var errorMessageFields = {
68
+ const errorMessageFields = {
98
69
  message: 1,
99
70
  line: 1,
100
71
  column: 1,
101
72
  fatal: 1
102
73
  };
103
- function _default(_x3) {
104
- return _ref.apply(this, arguments);
105
- }
106
- function _ref() {
107
- _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(client) {
108
- var appProtection, deprecation, source, errorMessage, fragments;
109
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
110
- while (1) {
111
- switch (_context2.prev = _context2.next) {
112
- case 0:
113
- _context2.next = 2;
114
- return getIntrospection(client, 'ApplicationProtection');
115
- case 2:
116
- appProtection = _context2.sent;
117
- _context2.next = 5;
118
- return getIntrospection(client, 'Deprecation');
119
- case 5:
120
- deprecation = _context2.sent;
121
- _context2.next = 8;
122
- return getIntrospection(client, 'ApplicationSource');
123
- case 8:
124
- source = _context2.sent;
125
- _context2.next = 11;
126
- return getIntrospection(client, 'ErrorMessages');
127
- case 11:
128
- errorMessage = _context2.sent;
129
- fragments = {
130
- application: {
131
- name: 1
132
- },
133
- applicationProtection: {}
134
- };
135
- fragments.applicationProtection = appProtection && getAvaliableFragments(appProtection.fields, protectionFields);
136
- fragments.applicationProtection.deprecations = deprecation && getAvaliableFragments(deprecation.fields, deprecationFields);
137
- fragments.applicationProtection.sources = source && getAvaliableFragments(source.fields, sourceFields);
138
- fragments.applicationProtection.sources.errorMessages = errorMessage && getAvaliableFragments(errorMessage.fields, errorMessageFields);
139
- return _context2.abrupt("return", {
140
- application: fragmentToQL(fragments.application),
141
- applicationProtection: fragmentToQL(fragments.applicationProtection)
142
- });
143
- case 18:
144
- case "end":
145
- return _context2.stop();
146
- }
147
- }
148
- }, _callee2);
149
- }));
150
- return _ref.apply(this, arguments);
74
+ async function _default(client) {
75
+ const appProtection = await getIntrospection(client, 'ApplicationProtection');
76
+ const deprecation = await getIntrospection(client, 'Deprecation');
77
+ const source = await getIntrospection(client, 'ApplicationSource');
78
+ const errorMessage = await getIntrospection(client, 'ErrorMessages');
79
+ const fragments = {
80
+ application: {
81
+ name: 1
82
+ },
83
+ applicationProtection: {}
84
+ };
85
+ fragments.applicationProtection = appProtection && getAvaliableFragments(appProtection.fields, protectionFields);
86
+ fragments.applicationProtection.deprecations = deprecation && getAvaliableFragments(deprecation.fields, deprecationFields);
87
+ fragments.applicationProtection.sources = source && getAvaliableFragments(source.fields, sourceFields);
88
+ fragments.applicationProtection.sources.errorMessages = errorMessage && getAvaliableFragments(errorMessage.fields, errorMessageFields);
89
+ return {
90
+ application: fragmentToQL(fragments.application),
91
+ applicationProtection: fragmentToQL(fragments.applicationProtection)
92
+ };
151
93
  }