@ledgerhq/device-trusted-app-kit-ledger-keyring-protocol 0.0.0-develop-20250904001204 → 0.0.0-e2e-speculos-20250904125723
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/LedgerKeyringProtocol.js +1 -1
- package/lib/cjs/api/LedgerKeyringProtocol.js.map +1 -1
- package/lib/cjs/api/LedgerKeyringProtocolBuilder.js +1 -1
- package/lib/cjs/api/LedgerKeyringProtocolBuilder.js.map +3 -3
- package/lib/cjs/api/app-binder/AddToTrustchainDeviceActionTypes.js +1 -1
- package/lib/cjs/api/app-binder/AddToTrustchainDeviceActionTypes.js.map +3 -3
- package/lib/cjs/api/app-binder/AuthenticateDeviceActionTypes.js +1 -1
- package/lib/cjs/api/app-binder/AuthenticateDeviceActionTypes.js.map +3 -3
- package/lib/cjs/api/app-binder/Errors.js +2 -0
- package/lib/cjs/api/app-binder/Errors.js.map +7 -0
- package/lib/cjs/api/app-binder/GetAppNameCommandTypes.js +2 -0
- package/lib/cjs/api/app-binder/GetAppNameCommandTypes.js.map +7 -0
- package/lib/cjs/api/app-binder/GetSeedIdCommandTypes.js +2 -0
- package/lib/cjs/api/app-binder/GetSeedIdCommandTypes.js.map +7 -0
- package/lib/cjs/api/app-binder/GetVersionCommandTypes.js +1 -1
- package/lib/cjs/api/app-binder/GetVersionCommandTypes.js.map +1 -1
- package/lib/cjs/api/app-binder/InitCommandTypes.js +2 -0
- package/lib/cjs/api/app-binder/InitCommandTypes.js.map +7 -0
- package/lib/cjs/api/app-binder/KeypairFromBytes.js +2 -0
- package/lib/cjs/api/app-binder/KeypairFromBytes.js.map +7 -0
- package/lib/cjs/api/app-binder/LKRPTypes.js +2 -0
- package/lib/cjs/api/app-binder/LKRPTypes.js.map +7 -0
- package/lib/cjs/api/app-binder/ParseStreamBlockCommandCommandTypes.js +2 -0
- package/lib/cjs/api/app-binder/ParseStreamBlockCommandCommandTypes.js.map +7 -0
- package/lib/cjs/api/app-binder/ParseStreamBlockHeaderCommandTypes.js +2 -0
- package/lib/cjs/api/app-binder/ParseStreamBlockHeaderCommandTypes.js.map +7 -0
- package/lib/cjs/api/app-binder/ParseStreamBlockSignatureTypes.js +2 -0
- package/lib/cjs/api/app-binder/ParseStreamBlockSignatureTypes.js.map +7 -0
- package/lib/cjs/api/app-binder/SetTrustedMemberTypes.js +2 -0
- package/lib/cjs/api/app-binder/SetTrustedMemberTypes.js.map +7 -0
- package/lib/cjs/api/app-binder/SignBlockCommandTypes.js +2 -0
- package/lib/cjs/api/app-binder/SignBlockCommandTypes.js.map +7 -0
- package/lib/cjs/api/app-binder/SignBlockHeaderCommandTypes.js +2 -0
- package/lib/cjs/api/app-binder/SignBlockHeaderCommandTypes.js.map +7 -0
- package/lib/cjs/api/app-binder/SignBlockSignatureCommandTypes.js +2 -0
- package/lib/cjs/api/app-binder/SignBlockSignatureCommandTypes.js.map +7 -0
- package/lib/cjs/api/app-binder/SignBlockSingleCommandTypes.js +2 -0
- package/lib/cjs/api/app-binder/SignBlockSingleCommandTypes.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/DefaultLedgerKeyringProtocol.js +1 -1
- package/lib/cjs/internal/DefaultLedgerKeyringProtocol.js.map +3 -3
- package/lib/cjs/internal/app-binder/LedgerKeyringProtocolBinder.js +1 -1
- package/lib/cjs/internal/app-binder/LedgerKeyringProtocolBinder.js.map +3 -3
- package/lib/cjs/internal/app-binder/command/GetAppNameCommand.js +1 -1
- package/lib/cjs/internal/app-binder/command/GetAppNameCommand.js.map +2 -2
- package/lib/cjs/internal/app-binder/command/GetSeedIdCommand.js +1 -1
- package/lib/cjs/internal/app-binder/command/GetSeedIdCommand.js.map +3 -3
- package/lib/cjs/internal/app-binder/command/GetSeedIdCommand.test.js +2 -2
- package/lib/cjs/internal/app-binder/command/GetSeedIdCommand.test.js.map +3 -3
- package/lib/cjs/internal/app-binder/command/GetVersionCommand.js.map +2 -2
- package/lib/cjs/internal/app-binder/command/InitCommand.js +1 -1
- package/lib/cjs/internal/app-binder/command/InitCommand.js.map +2 -2
- package/lib/cjs/internal/app-binder/command/InitCommand.test.js +1 -1
- package/lib/cjs/internal/app-binder/command/InitCommand.test.js.map +2 -2
- package/lib/cjs/internal/app-binder/command/ParseBlockSignatureCommand.js +1 -1
- package/lib/cjs/internal/app-binder/command/ParseBlockSignatureCommand.js.map +2 -2
- package/lib/cjs/internal/app-binder/command/ParseBlockSignatureCommand.test.js +1 -1
- package/lib/cjs/internal/app-binder/command/ParseBlockSignatureCommand.test.js.map +2 -2
- package/lib/cjs/internal/app-binder/command/ParseStreamBlockCommand.js.map +2 -2
- package/lib/cjs/internal/app-binder/command/ParseStreamBlockCommand.test.js +1 -1
- package/lib/cjs/internal/app-binder/command/ParseStreamBlockCommand.test.js.map +2 -2
- package/lib/cjs/internal/app-binder/command/ParseStreamBlockHeader.js +1 -1
- package/lib/cjs/internal/app-binder/command/ParseStreamBlockHeader.js.map +2 -2
- package/lib/cjs/internal/app-binder/command/ParseStreamBlockHeader.test.js.map +2 -2
- package/lib/cjs/internal/app-binder/command/SetTrustedMemberCommand.js +1 -1
- package/lib/cjs/internal/app-binder/command/SetTrustedMemberCommand.js.map +3 -3
- package/lib/cjs/internal/app-binder/command/SetTrustedMemberCommand.test.js.map +2 -2
- package/lib/cjs/internal/app-binder/command/SignBlockHeader.js +1 -1
- package/lib/cjs/internal/app-binder/command/SignBlockHeader.js.map +3 -3
- package/lib/cjs/internal/app-binder/command/SignBlockHeader.test.js +1 -1
- package/lib/cjs/internal/app-binder/command/SignBlockHeader.test.js.map +3 -3
- package/lib/cjs/internal/app-binder/command/SignBlockSignatureCommand.js +1 -1
- package/lib/cjs/internal/app-binder/command/SignBlockSignatureCommand.js.map +2 -2
- package/lib/cjs/internal/app-binder/command/SignBlockSignatureCommand.test.js +1 -1
- package/lib/cjs/internal/app-binder/command/SignBlockSignatureCommand.test.js.map +2 -2
- package/lib/cjs/internal/app-binder/command/SignBlockSingleCommand.js +1 -1
- package/lib/cjs/internal/app-binder/command/SignBlockSingleCommand.js.map +2 -2
- package/lib/cjs/internal/app-binder/command/SignBlockSingleCommand.test.js +1 -1
- package/lib/cjs/internal/app-binder/command/SignBlockSingleCommand.test.js.map +2 -2
- package/lib/cjs/internal/app-binder/device-action/AddToTrustchainDeviceAction.js +1 -1
- package/lib/cjs/internal/app-binder/device-action/AddToTrustchainDeviceAction.js.map +3 -3
- package/lib/cjs/internal/app-binder/device-action/AuthenticateDeviceAction.js +2 -0
- package/lib/cjs/internal/app-binder/device-action/AuthenticateDeviceAction.js.map +7 -0
- package/lib/cjs/internal/app-binder/task/InitTask.js +1 -1
- package/lib/cjs/internal/app-binder/task/InitTask.js.map +3 -3
- package/lib/cjs/internal/app-binder/task/ParseStreamToDeviceTask.js +1 -1
- package/lib/cjs/internal/app-binder/task/ParseStreamToDeviceTask.js.map +3 -3
- package/lib/cjs/internal/app-binder/task/SignBlockTask.js +1 -1
- package/lib/cjs/internal/app-binder/task/SignBlockTask.js.map +3 -3
- package/lib/cjs/internal/app-binder/task/SignChallengeWithKeypairTask.js +1 -1
- package/lib/cjs/internal/app-binder/task/SignChallengeWithKeypairTask.js.map +3 -3
- package/lib/cjs/internal/app-binder/task/SignChallengeWithKeypairTask.test.js +1 -1
- package/lib/cjs/internal/app-binder/task/SignChallengeWithKeypairTask.test.js.map +3 -3
- package/lib/cjs/internal/app-binder/task/utils/TrustedProperties.js +1 -1
- package/lib/cjs/internal/app-binder/task/utils/TrustedProperties.js.map +3 -3
- package/lib/cjs/internal/di.js +1 -1
- package/lib/cjs/internal/di.js.map +3 -3
- package/lib/cjs/internal/externalTypes.js +1 -1
- package/lib/cjs/internal/externalTypes.js.map +2 -2
- package/lib/cjs/internal/lkrp-datasource/data/HttpLKRPDataSource.js +1 -1
- package/lib/cjs/internal/lkrp-datasource/data/HttpLKRPDataSource.js.map +3 -3
- package/lib/cjs/internal/lkrp-datasource/data/HttpLKRPDataSource.test.js +1 -1
- package/lib/cjs/internal/lkrp-datasource/data/HttpLKRPDataSource.test.js.map +3 -3
- package/lib/cjs/internal/lkrp-datasource/data/LKRPDataSource.js +1 -1
- package/lib/cjs/internal/lkrp-datasource/data/LKRPDataSource.js.map +1 -1
- package/lib/cjs/internal/use-cases/authentication/AuthenticateUseCase.js +1 -1
- package/lib/cjs/internal/use-cases/authentication/AuthenticateUseCase.js.map +3 -3
- package/lib/cjs/internal/use-cases/di/useCasesModule.js +1 -1
- package/lib/cjs/internal/use-cases/di/useCasesModule.js.map +3 -3
- package/lib/cjs/internal/use-cases/di/useCasesTypes.js +1 -1
- package/lib/cjs/internal/use-cases/di/useCasesTypes.js.map +2 -2
- package/lib/cjs/internal/utils/LKRPBlock.js +4 -4
- package/lib/cjs/internal/utils/LKRPBlock.js.map +3 -3
- package/lib/cjs/internal/utils/LKRPBlock.test.js +3 -3
- package/lib/cjs/internal/utils/LKRPBlock.test.js.map +3 -3
- package/lib/cjs/internal/utils/LKRPBlockStream.js +2 -2
- package/lib/cjs/internal/utils/LKRPBlockStream.js.map +3 -3
- package/lib/cjs/internal/utils/LKRPBlockStream.test.js +3 -3
- package/lib/cjs/internal/utils/LKRPBlockStream.test.js.map +3 -3
- package/lib/cjs/internal/utils/LKRPCommand.js +2 -2
- package/lib/cjs/internal/utils/LKRPCommand.js.map +3 -3
- package/lib/cjs/internal/utils/LKRPCommand.test.js +1 -1
- package/lib/cjs/internal/utils/LKRPCommand.test.js.map +3 -3
- package/lib/cjs/internal/utils/TLVBuilder.js +2 -0
- package/lib/cjs/internal/utils/TLVBuilder.js.map +7 -0
- package/lib/cjs/internal/utils/TLVParser.js +1 -1
- package/lib/cjs/internal/utils/TLVParser.js.map +3 -3
- package/lib/cjs/internal/utils/TLVParser.test.js +1 -1
- package/lib/cjs/internal/utils/TLVParser.test.js.map +3 -3
- package/lib/cjs/internal/{models/Tags.js → utils/TLVTags.js} +1 -1
- package/lib/cjs/internal/{models/Tags.js.map → utils/TLVTags.js.map} +2 -2
- package/lib/cjs/internal/utils/crypto.js +2 -0
- package/lib/cjs/internal/utils/crypto.js.map +7 -0
- package/lib/cjs/internal/utils/hex.js +2 -0
- package/lib/cjs/internal/utils/hex.js.map +7 -0
- package/lib/cjs/internal/utils/required.js +1 -1
- package/lib/cjs/internal/utils/required.js.map +2 -2
- package/lib/cjs/internal/utils/types.js +2 -0
- package/lib/cjs/internal/utils/types.js.map +7 -0
- package/lib/cjs/package.json +2 -3
- package/lib/esm/api/LedgerKeyringProtocolBuilder.js +1 -1
- package/lib/esm/api/LedgerKeyringProtocolBuilder.js.map +3 -3
- package/lib/esm/api/app-binder/AddToTrustchainDeviceActionTypes.js +0 -1
- package/lib/esm/api/app-binder/AddToTrustchainDeviceActionTypes.js.map +4 -4
- package/lib/esm/api/app-binder/AuthenticateDeviceActionTypes.js +0 -1
- package/lib/esm/api/app-binder/AuthenticateDeviceActionTypes.js.map +4 -4
- package/lib/esm/api/app-binder/Errors.js +2 -0
- package/lib/esm/api/app-binder/Errors.js.map +7 -0
- package/lib/esm/api/app-binder/GetAppNameCommandTypes.js +1 -0
- package/lib/esm/api/app-binder/GetSeedIdCommandTypes.js +1 -0
- package/lib/esm/api/app-binder/InitCommandTypes.js +1 -0
- package/lib/esm/api/app-binder/KeypairFromBytes.js +2 -0
- package/lib/esm/api/app-binder/KeypairFromBytes.js.map +7 -0
- package/lib/esm/api/app-binder/LKRPTypes.js +2 -0
- package/lib/esm/api/app-binder/LKRPTypes.js.map +7 -0
- package/lib/esm/api/app-binder/ParseStreamBlockCommandCommandTypes.js +1 -0
- package/lib/esm/api/app-binder/ParseStreamBlockHeaderCommandTypes.js +1 -0
- package/lib/esm/api/app-binder/ParseStreamBlockSignatureTypes.js +1 -0
- package/lib/esm/api/app-binder/SetTrustedMemberTypes.js +1 -0
- package/lib/esm/api/app-binder/SetTrustedMemberTypes.js.map +7 -0
- package/lib/esm/api/app-binder/SignBlockCommandTypes.js +1 -0
- package/lib/esm/api/app-binder/SignBlockCommandTypes.js.map +7 -0
- package/lib/esm/api/app-binder/SignBlockHeaderCommandTypes.js +1 -0
- package/lib/esm/api/app-binder/SignBlockHeaderCommandTypes.js.map +7 -0
- package/lib/esm/api/app-binder/SignBlockSignatureCommandTypes.js +1 -0
- package/lib/esm/api/app-binder/SignBlockSignatureCommandTypes.js.map +7 -0
- package/lib/esm/api/app-binder/SignBlockSingleCommandTypes.js +1 -0
- package/lib/esm/api/app-binder/SignBlockSingleCommandTypes.js.map +7 -0
- package/lib/esm/api/index.js +1 -1
- package/lib/esm/api/index.js.map +2 -2
- package/lib/esm/internal/DefaultLedgerKeyringProtocol.js +1 -1
- package/lib/esm/internal/DefaultLedgerKeyringProtocol.js.map +3 -3
- package/lib/esm/internal/app-binder/LedgerKeyringProtocolBinder.js +1 -1
- package/lib/esm/internal/app-binder/LedgerKeyringProtocolBinder.js.map +3 -3
- package/lib/esm/internal/app-binder/command/GetAppNameCommand.js +1 -1
- package/lib/esm/internal/app-binder/command/GetAppNameCommand.js.map +2 -2
- package/lib/esm/internal/app-binder/command/GetSeedIdCommand.js +1 -1
- package/lib/esm/internal/app-binder/command/GetSeedIdCommand.js.map +3 -3
- package/lib/esm/internal/app-binder/command/GetSeedIdCommand.test.js +1 -1
- package/lib/esm/internal/app-binder/command/GetSeedIdCommand.test.js.map +3 -3
- package/lib/esm/internal/app-binder/command/GetVersionCommand.js.map +2 -2
- package/lib/esm/internal/app-binder/command/InitCommand.js +1 -1
- package/lib/esm/internal/app-binder/command/InitCommand.js.map +2 -2
- package/lib/esm/internal/app-binder/command/InitCommand.test.js +1 -1
- package/lib/esm/internal/app-binder/command/InitCommand.test.js.map +2 -2
- package/lib/esm/internal/app-binder/command/ParseBlockSignatureCommand.js +1 -1
- package/lib/esm/internal/app-binder/command/ParseBlockSignatureCommand.js.map +2 -2
- package/lib/esm/internal/app-binder/command/ParseBlockSignatureCommand.test.js +1 -1
- package/lib/esm/internal/app-binder/command/ParseBlockSignatureCommand.test.js.map +2 -2
- package/lib/esm/internal/app-binder/command/ParseStreamBlockCommand.js.map +2 -2
- package/lib/esm/internal/app-binder/command/ParseStreamBlockCommand.test.js +1 -1
- package/lib/esm/internal/app-binder/command/ParseStreamBlockCommand.test.js.map +2 -2
- package/lib/esm/internal/app-binder/command/ParseStreamBlockHeader.js +1 -1
- package/lib/esm/internal/app-binder/command/ParseStreamBlockHeader.js.map +2 -2
- package/lib/esm/internal/app-binder/command/ParseStreamBlockHeader.test.js.map +2 -2
- package/lib/esm/internal/app-binder/command/SetTrustedMemberCommand.js +1 -1
- package/lib/esm/internal/app-binder/command/SetTrustedMemberCommand.js.map +2 -2
- package/lib/esm/internal/app-binder/command/SetTrustedMemberCommand.test.js +1 -1
- package/lib/esm/internal/app-binder/command/SetTrustedMemberCommand.test.js.map +2 -2
- package/lib/esm/internal/app-binder/command/SignBlockHeader.js +1 -1
- package/lib/esm/internal/app-binder/command/SignBlockHeader.js.map +3 -3
- package/lib/esm/internal/app-binder/command/SignBlockHeader.test.js +1 -1
- package/lib/esm/internal/app-binder/command/SignBlockHeader.test.js.map +3 -3
- package/lib/esm/internal/app-binder/command/SignBlockSignatureCommand.js +1 -1
- package/lib/esm/internal/app-binder/command/SignBlockSignatureCommand.js.map +2 -2
- package/lib/esm/internal/app-binder/command/SignBlockSignatureCommand.test.js +1 -1
- package/lib/esm/internal/app-binder/command/SignBlockSignatureCommand.test.js.map +2 -2
- package/lib/esm/internal/app-binder/command/SignBlockSingleCommand.js +1 -1
- package/lib/esm/internal/app-binder/command/SignBlockSingleCommand.js.map +2 -2
- package/lib/esm/internal/app-binder/command/SignBlockSingleCommand.test.js +1 -1
- package/lib/esm/internal/app-binder/command/SignBlockSingleCommand.test.js.map +2 -2
- package/lib/esm/internal/app-binder/device-action/AddToTrustchainDeviceAction.js +1 -1
- package/lib/esm/internal/app-binder/device-action/AddToTrustchainDeviceAction.js.map +3 -3
- package/lib/esm/internal/app-binder/device-action/AuthenticateDeviceAction.js +2 -0
- package/lib/esm/internal/app-binder/device-action/AuthenticateDeviceAction.js.map +7 -0
- package/lib/esm/internal/app-binder/task/InitTask.js +1 -1
- package/lib/esm/internal/app-binder/task/InitTask.js.map +3 -3
- package/lib/esm/internal/app-binder/task/ParseStreamToDeviceTask.js +1 -1
- package/lib/esm/internal/app-binder/task/ParseStreamToDeviceTask.js.map +3 -3
- package/lib/esm/internal/app-binder/task/SignBlockTask.js +1 -1
- package/lib/esm/internal/app-binder/task/SignBlockTask.js.map +3 -3
- package/lib/esm/internal/app-binder/task/SignChallengeWithKeypairTask.js +1 -1
- package/lib/esm/internal/app-binder/task/SignChallengeWithKeypairTask.js.map +3 -3
- package/lib/esm/internal/app-binder/task/SignChallengeWithKeypairTask.test.js +1 -1
- package/lib/esm/internal/app-binder/task/SignChallengeWithKeypairTask.test.js.map +3 -3
- package/lib/esm/internal/app-binder/task/utils/TrustedProperties.js +1 -1
- package/lib/esm/internal/app-binder/task/utils/TrustedProperties.js.map +3 -3
- package/lib/esm/internal/di.js +1 -1
- package/lib/esm/internal/di.js.map +3 -3
- package/lib/esm/internal/externalTypes.js +1 -1
- package/lib/esm/internal/externalTypes.js.map +2 -2
- package/lib/esm/internal/lkrp-datasource/data/HttpLKRPDataSource.js +1 -1
- package/lib/esm/internal/lkrp-datasource/data/HttpLKRPDataSource.js.map +3 -3
- package/lib/esm/internal/lkrp-datasource/data/HttpLKRPDataSource.test.js +1 -1
- package/lib/esm/internal/lkrp-datasource/data/HttpLKRPDataSource.test.js.map +3 -3
- package/lib/esm/internal/use-cases/authentication/AuthenticateUseCase.js +1 -1
- package/lib/esm/internal/use-cases/authentication/AuthenticateUseCase.js.map +3 -3
- package/lib/esm/internal/use-cases/di/useCasesModule.js +1 -1
- package/lib/esm/internal/use-cases/di/useCasesModule.js.map +3 -3
- package/lib/esm/internal/use-cases/di/useCasesTypes.js +1 -1
- package/lib/esm/internal/use-cases/di/useCasesTypes.js.map +2 -2
- package/lib/esm/internal/utils/LKRPBlock.js +3 -3
- package/lib/esm/internal/utils/LKRPBlock.js.map +3 -3
- package/lib/esm/internal/utils/LKRPBlock.test.js +2 -2
- package/lib/esm/internal/utils/LKRPBlock.test.js.map +3 -3
- package/lib/esm/internal/utils/LKRPBlockStream.js +2 -2
- package/lib/esm/internal/utils/LKRPBlockStream.js.map +3 -3
- package/lib/esm/internal/utils/LKRPBlockStream.test.js +3 -3
- package/lib/esm/internal/utils/LKRPBlockStream.test.js.map +3 -3
- package/lib/esm/internal/utils/LKRPCommand.js +2 -2
- package/lib/esm/internal/utils/LKRPCommand.js.map +3 -3
- package/lib/esm/internal/utils/LKRPCommand.test.js +1 -1
- package/lib/esm/internal/utils/LKRPCommand.test.js.map +3 -3
- package/lib/esm/internal/utils/TLVBuilder.js +2 -0
- package/lib/esm/internal/utils/TLVBuilder.js.map +7 -0
- package/lib/esm/internal/utils/TLVParser.js +1 -1
- package/lib/esm/internal/utils/TLVParser.js.map +3 -3
- package/lib/esm/internal/utils/TLVParser.test.js +1 -1
- package/lib/esm/internal/utils/TLVParser.test.js.map +3 -3
- package/lib/esm/internal/{models/Tags.js → utils/TLVTags.js} +1 -1
- package/lib/esm/internal/{models/Tags.js.map → utils/TLVTags.js.map} +1 -1
- package/lib/esm/internal/utils/crypto.js +2 -0
- package/lib/esm/internal/utils/crypto.js.map +7 -0
- package/lib/esm/internal/utils/hex.js +2 -0
- package/lib/esm/internal/utils/hex.js.map +7 -0
- package/lib/esm/internal/utils/required.js +1 -1
- package/lib/esm/internal/utils/required.js.map +2 -2
- package/lib/esm/internal/utils/types.js +1 -0
- package/lib/esm/internal/utils/types.js.map +7 -0
- package/lib/esm/package.json +2 -3
- package/lib/types/api/LedgerKeyringProtocol.d.ts +5 -4
- package/lib/types/api/LedgerKeyringProtocol.d.ts.map +1 -1
- package/lib/types/api/LedgerKeyringProtocolBuilder.d.ts +6 -12
- package/lib/types/api/LedgerKeyringProtocolBuilder.d.ts.map +1 -1
- package/lib/types/api/app-binder/AddToTrustchainDeviceActionTypes.d.ts +11 -25
- package/lib/types/api/app-binder/AddToTrustchainDeviceActionTypes.d.ts.map +1 -1
- package/lib/types/api/app-binder/AuthenticateDeviceActionTypes.d.ts +31 -27
- package/lib/types/api/app-binder/AuthenticateDeviceActionTypes.d.ts.map +1 -1
- package/lib/types/api/app-binder/Errors.d.ts +27 -0
- package/lib/types/api/app-binder/Errors.d.ts.map +1 -0
- package/lib/types/api/app-binder/GetAppNameCommandTypes.d.ts +5 -0
- package/lib/types/api/app-binder/GetAppNameCommandTypes.d.ts.map +1 -0
- package/lib/types/api/app-binder/GetSeedIdCommandTypes.d.ts +14 -0
- package/lib/types/api/app-binder/GetSeedIdCommandTypes.d.ts.map +1 -0
- package/lib/types/api/app-binder/GetVersionCommandTypes.d.ts +1 -0
- package/lib/types/api/app-binder/GetVersionCommandTypes.d.ts.map +1 -1
- package/lib/types/api/app-binder/InitCommandTypes.d.ts +5 -0
- package/lib/types/api/app-binder/InitCommandTypes.d.ts.map +1 -0
- package/lib/types/api/app-binder/KeypairFromBytes.d.ts +11 -0
- package/lib/types/api/app-binder/KeypairFromBytes.d.ts.map +1 -0
- package/lib/types/api/{model/Permissions.d.ts → app-binder/LKRPTypes.d.ts} +15 -1
- package/lib/types/api/app-binder/LKRPTypes.d.ts.map +1 -0
- package/lib/types/api/app-binder/ParseStreamBlockCommandCommandTypes.d.ts +6 -0
- package/lib/types/api/app-binder/ParseStreamBlockCommandCommandTypes.d.ts.map +1 -0
- package/lib/types/api/app-binder/ParseStreamBlockHeaderCommandTypes.d.ts +5 -0
- package/lib/types/api/app-binder/ParseStreamBlockHeaderCommandTypes.d.ts.map +1 -0
- package/lib/types/api/app-binder/ParseStreamBlockSignatureTypes.d.ts +5 -0
- package/lib/types/api/app-binder/ParseStreamBlockSignatureTypes.d.ts.map +1 -0
- package/lib/types/api/app-binder/SetTrustedMemberTypes.d.ts +6 -0
- package/lib/types/api/app-binder/SetTrustedMemberTypes.d.ts.map +1 -0
- package/lib/types/api/app-binder/SignBlockCommandTypes.d.ts +9 -0
- package/lib/types/api/app-binder/SignBlockCommandTypes.d.ts.map +1 -0
- package/lib/types/api/app-binder/SignBlockHeaderCommandTypes.d.ts +5 -0
- package/lib/types/api/app-binder/SignBlockHeaderCommandTypes.d.ts.map +1 -0
- package/lib/types/api/app-binder/SignBlockSignatureCommandTypes.d.ts +6 -0
- package/lib/types/api/app-binder/SignBlockSignatureCommandTypes.d.ts.map +1 -0
- package/lib/types/api/app-binder/SignBlockSingleCommandTypes.d.ts +5 -0
- package/lib/types/api/app-binder/SignBlockSingleCommandTypes.d.ts.map +1 -0
- package/lib/types/api/index.d.ts +2 -10
- package/lib/types/api/index.d.ts.map +1 -1
- package/lib/types/internal/DefaultLedgerKeyringProtocol.d.ts +9 -12
- package/lib/types/internal/DefaultLedgerKeyringProtocol.d.ts.map +1 -1
- package/lib/types/internal/app-binder/LedgerKeyringProtocolBinder.d.ts +8 -14
- package/lib/types/internal/app-binder/LedgerKeyringProtocolBinder.d.ts.map +1 -1
- package/lib/types/internal/app-binder/command/GetAppNameCommand.d.ts +1 -4
- package/lib/types/internal/app-binder/command/GetAppNameCommand.d.ts.map +1 -1
- package/lib/types/internal/app-binder/command/GetSeedIdCommand.d.ts +1 -13
- package/lib/types/internal/app-binder/command/GetSeedIdCommand.d.ts.map +1 -1
- package/lib/types/internal/app-binder/command/GetVersionCommand.d.ts +1 -2
- package/lib/types/internal/app-binder/command/GetVersionCommand.d.ts.map +1 -1
- package/lib/types/internal/app-binder/command/InitCommand.d.ts +1 -4
- package/lib/types/internal/app-binder/command/InitCommand.d.ts.map +1 -1
- package/lib/types/internal/app-binder/command/ParseBlockSignatureCommand.d.ts +1 -4
- package/lib/types/internal/app-binder/command/ParseBlockSignatureCommand.d.ts.map +1 -1
- package/lib/types/internal/app-binder/command/ParseStreamBlockCommand.d.ts +1 -5
- package/lib/types/internal/app-binder/command/ParseStreamBlockCommand.d.ts.map +1 -1
- package/lib/types/internal/app-binder/command/ParseStreamBlockHeader.d.ts +1 -4
- package/lib/types/internal/app-binder/command/ParseStreamBlockHeader.d.ts.map +1 -1
- package/lib/types/internal/app-binder/command/SetTrustedMemberCommand.d.ts +1 -5
- package/lib/types/internal/app-binder/command/SetTrustedMemberCommand.d.ts.map +1 -1
- package/lib/types/internal/app-binder/command/SignBlockHeader.d.ts +1 -6
- package/lib/types/internal/app-binder/command/SignBlockHeader.d.ts.map +1 -1
- package/lib/types/internal/app-binder/command/SignBlockSignatureCommand.d.ts +1 -5
- package/lib/types/internal/app-binder/command/SignBlockSignatureCommand.d.ts.map +1 -1
- package/lib/types/internal/app-binder/command/SignBlockSingleCommand.d.ts +1 -4
- package/lib/types/internal/app-binder/command/SignBlockSingleCommand.d.ts.map +1 -1
- package/lib/types/internal/app-binder/device-action/AddToTrustchainDeviceAction.d.ts +6 -10
- package/lib/types/internal/app-binder/device-action/AddToTrustchainDeviceAction.d.ts.map +1 -1
- package/lib/types/internal/app-binder/device-action/AuthenticateDeviceAction.d.ts +42 -0
- package/lib/types/internal/app-binder/device-action/AuthenticateDeviceAction.d.ts.map +1 -0
- package/lib/types/internal/app-binder/task/InitTask.d.ts +3 -5
- package/lib/types/internal/app-binder/task/InitTask.d.ts.map +1 -1
- package/lib/types/internal/app-binder/task/ParseStreamToDeviceTask.d.ts +3 -3
- package/lib/types/internal/app-binder/task/ParseStreamToDeviceTask.d.ts.map +1 -1
- package/lib/types/internal/app-binder/task/SignBlockTask.d.ts +13 -15
- package/lib/types/internal/app-binder/task/SignBlockTask.d.ts.map +1 -1
- package/lib/types/internal/app-binder/task/SignChallengeWithKeypairTask.d.ts +5 -6
- package/lib/types/internal/app-binder/task/SignChallengeWithKeypairTask.d.ts.map +1 -1
- package/lib/types/internal/app-binder/task/utils/TrustedProperties.d.ts +2 -2
- package/lib/types/internal/app-binder/task/utils/TrustedProperties.d.ts.map +1 -1
- package/lib/types/internal/di.d.ts +3 -7
- package/lib/types/internal/di.d.ts.map +1 -1
- package/lib/types/internal/externalTypes.d.ts +1 -2
- package/lib/types/internal/externalTypes.d.ts.map +1 -1
- package/lib/types/internal/lkrp-datasource/data/HttpLKRPDataSource.d.ts +10 -8
- package/lib/types/internal/lkrp-datasource/data/HttpLKRPDataSource.d.ts.map +1 -1
- package/lib/types/internal/lkrp-datasource/data/LKRPDataSource.d.ts +8 -8
- package/lib/types/internal/lkrp-datasource/data/LKRPDataSource.d.ts.map +1 -1
- package/lib/types/internal/use-cases/authentication/AuthenticateUseCase.d.ts +2 -15
- package/lib/types/internal/use-cases/authentication/AuthenticateUseCase.d.ts.map +1 -1
- package/lib/types/internal/use-cases/di/useCasesModule.d.ts.map +1 -1
- package/lib/types/internal/use-cases/di/useCasesTypes.d.ts +0 -2
- package/lib/types/internal/use-cases/di/useCasesTypes.d.ts.map +1 -1
- package/lib/types/internal/utils/LKRPBlock.d.ts +2 -2
- package/lib/types/internal/utils/LKRPBlock.d.ts.map +1 -1
- package/lib/types/internal/utils/LKRPBlockStream.d.ts +8 -8
- package/lib/types/internal/utils/LKRPBlockStream.d.ts.map +1 -1
- package/lib/types/internal/utils/LKRPCommand.d.ts +3 -4
- package/lib/types/internal/utils/LKRPCommand.d.ts.map +1 -1
- package/lib/types/internal/utils/TLVBuilder.d.ts +15 -0
- package/lib/types/internal/utils/TLVBuilder.d.ts.map +1 -0
- package/lib/types/internal/utils/TLVParser.d.ts +3 -4
- package/lib/types/internal/utils/TLVParser.d.ts.map +1 -1
- package/lib/types/internal/{models/Tags.d.ts → utils/TLVTags.d.ts} +1 -1
- package/lib/types/internal/utils/TLVTags.d.ts.map +1 -0
- package/lib/types/internal/utils/crypto.d.ts +19 -0
- package/lib/types/internal/utils/crypto.d.ts.map +1 -0
- package/lib/types/internal/utils/hex.d.ts +3 -0
- package/lib/types/internal/utils/hex.d.ts.map +1 -0
- package/lib/types/internal/utils/required.d.ts +1 -1
- package/lib/types/internal/utils/required.d.ts.map +1 -1
- package/lib/types/internal/{models/LKRPCommandTypes.d.ts → utils/types.d.ts} +29 -6
- package/lib/types/internal/utils/types.d.ts.map +1 -0
- package/lib/types/tsconfig.prod.tsbuildinfo +1 -1
- package/package.json +5 -6
- package/lib/cjs/api/crypto/CryptoService.js +0 -2
- package/lib/cjs/api/crypto/CryptoService.js.map +0 -7
- package/lib/cjs/api/crypto/Key.js +0 -2
- package/lib/cjs/api/crypto/Key.js.map +0 -7
- package/lib/cjs/api/crypto/KeyPair.js +0 -2
- package/lib/cjs/api/crypto/KeyPair.js.map +0 -7
- package/lib/cjs/api/crypto/noble/NobleCryptoService.js +0 -2
- package/lib/cjs/api/crypto/noble/NobleCryptoService.js.map +0 -7
- package/lib/cjs/api/crypto/noble/NobleCryptoService.test.js +0 -2
- package/lib/cjs/api/crypto/noble/NobleCryptoService.test.js.map +0 -7
- package/lib/cjs/api/crypto/noble/NobleKey.js +0 -2
- package/lib/cjs/api/crypto/noble/NobleKey.js.map +0 -7
- package/lib/cjs/api/crypto/noble/NobleKey.test.js +0 -2
- package/lib/cjs/api/crypto/noble/NobleKey.test.js.map +0 -7
- package/lib/cjs/api/crypto/noble/NobleKeyPair.js +0 -2
- package/lib/cjs/api/crypto/noble/NobleKeyPair.js.map +0 -7
- package/lib/cjs/api/crypto/noble/NobleKeyPair.test.js +0 -2
- package/lib/cjs/api/crypto/noble/NobleKeyPair.test.js.map +0 -7
- package/lib/cjs/api/model/Env.js +0 -2
- package/lib/cjs/api/model/Env.js.map +0 -7
- package/lib/cjs/api/model/Errors.js +0 -2
- package/lib/cjs/api/model/Errors.js.map +0 -7
- package/lib/cjs/api/model/JWT.js +0 -2
- package/lib/cjs/api/model/JWT.js.map +0 -7
- package/lib/cjs/api/model/Permissions.js +0 -2
- package/lib/cjs/api/model/Permissions.js.map +0 -7
- package/lib/cjs/internal/app-binder/device-action/AuthenticateWithDeviceDeviceAction.js +0 -2
- package/lib/cjs/internal/app-binder/device-action/AuthenticateWithDeviceDeviceAction.js.map +0 -7
- package/lib/cjs/internal/app-binder/device-action/AuthenticateWithKeypairDeviceAction.js +0 -2
- package/lib/cjs/internal/app-binder/device-action/AuthenticateWithKeypairDeviceAction.js.map +0 -7
- package/lib/cjs/internal/app-binder/device-action/models/AuthenticateWithDeviceDeviceActionTypes.js +0 -2
- package/lib/cjs/internal/app-binder/device-action/models/AuthenticateWithDeviceDeviceActionTypes.js.map +0 -7
- package/lib/cjs/internal/app-binder/device-action/models/AuthenticateWithKeypairDeviceActionTypes.js +0 -2
- package/lib/cjs/internal/app-binder/device-action/models/AuthenticateWithKeypairDeviceActionTypes.js.map +0 -7
- package/lib/cjs/internal/app-binder/task/AuthenticateTask.js +0 -2
- package/lib/cjs/internal/app-binder/task/AuthenticateTask.js.map +0 -7
- package/lib/cjs/internal/app-binder/task/ExtractEncryptionKeyTask.js +0 -2
- package/lib/cjs/internal/app-binder/task/ExtractEncryptionKeyTask.js.map +0 -7
- package/lib/cjs/internal/models/LKRPBlockTypes.js +0 -2
- package/lib/cjs/internal/models/LKRPBlockTypes.js.map +0 -7
- package/lib/cjs/internal/models/LKRPCommandTypes.js +0 -2
- package/lib/cjs/internal/models/LKRPCommandTypes.js.map +0 -7
- package/lib/cjs/internal/models/Types.js +0 -2
- package/lib/cjs/internal/models/Types.js.map +0 -7
- package/lib/cjs/internal/use-cases/authentication/DecryptDataUseCase.js +0 -2
- package/lib/cjs/internal/use-cases/authentication/DecryptDataUseCase.js.map +0 -7
- package/lib/cjs/internal/use-cases/authentication/EncryptDataUseCase.js +0 -2
- package/lib/cjs/internal/use-cases/authentication/EncryptDataUseCase.js.map +0 -7
- package/lib/cjs/internal/utils/Trustchain.js +0 -2
- package/lib/cjs/internal/utils/Trustchain.js.map +0 -7
- package/lib/esm/api/crypto/CryptoService.js +0 -2
- package/lib/esm/api/crypto/CryptoService.js.map +0 -7
- package/lib/esm/api/crypto/Key.js +0 -2
- package/lib/esm/api/crypto/Key.js.map +0 -7
- package/lib/esm/api/crypto/KeyPair.js +0 -2
- package/lib/esm/api/crypto/KeyPair.js.map +0 -7
- package/lib/esm/api/crypto/noble/NobleCryptoService.js +0 -2
- package/lib/esm/api/crypto/noble/NobleCryptoService.js.map +0 -7
- package/lib/esm/api/crypto/noble/NobleCryptoService.test.js +0 -2
- package/lib/esm/api/crypto/noble/NobleCryptoService.test.js.map +0 -7
- package/lib/esm/api/crypto/noble/NobleKey.js +0 -2
- package/lib/esm/api/crypto/noble/NobleKey.js.map +0 -7
- package/lib/esm/api/crypto/noble/NobleKey.test.js +0 -2
- package/lib/esm/api/crypto/noble/NobleKey.test.js.map +0 -7
- package/lib/esm/api/crypto/noble/NobleKeyPair.js +0 -2
- package/lib/esm/api/crypto/noble/NobleKeyPair.js.map +0 -7
- package/lib/esm/api/crypto/noble/NobleKeyPair.test.js +0 -2
- package/lib/esm/api/crypto/noble/NobleKeyPair.test.js.map +0 -7
- package/lib/esm/api/model/Env.js +0 -2
- package/lib/esm/api/model/Env.js.map +0 -7
- package/lib/esm/api/model/Errors.js +0 -2
- package/lib/esm/api/model/Errors.js.map +0 -7
- package/lib/esm/api/model/JWT.js +0 -1
- package/lib/esm/api/model/Permissions.js +0 -2
- package/lib/esm/api/model/Permissions.js.map +0 -7
- package/lib/esm/internal/app-binder/device-action/AuthenticateWithDeviceDeviceAction.js +0 -2
- package/lib/esm/internal/app-binder/device-action/AuthenticateWithDeviceDeviceAction.js.map +0 -7
- package/lib/esm/internal/app-binder/device-action/AuthenticateWithKeypairDeviceAction.js +0 -2
- package/lib/esm/internal/app-binder/device-action/AuthenticateWithKeypairDeviceAction.js.map +0 -7
- package/lib/esm/internal/app-binder/device-action/models/AuthenticateWithDeviceDeviceActionTypes.js +0 -1
- package/lib/esm/internal/app-binder/device-action/models/AuthenticateWithKeypairDeviceActionTypes.js +0 -1
- package/lib/esm/internal/app-binder/task/AuthenticateTask.js +0 -2
- package/lib/esm/internal/app-binder/task/AuthenticateTask.js.map +0 -7
- package/lib/esm/internal/app-binder/task/ExtractEncryptionKeyTask.js +0 -2
- package/lib/esm/internal/app-binder/task/ExtractEncryptionKeyTask.js.map +0 -7
- package/lib/esm/internal/models/LKRPBlockTypes.js +0 -1
- package/lib/esm/internal/models/LKRPCommandTypes.js +0 -1
- package/lib/esm/internal/models/Types.js +0 -1
- package/lib/esm/internal/use-cases/authentication/DecryptDataUseCase.js +0 -2
- package/lib/esm/internal/use-cases/authentication/DecryptDataUseCase.js.map +0 -7
- package/lib/esm/internal/use-cases/authentication/EncryptDataUseCase.js +0 -2
- package/lib/esm/internal/use-cases/authentication/EncryptDataUseCase.js.map +0 -7
- package/lib/esm/internal/utils/Trustchain.js +0 -2
- package/lib/esm/internal/utils/Trustchain.js.map +0 -7
- package/lib/types/api/crypto/CryptoService.d.ts +0 -22
- package/lib/types/api/crypto/CryptoService.d.ts.map +0 -1
- package/lib/types/api/crypto/Key.d.ts +0 -7
- package/lib/types/api/crypto/Key.d.ts.map +0 -1
- package/lib/types/api/crypto/KeyPair.d.ts +0 -13
- package/lib/types/api/crypto/KeyPair.d.ts.map +0 -1
- package/lib/types/api/crypto/noble/NobleCryptoService.d.ts +0 -13
- package/lib/types/api/crypto/noble/NobleCryptoService.d.ts.map +0 -1
- package/lib/types/api/crypto/noble/NobleCryptoService.test.d.ts +0 -2
- package/lib/types/api/crypto/noble/NobleCryptoService.test.d.ts.map +0 -1
- package/lib/types/api/crypto/noble/NobleKey.d.ts +0 -11
- package/lib/types/api/crypto/noble/NobleKey.d.ts.map +0 -1
- package/lib/types/api/crypto/noble/NobleKey.test.d.ts +0 -2
- package/lib/types/api/crypto/noble/NobleKey.test.d.ts.map +0 -1
- package/lib/types/api/crypto/noble/NobleKeyPair.d.ts +0 -18
- package/lib/types/api/crypto/noble/NobleKeyPair.d.ts.map +0 -1
- package/lib/types/api/crypto/noble/NobleKeyPair.test.d.ts +0 -2
- package/lib/types/api/crypto/noble/NobleKeyPair.test.d.ts.map +0 -1
- package/lib/types/api/model/Env.d.ts +0 -5
- package/lib/types/api/model/Env.d.ts.map +0 -1
- package/lib/types/api/model/Errors.d.ts +0 -53
- package/lib/types/api/model/Errors.d.ts.map +0 -1
- package/lib/types/api/model/JWT.d.ts +0 -9
- package/lib/types/api/model/JWT.d.ts.map +0 -1
- package/lib/types/api/model/Permissions.d.ts.map +0 -1
- package/lib/types/internal/app-binder/device-action/AuthenticateWithDeviceDeviceAction.d.ts +0 -32
- package/lib/types/internal/app-binder/device-action/AuthenticateWithDeviceDeviceAction.d.ts.map +0 -1
- package/lib/types/internal/app-binder/device-action/AuthenticateWithKeypairDeviceAction.d.ts +0 -33
- package/lib/types/internal/app-binder/device-action/AuthenticateWithKeypairDeviceAction.d.ts.map +0 -1
- package/lib/types/internal/app-binder/device-action/models/AuthenticateWithDeviceDeviceActionTypes.d.ts +0 -22
- package/lib/types/internal/app-binder/device-action/models/AuthenticateWithDeviceDeviceActionTypes.d.ts.map +0 -1
- package/lib/types/internal/app-binder/device-action/models/AuthenticateWithKeypairDeviceActionTypes.d.ts +0 -19
- package/lib/types/internal/app-binder/device-action/models/AuthenticateWithKeypairDeviceActionTypes.d.ts.map +0 -1
- package/lib/types/internal/app-binder/task/AuthenticateTask.d.ts +0 -9
- package/lib/types/internal/app-binder/task/AuthenticateTask.d.ts.map +0 -1
- package/lib/types/internal/app-binder/task/ExtractEncryptionKeyTask.d.ts +0 -8
- package/lib/types/internal/app-binder/task/ExtractEncryptionKeyTask.d.ts.map +0 -1
- package/lib/types/internal/models/LKRPBlockTypes.d.ts +0 -11
- package/lib/types/internal/models/LKRPBlockTypes.d.ts.map +0 -1
- package/lib/types/internal/models/LKRPCommandTypes.d.ts.map +0 -1
- package/lib/types/internal/models/Tags.d.ts.map +0 -1
- package/lib/types/internal/models/Types.d.ts +0 -10
- package/lib/types/internal/models/Types.d.ts.map +0 -1
- package/lib/types/internal/use-cases/authentication/DecryptDataUseCase.d.ts +0 -7
- package/lib/types/internal/use-cases/authentication/DecryptDataUseCase.d.ts.map +0 -1
- package/lib/types/internal/use-cases/authentication/EncryptDataUseCase.d.ts +0 -7
- package/lib/types/internal/use-cases/authentication/EncryptDataUseCase.d.ts.map +0 -1
- package/lib/types/internal/utils/Trustchain.d.ts +0 -14
- package/lib/types/internal/utils/Trustchain.d.ts.map +0 -1
- /package/lib/esm/api/{model/JWT.js.map → app-binder/GetAppNameCommandTypes.js.map} +0 -0
- /package/lib/esm/{internal/app-binder/device-action/models/AuthenticateWithDeviceDeviceActionTypes.js.map → api/app-binder/GetSeedIdCommandTypes.js.map} +0 -0
- /package/lib/esm/{internal/app-binder/device-action/models/AuthenticateWithKeypairDeviceActionTypes.js.map → api/app-binder/InitCommandTypes.js.map} +0 -0
- /package/lib/esm/{internal/models/LKRPBlockTypes.js.map → api/app-binder/ParseStreamBlockCommandCommandTypes.js.map} +0 -0
- /package/lib/esm/{internal/models/LKRPCommandTypes.js.map → api/app-binder/ParseStreamBlockHeaderCommandTypes.js.map} +0 -0
- /package/lib/esm/{internal/models/Types.js.map → api/app-binder/ParseStreamBlockSignatureTypes.js.map} +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{LKRPMissingDataError as s}from"../../../api/app-binder/Errors";import{KeypairFromBytes as f}from"../../../api/app-binder/KeypairFromBytes";import{hexToBytes as b}from"../../utils/hex";import{SignChallengeWithKeypairTask as d}from"./SignChallengeWithKeypairTask";describe("SignChallengeWithKeypairTask",()=>{it("should sign a challenge with a keypair",async()=>{const{challenge:e,keypair:a,trustchainId:c}=i(),n=await new d(a,c).run(e).run();expect(n.isRight()).toBe(!0),n.ifRight(t=>{expect(t.challenge).toBe(e.json),expect(t.signature.credential).toEqual({version:0,curveId:33,signAlgorithm:1,publicKey:a.pubKeyToHex()}),expect(t.signature.attestation).toBe("0242303062373538386231393136633036373635343632656266343530363734346665323565643164623831393635326532646562613732313338393738396364633337"),expect(t.signature.signature).toBe("3045022100e9fead4e341f4e145f8888d7897184ff585e23c832a4c7acd15b5a2e53c58d2902204c58596d039960ab9b56ba4f9d27dbc5e647dbe779089e5e7e608501c5270049")})}),it("should handle invalid challenge",async()=>{const{challenge:e,keypair:a,trustchainId:c}=i({tlv:"invalid-tlv"});(await new d(a,c).run(e).run()).ifLeft(t=>expect(t).toBeInstanceOf(s))})});function i({privateKey:e="b21ef366414b1aaba29b9576b7c1a661d663cfd8b4f998257dddbf7dc60d315d",trustchainId:a="00b7588b1916c06765462ebf4506744fe25ed1db819652e2deba721389789cdc37",tlv:c="0101070201001210bb1ea0c98526e1ea2deb7c7537f2989514010115473045022038632e8fa245483f0ecdbaa4ca0d455a03e7510da269d2089fed0d5cfa69d3d6022100c2f938d60bf1c34e96a2d332822a86059d90ec26ea222189cd9731834a5c151216046878ab74202b7472757374636861696e2d6261636b656e642e6170692e6177732e7374672e6c64672d746563682e636f6d320121332103cb7628e7248ddf9c07da54b979f16bf081fb3d173aac0992ad2a44ef6a388ae2600401000000"}={}){return{challenge:{tlv:c,json:{}},keypair:new f(b(e)),trustchainId:a}}
|
|
2
2
|
//# sourceMappingURL=SignChallengeWithKeypairTask.test.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/internal/app-binder/task/SignChallengeWithKeypairTask.test.ts"],
|
|
4
|
-
"sourcesContent": ["import {
|
|
5
|
-
"mappings": "AAAA,OAAS,
|
|
6
|
-
"names": ["
|
|
4
|
+
"sourcesContent": ["import { LKRPMissingDataError } from \"@api/app-binder/Errors\";\nimport { KeypairFromBytes } from \"@api/app-binder/KeypairFromBytes\";\nimport { type Challenge } from \"@internal/lkrp-datasource/data/LKRPDataSource\";\nimport { hexToBytes } from \"@internal/utils/hex\";\n\nimport { SignChallengeWithKeypairTask } from \"./SignChallengeWithKeypairTask\";\n\ndescribe(\"SignChallengeWithKeypairTask\", () => {\n it(\"should sign a challenge with a keypair\", async () => {\n // GIVEN\n const { challenge, keypair, trustchainId } = getParameters();\n\n // WHEN\n const task = new SignChallengeWithKeypairTask(keypair, trustchainId);\n const result = await task.run(challenge).run();\n\n // THEN\n expect(result.isRight()).toBe(true);\n result.ifRight((payload) => {\n expect(payload.challenge).toBe(challenge.json);\n expect(payload.signature.credential).toEqual({\n version: 0,\n curveId: 33,\n signAlgorithm: 1,\n publicKey: keypair.pubKeyToHex(),\n });\n expect(payload.signature.attestation).toBe(\n \"0242303062373538386231393136633036373635343632656266343530363734346665323565643164623831393635326532646562613732313338393738396364633337\",\n );\n expect(payload.signature.signature).toBe(\n \"3045022100e9fead4e341f4e145f8888d7897184ff585e23c832a4c7acd15b5a2e53c58d2902204c58596d039960ab9b56ba4f9d27dbc5e647dbe779089e5e7e608501c5270049\",\n );\n });\n });\n\n it(\"should handle invalid challenge\", async () => {\n // GIVEN\n const { challenge, keypair, trustchainId } = getParameters({\n tlv: \"invalid-tlv\", // Invalid TLV\n });\n\n // WHEN\n const task = new SignChallengeWithKeypairTask(keypair, trustchainId);\n const result = await task.run(challenge).run();\n\n // THEN\n result.ifLeft((error) =>\n expect(error).toBeInstanceOf(LKRPMissingDataError),\n );\n });\n});\n\nfunction getParameters({\n privateKey = \"b21ef366414b1aaba29b9576b7c1a661d663cfd8b4f998257dddbf7dc60d315d\",\n trustchainId = \"00b7588b1916c06765462ebf4506744fe25ed1db819652e2deba721389789cdc37\",\n tlv = \"0101070201001210bb1ea0c98526e1ea2deb7c7537f2989514010115473045022038632e8fa245483f0ecdbaa4ca0d455a03e7510da269d2089fed0d5cfa69d3d6022100c2f938d60bf1c34e96a2d332822a86059d90ec26ea222189cd9731834a5c151216046878ab74202b7472757374636861696e2d6261636b656e642e6170692e6177732e7374672e6c64672d746563682e636f6d320121332103cb7628e7248ddf9c07da54b979f16bf081fb3d173aac0992ad2a44ef6a388ae2600401000000\",\n} = {}) {\n return {\n challenge: { tlv, json: {} as Challenge[\"json\"] },\n keypair: new KeypairFromBytes(hexToBytes(privateKey)),\n trustchainId,\n };\n}\n"],
|
|
5
|
+
"mappings": "AAAA,OAAS,wBAAAA,MAA4B,yBACrC,OAAS,oBAAAC,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trustchainId", "getParameters", "result", "payload", "error", "privateKey", "tlv"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{ByteArrayParser as a}from"@ledgerhq/device-management-kit";import{Either as p,Left as o,Right as i}from"purify-ts";import{LKRPParsingError as P}from"../../../../api/
|
|
1
|
+
import{ByteArrayParser as a}from"@ledgerhq/device-management-kit";import{Either as p,Left as o,Right as i}from"purify-ts";import{LKRPParsingError as P}from"../../../../api/app-binder/Errors";import{required as e}from"../../../utils/required";import{TPTags as t}from"../../../utils/TLVTags";class h{constructor(r){this.bytes=r;this.parser=new a(r)}parser;iv=null;encryptedProps=null;getIv(){if(!this.iv){const r=this.parser.extractFieldTLVEncoded();if(!r||r.tag!==0)return o(new P("Invalid trusted property: missing IV"));this.iv=r.value}return i(this.iv)}getIssuer(){return this.parseEncryptedProps().chain(r=>e(r.get(t.ISSUER)?.value,"Missing issuer in trusted properties"))}getXPriv(){return this.parseEncryptedProps().chain(r=>e(r.get(t.XPRIV)?.value,"Missing xpriv in trusted properties"))}getEphemeralPublicKey(){return this.parseEncryptedProps().chain(r=>e(r.get(t.EPHEMERAL_PUBLIC_KEY)?.value,"Missing ephemeral public key in trusted properties"))}getCommandIv(){return this.parseEncryptedProps().chain(r=>e(r.get(t.COMMAND_IV)?.value,"Missing command IV in trusted properties"))}getGroupKey(){return this.parseEncryptedProps().chain(r=>e(r.get(t.GROUPKEY)?.value,"Missing group key in trusted properties"))}getNewMember(){return this.parseEncryptedProps().chain(r=>e(r.get(t.NEW_MEMBER)?.tlv,"Missing new member in trusted properties"))}parseEncryptedProps(){return this.encryptedProps?i(this.encryptedProps):this.getIv().chain(()=>p.sequence(Array.from(E(this.parser)))).map(r=>new Map(r.map(n=>[n.tag,n]))).ifRight(r=>{this.encryptedProps=r})}}function*E(s){for(;;){const r=s.extractFieldTLVEncoded();if(!r)return;yield i(r)}}export{h as TrustedProperties};
|
|
2
2
|
//# sourceMappingURL=TrustedProperties.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/internal/app-binder/task/utils/TrustedProperties.ts"],
|
|
4
|
-
"sourcesContent": ["import { ByteArrayParser } from \"@ledgerhq/device-management-kit\";\nimport { Either, Left, Right } from \"purify-ts\";\n\nimport {
|
|
5
|
-
"mappings": "AAAA,OAAS,mBAAAA,MAAuB,kCAChC,OAAS,UAAAC,EAAQ,QAAAC,EAAM,SAAAC,MAAa,YAEpC,
|
|
6
|
-
"names": ["ByteArrayParser", "Either", "Left", "Right", "LKRPParsingError", "
|
|
4
|
+
"sourcesContent": ["import { ByteArrayParser } from \"@ledgerhq/device-management-kit\";\nimport { Either, Left, Right } from \"purify-ts\";\n\nimport {\n type LKRPMissingDataError,\n LKRPParsingError,\n} from \"@api/app-binder/Errors\";\nimport { required } from \"@internal/utils/required\";\nimport { TPTags } from \"@internal/utils/TLVTags\";\n\ntype EncryptedTPTag = Exclude<TPTags, TPTags.IV>;\ntype EncryptedTP = { tag: EncryptedTPTag; value: Uint8Array; tlv: Uint8Array };\n\nexport class TrustedProperties {\n private readonly parser: ByteArrayParser;\n private iv: Uint8Array | null = null;\n private encryptedProps: Map<EncryptedTPTag, EncryptedTP> | null = null;\n\n constructor(public readonly bytes: Uint8Array) {\n this.parser = new ByteArrayParser(bytes);\n }\n\n getIv(): Either<LKRPParsingError, Uint8Array> {\n if (!this.iv) {\n const field = this.parser.extractFieldTLVEncoded();\n if (!field || field.tag !== 0x00) {\n return Left(\n new LKRPParsingError(\"Invalid trusted property: missing IV\"),\n );\n }\n\n this.iv = field.value;\n }\n return Right(this.iv);\n }\n\n getIssuer(): Either<LKRPParsingError | LKRPMissingDataError, Uint8Array> {\n return this.parseEncryptedProps().chain((props) =>\n required(\n props.get(TPTags.ISSUER)?.value,\n \"Missing issuer in trusted properties\",\n ),\n );\n }\n\n getXPriv(): Either<LKRPParsingError | LKRPMissingDataError, Uint8Array> {\n return this.parseEncryptedProps().chain((props) =>\n required(\n props.get(TPTags.XPRIV)?.value,\n \"Missing xpriv in trusted properties\",\n ),\n );\n }\n\n getEphemeralPublicKey(): Either<\n LKRPParsingError | LKRPMissingDataError,\n Uint8Array\n > {\n return this.parseEncryptedProps().chain((props) =>\n required(\n props.get(TPTags.EPHEMERAL_PUBLIC_KEY)?.value,\n \"Missing ephemeral public key in trusted properties\",\n ),\n );\n }\n\n getCommandIv(): Either<LKRPParsingError | LKRPMissingDataError, Uint8Array> {\n return this.parseEncryptedProps().chain((props) =>\n required(\n props.get(TPTags.COMMAND_IV)?.value,\n \"Missing command IV in trusted properties\",\n ),\n );\n }\n\n getGroupKey(): Either<LKRPParsingError | LKRPMissingDataError, Uint8Array> {\n return this.parseEncryptedProps().chain((props) =>\n required(\n props.get(TPTags.GROUPKEY)?.value,\n \"Missing group key in trusted properties\",\n ),\n );\n }\n\n getNewMember(): Either<LKRPParsingError | LKRPMissingDataError, Uint8Array> {\n return this.parseEncryptedProps().chain((props) =>\n required(\n props.get(TPTags.NEW_MEMBER)?.tlv,\n \"Missing new member in trusted properties\",\n ),\n );\n }\n\n parseEncryptedProps(): Either<\n LKRPParsingError,\n Map<EncryptedTPTag, EncryptedTP>\n > {\n return this.encryptedProps\n ? Right(this.encryptedProps)\n : this.getIv()\n .chain(() => Either.sequence(Array.from(parseTPs(this.parser))))\n .map((fields) => new Map(fields.map((field) => [field.tag, field])))\n .ifRight((props) => {\n this.encryptedProps = props;\n });\n }\n}\n\nfunction* parseTPs(\n parser: ByteArrayParser,\n): Generator<Either<LKRPParsingError, EncryptedTP>> {\n while (true) {\n const field = parser.extractFieldTLVEncoded();\n if (!field) return;\n yield Right(field);\n }\n}\n"],
|
|
5
|
+
"mappings": "AAAA,OAAS,mBAAAA,MAAuB,kCAChC,OAAS,UAAAC,EAAQ,QAAAC,EAAM,SAAAC,MAAa,YAEpC,OAEE,oBAAAC,MACK,yBACP,OAAS,YAAAC,MAAgB,2BACzB,OAAS,UAAAC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,EAAS,KAAK,MAAM,CAAC,CAAC,CAAC,EAC9D,IAAKC,GAAW,IAAI,IAAIA,EAAO,IAAKH,GAAU,CAACA,EAAM,IAAKA,CAAK,CAAC,CAAC,CAAC,EAClE,QAASC,GAAU,CAClB,KAAK,eAAiBA,CACxB,CAAC,CACT,CACF,CAEA,SAAUC,EACRE,EACkD,CAClD,OAAa,CACX,MAAMJ,EAAQI,EAAO,uBAAuB,EAC5C,GAAI,CAACJ,EAAO,OACZ,MAAMN,EAAMM,CAAK,CACnB,CACF",
|
|
6
|
+
"names": ["ByteArrayParser", "Either", "Left", "Right", "LKRPParsingError", "required", "TPTags", "TrustedProperties", "bytes", "field", "props", "parseTPs", "fields", "parser"]
|
|
7
7
|
}
|
package/lib/esm/internal/di.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{Container as
|
|
1
|
+
import{Container as a}from"inversify";import{appBindingModuleFactory as s}from"./app-binder/di/appBinderModule";import{lkrpDatasourceModuleFactory as m}from"./lkrp-datasource/di/lkrpDatasourceModuleFactory";import{useCasesModuleFactory as p}from"./use-cases/di/useCasesModule";import{externalTypes as o}from"./externalTypes";const D=({dmk:t,sessionId:n,baseUrl:r,stub:i})=>{const e=new a;return e.bind(o.Dmk).toConstantValue(t),e.bind(o.SessionId).toConstantValue(n),e.loadSync(s(),m({baseUrl:r,stub:i}),p()),e};export{D as makeContainer};
|
|
2
2
|
//# sourceMappingURL=di.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/internal/di.ts"],
|
|
4
|
-
"sourcesContent": ["import {
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": ["Container", "
|
|
4
|
+
"sourcesContent": ["import {\n type DeviceManagementKit,\n type DeviceSessionId,\n} from \"@ledgerhq/device-management-kit\";\nimport { Container } from \"inversify\";\n\nimport { appBindingModuleFactory } from \"@internal/app-binder/di/appBinderModule\";\n\nimport { lkrpDatasourceModuleFactory } from \"./lkrp-datasource/di/lkrpDatasourceModuleFactory\";\nimport { useCasesModuleFactory } from \"./use-cases/di/useCasesModule\";\nimport { externalTypes } from \"./externalTypes\";\n\nexport type MakeContainerProps = {\n dmk: DeviceManagementKit;\n sessionId: DeviceSessionId;\n baseUrl?: string; // Optional base URL for the LKRP network requests\n stub?: boolean;\n};\n\nexport const makeContainer = ({\n dmk,\n sessionId,\n baseUrl,\n stub,\n}: MakeContainerProps) => {\n const container = new Container();\n\n container.bind<DeviceManagementKit>(externalTypes.Dmk).toConstantValue(dmk);\n container\n .bind<DeviceSessionId>(externalTypes.SessionId)\n .toConstantValue(sessionId);\n\n container.loadSync(\n appBindingModuleFactory(),\n lkrpDatasourceModuleFactory({ baseUrl, stub }),\n useCasesModuleFactory(),\n );\n\n return container;\n};\n"],
|
|
5
|
+
"mappings": "AAIA,OAAS,aAAAA,MAAiB,YAE1B,OAAS,2BAAAC,MAA+B,0CAExC,OAAS,+BAAAC,MAAmC,mDAC5C,OAAS,yBAAAC,MAA6B,gCACtC,OAAS,iBAAAC,MAAqB,kBASvB,MAAMC,EAAgB,CAAC,CAC5B,IAAAC,EACA,UAAAC,EACA,QAAAC,EACA,KAAAC,CACF,IAA0B,CACxB,MAAMC,EAAY,IAAIV,EAEtB,OAAAU,EAAU,KAA0BN,EAAc,GAAG,EAAE,gBAAgBE,CAAG,EAC1EI,EACG,KAAsBN,EAAc,SAAS,EAC7C,gBAAgBG,CAAS,EAE5BG,EAAU,SACRT,EAAwB,EACxBC,EAA4B,CAAE,QAAAM,EAAS,KAAAC,CAAK,CAAC,EAC7CN,EAAsB,CACxB,EAEOO,CACT",
|
|
6
|
+
"names": ["Container", "appBindingModuleFactory", "lkrpDatasourceModuleFactory", "useCasesModuleFactory", "externalTypes", "makeContainer", "dmk", "sessionId", "baseUrl", "stub", "container"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const r={Dmk:Symbol.for("Dmk"),
|
|
1
|
+
const r={Dmk:Symbol.for("Dmk"),SessionId:Symbol.for("SessionId")};export{r as externalTypes};
|
|
2
2
|
//# sourceMappingURL=externalTypes.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/internal/externalTypes.ts"],
|
|
4
|
-
"sourcesContent": ["export const externalTypes = {\n Dmk: Symbol.for(\"Dmk\"),\n
|
|
5
|
-
"mappings": "AAAO,MAAMA,EAAgB,CAC3B,IAAK,OAAO,IAAI,KAAK,EACrB,
|
|
4
|
+
"sourcesContent": ["export const externalTypes = {\n Dmk: Symbol.for(\"Dmk\"),\n SessionId: Symbol.for(\"SessionId\"),\n};\n\nexport type TrustedProperty = {\n iv: Uint8Array;\n issuer: Uint8Array;\n xpriv: Uint8Array;\n ephemeralPubKey: Uint8Array;\n commandIV: Uint8Array;\n groupKey: Uint8Array;\n newMember: Uint8Array;\n};\n"],
|
|
5
|
+
"mappings": "AAAO,MAAMA,EAAgB,CAC3B,IAAK,OAAO,IAAI,KAAK,EACrB,UAAW,OAAO,IAAI,WAAW,CACnC",
|
|
6
6
|
"names": ["externalTypes"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var d=Object.defineProperty;var
|
|
1
|
+
var d=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var m=(n,t,e,r)=>{for(var i=r>1?void 0:r?f(t,e):t,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(r?o(t,e,i):o(i))||i);return r&&i&&d(t,e,i),i},c=(n,t)=>(e,r)=>t(e,r,n);import{inject as g,injectable as y}from"inversify";import{EitherAsync as R,Just as u,Maybe as b,Nothing as l,Right as p}from"purify-ts";import{LKRPHttpRequestError as h,LKRPUnauthorizedError as T}from"../../../api/app-binder/Errors";import{lkrpDatasourceTypes as P}from"../../lkrp-datasource/di/lkrpDatasourceTypes";import{LKRPBlockStream as $}from"../../utils/LKRPBlockStream";let a=class{constructor(t){this.baseUrl=t}getChallenge(){return this.request("/challenge",l)}authenticate(t){return this.request("/authenticate",l,{method:"POST",body:JSON.stringify(t)}).map(e=>({jwt:e,trustchainId:b.fromNullable(Object.keys(e.permissions).find(r=>!!e.permissions[r]?.["m/"]))}))}getTrustchainById(t,e){return this.request(`/trustchain/${t}`,u(e)).map(r=>Object.fromEntries(Object.entries(r).map(([i,s])=>[i,$.fromHex(s)])))}postDerivation(t,e,r){return this.request(`/trustchain/${t}/derivation`,u(r),{method:"POST",body:JSON.stringify(e.toString())})}putCommands(t,e,r,i){return this.request(`/trustchain/${t}/commands`,u(i),{method:"PUT",body:JSON.stringify({path:e,blocks:[r.toString()]})})}request(t,e,r){const i=this.baseUrl+t;return R.fromPromise(async()=>{const s=await fetch(i,{...r,headers:{...r?.headers,"Content-Type":"application/json",...e.mapOrDefault(({access_token:o})=>({Authorization:`Bearer ${o}`}),{})}});switch(s.status){case 204:return p(void 0);case 401:throw new T(`Unauthorized request to ${i}: [${s.status}] ${s.statusText}`);default:if(!s.ok)throw new h(`Failed to fetch ${i}: [${s.status}] ${s.statusText}`);return p(await s.json())}}).mapLeft(s=>s instanceof h?s:new h(s))}};a=m([y(),c(0,g(P.BaseUrl))],a);export{a as HttpLKRPDataSource};
|
|
2
2
|
//# sourceMappingURL=HttpLKRPDataSource.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/internal/lkrp-datasource/data/HttpLKRPDataSource.ts"],
|
|
4
|
-
"sourcesContent": ["import { inject, injectable } from \"inversify\";\nimport { EitherAsync, Just,
|
|
5
|
-
"mappings": "iOAAA,OAAS,UAAAA,EAAQ,cAAAC,MAAkB,YACnC,OAAS,eAAAC,EAAa,QAAAC,EAAM,
|
|
6
|
-
"names": ["inject", "injectable", "EitherAsync", "Just", "
|
|
4
|
+
"sourcesContent": ["import { inject, injectable } from \"inversify\";\nimport { EitherAsync, Just, Maybe, Nothing, Right } from \"purify-ts\";\n\nimport {\n LKRPHttpRequestError,\n LKRPUnauthorizedError,\n} from \"@api/app-binder/Errors\";\nimport { JWT } from \"@api/app-binder/LKRPTypes\";\nimport { lkrpDatasourceTypes } from \"@internal/lkrp-datasource/di/lkrpDatasourceTypes\";\nimport { LKRPBlock } from \"@internal/utils/LKRPBlock\";\nimport { LKRPBlockStream } from \"@internal/utils/LKRPBlockStream\";\n\nimport {\n AuthenticationPayload,\n Challenge,\n LKRPDataSource,\n} from \"./LKRPDataSource\";\n\n@injectable()\nexport class HttpLKRPDataSource implements LKRPDataSource {\n constructor(\n @inject(lkrpDatasourceTypes.BaseUrl) private readonly baseUrl: string,\n ) {}\n\n getChallenge() {\n return this.request<Challenge>(\"/challenge\", Nothing);\n }\n\n authenticate(payload: AuthenticationPayload) {\n return this.request<JWT>(\"/authenticate\", Nothing, {\n method: \"POST\",\n body: JSON.stringify(payload),\n }).map((jwt) => ({\n jwt,\n trustchainId: Maybe.fromNullable(\n Object.keys(jwt.permissions).find((id) =>\n Boolean(jwt.permissions[id]?.[\"m/\"]),\n ),\n ),\n }));\n }\n\n getTrustchainById(id: string, jwt: JWT) {\n return this.request<{ [path: string]: string }>(\n `/trustchain/${id}`,\n Just(jwt),\n ).map((serialized) =>\n Object.fromEntries(\n Object.entries(serialized).map(([path, stream]) => [\n path,\n LKRPBlockStream.fromHex(stream),\n ]),\n ),\n );\n }\n\n postDerivation(id: string, block: LKRPBlock, jwt: JWT) {\n return this.request<void>(`/trustchain/${id}/derivation`, Just(jwt), {\n method: \"POST\",\n body: JSON.stringify(block.toString()),\n });\n }\n\n putCommands(id: string, path: string, block: LKRPBlock, jwt: JWT) {\n return this.request<void>(`/trustchain/${id}/commands`, Just(jwt), {\n method: \"PUT\",\n body: JSON.stringify({ path, blocks: [block.toString()] }),\n });\n }\n\n private request<Res>(\n endpoint: `/${string}`,\n jwt: Maybe<{ access_token: string }>,\n init?: RequestInit,\n ): EitherAsync<LKRPHttpRequestError, Res> {\n const href = this.baseUrl + endpoint;\n\n return EitherAsync.fromPromise(async () => {\n const response = await fetch(href, {\n ...init,\n headers: {\n ...init?.headers,\n \"Content-Type\": \"application/json\",\n ...jwt.mapOrDefault<{ Authorization?: string }>(\n ({ access_token }) => ({ Authorization: `Bearer ${access_token}` }),\n {},\n ),\n },\n });\n switch (response.status) {\n case 204:\n return Right(undefined as Res);\n\n case 401:\n throw new LKRPUnauthorizedError(\n `Unauthorized request to ${href}: [${response.status}] ${response.statusText}`,\n );\n\n default:\n if (!response.ok) {\n throw new LKRPHttpRequestError(\n `Failed to fetch ${href}: [${response.status}] ${response.statusText}`,\n );\n }\n return Right((await response.json()) as Res);\n }\n }).mapLeft((error: unknown) =>\n error instanceof LKRPHttpRequestError\n ? error\n : new LKRPHttpRequestError(error),\n );\n }\n}\n"],
|
|
5
|
+
"mappings": "iOAAA,OAAS,UAAAA,EAAQ,cAAAC,MAAkB,YACnC,OAAS,eAAAC,EAAa,QAAAC,EAAM,SAAAC,EAAO,WAAAC,EAAS,SAAAC,MAAa,YAEzD,OACE,wBAAAC,EACA,yBAAAC,MACK,yBAEP,OAAS,uBAAAC,MAA2B,mDAEpC,OAAS,mBAAAC,MAAuB,kCASzB,IAAMC,EAAN,KAAmD,CACxD,YACwDC,EACtD,CADsD,aAAAA,CACrD,CAEH,cAAe,CACb,OAAO,KAAK,QAAmB,aAAcC,CAAO,CACtD,CAEA,aAAaC,EAAgC,CAC3C,OAAO,KAAK,QAAa,gBAAiBD,EAAS,CACjD,OAAQ,OACR,KAAM,KAAK,UAAUC,CAAO,CAC9B,CAAC,EAAE,IAAKC,IAAS,CACf,IAAAA,EACA,aAAcC,EAAM,aAClB,OAAO,KAAKD,EAAI,WAAW,EAAE,KAAME,GACjC,EAAQF,EAAI,YAAYE,CAAE,IAAI,IAAI,CACpC,CACF,CACF,EAAE,CACJ,CAEA,kBAAkBA,EAAYF,EAAU,CACtC,OAAO,KAAK,QACV,eAAeE,CAAE,GACjBC,EAAK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C,EACA,IAAID,EAAqBC,CAAK,CACpC,CACF,CACF,EA7FatB,EAANuB,EAAA,CADNC,EAAW,EAGPC,EAAA,EAAAC,EAAOC,EAAoB,OAAO,IAF1B3B",
|
|
6
|
+
"names": ["inject", "injectable", "EitherAsync", "Just", "Maybe", "Nothing", "Right", "LKRPHttpRequestError", "LKRPUnauthorizedError", "lkrpDatasourceTypes", "LKRPBlockStream", "HttpLKRPDataSource", "baseUrl", "Nothing", "payload", "jwt", "Maybe", "id", "Just", "serialized", "path", "stream", "LKRPBlockStream", "block", "endpoint", "init", "href", "EitherAsync", "response", "access_token", "Right", "LKRPUnauthorizedError", "LKRPHttpRequestError", "error", "__decorateClass", "injectable", "__decorateParam", "inject", "lkrpDatasourceTypes"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{Just as
|
|
1
|
+
import{Just as b,Left as d,Nothing as S,Right as r}from"purify-ts";import{LKRPHttpRequestError as h,LKRPUnauthorizedError as T}from"../../../api/app-binder/Errors";import{LKRPBlock as m}from"../../utils/LKRPBlock";import{LKRPBlockStream as p}from"../../utils/LKRPBlockStream";import{HttpLKRPDataSource as c}from"./HttpLKRPDataSource";const n={access_token:"ACCESS TOKEN",permissions:{TRUSTCHAIN_ID:{"m/":["owner"]}}},i={version:0,challenge:{data:"1010101010010101010",expiry:"2025-06-30T10:00:00Z"},host:"example.com",rp:[{credential:{version:0,curveId:33,signAlgorithm:1,publicKey:"aaaaaaaaaaaaaaaaaaaaaaaaaa"},signature:"abababababababab"}],protocolVersion:{major:1,minor:0,patch:0}},u={credential:{version:0,curveId:33,signAlgorithm:1,publicKey:"bbbbbbbbbbbbbbbbbbbbbbbbbbb"},signature:"acacacacacacacac",attestation:"0000000000000000"};describe("HttpLKRPDataSource",()=>{const a=vi.spyOn(global,"fetch"),t="https://example.com";afterEach(()=>{a.mockClear()}),describe("getChallenge",()=>{it("should fetch challenge successfully",async()=>{const e={tlv:"0f1234567890",json:i};a.mockResolvedValueOnce({ok:!0,json:()=>Promise.resolve(e)});const s=await new c(t).getChallenge();expect(a).toHaveBeenCalledWith(`${t}/challenge`,{headers:{"Content-Type":"application/json"}}),expect(s).toEqual(r(e))}),it("should handle fetch error",async()=>{const e=new Error("Random error");a.mockRejectedValueOnce(e);const s=await new c(t).getChallenge();expect(s).toEqual(d(new h(e)))})}),describe("authenticate",()=>{it("should fetch a JWT when the authentication is successful",async()=>{a.mockResolvedValueOnce({ok:!0,json:()=>Promise.resolve(n)});const o=await new c(t).authenticate({challenge:i,signature:u});expect(a).toHaveBeenCalledWith(`${t}/authenticate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({challenge:i,signature:u})}),expect(o).toEqual(r({jwt:n,trustchainId:b("TRUSTCHAIN_ID")}))}),it("should return no trustchainId the returned JWT does not contain one",async()=>{const e={access_token:"ACCESS TOKEN",permissions:{}};a.mockResolvedValueOnce({ok:!0,json:()=>Promise.resolve(e)});const s=await new c(t).authenticate({challenge:i,signature:u});expect(s).toEqual(r({jwt:e,trustchainId:S}))}),it("should handle authentication error",async()=>{a.mockResolvedValueOnce({ok:!1,status:401,statusText:"Unauthorized"});const o=await new c(t).authenticate({challenge:i,signature:u});expect(o).toEqual(d(new T(`Unauthorized request to ${t}/authenticate: [401] Unauthorized`)))})}),describe("getTrustchainById",()=>{it("should fetch trustchain by ID successfully",async()=>{const e={"m/":"0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1e1d","m/16'":"1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b"};a.mockResolvedValueOnce({ok:!0,json:()=>Promise.resolve(e)});const s=await new c(t).getTrustchainById("TRUSTCHAIN_ID",n);expect(a).toHaveBeenCalledWith(`${t}/trustchain/TRUSTCHAIN_ID`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${n.access_token}`}}),expect(s).toEqual(r({"m/":p.fromHex("0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1e1d"),"m/16'":p.fromHex("1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b")}))}),it("should handle errors",async()=>{a.mockResolvedValueOnce({ok:!1,status:500,statusText:"Internal Server Error"});const o=await new c(t).getTrustchainById("TRUSTCHAIN_ID",n);expect(o).toEqual(d(new h(`Failed to fetch ${t}/trustchain/TRUSTCHAIN_ID: [500] Internal Server Error`)))})}),describe("postDerivation",()=>{it("should post derivation successfully",async()=>{const e="0102030405060708090a0b0c0d0e0f",o=m.fromHex(e);a.mockResolvedValueOnce({ok:!0,status:204});const l=await new c(t).postDerivation("TRUSTCHAIN_ID",o,n);expect(a).toHaveBeenCalledWith(`${t}/trustchain/TRUSTCHAIN_ID/derivation`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n.access_token}`},body:JSON.stringify(e)}),expect(l).toEqual(r(void 0))})}),describe("putCommands",()=>{it("should put commands successfully",async()=>{const e="0102030405060708090a0b0c0d0e0f",o=m.fromHex(e);a.mockResolvedValueOnce({ok:!0,status:204});const l=await new c(t).putCommands("TRUSTCHAIN_ID","m/0'/16'/0'",o,n);expect(a).toHaveBeenCalledWith(`${t}/trustchain/TRUSTCHAIN_ID/commands`,{method:"PUT",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n.access_token}`},body:JSON.stringify({path:"m/0'/16'/0'",blocks:[e]})}),expect(l).toEqual(r(void 0))})})});
|
|
2
2
|
//# sourceMappingURL=HttpLKRPDataSource.test.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/internal/lkrp-datasource/data/HttpLKRPDataSource.test.ts"],
|
|
4
|
-
"sourcesContent": ["import { Just, Left, Nothing, Right } from \"purify-ts\";\n\nimport {
|
|
5
|
-
"mappings": "AAAA,OAAS,QAAAA,EAAM,QAAAC,EAAM,WAAAC,EAAS,SAAAC,MAAa,YAE3C,
|
|
6
|
-
"names": ["Just", "Left", "Nothing", "Right", "
|
|
4
|
+
"sourcesContent": ["import { Just, Left, Nothing, Right } from \"purify-ts\";\n\nimport {\n LKRPHttpRequestError,\n LKRPUnauthorizedError,\n} from \"@api/app-binder/Errors\";\nimport { LKRPBlock } from \"@internal/utils/LKRPBlock\";\nimport { LKRPBlockStream } from \"@internal/utils/LKRPBlockStream\";\n\nimport { HttpLKRPDataSource } from \"./HttpLKRPDataSource\";\n\nconst mockJwt = {\n access_token: \"ACCESS TOKEN\",\n permissions: { TRUSTCHAIN_ID: { \"m/\": [\"owner\"] } },\n};\n\nconst mockChallengeJSON = {\n version: 0,\n challenge: {\n data: \"1010101010010101010\",\n expiry: \"2025-06-30T10:00:00Z\",\n },\n host: \"example.com\",\n rp: [\n {\n credential: {\n version: 0,\n curveId: 33,\n signAlgorithm: 1,\n publicKey: \"aaaaaaaaaaaaaaaaaaaaaaaaaa\",\n },\n signature: \"abababababababab\",\n },\n ],\n protocolVersion: { major: 1, minor: 0, patch: 0 },\n};\n\nconst mockSignature = {\n credential: {\n version: 0,\n curveId: 33,\n signAlgorithm: 1,\n publicKey: \"bbbbbbbbbbbbbbbbbbbbbbbbbbb\",\n },\n signature: \"acacacacacacacac\",\n attestation: \"0000000000000000\",\n};\n\ndescribe(\"HttpLKRPDataSource\", () => {\n const fetchSpy = vi.spyOn(global, \"fetch\");\n const baseUrl = \"https://example.com\";\n\n afterEach(() => {\n fetchSpy.mockClear();\n });\n\n describe(\"getChallenge\", () => {\n it(\"should fetch challenge successfully\", async () => {\n // GIVEN\n const mockChallenge = {\n tlv: \"0f1234567890\",\n json: mockChallengeJSON,\n };\n\n fetchSpy.mockResolvedValueOnce({\n ok: true,\n json: () => Promise.resolve(mockChallenge),\n } as Response);\n\n // WHEN\n const dataSource = new HttpLKRPDataSource(baseUrl);\n const result = await dataSource.getChallenge();\n expect(fetchSpy).toHaveBeenCalledWith(`${baseUrl}/challenge`, {\n headers: {\n \"Content-Type\": \"application/json\",\n },\n });\n\n // THEN\n expect(result).toEqual(Right(mockChallenge));\n });\n\n it(\"should handle fetch error\", async () => {\n // GIVEN\n const error = new Error(\"Random error\");\n fetchSpy.mockRejectedValueOnce(error);\n\n // WHEN\n const dataSource = new HttpLKRPDataSource(baseUrl);\n const result = await dataSource.getChallenge();\n\n // THEN\n expect(result).toEqual(Left(new LKRPHttpRequestError(error)));\n });\n });\n\n describe(\"authenticate\", () => {\n it(\"should fetch a JWT when the authentication is successful\", async () => {\n // GIVEN\n fetchSpy.mockResolvedValueOnce({\n ok: true,\n json: () => Promise.resolve(mockJwt),\n } as Response);\n\n // WHEN\n const dataSource = new HttpLKRPDataSource(baseUrl);\n const result = await dataSource.authenticate({\n challenge: mockChallengeJSON,\n signature: mockSignature,\n });\n\n // THEN\n expect(fetchSpy).toHaveBeenCalledWith(`${baseUrl}/authenticate`, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify({\n challenge: mockChallengeJSON,\n signature: mockSignature,\n }),\n });\n expect(result).toEqual(\n Right({ jwt: mockJwt, trustchainId: Just(\"TRUSTCHAIN_ID\") }),\n );\n });\n\n it(\"should return no trustchainId the returned JWT does not contain one\", async () => {\n // GIVEN\n const jwtWithoutTrustchainId = {\n access_token: \"ACCESS TOKEN\",\n permissions: {},\n };\n fetchSpy.mockResolvedValueOnce({\n ok: true,\n json: () => Promise.resolve(jwtWithoutTrustchainId),\n } as Response);\n\n // WHEN\n const dataSource = new HttpLKRPDataSource(baseUrl);\n const result = await dataSource.authenticate({\n challenge: mockChallengeJSON,\n signature: mockSignature,\n });\n\n // THEN\n expect(result).toEqual(\n Right({ jwt: jwtWithoutTrustchainId, trustchainId: Nothing }),\n );\n });\n\n it(\"should handle authentication error\", async () => {\n // GIVEN\n fetchSpy.mockResolvedValueOnce({\n ok: false,\n status: 401,\n statusText: \"Unauthorized\",\n } as Response);\n\n // WHEN\n const dataSource = new HttpLKRPDataSource(baseUrl);\n const result = await dataSource.authenticate({\n challenge: mockChallengeJSON,\n signature: mockSignature,\n });\n\n // THEN\n expect(result).toEqual(\n Left(\n new LKRPUnauthorizedError(\n `Unauthorized request to ${baseUrl}/authenticate: [401] Unauthorized`,\n ),\n ),\n );\n });\n });\n\n describe(\"getTrustchainById\", () => {\n it(\"should fetch trustchain by ID successfully\", async () => {\n // GIVEN\n const mockTrustchain = {\n \"m/\": \"0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1e1d\",\n \"m/16'\": \"1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b\",\n };\n fetchSpy.mockResolvedValueOnce({\n ok: true,\n json: () => Promise.resolve(mockTrustchain),\n } as Response);\n\n // WHEN\n const dataSource = new HttpLKRPDataSource(baseUrl);\n const result = await dataSource.getTrustchainById(\n \"TRUSTCHAIN_ID\",\n mockJwt,\n );\n\n // THEN\n expect(fetchSpy).toHaveBeenCalledWith(\n `${baseUrl}/trustchain/TRUSTCHAIN_ID`,\n {\n headers: {\n \"Content-Type\": \"application/json\",\n Authorization: `Bearer ${mockJwt.access_token}`,\n },\n },\n );\n expect(result).toEqual(\n Right({\n \"m/\": LKRPBlockStream.fromHex(\n \"0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1e1d\",\n ),\n \"m/16'\": LKRPBlockStream.fromHex(\n \"1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b\",\n ),\n }),\n );\n });\n\n it(\"should handle errors\", async () => {\n // GIVEN\n fetchSpy.mockResolvedValueOnce({\n ok: false,\n status: 500,\n statusText: \"Internal Server Error\",\n } as Response);\n\n // WHEN\n const dataSource = new HttpLKRPDataSource(baseUrl);\n const result = await dataSource.getTrustchainById(\n \"TRUSTCHAIN_ID\",\n mockJwt,\n );\n\n // THEN\n expect(result).toEqual(\n Left(\n new LKRPHttpRequestError(\n `Failed to fetch ${baseUrl}/trustchain/TRUSTCHAIN_ID: [500] Internal Server Error`,\n ),\n ),\n );\n });\n });\n\n describe(\"postDerivation\", () => {\n it(\"should post derivation successfully\", async () => {\n // GIVEN\n const hex = \"0102030405060708090a0b0c0d0e0f\";\n const mockBlock = LKRPBlock.fromHex(hex);\n fetchSpy.mockResolvedValueOnce({\n ok: true,\n status: 204,\n } as Response);\n\n // WHEN\n const dataSource = new HttpLKRPDataSource(baseUrl);\n const result = await dataSource.postDerivation(\n \"TRUSTCHAIN_ID\",\n mockBlock,\n mockJwt,\n );\n\n // THEN\n expect(fetchSpy).toHaveBeenCalledWith(\n `${baseUrl}/trustchain/TRUSTCHAIN_ID/derivation`,\n {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n Authorization: `Bearer ${mockJwt.access_token}`,\n },\n body: JSON.stringify(hex),\n },\n );\n expect(result).toEqual(Right(undefined));\n });\n });\n\n describe(\"putCommands\", () => {\n it(\"should put commands successfully\", async () => {\n // GIVEN\n const hex = \"0102030405060708090a0b0c0d0e0f\";\n const mockBlock = LKRPBlock.fromHex(hex);\n fetchSpy.mockResolvedValueOnce({\n ok: true,\n status: 204,\n } as Response);\n\n // WHEN\n const dataSource = new HttpLKRPDataSource(baseUrl);\n const result = await dataSource.putCommands(\n \"TRUSTCHAIN_ID\",\n \"m/0'/16'/0'\",\n mockBlock,\n mockJwt,\n );\n\n // THEN\n expect(fetchSpy).toHaveBeenCalledWith(\n `${baseUrl}/trustchain/TRUSTCHAIN_ID/commands`,\n {\n method: \"PUT\",\n headers: {\n \"Content-Type\": \"application/json\",\n Authorization: `Bearer ${mockJwt.access_token}`,\n },\n body: JSON.stringify({ path: \"m/0'/16'/0'\", blocks: [hex] }),\n },\n );\n expect(result).toEqual(Right(undefined));\n });\n });\n});\n"],
|
|
5
|
+
"mappings": "AAAA,OAAS,QAAAA,EAAM,QAAAC,EAAM,WAAAC,EAAS,SAAAC,MAAa,YAE3C,OACE,wBAAAC,EACA,yBAAAC,MACK,yBACP,OAAS,aAAAC,MAAiB,4BAC1B,OAAS,mBAAAC,MAAuB,kCAEhC,OAAS,sBAAAC,MAA0B,uBAEnC,MAAMC,EAAU,CACd,aAAc,eACd,YAAa,CAAE,cAAe,CAAE,KAAM,CAAC,OAAO,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Qa,CAAG,EACvCP,EAAS,sBAAsB,CAC7B,GAAI,GACJ,OAAQ,GACV,CAAa,EAIb,MAAMG,EAAS,MADI,IAAIP,EAAmBK,CAAO,EACjB,YAC9B,gBACA,cACAO,EACAX,CACF,EAGA,OAAOG,CAAQ,EAAE,qBACf,GAAGC,CAAO,qCACV,CACE,OAAQ,MACR,QAAS,CACP,eAAgB,mBAChB,cAAe,UAAUJ,EAAQ,YAAY,EAC/C,EACA,KAAM,KAAK,UAAU,CAAE,KAAM,cAAe,OAAQ,CAACU,CAAG,CAAE,CAAC,CAC7D,CACF,EACA,OAAOJ,CAAM,EAAE,QAAQZ,EAAM,MAAS,CAAC,CACzC,CAAC,CACH,CAAC,CACH,CAAC",
|
|
6
|
+
"names": ["Just", "Left", "Nothing", "Right", "LKRPHttpRequestError", "LKRPUnauthorizedError", "LKRPBlock", "LKRPBlockStream", "HttpLKRPDataSource", "mockJwt", "mockChallengeJSON", "mockSignature", "fetchSpy", "baseUrl", "mockChallenge", "result", "error", "jwtWithoutTrustchainId", "mockTrustchain", "hex", "mockBlock"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var
|
|
1
|
+
var g=Object.defineProperty;var s=Object.getOwnPropertyDescriptor;var c=(n,r,o,e)=>{for(var i=e>1?void 0:e?s(r,o):r,p=n.length-1,t;p>=0;p--)(t=n[p])&&(i=(e?t(r,o,i):t(i))||i);return e&&i&&g(r,o,i),i},d=(n,r)=>(o,e)=>r(o,e,n);import{inject as y,injectable as a}from"inversify";import{appBinderTypes as u}from"../../app-binder/di/appBinderTypes";let m=class{constructor(r){this.appBinder=r}execute(r,o,e,i,p,t){return this.appBinder.authenticate({keypair:r,applicationId:o,clientName:e,permissions:i,trustchainId:p,jwt:t})}};m=c([a(),d(0,y(u.AppBinding))],m);export{m as AuthenticateUseCase};
|
|
2
2
|
//# sourceMappingURL=AuthenticateUseCase.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/internal/use-cases/authentication/AuthenticateUseCase.ts"],
|
|
4
|
-
"sourcesContent": ["import {
|
|
5
|
-
"mappings": "iOAAA,
|
|
6
|
-
"names": ["
|
|
4
|
+
"sourcesContent": ["import { inject, injectable } from \"inversify\";\n\nimport { AuthenticateDAReturnType } from \"@api/app-binder/AuthenticateDeviceActionTypes\";\nimport { JWT, Keypair, Permissions } from \"@api/app-binder/LKRPTypes\";\nimport { appBinderTypes } from \"@internal/app-binder/di/appBinderTypes\";\nimport { LedgerKeyringProtocolBinder } from \"@internal/app-binder/LedgerKeyringProtocolBinder\";\n\n@injectable()\nexport class AuthenticateUseCase {\n constructor(\n @inject(appBinderTypes.AppBinding)\n private appBinder: LedgerKeyringProtocolBinder,\n ) {}\n\n execute(\n keypair: Keypair,\n applicationId: number,\n clientName: string,\n permissions: Permissions,\n trustchainId?: string,\n jwt?: JWT,\n ): AuthenticateDAReturnType {\n return this.appBinder.authenticate({\n keypair,\n applicationId,\n clientName,\n permissions,\n trustchainId,\n jwt,\n });\n }\n}\n"],
|
|
5
|
+
"mappings": "iOAAA,OAAS,UAAAA,EAAQ,cAAAC,MAAkB,YAInC,OAAS,kBAAAC,MAAsB,yCAIxB,IAAMC,EAAN,KAA0B,CAC/B,YAEUC,EACR,CADQ,eAAAA,CACP,CAEH,QACEC,EACAC,EACAC,EACAC,EACAC,EACAC,EAC0B,CAC1B,OAAO,KAAK,UAAU,aAAa,CACjC,QAAAL,EACA,cAAAC,EACA,WAAAC,EACA,YAAAC,EACA,aAAAC,EACA,IAAAC,CACF,CAAC,CACH,CACF,EAvBaP,EAANQ,EAAA,CADNC,EAAW,EAGPC,EAAA,EAAAC,EAAOC,EAAe,UAAU,IAFxBZ",
|
|
6
|
+
"names": ["inject", "injectable", "appBinderTypes", "AuthenticateUseCase", "appBinder", "keypair", "applicationId", "clientName", "permissions", "trustchainId", "jwt", "__decorateClass", "injectable", "__decorateParam", "inject", "appBinderTypes"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{ContainerModule as
|
|
1
|
+
import{ContainerModule as t}from"inversify";import{AuthenticateUseCase as o}from"../../use-cases/authentication/AuthenticateUseCase";import{useCasesTypes as s}from"./useCasesTypes";const m=()=>new t(({bind:e})=>{e(s.AuthenticateUseCase).to(o)});export{m as useCasesModuleFactory};
|
|
2
2
|
//# sourceMappingURL=useCasesModule.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/internal/use-cases/di/useCasesModule.ts"],
|
|
4
|
-
"sourcesContent": ["import { ContainerModule } from \"inversify\";\n\nimport { AuthenticateUseCase } from \"@internal/use-cases/authentication/AuthenticateUseCase\";\
|
|
5
|
-
"mappings": "AAAA,OAAS,mBAAAA,MAAuB,YAEhC,OAAS,uBAAAC,MAA2B,
|
|
6
|
-
"names": ["ContainerModule", "AuthenticateUseCase", "
|
|
4
|
+
"sourcesContent": ["import { ContainerModule } from \"inversify\";\n\nimport { AuthenticateUseCase } from \"@internal/use-cases/authentication/AuthenticateUseCase\";\n\nimport { useCasesTypes } from \"./useCasesTypes\";\n\nexport const useCasesModuleFactory = () =>\n new ContainerModule(({ bind }) => {\n bind(useCasesTypes.AuthenticateUseCase).to(AuthenticateUseCase);\n });\n"],
|
|
5
|
+
"mappings": "AAAA,OAAS,mBAAAA,MAAuB,YAEhC,OAAS,uBAAAC,MAA2B,yDAEpC,OAAS,iBAAAC,MAAqB,kBAEvB,MAAMC,EAAwB,IACnC,IAAIH,EAAgB,CAAC,CAAE,KAAAI,CAAK,IAAM,CAChCA,EAAKF,EAAc,mBAAmB,EAAE,GAAGD,CAAmB,CAChE,CAAC",
|
|
6
|
+
"names": ["ContainerModule", "AuthenticateUseCase", "useCasesTypes", "useCasesModuleFactory", "bind"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e={AuthenticateUseCase:Symbol.for("AuthenticateUseCase")
|
|
1
|
+
const e={AuthenticateUseCase:Symbol.for("AuthenticateUseCase")};export{e as useCasesTypes};
|
|
2
2
|
//# sourceMappingURL=useCasesTypes.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/internal/use-cases/di/useCasesTypes.ts"],
|
|
4
|
-
"sourcesContent": ["export const useCasesTypes = {\n AuthenticateUseCase: Symbol.for(\"AuthenticateUseCase\"),\n
|
|
5
|
-
"mappings": "AAAO,MAAMA,EAAgB,CAC3B,oBAAqB,OAAO,IAAI,qBAAqB,
|
|
4
|
+
"sourcesContent": ["export const useCasesTypes = {\n AuthenticateUseCase: Symbol.for(\"AuthenticateUseCase\"),\n};\n"],
|
|
5
|
+
"mappings": "AAAO,MAAMA,EAAgB,CAC3B,oBAAqB,OAAO,IAAI,qBAAqB,CACvD",
|
|
6
6
|
"names": ["useCasesTypes"]
|
|
7
7
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{bufferToHexaString as
|
|
1
|
+
import{bufferToHexaString as e,hexaStringToBuffer as n}from"@ledgerhq/device-management-kit";import{Either as m,Just as o,Nothing as u,Right as p}from"purify-ts";import{CryptoUtils as g}from"./crypto";import{TLVBuilder as y}from"./TLVBuilder";import{TLVParser as P}from"./TLVParser";class i{constructor(r,t){this.bytes=r;this.data=t?o(p(t)):u}hashValue=u;data;static fromHex(r){return new i(n(r)??new Uint8Array)}static fromData(r){const t=new y().addInt(1,1).addHash(n(r.parent)??new Uint8Array).addPublicKey(r.issuer).addInt(r.commands.length,1),a=t.build();r.commands.forEach(l=>t.push(l.toU8A()));const c=t.build().length,s=t.addSignature(r.signature).build(),h=s.slice(c,s.length);return new i(s,{...r,header:a,signature:h})}toString(){return e(this.bytes).slice(2)}toU8A(){return this.bytes}parse(){return this.data.orDefaultLazy(()=>{const r=new P(this.bytes).parseBlockData();return this.data=o(r),r})}toHuman(){return this.parse().chain(r=>m.sequence(r.commands.map(t=>t.toHuman())).map(t=>({...r,commands:t}))).map(r=>[`Parent: ${r.parent}`,`Issuer: ${e(r.issuer).slice(2)}`,`Commands:${r.commands.flatMap(t=>t.split(`
|
|
2
2
|
`).map(a=>`
|
|
3
|
-
${a}`)).join("")}`,`Signature: ${
|
|
4
|
-
`))}hash(){return this.hashValue.orDefaultLazy(()=>{const r=
|
|
3
|
+
${a}`)).join("")}`,`Signature: ${e(r.signature.slice(2)).slice(2)}`].join(`
|
|
4
|
+
`))}hash(){return this.hashValue.orDefaultLazy(()=>{const r=g.hash(this.bytes);return e(r).slice(2)})}}export{i as LKRPBlock};
|
|
5
5
|
//# sourceMappingURL=LKRPBlock.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/internal/utils/LKRPBlock.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n bufferToHexaString,\n
|
|
5
|
-
"mappings": "AAAA,OACE,sBAAAA,EACA,
|
|
6
|
-
"names": ["bufferToHexaString", "
|
|
4
|
+
"sourcesContent": ["import {\n bufferToHexaString,\n hexaStringToBuffer,\n} from \"@ledgerhq/device-management-kit\";\nimport { Either, Just, type Maybe, Nothing, Right } from \"purify-ts\";\n\nimport { type LKRPParsingError } from \"@api/app-binder/Errors\";\n\nimport { CryptoUtils } from \"./crypto\";\nimport { TLVBuilder } from \"./TLVBuilder\";\nimport { TLVParser } from \"./TLVParser\";\nimport { type LKRPBlockData, type LKRPBlockParsedData } from \"./types\";\n\nexport class LKRPBlock {\n private hashValue: Maybe<string> = Nothing; // Cache hash value for performance\n private data: Maybe<Either<LKRPParsingError, LKRPBlockParsedData>>;\n\n public constructor(\n private readonly bytes: Uint8Array,\n data?: LKRPBlockParsedData,\n ) {\n this.data = data ? Just(Right(data)) : Nothing;\n }\n\n static fromHex(hex: string): LKRPBlock {\n return new LKRPBlock(hexaStringToBuffer(hex) ?? new Uint8Array());\n }\n\n static fromData(data: LKRPBlockData): LKRPBlock {\n const builder = new TLVBuilder()\n .addInt(1, 1) // Version 1\n .addHash(hexaStringToBuffer(data.parent) ?? new Uint8Array())\n .addPublicKey(data.issuer)\n .addInt(data.commands.length, 1);\n\n const header = builder.build();\n\n data.commands.forEach((cmd) => builder.push(cmd.toU8A()));\n\n const sigStart = builder.build().length;\n const bytes = builder.addSignature(data.signature).build();\n const signature = bytes.slice(sigStart, bytes.length);\n\n return new LKRPBlock(bytes, { ...data, header, signature });\n }\n\n toString(): string {\n return bufferToHexaString(this.bytes).slice(2);\n }\n\n toU8A(): Uint8Array {\n return this.bytes;\n }\n\n parse(): Either<LKRPParsingError, LKRPBlockParsedData> {\n return this.data.orDefaultLazy(() => {\n const data = new TLVParser(this.bytes).parseBlockData();\n this.data = Just(data);\n return data;\n });\n }\n\n toHuman(): Either<LKRPParsingError, string> {\n return this.parse()\n .chain((data) =>\n Either.sequence(data.commands.map((cmd) => cmd.toHuman())).map(\n (commands) => ({ ...data, commands }),\n ),\n )\n .map((data) =>\n [\n `Parent: ${data.parent}`,\n `Issuer: ${bufferToHexaString(data.issuer).slice(2)}`,\n `Commands:${data.commands\n .flatMap((cmd) => cmd.split(\"\\n\").map((l) => `\\n ${l}`))\n .join(\"\")}`,\n `Signature: ${bufferToHexaString(data.signature.slice(2)).slice(2)}`,\n ].join(\"\\n\"),\n );\n }\n\n hash(): string {\n return this.hashValue.orDefaultLazy(() => {\n const hashValue = CryptoUtils.hash(this.bytes);\n return bufferToHexaString(hashValue).slice(2);\n });\n }\n}\n"],
|
|
5
|
+
"mappings": "AAAA,OACE,sBAAAA,EACA,sBAAAC,MACK,kCACP,OAAS,UAAAC,EAAQ,QAAAC,EAAkB,WAAAC,EAAS,SAAAC,MAAa,YAIzD,OAAS,eAAAC,MAAmB,WAC5B,OAAS,cAAAC,MAAkB,eAC3B,OAAS,aAAAC,MAAiB,cAGnB,MAAMC,CAAU,CAId,YACYC,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,GACtB,WAAWX,EAAmBW,EAAK,MAAM,EAAE,MAAM,CAAC,CAAC,GACnD,YAAYA,EAAK,SACd,QAASI,GAAQA,EAAI,MAAM;AAAA,CAAI,EAAE,IAAKI,GAAM;AAAA,IAAOA,CAAC,EAAE,CAAC,EACvD,KAAK,EAAE,CAAC,GACX,cAAcnB,EAAmBW,EAAK,UAAU,MAAM,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,EACpE,EAAE,KAAK;AAAA,CAAI,CACb,CACJ,CAEA,MAAe,CACb,OAAO,KAAK,UAAU,cAAc,IAAM,CACxC,MAAMS,EAAYd,EAAY,KAAK,KAAK,KAAK,EAC7C,OAAON,EAAmBoB,CAAS,EAAE,MAAM,CAAC,CAC9C,CAAC,CACH,CACF",
|
|
6
|
+
"names": ["bufferToHexaString", "hexaStringToBuffer", "Either", "Just", "Nothing", "Right", "CryptoUtils", "TLVBuilder", "TLVParser", "LKRPBlock", "bytes", "data", "hex", "builder", "header", "cmd", "sigStart", "signature", "commands", "l", "hashValue"]
|
|
7
7
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{Left as n,Right as b}from"purify-ts";import{LKRPParsingError as s}from"../../api/app-binder/Errors";import{hexToBytes as l}from"./hex";import{LKRPBlock as d}from"./LKRPBlock";import{LKRPCommand as t}from"./LKRPCommand";import{GeneralTags as m}from"./TLVTags";const f={parent:"0000",issuer:new Uint8Array([1,2,3]),commands:[t.fromHex("10020102"),t.fromHex("11020304")],signature:new Uint8Array([4,5,6])},r=["010101","02020000","0603010203","010102"].join(""),a=[...r,"10020102","11020304","0303040506"].join(""),o={...f,header:l(r),signature:Uint8Array.from([m.Signature,3,...f.signature])};describe("LKRPBlock",()=>{describe("fromData",()=>{it("should create a Block from data",()=>{const e=d.fromData(f);expect(e.parse()).toStrictEqual(b(o)),expect(e.toString()).toBe(a)})}),describe("toString",()=>{it("should return the hex representation of the block",()=>{const e=d.fromHex(a);expect(e.toString()).toBe(a)})}),describe("toU8A",()=>{it("should return the bytes of the block",()=>{const e=new Uint8Array([1,2,3,4,5,6,7,8]),c=new d(e);expect(c.toU8A()).toBe(e)})}),describe("parse",()=>{it("should parse the block data correctly",()=>{const c=d.fromHex(a).parse();expect(c).toStrictEqual(b(o))}),it("should fail if the block data is invalid",()=>{const e=d.fromHex("invalid");expect(e.parse()).toStrictEqual(n(new s("Unexpected end of TLV")))})}),describe("toHuman",()=>{it("should return a human-readable representation of the block",()=>{const e=`
|
|
2
2
|
01 01 01
|
|
3
3
|
02 20 1d bf 17 52 c5 4b 9f b5 4f b7 c3 63 c1 e6 15 f7 2f d9 61 b7 97 e6 f0 9e 6c 1d 1b 6e db 28 5a 6d
|
|
4
4
|
06 21 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20 21
|
|
@@ -20,5 +20,5 @@ import{hexaStringToBuffer as n}from"@ledgerhq/device-management-kit";import{Left
|
|
|
20
20
|
06 21 02 45 f1 1d 7d 78 bd 22 76 45 11 8a bb 20 b4 07 ff 97 8d f8 7a 6b b3 c4 46 1d 63 37 66 85 8f 98 f5
|
|
21
21
|
03 47 30 45 02 21 00 a0 ea 9d ee 12 f3 83 13 2f 90 72 ad 47 85 a4 15 14 75 d5 70 4a a9 ff 7f 95 52 e9 03 47 b4 ce be 02 20 71 a3 e4 4c 1f 4f a6 4b c6 e2 f4 06 fa 00 fc b4 6f 70 1c 99 49 29 12 bf 33 c7 3e df b2 d5 d1 71
|
|
22
22
|
`.replace(/\s/g,""),i=d.fromHex(e).toHuman();expect(i).toStrictEqual(b(["Parent: 1dbf1752c54b9fb54fb7c363c1e615f72fd961b797e6f09e6c1d1b6edb285a6d","Issuer: 0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f2021","Commands:"," Derive(0x15):"," path: m/0'/16'/1'"," groupKey: 034f37312d9babd8c032e1dd2de33da369fa1ce30f005bbba600d17330ba392cb2"," initializationVector: b6da2c97a3ec8b074f38f1508aed3335"," encryptedXpriv: d21f8f307702333f7a593bebd798a6b06eb5904277268a91350a3c1b1ee67c24b5a47d228c60d0fbc1524eac1bcf123e6e26b5d71708291cc08dcf49de0bb34bacf20093524ca6565d87c636b24475b2"," ephemeralPublicKey: 0293feb66412536d3d71d5c7afac96a36ea8c685889eebcf6f6f82685712fef150"," AddMember(0x11):"," name: debug-d4c61d"," publicKey: 03d4c61dda2aaf762954fce97396d9be0399e1dc75c3b790c7a34dde8596a11812"," permissions: 4294967295"," PublishKey(0x12):"," initializationVector: e7b736c40b14a830fb23aaded8eae544"," encryptedXpriv: df7e808c794675d0a2d466d4efc8ecd07d52368016100d34d6fdb8e6da86e92fbbb7110cb56429b83b1cb974ed4b705143f691b5b81468abd2c526266a6dee6df4fdf1a9d81fe74cda4f61c98960b4db"," recipient: 03d4c61dda2aaf762954fce97396d9be0399e1dc75c3b790c7a34dde8596a11812"," ephemeralPublicKey: 0245f11d7d78bd227645118abb20b407ff978df87a6bb3c4461d633766858f98f5","Signature: 3045022100a0ea9dee12f383132f9072ad4785a4151475d5704aa9ff7f9552e90347b4cebe022071a3e44c1f4fa64bc6e2f406fa00fcb46f701c99492912bf33c73edfb2d5d171"].join(`
|
|
23
|
-
`)))})}),describe("hash",()=>{it("should return the hash of the block",()=>{const
|
|
23
|
+
`)))})}),describe("hash",()=>{it("should return the hash of the block",()=>{const c=d.fromHex(a).hash();expect(c).toBe("7cf783bc15c062242ab92796237da3b192361da7645c488d5023698d4f9cc952")})})});
|
|
24
24
|
//# sourceMappingURL=LKRPBlock.test.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/internal/utils/LKRPBlock.test.ts"],
|
|
4
|
-
"sourcesContent": ["import {
|
|
5
|
-
"mappings": "AAAA,OAAS,
|
|
6
|
-
"names": ["
|
|
4
|
+
"sourcesContent": ["import { Left, Right } from \"purify-ts\";\n\nimport { LKRPParsingError } from \"@api/app-binder/Errors\";\n\nimport { hexToBytes } from \"./hex\";\nimport { LKRPBlock } from \"./LKRPBlock\";\nimport { LKRPCommand } from \"./LKRPCommand\";\nimport { GeneralTags } from \"./TLVTags\";\n\n// Mocked data for testing\nconst mockedBlockData = {\n parent: \"0000\",\n issuer: new Uint8Array([1, 2, 3]),\n commands: [LKRPCommand.fromHex(\"10020102\"), LKRPCommand.fromHex(\"11020304\")],\n signature: new Uint8Array([4, 5, 6]),\n};\nconst mockedHeaderHex = [\n \"010101\", // Version: 1\n \"02020000\", // Parent hash: 00 00 00\n \"0603010203\", // Issuer: 01 02 03\n \"010102\", // Command Count: 2\n].join(\"\");\nconst mockedBlockHex = [\n ...mockedHeaderHex, // Header\n \"10020102\", // Command 1\n \"11020304\", // Command 2\n \"0303040506\", // Signature: 04 05 06\n].join(\"\");\nconst parsedMockedBlockData = {\n ...mockedBlockData,\n header: hexToBytes(mockedHeaderHex),\n signature: Uint8Array.from([\n GeneralTags.Signature,\n 3,\n ...mockedBlockData.signature,\n ]),\n};\n\ndescribe(\"LKRPBlock\", () => {\n describe(\"fromData\", () => {\n it(\"should create a Block from data\", () => {\n // WHEN\n const block = LKRPBlock.fromData(mockedBlockData);\n // THEN\n expect(block.parse()).toStrictEqual(Right(parsedMockedBlockData));\n expect(block.toString()).toBe(mockedBlockHex);\n });\n });\n\n describe(\"toString\", () => {\n it(\"should return the hex representation of the block\", () => {\n // WHEN\n const block = LKRPBlock.fromHex(mockedBlockHex);\n // THEN\n expect(block.toString()).toBe(mockedBlockHex);\n });\n });\n\n describe(\"toU8A\", () => {\n it(\"should return the bytes of the block\", () => {\n // GIVEN\n const bytes = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8]);\n // WHEN\n const block = new LKRPBlock(bytes);\n // THEN\n expect(block.toU8A()).toBe(bytes);\n });\n });\n\n describe(\"parse\", () => {\n it(\"should parse the block data correctly\", () => {\n // GIVEN\n const block = LKRPBlock.fromHex(mockedBlockHex);\n // WHEN\n const parsedData = block.parse();\n // THEN\n expect(parsedData).toStrictEqual(Right(parsedMockedBlockData));\n });\n\n it(\"should fail if the block data is invalid\", () => {\n // WHEN\n const invalidBlock = LKRPBlock.fromHex(\"invalid\");\n // THEN\n expect(invalidBlock.parse()).toStrictEqual(\n Left(new LKRPParsingError(\"Unexpected end of TLV\")),\n );\n });\n });\n\n describe(\"toHuman\", () => {\n it(\"should return a human-readable representation of the block\", () => {\n // GIVEN\n const hex = `\n 01 01 01\n 02 20 1d bf 17 52 c5 4b 9f b5 4f b7 c3 63 c1 e6 15 f7 2f d9 61 b7 97 e6 f0 9e 6c 1d 1b 6e db 28 5a 6d\n 06 21 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20 21\n 01 01 03\n 15 b8\n 05 0c 80 00 00 00 80 00 00 10 80 00 00 01\n 06 21 03 4f 37 31 2d 9b ab d8 c0 32 e1 dd 2d e3 3d a3 69 fa 1c e3 0f 00 5b bb a6 00 d1 73 30 ba 39 2c b2\n 05 10 b6 da 2c 97 a3 ec 8b 07 4f 38 f1 50 8a ed 33 35\n 05 50 d2 1f 8f 30 77 02 33 3f 7a 59 3b eb d7 98 a6 b0 6e b5 90 42 77 26 8a 91 35 0a 3c 1b 1e e6 7c 24 b5 a4 7d 22 8c 60 d0 fb c1 52 4e ac 1b cf 12 3e 6e 26 b5 d7 17 08 29 1c c0 8d cf 49 de 0b b3 4b ac f2 00 93 52 4c a6 56 5d 87 c6 36 b2 44 75 b2\n 06 21 02 93 fe b6 64 12 53 6d 3d 71 d5 c7 af ac 96 a3 6e a8 c6 85 88 9e eb cf 6f 6f 82 68 57 12 fe f1 50\n 11 37\n 04 0c 64 65 62 75 67 2d 64 34 63 36 31 64\n 06 21 03 d4 c6 1d da 2a af 76 29 54 fc e9 73 96 d9 be 03 99 e1 dc 75 c3 b7 90 c7 a3 4d de 85 96 a1 18 12\n 01 04 ff ff ff ff\n 12 aa\n 05 10 e7 b7 36 c4 0b 14 a8 30 fb 23 aa de d8 ea e5 44\n 05 50 df 7e 80 8c 79 46 75 d0 a2 d4 66 d4 ef c8 ec d0 7d 52 36 80 16 10 0d 34 d6 fd b8 e6 da 86 e9 2f bb b7 11 0c b5 64 29 b8 3b 1c b9 74 ed 4b 70 51 43 f6 91 b5 b8 14 68 ab d2 c5 26 26 6a 6d ee 6d f4 fd f1 a9 d8 1f e7 4c da 4f 61 c9 89 60 b4 db\n 06 21 03 d4 c6 1d da 2a af 76 29 54 fc e9 73 96 d9 be 03 99 e1 dc 75 c3 b7 90 c7 a3 4d de 85 96 a1 18 12\n 06 21 02 45 f1 1d 7d 78 bd 22 76 45 11 8a bb 20 b4 07 ff 97 8d f8 7a 6b b3 c4 46 1d 63 37 66 85 8f 98 f5\n 03 47 30 45 02 21 00 a0 ea 9d ee 12 f3 83 13 2f 90 72 ad 47 85 a4 15 14 75 d5 70 4a a9 ff 7f 95 52 e9 03 47 b4 ce be 02 20 71 a3 e4 4c 1f 4f a6 4b c6 e2 f4 06 fa 00 fc b4 6f 70 1c 99 49 29 12 bf 33 c7 3e df b2 d5 d1 71\n `.replace(/\\s/g, \"\");\n\n // WHEN\n const block = LKRPBlock.fromHex(hex);\n const humanReadable = block.toHuman();\n\n // THEN\n expect(humanReadable).toStrictEqual(\n Right(\n [\n `Parent: 1dbf1752c54b9fb54fb7c363c1e615f72fd961b797e6f09e6c1d1b6edb285a6d`,\n `Issuer: 0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f2021`,\n `Commands:`,\n ` Derive(0x15):`,\n ` path: m/0'/16'/1'`,\n ` groupKey: 034f37312d9babd8c032e1dd2de33da369fa1ce30f005bbba600d17330ba392cb2`,\n ` initializationVector: b6da2c97a3ec8b074f38f1508aed3335`,\n ` encryptedXpriv: d21f8f307702333f7a593bebd798a6b06eb5904277268a91350a3c1b1ee67c24b5a47d228c60d0fbc1524eac1bcf123e6e26b5d71708291cc08dcf49de0bb34bacf20093524ca6565d87c636b24475b2`,\n ` ephemeralPublicKey: 0293feb66412536d3d71d5c7afac96a36ea8c685889eebcf6f6f82685712fef150`,\n ` AddMember(0x11):`,\n ` name: debug-d4c61d`,\n ` publicKey: 03d4c61dda2aaf762954fce97396d9be0399e1dc75c3b790c7a34dde8596a11812`,\n ` permissions: 4294967295`,\n ` PublishKey(0x12):`,\n ` initializationVector: e7b736c40b14a830fb23aaded8eae544`,\n ` encryptedXpriv: df7e808c794675d0a2d466d4efc8ecd07d52368016100d34d6fdb8e6da86e92fbbb7110cb56429b83b1cb974ed4b705143f691b5b81468abd2c526266a6dee6df4fdf1a9d81fe74cda4f61c98960b4db`,\n ` recipient: 03d4c61dda2aaf762954fce97396d9be0399e1dc75c3b790c7a34dde8596a11812`,\n ` ephemeralPublicKey: 0245f11d7d78bd227645118abb20b407ff978df87a6bb3c4461d633766858f98f5`,\n `Signature: 3045022100a0ea9dee12f383132f9072ad4785a4151475d5704aa9ff7f9552e90347b4cebe022071a3e44c1f4fa64bc6e2f406fa00fcb46f701c99492912bf33c73edfb2d5d171`,\n ].join(\"\\n\"),\n ),\n );\n });\n });\n\n describe(\"hash\", () => {\n it(\"should return the hash of the block\", () => {\n // GIVEN\n const block = LKRPBlock.fromHex(mockedBlockHex);\n // WHEN\n const hash = block.hash();\n // THEN\n expect(hash).toBe(\n \"7cf783bc15c062242ab92796237da3b192361da7645c488d5023698d4f9cc952\",\n );\n });\n });\n});\n"],
|
|
5
|
+
"mappings": "AAAA,OAAS,QAAAA,EAAM,SAAAC,MAAa,YAE5B,OAAS,oBAAAC,MAAwB,yBAEjC,OAAS,cAAAC,MAAkB,QAC3B,OAAS,aAAAC,MAAiB,cAC1B,OAAS,eAAAC,MAAmB,gBAC5B,OAAS,eAAAC,MAAmB,YAG5B,MAAMC,EAAkB,CACtB,OAAQ,OACR,OAAQ,IAAI,WAAW,CAAC,EAAG,EAAG,CAAC,CAAC,EAChC,SAAU,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CAA4C,IAAM,CAEnD,MAAMI,EAAeV,EAAU,QAAQ,SAAS,EAEhD,OAAOU,EAAa,MAAM,CAAC,EAAE,cAC3Bd,EAAK,IAAIE,EAAiB,uBAAuB,CAAC,CACpD,CACF,CAAC,CACH,CAAC,EAED,SAAS,UAAW,IAAM,CACxB,GAAG,6DAA8D,IAAM,CAErE,MAAMa,EAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,QAqBV,QAAQ,MAAO,EAAE,EAIbC,EADQZ,EAAU,QAAQW,CAAG,EACP,QAAQ,EAGpC,OAAOC,CAAa,EAAE,cACpBf,EACE,CACE,2EACA,6EACA,YACA,kBACA,wBACA,mFACA,6DACA,uLACA,6FACA,qBACA,yBACA,oFACA,8BACA,sBACA,6DACA,uLACA,oFACA,6FACA,2JACF,EAAE,KAAK;AAAA,CAAI,CACb,CACF,CACF,CAAC,CACH,CAAC,EAED,SAAS,OAAQ,IAAM,CACrB,GAAG,sCAAuC,IAAM,CAI9C,MAAMgB,EAFQb,EAAU,QAAQK,CAAc,EAE3B,KAAK,EAExB,OAAOQ,CAAI,EAAE,KACX,kEACF,CACF,CAAC,CACH,CAAC,CACH,CAAC",
|
|
6
|
+
"names": ["Left", "Right", "LKRPParsingError", "hexToBytes", "LKRPBlock", "LKRPCommand", "GeneralTags", "mockedBlockData", "mockedHeaderHex", "mockedBlockHex", "parsedMockedBlockData", "block", "bytes", "parsedData", "invalidBlock", "hex", "humanReadable", "hash"]
|
|
7
7
|
}
|