Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@secux/transport-webble

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@secux/transport-webble - npm Package Compare versions

Comparing version 3.3.0 to 3.3.1

2

lib/interface.d.ts

@@ -27,2 +27,4 @@ /*!

PACKET: number;
PREFIX?: string;
MANUFACTURE?: any;
};

@@ -29,0 +31,0 @@ export declare const Devices: {

2

lib/interface.js

@@ -18,2 +18,2 @@ "use strict";

limitations under the License.
*/Object.defineProperty(exports,"__esModule",{value:!0}),exports.Devices=void 0;const transport_1=require("@secux/transport"),interface_1=require("@secux/transport/lib/interface");exports.Devices={},exports.Devices[interface_1.DeviceType.crypto]={TYPE:interface_1.DeviceType.crypto,SERVICE:"6e400001-b5a3-f393-e0a9-e50e24dcca9e",PRIMARY:"6e400001-b5a3-f393-e0a9-e50e24dcca9e",RX:"6e400002-b5a3-f393-e0a9-e50e24dcca9e",TX:"6e400003-b5a3-f393-e0a9-e50e24dcca9e",PROTOCOL:transport_1.ITransport.PROTOCOLv1,PACKET:64},exports.Devices[interface_1.DeviceType.nifty]={TYPE:interface_1.DeviceType.nifty,SERVICE:"0000180a-0000-1000-8000-00805f9b34fb",PRIMARY:"7a200001-a171-69b8-8245-c41dd47bd699",RX:"7a200002-a171-69b8-8245-c41dd47bd699",TX:"7a200003-a171-69b8-8245-c41dd47bd699",PROTOCOL:transport_1.ITransport.PROTOCOLv2,PACKET:112},Object.freeze(exports.Devices);
*/Object.defineProperty(exports,"__esModule",{value:!0}),exports.Devices=void 0;const transport_1=require("@secux/transport"),interface_1=require("@secux/transport/lib/interface");exports.Devices={},exports.Devices[interface_1.DeviceType.crypto]={TYPE:interface_1.DeviceType.crypto,SERVICE:"6e400001-b5a3-f393-e0a9-e50e24dcca9e",PRIMARY:"6e400001-b5a3-f393-e0a9-e50e24dcca9e",RX:"6e400002-b5a3-f393-e0a9-e50e24dcca9e",TX:"6e400003-b5a3-f393-e0a9-e50e24dcca9e",PROTOCOL:transport_1.ITransport.PROTOCOLv1,PACKET:64},exports.Devices[interface_1.DeviceType.nifty]={TYPE:interface_1.DeviceType.nifty,SERVICE:"0000180a-0000-1000-8000-00805f9b34fb",PRIMARY:"7a200001-a171-69b8-8245-c41dd47bd699",RX:"7a200002-a171-69b8-8245-c41dd47bd699",TX:"7a200003-a171-69b8-8245-c41dd47bd699",PROTOCOL:transport_1.ITransport.PROTOCOLv2,PACKET:112,MANUFACTURE:[{dataPrefix:new Uint8Array([83,101,99,117,88,0]),companyIdentifier:44974}]},exports.Devices[interface_1.DeviceType.shield]={TYPE:interface_1.DeviceType.shield,SERVICE:"6e400001-b5a3-f393-e0a9-e50e24dcca9e",PRIMARY:"6e400001-b5a3-f393-e0a9-e50e24dcca9e",RX:"6e400002-b5a3-f393-e0a9-e50e24dcca9e",TX:"6e400003-b5a3-f393-e0a9-e50e24dcca9e",PROTOCOL:transport_1.ITransport.PROTOCOLv1,PACKET:64,PREFIX:"SX-"},Object.freeze(exports.Devices);

@@ -18,2 +18,2 @@ "use strict";

limitations under the License.
*/var _SecuxWebBLE_instances,_SecuxWebBLE_device,_SecuxWebBLE_mcuVersion,_SecuxWebBLE_seVersion,_SecuxWebBLE_model,_SecuxWebBLE_deviceId,_SecuxWebBLE_customerId,_SecuxWebBLE_reader,_SecuxWebBLE_writer,_SecuxWebBLE_type,_SecuxWebBLE_connected,_SecuxWebBLE_OnConnected,_SecuxWebBLE_OnDisconnected,_SecuxWebBLE_handleNotifications,_SecuxWebBLE_checkPairing,_SecuxWebBLE_identify,_SecuxWebBLE_setDeviceInfo,__classPrivateFieldSet=this&&this.__classPrivateFieldSet||function(receiver,state,value,kind,f){if("m"===kind)throw new TypeError("Private method is not writable");if("a"===kind&&!f)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof state?receiver!==state||!f:!state.has(receiver))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===kind?f.call(receiver,value):f?f.value=value:state.set(receiver,value),value},__classPrivateFieldGet=this&&this.__classPrivateFieldGet||function(receiver,state,kind,f){if("a"===kind&&!f)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof state?receiver!==state||!f:!state.has(receiver))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===kind?f:"a"===kind?f.call(receiver):f?f.value:state.get(receiver)};Object.defineProperty(exports,"__esModule",{value:!0}),exports.SecuxWebBLE=void 0;const transport_1=require("@secux/transport"),interface_1=require("@secux/transport/lib/interface"),communication_1=require("@secux/utility/lib/communication"),protocol_device_1=require("@secux/protocol-device"),interface_2=require("./interface"),callback=()=>{};class SecuxWebBLE extends transport_1.ITransport{constructor(device,OnConnected,OnDisconnected){super(),_SecuxWebBLE_instances.add(this),_SecuxWebBLE_device.set(this,void 0),_SecuxWebBLE_mcuVersion.set(this,""),_SecuxWebBLE_seVersion.set(this,""),_SecuxWebBLE_model.set(this,""),_SecuxWebBLE_deviceId.set(this,""),_SecuxWebBLE_customerId.set(this,""),_SecuxWebBLE_reader.set(this,void 0),_SecuxWebBLE_writer.set(this,void 0),_SecuxWebBLE_type.set(this,void 0),_SecuxWebBLE_connected.set(this,!1),_SecuxWebBLE_OnConnected.set(this,void 0),_SecuxWebBLE_OnDisconnected.set(this,void 0),_SecuxWebBLE_handleNotifications.set(this,(event=>{var _a;const value=null===(_a=event.target)||void 0===_a?void 0:_a.value;value.buffer&&this.ReceiveData(Buffer.from(value.buffer))})),__classPrivateFieldSet(this,_SecuxWebBLE_device,device,"f"),__classPrivateFieldSet(this,_SecuxWebBLE_OnConnected,null!=OnConnected?OnConnected:callback,"f"),__classPrivateFieldSet(this,_SecuxWebBLE_OnDisconnected,null!=OnDisconnected?OnDisconnected:callback,"f"),__classPrivateFieldGet(this,_SecuxWebBLE_device,"f").addEventListener("gattserverdisconnected",(()=>{__classPrivateFieldGet(this,_SecuxWebBLE_reader,"f").removeEventListener("characteristicvaluechanged",__classPrivateFieldGet(this,_SecuxWebBLE_handleNotifications,"f")),__classPrivateFieldSet(this,_SecuxWebBLE_reader,void 0,"f"),__classPrivateFieldSet(this,_SecuxWebBLE_writer,void 0,"f"),__classPrivateFieldGet(this,_SecuxWebBLE_connected,"f")&&__classPrivateFieldGet(this,_SecuxWebBLE_OnDisconnected,"f").call(this)}))}static async Create(OnConnected,OnDisconnected,devices){const filters=(null!=devices?devices:[interface_1.DeviceType.crypto]).map((x=>({services:[interface_2.Devices[x].SERVICE]}))),device=await navigator.bluetooth.requestDevice({filters,optionalServices:[...Object.values(interface_2.Devices).map((x=>x.PRIMARY))]});return new SecuxWebBLE(device,null!=OnConnected?OnConnected:callback,null!=OnDisconnected?OnDisconnected:callback)}async Connect(){const server=await __classPrivateFieldGet(this,_SecuxWebBLE_device,"f").gatt.connect();if(!server)throw Error("Cannot connect to device: BluetoothDevice.gatt is undefined");const services=await server.getPrimaryServices(),{service,uuid}=__classPrivateFieldGet(this,_SecuxWebBLE_instances,"m",_SecuxWebBLE_identify).call(this,services);__classPrivateFieldSet(this,_SecuxWebBLE_reader,await service.getCharacteristic(uuid.TX),"f"),__classPrivateFieldSet(this,_SecuxWebBLE_writer,await service.getCharacteristic(uuid.RX),"f"),__classPrivateFieldSet(this,_SecuxWebBLE_type,uuid.TYPE,"f"),this.version=uuid.PROTOCOL,this.packetSize=uuid.PACKET,transport_1.ITransport.deviceType=__classPrivateFieldGet(this,_SecuxWebBLE_type,"f"),await __classPrivateFieldGet(this,_SecuxWebBLE_reader,"f").startNotifications(),__classPrivateFieldGet(this,_SecuxWebBLE_reader,"f").addEventListener("characteristicvaluechanged",__classPrivateFieldGet(this,_SecuxWebBLE_handleNotifications,"f")),__classPrivateFieldGet(this,_SecuxWebBLE_type,"f")===interface_1.DeviceType.nifty&&(await __classPrivateFieldGet(this,_SecuxWebBLE_instances,"m",_SecuxWebBLE_checkPairing).call(this),await __classPrivateFieldGet(this,_SecuxWebBLE_instances,"m",_SecuxWebBLE_setDeviceInfo).call(this)),__classPrivateFieldSet(this,_SecuxWebBLE_connected,!0,"f"),__classPrivateFieldGet(this,_SecuxWebBLE_OnConnected,"f").call(this)}async Disconnect(){__classPrivateFieldGet(this,_SecuxWebBLE_device,"f").gatt.disconnect(),__classPrivateFieldSet(this,_SecuxWebBLE_reader,void 0,"f"),__classPrivateFieldSet(this,_SecuxWebBLE_writer,void 0,"f"),__classPrivateFieldSet(this,_SecuxWebBLE_connected,!1,"f")}async Write(data){await __classPrivateFieldGet(this,_SecuxWebBLE_writer,"f").writeValueWithoutResponse(data),await new Promise((resolve=>setTimeout(resolve,1)))}async SendOTP(otp){const recv=await this.Exchange(Buffer.from(otp)),dataLength=recv.readUInt16LE(0),status=recv.readUInt16BE(2+dataLength);if(status!==communication_1.StatusCode.SUCCESS)throw new communication_1.TransportStatusError(status);return await __classPrivateFieldGet(this,_SecuxWebBLE_instances,"m",_SecuxWebBLE_setDeviceInfo).call(this),!0}get CustomerId(){return __classPrivateFieldGet(this,_SecuxWebBLE_customerId,"f")}get DeviceName(){return __classPrivateFieldGet(this,_SecuxWebBLE_device,"f").name}get DeviceType(){var _a;return null!==(_a=__classPrivateFieldGet(this,_SecuxWebBLE_type,"f"))&&void 0!==_a?_a:""}get DeviceId(){return __classPrivateFieldGet(this,_SecuxWebBLE_deviceId,"f")}get Model(){return __classPrivateFieldGet(this,_SecuxWebBLE_model,"f")}get MCU(){return __classPrivateFieldGet(this,_SecuxWebBLE_mcuVersion,"f")}get SE(){return __classPrivateFieldGet(this,_SecuxWebBLE_seVersion,"f")}}exports.SecuxWebBLE=SecuxWebBLE,_SecuxWebBLE_device=new WeakMap,_SecuxWebBLE_mcuVersion=new WeakMap,_SecuxWebBLE_seVersion=new WeakMap,_SecuxWebBLE_model=new WeakMap,_SecuxWebBLE_deviceId=new WeakMap,_SecuxWebBLE_customerId=new WeakMap,_SecuxWebBLE_reader=new WeakMap,_SecuxWebBLE_writer=new WeakMap,_SecuxWebBLE_type=new WeakMap,_SecuxWebBLE_connected=new WeakMap,_SecuxWebBLE_OnConnected=new WeakMap,_SecuxWebBLE_OnDisconnected=new WeakMap,_SecuxWebBLE_handleNotifications=new WeakMap,_SecuxWebBLE_instances=new WeakSet,_SecuxWebBLE_checkPairing=async function(){const echoTest=async()=>{const payload=Buffer.from([112,97,105,114,105,110,103]),data=Buffer.from([130+payload.length,248,8,...payload]);await this.Write(data);let rsp=await this.Read();for(;!rsp;)rsp=await this.Read(),await new Promise((resolve=>setTimeout(resolve,1)));return data[1]=0,!!data.equals(rsp.slice(0,data.length))};for(let i=0;i<24;i++){if(!__classPrivateFieldGet(this,_SecuxWebBLE_reader,"f")||!__classPrivateFieldGet(this,_SecuxWebBLE_writer,"f")){const server=await __classPrivateFieldGet(this,_SecuxWebBLE_device,"f").gatt.connect();if(!server)throw Error("Cannot connect to device: BluetoothDevice.gatt is undefined");const info=interface_2.Devices[interface_1.DeviceType.nifty],service=await server.getPrimaryService(info.PRIMARY);__classPrivateFieldSet(this,_SecuxWebBLE_reader,await service.getCharacteristic(info.TX),"f"),__classPrivateFieldSet(this,_SecuxWebBLE_writer,await service.getCharacteristic(info.RX),"f"),await __classPrivateFieldGet(this,_SecuxWebBLE_reader,"f").startNotifications(),__classPrivateFieldGet(this,_SecuxWebBLE_reader,"f").addEventListener("characteristicvaluechanged",__classPrivateFieldGet(this,_SecuxWebBLE_handleNotifications,"f"))}try{if(await Promise.race([echoTest(),new Promise((resolve=>setTimeout(resolve,5e3)))]))return}catch(e){}}throw Error("bluetooth pairing error")},_SecuxWebBLE_identify=function(services){for(const uuid of Object.values(interface_2.Devices)){const service=services.find((x=>x.uuid===uuid.PRIMARY));if(service)return{service,uuid}}throw Error("Cannot find related GATTService")},_SecuxWebBLE_setDeviceInfo=async function(){const data=protocol_device_1.SecuxDevice.prepareGetVersion(),rsp=await this.Exchange((0,communication_1.getBuffer)(data)),{mcuFwVersion,seFwVersion,model,deviceId,customerId}=protocol_device_1.SecuxDevice.resolveVersion(rsp);__classPrivateFieldSet(this,_SecuxWebBLE_mcuVersion,mcuFwVersion,"f"),__classPrivateFieldSet(this,_SecuxWebBLE_seVersion,seFwVersion,"f"),model&&__classPrivateFieldSet(this,_SecuxWebBLE_model,model,"f"),deviceId&&__classPrivateFieldSet(this,_SecuxWebBLE_deviceId,deviceId,"f"),__classPrivateFieldSet(this,_SecuxWebBLE_customerId,customerId||await this.getCustomerId(),"f"),["C20"].includes(__classPrivateFieldGet(this,_SecuxWebBLE_model,"f"))&&(__classPrivateFieldSet(this,_SecuxWebBLE_type,interface_1.DeviceType.shield,"f"),transport_1.ITransport.deviceType=interface_1.DeviceType.shield),transport_1.ITransport.mcuVersion=mcuFwVersion,transport_1.ITransport.seVersion=seFwVersion};
*/var _SecuxWebBLE_instances,_SecuxWebBLE_device,_SecuxWebBLE_mcuVersion,_SecuxWebBLE_seVersion,_SecuxWebBLE_model,_SecuxWebBLE_deviceId,_SecuxWebBLE_customerId,_SecuxWebBLE_reader,_SecuxWebBLE_writer,_SecuxWebBLE_type,_SecuxWebBLE_connected,_SecuxWebBLE_OnConnected,_SecuxWebBLE_OnDisconnected,_SecuxWebBLE_handleNotifications,_SecuxWebBLE_checkPairing,_SecuxWebBLE_identify,_SecuxWebBLE_setDeviceInfo,__classPrivateFieldSet=this&&this.__classPrivateFieldSet||function(receiver,state,value,kind,f){if("m"===kind)throw new TypeError("Private method is not writable");if("a"===kind&&!f)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof state?receiver!==state||!f:!state.has(receiver))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===kind?f.call(receiver,value):f?f.value=value:state.set(receiver,value),value},__classPrivateFieldGet=this&&this.__classPrivateFieldGet||function(receiver,state,kind,f){if("a"===kind&&!f)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof state?receiver!==state||!f:!state.has(receiver))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===kind?f:"a"===kind?f.call(receiver):f?f.value:state.get(receiver)};Object.defineProperty(exports,"__esModule",{value:!0}),exports.SecuxWebBLE=void 0;const transport_1=require("@secux/transport"),interface_1=require("@secux/transport/lib/interface"),communication_1=require("@secux/utility/lib/communication"),protocol_device_1=require("@secux/protocol-device"),interface_2=require("./interface"),callback=()=>{};class SecuxWebBLE extends transport_1.ITransport{constructor(device,OnConnected,OnDisconnected){super(),_SecuxWebBLE_instances.add(this),_SecuxWebBLE_device.set(this,void 0),_SecuxWebBLE_mcuVersion.set(this,""),_SecuxWebBLE_seVersion.set(this,""),_SecuxWebBLE_model.set(this,""),_SecuxWebBLE_deviceId.set(this,""),_SecuxWebBLE_customerId.set(this,""),_SecuxWebBLE_reader.set(this,void 0),_SecuxWebBLE_writer.set(this,void 0),_SecuxWebBLE_type.set(this,void 0),_SecuxWebBLE_connected.set(this,!1),_SecuxWebBLE_OnConnected.set(this,void 0),_SecuxWebBLE_OnDisconnected.set(this,void 0),_SecuxWebBLE_handleNotifications.set(this,(event=>{var _a;const value=null===(_a=event.target)||void 0===_a?void 0:_a.value;value.buffer&&this.ReceiveData(Buffer.from(value.buffer))})),__classPrivateFieldSet(this,_SecuxWebBLE_device,device,"f"),__classPrivateFieldSet(this,_SecuxWebBLE_OnConnected,null!=OnConnected?OnConnected:callback,"f"),__classPrivateFieldSet(this,_SecuxWebBLE_OnDisconnected,null!=OnDisconnected?OnDisconnected:callback,"f"),__classPrivateFieldGet(this,_SecuxWebBLE_device,"f").addEventListener("gattserverdisconnected",(()=>{__classPrivateFieldGet(this,_SecuxWebBLE_reader,"f").removeEventListener("characteristicvaluechanged",__classPrivateFieldGet(this,_SecuxWebBLE_handleNotifications,"f")),__classPrivateFieldSet(this,_SecuxWebBLE_reader,void 0,"f"),__classPrivateFieldSet(this,_SecuxWebBLE_writer,void 0,"f"),__classPrivateFieldGet(this,_SecuxWebBLE_connected,"f")&&__classPrivateFieldGet(this,_SecuxWebBLE_OnDisconnected,"f").call(this)}))}static async Create(OnConnected,OnDisconnected,devices){const types=null!=devices?devices:[interface_1.DeviceType.crypto,interface_1.DeviceType.shield],filters=types.map((x=>({services:[interface_2.Devices[x].SERVICE],namePrefix:interface_2.Devices[x].PREFIX,manufacturerData:interface_2.Devices[x].MANUFACTURE}))),excludedDevices=Object.values(interface_2.Devices).filter((x=>!types.includes(x.TYPE))),excludedFilters=[];for(const def of excludedDevices)def.PREFIX&&excludedFilters.push({namePrefix:def.PREFIX});const device=await navigator.bluetooth.requestDevice({filters,exclusionFilters:excludedFilters.length>0?excludedFilters:void 0,optionalServices:Object.values(interface_2.Devices).map((x=>x.PRIMARY))});return new SecuxWebBLE(device,null!=OnConnected?OnConnected:callback,null!=OnDisconnected?OnDisconnected:callback)}async Connect(){const server=await __classPrivateFieldGet(this,_SecuxWebBLE_device,"f").gatt.connect();if(!server)throw Error("Cannot connect to device: BluetoothDevice.gatt is undefined");const services=await server.getPrimaryServices(),{service,uuid}=__classPrivateFieldGet(this,_SecuxWebBLE_instances,"m",_SecuxWebBLE_identify).call(this,services);__classPrivateFieldSet(this,_SecuxWebBLE_reader,await service.getCharacteristic(uuid.TX),"f"),__classPrivateFieldSet(this,_SecuxWebBLE_writer,await service.getCharacteristic(uuid.RX),"f"),__classPrivateFieldSet(this,_SecuxWebBLE_type,uuid.TYPE,"f"),this.version=uuid.PROTOCOL,this.packetSize=uuid.PACKET,transport_1.ITransport.deviceType=__classPrivateFieldGet(this,_SecuxWebBLE_type,"f"),await __classPrivateFieldGet(this,_SecuxWebBLE_reader,"f").startNotifications(),__classPrivateFieldGet(this,_SecuxWebBLE_reader,"f").addEventListener("characteristicvaluechanged",__classPrivateFieldGet(this,_SecuxWebBLE_handleNotifications,"f")),__classPrivateFieldGet(this,_SecuxWebBLE_type,"f")===interface_1.DeviceType.nifty&&(await __classPrivateFieldGet(this,_SecuxWebBLE_instances,"m",_SecuxWebBLE_checkPairing).call(this),await __classPrivateFieldGet(this,_SecuxWebBLE_instances,"m",_SecuxWebBLE_setDeviceInfo).call(this)),__classPrivateFieldSet(this,_SecuxWebBLE_connected,!0,"f"),__classPrivateFieldGet(this,_SecuxWebBLE_OnConnected,"f").call(this)}async Disconnect(){__classPrivateFieldGet(this,_SecuxWebBLE_device,"f").gatt.disconnect(),__classPrivateFieldSet(this,_SecuxWebBLE_reader,void 0,"f"),__classPrivateFieldSet(this,_SecuxWebBLE_writer,void 0,"f"),__classPrivateFieldSet(this,_SecuxWebBLE_connected,!1,"f")}async Write(data){await __classPrivateFieldGet(this,_SecuxWebBLE_writer,"f").writeValueWithoutResponse(data),await new Promise((resolve=>setTimeout(resolve,1)))}async SendOTP(otp){const recv=await this.Exchange(Buffer.from(otp)),dataLength=recv.readUInt16LE(0),status=recv.readUInt16BE(2+dataLength);if(status!==communication_1.StatusCode.SUCCESS)throw new communication_1.TransportStatusError(status);return await __classPrivateFieldGet(this,_SecuxWebBLE_instances,"m",_SecuxWebBLE_setDeviceInfo).call(this),!0}get CustomerId(){return __classPrivateFieldGet(this,_SecuxWebBLE_customerId,"f")}get DeviceName(){return __classPrivateFieldGet(this,_SecuxWebBLE_device,"f").name}get DeviceType(){var _a;return null!==(_a=__classPrivateFieldGet(this,_SecuxWebBLE_type,"f"))&&void 0!==_a?_a:""}get DeviceId(){return __classPrivateFieldGet(this,_SecuxWebBLE_deviceId,"f")}get Model(){return __classPrivateFieldGet(this,_SecuxWebBLE_model,"f")}get MCU(){return __classPrivateFieldGet(this,_SecuxWebBLE_mcuVersion,"f")}get SE(){return __classPrivateFieldGet(this,_SecuxWebBLE_seVersion,"f")}}exports.SecuxWebBLE=SecuxWebBLE,_SecuxWebBLE_device=new WeakMap,_SecuxWebBLE_mcuVersion=new WeakMap,_SecuxWebBLE_seVersion=new WeakMap,_SecuxWebBLE_model=new WeakMap,_SecuxWebBLE_deviceId=new WeakMap,_SecuxWebBLE_customerId=new WeakMap,_SecuxWebBLE_reader=new WeakMap,_SecuxWebBLE_writer=new WeakMap,_SecuxWebBLE_type=new WeakMap,_SecuxWebBLE_connected=new WeakMap,_SecuxWebBLE_OnConnected=new WeakMap,_SecuxWebBLE_OnDisconnected=new WeakMap,_SecuxWebBLE_handleNotifications=new WeakMap,_SecuxWebBLE_instances=new WeakSet,_SecuxWebBLE_checkPairing=async function(){const echoTest=async()=>{const payload=Buffer.from([112,97,105,114,105,110,103]),data=Buffer.from([130+payload.length,248,8,...payload]);await this.Write(data);let rsp=await this.Read();for(;!rsp;)rsp=await this.Read(),await new Promise((resolve=>setTimeout(resolve,1)));return data[1]=0,!!data.equals(rsp.slice(0,data.length))};for(let i=0;i<24;i++){if(!__classPrivateFieldGet(this,_SecuxWebBLE_reader,"f")||!__classPrivateFieldGet(this,_SecuxWebBLE_writer,"f")){const server=await __classPrivateFieldGet(this,_SecuxWebBLE_device,"f").gatt.connect();if(!server)throw Error("Cannot connect to device: BluetoothDevice.gatt is undefined");const info=interface_2.Devices[interface_1.DeviceType.nifty],service=await server.getPrimaryService(info.PRIMARY);__classPrivateFieldSet(this,_SecuxWebBLE_reader,await service.getCharacteristic(info.TX),"f"),__classPrivateFieldSet(this,_SecuxWebBLE_writer,await service.getCharacteristic(info.RX),"f"),await __classPrivateFieldGet(this,_SecuxWebBLE_reader,"f").startNotifications(),__classPrivateFieldGet(this,_SecuxWebBLE_reader,"f").addEventListener("characteristicvaluechanged",__classPrivateFieldGet(this,_SecuxWebBLE_handleNotifications,"f"))}try{if(await Promise.race([echoTest(),new Promise((resolve=>setTimeout(resolve,5e3)))]))return}catch(e){}}throw Error("bluetooth pairing error")},_SecuxWebBLE_identify=function(services){for(const uuid of Object.values(interface_2.Devices)){const service=services.find((x=>x.uuid===uuid.PRIMARY));if(service)return{service,uuid}}throw Error("Cannot find related GATTService")},_SecuxWebBLE_setDeviceInfo=async function(){const data=protocol_device_1.SecuxDevice.prepareGetVersion(),rsp=await this.Exchange((0,communication_1.getBuffer)(data)),{mcuFwVersion,seFwVersion,model,deviceId,customerId}=protocol_device_1.SecuxDevice.resolveVersion(rsp);__classPrivateFieldSet(this,_SecuxWebBLE_mcuVersion,mcuFwVersion,"f"),__classPrivateFieldSet(this,_SecuxWebBLE_seVersion,seFwVersion,"f"),model&&__classPrivateFieldSet(this,_SecuxWebBLE_model,model,"f"),deviceId&&__classPrivateFieldSet(this,_SecuxWebBLE_deviceId,deviceId,"f"),__classPrivateFieldSet(this,_SecuxWebBLE_customerId,customerId||await this.getCustomerId(),"f"),["C20"].includes(__classPrivateFieldGet(this,_SecuxWebBLE_model,"f"))&&(__classPrivateFieldSet(this,_SecuxWebBLE_type,interface_1.DeviceType.shield,"f"),transport_1.ITransport.deviceType=interface_1.DeviceType.shield),transport_1.ITransport.mcuVersion=mcuFwVersion,transport_1.ITransport.seVersion=seFwVersion};
{
"name": "@secux/transport-webble",
"version": "3.3.0",
"version": "3.3.1",
"description": "Secux Hardware Wallet webBLE API for communication layer",

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

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