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

mag-stripe

v1.0.8

Published

Magnetic stripe parser

Downloads

403

Readme

mag-stripe Build Status

Magnetic stripe parser for credit-cards and state-issued identification cards. Latest version also includes parser for PDF417 barcode data found on backs of state-issued identification cards.

Shopping

Here is a simple magstripe reader from Amazon

Barcode scanner (parses PDF417 data-matrix barcodes)

If you do not have a reader/scanner, feel free to use the sample mag-stripe or PDF417 data located in /tests/test_data.json

Getting Started

Want to build your own POS system? Go ahead and purchase the components above and get coding!

Both components should come as keyboard-input by default, however, some readers/scanners can be configured to use a different protocol. If you would like to use a different protocol (RS232 for example), follow instructions in your manual to configure the scanner/reader. Use a library like serialport to capture frames sent from your scanner/reader. You will need to convert the received bytes into ASCII characters in order to use this library.

Quick Start:

  • Install package npm install --save mag-stripe
  • Plug in your virtual keyboard (scanner or mag-stripe reader)
  • Use the cli() function documented below - this function will grab the input from your scanner/card-reader and output the parsed data to the commandline

Not-So-Quick Start

  • Install package npm install --save mag-stripe
  • Build card-payment application
  • On your 'swipe-credit-card-here' screen, grab the keyboard-input from your card reader and parse using this library!

Please be sure to use other people's data in an ethical manner ;)

Happy hacking!

Documentation

parse_card(data: string) -> {object}

Function parses input from ID mag-stripe and returns object:

{
    card_number: 1234567812345678,
    first_name: 'john',
    last_name: 'doe',
    expiration_date: '11/23',
    expired: false
}

parse_id(data: string) -> {object}

Function parses input from ID mag-stripe and returns object:

{
    first_name: 'john',
    last_name: 'doe',
    license_number: '81234567',
    under_21: false,
    under_18: false,
    expired: false,
    age: 25,
    date_of_birth: '19931223',
    expiration_date: '2112'
}

parse_pdf417(data: string) -> {object}

Function parses input from ID barcode and returns object:

{
    first_name: 'jane',
    last_name: 'doe',
    license_number: '123456789',
    under_21: false,
    under_18: false,
    expired: false,
    age: 24,
    date_of_birth: '05081994',
    expiration_date: '05082022'
}

Usage

index.js:

const parser = require('mag-stripe');
const id_data = parser.test_data.id;
const credit_card_data = parser.test_data.credit_card;
const pdf417_data = parser.test_data.pdf417_id;

function get_id_data () {
    let data = parser.parse_id(id_data);
    // do something with ID info (check age?)
}

function get_credit_card_data () {
    let data = parser.parse_card(credit_card_data);
    // do something with credit card info
}

function get_pdf417_id_data () {
    let data = parser.parse_pdf417(pdf417_data);
    // do something with ID info
}

CLI Usage

index.js:

require('mag-stripe').cli();

Run: node index.js this method will create a readline stream - plug in your card reader and swipe!