@evolu/react-native 14.2.0 → 15.0.0-next.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/README.md +3 -3
- 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/Worker.d.ts +30 -0
- package/dist/src/Worker.d.ts.map +1 -0
- package/dist/src/Worker.js +29 -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 +87 -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 +51 -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 +37 -0
- package/dist/src/web.d.ts.map +1 -0
- package/package.json +73 -52
- package/src/ErrorUtils.d.ts +19 -0
- package/src/Polyfills.ts +305 -0
- package/src/Task.ts +66 -0
- package/src/Worker.ts +54 -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 +113 -52
- package/src/sqlite-drivers/createExpoSqliteDriver.ts +59 -51
- package/src/sqlite-drivers/createOpSqliteDriver.ts +51 -61
- package/LICENSE +0 -21
- 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,74 @@
|
|
|
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
8
|
import { openDatabaseSync, SQLiteStatement } from "expo-sqlite";
|
|
9
9
|
|
|
10
|
-
export const createExpoSqliteDriver: CreateSqliteDriver =
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
10
|
+
export const createExpoSqliteDriver: CreateSqliteDriver =
|
|
11
|
+
(name, options) => () => {
|
|
12
|
+
const stack = new globalThis.DisposableStack();
|
|
13
|
+
const db = stack.adopt(
|
|
14
|
+
openDatabaseSync(
|
|
15
|
+
options?.mode === "memory" ? ":memory:" : `evolu1-${name}.db`,
|
|
16
|
+
),
|
|
17
|
+
(db) => {
|
|
18
|
+
db.closeSync();
|
|
19
|
+
},
|
|
20
|
+
);
|
|
21
|
+
if (options?.mode === "encrypted") {
|
|
22
|
+
db.execSync(`PRAGMA key = "x'${bytesToHex(options.encryptionKey)}'"`);
|
|
23
|
+
}
|
|
22
24
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
const cache = stack.use(
|
|
26
|
+
createPreparedStatementsCache<SQLiteStatement>(
|
|
27
|
+
(sql) => db.prepareSync(sql),
|
|
28
|
+
(statement) => {
|
|
29
|
+
statement.finalizeSync();
|
|
30
|
+
},
|
|
31
|
+
),
|
|
32
|
+
);
|
|
29
33
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
34
|
+
return ok({
|
|
35
|
+
exec: (query) => {
|
|
36
|
+
const execStatement = (statement: SQLiteStatement) => {
|
|
37
|
+
const result = statement.executeSync(query.parameters);
|
|
38
|
+
try {
|
|
39
|
+
const rows = result.getAllSync();
|
|
40
|
+
const changes = result.changes;
|
|
41
|
+
return { rows: rows as Array<SqliteRow>, changes };
|
|
42
|
+
} finally {
|
|
43
|
+
result.resetSync();
|
|
44
|
+
}
|
|
45
|
+
};
|
|
33
46
|
|
|
34
|
-
|
|
35
|
-
if (
|
|
36
|
-
const { changes } = prepared.executeSync(query.parameters);
|
|
37
|
-
return { rows: [], changes };
|
|
38
|
-
}
|
|
47
|
+
const prepared = cache.get(query);
|
|
48
|
+
if (prepared) return execStatement(prepared);
|
|
39
49
|
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
50
|
+
const statement = db.prepareSync(query.sql);
|
|
51
|
+
try {
|
|
52
|
+
return execStatement(statement);
|
|
53
|
+
} finally {
|
|
54
|
+
statement.finalizeSync();
|
|
55
|
+
}
|
|
56
|
+
},
|
|
45
57
|
|
|
46
|
-
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
}
|
|
58
|
+
export: () => {
|
|
59
|
+
const file = db.serializeSync();
|
|
60
|
+
const { buffer } = file;
|
|
50
61
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
62
|
+
if (buffer instanceof ArrayBuffer) {
|
|
63
|
+
return new Uint8Array(buffer, file.byteOffset, file.byteLength);
|
|
64
|
+
}
|
|
54
65
|
|
|
55
|
-
|
|
66
|
+
// Ensure export uses transferable ArrayBuffer backing.
|
|
67
|
+
return new Uint8Array(file);
|
|
68
|
+
},
|
|
56
69
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
db.closeSync();
|
|
62
|
-
},
|
|
70
|
+
[Symbol.dispose]: () => {
|
|
71
|
+
stack.dispose();
|
|
72
|
+
},
|
|
73
|
+
});
|
|
63
74
|
};
|
|
64
|
-
|
|
65
|
-
return Promise.resolve(driver);
|
|
66
|
-
};
|
|
@@ -1,74 +1,64 @@
|
|
|
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
|
+
const stack = new globalThis.DisposableStack();
|
|
15
|
+
const db = stack.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 = stack.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
|
-
|
|
34
|
-
|
|
39
|
+
return ok({
|
|
40
|
+
exec: (query) => {
|
|
41
|
+
const prepared = cache.get(query);
|
|
35
42
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
if (isSqlMutation(query.sql)) {
|
|
39
|
-
let changes = 0;
|
|
40
|
-
const { rowsAffected } = db.executeSync(query.sql, query.parameters);
|
|
41
|
-
changes += rowsAffected;
|
|
42
|
-
return { rows: [], changes };
|
|
43
|
+
if (prepared) {
|
|
44
|
+
prepared.bindSync(query.parameters);
|
|
43
45
|
}
|
|
44
|
-
const { rows } = db.executeSync(query.sql, query.parameters);
|
|
45
|
-
return { rows: rows as Array<SqliteRow>, changes: 0 };
|
|
46
|
-
}
|
|
47
46
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
return { rows:
|
|
53
|
-
}
|
|
47
|
+
const { rows, rowsAffected } = db.executeSync(
|
|
48
|
+
query.sql,
|
|
49
|
+
query.parameters,
|
|
50
|
+
);
|
|
51
|
+
return { rows: rows as Array<SqliteRow>, changes: rowsAffected };
|
|
52
|
+
},
|
|
54
53
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
54
|
+
// FIXME: op-sqlite does not expose binary, but a path to the database file
|
|
55
|
+
// another react native dependency would be needed to implement this
|
|
56
|
+
export: () => {
|
|
57
|
+
throw new Error("TODO: Not implemented yet");
|
|
58
|
+
},
|
|
58
59
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
},
|
|
64
|
-
|
|
65
|
-
[Symbol.dispose]: () => {
|
|
66
|
-
if (isDisposed) return;
|
|
67
|
-
isDisposed = true;
|
|
68
|
-
cache[Symbol.dispose]();
|
|
69
|
-
db.close();
|
|
70
|
-
},
|
|
60
|
+
[Symbol.dispose]: () => {
|
|
61
|
+
stack.dispose();
|
|
62
|
+
},
|
|
63
|
+
});
|
|
71
64
|
};
|
|
72
|
-
|
|
73
|
-
return Promise.resolve(driver);
|
|
74
|
-
};
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
The MIT License (MIT)
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2023 Evolu
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
@@ -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"}
|