@syncular/tauri 0.15.7 → 0.15.9
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/dist/index.d.ts +6 -1
- package/dist/index.js +14 -0
- package/package.json +3 -3
- package/src/index.ts +23 -0
package/dist/index.d.ts
CHANGED
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
* `invoke`/`listen` either from its ESM entry points, from the ambient
|
|
27
27
|
* `window.__TAURI__`, or via injected doubles (tests).
|
|
28
28
|
*/
|
|
29
|
-
import type { ClientChangeListener, CommitOutcome, CommitOutcomeQuery, ConflictRecord, InvalidationListener, LeaseState, MutationInput, PresencePeer, QueryReadSpec, QuerySnapshot, RejectionRecord, ResolveCommitOutcomeInput, SchemaFloor, SqlRow, SqlValue, SyncStatusSnapshot, WindowBase, WindowState } from '@syncular/client';
|
|
29
|
+
import type { ClientChangeListener, CommitOutcome, CommitOutcomeQuery, ConflictRecord, EncryptionKeyringConfig, InvalidationListener, LeaseState, MutationInput, PresencePeer, QueryReadSpec, QuerySnapshot, RejectionRecord, ResolveCommitOutcomeInput, SchemaFloor, SqlRow, SqlValue, SyncStatusSnapshot, WindowBase, WindowState } from '@syncular/client';
|
|
30
30
|
/** One event pushed on `syncular://event` (the derived client-observable set). */
|
|
31
31
|
interface SyncularEvent {
|
|
32
32
|
readonly type: string;
|
|
@@ -53,6 +53,11 @@ export interface TauriSyncClientConfig {
|
|
|
53
53
|
readonly clientId?: string;
|
|
54
54
|
/** §4.2 client limits, forwarded to the native `create`. */
|
|
55
55
|
readonly limits?: Record<string, unknown>;
|
|
56
|
+
/**
|
|
57
|
+
* Portable E2EE keys and declarative per-row key-id columns. Raw keys are
|
|
58
|
+
* encoded into the native command envelope and never sent to the server.
|
|
59
|
+
*/
|
|
60
|
+
readonly encryption?: EncryptionKeyringConfig;
|
|
56
61
|
/**
|
|
57
62
|
* The Tauri primitives. Omit in a real Tauri webview to auto-resolve from
|
|
58
63
|
* `@tauri-apps/api` (peer dep) or the ambient `window.__TAURI__`; inject in
|
package/dist/index.js
CHANGED
|
@@ -78,6 +78,17 @@ function encodeJsonValue(value) {
|
|
|
78
78
|
}
|
|
79
79
|
return value;
|
|
80
80
|
}
|
|
81
|
+
function encodeEncryption(config) {
|
|
82
|
+
return {
|
|
83
|
+
keys: Object.fromEntries(Object.entries(config.keys).map(([keyId, key]) => [
|
|
84
|
+
keyId,
|
|
85
|
+
{ $bytes: bytesToHex(key) },
|
|
86
|
+
])),
|
|
87
|
+
...(config.keyIdColumns !== undefined
|
|
88
|
+
? { keyIdColumns: config.keyIdColumns }
|
|
89
|
+
: {}),
|
|
90
|
+
};
|
|
91
|
+
}
|
|
81
92
|
/** Decode one query-result cell back to an `SqlValue` (`{$bytes}` → bytes). */
|
|
82
93
|
function decodeCell(value) {
|
|
83
94
|
if (isBytesEnvelope(value))
|
|
@@ -539,6 +550,9 @@ export async function createTauriSyncClient(config) {
|
|
|
539
550
|
...(config.clientId !== undefined ? { clientId: config.clientId } : {}),
|
|
540
551
|
schema: config.schema,
|
|
541
552
|
...(config.limits !== undefined ? { limits: config.limits } : {}),
|
|
553
|
+
...(config.encryption !== undefined
|
|
554
|
+
? { encryption: encodeEncryption(config.encryption) }
|
|
555
|
+
: {}),
|
|
542
556
|
},
|
|
543
557
|
},
|
|
544
558
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@syncular/tauri",
|
|
3
|
-
"version": "0.15.
|
|
3
|
+
"version": "0.15.9",
|
|
4
4
|
"description": "Tauri integration for the Syncular client",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Benjamin Kniffler",
|
|
@@ -48,12 +48,12 @@
|
|
|
48
48
|
"test": "bun test"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@syncular/client": "0.15.
|
|
51
|
+
"@syncular/client": "0.15.9"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
54
54
|
"@tauri-apps/api": ">=2.0.0"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
|
-
"@syncular/react": "0.15.
|
|
57
|
+
"@syncular/react": "0.15.9"
|
|
58
58
|
}
|
|
59
59
|
}
|
package/src/index.ts
CHANGED
|
@@ -36,6 +36,7 @@ import type {
|
|
|
36
36
|
CommitOutcome,
|
|
37
37
|
CommitOutcomeQuery,
|
|
38
38
|
ConflictRecord,
|
|
39
|
+
EncryptionKeyringConfig,
|
|
39
40
|
InvalidationEvent,
|
|
40
41
|
InvalidationListener,
|
|
41
42
|
LeaseState,
|
|
@@ -91,6 +92,11 @@ export interface TauriSyncClientConfig {
|
|
|
91
92
|
readonly clientId?: string;
|
|
92
93
|
/** §4.2 client limits, forwarded to the native `create`. */
|
|
93
94
|
readonly limits?: Record<string, unknown>;
|
|
95
|
+
/**
|
|
96
|
+
* Portable E2EE keys and declarative per-row key-id columns. Raw keys are
|
|
97
|
+
* encoded into the native command envelope and never sent to the server.
|
|
98
|
+
*/
|
|
99
|
+
readonly encryption?: EncryptionKeyringConfig;
|
|
94
100
|
/**
|
|
95
101
|
* The Tauri primitives. Omit in a real Tauri webview to auto-resolve from
|
|
96
102
|
* `@tauri-apps/api` (peer dep) or the ambient `window.__TAURI__`; inject in
|
|
@@ -157,6 +163,20 @@ function encodeJsonValue(value: unknown): unknown {
|
|
|
157
163
|
return value;
|
|
158
164
|
}
|
|
159
165
|
|
|
166
|
+
function encodeEncryption(config: EncryptionKeyringConfig): unknown {
|
|
167
|
+
return {
|
|
168
|
+
keys: Object.fromEntries(
|
|
169
|
+
Object.entries(config.keys).map(([keyId, key]) => [
|
|
170
|
+
keyId,
|
|
171
|
+
{ $bytes: bytesToHex(key) },
|
|
172
|
+
]),
|
|
173
|
+
),
|
|
174
|
+
...(config.keyIdColumns !== undefined
|
|
175
|
+
? { keyIdColumns: config.keyIdColumns }
|
|
176
|
+
: {}),
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
|
|
160
180
|
/** Decode one query-result cell back to an `SqlValue` (`{$bytes}` → bytes). */
|
|
161
181
|
function decodeCell(value: unknown): SqlValue {
|
|
162
182
|
if (isBytesEnvelope(value)) return hexToBytes(value.$bytes);
|
|
@@ -752,6 +772,9 @@ export async function createTauriSyncClient(
|
|
|
752
772
|
...(config.clientId !== undefined ? { clientId: config.clientId } : {}),
|
|
753
773
|
schema: config.schema,
|
|
754
774
|
...(config.limits !== undefined ? { limits: config.limits } : {}),
|
|
775
|
+
...(config.encryption !== undefined
|
|
776
|
+
? { encryption: encodeEncryption(config.encryption) }
|
|
777
|
+
: {}),
|
|
755
778
|
},
|
|
756
779
|
},
|
|
757
780
|
});
|