Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
branch: branch,
path,
withAccessToken: !!accessToken,
});
if (repo.private === true) {
const params = { owner: repo.owner.login, repo: repo.name, path: path };
// https://octokit.github.io/rest.js/#api-Repos-getContent
return fetchWithOctokit('repos.getContents', params, accessToken).then(
getContent,
);
}
const relativeUrl = `/${repo.owner.login}/${repo.name}/${branch}/${path}`;
logger.verbose(`Fetching file from public repo ${relativeUrl}`);
return fetch(`${baseRawUrl}${relativeUrl}`).then(response => {
if (response.status === 200) {
return response.text();
}
throw new Error(`Can't fetch ${path} from ${relativeUrl}.`);
});
}
static isOnline( callback ) {
// temporary until we have a ping API
fetch( "/pages/about", {
method: "head",
mode: "no-cors",
cache: "no-store" } ).
then( ( ) => callback( true ) ).
catch( ( ) => callback( false ) );
}
async function fetchGasPrice() {
const res = await fetch(GAS_STATION_URL)
if (res.status !== 200) {
throw new Error(`Fetch returned code ${res.status}`)
}
const jason = await res.json()
if (typeof jason[GAS_PRICE_KEY] !== 'undefined') {
// values come from EGS as tenths of gwei
return jason[GAS_PRICE_KEY] * 1e8
}
throw new Error(`Gas key of ${GAS_PRICE_KEY} is unavailable`)
}
mergeScanLatest(async (_acc, dependencies) => {
const resolvedDependencies: ResolvedDependencies = await fetch(RESOLVE_URL, {
method: 'POST',
body: JSON.stringify(dependencies),
mode: 'no-cors',
headers,
}).then(async (res) => {
if (!res.ok) {
throw new FetchError(RESOLVE_URL, res.status, res.statusText);
}
return res.json();
});
await handleDependencies(fs, queue, resolvedDependencies);
}),
retryBackoff(1000),
const fetchRemoteFile = async (uri, options) => {
const response = await fetch(uri, options);
const buffer = await (response.buffer
? response.buffer()
: response.arrayBuffer());
return buffer.constructor.name === 'Buffer' ? buffer : Buffer.from(buffer);
};
private async checkRPC(rpcPath: string): Promise {
try {
const response = await fetch(this.getAddress(rpcPath));
return response.ok;
} catch (error) {
if (error.code !== 'ECONNREFUSED') {
this.monitor.withData({ [this.monitor.labels.HTTP_PATH]: rpcPath }).logError({
name: 'http_client_request',
message: 'Failed to check RPC.',
error,
});
}
return false;
}
}
static authorize = (email, adminUrl) => {
const config = {
method: 'post',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({ email, admin_url: adminUrl })
};
return fetch('https://api.cezerin.com/v1/account/authorize', config).then(
RestClient.returnStatusAndJson
);
};
}
async _getWrapperKey () {
const siteUrl = 'http' + (this.instance.secure ? 's' : '') + '://' + this.instance.host + ':' + this.instance.port + '/' + this.site
const wrapperRequest = await fetch(siteUrl, { headers: { Accept: 'text/html' } })
const wrapperBody = await wrapperRequest.text()
const wrapperKey = wrapperBody.match(/wrapper_key = "(.*?)"/)[1]
return wrapperKey
}
async checkProvider() {
/**
* Call the options requests to node URL.
*/
try {
await fetch(this.provider);
this.status = true;
} catch(err) {
this.status = false;
}
return this.status;
}
return dispatch => {
dispatch(requestSchemas());
return fetch(`${apiUrl}/schema`)
.then(response => response.json())
.then(json => dispatch(receiveSchemas(json)));
};
}