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

@openpass/openpass-roku-sdk

v1.1.0

Published

OpenPass SSO Roku SDK

Downloads

23

Readme

OpenPass Roku SDK

License: MIT BrightScript Roku Package Manager

The OpenPass Roku SDK makes it easier to integrate OpenPass directly on your Roku channels.

Installation

ropm

The preferred installation method is via ropm

 ropm install @openpass/openpass-roku-sdk

Manually

Copy openpass_openpassrokusdk files inside your source folder

Requirements

In order to use this SDK you will need the following requirements

  1. Install Node.JS from here

  2. Install the Roku Package Manager node module globally

    npm i ropm -g
  3. Install BrighterScript module globally

    npm install brighterscript -g
  4. At project root level run

    ropm install
  5. Enable Developer Mode on you Roku device, you can see more here

  6. In order to use npm scripts to run the project locally, you will need to add the following ENV VARS to your system:

  • ROKU_HOST: This is the IP Address of your Roku device.
  • ROKU_DEV_PASSWORD: This is the password you set for your Roku device when Developer Mode was enabled.

To add the variables to your system for Mac or Linux:

  • If using zsh as your shell

    echo 'export ROKU_DEV_PASSWORD=<YOUR_DEVICE_PASSWORD>' >> ~/.zshrc
    echo 'export ROKU_HOST=<YOUR_DEVICE_HOST_IP>' >> ~/.zshrc
  • If using bash as your shell

    echo 'export ROKU_DEV_PASSWORD=<YOUR_DEVICE_PASSWORD>' >> ~/.bash_profile
    echo 'export ROKU_HOST=<YOUR_DEVICE_HOST_IP>' >> ~/.bash_profile

To add the variables to your system if using Windows

    setx ROKU_DEV_PASSWORD "<YOUR_DEVICE_PASSWORD>"
    setx ROKU_HOST "<ROKU_HOST>"

Usage

  1. Install the package via ropm
 ropm install @openpass/openpass-roku-sdk
  1. You will need to create 2 tasks nodes that will allow for specify a functions to be spawned in a different thread, you can do that like the following example:

create a task for Authorize Device flow: tasks/AuthorizeDeviceTask.brs

  sub Init()
    m.top.functionName = "AuthorizeDevice"
  end sub

  sub AuthorizeDevice()
    ' Your client Id
    clientId = "YOUR_CLIENT_ID"

    ' Init client
    m.op = openpass_openpassrokusdk_OpenPass()

    ' optionalParams = { polling_timeout: 200}
    ' optionalParams = { openpass_base_url: "www.differenturl.com", polling_timeout: 4000}
    ' optionalParams = { openpass_base_url: "www.differenturl.com"}
    optionalParams = { enable_logging: true }

    m.op.Init(clientId, AuthCallback, optionalParams)

    ' Start sign in process
    m.op.SignIn()

    ' m.op.SignOut()
  end sub

  sub AuthCallback(state, data)

    print state
    _states = {
      "SignedIn": 0,
      "SignedOut": 1,
      "Error": 2,
      "Loading": 3,
      "Polling": 4,
      "Refreshable": 5 ' Signed In but needs to refresh
    }

    if state = _states.SignedIn
      HandleSignedIn(data)
    else if state = _states.Polling
      HandlePolling(data)
    ' else if state = _states.Error
    '   HandleSignOut()
    end if

  end sub

  sub HandleSignedIn(data)
    authorizedDevice = CreateObject("roSGNode", "ContentNode")
    authorizedDevice.addFields(data["device_token_success"])
    m.top.authorizedDevice = authorizedDevice
  end sub

  sub HandlePolling(data)
    authDevice = CreateObject("roSGNode", "ContentNode")
    authDevice.addFields(data["authorize_device_success"])
    m.top.authDevice =authDevice
  end sub

and tasks/AuthorizeDeviceTask.xml

<?xml version="1.0" encoding="utf-8"?>

<component name="AuthorizeDeviceTask" extends="Task">
  <interface>
    <field id="authDevice" type="node" />
    <field id="authorizedDevice" type="node" />
    <field id="signedOut" type="node" />
  </interface>

  <!-- Import library -->
  <script type="text/brightscript"
    uri="pkg:/source/roku_modules/openpass_openpassrokusdk/dist/OpenPass.brs" />

  <script type="text/brightscript" uri="AuthorizeDeviceTask.brs" />
</component>
  1. Implement your recently created tasks where you need:

sub DeviceAuthorization()
  m.authTask = CreateObject("roSGNode", "AuthorizeDeviceTask")
  m.authTask.ObserveField("authDevice", "OnAuthDeviceCompleted")
  m.authTask.ObserveField("authorizedDevice", "OnAuthenticateTaskCompleted")
  m.authTask.ObserveField("signedOut", "OnSignedOutComplete")

  m.authTask.control = "run"
end sub

' Get device token
sub OnAuthDeviceCompleted()
  print "authorize device"
  print m.authTask.authDevice
  m.SigningScreen.authDevice = m.authTask.authDevice
end sub

' Get Authorized information
sub OnAuthenticateTaskCompleted()
  print "authorized"
  print m.authTask.authorizedDevice
  m.SigningScreen.authorizedDevice = m.authTask.authorizedDevice
  ' Do what you need with the response
end sub

sub OnSignedOutComplete()
  print "signedOut"
end sub

Development

The OpenPass SDK is a standalone headless library defined and managed by the Roku Package Manager. As such the OpenPass SDK is the primary way for developing the SDK. Use VSCode to open openpass-roku-sdk to begin development.

  • Start your dev Server: yarn start or bsc --watch --deploy --host <YOUR_DEVICE_HOST_IP> --password <YOUR_DEVICE_PASSWORD>

  • Lint the project: yarn start or bsc --create-package false --copy-to-staging false

Tests

See Tests README.

Generate Docs

  • npm run docs

Project Documentation

License

OpenPass is released under the MIT license. See LICENSE for details.