Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

netlify-onegraph-internal

Package Overview
Dependencies
Maintainers
1
Versions
100
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

netlify-onegraph-internal - npm Package Compare versions

Comparing version 0.1.12 to 0.1.13

4

dist/netlifyGraph.js

@@ -112,3 +112,3 @@ "use strict";

var generatedNetlifyGraphPersistedClient = function (netlifyGraphConfig, schemaId) {
return lruCacheImplementation + "\n\n" + out(netlifyGraphConfig, ["node"], "const httpGet = (input) => {\n const userHeaders = input.headers || {};\n const fullHeaders = {\n ...userHeaders,\n 'Content-Type': 'application/json'\n };\n const timeoutMs = 30_000\n const reqOptions = {\n method: 'GET',\n headers: fullHeaders,\n timeout: timeoutMs,\n };\n\n if (!input.docId) {\n throw new Error('docId is required for GET requests: ' + input.operationName);\n }\n\n const schemaId = input.schemaId || " + (schemaId ? "\"" + schemaId + "\"" : "undefined") + ";\n\n const encodedVariables = encodeURIComponent(input.variables || \"null\");\n const url = 'https://serve.onegraph.com/graphql?app_id=' + input.siteId + '&doc_id=' + input.docId + (input.operationName ? ('&operationName=' + input.operationName) : '') + (schemaId ? ('&schemaId=' + schemaId) : '') + '&variables=' + encodedVariables;\n \n const respBody = []\n\n return new Promise((resolve, reject) => {\n const req = https.request(url, reqOptions, (res) => {\n if (res.statusCode && (res.statusCode < 200 || res.statusCode > 299)) {\n return reject(\n new Error(\n \"Netlify Graph return non-OK HTTP status code\" + res.statusCode,\n ),\n )\n }\n\n res.on('data', (chunk) => respBody.push(chunk))\n\n res.on('end', () => {\n const resString = buffer.Buffer.concat(respBody).toString()\n resolve(resString)\n })\n })\n\n req.on('error', (error) => {\n console.error('Error making request to Netlify Graph:', error)\n })\n\n req.on('timeout', () => {\n req.destroy()\n reject(new Error('Request to Netlify Graph timed out'))\n })\n\n req.end()\n })\n}\n\nconst httpPost = (input) => {\n const reqBody = input.body || null\n const userHeaders = input.headers || {}\n const headers = {\n ...userHeaders,\n 'Content-Type': 'application/json',\n 'Content-Length': reqBody.length,\n }\n\n const timeoutMs = 30_000\n\n const reqOptions = {\n method: 'POST',\n headers: headers,\n timeout: timeoutMs,\n }\n\n const schemaId = input.schemaId || " + (schemaId ? "\"" + schemaId + "\"" : "undefined") + ";\n\n\n const url = 'https://serve.onegraph.com/graphql?app_id=' + input.siteId +\n (schemaId ? ('&schemaId=' + schemaId) : '');\n const respBody = []\n\n return new Promise((resolve, reject) => {\n const req = https.request(url, reqOptions, (res) => {\n if (res.statusCode && (res.statusCode < 200 || res.statusCode > 299)) {\n return reject(\n new Error(\n \"Netlify Graph return non-OK HTTP status code\" + res.statusCode,\n ),\n )\n }\n\n res.on('data', (chunk) => respBody.push(chunk))\n\n res.on('end', () => {\n const resString = buffer.Buffer.concat(respBody).toString()\n resolve(resString)\n })\n })\n\n req.on('error', (error) => {\n console.error('Error making request to Netlify Graph:', error)\n })\n\n req.on('timeout', () => {\n req.destroy()\n reject(new Error('Request to Netlify Graph timed out'))\n })\n\n req.write(reqBody)\n req.end()\n })\n}") + "\n\n" + out(netlifyGraphConfig, ["browser"], "const httpGet = (input) => {\n const userHeaders = input.headers || {};\n const fullHeaders = {\n ...userHeaders,\n 'Content-Type': 'application/json',\n };\n\n const timeoutMs = 30_000;\n\n const reqOptions = {\n method: 'GET',\n headers: fullHeaders,\n timeout: timeoutMs,\n };\n\n const encodedVariables = encodeURIComponent(\n JSON.stringify(input.variables || null)\n );\n\n const schemaId = input.schemaId || " + (schemaId ? "\"" + schemaId + "\"" : "undefined") + ";\n\n const url =\n 'https://serve.onegraph.com/graphql?app_id=' +\n input.siteId +\n '&doc_id=' +\n input.docId +\n (input.operationName ? '&operationName=' + input.operationName : '') +\n (schemaId ? ('&schemaId=' + schemaId) : '') +\n '&variables=' +\n encodedVariables;\n\n return fetch(url, reqOptions).then((response) => response.text());\n};\n\nconst httpPost = (input) => {\n const userHeaders = input.headers || {};\n const fullHeaders = {\n ...userHeaders,\n 'Content-Type': 'application/json',\n };\n\n const reqBody = JSON.stringify({\n doc_id: input.docId,\n query: input.query,\n operationName: input.operationName,\n variables: input.variables,\n });\n\n const timeoutMs = 30_000;\n\n const reqOptions = {\n method: 'POST',\n headers: fullHeaders,\n timeout: timeoutMs,\n body: reqBody,\n };\n\n const schemaId = input.schemaId || " + (schemaId ? "\"" + schemaId + "\"" : "undefined") + ";\n\n const url = 'https://serve.onegraph.com/graphql?app_id=' + input.siteId +\n (schemaId ? ('&schemaId=' + schemaId) : '');\n\n return fetch(url, reqOptions).then((response) => response.text());\n};") + "\n\nconst fetchNetlifyGraph = function fetchNetlifyGraph(input) {\n const docId = input.doc_id;\n const operationName = input.operationName;\n const variables = input.variables;\n\n const options = input.options || {};\n const accessToken = options.accessToken;\n const siteId = options.siteId || process.env.SITE_ID;\n\n const httpMethod = input.fetchStrategy === 'GET' ? httpGet : httpPost;\n\n let response;\n\n if (input.fetchStrategy === 'GET') {\n response = httpMethod({\n siteId: siteId,\n docId: docId,\n query: input.query,\n headers: {\n Authorization: accessToken ? 'Bearer ' + accessToken : '',\n },\n variables: variables,\n operationName: operationName,\n }).then((result) => JSON.parse(result));\n } else {\n let cachedOrLiveValue = new Promise((resolve) => {\n const cacheKey = calculateCacheKey(payload);\n\n // Check the cache for a previous result\n const cachedResultPair = getFromCache(cache, cacheKey);\n\n let conditionalHeaders = {};\n let cachedResultValue;\n\n if (cachedResultPair) {\n const [etag, previousResult] = cachedResultPair;\n conditionalHeaders = {\n 'If-None-Match': etag,\n };\n cachedResultValue = previousResult;\n }\n\n const persistedResponse = httpMethod({\n siteId: siteId,\n docId: docId,\n query: input.query,\n headers: {\n ...conditionalHeaders,\n Authorization: accessToken ? 'Bearer ' + accessToken : '',\n },\n variables: variables,\n operationName: operationName,\n });\n\n persistedResponse.then((result) => {\n // Check response headers for a 304 Not Modified\n if (result.status === 304) {\n // Return the cached result\n resolve(cachedResultValue);\n }\n else if (result.status === 200) {\n // Update the cache with the new etag and result\n const etag = result.headers.get('ng-etag');\n const resultJson = result.json();\n resultJson.then((json) => {\n if (etag) {\n // Make a not of the new etag for the given payload\n setInCache(cache, cacheKey, [etag, json])\n };\n resolve(json);\n });\n } else {\n return result.json().then((json) => {\n resolve(json);\n });\n }\n });\n };\n\n response = cachedOrLiveValue;\n }\n\n return response;\n};\n";
return lruCacheImplementation + "\n\n" + out(netlifyGraphConfig, ["node"], "const httpGet = (input) => {\n const userHeaders = input.headers || {};\n const fullHeaders = {\n ...userHeaders,\n 'Content-Type': 'application/json'\n };\n const timeoutMs = 30_000\n const reqOptions = {\n method: 'GET',\n headers: fullHeaders,\n timeout: timeoutMs,\n };\n\n if (!input.docId) {\n throw new Error('docId is required for GET requests: ' + input.operationName);\n }\n\n const schemaId = input.schemaId || " + (schemaId ? "\"" + schemaId + "\"" : "undefined") + ";\n\n const encodedVariables = encodeURIComponent(input.variables || \"null\");\n const url = 'https://serve.onegraph.com/graphql?app_id=' + input.siteId + '&doc_id=' + input.docId + (input.operationName ? ('&operationName=' + input.operationName) : '') + (schemaId ? ('&schemaId=' + schemaId) : '') + '&variables=' + encodedVariables;\n \n const respBody = []\n\n return new Promise((resolve, reject) => {\n const req = https.request(url, reqOptions, (res) => {\n if (res.statusCode && (res.statusCode < 200 || res.statusCode > 299)) {\n return reject(\n new Error(\n \"Netlify Graph return non-OK HTTP status code\" + res.statusCode,\n ),\n )\n }\n\n res.on('data', (chunk) => respBody.push(chunk))\n\n res.on('end', () => {\n const resString = buffer.Buffer.concat(respBody).toString()\n resolve(resString)\n })\n })\n\n req.on('error', (error) => {\n console.error('Error making request to Netlify Graph:', error)\n })\n\n req.on('timeout', () => {\n req.destroy()\n reject(new Error('Request to Netlify Graph timed out'))\n })\n\n req.end()\n })\n}\n\nconst httpPost = (input) => {\n const reqBody = input.body || null\n const userHeaders = input.headers || {}\n const headers = {\n ...userHeaders,\n 'Content-Type': 'application/json',\n 'Content-Length': reqBody.length,\n }\n\n const timeoutMs = 30_000\n\n const reqOptions = {\n method: 'POST',\n headers: headers,\n timeout: timeoutMs,\n }\n\n const schemaId = input.schemaId || " + (schemaId ? "\"" + schemaId + "\"" : "undefined") + ";\n\n\n const url = 'https://serve.onegraph.com/graphql?app_id=' + input.siteId +\n (schemaId ? ('&schemaId=' + schemaId) : '');\n const respBody = []\n\n return new Promise((resolve, reject) => {\n const req = https.request(url, reqOptions, (res) => {\n if (res.statusCode && (res.statusCode < 200 || res.statusCode > 299)) {\n return reject(\n new Error(\n \"Netlify Graph return non-OK HTTP status code\" + res.statusCode,\n ),\n )\n }\n\n res.on('data', (chunk) => respBody.push(chunk))\n\n res.on('end', () => {\n const resString = buffer.Buffer.concat(respBody).toString()\n resolve(resString)\n })\n })\n\n req.on('error', (error) => {\n console.error('Error making request to Netlify Graph:', error)\n })\n\n req.on('timeout', () => {\n req.destroy()\n reject(new Error('Request to Netlify Graph timed out'))\n })\n\n req.write(reqBody)\n req.end()\n })\n}") + "\n\n" + out(netlifyGraphConfig, ["browser"], "const httpGet = (input) => {\n const userHeaders = input.headers || {};\n const fullHeaders = {\n ...userHeaders,\n 'Content-Type': 'application/json',\n };\n\n const timeoutMs = 30_000;\n\n const reqOptions = {\n method: 'GET',\n headers: fullHeaders,\n timeout: timeoutMs,\n };\n\n const encodedVariables = encodeURIComponent(\n JSON.stringify(input.variables || null)\n );\n\n const schemaId = input.schemaId || " + (schemaId ? "\"" + schemaId + "\"" : "undefined") + ";\n\n const url =\n 'https://serve.onegraph.com/graphql?app_id=' +\n input.siteId +\n '&doc_id=' +\n input.docId +\n (input.operationName ? '&operationName=' + input.operationName : '') +\n (schemaId ? ('&schemaId=' + schemaId) : '') +\n '&variables=' +\n encodedVariables;\n\n return fetch(url, reqOptions).then((response) => response.text());\n};\n\nconst httpPost = (input) => {\n const userHeaders = input.headers || {};\n const fullHeaders = {\n ...userHeaders,\n 'Content-Type': 'application/json',\n };\n\n const reqBody = JSON.stringify({\n doc_id: input.docId,\n query: input.query,\n operationName: input.operationName,\n variables: input.variables,\n });\n\n const timeoutMs = 30_000;\n\n const reqOptions = {\n method: 'POST',\n headers: fullHeaders,\n timeout: timeoutMs,\n body: reqBody,\n };\n\n const schemaId = input.schemaId || " + (schemaId ? "\"" + schemaId + "\"" : "undefined") + ";\n\n const url = 'https://serve.onegraph.com/graphql?app_id=' + input.siteId +\n (schemaId ? ('&schemaId=' + schemaId) : '');\n\n return fetch(url, reqOptions).then((response) => response.text());\n};") + "\n\nconst fetchNetlifyGraph = function fetchNetlifyGraph(input) {\n const docId = input.doc_id;\n const operationName = input.operationName;\n const variables = input.variables;\n\n const options = input.options || {};\n const accessToken = options.accessToken;\n const siteId = options.siteId || process.env.SITE_ID;\n\n const httpMethod = input.fetchStrategy === 'GET' ? httpGet : httpPost;\n\n let response;\n\n if (input.fetchStrategy === 'GET') {\n response = httpMethod({\n siteId: siteId,\n docId: docId,\n query: input.query,\n headers: {\n Authorization: accessToken ? 'Bearer ' + accessToken : '',\n },\n variables: variables,\n operationName: operationName,\n }).then((result) => JSON.parse(result));\n } else {\n let cachedOrLiveValue = new Promise((resolve) => {\n const cacheKey = calculateCacheKey(payload);\n\n // Check the cache for a previous result\n const cachedResultPair = getFromCache(cache, cacheKey);\n\n let conditionalHeaders = {};\n let cachedResultValue;\n\n if (cachedResultPair) {\n const [etag, previousResult] = cachedResultPair;\n conditionalHeaders = {\n 'If-None-Match': etag,\n };\n cachedResultValue = previousResult;\n }\n\n const persistedResponse = httpMethod({\n siteId: siteId,\n docId: docId,\n query: input.query,\n headers: {\n ...conditionalHeaders,\n Authorization: accessToken ? 'Bearer ' + accessToken : '',\n },\n variables: variables,\n operationName: operationName,\n });\n\n persistedResponse.then((result) => {\n // Check response headers for a 304 Not Modified\n if (result.status === 304) {\n // Return the cached result\n resolve(cachedResultValue);\n }\n else if (result.status === 200) {\n // Update the cache with the new etag and result\n const etag = result.headers.get('ng-etag');\n const resultJson = result.json();\n resultJson.then((json) => {\n if (etag) {\n // Make a not of the new etag for the given payload\n setInCache(cache, cacheKey, [etag, json])\n };\n resolve(json);\n });\n } else {\n return result.json().then((json) => {\n resolve(json);\n });\n }\n });\n });\n\n response = cachedOrLiveValue;\n }\n\n return response;\n};\n";
};

@@ -318,3 +318,3 @@ var subscriptionParserReturnName = function (fn) {

var dummyHandler = exp(netlifyGraphConfig, ["node"], "handler", "() => {\n // return a 401 json response\n return {\n statusCode: 401,\n body: JSON.stringify({\n message: 'Unauthorized',\n }),\n }\n }");
var source = "/* eslint-disable */\n// @ts-nocheck\n// GENERATED VIA NETLIFY AUTOMATED DEV TOOLS, EDIT WITH CAUTION!\n " + imp(netlifyGraphConfig, ["node"], "buffer", "buffer") + "\n " + imp(netlifyGraphConfig, ["node"], "crypto", "crypto") + "\n " + imp(netlifyGraphConfig, ["node"], "https", "https") + "\n " + imp(netlifyGraphConfig, ["node"], "process", "process") + "\n\n" + exp(netlifyGraphConfig, ["node"], "verifySignature", "(input) => {\n const secret = input.secret\n const body = input.body\n const signature = input.signature\n\n if (!signature) {\n console.error('Missing signature')\n return false\n }\n\n const sig = {}\n for (const pair of signature.split(',')) {\n const [key, value] = pair.split('=')\n sig[key] = value\n }\n\n if (!sig.t || !sig.hmac_sha256) {\n console.error('Invalid signature header')\n return false\n }\n\n const hash = crypto\n .createHmac('sha256', secret)\n .update(sig.t)\n .update('.')\n .update(body)\n .digest('hex')\n\n if (\n !crypto.timingSafeEqual(\n Buffer.from(hash, 'hex'),\n Buffer.from(sig.hmac_sha256, 'hex')\n )\n ) {\n console.error('Invalid signature')\n return false\n }\n\n if (parseInt(sig.t, 10) < Date.now() / 1000 - 300 /* 5 minutes */) {\n console.error('Request is too old')\n return false\n }\n\n return true\n}") + "\n\n" + generatedNetlifyGraphDynamicClient(netlifyGraphConfig) + "\n\n" + exp(netlifyGraphConfig, ["node"], "verifyRequestSignature", "(request, options) => {\n const event = request.event\n const secret = options.webhookSecret || process.env.NETLIFY_GRAPH_WEBHOOK_SECRET\n const signature = event.headers['x-netlify-graph-signature']\n const body = event.body\n\n if (!secret) {\n console.error(\n 'NETLIFY_GRAPH_WEBHOOK_SECRET is not set, cannot verify incoming webhook request'\n )\n return false\n }\n\n return verifySignature({ secret, signature, body: body || '' })\n}") + "\n\n" + functionDecls.join("\n\n") + "\n\n/**\n * The generated NetlifyGraph library with your operations\n */\nconst functions = {\n " + exportedFunctionsObjectProperties + "\n}\n\n" + (netlifyGraphConfig.moduleType === "commonjs"
var source = "/* eslint-disable */\n// @ts-nocheck\n// GENERATED VIA NETLIFY AUTOMATED DEV TOOLS, EDIT WITH CAUTION!\n" + imp(netlifyGraphConfig, ["node"], "buffer", "buffer") + "\n" + imp(netlifyGraphConfig, ["node"], "crypto", "crypto") + "\n" + imp(netlifyGraphConfig, ["node"], "https", "https") + "\n" + imp(netlifyGraphConfig, ["node"], "process", "process") + "\n\n" + exp(netlifyGraphConfig, ["node"], "verifySignature", "(input) => {\n const secret = input.secret\n const body = input.body\n const signature = input.signature\n\n if (!signature) {\n console.error('Missing signature')\n return false\n }\n\n const sig = {}\n for (const pair of signature.split(',')) {\n const [key, value] = pair.split('=')\n sig[key] = value\n }\n\n if (!sig.t || !sig.hmac_sha256) {\n console.error('Invalid signature header')\n return false\n }\n\n const hash = crypto\n .createHmac('sha256', secret)\n .update(sig.t)\n .update('.')\n .update(body)\n .digest('hex')\n\n if (\n !crypto.timingSafeEqual(\n Buffer.from(hash, 'hex'),\n Buffer.from(sig.hmac_sha256, 'hex')\n )\n ) {\n console.error('Invalid signature')\n return false\n }\n\n if (parseInt(sig.t, 10) < Date.now() / 1000 - 300 /* 5 minutes */) {\n console.error('Request is too old')\n return false\n }\n\n return true\n}") + "\n\n" + generatedNetlifyGraphDynamicClient(netlifyGraphConfig) + "\n\n" + exp(netlifyGraphConfig, ["node"], "verifyRequestSignature", "(request, options) => {\n const event = request.event\n const secret = options.webhookSecret || process.env.NETLIFY_GRAPH_WEBHOOK_SECRET\n const signature = event.headers['x-netlify-graph-signature']\n const body = event.body\n\n if (!secret) {\n console.error(\n 'NETLIFY_GRAPH_WEBHOOK_SECRET is not set, cannot verify incoming webhook request'\n )\n return false\n }\n\n return verifySignature({ secret, signature, body: body || '' })\n}") + "\n\n" + functionDecls.join("\n\n") + "\n\n/**\n * The generated NetlifyGraph library with your operations\n */\nconst functions = {\n " + exportedFunctionsObjectProperties + "\n}\n\n" + (netlifyGraphConfig.moduleType === "commonjs"
? "exports.default = functions"

@@ -321,0 +321,0 @@ : "export default functions") + "\n\n" + dummyHandler;

{
"name": "netlify-onegraph-internal",
"version": "0.1.12",
"version": "0.1.13",
"description": "Internal tools for use by Netlify",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc