@ledgerhq/device-trusted-app-kit-ledger-keyring-protocol 0.0.0-rn-ble-pairing-removed-while-reconnecting-20250807094338 → 0.0.0-web-ble-29-08---20250829104351
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 +1 -1
- package/lib/cjs/api/app-binder/Errors.js.map +3 -3
- package/lib/cjs/api/app-binder/LKRPTypes.js +1 -1
- package/lib/cjs/api/app-binder/LKRPTypes.js.map +3 -3
- package/lib/cjs/api/app-binder/SignBlockHeaderCommandTypes.js +1 -1
- package/lib/cjs/api/app-binder/SignBlockHeaderCommandTypes.js.map +1 -1
- 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/SetTrustedMemberCommand.js +1 -1
- package/lib/cjs/internal/app-binder/command/SetTrustedMemberCommand.js.map +3 -3
- 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/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/AuthenticateWithDeviceDeviceAction.js +2 -0
- package/lib/cjs/internal/app-binder/device-action/AuthenticateWithDeviceDeviceAction.js.map +7 -0
- package/lib/cjs/internal/app-binder/device-action/AuthenticateWithKeypairDeviceAction.js +2 -0
- package/lib/cjs/internal/app-binder/device-action/AuthenticateWithKeypairDeviceAction.js.map +7 -0
- package/lib/cjs/internal/app-binder/device-action/models/AuthenticateWithDeviceDeviceActionTypes.js +2 -0
- package/lib/cjs/internal/app-binder/device-action/models/AuthenticateWithDeviceDeviceActionTypes.js.map +7 -0
- package/lib/cjs/internal/app-binder/device-action/models/AuthenticateWithKeypairDeviceActionTypes.js +2 -0
- package/lib/cjs/internal/app-binder/device-action/models/AuthenticateWithKeypairDeviceActionTypes.js.map +7 -0
- package/lib/cjs/internal/app-binder/task/AuthenticateTask.js +2 -0
- package/lib/cjs/internal/app-binder/task/AuthenticateTask.js.map +7 -0
- package/lib/cjs/internal/app-binder/task/ExtractEncryptionKeyTask.js +2 -0
- package/lib/cjs/internal/app-binder/task/ExtractEncryptionKeyTask.js.map +7 -0
- 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 +2 -2
- 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/models/LKRPBlockTypes.js +2 -0
- package/lib/cjs/internal/models/LKRPBlockTypes.js.map +7 -0
- package/lib/cjs/internal/models/LKRPCommandTypes.js +2 -0
- package/lib/cjs/internal/models/LKRPCommandTypes.js.map +7 -0
- package/lib/cjs/internal/{utils/TLVTags.js → models/Tags.js} +1 -1
- package/lib/cjs/internal/{utils/TLVTags.js.map → models/Tags.js.map} +2 -2
- package/lib/cjs/internal/models/Types.js +2 -0
- package/lib/cjs/internal/models/Types.js.map +7 -0
- 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/authentication/DecryptDataUseCase.js +2 -0
- package/lib/cjs/internal/use-cases/authentication/DecryptDataUseCase.js.map +7 -0
- package/lib/cjs/internal/use-cases/authentication/EncryptDataUseCase.js +2 -0
- package/lib/cjs/internal/use-cases/authentication/EncryptDataUseCase.js.map +7 -0
- 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.map +2 -2
- package/lib/cjs/internal/utils/LKRPBlock.test.js +1 -1
- 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 +1 -1
- package/lib/cjs/internal/utils/TLVBuilder.js.map +3 -3
- 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/utils/Trustchain.js +2 -0
- package/lib/cjs/internal/utils/Trustchain.js.map +7 -0
- package/lib/cjs/internal/utils/hex.js +1 -1
- package/lib/cjs/internal/utils/hex.js.map +3 -3
- package/lib/cjs/package.json +1 -0
- 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 +1 -0
- package/lib/esm/api/app-binder/AddToTrustchainDeviceActionTypes.js.map +4 -4
- package/lib/esm/api/app-binder/AuthenticateDeviceActionTypes.js +1 -0
- package/lib/esm/api/app-binder/AuthenticateDeviceActionTypes.js.map +4 -4
- package/lib/esm/api/app-binder/Errors.js +1 -1
- package/lib/esm/api/app-binder/Errors.js.map +3 -3
- package/lib/esm/api/app-binder/LKRPTypes.js +1 -1
- package/lib/esm/api/app-binder/LKRPTypes.js.map +3 -3
- 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/SetTrustedMemberCommand.js +1 -1
- package/lib/esm/internal/app-binder/command/SetTrustedMemberCommand.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/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/AuthenticateWithDeviceDeviceAction.js +2 -0
- package/lib/esm/internal/app-binder/device-action/AuthenticateWithDeviceDeviceAction.js.map +7 -0
- package/lib/esm/internal/app-binder/device-action/AuthenticateWithKeypairDeviceAction.js +2 -0
- package/lib/esm/internal/app-binder/device-action/AuthenticateWithKeypairDeviceAction.js.map +7 -0
- package/lib/esm/internal/app-binder/device-action/models/AuthenticateWithDeviceDeviceActionTypes.js +1 -0
- package/lib/esm/internal/app-binder/device-action/models/AuthenticateWithKeypairDeviceActionTypes.js +1 -0
- package/lib/esm/internal/app-binder/device-action/models/AuthenticateWithKeypairDeviceActionTypes.js.map +7 -0
- package/lib/esm/internal/app-binder/task/AuthenticateTask.js +2 -0
- package/lib/esm/internal/app-binder/task/AuthenticateTask.js.map +7 -0
- package/lib/esm/internal/app-binder/task/ExtractEncryptionKeyTask.js +2 -0
- package/lib/esm/internal/app-binder/task/ExtractEncryptionKeyTask.js.map +7 -0
- 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/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/models/LKRPBlockTypes.js +1 -0
- package/lib/esm/internal/models/LKRPBlockTypes.js.map +7 -0
- package/lib/esm/internal/models/LKRPCommandTypes.js +1 -0
- package/lib/esm/internal/models/LKRPCommandTypes.js.map +7 -0
- package/lib/esm/internal/{utils/TLVTags.js → models/Tags.js} +1 -1
- package/lib/esm/internal/{utils/TLVTags.js.map → models/Tags.js.map} +1 -1
- package/lib/esm/internal/models/Types.js +1 -0
- package/lib/esm/internal/models/Types.js.map +7 -0
- 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/authentication/DecryptDataUseCase.js +2 -0
- package/lib/esm/internal/use-cases/authentication/DecryptDataUseCase.js.map +7 -0
- package/lib/esm/internal/use-cases/authentication/EncryptDataUseCase.js +2 -0
- package/lib/esm/internal/use-cases/authentication/EncryptDataUseCase.js.map +7 -0
- 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.map +2 -2
- package/lib/esm/internal/utils/LKRPBlock.test.js +1 -1
- 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 +1 -1
- package/lib/esm/internal/utils/TLVBuilder.js.map +2 -2
- 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/utils/Trustchain.js +2 -0
- package/lib/esm/internal/utils/Trustchain.js.map +7 -0
- package/lib/esm/internal/utils/hex.js +1 -1
- package/lib/esm/internal/utils/hex.js.map +3 -3
- package/lib/esm/package.json +1 -0
- package/lib/types/api/LedgerKeyringProtocol.d.ts +3 -4
- package/lib/types/api/LedgerKeyringProtocol.d.ts.map +1 -1
- package/lib/types/api/LedgerKeyringProtocolBuilder.d.ts +9 -6
- package/lib/types/api/LedgerKeyringProtocolBuilder.d.ts.map +1 -1
- package/lib/types/api/app-binder/AddToTrustchainDeviceActionTypes.d.ts +18 -8
- package/lib/types/api/app-binder/AddToTrustchainDeviceActionTypes.d.ts.map +1 -1
- package/lib/types/api/app-binder/AuthenticateDeviceActionTypes.d.ts +27 -31
- package/lib/types/api/app-binder/AuthenticateDeviceActionTypes.d.ts.map +1 -1
- package/lib/types/api/app-binder/Errors.d.ts +38 -12
- package/lib/types/api/app-binder/Errors.d.ts.map +1 -1
- package/lib/types/api/app-binder/LKRPTypes.d.ts +4 -0
- package/lib/types/api/app-binder/LKRPTypes.d.ts.map +1 -1
- package/lib/types/api/app-binder/SignBlockHeaderCommandTypes.d.ts +2 -1
- package/lib/types/api/app-binder/SignBlockHeaderCommandTypes.d.ts.map +1 -1
- package/lib/types/internal/DefaultLedgerKeyringProtocol.d.ts +9 -8
- package/lib/types/internal/DefaultLedgerKeyringProtocol.d.ts.map +1 -1
- package/lib/types/internal/app-binder/LedgerKeyringProtocolBinder.d.ts +10 -7
- package/lib/types/internal/app-binder/LedgerKeyringProtocolBinder.d.ts.map +1 -1
- package/lib/types/internal/app-binder/command/SignBlockHeader.d.ts +1 -0
- package/lib/types/internal/app-binder/command/SignBlockHeader.d.ts.map +1 -1
- package/lib/types/internal/app-binder/device-action/AddToTrustchainDeviceAction.d.ts +2 -2
- package/lib/types/internal/app-binder/device-action/AddToTrustchainDeviceAction.d.ts.map +1 -1
- package/lib/types/internal/app-binder/device-action/AuthenticateWithDeviceDeviceAction.d.ts +29 -0
- package/lib/types/internal/app-binder/device-action/AuthenticateWithDeviceDeviceAction.d.ts.map +1 -0
- package/lib/types/internal/app-binder/device-action/AuthenticateWithKeypairDeviceAction.d.ts +30 -0
- package/lib/types/internal/app-binder/device-action/AuthenticateWithKeypairDeviceAction.d.ts.map +1 -0
- package/lib/types/internal/app-binder/device-action/models/AuthenticateWithDeviceDeviceActionTypes.d.ts +19 -0
- package/lib/types/internal/app-binder/device-action/models/AuthenticateWithDeviceDeviceActionTypes.d.ts.map +1 -0
- package/lib/types/internal/app-binder/device-action/models/AuthenticateWithKeypairDeviceActionTypes.d.ts +16 -0
- package/lib/types/internal/app-binder/device-action/models/AuthenticateWithKeypairDeviceActionTypes.d.ts.map +1 -0
- package/lib/types/internal/app-binder/task/AuthenticateTask.d.ts +9 -0
- package/lib/types/internal/app-binder/task/AuthenticateTask.d.ts.map +1 -0
- package/lib/types/internal/app-binder/task/ExtractEncryptionKeyTask.d.ts +11 -0
- package/lib/types/internal/app-binder/task/ExtractEncryptionKeyTask.d.ts.map +1 -0
- 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 +6 -7
- package/lib/types/internal/app-binder/task/SignBlockTask.d.ts.map +1 -1
- package/lib/types/internal/app-binder/task/SignChallengeWithKeypairTask.d.ts +2 -3
- package/lib/types/internal/app-binder/task/SignChallengeWithKeypairTask.d.ts.map +1 -1
- package/lib/types/internal/app-binder/task/utils/TrustedProperties.d.ts +1 -1
- package/lib/types/internal/app-binder/task/utils/TrustedProperties.d.ts.map +1 -1
- package/lib/types/internal/di.d.ts +5 -3
- package/lib/types/internal/di.d.ts.map +1 -1
- package/lib/types/internal/externalTypes.d.ts +1 -1
- package/lib/types/internal/lkrp-datasource/data/HttpLKRPDataSource.d.ts +7 -9
- package/lib/types/internal/lkrp-datasource/data/HttpLKRPDataSource.d.ts.map +1 -1
- package/lib/types/internal/lkrp-datasource/data/LKRPDataSource.d.ts +7 -7
- package/lib/types/internal/lkrp-datasource/data/LKRPDataSource.d.ts.map +1 -1
- package/lib/types/internal/models/LKRPBlockTypes.d.ts +11 -0
- package/lib/types/internal/models/LKRPBlockTypes.d.ts.map +1 -0
- package/lib/types/internal/{utils/types.d.ts → models/LKRPCommandTypes.d.ts} +6 -29
- package/lib/types/internal/models/LKRPCommandTypes.d.ts.map +1 -0
- package/lib/types/internal/{utils/TLVTags.d.ts → models/Tags.d.ts} +1 -1
- package/lib/types/internal/models/Tags.d.ts.map +1 -0
- package/lib/types/internal/models/Types.d.ts +10 -0
- package/lib/types/internal/models/Types.d.ts.map +1 -0
- package/lib/types/internal/use-cases/authentication/AuthenticateUseCase.d.ts +14 -2
- package/lib/types/internal/use-cases/authentication/AuthenticateUseCase.d.ts.map +1 -1
- package/lib/types/internal/use-cases/authentication/DecryptDataUseCase.d.ts +4 -0
- package/lib/types/internal/use-cases/authentication/DecryptDataUseCase.d.ts.map +1 -0
- package/lib/types/internal/use-cases/authentication/EncryptDataUseCase.d.ts +4 -0
- package/lib/types/internal/use-cases/authentication/EncryptDataUseCase.d.ts.map +1 -0
- package/lib/types/internal/use-cases/di/useCasesModule.d.ts.map +1 -1
- package/lib/types/internal/use-cases/di/useCasesTypes.d.ts +2 -0
- package/lib/types/internal/use-cases/di/useCasesTypes.d.ts.map +1 -1
- package/lib/types/internal/utils/LKRPBlock.d.ts +1 -1
- package/lib/types/internal/utils/LKRPBlock.d.ts.map +1 -1
- package/lib/types/internal/utils/LKRPBlockStream.d.ts +4 -5
- package/lib/types/internal/utils/LKRPBlockStream.d.ts.map +1 -1
- package/lib/types/internal/utils/LKRPCommand.d.ts +3 -2
- package/lib/types/internal/utils/LKRPCommand.d.ts.map +1 -1
- package/lib/types/internal/utils/TLVParser.d.ts +3 -2
- package/lib/types/internal/utils/TLVParser.d.ts.map +1 -1
- package/lib/types/internal/utils/Trustchain.d.ts +14 -0
- package/lib/types/internal/utils/Trustchain.d.ts.map +1 -0
- package/lib/types/internal/utils/hex.d.ts.map +1 -1
- package/lib/types/tsconfig.prod.tsbuildinfo +1 -1
- package/package.json +4 -3
- package/lib/cjs/internal/app-binder/device-action/AuthenticateDeviceAction.js +0 -2
- package/lib/cjs/internal/app-binder/device-action/AuthenticateDeviceAction.js.map +0 -7
- package/lib/cjs/internal/utils/types.js +0 -2
- package/lib/cjs/internal/utils/types.js.map +0 -7
- package/lib/esm/internal/app-binder/device-action/AuthenticateDeviceAction.js +0 -2
- package/lib/esm/internal/app-binder/device-action/AuthenticateDeviceAction.js.map +0 -7
- package/lib/esm/internal/utils/types.js +0 -1
- package/lib/types/internal/app-binder/device-action/AuthenticateDeviceAction.d.ts +0 -42
- package/lib/types/internal/app-binder/device-action/AuthenticateDeviceAction.d.ts.map +0 -1
- package/lib/types/internal/utils/TLVTags.d.ts.map +0 -1
- package/lib/types/internal/utils/types.d.ts.map +0 -1
- /package/lib/esm/internal/{utils/types.js.map → app-binder/device-action/models/AuthenticateWithDeviceDeviceActionTypes.js.map} +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{Left as a,Right as t}from"purify-ts";import{LKRPParsingError as s}from"../../api/app-binder/Errors";import{derivationPathAsString as c}from"./derivationPath";import{eitherSeqRecord as h}from"./eitherSeqRecord";import{bytesToHex as d}from"./hex";import{LKRPCommand as g}from"./LKRPCommand";
|
|
1
|
+
import{Left as a,Right as t}from"purify-ts";import{LKRPParsingError as s}from"../../api/app-binder/Errors";import{CommandTags as p,GeneralTags as i}from"../models/Tags";import{derivationPathAsString as c}from"./derivationPath";import{eitherSeqRecord as h}from"./eitherSeqRecord";import{bytesToHex as d}from"./hex";import{LKRPCommand as g}from"./LKRPCommand";const y=3;class w{bytes;parser;offset=0;constructor(e){this.bytes=e,this.parser=this.parseTLV(e)}get state(){return{offset:this.offset,isDone:this.offset>=this.bytes.length}}parse(){return this.parser.next().value}tlvEncoded(e){const r=this.offset;return e().map(()=>this.bytes.slice(r,this.offset))}parseNull(){return this.parse().chain(e=>e.tag!==i.Null?a(new s("Expected null")):t(e.value))}parseInt(){return this.parse().chain(e=>e.tag!==i.Int?a(new s("Expected a number")):t(e.value))}parseHash(){return this.parse().chain(e=>e.tag!==i.Hash?a(new s("Expected a hash")):t(e.value))}parseSignature(){return this.parse().chain(e=>e.tag!==i.Signature?a(new s("Expected a signature")):t(e.value))}parseString(){return this.parse().chain(e=>e.tag!==i.String?a(new s("Expected a string")):t(e.value))}parseBytes(){return this.parse().chain(e=>e.tag!==i.Bytes?a(new s("Expected bytes")):t(e.value))}parsePublicKey(){return this.parse().chain(e=>e.tag!==i.PublicKey?a(new s("Expected a public key")):t(e.value))}parseCommandBytes(){return this.parse().chain(({tag:e,value:r})=>e<16||e>63||!(r instanceof Uint8Array)?a(new s(`Invalid command type: 0x${e.toString(16).padStart(2,"0")}`)):t(r))}parseCommandData(){const e=this.parseCommandBytes(),r=this.offset;return e.chain(o=>{const n=o[0];switch(this.offset-=o.length-2,n){case p.Seed:return h({type:n,topic:()=>this.parseBytes(),protocolVersion:()=>this.parseInt(),groupKey:()=>this.parsePublicKey(),initializationVector:()=>this.parseBytes(),encryptedXpriv:()=>this.parseBytes(),ephemeralPublicKey:()=>this.parsePublicKey()});case p.AddMember:return h({type:n,name:()=>this.parseString(),publicKey:()=>this.parsePublicKey(),permissions:()=>this.parseInt()});case p.PublishKey:return h({type:n,initializationVector:()=>this.parseBytes(),encryptedXpriv:()=>this.parseBytes(),recipient:()=>this.parsePublicKey(),ephemeralPublicKey:()=>this.parsePublicKey()});case p.Derive:return h({type:n,path:()=>this.parseBytes().map(c),groupKey:()=>this.parsePublicKey(),initializationVector:()=>this.parseBytes(),encryptedXpriv:()=>this.parseBytes(),ephemeralPublicKey:()=>this.parsePublicKey()});default:return a(new s(`Unsupported command type: 0x${n?.toString(16).padStart(2,"0")}`))}}).chain(o=>this.offset===r?t(o):a(new s("Command was parsed incorrectly")))}parseCommands(){return this.parse().chain(e=>e.tag!==i.Int?a(new s("Expected a command count")):t(e.value)).chain(e=>{const r=[];for(let o=0;o<e;o++){const n=this.parseCommandBytes();if(n.isLeft())return n;n.ifRight(l=>r.push(new g(l)))}return t(r)})}parseBlockData(){const e=this.offset;return this.parseInt().chain(r=>h({parent:()=>this.parseHash().map(d),issuer:()=>this.parsePublicKey(),header:()=>t(this.bytes.slice(e,this.offset+y)),commands:()=>this.parseCommands(),signature:()=>this.tlvEncoded(()=>this.parseSignature())}))}*parseTLV(e){for(;;){const r=e[this.offset];if(typeof r>"u")return a(new s("Unexpected end of TLV"));this.offset++;const o=e[this.offset];if(typeof o>"u")return a(new s("Invalid end of TLV, expected length"));this.offset++;const n=this.offset+o,l=e.slice(this.offset,n);if(n>e.length)return a(new s("Invalid end of TLV value"));switch(this.offset=n,r){case i.Null:yield o>0?a(new s("Invalid null length")):t({tag:r,value:null});break;case i.Int:{const u=new DataView(l.buffer);switch(l.length){case 1:yield t({tag:r,value:u.getUint8(0)});break;case 2:yield t({tag:r,value:u.getUint16(0,!1)});break;case 4:yield t({tag:r,value:u.getUint32(0,!1)});break;default:yield a(new s("Unsupported integer length"))}}break;case i.String:yield l.length===0?a(new s("Empty string value")):t({tag:r,value:new TextDecoder().decode(l)});break;case i.Hash:case i.Signature:case i.Bytes:case i.PublicKey:yield t({tag:r,value:l});break;default:yield t({tag:r,value:new Uint8Array([r,o,...l])});break}}}}export{w as TLVParser};
|
|
2
2
|
//# sourceMappingURL=TLVParser.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/internal/utils/TLVParser.ts"],
|
|
4
|
-
"sourcesContent": ["import { type Either, Left, Right } from \"purify-ts\";\n\nimport { LKRPParsingError } from \"@api/app-binder/Errors\";\n\nimport { derivationPathAsString } from \"./derivationPath\";\nimport { eitherSeqRecord } from \"./eitherSeqRecord\";\nimport { bytesToHex } from \"./hex\";\nimport { LKRPCommand } from \"./LKRPCommand\";\nimport { CommandTags, GeneralTags } from \"./TLVTags\";\nimport { type LKRPBlockParsedData, type LKRPCommandData } from \"./types\";\n\ntype ParserValue = Either<\n LKRPParsingError,\n | { tag: GeneralTags.Null; value: null }\n | { tag: GeneralTags.Int; value: number }\n | { tag: GeneralTags.Hash; value: Uint8Array }\n | { tag: GeneralTags.Signature; value: Uint8Array }\n | { tag: GeneralTags.String; value: string }\n | { tag: GeneralTags.Bytes; value: Uint8Array }\n | { tag: GeneralTags.PublicKey; value: Uint8Array }\n | { tag: CommandTags; value: Uint8Array }\n | {\n tag: Exclude<number, GeneralTags | CommandTags>;\n value: null | number | Uint8Array;\n }\n>;\n\ntype Parser = Generator<ParserValue, ParserValue, void>;\n\nconst COMMAND_COUNT_LENGTH = 3;\n\nexport class TLVParser {\n private readonly bytes: Uint8Array;\n private readonly parser: Parser;\n private offset = 0;\n\n constructor(bytes: Uint8Array) {\n this.bytes = bytes;\n this.parser = this.parseTLV(bytes);\n }\n\n get state() {\n return {\n offset: this.offset,\n isDone: this.offset >= this.bytes.length,\n };\n }\n\n parse(): ParserValue {\n return this.parser.next().value;\n }\n\n tlvEncoded(\n fn: () => Either<LKRPParsingError, unknown>,\n ): Either<LKRPParsingError, Uint8Array> {\n const start = this.offset;\n return fn().map(() => this.bytes.slice(start, this.offset));\n }\n\n parseNull(): Either<LKRPParsingError, null> {\n return this.parse().chain((next) =>\n next.tag !== GeneralTags.Null\n ? Left(new LKRPParsingError(\"Expected null\"))\n : Right(next.value),\n );\n }\n\n parseInt(): Either<LKRPParsingError, number> {\n return this.parse().chain((next) =>\n next.tag !== GeneralTags.Int\n ? Left(new LKRPParsingError(\"Expected a number\"))\n : Right(next.value),\n );\n }\n\n parseHash(): Either<LKRPParsingError, Uint8Array> {\n return this.parse().chain((next) =>\n next.tag !== GeneralTags.Hash\n ? Left(new LKRPParsingError(\"Expected a hash\"))\n : Right(next.value),\n );\n }\n\n parseSignature(): Either<LKRPParsingError, Uint8Array> {\n return this.parse().chain((next) =>\n next.tag !== GeneralTags.Signature\n ? Left(new LKRPParsingError(\"Expected a signature\"))\n : Right(next.value),\n );\n }\n\n parseString(): Either<LKRPParsingError, string> {\n return this.parse().chain((next) =>\n next.tag !== GeneralTags.String\n ? Left(new LKRPParsingError(\"Expected a string\"))\n : Right(next.value),\n );\n }\n\n parseBytes(): Either<LKRPParsingError, Uint8Array> {\n return this.parse().chain((next) =>\n next.tag !== GeneralTags.Bytes\n ? Left(new LKRPParsingError(\"Expected bytes\"))\n : Right(next.value),\n );\n }\n\n parsePublicKey(): Either<LKRPParsingError, Uint8Array> {\n return this.parse().chain((next) =>\n next.tag !== GeneralTags.PublicKey\n ? Left(new LKRPParsingError(\"Expected a public key\"))\n : Right(next.value),\n );\n }\n\n parseCommandBytes(): Either<LKRPParsingError, Uint8Array> {\n return this.parse().chain(({ tag, value }) =>\n tag < 0x10 || tag > 0x3f || !(value instanceof Uint8Array)\n ? Left(\n new LKRPParsingError(\n `Invalid command type: 0x${tag.toString(16).padStart(2, \"0\")}`,\n ),\n )\n : Right(value),\n );\n }\n\n // https://ledgerhq.atlassian.net/wiki/spaces/TA/pages/4105207815/ARCH+LKRP+-+v1+specifications#Commands\n parseCommandData(): Either<LKRPParsingError, LKRPCommandData> {\n const bytes = this.parseCommandBytes();\n const end = this.offset;\n\n return bytes\n .chain<LKRPParsingError, LKRPCommandData>((value) => {\n const type = value[0];\n this.offset -= value.length - 2; // Adjust offset to the start of the command\n switch (type) {\n // https://ledgerhq.atlassian.net/wiki/spaces/TA/pages/4105207815/ARCH+LKRP+-+v1+specifications#Seed-(0x10)\n case CommandTags.Seed:\n return eitherSeqRecord({\n type,\n topic: () => this.parseBytes(),\n protocolVersion: () => this.parseInt(),\n groupKey: () => this.parsePublicKey(),\n initializationVector: () => this.parseBytes(),\n encryptedXpriv: () => this.parseBytes(),\n ephemeralPublicKey: () => this.parsePublicKey(),\n });\n\n // https://ledgerhq.atlassian.net/wiki/spaces/TA/pages/4105207815/ARCH+LKRP+-+v1+specifications#AddMember-(0x11)\n case CommandTags.AddMember:\n return eitherSeqRecord({\n type,\n name: () => this.parseString(),\n publicKey: () => this.parsePublicKey(),\n permissions: () => this.parseInt(),\n });\n\n // https://ledgerhq.atlassian.net/wiki/spaces/TA/pages/4105207815/ARCH+LKRP+-+v1+specifications#PublishKey-(0x12)\n case CommandTags.PublishKey:\n return eitherSeqRecord({\n type,\n initializationVector: () => this.parseBytes(),\n encryptedXpriv: () => this.parseBytes(),\n recipient: () => this.parsePublicKey(),\n ephemeralPublicKey: () => this.parsePublicKey(),\n });\n\n // https://ledgerhq.atlassian.net/wiki/spaces/TA/pages/4105207815/ARCH+LKRP+-+v1+specifications#Derive-(0x15)\n case CommandTags.Derive:\n return eitherSeqRecord({\n type,\n path: () => this.parseBytes().map(derivationPathAsString),\n groupKey: () => this.parsePublicKey(),\n initializationVector: () => this.parseBytes(),\n encryptedXpriv: () => this.parseBytes(),\n ephemeralPublicKey: () => this.parsePublicKey(),\n });\n\n default:\n return Left(\n new LKRPParsingError(\n `Unsupported command type: 0x${type?.toString(16).padStart(2, \"0\")}`,\n ),\n );\n }\n })\n .chain((data) =>\n this.offset === end\n ? Right(data)\n : Left(new LKRPParsingError(\"Command was parsed incorrectly\")),\n );\n }\n\n parseCommands(): Either<LKRPParsingError, LKRPCommand[]> {\n return this.parse()\n .chain((next) =>\n next.tag !== GeneralTags.Int\n ? Left(new LKRPParsingError(\"Expected a command count\"))\n : Right(next.value),\n )\n .chain((count) => {\n const commands: LKRPCommand[] = [];\n for (let i = 0; i < count; i++) {\n const command = this.parseCommandBytes();\n if (command.isLeft()) return command;\n command.ifRight((value) => commands.push(new LKRPCommand(value)));\n }\n return Right(commands);\n });\n }\n\n // https://ledgerhq.atlassian.net/wiki/spaces/TA/pages/4105207815/ARCH+LKRP+-+v1+specifications#Block\n parseBlockData(): Either<LKRPParsingError, LKRPBlockParsedData> {\n const startOffset = this.offset;\n return this.parseInt().chain((_version) =>\n eitherSeqRecord({\n parent: () => this.parseHash().map(bytesToHex),\n issuer: () => this.parsePublicKey(),\n header: () =>\n Right(\n this.bytes.slice(startOffset, this.offset + COMMAND_COUNT_LENGTH),\n ),\n commands: () => this.parseCommands(),\n signature: () => this.tlvEncoded(() => this.parseSignature()),\n }),\n );\n }\n\n private *parseTLV(bytes: Uint8Array): Parser {\n while (true) {\n const tag = bytes[this.offset];\n if (typeof tag === \"undefined\") {\n return Left(new LKRPParsingError(\"Unexpected end of TLV\"));\n }\n this.offset++;\n const length = bytes[this.offset];\n if (typeof length === \"undefined\") {\n return Left(\n new LKRPParsingError(\"Invalid end of TLV, expected length\"),\n );\n }\n this.offset++;\n const valueEnd = this.offset + length;\n const value = bytes.slice(this.offset, valueEnd);\n if (valueEnd > bytes.length) {\n return Left(new LKRPParsingError(\"Invalid end of TLV value\"));\n }\n this.offset = valueEnd;\n\n switch (tag) {\n case GeneralTags.Null:\n yield length > 0\n ? Left(new LKRPParsingError(\"Invalid null length\"))\n : Right({ tag, value: null });\n break;\n\n case GeneralTags.Int:\n {\n const dataView = new DataView(value.buffer);\n switch (value.length) {\n case 1:\n yield Right({ tag, value: dataView.getUint8(0) });\n break;\n case 2:\n yield Right({ tag, value: dataView.getUint16(0, false) }); // Big-endian\n break;\n case 4:\n yield Right({ tag, value: dataView.getUint32(0, false) }); // Big-endian\n break;\n default:\n yield Left(new LKRPParsingError(\"Unsupported integer length\"));\n }\n }\n break;\n\n case GeneralTags.String:\n yield value.length === 0\n ? Left(new LKRPParsingError(\"Empty string value\"))\n : Right({ tag, value: new TextDecoder().decode(value) });\n break;\n\n case GeneralTags.Hash:\n case GeneralTags.Signature:\n case GeneralTags.Bytes:\n case GeneralTags.PublicKey:\n yield Right({ tag, value });\n break;\n\n default:\n yield Right({ tag, value: new Uint8Array([tag, length, ...value]) });\n break;\n }\n }\n }\n}\n"],
|
|
5
|
-
"mappings": "AAAA,OAAsB,QAAAA,EAAM,SAAAC,MAAa,YAEzC,OAAS,oBAAAC,MAAwB,
|
|
6
|
-
"names": ["Left", "Right", "LKRPParsingError", "
|
|
4
|
+
"sourcesContent": ["import { type Either, Left, Right } from \"purify-ts\";\n\nimport { LKRPParsingError } from \"@api/app-binder/Errors\";\nimport { type LKRPBlockParsedData } from \"@internal/models/LKRPBlockTypes\";\nimport { type LKRPCommandData } from \"@internal/models/LKRPCommandTypes\";\nimport { CommandTags, GeneralTags } from \"@internal/models/Tags\";\n\nimport { derivationPathAsString } from \"./derivationPath\";\nimport { eitherSeqRecord } from \"./eitherSeqRecord\";\nimport { bytesToHex } from \"./hex\";\nimport { LKRPCommand } from \"./LKRPCommand\";\n\ntype ParserValue = Either<\n LKRPParsingError,\n | { tag: GeneralTags.Null; value: null }\n | { tag: GeneralTags.Int; value: number }\n | { tag: GeneralTags.Hash; value: Uint8Array }\n | { tag: GeneralTags.Signature; value: Uint8Array }\n | { tag: GeneralTags.String; value: string }\n | { tag: GeneralTags.Bytes; value: Uint8Array }\n | { tag: GeneralTags.PublicKey; value: Uint8Array }\n | { tag: CommandTags; value: Uint8Array }\n | {\n tag: Exclude<number, GeneralTags | CommandTags>;\n value: null | number | Uint8Array;\n }\n>;\n\ntype Parser = Generator<ParserValue, ParserValue, void>;\n\nconst COMMAND_COUNT_LENGTH = 3;\n\nexport class TLVParser {\n private readonly bytes: Uint8Array;\n private readonly parser: Parser;\n private offset = 0;\n\n constructor(bytes: Uint8Array) {\n this.bytes = bytes;\n this.parser = this.parseTLV(bytes);\n }\n\n get state() {\n return {\n offset: this.offset,\n isDone: this.offset >= this.bytes.length,\n };\n }\n\n parse(): ParserValue {\n return this.parser.next().value;\n }\n\n tlvEncoded(\n fn: () => Either<LKRPParsingError, unknown>,\n ): Either<LKRPParsingError, Uint8Array> {\n const start = this.offset;\n return fn().map(() => this.bytes.slice(start, this.offset));\n }\n\n parseNull(): Either<LKRPParsingError, null> {\n return this.parse().chain((next) =>\n next.tag !== GeneralTags.Null\n ? Left(new LKRPParsingError(\"Expected null\"))\n : Right(next.value),\n );\n }\n\n parseInt(): Either<LKRPParsingError, number> {\n return this.parse().chain((next) =>\n next.tag !== GeneralTags.Int\n ? Left(new LKRPParsingError(\"Expected a number\"))\n : Right(next.value),\n );\n }\n\n parseHash(): Either<LKRPParsingError, Uint8Array> {\n return this.parse().chain((next) =>\n next.tag !== GeneralTags.Hash\n ? Left(new LKRPParsingError(\"Expected a hash\"))\n : Right(next.value),\n );\n }\n\n parseSignature(): Either<LKRPParsingError, Uint8Array> {\n return this.parse().chain((next) =>\n next.tag !== GeneralTags.Signature\n ? Left(new LKRPParsingError(\"Expected a signature\"))\n : Right(next.value),\n );\n }\n\n parseString(): Either<LKRPParsingError, string> {\n return this.parse().chain((next) =>\n next.tag !== GeneralTags.String\n ? Left(new LKRPParsingError(\"Expected a string\"))\n : Right(next.value),\n );\n }\n\n parseBytes(): Either<LKRPParsingError, Uint8Array> {\n return this.parse().chain((next) =>\n next.tag !== GeneralTags.Bytes\n ? Left(new LKRPParsingError(\"Expected bytes\"))\n : Right(next.value),\n );\n }\n\n parsePublicKey(): Either<LKRPParsingError, Uint8Array> {\n return this.parse().chain((next) =>\n next.tag !== GeneralTags.PublicKey\n ? Left(new LKRPParsingError(\"Expected a public key\"))\n : Right(next.value),\n );\n }\n\n parseCommandBytes(): Either<LKRPParsingError, Uint8Array> {\n return this.parse().chain(({ tag, value }) =>\n tag < 0x10 || tag > 0x3f || !(value instanceof Uint8Array)\n ? Left(\n new LKRPParsingError(\n `Invalid command type: 0x${tag.toString(16).padStart(2, \"0\")}`,\n ),\n )\n : Right(value),\n );\n }\n\n // https://ledgerhq.atlassian.net/wiki/spaces/TA/pages/4105207815/ARCH+LKRP+-+v1+specifications#Commands\n parseCommandData(): Either<LKRPParsingError, LKRPCommandData> {\n const bytes = this.parseCommandBytes();\n const end = this.offset;\n\n return bytes\n .chain<LKRPParsingError, LKRPCommandData>((value) => {\n const type = value[0];\n this.offset -= value.length - 2; // Adjust offset to the start of the command\n switch (type) {\n // https://ledgerhq.atlassian.net/wiki/spaces/TA/pages/4105207815/ARCH+LKRP+-+v1+specifications#Seed-(0x10)\n case CommandTags.Seed:\n return eitherSeqRecord({\n type,\n topic: () => this.parseBytes(),\n protocolVersion: () => this.parseInt(),\n groupKey: () => this.parsePublicKey(),\n initializationVector: () => this.parseBytes(),\n encryptedXpriv: () => this.parseBytes(),\n ephemeralPublicKey: () => this.parsePublicKey(),\n });\n\n // https://ledgerhq.atlassian.net/wiki/spaces/TA/pages/4105207815/ARCH+LKRP+-+v1+specifications#AddMember-(0x11)\n case CommandTags.AddMember:\n return eitherSeqRecord({\n type,\n name: () => this.parseString(),\n publicKey: () => this.parsePublicKey(),\n permissions: () => this.parseInt(),\n });\n\n // https://ledgerhq.atlassian.net/wiki/spaces/TA/pages/4105207815/ARCH+LKRP+-+v1+specifications#PublishKey-(0x12)\n case CommandTags.PublishKey:\n return eitherSeqRecord({\n type,\n initializationVector: () => this.parseBytes(),\n encryptedXpriv: () => this.parseBytes(),\n recipient: () => this.parsePublicKey(),\n ephemeralPublicKey: () => this.parsePublicKey(),\n });\n\n // https://ledgerhq.atlassian.net/wiki/spaces/TA/pages/4105207815/ARCH+LKRP+-+v1+specifications#Derive-(0x15)\n case CommandTags.Derive:\n return eitherSeqRecord({\n type,\n path: () => this.parseBytes().map(derivationPathAsString),\n groupKey: () => this.parsePublicKey(),\n initializationVector: () => this.parseBytes(),\n encryptedXpriv: () => this.parseBytes(),\n ephemeralPublicKey: () => this.parsePublicKey(),\n });\n\n default:\n return Left(\n new LKRPParsingError(\n `Unsupported command type: 0x${type?.toString(16).padStart(2, \"0\")}`,\n ),\n );\n }\n })\n .chain((data) =>\n this.offset === end\n ? Right(data)\n : Left(new LKRPParsingError(\"Command was parsed incorrectly\")),\n );\n }\n\n parseCommands(): Either<LKRPParsingError, LKRPCommand[]> {\n return this.parse()\n .chain((next) =>\n next.tag !== GeneralTags.Int\n ? Left(new LKRPParsingError(\"Expected a command count\"))\n : Right(next.value),\n )\n .chain((count) => {\n const commands: LKRPCommand[] = [];\n for (let i = 0; i < count; i++) {\n const command = this.parseCommandBytes();\n if (command.isLeft()) return command;\n command.ifRight((value) => commands.push(new LKRPCommand(value)));\n }\n return Right(commands);\n });\n }\n\n // https://ledgerhq.atlassian.net/wiki/spaces/TA/pages/4105207815/ARCH+LKRP+-+v1+specifications#Block\n parseBlockData(): Either<LKRPParsingError, LKRPBlockParsedData> {\n const startOffset = this.offset;\n return this.parseInt().chain((_version) =>\n eitherSeqRecord({\n parent: () => this.parseHash().map(bytesToHex),\n issuer: () => this.parsePublicKey(),\n header: () =>\n Right(\n this.bytes.slice(startOffset, this.offset + COMMAND_COUNT_LENGTH),\n ),\n commands: () => this.parseCommands(),\n signature: () => this.tlvEncoded(() => this.parseSignature()),\n }),\n );\n }\n\n private *parseTLV(bytes: Uint8Array): Parser {\n while (true) {\n const tag = bytes[this.offset];\n if (typeof tag === \"undefined\") {\n return Left(new LKRPParsingError(\"Unexpected end of TLV\"));\n }\n this.offset++;\n const length = bytes[this.offset];\n if (typeof length === \"undefined\") {\n return Left(\n new LKRPParsingError(\"Invalid end of TLV, expected length\"),\n );\n }\n this.offset++;\n const valueEnd = this.offset + length;\n const value = bytes.slice(this.offset, valueEnd);\n if (valueEnd > bytes.length) {\n return Left(new LKRPParsingError(\"Invalid end of TLV value\"));\n }\n this.offset = valueEnd;\n\n switch (tag) {\n case GeneralTags.Null:\n yield length > 0\n ? Left(new LKRPParsingError(\"Invalid null length\"))\n : Right({ tag, value: null });\n break;\n\n case GeneralTags.Int:\n {\n const dataView = new DataView(value.buffer);\n switch (value.length) {\n case 1:\n yield Right({ tag, value: dataView.getUint8(0) });\n break;\n case 2:\n yield Right({ tag, value: dataView.getUint16(0, false) }); // Big-endian\n break;\n case 4:\n yield Right({ tag, value: dataView.getUint32(0, false) }); // Big-endian\n break;\n default:\n yield Left(new LKRPParsingError(\"Unsupported integer length\"));\n }\n }\n break;\n\n case GeneralTags.String:\n yield value.length === 0\n ? Left(new LKRPParsingError(\"Empty string value\"))\n : Right({ tag, value: new TextDecoder().decode(value) });\n break;\n\n case GeneralTags.Hash:\n case GeneralTags.Signature:\n case GeneralTags.Bytes:\n case GeneralTags.PublicKey:\n yield Right({ tag, value });\n break;\n\n default:\n yield Right({ tag, value: new Uint8Array([tag, length, ...value]) });\n break;\n }\n }\n }\n}\n"],
|
|
5
|
+
"mappings": "AAAA,OAAsB,QAAAA,EAAM,SAAAC,MAAa,YAEzC,OAAS,oBAAAC,MAAwB,yBAGjC,OAAS,eAAAC,EAAa,eAAAC,MAAmB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Ac,EAAK,MAAOa,EAAS,UAAU,EAAG,EAAK,CAAE,CAAC,EACxD,MACF,QACE,MAAM5B,EAAK,IAAIE,EAAiB,4BAA4B,CAAC,CACjE,CACF,CACA,MAEF,KAAKE,EAAY,OACf,MAAMY,EAAM,SAAW,EACnBhB,EAAK,IAAIE,EAAiB,oBAAoB,CAAC,EAC/CD,EAAM,CAAE,IAAAc,EAAK,MAAO,IAAI,YAAY,EAAE,OAAOC,CAAK,CAAE,CAAC,EACzD,MAEF,KAAKZ,EAAY,KACjB,KAAKA,EAAY,UACjB,KAAKA,EAAY,MACjB,KAAKA,EAAY,UACf,MAAMH,EAAM,CAAE,IAAAc,EAAK,MAAAC,CAAM,CAAC,EAC1B,MAEF,QACE,MAAMf,EAAM,CAAE,IAAAc,EAAK,MAAO,IAAI,WAAW,CAACA,EAAKW,EAAQ,GAAGV,CAAK,CAAC,CAAE,CAAC,EACnE,KACJ,CACF,CACF,CACF",
|
|
6
|
+
"names": ["Left", "Right", "LKRPParsingError", "CommandTags", "GeneralTags", "derivationPathAsString", "eitherSeqRecord", "bytesToHex", "LKRPCommand", "COMMAND_COUNT_LENGTH", "TLVParser", "bytes", "fn", "start", "next", "tag", "value", "end", "type", "data", "count", "commands", "i", "command", "startOffset", "_version", "length", "valueEnd", "dataView"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{Left as s,Right as o}from"purify-ts";import{LKRPParsingError as i}from"../../api/app-binder/Errors";import{
|
|
1
|
+
import{Left as s,Right as o}from"purify-ts";import{LKRPParsingError as i}from"../../api/app-binder/Errors";import{CommandTags as r,GeneralTags as e}from"../models/Tags";import{LKRPCommand as d}from"./LKRPCommand";import{TLVParser as n}from"./TLVParser";describe("TLVParser",()=>{describe("Block Data Parsing",()=>{describe("parseCommands",()=>{it("should parse has many commands has specified by the command count value",()=>{const a=new n(new Uint8Array([e.Int,1,2,r.AddMember,3,e.Int,1,1,r.Seed,3,e.Int,1,2])).parseCommands();expect(a).toStrictEqual(o([new d(new Uint8Array([r.AddMember,3,e.Int,1,1])),new d(new Uint8Array([r.Seed,3,e.Int,1,2]))]))})}),describe("parseBlockData",()=>{it("should parse a valid block data",()=>{const a=new n(Uint8Array.from([[e.Int,1,1],[e.Hash,3,1,2,3],[e.PublicKey,3,4,5,6],[e.Int,1,2],[r.AddMember,3,e.Int,1,1],[r.Seed,3,e.Int,1,2],[e.Signature,3,7,8,9]].flat())).parseBlockData();expect(a).toStrictEqual(o({parent:"010203",issuer:new Uint8Array([4,5,6]),header:Uint8Array.from([[e.Int,1,1],[e.Hash,3,1,2,3],[e.PublicKey,3,4,5,6],[e.Int,1,2]].flat()),commands:[new d(new Uint8Array([r.AddMember,3,e.Int,1,1])),new d(new Uint8Array([r.Seed,3,e.Int,1,2]))],signature:Uint8Array.from([e.Signature,3,7,8,9])}))}),it("should fail if the block data is invalid",()=>{const a=new n(new Uint8Array([])).parseBlockData();expect(a).toEqual(s(new i("Unexpected end of TLV")))})})}),describe("Command Data Parsing",()=>{describe("parseCommandBytes",()=>{it("should parse a valid command bytes",()=>{const a=new n(new Uint8Array([r.AddMember,3,1,2,3])).parseCommandBytes();expect(a).toEqual(o(new Uint8Array([r.AddMember,3,1,2,3])))}),it("should fail if the tag is not a command",()=>{const a=new n(new Uint8Array([e.Int,1,1])).parseCommandBytes();expect(a).toEqual(s(new i("Invalid command type: 0x01")))})}),describe("Parse Seed Command Data",()=>{it("should parse a valid seed command data",()=>{const t=new Uint8Array([e.Bytes,3,1,2,3,e.Int,2,1,2,e.PublicKey,3,2,4,6,e.Bytes,3,3,5,7,e.Bytes,3,4,8,16,e.PublicKey,3,10,11,12]),x=new n(new Uint8Array([r.Seed,t.length,...t])).parseCommandData();expect(x).toStrictEqual(o({type:r.Seed,topic:new Uint8Array([1,2,3]),protocolVersion:258,groupKey:new Uint8Array([2,4,6]),initializationVector:new Uint8Array([3,5,7]),encryptedXpriv:new Uint8Array([4,8,16]),ephemeralPublicKey:new Uint8Array([10,11,12])}))}),it("should fail if the command data is invalid",()=>{const t=new Uint8Array([e.Signature,3,1,2,3]),a=new Uint8Array([e.Bytes,3,1,2,3]),x=new n(new Uint8Array([r.Seed,t.length,...t])),p=new n(new Uint8Array([r.Seed,a.length,...a])),c=x.parseCommandData(),l=p.parseCommandData();expect(c).toEqual(s(new i("Expected bytes"))),expect(l).toEqual(s(new i("Unexpected end of TLV")))})}),describe("Parse AddMember Command Data",()=>{it("should parse a valid add member command data",()=>{const t=new Uint8Array([e.String,5,65,108,105,99,101,e.PublicKey,3,1,2,3,e.Int,1,1]),x=new n(new Uint8Array([r.AddMember,t.length,...t])).parseCommandData();expect(x).toStrictEqual(o({type:r.AddMember,name:"Alice",publicKey:new Uint8Array([1,2,3]),permissions:1}))}),it("should fail if the command data is invalid",()=>{const t=new Uint8Array([e.Bytes,3,1,2,3]),a=new Uint8Array([e.String,5,65,108,105,99,101]),x=new n(new Uint8Array([r.AddMember,t.length,...t])),p=new n(new Uint8Array([r.AddMember,a.length,...a])),c=x.parseCommandData(),l=p.parseCommandData();expect(c).toEqual(s(new i("Expected a string"))),expect(l).toEqual(s(new i("Unexpected end of TLV")))})}),describe("Parse PublishKey Command Data",()=>{it("should parse a valid publish key command data",()=>{const t=new Uint8Array([e.Bytes,3,1,2,3,e.Bytes,3,4,5,6,e.PublicKey,3,3,5,7,e.PublicKey,3,8,9,10]),x=new n(new Uint8Array([r.PublishKey,t.length,...t])).parseCommandData();expect(x).toStrictEqual(o({type:r.PublishKey,initializationVector:new Uint8Array([1,2,3]),encryptedXpriv:new Uint8Array([4,5,6]),recipient:new Uint8Array([3,5,7]),ephemeralPublicKey:new Uint8Array([8,9,10])}))}),it("should fail if the command data is invalid",()=>{const t=new Uint8Array([e.Int,2,1,2]),a=new Uint8Array([e.Bytes,3,1,2,3]),x=new n(new Uint8Array([r.PublishKey,t.length,...t])),p=new n(new Uint8Array([r.PublishKey,a.length,...a])),c=x.parseCommandData(),l=p.parseCommandData();expect(c).toEqual(s(new i("Expected bytes"))),expect(l).toEqual(s(new i("Unexpected end of TLV")))})}),describe("Parse Derive Command Data",()=>{it("should parse a valid derive command data",()=>{const t=new Uint8Array([e.Bytes,4,0,0,0,1,e.PublicKey,3,4,5,6,e.Bytes,3,3,5,7,e.Bytes,3,8,9,10,e.PublicKey,3,10,11,12]),x=new n(new Uint8Array([r.Derive,t.length,...t])).parseCommandData();expect(x).toStrictEqual(o({type:r.Derive,path:"m/1",groupKey:new Uint8Array([4,5,6]),initializationVector:new Uint8Array([3,5,7]),encryptedXpriv:new Uint8Array([8,9,10]),ephemeralPublicKey:new Uint8Array([10,11,12])}))}),it("should fail if the command data is invalid",()=>{const t=new Uint8Array([e.Int,2,1,2]),a=new Uint8Array([e.Bytes,3,1,2,3]),x=new n(new Uint8Array([r.Derive,t.length,...t])),p=new n(new Uint8Array([r.Derive,a.length,...a])),c=x.parseCommandData(),l=p.parseCommandData();expect(c).toEqual(s(new i("Expected bytes"))),expect(l).toEqual(s(new i("Unexpected end of TLV")))})}),it("should fail on unsupported command type",()=>{const a=new n(new Uint8Array([63,1,1])).parseCommandData();expect(a).toEqual(s(new i("Unsupported command type: 0x3f")))})}),describe("General Types Parsing",()=>{describe("parse",()=>{it("should parse a valid TLV structure",()=>{const t=new n(new Uint8Array([e.Int,1,1,e.Bytes,0])),a=t.parse(),x=t.parse();expect(a).toEqual(o({tag:e.Int,value:1})),expect(x).toEqual(o({tag:e.Bytes,value:new Uint8Array([])}))}),it("should fail on invalid TLV structure",()=>{const t=new n(new Uint8Array([])),a=new n(new Uint8Array([e.Int])),x=new n(new Uint8Array([e.Int,2])),p=t.parse(),c=a.parse(),l=x.parse();expect(p).toEqual(s(new i("Unexpected end of TLV"))),expect(c).toEqual(s(new i("Invalid end of TLV, expected length"))),expect(l).toEqual(s(new i("Invalid end of TLV value")))})}),describe("parseNull",()=>{it("should parse a null value",()=>{const a=new n(new Uint8Array([e.Null,0])).parseNull();expect(a).toEqual(o(null))}),it("should fail if the tag is not null",()=>{const a=new n(new Uint8Array([e.Int,1,1])).parseNull();expect(a).toEqual(s(new i("Expected null")))}),it("should fail if the format is invalid",()=>{const a=new n(new Uint8Array([e.Null,1,2])).parseNull();expect(a).toEqual(s(new i("Invalid null length")))})}),describe("parseInt",()=>{it("should parse big endian integer values",()=>{const t=new n(new Uint8Array([e.Int,1,1,e.Int,2,1,0,e.Int,4,1,0,0,0])),a=t.parseInt(),x=t.parseInt(),p=t.parseInt();expect(a).toEqual(o(1)),expect(x).toEqual(o(256)),expect(p).toEqual(o(16777216))}),it("should fail if the tag is not an integer",()=>{const a=new n(new Uint8Array([e.Bytes,1,1])).parseInt();expect(a).toEqual(s(new i("Expected a number")))}),it("should fail if the integer is not 1, 2, or 4 bytes",()=>{const a=new n(new Uint8Array([e.Int,3,1,2,3])).parseInt();expect(a).toEqual(s(new i("Unsupported integer length")))})}),describe("parseHash",()=>{it("should parse a hash value",()=>{const a=new n(new Uint8Array([e.Hash,3,1,2,3])).parseHash();expect(a).toEqual(o(new Uint8Array([1,2,3])))}),it("should fail if the tag is not a hash",()=>{const a=new n(new Uint8Array([e.Int,1,1])).parseHash();expect(a).toEqual(s(new i("Expected a hash")))})}),describe("parseSignature",()=>{it("should parse a signature value",()=>{const a=new n(new Uint8Array([e.Signature,3,1,2,3])).parseSignature();expect(a).toEqual(o(new Uint8Array([1,2,3])))}),it("should fail if the tag is not a signature",()=>{const a=new n(new Uint8Array([e.Int,1,1])).parseSignature();expect(a).toEqual(s(new i("Expected a signature")))})}),describe("parseString",()=>{it("should parse a string value",()=>{const a=new n(new Uint8Array([e.String,5,72,101,108,108,111])).parseString();expect(a).toEqual(o("Hello"))}),it("should fail if the tag is not a string",()=>{const a=new n(new Uint8Array([e.Int,1,1])).parseString();expect(a).toEqual(s(new i("Expected a string")))})}),describe("parseBytes",()=>{it("should parse a bytes value",()=>{const a=new n(new Uint8Array([e.Bytes,3,1,2,3])).parseBytes();expect(a).toEqual(o(new Uint8Array([1,2,3])))}),it("should fail if the tag is not bytes",()=>{const a=new n(new Uint8Array([e.Int,1,1])).parseBytes();expect(a).toEqual(s(new i("Expected bytes")))})}),describe("parsePublicKey",()=>{it("should parse a public key value",()=>{const a=new n(new Uint8Array([e.PublicKey,3,1,2,3])).parsePublicKey();expect(a).toEqual(o(new Uint8Array([1,2,3])))}),it("should fail if the tag is not a public key",()=>{const a=new n(new Uint8Array([e.Int,1,1])).parsePublicKey();expect(a).toEqual(s(new i("Expected a public key")))})})})});
|
|
2
2
|
//# sourceMappingURL=TLVParser.test.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/internal/utils/TLVParser.test.ts"],
|
|
4
|
-
"sourcesContent": ["import { Left, Right } from \"purify-ts\";\n\nimport { LKRPParsingError } from \"@api/app-binder/Errors\";\n\nimport { LKRPCommand } from \"./LKRPCommand\";\nimport { TLVParser } from \"./TLVParser\";\nimport { CommandTags, GeneralTags } from \"./TLVTags\";\n\ndescribe(\"TLVParser\", () => {\n describe(\"Block Data Parsing\", () => {\n describe(\"parseCommands\", () => {\n it(\"should parse has many commands has specified by the command count value\", () => {\n // GIVEN\n const parser = new TLVParser(\n new Uint8Array([\n ...[GeneralTags.Int, 1, 0x02], // Command count: 2\n ...[CommandTags.AddMember, 3, ...[GeneralTags.Int, 1, 0x01]], // First command\n ...[CommandTags.Seed, 3, ...[GeneralTags.Int, 1, 0x02]], // Second command\n ]),\n );\n // WHEN\n const commands = parser.parseCommands();\n\n // THEN\n expect(commands).toStrictEqual(\n Right([\n new LKRPCommand(\n new Uint8Array([\n CommandTags.AddMember,\n 3,\n ...[GeneralTags.Int, 1, 0x01],\n ]),\n ),\n new LKRPCommand(\n new Uint8Array([\n CommandTags.Seed,\n 3,\n ...[GeneralTags.Int, 1, 0x02],\n ]),\n ),\n ]),\n );\n });\n });\n\n describe(\"parseBlockData\", () => {\n it(\"should parse a valid block data\", () => {\n // GIVEN\n const parser = new TLVParser(\n Uint8Array.from(\n [\n [GeneralTags.Int, 1, 0x01], // Version\n [GeneralTags.Hash, 3, 0x01, 0x02, 0x03], // Parent\n [GeneralTags.PublicKey, 3, 0x04, 0x05, 0x06], // Issuer\n [GeneralTags.Int, 1, 0x02], // Command count: 2\n [CommandTags.AddMember, 3, ...[GeneralTags.Int, 1, 0x01]], // First command\n [CommandTags.Seed, 3, ...[GeneralTags.Int, 1, 0x02]], // Second command\n [GeneralTags.Signature, 3, 0x07, 0x08, 0x09], // Signature\n ].flat(),\n ),\n );\n // WHEN\n const blockData = parser.parseBlockData();\n\n // THEN\n expect(blockData).toStrictEqual(\n Right({\n parent: \"010203\",\n issuer: new Uint8Array([0x04, 0x05, 0x06]),\n header: Uint8Array.from(\n [\n [GeneralTags.Int, 1, 0x01], // Version\n [GeneralTags.Hash, 3, 0x01, 0x02, 0x03], // Parent\n [GeneralTags.PublicKey, 3, 0x04, 0x05, 0x06], // Issuer\n [GeneralTags.Int, 1, 0x02], // Command count: 2\n ].flat(),\n ),\n\n commands: [\n new LKRPCommand(\n new Uint8Array([\n CommandTags.AddMember,\n 3,\n ...[GeneralTags.Int, 1, 0x01],\n ]),\n ),\n new LKRPCommand(\n new Uint8Array([\n CommandTags.Seed,\n 3,\n ...[GeneralTags.Int, 1, 0x02],\n ]),\n ),\n ],\n signature: Uint8Array.from([\n GeneralTags.Signature,\n 3,\n 0x07,\n 0x08,\n 0x09,\n ]),\n }),\n );\n });\n\n it(\"should fail if the block data is invalid\", () => {\n // GIVEN\n const parser = new TLVParser(new Uint8Array([]));\n // WHEN\n const blockData = parser.parseBlockData();\n // THEN\n expect(blockData).toEqual(\n Left(new LKRPParsingError(\"Unexpected end of TLV\")),\n );\n });\n });\n });\n\n describe(\"Command Data Parsing\", () => {\n describe(\"parseCommandBytes\", () => {\n it(\"should parse a valid command bytes\", () => {\n // GIVEN\n const parser = new TLVParser(\n new Uint8Array([CommandTags.AddMember, 3, 0x01, 0x02, 0x03]),\n );\n // WHEN\n const value = parser.parseCommandBytes();\n // THEN\n expect(value).toEqual(\n Right(new Uint8Array([CommandTags.AddMember, 3, 0x01, 0x02, 0x03])),\n );\n });\n\n it(\"should fail if the tag is not a command\", () => {\n // GIVEN\n const parser = new TLVParser(\n new Uint8Array([GeneralTags.Int, 1, 0x01]),\n );\n // WHEN\n const value = parser.parseCommandBytes();\n // THEN\n expect(value).toEqual(\n Left(new LKRPParsingError(`Invalid command type: 0x01`)),\n );\n });\n });\n\n describe(\"Parse Seed Command Data\", () => {\n it(\"should parse a valid seed command data\", () => {\n // GIVEN\n const value = new Uint8Array([\n ...[GeneralTags.Bytes, 3, 0x01, 0x02, 0x03], // Topic\n ...[GeneralTags.Int, 2, 0x01, 0x02], // Protocol Version\n ...[GeneralTags.PublicKey, 3, 0x02, 0x04, 0x06], // Group Key\n ...[GeneralTags.Bytes, 3, 0x03, 0x05, 0x07], // Initialization Vector\n ...[GeneralTags.Bytes, 3, 0x04, 0x08, 0x10], // Encrypted xpriv\n ...[GeneralTags.PublicKey, 3, 0x0a, 0x0b, 0x0c], // Ephemeral Public Key\n ]);\n const parser = new TLVParser(\n new Uint8Array([CommandTags.Seed, value.length, ...value]),\n );\n\n // WHEN\n const parsed = parser.parseCommandData();\n\n // THEN\n expect(parsed).toStrictEqual(\n Right({\n type: CommandTags.Seed,\n topic: new Uint8Array([0x01, 0x02, 0x03]),\n protocolVersion: 258, // 0x0102 in big-endian\n groupKey: new Uint8Array([0x02, 0x04, 0x06]),\n initializationVector: new Uint8Array([0x03, 0x05, 0x07]),\n encryptedXpriv: new Uint8Array([0x04, 0x08, 0x10]),\n ephemeralPublicKey: new Uint8Array([0x0a, 0x0b, 0x0c]),\n }),\n );\n });\n\n it(\"should fail if the command data is invalid\", () => {\n // GIVEN\n const value1 = new Uint8Array([\n ...[GeneralTags.Signature, 3, 0x01, 0x02, 0x03], // Wrong type for Topic\n ]);\n const value2 = new Uint8Array([\n ...[GeneralTags.Bytes, 3, 0x01, 0x02, 0x03], // Correct type but the other fields are missing\n ]);\n const parser1 = new TLVParser(\n new Uint8Array([CommandTags.Seed, value1.length, ...value1]),\n );\n const parser2 = new TLVParser(\n new Uint8Array([CommandTags.Seed, value2.length, ...value2]),\n );\n\n // WHEN\n const parsed1 = parser1.parseCommandData();\n const parsed2 = parser2.parseCommandData();\n\n // THEN\n expect(parsed1).toEqual(Left(new LKRPParsingError(\"Expected bytes\")));\n expect(parsed2).toEqual(\n Left(new LKRPParsingError(\"Unexpected end of TLV\")),\n );\n });\n });\n\n describe(\"Parse AddMember Command Data\", () => {\n it(\"should parse a valid add member command data\", () => {\n // GIVEN\n const value = new Uint8Array([\n ...[GeneralTags.String, 5, 0x41, 0x6c, 0x69, 0x63, 0x65], // Name \"Alice\"\n ...[GeneralTags.PublicKey, 3, 0x01, 0x02, 0x03], // Public Key\n ...[GeneralTags.Int, 1, 0x01], // Permissions\n ]);\n const parser = new TLVParser(\n new Uint8Array([CommandTags.AddMember, value.length, ...value]),\n );\n\n // WHEN\n const parsed = parser.parseCommandData();\n\n // THEN\n expect(parsed).toStrictEqual(\n Right({\n type: CommandTags.AddMember,\n name: \"Alice\",\n publicKey: new Uint8Array([0x01, 0x02, 0x03]),\n permissions: 1,\n }),\n );\n });\n\n it(\"should fail if the command data is invalid\", () => {\n // GIVEN\n const value1 = new Uint8Array([\n ...[GeneralTags.Bytes, 3, 0x01, 0x02, 0x03], // Wrong type for Name\n ]);\n const value2 = new Uint8Array([\n ...[GeneralTags.String, 5, 0x41, 0x6c, 0x69, 0x63, 0x65], // Correct type but the other fields are missing\n ]);\n const parser1 = new TLVParser(\n new Uint8Array([CommandTags.AddMember, value1.length, ...value1]),\n );\n const parser2 = new TLVParser(\n new Uint8Array([CommandTags.AddMember, value2.length, ...value2]),\n );\n\n // WHEN\n const parsed1 = parser1.parseCommandData();\n const parsed2 = parser2.parseCommandData();\n\n // THEN\n expect(parsed1).toEqual(\n Left(new LKRPParsingError(\"Expected a string\")),\n );\n expect(parsed2).toEqual(\n Left(new LKRPParsingError(\"Unexpected end of TLV\")),\n );\n });\n });\n\n describe(\"Parse PublishKey Command Data\", () => {\n it(\"should parse a valid publish key command data\", () => {\n // GIVEN\n const value = new Uint8Array([\n ...[GeneralTags.Bytes, 3, 0x01, 0x02, 0x03], // Initialization Vector\n ...[GeneralTags.Bytes, 3, 0x04, 0x05, 0x06], // Encrypted xpriv\n ...[GeneralTags.PublicKey, 3, 0x03, 0x05, 0x07], // Recipient Public Key\n ...[GeneralTags.PublicKey, 3, 0x08, 0x09, 0x0a], // Ephemeral Public Key\n ]);\n const parser = new TLVParser(\n new Uint8Array([CommandTags.PublishKey, value.length, ...value]),\n );\n\n // WHEN\n const parsed = parser.parseCommandData();\n\n // THEN\n expect(parsed).toStrictEqual(\n Right({\n type: CommandTags.PublishKey,\n initializationVector: new Uint8Array([0x01, 0x02, 0x03]),\n encryptedXpriv: new Uint8Array([0x04, 0x05, 0x06]),\n recipient: new Uint8Array([0x03, 0x05, 0x07]),\n ephemeralPublicKey: new Uint8Array([0x08, 0x09, 0x0a]),\n }),\n );\n });\n\n it(\"should fail if the command data is invalid\", () => {\n // GIVEN\n const value1 = new Uint8Array([\n ...[GeneralTags.Int, 2, 0x01, 0x02], // Wrong type for Initialization Vector\n ]);\n const value2 = new Uint8Array([\n ...[GeneralTags.Bytes, 3, 0x01, 0x02, 0x03], // Correct type but the other fields are missing\n ]);\n const parser1 = new TLVParser(\n new Uint8Array([CommandTags.PublishKey, value1.length, ...value1]),\n );\n const parser2 = new TLVParser(\n new Uint8Array([CommandTags.PublishKey, value2.length, ...value2]),\n );\n\n // WHEN\n const parsed1 = parser1.parseCommandData();\n const parsed2 = parser2.parseCommandData();\n\n // THEN\n expect(parsed1).toEqual(Left(new LKRPParsingError(\"Expected bytes\")));\n expect(parsed2).toEqual(\n Left(new LKRPParsingError(\"Unexpected end of TLV\")),\n );\n });\n });\n\n describe(\"Parse Derive Command Data\", () => {\n it(\"should parse a valid derive command data\", () => {\n // GIVEN\n const value = new Uint8Array([\n ...[GeneralTags.Bytes, 4, 0x00, 0x00, 0x00, 0x01], // Path\n ...[GeneralTags.PublicKey, 3, 0x04, 0x05, 0x06], // Group Key\n ...[GeneralTags.Bytes, 3, 0x03, 0x05, 0x07], // Initialization Vector\n ...[GeneralTags.Bytes, 3, 0x08, 0x09, 0x0a], // Encrypted xpriv\n ...[GeneralTags.PublicKey, 3, 0x0a, 0x0b, 0x0c], // Ephemeral Public Key\n ]);\n const parser = new TLVParser(\n new Uint8Array([CommandTags.Derive, value.length, ...value]),\n );\n\n // WHEN\n const parsed = parser.parseCommandData();\n\n // THEN\n expect(parsed).toStrictEqual(\n Right({\n type: CommandTags.Derive,\n path: \"m/1\",\n groupKey: new Uint8Array([0x04, 0x05, 0x06]),\n initializationVector: new Uint8Array([0x03, 0x05, 0x07]),\n encryptedXpriv: new Uint8Array([0x08, 0x09, 0x0a]),\n ephemeralPublicKey: new Uint8Array([0x0a, 0x0b, 0x0c]),\n }),\n );\n });\n\n it(\"should fail if the command data is invalid\", () => {\n // GIVEN\n const value1 = new Uint8Array([\n ...[GeneralTags.Int, 2, 0x01, 0x02], // Wrong type for Path\n ]);\n const value2 = new Uint8Array([\n ...[GeneralTags.Bytes, 3, 0x01, 0x02, 0x03], // Correct type but the other fields are missing\n ]);\n const parser1 = new TLVParser(\n new Uint8Array([CommandTags.Derive, value1.length, ...value1]),\n );\n const parser2 = new TLVParser(\n new Uint8Array([CommandTags.Derive, value2.length, ...value2]),\n );\n\n // WHEN\n const parsed1 = parser1.parseCommandData();\n const parsed2 = parser2.parseCommandData();\n\n // THEN\n expect(parsed1).toEqual(Left(new LKRPParsingError(\"Expected bytes\")));\n expect(parsed2).toEqual(\n Left(new LKRPParsingError(\"Unexpected end of TLV\")),\n );\n });\n });\n\n it(\"should fail on unsupported command type\", () => {\n // GIVEN\n const parser = new TLVParser(new Uint8Array([0x3f, 1, 0x01]));\n // WHEN\n const parsed = parser.parseCommandData();\n // THEN\n expect(parsed).toEqual(\n Left(new LKRPParsingError(\"Unsupported command type: 0x3f\")),\n );\n });\n });\n\n describe(\"General Types Parsing\", () => {\n describe(\"parse\", () => {\n it(\"should parse a valid TLV structure\", () => {\n // GIVEN\n const parser = new TLVParser(\n new Uint8Array([GeneralTags.Int, 1, 0x01, GeneralTags.Bytes, 0]),\n );\n // WHEN\n const value1 = parser.parse();\n const value2 = parser.parse();\n // THEN\n expect(value1).toEqual(Right({ tag: GeneralTags.Int, value: 1 }));\n expect(value2).toEqual(\n Right({ tag: GeneralTags.Bytes, value: new Uint8Array([]) }),\n );\n });\n\n it(\"should fail on invalid TLV structure\", () => {\n // GIVEN\n const parser1 = new TLVParser(new Uint8Array([]));\n const parser2 = new TLVParser(new Uint8Array([GeneralTags.Int]));\n const parser3 = new TLVParser(new Uint8Array([GeneralTags.Int, 2]));\n // WHEN\n const value1 = parser1.parse();\n const value2 = parser2.parse();\n const value3 = parser3.parse();\n // THEN\n expect(value1).toEqual(\n Left(new LKRPParsingError(\"Unexpected end of TLV\")),\n );\n expect(value2).toEqual(\n Left(new LKRPParsingError(\"Invalid end of TLV, expected length\")),\n );\n expect(value3).toEqual(\n Left(new LKRPParsingError(\"Invalid end of TLV value\")),\n );\n });\n });\n\n describe(\"parseNull\", () => {\n it(\"should parse a null value\", () => {\n // GIVEN\n const parser = new TLVParser(new Uint8Array([GeneralTags.Null, 0]));\n // WHEN\n const value = parser.parseNull();\n // THEN\n expect(value).toEqual(Right(null));\n });\n\n it(\"should fail if the tag is not null\", () => {\n // GIVEN\n const parser = new TLVParser(\n new Uint8Array([GeneralTags.Int, 1, 0x01]),\n );\n // WHEN\n const value = parser.parseNull();\n // THEN\n expect(value).toEqual(Left(new LKRPParsingError(\"Expected null\")));\n });\n\n it(\"should fail if the format is invalid\", () => {\n // GIVEN\n const parser = new TLVParser(\n new Uint8Array([GeneralTags.Null, 1, 0x02]),\n );\n // WHEN\n const value = parser.parseNull();\n // THEN\n expect(value).toEqual(\n Left(new LKRPParsingError(\"Invalid null length\")),\n );\n });\n });\n\n describe(\"parseInt\", () => {\n it(\"should parse big endian integer values\", () => {\n // GIVEN\n const parser = new TLVParser(\n new Uint8Array([\n ...[GeneralTags.Int, 1, 0x01], // 1\n ...[GeneralTags.Int, 2, 0x01, 0x00], // 256\n ...[GeneralTags.Int, 4, 0x01, 0x00, 0x00, 0x00], // 16777216\n ]),\n );\n // WHEN\n const value1 = parser.parseInt();\n const value2 = parser.parseInt();\n const value4 = parser.parseInt();\n // THEN\n expect(value1).toEqual(Right(1));\n expect(value2).toEqual(Right(256));\n expect(value4).toEqual(Right(16777216));\n });\n\n it(\"should fail if the tag is not an integer\", () => {\n // GIVEN\n const parser = new TLVParser(\n new Uint8Array([GeneralTags.Bytes, 1, 0x01]),\n );\n // WHEN\n const value = parser.parseInt();\n // THEN\n expect(value).toEqual(Left(new LKRPParsingError(\"Expected a number\")));\n });\n\n it(\"should fail if the integer is not 1, 2, or 4 bytes\", () => {\n // GIVEN\n const parser = new TLVParser(\n new Uint8Array([GeneralTags.Int, 3, 0x01, 0x02, 0x03]),\n );\n // WHEN\n const value = parser.parseInt();\n // THEN\n expect(value).toEqual(\n Left(new LKRPParsingError(\"Unsupported integer length\")),\n );\n });\n });\n\n describe(\"parseHash\", () => {\n it(\"should parse a hash value\", () => {\n // GIVEN\n const parser = new TLVParser(\n new Uint8Array([GeneralTags.Hash, 3, 0x01, 0x02, 0x03]),\n );\n // WHEN\n const value = parser.parseHash();\n // THEN\n expect(value).toEqual(Right(new Uint8Array([0x01, 0x02, 0x03])));\n });\n\n it(\"should fail if the tag is not a hash\", () => {\n // GIVEN\n const parser = new TLVParser(\n new Uint8Array([GeneralTags.Int, 1, 0x01]),\n );\n // WHEN\n const value = parser.parseHash();\n // THEN\n expect(value).toEqual(Left(new LKRPParsingError(\"Expected a hash\")));\n });\n });\n\n describe(\"parseSignature\", () => {\n it(\"should parse a signature value\", () => {\n // GIVEN\n const parser = new TLVParser(\n new Uint8Array([GeneralTags.Signature, 3, 0x01, 0x02, 0x03]),\n );\n // WHEN\n const value = parser.parseSignature();\n // THEN\n expect(value).toEqual(Right(new Uint8Array([0x01, 0x02, 0x03])));\n });\n\n it(\"should fail if the tag is not a signature\", () => {\n // GIVEN\n const parser = new TLVParser(\n new Uint8Array([GeneralTags.Int, 1, 0x01]),\n );\n // WHEN\n const value = parser.parseSignature();\n // THEN\n expect(value).toEqual(\n Left(new LKRPParsingError(\"Expected a signature\")),\n );\n });\n });\n\n describe(\"parseString\", () => {\n it(\"should parse a string value\", () => {\n // GIVEN\n const parser = new TLVParser(\n new Uint8Array([GeneralTags.String, 5, 0x48, 0x65, 0x6c, 0x6c, 0x6f]),\n );\n // WHEN\n const value = parser.parseString();\n // THEN\n expect(value).toEqual(Right(\"Hello\"));\n });\n\n it(\"should fail if the tag is not a string\", () => {\n // GIVEN\n const parser = new TLVParser(\n new Uint8Array([GeneralTags.Int, 1, 0x01]),\n );\n // WHEN\n const value = parser.parseString();\n // THEN\n expect(value).toEqual(Left(new LKRPParsingError(\"Expected a string\")));\n });\n });\n\n describe(\"parseBytes\", () => {\n it(\"should parse a bytes value\", () => {\n // GIVEN\n const parser = new TLVParser(\n new Uint8Array([GeneralTags.Bytes, 3, 0x01, 0x02, 0x03]),\n );\n // WHEN\n const value = parser.parseBytes();\n // THEN\n expect(value).toEqual(Right(new Uint8Array([0x01, 0x02, 0x03])));\n });\n\n it(\"should fail if the tag is not bytes\", () => {\n // GIVEN\n const parser = new TLVParser(\n new Uint8Array([GeneralTags.Int, 1, 0x01]),\n );\n // WHEN\n const value = parser.parseBytes();\n // THEN\n expect(value).toEqual(Left(new LKRPParsingError(\"Expected bytes\")));\n });\n });\n\n describe(\"parsePublicKey\", () => {\n it(\"should parse a public key value\", () => {\n // GIVEN\n const parser = new TLVParser(\n new Uint8Array([GeneralTags.PublicKey, 3, 0x01, 0x02, 0x03]),\n );\n // WHEN\n const value = parser.parsePublicKey();\n // THEN\n expect(value).toEqual(Right(new Uint8Array([0x01, 0x02, 0x03])));\n });\n\n it(\"should fail if the tag is not a public key\", () => {\n // GIVEN\n const parser = new TLVParser(\n new Uint8Array([GeneralTags.Int, 1, 0x01]),\n );\n // WHEN\n const value = parser.parsePublicKey();\n // THEN\n expect(value).toEqual(\n Left(new LKRPParsingError(\"Expected a public key\")),\n );\n });\n });\n });\n});\n"],
|
|
5
|
-
"mappings": "AAAA,OAAS,QAAAA,EAAM,SAAAC,MAAa,YAE5B,OAAS,oBAAAC,MAAwB,yBAEjC,OAAS,eAAAC,MAAmB,gBAC5B,OAAS,aAAAC,MAAiB,cAC1B,OAAS,eAAAC,EAAa,eAAAC,MAAmB,YAEzC,SAAS,YAAa,IAAM,CAC1B,SAAS,qBAAsB,IAAM,CACnC,SAAS,gBAAiB,IAAM,CAC9B,GAAG,0EAA2E,IAAM,CAUlF,MAAMC,EARS,IAAIH,EACjB,IAAI,WAAW,CACTE,EAAY,IAAK,EAAG,EACpBD,EAAY,UAAW,EAAOC,EAAY,IAAK,EAAG,EAClDD,EAAY,KAAM,EAAOC,EAAY,IAAK,EAAG,CACnD,CAAC,CACH,EAEwB,cAAc,EAGtC,OAAOC,CAAQ,EAAE,cACfN,EAAM,CACJ,IAAIE,EACF,IAAI,WAAW,CACbE,EAAY,UACZ,EACIC,EAAY,IAAK,EAAG,CAC1B,CAAC,CACH,EACA,IAAIH,EACF,IAAI,WAAW,CACbE,EAAY,KACZ,EACIC,EAAY,IAAK,EAAG,CAC1B,CAAC,CACH,CACF,CAAC,CACH,CACF,CAAC,CACH,CAAC,EAED,SAAS,iBAAkB,IAAM,CAC/B,GAAG,kCAAmC,IAAM,CAgB1C,MAAME,EAdS,IAAIJ,EACjB,WAAW,KACT,CACE,CAACE,EAAY,IAAK,EAAG,CAAI,EACzB,CAACA,EAAY,KAAM,EAAG,EAAM,EAAM,CAAI,EACtC,CAACA,EAAY,UAAW,EAAG,EAAM,EAAM,CAAI,EAC3C,CAACA,EAAY,IAAK,EAAG,CAAI,EACzB,CAACD,EAAY,UAAW,E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AAI,CAAC,CAAC,CAAC,CACjE,CAAC,EAED,GAAG,sCAAuC,IAAM,CAM9C,MAAMQ,EAJS,IAAIL,EACjB,IAAI,WAAW,CAACE,EAAY,IAAK,EAAG,CAAI,CAAC,CAC3C,EAEqB,WAAW,EAEhC,OAAOG,CAAK,EAAE,QAAQT,EAAK,IAAIE,EAAiB,gBAAgB,CAAC,CAAC,CACpE,CAAC,CACH,CAAC,EAED,SAAS,iBAAkB,IAAM,CAC/B,GAAG,kCAAmC,IAAM,CAM1C,MAAMO,EAJS,IAAIL,EACjB,IAAI,WAAW,CAACE,EAAY,UAAW,EAAG,EAAM,EAAM,CAAI,CAAC,CAC7D,EAEqB,eAAe,EAEpC,OAAOG,CAAK,EAAE,QAAQR,EAAM,IAAI,WAAW,CAAC,EAAM,EAAM,CAAI,CAAC,CAAC,CAAC,CACjE,CAAC,EAED,GAAG,6CAA8C,IAAM,CAMrD,MAAMQ,EAJS,IAAIL,EACjB,IAAI,WAAW,CAACE,EAAY,IAAK,EAAG,CAAI,CAAC,CAC3C,EAEqB,eAAe,EAEpC,OAAOG,CAAK,EAAE,QACZT,EAAK,IAAIE,EAAiB,uBAAuB,CAAC,CACpD,CACF,CAAC,CACH,CAAC,CACH,CAAC,CACH,CAAC",
|
|
6
|
-
"names": ["Left", "Right", "LKRPParsingError", "
|
|
4
|
+
"sourcesContent": ["import { Left, Right } from \"purify-ts\";\n\nimport { LKRPParsingError } from \"@api/app-binder/Errors\";\nimport { CommandTags, GeneralTags } from \"@internal/models/Tags\";\n\nimport { LKRPCommand } from \"./LKRPCommand\";\nimport { TLVParser } from \"./TLVParser\";\n\ndescribe(\"TLVParser\", () => {\n describe(\"Block Data Parsing\", () => {\n describe(\"parseCommands\", () => {\n it(\"should parse has many commands has specified by the command count value\", () => {\n // GIVEN\n const parser = new TLVParser(\n new Uint8Array([\n ...[GeneralTags.Int, 1, 0x02], // Command count: 2\n ...[CommandTags.AddMember, 3, ...[GeneralTags.Int, 1, 0x01]], // First command\n ...[CommandTags.Seed, 3, ...[GeneralTags.Int, 1, 0x02]], // Second command\n ]),\n );\n // WHEN\n const commands = parser.parseCommands();\n\n // THEN\n expect(commands).toStrictEqual(\n Right([\n new LKRPCommand(\n new Uint8Array([\n CommandTags.AddMember,\n 3,\n ...[GeneralTags.Int, 1, 0x01],\n ]),\n ),\n new LKRPCommand(\n new Uint8Array([\n CommandTags.Seed,\n 3,\n ...[GeneralTags.Int, 1, 0x02],\n ]),\n ),\n ]),\n );\n });\n });\n\n describe(\"parseBlockData\", () => {\n it(\"should parse a valid block data\", () => {\n // GIVEN\n const parser = new TLVParser(\n Uint8Array.from(\n [\n [GeneralTags.Int, 1, 0x01], // Version\n [GeneralTags.Hash, 3, 0x01, 0x02, 0x03], // Parent\n [GeneralTags.PublicKey, 3, 0x04, 0x05, 0x06], // Issuer\n [GeneralTags.Int, 1, 0x02], // Command count: 2\n [CommandTags.AddMember, 3, ...[GeneralTags.Int, 1, 0x01]], // First command\n [CommandTags.Seed, 3, ...[GeneralTags.Int, 1, 0x02]], // Second command\n [GeneralTags.Signature, 3, 0x07, 0x08, 0x09], // Signature\n ].flat(),\n ),\n );\n // WHEN\n const blockData = parser.parseBlockData();\n\n // THEN\n expect(blockData).toStrictEqual(\n Right({\n parent: \"010203\",\n issuer: new Uint8Array([0x04, 0x05, 0x06]),\n header: Uint8Array.from(\n [\n [GeneralTags.Int, 1, 0x01], // Version\n [GeneralTags.Hash, 3, 0x01, 0x02, 0x03], // Parent\n [GeneralTags.PublicKey, 3, 0x04, 0x05, 0x06], // Issuer\n [GeneralTags.Int, 1, 0x02], // Command count: 2\n ].flat(),\n ),\n\n commands: [\n new LKRPCommand(\n new Uint8Array([\n CommandTags.AddMember,\n 3,\n ...[GeneralTags.Int, 1, 0x01],\n ]),\n ),\n new LKRPCommand(\n new Uint8Array([\n CommandTags.Seed,\n 3,\n ...[GeneralTags.Int, 1, 0x02],\n ]),\n ),\n ],\n signature: Uint8Array.from([\n GeneralTags.Signature,\n 3,\n 0x07,\n 0x08,\n 0x09,\n ]),\n }),\n );\n });\n\n it(\"should fail if the block data is invalid\", () => {\n // GIVEN\n const parser = new TLVParser(new Uint8Array([]));\n // WHEN\n const blockData = parser.parseBlockData();\n // THEN\n expect(blockData).toEqual(\n Left(new LKRPParsingError(\"Unexpected end of TLV\")),\n );\n });\n });\n });\n\n describe(\"Command Data Parsing\", () => {\n describe(\"parseCommandBytes\", () => {\n it(\"should parse a valid command bytes\", () => {\n // GIVEN\n const parser = new TLVParser(\n new Uint8Array([CommandTags.AddMember, 3, 0x01, 0x02, 0x03]),\n );\n // WHEN\n const value = parser.parseCommandBytes();\n // THEN\n expect(value).toEqual(\n Right(new Uint8Array([CommandTags.AddMember, 3, 0x01, 0x02, 0x03])),\n );\n });\n\n it(\"should fail if the tag is not a command\", () => {\n // GIVEN\n const parser = new TLVParser(\n new Uint8Array([GeneralTags.Int, 1, 0x01]),\n );\n // WHEN\n const value = parser.parseCommandBytes();\n // THEN\n expect(value).toEqual(\n Left(new LKRPParsingError(`Invalid command type: 0x01`)),\n );\n });\n });\n\n describe(\"Parse Seed Command Data\", () => {\n it(\"should parse a valid seed command data\", () => {\n // GIVEN\n const value = new Uint8Array([\n ...[GeneralTags.Bytes, 3, 0x01, 0x02, 0x03], // Topic\n ...[GeneralTags.Int, 2, 0x01, 0x02], // Protocol Version\n ...[GeneralTags.PublicKey, 3, 0x02, 0x04, 0x06], // Group Key\n ...[GeneralTags.Bytes, 3, 0x03, 0x05, 0x07], // Initialization Vector\n ...[GeneralTags.Bytes, 3, 0x04, 0x08, 0x10], // Encrypted xpriv\n ...[GeneralTags.PublicKey, 3, 0x0a, 0x0b, 0x0c], // Ephemeral Public Key\n ]);\n const parser = new TLVParser(\n new Uint8Array([CommandTags.Seed, value.length, ...value]),\n );\n\n // WHEN\n const parsed = parser.parseCommandData();\n\n // THEN\n expect(parsed).toStrictEqual(\n Right({\n type: CommandTags.Seed,\n topic: new Uint8Array([0x01, 0x02, 0x03]),\n protocolVersion: 258, // 0x0102 in big-endian\n groupKey: new Uint8Array([0x02, 0x04, 0x06]),\n initializationVector: new Uint8Array([0x03, 0x05, 0x07]),\n encryptedXpriv: new Uint8Array([0x04, 0x08, 0x10]),\n ephemeralPublicKey: new Uint8Array([0x0a, 0x0b, 0x0c]),\n }),\n );\n });\n\n it(\"should fail if the command data is invalid\", () => {\n // GIVEN\n const value1 = new Uint8Array([\n ...[GeneralTags.Signature, 3, 0x01, 0x02, 0x03], // Wrong type for Topic\n ]);\n const value2 = new Uint8Array([\n ...[GeneralTags.Bytes, 3, 0x01, 0x02, 0x03], // Correct type but the other fields are missing\n ]);\n const parser1 = new TLVParser(\n new Uint8Array([CommandTags.Seed, value1.length, ...value1]),\n );\n const parser2 = new TLVParser(\n new Uint8Array([CommandTags.Seed, value2.length, ...value2]),\n );\n\n // WHEN\n const parsed1 = parser1.parseCommandData();\n const parsed2 = parser2.parseCommandData();\n\n // THEN\n expect(parsed1).toEqual(Left(new LKRPParsingError(\"Expected bytes\")));\n expect(parsed2).toEqual(\n Left(new LKRPParsingError(\"Unexpected end of TLV\")),\n );\n });\n });\n\n describe(\"Parse AddMember Command Data\", () => {\n it(\"should parse a valid add member command data\", () => {\n // GIVEN\n const value = new Uint8Array([\n ...[GeneralTags.String, 5, 0x41, 0x6c, 0x69, 0x63, 0x65], // Name \"Alice\"\n ...[GeneralTags.PublicKey, 3, 0x01, 0x02, 0x03], // Public Key\n ...[GeneralTags.Int, 1, 0x01], // Permissions\n ]);\n const parser = new TLVParser(\n new Uint8Array([CommandTags.AddMember, value.length, ...value]),\n );\n\n // WHEN\n const parsed = parser.parseCommandData();\n\n // THEN\n expect(parsed).toStrictEqual(\n Right({\n type: CommandTags.AddMember,\n name: \"Alice\",\n publicKey: new Uint8Array([0x01, 0x02, 0x03]),\n permissions: 1,\n }),\n );\n });\n\n it(\"should fail if the command data is invalid\", () => {\n // GIVEN\n const value1 = new Uint8Array([\n ...[GeneralTags.Bytes, 3, 0x01, 0x02, 0x03], // Wrong type for Name\n ]);\n const value2 = new Uint8Array([\n ...[GeneralTags.String, 5, 0x41, 0x6c, 0x69, 0x63, 0x65], // Correct type but the other fields are missing\n ]);\n const parser1 = new TLVParser(\n new Uint8Array([CommandTags.AddMember, value1.length, ...value1]),\n );\n const parser2 = new TLVParser(\n new Uint8Array([CommandTags.AddMember, value2.length, ...value2]),\n );\n\n // WHEN\n const parsed1 = parser1.parseCommandData();\n const parsed2 = parser2.parseCommandData();\n\n // THEN\n expect(parsed1).toEqual(\n Left(new LKRPParsingError(\"Expected a string\")),\n );\n expect(parsed2).toEqual(\n Left(new LKRPParsingError(\"Unexpected end of TLV\")),\n );\n });\n });\n\n describe(\"Parse PublishKey Command Data\", () => {\n it(\"should parse a valid publish key command data\", () => {\n // GIVEN\n const value = new Uint8Array([\n ...[GeneralTags.Bytes, 3, 0x01, 0x02, 0x03], // Initialization Vector\n ...[GeneralTags.Bytes, 3, 0x04, 0x05, 0x06], // Encrypted xpriv\n ...[GeneralTags.PublicKey, 3, 0x03, 0x05, 0x07], // Recipient Public Key\n ...[GeneralTags.PublicKey, 3, 0x08, 0x09, 0x0a], // Ephemeral Public Key\n ]);\n const parser = new TLVParser(\n new Uint8Array([CommandTags.PublishKey, value.length, ...value]),\n );\n\n // WHEN\n const parsed = parser.parseCommandData();\n\n // THEN\n expect(parsed).toStrictEqual(\n Right({\n type: CommandTags.PublishKey,\n initializationVector: new Uint8Array([0x01, 0x02, 0x03]),\n encryptedXpriv: new Uint8Array([0x04, 0x05, 0x06]),\n recipient: new Uint8Array([0x03, 0x05, 0x07]),\n ephemeralPublicKey: new Uint8Array([0x08, 0x09, 0x0a]),\n }),\n );\n });\n\n it(\"should fail if the command data is invalid\", () => {\n // GIVEN\n const value1 = new Uint8Array([\n ...[GeneralTags.Int, 2, 0x01, 0x02], // Wrong type for Initialization Vector\n ]);\n const value2 = new Uint8Array([\n ...[GeneralTags.Bytes, 3, 0x01, 0x02, 0x03], // Correct type but the other fields are missing\n ]);\n const parser1 = new TLVParser(\n new Uint8Array([CommandTags.PublishKey, value1.length, ...value1]),\n );\n const parser2 = new TLVParser(\n new Uint8Array([CommandTags.PublishKey, value2.length, ...value2]),\n );\n\n // WHEN\n const parsed1 = parser1.parseCommandData();\n const parsed2 = parser2.parseCommandData();\n\n // THEN\n expect(parsed1).toEqual(Left(new LKRPParsingError(\"Expected bytes\")));\n expect(parsed2).toEqual(\n Left(new LKRPParsingError(\"Unexpected end of TLV\")),\n );\n });\n });\n\n describe(\"Parse Derive Command Data\", () => {\n it(\"should parse a valid derive command data\", () => {\n // GIVEN\n const value = new Uint8Array([\n ...[GeneralTags.Bytes, 4, 0x00, 0x00, 0x00, 0x01], // Path\n ...[GeneralTags.PublicKey, 3, 0x04, 0x05, 0x06], // Group Key\n ...[GeneralTags.Bytes, 3, 0x03, 0x05, 0x07], // Initialization Vector\n ...[GeneralTags.Bytes, 3, 0x08, 0x09, 0x0a], // Encrypted xpriv\n ...[GeneralTags.PublicKey, 3, 0x0a, 0x0b, 0x0c], // Ephemeral Public Key\n ]);\n const parser = new TLVParser(\n new Uint8Array([CommandTags.Derive, value.length, ...value]),\n );\n\n // WHEN\n const parsed = parser.parseCommandData();\n\n // THEN\n expect(parsed).toStrictEqual(\n Right({\n type: CommandTags.Derive,\n path: \"m/1\",\n groupKey: new Uint8Array([0x04, 0x05, 0x06]),\n initializationVector: new Uint8Array([0x03, 0x05, 0x07]),\n encryptedXpriv: new Uint8Array([0x08, 0x09, 0x0a]),\n ephemeralPublicKey: new Uint8Array([0x0a, 0x0b, 0x0c]),\n }),\n );\n });\n\n it(\"should fail if the command data is invalid\", () => {\n // GIVEN\n const value1 = new Uint8Array([\n ...[GeneralTags.Int, 2, 0x01, 0x02], // Wrong type for Path\n ]);\n const value2 = new Uint8Array([\n ...[GeneralTags.Bytes, 3, 0x01, 0x02, 0x03], // Correct type but the other fields are missing\n ]);\n const parser1 = new TLVParser(\n new Uint8Array([CommandTags.Derive, value1.length, ...value1]),\n );\n const parser2 = new TLVParser(\n new Uint8Array([CommandTags.Derive, value2.length, ...value2]),\n );\n\n // WHEN\n const parsed1 = parser1.parseCommandData();\n const parsed2 = parser2.parseCommandData();\n\n // THEN\n expect(parsed1).toEqual(Left(new LKRPParsingError(\"Expected bytes\")));\n expect(parsed2).toEqual(\n Left(new LKRPParsingError(\"Unexpected end of TLV\")),\n );\n });\n });\n\n it(\"should fail on unsupported command type\", () => {\n // GIVEN\n const parser = new TLVParser(new Uint8Array([0x3f, 1, 0x01]));\n // WHEN\n const parsed = parser.parseCommandData();\n // THEN\n expect(parsed).toEqual(\n Left(new LKRPParsingError(\"Unsupported command type: 0x3f\")),\n );\n });\n });\n\n describe(\"General Types Parsing\", () => {\n describe(\"parse\", () => {\n it(\"should parse a valid TLV structure\", () => {\n // GIVEN\n const parser = new TLVParser(\n new Uint8Array([GeneralTags.Int, 1, 0x01, GeneralTags.Bytes, 0]),\n );\n // WHEN\n const value1 = parser.parse();\n const value2 = parser.parse();\n // THEN\n expect(value1).toEqual(Right({ tag: GeneralTags.Int, value: 1 }));\n expect(value2).toEqual(\n Right({ tag: GeneralTags.Bytes, value: new Uint8Array([]) }),\n );\n });\n\n it(\"should fail on invalid TLV structure\", () => {\n // GIVEN\n const parser1 = new TLVParser(new Uint8Array([]));\n const parser2 = new TLVParser(new Uint8Array([GeneralTags.Int]));\n const parser3 = new TLVParser(new Uint8Array([GeneralTags.Int, 2]));\n // WHEN\n const value1 = parser1.parse();\n const value2 = parser2.parse();\n const value3 = parser3.parse();\n // THEN\n expect(value1).toEqual(\n Left(new LKRPParsingError(\"Unexpected end of TLV\")),\n );\n expect(value2).toEqual(\n Left(new LKRPParsingError(\"Invalid end of TLV, expected length\")),\n );\n expect(value3).toEqual(\n Left(new LKRPParsingError(\"Invalid end of TLV value\")),\n );\n });\n });\n\n describe(\"parseNull\", () => {\n it(\"should parse a null value\", () => {\n // GIVEN\n const parser = new TLVParser(new Uint8Array([GeneralTags.Null, 0]));\n // WHEN\n const value = parser.parseNull();\n // THEN\n expect(value).toEqual(Right(null));\n });\n\n it(\"should fail if the tag is not null\", () => {\n // GIVEN\n const parser = new TLVParser(\n new Uint8Array([GeneralTags.Int, 1, 0x01]),\n );\n // WHEN\n const value = parser.parseNull();\n // THEN\n expect(value).toEqual(Left(new LKRPParsingError(\"Expected null\")));\n });\n\n it(\"should fail if the format is invalid\", () => {\n // GIVEN\n const parser = new TLVParser(\n new Uint8Array([GeneralTags.Null, 1, 0x02]),\n );\n // WHEN\n const value = parser.parseNull();\n // THEN\n expect(value).toEqual(\n Left(new LKRPParsingError(\"Invalid null length\")),\n );\n });\n });\n\n describe(\"parseInt\", () => {\n it(\"should parse big endian integer values\", () => {\n // GIVEN\n const parser = new TLVParser(\n new Uint8Array([\n ...[GeneralTags.Int, 1, 0x01], // 1\n ...[GeneralTags.Int, 2, 0x01, 0x00], // 256\n ...[GeneralTags.Int, 4, 0x01, 0x00, 0x00, 0x00], // 16777216\n ]),\n );\n // WHEN\n const value1 = parser.parseInt();\n const value2 = parser.parseInt();\n const value4 = parser.parseInt();\n // THEN\n expect(value1).toEqual(Right(1));\n expect(value2).toEqual(Right(256));\n expect(value4).toEqual(Right(16777216));\n });\n\n it(\"should fail if the tag is not an integer\", () => {\n // GIVEN\n const parser = new TLVParser(\n new Uint8Array([GeneralTags.Bytes, 1, 0x01]),\n );\n // WHEN\n const value = parser.parseInt();\n // THEN\n expect(value).toEqual(Left(new LKRPParsingError(\"Expected a number\")));\n });\n\n it(\"should fail if the integer is not 1, 2, or 4 bytes\", () => {\n // GIVEN\n const parser = new TLVParser(\n new Uint8Array([GeneralTags.Int, 3, 0x01, 0x02, 0x03]),\n );\n // WHEN\n const value = parser.parseInt();\n // THEN\n expect(value).toEqual(\n Left(new LKRPParsingError(\"Unsupported integer length\")),\n );\n });\n });\n\n describe(\"parseHash\", () => {\n it(\"should parse a hash value\", () => {\n // GIVEN\n const parser = new TLVParser(\n new Uint8Array([GeneralTags.Hash, 3, 0x01, 0x02, 0x03]),\n );\n // WHEN\n const value = parser.parseHash();\n // THEN\n expect(value).toEqual(Right(new Uint8Array([0x01, 0x02, 0x03])));\n });\n\n it(\"should fail if the tag is not a hash\", () => {\n // GIVEN\n const parser = new TLVParser(\n new Uint8Array([GeneralTags.Int, 1, 0x01]),\n );\n // WHEN\n const value = parser.parseHash();\n // THEN\n expect(value).toEqual(Left(new LKRPParsingError(\"Expected a hash\")));\n });\n });\n\n describe(\"parseSignature\", () => {\n it(\"should parse a signature value\", () => {\n // GIVEN\n const parser = new TLVParser(\n new Uint8Array([GeneralTags.Signature, 3, 0x01, 0x02, 0x03]),\n );\n // WHEN\n const value = parser.parseSignature();\n // THEN\n expect(value).toEqual(Right(new Uint8Array([0x01, 0x02, 0x03])));\n });\n\n it(\"should fail if the tag is not a signature\", () => {\n // GIVEN\n const parser = new TLVParser(\n new Uint8Array([GeneralTags.Int, 1, 0x01]),\n );\n // WHEN\n const value = parser.parseSignature();\n // THEN\n expect(value).toEqual(\n Left(new LKRPParsingError(\"Expected a signature\")),\n );\n });\n });\n\n describe(\"parseString\", () => {\n it(\"should parse a string value\", () => {\n // GIVEN\n const parser = new TLVParser(\n new Uint8Array([GeneralTags.String, 5, 0x48, 0x65, 0x6c, 0x6c, 0x6f]),\n );\n // WHEN\n const value = parser.parseString();\n // THEN\n expect(value).toEqual(Right(\"Hello\"));\n });\n\n it(\"should fail if the tag is not a string\", () => {\n // GIVEN\n const parser = new TLVParser(\n new Uint8Array([GeneralTags.Int, 1, 0x01]),\n );\n // WHEN\n const value = parser.parseString();\n // THEN\n expect(value).toEqual(Left(new LKRPParsingError(\"Expected a string\")));\n });\n });\n\n describe(\"parseBytes\", () => {\n it(\"should parse a bytes value\", () => {\n // GIVEN\n const parser = new TLVParser(\n new Uint8Array([GeneralTags.Bytes, 3, 0x01, 0x02, 0x03]),\n );\n // WHEN\n const value = parser.parseBytes();\n // THEN\n expect(value).toEqual(Right(new Uint8Array([0x01, 0x02, 0x03])));\n });\n\n it(\"should fail if the tag is not bytes\", () => {\n // GIVEN\n const parser = new TLVParser(\n new Uint8Array([GeneralTags.Int, 1, 0x01]),\n );\n // WHEN\n const value = parser.parseBytes();\n // THEN\n expect(value).toEqual(Left(new LKRPParsingError(\"Expected bytes\")));\n });\n });\n\n describe(\"parsePublicKey\", () => {\n it(\"should parse a public key value\", () => {\n // GIVEN\n const parser = new TLVParser(\n new Uint8Array([GeneralTags.PublicKey, 3, 0x01, 0x02, 0x03]),\n );\n // WHEN\n const value = parser.parsePublicKey();\n // THEN\n expect(value).toEqual(Right(new Uint8Array([0x01, 0x02, 0x03])));\n });\n\n it(\"should fail if the tag is not a public key\", () => {\n // GIVEN\n const parser = new TLVParser(\n new Uint8Array([GeneralTags.Int, 1, 0x01]),\n );\n // WHEN\n const value = parser.parsePublicKey();\n // THEN\n expect(value).toEqual(\n Left(new LKRPParsingError(\"Expected a public key\")),\n );\n });\n });\n });\n});\n"],
|
|
5
|
+
"mappings": "AAAA,OAAS,QAAAA,EAAM,SAAAC,MAAa,YAE5B,OAAS,oBAAAC,MAAwB,yBACjC,OAAS,eAAAC,EAAa,eAAAC,MAAmB,wBAEzC,OAAS,eAAAC,MAAmB,gBAC5B,OAAS,aAAAC,MAAiB,cAE1B,SAAS,YAAa,IAAM,CAC1B,SAAS,qBAAsB,IAAM,CACnC,SAAS,gBAAiB,IAAM,CAC9B,GAAG,0EAA2E,IAAM,CAUlF,MAAMC,EARS,IAAID,EACjB,IAAI,WAAW,CACTF,EAAY,IAAK,EAAG,EACpBD,EAAY,UAAW,EAAOC,EAAY,IAAK,EAAG,EAClDD,EAAY,KAAM,EAAOC,EAAY,IAAK,EAAG,CACnD,CAAC,CACH,EAEwB,cAAc,EAGtC,OAAOG,CAAQ,EAAE,cACfN,EAAM,CACJ,IAAII,EACF,IAAI,WAAW,CACbF,EAAY,UACZ,EACIC,EAAY,IAAK,EAAG,CAC1B,CAAC,CACH,EACA,IAAIC,EACF,IAAI,WAAW,CACbF,EA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eneralTags", "LKRPCommand", "TLVParser", "commands", "blockData", "value", "parsed", "value1", "value2", "parser1", "parser2", "parsed1", "parsed2", "parser", "parser3", "value3", "value4"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{Maybe as t}from"purify-ts";import{LKRPBlockStream as e}from"./LKRPBlockStream";class s{constructor(r,i){this.id=r;this.serialized=i}getId(){return this.id}getRootStream(){return this.getStream("m/")}getAppStream(r){return this.getStream(`m/${r}'`)}getStream(r){return t.fromNullable(this.serialized[r]).map(e.fromHex)}}export{s as Trustchain};
|
|
2
|
+
//# sourceMappingURL=Trustchain.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/internal/utils/Trustchain.ts"],
|
|
4
|
+
"sourcesContent": ["import { Maybe } from \"purify-ts\";\n\nimport { LKRPBlockStream } from \"./LKRPBlockStream\";\n\nexport class Trustchain {\n constructor(\n private readonly id: string,\n private readonly serialized: {\n [path: string]: string;\n },\n ) {}\n\n getId(): string {\n return this.id;\n }\n\n getRootStream(): Maybe<LKRPBlockStream> {\n return this.getStream(\"m/\");\n }\n\n getAppStream(appId: number): Maybe<LKRPBlockStream> {\n return this.getStream(`m/${appId}'`);\n }\n\n getStream(path: string): Maybe<LKRPBlockStream> {\n return Maybe.fromNullable(this.serialized[path]).map(\n LKRPBlockStream.fromHex,\n );\n }\n}\n"],
|
|
5
|
+
"mappings": "AAAA,OAAS,SAAAA,MAAa,YAEtB,OAAS,mBAAAC,MAAuB,oBAEzB,MAAMC,CAAW,CACtB,YACmBC,EACAC,EAGjB,CAJiB,QAAAD,EACA,gBAAAC,CAGhB,CAEH,OAAgB,CACd,OAAO,KAAK,EACd,CAEA,eAAwC,CACtC,OAAO,KAAK,UAAU,IAAI,CAC5B,CAEA,aAAaC,EAAuC,CAClD,OAAO,KAAK,UAAU,KAAKA,CAAK,GAAG,CACrC,CAEA,UAAUC,EAAsC,CAC9C,OAAON,EAAM,aAAa,KAAK,WAAWM,CAAI,CAAC,EAAE,IAC/CL,EAAgB,OAClB,CACF,CACF",
|
|
6
|
+
"names": ["Maybe", "LKRPBlockStream", "Trustchain", "id", "serialized", "appId", "path"]
|
|
7
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
function
|
|
1
|
+
import{bufferToHexaString as t,hexaStringToBuffer as e}from"@ledgerhq/device-management-kit";function i(r){return e(r)??new Uint8Array}function o(r){return t(r).slice(2)}export{o as bytesToHex,i as hexToBytes};
|
|
2
2
|
//# sourceMappingURL=hex.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/internal/utils/hex.ts"],
|
|
4
|
-
"sourcesContent": ["
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": ["hexToBytes", "hex", "bytesToHex", "bytes"]
|
|
4
|
+
"sourcesContent": ["import {\n bufferToHexaString,\n hexaStringToBuffer,\n} from \"@ledgerhq/device-management-kit\";\n\nexport function hexToBytes(hex: string): Uint8Array {\n return hexaStringToBuffer(hex) ?? new Uint8Array();\n}\n\nexport function bytesToHex(bytes: Uint8Array): string {\n return bufferToHexaString(bytes).slice(2); // Remove the \"0x\" prefix\n}\n"],
|
|
5
|
+
"mappings": "AAAA,OACE,sBAAAA,EACA,sBAAAC,MACK,kCAEA,SAASC,EAAWC,EAAyB,CAClD,OAAOF,EAAmBE,CAAG,GAAK,IAAI,UACxC,CAEO,SAASC,EAAWC,EAA2B,CACpD,OAAOL,EAAmBK,CAAK,EAAE,MAAM,CAAC,CAC1C",
|
|
6
|
+
"names": ["bufferToHexaString", "hexaStringToBuffer", "hexToBytes", "hex", "bytesToHex", "bytes"]
|
|
7
7
|
}
|
package/lib/esm/package.json
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type AuthenticateUsecaseInput } from "../internal/use-cases/authentication/AuthenticateUseCase";
|
|
2
2
|
import { type AuthenticateDAReturnType } from "./app-binder/AuthenticateDeviceActionTypes";
|
|
3
|
-
import { type JWT, type Keypair, type Permissions } from "./app-binder/LKRPTypes";
|
|
4
3
|
export interface LedgerKeyringProtocol {
|
|
5
|
-
authenticate: (
|
|
4
|
+
authenticate: (input: AuthenticateUsecaseInput) => AuthenticateDAReturnType;
|
|
6
5
|
encryptData: (xpriv: Uint8Array, data: Uint8Array) => Uint8Array;
|
|
7
|
-
decryptData: (xpriv: Uint8Array, data: Uint8Array) =>
|
|
6
|
+
decryptData: (xpriv: Uint8Array, data: Uint8Array) => Uint8Array;
|
|
8
7
|
}
|
|
9
8
|
//# sourceMappingURL=LedgerKeyringProtocol.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LedgerKeyringProtocol.d.ts","sourceRoot":"","sources":["../../../src/api/LedgerKeyringProtocol.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,
|
|
1
|
+
{"version":3,"file":"LedgerKeyringProtocol.d.ts","sourceRoot":"","sources":["../../../src/api/LedgerKeyringProtocol.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,wBAAwB,EAAE,MAAM,wDAAwD,CAAC;AAEvG,OAAO,EAAE,KAAK,wBAAwB,EAAE,MAAM,4CAA4C,CAAC;AAE3F,MAAM,WAAW,qBAAqB;IACpC,YAAY,EAAE,CAAC,KAAK,EAAE,wBAAwB,KAAK,wBAAwB,CAAC;IAE5E,WAAW,EAAE,CAAC,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,KAAK,UAAU,CAAC;IAEjE,WAAW,EAAE,CAAC,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,KAAK,UAAU,CAAC;CAClE"}
|
|
@@ -1,13 +1,16 @@
|
|
|
1
|
-
import { type DeviceManagementKit
|
|
1
|
+
import { type DeviceManagementKit } from "@ledgerhq/device-management-kit";
|
|
2
2
|
import { type LedgerKeyringProtocol } from "./LedgerKeyringProtocol";
|
|
3
|
+
import { type LKRPEnv } from "./app-binder/LKRPTypes";
|
|
3
4
|
export declare class LedgerKeyringProtocolBuilder {
|
|
4
5
|
private readonly dmk;
|
|
5
|
-
private readonly
|
|
6
|
-
private readonly
|
|
7
|
-
|
|
6
|
+
private readonly applicationId;
|
|
7
|
+
private readonly env?;
|
|
8
|
+
private readonly baseUrl?;
|
|
9
|
+
constructor(args: {
|
|
8
10
|
dmk: DeviceManagementKit;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
+
applicationId: number;
|
|
12
|
+
env?: LKRPEnv;
|
|
13
|
+
baseUrl?: string;
|
|
11
14
|
});
|
|
12
15
|
build(): LedgerKeyringProtocol;
|
|
13
16
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LedgerKeyringProtocolBuilder.d.ts","sourceRoot":"","sources":["../../../src/api/LedgerKeyringProtocolBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"LedgerKeyringProtocolBuilder.d.ts","sourceRoot":"","sources":["../../../src/api/LedgerKeyringProtocolBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAE3E,OAAO,EAAE,KAAK,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAGxE,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAEtD,qBAAa,4BAA4B;IACvC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAsB;IAC1C,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAS;IACvC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAU;IAC/B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAS;gBAEtB,IAAI,EAAE;QAChB,GAAG,EAAE,mBAAmB,CAAC;QACzB,aAAa,EAAE,MAAM,CAAC;QACtB,GAAG,CAAC,EAAE,OAAO,CAAC;QACd,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB;IAOD,KAAK,IAAI,qBAAqB;CAQ/B"}
|
|
@@ -1,26 +1,36 @@
|
|
|
1
|
-
import { type OpenAppDAError, type
|
|
1
|
+
import { type OpenAppDAError, type UserInteractionRequired } from "@ledgerhq/device-management-kit";
|
|
2
2
|
import { type Either } from "purify-ts";
|
|
3
3
|
import { type LKRPDeviceCommandError } from "../../internal/app-binder/command/utils/ledgerKeyringProtocolErrors";
|
|
4
4
|
import { type LKRPDataSource } from "../../internal/lkrp-datasource/data/LKRPDataSource";
|
|
5
|
-
import { type
|
|
6
|
-
import { type
|
|
7
|
-
import { type LKRPHttpRequestError, type LKRPMissingDataError, type LKRPParsingError } from "./Errors";
|
|
5
|
+
import { type Trustchain } from "../../internal/utils/Trustchain";
|
|
6
|
+
import { type LKRPDataSourceError, type LKRPMissingDataError, type LKRPOutdatedTrustchainError, type LKRPParsingError, type LKRPTrustchainNotReady, type LKRPUnknownError } from "./Errors";
|
|
8
7
|
import { type JWT, type Keypair, type Permissions } from "./LKRPTypes";
|
|
9
8
|
export type AddToTrustchainDAOutput = undefined;
|
|
10
9
|
export type AddToTrustchainDAInput = Either<LKRPMissingDataError, {
|
|
11
10
|
readonly lkrpDataSource: LKRPDataSource;
|
|
12
11
|
readonly keypair: Keypair;
|
|
13
12
|
readonly jwt: JWT;
|
|
14
|
-
readonly
|
|
13
|
+
readonly appId: number;
|
|
15
14
|
readonly trustchain: Trustchain;
|
|
16
|
-
readonly applicationStream: LKRPBlockStream;
|
|
17
15
|
readonly clientName: string;
|
|
18
16
|
readonly permissions: Permissions;
|
|
19
17
|
}>;
|
|
20
|
-
export type AddToTrustchainDAError = LKRPDeviceCommandError |
|
|
18
|
+
export type AddToTrustchainDAError = LKRPDeviceCommandError | LKRPDataSourceError | LKRPParsingError | LKRPMissingDataError | LKRPOutdatedTrustchainError | LKRPTrustchainNotReady | OpenAppDAError | LKRPUnknownError;
|
|
21
19
|
export type AddToTrustchainDAIntermediateValue = {
|
|
22
|
-
|
|
20
|
+
requiredUserInteraction: UserInteractionRequired.None;
|
|
21
|
+
step?: AddToTrustchaineDAStep.Initialize | AddToTrustchaineDAStep.ParseStream;
|
|
22
|
+
} | {
|
|
23
|
+
requiredUserInteraction: AddToTrustchainDAState.AddMember;
|
|
24
|
+
step: AddToTrustchaineDAStep.AddMember;
|
|
23
25
|
};
|
|
26
|
+
export declare enum AddToTrustchainDAState {
|
|
27
|
+
AddMember = "lkrp-add-member"
|
|
28
|
+
}
|
|
29
|
+
export declare enum AddToTrustchaineDAStep {
|
|
30
|
+
Initialize = "lkrp-init-transaction",
|
|
31
|
+
ParseStream = "lkrp-parse-stream",
|
|
32
|
+
AddMember = "lkrp-add-member"
|
|
33
|
+
}
|
|
24
34
|
export type AddToTrustchainDAInternalState = Either<AddToTrustchainDAError, {
|
|
25
35
|
readonly sessionKeypair: Keypair | null;
|
|
26
36
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AddToTrustchainDeviceActionTypes.d.ts","sourceRoot":"","sources":["../../../../src/api/app-binder/AddToTrustchainDeviceActionTypes.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,
|
|
1
|
+
{"version":3,"file":"AddToTrustchainDeviceActionTypes.d.ts","sourceRoot":"","sources":["../../../../src/api/app-binder/AddToTrustchainDeviceActionTypes.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,uBAAuB,EAC7B,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,WAAW,CAAC;AAExC,OAAO,EAAE,KAAK,sBAAsB,EAAE,MAAM,gEAAgE,CAAC;AAC7G,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,+CAA+C,CAAC;AACpF,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAE7D,OAAO,EACL,KAAK,mBAAmB,EACxB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CACjD,sBAAsB,EACtB;IACE,QAAQ,CAAC,cAAc,EAAE,OAAO,GAAG,IAAI,CAAC;CACzC,CACF,CAAC"}
|
|
@@ -1,37 +1,33 @@
|
|
|
1
|
-
import { type ExecuteDeviceActionReturnType, type OpenAppDAError, type
|
|
2
|
-
import { type Either } from "purify-ts";
|
|
1
|
+
import { type ExecuteDeviceActionReturnType, type OpenAppDAError, type OpenAppDARequiredInteraction, type UserInteractionRequired } from "@ledgerhq/device-management-kit";
|
|
3
2
|
import { type LKRPDeviceCommandError } from "../../internal/app-binder/command/utils/ledgerKeyringProtocolErrors";
|
|
4
|
-
import { type
|
|
5
|
-
import { type
|
|
6
|
-
import { type
|
|
7
|
-
import { type LKRPHttpRequestError, type LKRPMissingDataError, type LKRPParsingError, type LKRPUnhandledState } from "./Errors";
|
|
8
|
-
import { type JWT, type Keypair, type Permissions } from "./LKRPTypes";
|
|
3
|
+
import { type AddToTrustchainDAError, type AddToTrustchainDAIntermediateValue } from "./AddToTrustchainDeviceActionTypes";
|
|
4
|
+
import { type LKRPDataSourceError, type LKRPMissingDataError, type LKRPParsingError, type LKRPTrustchainNotReady, type LKRPUnauthorizedError, type LKRPUnknownError } from "./Errors";
|
|
5
|
+
import { type JWT } from "./LKRPTypes";
|
|
9
6
|
export type AuthenticateDAReturnType = ExecuteDeviceActionReturnType<AuthenticateDAOutput, AuthenticateDAError, AuthenticateDAIntermediateValue>;
|
|
10
|
-
export type AuthenticateDAInput = {
|
|
11
|
-
readonly lkrpDataSource: LKRPDataSource;
|
|
12
|
-
readonly applicationId: number;
|
|
13
|
-
readonly keypair: Keypair;
|
|
14
|
-
readonly clientName: string;
|
|
15
|
-
readonly permissions: Permissions;
|
|
16
|
-
readonly trustchainId: string | null;
|
|
17
|
-
readonly jwt: JWT | null;
|
|
18
|
-
};
|
|
19
7
|
export type AuthenticateDAOutput = {
|
|
20
|
-
readonly jwt: JWT
|
|
21
|
-
readonly trustchainId: string
|
|
22
|
-
readonly applicationPath: string
|
|
23
|
-
readonly encryptionKey: Uint8Array
|
|
8
|
+
readonly jwt: JWT;
|
|
9
|
+
readonly trustchainId: string;
|
|
10
|
+
readonly applicationPath: string;
|
|
11
|
+
readonly encryptionKey: Uint8Array;
|
|
24
12
|
};
|
|
25
|
-
export type AuthenticateDAError = LKRPDeviceCommandError |
|
|
13
|
+
export type AuthenticateDAError = LKRPUnauthorizedError | AddToTrustchainDAError | LKRPDeviceCommandError | LKRPDataSourceError | LKRPParsingError | LKRPMissingDataError | LKRPTrustchainNotReady | OpenAppDAError | LKRPUnknownError;
|
|
26
14
|
export type AuthenticateDAIntermediateValue = {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
15
|
+
requiredUserInteraction: OpenAppDARequiredInteraction;
|
|
16
|
+
step: AuthenticateDAStep.OpenApp;
|
|
17
|
+
} | {
|
|
18
|
+
requiredUserInteraction: AuthenticateDAState.Authenticate;
|
|
19
|
+
step: AuthenticateDAStep.Authenticate;
|
|
20
|
+
} | {
|
|
21
|
+
requiredUserInteraction: UserInteractionRequired.None;
|
|
22
|
+
step?: AuthenticateDAStep.Authenticate | AuthenticateDAStep.GetTrustchain | AuthenticateDAStep.ExtractEncryptionKey;
|
|
23
|
+
} | AddToTrustchainDAIntermediateValue;
|
|
24
|
+
export declare enum AuthenticateDAState {
|
|
25
|
+
Authenticate = "lkrp-authenticate"
|
|
26
|
+
}
|
|
27
|
+
export declare enum AuthenticateDAStep {
|
|
28
|
+
OpenApp = "lkrp.steps.openApp",
|
|
29
|
+
Authenticate = "lkrp.steps.authenticate",
|
|
30
|
+
GetTrustchain = "lkrp.steps.getTrustchain",
|
|
31
|
+
ExtractEncryptionKey = "lkrp.steps.extractEncryptionKey"
|
|
32
|
+
}
|
|
37
33
|
//# sourceMappingURL=AuthenticateDeviceActionTypes.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AuthenticateDeviceActionTypes.d.ts","sourceRoot":"","sources":["../../../../src/api/app-binder/AuthenticateDeviceActionTypes.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,6BAA6B,EAClC,KAAK,cAAc,EACnB,KAAK,
|
|
1
|
+
{"version":3,"file":"AuthenticateDeviceActionTypes.d.ts","sourceRoot":"","sources":["../../../../src/api/app-binder/AuthenticateDeviceActionTypes.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,6BAA6B,EAClC,KAAK,cAAc,EACnB,KAAK,4BAA4B,EACjC,KAAK,uBAAuB,EAC7B,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EAAE,KAAK,sBAAsB,EAAE,MAAM,gEAAgE,CAAC;AAE7G,OAAO,EACL,KAAK,sBAAsB,EAC3B,KAAK,kCAAkC,EACxC,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EACL,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,EACzB,KAAK,gBAAgB,EACrB,KAAK,sBAAsB,EAC3B,KAAK,qBAAqB,EAC1B,KAAK,gBAAgB,EACtB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,KAAK,GAAG,EAAE,MAAM,aAAa,CAAC;AAEvC,MAAM,MAAM,wBAAwB,GAAG,6BAA6B,CAClE,oBAAoB,EACpB,mBAAmB,EACnB,+BAA+B,CAChC,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IACjC,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAC;IAClB,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,aAAa,EAAE,UAAU,CAAC;CACpC,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAC3B,qBAAqB,GACrB,sBAAsB,GACtB,sBAAsB,GACtB,mBAAmB,GACnB,gBAAgB,GAChB,oBAAoB,GACpB,sBAAsB,GACtB,cAAc,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