From bfd0ddaedc15b6bb5f3652c773f352c2704392aa Mon Sep 17 00:00:00 2001 From: Gregor MacLennan Date: Mon, 17 Jul 2023 18:05:04 +0100 Subject: [PATCH] fix: core.key is defined if passed in constructor --- vendor/hypercore.d.ts | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/vendor/hypercore.d.ts b/vendor/hypercore.d.ts index 5f557d5..fe39362 100644 --- a/vendor/hypercore.d.ts +++ b/vendor/hypercore.d.ts @@ -71,12 +71,14 @@ declare namespace Hypercore { type ValueEncoding = 'json' | 'utf-8' | 'binary' interface HypercoreOptions< - TValueEncoding extends Hypercore.ValueEncoding = 'binary' + TValueEncoding extends Hypercore.ValueEncoding = 'binary', + TKey extends Buffer | string | undefined = undefined > { createIfMissing?: boolean // create a new Hypercore key pair if none was present in storage overwrite?: boolean // overwrite any old Hypercore that might already exist valueEncoding?: TValueEncoding // defaults to binary encodeBatch?(batch: any[]): void // optionally apply an encoding to complete batches + key: TKey keyPair?: KeyPair // optionally pass the public key and secret key as a key pair encryptionKey?: Buffer // optionally pass an encryption key to enable block encryption onwait?: () => {} // hook that is called if gets are waiting for download @@ -100,12 +102,13 @@ declare namespace Hypercore { } declare class Hypercore< - TValueEncoding extends Hypercore.ValueEncoding = 'binary' + TValueEncoding extends Hypercore.ValueEncoding = 'binary', + TKey extends Buffer | string | undefined = undefined > extends TypedEmitter { readonly writable: boolean readonly readable: boolean readonly id: null | string - readonly key: null | Buffer + readonly key: TKey extends undefined ? null | Buffer : Buffer readonly peers: any[] readonly keyPair: null | KeyPair readonly discoveryKey: null | Buffer @@ -118,12 +121,12 @@ declare class Hypercore< constructor(storage: Hypercore.HypercoreStorage) constructor( storage: Hypercore.HypercoreStorage, - key: Buffer | string, - options?: Hypercore.HypercoreOptions + key: TKey, + options?: Hypercore.HypercoreOptions ) constructor( storage: Hypercore.HypercoreStorage, - options?: Hypercore.HypercoreOptions + options?: Hypercore.HypercoreOptions ) /** Append a block of data (or an array of blocks) to the core. Returns the