[PR #1219] [MERGED] Port send jslib to mobile #2795

Closed
opened 2025-11-26 23:24:12 -06:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/bitwarden/android/pull/1219
Author: @MGibson1
Created: 1/13/2021
Status: Merged
Merged: 1/25/2021
Merged by: @MGibson1

Base: masterHead: port-send-jslib-to-mobile


📝 Commits (10+)

📊 Changes

52 files changed (+2046 additions, -38 deletions)

View changed files

📝 .github/workflows/build.yml (+3 -0)
📝 bitwarden-mobile.sln (+66 -0)
📝 src/Android/Android.csproj (+1 -1)
📝 src/Core/Abstractions/IApiService.cs (+7 -0)
📝 src/Core/Abstractions/ICryptoFunctionService.cs (+6 -0)
📝 src/Core/Abstractions/ICryptoService.cs (+1 -0)
src/Core/Abstractions/ISendService.cs (+25 -0)
src/Core/Enums/HdkfAlgorithm.cs (+8 -0)
src/Core/Enums/SendType.cs (+8 -0)
src/Core/Models/Api/SendFileApi.cs (+12 -0)
src/Core/Models/Api/SendTextApi.cs (+8 -0)
src/Core/Models/Data/SendData.cs (+58 -0)
src/Core/Models/Data/SendFileData.cs (+27 -0)
src/Core/Models/Data/SendTextData.cs (+19 -0)
📝 src/Core/Models/Domain/CipherString.cs (+6 -3)
📝 src/Core/Models/Domain/Domain.cs (+2 -2)
src/Core/Models/Domain/Send.cs (+91 -0)
src/Core/Models/Domain/SendFile.cs (+27 -0)
src/Core/Models/Domain/SendText.cs (+25 -0)
src/Core/Models/Request/SendRequest.cs (+54 -0)

...and 32 more files

📄 Description

Overview

Port of Send PRs to jslib (bitwarden/jslib#190, bitwarden/jslib#192, bitwarden/jslib#205, bitwarden/jslib#242). This PR does not implement any actual use of the SendService.

Testing

Projects

Common

This project is a copy from the bitwarden/server/Core.Test project, with some additions. Given the similarity here, we should think about creating a new repo for common testing items and accessing them through a submodule.

Core.Test

This is a test bed for the Send feature I'm implementing. Crypto tests are copied from jslib tests. Send model and service tests are happy path tests to ensure proper function since I'm not implementing anything that uses them.

Automated Testing

An Automated test runner is added to the android job. Unfortunately, dotnet is not capable of building the android and iOS projects, so it is run against only the Core.Test project. We'll have to add another line per test project we add.

Files Changes/Added

  • build.yml: Added running of tests in the Core.Test project to the android job pipeline.
  • bitwarden-mobile.sln: Added test projects test/Common.csproj and test/Core.Test
  • Android.csproj: This was automatically changed by VS Mac when adding the above projects. The new Guid is what was already in the solution file and seems like a good change to me, so I kept it. @mportune-bw, @kspearrin if you know why this Guid differed from the solution file, please let me know and I'll revert.
  • IApiService.cs/ApiService.cs: Add Send methods. No Access methods on Mobile.
  • ICryptoFunctionService.cs/PclCryptoFunctionService.cs: Add expanded hkdf implementation to function service. A basic implementation used to be private to CryptoFunctionService, but is not implemented in classes implementing this interface.
  • ICryptoService.cs/CryptoService.cs: Add send MakeKey method
  • ISendService.cs/SendService.cs: Service handling send functionality.
  • Enums/HkdfAlgorithm: Hkdf is currently only valid for Sha256 and Sha512, so this represents a subset of valid CryptoHashAlgorithms. Conversion between these enums happens in the CryptoFunctionService when Hkdf is calculated
  • Enums/SendType.cs: Types of valid sends
  • SendFileApi.cs: Api interface model for File type send data.
  • SendTestApi.cs: Api interface model for Text type send data.
  • SendData.cs/SendFileData.cs/SendTextData.cs: Client storage model for Send / File Send info / and Text Send info, respectively
  • Domain/Send/SendFile/SendText Encrypted data model for Send / File Send info / and Text Send info, respectively
  • SendView/SendFileView/SendTextView: Decrypted model for Send / File Send info / and Text Send info, respectively
  • CipherString: Allow optionally passing in decryption key
  • Domain: Optionally allow specifying decryption key
  • SendRequest: Api request model
  • SendResponse: Api response model
  • SyncResponse: Added sends to sync response
  • SyncService: Handle synced sends and replace current storage with received send data.
  • CoreHelpers: Added this method for testing, but it exists in CoreHelpers for Server. Open to moving to TestHelpers
  • ServiceContainer.cs: Make SendService available from ServiceContainer

Testing Files Changes

Common

  • AutoSubDataAttribute/CustomAutoDataAttribute/SutAutoDataAttribute/InlineAutoSubDataAttribute/InlineCustomAutoDataAttribute/FixtureExtension: Helper attributes to allow creation of autofixtures with customizations, substitutions, or sutProviders
  • ISutProvider/SutProvider/SutProviderCustomization: Autofixture customization to provide SUT objects with access to injected dependencies
  • common/TestHelper.cs: Commonly used helper methods are placed here.
  • Common.csproj: Project to house testing code common across testing projects. We should think about splitting this to a new Repo to share between csharp projects.

Core.Test

  • Core.Test/**/SymmetricCryptoKeyCustomization / SendCustomizations: AutFixture customizations to produce valid fixture data for SymmetricCryptoKey and Send data structures, respectively.
  • Core.Test.csproj: Project housing all Core tests and Core specific testing infrastructure (like above customizations)
  • SendDataTests.cs: Tests for SendData, SendTextData, and SendFileData data models. These are model conversion tests
  • SendTests.cs: Tests for Send, SendText, and SendFile domain models. These are model conversion tests
  • SendRequestTests.cs: Tests for SendRequest, SendTextApi, and SendFileApi models. These are model conversion tests
  • CryptoFunctionServiceTests.cs: Tests of Hkdf implementations. Tests are copied from bitwarden/jslib
  • SendServiceTests.cs: Happy path tests of send service functions

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/bitwarden/android/pull/1219 **Author:** [@MGibson1](https://github.com/MGibson1) **Created:** 1/13/2021 **Status:** ✅ Merged **Merged:** 1/25/2021 **Merged by:** [@MGibson1](https://github.com/MGibson1) **Base:** `master` ← **Head:** `port-send-jslib-to-mobile` --- ### 📝 Commits (10+) - [`177ff78`](https://github.com/bitwarden/android/commit/177ff78801b7fa89d1987711554bfc35d3889192) Expand Hkdf crypto functions - [`1e04584`](https://github.com/bitwarden/android/commit/1e04584b2665570b129d21ef1ea0980293a932ef) Add tests for hkdf crypto functions - [`6d8791f`](https://github.com/bitwarden/android/commit/6d8791f909fbb816bb4de96b3d05143dd8bfda2e) Move Hkdf to cryptoFunctionService - [`dd04135`](https://github.com/bitwarden/android/commit/dd041353553fc394ac5593ad21755d22ec285ad8) Port changes from bitwarden/jslib#192 - [`9ecaf51`](https://github.com/bitwarden/android/commit/9ecaf51b944b602b051de291c075c574fc36f78f) Port changes from bitwarden/jslib#205 - [`9d469a1`](https://github.com/bitwarden/android/commit/9d469a16f3ac26cd43549e585d86a714187ade47) Make Send Expiration Optional implement changes from bitwarden/jslib#242 - [`7c38199`](https://github.com/bitwarden/android/commit/7c38199d01c64f94774c7c4c7c767d6119c165d0) Bug fixes found by testing - [`1ebe764`](https://github.com/bitwarden/android/commit/1ebe76475f68244620696ffce3b87670a7e5c9f5) Test helpers - [`55ab476`](https://github.com/bitwarden/android/commit/55ab4761f82856bea7e62063aa191442f7e034be) Test conversion between model types - [`1828ca4`](https://github.com/bitwarden/android/commit/1828ca45e1eb903ea4bf101cba69c975f73f755e) Test SendService ### 📊 Changes **52 files changed** (+2046 additions, -38 deletions) <details> <summary>View changed files</summary> 📝 `.github/workflows/build.yml` (+3 -0) 📝 `bitwarden-mobile.sln` (+66 -0) 📝 `src/Android/Android.csproj` (+1 -1) 📝 `src/Core/Abstractions/IApiService.cs` (+7 -0) 📝 `src/Core/Abstractions/ICryptoFunctionService.cs` (+6 -0) 📝 `src/Core/Abstractions/ICryptoService.cs` (+1 -0) ➕ `src/Core/Abstractions/ISendService.cs` (+25 -0) ➕ `src/Core/Enums/HdkfAlgorithm.cs` (+8 -0) ➕ `src/Core/Enums/SendType.cs` (+8 -0) ➕ `src/Core/Models/Api/SendFileApi.cs` (+12 -0) ➕ `src/Core/Models/Api/SendTextApi.cs` (+8 -0) ➕ `src/Core/Models/Data/SendData.cs` (+58 -0) ➕ `src/Core/Models/Data/SendFileData.cs` (+27 -0) ➕ `src/Core/Models/Data/SendTextData.cs` (+19 -0) 📝 `src/Core/Models/Domain/CipherString.cs` (+6 -3) 📝 `src/Core/Models/Domain/Domain.cs` (+2 -2) ➕ `src/Core/Models/Domain/Send.cs` (+91 -0) ➕ `src/Core/Models/Domain/SendFile.cs` (+27 -0) ➕ `src/Core/Models/Domain/SendText.cs` (+25 -0) ➕ `src/Core/Models/Request/SendRequest.cs` (+54 -0) _...and 32 more files_ </details> ### 📄 Description # Overview Port of Send PRs to jslib (bitwarden/jslib#190, bitwarden/jslib#192, bitwarden/jslib#205, bitwarden/jslib#242). This PR does not implement any actual use of the SendService. ## Testing ### Projects #### Common This project is a copy from the [bitwarden/server/Core.Test project](https://github.com/bitwarden/server/tree/master/test/Core.Test), with some additions. Given the similarity here, we should think about creating a new repo for common testing items and accessing them through a submodule. #### Core.Test This is a test bed for the Send feature I'm implementing. Crypto tests are copied from jslib tests. Send model and service tests are happy path tests to ensure proper function since I'm not implementing anything that uses them. ### Automated Testing An Automated test runner is added to the `android` job. Unfortunately, `dotnet` is not capable of building the `android` and `iOS` projects, so it is run against only the `Core.Test` project. We'll have to add another line per test project we add. # Files Changes/Added * **build.yml**: Added running of tests in the `Core.Test` project to the android job pipeline. * **bitwarden-mobile.sln**: Added test projects `test/Common.csproj` and `test/Core.Test` * **Android.csproj**: This was automatically changed by VS Mac when adding the above projects. The new Guid is what was already in the solution file and seems like a good change to me, so I kept it. @mportune-bw, @kspearrin if you know why this Guid differed from the solution file, please let me know and I'll revert. * **IApiService.cs/ApiService.cs**: Add Send methods. No Access methods on Mobile. * **ICryptoFunctionService.cs/PclCryptoFunctionService.cs**: Add expanded hkdf implementation to function service. A basic implementation used to be private to CryptoFunctionService, but is not implemented in classes implementing this interface. * **ICryptoService.cs/CryptoService.cs**: Add send MakeKey method * **ISendService.cs/SendService.cs**: Service handling send functionality. * **Enums/HkdfAlgorithm**: Hkdf is currently only valid for Sha256 and Sha512, so this represents a subset of valid CryptoHashAlgorithms. Conversion between these enums happens in the CryptoFunctionService when Hkdf is calculated * **Enums/SendType.cs**: Types of valid sends * **SendFileApi.cs**: Api interface model for File type send data. * **SendTestApi.cs**: Api interface model for Text type send data. * **SendData.cs/SendFileData.cs/SendTextData.cs**: Client storage model for Send / File Send info / and Text Send info, respectively * **Domain/Send/SendFile/SendText** Encrypted data model for Send / File Send info / and Text Send info, respectively * **SendView/SendFileView/SendTextView**: Decrypted model for Send / File Send info / and Text Send info, respectively * **CipherString**: Allow optionally passing in decryption key * **Domain**: Optionally allow specifying decryption key * **SendRequest**: Api request model * **SendResponse**: Api response model * **SyncResponse**: Added sends to sync response * **SyncService**: Handle synced sends and replace current storage with received send data. * **CoreHelpers**: Added this method for testing, but it exists in CoreHelpers for Server. Open to moving to TestHelpers * **ServiceContainer.cs**: Make SendService available from ServiceContainer ### Testing Files Changes #### Common * **AutoSubDataAttribute/CustomAutoDataAttribute/SutAutoDataAttribute/InlineAutoSubDataAttribute/InlineCustomAutoDataAttribute/FixtureExtension**: Helper attributes to allow creation of autofixtures with customizations, substitutions, or sutProviders * **ISutProvider/SutProvider/SutProviderCustomization**: Autofixture customization to provide SUT objects with access to injected dependencies * **common/TestHelper.cs**: Commonly used helper methods are placed here. * **Common.csproj**: Project to house testing code common across testing projects. We should think about splitting this to a new Repo to share between csharp projects. #### Core.Test * **Core.Test/\*\*/SymmetricCryptoKeyCustomization / SendCustomizations**: AutFixture customizations to produce valid fixture data for SymmetricCryptoKey and Send data structures, respectively. * **Core.Test.csproj**: Project housing all Core tests and Core specific testing infrastructure (like above customizations) * **SendDataTests.cs**: Tests for SendData, SendTextData, and SendFileData data models. These are model conversion tests * **SendTests.cs**: Tests for Send, SendText, and SendFile domain models. These are model conversion tests * **SendRequestTests.cs**: Tests for SendRequest, SendTextApi, and SendFileApi models. These are model conversion tests * **CryptoFunctionServiceTests.cs**: Tests of Hkdf implementations. Tests are copied from [bitwarden/jslib](https://github.com/bitwarden/jslib/blob/master/spec/node/services/nodeCryptoFunction.service.spec.ts#L52-L89) * **SendServiceTests.cs**: Happy path tests of send service functions --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2025-11-26 23:24:12 -06:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/android#2795