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

@onekeyfe/rollout

v1.0.6

Published

Small javascript library to get latest safe firmware version for OneKey update.

Downloads

86

Readme

onekeyhq-rollout

Tldr: For historical reasons, OneKey devices firmware updates are not always straightforward.

Incremental update: not every firmware update can be applied on any installed firmware. This currently applies only for T1 devices. Releases definitions (see below), contain min_bootloader_version and min_firmware_version. Depending on whether the device is in bootloader mode or not, respective field (min_bootloader_version or min_firmware_version) should be observed and next firmware to apply should be evaulated againts them.

Incremental downgrade: it is not possible to downgrade to lower version of bootloader. Rollout module does not solve this. Problem is, device will not tell you bootloader version if it is not in bootloader mode.

Rollout update: sometimes we might want to offer firmware only to small portion of users. This behaviour is defined by rollout field and handled by this lib.

Firmware headers: any firmware that is applied on firmware with bootloader >= 1.8.0 has old firmware header of 256 bytes, that should be removed before installing. This should be only temporary state and will be solved in future by introducing special intermediate firmwares for updating.

Commands

Build

to build a bundle run yarn build

Tests

run tests using yarn test or yarn run test:watch for watch mode

eslint

yarn run lint

Installation

Npm

npm install @onekeyhq/rollout --save

or

Yarn

yarn add @onekeyhq/rollout

Usage

import Rollout from '@onekeyhq/rollout';

Functions

Rollout(options)

  • options
{
  baseUrl: 'https://connect.onekey.so',
  releasesListsPaths: {
    1: 'data/firmware/1/releases.json',
    2: 'data/firmware/2/releases.json',
  }
}

getScore()

  • returns random number from 0 to 1 (0.21, 0.89, 0,45)
  • You may use this method to implement "rolling update". You probably want to save result of this function client side (local storage) under a key defined by concrete firmware. Items in releases list might have rollout field (number 0-1) that should be evaluated against getScore() result.

getInfo(features, score)

  • features: Features object provided by Connect
{
  major_version: 1,
  minor_version: 8,
  patch_version: 0,
  bootloader_mode: false,
  firmware_present: true,
  ...
}
  • score: Number (result of getScore()). This is to used to decide whether items with rollout defined are to be offered. Update is offered in case score provided is lower than rollout.

  • returns UpdateInfo item

{
    firmware: Object,               // single object from releaseList,
    isLatest: boolean || null,      // is returned firwmare the latest one? null means we cant tell
    isRequired: boolean,            // true if any of unistalled firmwares are required
    isNewer: boolean || null,       // is returned firmware newer then actual? null means we cant tell
}

getFw(features, score)

  • returns array buffer with firmware that is safe to upload to device.