@ledgerhq/device-signer-kit-bitcoin 1.2.1 → 1.3.1

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.
Files changed (91) hide show
  1. package/lib/cjs/api/app-binder/GetWalletAddressDeviceActionTypes.js +1 -1
  2. package/lib/cjs/api/app-binder/GetWalletAddressDeviceActionTypes.js.map +3 -3
  3. package/lib/cjs/api/app-binder/SignPsbtDeviceActionTypes.js +1 -1
  4. package/lib/cjs/api/app-binder/SignPsbtDeviceActionTypes.js.map +3 -3
  5. package/lib/cjs/api/app-binder/SignTransactionDeviceActionTypes.js +1 -1
  6. package/lib/cjs/api/app-binder/SignTransactionDeviceActionTypes.js.map +3 -3
  7. package/lib/cjs/internal/app-binder/BtcAppBinder.js +1 -1
  8. package/lib/cjs/internal/app-binder/BtcAppBinder.js.map +3 -3
  9. package/lib/cjs/internal/app-binder/BtcAppBinder.test.js +1 -1
  10. package/lib/cjs/internal/app-binder/BtcAppBinder.test.js.map +3 -3
  11. package/lib/cjs/internal/app-binder/command/ContinueCommand.js +1 -1
  12. package/lib/cjs/internal/app-binder/command/ContinueCommand.js.map +3 -3
  13. package/lib/cjs/internal/app-binder/command/ContinueCommand.test.js +1 -1
  14. package/lib/cjs/internal/app-binder/command/ContinueCommand.test.js.map +1 -1
  15. package/lib/cjs/internal/app-binder/command/GetExtendedPublicKeyCommand.js +1 -1
  16. package/lib/cjs/internal/app-binder/command/GetExtendedPublicKeyCommand.js.map +3 -3
  17. package/lib/cjs/internal/app-binder/command/GetExtendedPublicKeyCommand.test.js +1 -1
  18. package/lib/cjs/internal/app-binder/command/GetExtendedPublicKeyCommand.test.js.map +1 -1
  19. package/lib/cjs/internal/app-binder/command/GetMasterFingerprintCommand.js +1 -1
  20. package/lib/cjs/internal/app-binder/command/GetMasterFingerprintCommand.js.map +3 -3
  21. package/lib/cjs/internal/app-binder/command/GetMasterFingerprintCommand.test.js +1 -1
  22. package/lib/cjs/internal/app-binder/command/GetMasterFingerprintCommand.test.js.map +1 -1
  23. package/lib/cjs/internal/app-binder/constants.js +2 -0
  24. package/lib/cjs/internal/app-binder/constants.js.map +7 -0
  25. package/lib/cjs/internal/app-binder/device-action/GetWalletAddress/GetWalletAddressDeviceAction.js +1 -1
  26. package/lib/cjs/internal/app-binder/device-action/GetWalletAddress/GetWalletAddressDeviceAction.js.map +3 -3
  27. package/lib/cjs/internal/app-binder/device-action/GetWalletAddress/GetWalletAddressDeviceAction.test.js +1 -1
  28. package/lib/cjs/internal/app-binder/device-action/GetWalletAddress/GetWalletAddressDeviceAction.test.js.map +3 -3
  29. package/lib/cjs/internal/app-binder/device-action/SignPsbt/SignPsbtDeviceAction.js +1 -1
  30. package/lib/cjs/internal/app-binder/device-action/SignPsbt/SignPsbtDeviceAction.js.map +3 -3
  31. package/lib/cjs/internal/app-binder/device-action/SignPsbt/SignPsbtDeviceAction.test.js +1 -1
  32. package/lib/cjs/internal/app-binder/device-action/SignPsbt/SignPsbtDeviceAction.test.js.map +3 -3
  33. package/lib/cjs/internal/app-binder/device-action/SignTransaction/SignTransactionDeviceAction.js +1 -1
  34. package/lib/cjs/internal/app-binder/device-action/SignTransaction/SignTransactionDeviceAction.js.map +3 -3
  35. package/lib/cjs/internal/app-binder/device-action/SignTransaction/SignTransactionDeviceAction.test.js +1 -1
  36. package/lib/cjs/internal/app-binder/device-action/SignTransaction/SignTransactionDeviceAction.test.js.map +3 -3
  37. package/lib/cjs/package.json +1 -1
  38. package/lib/esm/api/app-binder/GetWalletAddressDeviceActionTypes.js +1 -0
  39. package/lib/esm/api/app-binder/GetWalletAddressDeviceActionTypes.js.map +4 -4
  40. package/lib/esm/api/app-binder/SignPsbtDeviceActionTypes.js +1 -0
  41. package/lib/esm/api/app-binder/SignPsbtDeviceActionTypes.js.map +4 -4
  42. package/lib/esm/api/app-binder/SignTransactionDeviceActionTypes.js +1 -0
  43. package/lib/esm/api/app-binder/SignTransactionDeviceActionTypes.js.map +4 -4
  44. package/lib/esm/internal/app-binder/BtcAppBinder.js +1 -1
  45. package/lib/esm/internal/app-binder/BtcAppBinder.js.map +3 -3
  46. package/lib/esm/internal/app-binder/BtcAppBinder.test.js +1 -1
  47. package/lib/esm/internal/app-binder/BtcAppBinder.test.js.map +3 -3
  48. package/lib/esm/internal/app-binder/command/ContinueCommand.js +1 -1
  49. package/lib/esm/internal/app-binder/command/ContinueCommand.js.map +3 -3
  50. package/lib/esm/internal/app-binder/command/ContinueCommand.test.js +1 -1
  51. package/lib/esm/internal/app-binder/command/ContinueCommand.test.js.map +1 -1
  52. package/lib/esm/internal/app-binder/command/GetExtendedPublicKeyCommand.js +1 -1
  53. package/lib/esm/internal/app-binder/command/GetExtendedPublicKeyCommand.js.map +3 -3
  54. package/lib/esm/internal/app-binder/command/GetExtendedPublicKeyCommand.test.js +1 -1
  55. package/lib/esm/internal/app-binder/command/GetExtendedPublicKeyCommand.test.js.map +1 -1
  56. package/lib/esm/internal/app-binder/command/GetMasterFingerprintCommand.js +1 -1
  57. package/lib/esm/internal/app-binder/command/GetMasterFingerprintCommand.js.map +3 -3
  58. package/lib/esm/internal/app-binder/command/GetMasterFingerprintCommand.test.js +1 -1
  59. package/lib/esm/internal/app-binder/command/GetMasterFingerprintCommand.test.js.map +1 -1
  60. package/lib/esm/internal/app-binder/constants.js +2 -0
  61. package/lib/esm/internal/app-binder/constants.js.map +7 -0
  62. package/lib/esm/internal/app-binder/device-action/GetWalletAddress/GetWalletAddressDeviceAction.js +1 -1
  63. package/lib/esm/internal/app-binder/device-action/GetWalletAddress/GetWalletAddressDeviceAction.js.map +3 -3
  64. package/lib/esm/internal/app-binder/device-action/GetWalletAddress/GetWalletAddressDeviceAction.test.js +1 -1
  65. package/lib/esm/internal/app-binder/device-action/GetWalletAddress/GetWalletAddressDeviceAction.test.js.map +3 -3
  66. package/lib/esm/internal/app-binder/device-action/SignPsbt/SignPsbtDeviceAction.js +1 -1
  67. package/lib/esm/internal/app-binder/device-action/SignPsbt/SignPsbtDeviceAction.js.map +3 -3
  68. package/lib/esm/internal/app-binder/device-action/SignPsbt/SignPsbtDeviceAction.test.js +1 -1
  69. package/lib/esm/internal/app-binder/device-action/SignPsbt/SignPsbtDeviceAction.test.js.map +3 -3
  70. package/lib/esm/internal/app-binder/device-action/SignTransaction/SignTransactionDeviceAction.js +1 -1
  71. package/lib/esm/internal/app-binder/device-action/SignTransaction/SignTransactionDeviceAction.js.map +3 -3
  72. package/lib/esm/internal/app-binder/device-action/SignTransaction/SignTransactionDeviceAction.test.js +1 -1
  73. package/lib/esm/internal/app-binder/device-action/SignTransaction/SignTransactionDeviceAction.test.js.map +3 -3
  74. package/lib/esm/package.json +1 -1
  75. package/lib/types/api/app-binder/GetWalletAddressDeviceActionTypes.d.ts +7 -0
  76. package/lib/types/api/app-binder/GetWalletAddressDeviceActionTypes.d.ts.map +1 -1
  77. package/lib/types/api/app-binder/SignPsbtDeviceActionTypes.d.ts +8 -0
  78. package/lib/types/api/app-binder/SignPsbtDeviceActionTypes.d.ts.map +1 -1
  79. package/lib/types/api/app-binder/SignTransactionDeviceActionTypes.d.ts +7 -0
  80. package/lib/types/api/app-binder/SignTransactionDeviceActionTypes.d.ts.map +1 -1
  81. package/lib/types/internal/app-binder/BtcAppBinder.d.ts.map +1 -1
  82. package/lib/types/internal/app-binder/command/ContinueCommand.d.ts.map +1 -1
  83. package/lib/types/internal/app-binder/command/GetExtendedPublicKeyCommand.d.ts.map +1 -1
  84. package/lib/types/internal/app-binder/command/GetMasterFingerprintCommand.d.ts.map +1 -1
  85. package/lib/types/internal/app-binder/constants.d.ts +2 -0
  86. package/lib/types/internal/app-binder/constants.d.ts.map +1 -0
  87. package/lib/types/internal/app-binder/device-action/GetWalletAddress/GetWalletAddressDeviceAction.d.ts.map +1 -1
  88. package/lib/types/internal/app-binder/device-action/SignPsbt/SignPsbtDeviceAction.d.ts.map +1 -1
  89. package/lib/types/internal/app-binder/device-action/SignTransaction/SignTransactionDeviceAction.d.ts.map +1 -1
  90. package/lib/types/tsconfig.prod.tsbuildinfo +1 -1
  91. package/package.json +6 -6
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/internal/app-binder/BtcAppBinder.ts"],
4
- "sourcesContent": ["import {\n CallTaskInAppDeviceAction,\n DeviceManagementKit,\n type DeviceSessionId,\n LoggerPublisherService,\n SendCommandInAppDeviceAction,\n UserInteractionRequired,\n} from \"@ledgerhq/device-management-kit\";\nimport { inject, injectable } from \"inversify\";\n\nimport {\n GetExtendedPublicKeyDAInput,\n GetExtendedPublicKeyDAReturnType,\n} from \"@api/app-binder/GetExtendedPublicKeyDeviceActionTypes\";\nimport {\n GetMasterFingerprintDAInput,\n GetMasterFingerprintDAReturnType,\n} from \"@api/app-binder/GetMasterFingerprintDeviceActionTypes\";\nimport {\n RegisterWalletDAInput,\n RegisterWalletDAReturnType,\n} from \"@api/app-binder/RegisterWalletDeviceActionTypes\";\nimport { SignMessageDAReturnType } from \"@api/app-binder/SignMessageDeviceActionTypes\";\nimport { SignPsbtDAReturnType } from \"@api/app-binder/SignPsbtDeviceActionTypes\";\nimport { SignTransactionDAReturnType } from \"@api/app-binder/SignTransactionDeviceActionTypes\";\nimport { GetWalletAddressDAReturnType } from \"@api/index\";\nimport { Psbt } from \"@api/model/Psbt\";\nimport { Wallet } from \"@api/model/Wallet\";\nimport { GetExtendedPublicKeyCommand } from \"@internal/app-binder/command/GetExtendedPublicKeyCommand\";\nimport { GetMasterFingerprintCommand } from \"@internal/app-binder/command/GetMasterFingerprintCommand\";\nimport { SignPsbtDeviceAction } from \"@internal/app-binder/device-action/SignPsbt/SignPsbtDeviceAction\";\nimport { SignTransactionDeviceAction } from \"@internal/app-binder/device-action/SignTransaction/SignTransactionDeviceAction\";\nimport { RegisterWalletTask } from \"@internal/app-binder/task/RegisterWalletTask\";\nimport { SendSignMessageTask } from \"@internal/app-binder/task/SignMessageTask\";\nimport { dataStoreTypes } from \"@internal/data-store/di/dataStoreTypes\";\nimport type { DataStoreService } from \"@internal/data-store/service/DataStoreService\";\nimport { externalTypes } from \"@internal/externalTypes\";\nimport { psbtTypes } from \"@internal/psbt/di/psbtTypes\";\nimport type { PsbtMapper } from \"@internal/psbt/service/psbt/PsbtMapper\";\nimport type { ValueParser } from \"@internal/psbt/service/value/ValueParser\";\nimport { walletTypes } from \"@internal/wallet/di/walletTypes\";\nimport type { WalletBuilder } from \"@internal/wallet/service/WalletBuilder\";\nimport type { WalletSerializer } from \"@internal/wallet/service/WalletSerializer\";\n\nimport { GetWalletAddressDeviceAction } from \"./device-action/GetWalletAddress/GetWalletAddressDeviceAction\";\n\n@injectable()\nexport class BtcAppBinder {\n constructor(\n @inject(externalTypes.Dmk)\n private readonly _dmk: DeviceManagementKit,\n @inject(externalTypes.SessionId)\n private readonly _sessionId: DeviceSessionId,\n @inject(walletTypes.WalletBuilder)\n private readonly _walletBuilder: WalletBuilder,\n @inject(walletTypes.WalletSerializer)\n private readonly _walletSerializer: WalletSerializer,\n @inject(dataStoreTypes.DataStoreService)\n private readonly _dataStoreService: DataStoreService,\n @inject(psbtTypes.PsbtMapper)\n private readonly _psbtMapper: PsbtMapper,\n @inject(psbtTypes.ValueParser)\n private readonly _valueParser: ValueParser,\n @inject(externalTypes.DmkLoggerFactory)\n private readonly _dmkLoggerFactory: (tag: string) => LoggerPublisherService,\n ) {}\n\n getExtendedPublicKey(\n args: GetExtendedPublicKeyDAInput,\n ): GetExtendedPublicKeyDAReturnType {\n return this._dmk.executeDeviceAction({\n sessionId: this._sessionId,\n deviceAction: new SendCommandInAppDeviceAction({\n input: {\n command: new GetExtendedPublicKeyCommand(args),\n appName: \"Bitcoin\",\n requiredUserInteraction: args.checkOnDevice\n ? UserInteractionRequired.VerifyAddress\n : UserInteractionRequired.None,\n skipOpenApp: args.skipOpenApp,\n },\n logger: this._dmkLoggerFactory(\"GetExtendedPublicKeyCommand\"),\n }),\n });\n }\n\n getMasterFingerprint(\n args: GetMasterFingerprintDAInput,\n ): GetMasterFingerprintDAReturnType {\n return this._dmk.executeDeviceAction({\n sessionId: this._sessionId,\n deviceAction: new SendCommandInAppDeviceAction({\n input: {\n command: new GetMasterFingerprintCommand(),\n appName: \"Bitcoin\",\n requiredUserInteraction: UserInteractionRequired.None,\n skipOpenApp: args.skipOpenApp,\n },\n logger: this._dmkLoggerFactory(\"GetMasterFingerprintCommand\"),\n }),\n });\n }\n\n signMessage(args: {\n derivationPath: string;\n message: string;\n skipOpenApp: boolean;\n }): SignMessageDAReturnType {\n return this._dmk.executeDeviceAction({\n sessionId: this._sessionId,\n deviceAction: new CallTaskInAppDeviceAction({\n input: {\n task: async (internalApi) =>\n new SendSignMessageTask(\n internalApi,\n {\n derivationPath: args.derivationPath,\n message: args.message,\n loggerFactory: this._dmkLoggerFactory,\n },\n this._dataStoreService,\n ).run(),\n appName: \"Bitcoin\",\n requiredUserInteraction: UserInteractionRequired.SignPersonalMessage,\n skipOpenApp: args.skipOpenApp,\n },\n logger: this._dmkLoggerFactory(\"SendSignMessageTask\"),\n }),\n });\n }\n\n signPsbt(args: {\n psbt: Psbt;\n wallet: Wallet;\n skipOpenApp: boolean;\n }): SignPsbtDAReturnType {\n return this._dmk.executeDeviceAction({\n sessionId: this._sessionId,\n deviceAction: new SignPsbtDeviceAction({\n input: {\n psbt: args.psbt,\n wallet: args.wallet,\n walletBuilder: this._walletBuilder,\n walletSerializer: this._walletSerializer,\n dataStoreService: this._dataStoreService,\n psbtMapper: this._psbtMapper,\n valueParser: this._valueParser,\n skipOpenApp: args.skipOpenApp,\n },\n loggerFactory: this._dmkLoggerFactory,\n }),\n });\n }\n\n getWalletAddress(args: {\n checkOnDevice: boolean;\n wallet: Wallet;\n change: boolean;\n addressIndex: number;\n skipOpenApp: boolean;\n }): GetWalletAddressDAReturnType {\n return this._dmk.executeDeviceAction({\n sessionId: this._sessionId,\n deviceAction: new GetWalletAddressDeviceAction({\n input: {\n wallet: args.wallet,\n skipOpenApp: args.skipOpenApp,\n checkOnDevice: args.checkOnDevice,\n change: args.change,\n addressIndex: args.addressIndex,\n walletBuilder: this._walletBuilder,\n walletSerializer: this._walletSerializer,\n dataStoreService: this._dataStoreService,\n },\n loggerFactory: this._dmkLoggerFactory,\n }),\n });\n }\n\n signTransaction(args: {\n psbt: Psbt;\n wallet: Wallet;\n skipOpenApp: boolean;\n }): SignTransactionDAReturnType {\n return this._dmk.executeDeviceAction({\n sessionId: this._sessionId,\n deviceAction: new SignTransactionDeviceAction({\n input: {\n psbt: args.psbt,\n wallet: args.wallet,\n walletBuilder: this._walletBuilder,\n walletSerializer: this._walletSerializer,\n dataStoreService: this._dataStoreService,\n psbtMapper: this._psbtMapper,\n valueParser: this._valueParser,\n skipOpenApp: args.skipOpenApp,\n },\n loggerFactory: this._dmkLoggerFactory,\n }),\n });\n }\n\n registerWallet(args: RegisterWalletDAInput): RegisterWalletDAReturnType {\n return this._dmk.executeDeviceAction({\n sessionId: this._sessionId,\n deviceAction: new CallTaskInAppDeviceAction({\n input: {\n task: async (internalApi) =>\n new RegisterWalletTask(\n internalApi,\n {\n walletPolicy: args.wallet,\n loggerFactory: this._dmkLoggerFactory,\n },\n this._walletBuilder,\n this._walletSerializer,\n this._dataStoreService,\n ).run(),\n appName: \"Bitcoin\",\n requiredUserInteraction: UserInteractionRequired.RegisterWallet,\n skipOpenApp: args.skipOpenApp,\n },\n logger: this._dmkLoggerFactory(\"RegisterWalletTask\"),\n }),\n });\n }\n}\n"],
5
- "mappings": "iOAAA,OACE,6BAAAA,EAIA,gCAAAC,EACA,2BAAAC,MACK,kCACP,OAAS,UAAAC,EAAQ,cAAAC,MAAkB,YAoBnC,OAAS,+BAAAC,MAAmC,2DAC5C,OAAS,+BAAAC,MAAmC,2DAC5C,OAAS,wBAAAC,MAA4B,mEACrC,OAAS,+BAAAC,MAAmC,iFAC5C,OAAS,sBAAAC,MAA0B,+CACnC,OAAS,uBAAAC,MAA2B,4CACpC,OAAS,kBAAAC,MAAsB,yCAE/B,OAAS,iBAAAC,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AaH,EAAK,WACpB,EACA,OAAQ,KAAK,kBAAkB,oBAAoB,CACrD,CAAC,CACH,CAAC,CACH,CACF,EAnLaT,EAANqB,EAAA,CADNC,EAAW,EAGPC,EAAA,EAAAC,EAAOC,EAAc,GAAG,GAExBF,EAAA,EAAAC,EAAOC,EAAc,SAAS,GAE9BF,EAAA,EAAAC,EAAOE,EAAY,aAAa,GAEhCH,EAAA,EAAAC,EAAOE,EAAY,gBAAgB,GAEnCH,EAAA,EAAAC,EAAOG,EAAe,gBAAgB,GAEtCJ,EAAA,EAAAC,EAAOI,EAAU,UAAU,GAE3BL,EAAA,EAAAC,EAAOI,EAAU,WAAW,GAE5BL,EAAA,EAAAC,EAAOC,EAAc,gBAAgB,IAhB7BzB",
6
- "names": ["CallTaskInAppDeviceAction", "SendCommandInAppDeviceAction", "UserInteractionRequired", "inject", "injectable", "GetExtendedPublicKeyCommand", "GetMasterFingerprintCommand", "SignPsbtDeviceAction", "SignTransactionDeviceAction", "RegisterWalletTask", "SendSignMessageTask", "dataStoreTypes", "externalTypes", "psbtTypes", "walletTypes", "GetWalletAddressDeviceAction", "BtcAppBinder", "_dmk", "_sessionId", "_walletBuilder", "_walletSerializer", "_dataStoreService", "_psbtMapper", "_valueParser", "_dmkLoggerFactory", "args", "SendCommandInAppDeviceAction", "GetExtendedPublicKeyCommand", "UserInteractionRequired", "GetMasterFingerprintCommand", "CallTaskInAppDeviceAction", "internalApi", "SendSignMessageTask", "SignPsbtDeviceAction", "GetWalletAddressDeviceAction", "SignTransactionDeviceAction", "RegisterWalletTask", "__decorateClass", "injectable", "__decorateParam", "inject", "externalTypes", "walletTypes", "dataStoreTypes", "psbtTypes"]
4
+ "sourcesContent": ["import {\n CallTaskInAppDeviceAction,\n DeviceManagementKit,\n type DeviceSessionId,\n LoggerPublisherService,\n SendCommandInAppDeviceAction,\n UserInteractionRequired,\n} from \"@ledgerhq/device-management-kit\";\nimport { inject, injectable } from \"inversify\";\n\nimport {\n GetExtendedPublicKeyDAInput,\n GetExtendedPublicKeyDAReturnType,\n} from \"@api/app-binder/GetExtendedPublicKeyDeviceActionTypes\";\nimport {\n GetMasterFingerprintDAInput,\n GetMasterFingerprintDAReturnType,\n} from \"@api/app-binder/GetMasterFingerprintDeviceActionTypes\";\nimport {\n RegisterWalletDAInput,\n RegisterWalletDAReturnType,\n} from \"@api/app-binder/RegisterWalletDeviceActionTypes\";\nimport { SignMessageDAReturnType } from \"@api/app-binder/SignMessageDeviceActionTypes\";\nimport { SignPsbtDAReturnType } from \"@api/app-binder/SignPsbtDeviceActionTypes\";\nimport { SignTransactionDAReturnType } from \"@api/app-binder/SignTransactionDeviceActionTypes\";\nimport { GetWalletAddressDAReturnType } from \"@api/index\";\nimport { Psbt } from \"@api/model/Psbt\";\nimport { Wallet } from \"@api/model/Wallet\";\nimport { GetExtendedPublicKeyCommand } from \"@internal/app-binder/command/GetExtendedPublicKeyCommand\";\nimport { GetMasterFingerprintCommand } from \"@internal/app-binder/command/GetMasterFingerprintCommand\";\nimport { SignPsbtDeviceAction } from \"@internal/app-binder/device-action/SignPsbt/SignPsbtDeviceAction\";\nimport { SignTransactionDeviceAction } from \"@internal/app-binder/device-action/SignTransaction/SignTransactionDeviceAction\";\nimport { RegisterWalletTask } from \"@internal/app-binder/task/RegisterWalletTask\";\nimport { SendSignMessageTask } from \"@internal/app-binder/task/SignMessageTask\";\nimport { dataStoreTypes } from \"@internal/data-store/di/dataStoreTypes\";\nimport type { DataStoreService } from \"@internal/data-store/service/DataStoreService\";\nimport { externalTypes } from \"@internal/externalTypes\";\nimport { psbtTypes } from \"@internal/psbt/di/psbtTypes\";\nimport type { PsbtMapper } from \"@internal/psbt/service/psbt/PsbtMapper\";\nimport type { ValueParser } from \"@internal/psbt/service/value/ValueParser\";\nimport { walletTypes } from \"@internal/wallet/di/walletTypes\";\nimport type { WalletBuilder } from \"@internal/wallet/service/WalletBuilder\";\nimport type { WalletSerializer } from \"@internal/wallet/service/WalletSerializer\";\n\nimport { GetWalletAddressDeviceAction } from \"./device-action/GetWalletAddress/GetWalletAddressDeviceAction\";\nimport { APP_NAME } from \"./constants\";\n\n@injectable()\nexport class BtcAppBinder {\n constructor(\n @inject(externalTypes.Dmk)\n private readonly _dmk: DeviceManagementKit,\n @inject(externalTypes.SessionId)\n private readonly _sessionId: DeviceSessionId,\n @inject(walletTypes.WalletBuilder)\n private readonly _walletBuilder: WalletBuilder,\n @inject(walletTypes.WalletSerializer)\n private readonly _walletSerializer: WalletSerializer,\n @inject(dataStoreTypes.DataStoreService)\n private readonly _dataStoreService: DataStoreService,\n @inject(psbtTypes.PsbtMapper)\n private readonly _psbtMapper: PsbtMapper,\n @inject(psbtTypes.ValueParser)\n private readonly _valueParser: ValueParser,\n @inject(externalTypes.DmkLoggerFactory)\n private readonly _dmkLoggerFactory: (tag: string) => LoggerPublisherService,\n ) {}\n\n getExtendedPublicKey(\n args: GetExtendedPublicKeyDAInput,\n ): GetExtendedPublicKeyDAReturnType {\n return this._dmk.executeDeviceAction({\n sessionId: this._sessionId,\n deviceAction: new SendCommandInAppDeviceAction({\n input: {\n command: new GetExtendedPublicKeyCommand(args),\n appName: APP_NAME,\n requiredUserInteraction: args.checkOnDevice\n ? UserInteractionRequired.VerifyAddress\n : UserInteractionRequired.None,\n skipOpenApp: args.skipOpenApp,\n },\n logger: this._dmkLoggerFactory(\"GetExtendedPublicKeyCommand\"),\n }),\n });\n }\n\n getMasterFingerprint(\n args: GetMasterFingerprintDAInput,\n ): GetMasterFingerprintDAReturnType {\n return this._dmk.executeDeviceAction({\n sessionId: this._sessionId,\n deviceAction: new SendCommandInAppDeviceAction({\n input: {\n command: new GetMasterFingerprintCommand(),\n appName: APP_NAME,\n requiredUserInteraction: UserInteractionRequired.None,\n skipOpenApp: args.skipOpenApp,\n },\n logger: this._dmkLoggerFactory(\"GetMasterFingerprintCommand\"),\n }),\n });\n }\n\n signMessage(args: {\n derivationPath: string;\n message: string;\n skipOpenApp: boolean;\n }): SignMessageDAReturnType {\n return this._dmk.executeDeviceAction({\n sessionId: this._sessionId,\n deviceAction: new CallTaskInAppDeviceAction({\n input: {\n task: async (internalApi) =>\n new SendSignMessageTask(\n internalApi,\n {\n derivationPath: args.derivationPath,\n message: args.message,\n loggerFactory: this._dmkLoggerFactory,\n },\n this._dataStoreService,\n ).run(),\n appName: APP_NAME,\n requiredUserInteraction: UserInteractionRequired.SignPersonalMessage,\n skipOpenApp: args.skipOpenApp,\n },\n logger: this._dmkLoggerFactory(\"SendSignMessageTask\"),\n }),\n });\n }\n\n signPsbt(args: {\n psbt: Psbt;\n wallet: Wallet;\n skipOpenApp: boolean;\n }): SignPsbtDAReturnType {\n return this._dmk.executeDeviceAction({\n sessionId: this._sessionId,\n deviceAction: new SignPsbtDeviceAction({\n input: {\n psbt: args.psbt,\n wallet: args.wallet,\n walletBuilder: this._walletBuilder,\n walletSerializer: this._walletSerializer,\n dataStoreService: this._dataStoreService,\n psbtMapper: this._psbtMapper,\n valueParser: this._valueParser,\n skipOpenApp: args.skipOpenApp,\n },\n loggerFactory: this._dmkLoggerFactory,\n }),\n });\n }\n\n getWalletAddress(args: {\n checkOnDevice: boolean;\n wallet: Wallet;\n change: boolean;\n addressIndex: number;\n skipOpenApp: boolean;\n }): GetWalletAddressDAReturnType {\n return this._dmk.executeDeviceAction({\n sessionId: this._sessionId,\n deviceAction: new GetWalletAddressDeviceAction({\n input: {\n wallet: args.wallet,\n skipOpenApp: args.skipOpenApp,\n checkOnDevice: args.checkOnDevice,\n change: args.change,\n addressIndex: args.addressIndex,\n walletBuilder: this._walletBuilder,\n walletSerializer: this._walletSerializer,\n dataStoreService: this._dataStoreService,\n },\n loggerFactory: this._dmkLoggerFactory,\n }),\n });\n }\n\n signTransaction(args: {\n psbt: Psbt;\n wallet: Wallet;\n skipOpenApp: boolean;\n }): SignTransactionDAReturnType {\n return this._dmk.executeDeviceAction({\n sessionId: this._sessionId,\n deviceAction: new SignTransactionDeviceAction({\n input: {\n psbt: args.psbt,\n wallet: args.wallet,\n walletBuilder: this._walletBuilder,\n walletSerializer: this._walletSerializer,\n dataStoreService: this._dataStoreService,\n psbtMapper: this._psbtMapper,\n valueParser: this._valueParser,\n skipOpenApp: args.skipOpenApp,\n },\n loggerFactory: this._dmkLoggerFactory,\n }),\n });\n }\n\n registerWallet(args: RegisterWalletDAInput): RegisterWalletDAReturnType {\n return this._dmk.executeDeviceAction({\n sessionId: this._sessionId,\n deviceAction: new CallTaskInAppDeviceAction({\n input: {\n task: async (internalApi) =>\n new RegisterWalletTask(\n internalApi,\n {\n walletPolicy: args.wallet,\n loggerFactory: this._dmkLoggerFactory,\n },\n this._walletBuilder,\n this._walletSerializer,\n this._dataStoreService,\n ).run(),\n appName: APP_NAME,\n requiredUserInteraction: UserInteractionRequired.RegisterWallet,\n skipOpenApp: args.skipOpenApp,\n },\n logger: this._dmkLoggerFactory(\"RegisterWalletTask\"),\n }),\n });\n }\n}\n"],
5
+ "mappings": "iOAAA,OACE,6BAAAA,EAIA,gCAAAC,EACA,2BAAAC,MACK,kCACP,OAAS,UAAAC,EAAQ,cAAAC,MAAkB,YAoBnC,OAAS,+BAAAC,MAAmC,2DAC5C,OAAS,+BAAAC,MAAmC,2DAC5C,OAAS,wBAAAC,MAA4B,mEACrC,OAAS,+BAAAC,MAAmC,iFAC5C,OAAS,sBAAAC,MAA0B,+CACnC,OAAS,uBAAAC,MAA2B,4CACpC,OAAS,kBAAAC,MAAsB,yCAE/B,OAAS,iBAAAC,MAAqB,0BAC9B,OAAS,aAAAC,MAAiB,8BAG1B,OAAS,eAAAC,MAAmB,kCAI5B,OAAS,gCAAAC,MAAoC,gEAC7C,OAAS,YAAAC,MAAgB,cAGlB,IAAMC,EAAN,KAAmB,CACxB,YAEmBC,EAEAC,EAEAC,EAEAC,EAEAC,EAEAC,EAEAC,EAEAC,EACjB,CAfiB,UAAAP,EAEA,gBAAAC,EAEA,oBAAAC,EAEA,uBAAAC,EAEA,uBAAAC,EAEA,iBAAAC,EAEA,kBAAAC,EAEA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AAC,EAAOG,EAAe,gBAAgB,GAEtCJ,EAAA,EAAAC,EAAOI,EAAU,UAAU,GAE3BL,EAAA,EAAAC,EAAOI,EAAU,WAAW,GAE5BL,EAAA,EAAAC,EAAOC,EAAc,gBAAgB,IAhB7B1B",
6
+ "names": ["CallTaskInAppDeviceAction", "SendCommandInAppDeviceAction", "UserInteractionRequired", "inject", "injectable", "GetExtendedPublicKeyCommand", "GetMasterFingerprintCommand", "SignPsbtDeviceAction", "SignTransactionDeviceAction", "RegisterWalletTask", "SendSignMessageTask", "dataStoreTypes", "externalTypes", "psbtTypes", "walletTypes", "GetWalletAddressDeviceAction", "APP_NAME", "BtcAppBinder", "_dmk", "_sessionId", "_walletBuilder", "_walletSerializer", "_dataStoreService", "_psbtMapper", "_valueParser", "_dmkLoggerFactory", "args", "SendCommandInAppDeviceAction", "GetExtendedPublicKeyCommand", "APP_NAME", "UserInteractionRequired", "GetMasterFingerprintCommand", "CallTaskInAppDeviceAction", "internalApi", "SendSignMessageTask", "SignPsbtDeviceAction", "GetWalletAddressDeviceAction", "SignTransactionDeviceAction", "RegisterWalletTask", "__decorateClass", "injectable", "__decorateParam", "inject", "externalTypes", "walletTypes", "dataStoreTypes", "psbtTypes"]
7
7
  }
@@ -1,2 +1,2 @@
1
- import{DeviceActionStatus as l,UserInteractionRequired as m}from"@ledgerhq/device-management-kit";import{from as v}from"rxjs";import{RegisteredWallet as g,WalletPolicy as D}from"../../api/model/Wallet";import{BtcAppBinder as c}from"../app-binder/BtcAppBinder";import{GetExtendedPublicKeyCommand as A}from"../app-binder/command/GetExtendedPublicKeyCommand";import{GetMasterFingerprintCommand as b}from"../app-binder/command/GetMasterFingerprintCommand";const p=()=>({debug:vi.fn(),info:vi.fn(),warn:vi.fn(),error:vi.fn(),subscribers:[]});describe("BtcAppBinder",()=>{const t={sendCommand:vi.fn(),executeDeviceAction:vi.fn()};beforeEach(()=>{vi.clearAllMocks()}),it("should be defined",()=>{const s=new c({},{},{},{},{},{},{},p);expect(s).toBeDefined()}),describe("getExtendedPublicKey",()=>{let s;afterEach(()=>{s&&s.unsubscribe()}),it("should return the pub key",()=>new Promise((i,a)=>{const r="D2PPQSYFe83nDzk96FqGumVU8JA7J8vj2Rhjc2oXzEi5";vi.spyOn(t,"executeDeviceAction").mockReturnValue({observable:v([{status:l.Completed,output:{extendedPublicKey:r}}]),cancel:vi.fn()});const n=new c(t,"sessionId",{},{},{},{},{},p),{observable:u}=n.getExtendedPublicKey({derivationPath:"44'/501'",checkOnDevice:!1,skipOpenApp:!1}),o=[];s=u.subscribe({next:e=>{o.push(e)},error:e=>{a(e)},complete:()=>{try{expect(o).toEqual([{status:l.Completed,output:{extendedPublicKey:r}}]),i()}catch(e){a(e)}}})})),describe("calls of executeDeviceAction with the correct params",()=>{const i={derivationPath:"44'/60'/3'/2/1",returnChainCode:!1,skipOpenApp:!1};it("when checkOnDevice is true: UserInteractionRequired.VerifyAddress",()=>{const r={...i,checkOnDevice:!0};new c(t,"sessionId",{},{},{},{},{},p).getExtendedPublicKey(r),expect(t.executeDeviceAction).toHaveBeenCalledWith({sessionId:"sessionId",deviceAction:expect.objectContaining({input:{command:new A(r),appName:"Bitcoin",requiredUserInteraction:m.VerifyAddress,skipOpenApp:!1}})})}),it("when checkOnDevice is false: UserInteractionRequired.None",()=>{const r={...i,checkOnDevice:!1};new c(t,"sessionId",{},{},{},{},{},p).getExtendedPublicKey(r),expect(t.executeDeviceAction).toHaveBeenCalledWith({sessionId:"sessionId",deviceAction:expect.objectContaining({input:{command:new A(r),appName:"Bitcoin",requiredUserInteraction:m.None,skipOpenApp:!1}})})})})}),describe("getMasterFingerprint",()=>{let s;afterEach(()=>{s&&s.unsubscribe()}),it("should return the master fingerprint",()=>new Promise((i,a)=>{const r=Uint8Array.from([130,141,194,243]);vi.spyOn(t,"executeDeviceAction").mockReturnValue({observable:v([{status:l.Completed,output:{masterFingerprint:r}}]),cancel:vi.fn()});const n=new c(t,"sessionId",{},{},{},{},{},p),{observable:u}=n.getMasterFingerprint({skipOpenApp:!1}),o=[];s=u.subscribe({next:e=>{o.push(e)},error:e=>{a(e)},complete:()=>{try{expect(o).toEqual([{status:l.Completed,output:{masterFingerprint:r}}]),i()}catch(e){a(e)}}})})),it("should call executeDeviceAction with the correct params",()=>{const i={skipOpenApp:!1};new c(t,"sessionId",{},{},{},{},{},p).getMasterFingerprint(i),expect(t.executeDeviceAction).toHaveBeenCalledWith({sessionId:"sessionId",deviceAction:expect.objectContaining({input:{command:new b,appName:"Bitcoin",requiredUserInteraction:m.None,skipOpenApp:!1}})})}),it("should pass skipOpenApp option correctly",()=>{const i={skipOpenApp:!0};new c(t,"sessionId",{},{},{},{},{},p).getMasterFingerprint(i),expect(t.executeDeviceAction).toHaveBeenCalledWith({sessionId:"sessionId",deviceAction:expect.objectContaining({input:{command:new b,appName:"Bitcoin",requiredUserInteraction:m.None,skipOpenApp:!0}})})})}),describe("signMessage",()=>{it("should return the signature",()=>new Promise((s,i)=>{const a={r:"0xDEF1",s:"0xAFAF",v:0},r="Hello, World!";vi.spyOn(t,"executeDeviceAction").mockReturnValue({observable:v([{status:l.Completed,output:a}]),cancel:vi.fn()});const n=new c(t,"sessionId",{},{},{},{},{},p),{observable:u}=n.signMessage({derivationPath:"44'/60'/3'/2/1",message:r,skipOpenApp:!1}),o=[];u.subscribe({next:e=>{o.push(e)},error:e=>{i(e)},complete:()=>{try{expect(o).toEqual([{status:l.Completed,output:a}]),s()}catch(e){i(e)}}})}))}),describe("registerWallet",()=>{let s;afterEach(()=>{s&&s.unsubscribe()}),it("should return the registered wallet with hmac",()=>new Promise((i,a)=>{const r=new D("My Multisig","wsh(sortedmulti(2,@0/**,@1/**))",["[f5acc2fd/48'/1'/0'/2']tpubXXX","tpubYYY"]),n=new g(r.name,r.descriptorTemplate,r.keys,Uint8Array.from(new Array(32).fill(66)));vi.spyOn(t,"executeDeviceAction").mockReturnValue({observable:v([{status:l.Completed,output:n}]),cancel:vi.fn()});const u=new c(t,"sessionId",{},{},{},{},{},p),{observable:o}=u.registerWallet({wallet:r,skipOpenApp:!1}),e=[];s=o.subscribe({next:d=>{e.push(d)},error:d=>{a(d)},complete:()=>{try{expect(e).toEqual([{status:l.Completed,output:n}]),i()}catch(d){a(d)}}})})),it("should call executeDeviceAction",()=>{const i=new D("My Multisig","wsh(sortedmulti(2,@0/**,@1/**))",["[f5acc2fd/48'/1'/0'/2']tpubXXX","tpubYYY"]);new c(t,"sessionId",{},{},{},{},{},p).registerWallet({wallet:i,skipOpenApp:!1}),expect(t.executeDeviceAction).toHaveBeenCalled()})})});
1
+ import{DeviceActionStatus as l,UserInteractionRequired as m}from"@ledgerhq/device-management-kit";import{from as A}from"rxjs";import{RegisteredWallet as f,WalletPolicy as D}from"../../api/model/Wallet";import{BtcAppBinder as c}from"../app-binder/BtcAppBinder";import{GetExtendedPublicKeyCommand as b}from"../app-binder/command/GetExtendedPublicKeyCommand";import{GetMasterFingerprintCommand as g}from"../app-binder/command/GetMasterFingerprintCommand";import{APP_NAME as v}from"./constants";const p=()=>({debug:vi.fn(),info:vi.fn(),warn:vi.fn(),error:vi.fn(),subscribers:[]});describe("BtcAppBinder",()=>{const t={sendCommand:vi.fn(),executeDeviceAction:vi.fn()};beforeEach(()=>{vi.clearAllMocks()}),it("should be defined",()=>{const s=new c({},{},{},{},{},{},{},p);expect(s).toBeDefined()}),describe("getExtendedPublicKey",()=>{let s;afterEach(()=>{s&&s.unsubscribe()}),it("should return the pub key",()=>new Promise((i,a)=>{const r="D2PPQSYFe83nDzk96FqGumVU8JA7J8vj2Rhjc2oXzEi5";vi.spyOn(t,"executeDeviceAction").mockReturnValue({observable:A([{status:l.Completed,output:{extendedPublicKey:r}}]),cancel:vi.fn()});const n=new c(t,"sessionId",{},{},{},{},{},p),{observable:u}=n.getExtendedPublicKey({derivationPath:"44'/501'",checkOnDevice:!1,skipOpenApp:!1}),o=[];s=u.subscribe({next:e=>{o.push(e)},error:e=>{a(e)},complete:()=>{try{expect(o).toEqual([{status:l.Completed,output:{extendedPublicKey:r}}]),i()}catch(e){a(e)}}})})),describe("calls of executeDeviceAction with the correct params",()=>{const i={derivationPath:"44'/60'/3'/2/1",returnChainCode:!1,skipOpenApp:!1};it("when checkOnDevice is true: UserInteractionRequired.VerifyAddress",()=>{const r={...i,checkOnDevice:!0};new c(t,"sessionId",{},{},{},{},{},p).getExtendedPublicKey(r),expect(t.executeDeviceAction).toHaveBeenCalledWith({sessionId:"sessionId",deviceAction:expect.objectContaining({input:{command:new b(r),appName:v,requiredUserInteraction:m.VerifyAddress,skipOpenApp:!1}})})}),it("when checkOnDevice is false: UserInteractionRequired.None",()=>{const r={...i,checkOnDevice:!1};new c(t,"sessionId",{},{},{},{},{},p).getExtendedPublicKey(r),expect(t.executeDeviceAction).toHaveBeenCalledWith({sessionId:"sessionId",deviceAction:expect.objectContaining({input:{command:new b(r),appName:v,requiredUserInteraction:m.None,skipOpenApp:!1}})})})})}),describe("getMasterFingerprint",()=>{let s;afterEach(()=>{s&&s.unsubscribe()}),it("should return the master fingerprint",()=>new Promise((i,a)=>{const r=Uint8Array.from([130,141,194,243]);vi.spyOn(t,"executeDeviceAction").mockReturnValue({observable:A([{status:l.Completed,output:{masterFingerprint:r}}]),cancel:vi.fn()});const n=new c(t,"sessionId",{},{},{},{},{},p),{observable:u}=n.getMasterFingerprint({skipOpenApp:!1}),o=[];s=u.subscribe({next:e=>{o.push(e)},error:e=>{a(e)},complete:()=>{try{expect(o).toEqual([{status:l.Completed,output:{masterFingerprint:r}}]),i()}catch(e){a(e)}}})})),it("should call executeDeviceAction with the correct params",()=>{const i={skipOpenApp:!1};new c(t,"sessionId",{},{},{},{},{},p).getMasterFingerprint(i),expect(t.executeDeviceAction).toHaveBeenCalledWith({sessionId:"sessionId",deviceAction:expect.objectContaining({input:{command:new g,appName:v,requiredUserInteraction:m.None,skipOpenApp:!1}})})}),it("should pass skipOpenApp option correctly",()=>{const i={skipOpenApp:!0};new c(t,"sessionId",{},{},{},{},{},p).getMasterFingerprint(i),expect(t.executeDeviceAction).toHaveBeenCalledWith({sessionId:"sessionId",deviceAction:expect.objectContaining({input:{command:new g,appName:v,requiredUserInteraction:m.None,skipOpenApp:!0}})})})}),describe("signMessage",()=>{it("should return the signature",()=>new Promise((s,i)=>{const a={r:"0xDEF1",s:"0xAFAF",v:0},r="Hello, World!";vi.spyOn(t,"executeDeviceAction").mockReturnValue({observable:A([{status:l.Completed,output:a}]),cancel:vi.fn()});const n=new c(t,"sessionId",{},{},{},{},{},p),{observable:u}=n.signMessage({derivationPath:"44'/60'/3'/2/1",message:r,skipOpenApp:!1}),o=[];u.subscribe({next:e=>{o.push(e)},error:e=>{i(e)},complete:()=>{try{expect(o).toEqual([{status:l.Completed,output:a}]),s()}catch(e){i(e)}}})}))}),describe("registerWallet",()=>{let s;afterEach(()=>{s&&s.unsubscribe()}),it("should return the registered wallet with hmac",()=>new Promise((i,a)=>{const r=new D("My Multisig","wsh(sortedmulti(2,@0/**,@1/**))",["[f5acc2fd/48'/1'/0'/2']tpubXXX","tpubYYY"]),n=new f(r.name,r.descriptorTemplate,r.keys,Uint8Array.from(new Array(32).fill(66)));vi.spyOn(t,"executeDeviceAction").mockReturnValue({observable:A([{status:l.Completed,output:n}]),cancel:vi.fn()});const u=new c(t,"sessionId",{},{},{},{},{},p),{observable:o}=u.registerWallet({wallet:r,skipOpenApp:!1}),e=[];s=o.subscribe({next:d=>{e.push(d)},error:d=>{a(d)},complete:()=>{try{expect(e).toEqual([{status:l.Completed,output:n}]),i()}catch(d){a(d)}}})})),it("should call executeDeviceAction",()=>{const i=new D("My Multisig","wsh(sortedmulti(2,@0/**,@1/**))",["[f5acc2fd/48'/1'/0'/2']tpubXXX","tpubYYY"]);new c(t,"sessionId",{},{},{},{},{},p).registerWallet({wallet:i,skipOpenApp:!1}),expect(t.executeDeviceAction).toHaveBeenCalled()})})});
2
2
  //# sourceMappingURL=BtcAppBinder.test.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/internal/app-binder/BtcAppBinder.test.ts"],
4
- "sourcesContent": ["import {\n type DeviceActionState,\n DeviceActionStatus,\n type DeviceManagementKit,\n type DeviceSessionId,\n UserInteractionRequired,\n} from \"@ledgerhq/device-management-kit\";\nimport { from, type Subscription } from \"rxjs\";\n\nimport {\n type GetExtendedDAIntermediateValue,\n type GetExtendedPublicKeyDAError,\n type GetExtendedPublicKeyDAOutput,\n} from \"@api/app-binder/GetExtendedPublicKeyDeviceActionTypes\";\nimport {\n type GetMasterFingerprintDAError,\n type GetMasterFingerprintDAIntermediateValue,\n type GetMasterFingerprintDAOutput,\n} from \"@api/app-binder/GetMasterFingerprintDeviceActionTypes\";\nimport {\n type RegisterWalletDAError,\n type RegisterWalletDAIntermediateValue,\n type RegisterWalletDAOutput,\n} from \"@api/app-binder/RegisterWalletDeviceActionTypes\";\nimport {\n type SignMessageDAError,\n type SignMessageDAIntermediateValue,\n type SignMessageDAOutput,\n} from \"@api/index\";\nimport { type Signature } from \"@api/model/Signature\";\nimport { RegisteredWallet, WalletPolicy } from \"@api/model/Wallet\";\nimport { BtcAppBinder } from \"@internal/app-binder/BtcAppBinder\";\nimport { GetExtendedPublicKeyCommand } from \"@internal/app-binder/command/GetExtendedPublicKeyCommand\";\nimport { GetMasterFingerprintCommand } from \"@internal/app-binder/command/GetMasterFingerprintCommand\";\nimport { type DataStoreService } from \"@internal/data-store/service/DataStoreService\";\nimport { type PsbtMapper } from \"@internal/psbt/service/psbt/PsbtMapper\";\nimport { type ValueParser } from \"@internal/psbt/service/value/ValueParser\";\nimport { type WalletBuilder } from \"@internal/wallet/service/WalletBuilder\";\nimport { type WalletSerializer } from \"@internal/wallet/service/WalletSerializer\";\n\nconst mockLoggerFactory = () => ({\n debug: vi.fn(),\n info: vi.fn(),\n warn: vi.fn(),\n error: vi.fn(),\n subscribers: [],\n});\n\ndescribe(\"BtcAppBinder\", () => {\n const mockedDmk: DeviceManagementKit = {\n sendCommand: vi.fn(),\n executeDeviceAction: vi.fn(),\n } as unknown as DeviceManagementKit;\n\n beforeEach(() => {\n vi.clearAllMocks();\n });\n\n it(\"should be defined\", () => {\n const binder = new BtcAppBinder(\n {} as DeviceManagementKit,\n {} as DeviceSessionId,\n {} as WalletBuilder,\n {} as WalletSerializer,\n {} as DataStoreService,\n {} as PsbtMapper,\n {} as ValueParser,\n mockLoggerFactory,\n );\n expect(binder).toBeDefined();\n });\n\n describe(\"getExtendedPublicKey\", () => {\n let subscription: Subscription;\n afterEach(() => {\n if (subscription) {\n subscription.unsubscribe();\n }\n });\n it(\"should return the pub key\", () =>\n new Promise<void>((resolve, reject) => {\n // GIVEN\n const extendedPublicKey =\n \"D2PPQSYFe83nDzk96FqGumVU8JA7J8vj2Rhjc2oXzEi5\";\n\n vi.spyOn(mockedDmk, \"executeDeviceAction\").mockReturnValue({\n observable: from([\n {\n status: DeviceActionStatus.Completed,\n output: { extendedPublicKey },\n } as DeviceActionState<\n GetExtendedPublicKeyDAOutput,\n GetExtendedPublicKeyDAError,\n GetExtendedDAIntermediateValue\n >,\n ]),\n cancel: vi.fn(),\n });\n\n // WHEN\n const appBinder = new BtcAppBinder(\n mockedDmk,\n \"sessionId\",\n {} as WalletBuilder,\n {} as WalletSerializer,\n {} as DataStoreService,\n {} as PsbtMapper,\n {} as ValueParser,\n mockLoggerFactory,\n );\n const { observable } = appBinder.getExtendedPublicKey({\n derivationPath: \"44'/501'\",\n checkOnDevice: false,\n skipOpenApp: false,\n });\n\n // THEN\n const states: DeviceActionState<\n GetExtendedPublicKeyDAOutput,\n GetExtendedPublicKeyDAError,\n GetExtendedDAIntermediateValue\n >[] = [];\n subscription = observable.subscribe({\n next: (state) => {\n states.push(state);\n },\n error: (err) => {\n reject(err);\n },\n complete: () => {\n try {\n expect(states).toEqual([\n {\n status: DeviceActionStatus.Completed,\n output: { extendedPublicKey },\n },\n ]);\n resolve();\n } catch (err) {\n reject(err as Error);\n }\n },\n });\n }));\n\n describe(\"calls of executeDeviceAction with the correct params\", () => {\n const baseParams = {\n derivationPath: \"44'/60'/3'/2/1\",\n returnChainCode: false,\n skipOpenApp: false,\n };\n\n it(\"when checkOnDevice is true: UserInteractionRequired.VerifyAddress\", () => {\n // GIVEN\n const checkOnDevice = true;\n const params = {\n ...baseParams,\n checkOnDevice,\n };\n\n // WHEN\n const appBinder = new BtcAppBinder(\n mockedDmk,\n \"sessionId\",\n {} as WalletBuilder,\n {} as WalletSerializer,\n {} as DataStoreService,\n {} as PsbtMapper,\n {} as ValueParser,\n mockLoggerFactory,\n );\n appBinder.getExtendedPublicKey(params);\n\n // THEN\n expect(mockedDmk.executeDeviceAction).toHaveBeenCalledWith({\n sessionId: \"sessionId\",\n deviceAction: expect.objectContaining({\n input: {\n command: new GetExtendedPublicKeyCommand(params),\n appName: \"Bitcoin\",\n requiredUserInteraction: UserInteractionRequired.VerifyAddress,\n skipOpenApp: false,\n },\n }),\n });\n });\n\n it(\"when checkOnDevice is false: UserInteractionRequired.None\", () => {\n // GIVEN\n const checkOnDevice = false;\n const params = {\n ...baseParams,\n checkOnDevice,\n };\n\n // WHEN\n const appBinder = new BtcAppBinder(\n mockedDmk,\n \"sessionId\",\n {} as WalletBuilder,\n {} as WalletSerializer,\n {} as DataStoreService,\n {} as PsbtMapper,\n {} as ValueParser,\n mockLoggerFactory,\n );\n appBinder.getExtendedPublicKey(params);\n\n // THEN\n expect(mockedDmk.executeDeviceAction).toHaveBeenCalledWith({\n sessionId: \"sessionId\",\n deviceAction: expect.objectContaining({\n input: {\n command: new GetExtendedPublicKeyCommand(params),\n appName: \"Bitcoin\",\n requiredUserInteraction: UserInteractionRequired.None,\n skipOpenApp: false,\n },\n }),\n });\n });\n });\n });\n\n describe(\"getMasterFingerprint\", () => {\n let subscription: Subscription;\n afterEach(() => {\n if (subscription) {\n subscription.unsubscribe();\n }\n });\n\n it(\"should return the master fingerprint\", () =>\n new Promise<void>((resolve, reject) => {\n // GIVEN\n const masterFingerprint = Uint8Array.from([0x82, 0x8d, 0xc2, 0xf3]);\n\n vi.spyOn(mockedDmk, \"executeDeviceAction\").mockReturnValue({\n observable: from([\n {\n status: DeviceActionStatus.Completed,\n output: { masterFingerprint },\n } as DeviceActionState<\n GetMasterFingerprintDAOutput,\n GetMasterFingerprintDAError,\n GetMasterFingerprintDAIntermediateValue\n >,\n ]),\n cancel: vi.fn(),\n });\n\n // WHEN\n const appBinder = new BtcAppBinder(\n mockedDmk,\n \"sessionId\",\n {} as WalletBuilder,\n {} as WalletSerializer,\n {} as DataStoreService,\n {} as PsbtMapper,\n {} as ValueParser,\n mockLoggerFactory,\n );\n const { observable } = appBinder.getMasterFingerprint({\n skipOpenApp: false,\n });\n\n // THEN\n const states: DeviceActionState<\n GetMasterFingerprintDAOutput,\n GetMasterFingerprintDAError,\n GetMasterFingerprintDAIntermediateValue\n >[] = [];\n subscription = observable.subscribe({\n next: (state) => {\n states.push(state);\n },\n error: (err) => {\n reject(err);\n },\n complete: () => {\n try {\n expect(states).toEqual([\n {\n status: DeviceActionStatus.Completed,\n output: { masterFingerprint },\n },\n ]);\n resolve();\n } catch (err) {\n reject(err as Error);\n }\n },\n });\n }));\n\n it(\"should call executeDeviceAction with the correct params\", () => {\n // GIVEN\n const params = {\n skipOpenApp: false,\n };\n\n // WHEN\n const appBinder = new BtcAppBinder(\n mockedDmk,\n \"sessionId\",\n {} as WalletBuilder,\n {} as WalletSerializer,\n {} as DataStoreService,\n {} as PsbtMapper,\n {} as ValueParser,\n mockLoggerFactory,\n );\n appBinder.getMasterFingerprint(params);\n\n // THEN\n expect(mockedDmk.executeDeviceAction).toHaveBeenCalledWith({\n sessionId: \"sessionId\",\n deviceAction: expect.objectContaining({\n input: {\n command: new GetMasterFingerprintCommand(),\n appName: \"Bitcoin\",\n requiredUserInteraction: UserInteractionRequired.None,\n skipOpenApp: false,\n },\n }),\n });\n });\n\n it(\"should pass skipOpenApp option correctly\", () => {\n // GIVEN\n const params = {\n skipOpenApp: true,\n };\n\n // WHEN\n const appBinder = new BtcAppBinder(\n mockedDmk,\n \"sessionId\",\n {} as WalletBuilder,\n {} as WalletSerializer,\n {} as DataStoreService,\n {} as PsbtMapper,\n {} as ValueParser,\n mockLoggerFactory,\n );\n appBinder.getMasterFingerprint(params);\n\n // THEN\n expect(mockedDmk.executeDeviceAction).toHaveBeenCalledWith({\n sessionId: \"sessionId\",\n deviceAction: expect.objectContaining({\n input: {\n command: new GetMasterFingerprintCommand(),\n appName: \"Bitcoin\",\n requiredUserInteraction: UserInteractionRequired.None,\n skipOpenApp: true,\n },\n }),\n });\n });\n });\n\n describe(\"signMessage\", () => {\n it(\"should return the signature\", () =>\n new Promise<void>((resolve, reject) => {\n // GIVEN\n const signature: Signature = {\n r: `0xDEF1`,\n s: `0xAFAF`,\n v: 0,\n };\n const message = \"Hello, World!\";\n\n vi.spyOn(mockedDmk, \"executeDeviceAction\").mockReturnValue({\n observable: from([\n {\n status: DeviceActionStatus.Completed,\n output: signature,\n } as DeviceActionState<\n SignMessageDAOutput,\n SignMessageDAError,\n SignMessageDAIntermediateValue\n >,\n ]),\n cancel: vi.fn(),\n });\n\n // WHEN\n const appBinder = new BtcAppBinder(\n mockedDmk,\n \"sessionId\",\n {} as WalletBuilder,\n {} as WalletSerializer,\n {} as DataStoreService,\n {} as PsbtMapper,\n {} as ValueParser,\n mockLoggerFactory,\n );\n const { observable } = appBinder.signMessage({\n derivationPath: \"44'/60'/3'/2/1\",\n message,\n skipOpenApp: false,\n });\n\n // THEN\n const states: DeviceActionState<\n SignMessageDAOutput,\n SignMessageDAError,\n SignMessageDAIntermediateValue\n >[] = [];\n observable.subscribe({\n next: (state) => {\n states.push(state);\n },\n error: (err) => {\n reject(err);\n },\n complete: () => {\n try {\n expect(states).toEqual([\n {\n status: DeviceActionStatus.Completed,\n output: signature,\n },\n ]);\n resolve();\n } catch (err) {\n reject(err as Error);\n }\n },\n });\n }));\n });\n\n describe(\"registerWallet\", () => {\n let subscription: Subscription;\n afterEach(() => {\n if (subscription) {\n subscription.unsubscribe();\n }\n });\n\n it(\"should return the registered wallet with hmac\", () =>\n new Promise<void>((resolve, reject) => {\n // GIVEN\n const walletPolicy = new WalletPolicy(\n \"My Multisig\",\n \"wsh(sortedmulti(2,@0/**,@1/**))\",\n [\"[f5acc2fd/48'/1'/0'/2']tpubXXX\", \"tpubYYY\"],\n );\n const registeredWallet = new RegisteredWallet(\n walletPolicy.name,\n walletPolicy.descriptorTemplate,\n walletPolicy.keys,\n Uint8Array.from(new Array(32).fill(0x42)),\n );\n\n vi.spyOn(mockedDmk, \"executeDeviceAction\").mockReturnValue({\n observable: from([\n {\n status: DeviceActionStatus.Completed,\n output: registeredWallet,\n } as DeviceActionState<\n RegisterWalletDAOutput,\n RegisterWalletDAError,\n RegisterWalletDAIntermediateValue\n >,\n ]),\n cancel: vi.fn(),\n });\n\n // WHEN\n const appBinder = new BtcAppBinder(\n mockedDmk,\n \"sessionId\",\n {} as WalletBuilder,\n {} as WalletSerializer,\n {} as DataStoreService,\n {} as PsbtMapper,\n {} as ValueParser,\n mockLoggerFactory,\n );\n const { observable } = appBinder.registerWallet({\n wallet: walletPolicy,\n skipOpenApp: false,\n });\n\n // THEN\n const states: DeviceActionState<\n RegisterWalletDAOutput,\n RegisterWalletDAError,\n RegisterWalletDAIntermediateValue\n >[] = [];\n subscription = observable.subscribe({\n next: (state) => {\n states.push(state);\n },\n error: (err) => {\n reject(err);\n },\n complete: () => {\n try {\n expect(states).toEqual([\n {\n status: DeviceActionStatus.Completed,\n output: registeredWallet,\n },\n ]);\n resolve();\n } catch (err) {\n reject(err as Error);\n }\n },\n });\n }));\n\n it(\"should call executeDeviceAction\", () => {\n // GIVEN\n const walletPolicy = new WalletPolicy(\n \"My Multisig\",\n \"wsh(sortedmulti(2,@0/**,@1/**))\",\n [\"[f5acc2fd/48'/1'/0'/2']tpubXXX\", \"tpubYYY\"],\n );\n\n // WHEN\n const appBinder = new BtcAppBinder(\n mockedDmk,\n \"sessionId\",\n {} as WalletBuilder,\n {} as WalletSerializer,\n {} as DataStoreService,\n {} as PsbtMapper,\n {} as ValueParser,\n mockLoggerFactory,\n );\n appBinder.registerWallet({\n wallet: walletPolicy,\n skipOpenApp: false,\n });\n\n // THEN\n expect(mockedDmk.executeDeviceAction).toHaveBeenCalled();\n });\n });\n});\n"],
5
- "mappings": "AAAA,OAEE,sBAAAA,EAGA,2BAAAC,MACK,kCACP,OAAS,QAAAC,MAA+B,OAuBxC,OAAS,oBAAAC,EAAkB,gBAAAC,MAAoB,oBAC/C,OAAS,gBAAAC,MAAoB,oCAC7B,OAAS,+BAAAC,MAAmC,2DAC5C,OAAS,+BAAAC,MAAmC,2DAO5C,MAAMC,EAAoB,KAAO,CAC/B,MAAO,GAAG,GAAG,EACb,KAAM,GAAG,GAAG,EACZ,KAAM,GAAG,GAAG,EACZ,MAAO,GAAG,GAAG,EACb,YAAa,CAAC,CAChB,GAEA,SAAS,eAAgB,IAAM,CAC7B,MAAMC,EAAiC,CACrC,YAAa,GAAG,GAAG,EACnB,oBAAqB,GAAG,GAAG,CAC7B,EAEA,WAAW,IAAM,CACf,GAAG,cAAc,CACnB,CAAC,EAED,GAAG,oBAAqB,IAAM,CAC5B,MAAMC,EAAS,IAAIL,EACjB,CAAC,EACD,CAAC,EACD,CAAC,EACD,CAAC,EACD,CAAC,EACD,CAAC,EACD,CAAC,EACDG,CACF,EACA,OAAOE,CAAM,EAAE,YAAY,CAC7B,CAAC,EAED,SAAS,uBAAwB,IAAM,CACrC,IAAIC,EACJ,UAAU,IAAM,CACVA,GACFA,EAAa,YAAY,CAE7B,CAAC,EACD,GAAG,4BAA6B,IAC9B,IAAI,QAAc,CAACC,EAASC,IAAW,CAErC,MAAMC,EACJ,+CAEF,GAAG,MAAML,EAAW,qBAAqB,EAAE,gBAAgB,CACzD,WAAYP,EAAK,CACf,CACE,OAAQF,EAAmB,UAC3B,OAAQ,CAAE,kBAAAc,CAAkB,CAC9B,CAKF,CAAC,EACD,OAAQ,GAAG,GAAG,CAChB,CAAC,EAGD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AmB,UAC3B,OAAQ0B,CACV,CACF,CAAC,EACDd,EAAQ,CACV,OAASO,EAAK,CACZN,EAAOM,CAAY,CACrB,CACF,CACF,CAAC,CACH,CAAC,CAAC,EAEJ,GAAG,kCAAmC,IAAM,CAE1C,MAAMM,EAAe,IAAIrB,EACvB,cACA,kCACA,CAAC,iCAAkC,SAAS,CAC9C,EAGkB,IAAIC,EACpBI,EACA,YACA,CAAC,EACD,CAAC,EACD,CAAC,EACD,CAAC,EACD,CAAC,EACDD,CACF,EACU,eAAe,CACvB,OAAQiB,EACR,YAAa,EACf,CAAC,EAGD,OAAOhB,EAAU,mBAAmB,EAAE,iBAAiB,CACzD,CAAC,CACH,CAAC,CACH,CAAC",
6
- "names": ["DeviceActionStatus", "UserInteractionRequired", "from", "RegisteredWallet", "WalletPolicy", "BtcAppBinder", "GetExtendedPublicKeyCommand", "GetMasterFingerprintCommand", "mockLoggerFactory", "mockedDmk", "binder", "subscription", "resolve", "reject", "extendedPublicKey", "appBinder", "observable", "states", "state", "err", "baseParams", "params", "masterFingerprint", "signature", "message", "walletPolicy", "registeredWallet"]
4
+ "sourcesContent": ["import {\n type DeviceActionState,\n DeviceActionStatus,\n type DeviceManagementKit,\n type DeviceSessionId,\n UserInteractionRequired,\n} from \"@ledgerhq/device-management-kit\";\nimport { from, type Subscription } from \"rxjs\";\n\nimport {\n type GetExtendedDAIntermediateValue,\n type GetExtendedPublicKeyDAError,\n type GetExtendedPublicKeyDAOutput,\n} from \"@api/app-binder/GetExtendedPublicKeyDeviceActionTypes\";\nimport {\n type GetMasterFingerprintDAError,\n type GetMasterFingerprintDAIntermediateValue,\n type GetMasterFingerprintDAOutput,\n} from \"@api/app-binder/GetMasterFingerprintDeviceActionTypes\";\nimport {\n type RegisterWalletDAError,\n type RegisterWalletDAIntermediateValue,\n type RegisterWalletDAOutput,\n} from \"@api/app-binder/RegisterWalletDeviceActionTypes\";\nimport {\n type SignMessageDAError,\n type SignMessageDAIntermediateValue,\n type SignMessageDAOutput,\n} from \"@api/index\";\nimport { type Signature } from \"@api/model/Signature\";\nimport { RegisteredWallet, WalletPolicy } from \"@api/model/Wallet\";\nimport { BtcAppBinder } from \"@internal/app-binder/BtcAppBinder\";\nimport { GetExtendedPublicKeyCommand } from \"@internal/app-binder/command/GetExtendedPublicKeyCommand\";\nimport { GetMasterFingerprintCommand } from \"@internal/app-binder/command/GetMasterFingerprintCommand\";\nimport { type DataStoreService } from \"@internal/data-store/service/DataStoreService\";\nimport { type PsbtMapper } from \"@internal/psbt/service/psbt/PsbtMapper\";\nimport { type ValueParser } from \"@internal/psbt/service/value/ValueParser\";\nimport { type WalletBuilder } from \"@internal/wallet/service/WalletBuilder\";\nimport { type WalletSerializer } from \"@internal/wallet/service/WalletSerializer\";\n\nimport { APP_NAME } from \"./constants\";\n\nconst mockLoggerFactory = () => ({\n debug: vi.fn(),\n info: vi.fn(),\n warn: vi.fn(),\n error: vi.fn(),\n subscribers: [],\n});\n\ndescribe(\"BtcAppBinder\", () => {\n const mockedDmk: DeviceManagementKit = {\n sendCommand: vi.fn(),\n executeDeviceAction: vi.fn(),\n } as unknown as DeviceManagementKit;\n\n beforeEach(() => {\n vi.clearAllMocks();\n });\n\n it(\"should be defined\", () => {\n const binder = new BtcAppBinder(\n {} as DeviceManagementKit,\n {} as DeviceSessionId,\n {} as WalletBuilder,\n {} as WalletSerializer,\n {} as DataStoreService,\n {} as PsbtMapper,\n {} as ValueParser,\n mockLoggerFactory,\n );\n expect(binder).toBeDefined();\n });\n\n describe(\"getExtendedPublicKey\", () => {\n let subscription: Subscription;\n afterEach(() => {\n if (subscription) {\n subscription.unsubscribe();\n }\n });\n it(\"should return the pub key\", () =>\n new Promise<void>((resolve, reject) => {\n // GIVEN\n const extendedPublicKey =\n \"D2PPQSYFe83nDzk96FqGumVU8JA7J8vj2Rhjc2oXzEi5\";\n\n vi.spyOn(mockedDmk, \"executeDeviceAction\").mockReturnValue({\n observable: from([\n {\n status: DeviceActionStatus.Completed,\n output: { extendedPublicKey },\n } as DeviceActionState<\n GetExtendedPublicKeyDAOutput,\n GetExtendedPublicKeyDAError,\n GetExtendedDAIntermediateValue\n >,\n ]),\n cancel: vi.fn(),\n });\n\n // WHEN\n const appBinder = new BtcAppBinder(\n mockedDmk,\n \"sessionId\",\n {} as WalletBuilder,\n {} as WalletSerializer,\n {} as DataStoreService,\n {} as PsbtMapper,\n {} as ValueParser,\n mockLoggerFactory,\n );\n const { observable } = appBinder.getExtendedPublicKey({\n derivationPath: \"44'/501'\",\n checkOnDevice: false,\n skipOpenApp: false,\n });\n\n // THEN\n const states: DeviceActionState<\n GetExtendedPublicKeyDAOutput,\n GetExtendedPublicKeyDAError,\n GetExtendedDAIntermediateValue\n >[] = [];\n subscription = observable.subscribe({\n next: (state) => {\n states.push(state);\n },\n error: (err) => {\n reject(err);\n },\n complete: () => {\n try {\n expect(states).toEqual([\n {\n status: DeviceActionStatus.Completed,\n output: { extendedPublicKey },\n },\n ]);\n resolve();\n } catch (err) {\n reject(err as Error);\n }\n },\n });\n }));\n\n describe(\"calls of executeDeviceAction with the correct params\", () => {\n const baseParams = {\n derivationPath: \"44'/60'/3'/2/1\",\n returnChainCode: false,\n skipOpenApp: false,\n };\n\n it(\"when checkOnDevice is true: UserInteractionRequired.VerifyAddress\", () => {\n // GIVEN\n const checkOnDevice = true;\n const params = {\n ...baseParams,\n checkOnDevice,\n };\n\n // WHEN\n const appBinder = new BtcAppBinder(\n mockedDmk,\n \"sessionId\",\n {} as WalletBuilder,\n {} as WalletSerializer,\n {} as DataStoreService,\n {} as PsbtMapper,\n {} as ValueParser,\n mockLoggerFactory,\n );\n appBinder.getExtendedPublicKey(params);\n\n // THEN\n expect(mockedDmk.executeDeviceAction).toHaveBeenCalledWith({\n sessionId: \"sessionId\",\n deviceAction: expect.objectContaining({\n input: {\n command: new GetExtendedPublicKeyCommand(params),\n appName: APP_NAME,\n requiredUserInteraction: UserInteractionRequired.VerifyAddress,\n skipOpenApp: false,\n },\n }),\n });\n });\n\n it(\"when checkOnDevice is false: UserInteractionRequired.None\", () => {\n // GIVEN\n const checkOnDevice = false;\n const params = {\n ...baseParams,\n checkOnDevice,\n };\n\n // WHEN\n const appBinder = new BtcAppBinder(\n mockedDmk,\n \"sessionId\",\n {} as WalletBuilder,\n {} as WalletSerializer,\n {} as DataStoreService,\n {} as PsbtMapper,\n {} as ValueParser,\n mockLoggerFactory,\n );\n appBinder.getExtendedPublicKey(params);\n\n // THEN\n expect(mockedDmk.executeDeviceAction).toHaveBeenCalledWith({\n sessionId: \"sessionId\",\n deviceAction: expect.objectContaining({\n input: {\n command: new GetExtendedPublicKeyCommand(params),\n appName: APP_NAME,\n requiredUserInteraction: UserInteractionRequired.None,\n skipOpenApp: false,\n },\n }),\n });\n });\n });\n });\n\n describe(\"getMasterFingerprint\", () => {\n let subscription: Subscription;\n afterEach(() => {\n if (subscription) {\n subscription.unsubscribe();\n }\n });\n\n it(\"should return the master fingerprint\", () =>\n new Promise<void>((resolve, reject) => {\n // GIVEN\n const masterFingerprint = Uint8Array.from([0x82, 0x8d, 0xc2, 0xf3]);\n\n vi.spyOn(mockedDmk, \"executeDeviceAction\").mockReturnValue({\n observable: from([\n {\n status: DeviceActionStatus.Completed,\n output: { masterFingerprint },\n } as DeviceActionState<\n GetMasterFingerprintDAOutput,\n GetMasterFingerprintDAError,\n GetMasterFingerprintDAIntermediateValue\n >,\n ]),\n cancel: vi.fn(),\n });\n\n // WHEN\n const appBinder = new BtcAppBinder(\n mockedDmk,\n \"sessionId\",\n {} as WalletBuilder,\n {} as WalletSerializer,\n {} as DataStoreService,\n {} as PsbtMapper,\n {} as ValueParser,\n mockLoggerFactory,\n );\n const { observable } = appBinder.getMasterFingerprint({\n skipOpenApp: false,\n });\n\n // THEN\n const states: DeviceActionState<\n GetMasterFingerprintDAOutput,\n GetMasterFingerprintDAError,\n GetMasterFingerprintDAIntermediateValue\n >[] = [];\n subscription = observable.subscribe({\n next: (state) => {\n states.push(state);\n },\n error: (err) => {\n reject(err);\n },\n complete: () => {\n try {\n expect(states).toEqual([\n {\n status: DeviceActionStatus.Completed,\n output: { masterFingerprint },\n },\n ]);\n resolve();\n } catch (err) {\n reject(err as Error);\n }\n },\n });\n }));\n\n it(\"should call executeDeviceAction with the correct params\", () => {\n // GIVEN\n const params = {\n skipOpenApp: false,\n };\n\n // WHEN\n const appBinder = new BtcAppBinder(\n mockedDmk,\n \"sessionId\",\n {} as WalletBuilder,\n {} as WalletSerializer,\n {} as DataStoreService,\n {} as PsbtMapper,\n {} as ValueParser,\n mockLoggerFactory,\n );\n appBinder.getMasterFingerprint(params);\n\n // THEN\n expect(mockedDmk.executeDeviceAction).toHaveBeenCalledWith({\n sessionId: \"sessionId\",\n deviceAction: expect.objectContaining({\n input: {\n command: new GetMasterFingerprintCommand(),\n appName: APP_NAME,\n requiredUserInteraction: UserInteractionRequired.None,\n skipOpenApp: false,\n },\n }),\n });\n });\n\n it(\"should pass skipOpenApp option correctly\", () => {\n // GIVEN\n const params = {\n skipOpenApp: true,\n };\n\n // WHEN\n const appBinder = new BtcAppBinder(\n mockedDmk,\n \"sessionId\",\n {} as WalletBuilder,\n {} as WalletSerializer,\n {} as DataStoreService,\n {} as PsbtMapper,\n {} as ValueParser,\n mockLoggerFactory,\n );\n appBinder.getMasterFingerprint(params);\n\n // THEN\n expect(mockedDmk.executeDeviceAction).toHaveBeenCalledWith({\n sessionId: \"sessionId\",\n deviceAction: expect.objectContaining({\n input: {\n command: new GetMasterFingerprintCommand(),\n appName: APP_NAME,\n requiredUserInteraction: UserInteractionRequired.None,\n skipOpenApp: true,\n },\n }),\n });\n });\n });\n\n describe(\"signMessage\", () => {\n it(\"should return the signature\", () =>\n new Promise<void>((resolve, reject) => {\n // GIVEN\n const signature: Signature = {\n r: `0xDEF1`,\n s: `0xAFAF`,\n v: 0,\n };\n const message = \"Hello, World!\";\n\n vi.spyOn(mockedDmk, \"executeDeviceAction\").mockReturnValue({\n observable: from([\n {\n status: DeviceActionStatus.Completed,\n output: signature,\n } as DeviceActionState<\n SignMessageDAOutput,\n SignMessageDAError,\n SignMessageDAIntermediateValue\n >,\n ]),\n cancel: vi.fn(),\n });\n\n // WHEN\n const appBinder = new BtcAppBinder(\n mockedDmk,\n \"sessionId\",\n {} as WalletBuilder,\n {} as WalletSerializer,\n {} as DataStoreService,\n {} as PsbtMapper,\n {} as ValueParser,\n mockLoggerFactory,\n );\n const { observable } = appBinder.signMessage({\n derivationPath: \"44'/60'/3'/2/1\",\n message,\n skipOpenApp: false,\n });\n\n // THEN\n const states: DeviceActionState<\n SignMessageDAOutput,\n SignMessageDAError,\n SignMessageDAIntermediateValue\n >[] = [];\n observable.subscribe({\n next: (state) => {\n states.push(state);\n },\n error: (err) => {\n reject(err);\n },\n complete: () => {\n try {\n expect(states).toEqual([\n {\n status: DeviceActionStatus.Completed,\n output: signature,\n },\n ]);\n resolve();\n } catch (err) {\n reject(err as Error);\n }\n },\n });\n }));\n });\n\n describe(\"registerWallet\", () => {\n let subscription: Subscription;\n afterEach(() => {\n if (subscription) {\n subscription.unsubscribe();\n }\n });\n\n it(\"should return the registered wallet with hmac\", () =>\n new Promise<void>((resolve, reject) => {\n // GIVEN\n const walletPolicy = new WalletPolicy(\n \"My Multisig\",\n \"wsh(sortedmulti(2,@0/**,@1/**))\",\n [\"[f5acc2fd/48'/1'/0'/2']tpubXXX\", \"tpubYYY\"],\n );\n const registeredWallet = new RegisteredWallet(\n walletPolicy.name,\n walletPolicy.descriptorTemplate,\n walletPolicy.keys,\n Uint8Array.from(new Array(32).fill(0x42)),\n );\n\n vi.spyOn(mockedDmk, \"executeDeviceAction\").mockReturnValue({\n observable: from([\n {\n status: DeviceActionStatus.Completed,\n output: registeredWallet,\n } as DeviceActionState<\n RegisterWalletDAOutput,\n RegisterWalletDAError,\n RegisterWalletDAIntermediateValue\n >,\n ]),\n cancel: vi.fn(),\n });\n\n // WHEN\n const appBinder = new BtcAppBinder(\n mockedDmk,\n \"sessionId\",\n {} as WalletBuilder,\n {} as WalletSerializer,\n {} as DataStoreService,\n {} as PsbtMapper,\n {} as ValueParser,\n mockLoggerFactory,\n );\n const { observable } = appBinder.registerWallet({\n wallet: walletPolicy,\n skipOpenApp: false,\n });\n\n // THEN\n const states: DeviceActionState<\n RegisterWalletDAOutput,\n RegisterWalletDAError,\n RegisterWalletDAIntermediateValue\n >[] = [];\n subscription = observable.subscribe({\n next: (state) => {\n states.push(state);\n },\n error: (err) => {\n reject(err);\n },\n complete: () => {\n try {\n expect(states).toEqual([\n {\n status: DeviceActionStatus.Completed,\n output: registeredWallet,\n },\n ]);\n resolve();\n } catch (err) {\n reject(err as Error);\n }\n },\n });\n }));\n\n it(\"should call executeDeviceAction\", () => {\n // GIVEN\n const walletPolicy = new WalletPolicy(\n \"My Multisig\",\n \"wsh(sortedmulti(2,@0/**,@1/**))\",\n [\"[f5acc2fd/48'/1'/0'/2']tpubXXX\", \"tpubYYY\"],\n );\n\n // WHEN\n const appBinder = new BtcAppBinder(\n mockedDmk,\n \"sessionId\",\n {} as WalletBuilder,\n {} as WalletSerializer,\n {} as DataStoreService,\n {} as PsbtMapper,\n {} as ValueParser,\n mockLoggerFactory,\n );\n appBinder.registerWallet({\n wallet: walletPolicy,\n skipOpenApp: false,\n });\n\n // THEN\n expect(mockedDmk.executeDeviceAction).toHaveBeenCalled();\n });\n });\n});\n"],
5
+ "mappings": "AAAA,OAEE,sBAAAA,EAGA,2BAAAC,MACK,kCACP,OAAS,QAAAC,MAA+B,OAuBxC,OAAS,oBAAAC,EAAkB,gBAAAC,MAAoB,oBAC/C,OAAS,gBAAAC,MAAoB,oCAC7B,OAAS,+BAAAC,MAAmC,2DAC5C,OAAS,+BAAAC,MAAmC,2DAO5C,OAAS,YAAAC,MAAgB,cAEzB,MAAMC,EAAoB,KAAO,CAC/B,MAAO,GAAG,GAAG,EACb,KAAM,GAAG,GAAG,EACZ,KAAM,GAAG,GAAG,EACZ,MAAO,GAAG,GAAG,EACb,YAAa,CAAC,CAChB,GAEA,SAA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AAmB,IAAIxB,EAC3BuB,EAAa,KACbA,EAAa,mBACbA,EAAa,KACb,WAAW,KAAK,IAAI,MAAM,EAAE,EAAE,KAAK,EAAI,CAAC,CAC1C,EAEA,GAAG,MAAMhB,EAAW,qBAAqB,EAAE,gBAAgB,CACzD,WAAYR,EAAK,CACf,CACE,OAAQF,EAAmB,UAC3B,OAAQ2B,CACV,CAKF,CAAC,EACD,OAAQ,GAAG,GAAG,CAChB,CAAC,EAGD,MAAMX,EAAY,IAAIX,EACpBK,EACA,YACA,CAAC,EACD,CAAC,EACD,CAAC,EACD,CAAC,EACD,CAAC,EACDD,CACF,EACM,CAAE,WAAAQ,CAAW,EAAID,EAAU,eAAe,CAC9C,OAAQU,EACR,YAAa,EACf,CAAC,EAGKR,EAIA,CAAC,EACPN,EAAeK,EAAW,UAAU,CAClC,KAAOE,GAAU,CACfD,EAAO,KAAKC,CAAK,CACnB,EACA,MAAQC,GAAQ,CACdN,EAAOM,CAAG,CACZ,EACA,SAAU,IAAM,CACd,GAAI,CACF,OAAOF,CAAM,EAAE,QAAQ,CACrB,CACE,OAAQlB,EAAmB,UAC3B,OAAQ2B,CACV,CACF,CAAC,EACDd,EAAQ,CACV,OAASO,EAAK,CACZN,EAAOM,CAAY,CACrB,CACF,CACF,CAAC,CACH,CAAC,CAAC,EAEJ,GAAG,kCAAmC,IAAM,CAE1C,MAAMM,EAAe,IAAItB,EACvB,cACA,kCACA,CAAC,iCAAkC,SAAS,CAC9C,EAGkB,IAAIC,EACpBK,EACA,YACA,CAAC,EACD,CAAC,EACD,CAAC,EACD,CAAC,EACD,CAAC,EACDD,CACF,EACU,eAAe,CACvB,OAAQiB,EACR,YAAa,EACf,CAAC,EAGD,OAAOhB,EAAU,mBAAmB,EAAE,iBAAiB,CACzD,CAAC,CACH,CAAC,CACH,CAAC",
6
+ "names": ["DeviceActionStatus", "UserInteractionRequired", "from", "RegisteredWallet", "WalletPolicy", "BtcAppBinder", "GetExtendedPublicKeyCommand", "GetMasterFingerprintCommand", "APP_NAME", "mockLoggerFactory", "mockedDmk", "binder", "subscription", "resolve", "reject", "extendedPublicKey", "appBinder", "observable", "states", "state", "err", "baseParams", "params", "masterFingerprint", "signature", "message", "walletPolicy", "registeredWallet"]
7
7
  }
@@ -1,2 +1,2 @@
1
- import{ApduBuilder as o,CommandResultFactory as r}from"@ledgerhq/device-management-kit";import{CommandErrorHelper as n}from"@ledgerhq/signer-utils";import{Maybe as t}from"purify-ts";import{BTC_APP_ERRORS as m,BtcAppCommandErrorFactory as p}from"../../app-binder/command/utils/bitcoinAppErrors";import{BtcCommandUtils as a}from"../../utils/BtcCommandUtils";class c{constructor(e,d=new n(m,p,a.isSuccessResponse)){this._args=e;this._errorHelper=d}name="continue";getApdu(){return new o({cla:248,ins:1,p1:0,p2:0}).addBufferToData(this._args.payload).build()}parseResponse(e){return t.fromNullable(this._errorHelper.getError(e)).orDefault(r({data:e}))}}export{c as ContinueCommand};
1
+ import{ApduBuilder as e,CommandResultFactory as r}from"@ledgerhq/device-management-kit";import{CommandErrorHelper as n}from"@ledgerhq/signer-utils";import{Maybe as t}from"purify-ts";import{BTC_APP_ERRORS as m,BtcAppCommandErrorFactory as p}from"../../app-binder/command/utils/bitcoinAppErrors";import{PROTOCOL_VERSION as a}from"../../app-binder/command/utils/constants";import{BtcCommandUtils as s}from"../../utils/BtcCommandUtils";class A{constructor(o,C=new n(m,p,s.isSuccessResponse)){this._args=o;this._errorHelper=C}name="continue";getApdu(){return new e({cla:248,ins:1,p1:0,p2:a}).addBufferToData(this._args.payload).build()}parseResponse(o){return t.fromNullable(this._errorHelper.getError(o)).orDefault(r({data:o}))}}export{A as ContinueCommand};
2
2
  //# sourceMappingURL=ContinueCommand.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/internal/app-binder/command/ContinueCommand.ts"],
4
- "sourcesContent": ["import {\n type Apdu,\n ApduBuilder,\n type ApduResponse,\n type Command,\n type CommandResult,\n CommandResultFactory,\n} from \"@ledgerhq/device-management-kit\";\nimport { CommandErrorHelper } from \"@ledgerhq/signer-utils\";\nimport { Maybe } from \"purify-ts\";\n\nimport {\n BTC_APP_ERRORS,\n BtcAppCommandErrorFactory,\n type BtcErrorCodes,\n} from \"@internal/app-binder/command/utils/bitcoinAppErrors\";\nimport { BtcCommandUtils } from \"@internal/utils/BtcCommandUtils\";\n\nexport type ContinueCommandArgs = {\n payload: Uint8Array;\n};\n\nexport type ContinueCommandResponse = ApduResponse;\n\nexport class ContinueCommand\n implements\n Command<ContinueCommandResponse, ContinueCommandArgs, BtcErrorCodes>\n{\n readonly name = \"continue\";\n constructor(\n private readonly _args: ContinueCommandArgs,\n private readonly _errorHelper = new CommandErrorHelper<\n ContinueCommandResponse,\n BtcErrorCodes\n >(\n BTC_APP_ERRORS,\n BtcAppCommandErrorFactory,\n BtcCommandUtils.isSuccessResponse,\n ),\n ) {}\n\n getApdu(): Apdu {\n return new ApduBuilder({\n cla: 0xf8,\n ins: 0x01,\n p1: 0x00,\n p2: 0x00,\n })\n .addBufferToData(this._args.payload)\n .build();\n }\n\n parseResponse(\n response: ApduResponse,\n ): CommandResult<ContinueCommandResponse, BtcErrorCodes> {\n return Maybe.fromNullable(this._errorHelper.getError(response)).orDefault(\n CommandResultFactory({\n data: response,\n }),\n );\n }\n}\n"],
5
- "mappings": "AAAA,OAEE,eAAAA,EAIA,wBAAAC,MACK,kCACP,OAAS,sBAAAC,MAA0B,yBACnC,OAAS,SAAAC,MAAa,YAEtB,OACE,kBAAAC,EACA,6BAAAC,MAEK,sDACP,OAAS,mBAAAC,MAAuB,kCAQzB,MAAMC,CAGb,CAEE,YACmBC,EACAC,EAAe,IAAIP,EAIlCE,EACAC,EACAC,EAAgB,iBAClB,EACA,CATiB,WAAAE,EACA,kBAAAC,CAQhB,CAXM,KAAO,WAahB,SAAgB,CACd,OAAO,IAAIT,EAAY,CACrB,IAAK,IACL,IAAK,EACL,GAAI,EACJ,GAAI,CACN,CAAC,EACE,gBAAgB,KAAK,MAAM,OAAO,EAClC,MAAM,CACX,CAEA,cACEU,EACuD,CACvD,OAAOP,EAAM,aAAa,KAAK,aAAa,SAASO,CAAQ,CAAC,EAAE,UAC9DT,EAAqB,CACnB,KAAMS,CACR,CAAC,CACH,CACF,CACF",
6
- "names": ["ApduBuilder", "CommandResultFactory", "CommandErrorHelper", "Maybe", "BTC_APP_ERRORS", "BtcAppCommandErrorFactory", "BtcCommandUtils", "ContinueCommand", "_args", "_errorHelper", "response"]
4
+ "sourcesContent": ["import {\n type Apdu,\n ApduBuilder,\n type ApduResponse,\n type Command,\n type CommandResult,\n CommandResultFactory,\n} from \"@ledgerhq/device-management-kit\";\nimport { CommandErrorHelper } from \"@ledgerhq/signer-utils\";\nimport { Maybe } from \"purify-ts\";\n\nimport {\n BTC_APP_ERRORS,\n BtcAppCommandErrorFactory,\n type BtcErrorCodes,\n} from \"@internal/app-binder/command/utils/bitcoinAppErrors\";\nimport { PROTOCOL_VERSION } from \"@internal/app-binder/command/utils/constants\";\nimport { BtcCommandUtils } from \"@internal/utils/BtcCommandUtils\";\n\nexport type ContinueCommandArgs = {\n payload: Uint8Array;\n};\n\nexport type ContinueCommandResponse = ApduResponse;\n\nexport class ContinueCommand\n implements\n Command<ContinueCommandResponse, ContinueCommandArgs, BtcErrorCodes>\n{\n readonly name = \"continue\";\n constructor(\n private readonly _args: ContinueCommandArgs,\n private readonly _errorHelper = new CommandErrorHelper<\n ContinueCommandResponse,\n BtcErrorCodes\n >(\n BTC_APP_ERRORS,\n BtcAppCommandErrorFactory,\n BtcCommandUtils.isSuccessResponse,\n ),\n ) {}\n\n getApdu(): Apdu {\n return new ApduBuilder({\n cla: 0xf8,\n ins: 0x01,\n p1: 0x00,\n p2: PROTOCOL_VERSION,\n })\n .addBufferToData(this._args.payload)\n .build();\n }\n\n parseResponse(\n response: ApduResponse,\n ): CommandResult<ContinueCommandResponse, BtcErrorCodes> {\n return Maybe.fromNullable(this._errorHelper.getError(response)).orDefault(\n CommandResultFactory({\n data: response,\n }),\n );\n }\n}\n"],
5
+ "mappings": "AAAA,OAEE,eAAAA,EAIA,wBAAAC,MACK,kCACP,OAAS,sBAAAC,MAA0B,yBACnC,OAAS,SAAAC,MAAa,YAEtB,OACE,kBAAAC,EACA,6BAAAC,MAEK,sDACP,OAAS,oBAAAC,MAAwB,+CACjC,OAAS,mBAAAC,MAAuB,kCAQzB,MAAMC,CAGb,CAEE,YACmBC,EACAC,EAAe,IAAIR,EAIlCE,EACAC,EACAE,EAAgB,iBAClB,EACA,CATiB,WAAAE,EACA,kBAAAC,CAQhB,CAXM,KAAO,WAahB,SAAgB,CACd,OAAO,IAAIV,EAAY,CACrB,IAAK,IACL,IAAK,EACL,GAAI,EACJ,GAAIM,CACN,CAAC,EACE,gBAAgB,KAAK,MAAM,OAAO,EAClC,MAAM,CACX,CAEA,cACEK,EACuD,CACvD,OAAOR,EAAM,aAAa,KAAK,aAAa,SAASQ,CAAQ,CAAC,EAAE,UAC9DV,EAAqB,CACnB,KAAMU,CACR,CAAC,CACH,CACF,CACF",
6
+ "names": ["ApduBuilder", "CommandResultFactory", "CommandErrorHelper", "Maybe", "BTC_APP_ERRORS", "BtcAppCommandErrorFactory", "PROTOCOL_VERSION", "BtcCommandUtils", "ContinueCommand", "_args", "_errorHelper", "response"]
7
7
  }
@@ -1,2 +1,2 @@
1
- import{ApduResponse as d,CommandResultFactory as c}from"@ledgerhq/device-management-kit";import{SW_INTERRUPTED_EXECUTION as i}from"../../app-binder/command/utils/constants";import{ContinueCommand as o}from"./ContinueCommand";describe("ContinueCommand",()=>{const n={payload:new Uint8Array([222,173,190,239])},a=new Uint8Array([248,1,0,0,4,222,173,190,239]);describe("name",()=>{it("should be 'continue'",()=>{const e=new o(n);expect(e.name).toBe("continue")})}),describe("getApdu",()=>{it("should return correct APDU for given payload",()=>{const t=new o(n).getApdu();expect(t.getRawApdu()).toStrictEqual(a)})}),describe("parseResponse",()=>{it("should return the APDU response if it's a continue response",()=>{const e=new o(n),t=new Uint8Array([1,2,3,4]),s=new d({statusCode:i,data:t}),r=e.parseResponse(s);expect(r).toStrictEqual(c({data:s}))})})});
1
+ import{ApduResponse as d,CommandResultFactory as c}from"@ledgerhq/device-management-kit";import{SW_INTERRUPTED_EXECUTION as i}from"../../app-binder/command/utils/constants";import{ContinueCommand as o}from"./ContinueCommand";describe("ContinueCommand",()=>{const n={payload:new Uint8Array([222,173,190,239])},a=new Uint8Array([248,1,0,1,4,222,173,190,239]);describe("name",()=>{it("should be 'continue'",()=>{const e=new o(n);expect(e.name).toBe("continue")})}),describe("getApdu",()=>{it("should return correct APDU for given payload",()=>{const t=new o(n).getApdu();expect(t.getRawApdu()).toStrictEqual(a)})}),describe("parseResponse",()=>{it("should return the APDU response if it's a continue response",()=>{const e=new o(n),t=new Uint8Array([1,2,3,4]),s=new d({statusCode:i,data:t}),r=e.parseResponse(s);expect(r).toStrictEqual(c({data:s}))})})});
2
2
  //# sourceMappingURL=ContinueCommand.test.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/internal/app-binder/command/ContinueCommand.test.ts"],
4
- "sourcesContent": ["import {\n ApduResponse,\n CommandResultFactory,\n} from \"@ledgerhq/device-management-kit\";\n\nimport { SW_INTERRUPTED_EXECUTION } from \"@internal/app-binder/command/utils/constants\";\n\nimport { ContinueCommand } from \"./ContinueCommand\";\n\ndescribe(\"ContinueCommand\", (): void => {\n const defaultArgs = {\n payload: new Uint8Array([0xde, 0xad, 0xbe, 0xef]),\n };\n\n const EXPECTED_APDU = new Uint8Array([\n 0xf8, // CLA\n 0x01, // INS\n 0x00, // P1\n 0x00, // P2\n 0x04, // Lc\n 0xde,\n 0xad,\n 0xbe,\n 0xef, // Payload data\n ]);\n\n describe(\"name\", () => {\n it(\"should be 'continue'\", () => {\n const command = new ContinueCommand(defaultArgs);\n expect(command.name).toBe(\"continue\");\n });\n });\n\n describe(\"getApdu\", () => {\n it(\"should return correct APDU for given payload\", () => {\n // given\n const command = new ContinueCommand(defaultArgs);\n // when\n const apdu = command.getApdu();\n // then\n expect(apdu.getRawApdu()).toStrictEqual(EXPECTED_APDU);\n });\n });\n\n describe(\"parseResponse\", () => {\n it(\"should return the APDU response if it's a continue response\", () => {\n // given\n const command = new ContinueCommand(defaultArgs);\n const continueResponseData = new Uint8Array([0x01, 0x02, 0x03, 0x04]);\n const apduResponse = new ApduResponse({\n statusCode: SW_INTERRUPTED_EXECUTION,\n data: continueResponseData,\n });\n\n // when\n const response = command.parseResponse(apduResponse);\n\n // then\n expect(response).toStrictEqual(\n CommandResultFactory({\n data: apduResponse,\n }),\n );\n });\n });\n});\n"],
4
+ "sourcesContent": ["import {\n ApduResponse,\n CommandResultFactory,\n} from \"@ledgerhq/device-management-kit\";\n\nimport { SW_INTERRUPTED_EXECUTION } from \"@internal/app-binder/command/utils/constants\";\n\nimport { ContinueCommand } from \"./ContinueCommand\";\n\ndescribe(\"ContinueCommand\", (): void => {\n const defaultArgs = {\n payload: new Uint8Array([0xde, 0xad, 0xbe, 0xef]),\n };\n\n const EXPECTED_APDU = new Uint8Array([\n 0xf8, // CLA\n 0x01, // INS\n 0x00, // P1\n 0x01, // P2\n 0x04, // Lc\n 0xde,\n 0xad,\n 0xbe,\n 0xef, // Payload data\n ]);\n\n describe(\"name\", () => {\n it(\"should be 'continue'\", () => {\n const command = new ContinueCommand(defaultArgs);\n expect(command.name).toBe(\"continue\");\n });\n });\n\n describe(\"getApdu\", () => {\n it(\"should return correct APDU for given payload\", () => {\n // given\n const command = new ContinueCommand(defaultArgs);\n // when\n const apdu = command.getApdu();\n // then\n expect(apdu.getRawApdu()).toStrictEqual(EXPECTED_APDU);\n });\n });\n\n describe(\"parseResponse\", () => {\n it(\"should return the APDU response if it's a continue response\", () => {\n // given\n const command = new ContinueCommand(defaultArgs);\n const continueResponseData = new Uint8Array([0x01, 0x02, 0x03, 0x04]);\n const apduResponse = new ApduResponse({\n statusCode: SW_INTERRUPTED_EXECUTION,\n data: continueResponseData,\n });\n\n // when\n const response = command.parseResponse(apduResponse);\n\n // then\n expect(response).toStrictEqual(\n CommandResultFactory({\n data: apduResponse,\n }),\n );\n });\n });\n});\n"],
5
5
  "mappings": "AAAA,OACE,gBAAAA,EACA,wBAAAC,MACK,kCAEP,OAAS,4BAAAC,MAAgC,+CAEzC,OAAS,mBAAAC,MAAuB,oBAEhC,SAAS,kBAAmB,IAAY,CACtC,MAAMC,EAAc,CAClB,QAAS,IAAI,WAAW,CAAC,IAAM,IAAM,IAAM,GAAI,CAAC,CAClD,EAEMC,EAAgB,IAAI,WAAW,CACnC,IACA,EACA,EACA,EACA,EACA,IACA,IACA,IACA,GACF,CAAC,EAED,SAAS,OAAQ,IAAM,CACrB,GAAG,uBAAwB,IAAM,CAC/B,MAAMC,EAAU,IAAIH,EAAgBC,CAAW,EAC/C,OAAOE,EAAQ,IAAI,EAAE,KAAK,UAAU,CACtC,CAAC,CACH,CAAC,EAED,SAAS,UAAW,IAAM,CACxB,GAAG,+CAAgD,IAAM,CAIvD,MAAMC,EAFU,IAAIJ,EAAgBC,CAAW,EAE1B,QAAQ,EAE7B,OAAOG,EAAK,WAAW,CAAC,EAAE,cAAcF,CAAa,CACvD,CAAC,CACH,CAAC,EAED,SAAS,gBAAiB,IAAM,CAC9B,GAAG,8DAA+D,IAAM,CAEtE,MAAMC,EAAU,IAAIH,EAAgBC,CAAW,EACzCI,EAAuB,IAAI,WAAW,CAAC,EAAM,EAAM,EAAM,CAAI,CAAC,EAC9DC,EAAe,IAAIT,EAAa,CACpC,WAAYE,EACZ,KAAMM,CACR,CAAC,EAGKE,EAAWJ,EAAQ,cAAcG,CAAY,EAGnD,OAAOC,CAAQ,EAAE,cACfT,EAAqB,CACnB,KAAMQ,CACR,CAAC,CACH,CACF,CAAC,CACH,CAAC,CACH,CAAC",
6
6
  "names": ["ApduResponse", "CommandResultFactory", "SW_INTERRUPTED_EXECUTION", "ContinueCommand", "defaultArgs", "EXPECTED_APDU", "command", "apdu", "continueResponseData", "apduResponse", "response"]
7
7
  }
@@ -1,2 +1,2 @@
1
- import{ApduBuilder as s,ApduParser as i,CommandResultFactory as d,InvalidStatusWordError as p}from"@ledgerhq/device-management-kit";import{CommandErrorHelper as m,DerivationPathUtils as l}from"@ledgerhq/signer-utils";import{Maybe as c}from"purify-ts";import{BTC_APP_ERRORS as u,BtcAppCommandErrorFactory as y}from"../../app-binder/command/utils/bitcoinAppErrors";import{BtcCommandUtils as g}from"../../utils/BtcCommandUtils";class h{constructor(t,e=new m(u,y,g.isSuccessResponse)){this._args=t;this._errorHelper=e}name="getExtendedPublicKey";getApdu(){const{checkOnDevice:t,derivationPath:e}=this._args,n={cla:225,ins:0,p1:0,p2:0},r=new s(n).add8BitUIntToData(t?1:0),o=l.splitPath(e);return r.add8BitUIntToData(o.length),o.forEach(a=>{r.add32BitUIntToData(a)}),r.build()}parseResponse(t){return c.fromNullable(this._errorHelper.getError(t)).orDefaultLazy(()=>{const e=new i(t),n=e.getUnparsedRemainingLength();if(n<=0)return d({error:new p("Invalid response length")});const r=e.encodeToString(e.extractFieldByLength(n));return d({data:{extendedPublicKey:r}})})}}export{h as GetExtendedPublicKeyCommand};
1
+ import{ApduBuilder as s,ApduParser as i,CommandResultFactory as d,InvalidStatusWordError as m}from"@ledgerhq/device-management-kit";import{CommandErrorHelper as p,DerivationPathUtils as l}from"@ledgerhq/signer-utils";import{Maybe as c}from"purify-ts";import{BTC_APP_ERRORS as u,BtcAppCommandErrorFactory as y}from"../../app-binder/command/utils/bitcoinAppErrors";import{PROTOCOL_VERSION as g}from"../../app-binder/command/utils/constants";import{BtcCommandUtils as C}from"../../utils/BtcCommandUtils";class B{constructor(t,e=new p(u,y,C.isSuccessResponse)){this._args=t;this._errorHelper=e}name="getExtendedPublicKey";getApdu(){const{checkOnDevice:t,derivationPath:e}=this._args,o={cla:225,ins:0,p1:0,p2:g},r=new s(o).add8BitUIntToData(t?1:0),n=l.splitPath(e);return r.add8BitUIntToData(n.length),n.forEach(a=>{r.add32BitUIntToData(a)}),r.build()}parseResponse(t){return c.fromNullable(this._errorHelper.getError(t)).orDefaultLazy(()=>{const e=new i(t),o=e.getUnparsedRemainingLength();if(o<=0)return d({error:new m("Invalid response length")});const r=e.encodeToString(e.extractFieldByLength(o));return d({data:{extendedPublicKey:r}})})}}export{B as GetExtendedPublicKeyCommand};
2
2
  //# sourceMappingURL=GetExtendedPublicKeyCommand.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/internal/app-binder/command/GetExtendedPublicKeyCommand.ts"],
4
- "sourcesContent": ["// https://github.com/LedgerHQ/app-bitcoin-new/blob/master/doc/bitcoin.md#get_extended_pubkey\nimport {\n type Apdu,\n ApduBuilder,\n type ApduBuilderArgs,\n ApduParser,\n type ApduResponse,\n type Command,\n type CommandResult,\n CommandResultFactory,\n InvalidStatusWordError,\n} from \"@ledgerhq/device-management-kit\";\nimport {\n CommandErrorHelper,\n DerivationPathUtils,\n} from \"@ledgerhq/signer-utils\";\nimport { Maybe } from \"purify-ts\";\n\nimport {\n BTC_APP_ERRORS,\n BtcAppCommandErrorFactory,\n type BtcErrorCodes,\n} from \"@internal/app-binder/command/utils/bitcoinAppErrors\";\nimport { BtcCommandUtils } from \"@internal/utils/BtcCommandUtils\";\n\nexport type GetExtendedPublicKeyCommandArgs = {\n checkOnDevice: boolean;\n derivationPath: string;\n};\n\nexport type GetExtendedPublicKeyCommandResponse = {\n extendedPublicKey: string;\n};\n\nexport class GetExtendedPublicKeyCommand\n implements\n Command<\n GetExtendedPublicKeyCommandResponse,\n GetExtendedPublicKeyCommandArgs,\n BtcErrorCodes\n >\n{\n readonly name = \"getExtendedPublicKey\";\n constructor(\n private readonly _args: GetExtendedPublicKeyCommandArgs,\n private readonly _errorHelper = new CommandErrorHelper<\n GetExtendedPublicKeyCommandResponse,\n BtcErrorCodes\n >(\n BTC_APP_ERRORS,\n BtcAppCommandErrorFactory,\n BtcCommandUtils.isSuccessResponse,\n ),\n ) {}\n\n getApdu(): Apdu {\n const { checkOnDevice, derivationPath } = this._args;\n\n const getExtendedPublicKeyArgs: ApduBuilderArgs = {\n cla: 0xe1,\n ins: 0x00,\n p1: 0x00,\n p2: 0x00,\n };\n const builder = new ApduBuilder(getExtendedPublicKeyArgs).add8BitUIntToData(\n checkOnDevice ? 0x01 : 0x00,\n );\n\n const path = DerivationPathUtils.splitPath(derivationPath);\n builder.add8BitUIntToData(path.length);\n path.forEach((element) => {\n builder.add32BitUIntToData(element);\n });\n\n return builder.build();\n }\n\n parseResponse(\n response: ApduResponse,\n ): CommandResult<GetExtendedPublicKeyCommandResponse, BtcErrorCodes> {\n return Maybe.fromNullable(\n this._errorHelper.getError(response),\n ).orDefaultLazy(() => {\n const parser = new ApduParser(response);\n const length = parser.getUnparsedRemainingLength();\n\n if (length <= 0) {\n return CommandResultFactory({\n error: new InvalidStatusWordError(\"Invalid response length\"),\n });\n }\n\n const extendedPublicKey = parser.encodeToString(\n parser.extractFieldByLength(length),\n );\n\n return CommandResultFactory({\n data: {\n extendedPublicKey,\n },\n });\n });\n }\n}\n"],
5
- "mappings": "AACA,OAEE,eAAAA,EAEA,cAAAC,EAIA,wBAAAC,EACA,0BAAAC,MACK,kCACP,OACE,sBAAAC,EACA,uBAAAC,MACK,yBACP,OAAS,SAAAC,MAAa,YAEtB,OACE,kBAAAC,EACA,6BAAAC,MAEK,sDACP,OAAS,mBAAAC,MAAuB,kCAWzB,MAAMC,CAOb,CAEE,YACmBC,EACAC,EAAe,IAAIR,EAIlCG,EACAC,EACAC,EAAgB,iBAClB,EACA,CATiB,WAAAE,EACA,kBAAAC,CAQhB,CAXM,KAAO,uBAahB,SAAgB,CACd,KAAM,CAAE,cAAAC,EAAe,eAAAC,CAAe,EAAI,KAAK,MAEzCC,EAA4C,CAChD,IAAK,IACL,IAAK,EACL,GAAI,EACJ,GAAI,CACN,EACMC,EAAU,IAAIhB,EAAYe,CAAwB,EAAE,kBACxDF,EAAgB,EAAO,CACzB,EAEMI,EAAOZ,EAAoB,UAAUS,CAAc,EACzD,OAAAE,EAAQ,kBAAkBC,EAAK,MAAM,EACrCA,EAAK,QAASC,GAAY,CACxBF,EAAQ,mBAAmBE,CAAO,CACpC,CAAC,EAEMF,EAAQ,MAAM,CACvB,CAEA,cACEG,EACmE,CACnE,OAAOb,EAAM,aACX,KAAK,aAAa,SAASa,CAAQ,CACrC,EAAE,cAAc,IAAM,CACpB,MAAMC,EAAS,IAAInB,EAAWkB,CAAQ,EAChCE,EAASD,EAAO,2BAA2B,EAEjD,GAAIC,GAAU,EACZ,OAAOnB,EAAqB,CAC1B,MAAO,IAAIC,EAAuB,yBAAyB,CAC7D,CAAC,EAGH,MAAMmB,EAAoBF,EAAO,eAC/BA,EAAO,qBAAqBC,CAAM,CACpC,EAEA,OAAOnB,EAAqB,CAC1B,KAAM,CACJ,kBAAAoB,CACF,CACF,CAAC,CACH,CAAC,CACH,CACF",
6
- "names": ["ApduBuilder", "ApduParser", "CommandResultFactory", "InvalidStatusWordError", "CommandErrorHelper", "DerivationPathUtils", "Maybe", "BTC_APP_ERRORS", "BtcAppCommandErrorFactory", "BtcCommandUtils", "GetExtendedPublicKeyCommand", "_args", "_errorHelper", "checkOnDevice", "derivationPath", "getExtendedPublicKeyArgs", "builder", "path", "element", "response", "parser", "length", "extendedPublicKey"]
4
+ "sourcesContent": ["// https://github.com/LedgerHQ/app-bitcoin-new/blob/master/doc/bitcoin.md#get_extended_pubkey\nimport {\n type Apdu,\n ApduBuilder,\n type ApduBuilderArgs,\n ApduParser,\n type ApduResponse,\n type Command,\n type CommandResult,\n CommandResultFactory,\n InvalidStatusWordError,\n} from \"@ledgerhq/device-management-kit\";\nimport {\n CommandErrorHelper,\n DerivationPathUtils,\n} from \"@ledgerhq/signer-utils\";\nimport { Maybe } from \"purify-ts\";\n\nimport {\n BTC_APP_ERRORS,\n BtcAppCommandErrorFactory,\n type BtcErrorCodes,\n} from \"@internal/app-binder/command/utils/bitcoinAppErrors\";\nimport { PROTOCOL_VERSION } from \"@internal/app-binder/command/utils/constants\";\nimport { BtcCommandUtils } from \"@internal/utils/BtcCommandUtils\";\n\nexport type GetExtendedPublicKeyCommandArgs = {\n checkOnDevice: boolean;\n derivationPath: string;\n};\n\nexport type GetExtendedPublicKeyCommandResponse = {\n extendedPublicKey: string;\n};\n\nexport class GetExtendedPublicKeyCommand\n implements\n Command<\n GetExtendedPublicKeyCommandResponse,\n GetExtendedPublicKeyCommandArgs,\n BtcErrorCodes\n >\n{\n readonly name = \"getExtendedPublicKey\";\n constructor(\n private readonly _args: GetExtendedPublicKeyCommandArgs,\n private readonly _errorHelper = new CommandErrorHelper<\n GetExtendedPublicKeyCommandResponse,\n BtcErrorCodes\n >(\n BTC_APP_ERRORS,\n BtcAppCommandErrorFactory,\n BtcCommandUtils.isSuccessResponse,\n ),\n ) {}\n\n getApdu(): Apdu {\n const { checkOnDevice, derivationPath } = this._args;\n\n const getExtendedPublicKeyArgs: ApduBuilderArgs = {\n cla: 0xe1,\n ins: 0x00,\n p1: 0x00,\n p2: PROTOCOL_VERSION,\n };\n const builder = new ApduBuilder(getExtendedPublicKeyArgs).add8BitUIntToData(\n checkOnDevice ? 0x01 : 0x00,\n );\n\n const path = DerivationPathUtils.splitPath(derivationPath);\n builder.add8BitUIntToData(path.length);\n path.forEach((element) => {\n builder.add32BitUIntToData(element);\n });\n\n return builder.build();\n }\n\n parseResponse(\n response: ApduResponse,\n ): CommandResult<GetExtendedPublicKeyCommandResponse, BtcErrorCodes> {\n return Maybe.fromNullable(\n this._errorHelper.getError(response),\n ).orDefaultLazy(() => {\n const parser = new ApduParser(response);\n const length = parser.getUnparsedRemainingLength();\n\n if (length <= 0) {\n return CommandResultFactory({\n error: new InvalidStatusWordError(\"Invalid response length\"),\n });\n }\n\n const extendedPublicKey = parser.encodeToString(\n parser.extractFieldByLength(length),\n );\n\n return CommandResultFactory({\n data: {\n extendedPublicKey,\n },\n });\n });\n }\n}\n"],
5
+ "mappings": "AACA,OAEE,eAAAA,EAEA,cAAAC,EAIA,wBAAAC,EACA,0BAAAC,MACK,kCACP,OACE,sBAAAC,EACA,uBAAAC,MACK,yBACP,OAAS,SAAAC,MAAa,YAEtB,OACE,kBAAAC,EACA,6BAAAC,MAEK,sDACP,OAAS,oBAAAC,MAAwB,+CACjC,OAAS,mBAAAC,MAAuB,kCAWzB,MAAMC,CAOb,CAEE,YACmBC,EACAC,EAAe,IAAIT,EAIlCG,EACAC,EACAE,EAAgB,iBAClB,EACA,CATiB,WAAAE,EACA,kBAAAC,CAQhB,CAXM,KAAO,uBAahB,SAAgB,CACd,KAAM,CAAE,cAAAC,EAAe,eAAAC,CAAe,EAAI,KAAK,MAEzCC,EAA4C,CAChD,IAAK,IACL,IAAK,EACL,GAAI,EACJ,GAAIP,CACN,EACMQ,EAAU,IAAIjB,EAAYgB,CAAwB,EAAE,kBACxDF,EAAgB,EAAO,CACzB,EAEMI,EAAOb,EAAoB,UAAUU,CAAc,EACzD,OAAAE,EAAQ,kBAAkBC,EAAK,MAAM,EACrCA,EAAK,QAASC,GAAY,CACxBF,EAAQ,mBAAmBE,CAAO,CACpC,CAAC,EAEMF,EAAQ,MAAM,CACvB,CAEA,cACEG,EACmE,CACnE,OAAOd,EAAM,aACX,KAAK,aAAa,SAASc,CAAQ,CACrC,EAAE,cAAc,IAAM,CACpB,MAAMC,EAAS,IAAIpB,EAAWmB,CAAQ,EAChCE,EAASD,EAAO,2BAA2B,EAEjD,GAAIC,GAAU,EACZ,OAAOpB,EAAqB,CAC1B,MAAO,IAAIC,EAAuB,yBAAyB,CAC7D,CAAC,EAGH,MAAMoB,EAAoBF,EAAO,eAC/BA,EAAO,qBAAqBC,CAAM,CACpC,EAEA,OAAOpB,EAAqB,CAC1B,KAAM,CACJ,kBAAAqB,CACF,CACF,CAAC,CACH,CAAC,CACH,CACF",
6
+ "names": ["ApduBuilder", "ApduParser", "CommandResultFactory", "InvalidStatusWordError", "CommandErrorHelper", "DerivationPathUtils", "Maybe", "BTC_APP_ERRORS", "BtcAppCommandErrorFactory", "PROTOCOL_VERSION", "BtcCommandUtils", "GetExtendedPublicKeyCommand", "_args", "_errorHelper", "checkOnDevice", "derivationPath", "getExtendedPublicKeyArgs", "builder", "path", "element", "response", "parser", "length", "extendedPublicKey"]
7
7
  }
@@ -1,2 +1,2 @@
1
- import{ApduResponse as o,CommandResultFactory as a,InvalidStatusWordError as s}from"@ledgerhq/device-management-kit";import{BTC_APP_ERRORS as d,BtcAppCommandErrorFactory as c}from"../../app-binder/command/utils/bitcoinAppErrors";import{GetExtendedPublicKeyCommand as r}from"./GetExtendedPublicKeyCommand";const u=new Uint8Array([225,0,0,0,14,1,3,128,0,0,84,128,0,0,0,128,0,0,0]),i=new Uint8Array([225,0,0,0,14,0,3,128,0,0,84,128,0,0,0,128,0,0,0]),p=new Uint8Array([225,0,0,0,18,1,4,128,0,0,49,128,0,0,0,128,0,0,0,0,0,0,0]),E=new Uint8Array([120,112,117,98,54,68,57,80,112,52,114,70,118,119,84,71,120,56,56,89,68,52,67,68,97,49,110,66,69,112,99,75,69,90,84,67,78,70,122,67,70,55,103,86,80,122,54,84,104,57,66,97,86,104,104,80,74,68,117,103,57,89,89,70,80,89,109,107,83,72,76,102,82,49,86,81,89,106,53,106,97,121,113,119,83,89,65,82,110,117,66,74,105,80,83,68,97,98,121,121,84,105,67,68,55,66,51,99,106,80,113]);describe("GetExtendedPublicKeyCommand",()=>{let x;const t={checkOnDevice:!0,derivationPath:"84'/0'/0'"};beforeEach(()=>{}),describe("name",()=>{it("should be 'getExtendedPublicKey'",()=>{x=new r(t),expect(x.name).toBe("getExtendedPublicKey")})}),describe("getApdu",()=>{it("should return the correct APDU",()=>{x=new r(t);const e=x.getApdu();expect(e.getRawApdu()).toEqual(u)}),it("should return the correct APDU without checkOnDevice",()=>{x=new r({...t,checkOnDevice:!1});const e=x.getApdu();expect(e.getRawApdu()).toEqual(i)}),it("should return the correct APDU with different derivation path",()=>{x=new r({...t,derivationPath:"49'/0'/0'/0"});const e=x.getApdu();expect(e.getRawApdu()).toEqual(p)})}),describe("parseResponse",()=>{it("should return the extended public key",()=>{x=new r(t);const e=new o({data:E,statusCode:new Uint8Array([144,0])}),n=x.parseResponse(e);expect(n).toEqual(a({data:{extendedPublicKey:"xpub6D9Pp4rFvwTGx88YD4CDa1nBEpcKEZTCNFzCF7gVPz6Th9BaVhhPJDug9YYFPYmkSHLfR1VQYj5jayqwSYARnuBJiPSDabyyTiCD7B3cjPq"}}))}),it("should return an error if the response is not successful",()=>{x=new r(t);const e=new o({statusCode:Uint8Array.from([109,0]),data:new Uint8Array(0)}),n=x.parseResponse(e);expect(n).toStrictEqual(a({error:c({...d["6d00"],errorCode:"6d00"})}))}),it("should return an error if the response is too short",()=>{x=new r(t);const e=new o({data:Uint8Array.from([]),statusCode:new Uint8Array([144,0])}),n=x.parseResponse(e);expect(n).toStrictEqual(a({error:new s("Invalid response length")}))})})});
1
+ import{ApduResponse as o,CommandResultFactory as a,InvalidStatusWordError as s}from"@ledgerhq/device-management-kit";import{BTC_APP_ERRORS as d,BtcAppCommandErrorFactory as c}from"../../app-binder/command/utils/bitcoinAppErrors";import{GetExtendedPublicKeyCommand as r}from"./GetExtendedPublicKeyCommand";const u=new Uint8Array([225,0,0,1,14,1,3,128,0,0,84,128,0,0,0,128,0,0,0]),i=new Uint8Array([225,0,0,1,14,0,3,128,0,0,84,128,0,0,0,128,0,0,0]),p=new Uint8Array([225,0,0,1,18,1,4,128,0,0,49,128,0,0,0,128,0,0,0,0,0,0,0]),E=new Uint8Array([120,112,117,98,54,68,57,80,112,52,114,70,118,119,84,71,120,56,56,89,68,52,67,68,97,49,110,66,69,112,99,75,69,90,84,67,78,70,122,67,70,55,103,86,80,122,54,84,104,57,66,97,86,104,104,80,74,68,117,103,57,89,89,70,80,89,109,107,83,72,76,102,82,49,86,81,89,106,53,106,97,121,113,119,83,89,65,82,110,117,66,74,105,80,83,68,97,98,121,121,84,105,67,68,55,66,51,99,106,80,113]);describe("GetExtendedPublicKeyCommand",()=>{let x;const t={checkOnDevice:!0,derivationPath:"84'/0'/0'"};beforeEach(()=>{}),describe("name",()=>{it("should be 'getExtendedPublicKey'",()=>{x=new r(t),expect(x.name).toBe("getExtendedPublicKey")})}),describe("getApdu",()=>{it("should return the correct APDU",()=>{x=new r(t);const e=x.getApdu();expect(e.getRawApdu()).toEqual(u)}),it("should return the correct APDU without checkOnDevice",()=>{x=new r({...t,checkOnDevice:!1});const e=x.getApdu();expect(e.getRawApdu()).toEqual(i)}),it("should return the correct APDU with different derivation path",()=>{x=new r({...t,derivationPath:"49'/0'/0'/0"});const e=x.getApdu();expect(e.getRawApdu()).toEqual(p)})}),describe("parseResponse",()=>{it("should return the extended public key",()=>{x=new r(t);const e=new o({data:E,statusCode:new Uint8Array([144,0])}),n=x.parseResponse(e);expect(n).toEqual(a({data:{extendedPublicKey:"xpub6D9Pp4rFvwTGx88YD4CDa1nBEpcKEZTCNFzCF7gVPz6Th9BaVhhPJDug9YYFPYmkSHLfR1VQYj5jayqwSYARnuBJiPSDabyyTiCD7B3cjPq"}}))}),it("should return an error if the response is not successful",()=>{x=new r(t);const e=new o({statusCode:Uint8Array.from([109,0]),data:new Uint8Array(0)}),n=x.parseResponse(e);expect(n).toStrictEqual(a({error:c({...d["6d00"],errorCode:"6d00"})}))}),it("should return an error if the response is too short",()=>{x=new r(t);const e=new o({data:Uint8Array.from([]),statusCode:new Uint8Array([144,0])}),n=x.parseResponse(e);expect(n).toStrictEqual(a({error:new s("Invalid response length")}))})})});
2
2
  //# sourceMappingURL=GetExtendedPublicKeyCommand.test.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/internal/app-binder/command/GetExtendedPublicKeyCommand.test.ts"],
4
- "sourcesContent": ["import {\n ApduResponse,\n CommandResultFactory,\n InvalidStatusWordError,\n} from \"@ledgerhq/device-management-kit\";\n\nimport {\n BTC_APP_ERRORS,\n BtcAppCommandErrorFactory,\n} from \"@internal/app-binder/command/utils/bitcoinAppErrors\";\n\nimport {\n GetExtendedPublicKeyCommand,\n type GetExtendedPublicKeyCommandArgs,\n} from \"./GetExtendedPublicKeyCommand\";\n\nconst GET_EXTENDED_PUBLIC_KEY_APDU_WITH_DISPLAY = new Uint8Array([\n 0xe1, 0x00, 0x00, 0x00, 0x0e, 0x01, 0x03, 0x80, 0x00, 0x00, 0x54, 0x80, 0x00,\n 0x00, 0x00, 0x80, 0x00, 0x00, 0x00,\n]);\n\nconst GET_EXTENDED_PUBLIC_KEY_APDU_WITHOUT_DISPLAY = new Uint8Array([\n 0xe1, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x03, 0x80, 0x00, 0x00, 0x54, 0x80, 0x00,\n 0x00, 0x00, 0x80, 0x00, 0x00, 0x00,\n]);\n\nconst GET_EXTENDED_PUBLIC_KEY_APDU_WITH_OTHER_DERIVATION_PATH = new Uint8Array([\n 0xe1, 0x00, 0x00, 0x00, 0x12, 0x01, 0x04, 0x80, 0x00, 0x00, 0x31, 0x80, 0x00,\n 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n]);\n\nconst GET_EXTENDED_PUBLIC_KEY_VALID_RESPONSE = new Uint8Array([\n 0x78, 0x70, 0x75, 0x62, 0x36, 0x44, 0x39, 0x50, 0x70, 0x34, 0x72, 0x46, 0x76,\n 0x77, 0x54, 0x47, 0x78, 0x38, 0x38, 0x59, 0x44, 0x34, 0x43, 0x44, 0x61, 0x31,\n 0x6e, 0x42, 0x45, 0x70, 0x63, 0x4b, 0x45, 0x5a, 0x54, 0x43, 0x4e, 0x46, 0x7a,\n 0x43, 0x46, 0x37, 0x67, 0x56, 0x50, 0x7a, 0x36, 0x54, 0x68, 0x39, 0x42, 0x61,\n 0x56, 0x68, 0x68, 0x50, 0x4a, 0x44, 0x75, 0x67, 0x39, 0x59, 0x59, 0x46, 0x50,\n 0x59, 0x6d, 0x6b, 0x53, 0x48, 0x4c, 0x66, 0x52, 0x31, 0x56, 0x51, 0x59, 0x6a,\n 0x35, 0x6a, 0x61, 0x79, 0x71, 0x77, 0x53, 0x59, 0x41, 0x52, 0x6e, 0x75, 0x42,\n 0x4a, 0x69, 0x50, 0x53, 0x44, 0x61, 0x62, 0x79, 0x79, 0x54, 0x69, 0x43, 0x44,\n 0x37, 0x42, 0x33, 0x63, 0x6a, 0x50, 0x71,\n]);\n\ndescribe(\"GetExtendedPublicKeyCommand\", () => {\n let command: GetExtendedPublicKeyCommand;\n const defaultArgs: GetExtendedPublicKeyCommandArgs = {\n checkOnDevice: true,\n derivationPath: \"84'/0'/0'\",\n };\n\n beforeEach(() => {});\n\n describe(\"name\", () => {\n it(\"should be 'getExtendedPublicKey'\", () => {\n command = new GetExtendedPublicKeyCommand(defaultArgs);\n expect(command.name).toBe(\"getExtendedPublicKey\");\n });\n });\n\n describe(\"getApdu\", () => {\n it(\"should return the correct APDU\", () => {\n // GIVEN\n command = new GetExtendedPublicKeyCommand(defaultArgs);\n\n // WHEN\n const apdu = command.getApdu();\n\n //THEN\n expect(apdu.getRawApdu()).toEqual(\n GET_EXTENDED_PUBLIC_KEY_APDU_WITH_DISPLAY,\n );\n });\n\n it(\"should return the correct APDU without checkOnDevice\", () => {\n // GIVEN\n command = new GetExtendedPublicKeyCommand({\n ...defaultArgs,\n checkOnDevice: false,\n });\n\n // WHEN\n const apdu = command.getApdu();\n\n //THEN\n expect(apdu.getRawApdu()).toEqual(\n GET_EXTENDED_PUBLIC_KEY_APDU_WITHOUT_DISPLAY,\n );\n });\n\n it(\"should return the correct APDU with different derivation path\", () => {\n // GIVEN\n command = new GetExtendedPublicKeyCommand({\n ...defaultArgs,\n derivationPath: \"49'/0'/0'/0\",\n });\n\n // WHEN\n const apdu = command.getApdu();\n\n //THEN\n expect(apdu.getRawApdu()).toEqual(\n GET_EXTENDED_PUBLIC_KEY_APDU_WITH_OTHER_DERIVATION_PATH,\n );\n });\n });\n\n describe(\"parseResponse\", () => {\n it(\"should return the extended public key\", () => {\n // GIVEN\n command = new GetExtendedPublicKeyCommand(defaultArgs);\n const response = new ApduResponse({\n data: GET_EXTENDED_PUBLIC_KEY_VALID_RESPONSE,\n statusCode: new Uint8Array([0x90, 0x00]),\n });\n\n // WHEN\n const result = command.parseResponse(response);\n\n // THEN\n expect(result).toEqual(\n CommandResultFactory({\n data: {\n extendedPublicKey:\n \"xpub6D9Pp4rFvwTGx88YD4CDa1nBEpcKEZTCNFzCF7gVPz6Th9BaVhhPJDug9YYFPYmkSHLfR1VQYj5jayqwSYARnuBJiPSDabyyTiCD7B3cjPq\",\n },\n }),\n );\n });\n\n it(\"should return an error if the response is not successful\", () => {\n // GIVEN\n command = new GetExtendedPublicKeyCommand(defaultArgs);\n const response = new ApduResponse({\n statusCode: Uint8Array.from([0x6d, 0x00]),\n data: new Uint8Array(0),\n });\n\n // WHEN\n const result = command.parseResponse(response);\n\n // THEN\n expect(result).toStrictEqual(\n CommandResultFactory({\n error: BtcAppCommandErrorFactory({\n ...BTC_APP_ERRORS[\"6d00\"],\n errorCode: \"6d00\",\n }),\n }),\n );\n });\n\n it(\"should return an error if the response is too short\", () => {\n // GIVEN\n command = new GetExtendedPublicKeyCommand(defaultArgs);\n const response = new ApduResponse({\n data: Uint8Array.from([]),\n statusCode: new Uint8Array([0x90, 0x00]),\n });\n\n // WHEN\n const result = command.parseResponse(response);\n\n // THEN\n expect(result).toStrictEqual(\n CommandResultFactory({\n error: new InvalidStatusWordError(\"Invalid response length\"),\n }),\n );\n });\n });\n});\n"],
4
+ "sourcesContent": ["import {\n ApduResponse,\n CommandResultFactory,\n InvalidStatusWordError,\n} from \"@ledgerhq/device-management-kit\";\n\nimport {\n BTC_APP_ERRORS,\n BtcAppCommandErrorFactory,\n} from \"@internal/app-binder/command/utils/bitcoinAppErrors\";\n\nimport {\n GetExtendedPublicKeyCommand,\n type GetExtendedPublicKeyCommandArgs,\n} from \"./GetExtendedPublicKeyCommand\";\n\nconst GET_EXTENDED_PUBLIC_KEY_APDU_WITH_DISPLAY = new Uint8Array([\n 0xe1, 0x00, 0x00, 0x01, 0x0e, 0x01, 0x03, 0x80, 0x00, 0x00, 0x54, 0x80, 0x00,\n 0x00, 0x00, 0x80, 0x00, 0x00, 0x00,\n]);\n\nconst GET_EXTENDED_PUBLIC_KEY_APDU_WITHOUT_DISPLAY = new Uint8Array([\n 0xe1, 0x00, 0x00, 0x01, 0x0e, 0x00, 0x03, 0x80, 0x00, 0x00, 0x54, 0x80, 0x00,\n 0x00, 0x00, 0x80, 0x00, 0x00, 0x00,\n]);\n\nconst GET_EXTENDED_PUBLIC_KEY_APDU_WITH_OTHER_DERIVATION_PATH = new Uint8Array([\n 0xe1, 0x00, 0x00, 0x01, 0x12, 0x01, 0x04, 0x80, 0x00, 0x00, 0x31, 0x80, 0x00,\n 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n]);\n\nconst GET_EXTENDED_PUBLIC_KEY_VALID_RESPONSE = new Uint8Array([\n 0x78, 0x70, 0x75, 0x62, 0x36, 0x44, 0x39, 0x50, 0x70, 0x34, 0x72, 0x46, 0x76,\n 0x77, 0x54, 0x47, 0x78, 0x38, 0x38, 0x59, 0x44, 0x34, 0x43, 0x44, 0x61, 0x31,\n 0x6e, 0x42, 0x45, 0x70, 0x63, 0x4b, 0x45, 0x5a, 0x54, 0x43, 0x4e, 0x46, 0x7a,\n 0x43, 0x46, 0x37, 0x67, 0x56, 0x50, 0x7a, 0x36, 0x54, 0x68, 0x39, 0x42, 0x61,\n 0x56, 0x68, 0x68, 0x50, 0x4a, 0x44, 0x75, 0x67, 0x39, 0x59, 0x59, 0x46, 0x50,\n 0x59, 0x6d, 0x6b, 0x53, 0x48, 0x4c, 0x66, 0x52, 0x31, 0x56, 0x51, 0x59, 0x6a,\n 0x35, 0x6a, 0x61, 0x79, 0x71, 0x77, 0x53, 0x59, 0x41, 0x52, 0x6e, 0x75, 0x42,\n 0x4a, 0x69, 0x50, 0x53, 0x44, 0x61, 0x62, 0x79, 0x79, 0x54, 0x69, 0x43, 0x44,\n 0x37, 0x42, 0x33, 0x63, 0x6a, 0x50, 0x71,\n]);\n\ndescribe(\"GetExtendedPublicKeyCommand\", () => {\n let command: GetExtendedPublicKeyCommand;\n const defaultArgs: GetExtendedPublicKeyCommandArgs = {\n checkOnDevice: true,\n derivationPath: \"84'/0'/0'\",\n };\n\n beforeEach(() => {});\n\n describe(\"name\", () => {\n it(\"should be 'getExtendedPublicKey'\", () => {\n command = new GetExtendedPublicKeyCommand(defaultArgs);\n expect(command.name).toBe(\"getExtendedPublicKey\");\n });\n });\n\n describe(\"getApdu\", () => {\n it(\"should return the correct APDU\", () => {\n // GIVEN\n command = new GetExtendedPublicKeyCommand(defaultArgs);\n\n // WHEN\n const apdu = command.getApdu();\n\n //THEN\n expect(apdu.getRawApdu()).toEqual(\n GET_EXTENDED_PUBLIC_KEY_APDU_WITH_DISPLAY,\n );\n });\n\n it(\"should return the correct APDU without checkOnDevice\", () => {\n // GIVEN\n command = new GetExtendedPublicKeyCommand({\n ...defaultArgs,\n checkOnDevice: false,\n });\n\n // WHEN\n const apdu = command.getApdu();\n\n //THEN\n expect(apdu.getRawApdu()).toEqual(\n GET_EXTENDED_PUBLIC_KEY_APDU_WITHOUT_DISPLAY,\n );\n });\n\n it(\"should return the correct APDU with different derivation path\", () => {\n // GIVEN\n command = new GetExtendedPublicKeyCommand({\n ...defaultArgs,\n derivationPath: \"49'/0'/0'/0\",\n });\n\n // WHEN\n const apdu = command.getApdu();\n\n //THEN\n expect(apdu.getRawApdu()).toEqual(\n GET_EXTENDED_PUBLIC_KEY_APDU_WITH_OTHER_DERIVATION_PATH,\n );\n });\n });\n\n describe(\"parseResponse\", () => {\n it(\"should return the extended public key\", () => {\n // GIVEN\n command = new GetExtendedPublicKeyCommand(defaultArgs);\n const response = new ApduResponse({\n data: GET_EXTENDED_PUBLIC_KEY_VALID_RESPONSE,\n statusCode: new Uint8Array([0x90, 0x00]),\n });\n\n // WHEN\n const result = command.parseResponse(response);\n\n // THEN\n expect(result).toEqual(\n CommandResultFactory({\n data: {\n extendedPublicKey:\n \"xpub6D9Pp4rFvwTGx88YD4CDa1nBEpcKEZTCNFzCF7gVPz6Th9BaVhhPJDug9YYFPYmkSHLfR1VQYj5jayqwSYARnuBJiPSDabyyTiCD7B3cjPq\",\n },\n }),\n );\n });\n\n it(\"should return an error if the response is not successful\", () => {\n // GIVEN\n command = new GetExtendedPublicKeyCommand(defaultArgs);\n const response = new ApduResponse({\n statusCode: Uint8Array.from([0x6d, 0x00]),\n data: new Uint8Array(0),\n });\n\n // WHEN\n const result = command.parseResponse(response);\n\n // THEN\n expect(result).toStrictEqual(\n CommandResultFactory({\n error: BtcAppCommandErrorFactory({\n ...BTC_APP_ERRORS[\"6d00\"],\n errorCode: \"6d00\",\n }),\n }),\n );\n });\n\n it(\"should return an error if the response is too short\", () => {\n // GIVEN\n command = new GetExtendedPublicKeyCommand(defaultArgs);\n const response = new ApduResponse({\n data: Uint8Array.from([]),\n statusCode: new Uint8Array([0x90, 0x00]),\n });\n\n // WHEN\n const result = command.parseResponse(response);\n\n // THEN\n expect(result).toStrictEqual(\n CommandResultFactory({\n error: new InvalidStatusWordError(\"Invalid response length\"),\n }),\n );\n });\n });\n});\n"],
5
5
  "mappings": "AAAA,OACE,gBAAAA,EACA,wBAAAC,EACA,0BAAAC,MACK,kCAEP,OACE,kBAAAC,EACA,6BAAAC,MACK,sDAEP,OACE,+BAAAC,MAEK,gCAEP,MAAMC,EAA4C,IAAI,WAAW,CAC/D,IAAM,EAAM,EAAM,EAAM,GAAM,EAAM,EAAM,IAAM,EAAM,EAAM,GAAM,IAAM,EACxE,EAAM,EAAM,IAAM,EAAM,EAAM,CAChC,CAAC,EAEKC,EAA+C,IAAI,WAAW,CAClE,IAAM,EAAM,EAAM,EAAM,GAAM,EAAM,EAAM,IAAM,EAAM,EAAM,GAAM,IAAM,EACxE,EAAM,EAA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IAAM,CAE9DO,EAAU,IAAIL,EAA4BM,CAAW,EACrD,MAAME,EAAW,IAAIb,EAAa,CAChC,KAAM,WAAW,KAAK,CAAC,CAAC,EACxB,WAAY,IAAI,WAAW,CAAC,IAAM,CAAI,CAAC,CACzC,CAAC,EAGKc,EAASJ,EAAQ,cAAcG,CAAQ,EAG7C,OAAOC,CAAM,EAAE,cACbb,EAAqB,CACnB,MAAO,IAAIC,EAAuB,yBAAyB,CAC7D,CAAC,CACH,CACF,CAAC,CACH,CAAC,CACH,CAAC",
6
6
  "names": ["ApduResponse", "CommandResultFactory", "InvalidStatusWordError", "BTC_APP_ERRORS", "BtcAppCommandErrorFactory", "GetExtendedPublicKeyCommand", "GET_EXTENDED_PUBLIC_KEY_APDU_WITH_DISPLAY", "GET_EXTENDED_PUBLIC_KEY_APDU_WITHOUT_DISPLAY", "GET_EXTENDED_PUBLIC_KEY_APDU_WITH_OTHER_DERIVATION_PATH", "GET_EXTENDED_PUBLIC_KEY_VALID_RESPONSE", "command", "defaultArgs", "apdu", "response", "result"]
7
7
  }
@@ -1,2 +1,2 @@
1
- import{ApduBuilder as n,ApduParser as o,CommandResultFactory as t,InvalidStatusWordError as s}from"@ledgerhq/device-management-kit";import{CommandErrorHelper as p}from"@ledgerhq/signer-utils";import{Maybe as a}from"purify-ts";import{BTC_APP_ERRORS as i,BtcAppCommandErrorFactory as m}from"../../app-binder/command/utils/bitcoinAppErrors";import{BtcCommandUtils as d}from"../../utils/BtcCommandUtils";const u=4;class F{constructor(r=new p(i,m,d.isSuccessResponse)){this._errorHelper=r}name="getMasterFingerprint";getApdu(){const r={cla:225,ins:5,p1:0,p2:0};return new n(r).build()}parseResponse(r){return a.fromNullable(this._errorHelper.getError(r)).orDefaultLazy(()=>{const e=new o(r).extractFieldByLength(u);return e?t({data:{masterFingerprint:e}}):t({error:new s("Master fingerprint is missing")})})}}export{F as GetMasterFingerprintCommand};
1
+ import{ApduBuilder as n,ApduParser as o,CommandResultFactory as t,InvalidStatusWordError as s}from"@ledgerhq/device-management-kit";import{CommandErrorHelper as p}from"@ledgerhq/signer-utils";import{Maybe as a}from"purify-ts";import{BTC_APP_ERRORS as m,BtcAppCommandErrorFactory as i}from"../../app-binder/command/utils/bitcoinAppErrors";import{PROTOCOL_VERSION as d}from"../../app-binder/command/utils/constants";import{BtcCommandUtils as u}from"../../utils/BtcCommandUtils";const l=4;class B{constructor(r=new p(m,i,u.isSuccessResponse)){this._errorHelper=r}name="getMasterFingerprint";getApdu(){const r={cla:225,ins:5,p1:0,p2:d};return new n(r).build()}parseResponse(r){return a.fromNullable(this._errorHelper.getError(r)).orDefaultLazy(()=>{const e=new o(r).extractFieldByLength(l);return e?t({data:{masterFingerprint:e}}):t({error:new s("Master fingerprint is missing")})})}}export{B as GetMasterFingerprintCommand};
2
2
  //# sourceMappingURL=GetMasterFingerprintCommand.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/internal/app-binder/command/GetMasterFingerprintCommand.ts"],
4
- "sourcesContent": ["// https://github.com/LedgerHQ/app-bitcoin-new/blob/master/doc/bitcoin.md#get_master_fingerprint\nimport {\n type Apdu,\n ApduBuilder,\n type ApduBuilderArgs,\n ApduParser,\n type ApduResponse,\n type Command,\n type CommandResult,\n CommandResultFactory,\n InvalidStatusWordError,\n} from \"@ledgerhq/device-management-kit\";\nimport { CommandErrorHelper } from \"@ledgerhq/signer-utils\";\nimport { Maybe } from \"purify-ts\";\n\nimport {\n BTC_APP_ERRORS,\n BtcAppCommandErrorFactory,\n type BtcErrorCodes,\n} from \"@internal/app-binder/command/utils/bitcoinAppErrors\";\nimport { BtcCommandUtils } from \"@internal/utils/BtcCommandUtils\";\n\nconst MASTER_FINGERPRINT_LENGTH = 4;\n\ntype GetMasterFingerprintCommandResponse = {\n masterFingerprint: Uint8Array;\n};\n\nexport class GetMasterFingerprintCommand\n implements Command<GetMasterFingerprintCommandResponse, void, BtcErrorCodes>\n{\n readonly name = \"getMasterFingerprint\";\n constructor(\n private readonly _errorHelper = new CommandErrorHelper<\n GetMasterFingerprintCommandResponse,\n BtcErrorCodes\n >(\n BTC_APP_ERRORS,\n BtcAppCommandErrorFactory,\n BtcCommandUtils.isSuccessResponse,\n ),\n ) {}\n getApdu(): Apdu {\n const getMasterFingerprintArgs: ApduBuilderArgs = {\n cla: 0xe1,\n ins: 0x05,\n p1: 0x00,\n p2: 0x00,\n };\n return new ApduBuilder(getMasterFingerprintArgs).build();\n }\n\n parseResponse(\n response: ApduResponse,\n ): CommandResult<GetMasterFingerprintCommandResponse, BtcErrorCodes> {\n return Maybe.fromNullable(\n this._errorHelper.getError(response),\n ).orDefaultLazy(() => {\n const parser = new ApduParser(response);\n\n const masterFingerprint = parser.extractFieldByLength(\n MASTER_FINGERPRINT_LENGTH,\n );\n if (!masterFingerprint) {\n return CommandResultFactory({\n error: new InvalidStatusWordError(\"Master fingerprint is missing\"),\n });\n }\n\n return CommandResultFactory({\n data: {\n masterFingerprint,\n },\n });\n });\n }\n}\n"],
5
- "mappings": "AACA,OAEE,eAAAA,EAEA,cAAAC,EAIA,wBAAAC,EACA,0BAAAC,MACK,kCACP,OAAS,sBAAAC,MAA0B,yBACnC,OAAS,SAAAC,MAAa,YAEtB,OACE,kBAAAC,EACA,6BAAAC,MAEK,sDACP,OAAS,mBAAAC,MAAuB,kCAEhC,MAAMC,EAA4B,EAM3B,MAAMC,CAEb,CAEE,YACmBC,EAAe,IAAIP,EAIlCE,EACAC,EACAC,EAAgB,iBAClB,EACA,CARiB,kBAAAG,CAQhB,CAVM,KAAO,uBAWhB,SAAgB,CACd,MAAMC,EAA4C,CAChD,IAAK,IACL,IAAK,EACL,GAAI,EACJ,GAAI,CACN,EACA,OAAO,IAAIZ,EAAYY,CAAwB,EAAE,MAAM,CACzD,CAEA,cACEC,EACmE,CACnE,OAAOR,EAAM,aACX,KAAK,aAAa,SAASQ,CAAQ,CACrC,EAAE,cAAc,IAAM,CAGpB,MAAMC,EAFS,IAAIb,EAAWY,CAAQ,EAEL,qBAC/BJ,CACF,EACA,OAAKK,EAMEZ,EAAqB,CAC1B,KAAM,CACJ,kBAAAY,CACF,CACF,CAAC,EATQZ,EAAqB,CAC1B,MAAO,IAAIC,EAAuB,+BAA+B,CACnE,CAAC,CAQL,CAAC,CACH,CACF",
6
- "names": ["ApduBuilder", "ApduParser", "CommandResultFactory", "InvalidStatusWordError", "CommandErrorHelper", "Maybe", "BTC_APP_ERRORS", "BtcAppCommandErrorFactory", "BtcCommandUtils", "MASTER_FINGERPRINT_LENGTH", "GetMasterFingerprintCommand", "_errorHelper", "getMasterFingerprintArgs", "response", "masterFingerprint"]
4
+ "sourcesContent": ["// https://github.com/LedgerHQ/app-bitcoin-new/blob/master/doc/bitcoin.md#get_master_fingerprint\nimport {\n type Apdu,\n ApduBuilder,\n type ApduBuilderArgs,\n ApduParser,\n type ApduResponse,\n type Command,\n type CommandResult,\n CommandResultFactory,\n InvalidStatusWordError,\n} from \"@ledgerhq/device-management-kit\";\nimport { CommandErrorHelper } from \"@ledgerhq/signer-utils\";\nimport { Maybe } from \"purify-ts\";\n\nimport {\n BTC_APP_ERRORS,\n BtcAppCommandErrorFactory,\n type BtcErrorCodes,\n} from \"@internal/app-binder/command/utils/bitcoinAppErrors\";\nimport { PROTOCOL_VERSION } from \"@internal/app-binder/command/utils/constants\";\nimport { BtcCommandUtils } from \"@internal/utils/BtcCommandUtils\";\n\nconst MASTER_FINGERPRINT_LENGTH = 4;\n\ntype GetMasterFingerprintCommandResponse = {\n masterFingerprint: Uint8Array;\n};\n\nexport class GetMasterFingerprintCommand\n implements Command<GetMasterFingerprintCommandResponse, void, BtcErrorCodes>\n{\n readonly name = \"getMasterFingerprint\";\n constructor(\n private readonly _errorHelper = new CommandErrorHelper<\n GetMasterFingerprintCommandResponse,\n BtcErrorCodes\n >(\n BTC_APP_ERRORS,\n BtcAppCommandErrorFactory,\n BtcCommandUtils.isSuccessResponse,\n ),\n ) {}\n getApdu(): Apdu {\n const getMasterFingerprintArgs: ApduBuilderArgs = {\n cla: 0xe1,\n ins: 0x05,\n p1: 0x00,\n p2: PROTOCOL_VERSION,\n };\n return new ApduBuilder(getMasterFingerprintArgs).build();\n }\n\n parseResponse(\n response: ApduResponse,\n ): CommandResult<GetMasterFingerprintCommandResponse, BtcErrorCodes> {\n return Maybe.fromNullable(\n this._errorHelper.getError(response),\n ).orDefaultLazy(() => {\n const parser = new ApduParser(response);\n\n const masterFingerprint = parser.extractFieldByLength(\n MASTER_FINGERPRINT_LENGTH,\n );\n if (!masterFingerprint) {\n return CommandResultFactory({\n error: new InvalidStatusWordError(\"Master fingerprint is missing\"),\n });\n }\n\n return CommandResultFactory({\n data: {\n masterFingerprint,\n },\n });\n });\n }\n}\n"],
5
+ "mappings": "AACA,OAEE,eAAAA,EAEA,cAAAC,EAIA,wBAAAC,EACA,0BAAAC,MACK,kCACP,OAAS,sBAAAC,MAA0B,yBACnC,OAAS,SAAAC,MAAa,YAEtB,OACE,kBAAAC,EACA,6BAAAC,MAEK,sDACP,OAAS,oBAAAC,MAAwB,+CACjC,OAAS,mBAAAC,MAAuB,kCAEhC,MAAMC,EAA4B,EAM3B,MAAMC,CAEb,CAEE,YACmBC,EAAe,IAAIR,EAIlCE,EACAC,EACAE,EAAgB,iBAClB,EACA,CARiB,kBAAAG,CAQhB,CAVM,KAAO,uBAWhB,SAAgB,CACd,MAAMC,EAA4C,CAChD,IAAK,IACL,IAAK,EACL,GAAI,EACJ,GAAIL,CACN,EACA,OAAO,IAAIR,EAAYa,CAAwB,EAAE,MAAM,CACzD,CAEA,cACEC,EACmE,CACnE,OAAOT,EAAM,aACX,KAAK,aAAa,SAASS,CAAQ,CACrC,EAAE,cAAc,IAAM,CAGpB,MAAMC,EAFS,IAAId,EAAWa,CAAQ,EAEL,qBAC/BJ,CACF,EACA,OAAKK,EAMEb,EAAqB,CAC1B,KAAM,CACJ,kBAAAa,CACF,CACF,CAAC,EATQb,EAAqB,CAC1B,MAAO,IAAIC,EAAuB,+BAA+B,CACnE,CAAC,CAQL,CAAC,CACH,CACF",
6
+ "names": ["ApduBuilder", "ApduParser", "CommandResultFactory", "InvalidStatusWordError", "CommandErrorHelper", "Maybe", "BTC_APP_ERRORS", "BtcAppCommandErrorFactory", "PROTOCOL_VERSION", "BtcCommandUtils", "MASTER_FINGERPRINT_LENGTH", "GetMasterFingerprintCommand", "_errorHelper", "getMasterFingerprintArgs", "response", "masterFingerprint"]
7
7
  }
@@ -1,2 +1,2 @@
1
- import{ApduResponse as s,CommandResultFactory as a,isSuccessCommandResult as n}from"@ledgerhq/device-management-kit";import{InvalidStatusWordError as i}from"@ledgerhq/device-management-kit";import{GetMasterFingerprintCommand as p}from"./GetMasterFingerprintCommand";const c=new Uint8Array([225,5,0,0,0]),o=new Uint8Array([130,141,194,243]);describe("GetMasterFingerprintCommand",()=>{let t;beforeEach(()=>{t=new p}),describe("name",()=>{it("should be 'getMasterFingerprint'",()=>{expect(t.name).toBe("getMasterFingerprint")})}),describe("getApdu",()=>{it("returns the correct APDU",()=>{const e=t.getApdu();expect(e.getRawApdu()).toEqual(c)})}),describe("parseResponse",()=>{it("should return the master fingerprint",()=>{const e=new s({data:o,statusCode:new Uint8Array([144,0])}),r=t.parseResponse(e);expect(r).toEqual(a({data:{masterFingerprint:Uint8Array.from([130,141,194,243])}}))}),it("should return an error if the response is not successful",()=>{const e=new s({statusCode:Uint8Array.from([109,0]),data:new Uint8Array(0)}),r=t.parseResponse(e);expect(n(r)).toBe(!1)}),it("should return an error if the response is too short",()=>{const e=new s({data:o.slice(0,2),statusCode:new Uint8Array([144,0])}),r=t.parseResponse(e);n(r)?assert.fail("Expected an error, but the result was successful"):expect(r.error).toEqual(new i("Master fingerprint is missing"))})})});
1
+ import{ApduResponse as s,CommandResultFactory as a,isSuccessCommandResult as n}from"@ledgerhq/device-management-kit";import{InvalidStatusWordError as i}from"@ledgerhq/device-management-kit";import{GetMasterFingerprintCommand as p}from"./GetMasterFingerprintCommand";const c=new Uint8Array([225,5,0,1,0]),o=new Uint8Array([130,141,194,243]);describe("GetMasterFingerprintCommand",()=>{let t;beforeEach(()=>{t=new p}),describe("name",()=>{it("should be 'getMasterFingerprint'",()=>{expect(t.name).toBe("getMasterFingerprint")})}),describe("getApdu",()=>{it("returns the correct APDU",()=>{const e=t.getApdu();expect(e.getRawApdu()).toEqual(c)})}),describe("parseResponse",()=>{it("should return the master fingerprint",()=>{const e=new s({data:o,statusCode:new Uint8Array([144,0])}),r=t.parseResponse(e);expect(r).toEqual(a({data:{masterFingerprint:Uint8Array.from([130,141,194,243])}}))}),it("should return an error if the response is not successful",()=>{const e=new s({statusCode:Uint8Array.from([109,0]),data:new Uint8Array(0)}),r=t.parseResponse(e);expect(n(r)).toBe(!1)}),it("should return an error if the response is too short",()=>{const e=new s({data:o.slice(0,2),statusCode:new Uint8Array([144,0])}),r=t.parseResponse(e);n(r)?assert.fail("Expected an error, but the result was successful"):expect(r.error).toEqual(new i("Master fingerprint is missing"))})})});
2
2
  //# sourceMappingURL=GetMasterFingerprintCommand.test.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/internal/app-binder/command/GetMasterFingerprintCommand.test.ts"],
4
- "sourcesContent": ["import {\n ApduResponse,\n CommandResultFactory,\n isSuccessCommandResult,\n} from \"@ledgerhq/device-management-kit\";\nimport { InvalidStatusWordError } from \"@ledgerhq/device-management-kit\";\n\nimport { GetMasterFingerprintCommand } from \"./GetMasterFingerprintCommand\";\n\nconst GET_MASTER_FINGERPRINT_APDU = new Uint8Array([\n 0xe1, 0x05, 0x00, 0x00, 0x00,\n]);\n\nconst GET_MASTER_FINGERPRINT_RESPONSE = new Uint8Array([\n 0x82, 0x8d, 0xc2, 0xf3,\n]);\n\ndescribe(\"GetMasterFingerprintCommand\", () => {\n let command: GetMasterFingerprintCommand;\n\n beforeEach(() => {\n command = new GetMasterFingerprintCommand();\n });\n\n describe(\"name\", () => {\n it(\"should be 'getMasterFingerprint'\", () => {\n expect(command.name).toBe(\"getMasterFingerprint\");\n });\n });\n\n describe(\"getApdu\", () => {\n it(\"returns the correct APDU\", () => {\n // WHEN\n const apdu = command.getApdu();\n\n // THEN\n expect(apdu.getRawApdu()).toEqual(GET_MASTER_FINGERPRINT_APDU);\n });\n });\n\n describe(\"parseResponse\", () => {\n it(\"should return the master fingerprint\", () => {\n // GIVEN\n const response = new ApduResponse({\n data: GET_MASTER_FINGERPRINT_RESPONSE,\n statusCode: new Uint8Array([0x90, 0x00]),\n });\n\n // WHEN\n const result = command.parseResponse(response);\n\n // THEN\n expect(result).toEqual(\n CommandResultFactory({\n data: {\n masterFingerprint: Uint8Array.from([0x82, 0x8d, 0xc2, 0xf3]),\n },\n }),\n );\n });\n\n it(\"should return an error if the response is not successful\", () => {\n // GIVEN\n const response = new ApduResponse({\n statusCode: Uint8Array.from([0x6d, 0x00]),\n data: new Uint8Array(0),\n });\n\n // WHEN\n const result = command.parseResponse(response);\n\n // THEN\n expect(isSuccessCommandResult(result)).toBe(false);\n });\n\n it(\"should return an error if the response is too short\", () => {\n // GIVEN\n const response = new ApduResponse({\n data: GET_MASTER_FINGERPRINT_RESPONSE.slice(0, 2),\n statusCode: new Uint8Array([0x90, 0x00]),\n });\n\n // WHEN\n const result = command.parseResponse(response);\n\n // THEN\n if (!isSuccessCommandResult(result)) {\n expect(result.error).toEqual(\n new InvalidStatusWordError(\"Master fingerprint is missing\"),\n );\n } else {\n assert.fail(\"Expected an error, but the result was successful\");\n }\n });\n });\n});\n"],
4
+ "sourcesContent": ["import {\n ApduResponse,\n CommandResultFactory,\n isSuccessCommandResult,\n} from \"@ledgerhq/device-management-kit\";\nimport { InvalidStatusWordError } from \"@ledgerhq/device-management-kit\";\n\nimport { GetMasterFingerprintCommand } from \"./GetMasterFingerprintCommand\";\n\nconst GET_MASTER_FINGERPRINT_APDU = new Uint8Array([\n 0xe1, 0x05, 0x00, 0x01, 0x00,\n]);\n\nconst GET_MASTER_FINGERPRINT_RESPONSE = new Uint8Array([\n 0x82, 0x8d, 0xc2, 0xf3,\n]);\n\ndescribe(\"GetMasterFingerprintCommand\", () => {\n let command: GetMasterFingerprintCommand;\n\n beforeEach(() => {\n command = new GetMasterFingerprintCommand();\n });\n\n describe(\"name\", () => {\n it(\"should be 'getMasterFingerprint'\", () => {\n expect(command.name).toBe(\"getMasterFingerprint\");\n });\n });\n\n describe(\"getApdu\", () => {\n it(\"returns the correct APDU\", () => {\n // WHEN\n const apdu = command.getApdu();\n\n // THEN\n expect(apdu.getRawApdu()).toEqual(GET_MASTER_FINGERPRINT_APDU);\n });\n });\n\n describe(\"parseResponse\", () => {\n it(\"should return the master fingerprint\", () => {\n // GIVEN\n const response = new ApduResponse({\n data: GET_MASTER_FINGERPRINT_RESPONSE,\n statusCode: new Uint8Array([0x90, 0x00]),\n });\n\n // WHEN\n const result = command.parseResponse(response);\n\n // THEN\n expect(result).toEqual(\n CommandResultFactory({\n data: {\n masterFingerprint: Uint8Array.from([0x82, 0x8d, 0xc2, 0xf3]),\n },\n }),\n );\n });\n\n it(\"should return an error if the response is not successful\", () => {\n // GIVEN\n const response = new ApduResponse({\n statusCode: Uint8Array.from([0x6d, 0x00]),\n data: new Uint8Array(0),\n });\n\n // WHEN\n const result = command.parseResponse(response);\n\n // THEN\n expect(isSuccessCommandResult(result)).toBe(false);\n });\n\n it(\"should return an error if the response is too short\", () => {\n // GIVEN\n const response = new ApduResponse({\n data: GET_MASTER_FINGERPRINT_RESPONSE.slice(0, 2),\n statusCode: new Uint8Array([0x90, 0x00]),\n });\n\n // WHEN\n const result = command.parseResponse(response);\n\n // THEN\n if (!isSuccessCommandResult(result)) {\n expect(result.error).toEqual(\n new InvalidStatusWordError(\"Master fingerprint is missing\"),\n );\n } else {\n assert.fail(\"Expected an error, but the result was successful\");\n }\n });\n });\n});\n"],
5
5
  "mappings": "AAAA,OACE,gBAAAA,EACA,wBAAAC,EACA,0BAAAC,MACK,kCACP,OAAS,0BAAAC,MAA8B,kCA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EAChD,WAAY,IAAI,WAAW,CAAC,IAAM,CAAI,CAAC,CACzC,CAAC,EAGKI,EAASH,EAAQ,cAAcE,CAAQ,EAGxCP,EAAuBQ,CAAM,EAKhC,OAAO,KAAK,kDAAkD,EAJ9D,OAAOA,EAAO,KAAK,EAAE,QACnB,IAAIP,EAAuB,+BAA+B,CAC5D,CAIJ,CAAC,CACH,CAAC,CACH,CAAC",
6
6
  "names": ["ApduResponse", "CommandResultFactory", "isSuccessCommandResult", "InvalidStatusWordError", "GetMasterFingerprintCommand", "GET_MASTER_FINGERPRINT_APDU", "GET_MASTER_FINGERPRINT_RESPONSE", "command", "apdu", "response", "result"]
7
7
  }
@@ -0,0 +1,2 @@
1
+ const o="Bitcoin";export{o as APP_NAME};
2
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/internal/app-binder/constants.ts"],
4
+ "sourcesContent": ["export const APP_NAME = \"Bitcoin\";\n"],
5
+ "mappings": "AAAO,MAAMA,EAAW",
6
+ "names": ["APP_NAME"]
7
+ }
@@ -1,2 +1,2 @@
1
- import{isSuccessCommandResult as o,OpenAppDeviceAction as W,UnknownDAError as m,UserInteractionRequired as l,XStateDeviceAction as S}from"@ledgerhq/device-management-kit";import{Left as y,Right as D}from"purify-ts";import{assign as r,fromPromise as d,setup as w}from"xstate";import{GetWalletAddressTask as I}from"../../../app-binder/task/GetWalletAddressTask";import{PrepareWalletPolicyTask as g}from"../../../app-binder/task/PrepareWalletPolicyTask";class k extends S{makeStateMachine(a){const{getWalletAddress:i,prepareWalletPolicy:s}=this.extractDependencies(a);return w({types:{input:{},context:{},output:{}},actors:{openAppStateMachine:new W({input:{appName:"Bitcoin"}}).makeStateMachine(a),prepareWalletPolicy:d(s),getWalletAddress:d(i)},guards:{noInternalError:({context:e})=>e._internalState.error===null,skipOpenApp:({context:e})=>e.input.skipOpenApp},actions:{assignErrorFromEvent:r({_internalState:e=>({...e.context._internalState,error:e.event.error})})}}).createMachine({id:"GetWalletAddressDeviceAction",initial:"InitialState",context:({input:e})=>({input:e,intermediateValue:{requiredUserInteraction:l.None},_internalState:{error:null,wallet:null,walletAddress:null}}),states:{InitialState:{always:[{target:"PrepareWalletPolicy",guard:"skipOpenApp"},"OpenAppDeviceAction"]},OpenAppDeviceAction:{exit:r({intermediateValue:{requiredUserInteraction:l.None}}),invoke:{id:"openAppStateMachine",input:{appName:"Bitcoin"},src:"openAppStateMachine",onSnapshot:{actions:r({intermediateValue:e=>e.event.snapshot.context.intermediateValue})},onDone:{actions:r({_internalState:e=>e.event.output.caseOf({Right:()=>e.context._internalState,Left:t=>({...e.context._internalState,error:t})})}),target:"CheckOpenAppDeviceActionResult"}}},CheckOpenAppDeviceActionResult:{always:[{target:"PrepareWalletPolicy",guard:"noInternalError"},"Error"]},PrepareWalletPolicy:{invoke:{id:"prepareWalletPolicy",src:"prepareWalletPolicy",input:({context:e})=>({wallet:e.input.wallet,walletBuilder:e.input.walletBuilder}),onDone:{target:"PrepareWalletPolicyResultCheck",actions:r({_internalState:({event:e,context:t})=>o(e.output)?{...t._internalState,wallet:e.output.data}:{...t._internalState,error:e.output.error}})},onError:{target:"Error",actions:"assignErrorFromEvent"}}},PrepareWalletPolicyResultCheck:{always:[{guard:"noInternalError",target:"GetWalletAddress"},{target:"Error"}]},GetWalletAddress:{entry:r(({context:e})=>({intermediateValue:{requiredUserInteraction:e.input.checkOnDevice?l.VerifyAddress:l.None}})),exit:r({intermediateValue:{requiredUserInteraction:l.None}}),invoke:{id:"getWalletAddress",src:"getWalletAddress",input:({context:e})=>({checkOnDevice:e.input.checkOnDevice,wallet:e._internalState.wallet,change:e.input.change,addressIndex:e.input.addressIndex,dataStoreService:e.input.dataStoreService,walletSerializer:e.input.walletSerializer,walletBuilder:e.input.walletBuilder}),onDone:{target:"GetWalletAddressResultCheck",actions:r({_internalState:({event:e,context:t})=>o(e.output)?{...t._internalState,walletAddress:e.output.data}:{...t._internalState,error:e.output.error}})},onError:{target:"Error",actions:"assignErrorFromEvent"}}},GetWalletAddressResultCheck:{always:[{guard:"noInternalError",target:"Success"},{target:"Error"}]},Success:{type:"final"},Error:{type:"final"}},output:({context:e})=>e._internalState.walletAddress?D(e._internalState.walletAddress):y(e._internalState.error||new m("No error in final state"))})}extractDependencies(a){return{getWalletAddress:async e=>{const{checkOnDevice:t,wallet:n,change:p,addressIndex:c,walletSerializer:u,dataStoreService:A}=e.input;return await new I(a,{checkOnDevice:t,wallet:n,change:p,addressIndex:c},u,A).run()},prepareWalletPolicy:async e=>{const{input:{walletBuilder:t,wallet:n}}=e;return await new g(a,{wallet:n},t).run()}}}}export{k as GetWalletAddressDeviceAction};
1
+ import{isSuccessCommandResult as d,OpenAppDeviceAction as m,UnknownDAError as D,UserInteractionRequired as a,XStateDeviceAction as y}from"@ledgerhq/device-management-kit";import{Left as E,Right as w}from"purify-ts";import{assign as r,fromPromise as p,setup as I}from"xstate";import{getWalletAddressDAStateSteps as l}from"../../../../api/app-binder/GetWalletAddressDeviceActionTypes";import{APP_NAME as c}from"../../../app-binder/constants";import{GetWalletAddressTask as P}from"../../../app-binder/task/GetWalletAddressTask";import{PrepareWalletPolicyTask as g}from"../../../app-binder/task/PrepareWalletPolicyTask";class R extends y{makeStateMachine(n){const{getWalletAddress:s,prepareWalletPolicy:o}=this.extractDependencies(n);return I({types:{input:{},context:{},output:{}},actors:{openAppStateMachine:new m({input:{appName:c}}).makeStateMachine(n),prepareWalletPolicy:p(o),getWalletAddress:p(s)},guards:{noInternalError:({context:e})=>e._internalState.error===null,skipOpenApp:({context:e})=>e.input.skipOpenApp},actions:{assignErrorFromEvent:r({_internalState:e=>({...e.context._internalState,error:e.event.error})})}}).createMachine({id:"GetWalletAddressDeviceAction",initial:"InitialState",context:({input:e})=>({input:e,intermediateValue:{requiredUserInteraction:a.None,step:l.OPEN_APP},_internalState:{error:null,wallet:null,walletAddress:null}}),states:{InitialState:{always:[{target:"PrepareWalletPolicy",guard:"skipOpenApp"},"OpenAppDeviceAction"]},OpenAppDeviceAction:{entry:r({intermediateValue:()=>({requiredUserInteraction:a.None,step:l.OPEN_APP})}),invoke:{id:"openAppStateMachine",input:{appName:c},src:"openAppStateMachine",onSnapshot:{actions:r({intermediateValue:({event:e})=>({...e.snapshot.context.intermediateValue,step:l.OPEN_APP})})},onDone:{actions:r({_internalState:({event:e,context:t})=>e.output.caseOf({Right:()=>t._internalState,Left:i=>({...t._internalState,error:i})})}),target:"CheckOpenAppDeviceActionResult"}}},CheckOpenAppDeviceActionResult:{always:[{target:"PrepareWalletPolicy",guard:"noInternalError"},"Error"]},PrepareWalletPolicy:{entry:r({intermediateValue:()=>({requiredUserInteraction:a.None,step:l.PREPARE_WALLET_POLICY})}),invoke:{id:"prepareWalletPolicy",src:"prepareWalletPolicy",input:({context:e})=>({wallet:e.input.wallet,walletBuilder:e.input.walletBuilder}),onDone:{target:"PrepareWalletPolicyResultCheck",actions:r({_internalState:({event:e,context:t})=>d(e.output)?{...t._internalState,wallet:e.output.data}:{...t._internalState,error:e.output.error}})},onError:{target:"Error",actions:"assignErrorFromEvent"}}},PrepareWalletPolicyResultCheck:{always:[{guard:"noInternalError",target:"GetWalletAddress"},{target:"Error"}]},GetWalletAddress:{entry:r(({context:e})=>({intermediateValue:{requiredUserInteraction:e.input.checkOnDevice?a.VerifyAddress:a.None,step:l.GET_WALLET_ADDRESS}})),exit:r({intermediateValue:{requiredUserInteraction:a.None,step:l.GET_WALLET_ADDRESS}}),invoke:{id:"getWalletAddress",src:"getWalletAddress",input:({context:e})=>({checkOnDevice:e.input.checkOnDevice,wallet:e._internalState.wallet,change:e.input.change,addressIndex:e.input.addressIndex,dataStoreService:e.input.dataStoreService,walletSerializer:e.input.walletSerializer,walletBuilder:e.input.walletBuilder}),onDone:{target:"GetWalletAddressResultCheck",actions:r({_internalState:({event:e,context:t})=>d(e.output)?{...t._internalState,walletAddress:e.output.data}:{...t._internalState,error:e.output.error}})},onError:{target:"Error",actions:"assignErrorFromEvent"}}},GetWalletAddressResultCheck:{always:[{guard:"noInternalError",target:"Success"},{target:"Error"}]},Success:{type:"final"},Error:{type:"final"}},output:({context:e})=>e._internalState.walletAddress?w(e._internalState.walletAddress):E(e._internalState.error||new D("No error in final state"))})}extractDependencies(n){return{getWalletAddress:async e=>{const{checkOnDevice:t,wallet:i,change:u,addressIndex:A,walletSerializer:W,dataStoreService:S}=e.input;return await new P(n,{checkOnDevice:t,wallet:i,change:u,addressIndex:A},W,S).run()},prepareWalletPolicy:async e=>{const{input:{walletBuilder:t,wallet:i}}=e;return await new g(n,{wallet:i},t).run()}}}}export{R as GetWalletAddressDeviceAction};
2
2
  //# sourceMappingURL=GetWalletAddressDeviceAction.js.map