@ledgerhq/device-signer-kit-aleo 0.0.0-develop-20260331001713 → 0.0.0-develop-20260401001841
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/api/SignerAleo.js +1 -1
- package/lib/cjs/api/SignerAleo.js.map +1 -1
- package/lib/cjs/internal/DefaultSignerAleo.js +1 -1
- package/lib/cjs/internal/DefaultSignerAleo.js.map +3 -3
- package/lib/cjs/internal/app-binder/AleoAppBinder.js +1 -1
- package/lib/cjs/internal/app-binder/AleoAppBinder.js.map +3 -3
- package/lib/cjs/internal/app-binder/command/SignFeeIntentCommand.js +1 -1
- package/lib/cjs/internal/app-binder/command/SignFeeIntentCommand.js.map +2 -2
- package/lib/cjs/internal/app-binder/command/SignFeeIntentCommand.test.js +1 -1
- package/lib/cjs/internal/app-binder/command/SignFeeIntentCommand.test.js.map +3 -3
- package/lib/cjs/internal/app-binder/command/SignRootIntentCommand.js +1 -1
- package/lib/cjs/internal/app-binder/command/SignRootIntentCommand.js.map +3 -3
- package/lib/cjs/internal/app-binder/command/SignRootIntentCommand.test.js +1 -1
- package/lib/cjs/internal/app-binder/command/SignRootIntentCommand.test.js.map +3 -3
- package/lib/cjs/internal/app-binder/command/utils/apduHeaderUtils.js +1 -1
- package/lib/cjs/internal/app-binder/command/utils/apduHeaderUtils.js.map +3 -3
- package/lib/cjs/internal/app-binder/task/AleoChunkableCommandArgs.js +2 -0
- package/lib/cjs/internal/app-binder/task/AleoChunkableCommandArgs.js.map +7 -0
- package/lib/cjs/internal/app-binder/task/SendAleoCommandInChunksTask.js +2 -0
- package/lib/cjs/internal/app-binder/task/SendAleoCommandInChunksTask.js.map +7 -0
- package/lib/cjs/internal/app-binder/task/SignFeeIntentTask.js +2 -0
- package/lib/cjs/internal/app-binder/task/SignFeeIntentTask.js.map +7 -0
- package/lib/cjs/internal/app-binder/task/SignFeeIntentTask.test.js +2 -0
- package/lib/cjs/internal/app-binder/task/SignFeeIntentTask.test.js.map +7 -0
- package/lib/cjs/internal/app-binder/task/SignRootIntentTask.js +2 -0
- package/lib/cjs/internal/app-binder/task/SignRootIntentTask.js.map +7 -0
- package/lib/cjs/internal/app-binder/task/SignRootIntentTask.test.js +2 -0
- package/lib/cjs/internal/app-binder/task/SignRootIntentTask.test.js.map +7 -0
- package/lib/cjs/internal/app-binder/task/__test-utils__/makeInternalApi.js +2 -0
- package/lib/cjs/internal/app-binder/task/__test-utils__/makeInternalApi.js.map +7 -0
- package/lib/cjs/internal/di.js +1 -1
- package/lib/cjs/internal/di.js.map +3 -3
- package/lib/cjs/package.json +1 -1
- package/lib/esm/internal/DefaultSignerAleo.js +1 -1
- package/lib/esm/internal/DefaultSignerAleo.js.map +3 -3
- package/lib/esm/internal/app-binder/AleoAppBinder.js +1 -1
- package/lib/esm/internal/app-binder/AleoAppBinder.js.map +3 -3
- package/lib/esm/internal/app-binder/command/SignFeeIntentCommand.js +1 -1
- package/lib/esm/internal/app-binder/command/SignFeeIntentCommand.js.map +3 -3
- package/lib/esm/internal/app-binder/command/SignFeeIntentCommand.test.js +1 -1
- package/lib/esm/internal/app-binder/command/SignFeeIntentCommand.test.js.map +3 -3
- package/lib/esm/internal/app-binder/command/SignRootIntentCommand.js +1 -1
- package/lib/esm/internal/app-binder/command/SignRootIntentCommand.js.map +3 -3
- package/lib/esm/internal/app-binder/command/SignRootIntentCommand.test.js +1 -1
- package/lib/esm/internal/app-binder/command/SignRootIntentCommand.test.js.map +3 -3
- package/lib/esm/internal/app-binder/command/utils/apduHeaderUtils.js +1 -1
- package/lib/esm/internal/app-binder/command/utils/apduHeaderUtils.js.map +3 -3
- package/lib/esm/internal/app-binder/task/AleoChunkableCommandArgs.js +1 -0
- package/lib/esm/internal/app-binder/task/SendAleoCommandInChunksTask.js +2 -0
- package/lib/esm/internal/app-binder/task/SendAleoCommandInChunksTask.js.map +7 -0
- package/lib/esm/internal/app-binder/task/SignFeeIntentTask.js +2 -0
- package/lib/esm/internal/app-binder/task/SignFeeIntentTask.js.map +7 -0
- package/lib/esm/internal/app-binder/task/SignFeeIntentTask.test.js +2 -0
- package/lib/esm/internal/app-binder/task/SignFeeIntentTask.test.js.map +7 -0
- package/lib/esm/internal/app-binder/task/SignRootIntentTask.js +2 -0
- package/lib/esm/internal/app-binder/task/SignRootIntentTask.js.map +7 -0
- package/lib/esm/internal/app-binder/task/SignRootIntentTask.test.js +2 -0
- package/lib/esm/internal/app-binder/task/SignRootIntentTask.test.js.map +7 -0
- package/lib/esm/internal/app-binder/task/__test-utils__/makeInternalApi.js +2 -0
- package/lib/esm/internal/app-binder/task/__test-utils__/makeInternalApi.js.map +7 -0
- package/lib/esm/internal/di.js +1 -1
- package/lib/esm/internal/di.js.map +3 -3
- package/lib/esm/package.json +1 -1
- package/lib/types/api/SignerAleo.d.ts +0 -2
- package/lib/types/api/SignerAleo.d.ts.map +1 -1
- package/lib/types/internal/DefaultSignerAleo.d.ts +0 -2
- package/lib/types/internal/DefaultSignerAleo.d.ts.map +1 -1
- package/lib/types/internal/app-binder/AleoAppBinder.d.ts +0 -6
- package/lib/types/internal/app-binder/AleoAppBinder.d.ts.map +1 -1
- package/lib/types/internal/app-binder/command/SignFeeIntentCommand.d.ts +3 -4
- package/lib/types/internal/app-binder/command/SignFeeIntentCommand.d.ts.map +1 -1
- package/lib/types/internal/app-binder/command/SignRootIntentCommand.d.ts +3 -5
- package/lib/types/internal/app-binder/command/SignRootIntentCommand.d.ts.map +1 -1
- package/lib/types/internal/app-binder/command/utils/apduHeaderUtils.d.ts +4 -0
- package/lib/types/internal/app-binder/command/utils/apduHeaderUtils.d.ts.map +1 -1
- package/lib/types/internal/app-binder/task/AleoChunkableCommandArgs.d.ts +8 -0
- package/lib/types/internal/app-binder/task/AleoChunkableCommandArgs.d.ts.map +1 -0
- package/lib/types/internal/app-binder/task/SendAleoCommandInChunksTask.d.ts +16 -0
- package/lib/types/internal/app-binder/task/SendAleoCommandInChunksTask.d.ts.map +1 -0
- package/lib/types/internal/app-binder/task/SignFeeIntentTask.d.ts +13 -0
- package/lib/types/internal/app-binder/task/SignFeeIntentTask.d.ts.map +1 -0
- package/lib/types/internal/app-binder/task/SignFeeIntentTask.test.d.ts +2 -0
- package/lib/types/internal/app-binder/task/SignFeeIntentTask.test.d.ts.map +1 -0
- package/lib/types/internal/app-binder/task/SignRootIntentTask.d.ts +14 -0
- package/lib/types/internal/app-binder/task/SignRootIntentTask.d.ts.map +1 -0
- package/lib/types/internal/app-binder/task/SignRootIntentTask.test.d.ts +2 -0
- package/lib/types/internal/app-binder/task/SignRootIntentTask.test.d.ts.map +1 -0
- package/lib/types/internal/app-binder/task/__test-utils__/makeInternalApi.d.ts +4 -0
- package/lib/types/internal/app-binder/task/__test-utils__/makeInternalApi.d.ts.map +1 -0
- package/lib/types/internal/di.d.ts.map +1 -1
- package/lib/types/tsconfig.prod.tsbuildinfo +1 -1
- package/package.json +8 -8
- package/lib/cjs/api/app-binder/SignMessageDeviceActionTypes.js +0 -2
- package/lib/cjs/api/app-binder/SignMessageDeviceActionTypes.js.map +0 -7
- package/lib/cjs/internal/app-binder/command/SignMessageCommand.js +0 -2
- package/lib/cjs/internal/app-binder/command/SignMessageCommand.js.map +0 -7
- package/lib/cjs/internal/app-binder/device-action/SignMessage/SignMessageDeviceAction.js +0 -2
- package/lib/cjs/internal/use-cases/message/SignMessageUseCase.js +0 -2
- package/lib/cjs/internal/use-cases/message/SignMessageUseCase.js.map +0 -7
- package/lib/cjs/internal/use-cases/message/di/messageModule.js +0 -2
- package/lib/cjs/internal/use-cases/message/di/messageModule.js.map +0 -7
- package/lib/cjs/internal/use-cases/message/di/messageTypes.js +0 -2
- package/lib/cjs/internal/use-cases/message/di/messageTypes.js.map +0 -7
- package/lib/esm/api/app-binder/SignMessageDeviceActionTypes.js +0 -1
- package/lib/esm/api/app-binder/SignMessageDeviceActionTypes.js.map +0 -7
- package/lib/esm/internal/app-binder/command/SignMessageCommand.js +0 -2
- package/lib/esm/internal/app-binder/command/SignMessageCommand.js.map +0 -7
- package/lib/esm/internal/app-binder/device-action/SignMessage/SignMessageDeviceAction.js +0 -1
- package/lib/esm/internal/app-binder/device-action/SignMessage/SignMessageDeviceAction.js.map +0 -7
- package/lib/esm/internal/use-cases/message/SignMessageUseCase.js +0 -2
- package/lib/esm/internal/use-cases/message/SignMessageUseCase.js.map +0 -7
- package/lib/esm/internal/use-cases/message/di/messageModule.js +0 -2
- package/lib/esm/internal/use-cases/message/di/messageModule.js.map +0 -7
- package/lib/esm/internal/use-cases/message/di/messageTypes.js +0 -2
- package/lib/esm/internal/use-cases/message/di/messageTypes.js.map +0 -7
- package/lib/types/api/app-binder/SignMessageDeviceActionTypes.d.ts +0 -10
- package/lib/types/api/app-binder/SignMessageDeviceActionTypes.d.ts.map +0 -1
- package/lib/types/internal/app-binder/command/SignMessageCommand.d.ts +0 -16
- package/lib/types/internal/app-binder/command/SignMessageCommand.d.ts.map +0 -1
- package/lib/types/internal/app-binder/device-action/SignMessage/SignMessageDeviceAction.d.ts +0 -1
- package/lib/types/internal/app-binder/device-action/SignMessage/SignMessageDeviceAction.d.ts.map +0 -1
- package/lib/types/internal/use-cases/message/SignMessageUseCase.d.ts +0 -8
- package/lib/types/internal/use-cases/message/SignMessageUseCase.d.ts.map +0 -1
- package/lib/types/internal/use-cases/message/di/messageModule.d.ts +0 -3
- package/lib/types/internal/use-cases/message/di/messageModule.d.ts.map +0 -1
- package/lib/types/internal/use-cases/message/di/messageTypes.d.ts +0 -4
- package/lib/types/internal/use-cases/message/di/messageTypes.d.ts.map +0 -1
- /package/lib/{cjs/internal/app-binder/device-action/SignMessage/SignMessageDeviceAction.js.map → esm/internal/app-binder/task/AleoChunkableCommandArgs.js.map} +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var r=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var s=Object.getOwnPropertyNames;var y=Object.prototype.hasOwnProperty;var A=(e,t,i,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of s(t))!y.call(e,n)&&n!==i&&r(e,n,{get:()=>t[n],enumerable:!(o=p(t,n))||o.enumerable});return e};var g=e=>A(r({},"__esModule",{value:!0}),e);var a={};module.exports=g(a);
|
|
2
2
|
//# sourceMappingURL=SignerAleo.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/api/SignerAleo.ts"],
|
|
4
|
-
"sourcesContent": ["import { type GetAddressDAReturnType } from \"@api/app-binder/GetAddressDeviceActionTypes\";\nimport { type GetAppConfigDAReturnType } from \"@api/app-binder/GetAppConfigDeviceActionTypes\";\nimport { type GetViewKeyDAReturnType } from \"@api/app-binder/GetViewKeyDeviceActionTypes\";\nimport { type SignFeeIntentDAReturnType } from \"@api/app-binder/SignFeeIntentDeviceActionTypes\";\nimport { type
|
|
4
|
+
"sourcesContent": ["import { type GetAddressDAReturnType } from \"@api/app-binder/GetAddressDeviceActionTypes\";\nimport { type GetAppConfigDAReturnType } from \"@api/app-binder/GetAppConfigDeviceActionTypes\";\nimport { type GetViewKeyDAReturnType } from \"@api/app-binder/GetViewKeyDeviceActionTypes\";\nimport { type SignFeeIntentDAReturnType } from \"@api/app-binder/SignFeeIntentDeviceActionTypes\";\nimport { type SignRootIntentDAReturnType } from \"@api/app-binder/SignRootIntentDeviceActionTypes\";\nimport { type AddressOptions } from \"@api/model/AddressOptions\";\nimport { type TransactionOptions } from \"@api/model/TransactionOptions\";\n\nexport interface SignerAleo {\n getAppConfig: () => GetAppConfigDAReturnType;\n\n getAddress: (\n derivationPath: string,\n options?: AddressOptions,\n ) => GetAddressDAReturnType;\n\n getViewKey: (\n derivationPath: string,\n options?: AddressOptions,\n ) => GetViewKeyDAReturnType;\n\n signRootIntent: (\n derivationPath: string,\n rootIntent: Uint8Array,\n options?: TransactionOptions,\n ) => SignRootIntentDAReturnType;\n\n signFeeIntent: (\n feeIntent: Uint8Array,\n options?: TransactionOptions,\n ) => SignFeeIntentDAReturnType;\n}\n"],
|
|
5
5
|
"mappings": "+WAAA,IAAAA,EAAA,kBAAAC,EAAAD",
|
|
6
6
|
"names": ["SignerAleo_exports", "__toCommonJS"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var i=Object.defineProperty;var
|
|
1
|
+
"use strict";var i=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var A=Object.prototype.hasOwnProperty;var f=(n,e)=>{for(var t in e)i(n,t,{get:e[t],enumerable:!0})},c=(n,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of y(e))!A.call(n,r)&&r!==t&&i(n,r,{get:()=>e[r],enumerable:!(o=g(e,r))||o.enumerable});return n};var u=n=>c(i({},"__esModule",{value:!0}),n);var d={};f(d,{DefaultSignerAleo:()=>C});module.exports=u(d);var a=require("./di"),s=require("./use-cases/address/di/addressTypes"),m=require("./use-cases/config/di/configTypes"),p=require("./use-cases/transaction/di/transactionTypes");class C{_container;constructor({dmk:e,sessionId:t}){this._container=(0,a.makeContainer)({dmk:e,sessionId:t})}getAppConfig(){return this._container.get(m.configTypes.GetAppConfigUseCase).execute()}getAddress(e,t){return this._container.get(s.addressTypes.GetAddressUseCase).execute(e,t)}getViewKey(e,t){return this._container.get(s.addressTypes.GetViewKeyUseCase).execute(e,t)}signRootIntent(e,t,o){return this._container.get(p.transactionTypes.SignRootIntentUseCase).execute(e,t,o)}signFeeIntent(e,t){return this._container.get(p.transactionTypes.SignFeeIntentUseCase).execute(e,t)}}0&&(module.exports={DefaultSignerAleo});
|
|
2
2
|
//# sourceMappingURL=DefaultSignerAleo.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/internal/DefaultSignerAleo.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n type DeviceManagementKit,\n type DeviceSessionId,\n} from \"@ledgerhq/device-management-kit\";\nimport { type Container } from \"inversify\";\n\nimport { type GetAddressDAReturnType } from \"@api/app-binder/GetAddressDeviceActionTypes\";\nimport { type GetAppConfigDAReturnType } from \"@api/app-binder/GetAppConfigDeviceActionTypes\";\nimport { type GetViewKeyDAReturnType } from \"@api/app-binder/GetViewKeyDeviceActionTypes\";\nimport { type SignFeeIntentDAReturnType } from \"@api/app-binder/SignFeeIntentDeviceActionTypes\";\nimport { type
|
|
5
|
-
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,uBAAAE,IAAA,eAAAC,EAAAH,
|
|
6
|
-
"names": ["DefaultSignerAleo_exports", "__export", "DefaultSignerAleo", "__toCommonJS", "import_di", "import_addressTypes", "import_configTypes", "
|
|
4
|
+
"sourcesContent": ["import {\n type DeviceManagementKit,\n type DeviceSessionId,\n} from \"@ledgerhq/device-management-kit\";\nimport { type Container } from \"inversify\";\n\nimport { type GetAddressDAReturnType } from \"@api/app-binder/GetAddressDeviceActionTypes\";\nimport { type GetAppConfigDAReturnType } from \"@api/app-binder/GetAppConfigDeviceActionTypes\";\nimport { type GetViewKeyDAReturnType } from \"@api/app-binder/GetViewKeyDeviceActionTypes\";\nimport { type SignFeeIntentDAReturnType } from \"@api/app-binder/SignFeeIntentDeviceActionTypes\";\nimport { type SignRootIntentDAReturnType } from \"@api/app-binder/SignRootIntentDeviceActionTypes\";\nimport { type AddressOptions } from \"@api/model/AddressOptions\";\nimport { type TransactionOptions } from \"@api/model/TransactionOptions\";\nimport { type SignerAleo } from \"@api/SignerAleo\";\nimport { makeContainer } from \"@internal/di\";\nimport { addressTypes } from \"@internal/use-cases/address/di/addressTypes\";\nimport { type GetAddressUseCase } from \"@internal/use-cases/address/GetAddressUseCase\";\nimport { type GetViewKeyUseCase } from \"@internal/use-cases/address/GetViewKeyUseCase\";\nimport { configTypes } from \"@internal/use-cases/config/di/configTypes\";\nimport { type GetAppConfigUseCase } from \"@internal/use-cases/config/GetAppConfigUseCase\";\nimport { transactionTypes } from \"@internal/use-cases/transaction/di/transactionTypes\";\nimport { type SignFeeIntentUseCase } from \"@internal/use-cases/transaction/SignFeeIntentUseCase\";\nimport { type SignRootIntentUseCase } from \"@internal/use-cases/transaction/SignRootIntentUseCase\";\n\ntype DefaultSignerAleoConstructorArgs = {\n dmk: DeviceManagementKit;\n sessionId: DeviceSessionId;\n};\n\nexport class DefaultSignerAleo implements SignerAleo {\n private readonly _container: Container;\n\n constructor({ dmk, sessionId }: DefaultSignerAleoConstructorArgs) {\n this._container = makeContainer({ dmk, sessionId });\n }\n\n getAppConfig(): GetAppConfigDAReturnType {\n return this._container\n .get<GetAppConfigUseCase>(configTypes.GetAppConfigUseCase)\n .execute();\n }\n\n getAddress(\n derivationPath: string,\n options?: AddressOptions,\n ): GetAddressDAReturnType {\n return this._container\n .get<GetAddressUseCase>(addressTypes.GetAddressUseCase)\n .execute(derivationPath, options);\n }\n\n getViewKey(\n derivationPath: string,\n options?: AddressOptions,\n ): GetViewKeyDAReturnType {\n return this._container\n .get<GetViewKeyUseCase>(addressTypes.GetViewKeyUseCase)\n .execute(derivationPath, options);\n }\n\n signRootIntent(\n derivationPath: string,\n rootIntent: Uint8Array,\n options?: TransactionOptions,\n ): SignRootIntentDAReturnType {\n return this._container\n .get<SignRootIntentUseCase>(transactionTypes.SignRootIntentUseCase)\n .execute(derivationPath, rootIntent, options);\n }\n\n signFeeIntent(\n feeIntent: Uint8Array,\n options?: TransactionOptions,\n ): SignFeeIntentDAReturnType {\n return this._container\n .get<SignFeeIntentUseCase>(transactionTypes.SignFeeIntentUseCase)\n .execute(feeIntent, options);\n }\n}\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,uBAAAE,IAAA,eAAAC,EAAAH,GAcA,IAAAI,EAA8B,wBAC9BC,EAA6B,uDAG7BC,EAA4B,qDAE5BC,EAAiC,+DAS1B,MAAML,CAAwC,CAClC,WAEjB,YAAY,CAAE,IAAAM,EAAK,UAAAC,CAAU,EAAqC,CAChE,KAAK,cAAa,iBAAc,CAAE,IAAAD,EAAK,UAAAC,CAAU,CAAC,CACpD,CAEA,cAAyC,CACvC,OAAO,KAAK,WACT,IAAyB,cAAY,mBAAmB,EACxD,QAAQ,CACb,CAEA,WACEC,EACAC,EACwB,CACxB,OAAO,KAAK,WACT,IAAuB,eAAa,iBAAiB,EACrD,QAAQD,EAAgBC,CAAO,CACpC,CAEA,WACED,EACAC,EACwB,CACxB,OAAO,KAAK,WACT,IAAuB,eAAa,iBAAiB,EACrD,QAAQD,EAAgBC,CAAO,CACpC,CAEA,eACED,EACAE,EACAD,EAC4B,CAC5B,OAAO,KAAK,WACT,IAA2B,mBAAiB,qBAAqB,EACjE,QAAQD,EAAgBE,EAAYD,CAAO,CAChD,CAEA,cACEE,EACAF,EAC2B,CAC3B,OAAO,KAAK,WACT,IAA0B,mBAAiB,oBAAoB,EAC/D,QAAQE,EAAWF,CAAO,CAC/B,CACF",
|
|
6
|
+
"names": ["DefaultSignerAleo_exports", "__export", "DefaultSignerAleo", "__toCommonJS", "import_di", "import_addressTypes", "import_configTypes", "import_transactionTypes", "dmk", "sessionId", "derivationPath", "options", "rootIntent", "feeIntent"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var c=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var O=Object.getOwnPropertyNames;var g=Object.prototype.hasOwnProperty;var T=(i,e)=>{for(var n in e)c(i,n,{get:e[n],enumerable:!0})},R=(i,e,n,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let p of O(e))!g.call(i,p)&&p!==n&&c(i,p,{get:()=>e[p],enumerable:!(o=u(e,p))||o.enumerable});return i};var w=i=>R(c({},"__esModule",{value:!0}),i),k=(i,e,n,o)=>{for(var p=o>1?void 0:o?u(e,n):e,a=i.length-1,d;a>=0;a--)(d=i[a])&&(p=(o?d(e,n,p):d(p))||p);return o&&p&&c(e,n,p),p},A=(i,e)=>(n,o)=>e(n,o,i);var S={};T(S,{AleoAppBinder:()=>s});module.exports=w(S);var t=require("@ledgerhq/device-management-kit"),m=require("inversify"),r=require("../app-binder/constants"),I=require("../externalTypes"),y=require("./command/GetAddressCommand"),v=require("./command/GetAppConfigCommand"),D=require("./command/GetViewKeyCommand"),f=require("./task/SignFeeIntentTask"),h=require("./task/SignRootIntentTask");let s=class{constructor(e,n){this.dmk=e;this.sessionId=n}getAppConfig(e){return this.dmk.executeDeviceAction({sessionId:this.sessionId,deviceAction:new t.SendCommandInAppDeviceAction({input:{command:new v.GetAppConfigCommand,appName:r.APP_NAME,requiredUserInteraction:t.UserInteractionRequired.None,skipOpenApp:e.skipOpenApp}})})}getAddress(e){return this.dmk.executeDeviceAction({sessionId:this.sessionId,deviceAction:new t.SendCommandInAppDeviceAction({input:{command:new y.GetAddressCommand(e),appName:r.APP_NAME,requiredUserInteraction:e.checkOnDevice?t.UserInteractionRequired.VerifyAddress:t.UserInteractionRequired.None,skipOpenApp:e.skipOpenApp}})})}getViewKey(e){return this.dmk.executeDeviceAction({sessionId:this.sessionId,deviceAction:new t.SendCommandInAppDeviceAction({input:{command:new D.GetViewKeyCommand(e),appName:r.APP_NAME,requiredUserInteraction:t.UserInteractionRequired.VerifyAddress,skipOpenApp:e.skipOpenApp}})})}signRootIntent(e){return this.dmk.executeDeviceAction({sessionId:this.sessionId,deviceAction:new t.CallTaskInAppDeviceAction({input:{task:n=>new h.SignRootIntentTask(n,{derivationPath:e.derivationPath,rootIntent:e.rootIntent}).run(),appName:r.APP_NAME,requiredUserInteraction:t.UserInteractionRequired.SignTransaction,skipOpenApp:e.skipOpenApp}})})}signFeeIntent(e){return this.dmk.executeDeviceAction({sessionId:this.sessionId,deviceAction:new t.CallTaskInAppDeviceAction({input:{task:n=>new f.SignFeeIntentTask(n,{feeIntent:e.feeIntent}).run(),appName:r.APP_NAME,requiredUserInteraction:t.UserInteractionRequired.SignTransaction,skipOpenApp:e.skipOpenApp}})})}};s=k([(0,m.injectable)(),A(0,(0,m.inject)(I.externalTypes.Dmk)),A(1,(0,m.inject)(I.externalTypes.SessionId))],s);0&&(module.exports={AleoAppBinder});
|
|
2
2
|
//# sourceMappingURL=AleoAppBinder.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/internal/app-binder/AleoAppBinder.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n type DeviceManagementKit,\n type DeviceSessionId,\n SendCommandInAppDeviceAction,\n UserInteractionRequired,\n} from \"@ledgerhq/device-management-kit\";\nimport { inject, injectable } from \"inversify\";\n\nimport { type GetAddressDAReturnType } from \"@api/app-binder/GetAddressDeviceActionTypes\";\nimport { type GetAppConfigDAReturnType } from \"@api/app-binder/GetAppConfigDeviceActionTypes\";\nimport { type GetViewKeyDAReturnType } from \"@api/app-binder/GetViewKeyDeviceActionTypes\";\nimport { type SignFeeIntentDAReturnType } from \"@api/app-binder/SignFeeIntentDeviceActionTypes\";\nimport { type
|
|
5
|
-
"mappings": "okBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,mBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,
|
|
6
|
-
"names": ["AleoAppBinder_exports", "__export", "AleoAppBinder", "__toCommonJS", "import_device_management_kit", "import_inversify", "import_constants", "import_externalTypes", "import_GetAddressCommand", "import_GetAppConfigCommand", "import_GetViewKeyCommand", "
|
|
4
|
+
"sourcesContent": ["import {\n CallTaskInAppDeviceAction,\n type DeviceManagementKit,\n type DeviceSessionId,\n SendCommandInAppDeviceAction,\n UserInteractionRequired,\n} from \"@ledgerhq/device-management-kit\";\nimport { inject, injectable } from \"inversify\";\n\nimport { type GetAddressDAReturnType } from \"@api/app-binder/GetAddressDeviceActionTypes\";\nimport { type GetAppConfigDAReturnType } from \"@api/app-binder/GetAppConfigDeviceActionTypes\";\nimport { type GetViewKeyDAReturnType } from \"@api/app-binder/GetViewKeyDeviceActionTypes\";\nimport { type SignFeeIntentDAReturnType } from \"@api/app-binder/SignFeeIntentDeviceActionTypes\";\nimport { type SignRootIntentDAReturnType } from \"@api/app-binder/SignRootIntentDeviceActionTypes\";\nimport { APP_NAME } from \"@internal/app-binder/constants\";\nimport { externalTypes } from \"@internal/externalTypes\";\n\nimport { GetAddressCommand } from \"./command/GetAddressCommand\";\nimport { GetAppConfigCommand } from \"./command/GetAppConfigCommand\";\nimport { GetViewKeyCommand } from \"./command/GetViewKeyCommand\";\nimport { SignFeeIntentTask } from \"./task/SignFeeIntentTask\";\nimport { SignRootIntentTask } from \"./task/SignRootIntentTask\";\n\n@injectable()\nexport class AleoAppBinder {\n constructor(\n @inject(externalTypes.Dmk) private dmk: DeviceManagementKit,\n @inject(externalTypes.SessionId) private sessionId: DeviceSessionId,\n ) {}\n\n getAppConfig(args: { skipOpenApp: boolean }): GetAppConfigDAReturnType {\n return this.dmk.executeDeviceAction({\n sessionId: this.sessionId,\n deviceAction: new SendCommandInAppDeviceAction({\n input: {\n command: new GetAppConfigCommand(),\n appName: APP_NAME,\n requiredUserInteraction: UserInteractionRequired.None,\n skipOpenApp: args.skipOpenApp,\n },\n }),\n });\n }\n\n getAddress(args: {\n derivationPath: string;\n checkOnDevice: boolean;\n skipOpenApp: boolean;\n }): GetAddressDAReturnType {\n return this.dmk.executeDeviceAction({\n sessionId: this.sessionId,\n deviceAction: new SendCommandInAppDeviceAction({\n input: {\n command: new GetAddressCommand(args),\n appName: APP_NAME,\n requiredUserInteraction: args.checkOnDevice\n ? UserInteractionRequired.VerifyAddress\n : UserInteractionRequired.None,\n skipOpenApp: args.skipOpenApp,\n },\n }),\n });\n }\n\n getViewKey(args: {\n derivationPath: string;\n skipOpenApp: boolean;\n }): GetViewKeyDAReturnType {\n return this.dmk.executeDeviceAction({\n sessionId: this.sessionId,\n deviceAction: new SendCommandInAppDeviceAction({\n input: {\n command: new GetViewKeyCommand(args),\n appName: APP_NAME,\n requiredUserInteraction: UserInteractionRequired.VerifyAddress,\n skipOpenApp: args.skipOpenApp,\n },\n }),\n });\n }\n\n signRootIntent(args: {\n derivationPath: string;\n rootIntent: Uint8Array;\n skipOpenApp: boolean;\n }): SignRootIntentDAReturnType {\n return this.dmk.executeDeviceAction({\n sessionId: this.sessionId,\n deviceAction: new CallTaskInAppDeviceAction({\n input: {\n task: (internalApi) =>\n new SignRootIntentTask(internalApi, {\n derivationPath: args.derivationPath,\n rootIntent: args.rootIntent,\n }).run(),\n appName: APP_NAME,\n requiredUserInteraction: UserInteractionRequired.SignTransaction,\n skipOpenApp: args.skipOpenApp,\n },\n }),\n });\n }\n\n signFeeIntent(args: {\n feeIntent: Uint8Array;\n skipOpenApp: boolean;\n }): SignFeeIntentDAReturnType {\n return this.dmk.executeDeviceAction({\n sessionId: this.sessionId,\n deviceAction: new CallTaskInAppDeviceAction({\n input: {\n task: (internalApi) =>\n new SignFeeIntentTask(internalApi, {\n feeIntent: args.feeIntent,\n }).run(),\n appName: APP_NAME,\n requiredUserInteraction: UserInteractionRequired.SignTransaction,\n skipOpenApp: args.skipOpenApp,\n },\n }),\n });\n }\n}\n"],
|
|
5
|
+
"mappings": "okBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,mBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAMO,2CACPC,EAAmC,qBAOnCC,EAAyB,0CACzBC,EAA8B,mCAE9BC,EAAkC,uCAClCC,EAAoC,yCACpCC,EAAkC,uCAClCC,EAAkC,oCAClCC,EAAmC,qCAG5B,IAAMC,EAAN,KAAoB,CACzB,YACqCC,EACMC,EACzC,CAFmC,SAAAD,EACM,eAAAC,CACxC,CAEH,aAAaC,EAA0D,CACrE,OAAO,KAAK,IAAI,oBAAoB,CAClC,UAAW,KAAK,UAChB,aAAc,IAAI,+BAA6B,CAC7C,MAAO,CACL,QAAS,IAAI,sBACb,QAAS,WACT,wBAAyB,0BAAwB,KACjD,YAAaA,EAAK,WACpB,CACF,CAAC,CACH,CAAC,CACH,CAEA,WAAWA,EAIgB,CACzB,OAAO,KAAK,IAAI,oBAAoB,CAClC,UAAW,KAAK,UAChB,aAAc,IAAI,+BAA6B,CAC7C,MAAO,CACL,QAAS,IAAI,oBAAkBA,CAAI,EACnC,QAAS,WACT,wBAAyBA,EAAK,cAC1B,0BAAwB,cACxB,0BAAwB,KAC5B,YAAaA,EAAK,WACpB,CACF,CAAC,CACH,CAAC,CACH,CAEA,WAAWA,EAGgB,CACzB,OAAO,KAAK,IAAI,oBAAoB,CAClC,UAAW,KAAK,UAChB,aAAc,IAAI,+BAA6B,CAC7C,MAAO,CACL,QAAS,IAAI,oBAAkBA,CAAI,EACnC,QAAS,WACT,wBAAyB,0BAAwB,cACjD,YAAaA,EAAK,WACpB,CACF,CAAC,CACH,CAAC,CACH,CAEA,eAAeA,EAIgB,CAC7B,OAAO,KAAK,IAAI,oBAAoB,CAClC,UAAW,KAAK,UAChB,aAAc,IAAI,4BAA0B,CAC1C,MAAO,CACL,KAAOC,GACL,IAAI,qBAAmBA,EAAa,CAClC,eAAgBD,EAAK,eACrB,WAAYA,EAAK,UACnB,CAAC,EAAE,IAAI,EACT,QAAS,WACT,wBAAyB,0BAAwB,gBACjD,YAAaA,EAAK,WACpB,CACF,CAAC,CACH,CAAC,CACH,CAEA,cAAcA,EAGgB,CAC5B,OAAO,KAAK,IAAI,oBAAoB,CAClC,UAAW,KAAK,UAChB,aAAc,IAAI,4BAA0B,CAC1C,MAAO,CACL,KAAOC,GACL,IAAI,oBAAkBA,EAAa,CACjC,UAAWD,EAAK,SAClB,CAAC,EAAE,IAAI,EACT,QAAS,WACT,wBAAyB,0BAAwB,gBACjD,YAAaA,EAAK,WACpB,CACF,CAAC,CACH,CAAC,CACH,CACF,EAlGaH,EAANK,EAAA,IADN,cAAW,EAGPC,EAAA,eAAO,gBAAc,GAAG,GACxBA,EAAA,eAAO,gBAAc,SAAS,IAHtBN",
|
|
6
|
+
"names": ["AleoAppBinder_exports", "__export", "AleoAppBinder", "__toCommonJS", "import_device_management_kit", "import_inversify", "import_constants", "import_externalTypes", "import_GetAddressCommand", "import_GetAppConfigCommand", "import_GetViewKeyCommand", "import_SignFeeIntentTask", "import_SignRootIntentTask", "AleoAppBinder", "dmk", "sessionId", "args", "internalApi", "__decorateClass", "__decorateParam"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var d=Object.defineProperty;var l=Object.getOwnPropertyDescriptor;var g=Object.getOwnPropertyNames;var u=Object.prototype.hasOwnProperty;var A=(o,e)=>{for(var r in e)d(o,r,{get:e[r],enumerable:!0})},C=(o,e,r,m)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of g(e))!u.call(o,n)&&n!==r&&d(o,n,{get:()=>e[n],enumerable:!(m=l(e,n))||m.enumerable});return o};var y=o=>C(d({},"__esModule",{value:!0}),o);var F={};A(F,{SignFeeIntentCommand:()=>S});module.exports=y(F);var a=require("@ledgerhq/device-management-kit"),p=require("@ledgerhq/signer-utils"),i=require("purify-ts"),t=require("../../app-binder/command/utils/apduHeaderUtils"),s=require("./utils/aleoApplicationErrors");class S{constructor(e){this.args=e}name="signFeeIntent";errorHelper=new p.CommandErrorHelper(s.ALEO_APP_ERRORS,s.AleoAppCommandErrorFactory);getApdu(){const e={cla:t.ALEO_CLA,ins:t.INS.SIGN_INTENT,p1:t.P1.SIGN_MODE_FEE,p2:this.args.isFirst?t.P2.FIRST_CHUNK:t.P2.NEXT_CHUNK},r=new a.ApduBuilder(e);return r.addBufferToData(this.args.chunkedData),r.build()}parseResponse(e){return i.Maybe.fromNullable(this.errorHelper.getError(e)).orDefaultLazy(()=>{const r=new a.ApduParser(e),m=r.getUnparsedRemainingLength(),n=r.extractFieldByLength(m);return n&&n.length>0?(0,a.CommandResultFactory)({data:{tlvSignature:r.encodeToHexaString(n)}}):(0,a.CommandResultFactory)({data:{tlvSignature:""}})})}}0&&(module.exports={SignFeeIntentCommand});
|
|
2
2
|
//# sourceMappingURL=SignFeeIntentCommand.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/internal/app-binder/command/SignFeeIntentCommand.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n type Apdu,\n ApduBuilder,\n type ApduBuilderArgs,\n ApduParser,\n type ApduResponse,\n type Command,\n type CommandResult,\n CommandResultFactory,\n
|
|
5
|
-
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,0BAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,
|
|
4
|
+
"sourcesContent": ["import {\n type Apdu,\n ApduBuilder,\n type ApduBuilderArgs,\n ApduParser,\n type ApduResponse,\n type Command,\n type CommandResult,\n CommandResultFactory,\n} from \"@ledgerhq/device-management-kit\";\nimport { CommandErrorHelper } from \"@ledgerhq/signer-utils\";\nimport { Maybe } from \"purify-ts\";\n\nimport {\n ALEO_CLA,\n INS,\n P1,\n P2,\n} from \"@internal/app-binder/command/utils/apduHeaderUtils\";\nimport { type AleoChunkableCommandArgs } from \"@internal/app-binder/task/AleoChunkableCommandArgs\";\n\nimport {\n ALEO_APP_ERRORS,\n AleoAppCommandErrorFactory,\n type AleoErrorCodes,\n} from \"./utils/aleoApplicationErrors\";\n\nexport type SignFeeIntentCommandArgs = AleoChunkableCommandArgs;\n\nexport type SignFeeIntentCommandResponse = {\n readonly tlvSignature: string;\n};\n\n/**\n * Command to sign the fee intent (second part) of an Aleo public transfer transaction.\n * This command sends the fee intent data to the device.\n * The device will prompt the user for confirmation and return the signature.\n * This command must be called after SignRootIntentCommand.\n */\nexport class SignFeeIntentCommand\n implements\n Command<\n SignFeeIntentCommandResponse,\n SignFeeIntentCommandArgs,\n AleoErrorCodes\n >\n{\n readonly name = \"signFeeIntent\";\n private readonly errorHelper = new CommandErrorHelper<\n SignFeeIntentCommandResponse,\n AleoErrorCodes\n >(ALEO_APP_ERRORS, AleoAppCommandErrorFactory);\n\n constructor(private readonly args: SignFeeIntentCommandArgs) {}\n\n getApdu(): Apdu {\n const signFeeIntentArgs: ApduBuilderArgs = {\n cla: ALEO_CLA,\n ins: INS.SIGN_INTENT,\n p1: P1.SIGN_MODE_FEE,\n p2: this.args.isFirst ? P2.FIRST_CHUNK : P2.NEXT_CHUNK,\n };\n\n const builder = new ApduBuilder(signFeeIntentArgs);\n\n // Add the chunked data\n builder.addBufferToData(this.args.chunkedData);\n\n return builder.build();\n }\n\n parseResponse(\n response: ApduResponse,\n ): CommandResult<SignFeeIntentCommandResponse, AleoErrorCodes> {\n return Maybe.fromNullable(\n this.errorHelper.getError(response),\n ).orDefaultLazy(() => {\n const parser = new ApduParser(response);\n\n // Get the remaining length of the response (data before the status code)\n const remainingLength = parser.getUnparsedRemainingLength();\n\n // Extract the data field\n const data = parser.extractFieldByLength(remainingLength);\n\n if (data && data.length > 0) {\n // Encode the data to a hexadecimal string\n return CommandResultFactory({\n data: {\n tlvSignature: parser.encodeToHexaString(data),\n },\n });\n }\n\n // for intermediate chunks, the device returns 0 bytes of data with 0x9000.\n return CommandResultFactory({\n data: {\n tlvSignature: \"\",\n },\n });\n });\n }\n}\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,0BAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EASO,2CACPC,EAAmC,kCACnCC,EAAsB,qBAEtBC,EAKO,8DAGPC,EAIO,yCAcA,MAAMN,CAOb,CAOE,YAA6BO,EAAgC,CAAhC,UAAAA,CAAiC,CANrD,KAAO,gBACC,YAAc,IAAI,qBAGjC,kBAAiB,4BAA0B,EAI7C,SAAgB,CACd,MAAMC,EAAqC,CACzC,IAAK,WACL,IAAK,MAAI,YACT,GAAI,KAAG,cACP,GAAI,KAAK,KAAK,QAAU,KAAG,YAAc,KAAG,UAC9C,EAEMC,EAAU,IAAI,cAAYD,CAAiB,EAGjD,OAAAC,EAAQ,gBAAgB,KAAK,KAAK,WAAW,EAEtCA,EAAQ,MAAM,CACvB,CAEA,cACEC,EAC6D,CAC7D,OAAO,QAAM,aACX,KAAK,YAAY,SAASA,CAAQ,CACpC,EAAE,cAAc,IAAM,CACpB,MAAMC,EAAS,IAAI,aAAWD,CAAQ,EAGhCE,EAAkBD,EAAO,2BAA2B,EAGpDE,EAAOF,EAAO,qBAAqBC,CAAe,EAExD,OAAIC,GAAQA,EAAK,OAAS,KAEjB,wBAAqB,CAC1B,KAAM,CACJ,aAAcF,EAAO,mBAAmBE,CAAI,CAC9C,CACF,CAAC,KAII,wBAAqB,CAC1B,KAAM,CACJ,aAAc,EAChB,CACF,CAAC,CACH,CAAC,CACH,CACF",
|
|
6
6
|
"names": ["SignFeeIntentCommand_exports", "__export", "SignFeeIntentCommand", "__toCommonJS", "import_device_management_kit", "import_signer_utils", "import_purify_ts", "import_apduHeaderUtils", "import_aleoApplicationErrors", "args", "signFeeIntentArgs", "builder", "response", "parser", "remainingLength", "data"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var r=require("@ledgerhq/device-management-kit"),t=require("../../app-binder/command/utils/apduHeaderUtils"),a=require("./SignFeeIntentCommand");describe("SignFeeIntentCommand",()=>{const s=new Uint8Array([5,6,7,8]),c=new Uint8Array(255).fill(36);describe("name",()=>{it("should be 'signFeeIntent'",()=>{const n=new a.SignFeeIntentCommand({chunkedData:s,isFirst:!0});expect(n.name).toBe("signFeeIntent")})}),describe("getApdu",()=>{it("should create correct APDU for the first chunk",()=>{const e=new a.SignFeeIntentCommand({chunkedData:s,isFirst:!0}).getApdu();expect(e.cla).toBe(t.ALEO_CLA),expect(e.ins).toBe(t.INS.SIGN_INTENT),expect(e.p1).toBe(t.P1.SIGN_MODE_FEE),expect(e.p2).toBe(t.P2.FIRST_CHUNK),expect(e.data.length).toBe(s.length),expect(e.data).toEqual(s)}),it("should create correct APDU for subsequent chunks",()=>{const e=new a.SignFeeIntentCommand({chunkedData:s,isFirst:!1}).getApdu();expect(e.cla).toBe(t.ALEO_CLA),expect(e.ins).toBe(t.INS.SIGN_INTENT),expect(e.p1).toBe(t.P1.SIGN_MODE_FEE),expect(e.p2).toBe(t.P2.NEXT_CHUNK),expect(e.data.length).toBe(s.length),expect(e.data).toEqual(s)}),it("should create correct APDU for a long chunk (255 bytes)",()=>{const e=new a.SignFeeIntentCommand({chunkedData:c,isFirst:!1}).getApdu();expect(e.cla).toBe(t.ALEO_CLA),expect(e.ins).toBe(t.INS.SIGN_INTENT),expect(e.p1).toBe(t.P1.SIGN_MODE_FEE),expect(e.p2).toBe(t.P2.NEXT_CHUNK),expect(e.data.length).toBe(255),expect(e.data).toEqual(c)})}),describe("parseResponse",()=>{it("should return hexadecimal string for successful response",()=>{const n=new a.SignFeeIntentCommand({chunkedData:s,isFirst:!0}),e={statusCode:new Uint8Array([144,0]),data:new Uint8Array([1,2,3])},o=n.parseResponse(e);expect(o).toEqual((0,r.CommandResultFactory)({data:{tlvSignature:"010203"}}))}),it("should return empty signature for successful response without data (intermediate chunks)",()=>{const n=new a.SignFeeIntentCommand({chunkedData:s,isFirst:!0}),e={statusCode:new Uint8Array([144,0]),data:new Uint8Array([])},o=n.parseResponse(e);expect(o).toEqual((0,r.CommandResultFactory)({data:{tlvSignature:""}}))}),it("should handle user rejection",()=>{const n=new a.SignFeeIntentCommand({chunkedData:s,isFirst:!0}),e={statusCode:new Uint8Array([105,240]),data:new Uint8Array([])},o=n.parseResponse(e);expect((0,r.isSuccessCommandResult)(o)).toBe(!1),(0,r.isSuccessCommandResult)(o)||expect(o.error).toEqual(expect.objectContaining({_tag:"AleoAppCommandError",errorCode:"69f0",message:"Denied by user"}))}),it("should handle device error codes",()=>{const n=new a.SignFeeIntentCommand({chunkedData:s,isFirst:!0}),e={statusCode:new Uint8Array([176,8]),data:new Uint8Array([])},o=n.parseResponse(e);expect((0,r.isSuccessCommandResult)(o)).toBe(!1),(0,r.isSuccessCommandResult)(o)||expect(o.error).toEqual(expect.objectContaining({_tag:"AleoAppCommandError",errorCode:"b008",message:"Signature fail"}))})})});
|
|
2
2
|
//# sourceMappingURL=SignFeeIntentCommand.test.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/internal/app-binder/command/SignFeeIntentCommand.test.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n type Apdu,\n type ApduResponse,\n CommandResultFactory,\n
|
|
5
|
-
"mappings": "aAAA,IAAAA,
|
|
6
|
-
"names": ["import_device_management_kit", "import_apduHeaderUtils", "import_SignFeeIntentCommand", "
|
|
4
|
+
"sourcesContent": ["import {\n type Apdu,\n type ApduResponse,\n CommandResultFactory,\n isSuccessCommandResult,\n} from \"@ledgerhq/device-management-kit\";\n\nimport {\n ALEO_CLA,\n INS,\n P1,\n P2,\n} from \"@internal/app-binder/command/utils/apduHeaderUtils\";\n\nimport { SignFeeIntentCommand } from \"./SignFeeIntentCommand\";\n\ndescribe(\"SignFeeIntentCommand\", () => {\n const mockChunkedData = new Uint8Array([0x05, 0x06, 0x07, 0x08]);\n const mockLongChunkedData = new Uint8Array(255).fill(0x24);\n\n describe(\"name\", () => {\n it(\"should be 'signFeeIntent'\", () => {\n const command = new SignFeeIntentCommand({\n chunkedData: mockChunkedData,\n isFirst: true,\n });\n expect(command.name).toBe(\"signFeeIntent\");\n });\n });\n\n describe(\"getApdu\", () => {\n it(\"should create correct APDU for the first chunk\", () => {\n // Given\n const command = new SignFeeIntentCommand({\n chunkedData: mockChunkedData,\n isFirst: true,\n });\n\n // When\n const apdu: Apdu = command.getApdu();\n\n // Then\n expect(apdu.cla).toBe(ALEO_CLA);\n expect(apdu.ins).toBe(INS.SIGN_INTENT);\n expect(apdu.p1).toBe(P1.SIGN_MODE_FEE);\n expect(apdu.p2).toBe(P2.FIRST_CHUNK);\n\n // Should ONLY contain chunked data\n expect(apdu.data.length).toBe(mockChunkedData.length);\n expect(apdu.data).toEqual(mockChunkedData);\n });\n\n it(\"should create correct APDU for subsequent chunks\", () => {\n // Given\n const command = new SignFeeIntentCommand({\n chunkedData: mockChunkedData,\n isFirst: false,\n });\n\n // When\n const apdu: Apdu = command.getApdu();\n\n // Then\n expect(apdu.cla).toBe(ALEO_CLA);\n expect(apdu.ins).toBe(INS.SIGN_INTENT);\n expect(apdu.p1).toBe(P1.SIGN_MODE_FEE);\n expect(apdu.p2).toBe(P2.NEXT_CHUNK);\n\n // Should ONLY contain chunked data\n expect(apdu.data.length).toBe(mockChunkedData.length);\n expect(apdu.data).toEqual(mockChunkedData);\n });\n\n it(\"should create correct APDU for a long chunk (255 bytes)\", () => {\n // Given\n const command = new SignFeeIntentCommand({\n chunkedData: mockLongChunkedData,\n isFirst: false,\n });\n\n // When\n const apdu: Apdu = command.getApdu();\n\n // Then\n expect(apdu.cla).toBe(ALEO_CLA);\n expect(apdu.ins).toBe(INS.SIGN_INTENT);\n expect(apdu.p1).toBe(P1.SIGN_MODE_FEE);\n expect(apdu.p2).toBe(P2.NEXT_CHUNK);\n\n expect(apdu.data.length).toBe(255);\n expect(apdu.data).toEqual(mockLongChunkedData);\n });\n });\n\n describe(\"parseResponse\", () => {\n it(\"should return hexadecimal string for successful response\", () => {\n // Given\n const command = new SignFeeIntentCommand({\n chunkedData: mockChunkedData,\n isFirst: true,\n });\n\n const response: ApduResponse = {\n statusCode: new Uint8Array([0x90, 0x00]),\n data: new Uint8Array([0x01, 0x02, 0x03]),\n };\n\n // When\n const result = command.parseResponse(response);\n\n // Then\n expect(result).toEqual(\n CommandResultFactory({\n data: {\n tlvSignature: \"010203\",\n },\n }),\n );\n });\n\n it(\"should return empty signature for successful response without data (intermediate chunks)\", () => {\n // Given\n const command = new SignFeeIntentCommand({\n chunkedData: mockChunkedData,\n isFirst: true,\n });\n\n const response: ApduResponse = {\n statusCode: new Uint8Array([0x90, 0x00]),\n data: new Uint8Array([]),\n };\n\n // When\n const result = command.parseResponse(response);\n\n // Then\n expect(result).toEqual(\n CommandResultFactory({\n data: {\n tlvSignature: \"\",\n },\n }),\n );\n });\n\n it(\"should handle user rejection\", () => {\n // Given\n const command = new SignFeeIntentCommand({\n chunkedData: mockChunkedData,\n isFirst: true,\n });\n\n // User denied\n const response: ApduResponse = {\n statusCode: new Uint8Array([0x69, 0xf0]),\n data: new Uint8Array([]),\n };\n\n // When\n const result = command.parseResponse(response);\n\n // Then\n expect(isSuccessCommandResult(result)).toBe(false);\n if (!isSuccessCommandResult(result)) {\n expect(result.error).toEqual(\n expect.objectContaining({\n _tag: \"AleoAppCommandError\",\n errorCode: \"69f0\",\n message: \"Denied by user\",\n }),\n );\n }\n });\n\n it(\"should handle device error codes\", () => {\n // Given\n const command = new SignFeeIntentCommand({\n chunkedData: mockChunkedData,\n isFirst: true,\n });\n\n // Signature fail (0xb008)\n const response: ApduResponse = {\n statusCode: new Uint8Array([0xb0, 0x08]),\n data: new Uint8Array([]),\n };\n\n // When\n const result = command.parseResponse(response);\n\n // Then\n expect(isSuccessCommandResult(result)).toBe(false);\n if (!isSuccessCommandResult(result)) {\n expect(result.error).toEqual(\n expect.objectContaining({\n _tag: \"AleoAppCommandError\",\n errorCode: \"b008\",\n message: \"Signature fail\",\n }),\n );\n }\n });\n });\n});\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": ["import_device_management_kit", "import_apduHeaderUtils", "import_SignFeeIntentCommand", "mockChunkedData", "mockLongChunkedData", "command", "apdu", "response", "result"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var d=Object.defineProperty;var l=Object.getOwnPropertyDescriptor;var g=Object.getOwnPropertyNames;var u=Object.prototype.hasOwnProperty;var A=(n,e)=>{for(var o in e)d(n,o,{get:e[o],enumerable:!0})},C=(n,e,o,m)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of g(e))!u.call(n,r)&&r!==o&&d(n,r,{get:()=>e[r],enumerable:!(m=l(e,r))||m.enumerable});return n};var R=n=>C(d({},"__esModule",{value:!0}),n);var S={};A(S,{SignRootIntentCommand:()=>y});module.exports=R(S);var a=require("@ledgerhq/device-management-kit"),p=require("@ledgerhq/signer-utils"),i=require("purify-ts"),t=require("../../app-binder/command/utils/apduHeaderUtils"),s=require("./utils/aleoApplicationErrors");class y{constructor(e){this.args=e}name="signRootIntent";errorHelper=new p.CommandErrorHelper(s.ALEO_APP_ERRORS,s.AleoAppCommandErrorFactory);getApdu(){const e={cla:t.ALEO_CLA,ins:t.INS.SIGN_INTENT,p1:t.P1.SIGN_MODE_ROOT,p2:this.args.isFirst?t.P2.FIRST_CHUNK:t.P2.NEXT_CHUNK},o=new a.ApduBuilder(e);return o.addBufferToData(this.args.chunkedData),o.build()}parseResponse(e){return i.Maybe.fromNullable(this.errorHelper.getError(e)).orDefaultLazy(()=>{const o=new a.ApduParser(e),m=o.getUnparsedRemainingLength(),r=o.extractFieldByLength(m);return r&&r.length>0?(0,a.CommandResultFactory)({data:{tlvSignature:o.encodeToHexaString(r)}}):(0,a.CommandResultFactory)({data:{tlvSignature:""}})})}}0&&(module.exports={SignRootIntentCommand});
|
|
2
2
|
//# sourceMappingURL=SignRootIntentCommand.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/internal/app-binder/command/SignRootIntentCommand.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n type Apdu,\n ApduBuilder,\n type ApduBuilderArgs,\n ApduParser,\n type ApduResponse,\n type Command,\n type CommandResult,\n CommandResultFactory,\n
|
|
5
|
-
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,2BAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,
|
|
6
|
-
"names": ["SignRootIntentCommand_exports", "__export", "SignRootIntentCommand", "__toCommonJS", "import_device_management_kit", "import_signer_utils", "import_purify_ts", "import_apduHeaderUtils", "import_aleoApplicationErrors", "args", "signRootIntentArgs", "builder", "
|
|
4
|
+
"sourcesContent": ["import {\n type Apdu,\n ApduBuilder,\n type ApduBuilderArgs,\n ApduParser,\n type ApduResponse,\n type Command,\n type CommandResult,\n CommandResultFactory,\n} from \"@ledgerhq/device-management-kit\";\nimport { CommandErrorHelper } from \"@ledgerhq/signer-utils\";\nimport { Maybe } from \"purify-ts\";\n\nimport {\n ALEO_CLA,\n INS,\n P1,\n P2,\n} from \"@internal/app-binder/command/utils/apduHeaderUtils\";\nimport { type AleoChunkableCommandArgs } from \"@internal/app-binder/task/AleoChunkableCommandArgs\";\n\nimport {\n ALEO_APP_ERRORS,\n AleoAppCommandErrorFactory,\n type AleoErrorCodes,\n} from \"./utils/aleoApplicationErrors\";\n\nexport type SignRootIntentCommandArgs = AleoChunkableCommandArgs;\n\nexport type SignRootIntentCommandResponse = {\n readonly tlvSignature: string;\n};\n\n/**\n * Command to sign the root intent (first part) of an Aleo public transfer transaction.\n * This command sends the derivation path and root intent data to the device.\n * On success, the device responds with TLV-encoded signature data and a 0x9000 status code.\n * After this, SignFeeIntentCommand should be called to complete the transaction.\n */\nexport class SignRootIntentCommand\n implements\n Command<\n SignRootIntentCommandResponse,\n SignRootIntentCommandArgs,\n AleoErrorCodes\n >\n{\n readonly name = \"signRootIntent\";\n private readonly errorHelper = new CommandErrorHelper<\n SignRootIntentCommandResponse,\n AleoErrorCodes\n >(ALEO_APP_ERRORS, AleoAppCommandErrorFactory);\n\n constructor(private readonly args: SignRootIntentCommandArgs) {}\n\n getApdu(): Apdu {\n const signRootIntentArgs: ApduBuilderArgs = {\n cla: ALEO_CLA,\n ins: INS.SIGN_INTENT,\n p1: P1.SIGN_MODE_ROOT,\n p2: this.args.isFirst ? P2.FIRST_CHUNK : P2.NEXT_CHUNK,\n };\n\n const builder = new ApduBuilder(signRootIntentArgs);\n\n // Add the chunked data\n builder.addBufferToData(this.args.chunkedData);\n\n return builder.build();\n }\n\n parseResponse(\n response: ApduResponse,\n ): CommandResult<SignRootIntentCommandResponse, AleoErrorCodes> {\n return Maybe.fromNullable(\n this.errorHelper.getError(response),\n ).orDefaultLazy(() => {\n const parser = new ApduParser(response);\n\n // Get the remaining length of the response (data before the status code)\n const remainingLength = parser.getUnparsedRemainingLength();\n\n // Extract the data field\n const data = parser.extractFieldByLength(remainingLength);\n\n if (data && data.length > 0) {\n // Encode the data to a hexadecimal string\n return CommandResultFactory({\n data: {\n tlvSignature: parser.encodeToHexaString(data),\n },\n });\n }\n\n // for intermediate chunks, the device returns 0 bytes of data with 0x9000.\n return CommandResultFactory({\n data: {\n tlvSignature: \"\",\n },\n });\n });\n }\n}\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,2BAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EASO,2CACPC,EAAmC,kCACnCC,EAAsB,qBAEtBC,EAKO,8DAGPC,EAIO,yCAcA,MAAMN,CAOb,CAOE,YAA6BO,EAAiC,CAAjC,UAAAA,CAAkC,CANtD,KAAO,iBACC,YAAc,IAAI,qBAGjC,kBAAiB,4BAA0B,EAI7C,SAAgB,CACd,MAAMC,EAAsC,CAC1C,IAAK,WACL,IAAK,MAAI,YACT,GAAI,KAAG,eACP,GAAI,KAAK,KAAK,QAAU,KAAG,YAAc,KAAG,UAC9C,EAEMC,EAAU,IAAI,cAAYD,CAAkB,EAGlD,OAAAC,EAAQ,gBAAgB,KAAK,KAAK,WAAW,EAEtCA,EAAQ,MAAM,CACvB,CAEA,cACEC,EAC8D,CAC9D,OAAO,QAAM,aACX,KAAK,YAAY,SAASA,CAAQ,CACpC,EAAE,cAAc,IAAM,CACpB,MAAMC,EAAS,IAAI,aAAWD,CAAQ,EAGhCE,EAAkBD,EAAO,2BAA2B,EAGpDE,EAAOF,EAAO,qBAAqBC,CAAe,EAExD,OAAIC,GAAQA,EAAK,OAAS,KAEjB,wBAAqB,CAC1B,KAAM,CACJ,aAAcF,EAAO,mBAAmBE,CAAI,CAC9C,CACF,CAAC,KAII,wBAAqB,CAC1B,KAAM,CACJ,aAAc,EAChB,CACF,CAAC,CACH,CAAC,CACH,CACF",
|
|
6
|
+
"names": ["SignRootIntentCommand_exports", "__export", "SignRootIntentCommand", "__toCommonJS", "import_device_management_kit", "import_signer_utils", "import_purify_ts", "import_apduHeaderUtils", "import_aleoApplicationErrors", "args", "signRootIntentArgs", "builder", "response", "parser", "remainingLength", "data"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var r=require("@ledgerhq/device-management-kit"),t=require("../../app-binder/command/utils/apduHeaderUtils"),a=require("./SignRootIntentCommand");describe("SignRootIntentCommand",()=>{const n=new Uint8Array([1,2,3,4]),c=new Uint8Array(255).fill(66);describe("name",()=>{it("should be 'signRootIntent'",()=>{const o=new a.SignRootIntentCommand({chunkedData:n,isFirst:!0});expect(o.name).toBe("signRootIntent")})}),describe("getApdu",()=>{it("should create correct APDU for the first chunk",()=>{const e=new a.SignRootIntentCommand({chunkedData:n,isFirst:!0}).getApdu();expect(e.cla).toBe(t.ALEO_CLA),expect(e.ins).toBe(t.INS.SIGN_INTENT),expect(e.p1).toBe(t.P1.SIGN_MODE_ROOT),expect(e.p2).toBe(t.P2.FIRST_CHUNK),expect(e.data.length).toBe(n.length),expect(e.data).toEqual(n)}),it("should create correct APDU for subsequent chunks",()=>{const e=new a.SignRootIntentCommand({chunkedData:n,isFirst:!1}).getApdu();expect(e.cla).toBe(t.ALEO_CLA),expect(e.ins).toBe(t.INS.SIGN_INTENT),expect(e.p1).toBe(t.P1.SIGN_MODE_ROOT),expect(e.p2).toBe(t.P2.NEXT_CHUNK),expect(e.data.length).toBe(n.length),expect(e.data).toEqual(n)}),it("should create correct APDU for any chunk",()=>{const e=new a.SignRootIntentCommand({chunkedData:n,isFirst:!0}).getApdu();expect(e.data.length).toBe(n.length),expect(e.data).toEqual(n)}),it("should create correct APDU for a long chunk (255 bytes)",()=>{const e=new a.SignRootIntentCommand({chunkedData:c,isFirst:!1}).getApdu();expect(e.cla).toBe(t.ALEO_CLA),expect(e.ins).toBe(t.INS.SIGN_INTENT),expect(e.p1).toBe(t.P1.SIGN_MODE_ROOT),expect(e.p2).toBe(t.P2.NEXT_CHUNK),expect(e.data.length).toBe(255),expect(e.data).toEqual(c)})}),describe("parseResponse",()=>{it("should return hexadecimal string for successful response with data",()=>{const o=new a.SignRootIntentCommand({chunkedData:n,isFirst:!1}),e={statusCode:new Uint8Array([144,0]),data:new Uint8Array([1,2,3])},s=o.parseResponse(e);expect(s).toEqual((0,r.CommandResultFactory)({data:{tlvSignature:"010203"}}))}),it("should return empty signature for successful response without data (intermediate chunks)",()=>{const o=new a.SignRootIntentCommand({chunkedData:n,isFirst:!0}),e={statusCode:new Uint8Array([144,0]),data:new Uint8Array([])},s=o.parseResponse(e);expect(s).toEqual((0,r.CommandResultFactory)({data:{tlvSignature:""}}))}),it("should handle error response codes",()=>{const o=new a.SignRootIntentCommand({chunkedData:n,isFirst:!0}),e={statusCode:new Uint8Array([105,240]),data:new Uint8Array([])},s=o.parseResponse(e);expect((0,r.isSuccessCommandResult)(s)).toBe(!1),(0,r.isSuccessCommandResult)(s)||expect(s.error).toEqual(expect.objectContaining({_tag:"AleoAppCommandError",errorCode:"69f0",message:"Denied by user"}))}),it("should handle device error codes",()=>{const o=new a.SignRootIntentCommand({chunkedData:n,isFirst:!0}),e={statusCode:new Uint8Array([176,4]),data:new Uint8Array([])},s=o.parseResponse(e);expect((0,r.isSuccessCommandResult)(s)).toBe(!1),(0,r.isSuccessCommandResult)(s)||expect(s.error).toEqual(expect.objectContaining({_tag:"AleoAppCommandError",errorCode:"b004",message:"Wrong transaction length"}))})})});
|
|
2
2
|
//# sourceMappingURL=SignRootIntentCommand.test.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/internal/app-binder/command/SignRootIntentCommand.test.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n type Apdu,\n type ApduResponse,\n CommandResultFactory,\n
|
|
5
|
-
"mappings": "aAAA,IAAAA,
|
|
6
|
-
"names": ["import_device_management_kit", "import_apduHeaderUtils", "import_SignRootIntentCommand", "
|
|
4
|
+
"sourcesContent": ["import {\n type Apdu,\n type ApduResponse,\n CommandResultFactory,\n isSuccessCommandResult,\n} from \"@ledgerhq/device-management-kit\";\n\nimport {\n ALEO_CLA,\n INS,\n P1,\n P2,\n} from \"@internal/app-binder/command/utils/apduHeaderUtils\";\n\nimport { SignRootIntentCommand } from \"./SignRootIntentCommand\";\n\ndescribe(\"SignRootIntentCommand\", () => {\n const mockChunkedData = new Uint8Array([0x01, 0x02, 0x03, 0x04]);\n const mockLongChunkedData = new Uint8Array(255).fill(0x42);\n\n describe(\"name\", () => {\n it(\"should be 'signRootIntent'\", () => {\n const command = new SignRootIntentCommand({\n chunkedData: mockChunkedData,\n isFirst: true,\n });\n expect(command.name).toBe(\"signRootIntent\");\n });\n });\n\n describe(\"getApdu\", () => {\n it(\"should create correct APDU for the first chunk\", () => {\n // Given\n const command = new SignRootIntentCommand({\n chunkedData: mockChunkedData,\n isFirst: true,\n });\n\n // When\n const apdu: Apdu = command.getApdu();\n\n // Then\n expect(apdu.cla).toBe(ALEO_CLA);\n expect(apdu.ins).toBe(INS.SIGN_INTENT);\n expect(apdu.p1).toBe(P1.SIGN_MODE_ROOT);\n expect(apdu.p2).toBe(P2.FIRST_CHUNK);\n\n // Should ONLY contain chunked data\n expect(apdu.data.length).toBe(mockChunkedData.length);\n expect(apdu.data).toEqual(mockChunkedData);\n });\n\n it(\"should create correct APDU for subsequent chunks\", () => {\n // Given\n const command = new SignRootIntentCommand({\n chunkedData: mockChunkedData,\n isFirst: false,\n });\n\n // When\n const apdu: Apdu = command.getApdu();\n\n // Then\n expect(apdu.cla).toBe(ALEO_CLA);\n expect(apdu.ins).toBe(INS.SIGN_INTENT);\n expect(apdu.p1).toBe(P1.SIGN_MODE_ROOT);\n expect(apdu.p2).toBe(P2.NEXT_CHUNK);\n\n // Should ONLY contain chunked data\n expect(apdu.data.length).toBe(mockChunkedData.length);\n expect(apdu.data).toEqual(mockChunkedData);\n });\n\n it(\"should create correct APDU for any chunk\", () => {\n // Given\n const command = new SignRootIntentCommand({\n chunkedData: mockChunkedData,\n isFirst: true,\n });\n\n // When\n const apdu: Apdu = command.getApdu();\n\n // Then\n expect(apdu.data.length).toBe(mockChunkedData.length);\n expect(apdu.data).toEqual(mockChunkedData);\n });\n\n it(\"should create correct APDU for a long chunk (255 bytes)\", () => {\n // Given\n const command = new SignRootIntentCommand({\n chunkedData: mockLongChunkedData,\n isFirst: false,\n });\n\n // When\n const apdu: Apdu = command.getApdu();\n\n // Then\n expect(apdu.cla).toBe(ALEO_CLA);\n expect(apdu.ins).toBe(INS.SIGN_INTENT);\n expect(apdu.p1).toBe(P1.SIGN_MODE_ROOT);\n expect(apdu.p2).toBe(P2.NEXT_CHUNK);\n\n expect(apdu.data.length).toBe(255);\n expect(apdu.data).toEqual(mockLongChunkedData);\n });\n });\n\n describe(\"parseResponse\", () => {\n it(\"should return hexadecimal string for successful response with data\", () => {\n // Given\n const command = new SignRootIntentCommand({\n chunkedData: mockChunkedData,\n isFirst: false,\n });\n\n const response: ApduResponse = {\n statusCode: new Uint8Array([0x90, 0x00]),\n data: new Uint8Array([0x01, 0x02, 0x03]),\n };\n\n // When\n const result = command.parseResponse(response);\n\n // Then\n expect(result).toEqual(\n CommandResultFactory({\n data: {\n tlvSignature: \"010203\",\n },\n }),\n );\n });\n\n it(\"should return empty signature for successful response without data (intermediate chunks)\", () => {\n // Given\n const command = new SignRootIntentCommand({\n chunkedData: mockChunkedData,\n isFirst: true,\n });\n\n const response: ApduResponse = {\n statusCode: new Uint8Array([0x90, 0x00]),\n data: new Uint8Array([]),\n };\n\n // When\n const result = command.parseResponse(response);\n\n // Then\n expect(result).toEqual(\n CommandResultFactory({\n data: {\n tlvSignature: \"\",\n },\n }),\n );\n });\n\n it(\"should handle error response codes\", () => {\n // Given\n const command = new SignRootIntentCommand({\n chunkedData: mockChunkedData,\n isFirst: true,\n });\n\n // User denied\n const response: ApduResponse = {\n statusCode: new Uint8Array([0x69, 0xf0]),\n data: new Uint8Array([]),\n };\n\n // When\n const result = command.parseResponse(response);\n\n // Then\n expect(isSuccessCommandResult(result)).toBe(false);\n if (!isSuccessCommandResult(result)) {\n expect(result.error).toEqual(\n expect.objectContaining({\n _tag: \"AleoAppCommandError\",\n errorCode: \"69f0\",\n message: \"Denied by user\",\n }),\n );\n }\n });\n\n it(\"should handle device error codes\", () => {\n // Given\n const command = new SignRootIntentCommand({\n chunkedData: mockChunkedData,\n isFirst: true,\n });\n\n // Wrong transaction length\n const response: ApduResponse = {\n statusCode: new Uint8Array([0xb0, 0x04]),\n data: new Uint8Array([]),\n };\n\n // When\n const result = command.parseResponse(response);\n\n // Then\n expect(isSuccessCommandResult(result)).toBe(false);\n if (!isSuccessCommandResult(result)) {\n expect(result.error).toEqual(\n expect.objectContaining({\n _tag: \"AleoAppCommandError\",\n errorCode: \"b004\",\n message: \"Wrong transaction length\",\n }),\n );\n }\n });\n });\n});\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": ["import_device_management_kit", "import_apduHeaderUtils", "import_SignRootIntentCommand", "mockChunkedData", "mockLongChunkedData", "command", "apdu", "response", "result"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var s=Object.defineProperty;var N=Object.getOwnPropertyDescriptor;var
|
|
1
|
+
"use strict";var s=Object.defineProperty;var N=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var n=Object.prototype.hasOwnProperty;var I=(_,E)=>{for(var o in E)s(_,o,{get:E[o],enumerable:!0})},S=(_,E,o,t)=>{if(E&&typeof E=="object"||typeof E=="function")for(let x of c(E))!n.call(_,x)&&x!==o&&s(_,x,{get:()=>E[x],enumerable:!(t=N(E,x))||t.enumerable});return _};var T=_=>S(s({},"__esModule",{value:!0}),_);var A={};I(A,{ALEO_CLA:()=>C,INS:()=>G,P1:()=>e,P2:()=>D,P2_DEFAULT:()=>O});module.exports=T(A);const C=224,O=0,D={FIRST_CHUNK:0,NEXT_CHUNK:1},G={GET_APP_VERSION:3,GET_ADDRESS:5,SIGN_INTENT:6,GET_VIEW_KEY:7},e={SIGN_MODE_ROOT:0,SIGN_MODE_NESTED_CALL:1,SIGN_MODE_FEE:2,CHECK_ON_DEVICE:1,NO_CHECK:0};0&&(module.exports={ALEO_CLA,INS,P1,P2,P2_DEFAULT});
|
|
2
2
|
//# sourceMappingURL=apduHeaderUtils.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/internal/app-binder/command/utils/apduHeaderUtils.ts"],
|
|
4
|
-
"sourcesContent": ["export const ALEO_CLA = 0xe0 as const;\nexport const P2_DEFAULT = 0x00 as const;\n\nexport const INS = {\n GET_APP_VERSION: 0x03,\n GET_ADDRESS: 0x05,\n SIGN_INTENT: 0x06,\n GET_VIEW_KEY: 0x07,\n} as const;\n\nexport const P1 = {\n SIGN_MODE_ROOT: 0x00,\n SIGN_MODE_NESTED_CALL: 0x01,\n SIGN_MODE_FEE: 0x02,\n CHECK_ON_DEVICE: 0x01,\n NO_CHECK: 0x00,\n} as const;\n"],
|
|
5
|
-
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,cAAAE,EAAA,QAAAC,EAAA,OAAAC,EAAA,eAAAC,IAAA,eAAAC,
|
|
6
|
-
"names": ["apduHeaderUtils_exports", "__export", "ALEO_CLA", "INS", "P1", "P2_DEFAULT", "__toCommonJS"]
|
|
4
|
+
"sourcesContent": ["export const ALEO_CLA = 0xe0 as const;\nexport const P2_DEFAULT = 0x00 as const;\n\nexport const P2 = {\n FIRST_CHUNK: 0x00,\n NEXT_CHUNK: 0x01,\n} as const;\n\nexport const INS = {\n GET_APP_VERSION: 0x03,\n GET_ADDRESS: 0x05,\n SIGN_INTENT: 0x06,\n GET_VIEW_KEY: 0x07,\n} as const;\n\nexport const P1 = {\n SIGN_MODE_ROOT: 0x00,\n SIGN_MODE_NESTED_CALL: 0x01,\n SIGN_MODE_FEE: 0x02,\n CHECK_ON_DEVICE: 0x01,\n NO_CHECK: 0x00,\n} as const;\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,cAAAE,EAAA,QAAAC,EAAA,OAAAC,EAAA,OAAAC,EAAA,eAAAC,IAAA,eAAAC,EAAAP,GAAO,MAAME,EAAW,IACXI,EAAa,EAEbD,EAAK,CAChB,YAAa,EACb,WAAY,CACd,EAEaF,EAAM,CACjB,gBAAiB,EACjB,YAAa,EACb,YAAa,EACb,aAAc,CAChB,EAEaC,EAAK,CAChB,eAAgB,EAChB,sBAAuB,EACvB,cAAe,EACf,gBAAiB,EACjB,SAAU,CACZ",
|
|
6
|
+
"names": ["apduHeaderUtils_exports", "__export", "ALEO_CLA", "INS", "P1", "P2", "P2_DEFAULT", "__toCommonJS"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var a=Object.defineProperty;var t=Object.getOwnPropertyDescriptor;var C=Object.getOwnPropertyNames;var l=Object.prototype.hasOwnProperty;var A=(r,o,n,m)=>{if(o&&typeof o=="object"||typeof o=="function")for(let e of C(o))!l.call(r,e)&&e!==n&&a(r,e,{get:()=>o[e],enumerable:!(m=t(o,e))||m.enumerable});return r};var d=r=>A(a({},"__esModule",{value:!0}),r);var p={};module.exports=d(p);
|
|
2
|
+
//# sourceMappingURL=AleoChunkableCommandArgs.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/internal/app-binder/task/AleoChunkableCommandArgs.ts"],
|
|
4
|
+
"sourcesContent": ["import { type Command } from \"@ledgerhq/device-management-kit\";\n\nimport { type AleoErrorCodes } from \"@internal/app-binder/command/utils/aleoApplicationErrors\";\n\nexport type AleoChunkableCommandArgs = {\n chunkedData: Uint8Array;\n isFirst: boolean;\n};\n\nexport type AleoCommandFactory<T> = (\n args: AleoChunkableCommandArgs,\n) => Command<T, AleoChunkableCommandArgs, AleoErrorCodes>;\n"],
|
|
5
|
+
"mappings": "+WAAA,IAAAA,EAAA,kBAAAC,EAAAD",
|
|
6
|
+
"names": ["AleoChunkableCommandArgs_exports", "__toCommonJS"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var s=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var c=Object.prototype.hasOwnProperty;var u=(t,o)=>{for(var e in o)s(t,e,{get:o[e],enumerable:!0})},A=(t,o,e,n)=>{if(o&&typeof o=="object"||typeof o=="function")for(let r of l(o))!c.call(t,r)&&r!==e&&s(t,r,{get:()=>o[r],enumerable:!(n=i(o,r))||n.enumerable});return t};var p=t=>A(s({},"__esModule",{value:!0}),t);var h={};u(h,{SendAleoCommandInChunksTask:()=>C});module.exports=p(h);var a=require("@ledgerhq/device-management-kit");class C{constructor(o,e){this.api=o;this.args=e}async run(){const{data:o,commandFactory:e}=this.args;let n;for(let r=0;r<o.length;r+=a.APDU_MAX_PAYLOAD){const m=r===0,d=o.slice(r,r+a.APDU_MAX_PAYLOAD);if(n=await this.api.sendCommand(e({chunkedData:d,isFirst:m})),!(0,a.isSuccessCommandResult)(n))return n}if(!n)throw new Error("No data to send in chunks");return n}}0&&(module.exports={SendAleoCommandInChunksTask});
|
|
2
|
+
//# sourceMappingURL=SendAleoCommandInChunksTask.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/internal/app-binder/task/SendAleoCommandInChunksTask.ts"],
|
|
4
|
+
"sourcesContent": ["import {\n APDU_MAX_PAYLOAD,\n type CommandResult,\n type InternalApi,\n isSuccessCommandResult,\n} from \"@ledgerhq/device-management-kit\";\n\nimport { type AleoErrorCodes } from \"@internal/app-binder/command/utils/aleoApplicationErrors\";\n\nimport { type AleoCommandFactory } from \"./AleoChunkableCommandArgs\";\n\nexport type SendAleoCommandInChunksTaskArgs<T> = {\n dataLength: number;\n data: Uint8Array;\n derivationPath?: string;\n commandFactory: AleoCommandFactory<T>;\n};\n\nexport class SendAleoCommandInChunksTask<T> {\n constructor(\n private api: InternalApi,\n private args: SendAleoCommandInChunksTaskArgs<T>,\n ) {}\n\n async run(): Promise<CommandResult<T, AleoErrorCodes>> {\n const { data, commandFactory } = this.args;\n let result: CommandResult<T, AleoErrorCodes> | undefined;\n\n for (let i = 0; i < data.length; i += APDU_MAX_PAYLOAD) {\n const isFirst = i === 0;\n const chunk = data.slice(i, i + APDU_MAX_PAYLOAD);\n\n result = await this.api.sendCommand(\n commandFactory({\n chunkedData: chunk,\n isFirst,\n }),\n );\n\n if (!isSuccessCommandResult(result)) {\n return result;\n }\n }\n\n if (!result) {\n // Should not happen if data.length > 0\n throw new Error(\"No data to send in chunks\");\n }\n\n return result;\n }\n}\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,iCAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAKO,2CAaA,MAAMF,CAA+B,CAC1C,YACUG,EACAC,EACR,CAFQ,SAAAD,EACA,UAAAC,CACP,CAEH,MAAM,KAAiD,CACrD,KAAM,CAAE,KAAAC,EAAM,eAAAC,CAAe,EAAI,KAAK,KACtC,IAAIC,EAEJ,QAASC,EAAI,EAAGA,EAAIH,EAAK,OAAQG,GAAK,mBAAkB,CACtD,MAAMC,EAAUD,IAAM,EAChBE,EAAQL,EAAK,MAAMG,EAAGA,EAAI,kBAAgB,EAShD,GAPAD,EAAS,MAAM,KAAK,IAAI,YACtBD,EAAe,CACb,YAAaI,EACb,QAAAD,CACF,CAAC,CACH,EAEI,IAAC,0BAAuBF,CAAM,EAChC,OAAOA,CAEX,CAEA,GAAI,CAACA,EAEH,MAAM,IAAI,MAAM,2BAA2B,EAG7C,OAAOA,CACT,CACF",
|
|
6
|
+
"names": ["SendAleoCommandInChunksTask_exports", "__export", "SendAleoCommandInChunksTask", "__toCommonJS", "import_device_management_kit", "api", "args", "data", "commandFactory", "result", "i", "isFirst", "chunk"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var a=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var g=Object.getOwnPropertyNames;var l=Object.prototype.hasOwnProperty;var y=(t,e)=>{for(var n in e)a(t,n,{get:e[n],enumerable:!0})},I=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of g(e))!l.call(t,o)&&o!==n&&a(t,o,{get:()=>e[o],enumerable:!(r=p(e,o))||r.enumerable});return t};var u=t=>I(a({},"__esModule",{value:!0}),t);var C={};y(C,{SignFeeIntentTask:()=>c});module.exports=u(C);var s=require("@ledgerhq/device-management-kit"),i=require("../../app-binder/command/SignFeeIntentCommand"),m=require("./SendAleoCommandInChunksTask");class c{constructor(e,n){this.api=e;this.args=n}async run(){const{feeIntent:e}=this.args,n=2+e.byteLength,r=new s.ByteArrayBuilder(n);r.add16BitUIntToData(e.byteLength),r.addBufferToData(e);const o=r.build();return new m.SendAleoCommandInChunksTask(this.api,{dataLength:e.byteLength,data:o,commandFactory:d=>new i.SignFeeIntentCommand(d)}).run()}}0&&(module.exports={SignFeeIntentTask});
|
|
2
|
+
//# sourceMappingURL=SignFeeIntentTask.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/internal/app-binder/task/SignFeeIntentTask.ts"],
|
|
4
|
+
"sourcesContent": ["import {\n ByteArrayBuilder,\n type CommandResult,\n type InternalApi,\n} from \"@ledgerhq/device-management-kit\";\n\nimport {\n SignFeeIntentCommand,\n type SignFeeIntentCommandResponse,\n} from \"@internal/app-binder/command/SignFeeIntentCommand\";\nimport { type AleoErrorCodes } from \"@internal/app-binder/command/utils/aleoApplicationErrors\";\n\nimport { SendAleoCommandInChunksTask } from \"./SendAleoCommandInChunksTask\";\n\nexport type SignFeeIntentTaskArgs = {\n feeIntent: Uint8Array;\n};\n\nexport class SignFeeIntentTask {\n constructor(\n private api: InternalApi,\n private args: SignFeeIntentTaskArgs,\n ) {}\n\n async run(): Promise<\n CommandResult<SignFeeIntentCommandResponse, AleoErrorCodes>\n > {\n const { feeIntent } = this.args;\n\n // Data length (2 bytes) + Fee intent data\n const totalLength = 2 + feeIntent.byteLength;\n\n const builder = new ByteArrayBuilder(totalLength);\n\n // Add intent length\n builder.add16BitUIntToData(feeIntent.byteLength);\n\n // Add the fee intent data\n builder.addBufferToData(feeIntent);\n\n const fullPayload = builder.build();\n\n return new SendAleoCommandInChunksTask<SignFeeIntentCommandResponse>(\n this.api,\n {\n dataLength: feeIntent.byteLength,\n data: fullPayload,\n commandFactory: (chunkArgs) => new SignFeeIntentCommand(chunkArgs),\n },\n ).run();\n }\n}\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,uBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAIO,2CAEPC,EAGO,6DAGPC,EAA4C,yCAMrC,MAAMJ,CAAkB,CAC7B,YACUK,EACAC,EACR,CAFQ,SAAAD,EACA,UAAAC,CACP,CAEH,MAAM,KAEJ,CACA,KAAM,CAAE,UAAAC,CAAU,EAAI,KAAK,KAGrBC,EAAc,EAAID,EAAU,WAE5BE,EAAU,IAAI,mBAAiBD,CAAW,EAGhDC,EAAQ,mBAAmBF,EAAU,UAAU,EAG/CE,EAAQ,gBAAgBF,CAAS,EAEjC,MAAMG,EAAcD,EAAQ,MAAM,EAElC,OAAO,IAAI,8BACT,KAAK,IACL,CACE,WAAYF,EAAU,WACtB,KAAMG,EACN,eAAiBC,GAAc,IAAI,uBAAqBA,CAAS,CACnE,CACF,EAAE,IAAI,CACR,CACF",
|
|
6
|
+
"names": ["SignFeeIntentTask_exports", "__export", "SignFeeIntentTask", "__toCommonJS", "import_device_management_kit", "import_SignFeeIntentCommand", "import_SendAleoCommandInChunksTask", "api", "args", "feeIntent", "totalLength", "builder", "fullPayload", "chunkArgs"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var e=require("@ledgerhq/device-management-kit"),u=require("../../app-binder/task/__test-utils__/makeInternalApi"),i=require("../../app-binder/task/SignFeeIntentTask");describe("SignFeeIntentTask",()=>{const t=(0,u.makeDeviceActionInternalApiMock)(),c={tlvSignature:"mock_signature"},l=(0,e.CommandResultFactory)({data:c}),m=(0,e.CommandResultFactory)({data:{tlvSignature:""}});beforeEach(()=>{vi.resetAllMocks()}),it("should send the fee intent in a single command",async()=>{const n=new Uint8Array([5,6,7,8]),a=new e.ByteArrayBuilder(2+n.length);a.add16BitUIntToData(n.length),a.addBufferToData(n);const s=a.build();t.sendCommand.mockResolvedValueOnce(l);const o=await new i.SignFeeIntentTask(t,{feeIntent:n}).run();expect(t.sendCommand).toHaveBeenCalledTimes(1),expect(t.sendCommand).toHaveBeenCalledWith(expect.objectContaining({args:{chunkedData:s,isFirst:!0}})),(0,e.isSuccessCommandResult)(o)?expect(o.data).toEqual(c):assert.fail("Expected success")}),it("should send the fee intent in multiple chunks",async()=>{const n=new Uint8Array(300).fill(36),a=new e.ByteArrayBuilder(2+n.length);a.add16BitUIntToData(n.length),a.addBufferToData(n);const s=a.build(),d=s.slice(0,e.APDU_MAX_PAYLOAD),o=s.slice(e.APDU_MAX_PAYLOAD);t.sendCommand.mockResolvedValueOnce(m).mockResolvedValueOnce(l);const r=await new i.SignFeeIntentTask(t,{feeIntent:n}).run();expect(t.sendCommand).toHaveBeenCalledTimes(2),expect(t.sendCommand).toHaveBeenNthCalledWith(1,expect.objectContaining({args:{chunkedData:d,isFirst:!0}})),expect(t.sendCommand).toHaveBeenNthCalledWith(2,expect.objectContaining({args:{chunkedData:o,isFirst:!1}})),(0,e.isSuccessCommandResult)(r)?expect(r.data).toEqual(c):assert.fail("Expected success")})});
|
|
2
|
+
//# sourceMappingURL=SignFeeIntentTask.test.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/internal/app-binder/task/SignFeeIntentTask.test.ts"],
|
|
4
|
+
"sourcesContent": ["import {\n APDU_MAX_PAYLOAD,\n ByteArrayBuilder,\n CommandResultFactory,\n isSuccessCommandResult,\n} from \"@ledgerhq/device-management-kit\";\n\nimport { makeDeviceActionInternalApiMock } from \"@internal/app-binder/task/__test-utils__/makeInternalApi\";\nimport { SignFeeIntentTask } from \"@internal/app-binder/task/SignFeeIntentTask\";\n\ndescribe(\"SignFeeIntentTask\", () => {\n const apiMock = makeDeviceActionInternalApiMock();\n const signature = { tlvSignature: \"mock_signature\" };\n const resultOk = CommandResultFactory({ data: signature });\n const resultEmpty = CommandResultFactory({ data: { tlvSignature: \"\" } });\n\n beforeEach(() => {\n vi.resetAllMocks();\n });\n\n it(\"should send the fee intent in a single command\", async () => {\n // GIVEN\n const feeIntent = new Uint8Array([0x05, 0x06, 0x07, 0x08]);\n\n // Calculate expected payload: 2 (intent len) + intent\n const builder = new ByteArrayBuilder(2 + feeIntent.length);\n builder.add16BitUIntToData(feeIntent.length);\n builder.addBufferToData(feeIntent);\n const expectedPayload = builder.build();\n\n apiMock.sendCommand.mockResolvedValueOnce(resultOk);\n\n const task = new SignFeeIntentTask(apiMock, {\n feeIntent,\n });\n\n // WHEN\n const result = await task.run();\n\n // THEN\n expect(apiMock.sendCommand).toHaveBeenCalledTimes(1);\n expect(apiMock.sendCommand).toHaveBeenCalledWith(\n expect.objectContaining({\n args: {\n chunkedData: expectedPayload,\n isFirst: true,\n },\n }),\n );\n\n if (isSuccessCommandResult(result)) {\n expect(result.data).toEqual(signature);\n } else {\n assert.fail(\"Expected success\");\n }\n });\n\n it(\"should send the fee intent in multiple chunks\", async () => {\n // GIVEN\n // Create a large fee intent so total payload > APDU_MAX_PAYLOAD (255)\n const feeIntent = new Uint8Array(300).fill(0x24);\n\n const builder = new ByteArrayBuilder(2 + feeIntent.length);\n builder.add16BitUIntToData(feeIntent.length);\n builder.addBufferToData(feeIntent);\n const fullPayload = builder.build();\n\n const chunk1 = fullPayload.slice(0, APDU_MAX_PAYLOAD);\n const chunk2 = fullPayload.slice(APDU_MAX_PAYLOAD);\n\n apiMock.sendCommand\n .mockResolvedValueOnce(resultEmpty)\n .mockResolvedValueOnce(resultOk);\n\n const task = new SignFeeIntentTask(apiMock, {\n feeIntent,\n });\n\n // WHEN\n const result = await task.run();\n\n // THEN\n expect(apiMock.sendCommand).toHaveBeenCalledTimes(2);\n\n // First chunk\n expect(apiMock.sendCommand).toHaveBeenNthCalledWith(\n 1,\n expect.objectContaining({\n args: {\n chunkedData: chunk1,\n isFirst: true,\n },\n }),\n );\n\n // Second chunk\n expect(apiMock.sendCommand).toHaveBeenNthCalledWith(\n 2,\n expect.objectContaining({\n args: {\n chunkedData: chunk2,\n isFirst: false,\n },\n }),\n );\n\n if (isSuccessCommandResult(result)) {\n expect(result.data).toEqual(signature);\n } else {\n assert.fail(\"Expected success\");\n }\n });\n});\n"],
|
|
5
|
+
"mappings": "aAAA,IAAAA,EAKO,2CAEPC,EAAgD,oEAChDC,EAAkC,uDAElC,SAAS,oBAAqB,IAAM,CAClC,MAAMC,KAAU,mCAAgC,EAC1CC,EAAY,CAAE,aAAc,gBAAiB,EAC7CC,KAAW,wBAAqB,CAAE,KAAMD,CAAU,CAAC,EACnDE,KAAc,wBAAqB,CAAE,KAAM,CAAE,aAAc,EAAG,CAAE,CAAC,EAEvE,WAAW,IAAM,CACf,GAAG,cAAc,CACnB,CAAC,EAED,GAAG,iDAAkD,SAAY,CAE/D,MAAMC,EAAY,IAAI,WAAW,CAAC,EAAM,EAAM,EAAM,CAAI,CAAC,EAGnDC,EAAU,IAAI,mBAAiB,EAAID,EAAU,MAAM,EACzDC,EAAQ,mBAAmBD,EAAU,MAAM,EAC3CC,EAAQ,gBAAgBD,CAAS,EACjC,MAAME,EAAkBD,EAAQ,MAAM,EAEtCL,EAAQ,YAAY,sBAAsBE,CAAQ,EAOlD,MAAMK,EAAS,MALF,IAAI,oBAAkBP,EAAS,CAC1C,UAAAI,CACF,CAAC,EAGyB,IAAI,EAG9B,OAAOJ,EAAQ,WAAW,EAAE,sBAAsB,CAAC,EACnD,OAAOA,EAAQ,WAAW,EAAE,qBAC1B,OAAO,iBAAiB,CACtB,KAAM,CACJ,YAAaM,EACb,QAAS,EACX,CACF,CAAC,CACH,KAEI,0BAAuBC,CAAM,EAC/B,OAAOA,EAAO,IAAI,EAAE,QAAQN,CAAS,EAErC,OAAO,KAAK,kBAAkB,CAElC,CAAC,EAED,GAAG,gDAAiD,SAAY,CAG9D,MAAMG,EAAY,IAAI,WAAW,GAAG,EAAE,KAAK,EAAI,EAEzCC,EAAU,IAAI,mBAAiB,EAAID,EAAU,MAAM,EACzDC,EAAQ,mBAAmBD,EAAU,MAAM,EAC3CC,EAAQ,gBAAgBD,CAAS,EACjC,MAAMI,EAAcH,EAAQ,MAAM,EAE5BI,EAASD,EAAY,MAAM,EAAG,kBAAgB,EAC9CE,EAASF,EAAY,MAAM,kBAAgB,EAEjDR,EAAQ,YACL,sBAAsBG,CAAW,EACjC,sBAAsBD,CAAQ,EAOjC,MAAMK,EAAS,MALF,IAAI,oBAAkBP,EAAS,CAC1C,UAAAI,CACF,CAAC,EAGyB,IAAI,EAG9B,OAAOJ,EAAQ,WAAW,EAAE,sBAAsB,CAAC,EAGnD,OAAOA,EAAQ,WAAW,EAAE,wBAC1B,EACA,OAAO,iBAAiB,CACtB,KAAM,CACJ,YAAaS,EACb,QAAS,EACX,CACF,CAAC,CACH,EAGA,OAAOT,EAAQ,WAAW,EAAE,wBAC1B,EACA,OAAO,iBAAiB,CACtB,KAAM,CACJ,YAAaU,EACb,QAAS,EACX,CACF,CAAC,CACH,KAEI,0BAAuBH,CAAM,EAC/B,OAAOA,EAAO,IAAI,EAAE,QAAQN,CAAS,EAErC,OAAO,KAAK,kBAAkB,CAElC,CAAC,CACH,CAAC",
|
|
6
|
+
"names": ["import_device_management_kit", "import_makeInternalApi", "import_SignFeeIntentTask", "apiMock", "signature", "resultOk", "resultEmpty", "feeIntent", "builder", "expectedPayload", "result", "fullPayload", "chunk1", "chunk2"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var s=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var I=Object.getOwnPropertyNames;var y=Object.prototype.hasOwnProperty;var c=(o,t)=>{for(var n in t)s(o,n,{get:t[n],enumerable:!0})},u=(o,t,n,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let e of I(t))!y.call(o,e)&&e!==n&&s(o,e,{get:()=>t[e],enumerable:!(a=h(t,e))||a.enumerable});return o};var R=o=>u(s({},"__esModule",{value:!0}),o);var f={};c(f,{SignRootIntentTask:()=>C});module.exports=R(f);var d=require("@ledgerhq/device-management-kit"),m=require("@ledgerhq/signer-utils"),p=require("../../app-binder/command/SignRootIntentCommand"),g=require("./SendAleoCommandInChunksTask");class C{constructor(t,n){this.api=t;this.args=n}async run(){const{derivationPath:t,rootIntent:n}=this.args,a=m.DerivationPathUtils.splitPath(t),e=1+a.length*4+2+n.byteLength,r=new d.ByteArrayBuilder(e);r.add8BitUIntToData(a.length),a.forEach(i=>{r.add32BitUIntToData(i)}),r.add16BitUIntToData(n.byteLength),r.addBufferToData(n);const l=r.build();return new g.SendAleoCommandInChunksTask(this.api,{dataLength:n.byteLength,data:l,commandFactory:i=>new p.SignRootIntentCommand(i)}).run()}}0&&(module.exports={SignRootIntentTask});
|
|
2
|
+
//# sourceMappingURL=SignRootIntentTask.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/internal/app-binder/task/SignRootIntentTask.ts"],
|
|
4
|
+
"sourcesContent": ["import {\n ByteArrayBuilder,\n type CommandResult,\n type InternalApi,\n} from \"@ledgerhq/device-management-kit\";\nimport { DerivationPathUtils } from \"@ledgerhq/signer-utils\";\n\nimport {\n SignRootIntentCommand,\n type SignRootIntentCommandResponse,\n} from \"@internal/app-binder/command/SignRootIntentCommand\";\nimport { type AleoErrorCodes } from \"@internal/app-binder/command/utils/aleoApplicationErrors\";\n\nimport { SendAleoCommandInChunksTask } from \"./SendAleoCommandInChunksTask\";\n\nexport type SignRootIntentTaskArgs = {\n derivationPath: string;\n rootIntent: Uint8Array;\n};\n\nexport class SignRootIntentTask {\n constructor(\n private api: InternalApi,\n private args: SignRootIntentTaskArgs,\n ) {}\n\n async run(): Promise<\n CommandResult<SignRootIntentCommandResponse, AleoErrorCodes>\n > {\n const { derivationPath, rootIntent } = this.args;\n\n const path = DerivationPathUtils.splitPath(derivationPath);\n // Path length (1 byte) + Path (4 bytes per element) + Data length (2 bytes) + Root intent data\n const totalLength = 1 + path.length * 4 + 2 + rootIntent.byteLength;\n\n const builder = new ByteArrayBuilder(totalLength);\n\n // Add the derivation path\n builder.add8BitUIntToData(path.length);\n path.forEach((element) => {\n builder.add32BitUIntToData(element);\n });\n\n // Add intent length\n builder.add16BitUIntToData(rootIntent.byteLength);\n\n // Add the root intent data\n builder.addBufferToData(rootIntent);\n\n const fullPayload = builder.build();\n\n return new SendAleoCommandInChunksTask<SignRootIntentCommandResponse>(\n this.api,\n {\n dataLength: rootIntent.byteLength,\n data: fullPayload,\n commandFactory: (chunkArgs) => new SignRootIntentCommand(chunkArgs),\n },\n ).run();\n }\n}\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,wBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAIO,2CACPC,EAAoC,kCAEpCC,EAGO,8DAGPC,EAA4C,yCAOrC,MAAML,CAAmB,CAC9B,YACUM,EACAC,EACR,CAFQ,SAAAD,EACA,UAAAC,CACP,CAEH,MAAM,KAEJ,CACA,KAAM,CAAE,eAAAC,EAAgB,WAAAC,CAAW,EAAI,KAAK,KAEtCC,EAAO,sBAAoB,UAAUF,CAAc,EAEnDG,EAAc,EAAID,EAAK,OAAS,EAAI,EAAID,EAAW,WAEnDG,EAAU,IAAI,mBAAiBD,CAAW,EAGhDC,EAAQ,kBAAkBF,EAAK,MAAM,EACrCA,EAAK,QAASG,GAAY,CACxBD,EAAQ,mBAAmBC,CAAO,CACpC,CAAC,EAGDD,EAAQ,mBAAmBH,EAAW,UAAU,EAGhDG,EAAQ,gBAAgBH,CAAU,EAElC,MAAMK,EAAcF,EAAQ,MAAM,EAElC,OAAO,IAAI,8BACT,KAAK,IACL,CACE,WAAYH,EAAW,WACvB,KAAMK,EACN,eAAiBC,GAAc,IAAI,wBAAsBA,CAAS,CACpE,CACF,EAAE,IAAI,CACR,CACF",
|
|
6
|
+
"names": ["SignRootIntentTask_exports", "__export", "SignRootIntentTask", "__toCommonJS", "import_device_management_kit", "import_signer_utils", "import_SignRootIntentCommand", "import_SendAleoCommandInChunksTask", "api", "args", "derivationPath", "rootIntent", "path", "totalLength", "builder", "element", "fullPayload", "chunkArgs"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var t=require("@ledgerhq/device-management-kit"),l=require("@ledgerhq/signer-utils"),r=require("../../app-binder/task/SignRootIntentTask"),g=require("./__test-utils__/makeInternalApi");const c="44'/683'/0'/0'/0'";describe("SignRootIntentTask",()=>{const a=(0,g.makeDeviceActionInternalApiMock)(),d={tlvSignature:"mock_signature"},u=(0,t.CommandResultFactory)({data:d}),k=(0,t.CommandResultFactory)({data:{tlvSignature:""}});beforeEach(()=>{vi.resetAllMocks()}),it("should send the root intent in a single command",async()=>{const n=new Uint8Array([1,2,3,4]),o=l.DerivationPathUtils.splitPath(c),e=new t.ByteArrayBuilder(1+o.length*4+2+n.length);e.add8BitUIntToData(o.length),o.forEach(h=>e.add32BitUIntToData(h)),e.add16BitUIntToData(n.length),e.addBufferToData(n);const s=e.build();a.sendCommand.mockResolvedValueOnce(u);const i=await new r.SignRootIntentTask(a,{derivationPath:c,rootIntent:n}).run();expect(a.sendCommand).toHaveBeenCalledTimes(1),expect(a.sendCommand).toHaveBeenCalledWith(expect.objectContaining({args:{chunkedData:s,isFirst:!0}})),(0,t.isSuccessCommandResult)(i)?expect(i.data).toEqual(d):assert.fail("Expected success")}),it("should send the root intent in multiple chunks",async()=>{const n=new Uint8Array(300).fill(66),o=l.DerivationPathUtils.splitPath(c),e=new t.ByteArrayBuilder(1+o.length*4+2+n.length);e.add8BitUIntToData(o.length),o.forEach(f=>e.add32BitUIntToData(f)),e.add16BitUIntToData(n.length),e.addBufferToData(n);const s=e.build(),m=s.slice(0,t.APDU_MAX_PAYLOAD),i=s.slice(t.APDU_MAX_PAYLOAD);a.sendCommand.mockResolvedValueOnce(k).mockResolvedValueOnce(u);const p=await new r.SignRootIntentTask(a,{derivationPath:c,rootIntent:n}).run();expect(a.sendCommand).toHaveBeenCalledTimes(2),expect(a.sendCommand).toHaveBeenNthCalledWith(1,expect.objectContaining({args:{chunkedData:m,isFirst:!0}})),expect(a.sendCommand).toHaveBeenNthCalledWith(2,expect.objectContaining({args:{chunkedData:i,isFirst:!1}})),(0,t.isSuccessCommandResult)(p)?expect(p.data).toEqual(d):assert.fail("Expected success")})});
|
|
2
|
+
//# sourceMappingURL=SignRootIntentTask.test.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/internal/app-binder/task/SignRootIntentTask.test.ts"],
|
|
4
|
+
"sourcesContent": ["import {\n APDU_MAX_PAYLOAD,\n ByteArrayBuilder,\n CommandResultFactory,\n isSuccessCommandResult,\n} from \"@ledgerhq/device-management-kit\";\nimport { DerivationPathUtils } from \"@ledgerhq/signer-utils\";\n\nimport { SignRootIntentTask } from \"@internal/app-binder/task/SignRootIntentTask\";\n\nimport { makeDeviceActionInternalApiMock } from \"./__test-utils__/makeInternalApi\";\n\nconst DERIVATION_PATH = \"44'/683'/0'/0'/0'\";\n\ndescribe(\"SignRootIntentTask\", () => {\n const apiMock = makeDeviceActionInternalApiMock();\n const signature = { tlvSignature: \"mock_signature\" };\n const resultOk = CommandResultFactory({ data: signature });\n const resultEmpty = CommandResultFactory({ data: { tlvSignature: \"\" } });\n\n beforeEach(() => {\n vi.resetAllMocks();\n });\n\n it(\"should send the root intent in a single command\", async () => {\n // GIVEN\n const rootIntent = new Uint8Array([0x01, 0x02, 0x03, 0x04]);\n const paths = DerivationPathUtils.splitPath(DERIVATION_PATH);\n\n // Calculate expected payload: 1 (path len) + path (4 * len) + 2 (intent len) + intent\n const builder = new ByteArrayBuilder(\n 1 + paths.length * 4 + 2 + rootIntent.length,\n );\n builder.add8BitUIntToData(paths.length);\n paths.forEach((p) => builder.add32BitUIntToData(p));\n builder.add16BitUIntToData(rootIntent.length);\n builder.addBufferToData(rootIntent);\n const expectedPayload = builder.build();\n\n apiMock.sendCommand.mockResolvedValueOnce(resultOk);\n\n const task = new SignRootIntentTask(apiMock, {\n derivationPath: DERIVATION_PATH,\n rootIntent,\n });\n\n // WHEN\n const result = await task.run();\n\n // THEN\n expect(apiMock.sendCommand).toHaveBeenCalledTimes(1);\n expect(apiMock.sendCommand).toHaveBeenCalledWith(\n expect.objectContaining({\n args: {\n chunkedData: expectedPayload,\n isFirst: true,\n },\n }),\n );\n\n if (isSuccessCommandResult(result)) {\n expect(result.data).toEqual(signature);\n } else {\n assert.fail(\"Expected success\");\n }\n });\n\n it(\"should send the root intent in multiple chunks\", async () => {\n // GIVEN\n // Create a large root intent so total payload > APDU_MAX_PAYLOAD (255)\n const rootIntent = new Uint8Array(300).fill(0x42);\n const paths = DerivationPathUtils.splitPath(DERIVATION_PATH);\n\n const builder = new ByteArrayBuilder(\n 1 + paths.length * 4 + 2 + rootIntent.length,\n );\n builder.add8BitUIntToData(paths.length);\n paths.forEach((p) => builder.add32BitUIntToData(p));\n builder.add16BitUIntToData(rootIntent.length);\n builder.addBufferToData(rootIntent);\n const fullPayload = builder.build();\n\n const chunk1 = fullPayload.slice(0, APDU_MAX_PAYLOAD);\n const chunk2 = fullPayload.slice(APDU_MAX_PAYLOAD);\n\n apiMock.sendCommand\n .mockResolvedValueOnce(resultEmpty)\n .mockResolvedValueOnce(resultOk);\n\n const task = new SignRootIntentTask(apiMock, {\n derivationPath: DERIVATION_PATH,\n rootIntent,\n });\n\n // WHEN\n const result = await task.run();\n\n // THEN\n expect(apiMock.sendCommand).toHaveBeenCalledTimes(2);\n\n // First chunk\n expect(apiMock.sendCommand).toHaveBeenNthCalledWith(\n 1,\n expect.objectContaining({\n args: {\n chunkedData: chunk1,\n isFirst: true,\n },\n }),\n );\n\n // Second chunk\n expect(apiMock.sendCommand).toHaveBeenNthCalledWith(\n 2,\n expect.objectContaining({\n args: {\n chunkedData: chunk2,\n isFirst: false,\n },\n }),\n );\n\n if (isSuccessCommandResult(result)) {\n expect(result.data).toEqual(signature);\n } else {\n assert.fail(\"Expected success\");\n }\n });\n});\n"],
|
|
5
|
+
"mappings": "aAAA,IAAAA,EAKO,2CACPC,EAAoC,kCAEpCC,EAAmC,wDAEnCC,EAAgD,4CAEhD,MAAMC,EAAkB,oBAExB,SAAS,qBAAsB,IAAM,CACnC,MAAMC,KAAU,mCAAgC,EAC1CC,EAAY,CAAE,aAAc,gBAAiB,EAC7CC,KAAW,wBAAqB,CAAE,KAAMD,CAAU,CAAC,EACnDE,KAAc,wBAAqB,CAAE,KAAM,CAAE,aAAc,EAAG,CAAE,CAAC,EAEvE,WAAW,IAAM,CACf,GAAG,cAAc,CACnB,CAAC,EAED,GAAG,kDAAmD,SAAY,CAEhE,MAAMC,EAAa,IAAI,WAAW,CAAC,EAAM,EAAM,EAAM,CAAI,CAAC,EACpDC,EAAQ,sBAAoB,UAAUN,CAAe,EAGrDO,EAAU,IAAI,mBAClB,EAAID,EAAM,OAAS,EAAI,EAAID,EAAW,MACxC,EACAE,EAAQ,kBAAkBD,EAAM,MAAM,EACtCA,EAAM,QAASE,GAAMD,EAAQ,mBAAmBC,CAAC,CAAC,EAClDD,EAAQ,mBAAmBF,EAAW,MAAM,EAC5CE,EAAQ,gBAAgBF,CAAU,EAClC,MAAMI,EAAkBF,EAAQ,MAAM,EAEtCN,EAAQ,YAAY,sBAAsBE,CAAQ,EAQlD,MAAMO,EAAS,MANF,IAAI,qBAAmBT,EAAS,CAC3C,eAAgBD,EAChB,WAAAK,CACF,CAAC,EAGyB,IAAI,EAG9B,OAAOJ,EAAQ,WAAW,EAAE,sBAAsB,CAAC,EACnD,OAAOA,EAAQ,WAAW,EAAE,qBAC1B,OAAO,iBAAiB,CACtB,KAAM,CACJ,YAAaQ,EACb,QAAS,EACX,CACF,CAAC,CACH,KAEI,0BAAuBC,CAAM,EAC/B,OAAOA,EAAO,IAAI,EAAE,QAAQR,CAAS,EAErC,OAAO,KAAK,kBAAkB,CAElC,CAAC,EAED,GAAG,iDAAkD,SAAY,CAG/D,MAAMG,EAAa,IAAI,WAAW,GAAG,EAAE,KAAK,EAAI,EAC1CC,EAAQ,sBAAoB,UAAUN,CAAe,EAErDO,EAAU,IAAI,mBAClB,EAAID,EAAM,OAAS,EAAI,EAAID,EAAW,MACxC,EACAE,EAAQ,kBAAkBD,EAAM,MAAM,EACtCA,EAAM,QAASE,GAAMD,EAAQ,mBAAmBC,CAAC,CAAC,EAClDD,EAAQ,mBAAmBF,EAAW,MAAM,EAC5CE,EAAQ,gBAAgBF,CAAU,EAClC,MAAMM,EAAcJ,EAAQ,MAAM,EAE5BK,EAASD,EAAY,MAAM,EAAG,kBAAgB,EAC9CE,EAASF,EAAY,MAAM,kBAAgB,EAEjDV,EAAQ,YACL,sBAAsBG,CAAW,EACjC,sBAAsBD,CAAQ,EAQjC,MAAMO,EAAS,MANF,IAAI,qBAAmBT,EAAS,CAC3C,eAAgBD,EAChB,WAAAK,CACF,CAAC,EAGyB,IAAI,EAG9B,OAAOJ,EAAQ,WAAW,EAAE,sBAAsB,CAAC,EAGnD,OAAOA,EAAQ,WAAW,EAAE,wBAC1B,EACA,OAAO,iBAAiB,CACtB,KAAM,CACJ,YAAaW,EACb,QAAS,EACX,CACF,CAAC,CACH,EAGA,OAAOX,EAAQ,WAAW,EAAE,wBAC1B,EACA,OAAO,iBAAiB,CACtB,KAAM,CACJ,YAAaY,EACb,QAAS,EACX,CACF,CAAC,CACH,KAEI,0BAAuBH,CAAM,EAC/B,OAAOA,EAAO,IAAI,EAAE,QAAQR,CAAS,EAErC,OAAO,KAAK,kBAAkB,CAElC,CAAC,CACH,CAAC",
|
|
6
|
+
"names": ["import_device_management_kit", "import_signer_utils", "import_SignRootIntentTask", "import_makeInternalApi", "DERIVATION_PATH", "apiMock", "signature", "resultOk", "resultEmpty", "rootIntent", "paths", "builder", "p", "expectedPayload", "result", "fullPayload", "chunk1", "chunk2"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var r=Object.defineProperty;var v=Object.getOwnPropertyDescriptor;var a=Object.getOwnPropertyNames;var f=Object.prototype.hasOwnProperty;var c=(n,e)=>{for(var t in e)r(n,t,{get:e[t],enumerable:!0})},s=(n,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of a(e))!f.call(n,i)&&i!==t&&r(n,i,{get:()=>e[i],enumerable:!(o=v(e,i))||o.enumerable});return n};var d=n=>s(r({},"__esModule",{value:!0}),n);var p={};c(p,{makeDeviceActionInternalApiMock:()=>g});module.exports=d(p);function g(){return{sendApdu:vi.fn(),sendCommand:vi.fn().mockResolvedValue(void 0),getDeviceModel:vi.fn(),getDeviceSessionState:vi.fn(),getDeviceSessionStateObservable:vi.fn(),setDeviceSessionState:vi.fn(),getManagerApiService:vi.fn(),getSecureChannelService:vi.fn(),loggerFactory:vi.fn(n=>({debug:vi.fn(),info:vi.fn(),warn:vi.fn(),error:vi.fn(),subscribers:[]}))}}0&&(module.exports={makeDeviceActionInternalApiMock});
|
|
2
|
+
//# sourceMappingURL=makeInternalApi.js.map
|