Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@elevated-libs/cuss2

Package Overview
Dependencies
Maintainers
0
Versions
135
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@elevated-libs/cuss2

Interact with a CUSS 2 API using a simple interface leveraging the asyncronicity of event driven architectures. By using the Elevated CUSS library you will get:

  • 2.3.0
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
20
increased by25%
Maintainers
0
Weekly downloads
 
Created
Source

cuss2

About Elevated CUSS Library

Interact with a CUSS 2 API using a simple interface leveraging the asyncronicity of event driven architectures. By using the Elevated CUSS library you will get:

  • Simple device interfaces
  • Subscribable events for all CUSS states and device status

CUSS (Common Use Self-Service) is a modern Typescript library facilitating application development of Self-Service check-in apps, self-tagging apps and self bag-drop apps.

You can have CUSS 2 NOW and run a modern browser entirely without plugins or Java. Finally, your Information Security department will be able to sign off on your CUSS applications.

We have also created typescript angular and react libs facilitating rapid development of CUSS applications.

The library and corresponding app platform also ensure backwards compatibility to legacy 1.X versions of CUSS.

The Sandbox

While you are developing your application, you can use the Elevated CUSS Sandbox to test against real platform responses. Watch your application respond correctly to CUSS Events like a paper jam or a required device unavailable.

Getting Started

  1. Request an access token from the Elevation Software Team.

  2. Generate an .npmrc file and add the token to this file.

To install the lib run:

npm install cuss2

To begin using the library, you will need to import the library into your project and set up a connection.

import { Cuss2 } from "cuss2";

const serviceState: { cuss2: Cuss2 | any} = { ref: null };
const connect = async (cuss2URL: string, oauthURL, deviceID: string, clientId: string, clientSecret: string): Promise<Cuss2 | null> => {
    // Avoid multiple subscriptions
    if (serviceState.ref) {
        return serviceState.ref;
    }
    const cuss2 = await Cuss2.connect(cuss2URL, oauthURL, deviceID, clientId, clientSecret);
    serviceState.cuss2 = cuss2;
    return ref;
};

// Connect to cuss2 Platform
const { clientId, clientSecret, platformURL, oauthURL, deviceID } = platformConfig;
connect(platformURL, oauthURL, deviceID, clientId, clientSecret)
  .then(checkDevices)
  .catch(connectionFailure);

State Transitions

One of the most important aspect in a CUSS platform, is the ability to transition between application states correctly, that is why we tried to simplify all different aspect of the transitions through a simple rxjs subscription.

sequenceDiagram
    Platform->>+App: Platform Initialize App
    App-->>Platform: Request Unavailable
    App-->>Platform: Check for required components
    App-->>Platform: Request Available
// CUSS Transitions

// Instantiating a connection
const cuss2 = await Cuss2.connect(cuss2URL, oauthURL, deviceID, clientId, clientSecret);

// Moving to unavailable
await cuss2.requestUnavailableState();

// checking for a ATB Printer
if (cuss2?.boardingPassPrinter) {
  // Moving to Available
  await cuss2.requestAvailableState();
}

// Subscribe to active state
cuss2.activated.subscribe(() => {
  console.log('Application is active');
});

// Subscribe when application goes from active to available
cuss2.deactivated.subscribe(() => {
  console.log('Application is not longer active');
});

Interacting with CUSS Devices

The library provides a simple and intuitive interface to interact with common CUSS devices, that enable developer to develop complex platform interactions without any unnecessary boilerplate.

sequenceDiagram
    App-->>Component: Query 
    Component-->>App: RC_OK
    App-->>Component: Enable
    App-->>Component: Interactions
    App-->>Component: Disable
MediaOutputs
const cuss2 = await Cuss2.connect(cuss2URL, oauthURL, deviceID, clientId, clientSecret);

// query ATB
 const res: PlatformData = await cuss2?.boardingPassPrinter.query();

 // validate component state
 if (res.meta.componentState !== ComponentState.READY) {
    console.log('Component is not ready')
 } else {

  // Enable component
  await cuss2.boardingPassPrinter.enable();

  // SETUP ATB
  await cuss2.boardingPassPrinter.setup(<PECTAB>);

  // Print boarding pass
  await cuss2.boardingPassPrinter.send(<PECTAB>);

  // Helper function to do both setup and send
  await cuss2.boardingPassPrinter.setupAndPrintRaw([<PECTAB_ARRAY>], <STREAM>);

  // Disable component
  await cuss2.boardingPassPrinter.disable();
 }

MediaInput
const cuss2 = await Cuss2.connect(cuss2URL, oauthURL, deviceID, clientId, clientSecret);

// query component
 const res: PlatformData = await cuss2?.barcodeReader.query();

 // validate component state
 if (res.meta.componentState !== ComponentState.READY) {
    console.log('Component is not ready')
 } else {
  // Enable component
  await cuss2.barcodeReader.enable();

  // Subscribe to MEDIA_PRESENT
  cuss2.barcodeReader.data.asObservable().subscribe((data: DataRecordList) => {
    console.log(`Barcode Data ${data}`);

    // Disable component
    await cuss2.barcodeReader.disable();
  });
 }

Methods and Components

Below are the methods you can use to interact with the CUSS 2.0 API and a list of components.


MethodDescription
announcement(componentID, rawData)
MethodDescription
play(componentID, rawData)Play the announcement
pause(componentID)Pause the announcement
resume(componentID)Resume the announcement
stop(componentID)Stop the announcement
cancel(componentID)Sends a cancel command to a given component (device).
checkRequiredComponentsAndSyncState()Check if all required components are available and move application to the appropriate state based on status.
connect(url, client_id, client_secret, options opt)Connect to the cuss platform.
disable(componentID)Sends disable command to a given component (device).
enable(componentID)Sends enable command to a given component (device).
getComponents()Get a list of components.
getEnvironment()Get the current environment level.
getStatus(componentID)Get the status of a given component (device).
queryComponents()Query each component for its current state.
requestActiveState()Request the platform to change the application state to Active state.
requestReload()Request the platform to reload the application.
setup(componentID, dataExchange)Send setup instructions to a given component (device).
staterequest(state, reasonCode, reason)Sends request to the platform for the application to change states.
authorize(url, client_id, client_secret, timeout)Retrieve a token from the CUSS Oauth Server using a client id and client secret.
connect(baseURL, oauthURL, deviceID,client_id, client_secret, tokenURL)Connects to a CUSS Platform at the provided URL.

ComponentsDescription
AnnouncementA component that announces messages.
BagTagPrinterA component that prints bag tags.
BarcodeReaderA component that reads barcodes.
BoardingPassPrinterA component that prints boarding passes.
CardReaderA component that reads cards.
DispenserA part of a printer that dispenses printed media.
DocumentReaderA component that reads documents.
FeederA part of a printer that feeds paper.
HeadsetA component that provides audio feedback.
IlluminationA component that controls illumination.
KeypadA component that provides keypad input.
Card Reader

Besides inheriting from all the Media Input methods, the library provides an automatic way to setup a card reader component to read ISO track data without truncation. This feature is only available on Platforms data provide a card reader component interface on CUSS 2 Platforms. The magtripe capabilities are officcially removed from CUSS 2 specification.

const cuss2 = await Cuss2.connect(cuss2URL, oauthURL, deviceID, clientId, clientSecret);

// query component
 const res: PlatformData = await cuss2?.cardReader.query();

 // validate component state
 if (res.meta.componentState !== ComponentState.READY) {
    console.log('Component is not ready')
 } else {
  // Enable component for ISO track data, for 10 secs then automatically disable the device
  await cuss2.cardReader.readPayment(5000);

  // Subscribe to MEDIA_PRESENT
  cuss2.cardReader.data.asObservable().subscribe((data: DataRecordList) => {
    console.log(`card Reader Data ${data}`);
  });
 }

FAQs

Package last updated on 11 Sep 2024

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