@ledgerhq/device-signer-kit-ethereum 0.0.0-signer-eth-plugin-fix-20250331141239 → 0.0.0-try-to-fix-20250429171448

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 (36) hide show
  1. package/lib/cjs/api/SignerEthBuilder.js +1 -1
  2. package/lib/cjs/api/SignerEthBuilder.js.map +3 -3
  3. package/lib/cjs/api/SignerEthBuilder.test.js +1 -1
  4. package/lib/cjs/api/SignerEthBuilder.test.js.map +3 -3
  5. package/lib/cjs/internal/app-binder/constant/plugins.js +1 -1
  6. package/lib/cjs/internal/app-binder/constant/plugins.js.map +2 -2
  7. package/lib/cjs/internal/app-binder/task/ProvideTransactionContextTask.js +1 -1
  8. package/lib/cjs/internal/app-binder/task/ProvideTransactionContextTask.js.map +3 -3
  9. package/lib/cjs/internal/app-binder/task/ProvideTransactionContextTask.test.js +1 -1
  10. package/lib/cjs/internal/app-binder/task/ProvideTransactionContextTask.test.js.map +3 -3
  11. package/lib/cjs/internal/shared/utils/ApplicationChecker.js +1 -1
  12. package/lib/cjs/internal/shared/utils/ApplicationChecker.js.map +2 -2
  13. package/lib/cjs/internal/shared/utils/ApplicationChecker.test.js +1 -1
  14. package/lib/cjs/internal/shared/utils/ApplicationChecker.test.js.map +2 -2
  15. package/lib/cjs/package.json +1 -1
  16. package/lib/esm/api/SignerEthBuilder.js +1 -1
  17. package/lib/esm/api/SignerEthBuilder.js.map +3 -3
  18. package/lib/esm/api/SignerEthBuilder.test.js +1 -1
  19. package/lib/esm/api/SignerEthBuilder.test.js.map +3 -3
  20. package/lib/esm/internal/app-binder/constant/plugins.js +1 -1
  21. package/lib/esm/internal/app-binder/constant/plugins.js.map +2 -2
  22. package/lib/esm/internal/app-binder/task/ProvideTransactionContextTask.js +1 -1
  23. package/lib/esm/internal/app-binder/task/ProvideTransactionContextTask.js.map +3 -3
  24. package/lib/esm/internal/app-binder/task/ProvideTransactionContextTask.test.js +1 -1
  25. package/lib/esm/internal/app-binder/task/ProvideTransactionContextTask.test.js.map +3 -3
  26. package/lib/esm/internal/shared/utils/ApplicationChecker.js +1 -1
  27. package/lib/esm/internal/shared/utils/ApplicationChecker.js.map +2 -2
  28. package/lib/esm/internal/shared/utils/ApplicationChecker.test.js +1 -1
  29. package/lib/esm/internal/shared/utils/ApplicationChecker.test.js.map +2 -2
  30. package/lib/esm/package.json +1 -1
  31. package/lib/types/api/SignerEthBuilder.d.ts +4 -2
  32. package/lib/types/api/SignerEthBuilder.d.ts.map +1 -1
  33. package/lib/types/internal/app-binder/constant/plugins.d.ts.map +1 -1
  34. package/lib/types/internal/shared/utils/ApplicationChecker.d.ts.map +1 -1
  35. package/lib/types/tsconfig.prod.tsbuildinfo +1 -1
  36. package/package.json +6 -6
@@ -1,2 +1,2 @@
1
- "use strict";var s=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var c=Object.prototype.hasOwnProperty;var m=(t,e)=>{for(var i in e)s(t,i,{get:e[i],enumerable:!0})},h=(t,e,i,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of l(e))!c.call(t,o)&&o!==i&&s(t,o,{get:()=>e[o],enumerable:!(n=u(e,o))||n.enumerable});return t};var M=t=>h(s({},"__esModule",{value:!0}),t);var a={};m(a,{SignerEthBuilder:()=>p});module.exports=M(a);var r=require("@ledgerhq/context-module"),d=require("../internal/DefaultSignerEth");class p{_dmk;_sessionId;_contextModule;constructor({dmk:e,sessionId:i}){this._dmk=e,this._sessionId=i,this._contextModule=new r.ContextModuleBuilder().build()}withContextModule(e){return this._contextModule=e,this}build(){return new d.DefaultSignerEth({dmk:this._dmk,sessionId:this._sessionId,contextModule:this._contextModule})}}0&&(module.exports={SignerEthBuilder});
1
+ "use strict";var s=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var c=Object.prototype.hasOwnProperty;var m=(t,e)=>{for(var i in e)s(t,i,{get:e[i],enumerable:!0})},g=(t,e,i,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of l(e))!c.call(t,o)&&o!==i&&s(t,o,{get:()=>e[o],enumerable:!(n=u(e,o))||n.enumerable});return t};var h=t=>g(s({},"__esModule",{value:!0}),t);var a={};m(a,{SignerEthBuilder:()=>p});module.exports=h(a);var r=require("@ledgerhq/context-module"),d=require("../internal/DefaultSignerEth");class p{_dmk;_sessionId;_customContextModule;_originToken;constructor({dmk:e,sessionId:i,originToken:n}){this._dmk=e,this._sessionId=i,this._originToken=n}withContextModule(e){return this._customContextModule=e,this}build(){const e=this._customContextModule??new r.ContextModuleBuilder({originToken:this._originToken}).build();return new d.DefaultSignerEth({dmk:this._dmk,sessionId:this._sessionId,contextModule:e})}}0&&(module.exports={SignerEthBuilder});
2
2
  //# sourceMappingURL=SignerEthBuilder.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/api/SignerEthBuilder.ts"],
4
- "sourcesContent": ["import {\n type ContextModule,\n ContextModuleBuilder,\n} from \"@ledgerhq/context-module\";\nimport {\n type DeviceManagementKit,\n type DeviceSessionId,\n} from \"@ledgerhq/device-management-kit\";\n\nimport { DefaultSignerEth } from \"@internal/DefaultSignerEth\";\n\ntype SignerEthBuilderConstructorArgs = {\n dmk: DeviceManagementKit;\n sessionId: DeviceSessionId;\n};\n\n/**\n * Builder for the `SignerEth` class.\n *\n * @example\n * ```\n * const dmk = new SignerEthBuilder(dmk)\n * .build();\n * ```\n */\nexport class SignerEthBuilder {\n private _dmk: DeviceManagementKit;\n private _sessionId: DeviceSessionId;\n private _contextModule: ContextModule;\n\n constructor({ dmk, sessionId }: SignerEthBuilderConstructorArgs) {\n this._dmk = dmk;\n this._sessionId = sessionId;\n // default context module for ETH\n this._contextModule = new ContextModuleBuilder().build();\n }\n\n /**\n * Override the default context module\n *\n * @param contextModule\n * @returns this\n */\n withContextModule(contextModule: ContextModule) {\n this._contextModule = contextModule;\n return this;\n }\n\n /**\n * Build the ethereum signer\n *\n * @returns the ethereum signer\n */\n public build() {\n return new DefaultSignerEth({\n dmk: this._dmk,\n sessionId: this._sessionId,\n contextModule: this._contextModule,\n });\n }\n}\n"],
5
- "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,sBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAGO,oCAMPC,EAAiC,sCAgB1B,MAAMH,CAAiB,CACpB,KACA,WACA,eAER,YAAY,CAAE,IAAAI,EAAK,UAAAC,CAAU,EAAoC,CAC/D,KAAK,KAAOD,EACZ,KAAK,WAAaC,EAElB,KAAK,eAAiB,IAAI,uBAAqB,EAAE,MAAM,CACzD,CAQA,kBAAkBC,EAA8B,CAC9C,YAAK,eAAiBA,EACf,IACT,CAOO,OAAQ,CACb,OAAO,IAAI,mBAAiB,CAC1B,IAAK,KAAK,KACV,UAAW,KAAK,WAChB,cAAe,KAAK,cACtB,CAAC,CACH,CACF",
6
- "names": ["SignerEthBuilder_exports", "__export", "SignerEthBuilder", "__toCommonJS", "import_context_module", "import_DefaultSignerEth", "dmk", "sessionId", "contextModule"]
4
+ "sourcesContent": ["import {\n type ContextModule,\n ContextModuleBuilder,\n} from \"@ledgerhq/context-module\";\nimport {\n type DeviceManagementKit,\n type DeviceSessionId,\n} from \"@ledgerhq/device-management-kit\";\n\nimport { DefaultSignerEth } from \"@internal/DefaultSignerEth\";\n\ntype SignerEthBuilderConstructorArgs = {\n dmk: DeviceManagementKit;\n sessionId: DeviceSessionId;\n originToken?: string;\n};\n\n/**\n * Builder for the `SignerEth` class.\n *\n * @example\n * ```\n * const dmk = new SignerEthBuilder(dmk)\n * .build();\n * ```\n */\nexport class SignerEthBuilder {\n private _dmk: DeviceManagementKit;\n private _sessionId: DeviceSessionId;\n private _customContextModule: ContextModule | undefined;\n private _originToken: string | undefined;\n\n constructor({\n dmk,\n sessionId,\n originToken,\n }: SignerEthBuilderConstructorArgs) {\n this._dmk = dmk;\n this._sessionId = sessionId;\n this._originToken = originToken;\n }\n\n /**\n * Override the default context module\n *\n * @param contextModule\n * @returns this\n */\n withContextModule(contextModule: ContextModule) {\n this._customContextModule = contextModule;\n return this;\n }\n\n /**\n * Build the ethereum signer\n *\n * @returns the ethereum signer\n */\n public build() {\n const contextModule =\n this._customContextModule ??\n new ContextModuleBuilder({ originToken: this._originToken }).build();\n\n return new DefaultSignerEth({\n dmk: this._dmk,\n sessionId: this._sessionId,\n contextModule,\n });\n }\n}\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,sBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAGO,oCAMPC,EAAiC,sCAiB1B,MAAMH,CAAiB,CACpB,KACA,WACA,qBACA,aAER,YAAY,CACV,IAAAI,EACA,UAAAC,EACA,YAAAC,CACF,EAAoC,CAClC,KAAK,KAAOF,EACZ,KAAK,WAAaC,EAClB,KAAK,aAAeC,CACtB,CAQA,kBAAkBC,EAA8B,CAC9C,YAAK,qBAAuBA,EACrB,IACT,CAOO,OAAQ,CACb,MAAMA,EACJ,KAAK,sBACL,IAAI,uBAAqB,CAAE,YAAa,KAAK,YAAa,CAAC,EAAE,MAAM,EAErE,OAAO,IAAI,mBAAiB,CAC1B,IAAK,KAAK,KACV,UAAW,KAAK,WAChB,cAAAA,CACF,CAAC,CACH,CACF",
6
+ "names": ["SignerEthBuilder_exports", "__export", "SignerEthBuilder", "__toCommonJS", "import_context_module", "import_DefaultSignerEth", "dmk", "sessionId", "originToken", "contextModule"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var t=require("./SignerEthBuilder");describe("SignerEthBuilder",()=>{const o={};test("should be an instance of SignerEth",()=>{const e=new t.SignerEthBuilder({dmk:o,sessionId:""});e.build(),expect(e).toBeInstanceOf(t.SignerEthBuilder)}),test("should instanciate with default context module",()=>{const e=new t.SignerEthBuilder({dmk:o,sessionId:""});e.build(),expect(e._contextModule).toBeDefined(),expect(e._contextModule._loaders).toHaveLength(6)}),test("should instanciate with custom context module",()=>{const e=new t.SignerEthBuilder({dmk:o,sessionId:""}),n={};e.withContextModule(n).build(),expect(e._contextModule).toBe(n)})});
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)})});
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 {\n type ContextLoader,\n type ContextModule,\n} from \"@ledgerhq/context-module\";\nimport { type DeviceManagementKit } from \"@ledgerhq/device-management-kit\";\n\nimport { SignerEthBuilder } from \"@api/SignerEthBuilder\";\n\ndescribe(\"SignerEthBuilder\", () => {\n const dmk: DeviceManagementKit = {} as DeviceManagementKit;\n\n test(\"should be an instance of SignerEth\", () => {\n // GIVEN\n const builder = new SignerEthBuilder({ dmk, sessionId: \"\" });\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({ dmk, sessionId: \"\" });\n\n // WHEN\n builder.build();\n\n // THEN\n expect(builder[\"_contextModule\"]).toBeDefined();\n expect(\n (builder[\"_contextModule\"] as unknown as { _loaders: ContextLoader[] })\n ._loaders,\n ).toHaveLength(6);\n });\n\n test(\"should instanciate with custom context module\", () => {\n // GIVEN\n const builder = new SignerEthBuilder({ dmk, sessionId: \"\" });\n const contextModule = {} as ContextModule;\n\n // WHEN\n builder.withContextModule(contextModule).build();\n\n // THEN\n expect(builder[\"_contextModule\"]).toBe(contextModule);\n });\n});\n"],
5
- "mappings": "aAMA,IAAAA,EAAiC,iCAEjC,SAAS,mBAAoB,IAAM,CACjC,MAAMC,EAA2B,CAAC,EAElC,KAAK,qCAAsC,IAAM,CAE/C,MAAMC,EAAU,IAAI,mBAAiB,CAAE,IAAAD,EAAK,UAAW,EAAG,CAAC,EAG3DC,EAAQ,MAAM,EAGd,OAAOA,CAAO,EAAE,eAAe,kBAAgB,CACjD,CAAC,EAED,KAAK,iDAAkD,IAAM,CAE3D,MAAMA,EAAU,IAAI,mBAAiB,CAAE,IAAAD,EAAK,UAAW,EAAG,CAAC,EAG3DC,EAAQ,MAAM,EAGd,OAAOA,EAAQ,cAAiB,EAAE,YAAY,EAC9C,OACGA,EAAQ,eACN,QACL,EAAE,aAAa,CAAC,CAClB,CAAC,EAED,KAAK,gDAAiD,IAAM,CAE1D,MAAMA,EAAU,IAAI,mBAAiB,CAAE,IAAAD,EAAK,UAAW,EAAG,CAAC,EACrDE,EAAgB,CAAC,EAGvBD,EAAQ,kBAAkBC,CAAa,EAAE,MAAM,EAG/C,OAAOD,EAAQ,cAAiB,EAAE,KAAKC,CAAa,CACtD,CAAC,CACH,CAAC",
6
- "names": ["import_SignerEthBuilder", "dmk", "builder", "contextModule"]
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"],
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
+ "names": ["import_SignerEthBuilder", "import_DefaultSignerEth", "import_externalTypes", "defaultConstructorArgs", "builder", "signer", "contextModule"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var r=Object.defineProperty;var t=Object.getOwnPropertyDescriptor;var s=Object.getOwnPropertyNames;var l=Object.prototype.hasOwnProperty;var c=(a,e)=>{for(var o in e)r(a,o,{get:e[o],enumerable:!0})},p=(a,e,o,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of s(e))!l.call(a,i)&&i!==o&&r(a,i,{get:()=>e[i],enumerable:!(n=t(e,i))||n.enumerable});return a};var S=a=>p(r({},"__esModule",{value:!0}),a);var A={};c(A,{ETHEREUM_PLUGINS:()=>k});module.exports=S(A);const k=["1inch","Aave","Alkemi","Angle","APWine","ArtBlocks","Brick Towers","capsa","cBridge","ChorusOne","CIAN","Coinbase","Cometh","Compound","DODO","EigenLayer","ENS","Figment","Harvest","Kelp","Kiln","Lens","libertify","Lido","[ L ] Market","Midas","Morpho","Nested","OKX Web3","OpenSea","P2P.org","Paraswap","POAP","QuickSwap","Rarible","Ribbon","Ricochet","Rocket Pool","Spool","Squid","Staderlabs","StakeDAO","StakeKit","Swell","Thales","Yearn","Uniswap"];0&&(module.exports={ETHEREUM_PLUGINS});
1
+ "use strict";var n=Object.defineProperty;var t=Object.getOwnPropertyDescriptor;var s=Object.getOwnPropertyNames;var l=Object.prototype.hasOwnProperty;var c=(a,e)=>{for(var o in e)n(a,o,{get:e[o],enumerable:!0})},p=(a,e,o,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of s(e))!l.call(a,i)&&i!==o&&n(a,i,{get:()=>e[i],enumerable:!(r=t(e,i))||r.enumerable});return a};var S=a=>p(n({},"__esModule",{value:!0}),a);var A={};c(A,{ETHEREUM_PLUGINS:()=>k});module.exports=S(A);const k=["1inch","Aave","Alkemi","Angle","APWine","ArtBlocks","Brick Towers","capsa","cBridge","ChorusOne","CIAN","Coinbase","Cometh","Compound","DODO","EigenLayer","ENS","Figment","Harvest","Kelp","Kiln","Lens","libertify","Lido","[ L ] Market","Midas","Morpho","Nested","OKX Web3","OpenSea","P2P.org","Paraswap","POAP","QuickSwap","Rarible","Ribbon","Ricochet","Rocket Pool","Spool","Squid","Staderlabs","StakeDAO","StakeKit","Swell","Thales","Yearn","Uniswap","Exchange"];0&&(module.exports={ETHEREUM_PLUGINS});
2
2
  //# sourceMappingURL=plugins.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/internal/app-binder/constant/plugins.ts"],
4
- "sourcesContent": ["export const ETHEREUM_PLUGINS: string[] = [\n \"1inch\",\n \"Aave\",\n \"Alkemi\",\n \"Angle\",\n \"APWine\",\n \"ArtBlocks\",\n \"Brick Towers\",\n \"capsa\",\n \"cBridge\",\n \"ChorusOne\",\n \"CIAN\",\n \"Coinbase\",\n \"Cometh\",\n \"Compound\",\n \"DODO\",\n \"EigenLayer\",\n \"ENS\",\n \"Figment\",\n \"Harvest\",\n \"Kelp\",\n \"Kiln\",\n \"Lens\",\n \"libertify\",\n \"Lido\",\n \"[ L ] Market\",\n \"Midas\",\n \"Morpho\",\n \"Nested\",\n \"OKX Web3\",\n \"OpenSea\",\n \"P2P.org\",\n \"Paraswap\",\n \"POAP\",\n \"QuickSwap\",\n \"Rarible\",\n \"Ribbon\",\n \"Ricochet\",\n \"Rocket Pool\",\n \"Spool\",\n \"Squid\",\n \"Staderlabs\",\n \"StakeDAO\",\n \"StakeKit\",\n \"Swell\",\n \"Thales\",\n \"Yearn\",\n \"Uniswap\",\n];\n"],
5
- "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,sBAAAE,IAAA,eAAAC,EAAAH,GAAO,MAAME,EAA6B,CACxC,QACA,OACA,SACA,QACA,SACA,YACA,eACA,QACA,UACA,YACA,OACA,WACA,SACA,WACA,OACA,aACA,MACA,UACA,UACA,OACA,OACA,OACA,YACA,OACA,eACA,QACA,SACA,SACA,WACA,UACA,UACA,WACA,OACA,YACA,UACA,SACA,WACA,cACA,QACA,QACA,aACA,WACA,WACA,QACA,SACA,QACA,SACF",
4
+ "sourcesContent": ["export const ETHEREUM_PLUGINS: string[] = [\n \"1inch\",\n \"Aave\",\n \"Alkemi\",\n \"Angle\",\n \"APWine\",\n \"ArtBlocks\",\n \"Brick Towers\",\n \"capsa\",\n \"cBridge\",\n \"ChorusOne\",\n \"CIAN\",\n \"Coinbase\",\n \"Cometh\",\n \"Compound\",\n \"DODO\",\n \"EigenLayer\",\n \"ENS\",\n \"Figment\",\n \"Harvest\",\n \"Kelp\",\n \"Kiln\",\n \"Lens\",\n \"libertify\",\n \"Lido\",\n \"[ L ] Market\",\n \"Midas\",\n \"Morpho\",\n \"Nested\",\n \"OKX Web3\",\n \"OpenSea\",\n \"P2P.org\",\n \"Paraswap\",\n \"POAP\",\n \"QuickSwap\",\n \"Rarible\",\n \"Ribbon\",\n \"Ricochet\",\n \"Rocket Pool\",\n \"Spool\",\n \"Squid\",\n \"Staderlabs\",\n \"StakeDAO\",\n \"StakeKit\",\n \"Swell\",\n \"Thales\",\n \"Yearn\",\n \"Uniswap\",\n \"Exchange\", // Not a plugin, but a compatible app during exchange flows\n];\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,sBAAAE,IAAA,eAAAC,EAAAH,GAAO,MAAME,EAA6B,CACxC,QACA,OACA,SACA,QACA,SACA,YACA,eACA,QACA,UACA,YACA,OACA,WACA,SACA,WACA,OACA,aACA,MACA,UACA,UACA,OACA,OACA,OACA,YACA,OACA,eACA,QACA,SACA,SACA,WACA,UACA,UACA,WACA,OACA,YACA,UACA,SACA,WACA,cACA,QACA,QACA,aACA,WACA,WACA,QACA,SACA,QACA,UACA,UACF",
6
6
  "names": ["plugins_exports", "__export", "ETHEREUM_PLUGINS", "__toCommonJS"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var m=Object.defineProperty;var E=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var f=Object.prototype.hasOwnProperty;var w=(a,e)=>{for(var t in e)m(a,t,{get:e[t],enumerable:!0})},S=(a,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of l(e))!f.call(a,r)&&r!==t&&m(a,r,{get:()=>e[r],enumerable:!(i=E(e,r))||i.enumerable});return a};var k=a=>S(m({},"__esModule",{value:!0}),a);var x={};w(x,{ProvideTransactionContextTask:()=>v});module.exports=k(x);var o=require("@ledgerhq/context-module"),n=require("@ledgerhq/device-management-kit"),s=require("purify-ts"),d=require("../../app-binder/command/ProvideNFTInformationCommand"),c=require("../../app-binder/command/ProvideTokenInformationCommand"),u=require("../../app-binder/command/ProvideTrustedNameCommand"),p=require("../../app-binder/command/ProvideWeb3CheckCommand"),h=require("../../app-binder/command/SetExternalPluginCommand"),T=require("../../app-binder/command/SetPluginCommand"),C=require("./SendPayloadInChunksTask");class v{constructor(e,t){this.api=e;this.args=t}async run(){for(const e of this.args.clearSignContexts){const t=await this.provideContext(e);if(!(0,n.isSuccessCommandResult)(t))return(0,s.Just)(t)}if(this.args.web3Check){const e=await this.provideContext(this.args.web3Check);if(!(0,n.isSuccessCommandResult)(e))return(0,s.Just)(e)}return s.Nothing}async provideContext({type:e,payload:t,certificate:i}){switch(i&&await this.api.sendCommand(new n.LoadCertificateCommand({keyUsage:i.keyUsageNumber,certificate:i.payload})),e){case o.ClearSignContextType.PLUGIN:return await this.api.sendCommand(new T.SetPluginCommand({payload:t}));case o.ClearSignContextType.EXTERNAL_PLUGIN:return await this.api.sendCommand(new h.SetExternalPluginCommand({payload:t}));case o.ClearSignContextType.NFT:return await this.api.sendCommand(new d.ProvideNFTInformationCommand({payload:t}));case o.ClearSignContextType.TOKEN:return await this.api.sendCommand(new c.ProvideTokenInformationCommand({payload:t}));case o.ClearSignContextType.TRUSTED_NAME:return new C.SendPayloadInChunksTask(this.api,{payload:t,commandFactory:r=>new u.ProvideTrustedNameCommand({data:r.chunkedData,isFirstChunk:r.isFirstChunk})}).run();case o.ClearSignContextType.ENUM:case o.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION:case o.ClearSignContextType.TRANSACTION_INFO:return(0,n.CommandResultFactory)({error:new n.InvalidStatusWordError("The context type [EXTERNAL_PLUGIN] is not valid here")});case o.ClearSignContextType.WEB3_CHECK:return new C.SendPayloadInChunksTask(this.api,{payload:t,commandFactory:r=>new p.ProvideWeb3CheckCommand({payload:r.chunkedData,isFirstChunk:r.isFirstChunk})}).run();default:{const r=e;return(0,n.CommandResultFactory)({error:new n.InvalidStatusWordError(`The context type [${r}] is not covered`)})}}}}0&&(module.exports={ProvideTransactionContextTask});
1
+ "use strict";var m=Object.defineProperty;var E=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var f=Object.prototype.hasOwnProperty;var w=(a,e)=>{for(var t in e)m(a,t,{get:e[t],enumerable:!0})},S=(a,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of l(e))!f.call(a,r)&&r!==t&&m(a,r,{get:()=>e[r],enumerable:!(i=E(e,r))||i.enumerable});return a};var k=a=>S(m({},"__esModule",{value:!0}),a);var x={};w(x,{ProvideTransactionContextTask:()=>v});module.exports=k(x);var o=require("@ledgerhq/context-module"),n=require("@ledgerhq/device-management-kit"),s=require("purify-ts"),d=require("../../app-binder/command/ProvideNFTInformationCommand"),c=require("../../app-binder/command/ProvideTokenInformationCommand"),u=require("../../app-binder/command/ProvideTrustedNameCommand"),p=require("../../app-binder/command/ProvideWeb3CheckCommand"),h=require("../../app-binder/command/SetExternalPluginCommand"),T=require("../../app-binder/command/SetPluginCommand"),C=require("./SendPayloadInChunksTask");class v{constructor(e,t){this.api=e;this.args=t}async run(){if(this.args.web3Check){const e=await this.provideContext(this.args.web3Check);if(!(0,n.isSuccessCommandResult)(e))return(0,s.Just)(e)}for(const e of this.args.clearSignContexts){const t=await this.provideContext(e);if(!(0,n.isSuccessCommandResult)(t))return(0,s.Just)(t)}return s.Nothing}async provideContext({type:e,payload:t,certificate:i}){switch(i&&await this.api.sendCommand(new n.LoadCertificateCommand({keyUsage:i.keyUsageNumber,certificate:i.payload})),e){case o.ClearSignContextType.PLUGIN:return await this.api.sendCommand(new T.SetPluginCommand({payload:t}));case o.ClearSignContextType.EXTERNAL_PLUGIN:return await this.api.sendCommand(new h.SetExternalPluginCommand({payload:t}));case o.ClearSignContextType.NFT:return await this.api.sendCommand(new d.ProvideNFTInformationCommand({payload:t}));case o.ClearSignContextType.TOKEN:return await this.api.sendCommand(new c.ProvideTokenInformationCommand({payload:t}));case o.ClearSignContextType.TRUSTED_NAME:return new C.SendPayloadInChunksTask(this.api,{payload:t,commandFactory:r=>new u.ProvideTrustedNameCommand({data:r.chunkedData,isFirstChunk:r.isFirstChunk})}).run();case o.ClearSignContextType.ENUM:case o.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION:case o.ClearSignContextType.TRANSACTION_INFO:return(0,n.CommandResultFactory)({error:new n.InvalidStatusWordError("The context type [EXTERNAL_PLUGIN] is not valid here")});case o.ClearSignContextType.WEB3_CHECK:return new C.SendPayloadInChunksTask(this.api,{payload:t,commandFactory:r=>new p.ProvideWeb3CheckCommand({payload:r.chunkedData,isFirstChunk:r.isFirstChunk})}).run();default:{const r=e;return(0,n.CommandResultFactory)({error:new n.InvalidStatusWordError(`The context type [${r}] 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 ClearSignContextSuccess,\n ClearSignContextType,\n} from \"@ledgerhq/context-module\";\nimport {\n type CommandErrorResult,\n type CommandResult,\n CommandResultFactory,\n type InternalApi,\n InvalidStatusWordError,\n isSuccessCommandResult,\n LoadCertificateCommand,\n} from \"@ledgerhq/device-management-kit\";\nimport { Just, type Maybe, Nothing } from \"purify-ts\";\n\nimport { ProvideNFTInformationCommand } from \"@internal/app-binder/command/ProvideNFTInformationCommand\";\nimport {\n ProvideTokenInformationCommand,\n type ProvideTokenInformationCommandResponse,\n} from \"@internal/app-binder/command/ProvideTokenInformationCommand\";\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 { type EthErrorCodes } from \"@internal/app-binder/command/utils/ethAppErrors\";\n\nimport { SendPayloadInChunksTask } from \"./SendPayloadInChunksTask\";\n\nexport type ProvideTransactionContextTaskArgs = {\n /**\n * The valid clear sign contexts offerred by the `BuildTrancationContextTask`.\n */\n clearSignContexts: ClearSignContextSuccess[];\n web3Check: ClearSignContextSuccess<ClearSignContextType.WEB3_CHECK> | null;\n};\n\n/**\n * This task is responsible for providing the transaction context to the device.\n * It will send the 5 necessary commands:\n * - `SetPluginCommand` (single command)\n * - `SetExternalPluginCommand` (single command)\n * - `ProvideNFTInformationCommand` (single command)\n * - `ProvideTokenInformationCommand` (single command)\n * - `ProvideTrustedNameCommand` (__mulpitle commands__)\n *\n * The method `provideTrustedNameTask` is dedicated to send the multiple `ProvideTrustedNameCommand`.\n */\nexport class ProvideTransactionContextTask {\n constructor(\n private api: InternalApi,\n private args: ProvideTransactionContextTaskArgs,\n ) {}\n\n async run(): Promise<Maybe<CommandErrorResult<EthErrorCodes>>> {\n for (const context of this.args.clearSignContexts) {\n const res = await this.provideContext(context);\n if (!isSuccessCommandResult(res)) {\n return Just(res);\n }\n }\n if (this.args.web3Check) {\n const res = await this.provideContext(this.args.web3Check);\n if (!isSuccessCommandResult(res)) {\n return Just(res);\n }\n }\n return Nothing;\n }\n\n /**\n * This method will send a command according to the clear sign context type and return the command result if only one command\n * is sent, otherwise it will return the result of the `provideTrustedNameTask`.\n *\n * @param context The clear sign context to provide.\n * @returns A promise that resolves when the command is sent or result of the `provideTrustedNameTask`.\n */\n async provideContext({\n type,\n payload,\n certificate,\n }: ClearSignContextSuccess): Promise<\n CommandResult<void | ProvideTokenInformationCommandResponse, EthErrorCodes>\n > {\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.TRUSTED_NAME: {\n return new SendPayloadInChunksTask(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 case ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION:\n case ClearSignContextType.TRANSACTION_INFO: {\n return CommandResultFactory({\n error: new InvalidStatusWordError(\n \"The context type [EXTERNAL_PLUGIN] is not valid here\",\n ),\n });\n }\n case ClearSignContextType.WEB3_CHECK:\n return new SendPayloadInChunksTask(this.api, {\n payload,\n commandFactory: (args) =>\n new ProvideWeb3CheckCommand({\n payload: 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 });\n }\n }\n }\n}\n"],
5
- "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,mCAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAGO,oCACPC,EAQO,2CACPC,EAA0C,qBAE1CC,EAA6C,qEAC7CC,EAGO,uEACPC,EAA0C,kEAC1CC,EAAwC,gEACxCC,EAAyC,iEACzCC,EAAiC,yDAGjCC,EAAwC,qCAqBjC,MAAMX,CAA8B,CACzC,YACUY,EACAC,EACR,CAFQ,SAAAD,EACA,UAAAC,CACP,CAEH,MAAM,KAAyD,CAC7D,UAAWC,KAAW,KAAK,KAAK,kBAAmB,CACjD,MAAMC,EAAM,MAAM,KAAK,eAAeD,CAAO,EAC7C,GAAI,IAAC,0BAAuBC,CAAG,EAC7B,SAAO,QAAKA,CAAG,CAEnB,CACA,GAAI,KAAK,KAAK,UAAW,CACvB,MAAMA,EAAM,MAAM,KAAK,eAAe,KAAK,KAAK,SAAS,EACzD,GAAI,IAAC,0BAAuBA,CAAG,EAC7B,SAAO,QAAKA,CAAG,CAEnB,CACA,OAAO,SACT,CASA,MAAM,eAAe,CACnB,KAAAC,EACA,QAAAC,EACA,YAAAC,CACF,EAEE,CAWA,OATIA,GACF,MAAM,KAAK,IAAI,YACb,IAAI,yBAAuB,CACzB,SAAUA,EAAY,eACtB,YAAaA,EAAY,OAC3B,CAAC,CACH,EAGMF,EAAM,CACZ,KAAK,uBAAqB,OACxB,OAAO,MAAM,KAAK,IAAI,YAAY,IAAI,mBAAiB,CAAE,QAAAC,CAAQ,CAAC,CAAC,EAErE,KAAK,uBAAqB,gBACxB,OAAO,MAAM,KAAK,IAAI,YACpB,IAAI,2BAAyB,CAAE,QAAAA,CAAQ,CAAC,CAC1C,EAEF,KAAK,uBAAqB,IACxB,OAAO,MAAM,KAAK,IAAI,YACpB,IAAI,+BAA6B,CAAE,QAAAA,CAAQ,CAAC,CAC9C,EAEF,KAAK,uBAAqB,MACxB,OAAO,MAAM,KAAK,IAAI,YACpB,IAAI,iCAA+B,CAAE,QAAAA,CAAQ,CAAC,CAChD,EAEF,KAAK,uBAAqB,aACxB,OAAO,IAAI,0BAAwB,KAAK,IAAK,CAC3C,QAAAA,EACA,eAAiBJ,GACf,IAAI,4BAA0B,CAC5B,KAAMA,EAAK,YACX,aAAcA,EAAK,YACrB,CAAC,CACL,CAAC,EAAE,IAAI,EAET,KAAK,uBAAqB,KAC1B,KAAK,uBAAqB,8BAC1B,KAAK,uBAAqB,iBACxB,SAAO,wBAAqB,CAC1B,MAAO,IAAI,yBACT,sDACF,CACF,CAAC,EAEH,KAAK,uBAAqB,WACxB,OAAO,IAAI,0BAAwB,KAAK,IAAK,CAC3C,QAAAI,EACA,eAAiBJ,GACf,IAAI,0BAAwB,CAC1B,QAASA,EAAK,YACd,aAAcA,EAAK,YACrB,CAAC,CACL,CAAC,EAAE,IAAI,EACT,QAAS,CACP,MAAMM,EAAuBH,EAC7B,SAAO,wBAAqB,CAC1B,MAAO,IAAI,yBACT,qBAAqBG,CAAa,kBACpC,CACF,CAAC,CACH,CACF,CACF,CACF",
6
- "names": ["ProvideTransactionContextTask_exports", "__export", "ProvideTransactionContextTask", "__toCommonJS", "import_context_module", "import_device_management_kit", "import_purify_ts", "import_ProvideNFTInformationCommand", "import_ProvideTokenInformationCommand", "import_ProvideTrustedNameCommand", "import_ProvideWeb3CheckCommand", "import_SetExternalPluginCommand", "import_SetPluginCommand", "import_SendPayloadInChunksTask", "api", "args", "context", "res", "type", "payload", "certificate", "uncoveredType"]
4
+ "sourcesContent": ["import {\n type ClearSignContextSuccess,\n ClearSignContextType,\n} from \"@ledgerhq/context-module\";\nimport {\n type CommandErrorResult,\n type CommandResult,\n CommandResultFactory,\n type InternalApi,\n InvalidStatusWordError,\n isSuccessCommandResult,\n LoadCertificateCommand,\n} from \"@ledgerhq/device-management-kit\";\nimport { Just, type Maybe, Nothing } from \"purify-ts\";\n\nimport { ProvideNFTInformationCommand } from \"@internal/app-binder/command/ProvideNFTInformationCommand\";\nimport {\n ProvideTokenInformationCommand,\n type ProvideTokenInformationCommandResponse,\n} from \"@internal/app-binder/command/ProvideTokenInformationCommand\";\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 { type EthErrorCodes } from \"@internal/app-binder/command/utils/ethAppErrors\";\n\nimport { SendPayloadInChunksTask } from \"./SendPayloadInChunksTask\";\n\nexport type ProvideTransactionContextTaskArgs = {\n /**\n * The valid clear sign contexts offerred by the `BuildTrancationContextTask`.\n */\n clearSignContexts: ClearSignContextSuccess[];\n web3Check: ClearSignContextSuccess<ClearSignContextType.WEB3_CHECK> | null;\n};\n\n/**\n * This task is responsible for providing the transaction context to the device.\n * It will send the 5 necessary commands:\n * - `SetPluginCommand` (single command)\n * - `SetExternalPluginCommand` (single command)\n * - `ProvideNFTInformationCommand` (single command)\n * - `ProvideTokenInformationCommand` (single command)\n * - `ProvideTrustedNameCommand` (__mulpitle commands__)\n *\n * The method `provideTrustedNameTask` is dedicated to send the multiple `ProvideTrustedNameCommand`.\n */\nexport class ProvideTransactionContextTask {\n constructor(\n private api: InternalApi,\n private args: ProvideTransactionContextTaskArgs,\n ) {}\n\n async run(): Promise<Maybe<CommandErrorResult<EthErrorCodes>>> {\n if (this.args.web3Check) {\n const res = await this.provideContext(this.args.web3Check);\n if (!isSuccessCommandResult(res)) {\n return Just(res);\n }\n }\n for (const context of this.args.clearSignContexts) {\n const res = await this.provideContext(context);\n if (!isSuccessCommandResult(res)) {\n return Just(res);\n }\n }\n return Nothing;\n }\n\n /**\n * This method will send a command according to the clear sign context type and return the command result if only one command\n * is sent, otherwise it will return the result of the `provideTrustedNameTask`.\n *\n * @param context The clear sign context to provide.\n * @returns A promise that resolves when the command is sent or result of the `provideTrustedNameTask`.\n */\n async provideContext({\n type,\n payload,\n certificate,\n }: ClearSignContextSuccess): Promise<\n CommandResult<void | ProvideTokenInformationCommandResponse, EthErrorCodes>\n > {\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.TRUSTED_NAME: {\n return new SendPayloadInChunksTask(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 case ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION:\n case ClearSignContextType.TRANSACTION_INFO: {\n return CommandResultFactory({\n error: new InvalidStatusWordError(\n \"The context type [EXTERNAL_PLUGIN] is not valid here\",\n ),\n });\n }\n case ClearSignContextType.WEB3_CHECK:\n return new SendPayloadInChunksTask(this.api, {\n payload,\n commandFactory: (args) =>\n new ProvideWeb3CheckCommand({\n payload: 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 });\n }\n }\n }\n}\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,mCAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAGO,oCACPC,EAQO,2CACPC,EAA0C,qBAE1CC,EAA6C,qEAC7CC,EAGO,uEACPC,EAA0C,kEAC1CC,EAAwC,gEACxCC,EAAyC,iEACzCC,EAAiC,yDAGjCC,EAAwC,qCAqBjC,MAAMX,CAA8B,CACzC,YACUY,EACAC,EACR,CAFQ,SAAAD,EACA,UAAAC,CACP,CAEH,MAAM,KAAyD,CAC7D,GAAI,KAAK,KAAK,UAAW,CACvB,MAAMC,EAAM,MAAM,KAAK,eAAe,KAAK,KAAK,SAAS,EACzD,GAAI,IAAC,0BAAuBA,CAAG,EAC7B,SAAO,QAAKA,CAAG,CAEnB,CACA,UAAWC,KAAW,KAAK,KAAK,kBAAmB,CACjD,MAAMD,EAAM,MAAM,KAAK,eAAeC,CAAO,EAC7C,GAAI,IAAC,0BAAuBD,CAAG,EAC7B,SAAO,QAAKA,CAAG,CAEnB,CACA,OAAO,SACT,CASA,MAAM,eAAe,CACnB,KAAAE,EACA,QAAAC,EACA,YAAAC,CACF,EAEE,CAWA,OATIA,GACF,MAAM,KAAK,IAAI,YACb,IAAI,yBAAuB,CACzB,SAAUA,EAAY,eACtB,YAAaA,EAAY,OAC3B,CAAC,CACH,EAGMF,EAAM,CACZ,KAAK,uBAAqB,OACxB,OAAO,MAAM,KAAK,IAAI,YAAY,IAAI,mBAAiB,CAAE,QAAAC,CAAQ,CAAC,CAAC,EAErE,KAAK,uBAAqB,gBACxB,OAAO,MAAM,KAAK,IAAI,YACpB,IAAI,2BAAyB,CAAE,QAAAA,CAAQ,CAAC,CAC1C,EAEF,KAAK,uBAAqB,IACxB,OAAO,MAAM,KAAK,IAAI,YACpB,IAAI,+BAA6B,CAAE,QAAAA,CAAQ,CAAC,CAC9C,EAEF,KAAK,uBAAqB,MACxB,OAAO,MAAM,KAAK,IAAI,YACpB,IAAI,iCAA+B,CAAE,QAAAA,CAAQ,CAAC,CAChD,EAEF,KAAK,uBAAqB,aACxB,OAAO,IAAI,0BAAwB,KAAK,IAAK,CAC3C,QAAAA,EACA,eAAiBJ,GACf,IAAI,4BAA0B,CAC5B,KAAMA,EAAK,YACX,aAAcA,EAAK,YACrB,CAAC,CACL,CAAC,EAAE,IAAI,EAET,KAAK,uBAAqB,KAC1B,KAAK,uBAAqB,8BAC1B,KAAK,uBAAqB,iBACxB,SAAO,wBAAqB,CAC1B,MAAO,IAAI,yBACT,sDACF,CACF,CAAC,EAEH,KAAK,uBAAqB,WACxB,OAAO,IAAI,0BAAwB,KAAK,IAAK,CAC3C,QAAAI,EACA,eAAiBJ,GACf,IAAI,0BAAwB,CAC1B,QAASA,EAAK,YACd,aAAcA,EAAK,YACrB,CAAC,CACL,CAAC,EAAE,IAAI,EACT,QAAS,CACP,MAAMM,EAAuBH,EAC7B,SAAO,wBAAqB,CAC1B,MAAO,IAAI,yBACT,qBAAqBG,CAAa,kBACpC,CACF,CAAC,CACH,CACF,CACF,CACF",
6
+ "names": ["ProvideTransactionContextTask_exports", "__export", "ProvideTransactionContextTask", "__toCommonJS", "import_context_module", "import_device_management_kit", "import_purify_ts", "import_ProvideNFTInformationCommand", "import_ProvideTokenInformationCommand", "import_ProvideTrustedNameCommand", "import_ProvideWeb3CheckCommand", "import_SetExternalPluginCommand", "import_SetPluginCommand", "import_SendPayloadInChunksTask", "api", "args", "res", "context", "type", "payload", "certificate", "uncoveredType"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var n=require("@ledgerhq/context-module"),a=require("@ledgerhq/device-management-kit"),i=require("../../app-binder/command/ProvideNFTInformationCommand"),s=require("../../app-binder/command/ProvideTokenInformationCommand"),c=require("../../app-binder/command/SetExternalPluginCommand"),m=require("../../app-binder/command/SetPluginCommand"),l=require("../../app-binder/device-action/__test-utils__/makeInternalApi"),r=require("./ProvideTransactionContextTask");describe("ProvideTransactionContextTask",()=>{const e=(0,l.makeDeviceActionInternalApiMock)(),p=(0,a.CommandResultFactory)({data:void 0}),d=(0,a.CommandResultFactory)({data:void 0,error:{}});beforeEach(()=>{vi.resetAllMocks()}),describe("run",()=>{const o={clearSignContexts:[{type:n.ClearSignContextType.PLUGIN,payload:"706c7567696e"},{type:n.ClearSignContextType.EXTERNAL_PLUGIN,payload:"65787465726e616c506c7567696e"},{type:n.ClearSignContextType.NFT,payload:"6e6674"},{type:n.ClearSignContextType.TOKEN,payload:"746f6b656e"}],web3Check:null};afterEach(()=>{vi.restoreAllMocks()}),it("should send relative commands when receiving ClearSignContexts of type not trustedName",async()=>{e.sendCommand.mockResolvedValue(p),await new r.ProvideTransactionContextTask(e,o).run(),expect(e.sendCommand).toHaveBeenCalledTimes(4),expect(e.sendCommand).toHaveBeenNthCalledWith(o.clearSignContexts.findIndex(t=>t.type===n.ClearSignContextType.PLUGIN)+1,expect.objectContaining(new m.SetPluginCommand({payload:"706c7567696e"}))),expect(e.sendCommand).toHaveBeenNthCalledWith(o.clearSignContexts.findIndex(t=>t.type===n.ClearSignContextType.EXTERNAL_PLUGIN)+1,expect.objectContaining(new c.SetExternalPluginCommand({payload:"65787465726e616c506c7567696e"}))),expect(e.sendCommand).toHaveBeenNthCalledWith(o.clearSignContexts.findIndex(t=>t.type===n.ClearSignContextType.NFT)+1,expect.objectContaining(new i.ProvideNFTInformationCommand({payload:"6e6674"}))),expect(e.sendCommand).toHaveBeenNthCalledWith(o.clearSignContexts.findIndex(t=>t.type===n.ClearSignContextType.TOKEN)+1,expect.objectContaining(new s.ProvideTokenInformationCommand({payload:"746f6b656e"})))}),it("should return the command error result and stop when the command fails",async()=>{e.sendCommand.mockReset(),e.sendCommand.mockResolvedValueOnce(d);const t=await new r.ProvideTransactionContextTask(e,o).run();expect(e.sendCommand).toHaveBeenCalledTimes(1),expect(t.isJust()).toBe(!0),expect(t.extract()).toStrictEqual(d)})})});
1
+ "use strict";var n=require("@ledgerhq/context-module"),a=require("@ledgerhq/device-management-kit"),c=require("../../app-binder/command/ProvideNFTInformationCommand"),m=require("../../app-binder/command/ProvideTokenInformationCommand"),l=require("../../app-binder/command/ProvideWeb3CheckCommand"),C=require("../../app-binder/command/SetExternalPluginCommand"),p=require("../../app-binder/command/SetPluginCommand"),x=require("../../app-binder/device-action/__test-utils__/makeInternalApi"),r=require("./ProvideTransactionContextTask");describe("ProvideTransactionContextTask",()=>{const e=(0,x.makeDeviceActionInternalApiMock)(),i=(0,a.CommandResultFactory)({data:void 0}),d=(0,a.CommandResultFactory)({data:void 0,error:{}});beforeEach(()=>{vi.resetAllMocks()}),describe("run",()=>{const o={clearSignContexts:[{type:n.ClearSignContextType.PLUGIN,payload:"706c7567696e"},{type:n.ClearSignContextType.EXTERNAL_PLUGIN,payload:"65787465726e616c506c7567696e"},{type:n.ClearSignContextType.NFT,payload:"6e6674"},{type:n.ClearSignContextType.TOKEN,payload:"746f6b656e"}],web3Check:null};beforeEach(()=>{vi.resetAllMocks()}),it("should send relative commands when receiving ClearSignContexts of type not trustedName",async()=>{e.sendCommand.mockResolvedValue(i),await new r.ProvideTransactionContextTask(e,o).run(),expect(e.sendCommand).toHaveBeenCalledTimes(4),expect(e.sendCommand).toHaveBeenNthCalledWith(o.clearSignContexts.findIndex(t=>t.type===n.ClearSignContextType.PLUGIN)+1,expect.objectContaining(new p.SetPluginCommand({payload:"706c7567696e"}))),expect(e.sendCommand).toHaveBeenNthCalledWith(o.clearSignContexts.findIndex(t=>t.type===n.ClearSignContextType.EXTERNAL_PLUGIN)+1,expect.objectContaining(new C.SetExternalPluginCommand({payload:"65787465726e616c506c7567696e"}))),expect(e.sendCommand).toHaveBeenNthCalledWith(o.clearSignContexts.findIndex(t=>t.type===n.ClearSignContextType.NFT)+1,expect.objectContaining(new c.ProvideNFTInformationCommand({payload:"6e6674"}))),expect(e.sendCommand).toHaveBeenNthCalledWith(o.clearSignContexts.findIndex(t=>t.type===n.ClearSignContextType.TOKEN)+1,expect.objectContaining(new m.ProvideTokenInformationCommand({payload:"746f6b656e"})))}),it("should return the command error result and stop when the command fails",async()=>{e.sendCommand.mockResolvedValueOnce(d);const t=await new r.ProvideTransactionContextTask(e,o).run();expect(e.sendCommand).toHaveBeenCalledTimes(1),expect(t.isJust()).toBe(!0),expect(t.extract()).toStrictEqual(d)}),it("should send the web3Check command when it is provided",async()=>{e.sendCommand.mockResolvedValue(i);const t=await new r.ProvideTransactionContextTask(e,{...o,web3Check:{type:n.ClearSignContextType.WEB3_CHECK,payload:"0x01020304",certificate:{payload:new Uint8Array,keyUsageNumber:1}}}).run();expect(e.sendCommand).toHaveBeenCalledTimes(6),expect(e.sendCommand).toHaveBeenNthCalledWith(1,expect.objectContaining(new a.LoadCertificateCommand({certificate:new Uint8Array,keyUsage:1}))),expect(e.sendCommand).toHaveBeenNthCalledWith(2,expect.objectContaining(new l.ProvideWeb3CheckCommand({payload:(0,a.hexaStringToBuffer)("0x000401020304"),isFirstChunk:!0}))),expect(t.isJust()).toBe(!1)})})});
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 { ClearSignContextType } from \"@ledgerhq/context-module\";\nimport {\n CommandResultFactory,\n type UnknownDeviceExchangeError,\n} from \"@ledgerhq/device-management-kit\";\n\nimport { ProvideNFTInformationCommand } from \"@internal/app-binder/command/ProvideNFTInformationCommand\";\nimport { ProvideTokenInformationCommand } from \"@internal/app-binder/command/ProvideTokenInformationCommand\";\nimport { SetExternalPluginCommand } from \"@internal/app-binder/command/SetExternalPluginCommand\";\nimport { SetPluginCommand } from \"@internal/app-binder/command/SetPluginCommand\";\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\";\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 args: ProvideTransactionContextTaskArgs = {\n clearSignContexts: [\n {\n type: ClearSignContextType.PLUGIN,\n payload: \"706c7567696e\", // \"plugin\"\n },\n {\n type: ClearSignContextType.EXTERNAL_PLUGIN,\n payload: \"65787465726e616c506c7567696e\", // \"externalPlugin\"\n },\n {\n type: ClearSignContextType.NFT,\n payload: \"6e6674\", // \"nft\"\n },\n {\n type: ClearSignContextType.TOKEN,\n payload: \"746f6b656e\", // \"token\"\n },\n ],\n web3Check: null,\n };\n afterEach(() => {\n vi.restoreAllMocks();\n });\n it(\"should send relative commands when receiving ClearSignContexts of type not trustedName\", async () => {\n api.sendCommand.mockResolvedValue(successResult);\n // GIVEN\n const task = new ProvideTransactionContextTask(api, args);\n // WHEN\n await task.run();\n // THEN\n expect(api.sendCommand).toHaveBeenCalledTimes(4);\n expect(api.sendCommand).toHaveBeenNthCalledWith(\n args.clearSignContexts.findIndex(\n (c) => c.type === ClearSignContextType.PLUGIN,\n ) + 1,\n expect.objectContaining(\n new SetPluginCommand({ payload: \"706c7567696e\" }),\n ),\n );\n expect(api.sendCommand).toHaveBeenNthCalledWith(\n args.clearSignContexts.findIndex(\n (c) => c.type === ClearSignContextType.EXTERNAL_PLUGIN,\n ) + 1,\n expect.objectContaining(\n new SetExternalPluginCommand({\n payload: \"65787465726e616c506c7567696e\",\n }),\n ),\n );\n expect(api.sendCommand).toHaveBeenNthCalledWith(\n args.clearSignContexts.findIndex(\n (c) => c.type === ClearSignContextType.NFT,\n ) + 1,\n expect.objectContaining(\n new ProvideNFTInformationCommand({ payload: \"6e6674\" }),\n ),\n );\n expect(api.sendCommand).toHaveBeenNthCalledWith(\n args.clearSignContexts.findIndex(\n (c) => c.type === ClearSignContextType.TOKEN,\n ) + 1,\n expect.objectContaining(\n new ProvideTokenInformationCommand({ payload: \"746f6b656e\" }),\n ),\n );\n });\n it(\"should return the command error result and stop when the command fails\", async () => {\n api.sendCommand.mockReset();\n api.sendCommand.mockResolvedValueOnce(errorResult);\n // GIVEN\n const task = new ProvideTransactionContextTask(api, args);\n // WHEN\n const result = await task.run();\n // THEN\n expect(api.sendCommand).toHaveBeenCalledTimes(1);\n expect(result.isJust()).toBe(true);\n expect(result.extract()).toStrictEqual(errorResult);\n });\n });\n});\n"],
5
- "mappings": "aAAA,IAAAA,EAAqC,oCACrCC,EAGO,2CAEPC,EAA6C,qEAC7CC,EAA+C,uEAC/CC,EAAyC,iEACzCC,EAAiC,yDAEjCC,EAAgD,6EAEhDC,EAGO,2CAEP,SAAS,gCAAiC,IAAM,CAC9C,MAAMC,KAAM,mCAAgC,EACtCC,KAAgB,wBAA0C,CAC9D,KAAM,MACR,CAAC,EACKC,KAAc,wBAA0C,CAC5D,KAAM,OACN,MAAO,CAAC,CACV,CAAC,EAED,WAAW,IAAM,CACf,GAAG,cAAc,CACnB,CAAC,EAED,SAAS,MAAO,IAAM,CACpB,MAAMC,EAA0C,CAC9C,kBAAm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I,EAE9B,IAAI,EAE9B,OAAOH,EAAI,WAAW,EAAE,sBAAsB,CAAC,EAC/C,OAAOK,EAAO,OAAO,CAAC,EAAE,KAAK,EAAI,EACjC,OAAOA,EAAO,QAAQ,CAAC,EAAE,cAAcH,CAAW,CACpD,CAAC,CACH,CAAC,CACH,CAAC",
6
- "names": ["import_context_module", "import_device_management_kit", "import_ProvideNFTInformationCommand", "import_ProvideTokenInformationCommand", "import_SetExternalPluginCommand", "import_SetPluginCommand", "import_makeInternalApi", "import_ProvideTransactionContextTask", "api", "successResult", "errorResult", "args", "c", "result"]
4
+ "sourcesContent": ["import { ClearSignContextType } from \"@ledgerhq/context-module\";\nimport {\n CommandResultFactory,\n hexaStringToBuffer,\n LoadCertificateCommand,\n type UnknownDeviceExchangeError,\n} from \"@ledgerhq/device-management-kit\";\n\nimport { ProvideNFTInformationCommand } from \"@internal/app-binder/command/ProvideNFTInformationCommand\";\nimport { ProvideTokenInformationCommand } from \"@internal/app-binder/command/ProvideTokenInformationCommand\";\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 { 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\";\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 args: ProvideTransactionContextTaskArgs = {\n clearSignContexts: [\n {\n type: ClearSignContextType.PLUGIN,\n payload: \"706c7567696e\", // \"plugin\"\n },\n {\n type: ClearSignContextType.EXTERNAL_PLUGIN,\n payload: \"65787465726e616c506c7567696e\", // \"externalPlugin\"\n },\n {\n type: ClearSignContextType.NFT,\n payload: \"6e6674\", // \"nft\"\n },\n {\n type: ClearSignContextType.TOKEN,\n payload: \"746f6b656e\", // \"token\"\n },\n ],\n web3Check: null,\n };\n\n beforeEach(() => {\n vi.resetAllMocks();\n });\n\n it(\"should send relative commands when receiving ClearSignContexts of type not trustedName\", async () => {\n api.sendCommand.mockResolvedValue(successResult);\n // GIVEN\n const task = new ProvideTransactionContextTask(api, args);\n // WHEN\n await task.run();\n // THEN\n expect(api.sendCommand).toHaveBeenCalledTimes(4);\n expect(api.sendCommand).toHaveBeenNthCalledWith(\n args.clearSignContexts.findIndex(\n (c) => c.type === ClearSignContextType.PLUGIN,\n ) + 1,\n expect.objectContaining(\n new SetPluginCommand({ payload: \"706c7567696e\" }),\n ),\n );\n expect(api.sendCommand).toHaveBeenNthCalledWith(\n args.clearSignContexts.findIndex(\n (c) => c.type === ClearSignContextType.EXTERNAL_PLUGIN,\n ) + 1,\n expect.objectContaining(\n new SetExternalPluginCommand({\n payload: \"65787465726e616c506c7567696e\",\n }),\n ),\n );\n expect(api.sendCommand).toHaveBeenNthCalledWith(\n args.clearSignContexts.findIndex(\n (c) => c.type === ClearSignContextType.NFT,\n ) + 1,\n expect.objectContaining(\n new ProvideNFTInformationCommand({ payload: \"6e6674\" }),\n ),\n );\n expect(api.sendCommand).toHaveBeenNthCalledWith(\n args.clearSignContexts.findIndex(\n (c) => c.type === ClearSignContextType.TOKEN,\n ) + 1,\n expect.objectContaining(\n new ProvideTokenInformationCommand({ payload: \"746f6b656e\" }),\n ),\n );\n });\n\n it(\"should return the command error result and stop when the command fails\", async () => {\n api.sendCommand.mockResolvedValueOnce(errorResult);\n // GIVEN\n const task = new ProvideTransactionContextTask(api, args);\n // WHEN\n const result = await task.run();\n // THEN\n expect(api.sendCommand).toHaveBeenCalledTimes(1);\n expect(result.isJust()).toBe(true);\n expect(result.extract()).toStrictEqual(errorResult);\n });\n\n it(\"should send the web3Check command when it is provided\", async () => {\n api.sendCommand.mockResolvedValue(successResult);\n // GIVEN\n const task = new ProvideTransactionContextTask(api, {\n ...args,\n web3Check: {\n type: ClearSignContextType.WEB3_CHECK,\n payload: \"0x01020304\",\n certificate: {\n payload: new Uint8Array(),\n keyUsageNumber: 1,\n },\n },\n });\n // WHEN\n const result = await task.run();\n // THEN\n expect(api.sendCommand).toHaveBeenCalledTimes(6);\n expect(api.sendCommand).toHaveBeenNthCalledWith(\n 1,\n expect.objectContaining(\n new LoadCertificateCommand({\n certificate: new Uint8Array(),\n keyUsage: 1,\n }),\n ),\n );\n expect(api.sendCommand).toHaveBeenNthCalledWith(\n 2,\n expect.objectContaining(\n new ProvideWeb3CheckCommand({\n payload: hexaStringToBuffer(\"0x000401020304\")!,\n isFirstChunk: true,\n }),\n ),\n );\n expect(result.isJust()).toBe(false);\n });\n });\n});\n"],
5
+ "mappings": "aAAA,IAAAA,EAAqC,oCACrCC,EAKO,2CAEPC,EAA6C,qEAC7CC,EAA+C,uEAC/CC,EAAwC,gEACxCC,EAAyC,iEACzCC,EAAiC,yDAEjCC,EAAgD,6EAEhDC,EAGO,2CAEP,SAAS,gCAAiC,IAAM,CAC9C,MAAMC,KAAM,mCAAgC,EACtCC,KAAgB,wBAA0C,CAC9D,KAAM,MACR,CAAC,EACKC,KAAc,wBAA0C,CAC5D,KAAM,OACN,MAAO,CAAC,CACV,CAAC,EAED,WAAW,IAAM,CACf,GAAG,cAAc,CACnB,CAAC,EAED,SAAS,MAAO,IAAM,CACpB,MAAMC,EAA0C,CAC9C,kBAAmB,CACjB,CACE,KAAM,uBAAqB,OAC3B,QAAS,cACX,EACA,CACE,KAAM,uBAAqB,gBAC3B,QAAS,8BACX,EACA,CACE,KAAM,uBAAqB,IAC3B,QAAS,QAC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,CAAW,CACpD,CAAC,EAED,GAAG,wDAAyD,SAAY,CACtEF,EAAI,YAAY,kBAAkBC,CAAa,EAc/C,MAAMI,EAAS,MAZF,IAAI,gCAA8BL,EAAK,CAClD,GAAGG,EACH,UAAW,CACT,KAAM,uBAAqB,WAC3B,QAAS,aACT,YAAa,CACX,QAAS,IAAI,WACb,eAAgB,CAClB,CACF,CACF,CAAC,EAEyB,IAAI,EAE9B,OAAOH,EAAI,WAAW,EAAE,sBAAsB,CAAC,EAC/C,OAAOA,EAAI,WAAW,EAAE,wBACtB,EACA,OAAO,iBACL,IAAI,yBAAuB,CACzB,YAAa,IAAI,WACjB,SAAU,CACZ,CAAC,CACH,CACF,EACA,OAAOA,EAAI,WAAW,EAAE,wBACtB,EACA,OAAO,iBACL,IAAI,0BAAwB,CAC1B,WAAS,sBAAmB,gBAAgB,EAC5C,aAAc,EAChB,CAAC,CACH,CACF,EACA,OAAOK,EAAO,OAAO,CAAC,EAAE,KAAK,EAAK,CACpC,CAAC,CACH,CAAC,CACH,CAAC",
6
+ "names": ["import_context_module", "import_device_management_kit", "import_ProvideNFTInformationCommand", "import_ProvideTokenInformationCommand", "import_ProvideWeb3CheckCommand", "import_SetExternalPluginCommand", "import_SetPluginCommand", "import_makeInternalApi", "import_ProvideTransactionContextTask", "api", "successResult", "errorResult", "args", "c", "result"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var r=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var a=Object.getOwnPropertyNames;var c=Object.prototype.hasOwnProperty;var h=(i,e)=>{for(var t in e)r(i,t,{get:e[t],enumerable:!0})},u=(i,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of a(e))!c.call(i,s)&&s!==t&&r(i,s,{get:()=>e[s],enumerable:!(n=m(e,s))||n.enumerable});return i};var f=i=>u(r({},"__esModule",{value:!0}),i);var C={};h(C,{ApplicationChecker:()=>d});module.exports=f(C);var p=require("@ledgerhq/device-management-kit"),o=require("semver"),l=require("../../app-binder/constant/plugins");class d{isCompatible=!0;version="0.0.1";modelId;constructor(e,t){if(this.modelId=e.deviceModelId,e.sessionStateType===p.DeviceSessionStateType.Connected){this.isCompatible=!1;return}if(e.currentApp.name!=="Ethereum"&&!l.ETHEREUM_PLUGINS.includes(e.currentApp.name)){this.isCompatible=!1;return}e.currentApp.name==="Ethereum"?this.version=e.currentApp.version:this.version=t.version}withMinVersionInclusive(e){return(0,o.gte)(this.version,e)||(this.isCompatible=!1),this}withMinVersionExclusive(e){return(0,o.gt)(this.version,e)||(this.isCompatible=!1),this}excludeDeviceModel(e){return this.modelId===e&&(this.isCompatible=!1),this}check(){return this.isCompatible}}0&&(module.exports={ApplicationChecker});
1
+ "use strict";var r=Object.defineProperty;var a=Object.getOwnPropertyDescriptor;var m=Object.getOwnPropertyNames;var c=Object.prototype.hasOwnProperty;var h=(i,e)=>{for(var s in e)r(i,s,{get:e[s],enumerable:!0})},f=(i,e,s,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of m(e))!c.call(i,t)&&t!==s&&r(i,t,{get:()=>e[t],enumerable:!(n=a(e,t))||n.enumerable});return i};var u=i=>f(r({},"__esModule",{value:!0}),i);var d={};h(d,{ApplicationChecker:()=>C});module.exports=u(d);var p=require("@ledgerhq/device-management-kit"),o=require("semver"),l=require("../../app-binder/constant/plugins");class C{isCompatible=!0;version="0.0.1";modelId;constructor(e,s){if(this.modelId=e.deviceModelId,e.sessionStateType===p.DeviceSessionStateType.Connected){this.isCompatible=!1;return}if(e.currentApp.name!=="Ethereum"&&!l.ETHEREUM_PLUGINS.includes(e.currentApp.name)){this.isCompatible=!1;return}e.currentApp.name==="Ethereum"?this.version=e.currentApp.version:e.currentApp.name==="Exchange"?this.isCompatible=!1:this.version=s.version}withMinVersionInclusive(e){return(0,o.gte)(this.version,e)||(this.isCompatible=!1),this}withMinVersionExclusive(e){return(0,o.gt)(this.version,e)||(this.isCompatible=!1),this}excludeDeviceModel(e){return this.modelId===e&&(this.isCompatible=!1),this}check(){return this.isCompatible}}0&&(module.exports={ApplicationChecker});
2
2
  //# sourceMappingURL=ApplicationChecker.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/internal/shared/utils/ApplicationChecker.ts"],
4
- "sourcesContent": ["import {\n type DeviceModelId,\n type DeviceSessionState,\n DeviceSessionStateType,\n} from \"@ledgerhq/device-management-kit\";\nimport { gt, gte } from \"semver\";\n\nimport { type GetConfigCommandResponse } from \"@api/app-binder/GetConfigCommandTypes\";\nimport { ETHEREUM_PLUGINS } from \"@internal/app-binder/constant/plugins\";\n\nexport class ApplicationChecker {\n private isCompatible: boolean = true;\n private version: string = \"0.0.1\";\n private modelId: DeviceModelId;\n\n constructor(\n deviceState: DeviceSessionState,\n appConfig: GetConfigCommandResponse,\n ) {\n this.modelId = deviceState.deviceModelId;\n\n // If device is not ready or app is unexpected, checker cannot be successful\n if (deviceState.sessionStateType === DeviceSessionStateType.Connected) {\n this.isCompatible = false;\n return;\n }\n if (\n deviceState.currentApp.name !== \"Ethereum\" &&\n !ETHEREUM_PLUGINS.includes(deviceState.currentApp.name)\n ) {\n this.isCompatible = false;\n return;\n }\n if (deviceState.currentApp.name === \"Ethereum\") {\n this.version = deviceState.currentApp.version;\n } else {\n // Fallback on appConfig version if a plugin is running.\n // It won't contain release candidate suffix but it should be enough for that edge case.\n this.version = appConfig.version;\n }\n }\n\n withMinVersionInclusive(version: string): ApplicationChecker {\n if (!gte(this.version, version)) {\n this.isCompatible = false;\n }\n return this;\n }\n\n withMinVersionExclusive(version: string): ApplicationChecker {\n if (!gt(this.version, version)) {\n this.isCompatible = false;\n }\n return this;\n }\n\n excludeDeviceModel(modelId: DeviceModelId): ApplicationChecker {\n if (this.modelId === modelId) {\n this.isCompatible = false;\n }\n return this;\n }\n\n check(): boolean {\n return this.isCompatible;\n }\n}\n"],
5
- "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,wBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAIO,2CACPC,EAAwB,kBAGxBC,EAAiC,iDAE1B,MAAMJ,CAAmB,CACtB,aAAwB,GACxB,QAAkB,QAClB,QAER,YACEK,EACAC,EACA,CAIA,GAHA,KAAK,QAAUD,EAAY,cAGvBA,EAAY,mBAAqB,yBAAuB,UAAW,CACrE,KAAK,aAAe,GACpB,MACF,CACA,GACEA,EAAY,WAAW,OAAS,YAChC,CAAC,mBAAiB,SAASA,EAAY,WAAW,IAAI,EACtD,CACA,KAAK,aAAe,GACpB,MACF,CACIA,EAAY,WAAW,OAAS,WAClC,KAAK,QAAUA,EAAY,WAAW,QAItC,KAAK,QAAUC,EAAU,OAE7B,CAEA,wBAAwBC,EAAqC,CAC3D,SAAK,OAAI,KAAK,QAASA,CAAO,IAC5B,KAAK,aAAe,IAEf,IACT,CAEA,wBAAwBA,EAAqC,CAC3D,SAAK,MAAG,KAAK,QAASA,CAAO,IAC3B,KAAK,aAAe,IAEf,IACT,CAEA,mBAAmBC,EAA4C,CAC7D,OAAI,KAAK,UAAYA,IACnB,KAAK,aAAe,IAEf,IACT,CAEA,OAAiB,CACf,OAAO,KAAK,YACd,CACF",
4
+ "sourcesContent": ["import {\n type DeviceModelId,\n type DeviceSessionState,\n DeviceSessionStateType,\n} from \"@ledgerhq/device-management-kit\";\nimport { gt, gte } from \"semver\";\n\nimport { type GetConfigCommandResponse } from \"@api/app-binder/GetConfigCommandTypes\";\nimport { ETHEREUM_PLUGINS } from \"@internal/app-binder/constant/plugins\";\n\nexport class ApplicationChecker {\n private isCompatible: boolean = true;\n private version: string = \"0.0.1\";\n private modelId: DeviceModelId;\n\n constructor(\n deviceState: DeviceSessionState,\n appConfig: GetConfigCommandResponse,\n ) {\n this.modelId = deviceState.deviceModelId;\n\n // If device is not ready or app is unexpected, checker cannot be successful\n if (deviceState.sessionStateType === DeviceSessionStateType.Connected) {\n this.isCompatible = false;\n return;\n }\n if (\n deviceState.currentApp.name !== \"Ethereum\" &&\n !ETHEREUM_PLUGINS.includes(deviceState.currentApp.name)\n ) {\n this.isCompatible = false;\n return;\n }\n if (deviceState.currentApp.name === \"Ethereum\") {\n this.version = deviceState.currentApp.version;\n } else if (deviceState.currentApp.name === \"Exchange\") {\n // Exchanges flows are not compatibles with ethereum features appart from SignTx\n this.isCompatible = false;\n } else {\n // Fallback on appConfig version if a plugin is running.\n // It won't contain release candidate suffix but it should be enough for that edge case.\n this.version = appConfig.version;\n }\n }\n\n withMinVersionInclusive(version: string): ApplicationChecker {\n if (!gte(this.version, version)) {\n this.isCompatible = false;\n }\n return this;\n }\n\n withMinVersionExclusive(version: string): ApplicationChecker {\n if (!gt(this.version, version)) {\n this.isCompatible = false;\n }\n return this;\n }\n\n excludeDeviceModel(modelId: DeviceModelId): ApplicationChecker {\n if (this.modelId === modelId) {\n this.isCompatible = false;\n }\n return this;\n }\n\n check(): boolean {\n return this.isCompatible;\n }\n}\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,wBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAIO,2CACPC,EAAwB,kBAGxBC,EAAiC,iDAE1B,MAAMJ,CAAmB,CACtB,aAAwB,GACxB,QAAkB,QAClB,QAER,YACEK,EACAC,EACA,CAIA,GAHA,KAAK,QAAUD,EAAY,cAGvBA,EAAY,mBAAqB,yBAAuB,UAAW,CACrE,KAAK,aAAe,GACpB,MACF,CACA,GACEA,EAAY,WAAW,OAAS,YAChC,CAAC,mBAAiB,SAASA,EAAY,WAAW,IAAI,EACtD,CACA,KAAK,aAAe,GACpB,MACF,CACIA,EAAY,WAAW,OAAS,WAClC,KAAK,QAAUA,EAAY,WAAW,QAC7BA,EAAY,WAAW,OAAS,WAEzC,KAAK,aAAe,GAIpB,KAAK,QAAUC,EAAU,OAE7B,CAEA,wBAAwBC,EAAqC,CAC3D,SAAK,OAAI,KAAK,QAASA,CAAO,IAC5B,KAAK,aAAe,IAEf,IACT,CAEA,wBAAwBA,EAAqC,CAC3D,SAAK,MAAG,KAAK,QAASA,CAAO,IAC3B,KAAK,aAAe,IAEf,IACT,CAEA,mBAAmBC,EAA4C,CAC7D,OAAI,KAAK,UAAYA,IACnB,KAAK,aAAe,IAEf,IACT,CAEA,OAAiB,CACf,OAAO,KAAK,YACd,CACF",
6
6
  "names": ["ApplicationChecker_exports", "__export", "ApplicationChecker", "__toCommonJS", "import_device_management_kit", "import_semver", "import_plugins", "deviceState", "appConfig", "version", "modelId"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var e=require("@ledgerhq/device-management-kit"),s=require("./ApplicationChecker");describe("ApplicationChecker",()=>{function i(t){return{blindSigningEnabled:!1,web3ChecksEnabled:!1,web3ChecksOptIn:!1,version:t}}it("should pass the check for exclusive version",()=>{const t={sessionStateType:e.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:e.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.13.0-rc"},deviceModelId:e.DeviceModelId.FLEX,isSecureConnectionAllowed:!1},n=i("1.13.0"),c=new s.ApplicationChecker(t,n).withMinVersionExclusive("1.12.0").check();expect(c).toStrictEqual(!0)}),it("should reject the check for exclusive version",()=>{const t={sessionStateType:e.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:e.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:e.DeviceModelId.FLEX,isSecureConnectionAllowed:!1},n=i("1.12.0"),c=new s.ApplicationChecker(t,n).withMinVersionExclusive("1.12.0").check();expect(c).toStrictEqual(!1)}),it("should pass the check for inclusive version",()=>{const t={sessionStateType:e.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:e.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:e.DeviceModelId.FLEX,isSecureConnectionAllowed:!1},n=i("1.10.0"),c=new s.ApplicationChecker(t,n).withMinVersionInclusive("1.12.0").check();expect(c).toStrictEqual(!0)}),it("should reject the check for inclusive version",()=>{const t={sessionStateType:e.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:e.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.11.0"},deviceModelId:e.DeviceModelId.FLEX,isSecureConnectionAllowed:!1},n=i("1.11.0"),c=new s.ApplicationChecker(t,n).withMinVersionInclusive("1.12.0").check();expect(c).toStrictEqual(!1)}),it("should pass the check for excluded device",()=>{const t={sessionStateType:e.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:e.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.11.0"},deviceModelId:e.DeviceModelId.FLEX,isSecureConnectionAllowed:!1},n=i("1.11.0"),c=new s.ApplicationChecker(t,n).excludeDeviceModel(e.DeviceModelId.NANO_S).check();expect(c).toStrictEqual(!0)}),it("should reject the check for excluded device",()=>{const t={sessionStateType:e.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:e.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.11.0"},deviceModelId:e.DeviceModelId.FLEX,isSecureConnectionAllowed:!1},n=i("1.11.0"),c=new s.ApplicationChecker(t,n).excludeDeviceModel(e.DeviceModelId.FLEX).check();expect(c).toStrictEqual(!1)}),it("should pass the check for chained condition",()=>{const t={sessionStateType:e.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:e.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.11.0"},deviceModelId:e.DeviceModelId.FLEX,isSecureConnectionAllowed:!1},n=i("1.11.0"),c=new s.ApplicationChecker(t,n).withMinVersionInclusive("1.11.0").excludeDeviceModel(e.DeviceModelId.NANO_S).check();expect(c).toStrictEqual(!0)}),it("should reject the check for chained condition",()=>{const t={sessionStateType:e.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:e.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.10.0"},deviceModelId:e.DeviceModelId.FLEX,isSecureConnectionAllowed:!1},n=i("1.10.0"),c=new s.ApplicationChecker(t,n).withMinVersionInclusive("1.11.0").excludeDeviceModel(e.DeviceModelId.NANO_S).check();expect(c).toStrictEqual(!1)}),it("should pass the check in plugins",()=>{const t={sessionStateType:e.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:e.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"1inch",version:"1.11.0-rc"},deviceModelId:e.DeviceModelId.FLEX,isSecureConnectionAllowed:!1},n=i("1.13.0"),c=new s.ApplicationChecker(t,n).withMinVersionExclusive("1.12.0").check();expect(c).toStrictEqual(!0)}),it("should reject the check in unknexpected app",()=>{const t={sessionStateType:e.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:e.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Bitcoin",version:"1.13.0-rc"},deviceModelId:e.DeviceModelId.FLEX,isSecureConnectionAllowed:!1},n=i("1.13.0"),c=new s.ApplicationChecker(t,n).withMinVersionExclusive("1.12.0").check();expect(c).toStrictEqual(!1)}),it("should reject the check in unknexpected state",()=>{const t={sessionStateType:e.DeviceSessionStateType.Connected,deviceStatus:e.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Bitcoin",version:"1.13.0-rc"},deviceModelId:e.DeviceModelId.FLEX,isSecureConnectionAllowed:!1},n=i("1.13.0"),c=new s.ApplicationChecker(t,n).withMinVersionExclusive("1.12.0").check();expect(c).toStrictEqual(!1)})});
1
+ "use strict";var e=require("@ledgerhq/device-management-kit"),s=require("./ApplicationChecker");describe("ApplicationChecker",()=>{function i(t){return{blindSigningEnabled:!1,web3ChecksEnabled:!1,web3ChecksOptIn:!1,version:t}}it("should pass the check for exclusive version",()=>{const t={sessionStateType:e.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:e.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.13.0-rc"},deviceModelId:e.DeviceModelId.FLEX,isSecureConnectionAllowed:!1},n=i("1.13.0"),c=new s.ApplicationChecker(t,n).withMinVersionExclusive("1.12.0").check();expect(c).toStrictEqual(!0)}),it("should reject the check for exclusive version",()=>{const t={sessionStateType:e.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:e.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:e.DeviceModelId.FLEX,isSecureConnectionAllowed:!1},n=i("1.12.0"),c=new s.ApplicationChecker(t,n).withMinVersionExclusive("1.12.0").check();expect(c).toStrictEqual(!1)}),it("should pass the check for inclusive version",()=>{const t={sessionStateType:e.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:e.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:e.DeviceModelId.FLEX,isSecureConnectionAllowed:!1},n=i("1.10.0"),c=new s.ApplicationChecker(t,n).withMinVersionInclusive("1.12.0").check();expect(c).toStrictEqual(!0)}),it("should reject the check for inclusive version",()=>{const t={sessionStateType:e.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:e.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.11.0"},deviceModelId:e.DeviceModelId.FLEX,isSecureConnectionAllowed:!1},n=i("1.11.0"),c=new s.ApplicationChecker(t,n).withMinVersionInclusive("1.12.0").check();expect(c).toStrictEqual(!1)}),it("should pass the check for excluded device",()=>{const t={sessionStateType:e.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:e.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.11.0"},deviceModelId:e.DeviceModelId.FLEX,isSecureConnectionAllowed:!1},n=i("1.11.0"),c=new s.ApplicationChecker(t,n).excludeDeviceModel(e.DeviceModelId.NANO_S).check();expect(c).toStrictEqual(!0)}),it("should reject the check for excluded device",()=>{const t={sessionStateType:e.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:e.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.11.0"},deviceModelId:e.DeviceModelId.FLEX,isSecureConnectionAllowed:!1},n=i("1.11.0"),c=new s.ApplicationChecker(t,n).excludeDeviceModel(e.DeviceModelId.FLEX).check();expect(c).toStrictEqual(!1)}),it("should pass the check for chained condition",()=>{const t={sessionStateType:e.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:e.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.11.0"},deviceModelId:e.DeviceModelId.FLEX,isSecureConnectionAllowed:!1},n=i("1.11.0"),c=new s.ApplicationChecker(t,n).withMinVersionInclusive("1.11.0").excludeDeviceModel(e.DeviceModelId.NANO_S).check();expect(c).toStrictEqual(!0)}),it("should reject the check for chained condition",()=>{const t={sessionStateType:e.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:e.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.10.0"},deviceModelId:e.DeviceModelId.FLEX,isSecureConnectionAllowed:!1},n=i("1.10.0"),c=new s.ApplicationChecker(t,n).withMinVersionInclusive("1.11.0").excludeDeviceModel(e.DeviceModelId.NANO_S).check();expect(c).toStrictEqual(!1)}),it("exchange app should not be compatible with eth features",()=>{const t={sessionStateType:e.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:e.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Exchange",version:"1.11.0-rc"},deviceModelId:e.DeviceModelId.FLEX,isSecureConnectionAllowed:!1},n=i("1.13.0"),c=new s.ApplicationChecker(t,n).check();expect(c).toStrictEqual(!1)}),it("should pass the check in plugins",()=>{const t={sessionStateType:e.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:e.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"1inch",version:"1.11.0-rc"},deviceModelId:e.DeviceModelId.FLEX,isSecureConnectionAllowed:!1},n=i("1.13.0"),c=new s.ApplicationChecker(t,n).withMinVersionExclusive("1.12.0").check();expect(c).toStrictEqual(!0)}),it("should reject the check in unknexpected app",()=>{const t={sessionStateType:e.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:e.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Bitcoin",version:"1.13.0-rc"},deviceModelId:e.DeviceModelId.FLEX,isSecureConnectionAllowed:!1},n=i("1.13.0"),c=new s.ApplicationChecker(t,n).withMinVersionExclusive("1.12.0").check();expect(c).toStrictEqual(!1)}),it("should reject the check in unknexpected state",()=>{const t={sessionStateType:e.DeviceSessionStateType.Connected,deviceStatus:e.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Bitcoin",version:"1.13.0-rc"},deviceModelId:e.DeviceModelId.FLEX,isSecureConnectionAllowed:!1},n=i("1.13.0"),c=new s.ApplicationChecker(t,n).withMinVersionExclusive("1.12.0").check();expect(c).toStrictEqual(!1)})});
2
2
  //# sourceMappingURL=ApplicationChecker.test.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/internal/shared/utils/ApplicationChecker.test.ts"],
4
- "sourcesContent": ["import {\n DeviceModelId,\n DeviceSessionStateType,\n DeviceStatus,\n} from \"@ledgerhq/device-management-kit\";\n\nimport type { GetConfigCommandResponse } from \"@api/app-binder/GetConfigCommandTypes\";\n\nimport { ApplicationChecker } from \"./ApplicationChecker\";\n\ndescribe(\"ApplicationChecker\", () => {\n function createAppConfig(version: string): GetConfigCommandResponse {\n return {\n blindSigningEnabled: false,\n web3ChecksEnabled: false,\n web3ChecksOptIn: false,\n version,\n };\n }\n\n it(\"should pass the check for exclusive version\", () => {\n // GIVEN\n const state = {\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.13.0-rc\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n };\n const config = createAppConfig(\"1.13.0\");\n // WHEN\n const result = new ApplicationChecker(state, config)\n .withMinVersionExclusive(\"1.12.0\")\n .check();\n // THEN\n expect(result).toStrictEqual(true);\n });\n\n it(\"should reject the check for exclusive version\", () => {\n // GIVEN\n const state = {\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.12.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n };\n const config = createAppConfig(\"1.12.0\");\n // WHEN\n const result = new ApplicationChecker(state, config)\n .withMinVersionExclusive(\"1.12.0\")\n .check();\n // THEN\n expect(result).toStrictEqual(false);\n });\n\n it(\"should pass the check for inclusive version\", () => {\n // GIVEN\n const state = {\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.12.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n };\n const config = createAppConfig(\"1.10.0\");\n // WHEN\n const result = new ApplicationChecker(state, config)\n .withMinVersionInclusive(\"1.12.0\")\n .check();\n // THEN\n expect(result).toStrictEqual(true);\n });\n\n it(\"should reject the check for inclusive version\", () => {\n // GIVEN\n const state = {\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.11.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n };\n const config = createAppConfig(\"1.11.0\");\n // WHEN\n const result = new ApplicationChecker(state, config)\n .withMinVersionInclusive(\"1.12.0\")\n .check();\n // THEN\n expect(result).toStrictEqual(false);\n });\n\n it(\"should pass the check for excluded device\", () => {\n // GIVEN\n const state = {\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.11.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n };\n const config = createAppConfig(\"1.11.0\");\n // WHEN\n const result = new ApplicationChecker(state, config)\n .excludeDeviceModel(DeviceModelId.NANO_S)\n .check();\n // THEN\n expect(result).toStrictEqual(true);\n });\n\n it(\"should reject the check for excluded device\", () => {\n // GIVEN\n const state = {\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.11.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n };\n const config = createAppConfig(\"1.11.0\");\n // WHEN\n const result = new ApplicationChecker(state, config)\n .excludeDeviceModel(DeviceModelId.FLEX)\n .check();\n // THEN\n expect(result).toStrictEqual(false);\n });\n\n it(\"should pass the check for chained condition\", () => {\n // GIVEN\n const state = {\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.11.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n };\n const config = createAppConfig(\"1.11.0\");\n // WHEN\n const result = new ApplicationChecker(state, config)\n .withMinVersionInclusive(\"1.11.0\")\n .excludeDeviceModel(DeviceModelId.NANO_S)\n .check();\n // THEN\n expect(result).toStrictEqual(true);\n });\n\n it(\"should reject the check for chained condition\", () => {\n // GIVEN\n const state = {\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.10.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n };\n const config = createAppConfig(\"1.10.0\");\n // WHEN\n const result = new ApplicationChecker(state, config)\n .withMinVersionInclusive(\"1.11.0\")\n .excludeDeviceModel(DeviceModelId.NANO_S)\n .check();\n // THEN\n expect(result).toStrictEqual(false);\n });\n\n it(\"should pass the check in plugins\", () => {\n // GIVEN\n const state = {\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"1inch\", version: \"1.11.0-rc\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n };\n const config = createAppConfig(\"1.13.0\");\n // WHEN\n const result = new ApplicationChecker(state, config)\n .withMinVersionExclusive(\"1.12.0\")\n .check();\n // THEN\n expect(result).toStrictEqual(true);\n });\n\n it(\"should reject the check in unknexpected app\", () => {\n // GIVEN\n const state = {\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Bitcoin\", version: \"1.13.0-rc\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n };\n const config = createAppConfig(\"1.13.0\");\n // WHEN\n const result = new ApplicationChecker(state, config)\n .withMinVersionExclusive(\"1.12.0\")\n .check();\n // THEN\n expect(result).toStrictEqual(false);\n });\n\n it(\"should reject the check in unknexpected state\", () => {\n // GIVEN\n const state = {\n sessionStateType: DeviceSessionStateType.Connected,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Bitcoin\", version: \"1.13.0-rc\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n };\n const config = createAppConfig(\"1.13.0\");\n // WHEN\n const result = new ApplicationChecker(state, config)\n .withMinVersionExclusive(\"1.12.0\")\n .check();\n // THEN\n expect(result).toStrictEqual(false);\n });\n});\n"],
5
- "mappings": "aAAA,IAAAA,EAIO,2CAIPC,EAAmC,gCAEnC,SAAS,qBAAsB,IAAM,CACnC,SAASC,EAAgBC,EAA2C,CAClE,MAAO,CACL,oBAAqB,GACrB,kBAAm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pD,cAAe,gBAAc,KAC7B,0BAA2B,EAC7B,EACMC,EAASH,EAAgB,QAAQ,EAEjCI,EAAS,IAAI,qBAAmBF,EAAOC,CAAM,EAChD,wBAAwB,QAAQ,EAChC,MAAM,EAET,OAAOC,CAAM,EAAE,cAAc,EAAK,CACpC,CAAC,CACH,CAAC",
4
+ "sourcesContent": ["import {\n DeviceModelId,\n DeviceSessionStateType,\n DeviceStatus,\n} from \"@ledgerhq/device-management-kit\";\n\nimport type { GetConfigCommandResponse } from \"@api/app-binder/GetConfigCommandTypes\";\n\nimport { ApplicationChecker } from \"./ApplicationChecker\";\n\ndescribe(\"ApplicationChecker\", () => {\n function createAppConfig(version: string): GetConfigCommandResponse {\n return {\n blindSigningEnabled: false,\n web3ChecksEnabled: false,\n web3ChecksOptIn: false,\n version,\n };\n }\n\n it(\"should pass the check for exclusive version\", () => {\n // GIVEN\n const state = {\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.13.0-rc\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n };\n const config = createAppConfig(\"1.13.0\");\n // WHEN\n const result = new ApplicationChecker(state, config)\n .withMinVersionExclusive(\"1.12.0\")\n .check();\n // THEN\n expect(result).toStrictEqual(true);\n });\n\n it(\"should reject the check for exclusive version\", () => {\n // GIVEN\n const state = {\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.12.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n };\n const config = createAppConfig(\"1.12.0\");\n // WHEN\n const result = new ApplicationChecker(state, config)\n .withMinVersionExclusive(\"1.12.0\")\n .check();\n // THEN\n expect(result).toStrictEqual(false);\n });\n\n it(\"should pass the check for inclusive version\", () => {\n // GIVEN\n const state = {\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.12.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n };\n const config = createAppConfig(\"1.10.0\");\n // WHEN\n const result = new ApplicationChecker(state, config)\n .withMinVersionInclusive(\"1.12.0\")\n .check();\n // THEN\n expect(result).toStrictEqual(true);\n });\n\n it(\"should reject the check for inclusive version\", () => {\n // GIVEN\n const state = {\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.11.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n };\n const config = createAppConfig(\"1.11.0\");\n // WHEN\n const result = new ApplicationChecker(state, config)\n .withMinVersionInclusive(\"1.12.0\")\n .check();\n // THEN\n expect(result).toStrictEqual(false);\n });\n\n it(\"should pass the check for excluded device\", () => {\n // GIVEN\n const state = {\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.11.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n };\n const config = createAppConfig(\"1.11.0\");\n // WHEN\n const result = new ApplicationChecker(state, config)\n .excludeDeviceModel(DeviceModelId.NANO_S)\n .check();\n // THEN\n expect(result).toStrictEqual(true);\n });\n\n it(\"should reject the check for excluded device\", () => {\n // GIVEN\n const state = {\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.11.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n };\n const config = createAppConfig(\"1.11.0\");\n // WHEN\n const result = new ApplicationChecker(state, config)\n .excludeDeviceModel(DeviceModelId.FLEX)\n .check();\n // THEN\n expect(result).toStrictEqual(false);\n });\n\n it(\"should pass the check for chained condition\", () => {\n // GIVEN\n const state = {\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.11.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n };\n const config = createAppConfig(\"1.11.0\");\n // WHEN\n const result = new ApplicationChecker(state, config)\n .withMinVersionInclusive(\"1.11.0\")\n .excludeDeviceModel(DeviceModelId.NANO_S)\n .check();\n // THEN\n expect(result).toStrictEqual(true);\n });\n\n it(\"should reject the check for chained condition\", () => {\n // GIVEN\n const state = {\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.10.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n };\n const config = createAppConfig(\"1.10.0\");\n // WHEN\n const result = new ApplicationChecker(state, config)\n .withMinVersionInclusive(\"1.11.0\")\n .excludeDeviceModel(DeviceModelId.NANO_S)\n .check();\n // THEN\n expect(result).toStrictEqual(false);\n });\n\n it(\"exchange app should not be compatible with eth features\", () => {\n // GIVEN\n const state = {\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Exchange\", version: \"1.11.0-rc\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n };\n const config = createAppConfig(\"1.13.0\");\n // WHEN\n const result = new ApplicationChecker(state, config).check();\n // THEN\n expect(result).toStrictEqual(false);\n });\n\n it(\"should pass the check in plugins\", () => {\n // GIVEN\n const state = {\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"1inch\", version: \"1.11.0-rc\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n };\n const config = createAppConfig(\"1.13.0\");\n // WHEN\n const result = new ApplicationChecker(state, config)\n .withMinVersionExclusive(\"1.12.0\")\n .check();\n // THEN\n expect(result).toStrictEqual(true);\n });\n\n it(\"should reject the check in unknexpected app\", () => {\n // GIVEN\n const state = {\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Bitcoin\", version: \"1.13.0-rc\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n };\n const config = createAppConfig(\"1.13.0\");\n // WHEN\n const result = new ApplicationChecker(state, config)\n .withMinVersionExclusive(\"1.12.0\")\n .check();\n // THEN\n expect(result).toStrictEqual(false);\n });\n\n it(\"should reject the check in unknexpected state\", () => {\n // GIVEN\n const state = {\n sessionStateType: DeviceSessionStateType.Connected,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Bitcoin\", version: \"1.13.0-rc\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n };\n const config = createAppConfig(\"1.13.0\");\n // WHEN\n const result = new ApplicationChecker(state, config)\n .withMinVersionExclusive(\"1.12.0\")\n .check();\n // THEN\n expect(result).toStrictEqual(false);\n });\n});\n"],
5
+ "mappings": "aAAA,IAAAA,EAIO,2CAIPC,EAAmC,gCAEnC,SAAS,qBAAsB,IAAM,CACnC,SAASC,EAAgBC,EAA2C,CAClE,MAAO,CACL,oBAAqB,GACrB,kBAAmB,GACnB,gBAAiB,GACjB,QAAAA,CACF,CACF,CAEA,GAAG,8CAA+C,IAAM,CAEtD,MAAMC,EAAQ,CACZ,iBAAkB,yBAAuB,0BACzC,aAAc,eAAa,UAC3B,cAAe,CAAC,EAChB,WAAY,CAAE,KAAM,WAAY,QAA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,gDAAiD,IAAM,CAExD,MAAMF,EAAQ,CACZ,iBAAkB,yBAAuB,UACzC,aAAc,eAAa,UAC3B,cAAe,CAAC,EAChB,WAAY,CAAE,KAAM,UAAW,QAAS,WAAY,EACpD,cAAe,gBAAc,KAC7B,0BAA2B,EAC7B,EACMC,EAASH,EAAgB,QAAQ,EAEjCI,EAAS,IAAI,qBAAmBF,EAAOC,CAAM,EAChD,wBAAwB,QAAQ,EAChC,MAAM,EAET,OAAOC,CAAM,EAAE,cAAc,EAAK,CACpC,CAAC,CACH,CAAC",
6
6
  "names": ["import_device_management_kit", "import_ApplicationChecker", "createAppConfig", "version", "state", "config", "result"]
7
7
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ledgerhq/device-signer-kit-ethereum",
3
- "version": "1.3.1",
3
+ "version": "1.3.3",
4
4
  "private": false,
5
5
  "license": "Apache-2.0",
6
6
  "exports": {
@@ -1,2 +1,2 @@
1
- import{ContextModuleBuilder as i}from"@ledgerhq/context-module";import{DefaultSignerEth as o}from"../internal/DefaultSignerEth";class d{_dmk;_sessionId;_contextModule;constructor({dmk:e,sessionId:t}){this._dmk=e,this._sessionId=t,this._contextModule=new i().build()}withContextModule(e){return this._contextModule=e,this}build(){return new o({dmk:this._dmk,sessionId:this._sessionId,contextModule:this._contextModule})}}export{d as SignerEthBuilder};
1
+ import{ContextModuleBuilder as o}from"@ledgerhq/context-module";import{DefaultSignerEth as n}from"../internal/DefaultSignerEth";class u{_dmk;_sessionId;_customContextModule;_originToken;constructor({dmk:e,sessionId:t,originToken:i}){this._dmk=e,this._sessionId=t,this._originToken=i}withContextModule(e){return this._customContextModule=e,this}build(){const e=this._customContextModule??new o({originToken:this._originToken}).build();return new n({dmk:this._dmk,sessionId:this._sessionId,contextModule:e})}}export{u as SignerEthBuilder};
2
2
  //# sourceMappingURL=SignerEthBuilder.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/api/SignerEthBuilder.ts"],
4
- "sourcesContent": ["import {\n type ContextModule,\n ContextModuleBuilder,\n} from \"@ledgerhq/context-module\";\nimport {\n type DeviceManagementKit,\n type DeviceSessionId,\n} from \"@ledgerhq/device-management-kit\";\n\nimport { DefaultSignerEth } from \"@internal/DefaultSignerEth\";\n\ntype SignerEthBuilderConstructorArgs = {\n dmk: DeviceManagementKit;\n sessionId: DeviceSessionId;\n};\n\n/**\n * Builder for the `SignerEth` class.\n *\n * @example\n * ```\n * const dmk = new SignerEthBuilder(dmk)\n * .build();\n * ```\n */\nexport class SignerEthBuilder {\n private _dmk: DeviceManagementKit;\n private _sessionId: DeviceSessionId;\n private _contextModule: ContextModule;\n\n constructor({ dmk, sessionId }: SignerEthBuilderConstructorArgs) {\n this._dmk = dmk;\n this._sessionId = sessionId;\n // default context module for ETH\n this._contextModule = new ContextModuleBuilder().build();\n }\n\n /**\n * Override the default context module\n *\n * @param contextModule\n * @returns this\n */\n withContextModule(contextModule: ContextModule) {\n this._contextModule = contextModule;\n return this;\n }\n\n /**\n * Build the ethereum signer\n *\n * @returns the ethereum signer\n */\n public build() {\n return new DefaultSignerEth({\n dmk: this._dmk,\n sessionId: this._sessionId,\n contextModule: this._contextModule,\n });\n }\n}\n"],
5
- "mappings": "AAAA,OAEE,wBAAAA,MACK,2BAMP,OAAS,oBAAAC,MAAwB,6BAgB1B,MAAMC,CAAiB,CACpB,KACA,WACA,eAER,YAAY,CAAE,IAAAC,EAAK,UAAAC,CAAU,EAAoC,CAC/D,KAAK,KAAOD,EACZ,KAAK,WAAaC,EAElB,KAAK,eAAiB,IAAIJ,EAAqB,EAAE,MAAM,CACzD,CAQA,kBAAkBK,EAA8B,CAC9C,YAAK,eAAiBA,EACf,IACT,CAOO,OAAQ,CACb,OAAO,IAAIJ,EAAiB,CAC1B,IAAK,KAAK,KACV,UAAW,KAAK,WAChB,cAAe,KAAK,cACtB,CAAC,CACH,CACF",
6
- "names": ["ContextModuleBuilder", "DefaultSignerEth", "SignerEthBuilder", "dmk", "sessionId", "contextModule"]
4
+ "sourcesContent": ["import {\n type ContextModule,\n ContextModuleBuilder,\n} from \"@ledgerhq/context-module\";\nimport {\n type DeviceManagementKit,\n type DeviceSessionId,\n} from \"@ledgerhq/device-management-kit\";\n\nimport { DefaultSignerEth } from \"@internal/DefaultSignerEth\";\n\ntype SignerEthBuilderConstructorArgs = {\n dmk: DeviceManagementKit;\n sessionId: DeviceSessionId;\n originToken?: string;\n};\n\n/**\n * Builder for the `SignerEth` class.\n *\n * @example\n * ```\n * const dmk = new SignerEthBuilder(dmk)\n * .build();\n * ```\n */\nexport class SignerEthBuilder {\n private _dmk: DeviceManagementKit;\n private _sessionId: DeviceSessionId;\n private _customContextModule: ContextModule | undefined;\n private _originToken: string | undefined;\n\n constructor({\n dmk,\n sessionId,\n originToken,\n }: SignerEthBuilderConstructorArgs) {\n this._dmk = dmk;\n this._sessionId = sessionId;\n this._originToken = originToken;\n }\n\n /**\n * Override the default context module\n *\n * @param contextModule\n * @returns this\n */\n withContextModule(contextModule: ContextModule) {\n this._customContextModule = contextModule;\n return this;\n }\n\n /**\n * Build the ethereum signer\n *\n * @returns the ethereum signer\n */\n public build() {\n const contextModule =\n this._customContextModule ??\n new ContextModuleBuilder({ originToken: this._originToken }).build();\n\n return new DefaultSignerEth({\n dmk: this._dmk,\n sessionId: this._sessionId,\n contextModule,\n });\n }\n}\n"],
5
+ "mappings": "AAAA,OAEE,wBAAAA,MACK,2BAMP,OAAS,oBAAAC,MAAwB,6BAiB1B,MAAMC,CAAiB,CACpB,KACA,WACA,qBACA,aAER,YAAY,CACV,IAAAC,EACA,UAAAC,EACA,YAAAC,CACF,EAAoC,CAClC,KAAK,KAAOF,EACZ,KAAK,WAAaC,EAClB,KAAK,aAAeC,CACtB,CAQA,kBAAkBC,EAA8B,CAC9C,YAAK,qBAAuBA,EACrB,IACT,CAOO,OAAQ,CACb,MAAMA,EACJ,KAAK,sBACL,IAAIN,EAAqB,CAAE,YAAa,KAAK,YAAa,CAAC,EAAE,MAAM,EAErE,OAAO,IAAIC,EAAiB,CAC1B,IAAK,KAAK,KACV,UAAW,KAAK,WAChB,cAAAK,CACF,CAAC,CACH,CACF",
6
+ "names": ["ContextModuleBuilder", "DefaultSignerEth", "SignerEthBuilder", "dmk", "sessionId", "originToken", "contextModule"]
7
7
  }
@@ -1,2 +1,2 @@
1
- import{SignerEthBuilder as t}from"./SignerEthBuilder";describe("SignerEthBuilder",()=>{const o={};test("should be an instance of SignerEth",()=>{const e=new t({dmk:o,sessionId:""});e.build(),expect(e).toBeInstanceOf(t)}),test("should instanciate with default context module",()=>{const e=new t({dmk:o,sessionId:""});e.build(),expect(e._contextModule).toBeDefined(),expect(e._contextModule._loaders).toHaveLength(6)}),test("should instanciate with custom context module",()=>{const e=new t({dmk:o,sessionId:""}),n={};e.withContextModule(n).build(),expect(e._contextModule).toBe(n)})});
1
+ import{SignerEthBuilder as n}from"./SignerEthBuilder";import{DefaultSignerEth as c}from"../internal/DefaultSignerEth";import{externalTypes as d}from"../internal/externalTypes";describe("SignerEthBuilder",()=>{const i={dmk:{},sessionId:"",originToken:"test"};test("should be an instance of SignerEth",()=>{const t=new n(i);t.build(),expect(t).toBeInstanceOf(n)}),test("should instanciate with default context module",()=>{const o=new n(i).build(),e=o._container.get(d.ContextModule);expect(o).toBeInstanceOf(c),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(i),o={},e=t.withContextModule(o).build();expect(e).toBeInstanceOf(c),expect(e._container.get(d.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 {\n type ContextLoader,\n type ContextModule,\n} from \"@ledgerhq/context-module\";\nimport { type DeviceManagementKit } from \"@ledgerhq/device-management-kit\";\n\nimport { SignerEthBuilder } from \"@api/SignerEthBuilder\";\n\ndescribe(\"SignerEthBuilder\", () => {\n const dmk: DeviceManagementKit = {} as DeviceManagementKit;\n\n test(\"should be an instance of SignerEth\", () => {\n // GIVEN\n const builder = new SignerEthBuilder({ dmk, sessionId: \"\" });\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({ dmk, sessionId: \"\" });\n\n // WHEN\n builder.build();\n\n // THEN\n expect(builder[\"_contextModule\"]).toBeDefined();\n expect(\n (builder[\"_contextModule\"] as unknown as { _loaders: ContextLoader[] })\n ._loaders,\n ).toHaveLength(6);\n });\n\n test(\"should instanciate with custom context module\", () => {\n // GIVEN\n const builder = new SignerEthBuilder({ dmk, sessionId: \"\" });\n const contextModule = {} as ContextModule;\n\n // WHEN\n builder.withContextModule(contextModule).build();\n\n // THEN\n expect(builder[\"_contextModule\"]).toBe(contextModule);\n });\n});\n"],
5
- "mappings": "AAMA,OAAS,oBAAAA,MAAwB,wBAEjC,SAAS,mBAAoB,IAAM,CACjC,MAAMC,EAA2B,CAAC,EAElC,KAAK,qCAAsC,IAAM,CAE/C,MAAMC,EAAU,IAAIF,EAAiB,CAAE,IAAAC,EAAK,UAAW,EAAG,CAAC,EAG3DC,EAAQ,MAAM,EAGd,OAAOA,CAAO,EAAE,eAAeF,CAAgB,CACjD,CAAC,EAED,KAAK,iDAAkD,IAAM,CAE3D,MAAME,EAAU,IAAIF,EAAiB,CAAE,IAAAC,EAAK,UAAW,EAAG,CAAC,EAG3DC,EAAQ,MAAM,EAGd,OAAOA,EAAQ,cAAiB,EAAE,YAAY,EAC9C,OACGA,EAAQ,eACN,QACL,EAAE,aAAa,CAAC,CAClB,CAAC,EAED,KAAK,gDAAiD,IAAM,CAE1D,MAAMA,EAAU,IAAIF,EAAiB,CAAE,IAAAC,EAAK,UAAW,EAAG,CAAC,EACrDE,EAAgB,CAAC,EAGvBD,EAAQ,kBAAkBC,CAAa,EAAE,MAAM,EAG/C,OAAOD,EAAQ,cAAiB,EAAE,KAAKC,CAAa,CACtD,CAAC,CACH,CAAC",
6
- "names": ["SignerEthBuilder", "dmk", "builder", "contextModule"]
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"],
5
+ "mappings": "AAGA,OAAS,oBAAAA,MAAwB,wBACjC,OAAS,oBAAAC,MAAwB,6BACjC,OAAS,iBAAAC,MAAqB,0BAE9B,SAAS,mBAAoB,IAAM,CAEjC,MAAMC,EAAyB,CAAE,IADA,CAAC,EACI,UAAW,GAAI,YAAa,MAAO,EAEzE,KAAK,qCAAsC,IAAM,CAE/C,MAAMC,EAAU,IAAIJ,EAAiBG,CAAsB,EAG3DC,EAAQ,MAAM,EAGd,OAAOA,CAAO,EAAE,eAAeJ,CAAgB,CACjD,CAAC,EAED,KAAK,iDAAkD,IAAM,CAK3D,MAAMK,EAHU,IAAIL,EAAiBG,CAAsB,EAGpC,MAAM,EACvBG,EAAgBD,EAAO,WAAc,IACzCH,EAAc,aAChB,EAGA,OAAOG,CAAM,EAAE,eAAeJ,CAAgB,EAC9C,OAAOK,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,IAAIJ,EAAiBG,CAAsB,EACrDG,EAAgB,CAAC,EAGjBD,EAASD,EAAQ,kBAAkBE,CAAa,EAAE,MAAM,EAG9D,OAAOD,CAAM,EAAE,eAAeJ,CAAgB,EAC9C,OACEI,EAAO,WAAc,IAAmBH,EAAc,aAAa,CACrE,EAAE,KAAKI,CAAa,CACtB,CAAC,CACH,CAAC",
6
+ "names": ["SignerEthBuilder", "DefaultSignerEth", "externalTypes", "defaultConstructorArgs", "builder", "signer", "contextModule"]
7
7
  }
@@ -1,2 +1,2 @@
1
- const e=["1inch","Aave","Alkemi","Angle","APWine","ArtBlocks","Brick Towers","capsa","cBridge","ChorusOne","CIAN","Coinbase","Cometh","Compound","DODO","EigenLayer","ENS","Figment","Harvest","Kelp","Kiln","Lens","libertify","Lido","[ L ] Market","Midas","Morpho","Nested","OKX Web3","OpenSea","P2P.org","Paraswap","POAP","QuickSwap","Rarible","Ribbon","Ricochet","Rocket Pool","Spool","Squid","Staderlabs","StakeDAO","StakeKit","Swell","Thales","Yearn","Uniswap"];export{e as ETHEREUM_PLUGINS};
1
+ const e=["1inch","Aave","Alkemi","Angle","APWine","ArtBlocks","Brick Towers","capsa","cBridge","ChorusOne","CIAN","Coinbase","Cometh","Compound","DODO","EigenLayer","ENS","Figment","Harvest","Kelp","Kiln","Lens","libertify","Lido","[ L ] Market","Midas","Morpho","Nested","OKX Web3","OpenSea","P2P.org","Paraswap","POAP","QuickSwap","Rarible","Ribbon","Ricochet","Rocket Pool","Spool","Squid","Staderlabs","StakeDAO","StakeKit","Swell","Thales","Yearn","Uniswap","Exchange"];export{e as ETHEREUM_PLUGINS};
2
2
  //# sourceMappingURL=plugins.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/internal/app-binder/constant/plugins.ts"],
4
- "sourcesContent": ["export const ETHEREUM_PLUGINS: string[] = [\n \"1inch\",\n \"Aave\",\n \"Alkemi\",\n \"Angle\",\n \"APWine\",\n \"ArtBlocks\",\n \"Brick Towers\",\n \"capsa\",\n \"cBridge\",\n \"ChorusOne\",\n \"CIAN\",\n \"Coinbase\",\n \"Cometh\",\n \"Compound\",\n \"DODO\",\n \"EigenLayer\",\n \"ENS\",\n \"Figment\",\n \"Harvest\",\n \"Kelp\",\n \"Kiln\",\n \"Lens\",\n \"libertify\",\n \"Lido\",\n \"[ L ] Market\",\n \"Midas\",\n \"Morpho\",\n \"Nested\",\n \"OKX Web3\",\n \"OpenSea\",\n \"P2P.org\",\n \"Paraswap\",\n \"POAP\",\n \"QuickSwap\",\n \"Rarible\",\n \"Ribbon\",\n \"Ricochet\",\n \"Rocket Pool\",\n \"Spool\",\n \"Squid\",\n \"Staderlabs\",\n \"StakeDAO\",\n \"StakeKit\",\n \"Swell\",\n \"Thales\",\n \"Yearn\",\n \"Uniswap\",\n];\n"],
5
- "mappings": "AAAO,MAAMA,EAA6B,CACxC,QACA,OACA,SACA,QACA,SACA,YACA,eACA,QACA,UACA,YACA,OACA,WACA,SACA,WACA,OACA,aACA,MACA,UACA,UACA,OACA,OACA,OACA,YACA,OACA,eACA,QACA,SACA,SACA,WACA,UACA,UACA,WACA,OACA,YACA,UACA,SACA,WACA,cACA,QACA,QACA,aACA,WACA,WACA,QACA,SACA,QACA,SACF",
4
+ "sourcesContent": ["export const ETHEREUM_PLUGINS: string[] = [\n \"1inch\",\n \"Aave\",\n \"Alkemi\",\n \"Angle\",\n \"APWine\",\n \"ArtBlocks\",\n \"Brick Towers\",\n \"capsa\",\n \"cBridge\",\n \"ChorusOne\",\n \"CIAN\",\n \"Coinbase\",\n \"Cometh\",\n \"Compound\",\n \"DODO\",\n \"EigenLayer\",\n \"ENS\",\n \"Figment\",\n \"Harvest\",\n \"Kelp\",\n \"Kiln\",\n \"Lens\",\n \"libertify\",\n \"Lido\",\n \"[ L ] Market\",\n \"Midas\",\n \"Morpho\",\n \"Nested\",\n \"OKX Web3\",\n \"OpenSea\",\n \"P2P.org\",\n \"Paraswap\",\n \"POAP\",\n \"QuickSwap\",\n \"Rarible\",\n \"Ribbon\",\n \"Ricochet\",\n \"Rocket Pool\",\n \"Spool\",\n \"Squid\",\n \"Staderlabs\",\n \"StakeDAO\",\n \"StakeKit\",\n \"Swell\",\n \"Thales\",\n \"Yearn\",\n \"Uniswap\",\n \"Exchange\", // Not a plugin, but a compatible app during exchange flows\n];\n"],
5
+ "mappings": "AAAO,MAAMA,EAA6B,CACxC,QACA,OACA,SACA,QACA,SACA,YACA,eACA,QACA,UACA,YACA,OACA,WACA,SACA,WACA,OACA,aACA,MACA,UACA,UACA,OACA,OACA,OACA,YACA,OACA,eACA,QACA,SACA,SACA,WACA,UACA,UACA,WACA,OACA,YACA,UACA,SACA,WACA,cACA,QACA,QACA,aACA,WACA,WACA,QACA,SACA,QACA,UACA,UACF",
6
6
  "names": ["ETHEREUM_PLUGINS"]
7
7
  }
@@ -1,2 +1,2 @@
1
- import{ClearSignContextType as t}from"@ledgerhq/context-module";import{CommandResultFactory as a,InvalidStatusWordError as i,isSuccessCommandResult as s,LoadCertificateCommand as d}from"@ledgerhq/device-management-kit";import{Just as m,Nothing as c}from"purify-ts";import{ProvideNFTInformationCommand as u}from"../../app-binder/command/ProvideNFTInformationCommand";import{ProvideTokenInformationCommand as p}from"../../app-binder/command/ProvideTokenInformationCommand";import{ProvideTrustedNameCommand as h}from"../../app-binder/command/ProvideTrustedNameCommand";import{ProvideWeb3CheckCommand as T}from"../../app-binder/command/ProvideWeb3CheckCommand";import{SetExternalPluginCommand as E}from"../../app-binder/command/SetExternalPluginCommand";import{SetPluginCommand as l}from"../../app-binder/command/SetPluginCommand";import{SendPayloadInChunksTask as C}from"./SendPayloadInChunksTask";class R{constructor(r,e){this.api=r;this.args=e}async run(){for(const r of this.args.clearSignContexts){const e=await this.provideContext(r);if(!s(e))return m(e)}if(this.args.web3Check){const r=await this.provideContext(this.args.web3Check);if(!s(r))return m(r)}return c}async provideContext({type:r,payload:e,certificate:o}){switch(o&&await this.api.sendCommand(new d({keyUsage:o.keyUsageNumber,certificate:o.payload})),r){case t.PLUGIN:return await this.api.sendCommand(new l({payload:e}));case t.EXTERNAL_PLUGIN:return await this.api.sendCommand(new E({payload:e}));case t.NFT:return await this.api.sendCommand(new u({payload:e}));case t.TOKEN:return await this.api.sendCommand(new p({payload:e}));case t.TRUSTED_NAME:return new C(this.api,{payload:e,commandFactory:n=>new h({data:n.chunkedData,isFirstChunk:n.isFirstChunk})}).run();case t.ENUM:case t.TRANSACTION_FIELD_DESCRIPTION:case t.TRANSACTION_INFO:return a({error:new i("The context type [EXTERNAL_PLUGIN] is not valid here")});case t.WEB3_CHECK:return new C(this.api,{payload:e,commandFactory:n=>new T({payload:n.chunkedData,isFirstChunk:n.isFirstChunk})}).run();default:{const n=r;return a({error:new i(`The context type [${n}] is not covered`)})}}}}export{R as ProvideTransactionContextTask};
1
+ import{ClearSignContextType as t}from"@ledgerhq/context-module";import{CommandResultFactory as a,InvalidStatusWordError as i,isSuccessCommandResult as s,LoadCertificateCommand as d}from"@ledgerhq/device-management-kit";import{Just as m,Nothing as c}from"purify-ts";import{ProvideNFTInformationCommand as u}from"../../app-binder/command/ProvideNFTInformationCommand";import{ProvideTokenInformationCommand as p}from"../../app-binder/command/ProvideTokenInformationCommand";import{ProvideTrustedNameCommand as h}from"../../app-binder/command/ProvideTrustedNameCommand";import{ProvideWeb3CheckCommand as T}from"../../app-binder/command/ProvideWeb3CheckCommand";import{SetExternalPluginCommand as E}from"../../app-binder/command/SetExternalPluginCommand";import{SetPluginCommand as l}from"../../app-binder/command/SetPluginCommand";import{SendPayloadInChunksTask as C}from"./SendPayloadInChunksTask";class R{constructor(r,e){this.api=r;this.args=e}async run(){if(this.args.web3Check){const r=await this.provideContext(this.args.web3Check);if(!s(r))return m(r)}for(const r of this.args.clearSignContexts){const e=await this.provideContext(r);if(!s(e))return m(e)}return c}async provideContext({type:r,payload:e,certificate:o}){switch(o&&await this.api.sendCommand(new d({keyUsage:o.keyUsageNumber,certificate:o.payload})),r){case t.PLUGIN:return await this.api.sendCommand(new l({payload:e}));case t.EXTERNAL_PLUGIN:return await this.api.sendCommand(new E({payload:e}));case t.NFT:return await this.api.sendCommand(new u({payload:e}));case t.TOKEN:return await this.api.sendCommand(new p({payload:e}));case t.TRUSTED_NAME:return new C(this.api,{payload:e,commandFactory:n=>new h({data:n.chunkedData,isFirstChunk:n.isFirstChunk})}).run();case t.ENUM:case t.TRANSACTION_FIELD_DESCRIPTION:case t.TRANSACTION_INFO:return a({error:new i("The context type [EXTERNAL_PLUGIN] is not valid here")});case t.WEB3_CHECK:return new C(this.api,{payload:e,commandFactory:n=>new T({payload:n.chunkedData,isFirstChunk:n.isFirstChunk})}).run();default:{const n=r;return a({error:new i(`The context type [${n}] is not covered`)})}}}}export{R as 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 ClearSignContextSuccess,\n ClearSignContextType,\n} from \"@ledgerhq/context-module\";\nimport {\n type CommandErrorResult,\n type CommandResult,\n CommandResultFactory,\n type InternalApi,\n InvalidStatusWordError,\n isSuccessCommandResult,\n LoadCertificateCommand,\n} from \"@ledgerhq/device-management-kit\";\nimport { Just, type Maybe, Nothing } from \"purify-ts\";\n\nimport { ProvideNFTInformationCommand } from \"@internal/app-binder/command/ProvideNFTInformationCommand\";\nimport {\n ProvideTokenInformationCommand,\n type ProvideTokenInformationCommandResponse,\n} from \"@internal/app-binder/command/ProvideTokenInformationCommand\";\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 { type EthErrorCodes } from \"@internal/app-binder/command/utils/ethAppErrors\";\n\nimport { SendPayloadInChunksTask } from \"./SendPayloadInChunksTask\";\n\nexport type ProvideTransactionContextTaskArgs = {\n /**\n * The valid clear sign contexts offerred by the `BuildTrancationContextTask`.\n */\n clearSignContexts: ClearSignContextSuccess[];\n web3Check: ClearSignContextSuccess<ClearSignContextType.WEB3_CHECK> | null;\n};\n\n/**\n * This task is responsible for providing the transaction context to the device.\n * It will send the 5 necessary commands:\n * - `SetPluginCommand` (single command)\n * - `SetExternalPluginCommand` (single command)\n * - `ProvideNFTInformationCommand` (single command)\n * - `ProvideTokenInformationCommand` (single command)\n * - `ProvideTrustedNameCommand` (__mulpitle commands__)\n *\n * The method `provideTrustedNameTask` is dedicated to send the multiple `ProvideTrustedNameCommand`.\n */\nexport class ProvideTransactionContextTask {\n constructor(\n private api: InternalApi,\n private args: ProvideTransactionContextTaskArgs,\n ) {}\n\n async run(): Promise<Maybe<CommandErrorResult<EthErrorCodes>>> {\n for (const context of this.args.clearSignContexts) {\n const res = await this.provideContext(context);\n if (!isSuccessCommandResult(res)) {\n return Just(res);\n }\n }\n if (this.args.web3Check) {\n const res = await this.provideContext(this.args.web3Check);\n if (!isSuccessCommandResult(res)) {\n return Just(res);\n }\n }\n return Nothing;\n }\n\n /**\n * This method will send a command according to the clear sign context type and return the command result if only one command\n * is sent, otherwise it will return the result of the `provideTrustedNameTask`.\n *\n * @param context The clear sign context to provide.\n * @returns A promise that resolves when the command is sent or result of the `provideTrustedNameTask`.\n */\n async provideContext({\n type,\n payload,\n certificate,\n }: ClearSignContextSuccess): Promise<\n CommandResult<void | ProvideTokenInformationCommandResponse, EthErrorCodes>\n > {\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.TRUSTED_NAME: {\n return new SendPayloadInChunksTask(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 case ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION:\n case ClearSignContextType.TRANSACTION_INFO: {\n return CommandResultFactory({\n error: new InvalidStatusWordError(\n \"The context type [EXTERNAL_PLUGIN] is not valid here\",\n ),\n });\n }\n case ClearSignContextType.WEB3_CHECK:\n return new SendPayloadInChunksTask(this.api, {\n payload,\n commandFactory: (args) =>\n new ProvideWeb3CheckCommand({\n payload: 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 });\n }\n }\n }\n}\n"],
5
- "mappings": "AAAA,OAEE,wBAAAA,MACK,2BACP,OAGE,wBAAAC,EAEA,0BAAAC,EACA,0BAAAC,EACA,0BAAAC,MACK,kCACP,OAAS,QAAAC,EAAkB,WAAAC,MAAe,YAE1C,OAAS,gCAAAC,MAAoC,4DAC7C,OACE,kCAAAC,MAEK,8DACP,OAAS,6BAAAC,MAAiC,yDAC1C,OAAS,2BAAAC,MAA+B,uDACxC,OAAS,4BAAAC,MAAgC,wDACzC,OAAS,oBAAAC,MAAwB,gDAGjC,OAAS,2BAAAC,MAA+B,4BAqBjC,MAAMC,CAA8B,CACzC,YACUC,EACAC,EACR,CAFQ,SAAAD,EACA,UAAAC,CACP,CAEH,MAAM,KAAyD,CAC7D,UAAWC,KAAW,KAAK,KAAK,kBAAmB,CACjD,MAAMC,EAAM,MAAM,KAAK,eAAeD,CAAO,EAC7C,GAAI,CAACd,EAAuBe,CAAG,EAC7B,OAAOb,EAAKa,CAAG,CAEnB,CACA,GAAI,KAAK,KAAK,UAAW,CACvB,MAAMA,EAAM,MAAM,KAAK,eAAe,KAAK,KAAK,SAAS,EACzD,GAAI,CAACf,EAAuBe,CAAG,EAC7B,OAAOb,EAAKa,CAAG,CAEnB,CACA,OAAOZ,CACT,CASA,MAAM,eAAe,CACnB,KAAAa,EACA,QAAAC,EACA,YAAAC,CACF,EAEE,CAWA,OATIA,GACF,MAAM,KAAK,IAAI,YACb,IAAIjB,EAAuB,CACzB,SAAUiB,EAAY,eACtB,YAAaA,EAAY,OAC3B,CAAC,CACH,EAGMF,EAAM,CACZ,KAAKnB,EAAqB,OACxB,OAAO,MAAM,KAAK,IAAI,YAAY,IAAIY,EAAiB,CAAE,QAAAQ,CAAQ,CAAC,CAAC,EAErE,KAAKpB,EAAqB,gBACxB,OAAO,MAAM,KAAK,IAAI,YACpB,IAAIW,EAAyB,CAAE,QAAAS,CAAQ,CAAC,CAC1C,EAEF,KAAKpB,EAAqB,IACxB,OAAO,MAAM,KAAK,IAAI,YACpB,IAAIO,EAA6B,CAAE,QAAAa,CAAQ,CAAC,CAC9C,EAEF,KAAKpB,EAAqB,MACxB,OAAO,MAAM,KAAK,IAAI,YACpB,IAAIQ,EAA+B,CAAE,QAAAY,CAAQ,CAAC,CAChD,EAEF,KAAKpB,EAAqB,aACxB,OAAO,IAAIa,EAAwB,KAAK,IAAK,CAC3C,QAAAO,EACA,eAAiBJ,GACf,IAAIP,EAA0B,CAC5B,KAAMO,EAAK,YACX,aAAcA,EAAK,YACrB,CAAC,CACL,CAAC,EAAE,IAAI,EAET,KAAKhB,EAAqB,KAC1B,KAAKA,EAAqB,8BAC1B,KAAKA,EAAqB,iBACxB,OAAOC,EAAqB,CAC1B,MAAO,IAAIC,EACT,sDACF,CACF,CAAC,EAEH,KAAKF,EAAqB,WACxB,OAAO,IAAIa,EAAwB,KAAK,IAAK,CAC3C,QAAAO,EACA,eAAiBJ,GACf,IAAIN,EAAwB,CAC1B,QAASM,EAAK,YACd,aAAcA,EAAK,YACrB,CAAC,CACL,CAAC,EAAE,IAAI,EACT,QAAS,CACP,MAAMM,EAAuBH,EAC7B,OAAOlB,EAAqB,CAC1B,MAAO,IAAIC,EACT,qBAAqBoB,CAAa,kBACpC,CACF,CAAC,CACH,CACF,CACF,CACF",
6
- "names": ["ClearSignContextType", "CommandResultFactory", "InvalidStatusWordError", "isSuccessCommandResult", "LoadCertificateCommand", "Just", "Nothing", "ProvideNFTInformationCommand", "ProvideTokenInformationCommand", "ProvideTrustedNameCommand", "ProvideWeb3CheckCommand", "SetExternalPluginCommand", "SetPluginCommand", "SendPayloadInChunksTask", "ProvideTransactionContextTask", "api", "args", "context", "res", "type", "payload", "certificate", "uncoveredType"]
4
+ "sourcesContent": ["import {\n type ClearSignContextSuccess,\n ClearSignContextType,\n} from \"@ledgerhq/context-module\";\nimport {\n type CommandErrorResult,\n type CommandResult,\n CommandResultFactory,\n type InternalApi,\n InvalidStatusWordError,\n isSuccessCommandResult,\n LoadCertificateCommand,\n} from \"@ledgerhq/device-management-kit\";\nimport { Just, type Maybe, Nothing } from \"purify-ts\";\n\nimport { ProvideNFTInformationCommand } from \"@internal/app-binder/command/ProvideNFTInformationCommand\";\nimport {\n ProvideTokenInformationCommand,\n type ProvideTokenInformationCommandResponse,\n} from \"@internal/app-binder/command/ProvideTokenInformationCommand\";\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 { type EthErrorCodes } from \"@internal/app-binder/command/utils/ethAppErrors\";\n\nimport { SendPayloadInChunksTask } from \"./SendPayloadInChunksTask\";\n\nexport type ProvideTransactionContextTaskArgs = {\n /**\n * The valid clear sign contexts offerred by the `BuildTrancationContextTask`.\n */\n clearSignContexts: ClearSignContextSuccess[];\n web3Check: ClearSignContextSuccess<ClearSignContextType.WEB3_CHECK> | null;\n};\n\n/**\n * This task is responsible for providing the transaction context to the device.\n * It will send the 5 necessary commands:\n * - `SetPluginCommand` (single command)\n * - `SetExternalPluginCommand` (single command)\n * - `ProvideNFTInformationCommand` (single command)\n * - `ProvideTokenInformationCommand` (single command)\n * - `ProvideTrustedNameCommand` (__mulpitle commands__)\n *\n * The method `provideTrustedNameTask` is dedicated to send the multiple `ProvideTrustedNameCommand`.\n */\nexport class ProvideTransactionContextTask {\n constructor(\n private api: InternalApi,\n private args: ProvideTransactionContextTaskArgs,\n ) {}\n\n async run(): Promise<Maybe<CommandErrorResult<EthErrorCodes>>> {\n if (this.args.web3Check) {\n const res = await this.provideContext(this.args.web3Check);\n if (!isSuccessCommandResult(res)) {\n return Just(res);\n }\n }\n for (const context of this.args.clearSignContexts) {\n const res = await this.provideContext(context);\n if (!isSuccessCommandResult(res)) {\n return Just(res);\n }\n }\n return Nothing;\n }\n\n /**\n * This method will send a command according to the clear sign context type and return the command result if only one command\n * is sent, otherwise it will return the result of the `provideTrustedNameTask`.\n *\n * @param context The clear sign context to provide.\n * @returns A promise that resolves when the command is sent or result of the `provideTrustedNameTask`.\n */\n async provideContext({\n type,\n payload,\n certificate,\n }: ClearSignContextSuccess): Promise<\n CommandResult<void | ProvideTokenInformationCommandResponse, EthErrorCodes>\n > {\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.TRUSTED_NAME: {\n return new SendPayloadInChunksTask(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 case ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION:\n case ClearSignContextType.TRANSACTION_INFO: {\n return CommandResultFactory({\n error: new InvalidStatusWordError(\n \"The context type [EXTERNAL_PLUGIN] is not valid here\",\n ),\n });\n }\n case ClearSignContextType.WEB3_CHECK:\n return new SendPayloadInChunksTask(this.api, {\n payload,\n commandFactory: (args) =>\n new ProvideWeb3CheckCommand({\n payload: 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 });\n }\n }\n }\n}\n"],
5
+ "mappings": "AAAA,OAEE,wBAAAA,MACK,2BACP,OAGE,wBAAAC,EAEA,0BAAAC,EACA,0BAAAC,EACA,0BAAAC,MACK,kCACP,OAAS,QAAAC,EAAkB,WAAAC,MAAe,YAE1C,OAAS,gCAAAC,MAAoC,4DAC7C,OACE,kCAAAC,MAEK,8DACP,OAAS,6BAAAC,MAAiC,yDAC1C,OAAS,2BAAAC,MAA+B,uDACxC,OAAS,4BAAAC,MAAgC,wDACzC,OAAS,oBAAAC,MAAwB,gDAGjC,OAAS,2BAAAC,MAA+B,4BAqBjC,MAAMC,CAA8B,CACzC,YACUC,EACAC,EACR,CAFQ,SAAAD,EACA,UAAAC,CACP,CAEH,MAAM,KAAyD,CAC7D,GAAI,KAAK,KAAK,UAAW,CACvB,MAAMC,EAAM,MAAM,KAAK,eAAe,KAAK,KAAK,SAAS,EACzD,GAAI,CAACd,EAAuBc,CAAG,EAC7B,OAAOZ,EAAKY,CAAG,CAEnB,CACA,UAAWC,KAAW,KAAK,KAAK,kBAAmB,CACjD,MAAMD,EAAM,MAAM,KAAK,eAAeC,CAAO,EAC7C,GAAI,CAACf,EAAuBc,CAAG,EAC7B,OAAOZ,EAAKY,CAAG,CAEnB,CACA,OAAOX,CACT,CASA,MAAM,eAAe,CACnB,KAAAa,EACA,QAAAC,EACA,YAAAC,CACF,EAEE,CAWA,OATIA,GACF,MAAM,KAAK,IAAI,YACb,IAAIjB,EAAuB,CACzB,SAAUiB,EAAY,eACtB,YAAaA,EAAY,OAC3B,CAAC,CACH,EAGMF,EAAM,CACZ,KAAKnB,EAAqB,OACxB,OAAO,MAAM,KAAK,IAAI,YAAY,IAAIY,EAAiB,CAAE,QAAAQ,CAAQ,CAAC,CAAC,EAErE,KAAKpB,EAAqB,gBACxB,OAAO,MAAM,KAAK,IAAI,YACpB,IAAIW,EAAyB,CAAE,QAAAS,CAAQ,CAAC,CAC1C,EAEF,KAAKpB,EAAqB,IACxB,OAAO,MAAM,KAAK,IAAI,YACpB,IAAIO,EAA6B,CAAE,QAAAa,CAAQ,CAAC,CAC9C,EAEF,KAAKpB,EAAqB,MACxB,OAAO,MAAM,KAAK,IAAI,YACpB,IAAIQ,EAA+B,CAAE,QAAAY,CAAQ,CAAC,CAChD,EAEF,KAAKpB,EAAqB,aACxB,OAAO,IAAIa,EAAwB,KAAK,IAAK,CAC3C,QAAAO,EACA,eAAiBJ,GACf,IAAIP,EAA0B,CAC5B,KAAMO,EAAK,YACX,aAAcA,EAAK,YACrB,CAAC,CACL,CAAC,EAAE,IAAI,EAET,KAAKhB,EAAqB,KAC1B,KAAKA,EAAqB,8BAC1B,KAAKA,EAAqB,iBACxB,OAAOC,EAAqB,CAC1B,MAAO,IAAIC,EACT,sDACF,CACF,CAAC,EAEH,KAAKF,EAAqB,WACxB,OAAO,IAAIa,EAAwB,KAAK,IAAK,CAC3C,QAAAO,EACA,eAAiBJ,GACf,IAAIN,EAAwB,CAC1B,QAASM,EAAK,YACd,aAAcA,EAAK,YACrB,CAAC,CACL,CAAC,EAAE,IAAI,EACT,QAAS,CACP,MAAMM,EAAuBH,EAC7B,OAAOlB,EAAqB,CAC1B,MAAO,IAAIC,EACT,qBAAqBoB,CAAa,kBACpC,CACF,CAAC,CACH,CACF,CACF,CACF",
6
+ "names": ["ClearSignContextType", "CommandResultFactory", "InvalidStatusWordError", "isSuccessCommandResult", "LoadCertificateCommand", "Just", "Nothing", "ProvideNFTInformationCommand", "ProvideTokenInformationCommand", "ProvideTrustedNameCommand", "ProvideWeb3CheckCommand", "SetExternalPluginCommand", "SetPluginCommand", "SendPayloadInChunksTask", "ProvideTransactionContextTask", "api", "args", "res", "context", "type", "payload", "certificate", "uncoveredType"]
7
7
  }
@@ -1,2 +1,2 @@
1
- import{ClearSignContextType as n}from"@ledgerhq/context-module";import{CommandResultFactory as r}from"@ledgerhq/device-management-kit";import{ProvideNFTInformationCommand as c}from"../../app-binder/command/ProvideNFTInformationCommand";import{ProvideTokenInformationCommand as m}from"../../app-binder/command/ProvideTokenInformationCommand";import{SetExternalPluginCommand as l}from"../../app-binder/command/SetExternalPluginCommand";import{SetPluginCommand as p}from"../../app-binder/command/SetPluginCommand";import{makeDeviceActionInternalApiMock as C}from"../../app-binder/device-action/__test-utils__/makeInternalApi";import{ProvideTransactionContextTask as d}from"./ProvideTransactionContextTask";describe("ProvideTransactionContextTask",()=>{const e=C(),i=r({data:void 0}),a=r({data:void 0,error:{}});beforeEach(()=>{vi.resetAllMocks()}),describe("run",()=>{const o={clearSignContexts:[{type:n.PLUGIN,payload:"706c7567696e"},{type:n.EXTERNAL_PLUGIN,payload:"65787465726e616c506c7567696e"},{type:n.NFT,payload:"6e6674"},{type:n.TOKEN,payload:"746f6b656e"}],web3Check:null};afterEach(()=>{vi.restoreAllMocks()}),it("should send relative commands when receiving ClearSignContexts of type not trustedName",async()=>{e.sendCommand.mockResolvedValue(i),await new d(e,o).run(),expect(e.sendCommand).toHaveBeenCalledTimes(4),expect(e.sendCommand).toHaveBeenNthCalledWith(o.clearSignContexts.findIndex(t=>t.type===n.PLUGIN)+1,expect.objectContaining(new p({payload:"706c7567696e"}))),expect(e.sendCommand).toHaveBeenNthCalledWith(o.clearSignContexts.findIndex(t=>t.type===n.EXTERNAL_PLUGIN)+1,expect.objectContaining(new l({payload:"65787465726e616c506c7567696e"}))),expect(e.sendCommand).toHaveBeenNthCalledWith(o.clearSignContexts.findIndex(t=>t.type===n.NFT)+1,expect.objectContaining(new c({payload:"6e6674"}))),expect(e.sendCommand).toHaveBeenNthCalledWith(o.clearSignContexts.findIndex(t=>t.type===n.TOKEN)+1,expect.objectContaining(new m({payload:"746f6b656e"})))}),it("should return the command error result and stop when the command fails",async()=>{e.sendCommand.mockReset(),e.sendCommand.mockResolvedValueOnce(a);const t=await new d(e,o).run();expect(e.sendCommand).toHaveBeenCalledTimes(1),expect(t.isJust()).toBe(!0),expect(t.extract()).toStrictEqual(a)})})});
1
+ import{ClearSignContextType as n}from"@ledgerhq/context-module";import{CommandResultFactory as s,hexaStringToBuffer as c,LoadCertificateCommand as m}from"@ledgerhq/device-management-kit";import{ProvideNFTInformationCommand as l}from"../../app-binder/command/ProvideNFTInformationCommand";import{ProvideTokenInformationCommand as C}from"../../app-binder/command/ProvideTokenInformationCommand";import{ProvideWeb3CheckCommand as p}from"../../app-binder/command/ProvideWeb3CheckCommand";import{SetExternalPluginCommand as x}from"../../app-binder/command/SetExternalPluginCommand";import{SetPluginCommand as h}from"../../app-binder/command/SetPluginCommand";import{makeDeviceActionInternalApiMock as y}from"../../app-binder/device-action/__test-utils__/makeInternalApi";import{ProvideTransactionContextTask as a}from"./ProvideTransactionContextTask";describe("ProvideTransactionContextTask",()=>{const e=y(),r=s({data:void 0}),i=s({data:void 0,error:{}});beforeEach(()=>{vi.resetAllMocks()}),describe("run",()=>{const o={clearSignContexts:[{type:n.PLUGIN,payload:"706c7567696e"},{type:n.EXTERNAL_PLUGIN,payload:"65787465726e616c506c7567696e"},{type:n.NFT,payload:"6e6674"},{type:n.TOKEN,payload:"746f6b656e"}],web3Check:null};beforeEach(()=>{vi.resetAllMocks()}),it("should send relative commands when receiving ClearSignContexts of type not trustedName",async()=>{e.sendCommand.mockResolvedValue(r),await new a(e,o).run(),expect(e.sendCommand).toHaveBeenCalledTimes(4),expect(e.sendCommand).toHaveBeenNthCalledWith(o.clearSignContexts.findIndex(t=>t.type===n.PLUGIN)+1,expect.objectContaining(new h({payload:"706c7567696e"}))),expect(e.sendCommand).toHaveBeenNthCalledWith(o.clearSignContexts.findIndex(t=>t.type===n.EXTERNAL_PLUGIN)+1,expect.objectContaining(new x({payload:"65787465726e616c506c7567696e"}))),expect(e.sendCommand).toHaveBeenNthCalledWith(o.clearSignContexts.findIndex(t=>t.type===n.NFT)+1,expect.objectContaining(new l({payload:"6e6674"}))),expect(e.sendCommand).toHaveBeenNthCalledWith(o.clearSignContexts.findIndex(t=>t.type===n.TOKEN)+1,expect.objectContaining(new C({payload:"746f6b656e"})))}),it("should return the command error result and stop when the command fails",async()=>{e.sendCommand.mockResolvedValueOnce(i);const t=await new a(e,o).run();expect(e.sendCommand).toHaveBeenCalledTimes(1),expect(t.isJust()).toBe(!0),expect(t.extract()).toStrictEqual(i)}),it("should send the web3Check command when it is provided",async()=>{e.sendCommand.mockResolvedValue(r);const t=await new a(e,{...o,web3Check:{type:n.WEB3_CHECK,payload:"0x01020304",certificate:{payload:new Uint8Array,keyUsageNumber:1}}}).run();expect(e.sendCommand).toHaveBeenCalledTimes(6),expect(e.sendCommand).toHaveBeenNthCalledWith(1,expect.objectContaining(new m({certificate:new Uint8Array,keyUsage:1}))),expect(e.sendCommand).toHaveBeenNthCalledWith(2,expect.objectContaining(new p({payload:c("0x000401020304"),isFirstChunk:!0}))),expect(t.isJust()).toBe(!1)})})});
2
2
  //# sourceMappingURL=ProvideTransactionContextTask.test.js.map