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

@signageos/sdk

v1.24.0

Published

Library which allows you to fully manage signageOS applets, devices, management & monitoring using JS.

Downloads

1,816

Readme

SDK Library

Library which allows you to fully manage signageOS applets, devices, management & monitoring using JS.

Installation and prerequisites

npm install @signageos/sdk

Environment variables

Mandatory ENV variables (when using SDK api/rest singleton - deprecated. Use factories createApiV1 or createApiV2 instead):

in .env file:

# Organization API SECURITY TOKENS
SOS_AUTH_CLIENT_ID="...OAuthClientID..."
SOS_AUTH_SECRET="...OAuthSecret..."

# Account API SECURITY TOKENS
SOS_API_IDENTIFICATION="...apiSecurityTokenID..."
SOS_API_SECURITY_TOKEN="...apiSecurityToken..."

Optional ENV variable adjustment (with default values):

# REST API URL (default to the production server)
SOS_API_URL="https://api.signageos.io"
# How many times to retry request until it fails
SOS_REQUEST_MAX_ATTEMPTS="3"
# You can setup which profile to use when loading from `~/.sosrc` file (see details in https://github.com/signageos/cli#run-control-file)
SOS_PROFILE=

How to obtain Organization API SECURITY TOKENS

  1. Go to Box in the side menu select Organize and sub menu Organizations
  2. In organizations select your organization (or create new one)
  3. In top tabs select API tokens
  4. Click on button Add new token and generate new values
  5. Generated values can be used in .env file SOS_AUTH_CLIENT_ID is Token ID and SOS_AUTH_SECRET is Token Secret

How to obtain Account API SECURITY TOKENS

  1. Go to Box in the top navigation menu click on account icon
  2. In drop down menu select My profile
  3. Scroll to the bottom of the page, click on button Add new token and generate new values
  4. Generate values can be used in .env file SOS_API_IDENTIFICATION is Token ID and SOS_API_SECURITY_TOKEN is Token Secret

You may read articles about setting up SDK & Rest API:

Please see the .env.dist file where all mandatory ENV variables, required for SDK usage, are listed too.

REST API

Credentials in code

Just by setting ENV variables properly, you are ready to go and may use the api. If not ENV variables provided to node.js app, it tries to get values from user's ~/.sosrc which is configured by @signageos/cli dependency.

import { createApiV1 } from "@signageos/sdk";

const api = createApiV1(
	{
		url: 'https://api.signageos.io', // Optional
		organizationAuth: {
			clientId: '...OAuthClientID...',
			secret: '...OAuthSecret...',
		},
		accountAuth: {
			tokenId: '...apiSecurityTokenID...',
			token: '...apiSecurityToken...',
		},
	},
);

// retrieves the list of all devices
const devices = await api.device.list();

// ...
import { createApiV2 } from "@signageos/sdk";

const api = createApiV2(
	{
		url: 'https://api.signageos.io', // Optional
		organizationAuth: {
			clientId: '...OAuthClientID...',
			secret: '...OAuthSecret...',
		},
		accountAuth: {
			tokenId: '...apiSecurityTokenID...',
			token: '...apiSecurityToken...',
		},
	},
);

// retrieves the list of all devices
const devices = await api.device.list();

// ...

Credentials from ENV Variables

import { createApiV1 } from "@signageos/sdk";

// takes parameters from env vars
const api = createApiV1();

// retrieves the list of all devices
const devices = await api.device.list();

// ...
import { createApiV2 } from "@signageos/sdk";

// takes parameters from env vars
const api = createApiV2();

// retrieves the list of all devices
const devices = await api.device.list();

// ...

Documentation

The complete SDK documentation may be generated by typedoc by running the command:

$ npm i && npm run docs

Once generated, the docs directory will contain the generated documentation.

The most useful documentation pages:

Development

Running the tests

Create .env file by running

cp .env.automated.test

and fill in the missing values. You have to ask the maintainer of the repository for the values.

Then,

  • for unit tests run npm run test
  • for integration tests, run npm run test-integration