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

byteark-sdk

v0.3.1

Published

[![NPM Version](https://img.shields.io/npm/v/byteark-sdk.svg)](https://www.npmjs.com/package/byteark-sdk) [![Build Status](https://travis-ci.org/byteark/byteark-sdk-js.svg?branch=master)](https://travis-ci.org/byteark/byteark-sdk-js)

Downloads

2,003

Readme

ByteArk SDK for js

NPM Version Build Status

Table of Contents

Installation

For NodeJS 5+, You may install this SDK via NPM

npm install byteark-sdk

Usages

Now the only feature availabled is creating signed URL with ByteArk Signature Version 2.

First, create a ByteArkV2UrlSigner instance with access_id and access_secret. (access_id is currently optional for ByteArk Fleet).

Then, call sign method with URL to sign, Unix timestamp that the URL should expired, and sign options.

For sign options argument, you may include method, which determines which HTTP method is allowed (GET is the default is not determined), and may includes custom policies.

Usage using ES6

The following example will create a signed URL that allows to GET the resource within 1st January 2018:

import { ByteArkV2UrlSigner } from 'byteark-sdk';

const signer = new ByteArkV2UrlSigner({
    access_id: '2Aj6Wkge4hi1ZYLp0DBG',
    access_secret: '31sX5C0lcBiWuGPTzRszYvjxzzI3aCZjJi85ZyB7',
});

const signedUrl = signer.sign(
    'https://example.cdn.byteark.com/path/to/file.png',
    1514764800
);

console.log(signedUrl)

/*
Output:
https://example.cdn.byteark.com/path/to/file.png
    ?x_ark_access_id=2Aj6Wkge4hi1ZYLp0DBG
    &x_ark_auth_type=ark-v2
    &x_ark_expires=1514764800
    &x_ark_signature=OsBgZpn9LTAJowa0UUhlYQ
*/

Usage using CommonJS

var byteark = require('byteark-sdk');
var ByteArkV2UrlSigner = byteark.ByteArkV2UrlSigner;

// Following steps just like using with CommonJS

For more usage details, please visit ByteArk Documentation

Usage for HLS

When signing URL for HLS, you have to choose common path prefix and assign to path_prefix option is required, since ByteArk will automatically create secured URLs for each segments using the same options and signature.

For example, if your stream URL is https://example.cdn.byteark.com/live/playlist.m3u8, you may use /live/ as a path prefix.

import { ByteArkV2UrlSigner } from 'byteark-sdk';

const signer = new ByteArkV2UrlSigner({
    access_id: '2Aj6Wkge4hi1ZYLp0DBG',
    access_secret: '31sX5C0lcBiWuGPTzRszYvjxzzI3aCZjJi85ZyB7',
});

const signedUrl = signer.sign(
    'https://example.cdn.byteark.com/live/playlist.m3u8',
    1514764800,
    {
        path_prefix: '/live/',
    }
);

console.log(signedUrl)

/*
Output:
https://example.cdn.byteark.com/live/playlist.m3u8
    ?x_ark_access_id=2Aj6Wkge4hi1ZYLp0DBG
    &x_ark_auth_type=ark-v2
    &x_ark_expires=1514764800
    &x_ark_path_prefix=%2Flive%2F
    &x_ark_signature=7JGsff2mBQEOoSYHTjxiVQ
*/

Options

ByteArkV2UrlSigner

| Option | Required | Default | Description | |---------------|----------|---------|---------------------------------------------------------------------------| | access_id | Required | - | Access key ID for signing | | acesss_secret | Required | - | Access key secret for signing | | default_age | - | 900 | Default signed URL age (in seconds), if signing without expired date/time |

ByteArkV2UrlSigner.sign(url, expires = null, options = [])

| Option | Required | Default | Description | |-------------|----------|---------|---------------------------------------------------------------------------------------------------------------------------------------------------------------| | method | - | GET | HTTP Method that allowed to use with the signed URL | | path_prefix | - | - | Path prefix that allowed to use with the signed URL (the same signing options and signature can be reuse with the