@ledgerhq/device-signer-kit-ethereum 0.0.0-fix-lns-20250901094837 → 0.0.0-fix-v0-transaction-unfunded-20250918072642

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/lib/cjs/api/SignerEthBuilder.test.js +1 -1
  2. package/lib/cjs/api/SignerEthBuilder.test.js.map +1 -1
  3. package/lib/cjs/api/index.js +1 -1
  4. package/lib/cjs/api/index.js.map +3 -3
  5. package/lib/cjs/internal/app-binder/command/ProvideNetworkConfigurationCommand.js +2 -0
  6. package/lib/cjs/internal/app-binder/command/ProvideNetworkConfigurationCommand.js.map +7 -0
  7. package/lib/cjs/internal/app-binder/command/ProvideNetworkConfigurationCommand.test.js +2 -0
  8. package/lib/cjs/internal/app-binder/command/ProvideNetworkConfigurationCommand.test.js.map +7 -0
  9. package/lib/cjs/internal/app-binder/task/BuildTransactionContextTask.js +1 -1
  10. package/lib/cjs/internal/app-binder/task/BuildTransactionContextTask.js.map +3 -3
  11. package/lib/cjs/internal/app-binder/task/ProvideTransactionContextTask.js +1 -1
  12. package/lib/cjs/internal/app-binder/task/ProvideTransactionContextTask.js.map +3 -3
  13. package/lib/cjs/internal/app-binder/task/ProvideTransactionContextTask.test.js +1 -1
  14. package/lib/cjs/internal/app-binder/task/ProvideTransactionContextTask.test.js.map +3 -3
  15. package/lib/cjs/internal/app-binder/task/SendPayloadInChunksTask.js +1 -1
  16. package/lib/cjs/internal/app-binder/task/SendPayloadInChunksTask.js.map +3 -3
  17. package/lib/cjs/internal/app-binder/task/SendPayloadInChunksTask.test.js +1 -1
  18. package/lib/cjs/internal/app-binder/task/SendPayloadInChunksTask.test.js.map +3 -3
  19. package/lib/esm/api/SignerEthBuilder.test.js +1 -1
  20. package/lib/esm/api/SignerEthBuilder.test.js.map +1 -1
  21. package/lib/esm/api/index.js +1 -1
  22. package/lib/esm/api/index.js.map +2 -2
  23. package/lib/esm/internal/app-binder/command/ProvideNetworkConfigurationCommand.js +2 -0
  24. package/lib/esm/internal/app-binder/command/ProvideNetworkConfigurationCommand.js.map +7 -0
  25. package/lib/esm/internal/app-binder/command/ProvideNetworkConfigurationCommand.test.js +2 -0
  26. package/lib/esm/internal/app-binder/command/ProvideNetworkConfigurationCommand.test.js.map +7 -0
  27. package/lib/esm/internal/app-binder/task/BuildTransactionContextTask.js +1 -1
  28. package/lib/esm/internal/app-binder/task/BuildTransactionContextTask.js.map +3 -3
  29. package/lib/esm/internal/app-binder/task/ProvideTransactionContextTask.js +1 -1
  30. package/lib/esm/internal/app-binder/task/ProvideTransactionContextTask.js.map +3 -3
  31. package/lib/esm/internal/app-binder/task/ProvideTransactionContextTask.test.js +1 -1
  32. package/lib/esm/internal/app-binder/task/ProvideTransactionContextTask.test.js.map +3 -3
  33. package/lib/esm/internal/app-binder/task/SendPayloadInChunksTask.js +1 -1
  34. package/lib/esm/internal/app-binder/task/SendPayloadInChunksTask.js.map +3 -3
  35. package/lib/esm/internal/app-binder/task/SendPayloadInChunksTask.test.js +1 -1
  36. package/lib/esm/internal/app-binder/task/SendPayloadInChunksTask.test.js.map +3 -3
  37. package/lib/types/api/index.d.ts +5 -9
  38. package/lib/types/api/index.d.ts.map +1 -1
  39. package/lib/types/internal/app-binder/command/ProvideNetworkConfigurationCommand.d.ts +28 -0
  40. package/lib/types/internal/app-binder/command/ProvideNetworkConfigurationCommand.d.ts.map +1 -0
  41. package/lib/types/internal/app-binder/command/ProvideNetworkConfigurationCommand.test.d.ts +2 -0
  42. package/lib/types/internal/app-binder/command/ProvideNetworkConfigurationCommand.test.d.ts.map +1 -0
  43. package/lib/types/internal/app-binder/task/BuildTransactionContextTask.d.ts.map +1 -1
  44. package/lib/types/internal/app-binder/task/ProvideTransactionContextTask.d.ts.map +1 -1
  45. package/lib/types/internal/app-binder/task/SendPayloadInChunksTask.d.ts +1 -0
  46. package/lib/types/internal/app-binder/task/SendPayloadInChunksTask.d.ts.map +1 -1
  47. package/lib/types/tsconfig.prod.tsbuildinfo +1 -1
  48. package/package.json +6 -6
@@ -1,2 +1,2 @@
1
- "use strict";var n=require("./SignerEthBuilder"),c=require("../internal/DefaultSignerEth"),d=require("../internal/externalTypes");describe("SignerEthBuilder",()=>{const i={dmk:{},sessionId:"",originToken:"test"};test("should be an instance of SignerEth",()=>{const t=new n.SignerEthBuilder(i);t.build(),expect(t).toBeInstanceOf(n.SignerEthBuilder)}),test("should instanciate with default context module",()=>{const o=new n.SignerEthBuilder(i).build(),e=o._container.get(d.externalTypes.ContextModule);expect(o).toBeInstanceOf(c.DefaultSignerEth),expect(e).toBeDefined(),expect(e._loaders).toHaveLength(6),expect(e._typedDataLoader).toBeDefined(),expect(e._web3CheckLoader).toBeDefined()}),test("should instanciate with custom context module",()=>{const t=new n.SignerEthBuilder(i),o={},e=t.withContextModule(o).build();expect(e).toBeInstanceOf(c.DefaultSignerEth),expect(e._container.get(d.externalTypes.ContextModule)).toBe(o)})});
1
+ "use strict";var n=require("./SignerEthBuilder"),c=require("../internal/DefaultSignerEth"),d=require("../internal/externalTypes");describe("SignerEthBuilder",()=>{const i={dmk:{},sessionId:"",originToken:"test"};test("should be an instance of SignerEth",()=>{const t=new n.SignerEthBuilder(i);t.build(),expect(t).toBeInstanceOf(n.SignerEthBuilder)}),test("should instanciate with default context module",()=>{const o=new n.SignerEthBuilder(i).build(),e=o._container.get(d.externalTypes.ContextModule);expect(o).toBeInstanceOf(c.DefaultSignerEth),expect(e).toBeDefined(),expect(e._loaders).toHaveLength(7),expect(e._typedDataLoader).toBeDefined(),expect(e._web3CheckLoader).toBeDefined()}),test("should instanciate with custom context module",()=>{const t=new n.SignerEthBuilder(i),o={},e=t.withContextModule(o).build();expect(e).toBeInstanceOf(c.DefaultSignerEth),expect(e._container.get(d.externalTypes.ContextModule)).toBe(o)})});
2
2
  //# sourceMappingURL=SignerEthBuilder.test.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/api/SignerEthBuilder.test.ts"],
4
- "sourcesContent": ["import { type ContextModule } from \"@ledgerhq/context-module\";\nimport { type DeviceManagementKit } from \"@ledgerhq/device-management-kit\";\n\nimport { SignerEthBuilder } from \"@api/SignerEthBuilder\";\nimport { DefaultSignerEth } from \"@internal/DefaultSignerEth\";\nimport { externalTypes } from \"@internal/externalTypes\";\n\ndescribe(\"SignerEthBuilder\", () => {\n const dmk: DeviceManagementKit = {} as DeviceManagementKit;\n const defaultConstructorArgs = { dmk, sessionId: \"\", originToken: \"test\" };\n\n test(\"should be an instance of SignerEth\", () => {\n // GIVEN\n const builder = new SignerEthBuilder(defaultConstructorArgs);\n\n // WHEN\n builder.build();\n\n // THEN\n expect(builder).toBeInstanceOf(SignerEthBuilder);\n });\n\n test(\"should instanciate with default context module\", () => {\n // GIVEN\n const builder = new SignerEthBuilder(defaultConstructorArgs);\n\n // WHEN\n const signer = builder.build();\n const contextModule = signer[\"_container\"].get<ContextModule>(\n externalTypes.ContextModule,\n );\n\n // THEN\n expect(signer).toBeInstanceOf(DefaultSignerEth);\n expect(contextModule).toBeDefined();\n // @ts-expect-error - private property\n expect(contextModule._loaders).toHaveLength(6);\n // @ts-expect-error - private property\n expect(contextModule._typedDataLoader).toBeDefined();\n // @ts-expect-error - private property\n expect(contextModule._web3CheckLoader).toBeDefined();\n });\n\n test(\"should instanciate with custom context module\", () => {\n // GIVEN\n const builder = new SignerEthBuilder(defaultConstructorArgs);\n const contextModule = {} as ContextModule;\n\n // WHEN\n const signer = builder.withContextModule(contextModule).build();\n\n // THEN\n expect(signer).toBeInstanceOf(DefaultSignerEth);\n expect(\n signer[\"_container\"].get<ContextModule>(externalTypes.ContextModule),\n ).toBe(contextModule);\n });\n});\n"],
4
+ "sourcesContent": ["import { type ContextModule } from \"@ledgerhq/context-module\";\nimport { type DeviceManagementKit } from \"@ledgerhq/device-management-kit\";\n\nimport { SignerEthBuilder } from \"@api/SignerEthBuilder\";\nimport { DefaultSignerEth } from \"@internal/DefaultSignerEth\";\nimport { externalTypes } from \"@internal/externalTypes\";\n\ndescribe(\"SignerEthBuilder\", () => {\n const dmk: DeviceManagementKit = {} as DeviceManagementKit;\n const defaultConstructorArgs = { dmk, sessionId: \"\", originToken: \"test\" };\n\n test(\"should be an instance of SignerEth\", () => {\n // GIVEN\n const builder = new SignerEthBuilder(defaultConstructorArgs);\n\n // WHEN\n builder.build();\n\n // THEN\n expect(builder).toBeInstanceOf(SignerEthBuilder);\n });\n\n test(\"should instanciate with default context module\", () => {\n // GIVEN\n const builder = new SignerEthBuilder(defaultConstructorArgs);\n\n // WHEN\n const signer = builder.build();\n const contextModule = signer[\"_container\"].get<ContextModule>(\n externalTypes.ContextModule,\n );\n\n // THEN\n expect(signer).toBeInstanceOf(DefaultSignerEth);\n expect(contextModule).toBeDefined();\n // @ts-expect-error - private property\n expect(contextModule._loaders).toHaveLength(7);\n // @ts-expect-error - private property\n expect(contextModule._typedDataLoader).toBeDefined();\n // @ts-expect-error - private property\n expect(contextModule._web3CheckLoader).toBeDefined();\n });\n\n test(\"should instanciate with custom context module\", () => {\n // GIVEN\n const builder = new SignerEthBuilder(defaultConstructorArgs);\n const contextModule = {} as ContextModule;\n\n // WHEN\n const signer = builder.withContextModule(contextModule).build();\n\n // THEN\n expect(signer).toBeInstanceOf(DefaultSignerEth);\n expect(\n signer[\"_container\"].get<ContextModule>(externalTypes.ContextModule),\n ).toBe(contextModule);\n });\n});\n"],
5
5
  "mappings": "aAGA,IAAAA,EAAiC,iCACjCC,EAAiC,sCACjCC,EAA8B,mCAE9B,SAAS,mBAAoB,IAAM,CAEjC,MAAMC,EAAyB,CAAE,IADA,CAAC,EACI,UAAW,GAAI,YAAa,MAAO,EAEzE,KAAK,qCAAsC,IAAM,CAE/C,MAAMC,EAAU,IAAI,mBAAiBD,CAAsB,EAG3DC,EAAQ,MAAM,EAGd,OAAOA,CAAO,EAAE,eAAe,kBAAgB,CACjD,CAAC,EAED,KAAK,iDAAkD,IAAM,CAK3D,MAAMC,EAHU,IAAI,mBAAiBF,CAAsB,EAGpC,MAAM,EACvBG,EAAgBD,EAAO,WAAc,IACzC,gBAAc,aAChB,EAGA,OAAOA,CAAM,EAAE,eAAe,kBAAgB,EAC9C,OAAOC,CAAa,EAAE,YAAY,EAElC,OAAOA,EAAc,QAAQ,EAAE,aAAa,CAAC,EAE7C,OAAOA,EAAc,gBAAgB,EAAE,YAAY,EAEnD,OAAOA,EAAc,gBAAgB,EAAE,YAAY,CACrD,CAAC,EAED,KAAK,gDAAiD,IAAM,CAE1D,MAAMF,EAAU,IAAI,mBAAiBD,CAAsB,EACrDG,EAAgB,CAAC,EAGjBD,EAASD,EAAQ,kBAAkBE,CAAa,EAAE,MAAM,EAG9D,OAAOD,CAAM,EAAE,eAAe,kBAAgB,EAC9C,OACEA,EAAO,WAAc,IAAmB,gBAAc,aAAa,CACrE,EAAE,KAAKC,CAAa,CACtB,CAAC,CACH,CAAC",
6
6
  "names": ["import_SignerEthBuilder", "import_DefaultSignerEth", "import_externalTypes", "defaultConstructorArgs", "builder", "signer", "contextModule"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var i=Object.defineProperty;var A=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var m=Object.prototype.hasOwnProperty;var u=(o,r)=>{for(var a in r)i(o,a,{get:r[a],enumerable:!0})},p=(o,r,a,D)=>{if(r&&typeof r=="object"||typeof r=="function")for(let n of y(r))!m.call(o,n)&&n!==a&&i(o,n,{get:()=>r[n],enumerable:!(D=A(r,n))||D.enumerable});return o},e=(o,r,a)=>(p(o,r,"default"),a&&p(a,r,"default"));var s=o=>p(i({},"__esModule",{value:!0}),o);var t={};u(t,{SignTransactionDAStep:()=>g.SignTransactionDAStep,SignTypedDataDAStateStep:()=>S.SignTypedDataDAStateStep});module.exports=s(t);e(t,require("./app-binder/GetAddressDeviceActionTypes"),module.exports);var g=require("./app-binder/SignTransactionDeviceActionTypes"),S=require("./app-binder/SignTypedDataDeviceActionTypes");e(t,require("./model/Address"),module.exports);e(t,require("./model/AddressOptions"),module.exports);e(t,require("./model/Signature"),module.exports);e(t,require("./model/TransactionOptions"),module.exports);e(t,require("./model/TransactionType"),module.exports);e(t,require("./model/TypedData"),module.exports);e(t,require("./SignerEth"),module.exports);e(t,require("./SignerEthBuilder"),module.exports);0&&(module.exports={SignTransactionDAStep,SignTypedDataDAStateStep,...require("./app-binder/GetAddressDeviceActionTypes"),...require("./model/Address"),...require("./model/AddressOptions"),...require("./model/Signature"),...require("./model/TransactionOptions"),...require("./model/TransactionType"),...require("./model/TypedData"),...require("./SignerEth"),...require("./SignerEthBuilder")});
1
+ "use strict";var i=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var S=Object.getOwnPropertyNames;var u=Object.prototype.hasOwnProperty;var s=(r,n)=>{for(var a in n)i(r,a,{get:n[a],enumerable:!0})},o=(r,n,a,D)=>{if(n&&typeof n=="object"||typeof n=="function")for(let p of S(n))!u.call(r,p)&&p!==a&&i(r,p,{get:()=>n[p],enumerable:!(D=g(n,p))||D.enumerable});return r},e=(r,n,a)=>(o(r,n,"default"),a&&o(a,n,"default"));var d=r=>o(i({},"__esModule",{value:!0}),r);var t={};s(t,{SignTransactionDAStep:()=>y.SignTransactionDAStep,SignTypedDataDAStateStep:()=>A.SignTypedDataDAStateStep});module.exports=d(t);var y=require("./app-binder/SignTransactionDeviceActionTypes"),A=require("./app-binder/SignTypedDataDeviceActionTypes");e(t,require("./model/Address"),module.exports);e(t,require("./model/AddressOptions"),module.exports);e(t,require("./model/Signature"),module.exports);e(t,require("./model/TransactionOptions"),module.exports);e(t,require("./model/TransactionType"),module.exports);e(t,require("./model/TypedData"),module.exports);e(t,require("./SignerEth"),module.exports);e(t,require("./SignerEthBuilder"),module.exports);0&&(module.exports={SignTransactionDAStep,SignTypedDataDAStateStep,...require("./model/Address"),...require("./model/AddressOptions"),...require("./model/Signature"),...require("./model/TransactionOptions"),...require("./model/TransactionType"),...require("./model/TypedData"),...require("./SignerEth"),...require("./SignerEthBuilder")});
2
2
  //# sourceMappingURL=index.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/api/index.ts"],
4
- "sourcesContent": ["export * from \"@api/app-binder/GetAddressDeviceActionTypes\";\nexport { type SignDelegationAuthorizationDAError } from \"@api/app-binder/SignDelegationAuthorizationTypes\";\nexport { type SignDelegationAuthorizationDAInput } from \"@api/app-binder/SignDelegationAuthorizationTypes\";\nexport { type SignDelegationAuthorizationDAOutput } from \"@api/app-binder/SignDelegationAuthorizationTypes\";\nexport { type SignDelegationAuthorizationDAState } from \"@api/app-binder/SignDelegationAuthorizationTypes\";\nexport { type SignDelegationAuthorizationDAIntermediateValue } from \"@api/app-binder/SignDelegationAuthorizationTypes\";\nexport type {\n SignPersonalMessageDAError,\n SignPersonalMessageDAIntermediateValue,\n SignPersonalMessageDAOutput,\n} from \"@api/app-binder/SignPersonalMessageDeviceActionTypes\";\nexport {\n type SignTransactionDAError,\n type SignTransactionDAInput,\n type SignTransactionDAIntermediateValue,\n type SignTransactionDAOutput,\n type SignTransactionDAState,\n SignTransactionDAStep,\n} from \"@api/app-binder/SignTransactionDeviceActionTypes\";\nexport {\n type SignTypedDataDAError,\n type SignTypedDataDAInput,\n type SignTypedDataDAIntermediateValue,\n type SignTypedDataDAOutput,\n type SignTypedDataDAState,\n SignTypedDataDAStateStep,\n} from \"@api/app-binder/SignTypedDataDeviceActionTypes\";\nexport * from \"@api/model/Address\";\nexport * from \"@api/model/AddressOptions\";\nexport * from \"@api/model/Signature\";\nexport * from \"@api/model/TransactionOptions\";\nexport * from \"@api/model/TransactionType\";\nexport * from \"@api/model/TypedData\";\nexport * from \"@api/SignerEth\";\nexport * from \"@api/SignerEthBuilder\";\n"],
5
- "mappings": "2dAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,4HAAAE,EAAAF,GAAAG,EAAAH,EAAc,uDAAd,gBAWA,IAAAI,EAOO,4DACPC,EAOO,0DACPF,EAAAH,EAAc,8BA3Bd,gBA4BAG,EAAAH,EAAc,qCA5Bd,gBA6BAG,EAAAH,EAAc,gCA7Bd,gBA8BAG,EAAAH,EAAc,yCA9Bd,gBA+BAG,EAAAH,EAAc,sCA/Bd,gBAgCAG,EAAAH,EAAc,gCAhCd,gBAiCAG,EAAAH,EAAc,0BAjCd,gBAkCAG,EAAAH,EAAc,iCAlCd",
6
- "names": ["api_exports", "__export", "__toCommonJS", "__reExport", "import_SignTransactionDeviceActionTypes", "import_SignTypedDataDeviceActionTypes"]
4
+ "sourcesContent": ["export {\n type GetAddressDAError,\n type GetAddressDAIntermediateValue,\n type GetAddressDAOutput,\n type GetAddressDAReturnType,\n} from \"@api/app-binder/GetAddressDeviceActionTypes\";\nexport {\n type SignDelegationAuthorizationDAError,\n type SignDelegationAuthorizationDAInput,\n type SignDelegationAuthorizationDAIntermediateValue,\n type SignDelegationAuthorizationDAOutput,\n type SignDelegationAuthorizationDAReturnType,\n type SignDelegationAuthorizationDAState,\n} from \"@api/app-binder/SignDelegationAuthorizationTypes\";\nexport {\n type SignPersonalMessageDAError,\n type SignPersonalMessageDAIntermediateValue,\n type SignPersonalMessageDAOutput,\n type SignPersonalMessageDAReturnType,\n} from \"@api/app-binder/SignPersonalMessageDeviceActionTypes\";\nexport {\n type SignTransactionDAError,\n type SignTransactionDAInput,\n type SignTransactionDAIntermediateValue,\n type SignTransactionDAInternalState,\n type SignTransactionDAOutput,\n type SignTransactionDAReturnType,\n type SignTransactionDAState,\n SignTransactionDAStep,\n} from \"@api/app-binder/SignTransactionDeviceActionTypes\";\nexport {\n type SignTypedDataDAError,\n type SignTypedDataDAInput,\n type SignTypedDataDAIntermediateValue,\n type SignTypedDataDAInternalState,\n type SignTypedDataDAOutput,\n type SignTypedDataDAReturnType,\n type SignTypedDataDAState,\n SignTypedDataDAStateStep,\n} from \"@api/app-binder/SignTypedDataDeviceActionTypes\";\nexport * from \"@api/model/Address\";\nexport * from \"@api/model/AddressOptions\";\nexport * from \"@api/model/Signature\";\nexport * from \"@api/model/TransactionOptions\";\nexport * from \"@api/model/TransactionType\";\nexport * from \"@api/model/TypedData\";\nexport * from \"@api/SignerEth\";\nexport * from \"@api/SignerEthBuilder\";\n"],
5
+ "mappings": "2dAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,4HAAAE,EAAAF,GAoBA,IAAAG,EASO,4DACPC,EASO,0DACPC,EAAAL,EAAc,8BAxCd,gBAyCAK,EAAAL,EAAc,qCAzCd,gBA0CAK,EAAAL,EAAc,gCA1Cd,gBA2CAK,EAAAL,EAAc,yCA3Cd,gBA4CAK,EAAAL,EAAc,sCA5Cd,gBA6CAK,EAAAL,EAAc,gCA7Cd,gBA8CAK,EAAAL,EAAc,0BA9Cd,gBA+CAK,EAAAL,EAAc,iCA/Cd",
6
+ "names": ["api_exports", "__export", "__toCommonJS", "import_SignTransactionDeviceActionTypes", "import_SignTypedDataDeviceActionTypes", "__reExport"]
7
7
  }
@@ -0,0 +1,2 @@
1
+ "use strict";var n=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var C=Object.prototype.hasOwnProperty;var A=(e,r)=>{for(var o in r)n(e,o,{get:r[o],enumerable:!0})},g=(e,r,o,i)=>{if(r&&typeof r=="object"||typeof r=="function")for(let t of l(r))!C.call(e,t)&&t!==o&&n(e,t,{get:()=>r[t],enumerable:!(i=u(r,t))||i.enumerable});return e};var y=e=>g(n({},"__esModule",{value:!0}),e);var f={};A(f,{NetworkConfigurationType:()=>m,ProvideNetworkConfigurationCommand:()=>E});module.exports=y(f);var d=require("@ledgerhq/device-management-kit"),s=require("@ledgerhq/signer-utils"),p=require("purify-ts"),a=require("./utils/ethAppErrors"),m=(o=>(o[o.CONFIGURATION=0]="CONFIGURATION",o[o.ICON=1]="ICON",o))(m||{});class E{constructor(r){this.args=r}errorHelper=new s.CommandErrorHelper(a.ETH_APP_ERRORS,a.EthAppCommandErrorFactory);getApdu(){const r={cla:224,ins:48,p1:this.args.isFirstChunk?1:0,p2:this.args.configurationType};return new d.ApduBuilder(r).addBufferToData(this.args.data).build()}parseResponse(r){return p.Maybe.fromNullable(this.errorHelper.getError(r)).orDefault((0,d.CommandResultFactory)({data:void 0}))}}0&&(module.exports={NetworkConfigurationType,ProvideNetworkConfigurationCommand});
2
+ //# sourceMappingURL=ProvideNetworkConfigurationCommand.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/internal/app-binder/command/ProvideNetworkConfigurationCommand.ts"],
4
+ "sourcesContent": ["// https://github.com/LedgerHQ/app-ethereum/blob/develop/doc/ethapp.adoc#provide-network-configuration\nimport {\n type Apdu,\n ApduBuilder,\n type ApduBuilderArgs,\n type ApduResponse,\n type Command,\n type CommandResult,\n CommandResultFactory,\n} from \"@ledgerhq/device-management-kit\";\nimport { CommandErrorHelper } from \"@ledgerhq/signer-utils\";\nimport { Maybe } from \"purify-ts\";\n\nimport {\n ETH_APP_ERRORS,\n EthAppCommandErrorFactory,\n type EthErrorCodes,\n} from \"./utils/ethAppErrors\";\n\nexport enum NetworkConfigurationType {\n CONFIGURATION = 0x00,\n ICON = 0x01,\n}\n\nexport type ProvideNetworkConfigurationCommandArgs = {\n /**\n * The network configuration data to provide in chunks\n */\n readonly data: Uint8Array;\n /**\n * If this is the first chunk of the network configuration\n */\n readonly isFirstChunk: boolean;\n /**\n * The type of network configuration being provided\n */\n readonly configurationType: NetworkConfigurationType;\n};\n\nexport class ProvideNetworkConfigurationCommand\n implements\n Command<void, ProvideNetworkConfigurationCommandArgs, EthErrorCodes>\n{\n private readonly errorHelper = new CommandErrorHelper<void, EthErrorCodes>(\n ETH_APP_ERRORS,\n EthAppCommandErrorFactory,\n );\n\n constructor(private readonly args: ProvideNetworkConfigurationCommandArgs) {}\n\n getApdu(): Apdu {\n const provideNetworkConfigurationArgs: ApduBuilderArgs = {\n cla: 0xe0,\n ins: 0x30,\n p1: this.args.isFirstChunk ? 0x01 : 0x00,\n p2: this.args.configurationType,\n };\n\n return new ApduBuilder(provideNetworkConfigurationArgs)\n .addBufferToData(this.args.data)\n .build();\n }\n\n parseResponse(response: ApduResponse): CommandResult<void, EthErrorCodes> {\n return Maybe.fromNullable(this.errorHelper.getError(response)).orDefault(\n CommandResultFactory({ data: undefined }),\n );\n }\n}\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,8BAAAE,EAAA,uCAAAC,IAAA,eAAAC,EAAAJ,GACA,IAAAK,EAQO,2CACPC,EAAmC,kCACnCC,EAAsB,qBAEtBC,EAIO,gCAEKN,OACVA,IAAA,cAAgB,GAAhB,gBACAA,IAAA,KAAO,GAAP,OAFUA,OAAA,IAoBL,MAAMC,CAGb,CAME,YAA6BM,EAA8C,CAA9C,UAAAA,CAA+C,CAL3D,YAAc,IAAI,qBACjC,iBACA,2BACF,EAIA,SAAgB,CACd,MAAMC,EAAmD,CACvD,IAAK,IACL,IAAK,GACL,GAAI,KAAK,KAAK,aAAe,EAAO,EACpC,GAAI,KAAK,KAAK,iBAChB,EAEA,OAAO,IAAI,cAAYA,CAA+B,EACnD,gBAAgB,KAAK,KAAK,IAAI,EAC9B,MAAM,CACX,CAEA,cAAcC,EAA4D,CACxE,OAAO,QAAM,aAAa,KAAK,YAAY,SAASA,CAAQ,CAAC,EAAE,aAC7D,wBAAqB,CAAE,KAAM,MAAU,CAAC,CAC1C,CACF,CACF",
6
+ "names": ["ProvideNetworkConfigurationCommand_exports", "__export", "NetworkConfigurationType", "ProvideNetworkConfigurationCommand", "__toCommonJS", "import_device_management_kit", "import_signer_utils", "import_purify_ts", "import_ethAppErrors", "args", "provideNetworkConfigurationArgs", "response"]
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";var n=require("@ledgerhq/device-management-kit"),s=require("./utils/ethAppErrors"),r=require("./ProvideNetworkConfigurationCommand");describe("ProvideNetworkConfigurationCommand",()=>{describe("getApdu",()=>{it("should return the raw APDU for the first chunk",()=>{const t={data:Uint8Array.from([1,2,3]),isFirstChunk:!0,configurationType:r.NetworkConfigurationType.CONFIGURATION},e=new r.ProvideNetworkConfigurationCommand(t).getApdu();expect(e.getRawApdu()).toStrictEqual(Uint8Array.from([224,48,1,0,3,1,2,3]))}),it("should return the raw APDU for the subsequent chunk",()=>{const t={data:Uint8Array.from([4,5,6]),isFirstChunk:!1,configurationType:r.NetworkConfigurationType.CONFIGURATION},e=new r.ProvideNetworkConfigurationCommand(t).getApdu();expect(e.getRawApdu()).toStrictEqual(Uint8Array.from([224,48,0,0,3,4,5,6]))})}),describe("parseResponse",()=>{it("should return an error if the response status code is invalid",()=>{const t={data:Uint8Array.from([]),statusCode:Uint8Array.from([109,0])},e=new r.ProvideNetworkConfigurationCommand({data:new Uint8Array(0),isFirstChunk:!0,configurationType:r.NetworkConfigurationType.CONFIGURATION}).parseResponse(t);if((0,n.isSuccessCommandResult)(e))throw new Error("Expected an error");expect(e.error).toBeDefined(),expect(e.error).toBeInstanceOf(s.EthAppCommandError)}),it("should return a success result if the response status code is valid",()=>{const t={data:Uint8Array.from([]),statusCode:Uint8Array.from([144,0])},e=new r.ProvideNetworkConfigurationCommand({data:new Uint8Array(0),isFirstChunk:!0,configurationType:r.NetworkConfigurationType.CONFIGURATION}).parseResponse(t);if((0,n.isSuccessCommandResult)(e))expect(e.data).toBeUndefined();else throw new Error("Expected a success result")})})});
2
+ //# sourceMappingURL=ProvideNetworkConfigurationCommand.test.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/internal/app-binder/command/ProvideNetworkConfigurationCommand.test.ts"],
4
+ "sourcesContent": ["import {\n type ApduResponse,\n isSuccessCommandResult,\n} from \"@ledgerhq/device-management-kit\";\n\nimport { EthAppCommandError } from \"./utils/ethAppErrors\";\nimport {\n NetworkConfigurationType,\n ProvideNetworkConfigurationCommand,\n type ProvideNetworkConfigurationCommandArgs,\n} from \"./ProvideNetworkConfigurationCommand\";\n\ndescribe(\"ProvideNetworkConfigurationCommand\", () => {\n describe(\"getApdu\", () => {\n it(\"should return the raw APDU for the first chunk\", () => {\n // GIVEN\n const args: ProvideNetworkConfigurationCommandArgs = {\n data: Uint8Array.from([0x01, 0x02, 0x03]),\n isFirstChunk: true,\n configurationType: NetworkConfigurationType.CONFIGURATION,\n };\n\n // WHEN\n const command = new ProvideNetworkConfigurationCommand(args);\n const apdu = command.getApdu();\n\n // THEN\n expect(apdu.getRawApdu()).toStrictEqual(\n Uint8Array.from([0xe0, 0x30, 0x01, 0x00, 0x03, 0x01, 0x02, 0x03]),\n );\n });\n\n it(\"should return the raw APDU for the subsequent chunk\", () => {\n // GIVEN\n const args: ProvideNetworkConfigurationCommandArgs = {\n data: Uint8Array.from([0x04, 0x05, 0x06]),\n isFirstChunk: false,\n configurationType: NetworkConfigurationType.CONFIGURATION,\n };\n\n // WHEN\n const command = new ProvideNetworkConfigurationCommand(args);\n const apdu = command.getApdu();\n\n // THEN\n expect(apdu.getRawApdu()).toStrictEqual(\n Uint8Array.from([0xe0, 0x30, 0x00, 0x00, 0x03, 0x04, 0x05, 0x06]),\n );\n });\n });\n\n describe(\"parseResponse\", () => {\n it(\"should return an error if the response status code is invalid\", () => {\n // GIVEN\n const response: ApduResponse = {\n data: Uint8Array.from([]),\n statusCode: Uint8Array.from([0x6d, 0x00]), // Invalid status code\n };\n\n // WHEN\n const command = new ProvideNetworkConfigurationCommand({\n data: new Uint8Array(0),\n isFirstChunk: true,\n configurationType: NetworkConfigurationType.CONFIGURATION,\n });\n const result = command.parseResponse(response);\n\n // THEN\n if (isSuccessCommandResult(result)) {\n throw new Error(\"Expected an error\");\n } else {\n expect(result.error).toBeDefined();\n expect(result.error).toBeInstanceOf(EthAppCommandError);\n }\n });\n\n it(\"should return a success result if the response status code is valid\", () => {\n // GIVEN\n const response: ApduResponse = {\n data: Uint8Array.from([]),\n statusCode: Uint8Array.from([0x90, 0x00]), // Success status code\n };\n\n // WHEN\n const command = new ProvideNetworkConfigurationCommand({\n data: new Uint8Array(0),\n isFirstChunk: true,\n configurationType: NetworkConfigurationType.CONFIGURATION,\n });\n const result = command.parseResponse(response);\n\n // THEN\n if (!isSuccessCommandResult(result)) {\n throw new Error(\"Expected a success result\");\n } else {\n expect(result.data).toBeUndefined();\n }\n });\n });\n});\n"],
5
+ "mappings": "aAAA,IAAAA,EAGO,2CAEPC,EAAmC,gCACnCC,EAIO,gDAEP,SAAS,qCAAsC,IAAM,CACnD,SAAS,UAAW,IAAM,CACxB,GAAG,iDAAkD,IAAM,CAEzD,MAAMC,EAA+C,CACnD,KAAM,WAAW,KAAK,CAAC,EAAM,EAAM,CAAI,CAAC,EACxC,aAAc,GACd,kBAAmB,2BAAyB,aAC9C,EAIMC,EADU,IAAI,qCAAmCD,CAAI,EACtC,QAAQ,EAG7B,OAAOC,EAAK,WAAW,CAAC,EAAE,cACxB,WAAW,KAAK,CAAC,IAAM,GAAM,EAAM,EAAM,EAAM,EAAM,EAAM,CAAI,CAAC,CAClE,CACF,CAAC,EAED,GAAG,sDAAuD,IAAM,CAE9D,MAAMD,EAA+C,CACnD,KAAM,WAAW,KAAK,CAAC,EAAM,EAAM,CAAI,CAAC,EACxC,aAAc,GACd,kBAAmB,2BAAyB,aAC9C,EAIMC,EADU,IAAI,qCAAmCD,CAAI,EACtC,QAAQ,EAG7B,OAAOC,EAAK,WAAW,CAAC,EAAE,cACxB,WAAW,KAAK,CAAC,IAAM,GAAM,EAAM,EAAM,EAAM,EAAM,EAAM,CAAI,CAAC,CAClE,CACF,CAAC,CACH,CAAC,EAED,SAAS,gBAAiB,IAAM,CAC9B,GAAG,gEAAiE,IAAM,CAExE,MAAMC,EAAyB,CAC7B,KAAM,WAAW,KAAK,CAAC,CAAC,EACxB,WAAY,WAAW,KAAK,CAAC,IAAM,CAAI,CAAC,CAC1C,EAQMC,EALU,IAAI,qCAAmC,CACrD,KAAM,IAAI,WAAW,CAAC,EACtB,aAAc,GACd,kBAAmB,2BAAyB,aAC9C,CAAC,EACsB,cAAcD,CAAQ,EAG7C,MAAI,0BAAuBC,CAAM,EAC/B,MAAM,IAAI,MAAM,mBAAmB,EAEnC,OAAOA,EAAO,KAAK,EAAE,YAAY,EACjC,OAAOA,EAAO,KAAK,EAAE,eAAe,oBAAkB,CAE1D,CAAC,EAED,GAAG,sEAAuE,IAAM,CAE9E,MAAMD,EAAyB,CAC7B,KAAM,WAAW,KAAK,CAAC,CAAC,EACxB,WAAY,WAAW,KAAK,CAAC,IAAM,CAAI,CAAC,CAC1C,EAQMC,EALU,IAAI,qCAAmC,CACrD,KAAM,IAAI,WAAW,CAAC,EACtB,aAAc,GACd,kBAAmB,2BAAyB,aAC9C,CAAC,EACsB,cAAcD,CAAQ,EAG7C,MAAK,0BAAuBC,CAAM,EAGhC,OAAOA,EAAO,IAAI,EAAE,cAAc,MAFlC,OAAM,IAAI,MAAM,2BAA2B,CAI/C,CAAC,CACH,CAAC,CACH,CAAC",
6
+ "names": ["import_device_management_kit", "import_ethAppErrors", "import_ProvideNetworkConfigurationCommand", "args", "apdu", "response", "result"]
7
+ }
@@ -1,2 +1,2 @@
1
- "use strict";var y=Object.defineProperty;var k=Object.getOwnPropertyDescriptor;var O=Object.getOwnPropertyNames;var R=Object.prototype.hasOwnProperty;var _=(a,e)=>{for(var n in e)y(a,n,{get:e[n],enumerable:!0})},v=(a,e,n,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of O(e))!R.call(a,i)&&i!==n&&y(a,i,{get:()=>e[i],enumerable:!(s=k(e,i))||s.enumerable});return a};var b=a=>v(y({},"__esModule",{value:!0}),a);var w={};_(w,{BuildTransactionContextTask:()=>M});module.exports=b(w);var o=require("@ledgerhq/context-module"),c=require("@ledgerhq/device-management-kit"),u=require("../../../api/model/ClearSigningType"),A=require("../../app-binder/command/GetChallengeCommand"),I=require("../../app-binder/task/GetWeb3CheckTask"),N=require("../../shared/utils/ApplicationChecker");class M{constructor(e,n,s=(i,p)=>new I.GetWeb3CheckTask(i,p)){this._api=e;this._args=n;this.getWeb3ChecksFactory=s}async run(){const{contextModule:e,options:n,appConfig:s,derivationPath:i,transaction:p,subset:x}=this._args,d=this._api.getDeviceSessionState();let r=[],T=[],f=u.ClearSigningType.BASIC,l=null;s.web3ChecksEnabled&&(l=(await this.getWeb3ChecksFactory(this._api,{contextModule:e,derivationPath:i,subset:x,transaction:p}).run()).web3Check);let m;if(d.deviceModelId!==c.DeviceModelId.NANO_S){const t=await this._api.sendCommand(new A.GetChallengeCommand);(0,c.isSuccessCommandResult)(t)&&(m=t.data.challenge)}const h=await e.getContexts({challenge:m,domain:n.domain,deviceModelId:d.deviceModelId,...x}),C=h.filter(t=>t.type!==o.ClearSignContextType.ERROR&&t.type!==o.ClearSignContextType.ENUM),E=h.filter(t=>t.type===o.ClearSignContextType.ENUM),S=C.find(t=>t.type===o.ClearSignContextType.TRANSACTION_INFO);if(!this.supportsGenericParser(d,s)||S===void 0)r=C.filter(t=>t.type!==o.ClearSignContextType.TRANSACTION_INFO&&t.type!==o.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION),l&&(r=[l,...r]);else if(S.certificate){const t=C.filter(g=>g.type===o.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION);r=[...C.filter(g=>g.type===o.ClearSignContextType.PROXY_DELEGATE_CALL),S,...t,...l?[l]:[]],T=[...E],f=u.ClearSigningType.EIP7730}return{clearSignContexts:r,clearSignContextsOptional:T,clearSigningType:f}}supportsGenericParser(e,n){return new N.ApplicationChecker(e,n).withMinVersionExclusive("1.14.0").excludeDeviceModel(c.DeviceModelId.NANO_S).check()}}0&&(module.exports={BuildTransactionContextTask});
1
+ "use strict";var y=Object.defineProperty;var O=Object.getOwnPropertyDescriptor;var _=Object.getOwnPropertyNames;var R=Object.prototype.hasOwnProperty;var v=(a,e)=>{for(var i in e)y(a,i,{get:e[i],enumerable:!0})},M=(a,e,i,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of _(e))!R.call(a,o)&&o!==i&&y(a,o,{get:()=>e[o],enumerable:!(s=O(e,o))||s.enumerable});return a};var b=a=>M(y({},"__esModule",{value:!0}),a);var D={};v(D,{BuildTransactionContextTask:()=>w});module.exports=b(D);var n=require("@ledgerhq/context-module"),p=require("@ledgerhq/device-management-kit"),u=require("../../../api/model/ClearSigningType"),I=require("../../app-binder/command/GetChallengeCommand"),h=require("../../app-binder/task/GetWeb3CheckTask"),A=require("../../shared/utils/ApplicationChecker");class w{constructor(e,i,s=(o,d)=>new h.GetWeb3CheckTask(o,d)){this._api=e;this._args=i;this.getWeb3ChecksFactory=s}async run(){const{contextModule:e,options:i,appConfig:s,derivationPath:o,transaction:d,subset:T}=this._args,S=this._api.getDeviceSessionState();let l=[],x=[],m=u.ClearSigningType.BASIC,c=null;s.web3ChecksEnabled&&(c=(await this.getWeb3ChecksFactory(this._api,{contextModule:e,derivationPath:o,subset:T,transaction:d}).run()).web3Check);let f;if(S.deviceModelId!==p.DeviceModelId.NANO_S){const t=await this._api.sendCommand(new I.GetChallengeCommand);(0,p.isSuccessCommandResult)(t)&&(f=t.data.challenge)}const N=await e.getContexts({challenge:f,domain:i.domain,deviceModelId:S.deviceModelId,...T}),C=N.filter(t=>t.type!==n.ClearSignContextType.ERROR&&t.type!==n.ClearSignContextType.ENUM),E=N.filter(t=>t.type===n.ClearSignContextType.ENUM),g=C.find(t=>t.type===n.ClearSignContextType.TRANSACTION_INFO);if(!this.supportsGenericParser(S,s)||g===void 0)l=C.filter(t=>t.type!==n.ClearSignContextType.TRANSACTION_INFO&&t.type!==n.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION),c&&(l=[c,...l]);else if(g.certificate){const t=C.filter(r=>r.type===n.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION),k=C.filter(r=>r.type===n.ClearSignContextType.PROXY_DELEGATE_CALL);l=[...C.filter(r=>r.type===n.ClearSignContextType.DYNAMIC_NETWORK||r.type===n.ClearSignContextType.DYNAMIC_NETWORK_ICON),...k,g,...t,...c?[c]:[]],x=[...E],m=u.ClearSigningType.EIP7730}return{clearSignContexts:l,clearSignContextsOptional:x,clearSigningType:m}}supportsGenericParser(e,i){return new A.ApplicationChecker(e,i).withMinVersionExclusive("1.14.0").excludeDeviceModel(p.DeviceModelId.NANO_S).check()}}0&&(module.exports={BuildTransactionContextTask});
2
2
  //# sourceMappingURL=BuildTransactionContextTask.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/internal/app-binder/task/BuildTransactionContextTask.ts"],
4
- "sourcesContent": ["import {\n type ClearSignContext,\n type ClearSignContextSuccess,\n type ClearSignContextSuccessType,\n ClearSignContextType,\n type ContextModule,\n type TransactionSubset,\n} from \"@ledgerhq/context-module\";\nimport {\n DeviceModelId,\n type DeviceSessionState,\n type InternalApi,\n isSuccessCommandResult,\n} from \"@ledgerhq/device-management-kit\";\n\nimport { type GetConfigCommandResponse } from \"@api/app-binder/GetConfigCommandTypes\";\nimport { ClearSigningType } from \"@api/model/ClearSigningType\";\nimport { type TransactionOptions } from \"@api/model/TransactionOptions\";\nimport { GetChallengeCommand } from \"@internal/app-binder/command/GetChallengeCommand\";\nimport {\n GetWeb3CheckTask,\n type GetWeb3CheckTaskArgs,\n} from \"@internal/app-binder/task/GetWeb3CheckTask\";\nimport { ApplicationChecker } from \"@internal/shared/utils/ApplicationChecker\";\n\nexport type BuildTransactionTaskResult = {\n readonly clearSignContexts: ClearSignContextSuccess[];\n readonly clearSignContextsOptional: ClearSignContextSuccess[];\n readonly clearSigningType: ClearSigningType;\n};\n\nexport type BuildTransactionContextTaskArgs = {\n readonly contextModule: ContextModule;\n readonly options: TransactionOptions;\n readonly appConfig: GetConfigCommandResponse;\n readonly derivationPath: string;\n readonly transaction: Uint8Array;\n readonly subset: TransactionSubset;\n};\n\nexport class BuildTransactionContextTask {\n constructor(\n private readonly _api: InternalApi,\n private readonly _args: BuildTransactionContextTaskArgs,\n private readonly getWeb3ChecksFactory = (\n api: InternalApi,\n args: GetWeb3CheckTaskArgs,\n ) => new GetWeb3CheckTask(api, args),\n ) {}\n\n async run(): Promise<BuildTransactionTaskResult> {\n const {\n contextModule,\n options,\n appConfig,\n derivationPath,\n transaction,\n subset,\n } = this._args;\n const deviceState = this._api.getDeviceSessionState();\n let filteredContexts: ClearSignContextSuccess[] = [];\n let filteredContextOptional: ClearSignContextSuccess[] = [];\n let clearSigningType: ClearSigningType = ClearSigningType.BASIC;\n\n // Run the web3checks if needed\n let web3Check: ClearSignContextSuccess<ClearSignContextType.WEB3_CHECK> | null =\n null;\n if (appConfig.web3ChecksEnabled) {\n web3Check = (\n await this.getWeb3ChecksFactory(this._api, {\n contextModule,\n derivationPath,\n subset,\n transaction,\n }).run()\n ).web3Check;\n }\n\n // Get challenge (not supported on Nano S)\n let challenge: string | undefined = undefined;\n if (deviceState.deviceModelId !== DeviceModelId.NANO_S) {\n const challengeRes = await this._api.sendCommand(\n new GetChallengeCommand(),\n );\n if (isSuccessCommandResult(challengeRes)) {\n challenge = challengeRes.data.challenge;\n }\n }\n\n // Get the clear sign contexts\n const clearSignContexts: ClearSignContext[] =\n await contextModule.getContexts({\n challenge: challenge,\n domain: options.domain,\n deviceModelId: deviceState.deviceModelId,\n ...subset,\n });\n\n // NOTE: we need to filter out the ENUM and ERROR types\n // ENUM are handled differently\n // ERROR are not handled at all for now\n const clearSignContextsSuccess: ClearSignContextSuccess<\n Exclude<ClearSignContextSuccessType, ClearSignContextType.ENUM>\n >[] = clearSignContexts.filter(\n (context) =>\n context.type !== ClearSignContextType.ERROR &&\n context.type !== ClearSignContextType.ENUM,\n );\n\n // Retrieve all ENUM contexts\n const transactionEnums: ClearSignContextSuccess<ClearSignContextType.ENUM>[] =\n clearSignContexts.filter(\n (context) => context.type === ClearSignContextType.ENUM,\n );\n\n const transactionInfo = clearSignContextsSuccess.find(\n (ctx) => ctx.type === ClearSignContextType.TRANSACTION_INFO,\n );\n\n // If the device does not support the generic parser,\n // we need to filter out the transaction info and transaction field description\n // as they are not supported by the device\n if (\n !this.supportsGenericParser(deviceState, appConfig) ||\n transactionInfo === undefined\n ) {\n filteredContexts = clearSignContextsSuccess.filter(\n (ctx) =>\n ctx.type !== ClearSignContextType.TRANSACTION_INFO &&\n ctx.type !== ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n );\n\n // If the device supports the web3 check, we need to add it to the list of contexts\n if (web3Check) {\n filteredContexts = [web3Check, ...filteredContexts];\n }\n } else if (transactionInfo.certificate) {\n const transactionFields = clearSignContextsSuccess.filter(\n (ctx) =>\n ctx.type === ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n );\n const proxyContexts = clearSignContextsSuccess.filter(\n (ctx) => ctx.type === ClearSignContextType.PROXY_DELEGATE_CALL,\n );\n\n filteredContexts = [\n ...proxyContexts,\n transactionInfo,\n ...transactionFields,\n ...(web3Check ? [web3Check] : []),\n ];\n filteredContextOptional = [...transactionEnums];\n clearSigningType = ClearSigningType.EIP7730;\n }\n\n return {\n clearSignContexts: filteredContexts,\n clearSignContextsOptional: filteredContextOptional,\n clearSigningType,\n };\n }\n\n private supportsGenericParser(\n deviceState: DeviceSessionState,\n appConfig: GetConfigCommandResponse,\n ): boolean {\n return new ApplicationChecker(deviceState, appConfig)\n .withMinVersionExclusive(\"1.14.0\")\n .excludeDeviceModel(DeviceModelId.NANO_S)\n .check();\n }\n}\n"],
5
- "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,iCAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAOO,oCACPC,EAKO,2CAGPC,EAAiC,uCAEjCC,EAAoC,4DACpCC,EAGO,sDACPC,EAAmC,qDAiB5B,MAAMP,CAA4B,CACvC,YACmBQ,EACAC,EACAC,EAAuB,CACtCC,EACAC,IACG,IAAI,mBAAiBD,EAAKC,CAAI,EACnC,CANiB,UAAAJ,EACA,WAAAC,EACA,0BAAAC,CAIhB,CAEH,MAAM,KAA2C,CAC/C,KAAM,CACJ,cAAAG,EACA,QAAAC,EACA,UAAAC,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,CAAC,CACjC,EACAF,EAA0B,CAAC,GAAGQ,CAAgB,EAC9CP,EAAmB,mBAAiB,OACtC,CAEA,MAAO,CACL,kBAAmBF,EACnB,0BAA2BC,EAC3B,iBAAAC,CACF,CACF,CAEQ,sBACNH,EACAJ,EACS,CACT,OAAO,IAAI,qBAAmBI,EAAaJ,CAAS,EACjD,wBAAwB,QAAQ,EAChC,mBAAmB,gBAAc,MAAM,EACvC,MAAM,CACX,CACF",
6
- "names": ["BuildTransactionContextTask_exports", "__export", "BuildTransactionContextTask", "__toCommonJS", "import_context_module", "import_device_management_kit", "import_ClearSigningType", "import_GetChallengeCommand", "import_GetWeb3CheckTask", "import_ApplicationChecker", "_api", "_args", "getWeb3ChecksFactory", "api", "args", "contextModule", "options", "appConfig", "derivationPath", "transaction", "subset", "deviceState", "filteredContexts", "filteredContextOptional", "clearSigningType", "web3Check", "challenge", "challengeRes", "clearSignContexts", "clearSignContextsSuccess", "context", "transactionEnums", "transactionInfo", "ctx", "transactionFields"]
4
+ "sourcesContent": ["import {\n type ClearSignContext,\n type ClearSignContextSuccess,\n type ClearSignContextSuccessType,\n ClearSignContextType,\n type ContextModule,\n type TransactionSubset,\n} from \"@ledgerhq/context-module\";\nimport {\n DeviceModelId,\n type DeviceSessionState,\n type InternalApi,\n isSuccessCommandResult,\n} from \"@ledgerhq/device-management-kit\";\n\nimport { type GetConfigCommandResponse } from \"@api/app-binder/GetConfigCommandTypes\";\nimport { ClearSigningType } from \"@api/model/ClearSigningType\";\nimport { type TransactionOptions } from \"@api/model/TransactionOptions\";\nimport { GetChallengeCommand } from \"@internal/app-binder/command/GetChallengeCommand\";\nimport {\n GetWeb3CheckTask,\n type GetWeb3CheckTaskArgs,\n} from \"@internal/app-binder/task/GetWeb3CheckTask\";\nimport { ApplicationChecker } from \"@internal/shared/utils/ApplicationChecker\";\n\nexport type BuildTransactionTaskResult = {\n readonly clearSignContexts: ClearSignContextSuccess[];\n readonly clearSignContextsOptional: ClearSignContextSuccess[];\n readonly clearSigningType: ClearSigningType;\n};\n\nexport type BuildTransactionContextTaskArgs = {\n readonly contextModule: ContextModule;\n readonly options: TransactionOptions;\n readonly appConfig: GetConfigCommandResponse;\n readonly derivationPath: string;\n readonly transaction: Uint8Array;\n readonly subset: TransactionSubset;\n};\n\nexport class BuildTransactionContextTask {\n constructor(\n private readonly _api: InternalApi,\n private readonly _args: BuildTransactionContextTaskArgs,\n private readonly getWeb3ChecksFactory = (\n api: InternalApi,\n args: GetWeb3CheckTaskArgs,\n ) => new GetWeb3CheckTask(api, args),\n ) {}\n\n async run(): Promise<BuildTransactionTaskResult> {\n const {\n contextModule,\n options,\n appConfig,\n derivationPath,\n transaction,\n subset,\n } = this._args;\n const deviceState = this._api.getDeviceSessionState();\n let filteredContexts: ClearSignContextSuccess[] = [];\n let filteredContextOptional: ClearSignContextSuccess[] = [];\n let clearSigningType: ClearSigningType = ClearSigningType.BASIC;\n\n // Run the web3checks if needed\n let web3Check: ClearSignContextSuccess<ClearSignContextType.WEB3_CHECK> | null =\n null;\n if (appConfig.web3ChecksEnabled) {\n web3Check = (\n await this.getWeb3ChecksFactory(this._api, {\n contextModule,\n derivationPath,\n subset,\n transaction,\n }).run()\n ).web3Check;\n }\n\n // Get challenge (not supported on Nano S)\n let challenge: string | undefined = undefined;\n if (deviceState.deviceModelId !== DeviceModelId.NANO_S) {\n const challengeRes = await this._api.sendCommand(\n new GetChallengeCommand(),\n );\n if (isSuccessCommandResult(challengeRes)) {\n challenge = challengeRes.data.challenge;\n }\n }\n\n // Get the clear sign contexts\n const clearSignContexts: ClearSignContext[] =\n await contextModule.getContexts({\n challenge: challenge,\n domain: options.domain,\n deviceModelId: deviceState.deviceModelId,\n ...subset,\n });\n\n // NOTE: we need to filter out the ENUM and ERROR types\n // ENUM are handled differently\n // ERROR are not handled at all for now\n const clearSignContextsSuccess: ClearSignContextSuccess<\n Exclude<ClearSignContextSuccessType, ClearSignContextType.ENUM>\n >[] = clearSignContexts.filter(\n (context) =>\n context.type !== ClearSignContextType.ERROR &&\n context.type !== ClearSignContextType.ENUM,\n );\n\n // Retrieve all ENUM contexts\n const transactionEnums: ClearSignContextSuccess<ClearSignContextType.ENUM>[] =\n clearSignContexts.filter(\n (context) => context.type === ClearSignContextType.ENUM,\n );\n\n const transactionInfo = clearSignContextsSuccess.find(\n (ctx) => ctx.type === ClearSignContextType.TRANSACTION_INFO,\n );\n\n // If the device does not support the generic parser,\n // we need to filter out the transaction info and transaction field description\n // as they are not supported by the device\n if (\n !this.supportsGenericParser(deviceState, appConfig) ||\n transactionInfo === undefined\n ) {\n filteredContexts = clearSignContextsSuccess.filter(\n (ctx) =>\n ctx.type !== ClearSignContextType.TRANSACTION_INFO &&\n ctx.type !== ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n );\n\n // If the device supports the web3 check, we need to add it to the list of contexts\n if (web3Check) {\n filteredContexts = [web3Check, ...filteredContexts];\n }\n } else if (transactionInfo.certificate) {\n const transactionFields = clearSignContextsSuccess.filter(\n (ctx) =>\n ctx.type === ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n );\n const proxyContexts = clearSignContextsSuccess.filter(\n (ctx) => ctx.type === ClearSignContextType.PROXY_DELEGATE_CALL,\n );\n const dynamicNetworkContexts = clearSignContextsSuccess.filter(\n (ctx) =>\n ctx.type === ClearSignContextType.DYNAMIC_NETWORK ||\n ctx.type === ClearSignContextType.DYNAMIC_NETWORK_ICON,\n );\n\n filteredContexts = [\n ...dynamicNetworkContexts,\n ...proxyContexts,\n transactionInfo,\n ...transactionFields,\n ...(web3Check ? [web3Check] : []),\n ];\n filteredContextOptional = [...transactionEnums];\n clearSigningType = ClearSigningType.EIP7730;\n }\n\n return {\n clearSignContexts: filteredContexts,\n clearSignContextsOptional: filteredContextOptional,\n clearSigningType,\n };\n }\n\n private supportsGenericParser(\n deviceState: DeviceSessionState,\n appConfig: GetConfigCommandResponse,\n ): boolean {\n return new ApplicationChecker(deviceState, appConfig)\n .withMinVersionExclusive(\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I,GAAQA,EAAI,OAAS,uBAAqB,gBAC7C,EAKA,GACE,CAAC,KAAK,sBAAsBZ,EAAaJ,CAAS,GAClDe,IAAoB,OAEpBV,EAAmBO,EAAyB,OACzCI,GACCA,EAAI,OAAS,uBAAqB,kBAClCA,EAAI,OAAS,uBAAqB,6BACtC,EAGIR,IACFH,EAAmB,CAACG,EAAW,GAAGH,CAAgB,WAE3CU,EAAgB,YAAa,CACtC,MAAME,EAAoBL,EAAyB,OAChDI,GACCA,EAAI,OAAS,uBAAqB,6BACtC,EACME,EAAgBN,EAAyB,OAC5CI,GAAQA,EAAI,OAAS,uBAAqB,mBAC7C,EAOAX,EAAmB,CACjB,GAP6BO,EAAyB,OACrDI,GACCA,EAAI,OAAS,uBAAqB,iBAClCA,EAAI,OAAS,uBAAqB,oBACtC,EAIE,GAAGE,EACHH,EACA,GAAGE,EACH,GAAIT,EAAY,CAACA,CAAS,EAAI,CAAC,CACjC,EACAF,EAA0B,CAAC,GAAGQ,CAAgB,EAC9CP,EAAmB,mBAAiB,OACtC,CAEA,MAAO,CACL,kBAAmBF,EACnB,0BAA2BC,EAC3B,iBAAAC,CACF,CACF,CAEQ,sBACNH,EACAJ,EACS,CACT,OAAO,IAAI,qBAAmBI,EAAaJ,CAAS,EACjD,wBAAwB,QAAQ,EAChC,mBAAmB,gBAAc,MAAM,EACvC,MAAM,CACX,CACF",
6
+ "names": ["BuildTransactionContextTask_exports", "__export", "BuildTransactionContextTask", "__toCommonJS", "import_context_module", "import_device_management_kit", "import_ClearSigningType", "import_GetChallengeCommand", "import_GetWeb3CheckTask", "import_ApplicationChecker", "_api", "_args", "getWeb3ChecksFactory", "api", "args", "contextModule", "options", "appConfig", "derivationPath", "transaction", "subset", "deviceState", "filteredContexts", "filteredContextOptional", "clearSigningType", "web3Check", "challenge", "challengeRes", "clearSignContexts", "clearSignContextsSuccess", "context", "transactionEnums", "transactionInfo", "ctx", "transactionFields", "proxyContexts"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var u=Object.defineProperty;var v=Object.getOwnPropertyDescriptor;var S=Object.getOwnPropertyNames;var x=Object.prototype.hasOwnProperty;var A=(s,a)=>{for(var t in a)u(s,t,{get:a[t],enumerable:!0})},g=(s,a,t,e)=>{if(a&&typeof a=="object"||typeof a=="function")for(let n of S(a))!x.call(s,n)&&n!==t&&u(s,n,{get:()=>a[n],enumerable:!(e=v(a,n))||e.enumerable});return s};var R=s=>g(u({},"__esModule",{value:!0}),s);var N={};A(N,{ProvideTransactionContextTask:()=>D});module.exports=R(N);var r=require("@ledgerhq/context-module"),o=require("@ledgerhq/device-management-kit"),C=require("@ledgerhq/signer-utils"),m=require("purify-ts"),h=require("../../app-binder/command/ProvideEnumCommand"),k=require("../../app-binder/command/ProvideNFTInformationCommand"),p=require("../../app-binder/command/ProvideProxyInfoCommand"),T=require("../../app-binder/command/ProvideTokenInformationCommand"),l=require("../../app-binder/command/ProvideTransactionFieldDescriptionCommand"),y=require("../../app-binder/command/ProvideTransactionInformationCommand"),F=require("../../app-binder/command/ProvideTrustedNameCommand"),I=require("../../app-binder/command/ProvideWeb3CheckCommand"),_=require("../../app-binder/command/SetExternalPluginCommand"),f=require("../../app-binder/command/SetPluginCommand"),P=require("../../app-binder/command/StoreTransactionCommand"),w=require("./SendCommandInChunksTask"),E=require("./SendPayloadInChunksTask");class D{constructor(a,t,e=(i,c)=>new E.SendPayloadInChunksTask(i,c),n=(i,c)=>new w.SendCommandInChunksTask(i,c)){this._api=a;this._args=t;this._sendPayloadInChunksTaskFactory=e;this._sendCommandInChunksTaskFactory=n}async run(){for(const t of this._args.subcontextsCallbacks){const e=await t();if(e.type===r.ClearSignContextType.ERROR)continue;const n=await this.provideContext(e);if(!(0,o.isSuccessCommandResult)(n))return(0,m.Left)(n)}const a=await this.provideContext(this._args.context);return(0,o.isSuccessCommandResult)(a)?(0,m.Right)(void 0):(0,m.Left)(a)}async provideContext({type:a,payload:t,certificate:e}){switch(e&&await this._api.sendCommand(new o.LoadCertificateCommand({keyUsage:e.keyUsageNumber,certificate:e.payload})),a){case r.ClearSignContextType.PLUGIN:return await this._api.sendCommand(new f.SetPluginCommand({payload:t}));case r.ClearSignContextType.EXTERNAL_PLUGIN:return await this._api.sendCommand(new _.SetExternalPluginCommand({payload:t}));case r.ClearSignContextType.NFT:return await this._api.sendCommand(new k.ProvideNFTInformationCommand({payload:t}));case r.ClearSignContextType.TOKEN:return await this._api.sendCommand(new T.ProvideTokenInformationCommand({payload:t}));case r.ClearSignContextType.TRANSACTION_INFO:{const n=C.DerivationPathUtils.splitPath(this._args.derivationPath),i=new o.ByteArrayBuilder;return i.add8BitUIntToData(n.length),n.forEach(d=>{i.add32BitUIntToData(d)}),i.addBufferToData(this._args.serializedTransaction),await this._sendCommandInChunksTaskFactory(this._api,{data:i.build(),commandFactory:d=>new P.StoreTransactionCommand({serializedTransaction:d.chunkedData,isFirstChunk:d.isFirstChunk})}).run(),await this._sendPayloadInChunksTaskFactory(this._api,{payload:this._args.context.payload,commandFactory:d=>new y.ProvideTransactionInformationCommand({data:d.chunkedData,isFirstChunk:d.isFirstChunk})}).run()}case r.ClearSignContextType.TRUSTED_NAME:return this._sendPayloadInChunksTaskFactory(this._api,{payload:t,commandFactory:n=>new F.ProvideTrustedNameCommand({data:n.chunkedData,isFirstChunk:n.isFirstChunk})}).run();case r.ClearSignContextType.ENUM:return this._sendPayloadInChunksTaskFactory(this._api,{payload:t,commandFactory:n=>new h.ProvideEnumCommand({data:n.chunkedData,isFirstChunk:n.isFirstChunk})}).run();case r.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION:return this._sendPayloadInChunksTaskFactory(this._api,{payload:t,commandFactory:n=>new l.ProvideTransactionFieldDescriptionCommand({data:n.chunkedData,isFirstChunk:n.isFirstChunk})}).run();case r.ClearSignContextType.WEB3_CHECK:return this._sendPayloadInChunksTaskFactory(this._api,{payload:t,commandFactory:n=>new I.ProvideWeb3CheckCommand({payload:n.chunkedData,isFirstChunk:n.isFirstChunk})}).run();case r.ClearSignContextType.PROXY_DELEGATE_CALL:return this._sendPayloadInChunksTaskFactory(this._api,{payload:t,commandFactory:n=>new p.ProvideProxyInfoCommand({data:n.chunkedData,isFirstChunk:n.isFirstChunk})}).run();default:{const n=a;return(0,o.CommandResultFactory)({error:new o.InvalidStatusWordError(`The context type [${n}] is not covered`)})}}}}0&&(module.exports={ProvideTransactionContextTask});
1
+ "use strict";var C=Object.defineProperty;var N=Object.getOwnPropertyDescriptor;var S=Object.getOwnPropertyNames;var x=Object.prototype.hasOwnProperty;var A=(i,a)=>{for(var t in a)C(i,t,{get:a[t],enumerable:!0})},g=(i,a,t,e)=>{if(a&&typeof a=="object"||typeof a=="function")for(let n of S(a))!x.call(i,n)&&n!==t&&C(i,n,{get:()=>a[n],enumerable:!(e=N(a,n))||e.enumerable});return i};var R=i=>g(C({},"__esModule",{value:!0}),i);var O={};A(O,{ProvideTransactionContextTask:()=>D});module.exports=R(O);var r=require("@ledgerhq/context-module"),o=require("@ledgerhq/device-management-kit"),h=require("@ledgerhq/signer-utils"),u=require("purify-ts"),k=require("../../app-binder/command/ProvideEnumCommand"),m=require("../../app-binder/command/ProvideNetworkConfigurationCommand"),p=require("../../app-binder/command/ProvideNFTInformationCommand"),T=require("../../app-binder/command/ProvideProxyInfoCommand"),y=require("../../app-binder/command/ProvideTokenInformationCommand"),l=require("../../app-binder/command/ProvideTransactionFieldDescriptionCommand"),F=require("../../app-binder/command/ProvideTransactionInformationCommand"),I=require("../../app-binder/command/ProvideTrustedNameCommand"),_=require("../../app-binder/command/ProvideWeb3CheckCommand"),f=require("../../app-binder/command/SetExternalPluginCommand"),P=require("../../app-binder/command/SetPluginCommand"),w=require("../../app-binder/command/StoreTransactionCommand"),E=require("./SendCommandInChunksTask"),v=require("./SendPayloadInChunksTask");class D{constructor(a,t,e=(s,c)=>new v.SendPayloadInChunksTask(s,c),n=(s,c)=>new E.SendCommandInChunksTask(s,c)){this._api=a;this._args=t;this._sendPayloadInChunksTaskFactory=e;this._sendCommandInChunksTaskFactory=n}async run(){for(const t of this._args.subcontextsCallbacks){const e=await t();if(e.type===r.ClearSignContextType.ERROR)continue;const n=await this.provideContext(e);if(!(0,o.isSuccessCommandResult)(n))return(0,u.Left)(n)}const a=await this.provideContext(this._args.context);return(0,o.isSuccessCommandResult)(a)?(0,u.Right)(void 0):(0,u.Left)(a)}async provideContext({type:a,payload:t,certificate:e}){switch(e&&await this._api.sendCommand(new o.LoadCertificateCommand({keyUsage:e.keyUsageNumber,certificate:e.payload})),a){case r.ClearSignContextType.PLUGIN:return await this._api.sendCommand(new P.SetPluginCommand({payload:t}));case r.ClearSignContextType.EXTERNAL_PLUGIN:return await this._api.sendCommand(new f.SetExternalPluginCommand({payload:t}));case r.ClearSignContextType.NFT:return await this._api.sendCommand(new p.ProvideNFTInformationCommand({payload:t}));case r.ClearSignContextType.TOKEN:return await this._api.sendCommand(new y.ProvideTokenInformationCommand({payload:t}));case r.ClearSignContextType.TRANSACTION_INFO:{const n=h.DerivationPathUtils.splitPath(this._args.derivationPath),s=new o.ByteArrayBuilder;return s.add8BitUIntToData(n.length),n.forEach(d=>{s.add32BitUIntToData(d)}),s.addBufferToData(this._args.serializedTransaction),await this._sendCommandInChunksTaskFactory(this._api,{data:s.build(),commandFactory:d=>new w.StoreTransactionCommand({serializedTransaction:d.chunkedData,isFirstChunk:d.isFirstChunk})}).run(),await this._sendPayloadInChunksTaskFactory(this._api,{payload:this._args.context.payload,commandFactory:d=>new F.ProvideTransactionInformationCommand({data:d.chunkedData,isFirstChunk:d.isFirstChunk})}).run()}case r.ClearSignContextType.TRUSTED_NAME:return this._sendPayloadInChunksTaskFactory(this._api,{payload:t,commandFactory:n=>new I.ProvideTrustedNameCommand({data:n.chunkedData,isFirstChunk:n.isFirstChunk})}).run();case r.ClearSignContextType.ENUM:return this._sendPayloadInChunksTaskFactory(this._api,{payload:t,commandFactory:n=>new k.ProvideEnumCommand({data:n.chunkedData,isFirstChunk:n.isFirstChunk})}).run();case r.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION:return this._sendPayloadInChunksTaskFactory(this._api,{payload:t,commandFactory:n=>new l.ProvideTransactionFieldDescriptionCommand({data:n.chunkedData,isFirstChunk:n.isFirstChunk})}).run();case r.ClearSignContextType.WEB3_CHECK:return this._sendPayloadInChunksTaskFactory(this._api,{payload:t,commandFactory:n=>new _.ProvideWeb3CheckCommand({payload:n.chunkedData,isFirstChunk:n.isFirstChunk})}).run();case r.ClearSignContextType.PROXY_DELEGATE_CALL:return this._sendPayloadInChunksTaskFactory(this._api,{payload:t,commandFactory:n=>new T.ProvideProxyInfoCommand({data:n.chunkedData,isFirstChunk:n.isFirstChunk})}).run();case r.ClearSignContextType.DYNAMIC_NETWORK:return this._sendPayloadInChunksTaskFactory(this._api,{payload:t,commandFactory:n=>new m.ProvideNetworkConfigurationCommand({data:n.chunkedData,isFirstChunk:n.isFirstChunk,configurationType:m.NetworkConfigurationType.CONFIGURATION})}).run();case r.ClearSignContextType.DYNAMIC_NETWORK_ICON:return this._sendPayloadInChunksTaskFactory(this._api,{payload:t,commandFactory:n=>new m.ProvideNetworkConfigurationCommand({data:n.chunkedData,isFirstChunk:n.isFirstChunk,configurationType:m.NetworkConfigurationType.ICON}),withPayloadLength:!1}).run();default:{const n=a;return(0,o.CommandResultFactory)({error:new o.InvalidStatusWordError(`The context type [${n}] is not covered`)})}}}}0&&(module.exports={ProvideTransactionContextTask});
2
2
  //# sourceMappingURL=ProvideTransactionContextTask.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/internal/app-binder/task/ProvideTransactionContextTask.ts"],
4
- "sourcesContent": ["import {\n type ClearSignContext,\n type ClearSignContextSuccess,\n ClearSignContextType,\n} from \"@ledgerhq/context-module\";\nimport {\n ByteArrayBuilder,\n type CommandErrorResult,\n type CommandResult,\n CommandResultFactory,\n type InternalApi,\n InvalidStatusWordError,\n isSuccessCommandResult,\n LoadCertificateCommand,\n} from \"@ledgerhq/device-management-kit\";\nimport { DerivationPathUtils } from \"@ledgerhq/signer-utils\";\nimport { type Either, Left, Right } from \"purify-ts\";\n\nimport { ProvideEnumCommand } from \"@internal/app-binder/command/ProvideEnumCommand\";\nimport { ProvideNFTInformationCommand } from \"@internal/app-binder/command/ProvideNFTInformationCommand\";\nimport { ProvideProxyInfoCommand } from \"@internal/app-binder/command/ProvideProxyInfoCommand\";\nimport { ProvideTokenInformationCommand } from \"@internal/app-binder/command/ProvideTokenInformationCommand\";\nimport { ProvideTransactionFieldDescriptionCommand } from \"@internal/app-binder/command/ProvideTransactionFieldDescriptionCommand\";\nimport { ProvideTransactionInformationCommand } from \"@internal/app-binder/command/ProvideTransactionInformationCommand\";\nimport { ProvideTrustedNameCommand } from \"@internal/app-binder/command/ProvideTrustedNameCommand\";\nimport { ProvideWeb3CheckCommand } from \"@internal/app-binder/command/ProvideWeb3CheckCommand\";\nimport { SetExternalPluginCommand } from \"@internal/app-binder/command/SetExternalPluginCommand\";\nimport { SetPluginCommand } from \"@internal/app-binder/command/SetPluginCommand\";\nimport { StoreTransactionCommand } from \"@internal/app-binder/command/StoreTransactionCommand\";\nimport { type EthErrorCodes } from \"@internal/app-binder/command/utils/ethAppErrors\";\n\nimport {\n SendCommandInChunksTask,\n type SendCommandInChunksTaskArgs,\n} from \"./SendCommandInChunksTask\";\nimport {\n SendPayloadInChunksTask,\n type SendPayloadInChunksTaskArgs,\n} from \"./SendPayloadInChunksTask\";\n\nexport type ProvideTransactionContextTaskArgs = {\n /**\n * The clear sign context to provide.\n */\n context: ClearSignContextSuccess;\n /**\n * The subcontexts callbacks to provide.\n */\n subcontextsCallbacks: (() => Promise<ClearSignContext>)[];\n /**\n * The serialized transaction to provide.\n */\n serializedTransaction: Uint8Array;\n /**\n * The derivation path to provide.\n */\n derivationPath: string;\n};\n\n/**\n * This task is responsible for providing the transaction context to the device.\n * It will send the subcontexts callbacks in order and finish with the context.\n */\nexport class ProvideTransactionContextTask {\n constructor(\n private _api: InternalApi,\n private _args: ProvideTransactionContextTaskArgs,\n private _sendPayloadInChunksTaskFactory = (\n api: InternalApi,\n args: SendPayloadInChunksTaskArgs<unknown>,\n ) => new SendPayloadInChunksTask(api, args),\n private _sendCommandInChunksTaskFactory = (\n api: InternalApi,\n args: SendCommandInChunksTaskArgs<unknown>,\n ) => new SendCommandInChunksTask(api, args),\n ) {}\n\n async run(): Promise<Either<CommandErrorResult<EthErrorCodes>, void>> {\n for (const callback of this._args.subcontextsCallbacks) {\n const subcontext = await callback();\n\n if (subcontext.type === ClearSignContextType.ERROR) {\n // silently ignore error subcontexts\n continue;\n }\n\n const res = await this.provideContext(subcontext);\n if (!isSuccessCommandResult(res)) {\n return Left(res);\n }\n }\n\n const res = await this.provideContext(this._args.context);\n if (!isSuccessCommandResult(res)) {\n return Left(res);\n }\n\n return Right(void 0);\n }\n\n /**\n * This method will send the context to the device.\n *\n * @param context The clear sign context to provide.\n * @returns A promise that resolves when the command is sent.\n */\n async provideContext({\n type,\n payload,\n certificate,\n }: ClearSignContextSuccess): Promise<CommandResult<unknown, EthErrorCodes>> {\n // if a certificate is provided, we load it before sending the command\n if (certificate) {\n await this._api.sendCommand(\n new LoadCertificateCommand({\n keyUsage: certificate.keyUsageNumber,\n certificate: certificate.payload,\n }),\n );\n }\n\n switch (type) {\n case ClearSignContextType.PLUGIN: {\n return await this._api.sendCommand(new SetPluginCommand({ payload }));\n }\n case ClearSignContextType.EXTERNAL_PLUGIN: {\n return await this._api.sendCommand(\n new SetExternalPluginCommand({ payload }),\n );\n }\n case ClearSignContextType.NFT: {\n return await this._api.sendCommand(\n new ProvideNFTInformationCommand({ payload }),\n );\n }\n case ClearSignContextType.TOKEN: {\n return await this._api.sendCommand(\n new ProvideTokenInformationCommand({ payload }),\n );\n }\n case ClearSignContextType.TRANSACTION_INFO: {\n const paths = DerivationPathUtils.splitPath(this._args.derivationPath);\n const builder = new ByteArrayBuilder();\n builder.add8BitUIntToData(paths.length);\n paths.forEach((path) => {\n builder.add32BitUIntToData(path);\n });\n builder.addBufferToData(this._args.serializedTransaction);\n await this._sendCommandInChunksTaskFactory(this._api, {\n data: builder.build(),\n commandFactory: (args) =>\n new StoreTransactionCommand({\n serializedTransaction: args.chunkedData,\n isFirstChunk: args.isFirstChunk,\n }),\n }).run();\n\n const transactionInfoResult =\n await this._sendPayloadInChunksTaskFactory(this._api, {\n payload: this._args.context.payload,\n commandFactory: (args) =>\n new ProvideTransactionInformationCommand({\n data: args.chunkedData,\n isFirstChunk: args.isFirstChunk,\n }),\n }).run();\n\n return transactionInfoResult;\n }\n case ClearSignContextType.TRUSTED_NAME: {\n return this._sendPayloadInChunksTaskFactory(this._api, {\n payload,\n commandFactory: (args) =>\n new ProvideTrustedNameCommand({\n data: args.chunkedData,\n isFirstChunk: args.isFirstChunk,\n }),\n }).run();\n }\n case ClearSignContextType.ENUM:\n return this._sendPayloadInChunksTaskFactory(this._api, {\n payload,\n commandFactory: (args) =>\n new ProvideEnumCommand({\n data: args.chunkedData,\n isFirstChunk: args.isFirstChunk,\n }),\n }).run();\n case ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION:\n return this._sendPayloadInChunksTaskFactory(this._api, {\n payload,\n commandFactory: (args) =>\n new ProvideTransactionFieldDescriptionCommand({\n data: args.chunkedData,\n isFirstChunk: args.isFirstChunk,\n }),\n }).run();\n case ClearSignContextType.WEB3_CHECK:\n return this._sendPayloadInChunksTaskFactory(this._api, {\n payload,\n commandFactory: (args) =>\n new ProvideWeb3CheckCommand({\n payload: args.chunkedData,\n isFirstChunk: args.isFirstChunk,\n }),\n }).run();\n case ClearSignContextType.PROXY_DELEGATE_CALL:\n return this._sendPayloadInChunksTaskFactory(this._api, {\n payload,\n commandFactory: (args) =>\n new ProvideProxyInfoCommand({\n data: args.chunkedData,\n isFirstChunk: args.isFirstChunk,\n }),\n }).run();\n default: {\n const uncoveredType: never = type;\n return CommandResultFactory({\n error: new InvalidStatusWordError(\n `The context type [${uncoveredType}] is not covered`,\n ),\n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ACf,IAAI,qBAAmB,CACrB,KAAMA,EAAK,YACX,aAAcA,EAAK,YACrB,CAAC,CACL,CAAC,EAAE,IAAI,EACT,KAAK,uBAAqB,8BACxB,OAAO,KAAK,gCAAgC,KAAK,KAAM,CACrD,QAAAM,EACA,eAAiBN,GACf,IAAI,4CAA0C,CAC5C,KAAMA,EAAK,YACX,aAAcA,EAAK,YACrB,CAAC,CACL,CAAC,EAAE,IAAI,EACT,KAAK,uBAAqB,WACxB,OAAO,KAAK,gCAAgC,KAAK,KAAM,CACrD,QAAAM,EACA,eAAiBN,GACf,IAAI,0BAAwB,CAC1B,QAASA,EAAK,YACd,aAAcA,EAAK,YACrB,CAAC,CACL,CAAC,EAAE,IAAI,EACT,KAAK,uBAAqB,oBACxB,OAAO,KAAK,gCAAgC,KAAK,KAAM,CACrD,QAAAM,EACA,eAAiBN,GACf,IAAI,0BAAwB,CAC1B,KAAMA,EAAK,YACX,aAAcA,EAAK,YACrB,CAAC,CACL,CAAC,EAAE,IAAI,EACT,QAAS,CACP,MAAMW,EAAuBN,EAC7B,SAAO,wBAAqB,CAC1B,MAAO,IAAI,yBACT,qBAAqBM,CAAa,kBACpC,CACF,CAAC,CACH,CACF,CACF,CACF",
6
- "names": ["ProvideTransactionContextTask_exports", "__export", "ProvideTransactionContextTask", "__toCommonJS", "import_context_module", "import_device_management_kit", "import_signer_utils", "import_purify_ts", "import_ProvideEnumCommand", "import_ProvideNFTInformationCommand", "import_ProvideProxyInfoCommand", "import_ProvideTokenInformationCommand", "import_ProvideTransactionFieldDescriptionCommand", "import_ProvideTransactionInformationCommand", "import_ProvideTrustedNameCommand", "import_ProvideWeb3CheckCommand", "import_SetExternalPluginCommand", "import_SetPluginCommand", "import_StoreTransactionCommand", "import_SendCommandInChunksTask", "import_SendPayloadInChunksTask", "_api", "_args", "_sendPayloadInChunksTaskFactory", "api", "args", "_sendCommandInChunksTaskFactory", "callback", "subcontext", "res", "type", "payload", "certificate", "paths", "builder", "path", "uncoveredType"]
4
+ "sourcesContent": ["import {\n type ClearSignContext,\n type ClearSignContextSuccess,\n ClearSignContextType,\n} from \"@ledgerhq/context-module\";\nimport {\n ByteArrayBuilder,\n type CommandErrorResult,\n type CommandResult,\n CommandResultFactory,\n type InternalApi,\n InvalidStatusWordError,\n isSuccessCommandResult,\n LoadCertificateCommand,\n} from \"@ledgerhq/device-management-kit\";\nimport { DerivationPathUtils } from \"@ledgerhq/signer-utils\";\nimport { type Either, Left, Right } from \"purify-ts\";\n\nimport { ProvideEnumCommand } from \"@internal/app-binder/command/ProvideEnumCommand\";\nimport {\n NetworkConfigurationType,\n ProvideNetworkConfigurationCommand,\n} from \"@internal/app-binder/command/ProvideNetworkConfigurationCommand\";\nimport { ProvideNFTInformationCommand } from \"@internal/app-binder/command/ProvideNFTInformationCommand\";\nimport { ProvideProxyInfoCommand } from \"@internal/app-binder/command/ProvideProxyInfoCommand\";\nimport { ProvideTokenInformationCommand } from \"@internal/app-binder/command/ProvideTokenInformationCommand\";\nimport { ProvideTransactionFieldDescriptionCommand } from \"@internal/app-binder/command/ProvideTransactionFieldDescriptionCommand\";\nimport { ProvideTransactionInformationCommand } from \"@internal/app-binder/command/ProvideTransactionInformationCommand\";\nimport { ProvideTrustedNameCommand } from \"@internal/app-binder/command/ProvideTrustedNameCommand\";\nimport { ProvideWeb3CheckCommand } from \"@internal/app-binder/command/ProvideWeb3CheckCommand\";\nimport { SetExternalPluginCommand } from \"@internal/app-binder/command/SetExternalPluginCommand\";\nimport { SetPluginCommand } from \"@internal/app-binder/command/SetPluginCommand\";\nimport { StoreTransactionCommand } from \"@internal/app-binder/command/StoreTransactionCommand\";\nimport { type EthErrorCodes } from \"@internal/app-binder/command/utils/ethAppErrors\";\n\nimport {\n SendCommandInChunksTask,\n type SendCommandInChunksTaskArgs,\n} from \"./SendCommandInChunksTask\";\nimport {\n SendPayloadInChunksTask,\n type SendPayloadInChunksTaskArgs,\n} from \"./SendPayloadInChunksTask\";\n\nexport type ProvideTransactionContextTaskArgs = {\n /**\n * The clear sign context to provide.\n */\n context: ClearSignContextSuccess;\n /**\n * The subcontexts callbacks to provide.\n */\n subcontextsCallbacks: (() => Promise<ClearSignContext>)[];\n /**\n * The serialized transaction to provide.\n */\n serializedTransaction: Uint8Array;\n /**\n * The derivation path to provide.\n */\n derivationPath: string;\n};\n\n/**\n * This task is responsible for providing the transaction context to the device.\n * It will send the subcontexts callbacks in order and finish with the context.\n */\nexport class ProvideTransactionContextTask {\n constructor(\n private _api: InternalApi,\n private _args: ProvideTransactionContextTaskArgs,\n private _sendPayloadInChunksTaskFactory = (\n api: InternalApi,\n args: SendPayloadInChunksTaskArgs<unknown>,\n ) => new SendPayloadInChunksTask(api, args),\n private _sendCommandInChunksTaskFactory = (\n api: InternalApi,\n args: SendCommandInChunksTaskArgs<unknown>,\n ) => new SendCommandInChunksTask(api, args),\n ) {}\n\n async run(): Promise<Either<CommandErrorResult<EthErrorCodes>, void>> {\n for (const callback of this._args.subcontextsCallbacks) {\n const subcontext = await callback();\n\n if (subcontext.type === ClearSignContextType.ERROR) {\n // silently ignore error subcontexts\n continue;\n }\n\n const res = await this.provideContext(subcontext);\n if (!isSuccessCommandResult(res)) {\n return Left(res);\n }\n }\n\n const res = await this.provideContext(this._args.context);\n if (!isSuccessCommandResult(res)) {\n return Left(res);\n }\n\n return Right(void 0);\n }\n\n /**\n * This method will send the context to the device.\n *\n * @param context The clear sign context to provide.\n * @returns A promise that resolves when the command is sent.\n */\n async provideContext({\n type,\n payload,\n certificate,\n }: ClearSignContextSuccess): Promise<CommandResult<unknown, EthErrorCodes>> {\n // if a certificate is provided, we load it before sending the command\n if (certificate) {\n await this._api.sendCommand(\n new LoadCertificateCommand({\n keyUsage: certificate.keyUsageNumber,\n certificate: certificate.payload,\n }),\n );\n }\n\n switch (type) {\n case ClearSignContextType.PLUGIN: {\n return await this._api.sendCommand(new SetPluginCommand({ payload }));\n }\n case ClearSignContextType.EXTERNAL_PLUGIN: {\n return await this._api.sendCommand(\n new SetExternalPluginCommand({ payload }),\n );\n }\n case ClearSignContextType.NFT: {\n return await this._api.sendCommand(\n new ProvideNFTInformationCommand({ payload }),\n );\n }\n case ClearSignContextType.TOKEN: {\n return await this._api.sendCommand(\n new ProvideTokenInformationCommand({ payload }),\n );\n }\n case ClearSignContextType.TRANSACTION_INFO: {\n const paths = DerivationPathUtils.splitPath(this._args.derivationPath);\n const builder = new ByteArrayBuilder();\n builder.add8BitUIntToData(paths.length);\n paths.forEach((path) => {\n builder.add32BitUIntToData(path);\n });\n builder.addBufferToData(this._args.serializedTransaction);\n await this._sendCommandInChunksTaskFactory(this._api, {\n data: builder.build(),\n commandFactory: (args) =>\n new StoreTransactionCommand({\n serializedTransaction: args.chunkedData,\n isFirstChunk: args.isFirstChunk,\n }),\n }).run();\n\n const transactionInfoResult =\n await this._sendPayloadInChunksTaskFactory(this._api, {\n payload: this._args.context.payload,\n commandFactory: (args) =>\n new ProvideTransactionInformationCommand({\n data: args.chunkedData,\n isFirstChunk: args.isFirstChunk,\n }),\n }).run();\n\n return transactionInfoResult;\n }\n case ClearSignContextType.TRUSTED_NAME: {\n return this._sendPayloadInChunksTaskFactory(this._api, {\n payload,\n commandFactory: (args) =>\n new ProvideTrustedNameCommand({\n data: args.chunkedData,\n isFirstChunk: args.isFirstChunk,\n }),\n }).run();\n }\n case ClearSignContextType.ENUM:\n return this._sendPayloadInChunksTaskFactory(this._api, {\n payload,\n commandFactory: (args) =>\n new ProvideEnumCommand({\n data: args.chunkedData,\n isFirstChunk: args.isFirstChunk,\n }),\n }).run();\n case ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION:\n return this._sendPayloadInChunksTaskFactory(this._api, {\n payload,\n commandFactory: (args) =>\n new ProvideTransactionFieldDescriptionCommand({\n data: args.chunkedData,\n isFirstChunk: args.isFirstChunk,\n }),\n }).run();\n case ClearSignContextType.WEB3_CHECK:\n return this._sendPayloadInChunksTaskFactory(this._api, {\n payload,\n commandFactory: (args) =>\n new ProvideWeb3CheckCommand({\n payload: args.chunkedData,\n isFirstChunk: args.isFirstChunk,\n }),\n }).run();\n case ClearSignContextType.PROXY_DELEGATE_CALL:\n return this._sendPayloadInChunksTaskFactory(this._api, {\n payload,\n commandFactory: (args) =>\n new ProvideProxyInfoCommand({\n data: args.chunkedData,\n isFirstChunk: args.isFirstChunk,\n }),\n }).run();\n case ClearSignContextType.DYNAMIC_NETWORK:\n // Dynamic network configuration uses the existing ProvideNetworkConfiguration command\n // but is provided as part of the context flow\n return this._sendPayloadInChunksTaskFactory(this._api, {\n payload,\n commandFactory: (args) =>\n new ProvideNetworkConfigurationCommand({\n data: args.chunkedData,\n isFirstChunk: args.isFirstChunk,\n configurationType: NetworkConfigurationType.CONFIGURATION,\n }),\n }).run();\n case ClearSignContextType.DYNAMIC_NETWORK_ICON: {\n return this._sendPayloadInChunksTaskFactory(this._api, {\n payload,\n commandFactory: (args) =>\n new ProvideNetworkConfigurationCommand({\n data: args.chunkedData,\n isFirstChunk: args.isFirstChunk,\n configurationType: NetworkConfigurationType.ICON,\n }),\n withPayloadLength: false,\n }).run();\n }\n default: {\n const uncoveredType: never = type;\n return CommandResultFactory({\n error: new InvalidStatusWordError(\n `The context type [${uncoveredType}] is not covered`,\n ),\n });\n }\n }\n }\n}\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,mCAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAIO,oCACPC,EASO,2CACPC,EAAoC,kCACpCC,EAAyC,qBAEzCC,EAAmC,2DACnCC,EAGO,2EACPC,EAA6C,qEAC7CC,EAAwC,gEACxCC,EAA+C,uEAC/CC,EAA0D,kFAC1DC,EAAqD,6EACrDC,EAA0C,kEAC1CC,EAAwC,gEACxCC,EAAyC,iEACzCC,EAAiC,yDACjCC,EAAwC,gEAGxCC,EAGO,qCACPC,EAGO,qCAyBA,MAAMnB,CAA8B,CACzC,YACUoB,EACAC,EACAC,EAAkC,CACxCC,EACAC,IACG,IAAI,0BAAwB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AqB,oBACxB,OAAO,KAAK,gCAAgC,KAAK,KAAM,CACrD,QAAAM,EACA,eAAiBN,GACf,IAAI,0BAAwB,CAC1B,KAAMA,EAAK,YACX,aAAcA,EAAK,YACrB,CAAC,CACL,CAAC,EAAE,IAAI,EACT,KAAK,uBAAqB,gBAGxB,OAAO,KAAK,gCAAgC,KAAK,KAAM,CACrD,QAAAM,EACA,eAAiBN,GACf,IAAI,qCAAmC,CACrC,KAAMA,EAAK,YACX,aAAcA,EAAK,aACnB,kBAAmB,2BAAyB,aAC9C,CAAC,CACL,CAAC,EAAE,IAAI,EACT,KAAK,uBAAqB,qBACxB,OAAO,KAAK,gCAAgC,KAAK,KAAM,CACrD,QAAAM,EACA,eAAiBN,GACf,IAAI,qCAAmC,CACrC,KAAMA,EAAK,YACX,aAAcA,EAAK,aACnB,kBAAmB,2BAAyB,IAC9C,CAAC,EACH,kBAAmB,EACrB,CAAC,EAAE,IAAI,EAET,QAAS,CACP,MAAMW,EAAuBN,EAC7B,SAAO,wBAAqB,CAC1B,MAAO,IAAI,yBACT,qBAAqBM,CAAa,kBACpC,CACF,CAAC,CACH,CACF,CACF,CACF",
6
+ "names": ["ProvideTransactionContextTask_exports", "__export", "ProvideTransactionContextTask", "__toCommonJS", "import_context_module", "import_device_management_kit", "import_signer_utils", "import_purify_ts", "import_ProvideEnumCommand", "import_ProvideNetworkConfigurationCommand", "import_ProvideNFTInformationCommand", "import_ProvideProxyInfoCommand", "import_ProvideTokenInformationCommand", "import_ProvideTransactionFieldDescriptionCommand", "import_ProvideTransactionInformationCommand", "import_ProvideTrustedNameCommand", "import_ProvideWeb3CheckCommand", "import_SetExternalPluginCommand", "import_SetPluginCommand", "import_StoreTransactionCommand", "import_SendCommandInChunksTask", "import_SendPayloadInChunksTask", "_api", "_args", "_sendPayloadInChunksTaskFactory", "api", "args", "_sendCommandInChunksTaskFactory", "callback", "subcontext", "res", "type", "payload", "certificate", "paths", "builder", "path", "uncoveredType"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var t=require("@ledgerhq/context-module"),y=require("@ledgerhq/device-management-kit"),l=require("purify-ts"),F=require("../../app-binder/command/ProvideEnumCommand"),h=require("../../app-binder/command/ProvideNFTInformationCommand"),N=require("../../app-binder/command/ProvideProxyInfoCommand"),T=require("../../app-binder/command/ProvideTokenInformationCommand"),f=require("../../app-binder/command/ProvideTransactionFieldDescriptionCommand"),E=require("../../app-binder/command/ProvideTransactionInformationCommand"),P=require("../../app-binder/command/ProvideTrustedNameCommand"),b=require("../../app-binder/command/ProvideWeb3CheckCommand"),g=require("../../app-binder/command/SetExternalPluginCommand"),B=require("../../app-binder/command/SetPluginCommand"),A=require("../../app-binder/command/StoreTransactionCommand"),R=require("../../app-binder/device-action/__test-utils__/makeInternalApi"),i=require("./ProvideTransactionContextTask"),U=require("./SendCommandInChunksTask"),O=require("./SendPayloadInChunksTask");describe("ProvideTransactionContextTask",()=>{const e=(0,R.makeDeviceActionInternalApiMock)(),c=(0,y.CommandResultFactory)({data:void 0}),v=(0,y.CommandResultFactory)({data:void 0,error:{}});beforeEach(()=>{vi.resetAllMocks()}),describe("run",()=>{const n=vi.fn(),C=vi.fn(),r=vi.fn(),d=vi.fn();beforeEach(()=>{vi.clearAllMocks(),r.mockImplementation((a,o)=>({run:()=>C(a,o)})),d.mockImplementation((a,o)=>({run:()=>n(a,o)}))}),describe("with no subcontexts",()=>{it("should provide the transaction context for a TRANSACTION_INFO context",async()=>{const a={context:{type:t.ClearSignContextType.TRANSACTION_INFO,payload:"0x00",certificate:{keyUsageNumber:1,payload:new Uint8Array([1,2,3])}},subcontextsCallbacks:[],serializedTransaction:new Uint8Array,derivationPath:"44'/60'/0'/0/0"};C.mockResolvedValue(c),n.mockResolvedValue(c),e.sendCommand.mockResolvedValue(c);const s=await new i.ProvideTransactionContextTask(e,a,d,r).run();expect(s).toEqual((0,l.Right)(void 0)),expect(C).toHaveBeenCalledTimes(1),expect(r).toHaveBeenCalledWith(e,{data:new Uint8Array([5,128,0,0,44,128,0,0,60,128,0,0,0,0,0,0,0,0,0,0,0]),commandFactory:expect.any(Function)});const m=r.mock.calls[0][1].commandFactory,p={chunkedData:new Uint8Array([1,2,3,4]),isFirstChunk:!0},x=m(p);expect(x).toBeInstanceOf(A.StoreTransactionCommand),expect(e.sendCommand).toHaveBeenCalledTimes(1),expect(e.sendCommand).toHaveBeenCalledWith(expect.any(y.LoadCertificateCommand)),expect(n).toHaveBeenCalledTimes(1),expect(n).toHaveBeenCalledWith(e,{payload:"0x00",commandFactory:expect.any(Function)});const k=n.mock.calls[0][1].commandFactory,I=k(p);expect(I).toBeInstanceOf(E.ProvideTransactionInformationCommand)}),it("should provide the transaction context for a TRANSACTION_INFO context without certificate",async()=>{const a={context:{type:t.ClearSignContextType.TRANSACTION_INFO,payload:"0x00"},subcontextsCallbacks:[],serializedTransaction:new Uint8Array,derivationPath:"44'/60'/0'/0/0"};C.mockResolvedValue(c),n.mockResolvedValue(c),e.sendCommand.mockResolvedValue(c);const s=await new i.ProvideTransactionContextTask(e,a,d,r).run();expect(s).toEqual((0,l.Right)(void 0)),expect(C).toHaveBeenCalledTimes(1),expect(r).toHaveBeenCalledWith(e,{data:new Uint8Array([5,128,0,0,44,128,0,0,60,128,0,0,0,0,0,0,0,0,0,0,0]),commandFactory:expect.any(Function)});const m=r.mock.calls[0][1].commandFactory,p={chunkedData:new Uint8Array([1,2,3,4]),isFirstChunk:!0},x=m(p);expect(x).toBeInstanceOf(A.StoreTransactionCommand),expect(e.sendCommand).toHaveBeenCalledTimes(0),expect(n).toHaveBeenCalledTimes(1),expect(n).toHaveBeenCalledWith(e,{payload:"0x00",commandFactory:expect.any(Function)});const k=n.mock.calls[0][1].commandFactory,I=k(p);expect(I).toBeInstanceOf(E.ProvideTransactionInformationCommand)}),it.each([[t.ClearSignContextType.PLUGIN,B.SetPluginCommand],[t.ClearSignContextType.EXTERNAL_PLUGIN,g.SetExternalPluginCommand],[t.ClearSignContextType.NFT,h.ProvideNFTInformationCommand],[t.ClearSignContextType.TOKEN,T.ProvideTokenInformationCommand]])("should provide the transaction context by calling sendCommand for a %s context",async(a,o)=>{const s={context:{type:a,payload:"payload"},subcontextsCallbacks:[],serializedTransaction:new Uint8Array,derivationPath:"44'/60'/0'/0/0"};e.sendCommand.mockResolvedValue(c);const m=await new i.ProvideTransactionContextTask(e,s,d,r).run();expect(m).toEqual((0,l.Right)(void 0)),expect(e.sendCommand).toHaveBeenCalledTimes(1),expect(e.sendCommand).toHaveBeenCalledWith(expect.any(o))}),it.each([[t.ClearSignContextType.ENUM,F.ProvideEnumCommand],[t.ClearSignContextType.TRUSTED_NAME,P.ProvideTrustedNameCommand],[t.ClearSignContextType.WEB3_CHECK,b.ProvideWeb3CheckCommand],[t.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,f.ProvideTransactionFieldDescriptionCommand],[t.ClearSignContextType.PROXY_DELEGATE_CALL,N.ProvideProxyInfoCommand]])("should provide the transaction context by calling sendPayloadInChunksTask for a %s context",async(a,o)=>{const s={context:{type:a,payload:"payload"},subcontextsCallbacks:[],serializedTransaction:new Uint8Array,derivationPath:"44'/60'/0'/0/0"};n.mockResolvedValue(c);const m=await new i.ProvideTransactionContextTask(e,s,d,r).run();expect(m).toEqual((0,l.Right)(void 0)),expect(n).toHaveBeenCalledTimes(1),expect(n).toHaveBeenCalledWith(e,{payload:"payload",commandFactory:expect.any(Function)});const x=d.mock.calls[0][1].commandFactory,w={chunkedData:new Uint8Array([1,2,3]),isFirstChunk:!0},k=x(w);expect(k).toBeInstanceOf(o)}),it("should skip the subcontexts if the context is an error",async()=>{const a={context:{type:t.ClearSignContextType.TOKEN,payload:"payload",certificate:{keyUsageNumber:1,payload:new Uint8Array([1,2,3])}},subcontextsCallbacks:[()=>Promise.resolve({type:t.ClearSignContextType.ERROR,error:new Error("error")})],serializedTransaction:new Uint8Array,derivationPath:"44'/60'/0'/0/0"};n.mockResolvedValue(c),e.sendCommand.mockResolvedValue(c);const s=await new i.ProvideTransactionContextTask(e,a,d,r).run();expect(s).toEqual((0,l.Right)(void 0)),expect(n).toHaveBeenCalledTimes(0),expect(C).toHaveBeenCalledTimes(0),expect(e.sendCommand).toHaveBeenCalledTimes(2),expect(e.sendCommand).toHaveBeenNthCalledWith(1,expect.any(y.LoadCertificateCommand)),expect(e.sendCommand).toHaveBeenNthCalledWith(2,expect.any(T.ProvideTokenInformationCommand))})}),describe("with subcontexts",()=>{it("should provide the transaction context and subcontext for a TRANSACTION_FIELD_DESCRIPTION context",async()=>{const a={context:{type:t.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"payload"},subcontextsCallbacks:[()=>Promise.resolve({type:t.ClearSignContextType.TOKEN,payload:"payload"})],serializedTransaction:new Uint8Array,derivationPath:"44'/60'/0'/0/0"};n.mockResolvedValue(c),e.sendCommand.mockResolvedValue(c);const s=await new i.ProvideTransactionContextTask(e,a,d,r).run();expect(s).toEqual((0,l.Right)(void 0)),expect(n).toHaveBeenCalledTimes(1),expect(n).toHaveBeenCalledWith(e,{payload:"payload",commandFactory:expect.any(Function)});const m=d.mock.calls[0][1].commandFactory,p={chunkedData:new Uint8Array([1,2,3]),isFirstChunk:!0},x=m(p);expect(x).toBeInstanceOf(f.ProvideTransactionFieldDescriptionCommand),expect(e.sendCommand).toHaveBeenCalledTimes(1),expect(e.sendCommand).toHaveBeenCalledWith(expect.any(T.ProvideTokenInformationCommand))}),it("should provide the transaction context and subcontexts for a TRUSTED_NAME context",async()=>{const a={context:{type:t.ClearSignContextType.TRUSTED_NAME,payload:"payload"},subcontextsCallbacks:[()=>Promise.resolve({type:t.ClearSignContextType.NFT,payload:"payload1"}),()=>Promise.resolve({type:t.ClearSignContextType.TOKEN,payload:"payload2"})],serializedTransaction:new Uint8Array,derivationPath:"44'/60'/0'/0/0"};n.mockResolvedValue(c),e.sendCommand.mockResolvedValue(c);const s=await new i.ProvideTransactionContextTask(e,a,d,r).run();expect(s).toEqual((0,l.Right)(void 0)),expect(n).toHaveBeenCalledTimes(1),expect(n).toHaveBeenCalledWith(e,{payload:"payload",commandFactory:expect.any(Function)});const m=d.mock.calls[0][1].commandFactory,p={chunkedData:new Uint8Array([1,2,3]),isFirstChunk:!0},x=m(p);expect(x).toBeInstanceOf(P.ProvideTrustedNameCommand),expect(e.sendCommand).toHaveBeenCalledTimes(2),expect(e.sendCommand).toHaveBeenNthCalledWith(1,expect.any(h.ProvideNFTInformationCommand)),expect(e.sendCommand).toHaveBeenNthCalledWith(2,expect.any(T.ProvideTokenInformationCommand))})}),describe("with subcontexts and certificate",()=>{it("should provide the transaction context and subcontexts for a TRUSTED_NAME context",async()=>{const a={context:{type:t.ClearSignContextType.TRUSTED_NAME,payload:"payload",certificate:{keyUsageNumber:1,payload:new Uint8Array([1,2,3])}},subcontextsCallbacks:[()=>Promise.resolve({type:t.ClearSignContextType.NFT,payload:"payload1",certificate:{keyUsageNumber:2,payload:new Uint8Array([4,5,6])}})],serializedTransaction:new Uint8Array,derivationPath:"44'/60'/0'/0/0"};n.mockResolvedValue(c),e.sendCommand.mockResolvedValue(c),await new i.ProvideTransactionContextTask(e,a,d,r).run(),expect(e.sendCommand).toHaveBeenCalledTimes(3),expect(e.sendCommand).toHaveBeenNthCalledWith(1,expect.any(y.LoadCertificateCommand)),expect(e.sendCommand).toHaveBeenNthCalledWith(2,expect.any(h.ProvideNFTInformationCommand)),expect(e.sendCommand).toHaveBeenNthCalledWith(3,expect.any(y.LoadCertificateCommand))})}),describe("with error",()=>{it("should return an error if the provideContext fails",async()=>{const a={context:{type:t.ClearSignContextType.TOKEN,payload:"payload"},subcontextsCallbacks:[],serializedTransaction:new Uint8Array,derivationPath:"44'/60'/0'/0/0"};e.sendCommand.mockResolvedValue(v);const s=await new i.ProvideTransactionContextTask(e,a,d,r).run();expect(s).toEqual((0,l.Left)(v))}),it("should return an error if the provide subcontext fails",async()=>{const a={context:{type:t.ClearSignContextType.TOKEN,payload:"payload"},subcontextsCallbacks:[()=>Promise.resolve({type:t.ClearSignContextType.TOKEN,payload:"payload"})],serializedTransaction:new Uint8Array,derivationPath:"44'/60'/0'/0/0"};e.sendCommand.mockResolvedValue(v);const s=await new i.ProvideTransactionContextTask(e,a,d,r).run();expect(s).toEqual((0,l.Left)(v))}),it("should return an error if the type is not supported",async()=>{const a={context:{type:"unsupported",payload:"payload"},subcontextsCallbacks:[],serializedTransaction:new Uint8Array,derivationPath:"44'/60'/0'/0/0"},s=await new i.ProvideTransactionContextTask(e,a,d,r).run();expect(s).toEqual((0,l.Left)((0,y.CommandResultFactory)({error:new y.InvalidStatusWordError("The context type [unsupported] is not covered")})))})}),describe("factory types",()=>{it("should have a sendPayloadInChunksTaskFactory by default",()=>{const a=new i.ProvideTransactionContextTask(e,{context:{type:t.ClearSignContextType.TOKEN,payload:"payload"},subcontextsCallbacks:[],serializedTransaction:new Uint8Array,derivationPath:"44'/60'/0'/0/0"});expect(a._sendPayloadInChunksTaskFactory).toBeDefined();const o=a._sendPayloadInChunksTaskFactory(e,{payload:"payload",commandFactory:()=>new f.ProvideTransactionFieldDescriptionCommand({data:new Uint8Array,isFirstChunk:!0})});expect(o).toBeInstanceOf(O.SendPayloadInChunksTask)}),it("should have a sendCommandInChunksTaskFactory by default",()=>{const a=new i.ProvideTransactionContextTask(e,{context:{type:t.ClearSignContextType.TOKEN,payload:"payload"},subcontextsCallbacks:[],serializedTransaction:new Uint8Array,derivationPath:"44'/60'/0'/0/0"});expect(a._sendCommandInChunksTaskFactory).toBeDefined();const o=a._sendCommandInChunksTaskFactory(e,{data:new Uint8Array,commandFactory:()=>new A.StoreTransactionCommand({serializedTransaction:new Uint8Array,isFirstChunk:!0})});expect(o).toBeInstanceOf(U.SendCommandInChunksTask)})})})});
1
+ "use strict";var t=require("@ledgerhq/context-module"),y=require("@ledgerhq/device-management-kit"),l=require("purify-ts"),F=require("../../app-binder/command/ProvideEnumCommand"),E=require("../../app-binder/command/ProvideNetworkConfigurationCommand"),f=require("../../app-binder/command/ProvideNFTInformationCommand"),b=require("../../app-binder/command/ProvideProxyInfoCommand"),v=require("../../app-binder/command/ProvideTokenInformationCommand"),A=require("../../app-binder/command/ProvideTransactionFieldDescriptionCommand"),N=require("../../app-binder/command/ProvideTransactionInformationCommand"),P=require("../../app-binder/command/ProvideTrustedNameCommand"),g=require("../../app-binder/command/ProvideWeb3CheckCommand"),B=require("../../app-binder/command/SetExternalPluginCommand"),R=require("../../app-binder/command/SetPluginCommand"),w=require("../../app-binder/command/StoreTransactionCommand"),U=require("../../app-binder/device-action/__test-utils__/makeInternalApi"),i=require("./ProvideTransactionContextTask"),O=require("./SendCommandInChunksTask"),H=require("./SendPayloadInChunksTask");describe("ProvideTransactionContextTask",()=>{const e=(0,U.makeDeviceActionInternalApiMock)(),c=(0,y.CommandResultFactory)({data:void 0}),h=(0,y.CommandResultFactory)({data:void 0,error:{}});beforeEach(()=>{vi.resetAllMocks()}),describe("run",()=>{const n=vi.fn(),C=vi.fn(),r=vi.fn(),d=vi.fn();beforeEach(()=>{vi.clearAllMocks(),r.mockImplementation((a,o)=>({run:()=>C(a,o)})),d.mockImplementation((a,o)=>({run:()=>n(a,o)}))}),describe("with no subcontexts",()=>{it("should provide the transaction context for a TRANSACTION_INFO context",async()=>{const a={context:{type:t.ClearSignContextType.TRANSACTION_INFO,payload:"0x00",certificate:{keyUsageNumber:1,payload:new Uint8Array([1,2,3])}},subcontextsCallbacks:[],serializedTransaction:new Uint8Array,derivationPath:"44'/60'/0'/0/0"};C.mockResolvedValue(c),n.mockResolvedValue(c),e.sendCommand.mockResolvedValue(c);const s=await new i.ProvideTransactionContextTask(e,a,d,r).run();expect(s).toEqual((0,l.Right)(void 0)),expect(C).toHaveBeenCalledTimes(1),expect(r).toHaveBeenCalledWith(e,{data:new Uint8Array([5,128,0,0,44,128,0,0,60,128,0,0,0,0,0,0,0,0,0,0,0]),commandFactory:expect.any(Function)});const p=r.mock.calls[0][1].commandFactory,m={chunkedData:new Uint8Array([1,2,3,4]),isFirstChunk:!0},x=p(m);expect(x).toBeInstanceOf(w.StoreTransactionCommand),expect(e.sendCommand).toHaveBeenCalledTimes(1),expect(e.sendCommand).toHaveBeenCalledWith(expect.any(y.LoadCertificateCommand)),expect(n).toHaveBeenCalledTimes(1),expect(n).toHaveBeenCalledWith(e,{payload:"0x00",commandFactory:expect.any(Function)});const k=n.mock.calls[0][1].commandFactory,T=k(m);expect(T).toBeInstanceOf(N.ProvideTransactionInformationCommand)}),it("should provide the transaction context for a TRANSACTION_INFO context without certificate",async()=>{const a={context:{type:t.ClearSignContextType.TRANSACTION_INFO,payload:"0x00"},subcontextsCallbacks:[],serializedTransaction:new Uint8Array,derivationPath:"44'/60'/0'/0/0"};C.mockResolvedValue(c),n.mockResolvedValue(c),e.sendCommand.mockResolvedValue(c);const s=await new i.ProvideTransactionContextTask(e,a,d,r).run();expect(s).toEqual((0,l.Right)(void 0)),expect(C).toHaveBeenCalledTimes(1),expect(r).toHaveBeenCalledWith(e,{data:new Uint8Array([5,128,0,0,44,128,0,0,60,128,0,0,0,0,0,0,0,0,0,0,0]),commandFactory:expect.any(Function)});const p=r.mock.calls[0][1].commandFactory,m={chunkedData:new Uint8Array([1,2,3,4]),isFirstChunk:!0},x=p(m);expect(x).toBeInstanceOf(w.StoreTransactionCommand),expect(e.sendCommand).toHaveBeenCalledTimes(0),expect(n).toHaveBeenCalledTimes(1),expect(n).toHaveBeenCalledWith(e,{payload:"0x00",commandFactory:expect.any(Function)});const k=n.mock.calls[0][1].commandFactory,T=k(m);expect(T).toBeInstanceOf(N.ProvideTransactionInformationCommand)}),it.each([[t.ClearSignContextType.PLUGIN,R.SetPluginCommand],[t.ClearSignContextType.EXTERNAL_PLUGIN,B.SetExternalPluginCommand],[t.ClearSignContextType.NFT,f.ProvideNFTInformationCommand],[t.ClearSignContextType.TOKEN,v.ProvideTokenInformationCommand]])("should provide the transaction context by calling sendCommand for a %s context",async(a,o)=>{const s={context:{type:a,payload:"payload"},subcontextsCallbacks:[],serializedTransaction:new Uint8Array,derivationPath:"44'/60'/0'/0/0"};e.sendCommand.mockResolvedValue(c);const p=await new i.ProvideTransactionContextTask(e,s,d,r).run();expect(p).toEqual((0,l.Right)(void 0)),expect(e.sendCommand).toHaveBeenCalledTimes(1),expect(e.sendCommand).toHaveBeenCalledWith(expect.any(o))}),it.each([[t.ClearSignContextType.ENUM,F.ProvideEnumCommand],[t.ClearSignContextType.TRUSTED_NAME,P.ProvideTrustedNameCommand],[t.ClearSignContextType.WEB3_CHECK,g.ProvideWeb3CheckCommand],[t.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,A.ProvideTransactionFieldDescriptionCommand],[t.ClearSignContextType.PROXY_DELEGATE_CALL,b.ProvideProxyInfoCommand],[t.ClearSignContextType.DYNAMIC_NETWORK_ICON,E.ProvideNetworkConfigurationCommand,!1],[t.ClearSignContextType.DYNAMIC_NETWORK,E.ProvideNetworkConfigurationCommand]])("should provide the transaction context by calling sendPayloadInChunksTask for a %s context",async(a,o,s=void 0)=>{const u={context:{type:a,payload:"payload"},subcontextsCallbacks:[],serializedTransaction:new Uint8Array,derivationPath:"44'/60'/0'/0/0"};n.mockResolvedValue(c);const m=await new i.ProvideTransactionContextTask(e,u,d,r).run();expect(m).toEqual((0,l.Right)(void 0)),expect(n).toHaveBeenCalledTimes(1),s===void 0?expect(n).toHaveBeenCalledWith(e,{payload:"payload",commandFactory:expect.any(Function)}):expect(n).toHaveBeenCalledWith(e,{payload:"payload",commandFactory:expect.any(Function),withPayloadLength:s});const I=d.mock.calls[0][1].commandFactory,k={chunkedData:new Uint8Array([1,2,3]),isFirstChunk:!0},T=I(k);expect(T).toBeInstanceOf(o)}),it("should skip the subcontexts if the context is an error",async()=>{const a={context:{type:t.ClearSignContextType.TOKEN,payload:"payload",certificate:{keyUsageNumber:1,payload:new Uint8Array([1,2,3])}},subcontextsCallbacks:[()=>Promise.resolve({type:t.ClearSignContextType.ERROR,error:new Error("error")})],serializedTransaction:new Uint8Array,derivationPath:"44'/60'/0'/0/0"};n.mockResolvedValue(c),e.sendCommand.mockResolvedValue(c);const s=await new i.ProvideTransactionContextTask(e,a,d,r).run();expect(s).toEqual((0,l.Right)(void 0)),expect(n).toHaveBeenCalledTimes(0),expect(C).toHaveBeenCalledTimes(0),expect(e.sendCommand).toHaveBeenCalledTimes(2),expect(e.sendCommand).toHaveBeenNthCalledWith(1,expect.any(y.LoadCertificateCommand)),expect(e.sendCommand).toHaveBeenNthCalledWith(2,expect.any(v.ProvideTokenInformationCommand))})}),describe("with subcontexts",()=>{it("should provide the transaction context and subcontext for a TRANSACTION_FIELD_DESCRIPTION context",async()=>{const a={context:{type:t.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"payload"},subcontextsCallbacks:[()=>Promise.resolve({type:t.ClearSignContextType.TOKEN,payload:"payload"})],serializedTransaction:new Uint8Array,derivationPath:"44'/60'/0'/0/0"};n.mockResolvedValue(c),e.sendCommand.mockResolvedValue(c);const s=await new i.ProvideTransactionContextTask(e,a,d,r).run();expect(s).toEqual((0,l.Right)(void 0)),expect(n).toHaveBeenCalledTimes(1),expect(n).toHaveBeenCalledWith(e,{payload:"payload",commandFactory:expect.any(Function)});const p=d.mock.calls[0][1].commandFactory,m={chunkedData:new Uint8Array([1,2,3]),isFirstChunk:!0},x=p(m);expect(x).toBeInstanceOf(A.ProvideTransactionFieldDescriptionCommand),expect(e.sendCommand).toHaveBeenCalledTimes(1),expect(e.sendCommand).toHaveBeenCalledWith(expect.any(v.ProvideTokenInformationCommand))}),it("should provide the transaction context and subcontexts for a TRUSTED_NAME context",async()=>{const a={context:{type:t.ClearSignContextType.TRUSTED_NAME,payload:"payload"},subcontextsCallbacks:[()=>Promise.resolve({type:t.ClearSignContextType.NFT,payload:"payload1"}),()=>Promise.resolve({type:t.ClearSignContextType.TOKEN,payload:"payload2"})],serializedTransaction:new Uint8Array,derivationPath:"44'/60'/0'/0/0"};n.mockResolvedValue(c),e.sendCommand.mockResolvedValue(c);const s=await new i.ProvideTransactionContextTask(e,a,d,r).run();expect(s).toEqual((0,l.Right)(void 0)),expect(n).toHaveBeenCalledTimes(1),expect(n).toHaveBeenCalledWith(e,{payload:"payload",commandFactory:expect.any(Function)});const p=d.mock.calls[0][1].commandFactory,m={chunkedData:new Uint8Array([1,2,3]),isFirstChunk:!0},x=p(m);expect(x).toBeInstanceOf(P.ProvideTrustedNameCommand),expect(e.sendCommand).toHaveBeenCalledTimes(2),expect(e.sendCommand).toHaveBeenNthCalledWith(1,expect.any(f.ProvideNFTInformationCommand)),expect(e.sendCommand).toHaveBeenNthCalledWith(2,expect.any(v.ProvideTokenInformationCommand))})}),describe("with subcontexts and certificate",()=>{it("should provide the transaction context and subcontexts for a TRUSTED_NAME context",async()=>{const a={context:{type:t.ClearSignContextType.TRUSTED_NAME,payload:"payload",certificate:{keyUsageNumber:1,payload:new Uint8Array([1,2,3])}},subcontextsCallbacks:[()=>Promise.resolve({type:t.ClearSignContextType.NFT,payload:"payload1",certificate:{keyUsageNumber:2,payload:new Uint8Array([4,5,6])}})],serializedTransaction:new Uint8Array,derivationPath:"44'/60'/0'/0/0"};n.mockResolvedValue(c),e.sendCommand.mockResolvedValue(c),await new i.ProvideTransactionContextTask(e,a,d,r).run(),expect(e.sendCommand).toHaveBeenCalledTimes(3),expect(e.sendCommand).toHaveBeenNthCalledWith(1,expect.any(y.LoadCertificateCommand)),expect(e.sendCommand).toHaveBeenNthCalledWith(2,expect.any(f.ProvideNFTInformationCommand)),expect(e.sendCommand).toHaveBeenNthCalledWith(3,expect.any(y.LoadCertificateCommand))})}),describe("with error",()=>{it("should return an error if the provideContext fails",async()=>{const a={context:{type:t.ClearSignContextType.TOKEN,payload:"payload"},subcontextsCallbacks:[],serializedTransaction:new Uint8Array,derivationPath:"44'/60'/0'/0/0"};e.sendCommand.mockResolvedValue(h);const s=await new i.ProvideTransactionContextTask(e,a,d,r).run();expect(s).toEqual((0,l.Left)(h))}),it("should return an error if the provide subcontext fails",async()=>{const a={context:{type:t.ClearSignContextType.TOKEN,payload:"payload"},subcontextsCallbacks:[()=>Promise.resolve({type:t.ClearSignContextType.TOKEN,payload:"payload"})],serializedTransaction:new Uint8Array,derivationPath:"44'/60'/0'/0/0"};e.sendCommand.mockResolvedValue(h);const s=await new i.ProvideTransactionContextTask(e,a,d,r).run();expect(s).toEqual((0,l.Left)(h))}),it("should return an error if the type is not supported",async()=>{const a={context:{type:"unsupported",payload:"payload"},subcontextsCallbacks:[],serializedTransaction:new Uint8Array,derivationPath:"44'/60'/0'/0/0"},s=await new i.ProvideTransactionContextTask(e,a,d,r).run();expect(s).toEqual((0,l.Left)((0,y.CommandResultFactory)({error:new y.InvalidStatusWordError("The context type [unsupported] is not covered")})))})}),describe("factory types",()=>{it("should have a sendPayloadInChunksTaskFactory by default",()=>{const a=new i.ProvideTransactionContextTask(e,{context:{type:t.ClearSignContextType.TOKEN,payload:"payload"},subcontextsCallbacks:[],serializedTransaction:new Uint8Array,derivationPath:"44'/60'/0'/0/0"});expect(a._sendPayloadInChunksTaskFactory).toBeDefined();const o=a._sendPayloadInChunksTaskFactory(e,{payload:"payload",commandFactory:()=>new A.ProvideTransactionFieldDescriptionCommand({data:new Uint8Array,isFirstChunk:!0})});expect(o).toBeInstanceOf(H.SendPayloadInChunksTask)}),it("should have a sendCommandInChunksTaskFactory by default",()=>{const a=new i.ProvideTransactionContextTask(e,{context:{type:t.ClearSignContextType.TOKEN,payload:"payload"},subcontextsCallbacks:[],serializedTransaction:new Uint8Array,derivationPath:"44'/60'/0'/0/0"});expect(a._sendCommandInChunksTaskFactory).toBeDefined();const o=a._sendCommandInChunksTaskFactory(e,{data:new Uint8Array,commandFactory:()=>new w.StoreTransactionCommand({serializedTransaction:new Uint8Array,isFirstChunk:!0})});expect(o).toBeInstanceOf(O.SendCommandInChunksTask)})})})});
2
2
  //# sourceMappingURL=ProvideTransactionContextTask.test.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/internal/app-binder/task/ProvideTransactionContextTask.test.ts"],
4
- "sourcesContent": ["import {\n type ClearSignContextSuccess,\n ClearSignContextType,\n} from \"@ledgerhq/context-module\";\nimport {\n CommandResultFactory,\n type InternalApi,\n InvalidStatusWordError,\n LoadCertificateCommand,\n type UnknownDeviceExchangeError,\n} from \"@ledgerhq/device-management-kit\";\nimport { Left, Right } from \"purify-ts\";\n\nimport { ProvideEnumCommand } from \"@internal/app-binder/command/ProvideEnumCommand\";\nimport { ProvideNFTInformationCommand } from \"@internal/app-binder/command/ProvideNFTInformationCommand\";\nimport { ProvideProxyInfoCommand } from \"@internal/app-binder/command/ProvideProxyInfoCommand\";\nimport { ProvideTokenInformationCommand } from \"@internal/app-binder/command/ProvideTokenInformationCommand\";\nimport { ProvideTransactionFieldDescriptionCommand } from \"@internal/app-binder/command/ProvideTransactionFieldDescriptionCommand\";\nimport { ProvideTransactionInformationCommand } from \"@internal/app-binder/command/ProvideTransactionInformationCommand\";\nimport { ProvideTrustedNameCommand } from \"@internal/app-binder/command/ProvideTrustedNameCommand\";\nimport { ProvideWeb3CheckCommand } from \"@internal/app-binder/command/ProvideWeb3CheckCommand\";\nimport { SetExternalPluginCommand } from \"@internal/app-binder/command/SetExternalPluginCommand\";\nimport { SetPluginCommand } from \"@internal/app-binder/command/SetPluginCommand\";\nimport { StoreTransactionCommand } from \"@internal/app-binder/command/StoreTransactionCommand\";\nimport { type EthErrorCodes } from \"@internal/app-binder/command/utils/ethAppErrors\";\nimport { makeDeviceActionInternalApiMock } from \"@internal/app-binder/device-action/__test-utils__/makeInternalApi\";\n\nimport {\n ProvideTransactionContextTask,\n type ProvideTransactionContextTaskArgs,\n} from \"./ProvideTransactionContextTask\";\nimport {\n SendCommandInChunksTask,\n type SendCommandInChunksTaskArgs,\n} from \"./SendCommandInChunksTask\";\nimport {\n SendPayloadInChunksTask,\n type SendPayloadInChunksTaskArgs,\n} from \"./SendPayloadInChunksTask\";\n\ndescribe(\"ProvideTransactionContextTask\", () => {\n const api = makeDeviceActionInternalApiMock();\n const successResult = CommandResultFactory<void, EthErrorCodes>({\n data: undefined,\n });\n const errorResult = CommandResultFactory<void, EthErrorCodes>({\n data: undefined,\n error: {} as UnknownDeviceExchangeError,\n });\n\n beforeEach(() => {\n vi.resetAllMocks();\n });\n\n describe(\"run\", () => {\n const sendPayloadInChunksRunMock = vi.fn();\n const sendCommandInChunksTaskRunMock = vi.fn();\n const sendCommandInChunksTaskMockFactory = vi.fn();\n const sendPayloadInChunksTaskMockFactory = vi.fn();\n\n beforeEach(() => {\n vi.clearAllMocks();\n sendCommandInChunksTaskMockFactory.mockImplementation(\n (a: InternalApi, args: SendCommandInChunksTaskArgs<unknown>) =>\n ({\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n run: () => sendCommandInChunksTaskRunMock(a, args),\n }) as unknown as SendCommandInChunksTask<unknown>,\n );\n sendPayloadInChunksTaskMockFactory.mockImplementation(\n (a: InternalApi, args: SendPayloadInChunksTaskArgs<unknown>) =>\n ({\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n run: () => sendPayloadInChunksRunMock(a, args),\n }) as unknown as SendPayloadInChunksTask<unknown>,\n );\n });\n\n describe(\"with no subcontexts\", () => {\n it(\"should provide the transaction context for a TRANSACTION_INFO context\", async () => {\n // GIVEN\n const args: ProvideTransactionContextTaskArgs = {\n context: {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"0x00\",\n certificate: {\n keyUsageNumber: 1,\n payload: new Uint8Array([1, 2, 3]),\n },\n },\n subcontextsCallbacks: [],\n serializedTransaction: new Uint8Array(),\n derivationPath: \"44'/60'/0'/0/0\",\n };\n sendCommandInChunksTaskRunMock.mockResolvedValue(successResult);\n sendPayloadInChunksRunMock.mockResolvedValue(successResult);\n api.sendCommand.mockResolvedValue(successResult);\n\n // WHEN\n const task = new ProvideTransactionContextTask(\n api,\n args,\n sendPayloadInChunksTaskMockFactory,\n sendCommandInChunksTaskMockFactory,\n );\n const result = await task.run();\n\n // THEN\n expect(result).toEqual(Right(void 0));\n\n // StoreTransactionCommand\n expect(sendCommandInChunksTaskRunMock).toHaveBeenCalledTimes(1);\n expect(sendCommandInChunksTaskMockFactory).toHaveBeenCalledWith(api, {\n data: new Uint8Array([\n 0x05, 0x80, 0x00, 0x00, 0x2c, 0x80, 0x00, 0x00, 0x3c, 0x80, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n ]),\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n commandFactory: expect.any(Function),\n });\n // Test that the commandFactory returns a StoreTransactionCommand\n const factoryCall = sendCommandInChunksTaskMockFactory.mock.calls[0]!;\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access\n const commandFactory = factoryCall[1].commandFactory;\n // arbitrary data to test the commandFactory\n const mockArgs = {\n chunkedData: new Uint8Array([1, 2, 3, 4]),\n isFirstChunk: true,\n };\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call\n const command = commandFactory(mockArgs);\n expect(command).toBeInstanceOf(StoreTransactionCommand);\n\n // LoadCertificateCommand\n expect(api.sendCommand).toHaveBeenCalledTimes(1);\n expect(api.sendCommand).toHaveBeenCalledWith(\n expect.any(LoadCertificateCommand),\n );\n\n // ProvideTransactionInformationCommand\n expect(sendPayloadInChunksRunMock).toHaveBeenCalledTimes(1);\n expect(sendPayloadInChunksRunMock).toHaveBeenCalledWith(api, {\n payload: \"0x00\",\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n commandFactory: expect.any(Function),\n });\n // Test that the commandFactory returns a ProvideTransactionInformationCommand\n const factoryCall2 = sendPayloadInChunksRunMock.mock.calls[0]!;\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access\n const commandFactory2 = factoryCall2[1].commandFactory;\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call\n const command2 = commandFactory2(mockArgs);\n expect(command2).toBeInstanceOf(ProvideTransactionInformationCommand);\n });\n\n it(\"should provide the transaction context for a TRANSACTION_INFO context without certificate\", async () => {\n // GIVEN\n const args: ProvideTransactionContextTaskArgs = {\n context: {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"0x00\",\n },\n subcontextsCallbacks: [],\n serializedTransaction: new Uint8Array(),\n derivationPath: \"44'/60'/0'/0/0\",\n };\n sendCommandInChunksTaskRunMock.mockResolvedValue(successResult);\n sendPayloadInChunksRunMock.mockResolvedValue(successResult);\n api.sendCommand.mockResolvedValue(successResult);\n\n // WHEN\n const task = new ProvideTransactionContextTask(\n api,\n args,\n sendPayloadInChunksTaskMockFactory,\n sendCommandInChunksTaskMockFactory,\n );\n const result = await task.run();\n\n // THEN\n expect(result).toEqual(Right(void 0));\n\n // StoreTransactionCommand\n expect(sendCommandInChunksTaskRunMock).toHaveBeenCalledTimes(1);\n expect(sendCommandInChunksTaskMockFactory).toHaveBeenCalledWith(api, {\n data: new Uint8Array([\n 0x05, 0x80, 0x00, 0x00, 0x2c, 0x80, 0x00, 0x00, 0x3c, 0x80, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n ]),\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n commandFactory: expect.any(Function),\n });\n // Test that the commandFactory returns a StoreTransactionCommand\n const factoryCall = sendCommandInChunksTaskMockFactory.mock.calls[0]!;\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access\n const commandFactory = factoryCall[1].commandFactory;\n // arbitrary data to test the commandFactory\n const mockArgs = {\n chunkedData: new Uint8Array([1, 2, 3, 4]),\n isFirstChunk: true,\n };\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call\n const command = commandFactory(mockArgs);\n expect(command).toBeInstanceOf(StoreTransactionCommand);\n\n // LoadCertificateCommand\n expect(api.sendCommand).toHaveBeenCalledTimes(0);\n\n // ProvideTransactionInformationCommand\n expect(sendPayloadInChunksRunMock).toHaveBeenCalledTimes(1);\n expect(sendPayloadInChunksRunMock).toHaveBeenCalledWith(api, {\n payload: \"0x00\",\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n commandFactory: expect.any(Function),\n });\n // Test that the commandFactory returns a ProvideTransactionInformationCommand\n const factoryCall2 = sendPayloadInChunksRunMock.mock.calls[0]!;\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access\n const commandFactory2 = factoryCall2[1].commandFactory;\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call\n const command2 = commandFactory2(mockArgs);\n expect(command2).toBeInstanceOf(ProvideTransactionInformationCommand);\n });\n\n it.each([\n [ClearSignContextType.PLUGIN, SetPluginCommand],\n [ClearSignContextType.EXTERNAL_PLUGIN, SetExternalPluginCommand],\n [ClearSignContextType.NFT, ProvideNFTInformationCommand],\n [ClearSignContextType.TOKEN, ProvideTokenInformationCommand],\n ] as const)(\n \"should provide the transaction context by calling sendCommand for a %s context\",\n async (contextType, commandClass) => {\n // GIVEN\n const args: ProvideTransactionContextTaskArgs = {\n context: {\n type: contextType,\n payload: \"payload\",\n },\n subcontextsCallbacks: [],\n serializedTransaction: new Uint8Array(),\n derivationPath: \"44'/60'/0'/0/0\",\n };\n api.sendCommand.mockResolvedValue(successResult);\n\n // WHEN\n const task = new ProvideTransactionContextTask(\n api,\n args,\n sendPayloadInChunksTaskMockFactory,\n sendCommandInChunksTaskMockFactory,\n );\n const result = await task.run();\n\n // THEN\n expect(result).toEqual(Right(void 0));\n expect(api.sendCommand).toHaveBeenCalledTimes(1);\n expect(api.sendCommand).toHaveBeenCalledWith(\n expect.any(commandClass),\n );\n },\n );\n\n it.each([\n [ClearSignContextType.ENUM, ProvideEnumCommand],\n [ClearSignContextType.TRUSTED_NAME, ProvideTrustedNameCommand],\n [ClearSignContextType.WEB3_CHECK, ProvideWeb3CheckCommand],\n [\n ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n ProvideTransactionFieldDescriptionCommand,\n ],\n [ClearSignContextType.PROXY_DELEGATE_CALL, ProvideProxyInfoCommand],\n ] as const)(\n \"should provide the transaction context by calling sendPayloadInChunksTask for a %s context\",\n async (contextType, commandClass) => {\n // GIVEN\n const args: ProvideTransactionContextTaskArgs = {\n context: {\n type: contextType,\n payload: \"payload\",\n } as ClearSignContextSuccess,\n subcontextsCallbacks: [],\n serializedTransaction: new Uint8Array(),\n derivationPath: \"44'/60'/0'/0/0\",\n };\n sendPayloadInChunksRunMock.mockResolvedValue(successResult);\n\n // WHEN\n const task = new ProvideTransactionContextTask(\n api,\n args,\n sendPayloadInChunksTaskMockFactory,\n sendCommandInChunksTaskMockFactory,\n );\n const result = await task.run();\n\n // THEN\n expect(result).toEqual(Right(void 0));\n expect(sendPayloadInChunksRunMock).toHaveBeenCalledTimes(1);\n expect(sendPayloadInChunksRunMock).toHaveBeenCalledWith(api, {\n payload: \"payload\",\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n commandFactory: expect.any(Function),\n });\n\n // Test that the commandFactory returns a commandClass\n const factoryCall = sendPayloadInChunksTaskMockFactory.mock.calls[0]!;\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access\n const commandFactory = factoryCall[1].commandFactory;\n const mockArgs = {\n chunkedData: new Uint8Array([1, 2, 3]),\n isFirstChunk: true,\n };\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call\n const command = commandFactory(mockArgs);\n expect(command).toBeInstanceOf(commandClass);\n },\n );\n\n it(\"should skip the subcontexts if the context is an error\", async () => {\n // GIVEN\n const args: ProvideTransactionContextTaskArgs = {\n context: {\n type: ClearSignContextType.TOKEN,\n payload: \"payload\",\n certificate: {\n keyUsageNumber: 1,\n payload: new Uint8Array([1, 2, 3]),\n },\n },\n subcontextsCallbacks: [\n () =>\n Promise.resolve({\n type: ClearSignContextType.ERROR,\n error: new Error(\"error\"),\n }),\n ],\n serializedTransaction: new Uint8Array(),\n derivationPath: \"44'/60'/0'/0/0\",\n };\n sendPayloadInChunksRunMock.mockResolvedValue(successResult);\n api.sendCommand.mockResolvedValue(successResult);\n\n // WHEN\n const task = new ProvideTransactionContextTask(\n api,\n args,\n sendPayloadInChunksTaskMockFactory,\n sendCommandInChunksTaskMockFactory,\n );\n const result = await task.run();\n\n // THEN\n expect(result).toEqual(Right(void 0));\n expect(sendPayloadInChunksRunMock).toHaveBeenCalledTimes(0);\n expect(sendCommandInChunksTaskRunMock).toHaveBeenCalledTimes(0);\n expect(api.sendCommand).toHaveBeenCalledTimes(2);\n expect(api.sendCommand).toHaveBeenNthCalledWith(\n 1,\n expect.any(LoadCertificateCommand),\n );\n expect(api.sendCommand).toHaveBeenNthCalledWith(\n 2,\n expect.any(ProvideTokenInformationCommand),\n );\n });\n });\n\n describe(\"with subcontexts\", () => {\n it(\"should provide the transaction context and subcontext for a TRANSACTION_FIELD_DESCRIPTION context\", async () => {\n // GIVEN\n const args: ProvideTransactionContextTaskArgs = {\n context: {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload\",\n },\n subcontextsCallbacks: [\n () =>\n Promise.resolve({\n type: ClearSignContextType.TOKEN,\n payload: \"payload\",\n }),\n ],\n serializedTransaction: new Uint8Array(),\n derivationPath: \"44'/60'/0'/0/0\",\n };\n sendPayloadInChunksRunMock.mockResolvedValue(successResult);\n api.sendCommand.mockResolvedValue(successResult);\n\n // WHEN\n const task = new ProvideTransactionContextTask(\n api,\n args,\n sendPayloadInChunksTaskMockFactory,\n sendCommandInChunksTaskMockFactory,\n );\n const result = await task.run();\n\n // THEN\n expect(result).toEqual(Right(void 0));\n expect(sendPayloadInChunksRunMock).toHaveBeenCalledTimes(1);\n expect(sendPayloadInChunksRunMock).toHaveBeenCalledWith(api, {\n payload: \"payload\",\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n commandFactory: expect.any(Function),\n });\n\n // Test that the commandFactory returns a commandClass\n const factoryCall = sendPayloadInChunksTaskMockFactory.mock.calls[0]!;\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access\n const commandFactory = factoryCall[1].commandFactory;\n const mockArgs = {\n chunkedData: new Uint8Array([1, 2, 3]),\n isFirstChunk: true,\n };\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call\n const command = commandFactory(mockArgs);\n expect(command).toBeInstanceOf(\n ProvideTransactionFieldDescriptionCommand,\n );\n\n expect(api.sendCommand).toHaveBeenCalledTimes(1);\n expect(api.sendCommand).toHaveBeenCalledWith(\n expect.any(ProvideTokenInformationCommand),\n );\n });\n\n it(\"should provide the transaction context and subcontexts for a TRUSTED_NAME context\", async () => {\n // GIVEN\n const args: ProvideTransactionContextTaskArgs = {\n context: {\n type: ClearSignContextType.TRUSTED_NAME,\n payload: \"payload\",\n },\n subcontextsCallbacks: [\n () =>\n Promise.resolve({\n type: ClearSignContextType.NFT,\n payload: \"payload1\",\n }),\n\n () =>\n Promise.resolve({\n type: ClearSignContextType.TOKEN,\n payload: \"payload2\",\n }),\n ],\n serializedTransaction: new Uint8Array(),\n derivationPath: \"44'/60'/0'/0/0\",\n };\n sendPayloadInChunksRunMock.mockResolvedValue(successResult);\n api.sendCommand.mockResolvedValue(successResult);\n\n // WHEN\n const task = new ProvideTransactionContextTask(\n api,\n args,\n sendPayloadInChunksTaskMockFactory,\n sendCommandInChunksTaskMockFactory,\n );\n const result = await task.run();\n\n // THEN\n expect(result).toEqual(Right(void 0));\n expect(sendPayloadInChunksRunMock).toHaveBeenCalledTimes(1);\n expect(sendPayloadInChunksRunMock).toHaveBeenCalledWith(api, {\n payload: \"payload\",\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n commandFactory: expect.any(Function),\n });\n\n // Test that the commandFactory returns a commandClass\n const factoryCall = sendPayloadInChunksTaskMockFactory.mock.calls[0]!;\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access\n const commandFactory = factoryCall[1].commandFactory;\n const mockArgs = {\n chunkedData: new Uint8Array([1, 2, 3]),\n isFirstChunk: true,\n };\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call\n const command = commandFactory(mockArgs);\n expect(command).toBeInstanceOf(ProvideTrustedNameCommand);\n\n expect(api.sendCommand).toHaveBeenCalledTimes(2);\n expect(api.sendCommand).toHaveBeenNthCalledWith(\n 1,\n expect.any(ProvideNFTInformationCommand),\n );\n expect(api.sendCommand).toHaveBeenNthCalledWith(\n 2,\n expect.any(ProvideTokenInformationCommand),\n );\n });\n });\n\n describe(\"with subcontexts and certificate\", () => {\n it(\"should provide the transaction context and subcontexts for a TRUSTED_NAME context\", async () => {\n // GIVEN\n const args: ProvideTransactionContextTaskArgs = {\n context: {\n type: ClearSignContextType.TRUSTED_NAME,\n payload: \"payload\",\n certificate: {\n keyUsageNumber: 1,\n payload: new Uint8Array([1, 2, 3]),\n },\n },\n subcontextsCallbacks: [\n () =>\n Promise.resolve({\n type: ClearSignContextType.NFT,\n payload: \"payload1\",\n certificate: {\n keyUsageNumber: 2,\n payload: new Uint8Array([4, 5, 6]),\n },\n }),\n ],\n serializedTransaction: new Uint8Array(),\n derivationPath: \"44'/60'/0'/0/0\",\n };\n sendPayloadInChunksRunMock.mockResolvedValue(successResult);\n api.sendCommand.mockResolvedValue(successResult);\n\n // WHEN\n const task = new ProvideTransactionContextTask(\n api,\n args,\n sendPayloadInChunksTaskMockFactory,\n sendCommandInChunksTaskMockFactory,\n );\n await task.run();\n\n // THEN\n expect(api.sendCommand).toHaveBeenCalledTimes(3);\n expect(api.sendCommand).toHaveBeenNthCalledWith(\n 1,\n expect.any(LoadCertificateCommand),\n );\n expect(api.sendCommand).toHaveBeenNthCalledWith(\n 2,\n expect.any(ProvideNFTInformationCommand),\n );\n expect(api.sendCommand).toHaveBeenNthCalledWith(\n 3,\n expect.any(LoadCertificateCommand),\n );\n });\n });\n\n describe(\"with error\", () => {\n it(\"should return an error if the provideContext fails\", async () => {\n // GIVEN\n const args: ProvideTransactionContextTaskArgs = {\n context: {\n type: ClearSignContextType.TOKEN,\n payload: \"payload\",\n },\n subcontextsCallbacks: [],\n serializedTransaction: new Uint8Array(),\n derivationPath: \"44'/60'/0'/0/0\",\n };\n api.sendCommand.mockResolvedValue(errorResult);\n\n // WHEN\n const task = new ProvideTransactionContextTask(\n api,\n args,\n sendPayloadInChunksTaskMockFactory,\n sendCommandInChunksTaskMockFactory,\n );\n const result = await task.run();\n\n // THEN\n expect(result).toEqual(Left(errorResult));\n });\n\n it(\"should return an error if the provide subcontext fails\", async () => {\n // GIVEN\n const args: ProvideTransactionContextTaskArgs = {\n context: {\n type: ClearSignContextType.TOKEN,\n payload: \"payload\",\n },\n subcontextsCallbacks: [\n () =>\n Promise.resolve({\n type: ClearSignContextType.TOKEN,\n payload: \"payload\",\n }),\n ],\n serializedTransaction: new Uint8Array(),\n derivationPath: \"44'/60'/0'/0/0\",\n };\n api.sendCommand.mockResolvedValue(errorResult);\n\n // WHEN\n const task = new ProvideTransactionContextTask(\n api,\n args,\n sendPayloadInChunksTaskMockFactory,\n sendCommandInChunksTaskMockFactory,\n );\n const result = await task.run();\n\n // THEN\n expect(result).toEqual(Left(errorResult));\n });\n\n it(\"should return an error if the type is not supported\", async () => {\n // GIVEN\n const args: ProvideTransactionContextTaskArgs = {\n context: {\n type: \"unsupported\" as unknown as ClearSignContextType.TOKEN,\n payload: \"payload\",\n },\n subcontextsCallbacks: [],\n serializedTransaction: new Uint8Array(),\n derivationPath: \"44'/60'/0'/0/0\",\n };\n\n // WHEN\n const task = new ProvideTransactionContextTask(\n api,\n args,\n sendPayloadInChunksTaskMockFactory,\n sendCommandInChunksTaskMockFactory,\n );\n const result = await task.run();\n\n // THEN\n expect(result).toEqual(\n Left(\n CommandResultFactory({\n error: new InvalidStatusWordError(\n `The context type [unsupported] is not covered`,\n ),\n }),\n ),\n );\n });\n });\n\n describe(\"factory types\", () => {\n it(\"should have a sendPayloadInChunksTaskFactory by default\", () => {\n // GIVEN\n const task = new ProvideTransactionContextTask(api, {\n context: {\n type: ClearSignContextType.TOKEN,\n payload: \"payload\",\n },\n subcontextsCallbacks: [],\n serializedTransaction: new Uint8Array(),\n derivationPath: \"44'/60'/0'/0/0\",\n });\n\n // THEN\n expect(task[\"_sendPayloadInChunksTaskFactory\"]).toBeDefined();\n const sendPayloadInChunksTask = task[\"_sendPayloadInChunksTaskFactory\"](\n api,\n {\n payload: \"payload\",\n commandFactory: () =>\n new ProvideTransactionFieldDescriptionCommand({\n data: new Uint8Array(),\n isFirstChunk: true,\n }),\n },\n );\n expect(sendPayloadInChunksTask).toBeInstanceOf(SendPayloadInChunksTask);\n });\n\n it(\"should have a sendCommandInChunksTaskFactory by default\", () => {\n // GIVEN\n const task = new ProvideTransactionContextTask(api, {\n context: {\n type: ClearSignContextType.TOKEN,\n payload: \"payload\",\n },\n subcontextsCallbacks: [],\n serializedTransaction: new Uint8Array(),\n derivationPath: \"44'/60'/0'/0/0\",\n });\n\n // THEN\n expect(task[\"_sendCommandInChunksTaskFactory\"]).toBeDefined();\n const sendCommandInChunksTask = task[\"_sendCommandInChunksTaskFactory\"](\n api,\n {\n data: new Uint8Array(),\n commandFactory: () =>\n new StoreTransactionCommand({\n serializedTransaction: new Uint8Array(),\n isFirstChunk: true,\n }),\n },\n );\n expect(sendCommandInChunksTask).toBeInstanceOf(SendCommandInChunksTask);\n });\n });\n });\n});\n"],
5
- "mappings": "aAAA,IAAAA,EAGO,oCACPC,EAMO,2CACPC,EAA4B,qBAE5BC,EAAmC,2DACnCC,EAA6C,qEAC7CC,EAAwC,gEACxCC,EAA+C,uEAC/CC,EAA0D,kFAC1DC,EAAqD,6EACrDC,EAA0C,kEAC1CC,EAAwC,gEACxCC,EAAyC,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AAM,IAAI,WACV,aAAc,EAChB,CAAC,CACL,CACF,EACA,OAAOiB,CAAuB,EAAE,eAAe,yBAAuB,CACxE,CAAC,EAED,GAAG,0DAA2D,IAAM,CAElE,MAAMD,EAAO,IAAI,gCAA8BhB,EAAK,CAClD,QAAS,CACP,KAAM,uBAAqB,MAC3B,QAAS,SACX,EACA,qBAAsB,CAAC,EACvB,sBAAuB,IAAI,WAC3B,eAAgB,gBAClB,CAAC,EAGD,OAAOgB,EAAK,+BAAkC,EAAE,YAAY,EAC5D,MAAME,EAA0BF,EAAK,gCACnChB,EACA,CACE,KAAM,IAAI,WACV,eAAgB,IACd,IAAI,0BAAwB,CAC1B,sBAAuB,IAAI,WAC3B,aAAc,EAChB,CAAC,CACL,CACF,EACA,OAAOkB,CAAuB,EAAE,eAAe,yBAAuB,CACxE,CAAC,CACH,CAAC,CACH,CAAC,CACH,CAAC",
6
- "names": ["import_context_module", "import_device_management_kit", "import_purify_ts", "import_ProvideEnumCommand", "import_ProvideNFTInformationCommand", "import_ProvideProxyInfoCommand", "import_ProvideTokenInformationCommand", "import_ProvideTransactionFieldDescriptionCommand", "import_ProvideTransactionInformationCommand", "import_ProvideTrustedNameCommand", "import_ProvideWeb3CheckCommand", "import_SetExternalPluginCommand", "import_SetPluginCommand", "import_StoreTransactionCommand", "import_makeInternalApi", "import_ProvideTransactionContextTask", "import_SendCommandInChunksTask", "import_SendPayloadInChunksTask", "api", "successResult", "errorResult", "sendPayloadInChunksRunMock", "sendCommandInChunksTaskRunMock", "sendCommandInChunksTaskMockFactory", "sendPayloadInChunksTaskMockFactory", "args", "result", "commandFactory", "mockArgs", "command", "commandFactory2", "command2", "contextType", "commandClass", "task", "sendPayloadInChunksTask", "sendCommandInChunksTask"]
4
+ "sourcesContent": ["import {\n type ClearSignContextSuccess,\n ClearSignContextType,\n} from \"@ledgerhq/context-module\";\nimport {\n CommandResultFactory,\n type InternalApi,\n InvalidStatusWordError,\n LoadCertificateCommand,\n type UnknownDeviceExchangeError,\n} from \"@ledgerhq/device-management-kit\";\nimport { Left, Right } from \"purify-ts\";\n\nimport { ProvideEnumCommand } from \"@internal/app-binder/command/ProvideEnumCommand\";\nimport { ProvideNetworkConfigurationCommand } from \"@internal/app-binder/command/ProvideNetworkConfigurationCommand\";\nimport { ProvideNFTInformationCommand } from \"@internal/app-binder/command/ProvideNFTInformationCommand\";\nimport { ProvideProxyInfoCommand } from \"@internal/app-binder/command/ProvideProxyInfoCommand\";\nimport { ProvideTokenInformationCommand } from \"@internal/app-binder/command/ProvideTokenInformationCommand\";\nimport { ProvideTransactionFieldDescriptionCommand } from \"@internal/app-binder/command/ProvideTransactionFieldDescriptionCommand\";\nimport { ProvideTransactionInformationCommand } from \"@internal/app-binder/command/ProvideTransactionInformationCommand\";\nimport { ProvideTrustedNameCommand } from \"@internal/app-binder/command/ProvideTrustedNameCommand\";\nimport { ProvideWeb3CheckCommand } from \"@internal/app-binder/command/ProvideWeb3CheckCommand\";\nimport { SetExternalPluginCommand } from \"@internal/app-binder/command/SetExternalPluginCommand\";\nimport { SetPluginCommand } from \"@internal/app-binder/command/SetPluginCommand\";\nimport { StoreTransactionCommand } from \"@internal/app-binder/command/StoreTransactionCommand\";\nimport { type EthErrorCodes } from \"@internal/app-binder/command/utils/ethAppErrors\";\nimport { makeDeviceActionInternalApiMock } from \"@internal/app-binder/device-action/__test-utils__/makeInternalApi\";\n\nimport {\n ProvideTransactionContextTask,\n type ProvideTransactionContextTaskArgs,\n} from \"./ProvideTransactionContextTask\";\nimport {\n SendCommandInChunksTask,\n type SendCommandInChunksTaskArgs,\n} from \"./SendCommandInChunksTask\";\nimport {\n SendPayloadInChunksTask,\n type SendPayloadInChunksTaskArgs,\n} from \"./SendPayloadInChunksTask\";\n\ndescribe(\"ProvideTransactionContextTask\", () => {\n const api = makeDeviceActionInternalApiMock();\n const successResult = CommandResultFactory<void, EthErrorCodes>({\n data: undefined,\n });\n const errorResult = CommandResultFactory<void, EthErrorCodes>({\n data: undefined,\n error: {} as UnknownDeviceExchangeError,\n });\n\n beforeEach(() => {\n vi.resetAllMocks();\n });\n\n describe(\"run\", () => {\n const sendPayloadInChunksRunMock = vi.fn();\n const sendCommandInChunksTaskRunMock = vi.fn();\n const sendCommandInChunksTaskMockFactory = vi.fn();\n const sendPayloadInChunksTaskMockFactory = vi.fn();\n\n beforeEach(() => {\n vi.clearAllMocks();\n sendCommandInChunksTaskMockFactory.mockImplementation(\n (a: InternalApi, args: SendCommandInChunksTaskArgs<unknown>) =>\n ({\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n run: () => sendCommandInChunksTaskRunMock(a, args),\n }) as unknown as SendCommandInChunksTask<unknown>,\n );\n sendPayloadInChunksTaskMockFactory.mockImplementation(\n (a: InternalApi, args: SendPayloadInChunksTaskArgs<unknown>) =>\n ({\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n run: () => sendPayloadInChunksRunMock(a, args),\n }) as unknown as SendPayloadInChunksTask<unknown>,\n );\n });\n\n describe(\"with no subcontexts\", () => {\n it(\"should provide the transaction context for a TRANSACTION_INFO context\", async () => {\n // GIVEN\n const args: ProvideTransactionContextTaskArgs = {\n context: {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"0x00\",\n certificate: {\n keyUsageNumber: 1,\n payload: new Uint8Array([1, 2, 3]),\n },\n },\n subcontextsCallbacks: [],\n serializedTransaction: new Uint8Array(),\n derivationPath: \"44'/60'/0'/0/0\",\n };\n sendCommandInChunksTaskRunMock.mockResolvedValue(successResult);\n sendPayloadInChunksRunMock.mockResolvedValue(successResult);\n api.sendCommand.mockResolvedValue(successResult);\n\n // WHEN\n const task = new ProvideTransactionContextTask(\n api,\n args,\n sendPayloadInChunksTaskMockFactory,\n sendCommandInChunksTaskMockFactory,\n );\n const result = await task.run();\n\n // THEN\n expect(result).toEqual(Right(void 0));\n\n // StoreTransactionCommand\n expect(sendCommandInChunksTaskRunMock).toHaveBeenCalledTimes(1);\n expect(sendCommandInChunksTaskMockFactory).toHaveBeenCalledWith(api, {\n data: new Uint8Array([\n 0x05, 0x80, 0x00, 0x00, 0x2c, 0x80, 0x00, 0x00, 0x3c, 0x80, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n ]),\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n commandFactory: expect.any(Function),\n });\n // Test that the commandFactory returns a StoreTransactionCommand\n const factoryCall = sendCommandInChunksTaskMockFactory.mock.calls[0]!;\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access\n const commandFactory = factoryCall[1].commandFactory;\n // arbitrary data to test the commandFactory\n const mockArgs = {\n chunkedData: new Uint8Array([1, 2, 3, 4]),\n isFirstChunk: true,\n };\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call\n const command = commandFactory(mockArgs);\n expect(command).toBeInstanceOf(StoreTransactionCommand);\n\n // LoadCertificateCommand\n expect(api.sendCommand).toHaveBeenCalledTimes(1);\n expect(api.sendCommand).toHaveBeenCalledWith(\n expect.any(LoadCertificateCommand),\n );\n\n // ProvideTransactionInformationCommand\n expect(sendPayloadInChunksRunMock).toHaveBeenCalledTimes(1);\n expect(sendPayloadInChunksRunMock).toHaveBeenCalledWith(api, {\n payload: \"0x00\",\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n commandFactory: expect.any(Function),\n });\n // Test that the commandFactory returns a ProvideTransactionInformationCommand\n const factoryCall2 = sendPayloadInChunksRunMock.mock.calls[0]!;\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access\n const commandFactory2 = factoryCall2[1].commandFactory;\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call\n const command2 = commandFactory2(mockArgs);\n expect(command2).toBeInstanceOf(ProvideTransactionInformationCommand);\n });\n\n it(\"should provide the transaction context for a TRANSACTION_INFO context without certificate\", async () => {\n // GIVEN\n const args: ProvideTransactionContextTaskArgs = {\n context: {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"0x00\",\n },\n subcontextsCallbacks: [],\n serializedTransaction: new Uint8Array(),\n derivationPath: \"44'/60'/0'/0/0\",\n };\n sendCommandInChunksTaskRunMock.mockResolvedValue(successResult);\n sendPayloadInChunksRunMock.mockResolvedValue(successResult);\n api.sendCommand.mockResolvedValue(successResult);\n\n // WHEN\n const task = new ProvideTransactionContextTask(\n api,\n args,\n sendPayloadInChunksTaskMockFactory,\n sendCommandInChunksTaskMockFactory,\n );\n const result = await task.run();\n\n // THEN\n expect(result).toEqual(Right(void 0));\n\n // StoreTransactionCommand\n expect(sendCommandInChunksTaskRunMock).toHaveBeenCalledTimes(1);\n expect(sendCommandInChunksTaskMockFactory).toHaveBeenCalledWith(api, {\n data: new Uint8Array([\n 0x05, 0x80, 0x00, 0x00, 0x2c, 0x80, 0x00, 0x00, 0x3c, 0x80, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n ]),\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n commandFactory: expect.any(Function),\n });\n // Test that the commandFactory returns a StoreTransactionCommand\n const factoryCall = sendCommandInChunksTaskMockFactory.mock.calls[0]!;\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access\n const commandFactory = factoryCall[1].commandFactory;\n // arbitrary data to test the commandFactory\n const mockArgs = {\n chunkedData: new Uint8Array([1, 2, 3, 4]),\n isFirstChunk: true,\n };\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call\n const command = commandFactory(mockArgs);\n expect(command).toBeInstanceOf(StoreTransactionCommand);\n\n // LoadCertificateCommand\n expect(api.sendCommand).toHaveBeenCalledTimes(0);\n\n // ProvideTransactionInformationCommand\n expect(sendPayloadInChunksRunMock).toHaveBeenCalledTimes(1);\n expect(sendPayloadInChunksRunMock).toHaveBeenCalledWith(api, {\n payload: \"0x00\",\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n commandFactory: expect.any(Function),\n });\n // Test that the commandFactory returns a ProvideTransactionInformationCommand\n const factoryCall2 = sendPayloadInChunksRunMock.mock.calls[0]!;\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access\n const commandFactory2 = factoryCall2[1].commandFactory;\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call\n const command2 = commandFactory2(mockArgs);\n expect(command2).toBeInstanceOf(ProvideTransactionInformationCommand);\n });\n\n it.each([\n [ClearSignContextType.PLUGIN, SetPluginCommand],\n [ClearSignContextType.EXTERNAL_PLUGIN, SetExternalPluginCommand],\n [ClearSignContextType.NFT, ProvideNFTInformationCommand],\n [ClearSignContextType.TOKEN, ProvideTokenInformationCommand],\n ] as const)(\n \"should provide the transaction context by calling sendCommand for a %s context\",\n async (contextType, commandClass) => {\n // GIVEN\n const args: ProvideTransactionContextTaskArgs = {\n context: {\n type: contextType,\n payload: \"payload\",\n },\n subcontextsCallbacks: [],\n serializedTransaction: new Uint8Array(),\n derivationPath: \"44'/60'/0'/0/0\",\n };\n api.sendCommand.mockResolvedValue(successResult);\n\n // WHEN\n const task = new ProvideTransactionContextTask(\n api,\n args,\n sendPayloadInChunksTaskMockFactory,\n sendCommandInChunksTaskMockFactory,\n );\n const result = await task.run();\n\n // THEN\n expect(result).toEqual(Right(void 0));\n expect(api.sendCommand).toHaveBeenCalledTimes(1);\n expect(api.sendCommand).toHaveBeenCalledWith(\n expect.any(commandClass),\n );\n },\n );\n\n it.each([\n [ClearSignContextType.ENUM, ProvideEnumCommand],\n [ClearSignContextType.TRUSTED_NAME, ProvideTrustedNameCommand],\n [ClearSignContextType.WEB3_CHECK, ProvideWeb3CheckCommand],\n [\n ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n ProvideTransactionFieldDescriptionCommand,\n ],\n [ClearSignContextType.PROXY_DELEGATE_CALL, ProvideProxyInfoCommand],\n [\n ClearSignContextType.DYNAMIC_NETWORK_ICON,\n ProvideNetworkConfigurationCommand,\n false,\n ],\n [\n ClearSignContextType.DYNAMIC_NETWORK,\n ProvideNetworkConfigurationCommand,\n ],\n ] as const)(\n \"should provide the transaction context by calling sendPayloadInChunksTask for a %s context\",\n async (contextType, commandClass, withPayloadLength = undefined) => {\n // GIVEN\n const args: ProvideTransactionContextTaskArgs = {\n context: {\n type: contextType,\n payload: \"payload\",\n } as ClearSignContextSuccess,\n subcontextsCallbacks: [],\n serializedTransaction: new Uint8Array(),\n derivationPath: \"44'/60'/0'/0/0\",\n };\n sendPayloadInChunksRunMock.mockResolvedValue(successResult);\n\n // WHEN\n const task = new ProvideTransactionContextTask(\n api,\n args,\n sendPayloadInChunksTaskMockFactory,\n sendCommandInChunksTaskMockFactory,\n );\n const result = await task.run();\n\n // THEN\n expect(result).toEqual(Right(void 0));\n expect(sendPayloadInChunksRunMock).toHaveBeenCalledTimes(1);\n if (withPayloadLength === undefined) {\n expect(sendPayloadInChunksRunMock).toHaveBeenCalledWith(api, {\n payload: \"payload\",\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n commandFactory: expect.any(Function),\n });\n } else {\n expect(sendPayloadInChunksRunMock).toHaveBeenCalledWith(api, {\n payload: \"payload\",\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n commandFactory: expect.any(Function),\n withPayloadLength,\n });\n }\n\n // Test that the commandFactory returns a commandClass\n const factoryCall = sendPayloadInChunksTaskMockFactory.mock.calls[0]!;\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access\n const commandFactory = factoryCall[1].commandFactory;\n const mockArgs = {\n chunkedData: new Uint8Array([1, 2, 3]),\n isFirstChunk: true,\n };\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call\n const command = commandFactory(mockArgs);\n expect(command).toBeInstanceOf(commandClass);\n },\n );\n\n it(\"should skip the subcontexts if the context is an error\", async () => {\n // GIVEN\n const args: ProvideTransactionContextTaskArgs = {\n context: {\n type: ClearSignContextType.TOKEN,\n payload: \"payload\",\n certificate: {\n keyUsageNumber: 1,\n payload: new Uint8Array([1, 2, 3]),\n },\n },\n subcontextsCallbacks: [\n () =>\n Promise.resolve({\n type: ClearSignContextType.ERROR,\n error: new Error(\"error\"),\n }),\n ],\n serializedTransaction: new Uint8Array(),\n derivationPath: \"44'/60'/0'/0/0\",\n };\n sendPayloadInChunksRunMock.mockResolvedValue(successResult);\n api.sendCommand.mockResolvedValue(successResult);\n\n // WHEN\n const task = new ProvideTransactionContextTask(\n api,\n args,\n sendPayloadInChunksTaskMockFactory,\n sendCommandInChunksTaskMockFactory,\n );\n const result = await task.run();\n\n // THEN\n expect(result).toEqual(Right(void 0));\n expect(sendPayloadInChunksRunMock).toHaveBeenCalledTimes(0);\n expect(sendCommandInChunksTaskRunMock).toHaveBeenCalledTimes(0);\n expect(api.sendCommand).toHaveBeenCalledTimes(2);\n expect(api.sendCommand).toHaveBeenNthCalledWith(\n 1,\n expect.any(LoadCertificateCommand),\n );\n expect(api.sendCommand).toHaveBeenNthCalledWith(\n 2,\n expect.any(ProvideTokenInformationCommand),\n );\n });\n });\n\n describe(\"with subcontexts\", () => {\n it(\"should provide the transaction context and subcontext for a TRANSACTION_FIELD_DESCRIPTION context\", async () => {\n // GIVEN\n const args: ProvideTransactionContextTaskArgs = {\n context: {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload\",\n },\n subcontextsCallbacks: [\n () =>\n Promise.resolve({\n type: ClearSignContextType.TOKEN,\n payload: \"payload\",\n }),\n ],\n serializedTransaction: new Uint8Array(),\n derivationPath: \"44'/60'/0'/0/0\",\n };\n sendPayloadInChunksRunMock.mockResolvedValue(successResult);\n api.sendCommand.mockResolvedValue(successResult);\n\n // WHEN\n const task = new ProvideTransactionContextTask(\n api,\n args,\n sendPayloadInChunksTaskMockFactory,\n sendCommandInChunksTaskMockFactory,\n );\n const result = await task.run();\n\n // THEN\n expect(result).toEqual(Right(void 0));\n expect(sendPayloadInChunksRunMock).toHaveBeenCalledTimes(1);\n expect(sendPayloadInChunksRunMock).toHaveBeenCalledWith(api, {\n payload: \"payload\",\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n commandFactory: expect.any(Function),\n });\n\n // Test that the commandFactory returns a commandClass\n const factoryCall = sendPayloadInChunksTaskMockFactory.mock.calls[0]!;\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access\n const commandFactory = factoryCall[1].commandFactory;\n const mockArgs = {\n chunkedData: new Uint8Array([1, 2, 3]),\n isFirstChunk: true,\n };\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call\n const command = commandFactory(mockArgs);\n expect(command).toBeInstanceOf(\n ProvideTransactionFieldDescriptionCommand,\n );\n\n expect(api.sendCommand).toHaveBeenCalledTimes(1);\n expect(api.sendCommand).toHaveBeenCalledWith(\n expect.any(ProvideTokenInformationCommand),\n );\n });\n\n it(\"should provide the transaction context and subcontexts for a TRUSTED_NAME context\", async () => {\n // GIVEN\n const args: ProvideTransactionContextTaskArgs = {\n context: {\n type: ClearSignContextType.TRUSTED_NAME,\n payload: \"payload\",\n },\n subcontextsCallbacks: [\n () =>\n Promise.resolve({\n type: ClearSignContextType.NFT,\n payload: \"payload1\",\n }),\n\n () =>\n Promise.resolve({\n type: ClearSignContextType.TOKEN,\n payload: \"payload2\",\n }),\n ],\n serializedTransaction: new Uint8Array(),\n derivationPath: \"44'/60'/0'/0/0\",\n };\n sendPayloadInChunksRunMock.mockResolvedValue(successResult);\n api.sendCommand.mockResolvedValue(successResult);\n\n // WHEN\n const task = new ProvideTransactionContextTask(\n api,\n args,\n sendPayloadInChunksTaskMockFactory,\n sendCommandInChunksTaskMockFactory,\n );\n const result = await task.run();\n\n // THEN\n expect(result).toEqual(Right(void 0));\n expect(sendPayloadInChunksRunMock).toHaveBeenCalledTimes(1);\n expect(sendPayloadInChunksRunMock).toHaveBeenCalledWith(api, {\n payload: \"payload\",\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n commandFactory: expect.any(Function),\n });\n\n // Test that the commandFactory returns a commandClass\n const factoryCall = sendPayloadInChunksTaskMockFactory.mock.calls[0]!;\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access\n const commandFactory = factoryCall[1].commandFactory;\n const mockArgs = {\n chunkedData: new Uint8Array([1, 2, 3]),\n isFirstChunk: true,\n };\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call\n const command = commandFactory(mockArgs);\n expect(command).toBeInstanceOf(ProvideTrustedNameCommand);\n\n expect(api.sendCommand).toHaveBeenCalledTimes(2);\n expect(api.sendCommand).toHaveBeenNthCalledWith(\n 1,\n expect.any(ProvideNFTInformationCommand),\n );\n expect(api.sendCommand).toHaveBeenNthCalledWith(\n 2,\n expect.any(ProvideTokenInformationCommand),\n );\n });\n });\n\n describe(\"with subcontexts and certificate\", () => {\n it(\"should provide the transaction context and subcontexts for a TRUSTED_NAME context\", async () => {\n // GIVEN\n const args: ProvideTransactionContextTaskArgs = {\n context: {\n type: ClearSignContextType.TRUSTED_NAME,\n payload: \"payload\",\n certificate: {\n keyUsageNumber: 1,\n payload: new Uint8Array([1, 2, 3]),\n },\n },\n subcontextsCallbacks: [\n () =>\n Promise.resolve({\n type: ClearSignContextType.NFT,\n payload: \"payload1\",\n certificate: {\n keyUsageNumber: 2,\n payload: new Uint8Array([4, 5, 6]),\n },\n }),\n ],\n serializedTransaction: new Uint8Array(),\n derivationPath: \"44'/60'/0'/0/0\",\n };\n sendPayloadInChunksRunMock.mockResolvedValue(successResult);\n api.sendCommand.mockResolvedValue(successResult);\n\n // WHEN\n const task = new ProvideTransactionContextTask(\n api,\n args,\n sendPayloadInChunksTaskMockFactory,\n sendCommandInChunksTaskMockFactory,\n );\n await task.run();\n\n // THEN\n expect(api.sendCommand).toHaveBeenCalledTimes(3);\n expect(api.sendCommand).toHaveBeenNthCalledWith(\n 1,\n expect.any(LoadCertificateCommand),\n );\n expect(api.sendCommand).toHaveBeenNthCalledWith(\n 2,\n expect.any(ProvideNFTInformationCommand),\n );\n expect(api.sendCommand).toHaveBeenNthCalledWith(\n 3,\n expect.any(LoadCertificateCommand),\n );\n });\n });\n\n describe(\"with error\", () => {\n it(\"should return an error if the provideContext fails\", async () => {\n // GIVEN\n const args: ProvideTransactionContextTaskArgs = {\n context: {\n type: ClearSignContextType.TOKEN,\n payload: \"payload\",\n },\n subcontextsCallbacks: [],\n serializedTransaction: new Uint8Array(),\n derivationPath: \"44'/60'/0'/0/0\",\n };\n api.sendCommand.mockResolvedValue(errorResult);\n\n // WHEN\n const task = new ProvideTransactionContextTask(\n api,\n args,\n sendPayloadInChunksTaskMockFactory,\n sendCommandInChunksTaskMockFactory,\n );\n const result = await task.run();\n\n // THEN\n expect(result).toEqual(Left(errorResult));\n });\n\n it(\"should return an error if the provide subcontext fails\", async () => {\n // GIVEN\n const args: ProvideTransactionContextTaskArgs = {\n context: {\n type: ClearSignContextType.TOKEN,\n payload: \"payload\",\n },\n subcontextsCallbacks: [\n () =>\n Promise.resolve({\n type: ClearSignContextType.TOKEN,\n payload: \"payload\",\n }),\n ],\n serializedTransaction: new Uint8Array(),\n derivationPath: \"44'/60'/0'/0/0\",\n };\n api.sendCommand.mockResolvedValue(errorResult);\n\n // WHEN\n const task = new ProvideTransactionContextTask(\n api,\n args,\n sendPayloadInChunksTaskMockFactory,\n sendCommandInChunksTaskMockFactory,\n );\n const result = await task.run();\n\n // THEN\n expect(result).toEqual(Left(errorResult));\n });\n\n it(\"should return an error if the type is not supported\", async () => {\n // GIVEN\n const args: ProvideTransactionContextTaskArgs = {\n context: {\n type: \"unsupported\" as unknown as ClearSignContextType.TOKEN,\n payload: \"payload\",\n },\n subcontextsCallbacks: [],\n serializedTransaction: new Uint8Array(),\n derivationPath: \"44'/60'/0'/0/0\",\n };\n\n // WHEN\n const task = new ProvideTransactionContextTask(\n api,\n args,\n sendPayloadInChunksTaskMockFactory,\n sendCommandInChunksTaskMockFactory,\n );\n const result = await task.run();\n\n // THEN\n expect(result).toEqual(\n Left(\n CommandResultFactory({\n error: new InvalidStatusWordError(\n `The context type [unsupported] is not covered`,\n ),\n }),\n ),\n );\n });\n });\n\n describe(\"factory types\", () => {\n it(\"should have a sendPayloadInChunksTaskFactory by default\", () => {\n // GIVEN\n const task = new ProvideTransactionContextTask(api, {\n context: {\n type: ClearSignContextType.TOKEN,\n payload: \"payload\",\n },\n subcontextsCallbacks: [],\n serializedTransaction: new Uint8Array(),\n derivationPath: \"44'/60'/0'/0/0\",\n });\n\n // THEN\n expect(task[\"_sendPayloadInChunksTaskFactory\"]).toBeDefined();\n const sendPayloadInChunksTask = task[\"_sendPayloadInChunksTaskFactory\"](\n api,\n {\n payload: \"payload\",\n commandFactory: () =>\n new ProvideTransactionFieldDescriptionCommand({\n data: new Uint8Array(),\n isFirstChunk: true,\n }),\n },\n );\n expect(sendPayloadInChunksTask).toBeInstanceOf(SendPayloadInChunksTask);\n });\n\n it(\"should have a sendCommandInChunksTaskFactory by default\", () => {\n // GIVEN\n const task = new ProvideTransactionContextTask(api, {\n context: {\n type: ClearSignContextType.TOKEN,\n payload: \"payload\",\n },\n subcontextsCallbacks: [],\n serializedTransaction: new Uint8Array(),\n derivationPath: \"44'/60'/0'/0/0\",\n });\n\n // THEN\n expect(task[\"_sendCommandInChunksTaskFactory\"]).toBeDefined();\n const sendCommandInChunksTask = task[\"_sendCommandInChunksTaskFactory\"](\n api,\n {\n data: new Uint8Array(),\n commandFactory: () =>\n new StoreTransactionCommand({\n serializedTransaction: new Uint8Array(),\n isFirstChunk: true,\n }),\n },\n );\n expect(sendCommandInChunksTask).toBeInstanceOf(SendCommandInChunksTask);\n });\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AAE,WACb,WACE,wBAAqB,CACnB,MAAO,IAAI,yBACT,+CACF,CACF,CAAC,CACH,CACF,CACF,CAAC,CACH,CAAC,EAED,SAAS,gBAAiB,IAAM,CAC9B,GAAG,0DAA2D,IAAM,CAElE,MAAMS,EAAO,IAAI,gCAA8BjB,EAAK,CAClD,QAAS,CACP,KAAM,uBAAqB,MAC3B,QAAS,SACX,EACA,qBAAsB,CAAC,EACvB,sBAAuB,IAAI,WAC3B,eAAgB,gBAClB,CAAC,EAGD,OAAOiB,EAAK,+BAAkC,EAAE,YAAY,EAC5D,MAAMC,EAA0BD,EAAK,gCACnCjB,EACA,CACE,QAAS,UACT,eAAgB,IACd,IAAI,4CAA0C,CAC5C,KAAM,IAAI,WACV,aAAc,EAChB,CAAC,CACL,CACF,EACA,OAAOkB,CAAuB,EAAE,eAAe,yBAAuB,CACxE,CAAC,EAED,GAAG,0DAA2D,IAAM,CAElE,MAAMD,EAAO,IAAI,gCAA8BjB,EAAK,CAClD,QAAS,CACP,KAAM,uBAAqB,MAC3B,QAAS,SACX,EACA,qBAAsB,CAAC,EACvB,sBAAuB,IAAI,WAC3B,eAAgB,gBAClB,CAAC,EAGD,OAAOiB,EAAK,+BAAkC,EAAE,YAAY,EAC5D,MAAME,EAA0BF,EAAK,gCACnCjB,EACA,CACE,KAAM,IAAI,WACV,eAAgB,IACd,IAAI,0BAAwB,CAC1B,sBAAuB,IAAI,WAC3B,aAAc,EAChB,CAAC,CACL,CACF,EACA,OAAOmB,CAAuB,EAAE,eAAe,yBAAuB,CACxE,CAAC,CACH,CAAC,CACH,CAAC,CACH,CAAC",
6
+ "names": ["import_context_module", "import_device_management_kit", "import_purify_ts", "import_ProvideEnumCommand", "import_ProvideNetworkConfigurationCommand", "import_ProvideNFTInformationCommand", "import_ProvideProxyInfoCommand", "import_ProvideTokenInformationCommand", "import_ProvideTransactionFieldDescriptionCommand", "import_ProvideTransactionInformationCommand", "import_ProvideTrustedNameCommand", "import_ProvideWeb3CheckCommand", "import_SetExternalPluginCommand", "import_SetPluginCommand", "import_StoreTransactionCommand", "import_makeInternalApi", "import_ProvideTransactionContextTask", "import_SendCommandInChunksTask", "import_SendPayloadInChunksTask", "api", "successResult", "errorResult", "sendPayloadInChunksRunMock", "sendCommandInChunksTaskRunMock", "sendCommandInChunksTaskMockFactory", "sendPayloadInChunksTaskMockFactory", "args", "result", "commandFactory", "mockArgs", "command", "commandFactory2", "command2", "contextType", "commandClass", "withPayloadLength", "task", "sendPayloadInChunksTask", "sendCommandInChunksTask"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var s=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var i=Object.getOwnPropertyNames;var y=Object.prototype.hasOwnProperty;var l=(r,a)=>{for(var o in a)s(r,o,{get:a[o],enumerable:!0})},u=(r,a,o,d)=>{if(a&&typeof a=="object"||typeof a=="function")for(let n of i(a))!y.call(r,n)&&n!==o&&s(r,n,{get:()=>a[n],enumerable:!(d=p(a,n))||d.enumerable});return r};var c=r=>u(s({},"__esModule",{value:!0}),r);var k={};l(k,{SendPayloadInChunksTask:()=>C});module.exports=c(k);var t=require("@ledgerhq/device-management-kit"),e=require("../../shared/utils/PayloadUtils"),m=require("./SendCommandInChunksTask");class C{constructor(a,o){this.api=a;this.args=o}async run(){const a=e.PayloadUtils.getBufferFromPayload(this.args.payload);return a?new m.SendCommandInChunksTask(this.api,{data:a,commandFactory:this.args.commandFactory}).run():(0,t.CommandResultFactory)({error:new t.InvalidStatusWordError("Invalid payload")})}}0&&(module.exports={SendPayloadInChunksTask});
1
+ "use strict";var s=Object.defineProperty;var l=Object.getOwnPropertyDescriptor;var i=Object.getOwnPropertyNames;var y=Object.prototype.hasOwnProperty;var p=(r,a)=>{for(var n in a)s(r,n,{get:a[n],enumerable:!0})},u=(r,a,n,o)=>{if(a&&typeof a=="object"||typeof a=="function")for(let e of i(a))!y.call(r,e)&&e!==n&&s(r,e,{get:()=>a[e],enumerable:!(o=l(a,e))||o.enumerable});return r};var h=r=>u(s({},"__esModule",{value:!0}),r);var C={};p(C,{SendPayloadInChunksTask:()=>c});module.exports=h(C);var t=require("@ledgerhq/device-management-kit"),d=require("../../shared/utils/PayloadUtils"),m=require("./SendCommandInChunksTask");class c{constructor(a,n){this.api=a;this.args=n}async run(){const{payload:a,withPayloadLength:n=!0}=this.args;let o=null;return n?o=d.PayloadUtils.getBufferFromPayload(a):o=(0,t.hexaStringToBuffer)(a),o?new m.SendCommandInChunksTask(this.api,{data:o,commandFactory:this.args.commandFactory}).run():(0,t.CommandResultFactory)({error:new t.InvalidStatusWordError("Invalid payload")})}}0&&(module.exports={SendPayloadInChunksTask});
2
2
  //# sourceMappingURL=SendPayloadInChunksTask.js.map