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

@blockfrost/blockfrost-js

Package Overview
Dependencies
Maintainers
2
Versions
105
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@blockfrost/blockfrost-js - npm Package Compare versions

Comparing version 0.6.0 to 0.7.0

8

CHANGELOG.MD

@@ -8,2 +8,10 @@ # Changelog

## [0.7.0] - 2021-06-23
### Added
- `retryCount` param
- `retryDelay` param
- axios `requestTimeout` params
## [0.6.0] - 2021-06-22

@@ -10,0 +18,0 @@

3

lib/index.d.ts

@@ -14,3 +14,3 @@ import { components } from './types/OpenApi';

import { txs, txsDelegations, txsMetadataCbor, txsPoolRetires, txsPoolUpdates, txsStakes, txsUtxos, txsWithdrawals, txsMirs, txsMetadata, txSubmit } from './endpoints/txs';
import { Options } from './types';
import { Options, ValidatedOptions } from './types';
declare class BlockFrostAPI {

@@ -20,2 +20,3 @@ apiUrl: string;

userAgent?: string;
options: ValidatedOptions;
constructor(options?: Options);

@@ -22,0 +23,0 @@ /**

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

constructor(options) {
var _a;
var _a, _b;
/**

@@ -563,12 +563,15 @@ * accounts - Obtain information about a specific stake account.

this.txSubmit = txs_1.txSubmit;
const opts = utils_1.validateOptions(options);
const apiBase = opts.isTestnet ? config_1.API_URLS.testnet : config_1.API_URLS.mainnet;
this.apiUrl = (options === null || options === void 0 ? void 0 : options.customBackend) || url_join_1.default(apiBase, `v${opts.version}`);
this.projectId = opts.projectId;
this.options = utils_1.validateOptions(options);
const apiBase = this.options.isTestnet
? config_1.API_URLS.testnet
: config_1.API_URLS.mainnet;
this.apiUrl =
((_a = this.options) === null || _a === void 0 ? void 0 : _a.customBackend) || url_join_1.default(apiBase, `v${this.options.version}`);
this.projectId = this.options.projectId;
this.userAgent =
(_a = options === null || options === void 0 ? void 0 : options.userAgent) !== null && _a !== void 0 ? _a : `${packageJson.name}@${packageJson.version}`;
if (opts.retry429) {
(_b = options === null || options === void 0 ? void 0 : options.userAgent) !== null && _b !== void 0 ? _b : `${packageJson.name}@${packageJson.version}`;
if (this.options.retry429) {
axios_retry_1.default(axios_1.default, {
retries: 20,
retryDelay: () => 1000,
retries: this.options.retryCount,
retryDelay: () => this.options.retryDelay,
retryCondition: err => {

@@ -580,4 +583,5 @@ var _a;

}
axios_1.default.defaults.timeout = this.options.requestTimeout;
}
}
exports.BlockFrostAPI = BlockFrostAPI;

@@ -15,2 +15,5 @@ import { AxiosError } from 'axios';

userAgent?: string;
requestTimeout?: number;
retryCount?: number;
retryDelay?: number;
};

@@ -24,2 +27,5 @@ export declare type Options = (OptionCombination1 | OptionCombination2) & AdditionalOptions;

retry429: boolean;
requestTimeout: number;
retryCount: number;
retryDelay: number;
}

@@ -26,0 +32,0 @@ export interface Headers {

@@ -6,2 +6,3 @@ "use strict";

const validateOptions = (options) => {
var _a, _b, _c;
if (!options || (!options.customBackend && !options.projectId)) {

@@ -16,2 +17,11 @@ throw Error('Missing customBackend or projectId option');

}
if (options.requestTimeout && isNaN(options.requestTimeout)) {
throw Error('Param requestTimeout is not a number');
}
if (options.retryDelay && isNaN(options.retryDelay)) {
throw Error('Param retryDelay is not a number');
}
if (options.retryCount && isNaN(options.retryCount)) {
throw Error('Param retryCount is not a number');
}
return {

@@ -23,2 +33,5 @@ customBackend: options.customBackend,

retry429: options.retry429 || true,
retryCount: (_a = options.retryCount) !== null && _a !== void 0 ? _a : 20,
retryDelay: (_b = options.retryDelay) !== null && _b !== void 0 ? _b : 1000,
requestTimeout: (_c = options.requestTimeout) !== null && _c !== void 0 ? _c : 20000, // 20 seconds
};

@@ -44,2 +57,3 @@ };

const handleError = (error) => {
var _a, _b, _c;
if (error.code && error.errno) {

@@ -54,10 +68,29 @@ // system errors such as -3008 ENOTFOUND

if (error.response) {
return error.response.data;
if (typeof error.response.data === 'object' &&
((_a = error.response.data) === null || _a === void 0 ? void 0 : _a.status_code)) {
// response.data is already properly formatted
return error.response.data;
}
// response.data may contain html output (eg. errors returned by nginx)
const statusCode = error.response.status;
const statusText = error.response.statusText;
return {
status_code: statusCode,
message: `${statusCode}: ${statusText}`,
error: statusText,
};
}
else if (error.request) {
return error.request.data;
const jsonError = error.toJSON();
const message = (_b = jsonError.message) !== null && _b !== void 0 ? _b : 'Unexpected error while sending a request';
const errorName = (_c = jsonError.error) !== null && _c !== void 0 ? _c : 'Error';
return `${errorName}: ${message}`;
}
else {
else if (error.message) {
return error.message;
}
else {
// we shouldn't get here, but just to be safe...
return 'Unexpected error';
}
};

@@ -64,0 +97,0 @@ exports.handleError = handleError;

{
"name": "@blockfrost/blockfrost-js",
"version": "0.6.0",
"version": "0.7.0",
"description": "A JavaScript/TypeScript SDK for interacting with the https://blockfrost.io API",

@@ -27,7 +27,7 @@ "files": [

"dependencies": {
"@blockfrost/openapi": "^0.1.19",
"@yarnpkg/pnpify": "^2.4.0",
"@blockfrost/openapi": "^0.1.21",
"@yarnpkg/pnpify": "3.0.0-rc.6",
"axios": "^0.21.1",
"axios-retry": "^3.1.9",
"dotenv": "^8.2.0",
"dotenv": "^10.0.0",
"rimraf": "^3.0.2",

@@ -37,23 +37,23 @@ "url-join": "^4.0.1"

"devDependencies": {
"@types/jest": "^26.0.22",
"@types/node": "^14.14.37",
"@types/jest": "^26.0.23",
"@types/node": "^15.12.4",
"@types/url-join": "^4.0.0",
"@typescript-eslint/eslint-plugin": "^4.21.0",
"@typescript-eslint/parser": "4.21.0",
"@typescript-eslint/eslint-plugin": "^4.28.0",
"@typescript-eslint/parser": "4.28.0",
"babel-plugin-module-resolver": "^4.1.0",
"eslint": "7.14.0",
"eslint": "7.29.0",
"eslint-config-airbnb-base": "14.2.1",
"eslint-config-prettier": "6.15.0",
"eslint-plugin-import": "2.22.1",
"eslint-plugin-prettier": "3.1.4",
"jest": "^26.6.3",
"openapi-typescript": "^3.0.1",
"prettier": "2.2.0",
"ts-jest": "^26.4.4",
"ts-node": "9.0.0",
"ts-node-dev": "^1.0.0",
"tsc-watch": "^4.2.8",
"eslint-config-prettier": "8.3.0",
"eslint-plugin-import": "2.23.4",
"eslint-plugin-prettier": "3.4.0",
"jest": "^27.0.5",
"openapi-typescript": "^4.0.1",
"prettier": "2.3.1",
"ts-jest": "^27.0.3",
"ts-node": "10.0.0",
"ts-node-dev": "^1.1.6",
"tsc-watch": "^4.4.0",
"tsconfig-paths": "^3.9.0",
"typedoc": "^0.20.35",
"typescript": "4.2.3"
"typedoc": "^0.21.0",
"typescript": "4.3.4"
},

@@ -60,0 +60,0 @@ "engines": {

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