Comparing version 0.2.0 to 1.0.0
{ | ||
"name": "connext", | ||
"version": "0.2.0", | ||
"version": "1.0.0", | ||
"description": "Connext is a payment api for Ethereum applications", | ||
"main": "connext.js", | ||
"main": "build/node4/index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
"build": "babel-build-all", | ||
"lint": "snazzy && echint", | ||
"pretest": "npm run lint && npm run build", | ||
"test": "tap test --node-arg=--require --node-arg=babel-register", | ||
"coverage": "tap test --reporter silent --coverage --nyc-arg=--require --nyc-arg=babel-register" | ||
}, | ||
@@ -13,2 +17,16 @@ "repository": { | ||
}, | ||
"files": [ | ||
"build", | ||
"src" | ||
], | ||
"standard": { | ||
"ignore": [ | ||
"build/**" | ||
] | ||
}, | ||
"echint": { | ||
"ignore": [ | ||
"build/**" | ||
] | ||
}, | ||
"keywords": [ | ||
@@ -24,3 +42,3 @@ "payment", | ||
], | ||
"author": "Arjun Bhuptani <arjunbhuptani@gmail.com>, Layne Haber <laynehaber@gmail.com> (http://connextapi.com)", | ||
"author": "Rahul Sethuram, <rahul@connextapi.com>, Arjun Bhuptani <arjun@connextapi.com>, Layne Haber <layne@connextapi.com> (http://connextapi.com)", | ||
"license": "MIT", | ||
@@ -31,6 +49,15 @@ "bugs": { | ||
"homepage": "https://github.com/ConnextAPI/connext#readme", | ||
"devDependencies": { | ||
"@ahmadnassri/babel-build-all": "*", | ||
"babel-plugin-add-module-exports": "*", | ||
"babel-preset-env": "^1.6.0", | ||
"babel-register": "*", | ||
"echint": "*", | ||
"snazzy": "*", | ||
"tap": "*" | ||
}, | ||
"dependencies": { | ||
"request": "^2.81.0", | ||
"web3": "^0.19.0" | ||
"axios": "^0.16.2", | ||
"check-types": "^7.3.0" | ||
} | ||
} |
113
README.md
@@ -12,9 +12,13 @@ # Connext | ||
2) Construct your connext object in a separate connext.js file and export it. This will reduce the risk of key and secret information being leaked. | ||
2) Do not save your API key and secret into source control. Use other strategies such as a git-ignored config file or environment variables. | ||
``` | ||
//connext.js | ||
var Connext = require('connext'); | ||
var connext = new Connext(ApiKey, ApiSecret); | ||
const Connext = require('connext'); | ||
const apiKey = process.env.API_KEY | ||
const apiSecret = process.env.API_SECRET | ||
const connext = new Connext(apiKey, apiSecret); | ||
module.exports = connext; | ||
@@ -25,16 +29,18 @@ ``` | ||
### getKey() [to be deprecated soon for security reasons] | ||
All of the Connext object methods return Promises. See this article for an overview on how to use them: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Using_promises. | ||
Inputs: (email, password, [callback]) | ||
Outputs: (error, {key, secret}) | ||
### getKey(email, password) [to be deprecated soon for security reasons] | ||
Retrieves your key and secret if you already have an account. Outputs get returned into a callback. | ||
Inputs: (email, password) | ||
Outputs: Promise that resolves with object `{ key, secret }` | ||
Retrieves your key and secret if you already have an account. | ||
Usage: | ||
``` | ||
connext.getKey(email, password, function(auth_details) { | ||
var key = auth_details.key; | ||
var secret = auth_details.secret; | ||
}) | ||
connext.getKey(email, password).then(({ key, secret }) => { | ||
console.log(key, secret); | ||
}) | ||
``` | ||
@@ -44,27 +50,39 @@ | ||
Inputs: ([callback]) | ||
Outputs: (error, token) | ||
Inputs: () | ||
Generates an empty token object to be filled out into a callback. You can ```console.log()``` it to find out what the possible data fields are. You should call this on your client side and fill out the data fields there so that no credit card info touches your servers. | ||
Outputs: Promise that resolves with an object `{ ...tokenParameters }` | ||
### tokenize() | ||
Generates an empty token object to be filled out into a Promise. You can `console.log()` it to find out what the possible data fields are. You should call this on your client side and fill out the data fields there so that no credit card info touches your servers. | ||
Inputs: (token, [callback]) | ||
Outputs: (error, updated_token) | ||
Usage: | ||
``` | ||
connext.newToken().then(token => { | ||
console.log(token); // show token parameters | ||
}) | ||
``` | ||
### tokenize(token) | ||
Inputs: (token) | ||
Outputs: Promise that resolves with an object `{ ...updatedTokenParameters }` | ||
Sends the card info to connext servers and returns a token in a callback. The token is a redacted version of the information which is saveable on your servers without violating PCI compliancy. Like above, call only from the client side to make sure credit card info never touches your servers. | ||
### chargeCard() | ||
Usage: | ||
Inputs: (token, amount, [callback]) | ||
Outputs: (error, receipt) | ||
``` | ||
connext.tokenize(token).then(newToken => { | ||
console.log(newToken); | ||
}) | ||
``` | ||
Actually charges the card. *Amount must be written as payment(in dollars)x100*. Eg: $30.10 becomes 3010. The tokenization and charge process are separated to facilitate recurring payments or a second attempt at a payment if the payment fails. Returns a receipt object in the callback. For now, the receipt object only has a success field. | ||
### chargeCard(token, amount, chargebackDestination, tokenContractAddress) | ||
### chargeEth() [COMING SOON] | ||
Inputs: (token, amount, chargebackDestination, tokenContractAddress) | ||
Inputs: (key, secret, to, from, from_key, amount, [callback]) | ||
Outputs: 1st callback(error, transaction hash), 2nd callback(error, transaction receipt) | ||
Outputs: Promise that resolves with an object `{ vaultAddress }` | ||
Not deployed yet. This will eventually be an easy to integrate "Pay with Eth" button that works with metamask out of the box! | ||
Actually charges the card and deploys a vault contract to receive the tokens. `chargebackDestination` must be a valid Ethereum address that will be the "escape hatch" for tokens that are returned in the case of a charge reversal. `tokenContractAddress` must be a valid Ethereum address that is the ERC20 token contract for the tokens that will be sent to the vault upon settlement of the transaction. *Amount must be written as payment(in dollars)x100, as a number*. Eg: $30.10 becomes 3010. The tokenization and charge process are separated to facilitate recurring payments or a second attempt at a payment if the payment fails. The resolved Promise object contains the vault address. | ||
@@ -74,29 +92,22 @@ ## Example usage: | ||
``` | ||
//connext.js | ||
var Connext = require('connext'); | ||
var connext = new Connext(ApiKey, ApiSecret); | ||
connext.newToken() | ||
.then(token => { | ||
return connext.tokenize(token); | ||
}) | ||
.then(newToken => { | ||
// add payment info here from input fields | ||
// ... | ||
return connext.chargeCard(newToken, 101, "0x1111111111111111", "0x1111111111111112"); | ||
}) | ||
.then(response => { | ||
const { vaultAddress } = response; // destructure vault address from response | ||
// send tokens to vault | ||
}) | ||
.catch(error => { | ||
// handle me | ||
}); | ||
``` | ||
module.exports = connext; | ||
## Error Handling | ||
//index.js | ||
var connext = require('./path/to/connext.js'); | ||
connext.newToken(function(err, token){ | ||
if (err) return (err); | ||
//add payment info here from input fields | ||
//... | ||
//tokenize the card data | ||
connext.tokenize(token, function(err, updated_token) { | ||
if (err) return (err); | ||
//actually charge the card | ||
connext.chargeCard(updated_token, 101, function(err, receipt) { | ||
if (err) return (err); | ||
console.log(receipt); //logs "success" | ||
}) | ||
}) | ||
}) | ||
``` | ||
The Connext API makes use of [axios](https://github.com/mzabriskie/axios) for HTTP calls. Errors are returned directly from axios, so they should be handled appropriately using this guide as reference: https://github.com/mzabriskie/axios#handling-errors |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
24796
11
478
1
110
7
+ Addedaxios@^0.16.2
+ Addedcheck-types@^7.3.0
+ Addedaxios@0.16.2(transitive)
+ Addedcheck-types@7.4.0(transitive)
+ Addedfollow-redirects@1.15.9(transitive)
+ Addedis-buffer@1.1.6(transitive)
- Removedrequest@^2.81.0
- Removedweb3@^0.19.0
- Removedajv@6.12.6(transitive)
- Removedasn1@0.2.6(transitive)
- Removedassert-plus@1.0.0(transitive)
- Removedasynckit@0.4.0(transitive)
- Removedaws-sign2@0.7.0(transitive)
- Removedaws4@1.13.2(transitive)
- Removedbcrypt-pbkdf@1.0.2(transitive)
- Removedbignumber.js@4.1.0(transitive)
- Removedcaseless@0.12.0(transitive)
- Removedcombined-stream@1.0.8(transitive)
- Removedcore-util-is@1.0.2(transitive)
- Removedcrypto-js@3.3.0(transitive)
- Removeddashdash@1.14.1(transitive)
- Removeddelayed-stream@1.0.0(transitive)
- Removedecc-jsbn@0.1.2(transitive)
- Removedextend@3.0.2(transitive)
- Removedextsprintf@1.3.0(transitive)
- Removedfast-deep-equal@3.1.3(transitive)
- Removedfast-json-stable-stringify@2.1.0(transitive)
- Removedforever-agent@0.6.1(transitive)
- Removedform-data@2.3.3(transitive)
- Removedgetpass@0.1.7(transitive)
- Removedhar-schema@2.0.0(transitive)
- Removedhar-validator@5.1.5(transitive)
- Removedhttp-signature@1.2.0(transitive)
- Removedis-typedarray@1.0.0(transitive)
- Removedisstream@0.1.2(transitive)
- Removedjsbn@0.1.1(transitive)
- Removedjson-schema@0.4.0(transitive)
- Removedjson-schema-traverse@0.4.1(transitive)
- Removedjson-stringify-safe@5.0.1(transitive)
- Removedjsprim@1.4.2(transitive)
- Removedmime-db@1.52.0(transitive)
- Removedmime-types@2.1.35(transitive)
- Removedoauth-sign@0.9.0(transitive)
- Removedperformance-now@2.1.0(transitive)
- Removedpsl@1.10.0(transitive)
- Removedpunycode@2.3.1(transitive)
- Removedqs@6.5.3(transitive)
- Removedrequest@2.88.2(transitive)
- Removedsafe-buffer@5.2.1(transitive)
- Removedsafer-buffer@2.1.2(transitive)
- Removedsshpk@1.18.0(transitive)
- Removedtough-cookie@2.5.0(transitive)
- Removedtunnel-agent@0.6.0(transitive)
- Removedtweetnacl@0.14.5(transitive)
- Removeduri-js@4.4.1(transitive)
- Removedutf8@2.1.2(transitive)
- Removeduuid@3.4.0(transitive)
- Removedverror@1.10.0(transitive)
- Removedweb3@0.19.1(transitive)
- Removedxhr2@0.2.1(transitive)
- Removedxmlhttprequest@1.8.0(transitive)