UNPKG

jscrambler

Version:

Jscrambler Code Integrity API client.

109 lines (108 loc) 7.51 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getApplication = getApplication; exports.getApplicationProtections = getApplicationProtections; exports.getApplicationProtectionsCount = getApplicationProtectionsCount; exports.getApplicationSource = getApplicationSource; exports.getApplications = getApplications; exports.getProtection = getProtection; exports.getTemplates = getTemplates; require("core-js/modules/es.regexp.exec.js"); require("core-js/modules/es.string.replace.js"); 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; } 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; } function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; } function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; } 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); } const getApplicationDefaultFragments = "\n _id,\n name,\n createdAt,\n sources {\n _id,\n filename,\n extension\n }\n"; /** * Return one application by id. * The options params argument can be used to filter protections by version and limit the number of protections returned. * @param {String} id the application id * @param {fragment} fragments GraphQL fragment * @param {Array} params {{String}protectionsVersion, {Integer} protectionsNumber} */ function getApplication(applicationId) { let fragments = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : getApplicationDefaultFragments; let params = arguments.length > 2 ? arguments[2] : undefined; return { query: "\n query getApplication ($applicationId: String!, $protectionsVersion: String, $protectionsLimit: Int) {\n application(_id: $applicationId, protectionsVersion: $protectionsVersion, protectionsLimit: $protectionsLimit) {\n ".concat(fragments, "\n }\n }\n "), params: JSON.stringify(_objectSpread({ applicationId }, params)) }; } const getApplicationSourceDefaultFragments = "\n _id,\n filename,\n extension\n"; function getApplicationSource(sourceId) { let fragments = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : getApplicationSourceDefaultFragments; let limits = arguments.length > 2 ? arguments[2] : undefined; return { query: "\n query getApplicationSource ($sourceId: String!, $contentLimit: Int, $transformedLimit: Int) {\n applicationSource(_id: $sourceId, contentLimit: $contentLimit, transformedLimit: $transformedLimit) {\n ".concat(fragments, "\n }\n }\n "), params: JSON.stringify(_objectSpread({ sourceId }, limits)) }; } const getApplicationProtectionsDefaultFragments = "\n _id,\n sources,\n parameters,\n finishedAt,\n randomizationSeed\n"; function getApplicationProtections(applicationId, params) { let fragments = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : getApplicationProtectionsDefaultFragments; let queryArgs = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : []; return { query: "\n query getApplicationProtections ($applicationId: String!, $sort: String, $order: String, $limit: Int, $page: Int".concat(queryArgs.map(v => ",".concat(v)), ") {\n applicationProtections(_id: $applicationId, sort: $sort, order: $order, limit: $limit, page: $page").concat(queryArgs.map(v => ", ".concat(v.split(':')[0].replace('$', ''), ": ").concat(v.split(':')[0])), ") {\n ").concat(fragments, "\n }\n }\n "), params: JSON.stringify(_objectSpread({ applicationId }, params)) }; } const getApplicationProtectionsCountDefaultFragments = "\n count\n"; function getApplicationProtectionsCount(applicationId) { let fragments = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : getApplicationProtectionsCountDefaultFragments; return { query: "\n query getApplicationProtectionsCount ($applicationId: String!) {\n applicationProtectionsCount(_id: $applicationId) {\n ".concat(fragments, "\n }\n }\n "), params: JSON.stringify({ applicationId }) }; } const getTemplatesDefaultFragments = "\n _id,\n parameters\n"; function getTemplates() { let fragments = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getTemplatesDefaultFragments; return { query: "\n query getTemplates {\n templates {\n ".concat(fragments, "\n }\n }\n "), params: '{}' }; } const getApplicationsDefaultFragments = "\n _id,\n name,\n protections,\n parameters\n"; /** * Return all applications. * The options params argument can be used to filter protections by version and limit the number of protections returned. * @param {fragment} fragments GraphQL fragment * @param {Array} params {{String}protectionsVersion, {Integer} protectionsNumber} */ function getApplications() { let fragments = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getApplicationsDefaultFragments; let params = arguments.length > 1 ? arguments[1] : undefined; return { query: "\n query getApplications($protectionsVersion:String, $protectionsLimit: Int) {\n applications(protectionsVersion: $protectionsVersion, protectionsLimit: $protectionsLimit) {\n ".concat(fragments, "\n }\n }\n "), params: JSON.stringify(_objectSpread({}, params)) }; } const getProtectionDefaultFragments = { application: "\n name\n ", applicationProtection: "\n _id,\n state,\n bail,\n deprecations {\n type,\n entity\n },\n errorMessage,\n sources {\n filename,\n errorMessages {\n message,\n line,\n column,\n fatal\n }\n }\n " }; function getProtection(applicationId, protectionId) { let fragments = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : getProtectionDefaultFragments; const params = { protectionId }; if (applicationId) { params.applicationId = applicationId; } return { query: "\n query getProtection (".concat(applicationId ? '$applicationId: String!,' : '', "$protectionId: String!) {\n ").concat(applicationId ? "\n application (_id: $applicationId) {\n ".concat(fragments.application, "\n }") : '', "\n applicationProtection (_id: $protectionId) {\n ").concat(fragments.applicationProtection, "\n }\n }\n "), params: JSON.stringify(params) }; }