coinguard

NodeJS API for CoinGuard

npm install coinguard
1 downloads in the last week
4 downloads in the last month

node-coinguard

NodeJS API for CoinGuard

How to Install

sudo npm install coinguard

How to use

var coinguard = require('coinguard').CoinGuard('sec-d8cPieZt00FG9k7vAAAz', {
  protocol: 'https', // Optional
  api_domain: 'coinguard.org', // Optional
  api_endpoint: '/api' // Optional
});

coinguard.create('a@b.com', 'c@d.com', function(err, res) {
  /**
    Example repsonse
    { '0': null,
      '1': 
       { result: 
          { address: '1G2d6pXm6jqAuzsTPTeYNMQEm6fpnLfBon',
            eka: 'binva-ZLE1GCpaCdwcz043AAAs',
            ekb: 'binvb-VLsFPKcyG1k3YK4NAAAt',
            sender: 'a@b.com',
            receiver: 'c@d.com' } } }
   */
});

coinguard.redeem('binva-ZLE1GCpaCdwcz043AAAs', 'binvb-VLsFPKcyG1k3YK4NAAAt', '1PGXTsbbrnXBnTgEdssRCH8Ukc57DvapcP', function(err, res) {
  /**
    Example repsonse
    { '0': null,
      '1': 
       { tx: '37b7e6df916b32113e9dda776d6127c0566106fcca89a75....' }
   */
});

/**
   To determine origin of a notification.
   Example implementation:
 */

var app = express();
app.post('/callback-endpoint', function(req, res) {
  if(coinguard.validateRequest(req.body)) {
    // notification received from CoinGuard!

    var address = req.body.address;
    var sender = req.body.sender;
    var receiver = req.body.receiver;

    // write your application code here...

    res.send(200); //OK
  } else {
    // notification from an attacker
    res.send(401); //Unauthorized
  }
});

API

Create Escrow

// Create escrow
coinguard.create(sender, receiver, function(err, res) { ... });

Redeem payment

// Here eka is Escrow Key A
//  and ekb is Escrow Key B
coinguard.redeem(eka, ekb, deposit_address, function(err, res) { ... });

validateRequest

// Convienience method for determining the origin of a notification
// Returns a boolean
coinguard.validateRequest(request_body);

Set Secret

// Change your secret
coinguard.setSecret(secret);

Get Secret

// Returns your secret
coinguard.getSecret();

License

(The MIT License)

Copyright (c) 2013 Shripad K <assortmentofsorts@gmail.com>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

npm loves you