jscrambler 6.4.20 → 6.4.23
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/CHANGELOG.md +14 -0
- package/dist/bin/jscrambler.js +154 -202
- package/dist/cleanup-input-fields.js +7 -8
- package/dist/client.js +69 -76
- package/dist/config.js +2 -3
- package/dist/constants.js +12 -10
- package/dist/generate-signed-params.js +13 -11
- package/dist/get-protection-default-fragments.js +42 -99
- package/dist/index.js +834 -1689
- package/dist/introspection.js +50 -172
- package/dist/mutations.js +70 -82
- package/dist/queries.js +33 -32
- package/dist/utils.js +2 -2
- package/dist/zip.js +110 -197
- package/package.json +27 -25
- /package/{LICENSE-MIT → LICENSE} +0 -0
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(
|
|
19
|
-
function _objectSpread(
|
|
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
|
|
22
|
-
function
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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
|
-
|
|
49
|
-
|
|
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
|
-
|
|
76
|
-
jscramblerVersion
|
|
77
|
-
clientId
|
|
64
|
+
const {
|
|
65
|
+
jscramblerVersion,
|
|
66
|
+
clientId
|
|
67
|
+
} = this.options;
|
|
78
68
|
this.axiosInstance = _axios.default.create({
|
|
79
69
|
headers: {
|
|
80
|
-
jscramblerVersion
|
|
81
|
-
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
|
-
|
|
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
|
-
|
|
125
|
-
|
|
126
|
-
|
|
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
|
-
|
|
145
|
-
for (
|
|
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
|
-
|
|
158
|
-
protocol
|
|
159
|
-
port
|
|
160
|
-
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
|
-
|
|
161
|
+
const formattedUrl = _url.default.format({
|
|
172
162
|
hostname: this.options.host,
|
|
173
|
-
port
|
|
163
|
+
port,
|
|
174
164
|
pathname: this.options.basePath + path,
|
|
175
|
-
protocol
|
|
165
|
+
protocol
|
|
176
166
|
});
|
|
177
|
-
|
|
178
|
-
|
|
167
|
+
let data;
|
|
168
|
+
const settings = {};
|
|
179
169
|
|
|
180
170
|
// Internal CA
|
|
181
|
-
|
|
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 ||
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
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
|
-
|
|
186
|
+
let formattedAuth = undefined;
|
|
196
187
|
if (auth) {
|
|
197
|
-
|
|
198
|
-
|
|
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
|
-
|
|
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
|
-
|
|
217
|
-
host
|
|
218
|
-
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
|
-
|
|
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
|
-
|
|
239
|
-
return promise.then(
|
|
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(
|
|
245
|
-
|
|
246
|
-
|
|
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
|
-
|
|
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[
|
|
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
|
-
|
|
282
|
+
let _token;
|
|
290
283
|
Object.defineProperty(JScramblerClient.prototype, 'token', {
|
|
291
|
-
get
|
|
284
|
+
get() {
|
|
292
285
|
return _token;
|
|
293
286
|
},
|
|
294
|
-
set
|
|
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
|
-
|
|
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
|
-
|
|
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.
|
|
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.
|
|
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.
|
|
31
|
-
|
|
32
|
-
|
|
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
|
-
|
|
13
|
-
var debug = !!process.env.DEBUG;
|
|
15
|
+
const debug = !!process.env.DEBUG;
|
|
14
16
|
function signedParams(method, path, host, keys) {
|
|
15
|
-
|
|
16
|
-
|
|
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
|
-
|
|
26
|
-
|
|
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
|
-
|
|
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
|
-
|
|
35
|
-
|
|
36
|
-
for (
|
|
37
|
-
|
|
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(
|
|
9
|
-
function _interopRequireWildcard(
|
|
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
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
return
|
|
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
|
-
|
|
47
|
-
return Object.keys(i).map(
|
|
19
|
+
const iterate = i => {
|
|
20
|
+
return Object.keys(i).map(key => {
|
|
48
21
|
var result;
|
|
49
|
-
|
|
50
|
-
if (
|
|
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
|
-
|
|
62
|
-
Object.keys(b).forEach(
|
|
63
|
-
|
|
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 (
|
|
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
|
-
|
|
47
|
+
const protectionFields = {
|
|
77
48
|
_id: 1,
|
|
78
49
|
state: 1,
|
|
79
50
|
bail: 1,
|
|
@@ -86,65 +57,37 @@ var protectionFields = {
|
|
|
86
57
|
hasForcedDateLock: 1,
|
|
87
58
|
parameters: 1
|
|
88
59
|
};
|
|
89
|
-
|
|
60
|
+
const deprecationFields = {
|
|
90
61
|
type: 1,
|
|
91
62
|
entity: 1
|
|
92
63
|
};
|
|
93
|
-
|
|
94
|
-
filename: 1
|
|
64
|
+
const sourceFields = {
|
|
65
|
+
filename: 1,
|
|
66
|
+
isSource: 1
|
|
95
67
|
};
|
|
96
|
-
|
|
68
|
+
const errorMessageFields = {
|
|
97
69
|
message: 1,
|
|
98
70
|
line: 1,
|
|
99
71
|
column: 1,
|
|
100
72
|
fatal: 1
|
|
101
73
|
};
|
|
102
|
-
function _default(
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
return getIntrospection(client, 'ApplicationSource');
|
|
122
|
-
case 8:
|
|
123
|
-
source = _context2.sent;
|
|
124
|
-
_context2.next = 11;
|
|
125
|
-
return getIntrospection(client, 'ErrorMessages');
|
|
126
|
-
case 11:
|
|
127
|
-
errorMessage = _context2.sent;
|
|
128
|
-
fragments = {
|
|
129
|
-
application: {
|
|
130
|
-
name: 1
|
|
131
|
-
},
|
|
132
|
-
applicationProtection: {}
|
|
133
|
-
};
|
|
134
|
-
fragments.applicationProtection = appProtection && getAvaliableFragments(appProtection.fields, protectionFields);
|
|
135
|
-
fragments.applicationProtection.deprecations = deprecation && getAvaliableFragments(deprecation.fields, deprecationFields);
|
|
136
|
-
fragments.applicationProtection.sources = source && getAvaliableFragments(source.fields, sourceFields);
|
|
137
|
-
fragments.applicationProtection.sources.errorMessages = errorMessage && getAvaliableFragments(errorMessage.fields, errorMessageFields);
|
|
138
|
-
return _context2.abrupt("return", {
|
|
139
|
-
application: fragmentToQL(fragments.application),
|
|
140
|
-
applicationProtection: fragmentToQL(fragments.applicationProtection)
|
|
141
|
-
});
|
|
142
|
-
case 18:
|
|
143
|
-
case "end":
|
|
144
|
-
return _context2.stop();
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
}, _callee2);
|
|
148
|
-
}));
|
|
149
|
-
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
|
+
};
|
|
150
93
|
}
|