@ledgerhq/device-trusted-app-kit-ledger-keyring-protocol 0.0.0-multisig-20250822145545 → 0.0.0-web-ble-29-08---20250829104351
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/api/LedgerKeyringProtocol.js +1 -1
- package/lib/cjs/api/LedgerKeyringProtocol.js.map +1 -1
- package/lib/cjs/api/LedgerKeyringProtocolBuilder.js +1 -1
- package/lib/cjs/api/LedgerKeyringProtocolBuilder.js.map +3 -3
- package/lib/cjs/api/app-binder/AddToTrustchainDeviceActionTypes.js.map +2 -2
- package/lib/cjs/api/app-binder/AuthenticateDeviceActionTypes.js.map +1 -1
- package/lib/cjs/api/{model → app-binder}/Errors.js.map +1 -1
- package/lib/cjs/api/app-binder/GetAppNameCommandTypes.js +2 -0
- package/lib/cjs/api/app-binder/GetAppNameCommandTypes.js.map +7 -0
- package/lib/cjs/api/app-binder/GetSeedIdCommandTypes.js +2 -0
- package/lib/cjs/api/app-binder/GetSeedIdCommandTypes.js.map +7 -0
- package/lib/cjs/api/app-binder/GetVersionCommandTypes.js +1 -1
- package/lib/cjs/api/app-binder/GetVersionCommandTypes.js.map +1 -1
- package/lib/cjs/api/app-binder/InitCommandTypes.js +2 -0
- package/lib/cjs/api/app-binder/InitCommandTypes.js.map +7 -0
- package/lib/cjs/api/app-binder/KeypairFromBytes.js +2 -0
- package/lib/cjs/api/app-binder/KeypairFromBytes.js.map +7 -0
- package/lib/cjs/api/app-binder/LKRPTypes.js +2 -0
- package/lib/cjs/api/app-binder/LKRPTypes.js.map +7 -0
- package/lib/cjs/api/app-binder/ParseStreamBlockCommandCommandTypes.js +2 -0
- package/lib/cjs/api/app-binder/ParseStreamBlockCommandCommandTypes.js.map +7 -0
- package/lib/cjs/api/app-binder/ParseStreamBlockHeaderCommandTypes.js +2 -0
- package/lib/cjs/api/app-binder/ParseStreamBlockHeaderCommandTypes.js.map +7 -0
- package/lib/cjs/api/app-binder/ParseStreamBlockSignatureTypes.js +2 -0
- package/lib/cjs/api/app-binder/ParseStreamBlockSignatureTypes.js.map +7 -0
- package/lib/cjs/api/app-binder/SetTrustedMemberTypes.js +2 -0
- package/lib/cjs/api/app-binder/SetTrustedMemberTypes.js.map +7 -0
- package/lib/cjs/api/app-binder/SignBlockCommandTypes.js +2 -0
- package/lib/cjs/api/app-binder/SignBlockCommandTypes.js.map +7 -0
- package/lib/cjs/api/app-binder/SignBlockHeaderCommandTypes.js +2 -0
- package/lib/cjs/api/app-binder/SignBlockHeaderCommandTypes.js.map +7 -0
- package/lib/cjs/api/app-binder/SignBlockSignatureCommandTypes.js +2 -0
- package/lib/cjs/api/app-binder/SignBlockSignatureCommandTypes.js.map +7 -0
- package/lib/cjs/api/app-binder/SignBlockSingleCommandTypes.js +2 -0
- package/lib/cjs/api/app-binder/SignBlockSingleCommandTypes.js.map +7 -0
- package/lib/cjs/api/index.js +1 -1
- package/lib/cjs/api/index.js.map +2 -2
- package/lib/cjs/internal/DefaultLedgerKeyringProtocol.js +1 -1
- package/lib/cjs/internal/DefaultLedgerKeyringProtocol.js.map +3 -3
- package/lib/cjs/internal/app-binder/LedgerKeyringProtocolBinder.js +1 -1
- package/lib/cjs/internal/app-binder/LedgerKeyringProtocolBinder.js.map +3 -3
- package/lib/cjs/internal/app-binder/command/GetAppNameCommand.js +1 -1
- package/lib/cjs/internal/app-binder/command/GetAppNameCommand.js.map +2 -2
- package/lib/cjs/internal/app-binder/command/GetSeedIdCommand.js +1 -1
- package/lib/cjs/internal/app-binder/command/GetSeedIdCommand.js.map +3 -3
- package/lib/cjs/internal/app-binder/command/GetSeedIdCommand.test.js +2 -2
- package/lib/cjs/internal/app-binder/command/GetSeedIdCommand.test.js.map +3 -3
- package/lib/cjs/internal/app-binder/command/GetVersionCommand.js.map +2 -2
- package/lib/cjs/internal/app-binder/command/InitCommand.js +1 -1
- package/lib/cjs/internal/app-binder/command/InitCommand.js.map +2 -2
- package/lib/cjs/internal/app-binder/command/InitCommand.test.js +1 -1
- package/lib/cjs/internal/app-binder/command/InitCommand.test.js.map +2 -2
- package/lib/cjs/internal/app-binder/command/ParseBlockSignatureCommand.js +1 -1
- package/lib/cjs/internal/app-binder/command/ParseBlockSignatureCommand.js.map +2 -2
- package/lib/cjs/internal/app-binder/command/ParseBlockSignatureCommand.test.js +1 -1
- package/lib/cjs/internal/app-binder/command/ParseBlockSignatureCommand.test.js.map +2 -2
- package/lib/cjs/internal/app-binder/command/ParseStreamBlockCommand.js.map +2 -2
- package/lib/cjs/internal/app-binder/command/ParseStreamBlockCommand.test.js +1 -1
- package/lib/cjs/internal/app-binder/command/ParseStreamBlockCommand.test.js.map +2 -2
- package/lib/cjs/internal/app-binder/command/ParseStreamBlockHeader.js +1 -1
- package/lib/cjs/internal/app-binder/command/ParseStreamBlockHeader.js.map +2 -2
- package/lib/cjs/internal/app-binder/command/ParseStreamBlockHeader.test.js.map +2 -2
- package/lib/cjs/internal/app-binder/command/SetTrustedMemberCommand.js +1 -1
- package/lib/cjs/internal/app-binder/command/SetTrustedMemberCommand.js.map +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 +1 -1
- package/lib/cjs/internal/utils/LKRPCommand.test.js.map +2 -2
- package/lib/cjs/internal/utils/TLVBuilder.js +2 -0
- package/lib/cjs/internal/utils/TLVBuilder.js.map +7 -0
- package/lib/cjs/internal/utils/TLVParser.js +1 -1
- package/lib/cjs/internal/utils/TLVParser.js.map +3 -3
- package/lib/cjs/internal/utils/TLVParser.test.js +1 -1
- package/lib/cjs/internal/utils/TLVParser.test.js.map +2 -2
- package/lib/cjs/internal/utils/crypto.js +2 -0
- package/lib/cjs/internal/utils/crypto.js.map +7 -0
- package/lib/cjs/internal/utils/hex.js +2 -0
- package/lib/cjs/internal/utils/hex.js.map +7 -0
- package/lib/cjs/internal/utils/required.js +1 -1
- package/lib/cjs/internal/utils/required.js.map +2 -2
- package/lib/cjs/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/{model → app-binder}/Errors.js.map +1 -1
- package/lib/esm/api/app-binder/GetAppNameCommandTypes.js +1 -0
- package/lib/esm/api/app-binder/GetSeedIdCommandTypes.js +1 -0
- package/lib/esm/api/app-binder/GetSeedIdCommandTypes.js.map +7 -0
- package/lib/esm/api/app-binder/InitCommandTypes.js +1 -0
- package/lib/esm/api/app-binder/InitCommandTypes.js.map +7 -0
- package/lib/esm/api/app-binder/KeypairFromBytes.js +2 -0
- package/lib/esm/api/app-binder/KeypairFromBytes.js.map +7 -0
- package/lib/esm/api/app-binder/LKRPTypes.js +2 -0
- package/lib/esm/api/app-binder/LKRPTypes.js.map +7 -0
- package/lib/esm/api/app-binder/ParseStreamBlockCommandCommandTypes.js +1 -0
- package/lib/esm/api/app-binder/ParseStreamBlockCommandCommandTypes.js.map +7 -0
- package/lib/esm/api/app-binder/ParseStreamBlockHeaderCommandTypes.js +1 -0
- package/lib/esm/api/app-binder/ParseStreamBlockHeaderCommandTypes.js.map +7 -0
- package/lib/esm/api/app-binder/ParseStreamBlockSignatureTypes.js +1 -0
- package/lib/esm/api/app-binder/ParseStreamBlockSignatureTypes.js.map +7 -0
- package/lib/esm/api/app-binder/SetTrustedMemberTypes.js +1 -0
- package/lib/esm/api/app-binder/SetTrustedMemberTypes.js.map +7 -0
- package/lib/esm/api/app-binder/SignBlockCommandTypes.js +1 -0
- package/lib/esm/api/app-binder/SignBlockCommandTypes.js.map +7 -0
- package/lib/esm/api/app-binder/SignBlockHeaderCommandTypes.js +1 -0
- package/lib/esm/api/app-binder/SignBlockHeaderCommandTypes.js.map +7 -0
- package/lib/esm/api/app-binder/SignBlockSignatureCommandTypes.js +1 -0
- package/lib/esm/api/app-binder/SignBlockSignatureCommandTypes.js.map +7 -0
- package/lib/esm/api/app-binder/SignBlockSingleCommandTypes.js +1 -0
- package/lib/esm/api/app-binder/SignBlockSingleCommandTypes.js.map +7 -0
- package/lib/esm/api/index.js +1 -1
- package/lib/esm/api/index.js.map +2 -2
- package/lib/esm/internal/DefaultLedgerKeyringProtocol.js +1 -1
- package/lib/esm/internal/DefaultLedgerKeyringProtocol.js.map +3 -3
- package/lib/esm/internal/app-binder/LedgerKeyringProtocolBinder.js +1 -1
- package/lib/esm/internal/app-binder/LedgerKeyringProtocolBinder.js.map +3 -3
- package/lib/esm/internal/app-binder/command/GetAppNameCommand.js +1 -1
- package/lib/esm/internal/app-binder/command/GetAppNameCommand.js.map +2 -2
- package/lib/esm/internal/app-binder/command/GetSeedIdCommand.js +1 -1
- package/lib/esm/internal/app-binder/command/GetSeedIdCommand.js.map +3 -3
- package/lib/esm/internal/app-binder/command/GetSeedIdCommand.test.js +1 -1
- package/lib/esm/internal/app-binder/command/GetSeedIdCommand.test.js.map +3 -3
- package/lib/esm/internal/app-binder/command/GetVersionCommand.js.map +2 -2
- package/lib/esm/internal/app-binder/command/InitCommand.js +1 -1
- package/lib/esm/internal/app-binder/command/InitCommand.js.map +2 -2
- package/lib/esm/internal/app-binder/command/InitCommand.test.js +1 -1
- package/lib/esm/internal/app-binder/command/InitCommand.test.js.map +2 -2
- package/lib/esm/internal/app-binder/command/ParseBlockSignatureCommand.js +1 -1
- package/lib/esm/internal/app-binder/command/ParseBlockSignatureCommand.js.map +2 -2
- package/lib/esm/internal/app-binder/command/ParseBlockSignatureCommand.test.js +1 -1
- package/lib/esm/internal/app-binder/command/ParseBlockSignatureCommand.test.js.map +2 -2
- package/lib/esm/internal/app-binder/command/ParseStreamBlockCommand.js.map +2 -2
- package/lib/esm/internal/app-binder/command/ParseStreamBlockCommand.test.js +1 -1
- package/lib/esm/internal/app-binder/command/ParseStreamBlockCommand.test.js.map +2 -2
- package/lib/esm/internal/app-binder/command/ParseStreamBlockHeader.js +1 -1
- package/lib/esm/internal/app-binder/command/ParseStreamBlockHeader.js.map +2 -2
- package/lib/esm/internal/app-binder/command/ParseStreamBlockHeader.test.js.map +2 -2
- package/lib/esm/internal/app-binder/command/SetTrustedMemberCommand.js +1 -1
- package/lib/esm/internal/app-binder/command/SetTrustedMemberCommand.js.map +2 -2
- package/lib/esm/internal/app-binder/command/SetTrustedMemberCommand.test.js +1 -1
- package/lib/esm/internal/app-binder/command/SetTrustedMemberCommand.test.js.map +2 -2
- package/lib/esm/internal/app-binder/command/SignBlockHeader.js +1 -1
- package/lib/esm/internal/app-binder/command/SignBlockHeader.js.map +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 +1 -1
- package/lib/esm/internal/utils/LKRPCommand.test.js.map +2 -2
- package/lib/esm/internal/utils/TLVBuilder.js +2 -0
- package/lib/esm/internal/utils/TLVBuilder.js.map +7 -0
- package/lib/esm/internal/utils/TLVParser.js +1 -1
- package/lib/esm/internal/utils/TLVParser.js.map +3 -3
- package/lib/esm/internal/utils/TLVParser.test.js +1 -1
- package/lib/esm/internal/utils/TLVParser.test.js.map +2 -2
- package/lib/esm/internal/utils/crypto.js +2 -0
- package/lib/esm/internal/utils/crypto.js.map +7 -0
- package/lib/esm/internal/utils/hex.js +2 -0
- package/lib/esm/internal/utils/hex.js.map +7 -0
- package/lib/esm/internal/utils/required.js +1 -1
- package/lib/esm/internal/utils/required.js.map +2 -2
- package/lib/esm/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 +1 -4
- package/lib/types/api/LedgerKeyringProtocolBuilder.d.ts.map +1 -1
- package/lib/types/api/app-binder/AddToTrustchainDeviceActionTypes.d.ts +4 -8
- 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/Errors.d.ts.map +1 -0
- package/lib/types/api/app-binder/GetAppNameCommandTypes.d.ts +5 -0
- package/lib/types/api/app-binder/GetAppNameCommandTypes.d.ts.map +1 -0
- package/lib/types/api/app-binder/GetSeedIdCommandTypes.d.ts +14 -0
- package/lib/types/api/app-binder/GetSeedIdCommandTypes.d.ts.map +1 -0
- package/lib/types/api/app-binder/GetVersionCommandTypes.d.ts +1 -0
- package/lib/types/api/app-binder/GetVersionCommandTypes.d.ts.map +1 -1
- package/lib/types/api/app-binder/InitCommandTypes.d.ts +5 -0
- package/lib/types/api/app-binder/InitCommandTypes.d.ts.map +1 -0
- package/lib/types/api/app-binder/KeypairFromBytes.d.ts +11 -0
- package/lib/types/api/app-binder/KeypairFromBytes.d.ts.map +1 -0
- package/lib/types/api/{model/Permissions.d.ts → app-binder/LKRPTypes.d.ts} +19 -1
- package/lib/types/api/app-binder/LKRPTypes.d.ts.map +1 -0
- package/lib/types/api/app-binder/ParseStreamBlockCommandCommandTypes.d.ts +6 -0
- package/lib/types/api/app-binder/ParseStreamBlockCommandCommandTypes.d.ts.map +1 -0
- package/lib/types/api/app-binder/ParseStreamBlockHeaderCommandTypes.d.ts +5 -0
- package/lib/types/api/app-binder/ParseStreamBlockHeaderCommandTypes.d.ts.map +1 -0
- package/lib/types/api/app-binder/ParseStreamBlockSignatureTypes.d.ts +5 -0
- package/lib/types/api/app-binder/ParseStreamBlockSignatureTypes.d.ts.map +1 -0
- package/lib/types/api/app-binder/SetTrustedMemberTypes.d.ts +6 -0
- package/lib/types/api/app-binder/SetTrustedMemberTypes.d.ts.map +1 -0
- package/lib/types/api/app-binder/SignBlockCommandTypes.d.ts +9 -0
- package/lib/types/api/app-binder/SignBlockCommandTypes.d.ts.map +1 -0
- package/lib/types/api/app-binder/SignBlockHeaderCommandTypes.d.ts +6 -0
- package/lib/types/api/app-binder/SignBlockHeaderCommandTypes.d.ts.map +1 -0
- package/lib/types/api/app-binder/SignBlockSignatureCommandTypes.d.ts +6 -0
- package/lib/types/api/app-binder/SignBlockSignatureCommandTypes.d.ts.map +1 -0
- package/lib/types/api/app-binder/SignBlockSingleCommandTypes.d.ts +5 -0
- package/lib/types/api/app-binder/SignBlockSingleCommandTypes.d.ts.map +1 -0
- package/lib/types/api/index.d.ts +2 -10
- package/lib/types/api/index.d.ts.map +1 -1
- package/lib/types/internal/DefaultLedgerKeyringProtocol.d.ts +4 -6
- package/lib/types/internal/DefaultLedgerKeyringProtocol.d.ts.map +1 -1
- package/lib/types/internal/app-binder/LedgerKeyringProtocolBinder.d.ts +4 -7
- package/lib/types/internal/app-binder/LedgerKeyringProtocolBinder.d.ts.map +1 -1
- package/lib/types/internal/app-binder/command/GetAppNameCommand.d.ts +1 -4
- package/lib/types/internal/app-binder/command/GetAppNameCommand.d.ts.map +1 -1
- package/lib/types/internal/app-binder/command/GetSeedIdCommand.d.ts +1 -13
- package/lib/types/internal/app-binder/command/GetSeedIdCommand.d.ts.map +1 -1
- package/lib/types/internal/app-binder/command/GetVersionCommand.d.ts +1 -2
- package/lib/types/internal/app-binder/command/GetVersionCommand.d.ts.map +1 -1
- package/lib/types/internal/app-binder/command/InitCommand.d.ts +1 -4
- package/lib/types/internal/app-binder/command/InitCommand.d.ts.map +1 -1
- package/lib/types/internal/app-binder/command/ParseBlockSignatureCommand.d.ts +1 -4
- package/lib/types/internal/app-binder/command/ParseBlockSignatureCommand.d.ts.map +1 -1
- package/lib/types/internal/app-binder/command/ParseStreamBlockCommand.d.ts +1 -5
- package/lib/types/internal/app-binder/command/ParseStreamBlockCommand.d.ts.map +1 -1
- package/lib/types/internal/app-binder/command/ParseStreamBlockHeader.d.ts +1 -4
- package/lib/types/internal/app-binder/command/ParseStreamBlockHeader.d.ts.map +1 -1
- package/lib/types/internal/app-binder/command/SetTrustedMemberCommand.d.ts +1 -5
- package/lib/types/internal/app-binder/command/SetTrustedMemberCommand.d.ts.map +1 -1
- package/lib/types/internal/app-binder/command/SignBlockHeader.d.ts +1 -5
- package/lib/types/internal/app-binder/command/SignBlockHeader.d.ts.map +1 -1
- package/lib/types/internal/app-binder/command/SignBlockSignatureCommand.d.ts +1 -5
- package/lib/types/internal/app-binder/command/SignBlockSignatureCommand.d.ts.map +1 -1
- package/lib/types/internal/app-binder/command/SignBlockSingleCommand.d.ts +1 -4
- package/lib/types/internal/app-binder/command/SignBlockSingleCommand.d.ts.map +1 -1
- package/lib/types/internal/app-binder/device-action/AddToTrustchainDeviceAction.d.ts +4 -8
- 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 +2 -5
- 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 +2 -5
- 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 +2 -5
- 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 +2 -5
- 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 +7 -4
- package/lib/types/internal/app-binder/task/ExtractEncryptionKeyTask.d.ts.map +1 -1
- package/lib/types/internal/app-binder/task/InitTask.d.ts +3 -5
- package/lib/types/internal/app-binder/task/InitTask.d.ts.map +1 -1
- package/lib/types/internal/app-binder/task/ParseStreamToDeviceTask.d.ts +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 +8 -11
- package/lib/types/internal/app-binder/task/SignBlockTask.d.ts.map +1 -1
- package/lib/types/internal/app-binder/task/SignChallengeWithKeypairTask.d.ts +3 -5
- 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 +1 -3
- package/lib/types/internal/di.d.ts.map +1 -1
- package/lib/types/internal/externalTypes.d.ts +0 -1
- 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 +2 -3
- package/lib/types/internal/use-cases/authentication/AuthenticateUseCase.d.ts.map +1 -1
- package/lib/types/internal/use-cases/authentication/DecryptDataUseCase.d.ts +1 -4
- package/lib/types/internal/use-cases/authentication/DecryptDataUseCase.d.ts.map +1 -1
- package/lib/types/internal/use-cases/authentication/EncryptDataUseCase.d.ts +1 -4
- 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 +3 -4
- 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/TLVBuilder.d.ts +15 -0
- package/lib/types/internal/utils/TLVBuilder.d.ts.map +1 -0
- 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/crypto.d.ts +19 -0
- package/lib/types/internal/utils/crypto.d.ts.map +1 -0
- package/lib/types/internal/utils/hex.d.ts +3 -0
- package/lib/types/internal/utils/hex.d.ts.map +1 -0
- package/lib/types/internal/utils/required.d.ts +1 -1
- package/lib/types/internal/utils/required.d.ts.map +1 -1
- package/lib/types/tsconfig.prod.tsbuildinfo +1 -1
- package/package.json +5 -5
- package/lib/cjs/api/crypto/CryptoService.js +0 -2
- package/lib/cjs/api/crypto/CryptoService.js.map +0 -7
- package/lib/cjs/api/crypto/Key.js +0 -2
- package/lib/cjs/api/crypto/Key.js.map +0 -7
- package/lib/cjs/api/crypto/KeyPair.js +0 -2
- package/lib/cjs/api/crypto/KeyPair.js.map +0 -7
- package/lib/cjs/api/crypto/noble/NobleCryptoService.js +0 -2
- package/lib/cjs/api/crypto/noble/NobleCryptoService.js.map +0 -7
- package/lib/cjs/api/crypto/noble/NobleCryptoService.test.js +0 -2
- package/lib/cjs/api/crypto/noble/NobleCryptoService.test.js.map +0 -7
- package/lib/cjs/api/crypto/noble/NobleKey.js +0 -2
- package/lib/cjs/api/crypto/noble/NobleKey.js.map +0 -7
- package/lib/cjs/api/crypto/noble/NobleKey.test.js +0 -2
- package/lib/cjs/api/crypto/noble/NobleKey.test.js.map +0 -7
- package/lib/cjs/api/crypto/noble/NobleKeyPair.js +0 -2
- package/lib/cjs/api/crypto/noble/NobleKeyPair.js.map +0 -7
- package/lib/cjs/api/crypto/noble/NobleKeyPair.test.js +0 -2
- package/lib/cjs/api/crypto/noble/NobleKeyPair.test.js.map +0 -7
- package/lib/cjs/api/model/Env.js +0 -2
- package/lib/cjs/api/model/Env.js.map +0 -7
- package/lib/cjs/api/model/JWT.js +0 -2
- package/lib/cjs/api/model/JWT.js.map +0 -7
- package/lib/cjs/api/model/Permissions.js +0 -2
- package/lib/cjs/api/model/Permissions.js.map +0 -7
- package/lib/esm/api/crypto/CryptoService.js +0 -2
- package/lib/esm/api/crypto/CryptoService.js.map +0 -7
- package/lib/esm/api/crypto/Key.js +0 -2
- package/lib/esm/api/crypto/Key.js.map +0 -7
- package/lib/esm/api/crypto/KeyPair.js +0 -2
- package/lib/esm/api/crypto/KeyPair.js.map +0 -7
- package/lib/esm/api/crypto/noble/NobleCryptoService.js +0 -2
- package/lib/esm/api/crypto/noble/NobleCryptoService.js.map +0 -7
- package/lib/esm/api/crypto/noble/NobleCryptoService.test.js +0 -2
- package/lib/esm/api/crypto/noble/NobleCryptoService.test.js.map +0 -7
- package/lib/esm/api/crypto/noble/NobleKey.js +0 -2
- package/lib/esm/api/crypto/noble/NobleKey.js.map +0 -7
- package/lib/esm/api/crypto/noble/NobleKey.test.js +0 -2
- package/lib/esm/api/crypto/noble/NobleKey.test.js.map +0 -7
- package/lib/esm/api/crypto/noble/NobleKeyPair.js +0 -2
- package/lib/esm/api/crypto/noble/NobleKeyPair.js.map +0 -7
- package/lib/esm/api/crypto/noble/NobleKeyPair.test.js +0 -2
- package/lib/esm/api/crypto/noble/NobleKeyPair.test.js.map +0 -7
- package/lib/esm/api/model/Env.js +0 -2
- package/lib/esm/api/model/Env.js.map +0 -7
- package/lib/esm/api/model/JWT.js +0 -1
- package/lib/esm/api/model/Permissions.js +0 -2
- package/lib/esm/api/model/Permissions.js.map +0 -7
- package/lib/types/api/crypto/CryptoService.d.ts +0 -22
- package/lib/types/api/crypto/CryptoService.d.ts.map +0 -1
- package/lib/types/api/crypto/Key.d.ts +0 -7
- package/lib/types/api/crypto/Key.d.ts.map +0 -1
- package/lib/types/api/crypto/KeyPair.d.ts +0 -12
- package/lib/types/api/crypto/KeyPair.d.ts.map +0 -1
- package/lib/types/api/crypto/noble/NobleCryptoService.d.ts +0 -13
- package/lib/types/api/crypto/noble/NobleCryptoService.d.ts.map +0 -1
- package/lib/types/api/crypto/noble/NobleCryptoService.test.d.ts +0 -2
- package/lib/types/api/crypto/noble/NobleCryptoService.test.d.ts.map +0 -1
- package/lib/types/api/crypto/noble/NobleKey.d.ts +0 -11
- package/lib/types/api/crypto/noble/NobleKey.d.ts.map +0 -1
- package/lib/types/api/crypto/noble/NobleKey.test.d.ts +0 -2
- package/lib/types/api/crypto/noble/NobleKey.test.d.ts.map +0 -1
- package/lib/types/api/crypto/noble/NobleKeyPair.d.ts +0 -17
- package/lib/types/api/crypto/noble/NobleKeyPair.d.ts.map +0 -1
- package/lib/types/api/crypto/noble/NobleKeyPair.test.d.ts +0 -2
- package/lib/types/api/crypto/noble/NobleKeyPair.test.d.ts.map +0 -1
- package/lib/types/api/model/Env.d.ts +0 -5
- package/lib/types/api/model/Env.d.ts.map +0 -1
- package/lib/types/api/model/Errors.d.ts.map +0 -1
- package/lib/types/api/model/JWT.d.ts +0 -9
- package/lib/types/api/model/JWT.d.ts.map +0 -1
- package/lib/types/api/model/Permissions.d.ts.map +0 -1
- /package/lib/cjs/api/{model → app-binder}/Errors.js +0 -0
- /package/lib/esm/api/{model → app-binder}/Errors.js +0 -0
- /package/lib/esm/api/{model/JWT.js.map → app-binder/GetAppNameCommandTypes.js.map} +0 -0
- /package/lib/types/api/{model → app-binder}/Errors.d.ts +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var r=require("@ledgerhq/device-management-kit"),e=require("vitest"),i=require("./SignBlockSignatureCommand");const a=Uint8Array.from([240,202,204,26]);(0,e.describe)("SignBlockSignatureCommand",()=>{(0,e.describe)("getApdu()",()=>{(0,e.it)("should build the correct APDU for finalize-signature",()=>{const
|
|
1
|
+
"use strict";var r=require("@ledgerhq/device-management-kit"),e=require("vitest"),i=require("./SignBlockSignatureCommand");const a=Uint8Array.from([240,202,204,26]);(0,e.describe)("SignBlockSignatureCommand",()=>{(0,e.describe)("getApdu()",()=>{(0,e.it)("should build the correct APDU for finalize-signature",()=>{const s=new i.SignBlockSignatureCommand().getApdu();(0,e.expect)(s.getRawApdu()).toEqual(Uint8Array.from([224,7,2,0,0]))})}),(0,e.describe)("parseResponse()",()=>{(0,e.it)("should return signature and sessionKey on success",()=>{const t=new Uint8Array([a.length,...a,a.length,...a]),s=new i.SignBlockSignatureCommand,o=new r.ApduResponse({statusCode:Uint8Array.from([144,0]),data:t}),n=s.parseResponse(o);if((0,e.expect)((0,r.isSuccessCommandResult)(n)).toBe(!0),(0,r.isSuccessCommandResult)(n)){const d=n.data;(0,e.expect)(d.signature).toEqual(a),(0,e.expect)(d.deviceSessionKey).toEqual(a)}}),(0,e.it)("should map SW errors to CommandResult errors",()=>{const t=new i.SignBlockSignatureCommand,s=new r.ApduResponse({statusCode:Uint8Array.from([106,134]),data:new Uint8Array}),o=t.parseResponse(s);(0,e.expect)((0,r.isSuccessCommandResult)(o)).toBe(!1),(0,r.isSuccessCommandResult)(o)||(0,e.expect)(o.error.errorCode).toBe("6a86")}),(0,e.it)("should error if missing length or reserved byte",()=>{const t=new i.SignBlockSignatureCommand,s=new r.ApduResponse({statusCode:Uint8Array.from([144,0]),data:new Uint8Array}),o=t.parseResponse(s);(0,e.expect)((0,r.isSuccessCommandResult)(o)).toBe(!1),(0,r.isSuccessCommandResult)(o)||((0,e.expect)(o.error._tag).toBe("InvalidStatusWordError"),(0,e.expect)(o.error.originalError.message).toBe("Invalid response: missing signature length or reserved byte"))}),(0,e.it)("should error if signature length out of bounds",()=>{const t=Uint8Array.from([5,170,187]),s=new i.SignBlockSignatureCommand,o=new r.ApduResponse({statusCode:Uint8Array.from([144,0]),data:t}),n=s.parseResponse(o);(0,e.expect)((0,r.isSuccessCommandResult)(n)).toBe(!1),(0,r.isSuccessCommandResult)(n)||((0,e.expect)(n.error._tag).toBe("InvalidStatusWordError"),(0,e.expect)(n.error.originalError.message).toBe("Signature length out of bounds"))})})});
|
|
2
2
|
//# sourceMappingURL=SignBlockSignatureCommand.test.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/internal/app-binder/command/SignBlockSignatureCommand.test.ts"],
|
|
4
|
-
"sourcesContent": ["/* eslint-disable @typescript-eslint/no-unsafe-member-access */\n/* eslint-disable @typescript-eslint/no-explicit-any */\n\nimport {\n ApduResponse,\n isSuccessCommandResult,\n} from \"@ledgerhq/device-management-kit\";\nimport { describe, expect, it } from \"vitest\";\n\nimport {\n
|
|
5
|
-
"mappings": "aAGA,IAAAA,EAGO,2CACPC,EAAqC,
|
|
4
|
+
"sourcesContent": ["/* eslint-disable @typescript-eslint/no-unsafe-member-access */\n/* eslint-disable @typescript-eslint/no-explicit-any */\n\nimport {\n ApduResponse,\n isSuccessCommandResult,\n} from \"@ledgerhq/device-management-kit\";\nimport { describe, expect, it } from \"vitest\";\n\nimport { type SignBlockSignatureCommandResponse } from \"@api/app-binder/SignBlockSignatureCommandTypes\";\n\nimport { SignBlockSignatureCommand } from \"./SignBlockSignatureCommand\";\n\nconst SIG_AND_KEY = Uint8Array.from([0xf0, 0xca, 0xcc, 0x1a]);\n\ndescribe(\"SignBlockSignatureCommand\", () => {\n describe(\"getApdu()\", () => {\n it(\"should build the correct APDU for finalize-signature\", () => {\n const cmd = new SignBlockSignatureCommand();\n const apdu = cmd.getApdu();\n expect(apdu.getRawApdu()).toEqual(\n Uint8Array.from([0xe0, 0x07, 0x02, 0x00, 0x00]),\n );\n });\n });\n\n describe(\"parseResponse()\", () => {\n it(\"should return signature and sessionKey on success\", () => {\n // given\n const payload = new Uint8Array([\n SIG_AND_KEY.length,\n ...SIG_AND_KEY,\n SIG_AND_KEY.length,\n ...SIG_AND_KEY,\n ]);\n const cmd = new SignBlockSignatureCommand();\n const response = new ApduResponse({\n statusCode: Uint8Array.from([0x90, 0x00]),\n data: payload,\n });\n\n // when\n const result = cmd.parseResponse(response);\n\n // then\n expect(isSuccessCommandResult(result)).toBe(true);\n if (isSuccessCommandResult(result)) {\n const res: SignBlockSignatureCommandResponse = result.data;\n expect(res.signature).toEqual(SIG_AND_KEY);\n expect(res.deviceSessionKey).toEqual(SIG_AND_KEY);\n }\n });\n\n it(\"should map SW errors to CommandResult errors\", () => {\n // given\n const cmd = new SignBlockSignatureCommand();\n const response = new ApduResponse({\n statusCode: Uint8Array.from([0x6a, 0x86]),\n data: new Uint8Array(),\n });\n\n // when\n const result = cmd.parseResponse(response);\n\n // then\n expect(isSuccessCommandResult(result)).toBe(false);\n if (!isSuccessCommandResult(result)) {\n expect((result.error as any).errorCode).toBe(\"6a86\");\n }\n });\n\n it(\"should error if missing length or reserved byte\", () => {\n // given\n const cmd = new SignBlockSignatureCommand();\n const response = new ApduResponse({\n statusCode: Uint8Array.from([0x90, 0x00]),\n data: new Uint8Array(),\n });\n\n // when\n const result = cmd.parseResponse(response);\n\n // then\n expect(isSuccessCommandResult(result)).toBe(false);\n if (!isSuccessCommandResult(result)) {\n expect((result.error as any)._tag).toBe(\"InvalidStatusWordError\");\n expect((result.error as any).originalError.message).toBe(\n \"Invalid response: missing signature length or reserved byte\",\n );\n }\n });\n\n it(\"should error if signature length out of bounds\", () => {\n // given\n const bad = Uint8Array.from([5, 0xaa, 0xbb]);\n const cmd = new SignBlockSignatureCommand();\n const response = new ApduResponse({\n statusCode: Uint8Array.from([0x90, 0x00]),\n data: bad,\n });\n\n // when\n const result = cmd.parseResponse(response);\n\n // then\n expect(isSuccessCommandResult(result)).toBe(false);\n if (!isSuccessCommandResult(result)) {\n expect((result.error as any)._tag).toBe(\"InvalidStatusWordError\");\n expect((result.error as any).originalError.message).toBe(\n \"Signature length out of bounds\",\n );\n }\n });\n });\n});\n"],
|
|
5
|
+
"mappings": "aAGA,IAAAA,EAGO,2CACPC,EAAqC,kBAIrCC,EAA0C,uCAE1C,MAAMC,EAAc,WAAW,KAAK,CAAC,IAAM,IAAM,IAAM,EAAI,CAAC,KAE5D,YAAS,4BAA6B,IAAM,IAC1C,YAAS,YAAa,IAAM,IAC1B,MAAG,uDAAwD,IAAM,CAE/D,MAAMC,EADM,IAAI,4BAA0B,EACzB,QAAQ,KACzB,UAAOA,EAAK,WAAW,CAAC,EAAE,QACxB,WAAW,KAAK,CAAC,IAAM,EAAM,EAAM,EAAM,CAAI,CAAC,CAChD,CACF,CAAC,CACH,CAAC,KAED,YAAS,kBAAmB,IAAM,IAChC,MAAG,oDAAqD,IAAM,CAE5D,MAAMC,EAAU,IAAI,WAAW,CAC7BF,EAAY,OACZ,GAAGA,EACHA,EAAY,OACZ,GAAGA,CACL,CAAC,EACKG,EAAM,IAAI,4BACVC,EAAW,IAAI,eAAa,CAChC,WAAY,WAAW,KAAK,CAAC,IAAM,CAAI,CAAC,EACxC,KAAMF,CACR,CAAC,EAGKG,EAASF,EAAI,cAAcC,CAAQ,EAIzC,MADA,aAAO,0BAAuBC,CAAM,CAAC,EAAE,KAAK,EAAI,KAC5C,0BAAuBA,CAAM,EAAG,CAClC,MAAMC,EAAyCD,EAAO,QACtD,UAAOC,EAAI,SAAS,EAAE,QAAQN,CAAW,KACzC,UAAOM,EAAI,gBAAgB,EAAE,QAAQN,CAAW,CAClD,CACF,CAAC,KAED,MAAG,+CAAgD,IAAM,CAEvD,MAAMG,EAAM,IAAI,4BACVC,EAAW,IAAI,eAAa,CAChC,WAAY,WAAW,KAAK,CAAC,IAAM,GAAI,CAAC,EACxC,KAAM,IAAI,UACZ,CAAC,EAGKC,EAASF,EAAI,cAAcC,CAAQ,KAGzC,aAAO,0BAAuBC,CAAM,CAAC,EAAE,KAAK,EAAK,KAC5C,0BAAuBA,CAAM,MAChC,UAAQA,EAAO,MAAc,SAAS,EAAE,KAAK,MAAM,CAEvD,CAAC,KAED,MAAG,kDAAmD,IAAM,CAE1D,MAAMF,EAAM,IAAI,4BACVC,EAAW,IAAI,eAAa,CAChC,WAAY,WAAW,KAAK,CAAC,IAAM,CAAI,CAAC,EACxC,KAAM,IAAI,UACZ,CAAC,EAGKC,EAASF,EAAI,cAAcC,CAAQ,KAGzC,aAAO,0BAAuBC,CAAM,CAAC,EAAE,KAAK,EAAK,KAC5C,0BAAuBA,CAAM,OAChC,UAAQA,EAAO,MAAc,IAAI,EAAE,KAAK,wBAAwB,KAChE,UAAQA,EAAO,MAAc,cAAc,OAAO,EAAE,KAClD,6DACF,EAEJ,CAAC,KAED,MAAG,iDAAkD,IAAM,CAEzD,MAAME,EAAM,WAAW,KAAK,CAAC,EAAG,IAAM,GAAI,CAAC,EACrCJ,EAAM,IAAI,4BACVC,EAAW,IAAI,eAAa,CAChC,WAAY,WAAW,KAAK,CAAC,IAAM,CAAI,CAAC,EACxC,KAAMG,CACR,CAAC,EAGKF,EAASF,EAAI,cAAcC,CAAQ,KAGzC,aAAO,0BAAuBC,CAAM,CAAC,EAAE,KAAK,EAAK,KAC5C,0BAAuBA,CAAM,OAChC,UAAQA,EAAO,MAAc,IAAI,EAAE,KAAK,wBAAwB,KAChE,UAAQA,EAAO,MAAc,cAAc,OAAO,EAAE,KAClD,gCACF,EAEJ,CAAC,CACH,CAAC,CACH,CAAC",
|
|
6
6
|
"names": ["import_device_management_kit", "import_vitest", "import_SignBlockSignatureCommand", "SIG_AND_KEY", "apdu", "payload", "cmd", "response", "result", "res", "bad"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var d=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var s=Object.getOwnPropertyNames;var p=Object.prototype.hasOwnProperty;var c=(o,r)=>{for(var t in r)d(o,t,{get:r[t],enumerable:!0})},u=(o,r,t,
|
|
1
|
+
"use strict";var d=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var s=Object.getOwnPropertyNames;var p=Object.prototype.hasOwnProperty;var c=(o,r)=>{for(var t in r)d(o,t,{get:r[t],enumerable:!0})},u=(o,r,t,m)=>{if(r&&typeof r=="object"||typeof r=="function")for(let n of s(r))!p.call(o,n)&&n!==t&&d(o,n,{get:()=>r[n],enumerable:!(m=g(r,n))||m.enumerable});return o};var S=o=>u(d({},"__esModule",{value:!0}),o);var C={};c(C,{SignBlockSingleCommand:()=>y});module.exports=S(C);var e=require("@ledgerhq/device-management-kit"),l=require("@ledgerhq/signer-utils"),i=require("purify-ts"),a=require("./utils/ledgerKeyringProtocolErrors");class y{constructor(r){this.args=r}errorHelper=new l.CommandErrorHelper(a.LEDGER_SYNC_ERRORS,a.LedgerKeyringProtocolErrorFactory);getApdu(){return new e.ApduBuilder({cla:224,ins:7,p1:1,p2:0}).addBufferToData(this.args.command).build()}parseResponse(r){return i.Maybe.fromNullable(this.errorHelper.getError(r)).orDefaultLazy(()=>{const t=new e.ApduParser(r),m=t.getUnparsedRemainingLength(),n=t.extractFieldByLength(m);return n?(0,e.CommandResultFactory)({data:n}):(0,e.CommandResultFactory)({error:new e.InvalidStatusWordError("No data returned by SignBlockSingleCommand")})})}}0&&(module.exports={SignBlockSingleCommand});
|
|
2
2
|
//# sourceMappingURL=SignBlockSingleCommand.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/internal/app-binder/command/SignBlockSingleCommand.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n type Apdu,\n ApduBuilder,\n ApduParser,\n type ApduResponse,\n type Command,\n type CommandResult,\n CommandResultFactory,\n InvalidStatusWordError,\n} from \"@ledgerhq/device-management-kit\";\nimport { CommandErrorHelper } from \"@ledgerhq/signer-utils\";\nimport { Maybe } from \"purify-ts\";\n\nimport {\n
|
|
5
|
-
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,4BAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EASO,2CACPC,EAAmC,kCACnCC,EAAsB,
|
|
4
|
+
"sourcesContent": ["import {\n type Apdu,\n ApduBuilder,\n ApduParser,\n type ApduResponse,\n type Command,\n type CommandResult,\n CommandResultFactory,\n InvalidStatusWordError,\n} from \"@ledgerhq/device-management-kit\";\nimport { CommandErrorHelper } from \"@ledgerhq/signer-utils\";\nimport { Maybe } from \"purify-ts\";\n\nimport {\n type SignBlockSingleCommandArgs,\n type SignBlockSingleCommandResponse,\n} from \"@api/app-binder/SignBlockSingleCommandTypes\";\n\nimport {\n LEDGER_SYNC_ERRORS,\n type LedgerKeyringProtocolErrorCodes,\n LedgerKeyringProtocolErrorFactory,\n} from \"./utils/ledgerKeyringProtocolErrors\";\n\nexport class SignBlockSingleCommand\n implements\n Command<\n SignBlockSingleCommandResponse,\n SignBlockSingleCommandArgs,\n LedgerKeyringProtocolErrorCodes\n >\n{\n private readonly errorHelper = new CommandErrorHelper<\n SignBlockSingleCommandResponse,\n LedgerKeyringProtocolErrorCodes\n >(LEDGER_SYNC_ERRORS, LedgerKeyringProtocolErrorFactory);\n\n constructor(private readonly args: SignBlockSingleCommandArgs) {}\n\n getApdu(): Apdu {\n return new ApduBuilder({\n cla: 0xe0,\n ins: 0x07,\n p1: 0x01,\n p2: 0x00,\n })\n .addBufferToData(this.args.command)\n .build();\n }\n\n parseResponse(\n apduResponse: ApduResponse,\n ): CommandResult<\n SignBlockSingleCommandResponse,\n LedgerKeyringProtocolErrorCodes\n > {\n return Maybe.fromNullable(\n this.errorHelper.getError(apduResponse),\n ).orDefaultLazy(() => {\n const parser = new ApduParser(apduResponse);\n const remaining = parser.getUnparsedRemainingLength();\n const tlvBlob = parser.extractFieldByLength(remaining);\n if (!tlvBlob) {\n return CommandResultFactory({\n error: new InvalidStatusWordError(\n \"No data returned by SignBlockSingleCommand\",\n ),\n });\n }\n return CommandResultFactory({ data: tlvBlob });\n });\n }\n}\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,4BAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EASO,2CACPC,EAAmC,kCACnCC,EAAsB,qBAOtBC,EAIO,+CAEA,MAAML,CAOb,CAME,YAA6BM,EAAkC,CAAlC,UAAAA,CAAmC,CAL/C,YAAc,IAAI,qBAGjC,qBAAoB,mCAAiC,EAIvD,SAAgB,CACd,OAAO,IAAI,cAAY,CACrB,IAAK,IACL,IAAK,EACL,GAAI,EACJ,GAAI,CACN,CAAC,EACE,gBAAgB,KAAK,KAAK,OAAO,EACjC,MAAM,CACX,CAEA,cACEC,EAIA,CACA,OAAO,QAAM,aACX,KAAK,YAAY,SAASA,CAAY,CACxC,EAAE,cAAc,IAAM,CACpB,MAAMC,EAAS,IAAI,aAAWD,CAAY,EACpCE,EAAYD,EAAO,2BAA2B,EAC9CE,EAAUF,EAAO,qBAAqBC,CAAS,EACrD,OAAKC,KAOE,wBAAqB,CAAE,KAAMA,CAAQ,CAAC,KANpC,wBAAqB,CAC1B,MAAO,IAAI,yBACT,4CACF,CACF,CAAC,CAGL,CAAC,CACH,CACF",
|
|
6
6
|
"names": ["SignBlockSingleCommand_exports", "__export", "SignBlockSingleCommand", "__toCommonJS", "import_device_management_kit", "import_signer_utils", "import_purify_ts", "import_ledgerKeyringProtocolErrors", "args", "apduResponse", "parser", "remaining", "tlvBlob"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var e=require("@ledgerhq/device-management-kit"),
|
|
1
|
+
"use strict";var e=require("@ledgerhq/device-management-kit"),o=require("vitest"),c=require("./SignBlockSingleCommand");const a=Uint8Array.from([240,202,204,26]),m=Uint8Array.from([240,202,204,26]);(0,o.describe)("SignBlockSingleCommand",()=>{(0,o.describe)("getApdu()",()=>{(0,o.it)("should build the correct APDU for a given command",()=>{const s={command:a},r=new c.SignBlockSingleCommand(s).getApdu(),n=Uint8Array.from([224,7,1,0,a.length,...a]);(0,o.expect)(r.getRawApdu()).toEqual(n)})}),(0,o.describe)("parseResponse()",()=>{(0,o.it)("should return the raw TLV blob on success",()=>{const s={command:a},t=new c.SignBlockSingleCommand(s),r=new e.ApduResponse({statusCode:Uint8Array.from([144,0]),data:m}),n=t.parseResponse(r);if((0,o.expect)((0,e.isSuccessCommandResult)(n)).toBe(!0),(0,e.isSuccessCommandResult)(n)){const d=n.data;(0,o.expect)(d).toEqual(m)}}),(0,o.it)("should map SW errors to CommandResult errors",()=>{const s={command:a},t=new c.SignBlockSingleCommand(s),r=new e.ApduResponse({statusCode:Uint8Array.from([106,134]),data:new Uint8Array}),n=t.parseResponse(r);(0,o.expect)((0,e.isSuccessCommandResult)(n)).toBe(!1),(0,e.isSuccessCommandResult)(n)||(0,o.expect)(n.error.errorCode).toBe("6a86")}),(0,o.it)("should return an empty Uint8Array if no data is returned",()=>{const s={command:a},t=new c.SignBlockSingleCommand(s),r=new e.ApduResponse({statusCode:Uint8Array.from([144,0]),data:new Uint8Array}),n=t.parseResponse(r);(0,o.expect)((0,e.isSuccessCommandResult)(n)).toBe(!0),(0,e.isSuccessCommandResult)(n)&&(0,o.expect)(n.data).toEqual(new Uint8Array)})})});
|
|
2
2
|
//# sourceMappingURL=SignBlockSingleCommand.test.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/internal/app-binder/command/SignBlockSingleCommand.test.ts"],
|
|
4
|
-
"sourcesContent": ["/* eslint-disable @typescript-eslint/no-unsafe-member-access */\n/* eslint-disable @typescript-eslint/no-explicit-any */\nimport {\n ApduResponse,\n isSuccessCommandResult,\n} from \"@ledgerhq/device-management-kit\";\nimport { describe, expect, it } from \"vitest\";\n\nimport {\n
|
|
5
|
-
"mappings": "aAEA,IAAAA,EAGO,2CACPC,EAAqC,
|
|
4
|
+
"sourcesContent": ["/* eslint-disable @typescript-eslint/no-unsafe-member-access */\n/* eslint-disable @typescript-eslint/no-explicit-any */\nimport {\n ApduResponse,\n isSuccessCommandResult,\n} from \"@ledgerhq/device-management-kit\";\nimport { describe, expect, it } from \"vitest\";\n\nimport {\n type SignBlockSingleCommandArgs,\n type SignBlockSingleCommandResponse,\n} from \"@api/app-binder/SignBlockSingleCommandTypes\";\n\nimport { SignBlockSingleCommand } from \"./SignBlockSingleCommand\";\n\nconst COMMAND_BYTES = Uint8Array.from([0xf0, 0xca, 0xcc, 0x1a]);\nconst TLV_PAYLOAD = Uint8Array.from([0xf0, 0xca, 0xcc, 0x1a]);\n\ndescribe(\"SignBlockSingleCommand\", () => {\n describe(\"getApdu()\", () => {\n it(\"should build the correct APDU for a given command\", () => {\n // given\n const args: SignBlockSingleCommandArgs = { command: COMMAND_BYTES };\n const cmd = new SignBlockSingleCommand(args);\n\n // when\n const apdu = cmd.getApdu();\n const expected = Uint8Array.from([\n 0xe0,\n 0x07,\n 0x01,\n 0x00,\n COMMAND_BYTES.length,\n ...COMMAND_BYTES,\n ]);\n\n // then\n expect(apdu.getRawApdu()).toEqual(expected);\n });\n });\n\n describe(\"parseResponse()\", () => {\n it(\"should return the raw TLV blob on success\", () => {\n // given\n const args: SignBlockSingleCommandArgs = { command: COMMAND_BYTES };\n const cmd = new SignBlockSingleCommand(args);\n const response = new ApduResponse({\n statusCode: Uint8Array.from([0x90, 0x00]),\n data: TLV_PAYLOAD,\n });\n\n // when\n const result = cmd.parseResponse(response);\n\n // then\n expect(isSuccessCommandResult(result)).toBe(true);\n if (isSuccessCommandResult(result)) {\n const data: SignBlockSingleCommandResponse = result.data;\n expect(data).toEqual(TLV_PAYLOAD);\n }\n });\n\n it(\"should map SW errors to CommandResult errors\", () => {\n // given\n const args: SignBlockSingleCommandArgs = { command: COMMAND_BYTES };\n const cmd = new SignBlockSingleCommand(args);\n const response = new ApduResponse({\n statusCode: Uint8Array.from([0x6a, 0x86]),\n data: new Uint8Array(),\n });\n\n // when\n const result = cmd.parseResponse(response);\n\n // then\n expect(isSuccessCommandResult(result)).toBe(false);\n if (!isSuccessCommandResult(result)) {\n expect((result.error as any).errorCode).toBe(\"6a86\");\n }\n });\n\n it(\"should return an empty Uint8Array if no data is returned\", () => {\n // given\n const args: SignBlockSingleCommandArgs = { command: COMMAND_BYTES };\n const cmd = new SignBlockSingleCommand(args);\n const response = new ApduResponse({\n statusCode: Uint8Array.from([0x90, 0x00]),\n data: new Uint8Array(),\n });\n\n // when\n const result = cmd.parseResponse(response);\n\n // then\n expect(isSuccessCommandResult(result)).toBe(true);\n if (isSuccessCommandResult(result)) {\n expect(result.data).toEqual(new Uint8Array());\n }\n });\n });\n});\n"],
|
|
5
|
+
"mappings": "aAEA,IAAAA,EAGO,2CACPC,EAAqC,kBAOrCC,EAAuC,oCAEvC,MAAMC,EAAgB,WAAW,KAAK,CAAC,IAAM,IAAM,IAAM,EAAI,CAAC,EACxDC,EAAc,WAAW,KAAK,CAAC,IAAM,IAAM,IAAM,EAAI,CAAC,KAE5D,YAAS,yBAA0B,IAAM,IACvC,YAAS,YAAa,IAAM,IAC1B,MAAG,oDAAqD,IAAM,CAE5D,MAAMC,EAAmC,CAAE,QAASF,CAAc,EAI5DG,EAHM,IAAI,yBAAuBD,CAAI,EAG1B,QAAQ,EACnBE,EAAW,WAAW,KAAK,CAC/B,IACA,EACA,EACA,EACAJ,EAAc,OACd,GAAGA,CACL,CAAC,KAGD,UAAOG,EAAK,WAAW,CAAC,EAAE,QAAQC,CAAQ,CAC5C,CAAC,CACH,CAAC,KAED,YAAS,kBAAmB,IAAM,IAChC,MAAG,4CAA6C,IAAM,CA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AD", "args", "apdu", "expected", "cmd", "response", "result", "data"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var S=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var k=Object.getOwnPropertyNames;var I=Object.prototype.hasOwnProperty;var
|
|
1
|
+
"use strict";var S=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var k=Object.getOwnPropertyNames;var I=Object.prototype.hasOwnProperty;var b=(o,r)=>{for(var i in r)S(o,i,{get:r[i],enumerable:!0})},f=(o,r,i,c)=>{if(r&&typeof r=="object"||typeof r=="function")for(let m of k(r))!I.call(o,m)&&m!==i&&S(o,m,{get:()=>r[m],enumerable:!(c=g(r,m))||c.enumerable});return o};var M=o=>f(S({},"__esModule",{value:!0}),o);var w={};b(w,{AddToTrustchainDeviceAction:()=>v});module.exports=M(w);var s=require("@ledgerhq/device-management-kit"),u=require("purify-ts"),a=require("xstate"),d=require("../../../api/app-binder/AddToTrustchainDeviceActionTypes"),A=require("../../../api/app-binder/Errors"),y=require("../../app-binder/task/InitTask"),D=require("../../app-binder/task/ParseStreamToDeviceTask"),E=require("../../app-binder/task/SignBlockTask"),l=require("../../utils/eitherSeqRecord"),p=require("../../utils/required"),T=require("./utils/raiseAndAssign");class v extends s.XStateDeviceAction{makeStateMachine(r){const{initCommand:i,parseStream:c,signBlock:m}=this.extractDependencies(r);return(0,a.setup)({types:{input:{},context:{},output:{}},actors:{initCommand:(0,a.fromPromise)(i),parseStream:(0,a.fromPromise)(c),signBlock:(0,a.fromPromise)(m)},actions:{assignErrorFromEvent:(0,T.raiseAndAssign)(({event:t})=>(0,u.Left)(new A.LKRPUnknownError(String(t.error))))},guards:{isTustchainEmpty:({context:t})=>t.input.toMaybe().chain(e=>e.trustchain.getAppStream(e.appId)).chain(e=>e.parse().toMaybe()).map(e=>e.length===0).orDefault(!0)}}).createMachine({id:"AddToTrustchainDeviceAction",context:({input:t})=>({input:t,intermediateValue:{requiredUserInteraction:s.UserInteractionRequired.None},_internalState:(0,u.Right)({sessionKeypair:null})}),initial:"InitSession",states:{InitSession:{entry:(0,a.assign)({intermediateValue:{requiredUserInteraction:s.UserInteractionRequired.None,step:d.AddToTrustchaineDAStep.Initialize}}),on:{success:"ParseStream",error:"Error"},invoke:{id:"initCommand",src:"initCommand",onError:{actions:"assignErrorFromEvent"},onDone:{actions:(0,T.raiseAndAssign)(({event:t})=>t.output.map(e=>({raise:"success",assign:{sessionKeypair:e}})))}}},ParseStream:{entry:(0,a.assign)({intermediateValue:{requiredUserInteraction:s.UserInteractionRequired.None,step:d.AddToTrustchaineDAStep.ParseStream}}),on:{success:"CheckApplicationStreamExist",error:"Error"},invoke:{id:"parseStream",src:"parseStream",input:({context:t})=>t.input.chain(e=>(0,l.eitherSeqRecord)({seedBlock:()=>(0,p.required)(e.trustchain.getRootStream().chain(n=>n.parse().toMaybe()).extract()?.[0],"Missing seed block to parse"),applicationStream:()=>(0,p.required)(e.trustchain.getAppStream(e.appId).extract(),"Missing application stream to parse")})),onError:{actions:"assignErrorFromEvent"},onDone:{actions:(0,T.raiseAndAssign)(({event:t})=>t.output.map(()=>({raise:"success"})))}}},CheckApplicationStreamExist:{always:[{target:"AddToNewStream",guard:"isTustchainEmpty"},{target:"AddToExistingStream"}]},AddToExistingStream:{entry:(0,a.assign)({intermediateValue:{requiredUserInteraction:d.AddToTrustchainDAState.AddMember,step:d.AddToTrustchaineDAStep.AddMember}}),on:{success:"Success",error:"Error"},invoke:{id:"signBlock",src:"signBlock",input:({context:t})=>t.input.chain(e=>{const n=e.trustchain.getAppStream(e.appId);return(0,l.eitherSeqRecord)({lkrpDataSource:e.lkrpDataSource,trustchainId:e.trustchain.getId(),jwt:e.jwt,clientName:e.clientName,sessionKeypair:()=>t._internalState.chain(({sessionKeypair:h})=>(0,p.required)(h,"Missing session keypair")),path:()=>(0,p.required)(n.chain(h=>h.getPath()).extract(),"Missing application path"),parent:()=>(0,p.required)(n.chain(h=>h.parse().toMaybe()).chainNullable(h=>h.at(-1)?.hash()).chainNullable(s.hexaStringToBuffer).extract(),"Missing parent block"),blockFlow:{type:"addMember",data:{name:e.clientName,publicKey:e.keypair.pubKeyToU8a(),permissions:e.permissions}}})}),onError:{actions:"assignErrorFromEvent"},onDone:{actions:(0,T.raiseAndAssign)(({event:t})=>t.output.map(()=>({raise:"success"})))}}},AddToNewStream:{entry:(0,a.assign)({intermediateValue:{requiredUserInteraction:d.AddToTrustchainDAState.AddMember,step:d.AddToTrustchaineDAStep.AddMember}}),on:{success:"Success",error:"Error"},invoke:{id:"signBlock",src:"signBlock",input:({context:t})=>t.input.chain(e=>(0,l.eitherSeqRecord)({lkrpDataSource:e.lkrpDataSource,trustchainId:e.trustchain.getId(),jwt:e.jwt,clientName:e.clientName,sessionKeypair:()=>t._internalState.chain(({sessionKeypair:n})=>(0,p.required)(n,"Missing session keypair")),path:`m/0'/${e.appId}'/0'`,parent:()=>(0,p.required)(e.trustchain.getRootStream().chain(n=>n.parse().toMaybe()).chainNullable(n=>n[0]?.hash()).chainNullable(s.hexaStringToBuffer).extract(),"Missing init block"),blockFlow:{type:"derive",data:{name:e.clientName,publicKey:e.keypair.pubKeyToU8a(),permissions:e.permissions}}}).chain(()=>(0,u.Left)(new A.LKRPTrustchainNotReady))),onError:{actions:"assignErrorFromEvent"},onDone:{actions:(0,T.raiseAndAssign)(({event:t})=>t.output.map(()=>({raise:"success"})))}}},Success:{type:"final"},Error:{type:"final"}},output:({context:t})=>t._internalState.map(e=>{})})}extractDependencies(r){return{initCommand:()=>new y.InitTask(r).run(),parseStream:async i=>u.EitherAsync.liftEither(i.input).chain(c=>new D.ParseStreamToDeviceTask(r).run(c)).run(),signBlock:i=>u.EitherAsync.liftEither(i.input).chain(c=>new E.SignBlockTask(r).run(c)).run()}}}0&&(module.exports={AddToTrustchainDeviceAction});
|
|
2
2
|
//# sourceMappingURL=AddToTrustchainDeviceAction.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/internal/app-binder/device-action/AddToTrustchainDeviceAction.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n type DeviceActionStateMachine,\n hexaStringToBuffer,\n type InternalApi,\n type StateMachineTypes,\n UserInteractionRequired,\n XStateDeviceAction,\n} from \"@ledgerhq/device-management-kit\";\nimport { type Either, EitherAsync, Left, Right } from \"purify-ts\";\nimport { assign, fromPromise, setup } from \"xstate\";\n\nimport {\n type AddToTrustchainDAError,\n type AddToTrustchainDAInput,\n type AddToTrustchainDAIntermediateValue,\n type AddToTrustchainDAInternalState,\n type AddToTrustchainDAOutput,\n AddToTrustchainDAState,\n AddToTrustchaineDAStep,\n} from \"@api/app-binder/AddToTrustchainDeviceActionTypes\";\nimport { type CryptoService } from \"@api/crypto/CryptoService\";\nimport { type KeyPair } from \"@api/crypto/KeyPair\";\nimport { LKRPTrustchainNotReady, LKRPUnknownError } from \"@api/model/Errors\";\nimport { InitTask } from \"@internal/app-binder/task/InitTask\";\nimport {\n ParseStreamToDeviceTask,\n type ParseStreamToDeviceTaskInput,\n} from \"@internal/app-binder/task/ParseStreamToDeviceTask\";\nimport {\n SignBlockTask,\n type SignBlockTaskInput,\n} from \"@internal/app-binder/task/SignBlockTask\";\nimport { eitherSeqRecord } from \"@internal/utils/eitherSeqRecord\";\nimport { required } from \"@internal/utils/required\";\n\nimport { raiseAndAssign } from \"./utils/raiseAndAssign\";\n\nexport class AddToTrustchainDeviceAction extends XStateDeviceAction<\n AddToTrustchainDAOutput,\n AddToTrustchainDAInput,\n AddToTrustchainDAError,\n AddToTrustchainDAIntermediateValue,\n AddToTrustchainDAInternalState\n> {\n makeStateMachine(\n internalApi: InternalApi,\n ): DeviceActionStateMachine<\n AddToTrustchainDAOutput,\n AddToTrustchainDAInput,\n AddToTrustchainDAError,\n AddToTrustchainDAIntermediateValue,\n AddToTrustchainDAInternalState\n > {\n type types = StateMachineTypes<\n AddToTrustchainDAOutput,\n AddToTrustchainDAInput,\n AddToTrustchainDAError,\n AddToTrustchainDAIntermediateValue,\n AddToTrustchainDAInternalState\n >;\n\n const { initCommand, parseStream, signBlock } =\n this.extractDependencies(internalApi);\n\n return setup({\n types: {\n input: {} as types[\"input\"],\n context: {} as types[\"context\"],\n output: {} as types[\"output\"],\n },\n\n actors: {\n initCommand: fromPromise(initCommand),\n parseStream: fromPromise(parseStream),\n signBlock: fromPromise(signBlock),\n },\n\n actions: {\n assignErrorFromEvent: raiseAndAssign(\n ({ event }) =>\n Left(\n new LKRPUnknownError(\n String((event as { error?: unknown }).error),\n ),\n ), // NOTE: it should never happen, the error is not typed anymore here\n ),\n },\n\n guards: {\n isTustchainEmpty: ({ context }) =>\n context.input\n .toMaybe()\n .chain((input) => input.trustchain.getAppStream(input.appId))\n .chain((appStream) => appStream.parse().toMaybe())\n .map((blocks) => blocks.length === 0)\n .orDefault(true),\n },\n }).createMachine({\n /** @xstate-layout N4IgpgJg5mDOIC5QEEIQCoHt0CcCusALgMYAWAhgJYB2AImAG6XFjLGGWbUB0AktZUIBlOLE7UAxBC5huNBpgDWsmoIDCmALaby1CAG0ADAF1EoAA6YxHLmZAAPRAEZDAdm6unAFgAcXpwBsAKwAzL7+TgA0IACezq4AnB6GIU4ATAFeaUEBuT5pAL4F0agY2PhEZFR0jMys7OJ8AsKi4hJgODiYONzmADbkhABm3ZpyzRraugYmdpbW4naOCAlJaS4JXgGpCZ6r0XEIPgHc2YaGXiEhOdlXTkUlaFi4BCQUNPRMLGw2PPyCIlgYi4ElgeGILCBRlMSBA80Ei1hy2uXm4IVcXlWZwS5xChiCB0QaQSQW4QVcxMC63SCTShWKIFKzwqb2qnzqP0a-xaQLaHS6OGhcysCNsSMQKLRGKxQUMOJS+MJKzlaPSXlcPkSPkMaQxD0ZT3KryqH1q3waXG4AAVyDhYGAhIQcGByJopDJxgplL1bfbHc7XULYfDfktEKETgEnJ4coZMkEsUqnNqySFgtGgsmsWkvPqmUbKu8al96r9rb6HU6XW7+d1egN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gZBB+syhYNeu-dan8CboidivXYCYUiZFcEqIiWc1TA3OLSTU98kZ3SYXrMOZRDbWRwfjNyTgeG7T4cOHEaYz7p1cCEXaH50JjmjHiNMjCmah0tEIKOQJVES3iLsKcN9fCqU-JcAkiltJkllvkQxtV1gyINI-Yue8WY8Wmo4me8RMy7RzFSK6cZ0gUyMeqf2tDpxpnJH3fuQA */\n\n id: \"AddToTrustchainDeviceAction\",\n context: ({ input }) => ({\n input,\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n _internalState: Right({\n sessionKeypair: null,\n }),\n }),\n\n initial: \"InitSession\",\n states: {\n InitSession: {\n entry: assign({\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: AddToTrustchaineDAStep.Initialize,\n },\n }),\n on: { success: \"ParseStream\", error: \"Error\" },\n invoke: {\n id: \"initCommand\",\n src: \"initCommand\",\n input: ({ context }) =>\n context.input.map((input) => input.cryptoService),\n onError: { actions: \"assignErrorFromEvent\" },\n onDone: {\n actions: raiseAndAssign(({ event }) =>\n event.output.map((sessionKeypair) => ({\n raise: \"success\",\n assign: { sessionKeypair },\n })),\n ),\n },\n },\n },\n\n ParseStream: {\n entry: assign({\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: AddToTrustchaineDAStep.ParseStream,\n },\n }),\n on: { success: \"CheckApplicationStreamExist\", error: \"Error\" },\n invoke: {\n id: \"parseStream\",\n src: \"parseStream\",\n input: ({ context }) =>\n context.input.chain((input) =>\n eitherSeqRecord({\n seedBlock: () =>\n required(\n input.trustchain\n .getRootStream()\n .chain((stream) => stream.parse().toMaybe())\n .extract()?.[0],\n \"Missing seed block to parse\",\n ),\n applicationStream: () =>\n required(\n input.trustchain.getAppStream(input.appId).extract(),\n \"Missing application stream to parse\",\n ),\n }),\n ),\n onError: { actions: \"assignErrorFromEvent\" },\n onDone: {\n actions: raiseAndAssign(({ event }) =>\n event.output.map(() => ({ raise: \"success\" })),\n ),\n },\n },\n },\n\n CheckApplicationStreamExist: {\n always: [\n { target: \"AddToNewStream\", guard: \"isTustchainEmpty\" },\n { target: \"AddToExistingStream\" },\n ],\n },\n\n AddToExistingStream: {\n entry: assign({\n intermediateValue: {\n requiredUserInteraction: AddToTrustchainDAState.AddMember,\n step: AddToTrustchaineDAStep.AddMember,\n },\n }),\n on: { success: \"Success\", error: \"Error\" },\n invoke: {\n id: \"signBlock\",\n src: \"signBlock\",\n input: ({ context }) =>\n context.input.chain((input) => {\n const appStream = input.trustchain.getAppStream(input.appId);\n return eitherSeqRecord({\n cryptoService: input.cryptoService,\n lkrpDataSource: input.lkrpDataSource,\n trustchainId: input.trustchain.getId(),\n jwt: input.jwt,\n clientName: input.clientName,\n sessionKeypair: () =>\n context._internalState.chain(({ sessionKeypair }) =>\n required(sessionKeypair, \"Missing session keypair\"),\n ),\n path: () =>\n required(\n appStream.chain((stream) => stream.getPath()).extract(),\n \"Missing application path\",\n ),\n parent: () =>\n required(\n appStream\n .chain((stream) => stream.parse().toMaybe())\n .chainNullable((blocks) => blocks.at(-1)?.hash())\n .chainNullable(hexaStringToBuffer)\n .extract(),\n \"Missing parent block\",\n ),\n blockFlow: {\n type: \"addMember\",\n data: {\n name: input.clientName,\n publicKey: input.keypair.getPublicKey(),\n permissions: input.permissions,\n },\n },\n });\n }),\n onError: { actions: \"assignErrorFromEvent\" },\n onDone: {\n actions: raiseAndAssign(({ event }) =>\n event.output.map(() => ({ raise: \"success\" })),\n ),\n },\n },\n },\n\n AddToNewStream: {\n entry: assign({\n intermediateValue: {\n requiredUserInteraction: AddToTrustchainDAState.AddMember,\n step: AddToTrustchaineDAStep.AddMember,\n },\n }),\n on: { success: \"Success\", error: \"Error\" },\n invoke: {\n id: \"signBlock\",\n src: \"signBlock\",\n input: ({ context }) =>\n context.input.chain((input) =>\n eitherSeqRecord({\n lkrpDataSource: input.lkrpDataSource,\n trustchainId: input.trustchain.getId(),\n jwt: input.jwt,\n clientName: input.clientName,\n sessionKeypair: () =>\n context._internalState.chain(({ sessionKeypair }) =>\n required(sessionKeypair, \"Missing session keypair\"),\n ),\n path: `m/0'/${input.appId}'/0'`,\n parent: () =>\n required(\n input.trustchain\n .getRootStream()\n .chain((stream) => stream.parse().toMaybe())\n .chainNullable((blocks) => blocks[0]?.hash())\n .chainNullable(hexaStringToBuffer)\n .extract(),\n \"Missing init block\",\n ),\n blockFlow: {\n type: \"derive\",\n data: {\n name: input.clientName,\n publicKey: input.keypair.getPublicKey(),\n permissions: input.permissions,\n },\n },\n }).chain(() => Left(new LKRPTrustchainNotReady())),\n ),\n onError: { actions: \"assignErrorFromEvent\" },\n onDone: {\n actions: raiseAndAssign(({ event }) =>\n event.output.map(() => ({ raise: \"success\" })),\n ),\n },\n },\n },\n\n Success: { type: \"final\" },\n\n Error: { type: \"final\" },\n },\n\n output: ({ context }) => context._internalState.map((_) => undefined),\n });\n }\n\n extractDependencies(internalApi: InternalApi) {\n return {\n initCommand: async (args: {\n input: Either<AddToTrustchainDAError, CryptoService>;\n }): Promise<Either<AddToTrustchainDAError, KeyPair>> =>\n EitherAsync.liftEither(args.input)\n .chain((cryptoService) =>\n new InitTask(internalApi, cryptoService).run(),\n )\n .run(),\n\n parseStream: async (args: {\n input: Either<AddToTrustchainDAError, ParseStreamToDeviceTaskInput>;\n }) =>\n EitherAsync.liftEither(args.input)\n .chain<AddToTrustchainDAError, unknown>((input) =>\n new ParseStreamToDeviceTask(internalApi).run(input),\n )\n .run(),\n\n signBlock: (args: {\n input: Either<\n AddToTrustchainDAError,\n SignBlockTaskInput & { cryptoService: CryptoService }\n >;\n }): Promise<Either<AddToTrustchainDAError, void>> =>\n EitherAsync.liftEither(args.input)\n .chain((input) =>\n new SignBlockTask(internalApi, input.cryptoService).run(input),\n )\n .run(),\n };\n }\n}\n"],
|
|
5
|
-
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,iCAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAOO,2CACPC,EAAsD,qBACtDC,EAA2C,kBAE3CC,EAQO,
|
|
6
|
-
"names": ["AddToTrustchainDeviceAction_exports", "__export", "AddToTrustchainDeviceAction", "__toCommonJS", "import_device_management_kit", "import_purify_ts", "import_xstate", "import_AddToTrustchainDeviceActionTypes", "import_Errors", "import_InitTask", "import_ParseStreamToDeviceTask", "import_SignBlockTask", "import_eitherSeqRecord", "import_required", "import_raiseAndAssign", "internalApi", "initCommand", "parseStream", "signBlock", "event", "context", "input", "appStream", "blocks", "sessionKeypair", "stream", "_", "args"
|
|
4
|
+
"sourcesContent": ["import {\n type DeviceActionStateMachine,\n hexaStringToBuffer,\n type InternalApi,\n type StateMachineTypes,\n UserInteractionRequired,\n XStateDeviceAction,\n} from \"@ledgerhq/device-management-kit\";\nimport { type Either, EitherAsync, Left, Right } from \"purify-ts\";\nimport { assign, fromPromise, setup } from \"xstate\";\n\nimport {\n type AddToTrustchainDAError,\n type AddToTrustchainDAInput,\n type AddToTrustchainDAIntermediateValue,\n type AddToTrustchainDAInternalState,\n type AddToTrustchainDAOutput,\n AddToTrustchainDAState,\n AddToTrustchaineDAStep,\n} from \"@api/app-binder/AddToTrustchainDeviceActionTypes\";\nimport {\n LKRPTrustchainNotReady,\n LKRPUnknownError,\n} from \"@api/app-binder/Errors\";\nimport { type Keypair } from \"@api/index\";\nimport { type LKRPDeviceCommandError } from \"@internal/app-binder/command/utils/ledgerKeyringProtocolErrors\";\nimport { InitTask } from \"@internal/app-binder/task/InitTask\";\nimport {\n ParseStreamToDeviceTask,\n type ParseStreamToDeviceTaskInput,\n} from \"@internal/app-binder/task/ParseStreamToDeviceTask\";\nimport {\n SignBlockTask,\n type SignBlockTaskInput,\n} from \"@internal/app-binder/task/SignBlockTask\";\nimport { eitherSeqRecord } from \"@internal/utils/eitherSeqRecord\";\nimport { required } from \"@internal/utils/required\";\n\nimport { raiseAndAssign } from \"./utils/raiseAndAssign\";\n\nexport class AddToTrustchainDeviceAction extends XStateDeviceAction<\n AddToTrustchainDAOutput,\n AddToTrustchainDAInput,\n AddToTrustchainDAError,\n AddToTrustchainDAIntermediateValue,\n AddToTrustchainDAInternalState\n> {\n makeStateMachine(\n internalApi: InternalApi,\n ): DeviceActionStateMachine<\n AddToTrustchainDAOutput,\n AddToTrustchainDAInput,\n AddToTrustchainDAError,\n AddToTrustchainDAIntermediateValue,\n AddToTrustchainDAInternalState\n > {\n type types = StateMachineTypes<\n AddToTrustchainDAOutput,\n AddToTrustchainDAInput,\n AddToTrustchainDAError,\n AddToTrustchainDAIntermediateValue,\n AddToTrustchainDAInternalState\n >;\n\n const { initCommand, parseStream, signBlock } =\n this.extractDependencies(internalApi);\n\n return setup({\n types: {\n input: {} as types[\"input\"],\n context: {} as types[\"context\"],\n output: {} as types[\"output\"],\n },\n\n actors: {\n initCommand: fromPromise(initCommand),\n parseStream: fromPromise(parseStream),\n signBlock: fromPromise(signBlock),\n },\n\n actions: {\n assignErrorFromEvent: raiseAndAssign(\n ({ event }) =>\n Left(\n new LKRPUnknownError(\n String((event as { error?: unknown }).error),\n ),\n ), // NOTE: it should never happen, the error is not typed anymore here\n ),\n },\n\n guards: {\n isTustchainEmpty: ({ context }) =>\n context.input\n .toMaybe()\n .chain((input) => input.trustchain.getAppStream(input.appId))\n .chain((appStream) => appStream.parse().toMaybe())\n .map((blocks) => blocks.length === 0)\n .orDefault(true),\n },\n }).createMachine({\n /** @xstate-layout N4IgpgJg5mDOIC5QEEIQCoHt0CcCusALgMYAWAhgJYB2AImAG6XFjLGGWbUB0AktZUIBlOLE7UAxBC5huNBpgDWsmoIDCmALaby1CAG0ADAF1EoAA6YxHLmZAAPRAEZDAdm6unAFgAcXpwBsAKwAzL7+TgA0IACezq4AnB6GIU4ATAFeaUEBuT5pAL4F0agY2PhEZFR0jMys7OJ8AsKi4hJgODiYONzmADbkhABm3ZpyzRraugYmdpbW4naOCAlJaS4JXgGpCZ6r0XEIPgHc2YaGXiEhOdlXTkUlaFi4BCQUNPRMLGw2PPyCIlgYi4ElgeGILCBRlM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oS4bw6N7Ha0FGO7bjraE9fJPQfJxSwgB3zKX9hJtTjIIigZahMAgOA7EonXUce1z4Nc5YAFoFMOWfSVWVZNXnVxtm8Eki-u+KhqaAFWinjbKvVF9rwDi6KSCWUKVzaK9ODifS-LXdJuFe2e3Vdx-HfBMtnRLSNOhxPxnSTucEcfh8TLgfsjXeg0WYmWYqxdixBOJcGsslQgH866-RxADK8Vxu7dXahFF8kUzofkxEELwWxsg3x3gZBB+syhYNeu-dan8CboidivXYCYUiZFcEqIiWc1TA3OLSTU98kZ3SYXrMOZRDbWRwfjNyTgeG7T4cOHEaYz7p1cCEXaH50JjmjHiNMjCmah0tEIKOQJVES3iLsKcN9fCqU-JcAkiltJkllvkQxtV1gyINI-Yue8WY8Wmo4me8RMy7RzFSK6cZ0gUyMeqf2tDpxpnJH3fuQA */\n\n id: \"AddToTrustchainDeviceAction\",\n context: ({ input }) => ({\n input,\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n _internalState: Right({\n sessionKeypair: null,\n }),\n }),\n\n initial: \"InitSession\",\n states: {\n InitSession: {\n entry: assign({\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: AddToTrustchaineDAStep.Initialize,\n },\n }),\n on: { success: \"ParseStream\", error: \"Error\" },\n invoke: {\n id: \"initCommand\",\n src: \"initCommand\",\n onError: { actions: \"assignErrorFromEvent\" },\n onDone: {\n actions: raiseAndAssign(({ event }) =>\n event.output.map((sessionKeypair) => ({\n raise: \"success\",\n assign: { sessionKeypair },\n })),\n ),\n },\n },\n },\n\n ParseStream: {\n entry: assign({\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: AddToTrustchaineDAStep.ParseStream,\n },\n }),\n on: { success: \"CheckApplicationStreamExist\", error: \"Error\" },\n invoke: {\n id: \"parseStream\",\n src: \"parseStream\",\n input: ({ context }) =>\n context.input.chain((input) =>\n eitherSeqRecord({\n seedBlock: () =>\n required(\n input.trustchain\n .getRootStream()\n .chain((stream) => stream.parse().toMaybe())\n .extract()?.[0],\n \"Missing seed block to parse\",\n ),\n applicationStream: () =>\n required(\n input.trustchain.getAppStream(input.appId).extract(),\n \"Missing application stream to parse\",\n ),\n }),\n ),\n onError: { actions: \"assignErrorFromEvent\" },\n onDone: {\n actions: raiseAndAssign(({ event }) =>\n event.output.map(() => ({ raise: \"success\" })),\n ),\n },\n },\n },\n\n CheckApplicationStreamExist: {\n always: [\n { target: \"AddToNewStream\", guard: \"isTustchainEmpty\" },\n { target: \"AddToExistingStream\" },\n ],\n },\n\n AddToExistingStream: {\n entry: assign({\n intermediateValue: {\n requiredUserInteraction: AddToTrustchainDAState.AddMember,\n step: AddToTrustchaineDAStep.AddMember,\n },\n }),\n on: { success: \"Success\", error: \"Error\" },\n invoke: {\n id: \"signBlock\",\n src: \"signBlock\",\n input: ({ context }) =>\n context.input.chain((input) => {\n const appStream = input.trustchain.getAppStream(input.appId);\n return eitherSeqRecord({\n lkrpDataSource: input.lkrpDataSource,\n trustchainId: input.trustchain.getId(),\n jwt: input.jwt,\n clientName: input.clientName,\n sessionKeypair: () =>\n context._internalState.chain(({ sessionKeypair }) =>\n required(sessionKeypair, \"Missing session keypair\"),\n ),\n path: () =>\n required(\n appStream.chain((stream) => stream.getPath()).extract(),\n \"Missing application path\",\n ),\n parent: () =>\n required(\n appStream\n .chain((stream) => stream.parse().toMaybe())\n .chainNullable((blocks) => blocks.at(-1)?.hash())\n .chainNullable(hexaStringToBuffer)\n .extract(),\n \"Missing parent block\",\n ),\n blockFlow: {\n type: \"addMember\",\n data: {\n name: input.clientName,\n publicKey: input.keypair.pubKeyToU8a(),\n permissions: input.permissions,\n },\n },\n });\n }),\n onError: { actions: \"assignErrorFromEvent\" },\n onDone: {\n actions: raiseAndAssign(({ event }) =>\n event.output.map(() => ({ raise: \"success\" })),\n ),\n },\n },\n },\n\n AddToNewStream: {\n entry: assign({\n intermediateValue: {\n requiredUserInteraction: AddToTrustchainDAState.AddMember,\n step: AddToTrustchaineDAStep.AddMember,\n },\n }),\n on: { success: \"Success\", error: \"Error\" },\n invoke: {\n id: \"signBlock\",\n src: \"signBlock\",\n input: ({ context }) =>\n context.input.chain((input) =>\n eitherSeqRecord({\n lkrpDataSource: input.lkrpDataSource,\n trustchainId: input.trustchain.getId(),\n jwt: input.jwt,\n clientName: input.clientName,\n sessionKeypair: () =>\n context._internalState.chain(({ sessionKeypair }) =>\n required(sessionKeypair, \"Missing session keypair\"),\n ),\n path: `m/0'/${input.appId}'/0'`,\n parent: () =>\n required(\n input.trustchain\n .getRootStream()\n .chain((stream) => stream.parse().toMaybe())\n .chainNullable((blocks) => blocks[0]?.hash())\n .chainNullable(hexaStringToBuffer)\n .extract(),\n \"Missing init block\",\n ),\n blockFlow: {\n type: \"derive\",\n data: {\n name: input.clientName,\n publicKey: input.keypair.pubKeyToU8a(),\n permissions: input.permissions,\n },\n },\n }).chain(() => Left(new LKRPTrustchainNotReady())),\n ),\n onError: { actions: \"assignErrorFromEvent\" },\n onDone: {\n actions: raiseAndAssign(({ event }) =>\n event.output.map(() => ({ raise: \"success\" })),\n ),\n },\n },\n },\n\n Success: { type: \"final\" },\n\n Error: { type: \"final\" },\n },\n\n output: ({ context }) => context._internalState.map((_) => undefined),\n });\n }\n\n extractDependencies(internalApi: InternalApi) {\n return {\n initCommand: (): Promise<Either<LKRPDeviceCommandError, Keypair>> =>\n new InitTask(internalApi).run(),\n\n parseStream: async (args: {\n input: Either<AddToTrustchainDAError, ParseStreamToDeviceTaskInput>;\n }) =>\n EitherAsync.liftEither(args.input)\n .chain<AddToTrustchainDAError, unknown>((input) =>\n new ParseStreamToDeviceTask(internalApi).run(input),\n )\n .run(),\n\n signBlock: (args: {\n input: Either<AddToTrustchainDAError, SignBlockTaskInput>;\n }): Promise<Either<AddToTrustchainDAError, void>> =>\n EitherAsync.liftEither(args.input)\n .chain((input) => new SignBlockTask(internalApi).run(input))\n .run(),\n };\n }\n}\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,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_exports", "__export", "AddToTrustchainDeviceAction", "__toCommonJS", "import_device_management_kit", "import_purify_ts", "import_xstate", "import_AddToTrustchainDeviceActionTypes", "import_Errors", "import_InitTask", "import_ParseStreamToDeviceTask", "import_SignBlockTask", "import_eitherSeqRecord", "import_required", "import_raiseAndAssign", "internalApi", "initCommand", "parseStream", "signBlock", "event", "context", "input", "appStream", "blocks", "sessionKeypair", "stream", "_", "args"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var D=Object.defineProperty;var
|
|
1
|
+
"use strict";var D=Object.defineProperty;var I=Object.getOwnPropertyDescriptor;var v=Object.getOwnPropertyNames;var f=Object.prototype.hasOwnProperty;var k=(s,i)=>{for(var o in i)D(s,o,{get:i[o],enumerable:!0})},M=(s,i,o,d)=>{if(i&&typeof i=="object"||typeof i=="function")for(let n of v(i))!f.call(s,n)&&n!==o&&D(s,n,{get:()=>i[n],enumerable:!(d=I(i,n))||d.enumerable});return s};var w=s=>M(D({},"__esModule",{value:!0}),s);var W={};k(W,{AuthenticateWithDeviceDeviceAction:()=>K});module.exports=w(W);var u=require("@ledgerhq/device-management-kit"),c=require("purify-ts"),r=require("xstate"),A=require("../../../api/app-binder/AuthenticateDeviceActionTypes"),m=require("../../../api/app-binder/Errors"),E=require("../../app-binder/task/AuthenticateTask"),T=require("../../app-binder/task/ExtractEncryptionKeyTask"),g=require("../../app-binder/task/SignChallengeWithDeviceTask"),y=require("../../utils/eitherSeqRecord"),a=require("../../utils/required"),h=require("./utils/raiseAndAssign"),S=require("./AddToTrustchainDeviceAction");const l="Ledger Sync";class K extends u.XStateDeviceAction{makeStateMachine(i){const{deviceAuth:o,getTrustchain:d,extractEncryptionKey:n}=this.extractDependencies(i);return(0,r.setup)({types:{input:{},context:{},output:{}},actors:{openAppStateMachine:new u.OpenAppDeviceAction({input:{appName:l}}).makeStateMachine(i),deviceAuth:(0,r.fromPromise)(o),getTrustchain:(0,r.fromPromise)(d),addToTrustchainStateMachine:new S.AddToTrustchainDeviceAction({input:(0,c.Left)(new m.LKRPMissingDataError("Missing input for GetEncryptionKey"))}).makeStateMachine(i),extractEncryptionKey:(0,r.fromPromise)(n)},actions:{assignErrorFromEvent:(0,h.raiseAndAssign)(({event:t})=>(0,c.Left)(new m.LKRPUnknownError(String(t.error))))},guards:{isTrustchainMember:({context:t})=>t._internalState.toMaybe().map(e=>e.wasAddedToTrustchain||e.trustchain?.getAppStream(t.input.appId).mapOrDefault(p=>p.hasMember(t.input.keypair.pubKeyToHex()),!1)).extract()??!1}}).createMachine({id:"AuthenticateWithDeviceDeviceAction",context:({input:t})=>({input:t,intermediateValue:{requiredUserInteraction:u.UserInteractionRequired.None},_internalState:(0,c.Right)({trustchainId:null,jwt:null,trustchain:null,encryptionKey:null,wasAddedToTrustchain:!1})}),initial:"OpenApp",states:{OpenApp:{on:{success:"DeviceAuth",error:"Error"},invoke:{id:"openApp",src:"openAppStateMachine",onSnapshot:{actions:(0,r.assign)({intermediateValue:({event:t})=>({step:A.AuthenticateDAStep.OpenApp,...t.snapshot.context.intermediateValue})})},input:{appName:l},onError:{actions:"assignErrorFromEvent"},onDone:{actions:(0,h.raiseAndAssign)(({event:t})=>t.output.map(()=>({raise:"success"})))}}},DeviceAuth:{entry:(0,r.assign)({intermediateValue:{step:A.AuthenticateDAStep.Authenticate,requiredUserInteraction:A.AuthenticateDAState.Authenticate}}),on:{success:"GetTrustchain",error:"Error"},invoke:{id:"deviceAuth",src:"deviceAuth",input:({context:t})=>t.input,onError:{actions:"assignErrorFromEvent"},onDone:{actions:(0,h.raiseAndAssign)(({event:t})=>t.output.chain(e=>e.trustchainId.caseOf({Nothing:()=>(0,c.Left)(new m.LKRPTrustchainNotReady),Just:p=>(0,c.Right)({raise:"success",assign:{jwt:e.jwt,trustchainId:p}})})))}}},GetTrustchain:{entry:(0,r.assign)({intermediateValue:{step:A.AuthenticateDAStep.GetTrustchain,requiredUserInteraction:u.UserInteractionRequired.None}}),on:{success:"CheckIsMembers",error:"Error"},invoke:{id:"getTrustchain",src:"getTrustchain",input:({context:t})=>t._internalState.chain(e=>(0,y.eitherSeqRecord)({lkrpDataSource:t.input.lkrpDataSource,trustchainId:()=>(0,a.required)(e.trustchainId,"Missing Trustchain ID for GetTrustchain"),jwt:()=>(0,a.required)(e.jwt,"Missing JWT for GetTrustchain")})),onError:{actions:"assignErrorFromEvent"},onDone:{actions:(0,h.raiseAndAssign)(({event:t})=>t.output.map(e=>({raise:"success",assign:{trustchain:e}})))}}},CheckIsMembers:{always:[{target:"ExtractEncryptionKey",guard:"isTrustchainMember"},{target:"AddToTrustchain"}]},AddToTrustchain:{on:{success:"GetTrustchain",error:"Error"},invoke:{id:"AddToTrustchain",src:"addToTrustchainStateMachine",onSnapshot:{actions:(0,r.assign)({intermediateValue:({event:t})=>t.snapshot.context.intermediateValue})},input:({context:t})=>t._internalState.mapLeft(()=>new m.LKRPMissingDataError("Missing data in the input for AddToTrustchain")).chain(e=>(0,y.eitherSeqRecord)({lkrpDataSource:t.input.lkrpDataSource,keypair:t.input.keypair,clientName:t.input.clientName,permissions:t.input.permissions,jwt:()=>(0,a.required)(e.jwt,"Missing JWT for AddToTrustchain"),appId:t.input.appId,trustchain:()=>(0,a.required)(e.trustchain,"Missing Trustchain for AddToTrustchain")})),onError:{actions:"assignErrorFromEvent"},onDone:{actions:(0,h.raiseAndAssign)(({event:t})=>t.output.map(()=>({raise:"success",assign:{wasAddedToTrustchain:!0}})))}}},ExtractEncryptionKey:{entry:(0,r.assign)({intermediateValue:{step:A.AuthenticateDAStep.ExtractEncryptionKey,requiredUserInteraction:u.UserInteractionRequired.None}}),on:{success:"Success",error:"Error"},invoke:{id:"ExtractEncryptionKey",src:"extractEncryptionKey",input:({context:t})=>({keypair:t.input.keypair,stream:t._internalState.chain(({trustchain:e})=>(0,a.required)(e?.getAppStream(t.input.appId).extract(),"Missing application stream for ExtractEncryptionKey"))}),onError:{actions:"assignErrorFromEvent"},onDone:{actions:(0,h.raiseAndAssign)(({event:t})=>t.output.map(e=>({raise:"success",assign:{encryptionKey:e}})))}}},Success:{type:"final"},Error:{type:"final"}},output:({context:t})=>t._internalState.chain(e=>(0,y.eitherSeqRecord)({trustchainId:()=>(0,a.required)(e.trustchainId,"Missing Trustchain ID in the output"),jwt:()=>(0,a.required)(e.jwt,"Missing JWT in the output"),applicationPath:()=>(0,a.required)(e.trustchain?.getAppStream(t.input.appId).chain(p=>p.getPath()).extract(),"Missing application path in the output"),encryptionKey:()=>(0,a.required)(e.encryptionKey,"Missing encryption key in the output")}))})}extractDependencies(i){const o=new E.AuthenticateTask,d=new T.ExtractEncryptionKeyTask;return{deviceAuth:({input:n})=>o.run(n.lkrpDataSource,new g.SignChallengeWithDeviceTask(i)),getTrustchain:n=>c.EitherAsync.liftEither(n.input).chain(({lkrpDataSource:t,trustchainId:e,jwt:p})=>t.getTrustchainById(e,p)).run(),extractEncryptionKey:async({input:n})=>c.EitherAsync.liftEither(n.stream).chain(t=>d.run(n.keypair,t))}}}0&&(module.exports={AuthenticateWithDeviceDeviceAction});
|
|
2
2
|
//# sourceMappingURL=AuthenticateWithDeviceDeviceAction.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/internal/app-binder/device-action/AuthenticateWithDeviceDeviceAction.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n type DeviceActionStateMachine,\n type InternalApi,\n OpenAppDeviceAction,\n type StateMachineTypes,\n UserInteractionRequired,\n XStateDeviceAction,\n} from \"@ledgerhq/device-management-kit\";\nimport { type Either, EitherAsync, Left, Right } from \"purify-ts\";\nimport { assign, fromPromise, setup } from \"xstate\";\n\nimport {\n type AuthenticateDAError,\n type AuthenticateDAIntermediateValue,\n type AuthenticateDAOutput,\n AuthenticateDAState,\n AuthenticateDAStep,\n} from \"@api/app-binder/AuthenticateDeviceActionTypes\";\nimport { type CryptoService } from \"@api/crypto/CryptoService\";\nimport { type KeyPair } from \"@api/crypto/KeyPair\";\nimport {\n LKRPMissingDataError,\n LKRPTrustchainNotReady,\n LKRPUnknownError,\n} from \"@api/model/Errors\";\nimport { type JWT } from \"@api/model/JWT\";\nimport { AuthenticateTask } from \"@internal/app-binder/task/AuthenticateTask\";\nimport { ExtractEncryptionKeyTask } from \"@internal/app-binder/task/ExtractEncryptionKeyTask\";\nimport { SignChallengeWithDeviceTask } from \"@internal/app-binder/task/SignChallengeWithDeviceTask\";\nimport { type LKRPDataSource } from \"@internal/lkrp-datasource/data/LKRPDataSource\";\nimport { eitherSeqRecord } from \"@internal/utils/eitherSeqRecord\";\nimport { type LKRPBlockStream } from \"@internal/utils/LKRPBlockStream\";\nimport { required } from \"@internal/utils/required\";\n\nimport {\n type AuthenticateWithDeviceDAInput,\n type AuthenticateWithDeviceDAInternalState,\n} from \"./models/AuthenticateWithDeviceDeviceActionTypes\";\nimport { raiseAndAssign } from \"./utils/raiseAndAssign\";\nimport { AddToTrustchainDeviceAction } from \"./AddToTrustchainDeviceAction\";\n\nconst APP_NAME = \"Ledger Sync\";\n\nexport class AuthenticateWithDeviceDeviceAction extends XStateDeviceAction<\n AuthenticateDAOutput,\n AuthenticateWithDeviceDAInput,\n AuthenticateDAError,\n AuthenticateDAIntermediateValue,\n AuthenticateWithDeviceDAInternalState\n> {\n makeStateMachine(\n internalApi: InternalApi,\n ): DeviceActionStateMachine<\n AuthenticateDAOutput,\n AuthenticateWithDeviceDAInput,\n AuthenticateDAError,\n AuthenticateDAIntermediateValue,\n AuthenticateWithDeviceDAInternalState\n > {\n type types = StateMachineTypes<\n AuthenticateDAOutput,\n AuthenticateWithDeviceDAInput,\n AuthenticateDAError,\n AuthenticateDAIntermediateValue,\n AuthenticateWithDeviceDAInternalState\n >;\n\n const { deviceAuth, getTrustchain, extractEncryptionKey } =\n this.extractDependencies(internalApi);\n\n return setup({\n types: {\n input: {} as types[\"input\"],\n context: {} as types[\"context\"],\n output: {} as types[\"output\"],\n },\n\n actors: {\n openAppStateMachine: new OpenAppDeviceAction({\n input: { appName: APP_NAME },\n }).makeStateMachine(internalApi),\n\n deviceAuth: fromPromise(deviceAuth),\n\n getTrustchain: fromPromise(getTrustchain),\n\n addToTrustchainStateMachine: new AddToTrustchainDeviceAction({\n input: Left(\n new LKRPMissingDataError(\"Missing input for GetEncryptionKey\"),\n ),\n }).makeStateMachine(internalApi),\n\n extractEncryptionKey: fromPromise(extractEncryptionKey),\n },\n\n actions: {\n assignErrorFromEvent: raiseAndAssign(\n ({ event }) =>\n Left(\n new LKRPUnknownError(\n String((event as { error?: unknown }).error),\n ),\n ), // NOTE: it should never happen, the error is not typed anymore here\n ),\n },\n\n guards: {\n isTrustchainMember: ({ context }) =>\n context._internalState\n .toMaybe()\n .map(\n (state) =>\n state.wasAddedToTrustchain ||\n state.trustchain\n ?.getAppStream(context.input.appId)\n .mapOrDefault(\n (stream) =>\n stream.hasMember(\n context.input.keypair.getPublicKeyToHex(),\n ),\n false,\n ),\n )\n .extract() ?? false,\n },\n }).createMachine({\n /** @xstate-layout N4IgpgJg5mDOIC5QEECuAXAFmAduglgMYCG6YA6vlgCJgBuRYtDhYyhBA9jgHQDyAB1zIBAgMQRuYHvhx1OAa2mchOEQIDaABgC6iUAM6wq+bvpAAPRAEYAzADYeATgAcAFltuntrdYBMAfYANCAAnogA7G6OttYREU5aWgERyQC+aSFoWLgEJGSUNPSMzIzsXLyCwqJiYABOdZx1PAIANqQAZk0Atjwq1Zq65obGFeZWCNbWAKw80-Z+Xvb2ni5OEdPWIeEI9tN+PC720RtuyU52GVkY2HhEpBRUmKWsL2wcppWq6mKwqISsWCwbR6JAgEYmMxgia2FwRHhaCIuaxaLz7ZbTLTBMKIFwuA7JLTePwJVxRCJXEDZW55B6FZ7FV6M94VfjfGr1Rp1EHDIyQnDjRAOA7WPGYiLHaxOab47Y2GVaHheOKiiVOAIBSnU3L3ApPN5vcqfHiGm4SKQyOSKaQQZnUnlgiFjaGIeZuQ62Py+PxSrQucVyhASxyuN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P0qs-NMwD36ry-twH+-sEqQJXKHJw4dI7RDDEkfY913TrHVDKDwCwr44O+ng1gRoCE9zfsvD+a9v5Tw1tyTm1kt6IGLrWJGnpy5+Ern1NsKIzjriOHvJGfZ1QZBQjgTgtp4BggJg-Hhis+FPl5FDFcABaVsOx5izGPhbUayJYiDjvjeL6IVkwdzZAMGxRtg4DQkuleIRJUTHB6kSbhfjsLGhfMEoOVYUSYxVPMBYPhOoST2EqJ2MphQXlgn4eJCt-H4N4JFXO7EUmFwmBcRwgFRQDQWE2ECh4j4FI2EiDwA0kYBW8cpD2mcqk8H+oDDaW1dp1BMclVJNgHDwmWDHWEb0PDqlyjQrEV8BrrD8E08pnsrHe3JqrWpsh6kyMmPEBypdrpiVcHsauSRoJxDWHYREMxJrDMJrgyxLIX6CJASIkhOAf7XKgdvO58jvAOD9M8g8bZpQEgKt5aIex-THLGac40ABlWcCUoVUNiJ2RYGx5gBD7E2CI91OwW2eohAI1YJo4qfnigh746gkt-AESSj1E5JAri4bs1dPS1l3EifYcJYI7n0WkIAA */\n\n id: \"AuthenticateWithDeviceDeviceAction\",\n context: ({ input }): types[\"context\"] => ({\n input,\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n _internalState: Right({\n trustchainId: null,\n jwt: null,\n trustchain: null,\n encryptionKey: null,\n wasAddedToTrustchain: false,\n }),\n }),\n\n initial: \"OpenApp\",\n states: {\n OpenApp: {\n on: { success: \"DeviceAuth\", error: \"Error\" },\n invoke: {\n id: \"openApp\",\n src: \"openAppStateMachine\",\n onSnapshot: {\n actions: assign({\n intermediateValue: ({ event }) => ({\n step: AuthenticateDAStep.OpenApp,\n ...event.snapshot.context.intermediateValue,\n }),\n }),\n },\n input: { appName: APP_NAME },\n onError: { actions: \"assignErrorFromEvent\" },\n onDone: {\n actions: raiseAndAssign(({ event }) =>\n event.output.map(() => ({ raise: \"success\" })),\n ),\n },\n },\n },\n\n DeviceAuth: {\n entry: assign({\n intermediateValue: {\n step: AuthenticateDAStep.Authenticate,\n requiredUserInteraction: AuthenticateDAState.Authenticate,\n },\n }),\n on: { success: \"GetTrustchain\", error: \"Error\" },\n invoke: {\n id: \"deviceAuth\",\n src: \"deviceAuth\",\n input: ({ context }) => context.input,\n onError: { actions: \"assignErrorFromEvent\" },\n onDone: {\n actions: raiseAndAssign(({ event }) =>\n event.output.chain((payload) =>\n payload.trustchainId.caseOf({\n Nothing: () => Left(new LKRPTrustchainNotReady()),\n Just: (trustchainId) =>\n Right({\n raise: \"success\",\n assign: { jwt: payload.jwt, trustchainId },\n }),\n }),\n ),\n ),\n },\n },\n },\n\n GetTrustchain: {\n entry: assign({\n intermediateValue: {\n step: AuthenticateDAStep.GetTrustchain,\n requiredUserInteraction: UserInteractionRequired.None,\n },\n }),\n on: { success: \"CheckIsMembers\", error: \"Error\" },\n invoke: {\n id: \"getTrustchain\",\n src: \"getTrustchain\",\n input: ({ context }) =>\n context._internalState.chain((state) =>\n eitherSeqRecord({\n lkrpDataSource: context.input.lkrpDataSource,\n trustchainId: () =>\n required(\n state.trustchainId,\n \"Missing Trustchain ID for GetTrustchain\",\n ),\n jwt: () =>\n required(state.jwt, \"Missing JWT for GetTrustchain\"),\n }),\n ),\n onError: { actions: \"assignErrorFromEvent\" },\n onDone: {\n actions: raiseAndAssign(({ event }) =>\n event.output.map((trustchain) => ({\n raise: \"success\",\n assign: { trustchain },\n })),\n ),\n },\n },\n },\n\n CheckIsMembers: {\n always: [\n { target: \"ExtractEncryptionKey\", guard: \"isTrustchainMember\" },\n { target: \"AddToTrustchain\" },\n ],\n },\n\n AddToTrustchain: {\n on: {\n success: \"GetTrustchain\",\n error: \"Error\",\n },\n invoke: {\n id: \"AddToTrustchain\",\n src: \"addToTrustchainStateMachine\",\n onSnapshot: {\n actions: assign({\n intermediateValue: ({ event }) =>\n event.snapshot.context.intermediateValue,\n }),\n },\n input: ({ context }) =>\n context._internalState\n .mapLeft(\n () =>\n new LKRPMissingDataError(\n \"Missing data in the input for AddToTrustchain\",\n ),\n )\n .chain((state) =>\n eitherSeqRecord({\n lkrpDataSource: context.input.lkrpDataSource,\n cryptoService: context.input.cryptoService,\n keypair: context.input.keypair,\n clientName: context.input.clientName,\n permissions: context.input.permissions,\n jwt: () =>\n required(state.jwt, \"Missing JWT for AddToTrustchain\"),\n appId: context.input.appId,\n trustchain: () =>\n required(\n state.trustchain,\n \"Missing Trustchain for AddToTrustchain\",\n ),\n }),\n ),\n onError: { actions: \"assignErrorFromEvent\" },\n onDone: {\n actions: raiseAndAssign(({ event }) =>\n event.output.map(() => ({\n raise: \"success\",\n assign: { wasAddedToTrustchain: true },\n })),\n ),\n },\n },\n },\n\n ExtractEncryptionKey: {\n entry: assign({\n intermediateValue: {\n step: AuthenticateDAStep.ExtractEncryptionKey,\n requiredUserInteraction: UserInteractionRequired.None,\n },\n }),\n on: { success: \"Success\", error: \"Error\" },\n invoke: {\n id: \"ExtractEncryptionKey\",\n src: \"extractEncryptionKey\",\n input: ({ context }) => ({\n cryptoService: context.input.cryptoService,\n keypair: context.input.keypair,\n stream: context._internalState.chain(({ trustchain }) =>\n required(\n trustchain?.getAppStream(context.input.appId).extract(),\n \"Missing application stream for ExtractEncryptionKey\",\n ),\n ),\n }),\n onError: { actions: \"assignErrorFromEvent\" },\n onDone: {\n actions: raiseAndAssign(({ event }) =>\n event.output.map((encryptionKey) => ({\n raise: \"success\",\n assign: { encryptionKey },\n })),\n ),\n },\n },\n },\n\n Success: { type: \"final\" },\n\n Error: { type: \"final\" },\n },\n\n output: ({ context }) =>\n context._internalState.chain((state) =>\n eitherSeqRecord({\n trustchainId: () =>\n required(\n state.trustchainId,\n \"Missing Trustchain ID in the output\",\n ),\n jwt: () => required(state.jwt, \"Missing JWT in the output\"),\n applicationPath: () =>\n required(\n state.trustchain\n ?.getAppStream(context.input.appId)\n .chain((stream) => stream.getPath())\n .extract(),\n \"Missing application path in the output\",\n ),\n encryptionKey: () =>\n required(\n state.encryptionKey,\n \"Missing encryption key in the output\",\n ),\n }),\n ),\n });\n }\n\n extractDependencies(internalApi: InternalApi) {\n const authentication = new AuthenticateTask();\n const encryptionKeyExtraction = new ExtractEncryptionKeyTask();\n\n return {\n deviceAuth: ({ input }: { input: AuthenticateWithDeviceDAInput }) =>\n authentication.run(\n input.lkrpDataSource,\n new SignChallengeWithDeviceTask(internalApi),\n ),\n\n getTrustchain: (args: {\n input: Either<\n AuthenticateDAError,\n {\n lkrpDataSource: LKRPDataSource;\n trustchainId: string;\n jwt: JWT;\n }\n >;\n }) =>\n EitherAsync.liftEither(args.input)\n .chain(({ lkrpDataSource, trustchainId, jwt }) =>\n lkrpDataSource.getTrustchainById(trustchainId, jwt),\n )\n .run(),\n\n extractEncryptionKey: async ({\n input,\n }: {\n input: {\n cryptoService: CryptoService;\n keypair: KeyPair;\n stream: Either<AuthenticateDAError, LKRPBlockStream>;\n };\n }) =>\n EitherAsync.liftEither(input.stream).chain((stream) =>\n encryptionKeyExtraction.run(\n input.cryptoService,\n input.keypair,\n stream,\n ),\n ),\n };\n }\n}\n"],
|
|
5
|
-
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,wCAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAOO,2CACPC,EAAsD,qBACtDC,EAA2C,kBAE3CC,EAMO,
|
|
4
|
+
"sourcesContent": ["import {\n type DeviceActionStateMachine,\n type InternalApi,\n OpenAppDeviceAction,\n type StateMachineTypes,\n UserInteractionRequired,\n XStateDeviceAction,\n} from \"@ledgerhq/device-management-kit\";\nimport { type Either, EitherAsync, Left, Right } from \"purify-ts\";\nimport { assign, fromPromise, setup } from \"xstate\";\n\nimport {\n type AuthenticateDAError,\n type AuthenticateDAIntermediateValue,\n type AuthenticateDAOutput,\n AuthenticateDAState,\n AuthenticateDAStep,\n} from \"@api/app-binder/AuthenticateDeviceActionTypes\";\nimport {\n LKRPMissingDataError,\n LKRPTrustchainNotReady,\n LKRPUnknownError,\n} from \"@api/app-binder/Errors\";\nimport { type JWT, type Keypair } from \"@api/index\";\nimport { AuthenticateTask } from \"@internal/app-binder/task/AuthenticateTask\";\nimport { ExtractEncryptionKeyTask } from \"@internal/app-binder/task/ExtractEncryptionKeyTask\";\nimport { SignChallengeWithDeviceTask } from \"@internal/app-binder/task/SignChallengeWithDeviceTask\";\nimport { type LKRPDataSource } from \"@internal/lkrp-datasource/data/LKRPDataSource\";\nimport { eitherSeqRecord } from \"@internal/utils/eitherSeqRecord\";\nimport { type LKRPBlockStream } from \"@internal/utils/LKRPBlockStream\";\nimport { required } from \"@internal/utils/required\";\n\nimport {\n type AuthenticateWithDeviceDAInput,\n type AuthenticateWithDeviceDAInternalState,\n} from \"./models/AuthenticateWithDeviceDeviceActionTypes\";\nimport { raiseAndAssign } from \"./utils/raiseAndAssign\";\nimport { AddToTrustchainDeviceAction } from \"./AddToTrustchainDeviceAction\";\n\nconst APP_NAME = \"Ledger Sync\";\n\nexport class AuthenticateWithDeviceDeviceAction extends XStateDeviceAction<\n AuthenticateDAOutput,\n AuthenticateWithDeviceDAInput,\n AuthenticateDAError,\n AuthenticateDAIntermediateValue,\n AuthenticateWithDeviceDAInternalState\n> {\n makeStateMachine(\n internalApi: InternalApi,\n ): DeviceActionStateMachine<\n AuthenticateDAOutput,\n AuthenticateWithDeviceDAInput,\n AuthenticateDAError,\n AuthenticateDAIntermediateValue,\n AuthenticateWithDeviceDAInternalState\n > {\n type types = StateMachineTypes<\n AuthenticateDAOutput,\n AuthenticateWithDeviceDAInput,\n AuthenticateDAError,\n AuthenticateDAIntermediateValue,\n AuthenticateWithDeviceDAInternalState\n >;\n\n const { deviceAuth, getTrustchain, extractEncryptionKey } =\n this.extractDependencies(internalApi);\n\n return setup({\n types: {\n input: {} as types[\"input\"],\n context: {} as types[\"context\"],\n output: {} as types[\"output\"],\n },\n\n actors: {\n openAppStateMachine: new OpenAppDeviceAction({\n input: { appName: APP_NAME },\n }).makeStateMachine(internalApi),\n\n deviceAuth: fromPromise(deviceAuth),\n\n getTrustchain: fromPromise(getTrustchain),\n\n addToTrustchainStateMachine: new AddToTrustchainDeviceAction({\n input: Left(\n new LKRPMissingDataError(\"Missing input for GetEncryptionKey\"),\n ),\n }).makeStateMachine(internalApi),\n\n extractEncryptionKey: fromPromise(extractEncryptionKey),\n },\n\n actions: {\n assignErrorFromEvent: raiseAndAssign(\n ({ event }) =>\n Left(\n new LKRPUnknownError(\n String((event as { error?: unknown }).error),\n ),\n ), // NOTE: it should never happen, the error is not typed anymore here\n ),\n },\n\n guards: {\n isTrustchainMember: ({ context }) =>\n context._internalState\n .toMaybe()\n .map(\n (state) =>\n state.wasAddedToTrustchain ||\n state.trustchain\n ?.getAppStream(context.input.appId)\n .mapOrDefault(\n (stream) =>\n stream.hasMember(context.input.keypair.pubKeyToHex()),\n false,\n ),\n )\n .extract() ?? false,\n },\n }).createMachine({\n /** @xstate-layout N4IgpgJg5mDOIC5QEECuAXAFmAduglgMYCG6YA6vlgCJgBuRYtDhYyhBA9jgHQDyAB1zIBAgMQRuYHvhx1OAa2mchOEQIDaABgC6iUAM6wq+bvpAAPRAEYAzADYeATgAcAFltuntrdYBMAfYANCAAnogA7G6OttYREU5aWgERyQC+aSFoWLgEJGSUNPSMzIzsXLyCwqJiYABOdZx1PAIANqQAZk0Atjwq1Zq65obGFeZWCNbWAKw80-Z+Xvb2ni5OEdPWIeEI9tN+PC720RtuyU52GVkY2HhEpBRUmKWsL2wcppWq6mKwqISsWCwbR6JAgEYmMxgia2FwRHhaCIuaxaLz7ZbTLTBMKIFwuA7JLTePwJVxRCJXEDZW55B6FZ7FV6M94VfjfGr1Rp1EHDIyQnDjRAOA7WPGYiLHaxOab47Y2GVaHheOKiiVOAIBSnU3L3ApPN5vcqfHiGm4SKQyOSKaQQZnUnlgiFjaGIeZuQ62Py+PxSrQucVyhASxyuNzRRKI3wrLU3HX5R5FFhMO0fbgmu1mzlNFrtdBdOq9W1J+1DR1852gCbTTE8WyuWFReyIhJbHG7CK2OaxPx4tz+bzTGM5O7x+kGlOs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ern1NsKIzjriOHvJGfZ1QZBQjgTgtp4BggJg-Hhis+FPl5FDFcABaVsOx5izGPhbUayJYiDjvjeL6IVkwdzZAMGxRtg4DQkuleIRJUTHB6kSbhfjsLGhfMEoOVYUSYxVPMBYPhOoST2EqJ2MphQXlgn4eJCt-H4N4JFXO7EUmFwmBcRwgFRQDQWE2ECh4j4FI2EiDwA0kYBW8cpD2mcqk8H+oDDaW1dp1BMclVJNgHDwmWDHWEb0PDqlyjQrEV8BrrD8E08pnsrHe3JqrWpsh6kyMmPEBypdrpiVcHsauSRoJxDWHYREMxJrDMJrgyxLIX6CJASIkhOAf7XKgdvO58jvAOD9M8g8bZpQEgKt5aIex-THLGac40ABlWcCUoVUNiJ2RYGx5gBD7E2CI91OwW2eohAI1YJo4qfnigh746gkt-AESSj1E5JAri4bs1dPS1l3EifYcJYI7n0WkIAA */\n\n id: \"AuthenticateWithDeviceDeviceAction\",\n context: ({ input }): types[\"context\"] => ({\n input,\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n _internalState: Right({\n trustchainId: null,\n jwt: null,\n trustchain: null,\n encryptionKey: null,\n wasAddedToTrustchain: false,\n }),\n }),\n\n initial: \"OpenApp\",\n states: {\n OpenApp: {\n on: { success: \"DeviceAuth\", error: \"Error\" },\n invoke: {\n id: \"openApp\",\n src: \"openAppStateMachine\",\n onSnapshot: {\n actions: assign({\n intermediateValue: ({ event }) => ({\n step: AuthenticateDAStep.OpenApp,\n ...event.snapshot.context.intermediateValue,\n }),\n }),\n },\n input: { appName: APP_NAME },\n onError: { actions: \"assignErrorFromEvent\" },\n onDone: {\n actions: raiseAndAssign(({ event }) =>\n event.output.map(() => ({ raise: \"success\" })),\n ),\n },\n },\n },\n\n DeviceAuth: {\n entry: assign({\n intermediateValue: {\n step: AuthenticateDAStep.Authenticate,\n requiredUserInteraction: AuthenticateDAState.Authenticate,\n },\n }),\n on: { success: \"GetTrustchain\", error: \"Error\" },\n invoke: {\n id: \"deviceAuth\",\n src: \"deviceAuth\",\n input: ({ context }) => context.input,\n onError: { actions: \"assignErrorFromEvent\" },\n onDone: {\n actions: raiseAndAssign(({ event }) =>\n event.output.chain((payload) =>\n payload.trustchainId.caseOf({\n Nothing: () => Left(new LKRPTrustchainNotReady()),\n Just: (trustchainId) =>\n Right({\n raise: \"success\",\n assign: { jwt: payload.jwt, trustchainId },\n }),\n }),\n ),\n ),\n },\n },\n },\n\n GetTrustchain: {\n entry: assign({\n intermediateValue: {\n step: AuthenticateDAStep.GetTrustchain,\n requiredUserInteraction: UserInteractionRequired.None,\n },\n }),\n on: { success: \"CheckIsMembers\", error: \"Error\" },\n invoke: {\n id: \"getTrustchain\",\n src: \"getTrustchain\",\n input: ({ context }) =>\n context._internalState.chain((state) =>\n eitherSeqRecord({\n lkrpDataSource: context.input.lkrpDataSource,\n trustchainId: () =>\n required(\n state.trustchainId,\n \"Missing Trustchain ID for GetTrustchain\",\n ),\n jwt: () =>\n required(state.jwt, \"Missing JWT for GetTrustchain\"),\n }),\n ),\n onError: { actions: \"assignErrorFromEvent\" },\n onDone: {\n actions: raiseAndAssign(({ event }) =>\n event.output.map((trustchain) => ({\n raise: \"success\",\n assign: { trustchain },\n })),\n ),\n },\n },\n },\n\n CheckIsMembers: {\n always: [\n { target: \"ExtractEncryptionKey\", guard: \"isTrustchainMember\" },\n { target: \"AddToTrustchain\" },\n ],\n },\n\n AddToTrustchain: {\n on: {\n success: \"GetTrustchain\",\n error: \"Error\",\n },\n invoke: {\n id: \"AddToTrustchain\",\n src: \"addToTrustchainStateMachine\",\n onSnapshot: {\n actions: assign({\n intermediateValue: ({ event }) =>\n event.snapshot.context.intermediateValue,\n }),\n },\n input: ({ context }) =>\n context._internalState\n .mapLeft(\n () =>\n new LKRPMissingDataError(\n \"Missing data in the input for AddToTrustchain\",\n ),\n )\n .chain((state) =>\n eitherSeqRecord({\n lkrpDataSource: context.input.lkrpDataSource,\n keypair: context.input.keypair,\n clientName: context.input.clientName,\n permissions: context.input.permissions,\n jwt: () =>\n required(state.jwt, \"Missing JWT for AddToTrustchain\"),\n appId: context.input.appId,\n trustchain: () =>\n required(\n state.trustchain,\n \"Missing Trustchain for AddToTrustchain\",\n ),\n }),\n ),\n onError: { actions: \"assignErrorFromEvent\" },\n onDone: {\n actions: raiseAndAssign(({ event }) =>\n event.output.map(() => ({\n raise: \"success\",\n assign: { wasAddedToTrustchain: true },\n })),\n ),\n },\n },\n },\n\n ExtractEncryptionKey: {\n entry: assign({\n intermediateValue: {\n step: AuthenticateDAStep.ExtractEncryptionKey,\n requiredUserInteraction: UserInteractionRequired.None,\n },\n }),\n on: { success: \"Success\", error: \"Error\" },\n invoke: {\n id: \"ExtractEncryptionKey\",\n src: \"extractEncryptionKey\",\n input: ({ context }) => ({\n keypair: context.input.keypair,\n stream: context._internalState.chain(({ trustchain }) =>\n required(\n trustchain?.getAppStream(context.input.appId).extract(),\n \"Missing application stream for ExtractEncryptionKey\",\n ),\n ),\n }),\n onError: { actions: \"assignErrorFromEvent\" },\n onDone: {\n actions: raiseAndAssign(({ event }) =>\n event.output.map((encryptionKey) => ({\n raise: \"success\",\n assign: { encryptionKey },\n })),\n ),\n },\n },\n },\n\n Success: { type: \"final\" },\n\n Error: { type: \"final\" },\n },\n\n output: ({ context }) =>\n context._internalState.chain((state) =>\n eitherSeqRecord({\n trustchainId: () =>\n required(\n state.trustchainId,\n \"Missing Trustchain ID in the output\",\n ),\n jwt: () => required(state.jwt, \"Missing JWT in the output\"),\n applicationPath: () =>\n required(\n state.trustchain\n ?.getAppStream(context.input.appId)\n .chain((stream) => stream.getPath())\n .extract(),\n \"Missing application path in the output\",\n ),\n encryptionKey: () =>\n required(\n state.encryptionKey,\n \"Missing encryption key in the output\",\n ),\n }),\n ),\n });\n }\n\n extractDependencies(internalApi: InternalApi) {\n const authentication = new AuthenticateTask();\n const encryptionKeyExtraction = new ExtractEncryptionKeyTask();\n\n return {\n deviceAuth: ({ input }: { input: AuthenticateWithDeviceDAInput }) =>\n authentication.run(\n input.lkrpDataSource,\n new SignChallengeWithDeviceTask(internalApi),\n ),\n\n getTrustchain: (args: {\n input: Either<\n AuthenticateDAError,\n {\n lkrpDataSource: LKRPDataSource;\n trustchainId: string;\n jwt: JWT;\n }\n >;\n }) =>\n EitherAsync.liftEither(args.input)\n .chain(({ lkrpDataSource, trustchainId, jwt }) =>\n lkrpDataSource.getTrustchainById(trustchainId, jwt),\n )\n .run(),\n\n extractEncryptionKey: async ({\n input,\n }: {\n input: {\n keypair: Keypair;\n stream: Either<AuthenticateDAError, LKRPBlockStream>;\n };\n }) =>\n EitherAsync.liftEither(input.stream).chain((stream) =>\n encryptionKeyExtraction.run(input.keypair, stream),\n ),\n };\n }\n}\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,wCAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAOO,2CACPC,EAAsD,qBACtDC,EAA2C,kBAE3CC,EAMO,yDACPC,EAIO,kCAEPC,EAAiC,sDACjCC,EAAyC,8DACzCC,EAA4C,iEAE5CC,EAAgC,2CAEhCC,EAAyB,oCAMzBC,EAA+B,kCAC/BC,EAA4C,yCAE5C,MAAMC,EAAW,cAEV,MAAMd,UAA2C,oBAMtD,CACA,iBACEe,EAOA,CASA,KAAM,CAAE,WAAAC,EAAY,cAAAC,EAAe,qBAAAC,CAAqB,EACtD,KAAK,oBAAoBH,CAAW,EAEtC,SAAO,SAAM,CACX,MAAO,CACL,MAAO,CAAC,EACR,QAAS,CAAC,EACV,OAAQ,CAAC,CACX,EAEA,OAAQ,CACN,oBAAqB,IAAI,sBAAoB,CAC3C,MAAO,CAAE,QAASD,CAAS,CAC7B,CAAC,EAAE,iBAAiBC,CAAW,EAE/B,cAAY,eAAYC,CAAU,EAElC,iBAAe,eAAYC,CAAa,EAExC,4BAA6B,IAAI,8BAA4B,CAC3D,SAAO,QACL,IAAI,uBAAqB,oCAAoC,CAC/D,CACF,CAAC,EAAE,iBAAiBF,CAA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,CACJ,CACF,CACF,CACF,EAEA,QAAS,CAAE,KAAM,OAAQ,EAEzB,MAAO,CAAE,KAAM,OAAQ,CACzB,EAEA,OAAQ,CAAC,CAAE,QAAAP,CAAQ,IACjBA,EAAQ,eAAe,MAAOC,MAC5B,mBAAgB,CACd,aAAc,OACZ,YACEA,EAAM,aACN,qCACF,EACF,IAAK,OAAM,YAASA,EAAM,IAAK,2BAA2B,EAC1D,gBAAiB,OACf,YACEA,EAAM,YACF,aAAaD,EAAQ,MAAM,KAAK,EACjC,MAAOE,GAAWA,EAAO,QAAQ,CAAC,EAClC,QAAQ,EACX,wCACF,EACF,cAAe,OACb,YACED,EAAM,cACN,sCACF,CACJ,CAAC,CACH,CACJ,CAAC,CACH,CAEA,oBAAoBN,EAA0B,CAC5C,MAAMa,EAAiB,IAAI,mBACrBC,EAA0B,IAAI,2BAEpC,MAAO,CACL,WAAY,CAAC,CAAE,MAAAN,CAAM,IACnBK,EAAe,IACbL,EAAM,eACN,IAAI,8BAA4BR,CAAW,CAC7C,EAEF,cAAgBe,GAUd,cAAY,WAAWA,EAAK,KAAK,EAC9B,MAAM,CAAC,CAAE,eAAAC,EAAgB,aAAAN,EAAc,IAAAO,CAAI,IAC1CD,EAAe,kBAAkBN,EAAcO,CAAG,CACpD,EACC,IAAI,EAET,qBAAsB,MAAO,CAC3B,MAAAT,CACF,IAME,cAAY,WAAWA,EAAM,MAAM,EAAE,MAAOD,GAC1CO,EAAwB,IAAIN,EAAM,QAASD,CAAM,CACnD,CACJ,CACF,CACF",
|
|
6
6
|
"names": ["AuthenticateWithDeviceDeviceAction_exports", "__export", "AuthenticateWithDeviceDeviceAction", "__toCommonJS", "import_device_management_kit", "import_purify_ts", "import_xstate", "import_AuthenticateDeviceActionTypes", "import_Errors", "import_AuthenticateTask", "import_ExtractEncryptionKeyTask", "import_SignChallengeWithDeviceTask", "import_eitherSeqRecord", "import_required", "import_raiseAndAssign", "import_AddToTrustchainDeviceAction", "APP_NAME", "internalApi", "deviceAuth", "getTrustchain", "extractEncryptionKey", "event", "context", "state", "stream", "input", "payload", "trustchainId", "trustchain", "encryptionKey", "authentication", "encryptionKeyExtraction", "args", "lkrpDataSource", "jwt"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var m=Object.defineProperty;var
|
|
1
|
+
"use strict";var m=Object.defineProperty;var d=Object.getOwnPropertyDescriptor;var S=Object.getOwnPropertyNames;var I=Object.prototype.hasOwnProperty;var g=(a,e)=>{for(var c in e)m(a,c,{get:e[c],enumerable:!0})},k=(a,e,c,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of S(e))!I.call(a,t)&&t!==c&&m(a,t,{get:()=>e[t],enumerable:!(r=d(e,t))||r.enumerable});return a};var f=a=>k(m({},"__esModule",{value:!0}),a);var x={};g(x,{AuthenticateWithKeypairDeviceAction:()=>T});module.exports=f(x);var o=require("@ledgerhq/device-management-kit"),p=require("purify-ts"),n=require("xstate"),A=require("../../../api/app-binder/AuthenticateDeviceActionTypes"),h=require("../../../api/app-binder/Errors"),E=require("../../app-binder/task/AuthenticateTask"),D=require("../../app-binder/task/ExtractEncryptionKeyTask"),l=require("../../app-binder/task/SignChallengeWithKeypairTask"),K=require("../../utils/eitherSeqRecord"),s=require("../../utils/required"),y=require("./utils/raiseAndAssign");class T extends o.XStateDeviceAction{execute(){const e=this.makeStateMachine();return this._subscribeToStateMachine(e)}makeStateMachine(){const{keypairAuth:e,getTrustchain:c,extractEncryptionKey:r}=this.extractDependencies();return(0,n.setup)({types:{input:{},context:{},output:{}},actors:{keypairAuth:(0,n.fromPromise)(e),getTrustchain:(0,n.fromPromise)(c),extractEncryptionKey:(0,n.fromPromise)(r)},actions:{assignErrorFromEvent:(0,y.raiseAndAssign)(({event:t})=>(0,p.Left)(new h.LKRPUnknownError(String(t.error))))}}).createMachine({id:"AuthenticateWithKeypairDeviceAction",context:({input:t})=>({input:t,intermediateValue:{requiredUserInteraction:o.UserInteractionRequired.None},_internalState:(0,p.Right)({jwt:null,trustchain:null,encryptionKey:null})}),initial:"KeypairAuth",states:{KeypairAuth:{entry:(0,n.assign)({intermediateValue:{requiredUserInteraction:o.UserInteractionRequired.None,step:A.AuthenticateDAStep.Authenticate}}),on:{success:"GetTrustchain",error:"Error"},invoke:{id:"keypairAuth",src:"keypairAuth",input:({context:t})=>t.input,onError:{actions:"assignErrorFromEvent"},onDone:{actions:(0,y.raiseAndAssign)(({context:t,event:i})=>i.output.map(({jwt:u})=>({raise:"success",assign:{jwt:u}})).mapLeft(u=>u instanceof h.LKRPDataSourceError&&u.status==="UNAUTHORIZED"?new h.LKRPUnauthorizedError(t.input.trustchainId):u))}}},GetTrustchain:{entry:(0,n.assign)({intermediateValue:{requiredUserInteraction:o.UserInteractionRequired.None,step:A.AuthenticateDAStep.GetTrustchain}}),on:{success:"ExtractEncryptionKey",error:"Error"},invoke:{id:"getTrustchain",src:"getTrustchain",input:({context:t})=>({lkrpDataSource:t.input.lkrpDataSource,trustchainId:t.input.trustchainId,jwt:t._internalState.chain(({jwt:i})=>(0,s.required)(i,"Missing JWT for GetTrustchain"))}),onError:{actions:"assignErrorFromEvent"},onDone:{actions:(0,y.raiseAndAssign)(({event:t})=>t.output.map(i=>({raise:"success",assign:{trustchain:i}})))}}},ExtractEncryptionKey:{entry:(0,n.assign)({intermediateValue:{requiredUserInteraction:o.UserInteractionRequired.None,step:A.AuthenticateDAStep.ExtractEncryptionKey}}),on:{success:"Success",error:"Error"},invoke:{id:"ExtractEncryptionKey",src:"extractEncryptionKey",input:({context:t})=>({keypair:t.input.keypair,stream:t._internalState.chain(({trustchain:i})=>(0,s.required)(i?.getAppStream(t.input.appId).extract(),"Missing application stream for ExtractEncryptionKey"))}),onError:{actions:"assignErrorFromEvent"},onDone:{actions:(0,y.raiseAndAssign)(({event:t})=>t.output.map(i=>({raise:"success",assign:{encryptionKey:i}})))}}},Success:{type:"final"},Error:{type:"final"}},output:({context:t})=>t._internalState.chain(i=>(0,K.eitherSeqRecord)({trustchainId:t.input.trustchainId,jwt:()=>(0,s.required)(i.jwt,"Missing JWT in the output"),applicationPath:()=>(0,s.required)(i.trustchain?.getAppStream(t.input.appId).chain(u=>u.getPath()).extract(),"Missing application path in the output"),encryptionKey:()=>(0,s.required)(i.encryptionKey,"Missing encryption key in the output")}))})}extractDependencies(){const e=new E.AuthenticateTask,c=new D.ExtractEncryptionKeyTask;return{keypairAuth:({input:r})=>e.run(r.lkrpDataSource,new l.SignChallengeWithKeypairTask(r.keypair,r.trustchainId)),getTrustchain:({input:r})=>p.EitherAsync.liftEither(r.jwt).chain(t=>r.lkrpDataSource.getTrustchainById(r.trustchainId,t)).run(),extractEncryptionKey:async({input:r})=>p.EitherAsync.liftEither(r.stream).chain(t=>c.run(r.keypair,t))}}}0&&(module.exports={AuthenticateWithKeypairDeviceAction});
|
|
2
2
|
//# sourceMappingURL=AuthenticateWithKeypairDeviceAction.js.map
|
package/lib/cjs/internal/app-binder/device-action/AuthenticateWithKeypairDeviceAction.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/internal/app-binder/device-action/AuthenticateWithKeypairDeviceAction.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n type DeviceActionStateMachine,\n type ExecuteDeviceActionReturnType,\n type StateMachineTypes,\n UserInteractionRequired,\n XStateDeviceAction,\n} from \"@ledgerhq/device-management-kit\";\nimport { type Either, EitherAsync, Left, Right } from \"purify-ts\";\nimport { assign, fromPromise, setup } from \"xstate\";\n\nimport {\n type AuthenticateDAError,\n type AuthenticateDAIntermediateValue,\n type AuthenticateDAOutput,\n AuthenticateDAStep,\n} from \"@api/app-binder/AuthenticateDeviceActionTypes\";\nimport { type CryptoService } from \"@api/crypto/CryptoService\";\nimport { type KeyPair } from \"@api/crypto/KeyPair\";\nimport {\n LKRPDataSourceError,\n LKRPUnauthorizedError,\n LKRPUnknownError,\n} from \"@api/model/Errors\";\nimport { type JWT } from \"@api/model/JWT\";\nimport { AuthenticateTask } from \"@internal/app-binder/task/AuthenticateTask\";\nimport { ExtractEncryptionKeyTask } from \"@internal/app-binder/task/ExtractEncryptionKeyTask\";\nimport { SignChallengeWithKeypairTask } from \"@internal/app-binder/task/SignChallengeWithKeypairTask\";\nimport { type LKRPDataSource } from \"@internal/lkrp-datasource/data/LKRPDataSource\";\nimport { eitherSeqRecord } from \"@internal/utils/eitherSeqRecord\";\nimport { type LKRPBlockStream } from \"@internal/utils/LKRPBlockStream\";\nimport { required } from \"@internal/utils/required\";\n\nimport {\n type AuthenticateWithKeypairDAInput,\n type AuthenticateWithKeypairDAInternalState,\n} from \"./models/AuthenticateWithKeypairDeviceActionTypes\";\nimport { raiseAndAssign } from \"./utils/raiseAndAssign\";\n\nexport class AuthenticateWithKeypairDeviceAction extends XStateDeviceAction<\n AuthenticateDAOutput,\n AuthenticateWithKeypairDAInput,\n AuthenticateDAError,\n AuthenticateDAIntermediateValue,\n AuthenticateWithKeypairDAInternalState\n> {\n execute(): ExecuteDeviceActionReturnType<\n AuthenticateDAOutput,\n AuthenticateDAError,\n AuthenticateDAIntermediateValue\n > {\n const stateMachine = this.makeStateMachine();\n return this._subscribeToStateMachine(stateMachine);\n }\n\n makeStateMachine(): DeviceActionStateMachine<\n AuthenticateDAOutput,\n AuthenticateWithKeypairDAInput,\n AuthenticateDAError,\n AuthenticateDAIntermediateValue,\n AuthenticateWithKeypairDAInternalState\n > {\n type types = StateMachineTypes<\n AuthenticateDAOutput,\n AuthenticateWithKeypairDAInput,\n AuthenticateDAError,\n AuthenticateDAIntermediateValue,\n AuthenticateWithKeypairDAInternalState\n >;\n\n const { keypairAuth, getTrustchain, extractEncryptionKey } =\n this.extractDependencies();\n\n return setup({\n types: {\n input: {} as types[\"input\"],\n context: {} as types[\"context\"],\n output: {} as types[\"output\"],\n },\n\n actors: {\n keypairAuth: fromPromise(keypairAuth),\n getTrustchain: fromPromise(getTrustchain),\n extractEncryptionKey: fromPromise(extractEncryptionKey),\n },\n\n actions: {\n assignErrorFromEvent: raiseAndAssign(\n ({ event }) =>\n Left(\n new LKRPUnknownError(\n String((event as { error?: unknown }).error),\n ),\n ), // NOTE: it should never happen, the error is not typed anymore here\n ),\n },\n }).createMachine({\n /** @xstate-layout N4IgpgJg5mDOIC5QEECuAXAFmAduglgMYCG6YA6vlgNJgCeADsfgE4AiYAbkWMoQQHscAOlqNmLNFgDEEIWGH4cnAQGsF68aymYA2gAYAuolAMBsKviEmQAD0QBGfQFZhADgDMAdgBMXh24AbG7Ozl4ePgA0IHSOnsI+PoEuzg4ALACcGT4BAL650Tq4BCRklDT0TKwc3IS8-FYiYlWSGJjSYCwsAizCDAA2pABmPQC2wpotOgbGSCBmFoI4NvYI2cLJbj4eAZnpgWlRMYhBwofByV6BHmke2V75hW3FRKQUVJjNEjU8fEuilQkOmksFQhDqsFgMxsC0s1jmqxubg2IT8XmcGQxaQcDkC0ViCA8+g8wgcXi89y8+jcGWCPjSjxARTwrzKHy+1S4vwaQgBWlaMk63RY0LmsKWK0QSJRzjRGKxOLxxwQgVxwkxGSJaWcHhuHmcDIKTOeLNK7wq-J+dT+jWEAHEwOgACosVCwdCETDMHCyeSKZRqBQwZ2u92e72i0zmOHLBGIA36YTeDG0hx+BzOQJHAm7YQuTVZfTorxpTJuRnMkpvcqfQGc2r1f4OkNuj1epQdLo9PqDdAjFjjYMu1vhpSR+bRiVxhA6kn6HEZ0vOfQXfEnLwJZI+fRpYLZLPaismqtsi0tK2N23N4dh9s+0HguBQowwyeNSUINz6RPhTXakJpG4JZroSO55jiSROIcRIZkeWAvGaNYcuwXLWjyIjXqGbbep2wrjuK77Tl+P53DczgAUBaQgZkrjYiEZLXJikFwdgprVuydYoQ2Nq8gAorY6AsMQ-C8TghAsIwSxiL6OAKEoKjqMI-GCcJ6CieJkmNGI+FvvCoCrE4TjCKEGSZNutKeJ4IFksiPhZIksqpIqO4sQh7Fnt8qGXnxAlCSJYkSQwUn0Lh3YDMMYxKb5qnqYFwV0DpiyEfpjjzg4CQGjStypG4pZeCBbjpcu35EkEu66rKrlsaetaWl5PEiMpflqQFmlCNJD4Qs+sxRklel2I4uoZBlATeHZma6iBWruEupnJtcgEPEalasuatXnvV6FRSp-kaUFWkhUKPSJTGH4OENI2eL4mLXB4U2ZuqkHBLiZH6s4+RGjgAgQHANgrYhHF1dx6Gvn1sYpQgAC0DggZDrhZAjiNIx4VUnmtyEXg1fJTG0oOndOaT5cqPghHmPiyjRHgHDuKPLceq1IZxmNbZhI53njU4Q4TrjomSVymdi5UgSTrghCEf5Zok6K0088HVejTObf8TUxa1+3tfQHPJQNax+O4Li5bKxJFtkwtfnmGS5Q4tLJpbYSowzgMbcD-wAMpgl1Wv9QZu6BEmo1UwcHiWdmUpgTTOS0vompkjLxpy2jjNA9yytdiwXvgzr+x+zsniB7cIfUaZGxkmSu7LoEXhfkt+RAA */\n\n id: \"AuthenticateWithKeypairDeviceAction\",\n context: ({ input }): types[\"context\"] => ({\n input,\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n _internalState: Right({\n jwt: null,\n trustchain: null,\n encryptionKey: null,\n }),\n }),\n\n initial: \"KeypairAuth\",\n states: {\n KeypairAuth: {\n entry: assign({\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: AuthenticateDAStep.Authenticate,\n },\n }),\n on: { success: \"GetTrustchain\", error: \"Error\" },\n invoke: {\n id: \"keypairAuth\",\n src: \"keypairAuth\",\n input: ({ context }) => context.input,\n onError: { actions: \"assignErrorFromEvent\" },\n onDone: {\n actions: raiseAndAssign(({ context, event }) =>\n event.output\n .map(({ jwt }) => ({ raise: \"success\", assign: { jwt } }))\n .mapLeft((error) =>\n error instanceof LKRPDataSourceError &&\n error.status === \"UNAUTHORIZED\"\n ? new LKRPUnauthorizedError(context.input.trustchainId)\n : error,\n ),\n ),\n },\n },\n },\n\n GetTrustchain: {\n entry: assign({\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: AuthenticateDAStep.GetTrustchain,\n },\n }),\n on: { success: \"ExtractEncryptionKey\", error: \"Error\" },\n invoke: {\n id: \"getTrustchain\",\n src: \"getTrustchain\",\n input: ({ context }) => ({\n lkrpDataSource: context.input.lkrpDataSource,\n trustchainId: context.input.trustchainId,\n jwt: context._internalState.chain(({ jwt }) =>\n required(jwt, \"Missing JWT for GetTrustchain\"),\n ),\n }),\n onError: { actions: \"assignErrorFromEvent\" },\n onDone: {\n actions: raiseAndAssign(({ event }) =>\n event.output.map((trustchain) => ({\n raise: \"success\",\n assign: { trustchain },\n })),\n ),\n },\n },\n },\n\n ExtractEncryptionKey: {\n entry: assign({\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: AuthenticateDAStep.ExtractEncryptionKey,\n },\n }),\n on: { success: \"Success\", error: \"Error\" },\n invoke: {\n id: \"ExtractEncryptionKey\",\n src: \"extractEncryptionKey\",\n input: ({ context }) => ({\n cryptoService: context.input.cryptoService,\n keypair: context.input.keypair,\n stream: context._internalState.chain(({ trustchain }) =>\n required(\n trustchain?.getAppStream(context.input.appId).extract(),\n \"Missing application stream for ExtractEncryptionKey\",\n ),\n ),\n }),\n onError: { actions: \"assignErrorFromEvent\" },\n onDone: {\n actions: raiseAndAssign(({ event }) =>\n event.output.map((encryptionKey) => ({\n raise: \"success\",\n assign: { encryptionKey },\n })),\n ),\n },\n },\n },\n\n Success: { type: \"final\" },\n\n Error: { type: \"final\" },\n },\n\n output: ({ context }) =>\n context._internalState.chain((state) =>\n eitherSeqRecord({\n trustchainId: context.input.trustchainId,\n jwt: () => required(state.jwt, \"Missing JWT in the output\"),\n applicationPath: () =>\n required(\n state.trustchain\n ?.getAppStream(context.input.appId)\n .chain((stream) => stream.getPath())\n .extract(),\n \"Missing application path in the output\",\n ),\n encryptionKey: () =>\n required(\n state.encryptionKey,\n \"Missing encryption key in the output\",\n ),\n }),\n ),\n });\n }\n\n extractDependencies() {\n const authentication = new AuthenticateTask();\n const encryptionKeyExtraction = new ExtractEncryptionKeyTask();\n\n return {\n keypairAuth: ({ input }: { input: AuthenticateWithKeypairDAInput }) =>\n authentication.run(\n input.lkrpDataSource,\n new SignChallengeWithKeypairTask(\n input.cryptoService,\n input.keypair,\n input.trustchainId,\n ),\n ),\n\n getTrustchain: ({\n input,\n }: {\n input: {\n lkrpDataSource: LKRPDataSource;\n trustchainId: string;\n jwt: Either<AuthenticateDAError, JWT>;\n };\n }) =>\n EitherAsync.liftEither(input.jwt)\n .chain((jwt) =>\n input.lkrpDataSource.getTrustchainById(input.trustchainId, jwt),\n )\n .run(),\n\n extractEncryptionKey: async ({\n input,\n }: {\n input: {\n cryptoService: CryptoService;\n keypair: KeyPair;\n stream: Either<AuthenticateDAError, LKRPBlockStream>;\n };\n }) =>\n EitherAsync.liftEither(input.stream).chain((stream) =>\n encryptionKeyExtraction.run(\n input.cryptoService,\n input.keypair,\n stream,\n ),\n ),\n };\n }\n}\n"],
|
|
5
|
-
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,yCAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAMO,2CACPC,EAAsD,qBACtDC,EAA2C,kBAE3CC,EAKO,
|
|
4
|
+
"sourcesContent": ["import {\n type DeviceActionStateMachine,\n type ExecuteDeviceActionReturnType,\n type StateMachineTypes,\n UserInteractionRequired,\n XStateDeviceAction,\n} from \"@ledgerhq/device-management-kit\";\nimport { type Either, EitherAsync, Left, Right } from \"purify-ts\";\nimport { assign, fromPromise, setup } from \"xstate\";\n\nimport {\n type AuthenticateDAError,\n type AuthenticateDAIntermediateValue,\n type AuthenticateDAOutput,\n AuthenticateDAStep,\n} from \"@api/app-binder/AuthenticateDeviceActionTypes\";\nimport {\n LKRPDataSourceError,\n LKRPUnauthorizedError,\n LKRPUnknownError,\n} from \"@api/app-binder/Errors\";\nimport { type JWT, type Keypair } from \"@api/index\";\nimport { AuthenticateTask } from \"@internal/app-binder/task/AuthenticateTask\";\nimport { ExtractEncryptionKeyTask } from \"@internal/app-binder/task/ExtractEncryptionKeyTask\";\nimport { SignChallengeWithKeypairTask } from \"@internal/app-binder/task/SignChallengeWithKeypairTask\";\nimport { type LKRPDataSource } from \"@internal/lkrp-datasource/data/LKRPDataSource\";\nimport { eitherSeqRecord } from \"@internal/utils/eitherSeqRecord\";\nimport { type LKRPBlockStream } from \"@internal/utils/LKRPBlockStream\";\nimport { required } from \"@internal/utils/required\";\n\nimport {\n type AuthenticateWithKeypairDAInput,\n type AuthenticateWithKeypairDAInternalState,\n} from \"./models/AuthenticateWithKeypairDeviceActionTypes\";\nimport { raiseAndAssign } from \"./utils/raiseAndAssign\";\n\nexport class AuthenticateWithKeypairDeviceAction extends XStateDeviceAction<\n AuthenticateDAOutput,\n AuthenticateWithKeypairDAInput,\n AuthenticateDAError,\n AuthenticateDAIntermediateValue,\n AuthenticateWithKeypairDAInternalState\n> {\n execute(): ExecuteDeviceActionReturnType<\n AuthenticateDAOutput,\n AuthenticateDAError,\n AuthenticateDAIntermediateValue\n > {\n const stateMachine = this.makeStateMachine();\n return this._subscribeToStateMachine(stateMachine);\n }\n\n makeStateMachine(): DeviceActionStateMachine<\n AuthenticateDAOutput,\n AuthenticateWithKeypairDAInput,\n AuthenticateDAError,\n AuthenticateDAIntermediateValue,\n AuthenticateWithKeypairDAInternalState\n > {\n type types = StateMachineTypes<\n AuthenticateDAOutput,\n AuthenticateWithKeypairDAInput,\n AuthenticateDAError,\n AuthenticateDAIntermediateValue,\n AuthenticateWithKeypairDAInternalState\n >;\n\n const { keypairAuth, getTrustchain, extractEncryptionKey } =\n this.extractDependencies();\n\n return setup({\n types: {\n input: {} as types[\"input\"],\n context: {} as types[\"context\"],\n output: {} as types[\"output\"],\n },\n\n actors: {\n keypairAuth: fromPromise(keypairAuth),\n getTrustchain: fromPromise(getTrustchain),\n extractEncryptionKey: fromPromise(extractEncryptionKey),\n },\n\n actions: {\n assignErrorFromEvent: raiseAndAssign(\n ({ event }) =>\n Left(\n new LKRPUnknownError(\n String((event as { error?: unknown }).error),\n ),\n ), // NOTE: it should never happen, the error is not typed anymore here\n ),\n },\n }).createMachine({\n /** @xstate-layout N4IgpgJg5mDOIC5QEECuAXAFmAduglgMYCG6YA6vlgNJgCeADsfgE4AiYAbkWMoQQHscAOlqNmLNFgDEEIWGH4cnAQGsF68aymYA2gAYAuolAMBsKviEmQAD0QBGfQFZhADgDMAdgBMXh24AbG7Ozl4ePgA0IHSOnsI+PoEuzg4ALACcGT4BAL650Tq4BCRklDT0TKwc3IS8-FYiYlWSGJjSYCwsAizCDAA2pABmPQC2wpotOgbGSCBmFoI4NvYI2cLJbj4eAZnpgWlRMYhBwofByV6BHmke2V75hW3FRKQUVJjNEjU8fEuilQkOmksFQhDqsFgMxsC0s1jmqxubg2IT8XmcGQxaQcDkC0ViCA8+g8wgcXi89y8+jcGWCPjSjxARTwrzKHy+1S4vwaQgBWlaMk63RY0LmsKWK0QSJRzjRGKxOLxxwQgVxwkxGSJaWcHhuHmcDIKTOeLNK7wq-J+dT+jWEAHEwOgACosVCwdCETDMHCyeSKZRqBQwZ2u92e72i0zmOHLBGIA36YTeDG0hx+BzOQJHAm7YQuTVZfTorxpTJuRnMkpvcqfQGc2r1f4OkNuj1epQdLo9PqDdAjFjjYMu1vhpSR+bRiVxhA6kn6HEZ0vOfQXfEnLwJZI+fRpYLZLPaismqtsi0tK2N23N4dh9s+0HguBQowwyeNSUINz6RPhTXakJpG4JZroSO55jiSROIcRIZkeWAvGaNYcuwXLWjyIjXqGbbep2wrjuK77Tl+P53DczgAUBaQgZkrjYiEZLXJikFwdgprVuydYoQ2Nq8gAorY6AsMQ-C8TghAsIwSxiL6OAKEoKjqMI-GCcJ6CieJkmNGI+FvvCoCrE4TjCKEGSZNutKeJ4IFksiPhZIksqpIqO4sQh7Fnt8qGXnxAlCSJYkSQwUn0Lh3YDMMYxKb5qnqYFwV0DpiyEfpjjzg4CQGjStypG4pZeCBbjpcu35EkEu66rKrlsaetaWl5PEiMpflqQFmlCNJD4Qs+sxRklel2I4uoZBlATeHZma6iBWruEupnJtcgEPEalasuatXnvV6FRSp-kaUFWkhUKPSJTGH4OENI2eL4mLXB4U2ZuqkHBLiZH6s4+RGjgAgQHANgrYhHF1dx6Gvn1sYpQgAC0DggZDrhZAjiNIx4VUnmtyEXg1fJTG0oOndOaT5cqPghHmPiyjRHgHDuKPLceq1IZxmNbZhI53njU4Q4TrjomSVymdi5UgSTrghCEf5Zok6K0088HVejTObf8TUxa1+3tfQHPJQNax+O4Li5bKxJFtkwtfnmGS5Q4tLJpbYSowzgMbcD-wAMpgl1Wv9QZu6BEmo1UwcHiWdmUpgTTOS0vompkjLxpy2jjNA9yytdiwXvgzr+x+zsniB7cIfUaZGxkmSu7LoEXhfkt+RAA */\n\n id: \"AuthenticateWithKeypairDeviceAction\",\n context: ({ input }): types[\"context\"] => ({\n input,\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n _internalState: Right({\n jwt: null,\n trustchain: null,\n encryptionKey: null,\n }),\n }),\n\n initial: \"KeypairAuth\",\n states: {\n KeypairAuth: {\n entry: assign({\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: AuthenticateDAStep.Authenticate,\n },\n }),\n on: { success: \"GetTrustchain\", error: \"Error\" },\n invoke: {\n id: \"keypairAuth\",\n src: \"keypairAuth\",\n input: ({ context }) => context.input,\n onError: { actions: \"assignErrorFromEvent\" },\n onDone: {\n actions: raiseAndAssign(({ context, event }) =>\n event.output\n .map(({ jwt }) => ({ raise: \"success\", assign: { jwt } }))\n .mapLeft((error) =>\n error instanceof LKRPDataSourceError &&\n error.status === \"UNAUTHORIZED\"\n ? new LKRPUnauthorizedError(context.input.trustchainId)\n : error,\n ),\n ),\n },\n },\n },\n\n GetTrustchain: {\n entry: assign({\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: AuthenticateDAStep.GetTrustchain,\n },\n }),\n on: { success: \"ExtractEncryptionKey\", error: \"Error\" },\n invoke: {\n id: \"getTrustchain\",\n src: \"getTrustchain\",\n input: ({ context }) => ({\n lkrpDataSource: context.input.lkrpDataSource,\n trustchainId: context.input.trustchainId,\n jwt: context._internalState.chain(({ jwt }) =>\n required(jwt, \"Missing JWT for GetTrustchain\"),\n ),\n }),\n onError: { actions: \"assignErrorFromEvent\" },\n onDone: {\n actions: raiseAndAssign(({ event }) =>\n event.output.map((trustchain) => ({\n raise: \"success\",\n assign: { trustchain },\n })),\n ),\n },\n },\n },\n\n ExtractEncryptionKey: {\n entry: assign({\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: AuthenticateDAStep.ExtractEncryptionKey,\n },\n }),\n on: { success: \"Success\", error: \"Error\" },\n invoke: {\n id: \"ExtractEncryptionKey\",\n src: \"extractEncryptionKey\",\n input: ({ context }) => ({\n keypair: context.input.keypair,\n stream: context._internalState.chain(({ trustchain }) =>\n required(\n trustchain?.getAppStream(context.input.appId).extract(),\n \"Missing application stream for ExtractEncryptionKey\",\n ),\n ),\n }),\n onError: { actions: \"assignErrorFromEvent\" },\n onDone: {\n actions: raiseAndAssign(({ event }) =>\n event.output.map((encryptionKey) => ({\n raise: \"success\",\n assign: { encryptionKey },\n })),\n ),\n },\n },\n },\n\n Success: { type: \"final\" },\n\n Error: { type: \"final\" },\n },\n\n output: ({ context }) =>\n context._internalState.chain((state) =>\n eitherSeqRecord({\n trustchainId: context.input.trustchainId,\n jwt: () => required(state.jwt, \"Missing JWT in the output\"),\n applicationPath: () =>\n required(\n state.trustchain\n ?.getAppStream(context.input.appId)\n .chain((stream) => stream.getPath())\n .extract(),\n \"Missing application path in the output\",\n ),\n encryptionKey: () =>\n required(\n state.encryptionKey,\n \"Missing encryption key in the output\",\n ),\n }),\n ),\n });\n }\n\n extractDependencies() {\n const authentication = new AuthenticateTask();\n const encryptionKeyExtraction = new ExtractEncryptionKeyTask();\n\n return {\n keypairAuth: ({ input }: { input: AuthenticateWithKeypairDAInput }) =>\n authentication.run(\n input.lkrpDataSource,\n new SignChallengeWithKeypairTask(input.keypair, input.trustchainId),\n ),\n\n getTrustchain: ({\n input,\n }: {\n input: {\n lkrpDataSource: LKRPDataSource;\n trustchainId: string;\n jwt: Either<AuthenticateDAError, JWT>;\n };\n }) =>\n EitherAsync.liftEither(input.jwt)\n .chain((jwt) =>\n input.lkrpDataSource.getTrustchainById(input.trustchainId, jwt),\n )\n .run(),\n\n extractEncryptionKey: async ({\n input,\n }: {\n input: {\n keypair: Keypair;\n stream: Either<AuthenticateDAError, LKRPBlockStream>;\n };\n }) =>\n EitherAsync.liftEither(input.stream).chain((stream) =>\n encryptionKeyExtraction.run(input.keypair, stream),\n ),\n };\n }\n}\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,yCAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAMO,2CACPC,EAAsD,qBACtDC,EAA2C,kBAE3CC,EAKO,yDACPC,EAIO,kCAEPC,EAAiC,sDACjCC,EAAyC,8DACzCC,EAA6C,kEAE7CC,EAAgC,2CAEhCC,EAAyB,oCAMzBC,EAA+B,kCAExB,MAAMZ,UAA4C,oBAMvD,CACA,SAIE,CACA,MAAMa,EAAe,KAAK,iBAAiB,EAC3C,OAAO,KAAK,yBAAyBA,CAAY,CACnD,CAEA,kBAME,CASA,KAAM,CAAE,YAAAC,EAAa,cAAAC,EAAe,qBAAAC,CAAqB,EACvD,KAAK,oBAAoB,EAE3B,SAAO,SAAM,CACX,MAAO,CACL,MAAO,CAAC,EACR,QAAS,CAAC,EACV,OAAQ,CAAC,CACX,EAEA,OAAQ,CACN,eAAa,eAAYF,CAAW,EACpC,iBAAe,eAAYC,CAAa,EACxC,wBAAsB,eAAYC,CAAoB,CACxD,EAEA,QAAS,CACP,wBAAsB,kBACpB,CAAC,CAAE,MAAAC,CAAM,OACP,QACE,IAAI,mBACF,OAAQA,EAA8B,KAAK,CAC7C,CACF,CACJ,CACF,CACF,CAAC,EAAE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,CACL,YAAa,CAAC,CAAE,MAAAT,CAAM,IACpBQ,EAAe,IACbR,EAAM,eACN,IAAI,+BAA6BA,EAAM,QAASA,EAAM,YAAY,CACpE,EAEF,cAAe,CAAC,CACd,MAAAA,CACF,IAOE,cAAY,WAAWA,EAAM,GAAG,EAC7B,MAAOE,GACNF,EAAM,eAAe,kBAAkBA,EAAM,aAAcE,CAAG,CAChE,EACC,IAAI,EAET,qBAAsB,MAAO,CAC3B,MAAAF,CACF,IAME,cAAY,WAAWA,EAAM,MAAM,EAAE,MAAOO,GAC1CE,EAAwB,IAAIT,EAAM,QAASO,CAAM,CACnD,CACJ,CACF,CACF",
|
|
6
6
|
"names": ["AuthenticateWithKeypairDeviceAction_exports", "__export", "AuthenticateWithKeypairDeviceAction", "__toCommonJS", "import_device_management_kit", "import_purify_ts", "import_xstate", "import_AuthenticateDeviceActionTypes", "import_Errors", "import_AuthenticateTask", "import_ExtractEncryptionKeyTask", "import_SignChallengeWithKeypairTask", "import_eitherSeqRecord", "import_required", "import_raiseAndAssign", "stateMachine", "keypairAuth", "getTrustchain", "extractEncryptionKey", "event", "input", "context", "jwt", "error", "trustchain", "encryptionKey", "state", "stream", "authentication", "encryptionKeyExtraction"]
|
|
7
7
|
}
|
package/lib/cjs/internal/app-binder/device-action/models/AuthenticateWithDeviceDeviceActionTypes.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var a=Object.defineProperty;var o=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var p=Object.prototype.hasOwnProperty;var l=(t,e,i,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of y(e))!p.call(t,r)&&r!==i&&a(t,r,{get:()=>e[r],enumerable:!(n=o(e,r))||n.enumerable});return t};var u=t=>l(a({},"__esModule",{value:!0}),t);var s={};module.exports=u(s);
|
|
2
2
|
//# sourceMappingURL=AuthenticateWithDeviceDeviceActionTypes.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/internal/app-binder/device-action/models/AuthenticateWithDeviceDeviceActionTypes.ts"],
|
|
4
|
-
"sourcesContent": ["import { type Either } from \"purify-ts\";\n\nimport {
|
|
4
|
+
"sourcesContent": ["import { type Either } from \"purify-ts\";\n\nimport {\n type AuthenticateDAError,\n type JWT,\n type Keypair,\n type Permissions,\n} from \"@api/index\";\nimport { type LKRPDataSource } from \"@internal/lkrp-datasource/data/LKRPDataSource\";\nimport { type Trustchain } from \"@internal/utils/Trustchain\";\n\nexport type AuthenticateWithDeviceDAInput = {\n readonly lkrpDataSource: LKRPDataSource;\n readonly appId: number;\n readonly keypair: Keypair;\n readonly clientName: string;\n readonly permissions: Permissions;\n};\n\nexport type AuthenticateWithDeviceDAInternalState = Either<\n AuthenticateDAError,\n {\n readonly trustchainId: string | null;\n readonly jwt: JWT | null;\n readonly trustchain: Trustchain | null;\n readonly encryptionKey: Uint8Array | null;\n readonly wasAddedToTrustchain: boolean;\n }\n>;\n"],
|
|
5
5
|
"mappings": "+WAAA,IAAAA,EAAA,kBAAAC,EAAAD",
|
|
6
6
|
"names": ["AuthenticateWithDeviceDeviceActionTypes_exports", "__toCommonJS"]
|
|
7
7
|
}
|
package/lib/cjs/internal/app-binder/device-action/models/AuthenticateWithKeypairDeviceActionTypes.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var n=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var o=Object.getOwnPropertyNames;var y=Object.prototype.hasOwnProperty;var u=(r,t,i,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let e of o(t))!y.call(r,e)&&e!==i&&n(r,e,{get:()=>t[e],enumerable:!(a=p(t,e))||a.enumerable});return r};var l=r=>u(n({},"__esModule",{value:!0}),r);var c={};module.exports=l(c);
|
|
2
2
|
//# sourceMappingURL=AuthenticateWithKeypairDeviceActionTypes.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/internal/app-binder/device-action/models/AuthenticateWithKeypairDeviceActionTypes.ts"],
|
|
4
|
-
"sourcesContent": ["import { type Either } from \"purify-ts\";\n\nimport { type
|
|
4
|
+
"sourcesContent": ["import { type Either } from \"purify-ts\";\n\nimport { type AuthenticateDAError, type JWT, type Keypair } from \"@api/index\";\nimport { type LKRPDataSource } from \"@internal/lkrp-datasource/data/LKRPDataSource\";\nimport { type Trustchain } from \"@internal/utils/Trustchain\";\n\nexport type AuthenticateWithKeypairDAInput = {\n readonly lkrpDataSource: LKRPDataSource;\n readonly appId: number;\n readonly keypair: Keypair;\n readonly trustchainId: string;\n};\n\nexport type AuthenticateWithKeypairDAInternalState = Either<\n AuthenticateDAError,\n {\n readonly jwt: JWT | null;\n readonly trustchain: Trustchain | null;\n readonly encryptionKey: Uint8Array | null;\n }\n>;\n"],
|
|
5
5
|
"mappings": "+WAAA,IAAAA,EAAA,kBAAAC,EAAAD",
|
|
6
6
|
"names": ["AuthenticateWithKeypairDeviceActionTypes_exports", "__toCommonJS"]
|
|
7
7
|
}
|