New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.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.2.5 to 3.2.6

2

lib/interface.d.ts

@@ -19,3 +19,3 @@ /*!

import { DeviceType } from "@secux/transport/lib/interface";
declare type info = {
type info = {
TYPE: DeviceType;

@@ -22,0 +22,0 @@ SERVICE: string;

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

limitations under the License.
*/Object.defineProperty(exports,"__esModule",{value:!0}),exports.Devices=void 0;const e=require("@secux/transport"),c=require("@secux/transport/lib/interface");exports.Devices={},exports.Devices[c.DeviceType.crypto]={TYPE:c.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:e.ITransport.PROTOCOLv1,PACKET:64},exports.Devices[c.DeviceType.nifty]={TYPE:c.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:e.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},Object.freeze(exports.Devices);

@@ -55,6 +55,9 @@ /*!

SendOTP(otp: string): Promise<boolean>;
get CustomerId(): string;
get DeviceName(): string | undefined;
get DeviceType(): "" | DeviceType;
get DeviceType(): DeviceType | "";
get DeviceId(): string;
get Model(): string;
get MCU(): string;
get SE(): string;
}

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

limitations under the License.
*/var e,t,i,s,a,r,n,o,c,h,f,u,l,v,d=this&&this.__classPrivateFieldSet||function(e,t,i,s,a){if("m"===s)throw new TypeError("Private method is not writable");if("a"===s&&!a)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!a:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===s?a.call(e,i):a?a.value=i:t.set(e,i),i},w=this&&this.__classPrivateFieldGet||function(e,t,i,s){if("a"===i&&!s)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?s:"a"===i?s.call(e):s?s.value:t.get(e)};Object.defineProperty(exports,"__esModule",{value:!0}),exports.SecuxWebBLE=void 0;const p=require("@secux/transport"),m=require("@secux/transport/lib/interface"),g=require("@secux/utility/lib/communication"),y=require("@secux/protocol-device"),T=require("./interface"),E=()=>{};class P extends p.ITransport{constructor(u,l,v){super(),e.add(this),t.set(this,void 0),i.set(this,""),s.set(this,""),a.set(this,void 0),r.set(this,void 0),n.set(this,void 0),o.set(this,!1),c.set(this,void 0),h.set(this,void 0),f.set(this,(e=>{var t;const i=null===(t=e.target)||void 0===t?void 0:t.value;i.buffer&&this.ReceiveData(Buffer.from(i.buffer))})),d(this,t,u,"f"),d(this,c,null!=l?l:E,"f"),d(this,h,null!=v?v:E,"f"),w(this,t,"f").addEventListener("gattserverdisconnected",(()=>{w(this,a,"f").removeEventListener("characteristicvaluechanged",w(this,f,"f")),d(this,a,void 0,"f"),d(this,r,void 0,"f"),w(this,o,"f")&&w(this,h,"f").call(this)}))}static async Create(e,t,i){const s=(null!=i?i:[m.DeviceType.crypto]).map((e=>({services:[T.Devices[e].SERVICE]}))),a=await navigator.bluetooth.requestDevice({filters:s,optionalServices:[...Object.values(T.Devices).map((e=>e.PRIMARY))]});return new P(a,null!=e?e:E,null!=t?t:E)}async Connect(){const i=await w(this,t,"f").gatt.connect();if(!i)throw"Cannot connect to device: BluetoothDevice.gatt is undefined";const s=await i.getPrimaryServices(),{service:h,uuid:g}=w(this,e,"m",l).call(this,s);d(this,a,await h.getCharacteristic(g.TX),"f"),d(this,r,await h.getCharacteristic(g.RX),"f"),d(this,n,g.TYPE,"f"),this.version=g.PROTOCOL,this.packetSize=g.PACKET,await w(this,a,"f").startNotifications(),w(this,a,"f").addEventListener("characteristicvaluechanged",w(this,f,"f")),w(this,n,"f")===m.DeviceType.nifty&&(await w(this,e,"m",u).call(this),await w(this,e,"m",v).call(this)),p.ITransport.deviceType=w(this,n,"f"),d(this,o,!0,"f"),w(this,c,"f").call(this)}async Disconnect(){w(this,t,"f").gatt.disconnect(),d(this,a,void 0,"f"),d(this,r,void 0,"f"),d(this,o,!1,"f")}async Write(e){await w(this,r,"f").writeValueWithoutResponse(e),await new Promise((e=>setTimeout(e,1)))}async SendOTP(t){const i=await this.Exchange(Buffer.from(t)),s=i.readUInt16LE(0),a=i.readUInt16BE(2+s);if(a!==g.StatusCode.SUCCESS)throw new g.TransportStatusError(a);return await w(this,e,"m",v).call(this),!0}get DeviceName(){return w(this,t,"f").name}get DeviceType(){var e;return null!==(e=w(this,n,"f"))&&void 0!==e?e:""}get MCU(){return w(this,i,"f")}get SE(){return w(this,s,"f")}}exports.SecuxWebBLE=P,t=new WeakMap,i=new WeakMap,s=new WeakMap,a=new WeakMap,r=new WeakMap,n=new WeakMap,o=new WeakMap,c=new WeakMap,h=new WeakMap,f=new WeakMap,e=new WeakSet,u=async function(){const e=async()=>{const e=Buffer.from([112,97,105,114,105,110,103]),t=Buffer.from([130+e.length,248,8,...e]);await this.Write(t);let i=await this.Read();for(;!i;)i=await this.Read(),await new Promise((e=>setTimeout(e,1)));return t[1]=0,!!t.equals(i.slice(0,t.length))};for(let i=0;i<24;i++){if(!w(this,a,"f")||!w(this,r,"f")){const e=await w(this,t,"f").gatt.connect();if(!e)throw"Cannot connect to device: BluetoothDevice.gatt is undefined";const i=T.Devices[m.DeviceType.nifty],s=await e.getPrimaryService(i.PRIMARY);d(this,a,await s.getCharacteristic(i.TX),"f"),d(this,r,await s.getCharacteristic(i.RX),"f"),await w(this,a,"f").startNotifications(),w(this,a,"f").addEventListener("characteristicvaluechanged",w(this,f,"f"))}try{if(await Promise.race([e(),new Promise((e=>setTimeout(e,5e3)))]))return}catch(e){}}throw Error("bluetooth pairing error")},l=function(e){for(const t of Object.values(T.Devices)){const i=e.find((e=>e.uuid===t.PRIMARY));if(i)return{service:i,uuid:t}}throw Error("Cannot find related GATTService")},v=async function(){const e=y.SecuxDevice.prepareGetVersion(),t=await this.Exchange((0,g.getBuffer)(e)),{mcuFwVersion:a,seFwVersion:r}=y.SecuxDevice.resolveVersion(t);d(this,i,a,"f"),d(this,s,r,"f"),p.ITransport.mcuVersion=a,p.ITransport.seVersion=r};
*/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"),transport_1.ITransport.mcuVersion=mcuFwVersion,transport_1.ITransport.seVersion=seFwVersion};
{
"name": "@secux/transport-webble",
"version": "3.2.5",
"version": "3.2.6",
"description": "Secux Hardware Wallet webBLE API for communication layer",

@@ -10,3 +10,3 @@ "keywords": [

],
"homepage": "https://github.com/secuxtech/secux-js/tree/master/packages/transport-webble",
"homepage": "https://github.com/SecuX/secux-js/tree/master/packages/transport-webble",
"author": "SecuX Technology Inc.",

@@ -33,3 +33,3 @@ "license": "Apache-2.0",

"dependencies": {
"@secux/protocol-device": "^3.0.3",
"@secux/protocol-device": "^3.6.0",
"@secux/transport": "^3.3.6"

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