@ledgerhq/device-signer-kit-bitcoin 0.0.0-wrong-error-when-in-experimental-provider-20251021161219 → 0.0.0-z-intent-queue-7-20251204111630
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.
- package/lib/cjs/internal/app-binder/command/ContinueCommand.js +1 -1
- package/lib/cjs/internal/app-binder/command/ContinueCommand.js.map +2 -2
- package/lib/cjs/internal/app-binder/command/ContinueCommand.test.js +1 -1
- package/lib/cjs/internal/app-binder/command/ContinueCommand.test.js.map +3 -3
- package/lib/cjs/internal/app-binder/command/GetExtendedPublicKeyCommand.js +1 -1
- package/lib/cjs/internal/app-binder/command/GetExtendedPublicKeyCommand.js.map +2 -2
- package/lib/cjs/internal/app-binder/command/GetExtendedPublicKeyCommand.test.js +1 -1
- package/lib/cjs/internal/app-binder/command/GetExtendedPublicKeyCommand.test.js.map +2 -2
- package/lib/cjs/internal/app-binder/command/GetMasterFingerprintCommand.js +1 -1
- package/lib/cjs/internal/app-binder/command/GetMasterFingerprintCommand.js.map +2 -2
- package/lib/cjs/internal/app-binder/command/GetMasterFingerprintCommand.test.js +1 -1
- package/lib/cjs/internal/app-binder/command/GetMasterFingerprintCommand.test.js.map +2 -2
- package/lib/cjs/internal/app-binder/command/GetWalletAddressCommand.js +1 -1
- package/lib/cjs/internal/app-binder/command/GetWalletAddressCommand.js.map +2 -2
- package/lib/cjs/internal/app-binder/command/GetWalletAddressCommand.test.js +1 -1
- package/lib/cjs/internal/app-binder/command/GetWalletAddressCommand.test.js.map +2 -2
- package/lib/cjs/internal/app-binder/command/RegisterWalletAddressCommand.js +1 -1
- package/lib/cjs/internal/app-binder/command/RegisterWalletAddressCommand.js.map +2 -2
- package/lib/cjs/internal/app-binder/command/RegisterWalletAddressCommand.test.js +1 -1
- package/lib/cjs/internal/app-binder/command/RegisterWalletAddressCommand.test.js.map +2 -2
- package/lib/cjs/internal/app-binder/command/SignMessageCommand.js +1 -1
- package/lib/cjs/internal/app-binder/command/SignMessageCommand.js.map +2 -2
- package/lib/cjs/internal/app-binder/command/SignMessageCommand.test.js +1 -1
- package/lib/cjs/internal/app-binder/command/SignMessageCommand.test.js.map +3 -3
- package/lib/cjs/internal/app-binder/command/SignPsbtCommand.js +1 -1
- package/lib/cjs/internal/app-binder/command/SignPsbtCommand.js.map +2 -2
- package/lib/cjs/internal/app-binder/command/SignPsbtCommand.test.js +1 -1
- package/lib/cjs/internal/app-binder/command/SignPsbtCommand.test.js.map +2 -2
- package/lib/cjs/internal/app-binder/device-action/__test-utils__/makeInternalApi.js +1 -1
- package/lib/cjs/internal/app-binder/device-action/__test-utils__/makeInternalApi.js.map +3 -3
- package/lib/cjs/internal/psbt/service/key-pair/DefaultKeyPairSerializer.test.js +1 -1
- package/lib/cjs/internal/psbt/service/key-pair/DefaultKeyPairSerializer.test.js.map +1 -1
- package/lib/cjs/internal/psbt/service/psbt/DefaultPsbtSerializer.js.map +1 -1
- package/lib/cjs/package.json +43 -39
- package/lib/esm/internal/app-binder/command/ContinueCommand.js +1 -1
- package/lib/esm/internal/app-binder/command/ContinueCommand.js.map +2 -2
- package/lib/esm/internal/app-binder/command/ContinueCommand.test.js +1 -1
- package/lib/esm/internal/app-binder/command/ContinueCommand.test.js.map +3 -3
- package/lib/esm/internal/app-binder/command/GetExtendedPublicKeyCommand.js +1 -1
- package/lib/esm/internal/app-binder/command/GetExtendedPublicKeyCommand.js.map +2 -2
- package/lib/esm/internal/app-binder/command/GetExtendedPublicKeyCommand.test.js +1 -1
- package/lib/esm/internal/app-binder/command/GetExtendedPublicKeyCommand.test.js.map +2 -2
- package/lib/esm/internal/app-binder/command/GetMasterFingerprintCommand.js +1 -1
- package/lib/esm/internal/app-binder/command/GetMasterFingerprintCommand.js.map +2 -2
- package/lib/esm/internal/app-binder/command/GetMasterFingerprintCommand.test.js +1 -1
- package/lib/esm/internal/app-binder/command/GetMasterFingerprintCommand.test.js.map +2 -2
- package/lib/esm/internal/app-binder/command/GetWalletAddressCommand.js +1 -1
- package/lib/esm/internal/app-binder/command/GetWalletAddressCommand.js.map +2 -2
- package/lib/esm/internal/app-binder/command/GetWalletAddressCommand.test.js +1 -1
- package/lib/esm/internal/app-binder/command/GetWalletAddressCommand.test.js.map +2 -2
- package/lib/esm/internal/app-binder/command/RegisterWalletAddressCommand.js +1 -1
- package/lib/esm/internal/app-binder/command/RegisterWalletAddressCommand.js.map +2 -2
- package/lib/esm/internal/app-binder/command/RegisterWalletAddressCommand.test.js +1 -1
- package/lib/esm/internal/app-binder/command/RegisterWalletAddressCommand.test.js.map +2 -2
- package/lib/esm/internal/app-binder/command/SignMessageCommand.js +1 -1
- package/lib/esm/internal/app-binder/command/SignMessageCommand.js.map +2 -2
- package/lib/esm/internal/app-binder/command/SignMessageCommand.test.js +1 -1
- package/lib/esm/internal/app-binder/command/SignMessageCommand.test.js.map +3 -3
- package/lib/esm/internal/app-binder/command/SignPsbtCommand.js +1 -1
- package/lib/esm/internal/app-binder/command/SignPsbtCommand.js.map +2 -2
- package/lib/esm/internal/app-binder/command/SignPsbtCommand.test.js +1 -1
- package/lib/esm/internal/app-binder/command/SignPsbtCommand.test.js.map +2 -2
- package/lib/esm/internal/app-binder/device-action/__test-utils__/makeInternalApi.js +1 -1
- package/lib/esm/internal/app-binder/device-action/__test-utils__/makeInternalApi.js.map +3 -3
- package/lib/esm/internal/psbt/service/key-pair/DefaultKeyPairSerializer.test.js +1 -1
- package/lib/esm/internal/psbt/service/key-pair/DefaultKeyPairSerializer.test.js.map +1 -1
- package/lib/esm/internal/psbt/service/psbt/DefaultPsbtSerializer.js.map +1 -1
- package/lib/esm/package.json +43 -39
- package/lib/types/internal/app-binder/command/ContinueCommand.d.ts +1 -0
- package/lib/types/internal/app-binder/command/ContinueCommand.d.ts.map +1 -1
- package/lib/types/internal/app-binder/command/GetExtendedPublicKeyCommand.d.ts +1 -0
- package/lib/types/internal/app-binder/command/GetExtendedPublicKeyCommand.d.ts.map +1 -1
- package/lib/types/internal/app-binder/command/GetMasterFingerprintCommand.d.ts +1 -0
- package/lib/types/internal/app-binder/command/GetMasterFingerprintCommand.d.ts.map +1 -1
- package/lib/types/internal/app-binder/command/GetWalletAddressCommand.d.ts +1 -0
- package/lib/types/internal/app-binder/command/GetWalletAddressCommand.d.ts.map +1 -1
- package/lib/types/internal/app-binder/command/RegisterWalletAddressCommand.d.ts +1 -0
- package/lib/types/internal/app-binder/command/RegisterWalletAddressCommand.d.ts.map +1 -1
- package/lib/types/internal/app-binder/command/SignMessageCommand.d.ts +1 -0
- package/lib/types/internal/app-binder/command/SignMessageCommand.d.ts.map +1 -1
- package/lib/types/internal/app-binder/command/SignPsbtCommand.d.ts +1 -0
- package/lib/types/internal/app-binder/command/SignPsbtCommand.d.ts.map +1 -1
- package/lib/types/internal/app-binder/device-action/__test-utils__/makeInternalApi.d.ts.map +1 -1
- package/lib/types/internal/psbt/service/psbt/DefaultPsbtSerializer.d.ts +2 -2
- package/lib/types/tsconfig.prod.tsbuildinfo +1 -1
- package/package.json +38 -34
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/internal/app-binder/command/GetWalletAddressCommand.test.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n ApduResponse,\n CommandResultFactory,\n isSuccessCommandResult,\n} from \"@ledgerhq/device-management-kit\";\n\nimport { SW_INTERRUPTED_EXECUTION } from \"./utils/constants\";\nimport {\n GetWalletAddressCommand,\n type GetWalletAddressCommandArgs,\n} from \"./GetWalletAddressCommand\";\n\nconst SUCCESS_STATUS = new Uint8Array([0x90, 0x00]);\nconst USER_DENIED_STATUS = new Uint8Array([0x69, 0x85]);\n\ndescribe(\"GetWalletAddressCommand\", () => {\n let command: GetWalletAddressCommand;\n const defaultArgs: GetWalletAddressCommandArgs = {\n checkOnDevice: true,\n walletId: Uint8Array.from(\"walletIdBuffer\", (c) => c.charCodeAt(0)),\n walletHmac: Uint8Array.from(\"walletHmacBuffer\", (c) => c.charCodeAt(0)),\n change: false,\n addressIndex: 0x00000000,\n };\n\n beforeEach(() => {\n command = new GetWalletAddressCommand(defaultArgs);\n vi.clearAllMocks();\n vi.importActual(\"@ledgerhq/device-management-kit\");\n });\n\n describe(\"getApdu\", () => {\n it(\"should return correct APDU for default arguments\", () => {\n const apdu = command.getApdu();\n const expectedApdu = Uint8Array.from([\n 0xe1, // CLA\n 0x03, // INS\n 0x00, // P1\n 0x01, // P2\n 0x24, // Length of data: 36 bytes\n 0x01, // checkOnDevice: true\n ...Uint8Array.from(\"walletIdBuffer\", (c) => c.charCodeAt(0)),\n ...Uint8Array.from(\"walletHmacBuffer\", (c) => c.charCodeAt(0)),\n 0x00, // change: false\n 0x00,\n 0x00,\n 0x00,\n 0x00, // addressIndex: 0x00000000\n ]);\n expect(apdu.getRawApdu()).toEqual(expectedApdu);\n });\n\n it(\"should return correct APDU for different arguments\", () => {\n const args: GetWalletAddressCommandArgs = {\n checkOnDevice: false,\n walletId: Uint8Array.from(\"anotherWalletId\", (c) => c.charCodeAt(0)),\n walletHmac: Uint8Array.from(\"anotherWalletHmac\", (c) =>\n c.charCodeAt(0),\n ),\n change: true,\n addressIndex: 0x00000005,\n };\n command = new GetWalletAddressCommand(args);\n const apdu = command.getApdu();\n const expectedApdu = Uint8Array.from([\n 0xe1, // CLA\n 0x03, // INS\n 0x00, // P1\n 0x01, // P2\n 0x26, // Length of data\n 0x00, // checkOnDevice: false\n ...Uint8Array.from(\"anotherWalletId\", (c) => c.charCodeAt(0)),\n ...Uint8Array.from(\"anotherWalletHmac\", (c) => c.charCodeAt(0)),\n 0x01, // change: true\n 0x00,\n 0x00,\n 0x00,\n 0x05, // addressIndex: 0x00000005\n ]);\n expect(apdu.getRawApdu()).toEqual(expectedApdu);\n });\n });\n\n describe(\"parseResponse\", () => {\n it(\"should return the APDU response if it's a continue response\", () => {\n // given\n const continueResponseData = new Uint8Array([0x01, 0x02, 0x03, 0x04]);\n\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 it(\"should return an error if user denied the operation\", () => {\n // given\n const apduResponse = new ApduResponse({\n statusCode: USER_DENIED_STATUS,\n data: new Uint8Array([]),\n });\n\n // when\n const response = command.parseResponse(apduResponse);\n\n // then\n expect(isSuccessCommandResult(response)).toBe(false);\n if (!isSuccessCommandResult(response)) {\n expect(response.error).toBeDefined();\n }\n });\n\n it(\"should return correct data when response is not empty\", () => {\n // given\n const responseData = Uint8Array.from(\"addressData\", (c) =>\n c.charCodeAt(0),\n );\n\n const apduResponse = new ApduResponse({\n statusCode: SUCCESS_STATUS,\n data: responseData,\n });\n\n // when\n const response = command.parseResponse(apduResponse);\n\n // then\n expect(response).toStrictEqual(\n CommandResultFactory({ data: apduResponse }),\n );\n });\n });\n});\n"],
|
|
5
|
-
"mappings": "AAAA,OACE,gBAAAA,EACA,wBAAAC,EACA,0BAAAC,MACK,kCAEP,OAAS,4BAAAC,MAAgC,oBACzC,OACE,2BAAAC,MAEK,4BAEP,MAAMC,EAAiB,IAAI,WAAW,CAAC,IAAM,CAAI,CAAC,EAC5CC,EAAqB,IAAI,WAAW,CAAC,IAAM,GAAI,CAAC,EAEtD,SAAS,0BAA2B,IAAM,CACxC,IAAIC,EACJ,MAAMC,EAA2C,CAC/C,cAAe,GACf,SAAU,WAAW,KAAK,iBAAmBC,GAAMA,EAAE,WAAW,CAAC,CAAC,EAClE,WAAY,WAAW,KAAK,mBAAqBA,GAAMA,EAAE,WAAW,CAAC,CAAC,EACtE,OAAQ,GACR,aAAc,CAChB,EAEA,WAAW,IAAM,CACfF,EAAU,IAAIH,EAAwBI,CAAW,EACjD,GAAG,cAAc,EACjB,GAAG,aAAa,iCAAiC,CACnD,CAAC,EAED,SAAS,UAAW,IAAM,CACxB,GAAG,mDAAoD,IAAM,CAC3D,
|
|
4
|
+
"sourcesContent": ["import {\n ApduResponse,\n CommandResultFactory,\n isSuccessCommandResult,\n} from \"@ledgerhq/device-management-kit\";\n\nimport { SW_INTERRUPTED_EXECUTION } from \"./utils/constants\";\nimport {\n GetWalletAddressCommand,\n type GetWalletAddressCommandArgs,\n} from \"./GetWalletAddressCommand\";\n\nconst SUCCESS_STATUS = new Uint8Array([0x90, 0x00]);\nconst USER_DENIED_STATUS = new Uint8Array([0x69, 0x85]);\n\ndescribe(\"GetWalletAddressCommand\", () => {\n let command: GetWalletAddressCommand;\n const defaultArgs: GetWalletAddressCommandArgs = {\n checkOnDevice: true,\n walletId: Uint8Array.from(\"walletIdBuffer\", (c) => c.charCodeAt(0)),\n walletHmac: Uint8Array.from(\"walletHmacBuffer\", (c) => c.charCodeAt(0)),\n change: false,\n addressIndex: 0x00000000,\n };\n\n beforeEach(() => {\n command = new GetWalletAddressCommand(defaultArgs);\n vi.clearAllMocks();\n vi.importActual(\"@ledgerhq/device-management-kit\");\n });\n\n describe(\"name\", () => {\n it(\"should be 'getWalletAddress'\", () => {\n expect(command.name).toBe(\"getWalletAddress\");\n });\n });\n\n describe(\"getApdu\", () => {\n it(\"should return correct APDU for default arguments\", () => {\n const apdu = command.getApdu();\n const expectedApdu = Uint8Array.from([\n 0xe1, // CLA\n 0x03, // INS\n 0x00, // P1\n 0x01, // P2\n 0x24, // Length of data: 36 bytes\n 0x01, // checkOnDevice: true\n ...Uint8Array.from(\"walletIdBuffer\", (c) => c.charCodeAt(0)),\n ...Uint8Array.from(\"walletHmacBuffer\", (c) => c.charCodeAt(0)),\n 0x00, // change: false\n 0x00,\n 0x00,\n 0x00,\n 0x00, // addressIndex: 0x00000000\n ]);\n expect(apdu.getRawApdu()).toEqual(expectedApdu);\n });\n\n it(\"should return correct APDU for different arguments\", () => {\n const args: GetWalletAddressCommandArgs = {\n checkOnDevice: false,\n walletId: Uint8Array.from(\"anotherWalletId\", (c) => c.charCodeAt(0)),\n walletHmac: Uint8Array.from(\"anotherWalletHmac\", (c) =>\n c.charCodeAt(0),\n ),\n change: true,\n addressIndex: 0x00000005,\n };\n command = new GetWalletAddressCommand(args);\n const apdu = command.getApdu();\n const expectedApdu = Uint8Array.from([\n 0xe1, // CLA\n 0x03, // INS\n 0x00, // P1\n 0x01, // P2\n 0x26, // Length of data\n 0x00, // checkOnDevice: false\n ...Uint8Array.from(\"anotherWalletId\", (c) => c.charCodeAt(0)),\n ...Uint8Array.from(\"anotherWalletHmac\", (c) => c.charCodeAt(0)),\n 0x01, // change: true\n 0x00,\n 0x00,\n 0x00,\n 0x05, // addressIndex: 0x00000005\n ]);\n expect(apdu.getRawApdu()).toEqual(expectedApdu);\n });\n });\n\n describe(\"parseResponse\", () => {\n it(\"should return the APDU response if it's a continue response\", () => {\n // given\n const continueResponseData = new Uint8Array([0x01, 0x02, 0x03, 0x04]);\n\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 it(\"should return an error if user denied the operation\", () => {\n // given\n const apduResponse = new ApduResponse({\n statusCode: USER_DENIED_STATUS,\n data: new Uint8Array([]),\n });\n\n // when\n const response = command.parseResponse(apduResponse);\n\n // then\n expect(isSuccessCommandResult(response)).toBe(false);\n if (!isSuccessCommandResult(response)) {\n expect(response.error).toBeDefined();\n }\n });\n\n it(\"should return correct data when response is not empty\", () => {\n // given\n const responseData = Uint8Array.from(\"addressData\", (c) =>\n c.charCodeAt(0),\n );\n\n const apduResponse = new ApduResponse({\n statusCode: SUCCESS_STATUS,\n data: responseData,\n });\n\n // when\n const response = command.parseResponse(apduResponse);\n\n // then\n expect(response).toStrictEqual(\n CommandResultFactory({ data: apduResponse }),\n );\n });\n });\n});\n"],
|
|
5
|
+
"mappings": "AAAA,OACE,gBAAAA,EACA,wBAAAC,EACA,0BA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,CACH,CAAC",
|
|
6
6
|
"names": ["ApduResponse", "CommandResultFactory", "isSuccessCommandResult", "SW_INTERRUPTED_EXECUTION", "GetWalletAddressCommand", "SUCCESS_STATUS", "USER_DENIED_STATUS", "command", "defaultArgs", "c", "apdu", "expectedApdu", "args", "continueResponseData", "apduResponse", "response", "responseData"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{ApduBuilder as d,ApduParser as l,CommandResultFactory as o,InvalidStatusWordError as m}from"@ledgerhq/device-management-kit";import{CommandErrorHelper as n}from"@ledgerhq/signer-utils";import{Maybe as p}from"purify-ts";import{BTC_APP_ERRORS as i,BtcAppCommandErrorFactory as c}from"../../app-binder/command/utils/bitcoinAppErrors";import{PROTOCOL_VERSION as R}from"../../app-binder/command/utils/constants";import{BtcCommandUtils as
|
|
1
|
+
import{ApduBuilder as d,ApduParser as l,CommandResultFactory as o,InvalidStatusWordError as m}from"@ledgerhq/device-management-kit";import{CommandErrorHelper as n}from"@ledgerhq/signer-utils";import{Maybe as p}from"purify-ts";import{BTC_APP_ERRORS as i,BtcAppCommandErrorFactory as c}from"../../app-binder/command/utils/bitcoinAppErrors";import{PROTOCOL_VERSION as R}from"../../app-binder/command/utils/constants";import{BtcCommandUtils as A}from"../../utils/BtcCommandUtils";const a=32;class w{constructor(e,r=new n(i,c,A.isSuccessResponse)){this._args=e;this._errorHelper=r}name="registerWalletAddress";getApdu(){const e=new d({cla:225,ins:2,p1:0,p2:R}),{walletPolicy:r}=this._args;return e.addBufferToData(r).build()}parseResponse(e){return p.fromNullable(this._errorHelper.getError(e)).orDefaultLazy(()=>{const r=new l(e),t=r.extractFieldByLength(a),s=r.extractFieldByLength(a);return!t||!s?o({error:new m("Data mismatch")}):o({data:{walletId:t,walletHmac:s}})})}}export{w as RegisterWalletAddressCommand};
|
|
2
2
|
//# sourceMappingURL=RegisterWalletAddressCommand.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/internal/app-binder/command/RegisterWalletAddressCommand.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n ApduBuilder,\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\nexport type RegisterWalletAddressCommandArgs = {\n walletPolicy: Uint8Array;\n};\n\ntype RegisterWalletAddressCommandResponse = {\n walletId: Uint8Array;\n walletHmac: Uint8Array;\n};\n\nconst RESPONSE_BUFFER_LENGTH = 32;\n\nexport class RegisterWalletAddressCommand\n implements\n Command<\n RegisterWalletAddressCommandResponse,\n RegisterWalletAddressCommandArgs,\n BtcErrorCodes\n >\n{\n constructor(\n private readonly _args: RegisterWalletAddressCommandArgs,\n private readonly _errorHelper = new CommandErrorHelper<\n RegisterWalletAddressCommandResponse,\n BtcErrorCodes\n >(\n BTC_APP_ERRORS,\n BtcAppCommandErrorFactory,\n BtcCommandUtils.isSuccessResponse,\n ),\n ) {}\n\n getApdu() {\n const builder = new ApduBuilder({\n cla: 0xe1,\n ins: 0x02,\n p1: 0x00,\n p2: PROTOCOL_VERSION,\n });\n const { walletPolicy } = this._args;\n\n return builder.addBufferToData(walletPolicy).build();\n }\n parseResponse(\n response: ApduResponse,\n ): CommandResult<RegisterWalletAddressCommandResponse, BtcErrorCodes> {\n return Maybe.fromNullable(\n this._errorHelper.getError(response),\n ).orDefaultLazy(() => {\n const parser = new ApduParser(response);\n\n const walletId = parser.extractFieldByLength(RESPONSE_BUFFER_LENGTH);\n const walletHmac = parser.extractFieldByLength(RESPONSE_BUFFER_LENGTH);\n if (!walletId || !walletHmac) {\n return CommandResultFactory({\n error: new InvalidStatusWordError(\"Data mismatch\"),\n });\n }\n return CommandResultFactory({\n data: {\n walletId,\n walletHmac,\n },\n });\n });\n }\n}\n"],
|
|
5
|
-
"mappings": "AAAA,OACE,eAAAA,EACA,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,kCAWhC,MAAMC,EAAyB,GAExB,MAAMC,CAOb,
|
|
4
|
+
"sourcesContent": ["import {\n ApduBuilder,\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\nexport type RegisterWalletAddressCommandArgs = {\n walletPolicy: Uint8Array;\n};\n\ntype RegisterWalletAddressCommandResponse = {\n walletId: Uint8Array;\n walletHmac: Uint8Array;\n};\n\nconst RESPONSE_BUFFER_LENGTH = 32;\n\nexport class RegisterWalletAddressCommand\n implements\n Command<\n RegisterWalletAddressCommandResponse,\n RegisterWalletAddressCommandArgs,\n BtcErrorCodes\n >\n{\n readonly name = \"registerWalletAddress\";\n constructor(\n private readonly _args: RegisterWalletAddressCommandArgs,\n private readonly _errorHelper = new CommandErrorHelper<\n RegisterWalletAddressCommandResponse,\n BtcErrorCodes\n >(\n BTC_APP_ERRORS,\n BtcAppCommandErrorFactory,\n BtcCommandUtils.isSuccessResponse,\n ),\n ) {}\n\n getApdu() {\n const builder = new ApduBuilder({\n cla: 0xe1,\n ins: 0x02,\n p1: 0x00,\n p2: PROTOCOL_VERSION,\n });\n const { walletPolicy } = this._args;\n\n return builder.addBufferToData(walletPolicy).build();\n }\n parseResponse(\n response: ApduResponse,\n ): CommandResult<RegisterWalletAddressCommandResponse, BtcErrorCodes> {\n return Maybe.fromNullable(\n this._errorHelper.getError(response),\n ).orDefaultLazy(() => {\n const parser = new ApduParser(response);\n\n const walletId = parser.extractFieldByLength(RESPONSE_BUFFER_LENGTH);\n const walletHmac = parser.extractFieldByLength(RESPONSE_BUFFER_LENGTH);\n if (!walletId || !walletHmac) {\n return CommandResultFactory({\n error: new InvalidStatusWordError(\"Data mismatch\"),\n });\n }\n return CommandResultFactory({\n data: {\n walletId,\n walletHmac,\n },\n });\n });\n }\n}\n"],
|
|
5
|
+
"mappings": "AAAA,OACE,eAAAA,EACA,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,kCAWhC,MAAMC,EAAyB,GAExB,MAAMC,CAOb,CAEE,YACmBC,EACAC,EAAe,IAAIT,EAIlCE,EACAC,EACAE,EAAgB,iBAClB,EACA,CATiB,WAAAG,EACA,kBAAAC,CAQhB,CAXM,KAAO,wBAahB,SAAU,CACR,MAAMC,EAAU,IAAId,EAAY,CAC9B,IAAK,IACL,IAAK,EACL,GAAI,EACJ,GAAIQ,CACN,CAAC,EACK,CAAE,aAAAO,CAAa,EAAI,KAAK,MAE9B,OAAOD,EAAQ,gBAAgBC,CAAY,EAAE,MAAM,CACrD,CACA,cACEC,EACoE,CACpE,OAAOX,EAAM,aACX,KAAK,aAAa,SAASW,CAAQ,CACrC,EAAE,cAAc,IAAM,CACpB,MAAMC,EAAS,IAAIhB,EAAWe,CAAQ,EAEhCE,EAAWD,EAAO,qBAAqBP,CAAsB,EAC7DS,EAAaF,EAAO,qBAAqBP,CAAsB,EACrE,MAAI,CAACQ,GAAY,CAACC,EACTjB,EAAqB,CAC1B,MAAO,IAAIC,EAAuB,eAAe,CACnD,CAAC,EAEID,EAAqB,CAC1B,KAAM,CACJ,SAAAgB,EACA,WAAAC,CACF,CACF,CAAC,CACH,CAAC,CACH,CACF",
|
|
6
6
|
"names": ["ApduBuilder", "ApduParser", "CommandResultFactory", "InvalidStatusWordError", "CommandErrorHelper", "Maybe", "BTC_APP_ERRORS", "BtcAppCommandErrorFactory", "PROTOCOL_VERSION", "BtcCommandUtils", "RESPONSE_BUFFER_LENGTH", "RegisterWalletAddressCommand", "_args", "_errorHelper", "builder", "walletPolicy", "response", "parser", "walletId", "walletHmac"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{ApduResponse as
|
|
1
|
+
import{ApduResponse as o,CommandResultFactory as n,InvalidStatusWordError as d,isSuccessCommandResult as c}from"@ledgerhq/device-management-kit";import{RegisterWalletAddressCommand as s}from"../../app-binder/command/RegisterWalletAddressCommand";const l=Uint8Array.from([124,103,232,79,153,116,70,113,20,147,239,139,116,112,177,15,96,75,2,210,88,79,160,68,111,206,247,217,137,131,227,220]),i=2,f=Uint8Array.from([75,197,70,127,36,147,133,178,158,91,142,201,251,36,204,101,163,113,11,26,38,210,141,233,245,196,243,244,93,214,84,193]),m=Uint8Array.from([2,12,67,111,108,100,32,115,116,111,114,97,103,101,30]),A=2,e=Uint8Array.from([A].concat(...m).concat(...l).concat([i]).concat(...f)),u=Uint8Array.from([225,2,0,1,81].concat(...e)),a=Uint8Array.from([29,21,14,212,37,168,113,165,202,126,44,85,219,27,50,149,193,253,151,20,127,208,167,177,136,212,50,127,75,167,64,42,250,115,227,97,25,50,79,190,76,193,202,148,170,132,44,98,97,82,109,68,17,42,34,22,75,197,124,51,53,16,43,4]);describe("RegisterWalletAddressCommand",()=>{describe("name",()=>{it("should be 'registerWalletAddress'",()=>{const x=new s({walletPolicy:e});expect(x.name).toBe("registerWalletAddress")})}),describe("getApdu",()=>{it("should send the correct APDU",()=>{const x=new s({walletPolicy:e});expect(x.getApdu().getRawApdu()).toEqual(u)})}),describe("parseResponse",()=>{it("should parse the response correctly",()=>{const x=new s({walletPolicy:e}),t=new o({statusCode:new Uint8Array([144,0]),data:a});expect(x.parseResponse(t)).toEqual(n({data:{walletId:a.slice(0,32),walletHmac:a.slice(32)}}))}),it("should return an error if the response is not successful",()=>{const x=new s({walletPolicy:e}),t=new o({statusCode:Uint8Array.from([109,0]),data:new Uint8Array(0)}),r=x.parseResponse(t);expect(c(r)).toBe(!1)}),it("should return an error if the response is too short",()=>{const x=new s({walletPolicy:e}),t=new o({data:a.slice(0,2),statusCode:new Uint8Array([144,0])}),r=x.parseResponse(t);c(r)?assert.fail("Expected an error, but the result was successful"):expect(r.error).toEqual(new d("Data mismatch"))})})});
|
|
2
2
|
//# sourceMappingURL=RegisterWalletAddressCommand.test.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/internal/app-binder/command/RegisterWalletAddressCommand.test.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n ApduResponse,\n CommandResultFactory,\n InvalidStatusWordError,\n isSuccessCommandResult,\n} from \"@ledgerhq/device-management-kit\";\n\nimport { RegisterWalletAddressCommand } from \"@internal/app-binder/command/RegisterWalletAddressCommand\";\n\nconst POLICY_HASH_DATA = Uint8Array.from([\n 0x7c, 0x67, 0xe8, 0x4f, 0x99, 0x74, 0x46, 0x71, 0x14, 0x93, 0xef, 0x8b, 0x74,\n 0x70, 0xb1, 0x0f, 0x60, 0x4b, 0x02, 0xd2, 0x58, 0x4f, 0xa0, 0x44, 0x6f, 0xce,\n 0xf7, 0xd9, 0x89, 0x83, 0xe3, 0xdc,\n]);\nconst KEYS_LENGTH = 0x02;\nconst KEYS_HASH_DATA = Uint8Array.from([\n 0x4b, 0xc5, 0x46, 0x7f, 0x24, 0x93, 0x85, 0xb2, 0x9e, 0x5b, 0x8e, 0xc9, 0xfb,\n 0x24, 0xcc, 0x65, 0xa3, 0x71, 0x0b, 0x1a, 0x26, 0xd2, 0x8d, 0xe9, 0xf5, 0xc4,\n 0xf3, 0xf4, 0x5d, 0xd6, 0x54, 0xc1,\n]);\nconst POLICY_NAME_DATA = Uint8Array.from([\n 0x02, 0x0c, 0x43, 0x6f, 0x6c, 0x64, 0x20, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67,\n 0x65, 0x1e,\n]);\nconst POLICY_VERSION = 0x02;\nconst WALLET_POLICY_DATA = Uint8Array.from(\n [POLICY_VERSION]\n .concat(...POLICY_NAME_DATA)\n .concat(...POLICY_HASH_DATA)\n .concat([KEYS_LENGTH])\n .concat(...KEYS_HASH_DATA),\n);\nconst EXPECTED_RAW_APDU = Uint8Array.from(\n [0xe1, 0x02, 0x00, 0x01, 0x51].concat(...WALLET_POLICY_DATA),\n);\nconst APDU_RESPONSE = Uint8Array.from([\n 0x1d, 0x15, 0x0e, 0xd4, 0x25, 0xa8, 0x71, 0xa5, 0xca, 0x7e, 0x2c, 0x55, 0xdb,\n 0x1b, 0x32, 0x95, 0xc1, 0xfd, 0x97, 0x14, 0x7f, 0xd0, 0xa7, 0xb1, 0x88, 0xd4,\n 0x32, 0x7f, 0x4b, 0xa7, 0x40, 0x2a, 0xfa, 0x73, 0xe3, 0x61, 0x19, 0x32, 0x4f,\n 0xbe, 0x4c, 0xc1, 0xca, 0x94, 0xaa, 0x84, 0x2c, 0x62, 0x61, 0x52, 0x6d, 0x44,\n 0x11, 0x2a, 0x22, 0x16, 0x4b, 0xc5, 0x7c, 0x33, 0x35, 0x10, 0x2b, 0x04,\n]);\n\ndescribe(\"RegisterWalletAddressCommand\", () => {\n describe(\"getApdu\", () => {\n it(\"should send the correct APDU\", () => {\n // when\n const command = new RegisterWalletAddressCommand({\n walletPolicy: WALLET_POLICY_DATA,\n });\n\n // then\n expect(command.getApdu().getRawApdu()).toEqual(EXPECTED_RAW_APDU);\n });\n });\n describe(\"parseResponse\", () => {\n it(\"should parse the response correctly\", () => {\n // given\n const command = new RegisterWalletAddressCommand({\n walletPolicy: WALLET_POLICY_DATA,\n });\n const response = new ApduResponse({\n statusCode: new Uint8Array([0x90, 0x00]),\n data: APDU_RESPONSE,\n });\n\n // then\n expect(command.parseResponse(response)).toEqual(\n CommandResultFactory({\n data: {\n walletId: APDU_RESPONSE.slice(0, 32),\n walletHmac: APDU_RESPONSE.slice(32),\n },\n }),\n );\n });\n\n it(\"should return an error if the response is not successful\", () => {\n // given\n const command = new RegisterWalletAddressCommand({\n walletPolicy: WALLET_POLICY_DATA,\n });\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 it(\"should return an error if the response is too short\", () => {\n // given\n const command = new RegisterWalletAddressCommand({\n walletPolicy: WALLET_POLICY_DATA,\n });\n const response = new ApduResponse({\n data: APDU_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(\"Data mismatch\"),\n );\n } else {\n assert.fail(\"Expected an error, but the result was successful\");\n }\n });\n });\n});\n"],
|
|
5
|
-
"mappings": "AAAA,OACE,gBAAAA,EACA,wBAAAC,EACA,0BAAAC,EACA,0BAAAC,MACK,kCAEP,OAAS,gCAAAC,MAAoC,4DAE7C,MAAMC,EAAmB,WAAW,KAAK,CACvC,IAAM,IAAM,IAAM,GAAM,IAAM,IAAM,GAAM,IAAM,GAAM,IAAM,IAAM,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AAM,CACxB,GAAG,+BAAgC,IAAM,CAEvC,
|
|
4
|
+
"sourcesContent": ["import {\n ApduResponse,\n CommandResultFactory,\n InvalidStatusWordError,\n isSuccessCommandResult,\n} from \"@ledgerhq/device-management-kit\";\n\nimport { RegisterWalletAddressCommand } from \"@internal/app-binder/command/RegisterWalletAddressCommand\";\n\nconst POLICY_HASH_DATA = Uint8Array.from([\n 0x7c, 0x67, 0xe8, 0x4f, 0x99, 0x74, 0x46, 0x71, 0x14, 0x93, 0xef, 0x8b, 0x74,\n 0x70, 0xb1, 0x0f, 0x60, 0x4b, 0x02, 0xd2, 0x58, 0x4f, 0xa0, 0x44, 0x6f, 0xce,\n 0xf7, 0xd9, 0x89, 0x83, 0xe3, 0xdc,\n]);\nconst KEYS_LENGTH = 0x02;\nconst KEYS_HASH_DATA = Uint8Array.from([\n 0x4b, 0xc5, 0x46, 0x7f, 0x24, 0x93, 0x85, 0xb2, 0x9e, 0x5b, 0x8e, 0xc9, 0xfb,\n 0x24, 0xcc, 0x65, 0xa3, 0x71, 0x0b, 0x1a, 0x26, 0xd2, 0x8d, 0xe9, 0xf5, 0xc4,\n 0xf3, 0xf4, 0x5d, 0xd6, 0x54, 0xc1,\n]);\nconst POLICY_NAME_DATA = Uint8Array.from([\n 0x02, 0x0c, 0x43, 0x6f, 0x6c, 0x64, 0x20, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67,\n 0x65, 0x1e,\n]);\nconst POLICY_VERSION = 0x02;\nconst WALLET_POLICY_DATA = Uint8Array.from(\n [POLICY_VERSION]\n .concat(...POLICY_NAME_DATA)\n .concat(...POLICY_HASH_DATA)\n .concat([KEYS_LENGTH])\n .concat(...KEYS_HASH_DATA),\n);\nconst EXPECTED_RAW_APDU = Uint8Array.from(\n [0xe1, 0x02, 0x00, 0x01, 0x51].concat(...WALLET_POLICY_DATA),\n);\nconst APDU_RESPONSE = Uint8Array.from([\n 0x1d, 0x15, 0x0e, 0xd4, 0x25, 0xa8, 0x71, 0xa5, 0xca, 0x7e, 0x2c, 0x55, 0xdb,\n 0x1b, 0x32, 0x95, 0xc1, 0xfd, 0x97, 0x14, 0x7f, 0xd0, 0xa7, 0xb1, 0x88, 0xd4,\n 0x32, 0x7f, 0x4b, 0xa7, 0x40, 0x2a, 0xfa, 0x73, 0xe3, 0x61, 0x19, 0x32, 0x4f,\n 0xbe, 0x4c, 0xc1, 0xca, 0x94, 0xaa, 0x84, 0x2c, 0x62, 0x61, 0x52, 0x6d, 0x44,\n 0x11, 0x2a, 0x22, 0x16, 0x4b, 0xc5, 0x7c, 0x33, 0x35, 0x10, 0x2b, 0x04,\n]);\n\ndescribe(\"RegisterWalletAddressCommand\", () => {\n describe(\"name\", () => {\n it(\"should be 'registerWalletAddress'\", () => {\n const command = new RegisterWalletAddressCommand({\n walletPolicy: WALLET_POLICY_DATA,\n });\n expect(command.name).toBe(\"registerWalletAddress\");\n });\n });\n\n describe(\"getApdu\", () => {\n it(\"should send the correct APDU\", () => {\n // when\n const command = new RegisterWalletAddressCommand({\n walletPolicy: WALLET_POLICY_DATA,\n });\n\n // then\n expect(command.getApdu().getRawApdu()).toEqual(EXPECTED_RAW_APDU);\n });\n });\n describe(\"parseResponse\", () => {\n it(\"should parse the response correctly\", () => {\n // given\n const command = new RegisterWalletAddressCommand({\n walletPolicy: WALLET_POLICY_DATA,\n });\n const response = new ApduResponse({\n statusCode: new Uint8Array([0x90, 0x00]),\n data: APDU_RESPONSE,\n });\n\n // then\n expect(command.parseResponse(response)).toEqual(\n CommandResultFactory({\n data: {\n walletId: APDU_RESPONSE.slice(0, 32),\n walletHmac: APDU_RESPONSE.slice(32),\n },\n }),\n );\n });\n\n it(\"should return an error if the response is not successful\", () => {\n // given\n const command = new RegisterWalletAddressCommand({\n walletPolicy: WALLET_POLICY_DATA,\n });\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 it(\"should return an error if the response is too short\", () => {\n // given\n const command = new RegisterWalletAddressCommand({\n walletPolicy: WALLET_POLICY_DATA,\n });\n const response = new ApduResponse({\n data: APDU_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(\"Data mismatch\"),\n );\n } else {\n assert.fail(\"Expected an error, but the result was successful\");\n }\n });\n });\n});\n"],
|
|
5
|
+
"mappings": "AAAA,OACE,gBAAAA,EACA,wBAAAC,EACA,0BAAAC,EACA,0BAAAC,MACK,kCAEP,OAAS,gCAAAC,MAAoC,4DAE7C,MAAMC,EAAmB,WAAW,KAAK,CACvC,IAAM,IAAM,IAAM,GAAM,IAAM,IAAM,GAAM,IAAM,GAAM,IAAM,IAAM,IAAM,IACxE,IAAM,IAAM,GAAM,GAAM,GAAM,EAAM,IAAM,GAAM,GAAM,IAAM,GAAM,IAAM,IACxE,IAAM,IAAM,IAAM,IAAM,IAAM,GAChC,CAAC,EACKC,EAAc,EACdC,EAAiB,WAAW,KAAK,CACrC,GAAM,IAAM,GAAM,IAAM,GAAM,IAAM,IAAM,IAAM,IAAM,GAAM,IAAM,IAAM,IACxE,GAAM,IAAM,IAAM,IAAM,IAAM,GAAM,GAAM,GAAM,IAAM,IAAM,IAAM,IAAM,IACxE,IAAM,IAAM,GAAM,IAAM,GAAM,GAChC,CAAC,EACKC,EAAmB,WAAW,KAAK,CACvC,EAAM,GAAM,GAAM,IAAM,IAAM,IAAM,GAAM,IAAM,IAAM,IAAM,IAAM,GAAM,IACxE,IAAM,EACR,CAAC,EACKC,EAAiB,EACjBC,EAAqB,WAAW,KACpC,CAACD,CAAc,EACZ,OAAO,GAAGD,CAAgB,EAC1B,OAAO,GAAGH,CAAgB,EAC1B,OAAO,CAACC,CAAW,CAAC,EACpB,OAAO,GAAGC,CAAc,CAC7B,E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AAG,EAAE,EACnC,WAAYA,EAAc,MAAM,EAAE,CACpC,CACF,CAAC,CACH,CACF,CAAC,EAED,GAAG,2DAA4D,IAAM,CAEnE,MAAMC,EAAU,IAAIT,EAA6B,CAC/C,aAAcM,CAChB,CAAC,EACKI,EAAW,IAAId,EAAa,CAChC,WAAY,WAAW,KAAK,CAAC,IAAM,CAAI,CAAC,EACxC,KAAM,IAAI,WAAW,CAAC,CACxB,CAAC,EAGKe,EAASF,EAAQ,cAAcC,CAAQ,EAG7C,OAAOX,EAAuBY,CAAM,CAAC,EAAE,KAAK,EAAK,CACnD,CAAC,EACD,GAAG,sDAAuD,IAAM,CAE9D,MAAMF,EAAU,IAAIT,EAA6B,CAC/C,aAAcM,CAChB,CAAC,EACKI,EAAW,IAAId,EAAa,CAChC,KAAMY,EAAc,MAAM,EAAG,CAAC,EAC9B,WAAY,IAAI,WAAW,CAAC,IAAM,CAAI,CAAC,CACzC,CAAC,EAGKG,EAASF,EAAQ,cAAcC,CAAQ,EAGxCX,EAAuBY,CAAM,EAKhC,OAAO,KAAK,kDAAkD,EAJ9D,OAAOA,EAAO,KAAK,EAAE,QACnB,IAAIb,EAAuB,eAAe,CAC5C,CAIJ,CAAC,CACH,CAAC,CACH,CAAC",
|
|
6
6
|
"names": ["ApduResponse", "CommandResultFactory", "InvalidStatusWordError", "isSuccessCommandResult", "RegisterWalletAddressCommand", "POLICY_HASH_DATA", "KEYS_LENGTH", "KEYS_HASH_DATA", "POLICY_NAME_DATA", "POLICY_VERSION", "WALLET_POLICY_DATA", "EXPECTED_RAW_APDU", "APDU_RESPONSE", "command", "response", "result"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{ApduBuilder as n,CommandResultFactory as m}from"@ledgerhq/device-management-kit";import{CommandErrorHelper as d,DerivationPathUtils as p}from"@ledgerhq/signer-utils";import{Maybe as i}from"purify-ts";import{PROTOCOL_VERSION as g}from"../../app-binder/command/utils/constants";import{BtcCommandUtils as l}from"../../utils/BtcCommandUtils";import{encodeVarint as C}from"../../utils/Varint";import{BTC_APP_ERRORS as u,BtcAppCommandErrorFactory as c}from"./utils/bitcoinAppErrors";class E{constructor(e,o=new d(u,c,l.isSuccessResponse)){this._args=e;this._errorHelper=o}getApdu(){const{derivationPath:e,messageLength:o,messageMerkleRoot:
|
|
1
|
+
import{ApduBuilder as n,CommandResultFactory as m}from"@ledgerhq/device-management-kit";import{CommandErrorHelper as d,DerivationPathUtils as p}from"@ledgerhq/signer-utils";import{Maybe as i}from"purify-ts";import{PROTOCOL_VERSION as g}from"../../app-binder/command/utils/constants";import{BtcCommandUtils as l}from"../../utils/BtcCommandUtils";import{encodeVarint as C}from"../../utils/Varint";import{BTC_APP_ERRORS as u,BtcAppCommandErrorFactory as c}from"./utils/bitcoinAppErrors";class E{constructor(e,o=new d(u,c,l.isSuccessResponse)){this._args=e;this._errorHelper=o}name="signMessage";getApdu(){const{derivationPath:e,messageLength:o,messageMerkleRoot:a}=this._args,r=new n({cla:225,ins:16,p1:0,p2:g}),s=p.splitPath(e);return r.add8BitUIntToData(s.length),s.forEach(t=>{r.add32BitUIntToData(t)}),r.addBufferToData(C(o).unsafeCoerce()).addBufferToData(a).build()}parseResponse(e){return i.fromNullable(this._errorHelper.getError(e)).orDefault(m({data:e}))}}export{E as SignMessageCommand};
|
|
2
2
|
//# sourceMappingURL=SignMessageCommand.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/internal/app-binder/command/SignMessageCommand.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 {\n CommandErrorHelper,\n DerivationPathUtils,\n} from \"@ledgerhq/signer-utils\";\nimport { Maybe } from \"purify-ts\";\n\nimport { PROTOCOL_VERSION } from \"@internal/app-binder/command/utils/constants\";\nimport { BtcCommandUtils } from \"@internal/utils/BtcCommandUtils\";\nimport { encodeVarint } from \"@internal/utils/Varint\";\n\nimport {\n BTC_APP_ERRORS,\n BtcAppCommandErrorFactory,\n type BtcErrorCodes,\n} from \"./utils/bitcoinAppErrors\";\n\nexport type SignMessageCommandArgs = {\n /**\n * The BIP32 path (e.g., \"m/44'/0'/0'/0/0\")\n */\n readonly derivationPath: string;\n /**\n * The total length of the message to be signed\n */\n readonly messageLength: number;\n /**\n * The Merkle root of the message data\n */\n readonly messageMerkleRoot: Uint8Array;\n};\n\nexport type SignMessageCommandResponse = ApduResponse;\n\nexport class SignMessageCommand\n implements\n Command<SignMessageCommandResponse, SignMessageCommandArgs, BtcErrorCodes>\n{\n constructor(\n private readonly _args: SignMessageCommandArgs,\n private readonly _errorHelper = new CommandErrorHelper<\n SignMessageCommandResponse,\n BtcErrorCodes\n >(\n BTC_APP_ERRORS,\n BtcAppCommandErrorFactory,\n BtcCommandUtils.isSuccessResponse,\n ),\n ) {}\n\n getApdu(): Apdu {\n const { derivationPath, messageLength, messageMerkleRoot } = this._args;\n\n const builder = new ApduBuilder({\n cla: 0xe1,\n ins: 0x10,\n p1: 0x00,\n p2: PROTOCOL_VERSION,\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\n .addBufferToData(encodeVarint(messageLength).unsafeCoerce()) // Message length (varint)\n .addBufferToData(messageMerkleRoot)\n .build();\n }\n\n parseResponse(\n apduResponse: ApduResponse,\n ): CommandResult<SignMessageCommandResponse, BtcErrorCodes> {\n return Maybe.fromNullable(\n this._errorHelper.getError(apduResponse),\n ).orDefault(CommandResultFactory({ data: apduResponse }));\n }\n}\n"],
|
|
5
|
-
"mappings": "AAAA,OAEE,eAAAA,EAIA,wBAAAC,MACK,kCACP,OACE,sBAAAC,EACA,uBAAAC,MACK,yBACP,OAAS,SAAAC,MAAa,YAEtB,OAAS,oBAAAC,MAAwB,+CACjC,OAAS,mBAAAC,MAAuB,kCAChC,OAAS,gBAAAC,MAAoB,yBAE7B,OACE,kBAAAC,EACA,6BAAAC,MAEK,2BAmBA,MAAMC,CAGb,
|
|
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 {\n CommandErrorHelper,\n DerivationPathUtils,\n} from \"@ledgerhq/signer-utils\";\nimport { Maybe } from \"purify-ts\";\n\nimport { PROTOCOL_VERSION } from \"@internal/app-binder/command/utils/constants\";\nimport { BtcCommandUtils } from \"@internal/utils/BtcCommandUtils\";\nimport { encodeVarint } from \"@internal/utils/Varint\";\n\nimport {\n BTC_APP_ERRORS,\n BtcAppCommandErrorFactory,\n type BtcErrorCodes,\n} from \"./utils/bitcoinAppErrors\";\n\nexport type SignMessageCommandArgs = {\n /**\n * The BIP32 path (e.g., \"m/44'/0'/0'/0/0\")\n */\n readonly derivationPath: string;\n /**\n * The total length of the message to be signed\n */\n readonly messageLength: number;\n /**\n * The Merkle root of the message data\n */\n readonly messageMerkleRoot: Uint8Array;\n};\n\nexport type SignMessageCommandResponse = ApduResponse;\n\nexport class SignMessageCommand\n implements\n Command<SignMessageCommandResponse, SignMessageCommandArgs, BtcErrorCodes>\n{\n readonly name = \"signMessage\";\n constructor(\n private readonly _args: SignMessageCommandArgs,\n private readonly _errorHelper = new CommandErrorHelper<\n SignMessageCommandResponse,\n BtcErrorCodes\n >(\n BTC_APP_ERRORS,\n BtcAppCommandErrorFactory,\n BtcCommandUtils.isSuccessResponse,\n ),\n ) {}\n\n getApdu(): Apdu {\n const { derivationPath, messageLength, messageMerkleRoot } = this._args;\n\n const builder = new ApduBuilder({\n cla: 0xe1,\n ins: 0x10,\n p1: 0x00,\n p2: PROTOCOL_VERSION,\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\n .addBufferToData(encodeVarint(messageLength).unsafeCoerce()) // Message length (varint)\n .addBufferToData(messageMerkleRoot)\n .build();\n }\n\n parseResponse(\n apduResponse: ApduResponse,\n ): CommandResult<SignMessageCommandResponse, BtcErrorCodes> {\n return Maybe.fromNullable(\n this._errorHelper.getError(apduResponse),\n ).orDefault(CommandResultFactory({ data: apduResponse }));\n }\n}\n"],
|
|
5
|
+
"mappings": "AAAA,OAEE,eAAAA,EAIA,wBAAAC,MACK,kCACP,OACE,sBAAAC,EACA,uBAAAC,MACK,yBACP,OAAS,SAAAC,MAAa,YAEtB,OAAS,oBAAAC,MAAwB,+CACjC,OAAS,mBAAAC,MAAuB,kCAChC,OAAS,gBAAAC,MAAoB,yBAE7B,OACE,kBAAAC,EACA,6BAAAC,MAEK,2BAmBA,MAAMC,CAGb,CAEE,YACmBC,EACAC,EAAe,IAAIV,EAIlCM,EACAC,EACAH,EAAgB,iBAClB,EACA,CATiB,WAAAK,EACA,kBAAAC,CAQhB,CAXM,KAAO,cAahB,SAAgB,CACd,KAAM,CAAE,eAAAC,EAAgB,cAAAC,EAAe,kBAAAC,CAAkB,EAAI,KAAK,MAE5DC,EAAU,IAAIhB,EAAY,CAC9B,IAAK,IACL,IAAK,GACL,GAAI,EACJ,GAAIK,CACN,CAAC,EAEKY,EAAOd,EAAoB,UAAUU,CAAc,EACzD,OAAAG,EAAQ,kBAAkBC,EAAK,MAAM,EACrCA,EAAK,QAASC,GAAY,CACxBF,EAAQ,mBAAmBE,CAAO,CACpC,CAAC,EAEMF,EACJ,gBAAgBT,EAAaO,CAAa,EAAE,aAAa,CAAC,EAC1D,gBAAgBC,CAAiB,EACjC,MAAM,CACX,CAEA,cACEI,EAC0D,CAC1D,OAAOf,EAAM,aACX,KAAK,aAAa,SAASe,CAAY,CACzC,EAAE,UAAUlB,EAAqB,CAAE,KAAMkB,CAAa,CAAC,CAAC,CAC1D,CACF",
|
|
6
6
|
"names": ["ApduBuilder", "CommandResultFactory", "CommandErrorHelper", "DerivationPathUtils", "Maybe", "PROTOCOL_VERSION", "BtcCommandUtils", "encodeVarint", "BTC_APP_ERRORS", "BtcAppCommandErrorFactory", "SignMessageCommand", "_args", "_errorHelper", "derivationPath", "messageLength", "messageMerkleRoot", "builder", "path", "element", "apduResponse"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{ApduResponse as o,CommandResultFactory as a,isSuccessCommandResult as
|
|
1
|
+
import{ApduResponse as o,CommandResultFactory as a,isSuccessCommandResult as c}from"@ledgerhq/device-management-kit";import{SW_INTERRUPTED_EXECUTION as i}from"./utils/constants";import{SignMessageCommand as s}from"./SignMessageCommand";const p="44'/0'/0'/0/0",m=new TextEncoder().encode("Hello Bitcoin!"),u=m.length,r=new Uint8Array(32).fill(250),f=({omitR:x=!1,omitS:e=!1}={})=>new Uint8Array([...x?[]:[27],...x?[]:[151,164,202,143,105,70,51,89,38,1,245,162,62,11,204,85,60,157,10,144,211,163,66,45,87,85,8,169,40,152,185,110],...e?[]:[105,80,208,46,116,233,193,2,193,100,162,37,83,48,130,202,189,216,144,239,196,99,246,127,96,206,254,140,63,135,207,206]]),l=new Uint8Array([105,133]),E=new Uint8Array([225,16,0,1,54,5,128,0,0,44,128,0,0,0,128,0,0,0,0,0,0,0,0,0,0,0,14,...r]);describe("SignMessageCommand",()=>{const x={derivationPath:p,messageLength:u,messageMerkleRoot:r};describe("name",()=>{it("should be 'signMessage'",()=>{const e=new s(x);expect(e.name).toBe("signMessage")})}),describe("getApdu",()=>{it("should return correct APDU for given arguments",()=>{const n=new s(x).getApdu();expect(n.getRawApdu()).toStrictEqual(E)})}),describe("parseResponse",()=>{it("should return the APDU response if it's a continue response",()=>{const e=new s(x),n=new Uint8Array([1,2,3,4]),t=new o({statusCode:i,data:n}),d=e.parseResponse(t);expect(d).toStrictEqual(a({data:t}))}),it("should return an error if user denied the operation",()=>{const e=new s(x),n=new o({statusCode:l,data:new Uint8Array([])}),t=e.parseResponse(n);expect(c(t)).toBe(!1),c(t)||expect(t.error).toBeDefined()}),it("should return correct data when the response data is not empty",()=>{const e=new s(x),n=new o({statusCode:new Uint8Array([144,0]),data:f()}),t=e.parseResponse(n);expect(t).toStrictEqual(a({data:n}))})})});
|
|
2
2
|
//# sourceMappingURL=SignMessageCommand.test.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/internal/app-binder/command/SignMessageCommand.test.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n ApduResponse,\n CommandResultFactory,\n isSuccessCommandResult,\n} from \"@ledgerhq/device-management-kit\";\n\nimport { SW_INTERRUPTED_EXECUTION } from \"./utils/constants\";\nimport { SignMessageCommand } from \"./SignMessageCommand\";\n\nconst PATH = \"44'/0'/0'/0/0\";\nconst MESSAGE = new TextEncoder().encode(\"Hello Bitcoin!\");\nconst MESSAGE_LENGTH = MESSAGE.length;\nconst MSG_MERKLE_ROOT = new Uint8Array(32).fill(0xfa);\n\nconst getResponse = ({\n omitR = false,\n omitS = false,\n}: {\n omitR?: boolean;\n omitS?: boolean;\n} = {}) =>\n new Uint8Array([\n ...(omitR ? [] : [0x1b]), // v\n ...(omitR\n ? []\n : [\n 0x97, 0xa4, 0xca, 0x8f, 0x69, 0x46, 0x33, 0x59, 0x26, 0x01, 0xf5,\n 0xa2, 0x3e, 0x0b, 0xcc, 0x55, 0x3c, 0x9d, 0x0a, 0x90, 0xd3, 0xa3,\n 0x42, 0x2d, 0x57, 0x55, 0x08, 0xa9, 0x28, 0x98, 0xb9, 0x6e,\n ]), // r (32 bytes)\n ...(omitS\n ? []\n : [\n 0x69, 0x50, 0xd0, 0x2e, 0x74, 0xe9, 0xc1, 0x02, 0xc1, 0x64, 0xa2,\n 0x25, 0x53, 0x30, 0x82, 0xca, 0xbd, 0xd8, 0x90, 0xef, 0xc4, 0x63,\n 0xf6, 0x7f, 0x60, 0xce, 0xfe, 0x8c, 0x3f, 0x87, 0xcf, 0xce,\n ]), // s (32 bytes)\n ]);\n\nconst USER_DENIED_STATUS = new Uint8Array([0x69, 0x85]);\n\nconst EXPECTED_APDU = new Uint8Array([\n 0xe1, // CLA\n 0x10, // INS\n 0x00, // P1\n 0x01, // P2\n 0x36, // Lc\n // Data:\n 0x05, // Number of derivation steps (5)\n // BIP32 path:\n // 44' (0x8000002C)\n 0x80,\n 0x00,\n 0x00,\n 0x2c,\n // 0' (0x80000000)\n 0x80,\n 0x00,\n 0x00,\n 0x00,\n // 0' (0x80000000)\n 0x80,\n 0x00,\n 0x00,\n 0x00,\n // 0 (0x00000000)\n 0x00,\n 0x00,\n 0x00,\n 0x00,\n // 0 (0x00000000)\n 0x00,\n 0x00,\n 0x00,\n 0x00,\n // Message length (varint)\n 0x0e, // 14 bytes (\"Hello Bitcoin!\")\n // messageMerkleRoot\n ...MSG_MERKLE_ROOT,\n]);\n\ndescribe(\"SignMessageCommand\", (): void => {\n const defaultArgs = {\n derivationPath: PATH,\n messageLength: MESSAGE_LENGTH,\n messageMerkleRoot: MSG_MERKLE_ROOT,\n };\n\n describe(\"getApdu\", () => {\n it(\"should return correct APDU for given arguments\", () => {\n // given\n const command = new SignMessageCommand(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 SignMessageCommand(defaultArgs);\n const continueResponseData = new Uint8Array([0x01, 0x02, 0x03, 0x04]);\n\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 it(\"should return an error if user denied the operation\", () => {\n // given\n const command = new SignMessageCommand(defaultArgs);\n const apduResponse = new ApduResponse({\n statusCode: USER_DENIED_STATUS,\n data: new Uint8Array([]),\n });\n // when\n const response = command.parseResponse(apduResponse);\n // then\n expect(isSuccessCommandResult(response)).toBe(false);\n if (!isSuccessCommandResult(response)) {\n expect(response.error).toBeDefined();\n }\n });\n\n it(\"should return correct data when the response data is not empty\", () => {\n // given\n const command = new SignMessageCommand(defaultArgs);\n const apduResponse = new ApduResponse({\n statusCode: new Uint8Array([0x90, 0x00]),\n data: getResponse(),\n });\n // when\n const response = command.parseResponse(apduResponse);\n // then\n expect(response).toStrictEqual(\n CommandResultFactory({\n data: apduResponse,\n }),\n );\n });\n });\n});\n"],
|
|
5
|
-
"mappings": "AAAA,OACE,gBAAAA,EACA,wBAAAC,EACA,0BAAAC,MACK,kCAEP,OAAS,4BAAAC,MAAgC,oBACzC,OAAS,sBAAAC,MAA0B,uBAEnC,MAAMC,EAAO,gBACPC,EAAU,IAAI,YAAY,EAAE,OAAO,gBAAgB,EACnDC,EAAiBD,EAAQ,OACzBE,EAAkB,IAAI,WAAW,EAAE,EAAE,KAAK,GAAI,EAE9CC,EAAc,CAAC,CACnB,MAAAC,EAAQ,GACR,MAAAC,EAAQ,EACV,EAGI,CAAC,IACH,IAAI,WAAW,CACb,GAAID,EAAQ,CAAC,EAAI,CAAC,EAAI,EACtB,GAAIA,EACA,CAAC,EACD,CACE,IAAM,IAAM,IAAM,IAAM,IAAM,GAAM,GAAM,GAAM,GAAM,EAAM,IAC5D,IAAM,GAAM,GAAM,IAAM,GAAM,GAAM,IAAM,GAAM,IAAM,IAAM,IAC5D,GAAM,GAAM,GAAM,GAAM,EAAM,IAAM,GAAM,IAAM,IAAM,GACxD,EACJ,GAAIC,EACA,CAAC,EACD,CACE,IAAM,GAAM,IAAM,GAAM,IAAM,IAAM,IAAM,EAAM,IAAM,IAAM,IAC5D,GAAM,GAAM,GAAM,IAAM,IAAM,IAAM,IAAM,IAAM,IAAM,IAAM,GAC5D,IAAM,IAAM,GAAM,IAAM,IAAM,IAAM,GAAM,IAAM,IAAM,GACxD,CACN,CAAC,EAEGC,EAAqB,IAAI,WAAW,CAAC,IAAM,GAAI,CAAC,EAEhDC,EAAgB,IAAI,WAAW,CACnC,IACA,GACA,EACA,EACA,GAEA,EAGA,IACA,EACA,EACA,GAEA,IACA,EACA,EACA,EAEA,IACA,EACA,EACA,EAEA,EACA,EACA,EACA,EAEA,EACA,EACA,EACA,EAEA,GAEA,GAAGL,CACL,CAAC,EAED,SAAS,qBAAsB,IAAY,CACzC,MAAMM,EAAc,CAClB,eAAgBT,EAChB,cAAeE,EACf,kBAAmBC,CACrB,EAEA,SAAS,UAAW,IAAM,CACxB,GAAG,iDAAkD,IAAM,CAIzD,
|
|
6
|
-
"names": ["ApduResponse", "CommandResultFactory", "isSuccessCommandResult", "SW_INTERRUPTED_EXECUTION", "SignMessageCommand", "PATH", "MESSAGE", "MESSAGE_LENGTH", "MSG_MERKLE_ROOT", "getResponse", "omitR", "omitS", "USER_DENIED_STATUS", "EXPECTED_APDU", "defaultArgs", "
|
|
4
|
+
"sourcesContent": ["import {\n ApduResponse,\n CommandResultFactory,\n isSuccessCommandResult,\n} from \"@ledgerhq/device-management-kit\";\n\nimport { SW_INTERRUPTED_EXECUTION } from \"./utils/constants\";\nimport { SignMessageCommand } from \"./SignMessageCommand\";\n\nconst PATH = \"44'/0'/0'/0/0\";\nconst MESSAGE = new TextEncoder().encode(\"Hello Bitcoin!\");\nconst MESSAGE_LENGTH = MESSAGE.length;\nconst MSG_MERKLE_ROOT = new Uint8Array(32).fill(0xfa);\n\nconst getResponse = ({\n omitR = false,\n omitS = false,\n}: {\n omitR?: boolean;\n omitS?: boolean;\n} = {}) =>\n new Uint8Array([\n ...(omitR ? [] : [0x1b]), // v\n ...(omitR\n ? []\n : [\n 0x97, 0xa4, 0xca, 0x8f, 0x69, 0x46, 0x33, 0x59, 0x26, 0x01, 0xf5,\n 0xa2, 0x3e, 0x0b, 0xcc, 0x55, 0x3c, 0x9d, 0x0a, 0x90, 0xd3, 0xa3,\n 0x42, 0x2d, 0x57, 0x55, 0x08, 0xa9, 0x28, 0x98, 0xb9, 0x6e,\n ]), // r (32 bytes)\n ...(omitS\n ? []\n : [\n 0x69, 0x50, 0xd0, 0x2e, 0x74, 0xe9, 0xc1, 0x02, 0xc1, 0x64, 0xa2,\n 0x25, 0x53, 0x30, 0x82, 0xca, 0xbd, 0xd8, 0x90, 0xef, 0xc4, 0x63,\n 0xf6, 0x7f, 0x60, 0xce, 0xfe, 0x8c, 0x3f, 0x87, 0xcf, 0xce,\n ]), // s (32 bytes)\n ]);\n\nconst USER_DENIED_STATUS = new Uint8Array([0x69, 0x85]);\n\nconst EXPECTED_APDU = new Uint8Array([\n 0xe1, // CLA\n 0x10, // INS\n 0x00, // P1\n 0x01, // P2\n 0x36, // Lc\n // Data:\n 0x05, // Number of derivation steps (5)\n // BIP32 path:\n // 44' (0x8000002C)\n 0x80,\n 0x00,\n 0x00,\n 0x2c,\n // 0' (0x80000000)\n 0x80,\n 0x00,\n 0x00,\n 0x00,\n // 0' (0x80000000)\n 0x80,\n 0x00,\n 0x00,\n 0x00,\n // 0 (0x00000000)\n 0x00,\n 0x00,\n 0x00,\n 0x00,\n // 0 (0x00000000)\n 0x00,\n 0x00,\n 0x00,\n 0x00,\n // Message length (varint)\n 0x0e, // 14 bytes (\"Hello Bitcoin!\")\n // messageMerkleRoot\n ...MSG_MERKLE_ROOT,\n]);\n\ndescribe(\"SignMessageCommand\", (): void => {\n const defaultArgs = {\n derivationPath: PATH,\n messageLength: MESSAGE_LENGTH,\n messageMerkleRoot: MSG_MERKLE_ROOT,\n };\n\n describe(\"name\", () => {\n it(\"should be 'signMessage'\", () => {\n const command = new SignMessageCommand(defaultArgs);\n expect(command.name).toBe(\"signMessage\");\n });\n });\n\n describe(\"getApdu\", () => {\n it(\"should return correct APDU for given arguments\", () => {\n // given\n const command = new SignMessageCommand(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 SignMessageCommand(defaultArgs);\n const continueResponseData = new Uint8Array([0x01, 0x02, 0x03, 0x04]);\n\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 it(\"should return an error if user denied the operation\", () => {\n // given\n const command = new SignMessageCommand(defaultArgs);\n const apduResponse = new ApduResponse({\n statusCode: USER_DENIED_STATUS,\n data: new Uint8Array([]),\n });\n // when\n const response = command.parseResponse(apduResponse);\n // then\n expect(isSuccessCommandResult(response)).toBe(false);\n if (!isSuccessCommandResult(response)) {\n expect(response.error).toBeDefined();\n }\n });\n\n it(\"should return correct data when the response data is not empty\", () => {\n // given\n const command = new SignMessageCommand(defaultArgs);\n const apduResponse = new ApduResponse({\n statusCode: new Uint8Array([0x90, 0x00]),\n data: getResponse(),\n });\n // when\n const response = command.parseResponse(apduResponse);\n // then\n expect(response).toStrictEqual(\n CommandResultFactory({\n data: apduResponse,\n }),\n );\n });\n });\n});\n"],
|
|
5
|
+
"mappings": "AAAA,OACE,gBAAAA,EACA,wBAAAC,EACA,0BAAAC,MACK,kCAEP,OAAS,4BAAAC,MAAgC,oBACzC,OAAS,sBAAAC,MAA0B,uBAEnC,MAAMC,EAAO,gBACPC,EAAU,IAAI,YAAY,EAAE,OAAO,gBAAgB,EACnDC,EAAiBD,EAAQ,OACzBE,EAAkB,IAAI,WAAW,EAAE,EAAE,KAAK,GAAI,EAE9CC,EAAc,CAAC,CACnB,MAAAC,EAAQ,GACR,MAAAC,EAAQ,EACV,EAGI,CAAC,IACH,IAAI,WAAW,CACb,GAAID,EAAQ,CAAC,EAAI,CAAC,EAAI,EACtB,GAAIA,EACA,CAAC,EACD,CACE,IAA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C,EAAM,EAAM,EAAM,CAAI,CAAC,EAE9DC,EAAe,IAAIlB,EAAa,CACpC,WAAYG,EACZ,KAAMc,CACR,CAAC,EAGKE,EAAWJ,EAAQ,cAAcG,CAAY,EAGnD,OAAOC,CAAQ,EAAE,cACflB,EAAqB,CACnB,KAAMiB,CACR,CAAC,CACH,CACF,CAAC,EAED,GAAG,sDAAuD,IAAM,CAE9D,MAAMH,EAAU,IAAIX,EAAmBU,CAAW,EAC5CI,EAAe,IAAIlB,EAAa,CACpC,WAAYY,EACZ,KAAM,IAAI,WAAW,CAAC,CAAC,CACzB,CAAC,EAEKO,EAAWJ,EAAQ,cAAcG,CAAY,EAEnD,OAAOhB,EAAuBiB,CAAQ,CAAC,EAAE,KAAK,EAAK,EAC9CjB,EAAuBiB,CAAQ,GAClC,OAAOA,EAAS,KAAK,EAAE,YAAY,CAEvC,CAAC,EAED,GAAG,iEAAkE,IAAM,CAEzE,MAAMJ,EAAU,IAAIX,EAAmBU,CAAW,EAC5CI,EAAe,IAAIlB,EAAa,CACpC,WAAY,IAAI,WAAW,CAAC,IAAM,CAAI,CAAC,EACvC,KAAMS,EAAY,CACpB,CAAC,EAEKU,EAAWJ,EAAQ,cAAcG,CAAY,EAEnD,OAAOC,CAAQ,EAAE,cACflB,EAAqB,CACnB,KAAMiB,CACR,CAAC,CACH,CACF,CAAC,CACH,CAAC,CACH,CAAC",
|
|
6
|
+
"names": ["ApduResponse", "CommandResultFactory", "isSuccessCommandResult", "SW_INTERRUPTED_EXECUTION", "SignMessageCommand", "PATH", "MESSAGE", "MESSAGE_LENGTH", "MSG_MERKLE_ROOT", "getResponse", "omitR", "omitS", "USER_DENIED_STATUS", "EXPECTED_APDU", "defaultArgs", "command", "apdu", "continueResponseData", "apduResponse", "response"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{ApduBuilder as d,CommandResultFactory as p}from"@ledgerhq/device-management-kit";import{CommandErrorHelper as u}from"@ledgerhq/signer-utils";import{Maybe as i}from"purify-ts";import{BTC_APP_ERRORS as l,BtcAppCommandErrorFactory as C}from"../../app-binder/command/utils/bitcoinAppErrors";import{PROTOCOL_VERSION as R}from"../../app-binder/command/utils/constants";import{BtcCommandUtils as c}from"../../utils/BtcCommandUtils";class S{constructor(t,o=new u(l,C,c.isSuccessResponse)){this._args=t;this._errorHelper=o}getApdu(){const t=new d({cla:225,ins:4,p1:0,p2:R}),{globalCommitment:o,inputsCount:r,inputsRoot:e,outputsCount:a,outputsRoot:n,walletHmac:s,walletId:m}=this._args;return t.addBufferToData(o).add8BitUIntToData(r).addBufferToData(e).add8BitUIntToData(a).addBufferToData(n).addBufferToData(m).addBufferToData(s).build()}parseResponse(t){return i.fromNullable(this._errorHelper.getError(t)).orDefault(p({data:t}))}}export{S as SignPsbtCommand};
|
|
1
|
+
import{ApduBuilder as d,CommandResultFactory as p}from"@ledgerhq/device-management-kit";import{CommandErrorHelper as u}from"@ledgerhq/signer-utils";import{Maybe as i}from"purify-ts";import{BTC_APP_ERRORS as l,BtcAppCommandErrorFactory as C}from"../../app-binder/command/utils/bitcoinAppErrors";import{PROTOCOL_VERSION as R}from"../../app-binder/command/utils/constants";import{BtcCommandUtils as c}from"../../utils/BtcCommandUtils";class S{constructor(t,o=new u(l,C,c.isSuccessResponse)){this._args=t;this._errorHelper=o}name="signPsbt";getApdu(){const t=new d({cla:225,ins:4,p1:0,p2:R}),{globalCommitment:o,inputsCount:r,inputsRoot:e,outputsCount:a,outputsRoot:n,walletHmac:s,walletId:m}=this._args;return t.addBufferToData(o).add8BitUIntToData(r).addBufferToData(e).add8BitUIntToData(a).addBufferToData(n).addBufferToData(m).addBufferToData(s).build()}parseResponse(t){return i.fromNullable(this._errorHelper.getError(t)).orDefault(p({data:t}))}}export{S as SignPsbtCommand};
|
|
2
2
|
//# sourceMappingURL=SignPsbtCommand.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/internal/app-binder/command/SignPsbtCommand.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 { PROTOCOL_VERSION } from \"@internal/app-binder/command/utils/constants\";\nimport { BtcCommandUtils } from \"@internal/utils/BtcCommandUtils\";\n\nexport type SignPsbtCommandArgs = {\n globalCommitment: Uint8Array;\n inputsCount: number;\n inputsRoot: Uint8Array;\n outputsCount: number;\n outputsRoot: Uint8Array;\n walletId: Uint8Array;\n walletHmac: Uint8Array;\n};\n\ntype SignPsbtCommandResponse = ApduResponse;\n\nexport class SignPsbtCommand\n implements\n Command<SignPsbtCommandResponse, SignPsbtCommandArgs, BtcErrorCodes>\n{\n constructor(\n private readonly _args: SignPsbtCommandArgs,\n private readonly _errorHelper = new CommandErrorHelper<\n SignPsbtCommandResponse,\n BtcErrorCodes\n >(\n BTC_APP_ERRORS,\n BtcAppCommandErrorFactory,\n BtcCommandUtils.isSuccessResponse,\n ),\n ) {}\n\n getApdu(): Apdu {\n const builder = new ApduBuilder({\n cla: 0xe1,\n ins: 0x04,\n p1: 0x00,\n p2: PROTOCOL_VERSION,\n });\n const {\n globalCommitment,\n inputsCount,\n inputsRoot,\n outputsCount,\n outputsRoot,\n walletHmac,\n walletId,\n } = this._args;\n\n return builder\n .addBufferToData(globalCommitment)\n .add8BitUIntToData(inputsCount)\n .addBufferToData(inputsRoot)\n .add8BitUIntToData(outputsCount)\n .addBufferToData(outputsRoot)\n .addBufferToData(walletId)\n .addBufferToData(walletHmac)\n .build();\n }\n parseResponse(\n response: ApduResponse,\n ): CommandResult<SignPsbtCommandResponse, BtcErrorCodes> {\n return Maybe.fromNullable(this._errorHelper.getError(response)).orDefault(\n CommandResultFactory({ data: response }),\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,kCAczB,MAAMC,CAGb,
|
|
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 SignPsbtCommandArgs = {\n globalCommitment: Uint8Array;\n inputsCount: number;\n inputsRoot: Uint8Array;\n outputsCount: number;\n outputsRoot: Uint8Array;\n walletId: Uint8Array;\n walletHmac: Uint8Array;\n};\n\ntype SignPsbtCommandResponse = ApduResponse;\n\nexport class SignPsbtCommand\n implements\n Command<SignPsbtCommandResponse, SignPsbtCommandArgs, BtcErrorCodes>\n{\n readonly name = \"signPsbt\";\n constructor(\n private readonly _args: SignPsbtCommandArgs,\n private readonly _errorHelper = new CommandErrorHelper<\n SignPsbtCommandResponse,\n BtcErrorCodes\n >(\n BTC_APP_ERRORS,\n BtcAppCommandErrorFactory,\n BtcCommandUtils.isSuccessResponse,\n ),\n ) {}\n\n getApdu(): Apdu {\n const builder = new ApduBuilder({\n cla: 0xe1,\n ins: 0x04,\n p1: 0x00,\n p2: PROTOCOL_VERSION,\n });\n const {\n globalCommitment,\n inputsCount,\n inputsRoot,\n outputsCount,\n outputsRoot,\n walletHmac,\n walletId,\n } = this._args;\n\n return builder\n .addBufferToData(globalCommitment)\n .add8BitUIntToData(inputsCount)\n .addBufferToData(inputsRoot)\n .add8BitUIntToData(outputsCount)\n .addBufferToData(outputsRoot)\n .addBufferToData(walletId)\n .addBufferToData(walletHmac)\n .build();\n }\n parseResponse(\n response: ApduResponse,\n ): CommandResult<SignPsbtCommandResponse, BtcErrorCodes> {\n return Maybe.fromNullable(this._errorHelper.getError(response)).orDefault(\n CommandResultFactory({ data: response }),\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,kCAczB,MAAMC,CAGb,CAEE,YACmBC,EACAC,EAAe,IAAIR,EAIlCE,EACAC,EACAE,EAAgB,iBAClB,EACA,CATiB,WAAAE,EACA,kBAAAC,CAQhB,CAXM,KAAO,WAahB,SAAgB,CACd,MAAMC,EAAU,IAAIX,EAAY,CAC9B,IAAK,IACL,IAAK,EACL,GAAI,EACJ,GAAIM,CACN,CAAC,EACK,CACJ,iBAAAM,EACA,YAAAC,EACA,WAAAC,EACA,aAAAC,EACA,YAAAC,EACA,WAAAC,EACA,SAAAC,CACF,EAAI,KAAK,MAET,OAAOP,EACJ,gBAAgBC,CAAgB,EAChC,kBAAkBC,CAAW,EAC7B,gBAAgBC,CAAU,EAC1B,kBAAkBC,CAAY,EAC9B,gBAAgBC,CAAW,EAC3B,gBAAgBE,CAAQ,EACxB,gBAAgBD,CAAU,EAC1B,MAAM,CACX,CACA,cACEE,EACuD,CACvD,OAAOhB,EAAM,aAAa,KAAK,aAAa,SAASgB,CAAQ,CAAC,EAAE,UAC9DlB,EAAqB,CAAE,KAAMkB,CAAS,CAAC,CACzC,CACF,CACF",
|
|
6
6
|
"names": ["ApduBuilder", "CommandResultFactory", "CommandErrorHelper", "Maybe", "BTC_APP_ERRORS", "BtcAppCommandErrorFactory", "PROTOCOL_VERSION", "BtcCommandUtils", "SignPsbtCommand", "_args", "_errorHelper", "builder", "globalCommitment", "inputsCount", "inputsRoot", "outputsCount", "outputsRoot", "walletHmac", "walletId", "response"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{ApduResponse as
|
|
1
|
+
import{ApduResponse as o,isSuccessCommandResult as n}from"@ledgerhq/device-management-kit";import{SignPsbtCommand as t}from"../../app-binder/command/SignPsbtCommand";const r=Uint8Array.from([5,81,155,56,218,231,68,71,183,33,81,243,84,203,19,140,163,89,26,95,248,172,129,50,137,177,138,0,78,49,50,22,32,58,34,31,75,185,94,30,99,129,67,20,166,147,179,89,53,61,70,96,163,67,81,101,211,223,183,53,206,45,245,245,143]),c=Uint8Array.from([1,42,200,205,188,111,214,67,112,5,86,99,249,80,47,227,102,237,248,73,112,204,125,126,232,246,186,71,89,159,17,5,194]),d=Uint8Array.from([1,217,53,20,212,41,104,141,118,87,201,175,10,8,134,172,116,75,208,136,28,74,25,16,181,55,250,186,40,205,202,46,17]),m=Uint8Array.from([65,172,65,166,22,180,162,250,212,152,38,143,233,200,166,59,136,84,135,56,57,6,93,230,251,47,171,241,251,232,146,86]),f=Uint8Array.from([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),i=Uint8Array.from([225,4,0,1,197,...r,1,...c,1,...d,...m,...f]);describe("SignPsbtCommand",()=>{const e={globalCommitment:r,inputsCount:1,inputsRoot:c,outputsCount:1,outputsRoot:d,walletId:m,walletHmac:f};describe("name",()=>{it("should be 'signPsbt'",()=>{const x=new t(e);expect(x.name).toBe("signPsbt")})}),describe("getApdu",()=>{it("should return a correct apdu",()=>{const x=new t(e);expect(x.getApdu().getRawApdu()).toEqual(i)})}),describe("parseResponse",()=>{it("should return success",()=>{const x=new t(e),s=new o({statusCode:Uint8Array.from([144,0]),data:Uint8Array.from([])}),a=x.parseResponse(s);expect(n(a)).toBe(!0)}),it("should return failure",()=>{const x=new t(e),s=new o({statusCode:Uint8Array.from([109,0]),data:new Uint8Array(0)}),a=x.parseResponse(s);expect(n(a)).toBe(!1)})})});
|
|
2
2
|
//# sourceMappingURL=SignPsbtCommand.test.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/internal/app-binder/command/SignPsbtCommand.test.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n ApduResponse,\n isSuccessCommandResult,\n} from \"@ledgerhq/device-management-kit\";\n\nimport {\n SignPsbtCommand,\n type SignPsbtCommandArgs,\n} from \"@internal/app-binder/command/SignPsbtCommand\";\n\nconst GLOBAL_COMMITMENT = Uint8Array.from([\n 0x05, 0x51, 0x9b, 0x38, 0xda, 0xe7, 0x44, 0x47, 0xb7, 0x21, 0x51, 0xf3, 0x54,\n 0xcb, 0x13, 0x8c, 0xa3, 0x59, 0x1a, 0x5f, 0xf8, 0xac, 0x81, 0x32, 0x89, 0xb1,\n 0x8a, 0x00, 0x4e, 0x31, 0x32, 0x16, 0x20, 0x3a, 0x22, 0x1f, 0x4b, 0xb9, 0x5e,\n 0x1e, 0x63, 0x81, 0x43, 0x14, 0xa6, 0x93, 0xb3, 0x59, 0x35, 0x3d, 0x46, 0x60,\n 0xa3, 0x43, 0x51, 0x65, 0xd3, 0xdf, 0xb7, 0x35, 0xce, 0x2d, 0xf5, 0xf5, 0x8f,\n]);\n\nconst INPUTS_ROOT = Uint8Array.from([\n 0x01, 0x2a, 0xc8, 0xcd, 0xbc, 0x6f, 0xd6, 0x43, 0x70, 0x05, 0x56, 0x63, 0xf9,\n 0x50, 0x2f, 0xe3, 0x66, 0xed, 0xf8, 0x49, 0x70, 0xcc, 0x7d, 0x7e, 0xe8, 0xf6,\n 0xba, 0x47, 0x59, 0x9f, 0x11, 0x05, 0xc2,\n]);\n\nconst OUTPUTS_ROOT = Uint8Array.from([\n 0x01, 0xd9, 0x35, 0x14, 0xd4, 0x29, 0x68, 0x8d, 0x76, 0x57, 0xc9, 0xaf, 0x0a,\n 0x08, 0x86, 0xac, 0x74, 0x4b, 0xd0, 0x88, 0x1c, 0x4a, 0x19, 0x10, 0xb5, 0x37,\n 0xfa, 0xba, 0x28, 0xcd, 0xca, 0x2e, 0x11,\n]);\nconst WALLET_ID = Uint8Array.from([\n 0x41, 0xac, 0x41, 0xa6, 0x16, 0xb4, 0xa2, 0xfa, 0xd4, 0x98, 0x26, 0x8f, 0xe9,\n 0xc8, 0xa6, 0x3b, 0x88, 0x54, 0x87, 0x38, 0x39, 0x06, 0x5d, 0xe6, 0xfb, 0x2f,\n 0xab, 0xf1, 0xfb, 0xe8, 0x92, 0x56,\n]);\nconst WALLET_HMAC = Uint8Array.from([\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n]);\nconst SIGN_PSBT_APDU = Uint8Array.from([\n 0xe1,\n 0x04,\n 0x00,\n 0x01,\n 0xc5,\n ...GLOBAL_COMMITMENT,\n 0x01,\n ...INPUTS_ROOT,\n 0x01,\n ...OUTPUTS_ROOT,\n ...WALLET_ID,\n ...WALLET_HMAC,\n]);\n\ndescribe(\"SignPsbtCommand\", () => {\n const args: SignPsbtCommandArgs = {\n globalCommitment: GLOBAL_COMMITMENT,\n inputsCount: 1,\n inputsRoot: INPUTS_ROOT,\n outputsCount: 1,\n outputsRoot: OUTPUTS_ROOT,\n walletId: WALLET_ID,\n walletHmac: WALLET_HMAC,\n };\n describe(\"getApdu\", () => {\n it(\"should return a correct apdu\", () => {\n const command = new SignPsbtCommand(args);\n\n expect(command.getApdu().getRawApdu()).toEqual(SIGN_PSBT_APDU);\n });\n });\n describe(\"parseResponse\", () => {\n it(\"should return success\", () => {\n // given\n const command = new SignPsbtCommand(args);\n const response = new ApduResponse({\n statusCode: Uint8Array.from([0x90, 0x00]),\n data: Uint8Array.from([]),\n });\n\n // when\n const result = command.parseResponse(response);\n\n // then\n expect(isSuccessCommandResult(result)).toBe(true);\n });\n it(\"should return failure\", () => {\n // given\n const command = new SignPsbtCommand(args);\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});\n"],
|
|
5
|
-
"mappings": "AAAA,OACE,gBAAAA,EACA,0BAAAC,MACK,kCAEP,OACE,mBAAAC,MAEK,+CAEP,MAAMC,EAAoB,WAAW,KAAK,CACxC,EAAM,GAAM,IAAM,GAAM,IAAM,IAAM,GAAM,GAAM,IAAM,GAAM,GAAM,IAAM,GACxE,IAAM,GAAM,IAAM,IAAM,GAAM,GAAM,GAAM,IAAM,IAAM,IAAM,GAAM,IAAM,IACxE,IAAM,EAAM,GAAM,GAAM,GAAM,GAAM,GAAM,GAAM,GAAM,GAAM,GAAM,IAAM,GACxE,GAAM,GAAM,IAAM,GAAM,GAAM,IAAM,IAAM,IAAM,GAAM,GAAM,GAAM,GAAM,GACxE,IAAM,GAAM,GAAM,IAAM,IAAM,IAAM,IAAM,GAAM,IAAM,GAAM,IAAM,IAAM,GAC1E,CAAC,EAEKC,EAAc,WAAW,KAAK,CAClC,EAAM,GAAM,IAAM,IAAM,IAAM,IAAM,IAAM,GAAM,IAAM,EAAM,GAAM,GAAM,IACxE,GAAM,GAAM,IAAM,IAAM,IAAM,IAAM,GAAM,IAAM,IAAM,IAAM,IAAM,IAAM,IACxE,IAAM,GAAM,GAAM,IAAM,GAAM,EAAM,GACtC,CAAC,EAEKC,EAAe,WAAW,KAAK,CACnC,EAAM,IAAM,GAAM,GAAM,IAAM,GAAM,IAAM,IAAM,IAAM,GAAM,IAAM,IAAM,GACxE,EAAM,IAAM,IAAM,IAAM,GAAM,IAAM,IAAM,GAAM,GAAM,GAAM,GAAM,IAAM,GACxE,IAAM,IAAM,GAAM,IAAM,IAAM,GAAM,EACtC,CAAC,EACKC,EAAY,WAAW,KAAK,CAChC,GAAM,IAAM,GAAM,IAAM,GAAM,IAAM,IAAM,IAAM,IAAM,IAAM,GAAM,IAAM,IACxE,IAAM,IAAM,GAAM,IAAM,GAAM,IAAM,GAAM,GAAM,EAAM,GAAM,IAAM,IAAM,GACxE,IAAM,IAAM,IAAM,IAAM,IAAM,EAChC,CAAC,EACKC,EAAc,WAAW,KAAK,CAClC,EAAM,EAAM,EAAM,EAAM,EAAM,EAAM,EAAM,EAAM,EAAM,EAAM,EAAM,EAAM,EACxE,EAAM,EAAM,EAAM,EAAM,EAAM,EAAM,EAAM,EAAM,EAAM,EAAM,EAAM,EAAM,EACxE,EAAM,EAAM,EAAM,EAAM,EAAM,CAChC,CAAC,EACKC,EAAiB,WAAW,KAAK,CACrC,IACA,EACA,EACA,EACA,IACA,GAAGL,EACH,EACA,GAAGC,EACH,EACA,GAAGC,EACH,GAAGC,EACH,GAAGC,CACL,CAAC,EAED,SAAS,kBAAmB,IAAM,CAChC,MAAME,EAA4B,CAChC,iBAAkBN,EAClB,YAAa,EACb,WAAYC,EACZ,aAAc,EACd,YAAaC,EACb,SAAUC,EACV,WAAYC,CACd,
|
|
4
|
+
"sourcesContent": ["import {\n ApduResponse,\n isSuccessCommandResult,\n} from \"@ledgerhq/device-management-kit\";\n\nimport {\n SignPsbtCommand,\n type SignPsbtCommandArgs,\n} from \"@internal/app-binder/command/SignPsbtCommand\";\n\nconst GLOBAL_COMMITMENT = Uint8Array.from([\n 0x05, 0x51, 0x9b, 0x38, 0xda, 0xe7, 0x44, 0x47, 0xb7, 0x21, 0x51, 0xf3, 0x54,\n 0xcb, 0x13, 0x8c, 0xa3, 0x59, 0x1a, 0x5f, 0xf8, 0xac, 0x81, 0x32, 0x89, 0xb1,\n 0x8a, 0x00, 0x4e, 0x31, 0x32, 0x16, 0x20, 0x3a, 0x22, 0x1f, 0x4b, 0xb9, 0x5e,\n 0x1e, 0x63, 0x81, 0x43, 0x14, 0xa6, 0x93, 0xb3, 0x59, 0x35, 0x3d, 0x46, 0x60,\n 0xa3, 0x43, 0x51, 0x65, 0xd3, 0xdf, 0xb7, 0x35, 0xce, 0x2d, 0xf5, 0xf5, 0x8f,\n]);\n\nconst INPUTS_ROOT = Uint8Array.from([\n 0x01, 0x2a, 0xc8, 0xcd, 0xbc, 0x6f, 0xd6, 0x43, 0x70, 0x05, 0x56, 0x63, 0xf9,\n 0x50, 0x2f, 0xe3, 0x66, 0xed, 0xf8, 0x49, 0x70, 0xcc, 0x7d, 0x7e, 0xe8, 0xf6,\n 0xba, 0x47, 0x59, 0x9f, 0x11, 0x05, 0xc2,\n]);\n\nconst OUTPUTS_ROOT = Uint8Array.from([\n 0x01, 0xd9, 0x35, 0x14, 0xd4, 0x29, 0x68, 0x8d, 0x76, 0x57, 0xc9, 0xaf, 0x0a,\n 0x08, 0x86, 0xac, 0x74, 0x4b, 0xd0, 0x88, 0x1c, 0x4a, 0x19, 0x10, 0xb5, 0x37,\n 0xfa, 0xba, 0x28, 0xcd, 0xca, 0x2e, 0x11,\n]);\nconst WALLET_ID = Uint8Array.from([\n 0x41, 0xac, 0x41, 0xa6, 0x16, 0xb4, 0xa2, 0xfa, 0xd4, 0x98, 0x26, 0x8f, 0xe9,\n 0xc8, 0xa6, 0x3b, 0x88, 0x54, 0x87, 0x38, 0x39, 0x06, 0x5d, 0xe6, 0xfb, 0x2f,\n 0xab, 0xf1, 0xfb, 0xe8, 0x92, 0x56,\n]);\nconst WALLET_HMAC = Uint8Array.from([\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n]);\nconst SIGN_PSBT_APDU = Uint8Array.from([\n 0xe1,\n 0x04,\n 0x00,\n 0x01,\n 0xc5,\n ...GLOBAL_COMMITMENT,\n 0x01,\n ...INPUTS_ROOT,\n 0x01,\n ...OUTPUTS_ROOT,\n ...WALLET_ID,\n ...WALLET_HMAC,\n]);\n\ndescribe(\"SignPsbtCommand\", () => {\n const args: SignPsbtCommandArgs = {\n globalCommitment: GLOBAL_COMMITMENT,\n inputsCount: 1,\n inputsRoot: INPUTS_ROOT,\n outputsCount: 1,\n outputsRoot: OUTPUTS_ROOT,\n walletId: WALLET_ID,\n walletHmac: WALLET_HMAC,\n };\n\n describe(\"name\", () => {\n it(\"should be 'signPsbt'\", () => {\n const command = new SignPsbtCommand(args);\n expect(command.name).toBe(\"signPsbt\");\n });\n });\n\n describe(\"getApdu\", () => {\n it(\"should return a correct apdu\", () => {\n const command = new SignPsbtCommand(args);\n\n expect(command.getApdu().getRawApdu()).toEqual(SIGN_PSBT_APDU);\n });\n });\n describe(\"parseResponse\", () => {\n it(\"should return success\", () => {\n // given\n const command = new SignPsbtCommand(args);\n const response = new ApduResponse({\n statusCode: Uint8Array.from([0x90, 0x00]),\n data: Uint8Array.from([]),\n });\n\n // when\n const result = command.parseResponse(response);\n\n // then\n expect(isSuccessCommandResult(result)).toBe(true);\n });\n it(\"should return failure\", () => {\n // given\n const command = new SignPsbtCommand(args);\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});\n"],
|
|
5
|
+
"mappings": "AAAA,OACE,gBAAAA,EACA,0BAAAC,MAC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EACxC,KAAM,IAAI,WAAW,CAAC,CACxB,CAAC,EAGKY,EAASF,EAAQ,cAAcC,CAAQ,EAG7C,OAAOV,EAAuBW,CAAM,CAAC,EAAE,KAAK,EAAK,CACnD,CAAC,CACH,CAAC,CACH,CAAC",
|
|
6
6
|
"names": ["ApduResponse", "isSuccessCommandResult", "SignPsbtCommand", "GLOBAL_COMMITMENT", "INPUTS_ROOT", "OUTPUTS_ROOT", "WALLET_ID", "WALLET_HMAC", "SIGN_PSBT_APDU", "args", "command", "response", "result"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=vi.fn(),n=vi.fn(),t=vi.fn(),i=vi.fn(),c=vi.fn(),o=vi.fn(),s=vi.fn(),a=vi.fn()
|
|
1
|
+
const e=vi.fn(),n=vi.fn(),t=vi.fn(),i=vi.fn(),c=vi.fn(),o=vi.fn(),s=vi.fn(),a=vi.fn();function v(){return{sendApdu:e,sendCommand:n,getDeviceModel:t,getDeviceSessionState:i,getDeviceSessionStateObservable:c,setDeviceSessionState:o,getManagerApiService:s,getSecureChannelService:a}}export{v as makeDeviceActionInternalApiMock};
|
|
2
2
|
//# sourceMappingURL=makeInternalApi.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/internal/app-binder/device-action/__test-utils__/makeInternalApi.ts"],
|
|
4
|
-
"sourcesContent": ["import { type InternalApi } from \"@ledgerhq/device-management-kit\";\nimport { type Mocked } from \"vitest\";\n\nconst sendApduMock = vi.fn();\nconst sendCommandMock = vi.fn();\nconst apiGetDeviceModelMock = vi.fn();\nconst apiGetDeviceSessionStateMock = vi.fn();\nconst apiGetDeviceSessionStateObservableMock = vi.fn();\nconst setDeviceSessionStateMock = vi.fn();\nconst getManagerApiServiceMock = vi.fn();\nconst getSecureChannelServiceMock = vi.fn();\
|
|
5
|
-
"mappings": "AAGA,MAAMA,EAAe,GAAG,GAAG,EACrBC,EAAkB,GAAG,GAAG,EACxBC,EAAwB,GAAG,GAAG,EAC9BC,EAA+B,GAAG,GAAG,EACrCC,EAAyC,GAAG,GAAG,EAC/CC,EAA4B,GAAG,GAAG,EAClCC,EAA2B,GAAG,GAAG,EACjCC,EAA8B,GAAG,GAAG,
|
|
6
|
-
"names": ["sendApduMock", "sendCommandMock", "apiGetDeviceModelMock", "apiGetDeviceSessionStateMock", "apiGetDeviceSessionStateObservableMock", "setDeviceSessionStateMock", "getManagerApiServiceMock", "getSecureChannelServiceMock", "
|
|
4
|
+
"sourcesContent": ["import { type InternalApi } from \"@ledgerhq/device-management-kit\";\nimport { type Mocked } from \"vitest\";\n\nconst sendApduMock = vi.fn();\nconst sendCommandMock = vi.fn();\nconst apiGetDeviceModelMock = vi.fn();\nconst apiGetDeviceSessionStateMock = vi.fn();\nconst apiGetDeviceSessionStateObservableMock = vi.fn();\nconst setDeviceSessionStateMock = vi.fn();\nconst getManagerApiServiceMock = vi.fn();\nconst getSecureChannelServiceMock = vi.fn();\n\nexport function makeDeviceActionInternalApiMock(): Mocked<InternalApi> {\n return {\n sendApdu: sendApduMock,\n sendCommand: sendCommandMock,\n getDeviceModel: apiGetDeviceModelMock,\n getDeviceSessionState: apiGetDeviceSessionStateMock,\n getDeviceSessionStateObservable: apiGetDeviceSessionStateObservableMock,\n setDeviceSessionState: setDeviceSessionStateMock,\n getManagerApiService: getManagerApiServiceMock,\n getSecureChannelService: getSecureChannelServiceMock,\n };\n}\n"],
|
|
5
|
+
"mappings": "AAGA,MAAMA,EAAe,GAAG,GAAG,EACrBC,EAAkB,GAAG,GAAG,EACxBC,EAAwB,GAAG,GAAG,EAC9BC,EAA+B,GAAG,GAAG,EACrCC,EAAyC,GAAG,GAAG,EAC/CC,EAA4B,GAAG,GAAG,EAClCC,EAA2B,GAAG,GAAG,EACjCC,EAA8B,GAAG,GAAG,EAEnC,SAASC,GAAuD,CACrE,MAAO,CACL,SAAUR,EACV,YAAaC,EACb,eAAgBC,EAChB,sBAAuBC,EACvB,gCAAiCC,EACjC,sBAAuBC,EACvB,qBAAsBC,EACtB,wBAAyBC,CAC3B,CACF",
|
|
6
|
+
"names": ["sendApduMock", "sendCommandMock", "apiGetDeviceModelMock", "apiGetDeviceSessionStateMock", "apiGetDeviceSessionStateObservableMock", "setDeviceSessionStateMock", "getManagerApiServiceMock", "getSecureChannelServiceMock", "makeDeviceActionInternalApiMock"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{ByteArrayBuilder as s,ByteArrayParser as a}from"@ledgerhq/device-management-kit";import{Just as o}from"purify-ts";import{DefaultKeySerializer as n}from"../../../psbt/service/key/DefaultKeySerializer";import{DefaultValueParser as u}from"../../../psbt/service/value/DefaultValueParser";import{DefaultKeyPairSerializer as y}from"./DefaultKeyPairSerializer";describe("DefaultKeyPairSerializer",()=>{let t;const i=new u;beforeEach(()=>{const e=new n;t=new y(e)}),it("Invalid key",()=>{const e=t.deserialize(new a(Uint8Array.from([])));expect(e.isJust()).toStrictEqual(!1)}),it("Invalid valueLen",()=>{const e=t.deserialize(new a(Uint8Array.from([7,42,0,1,2,3,4,5])));expect(e.isJust()).toStrictEqual(!1)}),it("Invalid value",()=>{const e=t.deserialize(new a(Uint8Array.from([7,42,0,1,2,3,4,5,2,7])));expect(e.isJust()).toStrictEqual(!1)}),it("Serialize and deserialize a
|
|
1
|
+
import{ByteArrayBuilder as s,ByteArrayParser as a}from"@ledgerhq/device-management-kit";import{Just as o}from"purify-ts";import{DefaultKeySerializer as n}from"../../../psbt/service/key/DefaultKeySerializer";import{DefaultValueParser as u}from"../../../psbt/service/value/DefaultValueParser";import{DefaultKeyPairSerializer as y}from"./DefaultKeyPairSerializer";describe("DefaultKeyPairSerializer",()=>{let t;const i=new u;beforeEach(()=>{const e=new n;t=new y(e)}),it("Invalid key",()=>{const e=t.deserialize(new a(Uint8Array.from([])));expect(e.isJust()).toStrictEqual(!1)}),it("Invalid valueLen",()=>{const e=t.deserialize(new a(Uint8Array.from([7,42,0,1,2,3,4,5])));expect(e.isJust()).toStrictEqual(!1)}),it("Invalid value",()=>{const e=t.deserialize(new a(Uint8Array.from([7,42,0,1,2,3,4,5,2,7])));expect(e.isJust()).toStrictEqual(!1)}),it("Serialize and deserialize a keyPair",()=>{const e=new a(Uint8Array.from([7,42,0,1,2,3,4,5,5,254,145,69,220,0,42])),l=t.deserialize(e);expect(l.isJust()).toStrictEqual(!0);const r=l.unsafeCoerce();expect(r.key.keyType).toStrictEqual(42),expect(r.key.keyData).toStrictEqual(Uint8Array.from([0,1,2,3,4,5])),expect(r.value.data).toStrictEqual(Uint8Array.from([254,145,69,220,0])),expect(i.getInt32LE(r.value.data)).toStrictEqual(o(-599420418)),expect(i.getVarint(r.value.data)).toStrictEqual(o(14435729)),expect(e.extract8BitUInt()).toStrictEqual(42);const c=new s;t.serialize(c,r),expect(c.build()).toStrictEqual(Uint8Array.from([7,42,0,1,2,3,4,5,5,254,145,69,220,0]))})});
|
|
2
2
|
//# sourceMappingURL=DefaultKeyPairSerializer.test.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/internal/psbt/service/key-pair/DefaultKeyPairSerializer.test.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n ByteArrayBuilder,\n ByteArrayParser,\n} from \"@ledgerhq/device-management-kit\";\nimport { Just } from \"purify-ts\";\n\nimport { DefaultKeySerializer } from \"@internal/psbt/service/key/DefaultKeySerializer\";\nimport { DefaultValueParser } from \"@internal/psbt/service/value/DefaultValueParser\";\n\nimport { DefaultKeyPairSerializer } from \"./DefaultKeyPairSerializer\";\n\ndescribe(\"DefaultKeyPairSerializer\", () => {\n let service: DefaultKeyPairSerializer;\n const valueParser = new DefaultValueParser();\n\n beforeEach(() => {\n const keySerializerService = new DefaultKeySerializer();\n service = new DefaultKeyPairSerializer(keySerializerService);\n });\n\n it(\"Invalid key\", () => {\n const keyPair = service.deserialize(\n new ByteArrayParser(Uint8Array.from([])),\n );\n expect(keyPair.isJust()).toStrictEqual(false);\n });\n\n it(\"Invalid valueLen\", () => {\n const keyPair = service.deserialize(\n new ByteArrayParser(Uint8Array.from([7, 42, 0, 1, 2, 3, 4, 5])),\n );\n expect(keyPair.isJust()).toStrictEqual(false);\n });\n\n it(\"Invalid value\", () => {\n const keyPair = service.deserialize(\n new ByteArrayParser(Uint8Array.from([7, 42, 0, 1, 2, 3, 4, 5, 2, 7])),\n );\n expect(keyPair.isJust()).toStrictEqual(false);\n });\n\n it(\"Serialize and deserialize a
|
|
4
|
+
"sourcesContent": ["import {\n ByteArrayBuilder,\n ByteArrayParser,\n} from \"@ledgerhq/device-management-kit\";\nimport { Just } from \"purify-ts\";\n\nimport { DefaultKeySerializer } from \"@internal/psbt/service/key/DefaultKeySerializer\";\nimport { DefaultValueParser } from \"@internal/psbt/service/value/DefaultValueParser\";\n\nimport { DefaultKeyPairSerializer } from \"./DefaultKeyPairSerializer\";\n\ndescribe(\"DefaultKeyPairSerializer\", () => {\n let service: DefaultKeyPairSerializer;\n const valueParser = new DefaultValueParser();\n\n beforeEach(() => {\n const keySerializerService = new DefaultKeySerializer();\n service = new DefaultKeyPairSerializer(keySerializerService);\n });\n\n it(\"Invalid key\", () => {\n const keyPair = service.deserialize(\n new ByteArrayParser(Uint8Array.from([])),\n );\n expect(keyPair.isJust()).toStrictEqual(false);\n });\n\n it(\"Invalid valueLen\", () => {\n const keyPair = service.deserialize(\n new ByteArrayParser(Uint8Array.from([7, 42, 0, 1, 2, 3, 4, 5])),\n );\n expect(keyPair.isJust()).toStrictEqual(false);\n });\n\n it(\"Invalid value\", () => {\n const keyPair = service.deserialize(\n new ByteArrayParser(Uint8Array.from([7, 42, 0, 1, 2, 3, 4, 5, 2, 7])),\n );\n expect(keyPair.isJust()).toStrictEqual(false);\n });\n\n it(\"Serialize and deserialize a keyPair\", () => {\n // Deserialize a valid keyPair\n const parser = new ByteArrayParser(\n Uint8Array.from([\n 7, 42, 0, 1, 2, 3, 4, 5, 5, 0xfe, 0x91, 0x45, 0xdc, 0x00, 42,\n ]),\n );\n\n const maybeKeyPair = service.deserialize(parser);\n expect(maybeKeyPair.isJust()).toStrictEqual(true);\n const keyPair = maybeKeyPair.unsafeCoerce();\n expect(keyPair.key.keyType).toStrictEqual(42);\n expect(keyPair.key.keyData).toStrictEqual(\n Uint8Array.from([0, 1, 2, 3, 4, 5]),\n );\n expect(keyPair.value.data).toStrictEqual(\n Uint8Array.from([0xfe, 0x91, 0x45, 0xdc, 0x00]),\n );\n expect(valueParser.getInt32LE(keyPair.value.data)).toStrictEqual(\n Just(-599420418),\n );\n expect(valueParser.getVarint(keyPair.value.data)).toStrictEqual(\n Just(0xdc4591),\n );\n expect(parser.extract8BitUInt()).toStrictEqual(42);\n\n // Re-serialize\n const builder = new ByteArrayBuilder();\n service.serialize(builder, keyPair);\n expect(builder.build()).toStrictEqual(\n Uint8Array.from([\n 7, 42, 0, 1, 2, 3, 4, 5, 5, 0xfe, 0x91, 0x45, 0xdc, 0x00,\n ]),\n );\n });\n});\n"],
|
|
5
5
|
"mappings": "AAAA,OACE,oBAAAA,EACA,mBAAAC,MACK,kCACP,OAAS,QAAAC,MAAY,YAErB,OAAS,wBAAAC,MAA4B,kDACrC,OAAS,sBAAAC,MAA0B,kDAEnC,OAAS,4BAAAC,MAAgC,6BAEzC,SAAS,2BAA4B,IAAM,CACzC,IAAIC,EACJ,MAAMC,EAAc,IAAIH,EAExB,WAAW,IAAM,CACf,MAAMI,EAAuB,IAAIL,EACjCG,EAAU,IAAID,EAAyBG,CAAoB,CAC7D,CAAC,EAED,GAAG,cAAe,IAAM,CACtB,MAAMC,EAAUH,EAAQ,YACtB,IAAIL,EAAgB,WAAW,KAAK,CAAC,CAAC,CAAC,CACzC,EACA,OAAOQ,EAAQ,OAAO,CAAC,EAAE,cAAc,EAAK,CAC9C,CAAC,EAED,GAAG,mBAAoB,IAAM,CAC3B,MAAMA,E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AQ,UAAUM,EAASH,CAAO,EAClC,OAAOG,EAAQ,MAAM,CAAC,EAAE,cACtB,WAAW,KAAK,CACd,EAAG,GAAI,EAAG,EAAG,EAAG,EAAG,EAAG,EAAG,EAAG,IAAM,IAAM,GAAM,IAAM,CACtD,CAAC,CACH,CACF,CAAC,CACH,CAAC",
|
|
6
6
|
"names": ["ByteArrayBuilder", "ByteArrayParser", "Just", "DefaultKeySerializer", "DefaultValueParser", "DefaultKeyPairSerializer", "service", "valueParser", "keySerializerService", "keyPair", "parser", "maybeKeyPair", "builder"]
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/internal/psbt/service/psbt/DefaultPsbtSerializer.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n bufferToHexaString,\n ByteArrayBuilder,\n ByteArrayParser,\n} from \"@ledgerhq/device-management-kit\";\nimport { Transaction } from \"bitcoinjs-lib\";\nimport { inject } from \"inversify\";\nimport { Either, Left, Maybe, Right } from \"purify-ts\";\n\nimport { psbtTypes } from \"@internal/psbt/di/psbtTypes\";\nimport { Key } from \"@internal/psbt/model/Key\";\nimport { Psbt } from \"@internal/psbt/model/Psbt\";\nimport { PsbtGlobal } from \"@internal/psbt/model/Psbt\";\nimport { Value } from \"@internal/psbt/model/Value\";\nimport { type KeyPairSerializer } from \"@internal/psbt/service/key-pair/KeyPairSerializer\";\nimport { type ValueParser } from \"@internal/psbt/service/value/ValueParser\";\n\nimport { type PsbtSerializer } from \"./PsbtSerializer\";\n\n// PSBT magic bytes\nconst PSBT_MAGIC_BYTES = Uint8Array.from([0x70, 0x73, 0x62, 0x74, 0xff]);\n\n/**\n * According to specification, psbt is formatted as:\n * <magic> <global-map> <input-map>* <output-map>*\n * with:\n * <magic>: 0x70 0x73 0x62 0x74 0xFF\n * <map>: <
|
|
4
|
+
"sourcesContent": ["import {\n bufferToHexaString,\n ByteArrayBuilder,\n ByteArrayParser,\n} from \"@ledgerhq/device-management-kit\";\nimport { Transaction } from \"bitcoinjs-lib\";\nimport { inject } from \"inversify\";\nimport { Either, Left, Maybe, Right } from \"purify-ts\";\n\nimport { psbtTypes } from \"@internal/psbt/di/psbtTypes\";\nimport { Key } from \"@internal/psbt/model/Key\";\nimport { Psbt } from \"@internal/psbt/model/Psbt\";\nimport { PsbtGlobal } from \"@internal/psbt/model/Psbt\";\nimport { Value } from \"@internal/psbt/model/Value\";\nimport { type KeyPairSerializer } from \"@internal/psbt/service/key-pair/KeyPairSerializer\";\nimport { type ValueParser } from \"@internal/psbt/service/value/ValueParser\";\n\nimport { type PsbtSerializer } from \"./PsbtSerializer\";\n\n// PSBT magic bytes\nconst PSBT_MAGIC_BYTES = Uint8Array.from([0x70, 0x73, 0x62, 0x74, 0xff]);\n\n/**\n * According to specification, psbt is formatted as:\n * <magic> <global-map> <input-map>* <output-map>*\n * with:\n * <magic>: 0x70 0x73 0x62 0x74 0xFF\n * <map>: <keyPair>* 0x00\n * For <keyPair> serialization, it's done in KeyPair class.\n * For more informations:\n * https://github.com/bitcoin/bips/blob/master/bip-0174.mediawiki#specification\n */\nexport class DefaultPsbtSerializer implements PsbtSerializer {\n constructor(\n @inject(psbtTypes.ValueParser)\n private readonly valueParser: ValueParser,\n @inject(psbtTypes.KeyPairSerializer)\n private readonly keyPairSerializer: KeyPairSerializer,\n ) {}\n\n private getValue(map: Map<string, Value>, keyType: number): Maybe<Value> {\n return Maybe.fromNullable(map.get(new Key(keyType).toHexaString()));\n }\n\n private sortMap(map: Map<string, Value>): Map<string, Value> {\n return new Map(\n Array.from(map.entries()).sort((a, b) => a[0].localeCompare(b[0])),\n );\n }\n\n deserialize(buffer: Uint8Array): Either<Error, Psbt> {\n const parser = new ByteArrayParser(buffer);\n\n // Read PSBT magic\n for (const magicByte of PSBT_MAGIC_BYTES) {\n if (parser.extract8BitUInt() !== magicByte) {\n return Left(new Error(\"PSBT deserializer: Invalid magic bytes\"));\n }\n }\n\n // Read all the maps available in that PSBT\n const maps: Map<string, Value>[] = [];\n while (parser.getUnparsedRemainingLength()) {\n maps.push(this.keyPairSerializer.deserializeMap(parser));\n }\n if (maps.length === 0) {\n return Left(new Error(\"PSBT deserializer: No map found\"));\n }\n\n // Get global map\n const globalMap = maps[0]!;\n\n // Get inputs and outpus count, either from the global map, or within the tx\n const transaction = this.getValue(globalMap, PsbtGlobal.UNSIGNED_TX).chain(\n (value) =>\n Either.encase(() =>\n Transaction.fromHex(bufferToHexaString(value.data, false)),\n ).toMaybe(),\n );\n const inputCount = this.getValue(globalMap, PsbtGlobal.INPUT_COUNT)\n .chain((value) => this.valueParser.getVarint(value.data))\n .alt(transaction.map((tx) => tx.ins.length));\n const outputCount = this.getValue(globalMap, PsbtGlobal.OUTPUT_COUNT)\n .chain((value) => this.valueParser.getVarint(value.data))\n .alt(transaction.map((tx) => tx.outs.length));\n\n // Get inputs map and outputs map\n if (inputCount.isJust() && outputCount.isJust()) {\n if (maps.length === 1 + inputCount.extract() + outputCount.extract()) {\n const inputMaps = maps.slice(1, 1 + inputCount.extract());\n const outputMaps = maps.slice(1 + inputCount.extract());\n return Right(new Psbt(globalMap, inputMaps, outputMaps));\n }\n return Left(\n new Error(\n \"PSBT deserializer: map count don't match input and output count\",\n ),\n );\n }\n return Left(\n new Error(\n \"PSBT deserializer: input or output count not found in global map or transaction\",\n ),\n );\n }\n\n serialize(psbt: Psbt): Uint8Array {\n const builder = new ByteArrayBuilder();\n\n // Start by ordering all the maps, in case some values were added\n psbt.globalMap = this.sortMap(psbt.globalMap);\n psbt.inputMaps = psbt.inputMaps.map((input) => this.sortMap(input));\n psbt.outputMaps = psbt.outputMaps.map((output) => this.sortMap(output));\n\n // Serialize PSBT magic\n builder.addBufferToData(PSBT_MAGIC_BYTES);\n\n // Serialize all the maps\n this.keyPairSerializer.serializeMap(builder, psbt.globalMap);\n psbt.inputMaps.forEach((input) =>\n this.keyPairSerializer.serializeMap(builder, input),\n );\n psbt.outputMaps.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K,CACpD,EACAH,EAAK,WAAW,QAASI,GACvB,KAAK,kBAAkB,aAAaH,EAASG,CAAM,CACrD,EAEOH,EAAQ,MAAM,CACvB,CACF,EAhGa7B,EAANiC,EAAA,CAEFC,EAAA,EAAAC,EAAOC,EAAU,WAAW,GAE5BF,EAAA,EAAAC,EAAOC,EAAU,iBAAiB,IAJ1BpC",
|
|
6
6
|
"names": ["bufferToHexaString", "ByteArrayBuilder", "ByteArrayParser", "Transaction", "inject", "Either", "Left", "Maybe", "Right", "psbtTypes", "Key", "Psbt", "PsbtGlobal", "PSBT_MAGIC_BYTES", "DefaultPsbtSerializer", "valueParser", "keyPairSerializer", "map", "keyType", "Maybe", "Key", "b", "buffer", "parser", "ByteArrayParser", "magicByte", "Left", "maps", "globalMap", "transaction", "PsbtGlobal", "value", "Either", "Transaction", "bufferToHexaString", "inputCount", "tx", "outputCount", "inputMaps", "outputMaps", "Right", "Psbt", "psbt", "builder", "ByteArrayBuilder", "input", "output", "__decorateClass", "__decorateParam", "inject", "psbtTypes"]
|
|
7
7
|
}
|
package/lib/esm/package.json
CHANGED
|
@@ -1,63 +1,67 @@
|
|
|
1
1
|
{
|
|
2
|
-
"
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
"dependencies": {
|
|
3
|
+
"@types/crypto-js": "catalog:",
|
|
4
|
+
"crypto-js": "catalog:",
|
|
5
|
+
"inversify": "catalog:",
|
|
6
|
+
"purify-ts": "catalog:",
|
|
7
|
+
"reflect-metadata": "catalog:",
|
|
8
|
+
"xstate": "catalog:"
|
|
9
|
+
},
|
|
10
|
+
"devDependencies": {
|
|
11
|
+
"@ledgerhq/device-management-kit": "workspace:^",
|
|
12
|
+
"@ledgerhq/eslint-config-dsdk": "workspace:^",
|
|
13
|
+
"@ledgerhq/ldmk-tool": "workspace:^",
|
|
14
|
+
"@ledgerhq/prettier-config-dsdk": "workspace:^",
|
|
15
|
+
"@ledgerhq/signer-utils": "workspace:^",
|
|
16
|
+
"@ledgerhq/tsconfig-dsdk": "workspace:^",
|
|
17
|
+
"@ledgerhq/vitest-config-dmk": "workspace:^",
|
|
18
|
+
"bitcoinjs-lib": "catalog:",
|
|
19
|
+
"rxjs": "catalog:",
|
|
20
|
+
"ts-node": "catalog:"
|
|
21
|
+
},
|
|
8
22
|
"exports": {
|
|
9
23
|
".": {
|
|
10
|
-
"types": "./lib/types/index.d.ts",
|
|
11
24
|
"import": "./lib/esm/index.js",
|
|
12
|
-
"require": "./lib/cjs/index.js"
|
|
25
|
+
"require": "./lib/cjs/index.js",
|
|
26
|
+
"types": "./lib/types/index.d.ts"
|
|
13
27
|
},
|
|
14
28
|
"./*": {
|
|
15
|
-
"types": "./lib/types/*",
|
|
16
29
|
"import": "./lib/esm/*",
|
|
17
|
-
"require": "./lib/cjs/*"
|
|
30
|
+
"require": "./lib/cjs/*",
|
|
31
|
+
"types": "./lib/types/*"
|
|
18
32
|
}
|
|
19
33
|
},
|
|
20
34
|
"files": [
|
|
21
35
|
"./lib"
|
|
22
36
|
],
|
|
37
|
+
"license": "Apache-2.0",
|
|
38
|
+
"main": "lib/cjs/index.js",
|
|
39
|
+
"name": "@ledgerhq/device-signer-kit-bitcoin",
|
|
40
|
+
"peerDependencies": {
|
|
41
|
+
"@ledgerhq/device-management-kit": "workspace:^",
|
|
42
|
+
"bitcoinjs-lib": "^6.1.6"
|
|
43
|
+
},
|
|
44
|
+
"private": false,
|
|
45
|
+
"repository": {
|
|
46
|
+
"type": "git",
|
|
47
|
+
"url": "https://github.com/LedgerHQ/device-sdk-ts.git"
|
|
48
|
+
},
|
|
23
49
|
"scripts": {
|
|
24
|
-
"prebuild": "rimraf lib",
|
|
25
50
|
"build": "pnpm ldmk-tool build --entryPoints src/index.ts,src/**/*.ts --tsconfig tsconfig.prod.json",
|
|
26
51
|
"dev": "concurrently \"pnpm watch:builds\" \"pnpm watch:types\"",
|
|
27
|
-
"watch:builds": "pnpm ldmk-tool watch --entryPoints src/index.ts,src/**/*.ts --tsconfig tsconfig.prod.json",
|
|
28
|
-
"watch:types": "concurrently \"tsc --watch -p tsconfig.prod.json\" \"tsc-alias --watch -p tsconfig.prod.json\"",
|
|
29
52
|
"lint": "eslint",
|
|
30
53
|
"lint:fix": "pnpm lint --fix",
|
|
31
54
|
"postpack": "find . -name '*.tgz' -exec cp {} ../../../dist/ \\; ",
|
|
55
|
+
"prebuild": "rimraf lib",
|
|
32
56
|
"prettier": "prettier . --check",
|
|
33
57
|
"prettier:fix": "prettier . --write",
|
|
34
|
-
"typecheck": "tsc --noEmit",
|
|
35
58
|
"test": "vitest run",
|
|
59
|
+
"test:coverage": "vitest run --coverage",
|
|
36
60
|
"test:watch": "vitest",
|
|
37
|
-
"
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
"@types/crypto-js": "catalog:",
|
|
41
|
-
"crypto-js": "catalog:",
|
|
42
|
-
"inversify": "catalog:",
|
|
43
|
-
"purify-ts": "catalog:",
|
|
44
|
-
"reflect-metadata": "catalog:",
|
|
45
|
-
"xstate": "catalog:"
|
|
46
|
-
},
|
|
47
|
-
"devDependencies": {
|
|
48
|
-
"@ledgerhq/device-management-kit": "workspace:*",
|
|
49
|
-
"@ledgerhq/ldmk-tool": "workspace:*",
|
|
50
|
-
"@ledgerhq/eslint-config-dsdk": "workspace:*",
|
|
51
|
-
"@ledgerhq/prettier-config-dsdk": "workspace:*",
|
|
52
|
-
"@ledgerhq/signer-utils": "workspace:*",
|
|
53
|
-
"@ledgerhq/tsconfig-dsdk": "workspace:*",
|
|
54
|
-
"@ledgerhq/vitest-config-dmk": "workspace:*",
|
|
55
|
-
"bitcoinjs-lib": "catalog:",
|
|
56
|
-
"rxjs": "catalog:",
|
|
57
|
-
"ts-node": "catalog:"
|
|
61
|
+
"typecheck": "tsc --noEmit",
|
|
62
|
+
"watch:builds": "pnpm ldmk-tool watch --entryPoints src/index.ts,src/**/*.ts --tsconfig tsconfig.prod.json",
|
|
63
|
+
"watch:types": "concurrently \"tsc --watch -p tsconfig.prod.json\" \"tsc-alias --watch -p tsconfig.prod.json\""
|
|
58
64
|
},
|
|
59
|
-
"
|
|
60
|
-
|
|
61
|
-
"bitcoinjs-lib": "^6.1.6"
|
|
62
|
-
}
|
|
65
|
+
"types": "lib/cjs/index.d.ts",
|
|
66
|
+
"version": "0.0.0-z-intent-queue-7-20251204111630"
|
|
63
67
|
}
|
|
@@ -8,6 +8,7 @@ export type ContinueCommandResponse = ApduResponse;
|
|
|
8
8
|
export declare class ContinueCommand implements Command<ContinueCommandResponse, ContinueCommandArgs, BtcErrorCodes> {
|
|
9
9
|
private readonly _args;
|
|
10
10
|
private readonly _errorHelper;
|
|
11
|
+
readonly name = "continue";
|
|
11
12
|
constructor(_args: ContinueCommandArgs, _errorHelper?: CommandErrorHelper<ApduResponse, BtcErrorCodes>);
|
|
12
13
|
getApdu(): Apdu;
|
|
13
14
|
parseResponse(response: ApduResponse): CommandResult<ContinueCommandResponse, BtcErrorCodes>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContinueCommand.d.ts","sourceRoot":"","sources":["../../../../../src/internal/app-binder/command/ContinueCommand.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,IAAI,EAET,KAAK,YAAY,EACjB,KAAK,OAAO,EACZ,KAAK,aAAa,EAEnB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAG5D,OAAO,EAGL,KAAK,aAAa,EACnB,MAAM,qDAAqD,CAAC;AAG7D,MAAM,MAAM,mBAAmB,GAAG;IAChC,OAAO,EAAE,UAAU,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG,YAAY,CAAC;AAEnD,qBAAa,eACX,YACE,OAAO,CAAC,uBAAuB,EAAE,mBAAmB,EAAE,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"ContinueCommand.d.ts","sourceRoot":"","sources":["../../../../../src/internal/app-binder/command/ContinueCommand.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,IAAI,EAET,KAAK,YAAY,EACjB,KAAK,OAAO,EACZ,KAAK,aAAa,EAEnB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAG5D,OAAO,EAGL,KAAK,aAAa,EACnB,MAAM,qDAAqD,CAAC;AAG7D,MAAM,MAAM,mBAAmB,GAAG;IAChC,OAAO,EAAE,UAAU,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG,YAAY,CAAC;AAEnD,qBAAa,eACX,YACE,OAAO,CAAC,uBAAuB,EAAE,mBAAmB,EAAE,aAAa,CAAC;IAIpE,OAAO,CAAC,QAAQ,CAAC,KAAK;IACtB,OAAO,CAAC,QAAQ,CAAC,YAAY;IAH/B,QAAQ,CAAC,IAAI,cAAc;gBAER,KAAK,EAAE,mBAAmB,EAC1B,YAAY,kDAO5B;IAGH,OAAO,IAAI,IAAI;IAWf,aAAa,CACX,QAAQ,EAAE,YAAY,GACrB,aAAa,CAAC,uBAAuB,EAAE,aAAa,CAAC;CAOzD"}
|
|
@@ -11,6 +11,7 @@ export type GetExtendedPublicKeyCommandResponse = {
|
|
|
11
11
|
export declare class GetExtendedPublicKeyCommand implements Command<GetExtendedPublicKeyCommandResponse, GetExtendedPublicKeyCommandArgs, BtcErrorCodes> {
|
|
12
12
|
private readonly _args;
|
|
13
13
|
private readonly _errorHelper;
|
|
14
|
+
readonly name = "getExtendedPublicKey";
|
|
14
15
|
constructor(_args: GetExtendedPublicKeyCommandArgs, _errorHelper?: CommandErrorHelper<GetExtendedPublicKeyCommandResponse, BtcErrorCodes>);
|
|
15
16
|
getApdu(): Apdu;
|
|
16
17
|
parseResponse(response: ApduResponse): CommandResult<GetExtendedPublicKeyCommandResponse, BtcErrorCodes>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GetExtendedPublicKeyCommand.d.ts","sourceRoot":"","sources":["../../../../../src/internal/app-binder/command/GetExtendedPublicKeyCommand.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,IAAI,EAIT,KAAK,YAAY,EACjB,KAAK,OAAO,EACZ,KAAK,aAAa,EAGnB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACL,kBAAkB,EAEnB,MAAM,wBAAwB,CAAC;AAGhC,OAAO,EAGL,KAAK,aAAa,EACnB,MAAM,qDAAqD,CAAC;AAG7D,MAAM,MAAM,+BAA+B,GAAG;IAC5C,aAAa,EAAE,OAAO,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,mCAAmC,GAAG;IAChD,iBAAiB,EAAE,MAAM,CAAC;CAC3B,CAAC;AAEF,qBAAa,2BACX,YACE,OAAO,CACL,mCAAmC,EACnC,+BAA+B,EAC/B,aAAa,CACd;
|
|
1
|
+
{"version":3,"file":"GetExtendedPublicKeyCommand.d.ts","sourceRoot":"","sources":["../../../../../src/internal/app-binder/command/GetExtendedPublicKeyCommand.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,IAAI,EAIT,KAAK,YAAY,EACjB,KAAK,OAAO,EACZ,KAAK,aAAa,EAGnB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACL,kBAAkB,EAEnB,MAAM,wBAAwB,CAAC;AAGhC,OAAO,EAGL,KAAK,aAAa,EACnB,MAAM,qDAAqD,CAAC;AAG7D,MAAM,MAAM,+BAA+B,GAAG;IAC5C,aAAa,EAAE,OAAO,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,mCAAmC,GAAG;IAChD,iBAAiB,EAAE,MAAM,CAAC;CAC3B,CAAC;AAEF,qBAAa,2BACX,YACE,OAAO,CACL,mCAAmC,EACnC,+BAA+B,EAC/B,aAAa,CACd;IAID,OAAO,CAAC,QAAQ,CAAC,KAAK;IACtB,OAAO,CAAC,QAAQ,CAAC,YAAY;IAH/B,QAAQ,CAAC,IAAI,0BAA0B;gBAEpB,KAAK,EAAE,+BAA+B,EACtC,YAAY,yEAO5B;IAGH,OAAO,IAAI,IAAI;IAsBf,aAAa,CACX,QAAQ,EAAE,YAAY,GACrB,aAAa,CAAC,mCAAmC,EAAE,aAAa,CAAC;CAwBrE"}
|
|
@@ -6,6 +6,7 @@ type GetMasterFingerprintCommandResponse = {
|
|
|
6
6
|
};
|
|
7
7
|
export declare class GetMasterFingerprintCommand implements Command<GetMasterFingerprintCommandResponse, void, BtcErrorCodes> {
|
|
8
8
|
private readonly _errorHelper;
|
|
9
|
+
readonly name = "getMasterFingerprint";
|
|
9
10
|
constructor(_errorHelper?: CommandErrorHelper<GetMasterFingerprintCommandResponse, BtcErrorCodes>);
|
|
10
11
|
getApdu(): Apdu;
|
|
11
12
|
parseResponse(response: ApduResponse): CommandResult<GetMasterFingerprintCommandResponse, BtcErrorCodes>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GetMasterFingerprintCommand.d.ts","sourceRoot":"","sources":["../../../../../src/internal/app-binder/command/GetMasterFingerprintCommand.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,IAAI,EAIT,KAAK,YAAY,EACjB,KAAK,OAAO,EACZ,KAAK,aAAa,EAGnB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAG5D,OAAO,EAGL,KAAK,aAAa,EACnB,MAAM,qDAAqD,CAAC;AAK7D,KAAK,mCAAmC,GAAG;IACzC,iBAAiB,EAAE,UAAU,CAAC;CAC/B,CAAC;AAEF,qBAAa,2BACX,YAAW,OAAO,CAAC,mCAAmC,EAAE,IAAI,EAAE,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"GetMasterFingerprintCommand.d.ts","sourceRoot":"","sources":["../../../../../src/internal/app-binder/command/GetMasterFingerprintCommand.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,IAAI,EAIT,KAAK,YAAY,EACjB,KAAK,OAAO,EACZ,KAAK,aAAa,EAGnB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAG5D,OAAO,EAGL,KAAK,aAAa,EACnB,MAAM,qDAAqD,CAAC;AAK7D,KAAK,mCAAmC,GAAG;IACzC,iBAAiB,EAAE,UAAU,CAAC;CAC/B,CAAC;AAEF,qBAAa,2BACX,YAAW,OAAO,CAAC,mCAAmC,EAAE,IAAI,EAAE,aAAa,CAAC;IAI1E,OAAO,CAAC,QAAQ,CAAC,YAAY;IAF/B,QAAQ,CAAC,IAAI,0BAA0B;gBAEpB,YAAY,yEAO5B;IAEH,OAAO,IAAI,IAAI;IAUf,aAAa,CACX,QAAQ,EAAE,YAAY,GACrB,aAAa,CAAC,mCAAmC,EAAE,aAAa,CAAC;CAsBrE"}
|