@ledgerhq/device-trusted-app-kit-ledger-keyring-protocol 0.0.0-web-ble-29-08---20250829104351 → 0.0.0-wrong-error-when-in-experimental-provider-20251021161219
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.map +2 -2
- package/lib/cjs/api/app-binder/AuthenticateDeviceActionTypes.js.map +1 -1
- package/lib/cjs/api/app-binder/GetVersionCommandTypes.js +1 -1
- package/lib/cjs/api/app-binder/GetVersionCommandTypes.js.map +1 -1
- package/lib/cjs/api/crypto/CryptoService.js +2 -0
- package/lib/cjs/api/crypto/CryptoService.js.map +7 -0
- package/lib/cjs/api/crypto/Key.js +2 -0
- package/lib/cjs/api/crypto/Key.js.map +7 -0
- package/lib/cjs/api/crypto/KeyPair.js +2 -0
- package/lib/cjs/api/crypto/KeyPair.js.map +7 -0
- package/lib/cjs/api/crypto/noble/NobleCryptoService.js +2 -0
- package/lib/cjs/api/crypto/noble/NobleCryptoService.js.map +7 -0
- package/lib/cjs/api/crypto/noble/NobleCryptoService.test.js +2 -0
- package/lib/cjs/api/crypto/noble/NobleCryptoService.test.js.map +7 -0
- package/lib/cjs/api/crypto/noble/NobleKey.js +2 -0
- package/lib/cjs/api/crypto/noble/NobleKey.js.map +7 -0
- package/lib/cjs/api/crypto/noble/NobleKey.test.js +2 -0
- package/lib/cjs/api/crypto/noble/NobleKey.test.js.map +7 -0
- package/lib/cjs/api/crypto/noble/NobleKeyPair.js +2 -0
- package/lib/cjs/api/crypto/noble/NobleKeyPair.js.map +7 -0
- package/lib/cjs/api/crypto/noble/NobleKeyPair.test.js +2 -0
- package/lib/cjs/api/crypto/noble/NobleKeyPair.test.js.map +7 -0
- package/lib/cjs/api/index.js +1 -1
- package/lib/cjs/api/index.js.map +2 -2
- package/lib/cjs/api/model/Env.js +2 -0
- package/lib/cjs/api/model/Env.js.map +7 -0
- package/lib/cjs/api/{app-binder → model}/Errors.js.map +1 -1
- package/lib/cjs/api/model/JWT.js +2 -0
- package/lib/cjs/api/model/JWT.js.map +7 -0
- package/lib/cjs/api/model/Permissions.js +2 -0
- package/lib/cjs/api/model/Permissions.js.map +7 -0
- package/lib/cjs/internal/DefaultLedgerKeyringProtocol.js +1 -1
- package/lib/cjs/internal/DefaultLedgerKeyringProtocol.js.map +3 -3
- package/lib/cjs/internal/app-binder/LedgerKeyringProtocolBinder.js +1 -1
- package/lib/cjs/internal/app-binder/LedgerKeyringProtocolBinder.js.map +3 -3
- package/lib/cjs/internal/app-binder/command/GetAppNameCommand.js +1 -1
- package/lib/cjs/internal/app-binder/command/GetAppNameCommand.js.map +2 -2
- package/lib/cjs/internal/app-binder/command/GetSeedIdCommand.js +1 -1
- package/lib/cjs/internal/app-binder/command/GetSeedIdCommand.js.map +3 -3
- package/lib/cjs/internal/app-binder/command/GetSeedIdCommand.test.js +2 -2
- package/lib/cjs/internal/app-binder/command/GetSeedIdCommand.test.js.map +3 -3
- package/lib/cjs/internal/app-binder/command/GetVersionCommand.js.map +2 -2
- package/lib/cjs/internal/app-binder/command/InitCommand.js +1 -1
- package/lib/cjs/internal/app-binder/command/InitCommand.js.map +2 -2
- package/lib/cjs/internal/app-binder/command/InitCommand.test.js +1 -1
- package/lib/cjs/internal/app-binder/command/InitCommand.test.js.map +2 -2
- package/lib/cjs/internal/app-binder/command/ParseBlockSignatureCommand.js +1 -1
- package/lib/cjs/internal/app-binder/command/ParseBlockSignatureCommand.js.map +2 -2
- package/lib/cjs/internal/app-binder/command/ParseBlockSignatureCommand.test.js +1 -1
- package/lib/cjs/internal/app-binder/command/ParseBlockSignatureCommand.test.js.map +2 -2
- package/lib/cjs/internal/app-binder/command/ParseStreamBlockCommand.js.map +2 -2
- package/lib/cjs/internal/app-binder/command/ParseStreamBlockCommand.test.js +1 -1
- package/lib/cjs/internal/app-binder/command/ParseStreamBlockCommand.test.js.map +2 -2
- package/lib/cjs/internal/app-binder/command/ParseStreamBlockHeader.js +1 -1
- package/lib/cjs/internal/app-binder/command/ParseStreamBlockHeader.js.map +2 -2
- package/lib/cjs/internal/app-binder/command/ParseStreamBlockHeader.test.js.map +2 -2
- package/lib/cjs/internal/app-binder/command/SetTrustedMemberCommand.js +1 -1
- package/lib/cjs/internal/app-binder/command/SetTrustedMemberCommand.js.map +2 -2
- package/lib/cjs/internal/app-binder/command/SetTrustedMemberCommand.test.js.map +2 -2
- package/lib/cjs/internal/app-binder/command/SignBlockHeader.js +1 -1
- package/lib/cjs/internal/app-binder/command/SignBlockHeader.js.map +2 -2
- package/lib/cjs/internal/app-binder/command/SignBlockHeader.test.js +1 -1
- package/lib/cjs/internal/app-binder/command/SignBlockHeader.test.js.map +2 -2
- package/lib/cjs/internal/app-binder/command/SignBlockSignatureCommand.js +1 -1
- package/lib/cjs/internal/app-binder/command/SignBlockSignatureCommand.js.map +2 -2
- package/lib/cjs/internal/app-binder/command/SignBlockSignatureCommand.test.js +1 -1
- package/lib/cjs/internal/app-binder/command/SignBlockSignatureCommand.test.js.map +2 -2
- package/lib/cjs/internal/app-binder/command/SignBlockSingleCommand.js +1 -1
- package/lib/cjs/internal/app-binder/command/SignBlockSingleCommand.js.map +2 -2
- package/lib/cjs/internal/app-binder/command/SignBlockSingleCommand.test.js +1 -1
- package/lib/cjs/internal/app-binder/command/SignBlockSingleCommand.test.js.map +2 -2
- package/lib/cjs/internal/app-binder/device-action/AddToTrustchainDeviceAction.js +1 -1
- package/lib/cjs/internal/app-binder/device-action/AddToTrustchainDeviceAction.js.map +3 -3
- package/lib/cjs/internal/app-binder/device-action/AuthenticateWithDeviceDeviceAction.js +1 -1
- package/lib/cjs/internal/app-binder/device-action/AuthenticateWithDeviceDeviceAction.js.map +2 -2
- package/lib/cjs/internal/app-binder/device-action/AuthenticateWithKeypairDeviceAction.js +1 -1
- package/lib/cjs/internal/app-binder/device-action/AuthenticateWithKeypairDeviceAction.js.map +2 -2
- package/lib/cjs/internal/app-binder/device-action/models/AuthenticateWithDeviceDeviceActionTypes.js +1 -1
- package/lib/cjs/internal/app-binder/device-action/models/AuthenticateWithDeviceDeviceActionTypes.js.map +1 -1
- package/lib/cjs/internal/app-binder/device-action/models/AuthenticateWithKeypairDeviceActionTypes.js +1 -1
- package/lib/cjs/internal/app-binder/device-action/models/AuthenticateWithKeypairDeviceActionTypes.js.map +1 -1
- package/lib/cjs/internal/app-binder/task/ExtractEncryptionKeyTask.js +1 -1
- package/lib/cjs/internal/app-binder/task/ExtractEncryptionKeyTask.js.map +3 -3
- package/lib/cjs/internal/app-binder/task/InitTask.js +1 -1
- package/lib/cjs/internal/app-binder/task/InitTask.js.map +3 -3
- package/lib/cjs/internal/app-binder/task/ParseStreamToDeviceTask.js +1 -1
- package/lib/cjs/internal/app-binder/task/ParseStreamToDeviceTask.js.map +3 -3
- package/lib/cjs/internal/app-binder/task/SignBlockTask.js +1 -1
- package/lib/cjs/internal/app-binder/task/SignBlockTask.js.map +3 -3
- package/lib/cjs/internal/app-binder/task/SignChallengeWithKeypairTask.js +1 -1
- package/lib/cjs/internal/app-binder/task/SignChallengeWithKeypairTask.js.map +3 -3
- package/lib/cjs/internal/app-binder/task/SignChallengeWithKeypairTask.test.js +1 -1
- package/lib/cjs/internal/app-binder/task/SignChallengeWithKeypairTask.test.js.map +3 -3
- package/lib/cjs/internal/app-binder/task/utils/TrustedProperties.js +1 -1
- package/lib/cjs/internal/app-binder/task/utils/TrustedProperties.js.map +2 -2
- 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 +2 -2
- package/lib/cjs/internal/lkrp-datasource/data/HttpLKRPDataSource.test.js +1 -1
- package/lib/cjs/internal/lkrp-datasource/data/HttpLKRPDataSource.test.js.map +2 -2
- package/lib/cjs/internal/lkrp-datasource/data/LKRPDataSource.js.map +1 -1
- package/lib/cjs/internal/use-cases/authentication/AuthenticateUseCase.js +1 -1
- package/lib/cjs/internal/use-cases/authentication/AuthenticateUseCase.js.map +2 -2
- package/lib/cjs/internal/use-cases/authentication/DecryptDataUseCase.js +1 -1
- package/lib/cjs/internal/use-cases/authentication/DecryptDataUseCase.js.map +3 -3
- package/lib/cjs/internal/use-cases/authentication/EncryptDataUseCase.js +1 -1
- package/lib/cjs/internal/use-cases/authentication/EncryptDataUseCase.js.map +3 -3
- package/lib/cjs/internal/utils/LKRPBlock.js +4 -4
- package/lib/cjs/internal/utils/LKRPBlock.js.map +3 -3
- package/lib/cjs/internal/utils/LKRPBlock.test.js +3 -3
- package/lib/cjs/internal/utils/LKRPBlock.test.js.map +3 -3
- package/lib/cjs/internal/utils/LKRPBlockStream.js +2 -2
- package/lib/cjs/internal/utils/LKRPBlockStream.js.map +3 -3
- package/lib/cjs/internal/utils/LKRPBlockStream.test.js +2 -2
- 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 +2 -2
- package/lib/cjs/internal/utils/LKRPCommand.test.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 +2 -2
- package/lib/cjs/internal/utils/required.js +1 -1
- package/lib/cjs/internal/utils/required.js.map +2 -2
- package/lib/cjs/package.json +2 -2
- 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.map +2 -2
- package/lib/esm/api/app-binder/AuthenticateDeviceActionTypes.js.map +1 -1
- package/lib/esm/api/crypto/CryptoService.js +2 -0
- package/lib/esm/api/crypto/CryptoService.js.map +7 -0
- package/lib/esm/api/crypto/Key.js +2 -0
- package/lib/esm/api/crypto/Key.js.map +7 -0
- package/lib/esm/api/crypto/KeyPair.js +2 -0
- package/lib/esm/api/crypto/KeyPair.js.map +7 -0
- package/lib/esm/api/crypto/noble/NobleCryptoService.js +2 -0
- package/lib/esm/api/crypto/noble/NobleCryptoService.js.map +7 -0
- package/lib/esm/api/crypto/noble/NobleCryptoService.test.js +2 -0
- package/lib/esm/api/crypto/noble/NobleCryptoService.test.js.map +7 -0
- package/lib/esm/api/crypto/noble/NobleKey.js +2 -0
- package/lib/esm/api/crypto/noble/NobleKey.js.map +7 -0
- package/lib/esm/api/crypto/noble/NobleKey.test.js +2 -0
- package/lib/esm/api/crypto/noble/NobleKey.test.js.map +7 -0
- package/lib/esm/api/crypto/noble/NobleKeyPair.js +2 -0
- package/lib/esm/api/crypto/noble/NobleKeyPair.js.map +7 -0
- package/lib/esm/api/crypto/noble/NobleKeyPair.test.js +2 -0
- package/lib/esm/api/crypto/noble/NobleKeyPair.test.js.map +7 -0
- package/lib/esm/api/index.js +1 -1
- package/lib/esm/api/index.js.map +2 -2
- package/lib/esm/api/model/Env.js +2 -0
- package/lib/esm/api/model/Env.js.map +7 -0
- package/lib/esm/api/{app-binder → model}/Errors.js.map +1 -1
- package/lib/esm/api/model/JWT.js +1 -0
- package/lib/esm/api/model/Permissions.js +2 -0
- package/lib/esm/api/model/Permissions.js.map +7 -0
- package/lib/esm/internal/DefaultLedgerKeyringProtocol.js +1 -1
- package/lib/esm/internal/DefaultLedgerKeyringProtocol.js.map +3 -3
- package/lib/esm/internal/app-binder/LedgerKeyringProtocolBinder.js +1 -1
- package/lib/esm/internal/app-binder/LedgerKeyringProtocolBinder.js.map +3 -3
- package/lib/esm/internal/app-binder/command/GetAppNameCommand.js +1 -1
- package/lib/esm/internal/app-binder/command/GetAppNameCommand.js.map +2 -2
- package/lib/esm/internal/app-binder/command/GetSeedIdCommand.js +1 -1
- package/lib/esm/internal/app-binder/command/GetSeedIdCommand.js.map +3 -3
- package/lib/esm/internal/app-binder/command/GetSeedIdCommand.test.js +1 -1
- package/lib/esm/internal/app-binder/command/GetSeedIdCommand.test.js.map +3 -3
- package/lib/esm/internal/app-binder/command/GetVersionCommand.js.map +2 -2
- package/lib/esm/internal/app-binder/command/InitCommand.js +1 -1
- package/lib/esm/internal/app-binder/command/InitCommand.js.map +2 -2
- package/lib/esm/internal/app-binder/command/InitCommand.test.js +1 -1
- package/lib/esm/internal/app-binder/command/InitCommand.test.js.map +2 -2
- package/lib/esm/internal/app-binder/command/ParseBlockSignatureCommand.js +1 -1
- package/lib/esm/internal/app-binder/command/ParseBlockSignatureCommand.js.map +2 -2
- package/lib/esm/internal/app-binder/command/ParseBlockSignatureCommand.test.js +1 -1
- package/lib/esm/internal/app-binder/command/ParseBlockSignatureCommand.test.js.map +2 -2
- package/lib/esm/internal/app-binder/command/ParseStreamBlockCommand.js.map +2 -2
- package/lib/esm/internal/app-binder/command/ParseStreamBlockCommand.test.js +1 -1
- package/lib/esm/internal/app-binder/command/ParseStreamBlockCommand.test.js.map +2 -2
- package/lib/esm/internal/app-binder/command/ParseStreamBlockHeader.js +1 -1
- package/lib/esm/internal/app-binder/command/ParseStreamBlockHeader.js.map +2 -2
- package/lib/esm/internal/app-binder/command/ParseStreamBlockHeader.test.js.map +2 -2
- package/lib/esm/internal/app-binder/command/SetTrustedMemberCommand.js +1 -1
- package/lib/esm/internal/app-binder/command/SetTrustedMemberCommand.js.map +2 -2
- package/lib/esm/internal/app-binder/command/SetTrustedMemberCommand.test.js +1 -1
- package/lib/esm/internal/app-binder/command/SetTrustedMemberCommand.test.js.map +2 -2
- package/lib/esm/internal/app-binder/command/SignBlockHeader.js +1 -1
- package/lib/esm/internal/app-binder/command/SignBlockHeader.js.map +2 -2
- package/lib/esm/internal/app-binder/command/SignBlockHeader.test.js +1 -1
- package/lib/esm/internal/app-binder/command/SignBlockHeader.test.js.map +2 -2
- package/lib/esm/internal/app-binder/command/SignBlockSignatureCommand.js +1 -1
- package/lib/esm/internal/app-binder/command/SignBlockSignatureCommand.js.map +2 -2
- package/lib/esm/internal/app-binder/command/SignBlockSignatureCommand.test.js +1 -1
- package/lib/esm/internal/app-binder/command/SignBlockSignatureCommand.test.js.map +2 -2
- package/lib/esm/internal/app-binder/command/SignBlockSingleCommand.js +1 -1
- package/lib/esm/internal/app-binder/command/SignBlockSingleCommand.js.map +2 -2
- package/lib/esm/internal/app-binder/command/SignBlockSingleCommand.test.js +1 -1
- package/lib/esm/internal/app-binder/command/SignBlockSingleCommand.test.js.map +2 -2
- package/lib/esm/internal/app-binder/device-action/AddToTrustchainDeviceAction.js +1 -1
- package/lib/esm/internal/app-binder/device-action/AddToTrustchainDeviceAction.js.map +3 -3
- package/lib/esm/internal/app-binder/device-action/AuthenticateWithDeviceDeviceAction.js +1 -1
- package/lib/esm/internal/app-binder/device-action/AuthenticateWithDeviceDeviceAction.js.map +2 -2
- package/lib/esm/internal/app-binder/device-action/AuthenticateWithKeypairDeviceAction.js +1 -1
- package/lib/esm/internal/app-binder/device-action/AuthenticateWithKeypairDeviceAction.js.map +2 -2
- package/lib/esm/internal/app-binder/task/ExtractEncryptionKeyTask.js +1 -1
- package/lib/esm/internal/app-binder/task/ExtractEncryptionKeyTask.js.map +3 -3
- package/lib/esm/internal/app-binder/task/InitTask.js +1 -1
- package/lib/esm/internal/app-binder/task/InitTask.js.map +3 -3
- package/lib/esm/internal/app-binder/task/ParseStreamToDeviceTask.js +1 -1
- package/lib/esm/internal/app-binder/task/ParseStreamToDeviceTask.js.map +3 -3
- package/lib/esm/internal/app-binder/task/SignBlockTask.js +1 -1
- package/lib/esm/internal/app-binder/task/SignBlockTask.js.map +3 -3
- package/lib/esm/internal/app-binder/task/SignChallengeWithKeypairTask.js +1 -1
- package/lib/esm/internal/app-binder/task/SignChallengeWithKeypairTask.js.map +3 -3
- package/lib/esm/internal/app-binder/task/SignChallengeWithKeypairTask.test.js +1 -1
- package/lib/esm/internal/app-binder/task/SignChallengeWithKeypairTask.test.js.map +3 -3
- package/lib/esm/internal/app-binder/task/utils/TrustedProperties.js +1 -1
- package/lib/esm/internal/app-binder/task/utils/TrustedProperties.js.map +2 -2
- 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 +2 -2
- package/lib/esm/internal/lkrp-datasource/data/HttpLKRPDataSource.test.js +1 -1
- package/lib/esm/internal/lkrp-datasource/data/HttpLKRPDataSource.test.js.map +2 -2
- package/lib/esm/internal/use-cases/authentication/AuthenticateUseCase.js +1 -1
- package/lib/esm/internal/use-cases/authentication/AuthenticateUseCase.js.map +2 -2
- package/lib/esm/internal/use-cases/authentication/DecryptDataUseCase.js +1 -1
- package/lib/esm/internal/use-cases/authentication/DecryptDataUseCase.js.map +3 -3
- package/lib/esm/internal/use-cases/authentication/EncryptDataUseCase.js +1 -1
- package/lib/esm/internal/use-cases/authentication/EncryptDataUseCase.js.map +3 -3
- package/lib/esm/internal/utils/LKRPBlock.js +3 -3
- package/lib/esm/internal/utils/LKRPBlock.js.map +3 -3
- package/lib/esm/internal/utils/LKRPBlock.test.js +2 -2
- package/lib/esm/internal/utils/LKRPBlock.test.js.map +3 -3
- package/lib/esm/internal/utils/LKRPBlockStream.js +2 -2
- package/lib/esm/internal/utils/LKRPBlockStream.js.map +3 -3
- package/lib/esm/internal/utils/LKRPBlockStream.test.js +1 -1
- 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 +2 -2
- package/lib/esm/internal/utils/LKRPCommand.test.js.map +3 -3
- 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 +2 -2
- package/lib/esm/internal/utils/required.js +1 -1
- package/lib/esm/internal/utils/required.js.map +2 -2
- package/lib/esm/package.json +2 -2
- package/lib/types/api/LedgerKeyringProtocol.d.ts +2 -2
- package/lib/types/api/LedgerKeyringProtocol.d.ts.map +1 -1
- package/lib/types/api/LedgerKeyringProtocolBuilder.d.ts +4 -1
- package/lib/types/api/LedgerKeyringProtocolBuilder.d.ts.map +1 -1
- package/lib/types/api/app-binder/AddToTrustchainDeviceActionTypes.d.ts +8 -4
- package/lib/types/api/app-binder/AddToTrustchainDeviceActionTypes.d.ts.map +1 -1
- package/lib/types/api/app-binder/AuthenticateDeviceActionTypes.d.ts +2 -2
- package/lib/types/api/app-binder/AuthenticateDeviceActionTypes.d.ts.map +1 -1
- package/lib/types/api/app-binder/GetVersionCommandTypes.d.ts +0 -1
- package/lib/types/api/app-binder/GetVersionCommandTypes.d.ts.map +1 -1
- package/lib/types/api/crypto/CryptoService.d.ts +22 -0
- package/lib/types/api/crypto/CryptoService.d.ts.map +1 -0
- package/lib/types/api/crypto/Key.d.ts +7 -0
- package/lib/types/api/crypto/Key.d.ts.map +1 -0
- package/lib/types/api/crypto/KeyPair.d.ts +13 -0
- package/lib/types/api/crypto/KeyPair.d.ts.map +1 -0
- package/lib/types/api/crypto/noble/NobleCryptoService.d.ts +13 -0
- package/lib/types/api/crypto/noble/NobleCryptoService.d.ts.map +1 -0
- package/lib/types/api/crypto/noble/NobleCryptoService.test.d.ts +2 -0
- package/lib/types/api/crypto/noble/NobleCryptoService.test.d.ts.map +1 -0
- package/lib/types/api/crypto/noble/NobleKey.d.ts +11 -0
- package/lib/types/api/crypto/noble/NobleKey.d.ts.map +1 -0
- package/lib/types/api/crypto/noble/NobleKey.test.d.ts +2 -0
- package/lib/types/api/crypto/noble/NobleKey.test.d.ts.map +1 -0
- package/lib/types/api/crypto/noble/NobleKeyPair.d.ts +18 -0
- package/lib/types/api/crypto/noble/NobleKeyPair.d.ts.map +1 -0
- package/lib/types/api/crypto/noble/NobleKeyPair.test.d.ts +2 -0
- package/lib/types/api/crypto/noble/NobleKeyPair.test.d.ts.map +1 -0
- package/lib/types/api/index.d.ts +10 -2
- package/lib/types/api/index.d.ts.map +1 -1
- package/lib/types/api/model/Env.d.ts +5 -0
- package/lib/types/api/model/Env.d.ts.map +1 -0
- package/lib/types/api/model/Errors.d.ts.map +1 -0
- package/lib/types/api/model/JWT.d.ts +9 -0
- package/lib/types/api/model/JWT.d.ts.map +1 -0
- package/lib/types/api/{app-binder/LKRPTypes.d.ts → model/Permissions.d.ts} +1 -19
- package/lib/types/api/model/Permissions.d.ts.map +1 -0
- package/lib/types/internal/DefaultLedgerKeyringProtocol.d.ts +6 -4
- package/lib/types/internal/DefaultLedgerKeyringProtocol.d.ts.map +1 -1
- package/lib/types/internal/app-binder/LedgerKeyringProtocolBinder.d.ts +7 -4
- package/lib/types/internal/app-binder/LedgerKeyringProtocolBinder.d.ts.map +1 -1
- package/lib/types/internal/app-binder/command/GetAppNameCommand.d.ts +4 -1
- package/lib/types/internal/app-binder/command/GetAppNameCommand.d.ts.map +1 -1
- package/lib/types/internal/app-binder/command/GetSeedIdCommand.d.ts +13 -1
- package/lib/types/internal/app-binder/command/GetSeedIdCommand.d.ts.map +1 -1
- package/lib/types/internal/app-binder/command/GetVersionCommand.d.ts +2 -1
- package/lib/types/internal/app-binder/command/GetVersionCommand.d.ts.map +1 -1
- package/lib/types/internal/app-binder/command/InitCommand.d.ts +4 -1
- package/lib/types/internal/app-binder/command/InitCommand.d.ts.map +1 -1
- package/lib/types/internal/app-binder/command/ParseBlockSignatureCommand.d.ts +4 -1
- package/lib/types/internal/app-binder/command/ParseBlockSignatureCommand.d.ts.map +1 -1
- package/lib/types/internal/app-binder/command/ParseStreamBlockCommand.d.ts +5 -1
- package/lib/types/internal/app-binder/command/ParseStreamBlockCommand.d.ts.map +1 -1
- package/lib/types/internal/app-binder/command/ParseStreamBlockHeader.d.ts +4 -1
- package/lib/types/internal/app-binder/command/ParseStreamBlockHeader.d.ts.map +1 -1
- package/lib/types/internal/app-binder/command/SetTrustedMemberCommand.d.ts +5 -1
- package/lib/types/internal/app-binder/command/SetTrustedMemberCommand.d.ts.map +1 -1
- package/lib/types/internal/app-binder/command/SignBlockHeader.d.ts +5 -1
- package/lib/types/internal/app-binder/command/SignBlockHeader.d.ts.map +1 -1
- package/lib/types/internal/app-binder/command/SignBlockSignatureCommand.d.ts +5 -1
- package/lib/types/internal/app-binder/command/SignBlockSignatureCommand.d.ts.map +1 -1
- package/lib/types/internal/app-binder/command/SignBlockSingleCommand.d.ts +4 -1
- package/lib/types/internal/app-binder/command/SignBlockSingleCommand.d.ts.map +1 -1
- package/lib/types/internal/app-binder/device-action/AddToTrustchainDeviceAction.d.ts +8 -4
- 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 +5 -2
- package/lib/types/internal/app-binder/device-action/AuthenticateWithDeviceDeviceAction.d.ts.map +1 -1
- package/lib/types/internal/app-binder/device-action/AuthenticateWithKeypairDeviceAction.d.ts +5 -2
- package/lib/types/internal/app-binder/device-action/AuthenticateWithKeypairDeviceAction.d.ts.map +1 -1
- package/lib/types/internal/app-binder/device-action/models/AuthenticateWithDeviceDeviceActionTypes.d.ts +5 -2
- package/lib/types/internal/app-binder/device-action/models/AuthenticateWithDeviceDeviceActionTypes.d.ts.map +1 -1
- package/lib/types/internal/app-binder/device-action/models/AuthenticateWithKeypairDeviceActionTypes.d.ts +5 -2
- package/lib/types/internal/app-binder/device-action/models/AuthenticateWithKeypairDeviceActionTypes.d.ts.map +1 -1
- package/lib/types/internal/app-binder/task/ExtractEncryptionKeyTask.d.ts +4 -7
- package/lib/types/internal/app-binder/task/ExtractEncryptionKeyTask.d.ts.map +1 -1
- package/lib/types/internal/app-binder/task/InitTask.d.ts +5 -3
- package/lib/types/internal/app-binder/task/InitTask.d.ts.map +1 -1
- package/lib/types/internal/app-binder/task/ParseStreamToDeviceTask.d.ts +1 -1
- package/lib/types/internal/app-binder/task/ParseStreamToDeviceTask.d.ts.map +1 -1
- package/lib/types/internal/app-binder/task/SignBlockTask.d.ts +11 -8
- package/lib/types/internal/app-binder/task/SignBlockTask.d.ts.map +1 -1
- package/lib/types/internal/app-binder/task/SignChallengeWithKeypairTask.d.ts +5 -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 +3 -1
- package/lib/types/internal/di.d.ts.map +1 -1
- package/lib/types/internal/externalTypes.d.ts +1 -0
- package/lib/types/internal/externalTypes.d.ts.map +1 -1
- package/lib/types/internal/lkrp-datasource/data/HttpLKRPDataSource.d.ts +2 -2
- package/lib/types/internal/lkrp-datasource/data/HttpLKRPDataSource.d.ts.map +1 -1
- package/lib/types/internal/lkrp-datasource/data/LKRPDataSource.d.ts +2 -2
- package/lib/types/internal/lkrp-datasource/data/LKRPDataSource.d.ts.map +1 -1
- package/lib/types/internal/use-cases/authentication/AuthenticateUseCase.d.ts +3 -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 -1
- package/lib/types/internal/use-cases/authentication/DecryptDataUseCase.d.ts.map +1 -1
- package/lib/types/internal/use-cases/authentication/EncryptDataUseCase.d.ts +4 -1
- package/lib/types/internal/use-cases/authentication/EncryptDataUseCase.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 -3
- package/lib/types/internal/utils/LKRPBlockStream.d.ts.map +1 -1
- package/lib/types/internal/utils/LKRPCommand.d.ts +1 -1
- package/lib/types/internal/utils/LKRPCommand.d.ts.map +1 -1
- package/lib/types/internal/utils/TLVParser.d.ts +1 -1
- package/lib/types/internal/utils/TLVParser.d.ts.map +1 -1
- package/lib/types/internal/utils/required.d.ts +1 -1
- package/lib/types/internal/utils/required.d.ts.map +1 -1
- package/lib/types/tsconfig.prod.tsbuildinfo +1 -1
- package/package.json +6 -6
- package/lib/cjs/api/app-binder/GetAppNameCommandTypes.js +0 -2
- package/lib/cjs/api/app-binder/GetAppNameCommandTypes.js.map +0 -7
- package/lib/cjs/api/app-binder/GetSeedIdCommandTypes.js +0 -2
- package/lib/cjs/api/app-binder/GetSeedIdCommandTypes.js.map +0 -7
- package/lib/cjs/api/app-binder/InitCommandTypes.js +0 -2
- package/lib/cjs/api/app-binder/InitCommandTypes.js.map +0 -7
- package/lib/cjs/api/app-binder/KeypairFromBytes.js +0 -2
- package/lib/cjs/api/app-binder/KeypairFromBytes.js.map +0 -7
- package/lib/cjs/api/app-binder/LKRPTypes.js +0 -2
- package/lib/cjs/api/app-binder/LKRPTypes.js.map +0 -7
- package/lib/cjs/api/app-binder/ParseStreamBlockCommandCommandTypes.js +0 -2
- package/lib/cjs/api/app-binder/ParseStreamBlockCommandCommandTypes.js.map +0 -7
- package/lib/cjs/api/app-binder/ParseStreamBlockHeaderCommandTypes.js +0 -2
- package/lib/cjs/api/app-binder/ParseStreamBlockHeaderCommandTypes.js.map +0 -7
- package/lib/cjs/api/app-binder/ParseStreamBlockSignatureTypes.js +0 -2
- package/lib/cjs/api/app-binder/ParseStreamBlockSignatureTypes.js.map +0 -7
- package/lib/cjs/api/app-binder/SetTrustedMemberTypes.js +0 -2
- package/lib/cjs/api/app-binder/SetTrustedMemberTypes.js.map +0 -7
- package/lib/cjs/api/app-binder/SignBlockCommandTypes.js +0 -2
- package/lib/cjs/api/app-binder/SignBlockCommandTypes.js.map +0 -7
- package/lib/cjs/api/app-binder/SignBlockHeaderCommandTypes.js +0 -2
- package/lib/cjs/api/app-binder/SignBlockHeaderCommandTypes.js.map +0 -7
- package/lib/cjs/api/app-binder/SignBlockSignatureCommandTypes.js +0 -2
- package/lib/cjs/api/app-binder/SignBlockSignatureCommandTypes.js.map +0 -7
- package/lib/cjs/api/app-binder/SignBlockSingleCommandTypes.js +0 -2
- package/lib/cjs/api/app-binder/SignBlockSingleCommandTypes.js.map +0 -7
- package/lib/cjs/internal/utils/TLVBuilder.js +0 -2
- package/lib/cjs/internal/utils/TLVBuilder.js.map +0 -7
- package/lib/cjs/internal/utils/crypto.js +0 -2
- package/lib/cjs/internal/utils/crypto.js.map +0 -7
- package/lib/cjs/internal/utils/hex.js +0 -2
- package/lib/cjs/internal/utils/hex.js.map +0 -7
- package/lib/esm/api/app-binder/GetAppNameCommandTypes.js +0 -1
- package/lib/esm/api/app-binder/GetSeedIdCommandTypes.js +0 -1
- package/lib/esm/api/app-binder/GetSeedIdCommandTypes.js.map +0 -7
- package/lib/esm/api/app-binder/InitCommandTypes.js +0 -1
- package/lib/esm/api/app-binder/InitCommandTypes.js.map +0 -7
- package/lib/esm/api/app-binder/KeypairFromBytes.js +0 -2
- package/lib/esm/api/app-binder/KeypairFromBytes.js.map +0 -7
- package/lib/esm/api/app-binder/LKRPTypes.js +0 -2
- package/lib/esm/api/app-binder/LKRPTypes.js.map +0 -7
- package/lib/esm/api/app-binder/ParseStreamBlockCommandCommandTypes.js +0 -1
- package/lib/esm/api/app-binder/ParseStreamBlockCommandCommandTypes.js.map +0 -7
- package/lib/esm/api/app-binder/ParseStreamBlockHeaderCommandTypes.js +0 -1
- package/lib/esm/api/app-binder/ParseStreamBlockHeaderCommandTypes.js.map +0 -7
- package/lib/esm/api/app-binder/ParseStreamBlockSignatureTypes.js +0 -1
- package/lib/esm/api/app-binder/ParseStreamBlockSignatureTypes.js.map +0 -7
- package/lib/esm/api/app-binder/SetTrustedMemberTypes.js +0 -1
- package/lib/esm/api/app-binder/SetTrustedMemberTypes.js.map +0 -7
- package/lib/esm/api/app-binder/SignBlockCommandTypes.js +0 -1
- package/lib/esm/api/app-binder/SignBlockCommandTypes.js.map +0 -7
- package/lib/esm/api/app-binder/SignBlockHeaderCommandTypes.js +0 -1
- package/lib/esm/api/app-binder/SignBlockHeaderCommandTypes.js.map +0 -7
- package/lib/esm/api/app-binder/SignBlockSignatureCommandTypes.js +0 -1
- package/lib/esm/api/app-binder/SignBlockSignatureCommandTypes.js.map +0 -7
- package/lib/esm/api/app-binder/SignBlockSingleCommandTypes.js +0 -1
- package/lib/esm/api/app-binder/SignBlockSingleCommandTypes.js.map +0 -7
- package/lib/esm/internal/utils/TLVBuilder.js +0 -2
- package/lib/esm/internal/utils/TLVBuilder.js.map +0 -7
- package/lib/esm/internal/utils/crypto.js +0 -2
- package/lib/esm/internal/utils/crypto.js.map +0 -7
- package/lib/esm/internal/utils/hex.js +0 -2
- package/lib/esm/internal/utils/hex.js.map +0 -7
- package/lib/types/api/app-binder/Errors.d.ts.map +0 -1
- package/lib/types/api/app-binder/GetAppNameCommandTypes.d.ts +0 -5
- package/lib/types/api/app-binder/GetAppNameCommandTypes.d.ts.map +0 -1
- package/lib/types/api/app-binder/GetSeedIdCommandTypes.d.ts +0 -14
- package/lib/types/api/app-binder/GetSeedIdCommandTypes.d.ts.map +0 -1
- package/lib/types/api/app-binder/InitCommandTypes.d.ts +0 -5
- package/lib/types/api/app-binder/InitCommandTypes.d.ts.map +0 -1
- package/lib/types/api/app-binder/KeypairFromBytes.d.ts +0 -11
- package/lib/types/api/app-binder/KeypairFromBytes.d.ts.map +0 -1
- package/lib/types/api/app-binder/LKRPTypes.d.ts.map +0 -1
- package/lib/types/api/app-binder/ParseStreamBlockCommandCommandTypes.d.ts +0 -6
- package/lib/types/api/app-binder/ParseStreamBlockCommandCommandTypes.d.ts.map +0 -1
- package/lib/types/api/app-binder/ParseStreamBlockHeaderCommandTypes.d.ts +0 -5
- package/lib/types/api/app-binder/ParseStreamBlockHeaderCommandTypes.d.ts.map +0 -1
- package/lib/types/api/app-binder/ParseStreamBlockSignatureTypes.d.ts +0 -5
- package/lib/types/api/app-binder/ParseStreamBlockSignatureTypes.d.ts.map +0 -1
- package/lib/types/api/app-binder/SetTrustedMemberTypes.d.ts +0 -6
- package/lib/types/api/app-binder/SetTrustedMemberTypes.d.ts.map +0 -1
- package/lib/types/api/app-binder/SignBlockCommandTypes.d.ts +0 -9
- package/lib/types/api/app-binder/SignBlockCommandTypes.d.ts.map +0 -1
- package/lib/types/api/app-binder/SignBlockHeaderCommandTypes.d.ts +0 -6
- package/lib/types/api/app-binder/SignBlockHeaderCommandTypes.d.ts.map +0 -1
- package/lib/types/api/app-binder/SignBlockSignatureCommandTypes.d.ts +0 -6
- package/lib/types/api/app-binder/SignBlockSignatureCommandTypes.d.ts.map +0 -1
- package/lib/types/api/app-binder/SignBlockSingleCommandTypes.d.ts +0 -5
- package/lib/types/api/app-binder/SignBlockSingleCommandTypes.d.ts.map +0 -1
- package/lib/types/internal/utils/TLVBuilder.d.ts +0 -15
- package/lib/types/internal/utils/TLVBuilder.d.ts.map +0 -1
- package/lib/types/internal/utils/crypto.d.ts +0 -19
- package/lib/types/internal/utils/crypto.d.ts.map +0 -1
- package/lib/types/internal/utils/hex.d.ts +0 -3
- package/lib/types/internal/utils/hex.d.ts.map +0 -1
- /package/lib/cjs/api/{app-binder → model}/Errors.js +0 -0
- /package/lib/esm/api/{app-binder → model}/Errors.js +0 -0
- /package/lib/esm/api/{app-binder/GetAppNameCommandTypes.js.map → model/JWT.js.map} +0 -0
- /package/lib/types/api/{app-binder → model}/Errors.d.ts +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var n=require("purify-ts"),s=require("../../api/app-binder/Errors"),e=require("../models/Tags"),c=require("./LKRPCommand"),r=require("./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 r.TLVParser(new Uint8Array([e.GeneralTags.Int,1,2,e.CommandTags.AddMember,3,e.GeneralTags.Int,1,1,e.CommandTags.Seed,3,e.GeneralTags.Int,1,2])).parseCommands();expect(a).toStrictEqual((0,n.Right)([new c.LKRPCommand(new Uint8Array([e.CommandTags.AddMember,3,e.GeneralTags.Int,1,1])),new c.LKRPCommand(new Uint8Array([e.CommandTags.Seed,3,e.GeneralTags.Int,1,2]))]))})}),describe("parseBlockData",()=>{it("should parse a valid block data",()=>{const a=new r.TLVParser(Uint8Array.from([[e.GeneralTags.Int,1,1],[e.GeneralTags.Hash,3,1,2,3],[e.GeneralTags.PublicKey,3,4,5,6],[e.GeneralTags.Int,1,2],[e.CommandTags.AddMember,3,e.GeneralTags.Int,1,1],[e.CommandTags.Seed,3,e.GeneralTags.Int,1,2],[e.GeneralTags.Signature,3,7,8,9]].flat())).parseBlockData();expect(a).toStrictEqual((0,n.Right)({parent:"010203",issuer:new Uint8Array([4,5,6]),header:Uint8Array.from([[e.GeneralTags.Int,1,1],[e.GeneralTags.Hash,3,1,2,3],[e.GeneralTags.PublicKey,3,4,5,6],[e.GeneralTags.Int,1,2]].flat()),commands:[new c.LKRPCommand(new Uint8Array([e.CommandTags.AddMember,3,e.GeneralTags.Int,1,1])),new c.LKRPCommand(new Uint8Array([e.CommandTags.Seed,3,e.GeneralTags.Int,1,2]))],signature:Uint8Array.from([e.GeneralTags.Signature,3,7,8,9])}))}),it("should fail if the block data is invalid",()=>{const a=new r.TLVParser(new Uint8Array([])).parseBlockData();expect(a).toEqual((0,n.Left)(new s.LKRPParsingError("Unexpected end of TLV")))})})}),describe("Command Data Parsing",()=>{describe("parseCommandBytes",()=>{it("should parse a valid command bytes",()=>{const a=new r.TLVParser(new Uint8Array([e.CommandTags.AddMember,3,1,2,3])).parseCommandBytes();expect(a).toEqual((0,n.Right)(new Uint8Array([e.CommandTags.AddMember,3,1,2,3])))}),it("should fail if the tag is not a command",()=>{const a=new r.TLVParser(new Uint8Array([e.GeneralTags.Int,1,1])).parseCommandBytes();expect(a).toEqual((0,n.Left)(new s.LKRPParsingError("Invalid command type: 0x01")))})}),describe("Parse Seed Command Data",()=>{it("should parse a valid seed command data",()=>{const t=new Uint8Array([e.GeneralTags.Bytes,3,1,2,3,e.GeneralTags.Int,2,1,2,e.GeneralTags.PublicKey,3,2,4,6,e.GeneralTags.Bytes,3,3,5,7,e.GeneralTags.Bytes,3,4,8,16,e.GeneralTags.PublicKey,3,10,11,12]),i=new r.TLVParser(new Uint8Array([e.CommandTags.Seed,t.length,...t])).parseCommandData();expect(i).toStrictEqual((0,n.Right)({type:e.CommandTags.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.GeneralTags.Signature,3,1,2,3]),a=new Uint8Array([e.GeneralTags.Bytes,3,1,2,3]),i=new r.TLVParser(new Uint8Array([e.CommandTags.Seed,t.length,...t])),x=new r.TLVParser(new Uint8Array([e.CommandTags.Seed,a.length,...a])),o=i.parseCommandData(),p=x.parseCommandData();expect(o).toEqual((0,n.Left)(new s.LKRPParsingError("Expected bytes"))),expect(p).toEqual((0,n.Left)(new s.LKRPParsingError("Unexpected end of TLV")))})}),describe("Parse AddMember Command Data",()=>{it("should parse a valid add member command data",()=>{const t=new Uint8Array([e.GeneralTags.String,5,65,108,105,99,101,e.GeneralTags.PublicKey,3,1,2,3,e.GeneralTags.Int,1,1]),i=new r.TLVParser(new Uint8Array([e.CommandTags.AddMember,t.length,...t])).parseCommandData();expect(i).toStrictEqual((0,n.Right)({type:e.CommandTags.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.GeneralTags.Bytes,3,1,2,3]),a=new Uint8Array([e.GeneralTags.String,5,65,108,105,99,101]),i=new r.TLVParser(new Uint8Array([e.CommandTags.AddMember,t.length,...t])),x=new r.TLVParser(new Uint8Array([e.CommandTags.AddMember,a.length,...a])),o=i.parseCommandData(),p=x.parseCommandData();expect(o).toEqual((0,n.Left)(new s.LKRPParsingError("Expected a string"))),expect(p).toEqual((0,n.Left)(new s.LKRPParsingError("Unexpected end of TLV")))})}),describe("Parse PublishKey Command Data",()=>{it("should parse a valid publish key command data",()=>{const t=new Uint8Array([e.GeneralTags.Bytes,3,1,2,3,e.GeneralTags.Bytes,3,4,5,6,e.GeneralTags.PublicKey,3,3,5,7,e.GeneralTags.PublicKey,3,8,9,10]),i=new r.TLVParser(new Uint8Array([e.CommandTags.PublishKey,t.length,...t])).parseCommandData();expect(i).toStrictEqual((0,n.Right)({type:e.CommandTags.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.GeneralTags.Int,2,1,2]),a=new Uint8Array([e.GeneralTags.Bytes,3,1,2,3]),i=new r.TLVParser(new Uint8Array([e.CommandTags.PublishKey,t.length,...t])),x=new r.TLVParser(new Uint8Array([e.CommandTags.PublishKey,a.length,...a])),o=i.parseCommandData(),p=x.parseCommandData();expect(o).toEqual((0,n.Left)(new s.LKRPParsingError("Expected bytes"))),expect(p).toEqual((0,n.Left)(new s.LKRPParsingError("Unexpected end of TLV")))})}),describe("Parse Derive Command Data",()=>{it("should parse a valid derive command data",()=>{const t=new Uint8Array([e.GeneralTags.Bytes,4,0,0,0,1,e.GeneralTags.PublicKey,3,4,5,6,e.GeneralTags.Bytes,3,3,5,7,e.GeneralTags.Bytes,3,8,9,10,e.GeneralTags.PublicKey,3,10,11,12]),i=new r.TLVParser(new Uint8Array([e.CommandTags.Derive,t.length,...t])).parseCommandData();expect(i).toStrictEqual((0,n.Right)({type:e.CommandTags.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.GeneralTags.Int,2,1,2]),a=new Uint8Array([e.GeneralTags.Bytes,3,1,2,3]),i=new r.TLVParser(new Uint8Array([e.CommandTags.Derive,t.length,...t])),x=new r.TLVParser(new Uint8Array([e.CommandTags.Derive,a.length,...a])),o=i.parseCommandData(),p=x.parseCommandData();expect(o).toEqual((0,n.Left)(new s.LKRPParsingError("Expected bytes"))),expect(p).toEqual((0,n.Left)(new s.LKRPParsingError("Unexpected end of TLV")))})}),it("should fail on unsupported command type",()=>{const a=new r.TLVParser(new Uint8Array([63,1,1])).parseCommandData();expect(a).toEqual((0,n.Left)(new s.LKRPParsingError("Unsupported command type: 0x3f")))})}),describe("General Types Parsing",()=>{describe("parse",()=>{it("should parse a valid TLV structure",()=>{const t=new r.TLVParser(new Uint8Array([e.GeneralTags.Int,1,1,e.GeneralTags.Bytes,0])),a=t.parse(),i=t.parse();expect(a).toEqual((0,n.Right)({tag:e.GeneralTags.Int,value:1})),expect(i).toEqual((0,n.Right)({tag:e.GeneralTags.Bytes,value:new Uint8Array([])}))}),it("should fail on invalid TLV structure",()=>{const t=new r.TLVParser(new Uint8Array([])),a=new r.TLVParser(new Uint8Array([e.GeneralTags.Int])),i=new r.TLVParser(new Uint8Array([e.GeneralTags.Int,2])),x=t.parse(),o=a.parse(),p=i.parse();expect(x).toEqual((0,n.Left)(new s.LKRPParsingError("Unexpected end of TLV"))),expect(o).toEqual((0,n.Left)(new s.LKRPParsingError("Invalid end of TLV, expected length"))),expect(p).toEqual((0,n.Left)(new s.LKRPParsingError("Invalid end of TLV value")))})}),describe("parseNull",()=>{it("should parse a null value",()=>{const a=new r.TLVParser(new Uint8Array([e.GeneralTags.Null,0])).parseNull();expect(a).toEqual((0,n.Right)(null))}),it("should fail if the tag is not null",()=>{const a=new r.TLVParser(new Uint8Array([e.GeneralTags.Int,1,1])).parseNull();expect(a).toEqual((0,n.Left)(new s.LKRPParsingError("Expected null")))}),it("should fail if the format is invalid",()=>{const a=new r.TLVParser(new Uint8Array([e.GeneralTags.Null,1,2])).parseNull();expect(a).toEqual((0,n.Left)(new s.LKRPParsingError("Invalid null length")))})}),describe("parseInt",()=>{it("should parse big endian integer values",()=>{const t=new r.TLVParser(new Uint8Array([e.GeneralTags.Int,1,1,e.GeneralTags.Int,2,1,0,e.GeneralTags.Int,4,1,0,0,0])),a=t.parseInt(),i=t.parseInt(),x=t.parseInt();expect(a).toEqual((0,n.Right)(1)),expect(i).toEqual((0,n.Right)(256)),expect(x).toEqual((0,n.Right)(16777216))}),it("should fail if the tag is not an integer",()=>{const a=new r.TLVParser(new Uint8Array([e.GeneralTags.Bytes,1,1])).parseInt();expect(a).toEqual((0,n.Left)(new s.LKRPParsingError("Expected a number")))}),it("should fail if the integer is not 1, 2, or 4 bytes",()=>{const a=new r.TLVParser(new Uint8Array([e.GeneralTags.Int,3,1,2,3])).parseInt();expect(a).toEqual((0,n.Left)(new s.LKRPParsingError("Unsupported integer length")))})}),describe("parseHash",()=>{it("should parse a hash value",()=>{const a=new r.TLVParser(new Uint8Array([e.GeneralTags.Hash,3,1,2,3])).parseHash();expect(a).toEqual((0,n.Right)(new Uint8Array([1,2,3])))}),it("should fail if the tag is not a hash",()=>{const a=new r.TLVParser(new Uint8Array([e.GeneralTags.Int,1,1])).parseHash();expect(a).toEqual((0,n.Left)(new s.LKRPParsingError("Expected a hash")))})}),describe("parseSignature",()=>{it("should parse a signature value",()=>{const a=new r.TLVParser(new Uint8Array([e.GeneralTags.Signature,3,1,2,3])).parseSignature();expect(a).toEqual((0,n.Right)(new Uint8Array([1,2,3])))}),it("should fail if the tag is not a signature",()=>{const a=new r.TLVParser(new Uint8Array([e.GeneralTags.Int,1,1])).parseSignature();expect(a).toEqual((0,n.Left)(new s.LKRPParsingError("Expected a signature")))})}),describe("parseString",()=>{it("should parse a string value",()=>{const a=new r.TLVParser(new Uint8Array([e.GeneralTags.String,5,72,101,108,108,111])).parseString();expect(a).toEqual((0,n.Right)("Hello"))}),it("should fail if the tag is not a string",()=>{const a=new r.TLVParser(new Uint8Array([e.GeneralTags.Int,1,1])).parseString();expect(a).toEqual((0,n.Left)(new s.LKRPParsingError("Expected a string")))})}),describe("parseBytes",()=>{it("should parse a bytes value",()=>{const a=new r.TLVParser(new Uint8Array([e.GeneralTags.Bytes,3,1,2,3])).parseBytes();expect(a).toEqual((0,n.Right)(new Uint8Array([1,2,3])))}),it("should fail if the tag is not bytes",()=>{const a=new r.TLVParser(new Uint8Array([e.GeneralTags.Int,1,1])).parseBytes();expect(a).toEqual((0,n.Left)(new s.LKRPParsingError("Expected bytes")))})}),describe("parsePublicKey",()=>{it("should parse a public key value",()=>{const a=new r.TLVParser(new Uint8Array([e.GeneralTags.PublicKey,3,1,2,3])).parsePublicKey();expect(a).toEqual((0,n.Right)(new Uint8Array([1,2,3])))}),it("should fail if the tag is not a public key",()=>{const a=new r.TLVParser(new Uint8Array([e.GeneralTags.Int,1,1])).parsePublicKey();expect(a).toEqual((0,n.Left)(new s.LKRPParsingError("Expected a public key")))})})})});
|
|
1
|
+
"use strict";var n=require("purify-ts"),s=require("../../api/model/Errors"),e=require("../models/Tags"),c=require("./LKRPCommand"),r=require("./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 r.TLVParser(new Uint8Array([e.GeneralTags.Int,1,2,e.CommandTags.AddMember,3,e.GeneralTags.Int,1,1,e.CommandTags.Seed,3,e.GeneralTags.Int,1,2])).parseCommands();expect(a).toStrictEqual((0,n.Right)([new c.LKRPCommand(new Uint8Array([e.CommandTags.AddMember,3,e.GeneralTags.Int,1,1])),new c.LKRPCommand(new Uint8Array([e.CommandTags.Seed,3,e.GeneralTags.Int,1,2]))]))})}),describe("parseBlockData",()=>{it("should parse a valid block data",()=>{const a=new r.TLVParser(Uint8Array.from([[e.GeneralTags.Int,1,1],[e.GeneralTags.Hash,3,1,2,3],[e.GeneralTags.PublicKey,3,4,5,6],[e.GeneralTags.Int,1,2],[e.CommandTags.AddMember,3,e.GeneralTags.Int,1,1],[e.CommandTags.Seed,3,e.GeneralTags.Int,1,2],[e.GeneralTags.Signature,3,7,8,9]].flat())).parseBlockData();expect(a).toStrictEqual((0,n.Right)({parent:"010203",issuer:new Uint8Array([4,5,6]),header:Uint8Array.from([[e.GeneralTags.Int,1,1],[e.GeneralTags.Hash,3,1,2,3],[e.GeneralTags.PublicKey,3,4,5,6],[e.GeneralTags.Int,1,2]].flat()),commands:[new c.LKRPCommand(new Uint8Array([e.CommandTags.AddMember,3,e.GeneralTags.Int,1,1])),new c.LKRPCommand(new Uint8Array([e.CommandTags.Seed,3,e.GeneralTags.Int,1,2]))],signature:Uint8Array.from([e.GeneralTags.Signature,3,7,8,9])}))}),it("should fail if the block data is invalid",()=>{const a=new r.TLVParser(new Uint8Array([])).parseBlockData();expect(a).toEqual((0,n.Left)(new s.LKRPParsingError("Unexpected end of TLV")))})})}),describe("Command Data Parsing",()=>{describe("parseCommandBytes",()=>{it("should parse a valid command bytes",()=>{const a=new r.TLVParser(new Uint8Array([e.CommandTags.AddMember,3,1,2,3])).parseCommandBytes();expect(a).toEqual((0,n.Right)(new Uint8Array([e.CommandTags.AddMember,3,1,2,3])))}),it("should fail if the tag is not a command",()=>{const a=new r.TLVParser(new Uint8Array([e.GeneralTags.Int,1,1])).parseCommandBytes();expect(a).toEqual((0,n.Left)(new s.LKRPParsingError("Invalid command type: 0x01")))})}),describe("Parse Seed Command Data",()=>{it("should parse a valid seed command data",()=>{const t=new Uint8Array([e.GeneralTags.Bytes,3,1,2,3,e.GeneralTags.Int,2,1,2,e.GeneralTags.PublicKey,3,2,4,6,e.GeneralTags.Bytes,3,3,5,7,e.GeneralTags.Bytes,3,4,8,16,e.GeneralTags.PublicKey,3,10,11,12]),i=new r.TLVParser(new Uint8Array([e.CommandTags.Seed,t.length,...t])).parseCommandData();expect(i).toStrictEqual((0,n.Right)({type:e.CommandTags.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.GeneralTags.Signature,3,1,2,3]),a=new Uint8Array([e.GeneralTags.Bytes,3,1,2,3]),i=new r.TLVParser(new Uint8Array([e.CommandTags.Seed,t.length,...t])),x=new r.TLVParser(new Uint8Array([e.CommandTags.Seed,a.length,...a])),o=i.parseCommandData(),p=x.parseCommandData();expect(o).toEqual((0,n.Left)(new s.LKRPParsingError("Expected bytes"))),expect(p).toEqual((0,n.Left)(new s.LKRPParsingError("Unexpected end of TLV")))})}),describe("Parse AddMember Command Data",()=>{it("should parse a valid add member command data",()=>{const t=new Uint8Array([e.GeneralTags.String,5,65,108,105,99,101,e.GeneralTags.PublicKey,3,1,2,3,e.GeneralTags.Int,1,1]),i=new r.TLVParser(new Uint8Array([e.CommandTags.AddMember,t.length,...t])).parseCommandData();expect(i).toStrictEqual((0,n.Right)({type:e.CommandTags.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.GeneralTags.Bytes,3,1,2,3]),a=new Uint8Array([e.GeneralTags.String,5,65,108,105,99,101]),i=new r.TLVParser(new Uint8Array([e.CommandTags.AddMember,t.length,...t])),x=new r.TLVParser(new Uint8Array([e.CommandTags.AddMember,a.length,...a])),o=i.parseCommandData(),p=x.parseCommandData();expect(o).toEqual((0,n.Left)(new s.LKRPParsingError("Expected a string"))),expect(p).toEqual((0,n.Left)(new s.LKRPParsingError("Unexpected end of TLV")))})}),describe("Parse PublishKey Command Data",()=>{it("should parse a valid publish key command data",()=>{const t=new Uint8Array([e.GeneralTags.Bytes,3,1,2,3,e.GeneralTags.Bytes,3,4,5,6,e.GeneralTags.PublicKey,3,3,5,7,e.GeneralTags.PublicKey,3,8,9,10]),i=new r.TLVParser(new Uint8Array([e.CommandTags.PublishKey,t.length,...t])).parseCommandData();expect(i).toStrictEqual((0,n.Right)({type:e.CommandTags.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.GeneralTags.Int,2,1,2]),a=new Uint8Array([e.GeneralTags.Bytes,3,1,2,3]),i=new r.TLVParser(new Uint8Array([e.CommandTags.PublishKey,t.length,...t])),x=new r.TLVParser(new Uint8Array([e.CommandTags.PublishKey,a.length,...a])),o=i.parseCommandData(),p=x.parseCommandData();expect(o).toEqual((0,n.Left)(new s.LKRPParsingError("Expected bytes"))),expect(p).toEqual((0,n.Left)(new s.LKRPParsingError("Unexpected end of TLV")))})}),describe("Parse Derive Command Data",()=>{it("should parse a valid derive command data",()=>{const t=new Uint8Array([e.GeneralTags.Bytes,4,0,0,0,1,e.GeneralTags.PublicKey,3,4,5,6,e.GeneralTags.Bytes,3,3,5,7,e.GeneralTags.Bytes,3,8,9,10,e.GeneralTags.PublicKey,3,10,11,12]),i=new r.TLVParser(new Uint8Array([e.CommandTags.Derive,t.length,...t])).parseCommandData();expect(i).toStrictEqual((0,n.Right)({type:e.CommandTags.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.GeneralTags.Int,2,1,2]),a=new Uint8Array([e.GeneralTags.Bytes,3,1,2,3]),i=new r.TLVParser(new Uint8Array([e.CommandTags.Derive,t.length,...t])),x=new r.TLVParser(new Uint8Array([e.CommandTags.Derive,a.length,...a])),o=i.parseCommandData(),p=x.parseCommandData();expect(o).toEqual((0,n.Left)(new s.LKRPParsingError("Expected bytes"))),expect(p).toEqual((0,n.Left)(new s.LKRPParsingError("Unexpected end of TLV")))})}),it("should fail on unsupported command type",()=>{const a=new r.TLVParser(new Uint8Array([63,1,1])).parseCommandData();expect(a).toEqual((0,n.Left)(new s.LKRPParsingError("Unsupported command type: 0x3f")))})}),describe("General Types Parsing",()=>{describe("parse",()=>{it("should parse a valid TLV structure",()=>{const t=new r.TLVParser(new Uint8Array([e.GeneralTags.Int,1,1,e.GeneralTags.Bytes,0])),a=t.parse(),i=t.parse();expect(a).toEqual((0,n.Right)({tag:e.GeneralTags.Int,value:1})),expect(i).toEqual((0,n.Right)({tag:e.GeneralTags.Bytes,value:new Uint8Array([])}))}),it("should fail on invalid TLV structure",()=>{const t=new r.TLVParser(new Uint8Array([])),a=new r.TLVParser(new Uint8Array([e.GeneralTags.Int])),i=new r.TLVParser(new Uint8Array([e.GeneralTags.Int,2])),x=t.parse(),o=a.parse(),p=i.parse();expect(x).toEqual((0,n.Left)(new s.LKRPParsingError("Unexpected end of TLV"))),expect(o).toEqual((0,n.Left)(new s.LKRPParsingError("Invalid end of TLV, expected length"))),expect(p).toEqual((0,n.Left)(new s.LKRPParsingError("Invalid end of TLV value")))})}),describe("parseNull",()=>{it("should parse a null value",()=>{const a=new r.TLVParser(new Uint8Array([e.GeneralTags.Null,0])).parseNull();expect(a).toEqual((0,n.Right)(null))}),it("should fail if the tag is not null",()=>{const a=new r.TLVParser(new Uint8Array([e.GeneralTags.Int,1,1])).parseNull();expect(a).toEqual((0,n.Left)(new s.LKRPParsingError("Expected null")))}),it("should fail if the format is invalid",()=>{const a=new r.TLVParser(new Uint8Array([e.GeneralTags.Null,1,2])).parseNull();expect(a).toEqual((0,n.Left)(new s.LKRPParsingError("Invalid null length")))})}),describe("parseInt",()=>{it("should parse big endian integer values",()=>{const t=new r.TLVParser(new Uint8Array([e.GeneralTags.Int,1,1,e.GeneralTags.Int,2,1,0,e.GeneralTags.Int,4,1,0,0,0])),a=t.parseInt(),i=t.parseInt(),x=t.parseInt();expect(a).toEqual((0,n.Right)(1)),expect(i).toEqual((0,n.Right)(256)),expect(x).toEqual((0,n.Right)(16777216))}),it("should fail if the tag is not an integer",()=>{const a=new r.TLVParser(new Uint8Array([e.GeneralTags.Bytes,1,1])).parseInt();expect(a).toEqual((0,n.Left)(new s.LKRPParsingError("Expected a number")))}),it("should fail if the integer is not 1, 2, or 4 bytes",()=>{const a=new r.TLVParser(new Uint8Array([e.GeneralTags.Int,3,1,2,3])).parseInt();expect(a).toEqual((0,n.Left)(new s.LKRPParsingError("Unsupported integer length")))})}),describe("parseHash",()=>{it("should parse a hash value",()=>{const a=new r.TLVParser(new Uint8Array([e.GeneralTags.Hash,3,1,2,3])).parseHash();expect(a).toEqual((0,n.Right)(new Uint8Array([1,2,3])))}),it("should fail if the tag is not a hash",()=>{const a=new r.TLVParser(new Uint8Array([e.GeneralTags.Int,1,1])).parseHash();expect(a).toEqual((0,n.Left)(new s.LKRPParsingError("Expected a hash")))})}),describe("parseSignature",()=>{it("should parse a signature value",()=>{const a=new r.TLVParser(new Uint8Array([e.GeneralTags.Signature,3,1,2,3])).parseSignature();expect(a).toEqual((0,n.Right)(new Uint8Array([1,2,3])))}),it("should fail if the tag is not a signature",()=>{const a=new r.TLVParser(new Uint8Array([e.GeneralTags.Int,1,1])).parseSignature();expect(a).toEqual((0,n.Left)(new s.LKRPParsingError("Expected a signature")))})}),describe("parseString",()=>{it("should parse a string value",()=>{const a=new r.TLVParser(new Uint8Array([e.GeneralTags.String,5,72,101,108,108,111])).parseString();expect(a).toEqual((0,n.Right)("Hello"))}),it("should fail if the tag is not a string",()=>{const a=new r.TLVParser(new Uint8Array([e.GeneralTags.Int,1,1])).parseString();expect(a).toEqual((0,n.Left)(new s.LKRPParsingError("Expected a string")))})}),describe("parseBytes",()=>{it("should parse a bytes value",()=>{const a=new r.TLVParser(new Uint8Array([e.GeneralTags.Bytes,3,1,2,3])).parseBytes();expect(a).toEqual((0,n.Right)(new Uint8Array([1,2,3])))}),it("should fail if the tag is not bytes",()=>{const a=new r.TLVParser(new Uint8Array([e.GeneralTags.Int,1,1])).parseBytes();expect(a).toEqual((0,n.Left)(new s.LKRPParsingError("Expected bytes")))})}),describe("parsePublicKey",()=>{it("should parse a public key value",()=>{const a=new r.TLVParser(new Uint8Array([e.GeneralTags.PublicKey,3,1,2,3])).parsePublicKey();expect(a).toEqual((0,n.Right)(new Uint8Array([1,2,3])))}),it("should fail if the tag is not a public key",()=>{const a=new r.TLVParser(new Uint8Array([e.GeneralTags.Int,1,1])).parsePublicKey();expect(a).toEqual((0,n.Left)(new s.LKRPParsingError("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\";\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,IAAAA,EAA4B,qBAE5BC,EAAiC,kCACjCC,EAAyC,iCAEzCC,EAA4B,yBAC5BC,EAA0B,uBAE1B,SAAS,YAAa,IAAM,CAC1B,SAAS,qBAAsB,IAAM,CACnC,SAAS,gBAAiB,IAAM,CAC9B,GAAG,0EAA2E,IAAM,CAUlF,MAAMC,EARS,IAAI,YACjB,IAAI,WAAW,CACT,cAAY,IAAK,EAAG,EACpB,cAAY,UAAW,EAAO,cAAY,IAAK,EAAG,EAClD,cAAY,KAAM,EAAO,cAAY,IAAK,EAAG,CACnD,CAAC,CACH,EAEwB,cAAc,EAGtC,OAAOA,CAAQ,EAAE,iBACf,SAAM,CACJ,IAAI,cACF,IAAI,WAAW,CACb,cAAY,UACZ,EACI,cAAY,IAAK,EAAG,CAC1B,CAAC,CACH,EACA,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I,mBAAiB,mBAAmB,CAAC,CAAC,CACvE,CAAC,CACH,CAAC,EAED,SAAS,aAAc,IAAM,CAC3B,GAAG,6BAA8B,IAAM,CAMrC,MAAMA,EAJS,IAAI,YACjB,IAAI,WAAW,CAAC,cAAY,MAAO,EAAG,EAAM,EAAM,CAAI,CAAC,CACzD,EAEqB,WAAW,EAEhC,OAAOA,CAAK,EAAE,WAAQ,SAAM,IAAI,WAAW,CAAC,EAAM,EAAM,CAAI,CAAC,CAAC,CAAC,CACjE,CAAC,EAED,GAAG,sCAAuC,IAAM,CAM9C,MAAMA,EAJS,IAAI,YACjB,IAAI,WAAW,CAAC,cAAY,IAAK,EAAG,CAAI,CAAC,CAC3C,EAEqB,WAAW,EAEhC,OAAOA,CAAK,EAAE,WAAQ,QAAK,IAAI,mBAAiB,gBAAgB,CAAC,CAAC,CACpE,CAAC,CACH,CAAC,EAED,SAAS,iBAAkB,IAAM,CAC/B,GAAG,kCAAmC,IAAM,CAM1C,MAAMA,EAJS,IAAI,YACjB,IAAI,WAAW,CAAC,cAAY,UAAW,EAAG,EAAM,EAAM,CAAI,CAAC,CAC7D,EAEqB,eAAe,EAEpC,OAAOA,CAAK,EAAE,WAAQ,SAAM,IAAI,WAAW,CAAC,EAAM,EAAM,CAAI,CAAC,CAAC,CAAC,CACjE,CAAC,EAED,GAAG,6CAA8C,IAAM,CAMrD,MAAMA,EAJS,IAAI,YACjB,IAAI,WAAW,CAAC,cAAY,IAAK,EAAG,CAAI,CAAC,CAC3C,EAEqB,eAAe,EAEpC,OAAOA,CAAK,EAAE,WACZ,QAAK,IAAI,mBAAiB,uBAAuB,CAAC,CACpD,CACF,CAAC,CACH,CAAC,CACH,CAAC,CACH,CAAC",
|
|
4
|
+
"sourcesContent": ["import { Left, Right } from \"purify-ts\";\n\nimport { LKRPParsingError } from \"@api/model/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,IAAAA,EAA4B,qBAE5BC,EAAiC,6BACjCC,EAAyC,iCAEzCC,EAA4B,yBAC5BC,EAA0B,uBAE1B,SAAS,YAAa,IAAM,CAC1B,SAAS,qBAAsB,IAAM,CACnC,SAAS,gBAAiB,IAAM,CAC9B,GAAG,0EAA2E,IAAM,CAUlF,MAAMC,EARS,IAAI,YACjB,IAAI,WAAW,CACT,cAAY,IAAK,EAAG,EACpB,cAAY,UAAW,EAAO,cAAY,IAAK,EAAG,EAClD,cAAY,KAAM,EAAO,cAAY,IAAK,EAAG,CACnD,CAAC,CACH,EAEwB,cAAc,EAGtC,OAAOA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PCommand", "import_TLVParser", "commands", "blockData", "value", "parsed", "value1", "value2", "parser1", "parser2", "parsed1", "parsed2", "parser", "parser3", "value3", "value4"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var o=Object.defineProperty;var l=Object.getOwnPropertyDescriptor;var m=Object.getOwnPropertyNames;var a=Object.prototype.hasOwnProperty;var d=(e,r)=>{for(var n in r)o(e,n,{get:r[n],enumerable:!0})},p=(e,r,n,t)=>{if(r&&typeof r=="object"||typeof r=="function")for(let i of m(r))!a.call(e,i)&&i!==n&&o(e,i,{get:()=>r[i],enumerable:!(t=l(r,i))||t.enumerable});return e};var s=e=>p(o({},"__esModule",{value:!0}),e);var g={};d(g,{required:()=>b});module.exports=s(g);var u=require("purify-ts"),f=require("../../api/
|
|
1
|
+
"use strict";var o=Object.defineProperty;var l=Object.getOwnPropertyDescriptor;var m=Object.getOwnPropertyNames;var a=Object.prototype.hasOwnProperty;var d=(e,r)=>{for(var n in r)o(e,n,{get:r[n],enumerable:!0})},p=(e,r,n,t)=>{if(r&&typeof r=="object"||typeof r=="function")for(let i of m(r))!a.call(e,i)&&i!==n&&o(e,i,{get:()=>r[i],enumerable:!(t=l(r,i))||t.enumerable});return e};var s=e=>p(o({},"__esModule",{value:!0}),e);var g={};d(g,{required:()=>b});module.exports=s(g);var u=require("purify-ts"),f=require("../../api/model/Errors");function b(e,r){return u.Maybe.fromNullable(e).toEither(new f.LKRPMissingDataError(r))}0&&(module.exports={required});
|
|
2
2
|
//# sourceMappingURL=required.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/internal/utils/required.ts"],
|
|
4
|
-
"sourcesContent": ["import { Maybe } from \"purify-ts\";\n\nimport { LKRPMissingDataError } from \"@api/
|
|
5
|
-
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,cAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAsB,qBAEtBC,EAAqC,
|
|
4
|
+
"sourcesContent": ["import { Maybe } from \"purify-ts\";\n\nimport { LKRPMissingDataError } from \"@api/model/Errors\";\n\nexport function required<T>(prop: T | undefined | null, errorMsg: string) {\n return Maybe.fromNullable(prop).toEither(new LKRPMissingDataError(errorMsg));\n}\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,cAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAsB,qBAEtBC,EAAqC,6BAE9B,SAASH,EAAYI,EAA4BC,EAAkB,CACxE,OAAO,QAAM,aAAaD,CAAI,EAAE,SAAS,IAAI,uBAAqBC,CAAQ,CAAC,CAC7E",
|
|
6
6
|
"names": ["required_exports", "__export", "required", "__toCommonJS", "import_purify_ts", "import_Errors", "prop", "errorMsg"]
|
|
7
7
|
}
|
package/lib/cjs/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ledgerhq/device-trusted-app-kit-ledger-keyring-protocol",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"private": false,
|
|
6
6
|
"exports": {
|
|
@@ -38,8 +38,8 @@
|
|
|
38
38
|
"@ledgerhq/device-management-kit": "workspace:*",
|
|
39
39
|
"@ledgerhq/signer-utils": "workspace:*",
|
|
40
40
|
"@noble/ciphers": "^1.3.0",
|
|
41
|
+
"@noble/curves": "^1.9.7",
|
|
41
42
|
"@noble/hashes": "^1.8.0",
|
|
42
|
-
"@noble/secp256k1": "^2.3.0",
|
|
43
43
|
"inversify": "catalog:",
|
|
44
44
|
"purify-ts": "catalog:",
|
|
45
45
|
"reflect-metadata": "catalog:",
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{DefaultLedgerKeyringProtocol as
|
|
1
|
+
import{NobleCryptoService as r}from"./crypto/noble/NobleCryptoService";import{DefaultLedgerKeyringProtocol as t}from"../internal/DefaultLedgerKeyringProtocol";class p{dmk;applicationId;env;baseUrl;cryptoService=new r;constructor(e){this.dmk=e.dmk,this.applicationId=e.applicationId,this.env=e.env,this.baseUrl=e.baseUrl}withCryptoService(e){return this.cryptoService=e,this}build(){return new t({dmk:this.dmk,applicationId:this.applicationId,cryptoService:this.cryptoService,env:this.env,baseUrl:this.baseUrl})}}export{p as LedgerKeyringProtocolBuilder};
|
|
2
2
|
//# sourceMappingURL=LedgerKeyringProtocolBuilder.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/api/LedgerKeyringProtocolBuilder.ts"],
|
|
4
|
-
"sourcesContent": ["import { type DeviceManagementKit } from \"@ledgerhq/device-management-kit\";\n\nimport { type
|
|
5
|
-
"mappings": "AAGA,OAAS,
|
|
6
|
-
"names": ["DefaultLedgerKeyringProtocol", "LedgerKeyringProtocolBuilder", "args"]
|
|
4
|
+
"sourcesContent": ["import { type DeviceManagementKit } from \"@ledgerhq/device-management-kit\";\n\nimport { type CryptoService } from \"@api/crypto/CryptoService\";\nimport { NobleCryptoService } from \"@api/crypto/noble/NobleCryptoService\";\nimport { type LedgerKeyringProtocol } from \"@api/LedgerKeyringProtocol\";\nimport { type LKRPEnv } from \"@api/model/Env\";\nimport { DefaultLedgerKeyringProtocol } from \"@internal/DefaultLedgerKeyringProtocol\";\n\nexport class LedgerKeyringProtocolBuilder {\n private readonly dmk: DeviceManagementKit;\n private readonly applicationId: number;\n private readonly env?: LKRPEnv;\n private readonly baseUrl?: string;\n private cryptoService: CryptoService = new NobleCryptoService();\n\n constructor(args: {\n dmk: DeviceManagementKit;\n applicationId: number;\n env?: LKRPEnv;\n baseUrl?: string;\n }) {\n this.dmk = args.dmk;\n this.applicationId = args.applicationId;\n this.env = args.env;\n this.baseUrl = args.baseUrl;\n }\n\n withCryptoService(service: CryptoService): LedgerKeyringProtocolBuilder {\n this.cryptoService = service;\n return this;\n }\n\n build(): LedgerKeyringProtocol {\n return new DefaultLedgerKeyringProtocol({\n dmk: this.dmk,\n applicationId: this.applicationId,\n cryptoService: this.cryptoService,\n env: this.env,\n baseUrl: this.baseUrl,\n });\n }\n}\n"],
|
|
5
|
+
"mappings": "AAGA,OAAS,sBAAAA,MAA0B,uCAGnC,OAAS,gCAAAC,MAAoC,yCAEtC,MAAMC,CAA6B,CACvB,IACA,cACA,IACA,QACT,cAA+B,IAAIF,EAE3C,YAAYG,EAKT,CACD,KAAK,IAAMA,EAAK,IAChB,KAAK,cAAgBA,EAAK,cAC1B,KAAK,IAAMA,EAAK,IAChB,KAAK,QAAUA,EAAK,OACtB,CAEA,kBAAkBC,EAAsD,CACtE,YAAK,cAAgBA,EACd,IACT,CAEA,OAA+B,CAC7B,OAAO,IAAIH,EAA6B,CACtC,IAAK,KAAK,IACV,cAAe,KAAK,cACpB,cAAe,KAAK,cACpB,IAAK,KAAK,IACV,QAAS,KAAK,OAChB,CAAC,CACH,CACF",
|
|
6
|
+
"names": ["NobleCryptoService", "DefaultLedgerKeyringProtocol", "LedgerKeyringProtocolBuilder", "args", "service"]
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/api/app-binder/AddToTrustchainDeviceActionTypes.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n type OpenAppDAError,\n type UserInteractionRequired,\n} from \"@ledgerhq/device-management-kit\";\nimport { type Either } from \"purify-ts\";\n\nimport { type
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["import {\n type OpenAppDAError,\n type UserInteractionRequired,\n} from \"@ledgerhq/device-management-kit\";\nimport { type Either } from \"purify-ts\";\n\nimport { type CryptoService } from \"@api/crypto/CryptoService\";\nimport { type KeyPair } from \"@api/crypto/KeyPair\";\nimport {\n type LKRPDataSourceError,\n type LKRPMissingDataError,\n type LKRPOutdatedTrustchainError,\n type LKRPParsingError,\n type LKRPTrustchainNotReady,\n type LKRPUnknownError,\n} from \"@api/model/Errors\";\nimport { type JWT } from \"@api/model/JWT\";\nimport { type Permissions } from \"@api/model/Permissions\";\nimport { type LKRPDeviceCommandError } from \"@internal/app-binder/command/utils/ledgerKeyringProtocolErrors\";\nimport { type LKRPDataSource } from \"@internal/lkrp-datasource/data/LKRPDataSource\";\nimport { type Trustchain } from \"@internal/utils/Trustchain\";\n\nexport type AddToTrustchainDAOutput = undefined;\n\nexport type AddToTrustchainDAInput = Either<\n LKRPMissingDataError,\n {\n readonly lkrpDataSource: LKRPDataSource;\n readonly cryptoService: CryptoService;\n readonly keypair: KeyPair;\n readonly jwt: JWT;\n readonly appId: number;\n readonly trustchain: Trustchain;\n readonly clientName: string;\n readonly permissions: Permissions;\n }\n>;\n\nexport type AddToTrustchainDAError =\n | LKRPDeviceCommandError\n | LKRPDataSourceError\n | LKRPParsingError\n | LKRPMissingDataError\n | LKRPOutdatedTrustchainError\n | LKRPTrustchainNotReady\n | OpenAppDAError\n | LKRPUnknownError;\n\nexport type AddToTrustchainDAIntermediateValue =\n | {\n requiredUserInteraction: UserInteractionRequired.None;\n step?:\n | AddToTrustchaineDAStep.Initialize\n | AddToTrustchaineDAStep.ParseStream;\n }\n | {\n requiredUserInteraction: AddToTrustchainDAState.AddMember;\n step: AddToTrustchaineDAStep.AddMember;\n };\n\nexport enum AddToTrustchainDAState {\n AddMember = \"lkrp-add-member\",\n}\n\nexport enum AddToTrustchaineDAStep {\n Initialize = \"lkrp-init-transaction\",\n ParseStream = \"lkrp-parse-stream\",\n AddMember = \"lkrp-add-member\",\n}\n\nexport type AddToTrustchainDAInternalState = Either<\n AddToTrustchainDAError,\n {\n readonly sessionKeypair: KeyPair | null;\n }\n>;\n"],
|
|
5
|
+
"mappings": "AA4DO,IAAKA,OACVA,EAAA,UAAY,kBADFA,OAAA,IAIAC,OACVA,EAAA,WAAa,wBACbA,EAAA,YAAc,oBACdA,EAAA,UAAY,kBAHFA,OAAA",
|
|
6
6
|
"names": ["AddToTrustchainDAState", "AddToTrustchaineDAStep"]
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/api/app-binder/AuthenticateDeviceActionTypes.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n type ExecuteDeviceActionReturnType,\n type OpenAppDAError,\n type OpenAppDARequiredInteraction,\n type UserInteractionRequired,\n} from \"@ledgerhq/device-management-kit\";\n\nimport {
|
|
4
|
+
"sourcesContent": ["import {\n type ExecuteDeviceActionReturnType,\n type OpenAppDAError,\n type OpenAppDARequiredInteraction,\n type UserInteractionRequired,\n} from \"@ledgerhq/device-management-kit\";\n\nimport {\n type LKRPDataSourceError,\n type LKRPMissingDataError,\n type LKRPParsingError,\n type LKRPTrustchainNotReady,\n type LKRPUnauthorizedError,\n type LKRPUnknownError,\n} from \"@api/model/Errors\";\nimport { type JWT } from \"@api/model/JWT\";\nimport { type LKRPDeviceCommandError } from \"@internal/app-binder/command/utils/ledgerKeyringProtocolErrors\";\n\nimport {\n type AddToTrustchainDAError,\n type AddToTrustchainDAIntermediateValue,\n} from \"./AddToTrustchainDeviceActionTypes\";\n\nexport type AuthenticateDAReturnType = ExecuteDeviceActionReturnType<\n AuthenticateDAOutput,\n AuthenticateDAError,\n AuthenticateDAIntermediateValue\n>;\n\nexport type AuthenticateDAOutput = {\n readonly jwt: JWT;\n readonly trustchainId: string;\n readonly applicationPath: string;\n readonly encryptionKey: Uint8Array;\n};\n\nexport type AuthenticateDAError =\n | LKRPUnauthorizedError\n | AddToTrustchainDAError\n | LKRPDeviceCommandError\n | LKRPDataSourceError\n | LKRPParsingError\n | LKRPMissingDataError\n | LKRPTrustchainNotReady\n | OpenAppDAError\n | LKRPUnknownError;\n\nexport type AuthenticateDAIntermediateValue =\n | {\n requiredUserInteraction: OpenAppDARequiredInteraction;\n step: AuthenticateDAStep.OpenApp;\n }\n | {\n requiredUserInteraction: AuthenticateDAState.Authenticate;\n step: AuthenticateDAStep.Authenticate;\n }\n | {\n requiredUserInteraction: UserInteractionRequired.None;\n step?:\n | AuthenticateDAStep.Authenticate\n | AuthenticateDAStep.GetTrustchain\n | AuthenticateDAStep.ExtractEncryptionKey;\n }\n | AddToTrustchainDAIntermediateValue;\n\nexport enum AuthenticateDAState {\n Authenticate = \"lkrp-authenticate\",\n}\nexport enum AuthenticateDAStep {\n OpenApp = \"lkrp.steps.openApp\",\n Authenticate = \"lkrp.steps.authenticate\",\n GetTrustchain = \"lkrp.steps.getTrustchain\",\n ExtractEncryptionKey = \"lkrp.steps.extractEncryptionKey\",\n}\n"],
|
|
5
5
|
"mappings": "AAiEO,IAAKA,OACVA,EAAA,aAAe,oBADLA,OAAA,IAGAC,OACVA,EAAA,QAAU,qBACVA,EAAA,aAAe,0BACfA,EAAA,cAAgB,2BAChBA,EAAA,qBAAuB,kCAJbA,OAAA",
|
|
6
6
|
"names": ["AuthenticateDAState", "AuthenticateDAStep"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/api/crypto/CryptoService.ts"],
|
|
4
|
+
"sourcesContent": ["import { type Key } from \"./Key\";\nimport { type KeyPair } from \"./KeyPair\";\n\nexport enum Curve {\n K256, // secp256k1\n P256, // P-256\n}\n\nexport enum EncryptionAlgo {\n AES256_GCM,\n}\n\nexport enum HashAlgo {\n SHA256,\n}\n\nexport interface CryptoService {\n // Generate a random buffer\n randomBytes(len: number): Uint8Array;\n\n // Compute a hash\n hash(bytes: Uint8Array, algo: HashAlgo): Uint8Array;\n\n // Compute a HMAC\n hmac(key: Uint8Array, message: Uint8Array, algo: HashAlgo): Uint8Array;\n\n // Generate a new random keypair\n createKeyPair(curve: Curve): Promise<KeyPair>;\n\n // Import a keypair\n importKeyPair(privateKey: Uint8Array, curve: Curve): KeyPair;\n\n // Generate a new random symmetric key\n createSymmetricKey(algo: EncryptionAlgo): Promise<Key>;\n\n // Import a symmetric key\n importSymmetricKey(keyMaterial: Uint8Array, algo: EncryptionAlgo): Key;\n}\n"],
|
|
5
|
+
"mappings": "AAGO,IAAKA,OACVA,IAAA,eACAA,IAAA,eAFUA,OAAA,IAKAC,OACVA,IAAA,2BADUA,OAAA,IAIAC,OACVA,IAAA,mBADUA,OAAA",
|
|
6
|
+
"names": ["Curve", "EncryptionAlgo", "HashAlgo"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/api/crypto/Key.ts"],
|
|
4
|
+
"sourcesContent": ["export const AES256_KEY_SIZE = 32;\nexport const AES256_BLOCK_SIZE = 16;\n\nexport interface Key {\n encrypt(iv: Uint8Array, data: Uint8Array): Promise<Uint8Array>;\n decrypt(iv: Uint8Array, encryptedData: Uint8Array): Promise<Uint8Array>;\n}\n"],
|
|
5
|
+
"mappings": "AAAO,MAAMA,EAAkB,GAClBC,EAAoB",
|
|
6
|
+
"names": ["AES256_KEY_SIZE", "AES256_BLOCK_SIZE"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/api/crypto/KeyPair.ts"],
|
|
4
|
+
"sourcesContent": ["export enum SigFormat {\n COMPACT,\n DER,\n}\n\nexport interface KeyPair {\n id: string;\n sign(data: Uint8Array, format?: SigFormat): Promise<Uint8Array>;\n verify(\n data: Uint8Array,\n signature: Uint8Array,\n format?: SigFormat,\n ): Promise<boolean>;\n deriveSharedSecret(peerPublicKey: Uint8Array): Promise<Uint8Array>;\n getPublicKey(): Uint8Array;\n getPublicKeyToHex(): string;\n}\n"],
|
|
5
|
+
"mappings": "AAAO,IAAKA,OACVA,IAAA,qBACAA,IAAA,aAFUA,OAAA",
|
|
6
|
+
"names": ["SigFormat"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{randomBytes as m}from"@noble/ciphers/webcrypto";import{hmac as n}from"@noble/hashes/hmac";import{sha256 as o}from"@noble/hashes/sha256";import{HashAlgo as i}from"../../crypto/CryptoService";import{NobleKey as a}from"./NobleKey";import{NobleKeyPair as y}from"./NobleKeyPair";class f{randomBytes(r){return m(r)}hash(r,e){switch(e){case i.SHA256:return o(r);default:throw new Error("Unsupported hash algorithm",e)}}hmac(r,e,t){switch(t){case i.SHA256:return n(o,r,e);default:throw new Error("Unsupported hash algorithm",t)}}async createKeyPair(r){return await y.generate(r)}importKeyPair(r,e){return y.from(r,e)}async createSymmetricKey(r){return await a.generate(r)}importSymmetricKey(r,e){return a.from(r,e)}}export{f as NobleCryptoService};
|
|
2
|
+
//# sourceMappingURL=NobleCryptoService.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/api/crypto/noble/NobleCryptoService.ts"],
|
|
4
|
+
"sourcesContent": ["import { randomBytes } from \"@noble/ciphers/webcrypto\";\nimport { hmac } from \"@noble/hashes/hmac\";\nimport { sha256 } from \"@noble/hashes/sha256\";\n\nimport {\n type CryptoService,\n type Curve,\n type EncryptionAlgo,\n HashAlgo,\n} from \"@api/crypto/CryptoService\";\nimport { type Key } from \"@api/crypto/Key\";\nimport { type KeyPair } from \"@api/crypto/KeyPair\";\n\nimport { NobleKey } from \"./NobleKey\";\nimport { NobleKeyPair } from \"./NobleKeyPair\";\n\nexport class NobleCryptoService implements CryptoService {\n randomBytes(len: number): Uint8Array {\n return randomBytes(len);\n }\n\n hash(bytes: Uint8Array, algo: HashAlgo): Uint8Array {\n switch (algo) {\n case HashAlgo.SHA256:\n return sha256(bytes);\n default:\n throw new Error(\"Unsupported hash algorithm\", algo);\n }\n }\n\n hmac(key: Uint8Array, message: Uint8Array, algo: HashAlgo): Uint8Array {\n switch (algo) {\n case HashAlgo.SHA256:\n return hmac(sha256, key, message);\n default:\n throw new Error(\"Unsupported hash algorithm\", algo);\n }\n }\n\n async createKeyPair(curve: Curve): Promise<KeyPair> {\n return await NobleKeyPair.generate(curve);\n }\n\n importKeyPair(privateKey: Uint8Array, curve: Curve): KeyPair {\n return NobleKeyPair.from(privateKey, curve);\n }\n\n async createSymmetricKey(algo: EncryptionAlgo): Promise<Key> {\n return await NobleKey.generate(algo);\n }\n\n importSymmetricKey(keyMaterial: Uint8Array, algo: EncryptionAlgo): Key {\n return NobleKey.from(keyMaterial, algo);\n }\n}\n"],
|
|
5
|
+
"mappings": "AAAA,OAAS,eAAAA,MAAmB,2BAC5B,OAAS,QAAAC,MAAY,qBACrB,OAAS,UAAAC,MAAc,uBAEvB,OAIE,YAAAC,MACK,4BAIP,OAAS,YAAAC,MAAgB,aACzB,OAAS,gBAAAC,MAAoB,iBAEtB,MAAMC,CAA4C,CACvD,YAAYC,EAAyB,CACnC,OAAOP,EAAYO,CAAG,CACxB,CAEA,KAAKC,EAAmBC,EAA4B,CAClD,OAAQA,EAAM,CACZ,KAAKN,EAAS,OACZ,OAAOD,EAAOM,CAAK,EACrB,QACE,MAAM,IAAI,MAAM,6BAA8BC,CAAI,CACtD,CACF,CAEA,KAAKC,EAAiBC,EAAqBF,EAA4B,CACrE,OAAQA,EAAM,CACZ,KAAKN,EAAS,OACZ,OAAOF,EAAKC,EAAQQ,EAAKC,CAAO,EAClC,QACE,MAAM,IAAI,MAAM,6BAA8BF,CAAI,CACtD,CACF,CAEA,MAAM,cAAcG,EAAgC,CAClD,OAAO,MAAMP,EAAa,SAASO,CAAK,CAC1C,CAEA,cAAcC,EAAwBD,EAAuB,CAC3D,OAAOP,EAAa,KAAKQ,EAAYD,CAAK,CAC5C,CAEA,MAAM,mBAAmBH,EAAoC,CAC3D,OAAO,MAAML,EAAS,SAASK,CAAI,CACrC,CAEA,mBAAmBK,EAAyBL,EAA2B,CACrE,OAAOL,EAAS,KAAKU,EAAaL,CAAI,CACxC,CACF",
|
|
6
|
+
"names": ["randomBytes", "hmac", "sha256", "HashAlgo", "NobleKey", "NobleKeyPair", "NobleCryptoService", "len", "bytes", "algo", "key", "message", "curve", "privateKey", "keyMaterial"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{hexaStringToBuffer as r}from"@ledgerhq/device-management-kit";import{Curve as c,EncryptionAlgo as a,HashAlgo as i}from"../../crypto/CryptoService";import{NobleCryptoService as l}from"./NobleCryptoService";import{NobleKey as n}from"./NobleKey";import{NobleKeyPair as s}from"./NobleKeyPair";describe("NobleCryptoService",()=>{let o;beforeEach(()=>{o=new l}),it("should generate random bytes of correct length",()=>{const t=o.randomBytes(32);expect(t.length).toBe(32)}),it("should hash data correctly with SHA256",()=>{const e=new TextEncoder().encode("test"),t=o.hash(e,i.SHA256);expect(t).toEqual(r("9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08"))}),it("should compute HMAC correctly with SHA256",()=>{const e=new Uint8Array(32).fill(97),t=new TextEncoder().encode("test message"),y=o.hmac(e,t,i.SHA256);expect(y).toEqual(r("0b19ad8fef1660f7a191465effeea922079633ada962f52cb60103d9935cc460"))}),it("should create a key pair",async()=>{const e=await o.createKeyPair(c.K256);expect(e instanceof s).toBeTruthy()}),it("should import a key pair",()=>{const e=new Uint8Array(32).fill(1),t=o.importKeyPair(e,c.K256);expect(t instanceof s).toBeTruthy()}),it("should create a symmetric key",async()=>{const e=await o.createSymmetricKey(a.AES256_GCM);expect(e instanceof n).toBeTruthy()}),it("should import a symmetric key",()=>{const e=new Uint8Array(32).fill(1),t=o.importSymmetricKey(e,a.AES256_GCM);expect(t instanceof n).toBeTruthy()})});
|
|
2
|
+
//# sourceMappingURL=NobleCryptoService.test.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/api/crypto/noble/NobleCryptoService.test.ts"],
|
|
4
|
+
"sourcesContent": ["import { hexaStringToBuffer } from \"@ledgerhq/device-management-kit\";\n\nimport { Curve, EncryptionAlgo, HashAlgo } from \"@api/crypto/CryptoService\";\n\nimport { NobleCryptoService } from \"./NobleCryptoService\";\nimport { NobleKey } from \"./NobleKey\";\nimport { NobleKeyPair } from \"./NobleKeyPair\";\n\ndescribe(\"NobleCryptoService\", () => {\n let cryptoService: NobleCryptoService;\n\n beforeEach(() => {\n cryptoService = new NobleCryptoService();\n });\n\n it(\"should generate random bytes of correct length\", () => {\n const length = 32;\n const bytes = cryptoService.randomBytes(length);\n expect(bytes.length).toBe(length);\n });\n\n it(\"should hash data correctly with SHA256\", () => {\n const data = new TextEncoder().encode(\"test\");\n const hashResult = cryptoService.hash(data, HashAlgo.SHA256);\n expect(hashResult).toEqual(\n hexaStringToBuffer(\n \"9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08\",\n )!,\n );\n });\n\n it(\"should compute HMAC correctly with SHA256\", () => {\n const key = new Uint8Array(32).fill(0x61);\n const message = new TextEncoder().encode(\"test message\");\n const hmacResult = cryptoService.hmac(key, message, HashAlgo.SHA256);\n expect(hmacResult).toEqual(\n hexaStringToBuffer(\n \"0b19ad8fef1660f7a191465effeea922079633ada962f52cb60103d9935cc460\",\n )!,\n );\n });\n\n it(\"should create a key pair\", async () => {\n const keyPair = await cryptoService.createKeyPair(Curve.K256);\n expect(keyPair instanceof NobleKeyPair).toBeTruthy();\n });\n\n it(\"should import a key pair\", () => {\n const privateKey = new Uint8Array(32).fill(1);\n const keyPair = cryptoService.importKeyPair(privateKey, Curve.K256);\n expect(keyPair instanceof NobleKeyPair).toBeTruthy();\n });\n\n it(\"should create a symmetric key\", async () => {\n const symmetricKey = await cryptoService.createSymmetricKey(\n EncryptionAlgo.AES256_GCM,\n );\n expect(symmetricKey instanceof NobleKey).toBeTruthy();\n });\n\n it(\"should import a symmetric key\", () => {\n const keyMaterial = new Uint8Array(32).fill(1);\n const symmetricKey = cryptoService.importSymmetricKey(\n keyMaterial,\n EncryptionAlgo.AES256_GCM,\n );\n expect(symmetricKey instanceof NobleKey).toBeTruthy();\n });\n});\n"],
|
|
5
|
+
"mappings": "AAAA,OAAS,sBAAAA,MAA0B,kCAEnC,OAAS,SAAAC,EAAO,kBAAAC,EAAgB,YAAAC,MAAgB,4BAEhD,OAAS,sBAAAC,MAA0B,uBACnC,OAAS,YAAAC,MAAgB,aACzB,OAAS,gBAAAC,MAAoB,iBAE7B,SAAS,qBAAsB,IAAM,CACnC,IAAIC,EAEJ,WAAW,IAAM,CACfA,EAAgB,IAAIH,CACtB,CAAC,EAED,GAAG,iDAAkD,IAAM,CAEzD,MAAMI,EAAQD,EAAc,YAAY,EAAM,EAC9C,OAAOC,EAAM,MAAM,EAAE,KAAK,EAAM,CAClC,CAAC,EAED,GAAG,yCAA0C,IAAM,CACjD,MAAMC,EAAO,IAAI,YAAY,EAAE,OAAO,MAAM,EACtCC,EAAaH,EAAc,KAAKE,EAAMN,EAAS,MAAM,EAC3D,OAAOO,CAAU,EAAE,QACjBV,EACE,kEACF,CACF,CACF,CAAC,EAED,GAAG,4CAA6C,IAAM,CACpD,MAAMW,EAAM,IAAI,WAAW,EAAE,EAAE,KAAK,EAAI,EAClCC,EAAU,IAAI,YAAY,EAAE,OAAO,cAAc,EACjDC,EAAaN,EAAc,KAAKI,EAAKC,EAAST,EAAS,MAAM,EACnE,OAAOU,CAAU,EAAE,QACjBb,EACE,kEACF,CACF,CACF,CAAC,EAED,GAAG,2BAA4B,SAAY,CACzC,MAAMc,EAAU,MAAMP,EAAc,cAAcN,EAAM,IAAI,EAC5D,OAAOa,aAAmBR,CAAY,EAAE,WAAW,CACrD,CAAC,EAED,GAAG,2BAA4B,IAAM,CACnC,MAAMS,EAAa,IAAI,WAAW,EAAE,EAAE,KAAK,CAAC,EACtCD,EAAUP,EAAc,cAAcQ,EAAYd,EAAM,IAAI,EAClE,OAAOa,aAAmBR,CAAY,EAAE,WAAW,CACrD,CAAC,EAED,GAAG,gCAAiC,SAAY,CAC9C,MAAMU,EAAe,MAAMT,EAAc,mBACvCL,EAAe,UACjB,EACA,OAAOc,aAAwBX,CAAQ,EAAE,WAAW,CACtD,CAAC,EAED,GAAG,gCAAiC,IAAM,CACxC,MAAMY,EAAc,IAAI,WAAW,EAAE,EAAE,KAAK,CAAC,EACvCD,EAAeT,EAAc,mBACjCU,EACAf,EAAe,UACjB,EACA,OAAOc,aAAwBX,CAAQ,EAAE,WAAW,CACtD,CAAC,CACH,CAAC",
|
|
6
|
+
"names": ["hexaStringToBuffer", "Curve", "EncryptionAlgo", "HashAlgo", "NobleCryptoService", "NobleKey", "NobleKeyPair", "cryptoService", "bytes", "data", "hashResult", "key", "message", "hmacResult", "keyPair", "privateKey", "symmetricKey", "keyMaterial"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{gcm as i}from"@noble/ciphers/aes";import{randomBytes as c}from"@noble/ciphers/webcrypto";import{EncryptionAlgo as e}from"../../crypto/CryptoService";import{AES256_BLOCK_SIZE as o,AES256_KEY_SIZE as p}from"../../crypto/Key";class n{constructor(r){this.key=r}static async generate(r=e.AES256_GCM){if(r!==e.AES256_GCM)throw new Error(`Unsupported encryption algorithm ${r}`);return new n(c(p))}static from(r,t=e.AES256_GCM){if(t!==e.AES256_GCM)throw new Error(`Unsupported encryption algorithm ${t}`);return new n(r)}async encrypt(r,t){return i(this.key,r.slice(0,o)).encrypt(t)}async decrypt(r,t){return i(this.key,r.slice(0,o)).decrypt(t)}}export{n as NobleKey};
|
|
2
|
+
//# sourceMappingURL=NobleKey.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/api/crypto/noble/NobleKey.ts"],
|
|
4
|
+
"sourcesContent": ["import { gcm } from \"@noble/ciphers/aes\";\nimport { randomBytes } from \"@noble/ciphers/webcrypto\";\n\nimport { EncryptionAlgo } from \"@api/crypto/CryptoService\";\nimport { AES256_BLOCK_SIZE, AES256_KEY_SIZE, type Key } from \"@api/crypto/Key\";\n\nexport class NobleKey implements Key {\n static async generate(\n algo: EncryptionAlgo = EncryptionAlgo.AES256_GCM,\n ): Promise<NobleKey> {\n if (algo !== EncryptionAlgo.AES256_GCM) {\n throw new Error(`Unsupported encryption algorithm ${algo}`);\n }\n return new NobleKey(randomBytes(AES256_KEY_SIZE));\n }\n\n static from(\n keyMaterial: Uint8Array,\n algo: EncryptionAlgo = EncryptionAlgo.AES256_GCM,\n ): NobleKey {\n if (algo !== EncryptionAlgo.AES256_GCM) {\n throw new Error(`Unsupported encryption algorithm ${algo}`);\n }\n return new NobleKey(keyMaterial);\n }\n\n private constructor(private key: Uint8Array) {}\n\n async encrypt(iv: Uint8Array, data: Uint8Array): Promise<Uint8Array> {\n const cipher = gcm(this.key, iv.slice(0, AES256_BLOCK_SIZE));\n return cipher.encrypt(data);\n }\n\n async decrypt(\n iv: Uint8Array,\n encryptedData: Uint8Array,\n ): Promise<Uint8Array> {\n const cipher = gcm(this.key, iv.slice(0, AES256_BLOCK_SIZE));\n return cipher.decrypt(encryptedData);\n }\n}\n"],
|
|
5
|
+
"mappings": "AAAA,OAAS,OAAAA,MAAW,qBACpB,OAAS,eAAAC,MAAmB,2BAE5B,OAAS,kBAAAC,MAAsB,4BAC/B,OAAS,qBAAAC,EAAmB,mBAAAC,MAAiC,kBAEtD,MAAMC,CAAwB,CAoB3B,YAAoBC,EAAiB,CAAjB,SAAAA,CAAkB,CAnB9C,aAAa,SACXC,EAAuBL,EAAe,WACnB,CACnB,GAAIK,IAASL,EAAe,WAC1B,MAAM,IAAI,MAAM,oCAAoCK,CAAI,EAAE,EAE5D,OAAO,IAAIF,EAASJ,EAAYG,CAAe,CAAC,CAClD,CAEA,OAAO,KACLI,EACAD,EAAuBL,EAAe,WAC5B,CACV,GAAIK,IAASL,EAAe,WAC1B,MAAM,IAAI,MAAM,oCAAoCK,CAAI,EAAE,EAE5D,OAAO,IAAIF,EAASG,CAAW,CACjC,CAIA,MAAM,QAAQC,EAAgBC,EAAuC,CAEnE,OADeV,EAAI,KAAK,IAAKS,EAAG,MAAM,EAAGN,CAAiB,CAAC,EAC7C,QAAQO,CAAI,CAC5B,CAEA,MAAM,QACJD,EACAE,EACqB,CAErB,OADeX,EAAI,KAAK,IAAKS,EAAG,MAAM,EAAGN,CAAiB,CAAC,EAC7C,QAAQQ,CAAa,CACrC,CACF",
|
|
6
|
+
"names": ["gcm", "randomBytes", "EncryptionAlgo", "AES256_BLOCK_SIZE", "AES256_KEY_SIZE", "NobleKey", "key", "algo", "keyMaterial", "iv", "data", "encryptedData"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{AES256_BLOCK_SIZE as r,AES256_KEY_SIZE as i}from"../../crypto/Key";import{NobleKey as o}from"./NobleKey";describe("NobleKey",()=>{const t=new TextEncoder().encode("Test Data");it("should encrypt and decrypt data correctly",async()=>{const c=await o.generate(),e=new Uint8Array(r).fill(2),a=await c.encrypt(e,t),n=await c.decrypt(e,a);expect(a).not.toEqual(t),expect(n).toEqual(t)}),it("should encrypt and decrypt data from key material",async()=>{const c=new Uint8Array(i).fill(1),e=o.from(c),a=new Uint8Array(r).fill(2),n=await e.encrypt(a,t),y=await e.decrypt(a,n);expect(n).not.toEqual(t),expect(y).toEqual(t)})});
|
|
2
|
+
//# sourceMappingURL=NobleKey.test.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/api/crypto/noble/NobleKey.test.ts"],
|
|
4
|
+
"sourcesContent": ["import { AES256_BLOCK_SIZE, AES256_KEY_SIZE } from \"@api/crypto/Key\";\n\nimport { NobleKey } from \"./NobleKey\";\n\ndescribe(\"NobleKey\", () => {\n const testData = new TextEncoder().encode(\"Test Data\");\n\n it(\"should encrypt and decrypt data correctly\", async () => {\n const key = await NobleKey.generate();\n const iv = new Uint8Array(AES256_BLOCK_SIZE).fill(0x02);\n const encryptedData = await key.encrypt(iv, testData);\n const decryptedData = await key.decrypt(iv, encryptedData);\n\n expect(encryptedData).not.toEqual(testData);\n expect(decryptedData).toEqual(testData);\n });\n\n it(\"should encrypt and decrypt data from key material\", async () => {\n const keyMaterial = new Uint8Array(AES256_KEY_SIZE).fill(0x01);\n const key = NobleKey.from(keyMaterial);\n const iv = new Uint8Array(AES256_BLOCK_SIZE).fill(0x02);\n const encryptedData = await key.encrypt(iv, testData);\n const decryptedData = await key.decrypt(iv, encryptedData);\n\n expect(encryptedData).not.toEqual(testData);\n expect(decryptedData).toEqual(testData);\n });\n});\n"],
|
|
5
|
+
"mappings": "AAAA,OAAS,qBAAAA,EAAmB,mBAAAC,MAAuB,kBAEnD,OAAS,YAAAC,MAAgB,aAEzB,SAAS,WAAY,IAAM,CACzB,MAAMC,EAAW,IAAI,YAAY,EAAE,OAAO,WAAW,EAErD,GAAG,4CAA6C,SAAY,CAC1D,MAAMC,EAAM,MAAMF,EAAS,SAAS,EAC9BG,EAAK,IAAI,WAAWL,CAAiB,EAAE,KAAK,CAAI,EAChDM,EAAgB,MAAMF,EAAI,QAAQC,EAAIF,CAAQ,EAC9CI,EAAgB,MAAMH,EAAI,QAAQC,EAAIC,CAAa,EAEzD,OAAOA,CAAa,EAAE,IAAI,QAAQH,CAAQ,EAC1C,OAAOI,CAAa,EAAE,QAAQJ,CAAQ,CACxC,CAAC,EAED,GAAG,oDAAqD,SAAY,CAClE,MAAMK,EAAc,IAAI,WAAWP,CAAe,EAAE,KAAK,CAAI,EACvDG,EAAMF,EAAS,KAAKM,CAAW,EAC/BH,EAAK,IAAI,WAAWL,CAAiB,EAAE,KAAK,CAAI,EAChDM,EAAgB,MAAMF,EAAI,QAAQC,EAAIF,CAAQ,EAC9CI,EAAgB,MAAMH,EAAI,QAAQC,EAAIC,CAAa,EAEzD,OAAOA,CAAa,EAAE,IAAI,QAAQH,CAAQ,EAC1C,OAAOI,CAAa,EAAE,QAAQJ,CAAQ,CACxC,CAAC,CACH,CAAC",
|
|
6
|
+
"names": ["AES256_BLOCK_SIZE", "AES256_KEY_SIZE", "NobleKey", "testData", "key", "iv", "encryptedData", "decryptedData", "keyMaterial"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{bufferToHexaString as n}from"@ledgerhq/device-management-kit";import{p256 as u}from"@noble/curves/nist.js";import{secp256k1 as o}from"@noble/curves/secp256k1.js";import{Curve as s}from"../../crypto/CryptoService";import{SigFormat as c}from"../../crypto/KeyPair";class i{constructor(r,e,t){this.curve=r;this.privateKey=e;this.publicKey=t}static async generate(r){const e=i.getCurve(r),{secretKey:t,publicKey:a}=e.keygen();return new i(e,t,a)}static from(r,e){const t=i.getCurve(e),a=t.getPublicKey(r);return new i(t,r,a)}static getCurve(r){switch(r){case s.K256:return o;case s.P256:return u;default:throw new Error(`Unsupported curve ${r}`)}}get id(){return n(this.privateKey)}async sign(r,e){return this.curve.sign(r,this.privateKey).toBytes(e===c.DER?"der":"compact")}async verify(r,e,t){return this.curve.verify(e,r,this.publicKey,{format:t===c.DER?"der":"compact"})}async deriveSharedSecret(r,e=!0){return this.curve.getSharedSecret(this.privateKey,r,e)}getPublicKey(){return this.publicKey}getPublicKeyToHex(){return n(this.publicKey,!1)}}export{i as NobleKeyPair};
|
|
2
|
+
//# sourceMappingURL=NobleKeyPair.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/api/crypto/noble/NobleKeyPair.ts"],
|
|
4
|
+
"sourcesContent": ["import { bufferToHexaString } from \"@ledgerhq/device-management-kit\";\nimport type { CurveFn } from \"@noble/curves/abstract/weierstrass.js\";\nimport { p256 } from \"@noble/curves/nist.js\";\nimport { secp256k1 } from \"@noble/curves/secp256k1.js\";\n\nimport { Curve } from \"@api/crypto/CryptoService\";\nimport { type KeyPair, SigFormat } from \"@api/crypto/KeyPair\";\n\nexport class NobleKeyPair implements KeyPair {\n static async generate(curve: Curve): Promise<NobleKeyPair> {\n const curveImpl = NobleKeyPair.getCurve(curve);\n const { secretKey, publicKey } = curveImpl.keygen();\n return new NobleKeyPair(curveImpl, secretKey, publicKey);\n }\n\n static from(privateKey: Uint8Array, curve: Curve): NobleKeyPair {\n const curveImpl = NobleKeyPair.getCurve(curve);\n const publicKey = curveImpl.getPublicKey(privateKey);\n return new NobleKeyPair(curveImpl, privateKey, publicKey);\n }\n\n private static getCurve(curve: Curve): CurveFn {\n switch (curve) {\n case Curve.K256:\n return secp256k1;\n case Curve.P256:\n return p256;\n default:\n throw new Error(`Unsupported curve ${curve}`);\n }\n }\n\n private constructor(\n private curve: CurveFn,\n private privateKey: Uint8Array,\n private publicKey: Uint8Array,\n ) {}\n\n get id() {\n return bufferToHexaString(this.privateKey);\n }\n\n async sign(data: Uint8Array, format?: SigFormat): Promise<Uint8Array> {\n return this.curve\n .sign(data, this.privateKey)\n .toBytes(format === SigFormat.DER ? \"der\" : \"compact\");\n }\n\n async verify(\n data: Uint8Array,\n signature: Uint8Array,\n format?: SigFormat,\n ): Promise<boolean> {\n return this.curve.verify(signature, data, this.publicKey, {\n format: format === SigFormat.DER ? \"der\" : \"compact\",\n });\n }\n\n async deriveSharedSecret(\n peerPublicKey: Uint8Array,\n isCompressed: boolean = true,\n ): Promise<Uint8Array> {\n return this.curve.getSharedSecret(\n this.privateKey,\n peerPublicKey,\n isCompressed,\n );\n }\n\n getPublicKey(): Uint8Array {\n return this.publicKey;\n }\n\n getPublicKeyToHex(): string {\n return bufferToHexaString(this.publicKey, false);\n }\n}\n"],
|
|
5
|
+
"mappings": "AAAA,OAAS,sBAAAA,MAA0B,kCAEnC,OAAS,QAAAC,MAAY,wBACrB,OAAS,aAAAC,MAAiB,6BAE1B,OAAS,SAAAC,MAAa,4BACtB,OAAuB,aAAAC,MAAiB,sBAEjC,MAAMC,CAAgC,CAwBnC,YACEC,EACAC,EACAC,EACR,CAHQ,WAAAF,EACA,gBAAAC,EACA,eAAAC,CACP,CA3BH,aAAa,SAASF,EAAqC,CACzD,MAAMG,EAAYJ,EAAa,SAASC,CAAK,EACvC,CAAE,UAAAI,EAAW,UAAAF,CAAU,EAAIC,EAAU,OAAO,EAClD,OAAO,IAAIJ,EAAaI,EAAWC,EAAWF,CAAS,CACzD,CAEA,OAAO,KAAKD,EAAwBD,EAA4B,CAC9D,MAAMG,EAAYJ,EAAa,SAASC,CAAK,EACvCE,EAAYC,EAAU,aAAaF,CAAU,EACnD,OAAO,IAAIF,EAAaI,EAAWF,EAAYC,CAAS,CAC1D,CAEA,OAAe,SAASF,EAAuB,CAC7C,OAAQA,EAAO,CACb,KAAKH,EAAM,KACT,OAAOD,EACT,KAAKC,EAAM,KACT,OAAOF,EACT,QACE,MAAM,IAAI,MAAM,qBAAqBK,CAAK,EAAE,CAChD,CACF,CAQA,IAAI,IAAK,CACP,OAAON,EAAmB,KAAK,UAAU,CAC3C,CAEA,MAAM,KAAKW,EAAkBC,EAAyC,CACpE,OAAO,KAAK,MACT,KAAKD,EAAM,KAAK,UAAU,EAC1B,QAAQC,IAAWR,EAAU,IAAM,MAAQ,SAAS,CACzD,CAEA,MAAM,OACJO,EACAE,EACAD,EACkB,CAClB,OAAO,KAAK,MAAM,OAAOC,EAAWF,EAAM,KAAK,UAAW,CACxD,OAAQC,IAAWR,EAAU,IAAM,MAAQ,SAC7C,CAAC,CACH,CAEA,MAAM,mBACJU,EACAC,EAAwB,GACH,CACrB,OAAO,KAAK,MAAM,gBAChB,KAAK,WACLD,EACAC,CACF,CACF,CAEA,cAA2B,CACzB,OAAO,KAAK,SACd,CAEA,mBAA4B,CAC1B,OAAOf,EAAmB,KAAK,UAAW,EAAK,CACjD,CACF",
|
|
6
|
+
"names": ["bufferToHexaString", "p256", "secp256k1", "Curve", "SigFormat", "NobleKeyPair", "curve", "privateKey", "publicKey", "curveImpl", "secretKey", "data", "format", "signature", "peerPublicKey", "isCompressed"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{Curve as r}from"../../crypto/CryptoService";import{SigFormat as n}from"../../crypto/KeyPair";import{NobleKeyPair as i}from"./NobleKeyPair";describe("NobleKeyPair",()=>{const c=new TextEncoder().encode("Test Data");it("should generate a key pair with correct public key",async()=>{const e=(await i.generate(r.K256)).getPublicKey();expect(e).toBeDefined(),expect(e.byteLength).toBeGreaterThan(0)}),it("should create a key pair from a private key",()=>{const t=new Uint8Array(32).fill(1),e=i.from(t,r.K256);expect(e.getPublicKey()).toBeDefined()}),it("should sign and verify data correctly",async()=>{const t=await i.generate(r.K256),e=await t.sign(c),a=await t.verify(c,e);expect(a).toBeTruthy()}),it("should sign and verify data correctly, in DER format",async()=>{const t=await i.generate(r.K256),e=await t.sign(c,n.DER),a=await t.verify(c,e,n.DER);expect(a).toBeTruthy()}),it("should derive a shared secret with another public key",async()=>{const t=await i.generate(r.K256),e=await i.generate(r.K256),a=await t.deriveSharedSecret(e.getPublicKey()),o=await e.deriveSharedSecret(t.getPublicKey());expect(a).toBeDefined(),expect(a.byteLength).toBeGreaterThan(0),expect(a).toStrictEqual(o)}),it("should convert public key to hex string",async()=>{const e=(await i.generate(r.K256)).getPublicKeyToHex();expect(typeof e).toBe("string"),expect(e.length).toBeGreaterThan(0)})});
|
|
2
|
+
//# sourceMappingURL=NobleKeyPair.test.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/api/crypto/noble/NobleKeyPair.test.ts"],
|
|
4
|
+
"sourcesContent": ["import { Curve } from \"@api/crypto/CryptoService\";\nimport { SigFormat } from \"@api/crypto/KeyPair\";\n\nimport { NobleKeyPair } from \"./NobleKeyPair\";\n\ndescribe(\"NobleKeyPair\", () => {\n const testData = new TextEncoder().encode(\"Test Data\");\n\n it(\"should generate a key pair with correct public key\", async () => {\n const keyPair = await NobleKeyPair.generate(Curve.K256);\n const publicKey = keyPair.getPublicKey();\n expect(publicKey).toBeDefined();\n expect(publicKey.byteLength).toBeGreaterThan(0);\n });\n\n it(\"should create a key pair from a private key\", () => {\n const privateKey = new Uint8Array(32).fill(1);\n const keyPair = NobleKeyPair.from(privateKey, Curve.K256);\n expect(keyPair.getPublicKey()).toBeDefined();\n });\n\n it(\"should sign and verify data correctly\", async () => {\n const keyPair = await NobleKeyPair.generate(Curve.K256);\n const signature = await keyPair.sign(testData);\n const isVerified = await keyPair.verify(testData, signature);\n expect(isVerified).toBeTruthy();\n });\n\n it(\"should sign and verify data correctly, in DER format\", async () => {\n const keyPair = await NobleKeyPair.generate(Curve.K256);\n const signature = await keyPair.sign(testData, SigFormat.DER);\n const isVerified = await keyPair.verify(testData, signature, SigFormat.DER);\n expect(isVerified).toBeTruthy();\n });\n\n it(\"should derive a shared secret with another public key\", async () => {\n const keyPair = await NobleKeyPair.generate(Curve.K256);\n const otherKeyPair = await NobleKeyPair.generate(Curve.K256);\n const sharedSecret1 = await keyPair.deriveSharedSecret(\n otherKeyPair.getPublicKey(),\n );\n const sharedSecret2 = await otherKeyPair.deriveSharedSecret(\n keyPair.getPublicKey(),\n );\n\n expect(sharedSecret1).toBeDefined();\n expect(sharedSecret1.byteLength).toBeGreaterThan(0);\n expect(sharedSecret1).toStrictEqual(sharedSecret2);\n });\n\n it(\"should convert public key to hex string\", async () => {\n const keyPair = await NobleKeyPair.generate(Curve.K256);\n const hexPublicKey = keyPair.getPublicKeyToHex();\n expect(typeof hexPublicKey).toBe(\"string\");\n expect(hexPublicKey.length).toBeGreaterThan(0);\n });\n});\n"],
|
|
5
|
+
"mappings": "AAAA,OAAS,SAAAA,MAAa,4BACtB,OAAS,aAAAC,MAAiB,sBAE1B,OAAS,gBAAAC,MAAoB,iBAE7B,SAAS,eAAgB,IAAM,CAC7B,MAAMC,EAAW,IAAI,YAAY,EAAE,OAAO,WAAW,EAErD,GAAG,qDAAsD,SAAY,CAEnE,MA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/C,OAAO,OAAOY,CAAY,EAAE,KAAK,QAAQ,EACzC,OAAOA,EAAa,MAAM,EAAE,gBAAgB,CAAC,CAC/C,CAAC,CACH,CAAC",
|
|
6
|
+
"names": ["Curve", "SigFormat", "NobleKeyPair", "testData", "publicKey", "privateKey", "keyPair", "signature", "isVerified", "otherKeyPair", "sharedSecret1", "sharedSecret2", "hexPublicKey"]
|
|
7
|
+
}
|
package/lib/esm/api/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export*from"./app-binder/AuthenticateDeviceActionTypes";export*from"./
|
|
1
|
+
export*from"./app-binder/AuthenticateDeviceActionTypes";export*from"./crypto/CryptoService";export*from"./crypto/Key";export*from"./crypto/KeyPair";export*from"./crypto/noble/NobleCryptoService";export*from"./crypto/noble/NobleKey";export*from"./crypto/noble/NobleKeyPair";export*from"./model/Env";export*from"./model/Errors";export*from"./model/JWT";export*from"./model/Permissions";export*from"./LedgerKeyringProtocol";export*from"./LedgerKeyringProtocolBuilder";export*from"../internal/externalTypes";
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/lib/esm/api/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/api/index.ts"],
|
|
4
|
-
"sourcesContent": ["export * from \"./app-binder/AuthenticateDeviceActionTypes\";\nexport * from \"./
|
|
5
|
-
"mappings": "AAAA,WAAc,6CACd,WAAc,
|
|
4
|
+
"sourcesContent": ["export * from \"./app-binder/AuthenticateDeviceActionTypes\";\nexport * from \"./crypto/CryptoService\";\nexport * from \"./crypto/Key\";\nexport * from \"./crypto/KeyPair\";\nexport * from \"./crypto/noble/NobleCryptoService\";\nexport * from \"./crypto/noble/NobleKey\";\nexport * from \"./crypto/noble/NobleKeyPair\";\nexport * from \"./model/Env\";\nexport * from \"./model/Errors\";\nexport * from \"./model/JWT\";\nexport * from \"./model/Permissions\";\nexport * from \"@api/LedgerKeyringProtocol\";\nexport * from \"@api/LedgerKeyringProtocolBuilder\";\nexport * from \"@internal/externalTypes\";\n"],
|
|
5
|
+
"mappings": "AAAA,WAAc,6CACd,WAAc,yBACd,WAAc,eACd,WAAc,mBACd,WAAc,oCACd,WAAc,0BACd,WAAc,8BACd,WAAc,cACd,WAAc,iBACd,WAAc,cACd,WAAc,sBACd,WAAc,6BACd,WAAc,oCACd,WAAc",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../../../src/api/
|
|
3
|
+
"sources": ["../../../../src/api/model/Errors.ts"],
|
|
4
4
|
"sourcesContent": ["import { GeneralDmkError } from \"@ledgerhq/device-management-kit\";\n\nexport type LKRPDataSourceErrorStatus =\n | \"UNAUTHORIZED\"\n | \"BAD_REQUEST\"\n | \"UNKNOWN\";\n\nexport class LKRPDataSourceError extends GeneralDmkError {\n override _tag = \"LedgerKeyringProtocolError\";\n public readonly message: string;\n public readonly status: LKRPDataSourceErrorStatus;\n\n constructor(\n readonly err: {\n status: LKRPDataSourceErrorStatus;\n message: string;\n },\n ) {\n super(err.message);\n this.status = err.status;\n this.message = err.message;\n }\n}\n\nexport class LKRPUnauthorizedError extends GeneralDmkError {\n override _tag = \"LedgerKeyringProtocolError\";\n constructor(\n readonly trustchainId: string | null = null,\n readonly message: string = `Current keypair is not a member of the trustchain${trustchainId ? ` ${trustchainId}` : \"\"}.`,\n ) {\n super(message);\n }\n}\n\nexport class LKRPOutdatedTrustchainError extends GeneralDmkError {\n override _tag = \"LedgerKeyringProtocolError\";\n constructor(readonly message = \"The trustchain is outdated.\") {\n super(message);\n }\n}\n\nexport class LKRPTrustchainNotReady extends GeneralDmkError {\n override readonly _tag = \"LedgerKeyringProtocolError\";\n constructor(\n readonly message = \"Ledger Sync must be initialized from Ledger Live with this device.\",\n ) {\n super(message);\n }\n}\n\nexport class LKRPParsingError extends GeneralDmkError {\n override readonly _tag = \"LedgerKeyringProtocolError\";\n constructor(readonly err?: unknown) {\n super(err);\n }\n}\n\nexport class LKRPMissingDataError extends GeneralDmkError {\n override readonly _tag = \"LedgerKeyringProtocolError\";\n constructor(readonly err?: unknown) {\n super(err);\n }\n}\n\nexport class LKRPUnsupportedCommandError extends GeneralDmkError {\n override readonly _tag = \"LedgerKeyringProtocolError\";\n readonly message: string;\n constructor(readonly command: unknown) {\n const commandType =\n command &&\n typeof command === \"object\" &&\n \"type\" in command &&\n typeof command.type === \"number\" &&\n `0x${command.type.toString(16).padStart(2, \"0\")}`;\n let message = `Unsupported command`;\n if (commandType) message += `: ${commandType}`;\n\n super(message);\n\n this.message = message;\n }\n}\n\nexport class LKRPUnknownError extends GeneralDmkError {\n override readonly _tag = \"LedgerKeyringProtocolError\";\n constructor(readonly message: string) {\n super(message);\n }\n}\n"],
|
|
5
5
|
"mappings": "AAAA,OAAS,mBAAAA,MAAuB,kCAOzB,MAAMC,UAA4BD,CAAgB,CAKvD,YACWE,EAIT,CACA,MAAMA,EAAI,OAAO,EALR,SAAAA,EAMT,KAAK,OAASA,EAAI,OAClB,KAAK,QAAUA,EAAI,OACrB,CAbS,KAAO,6BACA,QACA,MAYlB,CAEO,MAAMC,UAA8BH,CAAgB,CAEzD,YACWI,EAA8B,KAC9BC,EAAkB,oDAAoDD,EAAe,IAAIA,CAAY,GAAK,EAAE,IACrH,CACA,MAAMC,CAAO,EAHJ,kBAAAD,EACA,aAAAC,CAGX,CANS,KAAO,4BAOlB,CAEO,MAAMC,UAAoCN,CAAgB,CAE/D,YAAqBK,EAAU,8BAA+B,CAC5D,MAAMA,CAAO,EADM,aAAAA,CAErB,CAHS,KAAO,4BAIlB,CAEO,MAAME,UAA+BP,CAAgB,CAE1D,YACWK,EAAU,qEACnB,CACA,MAAMA,CAAO,EAFJ,aAAAA,CAGX,CALkB,KAAO,4BAM3B,CAEO,MAAMG,UAAyBR,CAAgB,CAEpD,YAAqBE,EAAe,CAClC,MAAMA,CAAG,EADU,SAAAA,CAErB,CAHkB,KAAO,4BAI3B,CAEO,MAAMO,UAA6BT,CAAgB,CAExD,YAAqBE,EAAe,CAClC,MAAMA,CAAG,EADU,SAAAA,CAErB,CAHkB,KAAO,4BAI3B,CAEO,MAAMQ,UAAoCV,CAAgB,CAG/D,YAAqBW,EAAkB,CACrC,MAAMC,EACJD,GACA,OAAOA,GAAY,UACnB,SAAUA,GACV,OAAOA,EAAQ,MAAS,UACxB,KAAKA,EAAQ,KAAK,SAAS,EAAE,EAAE,SAAS,EAAG,GAAG,CAAC,GACjD,IAAIN,EAAU,sBACVO,IAAaP,GAAW,KAAKO,CAAW,IAE5C,MAAMP,CAAO,EAVM,aAAAM,EAYnB,KAAK,QAAUN,CACjB,CAfkB,KAAO,6BAChB,OAeX,CAEO,MAAMQ,UAAyBb,CAAgB,CAEpD,YAAqBK,EAAiB,CACpC,MAAMA,CAAO,EADM,aAAAA,CAErB,CAHkB,KAAO,4BAI3B",
|
|
6
6
|
"names": ["GeneralDmkError", "LKRPDataSourceError", "err", "LKRPUnauthorizedError", "trustchainId", "message", "LKRPOutdatedTrustchainError", "LKRPTrustchainNotReady", "LKRPParsingError", "LKRPMissingDataError", "LKRPUnsupportedCommandError", "command", "commandType", "LKRPUnknownError"]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=JWT.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/api/model/Permissions.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * https://ledgerhq.atlassian.net/wiki/spaces/TA/pages/5865144361/ARCH+LKRP+-+v2+specifications#Member-permissions\n */\nexport enum Permissions {\n OWNER = 0xffffffff, // Owners of the stream have access to everything\n CAN_ENCRYPT = 1, // The member can have access to the stream private key\n CAN_DERIVE = 1 << 1, // The member can have access to the stream chain code (if a member have access to the private key and the chain code it is able to derive sub-streams)\n CAN_ADD_BLOCK = 1 << 2, // The member is authorized to issue blocks in the current stream\n}\n"],
|
|
5
|
+
"mappings": "AAGO,IAAKA,OACVA,IAAA,MAAQ,YAAR,QACAA,IAAA,YAAc,GAAd,cACAA,IAAA,WAAa,GAAb,aACAA,IAAA,cAAgB,GAAhB,gBAJUA,OAAA",
|
|
6
|
+
"names": ["Permissions"]
|
|
7
|
+
}
|