TypeScript SDK for Common Use Self-Service v2 Platform
Built from the ground up with TypeScript, providing complete type safety and excellent IDE support for all CUSS2 operations.
Full support for all CUSS2 peripheral devices including printers, scanners, card readers, scales, and baggage handling systems.
Built-in WebSocket management with automatic reconnection, OAuth token refresh, and exponential backoff strategies.
Reactive architecture with typed events for state changes, component updates, and real-time device data streams.
Automatic state synchronization based on required component availability with built-in state transition validation.
Designed for the modern Deno runtime with ESM modules, while providing browser bundles for web applications.
// Import from CDN
import { Cuss2 } from "https://esm.sh/jsr/@cuss/cuss2-ts@latest";
// Connect to CUSS2 platform
const cuss2 = Cuss2.connect(
"your-client-id",
"your-client-secret",
"wss://platform.example.com" // Optional custom URL
);
// Wait for connection
await cuss2.connected;
console.log("Connected! State:", cuss2.state);
// Work with components
if (cuss2.barcodeReader) {
await cuss2.barcodeReader.enable();
cuss2.barcodeReader.on("data", (data) => {
console.log("Barcodes:", data); // data is string[]
});
}
Note: Use this code inside a <script type="module"> tag in your HTML file.
// Import from JSR
import { Cuss2 } from "jsr:@cuss/cuss2-ts@latest";
// Connect with full configuration
const cuss2 = Cuss2.connect(
"client-id",
"client-secret",
"wss://cuss-platform.example.com",
"device-id",
"https://oauth.example.com/token"
);
// Wait for connection
await cuss2.connected;
// Request state transitions
await cuss2.requestInitializeState();
await cuss2.requestAvailableState();
// Enable components
if (cuss2.boardingPassPrinter) {
await cuss2.boardingPassPrinter.enable();
await cuss2.boardingPassPrinter.send(printData);
}
// Install from JSR for Node.js
// npx jsr add @cuss/cuss2-ts
import { Cuss2 } from "@cuss/cuss2-ts";
const cuss2 = Cuss2.connect(
process.env.CLIENT_ID,
process.env.CLIENT_SECRET
);
cuss2.connected.then(async () => {
console.log("Environment:", cuss2.environment);
console.log("Components:", Object.keys(cuss2.components));
// Listen for state changes
cuss2.on("stateChange", (change) => {
console.log(`State: ${change.previous} → ${change.current}`);
});
});
CUSS2 applications transition through well-defined states following strict rules