@ledgerhq/device-signer-kit-ethereum 1.6.0 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/api/SignerEthBuilder.test.js +1 -1
- package/lib/cjs/api/SignerEthBuilder.test.js.map +1 -1
- package/lib/cjs/api/index.js +1 -1
- package/lib/cjs/api/index.js.map +3 -3
- package/lib/cjs/internal/app-binder/command/ProvideNetworkConfigurationCommand.js +2 -0
- package/lib/cjs/internal/app-binder/command/ProvideNetworkConfigurationCommand.js.map +7 -0
- package/lib/cjs/internal/app-binder/command/ProvideNetworkConfigurationCommand.test.js +2 -0
- package/lib/cjs/internal/app-binder/command/ProvideNetworkConfigurationCommand.test.js.map +7 -0
- package/lib/cjs/internal/app-binder/task/BuildTransactionContextTask.js +1 -1
- package/lib/cjs/internal/app-binder/task/BuildTransactionContextTask.js.map +3 -3
- package/lib/cjs/internal/app-binder/task/BuildTransactionContextTask.test.js +1 -1
- package/lib/cjs/internal/app-binder/task/BuildTransactionContextTask.test.js.map +2 -2
- package/lib/cjs/internal/app-binder/task/ProvideTransactionContextTask.js +1 -1
- package/lib/cjs/internal/app-binder/task/ProvideTransactionContextTask.js.map +3 -3
- package/lib/cjs/internal/app-binder/task/ProvideTransactionContextTask.test.js +1 -1
- package/lib/cjs/internal/app-binder/task/ProvideTransactionContextTask.test.js.map +3 -3
- package/lib/cjs/internal/app-binder/task/SendPayloadInChunksTask.js +1 -1
- package/lib/cjs/internal/app-binder/task/SendPayloadInChunksTask.js.map +3 -3
- package/lib/cjs/internal/app-binder/task/SendPayloadInChunksTask.test.js +1 -1
- package/lib/cjs/internal/app-binder/task/SendPayloadInChunksTask.test.js.map +3 -3
- package/lib/cjs/package.json +1 -1
- package/lib/esm/api/SignerEthBuilder.test.js +1 -1
- package/lib/esm/api/SignerEthBuilder.test.js.map +1 -1
- package/lib/esm/api/index.js +1 -1
- package/lib/esm/api/index.js.map +2 -2
- package/lib/esm/internal/app-binder/command/ProvideNetworkConfigurationCommand.js +2 -0
- package/lib/esm/internal/app-binder/command/ProvideNetworkConfigurationCommand.js.map +7 -0
- package/lib/esm/internal/app-binder/command/ProvideNetworkConfigurationCommand.test.js +2 -0
- package/lib/esm/internal/app-binder/command/ProvideNetworkConfigurationCommand.test.js.map +7 -0
- package/lib/esm/internal/app-binder/task/BuildTransactionContextTask.js +1 -1
- package/lib/esm/internal/app-binder/task/BuildTransactionContextTask.js.map +3 -3
- package/lib/esm/internal/app-binder/task/BuildTransactionContextTask.test.js +1 -1
- package/lib/esm/internal/app-binder/task/BuildTransactionContextTask.test.js.map +2 -2
- package/lib/esm/internal/app-binder/task/ProvideTransactionContextTask.js +1 -1
- package/lib/esm/internal/app-binder/task/ProvideTransactionContextTask.js.map +3 -3
- package/lib/esm/internal/app-binder/task/ProvideTransactionContextTask.test.js +1 -1
- package/lib/esm/internal/app-binder/task/ProvideTransactionContextTask.test.js.map +3 -3
- package/lib/esm/internal/app-binder/task/SendPayloadInChunksTask.js +1 -1
- package/lib/esm/internal/app-binder/task/SendPayloadInChunksTask.js.map +3 -3
- package/lib/esm/internal/app-binder/task/SendPayloadInChunksTask.test.js +1 -1
- package/lib/esm/internal/app-binder/task/SendPayloadInChunksTask.test.js.map +3 -3
- package/lib/esm/package.json +1 -1
- package/lib/types/api/index.d.ts +5 -9
- package/lib/types/api/index.d.ts.map +1 -1
- package/lib/types/internal/app-binder/command/ProvideNetworkConfigurationCommand.d.ts +28 -0
- package/lib/types/internal/app-binder/command/ProvideNetworkConfigurationCommand.d.ts.map +1 -0
- package/lib/types/internal/app-binder/command/ProvideNetworkConfigurationCommand.test.d.ts +2 -0
- package/lib/types/internal/app-binder/command/ProvideNetworkConfigurationCommand.test.d.ts.map +1 -0
- package/lib/types/internal/app-binder/task/BuildTransactionContextTask.d.ts.map +1 -1
- package/lib/types/internal/app-binder/task/ProvideTransactionContextTask.d.ts.map +1 -1
- package/lib/types/internal/app-binder/task/SendPayloadInChunksTask.d.ts +1 -0
- package/lib/types/internal/app-binder/task/SendPayloadInChunksTask.d.ts.map +1 -1
- package/lib/types/tsconfig.prod.tsbuildinfo +1 -1
- package/package.json +10 -10
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var n=require("./SignerEthBuilder"),c=require("../internal/DefaultSignerEth"),d=require("../internal/externalTypes");describe("SignerEthBuilder",()=>{const i={dmk:{},sessionId:"",originToken:"test"};test("should be an instance of SignerEth",()=>{const t=new n.SignerEthBuilder(i);t.build(),expect(t).toBeInstanceOf(n.SignerEthBuilder)}),test("should instanciate with default context module",()=>{const o=new n.SignerEthBuilder(i).build(),e=o._container.get(d.externalTypes.ContextModule);expect(o).toBeInstanceOf(c.DefaultSignerEth),expect(e).toBeDefined(),expect(e._loaders).toHaveLength(
|
|
1
|
+
"use strict";var n=require("./SignerEthBuilder"),c=require("../internal/DefaultSignerEth"),d=require("../internal/externalTypes");describe("SignerEthBuilder",()=>{const i={dmk:{},sessionId:"",originToken:"test"};test("should be an instance of SignerEth",()=>{const t=new n.SignerEthBuilder(i);t.build(),expect(t).toBeInstanceOf(n.SignerEthBuilder)}),test("should instanciate with default context module",()=>{const o=new n.SignerEthBuilder(i).build(),e=o._container.get(d.externalTypes.ContextModule);expect(o).toBeInstanceOf(c.DefaultSignerEth),expect(e).toBeDefined(),expect(e._loaders).toHaveLength(7),expect(e._typedDataLoader).toBeDefined(),expect(e._web3CheckLoader).toBeDefined()}),test("should instanciate with custom context module",()=>{const t=new n.SignerEthBuilder(i),o={},e=t.withContextModule(o).build();expect(e).toBeInstanceOf(c.DefaultSignerEth),expect(e._container.get(d.externalTypes.ContextModule)).toBe(o)})});
|
|
2
2
|
//# sourceMappingURL=SignerEthBuilder.test.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/api/SignerEthBuilder.test.ts"],
|
|
4
|
-
"sourcesContent": ["import { type ContextModule } from \"@ledgerhq/context-module\";\nimport { type DeviceManagementKit } from \"@ledgerhq/device-management-kit\";\n\nimport { SignerEthBuilder } from \"@api/SignerEthBuilder\";\nimport { DefaultSignerEth } from \"@internal/DefaultSignerEth\";\nimport { externalTypes } from \"@internal/externalTypes\";\n\ndescribe(\"SignerEthBuilder\", () => {\n const dmk: DeviceManagementKit = {} as DeviceManagementKit;\n const defaultConstructorArgs = { dmk, sessionId: \"\", originToken: \"test\" };\n\n test(\"should be an instance of SignerEth\", () => {\n // GIVEN\n const builder = new SignerEthBuilder(defaultConstructorArgs);\n\n // WHEN\n builder.build();\n\n // THEN\n expect(builder).toBeInstanceOf(SignerEthBuilder);\n });\n\n test(\"should instanciate with default context module\", () => {\n // GIVEN\n const builder = new SignerEthBuilder(defaultConstructorArgs);\n\n // WHEN\n const signer = builder.build();\n const contextModule = signer[\"_container\"].get<ContextModule>(\n externalTypes.ContextModule,\n );\n\n // THEN\n expect(signer).toBeInstanceOf(DefaultSignerEth);\n expect(contextModule).toBeDefined();\n // @ts-expect-error - private property\n expect(contextModule._loaders).toHaveLength(
|
|
4
|
+
"sourcesContent": ["import { type ContextModule } from \"@ledgerhq/context-module\";\nimport { type DeviceManagementKit } from \"@ledgerhq/device-management-kit\";\n\nimport { SignerEthBuilder } from \"@api/SignerEthBuilder\";\nimport { DefaultSignerEth } from \"@internal/DefaultSignerEth\";\nimport { externalTypes } from \"@internal/externalTypes\";\n\ndescribe(\"SignerEthBuilder\", () => {\n const dmk: DeviceManagementKit = {} as DeviceManagementKit;\n const defaultConstructorArgs = { dmk, sessionId: \"\", originToken: \"test\" };\n\n test(\"should be an instance of SignerEth\", () => {\n // GIVEN\n const builder = new SignerEthBuilder(defaultConstructorArgs);\n\n // WHEN\n builder.build();\n\n // THEN\n expect(builder).toBeInstanceOf(SignerEthBuilder);\n });\n\n test(\"should instanciate with default context module\", () => {\n // GIVEN\n const builder = new SignerEthBuilder(defaultConstructorArgs);\n\n // WHEN\n const signer = builder.build();\n const contextModule = signer[\"_container\"].get<ContextModule>(\n externalTypes.ContextModule,\n );\n\n // THEN\n expect(signer).toBeInstanceOf(DefaultSignerEth);\n expect(contextModule).toBeDefined();\n // @ts-expect-error - private property\n expect(contextModule._loaders).toHaveLength(7);\n // @ts-expect-error - private property\n expect(contextModule._typedDataLoader).toBeDefined();\n // @ts-expect-error - private property\n expect(contextModule._web3CheckLoader).toBeDefined();\n });\n\n test(\"should instanciate with custom context module\", () => {\n // GIVEN\n const builder = new SignerEthBuilder(defaultConstructorArgs);\n const contextModule = {} as ContextModule;\n\n // WHEN\n const signer = builder.withContextModule(contextModule).build();\n\n // THEN\n expect(signer).toBeInstanceOf(DefaultSignerEth);\n expect(\n signer[\"_container\"].get<ContextModule>(externalTypes.ContextModule),\n ).toBe(contextModule);\n });\n});\n"],
|
|
5
5
|
"mappings": "aAGA,IAAAA,EAAiC,iCACjCC,EAAiC,sCACjCC,EAA8B,mCAE9B,SAAS,mBAAoB,IAAM,CAEjC,MAAMC,EAAyB,CAAE,IADA,CAAC,EACI,UAAW,GAAI,YAAa,MAAO,EAEzE,KAAK,qCAAsC,IAAM,CAE/C,MAAMC,EAAU,IAAI,mBAAiBD,CAAsB,EAG3DC,EAAQ,MAAM,EAGd,OAAOA,CAAO,EAAE,eAAe,kBAAgB,CACjD,CAAC,EAED,KAAK,iDAAkD,IAAM,CAK3D,MAAMC,EAHU,IAAI,mBAAiBF,CAAsB,EAGpC,MAAM,EACvBG,EAAgBD,EAAO,WAAc,IACzC,gBAAc,aAChB,EAGA,OAAOA,CAAM,EAAE,eAAe,kBAAgB,EAC9C,OAAOC,CAAa,EAAE,YAAY,EAElC,OAAOA,EAAc,QAAQ,EAAE,aAAa,CAAC,EAE7C,OAAOA,EAAc,gBAAgB,EAAE,YAAY,EAEnD,OAAOA,EAAc,gBAAgB,EAAE,YAAY,CACrD,CAAC,EAED,KAAK,gDAAiD,IAAM,CAE1D,MAAMF,EAAU,IAAI,mBAAiBD,CAAsB,EACrDG,EAAgB,CAAC,EAGjBD,EAASD,EAAQ,kBAAkBE,CAAa,EAAE,MAAM,EAG9D,OAAOD,CAAM,EAAE,eAAe,kBAAgB,EAC9C,OACEA,EAAO,WAAc,IAAmB,gBAAc,aAAa,CACrE,EAAE,KAAKC,CAAa,CACtB,CAAC,CACH,CAAC",
|
|
6
6
|
"names": ["import_SignerEthBuilder", "import_DefaultSignerEth", "import_externalTypes", "defaultConstructorArgs", "builder", "signer", "contextModule"]
|
|
7
7
|
}
|
package/lib/cjs/api/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var i=Object.defineProperty;var
|
|
1
|
+
"use strict";var i=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var S=Object.getOwnPropertyNames;var u=Object.prototype.hasOwnProperty;var s=(r,n)=>{for(var a in n)i(r,a,{get:n[a],enumerable:!0})},o=(r,n,a,D)=>{if(n&&typeof n=="object"||typeof n=="function")for(let p of S(n))!u.call(r,p)&&p!==a&&i(r,p,{get:()=>n[p],enumerable:!(D=g(n,p))||D.enumerable});return r},e=(r,n,a)=>(o(r,n,"default"),a&&o(a,n,"default"));var d=r=>o(i({},"__esModule",{value:!0}),r);var t={};s(t,{SignTransactionDAStep:()=>y.SignTransactionDAStep,SignTypedDataDAStateStep:()=>A.SignTypedDataDAStateStep});module.exports=d(t);var y=require("./app-binder/SignTransactionDeviceActionTypes"),A=require("./app-binder/SignTypedDataDeviceActionTypes");e(t,require("./model/Address"),module.exports);e(t,require("./model/AddressOptions"),module.exports);e(t,require("./model/Signature"),module.exports);e(t,require("./model/TransactionOptions"),module.exports);e(t,require("./model/TransactionType"),module.exports);e(t,require("./model/TypedData"),module.exports);e(t,require("./SignerEth"),module.exports);e(t,require("./SignerEthBuilder"),module.exports);0&&(module.exports={SignTransactionDAStep,SignTypedDataDAStateStep,...require("./model/Address"),...require("./model/AddressOptions"),...require("./model/Signature"),...require("./model/TransactionOptions"),...require("./model/TransactionType"),...require("./model/TypedData"),...require("./SignerEth"),...require("./SignerEthBuilder")});
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/lib/cjs/api/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/api/index.ts"],
|
|
4
|
-
"sourcesContent": ["export
|
|
5
|
-
"mappings": "2dAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,4HAAAE,EAAAF,
|
|
6
|
-
"names": ["api_exports", "__export", "__toCommonJS", "
|
|
4
|
+
"sourcesContent": ["export {\n type GetAddressDAError,\n type GetAddressDAIntermediateValue,\n type GetAddressDAOutput,\n type GetAddressDAReturnType,\n} from \"@api/app-binder/GetAddressDeviceActionTypes\";\nexport {\n type SignDelegationAuthorizationDAError,\n type SignDelegationAuthorizationDAInput,\n type SignDelegationAuthorizationDAIntermediateValue,\n type SignDelegationAuthorizationDAOutput,\n type SignDelegationAuthorizationDAReturnType,\n type SignDelegationAuthorizationDAState,\n} from \"@api/app-binder/SignDelegationAuthorizationTypes\";\nexport {\n type SignPersonalMessageDAError,\n type SignPersonalMessageDAIntermediateValue,\n type SignPersonalMessageDAOutput,\n type SignPersonalMessageDAReturnType,\n} from \"@api/app-binder/SignPersonalMessageDeviceActionTypes\";\nexport {\n type SignTransactionDAError,\n type SignTransactionDAInput,\n type SignTransactionDAIntermediateValue,\n type SignTransactionDAInternalState,\n type SignTransactionDAOutput,\n type SignTransactionDAReturnType,\n type SignTransactionDAState,\n SignTransactionDAStep,\n} from \"@api/app-binder/SignTransactionDeviceActionTypes\";\nexport {\n type SignTypedDataDAError,\n type SignTypedDataDAInput,\n type SignTypedDataDAIntermediateValue,\n type SignTypedDataDAInternalState,\n type SignTypedDataDAOutput,\n type SignTypedDataDAReturnType,\n type SignTypedDataDAState,\n SignTypedDataDAStateStep,\n} from \"@api/app-binder/SignTypedDataDeviceActionTypes\";\nexport * from \"@api/model/Address\";\nexport * from \"@api/model/AddressOptions\";\nexport * from \"@api/model/Signature\";\nexport * from \"@api/model/TransactionOptions\";\nexport * from \"@api/model/TransactionType\";\nexport * from \"@api/model/TypedData\";\nexport * from \"@api/SignerEth\";\nexport * from \"@api/SignerEthBuilder\";\n"],
|
|
5
|
+
"mappings": "2dAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,4HAAAE,EAAAF,GAoBA,IAAAG,EASO,4DACPC,EASO,0DACPC,EAAAL,EAAc,8BAxCd,gBAyCAK,EAAAL,EAAc,qCAzCd,gBA0CAK,EAAAL,EAAc,gCA1Cd,gBA2CAK,EAAAL,EAAc,yCA3Cd,gBA4CAK,EAAAL,EAAc,sCA5Cd,gBA6CAK,EAAAL,EAAc,gCA7Cd,gBA8CAK,EAAAL,EAAc,0BA9Cd,gBA+CAK,EAAAL,EAAc,iCA/Cd",
|
|
6
|
+
"names": ["api_exports", "__export", "__toCommonJS", "import_SignTransactionDeviceActionTypes", "import_SignTypedDataDeviceActionTypes", "__reExport"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var n=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var C=Object.prototype.hasOwnProperty;var A=(e,r)=>{for(var o in r)n(e,o,{get:r[o],enumerable:!0})},g=(e,r,o,i)=>{if(r&&typeof r=="object"||typeof r=="function")for(let t of l(r))!C.call(e,t)&&t!==o&&n(e,t,{get:()=>r[t],enumerable:!(i=u(r,t))||i.enumerable});return e};var y=e=>g(n({},"__esModule",{value:!0}),e);var f={};A(f,{NetworkConfigurationType:()=>m,ProvideNetworkConfigurationCommand:()=>E});module.exports=y(f);var d=require("@ledgerhq/device-management-kit"),s=require("@ledgerhq/signer-utils"),p=require("purify-ts"),a=require("./utils/ethAppErrors"),m=(o=>(o[o.CONFIGURATION=0]="CONFIGURATION",o[o.ICON=1]="ICON",o))(m||{});class E{constructor(r){this.args=r}errorHelper=new s.CommandErrorHelper(a.ETH_APP_ERRORS,a.EthAppCommandErrorFactory);getApdu(){const r={cla:224,ins:48,p1:this.args.isFirstChunk?1:0,p2:this.args.configurationType};return new d.ApduBuilder(r).addBufferToData(this.args.data).build()}parseResponse(r){return p.Maybe.fromNullable(this.errorHelper.getError(r)).orDefault((0,d.CommandResultFactory)({data:void 0}))}}0&&(module.exports={NetworkConfigurationType,ProvideNetworkConfigurationCommand});
|
|
2
|
+
//# sourceMappingURL=ProvideNetworkConfigurationCommand.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/internal/app-binder/command/ProvideNetworkConfigurationCommand.ts"],
|
|
4
|
+
"sourcesContent": ["// https://github.com/LedgerHQ/app-ethereum/blob/develop/doc/ethapp.adoc#provide-network-configuration\nimport {\n type Apdu,\n ApduBuilder,\n type ApduBuilderArgs,\n type ApduResponse,\n type Command,\n type CommandResult,\n CommandResultFactory,\n} from \"@ledgerhq/device-management-kit\";\nimport { CommandErrorHelper } from \"@ledgerhq/signer-utils\";\nimport { Maybe } from \"purify-ts\";\n\nimport {\n ETH_APP_ERRORS,\n EthAppCommandErrorFactory,\n type EthErrorCodes,\n} from \"./utils/ethAppErrors\";\n\nexport enum NetworkConfigurationType {\n CONFIGURATION = 0x00,\n ICON = 0x01,\n}\n\nexport type ProvideNetworkConfigurationCommandArgs = {\n /**\n * The network configuration data to provide in chunks\n */\n readonly data: Uint8Array;\n /**\n * If this is the first chunk of the network configuration\n */\n readonly isFirstChunk: boolean;\n /**\n * The type of network configuration being provided\n */\n readonly configurationType: NetworkConfigurationType;\n};\n\nexport class ProvideNetworkConfigurationCommand\n implements\n Command<void, ProvideNetworkConfigurationCommandArgs, EthErrorCodes>\n{\n private readonly errorHelper = new CommandErrorHelper<void, EthErrorCodes>(\n ETH_APP_ERRORS,\n EthAppCommandErrorFactory,\n );\n\n constructor(private readonly args: ProvideNetworkConfigurationCommandArgs) {}\n\n getApdu(): Apdu {\n const provideNetworkConfigurationArgs: ApduBuilderArgs = {\n cla: 0xe0,\n ins: 0x30,\n p1: this.args.isFirstChunk ? 0x01 : 0x00,\n p2: this.args.configurationType,\n };\n\n return new ApduBuilder(provideNetworkConfigurationArgs)\n .addBufferToData(this.args.data)\n .build();\n }\n\n parseResponse(response: ApduResponse): CommandResult<void, EthErrorCodes> {\n return Maybe.fromNullable(this.errorHelper.getError(response)).orDefault(\n CommandResultFactory({ data: undefined }),\n );\n }\n}\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,8BAAAE,EAAA,uCAAAC,IAAA,eAAAC,EAAAJ,GACA,IAAAK,EAQO,2CACPC,EAAmC,kCACnCC,EAAsB,qBAEtBC,EAIO,gCAEKN,OACVA,IAAA,cAAgB,GAAhB,gBACAA,IAAA,KAAO,GAAP,OAFUA,OAAA,IAoBL,MAAMC,CAGb,CAME,YAA6BM,EAA8C,CAA9C,UAAAA,CAA+C,CAL3D,YAAc,IAAI,qBACjC,iBACA,2BACF,EAIA,SAAgB,CACd,MAAMC,EAAmD,CACvD,IAAK,IACL,IAAK,GACL,GAAI,KAAK,KAAK,aAAe,EAAO,EACpC,GAAI,KAAK,KAAK,iBAChB,EAEA,OAAO,IAAI,cAAYA,CAA+B,EACnD,gBAAgB,KAAK,KAAK,IAAI,EAC9B,MAAM,CACX,CAEA,cAAcC,EAA4D,CACxE,OAAO,QAAM,aAAa,KAAK,YAAY,SAASA,CAAQ,CAAC,EAAE,aAC7D,wBAAqB,CAAE,KAAM,MAAU,CAAC,CAC1C,CACF,CACF",
|
|
6
|
+
"names": ["ProvideNetworkConfigurationCommand_exports", "__export", "NetworkConfigurationType", "ProvideNetworkConfigurationCommand", "__toCommonJS", "import_device_management_kit", "import_signer_utils", "import_purify_ts", "import_ethAppErrors", "args", "provideNetworkConfigurationArgs", "response"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var n=require("@ledgerhq/device-management-kit"),s=require("./utils/ethAppErrors"),r=require("./ProvideNetworkConfigurationCommand");describe("ProvideNetworkConfigurationCommand",()=>{describe("getApdu",()=>{it("should return the raw APDU for the first chunk",()=>{const t={data:Uint8Array.from([1,2,3]),isFirstChunk:!0,configurationType:r.NetworkConfigurationType.CONFIGURATION},e=new r.ProvideNetworkConfigurationCommand(t).getApdu();expect(e.getRawApdu()).toStrictEqual(Uint8Array.from([224,48,1,0,3,1,2,3]))}),it("should return the raw APDU for the subsequent chunk",()=>{const t={data:Uint8Array.from([4,5,6]),isFirstChunk:!1,configurationType:r.NetworkConfigurationType.CONFIGURATION},e=new r.ProvideNetworkConfigurationCommand(t).getApdu();expect(e.getRawApdu()).toStrictEqual(Uint8Array.from([224,48,0,0,3,4,5,6]))})}),describe("parseResponse",()=>{it("should return an error if the response status code is invalid",()=>{const t={data:Uint8Array.from([]),statusCode:Uint8Array.from([109,0])},e=new r.ProvideNetworkConfigurationCommand({data:new Uint8Array(0),isFirstChunk:!0,configurationType:r.NetworkConfigurationType.CONFIGURATION}).parseResponse(t);if((0,n.isSuccessCommandResult)(e))throw new Error("Expected an error");expect(e.error).toBeDefined(),expect(e.error).toBeInstanceOf(s.EthAppCommandError)}),it("should return a success result if the response status code is valid",()=>{const t={data:Uint8Array.from([]),statusCode:Uint8Array.from([144,0])},e=new r.ProvideNetworkConfigurationCommand({data:new Uint8Array(0),isFirstChunk:!0,configurationType:r.NetworkConfigurationType.CONFIGURATION}).parseResponse(t);if((0,n.isSuccessCommandResult)(e))expect(e.data).toBeUndefined();else throw new Error("Expected a success result")})})});
|
|
2
|
+
//# sourceMappingURL=ProvideNetworkConfigurationCommand.test.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/internal/app-binder/command/ProvideNetworkConfigurationCommand.test.ts"],
|
|
4
|
+
"sourcesContent": ["import {\n type ApduResponse,\n isSuccessCommandResult,\n} from \"@ledgerhq/device-management-kit\";\n\nimport { EthAppCommandError } from \"./utils/ethAppErrors\";\nimport {\n NetworkConfigurationType,\n ProvideNetworkConfigurationCommand,\n type ProvideNetworkConfigurationCommandArgs,\n} from \"./ProvideNetworkConfigurationCommand\";\n\ndescribe(\"ProvideNetworkConfigurationCommand\", () => {\n describe(\"getApdu\", () => {\n it(\"should return the raw APDU for the first chunk\", () => {\n // GIVEN\n const args: ProvideNetworkConfigurationCommandArgs = {\n data: Uint8Array.from([0x01, 0x02, 0x03]),\n isFirstChunk: true,\n configurationType: NetworkConfigurationType.CONFIGURATION,\n };\n\n // WHEN\n const command = new ProvideNetworkConfigurationCommand(args);\n const apdu = command.getApdu();\n\n // THEN\n expect(apdu.getRawApdu()).toStrictEqual(\n Uint8Array.from([0xe0, 0x30, 0x01, 0x00, 0x03, 0x01, 0x02, 0x03]),\n );\n });\n\n it(\"should return the raw APDU for the subsequent chunk\", () => {\n // GIVEN\n const args: ProvideNetworkConfigurationCommandArgs = {\n data: Uint8Array.from([0x04, 0x05, 0x06]),\n isFirstChunk: false,\n configurationType: NetworkConfigurationType.CONFIGURATION,\n };\n\n // WHEN\n const command = new ProvideNetworkConfigurationCommand(args);\n const apdu = command.getApdu();\n\n // THEN\n expect(apdu.getRawApdu()).toStrictEqual(\n Uint8Array.from([0xe0, 0x30, 0x00, 0x00, 0x03, 0x04, 0x05, 0x06]),\n );\n });\n });\n\n describe(\"parseResponse\", () => {\n it(\"should return an error if the response status code is invalid\", () => {\n // GIVEN\n const response: ApduResponse = {\n data: Uint8Array.from([]),\n statusCode: Uint8Array.from([0x6d, 0x00]), // Invalid status code\n };\n\n // WHEN\n const command = new ProvideNetworkConfigurationCommand({\n data: new Uint8Array(0),\n isFirstChunk: true,\n configurationType: NetworkConfigurationType.CONFIGURATION,\n });\n const result = command.parseResponse(response);\n\n // THEN\n if (isSuccessCommandResult(result)) {\n throw new Error(\"Expected an error\");\n } else {\n expect(result.error).toBeDefined();\n expect(result.error).toBeInstanceOf(EthAppCommandError);\n }\n });\n\n it(\"should return a success result if the response status code is valid\", () => {\n // GIVEN\n const response: ApduResponse = {\n data: Uint8Array.from([]),\n statusCode: Uint8Array.from([0x90, 0x00]), // Success status code\n };\n\n // WHEN\n const command = new ProvideNetworkConfigurationCommand({\n data: new Uint8Array(0),\n isFirstChunk: true,\n configurationType: NetworkConfigurationType.CONFIGURATION,\n });\n const result = command.parseResponse(response);\n\n // THEN\n if (!isSuccessCommandResult(result)) {\n throw new Error(\"Expected a success result\");\n } else {\n expect(result.data).toBeUndefined();\n }\n });\n });\n});\n"],
|
|
5
|
+
"mappings": "aAAA,IAAAA,EAGO,2CAEPC,EAAmC,gCACnCC,EAIO,gDAEP,SAAS,qCAAsC,IAAM,CACnD,SAAS,UAAW,IAAM,CACxB,GAAG,iDAAkD,IAAM,CAEzD,MAAMC,EAA+C,CACnD,KAAM,WAAW,KAAK,CAAC,EAAM,EAAM,CAAI,CAAC,EACxC,aAAc,GACd,kBAAmB,2BAAyB,aAC9C,EAIMC,EADU,IAAI,qCAAmCD,CAAI,EACtC,QAAQ,EAG7B,OAAOC,EAAK,WAAW,CAAC,EAAE,cACxB,WAAW,KAAK,CAAC,IAAM,GAAM,EAAM,EAAM,EAAM,EAAM,EAAM,CAAI,CAAC,CAClE,CACF,CAAC,EAED,GAAG,sDAAuD,IAAM,CAE9D,MAAMD,EAA+C,CACnD,KAAM,WAAW,KAAK,CAAC,EAAM,EAAM,CAAI,CAAC,EACxC,aAAc,GACd,kBAAmB,2BAAyB,aAC9C,EAIMC,EADU,IAAI,qCAAmCD,CAAI,EACtC,QAAQ,EAG7B,OAAOC,EAAK,WAAW,CAAC,EAAE,cACxB,WAAW,KAAK,CAAC,IAAM,GAAM,EAAM,EAAM,EAAM,EAAM,EAAM,CAAI,CAAC,CAClE,CACF,CAAC,CACH,CAAC,EAED,SAAS,gBAAiB,IAAM,CAC9B,GAAG,gEAAiE,IAAM,CAExE,MAAMC,EAAyB,CAC7B,KAAM,WAAW,KAAK,CAAC,CAAC,EACxB,WAAY,WAAW,KAAK,CAAC,IAAM,CAAI,CAAC,CAC1C,EAQMC,EALU,IAAI,qCAAmC,CACrD,KAAM,IAAI,WAAW,CAAC,EACtB,aAAc,GACd,kBAAmB,2BAAyB,aAC9C,CAAC,EACsB,cAAcD,CAAQ,EAG7C,MAAI,0BAAuBC,CAAM,EAC/B,MAAM,IAAI,MAAM,mBAAmB,EAEnC,OAAOA,EAAO,KAAK,EAAE,YAAY,EACjC,OAAOA,EAAO,KAAK,EAAE,eAAe,oBAAkB,CAE1D,CAAC,EAED,GAAG,sEAAuE,IAAM,CAE9E,MAAMD,EAAyB,CAC7B,KAAM,WAAW,KAAK,CAAC,CAAC,EACxB,WAAY,WAAW,KAAK,CAAC,IAAM,CAAI,CAAC,CAC1C,EAQMC,EALU,IAAI,qCAAmC,CACrD,KAAM,IAAI,WAAW,CAAC,EACtB,aAAc,GACd,kBAAmB,2BAAyB,aAC9C,CAAC,EACsB,cAAcD,CAAQ,EAG7C,MAAK,0BAAuBC,CAAM,EAGhC,OAAOA,EAAO,IAAI,EAAE,cAAc,MAFlC,OAAM,IAAI,MAAM,2BAA2B,CAI/C,CAAC,CACH,CAAC,CACH,CAAC",
|
|
6
|
+
"names": ["import_device_management_kit", "import_ethAppErrors", "import_ProvideNetworkConfigurationCommand", "args", "apdu", "response", "result"]
|
|
7
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var y=Object.defineProperty;var O=Object.getOwnPropertyDescriptor;var _=Object.getOwnPropertyNames;var R=Object.prototype.hasOwnProperty;var v=(a,e)=>{for(var i in e)y(a,i,{get:e[i],enumerable:!0})},M=(a,e,i,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of _(e))!R.call(a,o)&&o!==i&&y(a,o,{get:()=>e[o],enumerable:!(s=O(e,o))||s.enumerable});return a};var b=a=>M(y({},"__esModule",{value:!0}),a);var D={};v(D,{BuildTransactionContextTask:()=>w});module.exports=b(D);var n=require("@ledgerhq/context-module"),p=require("@ledgerhq/device-management-kit"),u=require("../../../api/model/ClearSigningType"),I=require("../../app-binder/command/GetChallengeCommand"),h=require("../../app-binder/task/GetWeb3CheckTask"),A=require("../../shared/utils/ApplicationChecker");class w{constructor(e,i,s=(o,d)=>new h.GetWeb3CheckTask(o,d)){this._api=e;this._args=i;this.getWeb3ChecksFactory=s}async run(){const{contextModule:e,options:i,appConfig:s,derivationPath:o,transaction:d,subset:T}=this._args,S=this._api.getDeviceSessionState();let l=[],x=[],m=u.ClearSigningType.BASIC,c=null;s.web3ChecksEnabled&&(c=(await this.getWeb3ChecksFactory(this._api,{contextModule:e,derivationPath:o,subset:T,transaction:d}).run()).web3Check);let f;if(S.deviceModelId!==p.DeviceModelId.NANO_S){const t=await this._api.sendCommand(new I.GetChallengeCommand);(0,p.isSuccessCommandResult)(t)&&(f=t.data.challenge)}const N=await e.getContexts({challenge:f,domain:i.domain,deviceModelId:S.deviceModelId,...T}),C=N.filter(t=>t.type!==n.ClearSignContextType.ERROR&&t.type!==n.ClearSignContextType.ENUM),E=N.filter(t=>t.type===n.ClearSignContextType.ENUM),g=C.find(t=>t.type===n.ClearSignContextType.TRANSACTION_INFO);if(!this.supportsGenericParser(S,s)||g===void 0)l=C.filter(t=>t.type!==n.ClearSignContextType.TRANSACTION_INFO&&t.type!==n.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION),c&&(l=[c,...l]);else if(g.certificate){const t=C.filter(r=>r.type===n.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION),k=C.filter(r=>r.type===n.ClearSignContextType.PROXY_DELEGATE_CALL);l=[...C.filter(r=>r.type===n.ClearSignContextType.DYNAMIC_NETWORK||r.type===n.ClearSignContextType.DYNAMIC_NETWORK_ICON),...k,g,...t,...c?[c]:[]],x=[...E],m=u.ClearSigningType.EIP7730}return{clearSignContexts:l,clearSignContextsOptional:x,clearSigningType:m}}supportsGenericParser(e,i){return new A.ApplicationChecker(e,i).withMinVersionExclusive("1.14.0").excludeDeviceModel(p.DeviceModelId.NANO_S).check()}}0&&(module.exports={BuildTransactionContextTask});
|
|
2
2
|
//# sourceMappingURL=BuildTransactionContextTask.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/internal/app-binder/task/BuildTransactionContextTask.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n type ClearSignContextSuccess,\n type ClearSignContextSuccessType,\n ClearSignContextType,\n type ContextModule,\n type TransactionSubset,\n} from \"@ledgerhq/context-module\";\nimport {\n DeviceModelId,\n type DeviceSessionState,\n type InternalApi,\n isSuccessCommandResult,\n} from \"@ledgerhq/device-management-kit\";\n\nimport { type GetConfigCommandResponse } from \"@api/app-binder/GetConfigCommandTypes\";\nimport { ClearSigningType } from \"@api/model/ClearSigningType\";\nimport { type TransactionOptions } from \"@api/model/TransactionOptions\";\nimport { GetChallengeCommand } from \"@internal/app-binder/command/GetChallengeCommand\";\nimport {\n GetWeb3CheckTask,\n type GetWeb3CheckTaskArgs,\n} from \"@internal/app-binder/task/GetWeb3CheckTask\";\nimport { ApplicationChecker } from \"@internal/shared/utils/ApplicationChecker\";\n\nexport type BuildTransactionTaskResult = {\n readonly clearSignContexts: ClearSignContextSuccess[];\n readonly clearSignContextsOptional: ClearSignContextSuccess[];\n readonly clearSigningType: ClearSigningType;\n};\n\nexport type BuildTransactionContextTaskArgs = {\n readonly contextModule: ContextModule;\n readonly options: TransactionOptions;\n readonly appConfig: GetConfigCommandResponse;\n readonly derivationPath: string;\n readonly transaction: Uint8Array;\n readonly subset: TransactionSubset;\n};\n\nexport class BuildTransactionContextTask {\n constructor(\n private readonly _api: InternalApi,\n private readonly _args: BuildTransactionContextTaskArgs,\n private readonly getWeb3ChecksFactory = (\n api: InternalApi,\n args: GetWeb3CheckTaskArgs,\n ) => new GetWeb3CheckTask(api, args),\n ) {}\n\n async run(): Promise<BuildTransactionTaskResult> {\n const {\n contextModule,\n options,\n appConfig,\n derivationPath,\n transaction,\n subset,\n } = this._args;\n const deviceState = this._api.getDeviceSessionState();\n let filteredContexts: ClearSignContextSuccess[] = [];\n let filteredContextOptional: ClearSignContextSuccess[] = [];\n let clearSigningType: ClearSigningType = ClearSigningType.BASIC;\n\n // Run the web3checks if needed\n let web3Check: ClearSignContextSuccess<ClearSignContextType.WEB3_CHECK> | null =\n null;\n if (appConfig.web3ChecksEnabled) {\n web3Check = (\n await this.getWeb3ChecksFactory(this._api, {\n contextModule,\n derivationPath,\n subset,\n transaction,\n }).run()\n ).web3Check;\n }\n\n // Get challenge (not supported on Nano S)\n let challenge: string | undefined = undefined;\n if (deviceState.deviceModelId !== DeviceModelId.NANO_S) {\n const challengeRes = await this._api.sendCommand(\n new GetChallengeCommand(),\n );\n if (isSuccessCommandResult(challengeRes)) {\n challenge = challengeRes.data.challenge;\n }\n }\n\n // Get the clear sign contexts\n const clearSignContexts
|
|
5
|
-
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,iCAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,
|
|
6
|
-
"names": ["BuildTransactionContextTask_exports", "__export", "BuildTransactionContextTask", "__toCommonJS", "import_context_module", "import_device_management_kit", "import_ClearSigningType", "import_GetChallengeCommand", "import_GetWeb3CheckTask", "import_ApplicationChecker", "_api", "_args", "getWeb3ChecksFactory", "api", "args", "contextModule", "options", "appConfig", "derivationPath", "transaction", "subset", "deviceState", "filteredContexts", "filteredContextOptional", "clearSigningType", "web3Check", "challenge", "challengeRes", "clearSignContexts", "clearSignContextsSuccess", "context", "transactionEnums", "transactionInfo", "ctx", "transactionFields"]
|
|
4
|
+
"sourcesContent": ["import {\n type ClearSignContext,\n type ClearSignContextSuccess,\n type ClearSignContextSuccessType,\n ClearSignContextType,\n type ContextModule,\n type TransactionSubset,\n} from \"@ledgerhq/context-module\";\nimport {\n DeviceModelId,\n type DeviceSessionState,\n type InternalApi,\n isSuccessCommandResult,\n} from \"@ledgerhq/device-management-kit\";\n\nimport { type GetConfigCommandResponse } from \"@api/app-binder/GetConfigCommandTypes\";\nimport { ClearSigningType } from \"@api/model/ClearSigningType\";\nimport { type TransactionOptions } from \"@api/model/TransactionOptions\";\nimport { GetChallengeCommand } from \"@internal/app-binder/command/GetChallengeCommand\";\nimport {\n GetWeb3CheckTask,\n type GetWeb3CheckTaskArgs,\n} from \"@internal/app-binder/task/GetWeb3CheckTask\";\nimport { ApplicationChecker } from \"@internal/shared/utils/ApplicationChecker\";\n\nexport type BuildTransactionTaskResult = {\n readonly clearSignContexts: ClearSignContextSuccess[];\n readonly clearSignContextsOptional: ClearSignContextSuccess[];\n readonly clearSigningType: ClearSigningType;\n};\n\nexport type BuildTransactionContextTaskArgs = {\n readonly contextModule: ContextModule;\n readonly options: TransactionOptions;\n readonly appConfig: GetConfigCommandResponse;\n readonly derivationPath: string;\n readonly transaction: Uint8Array;\n readonly subset: TransactionSubset;\n};\n\nexport class BuildTransactionContextTask {\n constructor(\n private readonly _api: InternalApi,\n private readonly _args: BuildTransactionContextTaskArgs,\n private readonly getWeb3ChecksFactory = (\n api: InternalApi,\n args: GetWeb3CheckTaskArgs,\n ) => new GetWeb3CheckTask(api, args),\n ) {}\n\n async run(): Promise<BuildTransactionTaskResult> {\n const {\n contextModule,\n options,\n appConfig,\n derivationPath,\n transaction,\n subset,\n } = this._args;\n const deviceState = this._api.getDeviceSessionState();\n let filteredContexts: ClearSignContextSuccess[] = [];\n let filteredContextOptional: ClearSignContextSuccess[] = [];\n let clearSigningType: ClearSigningType = ClearSigningType.BASIC;\n\n // Run the web3checks if needed\n let web3Check: ClearSignContextSuccess<ClearSignContextType.WEB3_CHECK> | null =\n null;\n if (appConfig.web3ChecksEnabled) {\n web3Check = (\n await this.getWeb3ChecksFactory(this._api, {\n contextModule,\n derivationPath,\n subset,\n transaction,\n }).run()\n ).web3Check;\n }\n\n // Get challenge (not supported on Nano S)\n let challenge: string | undefined = undefined;\n if (deviceState.deviceModelId !== DeviceModelId.NANO_S) {\n const challengeRes = await this._api.sendCommand(\n new GetChallengeCommand(),\n );\n if (isSuccessCommandResult(challengeRes)) {\n challenge = challengeRes.data.challenge;\n }\n }\n\n // Get the clear sign contexts\n const clearSignContexts: ClearSignContext[] =\n await contextModule.getContexts({\n challenge: challenge,\n domain: options.domain,\n deviceModelId: deviceState.deviceModelId,\n ...subset,\n });\n\n // NOTE: we need to filter out the ENUM and ERROR types\n // ENUM are handled differently\n // ERROR are not handled at all for now\n const clearSignContextsSuccess: ClearSignContextSuccess<\n Exclude<ClearSignContextSuccessType, ClearSignContextType.ENUM>\n >[] = clearSignContexts.filter(\n (context) =>\n context.type !== ClearSignContextType.ERROR &&\n context.type !== ClearSignContextType.ENUM,\n );\n\n // Retrieve all ENUM contexts\n const transactionEnums: ClearSignContextSuccess<ClearSignContextType.ENUM>[] =\n clearSignContexts.filter(\n (context) => context.type === ClearSignContextType.ENUM,\n );\n\n const transactionInfo = clearSignContextsSuccess.find(\n (ctx) => ctx.type === ClearSignContextType.TRANSACTION_INFO,\n );\n\n // If the device does not support the generic parser,\n // we need to filter out the transaction info and transaction field description\n // as they are not supported by the device\n if (\n !this.supportsGenericParser(deviceState, appConfig) ||\n transactionInfo === undefined\n ) {\n filteredContexts = clearSignContextsSuccess.filter(\n (ctx) =>\n ctx.type !== ClearSignContextType.TRANSACTION_INFO &&\n ctx.type !== ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n );\n\n // If the device supports the web3 check, we need to add it to the list of contexts\n if (web3Check) {\n filteredContexts = [web3Check, ...filteredContexts];\n }\n } else if (transactionInfo.certificate) {\n const transactionFields = clearSignContextsSuccess.filter(\n (ctx) =>\n ctx.type === ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n );\n const proxyContexts = clearSignContextsSuccess.filter(\n (ctx) => ctx.type === ClearSignContextType.PROXY_DELEGATE_CALL,\n );\n const dynamicNetworkContexts = clearSignContextsSuccess.filter(\n (ctx) =>\n ctx.type === ClearSignContextType.DYNAMIC_NETWORK ||\n ctx.type === ClearSignContextType.DYNAMIC_NETWORK_ICON,\n );\n\n filteredContexts = [\n ...dynamicNetworkContexts,\n ...proxyContexts,\n transactionInfo,\n ...transactionFields,\n ...(web3Check ? [web3Check] : []),\n ];\n filteredContextOptional = [...transactionEnums];\n clearSigningType = ClearSigningType.EIP7730;\n }\n\n return {\n clearSignContexts: filteredContexts,\n clearSignContextsOptional: filteredContextOptional,\n clearSigningType,\n };\n }\n\n private supportsGenericParser(\n deviceState: DeviceSessionState,\n appConfig: GetConfigCommandResponse,\n ): boolean {\n return new ApplicationChecker(deviceState, appConfig)\n .withMinVersionExclusive(\"1.14.0\")\n .excludeDeviceModel(DeviceModelId.NANO_S)\n .check();\n }\n}\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,iCAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAOO,oCACPC,EAKO,2CAGPC,EAAiC,uCAEjCC,EAAoC,4DACpCC,EAGO,sDACPC,EAAmC,qDAiB5B,MAAMP,CAA4B,CACvC,YACmBQ,EACAC,EACAC,EAAuB,CACtCC,EACAC,IACG,IAAI,mBAAiBD,EAAKC,CAAI,EACnC,CANiB,UAAAJ,EACA,WAAAC,EACA,0BAAAC,CAIhB,CAEH,MAAM,KAA2C,CAC/C,KAAM,CACJ,cAAAG,EACA,QAAAC,EACA,UAAAC,EACA,eAAAC,EACA,YAAAC,EACA,OAAAC,CACF,EAAI,KAAK,MACHC,EAAc,KAAK,KAAK,sBAAsB,EACpD,IAAIC,EAA8C,CAAC,EAC/CC,EAAqD,CAAC,EACtDC,EAAqC,mBAAiB,MAGtDC,EACF,KACER,EAAU,oBACZQ,GACE,MAAM,KAAK,qBAAqB,KAAK,KAAM,CACzC,cAAAV,EACA,eAAAG,EACA,OAAAE,EACA,YAAAD,CACF,CAAC,EAAE,IAAI,GACP,WAIJ,IAAIO,EACJ,GAAIL,EAAY,gBAAkB,gB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AAmB,gBAAc,MAAM,EACvC,MAAM,CACX,CACF",
|
|
6
|
+
"names": ["BuildTransactionContextTask_exports", "__export", "BuildTransactionContextTask", "__toCommonJS", "import_context_module", "import_device_management_kit", "import_ClearSigningType", "import_GetChallengeCommand", "import_GetWeb3CheckTask", "import_ApplicationChecker", "_api", "_args", "getWeb3ChecksFactory", "api", "args", "contextModule", "options", "appConfig", "derivationPath", "transaction", "subset", "deviceState", "filteredContexts", "filteredContextOptional", "clearSigningType", "web3Check", "challenge", "challengeRes", "clearSignContexts", "clearSignContextsSuccess", "context", "transactionEnums", "transactionInfo", "ctx", "transactionFields", "proxyContexts"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var n=require("@ledgerhq/context-module"),t=require("@ledgerhq/device-management-kit"),S=require("ethers"),d=require("../../../api/model/ClearSigningType"),y=require("../../app-binder/device-action/__test-utils__/makeInternalApi"),l=require("./BuildTransactionContextTask"),g=require("./GetWeb3CheckTask");describe("BuildTransactionContextTask",()=>{const s={getContext:vi.fn(),getContexts:vi.fn(),getTypedDataFilters:vi.fn(),getWeb3Checks:vi.fn(),getSolanaContext:vi.fn()},x={domain:"domain-name.eth"},C=(0,t.hexaStringToBuffer)(S.Transaction.from({chainId:1n,nonce:0,data:"0x"}).unsignedSerialized),r={keyUsageNumber:1,payload:new Uint8Array([1,2,3])};let c;const a=(0,y.makeDeviceActionInternalApiMock)(),i=vi.fn();function u(e){return{blindSigningEnabled:!1,web3ChecksEnabled:e,web3ChecksOptIn:!1,version:"1.13.0"}}beforeEach(()=>{vi.resetAllMocks(),a.sendCommand.mockResolvedValue((0,t.CommandResultFactory)({data:{challenge:"challenge"}})),i.mockReturnValue({run:async()=>Promise.resolve({web3Check:null})}),c={contextModule:s,subset:{chainId:1,to:void 0,data:"0x",selector:"0x"},transaction:C,options:x,appConfig:u(!1),derivationPath:"44'/60'/0'/0/0"}}),it("should init with a default GetWeb3CheckTaskFactory",()=>{const e=new l.BuildTransactionContextTask(a,c);expect(e.getWeb3ChecksFactory).toBeDefined(),expect(e.getWeb3ChecksFactory(a,{contextModule:c.contextModule,derivationPath:c.derivationPath,subset:c.subset,transaction:c.transaction})).toBeInstanceOf(g.GetWeb3CheckTask)}),it("should build the transaction context without clear sign contexts",async()=>{const e=[],o=[];s.getContexts.mockResolvedValueOnce(e),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:t.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:t.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:t.DeviceModelId.FLEX,isSecureConnectionAllowed:!1});const p=await new l.BuildTransactionContextTask(a,{...c,appConfig:u(!0)},i).run();expect(p).toEqual({clearSignContexts:e,clearSignContextsOptional:o,clearSigningType:d.ClearSigningType.BASIC})}),it("should build the transaction context with web3checks",async()=>{const e=[],o=[],p="web3Check";i.mockReturnValueOnce({run:async()=>Promise.resolve({web3Check:p})}),s.getContexts.mockResolvedValueOnce(e),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:t.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:t.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:t.DeviceModelId.FLEX,isSecureConnectionAllowed:!1});const E=await new l.BuildTransactionContextTask(a,{...c,appConfig:u(!0)},i).run();expect(E).toEqual({clearSignContexts:[p,...e],clearSignContextsOptional:o,clearSigningType:d.ClearSigningType.BASIC})}),it("should build the transaction context with web3checks and generic-parser clear sign contexts",async()=>{const e=[{type:n.ClearSignContextType.TRANSACTION_INFO,payload:"payload-1",certificate:r},{type:n.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-2"},{type:n.ClearSignContextType.ENUM,payload:"payload-3",id:1,value:2,certificate:r},{type:n.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-4"}],o="web3Check";i.mockReturnValueOnce({run:async()=>Promise.resolve({web3Check:o})}),s.getContexts.mockResolvedValueOnce(e),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:t.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:t.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.15.0"},deviceModelId:t.DeviceModelId.FLEX,isSecureConnectionAllowed:!1});const p=await new l.BuildTransactionContextTask(a,{...c,appConfig:u(!0)},i).run();expect(p).toEqual({clearSignContexts:[e[0],e[1],e[3],o],clearSignContextsOptional:[e[2]],clearSigningType:d.ClearSigningType.EIP7730})}),it("should build the transaction context with web3checks and generic-parser clear sign contexts in the correct order",async()=>{const e=[{type:n.ClearSignContextType.ENUM,payload:"payload-3",id:1,value:2,certificate:r},{type:n.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-4"},{type:n.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-2"},{type:n.ClearSignContextType.TRANSACTION_INFO,payload:"payload-1",certificate:r}],o="web3Check";i.mockReturnValueOnce({run:async()=>Promise.resolve({web3Check:o})}),s.getContexts.mockResolvedValueOnce(e),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:t.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:t.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.15.0"},deviceModelId:t.DeviceModelId.FLEX,isSecureConnectionAllowed:!1});const p=await new l.BuildTransactionContextTask(a,{...c,appConfig:u(!0)},i).run();expect(p).toEqual({clearSignContexts:[e[3],e[1],e[2],o],clearSignContextsOptional:[e[0]],clearSigningType:d.ClearSigningType.EIP7730})}),it("should build the transaction context with clear sign contexts",async()=>{const e=[{type:n.ClearSignContextType.TOKEN,payload:"payload-1"},{type:n.ClearSignContextType.NFT,payload:"payload-2"}],o="web3Check";i.mockReturnValueOnce({run:async()=>Promise.resolve({web3Check:o})}),s.getContexts.mockResolvedValueOnce(e),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:t.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:t.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:t.DeviceModelId.FLEX,isSecureConnectionAllowed:!1});const p=await new l.BuildTransactionContextTask(a,c,i).run();expect(p).toEqual({clearSignContexts:e,clearSignContextsOptional:[],clearSigningType:d.ClearSigningType.BASIC})}),it("should build the transaction context with generic-parser context",async()=>{const e=[{type:n.ClearSignContextType.TRANSACTION_INFO,payload:"payload-1",certificate:r},{type:n.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-2"},{type:n.ClearSignContextType.ENUM,payload:"payload-3",id:1,value:2,certificate:r},{type:n.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-4"}];s.getContexts.mockResolvedValueOnce(e),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:t.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:t.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.15.0"},deviceModelId:t.DeviceModelId.FLEX,isSecureConnectionAllowed:!1});const o=await new l.BuildTransactionContextTask(a,c,i).run();expect(o).toEqual({clearSignContexts:[e[0],e[1],e[3]],clearSignContextsOptional:[e[2]],clearSigningType:d.ClearSigningType.EIP7730})}),it("should call the web3checks factory with correct parameters",async()=>{const e=[];s.getContexts.mockResolvedValueOnce(e),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:t.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:t.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:t.DeviceModelId.FLEX,isSecureConnectionAllowed:!1}),await new l.BuildTransactionContextTask(a,{...c,appConfig:u(!0)},i).run(),expect(i).toHaveBeenCalledWith(a,{contextModule:s,derivationPath:"44'/60'/0'/0/0",subset:c.subset,transaction:C})}),it("should call the context module with the correct parameters",async()=>{const e=[];s.getContexts.mockResolvedValueOnce(e),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:t.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:t.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:t.DeviceModelId.FLEX,isSecureConnectionAllowed:!1}),await new l.BuildTransactionContextTask(a,c,i).run(),expect(s.getContexts).toHaveBeenCalledWith({deviceModelId:t.DeviceModelId.FLEX,challenge:"challenge",domain:"domain-name.eth",...c.subset})}),it("should call the context module without challenge for Nano S",async()=>{const e=[];s.getContexts.mockResolvedValueOnce(e),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:t.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:t.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:t.DeviceModelId.NANO_S,isSecureConnectionAllowed:!1}),await new l.BuildTransactionContextTask(a,c,i).run(),expect(s.getContexts).toHaveBeenCalledWith({deviceModelId:t.DeviceModelId.NANO_S,domain:"domain-name.eth",...c.subset})}),it("should call the context module without context on error",async()=>{const e=[];s.getContexts.mockResolvedValueOnce(e),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:t.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:t.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:t.DeviceModelId.FLEX,isSecureConnectionAllowed:!1}),a.sendCommand.mockResolvedValueOnce((0,t.CommandResultFactory)({error:new t.UnknownDeviceExchangeError})),await new l.BuildTransactionContextTask(a,c,i).run(),expect(s.getContexts).toHaveBeenCalledWith({deviceModelId:t.DeviceModelId.FLEX,challenge:void 0,domain:"domain-name.eth",...c.subset})}),it("should exclude error contexts from the result",async()=>{const e=[{type:n.ClearSignContextType.ERROR,error:new Error("error")},{type:n.ClearSignContextType.TOKEN,payload:"payload-1"},{type:n.ClearSignContextType.ERROR,error:new Error("error")},{type:n.ClearSignContextType.NFT,payload:"payload-2"}];s.getContexts.mockResolvedValueOnce(e),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:t.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:t.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:t.DeviceModelId.FLEX,isSecureConnectionAllowed:!1});const o=await new l.BuildTransactionContextTask(a,c,i).run();expect(o).toEqual({clearSignContexts:[e[1],e[3]],clearSignContextsOptional:[],clearSigningType:d.ClearSigningType.BASIC})}),it("should exclude generic-parser contexts from the result on old apps",async()=>{const e=[{type:n.ClearSignContextType.TRANSACTION_INFO,payload:"transaction_info",certificate:r},{type:n.ClearSignContextType.TOKEN,payload:"payload-1"},{type:n.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"transaction_field"},{type:n.ClearSignContextType.NFT,payload:"payload-2"},{type:n.ClearSignContextType.ENUM,payload:"enum",id:1,value:2,certificate:r}];s.getContexts.mockResolvedValueOnce(e),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:t.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:t.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:t.DeviceModelId.FLEX,isSecureConnectionAllowed:!1});const o=await new l.BuildTransactionContextTask(a,c,i).run();expect(o).toEqual({clearSignContexts:[e[1],e[3]],clearSignContextsOptional:[],clearSigningType:d.ClearSigningType.BASIC})}),it("should exclude generic-parser contexts from the result if no transaction_info was found",async()=>{const e=[{type:n.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"transaction_field"},{type:n.ClearSignContextType.TOKEN,payload:"payload-1"},{type:n.ClearSignContextType.ENUM,payload:"enum",id:1,value:2},{type:n.ClearSignContextType.NFT,payload:"payload-2"}];s.getContexts.mockResolvedValueOnce(e),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:t.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:t.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.14.0"},deviceModelId:t.DeviceModelId.FLEX,isSecureConnectionAllowed:!1});const o=await new l.BuildTransactionContextTask(a,c,i).run();expect(o).toEqual({clearSignContexts:[e[1],e[3]],clearSignContextsOptional:[],clearSigningType:d.ClearSigningType.BASIC})}),it("should exclude legacy contexts from the result for generic-parser transactions",async()=>{const e=[{type:n.ClearSignContextType.TOKEN,payload:"payload-1"},{type:n.ClearSignContextType.TRANSACTION_INFO,payload:"payload-2",certificate:r},{type:n.ClearSignContextType.EXTERNAL_PLUGIN,payload:"payload-3"},{type:n.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-4"},{type:n.ClearSignContextType.ENUM,payload:"payload-5",id:1,value:2,certificate:r}];s.getContexts.mockResolvedValueOnce(e),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:t.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:t.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.15.0"},deviceModelId:t.DeviceModelId.FLEX,isSecureConnectionAllowed:!1});const o=await new l.BuildTransactionContextTask(a,c,i).run();expect(o).toEqual({clearSignContexts:[e[1],e[3]],clearSignContextsOptional:[e[4]],clearSigningType:d.ClearSigningType.EIP7730})}),it("should exclude generic-parser contexts with a nano s device",async()=>{const e=[{type:n.ClearSignContextType.TOKEN,payload:"payload-1"},{type:n.ClearSignContextType.TRANSACTION_INFO,payload:"payload-2",certificate:r},{type:n.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-3"},{type:n.ClearSignContextType.ENUM,payload:"payload-4",id:1,value:2,certificate:r}];s.getContexts.mockResolvedValueOnce(e),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:t.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:t.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.14.0"},deviceModelId:t.DeviceModelId.NANO_S,isSecureConnectionAllowed:!1});const o=await new l.BuildTransactionContextTask(a,c,i).run();expect(o).toEqual({clearSignContexts:[e[0]],clearSignContextsOptional:[],clearSigningType:d.ClearSigningType.BASIC})}),it("should exclude generic-parser contexts with an old app version",async()=>{const e=[{type:n.ClearSignContextType.TOKEN,payload:"payload-1"},{type:n.ClearSignContextType.TRANSACTION_INFO,payload:"payload-2",certificate:r},{type:n.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-3"},{type:n.ClearSignContextType.ENUM,payload:"payload-4",id:1,value:2,certificate:r}];s.getContexts.mockResolvedValueOnce(e),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:t.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:t.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:t.DeviceModelId.FLEX,isSecureConnectionAllowed:!1});const o=await new l.BuildTransactionContextTask(a,c,i).run();expect(o).toEqual({clearSignContexts:[e[0]],clearSignContextsOptional:[],clearSigningType:d.ClearSigningType.BASIC})}),it("should exclude generic-parser contexts with a non ready device",async()=>{const e=[{type:n.ClearSignContextType.TOKEN,payload:"payload-1"},{type:n.ClearSignContextType.TRANSACTION_INFO,payload:"payload-2",certificate:r},{type:n.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-3"},{type:n.ClearSignContextType.ENUM,payload:"payload-4",id:1,value:2,certificate:r}];s.getContexts.mockResolvedValueOnce(e),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:t.DeviceSessionStateType.Connected,deviceStatus:t.DeviceStatus.NOT_CONNECTED,deviceModelId:t.DeviceModelId.FLEX});const o=await new l.BuildTransactionContextTask(a,c,i).run();expect(o).toEqual({clearSignContexts:[e[0]],clearSignContextsOptional:[],clearSigningType:d.ClearSigningType.BASIC})}),it("should return no clear sign context if the transaction info certificate is missing",async()=>{const e=[{type:n.ClearSignContextType.TRANSACTION_INFO,payload:"payload-1"},{type:n.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-2"},{type:n.ClearSignContextType.ENUM,payload:"payload-3",id:1,value:2}];s.getContexts.mockResolvedValueOnce(e),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:t.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:t.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.17.0"},deviceModelId:t.DeviceModelId.FLEX,isSecureConnectionAllowed:!1});const o=await new l.BuildTransactionContextTask(a,c,i).run();expect(o).toEqual({clearSignContexts:[],clearSignContextsOptional:[],clearSigningType:d.ClearSigningType.BASIC})})});
|
|
1
|
+
"use strict";var n=require("@ledgerhq/context-module"),t=require("@ledgerhq/device-management-kit"),S=require("ethers"),d=require("../../../api/model/ClearSigningType"),y=require("../../app-binder/device-action/__test-utils__/makeInternalApi"),s=require("./BuildTransactionContextTask"),g=require("./GetWeb3CheckTask");describe("BuildTransactionContextTask",()=>{const l={getContext:vi.fn(),getContexts:vi.fn(),getTypedDataFilters:vi.fn(),getWeb3Checks:vi.fn(),getSolanaContext:vi.fn()},x={domain:"domain-name.eth"},C=(0,t.hexaStringToBuffer)(S.Transaction.from({chainId:1n,nonce:0,data:"0x"}).unsignedSerialized),r={keyUsageNumber:1,payload:new Uint8Array([1,2,3])};let c;const a=(0,y.makeDeviceActionInternalApiMock)(),i=vi.fn();function u(e){return{blindSigningEnabled:!1,web3ChecksEnabled:e,web3ChecksOptIn:!1,version:"1.13.0"}}beforeEach(()=>{vi.resetAllMocks(),a.sendCommand.mockResolvedValue((0,t.CommandResultFactory)({data:{challenge:"challenge"}})),i.mockReturnValue({run:async()=>Promise.resolve({web3Check:null})}),c={contextModule:l,subset:{chainId:1,to:void 0,data:"0x",selector:"0x"},transaction:C,options:x,appConfig:u(!1),derivationPath:"44'/60'/0'/0/0"}}),it("should init with a default GetWeb3CheckTaskFactory",()=>{const e=new s.BuildTransactionContextTask(a,c);expect(e.getWeb3ChecksFactory).toBeDefined(),expect(e.getWeb3ChecksFactory(a,{contextModule:c.contextModule,derivationPath:c.derivationPath,subset:c.subset,transaction:c.transaction})).toBeInstanceOf(g.GetWeb3CheckTask)}),it("should build the transaction context without clear sign contexts",async()=>{const e=[],o=[];l.getContexts.mockResolvedValueOnce(e),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:t.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:t.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:t.DeviceModelId.FLEX,isSecureConnectionAllowed:!1});const p=await new s.BuildTransactionContextTask(a,{...c,appConfig:u(!0)},i).run();expect(p).toEqual({clearSignContexts:e,clearSignContextsOptional:o,clearSigningType:d.ClearSigningType.BASIC})}),it("should build the transaction context with web3checks",async()=>{const e=[],o=[],p="web3Check";i.mockReturnValueOnce({run:async()=>Promise.resolve({web3Check:p})}),l.getContexts.mockResolvedValueOnce(e),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:t.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:t.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:t.DeviceModelId.FLEX,isSecureConnectionAllowed:!1});const E=await new s.BuildTransactionContextTask(a,{...c,appConfig:u(!0)},i).run();expect(E).toEqual({clearSignContexts:[p,...e],clearSignContextsOptional:o,clearSigningType:d.ClearSigningType.BASIC})}),it("should build the transaction context with web3checks and generic-parser clear sign contexts",async()=>{const e=[{type:n.ClearSignContextType.TRANSACTION_INFO,payload:"payload-1",certificate:r},{type:n.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-2"},{type:n.ClearSignContextType.ENUM,payload:"payload-3",id:1,value:2,certificate:r},{type:n.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-4"}],o="web3Check";i.mockReturnValueOnce({run:async()=>Promise.resolve({web3Check:o})}),l.getContexts.mockResolvedValueOnce(e),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:t.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:t.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.15.0"},deviceModelId:t.DeviceModelId.FLEX,isSecureConnectionAllowed:!1});const p=await new s.BuildTransactionContextTask(a,{...c,appConfig:u(!0)},i).run();expect(p).toEqual({clearSignContexts:[e[0],e[1],e[3],o],clearSignContextsOptional:[e[2]],clearSigningType:d.ClearSigningType.EIP7730})}),it("should build the transaction context with web3checks and generic-parser clear sign contexts in the correct order",async()=>{const e=[{type:n.ClearSignContextType.ENUM,payload:"payload-3",id:1,value:2,certificate:r},{type:n.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-4"},{type:n.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-2"},{type:n.ClearSignContextType.TRANSACTION_INFO,payload:"payload-1",certificate:r}],o="web3Check";i.mockReturnValueOnce({run:async()=>Promise.resolve({web3Check:o})}),l.getContexts.mockResolvedValueOnce(e),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:t.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:t.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.15.0"},deviceModelId:t.DeviceModelId.FLEX,isSecureConnectionAllowed:!1});const p=await new s.BuildTransactionContextTask(a,{...c,appConfig:u(!0)},i).run();expect(p).toEqual({clearSignContexts:[e[3],e[1],e[2],o],clearSignContextsOptional:[e[0]],clearSigningType:d.ClearSigningType.EIP7730})}),it("should build the transaction context with clear sign contexts",async()=>{const e=[{type:n.ClearSignContextType.TOKEN,payload:"payload-1"},{type:n.ClearSignContextType.NFT,payload:"payload-2"}],o="web3Check";i.mockReturnValueOnce({run:async()=>Promise.resolve({web3Check:o})}),l.getContexts.mockResolvedValueOnce(e),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:t.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:t.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:t.DeviceModelId.FLEX,isSecureConnectionAllowed:!1});const p=await new s.BuildTransactionContextTask(a,c,i).run();expect(p).toEqual({clearSignContexts:e,clearSignContextsOptional:[],clearSigningType:d.ClearSigningType.BASIC})}),it("should build the transaction context with generic-parser context",async()=>{const e=[{type:n.ClearSignContextType.TRANSACTION_INFO,payload:"payload-1",certificate:r},{type:n.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-2"},{type:n.ClearSignContextType.ENUM,payload:"payload-3",id:1,value:2,certificate:r},{type:n.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-4"}];l.getContexts.mockResolvedValueOnce(e),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:t.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:t.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.15.0"},deviceModelId:t.DeviceModelId.FLEX,isSecureConnectionAllowed:!1});const o=await new s.BuildTransactionContextTask(a,c,i).run();expect(o).toEqual({clearSignContexts:[e[0],e[1],e[3]],clearSignContextsOptional:[e[2]],clearSigningType:d.ClearSigningType.EIP7730})}),it("should build the transaction context with proxy delegate call context",async()=>{const e=[{type:n.ClearSignContextType.TRANSACTION_INFO,payload:"payload-1",certificate:r},{type:n.ClearSignContextType.PROXY_DELEGATE_CALL,payload:"payload-2"}],o=[];l.getContexts.mockResolvedValueOnce(e),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:t.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:t.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.15.0"},deviceModelId:t.DeviceModelId.FLEX,isSecureConnectionAllowed:!1});const p=await new s.BuildTransactionContextTask(a,c,i).run();expect(p).toEqual({clearSignContexts:[e[1],e[0]],clearSignContextsOptional:o,clearSigningType:d.ClearSigningType.EIP7730})}),it("should call the web3checks factory with correct parameters",async()=>{const e=[];l.getContexts.mockResolvedValueOnce(e),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:t.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:t.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:t.DeviceModelId.FLEX,isSecureConnectionAllowed:!1}),await new s.BuildTransactionContextTask(a,{...c,appConfig:u(!0)},i).run(),expect(i).toHaveBeenCalledWith(a,{contextModule:l,derivationPath:"44'/60'/0'/0/0",subset:c.subset,transaction:C})}),it("should call the context module with the correct parameters",async()=>{const e=[];l.getContexts.mockResolvedValueOnce(e),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:t.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:t.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:t.DeviceModelId.FLEX,isSecureConnectionAllowed:!1}),await new s.BuildTransactionContextTask(a,c,i).run(),expect(l.getContexts).toHaveBeenCalledWith({deviceModelId:t.DeviceModelId.FLEX,challenge:"challenge",domain:"domain-name.eth",...c.subset})}),it("should call the context module without challenge for Nano S",async()=>{const e=[];l.getContexts.mockResolvedValueOnce(e),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:t.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:t.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:t.DeviceModelId.NANO_S,isSecureConnectionAllowed:!1}),await new s.BuildTransactionContextTask(a,c,i).run(),expect(l.getContexts).toHaveBeenCalledWith({deviceModelId:t.DeviceModelId.NANO_S,domain:"domain-name.eth",...c.subset})}),it("should call the context module without context on error",async()=>{const e=[];l.getContexts.mockResolvedValueOnce(e),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:t.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:t.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:t.DeviceModelId.FLEX,isSecureConnectionAllowed:!1}),a.sendCommand.mockResolvedValueOnce((0,t.CommandResultFactory)({error:new t.UnknownDeviceExchangeError})),await new s.BuildTransactionContextTask(a,c,i).run(),expect(l.getContexts).toHaveBeenCalledWith({deviceModelId:t.DeviceModelId.FLEX,challenge:void 0,domain:"domain-name.eth",...c.subset})}),it("should exclude error contexts from the result",async()=>{const e=[{type:n.ClearSignContextType.ERROR,error:new Error("error")},{type:n.ClearSignContextType.TOKEN,payload:"payload-1"},{type:n.ClearSignContextType.ERROR,error:new Error("error")},{type:n.ClearSignContextType.NFT,payload:"payload-2"}];l.getContexts.mockResolvedValueOnce(e),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:t.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:t.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:t.DeviceModelId.FLEX,isSecureConnectionAllowed:!1});const o=await new s.BuildTransactionContextTask(a,c,i).run();expect(o).toEqual({clearSignContexts:[e[1],e[3]],clearSignContextsOptional:[],clearSigningType:d.ClearSigningType.BASIC})}),it("should exclude generic-parser contexts from the result on old apps",async()=>{const e=[{type:n.ClearSignContextType.TRANSACTION_INFO,payload:"transaction_info",certificate:r},{type:n.ClearSignContextType.TOKEN,payload:"payload-1"},{type:n.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"transaction_field"},{type:n.ClearSignContextType.NFT,payload:"payload-2"},{type:n.ClearSignContextType.ENUM,payload:"enum",id:1,value:2,certificate:r}];l.getContexts.mockResolvedValueOnce(e),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:t.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:t.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:t.DeviceModelId.FLEX,isSecureConnectionAllowed:!1});const o=await new s.BuildTransactionContextTask(a,c,i).run();expect(o).toEqual({clearSignContexts:[e[1],e[3]],clearSignContextsOptional:[],clearSigningType:d.ClearSigningType.BASIC})}),it("should exclude generic-parser contexts from the result if no transaction_info was found",async()=>{const e=[{type:n.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"transaction_field"},{type:n.ClearSignContextType.TOKEN,payload:"payload-1"},{type:n.ClearSignContextType.ENUM,payload:"enum",id:1,value:2},{type:n.ClearSignContextType.NFT,payload:"payload-2"}];l.getContexts.mockResolvedValueOnce(e),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:t.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:t.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.14.0"},deviceModelId:t.DeviceModelId.FLEX,isSecureConnectionAllowed:!1});const o=await new s.BuildTransactionContextTask(a,c,i).run();expect(o).toEqual({clearSignContexts:[e[1],e[3]],clearSignContextsOptional:[],clearSigningType:d.ClearSigningType.BASIC})}),it("should exclude legacy contexts from the result for generic-parser transactions",async()=>{const e=[{type:n.ClearSignContextType.TOKEN,payload:"payload-1"},{type:n.ClearSignContextType.TRANSACTION_INFO,payload:"payload-2",certificate:r},{type:n.ClearSignContextType.EXTERNAL_PLUGIN,payload:"payload-3"},{type:n.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-4"},{type:n.ClearSignContextType.ENUM,payload:"payload-5",id:1,value:2,certificate:r}];l.getContexts.mockResolvedValueOnce(e),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:t.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:t.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.15.0"},deviceModelId:t.DeviceModelId.FLEX,isSecureConnectionAllowed:!1});const o=await new s.BuildTransactionContextTask(a,c,i).run();expect(o).toEqual({clearSignContexts:[e[1],e[3]],clearSignContextsOptional:[e[4]],clearSigningType:d.ClearSigningType.EIP7730})}),it("should exclude generic-parser contexts with a nano s device",async()=>{const e=[{type:n.ClearSignContextType.TOKEN,payload:"payload-1"},{type:n.ClearSignContextType.TRANSACTION_INFO,payload:"payload-2",certificate:r},{type:n.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-3"},{type:n.ClearSignContextType.ENUM,payload:"payload-4",id:1,value:2,certificate:r}];l.getContexts.mockResolvedValueOnce(e),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:t.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:t.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.14.0"},deviceModelId:t.DeviceModelId.NANO_S,isSecureConnectionAllowed:!1});const o=await new s.BuildTransactionContextTask(a,c,i).run();expect(o).toEqual({clearSignContexts:[e[0]],clearSignContextsOptional:[],clearSigningType:d.ClearSigningType.BASIC})}),it("should exclude generic-parser contexts with an old app version",async()=>{const e=[{type:n.ClearSignContextType.TOKEN,payload:"payload-1"},{type:n.ClearSignContextType.TRANSACTION_INFO,payload:"payload-2",certificate:r},{type:n.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-3"},{type:n.ClearSignContextType.ENUM,payload:"payload-4",id:1,value:2,certificate:r}];l.getContexts.mockResolvedValueOnce(e),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:t.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:t.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:t.DeviceModelId.FLEX,isSecureConnectionAllowed:!1});const o=await new s.BuildTransactionContextTask(a,c,i).run();expect(o).toEqual({clearSignContexts:[e[0]],clearSignContextsOptional:[],clearSigningType:d.ClearSigningType.BASIC})}),it("should exclude generic-parser contexts with a non ready device",async()=>{const e=[{type:n.ClearSignContextType.TOKEN,payload:"payload-1"},{type:n.ClearSignContextType.TRANSACTION_INFO,payload:"payload-2",certificate:r},{type:n.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-3"},{type:n.ClearSignContextType.ENUM,payload:"payload-4",id:1,value:2,certificate:r}];l.getContexts.mockResolvedValueOnce(e),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:t.DeviceSessionStateType.Connected,deviceStatus:t.DeviceStatus.NOT_CONNECTED,deviceModelId:t.DeviceModelId.FLEX});const o=await new s.BuildTransactionContextTask(a,c,i).run();expect(o).toEqual({clearSignContexts:[e[0]],clearSignContextsOptional:[],clearSigningType:d.ClearSigningType.BASIC})}),it("should return no clear sign context if the transaction info certificate is missing",async()=>{const e=[{type:n.ClearSignContextType.TRANSACTION_INFO,payload:"payload-1"},{type:n.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-2"},{type:n.ClearSignContextType.ENUM,payload:"payload-3",id:1,value:2}];l.getContexts.mockResolvedValueOnce(e),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:t.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:t.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.17.0"},deviceModelId:t.DeviceModelId.FLEX,isSecureConnectionAllowed:!1});const o=await new s.BuildTransactionContextTask(a,c,i).run();expect(o).toEqual({clearSignContexts:[],clearSignContextsOptional:[],clearSigningType:d.ClearSigningType.BASIC})})});
|
|
2
2
|
//# sourceMappingURL=BuildTransactionContextTask.test.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/internal/app-binder/task/BuildTransactionContextTask.test.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n type ClearSignContext,\n type ClearSignContextSuccess,\n ClearSignContextType,\n type PkiCertificate,\n} from \"@ledgerhq/context-module\";\nimport {\n CommandResultFactory,\n DeviceModelId,\n DeviceSessionStateType,\n DeviceStatus,\n hexaStringToBuffer,\n UnknownDeviceExchangeError,\n} from \"@ledgerhq/device-management-kit\";\nimport { Transaction } from \"ethers\";\n\nimport type { GetConfigCommandResponse } from \"@api/app-binder/GetConfigCommandTypes\";\nimport { ClearSigningType } from \"@api/model/ClearSigningType\";\nimport { makeDeviceActionInternalApiMock } from \"@internal/app-binder/device-action/__test-utils__/makeInternalApi\";\n\nimport {\n BuildTransactionContextTask,\n type BuildTransactionContextTaskArgs,\n} from \"./BuildTransactionContextTask\";\nimport { GetWeb3CheckTask } from \"./GetWeb3CheckTask\";\n\ndescribe(\"BuildTransactionContextTask\", () => {\n const contextModuleMock = {\n getContext: vi.fn(),\n getContexts: vi.fn(),\n getTypedDataFilters: vi.fn(),\n getWeb3Checks: vi.fn(),\n getSolanaContext: vi.fn(),\n };\n const defaultOptions = {\n domain: \"domain-name.eth\",\n };\n const defaultTransaction: Uint8Array = hexaStringToBuffer(\n Transaction.from({\n chainId: 1n,\n nonce: 0,\n data: \"0x\",\n }).unsignedSerialized,\n )!;\n const defaultCertificate: PkiCertificate = {\n keyUsageNumber: 1,\n payload: new Uint8Array([0x01, 0x02, 0x03]),\n };\n\n let defaultArgs: BuildTransactionContextTaskArgs;\n const apiMock = makeDeviceActionInternalApiMock();\n const getWeb3ChecksFactoryMock = vi.fn();\n\n function createAppConfig(\n web3ChecksEnabled: boolean,\n ): GetConfigCommandResponse {\n return {\n blindSigningEnabled: false,\n web3ChecksEnabled,\n web3ChecksOptIn: false,\n version: \"1.13.0\",\n };\n }\n\n beforeEach(() => {\n vi.resetAllMocks();\n apiMock.sendCommand.mockResolvedValue(\n CommandResultFactory({ data: { challenge: \"challenge\" } }),\n );\n getWeb3ChecksFactoryMock.mockReturnValue({\n run: async () => Promise.resolve({ web3Check: null }),\n });\n\n defaultArgs = {\n contextModule: contextModuleMock,\n subset: { chainId: 1, to: undefined, data: \"0x\", selector: \"0x\" },\n transaction: defaultTransaction,\n options: defaultOptions,\n appConfig: createAppConfig(false),\n derivationPath: \"44'/60'/0'/0/0\",\n };\n });\n\n it(\"should init with a default GetWeb3CheckTaskFactory\", () => {\n // GIVEN\n const task = new BuildTransactionContextTask(apiMock, defaultArgs);\n\n // THEN\n expect(task[\"getWeb3ChecksFactory\"]).toBeDefined();\n expect(\n task[\"getWeb3ChecksFactory\"](apiMock, {\n contextModule: defaultArgs.contextModule,\n derivationPath: defaultArgs.derivationPath,\n subset: defaultArgs.subset,\n transaction: defaultArgs.transaction,\n }),\n ).toBeInstanceOf(GetWeb3CheckTask);\n });\n\n it(\"should build the transaction context without clear sign contexts\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [];\n const clearSignContextsOptional: ClearSignContext[] = [];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\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\n // WHEN\n const result = await new BuildTransactionContextTask(\n apiMock,\n { ...defaultArgs, appConfig: createAppConfig(true) },\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts,\n clearSignContextsOptional,\n clearSigningType: ClearSigningType.BASIC,\n });\n });\n\n it(\"should build the transaction context with web3checks\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [];\n const clearSignContextsOptional: ClearSignContext[] = [];\n const expectedWeb3Check =\n \"web3Check\" as unknown as ClearSignContextSuccess<ClearSignContextType.WEB3_CHECK>;\n getWeb3ChecksFactoryMock.mockReturnValueOnce({\n run: async () => Promise.resolve({ web3Check: expectedWeb3Check }),\n });\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\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\n // WHEN\n const result = await new BuildTransactionContextTask(\n apiMock,\n { ...defaultArgs, appConfig: createAppConfig(true) },\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [expectedWeb3Check, ...clearSignContexts],\n clearSignContextsOptional,\n clearSigningType: ClearSigningType.BASIC,\n });\n });\n\n it(\"should build the transaction context with web3checks and generic-parser clear sign contexts\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-1\",\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-2\",\n },\n {\n type: ClearSignContextType.ENUM,\n payload: \"payload-3\",\n id: 1,\n value: 2,\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-4\",\n },\n ];\n const expectedWeb3Check =\n \"web3Check\" as unknown as ClearSignContextSuccess<ClearSignContextType.WEB3_CHECK>;\n getWeb3ChecksFactoryMock.mockReturnValueOnce({\n run: async () => Promise.resolve({ web3Check: expectedWeb3Check }),\n });\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.15.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildTransactionContextTask(\n apiMock,\n { ...defaultArgs, appConfig: createAppConfig(true) },\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [\n clearSignContexts[0],\n clearSignContexts[1],\n clearSignContexts[3],\n expectedWeb3Check,\n ],\n clearSignContextsOptional: [clearSignContexts[2]],\n clearSigningType: ClearSigningType.EIP7730,\n });\n });\n\n it(\"should build the transaction context with web3checks and generic-parser clear sign contexts in the correct order\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.ENUM,\n payload: \"payload-3\",\n id: 1,\n value: 2,\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-4\",\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-2\",\n },\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-1\",\n certificate: defaultCertificate,\n },\n ];\n const expectedWeb3Check =\n \"web3Check\" as unknown as ClearSignContextSuccess<ClearSignContextType.WEB3_CHECK>;\n getWeb3ChecksFactoryMock.mockReturnValueOnce({\n run: async () => Promise.resolve({ web3Check: expectedWeb3Check }),\n });\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.15.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildTransactionContextTask(\n apiMock,\n { ...defaultArgs, appConfig: createAppConfig(true) },\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [\n clearSignContexts[3], // transaction info\n clearSignContexts[1], // transaction field description\n clearSignContexts[2], // transaction field description\n expectedWeb3Check, // web3 check\n ],\n clearSignContextsOptional: [clearSignContexts[0]], // enum\n clearSigningType: ClearSigningType.EIP7730,\n });\n });\n\n it(\"should build the transaction context with clear sign contexts\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-1\",\n },\n {\n type: ClearSignContextType.NFT,\n payload: \"payload-2\",\n },\n ];\n const expectedWeb3Check =\n \"web3Check\" as unknown as ClearSignContextSuccess<ClearSignContextType.WEB3_CHECK>;\n getWeb3ChecksFactoryMock.mockReturnValueOnce({\n run: async () => Promise.resolve({ web3Check: expectedWeb3Check }),\n });\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\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\n // WHEN\n const result = await new BuildTransactionContextTask(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts,\n clearSignContextsOptional: [],\n clearSigningType: ClearSigningType.BASIC,\n });\n });\n\n it(\"should build the transaction context with generic-parser context\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-1\",\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-2\",\n },\n {\n type: ClearSignContextType.ENUM,\n payload: \"payload-3\",\n id: 1,\n value: 2,\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-4\",\n },\n ];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.15.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildTransactionContextTask(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [\n clearSignContexts[0],\n clearSignContexts[1],\n clearSignContexts[3],\n ],\n clearSignContextsOptional: [clearSignContexts[2]],\n clearSigningType: ClearSigningType.EIP7730,\n });\n });\n\n it(\"should call the web3checks factory with correct parameters\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\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\n // WHEN\n await new BuildTransactionContextTask(\n apiMock,\n { ...defaultArgs, appConfig: createAppConfig(true) },\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(getWeb3ChecksFactoryMock).toHaveBeenCalledWith(apiMock, {\n contextModule: contextModuleMock,\n derivationPath: \"44'/60'/0'/0/0\",\n subset: defaultArgs.subset,\n transaction: defaultTransaction,\n });\n });\n\n it(\"should call the context module with the correct parameters\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\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\n // WHEN\n await new BuildTransactionContextTask(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(contextModuleMock.getContexts).toHaveBeenCalledWith({\n deviceModelId: DeviceModelId.FLEX,\n challenge: \"challenge\",\n domain: \"domain-name.eth\",\n ...defaultArgs.subset,\n });\n });\n\n it(\"should call the context module without challenge for Nano S\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.12.0\" },\n deviceModelId: DeviceModelId.NANO_S,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n await new BuildTransactionContextTask(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(contextModuleMock.getContexts).toHaveBeenCalledWith({\n deviceModelId: DeviceModelId.NANO_S,\n domain: \"domain-name.eth\",\n ...defaultArgs.subset,\n });\n });\n\n it(\"should call the context module without context on error\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\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 apiMock.sendCommand.mockResolvedValueOnce(\n CommandResultFactory({ error: new UnknownDeviceExchangeError() }),\n );\n\n // WHEN\n await new BuildTransactionContextTask(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(contextModuleMock.getContexts).toHaveBeenCalledWith({\n deviceModelId: DeviceModelId.FLEX,\n challenge: undefined,\n domain: \"domain-name.eth\",\n ...defaultArgs.subset,\n });\n });\n\n it(\"should exclude error contexts from the result\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"error\"),\n },\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-1\",\n },\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"error\"),\n },\n {\n type: ClearSignContextType.NFT,\n payload: \"payload-2\",\n },\n ];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\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\n // WHEN\n const result = await new BuildTransactionContextTask(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [clearSignContexts[1], clearSignContexts[3]],\n clearSignContextsOptional: [],\n clearSigningType: ClearSigningType.BASIC,\n });\n });\n\n it(\"should exclude generic-parser contexts from the result on old apps\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"transaction_info\",\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-1\",\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"transaction_field\",\n },\n {\n type: ClearSignContextType.NFT,\n payload: \"payload-2\",\n },\n {\n type: ClearSignContextType.ENUM,\n payload: \"enum\",\n id: 1,\n value: 2,\n certificate: defaultCertificate,\n },\n ];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\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\n // WHEN\n const result = await new BuildTransactionContextTask(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [clearSignContexts[1], clearSignContexts[3]],\n clearSignContextsOptional: [],\n clearSigningType: ClearSigningType.BASIC,\n });\n });\n\n it(\"should exclude generic-parser contexts from the result if no transaction_info was found\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"transaction_field\",\n },\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-1\",\n },\n {\n type: ClearSignContextType.ENUM,\n payload: \"enum\",\n id: 1,\n value: 2,\n },\n {\n type: ClearSignContextType.NFT,\n payload: \"payload-2\",\n },\n ];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.14.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildTransactionContextTask(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [clearSignContexts[1], clearSignContexts[3]],\n clearSignContextsOptional: [],\n clearSigningType: ClearSigningType.BASIC,\n });\n });\n\n it(\"should exclude legacy contexts from the result for generic-parser transactions\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-1\",\n },\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-2\",\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.EXTERNAL_PLUGIN,\n payload: \"payload-3\",\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-4\",\n },\n {\n type: ClearSignContextType.ENUM,\n payload: \"payload-5\",\n id: 1,\n value: 2,\n certificate: defaultCertificate,\n },\n ];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.15.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildTransactionContextTask(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [clearSignContexts[1], clearSignContexts[3]],\n clearSignContextsOptional: [clearSignContexts[4]],\n clearSigningType: ClearSigningType.EIP7730,\n });\n });\n\n it(\"should exclude generic-parser contexts with a nano s device\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-1\",\n },\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-2\",\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-3\",\n },\n {\n type: ClearSignContextType.ENUM,\n payload: \"payload-4\",\n id: 1,\n value: 2,\n certificate: defaultCertificate,\n },\n ];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.14.0\" },\n deviceModelId: DeviceModelId.NANO_S,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildTransactionContextTask(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [clearSignContexts[0]],\n clearSignContextsOptional: [],\n clearSigningType: ClearSigningType.BASIC,\n });\n });\n\n it(\"should exclude generic-parser contexts with an old app version\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-1\",\n },\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-2\",\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-3\",\n },\n {\n type: ClearSignContextType.ENUM,\n payload: \"payload-4\",\n id: 1,\n value: 2,\n certificate: defaultCertificate,\n },\n ];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\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\n // WHEN\n const result = await new BuildTransactionContextTask(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [clearSignContexts[0]],\n clearSignContextsOptional: [],\n clearSigningType: ClearSigningType.BASIC,\n });\n });\n\n it(\"should exclude generic-parser contexts with a non ready device\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-1\",\n },\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-2\",\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-3\",\n },\n {\n type: ClearSignContextType.ENUM,\n payload: \"payload-4\",\n id: 1,\n value: 2,\n certificate: defaultCertificate,\n },\n ];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.Connected,\n deviceStatus: DeviceStatus.NOT_CONNECTED,\n deviceModelId: DeviceModelId.FLEX,\n });\n\n // WHEN\n const result = await new BuildTransactionContextTask(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [clearSignContexts[0]],\n clearSignContextsOptional: [],\n clearSigningType: ClearSigningType.BASIC,\n });\n });\n\n it(\"should return no clear sign context if the transaction info certificate is missing\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-1\",\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-2\",\n },\n {\n type: ClearSignContextType.ENUM,\n payload: \"payload-3\",\n id: 1,\n value: 2,\n },\n ];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.17.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildTransactionContextTask(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [],\n clearSignContextsOptional: [],\n clearSigningType: ClearSigningType.BASIC,\n });\n });\n});\n"],
|
|
5
|
-
"mappings": "aAAA,IAAAA,EAKO,oCACPC,EAOO,2CACPC,EAA4B,kBAG5BC,EAAiC,uCACjCC,EAAgD,6EAEhDC,EAGO,yCACPC,EAAiC,8BAEjC,SAAS,8BAA+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M,IAAI,8BACvBP,EACAD,EACAE,CACF,EAAE,IAAI,EAGN,OAAOM,CAAM,EAAE,QAAQ,CACrB,kBAAmB,CAACF,EAAkB,CAAC,CAAC,EACxC,0BAA2B,CAAC,EAC5B,iBAAkB,mBAAiB,KACrC,CAAC,CACH,CAAC,EAED,GAAG,qFAAsF,SAAY,CAEnG,MAAMA,EAAwC,CAC5C,CACE,KAAM,uBAAqB,iBAC3B,QAAS,WACX,EACA,CACE,KAAM,uBAAqB,8BAC3B,QAAS,WACX,EACA,CACE,KAAM,uBAAqB,KAC3B,QAAS,YACT,GAAI,EACJ,MAAO,CACT,CACF,EACAV,EAAkB,YAAY,sBAAsBU,CAAiB,EACrEL,EAAQ,sBAAsB,oBAAoB,CAChD,iBAAkB,yBAAuB,0BACzC,aAAc,eAAa,UAC3B,cAAe,CAAC,EAChB,WAAY,CAAE,KAAM,WAAY,QAAS,QAAS,EAClD,cAAe,gBAAc,KAC7B,0BAA2B,EAC7B,CAAC,EAGD,MAAMO,EAAS,MAAM,IAAI,8BACvBP,EACAD,EACAE,CACF,EAAE,IAAI,EAGN,OAAOM,CAAM,EAAE,QAAQ,CACrB,kBAAmB,CAAC,EACpB,0BAA2B,CAAC,EAC5B,iBAAkB,mBAAiB,KACrC,CAAC,CACH,CAAC,CACH,CAAC",
|
|
4
|
+
"sourcesContent": ["import {\n type ClearSignContext,\n type ClearSignContextSuccess,\n ClearSignContextType,\n type PkiCertificate,\n} from \"@ledgerhq/context-module\";\nimport {\n CommandResultFactory,\n DeviceModelId,\n DeviceSessionStateType,\n DeviceStatus,\n hexaStringToBuffer,\n UnknownDeviceExchangeError,\n} from \"@ledgerhq/device-management-kit\";\nimport { Transaction } from \"ethers\";\n\nimport type { GetConfigCommandResponse } from \"@api/app-binder/GetConfigCommandTypes\";\nimport { ClearSigningType } from \"@api/model/ClearSigningType\";\nimport { makeDeviceActionInternalApiMock } from \"@internal/app-binder/device-action/__test-utils__/makeInternalApi\";\n\nimport {\n BuildTransactionContextTask,\n type BuildTransactionContextTaskArgs,\n} from \"./BuildTransactionContextTask\";\nimport { GetWeb3CheckTask } from \"./GetWeb3CheckTask\";\n\ndescribe(\"BuildTransactionContextTask\", () => {\n const contextModuleMock = {\n getContext: vi.fn(),\n getContexts: vi.fn(),\n getTypedDataFilters: vi.fn(),\n getWeb3Checks: vi.fn(),\n getSolanaContext: vi.fn(),\n };\n const defaultOptions = {\n domain: \"domain-name.eth\",\n };\n const defaultTransaction: Uint8Array = hexaStringToBuffer(\n Transaction.from({\n chainId: 1n,\n nonce: 0,\n data: \"0x\",\n }).unsignedSerialized,\n )!;\n const defaultCertificate: PkiCertificate = {\n keyUsageNumber: 1,\n payload: new Uint8Array([0x01, 0x02, 0x03]),\n };\n\n let defaultArgs: BuildTransactionContextTaskArgs;\n const apiMock = makeDeviceActionInternalApiMock();\n const getWeb3ChecksFactoryMock = vi.fn();\n\n function createAppConfig(\n web3ChecksEnabled: boolean,\n ): GetConfigCommandResponse {\n return {\n blindSigningEnabled: false,\n web3ChecksEnabled,\n web3ChecksOptIn: false,\n version: \"1.13.0\",\n };\n }\n\n beforeEach(() => {\n vi.resetAllMocks();\n apiMock.sendCommand.mockResolvedValue(\n CommandResultFactory({ data: { challenge: \"challenge\" } }),\n );\n getWeb3ChecksFactoryMock.mockReturnValue({\n run: async () => Promise.resolve({ web3Check: null }),\n });\n\n defaultArgs = {\n contextModule: contextModuleMock,\n subset: { chainId: 1, to: undefined, data: \"0x\", selector: \"0x\" },\n transaction: defaultTransaction,\n options: defaultOptions,\n appConfig: createAppConfig(false),\n derivationPath: \"44'/60'/0'/0/0\",\n };\n });\n\n it(\"should init with a default GetWeb3CheckTaskFactory\", () => {\n // GIVEN\n const task = new BuildTransactionContextTask(apiMock, defaultArgs);\n\n // THEN\n expect(task[\"getWeb3ChecksFactory\"]).toBeDefined();\n expect(\n task[\"getWeb3ChecksFactory\"](apiMock, {\n contextModule: defaultArgs.contextModule,\n derivationPath: defaultArgs.derivationPath,\n subset: defaultArgs.subset,\n transaction: defaultArgs.transaction,\n }),\n ).toBeInstanceOf(GetWeb3CheckTask);\n });\n\n it(\"should build the transaction context without clear sign contexts\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [];\n const clearSignContextsOptional: ClearSignContext[] = [];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\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\n // WHEN\n const result = await new BuildTransactionContextTask(\n apiMock,\n { ...defaultArgs, appConfig: createAppConfig(true) },\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts,\n clearSignContextsOptional,\n clearSigningType: ClearSigningType.BASIC,\n });\n });\n\n it(\"should build the transaction context with web3checks\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [];\n const clearSignContextsOptional: ClearSignContext[] = [];\n const expectedWeb3Check =\n \"web3Check\" as unknown as ClearSignContextSuccess<ClearSignContextType.WEB3_CHECK>;\n getWeb3ChecksFactoryMock.mockReturnValueOnce({\n run: async () => Promise.resolve({ web3Check: expectedWeb3Check }),\n });\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\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\n // WHEN\n const result = await new BuildTransactionContextTask(\n apiMock,\n { ...defaultArgs, appConfig: createAppConfig(true) },\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [expectedWeb3Check, ...clearSignContexts],\n clearSignContextsOptional,\n clearSigningType: ClearSigningType.BASIC,\n });\n });\n\n it(\"should build the transaction context with web3checks and generic-parser clear sign contexts\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-1\",\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-2\",\n },\n {\n type: ClearSignContextType.ENUM,\n payload: \"payload-3\",\n id: 1,\n value: 2,\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-4\",\n },\n ];\n const expectedWeb3Check =\n \"web3Check\" as unknown as ClearSignContextSuccess<ClearSignContextType.WEB3_CHECK>;\n getWeb3ChecksFactoryMock.mockReturnValueOnce({\n run: async () => Promise.resolve({ web3Check: expectedWeb3Check }),\n });\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.15.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildTransactionContextTask(\n apiMock,\n { ...defaultArgs, appConfig: createAppConfig(true) },\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [\n clearSignContexts[0],\n clearSignContexts[1],\n clearSignContexts[3],\n expectedWeb3Check,\n ],\n clearSignContextsOptional: [clearSignContexts[2]],\n clearSigningType: ClearSigningType.EIP7730,\n });\n });\n\n it(\"should build the transaction context with web3checks and generic-parser clear sign contexts in the correct order\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.ENUM,\n payload: \"payload-3\",\n id: 1,\n value: 2,\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-4\",\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-2\",\n },\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-1\",\n certificate: defaultCertificate,\n },\n ];\n const expectedWeb3Check =\n \"web3Check\" as unknown as ClearSignContextSuccess<ClearSignContextType.WEB3_CHECK>;\n getWeb3ChecksFactoryMock.mockReturnValueOnce({\n run: async () => Promise.resolve({ web3Check: expectedWeb3Check }),\n });\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.15.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildTransactionContextTask(\n apiMock,\n { ...defaultArgs, appConfig: createAppConfig(true) },\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [\n clearSignContexts[3], // transaction info\n clearSignContexts[1], // transaction field description\n clearSignContexts[2], // transaction field description\n expectedWeb3Check, // web3 check\n ],\n clearSignContextsOptional: [clearSignContexts[0]], // enum\n clearSigningType: ClearSigningType.EIP7730,\n });\n });\n\n it(\"should build the transaction context with clear sign contexts\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-1\",\n },\n {\n type: ClearSignContextType.NFT,\n payload: \"payload-2\",\n },\n ];\n const expectedWeb3Check =\n \"web3Check\" as unknown as ClearSignContextSuccess<ClearSignContextType.WEB3_CHECK>;\n getWeb3ChecksFactoryMock.mockReturnValueOnce({\n run: async () => Promise.resolve({ web3Check: expectedWeb3Check }),\n });\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\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\n // WHEN\n const result = await new BuildTransactionContextTask(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts,\n clearSignContextsOptional: [],\n clearSigningType: ClearSigningType.BASIC,\n });\n });\n\n it(\"should build the transaction context with generic-parser context\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-1\",\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-2\",\n },\n {\n type: ClearSignContextType.ENUM,\n payload: \"payload-3\",\n id: 1,\n value: 2,\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-4\",\n },\n ];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.15.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildTransactionContextTask(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [\n clearSignContexts[0],\n clearSignContexts[1],\n clearSignContexts[3],\n ],\n clearSignContextsOptional: [clearSignContexts[2]],\n clearSigningType: ClearSigningType.EIP7730,\n });\n });\n\n it(\"should build the transaction context with proxy delegate call context\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-1\",\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.PROXY_DELEGATE_CALL,\n payload: \"payload-2\",\n },\n ];\n const clearSignContextsOptional: ClearSignContext[] = [];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.15.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildTransactionContextTask(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [clearSignContexts[1], clearSignContexts[0]],\n clearSignContextsOptional,\n clearSigningType: ClearSigningType.EIP7730,\n });\n });\n\n it(\"should call the web3checks factory with correct parameters\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\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\n // WHEN\n await new BuildTransactionContextTask(\n apiMock,\n { ...defaultArgs, appConfig: createAppConfig(true) },\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(getWeb3ChecksFactoryMock).toHaveBeenCalledWith(apiMock, {\n contextModule: contextModuleMock,\n derivationPath: \"44'/60'/0'/0/0\",\n subset: defaultArgs.subset,\n transaction: defaultTransaction,\n });\n });\n\n it(\"should call the context module with the correct parameters\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\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\n // WHEN\n await new BuildTransactionContextTask(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(contextModuleMock.getContexts).toHaveBeenCalledWith({\n deviceModelId: DeviceModelId.FLEX,\n challenge: \"challenge\",\n domain: \"domain-name.eth\",\n ...defaultArgs.subset,\n });\n });\n\n it(\"should call the context module without challenge for Nano S\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.12.0\" },\n deviceModelId: DeviceModelId.NANO_S,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n await new BuildTransactionContextTask(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(contextModuleMock.getContexts).toHaveBeenCalledWith({\n deviceModelId: DeviceModelId.NANO_S,\n domain: \"domain-name.eth\",\n ...defaultArgs.subset,\n });\n });\n\n it(\"should call the context module without context on error\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\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 apiMock.sendCommand.mockResolvedValueOnce(\n CommandResultFactory({ error: new UnknownDeviceExchangeError() }),\n );\n\n // WHEN\n await new BuildTransactionContextTask(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(contextModuleMock.getContexts).toHaveBeenCalledWith({\n deviceModelId: DeviceModelId.FLEX,\n challenge: undefined,\n domain: \"domain-name.eth\",\n ...defaultArgs.subset,\n });\n });\n\n it(\"should exclude error contexts from the result\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"error\"),\n },\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-1\",\n },\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"error\"),\n },\n {\n type: ClearSignContextType.NFT,\n payload: \"payload-2\",\n },\n ];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\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\n // WHEN\n const result = await new BuildTransactionContextTask(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [clearSignContexts[1], clearSignContexts[3]],\n clearSignContextsOptional: [],\n clearSigningType: ClearSigningType.BASIC,\n });\n });\n\n it(\"should exclude generic-parser contexts from the result on old apps\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"transaction_info\",\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-1\",\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"transaction_field\",\n },\n {\n type: ClearSignContextType.NFT,\n payload: \"payload-2\",\n },\n {\n type: ClearSignContextType.ENUM,\n payload: \"enum\",\n id: 1,\n value: 2,\n certificate: defaultCertificate,\n },\n ];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\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\n // WHEN\n const result = await new BuildTransactionContextTask(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [clearSignContexts[1], clearSignContexts[3]],\n clearSignContextsOptional: [],\n clearSigningType: ClearSigningType.BASIC,\n });\n });\n\n it(\"should exclude generic-parser contexts from the result if no transaction_info was found\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"transaction_field\",\n },\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-1\",\n },\n {\n type: ClearSignContextType.ENUM,\n payload: \"enum\",\n id: 1,\n value: 2,\n },\n {\n type: ClearSignContextType.NFT,\n payload: \"payload-2\",\n },\n ];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.14.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildTransactionContextTask(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [clearSignContexts[1], clearSignContexts[3]],\n clearSignContextsOptional: [],\n clearSigningType: ClearSigningType.BASIC,\n });\n });\n\n it(\"should exclude legacy contexts from the result for generic-parser transactions\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-1\",\n },\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-2\",\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.EXTERNAL_PLUGIN,\n payload: \"payload-3\",\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-4\",\n },\n {\n type: ClearSignContextType.ENUM,\n payload: \"payload-5\",\n id: 1,\n value: 2,\n certificate: defaultCertificate,\n },\n ];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.15.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildTransactionContextTask(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [clearSignContexts[1], clearSignContexts[3]],\n clearSignContextsOptional: [clearSignContexts[4]],\n clearSigningType: ClearSigningType.EIP7730,\n });\n });\n\n it(\"should exclude generic-parser contexts with a nano s device\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-1\",\n },\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-2\",\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-3\",\n },\n {\n type: ClearSignContextType.ENUM,\n payload: \"payload-4\",\n id: 1,\n value: 2,\n certificate: defaultCertificate,\n },\n ];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.14.0\" },\n deviceModelId: DeviceModelId.NANO_S,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildTransactionContextTask(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [clearSignContexts[0]],\n clearSignContextsOptional: [],\n clearSigningType: ClearSigningType.BASIC,\n });\n });\n\n it(\"should exclude generic-parser contexts with an old app version\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-1\",\n },\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-2\",\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-3\",\n },\n {\n type: ClearSignContextType.ENUM,\n payload: \"payload-4\",\n id: 1,\n value: 2,\n certificate: defaultCertificate,\n },\n ];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\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\n // WHEN\n const result = await new BuildTransactionContextTask(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [clearSignContexts[0]],\n clearSignContextsOptional: [],\n clearSigningType: ClearSigningType.BASIC,\n });\n });\n\n it(\"should exclude generic-parser contexts with a non ready device\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-1\",\n },\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-2\",\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-3\",\n },\n {\n type: ClearSignContextType.ENUM,\n payload: \"payload-4\",\n id: 1,\n value: 2,\n certificate: defaultCertificate,\n },\n ];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.Connected,\n deviceStatus: DeviceStatus.NOT_CONNECTED,\n deviceModelId: DeviceModelId.FLEX,\n });\n\n // WHEN\n const result = await new BuildTransactionContextTask(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [clearSignContexts[0]],\n clearSignContextsOptional: [],\n clearSigningType: ClearSigningType.BASIC,\n });\n });\n\n it(\"should return no clear sign context if the transaction info certificate is missing\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-1\",\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-2\",\n },\n {\n type: ClearSignContextType.ENUM,\n payload: \"payload-3\",\n id: 1,\n value: 2,\n },\n ];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.17.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildTransactionContextTask(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [],\n clearSignContextsOptional: [],\n clearSigningType: ClearSigningType.BASIC,\n });\n });\n});\n"],
|
|
5
|
+
"mappings": "aAAA,IAAAA,EAKO,oCACPC,EAOO,2CACPC,EAA4B,kBAG5BC,EAAiC,uCACjCC,EAAgD,6EAEhDC,EAGO,yCACPC,EAAiC,8BAEjC,SAAS,8BAA+B,IAAM,CAC5C,MAAMC,EAAoB,CACxB,WAAY,GAAG,GAAG,EAClB,YAAa,GAAG,GAAG,EACnB,oBAAqB,GAAG,GAAG,EAC3B,cAAe,GAAG,GAAG,EACrB,iBAAkB,GAAG,GAAG,CAC1B,EACMC,EAAiB,CACrB,OAAQ,iBACV,EACMC,KAAiC,sBACrC,cAAY,KAAK,CACf,QAAS,GACT,MAAO,EACP,KAAM,IACR,CAAC,EAAE,kBACL,EACMC,EAAqC,CACzC,eAAgB,EAChB,QAAS,IAAI,WAAW,CAAC,EAAM,EAAM,CAAI,CAAC,CAC5C,EAEA,IAAIC,EACJ,MAAMC,KAAU,mCAAgC,EAC1CC,EAA2B,GAAG,GAAG,EAEvC,SAASC,EACPC,EAC0B,CAC1B,MAAO,CACL,oBAAqB,GACrB,kBAAAA,EACA,gBAAiB,GACjB,QAAS,QACX,CACF,CAEA,WAAW,IAAM,CACf,GAAG,cAAc,EACjBH,EAAQ,YAAY,qBAClB,wBAAqB,CAAE,KAAM,CAAE,UAAW,WAAY,CAAE,CAAC,CAC3D,EACAC,EAAyB,gBAAgB,CACvC,IAAK,SAAY,QAAQ,QAAQ,CAAE,UAAW,IAAK,CAAC,CACtD,CAAC,EAEDF,EAAc,CAC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mBAAiB,KACrC,CAAC,CACH,CAAC,EAED,GAAG,qFAAsF,SAAY,CAEnG,MAAMA,EAAwC,CAC5C,CACE,KAAM,uBAAqB,iBAC3B,QAAS,WACX,EACA,CACE,KAAM,uBAAqB,8BAC3B,QAAS,WACX,EACA,CACE,KAAM,uBAAqB,KAC3B,QAAS,YACT,GAAI,EACJ,MAAO,CACT,CACF,EACAV,EAAkB,YAAY,sBAAsBU,CAAiB,EACrEL,EAAQ,sBAAsB,oBAAoB,CAChD,iBAAkB,yBAAuB,0BACzC,aAAc,eAAa,UAC3B,cAAe,CAAC,EAChB,WAAY,CAAE,KAAM,WAAY,QAAS,QAAS,EAClD,cAAe,gBAAc,KAC7B,0BAA2B,EAC7B,CAAC,EAGD,MAAMO,EAAS,MAAM,IAAI,8BACvBP,EACAD,EACAE,CACF,EAAE,IAAI,EAGN,OAAOM,CAAM,EAAE,QAAQ,CACrB,kBAAmB,CAAC,EACpB,0BAA2B,CAAC,EAC5B,iBAAkB,mBAAiB,KACrC,CAAC,CACH,CAAC,CACH,CAAC",
|
|
6
6
|
"names": ["import_context_module", "import_device_management_kit", "import_ethers", "import_ClearSigningType", "import_makeInternalApi", "import_BuildTransactionContextTask", "import_GetWeb3CheckTask", "contextModuleMock", "defaultOptions", "defaultTransaction", "defaultCertificate", "defaultArgs", "apiMock", "getWeb3ChecksFactoryMock", "createAppConfig", "web3ChecksEnabled", "task", "clearSignContexts", "clearSignContextsOptional", "result", "expectedWeb3Check"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var C=Object.defineProperty;var N=Object.getOwnPropertyDescriptor;var S=Object.getOwnPropertyNames;var x=Object.prototype.hasOwnProperty;var A=(i,a)=>{for(var t in a)C(i,t,{get:a[t],enumerable:!0})},g=(i,a,t,e)=>{if(a&&typeof a=="object"||typeof a=="function")for(let n of S(a))!x.call(i,n)&&n!==t&&C(i,n,{get:()=>a[n],enumerable:!(e=N(a,n))||e.enumerable});return i};var R=i=>g(C({},"__esModule",{value:!0}),i);var O={};A(O,{ProvideTransactionContextTask:()=>D});module.exports=R(O);var r=require("@ledgerhq/context-module"),o=require("@ledgerhq/device-management-kit"),h=require("@ledgerhq/signer-utils"),u=require("purify-ts"),k=require("../../app-binder/command/ProvideEnumCommand"),m=require("../../app-binder/command/ProvideNetworkConfigurationCommand"),p=require("../../app-binder/command/ProvideNFTInformationCommand"),T=require("../../app-binder/command/ProvideProxyInfoCommand"),y=require("../../app-binder/command/ProvideTokenInformationCommand"),l=require("../../app-binder/command/ProvideTransactionFieldDescriptionCommand"),F=require("../../app-binder/command/ProvideTransactionInformationCommand"),I=require("../../app-binder/command/ProvideTrustedNameCommand"),_=require("../../app-binder/command/ProvideWeb3CheckCommand"),f=require("../../app-binder/command/SetExternalPluginCommand"),P=require("../../app-binder/command/SetPluginCommand"),w=require("../../app-binder/command/StoreTransactionCommand"),E=require("./SendCommandInChunksTask"),v=require("./SendPayloadInChunksTask");class D{constructor(a,t,e=(s,c)=>new v.SendPayloadInChunksTask(s,c),n=(s,c)=>new E.SendCommandInChunksTask(s,c)){this._api=a;this._args=t;this._sendPayloadInChunksTaskFactory=e;this._sendCommandInChunksTaskFactory=n}async run(){for(const t of this._args.subcontextsCallbacks){const e=await t();if(e.type===r.ClearSignContextType.ERROR)continue;const n=await this.provideContext(e);if(!(0,o.isSuccessCommandResult)(n))return(0,u.Left)(n)}const a=await this.provideContext(this._args.context);return(0,o.isSuccessCommandResult)(a)?(0,u.Right)(void 0):(0,u.Left)(a)}async provideContext({type:a,payload:t,certificate:e}){switch(e&&await this._api.sendCommand(new o.LoadCertificateCommand({keyUsage:e.keyUsageNumber,certificate:e.payload})),a){case r.ClearSignContextType.PLUGIN:return await this._api.sendCommand(new P.SetPluginCommand({payload:t}));case r.ClearSignContextType.EXTERNAL_PLUGIN:return await this._api.sendCommand(new f.SetExternalPluginCommand({payload:t}));case r.ClearSignContextType.NFT:return await this._api.sendCommand(new p.ProvideNFTInformationCommand({payload:t}));case r.ClearSignContextType.TOKEN:return await this._api.sendCommand(new y.ProvideTokenInformationCommand({payload:t}));case r.ClearSignContextType.TRANSACTION_INFO:{const n=h.DerivationPathUtils.splitPath(this._args.derivationPath),s=new o.ByteArrayBuilder;return s.add8BitUIntToData(n.length),n.forEach(d=>{s.add32BitUIntToData(d)}),s.addBufferToData(this._args.serializedTransaction),await this._sendCommandInChunksTaskFactory(this._api,{data:s.build(),commandFactory:d=>new w.StoreTransactionCommand({serializedTransaction:d.chunkedData,isFirstChunk:d.isFirstChunk})}).run(),await this._sendPayloadInChunksTaskFactory(this._api,{payload:this._args.context.payload,commandFactory:d=>new F.ProvideTransactionInformationCommand({data:d.chunkedData,isFirstChunk:d.isFirstChunk})}).run()}case r.ClearSignContextType.TRUSTED_NAME:return this._sendPayloadInChunksTaskFactory(this._api,{payload:t,commandFactory:n=>new I.ProvideTrustedNameCommand({data:n.chunkedData,isFirstChunk:n.isFirstChunk})}).run();case r.ClearSignContextType.ENUM:return this._sendPayloadInChunksTaskFactory(this._api,{payload:t,commandFactory:n=>new k.ProvideEnumCommand({data:n.chunkedData,isFirstChunk:n.isFirstChunk})}).run();case r.ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION:return this._sendPayloadInChunksTaskFactory(this._api,{payload:t,commandFactory:n=>new l.ProvideTransactionFieldDescriptionCommand({data:n.chunkedData,isFirstChunk:n.isFirstChunk})}).run();case r.ClearSignContextType.WEB3_CHECK:return this._sendPayloadInChunksTaskFactory(this._api,{payload:t,commandFactory:n=>new _.ProvideWeb3CheckCommand({payload:n.chunkedData,isFirstChunk:n.isFirstChunk})}).run();case r.ClearSignContextType.PROXY_DELEGATE_CALL:return this._sendPayloadInChunksTaskFactory(this._api,{payload:t,commandFactory:n=>new T.ProvideProxyInfoCommand({data:n.chunkedData,isFirstChunk:n.isFirstChunk})}).run();case r.ClearSignContextType.DYNAMIC_NETWORK:return this._sendPayloadInChunksTaskFactory(this._api,{payload:t,commandFactory:n=>new m.ProvideNetworkConfigurationCommand({data:n.chunkedData,isFirstChunk:n.isFirstChunk,configurationType:m.NetworkConfigurationType.CONFIGURATION})}).run();case r.ClearSignContextType.DYNAMIC_NETWORK_ICON:return this._sendPayloadInChunksTaskFactory(this._api,{payload:t,commandFactory:n=>new m.ProvideNetworkConfigurationCommand({data:n.chunkedData,isFirstChunk:n.isFirstChunk,configurationType:m.NetworkConfigurationType.ICON}),withPayloadLength:!1}).run();default:{const n=a;return(0,o.CommandResultFactory)({error:new o.InvalidStatusWordError(`The context type [${n}] is not covered`)})}}}}0&&(module.exports={ProvideTransactionContextTask});
|
|
2
2
|
//# sourceMappingURL=ProvideTransactionContextTask.js.map
|