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
6
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.1.13 to 1.1.14

6

CHANGELOG.md

@@ -0,1 +1,7 @@

# 1.1.14
- chore(deps): bump protobufjs from 6.11.3 to 7.2.4 (d0cb6caae)
- fix(transport): fix occasional race condition (fb8062e18)
- feat(transport): internal_model enum (26c17386a)
# 1.1.13

@@ -2,0 +8,0 @@

7

lib/transports/abstract.d.ts

@@ -11,2 +11,7 @@ import * as protobuf from 'protobufjs/light';

};
export type ReleaseInput = {
path: string;
session: string;
onClose?: boolean;
};
type DeviceDescriptorDiff = {

@@ -54,3 +59,3 @@ didUpdate: boolean;

}): AbortableCall<string, typeof ERRORS.INTERFACE_UNABLE_TO_OPEN_DEVICE | typeof ERRORS.WRONG_RESULT_TYPE | typeof ERRORS.HTTP_ERROR | typeof ERRORS.DEVICE_DISCONNECTED_DURING_ACTION | typeof ERRORS.DEVICE_NOT_FOUND | typeof ERRORS.SESSION_WRONG_PREVIOUS | typeof ERRORS.UNEXPECTED_ERROR | typeof ERRORS.ABORTED_BY_TIMEOUT | typeof ERRORS.ABORTED_BY_SIGNAL | typeof ERRORS.WRONG_ENVIRONMENT>;
abstract release(session: string, onclose: boolean): AbortableCall<void, typeof ERRORS.SESSION_NOT_FOUND | typeof ERRORS.HTTP_ERROR | typeof ERRORS.WRONG_RESULT_TYPE | typeof ERRORS.UNEXPECTED_ERROR | typeof ERRORS.ABORTED_BY_TIMEOUT | typeof ERRORS.ABORTED_BY_SIGNAL | typeof ERRORS.WRONG_ENVIRONMENT>;
abstract release({ path, session, onClose }: ReleaseInput): AbortableCall<void, typeof ERRORS.SESSION_NOT_FOUND | typeof ERRORS.HTTP_ERROR | typeof ERRORS.WRONG_RESULT_TYPE | typeof ERRORS.DEVICE_DISCONNECTED_DURING_ACTION | typeof ERRORS.SESSION_WRONG_PREVIOUS | typeof ERRORS.DEVICE_NOT_FOUND | typeof ERRORS.INTERFACE_UNABLE_TO_OPEN_DEVICE | typeof ERRORS.UNEXPECTED_ERROR | typeof ERRORS.ABORTED_BY_TIMEOUT | typeof ERRORS.ABORTED_BY_SIGNAL | typeof ERRORS.WRONG_ENVIRONMENT>;
abstract releaseDevice(path: string): AsyncResultWithTypedError<void, string>;

@@ -57,0 +62,0 @@ abstract send({ path, session, data, name, }: {

44

lib/transports/abstract.js

@@ -132,26 +132,30 @@ "use strict";

this.logger.debug('nextDescriptors', nextDescriptors, 'diff', diff);
if (!diff.didUpdate) {
return;
}
this.descriptors = nextDescriptors;
if (diff.didUpdate) {
Object.keys(this.listenPromise).forEach(path => {
const descriptor = nextDescriptors.find(device => device.path === path);
if (!descriptor) {
return this.listenPromise[path].resolve(this.error({ error: ERRORS.DEVICE_DISCONNECTED_DURING_ACTION }));
Object.keys(this.listenPromise).forEach(path => {
const descriptor = nextDescriptors.find(device => device.path === path);
if (!descriptor) {
return this.listenPromise[path].resolve(this.error({ error: ERRORS.DEVICE_DISCONNECTED_DURING_ACTION }));
}
if (this.acquiredUnconfirmed[path]) {
const reportedNextSession = descriptor.session;
if (reportedNextSession === this.acquiredUnconfirmed[path]) {
this.listenPromise[path].resolve(this.success(this.acquiredUnconfirmed[path]));
}
if (this.acquiredUnconfirmed[descriptor.path]) {
const reportedNextSession = descriptor.session;
if (reportedNextSession === this.acquiredUnconfirmed[descriptor.path]) {
this.listenPromise[descriptor.path].resolve(this.success(this.acquiredUnconfirmed[descriptor.path]));
}
else {
this.listenPromise[descriptor.path].resolve(this.error({ error: ERRORS.SESSION_WRONG_PREVIOUS }));
}
delete this.acquiredUnconfirmed[descriptor.path];
else {
this.listenPromise[path].resolve(this.error({ error: ERRORS.SESSION_WRONG_PREVIOUS }));
}
});
if (this.releasePromise) {
this.releasePromise.resolve(undefined);
delete this.acquiredUnconfirmed[path];
}
this.emit(constants_1.TRANSPORT.UPDATE, diff);
this.releasingSession = undefined;
}
else if (this.releasingSession) {
this.listenPromise[path].resolve(this.success('null'));
}
else {
this.listenPromise[path].resolve(this.error({ error: ERRORS.SESSION_WRONG_PREVIOUS }));
}
});
this.emit(constants_1.TRANSPORT.UPDATE, diff);
this.releasingSession = undefined;
}

@@ -158,0 +162,0 @@ success(payload) {

import { Deferred } from '@trezor/utils';
import { AbstractTransport, AcquireInput } from './abstract';
import { AbstractTransport, AcquireInput, ReleaseInput } from './abstract';
import { SessionsClient } from '../sessions/client';

@@ -54,3 +54,3 @@ import type { UsbInterface } from '../interfaces/usb';

};
release(session: string): {
release({ path, session, onClose }: ReleaseInput): {
promise: Promise<import("../types").Success<undefined> | {

@@ -57,0 +57,0 @@ success: false;

@@ -94,7 +94,8 @@ "use strict";

}
this.acquirePromise = (0, utils_1.createDeferred)();
const acquireIntentResponse = yield this.sessionsClient.acquireIntent(input);
if (this.acquirePromise) {
this.acquirePromise.resolve(undefined);
}
if (!acquireIntentResponse.success) {
if (this.acquirePromise) {
this.acquirePromise.resolve(undefined);
}
return this.error({ error: acquireIntentResponse.error });

@@ -112,5 +113,2 @@ }

this.sessionsClient.acquireDone({ path });
if (this.acquirePromise) {
this.acquirePromise.resolve(undefined);
}
if (!this.listenPromise[path]) {

@@ -124,8 +122,7 @@ return this.success(acquireIntentResponse.payload.session);

}
release(session) {
release({ path, session, onClose }) {
return this.scheduleAction(() => __awaiter(this, void 0, void 0, function* () {
var _a;
if (this.listening) {
this.releasingSession = session;
this.releasePromise = (0, utils_1.createDeferred)();
this.listenPromise[path] = (0, utils_1.createDeferred)();
}

@@ -138,11 +135,17 @@ const releaseIntentResponse = yield this.sessionsClient.releaseIntent({

}
yield this.releaseDevice(releaseIntentResponse.payload.path);
const releasePromise = this.releaseDevice(releaseIntentResponse.payload.path);
if (onClose)
return this.success(undefined);
yield releasePromise;
yield this.sessionsClient.releaseDone({
path: releaseIntentResponse.payload.path,
});
if ((_a = this.releasePromise) === null || _a === void 0 ? void 0 : _a.promise) {
yield this.releasePromise.promise;
delete this.releasePromise;
if (!this.listenPromise[path]) {
return this.success(undefined);
}
return this.success(undefined);
return this.listenPromise[path].promise
.then(() => this.success(undefined))
.finally(() => {
delete this.listenPromise[path];
});
}));

@@ -149,0 +152,0 @@ }

import { Deferred } from '@trezor/utils';
import { AbstractTransport, AcquireInput } from './abstract';
import { AbstractTransport, AcquireInput, ReleaseInput } from './abstract';
import { Descriptor } from '../types';

@@ -82,5 +82,8 @@ type BridgeConstructorParameters = ConstructorParameters<typeof AbstractTransport>[0] & {

};
release(session: string, onclose?: boolean): {
promise: Promise<import("../types").Success<undefined> | {
release({ path, session, onClose }: ReleaseInput): {
promise: Promise<{
success: false;
error: "unexpected error";
} | import("../types").Success<undefined> | {
success: false;
error: NonNullable<"Aborted by signal" | "Aborted by timeout">;

@@ -92,2 +95,11 @@ message: string | undefined;

message: string;
} | {
success: false;
error: "Wrong result type.";
} | {
success: false;
error: "Network request failed";
} | {
success: false;
error: "session not found";
}>;

@@ -94,0 +106,0 @@ abort: () => void;

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

_listen() {
var _a;
return __awaiter(this, void 0, void 0, function* () {

@@ -107,3 +106,3 @@ if (this.stopped) {

}
if ((_a = this.acquirePromise) === null || _a === void 0 ? void 0 : _a.promise) {
if (this.acquirePromise) {
yield this.acquirePromise.promise;

@@ -124,2 +123,3 @@ }

}
this.acquirePromise = (0, utils_1.createDeferred)();
const response = yield this._post('/acquire', {

@@ -130,5 +130,3 @@ params: `${input.path}/${previous}`,

});
if (this.acquirePromise) {
this.acquirePromise.resolve(undefined);
}
this.acquirePromise.resolve(undefined);
if (!response.success) {

@@ -146,23 +144,24 @@ return response;

}
release(session, onclose) {
return this.scheduleAction((signal) => __awaiter(this, void 0, void 0, function* () {
var _a;
if (this.listening) {
release({ path, session, onClose }) {
return this.scheduleAction(signal => {
if (this.listening && !onClose) {
this.releasingSession = session;
this.releasePromise = (0, utils_1.createDeferred)();
this.listenPromise[path] = (0, utils_1.createDeferred)();
}
this._post('/release', {
const releasePromise = this._post('/release', {
params: session,
signal,
});
if (onclose || !this.listening) {
yield (0, utils_1.createTimeoutPromise)(1);
return this.success(undefined);
if (onClose) {
return Promise.resolve(this.success(undefined));
}
if ((_a = this.releasePromise) === null || _a === void 0 ? void 0 : _a.promise) {
yield this.releasePromise.promise;
delete this.releasePromise;
if (!this.listenPromise[path]) {
return releasePromise;
}
return this.success(undefined);
}));
return this.listenPromise[path].promise
.then(() => this.success(undefined))
.finally(() => {
delete this.listenPromise[path];
});
});
}

@@ -169,0 +168,0 @@ releaseDevice() {

/// <reference types="node" />
export type UintType = string | number;
export declare enum DeviceModelInternal {
T1B1 = "T1B1",
T2T1 = "T2T1",
T2B1 = "T2B1"
}
export type BinanceGetAddress = {

@@ -1192,3 +1197,3 @@ address_n: number[];

hide_passphrase_from_host?: boolean;
internal_model?: string;
internal_model: DeviceModelInternal;
unit_color?: number;

@@ -1195,0 +1200,0 @@ unit_btconly?: boolean;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.TezosBallotType = exports.TezosContractType = exports.StellarSignerType = exports.StellarMemoType = exports.StellarAssetType = exports.NEMImportanceTransferMode = exports.NEMModificationType = exports.NEMSupplyChangeType = exports.NEMMosaicLevy = exports.MoneroNetworkType = exports.Enum_WordRequestType = exports.RecoveryDeviceType = exports.SdProtectOperationType = exports.Enum_Capability = exports.Enum_HomescreenFormat = exports.Enum_SafetyCheckLevel = exports.Enum_BackupType = exports.EthereumDataType = exports.EthereumDefinitionType = exports.DebugPhysicalButton = exports.DebugButton = exports.Enum_PinMatrixRequestType = exports.Enum_ButtonRequestType = exports.FailureType = exports.CardanoTxWitnessType = exports.CardanoTxSigningMode = exports.CardanoCVoteRegistrationFormat = exports.CardanoTxAuxiliaryDataSupplementType = exports.CardanoPoolRelayType = exports.CardanoCertificateType = exports.CardanoTxOutputSerializationFormat = exports.CardanoNativeScriptHashDisplayFormat = exports.CardanoNativeScriptType = exports.CardanoAddressType = exports.CardanoDerivationType = exports.Enum_RequestType = exports.AmountUnit = exports.DecredStakingSpendType = exports.Enum_OutputScriptType = exports.Enum_InputScriptType = exports.BinanceTimeInForce = exports.BinanceOrderSide = exports.BinanceOrderType = void 0;
exports.TezosBallotType = exports.TezosContractType = exports.StellarSignerType = exports.StellarMemoType = exports.StellarAssetType = exports.NEMImportanceTransferMode = exports.NEMModificationType = exports.NEMSupplyChangeType = exports.NEMMosaicLevy = exports.MoneroNetworkType = exports.Enum_WordRequestType = exports.RecoveryDeviceType = exports.SdProtectOperationType = exports.Enum_Capability = exports.Enum_HomescreenFormat = exports.Enum_SafetyCheckLevel = exports.Enum_BackupType = exports.EthereumDataType = exports.EthereumDefinitionType = exports.DebugPhysicalButton = exports.DebugButton = exports.Enum_PinMatrixRequestType = exports.Enum_ButtonRequestType = exports.FailureType = exports.CardanoTxWitnessType = exports.CardanoTxSigningMode = exports.CardanoCVoteRegistrationFormat = exports.CardanoTxAuxiliaryDataSupplementType = exports.CardanoPoolRelayType = exports.CardanoCertificateType = exports.CardanoTxOutputSerializationFormat = exports.CardanoNativeScriptHashDisplayFormat = exports.CardanoNativeScriptType = exports.CardanoAddressType = exports.CardanoDerivationType = exports.Enum_RequestType = exports.AmountUnit = exports.DecredStakingSpendType = exports.Enum_OutputScriptType = exports.Enum_InputScriptType = exports.BinanceTimeInForce = exports.BinanceOrderSide = exports.BinanceOrderType = exports.DeviceModelInternal = void 0;
var DeviceModelInternal;
(function (DeviceModelInternal) {
DeviceModelInternal["T1B1"] = "T1B1";
DeviceModelInternal["T2T1"] = "T2T1";
DeviceModelInternal["T2B1"] = "T2B1";
})(DeviceModelInternal = exports.DeviceModelInternal || (exports.DeviceModelInternal = {}));
var BinanceOrderType;

@@ -5,0 +11,0 @@ (function (BinanceOrderType) {

{
"name": "@trezor/transport",
"version": "1.1.13",
"version": "1.1.14",
"description": "Low level library facilitating protocol buffers based communication with Trezor devices",

@@ -58,3 +58,3 @@ "npmPublishAccess": "public",

"dependencies": {
"@trezor/utils": "9.0.10",
"@trezor/utils": "9.0.11",
"bytebuffer": "^5.0.1",

@@ -65,5 +65,5 @@ "cross-fetch": "^3.1.6",

"prettier": "2.8.8",
"protobufjs": "6.11.3",
"protobufjs": "7.2.4",
"usb": "^2.9.0"
}
}

@@ -1,4 +0,1 @@

// flowtype only
// flowtype doesn't have `enum` declarations like typescript
const fs = require('fs');

@@ -10,6 +7,4 @@ const path = require('path');

const args = process.argv.slice(2);
const INDENT = ' '.repeat(4);
const isTypescript = args.includes('typescript');
// proto types to javascript types

@@ -43,23 +38,17 @@ const FIELD_TYPES = {

const parseEnum = (itemName, item) => {
const value = [];
const IS_KEY = ENUM_KEYS.includes(itemName);
// declare enum
if (IS_KEY) {
value.push(`export enum Enum_${itemName} {`);
} else {
value.push(`export enum ${itemName} {`);
}
const enumName = IS_KEY ? `Enum_${itemName}` : itemName;
const value = [`export enum ${enumName} {`];
// declare fields
Object.entries(item.values).forEach(([name, id]) => {
value.push(` ${name} = ${id},`);
});
value.push(...Object.entries(item.values).map(([name, id]) => `${INDENT}${name} = ${id},`));
// close enum declaration
value.push('}');
value.push('}', '');
if (IS_KEY) {
value.push(`export type ${itemName} = keyof typeof Enum_${itemName};`);
value.push(`export type ${itemName} = keyof typeof ${enumName};`, '');
}
// empty line
value.push('');

@@ -173,7 +162,13 @@ types.push({

lines.push('// This file is auto generated from data/messages/message.json');
lines.push('');
lines.push('// This file is auto generated from data/messages/message.json', '');
lines.push('// custom type uint32/64 may be represented as string');
lines.push(`export type ${UINT_TYPE} = string | number;`);
lines.push('');
lines.push(`export type ${UINT_TYPE} = string | number;`, '');
lines.push(
`export enum DeviceModelInternal {
T1B1 = 'T1B1',
T2T1 = 'T2T1',
T2B1 = 'T2B1',
}`,
'',
);
lines.push(content);

@@ -180,0 +175,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