Skip to content

Commit 99ab224

Browse files
Update SDK to 1.0.0-2681-1a956d45 (#5756)
Co-authored-by: bw-ghapp[bot] <178206702+bw-ghapp[bot]@users.noreply.github.com> Co-authored-by: Carlos Gonçalves <[email protected]>
1 parent bc7e682 commit 99ab224

File tree

14 files changed

+375
-3
lines changed

14 files changed

+375
-3
lines changed
Lines changed: 264 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,264 @@
1+
{
2+
"formatVersion": 1,
3+
"database": {
4+
"version": 8,
5+
"identityHash": "11387825dab701f9d2dd2e940ffbd794",
6+
"entities": [
7+
{
8+
"tableName": "ciphers",
9+
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `user_id` TEXT NOT NULL, `has_totp` INTEGER NOT NULL DEFAULT 1, `cipher_type` TEXT NOT NULL, `cipher_json` TEXT NOT NULL, PRIMARY KEY(`id`))",
10+
"fields": [
11+
{
12+
"fieldPath": "id",
13+
"columnName": "id",
14+
"affinity": "TEXT",
15+
"notNull": true
16+
},
17+
{
18+
"fieldPath": "userId",
19+
"columnName": "user_id",
20+
"affinity": "TEXT",
21+
"notNull": true
22+
},
23+
{
24+
"fieldPath": "hasTotp",
25+
"columnName": "has_totp",
26+
"affinity": "INTEGER",
27+
"notNull": true,
28+
"defaultValue": "1"
29+
},
30+
{
31+
"fieldPath": "cipherType",
32+
"columnName": "cipher_type",
33+
"affinity": "TEXT",
34+
"notNull": true
35+
},
36+
{
37+
"fieldPath": "cipherJson",
38+
"columnName": "cipher_json",
39+
"affinity": "TEXT",
40+
"notNull": true
41+
}
42+
],
43+
"primaryKey": {
44+
"autoGenerate": false,
45+
"columnNames": [
46+
"id"
47+
]
48+
},
49+
"indices": [
50+
{
51+
"name": "index_ciphers_user_id",
52+
"unique": false,
53+
"columnNames": [
54+
"user_id"
55+
],
56+
"orders": [],
57+
"createSql": "CREATE INDEX IF NOT EXISTS `index_ciphers_user_id` ON `${TABLE_NAME}` (`user_id`)"
58+
}
59+
]
60+
},
61+
{
62+
"tableName": "collections",
63+
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `user_id` TEXT NOT NULL, `organization_id` TEXT NOT NULL, `should_hide_passwords` INTEGER NOT NULL, `name` TEXT NOT NULL, `external_id` TEXT, `read_only` INTEGER NOT NULL, `manage` INTEGER, `default_user_collection_email` TEXT, `type` TEXT NOT NULL DEFAULT '0', PRIMARY KEY(`id`))",
64+
"fields": [
65+
{
66+
"fieldPath": "id",
67+
"columnName": "id",
68+
"affinity": "TEXT",
69+
"notNull": true
70+
},
71+
{
72+
"fieldPath": "userId",
73+
"columnName": "user_id",
74+
"affinity": "TEXT",
75+
"notNull": true
76+
},
77+
{
78+
"fieldPath": "organizationId",
79+
"columnName": "organization_id",
80+
"affinity": "TEXT",
81+
"notNull": true
82+
},
83+
{
84+
"fieldPath": "shouldHidePasswords",
85+
"columnName": "should_hide_passwords",
86+
"affinity": "INTEGER",
87+
"notNull": true
88+
},
89+
{
90+
"fieldPath": "name",
91+
"columnName": "name",
92+
"affinity": "TEXT",
93+
"notNull": true
94+
},
95+
{
96+
"fieldPath": "externalId",
97+
"columnName": "external_id",
98+
"affinity": "TEXT"
99+
},
100+
{
101+
"fieldPath": "isReadOnly",
102+
"columnName": "read_only",
103+
"affinity": "INTEGER",
104+
"notNull": true
105+
},
106+
{
107+
"fieldPath": "canManage",
108+
"columnName": "manage",
109+
"affinity": "INTEGER"
110+
},
111+
{
112+
"fieldPath": "defaultUserCollectionEmail",
113+
"columnName": "default_user_collection_email",
114+
"affinity": "TEXT"
115+
},
116+
{
117+
"fieldPath": "type",
118+
"columnName": "type",
119+
"affinity": "TEXT",
120+
"notNull": true,
121+
"defaultValue": "'0'"
122+
}
123+
],
124+
"primaryKey": {
125+
"autoGenerate": false,
126+
"columnNames": [
127+
"id"
128+
]
129+
},
130+
"indices": [
131+
{
132+
"name": "index_collections_user_id",
133+
"unique": false,
134+
"columnNames": [
135+
"user_id"
136+
],
137+
"orders": [],
138+
"createSql": "CREATE INDEX IF NOT EXISTS `index_collections_user_id` ON `${TABLE_NAME}` (`user_id`)"
139+
}
140+
]
141+
},
142+
{
143+
"tableName": "domains",
144+
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`user_id` TEXT NOT NULL, `domains_json` TEXT, PRIMARY KEY(`user_id`))",
145+
"fields": [
146+
{
147+
"fieldPath": "userId",
148+
"columnName": "user_id",
149+
"affinity": "TEXT",
150+
"notNull": true
151+
},
152+
{
153+
"fieldPath": "domainsJson",
154+
"columnName": "domains_json",
155+
"affinity": "TEXT"
156+
}
157+
],
158+
"primaryKey": {
159+
"autoGenerate": false,
160+
"columnNames": [
161+
"user_id"
162+
]
163+
}
164+
},
165+
{
166+
"tableName": "folders",
167+
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `user_id` TEXT NOT NULL, `name` TEXT, `revision_date` INTEGER NOT NULL, PRIMARY KEY(`id`))",
168+
"fields": [
169+
{
170+
"fieldPath": "id",
171+
"columnName": "id",
172+
"affinity": "TEXT",
173+
"notNull": true
174+
},
175+
{
176+
"fieldPath": "userId",
177+
"columnName": "user_id",
178+
"affinity": "TEXT",
179+
"notNull": true
180+
},
181+
{
182+
"fieldPath": "name",
183+
"columnName": "name",
184+
"affinity": "TEXT"
185+
},
186+
{
187+
"fieldPath": "revisionDate",
188+
"columnName": "revision_date",
189+
"affinity": "INTEGER",
190+
"notNull": true
191+
}
192+
],
193+
"primaryKey": {
194+
"autoGenerate": false,
195+
"columnNames": [
196+
"id"
197+
]
198+
},
199+
"indices": [
200+
{
201+
"name": "index_folders_user_id",
202+
"unique": false,
203+
"columnNames": [
204+
"user_id"
205+
],
206+
"orders": [],
207+
"createSql": "CREATE INDEX IF NOT EXISTS `index_folders_user_id` ON `${TABLE_NAME}` (`user_id`)"
208+
}
209+
]
210+
},
211+
{
212+
"tableName": "sends",
213+
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `user_id` TEXT NOT NULL, `send_type` TEXT NOT NULL, `send_json` TEXT NOT NULL, PRIMARY KEY(`id`))",
214+
"fields": [
215+
{
216+
"fieldPath": "id",
217+
"columnName": "id",
218+
"affinity": "TEXT",
219+
"notNull": true
220+
},
221+
{
222+
"fieldPath": "userId",
223+
"columnName": "user_id",
224+
"affinity": "TEXT",
225+
"notNull": true
226+
},
227+
{
228+
"fieldPath": "sendType",
229+
"columnName": "send_type",
230+
"affinity": "TEXT",
231+
"notNull": true
232+
},
233+
{
234+
"fieldPath": "sendJson",
235+
"columnName": "send_json",
236+
"affinity": "TEXT",
237+
"notNull": true
238+
}
239+
],
240+
"primaryKey": {
241+
"autoGenerate": false,
242+
"columnNames": [
243+
"id"
244+
]
245+
},
246+
"indices": [
247+
{
248+
"name": "index_sends_user_id",
249+
"unique": false,
250+
"columnNames": [
251+
"user_id"
252+
],
253+
"orders": [],
254+
"createSql": "CREATE INDEX IF NOT EXISTS `index_sends_user_id` ON `${TABLE_NAME}` (`user_id`)"
255+
}
256+
]
257+
}
258+
],
259+
"setupQueries": [
260+
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
261+
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '11387825dab701f9d2dd2e940ffbd794')"
262+
]
263+
}
264+
}

app/src/main/kotlin/com/x8bit/bitwarden/data/vault/datasource/disk/VaultDiskSourceImpl.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,8 @@ class VaultDiskSourceImpl(
146146
externalId = collection.externalId,
147147
isReadOnly = collection.isReadOnly,
148148
canManage = collection.canManage,
149+
defaultUserCollectionEmail = collection.defaultUserCollectionEmail,
150+
type = collection.type,
149151
),
150152
)
151153
}
@@ -167,6 +169,8 @@ class VaultDiskSourceImpl(
167169
externalId = entity.externalId,
168170
isReadOnly = entity.isReadOnly,
169171
canManage = entity.canManage,
172+
defaultUserCollectionEmail = entity.defaultUserCollectionEmail,
173+
type = entity.type,
170174
)
171175
}
172176
},
@@ -290,6 +294,8 @@ class VaultDiskSourceImpl(
290294
externalId = collection.externalId,
291295
isReadOnly = collection.isReadOnly,
292296
canManage = collection.canManage,
297+
defaultUserCollectionEmail = collection.defaultUserCollectionEmail,
298+
type = collection.type,
293299
)
294300
},
295301
)

app/src/main/kotlin/com/x8bit/bitwarden/data/vault/datasource/disk/database/VaultDatabase.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,11 @@ import com.x8bit.bitwarden.data.vault.datasource.disk.entity.SendEntity
2727
FolderEntity::class,
2828
SendEntity::class,
2929
],
30-
version = 7,
30+
version = 8,
3131
exportSchema = true,
3232
autoMigrations = [
3333
AutoMigration(from = 6, to = 7),
34+
AutoMigration(from = 7, to = 8),
3435
],
3536
)
3637
@TypeConverters(ZonedDateTimeTypeConverter::class)

app/src/main/kotlin/com/x8bit/bitwarden/data/vault/datasource/disk/entity/CollectionEntity.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package com.x8bit.bitwarden.data.vault.datasource.disk.entity
33
import androidx.room.ColumnInfo
44
import androidx.room.Entity
55
import androidx.room.PrimaryKey
6+
import com.bitwarden.network.model.CollectionTypeJson
67

78
/**
89
* Entity representing a collection in the database.
@@ -33,4 +34,10 @@ data class CollectionEntity(
3334

3435
@ColumnInfo(name = "manage")
3536
val canManage: Boolean?,
37+
38+
@ColumnInfo(name = "default_user_collection_email")
39+
val defaultUserCollectionEmail: String?,
40+
41+
@ColumnInfo(name = "type", defaultValue = "0")
42+
val type: CollectionTypeJson,
3643
)

app/src/main/kotlin/com/x8bit/bitwarden/data/vault/repository/util/VaultSdkCollectionExtensions.kt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
package com.x8bit.bitwarden.data.vault.repository.util
22

33
import com.bitwarden.collections.Collection
4+
import com.bitwarden.collections.CollectionType
45
import com.bitwarden.collections.CollectionView
56
import com.bitwarden.core.data.repository.util.SpecialCharWithPrecedenceComparator
7+
import com.bitwarden.network.model.CollectionTypeJson
68
import com.bitwarden.network.model.SyncResponseJson
79

810
/**
@@ -18,6 +20,8 @@ fun SyncResponseJson.Collection.toEncryptedSdkCollection(): Collection =
1820
hidePasswords = this.shouldHidePasswords,
1921
readOnly = this.isReadOnly,
2022
manage = this.canManage ?: !this.isReadOnly,
23+
defaultUserCollectionEmail = this.defaultUserCollectionEmail,
24+
type = this.type.toCollectionType(),
2125
)
2226

2327
/**
@@ -38,3 +42,13 @@ fun List<CollectionView>.sortAlphabetically(): List<CollectionView> {
3842
},
3943
)
4044
}
45+
46+
/**
47+
* Converts a [CollectionType] object to a corresponding
48+
* Bitwarden SDK [CollectionTypeJson] object.
49+
*/
50+
fun CollectionTypeJson.toCollectionType(): CollectionType =
51+
when (this) {
52+
CollectionTypeJson.SHARED_COLLECTION -> CollectionType.SHARED_COLLECTION
53+
CollectionTypeJson.DEFAULT_USER_COLLECTION -> CollectionType.DEFAULT_USER_COLLECTION
54+
}

app/src/test/kotlin/com/x8bit/bitwarden/data/vault/datasource/disk/VaultDiskSourceTest.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package com.x8bit.bitwarden.data.vault.datasource.disk
33
import app.cash.turbine.test
44
import com.bitwarden.core.di.CoreModule
55
import com.bitwarden.data.datasource.disk.base.FakeDispatcherManager
6+
import com.bitwarden.network.model.CollectionTypeJson
67
import com.bitwarden.network.model.SyncResponseJson
78
import com.bitwarden.network.model.createMockCipher
89
import com.bitwarden.network.model.createMockCollection
@@ -479,6 +480,8 @@ private val COLLECTION_ENTITY = CollectionEntity(
479480
externalId = "mockExternalId-3",
480481
isReadOnly = false,
481482
canManage = true,
483+
defaultUserCollectionEmail = "mockOffboardedUserEmail-3",
484+
type = CollectionTypeJson.SHARED_COLLECTION,
482485
)
483486

484487
private const val DOMAINS_JSON = """

0 commit comments

Comments
 (0)