New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@jaak/playback-utils

Package Overview
Dependencies
Maintainers
4
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@jaak/playback-utils

Utility methods for using the JAAK Playback API

  • 0.2.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
4
Created
Source

@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.

FAQs

Package last updated on 10 Feb 2019

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