web-dc-api 0.0.87 → 0.0.89
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/cjs/index.js +1 -0
- package/dist/cjs/protobuf-BVBdi7Hh.js +1 -0
- package/dist/dc.min.js +1 -19
- package/dist/esm/chunks/protobuf-CbxDm-Gy.js +1 -0
- package/dist/esm/index.js +1 -0
- package/dist/index.d.ts +947 -886
- package/package.json +14 -17
- package/dist/index.cjs.js +0 -19
- package/dist/index.esm.js +0 -19
- package/lib/common/blowfish/block.ts +0 -259
- package/lib/common/blowfish/cipher.ts +0 -144
- package/lib/common/blowfish/const.ts +0 -195
- package/lib/common/chain.ts +0 -469
- package/lib/common/commonclient.ts +0 -202
- package/lib/common/constants.ts +0 -55
- package/lib/common/dc-key/ed25519.ts +0 -343
- package/lib/common/dc-key/keyManager.ts +0 -424
- package/lib/common/dcapi.ts +0 -98
- package/lib/common/dcutil.ts +0 -595
- package/lib/common/define.ts +0 -66
- package/lib/common/error.ts +0 -67
- package/lib/common/grpc-dc.ts +0 -104
- package/lib/common/module-system.ts +0 -184
- package/lib/common/service-worker.ts +0 -234
- package/lib/common/types/types.ts +0 -344
- package/lib/dc.ts +0 -694
- package/lib/implements/account/client.ts +0 -185
- package/lib/implements/account/manager.ts +0 -683
- package/lib/implements/aiproxy/client.ts +0 -357
- package/lib/implements/aiproxy/manager.ts +0 -670
- package/lib/implements/cache/client.ts +0 -105
- package/lib/implements/cache/manager.ts +0 -127
- package/lib/implements/comment/client.ts +0 -982
- package/lib/implements/comment/manager.ts +0 -1151
- package/lib/implements/dc/client.ts +0 -51
- package/lib/implements/dc/manager.ts +0 -33
- package/lib/implements/file/client.ts +0 -253
- package/lib/implements/file/file-cache-manager.ts +0 -142
- package/lib/implements/file/manager.ts +0 -1240
- package/lib/implements/file/seekableFileStream.ts +0 -344
- package/lib/implements/file/streamwriter.ts +0 -322
- package/lib/implements/keyvalue/client.ts +0 -376
- package/lib/implements/keyvalue/manager.ts +0 -759
- package/lib/implements/message/client.ts +0 -250
- package/lib/implements/message/manager.ts +0 -215
- package/lib/implements/threaddb/cbor/coding.ts +0 -62
- package/lib/implements/threaddb/cbor/event.ts +0 -336
- package/lib/implements/threaddb/cbor/node.ts +0 -542
- package/lib/implements/threaddb/cbor/record.ts +0 -398
- package/lib/implements/threaddb/common/AsyncMutex.ts +0 -24
- package/lib/implements/threaddb/common/addrinfo.ts +0 -135
- package/lib/implements/threaddb/common/dispatcher.ts +0 -81
- package/lib/implements/threaddb/common/idbstore-adapter.ts +0 -260
- package/lib/implements/threaddb/common/json-patcher.ts +0 -204
- package/lib/implements/threaddb/common/key.ts +0 -290
- package/lib/implements/threaddb/common/level-adapter.ts +0 -235
- package/lib/implements/threaddb/common/lineReader.ts +0 -79
- package/lib/implements/threaddb/common/logstore.ts +0 -215
- package/lib/implements/threaddb/common/transformed-datastore.ts +0 -308
- package/lib/implements/threaddb/core/app.ts +0 -202
- package/lib/implements/threaddb/core/core.ts +0 -230
- package/lib/implements/threaddb/core/db.ts +0 -249
- package/lib/implements/threaddb/core/event.ts +0 -54
- package/lib/implements/threaddb/core/head.ts +0 -89
- package/lib/implements/threaddb/core/identity.ts +0 -171
- package/lib/implements/threaddb/core/logstore.ts +0 -137
- package/lib/implements/threaddb/core/options.ts +0 -14
- package/lib/implements/threaddb/core/record.ts +0 -54
- package/lib/implements/threaddb/db/collection.ts +0 -1910
- package/lib/implements/threaddb/db/db.ts +0 -698
- package/lib/implements/threaddb/db/json2Query.ts +0 -192
- package/lib/implements/threaddb/db/query.ts +0 -524
- package/lib/implements/threaddb/dbclient.ts +0 -443
- package/lib/implements/threaddb/dbmanager.ts +0 -1901
- package/lib/implements/threaddb/lsstoreds/addr_book.ts +0 -452
- package/lib/implements/threaddb/lsstoreds/cache.ts +0 -36
- package/lib/implements/threaddb/lsstoreds/cyclic_batch.ts +0 -87
- package/lib/implements/threaddb/lsstoreds/global.ts +0 -151
- package/lib/implements/threaddb/lsstoreds/headbook.ts +0 -280
- package/lib/implements/threaddb/lsstoreds/keybook.ts +0 -297
- package/lib/implements/threaddb/lsstoreds/logstore.ts +0 -29
- package/lib/implements/threaddb/lsstoreds/metadata.ts +0 -223
- package/lib/implements/threaddb/net/define.ts +0 -138
- package/lib/implements/threaddb/net/grpcClient.ts +0 -582
- package/lib/implements/threaddb/net/grpcserver.ts +0 -146
- package/lib/implements/threaddb/net/net.ts +0 -2006
- package/lib/implements/threaddb/pb/lstore.proto +0 -38
- package/lib/implements/threaddb/pb/lstore.ts +0 -393
- package/lib/implements/threaddb/pb/lstore_pb.d.ts +0 -433
- package/lib/implements/threaddb/pb/lstore_pb.js +0 -1085
- package/lib/implements/threaddb/pb/net.proto +0 -194
- package/lib/implements/threaddb/pb/net_pb.d.ts +0 -2349
- package/lib/implements/threaddb/pb/net_pb.js +0 -5525
- package/lib/implements/threaddb/pb/proto-custom-types.ts +0 -212
- package/lib/implements/util/client.ts +0 -72
- package/lib/implements/util/manager.ts +0 -146
- package/lib/implements/wallet/manager.ts +0 -664
- package/lib/index.ts +0 -57
- package/lib/interfaces/DCContext.ts +0 -51
- package/lib/interfaces/aiproxy-interface.ts +0 -145
- package/lib/interfaces/auth-interface.ts +0 -118
- package/lib/interfaces/cache-interface.ts +0 -22
- package/lib/interfaces/client-interface.ts +0 -11
- package/lib/interfaces/comment-interface.ts +0 -167
- package/lib/interfaces/database-interface.ts +0 -169
- package/lib/interfaces/file-interface.ts +0 -120
- package/lib/interfaces/index.ts +0 -10
- package/lib/interfaces/keyvalue-interface.ts +0 -156
- package/lib/interfaces/message-interface.ts +0 -22
- package/lib/interfaces/util-interface.ts +0 -31
- package/lib/modules/aiproxy-module.ts +0 -246
- package/lib/modules/auth-module.ts +0 -753
- package/lib/modules/cache-module.ts +0 -99
- package/lib/modules/client-module.ts +0 -71
- package/lib/modules/comment-module.ts +0 -429
- package/lib/modules/database-module.ts +0 -598
- package/lib/modules/file-module.ts +0 -291
- package/lib/modules/index.ts +0 -13
- package/lib/modules/keyvalue-module.ts +0 -379
- package/lib/modules/message-module.ts +0 -107
- package/lib/modules/util-module.ts +0 -148
- package/lib/polyfills/process-env-browser.ts +0 -1
- package/lib/proto/datasource.ts +0 -93
- package/lib/proto/dcnet.proto +0 -1601
- package/lib/proto/dcnet_proto.d.ts +0 -22857
- package/lib/proto/dcnet_proto.js +0 -55204
- package/lib/proto/dcnet_proto_sparse.js +0 -55166
- package/lib/proto/oidfetch.proto +0 -25
- package/lib/proto/oidfetch_proto.d.ts +0 -585
- package/lib/proto/oidfetch_proto.js +0 -1247
- package/lib/serverless/babel-browser.ts +0 -39
- package/lib/serverless/base_entity.ts +0 -78
- package/lib/serverless/base_repository.ts +0 -414
- package/lib/serverless/browser_schema_extractor.ts +0 -283
- package/lib/serverless/decorator_factory.ts +0 -322
- package/lib/util/BrowserLineReader.ts +0 -73
- package/lib/util/base64.ts +0 -105
- package/lib/util/bcrypt.ts +0 -206
- package/lib/util/curve25519Encryption.ts +0 -418
- package/lib/util/dccrypt.ts +0 -73
- package/lib/util/logger.ts +0 -104
- package/lib/util/utils.ts +0 -289
package/dist/index.d.ts
CHANGED
|
@@ -4,17 +4,17 @@ import { Libp2p } from 'libp2p';
|
|
|
4
4
|
import { Blocks, HeliaLibp2p } from 'helia';
|
|
5
5
|
import { CID } from 'multiformats/cid';
|
|
6
6
|
import { MultihashDigest } from 'multiformats/hashes/interface';
|
|
7
|
-
import { Ed25519PublicKey, Ed25519PrivateKey,
|
|
7
|
+
import { Ed25519PublicKey, Ed25519PrivateKey, PrivateKey, PublicKey, PeerId, Libp2p as Libp2p$1 } from '@libp2p/interface';
|
|
8
8
|
import { Blocks as Blocks$1 } from '@helia/interface';
|
|
9
|
-
import
|
|
9
|
+
import EventEmitter from 'eventemitter3';
|
|
10
10
|
import { ThreadID } from '@textile/threads-id';
|
|
11
|
-
import {
|
|
11
|
+
import { PublicKey as PublicKey$1 } from '@libp2p/interface-keys';
|
|
12
12
|
import { AnySchema } from 'ajv';
|
|
13
|
-
import
|
|
14
|
-
import {
|
|
13
|
+
import { Query as Query$1, Pair, Datastore, Key as Key$1, Batch } from 'interface-datastore';
|
|
14
|
+
import { Link } from 'multiformats/link';
|
|
15
15
|
import * as $protobuf from 'protobufjs';
|
|
16
16
|
import Long from 'long';
|
|
17
|
-
import {
|
|
17
|
+
import { DAGCBOR } from '@helia/dag-cbor';
|
|
18
18
|
import { UnixFS } from '@helia/unixfs';
|
|
19
19
|
import { HDKey } from '@scure/bip32';
|
|
20
20
|
|
|
@@ -292,17 +292,18 @@ type SignResponseMessage = {
|
|
|
292
292
|
success: boolean;
|
|
293
293
|
signature: string;
|
|
294
294
|
};
|
|
295
|
+
type EIP712SignReqMessageData = {
|
|
296
|
+
appUrl: string;
|
|
297
|
+
ethAccount: string;
|
|
298
|
+
domain: any;
|
|
299
|
+
types: any;
|
|
300
|
+
primaryType: string;
|
|
301
|
+
message: any;
|
|
302
|
+
};
|
|
295
303
|
type EIP712SignReqMessage = {
|
|
296
304
|
type: string;
|
|
297
305
|
origin: string;
|
|
298
|
-
data:
|
|
299
|
-
appUrl: string;
|
|
300
|
-
ethAccount: string;
|
|
301
|
-
domain: any;
|
|
302
|
-
types: any;
|
|
303
|
-
primaryType: string;
|
|
304
|
-
message: any;
|
|
305
|
-
};
|
|
306
|
+
data: EIP712SignReqMessageData;
|
|
306
307
|
};
|
|
307
308
|
type SendMessage<T> = {
|
|
308
309
|
type: string;
|
|
@@ -433,20 +434,69 @@ declare class DcUtil {
|
|
|
433
434
|
} | null;
|
|
434
435
|
}
|
|
435
436
|
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
437
|
+
/**
|
|
438
|
+
* Key is a wrapper for a symmetric key
|
|
439
|
+
*/
|
|
440
|
+
declare class SymmetricKey {
|
|
441
|
+
static readonly keyBytes: number;
|
|
442
|
+
private _raw;
|
|
443
|
+
constructor(rawBytes: Uint8Array);
|
|
444
|
+
/**
|
|
445
|
+
* Generate a new random key
|
|
446
|
+
*/
|
|
447
|
+
static newRandom(): SymmetricKey;
|
|
448
|
+
/**
|
|
449
|
+
* Creates a key without error handling (will throw if fails)
|
|
450
|
+
*/
|
|
451
|
+
static new(): SymmetricKey;
|
|
452
|
+
/**
|
|
453
|
+
* Create a key from raw bytes
|
|
454
|
+
*/
|
|
455
|
+
static fromBytes(k: Uint8Array): SymmetricKey;
|
|
456
|
+
/**
|
|
457
|
+
* Create a key from a base32-encoded string
|
|
458
|
+
*/
|
|
459
|
+
static fromString(k: string): SymmetricKey;
|
|
460
|
+
toSymKey(): Promise<SymKey>;
|
|
461
|
+
static fromSymKey(symKey: SymKey): SymmetricKey;
|
|
462
|
+
/**
|
|
463
|
+
* Get raw key bytes
|
|
464
|
+
*/
|
|
465
|
+
get raw(): Uint8Array;
|
|
466
|
+
/**
|
|
467
|
+
* Return raw key bytes
|
|
468
|
+
*/
|
|
469
|
+
bytes(): Uint8Array;
|
|
470
|
+
/**
|
|
471
|
+
* Convert key to binary format
|
|
472
|
+
*/
|
|
473
|
+
marshalBinary(): Uint8Array;
|
|
474
|
+
/**
|
|
475
|
+
* Return base32-encoded string representation
|
|
476
|
+
*/
|
|
477
|
+
toString(): string;
|
|
478
|
+
encrypt(plaintext: Uint8Array, exNonce?: Uint8Array): Promise<Uint8Array>;
|
|
479
|
+
/**
|
|
480
|
+
* Decrypt uses key to perform AES-256 GCM decryption on ciphertext
|
|
481
|
+
*/
|
|
482
|
+
decrypt(encryptBuffer: Uint8Array): Promise<Uint8Array>;
|
|
483
|
+
}
|
|
484
|
+
type LogKey = PrivateKey | PublicKey;
|
|
485
|
+
declare class Key {
|
|
486
|
+
private sk?;
|
|
487
|
+
private rk?;
|
|
488
|
+
constructor(sk: SymmetricKey, rk?: SymmetricKey);
|
|
489
|
+
static new(sk: SymmetricKey, rk?: SymmetricKey): Key;
|
|
490
|
+
static newRandom(): Key;
|
|
491
|
+
static newRandomService(): Key;
|
|
492
|
+
static fromBytes(b: Uint8Array): Key;
|
|
493
|
+
static fromString(s: string): Key;
|
|
494
|
+
service(): SymmetricKey | undefined;
|
|
495
|
+
read(): SymmetricKey | undefined;
|
|
496
|
+
defined(): boolean;
|
|
497
|
+
canRead(): boolean;
|
|
498
|
+
toBytes(): Uint8Array;
|
|
499
|
+
toString(): string;
|
|
450
500
|
}
|
|
451
501
|
|
|
452
502
|
interface Head {
|
|
@@ -482,257 +532,401 @@ declare class ThreadToken {
|
|
|
482
532
|
get defined(): boolean;
|
|
483
533
|
}
|
|
484
534
|
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
/** 获取内部区块的 CID */
|
|
488
|
-
blockID: () => CID;
|
|
489
|
-
/** 异步加载内部区块 */
|
|
490
|
-
getBlock: (bstore: Blocks) => Promise<IPLDNode>;
|
|
491
|
-
/** 前一个记录的 CID */
|
|
492
|
-
prevID: () => CID | undefined;
|
|
493
|
-
/** 记录的数字签名 */
|
|
494
|
-
sig: () => Signature;
|
|
495
|
-
/** 作者的原始公钥字节 */
|
|
496
|
-
pubKey: () => Uint8Array;
|
|
497
|
-
/** 验证签名有效性 */
|
|
498
|
-
verify: (key: PublicKey) => Promise<Error | undefined>;
|
|
535
|
+
interface Reducer {
|
|
536
|
+
reduce(events: Event[]): Promise<void>;
|
|
499
537
|
}
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
538
|
+
declare class Dispatcher {
|
|
539
|
+
private store;
|
|
540
|
+
private reducers;
|
|
541
|
+
private lock;
|
|
542
|
+
private lastID;
|
|
543
|
+
constructor(store: TxnDatastoreExtended);
|
|
544
|
+
getStore(): TxnDatastoreExtended;
|
|
545
|
+
register(reducer: Reducer): void;
|
|
546
|
+
dispatch(events: Event[]): Promise<void>;
|
|
547
|
+
query(query: Query$1): AsyncIterable<Pair>;
|
|
548
|
+
private getKey;
|
|
507
549
|
}
|
|
508
550
|
|
|
509
|
-
|
|
510
|
-
declare
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
551
|
+
type InstanceID$1 = string;
|
|
552
|
+
declare enum CoreActionType {
|
|
553
|
+
Create = 0,
|
|
554
|
+
Save = 1,
|
|
555
|
+
Delete = 2
|
|
556
|
+
}
|
|
557
|
+
/**
|
|
558
|
+
* Transaction class for collections
|
|
559
|
+
*/
|
|
560
|
+
interface ITxn {
|
|
561
|
+
/**
|
|
562
|
+
* Create new instances
|
|
563
|
+
*/
|
|
564
|
+
create(...newInstances: Uint8Array[]): Promise<InstanceID$1[]>;
|
|
565
|
+
/**
|
|
566
|
+
* Verify instance changes without saving them
|
|
567
|
+
*/
|
|
568
|
+
verify(...updated: Uint8Array[]): Promise<void>;
|
|
569
|
+
/**
|
|
570
|
+
* Save instance changes
|
|
571
|
+
*/
|
|
572
|
+
save(...updated: Uint8Array[]): Promise<void>;
|
|
573
|
+
/**
|
|
574
|
+
* Delete instances
|
|
575
|
+
*/
|
|
576
|
+
delete(...ids: InstanceID$1[]): Promise<void>;
|
|
577
|
+
/**
|
|
578
|
+
* Check if instances exist
|
|
579
|
+
*/
|
|
580
|
+
has(...ids: InstanceID$1[]): Promise<boolean>;
|
|
581
|
+
/**
|
|
582
|
+
* Find instance by ID
|
|
583
|
+
*/
|
|
584
|
+
findByID(id: InstanceID$1): Promise<Object>;
|
|
585
|
+
/**
|
|
586
|
+
* Find instances matching a query
|
|
587
|
+
*/
|
|
588
|
+
find(q?: Query$1): Promise<Object[]>;
|
|
589
|
+
/**
|
|
590
|
+
* Get instances modified since a specific time
|
|
591
|
+
*
|
|
592
|
+
* The _mod field tracks modified instances, but not those that have been deleted, so we need
|
|
593
|
+
* to query the dispatcher for all (unique) instances in this collection that have been modified
|
|
594
|
+
* at all since `time`.
|
|
595
|
+
*/
|
|
596
|
+
modifiedSince(time: number): Promise<InstanceID$1[]>;
|
|
597
|
+
/**
|
|
598
|
+
* Commit the transaction
|
|
599
|
+
*/
|
|
600
|
+
commit(): Promise<void>;
|
|
601
|
+
/**
|
|
602
|
+
* Discard the transaction
|
|
603
|
+
*/
|
|
604
|
+
discard(): void;
|
|
605
|
+
/**
|
|
606
|
+
* Refresh collection reference
|
|
607
|
+
*/
|
|
608
|
+
refreshCollection(): void;
|
|
609
|
+
}
|
|
610
|
+
interface ICollection {
|
|
611
|
+
baseKey(): Key$1;
|
|
612
|
+
getName(): string;
|
|
613
|
+
getSchema(): Uint8Array;
|
|
614
|
+
getWriteValidator(): Uint8Array;
|
|
615
|
+
getReadFilter(): Uint8Array;
|
|
616
|
+
readTxn(fn: (txn: ITxn) => Promise<void>, token?: ThreadToken): Promise<void>;
|
|
617
|
+
writeTxn(fn: (txn: ITxn) => Promise<void>, token?: ThreadToken): Promise<void>;
|
|
618
|
+
findByID(id: InstanceID$1, token?: ThreadToken): Promise<Object>;
|
|
619
|
+
create(v: Uint8Array, token?: ThreadToken): Promise<InstanceID$1>;
|
|
620
|
+
createMany(vs: Uint8Array[], token?: ThreadToken): Promise<InstanceID$1[]>;
|
|
621
|
+
delete(id: InstanceID$1, token?: ThreadToken): Promise<void>;
|
|
622
|
+
deleteMany(ids: InstanceID$1[], token?: ThreadToken): Promise<void>;
|
|
623
|
+
save(v: Uint8Array, token?: ThreadToken): Promise<void>;
|
|
624
|
+
saveMany(vs: Uint8Array[], token?: ThreadToken): Promise<void>;
|
|
625
|
+
verify(v: Uint8Array, token?: ThreadToken): Promise<void>;
|
|
626
|
+
verifyMany(vs: Uint8Array[], token?: ThreadToken): Promise<void>;
|
|
627
|
+
has(id: InstanceID$1, token?: ThreadToken): Promise<boolean>;
|
|
628
|
+
hasMany(ids: InstanceID$1[], token?: ThreadToken): Promise<boolean>;
|
|
629
|
+
find(q: Query$1, token?: ThreadToken): Promise<Object[]>;
|
|
630
|
+
modifiedSince(time: number, token?: ThreadToken): Promise<InstanceID$1[]>;
|
|
631
|
+
validInstance(v: Uint8Array): void;
|
|
632
|
+
validWrite(identity: Ed25519PubKey, e: Event): Promise<void>;
|
|
633
|
+
filterRead(identity: Ed25519PubKey, instance: Uint8Array): Promise<Uint8Array | null>;
|
|
634
|
+
}
|
|
635
|
+
interface IDB {
|
|
636
|
+
datastore: TxnDatastoreExtended;
|
|
637
|
+
connector: Connector | null;
|
|
638
|
+
dispatcher: Dispatcher | null;
|
|
639
|
+
eventcodec: EventCodec;
|
|
640
|
+
localEventsBus: LocalEventsBus | null;
|
|
641
|
+
collections: Map<string, ICollection>;
|
|
642
|
+
readTxn(collection: ICollection, fn: (txn: ITxn) => Promise<void>, token?: ThreadToken): Promise<void>;
|
|
643
|
+
writeTxn(collection: ICollection, fn: (txn: ITxn) => Promise<void>, token?: ThreadToken): Promise<void>;
|
|
644
|
+
notifyTxnEvents(node: IPLDNode, token?: ThreadToken): Promise<void>;
|
|
645
|
+
}
|
|
646
|
+
interface Event<T = any> {
|
|
647
|
+
/** 事件时间戳 (Unix纳秒时间戳) */
|
|
648
|
+
readonly timestamp: BigInt;
|
|
649
|
+
/** 关联的实例ID */
|
|
650
|
+
readonly instanceID: InstanceID$1;
|
|
651
|
+
/** 所属集合名称 */
|
|
652
|
+
readonly collection: string;
|
|
653
|
+
/** 事件负载数据 */
|
|
654
|
+
readonly payload: T;
|
|
655
|
+
/** 序列化为Uint8Array */
|
|
656
|
+
marshal(): Promise<Uint8Array>;
|
|
657
|
+
}
|
|
658
|
+
interface QueryResult {
|
|
659
|
+
key: string;
|
|
660
|
+
value: Uint8Array;
|
|
661
|
+
size?: number;
|
|
662
|
+
}
|
|
663
|
+
interface QueryExt extends Query$1 {
|
|
664
|
+
seekPrefix?: string;
|
|
665
|
+
}
|
|
666
|
+
interface Transaction {
|
|
667
|
+
put(key: Key$1, value: Uint8Array): Promise<Key$1>;
|
|
668
|
+
delete(key: Key$1): Promise<void>;
|
|
669
|
+
get(key: Key$1): Promise<Uint8Array | undefined>;
|
|
670
|
+
has(key: Key$1): Promise<boolean>;
|
|
671
|
+
commit(): Promise<void>;
|
|
672
|
+
discard(): void;
|
|
673
|
+
query(q: Query$1): AsyncIterable<QueryResult>;
|
|
674
|
+
queryExtended(q: QueryExt): AsyncIterable<QueryResult>;
|
|
675
|
+
}
|
|
676
|
+
interface DatastoreExtensions {
|
|
677
|
+
newTransactionExtended(readOnly: boolean): Promise<Transaction>;
|
|
678
|
+
queryExtended(q: QueryExt): AsyncIterable<QueryResult>;
|
|
679
|
+
}
|
|
680
|
+
interface TxnDatastoreExtended extends Datastore, DatastoreExtensions {
|
|
681
|
+
batch(): Batch;
|
|
682
|
+
newTransactionExtended(readOnly: boolean): Promise<Transaction>;
|
|
683
|
+
}
|
|
684
|
+
type IndexFunc = (collection: string, key: Key$1, txn: Transaction, oldData?: Uint8Array, newData?: Uint8Array) => Promise<void>;
|
|
685
|
+
interface Action {
|
|
686
|
+
type: CoreActionType;
|
|
687
|
+
instanceID: InstanceID$1;
|
|
688
|
+
collectionName: string;
|
|
689
|
+
previous?: Uint8Array;
|
|
690
|
+
current?: Uint8Array;
|
|
691
|
+
}
|
|
692
|
+
interface ReduceAction {
|
|
693
|
+
type: CoreActionType;
|
|
694
|
+
collection: string;
|
|
695
|
+
instanceID: InstanceID$1;
|
|
696
|
+
}
|
|
697
|
+
interface EventCodec {
|
|
698
|
+
reduce(events: Event[], store: TxnDatastoreExtended, baseKey: Key$1, indexFn: IndexFunc): Promise<ReduceAction[]>;
|
|
699
|
+
create(actions: Action[]): Promise<[Event[], IPLDNode]>;
|
|
700
|
+
eventsFromBytes(data: Uint8Array): Promise<Event[]>;
|
|
701
|
+
}
|
|
649
702
|
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
}
|
|
703
|
+
/** Namespace net. */
|
|
704
|
+
declare namespace net {
|
|
653
705
|
|
|
654
|
-
|
|
655
|
-
|
|
706
|
+
/** Namespace pb. */
|
|
707
|
+
namespace pb {
|
|
656
708
|
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
* @param [properties] Properties to set
|
|
660
|
-
*/
|
|
661
|
-
constructor(properties?: net.pb.Log.IRecord);
|
|
709
|
+
/** Properties of a Log. */
|
|
710
|
+
interface ILog {
|
|
662
711
|
|
|
663
|
-
|
|
664
|
-
|
|
712
|
+
/** Log ID */
|
|
713
|
+
ID?: (Uint8Array|null);
|
|
665
714
|
|
|
666
|
-
|
|
667
|
-
|
|
715
|
+
/** Log pubKey */
|
|
716
|
+
pubKey?: (Uint8Array|null);
|
|
668
717
|
|
|
669
|
-
|
|
670
|
-
|
|
718
|
+
/** Log addrs */
|
|
719
|
+
addrs?: (Uint8Array[]|null);
|
|
671
720
|
|
|
672
|
-
|
|
673
|
-
|
|
721
|
+
/** Log head */
|
|
722
|
+
head?: (Uint8Array|null);
|
|
674
723
|
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
* @returns Record instance
|
|
679
|
-
*/
|
|
680
|
-
public static create(properties?: net.pb.Log.IRecord): net.pb.Log.Record;
|
|
724
|
+
/** Log counter */
|
|
725
|
+
counter?: (number|Long|null);
|
|
726
|
+
}
|
|
681
727
|
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
* @param message Record message or plain object to encode
|
|
685
|
-
* @param [writer] Writer to encode to
|
|
686
|
-
* @returns Writer
|
|
687
|
-
*/
|
|
688
|
-
public static encode(message: net.pb.Log.IRecord, writer?: $protobuf.Writer): $protobuf.Writer;
|
|
728
|
+
/** Represents a Log. */
|
|
729
|
+
class Log implements ILog {
|
|
689
730
|
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
*/
|
|
696
|
-
public static encodeDelimited(message: net.pb.Log.IRecord, writer?: $protobuf.Writer): $protobuf.Writer;
|
|
731
|
+
/**
|
|
732
|
+
* Constructs a new Log.
|
|
733
|
+
* @param [properties] Properties to set
|
|
734
|
+
*/
|
|
735
|
+
constructor(properties?: net.pb.ILog);
|
|
697
736
|
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
* @param reader Reader or buffer to decode from
|
|
701
|
-
* @param [length] Message length if known beforehand
|
|
702
|
-
* @returns Record
|
|
703
|
-
* @throws {Error} If the payload is not a reader or valid buffer
|
|
704
|
-
* @throws {$protobuf.util.ProtocolError} If required fields are missing
|
|
705
|
-
*/
|
|
706
|
-
public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): net.pb.Log.Record;
|
|
737
|
+
/** Log ID. */
|
|
738
|
+
public ID: Uint8Array;
|
|
707
739
|
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
* @param reader Reader or buffer to decode from
|
|
711
|
-
* @returns Record
|
|
712
|
-
* @throws {Error} If the payload is not a reader or valid buffer
|
|
713
|
-
* @throws {$protobuf.util.ProtocolError} If required fields are missing
|
|
714
|
-
*/
|
|
715
|
-
public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): net.pb.Log.Record;
|
|
740
|
+
/** Log pubKey. */
|
|
741
|
+
public pubKey: Uint8Array;
|
|
716
742
|
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
* @param message Plain object to verify
|
|
720
|
-
* @returns `null` if valid, otherwise the reason why it is not
|
|
721
|
-
*/
|
|
722
|
-
public static verify(message: { [k: string]: any }): (string|null);
|
|
743
|
+
/** Log addrs. */
|
|
744
|
+
public addrs: Uint8Array[];
|
|
723
745
|
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
* @param object Plain object
|
|
727
|
-
* @returns Record
|
|
728
|
-
*/
|
|
729
|
-
public static fromObject(object: { [k: string]: any }): net.pb.Log.Record;
|
|
746
|
+
/** Log head. */
|
|
747
|
+
public head: Uint8Array;
|
|
730
748
|
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
749
|
+
/** Log counter. */
|
|
750
|
+
public counter: (number|Long);
|
|
751
|
+
|
|
752
|
+
/**
|
|
753
|
+
* Creates a new Log instance using the specified properties.
|
|
754
|
+
* @param [properties] Properties to set
|
|
755
|
+
* @returns Log instance
|
|
756
|
+
*/
|
|
757
|
+
public static create(properties?: net.pb.ILog): net.pb.Log;
|
|
758
|
+
|
|
759
|
+
/**
|
|
760
|
+
* Encodes the specified Log message. Does not implicitly {@link net.pb.Log.verify|verify} messages.
|
|
761
|
+
* @param message Log message or plain object to encode
|
|
762
|
+
* @param [writer] Writer to encode to
|
|
763
|
+
* @returns Writer
|
|
764
|
+
*/
|
|
765
|
+
public static encode(message: net.pb.ILog, writer?: $protobuf.Writer): $protobuf.Writer;
|
|
766
|
+
|
|
767
|
+
/**
|
|
768
|
+
* Encodes the specified Log message, length delimited. Does not implicitly {@link net.pb.Log.verify|verify} messages.
|
|
769
|
+
* @param message Log message or plain object to encode
|
|
770
|
+
* @param [writer] Writer to encode to
|
|
771
|
+
* @returns Writer
|
|
772
|
+
*/
|
|
773
|
+
public static encodeDelimited(message: net.pb.ILog, writer?: $protobuf.Writer): $protobuf.Writer;
|
|
774
|
+
|
|
775
|
+
/**
|
|
776
|
+
* Decodes a Log message from the specified reader or buffer.
|
|
777
|
+
* @param reader Reader or buffer to decode from
|
|
778
|
+
* @param [length] Message length if known beforehand
|
|
779
|
+
* @returns Log
|
|
780
|
+
* @throws {Error} If the payload is not a reader or valid buffer
|
|
781
|
+
* @throws {$protobuf.util.ProtocolError} If required fields are missing
|
|
782
|
+
*/
|
|
783
|
+
public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): net.pb.Log;
|
|
784
|
+
|
|
785
|
+
/**
|
|
786
|
+
* Decodes a Log message from the specified reader or buffer, length delimited.
|
|
787
|
+
* @param reader Reader or buffer to decode from
|
|
788
|
+
* @returns Log
|
|
789
|
+
* @throws {Error} If the payload is not a reader or valid buffer
|
|
790
|
+
* @throws {$protobuf.util.ProtocolError} If required fields are missing
|
|
791
|
+
*/
|
|
792
|
+
public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): net.pb.Log;
|
|
793
|
+
|
|
794
|
+
/**
|
|
795
|
+
* Verifies a Log message.
|
|
796
|
+
* @param message Plain object to verify
|
|
797
|
+
* @returns `null` if valid, otherwise the reason why it is not
|
|
798
|
+
*/
|
|
799
|
+
public static verify(message: { [k: string]: any }): (string|null);
|
|
800
|
+
|
|
801
|
+
/**
|
|
802
|
+
* Creates a Log message from a plain object. Also converts values to their respective internal types.
|
|
803
|
+
* @param object Plain object
|
|
804
|
+
* @returns Log
|
|
805
|
+
*/
|
|
806
|
+
public static fromObject(object: { [k: string]: any }): net.pb.Log;
|
|
807
|
+
|
|
808
|
+
/**
|
|
809
|
+
* Creates a plain object from a Log message. Also converts values to other types if specified.
|
|
810
|
+
* @param message Log
|
|
811
|
+
* @param [options] Conversion options
|
|
812
|
+
* @returns Plain object
|
|
813
|
+
*/
|
|
814
|
+
public static toObject(message: net.pb.Log, options?: $protobuf.IConversionOptions): { [k: string]: any };
|
|
815
|
+
|
|
816
|
+
/**
|
|
817
|
+
* Converts this Log to JSON.
|
|
818
|
+
* @returns JSON object
|
|
819
|
+
*/
|
|
820
|
+
public toJSON(): { [k: string]: any };
|
|
821
|
+
|
|
822
|
+
/**
|
|
823
|
+
* Gets the default type url for Log
|
|
824
|
+
* @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
|
|
825
|
+
* @returns The default type url
|
|
826
|
+
*/
|
|
827
|
+
public static getTypeUrl(typeUrlPrefix?: string): string;
|
|
828
|
+
}
|
|
829
|
+
|
|
830
|
+
namespace Log {
|
|
831
|
+
|
|
832
|
+
/** Properties of a Record. */
|
|
833
|
+
interface IRecord {
|
|
834
|
+
|
|
835
|
+
/** Record recordNode */
|
|
836
|
+
recordNode?: (Uint8Array|null);
|
|
837
|
+
|
|
838
|
+
/** Record eventNode */
|
|
839
|
+
eventNode?: (Uint8Array|null);
|
|
840
|
+
|
|
841
|
+
/** Record headerNode */
|
|
842
|
+
headerNode?: (Uint8Array|null);
|
|
843
|
+
|
|
844
|
+
/** Record bodyNode */
|
|
845
|
+
bodyNode?: (Uint8Array|null);
|
|
846
|
+
}
|
|
847
|
+
|
|
848
|
+
/** Represents a Record. */
|
|
849
|
+
class Record implements IRecord {
|
|
850
|
+
|
|
851
|
+
/**
|
|
852
|
+
* Constructs a new Record.
|
|
853
|
+
* @param [properties] Properties to set
|
|
854
|
+
*/
|
|
855
|
+
constructor(properties?: net.pb.Log.IRecord);
|
|
856
|
+
|
|
857
|
+
/** Record recordNode. */
|
|
858
|
+
public recordNode: Uint8Array;
|
|
859
|
+
|
|
860
|
+
/** Record eventNode. */
|
|
861
|
+
public eventNode: Uint8Array;
|
|
862
|
+
|
|
863
|
+
/** Record headerNode. */
|
|
864
|
+
public headerNode: Uint8Array;
|
|
865
|
+
|
|
866
|
+
/** Record bodyNode. */
|
|
867
|
+
public bodyNode: Uint8Array;
|
|
868
|
+
|
|
869
|
+
/**
|
|
870
|
+
* Creates a new Record instance using the specified properties.
|
|
871
|
+
* @param [properties] Properties to set
|
|
872
|
+
* @returns Record instance
|
|
873
|
+
*/
|
|
874
|
+
public static create(properties?: net.pb.Log.IRecord): net.pb.Log.Record;
|
|
875
|
+
|
|
876
|
+
/**
|
|
877
|
+
* Encodes the specified Record message. Does not implicitly {@link net.pb.Log.Record.verify|verify} messages.
|
|
878
|
+
* @param message Record message or plain object to encode
|
|
879
|
+
* @param [writer] Writer to encode to
|
|
880
|
+
* @returns Writer
|
|
881
|
+
*/
|
|
882
|
+
public static encode(message: net.pb.Log.IRecord, writer?: $protobuf.Writer): $protobuf.Writer;
|
|
883
|
+
|
|
884
|
+
/**
|
|
885
|
+
* Encodes the specified Record message, length delimited. Does not implicitly {@link net.pb.Log.Record.verify|verify} messages.
|
|
886
|
+
* @param message Record message or plain object to encode
|
|
887
|
+
* @param [writer] Writer to encode to
|
|
888
|
+
* @returns Writer
|
|
889
|
+
*/
|
|
890
|
+
public static encodeDelimited(message: net.pb.Log.IRecord, writer?: $protobuf.Writer): $protobuf.Writer;
|
|
891
|
+
|
|
892
|
+
/**
|
|
893
|
+
* Decodes a Record message from the specified reader or buffer.
|
|
894
|
+
* @param reader Reader or buffer to decode from
|
|
895
|
+
* @param [length] Message length if known beforehand
|
|
896
|
+
* @returns Record
|
|
897
|
+
* @throws {Error} If the payload is not a reader or valid buffer
|
|
898
|
+
* @throws {$protobuf.util.ProtocolError} If required fields are missing
|
|
899
|
+
*/
|
|
900
|
+
public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): net.pb.Log.Record;
|
|
901
|
+
|
|
902
|
+
/**
|
|
903
|
+
* Decodes a Record message from the specified reader or buffer, length delimited.
|
|
904
|
+
* @param reader Reader or buffer to decode from
|
|
905
|
+
* @returns Record
|
|
906
|
+
* @throws {Error} If the payload is not a reader or valid buffer
|
|
907
|
+
* @throws {$protobuf.util.ProtocolError} If required fields are missing
|
|
908
|
+
*/
|
|
909
|
+
public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): net.pb.Log.Record;
|
|
910
|
+
|
|
911
|
+
/**
|
|
912
|
+
* Verifies a Record message.
|
|
913
|
+
* @param message Plain object to verify
|
|
914
|
+
* @returns `null` if valid, otherwise the reason why it is not
|
|
915
|
+
*/
|
|
916
|
+
public static verify(message: { [k: string]: any }): (string|null);
|
|
917
|
+
|
|
918
|
+
/**
|
|
919
|
+
* Creates a Record message from a plain object. Also converts values to their respective internal types.
|
|
920
|
+
* @param object Plain object
|
|
921
|
+
* @returns Record
|
|
922
|
+
*/
|
|
923
|
+
public static fromObject(object: { [k: string]: any }): net.pb.Log.Record;
|
|
924
|
+
|
|
925
|
+
/**
|
|
926
|
+
* Creates a plain object from a Record message. Also converts values to other types if specified.
|
|
927
|
+
* @param message Record
|
|
928
|
+
* @param [options] Conversion options
|
|
929
|
+
* @returns Plain object
|
|
736
930
|
*/
|
|
737
931
|
public static toObject(message: net.pb.Log.Record, options?: $protobuf.IConversionOptions): { [k: string]: any };
|
|
738
932
|
|
|
@@ -2713,546 +2907,145 @@ declare namespace net {
|
|
|
2713
2907
|
* @returns JSON object
|
|
2714
2908
|
*/
|
|
2715
2909
|
public toJSON(): { [k: string]: any };
|
|
2716
|
-
|
|
2717
|
-
/**
|
|
2718
|
-
* Gets the default type url for ThreadEdges
|
|
2719
|
-
* @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
|
|
2720
|
-
* @returns The default type url
|
|
2721
|
-
*/
|
|
2722
|
-
public static getTypeUrl(typeUrlPrefix?: string): string;
|
|
2723
|
-
}
|
|
2724
|
-
}
|
|
2725
|
-
|
|
2726
|
-
/** Represents a Service */
|
|
2727
|
-
class Service extends $protobuf.rpc.Service {
|
|
2728
|
-
|
|
2729
|
-
/**
|
|
2730
|
-
* Constructs a new Service service.
|
|
2731
|
-
* @param rpcImpl RPC implementation
|
|
2732
|
-
* @param [requestDelimited=false] Whether requests are length-delimited
|
|
2733
|
-
* @param [responseDelimited=false] Whether responses are length-delimited
|
|
2734
|
-
*/
|
|
2735
|
-
constructor(rpcImpl: $protobuf.RPCImpl, requestDelimited?: boolean, responseDelimited?: boolean);
|
|
2736
|
-
|
|
2737
|
-
/**
|
|
2738
|
-
* Creates new Service service using the specified rpc implementation.
|
|
2739
|
-
* @param rpcImpl RPC implementation
|
|
2740
|
-
* @param [requestDelimited=false] Whether requests are length-delimited
|
|
2741
|
-
* @param [responseDelimited=false] Whether responses are length-delimited
|
|
2742
|
-
* @returns RPC service. Useful where requests and/or responses are streamed.
|
|
2743
|
-
*/
|
|
2744
|
-
public static create(rpcImpl: $protobuf.RPCImpl, requestDelimited?: boolean, responseDelimited?: boolean): Service;
|
|
2745
|
-
|
|
2746
|
-
/**
|
|
2747
|
-
* Calls GetLogs.
|
|
2748
|
-
* @param request GetLogsRequest message or plain object
|
|
2749
|
-
* @param callback Node-style callback called with the error, if any, and GetLogsReply
|
|
2750
|
-
*/
|
|
2751
|
-
public getLogs(request: net.pb.IGetLogsRequest, callback: net.pb.Service.GetLogsCallback): void;
|
|
2752
|
-
|
|
2753
|
-
/**
|
|
2754
|
-
* Calls GetLogs.
|
|
2755
|
-
* @param request GetLogsRequest message or plain object
|
|
2756
|
-
* @returns Promise
|
|
2757
|
-
*/
|
|
2758
|
-
public getLogs(request: net.pb.IGetLogsRequest): Promise<net.pb.GetLogsReply>;
|
|
2759
|
-
|
|
2760
|
-
/**
|
|
2761
|
-
* Calls PushLog.
|
|
2762
|
-
* @param request PushLogRequest message or plain object
|
|
2763
|
-
* @param callback Node-style callback called with the error, if any, and PushLogReply
|
|
2764
|
-
*/
|
|
2765
|
-
public pushLog(request: net.pb.IPushLogRequest, callback: net.pb.Service.PushLogCallback): void;
|
|
2766
|
-
|
|
2767
|
-
/**
|
|
2768
|
-
* Calls PushLog.
|
|
2769
|
-
* @param request PushLogRequest message or plain object
|
|
2770
|
-
* @returns Promise
|
|
2771
|
-
*/
|
|
2772
|
-
public pushLog(request: net.pb.IPushLogRequest): Promise<net.pb.PushLogReply>;
|
|
2773
|
-
|
|
2774
|
-
/**
|
|
2775
|
-
* Calls GetRecords.
|
|
2776
|
-
* @param request GetRecordsRequest message or plain object
|
|
2777
|
-
* @param callback Node-style callback called with the error, if any, and GetRecordsReply
|
|
2778
|
-
*/
|
|
2779
|
-
public getRecords(request: net.pb.IGetRecordsRequest, callback: net.pb.Service.GetRecordsCallback): void;
|
|
2780
|
-
|
|
2781
|
-
/**
|
|
2782
|
-
* Calls GetRecords.
|
|
2783
|
-
* @param request GetRecordsRequest message or plain object
|
|
2784
|
-
* @returns Promise
|
|
2785
|
-
*/
|
|
2786
|
-
public getRecords(request: net.pb.IGetRecordsRequest): Promise<net.pb.GetRecordsReply>;
|
|
2787
|
-
|
|
2788
|
-
/**
|
|
2789
|
-
* Calls PushRecord.
|
|
2790
|
-
* @param request PushRecordRequest message or plain object
|
|
2791
|
-
* @param callback Node-style callback called with the error, if any, and PushRecordReply
|
|
2792
|
-
*/
|
|
2793
|
-
public pushRecord(request: net.pb.IPushRecordRequest, callback: net.pb.Service.PushRecordCallback): void;
|
|
2794
|
-
|
|
2795
|
-
/**
|
|
2796
|
-
* Calls PushRecord.
|
|
2797
|
-
* @param request PushRecordRequest message or plain object
|
|
2798
|
-
* @returns Promise
|
|
2799
|
-
*/
|
|
2800
|
-
public pushRecord(request: net.pb.IPushRecordRequest): Promise<net.pb.PushRecordReply>;
|
|
2801
|
-
|
|
2802
|
-
/**
|
|
2803
|
-
* Calls ExchangeEdges.
|
|
2804
|
-
* @param request ExchangeEdgesRequest message or plain object
|
|
2805
|
-
* @param callback Node-style callback called with the error, if any, and ExchangeEdgesReply
|
|
2806
|
-
*/
|
|
2807
|
-
public exchangeEdges(request: net.pb.IExchangeEdgesRequest, callback: net.pb.Service.ExchangeEdgesCallback): void;
|
|
2808
|
-
|
|
2809
|
-
/**
|
|
2810
|
-
* Calls ExchangeEdges.
|
|
2811
|
-
* @param request ExchangeEdgesRequest message or plain object
|
|
2812
|
-
* @returns Promise
|
|
2813
|
-
*/
|
|
2814
|
-
public exchangeEdges(request: net.pb.IExchangeEdgesRequest): Promise<net.pb.ExchangeEdgesReply>;
|
|
2815
|
-
}
|
|
2816
|
-
|
|
2817
|
-
namespace Service {
|
|
2818
|
-
|
|
2819
|
-
/**
|
|
2820
|
-
* Callback as used by {@link net.pb.Service#getLogs}.
|
|
2821
|
-
* @param error Error, if any
|
|
2822
|
-
* @param [response] GetLogsReply
|
|
2823
|
-
*/
|
|
2824
|
-
type GetLogsCallback = (error: (Error|null), response?: net.pb.GetLogsReply) => void;
|
|
2825
|
-
|
|
2826
|
-
/**
|
|
2827
|
-
* Callback as used by {@link net.pb.Service#pushLog}.
|
|
2828
|
-
* @param error Error, if any
|
|
2829
|
-
* @param [response] PushLogReply
|
|
2830
|
-
*/
|
|
2831
|
-
type PushLogCallback = (error: (Error|null), response?: net.pb.PushLogReply) => void;
|
|
2832
|
-
|
|
2833
|
-
/**
|
|
2834
|
-
* Callback as used by {@link net.pb.Service#getRecords}.
|
|
2835
|
-
* @param error Error, if any
|
|
2836
|
-
* @param [response] GetRecordsReply
|
|
2837
|
-
*/
|
|
2838
|
-
type GetRecordsCallback = (error: (Error|null), response?: net.pb.GetRecordsReply) => void;
|
|
2839
|
-
|
|
2840
|
-
/**
|
|
2841
|
-
* Callback as used by {@link net.pb.Service#pushRecord}.
|
|
2842
|
-
* @param error Error, if any
|
|
2843
|
-
* @param [response] PushRecordReply
|
|
2844
|
-
*/
|
|
2845
|
-
type PushRecordCallback = (error: (Error|null), response?: net.pb.PushRecordReply) => void;
|
|
2846
|
-
|
|
2847
|
-
/**
|
|
2848
|
-
* Callback as used by {@link net.pb.Service#exchangeEdges}.
|
|
2849
|
-
* @param error Error, if any
|
|
2850
|
-
* @param [response] ExchangeEdgesReply
|
|
2851
|
-
*/
|
|
2852
|
-
type ExchangeEdgesCallback = (error: (Error|null), response?: net.pb.ExchangeEdgesReply) => void;
|
|
2853
|
-
}
|
|
2854
|
-
}
|
|
2855
|
-
}
|
|
2856
|
-
|
|
2857
|
-
type NewThreadOptions = {
|
|
2858
|
-
threadKey?: Key;
|
|
2859
|
-
logKey?: LogKey;
|
|
2860
|
-
token: ThreadToken;
|
|
2861
|
-
pubkey?: Ed25519PubKey;
|
|
2862
|
-
blockHeight: number;
|
|
2863
|
-
signature: Uint8Array;
|
|
2864
|
-
vaccount?: Ed25519PubKey;
|
|
2865
|
-
};
|
|
2866
|
-
|
|
2867
|
-
interface IThreadMetadata {
|
|
2868
|
-
getInt64(t: ThreadID, key: string): Promise<number | null>;
|
|
2869
|
-
putInt64(t: ThreadID, key: string, val: number): Promise<void>;
|
|
2870
|
-
getString(t: ThreadID, key: string): Promise<string | null>;
|
|
2871
|
-
putString(t: ThreadID, key: string, val: string): Promise<void>;
|
|
2872
|
-
getBool(t: ThreadID, key: string): Promise<boolean | null>;
|
|
2873
|
-
putBool(t: ThreadID, key: string, val: boolean): Promise<void>;
|
|
2874
|
-
getBytes(t: ThreadID, key: string): Promise<Uint8Array | null>;
|
|
2875
|
-
putBytes(t: ThreadID, key: string, val: Uint8Array): Promise<void>;
|
|
2876
|
-
clearMetadata(t: ThreadID): Promise<void>;
|
|
2877
|
-
dumpMeta(): Promise<DumpMetadata>;
|
|
2878
|
-
restoreMeta(book: DumpMetadata): Promise<void>;
|
|
2879
|
-
}
|
|
2880
|
-
interface KeyBook {
|
|
2881
|
-
pubKey(threadId: ThreadID, peerId: PeerId): Promise<PublicKey$1 | undefined>;
|
|
2882
|
-
addPubKey(threadId: ThreadID, peerId: PeerId, key: PublicKey$1): Promise<void>;
|
|
2883
|
-
privKey(threadId: ThreadID, peerId: PeerId): Promise<PrivateKey | null>;
|
|
2884
|
-
addPrivKey(threadId: ThreadID, peerId: PeerId, key: PrivateKey): Promise<void>;
|
|
2885
|
-
readKey(threadId: ThreadID): Promise<SymKey | undefined>;
|
|
2886
|
-
addReadKey(threadId: ThreadID, key: SymKey): Promise<void>;
|
|
2887
|
-
serviceKey(threadId: ThreadID): Promise<SymKey | undefined>;
|
|
2888
|
-
addServiceKey(threadId: ThreadID, key: SymKey): Promise<void>;
|
|
2889
|
-
clearKeys(threadId: ThreadID): Promise<void>;
|
|
2890
|
-
clearLogKeys(threadId: ThreadID, peerId: PeerId): Promise<void>;
|
|
2891
|
-
logsWithKeys(threadId: ThreadID): Promise<PeerId[]>;
|
|
2892
|
-
threadsFromKeys(): Promise<ThreadID[]>;
|
|
2893
|
-
dumpKeys(): Promise<DumpKeyBook>;
|
|
2894
|
-
restoreKeys(book: DumpKeyBook): Promise<void>;
|
|
2895
|
-
}
|
|
2896
|
-
interface AddrBook {
|
|
2897
|
-
addAddr(threadId: ThreadID, peerId: PeerId, addr: Multiaddr, ttl: number): Promise<void>;
|
|
2898
|
-
addAddrs(threadId: ThreadID, peerId: PeerId, addrs: Multiaddr[], ttl: number): Promise<void>;
|
|
2899
|
-
setAddr(threadId: ThreadID, peerId: PeerId, addr: Multiaddr, ttl: number): Promise<void>;
|
|
2900
|
-
setAddrs(threadId: ThreadID, peerId: PeerId, addrs: Multiaddr[], ttl: number): Promise<void>;
|
|
2901
|
-
updateAddrs(threadId: ThreadID, peerId: PeerId, oldTTL: number, newTTL: number): Promise<void>;
|
|
2902
|
-
addrs(threadId: ThreadID, peerId: PeerId): Promise<Multiaddr[]>;
|
|
2903
|
-
clearAddrs(threadId: ThreadID, peerId: PeerId): Promise<void>;
|
|
2904
|
-
logsWithAddrs(threadId: ThreadID): Promise<PeerId[]>;
|
|
2905
|
-
threadsFromAddrs(): Promise<ThreadID[]>;
|
|
2906
|
-
addrsEdge(threadId: ThreadID): Promise<number>;
|
|
2907
|
-
dumpAddrs(): Promise<DumpAddrBook>;
|
|
2908
|
-
restoreAddrs(book: DumpAddrBook): Promise<void>;
|
|
2909
|
-
}
|
|
2910
|
-
interface HeadBook {
|
|
2911
|
-
addHead(threadId: ThreadID, peerId: PeerId, head: Head): Promise<void>;
|
|
2912
|
-
addHeads(threadId: ThreadID, peerId: PeerId, heads: Head[]): Promise<void>;
|
|
2913
|
-
setHead(threadId: ThreadID, peerId: PeerId, head: Head): Promise<void>;
|
|
2914
|
-
setHeads(threadId: ThreadID, peerId: PeerId, heads: Head[]): Promise<void>;
|
|
2915
|
-
heads(threadId: ThreadID, peerId: PeerId): Promise<Head[]>;
|
|
2916
|
-
clearHeads(threadId: ThreadID, peerId: PeerId): Promise<void>;
|
|
2917
|
-
headsEdge(threadId: ThreadID): Promise<number>;
|
|
2918
|
-
dumpHeads(): Promise<DumpHeadBook>;
|
|
2919
|
-
restoreHeads(book: DumpHeadBook): Promise<void>;
|
|
2920
|
-
}
|
|
2921
|
-
interface ILogstore {
|
|
2922
|
-
metadata: IThreadMetadata;
|
|
2923
|
-
keyBook: KeyBook;
|
|
2924
|
-
addrBook: AddrBook;
|
|
2925
|
-
headBook: HeadBook;
|
|
2926
|
-
close(): Promise<void>;
|
|
2927
|
-
threads(): Promise<ThreadID[]>;
|
|
2928
|
-
addThread(info: IThreadInfo): Promise<void>;
|
|
2929
|
-
getThread(threadId: ThreadID): Promise<IThreadInfo>;
|
|
2930
|
-
deleteThread(threadId: ThreadID): Promise<void>;
|
|
2931
|
-
addLog(threadId: ThreadID, logInfo: IThreadLogInfo): Promise<void>;
|
|
2932
|
-
getLog(threadId: ThreadID, peerId: PeerId): Promise<IThreadLogInfo>;
|
|
2933
|
-
getManagedLogs(threadId: ThreadID): Promise<IThreadLogInfo[]>;
|
|
2934
|
-
deleteLog(threadId: ThreadID, peerId: PeerId): Promise<void>;
|
|
2935
|
-
}
|
|
2936
|
-
interface ExpiredAddress {
|
|
2937
|
-
addr: Multiaddr;
|
|
2938
|
-
expires: Date;
|
|
2939
|
-
}
|
|
2940
|
-
interface DumpHeadBook {
|
|
2941
|
-
data: Record<string, Record<string, Head[]>>;
|
|
2942
|
-
}
|
|
2943
|
-
interface DumpAddrBook {
|
|
2944
|
-
data: Record<string, Record<string, ExpiredAddress[]>>;
|
|
2945
|
-
}
|
|
2946
|
-
interface DumpKeyBook {
|
|
2947
|
-
data: {
|
|
2948
|
-
public: Record<string, Record<string, PublicKey$1>>;
|
|
2949
|
-
private: Record<string, Record<string, PrivateKey>>;
|
|
2950
|
-
read: Record<string, Uint8Array>;
|
|
2951
|
-
service: Record<string, Uint8Array>;
|
|
2952
|
-
};
|
|
2953
|
-
}
|
|
2954
|
-
interface DumpMetadata {
|
|
2955
|
-
data: {
|
|
2956
|
-
int64: Record<string, Record<string, number>>;
|
|
2957
|
-
bool: Record<string, Record<string, boolean>>;
|
|
2958
|
-
string: Record<string, Record<string, string>>;
|
|
2959
|
-
bytes: Record<string, Record<string, Uint8Array>>;
|
|
2960
|
-
};
|
|
2961
|
-
}
|
|
2962
|
-
|
|
2963
|
-
/**
|
|
2964
|
-
* Records with counters from a peer
|
|
2965
|
-
*/
|
|
2966
|
-
interface PeerRecords {
|
|
2967
|
-
records: IRecord[];
|
|
2968
|
-
counter: number;
|
|
2969
|
-
}
|
|
2970
|
-
|
|
2971
|
-
declare class DBClient {
|
|
2972
|
-
client: Client;
|
|
2973
|
-
dc: DcUtil;
|
|
2974
|
-
logstore: ILogstore;
|
|
2975
|
-
net: Net;
|
|
2976
|
-
constructor(dcClient: Client, dcUtil: DcUtil, net: Net, logstore: ILogstore);
|
|
2977
|
-
requestThreadID(peerAddr?: Multiaddr): Promise<string>;
|
|
2978
|
-
createThread(tid: string, opts: NewThreadOptions): Promise<string>;
|
|
2979
|
-
pushRecordToPeer(tid: ThreadID, lid: PeerId, rec: IRecord, counter: number): Promise<void>;
|
|
2980
|
-
/**
|
|
2981
|
-
* 与对等点交换边缘(状态信息)
|
|
2982
|
-
* @param threadIds threadID数组
|
|
2983
|
-
* @returns 无返回值
|
|
2984
|
-
*/
|
|
2985
|
-
exchangeEdges(threadIds: ThreadID[]): Promise<void>;
|
|
2986
|
-
/**
|
|
2987
|
-
* 获取threaddb 的本地边缘值(地址和头部)
|
|
2988
|
-
* 边缘值用于确定是否需要从远程对等点获取更新
|
|
2989
|
-
*
|
|
2990
|
-
* @param tid threaddb ID
|
|
2991
|
-
* @returns 地址边缘值和头部边缘值的对象
|
|
2992
|
-
* @throws 错误,包括特定的"No address edge"和"No heads edge"错误
|
|
2993
|
-
*/
|
|
2994
|
-
private localEdges;
|
|
2995
|
-
/**
|
|
2996
|
-
* 调度日志更新
|
|
2997
|
-
* @param tid threaddb ID
|
|
2998
|
-
*/
|
|
2999
|
-
scheduleUpdateLogs(tid: ThreadID): Promise<void>;
|
|
3000
|
-
/**
|
|
3001
|
-
* 调度记录更新
|
|
3002
|
-
* @param tid threaddb ID
|
|
3003
|
-
*/
|
|
3004
|
-
private scheduleUpdateRecords;
|
|
3005
|
-
/**
|
|
3006
|
-
* 构建获取记录的请求
|
|
3007
|
-
*/
|
|
3008
|
-
private buildGetRecordsRequest;
|
|
3009
|
-
/**
|
|
3010
|
-
* 获取threaddb 中的日志
|
|
3011
|
-
* @param tid threaddb ID
|
|
3012
|
-
* @param pid 对等点ID
|
|
3013
|
-
* @returns 日志信息数组
|
|
3014
|
-
*/
|
|
3015
|
-
getLogs(tid: ThreadID): Promise<IThreadLogInfo[]>;
|
|
3016
|
-
getRecordsFromPeer(req: any, serviceKey: SymKey): Promise<Record<string, PeerRecords>>;
|
|
3017
|
-
getThreadFromPeer(id: ThreadID, peerId: PeerId, options?: {
|
|
3018
|
-
token?: ThreadToken;
|
|
3019
|
-
}): Promise<IThreadInfo>;
|
|
3020
|
-
}
|
|
3021
|
-
|
|
3022
|
-
declare class AsyncMutex {
|
|
3023
|
-
private _locked;
|
|
3024
|
-
private _queue;
|
|
3025
|
-
acquire(): Promise<void>;
|
|
3026
|
-
release(): void;
|
|
3027
|
-
}
|
|
3028
|
-
|
|
3029
|
-
type PubKey = Ed25519PubKey;
|
|
3030
|
-
type Token = Uint8Array;
|
|
3031
|
-
interface App {
|
|
3032
|
-
validateNetRecordBody(body: IPLDNode, identity: PubKey): Promise<Error | undefined>;
|
|
3033
|
-
handleNetRecord(rec: IThreadRecord, key?: Key): Promise<Error | undefined>;
|
|
3034
|
-
getNetRecordCreateTime(rec: IThreadRecord, key?: Key): Promise<BigInt>;
|
|
3035
|
-
}
|
|
3036
|
-
declare class LocalEventsBus {
|
|
3037
|
-
private bus;
|
|
3038
|
-
private static readonly busTimeout;
|
|
3039
|
-
send(event: LocalEvent): Promise<void>;
|
|
3040
|
-
listen(): LocalEventListener;
|
|
3041
|
-
discard(): void;
|
|
3042
|
-
}
|
|
3043
|
-
declare class LocalEventListener {
|
|
3044
|
-
private bus;
|
|
3045
|
-
private handler;
|
|
3046
|
-
constructor(bus: EventEmitter);
|
|
3047
|
-
private onEvent;
|
|
3048
|
-
discard(): void;
|
|
3049
|
-
}
|
|
3050
|
-
interface LocalEvent {
|
|
3051
|
-
node: IPLDNode;
|
|
3052
|
-
token: ThreadToken;
|
|
3053
|
-
}
|
|
3054
|
-
interface Net extends INet {
|
|
3055
|
-
bstore: Blocks;
|
|
3056
|
-
connectApp(app: App, threadId: ThreadID): Promise<Connector>;
|
|
3057
|
-
createRecord(threadId: ThreadID, body: IPLDNode, options?: {
|
|
3058
|
-
threadToken?: ThreadToken;
|
|
3059
|
-
apiToken?: Token;
|
|
3060
|
-
}): Promise<IThreadRecord>;
|
|
3061
|
-
validate(id: ThreadID, token?: ThreadToken): Promise<Ed25519PubKey | undefined>;
|
|
3062
|
-
exchange(id: ThreadID): Promise<void>;
|
|
3063
|
-
threadOffsets(tid: ThreadID): Promise<[Record<string, Head>, PeerId[]]>;
|
|
3064
|
-
buildGetRecordsRequest(tid: ThreadID, offsets: Record<string, Head>, limit: number): Promise<{
|
|
3065
|
-
req: net.pb.IGetRecordsRequest;
|
|
3066
|
-
serviceKey: SymKey;
|
|
3067
|
-
}>;
|
|
3068
|
-
updateRecordsFromPeer(tid: ThreadID, peerId: PeerId | null, client?: DBClient): Promise<void>;
|
|
3069
|
-
getMutexForThread(threadId: string): AsyncMutex;
|
|
3070
|
-
preLoadLogs(tid: ThreadID, logs: net.pb.Log[]): Promise<void>;
|
|
3071
|
-
createExternalLogsIfNotExist(tid: ThreadID, logs: IThreadLogInfo[]): Promise<void>;
|
|
3072
|
-
createExternalLogsIfNotExistForPreload(tid: ThreadID, logs: IThreadLogInfo[]): Promise<void>;
|
|
3073
|
-
}
|
|
3074
|
-
declare class Connector {
|
|
3075
|
-
net: Net;
|
|
3076
|
-
private app;
|
|
3077
|
-
private threadInfo;
|
|
3078
|
-
readonly token: Token;
|
|
3079
|
-
constructor(net: Net, app: App, threadInfo: ThreadInfo);
|
|
3080
|
-
get threadId(): ThreadID;
|
|
3081
|
-
get threadKey(): Key | undefined;
|
|
3082
|
-
createNetRecord(body: IPLDNode, token?: ThreadToken): Promise<IThreadRecord>;
|
|
3083
|
-
validate(token?: ThreadToken): Promise<Error | undefined>;
|
|
3084
|
-
validateNetRecordBody(body: IPLDNode, identity: PubKey): Promise<Error | undefined>;
|
|
3085
|
-
handleNetRecord(rec: IThreadRecord): Promise<Error | undefined>;
|
|
3086
|
-
getNetRecordCreateTime(rec: IThreadRecord): Promise<BigInt>;
|
|
3087
|
-
private generateRandomBytes;
|
|
3088
|
-
}
|
|
3089
|
-
|
|
3090
|
-
interface Reducer {
|
|
3091
|
-
reduce(events: Event[]): Promise<void>;
|
|
3092
|
-
}
|
|
3093
|
-
declare class Dispatcher {
|
|
3094
|
-
private store;
|
|
3095
|
-
private reducers;
|
|
3096
|
-
private lock;
|
|
3097
|
-
private lastID;
|
|
3098
|
-
constructor(store: TxnDatastoreExtended);
|
|
3099
|
-
getStore(): TxnDatastoreExtended;
|
|
3100
|
-
register(reducer: Reducer): void;
|
|
3101
|
-
dispatch(events: Event[]): Promise<void>;
|
|
3102
|
-
query(query: Query$1): AsyncIterable<Pair>;
|
|
3103
|
-
private getKey;
|
|
3104
|
-
}
|
|
3105
|
-
|
|
3106
|
-
type InstanceID$1 = string;
|
|
3107
|
-
declare enum CoreActionType {
|
|
3108
|
-
Create = 0,
|
|
3109
|
-
Save = 1,
|
|
3110
|
-
Delete = 2
|
|
3111
|
-
}
|
|
3112
|
-
/**
|
|
3113
|
-
* Transaction class for collections
|
|
3114
|
-
*/
|
|
3115
|
-
interface ITxn {
|
|
3116
|
-
/**
|
|
3117
|
-
* Create new instances
|
|
3118
|
-
*/
|
|
3119
|
-
create(...newInstances: Uint8Array[]): Promise<InstanceID$1[]>;
|
|
3120
|
-
/**
|
|
3121
|
-
* Verify instance changes without saving them
|
|
3122
|
-
*/
|
|
3123
|
-
verify(...updated: Uint8Array[]): Promise<void>;
|
|
3124
|
-
/**
|
|
3125
|
-
* Save instance changes
|
|
3126
|
-
*/
|
|
3127
|
-
save(...updated: Uint8Array[]): Promise<void>;
|
|
3128
|
-
/**
|
|
3129
|
-
* Delete instances
|
|
3130
|
-
*/
|
|
3131
|
-
delete(...ids: InstanceID$1[]): Promise<void>;
|
|
3132
|
-
/**
|
|
3133
|
-
* Check if instances exist
|
|
3134
|
-
*/
|
|
3135
|
-
has(...ids: InstanceID$1[]): Promise<boolean>;
|
|
3136
|
-
/**
|
|
3137
|
-
* Find instance by ID
|
|
3138
|
-
*/
|
|
3139
|
-
findByID(id: InstanceID$1): Promise<Object>;
|
|
3140
|
-
/**
|
|
3141
|
-
* Find instances matching a query
|
|
3142
|
-
*/
|
|
3143
|
-
find(q?: Query$1): Promise<Object[]>;
|
|
3144
|
-
/**
|
|
3145
|
-
* Get instances modified since a specific time
|
|
3146
|
-
*
|
|
3147
|
-
* The _mod field tracks modified instances, but not those that have been deleted, so we need
|
|
3148
|
-
* to query the dispatcher for all (unique) instances in this collection that have been modified
|
|
3149
|
-
* at all since `time`.
|
|
3150
|
-
*/
|
|
3151
|
-
modifiedSince(time: number): Promise<InstanceID$1[]>;
|
|
3152
|
-
/**
|
|
3153
|
-
* Commit the transaction
|
|
3154
|
-
*/
|
|
3155
|
-
commit(): Promise<void>;
|
|
3156
|
-
/**
|
|
3157
|
-
* Discard the transaction
|
|
3158
|
-
*/
|
|
3159
|
-
discard(): void;
|
|
3160
|
-
/**
|
|
3161
|
-
* Refresh collection reference
|
|
3162
|
-
*/
|
|
3163
|
-
refreshCollection(): void;
|
|
3164
|
-
}
|
|
3165
|
-
interface ICollection {
|
|
3166
|
-
baseKey(): Key$1;
|
|
3167
|
-
getName(): string;
|
|
3168
|
-
getSchema(): Uint8Array;
|
|
3169
|
-
getWriteValidator(): Uint8Array;
|
|
3170
|
-
getReadFilter(): Uint8Array;
|
|
3171
|
-
readTxn(fn: (txn: ITxn) => Promise<void>, token?: ThreadToken): Promise<void>;
|
|
3172
|
-
writeTxn(fn: (txn: ITxn) => Promise<void>, token?: ThreadToken): Promise<void>;
|
|
3173
|
-
findByID(id: InstanceID$1, token?: ThreadToken): Promise<Object>;
|
|
3174
|
-
create(v: Uint8Array, token?: ThreadToken): Promise<InstanceID$1>;
|
|
3175
|
-
createMany(vs: Uint8Array[], token?: ThreadToken): Promise<InstanceID$1[]>;
|
|
3176
|
-
delete(id: InstanceID$1, token?: ThreadToken): Promise<void>;
|
|
3177
|
-
deleteMany(ids: InstanceID$1[], token?: ThreadToken): Promise<void>;
|
|
3178
|
-
save(v: Uint8Array, token?: ThreadToken): Promise<void>;
|
|
3179
|
-
saveMany(vs: Uint8Array[], token?: ThreadToken): Promise<void>;
|
|
3180
|
-
verify(v: Uint8Array, token?: ThreadToken): Promise<void>;
|
|
3181
|
-
verifyMany(vs: Uint8Array[], token?: ThreadToken): Promise<void>;
|
|
3182
|
-
has(id: InstanceID$1, token?: ThreadToken): Promise<boolean>;
|
|
3183
|
-
hasMany(ids: InstanceID$1[], token?: ThreadToken): Promise<boolean>;
|
|
3184
|
-
find(q: Query$1, token?: ThreadToken): Promise<Object[]>;
|
|
3185
|
-
modifiedSince(time: number, token?: ThreadToken): Promise<InstanceID$1[]>;
|
|
3186
|
-
validInstance(v: Uint8Array): void;
|
|
3187
|
-
validWrite(identity: Ed25519PubKey, e: Event): Promise<void>;
|
|
3188
|
-
filterRead(identity: Ed25519PubKey, instance: Uint8Array): Promise<Uint8Array | null>;
|
|
3189
|
-
}
|
|
3190
|
-
interface IDB {
|
|
3191
|
-
datastore: TxnDatastoreExtended;
|
|
3192
|
-
connector: Connector | null;
|
|
3193
|
-
dispatcher: Dispatcher | null;
|
|
3194
|
-
eventcodec: EventCodec;
|
|
3195
|
-
localEventsBus: LocalEventsBus | null;
|
|
3196
|
-
collections: Map<string, ICollection>;
|
|
3197
|
-
readTxn(collection: ICollection, fn: (txn: ITxn) => Promise<void>, token?: ThreadToken): Promise<void>;
|
|
3198
|
-
writeTxn(collection: ICollection, fn: (txn: ITxn) => Promise<void>, token?: ThreadToken): Promise<void>;
|
|
3199
|
-
notifyTxnEvents(node: IPLDNode, token?: ThreadToken): Promise<void>;
|
|
3200
|
-
}
|
|
3201
|
-
interface Event<T = any> {
|
|
3202
|
-
/** 事件时间戳 (Unix纳秒时间戳) */
|
|
3203
|
-
readonly timestamp: BigInt;
|
|
3204
|
-
/** 关联的实例ID */
|
|
3205
|
-
readonly instanceID: InstanceID$1;
|
|
3206
|
-
/** 所属集合名称 */
|
|
3207
|
-
readonly collection: string;
|
|
3208
|
-
/** 事件负载数据 */
|
|
3209
|
-
readonly payload: T;
|
|
3210
|
-
/** 序列化为Uint8Array */
|
|
3211
|
-
marshal(): Promise<Uint8Array>;
|
|
3212
|
-
}
|
|
3213
|
-
interface QueryResult {
|
|
3214
|
-
key: string;
|
|
3215
|
-
value: Uint8Array;
|
|
3216
|
-
size?: number;
|
|
3217
|
-
}
|
|
3218
|
-
interface QueryExt extends Query$1 {
|
|
3219
|
-
seekPrefix?: string;
|
|
3220
|
-
}
|
|
3221
|
-
interface Transaction {
|
|
3222
|
-
put(key: Key$1, value: Uint8Array): Promise<Key$1>;
|
|
3223
|
-
delete(key: Key$1): Promise<void>;
|
|
3224
|
-
get(key: Key$1): Promise<Uint8Array | undefined>;
|
|
3225
|
-
has(key: Key$1): Promise<boolean>;
|
|
3226
|
-
commit(): Promise<void>;
|
|
3227
|
-
discard(): void;
|
|
3228
|
-
query(q: Query$1): AsyncIterable<QueryResult>;
|
|
3229
|
-
queryExtended(q: QueryExt): AsyncIterable<QueryResult>;
|
|
3230
|
-
}
|
|
3231
|
-
interface DatastoreExtensions {
|
|
3232
|
-
newTransactionExtended(readOnly: boolean): Promise<Transaction>;
|
|
3233
|
-
queryExtended(q: QueryExt): AsyncIterable<QueryResult>;
|
|
3234
|
-
}
|
|
3235
|
-
interface TxnDatastoreExtended extends Datastore, DatastoreExtensions {
|
|
3236
|
-
batch(): Batch;
|
|
3237
|
-
newTransactionExtended(readOnly: boolean): Promise<Transaction>;
|
|
3238
|
-
}
|
|
3239
|
-
type IndexFunc = (collection: string, key: Key$1, txn: Transaction, oldData?: Uint8Array, newData?: Uint8Array) => Promise<void>;
|
|
3240
|
-
interface Action {
|
|
3241
|
-
type: CoreActionType;
|
|
3242
|
-
instanceID: InstanceID$1;
|
|
3243
|
-
collectionName: string;
|
|
3244
|
-
previous?: Uint8Array;
|
|
3245
|
-
current?: Uint8Array;
|
|
3246
|
-
}
|
|
3247
|
-
interface ReduceAction {
|
|
3248
|
-
type: CoreActionType;
|
|
3249
|
-
collection: string;
|
|
3250
|
-
instanceID: InstanceID$1;
|
|
3251
|
-
}
|
|
3252
|
-
interface EventCodec {
|
|
3253
|
-
reduce(events: Event[], store: TxnDatastoreExtended, baseKey: Key$1, indexFn: IndexFunc): Promise<ReduceAction[]>;
|
|
3254
|
-
create(actions: Action[]): Promise<[Event[], IPLDNode]>;
|
|
3255
|
-
eventsFromBytes(data: Uint8Array): Promise<Event[]>;
|
|
2910
|
+
|
|
2911
|
+
/**
|
|
2912
|
+
* Gets the default type url for ThreadEdges
|
|
2913
|
+
* @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
|
|
2914
|
+
* @returns The default type url
|
|
2915
|
+
*/
|
|
2916
|
+
public static getTypeUrl(typeUrlPrefix?: string): string;
|
|
2917
|
+
}
|
|
2918
|
+
}
|
|
2919
|
+
|
|
2920
|
+
/** Represents a Service */
|
|
2921
|
+
class Service extends $protobuf.rpc.Service {
|
|
2922
|
+
|
|
2923
|
+
/**
|
|
2924
|
+
* Constructs a new Service service.
|
|
2925
|
+
* @param rpcImpl RPC implementation
|
|
2926
|
+
* @param [requestDelimited=false] Whether requests are length-delimited
|
|
2927
|
+
* @param [responseDelimited=false] Whether responses are length-delimited
|
|
2928
|
+
*/
|
|
2929
|
+
constructor(rpcImpl: $protobuf.RPCImpl, requestDelimited?: boolean, responseDelimited?: boolean);
|
|
2930
|
+
|
|
2931
|
+
/**
|
|
2932
|
+
* Creates new Service service using the specified rpc implementation.
|
|
2933
|
+
* @param rpcImpl RPC implementation
|
|
2934
|
+
* @param [requestDelimited=false] Whether requests are length-delimited
|
|
2935
|
+
* @param [responseDelimited=false] Whether responses are length-delimited
|
|
2936
|
+
* @returns RPC service. Useful where requests and/or responses are streamed.
|
|
2937
|
+
*/
|
|
2938
|
+
public static create(rpcImpl: $protobuf.RPCImpl, requestDelimited?: boolean, responseDelimited?: boolean): Service;
|
|
2939
|
+
|
|
2940
|
+
/**
|
|
2941
|
+
* Calls GetLogs.
|
|
2942
|
+
* @param request GetLogsRequest message or plain object
|
|
2943
|
+
* @param callback Node-style callback called with the error, if any, and GetLogsReply
|
|
2944
|
+
*/
|
|
2945
|
+
public getLogs(request: net.pb.IGetLogsRequest, callback: net.pb.Service.GetLogsCallback): void;
|
|
2946
|
+
|
|
2947
|
+
/**
|
|
2948
|
+
* Calls GetLogs.
|
|
2949
|
+
* @param request GetLogsRequest message or plain object
|
|
2950
|
+
* @returns Promise
|
|
2951
|
+
*/
|
|
2952
|
+
public getLogs(request: net.pb.IGetLogsRequest): Promise<net.pb.GetLogsReply>;
|
|
2953
|
+
|
|
2954
|
+
/**
|
|
2955
|
+
* Calls PushLog.
|
|
2956
|
+
* @param request PushLogRequest message or plain object
|
|
2957
|
+
* @param callback Node-style callback called with the error, if any, and PushLogReply
|
|
2958
|
+
*/
|
|
2959
|
+
public pushLog(request: net.pb.IPushLogRequest, callback: net.pb.Service.PushLogCallback): void;
|
|
2960
|
+
|
|
2961
|
+
/**
|
|
2962
|
+
* Calls PushLog.
|
|
2963
|
+
* @param request PushLogRequest message or plain object
|
|
2964
|
+
* @returns Promise
|
|
2965
|
+
*/
|
|
2966
|
+
public pushLog(request: net.pb.IPushLogRequest): Promise<net.pb.PushLogReply>;
|
|
2967
|
+
|
|
2968
|
+
/**
|
|
2969
|
+
* Calls GetRecords.
|
|
2970
|
+
* @param request GetRecordsRequest message or plain object
|
|
2971
|
+
* @param callback Node-style callback called with the error, if any, and GetRecordsReply
|
|
2972
|
+
*/
|
|
2973
|
+
public getRecords(request: net.pb.IGetRecordsRequest, callback: net.pb.Service.GetRecordsCallback): void;
|
|
2974
|
+
|
|
2975
|
+
/**
|
|
2976
|
+
* Calls GetRecords.
|
|
2977
|
+
* @param request GetRecordsRequest message or plain object
|
|
2978
|
+
* @returns Promise
|
|
2979
|
+
*/
|
|
2980
|
+
public getRecords(request: net.pb.IGetRecordsRequest): Promise<net.pb.GetRecordsReply>;
|
|
2981
|
+
|
|
2982
|
+
/**
|
|
2983
|
+
* Calls PushRecord.
|
|
2984
|
+
* @param request PushRecordRequest message or plain object
|
|
2985
|
+
* @param callback Node-style callback called with the error, if any, and PushRecordReply
|
|
2986
|
+
*/
|
|
2987
|
+
public pushRecord(request: net.pb.IPushRecordRequest, callback: net.pb.Service.PushRecordCallback): void;
|
|
2988
|
+
|
|
2989
|
+
/**
|
|
2990
|
+
* Calls PushRecord.
|
|
2991
|
+
* @param request PushRecordRequest message or plain object
|
|
2992
|
+
* @returns Promise
|
|
2993
|
+
*/
|
|
2994
|
+
public pushRecord(request: net.pb.IPushRecordRequest): Promise<net.pb.PushRecordReply>;
|
|
2995
|
+
|
|
2996
|
+
/**
|
|
2997
|
+
* Calls ExchangeEdges.
|
|
2998
|
+
* @param request ExchangeEdgesRequest message or plain object
|
|
2999
|
+
* @param callback Node-style callback called with the error, if any, and ExchangeEdgesReply
|
|
3000
|
+
*/
|
|
3001
|
+
public exchangeEdges(request: net.pb.IExchangeEdgesRequest, callback: net.pb.Service.ExchangeEdgesCallback): void;
|
|
3002
|
+
|
|
3003
|
+
/**
|
|
3004
|
+
* Calls ExchangeEdges.
|
|
3005
|
+
* @param request ExchangeEdgesRequest message or plain object
|
|
3006
|
+
* @returns Promise
|
|
3007
|
+
*/
|
|
3008
|
+
public exchangeEdges(request: net.pb.IExchangeEdgesRequest): Promise<net.pb.ExchangeEdgesReply>;
|
|
3009
|
+
}
|
|
3010
|
+
|
|
3011
|
+
namespace Service {
|
|
3012
|
+
|
|
3013
|
+
/**
|
|
3014
|
+
* Callback as used by {@link net.pb.Service#getLogs}.
|
|
3015
|
+
* @param error Error, if any
|
|
3016
|
+
* @param [response] GetLogsReply
|
|
3017
|
+
*/
|
|
3018
|
+
type GetLogsCallback = (error: (Error|null), response?: net.pb.GetLogsReply) => void;
|
|
3019
|
+
|
|
3020
|
+
/**
|
|
3021
|
+
* Callback as used by {@link net.pb.Service#pushLog}.
|
|
3022
|
+
* @param error Error, if any
|
|
3023
|
+
* @param [response] PushLogReply
|
|
3024
|
+
*/
|
|
3025
|
+
type PushLogCallback = (error: (Error|null), response?: net.pb.PushLogReply) => void;
|
|
3026
|
+
|
|
3027
|
+
/**
|
|
3028
|
+
* Callback as used by {@link net.pb.Service#getRecords}.
|
|
3029
|
+
* @param error Error, if any
|
|
3030
|
+
* @param [response] GetRecordsReply
|
|
3031
|
+
*/
|
|
3032
|
+
type GetRecordsCallback = (error: (Error|null), response?: net.pb.GetRecordsReply) => void;
|
|
3033
|
+
|
|
3034
|
+
/**
|
|
3035
|
+
* Callback as used by {@link net.pb.Service#pushRecord}.
|
|
3036
|
+
* @param error Error, if any
|
|
3037
|
+
* @param [response] PushRecordReply
|
|
3038
|
+
*/
|
|
3039
|
+
type PushRecordCallback = (error: (Error|null), response?: net.pb.PushRecordReply) => void;
|
|
3040
|
+
|
|
3041
|
+
/**
|
|
3042
|
+
* Callback as used by {@link net.pb.Service#exchangeEdges}.
|
|
3043
|
+
* @param error Error, if any
|
|
3044
|
+
* @param [response] ExchangeEdgesReply
|
|
3045
|
+
*/
|
|
3046
|
+
type ExchangeEdgesCallback = (error: (Error|null), response?: net.pb.ExchangeEdgesReply) => void;
|
|
3047
|
+
}
|
|
3048
|
+
}
|
|
3256
3049
|
}
|
|
3257
3050
|
|
|
3258
3051
|
interface Context {
|
|
@@ -3321,105 +3114,319 @@ interface SymKey {
|
|
|
3321
3114
|
key: CryptoKey;
|
|
3322
3115
|
raw: Uint8Array;
|
|
3323
3116
|
}
|
|
3324
|
-
declare class ThreadMuliaddr {
|
|
3117
|
+
declare class ThreadMuliaddr {
|
|
3118
|
+
addr: Multiaddr;
|
|
3119
|
+
id: ThreadID;
|
|
3120
|
+
constructor(addr: Multiaddr, id: ThreadID);
|
|
3121
|
+
getMultiaddrString(): string;
|
|
3122
|
+
}
|
|
3123
|
+
interface IThreadInfo {
|
|
3124
|
+
id: ThreadID;
|
|
3125
|
+
key: Key | undefined;
|
|
3126
|
+
logs: IThreadLogInfo[];
|
|
3127
|
+
addrs: ThreadMuliaddr[];
|
|
3128
|
+
getFirstPrivKeyLog(): IThreadLogInfo | undefined;
|
|
3129
|
+
}
|
|
3130
|
+
interface IDBInfo {
|
|
3131
|
+
id: string;
|
|
3132
|
+
name: string;
|
|
3133
|
+
addrs: string[];
|
|
3134
|
+
key: string | undefined;
|
|
3135
|
+
}
|
|
3136
|
+
declare class ThreadInfo implements IThreadInfo {
|
|
3137
|
+
id: ThreadID;
|
|
3138
|
+
logs: IThreadLogInfo[];
|
|
3139
|
+
addrs: ThreadMuliaddr[];
|
|
3140
|
+
key: Key | undefined;
|
|
3141
|
+
constructor(id: ThreadID, logs: IThreadLogInfo[], addrs: ThreadMuliaddr[], key?: Key);
|
|
3142
|
+
getFirstPrivKeyLog(): IThreadLogInfo | undefined;
|
|
3143
|
+
}
|
|
3144
|
+
interface IThreadLogInfo {
|
|
3145
|
+
id: PeerId;
|
|
3146
|
+
privKey?: PrivateKey;
|
|
3147
|
+
pubKey?: PublicKey;
|
|
3148
|
+
addrs: Multiaddr[];
|
|
3149
|
+
managed: boolean;
|
|
3150
|
+
head?: Head;
|
|
3151
|
+
}
|
|
3152
|
+
|
|
3153
|
+
type Signature = Uint8Array;
|
|
3154
|
+
interface IRecord extends IPLDNode {
|
|
3155
|
+
/** 获取内部区块的 CID */
|
|
3156
|
+
blockID: () => CID;
|
|
3157
|
+
/** 异步加载内部区块 */
|
|
3158
|
+
getBlock: (bstore: Blocks) => Promise<IPLDNode>;
|
|
3159
|
+
/** 前一个记录的 CID */
|
|
3160
|
+
prevID: () => CID | undefined;
|
|
3161
|
+
/** 记录的数字签名 */
|
|
3162
|
+
sig: () => Signature;
|
|
3163
|
+
/** 作者的原始公钥字节 */
|
|
3164
|
+
pubKey: () => Uint8Array;
|
|
3165
|
+
/** 验证签名有效性 */
|
|
3166
|
+
verify: (key: PublicKey$1) => Promise<Error | undefined>;
|
|
3167
|
+
}
|
|
3168
|
+
interface IThreadRecord {
|
|
3169
|
+
/** 获取底层记录对象 */
|
|
3170
|
+
value: () => IRecord;
|
|
3171
|
+
/** 所属线程的标识符 */
|
|
3172
|
+
threadID: () => ThreadID;
|
|
3173
|
+
/** 日志来源的对等节点ID */
|
|
3174
|
+
logID: () => PeerId;
|
|
3175
|
+
}
|
|
3176
|
+
|
|
3177
|
+
type NewThreadOptions = {
|
|
3178
|
+
threadKey?: Key;
|
|
3179
|
+
logKey?: LogKey;
|
|
3180
|
+
token: ThreadToken;
|
|
3181
|
+
pubkey?: Ed25519PubKey;
|
|
3182
|
+
blockHeight: number;
|
|
3183
|
+
signature: Uint8Array;
|
|
3184
|
+
vaccount?: Ed25519PubKey;
|
|
3185
|
+
};
|
|
3186
|
+
|
|
3187
|
+
interface IThreadMetadata {
|
|
3188
|
+
getInt64(t: ThreadID, key: string): Promise<number | null>;
|
|
3189
|
+
putInt64(t: ThreadID, key: string, val: number): Promise<void>;
|
|
3190
|
+
getString(t: ThreadID, key: string): Promise<string | null>;
|
|
3191
|
+
putString(t: ThreadID, key: string, val: string): Promise<void>;
|
|
3192
|
+
getBool(t: ThreadID, key: string): Promise<boolean | null>;
|
|
3193
|
+
putBool(t: ThreadID, key: string, val: boolean): Promise<void>;
|
|
3194
|
+
getBytes(t: ThreadID, key: string): Promise<Uint8Array | null>;
|
|
3195
|
+
putBytes(t: ThreadID, key: string, val: Uint8Array): Promise<void>;
|
|
3196
|
+
clearMetadata(t: ThreadID): Promise<void>;
|
|
3197
|
+
dumpMeta(): Promise<DumpMetadata>;
|
|
3198
|
+
restoreMeta(book: DumpMetadata): Promise<void>;
|
|
3199
|
+
}
|
|
3200
|
+
interface KeyBook {
|
|
3201
|
+
pubKey(threadId: ThreadID, peerId: PeerId): Promise<PublicKey | undefined>;
|
|
3202
|
+
addPubKey(threadId: ThreadID, peerId: PeerId, key: PublicKey): Promise<void>;
|
|
3203
|
+
privKey(threadId: ThreadID, peerId: PeerId): Promise<PrivateKey | null>;
|
|
3204
|
+
addPrivKey(threadId: ThreadID, peerId: PeerId, key: PrivateKey): Promise<void>;
|
|
3205
|
+
readKey(threadId: ThreadID): Promise<SymKey | undefined>;
|
|
3206
|
+
addReadKey(threadId: ThreadID, key: SymKey): Promise<void>;
|
|
3207
|
+
serviceKey(threadId: ThreadID): Promise<SymKey | undefined>;
|
|
3208
|
+
addServiceKey(threadId: ThreadID, key: SymKey): Promise<void>;
|
|
3209
|
+
clearKeys(threadId: ThreadID): Promise<void>;
|
|
3210
|
+
clearLogKeys(threadId: ThreadID, peerId: PeerId): Promise<void>;
|
|
3211
|
+
logsWithKeys(threadId: ThreadID): Promise<PeerId[]>;
|
|
3212
|
+
threadsFromKeys(): Promise<ThreadID[]>;
|
|
3213
|
+
dumpKeys(): Promise<DumpKeyBook>;
|
|
3214
|
+
restoreKeys(book: DumpKeyBook): Promise<void>;
|
|
3215
|
+
}
|
|
3216
|
+
interface AddrBook {
|
|
3217
|
+
addAddr(threadId: ThreadID, peerId: PeerId, addr: Multiaddr, ttl: number): Promise<void>;
|
|
3218
|
+
addAddrs(threadId: ThreadID, peerId: PeerId, addrs: Multiaddr[], ttl: number): Promise<void>;
|
|
3219
|
+
setAddr(threadId: ThreadID, peerId: PeerId, addr: Multiaddr, ttl: number): Promise<void>;
|
|
3220
|
+
setAddrs(threadId: ThreadID, peerId: PeerId, addrs: Multiaddr[], ttl: number): Promise<void>;
|
|
3221
|
+
updateAddrs(threadId: ThreadID, peerId: PeerId, oldTTL: number, newTTL: number): Promise<void>;
|
|
3222
|
+
addrs(threadId: ThreadID, peerId: PeerId): Promise<Multiaddr[]>;
|
|
3223
|
+
clearAddrs(threadId: ThreadID, peerId: PeerId): Promise<void>;
|
|
3224
|
+
logsWithAddrs(threadId: ThreadID): Promise<PeerId[]>;
|
|
3225
|
+
threadsFromAddrs(): Promise<ThreadID[]>;
|
|
3226
|
+
addrsEdge(threadId: ThreadID, exceptPeerId?: string): Promise<bigint>;
|
|
3227
|
+
dumpAddrs(): Promise<DumpAddrBook>;
|
|
3228
|
+
restoreAddrs(book: DumpAddrBook): Promise<void>;
|
|
3229
|
+
}
|
|
3230
|
+
interface HeadBook {
|
|
3231
|
+
addHead(threadId: ThreadID, peerId: PeerId, head: Head): Promise<void>;
|
|
3232
|
+
addHeads(threadId: ThreadID, peerId: PeerId, heads: Head[]): Promise<void>;
|
|
3233
|
+
setHead(threadId: ThreadID, peerId: PeerId, head: Head): Promise<void>;
|
|
3234
|
+
setHeads(threadId: ThreadID, peerId: PeerId, heads: Head[]): Promise<void>;
|
|
3235
|
+
heads(threadId: ThreadID, peerId: PeerId): Promise<Head[]>;
|
|
3236
|
+
clearHeads(threadId: ThreadID, peerId: PeerId): Promise<void>;
|
|
3237
|
+
headsEdge(threadId: ThreadID): Promise<bigint>;
|
|
3238
|
+
dumpHeads(): Promise<DumpHeadBook>;
|
|
3239
|
+
restoreHeads(book: DumpHeadBook): Promise<void>;
|
|
3240
|
+
}
|
|
3241
|
+
interface ILogstore {
|
|
3242
|
+
metadata: IThreadMetadata;
|
|
3243
|
+
keyBook: KeyBook;
|
|
3244
|
+
addrBook: AddrBook;
|
|
3245
|
+
headBook: HeadBook;
|
|
3246
|
+
close(): Promise<void>;
|
|
3247
|
+
threads(): Promise<ThreadID[]>;
|
|
3248
|
+
addThread(info: IThreadInfo): Promise<void>;
|
|
3249
|
+
getThread(threadId: ThreadID): Promise<IThreadInfo>;
|
|
3250
|
+
deleteThread(threadId: ThreadID): Promise<void>;
|
|
3251
|
+
addLog(threadId: ThreadID, logInfo: IThreadLogInfo): Promise<void>;
|
|
3252
|
+
getLog(threadId: ThreadID, peerId: PeerId): Promise<IThreadLogInfo>;
|
|
3253
|
+
getManagedLogs(threadId: ThreadID): Promise<IThreadLogInfo[]>;
|
|
3254
|
+
deleteLog(threadId: ThreadID, peerId: PeerId): Promise<void>;
|
|
3255
|
+
}
|
|
3256
|
+
interface ExpiredAddress {
|
|
3325
3257
|
addr: Multiaddr;
|
|
3326
|
-
|
|
3327
|
-
constructor(addr: Multiaddr, id: ThreadID);
|
|
3328
|
-
getMultiaddrString(): string;
|
|
3258
|
+
expires: Date;
|
|
3329
3259
|
}
|
|
3330
|
-
interface
|
|
3331
|
-
|
|
3332
|
-
key: Key | undefined;
|
|
3333
|
-
logs: IThreadLogInfo[];
|
|
3334
|
-
addrs: ThreadMuliaddr[];
|
|
3335
|
-
getFirstPrivKeyLog(): IThreadLogInfo | undefined;
|
|
3260
|
+
interface DumpHeadBook {
|
|
3261
|
+
data: Record<string, Record<string, Head[]>>;
|
|
3336
3262
|
}
|
|
3337
|
-
interface
|
|
3338
|
-
|
|
3339
|
-
name: string;
|
|
3340
|
-
addrs: string[];
|
|
3341
|
-
key: string | undefined;
|
|
3263
|
+
interface DumpAddrBook {
|
|
3264
|
+
data: Record<string, Record<string, ExpiredAddress[]>>;
|
|
3342
3265
|
}
|
|
3343
|
-
|
|
3344
|
-
|
|
3345
|
-
|
|
3346
|
-
|
|
3347
|
-
|
|
3348
|
-
|
|
3349
|
-
|
|
3266
|
+
interface DumpKeyBook {
|
|
3267
|
+
data: {
|
|
3268
|
+
public: Record<string, Record<string, PublicKey>>;
|
|
3269
|
+
private: Record<string, Record<string, PrivateKey>>;
|
|
3270
|
+
read: Record<string, Uint8Array>;
|
|
3271
|
+
service: Record<string, Uint8Array>;
|
|
3272
|
+
};
|
|
3350
3273
|
}
|
|
3351
|
-
interface
|
|
3352
|
-
|
|
3353
|
-
|
|
3354
|
-
|
|
3355
|
-
|
|
3356
|
-
|
|
3357
|
-
|
|
3274
|
+
interface DumpMetadata {
|
|
3275
|
+
data: {
|
|
3276
|
+
int64: Record<string, Record<string, number>>;
|
|
3277
|
+
bool: Record<string, Record<string, boolean>>;
|
|
3278
|
+
string: Record<string, Record<string, string>>;
|
|
3279
|
+
bytes: Record<string, Record<string, Uint8Array>>;
|
|
3280
|
+
};
|
|
3358
3281
|
}
|
|
3359
3282
|
|
|
3360
3283
|
/**
|
|
3361
|
-
*
|
|
3284
|
+
* Records with counters from a peer
|
|
3362
3285
|
*/
|
|
3363
|
-
|
|
3364
|
-
|
|
3365
|
-
|
|
3366
|
-
|
|
3367
|
-
|
|
3368
|
-
|
|
3369
|
-
|
|
3370
|
-
|
|
3371
|
-
|
|
3372
|
-
|
|
3373
|
-
|
|
3374
|
-
|
|
3375
|
-
|
|
3376
|
-
|
|
3377
|
-
|
|
3378
|
-
static fromBytes(k: Uint8Array): SymmetricKey;
|
|
3286
|
+
interface PeerRecords {
|
|
3287
|
+
records: IRecord[];
|
|
3288
|
+
counter: number;
|
|
3289
|
+
}
|
|
3290
|
+
|
|
3291
|
+
declare class DBClient {
|
|
3292
|
+
client: Client;
|
|
3293
|
+
dc: DcUtil;
|
|
3294
|
+
logstore: ILogstore;
|
|
3295
|
+
net: Net;
|
|
3296
|
+
constructor(dcClient: Client, dcUtil: DcUtil, net: Net, logstore: ILogstore);
|
|
3297
|
+
requestThreadID(peerAddr?: Multiaddr): Promise<string>;
|
|
3298
|
+
createThread(tid: string, opts: NewThreadOptions): Promise<string>;
|
|
3299
|
+
pushRecordToPeer(tid: ThreadID, lid: PeerId, rec: IRecord, counter: number): Promise<void>;
|
|
3300
|
+
pushLogToPeer(tid: ThreadID, lid: PeerId, rec: IRecord): Promise<Error | null>;
|
|
3379
3301
|
/**
|
|
3380
|
-
*
|
|
3302
|
+
* 与对等点交换边缘(状态信息)
|
|
3303
|
+
* @param threadIds threadID数组
|
|
3304
|
+
* @returns 无返回值
|
|
3381
3305
|
*/
|
|
3382
|
-
|
|
3383
|
-
|
|
3384
|
-
static fromSymKey(symKey: SymKey): SymmetricKey;
|
|
3306
|
+
exchangeEdges(threadIds: ThreadID[]): Promise<void>;
|
|
3307
|
+
private pushLogsHeadToPeer;
|
|
3385
3308
|
/**
|
|
3386
|
-
*
|
|
3309
|
+
* 获取threaddb 的本地边缘值(地址和头部)
|
|
3310
|
+
* 边缘值用于确定是否需要从远程对等点获取更新
|
|
3311
|
+
*
|
|
3312
|
+
* @param tid threaddb ID
|
|
3313
|
+
* @returns 地址边缘值和头部边缘值的对象
|
|
3314
|
+
* @throws 错误,包括特定的"No address edge"和"No heads edge"错误
|
|
3387
3315
|
*/
|
|
3388
|
-
|
|
3316
|
+
private localEdges;
|
|
3317
|
+
private edgeToBigInt;
|
|
3389
3318
|
/**
|
|
3390
|
-
*
|
|
3319
|
+
* 调度日志更新
|
|
3320
|
+
* @param tid threaddb ID
|
|
3391
3321
|
*/
|
|
3392
|
-
|
|
3322
|
+
scheduleUpdateLogs(tid: ThreadID): Promise<void>;
|
|
3393
3323
|
/**
|
|
3394
|
-
*
|
|
3324
|
+
* 调度记录更新
|
|
3325
|
+
* @param tid threaddb ID
|
|
3395
3326
|
*/
|
|
3396
|
-
|
|
3327
|
+
private scheduleUpdateRecords;
|
|
3397
3328
|
/**
|
|
3398
|
-
*
|
|
3329
|
+
* 构建获取记录的请求
|
|
3399
3330
|
*/
|
|
3400
|
-
|
|
3401
|
-
encrypt(plaintext: Uint8Array, exNonce?: Uint8Array): Promise<Uint8Array>;
|
|
3331
|
+
private buildGetRecordsRequest;
|
|
3402
3332
|
/**
|
|
3403
|
-
*
|
|
3333
|
+
* 获取threaddb 中的日志
|
|
3334
|
+
* @param tid threaddb ID
|
|
3335
|
+
* @param pid 对等点ID
|
|
3336
|
+
* @returns 日志信息数组
|
|
3404
3337
|
*/
|
|
3405
|
-
|
|
3338
|
+
getLogs(tid: ThreadID): Promise<IThreadLogInfo[]>;
|
|
3339
|
+
getRecordsFromPeer(req: any, serviceKey: SymKey): Promise<Record<string, PeerRecords>>;
|
|
3340
|
+
getThreadFromPeer(id: ThreadID, peerId: PeerId, options?: {
|
|
3341
|
+
token?: ThreadToken;
|
|
3342
|
+
}): Promise<IThreadInfo>;
|
|
3406
3343
|
}
|
|
3407
|
-
|
|
3408
|
-
declare class
|
|
3409
|
-
private
|
|
3410
|
-
private
|
|
3411
|
-
|
|
3412
|
-
|
|
3413
|
-
|
|
3414
|
-
|
|
3415
|
-
|
|
3416
|
-
|
|
3417
|
-
|
|
3418
|
-
|
|
3419
|
-
|
|
3420
|
-
|
|
3421
|
-
|
|
3422
|
-
|
|
3344
|
+
|
|
3345
|
+
declare class AsyncMutex {
|
|
3346
|
+
private _locked;
|
|
3347
|
+
private _queue;
|
|
3348
|
+
acquire(): Promise<void>;
|
|
3349
|
+
release(): void;
|
|
3350
|
+
}
|
|
3351
|
+
|
|
3352
|
+
type PubKey = Ed25519PubKey;
|
|
3353
|
+
type Token = Uint8Array;
|
|
3354
|
+
interface App {
|
|
3355
|
+
validateNetRecordBody(body: IPLDNode, identity: PubKey): Promise<Error | undefined>;
|
|
3356
|
+
handleNetRecord(rec: IThreadRecord, key?: Key): Promise<Error | undefined>;
|
|
3357
|
+
getNetRecordCreateTime(rec: IThreadRecord, key?: Key): Promise<BigInt>;
|
|
3358
|
+
}
|
|
3359
|
+
declare class LocalEventsBus {
|
|
3360
|
+
private bus;
|
|
3361
|
+
private static readonly busTimeout;
|
|
3362
|
+
send(event: LocalEvent): Promise<void>;
|
|
3363
|
+
listen(): LocalEventListener;
|
|
3364
|
+
discard(): void;
|
|
3365
|
+
}
|
|
3366
|
+
declare class LocalEventListener {
|
|
3367
|
+
private bus;
|
|
3368
|
+
private handler;
|
|
3369
|
+
constructor(bus: EventEmitter);
|
|
3370
|
+
private onEvent;
|
|
3371
|
+
discard(): void;
|
|
3372
|
+
}
|
|
3373
|
+
interface LocalEvent {
|
|
3374
|
+
node: IPLDNode;
|
|
3375
|
+
token: ThreadToken;
|
|
3376
|
+
}
|
|
3377
|
+
interface Net extends INet {
|
|
3378
|
+
bstore: Blocks;
|
|
3379
|
+
connectApp(app: App, threadId: ThreadID): Promise<Connector>;
|
|
3380
|
+
createRecord(threadId: ThreadID, body: IPLDNode, options?: {
|
|
3381
|
+
threadToken?: ThreadToken;
|
|
3382
|
+
apiToken?: Token;
|
|
3383
|
+
}): Promise<IThreadRecord>;
|
|
3384
|
+
getDagService(): DAGCBOR;
|
|
3385
|
+
validate(id: ThreadID, token?: ThreadToken): Promise<Ed25519PubKey | undefined>;
|
|
3386
|
+
exchange(id: ThreadID): Promise<void>;
|
|
3387
|
+
threadOffsets(tid: ThreadID): Promise<[Record<string, Head>, PeerId[]]>;
|
|
3388
|
+
buildGetRecordsRequest(tid: ThreadID, offsets: Record<string, Head>, limit: number): Promise<{
|
|
3389
|
+
req: net.pb.IGetRecordsRequest;
|
|
3390
|
+
serviceKey: SymKey;
|
|
3391
|
+
}>;
|
|
3392
|
+
updateRecordsFromPeer(tid: ThreadID, peerId: PeerId | null, client?: DBClient): Promise<void>;
|
|
3393
|
+
getMutexForThread(threadId: string): AsyncMutex;
|
|
3394
|
+
preLoadLogs(tid: ThreadID, logs: net.pb.Log[]): Promise<void>;
|
|
3395
|
+
createExternalLogsIfNotExist(tid: ThreadID, logs: IThreadLogInfo[]): Promise<void>;
|
|
3396
|
+
createExternalLogsIfNotExistForPreload(tid: ThreadID, logs: IThreadLogInfo[]): Promise<void>;
|
|
3397
|
+
}
|
|
3398
|
+
declare class Connector {
|
|
3399
|
+
net: Net;
|
|
3400
|
+
private app;
|
|
3401
|
+
private threadInfo;
|
|
3402
|
+
readonly token: Token;
|
|
3403
|
+
constructor(net: Net, app: App, threadInfo: ThreadInfo);
|
|
3404
|
+
get threadId(): ThreadID;
|
|
3405
|
+
get threadKey(): Key | undefined;
|
|
3406
|
+
createNetRecord(body: IPLDNode, token?: ThreadToken): Promise<IThreadRecord>;
|
|
3407
|
+
validate(token?: ThreadToken): Promise<Error | undefined>;
|
|
3408
|
+
validateNetRecordBody(body: IPLDNode, identity: PubKey): Promise<Error | undefined>;
|
|
3409
|
+
handleNetRecord(rec: IThreadRecord): Promise<Error | undefined>;
|
|
3410
|
+
getNetRecordCreateTime(rec: IThreadRecord): Promise<BigInt>;
|
|
3411
|
+
private generateRandomBytes;
|
|
3412
|
+
}
|
|
3413
|
+
|
|
3414
|
+
declare class DCGrpcServer {
|
|
3415
|
+
private libp2p;
|
|
3416
|
+
private protocol;
|
|
3417
|
+
private net;
|
|
3418
|
+
constructor(libp2p: Libp2p$1, protocol: string);
|
|
3419
|
+
setNetwork(net: Net): void;
|
|
3420
|
+
start(): void;
|
|
3421
|
+
stop(): void;
|
|
3422
|
+
_parseFrameHeader(buffer: Uint8Array): {
|
|
3423
|
+
length: number;
|
|
3424
|
+
type: number;
|
|
3425
|
+
flags: number;
|
|
3426
|
+
streamId: number;
|
|
3427
|
+
payload: Uint8Array<ArrayBuffer>;
|
|
3428
|
+
};
|
|
3429
|
+
getLogs(streamId: number, request: any, writer: any): Promise<any>;
|
|
3423
3430
|
}
|
|
3424
3431
|
|
|
3425
3432
|
/**
|
|
@@ -3844,6 +3851,14 @@ interface IAuthOperations {
|
|
|
3844
3851
|
* @returns [状态码, 错误信息]
|
|
3845
3852
|
*/
|
|
3846
3853
|
bindNFTAccount(account: string, password: string, seccode: string, mnemonic: string): Promise<[NFTBindStatus | null, Error | null]>;
|
|
3854
|
+
/**
|
|
3855
|
+
* NFT账号密码修改
|
|
3856
|
+
* @param account NFT账号
|
|
3857
|
+
* @param password 密码
|
|
3858
|
+
* @param seccode 安全码
|
|
3859
|
+
* @param mnemonic 助记词 (可选,如果是主账号登录则需要)
|
|
3860
|
+
*/
|
|
3861
|
+
nftAccountPasswordModify(account: string, password: string, seccode: string, mnemonic?: string): Promise<Error | null>;
|
|
3847
3862
|
/**
|
|
3848
3863
|
* 创建APP访问账号,返回APP专用私钥
|
|
3849
3864
|
* @param appId 应用ID
|
|
@@ -3865,10 +3880,10 @@ interface IAuthOperations {
|
|
|
3865
3880
|
*/
|
|
3866
3881
|
isNftAccountBinded(nftAccount: string): Promise<[boolean | null, Error | null]>;
|
|
3867
3882
|
/**
|
|
3868
|
-
|
|
3869
|
-
|
|
3870
|
-
|
|
3871
|
-
|
|
3883
|
+
* 获取用户信息
|
|
3884
|
+
* @param nftAccount NFT账户
|
|
3885
|
+
* @returns 用户信息
|
|
3886
|
+
*/
|
|
3872
3887
|
getUserInfoWithNft(nftAccount: string): Promise<[User | null, Error | null]>;
|
|
3873
3888
|
/**
|
|
3874
3889
|
* 获取用户钱包信息
|
|
@@ -3900,6 +3915,42 @@ interface IAuthOperations {
|
|
|
3900
3915
|
* @returns 用户默认数据库信息
|
|
3901
3916
|
*/
|
|
3902
3917
|
setUserDefaultDB(threadId: string, rk: string, sk: string, remark: string, vaccount?: string): Promise<Error | null>;
|
|
3918
|
+
/**
|
|
3919
|
+
* 跳转到钱包进行签名
|
|
3920
|
+
* @param data 签名数据
|
|
3921
|
+
SignReqMessage: {
|
|
3922
|
+
type: string,
|
|
3923
|
+
origin: string,
|
|
3924
|
+
data<SignReqMessageData>:{
|
|
3925
|
+
appUrl: string,
|
|
3926
|
+
ethAccount: string,
|
|
3927
|
+
messageType?: string, // 'string',//string,hex,base64,eip712
|
|
3928
|
+
message: string,
|
|
3929
|
+
}
|
|
3930
|
+
}
|
|
3931
|
+
*/
|
|
3932
|
+
signMessageWithWallet(data: SignReqMessage): Promise<[SignResponseMessage | null, Error | null]>;
|
|
3933
|
+
/**
|
|
3934
|
+
* 跳转到钱包进行EIP712签名
|
|
3935
|
+
* @param data 签名数据
|
|
3936
|
+
EIP712SignReqMessage: {
|
|
3937
|
+
type: string,
|
|
3938
|
+
origin: string,
|
|
3939
|
+
data<EIP712SignReqMessageData>:{
|
|
3940
|
+
appUrl: string,
|
|
3941
|
+
ethAccount: string,
|
|
3942
|
+
domain: any,
|
|
3943
|
+
types: any,
|
|
3944
|
+
primaryType: string,
|
|
3945
|
+
message: any,
|
|
3946
|
+
}
|
|
3947
|
+
}
|
|
3948
|
+
*/
|
|
3949
|
+
signEIP712MessageWithWallet(data: EIP712SignReqMessage): Promise<[SignResponseMessage | null, Error | null]>;
|
|
3950
|
+
/**
|
|
3951
|
+
* 退出登录
|
|
3952
|
+
*/
|
|
3953
|
+
exitLogin(): void;
|
|
3903
3954
|
}
|
|
3904
3955
|
|
|
3905
3956
|
/**
|
|
@@ -3928,6 +3979,7 @@ interface IDatabaseOperations {
|
|
|
3928
3979
|
* @returns 错误信息
|
|
3929
3980
|
*/
|
|
3930
3981
|
initDBManager(): Promise<Error | null>;
|
|
3982
|
+
resetDBManager(): void;
|
|
3931
3983
|
/**
|
|
3932
3984
|
* 创建新数据库
|
|
3933
3985
|
* @param name 数据库名称
|
|
@@ -27545,7 +27597,7 @@ declare class DBManager {
|
|
|
27545
27597
|
syncDBFromDC(ctx: Context, threadid: string, dbname: string, dbAddr: string, b32Rk: string, b32Sk: string, block: boolean, collectionInfos: ICollectionConfig[]): Promise<Error | null>;
|
|
27546
27598
|
getDBRecordsCount(threadid: string): Promise<number>;
|
|
27547
27599
|
addLogToThread(ctx: Context, id: ThreadID, lid: PeerId): Promise<void>;
|
|
27548
|
-
addLogToThreadStart(ctx: Context, id: ThreadID, lid: PeerId): Promise<void>;
|
|
27600
|
+
addLogToThreadStart(ctx: Context | null, id: ThreadID, lid: PeerId): Promise<void>;
|
|
27549
27601
|
newDB(dbname: string, b32Rk: string, b32Sk: string, collectionInfos: ICollectionConfig[]): Promise<[string, Error | null]>;
|
|
27550
27602
|
refreshDBFromDC(threadId: string): Promise<Error | null>;
|
|
27551
27603
|
syncDBToDC(threadId: string): Promise<Error | null>;
|
|
@@ -27895,7 +27947,7 @@ declare class AuthModule implements DCModule, IAuthOperations {
|
|
|
27895
27947
|
* 账户登录
|
|
27896
27948
|
* @returns 是否登录成功
|
|
27897
27949
|
*/
|
|
27898
|
-
accountLoginWithWalletCall(accountInfo?: AccountInfo): Promise<Account
|
|
27950
|
+
accountLoginWithWalletCall(accountInfo?: AccountInfo): Promise<Account>;
|
|
27899
27951
|
/**
|
|
27900
27952
|
* 账户登录(钱包登录)不抛出异常
|
|
27901
27953
|
* @returns [账户信息, 错误信息]
|
|
@@ -27913,11 +27965,19 @@ declare class AuthModule implements DCModule, IAuthOperations {
|
|
|
27913
27965
|
* @returns [是否登录成功, 错误信息]
|
|
27914
27966
|
*/
|
|
27915
27967
|
accountLogin(nftAccount: string, password: string, safecode: string): Promise<[string, Error | null]>;
|
|
27968
|
+
/**
|
|
27969
|
+
* NFT账号密码修改
|
|
27970
|
+
* @param account NFT账号
|
|
27971
|
+
* @param password 密码
|
|
27972
|
+
* @param seccode 安全码
|
|
27973
|
+
* @param mnemonic 助记词 (可选,如果是主账号登录则需要)
|
|
27974
|
+
*/
|
|
27975
|
+
nftAccountPasswordModify(account: string, password: string, seccode: string, mnemonic?: string): Promise<Error | null>;
|
|
27916
27976
|
signWithWallet(payload: Uint8Array): Promise<Uint8Array>;
|
|
27917
27977
|
sign(payload: Uint8Array): Promise<[Uint8Array | null, Error | null]>;
|
|
27918
27978
|
decryptWithWallet(payload: Uint8Array): Promise<[Uint8Array | null, Error | null]>;
|
|
27919
|
-
signMessageWithWallet(data: SignReqMessage): Promise<SignResponseMessage | null>;
|
|
27920
|
-
signEIP712MessageWithWallet(data: EIP712SignReqMessage): Promise<SignResponseMessage | null>;
|
|
27979
|
+
signMessageWithWallet(data: SignReqMessage): Promise<[SignResponseMessage | null, Error | null]>;
|
|
27980
|
+
signEIP712MessageWithWallet(data: EIP712SignReqMessage): Promise<[SignResponseMessage | null, Error | null]>;
|
|
27921
27981
|
/**
|
|
27922
27982
|
* 将私钥绑定NFT账号(NFT账号+密码+安全码)
|
|
27923
27983
|
* @param account NFT账号
|
|
@@ -28138,6 +28198,7 @@ declare class DatabaseModule implements DCModule, IDatabaseOperations {
|
|
|
28138
28198
|
* 关闭数据库模块
|
|
28139
28199
|
*/
|
|
28140
28200
|
shutdown(): Promise<void>;
|
|
28201
|
+
resetDBManager(): Promise<void>;
|
|
28141
28202
|
/**
|
|
28142
28203
|
* 初始化数据库管理器
|
|
28143
28204
|
*/
|