Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

little-printer-claim-code

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

little-printer-claim-code

helper utility to generate (and process) claim codes for a Berg Little Printer

  • 0.0.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
increased by100%
Maintainers
1
Weekly downloads
 
Created
Source

little-printer-claim-code

Claim code encoding for Little Printer devices.

Ported from this Python implementation.

Mostly I expect this to be used to encode devices into generating a claim code (via encode), but it also supports unpacking a claim code into parameters (unpack), and decoding a device key from a claim code (decode);

Library Usage

encode

Turn device parameters into a claim code:

// generate a device address - from MAC address, or randomly, whatever
const deviceAddress = '000d6f000273c164';

// only the last 24 bits of the device address are used
const deviceAddressInt = parseInt(deviceAddress, 16) & 0xffffff;

// secret only known to printer and claim code, randomly generate
const secret = 0xeb1ba696a0;

console.log(encode(deviceAddressInt, secret));
// → 'n5ry-p6x6-kth7-7hc4'

unpack

Extract values within a claim code:

const claimCode = 'c1zp-g2ec-sqqh-28t5';

console.log(unpack(claimCode));
// → {
//   device: 74565,
//   secret: 444691369455,
//   crc: 22655,
//   value: 417918447673048574272325n
// }

decode

Decode a claim code to extract the key:

const claimCode = 'c1zp-g2ec-sqqh-28t5';

console.log(decode(claimCode));

// → {
//   device: 74565,
//   key: <Buffer d5 0b 90 4f 43 7c 1d 2e 87 c3 10 57 49 40 9e 3d>
// }

Generate a Claim Code

If all you really want to do is create a claim code with this library, then there's a script to help with that:

./bin/generate-claim-code.sh

// → {
//  device: '121745933cb16b91',
//  secret: 876353015208,
//  claimCode: '5rpd-r2oo-spnc-2v00'
// }

Maintenance: Releasing a Version

Publishing works via GitHub actions, so. Create a new version (+tag, etc), which should get pushed to GitHub automatically.

yarn version

Then open GitHub, and create (+ publish) a new release. This will trigger everything else that needs doing.

Keywords

FAQs

Package last updated on 18 Apr 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc