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

@jaak/playback-utils

v0.2.3

Published

Utility methods for using the JAAK Playback API

Downloads

8

Readme

@jaak/playback-utils

Utility methods for interacting with the JAAK Playback API

⚠️ This repo is under active development and the API is likely to change without warning ⚠️

Installation

npm install @jaak/playback-utils

Usage

Load the @jaak/playback-utils package:

const utils = require('@jaak/playback-utils')

Key management

Generate a Key:

const key = await utils.Key.generate()

Instantiate a key from a JSON Web Key (JWK):

const jwk = {
  "kty": "EC",
  "kid": "D6LJKdvD1gcmuyU7G5JeWltFV0AiXpxUx6_UyhsIg80",
  "crv": "P-256",
  "x": "m8ouXM1o0f7cOPmMzN_vfsFouab-n0S86hUegEZb0Ks",
  "y": "iqbequlfZJF1fubrAh2Hmrly9ZWup83NJZc5vsNt4xQ",
  "d": "kyWdoePrPNDWrVkEhXo8KlnA61JvwcRT-DmJIGb_W7A"
}

const key = await utils.Key.fromJWK(jwk)

Print a key's ID:

const keyID = await key.id

console.log(keyID)

Export a key as a public JWK:

const jwk = await key.toJWK()

Export a key as a private JWK:

const jwk = await key.toJWK({ private: true })

Generate a JSON Web Signature (JWS) using a key:

const payload = { foo: "bar" }

const jws = await key.sign(payload)

Access Vouchers

Generate an access voucher with generateAccessVoucher:

const key = await utils.Key.generate()
const licenseID = '0016e038-eb2e-4596-96fb-8864c76d9004'
const nonce = Date.now().toString()

const voucher = await utils.generateAccessVoucher(licenseID, key, nonce)

HTTP Requests

Send a GraphQL request to the Playback API using sendSignedRequest:

const payload = {
  query: 'query { application { id } }',
}
const uri = 'https://playback.beta.jaak.io/graphql'
const key = await utils.Key.fromJWK(jwk)

try {
  const { data, errors } = await sendSignedRequest(payload, uri, key)

  if (errors) {
    // GraphQL errors were returned from the server
    // client can choose how to handle them
  }

  // Operate on success data
  console.log(data.application.id)

} catch (error) {
  // A 4xx or 5xx HTTP status code was returned from the request
}

Custom Web Crypto API

Set a Web Crypto API polyfill using setCryptoProvider:

const NodeWebCrypto = require('node-webcrypto-ossl')

const webcrypto = new NodeWebCrypto()

utils.setCryptoProvider(webcrypto)

Contributing 🙋‍♀️

See the jaak.js contributing guide.