@ledgerhq/device-signer-kit-ethereum 0.0.0-io-revamp-20250630132403 → 0.0.0-io-revamp-20250630133506

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (155) hide show
  1. package/README.md +0 -53
  2. package/lib/cjs/api/SignerEth.js +1 -1
  3. package/lib/cjs/api/SignerEth.js.map +1 -1
  4. package/lib/cjs/api/index.js +1 -1
  5. package/lib/cjs/api/index.js.map +2 -2
  6. package/lib/cjs/internal/DefaultSignerEth.js +1 -1
  7. package/lib/cjs/internal/DefaultSignerEth.js.map +3 -3
  8. package/lib/cjs/internal/DefaultSignerEth.test.js +1 -1
  9. package/lib/cjs/internal/DefaultSignerEth.test.js.map +3 -3
  10. package/lib/cjs/internal/address/di/addressModule.js +1 -1
  11. package/lib/cjs/internal/address/di/addressModule.js.map +3 -3
  12. package/lib/cjs/internal/address/di/addressModule.test.js +1 -1
  13. package/lib/cjs/internal/address/di/addressModule.test.js.map +2 -2
  14. package/lib/cjs/internal/app-binder/EthAppBinder.js +1 -1
  15. package/lib/cjs/internal/app-binder/EthAppBinder.js.map +3 -3
  16. package/lib/cjs/internal/app-binder/EthAppBinder.test.js +1 -1
  17. package/lib/cjs/internal/app-binder/EthAppBinder.test.js.map +3 -3
  18. package/lib/cjs/internal/app-binder/device-action/SignTransaction/SignTransactionDeviceAction.js +1 -1
  19. package/lib/cjs/internal/app-binder/device-action/SignTransaction/SignTransactionDeviceAction.js.map +3 -3
  20. package/lib/cjs/internal/app-binder/device-action/SignTypedData/SignTypedDataDeviceAction.js +1 -1
  21. package/lib/cjs/internal/app-binder/device-action/SignTypedData/SignTypedDataDeviceAction.js.map +3 -3
  22. package/lib/cjs/internal/app-binder/di/appBinderModule.js +1 -1
  23. package/lib/cjs/internal/app-binder/di/appBinderModule.js.map +3 -3
  24. package/lib/cjs/internal/di.js +1 -1
  25. package/lib/cjs/internal/di.js.map +3 -3
  26. package/lib/cjs/internal/message/di/messageModule.js +1 -1
  27. package/lib/cjs/internal/message/di/messageModule.js.map +3 -3
  28. package/lib/cjs/internal/message/di/messageModule.test.js +1 -1
  29. package/lib/cjs/internal/message/di/messageModule.test.js.map +2 -2
  30. package/lib/cjs/internal/transaction/di/transactionModule.js +1 -1
  31. package/lib/cjs/internal/transaction/di/transactionModule.js.map +3 -3
  32. package/lib/cjs/internal/transaction/di/transactionModule.test.js +1 -1
  33. package/lib/cjs/internal/transaction/di/transactionModule.test.js.map +2 -2
  34. package/lib/cjs/internal/typed-data/di/typedDataModule.js +1 -1
  35. package/lib/cjs/internal/typed-data/di/typedDataModule.js.map +3 -3
  36. package/lib/cjs/internal/typed-data/di/typedDataModule.test.js +1 -1
  37. package/lib/cjs/internal/typed-data/di/typedDataModule.test.js.map +2 -2
  38. package/lib/cjs/package.json +4 -3
  39. package/lib/esm/api/index.js +1 -1
  40. package/lib/esm/api/index.js.map +2 -2
  41. package/lib/esm/internal/DefaultSignerEth.js +1 -1
  42. package/lib/esm/internal/DefaultSignerEth.js.map +3 -3
  43. package/lib/esm/internal/DefaultSignerEth.test.js +1 -1
  44. package/lib/esm/internal/DefaultSignerEth.test.js.map +3 -3
  45. package/lib/esm/internal/address/di/addressModule.js +1 -1
  46. package/lib/esm/internal/address/di/addressModule.js.map +3 -3
  47. package/lib/esm/internal/address/di/addressModule.test.js +1 -1
  48. package/lib/esm/internal/address/di/addressModule.test.js.map +2 -2
  49. package/lib/esm/internal/app-binder/EthAppBinder.js +1 -1
  50. package/lib/esm/internal/app-binder/EthAppBinder.js.map +3 -3
  51. package/lib/esm/internal/app-binder/EthAppBinder.test.js +1 -1
  52. package/lib/esm/internal/app-binder/EthAppBinder.test.js.map +3 -3
  53. package/lib/esm/internal/app-binder/device-action/SignTransaction/SignTransactionDeviceAction.js +1 -1
  54. package/lib/esm/internal/app-binder/device-action/SignTransaction/SignTransactionDeviceAction.js.map +3 -3
  55. package/lib/esm/internal/app-binder/device-action/SignTypedData/SignTypedDataDeviceAction.js +1 -1
  56. package/lib/esm/internal/app-binder/device-action/SignTypedData/SignTypedDataDeviceAction.js.map +3 -3
  57. package/lib/esm/internal/app-binder/di/appBinderModule.js +1 -1
  58. package/lib/esm/internal/app-binder/di/appBinderModule.js.map +3 -3
  59. package/lib/esm/internal/di.js +1 -1
  60. package/lib/esm/internal/di.js.map +3 -3
  61. package/lib/esm/internal/message/di/messageModule.js +1 -1
  62. package/lib/esm/internal/message/di/messageModule.js.map +3 -3
  63. package/lib/esm/internal/message/di/messageModule.test.js +1 -1
  64. package/lib/esm/internal/message/di/messageModule.test.js.map +2 -2
  65. package/lib/esm/internal/transaction/di/transactionModule.js +1 -1
  66. package/lib/esm/internal/transaction/di/transactionModule.js.map +3 -3
  67. package/lib/esm/internal/transaction/di/transactionModule.test.js +1 -1
  68. package/lib/esm/internal/transaction/di/transactionModule.test.js.map +2 -2
  69. package/lib/esm/internal/typed-data/di/typedDataModule.js +1 -1
  70. package/lib/esm/internal/typed-data/di/typedDataModule.js.map +3 -3
  71. package/lib/esm/internal/typed-data/di/typedDataModule.test.js +1 -1
  72. package/lib/esm/internal/typed-data/di/typedDataModule.test.js.map +2 -2
  73. package/lib/esm/package.json +4 -3
  74. package/lib/types/api/SignerEth.d.ts +2 -4
  75. package/lib/types/api/SignerEth.d.ts.map +1 -1
  76. package/lib/types/api/index.d.ts +0 -5
  77. package/lib/types/api/index.d.ts.map +1 -1
  78. package/lib/types/internal/DefaultSignerEth.d.ts +0 -2
  79. package/lib/types/internal/DefaultSignerEth.d.ts.map +1 -1
  80. package/lib/types/internal/address/di/addressModule.d.ts.map +1 -1
  81. package/lib/types/internal/app-binder/EthAppBinder.d.ts +0 -7
  82. package/lib/types/internal/app-binder/EthAppBinder.d.ts.map +1 -1
  83. package/lib/types/internal/app-binder/command/utils/ethAppErrors.d.ts.map +1 -1
  84. package/lib/types/internal/app-binder/device-action/SignTransaction/SignTransactionDeviceAction.d.ts.map +1 -1
  85. package/lib/types/internal/app-binder/device-action/SignTypedData/SignTypedDataDeviceAction.d.ts.map +1 -1
  86. package/lib/types/internal/app-binder/device-action/__test-utils__/setupOpenAppDAMock.d.ts.map +1 -1
  87. package/lib/types/internal/app-binder/di/appBinderModule.d.ts.map +1 -1
  88. package/lib/types/internal/app-binder/task/BuildEIP712ContextTask.d.ts.map +1 -1
  89. package/lib/types/internal/app-binder/task/BuildTransactionContextTask.d.ts.map +1 -1
  90. package/lib/types/internal/di.d.ts.map +1 -1
  91. package/lib/types/internal/message/di/messageModule.d.ts.map +1 -1
  92. package/lib/types/internal/transaction/di/transactionModule.d.ts.map +1 -1
  93. package/lib/types/internal/typed-data/di/typedDataModule.d.ts.map +1 -1
  94. package/lib/types/tsconfig.prod.tsbuildinfo +1 -1
  95. package/package.json +9 -8
  96. package/lib/cjs/api/app-binder/SignDelegationAuthorizationTypes.js +0 -2
  97. package/lib/cjs/api/app-binder/SignDelegationAuthorizationTypes.js.map +0 -7
  98. package/lib/cjs/internal/app-binder/command/SignAuthorizationDelegationCommand.js +0 -2
  99. package/lib/cjs/internal/app-binder/command/SignAuthorizationDelegationCommand.js.map +0 -7
  100. package/lib/cjs/internal/app-binder/command/SignAuthorizationDelegationCommand.test.js +0 -2
  101. package/lib/cjs/internal/app-binder/command/SignAuthorizationDelegationCommand.test.js.map +0 -7
  102. package/lib/cjs/internal/app-binder/task/SendSignAuthorizationDelegationTask.js +0 -2
  103. package/lib/cjs/internal/app-binder/task/SendSignAuthorizationDelegationTask.js.map +0 -7
  104. package/lib/cjs/internal/app-binder/task/SendSignAuthorizationDelegationTask.test.js +0 -2
  105. package/lib/cjs/internal/app-binder/task/SendSignAuthorizationDelegationTask.test.js.map +0 -7
  106. package/lib/cjs/internal/eip7702/di/eip7702Module.js +0 -2
  107. package/lib/cjs/internal/eip7702/di/eip7702Module.js.map +0 -7
  108. package/lib/cjs/internal/eip7702/di/eip7702Module.test.js +0 -2
  109. package/lib/cjs/internal/eip7702/di/eip7702Module.test.js.map +0 -7
  110. package/lib/cjs/internal/eip7702/di/eip7702Types.js +0 -2
  111. package/lib/cjs/internal/eip7702/di/eip7702Types.js.map +0 -7
  112. package/lib/cjs/internal/eip7702/use-case/SignDelegationAuthorizationUseCase.js +0 -2
  113. package/lib/cjs/internal/eip7702/use-case/SignDelegationAuthorizationUseCase.js.map +0 -7
  114. package/lib/cjs/internal/eip7702/use-case/SignDelegationAuthorizationUseCase.test.js +0 -2
  115. package/lib/cjs/internal/eip7702/use-case/SignDelegationAuthorizationUseCase.test.js.map +0 -7
  116. package/lib/esm/api/app-binder/SignDelegationAuthorizationTypes.js +0 -1
  117. package/lib/esm/api/app-binder/SignDelegationAuthorizationTypes.js.map +0 -7
  118. package/lib/esm/internal/app-binder/command/SignAuthorizationDelegationCommand.js +0 -2
  119. package/lib/esm/internal/app-binder/command/SignAuthorizationDelegationCommand.js.map +0 -7
  120. package/lib/esm/internal/app-binder/command/SignAuthorizationDelegationCommand.test.js +0 -2
  121. package/lib/esm/internal/app-binder/command/SignAuthorizationDelegationCommand.test.js.map +0 -7
  122. package/lib/esm/internal/app-binder/task/SendSignAuthorizationDelegationTask.js +0 -2
  123. package/lib/esm/internal/app-binder/task/SendSignAuthorizationDelegationTask.js.map +0 -7
  124. package/lib/esm/internal/app-binder/task/SendSignAuthorizationDelegationTask.test.js +0 -2
  125. package/lib/esm/internal/app-binder/task/SendSignAuthorizationDelegationTask.test.js.map +0 -7
  126. package/lib/esm/internal/eip7702/di/eip7702Module.js +0 -2
  127. package/lib/esm/internal/eip7702/di/eip7702Module.js.map +0 -7
  128. package/lib/esm/internal/eip7702/di/eip7702Module.test.js +0 -2
  129. package/lib/esm/internal/eip7702/di/eip7702Module.test.js.map +0 -7
  130. package/lib/esm/internal/eip7702/di/eip7702Types.js +0 -2
  131. package/lib/esm/internal/eip7702/di/eip7702Types.js.map +0 -7
  132. package/lib/esm/internal/eip7702/use-case/SignDelegationAuthorizationUseCase.js +0 -2
  133. package/lib/esm/internal/eip7702/use-case/SignDelegationAuthorizationUseCase.js.map +0 -7
  134. package/lib/esm/internal/eip7702/use-case/SignDelegationAuthorizationUseCase.test.js +0 -2
  135. package/lib/esm/internal/eip7702/use-case/SignDelegationAuthorizationUseCase.test.js.map +0 -7
  136. package/lib/types/api/app-binder/SignDelegationAuthorizationTypes.d.ts +0 -19
  137. package/lib/types/api/app-binder/SignDelegationAuthorizationTypes.d.ts.map +0 -1
  138. package/lib/types/internal/app-binder/command/SignAuthorizationDelegationCommand.d.ts +0 -29
  139. package/lib/types/internal/app-binder/command/SignAuthorizationDelegationCommand.d.ts.map +0 -1
  140. package/lib/types/internal/app-binder/command/SignAuthorizationDelegationCommand.test.d.ts +0 -2
  141. package/lib/types/internal/app-binder/command/SignAuthorizationDelegationCommand.test.d.ts.map +0 -1
  142. package/lib/types/internal/app-binder/task/SendSignAuthorizationDelegationTask.d.ts +0 -18
  143. package/lib/types/internal/app-binder/task/SendSignAuthorizationDelegationTask.d.ts.map +0 -1
  144. package/lib/types/internal/app-binder/task/SendSignAuthorizationDelegationTask.test.d.ts +0 -2
  145. package/lib/types/internal/app-binder/task/SendSignAuthorizationDelegationTask.test.d.ts.map +0 -1
  146. package/lib/types/internal/eip7702/di/eip7702Module.d.ts +0 -3
  147. package/lib/types/internal/eip7702/di/eip7702Module.d.ts.map +0 -1
  148. package/lib/types/internal/eip7702/di/eip7702Module.test.d.ts +0 -2
  149. package/lib/types/internal/eip7702/di/eip7702Module.test.d.ts.map +0 -1
  150. package/lib/types/internal/eip7702/di/eip7702Types.d.ts +0 -4
  151. package/lib/types/internal/eip7702/di/eip7702Types.d.ts.map +0 -1
  152. package/lib/types/internal/eip7702/use-case/SignDelegationAuthorizationUseCase.d.ts +0 -8
  153. package/lib/types/internal/eip7702/use-case/SignDelegationAuthorizationUseCase.d.ts.map +0 -1
  154. package/lib/types/internal/eip7702/use-case/SignDelegationAuthorizationUseCase.test.d.ts +0 -2
  155. package/lib/types/internal/eip7702/use-case/SignDelegationAuthorizationUseCase.test.d.ts.map +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ledgerhq/device-signer-kit-ethereum",
3
- "version": "0.0.0-io-revamp-20250630132403",
3
+ "version": "0.0.0-io-revamp-20250630133506",
4
4
  "private": false,
5
5
  "license": "Apache-2.0",
6
6
  "exports": {
@@ -19,29 +19,30 @@
19
19
  "./lib"
20
20
  ],
21
21
  "dependencies": {
22
- "ethers": "6.14.1",
23
- "inversify": "7.5.1",
22
+ "ethers": "6.13.4",
23
+ "inversify": "6.2.2",
24
+ "inversify-logger-middleware": "3.1.0",
24
25
  "purify-ts": "2.1.0",
25
26
  "reflect-metadata": "0.2.2",
26
27
  "semver": "7.7.0",
27
28
  "xstate": "5.19.2",
28
- "@ledgerhq/signer-utils": "0.0.0-io-revamp-20250630132403"
29
+ "@ledgerhq/signer-utils": "1.0.5"
29
30
  },
30
31
  "devDependencies": {
31
32
  "@types/semver": "7.7.0",
32
33
  "rxjs": "^7.8.2",
33
34
  "ts-node": "10.9.2",
34
- "@ledgerhq/context-module": "0.0.0-io-revamp-20250630132403",
35
- "@ledgerhq/device-management-kit": "0.0.0-io-revamp-20250630132403",
35
+ "@ledgerhq/context-module": "1.4.0",
36
36
  "@ledgerhq/ldmk-tool": "0.0.1",
37
+ "@ledgerhq/device-management-kit": "0.0.0-io-revamp-20250630133506",
37
38
  "@ledgerhq/eslint-config-dsdk": "0.0.2",
38
39
  "@ledgerhq/prettier-config-dsdk": "0.0.2",
39
40
  "@ledgerhq/tsconfig-dsdk": "1.0.1",
40
41
  "@ledgerhq/vitest-config-dmk": "0.0.0"
41
42
  },
42
43
  "peerDependencies": {
43
- "@ledgerhq/context-module": "0.0.0-io-revamp-20250630132403",
44
- "@ledgerhq/device-management-kit": "0.0.0-io-revamp-20250630132403"
44
+ "@ledgerhq/context-module": "^1.4.0",
45
+ "@ledgerhq/device-management-kit": "^0.7.0"
45
46
  },
46
47
  "scripts": {
47
48
  "prebuild": "rimraf lib",
@@ -1,2 +0,0 @@
1
- "use strict";var n=Object.defineProperty;var a=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var u=Object.prototype.hasOwnProperty;var A=(t,e,o,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of p(e))!u.call(t,i)&&i!==o&&n(t,i,{get:()=>e[i],enumerable:!(r=a(e,i))||r.enumerable});return t};var D=t=>A(n({},"__esModule",{value:!0}),t);var g={};module.exports=D(g);
2
- //# sourceMappingURL=SignDelegationAuthorizationTypes.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../../src/api/app-binder/SignDelegationAuthorizationTypes.ts"],
4
- "sourcesContent": ["import {\n type CommandErrorResult,\n type DeviceActionState,\n type ExecuteDeviceActionReturnType,\n type OpenAppDAError,\n type OpenAppDARequiredInteraction,\n type UserInteractionRequired,\n} from \"@ledgerhq/device-management-kit\";\n\nimport { type Signature } from \"@api/model/Signature\";\nimport { type EthErrorCodes } from \"@internal/app-binder/command/utils/ethAppErrors\";\n\nexport type SignDelegationAuthorizationDAOutput = Signature;\n\nexport type SignDelegationAuthorizationDAInput = {\n readonly derivationPath: string;\n readonly address: `0x${string}`;\n readonly chainId: number;\n readonly nonce: number;\n};\n\nexport type SignDelegationAuthorizationDAError =\n | OpenAppDAError\n | CommandErrorResult<EthErrorCodes>[\"error\"];\n\ntype SignDelegationAuthorizationDARequiredInteraction =\n | OpenAppDARequiredInteraction\n | UserInteractionRequired.SignDelegationAuthorization;\n\nexport type SignDelegationAuthorizationDAIntermediateValue = {\n requiredUserInteraction: SignDelegationAuthorizationDARequiredInteraction;\n};\n\nexport type SignDelegationAuthorizationDAState = DeviceActionState<\n SignDelegationAuthorizationDAOutput,\n SignDelegationAuthorizationDAError,\n SignDelegationAuthorizationDAIntermediateValue\n>;\n\nexport type SignDelegationAuthorizationDAReturnType =\n ExecuteDeviceActionReturnType<\n SignDelegationAuthorizationDAOutput,\n SignDelegationAuthorizationDAError,\n SignDelegationAuthorizationDAIntermediateValue\n >;\n"],
5
- "mappings": "+WAAA,IAAAA,EAAA,kBAAAC,EAAAD",
6
- "names": ["SignDelegationAuthorizationTypes_exports", "__toCommonJS"]
7
- }
@@ -1,2 +0,0 @@
1
- "use strict";var d=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var g=Object.getOwnPropertyNames;var A=Object.prototype.hasOwnProperty;var E=(e,r)=>{for(var t in r)d(e,t,{get:r[t],enumerable:!0})},l=(e,r,t,i)=>{if(r&&typeof r=="object"||typeof r=="function")for(let n of g(r))!A.call(e,n)&&n!==t&&d(e,n,{get:()=>r[n],enumerable:!(i=p(r,n))||i.enumerable});return e};var h=e=>l(d({},"__esModule",{value:!0}),e);var S={};E(S,{SignEIP7702AuthorizationCommand:()=>c});module.exports=h(S);var o=require("@ledgerhq/device-management-kit"),u=require("@ledgerhq/signer-utils"),a=require("purify-ts"),s=require("./utils/ethAppErrors");const C=32,y=32;class c{args;errorHelper=new u.CommandErrorHelper(s.ETH_APP_ERRORS,s.EthAppCommandErrorFactory);constructor(r){this.args=r}getApdu(){const{data:r,isFirstChunk:t}=this.args,i={cla:224,ins:52,p1:t?1:0,p2:0};return new o.ApduBuilder(i).addBufferToData(r).build()}parseResponse(r){return a.Maybe.fromNullable(this.errorHelper.getError(r)).orDefaultLazy(()=>{const t=new o.ApduParser(r),i=t.extract8BitUInt();if(i===void 0)return(0,o.CommandResultFactory)({data:a.Nothing});const n=t.encodeToHexaString(t.extractFieldByLength(C),!0);if(!n)return(0,o.CommandResultFactory)({error:new o.InvalidStatusWordError("R is missing")});const m=t.encodeToHexaString(t.extractFieldByLength(y),!0);return m?(0,o.CommandResultFactory)({data:(0,a.Just)({r:n,s:m,v:i})}):(0,o.CommandResultFactory)({error:new o.InvalidStatusWordError("S is missing")})})}}0&&(module.exports={SignEIP7702AuthorizationCommand});
2
- //# sourceMappingURL=SignAuthorizationDelegationCommand.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../../../src/internal/app-binder/command/SignAuthorizationDelegationCommand.ts"],
4
- "sourcesContent": ["// https://github.com/LedgerHQ/app-ethereum/blob/develop/doc/ethapp.adoc#sign-eth-personal-message\nimport {\n type Apdu,\n ApduBuilder,\n type ApduBuilderArgs,\n ApduParser,\n type ApduResponse,\n type Command,\n type CommandResult,\n CommandResultFactory,\n InvalidStatusWordError,\n} from \"@ledgerhq/device-management-kit\";\nimport { CommandErrorHelper } from \"@ledgerhq/signer-utils\";\nimport { Just, Maybe, Nothing } from \"purify-ts\";\n\nimport { type Signature } from \"@api/model/Signature\";\n\nimport {\n ETH_APP_ERRORS,\n EthAppCommandErrorFactory,\n type EthErrorCodes,\n} from \"./utils/ethAppErrors\";\n\nconst R_LENGTH = 32;\nconst S_LENGTH = 32;\n\nexport type SignEIP7702AuthorizationCommandArgs = {\n /**\n * The data to sign in max 255 bytes chunks\n * Data is a concatenation of the following:\n * - Derivation path length (1 byte)\n * - Derivation path (4 bytes per element)\n * - Nonce (4 bytes)\n * - Chain ID (4 bytes)\n * - Address (20 bytes)\n */\n readonly data: Uint8Array;\n /**\n * If this is the first chunk of the message\n */\n readonly isFirstChunk: boolean;\n};\n\nexport type SignEIP7702AuthorizationCommandResponse = Maybe<Signature>;\n\nexport class SignEIP7702AuthorizationCommand\n implements\n Command<\n SignEIP7702AuthorizationCommandResponse,\n SignEIP7702AuthorizationCommandArgs,\n EthErrorCodes\n >\n{\n readonly args: SignEIP7702AuthorizationCommandArgs;\n private readonly errorHelper = new CommandErrorHelper<\n SignEIP7702AuthorizationCommandResponse,\n EthErrorCodes\n >(ETH_APP_ERRORS, EthAppCommandErrorFactory);\n\n constructor(args: SignEIP7702AuthorizationCommandArgs) {\n this.args = args;\n }\n\n getApdu(): Apdu {\n const { data, isFirstChunk } = this.args;\n const signEIP7702AuthorizationArgs: ApduBuilderArgs = {\n cla: 0xe0,\n ins: 0x34,\n p1: isFirstChunk ? 0x01 : 0x00,\n p2: 0x00,\n };\n\n return new ApduBuilder(signEIP7702AuthorizationArgs)\n .addBufferToData(data)\n .build();\n }\n\n parseResponse(\n apduResponse: ApduResponse,\n ): CommandResult<SignEIP7702AuthorizationCommandResponse, EthErrorCodes> {\n return Maybe.fromNullable(\n this.errorHelper.getError(apduResponse),\n ).orDefaultLazy(() => {\n const parser = new ApduParser(apduResponse);\n\n // The data is returned only for the last chunk\n const v = parser.extract8BitUInt();\n if (v === undefined) {\n return CommandResultFactory({ data: Nothing });\n }\n\n const r = parser.encodeToHexaString(\n parser.extractFieldByLength(R_LENGTH),\n true,\n );\n if (!r) {\n return CommandResultFactory({\n error: new InvalidStatusWordError(\"R is missing\"),\n });\n }\n\n const s = parser.encodeToHexaString(\n parser.extractFieldByLength(S_LENGTH),\n true,\n );\n if (!s) {\n return CommandResultFactory({\n error: new InvalidStatusWordError(\"S is missing\"),\n });\n }\n\n return CommandResultFactory({\n data: Just({\n r,\n s,\n v,\n }),\n });\n });\n }\n}\n"],
5
- "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,qCAAAE,IAAA,eAAAC,EAAAH,GACA,IAAAI,EAUO,2CACPC,EAAmC,kCACnCC,EAAqC,qBAIrCC,EAIO,gCAEP,MAAMC,EAAW,GACXC,EAAW,GAqBV,MAAMP,CAOb,CACW,KACQ,YAAc,IAAI,qBAGjC,iBAAgB,2BAAyB,EAE3C,YAAYQ,EAA2C,CACrD,KAAK,KAAOA,CACd,CAEA,SAAgB,CACd,KAAM,CAAE,KAAAC,EAAM,aAAAC,CAAa,EAAI,KAAK,KAC9BC,EAAgD,CACpD,IAAK,IACL,IAAK,GACL,GAAID,EAAe,EAAO,EAC1B,GAAI,CACN,EAEA,OAAO,IAAI,cAAYC,CAA4B,EAChD,gBAAgBF,CAAI,EACpB,MAAM,CACX,CAEA,cACEG,EACuE,CACvE,OAAO,QAAM,aACX,KAAK,YAAY,SAASA,CAAY,CACxC,EAAE,cAAc,IAAM,CACpB,MAAMC,EAAS,IAAI,aAAWD,CAAY,EAGpCE,EAAID,EAAO,gBAAgB,EACjC,GAAIC,IAAM,OACR,SAAO,wBAAqB,CAAE,KAAM,SAAQ,CAAC,EAG/C,MAAMC,EAAIF,EAAO,mBACfA,EAAO,qBAAqBP,CAAQ,EACpC,EACF,EACA,GAAI,CAACS,EACH,SAAO,wBAAqB,CAC1B,MAAO,IAAI,yBAAuB,cAAc,CAClD,CAAC,EAGH,MAAMC,EAAIH,EAAO,mBACfA,EAAO,qBAAqBN,CAAQ,EACpC,EACF,EACA,OAAKS,KAME,wBAAqB,CAC1B,QAAM,QAAK,CACT,EAAAD,EACA,EAAAC,EACA,EAAAF,CACF,CAAC,CACH,CAAC,KAXQ,wBAAqB,CAC1B,MAAO,IAAI,yBAAuB,cAAc,CAClD,CAAC,CAUL,CAAC,CACH,CACF",
6
- "names": ["SignAuthorizationDelegationCommand_exports", "__export", "SignEIP7702AuthorizationCommand", "__toCommonJS", "import_device_management_kit", "import_signer_utils", "import_purify_ts", "import_ethAppErrors", "R_LENGTH", "S_LENGTH", "args", "data", "isFirstChunk", "signEIP7702AuthorizationArgs", "apduResponse", "parser", "v", "r", "s"]
7
- }
@@ -1,2 +0,0 @@
1
- "use strict";var s=require("@ledgerhq/device-management-kit"),n=require("purify-ts"),r=require("./SignAuthorizationDelegationCommand");const a=Uint8Array.from([224,52,1,0,8,0,6,76,101,100,103,101,114]),c=Uint8Array.from([224,52,0,0,8,0,6,76,101,100,103,101,114]),x=new Uint8Array([27,151,164,202,143,105,70,51,89,38,1,245,162,62,11,204,85,60,157,10,144,211,163,66,45,87,85,8,169,40,152,185,110,105,80,208,46,116,233,193,2,193,100,162,37,83,48,130,202,189,216,144,239,196,99,246,127,96,206,254,140,63,135,207,206]);describe("SignEIP7702AuthorizationCommand",()=>{describe("getApdu",()=>{it("should return the first chunk raw APDU",()=>{const e={data:a.slice(5),isFirstChunk:!0},t=new r.SignEIP7702AuthorizationCommand(e).getApdu();expect(t.getRawApdu()).toStrictEqual(a)}),it("should return the next chunk raw APDU",()=>{const e={data:a.slice(5),isFirstChunk:!1},t=new r.SignEIP7702AuthorizationCommand(e).getApdu();expect(t.getRawApdu()).toStrictEqual(c)})}),describe("parseResponse",()=>{it("should return an error if the response status code is invalid",()=>{const e={data:Buffer.from([]),statusCode:Buffer.from([106,128])},t=new r.SignEIP7702AuthorizationCommand({data:Uint8Array.from([]),isFirstChunk:!0}).parseResponse(e);expect((0,s.isSuccessCommandResult)(t)).toBe(!1)}),it("should return success without result for first chunk",()=>{const e={statusCode:Buffer.from([144,0]),data:Buffer.from([])},t=new r.SignEIP7702AuthorizationCommand({data:Uint8Array.from([]),isFirstChunk:!0}).parseResponse(e);expect(t).toStrictEqual((0,s.CommandResultFactory)({data:n.Nothing}))}),it("should return success if the response signature is valid",()=>{const e={statusCode:Buffer.from([144,0]),data:x},t=new r.SignEIP7702AuthorizationCommand({data:Uint8Array.from([]),isFirstChunk:!0}).parseResponse(e);expect(t).toStrictEqual((0,s.CommandResultFactory)({data:(0,n.Just)({r:"0x97a4ca8f694633592601f5a23e0bcc553c9d0a90d3a3422d575508a92898b96e",s:"0x6950d02e74e9c102c164a225533082cabdd890efc463f67f60cefe8c3f87cfce",v:27})}))}),it("should return an error if r is missing",()=>{const e={statusCode:Buffer.from([144,0]),data:x.slice(0,32)},t=new r.SignEIP7702AuthorizationCommand({data:Uint8Array.from([]),isFirstChunk:!0}).parseResponse(e);expect(t).toStrictEqual((0,s.CommandResultFactory)({error:new s.InvalidStatusWordError("R is missing")}))}),it("should return an error if s is missing",()=>{const e={statusCode:Buffer.from([144,0]),data:x.slice(0,64)},t=new r.SignEIP7702AuthorizationCommand({data:Uint8Array.from([]),isFirstChunk:!0}).parseResponse(e);expect(t).toStrictEqual((0,s.CommandResultFactory)({error:new s.InvalidStatusWordError("S is missing")}))})})});
2
- //# sourceMappingURL=SignAuthorizationDelegationCommand.test.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../../../src/internal/app-binder/command/SignAuthorizationDelegationCommand.test.ts"],
4
- "sourcesContent": ["import {\n type ApduResponse,\n CommandResultFactory,\n InvalidStatusWordError,\n isSuccessCommandResult,\n} from \"@ledgerhq/device-management-kit\";\nimport { Just, Nothing } from \"purify-ts\";\n\nimport {\n SignEIP7702AuthorizationCommand,\n type SignEIP7702AuthorizationCommandArgs,\n} from \"./SignAuthorizationDelegationCommand\";\n\nconst FIRST_CHUNK_APDU = Uint8Array.from([\n 0xe0, 0x34, 0x01, 0x00, 0x08, 0x00, 0x06, 0x4c, 0x65, 0x64, 0x67, 0x65, 0x72,\n]);\n\nconst NEXT_CHUNK_APDU = Uint8Array.from([\n 0xe0, 0x34, 0x00, 0x00, 0x08, 0x00, 0x06, 0x4c, 0x65, 0x64, 0x67, 0x65, 0x72,\n]);\n\nconst SUCCESS_RESPONSE = new Uint8Array([\n 0x1b, 0x97, 0xa4, 0xca, 0x8f, 0x69, 0x46, 0x33, 0x59, 0x26, 0x01, 0xf5, 0xa2,\n 0x3e, 0x0b, 0xcc, 0x55, 0x3c, 0x9d, 0x0a, 0x90, 0xd3, 0xa3, 0x42, 0x2d, 0x57,\n 0x55, 0x08, 0xa9, 0x28, 0x98, 0xb9, 0x6e, 0x69, 0x50, 0xd0, 0x2e, 0x74, 0xe9,\n 0xc1, 0x02, 0xc1, 0x64, 0xa2, 0x25, 0x53, 0x30, 0x82, 0xca, 0xbd, 0xd8, 0x90,\n 0xef, 0xc4, 0x63, 0xf6, 0x7f, 0x60, 0xce, 0xfe, 0x8c, 0x3f, 0x87, 0xcf, 0xce,\n]);\n\ndescribe(\"SignEIP7702AuthorizationCommand\", () => {\n describe(\"getApdu\", () => {\n it(\"should return the first chunk raw APDU\", () => {\n // GIVEN\n const args: SignEIP7702AuthorizationCommandArgs = {\n data: FIRST_CHUNK_APDU.slice(5),\n isFirstChunk: true,\n };\n // WHEN\n const command = new SignEIP7702AuthorizationCommand(args);\n const apdu = command.getApdu();\n // THEN\n expect(apdu.getRawApdu()).toStrictEqual(FIRST_CHUNK_APDU);\n });\n\n it(\"should return the next chunk raw APDU\", () => {\n // GIVEN\n const args: SignEIP7702AuthorizationCommandArgs = {\n data: FIRST_CHUNK_APDU.slice(5),\n isFirstChunk: false,\n };\n // WHEN\n const command = new SignEIP7702AuthorizationCommand(args);\n const apdu = command.getApdu();\n // THEN\n expect(apdu.getRawApdu()).toStrictEqual(NEXT_CHUNK_APDU);\n });\n });\n\n describe(\"parseResponse\", () => {\n it(\"should return an error if the response status code is invalid\", () => {\n // GIVEN\n const response: ApduResponse = {\n data: Buffer.from([]),\n statusCode: Buffer.from([0x6a, 0x80]), // Invalid status code\n };\n // WHEN\n const command = new SignEIP7702AuthorizationCommand({\n data: Uint8Array.from([]),\n isFirstChunk: true,\n });\n const result = command.parseResponse(response);\n // THEN\n expect(isSuccessCommandResult(result)).toBe(false);\n });\n\n it(\"should return success without result for first chunk\", () => {\n // GIVEN\n const response: ApduResponse = {\n statusCode: Buffer.from([0x90, 0x00]), // Success status code\n data: Buffer.from([]),\n };\n // WHEN\n const command = new SignEIP7702AuthorizationCommand({\n data: Uint8Array.from([]),\n isFirstChunk: true,\n });\n const result = command.parseResponse(response);\n // THEN\n expect(result).toStrictEqual(\n CommandResultFactory({\n data: Nothing,\n }),\n );\n });\n\n it(\"should return success if the response signature is valid\", () => {\n // GIVEN\n const response: ApduResponse = {\n statusCode: Buffer.from([0x90, 0x00]), // Success status code\n data: SUCCESS_RESPONSE,\n };\n // WHEN\n const command = new SignEIP7702AuthorizationCommand({\n data: Uint8Array.from([]),\n isFirstChunk: true,\n });\n const result = command.parseResponse(response);\n // THEN\n expect(result).toStrictEqual(\n CommandResultFactory({\n data: Just({\n r: \"0x97a4ca8f694633592601f5a23e0bcc553c9d0a90d3a3422d575508a92898b96e\",\n s: \"0x6950d02e74e9c102c164a225533082cabdd890efc463f67f60cefe8c3f87cfce\",\n v: 27,\n }),\n }),\n );\n });\n\n it(\"should return an error if r is missing\", () => {\n // GIVEN\n const response: ApduResponse = {\n statusCode: Buffer.from([0x90, 0x00]), // Success status code\n data: SUCCESS_RESPONSE.slice(0, 32),\n };\n // WHEN\n const command = new SignEIP7702AuthorizationCommand({\n data: Uint8Array.from([]),\n isFirstChunk: true,\n });\n const result = command.parseResponse(response);\n // THEN\n expect(result).toStrictEqual(\n CommandResultFactory({\n error: new InvalidStatusWordError(\"R is missing\"),\n }),\n );\n });\n\n it(\"should return an error if s is missing\", () => {\n // GIVEN\n const response: ApduResponse = {\n statusCode: Buffer.from([0x90, 0x00]), // Success status code\n data: SUCCESS_RESPONSE.slice(0, 64),\n };\n // WHEN\n const command = new SignEIP7702AuthorizationCommand({\n data: Uint8Array.from([]),\n isFirstChunk: true,\n });\n const result = command.parseResponse(response);\n // THEN\n expect(result).toStrictEqual(\n CommandResultFactory({\n error: new InvalidStatusWordError(\"S is missing\"),\n }),\n );\n });\n });\n});\n"],
5
- "mappings": "aAAA,IAAAA,EAKO,2CACPC,EAA8B,qBAE9BC,EAGO,gDAEP,MAAMC,EAAmB,WAAW,KAAK,CACvC,IAAM,GAAM,EAAM,EAAM,EAAM,EAAM,EAAM,GAAM,IAAM,IAAM,IAAM,IAAM,GAC1E,CAAC,EAEKC,EAAkB,WAAW,KAAK,CACtC,IAAM,GAAM,EAAM,EAAM,EAAM,EAAM,EAAM,GAAM,IAAM,IAAM,IAAM,IAAM,GAC1E,CAAC,EAEKC,EAAmB,IAAI,WAAW,CACtC,GAAM,IAAM,IAAM,IAAM,IAAM,IAAM,GAAM,GAAM,GAAM,GAAM,EAAM,IAAM,IACxE,GAAM,GAAM,IAAM,GAAM,GAAM,IAAM,GAAM,IAAM,IAAM,IAAM,GAAM,GAAM,GACxE,GAAM,EAAM,IAAM,GAAM,IAAM,IAAM,IAAM,IAAM,GAAM,IAAM,GAAM,IAAM,IACxE,IAAM,EAAM,IAAM,IAAM,IAAM,GAAM,GAAM,GAAM,IAAM,IAAM,IAAM,IAAM,IACxE,IAAM,IAAM,GAAM,IAAM,IAAM,GAAM,IAAM,IAAM,I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AC7B,WAAY,OAAO,KAAK,CAAC,IAAM,CAAI,CAAC,EACpC,KAAMH,CACR,EAMMI,EAJU,IAAI,kCAAgC,CAClD,KAAM,WAAW,KAAK,CAAC,CAAC,EACxB,aAAc,EAChB,CAAC,EACsB,cAAcD,CAAQ,EAE7C,OAAOC,CAAM,EAAE,iBACb,wBAAqB,CACnB,QAAM,QAAK,CACT,EAAG,qEACH,EAAG,qEACH,EAAG,EACL,CAAC,CACH,CAAC,CACH,CACF,CAAC,EAED,GAAG,yCAA0C,IAAM,CAEjD,MAAMD,EAAyB,CAC7B,WAAY,OAAO,KAAK,CAAC,IAAM,CAAI,CAAC,EACpC,KAAMH,EAAiB,MAAM,EAAG,EAAE,CACpC,EAMMI,EAJU,IAAI,kCAAgC,CAClD,KAAM,WAAW,KAAK,CAAC,CAAC,EACxB,aAAc,EAChB,CAAC,EACsB,cAAcD,CAAQ,EAE7C,OAAOC,CAAM,EAAE,iBACb,wBAAqB,CACnB,MAAO,IAAI,yBAAuB,cAAc,CAClD,CAAC,CACH,CACF,CAAC,EAED,GAAG,yCAA0C,IAAM,CAEjD,MAAMD,EAAyB,CAC7B,WAAY,OAAO,KAAK,CAAC,IAAM,CAAI,CAAC,EACpC,KAAMH,EAAiB,MAAM,EAAG,EAAE,CACpC,EAMMI,EAJU,IAAI,kCAAgC,CAClD,KAAM,WAAW,KAAK,CAAC,CAAC,EACxB,aAAc,EAChB,CAAC,EACsB,cAAcD,CAAQ,EAE7C,OAAOC,CAAM,EAAE,iBACb,wBAAqB,CACnB,MAAO,IAAI,yBAAuB,cAAc,CAClD,CAAC,CACH,CACF,CAAC,CACH,CAAC,CACH,CAAC",
6
- "names": ["import_device_management_kit", "import_purify_ts", "import_SignAuthorizationDelegationCommand", "FIRST_CHUNK_APDU", "NEXT_CHUNK_APDU", "SUCCESS_RESPONSE", "args", "apdu", "response", "result"]
7
- }
@@ -1,2 +0,0 @@
1
- "use strict";var m=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var p=Object.prototype.hasOwnProperty;var g=(a,t)=>{for(var r in t)m(a,r,{get:t[r],enumerable:!0})},A=(a,t,r,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let e of l(t))!p.call(a,e)&&e!==r&&m(a,e,{get:()=>t[e],enumerable:!(i=h(t,e))||i.enumerable});return a};var S=a=>A(m({},"__esModule",{value:!0}),a);var _={};g(_,{SendSignAuthorizationDelegationTask:()=>D});module.exports=S(_);var n=require("@ledgerhq/device-management-kit"),c=require("@ledgerhq/signer-utils"),I=require("../../app-binder/command/SignAuthorizationDelegationCommand"),T=require("./SendCommandInChunksTask");const C=0,f=1,E=2,b=3;class D{constructor(t,r){this.api=t;this.args=r}async run(){const{derivationPath:t,chainId:r,address:i,nonce:e}=this.args,d=c.DerivationPathUtils.splitPath(t),o=this.buildData(d,r,i,e),s=await new T.SendCommandInChunksTask(this.api,{data:o,commandFactory:u=>new I.SignEIP7702AuthorizationCommand({data:u.chunkedData,isFirstChunk:u.isFirstChunk})}).run();return(0,n.isSuccessCommandResult)(s)?s.data.mapOrDefault(u=>(0,n.CommandResultFactory)({data:u}),(0,n.CommandResultFactory)({error:new n.InvalidStatusWordError("no signature returned")})):s}buildData(t,r,i,e){const d=new n.ByteArrayBuilder;d.add8BitUIntToData(t.length),t.forEach(u=>{d.add32BitUIntToData(u)});const o=new n.ByteArrayBuilder;o.encodeInTLVFromBuffer(C,Uint8Array.from([1])),o.encodeInTLVFromHexa(f,i),o.encodeInTLVFromUInt64(E,r),o.encodeInTLVFromUInt64(b,e);const s=o.build();return d.add16BitUIntToData(s.length).addBufferToData(s).build()}}0&&(module.exports={SendSignAuthorizationDelegationTask});
2
- //# sourceMappingURL=SendSignAuthorizationDelegationTask.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../../../src/internal/app-binder/task/SendSignAuthorizationDelegationTask.ts"],
4
- "sourcesContent": ["import {\n ByteArrayBuilder,\n type CommandResult,\n CommandResultFactory,\n type InternalApi,\n InvalidStatusWordError,\n isSuccessCommandResult,\n} from \"@ledgerhq/device-management-kit\";\nimport { DerivationPathUtils } from \"@ledgerhq/signer-utils\";\n\nimport { type Signature } from \"@api/model/Signature\";\nimport {\n SignEIP7702AuthorizationCommand,\n type SignEIP7702AuthorizationCommandResponse,\n} from \"@internal/app-binder/command/SignAuthorizationDelegationCommand\";\nimport { type EthErrorCodes } from \"@internal/app-binder/command/utils/ethAppErrors\";\n\nimport { SendCommandInChunksTask } from \"./SendCommandInChunksTask\";\n\nconst TAG_STRUCT_EIP7702_VERSION: number = 0x00;\nconst TAG_STRUCT_EIP7702_DELEGATE_ADDR: number = 0x01;\nconst TAG_STRUCT_EIP7702_CHAIN_ID: number = 0x02;\nconst TAG_STRUCT_EIP7702_NONCE: number = 0x03;\n\ntype SendSignAuthorizationDelegationTaskArgs = {\n derivationPath: string;\n chainId: number;\n address: string;\n nonce: number;\n};\n\nexport class SendSignAuthorizationDelegationTask {\n constructor(\n private api: InternalApi,\n private args: SendSignAuthorizationDelegationTaskArgs,\n ) {}\n\n async run(): Promise<CommandResult<Signature, EthErrorCodes>> {\n const { derivationPath, chainId, address, nonce } = this.args;\n const paths = DerivationPathUtils.splitPath(derivationPath);\n\n const buffer = this.buildData(paths, chainId, address, nonce);\n\n const result =\n await new SendCommandInChunksTask<SignEIP7702AuthorizationCommandResponse>(\n this.api,\n {\n data: buffer,\n commandFactory: (args) =>\n new SignEIP7702AuthorizationCommand({\n data: args.chunkedData,\n isFirstChunk: args.isFirstChunk,\n }),\n },\n ).run();\n\n if (!isSuccessCommandResult(result)) {\n return result;\n }\n\n return result.data.mapOrDefault(\n (data) => CommandResultFactory({ data }),\n CommandResultFactory({\n error: new InvalidStatusWordError(\"no signature returned\"),\n }),\n );\n }\n\n buildData(\n paths: number[],\n chainId: number,\n address: string,\n nonce: number,\n ): Uint8Array {\n const builder = new ByteArrayBuilder();\n // add the derivation paths length\n builder.add8BitUIntToData(paths.length);\n // add every derivation path\n paths.forEach((path) => {\n builder.add32BitUIntToData(path);\n });\n\n // Send EIP7702 Auth structure\n const builderStruct = new ByteArrayBuilder();\n builderStruct.encodeInTLVFromBuffer(\n TAG_STRUCT_EIP7702_VERSION,\n Uint8Array.from([0x01]),\n );\n // Add address\n builderStruct.encodeInTLVFromHexa(\n TAG_STRUCT_EIP7702_DELEGATE_ADDR,\n address,\n );\n // Add chainId\n builderStruct.encodeInTLVFromUInt64(TAG_STRUCT_EIP7702_CHAIN_ID, chainId);\n // Add nonce\n builderStruct.encodeInTLVFromUInt64(TAG_STRUCT_EIP7702_NONCE, nonce);\n const structBuffer = builderStruct.build();\n\n return builder\n .add16BitUIntToData(structBuffer.length)\n .addBufferToData(structBuffer)\n .build();\n }\n}\n"],
5
- "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,yCAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAOO,2CACPC,EAAoC,kCAGpCC,EAGO,2EAGPC,EAAwC,qCAExC,MAAMC,EAAqC,EACrCC,EAA2C,EAC3CC,EAAsC,EACtCC,EAAmC,EASlC,MAAMT,CAAoC,CAC/C,YACUU,EACAC,EACR,CAFQ,SAAAD,EACA,UAAAC,CACP,CAEH,MAAM,KAAwD,CAC5D,KAAM,CAAE,eAAAC,EAAgB,QAAAC,EAAS,QAAAC,EAAS,MAAAC,CAAM,EAAI,KAAK,KACnDC,EAAQ,sBAAoB,UAAUJ,CAAc,EAEpDK,EAAS,KAAK,UAAUD,EAAOH,EAASC,EAASC,CAAK,EAEtDG,EACJ,MAAM,IAAI,0BACR,KAAK,IACL,CACE,KAAMD,EACN,eAAiBN,GACf,IAAI,kCAAgC,CAClC,KAAMA,EAAK,YACX,aAAcA,EAAK,YACrB,CAAC,CACL,CACF,EAAE,IAAI,EAER,SAAK,0BAAuBO,CAAM,EAI3BA,EAAO,KAAK,aAChBC,MAAS,wBAAqB,CAAE,KAAAA,CAAK,CAAC,KACvC,wBAAqB,CACnB,MAAO,IAAI,yBAAuB,uBAAuB,CAC3D,CAAC,CACH,EARSD,CASX,CAEA,UACEF,EACAH,EACAC,EACAC,EACY,CACZ,MAAMK,EAAU,IAAI,mBAEpBA,EAAQ,kBAAkBJ,EAAM,MAAM,EAEtCA,EAAM,QAASK,GAAS,CACtBD,EAAQ,mBAAmBC,CAAI,CACjC,CAAC,EAGD,MAAMC,EAAgB,IAAI,mBAC1BA,EAAc,sBACZhB,EACA,WAAW,KAAK,CAAC,CAAI,CAAC,CACxB,EAEAgB,EAAc,oBACZf,EACAO,CACF,EAEAQ,EAAc,sBAAsBd,EAA6BK,CAAO,EAExES,EAAc,sBAAsBb,EAA0BM,CAAK,EACnE,MAAMQ,EAAeD,EAAc,MAAM,EAEzC,OAAOF,EACJ,mBAAmBG,EAAa,MAAM,EACtC,gBAAgBA,CAAY,EAC5B,MAAM,CACX,CACF",
6
- "names": ["SendSignAuthorizationDelegationTask_exports", "__export", "SendSignAuthorizationDelegationTask", "__toCommonJS", "import_device_management_kit", "import_signer_utils", "import_SignAuthorizationDelegationCommand", "import_SendCommandInChunksTask", "TAG_STRUCT_EIP7702_VERSION", "TAG_STRUCT_EIP7702_DELEGATE_ADDR", "TAG_STRUCT_EIP7702_CHAIN_ID", "TAG_STRUCT_EIP7702_NONCE", "api", "args", "derivationPath", "chainId", "address", "nonce", "paths", "buffer", "result", "data", "builder", "path", "builderStruct", "structBuffer"]
7
- }
@@ -1,2 +0,0 @@
1
- "use strict";var a=require("@ledgerhq/device-management-kit"),n=require("@ledgerhq/device-management-kit"),o=require("purify-ts"),t=require("../../app-binder/command/SignAuthorizationDelegationCommand"),l=require("../../app-binder/device-action/__test-utils__/makeInternalApi"),d=require("./SendSignAuthorizationDelegationTask");const f=new Uint8Array([5,128,0,0,44,128,0,0,60,128,0,0,0,0,0,0,0,0,0,0,0,0,45,0,1,1,1,20,76,210,65,232,209,81,14,48,178,7,99,151,175,199,80,138,229,156,102,201,2,8,0,0,0,0,0,0,0,1,3,8,0,0,0,0,0,0,0,41]),m=new Uint8Array([5,128,0,0,44,128,0,0,60,128,0,0,0,0,0,0,0,0,0,0,0,1,9,0,1,1,1,240,76,210,65,232,209,81,14,48,178,7,99,151,175,199,80,138,229,156,102,201,76,210,65,232,209,81,14,48,178,7,99,151,175,199,80,138,229,156,102,201,76,210,65,232,209,81,14,48,178,7,99,151,175,199,80,138,229,156,102,201,76,210,65,232,209,81,14,48,178,7,99,151,175,199,80,138,229,156,102,201,76,210,65,232,209,81,14,48,178,7,99,151,175,199,80,138,229,156,102,201,76,210,65,232,209,81,14,48,178,7,99,151,175,199,80,138,229,156,102,201,76,210,65,232,209,81,14,48,178,7,99,151,175,199,80,138,229,156,102,201,76,210,65,232,209,81,14,48,178,7,99,151,175,199,80,138,229,156,102,201,76,210,65,232,209,81,14,48,178,7,99,151,175,199,80,138,229,156,102,201,76,210,65,232,209,81,14,48,178,7,99,151,175,199,80,138,229,156,102,201,76,210,65,232,209,81,14,48,178,7,99,151,175,199,80,138,229,156,102,201,76,210,65,232,209,81,14,48,178,7,99,151,175,199,80,138,229,156,102,201,2,8,0,0,0,0,0,0,0,1,3,8,0,0,0,0,0,0,0,41]);describe("SendSignAuthorizationDelegationTask",()=>{const x=(0,l.makeDeviceActionInternalApiMock)(),r={v:27,r:"0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",s:"0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef"},i=(0,a.CommandResultFactory)({data:(0,o.Just)(r)}),s=(0,a.CommandResultFactory)({data:o.Nothing});beforeEach(()=>{vi.resetAllMocks()}),describe("run",()=>{it("should send the message in chunks",async()=>{const e={derivationPath:"44'/60'/0'/0/0",address:"0x4Cd241E8d1510e30b2076397afc7508Ae59C66c9",chainId:1,nonce:41};x.sendCommand.mockResolvedValueOnce(i),x.sendCommand.mockResolvedValueOnce(s);const c=await new d.SendSignAuthorizationDelegationTask(x,e).run();expect(x.sendCommand.mock.calls).toHaveLength(1),expect(x.sendCommand.mock.calls[0][0]).toStrictEqual(new t.SignEIP7702AuthorizationCommand({data:new Uint8Array(f),isFirstChunk:!0})),expect(c.data).toStrictEqual(r)}),it("should send the long message in chunks",async()=>{const e={derivationPath:"44'/60'/0'/0/0",address:"0x4Cd241E8d1510e30b2076397afc7508Ae59C66c94Cd241E8d1510e30b2076397afc7508Ae59C66c94Cd241E8d1510e30b2076397afc7508Ae59C66c94Cd241E8d1510e30b2076397afc7508Ae59C66c94Cd241E8d1510e30b2076397afc7508Ae59C66c94Cd241E8d1510e30b2076397afc7508Ae59C66c94Cd241E8d1510e30b2076397afc7508Ae59C66c94Cd241E8d1510e30b2076397afc7508Ae59C66c94Cd241E8d1510e30b2076397afc7508Ae59C66c94Cd241E8d1510e30b2076397afc7508Ae59C66c94Cd241E8d1510e30b2076397afc7508Ae59C66c94Cd241E8d1510e30b2076397afc7508Ae59C66c9",chainId:1,nonce:41};x.sendCommand.mockResolvedValueOnce(s),x.sendCommand.mockResolvedValueOnce(i);const c=await new d.SendSignAuthorizationDelegationTask(x,e).run();expect(x.sendCommand.mock.calls).toHaveLength(2),expect(x.sendCommand.mock.calls[0][0]).toStrictEqual(new t.SignEIP7702AuthorizationCommand({data:m.slice(0,255),isFirstChunk:!0})),expect(x.sendCommand.mock.calls[1][0]).toStrictEqual(new t.SignEIP7702AuthorizationCommand({data:m.slice(255,510),isFirstChunk:!1})),expect(c.data).toStrictEqual(r)}),it("should return an error if the command fails",async()=>{const e={derivationPath:"44'/60'/0'/0/0",address:"0x4Cd241E8d1510e30b2076397afc7508Ae59C66c9",chainId:1,nonce:41};x.sendCommand.mockResolvedValueOnce((0,a.CommandResultFactory)({error:new n.InvalidStatusWordError("An error")}));const c=await new d.SendSignAuthorizationDelegationTask(x,e).run();expect(c).toStrictEqual((0,a.CommandResultFactory)({error:new n.InvalidStatusWordError("An error")}))}),it("should return an error if the command returns no data",async()=>{const e={derivationPath:"44'/60'/0'/0/0",address:"0x4Cd241E8d1510e30b2076397afc7508Ae59C66c9",chainId:1,nonce:41};x.sendCommand.mockResolvedValueOnce(s);const c=await new d.SendSignAuthorizationDelegationTask(x,e).run();expect(c).toStrictEqual((0,a.CommandResultFactory)({error:new n.InvalidStatusWordError("no signature returned")}))})})});
2
- //# sourceMappingURL=SendSignAuthorizationDelegationTask.test.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../../../src/internal/app-binder/task/SendSignAuthorizationDelegationTask.test.ts"],
4
- "sourcesContent": ["import { CommandResultFactory } from \"@ledgerhq/device-management-kit\";\nimport { InvalidStatusWordError } from \"@ledgerhq/device-management-kit\";\nimport { Just, Nothing } from \"purify-ts\";\n\nimport { SignEIP7702AuthorizationCommand } from \"@internal/app-binder/command/SignAuthorizationDelegationCommand\";\nimport { makeDeviceActionInternalApiMock } from \"@internal/app-binder/device-action/__test-utils__/makeInternalApi\";\n\nimport { SendSignAuthorizationDelegationTask } from \"./SendSignAuthorizationDelegationTask\";\n\nconst SMALL_MESSAGE_DATA = new Uint8Array([\n 0x05, 0x80, 0x00, 0x00, 0x2c, 0x80, 0x00, 0x00, 0x3c, 0x80, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2d, 0x00, 0x01, 0x01,\n 0x01, 0x14, 0x4c, 0xd2, 0x41, 0xe8, 0xd1, 0x51, 0x0e, 0x30, 0xb2, 0x07, 0x63,\n 0x97, 0xaf, 0xc7, 0x50, 0x8a, 0xe5, 0x9c, 0x66, 0xc9, 0x02, 0x08, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x29,\n]);\n\nconst LONG_MESSAGE_DATA = new Uint8Array([\n 0x05, 0x80, 0x00, 0x00, 0x2c, 0x80, 0x00, 0x00, 0x3c, 0x80, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x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0x07, 0x63, 0x97, 0xaf, 0xc7, 0x50, 0x8a, 0xe5, 0x9c, 0x66, 0xc9,\n 0x4c, 0xd2, 0x41, 0xe8, 0xd1, 0x51, 0x0e, 0x30, 0xb2, 0x07, 0x63, 0x97, 0xaf,\n 0xc7, 0x50, 0x8a, 0xe5, 0x9c, 0x66, 0xc9, 0x4c, 0xd2, 0x41, 0xe8, 0xd1, 0x51,\n 0x0e, 0x30, 0xb2, 0x07, 0x63, 0x97, 0xaf, 0xc7, 0x50, 0x8a, 0xe5, 0x9c, 0x66,\n 0xc9, 0x4c, 0xd2, 0x41, 0xe8, 0xd1, 0x51, 0x0e, 0x30, 0xb2, 0x07, 0x63, 0x97,\n 0xaf, 0xc7, 0x50, 0x8a, 0xe5, 0x9c, 0x66, 0xc9, 0x02, 0x08, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x29,\n]);\n\ndescribe(\"SendSignAuthorizationDelegationTask\", () => {\n const apiMock = makeDeviceActionInternalApiMock();\n const signature = {\n v: 27,\n r: \"0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef\",\n s: \"0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef\",\n };\n const resultOk = CommandResultFactory({\n data: Just(signature),\n });\n const resultNothing = CommandResultFactory({ data: Nothing });\n\n beforeEach(() => {\n vi.resetAllMocks();\n });\n\n describe(\"run\", () => {\n it(\"should send the message in chunks\", async () => {\n // GIVEN\n const args = {\n derivationPath: \"44'/60'/0'/0/0\",\n address: \"0x4Cd241E8d1510e30b2076397afc7508Ae59C66c9\",\n chainId: 1,\n nonce: 41,\n };\n apiMock.sendCommand.mockResolvedValueOnce(resultOk);\n apiMock.sendCommand.mockResolvedValueOnce(resultNothing);\n\n // WHEN\n const result = await new SendSignAuthorizationDelegationTask(\n apiMock,\n args,\n ).run();\n\n // THEN\n expect(apiMock.sendCommand.mock.calls).toHaveLength(1);\n expect(apiMock.sendCommand.mock.calls[0]![0]).toStrictEqual(\n new SignEIP7702AuthorizationCommand({\n data: new Uint8Array(SMALL_MESSAGE_DATA),\n isFirstChunk: true,\n }),\n );\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n expect((result as any).data).toStrictEqual(signature);\n });\n\n it(\"should send the long message in chunks\", async () => {\n // GIVEN\n const args = {\n derivationPath: \"44'/60'/0'/0/0\",\n address:\n \"0x4Cd241E8d1510e30b2076397afc7508Ae59C66c94Cd241E8d1510e30b2076397afc7508Ae59C66c94Cd241E8d1510e30b2076397afc7508Ae59C66c94Cd241E8d1510e30b2076397afc7508Ae59C66c94Cd241E8d1510e30b2076397afc7508Ae59C66c94Cd241E8d1510e30b2076397afc7508Ae59C66c94Cd241E8d1510e30b2076397afc7508Ae59C66c94Cd241E8d1510e30b2076397afc7508Ae59C66c94Cd241E8d1510e30b2076397afc7508Ae59C66c94Cd241E8d1510e30b2076397afc7508Ae59C66c94Cd241E8d1510e30b2076397afc7508Ae59C66c94Cd241E8d1510e30b2076397afc7508Ae59C66c9\",\n chainId: 1,\n nonce: 41,\n };\n apiMock.sendCommand.mockResolvedValueOnce(resultNothing);\n apiMock.sendCommand.mockResolvedValueOnce(resultOk);\n\n // WHEN\n const result = await new SendSignAuthorizationDelegationTask(\n apiMock,\n args,\n ).run();\n\n // THEN\n expect(apiMock.sendCommand.mock.calls).toHaveLength(2);\n expect(apiMock.sendCommand.mock.calls[0]![0]).toStrictEqual(\n new SignEIP7702AuthorizationCommand({\n data: LONG_MESSAGE_DATA.slice(0, 255),\n isFirstChunk: true,\n }),\n );\n expect(apiMock.sendCommand.mock.calls[1]![0]).toStrictEqual(\n new SignEIP7702AuthorizationCommand({\n data: LONG_MESSAGE_DATA.slice(255, 510),\n isFirstChunk: false,\n }),\n );\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n expect((result as any).data).toStrictEqual(signature);\n });\n\n it(\"should return an error if the command fails\", async () => {\n // GIVEN\n const args = {\n derivationPath: \"44'/60'/0'/0/0\",\n address: \"0x4Cd241E8d1510e30b2076397afc7508Ae59C66c9\",\n chainId: 1,\n nonce: 41,\n };\n apiMock.sendCommand.mockResolvedValueOnce(\n CommandResultFactory({\n error: new InvalidStatusWordError(\"An error\"),\n }),\n );\n\n // WHEN\n const result = await new SendSignAuthorizationDelegationTask(\n apiMock,\n args,\n ).run();\n\n // THEN\n expect(result).toStrictEqual(\n CommandResultFactory({\n error: new InvalidStatusWordError(\"An error\"),\n }),\n );\n });\n\n it(\"should return an error if the command returns no data\", async () => {\n // GIVEN\n const args = {\n derivationPath: \"44'/60'/0'/0/0\",\n address: \"0x4Cd241E8d1510e30b2076397afc7508Ae59C66c9\",\n chainId: 1,\n nonce: 41,\n };\n apiMock.sendCommand.mockResolvedValueOnce(resultNothing);\n\n // WHEN\n const result = await new SendSignAuthorizationDelegationTask(\n apiMock,\n args,\n ).run();\n\n // THEN\n expect(result).toStrictEqual(\n CommandResultFactory({\n error: new InvalidStatusWordError(\"no signature returned\"),\n }),\n );\n });\n });\n});\n"],
5
- "mappings": "aAAA,IAAAA,EAAqC,2CACrCA,EAAuC,2CACvCC,EAA8B,qBAE9BC,EAAgD,2EAChDC,EAAgD,6EAEhDC,EAAoD,iDAEpD,MAAMC,EAAqB,IAAI,WAAW,CACxC,EAAM,IAAM,EAAM,EAAM,GAAM,IAAM,EAAM,EAAM,GAAM,IAAM,EAAM,EAAM,EACxE,EAAM,EAAM,EAAM,EAAM,EAAM,EAAM,EAAM,EAAM,EAAM,GAAM,EAAM,EAAM,EACxE,EAAM,GAAM,GAAM,IAAM,GAAM,IAAM,IAAM,GAAM,GAAM,GAAM,IAAM,EAAM,GACxE,IAAM,IAAM,IAAM,GAAM,IAAM,IAAM,IAAM,IAAM,IAAM,EAAM,EAAM,EAAM,EACxE,EAAM,EAAM,EAAM,EAAM,EAAM,EAAM,EAAM,EAAM,EAAM,EAAM,EAAM,EAAM,EACxE,EAAM,EAAM,E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,sBAAsBG,CAAa,EAGvD,MAAME,EAAS,MAAM,IAAI,sCACvBL,EACAI,CACF,EAAE,IAAI,EAGN,OAAOC,CAAM,EAAE,iBACb,wBAAqB,CACnB,MAAO,IAAI,yBAAuB,uBAAuB,CAC3D,CAAC,CACH,CACF,CAAC,CACH,CAAC,CACH,CAAC",
6
- "names": ["import_device_management_kit", "import_purify_ts", "import_SignAuthorizationDelegationCommand", "import_makeInternalApi", "import_SendSignAuthorizationDelegationTask", "SMALL_MESSAGE_DATA", "LONG_MESSAGE_DATA", "apiMock", "signature", "resultOk", "resultNothing", "args", "result"]
7
- }
@@ -1,2 +0,0 @@
1
- "use strict";var r=Object.defineProperty;var s=Object.getOwnPropertyDescriptor;var g=Object.getOwnPropertyNames;var l=Object.prototype.hasOwnProperty;var u=(o,e)=>{for(var t in e)r(o,t,{get:e[t],enumerable:!0})},f=(o,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of g(e))!l.call(o,i)&&i!==t&&r(o,i,{get:()=>e[i],enumerable:!(n=s(e,i))||n.enumerable});return o};var C=o=>f(r({},"__esModule",{value:!0}),o);var d={};u(d,{eip7702ModuleFactory:()=>c});module.exports=C(d);var a=require("inversify"),p=require("../../eip7702/di/eip7702Types"),m=require("../../eip7702/use-case/SignDelegationAuthorizationUseCase");const c=()=>new a.ContainerModule(({bind:o})=>{o(p.eip7702Types.SignDelegationAuthorizationUseCase).to(m.SignDelegationAuthorizationUseCase)});0&&(module.exports={eip7702ModuleFactory});
2
- //# sourceMappingURL=eip7702Module.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../../../src/internal/eip7702/di/eip7702Module.ts"],
4
- "sourcesContent": ["import { ContainerModule } from \"inversify\";\n\nimport { eip7702Types } from \"@internal/eip7702/di/eip7702Types\";\nimport { SignDelegationAuthorizationUseCase } from \"@internal/eip7702/use-case/SignDelegationAuthorizationUseCase\";\n\nexport const eip7702ModuleFactory = () =>\n new ContainerModule(({ bind }) => {\n bind(eip7702Types.SignDelegationAuthorizationUseCase).to(\n SignDelegationAuthorizationUseCase,\n );\n });\n"],
5
- "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,0BAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAgC,qBAEhCC,EAA6B,6CAC7BC,EAAmD,yEAE5C,MAAMJ,EAAuB,IAClC,IAAI,kBAAgB,CAAC,CAAE,KAAAK,CAAK,IAAM,CAChCA,EAAK,eAAa,kCAAkC,EAAE,GACpD,oCACF,CACF,CAAC",
6
- "names": ["eip7702Module_exports", "__export", "eip7702ModuleFactory", "__toCommonJS", "import_inversify", "import_eip7702Types", "import_SignDelegationAuthorizationUseCase", "bind"]
7
- }
@@ -1,2 +0,0 @@
1
- "use strict";var t=require("inversify"),r=require("./eip7702Module");describe("eip7702ModuleFactory",()=>{describe("Default",()=>{let o,e;beforeEach(()=>{e=(0,r.eip7702ModuleFactory)(),o=new t.Container,o.load(e)}),it("should return the eip7702 module",()=>{expect(e).toBeDefined()})})});
2
- //# sourceMappingURL=eip7702Module.test.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../../../src/internal/eip7702/di/eip7702Module.test.ts"],
4
- "sourcesContent": ["import { Container } from \"inversify\";\n\nimport { eip7702ModuleFactory } from \"./eip7702Module\";\n\ndescribe(\"eip7702ModuleFactory\", () => {\n describe(\"Default\", () => {\n let container: Container;\n let mod: ReturnType<typeof eip7702ModuleFactory>;\n beforeEach(() => {\n mod = eip7702ModuleFactory();\n container = new Container();\n container.load(mod);\n });\n\n it(\"should return the eip7702 module\", () => {\n expect(mod).toBeDefined();\n });\n });\n});\n"],
5
- "mappings": "aAAA,IAAAA,EAA0B,qBAE1BC,EAAqC,2BAErC,SAAS,uBAAwB,IAAM,CACrC,SAAS,UAAW,IAAM,CACxB,IAAIC,EACAC,EACJ,WAAW,IAAM,CACfA,KAAM,wBAAqB,EAC3BD,EAAY,IAAI,YAChBA,EAAU,KAAKC,CAAG,CACpB,CAAC,EAED,GAAG,mCAAoC,IAAM,CAC3C,OAAOA,CAAG,EAAE,YAAY,CAC1B,CAAC,CACH,CAAC,CACH,CAAC",
6
- "names": ["import_inversify", "import_eip7702Module", "container", "mod"]
7
- }
@@ -1,2 +0,0 @@
1
- "use strict";var n=Object.defineProperty;var s=Object.getOwnPropertyDescriptor;var g=Object.getOwnPropertyNames;var r=Object.prototype.hasOwnProperty;var l=(o,e)=>{for(var t in e)n(o,t,{get:e[t],enumerable:!0})},p=(o,e,t,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of g(e))!r.call(o,i)&&i!==t&&n(o,i,{get:()=>e[i],enumerable:!(a=s(e,i))||a.enumerable});return o};var S=o=>p(n({},"__esModule",{value:!0}),o);var u={};l(u,{eip7702Types:()=>h});module.exports=S(u);const h={SignDelegationAuthorizationUseCase:Symbol.for("SignDelegationAuthorizationUseCase")};0&&(module.exports={eip7702Types});
2
- //# sourceMappingURL=eip7702Types.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../../../src/internal/eip7702/di/eip7702Types.ts"],
4
- "sourcesContent": ["export const eip7702Types = {\n SignDelegationAuthorizationUseCase: Symbol.for(\n \"SignDelegationAuthorizationUseCase\",\n ),\n};\n"],
5
- "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,kBAAAE,IAAA,eAAAC,EAAAH,GAAO,MAAME,EAAe,CAC1B,mCAAoC,OAAO,IACzC,oCACF,CACF",
6
- "names": ["eip7702Types_exports", "__export", "eip7702Types", "__toCommonJS"]
7
- }
@@ -1,2 +0,0 @@
1
- "use strict";var o=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var a=Object.getOwnPropertyNames;var f=Object.prototype.hasOwnProperty;var b=(t,r)=>{for(var i in r)o(t,i,{get:r[i],enumerable:!0})},g=(t,r,i,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let p of a(r))!f.call(t,p)&&p!==i&&o(t,p,{get:()=>r[p],enumerable:!(n=u(r,p))||n.enumerable});return t};var s=t=>g(o({},"__esModule",{value:!0}),t),c=(t,r,i,n)=>{for(var p=n>1?void 0:n?u(r,i):r,d=t.length-1,B;d>=0;d--)(B=t[d])&&(p=(n?B(r,i,p):B(p))||p);return n&&p&&o(r,i,p),p},A=(t,r)=>(i,n)=>r(i,n,t);var y={};b(y,{SignDelegationAuthorizationUseCase:()=>e});module.exports=s(y);var m=require("inversify"),h=require("../../app-binder/di/appBinderTypes");let e=class{_appBinder;constructor(r){this._appBinder=r}execute(r,i,n,p){return this._appBinder.signDelegationAuthorization({derivationPath:r,nonce:i,address:n,chainId:p})}};e=c([(0,m.injectable)(),A(0,(0,m.inject)(h.appBinderTypes.AppBinding))],e);0&&(module.exports={SignDelegationAuthorizationUseCase});
2
- //# sourceMappingURL=SignDelegationAuthorizationUseCase.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../../../src/internal/eip7702/use-case/SignDelegationAuthorizationUseCase.ts"],
4
- "sourcesContent": ["import { inject, injectable } from \"inversify\";\n\nimport { SignDelegationAuthorizationDAReturnType } from \"@api/app-binder/SignDelegationAuthorizationTypes\";\nimport { appBinderTypes } from \"@internal/app-binder/di/appBinderTypes\";\nimport { EthAppBinder } from \"@internal/app-binder/EthAppBinder\";\n\n@injectable()\nexport class SignDelegationAuthorizationUseCase {\n private _appBinder: EthAppBinder;\n\n constructor(\n @inject(appBinderTypes.AppBinding)\n appBinding: EthAppBinder,\n ) {\n this._appBinder = appBinding;\n }\n\n execute(\n derivationPath: string,\n nonce: number,\n address: string,\n chainId: number,\n ): SignDelegationAuthorizationDAReturnType {\n return this._appBinder.signDelegationAuthorization({\n derivationPath,\n nonce,\n address,\n chainId,\n });\n }\n}\n"],
5
- "mappings": "okBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,wCAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAmC,qBAGnCC,EAA+B,kDAIxB,IAAMC,EAAN,KAAyC,CACtC,WAER,YAEEC,EACA,CACA,KAAK,WAAaA,CACpB,CAEA,QACEC,EACAC,EACAC,EACAC,EACyC,CACzC,OAAO,KAAK,WAAW,4BAA4B,CACjD,eAAAH,EACA,MAAAC,EACA,QAAAC,EACA,QAAAC,CACF,CAAC,CACH,CACF,EAvBaL,EAANM,EAAA,IADN,cAAW,EAKPC,EAAA,eAAO,iBAAe,UAAU,IAJxBP",
6
- "names": ["SignDelegationAuthorizationUseCase_exports", "__export", "SignDelegationAuthorizationUseCase", "__toCommonJS", "import_inversify", "import_appBinderTypes", "SignDelegationAuthorizationUseCase", "appBinding", "derivationPath", "nonce", "address", "chainId", "__decorateClass", "__decorateParam"]
7
- }
@@ -1,2 +0,0 @@
1
- "use strict";var s=require("./SignDelegationAuthorizationUseCase");describe("SignDelegationAuthorizationUseCase",()=>{it("should call signPersonalMessage on appBinder with the correct arguments",()=>{const e="44'/501'/0'/0'",n="address",i={signDelegationAuthorization:vi.fn()};new s.SignDelegationAuthorizationUseCase(i).execute(e,42,n,2),expect(i.signDelegationAuthorization).toHaveBeenCalledWith({derivationPath:e,nonce:42,address:n,chainId:2})})});
2
- //# sourceMappingURL=SignDelegationAuthorizationUseCase.test.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../../../src/internal/eip7702/use-case/SignDelegationAuthorizationUseCase.test.ts"],
4
- "sourcesContent": ["import { type EthAppBinder } from \"@internal/app-binder/EthAppBinder\";\n\nimport { SignDelegationAuthorizationUseCase } from \"./SignDelegationAuthorizationUseCase\";\n\ndescribe(\"SignDelegationAuthorizationUseCase\", () => {\n it(\"should call signPersonalMessage on appBinder with the correct arguments\", () => {\n // Given\n const derivationPath = \"44'/501'/0'/0'\";\n const chainId = 2;\n const nonce = 42;\n const address = \"address\";\n const appBinder = {\n signDelegationAuthorization: vi.fn(),\n };\n const signMessageUseCase = new SignDelegationAuthorizationUseCase(\n appBinder as unknown as EthAppBinder,\n );\n\n // When\n signMessageUseCase.execute(derivationPath, nonce, address, chainId);\n\n // Then\n expect(appBinder.signDelegationAuthorization).toHaveBeenCalledWith({\n derivationPath,\n nonce,\n address,\n chainId,\n });\n });\n});\n"],
5
- "mappings": "aAEA,IAAAA,EAAmD,gDAEnD,SAAS,qCAAsC,IAAM,CACnD,GAAG,0EAA2E,IAAM,CAElF,MAAMC,EAAiB,iBAGjBC,EAAU,UACVC,EAAY,CAChB,4BAA6B,GAAG,GAAG,CACrC,EAC2B,IAAI,qCAC7BA,CACF,EAGmB,QAAQF,EAAgB,GAAOC,EAAS,CAAO,EAGlE,OAAOC,EAAU,2BAA2B,EAAE,qBAAqB,CACjE,eAAAF,EACA,SACA,QAAAC,EACA,SACF,CAAC,CACH,CAAC,CACH,CAAC",
6
- "names": ["import_SignDelegationAuthorizationUseCase", "derivationPath", "address", "appBinder"]
7
- }
@@ -1 +0,0 @@
1
- //# sourceMappingURL=SignDelegationAuthorizationTypes.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": [],
4
- "sourcesContent": [],
5
- "mappings": "",
6
- "names": []
7
- }
@@ -1,2 +0,0 @@
1
- import{ApduBuilder as s,ApduParser as d,CommandResultFactory as e,InvalidStatusWordError as a}from"@ledgerhq/device-management-kit";import{CommandErrorHelper as m}from"@ledgerhq/signer-utils";import{Just as u,Maybe as p,Nothing as g}from"purify-ts";import{ETH_APP_ERRORS as A,EthAppCommandErrorFactory as E}from"./utils/ethAppErrors";const l=32,h=32;class f{args;errorHelper=new m(A,E);constructor(t){this.args=t}getApdu(){const{data:t,isFirstChunk:r}=this.args,o={cla:224,ins:52,p1:r?1:0,p2:0};return new s(o).addBufferToData(t).build()}parseResponse(t){return p.fromNullable(this.errorHelper.getError(t)).orDefaultLazy(()=>{const r=new d(t),o=r.extract8BitUInt();if(o===void 0)return e({data:g});const n=r.encodeToHexaString(r.extractFieldByLength(l),!0);if(!n)return e({error:new a("R is missing")});const i=r.encodeToHexaString(r.extractFieldByLength(h),!0);return i?e({data:u({r:n,s:i,v:o})}):e({error:new a("S is missing")})})}}export{f as SignEIP7702AuthorizationCommand};
2
- //# sourceMappingURL=SignAuthorizationDelegationCommand.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../../../src/internal/app-binder/command/SignAuthorizationDelegationCommand.ts"],
4
- "sourcesContent": ["// https://github.com/LedgerHQ/app-ethereum/blob/develop/doc/ethapp.adoc#sign-eth-personal-message\nimport {\n type Apdu,\n ApduBuilder,\n type ApduBuilderArgs,\n ApduParser,\n type ApduResponse,\n type Command,\n type CommandResult,\n CommandResultFactory,\n InvalidStatusWordError,\n} from \"@ledgerhq/device-management-kit\";\nimport { CommandErrorHelper } from \"@ledgerhq/signer-utils\";\nimport { Just, Maybe, Nothing } from \"purify-ts\";\n\nimport { type Signature } from \"@api/model/Signature\";\n\nimport {\n ETH_APP_ERRORS,\n EthAppCommandErrorFactory,\n type EthErrorCodes,\n} from \"./utils/ethAppErrors\";\n\nconst R_LENGTH = 32;\nconst S_LENGTH = 32;\n\nexport type SignEIP7702AuthorizationCommandArgs = {\n /**\n * The data to sign in max 255 bytes chunks\n * Data is a concatenation of the following:\n * - Derivation path length (1 byte)\n * - Derivation path (4 bytes per element)\n * - Nonce (4 bytes)\n * - Chain ID (4 bytes)\n * - Address (20 bytes)\n */\n readonly data: Uint8Array;\n /**\n * If this is the first chunk of the message\n */\n readonly isFirstChunk: boolean;\n};\n\nexport type SignEIP7702AuthorizationCommandResponse = Maybe<Signature>;\n\nexport class SignEIP7702AuthorizationCommand\n implements\n Command<\n SignEIP7702AuthorizationCommandResponse,\n SignEIP7702AuthorizationCommandArgs,\n EthErrorCodes\n >\n{\n readonly args: SignEIP7702AuthorizationCommandArgs;\n private readonly errorHelper = new CommandErrorHelper<\n SignEIP7702AuthorizationCommandResponse,\n EthErrorCodes\n >(ETH_APP_ERRORS, EthAppCommandErrorFactory);\n\n constructor(args: SignEIP7702AuthorizationCommandArgs) {\n this.args = args;\n }\n\n getApdu(): Apdu {\n const { data, isFirstChunk } = this.args;\n const signEIP7702AuthorizationArgs: ApduBuilderArgs = {\n cla: 0xe0,\n ins: 0x34,\n p1: isFirstChunk ? 0x01 : 0x00,\n p2: 0x00,\n };\n\n return new ApduBuilder(signEIP7702AuthorizationArgs)\n .addBufferToData(data)\n .build();\n }\n\n parseResponse(\n apduResponse: ApduResponse,\n ): CommandResult<SignEIP7702AuthorizationCommandResponse, EthErrorCodes> {\n return Maybe.fromNullable(\n this.errorHelper.getError(apduResponse),\n ).orDefaultLazy(() => {\n const parser = new ApduParser(apduResponse);\n\n // The data is returned only for the last chunk\n const v = parser.extract8BitUInt();\n if (v === undefined) {\n return CommandResultFactory({ data: Nothing });\n }\n\n const r = parser.encodeToHexaString(\n parser.extractFieldByLength(R_LENGTH),\n true,\n );\n if (!r) {\n return CommandResultFactory({\n error: new InvalidStatusWordError(\"R is missing\"),\n });\n }\n\n const s = parser.encodeToHexaString(\n parser.extractFieldByLength(S_LENGTH),\n true,\n );\n if (!s) {\n return CommandResultFactory({\n error: new InvalidStatusWordError(\"S is missing\"),\n });\n }\n\n return CommandResultFactory({\n data: Just({\n r,\n s,\n v,\n }),\n });\n });\n }\n}\n"],
5
- "mappings": "AACA,OAEE,eAAAA,EAEA,cAAAC,EAIA,wBAAAC,EACA,0BAAAC,MACK,kCACP,OAAS,sBAAAC,MAA0B,yBACnC,OAAS,QAAAC,EAAM,SAAAC,EAAO,WAAAC,MAAe,YAIrC,OACE,kBAAAC,EACA,6BAAAC,MAEK,uBAEP,MAAMC,EAAW,GACXC,EAAW,GAqBV,MAAMC,CAOb,CACW,KACQ,YAAc,IAAIR,EAGjCI,EAAgBC,CAAyB,EAE3C,YAAYI,EAA2C,CACrD,KAAK,KAAOA,CACd,CAEA,SAAgB,CACd,KAAM,CAAE,KAAAC,EAAM,aAAAC,CAAa,EAAI,KAAK,KAC9BC,EAAgD,CACpD,IAAK,IACL,IAAK,GACL,GAAID,EAAe,EAAO,EAC1B,GAAI,CACN,EAEA,OAAO,IAAIf,EAAYgB,CAA4B,EAChD,gBAAgBF,CAAI,EACpB,MAAM,CACX,CAEA,cACEG,EACuE,CACvE,OAAOX,EAAM,aACX,KAAK,YAAY,SAASW,CAAY,CACxC,EAAE,cAAc,IAAM,CACpB,MAAMC,EAAS,IAAIjB,EAAWgB,CAAY,EAGpCE,EAAID,EAAO,gBAAgB,EACjC,GAAIC,IAAM,OACR,OAAOjB,EAAqB,CAAE,KAAMK,CAAQ,CAAC,EAG/C,MAAMa,EAAIF,EAAO,mBACfA,EAAO,qBAAqBR,CAAQ,EACpC,EACF,EACA,GAAI,CAACU,EACH,OAAOlB,EAAqB,CAC1B,MAAO,IAAIC,EAAuB,cAAc,CAClD,CAAC,EAGH,MAAMkB,EAAIH,EAAO,mBACfA,EAAO,qBAAqBP,CAAQ,EACpC,EACF,EACA,OAAKU,EAMEnB,EAAqB,CAC1B,KAAMG,EAAK,CACT,EAAAe,EACA,EAAAC,EACA,EAAAF,CACF,CAAC,CACH,CAAC,EAXQjB,EAAqB,CAC1B,MAAO,IAAIC,EAAuB,cAAc,CAClD,CAAC,CAUL,CAAC,CACH,CACF",
6
- "names": ["ApduBuilder", "ApduParser", "CommandResultFactory", "InvalidStatusWordError", "CommandErrorHelper", "Just", "Maybe", "Nothing", "ETH_APP_ERRORS", "EthAppCommandErrorFactory", "R_LENGTH", "S_LENGTH", "SignEIP7702AuthorizationCommand", "args", "data", "isFirstChunk", "signEIP7702AuthorizationArgs", "apduResponse", "parser", "v", "r", "s"]
7
- }
@@ -1,2 +0,0 @@
1
- import{CommandResultFactory as o,InvalidStatusWordError as x,isSuccessCommandResult as c}from"@ledgerhq/device-management-kit";import{Just as i,Nothing as u}from"purify-ts";import{SignEIP7702AuthorizationCommand as s}from"./SignAuthorizationDelegationCommand";const n=Uint8Array.from([224,52,1,0,8,0,6,76,101,100,103,101,114]),d=Uint8Array.from([224,52,0,0,8,0,6,76,101,100,103,101,114]),a=new Uint8Array([27,151,164,202,143,105,70,51,89,38,1,245,162,62,11,204,85,60,157,10,144,211,163,66,45,87,85,8,169,40,152,185,110,105,80,208,46,116,233,193,2,193,100,162,37,83,48,130,202,189,216,144,239,196,99,246,127,96,206,254,140,63,135,207,206]);describe("SignEIP7702AuthorizationCommand",()=>{describe("getApdu",()=>{it("should return the first chunk raw APDU",()=>{const e={data:n.slice(5),isFirstChunk:!0},t=new s(e).getApdu();expect(t.getRawApdu()).toStrictEqual(n)}),it("should return the next chunk raw APDU",()=>{const e={data:n.slice(5),isFirstChunk:!1},t=new s(e).getApdu();expect(t.getRawApdu()).toStrictEqual(d)})}),describe("parseResponse",()=>{it("should return an error if the response status code is invalid",()=>{const e={data:Buffer.from([]),statusCode:Buffer.from([106,128])},t=new s({data:Uint8Array.from([]),isFirstChunk:!0}).parseResponse(e);expect(c(t)).toBe(!1)}),it("should return success without result for first chunk",()=>{const e={statusCode:Buffer.from([144,0]),data:Buffer.from([])},t=new s({data:Uint8Array.from([]),isFirstChunk:!0}).parseResponse(e);expect(t).toStrictEqual(o({data:u}))}),it("should return success if the response signature is valid",()=>{const e={statusCode:Buffer.from([144,0]),data:a},t=new s({data:Uint8Array.from([]),isFirstChunk:!0}).parseResponse(e);expect(t).toStrictEqual(o({data:i({r:"0x97a4ca8f694633592601f5a23e0bcc553c9d0a90d3a3422d575508a92898b96e",s:"0x6950d02e74e9c102c164a225533082cabdd890efc463f67f60cefe8c3f87cfce",v:27})}))}),it("should return an error if r is missing",()=>{const e={statusCode:Buffer.from([144,0]),data:a.slice(0,32)},t=new s({data:Uint8Array.from([]),isFirstChunk:!0}).parseResponse(e);expect(t).toStrictEqual(o({error:new x("R is missing")}))}),it("should return an error if s is missing",()=>{const e={statusCode:Buffer.from([144,0]),data:a.slice(0,64)},t=new s({data:Uint8Array.from([]),isFirstChunk:!0}).parseResponse(e);expect(t).toStrictEqual(o({error:new x("S is missing")}))})})});
2
- //# sourceMappingURL=SignAuthorizationDelegationCommand.test.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../../../src/internal/app-binder/command/SignAuthorizationDelegationCommand.test.ts"],
4
- "sourcesContent": ["import {\n type ApduResponse,\n CommandResultFactory,\n InvalidStatusWordError,\n isSuccessCommandResult,\n} from \"@ledgerhq/device-management-kit\";\nimport { Just, Nothing } from \"purify-ts\";\n\nimport {\n SignEIP7702AuthorizationCommand,\n type SignEIP7702AuthorizationCommandArgs,\n} from \"./SignAuthorizationDelegationCommand\";\n\nconst FIRST_CHUNK_APDU = Uint8Array.from([\n 0xe0, 0x34, 0x01, 0x00, 0x08, 0x00, 0x06, 0x4c, 0x65, 0x64, 0x67, 0x65, 0x72,\n]);\n\nconst NEXT_CHUNK_APDU = Uint8Array.from([\n 0xe0, 0x34, 0x00, 0x00, 0x08, 0x00, 0x06, 0x4c, 0x65, 0x64, 0x67, 0x65, 0x72,\n]);\n\nconst SUCCESS_RESPONSE = new Uint8Array([\n 0x1b, 0x97, 0xa4, 0xca, 0x8f, 0x69, 0x46, 0x33, 0x59, 0x26, 0x01, 0xf5, 0xa2,\n 0x3e, 0x0b, 0xcc, 0x55, 0x3c, 0x9d, 0x0a, 0x90, 0xd3, 0xa3, 0x42, 0x2d, 0x57,\n 0x55, 0x08, 0xa9, 0x28, 0x98, 0xb9, 0x6e, 0x69, 0x50, 0xd0, 0x2e, 0x74, 0xe9,\n 0xc1, 0x02, 0xc1, 0x64, 0xa2, 0x25, 0x53, 0x30, 0x82, 0xca, 0xbd, 0xd8, 0x90,\n 0xef, 0xc4, 0x63, 0xf6, 0x7f, 0x60, 0xce, 0xfe, 0x8c, 0x3f, 0x87, 0xcf, 0xce,\n]);\n\ndescribe(\"SignEIP7702AuthorizationCommand\", () => {\n describe(\"getApdu\", () => {\n it(\"should return the first chunk raw APDU\", () => {\n // GIVEN\n const args: SignEIP7702AuthorizationCommandArgs = {\n data: FIRST_CHUNK_APDU.slice(5),\n isFirstChunk: true,\n };\n // WHEN\n const command = new SignEIP7702AuthorizationCommand(args);\n const apdu = command.getApdu();\n // THEN\n expect(apdu.getRawApdu()).toStrictEqual(FIRST_CHUNK_APDU);\n });\n\n it(\"should return the next chunk raw APDU\", () => {\n // GIVEN\n const args: SignEIP7702AuthorizationCommandArgs = {\n data: FIRST_CHUNK_APDU.slice(5),\n isFirstChunk: false,\n };\n // WHEN\n const command = new SignEIP7702AuthorizationCommand(args);\n const apdu = command.getApdu();\n // THEN\n expect(apdu.getRawApdu()).toStrictEqual(NEXT_CHUNK_APDU);\n });\n });\n\n describe(\"parseResponse\", () => {\n it(\"should return an error if the response status code is invalid\", () => {\n // GIVEN\n const response: ApduResponse = {\n data: Buffer.from([]),\n statusCode: Buffer.from([0x6a, 0x80]), // Invalid status code\n };\n // WHEN\n const command = new SignEIP7702AuthorizationCommand({\n data: Uint8Array.from([]),\n isFirstChunk: true,\n });\n const result = command.parseResponse(response);\n // THEN\n expect(isSuccessCommandResult(result)).toBe(false);\n });\n\n it(\"should return success without result for first chunk\", () => {\n // GIVEN\n const response: ApduResponse = {\n statusCode: Buffer.from([0x90, 0x00]), // Success status code\n data: Buffer.from([]),\n };\n // WHEN\n const command = new SignEIP7702AuthorizationCommand({\n data: Uint8Array.from([]),\n isFirstChunk: true,\n });\n const result = command.parseResponse(response);\n // THEN\n expect(result).toStrictEqual(\n CommandResultFactory({\n data: Nothing,\n }),\n );\n });\n\n it(\"should return success if the response signature is valid\", () => {\n // GIVEN\n const response: ApduResponse = {\n statusCode: Buffer.from([0x90, 0x00]), // Success status code\n data: SUCCESS_RESPONSE,\n };\n // WHEN\n const command = new SignEIP7702AuthorizationCommand({\n data: Uint8Array.from([]),\n isFirstChunk: true,\n });\n const result = command.parseResponse(response);\n // THEN\n expect(result).toStrictEqual(\n CommandResultFactory({\n data: Just({\n r: \"0x97a4ca8f694633592601f5a23e0bcc553c9d0a90d3a3422d575508a92898b96e\",\n s: \"0x6950d02e74e9c102c164a225533082cabdd890efc463f67f60cefe8c3f87cfce\",\n v: 27,\n }),\n }),\n );\n });\n\n it(\"should return an error if r is missing\", () => {\n // GIVEN\n const response: ApduResponse = {\n statusCode: Buffer.from([0x90, 0x00]), // Success status code\n data: SUCCESS_RESPONSE.slice(0, 32),\n };\n // WHEN\n const command = new SignEIP7702AuthorizationCommand({\n data: Uint8Array.from([]),\n isFirstChunk: true,\n });\n const result = command.parseResponse(response);\n // THEN\n expect(result).toStrictEqual(\n CommandResultFactory({\n error: new InvalidStatusWordError(\"R is missing\"),\n }),\n );\n });\n\n it(\"should return an error if s is missing\", () => {\n // GIVEN\n const response: ApduResponse = {\n statusCode: Buffer.from([0x90, 0x00]), // Success status code\n data: SUCCESS_RESPONSE.slice(0, 64),\n };\n // WHEN\n const command = new SignEIP7702AuthorizationCommand({\n data: Uint8Array.from([]),\n isFirstChunk: true,\n });\n const result = command.parseResponse(response);\n // THEN\n expect(result).toStrictEqual(\n CommandResultFactory({\n error: new InvalidStatusWordError(\"S is missing\"),\n }),\n );\n });\n });\n});\n"],
5
- "mappings": "AAAA,OAEE,wBAAAA,EACA,0BAAAC,EACA,0BAAAC,MACK,kCACP,OAAS,QAAAC,EAAM,WAAAC,MAAe,YAE9B,OACE,mCAAAC,MAEK,uCAEP,MAAMC,EAAmB,WAAW,KAAK,CACvC,IAAM,GAAM,EAAM,EAAM,EAAM,EAAM,EAAM,GAAM,IAAM,IAAM,IAAM,IAAM,GAC1E,CAAC,EAEKC,EAAkB,WAAW,KAAK,CACtC,IAAM,GAAM,EAAM,EAAM,EAAM,EAAM,EAAM,GAAM,IAAM,IAAM,IAAM,IAAM,GAC1E,CAAC,EAEKC,EAAmB,IAAI,WAAW,CACtC,GAAM,IAAM,IAAM,IAAM,IAAM,IAAM,GAAM,GAAM,GAAM,GAAM,EAAM,IAAM,IACxE,GAAM,GAAM,IAAM,GAAM,GAAM,IAAM,GAAM,IAAM,IAAM,IAAM,GAAM,GAAM,GACxE,GAAM,EAAM,IAAM,GAAM,IAAM,IAA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atusWordError", "isSuccessCommandResult", "Just", "Nothing", "SignEIP7702AuthorizationCommand", "FIRST_CHUNK_APDU", "NEXT_CHUNK_APDU", "SUCCESS_RESPONSE", "args", "apdu", "response", "result"]
7
- }
@@ -1,2 +0,0 @@
1
- import{ByteArrayBuilder as u,CommandResultFactory as d,InvalidStatusWordError as m,isSuccessCommandResult as c}from"@ledgerhq/device-management-kit";import{DerivationPathUtils as I}from"@ledgerhq/signer-utils";import{SignEIP7702AuthorizationCommand as T}from"../../app-binder/command/SignAuthorizationDelegationCommand";import{SendCommandInChunksTask as h}from"./SendCommandInChunksTask";const l=0,p=1,g=2,A=3;class D{constructor(e,o){this.api=e;this.args=o}async run(){const{derivationPath:e,chainId:o,address:i,nonce:s}=this.args,a=I.splitPath(e),t=this.buildData(a,o,i,s),n=await new h(this.api,{data:t,commandFactory:r=>new T({data:r.chunkedData,isFirstChunk:r.isFirstChunk})}).run();return c(n)?n.data.mapOrDefault(r=>d({data:r}),d({error:new m("no signature returned")})):n}buildData(e,o,i,s){const a=new u;a.add8BitUIntToData(e.length),e.forEach(r=>{a.add32BitUIntToData(r)});const t=new u;t.encodeInTLVFromBuffer(l,Uint8Array.from([1])),t.encodeInTLVFromHexa(p,i),t.encodeInTLVFromUInt64(g,o),t.encodeInTLVFromUInt64(A,s);const n=t.build();return a.add16BitUIntToData(n.length).addBufferToData(n).build()}}export{D as SendSignAuthorizationDelegationTask};
2
- //# sourceMappingURL=SendSignAuthorizationDelegationTask.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../../../src/internal/app-binder/task/SendSignAuthorizationDelegationTask.ts"],
4
- "sourcesContent": ["import {\n ByteArrayBuilder,\n type CommandResult,\n CommandResultFactory,\n type InternalApi,\n InvalidStatusWordError,\n isSuccessCommandResult,\n} from \"@ledgerhq/device-management-kit\";\nimport { DerivationPathUtils } from \"@ledgerhq/signer-utils\";\n\nimport { type Signature } from \"@api/model/Signature\";\nimport {\n SignEIP7702AuthorizationCommand,\n type SignEIP7702AuthorizationCommandResponse,\n} from \"@internal/app-binder/command/SignAuthorizationDelegationCommand\";\nimport { type EthErrorCodes } from \"@internal/app-binder/command/utils/ethAppErrors\";\n\nimport { SendCommandInChunksTask } from \"./SendCommandInChunksTask\";\n\nconst TAG_STRUCT_EIP7702_VERSION: number = 0x00;\nconst TAG_STRUCT_EIP7702_DELEGATE_ADDR: number = 0x01;\nconst TAG_STRUCT_EIP7702_CHAIN_ID: number = 0x02;\nconst TAG_STRUCT_EIP7702_NONCE: number = 0x03;\n\ntype SendSignAuthorizationDelegationTaskArgs = {\n derivationPath: string;\n chainId: number;\n address: string;\n nonce: number;\n};\n\nexport class SendSignAuthorizationDelegationTask {\n constructor(\n private api: InternalApi,\n private args: SendSignAuthorizationDelegationTaskArgs,\n ) {}\n\n async run(): Promise<CommandResult<Signature, EthErrorCodes>> {\n const { derivationPath, chainId, address, nonce } = this.args;\n const paths = DerivationPathUtils.splitPath(derivationPath);\n\n const buffer = this.buildData(paths, chainId, address, nonce);\n\n const result =\n await new SendCommandInChunksTask<SignEIP7702AuthorizationCommandResponse>(\n this.api,\n {\n data: buffer,\n commandFactory: (args) =>\n new SignEIP7702AuthorizationCommand({\n data: args.chunkedData,\n isFirstChunk: args.isFirstChunk,\n }),\n },\n ).run();\n\n if (!isSuccessCommandResult(result)) {\n return result;\n }\n\n return result.data.mapOrDefault(\n (data) => CommandResultFactory({ data }),\n CommandResultFactory({\n error: new InvalidStatusWordError(\"no signature returned\"),\n }),\n );\n }\n\n buildData(\n paths: number[],\n chainId: number,\n address: string,\n nonce: number,\n ): Uint8Array {\n const builder = new ByteArrayBuilder();\n // add the derivation paths length\n builder.add8BitUIntToData(paths.length);\n // add every derivation path\n paths.forEach((path) => {\n builder.add32BitUIntToData(path);\n });\n\n // Send EIP7702 Auth structure\n const builderStruct = new ByteArrayBuilder();\n builderStruct.encodeInTLVFromBuffer(\n TAG_STRUCT_EIP7702_VERSION,\n Uint8Array.from([0x01]),\n );\n // Add address\n builderStruct.encodeInTLVFromHexa(\n TAG_STRUCT_EIP7702_DELEGATE_ADDR,\n address,\n );\n // Add chainId\n builderStruct.encodeInTLVFromUInt64(TAG_STRUCT_EIP7702_CHAIN_ID, chainId);\n // Add nonce\n builderStruct.encodeInTLVFromUInt64(TAG_STRUCT_EIP7702_NONCE, nonce);\n const structBuffer = builderStruct.build();\n\n return builder\n .add16BitUIntToData(structBuffer.length)\n .addBufferToData(structBuffer)\n .build();\n }\n}\n"],
5
- "mappings": "AAAA,OACE,oBAAAA,EAEA,wBAAAC,EAEA,0BAAAC,EACA,0BAAAC,MACK,kCACP,OAAS,uBAAAC,MAA2B,yBAGpC,OACE,mCAAAC,MAEK,kEAGP,OAAS,2BAAAC,MAA+B,4BAExC,MAAMC,EAAqC,EACrCC,EAA2C,EAC3CC,EAAsC,EACtCC,EAAmC,EASlC,MAAMC,CAAoC,CAC/C,YACUC,EACAC,EACR,CAFQ,SAAAD,EACA,UAAAC,CACP,CAEH,MAAM,KAAwD,CAC5D,KAAM,CAAE,eAAAC,EAAgB,QAAAC,EAAS,QAAAC,EAAS,MAAAC,CAAM,EAAI,KAAK,KACnDC,EAAQd,EAAoB,UAAUU,CAAc,EAEpDK,EAAS,KAAK,UAAUD,EAAOH,EAASC,EAASC,CAAK,EAEtDG,EACJ,MAAM,IAAId,EACR,KAAK,IACL,CACE,KAAMa,EACN,eAAiBN,GACf,IAAIR,EAAgC,CAClC,KAAMQ,EAAK,YACX,aAAcA,EAAK,YACrB,CAAC,CACL,CACF,EAAE,IAAI,EAER,OAAKV,EAAuBiB,CAAM,EAI3BA,EAAO,KAAK,aAChBC,GAASpB,EAAqB,CAAE,KAAAoB,CAAK,CAAC,EACvCpB,EAAqB,CACnB,MAAO,IAAIC,EAAuB,uBAAuB,CAC3D,CAAC,CACH,EARSkB,CASX,CAEA,UACEF,EACAH,EACAC,EACAC,EACY,CACZ,MAAMK,EAAU,IAAItB,EAEpBsB,EAAQ,kBAAkBJ,EAAM,MAAM,EAEtCA,EAAM,QAASK,GAAS,CACtBD,EAAQ,mBAAmBC,CAAI,CACjC,CAAC,EAGD,MAAMC,EAAgB,IAAIxB,EAC1BwB,EAAc,sBACZjB,EACA,WAAW,KAAK,CAAC,CAAI,CAAC,CACxB,EAEAiB,EAAc,oBACZhB,EACAQ,CACF,EAEAQ,EAAc,sBAAsBf,EAA6BM,CAAO,EAExES,EAAc,sBAAsBd,EAA0BO,CAAK,EACnE,MAAMQ,EAAeD,EAAc,MAAM,EAEzC,OAAOF,EACJ,mBAAmBG,EAAa,MAAM,EACtC,gBAAgBA,CAAY,EAC5B,MAAM,CACX,CACF",
6
- "names": ["ByteArrayBuilder", "CommandResultFactory", "InvalidStatusWordError", "isSuccessCommandResult", "DerivationPathUtils", "SignEIP7702AuthorizationCommand", "SendCommandInChunksTask", "TAG_STRUCT_EIP7702_VERSION", "TAG_STRUCT_EIP7702_DELEGATE_ADDR", "TAG_STRUCT_EIP7702_CHAIN_ID", "TAG_STRUCT_EIP7702_NONCE", "SendSignAuthorizationDelegationTask", "api", "args", "derivationPath", "chainId", "address", "nonce", "paths", "buffer", "result", "data", "builder", "path", "builderStruct", "structBuffer"]
7
- }
@@ -1,2 +0,0 @@
1
- import{CommandResultFactory as a}from"@ledgerhq/device-management-kit";import{InvalidStatusWordError as o}from"@ledgerhq/device-management-kit";import{Just as m,Nothing as l}from"purify-ts";import{SignEIP7702AuthorizationCommand as r}from"../../app-binder/command/SignAuthorizationDelegationCommand";import{makeDeviceActionInternalApiMock as f}from"../../app-binder/device-action/__test-utils__/makeInternalApi";import{SendSignAuthorizationDelegationTask as d}from"./SendSignAuthorizationDelegationTask";const u=new Uint8Array([5,128,0,0,44,128,0,0,60,128,0,0,0,0,0,0,0,0,0,0,0,0,45,0,1,1,1,20,76,210,65,232,209,81,14,48,178,7,99,151,175,199,80,138,229,156,102,201,2,8,0,0,0,0,0,0,0,1,3,8,0,0,0,0,0,0,0,41]),i=new Uint8Array([5,128,0,0,44,128,0,0,60,128,0,0,0,0,0,0,0,0,0,0,0,1,9,0,1,1,1,240,76,210,65,232,209,81,14,48,178,7,99,151,175,199,80,138,229,156,102,201,76,210,65,232,209,81,14,48,178,7,99,151,175,199,80,138,229,156,102,201,76,210,65,232,209,81,14,48,178,7,99,151,175,199,80,138,229,156,102,201,76,210,65,232,209,81,14,48,178,7,99,151,175,199,80,138,229,156,102,201,76,210,65,232,209,81,14,48,178,7,99,151,175,199,80,138,229,156,102,201,76,210,65,232,209,81,14,48,178,7,99,151,175,199,80,138,229,156,102,201,76,210,65,232,209,81,14,48,178,7,99,151,175,199,80,138,229,156,102,201,76,210,65,232,209,81,14,48,178,7,99,151,175,199,80,138,229,156,102,201,76,210,65,232,209,81,14,48,178,7,99,151,175,199,80,138,229,156,102,201,76,210,65,232,209,81,14,48,178,7,99,151,175,199,80,138,229,156,102,201,76,210,65,232,209,81,14,48,178,7,99,151,175,199,80,138,229,156,102,201,76,210,65,232,209,81,14,48,178,7,99,151,175,199,80,138,229,156,102,201,2,8,0,0,0,0,0,0,0,1,3,8,0,0,0,0,0,0,0,41]);describe("SendSignAuthorizationDelegationTask",()=>{const x=f(),n={v:27,r:"0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",s:"0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef"},s=a({data:m(n)}),t=a({data:l});beforeEach(()=>{vi.resetAllMocks()}),describe("run",()=>{it("should send the message in chunks",async()=>{const e={derivationPath:"44'/60'/0'/0/0",address:"0x4Cd241E8d1510e30b2076397afc7508Ae59C66c9",chainId:1,nonce:41};x.sendCommand.mockResolvedValueOnce(s),x.sendCommand.mockResolvedValueOnce(t);const c=await new d(x,e).run();expect(x.sendCommand.mock.calls).toHaveLength(1),expect(x.sendCommand.mock.calls[0][0]).toStrictEqual(new r({data:new Uint8Array(u),isFirstChunk:!0})),expect(c.data).toStrictEqual(n)}),it("should send the long message in chunks",async()=>{const e={derivationPath:"44'/60'/0'/0/0",address:"0x4Cd241E8d1510e30b2076397afc7508Ae59C66c94Cd241E8d1510e30b2076397afc7508Ae59C66c94Cd241E8d1510e30b2076397afc7508Ae59C66c94Cd241E8d1510e30b2076397afc7508Ae59C66c94Cd241E8d1510e30b2076397afc7508Ae59C66c94Cd241E8d1510e30b2076397afc7508Ae59C66c94Cd241E8d1510e30b2076397afc7508Ae59C66c94Cd241E8d1510e30b2076397afc7508Ae59C66c94Cd241E8d1510e30b2076397afc7508Ae59C66c94Cd241E8d1510e30b2076397afc7508Ae59C66c94Cd241E8d1510e30b2076397afc7508Ae59C66c94Cd241E8d1510e30b2076397afc7508Ae59C66c9",chainId:1,nonce:41};x.sendCommand.mockResolvedValueOnce(t),x.sendCommand.mockResolvedValueOnce(s);const c=await new d(x,e).run();expect(x.sendCommand.mock.calls).toHaveLength(2),expect(x.sendCommand.mock.calls[0][0]).toStrictEqual(new r({data:i.slice(0,255),isFirstChunk:!0})),expect(x.sendCommand.mock.calls[1][0]).toStrictEqual(new r({data:i.slice(255,510),isFirstChunk:!1})),expect(c.data).toStrictEqual(n)}),it("should return an error if the command fails",async()=>{const e={derivationPath:"44'/60'/0'/0/0",address:"0x4Cd241E8d1510e30b2076397afc7508Ae59C66c9",chainId:1,nonce:41};x.sendCommand.mockResolvedValueOnce(a({error:new o("An error")}));const c=await new d(x,e).run();expect(c).toStrictEqual(a({error:new o("An error")}))}),it("should return an error if the command returns no data",async()=>{const e={derivationPath:"44'/60'/0'/0/0",address:"0x4Cd241E8d1510e30b2076397afc7508Ae59C66c9",chainId:1,nonce:41};x.sendCommand.mockResolvedValueOnce(t);const c=await new d(x,e).run();expect(c).toStrictEqual(a({error:new o("no signature returned")}))})})});
2
- //# sourceMappingURL=SendSignAuthorizationDelegationTask.test.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../../../src/internal/app-binder/task/SendSignAuthorizationDelegationTask.test.ts"],
4
- "sourcesContent": ["import { CommandResultFactory } from \"@ledgerhq/device-management-kit\";\nimport { InvalidStatusWordError } from \"@ledgerhq/device-management-kit\";\nimport { Just, Nothing } from \"purify-ts\";\n\nimport { SignEIP7702AuthorizationCommand } from \"@internal/app-binder/command/SignAuthorizationDelegationCommand\";\nimport { makeDeviceActionInternalApiMock } from \"@internal/app-binder/device-action/__test-utils__/makeInternalApi\";\n\nimport { SendSignAuthorizationDelegationTask } from \"./SendSignAuthorizationDelegationTask\";\n\nconst SMALL_MESSAGE_DATA = new Uint8Array([\n 0x05, 0x80, 0x00, 0x00, 0x2c, 0x80, 0x00, 0x00, 0x3c, 0x80, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2d, 0x00, 0x01, 0x01,\n 0x01, 0x14, 0x4c, 0xd2, 0x41, 0xe8, 0xd1, 0x51, 0x0e, 0x30, 0xb2, 0x07, 0x63,\n 0x97, 0xaf, 0xc7, 0x50, 0x8a, 0xe5, 0x9c, 0x66, 0xc9, 0x02, 0x08, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x29,\n]);\n\nconst LONG_MESSAGE_DATA = new Uint8Array([\n 0x05, 0x80, 0x00, 0x00, 0x2c, 0x80, 0x00, 0x00, 0x3c, 0x80, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x09, 0x00, 0x01, 0x01,\n 0x01, 0xf0, 0x4c, 0xd2, 0x41, 0xe8, 0xd1, 0x51, 0x0e, 0x30, 0xb2, 0x07, 0x63,\n 0x97, 0xaf, 0xc7, 0x50, 0x8a, 0xe5, 0x9c, 0x66, 0xc9, 0x4c, 0xd2, 0x41, 0xe8,\n 0xd1, 0x51, 0x0e, 0x30, 0xb2, 0x07, 0x63, 0x97, 0xaf, 0xc7, 0x50, 0x8a, 0xe5,\n 0x9c, 0x66, 0xc9, 0x4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\n 0xc9, 0x4c, 0xd2, 0x41, 0xe8, 0xd1, 0x51, 0x0e, 0x30, 0xb2, 0x07, 0x63, 0x97,\n 0xaf, 0xc7, 0x50, 0x8a, 0xe5, 0x9c, 0x66, 0xc9, 0x02, 0x08, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x29,\n]);\n\ndescribe(\"SendSignAuthorizationDelegationTask\", () => {\n const apiMock = makeDeviceActionInternalApiMock();\n const signature = {\n v: 27,\n r: \"0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef\",\n s: \"0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef\",\n };\n const resultOk = CommandResultFactory({\n data: Just(signature),\n });\n const resultNothing = CommandResultFactory({ data: Nothing });\n\n beforeEach(() => {\n vi.resetAllMocks();\n });\n\n describe(\"run\", () => {\n it(\"should send the message in chunks\", async () => {\n // GIVEN\n const args = {\n derivationPath: \"44'/60'/0'/0/0\",\n address: \"0x4Cd241E8d1510e30b2076397afc7508Ae59C66c9\",\n chainId: 1,\n nonce: 41,\n };\n apiMock.sendCommand.mockResolvedValueOnce(resultOk);\n apiMock.sendCommand.mockResolvedValueOnce(resultNothing);\n\n // WHEN\n const result = await new SendSignAuthorizationDelegationTask(\n apiMock,\n args,\n ).run();\n\n // THEN\n expect(apiMock.sendCommand.mock.calls).toHaveLength(1);\n expect(apiMock.sendCommand.mock.calls[0]![0]).toStrictEqual(\n new SignEIP7702AuthorizationCommand({\n data: new Uint8Array(SMALL_MESSAGE_DATA),\n isFirstChunk: true,\n }),\n );\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n expect((result as any).data).toStrictEqual(signature);\n });\n\n it(\"should send the long message in chunks\", async () => {\n // GIVEN\n const args = {\n derivationPath: \"44'/60'/0'/0/0\",\n address:\n \"0x4Cd241E8d1510e30b2076397afc7508Ae59C66c94Cd241E8d1510e30b2076397afc7508Ae59C66c94Cd241E8d1510e30b2076397afc7508Ae59C66c94Cd241E8d1510e30b2076397afc7508Ae59C66c94Cd241E8d1510e30b2076397afc7508Ae59C66c94Cd241E8d1510e30b2076397afc7508Ae59C66c94Cd241E8d1510e30b2076397afc7508Ae59C66c94Cd241E8d1510e30b2076397afc7508Ae59C66c94Cd241E8d1510e30b2076397afc7508Ae59C66c94Cd241E8d1510e30b2076397afc7508Ae59C66c94Cd241E8d1510e30b2076397afc7508Ae59C66c94Cd241E8d1510e30b2076397afc7508Ae59C66c9\",\n chainId: 1,\n nonce: 41,\n };\n apiMock.sendCommand.mockResolvedValueOnce(resultNothing);\n apiMock.sendCommand.mockResolvedValueOnce(resultOk);\n\n // WHEN\n const result = await new SendSignAuthorizationDelegationTask(\n apiMock,\n args,\n ).run();\n\n // THEN\n expect(apiMock.sendCommand.mock.calls).toHaveLength(2);\n expect(apiMock.sendCommand.mock.calls[0]![0]).toStrictEqual(\n new SignEIP7702AuthorizationCommand({\n data: LONG_MESSAGE_DATA.slice(0, 255),\n isFirstChunk: true,\n }),\n );\n expect(apiMock.sendCommand.mock.calls[1]![0]).toStrictEqual(\n new SignEIP7702AuthorizationCommand({\n data: LONG_MESSAGE_DATA.slice(255, 510),\n isFirstChunk: false,\n }),\n );\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n expect((result as any).data).toStrictEqual(signature);\n });\n\n it(\"should return an error if the command fails\", async () => {\n // GIVEN\n const args = {\n derivationPath: \"44'/60'/0'/0/0\",\n address: \"0x4Cd241E8d1510e30b2076397afc7508Ae59C66c9\",\n chainId: 1,\n nonce: 41,\n };\n apiMock.sendCommand.mockResolvedValueOnce(\n CommandResultFactory({\n error: new InvalidStatusWordError(\"An error\"),\n }),\n );\n\n // WHEN\n const result = await new SendSignAuthorizationDelegationTask(\n apiMock,\n args,\n ).run();\n\n // THEN\n expect(result).toStrictEqual(\n CommandResultFactory({\n error: new InvalidStatusWordError(\"An error\"),\n }),\n );\n });\n\n it(\"should return an error if the command returns no data\", async () => {\n // GIVEN\n const args = {\n derivationPath: \"44'/60'/0'/0/0\",\n address: \"0x4Cd241E8d1510e30b2076397afc7508Ae59C66c9\",\n chainId: 1,\n nonce: 41,\n };\n apiMock.sendCommand.mockResolvedValueOnce(resultNothing);\n\n // WHEN\n const result = await new SendSignAuthorizationDelegationTask(\n apiMock,\n args,\n ).run();\n\n // THEN\n expect(result).toStrictEqual(\n CommandResultFactory({\n error: new InvalidStatusWordError(\"no signature returned\"),\n }),\n );\n });\n });\n});\n"],
5
- "mappings": "AAAA,OAAS,wBAAAA,MAA4B,kCACrC,OAAS,0BAAAC,MAA8B,kCACvC,OAAS,QAAAC,EAAM,WAAAC,MAAe,YAE9B,OAAS,mCAAAC,MAAuC,kEAChD,OAAS,mCAAAC,MAAuC,oEAEhD,OAAS,uCAAAC,MAA2C,wCAEpD,MAAMC,EAAqB,IAAI,WAAW,CACxC,EAAM,IAAM,EAAM,EAAM,GAAM,IAAM,EAAM,EAAM,GAAM,IAAM,EAAM,EAAM,EACxE,EAAM,EAAM,EAAM,EAAM,EAAM,EAAM,EAAM,EAAM,EAAM,GAAM,EAAM,EAAM,EACxE,EAAM,GAAM,GAAM,IAAM,GAAM,IAAM,IAAM,GAAM,GAAM,GAAM,IAAM,EAAM,GACxE,IAAM,IAAM,IAAM,GAAM,IAAM,IAAM,IAAM,IAAM,IAAM,EAAM,EAAM,EAAM,EACxE,EAAM,EAAM,EAAM,EAAM,EAAM,EAAM,EAAM,EAAM,EAAM,EAAM,EAAM,EAAM,EACxE,EAAM,EAAM,EACd,CAAC,EAEKC,EAAoB,IAAI,WAAW,CACvC,EAAM,IAAM,EAAM,EAAM,GAAM,IAAM,EAAM,EAAM,GAAM,IAAM,EAAM,EAAM,EACxE,EAAM,EAAM,EAAM,EAAM,EAAM,EAAM,EAAM,EAAM,EAAM,EAAM,EAAM,EAAM,EACxE,EAAM,IAAM,GAAM,IAAM,GAAM,IAAM,IAAM,GAAM,GAAM,GAAM,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EIP7702AuthorizationCommand", "makeDeviceActionInternalApiMock", "SendSignAuthorizationDelegationTask", "SMALL_MESSAGE_DATA", "LONG_MESSAGE_DATA", "apiMock", "signature", "resultOk", "resultNothing", "args", "result"]
7
- }
@@ -1,2 +0,0 @@
1
- import{ContainerModule as e}from"inversify";import{eip7702Types as i}from"../../eip7702/di/eip7702Types";import{SignDelegationAuthorizationUseCase as t}from"../../eip7702/use-case/SignDelegationAuthorizationUseCase";const p=()=>new e(({bind:o})=>{o(i.SignDelegationAuthorizationUseCase).to(t)});export{p as eip7702ModuleFactory};
2
- //# sourceMappingURL=eip7702Module.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../../../src/internal/eip7702/di/eip7702Module.ts"],
4
- "sourcesContent": ["import { ContainerModule } from \"inversify\";\n\nimport { eip7702Types } from \"@internal/eip7702/di/eip7702Types\";\nimport { SignDelegationAuthorizationUseCase } from \"@internal/eip7702/use-case/SignDelegationAuthorizationUseCase\";\n\nexport const eip7702ModuleFactory = () =>\n new ContainerModule(({ bind }) => {\n bind(eip7702Types.SignDelegationAuthorizationUseCase).to(\n SignDelegationAuthorizationUseCase,\n );\n });\n"],
5
- "mappings": "AAAA,OAAS,mBAAAA,MAAuB,YAEhC,OAAS,gBAAAC,MAAoB,oCAC7B,OAAS,sCAAAC,MAA0C,gEAE5C,MAAMC,EAAuB,IAClC,IAAIH,EAAgB,CAAC,CAAE,KAAAI,CAAK,IAAM,CAChCA,EAAKH,EAAa,kCAAkC,EAAE,GACpDC,CACF,CACF,CAAC",
6
- "names": ["ContainerModule", "eip7702Types", "SignDelegationAuthorizationUseCase", "eip7702ModuleFactory", "bind"]
7
- }
@@ -1,2 +0,0 @@
1
- import{Container as t}from"inversify";import{eip7702ModuleFactory as r}from"./eip7702Module";describe("eip7702ModuleFactory",()=>{describe("Default",()=>{let o,e;beforeEach(()=>{e=r(),o=new t,o.load(e)}),it("should return the eip7702 module",()=>{expect(e).toBeDefined()})})});
2
- //# sourceMappingURL=eip7702Module.test.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../../../src/internal/eip7702/di/eip7702Module.test.ts"],
4
- "sourcesContent": ["import { Container } from \"inversify\";\n\nimport { eip7702ModuleFactory } from \"./eip7702Module\";\n\ndescribe(\"eip7702ModuleFactory\", () => {\n describe(\"Default\", () => {\n let container: Container;\n let mod: ReturnType<typeof eip7702ModuleFactory>;\n beforeEach(() => {\n mod = eip7702ModuleFactory();\n container = new Container();\n container.load(mod);\n });\n\n it(\"should return the eip7702 module\", () => {\n expect(mod).toBeDefined();\n });\n });\n});\n"],
5
- "mappings": "AAAA,OAAS,aAAAA,MAAiB,YAE1B,OAAS,wBAAAC,MAA4B,kBAErC,SAAS,uBAAwB,IAAM,CACrC,SAAS,UAAW,IAAM,CACxB,IAAIC,EACAC,EACJ,WAAW,IAAM,CACfA,EAAMF,EAAqB,EAC3BC,EAAY,IAAIF,EAChBE,EAAU,KAAKC,CAAG,CACpB,CAAC,EAED,GAAG,mCAAoC,IAAM,CAC3C,OAAOA,CAAG,EAAE,YAAY,CAC1B,CAAC,CACH,CAAC,CACH,CAAC",
6
- "names": ["Container", "eip7702ModuleFactory", "container", "mod"]
7
- }
@@ -1,2 +0,0 @@
1
- const e={SignDelegationAuthorizationUseCase:Symbol.for("SignDelegationAuthorizationUseCase")};export{e as eip7702Types};
2
- //# sourceMappingURL=eip7702Types.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../../../src/internal/eip7702/di/eip7702Types.ts"],
4
- "sourcesContent": ["export const eip7702Types = {\n SignDelegationAuthorizationUseCase: Symbol.for(\n \"SignDelegationAuthorizationUseCase\",\n ),\n};\n"],
5
- "mappings": "AAAO,MAAMA,EAAe,CAC1B,mCAAoC,OAAO,IACzC,oCACF,CACF",
6
- "names": ["eip7702Types"]
7
- }
@@ -1,2 +0,0 @@
1
- var u=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var d=(n,r,i,t)=>{for(var p=t>1?void 0:t?c(r,i):r,o=n.length-1,m;o>=0;o--)(m=n[o])&&(p=(t?m(r,i,p):m(p))||p);return t&&p&&u(r,i,p),p},B=(n,r)=>(i,t)=>r(i,t,n);import{inject as A,injectable as h}from"inversify";import{appBinderTypes as a}from"../../app-binder/di/appBinderTypes";let e=class{_appBinder;constructor(r){this._appBinder=r}execute(r,i,t,p){return this._appBinder.signDelegationAuthorization({derivationPath:r,nonce:i,address:t,chainId:p})}};e=d([h(),B(0,A(a.AppBinding))],e);export{e as SignDelegationAuthorizationUseCase};
2
- //# sourceMappingURL=SignDelegationAuthorizationUseCase.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../../../src/internal/eip7702/use-case/SignDelegationAuthorizationUseCase.ts"],
4
- "sourcesContent": ["import { inject, injectable } from \"inversify\";\n\nimport { SignDelegationAuthorizationDAReturnType } from \"@api/app-binder/SignDelegationAuthorizationTypes\";\nimport { appBinderTypes } from \"@internal/app-binder/di/appBinderTypes\";\nimport { EthAppBinder } from \"@internal/app-binder/EthAppBinder\";\n\n@injectable()\nexport class SignDelegationAuthorizationUseCase {\n private _appBinder: EthAppBinder;\n\n constructor(\n @inject(appBinderTypes.AppBinding)\n appBinding: EthAppBinder,\n ) {\n this._appBinder = appBinding;\n }\n\n execute(\n derivationPath: string,\n nonce: number,\n address: string,\n chainId: number,\n ): SignDelegationAuthorizationDAReturnType {\n return this._appBinder.signDelegationAuthorization({\n derivationPath,\n nonce,\n address,\n chainId,\n });\n }\n}\n"],
5
- "mappings": "iOAAA,OAAS,UAAAA,EAAQ,cAAAC,MAAkB,YAGnC,OAAS,kBAAAC,MAAsB,yCAIxB,IAAMC,EAAN,KAAyC,CACtC,WAER,YAEEC,EACA,CACA,KAAK,WAAaA,CACpB,CAEA,QACEC,EACAC,EACAC,EACAC,EACyC,CACzC,OAAO,KAAK,WAAW,4BAA4B,CACjD,eAAAH,EACA,MAAAC,EACA,QAAAC,EACA,QAAAC,CACF,CAAC,CACH,CACF,EAvBaL,EAANM,EAAA,CADNC,EAAW,EAKPC,EAAA,EAAAC,EAAOC,EAAe,UAAU,IAJxBV",
6
- "names": ["inject", "injectable", "appBinderTypes", "SignDelegationAuthorizationUseCase", "appBinding", "derivationPath", "nonce", "address", "chainId", "__decorateClass", "injectable", "__decorateParam", "inject", "appBinderTypes"]
7
- }
@@ -1,2 +0,0 @@
1
- import{SignDelegationAuthorizationUseCase as s}from"./SignDelegationAuthorizationUseCase";describe("SignDelegationAuthorizationUseCase",()=>{it("should call signPersonalMessage on appBinder with the correct arguments",()=>{const e="44'/501'/0'/0'",n="address",i={signDelegationAuthorization:vi.fn()};new s(i).execute(e,42,n,2),expect(i.signDelegationAuthorization).toHaveBeenCalledWith({derivationPath:e,nonce:42,address:n,chainId:2})})});
2
- //# sourceMappingURL=SignDelegationAuthorizationUseCase.test.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../../../src/internal/eip7702/use-case/SignDelegationAuthorizationUseCase.test.ts"],
4
- "sourcesContent": ["import { type EthAppBinder } from \"@internal/app-binder/EthAppBinder\";\n\nimport { SignDelegationAuthorizationUseCase } from \"./SignDelegationAuthorizationUseCase\";\n\ndescribe(\"SignDelegationAuthorizationUseCase\", () => {\n it(\"should call signPersonalMessage on appBinder with the correct arguments\", () => {\n // Given\n const derivationPath = \"44'/501'/0'/0'\";\n const chainId = 2;\n const nonce = 42;\n const address = \"address\";\n const appBinder = {\n signDelegationAuthorization: vi.fn(),\n };\n const signMessageUseCase = new SignDelegationAuthorizationUseCase(\n appBinder as unknown as EthAppBinder,\n );\n\n // When\n signMessageUseCase.execute(derivationPath, nonce, address, chainId);\n\n // Then\n expect(appBinder.signDelegationAuthorization).toHaveBeenCalledWith({\n derivationPath,\n nonce,\n address,\n chainId,\n });\n });\n});\n"],
5
- "mappings": "AAEA,OAAS,sCAAAA,MAA0C,uCAEnD,SAAS,qCAAsC,IAAM,CACnD,GAAG,0EAA2E,IAAM,CAElF,MAAMC,EAAiB,iBAGjBC,EAAU,UACVC,EAAY,CAChB,4BAA6B,GAAG,GAAG,CACrC,EAC2B,IAAIH,EAC7BG,CACF,EAGmB,QAAQF,EAAgB,GAAOC,EAAS,CAAO,EAGlE,OAAOC,EAAU,2BAA2B,EAAE,qBAAqB,CACjE,eAAAF,EACA,SACA,QAAAC,EACA,SACF,CAAC,CACH,CAAC,CACH,CAAC",
6
- "names": ["SignDelegationAuthorizationUseCase", "derivationPath", "address", "appBinder"]
7
- }
@@ -1,19 +0,0 @@
1
- import { type CommandErrorResult, type DeviceActionState, type ExecuteDeviceActionReturnType, type OpenAppDAError, type OpenAppDARequiredInteraction, type UserInteractionRequired } from "@ledgerhq/device-management-kit";
2
- import { type Signature } from "../model/Signature";
3
- import { type EthErrorCodes } from "../../internal/app-binder/command/utils/ethAppErrors";
4
- export type SignDelegationAuthorizationDAOutput = Signature;
5
- export type SignDelegationAuthorizationDAInput = {
6
- readonly derivationPath: string;
7
- readonly address: `0x${string}`;
8
- readonly chainId: number;
9
- readonly nonce: number;
10
- };
11
- export type SignDelegationAuthorizationDAError = OpenAppDAError | CommandErrorResult<EthErrorCodes>["error"];
12
- type SignDelegationAuthorizationDARequiredInteraction = OpenAppDARequiredInteraction | UserInteractionRequired.SignDelegationAuthorization;
13
- export type SignDelegationAuthorizationDAIntermediateValue = {
14
- requiredUserInteraction: SignDelegationAuthorizationDARequiredInteraction;
15
- };
16
- export type SignDelegationAuthorizationDAState = DeviceActionState<SignDelegationAuthorizationDAOutput, SignDelegationAuthorizationDAError, SignDelegationAuthorizationDAIntermediateValue>;
17
- export type SignDelegationAuthorizationDAReturnType = ExecuteDeviceActionReturnType<SignDelegationAuthorizationDAOutput, SignDelegationAuthorizationDAError, SignDelegationAuthorizationDAIntermediateValue>;
18
- export {};
19
- //# sourceMappingURL=SignDelegationAuthorizationTypes.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SignDelegationAuthorizationTypes.d.ts","sourceRoot":"","sources":["../../../../src/api/app-binder/SignDelegationAuthorizationTypes.ts"],"names":[],"mappings":"AAAA,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,aAAa,EAAE,MAAM,iDAAiD,CAAC;AAErF,MAAM,MAAM,mCAAmC,GAAG,SAAS,CAAC;AAE5D,MAAM,MAAM,kCAAkC,GAAG;IAC/C,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,OAAO,EAAE,KAAK,MAAM,EAAE,CAAC;IAChC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,kCAAkC,GAC1C,cAAc,GACd,kBAAkB,CAAC,aAAa,CAAC,CAAC,OAAO,CAAC,CAAC;AAE/C,KAAK,gDAAgD,GACjD,4BAA4B,GAC5B,uBAAuB,CAAC,2BAA2B,CAAC;AAExD,MAAM,MAAM,8CAA8C,GAAG;IAC3D,uBAAuB,EAAE,gDAAgD,CAAC;CAC3E,CAAC;AAEF,MAAM,MAAM,kCAAkC,GAAG,iBAAiB,CAChE,mCAAmC,EACnC,kCAAkC,EAClC,8CAA8C,CAC/C,CAAC;AAEF,MAAM,MAAM,uCAAuC,GACjD,6BAA6B,CAC3B,mCAAmC,EACnC,kCAAkC,EAClC,8CAA8C,CAC/C,CAAC"}
@@ -1,29 +0,0 @@
1
- import { type Apdu, type ApduResponse, type Command, type CommandResult } from "@ledgerhq/device-management-kit";
2
- import { Maybe } from "purify-ts";
3
- import { type Signature } from "../../../api/model/Signature";
4
- import { type EthErrorCodes } from "./utils/ethAppErrors";
5
- export type SignEIP7702AuthorizationCommandArgs = {
6
- /**
7
- * The data to sign in max 255 bytes chunks
8
- * Data is a concatenation of the following:
9
- * - Derivation path length (1 byte)
10
- * - Derivation path (4 bytes per element)
11
- * - Nonce (4 bytes)
12
- * - Chain ID (4 bytes)
13
- * - Address (20 bytes)
14
- */
15
- readonly data: Uint8Array;
16
- /**
17
- * If this is the first chunk of the message
18
- */
19
- readonly isFirstChunk: boolean;
20
- };
21
- export type SignEIP7702AuthorizationCommandResponse = Maybe<Signature>;
22
- export declare class SignEIP7702AuthorizationCommand implements Command<SignEIP7702AuthorizationCommandResponse, SignEIP7702AuthorizationCommandArgs, EthErrorCodes> {
23
- readonly args: SignEIP7702AuthorizationCommandArgs;
24
- private readonly errorHelper;
25
- constructor(args: SignEIP7702AuthorizationCommandArgs);
26
- getApdu(): Apdu;
27
- parseResponse(apduResponse: ApduResponse): CommandResult<SignEIP7702AuthorizationCommandResponse, EthErrorCodes>;
28
- }
29
- //# sourceMappingURL=SignAuthorizationDelegationCommand.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SignAuthorizationDelegationCommand.d.ts","sourceRoot":"","sources":["../../../../../src/internal/app-binder/command/SignAuthorizationDelegationCommand.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,IAAI,EAIT,KAAK,YAAY,EACjB,KAAK,OAAO,EACZ,KAAK,aAAa,EAGnB,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EAAQ,KAAK,EAAW,MAAM,WAAW,CAAC;AAEjD,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEtD,OAAO,EAGL,KAAK,aAAa,EACnB,MAAM,sBAAsB,CAAC;AAK9B,MAAM,MAAM,mCAAmC,GAAG;IAChD;;;;;;;;OAQG;IACH,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAC1B;;OAEG;IACH,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAC;CAChC,CAAC;AAEF,MAAM,MAAM,uCAAuC,GAAG,KAAK,CAAC,SAAS,CAAC,CAAC;AAEvE,qBAAa,+BACX,YACE,OAAO,CACL,uCAAuC,EACvC,mCAAmC,EACnC,aAAa,CACd;IAEH,QAAQ,CAAC,IAAI,EAAE,mCAAmC,CAAC;IACnD,OAAO,CAAC,QAAQ,CAAC,WAAW,CAGiB;gBAEjC,IAAI,EAAE,mCAAmC;IAIrD,OAAO,IAAI,IAAI;IAcf,aAAa,CACX,YAAY,EAAE,YAAY,GACzB,aAAa,CAAC,uCAAuC,EAAE,aAAa,CAAC;CAyCzE"}