@ledgerhq/device-signer-kit-ethereum 1.3.2 → 1.3.3
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/app-binder/SignTransactionDeviceActionTypes.js +1 -1
- package/lib/cjs/api/app-binder/SignTransactionDeviceActionTypes.js.map +2 -2
- package/lib/cjs/api/app-binder/SignTypedDataDeviceActionTypes.js +1 -1
- package/lib/cjs/api/app-binder/SignTypedDataDeviceActionTypes.js.map +2 -2
- package/lib/cjs/internal/app-binder/device-action/SignTransaction/SignTransactionDeviceAction.js +1 -1
- package/lib/cjs/internal/app-binder/device-action/SignTransaction/SignTransactionDeviceAction.js.map +2 -2
- package/lib/cjs/internal/app-binder/device-action/SignTransaction/SignTransactionDeviceAction.test.js +1 -1
- package/lib/cjs/internal/app-binder/device-action/SignTransaction/SignTransactionDeviceAction.test.js.map +3 -3
- package/lib/cjs/internal/app-binder/device-action/SignTypedData/SignTypedDataDeviceAction.js +1 -1
- package/lib/cjs/internal/app-binder/device-action/SignTypedData/SignTypedDataDeviceAction.js.map +2 -2
- package/lib/cjs/internal/app-binder/device-action/SignTypedData/SignTypedDataDeviceAction.test.js +1 -1
- package/lib/cjs/internal/app-binder/device-action/SignTypedData/SignTypedDataDeviceAction.test.js.map +3 -3
- package/lib/cjs/internal/app-binder/task/BuildEIP712ContextTask.js +1 -1
- package/lib/cjs/internal/app-binder/task/BuildEIP712ContextTask.js.map +3 -3
- package/lib/cjs/internal/app-binder/task/BuildEIP712ContextTask.test.js +1 -1
- package/lib/cjs/internal/app-binder/task/BuildEIP712ContextTask.test.js.map +3 -3
- 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 +3 -3
- package/lib/cjs/internal/shared/utils/ApplicationChecker.js +1 -1
- package/lib/cjs/internal/shared/utils/ApplicationChecker.js.map +3 -3
- package/lib/cjs/internal/shared/utils/ApplicationChecker.test.js +1 -1
- package/lib/cjs/internal/shared/utils/ApplicationChecker.test.js.map +3 -3
- package/lib/cjs/package.json +3 -3
- package/lib/esm/api/app-binder/SignTransactionDeviceActionTypes.js.map +2 -2
- package/lib/esm/api/app-binder/SignTypedDataDeviceActionTypes.js.map +2 -2
- package/lib/esm/internal/app-binder/device-action/SignTransaction/SignTransactionDeviceAction.js +1 -1
- package/lib/esm/internal/app-binder/device-action/SignTransaction/SignTransactionDeviceAction.js.map +2 -2
- package/lib/esm/internal/app-binder/device-action/SignTransaction/SignTransactionDeviceAction.test.js +1 -1
- package/lib/esm/internal/app-binder/device-action/SignTransaction/SignTransactionDeviceAction.test.js.map +3 -3
- package/lib/esm/internal/app-binder/device-action/SignTypedData/SignTypedDataDeviceAction.js +1 -1
- package/lib/esm/internal/app-binder/device-action/SignTypedData/SignTypedDataDeviceAction.js.map +2 -2
- package/lib/esm/internal/app-binder/device-action/SignTypedData/SignTypedDataDeviceAction.test.js +1 -1
- package/lib/esm/internal/app-binder/device-action/SignTypedData/SignTypedDataDeviceAction.test.js.map +3 -3
- package/lib/esm/internal/app-binder/task/BuildEIP712ContextTask.js +1 -1
- package/lib/esm/internal/app-binder/task/BuildEIP712ContextTask.js.map +3 -3
- package/lib/esm/internal/app-binder/task/BuildEIP712ContextTask.test.js +1 -1
- package/lib/esm/internal/app-binder/task/BuildEIP712ContextTask.test.js.map +3 -3
- 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 +3 -3
- package/lib/esm/internal/shared/utils/ApplicationChecker.js +1 -1
- package/lib/esm/internal/shared/utils/ApplicationChecker.js.map +3 -3
- package/lib/esm/internal/shared/utils/ApplicationChecker.test.js +1 -1
- package/lib/esm/internal/shared/utils/ApplicationChecker.test.js.map +3 -3
- package/lib/esm/package.json +3 -3
- package/lib/types/api/app-binder/SignTransactionDeviceActionTypes.d.ts +2 -2
- package/lib/types/api/app-binder/SignTransactionDeviceActionTypes.d.ts.map +1 -1
- package/lib/types/api/app-binder/SignTypedDataDeviceActionTypes.d.ts +2 -2
- package/lib/types/api/app-binder/SignTypedDataDeviceActionTypes.d.ts.map +1 -1
- package/lib/types/internal/app-binder/device-action/SignTransaction/SignTransactionDeviceAction.d.ts +1 -1
- package/lib/types/internal/app-binder/device-action/SignTransaction/SignTransactionDeviceAction.d.ts.map +1 -1
- package/lib/types/internal/app-binder/device-action/SignTypedData/SignTypedDataDeviceAction.d.ts +1 -1
- package/lib/types/internal/app-binder/device-action/SignTypedData/SignTypedDataDeviceAction.d.ts.map +1 -1
- package/lib/types/internal/app-binder/task/BuildEIP712ContextTask.d.ts +3 -2
- package/lib/types/internal/app-binder/task/BuildEIP712ContextTask.d.ts.map +1 -1
- package/lib/types/internal/app-binder/task/BuildTransactionContextTask.d.ts +2 -1
- package/lib/types/internal/app-binder/task/BuildTransactionContextTask.d.ts.map +1 -1
- package/lib/types/internal/shared/utils/ApplicationChecker.d.ts +2 -1
- package/lib/types/internal/shared/utils/ApplicationChecker.d.ts.map +1 -1
- package/lib/types/tsconfig.prod.tsbuildinfo +1 -1
- package/package.json +3 -3
|
@@ -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} from \"@ledgerhq/context-module\";\nimport {\n DeviceModelId,\n type DeviceSessionState,\n type InternalApi,\n isSuccessCommandResult,\n} from \"@ledgerhq/device-management-kit\";\n\nimport { type TransactionOptions } from \"@api/model/TransactionOptions\";\nimport { type TransactionType } from \"@api/model/TransactionType\";\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\";\nimport { type TransactionMapperService } from \"@internal/transaction/service/mapper/TransactionMapperService\";\n\nimport { type GenericContext } from \"./ProvideTransactionGenericContextTask\";\n\nexport type BuildTransactionTaskResult = {\n readonly clearSignContexts: ClearSignContextSuccess[] | GenericContext;\n readonly serializedTransaction: Uint8Array;\n readonly chainId: number;\n readonly transactionType: TransactionType;\n readonly web3Check: ClearSignContextSuccess<ClearSignContextType.WEB3_CHECK> | null;\n};\n\nexport type BuildTransactionContextTaskArgs = {\n readonly contextModule: ContextModule;\n readonly mapper: TransactionMapperService;\n readonly transaction: Uint8Array;\n readonly options: TransactionOptions;\n readonly
|
|
5
|
-
"mappings": "AAAA,OAGE,wBAAAA,MAEK,2BACP,OACE,iBAAAC,EAGA,0BAAAC,MACK,
|
|
6
|
-
"names": ["ClearSignContextType", "DeviceModelId", "isSuccessCommandResult", "GetChallengeCommand", "GetWeb3CheckTask", "ApplicationChecker", "BuildTransactionContextTask", "api", "args", "getWeb3ChecksFactory", "contextModule", "mapper", "transaction", "options", "
|
|
4
|
+
"sourcesContent": ["import {\n type ClearSignContextSuccess,\n type ClearSignContextSuccessType,\n ClearSignContextType,\n type ContextModule,\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 { type TransactionOptions } from \"@api/model/TransactionOptions\";\nimport { type TransactionType } from \"@api/model/TransactionType\";\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\";\nimport { type TransactionMapperService } from \"@internal/transaction/service/mapper/TransactionMapperService\";\n\nimport { type GenericContext } from \"./ProvideTransactionGenericContextTask\";\n\nexport type BuildTransactionTaskResult = {\n readonly clearSignContexts: ClearSignContextSuccess[] | GenericContext;\n readonly serializedTransaction: Uint8Array;\n readonly chainId: number;\n readonly transactionType: TransactionType;\n readonly web3Check: ClearSignContextSuccess<ClearSignContextType.WEB3_CHECK> | null;\n};\n\nexport type BuildTransactionContextTaskArgs = {\n readonly contextModule: ContextModule;\n readonly mapper: TransactionMapperService;\n readonly transaction: Uint8Array;\n readonly options: TransactionOptions;\n readonly appConfig: GetConfigCommandResponse;\n readonly derivationPath: string;\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 mapper,\n transaction,\n options,\n appConfig,\n derivationPath,\n } = this.args;\n const deviceState = this.api.getDeviceSessionState();\n\n // Parse transaction\n const parsed = mapper.mapTransactionToSubset(transaction);\n parsed.ifLeft((err) => {\n throw err;\n });\n const { subset, serializedTransaction, type } = parsed.unsafeCoerce();\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 mapper,\n transaction,\n }).run()\n ).web3Check;\n }\n\n // Get challenge\n let challenge: string | undefined = undefined;\n const challengeRes = await this.api.sendCommand(new GetChallengeCommand());\n if (isSuccessCommandResult(challengeRes)) {\n challenge = challengeRes.data.challenge;\n }\n\n // Get the clear sign contexts\n const clearSignContexts = 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 let filteredContexts: ClearSignContextSuccess[] | GenericContext = [];\n const transactionInfo = clearSignContextsSuccess.find(\n (ctx) => ctx.type === ClearSignContextType.TRANSACTION_INFO,\n );\n\n if (transactionInfo && !transactionInfo.certificate) {\n throw new Error(\"Transaction info certificate is missing\");\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 } else {\n const transactionFields = clearSignContextsSuccess.filter(\n (ctx) =>\n ctx.type === ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n );\n filteredContexts = {\n transactionInfo: transactionInfo.payload,\n transactionInfoCertificate: transactionInfo.certificate!,\n transactionFields,\n transactionEnums,\n };\n }\n\n return {\n clearSignContexts: filteredContexts,\n serializedTransaction,\n chainId: subset.chainId,\n transactionType: type,\n web3Check,\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": "AAAA,OAGE,wBAAAA,MAEK,2BACP,OACE,iBAAAC,EAGA,0BAAAC,MACK,kCAKP,OAAS,uBAAAC,MAA2B,mDACpC,OACE,oBAAAC,MAEK,6CACP,OAAS,sBAAAC,MAA0B,4CAsB5B,MAAMC,CAA4B,CACvC,YACmBC,EACAC,EACAC,EAAuB,CACtCF,EACAC,IACG,IAAIJ,EAAiBG,EAAKC,CAAI,EACnC,CANiB,SAAAD,EACA,UAAAC,EACA,0BAAAC,CAIhB,CAEH,MAAM,KAA2C,CAC/C,KAAM,CACJ,cAAAC,EACA,OAAAC,EACA,YAAAC,EACA,QAAAC,EACA,UAAAC,EACA,eAAAC,CACF,EAAI,KAAK,KACHC,EAAc,KAAK,IAAI,sBAAsB,EAG7CC,EAASN,EAAO,uBAAuBC,CAAW,EACxDK,EAAO,OAAQC,GAAQ,CACrB,MAAMA,CACR,CAAC,EACD,KAAM,CAAE,OAAAC,EAAQ,sBAAAC,EAAuB,KAAAC,CAAK,EAAIJ,EAAO,aAAa,EAGpE,IAAIK,EACF,KACER,EAAU,oBACZQ,GACE,MAAM,KAAK,qBAAqB,KAAK,IAAK,CACxC,cAAAZ,EACA,eAAAK,EACA,OAAAJ,EACA,YAAAC,CACF,CAAC,EAAE,IAAI,GACP,WAIJ,IAAIW,EACJ,MAAMC,EAAe,MAAM,KAAK,IAAI,YAAY,IAAIrB,CAAqB,EACrED,EAAuBsB,CAAY,IACrCD,EAAYC,EAAa,KAAK,WAIhC,MAAMC,EAAoB,MAAMf,EAAc,YAAY,CACxD,UAAWa,EACX,OAAQV,EAAQ,OAChB,cAAeG,EAAY,cAC3B,GAAGG,CACL,CAAC,EAKKO,EAEAD,EAAkB,OACrBE,GACCA,EAAQ,OAAS3B,EAAqB,OACtC2B,EAAQ,OAAS3B,EAAqB,IAC1C,EAGM4B,EACJH,EAAkB,OACfE,GAAYA,EAAQ,OAAS3B,EAAqB,IACrD,EAEF,IAAI6B,EAA+D,CAAC,EACpE,MAAMC,EAAkBJ,EAAyB,KAC9CK,GAAQA,EAAI,OAAS/B,EAAqB,gBAC7C,EAEA,GAAI8B,GAAmB,CAACA,EAAgB,YACtC,MAAM,IAAI,MAAM,yCAAyC,EAM3D,GACE,CAAC,KAAK,sBAAsBd,EAAaF,CAAS,GAClDgB,IAAoB,OAEpBD,EAAmBH,EAAyB,OACzCK,GACCA,EAAI,OAAS/B,EAAqB,kBAClC+B,EAAI,OAAS/B,EAAqB,6BACtC,MACK,CACL,MAAMgC,EAAoBN,EAAyB,OAChDK,GACCA,EAAI,OAAS/B,EAAqB,6BACtC,EACA6B,EAAmB,CACjB,gBAAiBC,EAAgB,QACjC,2BAA4BA,EAAgB,YAC5C,kBAAAE,EACA,iBAAAJ,CACF,CACF,CAEA,MAAO,CACL,kBAAmBC,EACnB,sBAAAT,EACA,QAASD,EAAO,QAChB,gBAAiBE,EACjB,UAAAC,CACF,CACF,CAEQ,sBACNN,EACAF,EACS,CACT,OAAO,IAAIT,EAAmBW,EAAaF,CAAS,EACjD,wBAAwB,QAAQ,EAChC,mBAAmBb,EAAc,MAAM,EACvC,MAAM,CACX,CACF",
|
|
6
|
+
"names": ["ClearSignContextType", "DeviceModelId", "isSuccessCommandResult", "GetChallengeCommand", "GetWeb3CheckTask", "ApplicationChecker", "BuildTransactionContextTask", "api", "args", "getWeb3ChecksFactory", "contextModule", "mapper", "transaction", "options", "appConfig", "derivationPath", "deviceState", "parsed", "err", "subset", "serializedTransaction", "type", "web3Check", "challenge", "challengeRes", "clearSignContexts", "clearSignContextsSuccess", "context", "transactionEnums", "filteredContexts", "transactionInfo", "ctx", "transactionFields"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{ClearSignContextType as n}from"@ledgerhq/context-module";import{CommandResultFactory as m,DeviceModelId as l,DeviceSessionStateType as d,DeviceStatus as p,hexaStringToBuffer as R,UnknownDeviceExchangeError as E}from"@ledgerhq/device-management-kit";import{Transaction as v}from"ethers";import{Left as O,Right as C}from"purify-ts";import{makeDeviceActionInternalApiMock as g}from"../../app-binder/device-action/__test-utils__/makeInternalApi";import{BuildTransactionContextTask as y}from"./BuildTransactionContextTask";describe("BuildTransactionContextTask",()=>{const i={getContext:vi.fn(),getContexts:vi.fn(),getTypedDataFilters:vi.fn(),getWeb3Checks:vi.fn()},r={mapTransactionToSubset:vi.fn()},h={domain:"domain-name.eth"},T=R(v.from({chainId:1n,nonce:0,data:"0x"}).unsignedSerialized),S={keyUsageNumber:1,payload:new Uint8Array([1,2,3])};let u;const a=g(),c=vi.fn();beforeEach(()=>{vi.resetAllMocks(),a.sendCommand.mockResolvedValue(m({data:{challenge:"challenge"}})),c.mockReturnValue({run:async()=>({web3Check:null})}),u={contextModule:i,mapper:r,transaction:T,options:h,web3ChecksEnabled:!1,derivationPath:"44'/60'/0'/0/0"}}),it("should build the transaction context without clear sign contexts",async()=>{const t=new Uint8Array([1,2,3]),e=[],o={subset:{chainId:1,to:void 0,data:"0x"},serializedTransaction:t,type:0};r.mapTransactionToSubset.mockReturnValueOnce(C(o)),i.getContexts.mockResolvedValueOnce(e),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:d.ReadyWithoutSecureChannel,deviceStatus:p.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:l.FLEX,isSecureConnectionAllowed:!1});const s=await new y(a,{...u,web3ChecksEnabled:!0},c).run();expect(s).toEqual({clearSignContexts:e,serializedTransaction:t,chainId:1,transactionType:0,web3Check:null})}),it("should build the transaction context with web3checks",async()=>{const t=new Uint8Array([1,2,3]),e=[],o={subset:{chainId:1,to:void 0,data:"0x"},serializedTransaction:t,type:0},s="web3Check";c.mockReturnValueOnce({run:async()=>({web3Check:s})}),r.mapTransactionToSubset.mockReturnValueOnce(C(o)),i.getContexts.mockResolvedValueOnce(e),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:d.ReadyWithoutSecureChannel,deviceStatus:p.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:l.FLEX,isSecureConnectionAllowed:!1});const x=await new y(a,{...u,web3ChecksEnabled:!0},c).run();expect(x).toEqual({clearSignContexts:e,serializedTransaction:t,chainId:1,transactionType:0,web3Check:s})}),it("should build the transaction context with clear sign contexts",async()=>{const t=new Uint8Array([1,2,3]),e=[{type:n.TOKEN,payload:"payload-1"},{type:n.NFT,payload:"payload-2"}],o={subset:{chainId:1,to:void 0,data:"0x"},serializedTransaction:t,type:2},s="web3Check";c.mockReturnValueOnce({run:async()=>({web3Check:s})}),r.mapTransactionToSubset.mockReturnValueOnce(C(o)),i.getContexts.mockResolvedValueOnce(e),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:d.ReadyWithoutSecureChannel,deviceStatus:p.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:l.FLEX,isSecureConnectionAllowed:!1});const x=await new y(a,u,c).run();expect(x).toEqual({clearSignContexts:e,serializedTransaction:t,chainId:1,transactionType:2,web3Check:null})}),it("should build the transaction context with generic-parser context",async()=>{const t=new Uint8Array([1,2,3]),e=[{type:n.TRANSACTION_INFO,payload:"payload-1",certificate:S},{type:n.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-2"},{type:n.ENUM,payload:"payload-3",id:1,value:2,certificate:S},{type:n.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-4"}],o={subset:{chainId:1,to:void 0,data:"0x"},serializedTransaction:t,type:2};r.mapTransactionToSubset.mockReturnValueOnce(C(o)),i.getContexts.mockResolvedValueOnce(e),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:d.ReadyWithoutSecureChannel,deviceStatus:p.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.15.0"},deviceModelId:l.FLEX,isSecureConnectionAllowed:!1});const s=await new y(a,u,c).run();expect(s).toEqual({clearSignContexts:{transactionInfo:"payload-1",transactionInfoCertificate:S,transactionFields:[e[1],e[3]],transactionEnums:[e[2]]},serializedTransaction:t,chainId:1,transactionType:2,web3Check:null})}),it("should call the mapper with the transaction",async()=>{const t=new Uint8Array([1,2,3]),e=[],o={subset:{chainId:1,to:void 0,data:"0x"},serializedTransaction:t,type:0};r.mapTransactionToSubset.mockReturnValueOnce(C(o)),i.getContexts.mockResolvedValueOnce(e),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:d.ReadyWithoutSecureChannel,deviceStatus:p.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:l.FLEX,isSecureConnectionAllowed:!1}),await new y(a,u,c).run(),expect(r.mapTransactionToSubset).toHaveBeenCalledWith(T)}),it("should call the web3checks factory with correct parameters",async()=>{const t=new Uint8Array([1,2,3]),e=[],o={subset:{chainId:1,to:void 0,data:"0x"},serializedTransaction:t,type:0};r.mapTransactionToSubset.mockReturnValueOnce(C(o)),i.getContexts.mockResolvedValueOnce(e),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:d.ReadyWithoutSecureChannel,deviceStatus:p.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:l.FLEX,isSecureConnectionAllowed:!1}),await new y(a,{...u,web3ChecksEnabled:!0},c).run(),expect(c).toHaveBeenCalledWith(a,{contextModule:i,derivationPath:"44'/60'/0'/0/0",mapper:r,transaction:T})}),it("should call the context module with the correct parameters",async()=>{const t=new Uint8Array([1,2,3]),e=[],o={subset:{chainId:1,to:void 0,data:"0x"},serializedTransaction:t,type:0};r.mapTransactionToSubset.mockReturnValueOnce(C(o)),i.getContexts.mockResolvedValueOnce(e),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:d.ReadyWithoutSecureChannel,deviceStatus:p.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:l.FLEX,isSecureConnectionAllowed:!1}),await new y(a,u,c).run(),expect(i.getContexts).toHaveBeenCalledWith({deviceModelId:l.FLEX,challenge:"challenge",domain:"domain-name.eth",...o.subset})}),it("should call the context module without context on error",async()=>{const t=new Uint8Array([1,2,3]),e=[],o={subset:{chainId:1,to:void 0,data:"0x"},serializedTransaction:t,type:0};r.mapTransactionToSubset.mockReturnValueOnce(C(o)),i.getContexts.mockResolvedValueOnce(e),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:d.ReadyWithoutSecureChannel,deviceStatus:p.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:l.FLEX,isSecureConnectionAllowed:!1}),a.sendCommand.mockResolvedValueOnce(m({error:new E})),await new y(a,u,c).run(),expect(i.getContexts).toHaveBeenCalledWith({deviceModelId:l.FLEX,challenge:void 0,domain:"domain-name.eth",...o.subset})}),it("should throw an error if the mapper returns an error",async()=>{const t=new Error("error");r.mapTransactionToSubset.mockReturnValueOnce(O(t)),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:d.ReadyWithoutSecureChannel,deviceStatus:p.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:l.FLEX,isSecureConnectionAllowed:!1});const e=new y(a,u,c);await expect(e.run()).rejects.toThrow(t)}),it("should exclude error contexts from the result",async()=>{const t=new Uint8Array([1,2,3]),e=[{type:n.ERROR,error:new Error("error")},{type:n.TOKEN,payload:"payload-1"},{type:n.ERROR,error:new Error("error")},{type:n.NFT,payload:"payload-2"}],o={subset:{chainId:1,to:void 0,data:"0x"},serializedTransaction:t,type:0};r.mapTransactionToSubset.mockReturnValueOnce(C(o)),i.getContexts.mockResolvedValueOnce(e),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:d.ReadyWithoutSecureChannel,deviceStatus:p.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:l.FLEX,isSecureConnectionAllowed:!1});const s=await new y(a,u,c).run();expect(s).toEqual({clearSignContexts:[e[1],e[3]],serializedTransaction:t,chainId:1,transactionType:0,web3Check:null})}),it("should exclude generic-parser contexts from the result on old apps",async()=>{const t=new Uint8Array([1,2,3]),e=[{type:n.TRANSACTION_INFO,payload:"transaction_info",certificate:S},{type:n.TOKEN,payload:"payload-1"},{type:n.TRANSACTION_FIELD_DESCRIPTION,payload:"transaction_field"},{type:n.NFT,payload:"payload-2"},{type:n.ENUM,payload:"enum",id:1,value:2,certificate:S}],o={subset:{chainId:1,to:void 0,data:"0x"},serializedTransaction:t,type:0};r.mapTransactionToSubset.mockReturnValueOnce(C(o)),i.getContexts.mockResolvedValueOnce(e),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:d.ReadyWithoutSecureChannel,deviceStatus:p.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:l.FLEX,isSecureConnectionAllowed:!1});const s=await new y(a,u,c).run();expect(s).toEqual({clearSignContexts:[e[1],e[3]],serializedTransaction:t,chainId:1,transactionType:0,web3Check:null})}),it("should exclude generic-parser contexts from the result if no transaction_info was found",async()=>{const t=new Uint8Array([1,2,3]),e=[{type:n.TRANSACTION_FIELD_DESCRIPTION,payload:"transaction_field"},{type:n.TOKEN,payload:"payload-1"},{type:n.ENUM,payload:"enum",id:1,value:2},{type:n.NFT,payload:"payload-2"}],o={subset:{chainId:1,to:void 0,data:"0x"},serializedTransaction:t,type:0};r.mapTransactionToSubset.mockReturnValueOnce(C(o)),i.getContexts.mockResolvedValueOnce(e),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:d.ReadyWithoutSecureChannel,deviceStatus:p.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.14.0"},deviceModelId:l.FLEX,isSecureConnectionAllowed:!1});const s=await new y(a,u,c).run();expect(s).toEqual({clearSignContexts:[e[1],e[3]],serializedTransaction:t,chainId:1,transactionType:0,web3Check:null})}),it("should exclude legacy contexts from the result for generic-parser transactions",async()=>{const t=new Uint8Array([1,2,3]),e=[{type:n.TOKEN,payload:"payload-1"},{type:n.TRANSACTION_INFO,payload:"payload-2",certificate:S},{type:n.EXTERNAL_PLUGIN,payload:"payload-3"},{type:n.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-4"},{type:n.ENUM,payload:"payload-5",id:1,value:2,certificate:S}],o={subset:{chainId:1,to:void 0,data:"0x"},serializedTransaction:t,type:2};r.mapTransactionToSubset.mockReturnValueOnce(C(o)),i.getContexts.mockResolvedValueOnce(e),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:d.ReadyWithoutSecureChannel,deviceStatus:p.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.15.0"},deviceModelId:l.FLEX,isSecureConnectionAllowed:!1});const s=await new y(a,u,c).run();expect(s).toEqual({clearSignContexts:{transactionInfo:"payload-2",transactionInfoCertificate:S,transactionFields:[e[3]],transactionEnums:[e[4]]},serializedTransaction:t,chainId:1,transactionType:2,web3Check:null})}),it("should exclude generic-parser contexts with a nano s device",async()=>{const t=new Uint8Array([1,2,3]),e=[{type:n.TOKEN,payload:"payload-1"},{type:n.TRANSACTION_INFO,payload:"payload-2",certificate:S},{type:n.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-3"},{type:n.ENUM,payload:"payload-4",id:1,value:2,certificate:S}],o={subset:{chainId:1,to:void 0,data:"0x"},serializedTransaction:t,type:2};r.mapTransactionToSubset.mockReturnValueOnce(C(o)),i.getContexts.mockResolvedValueOnce(e),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:d.ReadyWithoutSecureChannel,deviceStatus:p.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.14.0"},deviceModelId:l.NANO_S,isSecureConnectionAllowed:!1});const s=await new y(a,u,c).run();expect(s).toEqual({clearSignContexts:[e[0]],serializedTransaction:t,chainId:1,transactionType:2,web3Check:null})}),it("should exclude generic-parser contexts with an old app version",async()=>{const t=new Uint8Array([1,2,3]),e=[{type:n.TOKEN,payload:"payload-1"},{type:n.TRANSACTION_INFO,payload:"payload-2",certificate:S},{type:n.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-3"},{type:n.ENUM,payload:"payload-4",id:1,value:2,certificate:S}],o={subset:{chainId:1,to:void 0,data:"0x"},serializedTransaction:t,type:2};r.mapTransactionToSubset.mockReturnValueOnce(C(o)),i.getContexts.mockResolvedValueOnce(e),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:d.ReadyWithoutSecureChannel,deviceStatus:p.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:l.FLEX,isSecureConnectionAllowed:!1});const s=await new y(a,u,c).run();expect(s).toEqual({clearSignContexts:[e[0]],serializedTransaction:t,chainId:1,transactionType:2,web3Check:null})}),it("should exclude generic-parser contexts with a non ready device",async()=>{const t=new Uint8Array([1,2,3]),e=[{type:n.TOKEN,payload:"payload-1"},{type:n.TRANSACTION_INFO,payload:"payload-2",certificate:S},{type:n.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-3"},{type:n.ENUM,payload:"payload-4",id:1,value:2,certificate:S}],o={subset:{chainId:1,to:void 0,data:"0x"},serializedTransaction:t,type:2};r.mapTransactionToSubset.mockReturnValueOnce(C(o)),i.getContexts.mockResolvedValueOnce(e),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:d.Connected,deviceStatus:p.NOT_CONNECTED,deviceModelId:l.FLEX});const s=await new y(a,u,c).run();expect(s).toEqual({clearSignContexts:[e[0]],serializedTransaction:t,chainId:1,transactionType:2,web3Check:null})}),it("should return an error if the transaction info certificate is missing",async()=>{const t=new Uint8Array([1,2,3]),e=[{type:n.TRANSACTION_INFO,payload:"payload-1"},{type:n.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-2"},{type:n.ENUM,payload:"payload-3",id:1,value:2}],o={subset:{chainId:1,to:void 0,data:"0x"},serializedTransaction:t,type:2};r.mapTransactionToSubset.mockReturnValueOnce(C(o)),i.getContexts.mockResolvedValueOnce(e),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:d.ReadyWithoutSecureChannel,deviceStatus:p.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.14.0"},deviceModelId:l.FLEX,isSecureConnectionAllowed:!1});const s=new y(a,u,c);await expect(s.run()).rejects.toThrow("Transaction info certificate is missing")})});
|
|
1
|
+
import{ClearSignContextType as n}from"@ledgerhq/context-module";import{CommandResultFactory as h,DeviceModelId as l,DeviceSessionStateType as d,DeviceStatus as p,hexaStringToBuffer as E,UnknownDeviceExchangeError as g}from"@ledgerhq/device-management-kit";import{Transaction as v}from"ethers";import{Left as O,Right as y}from"purify-ts";import{makeDeviceActionInternalApiMock as w}from"../../app-binder/device-action/__test-utils__/makeInternalApi";import{BuildTransactionContextTask as C}from"./BuildTransactionContextTask";describe("BuildTransactionContextTask",()=>{const i={getContext:vi.fn(),getContexts:vi.fn(),getTypedDataFilters:vi.fn(),getWeb3Checks:vi.fn()},r={mapTransactionToSubset:vi.fn()},R={domain:"domain-name.eth"},x=E(v.from({chainId:1n,nonce:0,data:"0x"}).unsignedSerialized),S={keyUsageNumber:1,payload:new Uint8Array([1,2,3])};let u;const a=w(),c=vi.fn();function T(t){return{blindSigningEnabled:!1,web3ChecksEnabled:t,web3ChecksOptIn:!1,version:"1.13.0"}}beforeEach(()=>{vi.resetAllMocks(),a.sendCommand.mockResolvedValue(h({data:{challenge:"challenge"}})),c.mockReturnValue({run:async()=>({web3Check:null})}),u={contextModule:i,mapper:r,transaction:x,options:R,appConfig:T(!1),derivationPath:"44'/60'/0'/0/0"}}),it("should build the transaction context without clear sign contexts",async()=>{const t=new Uint8Array([1,2,3]),e=[],o={subset:{chainId:1,to:void 0,data:"0x"},serializedTransaction:t,type:0};r.mapTransactionToSubset.mockReturnValueOnce(y(o)),i.getContexts.mockResolvedValueOnce(e),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:d.ReadyWithoutSecureChannel,deviceStatus:p.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:l.FLEX,isSecureConnectionAllowed:!1});const s=await new C(a,{...u,appConfig:T(!0)},c).run();expect(s).toEqual({clearSignContexts:e,serializedTransaction:t,chainId:1,transactionType:0,web3Check:null})}),it("should build the transaction context with web3checks",async()=>{const t=new Uint8Array([1,2,3]),e=[],o={subset:{chainId:1,to:void 0,data:"0x"},serializedTransaction:t,type:0},s="web3Check";c.mockReturnValueOnce({run:async()=>({web3Check:s})}),r.mapTransactionToSubset.mockReturnValueOnce(y(o)),i.getContexts.mockResolvedValueOnce(e),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:d.ReadyWithoutSecureChannel,deviceStatus:p.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:l.FLEX,isSecureConnectionAllowed:!1});const m=await new C(a,{...u,appConfig:T(!0)},c).run();expect(m).toEqual({clearSignContexts:e,serializedTransaction:t,chainId:1,transactionType:0,web3Check:s})}),it("should build the transaction context with clear sign contexts",async()=>{const t=new Uint8Array([1,2,3]),e=[{type:n.TOKEN,payload:"payload-1"},{type:n.NFT,payload:"payload-2"}],o={subset:{chainId:1,to:void 0,data:"0x"},serializedTransaction:t,type:2},s="web3Check";c.mockReturnValueOnce({run:async()=>({web3Check:s})}),r.mapTransactionToSubset.mockReturnValueOnce(y(o)),i.getContexts.mockResolvedValueOnce(e),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:d.ReadyWithoutSecureChannel,deviceStatus:p.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:l.FLEX,isSecureConnectionAllowed:!1});const m=await new C(a,u,c).run();expect(m).toEqual({clearSignContexts:e,serializedTransaction:t,chainId:1,transactionType:2,web3Check:null})}),it("should build the transaction context with generic-parser context",async()=>{const t=new Uint8Array([1,2,3]),e=[{type:n.TRANSACTION_INFO,payload:"payload-1",certificate:S},{type:n.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-2"},{type:n.ENUM,payload:"payload-3",id:1,value:2,certificate:S},{type:n.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-4"}],o={subset:{chainId:1,to:void 0,data:"0x"},serializedTransaction:t,type:2};r.mapTransactionToSubset.mockReturnValueOnce(y(o)),i.getContexts.mockResolvedValueOnce(e),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:d.ReadyWithoutSecureChannel,deviceStatus:p.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.15.0"},deviceModelId:l.FLEX,isSecureConnectionAllowed:!1});const s=await new C(a,u,c).run();expect(s).toEqual({clearSignContexts:{transactionInfo:"payload-1",transactionInfoCertificate:S,transactionFields:[e[1],e[3]],transactionEnums:[e[2]]},serializedTransaction:t,chainId:1,transactionType:2,web3Check:null})}),it("should call the mapper with the transaction",async()=>{const t=new Uint8Array([1,2,3]),e=[],o={subset:{chainId:1,to:void 0,data:"0x"},serializedTransaction:t,type:0};r.mapTransactionToSubset.mockReturnValueOnce(y(o)),i.getContexts.mockResolvedValueOnce(e),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:d.ReadyWithoutSecureChannel,deviceStatus:p.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:l.FLEX,isSecureConnectionAllowed:!1}),await new C(a,u,c).run(),expect(r.mapTransactionToSubset).toHaveBeenCalledWith(x)}),it("should call the web3checks factory with correct parameters",async()=>{const t=new Uint8Array([1,2,3]),e=[],o={subset:{chainId:1,to:void 0,data:"0x"},serializedTransaction:t,type:0};r.mapTransactionToSubset.mockReturnValueOnce(y(o)),i.getContexts.mockResolvedValueOnce(e),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:d.ReadyWithoutSecureChannel,deviceStatus:p.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:l.FLEX,isSecureConnectionAllowed:!1}),await new C(a,{...u,appConfig:T(!0)},c).run(),expect(c).toHaveBeenCalledWith(a,{contextModule:i,derivationPath:"44'/60'/0'/0/0",mapper:r,transaction:x})}),it("should call the context module with the correct parameters",async()=>{const t=new Uint8Array([1,2,3]),e=[],o={subset:{chainId:1,to:void 0,data:"0x"},serializedTransaction:t,type:0};r.mapTransactionToSubset.mockReturnValueOnce(y(o)),i.getContexts.mockResolvedValueOnce(e),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:d.ReadyWithoutSecureChannel,deviceStatus:p.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:l.FLEX,isSecureConnectionAllowed:!1}),await new C(a,u,c).run(),expect(i.getContexts).toHaveBeenCalledWith({deviceModelId:l.FLEX,challenge:"challenge",domain:"domain-name.eth",...o.subset})}),it("should call the context module without context on error",async()=>{const t=new Uint8Array([1,2,3]),e=[],o={subset:{chainId:1,to:void 0,data:"0x"},serializedTransaction:t,type:0};r.mapTransactionToSubset.mockReturnValueOnce(y(o)),i.getContexts.mockResolvedValueOnce(e),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:d.ReadyWithoutSecureChannel,deviceStatus:p.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:l.FLEX,isSecureConnectionAllowed:!1}),a.sendCommand.mockResolvedValueOnce(h({error:new g})),await new C(a,u,c).run(),expect(i.getContexts).toHaveBeenCalledWith({deviceModelId:l.FLEX,challenge:void 0,domain:"domain-name.eth",...o.subset})}),it("should throw an error if the mapper returns an error",async()=>{const t=new Error("error");r.mapTransactionToSubset.mockReturnValueOnce(O(t)),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:d.ReadyWithoutSecureChannel,deviceStatus:p.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:l.FLEX,isSecureConnectionAllowed:!1});const e=new C(a,u,c);await expect(e.run()).rejects.toThrow(t)}),it("should exclude error contexts from the result",async()=>{const t=new Uint8Array([1,2,3]),e=[{type:n.ERROR,error:new Error("error")},{type:n.TOKEN,payload:"payload-1"},{type:n.ERROR,error:new Error("error")},{type:n.NFT,payload:"payload-2"}],o={subset:{chainId:1,to:void 0,data:"0x"},serializedTransaction:t,type:0};r.mapTransactionToSubset.mockReturnValueOnce(y(o)),i.getContexts.mockResolvedValueOnce(e),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:d.ReadyWithoutSecureChannel,deviceStatus:p.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:l.FLEX,isSecureConnectionAllowed:!1});const s=await new C(a,u,c).run();expect(s).toEqual({clearSignContexts:[e[1],e[3]],serializedTransaction:t,chainId:1,transactionType:0,web3Check:null})}),it("should exclude generic-parser contexts from the result on old apps",async()=>{const t=new Uint8Array([1,2,3]),e=[{type:n.TRANSACTION_INFO,payload:"transaction_info",certificate:S},{type:n.TOKEN,payload:"payload-1"},{type:n.TRANSACTION_FIELD_DESCRIPTION,payload:"transaction_field"},{type:n.NFT,payload:"payload-2"},{type:n.ENUM,payload:"enum",id:1,value:2,certificate:S}],o={subset:{chainId:1,to:void 0,data:"0x"},serializedTransaction:t,type:0};r.mapTransactionToSubset.mockReturnValueOnce(y(o)),i.getContexts.mockResolvedValueOnce(e),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:d.ReadyWithoutSecureChannel,deviceStatus:p.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:l.FLEX,isSecureConnectionAllowed:!1});const s=await new C(a,u,c).run();expect(s).toEqual({clearSignContexts:[e[1],e[3]],serializedTransaction:t,chainId:1,transactionType:0,web3Check:null})}),it("should exclude generic-parser contexts from the result if no transaction_info was found",async()=>{const t=new Uint8Array([1,2,3]),e=[{type:n.TRANSACTION_FIELD_DESCRIPTION,payload:"transaction_field"},{type:n.TOKEN,payload:"payload-1"},{type:n.ENUM,payload:"enum",id:1,value:2},{type:n.NFT,payload:"payload-2"}],o={subset:{chainId:1,to:void 0,data:"0x"},serializedTransaction:t,type:0};r.mapTransactionToSubset.mockReturnValueOnce(y(o)),i.getContexts.mockResolvedValueOnce(e),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:d.ReadyWithoutSecureChannel,deviceStatus:p.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.14.0"},deviceModelId:l.FLEX,isSecureConnectionAllowed:!1});const s=await new C(a,u,c).run();expect(s).toEqual({clearSignContexts:[e[1],e[3]],serializedTransaction:t,chainId:1,transactionType:0,web3Check:null})}),it("should exclude legacy contexts from the result for generic-parser transactions",async()=>{const t=new Uint8Array([1,2,3]),e=[{type:n.TOKEN,payload:"payload-1"},{type:n.TRANSACTION_INFO,payload:"payload-2",certificate:S},{type:n.EXTERNAL_PLUGIN,payload:"payload-3"},{type:n.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-4"},{type:n.ENUM,payload:"payload-5",id:1,value:2,certificate:S}],o={subset:{chainId:1,to:void 0,data:"0x"},serializedTransaction:t,type:2};r.mapTransactionToSubset.mockReturnValueOnce(y(o)),i.getContexts.mockResolvedValueOnce(e),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:d.ReadyWithoutSecureChannel,deviceStatus:p.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.15.0"},deviceModelId:l.FLEX,isSecureConnectionAllowed:!1});const s=await new C(a,u,c).run();expect(s).toEqual({clearSignContexts:{transactionInfo:"payload-2",transactionInfoCertificate:S,transactionFields:[e[3]],transactionEnums:[e[4]]},serializedTransaction:t,chainId:1,transactionType:2,web3Check:null})}),it("should exclude generic-parser contexts with a nano s device",async()=>{const t=new Uint8Array([1,2,3]),e=[{type:n.TOKEN,payload:"payload-1"},{type:n.TRANSACTION_INFO,payload:"payload-2",certificate:S},{type:n.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-3"},{type:n.ENUM,payload:"payload-4",id:1,value:2,certificate:S}],o={subset:{chainId:1,to:void 0,data:"0x"},serializedTransaction:t,type:2};r.mapTransactionToSubset.mockReturnValueOnce(y(o)),i.getContexts.mockResolvedValueOnce(e),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:d.ReadyWithoutSecureChannel,deviceStatus:p.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.14.0"},deviceModelId:l.NANO_S,isSecureConnectionAllowed:!1});const s=await new C(a,u,c).run();expect(s).toEqual({clearSignContexts:[e[0]],serializedTransaction:t,chainId:1,transactionType:2,web3Check:null})}),it("should exclude generic-parser contexts with an old app version",async()=>{const t=new Uint8Array([1,2,3]),e=[{type:n.TOKEN,payload:"payload-1"},{type:n.TRANSACTION_INFO,payload:"payload-2",certificate:S},{type:n.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-3"},{type:n.ENUM,payload:"payload-4",id:1,value:2,certificate:S}],o={subset:{chainId:1,to:void 0,data:"0x"},serializedTransaction:t,type:2};r.mapTransactionToSubset.mockReturnValueOnce(y(o)),i.getContexts.mockResolvedValueOnce(e),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:d.ReadyWithoutSecureChannel,deviceStatus:p.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:l.FLEX,isSecureConnectionAllowed:!1});const s=await new C(a,u,c).run();expect(s).toEqual({clearSignContexts:[e[0]],serializedTransaction:t,chainId:1,transactionType:2,web3Check:null})}),it("should exclude generic-parser contexts with a non ready device",async()=>{const t=new Uint8Array([1,2,3]),e=[{type:n.TOKEN,payload:"payload-1"},{type:n.TRANSACTION_INFO,payload:"payload-2",certificate:S},{type:n.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-3"},{type:n.ENUM,payload:"payload-4",id:1,value:2,certificate:S}],o={subset:{chainId:1,to:void 0,data:"0x"},serializedTransaction:t,type:2};r.mapTransactionToSubset.mockReturnValueOnce(y(o)),i.getContexts.mockResolvedValueOnce(e),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:d.Connected,deviceStatus:p.NOT_CONNECTED,deviceModelId:l.FLEX});const s=await new C(a,u,c).run();expect(s).toEqual({clearSignContexts:[e[0]],serializedTransaction:t,chainId:1,transactionType:2,web3Check:null})}),it("should return an error if the transaction info certificate is missing",async()=>{const t=new Uint8Array([1,2,3]),e=[{type:n.TRANSACTION_INFO,payload:"payload-1"},{type:n.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-2"},{type:n.ENUM,payload:"payload-3",id:1,value:2}],o={subset:{chainId:1,to:void 0,data:"0x"},serializedTransaction:t,type:2};r.mapTransactionToSubset.mockReturnValueOnce(y(o)),i.getContexts.mockResolvedValueOnce(e),a.getDeviceSessionState.mockReturnValueOnce({sessionStateType:d.ReadyWithoutSecureChannel,deviceStatus:p.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.14.0"},deviceModelId:l.FLEX,isSecureConnectionAllowed:!1});const s=new C(a,u,c);await expect(s.run()).rejects.toThrow("Transaction info certificate is missing")})});
|
|
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\";\nimport { Left, Right } from \"purify-ts\";\n\nimport { makeDeviceActionInternalApiMock } from \"@internal/app-binder/device-action/__test-utils__/makeInternalApi\";\nimport { type TransactionMapperResult } from \"@internal/transaction/service/mapper/model/TransactionMapperResult\";\nimport { type TransactionMapperService } from \"@internal/transaction/service/mapper/TransactionMapperService\";\n\nimport {\n BuildTransactionContextTask,\n type BuildTransactionContextTaskArgs,\n} from \"./BuildTransactionContextTask\";\n\ndescribe(\"BuildTransactionContextTask\", () => {\n const contextModuleMock = {\n getContext: vi.fn(),\n getContexts: vi.fn(),\n getTypedDataFilters: vi.fn(),\n getWeb3Checks: vi.fn(),\n };\n const mapperMock = {\n mapTransactionToSubset: 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 beforeEach(() => {\n vi.resetAllMocks();\n apiMock.sendCommand.mockResolvedValue(\n CommandResultFactory({ data: { challenge: \"challenge\" } }),\n );\n getWeb3ChecksFactoryMock.mockReturnValue({\n run: async () => ({ web3Check: null }),\n });\n\n defaultArgs = {\n contextModule: contextModuleMock,\n mapper: mapperMock as unknown as TransactionMapperService,\n transaction: defaultTransaction,\n options: defaultOptions,\n web3ChecksEnabled: false,\n derivationPath: \"44'/60'/0'/0/0\",\n };\n });\n\n it(\"should build the transaction context without clear sign contexts\", async () => {\n // GIVEN\n const serializedTransaction = new Uint8Array([0x01, 0x02, 0x03]);\n const clearSignContexts: ClearSignContext[] = [];\n const mapperResult: TransactionMapperResult = {\n subset: { chainId: 1, to: undefined, data: \"0x\" },\n serializedTransaction,\n type: 0,\n };\n mapperMock.mapTransactionToSubset.mockReturnValueOnce(Right(mapperResult));\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, web3ChecksEnabled: true },\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts,\n serializedTransaction,\n chainId: 1,\n transactionType: 0,\n web3Check: null,\n });\n });\n\n it(\"should build the transaction context with web3checks\", async () => {\n // GIVEN\n const serializedTransaction = new Uint8Array([0x01, 0x02, 0x03]);\n const clearSignContexts: ClearSignContext[] = [];\n const mapperResult: TransactionMapperResult = {\n subset: { chainId: 1, to: undefined, data: \"0x\" },\n serializedTransaction,\n type: 0,\n };\n const expectedWeb3Check =\n \"web3Check\" as unknown as ClearSignContextSuccess<ClearSignContextType.WEB3_CHECK>;\n getWeb3ChecksFactoryMock.mockReturnValueOnce({\n run: async () => ({ web3Check: expectedWeb3Check }),\n });\n mapperMock.mapTransactionToSubset.mockReturnValueOnce(Right(mapperResult));\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, web3ChecksEnabled: true },\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts,\n serializedTransaction,\n chainId: 1,\n transactionType: 0,\n web3Check: expectedWeb3Check,\n });\n });\n\n it(\"should build the transaction context with clear sign contexts\", async () => {\n // GIVEN\n const serializedTransaction = new Uint8Array([0x01, 0x02, 0x03]);\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 mapperResult: TransactionMapperResult = {\n subset: { chainId: 1, to: undefined, data: \"0x\" },\n serializedTransaction,\n type: 2,\n };\n const expectedWeb3Check =\n \"web3Check\" as unknown as ClearSignContextSuccess<ClearSignContextType.WEB3_CHECK>;\n getWeb3ChecksFactoryMock.mockReturnValueOnce({\n run: async () => ({ web3Check: expectedWeb3Check }),\n });\n mapperMock.mapTransactionToSubset.mockReturnValueOnce(Right(mapperResult));\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 serializedTransaction,\n chainId: 1,\n transactionType: 2,\n web3Check: null,\n });\n });\n\n it(\"should build the transaction context with generic-parser context\", async () => {\n // GIVEN\n const serializedTransaction = new Uint8Array([0x01, 0x02, 0x03]);\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 mapperResult: TransactionMapperResult = {\n subset: { chainId: 1, to: undefined, data: \"0x\" },\n serializedTransaction,\n type: 2,\n };\n mapperMock.mapTransactionToSubset.mockReturnValueOnce(Right(mapperResult));\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 transactionInfo: \"payload-1\",\n transactionInfoCertificate: defaultCertificate,\n transactionFields: [clearSignContexts[1], clearSignContexts[3]],\n transactionEnums: [clearSignContexts[2]],\n },\n serializedTransaction,\n chainId: 1,\n transactionType: 2,\n web3Check: null,\n });\n });\n\n it(\"should call the mapper with the transaction\", async () => {\n // GIVEN\n const serializedTransaction = new Uint8Array([0x01, 0x02, 0x03]);\n const clearSignContexts: ClearSignContext[] = [];\n const mapperResult: TransactionMapperResult = {\n subset: { chainId: 1, to: undefined, data: \"0x\" },\n serializedTransaction,\n type: 0,\n };\n mapperMock.mapTransactionToSubset.mockReturnValueOnce(Right(mapperResult));\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(mapperMock.mapTransactionToSubset).toHaveBeenCalledWith(\n defaultTransaction,\n );\n });\n\n it(\"should call the web3checks factory with correct parameters\", async () => {\n // GIVEN\n const serializedTransaction = new Uint8Array([0x01, 0x02, 0x03]);\n const clearSignContexts: ClearSignContext[] = [];\n const mapperResult: TransactionMapperResult = {\n subset: { chainId: 1, to: undefined, data: \"0x\" },\n serializedTransaction,\n type: 0,\n };\n mapperMock.mapTransactionToSubset.mockReturnValueOnce(Right(mapperResult));\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, web3ChecksEnabled: true },\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(getWeb3ChecksFactoryMock).toHaveBeenCalledWith(apiMock, {\n contextModule: contextModuleMock,\n derivationPath: \"44'/60'/0'/0/0\",\n mapper: mapperMock,\n transaction: defaultTransaction,\n });\n });\n\n it(\"should call the context module with the correct parameters\", async () => {\n // GIVEN\n const serializedTransaction = new Uint8Array([0x01, 0x02, 0x03]);\n const clearSignContexts: ClearSignContext[] = [];\n const mapperResult: TransactionMapperResult = {\n subset: { chainId: 1, to: undefined, data: \"0x\" },\n serializedTransaction,\n type: 0,\n };\n mapperMock.mapTransactionToSubset.mockReturnValueOnce(Right(mapperResult));\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 ...mapperResult.subset,\n });\n });\n\n it(\"should call the context module without context on error\", async () => {\n // GIVEN\n const serializedTransaction = new Uint8Array([0x01, 0x02, 0x03]);\n const clearSignContexts: ClearSignContext[] = [];\n const mapperResult: TransactionMapperResult = {\n subset: { chainId: 1, to: undefined, data: \"0x\" },\n serializedTransaction,\n type: 0,\n };\n mapperMock.mapTransactionToSubset.mockReturnValueOnce(Right(mapperResult));\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 ...mapperResult.subset,\n });\n });\n\n it(\"should throw an error if the mapper returns an error\", async () => {\n // GIVEN\n const error = new Error(\"error\");\n mapperMock.mapTransactionToSubset.mockReturnValueOnce(Left(error));\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 task = new BuildTransactionContextTask(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n );\n\n // THEN\n await expect(task.run()).rejects.toThrow(error);\n });\n\n it(\"should exclude error contexts from the result\", async () => {\n // GIVEN\n const serializedTransaction = new Uint8Array([0x01, 0x02, 0x03]);\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 const mapperResult: TransactionMapperResult = {\n subset: { chainId: 1, to: undefined, data: \"0x\" },\n serializedTransaction,\n type: 0,\n };\n mapperMock.mapTransactionToSubset.mockReturnValueOnce(Right(mapperResult));\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 serializedTransaction,\n chainId: 1,\n transactionType: 0,\n web3Check: null,\n });\n });\n\n it(\"should exclude generic-parser contexts from the result on old apps\", async () => {\n // GIVEN\n const serializedTransaction = new Uint8Array([0x01, 0x02, 0x03]);\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 const mapperResult: TransactionMapperResult = {\n subset: { chainId: 1, to: undefined, data: \"0x\" },\n serializedTransaction,\n type: 0,\n };\n mapperMock.mapTransactionToSubset.mockReturnValueOnce(Right(mapperResult));\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 serializedTransaction,\n chainId: 1,\n transactionType: 0,\n web3Check: null,\n });\n });\n\n it(\"should exclude generic-parser contexts from the result if no transaction_info was found\", async () => {\n // GIVEN\n const serializedTransaction = new Uint8Array([0x01, 0x02, 0x03]);\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 const mapperResult: TransactionMapperResult = {\n subset: { chainId: 1, to: undefined, data: \"0x\" },\n serializedTransaction,\n type: 0,\n };\n mapperMock.mapTransactionToSubset.mockReturnValueOnce(Right(mapperResult));\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 serializedTransaction,\n chainId: 1,\n transactionType: 0,\n web3Check: null,\n });\n });\n\n it(\"should exclude legacy contexts from the result for generic-parser transactions\", async () => {\n // GIVEN\n const serializedTransaction = new Uint8Array([0x01, 0x02, 0x03]);\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 const mapperResult: TransactionMapperResult = {\n subset: { chainId: 1, to: undefined, data: \"0x\" },\n serializedTransaction,\n type: 2,\n };\n mapperMock.mapTransactionToSubset.mockReturnValueOnce(Right(mapperResult));\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 transactionInfo: \"payload-2\",\n transactionInfoCertificate: defaultCertificate,\n transactionFields: [clearSignContexts[3]],\n transactionEnums: [clearSignContexts[4]],\n },\n serializedTransaction,\n chainId: 1,\n transactionType: 2,\n web3Check: null,\n });\n });\n\n it(\"should exclude generic-parser contexts with a nano s device\", async () => {\n // GIVEN\n const serializedTransaction = new Uint8Array([0x01, 0x02, 0x03]);\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 const mapperResult: TransactionMapperResult = {\n subset: { chainId: 1, to: undefined, data: \"0x\" },\n serializedTransaction,\n type: 2,\n };\n mapperMock.mapTransactionToSubset.mockReturnValueOnce(Right(mapperResult));\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 serializedTransaction,\n chainId: 1,\n transactionType: 2,\n web3Check: null,\n });\n });\n\n it(\"should exclude generic-parser contexts with an old app version\", async () => {\n // GIVEN\n const serializedTransaction = new Uint8Array([0x01, 0x02, 0x03]);\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 const mapperResult: TransactionMapperResult = {\n subset: { chainId: 1, to: undefined, data: \"0x\" },\n serializedTransaction,\n type: 2,\n };\n mapperMock.mapTransactionToSubset.mockReturnValueOnce(Right(mapperResult));\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 serializedTransaction,\n chainId: 1,\n transactionType: 2,\n web3Check: null,\n });\n });\n\n it(\"should exclude generic-parser contexts with a non ready device\", async () => {\n // GIVEN\n const serializedTransaction = new Uint8Array([0x01, 0x02, 0x03]);\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 const mapperResult: TransactionMapperResult = {\n subset: { chainId: 1, to: undefined, data: \"0x\" },\n serializedTransaction,\n type: 2,\n };\n mapperMock.mapTransactionToSubset.mockReturnValueOnce(Right(mapperResult));\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 serializedTransaction,\n chainId: 1,\n transactionType: 2,\n web3Check: null,\n });\n });\n\n it(\"should return an error if the transaction info certificate is missing\", async () => {\n // GIVEN\n const serializedTransaction = new Uint8Array([0x01, 0x02, 0x03]);\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 const mapperResult: TransactionMapperResult = {\n subset: { chainId: 1, to: undefined, data: \"0x\" },\n serializedTransaction,\n type: 2,\n };\n mapperMock.mapTransactionToSubset.mockReturnValueOnce(Right(mapperResult));\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 task = new BuildTransactionContextTask(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n );\n\n // THEN\n await expect(task.run()).rejects.toThr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If,EACfO,EACAD,EACAE,CACF,EAGA,MAAM,OAAOO,EAAK,IAAI,CAAC,EAAE,QAAQ,QAC/B,yCACF,CACF,CAAC,CACH,CAAC",
|
|
6
|
-
"names": ["ClearSignContextType", "CommandResultFactory", "DeviceModelId", "DeviceSessionStateType", "DeviceStatus", "hexaStringToBuffer", "UnknownDeviceExchangeError", "Transaction", "Left", "Right", "makeDeviceActionInternalApiMock", "BuildTransactionContextTask", "contextModuleMock", "mapperMock", "defaultOptions", "defaultTransaction", "defaultCertificate", "defaultArgs", "apiMock", "getWeb3ChecksFactoryMock", "serializedTransaction", "clearSignContexts", "mapperResult", "result", "expectedWeb3Check", "error", "task"]
|
|
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\";\nimport { Left, Right } from \"purify-ts\";\n\nimport type { GetConfigCommandResponse } from \"@api/app-binder/GetConfigCommandTypes\";\nimport { makeDeviceActionInternalApiMock } from \"@internal/app-binder/device-action/__test-utils__/makeInternalApi\";\nimport { type TransactionMapperResult } from \"@internal/transaction/service/mapper/model/TransactionMapperResult\";\nimport { type TransactionMapperService } from \"@internal/transaction/service/mapper/TransactionMapperService\";\n\nimport {\n BuildTransactionContextTask,\n type BuildTransactionContextTaskArgs,\n} from \"./BuildTransactionContextTask\";\n\ndescribe(\"BuildTransactionContextTask\", () => {\n const contextModuleMock = {\n getContext: vi.fn(),\n getContexts: vi.fn(),\n getTypedDataFilters: vi.fn(),\n getWeb3Checks: vi.fn(),\n };\n const mapperMock = {\n mapTransactionToSubset: 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 () => ({ web3Check: null }),\n });\n\n defaultArgs = {\n contextModule: contextModuleMock,\n mapper: mapperMock as unknown as TransactionMapperService,\n transaction: defaultTransaction,\n options: defaultOptions,\n appConfig: createAppConfig(false),\n derivationPath: \"44'/60'/0'/0/0\",\n };\n });\n\n it(\"should build the transaction context without clear sign contexts\", async () => {\n // GIVEN\n const serializedTransaction = new Uint8Array([0x01, 0x02, 0x03]);\n const clearSignContexts: ClearSignContext[] = [];\n const mapperResult: TransactionMapperResult = {\n subset: { chainId: 1, to: undefined, data: \"0x\" },\n serializedTransaction,\n type: 0,\n };\n mapperMock.mapTransactionToSubset.mockReturnValueOnce(Right(mapperResult));\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 serializedTransaction,\n chainId: 1,\n transactionType: 0,\n web3Check: null,\n });\n });\n\n it(\"should build the transaction context with web3checks\", async () => {\n // GIVEN\n const serializedTransaction = new Uint8Array([0x01, 0x02, 0x03]);\n const clearSignContexts: ClearSignContext[] = [];\n const mapperResult: TransactionMapperResult = {\n subset: { chainId: 1, to: undefined, data: \"0x\" },\n serializedTransaction,\n type: 0,\n };\n const expectedWeb3Check =\n \"web3Check\" as unknown as ClearSignContextSuccess<ClearSignContextType.WEB3_CHECK>;\n getWeb3ChecksFactoryMock.mockReturnValueOnce({\n run: async () => ({ web3Check: expectedWeb3Check }),\n });\n mapperMock.mapTransactionToSubset.mockReturnValueOnce(Right(mapperResult));\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 serializedTransaction,\n chainId: 1,\n transactionType: 0,\n web3Check: expectedWeb3Check,\n });\n });\n\n it(\"should build the transaction context with clear sign contexts\", async () => {\n // GIVEN\n const serializedTransaction = new Uint8Array([0x01, 0x02, 0x03]);\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 mapperResult: TransactionMapperResult = {\n subset: { chainId: 1, to: undefined, data: \"0x\" },\n serializedTransaction,\n type: 2,\n };\n const expectedWeb3Check =\n \"web3Check\" as unknown as ClearSignContextSuccess<ClearSignContextType.WEB3_CHECK>;\n getWeb3ChecksFactoryMock.mockReturnValueOnce({\n run: async () => ({ web3Check: expectedWeb3Check }),\n });\n mapperMock.mapTransactionToSubset.mockReturnValueOnce(Right(mapperResult));\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 serializedTransaction,\n chainId: 1,\n transactionType: 2,\n web3Check: null,\n });\n });\n\n it(\"should build the transaction context with generic-parser context\", async () => {\n // GIVEN\n const serializedTransaction = new Uint8Array([0x01, 0x02, 0x03]);\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 mapperResult: TransactionMapperResult = {\n subset: { chainId: 1, to: undefined, data: \"0x\" },\n serializedTransaction,\n type: 2,\n };\n mapperMock.mapTransactionToSubset.mockReturnValueOnce(Right(mapperResult));\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 transactionInfo: \"payload-1\",\n transactionInfoCertificate: defaultCertificate,\n transactionFields: [clearSignContexts[1], clearSignContexts[3]],\n transactionEnums: [clearSignContexts[2]],\n },\n serializedTransaction,\n chainId: 1,\n transactionType: 2,\n web3Check: null,\n });\n });\n\n it(\"should call the mapper with the transaction\", async () => {\n // GIVEN\n const serializedTransaction = new Uint8Array([0x01, 0x02, 0x03]);\n const clearSignContexts: ClearSignContext[] = [];\n const mapperResult: TransactionMapperResult = {\n subset: { chainId: 1, to: undefined, data: \"0x\" },\n serializedTransaction,\n type: 0,\n };\n mapperMock.mapTransactionToSubset.mockReturnValueOnce(Right(mapperResult));\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(mapperMock.mapTransactionToSubset).toHaveBeenCalledWith(\n defaultTransaction,\n );\n });\n\n it(\"should call the web3checks factory with correct parameters\", async () => {\n // GIVEN\n const serializedTransaction = new Uint8Array([0x01, 0x02, 0x03]);\n const clearSignContexts: ClearSignContext[] = [];\n const mapperResult: TransactionMapperResult = {\n subset: { chainId: 1, to: undefined, data: \"0x\" },\n serializedTransaction,\n type: 0,\n };\n mapperMock.mapTransactionToSubset.mockReturnValueOnce(Right(mapperResult));\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 mapper: mapperMock,\n transaction: defaultTransaction,\n });\n });\n\n it(\"should call the context module with the correct parameters\", async () => {\n // GIVEN\n const serializedTransaction = new Uint8Array([0x01, 0x02, 0x03]);\n const clearSignContexts: ClearSignContext[] = [];\n const mapperResult: TransactionMapperResult = {\n subset: { chainId: 1, to: undefined, data: \"0x\" },\n serializedTransaction,\n type: 0,\n };\n mapperMock.mapTransactionToSubset.mockReturnValueOnce(Right(mapperResult));\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 ...mapperResult.subset,\n });\n });\n\n it(\"should call the context module without context on error\", async () => {\n // GIVEN\n const serializedTransaction = new Uint8Array([0x01, 0x02, 0x03]);\n const clearSignContexts: ClearSignContext[] = [];\n const mapperResult: TransactionMapperResult = {\n subset: { chainId: 1, to: undefined, data: \"0x\" },\n serializedTransaction,\n type: 0,\n };\n mapperMock.mapTransactionToSubset.mockReturnValueOnce(Right(mapperResult));\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 ...mapperResult.subset,\n });\n });\n\n it(\"should throw an error if the mapper returns an error\", async () => {\n // GIVEN\n const error = new Error(\"error\");\n mapperMock.mapTransactionToSubset.mockReturnValueOnce(Left(error));\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 task = new BuildTransactionContextTask(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n );\n\n // THEN\n await expect(task.run()).rejects.toThrow(error);\n });\n\n it(\"should exclude error contexts from the result\", async () => {\n // GIVEN\n const serializedTransaction = new Uint8Array([0x01, 0x02, 0x03]);\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 const mapperResult: TransactionMapperResult = {\n subset: { chainId: 1, to: undefined, data: \"0x\" },\n serializedTransaction,\n type: 0,\n };\n mapperMock.mapTransactionToSubset.mockReturnValueOnce(Right(mapperResult));\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 serializedTransaction,\n chainId: 1,\n transactionType: 0,\n web3Check: null,\n });\n });\n\n it(\"should exclude generic-parser contexts from the result on old apps\", async () => {\n // GIVEN\n const serializedTransaction = new Uint8Array([0x01, 0x02, 0x03]);\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 const mapperResult: TransactionMapperResult = {\n subset: { chainId: 1, to: undefined, data: \"0x\" },\n serializedTransaction,\n type: 0,\n };\n mapperMock.mapTransactionToSubset.mockReturnValueOnce(Right(mapperResult));\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 serializedTransaction,\n chainId: 1,\n transactionType: 0,\n web3Check: null,\n });\n });\n\n it(\"should exclude generic-parser contexts from the result if no transaction_info was found\", async () => {\n // GIVEN\n const serializedTransaction = new Uint8Array([0x01, 0x02, 0x03]);\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 const mapperResult: TransactionMapperResult = {\n subset: { chainId: 1, to: undefined, data: \"0x\" },\n serializedTransaction,\n type: 0,\n };\n mapperMock.mapTransactionToSubset.mockReturnValueOnce(Right(mapperResult));\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 serializedTransaction,\n chainId: 1,\n transactionType: 0,\n web3Check: null,\n });\n });\n\n it(\"should exclude legacy contexts from the result for generic-parser transactions\", async () => {\n // GIVEN\n const serializedTransaction = new Uint8Array([0x01, 0x02, 0x03]);\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 const mapperResult: TransactionMapperResult = {\n subset: { chainId: 1, to: undefined, data: \"0x\" },\n serializedTransaction,\n type: 2,\n };\n mapperMock.mapTransactionToSubset.mockReturnValueOnce(Right(mapperResult));\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 transactionInfo: \"payload-2\",\n transactionInfoCertificate: defaultCertificate,\n transactionFields: [clearSignContexts[3]],\n transactionEnums: [clearSignContexts[4]],\n },\n serializedTransaction,\n chainId: 1,\n transactionType: 2,\n web3Check: null,\n });\n });\n\n it(\"should exclude generic-parser contexts with a nano s device\", async () => {\n // GIVEN\n const serializedTransaction = new Uint8Array([0x01, 0x02, 0x03]);\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 const mapperResult: TransactionMapperResult = {\n subset: { chainId: 1, to: undefined, data: \"0x\" },\n serializedTransaction,\n type: 2,\n };\n mapperMock.mapTransactionToSubset.mockReturnValueOnce(Right(mapperResult));\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 serializedTransaction,\n chainId: 1,\n transactionType: 2,\n web3Check: null,\n });\n });\n\n it(\"should exclude generic-parser contexts with an old app version\", async () => {\n // GIVEN\n const serializedTransaction = new Uint8Array([0x01, 0x02, 0x03]);\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 const mapperResult: TransactionMapperResult = {\n subset: { chainId: 1, to: undefined, data: \"0x\" },\n serializedTransaction,\n type: 2,\n };\n mapperMock.mapTransactionToSubset.mockReturnValueOnce(Right(mapperResult));\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 serializedTransaction,\n chainId: 1,\n transactionType: 2,\n web3Check: null,\n });\n });\n\n it(\"should exclude generic-parser contexts with a non ready device\", async () => {\n // GIVEN\n const serializedTransaction = new Uint8Array([0x01, 0x02, 0x03]);\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 const mapperResult: TransactionMapperResult = {\n subset: { chainId: 1, to: undefined, data: \"0x\" },\n serializedTransaction,\n type: 2,\n };\n mapperMock.mapTransactionToSubset.mockReturnValueOnce(Right(mapperResult));\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 serializedTransaction,\n chainId: 1,\n transactionType: 2,\n web3Check: null,\n });\n });\n\n it(\"should return an error if the transaction info certificate is missing\", async () => {\n // GIVEN\n const serializedTransaction = new Uint8Array([0x01, 0x02, 0x03]);\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 const mapperResult: TransactionMapperResult = {\n subset: { chainId: 1, to: undefined, data: \"0x\" },\n serializedTransaction,\n type: 2,\n };\n mapperMock.mapTransactionToSubset.mockReturnValueOnce(Right(mapperResult));\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 task = new BuildTransactionContextTask(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n );\n\n // THEN\n await expect(task.run()).rejects.toThrow(\n \"Transaction info certificate is missing\",\n );\n });\n});\n"],
|
|
5
|
+
"mappings":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,QAAS,QAAS,EAClD,cAAeF,EAAc,KAC7B,0BAA2B,EAC7B,CAAC,EAGD,MAAM0B,EAAO,IAAIjB,EACfO,EACAD,EACAE,CACF,EAGA,MAAM,OAAOS,EAAK,IAAI,CAAC,EAAE,QAAQ,QAC/B,yCACF,CACF,CAAC,CACH,CAAC",
|
|
6
|
+
"names": ["ClearSignContextType", "CommandResultFactory", "DeviceModelId", "DeviceSessionStateType", "DeviceStatus", "hexaStringToBuffer", "UnknownDeviceExchangeError", "Transaction", "Left", "Right", "makeDeviceActionInternalApiMock", "BuildTransactionContextTask", "contextModuleMock", "mapperMock", "defaultOptions", "defaultTransaction", "defaultCertificate", "defaultArgs", "apiMock", "getWeb3ChecksFactoryMock", "createAppConfig", "web3ChecksEnabled", "serializedTransaction", "clearSignContexts", "mapperResult", "result", "expectedWeb3Check", "error", "task"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{DeviceSessionStateType as
|
|
1
|
+
import{DeviceSessionStateType as t}from"@ledgerhq/device-management-kit";import{gt as s,gte as o}from"semver";import{ETHEREUM_PLUGINS as r}from"../../app-binder/constant/plugins";class a{isCompatible=!0;version="0.0.1";modelId;constructor(e,i){if(this.modelId=e.deviceModelId,e.sessionStateType===t.Connected){this.isCompatible=!1;return}if(e.currentApp.name!=="Ethereum"&&!r.includes(e.currentApp.name)){this.isCompatible=!1;return}e.currentApp.name==="Ethereum"?this.version=e.currentApp.version:this.version=i.version}withMinVersionInclusive(e){return o(this.version,e)||(this.isCompatible=!1),this}withMinVersionExclusive(e){return s(this.version,e)||(this.isCompatible=!1),this}excludeDeviceModel(e){return this.modelId===e&&(this.isCompatible=!1),this}check(){return this.isCompatible}}export{a as ApplicationChecker};
|
|
2
2
|
//# sourceMappingURL=ApplicationChecker.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/internal/shared/utils/ApplicationChecker.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n type DeviceModelId,\n type DeviceSessionState,\n DeviceSessionStateType,\n} from \"@ledgerhq/device-management-kit\";\nimport { gt, gte } from \"semver\";\n\nimport { ETHEREUM_PLUGINS } from \"@internal/app-binder/constant/plugins\";\n\nexport class ApplicationChecker {\n private isCompatible: boolean = true;\n private version: string = \"0.0.1\";\n private modelId: DeviceModelId;\n\n constructor(deviceState: DeviceSessionState) {\n this.modelId = deviceState.deviceModelId;\n\n // If device is not ready or app is unexpected, checker cannot be successful\n if (deviceState.sessionStateType === DeviceSessionStateType.Connected) {\n this.isCompatible = false;\n return;\n }\n if (\n deviceState.currentApp.name !== \"Ethereum\" &&\n !ETHEREUM_PLUGINS.includes(deviceState.currentApp.name)\n ) {\n this.isCompatible = false;\n return;\n }\n this.version = deviceState.currentApp.version;\n }\n\n withMinVersionInclusive(version: string): ApplicationChecker {\n if (!gte(this.version, version)) {\n this.isCompatible = false;\n }\n return this;\n }\n\n withMinVersionExclusive(version: string): ApplicationChecker {\n if (!gt(this.version, version)) {\n this.isCompatible = false;\n }\n return this;\n }\n\n excludeDeviceModel(modelId: DeviceModelId): ApplicationChecker {\n if (this.modelId === modelId) {\n this.isCompatible = false;\n }\n return this;\n }\n\n check(): boolean {\n return this.isCompatible;\n }\n}\n"],
|
|
5
|
-
"mappings": "AAAA,OAGE,0BAAAA,MACK,kCACP,OAAS,MAAAC,EAAI,OAAAC,MAAW,
|
|
6
|
-
"names": ["DeviceSessionStateType", "gt", "gte", "ETHEREUM_PLUGINS", "ApplicationChecker", "deviceState", "version", "modelId"]
|
|
4
|
+
"sourcesContent": ["import {\n type DeviceModelId,\n type DeviceSessionState,\n DeviceSessionStateType,\n} from \"@ledgerhq/device-management-kit\";\nimport { gt, gte } from \"semver\";\n\nimport { type GetConfigCommandResponse } from \"@api/app-binder/GetConfigCommandTypes\";\nimport { ETHEREUM_PLUGINS } from \"@internal/app-binder/constant/plugins\";\n\nexport class ApplicationChecker {\n private isCompatible: boolean = true;\n private version: string = \"0.0.1\";\n private modelId: DeviceModelId;\n\n constructor(\n deviceState: DeviceSessionState,\n appConfig: GetConfigCommandResponse,\n ) {\n this.modelId = deviceState.deviceModelId;\n\n // If device is not ready or app is unexpected, checker cannot be successful\n if (deviceState.sessionStateType === DeviceSessionStateType.Connected) {\n this.isCompatible = false;\n return;\n }\n if (\n deviceState.currentApp.name !== \"Ethereum\" &&\n !ETHEREUM_PLUGINS.includes(deviceState.currentApp.name)\n ) {\n this.isCompatible = false;\n return;\n }\n if (deviceState.currentApp.name === \"Ethereum\") {\n this.version = deviceState.currentApp.version;\n } else {\n // Fallback on appConfig version if a plugin is running.\n // It won't contain release candidate suffix but it should be enough for that edge case.\n this.version = appConfig.version;\n }\n }\n\n withMinVersionInclusive(version: string): ApplicationChecker {\n if (!gte(this.version, version)) {\n this.isCompatible = false;\n }\n return this;\n }\n\n withMinVersionExclusive(version: string): ApplicationChecker {\n if (!gt(this.version, version)) {\n this.isCompatible = false;\n }\n return this;\n }\n\n excludeDeviceModel(modelId: DeviceModelId): ApplicationChecker {\n if (this.modelId === modelId) {\n this.isCompatible = false;\n }\n return this;\n }\n\n check(): boolean {\n return this.isCompatible;\n }\n}\n"],
|
|
5
|
+
"mappings": "AAAA,OAGE,0BAAAA,MACK,kCACP,OAAS,MAAAC,EAAI,OAAAC,MAAW,SAGxB,OAAS,oBAAAC,MAAwB,wCAE1B,MAAMC,CAAmB,CACtB,aAAwB,GACxB,QAAkB,QAClB,QAER,YACEC,EACAC,EACA,CAIA,GAHA,KAAK,QAAUD,EAAY,cAGvBA,EAAY,mBAAqBL,EAAuB,UAAW,CACrE,KAAK,aAAe,GACpB,MACF,CACA,GACEK,EAAY,WAAW,OAAS,YAChC,CAACF,EAAiB,SAASE,EAAY,WAAW,IAAI,EACtD,CACA,KAAK,aAAe,GACpB,MACF,CACIA,EAAY,WAAW,OAAS,WAClC,KAAK,QAAUA,EAAY,WAAW,QAItC,KAAK,QAAUC,EAAU,OAE7B,CAEA,wBAAwBC,EAAqC,CAC3D,OAAKL,EAAI,KAAK,QAASK,CAAO,IAC5B,KAAK,aAAe,IAEf,IACT,CAEA,wBAAwBA,EAAqC,CAC3D,OAAKN,EAAG,KAAK,QAASM,CAAO,IAC3B,KAAK,aAAe,IAEf,IACT,CAEA,mBAAmBC,EAA4C,CAC7D,OAAI,KAAK,UAAYA,IACnB,KAAK,aAAe,IAEf,IACT,CAEA,OAAiB,CACf,OAAO,KAAK,YACd,CACF",
|
|
6
|
+
"names": ["DeviceSessionStateType", "gt", "gte", "ETHEREUM_PLUGINS", "ApplicationChecker", "deviceState", "appConfig", "version", "modelId"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{DeviceModelId as c,DeviceSessionStateType as
|
|
1
|
+
import{DeviceModelId as c,DeviceSessionStateType as i,DeviceStatus as o}from"@ledgerhq/device-management-kit";import{ApplicationChecker as l}from"./ApplicationChecker";describe("ApplicationChecker",()=>{function s(e){return{blindSigningEnabled:!1,web3ChecksEnabled:!1,web3ChecksOptIn:!1,version:e}}it("should pass the check for exclusive version",()=>{const e={sessionStateType:i.ReadyWithoutSecureChannel,deviceStatus:o.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.13.0-rc"},deviceModelId:c.FLEX,isSecureConnectionAllowed:!1},t=s("1.13.0"),n=new l(e,t).withMinVersionExclusive("1.12.0").check();expect(n).toStrictEqual(!0)}),it("should reject the check for exclusive version",()=>{const e={sessionStateType:i.ReadyWithoutSecureChannel,deviceStatus:o.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:c.FLEX,isSecureConnectionAllowed:!1},t=s("1.12.0"),n=new l(e,t).withMinVersionExclusive("1.12.0").check();expect(n).toStrictEqual(!1)}),it("should pass the check for inclusive version",()=>{const e={sessionStateType:i.ReadyWithoutSecureChannel,deviceStatus:o.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:c.FLEX,isSecureConnectionAllowed:!1},t=s("1.10.0"),n=new l(e,t).withMinVersionInclusive("1.12.0").check();expect(n).toStrictEqual(!0)}),it("should reject the check for inclusive version",()=>{const e={sessionStateType:i.ReadyWithoutSecureChannel,deviceStatus:o.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.11.0"},deviceModelId:c.FLEX,isSecureConnectionAllowed:!1},t=s("1.11.0"),n=new l(e,t).withMinVersionInclusive("1.12.0").check();expect(n).toStrictEqual(!1)}),it("should pass the check for excluded device",()=>{const e={sessionStateType:i.ReadyWithoutSecureChannel,deviceStatus:o.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.11.0"},deviceModelId:c.FLEX,isSecureConnectionAllowed:!1},t=s("1.11.0"),n=new l(e,t).excludeDeviceModel(c.NANO_S).check();expect(n).toStrictEqual(!0)}),it("should reject the check for excluded device",()=>{const e={sessionStateType:i.ReadyWithoutSecureChannel,deviceStatus:o.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.11.0"},deviceModelId:c.FLEX,isSecureConnectionAllowed:!1},t=s("1.11.0"),n=new l(e,t).excludeDeviceModel(c.FLEX).check();expect(n).toStrictEqual(!1)}),it("should pass the check for chained condition",()=>{const e={sessionStateType:i.ReadyWithoutSecureChannel,deviceStatus:o.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.11.0"},deviceModelId:c.FLEX,isSecureConnectionAllowed:!1},t=s("1.11.0"),n=new l(e,t).withMinVersionInclusive("1.11.0").excludeDeviceModel(c.NANO_S).check();expect(n).toStrictEqual(!0)}),it("should reject the check for chained condition",()=>{const e={sessionStateType:i.ReadyWithoutSecureChannel,deviceStatus:o.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.10.0"},deviceModelId:c.FLEX,isSecureConnectionAllowed:!1},t=s("1.10.0"),n=new l(e,t).withMinVersionInclusive("1.11.0").excludeDeviceModel(c.NANO_S).check();expect(n).toStrictEqual(!1)}),it("should pass the check in plugins",()=>{const e={sessionStateType:i.ReadyWithoutSecureChannel,deviceStatus:o.CONNECTED,installedApps:[],currentApp:{name:"1inch",version:"1.11.0-rc"},deviceModelId:c.FLEX,isSecureConnectionAllowed:!1},t=s("1.13.0"),n=new l(e,t).withMinVersionExclusive("1.12.0").check();expect(n).toStrictEqual(!0)}),it("should reject the check in unknexpected app",()=>{const e={sessionStateType:i.ReadyWithoutSecureChannel,deviceStatus:o.CONNECTED,installedApps:[],currentApp:{name:"Bitcoin",version:"1.13.0-rc"},deviceModelId:c.FLEX,isSecureConnectionAllowed:!1},t=s("1.13.0"),n=new l(e,t).withMinVersionExclusive("1.12.0").check();expect(n).toStrictEqual(!1)}),it("should reject the check in unknexpected state",()=>{const e={sessionStateType:i.Connected,deviceStatus:o.CONNECTED,installedApps:[],currentApp:{name:"Bitcoin",version:"1.13.0-rc"},deviceModelId:c.FLEX,isSecureConnectionAllowed:!1},t=s("1.13.0"),n=new l(e,t).withMinVersionExclusive("1.12.0").check();expect(n).toStrictEqual(!1)})});
|
|
2
2
|
//# sourceMappingURL=ApplicationChecker.test.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/internal/shared/utils/ApplicationChecker.test.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n DeviceModelId,\n DeviceSessionStateType,\n DeviceStatus,\n} from \"@ledgerhq/device-management-kit\";\n\nimport { ApplicationChecker } from \"./ApplicationChecker\";\n\ndescribe(\"ApplicationChecker\", () => {\n it(\"should pass the check for exclusive version\", () => {\n // GIVEN\n const state = {\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.13.0-rc\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n };\n // WHEN\n const result = new ApplicationChecker(state)\n .withMinVersionExclusive(\"1.12.0\")\n .check();\n // THEN\n expect(result).toStrictEqual(true);\n });\n\n it(\"should reject the check for exclusive version\", () => {\n // GIVEN\n const state = {\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.12.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n };\n // WHEN\n const result = new ApplicationChecker(state)\n .withMinVersionExclusive(\"1.12.0\")\n .check();\n // THEN\n expect(result).toStrictEqual(false);\n });\n\n it(\"should pass the check for inclusive version\", () => {\n // GIVEN\n const state = {\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.12.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n };\n // WHEN\n const result = new ApplicationChecker(state)\n .withMinVersionInclusive(\"1.12.0\")\n .check();\n // THEN\n expect(result).toStrictEqual(true);\n });\n\n it(\"should reject the check for inclusive version\", () => {\n // GIVEN\n const state = {\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.11.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n };\n // WHEN\n const result = new ApplicationChecker(state)\n .withMinVersionInclusive(\"1.12.0\")\n .check();\n // THEN\n expect(result).toStrictEqual(false);\n });\n\n it(\"should pass the check for excluded device\", () => {\n // GIVEN\n const state = {\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.11.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n };\n // WHEN\n const result = new ApplicationChecker(state)\n .excludeDeviceModel(DeviceModelId.NANO_S)\n .check();\n // THEN\n expect(result).toStrictEqual(true);\n });\n\n it(\"should reject the check for excluded device\", () => {\n // GIVEN\n const state = {\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.11.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n };\n // WHEN\n const result = new ApplicationChecker(state)\n .excludeDeviceModel(DeviceModelId.FLEX)\n .check();\n // THEN\n expect(result).toStrictEqual(false);\n });\n\n it(\"should pass the check for chained condition\", () => {\n // GIVEN\n const state = {\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.11.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n };\n // WHEN\n const result = new ApplicationChecker(state)\n .withMinVersionInclusive(\"1.11.0\")\n .excludeDeviceModel(DeviceModelId.NANO_S)\n .check();\n // THEN\n expect(result).toStrictEqual(true);\n });\n\n it(\"should reject the check for chained condition\", () => {\n // GIVEN\n const state = {\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.10.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n };\n // WHEN\n const result = new ApplicationChecker(state)\n .withMinVersionInclusive(\"1.11.0\")\n .excludeDeviceModel(DeviceModelId.NANO_S)\n .check();\n // THEN\n expect(result).toStrictEqual(false);\n });\n\n it(\"should pass the check in plugins\", () => {\n // GIVEN\n const state = {\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"1inch\", version: \"1.
|
|
5
|
-
"mappings": "AAAA,OACE,iBAAAA,EACA,0BAAAC,EACA,gBAAAC,MACK,
|
|
6
|
-
"names": ["DeviceModelId", "DeviceSessionStateType", "DeviceStatus", "ApplicationChecker", "state", "result"]
|
|
4
|
+
"sourcesContent": ["import {\n DeviceModelId,\n DeviceSessionStateType,\n DeviceStatus,\n} from \"@ledgerhq/device-management-kit\";\n\nimport type { GetConfigCommandResponse } from \"@api/app-binder/GetConfigCommandTypes\";\n\nimport { ApplicationChecker } from \"./ApplicationChecker\";\n\ndescribe(\"ApplicationChecker\", () => {\n function createAppConfig(version: string): GetConfigCommandResponse {\n return {\n blindSigningEnabled: false,\n web3ChecksEnabled: false,\n web3ChecksOptIn: false,\n version,\n };\n }\n\n it(\"should pass the check for exclusive version\", () => {\n // GIVEN\n const state = {\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.13.0-rc\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n };\n const config = createAppConfig(\"1.13.0\");\n // WHEN\n const result = new ApplicationChecker(state, config)\n .withMinVersionExclusive(\"1.12.0\")\n .check();\n // THEN\n expect(result).toStrictEqual(true);\n });\n\n it(\"should reject the check for exclusive version\", () => {\n // GIVEN\n const state = {\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.12.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n };\n const config = createAppConfig(\"1.12.0\");\n // WHEN\n const result = new ApplicationChecker(state, config)\n .withMinVersionExclusive(\"1.12.0\")\n .check();\n // THEN\n expect(result).toStrictEqual(false);\n });\n\n it(\"should pass the check for inclusive version\", () => {\n // GIVEN\n const state = {\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.12.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n };\n const config = createAppConfig(\"1.10.0\");\n // WHEN\n const result = new ApplicationChecker(state, config)\n .withMinVersionInclusive(\"1.12.0\")\n .check();\n // THEN\n expect(result).toStrictEqual(true);\n });\n\n it(\"should reject the check for inclusive version\", () => {\n // GIVEN\n const state = {\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.11.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n };\n const config = createAppConfig(\"1.11.0\");\n // WHEN\n const result = new ApplicationChecker(state, config)\n .withMinVersionInclusive(\"1.12.0\")\n .check();\n // THEN\n expect(result).toStrictEqual(false);\n });\n\n it(\"should pass the check for excluded device\", () => {\n // GIVEN\n const state = {\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.11.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n };\n const config = createAppConfig(\"1.11.0\");\n // WHEN\n const result = new ApplicationChecker(state, config)\n .excludeDeviceModel(DeviceModelId.NANO_S)\n .check();\n // THEN\n expect(result).toStrictEqual(true);\n });\n\n it(\"should reject the check for excluded device\", () => {\n // GIVEN\n const state = {\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.11.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n };\n const config = createAppConfig(\"1.11.0\");\n // WHEN\n const result = new ApplicationChecker(state, config)\n .excludeDeviceModel(DeviceModelId.FLEX)\n .check();\n // THEN\n expect(result).toStrictEqual(false);\n });\n\n it(\"should pass the check for chained condition\", () => {\n // GIVEN\n const state = {\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.11.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n };\n const config = createAppConfig(\"1.11.0\");\n // WHEN\n const result = new ApplicationChecker(state, config)\n .withMinVersionInclusive(\"1.11.0\")\n .excludeDeviceModel(DeviceModelId.NANO_S)\n .check();\n // THEN\n expect(result).toStrictEqual(true);\n });\n\n it(\"should reject the check for chained condition\", () => {\n // GIVEN\n const state = {\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.10.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n };\n const config = createAppConfig(\"1.10.0\");\n // WHEN\n const result = new ApplicationChecker(state, config)\n .withMinVersionInclusive(\"1.11.0\")\n .excludeDeviceModel(DeviceModelId.NANO_S)\n .check();\n // THEN\n expect(result).toStrictEqual(false);\n });\n\n it(\"should pass the check in plugins\", () => {\n // GIVEN\n const state = {\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"1inch\", version: \"1.11.0-rc\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n };\n const config = createAppConfig(\"1.13.0\");\n // WHEN\n const result = new ApplicationChecker(state, config)\n .withMinVersionExclusive(\"1.12.0\")\n .check();\n // THEN\n expect(result).toStrictEqual(true);\n });\n\n it(\"should reject the check in unknexpected app\", () => {\n // GIVEN\n const state = {\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Bitcoin\", version: \"1.13.0-rc\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n };\n const config = createAppConfig(\"1.13.0\");\n // WHEN\n const result = new ApplicationChecker(state, config)\n .withMinVersionExclusive(\"1.12.0\")\n .check();\n // THEN\n expect(result).toStrictEqual(false);\n });\n\n it(\"should reject the check in unknexpected state\", () => {\n // GIVEN\n const state = {\n sessionStateType: DeviceSessionStateType.Connected,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Bitcoin\", version: \"1.13.0-rc\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n };\n const config = createAppConfig(\"1.13.0\");\n // WHEN\n const result = new ApplicationChecker(state, config)\n .withMinVersionExclusive(\"1.12.0\")\n .check();\n // THEN\n expect(result).toStrictEqual(false);\n });\n});\n"],
|
|
5
|
+
"mappings": "AAAA,OACE,iBAAAA,EACA,0BAAAC,EACA,gBAAAC,MACK,kCAIP,OAAS,sBAAAC,MAA0B,uBAEnC,SAAS,qBAAsB,IAAM,CACnC,SAASC,EAAgBC,EAA2C,CAClE,MAAO,CACL,oBAAqB,GACrB,kBAAmB,GACnB,gBAAiB,GACjB,QAAAA,CACF,CACF,CAEA,GAAG,8CAA+C,IAAM,CAEtD,MAAMC,EAAQ,CACZ,iBAAkBL,EAAuB,0BACzC,aAAcC,EAAa,UAC3B,cAAe,CAAC,EAChB,WAAY,CAAE,KAAM,WAAY,QAAS,WAAY,EACrD,cAAeF,EAAc,KAC7B,0BAA2B,EAC7B,EACMO,EAASH,EAAgB,QAAQ,EAEjCI,EAAS,IAAIL,EAAmBG,EAAOC,CAAM,EAChD,wBAAwB,QAAQ,EAChC,MAAM,EAET,OAAOC,CAAM,EAAE,cAAc,EAAI,CACnC,CAAC,EAED,GAAG,gDAAiD,IAAM,CAExD,MAAMF,EAAQ,CACZ,iBAAkBL,EAAuB,0BACzC,aAAcC,EAAa,UAC3B,cAAe,CAAC,EAChB,WAAY,CAAE,KAAM,WAAY,QAAS,QAAS,E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AM,QAAS,QAAS,WAAY,EAClD,cAAeF,EAAc,KAC7B,0BAA2B,EAC7B,EACMO,EAASH,EAAgB,QAAQ,EAEjCI,EAAS,IAAIL,EAAmBG,EAAOC,CAAM,EAChD,wBAAwB,QAAQ,EAChC,MAAM,EAET,OAAOC,CAAM,EAAE,cAAc,EAAI,CACnC,CAAC,EAED,GAAG,8CAA+C,IAAM,CAEtD,MAAMF,EAAQ,CACZ,iBAAkBL,EAAuB,0BACzC,aAAcC,EAAa,UAC3B,cAAe,CAAC,EAChB,WAAY,CAAE,KAAM,UAAW,QAAS,WAAY,EACpD,cAAeF,EAAc,KAC7B,0BAA2B,EAC7B,EACMO,EAASH,EAAgB,QAAQ,EAEjCI,EAAS,IAAIL,EAAmBG,EAAOC,CAAM,EAChD,wBAAwB,QAAQ,EAChC,MAAM,EAET,OAAOC,CAAM,EAAE,cAAc,EAAK,CACpC,CAAC,EAED,GAAG,gDAAiD,IAAM,CAExD,MAAMF,EAAQ,CACZ,iBAAkBL,EAAuB,UACzC,aAAcC,EAAa,UAC3B,cAAe,CAAC,EAChB,WAAY,CAAE,KAAM,UAAW,QAAS,WAAY,EACpD,cAAeF,EAAc,KAC7B,0BAA2B,EAC7B,EACMO,EAASH,EAAgB,QAAQ,EAEjCI,EAAS,IAAIL,EAAmBG,EAAOC,CAAM,EAChD,wBAAwB,QAAQ,EAChC,MAAM,EAET,OAAOC,CAAM,EAAE,cAAc,EAAK,CACpC,CAAC,CACH,CAAC",
|
|
6
|
+
"names": ["DeviceModelId", "DeviceSessionStateType", "DeviceStatus", "ApplicationChecker", "createAppConfig", "version", "state", "config", "result"]
|
|
7
7
|
}
|
package/lib/esm/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ledgerhq/device-signer-kit-ethereum",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.3",
|
|
4
4
|
"private": false,
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"exports": {
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"ts-node": "^10.9.2"
|
|
58
58
|
},
|
|
59
59
|
"peerDependencies": {
|
|
60
|
-
"@ledgerhq/context-module": "
|
|
61
|
-
"@ledgerhq/device-management-kit": "
|
|
60
|
+
"@ledgerhq/context-module": "^1.3.1",
|
|
61
|
+
"@ledgerhq/device-management-kit": "^0.6.5"
|
|
62
62
|
}
|
|
63
63
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type ClearSignContextSuccess, type ClearSignContextType, type ContextModule } from "@ledgerhq/context-module";
|
|
2
2
|
import { type CommandErrorResult, type DeviceActionState, type ExecuteDeviceActionReturnType, type OpenAppDAError, type OpenAppDARequiredInteraction, type UserInteractionRequired } from "@ledgerhq/device-management-kit";
|
|
3
|
+
import { type GetConfigCommandResponse } from "../app-binder/GetConfigCommandTypes";
|
|
3
4
|
import { type Signature } from "../model/Signature";
|
|
4
5
|
import { type TransactionOptions } from "../model/TransactionOptions";
|
|
5
6
|
import { type TransactionType } from "../model/TransactionType";
|
|
@@ -34,9 +35,8 @@ export type SignTransactionDAIntermediateValue = {
|
|
|
34
35
|
export type SignTransactionDAState = DeviceActionState<SignTransactionDAOutput, SignTransactionDAError, SignTransactionDAIntermediateValue>;
|
|
35
36
|
export type SignTransactionDAInternalState = {
|
|
36
37
|
readonly error: SignTransactionDAError | null;
|
|
38
|
+
readonly appConfig: GetConfigCommandResponse | null;
|
|
37
39
|
readonly clearSignContexts: ClearSignContextSuccess[] | GenericContext | null;
|
|
38
|
-
readonly web3ChecksOptIn: boolean;
|
|
39
|
-
readonly web3ChecksEnabled: boolean;
|
|
40
40
|
readonly web3Check: ClearSignContextSuccess<ClearSignContextType.WEB3_CHECK> | null;
|
|
41
41
|
readonly serializedTransaction: Uint8Array | null;
|
|
42
42
|
readonly chainId: number | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SignTransactionDeviceActionTypes.d.ts","sourceRo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,EAAE,kBAAkB,CAAC;CACtC,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAC9B,cAAc,GACd,kBAAkB,CAAC,aAAa,CAAC,CAAC,OAAO,CAAC,CAAC;AAE/C,KAAK,oCAAoC,GACrC,4BAA4B,GAC5B,uBAAuB,CAAC,eAAe,GACvC,uBAAuB,CAAC,eAAe,CAAC;AAE5C,MAAM,MAAM,kCAAkC,GAAG;IAC/C,uBAAuB,EAAE,oCAAoC,CAAC;IAC9D,IAAI,EAAE,qBAAqB,CAAC;CAC7B,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG,iBAAiB,CACpD,uBAAuB,EACvB,sBAAsB,EACtB,kCAAkC,CACnC,CAAC;AAEF,MAAM,MAAM,8BAA8B,GAAG;IAC3C,QAAQ,CAAC,KAAK,EAAE,sBAAsB,GAAG,IAAI,CAAC;IAC9C,QAAQ,CAAC,
|
|
1
|
+
{"version":3,"file":"SignTransactionDeviceActionTypes.d.ts","sourceRoot":"","sources":["../../../../src/api/app-binder/SignTransactionDeviceActionTypes.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,uBAAuB,EAC5B,KAAK,oBAAoB,EACzB,KAAK,aAAa,EACnB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACtB,KAAK,6BAA6B,EAClC,KAAK,cAAc,EACnB,KAAK,4BAA4B,EACjC,KAAK,uBAAuB,EAC7B,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EAAE,KAAK,wBAAwB,EAAE,MAAM,uCAAuC,CAAC;AACtF,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,KAAK,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACxE,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,iDAAiD,CAAC;AACrF,OAAO,EAAE,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wB,GAAG,IAAI,CAAC;IACpD,QAAQ,CAAC,iBAAiB,EAAE,uBAAuB,EAAE,GAAG,cAAc,GAAG,IAAI,CAAC;IAC9E,QAAQ,CAAC,SAAS,EAAE,uBAAuB,CAAC,oBAAoB,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC;IACpF,QAAQ,CAAC,qBAAqB,EAAE,UAAU,GAAG,IAAI,CAAC;IAClD,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,QAAQ,CAAC,eAAe,EAAE,eAAe,GAAG,IAAI,CAAC;IACjD,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,SAAS,EAAE,SAAS,GAAG,IAAI,CAAC;CACtC,CAAC;AAEF,MAAM,MAAM,2BAA2B,GAAG,6BAA6B,CACrE,uBAAuB,EACvB,sBAAsB,EACtB,kCAAkC,CACnC,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type ContextModule } from "@ledgerhq/context-module";
|
|
2
2
|
import { type CommandErrorResult, type DeviceActionState, type ExecuteDeviceActionReturnType, type OpenAppDAError, type OpenAppDARequiredInteraction, type UserInteractionRequired } from "@ledgerhq/device-management-kit";
|
|
3
|
+
import { type GetConfigCommandResponse } from "../app-binder/GetConfigCommandTypes";
|
|
3
4
|
import { type Signature } from "../model/Signature";
|
|
4
5
|
import { type TypedData } from "../model/TypedData";
|
|
5
6
|
import { type EthErrorCodes } from "../../internal/app-binder/command/utils/ethAppErrors";
|
|
@@ -31,8 +32,7 @@ export type SignTypedDataDAIntermediateValue = {
|
|
|
31
32
|
export type SignTypedDataDAState = DeviceActionState<SignTypedDataDAOutput, SignTypedDataDAError, SignTypedDataDAIntermediateValue>;
|
|
32
33
|
export type SignTypedDataDAInternalState = {
|
|
33
34
|
readonly error: SignTypedDataDAError | null;
|
|
34
|
-
|
|
35
|
-
web3ChecksEnabled: boolean;
|
|
35
|
+
readonly appConfig: GetConfigCommandResponse | null;
|
|
36
36
|
readonly typedDataContext: ProvideEIP712ContextTaskArgs | null;
|
|
37
37
|
readonly signature: Signature | null;
|
|
38
38
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SignTypedDataDeviceActionTypes.d.ts","sourceRoot":"","sources":["../../../../src/api/app-binder/SignTypedDataDeviceActionTypes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACtB,KAAK,6BAA6B,EAClC,KAAK,cAAc,EACnB,KAAK,4BAA4B,EACjC,KAAK,uBAAuB,EAC7B,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,iDAAiD,CAAC;AACrF,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,oDAAoD,CAAC;AACvG,OAAO,EAAE,KAAK,sBAAsB,EAAE,MAAM,qDAAqD,CAAC;AAElG,oBAAY,wBAAwB;IAClC,QAAQ,6BAA6B;IACrC,cAAc,kCAAkC;IAChD,kBAAkB,qCAAqC;IACvD,aAAa,kCAAkC;IAC/C,eAAe,oCAAoC;IACnD,uBAAuB,2CAA2C;IAClE,eAAe,mCAAmC;IAClD,sBAAsB,yCAAyC;CAChE;AAED,MAAM,MAAM,qBAAqB,GAAG,SAAS,CAAC;AAE9C,MAAM,MAAM,oBAAoB,GAAG;IACjC,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB,QAAQ,CAAC,MAAM,EAAE,sBAAsB,CAAC;IACxC,QAAQ,CAAC,aAAa,EAAE,aAAa,CAAC;CACvC,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAC5B,cAAc,GACd,kBAAkB,CAAC,aAAa,CAAC,CAAC,OAAO,CAAC,CAAC;AAE/C,KAAK,kCAAkC,GACnC,4BAA4B,GAC5B,uBAAuB,CAAC,eAAe,GACvC,uBAAuB,CAAC,aAAa,CAAC;AAE1C,MAAM,MAAM,gCAAgC,GAAG;IAC7C,uBAAuB,EAAE,kCAAkC,CAAC;IAC5D,IAAI,EAAE,wBAAwB,CAAC;CAChC,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG,iBAAiB,CAClD,qBAAqB,EACrB,oBAAoB,EACpB,gCAAgC,CACjC,CAAC;AAEF,MAAM,MAAM,4BAA4B,GAAG;IACzC,QAAQ,CAAC,KAAK,EAAE,oBAAoB,GAAG,IAAI,CAAC;IAC5C,
|
|
1
|
+
{"version":3,"file":"SignTypedDataDeviceActionTypes.d.ts","sourceRoot":"","sources":["../../../../src/api/app-binder/SignTypedDataDeviceActionTypes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACtB,KAAK,6BAA6B,EAClC,KAAK,cAAc,EACnB,KAAK,4BAA4B,EACjC,KAAK,uBAAuB,EAC7B,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EAAE,KAAK,wBAAwB,EAAE,MAAM,uCAAuC,CAAC;AACtF,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,iDAAiD,CAAC;AACrF,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,oDAAoD,CAAC;AACvG,OAAO,EAAE,KAAK,sBAAsB,EAAE,MAAM,qDAAqD,CAAC;AAElG,oBAAY,wBAAwB;IAClC,QAAQ,6BAA6B;IACrC,cAAc,kCAAkC;IAChD,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HANGED
|
@@ -21,7 +21,7 @@ export type MachineDependencies = {
|
|
|
21
21
|
mapper: TransactionMapperService;
|
|
22
22
|
transaction: Uint8Array;
|
|
23
23
|
options: TransactionOptions;
|
|
24
|
-
|
|
24
|
+
appConfig: GetConfigCommandResponse;
|
|
25
25
|
derivationPath: string;
|
|
26
26
|
};
|
|
27
27
|
}) => Promise<BuildTransactionTaskResult>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SignTransactionDeviceAction.d.ts","sourceRoot":"","sources":["../../../../../../src/internal/app-binder/device-action/SignTransaction/SignTransactionDeviceAction.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,uBAAuB,EAC5B,KAAK,oBAAoB,EACzB,KAAK,aAAa,EACnB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,aAAa,EAClB,KAAK,wBAAwB,EAE7B,KAAK,WAAW,EAMhB,kBAAkB,EACnB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAQ,KAAK,KAAK,EAAS,MAAM,WAAW,CAAC;AAGpD,OAAO,EAAE,KAAK,wBAAwB,EAAE,MAAM,uCAAuC,CAAC;AACtF,OAAO,EACL,KAAK,sBAAsB,EAC3B,KAAK,sBAAsB,EAC3B,KAAK,kCAAkC,EACvC,KAAK,8BAA8B,EACnC,KAAK,uBAAuB,EAE7B,MAAM,kDAAkD,CAAC;AAC1D,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,KAAK,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACxE,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAElE,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,iDAAiD,CAAC;AACrF,OAAO,EAEL,KAAK,6BAA6B,EACnC,MAAM,oDAAoD,CAAC;AAE5D,OAAO,EAGL,KAAK,0BAA0B,EAChC,MAAM,uDAAuD,CAAC;AAE/D,OAAO,EACL,KAAK,cAAc,EAEnB,KAAK,8CAA8C,EACpD,MAAM,gEAAgE,CAAC;AAGxE,OAAO,EAAE,KAAK,wBAAwB,EAAE,MAAM,+DAA+D,CAAC;AAC9G,OAAO,EAAE,KAAK,wBAAwB,EAAE,MAAM,+DAA+D,CAAC;AAE9G,MAAM,MAAM,mBAAmB,GAAG;IAChC,QAAQ,CAAC,YAAY,EAAE,MAAM,OAAO,CAClC,aAAa,CAAC,wBAAwB,EAAE,aAAa,CAAC,CACvD,CAAC;IACF,QAAQ,CAAC,cAAc,EAAE,MAAM,OAAO,CACpC,aAAa,CAAC,6BAA6B,EAAE,aAAa,CAAC,CAC5D,CAAC;IACF,QAAQ,CAAC,YAAY,EAAE,CAAC,IAAI,EAAE;QAC5B,KAAK,EAAE;YACL,aAAa,EAAE,aAAa,CAAC;YAC7B,MAAM,EAAE,wBAAwB,CAAC;YACjC,WAAW,EAAE,UAAU,CAAC;YACxB,OAAO,EAAE,kBAAkB,CAAC;YAC5B,
|
|
1
|
+
{"version":3,"file":"SignTransactionDeviceAction.d.ts","sourceRoot":"","sources":["../../../../../../src/internal/app-binder/device-action/SignTransaction/SignTransactionDeviceAction.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,uBAAuB,EAC5B,KAAK,oBAAoB,EACzB,KAAK,aAAa,EACnB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,aAAa,EAClB,KAAK,wBAAwB,EAE7B,KAAK,WAAW,EAMhB,kBAAkB,EACnB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAQ,KAAK,KAAK,EAAS,MAAM,WAAW,CAAC;AAGpD,OAAO,EAAE,KAAK,wBAAwB,EAAE,MAAM,uCAAuC,CAAC;AACtF,OAAO,EACL,KAAK,sBAAsB,EAC3B,KAAK,sBAAsB,EAC3B,KAAK,kCAAkC,EACvC,KAAK,8BAA8B,EACnC,KAAK,uBAAuB,EAE7B,MAAM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