Socket
Socket
Sign inDemoInstall

usb

Package Overview
Dependencies
Maintainers
3
Versions
96
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

usb - npm Package Compare versions

Comparing version 2.11.0 to 2.12.0

prebuilds/android-arm/usb.armv7.node

16

CHANGELOG.md
# Changelog
## [2.12.0] - 2024-03-02
#### Added
- Added prebuilt binary for Windows Arm64 - [`735`](https://github.com/node-usb/node-usb/pull/735) ([Rob Moran](https://github.com/thegecko))
- Added exception handling - [`738`](https://github.com/node-usb/node-usb/pull/738) ([Rob Moran](https://github.com/thegecko))
- Added exception when trying to transfer and device is closed - [`715`](https://github.com/node-usb/node-usb/pull/715) ([Rob Moran](https://github.com/thegecko))
### Changed
- Precreate async transfer functions to increase speed - [`725`](https://github.com/node-usb/node-usb/pull/725) ([Cosmin Tanislav](https://github.com/Demon000))
- Precreate all other async functions to increase speed - [`730`](https://github.com/node-usb/node-usb/pull/730) ([Rob Moran](https://github.com/thegecko))
### Fixed
- Explicitly set configuration in WebUSB for vendor-specific devices on macos - [`739`](https://github.com/node-usb/node-usb/pull/739) ([Jouni Airaksinen](https://github.com/jounii))
- Handle exception when loading library on WSL - [`726`](https://github.com/node-usb/node-usb/pull/726) ([Julian Waller](https://github.com/Julusian))
- Comment typo fix - [`723`](https://github.com/node-usb/node-usb/pull/723) ([koji](https://github.com/koji))
## [2.11.0] - 2023-10-02

@@ -4,0 +20,0 @@

3

dist/usb/device.js

@@ -64,6 +64,7 @@ "use strict";

this.__open();
// The presence of interfaces is used to determine if the device is open
this.interfaces = [];
if (defaultConfig === false) {
return;
}
this.interfaces = [];
const len = this.configDescriptor ? this.configDescriptor.interfaces.length : 0;

@@ -70,0 +71,0 @@ for (let i = 0; i < len; i++) {

@@ -39,2 +39,3 @@ /// <reference types="node" />

pollActive: boolean;
transferAsync: (length: number) => Promise<Buffer | undefined>;
constructor(device: Device, descriptor: EndpointDescriptor);

@@ -80,2 +81,4 @@ /**

direction: 'in' | 'out';
transferAsync: (buffer: Buffer) => Promise<number>;
constructor(device: Device, descriptor: EndpointDescriptor);
/**

@@ -82,0 +85,0 @@ * Perform a transfer to write `data` to the endpoint.

@@ -6,2 +6,3 @@ "use strict";

const bindings_1 = require("./bindings");
const util_1 = require("util");
const isBuffer = (obj) => obj && obj instanceof Uint8Array;

@@ -47,2 +48,3 @@ /** Common base for InEndpoint and OutEndpoint. */

this.pollActive = false;
this.transferAsync = util_1.promisify(this.transfer).bind(this);
}

@@ -171,6 +173,7 @@ /**

class OutEndpoint extends Endpoint {
constructor() {
super(...arguments);
constructor(device, descriptor) {
super(device, descriptor);
/** Endpoint direction. */
this.direction = 'out';
this.transferAsync = util_1.promisify(this.transfer).bind(this);
}

@@ -177,0 +180,0 @@ /**

@@ -18,5 +18,8 @@ "use strict";

});
Object.getOwnPropertyNames(device_1.ExtendedDevice.prototype).forEach(name => {
Object.defineProperty(usb.Device.prototype, name, Object.getOwnPropertyDescriptor(device_1.ExtendedDevice.prototype, name) || Object.create(null));
});
// `usb.Device` is not defined when `usb.INIT_ERROR` is true
if (usb.Device) {
Object.getOwnPropertyNames(device_1.ExtendedDevice.prototype).forEach(name => {
Object.defineProperty(usb.Device.prototype, name, Object.getOwnPropertyDescriptor(device_1.ExtendedDevice.prototype, name) || Object.create(null));
});
}
// Devices delta support for non-libusb hotplug events

@@ -23,0 +26,0 @@ let hotPlugDevices = new Set();

@@ -15,2 +15,4 @@ import { LibUSBException, Device } from './bindings';

endpoints: Endpoint[];
releaseAsync: () => Promise<void>;
setAltSettingAsync: (alternateSetting: number) => Promise<void>;
constructor(device: Device, id: number);

@@ -17,0 +19,0 @@ protected refresh(): void;

@@ -6,2 +6,3 @@ "use strict";

const endpoint_1 = require("./endpoint");
const util_1 = require("util");
class Interface {

@@ -14,2 +15,4 @@ constructor(device, id) {

this.refresh();
this.releaseAsync = util_1.promisify(this.release).bind(this);
this.setAltSettingAsync = util_1.promisify(this.setAltSetting).bind(this);
}

@@ -16,0 +19,0 @@ refresh() {

@@ -24,2 +24,6 @@ /// <reference types="w3c-web-usb" />

configurations: USBConfiguration[];
private controlTransferAsync;
private setConfigurationAsync;
private resetAsync;
private getStringDescriptorAsync;
private constructor();

@@ -50,2 +54,3 @@ get configuration(): USBConfiguration | undefined;

private _releaseInterface;
private checkDeviceOpen;
}

@@ -6,2 +6,3 @@ "use strict";

const util_1 = require("util");
const os_1 = require("os");
const LIBUSB_TRANSFER_TYPE_MASK = 0x03;

@@ -31,2 +32,6 @@ const ENDPOINT_NUMBER_MASK = 0x7f;

this.deviceVersionSubminor = deviceVersion.sub;
this.controlTransferAsync = util_1.promisify(this.device.controlTransfer).bind(this.device);
this.setConfigurationAsync = util_1.promisify(this.device.setConfiguration).bind(this.device);
this.resetAsync = util_1.promisify(this.device.reset).bind(this.device);
this.getStringDescriptorAsync = util_1.promisify(this.device.getStringDescriptor).bind(this.device);
}

@@ -99,4 +104,3 @@ static async createInstance(device) {

try {
const setConfiguration = util_1.promisify(this.device.setConfiguration).bind(this.device);
await setConfiguration(configurationValue);
await this.setConfigurationAsync(configurationValue);
}

@@ -166,4 +170,3 @@ catch (error) {

const iface = this.device.interface(interfaceNumber);
const setAltSetting = util_1.promisify(iface.setAltSetting).bind(iface);
await setAltSetting(alternateSetting);
await iface.setAltSettingAsync(alternateSetting);
}

@@ -176,5 +179,5 @@ catch (error) {

try {
this.checkDeviceOpen();
const type = this.controlTransferParamsToType(setup, usb.LIBUSB_ENDPOINT_IN);
const controlTransfer = util_1.promisify(this.device.controlTransfer).bind(this.device);
const result = await controlTransfer(type, setup.request, setup.value, setup.index, length);
const result = await this.controlTransferAsync(type, setup.request, setup.value, setup.index, length);
return {

@@ -201,6 +204,6 @@ data: result ? new DataView(new Uint8Array(result).buffer) : undefined,

try {
this.checkDeviceOpen();
const type = this.controlTransferParamsToType(setup, usb.LIBUSB_ENDPOINT_OUT);
const controlTransfer = util_1.promisify(this.device.controlTransfer).bind(this.device);
const buffer = data ? Buffer.from(data) : Buffer.alloc(0);
const bytesWritten = await controlTransfer(type, setup.request, setup.value, setup.index, buffer);
const bytesWritten = await this.controlTransferAsync(type, setup.request, setup.value, setup.index, buffer);
return {

@@ -224,4 +227,3 @@ bytesWritten,

const wIndex = endpointNumber | (direction === 'in' ? usb.LIBUSB_ENDPOINT_IN : usb.LIBUSB_ENDPOINT_OUT);
const controlTransfer = util_1.promisify(this.device.controlTransfer).bind(this.device);
await controlTransfer(usb.LIBUSB_RECIPIENT_ENDPOINT, CLEAR_FEATURE, ENDPOINT_HALT, wIndex, Buffer.from(new Uint8Array()));
await this.controlTransferAsync(usb.LIBUSB_RECIPIENT_ENDPOINT, CLEAR_FEATURE, ENDPOINT_HALT, wIndex, Buffer.from(new Uint8Array()));
}

@@ -234,5 +236,5 @@ catch (error) {

try {
this.checkDeviceOpen();
const endpoint = this.getEndpoint(endpointNumber | usb.LIBUSB_ENDPOINT_IN);
const transfer = util_1.promisify(endpoint.transfer).bind(endpoint);
const result = await transfer(length);
const result = await endpoint.transferAsync(length);
return {

@@ -259,6 +261,6 @@ data: result ? new DataView(new Uint8Array(result).buffer) : undefined,

try {
this.checkDeviceOpen();
const endpoint = this.getEndpoint(endpointNumber | usb.LIBUSB_ENDPOINT_OUT);
const transfer = util_1.promisify(endpoint.transfer).bind(endpoint);
const buffer = Buffer.from(data);
const bytesWritten = await transfer(buffer);
const bytesWritten = await endpoint.transferAsync(buffer);
return {

@@ -281,4 +283,3 @@ bytesWritten,

try {
const reset = util_1.promisify(this.device.reset).bind(this.device);
await reset();
await this.resetAsync();
}

@@ -302,2 +303,7 @@ catch (error) {

this.device.open();
// Explicitly set configuration for vendor-specific devices on macos
// https://github.com/node-usb/node-usb/issues/61
if (this.deviceClass === 0xff && os_1.platform() === 'darwin') {
await this.setConfigurationAsync(1);
}
}

@@ -328,4 +334,3 @@ this.manufacturerName = await this.getStringDescriptor(this.device.deviceDescriptor.iManufacturer);

try {
const getStringDescriptor = util_1.promisify(this.device.getStringDescriptor).bind(this.device);
const buffer = await getStringDescriptor(index);
const buffer = await this.getStringDescriptorAsync(index);
return buffer ? buffer.toString() : '';

@@ -421,4 +426,3 @@ }

const iface = this.device.interface(interfaceNumber);
const release = util_1.promisify(iface.release).bind(iface);
await release();
await iface.releaseAsync();
}

@@ -429,4 +433,9 @@ catch (error) {

}
checkDeviceOpen() {
if (!this.opened) {
throw new Error('The device must be opened first');
}
}
}
exports.WebUSBDevice = WebUSBDevice;
//# sourceMappingURL=webusb-device.js.map

@@ -5,3 +5,3 @@ {

"license": "MIT",
"version": "2.11.0",
"version": "2.12.0",
"main": "dist/index.js",

@@ -61,3 +61,3 @@ "engines": {

"devDependencies": {
"@types/node": "^20.1.4",
"@types/node": "^20.11.20",
"@typescript-eslint/eslint-plugin": "^5.45.1",

@@ -68,4 +68,4 @@ "@typescript-eslint/parser": "^5.45.1",

"mocha": "^10.1.0",
"node-gyp": "^9.3.0",
"prebuildify": "^5.0.1",
"node-gyp": "^10.0.1",
"prebuildify": "^6.0.0",
"prebuildify-ci": "^1.0.5",

@@ -72,0 +72,0 @@ "prebuildify-cross": "^5.0.0",

@@ -188,3 +188,3 @@ # USB Library for Node.JS

const customWebUSB = new WebUSB({
// Bypass cheking for authorised devices
// Bypass checking for authorised devices
allowAllDevices: true

@@ -191,0 +191,0 @@ });

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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