New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@keiser/echip-webusb

Package Overview
Dependencies
Maintainers
2
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@keiser/echip-webusb - npm Package Compare versions

Comparing version 1.3.4 to 2.0.0

45

index.d.ts

@@ -1,3 +0,1 @@

// Generated by dts-bundle v0.7.3
export class ChipReaderWatcher extends USBDevice {

@@ -10,5 +8,4 @@ constructor();

}
const _default: ChipReaderWatcher;
export default _default;
export default ChipReaderWatcher;
export class USBDevice {

@@ -36,5 +33,7 @@ protected connectedDevices: Array<WebUSBDevice>;

}
export interface Disposable {
dispose(): void;
}
export class TypedEvent<T> {

@@ -44,2 +43,3 @@ on(listener: Listener<T>): Disposable;

}
export class WebUSBConnectionEvent extends Event {

@@ -50,3 +50,2 @@ readonly device: WebUSBDevice;

type USBDirection = "in" | "out"

@@ -57,3 +56,2 @@ type USBEndpointType = "bulk" | "interrupt" | "isochronous"

type USBTransferStatus = "ok" | "stall" | "babble"
export interface USBEndpoint {

@@ -160,3 +158,2 @@ readonly endpointNumber: number

requestDevice(options?: USBDeviceRequestOptions): Promise<WebUSBDevice>
addEventListener(type: "connect" | "disconnect", listener: EventListener, useCapture?: boolean): void

@@ -206,7 +203,9 @@ }

export type Chip = DataChip | RTCChip | TZChip | BaseChip;
export class DataChip extends BaseChip {
protected data: Promise<DataChipObject>;
protected chipData: DataChipObject;
protected onDataEvent: TypedEvent<DataChipObject>;
constructor(chipId: Uint8Array, owDevice: OWDevice, onDisconnect: (listener: Listener<null>) => Disposable);
getData(): Promise<DataChipObject>;
get data(): DataChipObject;
onData(listener: Listener<DataChipObject>): Disposable;
protected setChipData(data: DataChipObject): void;
clearData(): Promise<void>;

@@ -216,3 +215,2 @@ setData(machines: {

}): Promise<void>;
performSetData(newData: Uint8Array[]): Promise<void>;
}

@@ -222,3 +220,2 @@

constructor(chipId: Uint8Array, owDevice: OWDevice, onDisconnect: (listener: Listener<null>) => Disposable);
getData(): Promise<ChipObject>;
setRTC(): Promise<ChipObject>;

@@ -229,3 +226,2 @@ }

constructor(chipId: Uint8Array, owDevice: OWDevice, onDisconnect: (listener: Listener<null>) => Disposable);
getData(): Promise<ChipObject>;
setTZOffset(): Promise<ChipObject>;

@@ -235,6 +231,11 @@ }

export class BaseChip {
protected chipData: ChipObject;
protected chipId: Uint8Array;
protected owDevice: OWDevice;
protected _onDataEvent: TypedEvent<ChipObject>;
constructor(chipId: Uint8Array, owDevice: OWDevice, onDisconnect: (listener: Listener<null>) => Disposable);
get data(): ChipObject;
get diposed(): boolean;
onData(listener: Listener<ChipObject>): Disposable;
protected setChipData(data: ChipObject): void;
onDisconnect(listener: Listener<null>): Disposable;

@@ -265,2 +266,3 @@ protected disconnected(): void;

}
export class DataChipObject extends ChipObject {

@@ -274,2 +276,3 @@ constructor(data?: Uint8Array[]);

}
export interface MachineObject {

@@ -279,2 +282,3 @@ position: MachinePosition;

}
export interface MachinePosition {

@@ -286,2 +290,3 @@ chest: number | null;

}
export interface MachineSet {

@@ -304,2 +309,3 @@ version: string;

}
export interface MachineTest {

@@ -310,2 +316,3 @@ type: TestType;

}
export interface MachineTestResult {

@@ -317,2 +324,3 @@ power: number;

}
export enum Precision {

@@ -322,2 +330,3 @@ dec = "dec",

}
export enum ForceUnit {

@@ -329,2 +338,3 @@ lb = "lb",

}
export enum TestType {

@@ -335,2 +345,3 @@ power6r = "power6r",

}
export enum ChipType {

@@ -342,2 +353,3 @@ dataChip = 12,

}
export function DataChipParser(data?: Uint8Array[]): {

@@ -348,6 +360,8 @@ machineData: {

validStructure: boolean;
};
}
;
export function DataChipBuilder(machines: {
[index: string]: MachineObject;
}): Uint8Array[];
}
): Uint8Array[];
export function getChipType(value: number): ChipType;

@@ -357,2 +371,1 @@ export function getChipLabel(type: ChipType): "Data Chip" | "RTC Chip" | "TZ Chip" | "Unknown Chip";

export function getCurrentTimeArray(): Uint8Array;
{
"name": "@keiser/echip-webusb",
"version": "1.3.4",
"version": "2.0.0",
"description": "Keiser Air eChip WebUSB Library",

@@ -5,0 +5,0 @@ "keywords": [

@@ -5,3 +5,3 @@ # Keiser Air eChip WebUSB Library

## Project
This library handles communication with the EChip USB reader using WebUSB.
This library handles communication with the Chip USB reader using WebUSB.

@@ -19,10 +19,10 @@ Required Hardware: [USB to 1-Wire/iButton Adapter (DS9490)](https://www.maximintegrated.com/en/products/ibutton/ibutton/DS9490.html)

```ts
import EChipReaderWatcher from '@keiser/echip-webusb'
import ChipReaderWatcher from '@keiser/echip-webusb'
if (EChipReaderWatcher.isConnected) {
console.log('EChip Reader Connected 😄')
if (ChipReaderWatcher.isConnected) {
console.log('Chip Reader Connected 😄')
}
```
The `EChipReaderWatcher` handles permissions and USB connection events. On first load, the browser will not have provided a grant to the site to access the USB device, so the `EChipReaderWatcher.start()` method must be called by an event that originates from a user action. This may only be required once on the first visit to the site, or it may be required each time the site is loaded based on browser vendors preferred implementation.
The `ChipReaderWatcher` handles permissions and USB connection events. On first load, the browser will not have provided a grant to the site to access the USB device, so the `ChipReaderWatcher.start()` method must be called by an event that originates from a user action. This may only be required once on the first visit to the site, or it may be required each time the site is loaded based on browser vendors preferred implementation.

@@ -32,3 +32,3 @@ ```ts

try {
await EChipReaderWatcher.start()
await ChipReaderWatcher.start()
} catch (error) {

@@ -40,32 +40,32 @@ console.error(error.message)

Once the `EChipReaderWatcher.start()` method has been called the class will prompt the browser for permission and begin watching for devices matching the EChip Readers device signature. To be alerted when a device is found, pass a function to the `EChipReaderWatcher.onConnect()` method.
Once the `ChipReaderWatcher.start()` method has been called the class will prompt the browser for permission and begin watching for devices matching the Chip Readers device signature. To be alerted when a device is found, pass a function to the `ChipReaderWatcher.onConnect()` method.
```ts
EChipReaderWatcher.onConnect((echipReader) => {
console.log('EChip Reader Connected 😄')
ChipReaderWatcher.onConnect((chipReader) => {
console.log('Chip Reader Connected 😄')
})
```
The `EChipReaderWatcher.onConnect()` will pass in an `EChipReader` object which is the object bound to the physical device connected. This library is capable of handling multiple EChip Reader devices simultaneously, so the `onConnect()` method has potential for returning multiple `EChipReader` devices over the course of the application's life.
The `ChipReaderWatcher.onConnect()` will pass in a `ChipReader` object which is the object bound to the physical device connected. This library is capable of handling multiple Chip Reader devices simultaneously, so the `onConnect()` method has potential for returning multiple `ChipReader` devices over the course of the application's life.
```ts
echipReader.onDisconnect(() => {
console.log('EChip Reader Disconnected 😞')
chipReader.onDisconnect(() => {
console.log('Chip Reader Disconnected 😞')
})
```
The `EChipReader` object has a `onDisconnect()` method which will alert when the EChip Reader has been disconnected for some reason. Once an `EChipReader` object has been disconnected, it is disposed and cannot be used again. The next time the device is connected, a new `EChipReader` object will be returned.
The `ChipReader` object has an `onDisconnect()` method which will alert when the Chip Reader has been disconnected for some reason. Once a `ChipReader` object has been disconnected, it is disposed and cannot be used again. The next time the device is connected, a new `ChipReader` object will be returned.
```ts
echipReader.onEChipDetect(async (echip) => {
console.log('EChip Connected: ' + echip.id)
console.log(await echip.getData())
chipReader.onChipDetect(async (chip) => {
console.log('Chip Connected: ' + chip.id)
console.log(await chip.getData())
})
```
The `EChipReader` object also has an `onEChipDetect()` method which will alert when a valid EChip has been placed into the reader. The event passes in an `EChip` object that can be used to interact with the EChip data directly. Just like the `EChipReaderWatcher.onConnect()` method, the `EChipReader.onEChipDetect()` method can be called multiple times for multiple EChips all being handled concurrently. Once an EChip is disconnected, the `EChip` object is disposed and cannot be reused.
The `ChipReader` object also has an `onChipDetect()` method which will alert when a valid chip has been placed into the reader. The event passes in a `Chip` object that can be used to interact with the chip data directly. Just like the `ChipReaderWatcher.onConnect()` method, the `ChipReader.onChipDetect()` method can be called multiple times for multiple chips all being handled concurrently. Once a chip is disconnected, the `Chip` object is disposed and cannot be reused.
Full example usage:
```ts
import EChipReaderWatcher from '@keiser/echip-webusb'
import ChipReaderWatcher from '@keiser/echip-webusb'

@@ -78,3 +78,3 @@ document.addEventListener('DOMContentLoaded', event => {

try {
await EChipReaderWatcher.start()
await ChipReaderWatcher.start()
} catch (error) {

@@ -86,12 +86,12 @@ console.error(error.message)

EChipReaderWatcher.onConnect((echipReader) => {
console.log('EChip Reader Connected 😄')
ChipReaderWatcher.onConnect((chipReader) => {
console.log('Chip Reader Connected 😄')
echipReader.onEChipDetect(async (echip) => {
console.log('EChip Connected: ' + echip.id)
console.log(await echip.getData())
chipReader.onChipDetect(async (chip) => {
console.log('Chip Connected: ' + chip.id)
chip.onData(data => console.log(data))
})
echipReader.onDisconnect(() => {
console.log('EChip Reader Disconnected 😞')
chipReader.onDisconnect(() => {
console.log('Chip Reader Disconnected 😞')
})

@@ -104,5 +104,5 @@ })

### EChipReaderWatcher
### ChipReaderWatcher
The `EChipReaderWatcher` is a singleton class which handles the USB device monitoring and permissions handling. There can be only one `EChipReaderWatcher` instance created within a `window` scope, so the library instantiates the class during import and preserves a single instance for all imports.
The `ChipReaderWatcher` is a singleton class which handles the USB device monitoring and permissions handling. There can be only one `ChipReaderWatcher` instance created within a `window` scope, so the library instantiates the class during import and preserves a single instance for all imports.

@@ -112,3 +112,3 @@ #### Properties

| ---- | ----- |
| `isConnected: boolean` | Indicates whether an eChip Reader Device is connected |
| `isConnected: boolean` | Indicates whether a Chip Reader device is connected |

@@ -118,9 +118,9 @@ #### Methods

| ---- | ----- |
| `onConnect(Listener<EChipReader>): Disposable` | Adds an event listener for when an eChip Reader Device is connected. Callback method will be passed the new `EChipReader` instance for the connected device. |
| `onConnect(Listener<ChipReader>): Disposable` | Adds an event listener for when a Chip Reader device is connected. Callback method will be passed the new `ChipReader` instance for the connected device. |
| `start(): Promise<void>` | Initializes the watcher by first requesting permissions and then doing a hardware search. This method must be triggered by a user action such as a click event or the permission request will be denied. |
| `stop(): Promise<void>` | Closes all active connections. |
### EChipReader
### ChipReader
The `EChipReader` instance is passed into the `onConnect` callback function and is the interface to the connected eChip Reader Device.
The `ChipReader` instance is passed into the `onConnect` callback function and is the interface to the connected Chip Reader device.

@@ -136,8 +136,8 @@ #### Properties

| ---- | ----- |
| `onDisconnect(Listener<null>): Disposable` | Adds an event listener for when this eChip Reader Device becomes disconnected. The instance will be disposed following this event. |
| `onEChipDetect(Listener<EChip>): Disposable` | Adds an event listener for when an eChip is connected to the eChip Reader device. Callback method will be passed the new `EChip` instance for the connected eChip. |
| `onChipDetect(Listener<Chip>): Disposable` | Adds an event listener for when a chip is connected to the Chip Reader device. Callback method will be passed the new `Chip` instance for the connected chip. |
| `onDisconnect(Listener<null>): Disposable` | Adds an event listener for when this Chip Reader device becomes disconnected. The instance will be disposed following this event. |
### EChip
### BaseChip
The `EChip` instance is passed into the `onEChipDetect` callback function and is the interface to the connected eChip device.
The `BaseChip` instance is passed into the `onChipDetect` callback function and is the interface to the connected chip device. There are several different extensions to the base `BaseChip` object that can identified by doing a `instanceOf` check or looking at the `type` property.

@@ -147,4 +147,6 @@ #### Properties

| ---- | ----- |
| `disposed: boolean` | Indicates if the eChip connection has been severed and the class instance disposed. |
| `data: ChipObject` | Generic object with the current data from the chip. |
| `id: string` | UUID string of the eChip. |
| `disposed: boolean` | Indicates if the eChip connection has been severed and the class instance disposed. |
| `type: ChipType` | `ChipType` enum value corresponding to the type of chip. |

@@ -155,12 +157,32 @@ #### Methods

| `destroy(): void` | Called to disconnect the eChip device. |
| `onDisconnect(Listener<null>): Disposable` | Adds an event listener for when this eChip becomes disconnected. The instance will be disposed following this event. |
| `getData(): Promise<EChipObject>` | Promise resolves with an `EChipObject` representing the data on the eChip. |
| `clearData(): Promise<EChipObject>` | Method clears the data on the eChip and resolves with an `EChipObject` of the new blank eChip data. |
| `setData({string: MachineObject}): Promise<EChipObject>` | Method sets the data on the eChip according to the data passed into the method. The method accepts an object with `string` keys corresponding to the machine's 4-digit model number with the `MachineObject` as the value of the property. |
| `onDisconnect(Listener<null>): Disposable` | Adds an event listener for when this chip becomes disconnected. The instance will be disposed following this event. |
| `onData(Listener<ChipObject>): Disposable` | Adds an event listener for when the chip data has changed. |
## TZChip and RTCChip
The `TZChip` and `RTCChip` are class extensions on the `BaseChip` class. They add no additional properties or methods, but allow the identification of chip type and will perform chip set operations automatically when detected. An event issued on the `onData` event indicates that the chips data has been successfully updated.
## DataChip
The `DataChip` class extension on the `BaseChip` class adds additional properties and methods specific to the data chip.
#### Methods
| Name | Usage |
| ---- | ----- |
| `clearData(): Promise<void>` | Method clears the data on the chip and resolve the promise on successful write. An `onData` event will be issues for the blank chip data. |
| `setData({string: MachineObject}): Promise<void>` | Method sets the data on the chip according to the data passed into the method. The method accepts an object with `string` keys corresponding to the machine's 4-digit model number with the `MachineObject` as the value of the property. Method resolve the promise on successful write. An `onData` event will be issues for the freshly written chip data. |
### Data Structures
#### EChipObject
#### ChipObject
```ts
interface EChipObject {
interface ChipObject {
type: ChipType
}
```
#### DataChipObject
```ts
interface DataChipObject {
type: ChipType
machineData: {[index: string]: MachineObject}

@@ -250,2 +272,9 @@ rawData: Uint8Array[]

}
enum ChipType {
dataChip = 12,
rtcChip = 36,
tzChip = 45,
unknown = 0
}
```

@@ -252,0 +281,0 @@

Sorry, the diff of this file is too big to display

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