@ledgerhq/device-transport-kit-react-native-hid 0.0.0-rn-hid-issues-20251022142715 → 0.0.0-rn-hid-issues-20251023081020

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -17,6 +17,8 @@ import com.ledger.devicesdk.shared.androidMain.transport.usb.controller.ACTION_U
17
17
  import com.ledger.devicesdk.shared.androidMain.transport.usb.controller.UsbAttachedReceiverController
18
18
  import com.ledger.devicesdk.shared.androidMain.transport.usb.controller.UsbDetachedReceiverController
19
19
  import com.ledger.devicesdk.shared.androidMain.transport.usb.controller.UsbPermissionReceiver
20
+ import com.ledger.devicesdk.shared.api.apdu.SendApduFailureReason
21
+ import com.ledger.devicesdk.shared.api.apdu.SendApduResult
20
22
  import com.ledger.devicesdk.shared.api.discovery.DiscoveryDevice
21
23
  import com.ledger.devicesdk.shared.internal.connection.InternalConnectedDevice
22
24
  import com.ledger.devicesdk.shared.internal.connection.InternalConnectionResult
@@ -244,7 +246,9 @@ class TransportHidModule(
244
246
  try {
245
247
  val device = connectedDevices.firstOrNull() { it.id == sessionId }
246
248
  if (device == null) {
247
- promise.reject(Exception("[TransportHidModule][sendApdu] Device not found"))
249
+ promise.resolve(
250
+ SendApduResult.Failure(SendApduFailureReason.DeviceNotFound).toWritableMap()
251
+ )
248
252
  return
249
253
  }
250
254
  coroutineScope.launch {
@@ -1,2 +1,2 @@
1
- "use strict";var c=Object.defineProperty;var v=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var D=Object.prototype.hasOwnProperty;var m=(e,t)=>{for(var r in t)c(e,r,{get:t[r],enumerable:!0})},f=(e,t,r,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of l(t))!D.call(e,i)&&i!==r&&c(e,i,{get:()=>t[i],enumerable:!(s=v(t,i))||s.enumerable});return e};var y=e=>f(c({},"__esModule",{value:!0}),e);var b={};m(b,{mapNativeConnectionResultToConnectionResult:()=>R,mapNativeDeviceConnectionLostToDeviceDisconnected:()=>L,mapNativeDiscoveryDeviceToTransportDiscoveredDevice:()=>N,mapNativeLedgerDeviceToDeviceModel:()=>a,mapNativeSendApduResultToSendApduResult:()=>T,mapNativeTransportLogToLog:()=>g});module.exports=y(b);var n=require("@ledgerhq/device-management-kit"),o=require("purify-ts"),d=require("../helpers/base64Utils"),p=require("../transport/Errors"),u=require("../transport/rnHidTransportIdentifier");function a(e,t){return t.filterDeviceModels({usbProductId:Number.parseInt(e.usbProductIdMask,16)})[0]??null}function N(e,t){const r=a(e.ledgerDevice,t);return r==null?null:{id:e.uid,deviceModel:r,transport:u.TRANSPORT_IDENTIFIER,name:e.name}}function g(e){let t;switch(e.level){case"error":t=n.LogLevel.Error;break;case"warning":t=n.LogLevel.Warning;break;case"info":t=n.LogLevel.Info;break;case"debug":t=n.LogLevel.Debug;break;default:I(e.level),t=n.LogLevel.Info;break}return[t,e.message,{tag:e.tag,data:e.jsonPayload,timestamp:Number.parseInt(e.timestamp,10)}]}function I(e){throw new Error("Unexpected object: "+e)}function R(e,t){if(e.success){const r=a(e.ledgerDevice,t);return r?(0,o.Right)({sessionId:e.sessionId,transportDeviceModel:r}):(0,o.Left)(new n.OpeningConnectionError(`Could not find device model for the connected device with usbProductIdMask: ${e.ledgerDevice.usbProductIdMask}`))}else return(0,o.Left)(new n.OpeningConnectionError(e.error))}function T(e){if(e.success){const t=(0,d.base64ToUint8Array)(e.apdu),r=n.FramerUtils.getFirstBytesFrom(t,t.length-2),s=n.FramerUtils.getLastBytesFrom(t,2);return(0,o.Right)(new n.ApduResponse({data:r,statusCode:s}))}else return e.error==="SendApduTimeout"?(0,o.Left)(new n.SendApduTimeoutError("Abort timeout")):e.error==="EmptyResponse"?(0,o.Left)(new n.SendApduEmptyResponseError("Empty response")):e.error==="DeviceDisconnected"?(0,o.Left)(new n.DeviceDisconnectedWhileSendingError("Device disconnected")):(0,o.Left)(new p.HidTransportSendApduUnknownError(e.error))}function L(e){return{sessionId:e.id}}0&&(module.exports={mapNativeConnectionResultToConnectionResult,mapNativeDeviceConnectionLostToDeviceDisconnected,mapNativeDiscoveryDeviceToTransportDiscoveredDevice,mapNativeLedgerDeviceToDeviceModel,mapNativeSendApduResultToSendApduResult,mapNativeTransportLogToLog});
1
+ "use strict";var s=Object.defineProperty;var v=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var D=Object.prototype.hasOwnProperty;var m=(e,t)=>{for(var o in t)s(e,o,{get:t[o],enumerable:!0})},f=(e,t,o,c)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of l(t))!D.call(e,i)&&i!==o&&s(e,i,{get:()=>t[i],enumerable:!(c=v(t,i))||c.enumerable});return e};var N=e=>f(s({},"__esModule",{value:!0}),e);var b={};m(b,{mapNativeConnectionResultToConnectionResult:()=>R,mapNativeDeviceConnectionLostToDeviceDisconnected:()=>L,mapNativeDiscoveryDeviceToTransportDiscoveredDevice:()=>y,mapNativeLedgerDeviceToDeviceModel:()=>a,mapNativeSendApduResultToSendApduResult:()=>T,mapNativeTransportLogToLog:()=>g});module.exports=N(b);var n=require("@ledgerhq/device-management-kit"),r=require("purify-ts"),d=require("../helpers/base64Utils"),u=require("../transport/Errors"),p=require("../transport/rnHidTransportIdentifier");function a(e,t){return t.filterDeviceModels({usbProductId:Number.parseInt(e.usbProductIdMask,16)})[0]??null}function y(e,t){const o=a(e.ledgerDevice,t);return o==null?null:{id:e.uid,deviceModel:o,transport:p.TRANSPORT_IDENTIFIER,name:e.name}}function g(e){let t;switch(e.level){case"error":t=n.LogLevel.Error;break;case"warning":t=n.LogLevel.Warning;break;case"info":t=n.LogLevel.Info;break;case"debug":t=n.LogLevel.Debug;break;default:I(e.level),t=n.LogLevel.Info;break}return[t,e.message,{tag:e.tag,data:e.jsonPayload,timestamp:Number.parseInt(e.timestamp,10)}]}function I(e){throw new Error("Unexpected object: "+e)}function R(e,t){if(e.success){const o=a(e.ledgerDevice,t);return o?(0,r.Right)({sessionId:e.sessionId,transportDeviceModel:o}):(0,r.Left)(new n.OpeningConnectionError(`Could not find device model for the connected device with usbProductIdMask: ${e.ledgerDevice.usbProductIdMask}`))}else return(0,r.Left)(new n.OpeningConnectionError(e.error))}function T(e){if(e.success){const t=(0,d.base64ToUint8Array)(e.apdu),o=n.FramerUtils.getFirstBytesFrom(t,t.length-2),c=n.FramerUtils.getLastBytesFrom(t,2);return(0,r.Right)(new n.ApduResponse({data:o,statusCode:c}))}else switch(e.error){case"SendApduTimeout":return(0,r.Left)(new n.SendApduTimeoutError("Abort timeout"));case"EmptyResponse":return(0,r.Left)(new n.SendApduEmptyResponseError("Empty response"));case"DeviceDisconnected":return(0,r.Left)(new n.DeviceDisconnectedWhileSendingError("Device disconnected"));case"DeviceNotFound":case"NoUsbEndpointFound":return(0,r.Left)(new n.DeviceDisconnectedBeforeSendingApdu);default:return(0,r.Left)(new u.HidTransportSendApduUnknownError(e.error))}}function L(e){return{sessionId:e.id}}0&&(module.exports={mapNativeConnectionResultToConnectionResult,mapNativeDeviceConnectionLostToDeviceDisconnected,mapNativeDiscoveryDeviceToTransportDiscoveredDevice,mapNativeLedgerDeviceToDeviceModel,mapNativeSendApduResultToSendApduResult,mapNativeTransportLogToLog});
2
2
  //# sourceMappingURL=mapper.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/api/bridge/mapper.ts"],
4
- "sourcesContent": ["import {\n ApduResponse,\n DeviceDisconnectedWhileSendingError,\n type DeviceModelDataSource,\n FramerUtils,\n LogLevel,\n type LogParams,\n OpeningConnectionError,\n SendApduEmptyResponseError,\n type SendApduResult,\n SendApduTimeoutError,\n type TransportDeviceModel,\n type TransportDiscoveredDevice,\n} from \"@ledgerhq/device-management-kit\";\nimport { Left, Right } from \"purify-ts\";\n\nimport { base64ToUint8Array } from \"@api/helpers/base64Utils\";\nimport { HidTransportSendApduUnknownError } from \"@api/transport/Errors\";\nimport { TRANSPORT_IDENTIFIER } from \"@api/transport/rnHidTransportIdentifier\";\nimport {\n type InternalConnectionResult,\n type InternalDeviceDisconnected,\n} from \"@api/transport/types\";\n\nimport {\n type NativeDeviceConnectionLost,\n type NativeDiscoveryDevice,\n type NativeInternalConnectionResult,\n type NativeLedgerDevice,\n type NativeLog,\n type NativeSendApduResult,\n} from \"./types\";\n\nexport function mapNativeLedgerDeviceToDeviceModel(\n nativeLedgerDevice: NativeLedgerDevice,\n deviceModelDataSource: DeviceModelDataSource,\n): TransportDeviceModel | null {\n return (\n deviceModelDataSource.filterDeviceModels({\n usbProductId: Number.parseInt(nativeLedgerDevice.usbProductIdMask, 16),\n })[0] ?? null\n );\n}\n\nexport function mapNativeDiscoveryDeviceToTransportDiscoveredDevice(\n nativeDevice: NativeDiscoveryDevice,\n deviceModelDataSource: DeviceModelDataSource,\n): TransportDiscoveredDevice | null {\n const deviceModel = mapNativeLedgerDeviceToDeviceModel(\n nativeDevice.ledgerDevice,\n deviceModelDataSource,\n );\n if (deviceModel == null) return null;\n\n return {\n id: nativeDevice.uid,\n deviceModel,\n transport: TRANSPORT_IDENTIFIER,\n name: nativeDevice.name,\n };\n}\n\nexport function mapNativeTransportLogToLog(log: NativeLog): LogParams {\n let level: LogLevel;\n switch (log.level) {\n case \"error\":\n level = LogLevel.Error;\n break;\n case \"warning\":\n level = LogLevel.Warning;\n break;\n case \"info\":\n level = LogLevel.Info;\n break;\n case \"debug\":\n level = LogLevel.Debug;\n break;\n default:\n assertNever(log.level);\n level = LogLevel.Info;\n break;\n }\n\n return [\n level,\n log.message,\n {\n tag: log.tag,\n data: log.jsonPayload,\n timestamp: Number.parseInt(log.timestamp, 10),\n },\n ];\n}\n\nfunction assertNever(x: never) {\n throw new Error(\"Unexpected object: \" + x);\n}\n\nexport function mapNativeConnectionResultToConnectionResult(\n result: NativeInternalConnectionResult,\n deviceModelDataSource: DeviceModelDataSource,\n): InternalConnectionResult {\n if (result.success) {\n const transportDeviceModel = mapNativeLedgerDeviceToDeviceModel(\n result.ledgerDevice,\n deviceModelDataSource,\n );\n if (!transportDeviceModel)\n return Left(\n new OpeningConnectionError(\n `Could not find device model for the connected device with usbProductIdMask: ${result.ledgerDevice.usbProductIdMask}`,\n ),\n );\n return Right({ sessionId: result.sessionId, transportDeviceModel });\n } else {\n return Left(new OpeningConnectionError(result.error));\n }\n}\n\nexport function mapNativeSendApduResultToSendApduResult(\n result: NativeSendApduResult,\n): SendApduResult {\n if (result.success) {\n const responseBytes = base64ToUint8Array(result.apdu);\n const data = FramerUtils.getFirstBytesFrom(\n responseBytes,\n responseBytes.length - 2,\n );\n const statusCode = FramerUtils.getLastBytesFrom(responseBytes, 2);\n return Right(new ApduResponse({ data, statusCode }));\n } else if (result.error === \"SendApduTimeout\") {\n return Left(new SendApduTimeoutError(\"Abort timeout\"));\n } else if (result.error === \"EmptyResponse\") {\n return Left(new SendApduEmptyResponseError(\"Empty response\"));\n } else if (result.error === \"DeviceDisconnected\") {\n return Left(new DeviceDisconnectedWhileSendingError(\"Device disconnected\"));\n } else {\n return Left(new HidTransportSendApduUnknownError(result.error));\n }\n}\n\nexport function mapNativeDeviceConnectionLostToDeviceDisconnected(\n nativeDeviceConnectionLost: NativeDeviceConnectionLost,\n): InternalDeviceDisconnected {\n return {\n sessionId: nativeDeviceConnectionLost.id,\n };\n}\n"],
5
- "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,iDAAAE,EAAA,sDAAAC,EAAA,wDAAAC,EAAA,uCAAAC,EAAA,4CAAAC,EAAA,+BAAAC,IAAA,eAAAC,EAAAR,GAAA,IAAAS,EAaO,2CACPC,EAA4B,qBAE5BC,EAAmC,oCACnCC,EAAiD,iCACjDC,EAAqC,mDAe9B,SAASR,EACdS,EACAC,EAC6B,CAC7B,OACEA,EAAsB,mBAAmB,CACvC,aAAc,OAAO,SAASD,EAAmB,iBAAkB,EAAE,CACvE,CAAC,EAAE,CAAC,GAAK,IAEb,CAEO,SAASV,EACdY,EACAD,EACkC,CAClC,MAAME,EAAcZ,EAClBW,EA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,EAC5CA,EAAO,QAAU,mBACnB,QAAK,IAAI,6BAA2B,gBAAgB,CAAC,EACnDA,EAAO,QAAU,wBACnB,QAAK,IAAI,sCAAoC,qBAAqB,CAAC,KAEnE,QAAK,IAAI,mCAAiCA,EAAO,KAAK,CAAC,CAElE,CAEO,SAASnB,EACdwB,EAC4B,CAC5B,MAAO,CACL,UAAWA,EAA2B,EACxC,CACF",
4
+ "sourcesContent": ["import {\n ApduResponse,\n DeviceDisconnectedBeforeSendingApdu,\n DeviceDisconnectedWhileSendingError,\n type DeviceModelDataSource,\n FramerUtils,\n LogLevel,\n type LogParams,\n OpeningConnectionError,\n SendApduEmptyResponseError,\n type SendApduResult,\n SendApduTimeoutError,\n type TransportDeviceModel,\n type TransportDiscoveredDevice,\n} from \"@ledgerhq/device-management-kit\";\nimport { Left, Right } from \"purify-ts\";\n\nimport { base64ToUint8Array } from \"@api/helpers/base64Utils\";\nimport { HidTransportSendApduUnknownError } from \"@api/transport/Errors\";\nimport { TRANSPORT_IDENTIFIER } from \"@api/transport/rnHidTransportIdentifier\";\nimport {\n type InternalConnectionResult,\n type InternalDeviceDisconnected,\n} from \"@api/transport/types\";\n\nimport {\n type NativeDeviceConnectionLost,\n type NativeDiscoveryDevice,\n type NativeInternalConnectionResult,\n type NativeLedgerDevice,\n type NativeLog,\n type NativeSendApduResult,\n} from \"./types\";\n\nexport function mapNativeLedgerDeviceToDeviceModel(\n nativeLedgerDevice: NativeLedgerDevice,\n deviceModelDataSource: DeviceModelDataSource,\n): TransportDeviceModel | null {\n return (\n deviceModelDataSource.filterDeviceModels({\n usbProductId: Number.parseInt(nativeLedgerDevice.usbProductIdMask, 16),\n })[0] ?? null\n );\n}\n\nexport function mapNativeDiscoveryDeviceToTransportDiscoveredDevice(\n nativeDevice: NativeDiscoveryDevice,\n deviceModelDataSource: DeviceModelDataSource,\n): TransportDiscoveredDevice | null {\n const deviceModel = mapNativeLedgerDeviceToDeviceModel(\n nativeDevice.ledgerDevice,\n deviceModelDataSource,\n );\n if (deviceModel == null) return null;\n\n return {\n id: nativeDevice.uid,\n deviceModel,\n transport: TRANSPORT_IDENTIFIER,\n name: nativeDevice.name,\n };\n}\n\nexport function mapNativeTransportLogToLog(log: NativeLog): LogParams {\n let level: LogLevel;\n switch (log.level) {\n case \"error\":\n level = LogLevel.Error;\n break;\n case \"warning\":\n level = LogLevel.Warning;\n break;\n case \"info\":\n level = LogLevel.Info;\n break;\n case \"debug\":\n level = LogLevel.Debug;\n break;\n default:\n assertNever(log.level);\n level = LogLevel.Info;\n break;\n }\n\n return [\n level,\n log.message,\n {\n tag: log.tag,\n data: log.jsonPayload,\n timestamp: Number.parseInt(log.timestamp, 10),\n },\n ];\n}\n\nfunction assertNever(x: never) {\n throw new Error(\"Unexpected object: \" + x);\n}\n\nexport function mapNativeConnectionResultToConnectionResult(\n result: NativeInternalConnectionResult,\n deviceModelDataSource: DeviceModelDataSource,\n): InternalConnectionResult {\n if (result.success) {\n const transportDeviceModel = mapNativeLedgerDeviceToDeviceModel(\n result.ledgerDevice,\n deviceModelDataSource,\n );\n if (!transportDeviceModel)\n return Left(\n new OpeningConnectionError(\n `Could not find device model for the connected device with usbProductIdMask: ${result.ledgerDevice.usbProductIdMask}`,\n ),\n );\n return Right({ sessionId: result.sessionId, transportDeviceModel });\n } else {\n return Left(new OpeningConnectionError(result.error));\n }\n}\n\nexport function mapNativeSendApduResultToSendApduResult(\n result: NativeSendApduResult,\n): SendApduResult {\n if (result.success) {\n const responseBytes = base64ToUint8Array(result.apdu);\n const data = FramerUtils.getFirstBytesFrom(\n responseBytes,\n responseBytes.length - 2,\n );\n const statusCode = FramerUtils.getLastBytesFrom(responseBytes, 2);\n return Right(new ApduResponse({ data, statusCode }));\n } else {\n switch (result.error) {\n case \"SendApduTimeout\":\n return Left(new SendApduTimeoutError(\"Abort timeout\"));\n case \"EmptyResponse\":\n return Left(new SendApduEmptyResponseError(\"Empty response\"));\n case \"DeviceDisconnected\":\n return Left(\n new DeviceDisconnectedWhileSendingError(\"Device disconnected\"),\n );\n case \"DeviceNotFound\":\n case \"NoUsbEndpointFound\":\n return Left(new DeviceDisconnectedBeforeSendingApdu());\n default:\n return Left(new HidTransportSendApduUnknownError(result.error));\n }\n }\n}\n\nexport function mapNativeDeviceConnectionLostToDeviceDisconnected(\n nativeDeviceConnectionLost: NativeDeviceConnectionLost,\n): InternalDeviceDisconnected {\n return {\n sessionId: nativeDeviceConnectionLost.id,\n };\n}\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,iDAAAE,EAAA,sDAAAC,EAAA,wDAAAC,EAAA,uCAAAC,EAAA,4CAAAC,EAAA,+BAAAC,IAAA,eAAAC,EAAAR,GAAA,IAAAS,EAcO,2CACPC,EAA4B,qBAE5BC,EAAmC,oCACnCC,EAAiD,iCACjDC,EAAqC,mDAe9B,SAASR,EACdS,EACAC,EAC6B,CAC7B,OACEA,EAAsB,mBAAmB,CACvC,aAAc,OAAO,SAASD,EAAmB,iBAAkB,EAAE,CACvE,CAAC,EAAE,CAAC,GAAK,IAEb,CAEO,SAASV,EACdY,EACAD,EACkC,CAClC,MAAME,EAAcZ,EAClBW,EAAa,aACbD,CACF,EACA,OAAIE,GAAe,KAAa,KAEzB,CACL,GAAID,EAAa,IACjB,YAAAC,EACA,UAAW,uBACX,KAAMD,EAAa,IACrB,CACF,CAEO,SAAST,EAA2BW,EAA2B,CACpE,IAAIC,EACJ,OAAQD,EAAI,MAAO,CACjB,IAAK,QACHC,EAAQ,WAAS,MACjB,MACF,IAAK,UACHA,EAAQ,WAAS,QACjB,MACF,IAAK,OACHA,EAAQ,WAAS,KACjB,MACF,IAAK,QACHA,EAAQ,WAAS,MACjB,MACF,QACEC,EAAYF,EAAI,KAAK,EACrBC,EAAQ,WAAS,KACjB,KACJ,CAEA,MAAO,CACLA,EACAD,EAAI,QACJ,CACE,IAAKA,EAAI,IACT,KAAMA,EAAI,YACV,UAAW,OAAO,SAASA,EAAI,UAAW,EAAE,CAC9C,CACF,CACF,CAEA,SAASE,EAAYC,EAAU,CAC7B,MAAM,IAAI,MAAM,sBAAwBA,CAAC,CAC3C,CAEO,SAASnB,EACdoB,EACAP,EAC0B,CAC1B,GAAIO,EAAO,QAAS,CAClB,MAAMC,EAAuBlB,EAC3BiB,EAAO,aACPP,CACF,EACA,OAAKQ,KAME,SAAM,CAAE,UAAWD,EAAO,UAAW,qBAAAC,CAAqB,CAAC,KALzD,QACL,IAAI,yBACF,+EAA+ED,EAAO,aAAa,gBAAgB,EACrH,CACF,CAEJ,KACE,UAAO,QAAK,IAAI,yBAAuBA,EAAO,KAAK,CAAC,CAExD,CAEO,SAAShB,EACdgB,EACgB,CAChB,GAAIA,EAAO,QAAS,CAClB,MAAME,KAAgB,sBAAmBF,EAAO,IAAI,EAC9CG,EAAO,cAAY,kBACvBD,EACAA,EAAc,OAAS,CACzB,EACME,EAAa,cAAY,iBAAiBF,EAAe,CAAC,EAChE,SAAO,SAAM,IAAI,eAAa,CAAE,KAAAC,EAAM,WAAAC,CAAW,CAAC,CAAC,CACrD,KACE,QAAQJ,EAAO,MAAO,CACpB,IAAK,kBACH,SAAO,QAAK,IAAI,uBAAqB,eAAe,CAAC,EACvD,IAAK,gBACH,SAAO,QAAK,IAAI,6BAA2B,gBAAgB,CAAC,EAC9D,IAAK,qBACH,SAAO,QACL,IAAI,sCAAoC,qBAAqB,CAC/D,EACF,IAAK,iBACL,IAAK,qBACH,SAAO,QAAK,IAAI,qCAAqC,EACvD,QACE,SAAO,QAAK,IAAI,mCAAiCA,EAAO,KAAK,CAAC,CAClE,CAEJ,CAEO,SAASnB,EACdwB,EAC4B,CAC5B,MAAO,CACL,UAAWA,EAA2B,EACxC,CACF",
6
6
  "names": ["mapper_exports", "__export", "mapNativeConnectionResultToConnectionResult", "mapNativeDeviceConnectionLostToDeviceDisconnected", "mapNativeDiscoveryDeviceToTransportDiscoveredDevice", "mapNativeLedgerDeviceToDeviceModel", "mapNativeSendApduResultToSendApduResult", "mapNativeTransportLogToLog", "__toCommonJS", "import_device_management_kit", "import_purify_ts", "import_base64Utils", "import_Errors", "import_rnHidTransportIdentifier", "nativeLedgerDevice", "deviceModelDataSource", "nativeDevice", "deviceModel", "log", "level", "assertNever", "x", "result", "transportDeviceModel", "responseBytes", "data", "statusCode", "nativeDeviceConnectionLost"]
7
7
  }
package/lib/cjs/index.js CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";var a=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var I=Object.getOwnPropertyNames;var R=Object.prototype.hasOwnProperty;var d=(o,r)=>{for(var T in r)a(o,T,{get:r[T],enumerable:!0})},f=(o,r,T,e)=>{if(r&&typeof r=="object"||typeof r=="function")for(let t of I(r))!R.call(o,t)&&t!==T&&a(o,t,{get:()=>r[t],enumerable:!(e=p(r,t))||e.enumerable});return o};var s=o=>f(a({},"__esModule",{value:!0}),o);var N={};d(N,{RNHidTransportFactory:()=>i.RNHidTransportFactory,rnHidTransportIdentifier:()=>n.TRANSPORT_IDENTIFIER});module.exports=s(N);var i=require("./api/RNHidTransportFactory"),n=require("./api/transport/rnHidTransportIdentifier");0&&(module.exports={RNHidTransportFactory,rnHidTransportIdentifier});
1
+ "use strict";var p=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var s=Object.prototype.hasOwnProperty;var I=(o,r)=>{for(var t in r)p(o,t,{get:r[t],enumerable:!0})},R=(o,r,t,d)=>{if(r&&typeof r=="object"||typeof r=="function")for(let n of f(r))!s.call(o,n)&&n!==t&&p(o,n,{get:()=>r[n],enumerable:!(d=i(r,n))||d.enumerable});return o};var m=o=>R(p({},"__esModule",{value:!0}),o);var x={};I(x,{HidTransportSendApduUnknownError:()=>T.HidTransportSendApduUnknownError,RNHidTransportFactory:()=>e.RNHidTransportFactory,rnHidTransportIdentifier:()=>a.TRANSPORT_IDENTIFIER});module.exports=m(x);var e=require("./api/RNHidTransportFactory"),T=require("./api/transport/Errors"),a=require("./api/transport/rnHidTransportIdentifier");0&&(module.exports={HidTransportSendApduUnknownError,RNHidTransportFactory,rnHidTransportIdentifier});
2
2
  //# sourceMappingURL=index.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/index.ts"],
4
- "sourcesContent": ["export { RNHidTransportFactory } from \"@api/RNHidTransportFactory\";\nexport { TRANSPORT_IDENTIFIER as rnHidTransportIdentifier } from \"@api/transport/rnHidTransportIdentifier\";\n"],
5
- "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,wHAAAE,EAAAF,GAAA,IAAAG,EAAsC,sCACtCC,EAAiE",
6
- "names": ["index_exports", "__export", "__toCommonJS", "import_RNHidTransportFactory", "import_rnHidTransportIdentifier"]
4
+ "sourcesContent": ["export { RNHidTransportFactory } from \"@api/RNHidTransportFactory\";\nexport { HidTransportSendApduUnknownError } from \"@api/transport/Errors\";\nexport { TRANSPORT_IDENTIFIER as rnHidTransportIdentifier } from \"@api/transport/rnHidTransportIdentifier\";\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,gMAAAE,EAAAF,GAAA,IAAAG,EAAsC,sCACtCC,EAAiD,iCACjDC,EAAiE",
6
+ "names": ["index_exports", "__export", "__toCommonJS", "import_RNHidTransportFactory", "import_Errors", "import_rnHidTransportIdentifier"]
7
7
  }
@@ -1,2 +1,2 @@
1
- import{ApduResponse as p,DeviceDisconnectedWhileSendingError as u,FramerUtils as i,LogLevel as o,OpeningConnectionError as s,SendApduEmptyResponseError as v,SendApduTimeoutError as l}from"@ledgerhq/device-management-kit";import{Left as r,Right as c}from"purify-ts";import{base64ToUint8Array as D}from"../helpers/base64Utils";import{HidTransportSendApduUnknownError as m}from"../transport/Errors";import{TRANSPORT_IDENTIFIER as f}from"../transport/rnHidTransportIdentifier";function a(e,t){return t.filterDeviceModels({usbProductId:Number.parseInt(e.usbProductIdMask,16)})[0]??null}function L(e,t){const n=a(e.ledgerDevice,t);return n==null?null:{id:e.uid,deviceModel:n,transport:f,name:e.name}}function b(e){let t;switch(e.level){case"error":t=o.Error;break;case"warning":t=o.Warning;break;case"info":t=o.Info;break;case"debug":t=o.Debug;break;default:y(e.level),t=o.Info;break}return[t,e.message,{tag:e.tag,data:e.jsonPayload,timestamp:Number.parseInt(e.timestamp,10)}]}function y(e){throw new Error("Unexpected object: "+e)}function S(e,t){if(e.success){const n=a(e.ledgerDevice,t);return n?c({sessionId:e.sessionId,transportDeviceModel:n}):r(new s(`Could not find device model for the connected device with usbProductIdMask: ${e.ledgerDevice.usbProductIdMask}`))}else return r(new s(e.error))}function A(e){if(e.success){const t=D(e.apdu),n=i.getFirstBytesFrom(t,t.length-2),d=i.getLastBytesFrom(t,2);return c(new p({data:n,statusCode:d}))}else return e.error==="SendApduTimeout"?r(new l("Abort timeout")):e.error==="EmptyResponse"?r(new v("Empty response")):e.error==="DeviceDisconnected"?r(new u("Device disconnected")):r(new m(e.error))}function w(e){return{sessionId:e.id}}export{S as mapNativeConnectionResultToConnectionResult,w as mapNativeDeviceConnectionLostToDeviceDisconnected,L as mapNativeDiscoveryDeviceToTransportDiscoveredDevice,a as mapNativeLedgerDeviceToDeviceModel,A as mapNativeSendApduResultToSendApduResult,b as mapNativeTransportLogToLog};
1
+ import{ApduResponse as u,DeviceDisconnectedBeforeSendingApdu as p,DeviceDisconnectedWhileSendingError as v,FramerUtils as i,LogLevel as r,OpeningConnectionError as c,SendApduEmptyResponseError as l,SendApduTimeoutError as D}from"@ledgerhq/device-management-kit";import{Left as o,Right as s}from"purify-ts";import{base64ToUint8Array as m}from"../helpers/base64Utils";import{HidTransportSendApduUnknownError as f}from"../transport/Errors";import{TRANSPORT_IDENTIFIER as N}from"../transport/rnHidTransportIdentifier";function a(e,t){return t.filterDeviceModels({usbProductId:Number.parseInt(e.usbProductIdMask,16)})[0]??null}function b(e,t){const n=a(e.ledgerDevice,t);return n==null?null:{id:e.uid,deviceModel:n,transport:N,name:e.name}}function S(e){let t;switch(e.level){case"error":t=r.Error;break;case"warning":t=r.Warning;break;case"info":t=r.Info;break;case"debug":t=r.Debug;break;default:y(e.level),t=r.Info;break}return[t,e.message,{tag:e.tag,data:e.jsonPayload,timestamp:Number.parseInt(e.timestamp,10)}]}function y(e){throw new Error("Unexpected object: "+e)}function w(e,t){if(e.success){const n=a(e.ledgerDevice,t);return n?s({sessionId:e.sessionId,transportDeviceModel:n}):o(new c(`Could not find device model for the connected device with usbProductIdMask: ${e.ledgerDevice.usbProductIdMask}`))}else return o(new c(e.error))}function A(e){if(e.success){const t=m(e.apdu),n=i.getFirstBytesFrom(t,t.length-2),d=i.getLastBytesFrom(t,2);return s(new u({data:n,statusCode:d}))}else switch(e.error){case"SendApduTimeout":return o(new D("Abort timeout"));case"EmptyResponse":return o(new l("Empty response"));case"DeviceDisconnected":return o(new v("Device disconnected"));case"DeviceNotFound":case"NoUsbEndpointFound":return o(new p);default:return o(new f(e.error))}}function E(e){return{sessionId:e.id}}export{w as mapNativeConnectionResultToConnectionResult,E as mapNativeDeviceConnectionLostToDeviceDisconnected,b as mapNativeDiscoveryDeviceToTransportDiscoveredDevice,a as mapNativeLedgerDeviceToDeviceModel,A as mapNativeSendApduResultToSendApduResult,S as mapNativeTransportLogToLog};
2
2
  //# sourceMappingURL=mapper.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/api/bridge/mapper.ts"],
4
- "sourcesContent": ["import {\n ApduResponse,\n DeviceDisconnectedWhileSendingError,\n type DeviceModelDataSource,\n FramerUtils,\n LogLevel,\n type LogParams,\n OpeningConnectionError,\n SendApduEmptyResponseError,\n type SendApduResult,\n SendApduTimeoutError,\n type TransportDeviceModel,\n type TransportDiscoveredDevice,\n} from \"@ledgerhq/device-management-kit\";\nimport { Left, Right } from \"purify-ts\";\n\nimport { base64ToUint8Array } from \"@api/helpers/base64Utils\";\nimport { HidTransportSendApduUnknownError } from \"@api/transport/Errors\";\nimport { TRANSPORT_IDENTIFIER } from \"@api/transport/rnHidTransportIdentifier\";\nimport {\n type InternalConnectionResult,\n type InternalDeviceDisconnected,\n} from \"@api/transport/types\";\n\nimport {\n type NativeDeviceConnectionLost,\n type NativeDiscoveryDevice,\n type NativeInternalConnectionResult,\n type NativeLedgerDevice,\n type NativeLog,\n type NativeSendApduResult,\n} from \"./types\";\n\nexport function mapNativeLedgerDeviceToDeviceModel(\n nativeLedgerDevice: NativeLedgerDevice,\n deviceModelDataSource: DeviceModelDataSource,\n): TransportDeviceModel | null {\n return (\n deviceModelDataSource.filterDeviceModels({\n usbProductId: Number.parseInt(nativeLedgerDevice.usbProductIdMask, 16),\n })[0] ?? null\n );\n}\n\nexport function mapNativeDiscoveryDeviceToTransportDiscoveredDevice(\n nativeDevice: NativeDiscoveryDevice,\n deviceModelDataSource: DeviceModelDataSource,\n): TransportDiscoveredDevice | null {\n const deviceModel = mapNativeLedgerDeviceToDeviceModel(\n nativeDevice.ledgerDevice,\n deviceModelDataSource,\n );\n if (deviceModel == null) return null;\n\n return {\n id: nativeDevice.uid,\n deviceModel,\n transport: TRANSPORT_IDENTIFIER,\n name: nativeDevice.name,\n };\n}\n\nexport function mapNativeTransportLogToLog(log: NativeLog): LogParams {\n let level: LogLevel;\n switch (log.level) {\n case \"error\":\n level = LogLevel.Error;\n break;\n case \"warning\":\n level = LogLevel.Warning;\n break;\n case \"info\":\n level = LogLevel.Info;\n break;\n case \"debug\":\n level = LogLevel.Debug;\n break;\n default:\n assertNever(log.level);\n level = LogLevel.Info;\n break;\n }\n\n return [\n level,\n log.message,\n {\n tag: log.tag,\n data: log.jsonPayload,\n timestamp: Number.parseInt(log.timestamp, 10),\n },\n ];\n}\n\nfunction assertNever(x: never) {\n throw new Error(\"Unexpected object: \" + x);\n}\n\nexport function mapNativeConnectionResultToConnectionResult(\n result: NativeInternalConnectionResult,\n deviceModelDataSource: DeviceModelDataSource,\n): InternalConnectionResult {\n if (result.success) {\n const transportDeviceModel = mapNativeLedgerDeviceToDeviceModel(\n result.ledgerDevice,\n deviceModelDataSource,\n );\n if (!transportDeviceModel)\n return Left(\n new OpeningConnectionError(\n `Could not find device model for the connected device with usbProductIdMask: ${result.ledgerDevice.usbProductIdMask}`,\n ),\n );\n return Right({ sessionId: result.sessionId, transportDeviceModel });\n } else {\n return Left(new OpeningConnectionError(result.error));\n }\n}\n\nexport function mapNativeSendApduResultToSendApduResult(\n result: NativeSendApduResult,\n): SendApduResult {\n if (result.success) {\n const responseBytes = base64ToUint8Array(result.apdu);\n const data = FramerUtils.getFirstBytesFrom(\n responseBytes,\n responseBytes.length - 2,\n );\n const statusCode = FramerUtils.getLastBytesFrom(responseBytes, 2);\n return Right(new ApduResponse({ data, statusCode }));\n } else if (result.error === \"SendApduTimeout\") {\n return Left(new SendApduTimeoutError(\"Abort timeout\"));\n } else if (result.error === \"EmptyResponse\") {\n return Left(new SendApduEmptyResponseError(\"Empty response\"));\n } else if (result.error === \"DeviceDisconnected\") {\n return Left(new DeviceDisconnectedWhileSendingError(\"Device disconnected\"));\n } else {\n return Left(new HidTransportSendApduUnknownError(result.error));\n }\n}\n\nexport function mapNativeDeviceConnectionLostToDeviceDisconnected(\n nativeDeviceConnectionLost: NativeDeviceConnectionLost,\n): InternalDeviceDisconnected {\n return {\n sessionId: nativeDeviceConnectionLost.id,\n };\n}\n"],
5
- "mappings": "AAAA,OACE,gBAAAA,EACA,uCAAAC,EAEA,eAAAC,EACA,YAAAC,EAEA,0BAAAC,EACA,8BAAAC,EAEA,wBAAAC,MAGK,kCACP,OAAS,QAAAC,EAAM,SAAAC,MAAa,YAE5B,OAAS,sBAAAC,MAA0B,2BACnC,OAAS,oCAAAC,MAAwC,wBACjD,OAAS,wBAAAC,MAA4B,0CAe9B,SAASC,EACdC,EACAC,EAC6B,CAC7B,OACEA,EAAsB,mBAAmB,CACvC,aAAc,OAAO,SAASD,EAAmB,iBAAkB,EAAE,CACvE,CAAC,EAAE,CAAC,GAAK,IAEb,CAEO,SAASE,EACdC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CACrD,KAAO,QAAIL,EAAO,QAAU,kBACnBjB,EAAK,IAAID,EAAqB,eAAe,CAAC,EAC5CkB,EAAO,QAAU,gBACnBjB,EAAK,IAAIF,EAA2B,gBAAgB,CAAC,EACnDmB,EAAO,QAAU,qBACnBjB,EAAK,IAAIN,EAAoC,qBAAqB,CAAC,EAEnEM,EAAK,IAAIG,EAAiCc,EAAO,KAAK,CAAC,CAElE,CAEO,SAASM,EACdC,EAC4B,CAC5B,MAAO,CACL,UAAWA,EAA2B,EACxC,CACF",
6
- "names": ["ApduResponse", "DeviceDisconnectedWhileSendingError", "FramerUtils", "LogLevel", "OpeningConnectionError", "SendApduEmptyResponseError", "SendApduTimeoutError", "Left", "Right", "base64ToUint8Array", "HidTransportSendApduUnknownError", "TRANSPORT_IDENTIFIER", "mapNativeLedgerDeviceToDeviceModel", "nativeLedgerDevice", "deviceModelDataSource", "mapNativeDiscoveryDeviceToTransportDiscoveredDevice", "nativeDevice", "deviceModel", "mapNativeTransportLogToLog", "log", "level", "assertNever", "x", "mapNativeConnectionResultToConnectionResult", "result", "transportDeviceModel", "mapNativeSendApduResultToSendApduResult", "responseBytes", "data", "statusCode", "mapNativeDeviceConnectionLostToDeviceDisconnected", "nativeDeviceConnectionLost"]
4
+ "sourcesContent": ["import {\n ApduResponse,\n DeviceDisconnectedBeforeSendingApdu,\n DeviceDisconnectedWhileSendingError,\n type DeviceModelDataSource,\n FramerUtils,\n LogLevel,\n type LogParams,\n OpeningConnectionError,\n SendApduEmptyResponseError,\n type SendApduResult,\n SendApduTimeoutError,\n type TransportDeviceModel,\n type TransportDiscoveredDevice,\n} from \"@ledgerhq/device-management-kit\";\nimport { Left, Right } from \"purify-ts\";\n\nimport { base64ToUint8Array } from \"@api/helpers/base64Utils\";\nimport { HidTransportSendApduUnknownError } from \"@api/transport/Errors\";\nimport { TRANSPORT_IDENTIFIER } from \"@api/transport/rnHidTransportIdentifier\";\nimport {\n type InternalConnectionResult,\n type InternalDeviceDisconnected,\n} from \"@api/transport/types\";\n\nimport {\n type NativeDeviceConnectionLost,\n type NativeDiscoveryDevice,\n type NativeInternalConnectionResult,\n type NativeLedgerDevice,\n type NativeLog,\n type NativeSendApduResult,\n} from \"./types\";\n\nexport function mapNativeLedgerDeviceToDeviceModel(\n nativeLedgerDevice: NativeLedgerDevice,\n deviceModelDataSource: DeviceModelDataSource,\n): TransportDeviceModel | null {\n return (\n deviceModelDataSource.filterDeviceModels({\n usbProductId: Number.parseInt(nativeLedgerDevice.usbProductIdMask, 16),\n })[0] ?? null\n );\n}\n\nexport function mapNativeDiscoveryDeviceToTransportDiscoveredDevice(\n nativeDevice: NativeDiscoveryDevice,\n deviceModelDataSource: DeviceModelDataSource,\n): TransportDiscoveredDevice | null {\n const deviceModel = mapNativeLedgerDeviceToDeviceModel(\n nativeDevice.ledgerDevice,\n deviceModelDataSource,\n );\n if (deviceModel == null) return null;\n\n return {\n id: nativeDevice.uid,\n deviceModel,\n transport: TRANSPORT_IDENTIFIER,\n name: nativeDevice.name,\n };\n}\n\nexport function mapNativeTransportLogToLog(log: NativeLog): LogParams {\n let level: LogLevel;\n switch (log.level) {\n case \"error\":\n level = LogLevel.Error;\n break;\n case \"warning\":\n level = LogLevel.Warning;\n break;\n case \"info\":\n level = LogLevel.Info;\n break;\n case \"debug\":\n level = LogLevel.Debug;\n break;\n default:\n assertNever(log.level);\n level = LogLevel.Info;\n break;\n }\n\n return [\n level,\n log.message,\n {\n tag: log.tag,\n data: log.jsonPayload,\n timestamp: Number.parseInt(log.timestamp, 10),\n },\n ];\n}\n\nfunction assertNever(x: never) {\n throw new Error(\"Unexpected object: \" + x);\n}\n\nexport function mapNativeConnectionResultToConnectionResult(\n result: NativeInternalConnectionResult,\n deviceModelDataSource: DeviceModelDataSource,\n): InternalConnectionResult {\n if (result.success) {\n const transportDeviceModel = mapNativeLedgerDeviceToDeviceModel(\n result.ledgerDevice,\n deviceModelDataSource,\n );\n if (!transportDeviceModel)\n return Left(\n new OpeningConnectionError(\n `Could not find device model for the connected device with usbProductIdMask: ${result.ledgerDevice.usbProductIdMask}`,\n ),\n );\n return Right({ sessionId: result.sessionId, transportDeviceModel });\n } else {\n return Left(new OpeningConnectionError(result.error));\n }\n}\n\nexport function mapNativeSendApduResultToSendApduResult(\n result: NativeSendApduResult,\n): SendApduResult {\n if (result.success) {\n const responseBytes = base64ToUint8Array(result.apdu);\n const data = FramerUtils.getFirstBytesFrom(\n responseBytes,\n responseBytes.length - 2,\n );\n const statusCode = FramerUtils.getLastBytesFrom(responseBytes, 2);\n return Right(new ApduResponse({ data, statusCode }));\n } else {\n switch (result.error) {\n case \"SendApduTimeout\":\n return Left(new SendApduTimeoutError(\"Abort timeout\"));\n case \"EmptyResponse\":\n return Left(new SendApduEmptyResponseError(\"Empty response\"));\n case \"DeviceDisconnected\":\n return Left(\n new DeviceDisconnectedWhileSendingError(\"Device disconnected\"),\n );\n case \"DeviceNotFound\":\n case \"NoUsbEndpointFound\":\n return Left(new DeviceDisconnectedBeforeSendingApdu());\n default:\n return Left(new HidTransportSendApduUnknownError(result.error));\n }\n }\n}\n\nexport function mapNativeDeviceConnectionLostToDeviceDisconnected(\n nativeDeviceConnectionLost: NativeDeviceConnectionLost,\n): InternalDeviceDisconnected {\n return {\n sessionId: nativeDeviceConnectionLost.id,\n };\n}\n"],
5
+ "mappings": "AAAA,OACE,gBAAAA,EACA,uCAAAC,EACA,uCAAAC,EAEA,eAAAC,EACA,YAAAC,EAEA,0BAAAC,EACA,8BAAAC,EAEA,wBAAAC,MAGK,kCACP,OAAS,QAAAC,EAAM,SAAAC,MAAa,YAE5B,OAAS,sBAAAC,MAA0B,2BACnC,OAAS,oCAAAC,MAAwC,wBACjD,OAAS,wBAAAC,MAA4B,0CAe9B,SAASC,EACdC,EACAC,EAC6B,CAC7B,OACEA,EAAsB,mBAAmB,CACvC,aAAc,OAAO,SAASD,EAAmB,iBAAkB,EAAE,CACvE,CAAC,EAAE,CAAC,GAAK,IAEb,CAEO,SAASE,EACdC,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ACrD,KACE,QAAQL,EAAO,MAAO,CACpB,IAAK,kBACH,OAAOjB,EAAK,IAAID,EAAqB,eAAe,CAAC,EACvD,IAAK,gBACH,OAAOC,EAAK,IAAIF,EAA2B,gBAAgB,CAAC,EAC9D,IAAK,qBACH,OAAOE,EACL,IAAIN,EAAoC,qBAAqB,CAC/D,EACF,IAAK,iBACL,IAAK,qBACH,OAAOM,EAAK,IAAIP,CAAqC,EACvD,QACE,OAAOO,EAAK,IAAIG,EAAiCc,EAAO,KAAK,CAAC,CAClE,CAEJ,CAEO,SAASM,EACdC,EAC4B,CAC5B,MAAO,CACL,UAAWA,EAA2B,EACxC,CACF",
6
+ "names": ["ApduResponse", "DeviceDisconnectedBeforeSendingApdu", "DeviceDisconnectedWhileSendingError", "FramerUtils", "LogLevel", "OpeningConnectionError", "SendApduEmptyResponseError", "SendApduTimeoutError", "Left", "Right", "base64ToUint8Array", "HidTransportSendApduUnknownError", "TRANSPORT_IDENTIFIER", "mapNativeLedgerDeviceToDeviceModel", "nativeLedgerDevice", "deviceModelDataSource", "mapNativeDiscoveryDeviceToTransportDiscoveredDevice", "nativeDevice", "deviceModel", "mapNativeTransportLogToLog", "log", "level", "assertNever", "x", "mapNativeConnectionResultToConnectionResult", "result", "transportDeviceModel", "mapNativeSendApduResultToSendApduResult", "responseBytes", "data", "statusCode", "mapNativeDeviceConnectionLostToDeviceDisconnected", "nativeDeviceConnectionLost"]
7
7
  }
package/lib/esm/index.js CHANGED
@@ -1,2 +1,2 @@
1
- import{RNHidTransportFactory as t}from"./api/RNHidTransportFactory";import{TRANSPORT_IDENTIFIER as a}from"./api/transport/rnHidTransportIdentifier";export{t as RNHidTransportFactory,a as rnHidTransportIdentifier};
1
+ import{RNHidTransportFactory as n}from"./api/RNHidTransportFactory";import{HidTransportSendApduUnknownError as p}from"./api/transport/Errors";import{TRANSPORT_IDENTIFIER as e}from"./api/transport/rnHidTransportIdentifier";export{p as HidTransportSendApduUnknownError,n as RNHidTransportFactory,e as rnHidTransportIdentifier};
2
2
  //# sourceMappingURL=index.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/index.ts"],
4
- "sourcesContent": ["export { RNHidTransportFactory } from \"@api/RNHidTransportFactory\";\nexport { TRANSPORT_IDENTIFIER as rnHidTransportIdentifier } from \"@api/transport/rnHidTransportIdentifier\";\n"],
5
- "mappings": "AAAA,OAAS,yBAAAA,MAA6B,6BACtC,OAAiC,wBAAxBC,MAAwD",
6
- "names": ["RNHidTransportFactory", "TRANSPORT_IDENTIFIER"]
4
+ "sourcesContent": ["export { RNHidTransportFactory } from \"@api/RNHidTransportFactory\";\nexport { HidTransportSendApduUnknownError } from \"@api/transport/Errors\";\nexport { TRANSPORT_IDENTIFIER as rnHidTransportIdentifier } from \"@api/transport/rnHidTransportIdentifier\";\n"],
5
+ "mappings": "AAAA,OAAS,yBAAAA,MAA6B,6BACtC,OAAS,oCAAAC,MAAwC,wBACjD,OAAiC,wBAAxBC,MAAwD",
6
+ "names": ["RNHidTransportFactory", "HidTransportSendApduUnknownError", "TRANSPORT_IDENTIFIER"]
7
7
  }
@@ -1 +1 @@
1
- {"version":3,"file":"mapper.d.ts","sourceRoot":"","sources":["../../../../src/api/bridge/mapper.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,qBAAqB,EAG1B,KAAK,SAAS,EAGd,KAAK,cAAc,EAEnB,KAAK,oBAAoB,EACzB,KAAK,yBAAyB,EAC/B,MAAM,iCAAiC,CAAC;AAMzC,OAAO,EACL,KAAK,wBAAwB,EAC7B,KAAK,0BAA0B,EAChC,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EACL,KAAK,0BAA0B,EAC/B,KAAK,qBAAqB,EAC1B,KAAK,8BAA8B,EACnC,KAAK,kBAAkB,EACvB,KAAK,SAAS,EACd,KAAK,oBAAoB,EAC1B,MAAM,SAAS,CAAC;AAEjB,wBAAgB,kCAAkC,CAChD,kBAAkB,EAAE,kBAAkB,EACt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8BpE;AAMD,wBAAgB,2CAA2C,CACzD,MAAM,EAAE,8BAA8B,EACtC,qBAAqB,EAAE,qBAAqB,GAC3C,wBAAwB,CAgB1B;AAED,wBAAgB,uCAAuC,CACrD,MAAM,EAAE,oBAAoB,GAC3B,cAAc,CA0BhB;AAED,wBAAgB,iDAAiD,CAC/D,0BAA0B,EAAE,0BAA0B,GACrD,0BAA0B,CAI5B"}
@@ -1,3 +1,4 @@
1
1
  export { RNHidTransportFactory } from "./api/RNHidTransportFactory";
2
+ export { HidTransportSendApduUnknownError } from "./api/transport/Errors";
2
3
  export { TRANSPORT_IDENTIFIER as rnHidTransportIdentifier } from "./api/transport/rnHidTransportIdentifier";
3
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,oBAAoB,IAAI,wBAAwB,EAAE,MAAM,yCAAyC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,gCAAgC,EAAE,MAAM,uBAAuB,CAAC;AACzE,OAAO,EAAE,oBAAoB,IAAI,wBAAwB,EAAE,MAAM,yCAAyC,CAAC"}