Skip to content

Commit 2fbf141

Browse files
committed
General cleanup, removed connector.
1 parent e801fc4 commit 2fbf141

File tree

4 files changed

+497
-469
lines changed

4 files changed

+497
-469
lines changed

demos/example-vite-encryption/README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
# PowerSync Vite bundling test
1+
# PowerSync Web Encryption example
22

3-
This is a minimal example demonstrating bundling with Vite. It attempts a connection to verify that web workers load correctly, but networks requests will fail since no credentials are configured. See [src/index.js](src/index.js) for details.
3+
This is a minimal example demonstrating web encryption. It prompts an encryption key, which is used for the database.
4+
If the database doesn't exist yet, it will apply the encryption key when creating the database for the specified database name.
5+
If the database does exist, it will use the encryption key to access the database - should the provided key be different to the one provided upon creation it fail to open the database.
46

57
To see it in action:
68

demos/example-vite-encryption/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
2-
"name": "example-vite",
2+
"name": "example-vite-cencryption",
33
"private": true,
4-
"version": "0.0.33",
4+
"version": "0.0.1",
55
"type": "module",
66
"scripts": {
77
"dev": "vite",

demos/example-vite-encryption/src/index.js

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,8 @@
1-
import { column, Schema, Table, PowerSyncDatabase, WASQLiteVFS } from '@powersync/web';
1+
import { column, Schema, Table, PowerSyncDatabase } from '@powersync/web';
22
import Logger from 'js-logger';
33

44
Logger.useDefaults();
55

6-
/**
7-
* A placeholder connector which doesn't do anything.
8-
* This is just used to verify that the sync workers can be loaded
9-
* when connecting.
10-
*/
11-
class DummyConnector {
12-
async fetchCredentials() {
13-
return {
14-
endpoint: '',
15-
token: ''
16-
};
17-
}
18-
19-
async uploadData(database) {}
20-
}
21-
226
const customers = new Table({ name: column.text });
237

248
export const AppSchema = new Schema({ customers });
@@ -39,19 +23,7 @@ const openDatabase = async (encryptionKey) => {
3923

4024
const result = await PowerSync.getAll('SELECT * FROM customers');
4125
console.log('contents of customers: ', result);
42-
43-
console.log(
44-
`Attempting to connect in order to verify web workers are correctly loaded.
45-
This doesn't use any actual network credentials.
46-
Network errors will be shown: these can be ignored.`
47-
);
48-
49-
/**
50-
* Try and connect, this will setup shared sync workers
51-
* This will fail due to not having a valid endpoint,
52-
* but it will try - which is all that matters.
53-
*/
54-
await PowerSync.connect(new DummyConnector());
26+
console.table(result);
5527
};
5628

5729
document.addEventListener('DOMContentLoaded', async (event) => {

0 commit comments

Comments
 (0)