npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

bond-sdk-cards

v1.8.1

Published

Bond Card Management SDK

Downloads

31

Readme

Bond Card Management JavaScript SDK

Storing and processing card details including primary account number (PAN), CVV, expiration date, and personal identification number (PIN) involves complying with PCI DSS data security requirements. PCI compliance typically requires high overhead, so Bond created an SDK that vaults and tokenizes this card information. Using the below SDK, you can easily allow your customers to retrieve their card details, set PINs, and reset PINS without entering PCI scope, or worrying about seeing and storing your customers' sensitive card details.

-This overview outlines Requirements, Installation, and Usage. -The Docs folder provides Bond Cards SDK Documentation you can run. -Then check out the sample files to see sample implementation you can build and run.

Requirements

When working with Bond, you'll create API Keys to enable access to the platform. Then you're ready to build.

To use this SDK you can just import it using the steps under 'Installation'. But if you'd like to build the repo yourself, with or without sample files, you'll need:

Node installation will include NPM, which is responsible for dependency management.

Installation

NPM

To install the module in your repo use your terminal to type: npm install bond-sdk-cards

Then import it in your Javascript code: import BondCards from 'bond-sdk-cards';

CDN

Or you can install the SDK from a CDN.

Using JS

import BondCards from 'cdn.bond.tech/sdk/cards/v1/bond-sdk-cards.js';

Using HTML

Usage

This SDK relies heavily on Promises, making it easier to handle the asynchronous requests made to the API. The SDK provides a BondCards object containing several methods which map to the calls and parameters described in BondCards's API documentation.

The following snippet is a generic example of how brands can use the SDK. If you need details for a specific module, refer to the sample files.

Before executing any request, you need to authorize the calls to the Bond API:

Using temporary tokens

  1. Make an authorized call from your backend with the correct customer_id to receive temporary tokens of {Identity, Authorization}.

cURL

curl --request POST \
  --url https://api.bond.tech/api/v0/auth/key/temporary \
  --header 'Content-Type: application/json' \
  --header 'Identity: YOUR_IDENTITY' \
  --header 'Authorization: YOUR_AUTHORIZATION' \
  --data '{"customer_id": "YOUR_CUSTOMER_ID"}'

Python

import requests

url = "https://api.bond.tech/api/v0/auth/key/temporary"

headers = { "Content-type": "application/json", "Identity": "YOUR_IDENTITY", "Authorization": "YOUR_AUTHORIZATION" }

payload = { 'customer_id': 'YOUR_CUSTOMER_ID' }

response = requests.post(url, headers=headers, json=payload)

print(response.text)

Ruby

uri = URI.parse("https://api.bond.tech/api/v0/auth/key/temporary")
params = {'customer_id' => 'YOUR_CUSTOMER_ID'}
headers = {
    'Content-Type'=>'application/json',
    'Identity'=>'YOUR_IDENTITY',
    'Authorization'=>'YOUR_AUTHORIZATION'
}

http = Net::HTTP.new(uri.host, uri.port)
response = http.post(uri.path, params.to_json, headers)
output = response.body
puts output

Node

const fetch = require("node-fetch");

let url = "https://api.bond.tech/api/v0/auth/key/temporary";
let options = {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    Identity: "YOUR_IDENTITY",
    Authorization: "YOUR_AUTHORIZATION",
  },
  body: { customer_id: "YOUR_CUSTOMER_ID" },
};

fetch(url, options)
  .then((res) => res.json())
  .then((json) => console.log(json))
  .catch((err) => console.error("error:" + err));

Javascript

// Client-side example for quick testing.
// You would call this from your backend in production

fetch("https://api.bond.tech/api/v0/auth/key/temporary", {
  method: "POST",
  headers: {
    "Content-type": "application/json",
    Identity: "YOUR_IDENTITY",
    Authorization: "YOUR_AUTHORIZATION",
  },
  body: {
    customer_id: "YOUR_CUSTOMER_ID",
  },
});

Java

OkHttpClient client = new OkHttpClient();

Request request = new Request.Builder()
  .url("https://api.bond.tech/api/v0/auth/key/temporary")
  .addHeader("Content-Type", "application/json")
  .addHeader("Identity", "YOUR_IDENTITY")
  .addHeader("Authorization", "YOUR_AUTHORIZATION")
  .post(RequestBody
                .create(MediaType
                    .parse("application/json"),
                        "{\"customer_id\": \"" + YOUR_CUSTOMER_ID + "\"}"
                ))
  .build();

Response response = client.newCall(request).execute();

C#

var client = new RestClient("https://api.bond.tech/api/v0/auth/key/temporary");
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Identity", "YOUR_IDENTITY");
request.AddHeader("Authorization", "YOUR_AUTHORIZATION");
request.AddParameter("application/json", {"customer_id": "YOUR_CUSTOMER_ID"}, ParameterType.RequestBody);
IRestResponse response = client.Execute(request);

Initialize BondCards

  1. Call the constructor ( 'live: false' to access the Sandbox environment )
const bondCards = new BondCards({ live: true });

Making requests

  1. You can now use the various methods from the SDK to reveal/manage PCI-sensitive data for a particular Bond Card ID. Following the Promises notation, you should use.then()/.catch() to handle the successful and failed requests, respectively.

Most of the calls take an object as the only parameter but please refer to the API documentation to tune the query as intended.

bondCards
  .show({
    cardId: [BOND CARD ID],
    identity: [TEMP IDENTITY TOKEN],
    authorization: [TEMP AUTH TOKEN],
    field: "number",
    htmlSelector: "#num",
    format: {
        replaceThis: "(\\d{4})(\\d{4})(\\d{4})(\\d{4})",
        withThis: "$1-$2-$3-$4",
      },
  })
  .then((data) => {
    // Handle data
  })
  .catch((error) => {
    // Handle an error
  });
  1. You can easily control loading with the various methods from the SDK. You should use.then()/.catch() to handle the successful and failed requests, respectively.
// Handle show loader
bondCards
    .showMultiple(configuration)
    .then((data) => {
        // Handle hide loader
    })
    .catch((error) => {
        // Handle hide loader
    });

Available methods

See API Documentation

Working with the Repo

The following script aliases are available:

  • npm run doc: Run JSDoc to create a 'docs' folder with automatically generated documentation for the source code.
  • npm run build: Create a production build minified and transpiled js bundle without any sample code.
  • npm run start: Lint SDK and Sample files, then Deploy a web server from the root folder at localhost:8080 to run the html samples.

Developing the BondCards SDK

To handle all implementation use cases, Engineers should always build this project (npm run build) before committing.

Include the /dist folder in your commit for customers that link to the built bond-sdk-cards.js file directly.