@ledgerhq/device-signer-kit-solana 1.3.0 → 1.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/internal/app-binder/command/GetAppConfigurationCommand.js +1 -1
- package/lib/cjs/internal/app-binder/command/GetAppConfigurationCommand.js.map +2 -2
- package/lib/cjs/internal/app-binder/command/GetAppConfigurationCommand.test.js +1 -1
- package/lib/cjs/internal/app-binder/command/GetAppConfigurationCommand.test.js.map +2 -2
- package/lib/cjs/internal/app-binder/command/GetChallengeCommand.js +1 -1
- package/lib/cjs/internal/app-binder/command/GetChallengeCommand.js.map +2 -2
- package/lib/cjs/internal/app-binder/command/GetChallengeCommand.test.js +1 -1
- package/lib/cjs/internal/app-binder/command/GetChallengeCommand.test.js.map +2 -2
- package/lib/cjs/internal/app-binder/command/GetPubKeyCommand.js +1 -1
- package/lib/cjs/internal/app-binder/command/GetPubKeyCommand.js.map +2 -2
- package/lib/cjs/internal/app-binder/command/GetPubKeyCommand.test.js +1 -1
- package/lib/cjs/internal/app-binder/command/GetPubKeyCommand.test.js.map +2 -2
- package/lib/cjs/internal/app-binder/command/ProvideTLVDescriptorCommand.js +1 -1
- package/lib/cjs/internal/app-binder/command/ProvideTLVDescriptorCommand.js.map +2 -2
- package/lib/cjs/internal/app-binder/command/ProvideTLVDescriptorCommand.test.js +1 -1
- package/lib/cjs/internal/app-binder/command/ProvideTLVDescriptorCommand.test.js.map +2 -2
- package/lib/cjs/internal/app-binder/command/ProvideTrustedNamePKICommand.js +1 -1
- package/lib/cjs/internal/app-binder/command/ProvideTrustedNamePKICommand.js.map +2 -2
- package/lib/cjs/internal/app-binder/command/ProvideTrustedNamePKICommand.test.js +1 -1
- package/lib/cjs/internal/app-binder/command/ProvideTrustedNamePKICommand.test.js.map +2 -2
- package/lib/cjs/internal/app-binder/command/SignOffChainMessageCommand.js +1 -1
- package/lib/cjs/internal/app-binder/command/SignOffChainMessageCommand.js.map +3 -3
- package/lib/cjs/internal/app-binder/command/SignOffChainMessageCommand.test.js +1 -1
- package/lib/cjs/internal/app-binder/command/SignOffChainMessageCommand.test.js.map +3 -3
- package/lib/cjs/internal/app-binder/command/SignTransactionCommand.js +1 -1
- package/lib/cjs/internal/app-binder/command/SignTransactionCommand.js.map +2 -2
- package/lib/cjs/internal/app-binder/command/SignTransactionCommand.test.js +1 -1
- package/lib/cjs/internal/app-binder/command/SignTransactionCommand.test.js.map +3 -3
- package/lib/cjs/internal/app-binder/device-action/SignTransactionDeviceAction.test.js +1 -1
- package/lib/cjs/internal/app-binder/device-action/SignTransactionDeviceAction.test.js.map +2 -2
- package/lib/cjs/internal/app-binder/task/BuildTransactionContextTask.test.js +1 -1
- package/lib/cjs/internal/app-binder/task/BuildTransactionContextTask.test.js.map +2 -2
- package/lib/cjs/internal/app-binder/task/SendSignMessageTask.js +1 -1
- package/lib/cjs/internal/app-binder/task/SendSignMessageTask.js.map +3 -3
- package/lib/cjs/internal/app-binder/task/SendSignMessageTask.test.js +3 -1
- package/lib/cjs/internal/app-binder/task/SendSignMessageTask.test.js.map +3 -3
- package/lib/cjs/package.json +3 -3
- package/lib/esm/internal/app-binder/command/GetAppConfigurationCommand.js +1 -1
- package/lib/esm/internal/app-binder/command/GetAppConfigurationCommand.js.map +2 -2
- package/lib/esm/internal/app-binder/command/GetAppConfigurationCommand.test.js +1 -1
- package/lib/esm/internal/app-binder/command/GetAppConfigurationCommand.test.js.map +2 -2
- package/lib/esm/internal/app-binder/command/GetChallengeCommand.js +1 -1
- package/lib/esm/internal/app-binder/command/GetChallengeCommand.js.map +2 -2
- package/lib/esm/internal/app-binder/command/GetChallengeCommand.test.js +1 -1
- package/lib/esm/internal/app-binder/command/GetChallengeCommand.test.js.map +2 -2
- package/lib/esm/internal/app-binder/command/GetPubKeyCommand.js +1 -1
- package/lib/esm/internal/app-binder/command/GetPubKeyCommand.js.map +2 -2
- package/lib/esm/internal/app-binder/command/GetPubKeyCommand.test.js +1 -1
- package/lib/esm/internal/app-binder/command/GetPubKeyCommand.test.js.map +2 -2
- package/lib/esm/internal/app-binder/command/ProvideTLVDescriptorCommand.js +1 -1
- package/lib/esm/internal/app-binder/command/ProvideTLVDescriptorCommand.js.map +2 -2
- package/lib/esm/internal/app-binder/command/ProvideTLVDescriptorCommand.test.js +1 -1
- package/lib/esm/internal/app-binder/command/ProvideTLVDescriptorCommand.test.js.map +2 -2
- package/lib/esm/internal/app-binder/command/ProvideTrustedNamePKICommand.js +1 -1
- package/lib/esm/internal/app-binder/command/ProvideTrustedNamePKICommand.js.map +2 -2
- package/lib/esm/internal/app-binder/command/ProvideTrustedNamePKICommand.test.js +1 -1
- package/lib/esm/internal/app-binder/command/ProvideTrustedNamePKICommand.test.js.map +2 -2
- package/lib/esm/internal/app-binder/command/SignOffChainMessageCommand.js +1 -1
- package/lib/esm/internal/app-binder/command/SignOffChainMessageCommand.js.map +3 -3
- package/lib/esm/internal/app-binder/command/SignOffChainMessageCommand.test.js +1 -1
- package/lib/esm/internal/app-binder/command/SignOffChainMessageCommand.test.js.map +3 -3
- package/lib/esm/internal/app-binder/command/SignTransactionCommand.js +1 -1
- package/lib/esm/internal/app-binder/command/SignTransactionCommand.js.map +2 -2
- package/lib/esm/internal/app-binder/command/SignTransactionCommand.test.js +1 -1
- package/lib/esm/internal/app-binder/command/SignTransactionCommand.test.js.map +3 -3
- package/lib/esm/internal/app-binder/device-action/SignTransactionDeviceAction.test.js +1 -1
- package/lib/esm/internal/app-binder/device-action/SignTransactionDeviceAction.test.js.map +2 -2
- package/lib/esm/internal/app-binder/task/BuildTransactionContextTask.test.js +1 -1
- package/lib/esm/internal/app-binder/task/BuildTransactionContextTask.test.js.map +2 -2
- package/lib/esm/internal/app-binder/task/SendSignMessageTask.js +1 -1
- package/lib/esm/internal/app-binder/task/SendSignMessageTask.js.map +3 -3
- package/lib/esm/internal/app-binder/task/SendSignMessageTask.test.js +3 -1
- package/lib/esm/internal/app-binder/task/SendSignMessageTask.test.js.map +3 -3
- package/lib/esm/package.json +3 -3
- package/lib/types/internal/app-binder/command/GetAppConfigurationCommand.d.ts +1 -0
- package/lib/types/internal/app-binder/command/GetAppConfigurationCommand.d.ts.map +1 -1
- package/lib/types/internal/app-binder/command/GetChallengeCommand.d.ts +1 -0
- package/lib/types/internal/app-binder/command/GetChallengeCommand.d.ts.map +1 -1
- package/lib/types/internal/app-binder/command/GetPubKeyCommand.d.ts +1 -0
- package/lib/types/internal/app-binder/command/GetPubKeyCommand.d.ts.map +1 -1
- package/lib/types/internal/app-binder/command/ProvideTLVDescriptorCommand.d.ts +1 -0
- package/lib/types/internal/app-binder/command/ProvideTLVDescriptorCommand.d.ts.map +1 -1
- package/lib/types/internal/app-binder/command/ProvideTrustedNamePKICommand.d.ts +1 -0
- package/lib/types/internal/app-binder/command/ProvideTrustedNamePKICommand.d.ts.map +1 -1
- package/lib/types/internal/app-binder/command/SignOffChainMessageCommand.d.ts +14 -12
- package/lib/types/internal/app-binder/command/SignOffChainMessageCommand.d.ts.map +1 -1
- package/lib/types/internal/app-binder/command/SignTransactionCommand.d.ts +1 -0
- package/lib/types/internal/app-binder/command/SignTransactionCommand.d.ts.map +1 -1
- package/lib/types/internal/app-binder/task/SendSignMessageTask.d.ts +19 -5
- package/lib/types/internal/app-binder/task/SendSignMessageTask.d.ts.map +1 -1
- package/lib/types/tsconfig.prod.tsbuildinfo +1 -1
- package/package.json +5 -5
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/internal/app-binder/command/GetAppConfigurationCommand.test.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n ApduResponse,\n CommandResultFactory,\n isSuccessCommandResult,\n} from \"@ledgerhq/device-management-kit\";\n\nimport { PublicKeyDisplayMode } from \"@api/model/PublicKeyDisplayMode\";\n\nimport { GetAppConfigurationCommand } from \"./GetAppConfigurationCommand\";\n\nconst GET_APP_CONFIG_APDU = new Uint8Array([0xe0, 0x04, 0x00, 0x00, 0x00]);\n\nconst GET_APP_CONFIG_RESPONSE_DATA = new Uint8Array([\n 0x01, 0x00, 0x02, 0x05, 0x0a,\n]);\n\nconst GET_APP_CONFIG_RESPONSE = new ApduResponse({\n statusCode: Uint8Array.from([0x90, 0x00]),\n data: GET_APP_CONFIG_RESPONSE_DATA,\n});\n\nconst GET_APP_CONFIG_RESPONSE_DATA_SHORT_PUB_KEY_DISPLAY_MODE = new Uint8Array([\n 0x01, 0x01, 0x02, 0x05, 0x0a,\n]);\n\nconst GET_APP_CONFIG_RESPONSE_SHORT_PUB_KEY_DISPLAY_MODE = new ApduResponse({\n statusCode: Uint8Array.from([0x90, 0x00]),\n data: GET_APP_CONFIG_RESPONSE_DATA_SHORT_PUB_KEY_DISPLAY_MODE,\n});\n\ndescribe(\"GetAppConfigurationCommand\", () => {\n let command: GetAppConfigurationCommand;\n\n beforeEach(() => {\n command = new GetAppConfigurationCommand();\n vi.clearAllMocks();\n vi.importActual(\"@ledgerhq/device-management-kit\");\n });\n\n describe(\"getApdu\", () => {\n it(\"should return the correct APDU\", () => {\n const apdu = command.getApdu();\n expect(apdu.getRawApdu()).toEqual(GET_APP_CONFIG_APDU);\n });\n });\n\n describe(\"parseResponse\", () => {\n it(\"should parse the response correctly\", () => {\n const parsed = command.parseResponse(GET_APP_CONFIG_RESPONSE);\n expect(parsed).toStrictEqual(\n CommandResultFactory({\n data: {\n blindSigningEnabled: true,\n pubKeyDisplayMode: PublicKeyDisplayMode.LONG,\n version: \"2.5.10\",\n },\n }),\n );\n });\n\n it(\"should parse the response correctly with short pub key display mode\", () => {\n const parsed = command.parseResponse(\n GET_APP_CONFIG_RESPONSE_SHORT_PUB_KEY_DISPLAY_MODE,\n );\n expect(parsed).toStrictEqual(\n CommandResultFactory({\n data: {\n blindSigningEnabled: true,\n pubKeyDisplayMode: PublicKeyDisplayMode.SHORT,\n version: \"2.5.10\",\n },\n }),\n );\n });\n\n describe(\"error handling\", () => {\n it(\"should return error if response is not success\", () => {\n const response = new ApduResponse({\n statusCode: Uint8Array.from([0x6a, 0x82]),\n data: new Uint8Array(0),\n });\n const result = command.parseResponse(response);\n expect(isSuccessCommandResult(result)).toBe(false);\n if (!isSuccessCommandResult(result)) {\n expect(result.error).toEqual(\n expect.objectContaining({\n _tag: \"SolanaAppCommandError\",\n errorCode: \"6a82\",\n message: \"Invalid off-chain message format\",\n }),\n );\n } else {\n assert.fail(\"Expected error\");\n }\n });\n\n it(\"should return error if response is not success\", () => {\n const response = new ApduResponse({\n statusCode: Uint8Array.from([0x6a, 0x82]),\n data: new Uint8Array(0),\n });\n const result = command.parseResponse(response);\n expect(isSuccessCommandResult(result)).toBe(false);\n if (!isSuccessCommandResult(result)) {\n expect(result.error).toEqual(\n expect.objectContaining({\n _tag: \"SolanaAppCommandError\",\n errorCode: \"6a82\",\n message: \"Invalid off-chain message format\",\n }),\n );\n } else {\n assert.fail(\"Expected error\");\n }\n });\n });\n });\n});\n"],
|
|
5
|
-
"mappings": "AAAA,OACE,gBAAAA,EACA,wBAAAC,EACA,0BAAAC,MACK,kCAEP,OAAS,wBAAAC,MAA4B,kCAErC,OAAS,8BAAAC,MAAkC,+BAE3C,MAAMC,EAAsB,IAAI,WAAW,CAAC,IAAM,EAAM,EAAM,EAAM,CAAI,CAAC,EAEnEC,EAA+B,IAAI,WAAW,CAClD,EAAM,EAAM,EAAM,EAAM,EAC1B,CAAC,EAEKC,EAA0B,IAAIP,EAAa,CAC/C,WAAY,WAAW,KAAK,CAAC,IAAM,CAAI,CAAC,EACxC,KAAMM,CACR,CAAC,EAEKE,EAA0D,IAAI,WAAW,CAC7E,EAAM,EAAM,EAAM,EAAM,EAC1B,CAAC,EAEKC,EAAqD,IAAIT,EAAa,CAC1E,WAAY,WAAW,KAAK,CAAC,IAAM,CAAI,CAAC,EACxC,KAAMQ,CACR,CAAC,EAED,SAAS,6BAA8B,IAAM,CAC3C,IAAIE,EAEJ,WAAW,IAAM,CACfA,EAAU,IAAIN,EACd,GAAG,cAAc,EACjB,GAAG,aAAa,iCAAiC,CACnD,CAAC,EAED,SAAS,UAAW,IAAM,CACxB,GAAG,iCAAkC,IAAM,CACzC,
|
|
4
|
+
"sourcesContent": ["import {\n ApduResponse,\n CommandResultFactory,\n isSuccessCommandResult,\n} from \"@ledgerhq/device-management-kit\";\n\nimport { PublicKeyDisplayMode } from \"@api/model/PublicKeyDisplayMode\";\n\nimport { GetAppConfigurationCommand } from \"./GetAppConfigurationCommand\";\n\nconst GET_APP_CONFIG_APDU = new Uint8Array([0xe0, 0x04, 0x00, 0x00, 0x00]);\n\nconst GET_APP_CONFIG_RESPONSE_DATA = new Uint8Array([\n 0x01, 0x00, 0x02, 0x05, 0x0a,\n]);\n\nconst GET_APP_CONFIG_RESPONSE = new ApduResponse({\n statusCode: Uint8Array.from([0x90, 0x00]),\n data: GET_APP_CONFIG_RESPONSE_DATA,\n});\n\nconst GET_APP_CONFIG_RESPONSE_DATA_SHORT_PUB_KEY_DISPLAY_MODE = new Uint8Array([\n 0x01, 0x01, 0x02, 0x05, 0x0a,\n]);\n\nconst GET_APP_CONFIG_RESPONSE_SHORT_PUB_KEY_DISPLAY_MODE = new ApduResponse({\n statusCode: Uint8Array.from([0x90, 0x00]),\n data: GET_APP_CONFIG_RESPONSE_DATA_SHORT_PUB_KEY_DISPLAY_MODE,\n});\n\ndescribe(\"GetAppConfigurationCommand\", () => {\n let command: GetAppConfigurationCommand;\n\n beforeEach(() => {\n command = new GetAppConfigurationCommand();\n vi.clearAllMocks();\n vi.importActual(\"@ledgerhq/device-management-kit\");\n });\n\n describe(\"name\", () => {\n it(\"should be 'getAppConfiguration'\", () => {\n expect(command.name).toBe(\"getAppConfiguration\");\n });\n });\n\n describe(\"getApdu\", () => {\n it(\"should return the correct APDU\", () => {\n const apdu = command.getApdu();\n expect(apdu.getRawApdu()).toEqual(GET_APP_CONFIG_APDU);\n });\n });\n\n describe(\"parseResponse\", () => {\n it(\"should parse the response correctly\", () => {\n const parsed = command.parseResponse(GET_APP_CONFIG_RESPONSE);\n expect(parsed).toStrictEqual(\n CommandResultFactory({\n data: {\n blindSigningEnabled: true,\n pubKeyDisplayMode: PublicKeyDisplayMode.LONG,\n version: \"2.5.10\",\n },\n }),\n );\n });\n\n it(\"should parse the response correctly with short pub key display mode\", () => {\n const parsed = command.parseResponse(\n GET_APP_CONFIG_RESPONSE_SHORT_PUB_KEY_DISPLAY_MODE,\n );\n expect(parsed).toStrictEqual(\n CommandResultFactory({\n data: {\n blindSigningEnabled: true,\n pubKeyDisplayMode: PublicKeyDisplayMode.SHORT,\n version: \"2.5.10\",\n },\n }),\n );\n });\n\n describe(\"error handling\", () => {\n it(\"should return error if response is not success\", () => {\n const response = new ApduResponse({\n statusCode: Uint8Array.from([0x6a, 0x82]),\n data: new Uint8Array(0),\n });\n const result = command.parseResponse(response);\n expect(isSuccessCommandResult(result)).toBe(false);\n if (!isSuccessCommandResult(result)) {\n expect(result.error).toEqual(\n expect.objectContaining({\n _tag: \"SolanaAppCommandError\",\n errorCode: \"6a82\",\n message: \"Invalid off-chain message format\",\n }),\n );\n } else {\n assert.fail(\"Expected error\");\n }\n });\n\n it(\"should return error if response is not success\", () => {\n const response = new ApduResponse({\n statusCode: Uint8Array.from([0x6a, 0x82]),\n data: new Uint8Array(0),\n });\n const result = command.parseResponse(response);\n expect(isSuccessCommandResult(result)).toBe(false);\n if (!isSuccessCommandResult(result)) {\n expect(result.error).toEqual(\n expect.objectContaining({\n _tag: \"SolanaAppCommandError\",\n errorCode: \"6a82\",\n message: \"Invalid off-chain message format\",\n }),\n );\n } else {\n assert.fail(\"Expected error\");\n }\n });\n });\n });\n});\n"],
|
|
5
|
+
"mappings": "AAAA,OACE,gBAAAA,EACA,wBAAAC,EACA,0BAAAC,MACK,kCAEP,OAAS,wBAAAC,MAA4B,kCAErC,OAAS,8BAAAC,MAAkC,+BAE3C,MAAMC,EAAsB,IAAI,WAAW,CAAC,IAAM,EAAM,EAAM,EAAM,CAAI,CAAC,EAEnEC,EAA+B,IAAI,WAAW,CAClD,EAAM,EAAM,EAAM,EAAM,EAC1B,CAAC,EAEKC,EAA0B,IAAIP,EAAa,CAC/C,WAAY,WAAW,KAAK,CAAC,IAAM,CAAI,CAAC,EACxC,KAAMM,CACR,CAAC,EAEKE,EAA0D,IAAI,WAAW,CAC7E,EAAM,EAAM,EAAM,EAAM,EAC1B,CAAC,EAEKC,EAAqD,IAAIT,EAAa,CAC1E,WAAY,WAAW,KAAK,CAAC,IAAM,CAAI,CAAC,EACxC,KAAMQ,CACR,CAAC,EAED,SAAS,6BAA8B,IAAM,CAC3C,IAAIE,EAEJ,WAAW,IAAM,CACfA,EAAU,IAAIN,EACd,GAAG,cAAc,EACjB,GAAG,aAAa,iCAAiC,CACnD,CAAC,EAED,SAAS,OAAQ,IAAM,CACrB,GAAG,kCAAmC,IAAM,CAC1C,OAAOM,EAAQ,IAAI,EAAE,KAAK,qBAAqB,CACjD,CAAC,CACH,CAAC,EAED,SAAS,UAAW,IAAM,CACxB,GAAG,iCAAkC,IAAM,CACzC,MAAMC,EAAOD,EAAQ,QAAQ,EAC7B,OAAOC,EAAK,WAAW,CAAC,EAAE,QAAQN,CAAmB,CACvD,CAAC,CACH,CAAC,EAED,SAAS,gBAAiB,IAAM,CAC9B,GAAG,sCAAuC,IAAM,CAC9C,MAAMO,EAASF,EAAQ,cAAcH,CAAuB,EAC5D,OAAOK,CAAM,EAAE,cACbX,EAAqB,CACnB,KAAM,CACJ,oBAAqB,GACrB,kBAAmBE,EAAqB,KACxC,QAAS,QACX,CACF,CAAC,CACH,CACF,CAAC,EAED,GAAG,sEAAuE,IAAM,CAC9E,MAAMS,EAASF,EAAQ,cACrBD,CACF,EACA,OAAOG,CAAM,EAAE,cACbX,EAAqB,CACnB,KAAM,CACJ,oBAAqB,GACrB,kBAAmBE,EAAqB,MACxC,QAAS,QACX,CACF,CAAC,CACH,CACF,CAAC,EAED,SAAS,iBAAkB,IAAM,CAC/B,GAAG,iDAAkD,IAAM,CACzD,MAAMU,EAAW,IAAIb,EAAa,CAChC,WAAY,WAAW,KAAK,CAAC,IAAM,GAAI,CAAC,EACxC,KAAM,IAAI,WAAW,CAAC,CACxB,CAAC,EACKc,EAASJ,EAAQ,cAAcG,CAAQ,EAC7C,OAAOX,EAAuBY,CAAM,CAAC,EAAE,KAAK,EAAK,EAC5CZ,EAAuBY,CAAM,EAShC,OAAO,KAAK,gBAAgB,EAR5B,OAAOA,EAAO,KAAK,EAAE,QACnB,OAAO,iBAAiB,CACtB,KAAM,wBACN,UAAW,OACX,QAAS,kCACX,CAAC,CACH,CAIJ,CAAC,EAED,GAAG,iDAAkD,IAAM,CACzD,MAAMD,EAAW,IAAIb,EAAa,CAChC,WAAY,WAAW,KAAK,CAAC,IAAM,GAAI,CAAC,EACxC,KAAM,IAAI,WAAW,CAAC,CACxB,CAAC,EACKc,EAASJ,EAAQ,cAAcG,CAAQ,EAC7C,OAAOX,EAAuBY,CAAM,CAAC,EAAE,KAAK,EAAK,EAC5CZ,EAAuBY,CAAM,EAShC,OAAO,KAAK,gBAAgB,EAR5B,OAAOA,EAAO,KAAK,EAAE,QACnB,OAAO,iBAAiB,CACtB,KAAM,wBACN,UAAW,OACX,QAAS,kCACX,CAAC,CACH,CAIJ,CAAC,CACH,CAAC,CACH,CAAC,CACH,CAAC",
|
|
6
6
|
"names": ["ApduResponse", "CommandResultFactory", "isSuccessCommandResult", "PublicKeyDisplayMode", "GetAppConfigurationCommand", "GET_APP_CONFIG_APDU", "GET_APP_CONFIG_RESPONSE_DATA", "GET_APP_CONFIG_RESPONSE", "GET_APP_CONFIG_RESPONSE_DATA_SHORT_PUB_KEY_DISPLAY_MODE", "GET_APP_CONFIG_RESPONSE_SHORT_PUB_KEY_DISPLAY_MODE", "command", "apdu", "parsed", "response", "result"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{ApduBuilder as t,ApduParser as
|
|
1
|
+
import{ApduBuilder as t,ApduParser as l,CommandResultFactory as o,InvalidStatusWordError as p}from"@ledgerhq/device-management-kit";import{CommandErrorHelper as s}from"@ledgerhq/signer-utils";import{Maybe as m}from"purify-ts";import{SOLANA_APP_ERRORS as d,SolanaAppCommandErrorFactory as C}from"./utils/SolanaApplicationErrors";const i=224,u=32,g=0,A=0,n=4;class S{name="getChallenge";errorHelper=new s(d,C);getApdu(){return new t({cla:i,ins:u,p1:g,p2:A}).build()}parseResponse(r){return m.fromNullable(this.errorHelper.getError(r)).orDefaultLazy(()=>{const e=new l(r);if(e.testMinimalLength(n)===!1)return o({error:new p("Challenge key is missing")});const a=e.encodeToHexaString(e.extractFieldByLength(n));return o({data:{challenge:a}})})}}export{S as GetChallengeCommand};
|
|
2
2
|
//# sourceMappingURL=GetChallengeCommand.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/internal/app-binder/command/GetChallengeCommand.ts"],
|
|
4
|
-
"sourcesContent": ["// https://github.com/LedgerHQ/app-solana/blob/develop/doc/api.md#get-challenge\nimport {\n type Apdu,\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 SOLANA_APP_ERRORS,\n SolanaAppCommandErrorFactory,\n type SolanaAppErrorCodes,\n} from \"./utils/SolanaApplicationErrors\";\n\nconst CLA = 0xe0;\nconst INS = 0x20;\nconst P1 = 0x00;\nconst P2 = 0x00;\nconst CHALLENGE_LENGTH = 4;\n\nexport type GetChallengeCommandResponse = {\n challenge: string;\n};\n\nexport class GetChallengeCommand\n implements Command<GetChallengeCommandResponse, void, SolanaAppErrorCodes>\n{\n private readonly errorHelper = new CommandErrorHelper<\n GetChallengeCommandResponse,\n SolanaAppErrorCodes\n >(SOLANA_APP_ERRORS, SolanaAppCommandErrorFactory);\n\n getApdu(): Apdu {\n return new ApduBuilder({\n cla: CLA,\n ins: INS,\n p1: P1,\n p2: P2,\n }).build();\n }\n\n parseResponse(\n response: ApduResponse,\n ): CommandResult<GetChallengeCommandResponse, SolanaAppErrorCodes> {\n return Maybe.fromNullable(\n this.errorHelper.getError(response),\n ).orDefaultLazy(() => {\n const parser = new ApduParser(response);\n\n if (parser.testMinimalLength(CHALLENGE_LENGTH) === false) {\n return CommandResultFactory({\n error: new InvalidStatusWordError(\"Challenge key is missing\"),\n });\n }\n\n const challenge = parser.encodeToHexaString(\n parser.extractFieldByLength(CHALLENGE_LENGTH),\n );\n\n return CommandResultFactory({\n data: {\n challenge,\n },\n });\n });\n }\n}\n"],
|
|
5
|
-
"mappings": "AACA,OAEE,eAAAA,EACA,cAAAC,EAIA,wBAAAC,EACA,0BAAAC,MACK,kCACP,OAAS,sBAAAC,MAA0B,yBACnC,OAAS,SAAAC,MAAa,YAEtB,OACE,qBAAAC,EACA,gCAAAC,MAEK,kCAEP,MAAMC,EAAM,IACNC,EAAM,GACNC,EAAK,EACLC,EAAK,EACLC,EAAmB,EAMlB,MAAMC,CAEb,
|
|
4
|
+
"sourcesContent": ["// https://github.com/LedgerHQ/app-solana/blob/develop/doc/api.md#get-challenge\nimport {\n type Apdu,\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 SOLANA_APP_ERRORS,\n SolanaAppCommandErrorFactory,\n type SolanaAppErrorCodes,\n} from \"./utils/SolanaApplicationErrors\";\n\nconst CLA = 0xe0;\nconst INS = 0x20;\nconst P1 = 0x00;\nconst P2 = 0x00;\nconst CHALLENGE_LENGTH = 4;\n\nexport type GetChallengeCommandResponse = {\n challenge: string;\n};\n\nexport class GetChallengeCommand\n implements Command<GetChallengeCommandResponse, void, SolanaAppErrorCodes>\n{\n readonly name = \"getChallenge\";\n private readonly errorHelper = new CommandErrorHelper<\n GetChallengeCommandResponse,\n SolanaAppErrorCodes\n >(SOLANA_APP_ERRORS, SolanaAppCommandErrorFactory);\n\n getApdu(): Apdu {\n return new ApduBuilder({\n cla: CLA,\n ins: INS,\n p1: P1,\n p2: P2,\n }).build();\n }\n\n parseResponse(\n response: ApduResponse,\n ): CommandResult<GetChallengeCommandResponse, SolanaAppErrorCodes> {\n return Maybe.fromNullable(\n this.errorHelper.getError(response),\n ).orDefaultLazy(() => {\n const parser = new ApduParser(response);\n\n if (parser.testMinimalLength(CHALLENGE_LENGTH) === false) {\n return CommandResultFactory({\n error: new InvalidStatusWordError(\"Challenge key is missing\"),\n });\n }\n\n const challenge = parser.encodeToHexaString(\n parser.extractFieldByLength(CHALLENGE_LENGTH),\n );\n\n return CommandResultFactory({\n data: {\n challenge,\n },\n });\n });\n }\n}\n"],
|
|
5
|
+
"mappings": "AACA,OAEE,eAAAA,EACA,cAAAC,EAIA,wBAAAC,EACA,0BAAAC,MACK,kCACP,OAAS,sBAAAC,MAA0B,yBACnC,OAAS,SAAAC,MAAa,YAEtB,OACE,qBAAAC,EACA,gCAAAC,MAEK,kCAEP,MAAMC,EAAM,IACNC,EAAM,GACNC,EAAK,EACLC,EAAK,EACLC,EAAmB,EAMlB,MAAMC,CAEb,CACW,KAAO,eACC,YAAc,IAAIT,EAGjCE,EAAmBC,CAA4B,EAEjD,SAAgB,CACd,OAAO,IAAIP,EAAY,CACrB,IAAKQ,EACL,IAAKC,EACL,GAAIC,EACJ,GAAIC,CACN,CAAC,EAAE,MAAM,CACX,CAEA,cACEG,EACiE,CACjE,OAAOT,EAAM,aACX,KAAK,YAAY,SAASS,CAAQ,CACpC,EAAE,cAAc,IAAM,CACpB,MAAMC,EAAS,IAAId,EAAWa,CAAQ,EAEtC,GAAIC,EAAO,kBAAkBH,CAAgB,IAAM,GACjD,OAAOV,EAAqB,CAC1B,MAAO,IAAIC,EAAuB,0BAA0B,CAC9D,CAAC,EAGH,MAAMa,EAAYD,EAAO,mBACvBA,EAAO,qBAAqBH,CAAgB,CAC9C,EAEA,OAAOV,EAAqB,CAC1B,KAAM,CACJ,UAAAc,CACF,CACF,CAAC,CACH,CAAC,CACH,CACF",
|
|
6
6
|
"names": ["ApduBuilder", "ApduParser", "CommandResultFactory", "InvalidStatusWordError", "CommandErrorHelper", "Maybe", "SOLANA_APP_ERRORS", "SolanaAppCommandErrorFactory", "CLA", "INS", "P1", "P2", "CHALLENGE_LENGTH", "GetChallengeCommand", "response", "parser", "challenge"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{CommandResultFactory as
|
|
1
|
+
import{CommandResultFactory as r,InvalidStatusWordError as o,isSuccessCommandResult as s}from"@ledgerhq/device-management-kit";import{GetChallengeCommand as a}from"./GetChallengeCommand";const n=Uint8Array.from([224,32,0,0,0]),c=Uint8Array.from([1,2,3,4]),d={statusCode:Uint8Array.from([144,0]),data:c},l={statusCode:Uint8Array.from([85,21]),data:new Uint8Array},p=Uint8Array.from([1,2]),i={statusCode:Uint8Array.from([144,0]),data:p};describe("GetChallengeCommand",()=>{let t;beforeEach(()=>{t=new a}),describe("name",()=>{it("should be 'getChallenge'",()=>{expect(t.name).toBe("getChallenge")})}),describe("getApdu",()=>{it("should return the challenge apdu",()=>{const e=t.getApdu();expect(e.getRawApdu()).toStrictEqual(n)})}),describe("parseResponse",()=>{it("should parse the response",()=>{const e=t.parseResponse(d);expect(e).toStrictEqual(r({data:{challenge:"01020304"}}))}),it("should return an error if the response is not successful",()=>{const e=t.parseResponse(l);expect(s(e)).toBe(!1)}),it("should return an error if the response is too short",()=>{const e=t.parseResponse(i);expect(s(e)).toBe(!1),expect(e.error).toBeInstanceOf(o)})})});
|
|
2
2
|
//# sourceMappingURL=GetChallengeCommand.test.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/internal/app-binder/command/GetChallengeCommand.test.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n CommandResultFactory,\n InvalidStatusWordError,\n isSuccessCommandResult,\n} from \"@ledgerhq/device-management-kit\";\n\nimport { GetChallengeCommand } from \"./GetChallengeCommand\";\n\nconst GET_CHALLENGE_APDU = Uint8Array.from([0xe0, 0x20, 0x00, 0x00, 0x00]);\n\nconst LNX_RESPONSE_DATA_GOOD = Uint8Array.from([0x01, 0x02, 0x03, 0x04]);\n\nconst LNX_RESPONSE_GOOD = {\n statusCode: Uint8Array.from([0x90, 0x00]),\n data: LNX_RESPONSE_DATA_GOOD,\n};\n\nconst LNX_RESPONSE_LOCKED = {\n statusCode: Uint8Array.from([0x55, 0x15]),\n data: new Uint8Array(),\n};\n\nconst LNX_RESPONSE_DATA_TOO_SHORT = Uint8Array.from([0x01, 0x02]);\n\nconst LNX_RESPONSE_TOO_SHORT = {\n statusCode: Uint8Array.from([0x90, 0x00]),\n data: LNX_RESPONSE_DATA_TOO_SHORT,\n};\n\ndescribe(\"GetChallengeCommand\", () => {\n let command: GetChallengeCommand;\n\n beforeEach(() => {\n command = new GetChallengeCommand();\n });\n\n describe(\"getApdu\", () => {\n it(\"should return the challenge apdu\", () => {\n const apdu = command.getApdu();\n expect(apdu.getRawApdu()).toStrictEqual(GET_CHALLENGE_APDU);\n });\n });\n\n describe(\"parseResponse\", () => {\n it(\"should parse the response\", () => {\n const parsedResponse = command.parseResponse(LNX_RESPONSE_GOOD);\n expect(parsedResponse).toStrictEqual(\n CommandResultFactory({\n data: {\n challenge: \"01020304\",\n },\n }),\n );\n });\n\n it(\"should return an error if the response is not successful\", () => {\n const result = command.parseResponse(LNX_RESPONSE_LOCKED);\n expect(isSuccessCommandResult(result)).toBe(false);\n });\n\n it(\"should return an error if the response is too short\", () => {\n const result = command.parseResponse(LNX_RESPONSE_TOO_SHORT);\n\n expect(isSuccessCommandResult(result)).toBe(false);\n // @ts-ignore\n expect(result.error).toBeInstanceOf(InvalidStatusWordError);\n });\n });\n});\n"],
|
|
5
|
-
"mappings": "AAAA,OACE,wBAAAA,EACA,0BAAAC,EACA,0BAAAC,MACK,kCAEP,OAAS,uBAAAC,MAA2B,wBAEpC,MAAMC,EAAqB,WAAW,KAAK,CAAC,IAAM,GAAM,EAAM,EAAM,CAAI,CAAC,EAEnEC,EAAyB,WAAW,KAAK,CAAC,EAAM,EAAM,EAAM,CAAI,CAAC,EAEjEC,EAAoB,CACxB,WAAY,WAAW,KAAK,CAAC,IAAM,CAAI,CAAC,EACxC,KAAMD,CACR,EAEME,EAAsB,CAC1B,WAAY,WAAW,KAAK,CAAC,GAAM,EAAI,CAAC,EACxC,KAAM,IAAI,UACZ,EAEMC,EAA8B,WAAW,KAAK,CAAC,EAAM,CAAI,CAAC,EAE1DC,EAAyB,CAC7B,WAAY,WAAW,KAAK,CAAC,IAAM,CAAI,CAAC,EACxC,KAAMD,CACR,EAEA,SAAS,sBAAuB,IAAM,CACpC,IAAIE,EAEJ,WAAW,IAAM,CACfA,EAAU,IAAIP,CAChB,CAAC,EAED,SAAS,UAAW,IAAM,CACxB,GAAG,mCAAoC,IAAM,CAC3C,
|
|
4
|
+
"sourcesContent": ["import {\n CommandResultFactory,\n InvalidStatusWordError,\n isSuccessCommandResult,\n} from \"@ledgerhq/device-management-kit\";\n\nimport { GetChallengeCommand } from \"./GetChallengeCommand\";\n\nconst GET_CHALLENGE_APDU = Uint8Array.from([0xe0, 0x20, 0x00, 0x00, 0x00]);\n\nconst LNX_RESPONSE_DATA_GOOD = Uint8Array.from([0x01, 0x02, 0x03, 0x04]);\n\nconst LNX_RESPONSE_GOOD = {\n statusCode: Uint8Array.from([0x90, 0x00]),\n data: LNX_RESPONSE_DATA_GOOD,\n};\n\nconst LNX_RESPONSE_LOCKED = {\n statusCode: Uint8Array.from([0x55, 0x15]),\n data: new Uint8Array(),\n};\n\nconst LNX_RESPONSE_DATA_TOO_SHORT = Uint8Array.from([0x01, 0x02]);\n\nconst LNX_RESPONSE_TOO_SHORT = {\n statusCode: Uint8Array.from([0x90, 0x00]),\n data: LNX_RESPONSE_DATA_TOO_SHORT,\n};\n\ndescribe(\"GetChallengeCommand\", () => {\n let command: GetChallengeCommand;\n\n beforeEach(() => {\n command = new GetChallengeCommand();\n });\n\n describe(\"name\", () => {\n it(\"should be 'getChallenge'\", () => {\n expect(command.name).toBe(\"getChallenge\");\n });\n });\n\n describe(\"getApdu\", () => {\n it(\"should return the challenge apdu\", () => {\n const apdu = command.getApdu();\n expect(apdu.getRawApdu()).toStrictEqual(GET_CHALLENGE_APDU);\n });\n });\n\n describe(\"parseResponse\", () => {\n it(\"should parse the response\", () => {\n const parsedResponse = command.parseResponse(LNX_RESPONSE_GOOD);\n expect(parsedResponse).toStrictEqual(\n CommandResultFactory({\n data: {\n challenge: \"01020304\",\n },\n }),\n );\n });\n\n it(\"should return an error if the response is not successful\", () => {\n const result = command.parseResponse(LNX_RESPONSE_LOCKED);\n expect(isSuccessCommandResult(result)).toBe(false);\n });\n\n it(\"should return an error if the response is too short\", () => {\n const result = command.parseResponse(LNX_RESPONSE_TOO_SHORT);\n\n expect(isSuccessCommandResult(result)).toBe(false);\n // @ts-ignore\n expect(result.error).toBeInstanceOf(InvalidStatusWordError);\n });\n });\n});\n"],
|
|
5
|
+
"mappings": "AAAA,OACE,wBAAAA,EACA,0BAAAC,EACA,0BAAAC,MACK,kCAEP,OAAS,uBAAAC,MAA2B,wBAEpC,MAAMC,EAAqB,WAAW,KAAK,CAAC,IAAM,GAAM,EAAM,EAAM,CAAI,CAAC,EAEnEC,EAAyB,WAAW,KAAK,CAAC,EAAM,EAAM,EAAM,CAAI,CAAC,EAEjEC,EAAoB,CACxB,WAAY,WAAW,KAAK,CAAC,IAAM,CAAI,CAAC,EACxC,KAAMD,CACR,EAEME,EAAsB,CAC1B,WAAY,WAAW,KAAK,CAAC,GAAM,EAAI,CAAC,EACxC,KAAM,IAAI,UACZ,EAEMC,EAA8B,WAAW,KAAK,CAAC,EAAM,CAAI,CAAC,EAE1DC,EAAyB,CAC7B,WAAY,WAAW,KAAK,CAAC,IAAM,CAAI,CAAC,EACxC,KAAMD,CACR,EAEA,SAAS,sBAAuB,IAAM,CACpC,IAAIE,EAEJ,WAAW,IAAM,CACfA,EAAU,IAAIP,CAChB,CAAC,EAED,SAAS,OAAQ,IAAM,CACrB,GAAG,2BAA4B,IAAM,CACnC,OAAOO,EAAQ,IAAI,EAAE,KAAK,cAAc,CAC1C,CAAC,CACH,CAAC,EAED,SAAS,UAAW,IAAM,CACxB,GAAG,mCAAoC,IAAM,CAC3C,MAAMC,EAAOD,EAAQ,QAAQ,EAC7B,OAAOC,EAAK,WAAW,CAAC,EAAE,cAAcP,CAAkB,CAC5D,CAAC,CACH,CAAC,EAED,SAAS,gBAAiB,IAAM,CAC9B,GAAG,4BAA6B,IAAM,CACpC,MAAMQ,EAAiBF,EAAQ,cAAcJ,CAAiB,EAC9D,OAAOM,CAAc,EAAE,cACrBZ,EAAqB,CACnB,KAAM,CACJ,UAAW,UACb,CACF,CAAC,CACH,CACF,CAAC,EAED,GAAG,2DAA4D,IAAM,CACnE,MAAMa,EAASH,EAAQ,cAAcH,CAAmB,EACxD,OAAOL,EAAuBW,CAAM,CAAC,EAAE,KAAK,EAAK,CACnD,CAAC,EAED,GAAG,sDAAuD,IAAM,CAC9D,MAAMA,EAASH,EAAQ,cAAcD,CAAsB,EAE3D,OAAOP,EAAuBW,CAAM,CAAC,EAAE,KAAK,EAAK,EAEjD,OAAOA,EAAO,KAAK,EAAE,eAAeZ,CAAsB,CAC5D,CAAC,CACH,CAAC,CACH,CAAC",
|
|
6
6
|
"names": ["CommandResultFactory", "InvalidStatusWordError", "isSuccessCommandResult", "GetChallengeCommand", "GET_CHALLENGE_APDU", "LNX_RESPONSE_DATA_GOOD", "LNX_RESPONSE_GOOD", "LNX_RESPONSE_LOCKED", "LNX_RESPONSE_DATA_TOO_SHORT", "LNX_RESPONSE_TOO_SHORT", "command", "apdu", "parsedResponse", "result"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{ApduBuilder as d,ApduParser as
|
|
1
|
+
import{ApduBuilder as d,ApduParser as m,CommandResultFactory as o,InvalidStatusWordError as a}from"@ledgerhq/device-management-kit";import{CommandErrorHelper as i,DerivationPathUtils as u}from"@ledgerhq/signer-utils";import{Maybe as l}from"purify-ts";import{DefaultBs58Encoder as y}from"../../app-binder/services/bs58Encoder";import{SOLANA_APP_ERRORS as c,SolanaAppCommandErrorFactory as b}from"./utils/SolanaApplicationErrors";const s=32;class f{constructor(r,e=y){this.bs58Encoder=e;this.args=r}name="getPubKey";errorHelper=new i(c,b);args;getApdu(){const r={cla:224,ins:5,p1:this.args.checkOnDevice?1:0,p2:0},e=new d(r),t=this.args.derivationPath,n=u.splitPath(t);return e.add8BitUIntToData(n.length),n.forEach(p=>{e.add32BitUIntToData(p)}),e.build()}parseResponse(r){return l.fromNullable(this.errorHelper.getError(r)).orDefaultLazy(()=>{const e=new m(r);if(e.testMinimalLength(s)===!1)return o({error:new a("Public key is missing")});const t=e.extractFieldByLength(s);return t===void 0?o({error:new a("Unable to extract public key")}):o({data:this.bs58Encoder.encode(t)})})}}export{f as GetPubKeyCommand};
|
|
2
2
|
//# sourceMappingURL=GetPubKeyCommand.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/internal/app-binder/command/GetPubKeyCommand.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n type Apdu,\n ApduBuilder,\n type ApduBuilderArgs,\n ApduParser,\n type ApduResponse,\n type Command,\n type CommandResult,\n CommandResultFactory,\n InvalidStatusWordError,\n} from \"@ledgerhq/device-management-kit\";\nimport {\n CommandErrorHelper,\n DerivationPathUtils,\n} from \"@ledgerhq/signer-utils\";\nimport { Maybe } from \"purify-ts\";\n\nimport { type PublicKey } from \"@api/model/PublicKey\";\nimport {\n type Bs58Encoder,\n DefaultBs58Encoder,\n} from \"@internal/app-binder/services/bs58Encoder\";\n\nimport {\n SOLANA_APP_ERRORS,\n SolanaAppCommandErrorFactory,\n type SolanaAppErrorCodes,\n} from \"./utils/SolanaApplicationErrors\";\n\nconst PUBKEY_LENGTH = 32;\n\nexport type GetPubKeyCommandResponse = PublicKey;\n\nexport type GetPubKeyCommandArgs = {\n derivationPath: string;\n checkOnDevice: boolean;\n};\n\nexport class GetPubKeyCommand\n implements\n Command<GetPubKeyCommandResponse, GetPubKeyCommandArgs, SolanaAppErrorCodes>\n{\n private readonly errorHelper = new CommandErrorHelper<\n GetPubKeyCommandResponse,\n SolanaAppErrorCodes\n >(SOLANA_APP_ERRORS, SolanaAppCommandErrorFactory);\n\n args: GetPubKeyCommandArgs;\n\n constructor(\n args: GetPubKeyCommandArgs,\n private readonly bs58Encoder: Bs58Encoder = DefaultBs58Encoder,\n ) {\n this.args = args;\n }\n\n getApdu(): Apdu {\n const getPubKeyArgs: ApduBuilderArgs = {\n cla: 0xe0,\n ins: 0x05,\n p1: this.args.checkOnDevice ? 0x01 : 0x00,\n p2: 0x00,\n };\n const builder = new ApduBuilder(getPubKeyArgs);\n const derivationPath = this.args.derivationPath;\n\n const path = DerivationPathUtils.splitPath(derivationPath);\n builder.add8BitUIntToData(path.length);\n path.forEach((element) => {\n builder.add32BitUIntToData(element);\n });\n\n return builder.build();\n }\n\n parseResponse(\n response: ApduResponse,\n ): CommandResult<GetPubKeyCommandResponse, SolanaAppErrorCodes> {\n return Maybe.fromNullable(\n this.errorHelper.getError(response),\n ).orDefaultLazy(() => {\n const parser = new ApduParser(response);\n\n if (parser.testMinimalLength(PUBKEY_LENGTH) === false) {\n return CommandResultFactory({\n error: new InvalidStatusWordError(\"Public key is missing\"),\n });\n }\n\n const buffer = parser.extractFieldByLength(PUBKEY_LENGTH);\n if (buffer === undefined) {\n return CommandResultFactory({\n error: new InvalidStatusWordError(\"Unable to extract public key\"),\n });\n }\n\n return CommandResultFactory({\n data: this.bs58Encoder.encode(buffer),\n });\n });\n }\n}\n"],
|
|
5
|
-
"mappings": "AAAA,OAEE,eAAAA,EAEA,cAAAC,EAIA,wBAAAC,EACA,0BAAAC,MACK,kCACP,OACE,sBAAAC,EACA,uBAAAC,MACK,yBACP,OAAS,SAAAC,MAAa,YAGtB,OAEE,sBAAAC,MACK,4CAEP,OACE,qBAAAC,EACA,gCAAAC,MAEK,kCAEP,MAAMC,EAAgB,GASf,MAAMC,CAGb,
|
|
4
|
+
"sourcesContent": ["import {\n type Apdu,\n ApduBuilder,\n type ApduBuilderArgs,\n ApduParser,\n type ApduResponse,\n type Command,\n type CommandResult,\n CommandResultFactory,\n InvalidStatusWordError,\n} from \"@ledgerhq/device-management-kit\";\nimport {\n CommandErrorHelper,\n DerivationPathUtils,\n} from \"@ledgerhq/signer-utils\";\nimport { Maybe } from \"purify-ts\";\n\nimport { type PublicKey } from \"@api/model/PublicKey\";\nimport {\n type Bs58Encoder,\n DefaultBs58Encoder,\n} from \"@internal/app-binder/services/bs58Encoder\";\n\nimport {\n SOLANA_APP_ERRORS,\n SolanaAppCommandErrorFactory,\n type SolanaAppErrorCodes,\n} from \"./utils/SolanaApplicationErrors\";\n\nconst PUBKEY_LENGTH = 32;\n\nexport type GetPubKeyCommandResponse = PublicKey;\n\nexport type GetPubKeyCommandArgs = {\n derivationPath: string;\n checkOnDevice: boolean;\n};\n\nexport class GetPubKeyCommand\n implements\n Command<GetPubKeyCommandResponse, GetPubKeyCommandArgs, SolanaAppErrorCodes>\n{\n readonly name = \"getPubKey\";\n private readonly errorHelper = new CommandErrorHelper<\n GetPubKeyCommandResponse,\n SolanaAppErrorCodes\n >(SOLANA_APP_ERRORS, SolanaAppCommandErrorFactory);\n\n args: GetPubKeyCommandArgs;\n\n constructor(\n args: GetPubKeyCommandArgs,\n private readonly bs58Encoder: Bs58Encoder = DefaultBs58Encoder,\n ) {\n this.args = args;\n }\n\n getApdu(): Apdu {\n const getPubKeyArgs: ApduBuilderArgs = {\n cla: 0xe0,\n ins: 0x05,\n p1: this.args.checkOnDevice ? 0x01 : 0x00,\n p2: 0x00,\n };\n const builder = new ApduBuilder(getPubKeyArgs);\n const derivationPath = this.args.derivationPath;\n\n const path = DerivationPathUtils.splitPath(derivationPath);\n builder.add8BitUIntToData(path.length);\n path.forEach((element) => {\n builder.add32BitUIntToData(element);\n });\n\n return builder.build();\n }\n\n parseResponse(\n response: ApduResponse,\n ): CommandResult<GetPubKeyCommandResponse, SolanaAppErrorCodes> {\n return Maybe.fromNullable(\n this.errorHelper.getError(response),\n ).orDefaultLazy(() => {\n const parser = new ApduParser(response);\n\n if (parser.testMinimalLength(PUBKEY_LENGTH) === false) {\n return CommandResultFactory({\n error: new InvalidStatusWordError(\"Public key is missing\"),\n });\n }\n\n const buffer = parser.extractFieldByLength(PUBKEY_LENGTH);\n if (buffer === undefined) {\n return CommandResultFactory({\n error: new InvalidStatusWordError(\"Unable to extract public key\"),\n });\n }\n\n return CommandResultFactory({\n data: this.bs58Encoder.encode(buffer),\n });\n });\n }\n}\n"],
|
|
5
|
+
"mappings": "AAAA,OAEE,eAAAA,EAEA,cAAAC,EAIA,wBAAAC,EACA,0BAAAC,MACK,kCACP,OACE,sBAAAC,EACA,uBAAAC,MACK,yBACP,OAAS,SAAAC,MAAa,YAGtB,OAEE,sBAAAC,MACK,4CAEP,OACE,qBAAAC,EACA,gCAAAC,MAEK,kCAEP,MAAMC,EAAgB,GASf,MAAMC,CAGb,CASE,YACEC,EACiBC,EAA2BN,EAC5C,CADiB,iBAAAM,EAEjB,KAAK,KAAOD,CACd,CAbS,KAAO,YACC,YAAc,IAAIR,EAGjCI,EAAmBC,CAA4B,EAEjD,KASA,SAAgB,CACd,MAAMK,EAAiC,CACrC,IAAK,IACL,IAAK,EACL,GAAI,KAAK,KAAK,cAAgB,EAAO,EACrC,GAAI,CACN,EACMC,EAAU,IAAIf,EAAYc,CAAa,EACvCE,EAAiB,KAAK,KAAK,eAE3BC,EAAOZ,EAAoB,UAAUW,CAAc,EACzD,OAAAD,EAAQ,kBAAkBE,EAAK,MAAM,EACrCA,EAAK,QAASC,GAAY,CACxBH,EAAQ,mBAAmBG,CAAO,CACpC,CAAC,EAEMH,EAAQ,MAAM,CACvB,CAEA,cACEI,EAC8D,CAC9D,OAAOb,EAAM,aACX,KAAK,YAAY,SAASa,CAAQ,CACpC,EAAE,cAAc,IAAM,CACpB,MAAMC,EAAS,IAAInB,EAAWkB,CAAQ,EAEtC,GAAIC,EAAO,kBAAkBV,CAAa,IAAM,GAC9C,OAAOR,EAAqB,CAC1B,MAAO,IAAIC,EAAuB,uBAAuB,CAC3D,CAAC,EAGH,MAAMkB,EAASD,EAAO,qBAAqBV,CAAa,EACxD,OAAIW,IAAW,OACNnB,EAAqB,CAC1B,MAAO,IAAIC,EAAuB,8BAA8B,CAClE,CAAC,EAGID,EAAqB,CAC1B,KAAM,KAAK,YAAY,OAAOmB,CAAM,CACtC,CAAC,CACH,CAAC,CACH,CACF",
|
|
6
6
|
"names": ["ApduBuilder", "ApduParser", "CommandResultFactory", "InvalidStatusWordError", "CommandErrorHelper", "DerivationPathUtils", "Maybe", "DefaultBs58Encoder", "SOLANA_APP_ERRORS", "SolanaAppCommandErrorFactory", "PUBKEY_LENGTH", "GetPubKeyCommand", "args", "bs58Encoder", "getPubKeyArgs", "builder", "derivationPath", "path", "element", "response", "parser", "buffer"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{ApduResponse as a,CommandResultFactory as n,isSuccessCommandResult as x}from"@ledgerhq/device-management-kit";import{GetPubKeyCommand as o}from"./GetPubKeyCommand";const c=new Uint8Array([224,5,1,0,9,2,128,0,0,44,128,0,1,245]),i=new Uint8Array([224,5,0,0,9,2,128,0,0,44,128,0,1,245]),d=new Uint8Array([224,5,1,0,9,2,128,0,0,44,128,0,1,246]),u=new Uint8Array([178,167,34,220,24,221,92,73,195,244,142,155,7,38,241,27,230,103,134,233,28,172,87,52,152,214,238,136,57,44,201,106,144,0]),p=new a({statusCode:Uint8Array.from([144,0]),data:u});describe("GetPubKeyCommand",()=>{let t;const s={derivationPath:"44'/501'",checkOnDevice:!0};beforeEach(()=>{t=new o(s),vi.clearAllMocks(),vi.importActual("@ledgerhq/device-management-kit")}),describe("getApdu",()=>{it("should return APDU",()=>{const e=t.getApdu();expect(e.getRawApdu()).toEqual(c)}),it("should return APDU without confirm",()=>{t=new o({...s,checkOnDevice:!1});const e=t.getApdu();expect(e.getRawApdu()).toEqual(i)}),it("should return APDU with different path",()=>{t=new o({...s,derivationPath:"44'/502'"});const e=t.getApdu();expect(e.getRawApdu()).toEqual(d)})}),describe("parseResponse",()=>{it("should parse the response",()=>{const e=t.parseResponse(p);expect(e).toStrictEqual(n({data:"D2PPQSYFe83nDzk96FqGumVU8JA7J8vj2Rhjc2oXzEi5"}))}),describe("error handling",()=>{it("should return error if response is not success",()=>{const e=new a({statusCode:Uint8Array.from([106,130]),data:new Uint8Array(0)}),r=t.parseResponse(e);expect(x(r)).toBe(!1),x(r)?assert.fail("Expected error"):expect(r.error).toEqual(expect.objectContaining({_tag:"SolanaAppCommandError",errorCode:"6a82",message:"Invalid off-chain message format"}))}),it("should return error if public key is missing",()=>{const e=new a({statusCode:Uint8Array.from([144,0]),data:new Uint8Array(0)}),r=t.parseResponse(e);expect(x(r)).toBe(!1),x(r)?assert.fail("Expected error"):expect(r.error.originalError).toEqual(expect.objectContaining({message:"Public key is missing"}))})})})});
|
|
1
|
+
import{ApduResponse as a,CommandResultFactory as n,isSuccessCommandResult as x}from"@ledgerhq/device-management-kit";import{GetPubKeyCommand as o}from"./GetPubKeyCommand";const c=new Uint8Array([224,5,1,0,9,2,128,0,0,44,128,0,1,245]),i=new Uint8Array([224,5,0,0,9,2,128,0,0,44,128,0,1,245]),d=new Uint8Array([224,5,1,0,9,2,128,0,0,44,128,0,1,246]),u=new Uint8Array([178,167,34,220,24,221,92,73,195,244,142,155,7,38,241,27,230,103,134,233,28,172,87,52,152,214,238,136,57,44,201,106,144,0]),p=new a({statusCode:Uint8Array.from([144,0]),data:u});describe("GetPubKeyCommand",()=>{let t;const s={derivationPath:"44'/501'",checkOnDevice:!0};beforeEach(()=>{t=new o(s),vi.clearAllMocks(),vi.importActual("@ledgerhq/device-management-kit")}),describe("name",()=>{it("should be 'getPubKey'",()=>{expect(t.name).toBe("getPubKey")})}),describe("getApdu",()=>{it("should return APDU",()=>{const e=t.getApdu();expect(e.getRawApdu()).toEqual(c)}),it("should return APDU without confirm",()=>{t=new o({...s,checkOnDevice:!1});const e=t.getApdu();expect(e.getRawApdu()).toEqual(i)}),it("should return APDU with different path",()=>{t=new o({...s,derivationPath:"44'/502'"});const e=t.getApdu();expect(e.getRawApdu()).toEqual(d)})}),describe("parseResponse",()=>{it("should parse the response",()=>{const e=t.parseResponse(p);expect(e).toStrictEqual(n({data:"D2PPQSYFe83nDzk96FqGumVU8JA7J8vj2Rhjc2oXzEi5"}))}),describe("error handling",()=>{it("should return error if response is not success",()=>{const e=new a({statusCode:Uint8Array.from([106,130]),data:new Uint8Array(0)}),r=t.parseResponse(e);expect(x(r)).toBe(!1),x(r)?assert.fail("Expected error"):expect(r.error).toEqual(expect.objectContaining({_tag:"SolanaAppCommandError",errorCode:"6a82",message:"Invalid off-chain message format"}))}),it("should return error if public key is missing",()=>{const e=new a({statusCode:Uint8Array.from([144,0]),data:new Uint8Array(0)}),r=t.parseResponse(e);expect(x(r)).toBe(!1),x(r)?assert.fail("Expected error"):expect(r.error.originalError).toEqual(expect.objectContaining({message:"Public key is missing"}))})})})});
|
|
2
2
|
//# sourceMappingURL=GetPubKeyCommand.test.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/internal/app-binder/command/GetPubKeyCommand.test.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n ApduResponse,\n CommandResultFactory,\n isSuccessCommandResult,\n} from \"@ledgerhq/device-management-kit\";\n\nimport { GetPubKeyCommand } from \"./GetPubKeyCommand\";\n\nconst GET_PUBKYEY_APDU_DEFAULT_PATH_WITH_CONFIRM = new Uint8Array([\n 0xe0, 0x05, 0x01, 0x00, 0x09, 0x02, 0x80, 0x00, 0x00, 0x2c, 0x80, 0x00, 0x01,\n 0xf5,\n]);\n\nconst GET_PUBKYEY_APDU_DEFAULT_PATH_WITHOUT_CONFIRM = new Uint8Array([\n 0xe0, 0x05, 0x00, 0x00, 0x09, 0x02, 0x80, 0x00, 0x00, 0x2c, 0x80, 0x00, 0x01,\n 0xf5,\n]);\n\nconst GET_PUBKEY_APDU_DIFFERENT_PATH = new Uint8Array([\n 0xe0, 0x05, 0x01, 0x00, 0x09, 0x02, 0x80, 0x00, 0x00, 0x2c, 0x80, 0x00, 0x01,\n 0xf6,\n]);\n\n// D2PPQSYFe83nDzk96FqGumVU8JA7J8vj2Rhjc2oXzEi5\nconst GET_PUBKEY_APDU = new Uint8Array([\n 0xb2, 0xa7, 0x22, 0xdc, 0x18, 0xdd, 0x5c, 0x49, 0xc3, 0xf4, 0x8e, 0x9b, 0x07,\n 0x26, 0xf1, 0x1b, 0xe6, 0x67, 0x86, 0xe9, 0x1c, 0xac, 0x57, 0x34, 0x98, 0xd6,\n 0xee, 0x88, 0x39, 0x2c, 0xc9, 0x6a, 0x90, 0x00,\n]);\n\nconst GET_PUBKEY_APDU_RESPONSE = new ApduResponse({\n statusCode: Uint8Array.from([0x90, 0x00]),\n data: GET_PUBKEY_APDU,\n});\n\ndescribe(\"GetPubKeyCommand\", () => {\n let command: GetPubKeyCommand;\n const defaultArgs = {\n derivationPath: \"44'/501'\",\n checkOnDevice: true,\n };\n\n beforeEach(() => {\n command = new GetPubKeyCommand(defaultArgs);\n vi.clearAllMocks();\n vi.importActual(\"@ledgerhq/device-management-kit\");\n });\n\n describe(\"getApdu\", () => {\n it(\"should return APDU\", () => {\n const apdu = command.getApdu();\n expect(apdu.getRawApdu()).toEqual(\n GET_PUBKYEY_APDU_DEFAULT_PATH_WITH_CONFIRM,\n );\n });\n\n it(\"should return APDU without confirm\", () => {\n command = new GetPubKeyCommand({\n ...defaultArgs,\n checkOnDevice: false,\n });\n const apdu = command.getApdu();\n expect(apdu.getRawApdu()).toEqual(\n GET_PUBKYEY_APDU_DEFAULT_PATH_WITHOUT_CONFIRM,\n );\n });\n\n it(\"should return APDU with different path\", () => {\n command = new GetPubKeyCommand({\n ...defaultArgs,\n derivationPath: \"44'/502'\",\n });\n const apdu = command.getApdu();\n expect(apdu.getRawApdu()).toEqual(GET_PUBKEY_APDU_DIFFERENT_PATH);\n });\n });\n\n describe(\"parseResponse\", () => {\n it(\"should parse the response\", () => {\n const parsed = command.parseResponse(GET_PUBKEY_APDU_RESPONSE);\n expect(parsed).toStrictEqual(\n CommandResultFactory({\n data: \"D2PPQSYFe83nDzk96FqGumVU8JA7J8vj2Rhjc2oXzEi5\",\n }),\n );\n });\n\n describe(\"error handling\", () => {\n it(\"should return error if response is not success\", () => {\n const response = new ApduResponse({\n statusCode: Uint8Array.from([0x6a, 0x82]),\n data: new Uint8Array(0),\n });\n const result = command.parseResponse(response);\n expect(isSuccessCommandResult(result)).toBe(false);\n if (!isSuccessCommandResult(result)) {\n expect(result.error).toEqual(\n expect.objectContaining({\n _tag: \"SolanaAppCommandError\",\n errorCode: \"6a82\",\n message: \"Invalid off-chain message format\",\n }),\n );\n } else {\n assert.fail(\"Expected error\");\n }\n });\n\n it(\"should return error if public key is missing\", () => {\n const response = new ApduResponse({\n statusCode: Uint8Array.from([0x90, 0x00]),\n data: new Uint8Array(0),\n });\n const result = command.parseResponse(response);\n expect(isSuccessCommandResult(result)).toBe(false);\n if (!isSuccessCommandResult(result)) {\n expect(result.error.originalError).toEqual(\n expect.objectContaining({\n message: \"Public key is missing\",\n }),\n );\n } else {\n assert.fail(\"Expected error\");\n }\n });\n });\n });\n});\n"],
|
|
5
|
-
"mappings": "AAAA,OACE,gBAAAA,EACA,wBAAAC,EACA,0BAAAC,MACK,kCAEP,OAAS,oBAAAC,MAAwB,qBAEjC,MAAMC,EAA6C,IAAI,WAAW,CAChE,IAAM,EAAM,EAAM,EAAM,EAAM,EAAM,IAAM,EAAM,EAAM,GAAM,IAAM,EAAM,EACxE,GACF,CAAC,EAEKC,EAAgD,IAAI,WAAW,CACnE,IAAM,EAAM,EAAM,EAAM,EAAM,EAAM,IAAM,EAAM,EAAM,GAAM,IAAM,EAAM,EACxE,GACF,CAAC,EAEKC,EAAiC,IAAI,WAAW,CACpD,IAAM,EAAM,EAAM,EAAM,EAAM,EAAM,IAAM,EAAM,EAAM,GAAM,IAAM,EAAM,EACxE,GACF,CAAC,EAGKC,EAAkB,IAAI,WAAW,CACrC,IAAM,IAAM,GAAM,IAAM,GAAM,IAAM,GAAM,GAAM,IAAM,IAAM,IAAM,IAAM,EACxE,GAAM,IAAM,GAAM,IAAM,IAAM,IAAM,IAAM,GAAM,IAAM,GAAM,GAAM,IAAM,IACxE,IAAM,IAAM,GAAM,GAAM,IAAM,IAAM,IAAM,CAC5C,CAAC,EAEKC,EAA2B,IAAIR,EAAa,CAChD,WAAY,WAAW,KAAK,CAAC,IAAM,CAAI,CAAC,EACxC,KAAMO,CACR,CAAC,EAED,SAAS,mBAAoB,IAAM,CACjC,IAAIE,EACJ,MAAMC,EAAc,CAClB,eAAgB,WAChB,cAAe,EACjB,EAEA,WAAW,IAAM,CACfD,EAAU,IAAIN,EAAiBO,CAAW,EAC1C,GAAG,cAAc,EACjB,GAAG,aAAa,iCAAiC,CACnD,CAAC,EAED,SAAS,UAAW,IAAM,CACxB,GAAG,qBAAsB,IAAM,CAC7B,
|
|
4
|
+
"sourcesContent": ["import {\n ApduResponse,\n CommandResultFactory,\n isSuccessCommandResult,\n} from \"@ledgerhq/device-management-kit\";\n\nimport { GetPubKeyCommand } from \"./GetPubKeyCommand\";\n\nconst GET_PUBKYEY_APDU_DEFAULT_PATH_WITH_CONFIRM = new Uint8Array([\n 0xe0, 0x05, 0x01, 0x00, 0x09, 0x02, 0x80, 0x00, 0x00, 0x2c, 0x80, 0x00, 0x01,\n 0xf5,\n]);\n\nconst GET_PUBKYEY_APDU_DEFAULT_PATH_WITHOUT_CONFIRM = new Uint8Array([\n 0xe0, 0x05, 0x00, 0x00, 0x09, 0x02, 0x80, 0x00, 0x00, 0x2c, 0x80, 0x00, 0x01,\n 0xf5,\n]);\n\nconst GET_PUBKEY_APDU_DIFFERENT_PATH = new Uint8Array([\n 0xe0, 0x05, 0x01, 0x00, 0x09, 0x02, 0x80, 0x00, 0x00, 0x2c, 0x80, 0x00, 0x01,\n 0xf6,\n]);\n\n// D2PPQSYFe83nDzk96FqGumVU8JA7J8vj2Rhjc2oXzEi5\nconst GET_PUBKEY_APDU = new Uint8Array([\n 0xb2, 0xa7, 0x22, 0xdc, 0x18, 0xdd, 0x5c, 0x49, 0xc3, 0xf4, 0x8e, 0x9b, 0x07,\n 0x26, 0xf1, 0x1b, 0xe6, 0x67, 0x86, 0xe9, 0x1c, 0xac, 0x57, 0x34, 0x98, 0xd6,\n 0xee, 0x88, 0x39, 0x2c, 0xc9, 0x6a, 0x90, 0x00,\n]);\n\nconst GET_PUBKEY_APDU_RESPONSE = new ApduResponse({\n statusCode: Uint8Array.from([0x90, 0x00]),\n data: GET_PUBKEY_APDU,\n});\n\ndescribe(\"GetPubKeyCommand\", () => {\n let command: GetPubKeyCommand;\n const defaultArgs = {\n derivationPath: \"44'/501'\",\n checkOnDevice: true,\n };\n\n beforeEach(() => {\n command = new GetPubKeyCommand(defaultArgs);\n vi.clearAllMocks();\n vi.importActual(\"@ledgerhq/device-management-kit\");\n });\n\n describe(\"name\", () => {\n it(\"should be 'getPubKey'\", () => {\n expect(command.name).toBe(\"getPubKey\");\n });\n });\n\n describe(\"getApdu\", () => {\n it(\"should return APDU\", () => {\n const apdu = command.getApdu();\n expect(apdu.getRawApdu()).toEqual(\n GET_PUBKYEY_APDU_DEFAULT_PATH_WITH_CONFIRM,\n );\n });\n\n it(\"should return APDU without confirm\", () => {\n command = new GetPubKeyCommand({\n ...defaultArgs,\n checkOnDevice: false,\n });\n const apdu = command.getApdu();\n expect(apdu.getRawApdu()).toEqual(\n GET_PUBKYEY_APDU_DEFAULT_PATH_WITHOUT_CONFIRM,\n );\n });\n\n it(\"should return APDU with different path\", () => {\n command = new GetPubKeyCommand({\n ...defaultArgs,\n derivationPath: \"44'/502'\",\n });\n const apdu = command.getApdu();\n expect(apdu.getRawApdu()).toEqual(GET_PUBKEY_APDU_DIFFERENT_PATH);\n });\n });\n\n describe(\"parseResponse\", () => {\n it(\"should parse the response\", () => {\n const parsed = command.parseResponse(GET_PUBKEY_APDU_RESPONSE);\n expect(parsed).toStrictEqual(\n CommandResultFactory({\n data: \"D2PPQSYFe83nDzk96FqGumVU8JA7J8vj2Rhjc2oXzEi5\",\n }),\n );\n });\n\n describe(\"error handling\", () => {\n it(\"should return error if response is not success\", () => {\n const response = new ApduResponse({\n statusCode: Uint8Array.from([0x6a, 0x82]),\n data: new Uint8Array(0),\n });\n const result = command.parseResponse(response);\n expect(isSuccessCommandResult(result)).toBe(false);\n if (!isSuccessCommandResult(result)) {\n expect(result.error).toEqual(\n expect.objectContaining({\n _tag: \"SolanaAppCommandError\",\n errorCode: \"6a82\",\n message: \"Invalid off-chain message format\",\n }),\n );\n } else {\n assert.fail(\"Expected error\");\n }\n });\n\n it(\"should return error if public key is missing\", () => {\n const response = new ApduResponse({\n statusCode: Uint8Array.from([0x90, 0x00]),\n data: new Uint8Array(0),\n });\n const result = command.parseResponse(response);\n expect(isSuccessCommandResult(result)).toBe(false);\n if (!isSuccessCommandResult(result)) {\n expect(result.error.originalError).toEqual(\n expect.objectContaining({\n message: \"Public key is missing\",\n }),\n );\n } else {\n assert.fail(\"Expected error\");\n }\n });\n });\n });\n});\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
6
|
"names": ["ApduResponse", "CommandResultFactory", "isSuccessCommandResult", "GetPubKeyCommand", "GET_PUBKYEY_APDU_DEFAULT_PATH_WITH_CONFIRM", "GET_PUBKYEY_APDU_DEFAULT_PATH_WITHOUT_CONFIRM", "GET_PUBKEY_APDU_DIFFERENT_PATH", "GET_PUBKEY_APDU", "GET_PUBKEY_APDU_RESPONSE", "command", "defaultArgs", "apdu", "parsed", "response", "result"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{ApduBuilder as d,CommandResultFactory as e,InvalidStatusWordError as p}from"@ledgerhq/device-management-kit";import{CommandErrorHelper as a}from"@ledgerhq/signer-utils";import{SOLANA_APP_ERRORS as t,SolanaAppCommandErrorFactory as n}from"./utils/SolanaApplicationErrors";const s=224,i=33,m=0,l=0;class y{constructor(r){this.args=r}errorHelper=new a(t,n);getApdu(){const r={cla:s,ins:i,p1:m,p2:l};return new d(r).addBufferToData(this.args.payload).build()}parseResponse(r){const o=this.errorHelper.getError(r);return o||(r.data.length!==0?e({error:new p("Unexpected data in response")}):e({data:void 0}))}}export{y as ProvideTLVDescriptorCommand};
|
|
1
|
+
import{ApduBuilder as d,CommandResultFactory as e,InvalidStatusWordError as p}from"@ledgerhq/device-management-kit";import{CommandErrorHelper as a}from"@ledgerhq/signer-utils";import{SOLANA_APP_ERRORS as t,SolanaAppCommandErrorFactory as n}from"./utils/SolanaApplicationErrors";const s=224,i=33,m=0,l=0;class y{constructor(r){this.args=r}name="provideTLVDescriptor";errorHelper=new a(t,n);getApdu(){const r={cla:s,ins:i,p1:m,p2:l};return new d(r).addBufferToData(this.args.payload).build()}parseResponse(r){const o=this.errorHelper.getError(r);return o||(r.data.length!==0?e({error:new p("Unexpected data in response")}):e({data:void 0}))}}export{y as ProvideTLVDescriptorCommand};
|
|
2
2
|
//# sourceMappingURL=ProvideTLVDescriptorCommand.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/internal/app-binder/command/ProvideTLVDescriptorCommand.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n type Apdu,\n ApduBuilder,\n type ApduBuilderArgs,\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\";\n\nimport {\n SOLANA_APP_ERRORS,\n SolanaAppCommandErrorFactory,\n type SolanaAppErrorCodes,\n} from \"./utils/SolanaApplicationErrors\";\n\nconst CLA = 0xe0;\nconst INS = 0x21;\nconst P1 = 0x00;\nconst P2 = 0x00;\n\nexport type ProvideTLVDescriptorCommandArgs = {\n payload: Uint8Array;\n};\n\nexport class ProvideTLVDescriptorCommand\n implements Command<void, ProvideTLVDescriptorCommandArgs, SolanaAppErrorCodes>\n{\n private readonly errorHelper = new CommandErrorHelper<\n void,\n SolanaAppErrorCodes\n >(SOLANA_APP_ERRORS, SolanaAppCommandErrorFactory);\n\n constructor(readonly args: ProvideTLVDescriptorCommandArgs) {}\n\n getApdu(): Apdu {\n const apduBuilderArgs: ApduBuilderArgs = {\n cla: CLA,\n ins: INS,\n p1: P1,\n p2: P2,\n };\n return new ApduBuilder(apduBuilderArgs)\n .addBufferToData(this.args.payload)\n .build();\n }\n\n parseResponse(\n response: ApduResponse,\n ): CommandResult<void, SolanaAppErrorCodes> {\n const error = this.errorHelper.getError(response);\n if (error) {\n return error;\n }\n\n if (response.data.length !== 0) {\n return CommandResultFactory({\n error: new InvalidStatusWordError(\"Unexpected data in response\"),\n });\n }\n\n return CommandResultFactory({ data: undefined });\n }\n}\n"],
|
|
5
|
-
"mappings": "AAAA,OAEE,eAAAA,EAKA,wBAAAC,EACA,0BAAAC,MACK,kCACP,OAAS,sBAAAC,MAA0B,yBAEnC,OACE,qBAAAC,EACA,gCAAAC,MAEK,kCAEP,MAAMC,EAAM,IACNC,EAAM,GACNC,EAAK,EACLC,EAAK,EAMJ,MAAMC,CAEb,
|
|
4
|
+
"sourcesContent": ["import {\n type Apdu,\n ApduBuilder,\n type ApduBuilderArgs,\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\";\n\nimport {\n SOLANA_APP_ERRORS,\n SolanaAppCommandErrorFactory,\n type SolanaAppErrorCodes,\n} from \"./utils/SolanaApplicationErrors\";\n\nconst CLA = 0xe0;\nconst INS = 0x21;\nconst P1 = 0x00;\nconst P2 = 0x00;\n\nexport type ProvideTLVDescriptorCommandArgs = {\n payload: Uint8Array;\n};\n\nexport class ProvideTLVDescriptorCommand\n implements Command<void, ProvideTLVDescriptorCommandArgs, SolanaAppErrorCodes>\n{\n readonly name = \"provideTLVDescriptor\";\n private readonly errorHelper = new CommandErrorHelper<\n void,\n SolanaAppErrorCodes\n >(SOLANA_APP_ERRORS, SolanaAppCommandErrorFactory);\n\n constructor(readonly args: ProvideTLVDescriptorCommandArgs) {}\n\n getApdu(): Apdu {\n const apduBuilderArgs: ApduBuilderArgs = {\n cla: CLA,\n ins: INS,\n p1: P1,\n p2: P2,\n };\n return new ApduBuilder(apduBuilderArgs)\n .addBufferToData(this.args.payload)\n .build();\n }\n\n parseResponse(\n response: ApduResponse,\n ): CommandResult<void, SolanaAppErrorCodes> {\n const error = this.errorHelper.getError(response);\n if (error) {\n return error;\n }\n\n if (response.data.length !== 0) {\n return CommandResultFactory({\n error: new InvalidStatusWordError(\"Unexpected data in response\"),\n });\n }\n\n return CommandResultFactory({ data: undefined });\n }\n}\n"],
|
|
5
|
+
"mappings": "AAAA,OAEE,eAAAA,EAKA,wBAAAC,EACA,0BAAAC,MACK,kCACP,OAAS,sBAAAC,MAA0B,yBAEnC,OACE,qBAAAC,EACA,gCAAAC,MAEK,kCAEP,MAAMC,EAAM,IACNC,EAAM,GACNC,EAAK,EACLC,EAAK,EAMJ,MAAMC,CAEb,CAOE,YAAqBC,EAAuC,CAAvC,UAAAA,CAAwC,CANpD,KAAO,uBACC,YAAc,IAAIR,EAGjCC,EAAmBC,CAA4B,EAIjD,SAAgB,CACd,MAAMO,EAAmC,CACvC,IAAKN,EACL,IAAKC,EACL,GAAIC,EACJ,GAAIC,CACN,EACA,OAAO,IAAIT,EAAYY,CAAe,EACnC,gBAAgB,KAAK,KAAK,OAAO,EACjC,MAAM,CACX,CAEA,cACEC,EAC0C,CAC1C,MAAMC,EAAQ,KAAK,YAAY,SAASD,CAAQ,EAChD,OAAIC,IAIAD,EAAS,KAAK,SAAW,EACpBZ,EAAqB,CAC1B,MAAO,IAAIC,EAAuB,6BAA6B,CACjE,CAAC,EAGID,EAAqB,CAAE,KAAM,MAAU,CAAC,EACjD,CACF",
|
|
6
6
|
"names": ["ApduBuilder", "CommandResultFactory", "InvalidStatusWordError", "CommandErrorHelper", "SOLANA_APP_ERRORS", "SolanaAppCommandErrorFactory", "CLA", "INS", "P1", "P2", "ProvideTLVDescriptorCommand", "args", "apduBuilderArgs", "response", "error"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{CommandResultFactory as s,InvalidStatusWordError as a,isSuccessCommandResult as o}from"@ledgerhq/device-management-kit";import{ProvideTLVDescriptorCommand as n}from"./ProvideTLVDescriptorCommand";const d=224,c=33,i=0,
|
|
1
|
+
import{CommandResultFactory as s,InvalidStatusWordError as a,isSuccessCommandResult as o}from"@ledgerhq/device-management-kit";import{ProvideTLVDescriptorCommand as n}from"./ProvideTLVDescriptorCommand";const d=224,c=33,i=0,p=0,u=Uint8Array.from([d,c,i,p,4,222,173,190,239]);describe("ProvideTLVDescriptorCommand",()=>{let r;beforeEach(()=>{r=new n({payload:Uint8Array.from([222,173,190,239])})}),describe("name",()=>{it("should be 'provideTLVDescriptor'",()=>{expect(r.name).toBe("provideTLVDescriptor")})}),describe("getApdu",()=>{it("should construct the correct APDU",()=>{const e=r.getApdu();expect(e.getRawApdu()).toStrictEqual(u)})}),describe("parseResponse",()=>{it("should return success when status is 0x9000 and no data",()=>{const e={statusCode:Uint8Array.from([144,0]),data:new Uint8Array},t=r.parseResponse(e);expect(t).toStrictEqual(s({data:void 0})),expect(o(t)).toBe(!0)}),it("should return an error if the status code is not 0x9000",()=>{const e={statusCode:Uint8Array.from([106,128]),data:new Uint8Array},t=r.parseResponse(e);expect(o(t)).toBe(!1)}),it("should return an error if response contains unexpected data",()=>{const e={statusCode:Uint8Array.from([144,0]),data:Uint8Array.from([1])},t=r.parseResponse(e);expect(o(t)).toBe(!1),expect(t.error).toBeInstanceOf(a)})})});
|
|
2
2
|
//# sourceMappingURL=ProvideTLVDescriptorCommand.test.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/internal/app-binder/command/ProvideTLVDescriptorCommand.test.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n CommandResultFactory,\n InvalidStatusWordError,\n isSuccessCommandResult,\n} from \"@ledgerhq/device-management-kit\";\n\nimport { ProvideTLVDescriptorCommand } from \"./ProvideTLVDescriptorCommand\";\n\nconst CLA = 0xe0;\nconst INS = 0x21;\nconst P1 = 0x00;\nconst P2 = 0x00;\n\nconst EXPECTED_APDU = Uint8Array.from([\n CLA,\n INS,\n P1,\n P2,\n 0x04,\n 0xde,\n 0xad,\n 0xbe,\n 0xef,\n]);\n\ndescribe(\"ProvideTLVDescriptorCommand\", () => {\n let command: ProvideTLVDescriptorCommand;\n\n beforeEach(() => {\n command = new ProvideTLVDescriptorCommand({\n payload: Uint8Array.from([0xde, 0xad, 0xbe, 0xef]),\n });\n });\n\n describe(\"getApdu\", () => {\n it(\"should construct the correct APDU\", () => {\n const apdu = command.getApdu();\n expect(apdu.getRawApdu()).toStrictEqual(EXPECTED_APDU);\n });\n });\n\n describe(\"parseResponse\", () => {\n it(\"should return success when status is 0x9000 and no data\", () => {\n const LNX_RESPONSE_GOOD = {\n statusCode: Uint8Array.from([0x90, 0x00]),\n data: new Uint8Array(),\n };\n\n const parsed = command.parseResponse(LNX_RESPONSE_GOOD);\n expect(parsed).toStrictEqual(CommandResultFactory({ data: undefined }));\n expect(isSuccessCommandResult(parsed)).toBe(true);\n });\n\n it(\"should return an error if the status code is not 0x9000\", () => {\n const LNX_RESPONSE_ERROR = {\n statusCode: Uint8Array.from([0x6a, 0x80]),\n data: new Uint8Array(),\n };\n\n const result = command.parseResponse(LNX_RESPONSE_ERROR);\n expect(isSuccessCommandResult(result)).toBe(false);\n });\n\n it(\"should return an error if response contains unexpected data\", () => {\n const LNX_RESPONSE_EXTRA = {\n statusCode: Uint8Array.from([0x90, 0x00]),\n data: Uint8Array.from([0x01]),\n };\n\n const result = command.parseResponse(LNX_RESPONSE_EXTRA);\n expect(isSuccessCommandResult(result)).toBe(false);\n // @ts-expect-error response is not typed\n expect(result.error).toBeInstanceOf(InvalidStatusWordError);\n });\n });\n});\n"],
|
|
5
|
-
"mappings": "AAAA,OACE,wBAAAA,EACA,0BAAAC,EACA,0BAAAC,MACK,kCAEP,OAAS,+BAAAC,MAAmC,gCAE5C,MAAMC,EAAM,IACNC,EAAM,GACNC,EAAK,EACLC,EAAK,EAELC,EAAgB,WAAW,KAAK,CACpCJ,EACAC,EACAC,EACAC,EACA,EACA,IACA,IACA,IACA,GACF,CAAC,EAED,SAAS,8BAA+B,IAAM,CAC5C,IAAIE,EAEJ,WAAW,IAAM,CACfA,EAAU,IAAIN,EAA4B,CACxC,QAAS,WAAW,KAAK,CAAC,IAAM,IAAM,IAAM,GAAI,CAAC,CACnD,CAAC,CACH,CAAC,EAED,SAAS,UAAW,IAAM,CACxB,GAAG,oCAAqC,IAAM,CAC5C,
|
|
4
|
+
"sourcesContent": ["import {\n CommandResultFactory,\n InvalidStatusWordError,\n isSuccessCommandResult,\n} from \"@ledgerhq/device-management-kit\";\n\nimport { ProvideTLVDescriptorCommand } from \"./ProvideTLVDescriptorCommand\";\n\nconst CLA = 0xe0;\nconst INS = 0x21;\nconst P1 = 0x00;\nconst P2 = 0x00;\n\nconst EXPECTED_APDU = Uint8Array.from([\n CLA,\n INS,\n P1,\n P2,\n 0x04,\n 0xde,\n 0xad,\n 0xbe,\n 0xef,\n]);\n\ndescribe(\"ProvideTLVDescriptorCommand\", () => {\n let command: ProvideTLVDescriptorCommand;\n\n beforeEach(() => {\n command = new ProvideTLVDescriptorCommand({\n payload: Uint8Array.from([0xde, 0xad, 0xbe, 0xef]),\n });\n });\n\n describe(\"name\", () => {\n it(\"should be 'provideTLVDescriptor'\", () => {\n expect(command.name).toBe(\"provideTLVDescriptor\");\n });\n });\n\n describe(\"getApdu\", () => {\n it(\"should construct the correct APDU\", () => {\n const apdu = command.getApdu();\n expect(apdu.getRawApdu()).toStrictEqual(EXPECTED_APDU);\n });\n });\n\n describe(\"parseResponse\", () => {\n it(\"should return success when status is 0x9000 and no data\", () => {\n const LNX_RESPONSE_GOOD = {\n statusCode: Uint8Array.from([0x90, 0x00]),\n data: new Uint8Array(),\n };\n\n const parsed = command.parseResponse(LNX_RESPONSE_GOOD);\n expect(parsed).toStrictEqual(CommandResultFactory({ data: undefined }));\n expect(isSuccessCommandResult(parsed)).toBe(true);\n });\n\n it(\"should return an error if the status code is not 0x9000\", () => {\n const LNX_RESPONSE_ERROR = {\n statusCode: Uint8Array.from([0x6a, 0x80]),\n data: new Uint8Array(),\n };\n\n const result = command.parseResponse(LNX_RESPONSE_ERROR);\n expect(isSuccessCommandResult(result)).toBe(false);\n });\n\n it(\"should return an error if response contains unexpected data\", () => {\n const LNX_RESPONSE_EXTRA = {\n statusCode: Uint8Array.from([0x90, 0x00]),\n data: Uint8Array.from([0x01]),\n };\n\n const result = command.parseResponse(LNX_RESPONSE_EXTRA);\n expect(isSuccessCommandResult(result)).toBe(false);\n // @ts-expect-error response is not typed\n expect(result.error).toBeInstanceOf(InvalidStatusWordError);\n });\n });\n});\n"],
|
|
5
|
+
"mappings": "AAAA,OACE,wBAAAA,EACA,0BAAAC,EACA,0BAAAC,MACK,kCAEP,OAAS,+BAAAC,MAAmC,gCAE5C,MAAMC,EAAM,IACNC,EAAM,GACNC,EAAK,EACLC,EAAK,EAELC,EAAgB,WAAW,KAAK,CACpCJ,EACAC,EACAC,EACAC,EACA,EACA,IACA,IACA,IACA,GACF,CAAC,EAED,SAAS,8BAA+B,IAAM,CAC5C,IAAIE,EAEJ,WAAW,IAAM,CACfA,EAAU,IAAIN,EAA4B,CACxC,QAAS,WAAW,KAAK,CAAC,IAAM,IAAM,IAAM,GAAI,CAAC,CACnD,CAAC,CACH,CAAC,EAED,SAAS,OAAQ,IAAM,CACrB,GAAG,mCAAoC,IAAM,CAC3C,OAAOM,EAAQ,IAAI,EAAE,KAAK,sBAAsB,CAClD,CAAC,CACH,CAAC,EAED,SAAS,UAAW,IAAM,CACxB,GAAG,oCAAqC,IAAM,CAC5C,MAAMC,EAAOD,EAAQ,QAAQ,EAC7B,OAAOC,EAAK,WAAW,CAAC,EAAE,cAAcF,CAAa,CACvD,CAAC,CACH,CAAC,EAED,SAAS,gBAAiB,IAAM,CAC9B,GAAG,0DAA2D,IAAM,CAClE,MAAMG,EAAoB,CACxB,WAAY,WAAW,KAAK,CAAC,IAAM,CAAI,CAAC,EACxC,KAAM,IAAI,UACZ,EAEMC,EAASH,EAAQ,cAAcE,CAAiB,EACtD,OAAOC,CAAM,EAAE,cAAcZ,EAAqB,CAAE,KAAM,MAAU,CAAC,CAAC,EACtE,OAAOE,EAAuBU,CAAM,CAAC,EAAE,KAAK,EAAI,CAClD,CAAC,EAED,GAAG,0DAA2D,IAAM,CAClE,MAAMC,EAAqB,CACzB,WAAY,WAAW,KAAK,CAAC,IAAM,GAAI,CAAC,EACxC,KAAM,IAAI,UACZ,EAEMC,EAASL,EAAQ,cAAcI,CAAkB,EACvD,OAAOX,EAAuBY,CAAM,CAAC,EAAE,KAAK,EAAK,CACnD,CAAC,EAED,GAAG,8DAA+D,IAAM,CACtE,MAAMC,EAAqB,CACzB,WAAY,WAAW,KAAK,CAAC,IAAM,CAAI,CAAC,EACxC,KAAM,WAAW,KAAK,CAAC,CAAI,CAAC,CAC9B,EAEMD,EAASL,EAAQ,cAAcM,CAAkB,EACvD,OAAOb,EAAuBY,CAAM,CAAC,EAAE,KAAK,EAAK,EAEjD,OAAOA,EAAO,KAAK,EAAE,eAAeb,CAAsB,CAC5D,CAAC,CACH,CAAC,CACH,CAAC",
|
|
6
6
|
"names": ["CommandResultFactory", "InvalidStatusWordError", "isSuccessCommandResult", "ProvideTLVDescriptorCommand", "CLA", "INS", "P1", "P2", "EXPECTED_APDU", "command", "apdu", "LNX_RESPONSE_GOOD", "parsed", "LNX_RESPONSE_ERROR", "result", "LNX_RESPONSE_EXTRA"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{ApduBuilder as d,CommandResultFactory as o,InvalidStatusWordError as a}from"@ledgerhq/device-management-kit";import{CommandErrorHelper as t}from"@ledgerhq/signer-utils";import{SOLANA_APP_ERRORS as
|
|
1
|
+
import{ApduBuilder as d,CommandResultFactory as o,InvalidStatusWordError as a}from"@ledgerhq/device-management-kit";import{CommandErrorHelper as t}from"@ledgerhq/signer-utils";import{SOLANA_APP_ERRORS as n,SolanaAppCommandErrorFactory as p}from"./utils/SolanaApplicationErrors";const s=176,m=6,u=4,i=0;class y{constructor(r){this.args=r}name="provideTrustedNamePKI";errorHelper=new t(n,p);getApdu(){const r={cla:s,ins:m,p1:u,p2:i};return new d(r).addBufferToData(this.args.pkiBlob).build()}parseResponse(r){const e=this.errorHelper.getError(r);return e||(r.data.length!==0?o({error:new a("Unexpected data in response")}):o({data:void 0}))}}export{y as ProvideTrustedNamePKICommand};
|
|
2
2
|
//# sourceMappingURL=ProvideTrustedNamePKICommand.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/internal/app-binder/command/ProvideTrustedNamePKICommand.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n type Apdu,\n ApduBuilder,\n type ApduBuilderArgs,\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\";\n\nimport {\n SOLANA_APP_ERRORS,\n SolanaAppCommandErrorFactory,\n type SolanaAppErrorCodes,\n} from \"./utils/SolanaApplicationErrors\";\n\nconst CLA = 0xb0;\nconst INS = 0x06;\nconst P1 = 0x04;\nconst P2 = 0x00;\n\nexport type ProvideTrustedNamePKICommandArgs = {\n pkiBlob: Uint8Array;\n};\n\nexport class ProvideTrustedNamePKICommand\n implements\n Command<void, ProvideTrustedNamePKICommandArgs, SolanaAppErrorCodes>\n{\n private readonly errorHelper = new CommandErrorHelper<\n void,\n SolanaAppErrorCodes\n >(SOLANA_APP_ERRORS, SolanaAppCommandErrorFactory);\n\n constructor(readonly args: ProvideTrustedNamePKICommandArgs) {}\n\n getApdu(): Apdu {\n const apduBuilderArgs: ApduBuilderArgs = {\n cla: CLA,\n ins: INS,\n p1: P1,\n p2: P2,\n };\n return new ApduBuilder(apduBuilderArgs)\n .addBufferToData(this.args.pkiBlob)\n .build();\n }\n\n parseResponse(\n response: ApduResponse,\n ): CommandResult<void, SolanaAppErrorCodes> {\n const error = this.errorHelper.getError(response);\n if (error) {\n return error;\n }\n\n if (response.data.length !== 0) {\n return CommandResultFactory({\n error: new InvalidStatusWordError(\"Unexpected data in response\"),\n });\n }\n\n return CommandResultFactory({ data: undefined });\n }\n}\n"],
|
|
5
|
-
"mappings": "AAAA,OAEE,eAAAA,EAKA,wBAAAC,EACA,0BAAAC,MACK,kCACP,OAAS,sBAAAC,MAA0B,yBAEnC,OACE,qBAAAC,EACA,gCAAAC,MAEK,kCAEP,MAAMC,EAAM,IACNC,EAAM,EACNC,EAAK,EACLC,EAAK,EAMJ,MAAMC,CAGb,
|
|
4
|
+
"sourcesContent": ["import {\n type Apdu,\n ApduBuilder,\n type ApduBuilderArgs,\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\";\n\nimport {\n SOLANA_APP_ERRORS,\n SolanaAppCommandErrorFactory,\n type SolanaAppErrorCodes,\n} from \"./utils/SolanaApplicationErrors\";\n\nconst CLA = 0xb0;\nconst INS = 0x06;\nconst P1 = 0x04;\nconst P2 = 0x00;\n\nexport type ProvideTrustedNamePKICommandArgs = {\n pkiBlob: Uint8Array;\n};\n\nexport class ProvideTrustedNamePKICommand\n implements\n Command<void, ProvideTrustedNamePKICommandArgs, SolanaAppErrorCodes>\n{\n readonly name = \"provideTrustedNamePKI\";\n private readonly errorHelper = new CommandErrorHelper<\n void,\n SolanaAppErrorCodes\n >(SOLANA_APP_ERRORS, SolanaAppCommandErrorFactory);\n\n constructor(readonly args: ProvideTrustedNamePKICommandArgs) {}\n\n getApdu(): Apdu {\n const apduBuilderArgs: ApduBuilderArgs = {\n cla: CLA,\n ins: INS,\n p1: P1,\n p2: P2,\n };\n return new ApduBuilder(apduBuilderArgs)\n .addBufferToData(this.args.pkiBlob)\n .build();\n }\n\n parseResponse(\n response: ApduResponse,\n ): CommandResult<void, SolanaAppErrorCodes> {\n const error = this.errorHelper.getError(response);\n if (error) {\n return error;\n }\n\n if (response.data.length !== 0) {\n return CommandResultFactory({\n error: new InvalidStatusWordError(\"Unexpected data in response\"),\n });\n }\n\n return CommandResultFactory({ data: undefined });\n }\n}\n"],
|
|
5
|
+
"mappings": "AAAA,OAEE,eAAAA,EAKA,wBAAAC,EACA,0BAAAC,MACK,kCACP,OAAS,sBAAAC,MAA0B,yBAEnC,OACE,qBAAAC,EACA,gCAAAC,MAEK,kCAEP,MAAMC,EAAM,IACNC,EAAM,EACNC,EAAK,EACLC,EAAK,EAMJ,MAAMC,CAGb,CAOE,YAAqBC,EAAwC,CAAxC,UAAAA,CAAyC,CANrD,KAAO,wBACC,YAAc,IAAIR,EAGjCC,EAAmBC,CAA4B,EAIjD,SAAgB,CACd,MAAMO,EAAmC,CACvC,IAAKN,EACL,IAAKC,EACL,GAAIC,EACJ,GAAIC,CACN,EACA,OAAO,IAAIT,EAAYY,CAAe,EACnC,gBAAgB,KAAK,KAAK,OAAO,EACjC,MAAM,CACX,CAEA,cACEC,EAC0C,CAC1C,MAAMC,EAAQ,KAAK,YAAY,SAASD,CAAQ,EAChD,OAAIC,IAIAD,EAAS,KAAK,SAAW,EACpBZ,EAAqB,CAC1B,MAAO,IAAIC,EAAuB,6BAA6B,CACjE,CAAC,EAGID,EAAqB,CAAE,KAAM,MAAU,CAAC,EACjD,CACF",
|
|
6
6
|
"names": ["ApduBuilder", "CommandResultFactory", "InvalidStatusWordError", "CommandErrorHelper", "SOLANA_APP_ERRORS", "SolanaAppCommandErrorFactory", "CLA", "INS", "P1", "P2", "ProvideTrustedNamePKICommand", "args", "apduBuilderArgs", "response", "error"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{CommandResultFactory as o,InvalidStatusWordError as a,isSuccessCommandResult as s}from"@ledgerhq/device-management-kit";import{ProvideTrustedNamePKICommand as n}from"./ProvideTrustedNamePKICommand";const d=176,c=6,x=4,
|
|
1
|
+
import{CommandResultFactory as o,InvalidStatusWordError as a,isSuccessCommandResult as s}from"@ledgerhq/device-management-kit";import{ProvideTrustedNamePKICommand as n}from"./ProvideTrustedNamePKICommand";const d=176,c=6,x=4,i=0,u=Uint8Array.from([222,173,190,239,21,2,1,2]),m=Uint8Array.from([d,c,x,i,8,222,173,190,239,21,2,1,2]);describe("ProvideTrustedNamePKICommand",()=>{let r;beforeEach(()=>{r=new n({pkiBlob:u})}),describe("name",()=>{it("should be 'provideTrustedNamePKI'",()=>{expect(r.name).toBe("provideTrustedNamePKI")})}),describe("getApdu",()=>{it("should construct the correct APDU",()=>{const e=r.getApdu();expect(e.getRawApdu()).toStrictEqual(m)})}),describe("parseResponse",()=>{it("should return success when status is 0x9000 and no data",()=>{const e={statusCode:Uint8Array.from([144,0]),data:new Uint8Array},t=r.parseResponse(e);expect(t).toStrictEqual(o({data:void 0})),expect(s(t)).toBe(!0)}),it("should return an error if the status code is not 0x9000",()=>{const e={statusCode:Uint8Array.from([85,21]),data:new Uint8Array},t=r.parseResponse(e);expect(s(t)).toBe(!1)}),it("should return an error if response contains unexpected data",()=>{const e={statusCode:Uint8Array.from([144,0]),data:Uint8Array.from([0])},t=r.parseResponse(e);expect(s(t)).toBe(!1),expect(t.error).toBeInstanceOf(a)})})});
|
|
2
2
|
//# sourceMappingURL=ProvideTrustedNamePKICommand.test.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/internal/app-binder/command/ProvideTrustedNamePKICommand.test.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n CommandResultFactory,\n InvalidStatusWordError,\n isSuccessCommandResult,\n} from \"@ledgerhq/device-management-kit\";\n\nimport { ProvideTrustedNamePKICommand } from \"./ProvideTrustedNamePKICommand\";\n\nconst CLA = 0xb0;\nconst INS = 0x06;\nconst P1 = 0x04;\nconst P2 = 0x00;\n\nconst pkiBlob = Uint8Array.from([\n 0xde, 0xad, 0xbe, 0xef, 0x15, 0x02, 0x01, 0x02,\n]);\n\nconst EXPECTED_APDU = Uint8Array.from([\n CLA,\n INS,\n P1,\n P2,\n 0x08,\n 0xde,\n 0xad,\n 0xbe,\n 0xef,\n 0x15,\n 0x02,\n 0x01,\n 0x02,\n]);\n\ndescribe(\"ProvideTrustedNamePKICommand\", () => {\n let command: ProvideTrustedNamePKICommand;\n\n beforeEach(() => {\n command = new ProvideTrustedNamePKICommand({ pkiBlob });\n });\n\n describe(\"getApdu\", () => {\n it(\"should construct the correct APDU\", () => {\n const apdu = command.getApdu();\n expect(apdu.getRawApdu()).toStrictEqual(EXPECTED_APDU);\n });\n });\n\n describe(\"parseResponse\", () => {\n it(\"should return success when status is 0x9000 and no data\", () => {\n const LNX_RESPONSE_GOOD = {\n statusCode: Uint8Array.from([0x90, 0x00]),\n data: new Uint8Array(),\n };\n\n const parsed = command.parseResponse(LNX_RESPONSE_GOOD);\n expect(parsed).toStrictEqual(CommandResultFactory({ data: undefined }));\n expect(isSuccessCommandResult(parsed)).toBe(true);\n });\n\n it(\"should return an error if the status code is not 0x9000\", () => {\n const LNX_RESPONSE_ERROR = {\n statusCode: Uint8Array.from([0x55, 0x15]),\n data: new Uint8Array(),\n };\n\n const result = command.parseResponse(LNX_RESPONSE_ERROR);\n expect(isSuccessCommandResult(result)).toBe(false);\n });\n\n it(\"should return an error if response contains unexpected data\", () => {\n const LNX_RESPONSE_EXTRA = {\n statusCode: Uint8Array.from([0x90, 0x00]),\n data: Uint8Array.from([0x00]), // extra byte\n };\n\n const result = command.parseResponse(LNX_RESPONSE_EXTRA);\n expect(isSuccessCommandResult(result)).toBe(false);\n // @ts-ignore\n expect(result.error).toBeInstanceOf(InvalidStatusWordError);\n });\n });\n});\n"],
|
|
5
|
-
"mappings": "AAAA,OACE,wBAAAA,EACA,0BAAAC,EACA,0BAAAC,MACK,kCAEP,OAAS,gCAAAC,MAAoC,iCAE7C,MAAMC,EAAM,IACNC,EAAM,EACNC,EAAK,EACLC,EAAK,EAELC,EAAU,WAAW,KAAK,CAC9B,IAAM,IAAM,IAAM,IAAM,GAAM,EAAM,EAAM,CAC5C,CAAC,EAEKC,EAAgB,WAAW,KAAK,CACpCL,EACAC,EACAC,EACAC,EACA,EACA,IACA,IACA,IACA,IACA,GACA,EACA,EACA,CACF,CAAC,EAED,SAAS,+BAAgC,IAAM,CAC7C,IAAIG,EAEJ,WAAW,IAAM,CACfA,EAAU,IAAIP,EAA6B,CAAE,QAAAK,CAAQ,CAAC,CACxD,CAAC,EAED,SAAS,UAAW,IAAM,CACxB,GAAG,oCAAqC,IAAM,CAC5C,
|
|
4
|
+
"sourcesContent": ["import {\n CommandResultFactory,\n InvalidStatusWordError,\n isSuccessCommandResult,\n} from \"@ledgerhq/device-management-kit\";\n\nimport { ProvideTrustedNamePKICommand } from \"./ProvideTrustedNamePKICommand\";\n\nconst CLA = 0xb0;\nconst INS = 0x06;\nconst P1 = 0x04;\nconst P2 = 0x00;\n\nconst pkiBlob = Uint8Array.from([\n 0xde, 0xad, 0xbe, 0xef, 0x15, 0x02, 0x01, 0x02,\n]);\n\nconst EXPECTED_APDU = Uint8Array.from([\n CLA,\n INS,\n P1,\n P2,\n 0x08,\n 0xde,\n 0xad,\n 0xbe,\n 0xef,\n 0x15,\n 0x02,\n 0x01,\n 0x02,\n]);\n\ndescribe(\"ProvideTrustedNamePKICommand\", () => {\n let command: ProvideTrustedNamePKICommand;\n\n beforeEach(() => {\n command = new ProvideTrustedNamePKICommand({ pkiBlob });\n });\n\n describe(\"name\", () => {\n it(\"should be 'provideTrustedNamePKI'\", () => {\n expect(command.name).toBe(\"provideTrustedNamePKI\");\n });\n });\n\n describe(\"getApdu\", () => {\n it(\"should construct the correct APDU\", () => {\n const apdu = command.getApdu();\n expect(apdu.getRawApdu()).toStrictEqual(EXPECTED_APDU);\n });\n });\n\n describe(\"parseResponse\", () => {\n it(\"should return success when status is 0x9000 and no data\", () => {\n const LNX_RESPONSE_GOOD = {\n statusCode: Uint8Array.from([0x90, 0x00]),\n data: new Uint8Array(),\n };\n\n const parsed = command.parseResponse(LNX_RESPONSE_GOOD);\n expect(parsed).toStrictEqual(CommandResultFactory({ data: undefined }));\n expect(isSuccessCommandResult(parsed)).toBe(true);\n });\n\n it(\"should return an error if the status code is not 0x9000\", () => {\n const LNX_RESPONSE_ERROR = {\n statusCode: Uint8Array.from([0x55, 0x15]),\n data: new Uint8Array(),\n };\n\n const result = command.parseResponse(LNX_RESPONSE_ERROR);\n expect(isSuccessCommandResult(result)).toBe(false);\n });\n\n it(\"should return an error if response contains unexpected data\", () => {\n const LNX_RESPONSE_EXTRA = {\n statusCode: Uint8Array.from([0x90, 0x00]),\n data: Uint8Array.from([0x00]), // extra byte\n };\n\n const result = command.parseResponse(LNX_RESPONSE_EXTRA);\n expect(isSuccessCommandResult(result)).toBe(false);\n // @ts-ignore\n expect(result.error).toBeInstanceOf(InvalidStatusWordError);\n });\n });\n});\n"],
|
|
5
|
+
"mappings": "AAAA,OACE,wBAAAA,EACA,0BAAAC,EACA,0BAAAC,MACK,kCAEP,OAAS,gCAAAC,MAAoC,iCAE7C,MAAMC,EAAM,IACNC,EAAM,EACNC,EAAK,EACLC,EAAK,EAELC,EAAU,WAAW,KAAK,CAC9B,IAAM,IAAM,IAAM,IAAM,GAAM,EAAM,EAAM,CAC5C,CAAC,EAEKC,EAAgB,WAAW,KAAK,CACpCL,EACAC,EACAC,EACAC,EACA,EACA,IACA,IACA,IACA,IACA,GACA,EACA,EACA,CACF,CAAC,EAED,SAAS,+BAAgC,IAAM,CAC7C,IAAIG,EAEJ,WAAW,IAAM,CACfA,EAAU,IAAIP,EAA6B,CAAE,QAAAK,CAAQ,CAAC,CACxD,CAAC,EAED,SAAS,OAAQ,IAAM,CACrB,GAAG,oCAAqC,IAAM,CAC5C,OAAOE,EAAQ,IAAI,EAAE,KAAK,uBAAuB,CACnD,CAAC,CACH,CAAC,EAED,SAAS,UAAW,IAAM,CACxB,GAAG,oCAAqC,IAAM,CAC5C,MAAMC,EAAOD,EAAQ,QAAQ,EAC7B,OAAOC,EAAK,WAAW,CAAC,EAAE,cAAcF,CAAa,CACvD,CAAC,CACH,CAAC,EAED,SAAS,gBAAiB,IAAM,CAC9B,GAAG,0DAA2D,IAAM,CAClE,MAAMG,EAAoB,CACxB,WAAY,WAAW,KAAK,CAAC,IAAM,CAAI,CAAC,EACxC,KAAM,IAAI,UACZ,EAEMC,EAASH,EAAQ,cAAcE,CAAiB,EACtD,OAAOC,CAAM,EAAE,cAAcb,EAAqB,CAAE,KAAM,MAAU,CAAC,CAAC,EACtE,OAAOE,EAAuBW,CAAM,CAAC,EAAE,KAAK,EAAI,CAClD,CAAC,EAED,GAAG,0DAA2D,IAAM,CAClE,MAAMC,EAAqB,CACzB,WAAY,WAAW,KAAK,CAAC,GAAM,EAAI,CAAC,EACxC,KAAM,IAAI,UACZ,EAEMC,EAASL,EAAQ,cAAcI,CAAkB,EACvD,OAAOZ,EAAuBa,CAAM,CAAC,EAAE,KAAK,EAAK,CACnD,CAAC,EAED,GAAG,8DAA+D,IAAM,CACtE,MAAMC,EAAqB,CACzB,WAAY,WAAW,KAAK,CAAC,IAAM,CAAI,CAAC,EACxC,KAAM,WAAW,KAAK,CAAC,CAAI,CAAC,CAC9B,EAEMD,EAASL,EAAQ,cAAcM,CAAkB,EACvD,OAAOd,EAAuBa,CAAM,CAAC,EAAE,KAAK,EAAK,EAEjD,OAAOA,EAAO,KAAK,EAAE,eAAed,CAAsB,CAC5D,CAAC,CACH,CAAC,CACH,CAAC",
|
|
6
6
|
"names": ["CommandResultFactory", "InvalidStatusWordError", "isSuccessCommandResult", "ProvideTrustedNamePKICommand", "CLA", "INS", "P1", "P2", "pkiBlob", "EXPECTED_APDU", "command", "apdu", "LNX_RESPONSE_GOOD", "parsed", "LNX_RESPONSE_ERROR", "result", "LNX_RESPONSE_EXTRA"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{ApduBuilder as
|
|
1
|
+
import{ApduBuilder as s,ApduParser as t,CommandResultFactory as r}from"@ledgerhq/device-management-kit";const p=224,d=7,m=1,o=64,a={INIT:0,EXTEND:1,MORE:2};class g{constructor(e){this.args=e}name="signOffChainMessage";getApdu(){const e=(this.args.extend?a.EXTEND:a.INIT)|(this.args.more?a.MORE:0);return new s({cla:p,ins:d,p1:m,p2:e}).addBufferToData(this.args.chunkedData).build()}parseResponse(e){const n=new t(e).extractFieldByLength(o);return!n||n.length!==o?r({data:new Uint8Array(0)}):r({data:n})}}export{p as CLA,d as INS,m as P1,a as SOL_P2,g as SignOffChainMessageCommand};
|
|
2
2
|
//# sourceMappingURL=SignOffChainMessageCommand.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/internal/app-binder/command/SignOffChainMessageCommand.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n type Apdu,\n ApduBuilder,\n ApduParser,\n type ApduResponse,\n type Command,\n type CommandResult,\n CommandResultFactory,\n
|
|
5
|
-
"mappings": "AAAA,OAEE,eAAAA,EACA,cAAAC,EAIA,wBAAAC,
|
|
6
|
-
"names": ["ApduBuilder", "ApduParser", "CommandResultFactory", "
|
|
4
|
+
"sourcesContent": ["import {\n type Apdu,\n ApduBuilder,\n ApduParser,\n type ApduResponse,\n type Command,\n type CommandResult,\n CommandResultFactory,\n} from \"@ledgerhq/device-management-kit\";\n\nimport { type ChunkableCommandArgs } from \"@internal/app-binder/task/SendCommandInChunksTask\";\n\nimport { type SolanaAppErrorCodes } from \"./utils/SolanaApplicationErrors\";\n\nexport const CLA = 0xe0;\nexport const INS = 0x07;\nexport const P1 = 0x01;\n\nconst SIGNATURE_LENGTH = 64;\n\nexport const SOL_P2 = {\n INIT: 0x00,\n EXTEND: 0x01,\n MORE: 0x02,\n};\n\nexport type SignOffChainRawResponse = Uint8Array;\n\nexport class SignOffChainMessageCommand\n implements\n Command<SignOffChainRawResponse, ChunkableCommandArgs, SolanaAppErrorCodes>\n{\n readonly name = \"signOffChainMessage\";\n constructor(readonly args: ChunkableCommandArgs) {}\n\n getApdu(): Apdu {\n const p2 =\n (this.args.extend ? SOL_P2.EXTEND : SOL_P2.INIT) |\n (this.args.more ? SOL_P2.MORE : 0);\n\n return new ApduBuilder({\n cla: CLA,\n ins: INS,\n p1: P1,\n p2,\n })\n .addBufferToData(this.args.chunkedData)\n .build();\n }\n\n parseResponse(\n response: ApduResponse,\n ): CommandResult<SignOffChainRawResponse, SolanaAppErrorCodes> {\n const parser = new ApduParser(response);\n const sig = parser.extractFieldByLength(SIGNATURE_LENGTH);\n\n // for intermediate chunks, the device returns 0 bytes of data with 0x9000.\n // only the last chunk yields the 64-byte signature.\n if (!sig || sig.length !== SIGNATURE_LENGTH) {\n return CommandResultFactory({ data: new Uint8Array(0) });\n }\n\n return CommandResultFactory({ data: sig });\n }\n}\n"],
|
|
5
|
+
"mappings": "AAAA,OAEE,eAAAA,EACA,cAAAC,EAIA,wBAAAC,MACK,kCAMA,MAAMC,EAAM,IACNC,EAAM,EACNC,EAAK,EAEZC,EAAmB,GAEZC,EAAS,CACpB,KAAM,EACN,OAAQ,EACR,KAAM,CACR,EAIO,MAAMC,CAGb,CAEE,YAAqBC,EAA4B,CAA5B,UAAAA,CAA6B,CADzC,KAAO,sBAGhB,SAAgB,CACd,MAAMC,GACH,KAAK,KAAK,OAASH,EAAO,OAASA,EAAO,OAC1C,KAAK,KAAK,KAAOA,EAAO,KAAO,GAElC,OAAO,IAAIP,EAAY,CACrB,IAAKG,EACL,IAAKC,EACL,GAAIC,EACJ,GAAAK,CACF,CAAC,EACE,gBAAgB,KAAK,KAAK,WAAW,EACrC,MAAM,CACX,CAEA,cACEC,EAC6D,CAE7D,MAAMC,EADS,IAAIX,EAAWU,CAAQ,EACnB,qBAAqBL,CAAgB,EAIxD,MAAI,CAACM,GAAOA,EAAI,SAAWN,EAClBJ,EAAqB,CAAE,KAAM,IAAI,WAAW,CAAC,CAAE,CAAC,EAGlDA,EAAqB,CAAE,KAAMU,CAAI,CAAC,CAC3C,CACF",
|
|
6
|
+
"names": ["ApduBuilder", "ApduParser", "CommandResultFactory", "CLA", "INS", "P1", "SIGNATURE_LENGTH", "SOL_P2", "SignOffChainMessageCommand", "args", "p2", "response", "sig"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{ApduBuilder as
|
|
1
|
+
import{ApduBuilder as c,ApduResponse as p,isSuccessCommandResult as d}from"@ledgerhq/device-management-kit";import{CLA as r,INS as o,P1 as u,SignOffChainMessageCommand as s}from"./SignOffChainMessageCommand";describe("SignOffChainMessageCommand",()=>{const a=new TextEncoder().encode("Solana SignOffChainMessage"),i=64;describe("name",()=>{it("should be 'signOffChainMessage'",()=>{const n=new s({chunkedData:a,extend:!1,more:!1});expect(n.name).toBe("signOffChainMessage")})}),describe("getApdu()",()=>{it("builds APDU for a single (final) chunk (p2=INIT)",()=>{const e=new s({chunkedData:a,extend:!1,more:!1}).getApdu(),t=new c({cla:r,ins:o,p1:u,p2:0}).addBufferToData(a).build();expect(e.getRawApdu()).toEqual(t.getRawApdu())}),it("sets p2 correctly for first of many chunks (INIT|MORE)",()=>{const e=new s({chunkedData:a,extend:!1,more:!0}).getApdu(),t=new c({cla:r,ins:o,p1:u,p2:2}).addBufferToData(a).build();expect(e.getRawApdu()).toEqual(t.getRawApdu())}),it("sets p2 correctly for middle chunks (EXTEND|MORE)",()=>{const e=new s({chunkedData:a,extend:!0,more:!0}).getApdu(),t=new c({cla:r,ins:o,p1:u,p2:3}).addBufferToData(a).build();expect(e.getRawApdu()).toEqual(t.getRawApdu())}),it("sets p2 correctly for the final chunk after extends (EXTEND)",()=>{const e=new s({chunkedData:a,extend:!0,more:!1}).getApdu(),t=new c({cla:r,ins:o,p1:u,p2:1}).addBufferToData(a).build();expect(e.getRawApdu()).toEqual(t.getRawApdu())})}),describe("parseResponse()",()=>{it("returns raw 64-byte signature on the last chunk",()=>{const n=new s({chunkedData:a,extend:!0,more:!1}),e=new Uint8Array(i).fill(66),t=n.parseResponse(new p({data:e,statusCode:new Uint8Array([144,0])}));expect(d(t)).toBe(!0),d(t)&&expect(t.data).toEqual(e)}),it("returns empty data for intermediate chunks (no signature yet)",()=>{const e=new s({chunkedData:a,extend:!0,more:!0}).parseResponse(new p({data:new Uint8Array(0),statusCode:new Uint8Array([144,0])}));expect(d(e)).toBe(!0),d(e)&&expect(e.data).toEqual(new Uint8Array(0))}),it("returns empty data if signature is present but not 64 bytes",()=>{const n=new s({chunkedData:a,extend:!0,more:!1}),e=new Uint8Array(i-1).fill(153),t=n.parseResponse(new p({data:e,statusCode:new Uint8Array([144,0])}));expect(d(t)).toBe(!0),d(t)&&expect(t.data).toEqual(new Uint8Array(0))})})});
|
|
2
2
|
//# sourceMappingURL=SignOffChainMessageCommand.test.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/internal/app-binder/command/SignOffChainMessageCommand.test.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n ApduBuilder,\n ApduResponse,\n isSuccessCommandResult,\n} from \"@ledgerhq/device-management-kit\";\n\nimport {
|
|
5
|
-
"mappings": "AAAA,OACE,eAAAA,EACA,gBAAAC,EACA,0BAAAC,MACK,kCAEP,
|
|
6
|
-
"names": ["ApduBuilder", "ApduResponse", "isSuccessCommandResult", "
|
|
4
|
+
"sourcesContent": ["import {\n ApduBuilder,\n ApduResponse,\n isSuccessCommandResult,\n} from \"@ledgerhq/device-management-kit\";\n\nimport {\n CLA,\n INS,\n P1,\n SignOffChainMessageCommand,\n} from \"./SignOffChainMessageCommand\";\n\ndescribe(\"SignOffChainMessageCommand\", () => {\n const MESSAGE = new TextEncoder().encode(\"Solana SignOffChainMessage\");\n const SIGNATURE_LENGTH = 64;\n\n describe(\"name\", () => {\n it(\"should be 'signOffChainMessage'\", () => {\n const command = new SignOffChainMessageCommand({\n chunkedData: MESSAGE,\n extend: false,\n more: false,\n });\n expect(command.name).toBe(\"signOffChainMessage\");\n });\n });\n\n describe(\"getApdu()\", () => {\n it(\"builds APDU for a single (final) chunk (p2=INIT)\", () => {\n const cmd = new SignOffChainMessageCommand({\n chunkedData: MESSAGE,\n extend: false,\n more: false,\n });\n\n const apdu = cmd.getApdu();\n\n const expected = new ApduBuilder({\n cla: CLA,\n ins: INS,\n p1: P1,\n p2: 0x00, // INIT only\n })\n .addBufferToData(MESSAGE)\n .build();\n\n expect(apdu.getRawApdu()).toEqual(expected.getRawApdu());\n });\n\n it(\"sets p2 correctly for first of many chunks (INIT|MORE)\", () => {\n const cmd = new SignOffChainMessageCommand({\n chunkedData: MESSAGE,\n extend: false,\n more: true,\n });\n\n const apdu = cmd.getApdu();\n\n const expected = new ApduBuilder({\n cla: CLA,\n ins: INS,\n p1: P1,\n p2: 0x02, // INIT|MORE\n })\n .addBufferToData(MESSAGE)\n .build();\n\n expect(apdu.getRawApdu()).toEqual(expected.getRawApdu());\n });\n\n it(\"sets p2 correctly for middle chunks (EXTEND|MORE)\", () => {\n const cmd = new SignOffChainMessageCommand({\n chunkedData: MESSAGE,\n extend: true,\n more: true,\n });\n\n const apdu = cmd.getApdu();\n\n const expected = new ApduBuilder({\n cla: CLA,\n ins: INS,\n p1: P1,\n p2: 0x03, // EXTEND|MORE\n })\n .addBufferToData(MESSAGE)\n .build();\n\n expect(apdu.getRawApdu()).toEqual(expected.getRawApdu());\n });\n\n it(\"sets p2 correctly for the final chunk after extends (EXTEND)\", () => {\n const cmd = new SignOffChainMessageCommand({\n chunkedData: MESSAGE,\n extend: true,\n more: false,\n });\n\n const apdu = cmd.getApdu();\n\n const expected = new ApduBuilder({\n cla: CLA,\n ins: INS,\n p1: P1,\n p2: 0x01, // EXTEND only\n })\n .addBufferToData(MESSAGE)\n .build();\n\n expect(apdu.getRawApdu()).toEqual(expected.getRawApdu());\n });\n });\n\n describe(\"parseResponse()\", () => {\n it(\"returns raw 64-byte signature on the last chunk\", () => {\n const cmd = new SignOffChainMessageCommand({\n chunkedData: MESSAGE,\n extend: true,\n more: false,\n });\n\n const signature = new Uint8Array(SIGNATURE_LENGTH).fill(0x42);\n\n const parsed = cmd.parseResponse(\n new ApduResponse({\n data: signature,\n statusCode: new Uint8Array([0x90, 0x00]),\n }),\n );\n\n expect(isSuccessCommandResult(parsed)).toBe(true);\n if (isSuccessCommandResult(parsed)) {\n expect(parsed.data).toEqual(signature);\n }\n });\n\n it(\"returns empty data for intermediate chunks (no signature yet)\", () => {\n const cmd = new SignOffChainMessageCommand({\n chunkedData: MESSAGE,\n extend: true,\n more: true,\n });\n\n const parsed = cmd.parseResponse(\n new ApduResponse({\n data: new Uint8Array(0), // device returns no data mid-stream\n statusCode: new Uint8Array([0x90, 0x00]),\n }),\n );\n\n expect(isSuccessCommandResult(parsed)).toBe(true);\n if (isSuccessCommandResult(parsed)) {\n expect(parsed.data).toEqual(new Uint8Array(0));\n }\n });\n\n it(\"returns empty data if signature is present but not 64 bytes\", () => {\n const cmd = new SignOffChainMessageCommand({\n chunkedData: MESSAGE,\n extend: true,\n more: false,\n });\n\n const shortSig = new Uint8Array(SIGNATURE_LENGTH - 1).fill(0x99);\n\n const parsed = cmd.parseResponse(\n new ApduResponse({\n data: shortSig,\n statusCode: new Uint8Array([0x90, 0x00]),\n }),\n );\n\n expect(isSuccessCommandResult(parsed)).toBe(true);\n if (isSuccessCommandResult(parsed)) {\n expect(parsed.data).toEqual(new Uint8Array(0));\n }\n });\n });\n});\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": ["ApduBuilder", "ApduResponse", "isSuccessCommandResult", "CLA", "INS", "P1", "SignOffChainMessageCommand", "MESSAGE", "SIGNATURE_LENGTH", "command", "apdu", "expected", "cmd", "signature", "parsed", "shortSig"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{ApduBuilder as s,ApduParser as i,CommandResultFactory as o,InvalidStatusWordError as p}from"@ledgerhq/device-management-kit";import{CommandErrorHelper as d}from"@ledgerhq/signer-utils";import{Just as m,Maybe as l,Nothing as g}from"purify-ts";import{SOLANA_APP_ERRORS as u,SolanaAppCommandErrorFactory as A}from"./utils/SolanaApplicationErrors";const c=64;class f{errorHelper=new d(u,A);args;constructor(r){this.args=r}getApdu(){const{more:r,extend:n,serializedTransaction:e}=this.args;let a=0;r&&(a|=2),n&&(a|=1);const t={cla:224,ins:6,p1:1,p2:a};return new s(t).addBufferToData(e).build()}parseResponse(r){return l.fromNullable(this.errorHelper.getError(r)).orDefaultLazy(()=>{const n=new i(r);if(n.getUnparsedRemainingLength()===0)return o({data:g});const e=n.extractFieldByLength(c);return e?o({data:m(e)}):o({error:new p("Signature is missing")})})}}export{f as SignTransactionCommand};
|
|
1
|
+
import{ApduBuilder as s,ApduParser as i,CommandResultFactory as o,InvalidStatusWordError as p}from"@ledgerhq/device-management-kit";import{CommandErrorHelper as d}from"@ledgerhq/signer-utils";import{Just as m,Maybe as l,Nothing as g}from"purify-ts";import{SOLANA_APP_ERRORS as u,SolanaAppCommandErrorFactory as A}from"./utils/SolanaApplicationErrors";const c=64;class f{name="signTransaction";errorHelper=new d(u,A);args;constructor(r){this.args=r}getApdu(){const{more:r,extend:n,serializedTransaction:e}=this.args;let a=0;r&&(a|=2),n&&(a|=1);const t={cla:224,ins:6,p1:1,p2:a};return new s(t).addBufferToData(e).build()}parseResponse(r){return l.fromNullable(this.errorHelper.getError(r)).orDefaultLazy(()=>{const n=new i(r);if(n.getUnparsedRemainingLength()===0)return o({data:g});const e=n.extractFieldByLength(c);return e?o({data:m(e)}):o({error:new p("Signature is missing")})})}}export{f as SignTransactionCommand};
|
|
2
2
|
//# sourceMappingURL=SignTransactionCommand.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/internal/app-binder/command/SignTransactionCommand.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n type Apdu,\n ApduBuilder,\n type ApduBuilderArgs,\n ApduParser,\n type ApduResponse,\n type Command,\n type CommandResult,\n CommandResultFactory,\n InvalidStatusWordError,\n} from \"@ledgerhq/device-management-kit\";\nimport { CommandErrorHelper } from \"@ledgerhq/signer-utils\";\nimport { Just, Maybe, Nothing } from \"purify-ts\";\n\nimport { type Signature } from \"@api/model/Signature\";\n\nimport {\n SOLANA_APP_ERRORS,\n SolanaAppCommandErrorFactory,\n type SolanaAppErrorCodes,\n} from \"./utils/SolanaApplicationErrors\";\n\nconst SIGNATURE_LENGTH = 64;\n\nexport type SignTransactionCommandResponse = Maybe<Signature>;\nexport type SignTransactionCommandArgs = {\n /**\n * Chunked serialized transaction\n */\n readonly serializedTransaction: Uint8Array;\n readonly more: boolean;\n readonly extend: boolean;\n};\n\nexport class SignTransactionCommand\n implements\n Command<\n SignTransactionCommandResponse,\n SignTransactionCommandArgs,\n SolanaAppErrorCodes\n >\n{\n private readonly errorHelper = new CommandErrorHelper<\n SignTransactionCommandResponse,\n SolanaAppErrorCodes\n >(SOLANA_APP_ERRORS, SolanaAppCommandErrorFactory);\n\n args: SignTransactionCommandArgs;\n\n constructor(args: SignTransactionCommandArgs) {\n this.args = args;\n }\n\n getApdu(): Apdu {\n const { more, extend, serializedTransaction } = this.args;\n let p2 = 0x00;\n if (more) p2 |= 0x02;\n if (extend) p2 |= 0x01;\n\n const signTransactionArgs: ApduBuilderArgs = {\n cla: 0xe0,\n ins: 0x06,\n p1: 0x01,\n p2,\n };\n\n return new ApduBuilder(signTransactionArgs)\n .addBufferToData(serializedTransaction)\n .build();\n }\n\n parseResponse(\n response: ApduResponse,\n ): CommandResult<SignTransactionCommandResponse, SolanaAppErrorCodes> {\n return Maybe.fromNullable(\n this.errorHelper.getError(response),\n ).orDefaultLazy(() => {\n const parser = new ApduParser(response);\n\n if (parser.getUnparsedRemainingLength() === 0) {\n return CommandResultFactory({\n data: Nothing,\n });\n }\n\n const signature = parser.extractFieldByLength(SIGNATURE_LENGTH);\n if (!signature) {\n return CommandResultFactory({\n error: new InvalidStatusWordError(\"Signature is missing\"),\n });\n }\n\n return CommandResultFactory({\n data: Just(signature),\n });\n });\n }\n}\n"],
|
|
5
|
-
"mappings": "AAAA,OAEE,eAAAA,EAEA,cAAAC,EAIA,wBAAAC,EACA,0BAAAC,MACK,kCACP,OAAS,sBAAAC,MAA0B,yBACnC,OAAS,QAAAC,EAAM,SAAAC,EAAO,WAAAC,MAAe,YAIrC,OACE,qBAAAC,EACA,gCAAAC,MAEK,kCAEP,MAAMC,EAAmB,GAYlB,MAAMC,CAOb,
|
|
4
|
+
"sourcesContent": ["import {\n type Apdu,\n ApduBuilder,\n type ApduBuilderArgs,\n ApduParser,\n type ApduResponse,\n type Command,\n type CommandResult,\n CommandResultFactory,\n InvalidStatusWordError,\n} from \"@ledgerhq/device-management-kit\";\nimport { CommandErrorHelper } from \"@ledgerhq/signer-utils\";\nimport { Just, Maybe, Nothing } from \"purify-ts\";\n\nimport { type Signature } from \"@api/model/Signature\";\n\nimport {\n SOLANA_APP_ERRORS,\n SolanaAppCommandErrorFactory,\n type SolanaAppErrorCodes,\n} from \"./utils/SolanaApplicationErrors\";\n\nconst SIGNATURE_LENGTH = 64;\n\nexport type SignTransactionCommandResponse = Maybe<Signature>;\nexport type SignTransactionCommandArgs = {\n /**\n * Chunked serialized transaction\n */\n readonly serializedTransaction: Uint8Array;\n readonly more: boolean;\n readonly extend: boolean;\n};\n\nexport class SignTransactionCommand\n implements\n Command<\n SignTransactionCommandResponse,\n SignTransactionCommandArgs,\n SolanaAppErrorCodes\n >\n{\n readonly name = \"signTransaction\";\n private readonly errorHelper = new CommandErrorHelper<\n SignTransactionCommandResponse,\n SolanaAppErrorCodes\n >(SOLANA_APP_ERRORS, SolanaAppCommandErrorFactory);\n\n args: SignTransactionCommandArgs;\n\n constructor(args: SignTransactionCommandArgs) {\n this.args = args;\n }\n\n getApdu(): Apdu {\n const { more, extend, serializedTransaction } = this.args;\n let p2 = 0x00;\n if (more) p2 |= 0x02;\n if (extend) p2 |= 0x01;\n\n const signTransactionArgs: ApduBuilderArgs = {\n cla: 0xe0,\n ins: 0x06,\n p1: 0x01,\n p2,\n };\n\n return new ApduBuilder(signTransactionArgs)\n .addBufferToData(serializedTransaction)\n .build();\n }\n\n parseResponse(\n response: ApduResponse,\n ): CommandResult<SignTransactionCommandResponse, SolanaAppErrorCodes> {\n return Maybe.fromNullable(\n this.errorHelper.getError(response),\n ).orDefaultLazy(() => {\n const parser = new ApduParser(response);\n\n if (parser.getUnparsedRemainingLength() === 0) {\n return CommandResultFactory({\n data: Nothing,\n });\n }\n\n const signature = parser.extractFieldByLength(SIGNATURE_LENGTH);\n if (!signature) {\n return CommandResultFactory({\n error: new InvalidStatusWordError(\"Signature is missing\"),\n });\n }\n\n return CommandResultFactory({\n data: Just(signature),\n });\n });\n }\n}\n"],
|
|
5
|
+
"mappings": "AAAA,OAEE,eAAAA,EAEA,cAAAC,EAIA,wBAAAC,EACA,0BAAAC,MACK,kCACP,OAAS,sBAAAC,MAA0B,yBACnC,OAAS,QAAAC,EAAM,SAAAC,EAAO,WAAAC,MAAe,YAIrC,OACE,qBAAAC,EACA,gCAAAC,MAEK,kCAEP,MAAMC,EAAmB,GAYlB,MAAMC,CAOb,CACW,KAAO,kBACC,YAAc,IAAIP,EAGjCI,EAAmBC,CAA4B,EAEjD,KAEA,YAAYG,EAAkC,CAC5C,KAAK,KAAOA,CACd,CAEA,SAAgB,CACd,KAAM,CAAE,KAAAC,EAAM,OAAAC,EAAQ,sBAAAC,CAAsB,EAAI,KAAK,KACrD,IAAIC,EAAK,EACLH,IAAMG,GAAM,GACZF,IAAQE,GAAM,GAElB,MAAMC,EAAuC,CAC3C,IAAK,IACL,IAAK,EACL,GAAI,EACJ,GAAAD,CACF,EAEA,OAAO,IAAIhB,EAAYiB,CAAmB,EACvC,gBAAgBF,CAAqB,EACrC,MAAM,CACX,CAEA,cACEG,EACoE,CACpE,OAAOZ,EAAM,aACX,KAAK,YAAY,SAASY,CAAQ,CACpC,EAAE,cAAc,IAAM,CACpB,MAAMC,EAAS,IAAIlB,EAAWiB,CAAQ,EAEtC,GAAIC,EAAO,2BAA2B,IAAM,EAC1C,OAAOjB,EAAqB,CAC1B,KAAMK,CACR,CAAC,EAGH,MAAMa,EAAYD,EAAO,qBAAqBT,CAAgB,EAC9D,OAAKU,EAMElB,EAAqB,CAC1B,KAAMG,EAAKe,CAAS,CACtB,CAAC,EAPQlB,EAAqB,CAC1B,MAAO,IAAIC,EAAuB,sBAAsB,CAC1D,CAAC,CAML,CAAC,CACH,CACF",
|
|
6
6
|
"names": ["ApduBuilder", "ApduParser", "CommandResultFactory", "InvalidStatusWordError", "CommandErrorHelper", "Just", "Maybe", "Nothing", "SOLANA_APP_ERRORS", "SolanaAppCommandErrorFactory", "SIGNATURE_LENGTH", "SignTransactionCommand", "args", "more", "extend", "serializedTransaction", "p2", "signTransactionArgs", "response", "parser", "signature"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{ApduResponse as
|
|
1
|
+
import{ApduResponse as r,CommandResultFactory as o,InvalidStatusWordError as i,isSuccessCommandResult as x}from"@ledgerhq/device-management-kit";import{Just as d,Nothing as p}from"purify-ts";import{SignTransactionCommand as n}from"./SignTransactionCommand";describe("SignTransactionCommand",()=>{const a={serializedTransaction:new Uint8Array,more:!1,extend:!1};describe("name",()=>{it("should be 'signTransaction'",()=>{const t=new n(a);expect(t.name).toBe("signTransaction")})}),describe("getApdu",()=>{it("should return the correct APDU when the data is empty",()=>{const e=new n(a).getApdu();expect(e.data).toStrictEqual(new Uint8Array),expect(e.cla).toBe(224),expect(e.ins).toBe(6),expect(e.p1).toBe(1),expect(e.p2).toBe(0)}),it("should return the correct APDU when the data is not empty",()=>{const e=new n({serializedTransaction:new Uint8Array([1,2,3]),more:!1,extend:!1}).getApdu();expect(e.data).toStrictEqual(new Uint8Array([1,2,3])),expect(e.cla).toBe(224),expect(e.ins).toBe(6),expect(e.p1).toBe(1),expect(e.p2).toBe(0)}),it("should return the correct APDU when the more flag is set",()=>{const e=new n({serializedTransaction:new Uint8Array([1,2,3]),more:!0,extend:!1}).getApdu();expect(e.data).toStrictEqual(new Uint8Array([1,2,3])),expect(e.cla).toBe(224),expect(e.ins).toBe(6),expect(e.p1).toBe(1),expect(e.p2).toBe(2)}),it("should return the correct APDU when the extend flag is set",()=>{const e=new n({serializedTransaction:new Uint8Array([1,2,3]),more:!1,extend:!0}).getApdu();expect(e.data).toStrictEqual(new Uint8Array([1,2,3])),expect(e.cla).toBe(224),expect(e.ins).toBe(6),expect(e.p1).toBe(1),expect(e.p2).toBe(1)}),it("should return the correct APDU when the more and extend flags are set",()=>{const e=new n({serializedTransaction:new Uint8Array([1,2,3]),more:!0,extend:!0}).getApdu();expect(e.data).toStrictEqual(new Uint8Array([1,2,3])),expect(e.cla).toBe(224),expect(e.ins).toBe(6),expect(e.p1).toBe(1),expect(e.p2).toBe(3)})}),describe("parseResponse",()=>{it("should return Noting when the response is empty",()=>{const e=new n(a).parseResponse(new r({statusCode:Uint8Array.from([144,0]),data:new Uint8Array([])}));expect(e).toStrictEqual(o({data:p}))}),it("should return the signature when the response is not empty",()=>{const t=new n(a),e=new Uint8Array(Array.from({length:64},(m,c)=>c+1)),s=t.parseResponse(new r({statusCode:Uint8Array.from([144,0]),data:e}));expect(s).toStrictEqual(o({data:d(e)}))}),it("should return an error when the response data is not valid",()=>{const e=new n(a).parseResponse(new r({statusCode:Uint8Array.from([144,0]),data:new Uint8Array([1])}));x(e)?assert.fail("The result should be an error."):expect(e.error).toEqual(new i("Signature is missing"))})})});
|
|
2
2
|
//# sourceMappingURL=SignTransactionCommand.test.js.map
|