Skip to content

Commit 06e16dd

Browse files
committed
feat(backup): add user verification on JS/TS
1 parent 63492d3 commit 06e16dd

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

backup/src/commonMain/kotlin/com/wire/backup/ingest/BackupPeekResult.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import com.wire.backup.data.BackupQualifiedId
2121
import com.wire.backup.envelope.HashData
2222
import com.wire.backup.hash.hashUserId
2323
import kotlin.js.JsExport
24+
import kotlin.js.JsName
2425

2526
@JsExport
2627
public sealed class BackupPeekResult {
@@ -40,6 +41,7 @@ public sealed class BackupPeekResult {
4041
}
4142
}
4243

44+
@JsName("isCreatedBySameUserSUSPEND")
4345
public suspend fun BackupPeekResult.Success.isCreatedBySameUser(userId: BackupQualifiedId): Boolean {
4446
val candidateHash = hashUserId(userId, hashData.salt, hashData.hashingMemoryLimit, hashData.operationsLimit)
4547
val actualHash = hashData.hashedUserId
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
* Wire
3+
* Copyright (C) 2025 Wire Swiss GmbH
4+
*
5+
* This program is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU General Public License as published by
7+
* the Free Software Foundation, either version 3 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* This program is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU General Public License
16+
* along with this program. If not, see http://www.gnu.org/licenses/.
17+
*/
18+
package com.wire.backup.ingest
19+
20+
import com.wire.backup.data.BackupQualifiedId
21+
import kotlinx.coroutines.GlobalScope
22+
import kotlinx.coroutines.promise
23+
import kotlin.js.Promise
24+
25+
@JsExport
26+
@JsName("isCreatedBySameUser")
27+
public fun BackupPeekResult.Success.isFromSameUser(backupQualifiedId: BackupQualifiedId): Promise<Boolean> = GlobalScope.promise {
28+
isCreatedBySameUser(backupQualifiedId)
29+
}

0 commit comments

Comments
 (0)