File tree Expand file tree Collapse file tree 4 files changed +12
-7
lines changed
backup/src/jsMain/kotlin/com/wire/backup
samples/src/jsMain/kotlin/samples/backup Expand file tree Collapse file tree 4 files changed +12
-7
lines changed Original file line number Diff line number Diff line change 17
17
*/
18
18
package com.wire.backup.dump
19
19
20
+ import org.khronos.webgl.Uint8Array
21
+
20
22
@JsExport
21
23
public sealed class BackupExportResult {
22
- public class Success (public val bytes : ByteArray ) : BackupExportResult()
24
+ public class Success (
25
+ public val bytes : Uint8Array
26
+ ) : BackupExportResult()
23
27
public sealed class Failure (public val message : String ) : BackupExportResult() {
24
28
/* *
25
29
* Represents an I/O error that occurs during an export process.
Original file line number Diff line number Diff line change @@ -72,7 +72,7 @@ public actual class MPBackupExporter(
72
72
when (val result = finalize(password, output)) {
73
73
is ExportResult .Failure .IOError -> BackupExportResult .Failure .IOError (result.message)
74
74
is ExportResult .Failure .ZipError -> BackupExportResult .Failure .ZipError (result.message)
75
- ExportResult .Success -> BackupExportResult .Success (output.readByteArray())
75
+ ExportResult .Success -> BackupExportResult .Success (output.readByteArray().toUByteArray().toUInt8Array() )
76
76
}
77
77
}
78
78
}
Original file line number Diff line number Diff line change @@ -42,15 +42,15 @@ import kotlin.js.Promise
42
42
public actual class MPBackupImporter : CommonMPBackupImporter () {
43
43
private val inMemoryUnencryptedBuffer = Buffer ()
44
44
45
- public fun peekFileData (data : ByteArray ): Promise <BackupPeekResult > = GlobalScope .promise {
45
+ public fun peekFileData (data : Uint8Array ): Promise <BackupPeekResult > = GlobalScope .promise {
46
46
val buffer = Buffer ()
47
- buffer.write(data)
47
+ buffer.write(data.toUByteArray().toByteArray() )
48
48
peekBackup(buffer)
49
49
}
50
50
51
- public fun importFromFileData (data : ByteArray , passphrase : String? ): Promise <BackupImportResult > = GlobalScope .promise {
51
+ public fun importFromFileData (data : Uint8Array , passphrase : String? ): Promise <BackupImportResult > = GlobalScope .promise {
52
52
val buffer = Buffer ()
53
- buffer.write(data)
53
+ buffer.write(data.toUByteArray().toByteArray() )
54
54
importBackup(buffer, passphrase)
55
55
}
56
56
Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ import com.wire.backup.ingest.BackupPeekResult
22
22
import com.wire.backup.ingest.MPBackupImporter
23
23
import com.wire.backup.ingest.isCreatedBySameUser
24
24
import kotlinx.coroutines.await
25
+ import org.khronos.webgl.Uint8Array
25
26
26
27
object BackupSamplesJs : BackupSamples() {
27
28
@@ -51,7 +52,7 @@ object BackupSamplesJs : BackupSamples() {
51
52
println (" Backup created file. Raw binary data: $fileData " )
52
53
}
53
54
54
- suspend fun peekBackup (data : ByteArray ) {
55
+ suspend fun peekBackup (data : Uint8Array ) {
55
56
// Peek into backup file
56
57
val importer = MPBackupImporter ()
57
58
You can’t perform that action at this time.
0 commit comments