@ledgerhq/device-signer-kit-aleo 0.0.0-develop-20260312001221 → 0.0.0-develop-20260313001318
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/SignFeeIntentCommand.test.js +1 -1
- package/lib/cjs/internal/app-binder/command/SignFeeIntentCommand.test.js.map +1 -1
- package/lib/cjs/internal/app-binder/command/SignRootIntentCommand.test.js +1 -1
- package/lib/cjs/internal/app-binder/command/SignRootIntentCommand.test.js.map +1 -1
- package/lib/cjs/internal/app-binder/command/utils/aleoApplicationErrors.js +1 -1
- package/lib/cjs/internal/app-binder/command/utils/aleoApplicationErrors.js.map +2 -2
- package/lib/cjs/package.json +1 -1
- package/lib/esm/internal/app-binder/command/SignFeeIntentCommand.test.js +1 -1
- package/lib/esm/internal/app-binder/command/SignFeeIntentCommand.test.js.map +1 -1
- package/lib/esm/internal/app-binder/command/SignRootIntentCommand.test.js +1 -1
- package/lib/esm/internal/app-binder/command/SignRootIntentCommand.test.js.map +1 -1
- package/lib/esm/internal/app-binder/command/utils/aleoApplicationErrors.js +1 -1
- package/lib/esm/internal/app-binder/command/utils/aleoApplicationErrors.js.map +2 -2
- package/lib/esm/package.json +1 -1
- package/lib/types/tsconfig.prod.tsbuildinfo +1 -1
- package/package.json +8 -8
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var s=require("@ledgerhq/device-management-kit"),r=require("../../app-binder/command/utils/apduHeaderUtils"),a=require("./SignFeeIntentCommand");describe("SignFeeIntentCommand",()=>{const n=new Uint8Array([5,6,7,8]);describe("name",()=>{it("should be 'signFeeIntent'",()=>{const o=new a.SignFeeIntentCommand({feeIntent:n});expect(o.name).toBe("signFeeIntent")})}),describe("getApdu",()=>{it("should create correct APDU with P1=0x02",()=>{const t=new a.SignFeeIntentCommand({feeIntent:n}).getApdu();expect(t.cla).toBe(r.ALEO_CLA),expect(t.ins).toBe(r.INS.SIGN_INTENT),expect(t.p1).toBe(r.P1.SIGN_MODE_FEE),expect(t.p2).toBe(r.P2_DEFAULT),expect(t.data.length).toBe(2+n.length);const e=new Uint8Array(2+n.length);e[0]=0,e[1]=n.length,e.set(n,2),expect(t.data).toEqual(e)})}),describe("parseResponse",()=>{it("should return hexadecimal string for successful response",()=>{const o=new a.SignFeeIntentCommand({feeIntent:n}),t={statusCode:new Uint8Array([144,0]),data:new Uint8Array([1,2,3])},e=o.parseResponse(t);expect(e).toEqual((0,s.CommandResultFactory)({data:{tlvSignature:"010203"}}))}),it("should return error if extraction fails",()=>{const o=new a.SignFeeIntentCommand({feeIntent:n}),t={statusCode:new Uint8Array([144,0]),data:new Uint8Array([])},e=o.parseResponse(t);expect(e).toEqual((0,s.CommandResultFactory)({error:new s.InvalidStatusWordError("Failed to extract data from response")}))}),it("should handle user rejection",()=>{const o=new a.SignFeeIntentCommand({feeIntent:n}),t={statusCode:new Uint8Array([105,
|
|
1
|
+
"use strict";var s=require("@ledgerhq/device-management-kit"),r=require("../../app-binder/command/utils/apduHeaderUtils"),a=require("./SignFeeIntentCommand");describe("SignFeeIntentCommand",()=>{const n=new Uint8Array([5,6,7,8]);describe("name",()=>{it("should be 'signFeeIntent'",()=>{const o=new a.SignFeeIntentCommand({feeIntent:n});expect(o.name).toBe("signFeeIntent")})}),describe("getApdu",()=>{it("should create correct APDU with P1=0x02",()=>{const t=new a.SignFeeIntentCommand({feeIntent:n}).getApdu();expect(t.cla).toBe(r.ALEO_CLA),expect(t.ins).toBe(r.INS.SIGN_INTENT),expect(t.p1).toBe(r.P1.SIGN_MODE_FEE),expect(t.p2).toBe(r.P2_DEFAULT),expect(t.data.length).toBe(2+n.length);const e=new Uint8Array(2+n.length);e[0]=0,e[1]=n.length,e.set(n,2),expect(t.data).toEqual(e)})}),describe("parseResponse",()=>{it("should return hexadecimal string for successful response",()=>{const o=new a.SignFeeIntentCommand({feeIntent:n}),t={statusCode:new Uint8Array([144,0]),data:new Uint8Array([1,2,3])},e=o.parseResponse(t);expect(e).toEqual((0,s.CommandResultFactory)({data:{tlvSignature:"010203"}}))}),it("should return error if extraction fails",()=>{const o=new a.SignFeeIntentCommand({feeIntent:n}),t={statusCode:new Uint8Array([144,0]),data:new Uint8Array([])},e=o.parseResponse(t);expect(e).toEqual((0,s.CommandResultFactory)({error:new s.InvalidStatusWordError("Failed to extract data from response")}))}),it("should handle user rejection",()=>{const o=new a.SignFeeIntentCommand({feeIntent:n}),t={statusCode:new Uint8Array([105,240]),data:new Uint8Array([])},e=o.parseResponse(t);expect((0,s.isSuccessCommandResult)(e)).toBe(!1),(0,s.isSuccessCommandResult)(e)||expect(e.error).toEqual(expect.objectContaining({_tag:"AleoAppCommandError",errorCode:"69f0",message:"Denied by user"}))}),it("should handle device error codes",()=>{const o=new a.SignFeeIntentCommand({feeIntent:n}),t={statusCode:new Uint8Array([176,8]),data:new Uint8Array([])},e=o.parseResponse(t);expect((0,s.isSuccessCommandResult)(e)).toBe(!1),(0,s.isSuccessCommandResult)(e)||expect(e.error).toEqual(expect.objectContaining({_tag:"AleoAppCommandError",errorCode:"b008",message:"Signature fail"}))})})});
|
|
2
2
|
//# sourceMappingURL=SignFeeIntentCommand.test.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/internal/app-binder/command/SignFeeIntentCommand.test.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n type Apdu,\n type ApduResponse,\n CommandResultFactory,\n InvalidStatusWordError,\n isSuccessCommandResult,\n} from \"@ledgerhq/device-management-kit\";\n\nimport {\n ALEO_CLA,\n INS,\n P1,\n P2_DEFAULT,\n} from \"@internal/app-binder/command/utils/apduHeaderUtils\";\n\nimport { SignFeeIntentCommand } from \"./SignFeeIntentCommand\";\n\ndescribe(\"SignFeeIntentCommand\", () => {\n const mockFeeIntent = new Uint8Array([0x05, 0x06, 0x07, 0x08]);\n\n describe(\"name\", () => {\n it(\"should be 'signFeeIntent'\", () => {\n const command = new SignFeeIntentCommand({\n feeIntent: mockFeeIntent,\n });\n expect(command.name).toBe(\"signFeeIntent\");\n });\n });\n\n describe(\"getApdu\", () => {\n it(\"should create correct APDU with P1=0x02\", () => {\n // Given\n const command = new SignFeeIntentCommand({\n feeIntent: mockFeeIntent,\n });\n\n // When\n const apdu: Apdu = command.getApdu();\n\n // Then\n expect(apdu.cla).toBe(ALEO_CLA);\n expect(apdu.ins).toBe(INS.SIGN_INTENT);\n expect(apdu.p1).toBe(P1.SIGN_MODE_FEE);\n expect(apdu.p2).toBe(P2_DEFAULT);\n\n // Should only contain length (2 bytes) + fee intent data (no derivation path)\n expect(apdu.data.length).toBe(2 + mockFeeIntent.length);\n const expectedData = new Uint8Array(2 + mockFeeIntent.length);\n expectedData[0] = 0x00;\n expectedData[1] = mockFeeIntent.length;\n expectedData.set(mockFeeIntent, 2);\n expect(apdu.data).toEqual(expectedData);\n });\n });\n\n describe(\"parseResponse\", () => {\n it(\"should return hexadecimal string for successful response\", () => {\n // Given\n const command = new SignFeeIntentCommand({\n feeIntent: mockFeeIntent,\n });\n\n const response: ApduResponse = {\n statusCode: new Uint8Array([0x90, 0x00]),\n data: new Uint8Array([0x01, 0x02, 0x03]),\n };\n\n // When\n const result = command.parseResponse(response);\n\n // Then\n expect(result).toEqual(\n CommandResultFactory({\n data: {\n tlvSignature: \"010203\",\n },\n }),\n );\n });\n\n it(\"should return error if extraction fails\", () => {\n // Given\n const command = new SignFeeIntentCommand({\n feeIntent: mockFeeIntent,\n });\n\n const response: ApduResponse = {\n statusCode: new Uint8Array([0x90, 0x00]),\n data: new Uint8Array([]), // Empty data when extraction is expected\n };\n\n // When\n const result = command.parseResponse(response);\n\n // Then\n expect(result).toEqual(\n CommandResultFactory({\n error: new InvalidStatusWordError(\n \"Failed to extract data from response\",\n ),\n }),\n );\n });\n\n it(\"should handle user rejection\", () => {\n // Given\n const command = new SignFeeIntentCommand({\n feeIntent: mockFeeIntent,\n });\n\n // User denied
|
|
4
|
+
"sourcesContent": ["import {\n type Apdu,\n type ApduResponse,\n CommandResultFactory,\n InvalidStatusWordError,\n isSuccessCommandResult,\n} from \"@ledgerhq/device-management-kit\";\n\nimport {\n ALEO_CLA,\n INS,\n P1,\n P2_DEFAULT,\n} from \"@internal/app-binder/command/utils/apduHeaderUtils\";\n\nimport { SignFeeIntentCommand } from \"./SignFeeIntentCommand\";\n\ndescribe(\"SignFeeIntentCommand\", () => {\n const mockFeeIntent = new Uint8Array([0x05, 0x06, 0x07, 0x08]);\n\n describe(\"name\", () => {\n it(\"should be 'signFeeIntent'\", () => {\n const command = new SignFeeIntentCommand({\n feeIntent: mockFeeIntent,\n });\n expect(command.name).toBe(\"signFeeIntent\");\n });\n });\n\n describe(\"getApdu\", () => {\n it(\"should create correct APDU with P1=0x02\", () => {\n // Given\n const command = new SignFeeIntentCommand({\n feeIntent: mockFeeIntent,\n });\n\n // When\n const apdu: Apdu = command.getApdu();\n\n // Then\n expect(apdu.cla).toBe(ALEO_CLA);\n expect(apdu.ins).toBe(INS.SIGN_INTENT);\n expect(apdu.p1).toBe(P1.SIGN_MODE_FEE);\n expect(apdu.p2).toBe(P2_DEFAULT);\n\n // Should only contain length (2 bytes) + fee intent data (no derivation path)\n expect(apdu.data.length).toBe(2 + mockFeeIntent.length);\n const expectedData = new Uint8Array(2 + mockFeeIntent.length);\n expectedData[0] = 0x00;\n expectedData[1] = mockFeeIntent.length;\n expectedData.set(mockFeeIntent, 2);\n expect(apdu.data).toEqual(expectedData);\n });\n });\n\n describe(\"parseResponse\", () => {\n it(\"should return hexadecimal string for successful response\", () => {\n // Given\n const command = new SignFeeIntentCommand({\n feeIntent: mockFeeIntent,\n });\n\n const response: ApduResponse = {\n statusCode: new Uint8Array([0x90, 0x00]),\n data: new Uint8Array([0x01, 0x02, 0x03]),\n };\n\n // When\n const result = command.parseResponse(response);\n\n // Then\n expect(result).toEqual(\n CommandResultFactory({\n data: {\n tlvSignature: \"010203\",\n },\n }),\n );\n });\n\n it(\"should return error if extraction fails\", () => {\n // Given\n const command = new SignFeeIntentCommand({\n feeIntent: mockFeeIntent,\n });\n\n const response: ApduResponse = {\n statusCode: new Uint8Array([0x90, 0x00]),\n data: new Uint8Array([]), // Empty data when extraction is expected\n };\n\n // When\n const result = command.parseResponse(response);\n\n // Then\n expect(result).toEqual(\n CommandResultFactory({\n error: new InvalidStatusWordError(\n \"Failed to extract data from response\",\n ),\n }),\n );\n });\n\n it(\"should handle user rejection\", () => {\n // Given\n const command = new SignFeeIntentCommand({\n feeIntent: mockFeeIntent,\n });\n\n // User denied\n const response: ApduResponse = {\n statusCode: new Uint8Array([0x69, 0xf0]),\n data: new Uint8Array([]),\n };\n\n // When\n const result = command.parseResponse(response);\n\n // Then\n expect(isSuccessCommandResult(result)).toBe(false);\n if (!isSuccessCommandResult(result)) {\n expect(result.error).toEqual(\n expect.objectContaining({\n _tag: \"AleoAppCommandError\",\n errorCode: \"69f0\",\n message: \"Denied by user\",\n }),\n );\n }\n });\n\n it(\"should handle device error codes\", () => {\n // Given\n const command = new SignFeeIntentCommand({\n feeIntent: mockFeeIntent,\n });\n\n // Signature fail (0xb008)\n const response: ApduResponse = {\n statusCode: new Uint8Array([0xb0, 0x08]),\n data: new Uint8Array([]),\n };\n\n // When\n const result = command.parseResponse(response);\n\n // Then\n expect(isSuccessCommandResult(result)).toBe(false);\n if (!isSuccessCommandResult(result)) {\n expect(result.error).toEqual(\n expect.objectContaining({\n _tag: \"AleoAppCommandError\",\n errorCode: \"b008\",\n message: \"Signature fail\",\n }),\n );\n }\n });\n });\n});\n"],
|
|
5
5
|
"mappings": "aAAA,IAAAA,EAMO,2CAEPC,EAKO,8DAEPC,EAAqC,kCAErC,SAAS,uBAAwB,IAAM,CACrC,MAAMC,EAAgB,IAAI,WAAW,CAAC,EAAM,EAAM,EAAM,CAAI,CAAC,EAE7D,SAAS,OAAQ,IAAM,CACrB,GAAG,4BAA6B,IAAM,CACpC,MAAMC,EAAU,IAAI,uBA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CACzB,EAGMC,EAASJ,EAAQ,cAAcG,CAAQ,EAG7C,OAAOC,CAAM,EAAE,WACb,wBAAqB,CACnB,MAAO,IAAI,yBACT,sCACF,CACF,CAAC,CACH,CACF,CAAC,EAED,GAAG,+BAAgC,IAAM,CAEvC,MAAMJ,EAAU,IAAI,uBAAqB,CACvC,UAAWD,CACb,CAAC,EAGKI,EAAyB,CAC7B,WAAY,IAAI,WAAW,CAAC,IAAM,GAAI,CAAC,EACvC,KAAM,IAAI,WAAW,CAAC,CAAC,CACzB,EAGMC,EAASJ,EAAQ,cAAcG,CAAQ,EAG7C,UAAO,0BAAuBC,CAAM,CAAC,EAAE,KAAK,EAAK,KAC5C,0BAAuBA,CAAM,GAChC,OAAOA,EAAO,KAAK,EAAE,QACnB,OAAO,iBAAiB,CACtB,KAAM,sBACN,UAAW,OACX,QAAS,gBACX,CAAC,CACH,CAEJ,CAAC,EAED,GAAG,mCAAoC,IAAM,CAE3C,MAAMJ,EAAU,IAAI,uBAAqB,CACvC,UAAWD,CACb,CAAC,EAGKI,EAAyB,CAC7B,WAAY,IAAI,WAAW,CAAC,IAAM,CAAI,CAAC,EACvC,KAAM,IAAI,WAAW,CAAC,CAAC,CACzB,EAGMC,EAASJ,EAAQ,cAAcG,CAAQ,EAG7C,UAAO,0BAAuBC,CAAM,CAAC,EAAE,KAAK,EAAK,KAC5C,0BAAuBA,CAAM,GAChC,OAAOA,EAAO,KAAK,EAAE,QACnB,OAAO,iBAAiB,CACtB,KAAM,sBACN,UAAW,OACX,QAAS,gBACX,CAAC,CACH,CAEJ,CAAC,CACH,CAAC,CACH,CAAC",
|
|
6
6
|
"names": ["import_device_management_kit", "import_apduHeaderUtils", "import_SignFeeIntentCommand", "mockFeeIntent", "command", "apdu", "expectedData", "response", "result"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var n=require("@ledgerhq/device-management-kit"),a=require("../../app-binder/command/utils/apduHeaderUtils"),s=require("./SignRootIntentCommand");describe("SignRootIntentCommand",()=>{const c="m/44'/1'/0'/0/0",r=new Uint8Array([1,2,3,4]);describe("name",()=>{it("should be 'signRootIntent'",()=>{const o=new s.SignRootIntentCommand({derivationPath:"44'/683'/0'",rootIntent:r});expect(o.name).toBe("signRootIntent")})}),describe("getApdu",()=>{it("should create correct APDU",()=>{const t=new s.SignRootIntentCommand({derivationPath:"44'/683'/0'",rootIntent:r}).getApdu();expect(t.cla).toBe(a.ALEO_CLA),expect(t.ins).toBe(a.INS.SIGN_INTENT),expect(t.p1).toBe(a.P1.SIGN_MODE_ROOT),expect(t.p2).toBe(a.P2_DEFAULT);const e=1+3*4;expect(t.data.length).toBe(e+2+r.length),expect(t.data[0]).toBe(3)}),it("should handle custom derivation path",()=>{const o="44'/683'/122'",e=new s.SignRootIntentCommand({derivationPath:o,rootIntent:r}).getApdu();expect(e.data[0]).toBe(3);const d=1+3*4;expect(e.data.length).toBe(d+2+r.length)})}),describe("parseResponse",()=>{it("should return hexadecimal string for successful response",()=>{const o=new s.SignRootIntentCommand({derivationPath:c,rootIntent:r}),t={statusCode:new Uint8Array([144,0]),data:new Uint8Array([1,2,3])},e=o.parseResponse(t);expect(e).toEqual((0,n.CommandResultFactory)({data:{tlvSignature:"010203"}}))}),it("should return error if extraction fails",()=>{const o=new s.SignRootIntentCommand({derivationPath:c,rootIntent:r}),t={statusCode:new Uint8Array([144,0]),data:new Uint8Array([])},e=o.parseResponse(t);expect(e).toEqual((0,n.CommandResultFactory)({error:new n.InvalidStatusWordError("Failed to extract data from response")}))}),it("should handle error response codes",()=>{const o=new s.SignRootIntentCommand({derivationPath:c,rootIntent:r}),t={statusCode:new Uint8Array([105,
|
|
1
|
+
"use strict";var n=require("@ledgerhq/device-management-kit"),a=require("../../app-binder/command/utils/apduHeaderUtils"),s=require("./SignRootIntentCommand");describe("SignRootIntentCommand",()=>{const c="m/44'/1'/0'/0/0",r=new Uint8Array([1,2,3,4]);describe("name",()=>{it("should be 'signRootIntent'",()=>{const o=new s.SignRootIntentCommand({derivationPath:"44'/683'/0'",rootIntent:r});expect(o.name).toBe("signRootIntent")})}),describe("getApdu",()=>{it("should create correct APDU",()=>{const t=new s.SignRootIntentCommand({derivationPath:"44'/683'/0'",rootIntent:r}).getApdu();expect(t.cla).toBe(a.ALEO_CLA),expect(t.ins).toBe(a.INS.SIGN_INTENT),expect(t.p1).toBe(a.P1.SIGN_MODE_ROOT),expect(t.p2).toBe(a.P2_DEFAULT);const e=1+3*4;expect(t.data.length).toBe(e+2+r.length),expect(t.data[0]).toBe(3)}),it("should handle custom derivation path",()=>{const o="44'/683'/122'",e=new s.SignRootIntentCommand({derivationPath:o,rootIntent:r}).getApdu();expect(e.data[0]).toBe(3);const d=1+3*4;expect(e.data.length).toBe(d+2+r.length)})}),describe("parseResponse",()=>{it("should return hexadecimal string for successful response",()=>{const o=new s.SignRootIntentCommand({derivationPath:c,rootIntent:r}),t={statusCode:new Uint8Array([144,0]),data:new Uint8Array([1,2,3])},e=o.parseResponse(t);expect(e).toEqual((0,n.CommandResultFactory)({data:{tlvSignature:"010203"}}))}),it("should return error if extraction fails",()=>{const o=new s.SignRootIntentCommand({derivationPath:c,rootIntent:r}),t={statusCode:new Uint8Array([144,0]),data:new Uint8Array([])},e=o.parseResponse(t);expect(e).toEqual((0,n.CommandResultFactory)({error:new n.InvalidStatusWordError("Failed to extract data from response")}))}),it("should handle error response codes",()=>{const o=new s.SignRootIntentCommand({derivationPath:c,rootIntent:r}),t={statusCode:new Uint8Array([105,240]),data:new Uint8Array([])},e=o.parseResponse(t);expect((0,n.isSuccessCommandResult)(e)).toBe(!1),(0,n.isSuccessCommandResult)(e)||expect(e.error).toEqual(expect.objectContaining({_tag:"AleoAppCommandError",errorCode:"69f0",message:"Denied by user"}))}),it("should handle device error codes",()=>{const o=new s.SignRootIntentCommand({derivationPath:c,rootIntent:r}),t={statusCode:new Uint8Array([176,4]),data:new Uint8Array([])},e=o.parseResponse(t);expect((0,n.isSuccessCommandResult)(e)).toBe(!1),(0,n.isSuccessCommandResult)(e)||expect(e.error).toEqual(expect.objectContaining({_tag:"AleoAppCommandError",errorCode:"b004",message:"Wrong transaction length"}))})})});
|
|
2
2
|
//# sourceMappingURL=SignRootIntentCommand.test.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/internal/app-binder/command/SignRootIntentCommand.test.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n type Apdu,\n type ApduResponse,\n CommandResultFactory,\n InvalidStatusWordError,\n isSuccessCommandResult,\n} from \"@ledgerhq/device-management-kit\";\n\nimport {\n ALEO_CLA,\n INS,\n P1,\n P2_DEFAULT,\n} from \"@internal/app-binder/command/utils/apduHeaderUtils\";\n\nimport { SignRootIntentCommand } from \"./SignRootIntentCommand\";\n\ndescribe(\"SignRootIntentCommand\", () => {\n const mockDerivationPath = \"m/44'/1'/0'/0/0\";\n const mockRootIntent = new Uint8Array([0x01, 0x02, 0x03, 0x04]);\n\n describe(\"name\", () => {\n it(\"should be 'signRootIntent'\", () => {\n const command = new SignRootIntentCommand({\n derivationPath: \"44'/683'/0'\",\n rootIntent: mockRootIntent,\n });\n expect(command.name).toBe(\"signRootIntent\");\n });\n });\n\n describe(\"getApdu\", () => {\n it(\"should create correct APDU\", () => {\n // Given\n const command = new SignRootIntentCommand({\n derivationPath: \"44'/683'/0'\",\n rootIntent: mockRootIntent,\n });\n\n // When\n const apdu: Apdu = command.getApdu();\n\n // Then\n expect(apdu.cla).toBe(ALEO_CLA);\n expect(apdu.ins).toBe(INS.SIGN_INTENT);\n expect(apdu.p1).toBe(P1.SIGN_MODE_ROOT);\n expect(apdu.p2).toBe(P2_DEFAULT);\n\n // Should contain derivation path (3 path elements) + root intent length (2 bytes) + root intent data\n const expectedPathLength = 1 + 3 * 4; // 1 byte for count + 3 elements * 4 bytes each\n expect(apdu.data.length).toBe(\n expectedPathLength + 2 + mockRootIntent.length,\n );\n\n // Verify path count is 3\n expect(apdu.data[0]).toBe(3);\n });\n\n it(\"should handle custom derivation path\", () => {\n // Given\n const customPath = \"44'/683'/122'\";\n const command = new SignRootIntentCommand({\n derivationPath: customPath,\n rootIntent: mockRootIntent,\n });\n\n // When\n const apdu: Apdu = command.getApdu();\n\n // Then\n expect(apdu.data[0]).toBe(3); // 3 elements\n const expectedPathLength = 1 + 3 * 4;\n expect(apdu.data.length).toBe(\n expectedPathLength + 2 + mockRootIntent.length,\n );\n });\n });\n\n describe(\"parseResponse\", () => {\n it(\"should return hexadecimal string for successful response\", () => {\n // Given\n const command = new SignRootIntentCommand({\n derivationPath: mockDerivationPath,\n rootIntent: mockRootIntent,\n });\n\n const response: ApduResponse = {\n statusCode: new Uint8Array([0x90, 0x00]),\n data: new Uint8Array([0x01, 0x02, 0x03]),\n };\n\n // When\n const result = command.parseResponse(response);\n\n // Then\n expect(result).toEqual(\n CommandResultFactory({\n data: {\n tlvSignature: \"010203\",\n },\n }),\n );\n });\n\n it(\"should return error if extraction fails\", () => {\n // Given\n const command = new SignRootIntentCommand({\n derivationPath: mockDerivationPath,\n rootIntent: mockRootIntent,\n });\n\n const response: ApduResponse = {\n statusCode: new Uint8Array([0x90, 0x00]),\n data: new Uint8Array([]), // Empty data when extraction is expected\n };\n\n // When\n const result = command.parseResponse(response);\n\n // Then\n expect(result).toEqual(\n CommandResultFactory({\n error: new InvalidStatusWordError(\n \"Failed to extract data from response\",\n ),\n }),\n );\n });\n\n it(\"should handle error response codes\", () => {\n // Given\n const command = new SignRootIntentCommand({\n derivationPath: mockDerivationPath,\n rootIntent: mockRootIntent,\n });\n\n // User denied\n const response: ApduResponse = {\n statusCode: new Uint8Array([0x69,
|
|
4
|
+
"sourcesContent": ["import {\n type Apdu,\n type ApduResponse,\n CommandResultFactory,\n InvalidStatusWordError,\n isSuccessCommandResult,\n} from \"@ledgerhq/device-management-kit\";\n\nimport {\n ALEO_CLA,\n INS,\n P1,\n P2_DEFAULT,\n} from \"@internal/app-binder/command/utils/apduHeaderUtils\";\n\nimport { SignRootIntentCommand } from \"./SignRootIntentCommand\";\n\ndescribe(\"SignRootIntentCommand\", () => {\n const mockDerivationPath = \"m/44'/1'/0'/0/0\";\n const mockRootIntent = new Uint8Array([0x01, 0x02, 0x03, 0x04]);\n\n describe(\"name\", () => {\n it(\"should be 'signRootIntent'\", () => {\n const command = new SignRootIntentCommand({\n derivationPath: \"44'/683'/0'\",\n rootIntent: mockRootIntent,\n });\n expect(command.name).toBe(\"signRootIntent\");\n });\n });\n\n describe(\"getApdu\", () => {\n it(\"should create correct APDU\", () => {\n // Given\n const command = new SignRootIntentCommand({\n derivationPath: \"44'/683'/0'\",\n rootIntent: mockRootIntent,\n });\n\n // When\n const apdu: Apdu = command.getApdu();\n\n // Then\n expect(apdu.cla).toBe(ALEO_CLA);\n expect(apdu.ins).toBe(INS.SIGN_INTENT);\n expect(apdu.p1).toBe(P1.SIGN_MODE_ROOT);\n expect(apdu.p2).toBe(P2_DEFAULT);\n\n // Should contain derivation path (3 path elements) + root intent length (2 bytes) + root intent data\n const expectedPathLength = 1 + 3 * 4; // 1 byte for count + 3 elements * 4 bytes each\n expect(apdu.data.length).toBe(\n expectedPathLength + 2 + mockRootIntent.length,\n );\n\n // Verify path count is 3\n expect(apdu.data[0]).toBe(3);\n });\n\n it(\"should handle custom derivation path\", () => {\n // Given\n const customPath = \"44'/683'/122'\";\n const command = new SignRootIntentCommand({\n derivationPath: customPath,\n rootIntent: mockRootIntent,\n });\n\n // When\n const apdu: Apdu = command.getApdu();\n\n // Then\n expect(apdu.data[0]).toBe(3); // 3 elements\n const expectedPathLength = 1 + 3 * 4;\n expect(apdu.data.length).toBe(\n expectedPathLength + 2 + mockRootIntent.length,\n );\n });\n });\n\n describe(\"parseResponse\", () => {\n it(\"should return hexadecimal string for successful response\", () => {\n // Given\n const command = new SignRootIntentCommand({\n derivationPath: mockDerivationPath,\n rootIntent: mockRootIntent,\n });\n\n const response: ApduResponse = {\n statusCode: new Uint8Array([0x90, 0x00]),\n data: new Uint8Array([0x01, 0x02, 0x03]),\n };\n\n // When\n const result = command.parseResponse(response);\n\n // Then\n expect(result).toEqual(\n CommandResultFactory({\n data: {\n tlvSignature: \"010203\",\n },\n }),\n );\n });\n\n it(\"should return error if extraction fails\", () => {\n // Given\n const command = new SignRootIntentCommand({\n derivationPath: mockDerivationPath,\n rootIntent: mockRootIntent,\n });\n\n const response: ApduResponse = {\n statusCode: new Uint8Array([0x90, 0x00]),\n data: new Uint8Array([]), // Empty data when extraction is expected\n };\n\n // When\n const result = command.parseResponse(response);\n\n // Then\n expect(result).toEqual(\n CommandResultFactory({\n error: new InvalidStatusWordError(\n \"Failed to extract data from response\",\n ),\n }),\n );\n });\n\n it(\"should handle error response codes\", () => {\n // Given\n const command = new SignRootIntentCommand({\n derivationPath: mockDerivationPath,\n rootIntent: mockRootIntent,\n });\n\n // User denied\n const response: ApduResponse = {\n statusCode: new Uint8Array([0x69, 0xf0]),\n data: new Uint8Array([]),\n };\n\n // When\n const result = command.parseResponse(response);\n\n // Then\n expect(isSuccessCommandResult(result)).toBe(false);\n if (!isSuccessCommandResult(result)) {\n expect(result.error).toEqual(\n expect.objectContaining({\n _tag: \"AleoAppCommandError\",\n errorCode: \"69f0\",\n message: \"Denied by user\",\n }),\n );\n }\n });\n\n it(\"should handle device error codes\", () => {\n // Given\n const command = new SignRootIntentCommand({\n derivationPath: mockDerivationPath,\n rootIntent: mockRootIntent,\n });\n\n // Wrong transaction length\n const response: ApduResponse = {\n statusCode: new Uint8Array([0xb0, 0x04]),\n data: new Uint8Array([]),\n };\n\n // When\n const result = command.parseResponse(response);\n\n // Then\n expect(isSuccessCommandResult(result)).toBe(false);\n if (!isSuccessCommandResult(result)) {\n expect(result.error).toEqual(\n expect.objectContaining({\n _tag: \"AleoAppCommandError\",\n errorCode: \"b004\",\n message: \"Wrong transaction length\",\n }),\n );\n }\n });\n });\n});\n"],
|
|
5
5
|
"mappings": "aAAA,IAAAA,EAMO,2CA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,WAAW,CAAC,CAAC,CACzB,EAGMC,EAASL,EAAQ,cAAcI,CAAQ,EAG7C,UAAO,0BAAuBC,CAAM,CAAC,EAAE,KAAK,EAAK,KAC5C,0BAAuBA,CAAM,GAChC,OAAOA,EAAO,KAAK,EAAE,QACnB,OAAO,iBAAiB,CACtB,KAAM,sBACN,UAAW,OACX,QAAS,0BACX,CAAC,CACH,CAEJ,CAAC,CACH,CAAC,CACH,CAAC",
|
|
6
6
|
"names": ["import_device_management_kit", "import_apduHeaderUtils", "import_SignRootIntentCommand", "mockDerivationPath", "mockRootIntent", "command", "apdu", "expectedPathLength", "customPath", "response", "result"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var a=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var d=Object.getOwnPropertyNames;var
|
|
1
|
+
"use strict";var a=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var d=Object.getOwnPropertyNames;var i=Object.prototype.hasOwnProperty;var l=(o,e)=>{for(var s in e)a(o,s,{get:e[s],enumerable:!0})},p=(o,e,s,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of d(e))!i.call(o,r)&&r!==s&&a(o,r,{get:()=>e[r],enumerable:!(n=g(e,r))||n.enumerable});return o};var b=o=>p(a({},"__esModule",{value:!0}),o);var E={};l(E,{ALEO_APP_ERRORS:()=>c,AleoAppCommandError:()=>m,AleoAppCommandErrorFactory:()=>A});module.exports=b(E);var t=require("@ledgerhq/device-management-kit");const c={"69f0":{message:"Denied by user"},6985:{message:"Condition not satisfied"},"6a86":{message:"Incorrect P1 or P2"},"6a87":{message:"Wrong LC or length of APDU command less than 5"},"6d00":{message:"Unknown command with this INS"},"6e00":{message:"Instruction class is different than CLA"},b000:{message:"Wrong response length (buffer too small or too big)"},b001:{message:"Fail to display BIP32 path"},b002:{message:"Fail to display address"},b003:{message:"Fail to display amount"},b004:{message:"Wrong transaction length"},b005:{message:"Fail of transaction parsing"},b006:{message:"Fail of transaction hash"},b007:{message:"Bad state"},b008:{message:"Signature fail"},c000:{message:"Swap failure"}};class m extends t.DeviceExchangeError{constructor(e){super({tag:"AleoAppCommandError",...e})}}const A=o=>new m(o);0&&(module.exports={ALEO_APP_ERRORS,AleoAppCommandError,AleoAppCommandErrorFactory});
|
|
2
2
|
//# sourceMappingURL=aleoApplicationErrors.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/internal/app-binder/command/utils/aleoApplicationErrors.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n type CommandErrorArgs,\n type CommandErrors,\n DeviceExchangeError,\n} from \"@ledgerhq/device-management-kit\";\n\nexport type AleoErrorCodes =\n | \"69f0\"\n | \"6985\"\n | \"6a86\"\n | \"6a87\"\n | \"6d00\"\n | \"6e00\"\n | \"b000\"\n | \"b001\"\n | \"b002\"\n | \"b003\"\n | \"b004\"\n | \"b005\"\n | \"b006\"\n | \"b007\"\n | \"b008\"\n | \"c000\";\n\nexport const ALEO_APP_ERRORS: CommandErrors<AleoErrorCodes> = {\n \"69f0\": { message: \"Denied by user\" }
|
|
5
|
-
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,qBAAAE,EAAA,wBAAAC,EAAA,+BAAAC,IAAA,eAAAC,EAAAL,GAAA,IAAAM,EAIO,2CAoBA,MAAMJ,EAAiD,CAC5D,OAAQ,CAAE,QAAS,gBAAiB,EACpC,KAAQ,CAAE,QAAS,
|
|
4
|
+
"sourcesContent": ["import {\n type CommandErrorArgs,\n type CommandErrors,\n DeviceExchangeError,\n} from \"@ledgerhq/device-management-kit\";\n\nexport type AleoErrorCodes =\n | \"69f0\"\n | \"6985\"\n | \"6a86\"\n | \"6a87\"\n | \"6d00\"\n | \"6e00\"\n | \"b000\"\n | \"b001\"\n | \"b002\"\n | \"b003\"\n | \"b004\"\n | \"b005\"\n | \"b006\"\n | \"b007\"\n | \"b008\"\n | \"c000\";\n\nexport const ALEO_APP_ERRORS: CommandErrors<AleoErrorCodes> = {\n \"69f0\": { message: \"Denied by user\" },\n \"6985\": { message: \"Condition not satisfied\" },\n \"6a86\": { message: \"Incorrect P1 or P2\" },\n \"6a87\": { message: \"Wrong LC or length of APDU command less than 5\" },\n \"6d00\": { message: \"Unknown command with this INS\" },\n \"6e00\": { message: \"Instruction class is different than CLA\" },\n b000: { message: \"Wrong response length (buffer too small or too big)\" },\n b001: { message: \"Fail to display BIP32 path\" },\n b002: { message: \"Fail to display address\" },\n b003: { message: \"Fail to display amount\" },\n b004: { message: \"Wrong transaction length\" },\n b005: { message: \"Fail of transaction parsing\" },\n b006: { message: \"Fail of transaction hash\" },\n b007: { message: \"Bad state\" },\n b008: { message: \"Signature fail\" },\n c000: { message: \"Swap failure\" },\n};\n\nexport class AleoAppCommandError extends DeviceExchangeError<AleoErrorCodes> {\n constructor(args: CommandErrorArgs<AleoErrorCodes>) {\n super({ tag: \"AleoAppCommandError\", ...args });\n }\n}\n\nexport const AleoAppCommandErrorFactory = (\n args: CommandErrorArgs<AleoErrorCodes>,\n) => new AleoAppCommandError(args);\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,qBAAAE,EAAA,wBAAAC,EAAA,+BAAAC,IAAA,eAAAC,EAAAL,GAAA,IAAAM,EAIO,2CAoBA,MAAMJ,EAAiD,CAC5D,OAAQ,CAAE,QAAS,gBAAiB,EACpC,KAAQ,CAAE,QAAS,yBAA0B,EAC7C,OAAQ,CAAE,QAAS,oBAAqB,EACxC,OAAQ,CAAE,QAAS,gDAAiD,EACpE,OAAQ,CAAE,QAAS,+BAAgC,EACnD,OAAQ,CAAE,QAAS,yCAA0C,EAC7D,KAAM,CAAE,QAAS,qDAAsD,EACvE,KAAM,CAAE,QAAS,4BAA6B,EAC9C,KAAM,CAAE,QAAS,yBAA0B,EAC3C,KAAM,CAAE,QAAS,wBAAyB,EAC1C,KAAM,CAAE,QAAS,0BAA2B,EAC5C,KAAM,CAAE,QAAS,6BAA8B,EAC/C,KAAM,CAAE,QAAS,0BAA2B,EAC5C,KAAM,CAAE,QAAS,WAAY,EAC7B,KAAM,CAAE,QAAS,gBAAiB,EAClC,KAAM,CAAE,QAAS,cAAe,CAClC,EAEO,MAAMC,UAA4B,qBAAoC,CAC3E,YAAYI,EAAwC,CAClD,MAAM,CAAE,IAAK,sBAAuB,GAAGA,CAAK,CAAC,CAC/C,CACF,CAEO,MAAMH,EACXG,GACG,IAAIJ,EAAoBI,CAAI",
|
|
6
6
|
"names": ["aleoApplicationErrors_exports", "__export", "ALEO_APP_ERRORS", "AleoAppCommandError", "AleoAppCommandErrorFactory", "__toCommonJS", "import_device_management_kit", "args"]
|
|
7
7
|
}
|
package/lib/cjs/package.json
CHANGED
|
@@ -59,5 +59,5 @@
|
|
|
59
59
|
"watch:builds": "pnpm ldmk-tool watch --entryPoints src/index.ts,src/**/*.ts --tsconfig tsconfig.prod.json",
|
|
60
60
|
"watch:types": "concurrently \"tsc --watch -p tsconfig.prod.json\" \"tsc-alias --watch -p tsconfig.prod.json\""
|
|
61
61
|
},
|
|
62
|
-
"version": "0.0.0-develop-
|
|
62
|
+
"version": "0.0.0-develop-20260313001318"
|
|
63
63
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{CommandResultFactory as a,InvalidStatusWordError as c,isSuccessCommandResult as r}from"@ledgerhq/device-management-kit";import{ALEO_CLA as p,INS as d,P1 as i,P2_DEFAULT as u}from"../../app-binder/command/utils/apduHeaderUtils";import{SignFeeIntentCommand as s}from"./SignFeeIntentCommand";describe("SignFeeIntentCommand",()=>{const n=new Uint8Array([5,6,7,8]);describe("name",()=>{it("should be 'signFeeIntent'",()=>{const o=new s({feeIntent:n});expect(o.name).toBe("signFeeIntent")})}),describe("getApdu",()=>{it("should create correct APDU with P1=0x02",()=>{const t=new s({feeIntent:n}).getApdu();expect(t.cla).toBe(p),expect(t.ins).toBe(d.SIGN_INTENT),expect(t.p1).toBe(i.SIGN_MODE_FEE),expect(t.p2).toBe(u),expect(t.data.length).toBe(2+n.length);const e=new Uint8Array(2+n.length);e[0]=0,e[1]=n.length,e.set(n,2),expect(t.data).toEqual(e)})}),describe("parseResponse",()=>{it("should return hexadecimal string for successful response",()=>{const o=new s({feeIntent:n}),t={statusCode:new Uint8Array([144,0]),data:new Uint8Array([1,2,3])},e=o.parseResponse(t);expect(e).toEqual(a({data:{tlvSignature:"010203"}}))}),it("should return error if extraction fails",()=>{const o=new s({feeIntent:n}),t={statusCode:new Uint8Array([144,0]),data:new Uint8Array([])},e=o.parseResponse(t);expect(e).toEqual(a({error:new c("Failed to extract data from response")}))}),it("should handle user rejection",()=>{const o=new s({feeIntent:n}),t={statusCode:new Uint8Array([105,
|
|
1
|
+
import{CommandResultFactory as a,InvalidStatusWordError as c,isSuccessCommandResult as r}from"@ledgerhq/device-management-kit";import{ALEO_CLA as p,INS as d,P1 as i,P2_DEFAULT as u}from"../../app-binder/command/utils/apduHeaderUtils";import{SignFeeIntentCommand as s}from"./SignFeeIntentCommand";describe("SignFeeIntentCommand",()=>{const n=new Uint8Array([5,6,7,8]);describe("name",()=>{it("should be 'signFeeIntent'",()=>{const o=new s({feeIntent:n});expect(o.name).toBe("signFeeIntent")})}),describe("getApdu",()=>{it("should create correct APDU with P1=0x02",()=>{const t=new s({feeIntent:n}).getApdu();expect(t.cla).toBe(p),expect(t.ins).toBe(d.SIGN_INTENT),expect(t.p1).toBe(i.SIGN_MODE_FEE),expect(t.p2).toBe(u),expect(t.data.length).toBe(2+n.length);const e=new Uint8Array(2+n.length);e[0]=0,e[1]=n.length,e.set(n,2),expect(t.data).toEqual(e)})}),describe("parseResponse",()=>{it("should return hexadecimal string for successful response",()=>{const o=new s({feeIntent:n}),t={statusCode:new Uint8Array([144,0]),data:new Uint8Array([1,2,3])},e=o.parseResponse(t);expect(e).toEqual(a({data:{tlvSignature:"010203"}}))}),it("should return error if extraction fails",()=>{const o=new s({feeIntent:n}),t={statusCode:new Uint8Array([144,0]),data:new Uint8Array([])},e=o.parseResponse(t);expect(e).toEqual(a({error:new c("Failed to extract data from response")}))}),it("should handle user rejection",()=>{const o=new s({feeIntent:n}),t={statusCode:new Uint8Array([105,240]),data:new Uint8Array([])},e=o.parseResponse(t);expect(r(e)).toBe(!1),r(e)||expect(e.error).toEqual(expect.objectContaining({_tag:"AleoAppCommandError",errorCode:"69f0",message:"Denied by user"}))}),it("should handle device error codes",()=>{const o=new s({feeIntent:n}),t={statusCode:new Uint8Array([176,8]),data:new Uint8Array([])},e=o.parseResponse(t);expect(r(e)).toBe(!1),r(e)||expect(e.error).toEqual(expect.objectContaining({_tag:"AleoAppCommandError",errorCode:"b008",message:"Signature fail"}))})})});
|
|
2
2
|
//# sourceMappingURL=SignFeeIntentCommand.test.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/internal/app-binder/command/SignFeeIntentCommand.test.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n type Apdu,\n type ApduResponse,\n CommandResultFactory,\n InvalidStatusWordError,\n isSuccessCommandResult,\n} from \"@ledgerhq/device-management-kit\";\n\nimport {\n ALEO_CLA,\n INS,\n P1,\n P2_DEFAULT,\n} from \"@internal/app-binder/command/utils/apduHeaderUtils\";\n\nimport { SignFeeIntentCommand } from \"./SignFeeIntentCommand\";\n\ndescribe(\"SignFeeIntentCommand\", () => {\n const mockFeeIntent = new Uint8Array([0x05, 0x06, 0x07, 0x08]);\n\n describe(\"name\", () => {\n it(\"should be 'signFeeIntent'\", () => {\n const command = new SignFeeIntentCommand({\n feeIntent: mockFeeIntent,\n });\n expect(command.name).toBe(\"signFeeIntent\");\n });\n });\n\n describe(\"getApdu\", () => {\n it(\"should create correct APDU with P1=0x02\", () => {\n // Given\n const command = new SignFeeIntentCommand({\n feeIntent: mockFeeIntent,\n });\n\n // When\n const apdu: Apdu = command.getApdu();\n\n // Then\n expect(apdu.cla).toBe(ALEO_CLA);\n expect(apdu.ins).toBe(INS.SIGN_INTENT);\n expect(apdu.p1).toBe(P1.SIGN_MODE_FEE);\n expect(apdu.p2).toBe(P2_DEFAULT);\n\n // Should only contain length (2 bytes) + fee intent data (no derivation path)\n expect(apdu.data.length).toBe(2 + mockFeeIntent.length);\n const expectedData = new Uint8Array(2 + mockFeeIntent.length);\n expectedData[0] = 0x00;\n expectedData[1] = mockFeeIntent.length;\n expectedData.set(mockFeeIntent, 2);\n expect(apdu.data).toEqual(expectedData);\n });\n });\n\n describe(\"parseResponse\", () => {\n it(\"should return hexadecimal string for successful response\", () => {\n // Given\n const command = new SignFeeIntentCommand({\n feeIntent: mockFeeIntent,\n });\n\n const response: ApduResponse = {\n statusCode: new Uint8Array([0x90, 0x00]),\n data: new Uint8Array([0x01, 0x02, 0x03]),\n };\n\n // When\n const result = command.parseResponse(response);\n\n // Then\n expect(result).toEqual(\n CommandResultFactory({\n data: {\n tlvSignature: \"010203\",\n },\n }),\n );\n });\n\n it(\"should return error if extraction fails\", () => {\n // Given\n const command = new SignFeeIntentCommand({\n feeIntent: mockFeeIntent,\n });\n\n const response: ApduResponse = {\n statusCode: new Uint8Array([0x90, 0x00]),\n data: new Uint8Array([]), // Empty data when extraction is expected\n };\n\n // When\n const result = command.parseResponse(response);\n\n // Then\n expect(result).toEqual(\n CommandResultFactory({\n error: new InvalidStatusWordError(\n \"Failed to extract data from response\",\n ),\n }),\n );\n });\n\n it(\"should handle user rejection\", () => {\n // Given\n const command = new SignFeeIntentCommand({\n feeIntent: mockFeeIntent,\n });\n\n // User denied
|
|
4
|
+
"sourcesContent": ["import {\n type Apdu,\n type ApduResponse,\n CommandResultFactory,\n InvalidStatusWordError,\n isSuccessCommandResult,\n} from \"@ledgerhq/device-management-kit\";\n\nimport {\n ALEO_CLA,\n INS,\n P1,\n P2_DEFAULT,\n} from \"@internal/app-binder/command/utils/apduHeaderUtils\";\n\nimport { SignFeeIntentCommand } from \"./SignFeeIntentCommand\";\n\ndescribe(\"SignFeeIntentCommand\", () => {\n const mockFeeIntent = new Uint8Array([0x05, 0x06, 0x07, 0x08]);\n\n describe(\"name\", () => {\n it(\"should be 'signFeeIntent'\", () => {\n const command = new SignFeeIntentCommand({\n feeIntent: mockFeeIntent,\n });\n expect(command.name).toBe(\"signFeeIntent\");\n });\n });\n\n describe(\"getApdu\", () => {\n it(\"should create correct APDU with P1=0x02\", () => {\n // Given\n const command = new SignFeeIntentCommand({\n feeIntent: mockFeeIntent,\n });\n\n // When\n const apdu: Apdu = command.getApdu();\n\n // Then\n expect(apdu.cla).toBe(ALEO_CLA);\n expect(apdu.ins).toBe(INS.SIGN_INTENT);\n expect(apdu.p1).toBe(P1.SIGN_MODE_FEE);\n expect(apdu.p2).toBe(P2_DEFAULT);\n\n // Should only contain length (2 bytes) + fee intent data (no derivation path)\n expect(apdu.data.length).toBe(2 + mockFeeIntent.length);\n const expectedData = new Uint8Array(2 + mockFeeIntent.length);\n expectedData[0] = 0x00;\n expectedData[1] = mockFeeIntent.length;\n expectedData.set(mockFeeIntent, 2);\n expect(apdu.data).toEqual(expectedData);\n });\n });\n\n describe(\"parseResponse\", () => {\n it(\"should return hexadecimal string for successful response\", () => {\n // Given\n const command = new SignFeeIntentCommand({\n feeIntent: mockFeeIntent,\n });\n\n const response: ApduResponse = {\n statusCode: new Uint8Array([0x90, 0x00]),\n data: new Uint8Array([0x01, 0x02, 0x03]),\n };\n\n // When\n const result = command.parseResponse(response);\n\n // Then\n expect(result).toEqual(\n CommandResultFactory({\n data: {\n tlvSignature: \"010203\",\n },\n }),\n );\n });\n\n it(\"should return error if extraction fails\", () => {\n // Given\n const command = new SignFeeIntentCommand({\n feeIntent: mockFeeIntent,\n });\n\n const response: ApduResponse = {\n statusCode: new Uint8Array([0x90, 0x00]),\n data: new Uint8Array([]), // Empty data when extraction is expected\n };\n\n // When\n const result = command.parseResponse(response);\n\n // Then\n expect(result).toEqual(\n CommandResultFactory({\n error: new InvalidStatusWordError(\n \"Failed to extract data from response\",\n ),\n }),\n );\n });\n\n it(\"should handle user rejection\", () => {\n // Given\n const command = new SignFeeIntentCommand({\n feeIntent: mockFeeIntent,\n });\n\n // User denied\n const response: ApduResponse = {\n statusCode: new Uint8Array([0x69, 0xf0]),\n data: new Uint8Array([]),\n };\n\n // When\n const result = command.parseResponse(response);\n\n // Then\n expect(isSuccessCommandResult(result)).toBe(false);\n if (!isSuccessCommandResult(result)) {\n expect(result.error).toEqual(\n expect.objectContaining({\n _tag: \"AleoAppCommandError\",\n errorCode: \"69f0\",\n message: \"Denied by user\",\n }),\n );\n }\n });\n\n it(\"should handle device error codes\", () => {\n // Given\n const command = new SignFeeIntentCommand({\n feeIntent: mockFeeIntent,\n });\n\n // Signature fail (0xb008)\n const response: ApduResponse = {\n statusCode: new Uint8Array([0xb0, 0x08]),\n data: new Uint8Array([]),\n };\n\n // When\n const result = command.parseResponse(response);\n\n // Then\n expect(isSuccessCommandResult(result)).toBe(false);\n if (!isSuccessCommandResult(result)) {\n expect(result.error).toEqual(\n expect.objectContaining({\n _tag: \"AleoAppCommandError\",\n errorCode: \"b008\",\n message: \"Signature fail\",\n }),\n );\n }\n });\n });\n});\n"],
|
|
5
5
|
"mappings": "AAAA,OAGE,wBAAAA,EACA,0BAAAC,EACA,0BAAAC,MACK,kCAEP,OACE,YAAAC,EACA,OAAAC,EACA,MAAAC,EACA,cAAAC,MACK,qDAEP,OAAS,wBAAAC,MAA4B,yBAErC,SAAS,uBAAwB,IAAM,CACrC,MAAMC,EAAgB,IAAI,WAAW,CAAC,EAAM,EAAM,EAAM,CAAI,CAAC,EAE7D,SAAS,OAAQ,IAAM,CACrB,GAAG,4BAA6B,IAAM,CACpC,MAAMC,EAAU,IAAIF,EAAqB,CACvC,UAAWC,CACb,CAAC,EACD,OAAOC,EAAQ,IAAI,EAAE,KAAK,eAAe,CAC3C,CAAC,CACH,CAAC,EAED,SAAS,UAAW,IAAM,CACxB,GAAG,0CAA2C,I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C,EAED,GAAG,+BAAgC,IAAM,CAEvC,MAAMQ,EAAU,IAAIF,EAAqB,CACvC,UAAWC,CACb,CAAC,EAGKI,EAAyB,CAC7B,WAAY,IAAI,WAAW,CAAC,IAAM,GAAI,CAAC,EACvC,KAAM,IAAI,WAAW,CAAC,CAAC,CACzB,EAGMC,EAASJ,EAAQ,cAAcG,CAAQ,EAG7C,OAAOV,EAAuBW,CAAM,CAAC,EAAE,KAAK,EAAK,EAC5CX,EAAuBW,CAAM,GAChC,OAAOA,EAAO,KAAK,EAAE,QACnB,OAAO,iBAAiB,CACtB,KAAM,sBACN,UAAW,OACX,QAAS,gBACX,CAAC,CACH,CAEJ,CAAC,EAED,GAAG,mCAAoC,IAAM,CAE3C,MAAMJ,EAAU,IAAIF,EAAqB,CACvC,UAAWC,CACb,CAAC,EAGKI,EAAyB,CAC7B,WAAY,IAAI,WAAW,CAAC,IAAM,CAAI,CAAC,EACvC,KAAM,IAAI,WAAW,CAAC,CAAC,CACzB,EAGMC,EAASJ,EAAQ,cAAcG,CAAQ,EAG7C,OAAOV,EAAuBW,CAAM,CAAC,EAAE,KAAK,EAAK,EAC5CX,EAAuBW,CAAM,GAChC,OAAOA,EAAO,KAAK,EAAE,QACnB,OAAO,iBAAiB,CACtB,KAAM,sBACN,UAAW,OACX,QAAS,gBACX,CAAC,CACH,CAEJ,CAAC,CACH,CAAC,CACH,CAAC",
|
|
6
6
|
"names": ["CommandResultFactory", "InvalidStatusWordError", "isSuccessCommandResult", "ALEO_CLA", "INS", "P1", "P2_DEFAULT", "SignFeeIntentCommand", "mockFeeIntent", "command", "apdu", "expectedData", "response", "result"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{CommandResultFactory as c,InvalidStatusWordError as p,isSuccessCommandResult as a}from"@ledgerhq/device-management-kit";import{ALEO_CLA as i,INS as m,P1 as u,P2_DEFAULT as x}from"../../app-binder/command/utils/apduHeaderUtils";import{SignRootIntentCommand as r}from"./SignRootIntentCommand";describe("SignRootIntentCommand",()=>{const s="m/44'/1'/0'/0/0",n=new Uint8Array([1,2,3,4]);describe("name",()=>{it("should be 'signRootIntent'",()=>{const o=new r({derivationPath:"44'/683'/0'",rootIntent:n});expect(o.name).toBe("signRootIntent")})}),describe("getApdu",()=>{it("should create correct APDU",()=>{const t=new r({derivationPath:"44'/683'/0'",rootIntent:n}).getApdu();expect(t.cla).toBe(i),expect(t.ins).toBe(m.SIGN_INTENT),expect(t.p1).toBe(u.SIGN_MODE_ROOT),expect(t.p2).toBe(x);const e=1+3*4;expect(t.data.length).toBe(e+2+n.length),expect(t.data[0]).toBe(3)}),it("should handle custom derivation path",()=>{const o="44'/683'/122'",e=new r({derivationPath:o,rootIntent:n}).getApdu();expect(e.data[0]).toBe(3);const d=1+3*4;expect(e.data.length).toBe(d+2+n.length)})}),describe("parseResponse",()=>{it("should return hexadecimal string for successful response",()=>{const o=new r({derivationPath:s,rootIntent:n}),t={statusCode:new Uint8Array([144,0]),data:new Uint8Array([1,2,3])},e=o.parseResponse(t);expect(e).toEqual(c({data:{tlvSignature:"010203"}}))}),it("should return error if extraction fails",()=>{const o=new r({derivationPath:s,rootIntent:n}),t={statusCode:new Uint8Array([144,0]),data:new Uint8Array([])},e=o.parseResponse(t);expect(e).toEqual(c({error:new p("Failed to extract data from response")}))}),it("should handle error response codes",()=>{const o=new r({derivationPath:s,rootIntent:n}),t={statusCode:new Uint8Array([105,
|
|
1
|
+
import{CommandResultFactory as c,InvalidStatusWordError as p,isSuccessCommandResult as a}from"@ledgerhq/device-management-kit";import{ALEO_CLA as i,INS as m,P1 as u,P2_DEFAULT as x}from"../../app-binder/command/utils/apduHeaderUtils";import{SignRootIntentCommand as r}from"./SignRootIntentCommand";describe("SignRootIntentCommand",()=>{const s="m/44'/1'/0'/0/0",n=new Uint8Array([1,2,3,4]);describe("name",()=>{it("should be 'signRootIntent'",()=>{const o=new r({derivationPath:"44'/683'/0'",rootIntent:n});expect(o.name).toBe("signRootIntent")})}),describe("getApdu",()=>{it("should create correct APDU",()=>{const t=new r({derivationPath:"44'/683'/0'",rootIntent:n}).getApdu();expect(t.cla).toBe(i),expect(t.ins).toBe(m.SIGN_INTENT),expect(t.p1).toBe(u.SIGN_MODE_ROOT),expect(t.p2).toBe(x);const e=1+3*4;expect(t.data.length).toBe(e+2+n.length),expect(t.data[0]).toBe(3)}),it("should handle custom derivation path",()=>{const o="44'/683'/122'",e=new r({derivationPath:o,rootIntent:n}).getApdu();expect(e.data[0]).toBe(3);const d=1+3*4;expect(e.data.length).toBe(d+2+n.length)})}),describe("parseResponse",()=>{it("should return hexadecimal string for successful response",()=>{const o=new r({derivationPath:s,rootIntent:n}),t={statusCode:new Uint8Array([144,0]),data:new Uint8Array([1,2,3])},e=o.parseResponse(t);expect(e).toEqual(c({data:{tlvSignature:"010203"}}))}),it("should return error if extraction fails",()=>{const o=new r({derivationPath:s,rootIntent:n}),t={statusCode:new Uint8Array([144,0]),data:new Uint8Array([])},e=o.parseResponse(t);expect(e).toEqual(c({error:new p("Failed to extract data from response")}))}),it("should handle error response codes",()=>{const o=new r({derivationPath:s,rootIntent:n}),t={statusCode:new Uint8Array([105,240]),data:new Uint8Array([])},e=o.parseResponse(t);expect(a(e)).toBe(!1),a(e)||expect(e.error).toEqual(expect.objectContaining({_tag:"AleoAppCommandError",errorCode:"69f0",message:"Denied by user"}))}),it("should handle device error codes",()=>{const o=new r({derivationPath:s,rootIntent:n}),t={statusCode:new Uint8Array([176,4]),data:new Uint8Array([])},e=o.parseResponse(t);expect(a(e)).toBe(!1),a(e)||expect(e.error).toEqual(expect.objectContaining({_tag:"AleoAppCommandError",errorCode:"b004",message:"Wrong transaction length"}))})})});
|
|
2
2
|
//# sourceMappingURL=SignRootIntentCommand.test.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/internal/app-binder/command/SignRootIntentCommand.test.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n type Apdu,\n type ApduResponse,\n CommandResultFactory,\n InvalidStatusWordError,\n isSuccessCommandResult,\n} from \"@ledgerhq/device-management-kit\";\n\nimport {\n ALEO_CLA,\n INS,\n P1,\n P2_DEFAULT,\n} from \"@internal/app-binder/command/utils/apduHeaderUtils\";\n\nimport { SignRootIntentCommand } from \"./SignRootIntentCommand\";\n\ndescribe(\"SignRootIntentCommand\", () => {\n const mockDerivationPath = \"m/44'/1'/0'/0/0\";\n const mockRootIntent = new Uint8Array([0x01, 0x02, 0x03, 0x04]);\n\n describe(\"name\", () => {\n it(\"should be 'signRootIntent'\", () => {\n const command = new SignRootIntentCommand({\n derivationPath: \"44'/683'/0'\",\n rootIntent: mockRootIntent,\n });\n expect(command.name).toBe(\"signRootIntent\");\n });\n });\n\n describe(\"getApdu\", () => {\n it(\"should create correct APDU\", () => {\n // Given\n const command = new SignRootIntentCommand({\n derivationPath: \"44'/683'/0'\",\n rootIntent: mockRootIntent,\n });\n\n // When\n const apdu: Apdu = command.getApdu();\n\n // Then\n expect(apdu.cla).toBe(ALEO_CLA);\n expect(apdu.ins).toBe(INS.SIGN_INTENT);\n expect(apdu.p1).toBe(P1.SIGN_MODE_ROOT);\n expect(apdu.p2).toBe(P2_DEFAULT);\n\n // Should contain derivation path (3 path elements) + root intent length (2 bytes) + root intent data\n const expectedPathLength = 1 + 3 * 4; // 1 byte for count + 3 elements * 4 bytes each\n expect(apdu.data.length).toBe(\n expectedPathLength + 2 + mockRootIntent.length,\n );\n\n // Verify path count is 3\n expect(apdu.data[0]).toBe(3);\n });\n\n it(\"should handle custom derivation path\", () => {\n // Given\n const customPath = \"44'/683'/122'\";\n const command = new SignRootIntentCommand({\n derivationPath: customPath,\n rootIntent: mockRootIntent,\n });\n\n // When\n const apdu: Apdu = command.getApdu();\n\n // Then\n expect(apdu.data[0]).toBe(3); // 3 elements\n const expectedPathLength = 1 + 3 * 4;\n expect(apdu.data.length).toBe(\n expectedPathLength + 2 + mockRootIntent.length,\n );\n });\n });\n\n describe(\"parseResponse\", () => {\n it(\"should return hexadecimal string for successful response\", () => {\n // Given\n const command = new SignRootIntentCommand({\n derivationPath: mockDerivationPath,\n rootIntent: mockRootIntent,\n });\n\n const response: ApduResponse = {\n statusCode: new Uint8Array([0x90, 0x00]),\n data: new Uint8Array([0x01, 0x02, 0x03]),\n };\n\n // When\n const result = command.parseResponse(response);\n\n // Then\n expect(result).toEqual(\n CommandResultFactory({\n data: {\n tlvSignature: \"010203\",\n },\n }),\n );\n });\n\n it(\"should return error if extraction fails\", () => {\n // Given\n const command = new SignRootIntentCommand({\n derivationPath: mockDerivationPath,\n rootIntent: mockRootIntent,\n });\n\n const response: ApduResponse = {\n statusCode: new Uint8Array([0x90, 0x00]),\n data: new Uint8Array([]), // Empty data when extraction is expected\n };\n\n // When\n const result = command.parseResponse(response);\n\n // Then\n expect(result).toEqual(\n CommandResultFactory({\n error: new InvalidStatusWordError(\n \"Failed to extract data from response\",\n ),\n }),\n );\n });\n\n it(\"should handle error response codes\", () => {\n // Given\n const command = new SignRootIntentCommand({\n derivationPath: mockDerivationPath,\n rootIntent: mockRootIntent,\n });\n\n // User denied\n const response: ApduResponse = {\n statusCode: new Uint8Array([0x69,
|
|
4
|
+
"sourcesContent": ["import {\n type Apdu,\n type ApduResponse,\n CommandResultFactory,\n InvalidStatusWordError,\n isSuccessCommandResult,\n} from \"@ledgerhq/device-management-kit\";\n\nimport {\n ALEO_CLA,\n INS,\n P1,\n P2_DEFAULT,\n} from \"@internal/app-binder/command/utils/apduHeaderUtils\";\n\nimport { SignRootIntentCommand } from \"./SignRootIntentCommand\";\n\ndescribe(\"SignRootIntentCommand\", () => {\n const mockDerivationPath = \"m/44'/1'/0'/0/0\";\n const mockRootIntent = new Uint8Array([0x01, 0x02, 0x03, 0x04]);\n\n describe(\"name\", () => {\n it(\"should be 'signRootIntent'\", () => {\n const command = new SignRootIntentCommand({\n derivationPath: \"44'/683'/0'\",\n rootIntent: mockRootIntent,\n });\n expect(command.name).toBe(\"signRootIntent\");\n });\n });\n\n describe(\"getApdu\", () => {\n it(\"should create correct APDU\", () => {\n // Given\n const command = new SignRootIntentCommand({\n derivationPath: \"44'/683'/0'\",\n rootIntent: mockRootIntent,\n });\n\n // When\n const apdu: Apdu = command.getApdu();\n\n // Then\n expect(apdu.cla).toBe(ALEO_CLA);\n expect(apdu.ins).toBe(INS.SIGN_INTENT);\n expect(apdu.p1).toBe(P1.SIGN_MODE_ROOT);\n expect(apdu.p2).toBe(P2_DEFAULT);\n\n // Should contain derivation path (3 path elements) + root intent length (2 bytes) + root intent data\n const expectedPathLength = 1 + 3 * 4; // 1 byte for count + 3 elements * 4 bytes each\n expect(apdu.data.length).toBe(\n expectedPathLength + 2 + mockRootIntent.length,\n );\n\n // Verify path count is 3\n expect(apdu.data[0]).toBe(3);\n });\n\n it(\"should handle custom derivation path\", () => {\n // Given\n const customPath = \"44'/683'/122'\";\n const command = new SignRootIntentCommand({\n derivationPath: customPath,\n rootIntent: mockRootIntent,\n });\n\n // When\n const apdu: Apdu = command.getApdu();\n\n // Then\n expect(apdu.data[0]).toBe(3); // 3 elements\n const expectedPathLength = 1 + 3 * 4;\n expect(apdu.data.length).toBe(\n expectedPathLength + 2 + mockRootIntent.length,\n );\n });\n });\n\n describe(\"parseResponse\", () => {\n it(\"should return hexadecimal string for successful response\", () => {\n // Given\n const command = new SignRootIntentCommand({\n derivationPath: mockDerivationPath,\n rootIntent: mockRootIntent,\n });\n\n const response: ApduResponse = {\n statusCode: new Uint8Array([0x90, 0x00]),\n data: new Uint8Array([0x01, 0x02, 0x03]),\n };\n\n // When\n const result = command.parseResponse(response);\n\n // Then\n expect(result).toEqual(\n CommandResultFactory({\n data: {\n tlvSignature: \"010203\",\n },\n }),\n );\n });\n\n it(\"should return error if extraction fails\", () => {\n // Given\n const command = new SignRootIntentCommand({\n derivationPath: mockDerivationPath,\n rootIntent: mockRootIntent,\n });\n\n const response: ApduResponse = {\n statusCode: new Uint8Array([0x90, 0x00]),\n data: new Uint8Array([]), // Empty data when extraction is expected\n };\n\n // When\n const result = command.parseResponse(response);\n\n // Then\n expect(result).toEqual(\n CommandResultFactory({\n error: new InvalidStatusWordError(\n \"Failed to extract data from response\",\n ),\n }),\n );\n });\n\n it(\"should handle error response codes\", () => {\n // Given\n const command = new SignRootIntentCommand({\n derivationPath: mockDerivationPath,\n rootIntent: mockRootIntent,\n });\n\n // User denied\n const response: ApduResponse = {\n statusCode: new Uint8Array([0x69, 0xf0]),\n data: new Uint8Array([]),\n };\n\n // When\n const result = command.parseResponse(response);\n\n // Then\n expect(isSuccessCommandResult(result)).toBe(false);\n if (!isSuccessCommandResult(result)) {\n expect(result.error).toEqual(\n expect.objectContaining({\n _tag: \"AleoAppCommandError\",\n errorCode: \"69f0\",\n message: \"Denied by user\",\n }),\n );\n }\n });\n\n it(\"should handle device error codes\", () => {\n // Given\n const command = new SignRootIntentCommand({\n derivationPath: mockDerivationPath,\n rootIntent: mockRootIntent,\n });\n\n // Wrong transaction length\n const response: ApduResponse = {\n statusCode: new Uint8Array([0xb0, 0x04]),\n data: new Uint8Array([]),\n };\n\n // When\n const result = command.parseResponse(response);\n\n // Then\n expect(isSuccessCommandResult(result)).toBe(false);\n if (!isSuccessCommandResult(result)) {\n expect(result.error).toEqual(\n expect.objectContaining({\n _tag: \"AleoAppCommandError\",\n errorCode: \"b004\",\n message: \"Wrong transaction length\",\n }),\n );\n }\n });\n });\n});\n"],
|
|
5
5
|
"mappings": "AAAA,OAGE,wBAAAA,EACA,0BAAAC,EACA,0BAAAC,MACK,kCAEP,OACE,YAAAC,EACA,OAAAC,EACA,MAAAC,EACA,cAAAC,MACK,qDAEP,OAAS,yBAAAC,MAA6B,0BAEtC,SAAS,wBAAyB,IAAM,CACtC,MAAMC,EAAqB,kBACrBC,EAAiB,IAAI,WAAW,CAAC,EAAM,EAAM,EAAM,CAAI,CAAC,EAE9D,SAAS,OAAQ,IAAM,CACrB,GAAG,6BAA8B,IAAM,CACrC,MAA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,CACtB,KAAM,sBACN,UAAW,OACX,QAAS,0BACX,CAAC,CACH,CAEJ,CAAC,CACH,CAAC,CACH,CAAC",
|
|
6
6
|
"names": ["CommandResultFactory", "InvalidStatusWordError", "isSuccessCommandResult", "ALEO_CLA", "INS", "P1", "P2_DEFAULT", "SignRootIntentCommand", "mockDerivationPath", "mockRootIntent", "command", "apdu", "expectedPathLength", "customPath", "response", "result"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{DeviceExchangeError as
|
|
1
|
+
import{DeviceExchangeError as r}from"@ledgerhq/device-management-kit";const n={"69f0":{message:"Denied by user"},6985:{message:"Condition not satisfied"},"6a86":{message:"Incorrect P1 or P2"},"6a87":{message:"Wrong LC or length of APDU command less than 5"},"6d00":{message:"Unknown command with this INS"},"6e00":{message:"Instruction class is different than CLA"},b000:{message:"Wrong response length (buffer too small or too big)"},b001:{message:"Fail to display BIP32 path"},b002:{message:"Fail to display address"},b003:{message:"Fail to display amount"},b004:{message:"Wrong transaction length"},b005:{message:"Fail of transaction parsing"},b006:{message:"Fail of transaction hash"},b007:{message:"Bad state"},b008:{message:"Signature fail"},c000:{message:"Swap failure"}};class s extends r{constructor(o){super({tag:"AleoAppCommandError",...o})}}const t=e=>new s(e);export{n as ALEO_APP_ERRORS,s as AleoAppCommandError,t as AleoAppCommandErrorFactory};
|
|
2
2
|
//# sourceMappingURL=aleoApplicationErrors.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/internal/app-binder/command/utils/aleoApplicationErrors.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n type CommandErrorArgs,\n type CommandErrors,\n DeviceExchangeError,\n} from \"@ledgerhq/device-management-kit\";\n\nexport type AleoErrorCodes =\n | \"69f0\"\n | \"6985\"\n | \"6a86\"\n | \"6a87\"\n | \"6d00\"\n | \"6e00\"\n | \"b000\"\n | \"b001\"\n | \"b002\"\n | \"b003\"\n | \"b004\"\n | \"b005\"\n | \"b006\"\n | \"b007\"\n | \"b008\"\n | \"c000\";\n\nexport const ALEO_APP_ERRORS: CommandErrors<AleoErrorCodes> = {\n \"69f0\": { message: \"Denied by user\" }
|
|
5
|
-
"mappings": "AAAA,OAGE,uBAAAA,MACK,kCAoBA,MAAMC,EAAiD,CAC5D,OAAQ,CAAE,QAAS,gBAAiB,EACpC,KAAQ,CAAE,QAAS,
|
|
4
|
+
"sourcesContent": ["import {\n type CommandErrorArgs,\n type CommandErrors,\n DeviceExchangeError,\n} from \"@ledgerhq/device-management-kit\";\n\nexport type AleoErrorCodes =\n | \"69f0\"\n | \"6985\"\n | \"6a86\"\n | \"6a87\"\n | \"6d00\"\n | \"6e00\"\n | \"b000\"\n | \"b001\"\n | \"b002\"\n | \"b003\"\n | \"b004\"\n | \"b005\"\n | \"b006\"\n | \"b007\"\n | \"b008\"\n | \"c000\";\n\nexport const ALEO_APP_ERRORS: CommandErrors<AleoErrorCodes> = {\n \"69f0\": { message: \"Denied by user\" },\n \"6985\": { message: \"Condition not satisfied\" },\n \"6a86\": { message: \"Incorrect P1 or P2\" },\n \"6a87\": { message: \"Wrong LC or length of APDU command less than 5\" },\n \"6d00\": { message: \"Unknown command with this INS\" },\n \"6e00\": { message: \"Instruction class is different than CLA\" },\n b000: { message: \"Wrong response length (buffer too small or too big)\" },\n b001: { message: \"Fail to display BIP32 path\" },\n b002: { message: \"Fail to display address\" },\n b003: { message: \"Fail to display amount\" },\n b004: { message: \"Wrong transaction length\" },\n b005: { message: \"Fail of transaction parsing\" },\n b006: { message: \"Fail of transaction hash\" },\n b007: { message: \"Bad state\" },\n b008: { message: \"Signature fail\" },\n c000: { message: \"Swap failure\" },\n};\n\nexport class AleoAppCommandError extends DeviceExchangeError<AleoErrorCodes> {\n constructor(args: CommandErrorArgs<AleoErrorCodes>) {\n super({ tag: \"AleoAppCommandError\", ...args });\n }\n}\n\nexport const AleoAppCommandErrorFactory = (\n args: CommandErrorArgs<AleoErrorCodes>,\n) => new AleoAppCommandError(args);\n"],
|
|
5
|
+
"mappings": "AAAA,OAGE,uBAAAA,MACK,kCAoBA,MAAMC,EAAiD,CAC5D,OAAQ,CAAE,QAAS,gBAAiB,EACpC,KAAQ,CAAE,QAAS,yBAA0B,EAC7C,OAAQ,CAAE,QAAS,oBAAqB,EACxC,OAAQ,CAAE,QAAS,gDAAiD,EACpE,OAAQ,CAAE,QAAS,+BAAgC,EACnD,OAAQ,CAAE,QAAS,yCAA0C,EAC7D,KAAM,CAAE,QAAS,qDAAsD,EACvE,KAAM,CAAE,QAAS,4BAA6B,EAC9C,KAAM,CAAE,QAAS,yBAA0B,EAC3C,KAAM,CAAE,QAAS,wBAAyB,EAC1C,KAAM,CAAE,QAAS,0BAA2B,EAC5C,KAAM,CAAE,QAAS,6BAA8B,EAC/C,KAAM,CAAE,QAAS,0BAA2B,EAC5C,KAAM,CAAE,QAAS,WAAY,EAC7B,KAAM,CAAE,QAAS,gBAAiB,EAClC,KAAM,CAAE,QAAS,cAAe,CAClC,EAEO,MAAMC,UAA4BF,CAAoC,CAC3E,YAAYG,EAAwC,CAClD,MAAM,CAAE,IAAK,sBAAuB,GAAGA,CAAK,CAAC,CAC/C,CACF,CAEO,MAAMC,EACXD,GACG,IAAID,EAAoBC,CAAI",
|
|
6
6
|
"names": ["DeviceExchangeError", "ALEO_APP_ERRORS", "AleoAppCommandError", "args", "AleoAppCommandErrorFactory"]
|
|
7
7
|
}
|
package/lib/esm/package.json
CHANGED
|
@@ -59,5 +59,5 @@
|
|
|
59
59
|
"watch:builds": "pnpm ldmk-tool watch --entryPoints src/index.ts,src/**/*.ts --tsconfig tsconfig.prod.json",
|
|
60
60
|
"watch:types": "concurrently \"tsc --watch -p tsconfig.prod.json\" \"tsc-alias --watch -p tsconfig.prod.json\""
|
|
61
61
|
},
|
|
62
|
-
"version": "0.0.0-develop-
|
|
62
|
+
"version": "0.0.0-develop-20260313001318"
|
|
63
63
|
}
|