@open-e2ee/signal-protocol-sdk 12.0.1 → 13.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ADAPTERS.md +3 -0
- package/ARCHITECTURE.md +4 -4
- package/CHANGELOG.md +141 -0
- package/README.md +1 -1
- package/SECURITY.md +2 -2
- package/client/README.md +40 -0
- package/device/README.md +40 -4
- package/dist/client/client.d.ts +8 -0
- package/dist/client/client.d.ts.map +1 -1
- package/dist/client/client.js +19 -1
- package/dist/client/client.js.map +1 -1
- package/dist/client/config.d.ts +6 -2
- package/dist/client/config.d.ts.map +1 -1
- package/dist/client/config.js.map +1 -1
- package/dist/client/event-hooks.d.ts +28 -0
- package/dist/client/event-hooks.d.ts.map +1 -1
- package/dist/client/event-hooks.js +1 -0
- package/dist/client/event-hooks.js.map +1 -1
- package/dist/client/group-init-status.d.ts +21 -0
- package/dist/client/group-init-status.d.ts.map +1 -0
- package/dist/client/group-init-status.js +156 -0
- package/dist/client/group-init-status.js.map +1 -0
- package/dist/client/hosted-device-link-transport.d.ts +11 -0
- package/dist/client/hosted-device-link-transport.d.ts.map +1 -0
- package/dist/client/hosted-device-link-transport.js +25 -0
- package/dist/client/hosted-device-link-transport.js.map +1 -0
- package/dist/client/hosted-device-link.d.ts +97 -0
- package/dist/client/hosted-device-link.d.ts.map +1 -0
- package/dist/client/hosted-device-link.js +149 -0
- package/dist/client/hosted-device-link.js.map +1 -0
- package/dist/client/hosted-http-error.d.ts +30 -0
- package/dist/client/hosted-http-error.d.ts.map +1 -0
- package/dist/client/hosted-http-error.js +34 -0
- package/dist/client/hosted-http-error.js.map +1 -0
- package/dist/client/hosted-presence.js +1 -1
- package/dist/client/hosted-presence.js.map +1 -1
- package/dist/client/hosted-profile-keys.js +1 -1
- package/dist/client/hosted-profile-keys.js.map +1 -1
- package/dist/client/hosted-sandbox-identity.d.ts +3 -3
- package/dist/client/hosted-sandbox-identity.js +3 -3
- package/dist/client/hosted-transport.d.ts +12 -13
- package/dist/client/hosted-transport.d.ts.map +1 -1
- package/dist/client/hosted-transport.js +111 -17
- package/dist/client/hosted-transport.js.map +1 -1
- package/dist/client/hosted.d.ts +57 -8
- package/dist/client/hosted.d.ts.map +1 -1
- package/dist/client/hosted.js +170 -19
- package/dist/client/hosted.js.map +1 -1
- package/dist/client/index.d.ts +2 -1
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +1 -1
- package/dist/client/index.js.map +1 -1
- package/dist/client/receive-queue.d.ts +4 -2
- package/dist/client/receive-queue.d.ts.map +1 -1
- package/dist/client/receive-queue.js +26 -22
- package/dist/client/receive-queue.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/local/store/conformance/cases/ciphertext.d.ts +7 -0
- package/dist/local/store/conformance/cases/ciphertext.d.ts.map +1 -0
- package/dist/local/store/conformance/cases/ciphertext.js +55 -0
- package/dist/local/store/conformance/cases/ciphertext.js.map +1 -0
- package/dist/local/store/conformance/cases/durability.d.ts +6 -0
- package/dist/local/store/conformance/cases/durability.d.ts.map +1 -0
- package/dist/local/store/conformance/cases/durability.js +34 -0
- package/dist/local/store/conformance/cases/durability.js.map +1 -0
- package/dist/local/store/conformance/cases/identity.d.ts +7 -0
- package/dist/local/store/conformance/cases/identity.d.ts.map +1 -0
- package/dist/local/store/conformance/cases/identity.js +84 -0
- package/dist/local/store/conformance/cases/identity.js.map +1 -0
- package/dist/local/store/conformance/cases/metadata.d.ts +7 -0
- package/dist/local/store/conformance/cases/metadata.d.ts.map +1 -0
- package/dist/local/store/conformance/cases/metadata.js +48 -0
- package/dist/local/store/conformance/cases/metadata.js.map +1 -0
- package/dist/local/store/conformance/cases/protection.d.ts +7 -0
- package/dist/local/store/conformance/cases/protection.d.ts.map +1 -0
- package/dist/local/store/conformance/cases/protection.js +14 -0
- package/dist/local/store/conformance/cases/protection.js.map +1 -0
- package/dist/local/store/conformance/cases/receive-work.d.ts +8 -0
- package/dist/local/store/conformance/cases/receive-work.d.ts.map +1 -0
- package/dist/local/store/conformance/cases/receive-work.js +152 -0
- package/dist/local/store/conformance/cases/receive-work.js.map +1 -0
- package/dist/local/store/conformance/cases/sender-key.d.ts +7 -0
- package/dist/local/store/conformance/cases/sender-key.d.ts.map +1 -0
- package/dist/local/store/conformance/cases/sender-key.js +59 -0
- package/dist/local/store/conformance/cases/sender-key.js.map +1 -0
- package/dist/local/store/conformance/cases/session-trust.d.ts +7 -0
- package/dist/local/store/conformance/cases/session-trust.d.ts.map +1 -0
- package/dist/local/store/conformance/cases/session-trust.js +64 -0
- package/dist/local/store/conformance/cases/session-trust.js.map +1 -0
- package/dist/local/store/conformance/checks.d.ts +15 -0
- package/dist/local/store/conformance/checks.d.ts.map +1 -0
- package/dist/local/store/conformance/checks.js +67 -0
- package/dist/local/store/conformance/checks.js.map +1 -0
- package/dist/local/store/conformance/index.d.ts +30 -0
- package/dist/local/store/conformance/index.d.ts.map +1 -0
- package/dist/local/store/conformance/index.js +29 -0
- package/dist/local/store/conformance/index.js.map +1 -0
- package/dist/local/store/conformance/records.d.ts +36 -0
- package/dist/local/store/conformance/records.d.ts.map +1 -0
- package/dist/local/store/conformance/records.js +109 -0
- package/dist/local/store/conformance/records.js.map +1 -0
- package/dist/local/store/conformance/run.d.ts +24 -0
- package/dist/local/store/conformance/run.d.ts.map +1 -0
- package/dist/local/store/conformance/run.js +156 -0
- package/dist/local/store/conformance/run.js.map +1 -0
- package/dist/local/store/conformance/types.d.ts +55 -0
- package/dist/local/store/conformance/types.d.ts.map +1 -0
- package/dist/local/store/conformance/types.js +6 -0
- package/dist/local/store/conformance/types.js.map +1 -0
- package/dist/local/store/expo/adapter.d.ts +2 -1
- package/dist/local/store/expo/adapter.d.ts.map +1 -1
- package/dist/local/store/expo/adapter.js.map +1 -1
- package/dist/local/store/node/adapter.d.ts +2 -2
- package/dist/local/store/react-native/adapter.d.ts +2 -1
- package/dist/local/store/react-native/adapter.d.ts.map +1 -1
- package/dist/local/store/react-native/adapter.js.map +1 -1
- package/dist/local/store/sqlite/convert-plaintext.d.ts +62 -0
- package/dist/local/store/sqlite/convert-plaintext.d.ts.map +1 -0
- package/dist/local/store/sqlite/convert-plaintext.js +236 -0
- package/dist/local/store/sqlite/convert-plaintext.js.map +1 -0
- package/dist/local/store/sqlite/encryption.d.ts +21 -0
- package/dist/local/store/sqlite/encryption.d.ts.map +1 -1
- package/dist/local/store/sqlite/encryption.js.map +1 -1
- package/dist/local/store/sqlite/errors.d.ts.map +1 -1
- package/dist/local/store/sqlite/errors.js +2 -1
- package/dist/local/store/sqlite/errors.js.map +1 -1
- package/dist/local/store/sqlite/key-storage/identity-keys.d.ts +3 -1
- package/dist/local/store/sqlite/key-storage/identity-keys.d.ts.map +1 -1
- package/dist/local/store/sqlite/key-storage/identity-keys.js +3 -1
- package/dist/local/store/sqlite/key-storage/identity-keys.js.map +1 -1
- package/dist/local/store/sqlite/open-store.d.ts +36 -4
- package/dist/local/store/sqlite/open-store.d.ts.map +1 -1
- package/dist/local/store/sqlite/open-store.js +326 -21
- package/dist/local/store/sqlite/open-store.js.map +1 -1
- package/dist/local/store/sqlite/web/worker.d.ts +5 -0
- package/dist/local/store/sqlite/web/worker.d.ts.map +1 -1
- package/dist/local/store/sqlite/web/worker.js +99 -20
- package/dist/local/store/sqlite/web/worker.js.map +1 -1
- package/dist/local/store/web-sqlite/adapter.d.ts +3 -2
- package/dist/local/store/web-sqlite/adapter.d.ts.map +1 -1
- package/dist/local/store/web-sqlite/adapter.js +12 -2
- package/dist/local/store/web-sqlite/adapter.js.map +1 -1
- package/dist/remote/relay/types.d.ts +4 -2
- package/dist/remote/relay/types.d.ts.map +1 -1
- package/dist/types/api.d.ts +20 -4
- package/dist/types/api.d.ts.map +1 -1
- package/docs/ASSURANCE.md +25 -7
- package/docs/DEVIATIONS.md +35 -3
- package/docs/ERROR_HANDLING.md +8 -6
- package/docs/GETTING_STARTED.md +25 -8
- package/docs/INTERFACES.md +3 -1
- package/docs/PACKAGE_SURFACE.md +1 -0
- package/docs/RECIPES.md +44 -0
- package/docs/SECURITY.md +23 -5
- package/keys/README.md +3 -1
- package/local/store/README.md +92 -12
- package/local/store/expo/README.md +63 -6
- package/local/store/key-value/README.md +3 -2
- package/local/store/node/README.md +68 -6
- package/local/store/react-native/README.md +62 -4
- package/local/store/web-sqlite/README.md +101 -4
- package/package.json +5 -1
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The data side of the conversion of a plaintext SQLite store to an encrypted
|
|
3
|
+
* one.
|
|
4
|
+
*
|
|
5
|
+
* The open in `./open-store` owns the steps, the keys, and the recovery. This
|
|
6
|
+
* module checks a plaintext database before the first write. It also copies
|
|
7
|
+
* the schema and the rows of one database into another in one transaction.
|
|
8
|
+
* The driver seam has no rename, attach, or export, so the copy is the only
|
|
9
|
+
* path, and it runs the same way on every driver.
|
|
10
|
+
*
|
|
11
|
+
* The copy keeps every row, its rowid, the `sqlite_sequence` counters, and
|
|
12
|
+
* `PRAGMA user_version`. Only SDK tables are copied. A driver value is a
|
|
13
|
+
* string, a number, or null, so a BLOB value or an integer outside the safe
|
|
14
|
+
* JavaScript range cannot pass through the copy. The check refuses them
|
|
15
|
+
* before anything is written.
|
|
16
|
+
*/
|
|
17
|
+
import { EncryptionError, EncryptionErrorCode } from '../../../types/errors.js';
|
|
18
|
+
import { SqliteSchemaTooNewError, SqliteStoreInUseError, classifySqliteError } from './errors.js';
|
|
19
|
+
import { createSqliteExecutor } from './executor.js';
|
|
20
|
+
import { SQLITE_STORE_MIGRATIONS } from './migrations.js';
|
|
21
|
+
import { SQLITE_STORE_TABLES } from './schema.js';
|
|
22
|
+
/**
|
|
23
|
+
* The name ending of the temporary file of a conversion. The core refuses a
|
|
24
|
+
* store name with this ending, so no store shares the file.
|
|
25
|
+
*/
|
|
26
|
+
export const SQLITE_CONVERT_SUFFIX = '.oe2e-convert';
|
|
27
|
+
/** The temporary file of the conversion of the store `name`. */
|
|
28
|
+
export function sqliteConvertTempName(name) {
|
|
29
|
+
return `${name}${SQLITE_CONVERT_SUFFIX}`;
|
|
30
|
+
}
|
|
31
|
+
/** The rows that one read of the copy returns. */
|
|
32
|
+
const PAGE_SIZE = 256;
|
|
33
|
+
/** The alias of the rowid in the reads of the copy. No SDK column has this name. */
|
|
34
|
+
const ROWID = 'oe2e_copy_rowid';
|
|
35
|
+
/** SQL that is true when `expression` is an integer outside the safe JavaScript range. */
|
|
36
|
+
function unsafeInteger(expression) {
|
|
37
|
+
return (`(typeof(${expression}) = 'integer' AND ` +
|
|
38
|
+
`(${expression} > ${Number.MAX_SAFE_INTEGER} OR ${expression} < ${-Number.MAX_SAFE_INTEGER}))`);
|
|
39
|
+
}
|
|
40
|
+
function quote(identifier) {
|
|
41
|
+
return `"${identifier.replaceAll('"', '""')}"`;
|
|
42
|
+
}
|
|
43
|
+
function invalidState(message, originalError) {
|
|
44
|
+
return new EncryptionError(message, EncryptionErrorCode.INVALID_STATE, {
|
|
45
|
+
operation: 'open',
|
|
46
|
+
originalError: originalError,
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
async function readUserVersion(db) {
|
|
50
|
+
const row = await db.first('PRAGMA user_version');
|
|
51
|
+
return row?.user_version ?? 0;
|
|
52
|
+
}
|
|
53
|
+
/** The tables of `db` in creation order, without the `sqlite_` tables. */
|
|
54
|
+
async function readTables(db) {
|
|
55
|
+
const rows = await db.all("SELECT name FROM sqlite_master WHERE type = 'table' AND substr(name, 1, 7) <> 'sqlite_' " +
|
|
56
|
+
'ORDER BY rowid');
|
|
57
|
+
return rows.map((row) => row.name);
|
|
58
|
+
}
|
|
59
|
+
async function readColumns(db, table) {
|
|
60
|
+
const rows = await db.all('SELECT name FROM pragma_table_info(?) ORDER BY cid', [table]);
|
|
61
|
+
return rows.map((row) => row.name);
|
|
62
|
+
}
|
|
63
|
+
async function hasSequenceTable(db) {
|
|
64
|
+
const row = await db.first("SELECT 1 AS present FROM sqlite_master WHERE type = 'table' AND name = 'sqlite_sequence'");
|
|
65
|
+
return row !== null;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Open the plaintext database `file` with no key, and check that the copy
|
|
69
|
+
* can keep all of it. The open writes nothing. On a failure, it closes the
|
|
70
|
+
* database before it throws.
|
|
71
|
+
*
|
|
72
|
+
* @throws EncryptionError with `INVALID_STATE` when the database holds no SDK
|
|
73
|
+
* schema, holds a table that is not an SDK table, or holds a BLOB value or
|
|
74
|
+
* an unsafe integer.
|
|
75
|
+
* @throws SqliteSchemaTooNewError when a newer SDK wrote the database.
|
|
76
|
+
* @throws SqliteStoreInUseError when another connection holds the file.
|
|
77
|
+
*/
|
|
78
|
+
export async function openSqliteConversionSource(driver, file) {
|
|
79
|
+
let db;
|
|
80
|
+
try {
|
|
81
|
+
db = createSqliteExecutor(await driver.open(file, null));
|
|
82
|
+
}
|
|
83
|
+
catch (error) {
|
|
84
|
+
if (classifySqliteError(error) === 'busy')
|
|
85
|
+
throw new SqliteStoreInUseError(driver.name, error);
|
|
86
|
+
throw error;
|
|
87
|
+
}
|
|
88
|
+
try {
|
|
89
|
+
await assertConvertible(db, file);
|
|
90
|
+
}
|
|
91
|
+
catch (error) {
|
|
92
|
+
// The check error is the one to report. A failed close adds nothing.
|
|
93
|
+
await db.close().catch(() => undefined);
|
|
94
|
+
throw error;
|
|
95
|
+
}
|
|
96
|
+
return db;
|
|
97
|
+
}
|
|
98
|
+
async function assertConvertible(db, file) {
|
|
99
|
+
const version = await readUserVersion(db);
|
|
100
|
+
if (version === 0) {
|
|
101
|
+
throw invalidState(`The plaintext database ${file} holds no SDK schema, so there is nothing to convert. ` +
|
|
102
|
+
'Reset the store to start an encrypted one.');
|
|
103
|
+
}
|
|
104
|
+
const last = SQLITE_STORE_MIGRATIONS.at(-1)?.version ?? 0;
|
|
105
|
+
if (version > last)
|
|
106
|
+
throw new SqliteSchemaTooNewError(version, last);
|
|
107
|
+
const known = new Set(SQLITE_STORE_TABLES);
|
|
108
|
+
const tables = await readTables(db);
|
|
109
|
+
const foreign = tables.filter((table) => !known.has(table));
|
|
110
|
+
if (foreign.length > 0) {
|
|
111
|
+
throw invalidState(`The plaintext database ${file} holds tables that the SDK does not own: ` +
|
|
112
|
+
`${foreign.join(', ')}. Move them to another database, then convert.`);
|
|
113
|
+
}
|
|
114
|
+
for (const table of tables) {
|
|
115
|
+
const columns = (await readColumns(db, table)).map(quote);
|
|
116
|
+
const blob = columns.map((column) => `typeof(${column}) = 'blob'`).join(' OR ') || '0';
|
|
117
|
+
const unsafe = ['rowid', ...columns].map(unsafeInteger).join(' OR ');
|
|
118
|
+
const row = await db.first(`SELECT coalesce(sum(${blob}), 0) AS blobs, coalesce(sum(${unsafe}), 0) AS unsafe ` +
|
|
119
|
+
`FROM ${quote(table)}`);
|
|
120
|
+
if (row && row.blobs > 0) {
|
|
121
|
+
throw invalidState(`The plaintext database ${file} holds BLOB values in table ${table}. ` +
|
|
122
|
+
'The SDK stores no BLOB values, so the conversion cannot keep them.');
|
|
123
|
+
}
|
|
124
|
+
if (row && row.unsafe > 0) {
|
|
125
|
+
throw invalidState(`The plaintext database ${file} holds integers in table ${table} that a JavaScript ` +
|
|
126
|
+
'number cannot hold exactly, so the conversion cannot keep them.');
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
if (await hasSequenceTable(db)) {
|
|
130
|
+
const row = await db.first(`SELECT count(*) AS unsafe FROM sqlite_sequence WHERE ${unsafeInteger('seq')}`);
|
|
131
|
+
if (row && row.unsafe > 0) {
|
|
132
|
+
throw invalidState(`The plaintext database ${file} holds a row counter that a JavaScript number cannot ` +
|
|
133
|
+
'hold exactly, so the conversion cannot keep it.');
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Copy the schema and the rows of `source` into the empty database `target`,
|
|
139
|
+
* in one `BEGIN IMMEDIATE` transaction on `target`.
|
|
140
|
+
*
|
|
141
|
+
* The order is: the tables, their rows page by page in rowid order, the
|
|
142
|
+
* `sqlite_sequence` counters, the other schema objects in creation order, and
|
|
143
|
+
* `PRAGMA user_version` last. Indexes and triggers come after the rows, so no
|
|
144
|
+
* trigger runs on a copied row. Foreign keys are off on `target`, so the
|
|
145
|
+
* table order does not matter. The transaction checks the row count of each
|
|
146
|
+
* table, and a difference rolls it back.
|
|
147
|
+
*
|
|
148
|
+
* @throws EncryptionError with `INVALID_STATE` when a table of `target` has
|
|
149
|
+
* another row count than the same table of `source`.
|
|
150
|
+
*/
|
|
151
|
+
export async function copySqliteDatabase(source, target) {
|
|
152
|
+
const objects = await source.all("SELECT type, name, sql FROM sqlite_master WHERE sql IS NOT NULL AND substr(name, 1, 7) <> 'sqlite_' " +
|
|
153
|
+
'ORDER BY rowid');
|
|
154
|
+
const version = await readUserVersion(source);
|
|
155
|
+
const sequence = (await hasSequenceTable(source))
|
|
156
|
+
? await source.all('SELECT name, seq FROM sqlite_sequence')
|
|
157
|
+
: null;
|
|
158
|
+
// SQLite ignores this pragma inside a transaction.
|
|
159
|
+
await target.run('PRAGMA foreign_keys = OFF');
|
|
160
|
+
await target.transaction(async (tx) => {
|
|
161
|
+
const tables = objects.filter((object) => object.type === 'table');
|
|
162
|
+
for (const table of tables)
|
|
163
|
+
await tx.run(table.sql);
|
|
164
|
+
for (const table of tables)
|
|
165
|
+
await copyRows(source, tx, table.name);
|
|
166
|
+
if (sequence) {
|
|
167
|
+
// Each copied row moved the counter to the largest rowid. The source
|
|
168
|
+
// counter can be higher, because a delete does not lower it.
|
|
169
|
+
await tx.run('DELETE FROM sqlite_sequence');
|
|
170
|
+
for (const row of sequence) {
|
|
171
|
+
await tx.run('INSERT INTO sqlite_sequence (name, seq) VALUES (?, ?)', [row.name, row.seq]);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
for (const object of objects) {
|
|
175
|
+
if (object.type !== 'table')
|
|
176
|
+
await tx.run(object.sql);
|
|
177
|
+
}
|
|
178
|
+
await tx.run(`PRAGMA user_version = ${version}`);
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
async function copyRows(source, target, table) {
|
|
182
|
+
const names = await readColumns(source, table);
|
|
183
|
+
const columns = names.map(quote);
|
|
184
|
+
const from = quote(table);
|
|
185
|
+
const select = `SELECT rowid AS ${ROWID}${columns.map((column) => `, ${column}`).join('')} FROM ${from}`;
|
|
186
|
+
const insert = `INSERT INTO ${from} (rowid${columns.map((column) => `, ${column}`).join('')}) ` +
|
|
187
|
+
`VALUES (?${', ?'.repeat(columns.length)})`;
|
|
188
|
+
let after = null;
|
|
189
|
+
for (;;) {
|
|
190
|
+
const rows = await source.all(after === null
|
|
191
|
+
? `${select} ORDER BY rowid LIMIT ${PAGE_SIZE}`
|
|
192
|
+
: `${select} WHERE rowid > ? ORDER BY rowid LIMIT ${PAGE_SIZE}`, after === null ? [] : [after]);
|
|
193
|
+
for (const row of rows) {
|
|
194
|
+
await target.run(insert, [row[ROWID], ...names.map((name) => row[name])]);
|
|
195
|
+
}
|
|
196
|
+
if (rows.length < PAGE_SIZE)
|
|
197
|
+
break;
|
|
198
|
+
after = rows[rows.length - 1][ROWID];
|
|
199
|
+
}
|
|
200
|
+
const count = `SELECT count(*) AS count FROM ${from}`;
|
|
201
|
+
const expected = (await source.first(count))?.count ?? 0;
|
|
202
|
+
const copied = (await target.first(count))?.count ?? 0;
|
|
203
|
+
if (copied !== expected) {
|
|
204
|
+
throw invalidState(`The conversion copied ${copied} rows of table ${table} instead of ${expected}. ` +
|
|
205
|
+
'It wrote nothing.');
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Open the existing file `file` with `key`, read its `PRAGMA user_version`,
|
|
210
|
+
* and close it. The read writes nothing. Return `null` when the key does not
|
|
211
|
+
* open the file. Call it only for a file that exists, because a driver
|
|
212
|
+
* creates a file that it opens.
|
|
213
|
+
*
|
|
214
|
+
* @throws SqliteStoreInUseError when another connection holds the file.
|
|
215
|
+
*/
|
|
216
|
+
export async function readSqliteUserVersion(driver, file, key) {
|
|
217
|
+
let db;
|
|
218
|
+
try {
|
|
219
|
+
db = createSqliteExecutor(await driver.open(file, key));
|
|
220
|
+
}
|
|
221
|
+
catch (error) {
|
|
222
|
+
const kind = classifySqliteError(error);
|
|
223
|
+
if (kind === 'not-a-database')
|
|
224
|
+
return null;
|
|
225
|
+
if (kind === 'busy')
|
|
226
|
+
throw new SqliteStoreInUseError(driver.name, error);
|
|
227
|
+
throw error;
|
|
228
|
+
}
|
|
229
|
+
try {
|
|
230
|
+
return await readUserVersion(db);
|
|
231
|
+
}
|
|
232
|
+
finally {
|
|
233
|
+
await db.close().catch(() => undefined);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
//# sourceMappingURL=convert-plaintext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"convert-plaintext.js","sourceRoot":"","sources":["../../../../local/store/sqlite/convert-plaintext.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE7E,OAAO,EAAE,uBAAuB,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAC/F,OAAO,EAAE,oBAAoB,EAA2B,MAAM,YAAY,CAAC;AAC3E,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAE/C;;;GAGG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,eAAe,CAAC;AAErD,gEAAgE;AAChE,MAAM,UAAU,qBAAqB,CAAC,IAAY;IAChD,OAAO,GAAG,IAAI,GAAG,qBAAqB,EAAE,CAAC;AAC3C,CAAC;AAED,kDAAkD;AAClD,MAAM,SAAS,GAAG,GAAG,CAAC;AAEtB,oFAAoF;AACpF,MAAM,KAAK,GAAG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,EAAE,CAAC;QACxB,MAAM,YAAY,CAChB,yBAAyB,MAAM,kBAAkB,KAAK,eAAe,QAAQ,IAAI;YAC/E,mBAAmB,CACtB,CAAC;IACJ,CAAC;AACH,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,qBAAqB,CACzC,MAAoB,EACpB,IAAY,EACZ,GAAe;IAEf,IAAI,EAAsB,CAAC;IAC3B,IAAI,CAAC;QACH,EAAE,GAAG,oBAAoB,CAAC,MAAM,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC;IAC1D,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,GAAG,mBAAmB,CAAC,KAAK,CAAC,CAAC;QACxC,IAAI,IAAI,KAAK,gBAAgB;YAAE,OAAO,IAAI,CAAC;QAC3C,IAAI,IAAI,KAAK,MAAM;YAAE,MAAM,IAAI,qBAAqB,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QACzE,MAAM,KAAK,CAAC;IACd,CAAC;IACD,IAAI,CAAC;QACH,OAAO,MAAM,eAAe,CAAC,EAAE,CAAC,CAAC;IACnC,CAAC;YAAS,CAAC;QACT,MAAM,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;IAC1C,CAAC;AACH,CAAC"}
|
|
@@ -26,6 +26,27 @@ export interface SqliteEncryptionOptions {
|
|
|
26
26
|
* Default: `true`. The open fails when the binding has no cipher.
|
|
27
27
|
*/
|
|
28
28
|
readonly encryptionAtRest?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Pass `true` to convert a plaintext database to an encrypted one at an
|
|
31
|
+
* encrypted open. The store keeps every row and its schema version. The
|
|
32
|
+
* open writes a new key to the vault, and it does not change the plaintext
|
|
33
|
+
* file until the encrypted copy is complete. An open that stops during a
|
|
34
|
+
* conversion leaves a state that the next encrypted open finishes or
|
|
35
|
+
* starts again.
|
|
36
|
+
*
|
|
37
|
+
* The conversion refuses a database that holds tables of the application,
|
|
38
|
+
* BLOB values, or integers outside the safe JavaScript range. The disk
|
|
39
|
+
* blocks of the removed plaintext file can keep its data until the file
|
|
40
|
+
* system reuses them.
|
|
41
|
+
*
|
|
42
|
+
* The option does nothing on an encrypted database or when no database
|
|
43
|
+
* exists. With `encryptionAtRest: false`, the open fails with
|
|
44
|
+
* `INVALID_STATE`.
|
|
45
|
+
*
|
|
46
|
+
* Default: `false`. An encrypted open of a plaintext database then fails
|
|
47
|
+
* with `SqliteKeyMismatchError`.
|
|
48
|
+
*/
|
|
49
|
+
readonly convertPlaintext?: boolean;
|
|
29
50
|
}
|
|
30
51
|
export interface SqliteOpenOptions extends SqliteEncryptionOptions {
|
|
31
52
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"encryption.d.ts","sourceRoot":"","sources":["../../../../local/store/sqlite/encryption.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAGH,OAAO,EAA+B,KAAK,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAE3E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAE3D,OAAO,KAAK,EAAE,gBAAgB,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAQ/E,6DAA6D;AAC7D,MAAM,WAAW,uBAAuB;IACtC;;;;;;;OAOG;IACH,QAAQ,CAAC,gBAAgB,CAAC,EAAE,OAAO,CAAC;CACrC;AAED,MAAM,WAAW,iBAAkB,SAAQ,uBAAuB;IAChE;;;OAGG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CAC1B;AAOD;;;;;GAKG;AACH,wBAAgB,6BAA6B,CAC3C,GAAG,EAAE,UAAU,GAAG,IAAI,EACtB,OAAO,EAAE,uBAAuB,GAC/B,IAAI,CAUN;AAED;;;;GAIG;AACH,wBAAsB,uBAAuB,CAC3C,UAAU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O,EAAE,iBAAiB,GACzB,OAAO,CAAC,IAAI,CAAC,CA0Bf;AAED;;;;GAIG;AACH,wBAAsB,gBAAgB,CACpC,EAAE,EAAE,cAAc,GACjB,OAAO,CAAC,OAAO,CAAC,gBAAgB,EAAE,aAAa,GAAG,MAAM,CAAC,CAAC,CAG5D;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,yBAAyB,CAC7C,MAAM,EAAE,YAAY,EACpB,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,OAAO,CAAC,CAgBlB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"encryption.js","sourceRoot":"","sources":["../../../../local/store/sqlite/encryption.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC7E,OAAO,EAAE,2BAA2B,EAAe,MAAM,iBAAiB,CAAC;AAK3E,OAAO,EACL,gCAAgC,EAChC,sBAAsB,EACtB,qBAAqB,EACrB,mBAAmB,GACpB,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"encryption.js","sourceRoot":"","sources":["../../../../local/store/sqlite/encryption.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC7E,OAAO,EAAE,2BAA2B,EAAe,MAAM,iBAAiB,CAAC;AAK3E,OAAO,EACL,gCAAgC,EAChC,sBAAsB,EACtB,qBAAqB,EACrB,mBAAmB,GACpB,MAAM,UAAU,CAAC;AA4ClB,2EAA2E;AAC3E,6DAA6D;AAC7D,MAAM,qBAAqB,GAAG,UAAU,CAAC,CAAC,SAAS;AACnD,MAAM,qBAAqB,GAAG,UAAU,CAAC,CAAC,SAAS;AAEnD;;;;;GAKG;AACH,MAAM,UAAU,6BAA6B,CAC3C,GAAsB,EACtB,OAAgC;IAEhC,MAAM,SAAS,GAAG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C,KAAK,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;IAClD,CAAC;AACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../../local/store/sqlite/errors.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,eAAe,EAGhB,MAAM,uBAAuB,CAAC;AAE/B,MAAM,MAAM,eAAe;AACzB,iEAAiE;AAC/D,mBAAmB;AACrB,wDAAwD;GACtD,MAAM;AACR,8EAA8E;GAC5E,gBAAgB;AAClB;;;GAGG;GACD,MAAM,GACN,OAAO,CAAC;AAQZ,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,GAAG,eAAe,CASnE;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAG3D;AAED;;GAEG;AACH,qBAAa,sBAAuB,SAAQ,eAAe;IACzD,SAAkB,IAAI,4BAA4B;IAClD,YAAY,OAAO,EAAE,MAAM,EAE1B;CACF;AAED;;;;;;GAMG;AACH,qBAAa,sBAAuB,SAAQ,eAAe;IACzD,SAAkB,IAAI,4BAA4B;IAClD,YAAY,MAAM,EAAE,MAAM,EAAE,aAAa,CAAC,EAAE,OAAO,
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../../local/store/sqlite/errors.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,eAAe,EAGhB,MAAM,uBAAuB,CAAC;AAE/B,MAAM,MAAM,eAAe;AACzB,iEAAiE;AAC/D,mBAAmB;AACrB,wDAAwD;GACtD,MAAM;AACR,8EAA8E;GAC5E,gBAAgB;AAClB;;;GAGG;GACD,MAAM,GACN,OAAO,CAAC;AAQZ,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,GAAG,eAAe,CASnE;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAG3D;AAED;;GAEG;AACH,qBAAa,sBAAuB,SAAQ,eAAe;IACzD,SAAkB,IAAI,4BAA4B;IAClD,YAAY,OAAO,EAAE,MAAM,EAE1B;CACF;AAED;;;;;;GAMG;AACH,qBAAa,sBAAuB,SAAQ,eAAe;IACzD,SAAkB,IAAI,4BAA4B;IAClD,YAAY,MAAM,EAAE,MAAM,EAAE,aAAa,CAAC,EAAE,OAAO,EAQlD;CACF;AAED;;;;GAIG;AACH,qBAAa,gCAAiC,SAAQ,eAAe;IACnE,SAAkB,IAAI,sCAAsC;IAC5D,YAAY,MAAM,EAAE,MAAM,EAQzB;CACF;AAED;;;GAGG;AACH,qBAAa,uBAAwB,SAAQ,eAAe;IAC1D,SAAkB,IAAI,6BAA6B;IACnD,YAAY,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,OAAO,EAMjD;CACF;AAED,6DAA6D;AAC7D,qBAAa,qBAAsB,SAAQ,eAAe;IACxD,SAAkB,IAAI,2BAA2B;IACjD,YAAY,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,OAAO,EAMjD;CACF;AAED;;;GAGG;AACH,qBAAa,uBAAwB,SAAQ,eAAe;IAC1D,SAAkB,IAAI,6BAA6B;IACnD,YAAY,WAAW,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAOpD;CACF"}
|
|
@@ -54,7 +54,8 @@ export class SqliteKeyMismatchError extends EncryptionError {
|
|
|
54
54
|
name = 'SqliteKeyMismatchError';
|
|
55
55
|
constructor(driver, originalError) {
|
|
56
56
|
super(`The ${driver} database exists but cannot be read with this key and encryption setting. ` +
|
|
57
|
-
'Open it with the key and setting that created it, or reset the store.
|
|
57
|
+
'Open it with the key and setting that created it, or reset the store. To keep the ' +
|
|
58
|
+
'data of a plaintext database in an encrypted store, open it with convertPlaintext: true.', EncryptionErrorCode.KEY_STORAGE_ERROR, { operation: 'open', originalError: originalError });
|
|
58
59
|
}
|
|
59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IACjD,YAAY,MAAc,EAAE,aAAsB;QAChD,KAAK,CACH,OAAO,MAAM,qDAAqD,EAClE,mBAAmB,CAAC,iBAAiB,EACrC,EAAE,SAAS,EAAE,MAAM,EAAE,aAAa,EAAE,aAAsB,EAAE,CAC7D,CAAC;IACJ,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,OAAO,uBAAwB,SAAQ,eAAe;IACxC,IAAI,GAAG,yBAAyB,CAAC;IACnD,YAAY,WAAmB,EAAE,YAAoB;QACnD,KAAK,CACH,qCAAqC,WAAW,sCAAsC;YACpF,GAAG,YAAY,qEAAqE,EACtF,mBAAmB,CAAC,aAAa,EACjC,EAAE,SAAS,EAAE,MAAM,EAAE,CACtB,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
import type { IdentityKeyPair, IdentityType } from '../../../../keys/index.js';
|
|
3
3
|
import { type KeyStorageContext } from './context.js';
|
|
4
4
|
/**
|
|
5
|
-
* Store identity key pair
|
|
5
|
+
* Store the identity key pair of one identity type. A call for a type that
|
|
6
|
+
* already has a key pair overwrites the key pair and the registration ID of
|
|
7
|
+
* that type, and leaves the other type unchanged.
|
|
6
8
|
*
|
|
7
9
|
* IdentityKeyPair has nested structure:
|
|
8
10
|
* - dhKey: { publicKey, privateKey } (X25519 for DH)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"identity-keys.d.ts","sourceRoot":"","sources":["../../../../../local/store/sqlite/key-storage/identity-keys.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAE7E,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAStE,OAAO,EAAmB,KAAK,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAEpE
|
|
1
|
+
{"version":3,"file":"identity-keys.d.ts","sourceRoot":"","sources":["../../../../../local/store/sqlite/key-storage/identity-keys.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAE7E,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAStE,OAAO,EAAmB,KAAK,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAEpE;;;;;;;;;GASG;AACH,wBAAsB,gBAAgB,CACpC,GAAG,EAAE,iBAAiB,EACtB,OAAO,EAAE,eAAe,EACxB,YAAY,EAAE,YAAY,GACzB,OAAO,CAAC,IAAI,CAAC,CAmBf;AAED,wBAAsB,cAAc,CAClC,GAAG,EAAE,iBAAiB,EACtB,YAAY,EAAE,YAAY,GACzB,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC,CAkCjC;AAED,wBAAsB,iBAAiB,CACrC,GAAG,EAAE,iBAAiB,EACtB,YAAY,EAAE,YAAY,GACzB,OAAO,CAAC,IAAI,CAAC,CAMf;AAED,wBAAsB,cAAc,CAClC,GAAG,EAAE,iBAAiB,EACtB,YAAY,EAAE,YAAY,GACzB,OAAO,CAAC,OAAO,CAAC,CAOlB;AAED,wBAAsB,sBAAsB,CAC1C,GAAG,EAAE,iBAAiB,EACtB,YAAY,EAAE,YAAY,GACzB,OAAO,CAAC,MAAM,CAAC,CAGjB;AAED,wBAAsB,sBAAsB,CAC1C,GAAG,EAAE,iBAAiB,EACtB,EAAE,EAAE,MAAM,EACV,YAAY,EAAE,YAAY,GACzB,OAAO,CAAC,IAAI,CAAC,CAEf"}
|
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
import { createPrimaryIdentityKey, deletePrimaryIdentityKey, getLocalRegistrationId as modelGetLocalRegistrationId, getPrimaryIdentityKey, setLocalRegistrationId as modelSetLocalRegistrationId, } from '../models/index.js';
|
|
3
3
|
import { keyStorageError } from './context.js';
|
|
4
4
|
/**
|
|
5
|
-
* Store identity key pair
|
|
5
|
+
* Store the identity key pair of one identity type. A call for a type that
|
|
6
|
+
* already has a key pair overwrites the key pair and the registration ID of
|
|
7
|
+
* that type, and leaves the other type unchanged.
|
|
6
8
|
*
|
|
7
9
|
* IdentityKeyPair has nested structure:
|
|
8
10
|
* - dhKey: { publicKey, privateKey } (X25519 for DH)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"identity-keys.js","sourceRoot":"","sources":["../../../../../local/store/sqlite/key-storage/identity-keys.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAI7E,OAAO,EACL,wBAAwB,EACxB,wBAAwB,EACxB,sBAAsB,IAAI,2BAA2B,EACrD,qBAAqB,EACrB,sBAAsB,IAAI,2BAA2B,GACtD,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,eAAe,EAA0B,MAAM,WAAW,CAAC;AAEpE
|
|
1
|
+
{"version":3,"file":"identity-keys.js","sourceRoot":"","sources":["../../../../../local/store/sqlite/key-storage/identity-keys.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAI7E,OAAO,EACL,wBAAwB,EACxB,wBAAwB,EACxB,sBAAsB,IAAI,2BAA2B,EACrD,qBAAqB,EACrB,sBAAsB,IAAI,2BAA2B,GACtD,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,eAAe,EAA0B,MAAM,WAAW,CAAC;AAEpE;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,GAAsB,EACtB,OAAwB,EACxB,YAA0B;IAE1B,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,wBAAwB,CAAC;YACxC,SAAS,EAAE,OAAO,CAAC,KAAK,CAAC,SAAS;YAClC,KAAK,EAAE,OAAO,CAAC,KAAK;YACpB,UAAU,EAAE,OAAO,CAAC,UAAU;YAC9B,YAAY;SACb,CAAC,CAAC;QACH,MAAM,GAAG,CAAC,EAAE,CAAC,WAAW,CAAC,KAAK,EAAE,EAAE,EAAE,EAAE;YACpC,MAAM,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YACxB,MAAM,2BAA2B,CAAC,EAAE,EAAE,OAAO,CAAC,cAAc,EAAE,YAAY,CAAC,CAAC;QAC9E,CAAC,CAAC,CAAC;IACL,CAAC;IAAC,O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
* `encryptionAtRest: false` has no key, and its open and reset do not touch
|
|
19
19
|
* the vault.
|
|
20
20
|
*
|
|
21
|
+
* With `convertPlaintext: true`, an encrypted open converts a plaintext file
|
|
22
|
+
* and keeps its data. The driver seam has no rename, so the conversion copies
|
|
23
|
+
* twice: the plaintext file to a temporary encrypted file, then that file back
|
|
24
|
+
* to the store name. A pending vault slot holds the new key until the copy
|
|
25
|
+
* back is complete. Removing the plaintext file is the commit point. Before
|
|
26
|
+
* it, a failed conversion leaves the plaintext file, and the next conversion
|
|
27
|
+
* starts again with a new key. After it, the next encrypted open finishes the
|
|
28
|
+
* conversion, with or without the option.
|
|
29
|
+
*
|
|
21
30
|
* In one process, the open and the reset of a database run one at a time, and
|
|
22
31
|
* a database has at most one open store. Two first opens therefore cannot write
|
|
23
32
|
* two different keys, and a reset or the driver's `exists` never runs on a
|
|
@@ -39,6 +48,13 @@ export interface SqliteStoreOpenOptions extends SqliteOpenOptions {
|
|
|
39
48
|
readonly name: string;
|
|
40
49
|
/** The vault that holds the database key. */
|
|
41
50
|
readonly vault: SignalProtocolLocalSecretVault;
|
|
51
|
+
/**
|
|
52
|
+
* Take the lock that a conversion needs, and return the function that
|
|
53
|
+
* releases it. The open calls it before a conversion or its recovery
|
|
54
|
+
* changes a file or a vault slot, and releases the lock before it returns.
|
|
55
|
+
* Default: no lock beyond the one-at-a-time open.
|
|
56
|
+
*/
|
|
57
|
+
readonly lockConversion?: () => Promise<() => void>;
|
|
42
58
|
}
|
|
43
59
|
/**
|
|
44
60
|
* The vault slot that holds the key of the database `identity`, the value of
|
|
@@ -46,8 +62,9 @@ export interface SqliteStoreOpenOptions extends SqliteOpenOptions {
|
|
|
46
62
|
*/
|
|
47
63
|
export declare function sqliteDatabaseKeySlot(identity: string): string;
|
|
48
64
|
/**
|
|
49
|
-
* Reject a name that is not safe as a file name on every platform,
|
|
50
|
-
*
|
|
65
|
+
* Reject a name that is not safe as a file name on every platform, or that
|
|
66
|
+
* names the temporary file of a conversion, with the error of
|
|
67
|
+
* {@link openSqliteStore}.
|
|
51
68
|
*/
|
|
52
69
|
export declare function assertSqliteStoreName(name: string, operation: 'open' | 'reset'): void;
|
|
53
70
|
/**
|
|
@@ -55,11 +72,19 @@ export declare function assertSqliteStoreName(name: string, operation: 'open' |
|
|
|
55
72
|
* migrations. On an encrypted store, the key comes from the vault. The key,
|
|
56
73
|
* then the file, are created only when the file does not exist.
|
|
57
74
|
*
|
|
75
|
+
* With `convertPlaintext: true`, an encrypted open of a plaintext file
|
|
76
|
+
* converts it. The store keeps every row and its schema version. An
|
|
77
|
+
* encrypted open also finishes a conversion that stopped after its commit
|
|
78
|
+
* point, with or without the option.
|
|
79
|
+
*
|
|
58
80
|
* `close()` on the result closes the database and releases the name.
|
|
59
81
|
*
|
|
60
82
|
* @throws EncryptionError with `INVALID_STATE` when the name is not valid or
|
|
61
83
|
* its database already has an open store in this process, or when a newer
|
|
62
|
-
* SDK wrote the file.
|
|
84
|
+
* SDK wrote the file. Also when `convertPlaintext` comes with
|
|
85
|
+
* `encryptionAtRest: false`, when an open with `encryptionAtRest: false`
|
|
86
|
+
* finds an incomplete conversion, or when a plaintext file cannot be
|
|
87
|
+
* converted.
|
|
63
88
|
* @throws EncryptionError with `LOCAL_STORE_KEY_LOST` when the file exists
|
|
64
89
|
* and the vault holds no key for it.
|
|
65
90
|
* @throws EncryptionError with `KEY_STORAGE_ERROR` when the vault fails or
|
|
@@ -76,8 +101,15 @@ export declare function openSqliteStore(options: SqliteStoreOpenOptions): Promis
|
|
|
76
101
|
* {@link openSqliteStore} opens that state as a new store. The other order
|
|
77
102
|
* would leave the old file under a key that no longer exists.
|
|
78
103
|
*
|
|
104
|
+
* An encrypted reset also ends an incomplete conversion. It deletes the
|
|
105
|
+
* pending key first, then the temporary file, then the database. A process
|
|
106
|
+
* that stops after the key deletion cannot finish the conversion of the old
|
|
107
|
+
* data.
|
|
108
|
+
*
|
|
79
109
|
* @throws EncryptionError with `INVALID_STATE` when the name is not valid or
|
|
80
|
-
* its database already has an open store in this process.
|
|
110
|
+
* its database already has an open store in this process. Also when
|
|
111
|
+
* `convertPlaintext` comes with `encryptionAtRest: false`, or when a reset
|
|
112
|
+
* with `encryptionAtRest: false` finds an incomplete conversion.
|
|
81
113
|
*/
|
|
82
114
|
export declare function resetSqliteStore(options: SqliteStoreOpenOptions): Promise<SqliteRootExecutor>;
|
|
83
115
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"open-store.d.ts","sourceRoot":"","sources":["../../../../local/store/sqlite/open-store.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"open-store.d.ts","sourceRoot":"","sources":["../../../../local/store/sqlite/open-store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAGH,OAAO,KAAK,EAAE,oBAAoB,EAAE,8BAA8B,EAAE,MAAM,oBAAoB,CAAC;AAE/F,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAU7C,OAAO,EAA+C,KAAK,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEnG,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AASrD,2EAA2E;AAC3E,MAAM,WAAW,sBAAuB,SAAQ,iBAAiB;IAC/D,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B;;;OAGG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,6CAA6C;IAC7C,QAAQ,CAAC,KAAK,EAAE,8BAA8B,CAAC;IAC/C;;;;;OAKG;IACH,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,OAAO,CAAC,MAAM,IAAI,CAAC,CAAC;CACrD;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAE9D;AAUD;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,E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