@evolu/react-native 14.3.0 → 15.0.0-next.1
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/README.md +3 -3
- package/dist/src/LockManager.d.ts +13 -0
- package/dist/src/LockManager.d.ts.map +1 -0
- package/dist/src/LockManager.js +219 -0
- package/dist/src/Polyfills.d.ts +3 -0
- package/dist/src/Polyfills.d.ts.map +1 -0
- package/dist/src/Polyfills.js +209 -0
- package/dist/src/Task.d.ts +31 -0
- package/dist/src/Task.d.ts.map +1 -0
- package/dist/src/Task.js +46 -0
- package/dist/src/components/EvoluIdenticon.d.ts +9 -0
- package/dist/src/components/EvoluIdenticon.d.ts.map +1 -0
- package/dist/{components → src/components}/EvoluIdenticon.js +1 -1
- package/dist/src/createExpoDeps.d.ts +1 -0
- package/dist/src/createExpoDeps.d.ts.map +1 -0
- package/dist/src/createExpoDeps.js +163 -0
- package/dist/src/exports/bare-op-sqlite.d.ts +1 -0
- package/dist/src/exports/bare-op-sqlite.d.ts.map +1 -0
- package/dist/src/exports/bare-op-sqlite.js +31 -0
- package/dist/src/exports/expo-op-sqlite.d.ts +1 -0
- package/dist/src/exports/expo-op-sqlite.d.ts.map +1 -0
- package/dist/src/exports/expo-op-sqlite.js +16 -0
- package/dist/src/exports/expo-sqlite.d.ts +11 -0
- package/dist/src/exports/expo-sqlite.d.ts.map +1 -0
- package/dist/src/exports/expo-sqlite.js +24 -0
- package/dist/src/index.d.ts +4 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +3 -0
- package/dist/src/shared.d.ts +5 -0
- package/dist/src/shared.d.ts.map +1 -0
- package/dist/src/shared.js +90 -0
- package/dist/src/sqlite-drivers/createExpoSqliteDriver.d.ts +3 -0
- package/dist/src/sqlite-drivers/createExpoSqliteDriver.d.ts.map +1 -0
- package/dist/src/sqlite-drivers/createExpoSqliteDriver.js +134 -0
- package/dist/src/sqlite-drivers/createOpSqliteDriver.d.ts +3 -0
- package/dist/src/sqlite-drivers/createOpSqliteDriver.d.ts.map +1 -0
- package/dist/src/sqlite-drivers/createOpSqliteDriver.js +119 -0
- package/dist/src/web.d.ts.map +1 -0
- package/package.json +72 -48
- package/src/ErrorUtils.d.ts +19 -0
- package/src/LockManager.ts +325 -0
- package/src/Polyfills.ts +301 -0
- package/src/Task.ts +66 -0
- package/src/components/EvoluIdenticon.tsx +2 -2
- package/src/createExpoDeps.ts +162 -160
- package/src/exports/bare-op-sqlite.ts +30 -28
- package/src/exports/expo-op-sqlite.ts +15 -14
- package/src/exports/expo-sqlite.ts +21 -4
- package/src/index.ts +2 -0
- package/src/shared.ts +115 -49
- package/src/sqlite-drivers/createExpoSqliteDriver.ts +74 -51
- package/src/sqlite-drivers/createOpSqliteDriver.ts +62 -60
- package/dist/components/EvoluIdenticon.d.ts +0 -9
- package/dist/components/EvoluIdenticon.d.ts.map +0 -1
- package/dist/createExpoDeps.d.ts +0 -7
- package/dist/createExpoDeps.d.ts.map +0 -1
- package/dist/createExpoDeps.js +0 -123
- package/dist/exports/bare-op-sqlite.d.ts +0 -10
- package/dist/exports/bare-op-sqlite.d.ts.map +0 -1
- package/dist/exports/bare-op-sqlite.js +0 -24
- package/dist/exports/expo-op-sqlite.d.ts +0 -9
- package/dist/exports/expo-op-sqlite.d.ts.map +0 -1
- package/dist/exports/expo-op-sqlite.js +0 -12
- package/dist/exports/expo-sqlite.d.ts +0 -8
- package/dist/exports/expo-sqlite.d.ts.map +0 -1
- package/dist/exports/expo-sqlite.js +0 -11
- package/dist/index.d.ts +0 -2
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -1
- package/dist/shared.d.ts +0 -5
- package/dist/shared.d.ts.map +0 -1
- package/dist/shared.js +0 -39
- package/dist/sqlite-drivers/createExpoSqliteDriver.d.ts +0 -3
- package/dist/sqlite-drivers/createExpoSqliteDriver.d.ts.map +0 -1
- package/dist/sqlite-drivers/createExpoSqliteDriver.js +0 -46
- package/dist/sqlite-drivers/createOpSqliteDriver.d.ts +0 -3
- package/dist/sqlite-drivers/createOpSqliteDriver.d.ts.map +0 -1
- package/dist/sqlite-drivers/createOpSqliteDriver.js +0 -54
- package/dist/web.d.ts.map +0 -1
- /package/dist/{web.d.ts → src/web.d.ts} +0 -0
- /package/dist/{web.js → src/web.js} +0 -0
|
@@ -1,66 +1,89 @@
|
|
|
1
1
|
import {
|
|
2
2
|
bytesToHex,
|
|
3
3
|
createPreparedStatementsCache,
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
SqliteRow,
|
|
4
|
+
ok,
|
|
5
|
+
type CreateSqliteDriver,
|
|
6
|
+
type SqliteRow,
|
|
7
7
|
} from "@evolu/common";
|
|
8
|
-
import {
|
|
8
|
+
import {
|
|
9
|
+
deleteDatabaseSync,
|
|
10
|
+
openDatabaseSync,
|
|
11
|
+
type SQLiteStatement,
|
|
12
|
+
} from "expo-sqlite";
|
|
13
|
+
|
|
14
|
+
export const createExpoSqliteDriver: CreateSqliteDriver =
|
|
15
|
+
(name, options) => () => {
|
|
16
|
+
const databaseName = `evolu1-${name}.db`;
|
|
17
|
+
using disposer = new DisposableStack();
|
|
18
|
+
const db = disposer.adopt(
|
|
19
|
+
openDatabaseSync(options?.mode === "memory" ? ":memory:" : databaseName),
|
|
20
|
+
(db) => {
|
|
21
|
+
db.closeSync();
|
|
22
|
+
},
|
|
23
|
+
);
|
|
24
|
+
if (options?.mode === "encrypted") {
|
|
25
|
+
db.execSync(`PRAGMA key = "x'${bytesToHex(options.encryptionKey)}'"`);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const cache = disposer.use(
|
|
29
|
+
createPreparedStatementsCache<SQLiteStatement>(
|
|
30
|
+
(sql) => db.prepareSync(sql),
|
|
31
|
+
(statement) => {
|
|
32
|
+
statement.finalizeSync();
|
|
33
|
+
},
|
|
34
|
+
),
|
|
35
|
+
);
|
|
9
36
|
|
|
10
|
-
|
|
11
|
-
const db = openDatabaseSync(
|
|
12
|
-
options?.memory ? ":memory:" : `evolu1-${name}.db`,
|
|
13
|
-
);
|
|
14
|
-
if (options?.encryptionKey) {
|
|
15
|
-
db.execSync(`
|
|
16
|
-
PRAGMA cipher = 'sqlcipher';
|
|
17
|
-
PRAGMA legacy = 4;
|
|
18
|
-
PRAGMA key = "x'${bytesToHex(options.encryptionKey)}'";
|
|
19
|
-
`);
|
|
20
|
-
}
|
|
21
|
-
let isDisposed = false;
|
|
37
|
+
const disposables = disposer.move();
|
|
22
38
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
39
|
+
return ok({
|
|
40
|
+
exec: (query) => {
|
|
41
|
+
const execStatement = (statement: SQLiteStatement) => {
|
|
42
|
+
const result = statement.executeSync(query.parameters);
|
|
43
|
+
try {
|
|
44
|
+
const rows = result.getAllSync();
|
|
45
|
+
const changes = result.changes;
|
|
46
|
+
return { rows: rows as Array<SqliteRow>, changes };
|
|
47
|
+
} finally {
|
|
48
|
+
result.resetSync();
|
|
49
|
+
}
|
|
50
|
+
};
|
|
29
51
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
const prepared = cache.get(query);
|
|
52
|
+
const prepared = cache.get(query);
|
|
53
|
+
if (prepared) return execStatement(prepared);
|
|
33
54
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
55
|
+
const statement = db.prepareSync(query.sql);
|
|
56
|
+
try {
|
|
57
|
+
return execStatement(statement);
|
|
58
|
+
} finally {
|
|
59
|
+
statement.finalizeSync();
|
|
38
60
|
}
|
|
61
|
+
},
|
|
39
62
|
|
|
40
|
-
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
return { rows: rows as Array<SqliteRow>, changes: 0 };
|
|
44
|
-
}
|
|
63
|
+
export: () => {
|
|
64
|
+
const file = db.serializeSync();
|
|
65
|
+
const { buffer } = file;
|
|
45
66
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
67
|
+
if (buffer instanceof ArrayBuffer) {
|
|
68
|
+
return new Uint8Array(buffer, file.byteOffset, file.byteLength);
|
|
69
|
+
}
|
|
50
70
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
71
|
+
// Ensure export uses transferable ArrayBuffer backing.
|
|
72
|
+
return new Uint8Array(file);
|
|
73
|
+
},
|
|
54
74
|
|
|
55
|
-
|
|
75
|
+
deleteDatabase: () => {
|
|
76
|
+
using deleteDisposer = new DisposableStack();
|
|
77
|
+
if (options?.mode !== "memory") {
|
|
78
|
+
deleteDisposer.defer(() => {
|
|
79
|
+
deleteDatabaseSync(databaseName);
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
deleteDisposer.use(disposables);
|
|
83
|
+
},
|
|
56
84
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
db.closeSync();
|
|
62
|
-
},
|
|
85
|
+
[Symbol.dispose]: () => {
|
|
86
|
+
disposables.dispose();
|
|
87
|
+
},
|
|
88
|
+
});
|
|
63
89
|
};
|
|
64
|
-
|
|
65
|
-
return Promise.resolve(driver);
|
|
66
|
-
};
|
|
@@ -1,74 +1,76 @@
|
|
|
1
1
|
import {
|
|
2
2
|
bytesToHex,
|
|
3
|
-
constVoid,
|
|
4
3
|
createPreparedStatementsCache,
|
|
5
|
-
CreateSqliteDriver,
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
SqliteRow,
|
|
4
|
+
type CreateSqliteDriver,
|
|
5
|
+
lazyVoid,
|
|
6
|
+
ok,
|
|
7
|
+
type SqliteRow,
|
|
9
8
|
} from "@evolu/common";
|
|
10
|
-
import { open, PreparedStatement } from "@op-engineering/op-sqlite";
|
|
9
|
+
import { open, type PreparedStatement } from "@op-engineering/op-sqlite";
|
|
11
10
|
|
|
12
|
-
export const createOpSqliteDriver: CreateSqliteDriver =
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
11
|
+
export const createOpSqliteDriver: CreateSqliteDriver =
|
|
12
|
+
(name, options) => () => {
|
|
13
|
+
// https://op-engineering.github.io/op-sqlite/docs/configuration#in-memory
|
|
14
|
+
using disposer = new DisposableStack();
|
|
15
|
+
const db = disposer.adopt(
|
|
16
|
+
open(
|
|
17
|
+
options?.mode === "memory"
|
|
18
|
+
? { name: `inMemoryDb`, location: ":memory:" }
|
|
19
|
+
: {
|
|
20
|
+
name: `evolu1-${name}.db`,
|
|
21
|
+
...(options?.mode === "encrypted" && {
|
|
22
|
+
encryptionKey: `x'${bytesToHex(options.encryptionKey)}'`,
|
|
23
|
+
}),
|
|
24
|
+
},
|
|
25
|
+
),
|
|
26
|
+
(db) => {
|
|
27
|
+
db.close();
|
|
28
|
+
},
|
|
29
|
+
);
|
|
25
30
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
+
const cache = disposer.use(
|
|
32
|
+
createPreparedStatementsCache<PreparedStatement>(
|
|
33
|
+
(sql) => db.prepareStatement(sql),
|
|
34
|
+
// op-sqlite doesn't have API for that
|
|
35
|
+
lazyVoid,
|
|
36
|
+
),
|
|
37
|
+
);
|
|
31
38
|
|
|
32
|
-
|
|
33
|
-
exec: (query, isMutation) => {
|
|
34
|
-
const prepared = cache.get(query);
|
|
39
|
+
const disposables = disposer.move();
|
|
35
40
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
return { rows: [], changes };
|
|
41
|
+
return ok({
|
|
42
|
+
exec: (query) => {
|
|
43
|
+
const prepared = cache.get(query);
|
|
44
|
+
|
|
45
|
+
if (prepared) {
|
|
46
|
+
prepared.bindSync(query.parameters);
|
|
43
47
|
}
|
|
44
|
-
const { rows } = db.executeSync(query.sql, query.parameters);
|
|
45
|
-
return { rows: rows as Array<SqliteRow>, changes: 0 };
|
|
46
|
-
}
|
|
47
48
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
return { rows:
|
|
53
|
-
}
|
|
49
|
+
const { rows, rowsAffected } = db.executeSync(
|
|
50
|
+
query.sql,
|
|
51
|
+
query.parameters,
|
|
52
|
+
);
|
|
53
|
+
return { rows: rows as Array<SqliteRow>, changes: rowsAffected };
|
|
54
|
+
},
|
|
54
55
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
56
|
+
// FIXME: op-sqlite does not expose binary, but a path to the database file
|
|
57
|
+
// another react native dependency would be needed to implement this
|
|
58
|
+
export: () => {
|
|
59
|
+
throw new Error("TODO: Not implemented yet");
|
|
60
|
+
},
|
|
58
61
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
62
|
+
deleteDatabase: () => {
|
|
63
|
+
using deleteDisposer = new DisposableStack();
|
|
64
|
+
if (options?.mode !== "memory") {
|
|
65
|
+
deleteDisposer.defer(() => {
|
|
66
|
+
db.delete();
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
deleteDisposer.use(disposables);
|
|
70
|
+
},
|
|
64
71
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
db.close();
|
|
70
|
-
},
|
|
72
|
+
[Symbol.dispose]: () => {
|
|
73
|
+
disposables.dispose();
|
|
74
|
+
},
|
|
75
|
+
});
|
|
71
76
|
};
|
|
72
|
-
|
|
73
|
-
return Promise.resolve(driver);
|
|
74
|
-
};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { IdenticonStyle, OwnerId } from "@evolu/common";
|
|
2
|
-
import { FC } from "react";
|
|
3
|
-
export declare const EvoluIdenticon: FC<{
|
|
4
|
-
id: OwnerId;
|
|
5
|
-
size?: number;
|
|
6
|
-
borderRadius?: number;
|
|
7
|
-
style?: IdenticonStyle;
|
|
8
|
-
}>;
|
|
9
|
-
//# sourceMappingURL=EvoluIdenticon.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"EvoluIdenticon.d.ts","sourceRoot":"","sources":["../../src/components/EvoluIdenticon.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAmB,cAAc,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACzE,OAAO,EAAE,EAAE,EAAW,MAAM,OAAO,CAAC;AAIpC,eAAO,MAAM,cAAc,EAAE,EAAE,CAAC;IAC9B,EAAE,EAAE,OAAO,CAAC;IACZ,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,KAAK,CAAC,EAAE,cAAc,CAAC;CACxB,CAcA,CAAC"}
|
package/dist/createExpoDeps.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { CreateSqliteDriverDep, LocalAuth } from "@evolu/common";
|
|
2
|
-
import { EvoluDeps } from "@evolu/common/local-first";
|
|
3
|
-
export declare const createExpoDeps: (deps: CreateSqliteDriverDep) => {
|
|
4
|
-
evoluReactNativeDeps: EvoluDeps;
|
|
5
|
-
localAuth: LocalAuth;
|
|
6
|
-
};
|
|
7
|
-
//# sourceMappingURL=createExpoDeps.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createExpoDeps.d.ts","sourceRoot":"","sources":["../src/createExpoDeps.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AACjE,OAAO,EAAE,SAAS,EAAa,MAAM,2BAA2B,CAAC;AAwJjE,eAAO,MAAM,cAAc,GACzB,MAAM,qBAAqB,KAC1B;IAAE,oBAAoB,EAAE,SAAS,CAAC;IAAC,SAAS,EAAE,SAAS,CAAA;CAMxD,CAAC"}
|
package/dist/createExpoDeps.js
DELETED
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
import * as Expo from "expo";
|
|
2
|
-
import { createSharedEvoluDeps, createSharedLocalAuth } from "./shared.js";
|
|
3
|
-
import { localAuthDefaultOptions } from "@evolu/common";
|
|
4
|
-
import * as SecureStore from "expo-secure-store";
|
|
5
|
-
import KVStore from "expo-sqlite/kv-store";
|
|
6
|
-
const reloadApp = () => {
|
|
7
|
-
void Expo.reloadAppAsync();
|
|
8
|
-
};
|
|
9
|
-
const createSecureStore = () => {
|
|
10
|
-
const store = {
|
|
11
|
-
setItem: async (key, value, options) => {
|
|
12
|
-
const rnsiOpts = convertOptions(options);
|
|
13
|
-
const service = options?.service ?? "default";
|
|
14
|
-
const metadata = createMetadata(options?.accessControl === "none");
|
|
15
|
-
await KVStore.setItem(`${service}-${key}`, "1");
|
|
16
|
-
await SecureStore.setItemAsync(key, JSON.stringify({ value, metadata }), rnsiOpts);
|
|
17
|
-
return { metadata };
|
|
18
|
-
},
|
|
19
|
-
getItem: async (key, options) => {
|
|
20
|
-
const rnsiOpts = convertOptions(options);
|
|
21
|
-
const service = options?.service ?? "default";
|
|
22
|
-
let data;
|
|
23
|
-
try {
|
|
24
|
-
const result = await SecureStore.getItemAsync(key, rnsiOpts);
|
|
25
|
-
if (!result)
|
|
26
|
-
return null;
|
|
27
|
-
data = JSON.parse(result);
|
|
28
|
-
}
|
|
29
|
-
catch (_error) {
|
|
30
|
-
return null;
|
|
31
|
-
}
|
|
32
|
-
return { key, service, ...data };
|
|
33
|
-
},
|
|
34
|
-
deleteItem: async (key, options) => {
|
|
35
|
-
const rnsiOpts = convertOptions(options);
|
|
36
|
-
const service = options?.service ?? "default";
|
|
37
|
-
await Promise.all([
|
|
38
|
-
KVStore.removeItemAsync(`${service}-${key}`),
|
|
39
|
-
SecureStore.deleteItemAsync(key, rnsiOpts),
|
|
40
|
-
]);
|
|
41
|
-
return true;
|
|
42
|
-
},
|
|
43
|
-
getAllItems: async (options) => {
|
|
44
|
-
const keys = await KVStore.getAllKeysAsync();
|
|
45
|
-
const service = options?.service ?? "default";
|
|
46
|
-
const metadata = createMetadata(options?.accessControl === "none");
|
|
47
|
-
return keys
|
|
48
|
-
.filter((key) => key.startsWith(`${service}-`))
|
|
49
|
-
.map((key) => ({
|
|
50
|
-
key: key.slice(service.length + 1),
|
|
51
|
-
service,
|
|
52
|
-
metadata,
|
|
53
|
-
}));
|
|
54
|
-
},
|
|
55
|
-
clearService: async (options) => {
|
|
56
|
-
const rnsiOpts = convertOptions(options);
|
|
57
|
-
const service = options?.service ?? "default";
|
|
58
|
-
const items = await store.getAllItems(options);
|
|
59
|
-
await KVStore.multiRemove(items.map((item) => `${service}-${item.key}`));
|
|
60
|
-
await Promise.all(items.map(async (item) => {
|
|
61
|
-
await SecureStore.deleteItemAsync(item.key, rnsiOpts);
|
|
62
|
-
}));
|
|
63
|
-
},
|
|
64
|
-
};
|
|
65
|
-
return store;
|
|
66
|
-
};
|
|
67
|
-
/**
|
|
68
|
-
* Create default metadata for backwards compatibility with items that don't
|
|
69
|
-
* have stored metadata.
|
|
70
|
-
*/
|
|
71
|
-
const createMetadata = (isSecure = true) => {
|
|
72
|
-
return {
|
|
73
|
-
backend: "keychain",
|
|
74
|
-
accessControl: isSecure ? "biometryCurrentSet" : "none",
|
|
75
|
-
securityLevel: isSecure ? "biometry" : "software",
|
|
76
|
-
timestamp: Date.now(),
|
|
77
|
-
};
|
|
78
|
-
};
|
|
79
|
-
function convertOptions(options) {
|
|
80
|
-
const accessGroup = options?.keychainGroup ?? localAuthDefaultOptions.keychainGroup ?? "";
|
|
81
|
-
const keychainService = options?.service ?? localAuthDefaultOptions.service ?? "";
|
|
82
|
-
const keychainAccessible = convertKeychainAccessible(options?.accessControl ??
|
|
83
|
-
localAuthDefaultOptions.accessControl ??
|
|
84
|
-
"biometryCurrentSet");
|
|
85
|
-
const authenticationPrompt = options?.authenticationPrompt?.title ??
|
|
86
|
-
localAuthDefaultOptions.authenticationPrompt?.title ??
|
|
87
|
-
"";
|
|
88
|
-
return {
|
|
89
|
-
accessGroup,
|
|
90
|
-
keychainService,
|
|
91
|
-
keychainAccessible,
|
|
92
|
-
authenticationPrompt,
|
|
93
|
-
requireAuthentication: options?.accessControl !== "none",
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
function convertKeychainAccessible(accessControl) {
|
|
97
|
-
switch (accessControl) {
|
|
98
|
-
case "none":
|
|
99
|
-
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
100
|
-
return SecureStore.ALWAYS;
|
|
101
|
-
case "biometryCurrentSet":
|
|
102
|
-
return SecureStore.AFTER_FIRST_UNLOCK;
|
|
103
|
-
case "biometryAny":
|
|
104
|
-
return SecureStore.AFTER_FIRST_UNLOCK;
|
|
105
|
-
case "devicePasscode":
|
|
106
|
-
return SecureStore.AFTER_FIRST_UNLOCK;
|
|
107
|
-
case "secureEnclaveBiometry":
|
|
108
|
-
return SecureStore.AFTER_FIRST_UNLOCK;
|
|
109
|
-
// Exhaustive check
|
|
110
|
-
default:
|
|
111
|
-
accessControl;
|
|
112
|
-
// Default (for typescript, should never hit)
|
|
113
|
-
return SecureStore.AFTER_FIRST_UNLOCK;
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
const localAuth = createSharedLocalAuth(createSecureStore());
|
|
117
|
-
export const createExpoDeps = (deps) => ({
|
|
118
|
-
evoluReactNativeDeps: createSharedEvoluDeps({
|
|
119
|
-
...deps,
|
|
120
|
-
reloadApp,
|
|
121
|
-
}),
|
|
122
|
-
localAuth,
|
|
123
|
-
});
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Public entry point for bare React Native with OP-SQLite. Exported as
|
|
3
|
-
* "@evolu/react-native/bare-op-sqlite" in package.json.
|
|
4
|
-
*
|
|
5
|
-
* Use this with bare React Native projects (not Expo) that use
|
|
6
|
-
* `@op-engineering/op-sqlite`.
|
|
7
|
-
*/
|
|
8
|
-
export declare const evoluReactNativeDeps: import("@evolu/common").EvoluDeps;
|
|
9
|
-
export declare const localAuth: import("@evolu/common").LocalAuth;
|
|
10
|
-
//# sourceMappingURL=bare-op-sqlite.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bare-op-sqlite.d.ts","sourceRoot":"","sources":["../../src/exports/bare-op-sqlite.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAgBH,eAAO,MAAM,oBAAoB,mCAG/B,CAAC;AAEH,eAAO,MAAM,SAAS,mCAAuC,CAAC"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Public entry point for bare React Native with OP-SQLite. Exported as
|
|
3
|
-
* "@evolu/react-native/bare-op-sqlite" in package.json.
|
|
4
|
-
*
|
|
5
|
-
* Use this with bare React Native projects (not Expo) that use
|
|
6
|
-
* `@op-engineering/op-sqlite`.
|
|
7
|
-
*/
|
|
8
|
-
import { DevSettings } from "react-native";
|
|
9
|
-
import { SensitiveInfo } from "react-native-sensitive-info";
|
|
10
|
-
import { createSharedEvoluDeps, createSharedLocalAuth } from "../shared.js";
|
|
11
|
-
import { createOpSqliteDriver } from "../sqlite-drivers/createOpSqliteDriver.js";
|
|
12
|
-
const reloadApp = () => {
|
|
13
|
-
if (process.env.NODE_ENV === "development") {
|
|
14
|
-
DevSettings.reload();
|
|
15
|
-
}
|
|
16
|
-
else {
|
|
17
|
-
// TODO: reload not implemented for bare rn
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
export const evoluReactNativeDeps = createSharedEvoluDeps({
|
|
21
|
-
createSqliteDriver: createOpSqliteDriver,
|
|
22
|
-
reloadApp,
|
|
23
|
-
});
|
|
24
|
-
export const localAuth = createSharedLocalAuth(SensitiveInfo);
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Public entry point for Expo with OP-SQLite. Exported as
|
|
3
|
-
* "@evolu/react-native/expo-op-sqlite" in package.json.
|
|
4
|
-
*
|
|
5
|
-
* Use this with Expo projects that use `@op-engineering/op-sqlite` for better
|
|
6
|
-
* performance.
|
|
7
|
-
*/
|
|
8
|
-
export declare const evoluReactNativeDeps: import("@evolu/common").EvoluDeps, localAuth: import("@evolu/common").LocalAuth;
|
|
9
|
-
//# sourceMappingURL=expo-op-sqlite.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"expo-op-sqlite.d.ts","sourceRoot":"","sources":["../../src/exports/expo-op-sqlite.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH,eAAO,MAAQ,oBAAoB,qCAAE,SAAS,mCAE5C,CAAC"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Public entry point for Expo with OP-SQLite. Exported as
|
|
3
|
-
* "@evolu/react-native/expo-op-sqlite" in package.json.
|
|
4
|
-
*
|
|
5
|
-
* Use this with Expo projects that use `@op-engineering/op-sqlite` for better
|
|
6
|
-
* performance.
|
|
7
|
-
*/
|
|
8
|
-
import { createExpoDeps } from "../createExpoDeps.js";
|
|
9
|
-
import { createOpSqliteDriver } from "../sqlite-drivers/createOpSqliteDriver.js";
|
|
10
|
-
export const { evoluReactNativeDeps, localAuth } = createExpoDeps({
|
|
11
|
-
createSqliteDriver: createOpSqliteDriver,
|
|
12
|
-
});
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Public entry point for Expo SQLite. Exported as
|
|
3
|
-
* "@evolu/react-native/expo-sqlite" in package.json.
|
|
4
|
-
*
|
|
5
|
-
* Use this with Expo projects that use expo-sqlite.
|
|
6
|
-
*/
|
|
7
|
-
export declare const evoluReactNativeDeps: import("@evolu/common").EvoluDeps, localAuth: import("@evolu/common").LocalAuth;
|
|
8
|
-
//# sourceMappingURL=expo-sqlite.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"expo-sqlite.d.ts","sourceRoot":"","sources":["../../src/exports/expo-sqlite.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,eAAO,MAAQ,oBAAoB,qCAAE,SAAS,mCAE5C,CAAC"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Public entry point for Expo SQLite. Exported as
|
|
3
|
-
* "@evolu/react-native/expo-sqlite" in package.json.
|
|
4
|
-
*
|
|
5
|
-
* Use this with Expo projects that use expo-sqlite.
|
|
6
|
-
*/
|
|
7
|
-
import { createExpoDeps } from "../createExpoDeps.js";
|
|
8
|
-
import { createExpoSqliteDriver } from "../sqlite-drivers/createExpoSqliteDriver.js";
|
|
9
|
-
export const { evoluReactNativeDeps, localAuth } = createExpoDeps({
|
|
10
|
-
createSqliteDriver: createExpoSqliteDriver,
|
|
11
|
-
});
|
package/dist/index.d.ts
DELETED
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gCAAgC,CAAC"}
|
package/dist/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./components/EvoluIdenticon.js";
|
package/dist/shared.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { CreateSqliteDriverDep, LocalAuth, SecureStorage } from "@evolu/common";
|
|
2
|
-
import { EvoluDeps, ReloadAppDep } from "@evolu/common/local-first";
|
|
3
|
-
export declare const createSharedEvoluDeps: (deps: CreateSqliteDriverDep & ReloadAppDep) => EvoluDeps;
|
|
4
|
-
export declare const createSharedLocalAuth: (secureStorage: SecureStorage) => LocalAuth;
|
|
5
|
-
//# sourceMappingURL=shared.d.ts.map
|
package/dist/shared.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../src/shared.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,qBAAqB,EAGrB,SAAS,EACT,aAAa,EACd,MAAM,eAAe,CAAC;AACvB,OAAO,EAEL,SAAS,EACT,YAAY,EACb,MAAM,2BAA2B,CAAC;AAuBnC,eAAO,MAAM,qBAAqB,GAChC,MAAM,qBAAqB,GAAG,YAAY,KACzC,SAcD,CAAC;AAEH,eAAO,MAAM,qBAAqB,GAChC,eAAe,aAAa,KAC3B,SAIC,CAAC"}
|
package/dist/shared.js
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { createConsole, createLocalAuth, createRandom, createRandomBytes, createTime, createWebSocket, } from "@evolu/common";
|
|
2
|
-
import { createDbWorkerForPlatform, } from "@evolu/common/local-first";
|
|
3
|
-
/**
|
|
4
|
-
* Polyfills `Promise.withResolvers`.
|
|
5
|
-
*
|
|
6
|
-
* @see https://github.com/facebook/hermes/pull/1452
|
|
7
|
-
*/
|
|
8
|
-
if (typeof Promise.withResolvers === "undefined") {
|
|
9
|
-
// @ts-expect-error This is OK.
|
|
10
|
-
Promise.withResolvers = function () {
|
|
11
|
-
let resolve, reject;
|
|
12
|
-
const promise = new Promise((res, rej) => {
|
|
13
|
-
resolve = res;
|
|
14
|
-
reject = rej;
|
|
15
|
-
});
|
|
16
|
-
return { promise, resolve, reject };
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
const console = createConsole();
|
|
20
|
-
const randomBytes = createRandomBytes();
|
|
21
|
-
const time = createTime();
|
|
22
|
-
export const createSharedEvoluDeps = (deps) => ({
|
|
23
|
-
...deps,
|
|
24
|
-
console,
|
|
25
|
-
createDbWorker: () => createDbWorkerForPlatform({
|
|
26
|
-
...deps,
|
|
27
|
-
console,
|
|
28
|
-
createWebSocket,
|
|
29
|
-
random: createRandom(),
|
|
30
|
-
randomBytes,
|
|
31
|
-
time,
|
|
32
|
-
}),
|
|
33
|
-
randomBytes,
|
|
34
|
-
time,
|
|
35
|
-
});
|
|
36
|
-
export const createSharedLocalAuth = (secureStorage) => createLocalAuth({
|
|
37
|
-
randomBytes,
|
|
38
|
-
secureStorage,
|
|
39
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createExpoSqliteDriver.d.ts","sourceRoot":"","sources":["../../src/sqlite-drivers/createExpoSqliteDriver.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,kBAAkB,EAGnB,MAAM,eAAe,CAAC;AAGvB,eAAO,MAAM,sBAAsB,EAAE,kBAwDpC,CAAC"}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { bytesToHex, createPreparedStatementsCache, } from "@evolu/common";
|
|
2
|
-
import { openDatabaseSync } from "expo-sqlite";
|
|
3
|
-
export const createExpoSqliteDriver = (name, options) => {
|
|
4
|
-
const db = openDatabaseSync(options?.memory ? ":memory:" : `evolu1-${name}.db`);
|
|
5
|
-
if (options?.encryptionKey) {
|
|
6
|
-
db.execSync(`
|
|
7
|
-
PRAGMA cipher = 'sqlcipher';
|
|
8
|
-
PRAGMA legacy = 4;
|
|
9
|
-
PRAGMA key = "x'${bytesToHex(options.encryptionKey)}'";
|
|
10
|
-
`);
|
|
11
|
-
}
|
|
12
|
-
let isDisposed = false;
|
|
13
|
-
const cache = createPreparedStatementsCache((sql) => db.prepareSync(sql), (statement) => {
|
|
14
|
-
statement.finalizeSync();
|
|
15
|
-
});
|
|
16
|
-
const driver = {
|
|
17
|
-
exec: (query, isMutation) => {
|
|
18
|
-
const prepared = cache.get(query);
|
|
19
|
-
if (prepared) {
|
|
20
|
-
if (isMutation) {
|
|
21
|
-
const { changes } = prepared.executeSync(query.parameters);
|
|
22
|
-
return { rows: [], changes };
|
|
23
|
-
}
|
|
24
|
-
const result = prepared.executeSync(query.parameters);
|
|
25
|
-
const rows = result.getAllSync();
|
|
26
|
-
result.resetSync();
|
|
27
|
-
return { rows: rows, changes: 0 };
|
|
28
|
-
}
|
|
29
|
-
if (isMutation) {
|
|
30
|
-
const { changes } = db.runSync(query.sql, query.parameters);
|
|
31
|
-
return { rows: [], changes };
|
|
32
|
-
}
|
|
33
|
-
const rows = db.getAllSync(query.sql, query.parameters);
|
|
34
|
-
return { rows: rows, changes: 0 };
|
|
35
|
-
},
|
|
36
|
-
export: () => db.serializeSync(),
|
|
37
|
-
[Symbol.dispose]: () => {
|
|
38
|
-
if (isDisposed)
|
|
39
|
-
return;
|
|
40
|
-
isDisposed = true;
|
|
41
|
-
cache[Symbol.dispose]();
|
|
42
|
-
db.closeSync();
|
|
43
|
-
},
|
|
44
|
-
};
|
|
45
|
-
return Promise.resolve(driver);
|
|
46
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createOpSqliteDriver.d.ts","sourceRoot":"","sources":["../../src/sqlite-drivers/createOpSqliteDriver.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,kBAAkB,EAInB,MAAM,eAAe,CAAC;AAGvB,eAAO,MAAM,oBAAoB,EAAE,kBA8DlC,CAAC"}
|