Code Monkey home page Code Monkey logo

cs2-encryption's Introduction

Cybersource V2 Encryption

A small (~9kB) helper library to port NodeJS WebCrypto and perform Cybersource V2 MicroForm encryption.

NPM registry NPM license

Installation

yarn add cs2-encryption --save

// or

npm i cs2-encryption -S

Card Types

import { CardTypes } from 'cs2-encryption';

console.log(CardTypes.Visa);
// => '001'

Example Usage

import { encrypt, CardData, CardTypes } from 'cs2-encryption';

// Received from `POST` to https://flex.cybersource.com/flex/v2/tokens
const context = "eyJraWQiOiJsbiIsImFsZyI...";

const data: CardData = {
  number: "4242424242424242",
  securityCode: "123",
  expirationMonth: "10",
  expirationYear: "2021",
  type: CardTypes.Visa, // see `CardTypes` declarations 
};

const encrypted = await encrypt(data, context);

console.log(encrypted);
// => eyJraWQiOiIwM3dEVnJC...

console.log(typeof encrypted);
// => string (an encrypted JWT)

Changelog

[1.0.4] - 2021-01-25

Changed

  • Fixed types
  • Fixed compilation error from WebCrypto port

[1.0.0 - 1.0.3] - 2020-11-06

Added

  • Cybersource V2 Encryption

cs2-encryption's People

Contributors

walmat avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

cs2-encryption's Issues

Improve repository

Need to add the following when I get around to it.

  • Contribution section
  • Badges (tests, coverage, etc.)
  • Examples?
  • Documentation?
  • Sponsors / Donations?

Add more tests

In order to solidify the encryption method a bit more, we should add some more tests to make sure that all possible edge cases are covered. This will also allows us to make our types stricter and make the margin of error as close to zero as possible.

I will be updating this issue with possible edge cases as I come up with them (and the time to cover them).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.