From 7e5672eff071d3f773aeaa445ce39834e3227a4d Mon Sep 17 00:00:00 2001 From: Hayden Young Date: Thu, 23 May 2024 15:33:33 +0100 Subject: [PATCH] fix: Linting. --- src/database.js | 4 ++-- src/databases/events.js | 4 ++-- src/databases/keyvalue-indexed.js | 4 ++-- src/databases/keyvalue.js | 4 ++-- src/orbitdb.js | 6 +++--- test/oplog/log.test.js | 4 ++-- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/database.js b/src/database.js index b24d385..1b9be40 100644 --- a/src/database.js +++ b/src/database.js @@ -44,7 +44,7 @@ const defaultCacheSize = 1000 * @return {module:Databases~Database} An instance of Database. * @instance */ -const Database = async ({ ipfs, identity, address, name, access, directory, meta, headsStorage, entryStorage, indexStorage, referencesCount, syncAutomatically, onUpdate }) => { +const Database = async ({ ipfs, identity, address, name, access, directory, meta, headsStorage, entryStorage, indexStorage, referencesCount, syncAutomatically, onUpdate, encryption }) => { /** * @namespace module:Databases~Database * @description The instance returned by {@link module:Database~Database}. @@ -110,7 +110,7 @@ const Database = async ({ ipfs, identity, address, name, access, directory, meta await LevelStorage({ path: pathJoin(directory, '/log/_index/') }) ) - const log = await Log(identity, { logId: address, access, entryStorage, headsStorage, indexStorage }) + const log = await Log(identity, { logId: address, access, entryStorage, headsStorage, indexStorage, encryption }) const events = new EventEmitter() diff --git a/src/databases/events.js b/src/databases/events.js index 1ddfe87..b68e782 100644 --- a/src/databases/events.js +++ b/src/databases/events.js @@ -15,8 +15,8 @@ const type = 'events' * @return {module:Databases.Databases-Events} A Events function. * @memberof module:Databases */ -const Events = () => async ({ ipfs, identity, address, name, access, directory, meta, headsStorage, entryStorage, indexStorage, referencesCount, syncAutomatically, onUpdate }) => { - const database = await Database({ ipfs, identity, address, name, access, directory, meta, headsStorage, entryStorage, indexStorage, referencesCount, syncAutomatically, onUpdate }) +const Events = () => async ({ ipfs, identity, address, name, access, directory, meta, headsStorage, entryStorage, indexStorage, referencesCount, syncAutomatically, onUpdate, encryption }) => { + const database = await Database({ ipfs, identity, address, name, access, directory, meta, headsStorage, entryStorage, indexStorage, referencesCount, syncAutomatically, onUpdate, encryption }) const { addOperation, log } = database diff --git a/src/databases/keyvalue-indexed.js b/src/databases/keyvalue-indexed.js index ceff536..4cb75f5 100644 --- a/src/databases/keyvalue-indexed.js +++ b/src/databases/keyvalue-indexed.js @@ -109,7 +109,7 @@ const Index = ({ directory } = {}) => async () => { * function. * @memberof module:Databases */ -const KeyValueIndexed = () => async ({ ipfs, identity, address, name, access, directory, meta, headsStorage, entryStorage, indexStorage, referencesCount, syncAutomatically, onUpdate }) => { +const KeyValueIndexed = () => async ({ ipfs, identity, address, name, access, directory, meta, headsStorage, entryStorage, indexStorage, referencesCount, syncAutomatically, onUpdate, encryption }) => { // Set up the directory for an index directory = pathJoin(directory || './orbitdb', `./${address}/_index/`) @@ -117,7 +117,7 @@ const KeyValueIndexed = () => async ({ ipfs, identity, address, name, access, di const index = await Index({ directory })() // Set up the underlying KeyValue database - const keyValueStore = await KeyValue()({ ipfs, identity, address, name, access, directory, meta, headsStorage, entryStorage, indexStorage, referencesCount, syncAutomatically, onUpdate: index.update }) + const keyValueStore = await KeyValue()({ ipfs, identity, address, name, access, directory, meta, headsStorage, entryStorage, indexStorage, referencesCount, syncAutomatically, onUpdate: index.update, encryption }) /** * Gets a value from the store by key. diff --git a/src/databases/keyvalue.js b/src/databases/keyvalue.js index 42f7ebb..74e955d 100644 --- a/src/databases/keyvalue.js +++ b/src/databases/keyvalue.js @@ -15,8 +15,8 @@ const type = 'keyvalue' * @return {module:Databases.Databases-KeyValue} A KeyValue function. * @memberof module:Databases */ -const KeyValue = () => async ({ ipfs, identity, address, name, access, directory, meta, headsStorage, entryStorage, indexStorage, referencesCount, syncAutomatically, onUpdate, encryptFn, decryptFn }) => { - const database = await Database({ ipfs, identity, address, name, access, directory, meta, headsStorage, entryStorage, indexStorage, referencesCount, syncAutomatically, onUpdate }) +const KeyValue = () => async ({ ipfs, identity, address, name, access, directory, meta, headsStorage, entryStorage, indexStorage, referencesCount, syncAutomatically, onUpdate, encryption }) => { + const database = await Database({ ipfs, identity, address, name, access, directory, meta, headsStorage, entryStorage, indexStorage, referencesCount, syncAutomatically, onUpdate, encryption }) const { addOperation, log } = database diff --git a/src/orbitdb.js b/src/orbitdb.js index 15ae4e6..92f093c 100644 --- a/src/orbitdb.js +++ b/src/orbitdb.js @@ -104,7 +104,7 @@ const OrbitDB = async ({ ipfs, id, identity, identities, directory } = {}) => { * @param {module:Storage} [params.indexStorage=[ComposedStorage]{@link module:Storage.Storage-Composed}] A compatible storage instance for storing an " index of log entries. Defaults to ComposedStorage(LRUStorage, LevelStorage). * @param {number} [params.referencesCount] The number of references to * use for [Log]{@link module:Log} entries. - * @param {number} [params.encrypt] Options for encrypting database operations and entries. If provided, the encrypt object must take the form { data: { encryptFn, decryptFn }, op: { encryptFn, decryptFn } }. To encrypt the operation data value only, pass the "data" option. To encrypt the op, pass the "op" option. To encrypt "data" and "op", pass both options. + * @param {number} [params.encryption] Options for encrypting database payloads and entries. If provided, the encryption object must take the form { encryptPayloadFn, decryptPayloadFn, encryptEntryFn, decryptEntryFn }. To encrypt the payload, pass the payload encrypt/decrypt functions. To encrypt the entry, pass the entry encrypt/decrypt functions. To encrypt/decrypt both payload and entry, pass all functions. * @memberof module:OrbitDB * @return {module:Database} A database instance. * @throws "Unsupported database type" if the type specified is not in the list @@ -113,7 +113,7 @@ const OrbitDB = async ({ ipfs, id, identity, identities, directory } = {}) => { * @instance * @async */ - const open = async (address, { type, meta, sync, Database, AccessController, headsStorage, entryStorage, indexStorage, referencesCount, encrypt } = {}) => { + const open = async (address, { type, meta, sync, Database, AccessController, headsStorage, entryStorage, indexStorage, referencesCount, encryption } = {}) => { let name, manifest, accessController if (databases[address]) { @@ -154,7 +154,7 @@ const OrbitDB = async ({ ipfs, id, identity, identities, directory } = {}) => { address = address.toString() - const db = await Database({ ipfs, identity, address, name, access: accessController, directory, meta, syncAutomatically: sync, headsStorage, entryStorage, indexStorage, referencesCount, encrypt }) + const db = await Database({ ipfs, identity, address, name, access: accessController, directory, meta, syncAutomatically: sync, headsStorage, entryStorage, indexStorage, referencesCount, encryption }) db.events.on('close', onDatabaseClosed(address)) diff --git a/test/oplog/log.test.js b/test/oplog/log.test.js index c6b54ff..4073280 100644 --- a/test/oplog/log.test.js +++ b/test/oplog/log.test.js @@ -157,7 +157,7 @@ describe('Log', function () { const value = await log.get(entry.hash) strictEqual(value.payload, 'hello1') }) - + it('encrypts a log entry when the payload is an object', async () => { const keys = await keystore.createKey('hello1') @@ -171,6 +171,6 @@ describe('Log', function () { const value = await log.get(entry.hash) deepStrictEqual(value.payload, { test: 'hello1' }) - }) + }) }) })