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

@banked/node

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@banked/node - npm Package Compare versions

Comparing version 0.0.5 to 0.0.6

dist/validators/request-config.js

4

CHANGELOG.md

@@ -5,2 +5,6 @@ # Changelog

### [0.0.6](https://github.com/banked/banked-node/compare/v0.0.5...v0.0.6) (2020-03-13)
### [0.0.5](https://github.com/banked/banked-node/compare/v0.0.4...v0.0.5) (2020-03-06)

@@ -7,0 +11,0 @@

26

dist/index.js
"use strict";
var _config = _interopRequireDefault(require("./util/config"));
var _client = require("./util/client");
var _client = _interopRequireDefault(require("./util/client"));
var _keys = _interopRequireDefault(require("./validators/keys"));
var _requestConfig = _interopRequireDefault(require("./validators/request-config"));
var _create = _interopRequireDefault(require("./payments/create"));

@@ -17,7 +19,19 @@

// Setup
// Payments
// Webhooks
class Banked {
constructor(keys = {}) {
this.__config = new _config.default();
this.__config.keys = keys;
this.__client = (0, _client.default)(this.__config.keys);
constructor(keys = {}, requestConfig) {
const k = (0, _keys.default)(keys);
const r = (0, _requestConfig.default)(requestConfig);
if (k.error) {
throw new Error(k.error);
}
if (r.error) {
throw new Error(r.error);
}
(0, _client.bootstrapClient)(k.value, r.value);
this.payments = {

@@ -24,0 +38,0 @@ create: _create.default,

@@ -8,20 +8,7 @@ "use strict";

var _axios = _interopRequireDefault(require("axios"));
var _client = require("../util/client");
var _paymentRequest = _interopRequireDefault(require("../validators/payment-request"));
var _api = require("../util/api");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const create = (paymentRequest = {}) => {
const _paymentRequestValida = (0, _paymentRequest.default)(paymentRequest),
value = _paymentRequestValida.value,
error = _paymentRequestValida.error;
if (error) {
throw new Error(error);
}
return _axios.default.post((0, _api.constructAPIURI)("/payment_sessions"), value);
const create = paymentRequest => {
const client = (0, _client.getClient)();
return client.post("/payment_sessions", paymentRequest);
};

@@ -28,0 +15,0 @@

@@ -8,20 +8,7 @@ "use strict";

var _axios = _interopRequireDefault(require("axios"));
var _client = require("../util/client");
var _paymentId = _interopRequireDefault(require("../validators/payment-id"));
var _api = require("../util/api");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const del = (paymentID = "") => {
const _paymentIDValidator = (0, _paymentId.default)(paymentID),
value = _paymentIDValidator.value,
error = _paymentIDValidator.error;
if (error) {
throw new Error(error);
}
return _axios.default.delete((0, _api.constructAPIURI)(`/payment_sessions/${value}`));
const del = paymentID => {
const client = (0, _client.getClient)();
return client.delete(`/payment_sessions/${paymentID}`);
};

@@ -28,0 +15,0 @@

@@ -8,20 +8,7 @@ "use strict";

var _axios = _interopRequireDefault(require("axios"));
var _client = require("../util/client");
var _paymentId = _interopRequireDefault(require("../validators/payment-id"));
var _api = require("../util/api");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const read = (paymentID = "") => {
const _paymentIDValidator = (0, _paymentId.default)(paymentID),
value = _paymentIDValidator.value,
error = _paymentIDValidator.error;
if (error) {
throw new Error(error);
}
return _axios.default.get((0, _api.constructAPIURI)(`/payment_sessions/${value}`));
const read = paymentID => {
const client = (0, _client.getClient)();
return client.get(`/payment_sessions/${paymentID}`);
};

@@ -28,0 +15,0 @@

@@ -6,10 +6,19 @@ "use strict";

});
exports.default = void 0;
exports.getClient = exports.bootstrapClient = void 0;
var _axios = _interopRequireDefault(require("axios"));
var _axiosRetry = _interopRequireDefault(require("axios-retry"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const bootstrapClient = keys => {
_axios.default.interceptors.request.use(config => {
let instance;
const bootstrapClient = (keys, requestConfig) => {
instance = _axios.default.create({
baseURL: "https://banked.me/api/v2",
timeout: requestConfig && requestConfig.timeout ? requestConfig.timeout : 3000,
proxy: requestConfig && requestConfig.proxy ? requestConfig.proxy : {}
});
instance.interceptors.request.use(config => {
config.auth = {

@@ -21,5 +30,19 @@ username: keys.api_key,

});
if (requestConfig && requestConfig.maxNetworkRetries) {
(0, _axiosRetry.default)(instance, {
retries: requestConfig.maxNetworkRetries,
retryDelay: _axiosRetry.default.exponentialDelay
});
}
return instance;
};
var _default = bootstrapClient;
exports.default = _default;
exports.bootstrapClient = bootstrapClient;
const getClient = () => {
return instance;
};
exports.getClient = getClient;

@@ -10,2 +10,4 @@ "use strict";

var _requestConfig = _interopRequireDefault(require("../validators/request-config"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -16,2 +18,3 @@

this._keys = null;
this._requestConfig = null;
}

@@ -35,2 +38,18 @@

get requestConfig() {
return this._requestConfig;
}
set requestConfig(rc) {
const _requestConfigValidat = (0, _requestConfig.default)(rc),
value = _requestConfigValidat.value,
error = _requestConfigValidat.error;
if (error) {
throw new Error(error);
}
this.requestConfig = value;
}
}

@@ -37,0 +56,0 @@

{
"name": "@banked/node",
"version": "0.0.5",
"version": "0.0.6",
"description": "Node.js library for the Banked API",

@@ -18,3 +18,3 @@ "license": "MIT",

"scripts": {
"test": "npm run build && jest",
"test": "npm run build && jest --verbose",
"test:unit": "jest ./test/unit",

@@ -49,2 +49,3 @@ "test:e2e": "npm run build && jest ./test/e2e --config '{ \"collectCoverage\" : false}'",

"axios": "0.19.2",
"axios-retry": "3.1.2",
"date-fns": "2.10.0"

@@ -51,0 +52,0 @@ },

# banked-node
[![Version](https://img.shields.io/npm/v/@banked/node)](https://www.npmjs.com/package/@banked/node)
[![Build Status](https://img.shields.io/github/workflow/status/banked/banked-node/ci)](https://github.com/banked/banked-node/actions)
The Banked Node library provides convenient access to the Banked API from applications written in server-side JavaScript.

@@ -29,2 +32,25 @@

### Network configuration
Banked's Node library optionally takes a global network configuration object as it's second paramter. This implements: a custom timeout period; an automatic retry policy; and/or configures an HTTP proxy.
```javascript
const Banked = require('@banked/node');
const banked = new Banked({
api_key: 'Your API key',
secret_key: 'Your secret key'
}, {
timeout: 5000, // (optional) defaults to 3000
maxNetworkRetries: 5, //(optional) defaults to 0,
proxy: { // (optional, but contains required properties if configured)
host: '127.0.0.1', // (required, string) a valid IPv4 or IPv6 string, with optional CIDR
port: 8080, // (required, string) a valid port
auth: { // (optional, but contains required properties if configured)
username: 'frodobaggins', // (required, string)
password: '4TheShire' // (required, string)
}
}
});
```
### Payments

@@ -31,0 +57,0 @@

@@ -1,13 +0,23 @@

import Config from "./util/config";
import bootstrapClient from "./util/client";
// Setup
import { bootstrapClient } from "./util/client";
import keysValidator from "./validators/keys";
import requestConfigValidator from "./validators/request-config";
// Payments
import create from "./payments/create";
import read from "./payments/read";
import del from "./payments/delete";
// Webhooks
import validate from "./webhooks/validate";
class Banked {
constructor(keys = {}) {
this.__config = new Config();
this.__config.keys = keys;
this.__client = bootstrapClient(this.__config.keys);
constructor(keys = {}, requestConfig) {
const k = keysValidator(keys);
const r = requestConfigValidator(requestConfig);
if (k.error) {
throw new Error(k.error);
}
if (r.error) {
throw new Error(r.error);
}
bootstrapClient(k.value, r.value);
this.payments = {

@@ -14,0 +24,0 @@ create,

@@ -1,13 +0,8 @@

import axios from "axios";
import paymentRequestValidator from "../validators/payment-request";
import { constructAPIURI } from "../util/api";
import { getClient } from "../util/client";
const create = (paymentRequest = {}) => {
const { value, error } = paymentRequestValidator(paymentRequest);
if (error) {
throw new Error(error);
}
return axios.post(constructAPIURI("/payment_sessions"), value);
const create = paymentRequest => {
const client = getClient();
return client.post("/payment_sessions", paymentRequest);
};
export default create;

@@ -1,13 +0,8 @@

import axios from "axios";
import paymentIDValidator from "../validators/payment-id";
import { constructAPIURI } from "../util/api";
import { getClient } from "../util/client";
const del = (paymentID = "") => {
const { value, error } = paymentIDValidator(paymentID);
if (error) {
throw new Error(error);
}
return axios.delete(constructAPIURI(`/payment_sessions/${value}`));
const del = paymentID => {
const client = getClient();
return client.delete(`/payment_sessions/${paymentID}`);
};
export default del;

@@ -1,13 +0,8 @@

import axios from "axios";
import paymentIDValidator from "../validators/payment-id";
import { constructAPIURI } from "../util/api";
import { getClient } from "../util/client";
const read = (paymentID = "") => {
const { value, error } = paymentIDValidator(paymentID);
if (error) {
throw new Error(error);
}
return axios.get(constructAPIURI(`/payment_sessions/${value}`));
const read = paymentID => {
const client = getClient();
return client.get(`/payment_sessions/${paymentID}`);
};
export default read;
import axios from "axios";
import axiosRetry from "axios-retry";
const bootstrapClient = keys => {
axios.interceptors.request.use(config => {
let instance;
const bootstrapClient = (keys, requestConfig) => {
instance = axios.create({
baseURL: "https://banked.me/api/v2",
timeout:
requestConfig && requestConfig.timeout ? requestConfig.timeout : 3000,
proxy: requestConfig && requestConfig.proxy ? requestConfig.proxy : {}
});
instance.interceptors.request.use(config => {
config.auth = {

@@ -11,4 +20,15 @@ username: keys.api_key,

});
if (requestConfig && requestConfig.maxNetworkRetries) {
axiosRetry(instance, {
retries: requestConfig.maxNetworkRetries,
retryDelay: axiosRetry.exponentialDelay
});
}
return instance;
};
export default bootstrapClient;
const getClient = () => {
return instance;
};
export { bootstrapClient, getClient };
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