@ledgerhq/device-signer-kit-aleo 0.0.0-develop-20260305001411 → 0.0.0-develop-20260306001908
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/api/app-binder/GetViewKeyDeviceActionTypes.js.map +1 -1
- package/lib/cjs/api/app-binder/SignFeeIntentDeviceActionTypes.js +2 -0
- package/lib/cjs/api/app-binder/SignFeeIntentDeviceActionTypes.js.map +7 -0
- package/lib/cjs/api/app-binder/SignRootIntentDeviceActionTypes.js +2 -0
- package/lib/cjs/api/app-binder/SignRootIntentDeviceActionTypes.js.map +7 -0
- package/lib/cjs/api/index.js +1 -1
- package/lib/cjs/api/index.js.map +2 -2
- 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/GetAddressCommand.js +1 -1
- package/lib/cjs/internal/app-binder/command/GetAddressCommand.js.map +3 -3
- package/lib/cjs/internal/app-binder/command/GetAddressCommand.test.js +1 -1
- package/lib/cjs/internal/app-binder/command/GetAddressCommand.test.js.map +1 -1
- package/lib/cjs/internal/app-binder/command/GetAppConfigCommand.js +1 -1
- package/lib/cjs/internal/app-binder/command/GetAppConfigCommand.js.map +3 -3
- package/lib/cjs/internal/app-binder/command/GetAppConfigCommand.test.js +1 -1
- package/lib/cjs/internal/app-binder/command/GetAppConfigCommand.test.js.map +3 -3
- package/lib/cjs/internal/app-binder/command/GetViewKeyCommand.js +1 -1
- package/lib/cjs/internal/app-binder/command/GetViewKeyCommand.js.map +3 -3
- package/lib/cjs/internal/app-binder/command/GetViewKeyCommand.test.js +1 -1
- package/lib/cjs/internal/app-binder/command/GetViewKeyCommand.test.js.map +3 -3
- package/lib/cjs/internal/app-binder/command/SignFeeIntentCommand.js +2 -0
- package/lib/cjs/internal/app-binder/command/SignFeeIntentCommand.js.map +7 -0
- package/lib/cjs/internal/app-binder/command/SignFeeIntentCommand.test.js +2 -0
- package/lib/cjs/internal/app-binder/command/SignFeeIntentCommand.test.js.map +7 -0
- package/lib/cjs/internal/app-binder/command/SignRootIntentCommand.js +2 -0
- package/lib/cjs/internal/app-binder/command/SignRootIntentCommand.js.map +7 -0
- package/lib/cjs/internal/app-binder/command/SignRootIntentCommand.test.js +2 -0
- package/lib/cjs/internal/app-binder/command/SignRootIntentCommand.test.js.map +7 -0
- package/lib/cjs/internal/app-binder/command/utils/aleoApplicationErrors.js +1 -1
- package/lib/cjs/internal/app-binder/command/utils/aleoApplicationErrors.js.map +2 -2
- package/lib/cjs/internal/app-binder/command/utils/apduHeaderUtils.js +2 -0
- package/lib/cjs/internal/app-binder/command/utils/apduHeaderUtils.js.map +7 -0
- package/lib/cjs/internal/use-cases/address/GetViewKeyUseCase.js +1 -1
- package/lib/cjs/internal/use-cases/address/GetViewKeyUseCase.js.map +2 -2
- package/lib/cjs/internal/use-cases/transaction/SignFeeIntentUseCase.js +2 -0
- package/lib/cjs/internal/use-cases/transaction/SignFeeIntentUseCase.js.map +7 -0
- package/lib/cjs/internal/use-cases/transaction/SignRootIntentUseCase.js +2 -0
- package/lib/cjs/internal/use-cases/transaction/SignRootIntentUseCase.js.map +7 -0
- package/lib/cjs/internal/use-cases/transaction/di/transactionModule.js +1 -1
- package/lib/cjs/internal/use-cases/transaction/di/transactionModule.js.map +3 -3
- package/lib/cjs/internal/use-cases/transaction/di/transactionTypes.js +1 -1
- package/lib/cjs/internal/use-cases/transaction/di/transactionTypes.js.map +2 -2
- package/lib/cjs/package.json +1 -1
- package/lib/esm/api/app-binder/SignFeeIntentDeviceActionTypes.js +1 -0
- package/lib/esm/api/app-binder/SignRootIntentDeviceActionTypes.js +1 -0
- package/lib/esm/api/app-binder/SignRootIntentDeviceActionTypes.js.map +7 -0
- package/lib/esm/api/index.js.map +2 -2
- 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/GetAddressCommand.js +1 -1
- package/lib/esm/internal/app-binder/command/GetAddressCommand.js.map +3 -3
- package/lib/esm/internal/app-binder/command/GetAddressCommand.test.js +1 -1
- package/lib/esm/internal/app-binder/command/GetAddressCommand.test.js.map +1 -1
- package/lib/esm/internal/app-binder/command/GetAppConfigCommand.js +1 -1
- package/lib/esm/internal/app-binder/command/GetAppConfigCommand.js.map +3 -3
- package/lib/esm/internal/app-binder/command/GetAppConfigCommand.test.js +1 -1
- package/lib/esm/internal/app-binder/command/GetAppConfigCommand.test.js.map +3 -3
- package/lib/esm/internal/app-binder/command/GetViewKeyCommand.js +1 -1
- package/lib/esm/internal/app-binder/command/GetViewKeyCommand.js.map +3 -3
- package/lib/esm/internal/app-binder/command/GetViewKeyCommand.test.js +1 -1
- package/lib/esm/internal/app-binder/command/GetViewKeyCommand.test.js.map +3 -3
- package/lib/esm/internal/app-binder/command/SignFeeIntentCommand.js +2 -0
- package/lib/esm/internal/app-binder/command/SignFeeIntentCommand.js.map +7 -0
- package/lib/esm/internal/app-binder/command/SignFeeIntentCommand.test.js +2 -0
- package/lib/esm/internal/app-binder/command/SignFeeIntentCommand.test.js.map +7 -0
- package/lib/esm/internal/app-binder/command/SignRootIntentCommand.js +2 -0
- package/lib/esm/internal/app-binder/command/SignRootIntentCommand.js.map +7 -0
- package/lib/esm/internal/app-binder/command/SignRootIntentCommand.test.js +2 -0
- package/lib/esm/internal/app-binder/command/SignRootIntentCommand.test.js.map +7 -0
- package/lib/esm/internal/app-binder/command/utils/aleoApplicationErrors.js +1 -1
- package/lib/esm/internal/app-binder/command/utils/aleoApplicationErrors.js.map +2 -2
- package/lib/esm/internal/app-binder/command/utils/apduHeaderUtils.js +2 -0
- package/lib/esm/internal/app-binder/command/utils/apduHeaderUtils.js.map +7 -0
- package/lib/esm/internal/use-cases/address/GetViewKeyUseCase.js +1 -1
- package/lib/esm/internal/use-cases/address/GetViewKeyUseCase.js.map +2 -2
- package/lib/esm/internal/use-cases/transaction/SignFeeIntentUseCase.js +2 -0
- package/lib/esm/internal/use-cases/transaction/SignFeeIntentUseCase.js.map +7 -0
- package/lib/esm/internal/use-cases/transaction/SignRootIntentUseCase.js +2 -0
- package/lib/esm/internal/use-cases/transaction/SignRootIntentUseCase.js.map +7 -0
- package/lib/esm/internal/use-cases/transaction/di/transactionModule.js +1 -1
- package/lib/esm/internal/use-cases/transaction/di/transactionModule.js.map +3 -3
- package/lib/esm/internal/use-cases/transaction/di/transactionTypes.js +1 -1
- package/lib/esm/internal/use-cases/transaction/di/transactionTypes.js.map +2 -2
- package/lib/esm/package.json +1 -1
- package/lib/types/api/SignerAleo.d.ts +4 -2
- package/lib/types/api/SignerAleo.d.ts.map +1 -1
- package/lib/types/api/app-binder/GetViewKeyDeviceActionTypes.d.ts +1 -1
- package/lib/types/api/app-binder/GetViewKeyDeviceActionTypes.d.ts.map +1 -1
- package/lib/types/api/app-binder/SignFeeIntentDeviceActionTypes.d.ts +12 -0
- package/lib/types/api/app-binder/SignFeeIntentDeviceActionTypes.d.ts.map +1 -0
- package/lib/types/api/app-binder/SignRootIntentDeviceActionTypes.d.ts +12 -0
- package/lib/types/api/app-binder/SignRootIntentDeviceActionTypes.d.ts.map +1 -0
- package/lib/types/api/index.d.ts +2 -1
- package/lib/types/api/index.d.ts.map +1 -1
- package/lib/types/internal/DefaultSignerAleo.d.ts +4 -2
- package/lib/types/internal/DefaultSignerAleo.d.ts.map +1 -1
- package/lib/types/internal/app-binder/AleoAppBinder.d.ts +11 -7
- package/lib/types/internal/app-binder/AleoAppBinder.d.ts.map +1 -1
- package/lib/types/internal/app-binder/command/GetAddressCommand.d.ts +1 -1
- package/lib/types/internal/app-binder/command/GetAddressCommand.d.ts.map +1 -1
- package/lib/types/internal/app-binder/command/GetAppConfigCommand.d.ts.map +1 -1
- package/lib/types/internal/app-binder/command/GetViewKeyCommand.d.ts +0 -1
- package/lib/types/internal/app-binder/command/GetViewKeyCommand.d.ts.map +1 -1
- package/lib/types/internal/app-binder/command/SignFeeIntentCommand.d.ts +23 -0
- package/lib/types/internal/app-binder/command/SignFeeIntentCommand.d.ts.map +1 -0
- package/lib/types/internal/app-binder/command/SignFeeIntentCommand.test.d.ts +2 -0
- package/lib/types/internal/app-binder/command/SignFeeIntentCommand.test.d.ts.map +1 -0
- package/lib/types/internal/app-binder/command/SignRootIntentCommand.d.ts +24 -0
- package/lib/types/internal/app-binder/command/SignRootIntentCommand.d.ts.map +1 -0
- package/lib/types/internal/app-binder/command/SignRootIntentCommand.test.d.ts +2 -0
- package/lib/types/internal/app-binder/command/SignRootIntentCommand.test.d.ts.map +1 -0
- package/lib/types/internal/app-binder/command/utils/aleoApplicationErrors.d.ts +1 -1
- package/lib/types/internal/app-binder/command/utils/aleoApplicationErrors.d.ts.map +1 -1
- package/lib/types/internal/app-binder/command/utils/apduHeaderUtils.d.ts +16 -0
- package/lib/types/internal/app-binder/command/utils/apduHeaderUtils.d.ts.map +1 -0
- package/lib/types/internal/use-cases/address/GetViewKeyUseCase.d.ts.map +1 -1
- package/lib/types/internal/use-cases/transaction/SignFeeIntentUseCase.d.ts +9 -0
- package/lib/types/internal/use-cases/transaction/SignFeeIntentUseCase.d.ts.map +1 -0
- package/lib/types/internal/use-cases/transaction/SignRootIntentUseCase.d.ts +9 -0
- package/lib/types/internal/use-cases/transaction/SignRootIntentUseCase.d.ts.map +1 -0
- package/lib/types/internal/use-cases/transaction/di/transactionModule.d.ts.map +1 -1
- package/lib/types/internal/use-cases/transaction/di/transactionTypes.d.ts +2 -1
- package/lib/types/internal/use-cases/transaction/di/transactionTypes.d.ts.map +1 -1
- package/lib/types/tsconfig.prod.tsbuildinfo +1 -1
- package/package.json +8 -8
- package/lib/cjs/api/app-binder/SignTransactionDeviceActionTypes.js +0 -2
- package/lib/cjs/api/app-binder/SignTransactionDeviceActionTypes.js.map +0 -7
- package/lib/cjs/internal/app-binder/command/SignTransactionCommand.js +0 -2
- package/lib/cjs/internal/app-binder/command/SignTransactionCommand.js.map +0 -7
- package/lib/cjs/internal/app-binder/task/SignTransactionTask.js +0 -2
- package/lib/cjs/internal/app-binder/task/SignTransactionTask.js.map +0 -7
- package/lib/cjs/internal/use-cases/transaction/SignTransactionUseCase.js +0 -2
- package/lib/cjs/internal/use-cases/transaction/SignTransactionUseCase.js.map +0 -7
- package/lib/esm/api/app-binder/SignTransactionDeviceActionTypes.js +0 -1
- package/lib/esm/internal/app-binder/command/SignTransactionCommand.js +0 -2
- package/lib/esm/internal/app-binder/command/SignTransactionCommand.js.map +0 -7
- package/lib/esm/internal/app-binder/task/SignTransactionTask.js +0 -2
- package/lib/esm/internal/app-binder/task/SignTransactionTask.js.map +0 -7
- package/lib/esm/internal/use-cases/transaction/SignTransactionUseCase.js +0 -2
- package/lib/esm/internal/use-cases/transaction/SignTransactionUseCase.js.map +0 -7
- package/lib/types/api/app-binder/SignTransactionDeviceActionTypes.d.ts +0 -12
- package/lib/types/api/app-binder/SignTransactionDeviceActionTypes.d.ts.map +0 -1
- package/lib/types/internal/app-binder/command/SignTransactionCommand.d.ts +0 -21
- package/lib/types/internal/app-binder/command/SignTransactionCommand.d.ts.map +0 -1
- package/lib/types/internal/app-binder/task/SignTransactionTask.d.ts +0 -15
- package/lib/types/internal/app-binder/task/SignTransactionTask.d.ts.map +0 -1
- package/lib/types/internal/use-cases/transaction/SignTransactionUseCase.d.ts +0 -9
- package/lib/types/internal/use-cases/transaction/SignTransactionUseCase.d.ts.map +0 -1
- /package/lib/esm/api/app-binder/{SignTransactionDeviceActionTypes.js.map → SignFeeIntentDeviceActionTypes.js.map} +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var i=Object.defineProperty;var
|
|
1
|
+
"use strict";var i=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var s=Object.getOwnPropertyNames;var y=Object.prototype.hasOwnProperty;var g=(e,t,o,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of s(t))!y.call(e,n)&&n!==o&&i(e,n,{get:()=>t[n],enumerable:!(r=p(t,n))||r.enumerable});return e};var A=e=>g(i({},"__esModule",{value:!0}),e);var a={};module.exports=A(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 SignMessageDAReturnType } from \"@api/app-binder/SignMessageDeviceActionTypes\";\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 SignMessageDAReturnType } from \"@api/app-binder/SignMessageDeviceActionTypes\";\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 signMessage: (\n derivationPath: string,\n message: string | Uint8Array,\n ) => SignMessageDAReturnType;\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,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/api/app-binder/GetViewKeyDeviceActionTypes.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n type CommandErrorResult,\n type ExecuteDeviceActionReturnType,\n type OpenAppDAError,\n type SendCommandInAppDAIntermediateValue,\n type SendCommandInAppDAOutput,\n type UserInteractionRequired,\n} from \"@ledgerhq/device-management-kit\";\n\nimport { type GetViewKeyCommandResponse } from \"@internal/app-binder/command/GetViewKeyCommand\";\nimport { type AleoErrorCodes } from \"@internal/app-binder/command/utils/aleoApplicationErrors\";\n\ntype GetViewKeyDAUserInteractionRequired =\n
|
|
4
|
+
"sourcesContent": ["import {\n type CommandErrorResult,\n type ExecuteDeviceActionReturnType,\n type OpenAppDAError,\n type SendCommandInAppDAIntermediateValue,\n type SendCommandInAppDAOutput,\n type UserInteractionRequired,\n} from \"@ledgerhq/device-management-kit\";\n\nimport { type GetViewKeyCommandResponse } from \"@internal/app-binder/command/GetViewKeyCommand\";\nimport { type AleoErrorCodes } from \"@internal/app-binder/command/utils/aleoApplicationErrors\";\n\ntype GetViewKeyDAUserInteractionRequired =\n UserInteractionRequired.VerifyAddress;\n\nexport type GetViewKeyDAOutput =\n SendCommandInAppDAOutput<GetViewKeyCommandResponse>;\n\nexport type GetViewKeyDAError =\n | OpenAppDAError\n | CommandErrorResult<AleoErrorCodes>[\"error\"];\n\nexport type GetViewKeyDAIntermediateValue =\n SendCommandInAppDAIntermediateValue<GetViewKeyDAUserInteractionRequired>;\n\nexport type GetViewKeyDAReturnType = ExecuteDeviceActionReturnType<\n GetViewKeyDAOutput,\n GetViewKeyDAError,\n GetViewKeyDAIntermediateValue\n>;\n"],
|
|
5
5
|
"mappings": "+WAAA,IAAAA,EAAA,kBAAAC,EAAAD",
|
|
6
6
|
"names": ["GetViewKeyDeviceActionTypes_exports", "__toCommonJS"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var o=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var A=Object.getOwnPropertyNames;var u=Object.prototype.hasOwnProperty;var I=(t,e,p,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of A(e))!u.call(t,n)&&n!==p&&o(t,n,{get:()=>e[n],enumerable:!(r=i(e,n))||r.enumerable});return t};var a=t=>I(o({},"__esModule",{value:!0}),t);var m={};module.exports=a(m);
|
|
2
|
+
//# sourceMappingURL=SignFeeIntentDeviceActionTypes.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/api/app-binder/SignFeeIntentDeviceActionTypes.ts"],
|
|
4
|
+
"sourcesContent": ["import {\n type CommandErrorResult,\n type ExecuteDeviceActionReturnType,\n type OpenAppDAError,\n type OpenAppDARequiredInteraction,\n type UserInteractionRequired,\n} from \"@ledgerhq/device-management-kit\";\n\nimport { type SignFeeIntentCommandResponse } from \"@internal/app-binder/command/SignFeeIntentCommand\";\nimport { type AleoErrorCodes } from \"@internal/app-binder/command/utils/aleoApplicationErrors\";\n\nexport type SignFeeIntentDAOutput = SignFeeIntentCommandResponse;\n\nexport type SignFeeIntentDAError =\n | OpenAppDAError\n | CommandErrorResult<AleoErrorCodes>[\"error\"];\n\ntype SignFeeIntentDARequiredInteraction =\n | OpenAppDARequiredInteraction\n | UserInteractionRequired.SignTransaction;\n\nexport type SignFeeIntentDAIntermediateValue = {\n requiredUserInteraction: SignFeeIntentDARequiredInteraction;\n};\n\nexport type SignFeeIntentDAReturnType = ExecuteDeviceActionReturnType<\n SignFeeIntentDAOutput,\n SignFeeIntentDAError,\n SignFeeIntentDAIntermediateValue\n>;\n"],
|
|
5
|
+
"mappings": "+WAAA,IAAAA,EAAA,kBAAAC,EAAAD",
|
|
6
|
+
"names": ["SignFeeIntentDeviceActionTypes_exports", "__toCommonJS"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var r=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var R=Object.getOwnPropertyNames;var A=Object.prototype.hasOwnProperty;var u=(t,e,p,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of R(e))!A.call(t,n)&&n!==p&&r(t,n,{get:()=>e[n],enumerable:!(o=i(e,n))||o.enumerable});return t};var I=t=>u(r({},"__esModule",{value:!0}),t);var a={};module.exports=I(a);
|
|
2
|
+
//# sourceMappingURL=SignRootIntentDeviceActionTypes.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/api/app-binder/SignRootIntentDeviceActionTypes.ts"],
|
|
4
|
+
"sourcesContent": ["import {\n type CommandErrorResult,\n type ExecuteDeviceActionReturnType,\n type OpenAppDAError,\n type OpenAppDARequiredInteraction,\n type UserInteractionRequired,\n} from \"@ledgerhq/device-management-kit\";\n\nimport { type SignRootIntentCommandResponse } from \"@internal/app-binder/command/SignRootIntentCommand\";\nimport { type AleoErrorCodes } from \"@internal/app-binder/command/utils/aleoApplicationErrors\";\n\nexport type SignRootIntentDAOutput = SignRootIntentCommandResponse;\n\nexport type SignRootIntentDAError =\n | OpenAppDAError\n | CommandErrorResult<AleoErrorCodes>[\"error\"];\n\ntype SignRootIntentDARequiredInteraction =\n | OpenAppDARequiredInteraction\n | UserInteractionRequired.SignTransaction;\n\nexport type SignRootIntentDAIntermediateValue = {\n requiredUserInteraction: SignRootIntentDARequiredInteraction;\n};\n\nexport type SignRootIntentDAReturnType = ExecuteDeviceActionReturnType<\n SignRootIntentDAOutput,\n SignRootIntentDAError,\n SignRootIntentDAIntermediateValue\n>;\n"],
|
|
5
|
+
"mappings": "+WAAA,IAAAA,EAAA,kBAAAC,EAAAD",
|
|
6
|
+
"names": ["SignRootIntentDeviceActionTypes_exports", "__toCommonJS"]
|
|
7
|
+
}
|
package/lib/cjs/api/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var a=Object.defineProperty;var D=Object.getOwnPropertyDescriptor;var d=Object.getOwnPropertyNames;var u=Object.prototype.hasOwnProperty;var o=(n,e,i,A)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of d(e))!u.call(n,r)&&r!==i&&a(n,r,{get:()=>e[r],enumerable:!(A=D(e,r))||A.enumerable});return n},p=(n,e,i)=>(o(n,e,"default"),i&&o(i,e,"default"));var y=n=>o(a({},"__esModule",{value:!0}),n);var t={};module.exports=y(t);p(t,require("./SignerAleo"),module.exports);p(t,require("./SignerAleoBuilder"),module.exports);0&&(module.exports={...require("./SignerAleo"),...require("./SignerAleoBuilder")});
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/lib/cjs/api/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/api/index.ts"],
|
|
4
|
-
"sourcesContent": ["export type {\n GetAddressDAError,\n GetAddressDAIntermediateValue,\n GetAddressDAOutput,\n} from \"@api/app-binder/GetAddressDeviceActionTypes\";\nexport type {\n GetAppConfigDAError,\n GetAppConfigDAIntermediateValue,\n GetAppConfigDAOutput,\n} from \"@api/app-binder/GetAppConfigDeviceActionTypes\";\nexport type {\n GetViewKeyDAError,\n GetViewKeyDAIntermediateValue,\n GetViewKeyDAOutput,\n} from \"@api/app-binder/GetViewKeyDeviceActionTypes\";\nexport type {\n
|
|
5
|
-
"mappings": "iaAAA,IAAAA,EAAA,kBAAAC,EAAAD,
|
|
4
|
+
"sourcesContent": ["export type {\n GetAddressDAError,\n GetAddressDAIntermediateValue,\n GetAddressDAOutput,\n} from \"@api/app-binder/GetAddressDeviceActionTypes\";\nexport type {\n GetAppConfigDAError,\n GetAppConfigDAIntermediateValue,\n GetAppConfigDAOutput,\n} from \"@api/app-binder/GetAppConfigDeviceActionTypes\";\nexport type {\n GetViewKeyDAError,\n GetViewKeyDAIntermediateValue,\n GetViewKeyDAOutput,\n} from \"@api/app-binder/GetViewKeyDeviceActionTypes\";\nexport type {\n SignFeeIntentDAError,\n SignFeeIntentDAIntermediateValue,\n SignFeeIntentDAOutput,\n} from \"@api/app-binder/SignFeeIntentDeviceActionTypes\";\nexport type {\n SignRootIntentDAError,\n SignRootIntentDAIntermediateValue,\n SignRootIntentDAOutput,\n} from \"@api/app-binder/SignRootIntentDeviceActionTypes\";\nexport * from \"@api/SignerAleo\";\nexport * from \"@api/SignerAleoBuilder\";\n// Export other types as needed\n"],
|
|
5
|
+
"mappings": "iaAAA,IAAAA,EAAA,kBAAAC,EAAAD,GAyBAE,EAAAF,EAAc,2BAzBd,gBA0BAE,EAAAF,EAAc,kCA1Bd",
|
|
6
6
|
"names": ["api_exports", "__toCommonJS", "__reExport"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var i=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var A=Object.getOwnPropertyNames;var
|
|
1
|
+
"use strict";var i=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var A=Object.getOwnPropertyNames;var f=Object.prototype.hasOwnProperty;var u=(n,e)=>{for(var t in e)i(n,t,{get:e[t],enumerable:!0})},C=(n,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of A(e))!f.call(n,r)&&r!==t&&i(n,r,{get:()=>e[r],enumerable:!(s=y(e,r))||s.enumerable});return n};var c=n=>C(i({},"__esModule",{value:!0}),n);var S={};u(S,{DefaultSignerAleo:()=>d});module.exports=c(S);var a=require("./di"),o=require("./use-cases/address/di/addressTypes"),g=require("./use-cases/config/di/configTypes"),m=require("./use-cases/message/di/messageTypes"),p=require("./use-cases/transaction/di/transactionTypes");class d{_container;constructor({dmk:e,sessionId:t}){this._container=(0,a.makeContainer)({dmk:e,sessionId:t})}getAppConfig(){return this._container.get(g.configTypes.GetAppConfigUseCase).execute()}getAddress(e,t){return this._container.get(o.addressTypes.GetAddressUseCase).execute(e,t)}getViewKey(e,t){return this._container.get(o.addressTypes.GetViewKeyUseCase).execute(e,t)}signMessage(e,t){return this._container.get(m.messageTypes.SignMessageUseCase).execute(e,t)}signRootIntent(e,t,s){return this._container.get(p.transactionTypes.SignRootIntentUseCase).execute(e,t,s)}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 SignMessageDAReturnType } from \"@api/app-binder/SignMessageDeviceActionTypes\";\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", "import_messageTypes", "import_transactionTypes", "dmk", "sessionId", "derivationPath", "options", "
|
|
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 SignMessageDAReturnType } from \"@api/app-binder/SignMessageDeviceActionTypes\";\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 { messageTypes } from \"@internal/use-cases/message/di/messageTypes\";\nimport { type SignMessageUseCase } from \"@internal/use-cases/message/SignMessageUseCase\";\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 signMessage(\n derivationPath: string,\n message: string | Uint8Array,\n ): SignMessageDAReturnType {\n return this._container\n .get<SignMessageUseCase>(messageTypes.SignMessageUseCase)\n .execute(derivationPath, message);\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,GAeA,IAAAI,EAA8B,wBAC9BC,EAA6B,uDAG7BC,EAA4B,qDAE5BC,EAA6B,uDAE7BC,EAAiC,+DAS1B,MAAMN,CAAwC,CAClC,WAEjB,YAAY,CAAE,IAAAO,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,YACED,EACAE,EACyB,CACzB,OAAO,KAAK,WACT,IAAwB,eAAa,kBAAkB,EACvD,QAAQF,EAAgBE,CAAO,CACpC,CAEA,eACEF,EACAG,EACAF,EAC4B,CAC5B,OAAO,KAAK,WACT,IAA2B,mBAAiB,qBAAqB,EACjE,QAAQD,EAAgBG,EAAYF,CAAO,CAChD,CAEA,cACEG,EACAH,EAC2B,CAC3B,OAAO,KAAK,WACT,IAA0B,mBAAiB,oBAAoB,EAC/D,QAAQG,EAAWH,CAAO,CAC/B,CACF",
|
|
6
|
+
"names": ["DefaultSignerAleo_exports", "__export", "DefaultSignerAleo", "__toCommonJS", "import_di", "import_addressTypes", "import_configTypes", "import_messageTypes", "import_transactionTypes", "dmk", "sessionId", "derivationPath", "options", "message", "rootIntent", "feeIntent"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var m=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var O=Object.getOwnPropertyNames;var h=Object.prototype.hasOwnProperty;var R=(i,e)=>{for(var p in e)m(i,p,{get:e[p],enumerable:!0})},w=(i,e,p,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of O(e))!h.call(i,t)&&t!==p&&m(i,t,{get:()=>e[t],enumerable:!(o=u(e,t))||o.enumerable});return i};var S=i=>w(m({},"__esModule",{value:!0}),i),I=(i,e,p,o)=>{for(var t=o>1?void 0:o?u(e,p):e,a=i.length-1,d;a>=0;a--)(d=i[a])&&(t=(o?d(e,p,t):d(t))||t);return o&&t&&m(e,p,t),t},c=(i,e)=>(p,o)=>e(p,o,i);var T={};R(T,{AleoAppBinder:()=>s});module.exports=S(T);var n=require("@ledgerhq/device-management-kit"),r=require("inversify"),A=require("../externalTypes"),y=require("./command/GetAddressCommand"),g=require("./command/GetAppConfigCommand"),k=require("./command/GetViewKeyCommand"),D=require("./command/SignFeeIntentCommand"),v=require("./command/SignMessageCommand"),f=require("./command/SignRootIntentCommand");let s=class{constructor(e,p){this.dmk=e;this.sessionId=p}getAppConfig(e){return this.dmk.executeDeviceAction({sessionId:this.sessionId,deviceAction:new n.SendCommandInAppDeviceAction({input:{command:new g.GetAppConfigCommand,appName:"Aleo",requiredUserInteraction:n.UserInteractionRequired.None,skipOpenApp:e.skipOpenApp}})})}getAddress(e){return this.dmk.executeDeviceAction({sessionId:this.sessionId,deviceAction:new n.SendCommandInAppDeviceAction({input:{command:new y.GetAddressCommand(e),appName:"Aleo",requiredUserInteraction:e.checkOnDevice?n.UserInteractionRequired.VerifyAddress:n.UserInteractionRequired.None,skipOpenApp:e.skipOpenApp}})})}getViewKey(e){return this.dmk.executeDeviceAction({sessionId:this.sessionId,deviceAction:new n.SendCommandInAppDeviceAction({input:{command:new k.GetViewKeyCommand(e),appName:"Aleo",requiredUserInteraction:n.UserInteractionRequired.VerifyAddress,skipOpenApp:e.skipOpenApp}})})}signMessage(e){return this.dmk.executeDeviceAction({sessionId:this.sessionId,deviceAction:new n.SendCommandInAppDeviceAction({input:{command:new v.SignMessageCommand(e),appName:"Aleo",requiredUserInteraction:n.UserInteractionRequired.SignPersonalMessage,skipOpenApp:e.skipOpenApp}})})}signRootIntent(e){return this.dmk.executeDeviceAction({sessionId:this.sessionId,deviceAction:new n.SendCommandInAppDeviceAction({input:{command:new f.SignRootIntentCommand(e),appName:"Aleo",requiredUserInteraction:n.UserInteractionRequired.SignTransaction,skipOpenApp:e.skipOpenApp}})})}signFeeIntent(e){return this.dmk.executeDeviceAction({sessionId:this.sessionId,deviceAction:new n.SendCommandInAppDeviceAction({input:{command:new D.SignFeeIntentCommand(e),appName:"Aleo",requiredUserInteraction:n.UserInteractionRequired.SignTransaction,skipOpenApp:e.skipOpenApp}})})}};s=I([(0,r.injectable)(),c(0,(0,r.inject)(A.externalTypes.Dmk)),c(1,(0,r.inject)(A.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
|
|
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_externalTypes", "import_GetAddressCommand", "import_GetAppConfigCommand", "import_GetViewKeyCommand", "import_SignMessageCommand", "
|
|
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 SignMessageDAReturnType } from \"@api/app-binder/SignMessageDeviceActionTypes\";\nimport { type SignRootIntentDAReturnType } from \"@api/app-binder/SignRootIntentDeviceActionTypes\";\nimport { externalTypes } from \"@internal/externalTypes\";\n\nimport { GetAddressCommand } from \"./command/GetAddressCommand\";\nimport { GetAppConfigCommand } from \"./command/GetAppConfigCommand\";\nimport { GetViewKeyCommand } from \"./command/GetViewKeyCommand\";\nimport { SignFeeIntentCommand } from \"./command/SignFeeIntentCommand\";\nimport { SignMessageCommand } from \"./command/SignMessageCommand\";\nimport { SignRootIntentCommand } from \"./command/SignRootIntentCommand\";\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: \"Aleo\",\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: \"Aleo\",\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: \"Aleo\",\n requiredUserInteraction: UserInteractionRequired.VerifyAddress,\n skipOpenApp: args.skipOpenApp,\n },\n }),\n });\n }\n\n signMessage(args: {\n derivationPath: string;\n message: string | Uint8Array;\n skipOpenApp: boolean;\n }): SignMessageDAReturnType {\n return this.dmk.executeDeviceAction({\n sessionId: this.sessionId,\n deviceAction: new SendCommandInAppDeviceAction({\n input: {\n command: new SignMessageCommand(args),\n appName: \"Aleo\",\n requiredUserInteraction: UserInteractionRequired.SignPersonalMessage,\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 SendCommandInAppDeviceAction({\n input: {\n command: new SignRootIntentCommand(args),\n appName: \"Aleo\",\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 SendCommandInAppDeviceAction({\n input: {\n command: new SignFeeIntentCommand(args),\n appName: \"Aleo\",\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,EAKO,2CACPC,EAAmC,qBAQnCC,EAA8B,mCAE9BC,EAAkC,uCAClCC,EAAoC,yCACpCC,EAAkC,uCAClCC,EAAqC,0CACrCC,EAAmC,wCACnCC,EAAsC,2CAG/B,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,OACT,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,OACT,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,OACT,wBAAyB,0BAAwB,cACjD,YAAaA,EAAK,WACpB,CACF,CAAC,CACH,CAAC,CACH,CAEA,YAAYA,EAIgB,CAC1B,OAAO,KAAK,IAAI,oBAAoB,CAClC,UAAW,KAAK,UAChB,aAAc,IAAI,+BAA6B,CAC7C,MAAO,CACL,QAAS,IAAI,qBAAmBA,CAAI,EACpC,QAAS,OACT,wBAAyB,0BAAwB,oBACjD,YAAaA,EAAK,WACpB,CACF,CAAC,CACH,CAAC,CACH,CAEA,eAAeA,EAIgB,CAC7B,OAAO,KAAK,IAAI,oBAAoB,CAClC,UAAW,KAAK,UAChB,aAAc,IAAI,+BAA6B,CAC7C,MAAO,CACL,QAAS,IAAI,wBAAsBA,CAAI,EACvC,QAAS,OACT,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,+BAA6B,CAC7C,MAAO,CACL,QAAS,IAAI,uBAAqBA,CAAI,EACtC,QAAS,OACT,wBAAyB,0BAAwB,gBACjD,YAAaA,EAAK,WACpB,CACF,CAAC,CACH,CAAC,CACH,CACF,EA7GaH,EAANI,EAAA,IADN,cAAW,EAGPC,EAAA,eAAO,gBAAc,GAAG,GACxBA,EAAA,eAAO,gBAAc,SAAS,IAHtBL",
|
|
6
|
+
"names": ["AleoAppBinder_exports", "__export", "AleoAppBinder", "__toCommonJS", "import_device_management_kit", "import_inversify", "import_externalTypes", "import_GetAddressCommand", "import_GetAppConfigCommand", "import_GetViewKeyCommand", "import_SignFeeIntentCommand", "import_SignMessageCommand", "import_SignRootIntentCommand", "AleoAppBinder", "dmk", "sessionId", "args", "__decorateClass", "__decorateParam"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var p=Object.defineProperty;var l=Object.getOwnPropertyDescriptor;var u=Object.getOwnPropertyNames;var C=Object.prototype.hasOwnProperty;var c=(d,e)=>{for(var r in e)p(d,r,{get:e[r],enumerable:!0})},g=(d,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of u(e))!C.call(d,s)&&s!==r&&p(d,s,{get:()=>e[s],enumerable:!(n=l(e,s))||n.enumerable});return d};var y=d=>g(p({},"__esModule",{value:!0}),d);var h={};c(h,{GetAddressCommand:()=>E});module.exports=y(h);var t=require("@ledgerhq/device-management-kit"),a=require("@ledgerhq/signer-utils"),A=require("purify-ts"),o=require("../../app-binder/command/utils/apduHeaderUtils"),i=require("./utils/aleoApplicationErrors");class E{name="getAddress";errorHelper=new a.CommandErrorHelper(i.ALEO_APP_ERRORS,i.AleoAppCommandErrorFactory);args;constructor(e){this.args=e}getApdu(){const e={cla:o.ALEO_CLA,ins:o.INS.GET_ADDRESS,p1:this.args.checkOnDevice?o.P1.CHECK_ON_DEVICE:o.P1.NO_CHECK,p2:o.P2_DEFAULT},r=new t.ApduBuilder(e),n=this.args.derivationPath,s=a.DerivationPathUtils.splitPath(n);return r.add8BitUIntToData(s.length),s.forEach(m=>{r.add32BitUIntToData(m)}),r.build()}parseResponse(e){return A.Maybe.fromNullable(this.errorHelper.getError(e)).orDefaultLazy(()=>{const r=new t.ApduParser(e),n=r.extract8BitUInt();if(n===void 0)return(0,t.CommandResultFactory)({error:new t.InvalidStatusWordError("Aleo address length is missing")});if(r.testMinimalLength(n)===!1)return(0,t.CommandResultFactory)({error:new t.InvalidStatusWordError("Address is missing")});const s=r.extractFieldByLength(n);if(s===void 0)return(0,t.CommandResultFactory)({error:new t.InvalidStatusWordError("Unable to extract address")});const m=r.encodeToString(s);return(0,t.CommandResultFactory)({data:{address:m}})})}}0&&(module.exports={GetAddressCommand});
|
|
2
2
|
//# sourceMappingURL=GetAddressCommand.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/internal/app-binder/command/GetAddressCommand.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 InvalidStatusWordError,\n} from \"@ledgerhq/device-management-kit\";\nimport {\n CommandErrorHelper,\n DerivationPathUtils,\n} from \"@ledgerhq/signer-utils\";\nimport { Maybe } from \"purify-ts\";\n\nimport {\n ALEO_APP_ERRORS,\n AleoAppCommandErrorFactory,\n type AleoErrorCodes,\n} from \"./utils/aleoApplicationErrors\";\n\nexport type GetAddressCommandArgs = {\n readonly derivationPath: string;\n readonly checkOnDevice?: boolean;\n};\n\nexport type GetAddressCommandResponse = {\n readonly address: string;\n};\n\nexport class GetAddressCommand\n implements\n Command<GetAddressCommandResponse, GetAddressCommandArgs, AleoErrorCodes>\n{\n readonly name = \"
|
|
5
|
-
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,uBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAUO,2CACPC,EAGO,kCACPC,EAAsB,qBAEtBC,EAIO,yCAWA,
|
|
6
|
-
"names": ["GetAddressCommand_exports", "__export", "GetAddressCommand", "__toCommonJS", "import_device_management_kit", "import_signer_utils", "import_purify_ts", "import_aleoApplicationErrors", "args", "getAddressCommandArgs", "builder", "derivationPath", "path", "element", "response", "parser", "addressLength", "buffer", "address"]
|
|
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 InvalidStatusWordError,\n} from \"@ledgerhq/device-management-kit\";\nimport {\n CommandErrorHelper,\n DerivationPathUtils,\n} from \"@ledgerhq/signer-utils\";\nimport { Maybe } from \"purify-ts\";\n\nimport {\n ALEO_CLA,\n INS,\n P1,\n P2_DEFAULT,\n} from \"@internal/app-binder/command/utils/apduHeaderUtils\";\n\nimport {\n ALEO_APP_ERRORS,\n AleoAppCommandErrorFactory,\n type AleoErrorCodes,\n} from \"./utils/aleoApplicationErrors\";\n\nexport type GetAddressCommandArgs = {\n readonly derivationPath: string;\n readonly checkOnDevice?: boolean;\n};\n\nexport type GetAddressCommandResponse = {\n readonly address: string;\n};\n\nexport class GetAddressCommand\n implements\n Command<GetAddressCommandResponse, GetAddressCommandArgs, AleoErrorCodes>\n{\n readonly name = \"getAddress\";\n private readonly errorHelper = new CommandErrorHelper<\n GetAddressCommandResponse,\n AleoErrorCodes\n >(ALEO_APP_ERRORS, AleoAppCommandErrorFactory);\n\n private readonly args: GetAddressCommandArgs;\n\n constructor(args: GetAddressCommandArgs) {\n this.args = args;\n }\n\n getApdu(): Apdu {\n const getAddressCommandArgs: ApduBuilderArgs = {\n cla: ALEO_CLA,\n ins: INS.GET_ADDRESS,\n p1: this.args.checkOnDevice ? P1.CHECK_ON_DEVICE : P1.NO_CHECK,\n p2: P2_DEFAULT,\n };\n\n const builder = new ApduBuilder(getAddressCommandArgs);\n const derivationPath = this.args.derivationPath;\n\n const path = DerivationPathUtils.splitPath(derivationPath);\n builder.add8BitUIntToData(path.length);\n path.forEach((element) => {\n builder.add32BitUIntToData(element);\n });\n\n return builder.build();\n }\n\n parseResponse(\n response: ApduResponse,\n ): CommandResult<GetAddressCommandResponse, AleoErrorCodes> {\n return Maybe.fromNullable(\n this.errorHelper.getError(response),\n ).orDefaultLazy(() => {\n const parser = new ApduParser(response);\n\n const addressLength = parser.extract8BitUInt();\n if (addressLength === undefined) {\n return CommandResultFactory({\n error: new InvalidStatusWordError(\"Aleo address length is missing\"),\n });\n }\n\n if (parser.testMinimalLength(addressLength) === false) {\n return CommandResultFactory({\n error: new InvalidStatusWordError(\"Address is missing\"),\n });\n }\n\n const buffer = parser.extractFieldByLength(addressLength);\n if (buffer === undefined) {\n return CommandResultFactory({\n error: new InvalidStatusWordError(\"Unable to extract address\"),\n });\n }\n\n const address = parser.encodeToString(buffer);\n\n return CommandResultFactory({\n data: {\n address,\n },\n });\n });\n }\n}\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,uBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAUO,2CACPC,EAGO,kCACPC,EAAsB,qBAEtBC,EAKO,8DAEPC,EAIO,yCAWA,MAAMN,CAGb,CACW,KAAO,aACC,YAAc,IAAI,qBAGjC,kBAAiB,4BAA0B,EAE5B,KAEjB,YAAYO,EAA6B,CACvC,KAAK,KAAOA,CACd,CAEA,SAAgB,CACd,MAAMC,EAAyC,CAC7C,IAAK,WACL,IAAK,MAAI,YACT,GAAI,KAAK,KAAK,cAAgB,KAAG,gBAAkB,KAAG,SACtD,GAAI,YACN,EAEMC,EAAU,IAAI,cAAYD,CAAqB,EAC/CE,EAAiB,KAAK,KAAK,eAE3BC,EAAO,sBAAoB,UAAUD,CAAc,EACzD,OAAAD,EAAQ,kBAAkBE,EAAK,MAAM,EACrCA,EAAK,QAASC,GAAY,CACxBH,EAAQ,mBAAmBG,CAAO,CACpC,CAAC,EAEMH,EAAQ,MAAM,CACvB,CAEA,cACEI,EAC0D,CAC1D,OAAO,QAAM,aACX,KAAK,YAAY,SAASA,CAAQ,CACpC,EAAE,cAAc,IAAM,CACpB,MAAMC,EAAS,IAAI,aAAWD,CAAQ,EAEhCE,EAAgBD,EAAO,gBAAgB,EAC7C,GAAIC,IAAkB,OACpB,SAAO,wBAAqB,CAC1B,MAAO,IAAI,yBAAuB,gCAAgC,CACpE,CAAC,EAGH,GAAID,EAAO,kBAAkBC,CAAa,IAAM,GAC9C,SAAO,wBAAqB,CAC1B,MAAO,IAAI,yBAAuB,oBAAoB,CACxD,CAAC,EAGH,MAAMC,EAASF,EAAO,qBAAqBC,CAAa,EACxD,GAAIC,IAAW,OACb,SAAO,wBAAqB,CAC1B,MAAO,IAAI,yBAAuB,2BAA2B,CAC/D,CAAC,EAGH,MAAMC,EAAUH,EAAO,eAAeE,CAAM,EAE5C,SAAO,wBAAqB,CAC1B,KAAM,CACJ,QAAAC,CACF,CACF,CAAC,CACH,CAAC,CACH,CACF",
|
|
6
|
+
"names": ["GetAddressCommand_exports", "__export", "GetAddressCommand", "__toCommonJS", "import_device_management_kit", "import_signer_utils", "import_purify_ts", "import_apduHeaderUtils", "import_aleoApplicationErrors", "args", "getAddressCommandArgs", "builder", "derivationPath", "path", "element", "response", "parser", "addressLength", "buffer", "address"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var e=require("@ledgerhq/device-management-kit"),o=require("./GetAddressCommand");const d="aleo1zcwqycj02lccfuu57dzjhva7w5dpzc7pngl0sxjhp58t6vlnnqxs6lnp6f",p=Uint8Array.from(Buffer.from("e00501000d038000002c800002ab00000000","hex")),m=Uint8Array.from(Buffer.from("e005010015058000002c8000003c800000010000000200000003","hex")),u=Uint8Array.from(Buffer.from("e00500000d038000002c800002ab00000000","hex")),f=Uint8Array.from(Buffer.concat([Buffer.from([63]),Buffer.from(d,"ascii")])),a="3f616c656f317a63777179636a30326c63636675753537647a6a68766137773564707a6337706e676c3073786a687035387436766c6e6e717873366c6e7036669000",l=new e.ApduResponse({statusCode:Uint8Array.from([144,0]),data:f});describe("GetAddressCommand",()=>{const n="44'/683'/0";describe("name",()=>{it("should be '
|
|
1
|
+
"use strict";var e=require("@ledgerhq/device-management-kit"),o=require("./GetAddressCommand");const d="aleo1zcwqycj02lccfuu57dzjhva7w5dpzc7pngl0sxjhp58t6vlnnqxs6lnp6f",p=Uint8Array.from(Buffer.from("e00501000d038000002c800002ab00000000","hex")),m=Uint8Array.from(Buffer.from("e005010015058000002c8000003c800000010000000200000003","hex")),u=Uint8Array.from(Buffer.from("e00500000d038000002c800002ab00000000","hex")),f=Uint8Array.from(Buffer.concat([Buffer.from([63]),Buffer.from(d,"ascii")])),a="3f616c656f317a63777179636a30326c63636675753537647a6a68766137773564707a6337706e676c3073786a687035387436766c6e6e717873366c6e7036669000",l=new e.ApduResponse({statusCode:Uint8Array.from([144,0]),data:f});describe("GetAddressCommand",()=>{const n="44'/683'/0";describe("name",()=>{it("should be 'getAddress'",()=>{const s=new o.GetAddressCommand({derivationPath:n});expect(s.name).toBe("getAddress")})}),describe("getApdu",()=>{it("should return the getAddress apdu with checkOnDevice set to true",()=>{const r=new o.GetAddressCommand({derivationPath:n,checkOnDevice:!0}).getApdu();expect(r.getRawApdu()).toStrictEqual(p)}),it("should return the getAddress apdu with checkOnDevice set to true and custom derivation path",()=>{const r=new o.GetAddressCommand({derivationPath:"44'/60'/1'/2/3",checkOnDevice:!0}).getApdu();expect(r.getRawApdu()).toStrictEqual(m)}),it("should return the getAddress apdu with checkOnDevice set to false",()=>{const r=new o.GetAddressCommand({derivationPath:n,checkOnDevice:!1}).getApdu();expect(r.getRawApdu()).toStrictEqual(u)})}),describe("parseResponse",()=>{it("should parse the response",()=>{const r=new o.GetAddressCommand({derivationPath:n}).parseResponse(l);expect(r).toStrictEqual((0,e.CommandResultFactory)({data:{address:d}}))}),it("should parse the response from raw hex",()=>{const s=Uint8Array.from(Buffer.from(a.substring(0,a.length-4),"hex")),r=Uint8Array.from(Buffer.from(a.substring(a.length-4),"hex")),t=new e.ApduResponse({data:s,statusCode:r}),c=new o.GetAddressCommand({derivationPath:n,checkOnDevice:!0}).parseResponse(t);expect(c).toStrictEqual((0,e.CommandResultFactory)({data:{address:d}}))}),it("should parse the response with a different address",()=>{const s="aleo16m3u6v6k6p6k6p6k6p6k6p6k6p6k6p6k6p6k6p6k6p6k6p6k6p6k6p6k6p",r=Uint8Array.from(Buffer.concat([Buffer.from([63]),Buffer.from(s,"ascii")])),t=new e.ApduResponse({statusCode:Uint8Array.from([144,0]),data:r}),c=new o.GetAddressCommand({derivationPath:n}).parseResponse(t);expect(c).toStrictEqual((0,e.CommandResultFactory)({data:{address:s}}))}),describe("should return an error",()=>{it("when the response is not successful",()=>{const s=new o.GetAddressCommand({derivationPath:n}),r=new e.ApduResponse({statusCode:Uint8Array.from([109,0]),data:new Uint8Array(0)}),t=s.parseResponse(r);expect((0,e.isSuccessCommandResult)(t)).toBe(!1)}),it("when address is missing (response too short)",()=>{const s=new o.GetAddressCommand({derivationPath:n}),r=new e.ApduResponse({statusCode:Uint8Array.from([144,0]),data:Uint8Array.from([63])}),t=s.parseResponse(r);if((0,e.isSuccessCommandResult)(t))throw new Error("Expected an error");expect(t.error).toBeInstanceOf(e.InvalidStatusWordError),expect(t.error.originalError).toEqual(new Error("Address is missing"))}),it("when Aleo address length is missing",()=>{const s=new o.GetAddressCommand({derivationPath:n}),r=new e.ApduResponse({statusCode:Uint8Array.from([144,0]),data:new Uint8Array(0)}),t=s.parseResponse(r);if((0,e.isSuccessCommandResult)(t))throw new Error("Expected an error");expect(t.error).toBeInstanceOf(e.InvalidStatusWordError),expect(t.error.originalError).toEqual(new Error("Aleo address length is missing"))}),it("when Aleo address length is incorrect (less than expected)",()=>{const s=new o.GetAddressCommand({derivationPath:n}),r=new e.ApduResponse({statusCode:Uint8Array.from([144,0]),data:Uint8Array.from([63,...Array(62).fill(2)])}),t=s.parseResponse(r);if((0,e.isSuccessCommandResult)(t))throw new Error("Expected an error");expect(t.error).toBeInstanceOf(e.InvalidStatusWordError),expect(t.error.originalError).toEqual(new Error("Address is missing"))}),it("when unable to extract address",()=>{const s=new o.GetAddressCommand({derivationPath:n}),r=new e.ApduResponse({statusCode:Uint8Array.from([144,0]),data:Uint8Array.from([63,...Array(10).fill(0)])}),t=s.parseResponse(r);if((0,e.isSuccessCommandResult)(t))throw new Error("Expected an error");expect(t.error).toBeInstanceOf(e.InvalidStatusWordError),expect(t.error.originalError).toEqual(new Error("Address is missing"))})})})});
|
|
2
2
|
//# sourceMappingURL=GetAddressCommand.test.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/internal/app-binder/command/GetAddressCommand.test.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n ApduResponse,\n CommandResultFactory,\n InvalidStatusWordError,\n isSuccessCommandResult,\n} from \"@ledgerhq/device-management-kit\";\n\nimport { GetAddressCommand } from \"./GetAddressCommand\";\n\nconst ADDRESS =\n \"aleo1zcwqycj02lccfuu57dzjhva7w5dpzc7pngl0sxjhp58t6vlnnqxs6lnp6f\";\n\nconst GET_ADDRESS_APDU_WITH_CHECK_ON_DEVICE = Uint8Array.from(\n Buffer.from(\"e00501000d038000002c800002ab00000000\", \"hex\"),\n);\n\nconst GET_ADDRESS_APDU_WITH_CHECK_ON_DEVICE_AND_LONG_DERIVATION_PATH =\n Uint8Array.from(\n Buffer.from(\"e005010015058000002c8000003c800000010000000200000003\", \"hex\"),\n );\n\nconst GET_ADDRESS_APDU_WITHOUT_CHECK_ON_DEVICE = Uint8Array.from(\n Buffer.from(\"e00500000d038000002c800002ab00000000\", \"hex\"),\n);\n\nconst RESPONSE_DATA = Uint8Array.from(\n Buffer.concat([Buffer.from([0x3f]), Buffer.from(ADDRESS, \"ascii\")]),\n);\n\nconst RESPONSE_GOOD_RAW =\n \"3f616c656f317a63777179636a30326c63636675753537647a6a68766137773564707a6337706e676c3073786a687035387436766c6e6e717873366c6e7036669000\";\n\nconst RESPONSE_GOOD = new ApduResponse({\n statusCode: Uint8Array.from([0x90, 0x00]),\n data: RESPONSE_DATA,\n});\n\ndescribe(\"GetAddressCommand\", () => {\n const derivationPath = \"44'/683'/0\";\n\n describe(\"name\", () => {\n it(\"should be '
|
|
4
|
+
"sourcesContent": ["import {\n ApduResponse,\n CommandResultFactory,\n InvalidStatusWordError,\n isSuccessCommandResult,\n} from \"@ledgerhq/device-management-kit\";\n\nimport { GetAddressCommand } from \"./GetAddressCommand\";\n\nconst ADDRESS =\n \"aleo1zcwqycj02lccfuu57dzjhva7w5dpzc7pngl0sxjhp58t6vlnnqxs6lnp6f\";\n\nconst GET_ADDRESS_APDU_WITH_CHECK_ON_DEVICE = Uint8Array.from(\n Buffer.from(\"e00501000d038000002c800002ab00000000\", \"hex\"),\n);\n\nconst GET_ADDRESS_APDU_WITH_CHECK_ON_DEVICE_AND_LONG_DERIVATION_PATH =\n Uint8Array.from(\n Buffer.from(\"e005010015058000002c8000003c800000010000000200000003\", \"hex\"),\n );\n\nconst GET_ADDRESS_APDU_WITHOUT_CHECK_ON_DEVICE = Uint8Array.from(\n Buffer.from(\"e00500000d038000002c800002ab00000000\", \"hex\"),\n);\n\nconst RESPONSE_DATA = Uint8Array.from(\n Buffer.concat([Buffer.from([0x3f]), Buffer.from(ADDRESS, \"ascii\")]),\n);\n\nconst RESPONSE_GOOD_RAW =\n \"3f616c656f317a63777179636a30326c63636675753537647a6a68766137773564707a6337706e676c3073786a687035387436766c6e6e717873366c6e7036669000\";\n\nconst RESPONSE_GOOD = new ApduResponse({\n statusCode: Uint8Array.from([0x90, 0x00]),\n data: RESPONSE_DATA,\n});\n\ndescribe(\"GetAddressCommand\", () => {\n const derivationPath = \"44'/683'/0\";\n\n describe(\"name\", () => {\n it(\"should be 'getAddress'\", () => {\n const command = new GetAddressCommand({ derivationPath });\n expect(command.name).toBe(\"getAddress\");\n });\n });\n\n describe(\"getApdu\", () => {\n it(\"should return the getAddress apdu with checkOnDevice set to true\", () => {\n const command = new GetAddressCommand({\n derivationPath,\n checkOnDevice: true,\n });\n const apdu = command.getApdu();\n expect(apdu.getRawApdu()).toStrictEqual(\n GET_ADDRESS_APDU_WITH_CHECK_ON_DEVICE,\n );\n });\n\n it(\"should return the getAddress apdu with checkOnDevice set to true and custom derivation path\", () => {\n const command = new GetAddressCommand({\n derivationPath: \"44'/60'/1'/2/3\",\n checkOnDevice: true,\n });\n const apdu = command.getApdu();\n expect(apdu.getRawApdu()).toStrictEqual(\n GET_ADDRESS_APDU_WITH_CHECK_ON_DEVICE_AND_LONG_DERIVATION_PATH,\n );\n });\n\n it(\"should return the getAddress apdu with checkOnDevice set to false\", () => {\n const command = new GetAddressCommand({\n derivationPath,\n checkOnDevice: false,\n });\n const apdu = command.getApdu();\n expect(apdu.getRawApdu()).toStrictEqual(\n GET_ADDRESS_APDU_WITHOUT_CHECK_ON_DEVICE,\n );\n });\n });\n\n describe(\"parseResponse\", () => {\n it(\"should parse the response\", () => {\n const command = new GetAddressCommand({ derivationPath });\n const parsed = command.parseResponse(RESPONSE_GOOD);\n expect(parsed).toStrictEqual(\n CommandResultFactory({\n data: {\n address: ADDRESS,\n },\n }),\n );\n });\n\n it(\"should parse the response from raw hex\", () => {\n // GIVEN\n const data = Uint8Array.from(\n Buffer.from(\n RESPONSE_GOOD_RAW.substring(0, RESPONSE_GOOD_RAW.length - 4),\n \"hex\",\n ),\n );\n const statusCode = Uint8Array.from(\n Buffer.from(\n RESPONSE_GOOD_RAW.substring(RESPONSE_GOOD_RAW.length - 4),\n \"hex\",\n ),\n );\n const response = new ApduResponse({\n data,\n statusCode,\n });\n const command = new GetAddressCommand({\n derivationPath,\n checkOnDevice: true,\n });\n\n // WHEN\n const parsed = command.parseResponse(response);\n\n // THEN\n expect(parsed).toStrictEqual(\n CommandResultFactory({\n data: {\n address: ADDRESS,\n },\n }),\n );\n });\n\n it(\"should parse the response with a different address\", () => {\n const otherAddress =\n \"aleo16m3u6v6k6p6k6p6k6p6k6p6k6p6k6p6k6p6k6p6k6p6k6p6k6p6k6p6k6p\";\n const otherResponseData = Uint8Array.from(\n Buffer.concat([\n Buffer.from([0x3f]),\n Buffer.from(otherAddress, \"ascii\"),\n ]),\n );\n const otherResponse = new ApduResponse({\n statusCode: Uint8Array.from([0x90, 0x00]),\n data: otherResponseData,\n });\n\n const command = new GetAddressCommand({ derivationPath });\n const parsed = command.parseResponse(otherResponse);\n expect(parsed).toStrictEqual(\n CommandResultFactory({\n data: {\n address: otherAddress,\n },\n }),\n );\n });\n\n describe(\"should return an error\", () => {\n it(\"when the response is not successful\", () => {\n // GIVEN\n const command = new GetAddressCommand({ derivationPath });\n const response = new ApduResponse({\n statusCode: Uint8Array.from([0x6d, 0x00]),\n data: new Uint8Array(0),\n });\n\n // WHEN\n const result = command.parseResponse(response);\n\n // THEN\n expect(isSuccessCommandResult(result)).toBe(false);\n });\n\n it(\"when address is missing (response too short)\", () => {\n // GIVEN\n const command = new GetAddressCommand({ derivationPath });\n const response = new ApduResponse({\n statusCode: Uint8Array.from([0x90, 0x00]),\n data: Uint8Array.from([0x3f]), // Only length, no address\n });\n\n // WHEN\n const result = command.parseResponse(response);\n\n // THEN\n if (isSuccessCommandResult(result)) {\n throw new Error(\"Expected an error\");\n } else {\n expect(result.error).toBeInstanceOf(InvalidStatusWordError);\n expect(result.error.originalError).toEqual(\n new Error(\"Address is missing\"),\n );\n }\n });\n\n it(\"when Aleo address length is missing\", () => {\n // GIVEN\n const command = new GetAddressCommand({ derivationPath });\n const response = new ApduResponse({\n statusCode: Uint8Array.from([0x90, 0x00]),\n data: new Uint8Array(0),\n });\n\n // WHEN\n const result = command.parseResponse(response);\n\n // THEN\n if (isSuccessCommandResult(result)) {\n throw new Error(\"Expected an error\");\n } else {\n expect(result.error).toBeInstanceOf(InvalidStatusWordError);\n expect(result.error.originalError).toEqual(\n new Error(\"Aleo address length is missing\"),\n );\n }\n });\n\n it(\"when Aleo address length is incorrect (less than expected)\", () => {\n // GIVEN\n const command = new GetAddressCommand({ derivationPath });\n const response = new ApduResponse({\n statusCode: Uint8Array.from([0x90, 0x00]),\n data: Uint8Array.from([0x3f, ...Array<number>(62).fill(0x02)]), // Length says 63, but only 62 bytes follow\n });\n\n // WHEN\n const result = command.parseResponse(response);\n\n // THEN\n if (isSuccessCommandResult(result)) {\n throw new Error(\"Expected an error\");\n } else {\n expect(result.error).toBeInstanceOf(InvalidStatusWordError);\n expect(result.error.originalError).toEqual(\n new Error(\"Address is missing\"),\n );\n }\n });\n\n it(\"when unable to extract address\", () => {\n // GIVEN\n const command = new GetAddressCommand({ derivationPath });\n const response = new ApduResponse({\n statusCode: Uint8Array.from([0x90, 0x00]),\n data: Uint8Array.from([0x3f, ...Array<number>(10).fill(0x00)]), // length 63, but only 10 bytes follow\n });\n\n // WHEN\n const result = command.parseResponse(response);\n\n // THEN\n if (isSuccessCommandResult(result)) {\n throw new Error(\"Expected an error\");\n } else {\n expect(result.error).toBeInstanceOf(InvalidStatusWordError);\n expect(result.error.originalError).toEqual(\n new Error(\"Address is missing\"),\n );\n }\n });\n });\n });\n});\n"],
|
|
5
5
|
"mappings": "aAAA,IAAAA,EAKO,2CAEPC,EAAkC,+BAElC,MAAMC,EACJ,kEAEIC,EAAwC,WAAW,KACvD,OAAO,KAAK,uCAAwC,KAAK,CAC3D,EAEMC,EACJ,WAAW,KACT,OAAO,KAAK,uDAAwD,KAAK,CAC3E,EAEIC,EAA2C,WAAW,KAC1D,OAAO,KAAK,uCAAwC,KAAK,CAC3D,EAEMC,EAAgB,WAAW,KAC/B,OAAO,OAAO,CAAC,OAAO,KAAK,CAAC,EAAI,CAAC,EAAG,OAAO,KAAKJ,EAAS,OAAO,CAAC,CAAC,CACpE,EAEMK,EACJ,uIAEIC,EAAgB,IAAI,eAAa,CACrC,WAAY,WAAW,KAAK,CAAC,IAAM,CAAI,CAAC,EACxC,KAAMF,CACR,CAAC,EAED,SAAS,oBAAqB,IAAM,CAClC,MAAMG,EAAiB,aAEvB,SAAS,OAAQ,IAAM,CACrB,GAAG,yBAA0B,IAAM,CACjC,MAAMC,EAAU,IAAI,oBAAkB,CAAE,eAAAD,CAAe,CAAC,EACxD,OAAOC,EAAQ,IAAI,EAAE,KAAK,YAAY,CACxC,CAAC,CACH,CAAC,EAED,SAAS,UAAW,IAAM,CACxB,GAAG,mEAAoE,IAAM,CAK3E,MAAMC,EAJU,IAAI,oBAAkB,CACpC,eAAAF,EACA,cAAe,EACjB,CAAC,EACoB,QAAQ,EAC7B,OAAOE,EAAK,WAAW,CAAC,EAAE,cACxBR,CACF,CACF,CAAC,EAED,GAAG,8FAA+F,IAAM,CAKtG,MAAMQ,EAJU,IAAI,oBAAkB,CACpC,eAAgB,iBAChB,cAAe,EACjB,CAAC,EACoB,QAAQ,EAC7B,OAAOA,EAAK,WAAW,CAAC,EAAE,cACxBP,CACF,CACF,CAAC,EAED,GAAG,oEAAqE,IAAM,CAK5E,MAAMO,EAJU,IAAI,oBAAkB,CACpC,eAAAF,EACA,cAAe,EACjB,CAAC,EACoB,QAAQ,EAC7B,OAAOE,EAAK,WAAW,CAAC,EAAE,cACxBN,CACF,CACF,CAAC,CACH,CAAC,EAED,SAAS,gBAAiB,IAAM,CAC9B,GAAG,4BAA6B,IAAM,CAEpC,MAAMO,EADU,IAAI,oBAAkB,CAAE,eAAAH,CAAe,CAAC,EACjC,cAAcD,CAAa,EAClD,OAAOI,CAAM,EAAE,iBACb,wBAAqB,CACnB,KAAM,CACJ,QAASV,CACX,CACF,CAAC,CACH,CACF,CAAC,EAED,GAAG,yCAA0C,IAAM,CAEjD,MAAMW,EAAO,WAAW,KACtB,OAAO,KACLN,EAAkB,UAAU,EAAGA,EAAkB,OAAS,CAAC,EAC3D,KACF,CACF,EACMO,EAAa,WAAW,KAC5B,OAAO,KACLP,EAAkB,UAAUA,EAAkB,OAAS,CAAC,EACxD,KACF,CACF,EACMQ,EAAW,IAAI,eAAa,CAChC,KAAAF,EACA,WAAAC,CACF,CAAC,EAOKF,EANU,IAAI,oBAAkB,CACpC,eAAAH,EACA,cAAe,EACjB,CAAC,EAGsB,cAAcM,CAAQ,EAG7C,OAAOH,CAAM,EAAE,iBACb,wBAAqB,CACnB,KAAM,CACJ,QAASV,CACX,CACF,CAAC,CACH,CACF,CAAC,EAED,GAAG,qDAAsD,IAAM,CAC7D,MAAMc,EACJ,kEACIC,EAAoB,WAAW,KACnC,OAAO,OAAO,CACZ,OAAO,KAAK,CAAC,EAAI,CAAC,EAClB,OAAO,KAAKD,EAAc,OAAO,CACnC,CAAC,CACH,EACME,EAAgB,IAAI,eAAa,CACrC,WAAY,WAAW,KAAK,CAAC,IAAM,CAAI,CAAC,EACxC,KAAMD,CACR,CAAC,EAGKL,EADU,IAAI,oBAAkB,CAAE,eAAAH,CAAe,CAAC,EACjC,cAAcS,CAAa,EAClD,OAAON,CAAM,EAAE,iBACb,wBAAqB,CACnB,KAAM,CACJ,QAASI,CACX,CACF,CAAC,CACH,CACF,CAAC,EAED,SAAS,yBAA0B,IAAM,CACvC,GAAG,sCAAuC,IAAM,CAE9C,MAAMN,EAAU,IAAI,oBAAkB,CAAE,eAAAD,CAAe,CAAC,EAClDM,EAAW,IAAI,eAAa,CAChC,WAAY,WAAW,KAAK,CAAC,IAAM,CAAI,CAAC,EACxC,KAAM,IAAI,WAAW,CAAC,CACxB,CAAC,EAGKI,EAAST,EAAQ,cAAcK,CAAQ,EAG7C,UAAO,0BAAuBI,CAAM,CAAC,EAAE,KAAK,EAAK,CACnD,CAAC,EAED,GAAG,+CAAgD,IAAM,CAEvD,MAAMT,EAAU,IAAI,oBAAkB,CAAE,eAAAD,CAAe,CAAC,EAClDM,EAAW,IAAI,eAAa,CAChC,WAAY,WAAW,KAAK,CAAC,IAAM,CAAI,CAAC,EACxC,KAAM,WAAW,KAAK,CAAC,EAAI,CAAC,CAC9B,CAAC,EAGKI,EAAST,EAAQ,cAAcK,CAAQ,EAG7C,MAAI,0BAAuBI,CAAM,EAC/B,MAAM,IAAI,MAAM,mBAAmB,EAEnC,OAAOA,EAAO,KAAK,EAAE,eAAe,wBAAsB,EAC1D,OAAOA,EAAO,MAAM,aAAa,EAAE,QACjC,IAAI,MAAM,oBAAoB,CAChC,CAEJ,CAAC,EAED,GAAG,sCAAuC,IAAM,CAE9C,MAAMT,EAAU,IAAI,oBAAkB,CAAE,eAAAD,CAAe,CAAC,EAClDM,EAAW,IAAI,eAAa,CAChC,WAAY,WAAW,KAAK,CAAC,IAAM,CAAI,CAAC,EACxC,KAAM,IAAI,WAAW,CAAC,CACxB,CAAC,EAGKI,EAAST,EAAQ,cAAcK,CAAQ,EAG7C,MAAI,0BAAuBI,CAAM,EAC/B,MAAM,IAAI,MAAM,mBAAmB,EAEnC,OAAOA,EAAO,KAAK,EAAE,eAAe,wBAAsB,EAC1D,OAAOA,EAAO,MAAM,aAAa,EAAE,QACjC,IAAI,MAAM,gCAAgC,CAC5C,CAEJ,CAAC,EAED,GAAG,6DAA8D,IAAM,CAErE,MAAMT,EAAU,IAAI,oBAAkB,CAAE,eAAAD,CAAe,CAAC,EAClDM,EAAW,IAAI,eAAa,CAChC,WAAY,WAAW,KAAK,CAAC,IAAM,CAAI,CAAC,EACxC,KAAM,WAAW,KAAK,CAAC,GAAM,GAAG,MAAc,EAAE,EAAE,KAAK,CAAI,CAAC,CAAC,CAC/D,CAAC,EAGKI,EAAST,EAAQ,cAAcK,CAAQ,EAG7C,MAAI,0BAAuBI,CAAM,EAC/B,MAAM,IAAI,MAAM,mBAAmB,EAEnC,OAAOA,EAAO,KAAK,EAAE,eAAe,wBAAsB,EAC1D,OAAOA,EAAO,MAAM,aAAa,EAAE,QACjC,IAAI,MAAM,oBAAoB,CAChC,CAEJ,CAAC,EAED,GAAG,iCAAkC,IAAM,CAEzC,MAAMT,EAAU,IAAI,oBAAkB,CAAE,eAAAD,CAAe,CAAC,EAClDM,EAAW,IAAI,eAAa,CAChC,WAAY,WAAW,KAAK,CAAC,IAAM,CAAI,CAAC,EACxC,KAAM,WAAW,KAAK,CAAC,GAAM,GAAG,MAAc,EAAE,EAAE,KAAK,CAAI,CAAC,CAAC,CAC/D,CAAC,EAGKI,EAAST,EAAQ,cAAcK,CAAQ,EAG7C,MAAI,0BAAuBI,CAAM,EAC/B,MAAM,IAAI,MAAM,mBAAmB,EAEnC,OAAOA,EAAO,KAAK,EAAE,eAAe,wBAAsB,EAC1D,OAAOA,EAAO,MAAM,aAAa,EAAE,QACjC,IAAI,MAAM,oBAAoB,CAChC,CAEJ,CAAC,CACH,CAAC,CACH,CAAC,CACH,CAAC",
|
|
6
6
|
"names": ["import_device_management_kit", "import_GetAddressCommand", "ADDRESS", "GET_ADDRESS_APDU_WITH_CHECK_ON_DEVICE", "GET_ADDRESS_APDU_WITH_CHECK_ON_DEVICE_AND_LONG_DERIVATION_PATH", "GET_ADDRESS_APDU_WITHOUT_CHECK_ON_DEVICE", "RESPONSE_DATA", "RESPONSE_GOOD_RAW", "RESPONSE_GOOD", "derivationPath", "command", "apdu", "parsed", "data", "statusCode", "response", "otherAddress", "otherResponseData", "otherResponse", "result"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var m=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var C=Object.getOwnPropertyNames;var f=Object.prototype.hasOwnProperty;var E=(p,r)=>{for(var d in r)m(p,d,{get:r[d],enumerable:!0})},g=(p,r,d,e)=>{if(r&&typeof r=="object"||typeof r=="function")for(let t of C(r))!f.call(p,t)&&t!==d&&m(p,t,{get:()=>r[t],enumerable:!(e=u(r,t))||e.enumerable});return p};var y=p=>g(m({},"__esModule",{value:!0}),p);var R={};E(R,{GetAppConfigCommand:()=>c});module.exports=y(R);var o=require("@ledgerhq/device-management-kit"),i=require("@ledgerhq/signer-utils"),a=require("purify-ts"),n=require("../../app-binder/command/utils/apduHeaderUtils"),s=require("./utils/aleoApplicationErrors");const A=3;class c{name="GetAppConfig";errorHelper=new i.CommandErrorHelper(s.ALEO_APP_ERRORS,s.AleoAppCommandErrorFactory);getApdu(){const r={cla:n.ALEO_CLA,ins:n.INS.GET_APP_VERSION,p1:n.P1.NO_CHECK,p2:n.P2_DEFAULT};return new o.ApduBuilder(r).build()}parseResponse(r){return a.Maybe.fromNullable(this.errorHelper.getError(r)).orDefaultLazy(()=>{const e=new o.ApduParser(r).extractFieldByLength(A);if(!e||e.length!==A||e.some(l=>l===void 0))return(0,o.CommandResultFactory)({error:new o.InvalidStatusWordError("Invalid response")});const t={version:`${e[0]}.${e[1]}.${e[2]}`};return(0,o.CommandResultFactory)({data:t})})}}0&&(module.exports={GetAppConfigCommand});
|
|
2
2
|
//# sourceMappingURL=GetAppConfigCommand.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/internal/app-binder/command/GetAppConfigCommand.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 InvalidStatusWordError,\n} from \"@ledgerhq/device-management-kit\";\nimport { CommandErrorHelper } from \"@ledgerhq/signer-utils\";\nimport { Maybe } from \"purify-ts\";\n\nimport { type AppConfig } from \"@api/model/AppConfig\";\n\nimport {\n ALEO_APP_ERRORS,\n AleoAppCommandErrorFactory,\n type AleoErrorCodes,\n} from \"./utils/aleoApplicationErrors\";\n\nconst EXPECTED_DATA_LENGTH = 3;\n\nexport class GetAppConfigCommand\n implements Command<AppConfig, void, AleoErrorCodes>\n{\n readonly name = \"GetAppConfig\";\n private readonly errorHelper = new CommandErrorHelper<\n AppConfig,\n AleoErrorCodes\n >(ALEO_APP_ERRORS, AleoAppCommandErrorFactory);\n\n getApdu(): Apdu {\n const getConfigArgs: ApduBuilderArgs = {\n cla:
|
|
5
|
-
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,yBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAUO,2CACPC,EAAmC,kCACnCC,EAAsB,
|
|
6
|
-
"names": ["GetAppConfigCommand_exports", "__export", "GetAppConfigCommand", "__toCommonJS", "import_device_management_kit", "import_signer_utils", "import_purify_ts", "import_aleoApplicationErrors", "EXPECTED_DATA_LENGTH", "getConfigArgs", "response", "buffer", "element", "config"]
|
|
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 InvalidStatusWordError,\n} from \"@ledgerhq/device-management-kit\";\nimport { CommandErrorHelper } from \"@ledgerhq/signer-utils\";\nimport { Maybe } from \"purify-ts\";\n\nimport { type AppConfig } from \"@api/model/AppConfig\";\nimport {\n ALEO_CLA,\n INS,\n P1,\n P2_DEFAULT,\n} from \"@internal/app-binder/command/utils/apduHeaderUtils\";\n\nimport {\n ALEO_APP_ERRORS,\n AleoAppCommandErrorFactory,\n type AleoErrorCodes,\n} from \"./utils/aleoApplicationErrors\";\n\nconst EXPECTED_DATA_LENGTH = 3;\n\nexport class GetAppConfigCommand\n implements Command<AppConfig, void, AleoErrorCodes>\n{\n readonly name = \"GetAppConfig\";\n private readonly errorHelper = new CommandErrorHelper<\n AppConfig,\n AleoErrorCodes\n >(ALEO_APP_ERRORS, AleoAppCommandErrorFactory);\n\n getApdu(): Apdu {\n const getConfigArgs: ApduBuilderArgs = {\n cla: ALEO_CLA,\n ins: INS.GET_APP_VERSION,\n p1: P1.NO_CHECK,\n p2: P2_DEFAULT,\n };\n const builder = new ApduBuilder(getConfigArgs);\n return builder.build();\n }\n\n parseResponse(\n response: ApduResponse,\n ): CommandResult<AppConfig, AleoErrorCodes> {\n return Maybe.fromNullable(\n this.errorHelper.getError(response),\n ).orDefaultLazy(() => {\n const parser = new ApduParser(response);\n const buffer = parser.extractFieldByLength(EXPECTED_DATA_LENGTH);\n if (\n !buffer ||\n buffer.length !== EXPECTED_DATA_LENGTH ||\n buffer.some((element) => element === undefined)\n ) {\n return CommandResultFactory({\n error: new InvalidStatusWordError(\"Invalid response\"),\n });\n }\n\n const config: AppConfig = {\n version: `${buffer[0]}.${buffer[1]}.${buffer[2]}`,\n };\n\n return CommandResultFactory({\n data: config,\n });\n });\n }\n}\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,yBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAUO,2CACPC,EAAmC,kCACnCC,EAAsB,qBAGtBC,EAKO,8DAEPC,EAIO,yCAEP,MAAMC,EAAuB,EAEtB,MAAMP,CAEb,CACW,KAAO,eACC,YAAc,IAAI,qBAGjC,kBAAiB,4BAA0B,EAE7C,SAAgB,CACd,MAAMQ,EAAiC,CACrC,IAAK,WACL,IAAK,MAAI,gBACT,GAAI,KAAG,SACP,GAAI,YACN,EAEA,OADgB,IAAI,cAAYA,CAAa,EAC9B,MAAM,CACvB,CAEA,cACEC,EAC0C,CAC1C,OAAO,QAAM,aACX,KAAK,YAAY,SAASA,CAAQ,CACpC,EAAE,cAAc,IAAM,CAEpB,MAAMC,EADS,IAAI,aAAWD,CAAQ,EAChB,qBAAqBF,CAAoB,EAC/D,GACE,CAACG,GACDA,EAAO,SAAWH,GAClBG,EAAO,KAAMC,GAAYA,IAAY,MAAS,EAE9C,SAAO,wBAAqB,CAC1B,MAAO,IAAI,yBAAuB,kBAAkB,CACtD,CAAC,EAGH,MAAMC,EAAoB,CACxB,QAAS,GAAGF,EAAO,CAAC,CAAC,IAAIA,EAAO,CAAC,CAAC,IAAIA,EAAO,CAAC,CAAC,EACjD,EAEA,SAAO,wBAAqB,CAC1B,KAAME,CACR,CAAC,CACH,CAAC,CACH,CACF",
|
|
6
|
+
"names": ["GetAppConfigCommand_exports", "__export", "GetAppConfigCommand", "__toCommonJS", "import_device_management_kit", "import_signer_utils", "import_purify_ts", "import_apduHeaderUtils", "import_aleoApplicationErrors", "EXPECTED_DATA_LENGTH", "getConfigArgs", "response", "buffer", "element", "config"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var e=require("@ledgerhq/device-management-kit"),
|
|
1
|
+
"use strict";var e=require("@ledgerhq/device-management-kit"),n=require("../../app-binder/command/GetAppConfigCommand"),r=require("../../app-binder/command/utils/apduHeaderUtils");const a=new Uint8Array([r.ALEO_CLA,r.INS.GET_APP_VERSION,r.P1.NO_CHECK,r.P2_DEFAULT,0]),p=new Uint8Array([0,1,2]),c=new e.ApduResponse({statusCode:Uint8Array.from([144,0]),data:p});describe("GetAppConfigurationCommand",()=>{let t;beforeEach(()=>{t=new n.GetAppConfigCommand,vi.clearAllMocks(),vi.importActual("@ledgerhq/device-management-kit")}),describe("name",()=>{it("should be 'GetAppConfig'",()=>{expect(t.name).toBe("GetAppConfig")})}),describe("getApdu",()=>{it("should return the correct APDU",()=>{const o=t.getApdu();expect(o.getRawApdu()).toEqual(a)})}),describe("parseResponse",()=>{it("should parse the response correctly",()=>{const o=t.parseResponse(c);expect(o).toStrictEqual((0,e.CommandResultFactory)({data:{version:"0.1.2"}}))}),describe("error handling",()=>{it("should return error if response is not success",()=>{const o=new e.ApduResponse({statusCode:Uint8Array.from([106,134]),data:new Uint8Array(0)}),s=t.parseResponse(o);expect((0,e.isSuccessCommandResult)(s)).toBe(!1),(0,e.isSuccessCommandResult)(s)?assert.fail("Expected error"):expect(s.error).toEqual(expect.objectContaining({_tag:"AleoAppCommandError",errorCode:"6a86",message:"Incorrect P1 or P2"}))})})})});
|
|
2
2
|
//# sourceMappingURL=GetAppConfigCommand.test.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/internal/app-binder/command/GetAppConfigCommand.test.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n ApduResponse,\n CommandResultFactory,\n isSuccessCommandResult,\n} from \"@ledgerhq/device-management-kit\";\n\nimport { GetAppConfigCommand } from \"@internal/app-binder/command/GetAppConfigCommand\";\n\nconst GET_APP_CONFIG_APDU = new Uint8Array([
|
|
5
|
-
"mappings": "aAAA,IAAAA,EAIO,2CAEPC,EAAoC,
|
|
6
|
-
"names": ["import_device_management_kit", "import_GetAppConfigCommand", "GET_APP_CONFIG_APDU", "GET_APP_CONFIG_RESPONSE_DATA", "GET_APP_CONFIG_RESPONSE", "command", "apdu", "parsed", "response", "result"]
|
|
4
|
+
"sourcesContent": ["import {\n ApduResponse,\n CommandResultFactory,\n isSuccessCommandResult,\n} from \"@ledgerhq/device-management-kit\";\n\nimport { GetAppConfigCommand } from \"@internal/app-binder/command/GetAppConfigCommand\";\nimport {\n ALEO_CLA,\n INS,\n P1,\n P2_DEFAULT,\n} from \"@internal/app-binder/command/utils/apduHeaderUtils\";\n\nconst GET_APP_CONFIG_APDU = new Uint8Array([\n ALEO_CLA,\n INS.GET_APP_VERSION,\n P1.NO_CHECK,\n P2_DEFAULT,\n 0x00,\n]);\n\nconst GET_APP_CONFIG_RESPONSE_DATA = new Uint8Array([0x00, 0x01, 0x02]);\n\nconst GET_APP_CONFIG_RESPONSE = new ApduResponse({\n statusCode: Uint8Array.from([0x90, 0x00]),\n data: GET_APP_CONFIG_RESPONSE_DATA,\n});\n\ndescribe(\"GetAppConfigurationCommand\", () => {\n let command: GetAppConfigCommand;\n\n beforeEach(() => {\n command = new GetAppConfigCommand();\n vi.clearAllMocks();\n vi.importActual(\"@ledgerhq/device-management-kit\");\n });\n\n describe(\"name\", () => {\n it(\"should be 'GetAppConfig'\", () => {\n expect(command.name).toBe(\"GetAppConfig\");\n });\n });\n\n describe(\"getApdu\", () => {\n it(\"should return the correct APDU\", () => {\n const apdu = command.getApdu();\n expect(apdu.getRawApdu()).toEqual(GET_APP_CONFIG_APDU);\n });\n });\n\n describe(\"parseResponse\", () => {\n it(\"should parse the response correctly\", () => {\n const parsed = command.parseResponse(GET_APP_CONFIG_RESPONSE);\n expect(parsed).toStrictEqual(\n CommandResultFactory({\n data: {\n version: \"0.1.2\",\n },\n }),\n );\n });\n\n describe(\"error handling\", () => {\n it(\"should return error if response is not success\", () => {\n const response = new ApduResponse({\n statusCode: Uint8Array.from([0x6a, 0x86]),\n data: new Uint8Array(0),\n });\n const result = command.parseResponse(response);\n expect(isSuccessCommandResult(result)).toBe(false);\n if (!isSuccessCommandResult(result)) {\n expect(result.error).toEqual(\n expect.objectContaining({\n _tag: \"AleoAppCommandError\",\n errorCode: \"6a86\",\n message: \"Incorrect P1 or P2\",\n }),\n );\n } else {\n assert.fail(\"Expected error\");\n }\n });\n });\n });\n});\n"],
|
|
5
|
+
"mappings": "aAAA,IAAAA,EAIO,2CAEPC,EAAoC,4DACpCC,EAKO,8DAEP,MAAMC,EAAsB,IAAI,WAAW,CACzC,WACA,MAAI,gBACJ,KAAG,SACH,aACA,CACF,CAAC,EAEKC,EAA+B,IAAI,WAAW,CAAC,EAAM,EAAM,CAAI,CAAC,EAEhEC,EAA0B,IAAI,eAAa,CAC/C,WAAY,WAAW,KAAK,CAAC,IAAM,CAAI,CAAC,EACxC,KAAMD,CACR,CAAC,EAED,SAAS,6BAA8B,IAAM,CAC3C,IAAIE,EAEJ,WAAW,IAAM,CACfA,EAAU,IAAI,sBACd,GAAG,cAAc,EACjB,GAAG,aAAa,iCAAiC,CACnD,CAAC,EAED,SAAS,OAAQ,IAAM,CACrB,GAAG,2BAA4B,IAAM,CACnC,OAAOA,EAAQ,IAAI,EAAE,KAAK,cAAc,CAC1C,CAAC,CACH,CAAC,EAED,SAAS,UAAW,IAAM,CACxB,GAAG,iCAAkC,IAAM,CACzC,MAAMC,EAAOD,EAAQ,QAAQ,EAC7B,OAAOC,EAAK,WAAW,CAAC,EAAE,QAAQJ,CAAmB,CACvD,CAAC,CACH,CAAC,EAED,SAAS,gBAAiB,IAAM,CAC9B,GAAG,sCAAuC,IAAM,CAC9C,MAAMK,EAASF,EAAQ,cAAcD,CAAuB,EAC5D,OAAOG,CAAM,EAAE,iBACb,wBAAqB,CACnB,KAAM,CACJ,QAAS,OACX,CACF,CAAC,CACH,CACF,CAAC,EAED,SAAS,iBAAkB,IAAM,CAC/B,GAAG,iDAAkD,IAAM,CACzD,MAAMC,EAAW,IAAI,eAAa,CAChC,WAAY,WAAW,KAAK,CAAC,IAAM,GAAI,CAAC,EACxC,KAAM,IAAI,WAAW,CAAC,CACxB,CAAC,EACKC,EAASJ,EAAQ,cAAcG,CAAQ,EAC7C,UAAO,0BAAuBC,CAAM,CAAC,EAAE,KAAK,EAAK,KAC5C,0BAAuBA,CAAM,EAShC,OAAO,KAAK,gBAAgB,EAR5B,OAAOA,EAAO,KAAK,EAAE,QACnB,OAAO,iBAAiB,CACtB,KAAM,sBACN,UAAW,OACX,QAAS,oBACX,CAAC,CACH,CAIJ,CAAC,CACH,CAAC,CACH,CAAC,CACH,CAAC",
|
|
6
|
+
"names": ["import_device_management_kit", "import_GetAppConfigCommand", "import_apduHeaderUtils", "GET_APP_CONFIG_APDU", "GET_APP_CONFIG_RESPONSE_DATA", "GET_APP_CONFIG_RESPONSE", "command", "apdu", "parsed", "response", "result"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var p=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var u=Object.getOwnPropertyNames;var A=Object.prototype.hasOwnProperty;var C=(n,e)=>{for(var r in e)p(n,r,{get:e[r],enumerable:!0})},g=(n,e,r,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of u(e))!A.call(n,o)&&o!==r&&p(n,o,{get:()=>e[o],enumerable:!(a=y(e,o))||a.enumerable});return n};var w=n=>g(p({},"__esModule",{value:!0}),n);var E={};C(E,{GetViewKeyCommand:()=>c});module.exports=w(E);var t=require("@ledgerhq/device-management-kit"),s=require("@ledgerhq/signer-utils"),l=require("purify-ts"),i=require("../../app-binder/command/utils/apduHeaderUtils"),d=require("./utils/aleoApplicationErrors");class c{name="getViewKey";errorHelper=new s.CommandErrorHelper(d.ALEO_APP_ERRORS,d.AleoAppCommandErrorFactory);args;constructor(e){this.args=e}getApdu(){const e={cla:i.ALEO_CLA,ins:i.INS.GET_VIEW_KEY,p1:i.P1.CHECK_ON_DEVICE,p2:i.P2_DEFAULT},r=new t.ApduBuilder(e),a=this.args.derivationPath,o=s.DerivationPathUtils.splitPath(a);return r.add8BitUIntToData(o.length),o.forEach(m=>{r.add32BitUIntToData(m)}),r.build()}parseResponse(e){return l.Maybe.fromNullable(this.errorHelper.getError(e)).orDefaultLazy(()=>{const r=new t.ApduParser(e),a=r.extract8BitUInt();if(a===void 0)return(0,t.CommandResultFactory)({error:new t.InvalidStatusWordError("Aleo view key length is missing")});if(r.testMinimalLength(a)===!1)return(0,t.CommandResultFactory)({error:new t.InvalidStatusWordError("View key is missing")});const o=r.extractFieldByLength(a);if(o===void 0)return(0,t.CommandResultFactory)({error:new t.InvalidStatusWordError("Unable to extract view key")});const m=r.encodeToString(o);return(0,t.CommandResultFactory)({data:{viewKey:m}})})}}0&&(module.exports={GetViewKeyCommand});
|
|
2
2
|
//# sourceMappingURL=GetViewKeyCommand.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/internal/app-binder/command/GetViewKeyCommand.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 InvalidStatusWordError,\n} from \"@ledgerhq/device-management-kit\";\nimport {\n CommandErrorHelper,\n DerivationPathUtils,\n} from \"@ledgerhq/signer-utils\";\nimport { Maybe } from \"purify-ts\";\n\nimport {\n ALEO_APP_ERRORS,\n AleoAppCommandErrorFactory,\n type AleoErrorCodes,\n} from \"./utils/aleoApplicationErrors\";\n\nexport type GetViewKeyCommandArgs = {\n readonly derivationPath: string;\n
|
|
5
|
-
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,uBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAUO,2CACPC,EAGO,kCACPC,EAAsB,qBAEtBC,EAIO,
|
|
6
|
-
"names": ["GetViewKeyCommand_exports", "__export", "GetViewKeyCommand", "__toCommonJS", "import_device_management_kit", "import_signer_utils", "import_purify_ts", "import_aleoApplicationErrors", "args", "getViewKeyCommandArgs", "builder", "derivationPath", "path", "element", "response", "parser", "viewKeyLength", "buffer", "viewKey"]
|
|
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 InvalidStatusWordError,\n} from \"@ledgerhq/device-management-kit\";\nimport {\n CommandErrorHelper,\n DerivationPathUtils,\n} from \"@ledgerhq/signer-utils\";\nimport { Maybe } from \"purify-ts\";\n\nimport {\n ALEO_CLA,\n INS,\n P1,\n P2_DEFAULT,\n} from \"@internal/app-binder/command/utils/apduHeaderUtils\";\n\nimport {\n ALEO_APP_ERRORS,\n AleoAppCommandErrorFactory,\n type AleoErrorCodes,\n} from \"./utils/aleoApplicationErrors\";\n\nexport type GetViewKeyCommandArgs = {\n readonly derivationPath: string;\n};\n\nexport type GetViewKeyCommandResponse = {\n readonly viewKey: string;\n};\n\nexport class GetViewKeyCommand\n implements\n Command<GetViewKeyCommandResponse, GetViewKeyCommandArgs, AleoErrorCodes>\n{\n readonly name = \"getViewKey\";\n private readonly errorHelper = new CommandErrorHelper<\n GetViewKeyCommandResponse,\n AleoErrorCodes\n >(ALEO_APP_ERRORS, AleoAppCommandErrorFactory);\n\n private readonly args: GetViewKeyCommandArgs;\n\n constructor(args: GetViewKeyCommandArgs) {\n this.args = args;\n }\n\n getApdu(): Apdu {\n const getViewKeyCommandArgs: ApduBuilderArgs = {\n cla: ALEO_CLA,\n ins: INS.GET_VIEW_KEY,\n p1: P1.CHECK_ON_DEVICE,\n p2: P2_DEFAULT,\n };\n\n const builder = new ApduBuilder(getViewKeyCommandArgs);\n const derivationPath = this.args.derivationPath;\n\n const path = DerivationPathUtils.splitPath(derivationPath);\n builder.add8BitUIntToData(path.length);\n path.forEach((element) => {\n builder.add32BitUIntToData(element);\n });\n\n return builder.build();\n }\n\n parseResponse(\n response: ApduResponse,\n ): CommandResult<GetViewKeyCommandResponse, AleoErrorCodes> {\n return Maybe.fromNullable(\n this.errorHelper.getError(response),\n ).orDefaultLazy(() => {\n const parser = new ApduParser(response);\n\n const viewKeyLength = parser.extract8BitUInt();\n if (viewKeyLength === undefined) {\n return CommandResultFactory({\n error: new InvalidStatusWordError(\"Aleo view key length is missing\"),\n });\n }\n\n if (parser.testMinimalLength(viewKeyLength) === false) {\n return CommandResultFactory({\n error: new InvalidStatusWordError(\"View key is missing\"),\n });\n }\n\n const buffer = parser.extractFieldByLength(viewKeyLength);\n if (buffer === undefined) {\n return CommandResultFactory({\n error: new InvalidStatusWordError(\"Unable to extract view key\"),\n });\n }\n\n const viewKey = parser.encodeToString(buffer);\n\n return CommandResultFactory({\n data: {\n viewKey,\n },\n });\n });\n }\n}\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,uBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAUO,2CACPC,EAGO,kCACPC,EAAsB,qBAEtBC,EAKO,8DAEPC,EAIO,yCAUA,MAAMN,CAGb,CACW,KAAO,aACC,YAAc,IAAI,qBAGjC,kBAAiB,4BAA0B,EAE5B,KAEjB,YAAYO,EAA6B,CACvC,KAAK,KAAOA,CACd,CAEA,SAAgB,CACd,MAAMC,EAAyC,CAC7C,IAAK,WACL,IAAK,MAAI,aACT,GAAI,KAAG,gBACP,GAAI,YACN,EAEMC,EAAU,IAAI,cAAYD,CAAqB,EAC/CE,EAAiB,KAAK,KAAK,eAE3BC,EAAO,sBAAoB,UAAUD,CAAc,EACzD,OAAAD,EAAQ,kBAAkBE,EAAK,MAAM,EACrCA,EAAK,QAASC,GAAY,CACxBH,EAAQ,mBAAmBG,CAAO,CACpC,CAAC,EAEMH,EAAQ,MAAM,CACvB,CAEA,cACEI,EAC0D,CAC1D,OAAO,QAAM,aACX,KAAK,YAAY,SAASA,CAAQ,CACpC,EAAE,cAAc,IAAM,CACpB,MAAMC,EAAS,IAAI,aAAWD,CAAQ,EAEhCE,EAAgBD,EAAO,gBAAgB,EAC7C,GAAIC,IAAkB,OACpB,SAAO,wBAAqB,CAC1B,MAAO,IAAI,yBAAuB,iCAAiC,CACrE,CAAC,EAGH,GAAID,EAAO,kBAAkBC,CAAa,IAAM,GAC9C,SAAO,wBAAqB,CAC1B,MAAO,IAAI,yBAAuB,qBAAqB,CACzD,CAAC,EAGH,MAAMC,EAASF,EAAO,qBAAqBC,CAAa,EACxD,GAAIC,IAAW,OACb,SAAO,wBAAqB,CAC1B,MAAO,IAAI,yBAAuB,4BAA4B,CAChE,CAAC,EAGH,MAAMC,EAAUH,EAAO,eAAeE,CAAM,EAE5C,SAAO,wBAAqB,CAC1B,KAAM,CACJ,QAAAC,CACF,CACF,CAAC,CACH,CAAC,CACH,CACF",
|
|
6
|
+
"names": ["GetViewKeyCommand_exports", "__export", "GetViewKeyCommand", "__toCommonJS", "import_device_management_kit", "import_signer_utils", "import_purify_ts", "import_apduHeaderUtils", "import_aleoApplicationErrors", "args", "getViewKeyCommandArgs", "builder", "derivationPath", "path", "element", "response", "parser", "viewKeyLength", "buffer", "viewKey"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var e=require("@ledgerhq/device-management-kit"),n=require("./GetViewKeyCommand");const a="AViewKey1q7Q7AA6bRb4ipW2Qe7aDS7qaobZSH2qPqZ6FueUR72wL",
|
|
1
|
+
"use strict";var e=require("@ledgerhq/device-management-kit"),n=require("./GetViewKeyCommand");const a="AViewKey1q7Q7AA6bRb4ipW2Qe7aDS7qaobZSH2qPqZ6FueUR72wL",i=Uint8Array.from(Buffer.from("e007010015058000002c8000003c800000010000000200000003","hex")),c=Uint8Array.from(Buffer.from("e00701000d038000002c800002ab00000000","hex")),d=Uint8Array.from(Buffer.concat([Buffer.from([53]),Buffer.from(a,"ascii")])),m=new e.ApduResponse({statusCode:Uint8Array.from([144,0]),data:d});describe("GetViewKeyCommand",()=>{const s="44'/683'/0";describe("name",()=>{it("should be 'getViewKey'",()=>{const r=new n.GetViewKeyCommand({derivationPath:s});expect(r.name).toBe("getViewKey")})}),describe("getApdu",()=>{it("should return the GetViewKey apdu",()=>{const t=new n.GetViewKeyCommand({derivationPath:s}).getApdu();expect(t.getRawApdu()).toStrictEqual(c)}),it("should return the GetViewKey apdu with custom derivation path",()=>{const t=new n.GetViewKeyCommand({derivationPath:"44'/60'/1'/2/3"}).getApdu();expect(t.getRawApdu()).toStrictEqual(i)})}),describe("parseResponse",()=>{it("should parse the response",()=>{const t=new n.GetViewKeyCommand({derivationPath:s}).parseResponse(m);expect(t).toStrictEqual((0,e.CommandResultFactory)({data:{viewKey:a}}))}),describe("should return an error",()=>{it("when the response is not successfull",()=>{const r=new n.GetViewKeyCommand({derivationPath:s}),t=new e.ApduResponse({statusCode:Uint8Array.from([109,0]),data:new Uint8Array(0)}),o=r.parseResponse(t);expect((0,e.isSuccessCommandResult)(o)).toBe(!1)}),it("when view key is missing (response too short)",()=>{const r=new n.GetViewKeyCommand({derivationPath:s}),t=new e.ApduResponse({statusCode:Uint8Array.from([144,0]),data:Uint8Array.from([53])}),o=r.parseResponse(t);if((0,e.isSuccessCommandResult)(o))throw new Error("Expected an error");expect(o.error).toBeInstanceOf(e.InvalidStatusWordError),expect(o.error.originalError).toEqual(new Error("View key is missing"))}),it("when Aleo view key length is missing",()=>{const r=new n.GetViewKeyCommand({derivationPath:s}),t=new e.ApduResponse({statusCode:Uint8Array.from([144,0]),data:new Uint8Array(0)}),o=r.parseResponse(t);if((0,e.isSuccessCommandResult)(o))throw new Error("Expected an error");expect(o.error).toBeInstanceOf(e.InvalidStatusWordError),expect(o.error.originalError).toEqual(new Error("Aleo view key length is missing"))})})})});
|
|
2
2
|
//# sourceMappingURL=GetViewKeyCommand.test.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/internal/app-binder/command/GetViewKeyCommand.test.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n ApduResponse,\n CommandResultFactory,\n InvalidStatusWordError,\n isSuccessCommandResult,\n} from \"@ledgerhq/device-management-kit\";\n\nimport { GetViewKeyCommand } from \"./GetViewKeyCommand\";\n\nconst VIEW_KEY = \"AViewKey1q7Q7AA6bRb4ipW2Qe7aDS7qaobZSH2qPqZ6FueUR72wL\";\n\nconst
|
|
5
|
-
"mappings": "aAAA,IAAAA,EAKO,2CAEPC,EAAkC,+BAElC,MAAMC,EAAW,wDAEXC,
|
|
6
|
-
"names": ["import_device_management_kit", "import_GetViewKeyCommand", "VIEW_KEY", "
|
|
4
|
+
"sourcesContent": ["import {\n ApduResponse,\n CommandResultFactory,\n InvalidStatusWordError,\n isSuccessCommandResult,\n} from \"@ledgerhq/device-management-kit\";\n\nimport { GetViewKeyCommand } from \"./GetViewKeyCommand\";\n\nconst VIEW_KEY = \"AViewKey1q7Q7AA6bRb4ipW2Qe7aDS7qaobZSH2qPqZ6FueUR72wL\";\n\nconst GET_VIEW_KEY_APDU_WITH_CHECK_ON_DEVICE_AND_LONG_DERIVATION_PATH =\n Uint8Array.from(\n Buffer.from(\"e007010015058000002c8000003c800000010000000200000003\", \"hex\"),\n );\n\nconst GET_VIEW_KEY_APDU_WIT_CHECK_ON_DEVICE = Uint8Array.from(\n Buffer.from(\"e00701000d038000002c800002ab00000000\", \"hex\"),\n);\n\nconst RESPONSE_DATA = Uint8Array.from(\n Buffer.concat([Buffer.from([0x35]), Buffer.from(VIEW_KEY, \"ascii\")]),\n);\n\nconst RESPONSE_GOOD = new ApduResponse({\n statusCode: Uint8Array.from([0x90, 0x00]),\n data: RESPONSE_DATA,\n});\n\ndescribe(\"GetViewKeyCommand\", () => {\n const derivationPath = \"44'/683'/0\";\n\n describe(\"name\", () => {\n it(\"should be 'getViewKey'\", () => {\n const command = new GetViewKeyCommand({ derivationPath });\n expect(command.name).toBe(\"getViewKey\");\n });\n });\n\n describe(\"getApdu\", () => {\n it(\"should return the GetViewKey apdu\", () => {\n const command = new GetViewKeyCommand({\n derivationPath,\n });\n const apdu = command.getApdu();\n expect(apdu.getRawApdu()).toStrictEqual(\n GET_VIEW_KEY_APDU_WIT_CHECK_ON_DEVICE,\n );\n });\n\n it(\"should return the GetViewKey apdu with custom derivation path\", () => {\n const command = new GetViewKeyCommand({\n derivationPath: \"44'/60'/1'/2/3\",\n });\n const apdu = command.getApdu();\n expect(apdu.getRawApdu()).toStrictEqual(\n GET_VIEW_KEY_APDU_WITH_CHECK_ON_DEVICE_AND_LONG_DERIVATION_PATH,\n );\n });\n });\n\n describe(\"parseResponse\", () => {\n it(\"should parse the response\", () => {\n const command = new GetViewKeyCommand({ derivationPath });\n const parsed = command.parseResponse(RESPONSE_GOOD);\n expect(parsed).toStrictEqual(\n CommandResultFactory({\n data: {\n viewKey: VIEW_KEY,\n },\n }),\n );\n });\n\n describe(\"should return an error\", () => {\n it(\"when the response is not successfull\", () => {\n // GIVEN\n const command = new GetViewKeyCommand({ derivationPath });\n const response = new ApduResponse({\n statusCode: Uint8Array.from([0x6d, 0x00]),\n data: new Uint8Array(0),\n });\n\n // WHEN\n const result = command.parseResponse(response);\n\n // THEN\n expect(isSuccessCommandResult(result)).toBe(false);\n });\n\n it(\"when view key is missing (response too short)\", () => {\n // GIVEN\n const command = new GetViewKeyCommand({ derivationPath });\n const response = new ApduResponse({\n statusCode: Uint8Array.from([0x90, 0x00]),\n data: Uint8Array.from([0x35]), // Only length, no view key\n });\n\n // WHEN\n const result = command.parseResponse(response);\n\n // THEN\n if (isSuccessCommandResult(result)) {\n throw new Error(\"Expected an error\");\n } else {\n expect(result.error).toBeInstanceOf(InvalidStatusWordError);\n expect(result.error.originalError).toEqual(\n new Error(\"View key is missing\"),\n );\n }\n });\n\n it(\"when Aleo view key length is missing\", () => {\n // GIVEN\n const command = new GetViewKeyCommand({ derivationPath });\n const response = new ApduResponse({\n statusCode: Uint8Array.from([0x90, 0x00]),\n data: new Uint8Array(0),\n });\n\n // WHEN\n const result = command.parseResponse(response);\n\n // THEN\n if (isSuccessCommandResult(result)) {\n throw new Error(\"Expected an error\");\n } else {\n expect(result.error).toBeInstanceOf(InvalidStatusWordError);\n expect(result.error.originalError).toEqual(\n new Error(\"Aleo view key length is missing\"),\n );\n }\n });\n });\n });\n});\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": ["import_device_management_kit", "import_GetViewKeyCommand", "VIEW_KEY", "GET_VIEW_KEY_APDU_WITH_CHECK_ON_DEVICE_AND_LONG_DERIVATION_PATH", "GET_VIEW_KEY_APDU_WIT_CHECK_ON_DEVICE", "RESPONSE_DATA", "RESPONSE_GOOD", "derivationPath", "command", "apdu", "parsed", "response", "result"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var m=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var u=Object.prototype.hasOwnProperty;var A=(o,e)=>{for(var r in e)m(o,r,{get:e[r],enumerable:!0})},C=(o,e,r,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of l(e))!u.call(o,n)&&n!==r&&m(o,n,{get:()=>e[n],enumerable:!(s=g(e,n))||s.enumerable});return o};var y=o=>C(m({},"__esModule",{value:!0}),o);var F={};A(F,{SignFeeIntentCommand:()=>I});module.exports=y(F);var t=require("@ledgerhq/device-management-kit"),p=require("@ledgerhq/signer-utils"),i=require("purify-ts"),a=require("../../app-binder/command/utils/apduHeaderUtils"),d=require("./utils/aleoApplicationErrors");class I{name="signFeeIntent";errorHelper=new p.CommandErrorHelper(d.ALEO_APP_ERRORS,d.AleoAppCommandErrorFactory);args;constructor(e){this.args=e}getApdu(){const e={cla:a.ALEO_CLA,ins:a.INS.SIGN_INTENT,p1:a.P1.SIGN_MODE_FEE,p2:a.P2_DEFAULT},r=new t.ApduBuilder(e);return r.add16BitUIntToData(this.args.feeIntent.byteLength),r.addBufferToData(this.args.feeIntent),r.build()}parseResponse(e){return i.Maybe.fromNullable(this.errorHelper.getError(e)).orDefaultLazy(()=>{const r=new t.ApduParser(e),s=r.getUnparsedRemainingLength(),n=r.extractFieldByLength(s);return n&&n.length>0?(0,t.CommandResultFactory)({data:{tlvSignature:r.encodeToHexaString(n)}}):(0,t.CommandResultFactory)({error:new t.InvalidStatusWordError("Failed to extract data from response")})})}}0&&(module.exports={SignFeeIntentCommand});
|
|
2
|
+
//# sourceMappingURL=SignFeeIntentCommand.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 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 InvalidStatusWordError,\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_DEFAULT,\n} from \"@internal/app-binder/command/utils/apduHeaderUtils\";\n\nimport {\n ALEO_APP_ERRORS,\n AleoAppCommandErrorFactory,\n type AleoErrorCodes,\n} from \"./utils/aleoApplicationErrors\";\n\nexport type SignFeeIntentCommandArgs = {\n readonly feeIntent: Uint8Array;\n};\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 private readonly args: SignFeeIntentCommandArgs;\n\n constructor(args: SignFeeIntentCommandArgs) {\n this.args = args;\n }\n\n getApdu(): Apdu {\n const signFeeIntentArgs: ApduBuilderArgs = {\n cla: ALEO_CLA,\n ins: INS.SIGN_INTENT,\n p1: P1.SIGN_MODE_FEE, // Second chunk / fee intent\n p2: P2_DEFAULT,\n };\n\n const builder = new ApduBuilder(signFeeIntentArgs);\n\n builder.add16BitUIntToData(this.args.feeIntent.byteLength);\n\n // Add the fee intent data (no derivation path for the second chunk)\n builder.addBufferToData(this.args.feeIntent);\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 return CommandResultFactory({\n error: new InvalidStatusWordError(\n \"Failed to extract data from response\",\n ),\n });\n });\n }\n}\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,0BAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAUO,2CACPC,EAAmC,kCACnCC,EAAsB,qBAEtBC,EAKO,8DAEPC,EAIO,yCAgBA,MAAMN,CAOb,CACW,KAAO,gBACC,YAAc,IAAI,qBAGjC,kBAAiB,4BAA0B,EAE5B,KAEjB,YAAYO,EAAgC,CAC1C,KAAK,KAAOA,CACd,CAEA,SAAgB,CACd,MAAMC,EAAqC,CACzC,IAAK,WACL,IAAK,MAAI,YACT,GAAI,KAAG,cACP,GAAI,YACN,EAEMC,EAAU,IAAI,cAAYD,CAAiB,EAEjD,OAAAC,EAAQ,mBAAmB,KAAK,KAAK,UAAU,UAAU,EAGzDA,EAAQ,gBAAgB,KAAK,KAAK,SAAS,EAEpCA,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,KAGI,wBAAqB,CAC1B,MAAO,IAAI,yBACT,sCACF,CACF,CAAC,CACH,CAAC,CACH,CACF",
|
|
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
|
+
}
|