Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
Object.defineProperty(exports, "__esModule", { value: true });
var axios_1 = require("axios");
var gcpMetadata = require("gcp-metadata");
var rax = require("retry-axios");
var oauth2client_1 = require("./oauth2client");
// Create a scoped axios instance that will retry 3 times by default
var ax = axios_1.default.create();
rax.attach(ax);
var Compute = /** @class */ (function (_super) {
__extends(Compute, _super);
/**
* Google Compute Engine service account credentials.
*
* Retrieve access token from the metadata server.
* See: https://developers.google.com/compute/docs/authentication
*/
function Compute(options) {
var _this = _super.call(this, options) || this;
// Start with an expired refresh token, which will automatically be
// refreshed before the first API call is made.
_this.credentials = { expiry_date: 1, refresh_token: 'compute-placeholder' };
return _this;
}
/**
export const nodeApi = (baseUrl, useCustomRequestConfig) => {
const trimmedUrl = Strings.trimEnd(baseUrl, '/');
const config = buildAxiosConfig(useCustomRequestConfig);
const nodeAxios = axios.create(config);
const get = (url, config) => nodeAxios.get(trimmedUrl + url, config);
const retryableAxios = axios.create(config);
retryableAxios.defaults.raxConfig = buildRetryableAxiosConfig(retryableAxios);
rax.attach(retryableAxios);
const retryableGet = (url, config) => retryableAxios.get(trimmedUrl + url, config);
return {
version: () => get('/node/version'),
baseTarget: () => get('/consensus/basetarget'),
addresses: {
details: (address) => retryableGet(`/addresses/balance/details/${address}`),
aliases: (address) => retryableGet(`/alias/by-address/${address}`),
validate: (address) => retryableGet(`/addresses/validate/${address}`),
data: (address) => retryableGet(`/addresses/data/${address}`),
script: (address) => retryableGet(`/addresses/scriptInfo/${address}`)
},
blocks: {
height: () => get('/blocks/height'),
heightBySignature: (signature) => get(`/blocks/height/${signature}`),
delay: (fromSignature, count) => get(`/blocks/delay/${fromSignature}/${count}`),