-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This commit introduces a new cross-platform backup module to the project with support for iOS, Web, and Android. Additionally, it enables JavaScript multiplatform support in existing `kalium/network-model` and `kalium/data` projects.
- Loading branch information
1 parent
08c0cff
commit 4b3f4aa
Showing
4 changed files
with
176 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# Cross-platform Backup | ||
|
||
This module implements the Wire Cross-platform Backup solution. | ||
Its purpose is to create a common implementation to be used by iOS, Web, and Android. | ||
|
||
## Capabilities | ||
|
||
> [!TIP] | ||
> The backup blob/file will be referred in this document as **backup artifact**, or simply | ||
> **artifact**. | ||
> The clients (iOS, Web, and Android) will be referred as **callers**. | ||
### Creation of backup artifact | ||
|
||
The library should be able to transform data like messages, conversations, users into an artifact, | ||
_i.e._ create a backup file. | ||
|
||
### Restoration of original data | ||
|
||
It should also be able to revert this process, _i.e._ read a backup artifact and understand all of | ||
its contents, allowing the caller to get access to the original data. | ||
|
||
### Optional Encryption | ||
|
||
The artifact may _(or may not)_ be Encrypted. Clients using this library can provide an optional | ||
passphrase to encrypt and decrypt the artifact. | ||
|
||
### Optional UserID verification | ||
|
||
When creating an artifact, callers need to provide a qualified user ID. This qualified user ID will | ||
be stored within the artifact. | ||
When restoring the original data, the library _can_ compare the user ID in the artifact with a user | ||
ID provided by the caller. This may not be wanted in all features, _e.g._ in case of chat history | ||
sharing across different users. | ||
|
||
### Peak into artifact | ||
|
||
Clients can ask the library if a piece of data is an actual cross-platform artifact. | ||
The library should respond yes/no, and provide more details in case of a positive answer: is it | ||
encrypted? Was it created by the same user that is restoring the artifact? | ||
|
||
-------- | ||
|
||
# Development | ||
|
||
Using Kotlin Multiplatform, it should at least be available for iOS, JS (with TypeScript types), | ||
Android, and JVM. | ||
|
||
### Building | ||
|
||
Before we can automate the deployment of this library, we can manually generate and send library | ||
artifacts (not backup artifacts) using the following Gradle tasks: | ||
|
||
- iOS: `./gradlew :backup:assembleBackupDebugXCFramework` | ||
- Web: `./gradlew :backup:jsBrowserDevelopmentLibraryDistribution` | ||
|
||
**Output:** the results will be in `backup/build` directory. iOS needs the whole `backup.xcframework` directory, Web/JS needs the whole directory that contains `package.json` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
import org.jetbrains.kotlin.gradle.plugin.mpp.apple.XCFramework | ||
|
||
/* | ||
* Wire | ||
* Copyright (C) 2024 Wire Swiss GmbH | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see http://www.gnu.org/licenses/. | ||
*/ | ||
plugins { | ||
id(libs.plugins.android.library.get().pluginId) | ||
id(libs.plugins.kotlin.multiplatform.get().pluginId) | ||
alias(libs.plugins.kotlin.serialization) | ||
alias(libs.plugins.ksp) | ||
id(libs.plugins.kalium.library.get().pluginId) | ||
} | ||
|
||
kaliumLibrary { | ||
multiplatform { enableJs.set(true) } | ||
} | ||
|
||
@Suppress("UnusedPrivateProperty") | ||
kotlin { | ||
val xcf = XCFramework() | ||
val appleTargets = listOf(iosX64(), iosArm64(), iosSimulatorArm64(), macosArm64(), macosX64()) | ||
appleTargets.forEach { | ||
it.binaries.framework { | ||
baseName = "backup" | ||
xcf.add(this) | ||
} | ||
} | ||
js { | ||
browser() | ||
binaries.library() | ||
generateTypeScriptDefinitions() | ||
} | ||
sourceSets { | ||
val commonMain by getting { | ||
dependencies { | ||
implementation(project(":data")) | ||
implementation(project(":protobuf")) | ||
implementation(libs.pbandk.runtime.common) | ||
|
||
implementation(libs.coroutines.core) | ||
implementation(libs.ktxDateTime) | ||
implementation(libs.ktxSerialization) | ||
|
||
implementation(libs.okio.core) | ||
|
||
// Libsodium | ||
implementation(libs.libsodiumBindingsMP) | ||
} | ||
} | ||
val commonTest by getting { | ||
dependencies { | ||
implementation(libs.coroutines.test) | ||
implementation(libs.okio.test) | ||
} | ||
} | ||
|
||
val nonJsMain by creating { | ||
dependsOn(commonMain) | ||
} | ||
val nonJsTest by creating { | ||
dependsOn(commonTest) | ||
} | ||
val androidMain by getting { | ||
dependsOn(nonJsMain) | ||
} | ||
val jvmMain by getting { | ||
dependsOn(nonJsMain) | ||
} | ||
|
||
val iosX64Main by getting { | ||
dependsOn(nonJsMain) | ||
dependencies { | ||
implementation(libs.pbandk.runtime.iosX64) | ||
} | ||
} | ||
val iosArm64Main by getting { | ||
dependsOn(nonJsMain) | ||
dependencies { | ||
implementation(libs.pbandk.runtime.iosArm64) | ||
} | ||
} | ||
val iosSimulatorArm64Main by getting { | ||
dependsOn(nonJsMain) | ||
dependencies { | ||
implementation(libs.pbandk.runtime.iosSimulatorArm64) | ||
} | ||
} | ||
val macosX64Main by getting { | ||
dependsOn(nonJsMain) | ||
dependencies { | ||
implementation(libs.pbandk.runtime.macX64) | ||
} | ||
} | ||
val macosArm64Main by getting { | ||
dependsOn(nonJsMain) | ||
dependencies { | ||
implementation(libs.pbandk.runtime.macArm64) | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,7 +25,7 @@ plugins { | |
|
||
kaliumLibrary { | ||
multiplatform { | ||
enableJs.set(false) | ||
enableJs.set(true) | ||
} | ||
} | ||
|
||
|