You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: packages/web/README.md
+33Lines changed: 33 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -28,6 +28,39 @@ Install it in your app with:
28
28
npm install @journeyapps/wa-sqlite
29
29
```
30
30
31
+
### Encryption with Multiple Ciphers
32
+
33
+
To enable encryption you need to specify an encryption key when instantiating the PowerSync database.
34
+
35
+
> The PowerSync Web SDK uses the ChaCha20 cipher algorithm by [default](https://utelle.github.io/SQLite3MultipleCiphers/docs/ciphers/cipher_chacha20/).
36
+
37
+
```typescript
38
+
exportconst db =newPowerSyncDatabase({
39
+
// The schema you defined
40
+
schema: AppSchema,
41
+
database: {
42
+
// Filename for the SQLite database — it's important to only instantiate one instance per file.
43
+
dbFilename: 'example.db'
44
+
// Optional. Directory where the database file is located.'
45
+
// dbLocation: 'path/to/directory'
46
+
},
47
+
// Encryption key for the database.
48
+
encryptionKey: 'your-encryption-key'
49
+
});
50
+
51
+
// If you are using a custom WASQLiteOpenFactory or WASQLiteDBAdapter, you need specify the encryption key inside the construtor
52
+
exportconst db =newPowerSyncDatabase({
53
+
schema: AppSchema,
54
+
database: newWASQLiteOpenFactory({
55
+
//new WASQLiteDBAdapter
56
+
dbFilename: 'example.db',
57
+
vfs: WASQLiteVFS.OPFSCoopSyncVFS,
58
+
// Encryption key for the database.
59
+
encryptionKey: 'your-encryption-key'
60
+
})
61
+
});
62
+
```
63
+
31
64
## Webpack
32
65
33
66
See the [example Webpack config](https://github.com/powersync-ja/powersync-js/blob/main/demos/example-webpack/webpack.config.js) for details on polyfills and requirements.
`Invalid configuration: 'encryptionKey' should only be included inside the database object when using a custom ${isSQLOpenFactory(database) ? 'WASQLiteOpenFactory' : 'WASQLiteDBAdapter'} constructor.`
105
+
);
106
+
}
107
+
}
108
+
}
109
+
83
110
/**
84
111
* A PowerSync database which provides SQLite functionality
85
112
* which is automatically synced.
@@ -107,6 +134,8 @@ export class PowerSyncDatabase extends AbstractPowerSyncDatabase {
0 commit comments