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

@altangent/lib-coinbase

Package Overview
Dependencies
Maintainers
2
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@altangent/lib-coinbase - npm Package Compare versions

Comparing version 0.9.1 to 0.10.0

dist/Options.d.ts

10

dist/CoinbaseClient.d.ts
/// <reference types="node" />
import { Pagination } from "./Options";
import { Results } from "./Results";

@@ -11,11 +12,12 @@ export declare class CoinbaseClient {

getUser(userid: string): Promise<Results.SingleResult<Results.User>>;
getAccounts(): Promise<Results.PagedResult<Results.Account>>;
getAccounts(options?: Pagination): Promise<Results.PagedResult<Results.Account>>;
getAccount(accountid: string): Promise<Results.SingleResult<Results.Account>>;
getAddresses(accountid: string): Promise<Results.PagedResult<Results.Address>>;
getAddresses(accountid: string, options?: Pagination): Promise<Results.PagedResult<Results.Address>>;
getAddress(accountid: string, address: string): Promise<Results.SingleResult<Results.Address>>;
getTransactions(accountid: string): Promise<Results.PagedResult<Results.Transaction>>;
getTransactions(accountid: string, options?: Pagination): Promise<Results.PagedResult<Results.Transaction>>;
getTransaction(accountid: string, transactionId: string): Promise<Results.SingleResult<Results.Transaction>>;
request<T>(path: string): Promise<T>;
request<T>(path: string, query?: any): Promise<T>;
protected _cleanOptions(options: any): any;
protected _createSigData(timestamp: number, method: string, path: string, body: string): string;
protected _sign(data: string, key: string): Buffer;
}

34

dist/CoinbaseClient.js

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

exports.CoinbaseClient = void 0;
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
const lib_http_1 = require("@altangent/lib-http");
const querystring_1 = __importDefault(require("querystring"));
const crypto_1 = __importDefault(require("crypto"));

@@ -25,5 +28,6 @@ class CoinbaseClient {

}
getAccounts() {
getAccounts(options) {
const path = `/v2/accounts`;
return this.request(path);
const query = this._cleanOptions(options);
return this.request(path, query);
}

@@ -34,5 +38,6 @@ getAccount(accountid) {

}
getAddresses(accountid) {
getAddresses(accountid, options) {
const path = `/v2/accounts/${accountid}/addresses`;
return this.request(path);
const query = this._cleanOptions(options);
return this.request(path, query);
}

@@ -43,5 +48,6 @@ getAddress(accountid, address) {

}
getTransactions(accountid) {
getTransactions(accountid, options) {
const path = `/v2/accounts/${accountid}/transactions`;
return this.request(path);
const query = this._cleanOptions(options);
return this.request(path, query);
}

@@ -52,9 +58,10 @@ getTransaction(accountid, transactionId) {

}
request(path) {
request(path, query) {
const key = this.key;
const keysecret = this.keysecret;
const pathQuery = query ? path + "?" + querystring_1.default.encode(query) : path;
const timestamp = Math.floor(new Date().getTime() / 1000);
const method = "GET";
const body = "";
const sig = this._sign(this._createSigData(timestamp, method, path, body), keysecret);
const sig = this._sign(this._createSigData(timestamp, method, pathQuery, body), keysecret);
const headers = {

@@ -66,6 +73,15 @@ "CB-ACCESS-SIGN": sig.toString("hex"),

};
const url = this.urlbase + path;
const url = this.urlbase + pathQuery;
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
return (0, lib_http_1.request)({ url, method, headers });
}
_cleanOptions(options) {
const result = {};
for (const key in options) {
if (options[key] !== undefined) {
result[key] = options[key];
}
}
return result;
}
_createSigData(timestamp, method, path, body) {

@@ -72,0 +88,0 @@ return `${timestamp}${method.toUpperCase()}${path}${body}`;

export * from "./CoinbaseClient";
export * from "./Results";
export * from "./Options";

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

__exportStar(require("./Results"), exports);
__exportStar(require("./Options"), exports);
//# sourceMappingURL=index.js.map

@@ -8,2 +8,4 @@ export declare namespace Results {

starting_after: string;
previous_ending_before: string;
next_starting_after: string;
limit: number;

@@ -72,9 +74,32 @@ order: string;

resource_path: string;
details: any;
network?: any;
to?: any;
from?: any;
details: Partial<Details>;
network?: Partial<Network>;
to?: Partial<To>;
from?: Partial<From>;
address?: any;
application?: any;
};
type Network = {
status: string;
status_description: string;
hash: string;
transaction_url: string;
};
type From = {
resource: string;
currency: string;
};
type To = {
resource: string;
address: string;
currency: string;
address_url: string;
};
type Details = {
title: string;
subtitle: string;
header: string;
health: string;
payment_method_name: string;
};
}

@@ -0,3 +1,7 @@

/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
import { request } from "@altangent/lib-http";
import qs from "querystring";
import crypto from "crypto";
import { Pagination } from "./Options";
import { Results } from "./Results";

@@ -23,5 +27,6 @@

public getAccounts(): Promise<Results.PagedResult<Results.Account>> {
public getAccounts(options?: Pagination): Promise<Results.PagedResult<Results.Account>> {
const path = `/v2/accounts`;
return this.request(path);
const query = this._cleanOptions(options);
return this.request(path, query);
}

@@ -34,5 +39,9 @@

public getAddresses(accountid: string): Promise<Results.PagedResult<Results.Address>> {
public getAddresses(
accountid: string,
options?: Pagination,
): Promise<Results.PagedResult<Results.Address>> {
const path = `/v2/accounts/${accountid}/addresses`;
return this.request(path);
const query = this._cleanOptions(options);
return this.request(path, query);
}

@@ -48,5 +57,9 @@

public getTransactions(accountid: string): Promise<Results.PagedResult<Results.Transaction>> {
public getTransactions(
accountid: string,
options?: Pagination,
): Promise<Results.PagedResult<Results.Transaction>> {
const path = `/v2/accounts/${accountid}/transactions`;
return this.request(path);
const query = this._cleanOptions(options);
return this.request(path, query);
}

@@ -62,10 +75,12 @@

public request<T>(path: string): Promise<T> {
public request<T>(path: string, query?: any): Promise<T> {
const key = this.key;
const keysecret = this.keysecret;
const pathQuery = query ? path + "?" + qs.encode(query) : path;
const timestamp = Math.floor(new Date().getTime() / 1000);
const method = "GET";
const body = "";
const sig = this._sign(this._createSigData(timestamp, method, path, body), keysecret);
const sig = this._sign(this._createSigData(timestamp, method, pathQuery, body), keysecret);

@@ -79,3 +94,3 @@ const headers = {

const url = this.urlbase + path;
const url = this.urlbase + pathQuery;

@@ -86,2 +101,12 @@ // eslint-disable-next-line @typescript-eslint/no-unsafe-call

protected _cleanOptions(options: any): any {
const result = {};
for (const key in options) {
if (options[key] !== undefined) {
result[key] = options[key];
}
}
return result;
}
protected _createSigData(

@@ -88,0 +113,0 @@ timestamp: number,

export * from "./CoinbaseClient";
export * from "./Results";
export * from "./Options";

@@ -10,2 +10,4 @@ /* eslint-disable @typescript-eslint/no-namespace */

starting_after: string;
previous_ending_before: string;
next_starting_after: string;
limit: number;

@@ -82,9 +84,36 @@ order: string;

resource_path: string;
details: any;
network?: any;
to?: any;
from?: any;
details: Partial<Details>;
network?: Partial<Network>;
to?: Partial<To>;
from?: Partial<From>;
address?: any;
application?: any;
};
export type Network = {
status: string;
status_description: string;
hash: string;
transaction_url: string;
};
export type From = {
resource: string;
currency: string;
};
export type To = {
resource: string;
address: string;
currency: string;
address_url: string;
};
export type Details = {
title: string;
subtitle: string;
header: string;
health: string;
payment_method_name: string;
};
}
{
"name": "@altangent/lib-coinbase",
"version": "0.9.1",
"version": "0.10.0",
"description": "Coinbase API client",

@@ -27,3 +27,3 @@ "author": "Brian Mancini <bmancini@gmail.com>",

"dependencies": {
"@altangent/lib-http": "^0.9.1"
"@altangent/lib-http": "^0.10.0"
},

@@ -33,3 +33,3 @@ "publishConfig": {

},
"gitHead": "2d434edf04b2626b395ef68ab414931a05b2fd04"
"gitHead": "3a97f77d3e45056ad90da16ecaaf4d3a367fd56c"
}

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