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

@trezor/transport

Package Overview
Dependencies
Maintainers
4
Versions
62
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@trezor/transport - npm Package Compare versions

Comparing version 1.3.4 to 1.3.5-beta.1

43

lib/api/udp.d.ts

@@ -16,43 +16,4 @@ import UDP from 'dgram';

private listenLoop;
write(path: string, buffer: Buffer, signal?: AbortSignal): Promise<import("../types").Success<undefined> | {
success: false;
error: "Unable to open device";
} | {
success: false;
error: "A transfer error has occurred.";
} | {
success: false;
error: "device not found";
} | {
success: false;
error: "device disconnected during action";
} | {
success: false;
error: "unexpected error";
} | {
success: false;
error: "Aborted by signal";
}>;
read(_path: string, signal?: AbortSignal): Promise<import("../types").Success<Buffer> | {
success: false;
error: "Unable to open device";
} | {
success: false;
error: "A transfer error has occurred.";
} | {
success: false;
error: "device not found";
} | {
success: false;
error: "device disconnected during action";
} | {
success: false;
error: "unexpected error";
} | {
success: false;
error: "Aborted by signal";
} | {
success: false;
error: "Aborted by timeout";
}>;
write(path: string, buffer: Buffer, signal?: AbortSignal): Promise<import("../types").Success<undefined> | import("../types").ErrorGeneric<"Unable to open device" | "A transfer error has occurred." | "device not found" | "device disconnected during action" | "unexpected error" | "Aborted by signal">>;
read(_path: string, signal?: AbortSignal): Promise<import("../types").Success<Buffer> | import("../types").ErrorGeneric<"Unable to open device" | "A transfer error has occurred." | "device not found" | "device disconnected during action" | "unexpected error" | "Aborted by signal" | "Aborted by timeout">>;
private ping;

@@ -59,0 +20,0 @@ enumerate(signal?: AbortSignal): Promise<import("../types").Success<{

@@ -46,8 +46,4 @@ import { AbstractApi, AbstractApiConstructorParams } from './abstract';

success: false;
error: "A transfer error has occurred." | "Aborted by signal";
error: "A transfer error has occurred.";
message: string | undefined;
} | {
success: false;
error: "unexpected error";
message: string;
}>;

@@ -54,0 +50,0 @@ write(path: string, buffer: Buffer, signal?: AbortSignal): Promise<import("../types").Success<undefined> | {

38

lib/api/usb.js

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

}
return this.unknownError(err, [
ERRORS.ABORTED_BY_SIGNAL,
ERRORS.INTERFACE_DATA_TRANSFER,
]);
return this.error({ error: ERRORS.INTERFACE_DATA_TRANSFER, message: err.message });
}

@@ -275,4 +272,4 @@ });

return tslib_1.__awaiter(this, void 0, void 0, function* () {
var _a, _b, _c, _d, _e, _f, _g;
const device = this.findDevice(path);
var _a, _b, _c, _d, _e, _f, _g, _h;
let device = this.findDevice(path);
if (!device) {

@@ -283,23 +280,32 @@ return this.error({ error: ERRORS.DEVICE_NOT_FOUND });

if (device.opened) {
if (!this.debugLink) {
try {
yield device.reset();
}
catch (err) {
(_b = this.logger) === null || _b === void 0 ? void 0 : _b.error(`usb: device.reset error ${err}. device: ${this.formatDeviceForLog(device)}`);
}
}
}
device = this.findDevice(path);
if (device === null || device === void 0 ? void 0 : device.opened) {
try {
const interfaceId = this.debugLink ? constants_1.DEBUGLINK_INTERFACE_ID : constants_1.INTERFACE_ID;
(_b = this.logger) === null || _b === void 0 ? void 0 : _b.debug(`usb: device.releaseInterface: ${interfaceId}`);
if (!this.debugLink) {
yield device.reset();
}
(_c = this.logger) === null || _c === void 0 ? void 0 : _c.debug(`usb: device.releaseInterface: ${interfaceId}`);
yield device.releaseInterface(interfaceId);
(_c = this.logger) === null || _c === void 0 ? void 0 : _c.debug(`usb: device.releaseInterface done: ${interfaceId}. device: ${this.formatDeviceForLog(device)}`);
(_d = this.logger) === null || _d === void 0 ? void 0 : _d.debug(`usb: device.releaseInterface done: ${interfaceId}. device: ${this.formatDeviceForLog(device)}`);
}
catch (err) {
(_d = this.logger) === null || _d === void 0 ? void 0 : _d.error(`usb: releaseInterface error ${err}. device: ${this.formatDeviceForLog(device)}`);
(_e = this.logger) === null || _e === void 0 ? void 0 : _e.error(`usb: releaseInterface error ${err}. device: ${this.formatDeviceForLog(device)}`);
}
}
if (device.opened) {
device = this.findDevice(path);
if (device === null || device === void 0 ? void 0 : device.opened) {
try {
(_e = this.logger) === null || _e === void 0 ? void 0 : _e.debug(`usb: device.close`);
(_f = this.logger) === null || _f === void 0 ? void 0 : _f.debug(`usb: device.close`);
yield device.close();
(_f = this.logger) === null || _f === void 0 ? void 0 : _f.debug(`usb: device.close done. device: ${this.formatDeviceForLog(device)}`);
(_g = this.logger) === null || _g === void 0 ? void 0 : _g.debug(`usb: device.close done. device: ${this.formatDeviceForLog(device)}`);
}
catch (err) {
(_g = this.logger) === null || _g === void 0 ? void 0 : _g.debug(`usb: device.close error ${err}. device: ${this.formatDeviceForLog(device)}`);
(_h = this.logger) === null || _h === void 0 ? void 0 : _h.debug(`usb: device.close error ${err}. device: ${this.formatDeviceForLog(device)}`);
return this.error({

@@ -306,0 +312,0 @@ error: ERRORS.INTERFACE_UNABLE_TO_CLOSE_DEVICE,

@@ -30,11 +30,2 @@ import { AbstractTransport, AbstractTransportParams, AbstractTransportMethodParams } from './abstract';

success: false;
error: "unexpected error";
} | {
success: false;
error: "Aborted by signal";
} | {
success: false;
error: "Aborted by timeout";
} | {
success: false;
error: NonNullable<"Aborted by signal" | "Aborted by timeout">;

@@ -46,23 +37,8 @@ message: string | undefined;

message: string;
} | import("../types").Success<import("../types").Descriptor[]>>;
} | import("../types").ErrorGeneric<"unexpected error" | "Aborted by signal" | "Aborted by timeout"> | import("../types").Success<import("../types").Descriptor[]>>;
acquire({ input, signal }: AbstractTransportMethodParams<'acquire'>): Promise<{
success: false;
error: "Unable to open device";
} | {
success: false;
error: "device not found";
} | {
success: false;
error: "unexpected error";
} | {
success: false;
error: "Aborted by signal";
} | {
success: false;
error: "Aborted by timeout";
} | {
success: false;
error: "wrong previous session" | "descriptor not found";
message: string | undefined;
} | import("../types").Success<Session> | {
} | import("../types").ErrorGeneric<"Unable to open device" | "device not found" | "unexpected error" | "Aborted by signal" | "Aborted by timeout"> | import("../types").Success<Session> | {
success: false;

@@ -89,25 +65,4 @@ error: NonNullable<"wrong previous session" | "device disconnected during action" | "Aborted by signal" | "Aborted by timeout">;

} | import("../types").Success<null>>;
call({ session, name, data, protocol: customProtocol, signal, }: AbstractTransportMethodParams<'call'>): Promise<{
call({ session, name, data, protocol: customProtocol, signal, }: AbstractTransportMethodParams<'call'>): Promise<import("../types").ErrorGeneric<"Unable to open device" | "A transfer error has occurred." | "device not found" | "device disconnected during action" | "unexpected error" | "Aborted by signal" | "Aborted by timeout"> | {
success: false;
error: "Unable to open device";
} | {
success: false;
error: "A transfer error has occurred.";
} | {
success: false;
error: "device not found";
} | {
success: false;
error: "device disconnected during action";
} | {
success: false;
error: "unexpected error";
} | {
success: false;
error: "Aborted by signal";
} | {
success: false;
error: "Aborted by timeout";
} | {
success: false;
error: NonNullable<"Aborted by signal" | "Aborted by timeout">;

@@ -127,20 +82,2 @@ message: string | undefined;

success: false;
error: "Unable to open device";
} | {
success: false;
error: "A transfer error has occurred.";
} | {
success: false;
error: "device not found";
} | {
success: false;
error: "device disconnected during action";
} | {
success: false;
error: "unexpected error";
} | {
success: false;
error: "Aborted by signal";
} | {
success: false;
error: NonNullable<"Aborted by signal" | "Aborted by timeout">;

@@ -156,29 +93,8 @@ message: string | undefined;

message: string | undefined;
} | {
} | import("../types").ErrorGeneric<"Unable to open device" | "A transfer error has occurred." | "device not found" | "device disconnected during action" | "unexpected error" | "Aborted by signal"> | {
success: true;
payload: undefined;
}>;
receive({ session, protocol: customProtocol, signal, }: AbstractTransportMethodParams<'receive'>): Promise<{
receive({ session, protocol: customProtocol, signal, }: AbstractTransportMethodParams<'receive'>): Promise<import("../types").ErrorGeneric<"Unable to open device" | "A transfer error has occurred." | "device not found" | "device disconnected during action" | "unexpected error" | "Aborted by signal" | "Aborted by timeout"> | {
success: false;
error: "Unable to open device";
} | {
success: false;
error: "A transfer error has occurred.";
} | {
success: false;
error: "device not found";
} | {
success: false;
error: "device disconnected during action";
} | {
success: false;
error: "unexpected error";
} | {
success: false;
error: "Aborted by signal";
} | {
success: false;
error: "Aborted by timeout";
} | {
success: false;
error: NonNullable<"Aborted by signal" | "Aborted by timeout">;

@@ -200,12 +116,3 @@ message: string | undefined;

}>>;
releaseDevice(session: Session): Promise<import("../types").Success<undefined> | {
success: false;
error: "device not found";
} | {
success: false;
error: "unexpected error";
} | {
success: false;
error: "Unable to close device";
}>;
releaseDevice(session: Session): Promise<import("../types").Success<undefined> | import("../types").ErrorGeneric<"Unable to close device" | "device not found" | "unexpected error">>;
stop(): void;

@@ -212,0 +119,0 @@ }

import { AbstractTransport, AbstractTransportParams, AbstractTransportMethodParams } from './abstract';
import * as ERRORS from '../errors';
import { Descriptor, Session } from '../types';
type BridgeCommonErrors = typeof ERRORS.HTTP_ERROR | typeof ERRORS.WRONG_RESULT_TYPE | typeof ERRORS.UNEXPECTED_ERROR;
type BridgeConstructorParameters = AbstractTransportParams & {

@@ -15,5 +17,2 @@ url?: string;

success: false;
error: "unexpected error";
} | {
success: false;
error: NonNullable<"Aborted by signal" | "Aborted by timeout">;

@@ -25,9 +24,3 @@ message: string | undefined;

message: string;
} | {
success: false;
error: "Wrong result type.";
} | {
success: false;
error: "Network request failed";
}>;
} | import("../types").ErrorGeneric<BridgeCommonErrors>>;
listen(): import("../types").Success<undefined> | {

@@ -41,5 +34,2 @@ success: false;

success: false;
error: "unexpected error";
} | {
success: false;
error: NonNullable<"Aborted by signal" | "Aborted by timeout">;

@@ -51,29 +41,5 @@ message: string | undefined;

message: string;
} | {
} | import("../types").Success<Descriptor[]> | import("../types").ErrorGeneric<BridgeCommonErrors>>;
acquire({ input, signal }: AbstractTransportMethodParams<'acquire'>): Promise<import("../types").Success<Session> | {
success: false;
error: "Wrong result type.";
} | {
success: false;
error: "Network request failed";
} | import("../types").Success<Descriptor[]>>;
acquire({ input, signal }: AbstractTransportMethodParams<'acquire'>): Promise<{
success: false;
error: "wrong previous session";
} | {
success: false;
error: "Unable to open device";
} | {
success: false;
error: "device not found";
} | {
success: false;
error: "unexpected error";
} | {
success: false;
error: "Wrong result type.";
} | {
success: false;
error: "Network request failed";
} | import("../types").Success<Session> | {
success: false;
error: NonNullable<"wrong previous session" | "device disconnected during action" | "Aborted by signal" | "Aborted by timeout">;

@@ -85,11 +51,5 @@ message: string | undefined;

message: string;
}>;
} | import("../types").ErrorGeneric<"Unable to open device" | "device not found" | "wrong previous session" | BridgeCommonErrors>>;
release({ path: _, session, onClose, signal, }: AbstractTransportMethodParams<'release'>): Promise<{
success: false;
error: "session not found";
} | {
success: false;
error: "unexpected error";
} | {
success: false;
error: NonNullable<"Aborted by signal" | "Aborted by timeout">;

@@ -101,35 +61,8 @@ message: string | undefined;

message: string;
} | {
success: false;
error: "Wrong result type.";
} | {
success: false;
error: "Network request failed";
} | import("../types").Success<null>>;
} | import("../types").Success<null> | import("../types").ErrorGeneric<"session not found" | BridgeCommonErrors>>;
releaseDevice(): Promise<import("../types").Success<undefined>>;
private getProtocol;
private getRequestBody;
call({ session, name, data, protocol: customProtocol, signal, }: AbstractTransportMethodParams<'call'>): Promise<{
call({ session, name, data, protocol: customProtocol, signal, }: AbstractTransportMethodParams<'call'>): Promise<import("../types").ErrorGeneric<"Unable to open device" | "A transfer error has occurred." | "device not found" | "device disconnected during action" | "unexpected error" | "Aborted by signal" | "Aborted by timeout"> | {
success: false;
error: "Unable to open device";
} | {
success: false;
error: "A transfer error has occurred.";
} | {
success: false;
error: "device not found";
} | {
success: false;
error: "device disconnected during action";
} | {
success: false;
error: "unexpected error";
} | {
success: false;
error: "Aborted by signal";
} | {
success: false;
error: "Aborted by timeout";
} | {
success: false;
error: NonNullable<"Aborted by signal" | "Aborted by timeout">;

@@ -141,15 +74,3 @@ message: string | undefined;

message: string;
} | {
success: false;
error: "Wrong result type.";
} | {
success: false;
error: "Network request failed";
} | {
success: false;
error: "other call in progress";
} | {
success: false;
error: "Malformed protocol format";
} | import("../types").Success<{
} | import("../types").ErrorGeneric<"device disconnected during action" | "other call in progress" | "Malformed protocol format" | BridgeCommonErrors> | import("../types").Success<{
message: {

@@ -162,8 +83,2 @@ [key: string]: any;

success: false;
error: "device disconnected during action";
} | {
success: false;
error: "unexpected error";
} | {
success: false;
error: NonNullable<"Aborted by signal" | "Aborted by timeout">;

@@ -175,38 +90,5 @@ message: string | undefined;

message: string;
} | {
} | import("../types").ErrorGeneric<"device disconnected during action" | "other call in progress" | "Malformed protocol format" | BridgeCommonErrors>>;
receive({ session, protocol: customProtocol, signal, }: AbstractTransportMethodParams<'receive'>): Promise<import("../types").ErrorGeneric<"Unable to open device" | "A transfer error has occurred." | "device not found" | "device disconnected during action" | "unexpected error" | "Aborted by signal" | "Aborted by timeout"> | {
success: false;
error: "Wrong result type.";
} | {
success: false;
error: "Network request failed";
} | {
success: false;
error: "other call in progress";
} | {
success: false;
error: "Malformed protocol format";
}>;
receive({ session, protocol: customProtocol, signal, }: AbstractTransportMethodParams<'receive'>): Promise<{
success: false;
error: "Unable to open device";
} | {
success: false;
error: "A transfer error has occurred.";
} | {
success: false;
error: "device not found";
} | {
success: false;
error: "device disconnected during action";
} | {
success: false;
error: "unexpected error";
} | {
success: false;
error: "Aborted by signal";
} | {
success: false;
error: "Aborted by timeout";
} | {
success: false;
error: NonNullable<"Aborted by signal" | "Aborted by timeout">;

@@ -218,15 +100,3 @@ message: string | undefined;

message: string;
} | {
success: false;
error: "Wrong result type.";
} | {
success: false;
error: "Network request failed";
} | {
success: false;
error: "other call in progress";
} | {
success: false;
error: "Malformed protocol format";
} | import("../types").Success<{
} | import("../types").ErrorGeneric<"device disconnected during action" | "other call in progress" | "Malformed protocol format" | BridgeCommonErrors> | import("../types").Success<{
message: {

@@ -233,0 +103,0 @@ [key: string]: any;

@@ -171,3 +171,3 @@ "use strict";

if (response.error === ERRORS.UNEXPECTED_ERROR) {
return response;
return this.unknownError(response.error);
}

@@ -187,4 +187,5 @@ if (response.error === ERRORS.HTTP_ERROR) {

]);
case '/call':
case '/read':
case '/call':
case '/post':
return this.unknownError(response.error, [

@@ -194,2 +195,3 @@ ERRORS.SESSION_NOT_FOUND,

ERRORS.OTHER_CALL_IN_PROGRESS,
ERRORS.INTERFACE_DATA_TRANSFER,
protocol_1.PROTOCOL_MALFORMED,

@@ -200,9 +202,2 @@ ]);

return this.unknownError(response.error);
case '/post':
return this.unknownError(response.error, [
ERRORS.SESSION_NOT_FOUND,
ERRORS.DEVICE_DISCONNECTED_DURING_ACTION,
ERRORS.OTHER_CALL_IN_PROGRESS,
protocol_1.PROTOCOL_MALFORMED,
]);
case '/release':

@@ -209,0 +204,0 @@ return this.unknownError(response.error, [

@@ -8,8 +8,5 @@ import type { PROTOCOL_MALFORMED, TransportProtocol } from '@trezor/protocol';

}
export type ErrorGeneric<ErrorType> = ErrorType extends AnyError ? {
export type ErrorGeneric<ErrorType> = {
success: false;
error: ErrorType;
} : {
success: false;
error: ErrorType;
message?: string;

@@ -16,0 +13,0 @@ };

@@ -11,9 +11,5 @@ export type HttpRequestOptions = {

success: false;
error: "Malformed protocol format";
error: string;
message: string | undefined;
} | {
success: false;
error: NonNullable<"Unable to open device" | "Unable to close device" | "A transfer error has occurred." | "device not found" | "Device unreadable" | "wrong previous session" | "session not found" | "descriptor not found" | "sessions background did not respond" | "already listening" | "interface not available" | "Wrong result type." | "This transport can not be used in this environment" | "device disconnected during action" | "other call in progress" | "Network request failed" | "unexpected error" | "Aborted by signal" | "Aborted by timeout">;
message: string | undefined;
} | import("../types").Success<string | Record<string, unknown>>>;
//# sourceMappingURL=bridgeApiCall.d.ts.map

@@ -79,2 +79,12 @@ "use strict";

}
if (typeof resParsed !== 'string' &&
'error' in resParsed &&
typeof resParsed.error === 'string') {
return (0, result_1.error)({
error: resParsed.error,
message: 'message' in resParsed && typeof resParsed.message === 'string'
? resParsed.message
: undefined,
});
}
return (0, result_1.unknownError)(new Error(errStr), Object.values(ERRORS));

@@ -81,0 +91,0 @@ }

import { Root } from 'protobufjs/light';
import { TransportProtocol } from '@trezor/protocol';
import { AbstractApi } from '../api/abstract';
export declare function receive<T extends () => ReturnType<AbstractApi['read']>>(receiver: T, protocol: TransportProtocol): Promise<{
success: false;
error: "Unable to open device";
} | {
success: false;
error: "A transfer error has occurred.";
} | {
success: false;
error: "device not found";
} | {
success: false;
error: "device disconnected during action";
} | {
success: false;
error: "unexpected error";
} | {
success: false;
error: "Aborted by signal";
} | {
success: false;
error: "Aborted by timeout";
} | import("../types").Success<{
export declare function receive<T extends () => ReturnType<AbstractApi['read']>>(receiver: T, protocol: TransportProtocol): Promise<import("../types").ErrorGeneric<"Unable to open device" | "A transfer error has occurred." | "device not found" | "device disconnected during action" | "unexpected error" | "Aborted by signal" | "Aborted by timeout"> | import("../types").Success<{
messageType: string | number;
payload: Buffer;
}>>;
export declare function receiveAndParse<T extends () => ReturnType<AbstractApi['read']>>(messages: Root, receiver: T, protocol: TransportProtocol): Promise<{
success: false;
error: "Unable to open device";
} | {
success: false;
error: "A transfer error has occurred.";
} | {
success: false;
error: "device not found";
} | {
success: false;
error: "device disconnected during action";
} | {
success: false;
error: "unexpected error";
} | {
success: false;
error: "Aborted by signal";
} | {
success: false;
error: "Aborted by timeout";
} | import("../types").Success<{
export declare function receiveAndParse<T extends () => ReturnType<AbstractApi['read']>>(messages: Root, receiver: T, protocol: TransportProtocol): Promise<import("../types").ErrorGeneric<"Unable to open device" | "A transfer error has occurred." | "device not found" | "device disconnected during action" | "unexpected error" | "Aborted by signal" | "Aborted by timeout"> | import("../types").Success<{
message: {

@@ -52,0 +10,0 @@ [key: string]: any;

{
"name": "@trezor/transport",
"version": "1.3.4",
"version": "1.3.5-beta.1",
"description": "Low level library facilitating protocol buffers based communication with Trezor devices",

@@ -66,5 +66,5 @@ "npmPublishAccess": "public",

"dependencies": {
"@trezor/protobuf": "1.2.4",
"@trezor/protobuf": "1.2.5-beta.1",
"@trezor/protocol": "1.2.2",
"@trezor/utils": "9.2.3",
"@trezor/utils": "9.2.4-beta.1",
"cross-fetch": "^4.0.0",

@@ -71,0 +71,0 @@ "long": "^4.0.0",

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