protected async nonInstanceFetch (url: string, options: RequestInit = {}, headers = {}) { const fetchOptions = Object.assign({}, generalOptions, options) const res = await nodeFetch(url, { headers: { 'content-type': 'application/json', ...headers }, ...fetchOptions }) const json = await parseJSON(res) return checkStatus(json) }
const handleRequest = function(route, method, data){ if(!settingsCookie["lightcord-5"]){ return Promise.reject(new LightcordError("The current settings blocked the request.")) } return nodeFetch(`${Constants.SERVER_URL}/api/v1${route}`, { method, headers: { "CLIENT": "Lightcord", "Authorization": window.Lightcord.Api.Authorization || "None::Anonymous" }, ...(data ? { body: data } : {}) }) }
if(!attachment.filename.endsWith(".plugin.js") && !attachment.filename.endsWith(".theme.css"))return document.getElementById(id).remove() nodeFetch(attachment.url, { headers: { "User-Agent": electron.ipcRenderer.sendSync("LIGHTCORD_GET_USER_AGENT")
protected async fetch (url: string, options: RequestInit = {}, headers = {}): Promise<any> { const headersToSend = Object.assign( { 'content-type': 'application/json', 'x-api-key': this.instance.token }, headers, options.headers ) delete options.headers const fetchOptions = Object.assign({}, generalOptions, options) const res = await nodeFetch(url, { headers: headersToSend, ...fetchOptions }) const json = await parseJSON(res) return checkStatus(json) }
export function checkHash(hash, data, filename, resultCallback, removeCallback){ console.log(`File: ${filename} hash: ${hash}`) if(!cache[hash]){ nodeFetch("https://cdn.jsdelivr.net/gh/Lightcord/filehashes@master/hashes/"+hash, { // Using node-fetch to bypass cors headers: { "User-Agent": electron.ipcRenderer.sendSync("LIGHTCORD_GET_USER_AGENT") // have to set user-agent
let link = getKeyedArray(cache2).find(e => e[1] === result.hash)[0] nodeFetch(link) .then(async res => { if(res.status !== 200)throw new Error("Status was not 200")
defer: true, fn: defer => { return nodeFetch(options.uri) .then(response => response.text()) .then(text => {
let link = getKeyedArray(cache2).find(e => e[1] === result.hash)[0] console.log(link) nodeFetch(link) .then(async res => { if(res.status !== 200)throw new Error("Status was not 200")
const handleRequest = function(route, method, data){ if(!settingsCookie["lightcord-5"]){ return Promise.reject(new LightcordError("The current settings blocked the request.")) } return nodeFetch(`${Constants.SERVER_URL}/api/v1${route}`, { method, headers: { "CLIENT": "Lightcord", "Authorization": window.Lightcord.Api.Authorization || "None::Anonymous" }, ...(data ? { body: data } : {}) }) }
if(!attachment.filename.endsWith(".plugin.js") && !attachment.filename.endsWith(".theme.css"))return document.getElementById(id).remove() nodeFetch(attachment.url, { headers: { "User-Agent": electron.ipcRenderer.sendSync("LIGHTCORD_GET_USER_AGENT")
export function checkHash(hash, data, filename, resultCallback, removeCallback){ console.log(`File: ${filename} hash: ${hash}`) if(!cache[hash]){ nodeFetch("https://cdn.jsdelivr.net/gh/Lightcord/filehashes@master/hashes/"+hash, { // Using node-fetch to bypass cors headers: { "User-Agent": electron.ipcRenderer.sendSync("LIGHTCORD_GET_USER_AGENT") // have to set user-agent
let link = getKeyedArray(cache2).find(e => e[1] === result.hash)[0] nodeFetch(link) .then(async res => { if(res.status !== 200)throw new Error("Status was not 200")
let link = getKeyedArray(cache2).find(e => e[1] === result.hash)[0] console.log(link) nodeFetch(link) .then(async res => { if(res.status !== 200)throw new Error("Status was not 200")