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

fireblocks-sdk

Package Overview
Dependencies
Maintainers
6
Versions
137
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fireblocks-sdk - npm Package Compare versions

Comparing version 3.1.4 to 4.0.0

2

dist/package.json
{
"name": "fireblocks-sdk",
"version": "3.1.4",
"version": "4.0.0",
"main": "dist/src/fireblocks-sdk.js",

@@ -5,0 +5,0 @@ "types": "dist/src/fireblocks-sdk.d.ts",

import { IAuthProvider } from "./iauth-provider";
import { RequestOptions } from "./types";
import { RequestOptions, TransactionPageResponse } from "./types";
import { SDKOptions } from "./fireblocks-sdk";

@@ -7,11 +7,12 @@ export declare class ApiClient {

private apiBaseUrl;
private options;
private options?;
private axiosInstance;
constructor(authProvider: IAuthProvider, apiBaseUrl: string, options: SDKOptions);
constructor(authProvider: IAuthProvider, apiBaseUrl: string, options?: SDKOptions);
private getUserAgent;
issueGetRequest(path: string, pageMode?: boolean): Promise<any>;
issuePostRequest(path: string, body: any, requestOptions?: RequestOptions): Promise<any>;
issuePutRequest(path: string, body: any): Promise<any>;
issuePatchRequest(path: string, body: any): Promise<any>;
issueDeleteRequest(path: string): Promise<any>;
issueGetRequestForTransactionPages(path: string): Promise<TransactionPageResponse>;
issueGetRequest<T>(path: string): Promise<T>;
issuePostRequest<T>(path: string, body: any, requestOptions?: RequestOptions): Promise<T>;
issuePutRequest<T>(path: string, body: any): Promise<T>;
issuePatchRequest<T>(path: string, body: any): Promise<T>;
issueDeleteRequest<T>(path: string): Promise<T>;
}

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

constructor(authProvider, apiBaseUrl, options) {
var _a, _b;
var _a, _b, _c, _d;
this.authProvider = authProvider;

@@ -36,2 +36,5 @@ this.apiBaseUrl = apiBaseUrl;

});
if ((_d = (_c = options === null || options === void 0 ? void 0 : options.customAxiosOptions) === null || _c === void 0 ? void 0 : _c.interceptors) === null || _d === void 0 ? void 0 : _d.response) {
this.axiosInstance.interceptors.response.use(options.customAxiosOptions.interceptors.response.onFulfilled, options.customAxiosOptions.interceptors.response.onRejected);
}
}

@@ -49,3 +52,3 @@ getUserAgent() {

}
issueGetRequest(path, pageMode = false) {
issueGetRequestForTransactionPages(path) {
return __awaiter(this, void 0, void 0, function* () {

@@ -56,11 +59,17 @@ const token = this.authProvider.signJwt(path);

});
if (pageMode) {
return {
transactions: res.data,
pageDetails: {
prevPage: res.headers["prev-page"] ? res.headers["prev-page"].toString() : "",
nextPage: res.headers["next-page"] ? res.headers["next-page"].toString() : "",
}
};
}
return {
transactions: res.data,
pageDetails: {
prevPage: res.headers["prev-page"] ? res.headers["prev-page"].toString() : "",
nextPage: res.headers["next-page"] ? res.headers["next-page"].toString() : "",
}
};
});
}
issueGetRequest(path) {
return __awaiter(this, void 0, void 0, function* () {
const token = this.authProvider.signJwt(path);
const res = yield this.axiosInstance.get(path, {
headers: { "Authorization": `Bearer ${token}` }
});
return res.data;

@@ -77,3 +86,4 @@ });

}
return (yield this.axiosInstance.post(path, body, { headers })).data;
const response = yield this.axiosInstance.post(path, body, { headers });
return response.data;
});

@@ -84,5 +94,6 @@ }

const token = this.authProvider.signJwt(path, body);
return (yield this.axiosInstance.put(path, body, {
const res = (yield this.axiosInstance.put(path, body, {
headers: { "Authorization": `Bearer ${token}` }
})).data;
}));
return res.data;
});

@@ -93,5 +104,6 @@ }

const token = this.authProvider.signJwt(path, body);
return (yield this.axiosInstance.patch(path, body, {
const res = (yield this.axiosInstance.patch(path, body, {
headers: { "Authorization": `Bearer ${token}` }
})).data;
}));
return res.data;
});

@@ -102,5 +114,6 @@ }

const token = this.authProvider.signJwt(path);
return (yield this.axiosInstance.delete(path, {
const res = (yield this.axiosInstance.delete(path, {
headers: { "Authorization": `Bearer ${token}` }
})).data;
}));
return res.data;
});

@@ -107,0 +120,0 @@ }

@@ -0,4 +1,5 @@

import { ApiClient } from "./api-client";
import { IAuthProvider } from "./iauth-provider";
import { AllocateFundsRequest, AssetResponse, AssetTypeResponse, CancelTransactionResponse, ConvertExchangeAssetResponse, CreateTransactionResponse, CreateTransferTicketArgs, CreateTransferTicketResponse, DeallocateFundsRequest, DepositAddressResponse, EstimateFeeResponse, EstimateTransactionFeeResponse, ExchangeResponse, ExecuteTermArgs, ExternalWalletAsset, FiatAccountResponse, GasStationInfo, GenerateAddressResponse, InternalWalletAsset, MaxSpendableAmountResponse, NetworkConnectionResponse, OffExchangeEntityResponse, OperationSuccessResponse, PagedVaultAccountsRequestFilters, PagedVaultAccountsResponse, PublicKeyInfoArgs, PublicKeyInfoForVaultAccountArgs, RequestOptions, ResendWebhooksResponse, TermResponse, TransactionArguments, TransactionFilter, TransactionPageFilter, TransactionPageResponse, TransactionResponse, TransferTicketResponse, User, ValidateAddressResponse, VaultAccountResponse, VaultAccountsFilter, VaultAssetResponse, VaultBalancesFilter, WalletContainerResponse, SetFeePayerConfiguration, FeePayerConfiguration, CreateWeb3ConnectionResponse, Session, NetworkConnectionRoutingPolicy, NetworkIdRoutingPolicy, NetworkIdResponse, TimePeriod, AuditsResponse, NFTOwnershipFilter, Token, TokenWithBalance, APIPagedResponse, CreateWalletConnectPayload, Web3ConnectionType, GetWeb3ConnectionsPayload, PublicKeyResponse, AllocateFundsResponse, SettleOffExchangeAccountResponse, GetNFTsFilter } from "./types";
import { AxiosProxyConfig } from "axios";
import { AllocateFundsRequest, AssetResponse, AssetTypeResponse, CancelTransactionResponse, ConvertExchangeAssetResponse, CreateTransactionResponse, DeallocateFundsRequest, DepositAddressResponse, EstimateFeeResponse, EstimateTransactionFeeResponse, ExchangeResponse, ExternalWalletAsset, FiatAccountResponse, GasStationInfo, GenerateAddressResponse, InternalWalletAsset, MaxSpendableAmountResponse, NetworkConnectionResponse, OffExchangeEntityResponse, OperationSuccessResponse, PagedVaultAccountsRequestFilters, PagedVaultAccountsResponse, PublicKeyInfoArgs, PublicKeyInfoForVaultAccountArgs, RequestOptions, ResendWebhooksResponse, TransactionArguments, TransactionFilter, TransactionPageFilter, TransactionPageResponse, TransactionResponse, User, ValidateAddressResponse, VaultAccountResponse, VaultAssetResponse, VaultBalancesFilter, WalletContainerResponse, SetFeePayerConfiguration, FeePayerConfiguration, CreateWeb3ConnectionResponse, Session, NetworkConnectionRoutingPolicy, NetworkIdRoutingPolicy, NetworkIdResponse, TimePeriod, AuditsResponse, NFTOwnershipFilter, Token, TokenWithBalance, Web3PagedResponse, CreateWalletConnectPayload, Web3ConnectionType, GetWeb3ConnectionsPayload, PublicKeyResponse, AllocateFundsResponse, GetNFTsFilter, SettleOffExchangeAccountResponse, PublicKeyInformation, DropTransactionResponse } from "./types";
import { AxiosProxyConfig, AxiosResponse } from "axios";
export * from "./types";

@@ -14,7 +15,18 @@ export interface SDKOptions {

userAgent?: string;
/**
* Providing custom axios options including a response interceptor (https://axios-http.com/docs/interceptors)
*/
customAxiosOptions?: {
interceptors?: {
response?: {
onFulfilled: (value: AxiosResponse<any, any>) => AxiosResponse<any, any> | Promise<AxiosResponse<any, any>>;
onRejected: (error: any) => any;
};
};
};
}
export declare class FireblocksSDK {
private authProvider;
private apiBaseUrl;
private apiClient;
private readonly authProvider;
private readonly apiBaseUrl;
private readonly apiClient;
/**

@@ -30,2 +42,6 @@ * Creates a new Fireblocks API Client

/**
* Get the instance of ApiClient used by the FireblocksSDK
*/
getApiClient(): ApiClient;
/**
* Gets all assets that are currently supported by Fireblocks

@@ -35,7 +51,2 @@ */

/**
* @deprecated this method is deprecated and will be removed in the future. Please use getVaultAccountsWithPageInfo instead.
* Gets all vault accounts for your tenant
*/
getVaultAccounts(filter?: VaultAccountsFilter): Promise<VaultAccountResponse[]>;
/**
* Gets a list of vault accounts per page matching the given filter or path

@@ -46,11 +57,5 @@ * @param pagedVaultAccountsRequestFilters Filters for the first request

/**
* @deprecated Replaced by getVaultAccountById.
* Gets a single vault account
* @param vaultAccountId The vault account ID
*/
getVaultAccount(vaultAccountId: string): Promise<VaultAccountResponse>;
/**
* Gets a single vault account
* @param vaultAccountId The vault account ID
*/
getVaultAccountById(vaultAccountId: string): Promise<VaultAccountResponse>;

@@ -130,3 +135,3 @@ /**

*/
setNetworkConnectionRoutingPolicy(connectionId: string, routingPolicy: NetworkConnectionRoutingPolicy): Promise<any>;
setNetworkConnectionRoutingPolicy(connectionId: string, routingPolicy: NetworkConnectionRoutingPolicy): Promise<void>;
/**

@@ -163,3 +168,3 @@ * Gets all discoverable network profiles

*/
setNetworkIdRoutingPolicy(networkId: string, routingPolicy: NetworkIdRoutingPolicy): Promise<any>;
setNetworkIdRoutingPolicy(networkId: string, routingPolicy: NetworkIdRoutingPolicy): Promise<void>;
/**

@@ -170,11 +175,5 @@ * Gets all exchange accounts for your tenant

/**
* @deprecated Replaced by getExchangeAccountById
* Gets a single exchange account by ID
* @param exchangeAccountId The exchange account ID
*/
getExchangeAccount(exchangeAccountId: string): Promise<ExchangeResponse>;
/**
* Gets a single exchange account by ID
* @param exchangeAccountId The exchange account ID
*/
getExchangeAccountById(exchangeAccountId: string): Promise<ExchangeResponse>;

@@ -420,35 +419,2 @@ /**

/**
* Creates a new transfer ticket
*/
createTransferTicket(options: CreateTransferTicketArgs, requestOptions?: RequestOptions): Promise<CreateTransferTicketResponse>;
/**
* Gets all transfer tickets
*/
getTransferTickets(): Promise<TransferTicketResponse[]>;
/**
* Get a transfer ticket by ticket ID
* @param ticketId
*/
getTransferTicketById(ticketId: string): Promise<TransferTicketResponse>;
/**
* Get a term of transfer ticket
* @param ticketId
* @param termId
*/
getTransferTicketTerm(ticketId: string, termId: string): Promise<TermResponse>;
/**
* Cancel the transfer ticket
* @param ticketId
* @param requestOptions
*/
cancelTransferTicket(ticketId: string, requestOptions?: RequestOptions): Promise<any>;
/**
* Executes a transaction for a single term of a transfer ticket
* @param ticketId
* @param termId
* @param options
* @param requestOptions
*/
executeTransferTicketTerm(ticketId: string, termId: string, options: ExecuteTermArgs, requestOptions?: RequestOptions): Promise<any>;
/**
* Deletes a single internal wallet

@@ -535,3 +501,3 @@ * @param walletId The internal wallet ID

*/
getPublicKeyInfo(args: PublicKeyInfoArgs): Promise<any>;
getPublicKeyInfo(args: PublicKeyInfoArgs): Promise<PublicKeyInformation>;
/**

@@ -571,3 +537,3 @@ * allocate funds from you default balance to a private ledger

*/
dropTransaction(txId: string, feeLevel?: string, requestedFee?: string, requestOptions?: RequestOptions): Promise<any>;
dropTransaction(txId: string, feeLevel?: string, requestedFee?: string, requestOptions?: RequestOptions): Promise<DropTransactionResponse>;
/**

@@ -661,3 +627,3 @@ * Get max spendable amount per asset and vault

*/
getWeb3Connections({ pageCursor, pageSize, sort, filter, order }?: GetWeb3ConnectionsPayload): Promise<APIPagedResponse<Session>>;
getWeb3Connections({ pageCursor, pageSize, sort, filter, order }?: GetWeb3ConnectionsPayload): Promise<Web3PagedResponse<Session>>;
/**

@@ -667,2 +633,3 @@ * Initiate a new web3 connection

* @param payload The payload for creating a new web3 connection
* @param requestOptions
* @param payload.vaultAccountId The vault account to link with the dapp

@@ -713,3 +680,3 @@ * @param payload.feeLevel The fee level for the connection

*/
getNFTs(filter: GetNFTsFilter): Promise<APIPagedResponse<Token>>;
getNFTs(filter: GetNFTsFilter): Promise<Web3PagedResponse<Token>>;
/**

@@ -725,3 +692,3 @@ *

*/
getOwnedNFTs(filter?: NFTOwnershipFilter): Promise<APIPagedResponse<TokenWithBalance>>;
getOwnedNFTs(filter?: NFTOwnershipFilter): Promise<Web3PagedResponse<TokenWithBalance>>;
/**

@@ -728,0 +695,0 @@ *

@@ -49,2 +49,8 @@ "use strict";

/**
* Get the instance of ApiClient used by the FireblocksSDK
*/
getApiClient() {
return this.apiClient;
}
/**
* Gets all assets that are currently supported by Fireblocks

@@ -58,12 +64,2 @@ */

/**
* @deprecated this method is deprecated and will be removed in the future. Please use getVaultAccountsWithPageInfo instead.
* Gets all vault accounts for your tenant
*/
getVaultAccounts(filter) {
return __awaiter(this, void 0, void 0, function* () {
const url = `/v1/vault/accounts?${query_string_1.default.stringify(filter)}`;
return yield this.apiClient.issueGetRequest(url);
});
}
/**
* Gets a list of vault accounts per page matching the given filter or path

@@ -78,15 +74,5 @@ * @param pagedVaultAccountsRequestFilters Filters for the first request

/**
* @deprecated Replaced by getVaultAccountById.
* Gets a single vault account
* @param vaultAccountId The vault account ID
*/
getVaultAccount(vaultAccountId) {
return __awaiter(this, void 0, void 0, function* () {
return yield this.getVaultAccountById(vaultAccountId);
});
}
/**
* Gets a single vault account
* @param vaultAccountId The vault account ID
*/
getVaultAccountById(vaultAccountId) {

@@ -288,15 +274,5 @@ return __awaiter(this, void 0, void 0, function* () {

/**
* @deprecated Replaced by getExchangeAccountById
* Gets a single exchange account by ID
* @param exchangeAccountId The exchange account ID
*/
getExchangeAccount(exchangeAccountId) {
return __awaiter(this, void 0, void 0, function* () {
return yield this.getExchangeAccount(exchangeAccountId);
});
}
/**
* Gets a single exchange account by ID
* @param exchangeAccountId The exchange account ID
*/
getExchangeAccountById(exchangeAccountId) {

@@ -431,3 +407,3 @@ return __awaiter(this, void 0, void 0, function* () {

if (pageFilter) {
return yield this.apiClient.issueGetRequest(`/v1/transactions?${query_string_1.default.stringify(pageFilter)}`, true);
return yield this.apiClient.issueGetRequestForTransactionPages(`/v1/transactions?${query_string_1.default.stringify(pageFilter)}`);
}

@@ -437,5 +413,7 @@ else if (nextOrPreviousPath) {

const path = nextOrPreviousPath.substring(index, nextOrPreviousPath.length);
return yield this.apiClient.issueGetRequest(path, true);
return yield this.apiClient.issueGetRequestForTransactionPages(path);
}
return { transactions: [], pageDetails: { prevPage: "", nextPage: "" } };
return {
transactions: [], pageDetails: { prevPage: "", nextPage: "" },
};
});

@@ -759,59 +737,2 @@ }

/**
* Creates a new transfer ticket
*/
createTransferTicket(options, requestOptions) {
return __awaiter(this, void 0, void 0, function* () {
return yield this.apiClient.issuePostRequest("/v1/transfer_tickets", options, requestOptions);
});
}
/**
* Gets all transfer tickets
*/
getTransferTickets() {
return __awaiter(this, void 0, void 0, function* () {
return yield this.apiClient.issueGetRequest("/v1/transfer_tickets");
});
}
/**
* Get a transfer ticket by ticket ID
* @param ticketId
*/
getTransferTicketById(ticketId) {
return __awaiter(this, void 0, void 0, function* () {
return yield this.apiClient.issueGetRequest(`/v1/transfer_tickets/${ticketId}`);
});
}
/**
* Get a term of transfer ticket
* @param ticketId
* @param termId
*/
getTransferTicketTerm(ticketId, termId) {
return __awaiter(this, void 0, void 0, function* () {
return yield this.apiClient.issueGetRequest(`/v1/transfer_tickets/${ticketId}/${termId}`);
});
}
/**
* Cancel the transfer ticket
* @param ticketId
* @param requestOptions
*/
cancelTransferTicket(ticketId, requestOptions) {
return __awaiter(this, void 0, void 0, function* () {
return yield this.apiClient.issuePostRequest(`/v1/transfer_tickets/${ticketId}/cancel`, {}, requestOptions);
});
}
/**
* Executes a transaction for a single term of a transfer ticket
* @param ticketId
* @param termId
* @param options
* @param requestOptions
*/
executeTransferTicketTerm(ticketId, termId, options, requestOptions) {
return __awaiter(this, void 0, void 0, function* () {
return yield this.apiClient.issuePostRequest(`/v1/transfer_tickets/${ticketId}/${termId}/transfer`, options, requestOptions);
});
}
/**
* Deletes a single internal wallet

@@ -957,3 +878,3 @@ * @param walletId The internal wallet ID

if (args.derivationPath) {
url += `&derivationPath=${args.derivationPath}`;
url += `&derivationPath=${JSON.stringify(args.derivationPath)}`;
}

@@ -960,0 +881,0 @@ if (args.compressed) {

@@ -0,1 +1,9 @@

import { AxiosResponseHeaders } from "axios";
export interface Web3PagedResponse<T> {
data: T[];
paging?: Paging;
}
export declare type APIResponseHeaders = AxiosResponseHeaders & {
"x-request-id"?: string;
};
export interface VaultAccountResponse {

@@ -333,3 +341,3 @@ id: string;

algorithm: string;
derivationPath: string;
derivationPath: number[];
signature: {

@@ -451,6 +459,2 @@ fullSig: string;

}
export interface APIPagedResponse<T> {
data: T[];
paging?: Paging;
}
export interface Token {

@@ -616,3 +620,3 @@ id: string;

algorithm?: string;
derivationPath?: string;
derivationPath?: number[];
compressed?: boolean;

@@ -643,2 +647,11 @@ }

}
export interface PublicKeyInformation {
algorithm: string;
derivationPath: number[];
publicKey: String;
}
export interface DropTransactionResponse {
success: boolean;
transactions?: string[];
}
export interface MaxSpendableAmountResponse {

@@ -645,0 +658,0 @@ maxSpendableAmount: string;

{
"name": "fireblocks-sdk",
"version": "3.1.4",
"version": "4.0.0",
"main": "dist/src/fireblocks-sdk.js",

@@ -5,0 +5,0 @@ "types": "dist/src/fireblocks-sdk.d.ts",

@@ -8,2 +8,5 @@ ## The Official Javascript & Typescript SDK for Fireblocks API

## V4 Migration
Please read the [following](./docs/V4-MIGRATION.md) guide for migration
## Usage

@@ -14,3 +17,3 @@ #### Before You Begin

#### Requirements
- [node.js](https://nodejs.org) v6.3.1 or newer
- [node.js](https://nodejs.org) v12 or newer

@@ -59,1 +62,37 @@ #### Installation

```
#### Axios Interceptor
You can provide the sdk options with an [axios response interceptor](https://axios-http.com/docs/interceptors):
```ts
new FireblocksSDK(privateKey, userId, serverAddress, undefined, {
customAxiosOptions: {
interceptors: {
response: {
onFulfilled: (response) => {
console.log(`Request ID: ${response.headers["x-request-id"]}`);
return response;
},
onRejected: (error) => {
console.log(`Request ID: ${error.response.headers["x-request-id"]}`);
throw error;
}
}
}
}
});
```
#### Error Handling
The SDK throws `AxiosError` upon http errors for API requests.
You can read more about axios error handling [here](https://axios-http.com/docs/handling_errors).
You can get more data on the Fireblocks error using the following fields:
- `error.response.data.code`: The Fireblocks error code, should be provided on support tickets
- `error.response.data.message`: Explanation of the Fireblocks error
- `error.response.headers['x-request-id']`: The request ID correlated to the API request, should be provided on support tickets / Github issues

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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