web-dc-api 0.1.5 → 0.1.7
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 -1
- package/dist/dc.min.js +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/index.d.ts +934 -878
- package/package.json +4 -8
- package/dist/cjs/helia-core-B1Xqha7a.js +0 -1
- package/dist/cjs/helia-core-D8Uv1KjQ.js +0 -1
- package/dist/cjs/polkadot-api-7PhQf3ws.js +0 -1
- package/dist/cjs/polkadot-api-CtrJVWuZ.js +0 -1
- package/dist/esm/chunks/helia-core-BxMqyK2Y.js +0 -1
- package/dist/esm/chunks/helia-core-DMXRpcO-.js +0 -1
- package/dist/esm/chunks/polkadot-api-5Y9Bw8VT.js +0 -1
- package/dist/esm/chunks/polkadot-api-D69Ioun_.js +0 -1
- 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 -627
- package/lib/common/define.ts +0 -70
- 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 -701
- 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 -206
- 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 -543
- package/lib/implements/threaddb/dbmanager.ts +0 -1906
- package/lib/implements/threaddb/lsstoreds/addr_book.ts +0 -549
- 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 -373
- 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 -149
- package/lib/implements/threaddb/net/grpcClient.ts +0 -589
- package/lib/implements/threaddb/net/grpcserver.ts +0 -146
- package/lib/implements/threaddb/net/net.ts +0 -2047
- 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 -671
- 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/components/news-component.ts +0 -0
- 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/components/news-components.ts +0 -390
- 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,18 +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
17
|
import { DAGCBOR } from '@helia/dag-cbor';
|
|
18
|
-
import { Link } from 'multiformats/link';
|
|
19
18
|
import { UnixFS } from '@helia/unixfs';
|
|
20
19
|
import { HDKey } from '@scure/bip32';
|
|
21
20
|
|
|
@@ -293,17 +292,18 @@ type SignResponseMessage = {
|
|
|
293
292
|
success: boolean;
|
|
294
293
|
signature: string;
|
|
295
294
|
};
|
|
295
|
+
type EIP712SignReqMessageData = {
|
|
296
|
+
appUrl: string;
|
|
297
|
+
ethAccount: string;
|
|
298
|
+
domain: any;
|
|
299
|
+
types: any;
|
|
300
|
+
primaryType: string;
|
|
301
|
+
message: any;
|
|
302
|
+
};
|
|
296
303
|
type EIP712SignReqMessage = {
|
|
297
304
|
type: string;
|
|
298
305
|
origin: string;
|
|
299
|
-
data:
|
|
300
|
-
appUrl: string;
|
|
301
|
-
ethAccount: string;
|
|
302
|
-
domain: any;
|
|
303
|
-
types: any;
|
|
304
|
-
primaryType: string;
|
|
305
|
-
message: any;
|
|
306
|
-
};
|
|
306
|
+
data: EIP712SignReqMessageData;
|
|
307
307
|
};
|
|
308
308
|
type SendMessage<T> = {
|
|
309
309
|
type: string;
|
|
@@ -434,20 +434,69 @@ declare class DcUtil {
|
|
|
434
434
|
} | null;
|
|
435
435
|
}
|
|
436
436
|
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
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;
|
|
451
500
|
}
|
|
452
501
|
|
|
453
502
|
interface Head {
|
|
@@ -483,254 +532,398 @@ declare class ThreadToken {
|
|
|
483
532
|
get defined(): boolean;
|
|
484
533
|
}
|
|
485
534
|
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
/** 获取内部区块的 CID */
|
|
489
|
-
blockID: () => CID;
|
|
490
|
-
/** 异步加载内部区块 */
|
|
491
|
-
getBlock: (bstore: Blocks) => Promise<IPLDNode>;
|
|
492
|
-
/** 前一个记录的 CID */
|
|
493
|
-
prevID: () => CID | undefined;
|
|
494
|
-
/** 记录的数字签名 */
|
|
495
|
-
sig: () => Signature;
|
|
496
|
-
/** 作者的原始公钥字节 */
|
|
497
|
-
pubKey: () => Uint8Array;
|
|
498
|
-
/** 验证签名有效性 */
|
|
499
|
-
verify: (key: PublicKey) => Promise<Error | undefined>;
|
|
535
|
+
interface Reducer {
|
|
536
|
+
reduce(events: Event[]): Promise<void>;
|
|
500
537
|
}
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
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;
|
|
508
549
|
}
|
|
509
550
|
|
|
510
|
-
|
|
511
|
-
declare
|
|
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
|
-
|
|
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
|
+
}
|
|
647
702
|
|
|
648
|
-
|
|
649
|
-
|
|
703
|
+
/** Namespace net. */
|
|
704
|
+
declare namespace net {
|
|
650
705
|
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
}
|
|
706
|
+
/** Namespace pb. */
|
|
707
|
+
namespace pb {
|
|
654
708
|
|
|
655
|
-
|
|
656
|
-
|
|
709
|
+
/** Properties of a Log. */
|
|
710
|
+
interface ILog {
|
|
657
711
|
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
* @param [properties] Properties to set
|
|
661
|
-
*/
|
|
662
|
-
constructor(properties?: net.pb.Log.IRecord);
|
|
712
|
+
/** Log ID */
|
|
713
|
+
ID?: (Uint8Array|null);
|
|
663
714
|
|
|
664
|
-
|
|
665
|
-
|
|
715
|
+
/** Log pubKey */
|
|
716
|
+
pubKey?: (Uint8Array|null);
|
|
666
717
|
|
|
667
|
-
|
|
668
|
-
|
|
718
|
+
/** Log addrs */
|
|
719
|
+
addrs?: (Uint8Array[]|null);
|
|
669
720
|
|
|
670
|
-
|
|
671
|
-
|
|
721
|
+
/** Log head */
|
|
722
|
+
head?: (Uint8Array|null);
|
|
672
723
|
|
|
673
|
-
|
|
674
|
-
|
|
724
|
+
/** Log counter */
|
|
725
|
+
counter?: (number|Long|null);
|
|
726
|
+
}
|
|
675
727
|
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
* @param [properties] Properties to set
|
|
679
|
-
* @returns Record instance
|
|
680
|
-
*/
|
|
681
|
-
public static create(properties?: net.pb.Log.IRecord): net.pb.Log.Record;
|
|
728
|
+
/** Represents a Log. */
|
|
729
|
+
class Log implements ILog {
|
|
682
730
|
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
*/
|
|
689
|
-
public static encode(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);
|
|
690
736
|
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
* @param message Record message or plain object to encode
|
|
694
|
-
* @param [writer] Writer to encode to
|
|
695
|
-
* @returns Writer
|
|
696
|
-
*/
|
|
697
|
-
public static encodeDelimited(message: net.pb.Log.IRecord, writer?: $protobuf.Writer): $protobuf.Writer;
|
|
737
|
+
/** Log ID. */
|
|
738
|
+
public ID: Uint8Array;
|
|
698
739
|
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
* @param reader Reader or buffer to decode from
|
|
702
|
-
* @param [length] Message length if known beforehand
|
|
703
|
-
* @returns Record
|
|
704
|
-
* @throws {Error} If the payload is not a reader or valid buffer
|
|
705
|
-
* @throws {$protobuf.util.ProtocolError} If required fields are missing
|
|
706
|
-
*/
|
|
707
|
-
public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): net.pb.Log.Record;
|
|
740
|
+
/** Log pubKey. */
|
|
741
|
+
public pubKey: Uint8Array;
|
|
708
742
|
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
* @param reader Reader or buffer to decode from
|
|
712
|
-
* @returns Record
|
|
713
|
-
* @throws {Error} If the payload is not a reader or valid buffer
|
|
714
|
-
* @throws {$protobuf.util.ProtocolError} If required fields are missing
|
|
715
|
-
*/
|
|
716
|
-
public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): net.pb.Log.Record;
|
|
743
|
+
/** Log addrs. */
|
|
744
|
+
public addrs: Uint8Array[];
|
|
717
745
|
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
* @param message Plain object to verify
|
|
721
|
-
* @returns `null` if valid, otherwise the reason why it is not
|
|
722
|
-
*/
|
|
723
|
-
public static verify(message: { [k: string]: any }): (string|null);
|
|
746
|
+
/** Log head. */
|
|
747
|
+
public head: Uint8Array;
|
|
724
748
|
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
* @param object Plain object
|
|
728
|
-
* @returns Record
|
|
729
|
-
*/
|
|
730
|
-
public static fromObject(object: { [k: string]: any }): net.pb.Log.Record;
|
|
749
|
+
/** Log counter. */
|
|
750
|
+
public counter: (number|Long);
|
|
731
751
|
|
|
732
|
-
|
|
733
|
-
|
|
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.
|
|
734
927
|
* @param message Record
|
|
735
928
|
* @param [options] Conversion options
|
|
736
929
|
* @returns Plain object
|
|
@@ -2721,543 +2914,138 @@ declare namespace net {
|
|
|
2721
2914
|
* @returns The default type url
|
|
2722
2915
|
*/
|
|
2723
2916
|
public static getTypeUrl(typeUrlPrefix?: string): string;
|
|
2724
|
-
}
|
|
2725
|
-
}
|
|
2726
|
-
|
|
2727
|
-
/** Represents a Service */
|
|
2728
|
-
class Service extends $protobuf.rpc.Service {
|
|
2729
|
-
|
|
2730
|
-
/**
|
|
2731
|
-
* Constructs a new Service service.
|
|
2732
|
-
* @param rpcImpl RPC implementation
|
|
2733
|
-
* @param [requestDelimited=false] Whether requests are length-delimited
|
|
2734
|
-
* @param [responseDelimited=false] Whether responses are length-delimited
|
|
2735
|
-
*/
|
|
2736
|
-
constructor(rpcImpl: $protobuf.RPCImpl, requestDelimited?: boolean, responseDelimited?: boolean);
|
|
2737
|
-
|
|
2738
|
-
/**
|
|
2739
|
-
* Creates new Service service using the specified rpc implementation.
|
|
2740
|
-
* @param rpcImpl RPC implementation
|
|
2741
|
-
* @param [requestDelimited=false] Whether requests are length-delimited
|
|
2742
|
-
* @param [responseDelimited=false] Whether responses are length-delimited
|
|
2743
|
-
* @returns RPC service. Useful where requests and/or responses are streamed.
|
|
2744
|
-
*/
|
|
2745
|
-
public static create(rpcImpl: $protobuf.RPCImpl, requestDelimited?: boolean, responseDelimited?: boolean): Service;
|
|
2746
|
-
|
|
2747
|
-
/**
|
|
2748
|
-
* Calls GetLogs.
|
|
2749
|
-
* @param request GetLogsRequest message or plain object
|
|
2750
|
-
* @param callback Node-style callback called with the error, if any, and GetLogsReply
|
|
2751
|
-
*/
|
|
2752
|
-
public getLogs(request: net.pb.IGetLogsRequest, callback: net.pb.Service.GetLogsCallback): void;
|
|
2753
|
-
|
|
2754
|
-
/**
|
|
2755
|
-
* Calls GetLogs.
|
|
2756
|
-
* @param request GetLogsRequest message or plain object
|
|
2757
|
-
* @returns Promise
|
|
2758
|
-
*/
|
|
2759
|
-
public getLogs(request: net.pb.IGetLogsRequest): Promise<net.pb.GetLogsReply>;
|
|
2760
|
-
|
|
2761
|
-
/**
|
|
2762
|
-
* Calls PushLog.
|
|
2763
|
-
* @param request PushLogRequest message or plain object
|
|
2764
|
-
* @param callback Node-style callback called with the error, if any, and PushLogReply
|
|
2765
|
-
*/
|
|
2766
|
-
public pushLog(request: net.pb.IPushLogRequest, callback: net.pb.Service.PushLogCallback): void;
|
|
2767
|
-
|
|
2768
|
-
/**
|
|
2769
|
-
* Calls PushLog.
|
|
2770
|
-
* @param request PushLogRequest message or plain object
|
|
2771
|
-
* @returns Promise
|
|
2772
|
-
*/
|
|
2773
|
-
public pushLog(request: net.pb.IPushLogRequest): Promise<net.pb.PushLogReply>;
|
|
2774
|
-
|
|
2775
|
-
/**
|
|
2776
|
-
* Calls GetRecords.
|
|
2777
|
-
* @param request GetRecordsRequest message or plain object
|
|
2778
|
-
* @param callback Node-style callback called with the error, if any, and GetRecordsReply
|
|
2779
|
-
*/
|
|
2780
|
-
public getRecords(request: net.pb.IGetRecordsRequest, callback: net.pb.Service.GetRecordsCallback): void;
|
|
2781
|
-
|
|
2782
|
-
/**
|
|
2783
|
-
* Calls GetRecords.
|
|
2784
|
-
* @param request GetRecordsRequest message or plain object
|
|
2785
|
-
* @returns Promise
|
|
2786
|
-
*/
|
|
2787
|
-
public getRecords(request: net.pb.IGetRecordsRequest): Promise<net.pb.GetRecordsReply>;
|
|
2788
|
-
|
|
2789
|
-
/**
|
|
2790
|
-
* Calls PushRecord.
|
|
2791
|
-
* @param request PushRecordRequest message or plain object
|
|
2792
|
-
* @param callback Node-style callback called with the error, if any, and PushRecordReply
|
|
2793
|
-
*/
|
|
2794
|
-
public pushRecord(request: net.pb.IPushRecordRequest, callback: net.pb.Service.PushRecordCallback): void;
|
|
2795
|
-
|
|
2796
|
-
/**
|
|
2797
|
-
* Calls PushRecord.
|
|
2798
|
-
* @param request PushRecordRequest message or plain object
|
|
2799
|
-
* @returns Promise
|
|
2800
|
-
*/
|
|
2801
|
-
public pushRecord(request: net.pb.IPushRecordRequest): Promise<net.pb.PushRecordReply>;
|
|
2802
|
-
|
|
2803
|
-
/**
|
|
2804
|
-
* Calls ExchangeEdges.
|
|
2805
|
-
* @param request ExchangeEdgesRequest message or plain object
|
|
2806
|
-
* @param callback Node-style callback called with the error, if any, and ExchangeEdgesReply
|
|
2807
|
-
*/
|
|
2808
|
-
public exchangeEdges(request: net.pb.IExchangeEdgesRequest, callback: net.pb.Service.ExchangeEdgesCallback): void;
|
|
2809
|
-
|
|
2810
|
-
/**
|
|
2811
|
-
* Calls ExchangeEdges.
|
|
2812
|
-
* @param request ExchangeEdgesRequest message or plain object
|
|
2813
|
-
* @returns Promise
|
|
2814
|
-
*/
|
|
2815
|
-
public exchangeEdges(request: net.pb.IExchangeEdgesRequest): Promise<net.pb.ExchangeEdgesReply>;
|
|
2816
|
-
}
|
|
2817
|
-
|
|
2818
|
-
namespace Service {
|
|
2819
|
-
|
|
2820
|
-
/**
|
|
2821
|
-
* Callback as used by {@link net.pb.Service#getLogs}.
|
|
2822
|
-
* @param error Error, if any
|
|
2823
|
-
* @param [response] GetLogsReply
|
|
2824
|
-
*/
|
|
2825
|
-
type GetLogsCallback = (error: (Error|null), response?: net.pb.GetLogsReply) => void;
|
|
2826
|
-
|
|
2827
|
-
/**
|
|
2828
|
-
* Callback as used by {@link net.pb.Service#pushLog}.
|
|
2829
|
-
* @param error Error, if any
|
|
2830
|
-
* @param [response] PushLogReply
|
|
2831
|
-
*/
|
|
2832
|
-
type PushLogCallback = (error: (Error|null), response?: net.pb.PushLogReply) => void;
|
|
2833
|
-
|
|
2834
|
-
/**
|
|
2835
|
-
* Callback as used by {@link net.pb.Service#getRecords}.
|
|
2836
|
-
* @param error Error, if any
|
|
2837
|
-
* @param [response] GetRecordsReply
|
|
2838
|
-
*/
|
|
2839
|
-
type GetRecordsCallback = (error: (Error|null), response?: net.pb.GetRecordsReply) => void;
|
|
2840
|
-
|
|
2841
|
-
/**
|
|
2842
|
-
* Callback as used by {@link net.pb.Service#pushRecord}.
|
|
2843
|
-
* @param error Error, if any
|
|
2844
|
-
* @param [response] PushRecordReply
|
|
2845
|
-
*/
|
|
2846
|
-
type PushRecordCallback = (error: (Error|null), response?: net.pb.PushRecordReply) => void;
|
|
2847
|
-
|
|
2848
|
-
/**
|
|
2849
|
-
* Callback as used by {@link net.pb.Service#exchangeEdges}.
|
|
2850
|
-
* @param error Error, if any
|
|
2851
|
-
* @param [response] ExchangeEdgesReply
|
|
2852
|
-
*/
|
|
2853
|
-
type ExchangeEdgesCallback = (error: (Error|null), response?: net.pb.ExchangeEdgesReply) => void;
|
|
2854
|
-
}
|
|
2855
|
-
}
|
|
2856
|
-
}
|
|
2857
|
-
|
|
2858
|
-
type NewThreadOptions = {
|
|
2859
|
-
threadKey?: Key;
|
|
2860
|
-
logKey?: LogKey;
|
|
2861
|
-
token: ThreadToken;
|
|
2862
|
-
pubkey?: Ed25519PubKey;
|
|
2863
|
-
blockHeight: number;
|
|
2864
|
-
signature: Uint8Array;
|
|
2865
|
-
vaccount?: Ed25519PubKey;
|
|
2866
|
-
};
|
|
2867
|
-
|
|
2868
|
-
interface IThreadMetadata {
|
|
2869
|
-
getInt64(t: ThreadID, key: string): Promise<number | null>;
|
|
2870
|
-
putInt64(t: ThreadID, key: string, val: number): Promise<void>;
|
|
2871
|
-
getString(t: ThreadID, key: string): Promise<string | null>;
|
|
2872
|
-
putString(t: ThreadID, key: string, val: string): Promise<void>;
|
|
2873
|
-
getBool(t: ThreadID, key: string): Promise<boolean | null>;
|
|
2874
|
-
putBool(t: ThreadID, key: string, val: boolean): Promise<void>;
|
|
2875
|
-
getBytes(t: ThreadID, key: string): Promise<Uint8Array | null>;
|
|
2876
|
-
putBytes(t: ThreadID, key: string, val: Uint8Array): Promise<void>;
|
|
2877
|
-
clearMetadata(t: ThreadID): Promise<void>;
|
|
2878
|
-
dumpMeta(): Promise<DumpMetadata>;
|
|
2879
|
-
restoreMeta(book: DumpMetadata): Promise<void>;
|
|
2880
|
-
}
|
|
2881
|
-
interface KeyBook {
|
|
2882
|
-
pubKey(threadId: ThreadID, peerId: PeerId): Promise<PublicKey$1 | undefined>;
|
|
2883
|
-
addPubKey(threadId: ThreadID, peerId: PeerId, key: PublicKey$1): Promise<void>;
|
|
2884
|
-
privKey(threadId: ThreadID, peerId: PeerId): Promise<PrivateKey | null>;
|
|
2885
|
-
addPrivKey(threadId: ThreadID, peerId: PeerId, key: PrivateKey): Promise<void>;
|
|
2886
|
-
readKey(threadId: ThreadID): Promise<SymKey | undefined>;
|
|
2887
|
-
addReadKey(threadId: ThreadID, key: SymKey): Promise<void>;
|
|
2888
|
-
serviceKey(threadId: ThreadID): Promise<SymKey | undefined>;
|
|
2889
|
-
addServiceKey(threadId: ThreadID, key: SymKey): Promise<void>;
|
|
2890
|
-
clearKeys(threadId: ThreadID): Promise<void>;
|
|
2891
|
-
clearLogKeys(threadId: ThreadID, peerId: PeerId): Promise<void>;
|
|
2892
|
-
logsWithKeys(threadId: ThreadID): Promise<PeerId[]>;
|
|
2893
|
-
threadsFromKeys(): Promise<ThreadID[]>;
|
|
2894
|
-
dumpKeys(): Promise<DumpKeyBook>;
|
|
2895
|
-
restoreKeys(book: DumpKeyBook): Promise<void>;
|
|
2896
|
-
}
|
|
2897
|
-
interface AddrBook {
|
|
2898
|
-
addAddr(threadId: ThreadID, peerId: PeerId, addr: Multiaddr, ttl: number): Promise<void>;
|
|
2899
|
-
addAddrs(threadId: ThreadID, peerId: PeerId, addrs: Multiaddr[], ttl: number): Promise<void>;
|
|
2900
|
-
setAddr(threadId: ThreadID, peerId: PeerId, addr: Multiaddr, ttl: number): Promise<void>;
|
|
2901
|
-
setAddrs(threadId: ThreadID, peerId: PeerId, addrs: Multiaddr[], ttl: number): Promise<void>;
|
|
2902
|
-
updateAddrs(threadId: ThreadID, peerId: PeerId, oldTTL: number, newTTL: number): Promise<void>;
|
|
2903
|
-
addrs(threadId: ThreadID, peerId: PeerId): Promise<Multiaddr[]>;
|
|
2904
|
-
clearAddrs(threadId: ThreadID, peerId: PeerId): Promise<void>;
|
|
2905
|
-
logsWithAddrs(threadId: ThreadID): Promise<PeerId[]>;
|
|
2906
|
-
threadsFromAddrs(): Promise<ThreadID[]>;
|
|
2907
|
-
addrsEdge(threadId: ThreadID, exceptPeerId?: string): Promise<bigint>;
|
|
2908
|
-
dumpAddrs(): Promise<DumpAddrBook>;
|
|
2909
|
-
restoreAddrs(book: DumpAddrBook): Promise<void>;
|
|
2910
|
-
}
|
|
2911
|
-
interface HeadBook {
|
|
2912
|
-
addHead(threadId: ThreadID, peerId: PeerId, head: Head): Promise<void>;
|
|
2913
|
-
addHeads(threadId: ThreadID, peerId: PeerId, heads: Head[]): Promise<void>;
|
|
2914
|
-
setHead(threadId: ThreadID, peerId: PeerId, head: Head): Promise<void>;
|
|
2915
|
-
setHeads(threadId: ThreadID, peerId: PeerId, heads: Head[]): Promise<void>;
|
|
2916
|
-
heads(threadId: ThreadID, peerId: PeerId): Promise<Head[]>;
|
|
2917
|
-
clearHeads(threadId: ThreadID, peerId: PeerId): Promise<void>;
|
|
2918
|
-
headsEdge(threadId: ThreadID): Promise<bigint>;
|
|
2919
|
-
dumpHeads(): Promise<DumpHeadBook>;
|
|
2920
|
-
restoreHeads(book: DumpHeadBook): Promise<void>;
|
|
2921
|
-
}
|
|
2922
|
-
interface ILogstore {
|
|
2923
|
-
metadata: IThreadMetadata;
|
|
2924
|
-
keyBook: KeyBook;
|
|
2925
|
-
addrBook: AddrBook;
|
|
2926
|
-
headBook: HeadBook;
|
|
2927
|
-
close(): Promise<void>;
|
|
2928
|
-
threads(): Promise<ThreadID[]>;
|
|
2929
|
-
addThread(info: IThreadInfo): Promise<void>;
|
|
2930
|
-
getThread(threadId: ThreadID): Promise<IThreadInfo>;
|
|
2931
|
-
deleteThread(threadId: ThreadID): Promise<void>;
|
|
2932
|
-
addLog(threadId: ThreadID, logInfo: IThreadLogInfo): Promise<void>;
|
|
2933
|
-
getLog(threadId: ThreadID, peerId: PeerId): Promise<IThreadLogInfo>;
|
|
2934
|
-
getManagedLogs(threadId: ThreadID): Promise<IThreadLogInfo[]>;
|
|
2935
|
-
deleteLog(threadId: ThreadID, peerId: PeerId): Promise<void>;
|
|
2936
|
-
}
|
|
2937
|
-
interface ExpiredAddress {
|
|
2938
|
-
addr: Multiaddr;
|
|
2939
|
-
expires: Date;
|
|
2940
|
-
}
|
|
2941
|
-
interface DumpHeadBook {
|
|
2942
|
-
data: Record<string, Record<string, Head[]>>;
|
|
2943
|
-
}
|
|
2944
|
-
interface DumpAddrBook {
|
|
2945
|
-
data: Record<string, Record<string, ExpiredAddress[]>>;
|
|
2946
|
-
}
|
|
2947
|
-
interface DumpKeyBook {
|
|
2948
|
-
data: {
|
|
2949
|
-
public: Record<string, Record<string, PublicKey$1>>;
|
|
2950
|
-
private: Record<string, Record<string, PrivateKey>>;
|
|
2951
|
-
read: Record<string, Uint8Array>;
|
|
2952
|
-
service: Record<string, Uint8Array>;
|
|
2953
|
-
};
|
|
2954
|
-
}
|
|
2955
|
-
interface DumpMetadata {
|
|
2956
|
-
data: {
|
|
2957
|
-
int64: Record<string, Record<string, number>>;
|
|
2958
|
-
bool: Record<string, Record<string, boolean>>;
|
|
2959
|
-
string: Record<string, Record<string, string>>;
|
|
2960
|
-
bytes: Record<string, Record<string, Uint8Array>>;
|
|
2961
|
-
};
|
|
2962
|
-
}
|
|
2963
|
-
|
|
2964
|
-
/**
|
|
2965
|
-
* Records with counters from a peer
|
|
2966
|
-
*/
|
|
2967
|
-
interface PeerRecords {
|
|
2968
|
-
records: IRecord[];
|
|
2969
|
-
counter: number;
|
|
2970
|
-
}
|
|
2971
|
-
|
|
2972
|
-
declare class DBClient {
|
|
2973
|
-
client: Client;
|
|
2974
|
-
dc: DcUtil;
|
|
2975
|
-
logstore: ILogstore;
|
|
2976
|
-
net: Net;
|
|
2977
|
-
constructor(dcClient: Client, dcUtil: DcUtil, net: Net, logstore: ILogstore);
|
|
2978
|
-
requestThreadID(peerAddr?: Multiaddr): Promise<string>;
|
|
2979
|
-
createThread(tid: string, opts: NewThreadOptions): Promise<string>;
|
|
2980
|
-
pushRecordToPeer(tid: ThreadID, lid: PeerId, rec: IRecord, counter: number): Promise<void>;
|
|
2981
|
-
pushLogToPeer(tid: ThreadID, lid: PeerId, rec: IRecord): Promise<Error | null>;
|
|
2982
|
-
/**
|
|
2983
|
-
* 与对等点交换边缘(状态信息)
|
|
2984
|
-
* @param threadIds threadID数组
|
|
2985
|
-
* @returns 无返回值
|
|
2986
|
-
*/
|
|
2987
|
-
exchangeEdges(threadIds: ThreadID[]): Promise<void>;
|
|
2988
|
-
private pushLogsHeadToPeer;
|
|
2989
|
-
/**
|
|
2990
|
-
* 获取threaddb 的本地边缘值(地址和头部)
|
|
2991
|
-
* 边缘值用于确定是否需要从远程对等点获取更新
|
|
2992
|
-
*
|
|
2993
|
-
* @param tid threaddb ID
|
|
2994
|
-
* @returns 地址边缘值和头部边缘值的对象
|
|
2995
|
-
* @throws 错误,包括特定的"No address edge"和"No heads edge"错误
|
|
2996
|
-
*/
|
|
2997
|
-
private localEdges;
|
|
2998
|
-
private edgeToBigInt;
|
|
2999
|
-
/**
|
|
3000
|
-
* 调度日志更新
|
|
3001
|
-
* @param tid threaddb ID
|
|
3002
|
-
*/
|
|
3003
|
-
scheduleUpdateLogs(tid: ThreadID): Promise<void>;
|
|
3004
|
-
/**
|
|
3005
|
-
* 调度记录更新
|
|
3006
|
-
* @param tid threaddb ID
|
|
3007
|
-
*/
|
|
3008
|
-
private scheduleUpdateRecords;
|
|
3009
|
-
/**
|
|
3010
|
-
* 构建获取记录的请求
|
|
3011
|
-
*/
|
|
3012
|
-
private buildGetRecordsRequest;
|
|
3013
|
-
/**
|
|
3014
|
-
* 获取threaddb 中的日志
|
|
3015
|
-
* @param tid threaddb ID
|
|
3016
|
-
* @param pid 对等点ID
|
|
3017
|
-
* @returns 日志信息数组
|
|
3018
|
-
*/
|
|
3019
|
-
getLogs(tid: ThreadID): Promise<IThreadLogInfo[]>;
|
|
3020
|
-
getRecordsFromPeer(req: any, serviceKey: SymKey): Promise<Record<string, PeerRecords>>;
|
|
3021
|
-
getThreadFromPeer(id: ThreadID, peerId: PeerId, options?: {
|
|
3022
|
-
token?: ThreadToken;
|
|
3023
|
-
}): Promise<IThreadInfo>;
|
|
3024
|
-
}
|
|
3025
|
-
|
|
3026
|
-
declare class AsyncMutex {
|
|
3027
|
-
private _locked;
|
|
3028
|
-
private _queue;
|
|
3029
|
-
acquire(): Promise<void>;
|
|
3030
|
-
release(): void;
|
|
3031
|
-
}
|
|
3032
|
-
|
|
3033
|
-
type PubKey = Ed25519PubKey;
|
|
3034
|
-
type Token = Uint8Array;
|
|
3035
|
-
interface App {
|
|
3036
|
-
validateNetRecordBody(body: IPLDNode, identity: PubKey): Promise<Error | undefined>;
|
|
3037
|
-
handleNetRecord(rec: IThreadRecord, key?: Key): Promise<Error | undefined>;
|
|
3038
|
-
getNetRecordCreateTime(rec: IThreadRecord, key?: Key): Promise<BigInt>;
|
|
3039
|
-
}
|
|
3040
|
-
declare class LocalEventsBus {
|
|
3041
|
-
private bus;
|
|
3042
|
-
private static readonly busTimeout;
|
|
3043
|
-
send(event: LocalEvent): Promise<void>;
|
|
3044
|
-
listen(): LocalEventListener;
|
|
3045
|
-
discard(): void;
|
|
3046
|
-
}
|
|
3047
|
-
declare class LocalEventListener {
|
|
3048
|
-
private bus;
|
|
3049
|
-
private handler;
|
|
3050
|
-
constructor(bus: EventEmitter);
|
|
3051
|
-
private onEvent;
|
|
3052
|
-
discard(): void;
|
|
3053
|
-
}
|
|
3054
|
-
interface LocalEvent {
|
|
3055
|
-
node: IPLDNode;
|
|
3056
|
-
token: ThreadToken;
|
|
3057
|
-
}
|
|
3058
|
-
interface Net extends INet {
|
|
3059
|
-
bstore: Blocks;
|
|
3060
|
-
connectApp(app: App, threadId: ThreadID): Promise<Connector>;
|
|
3061
|
-
createRecord(threadId: ThreadID, body: IPLDNode, options?: {
|
|
3062
|
-
threadToken?: ThreadToken;
|
|
3063
|
-
apiToken?: Token;
|
|
3064
|
-
}): Promise<IThreadRecord>;
|
|
3065
|
-
getDagService(): DAGCBOR;
|
|
3066
|
-
validate(id: ThreadID, token?: ThreadToken): Promise<Ed25519PubKey | undefined>;
|
|
3067
|
-
exchange(id: ThreadID): Promise<void>;
|
|
3068
|
-
threadOffsets(tid: ThreadID): Promise<[Record<string, Head>, PeerId[]]>;
|
|
3069
|
-
buildGetRecordsRequest(tid: ThreadID, offsets: Record<string, Head>, limit: number): Promise<{
|
|
3070
|
-
req: net.pb.IGetRecordsRequest;
|
|
3071
|
-
serviceKey: SymKey;
|
|
3072
|
-
}>;
|
|
3073
|
-
updateRecordsFromPeer(tid: ThreadID, peerId: PeerId | null, client?: DBClient): Promise<void>;
|
|
3074
|
-
getMutexForThread(threadId: string): AsyncMutex;
|
|
3075
|
-
preLoadLogs(tid: ThreadID, logs: net.pb.Log[]): Promise<void>;
|
|
3076
|
-
createExternalLogsIfNotExist(tid: ThreadID, logs: IThreadLogInfo[]): Promise<void>;
|
|
3077
|
-
createExternalLogsIfNotExistForPreload(tid: ThreadID, logs: IThreadLogInfo[]): Promise<void>;
|
|
3078
|
-
}
|
|
3079
|
-
declare class Connector {
|
|
3080
|
-
net: Net;
|
|
3081
|
-
private app;
|
|
3082
|
-
private threadInfo;
|
|
3083
|
-
readonly token: Token;
|
|
3084
|
-
constructor(net: Net, app: App, threadInfo: ThreadInfo);
|
|
3085
|
-
get threadId(): ThreadID;
|
|
3086
|
-
get threadKey(): Key | undefined;
|
|
3087
|
-
createNetRecord(body: IPLDNode, token?: ThreadToken): Promise<IThreadRecord>;
|
|
3088
|
-
validate(token?: ThreadToken): Promise<Error | undefined>;
|
|
3089
|
-
validateNetRecordBody(body: IPLDNode, identity: PubKey): Promise<Error | undefined>;
|
|
3090
|
-
handleNetRecord(rec: IThreadRecord): Promise<Error | undefined>;
|
|
3091
|
-
getNetRecordCreateTime(rec: IThreadRecord): Promise<BigInt>;
|
|
3092
|
-
private generateRandomBytes;
|
|
3093
|
-
}
|
|
3094
|
-
|
|
3095
|
-
interface Reducer {
|
|
3096
|
-
reduce(events: Event[]): Promise<void>;
|
|
3097
|
-
}
|
|
3098
|
-
declare class Dispatcher {
|
|
3099
|
-
private store;
|
|
3100
|
-
private reducers;
|
|
3101
|
-
private lock;
|
|
3102
|
-
private lastID;
|
|
3103
|
-
constructor(store: TxnDatastoreExtended);
|
|
3104
|
-
getStore(): TxnDatastoreExtended;
|
|
3105
|
-
register(reducer: Reducer): void;
|
|
3106
|
-
dispatch(events: Event[]): Promise<void>;
|
|
3107
|
-
query(query: Query$1): AsyncIterable<Pair>;
|
|
3108
|
-
private getKey;
|
|
3109
|
-
}
|
|
3110
|
-
|
|
3111
|
-
type InstanceID$1 = string;
|
|
3112
|
-
declare enum CoreActionType {
|
|
3113
|
-
Create = 0,
|
|
3114
|
-
Save = 1,
|
|
3115
|
-
Delete = 2
|
|
3116
|
-
}
|
|
3117
|
-
/**
|
|
3118
|
-
* Transaction class for collections
|
|
3119
|
-
*/
|
|
3120
|
-
interface ITxn {
|
|
3121
|
-
/**
|
|
3122
|
-
* Create new instances
|
|
3123
|
-
*/
|
|
3124
|
-
create(...newInstances: Uint8Array[]): Promise<InstanceID$1[]>;
|
|
3125
|
-
/**
|
|
3126
|
-
* Verify instance changes without saving them
|
|
3127
|
-
*/
|
|
3128
|
-
verify(...updated: Uint8Array[]): Promise<void>;
|
|
3129
|
-
/**
|
|
3130
|
-
* Save instance changes
|
|
3131
|
-
*/
|
|
3132
|
-
save(...updated: Uint8Array[]): Promise<void>;
|
|
3133
|
-
/**
|
|
3134
|
-
* Delete instances
|
|
3135
|
-
*/
|
|
3136
|
-
delete(...ids: InstanceID$1[]): Promise<void>;
|
|
3137
|
-
/**
|
|
3138
|
-
* Check if instances exist
|
|
3139
|
-
*/
|
|
3140
|
-
has(...ids: InstanceID$1[]): Promise<boolean>;
|
|
3141
|
-
/**
|
|
3142
|
-
* Find instance by ID
|
|
3143
|
-
*/
|
|
3144
|
-
findByID(id: InstanceID$1): Promise<Object>;
|
|
3145
|
-
/**
|
|
3146
|
-
* Find instances matching a query
|
|
3147
|
-
*/
|
|
3148
|
-
find(q?: Query$1): Promise<Object[]>;
|
|
3149
|
-
/**
|
|
3150
|
-
* Get instances modified since a specific time
|
|
3151
|
-
*
|
|
3152
|
-
* The _mod field tracks modified instances, but not those that have been deleted, so we need
|
|
3153
|
-
* to query the dispatcher for all (unique) instances in this collection that have been modified
|
|
3154
|
-
* at all since `time`.
|
|
3155
|
-
*/
|
|
3156
|
-
modifiedSince(time: number): Promise<InstanceID$1[]>;
|
|
3157
|
-
/**
|
|
3158
|
-
* Commit the transaction
|
|
3159
|
-
*/
|
|
3160
|
-
commit(): Promise<void>;
|
|
3161
|
-
/**
|
|
3162
|
-
* Discard the transaction
|
|
3163
|
-
*/
|
|
3164
|
-
discard(): void;
|
|
3165
|
-
/**
|
|
3166
|
-
* Refresh collection reference
|
|
3167
|
-
*/
|
|
3168
|
-
refreshCollection(): void;
|
|
3169
|
-
}
|
|
3170
|
-
interface ICollection {
|
|
3171
|
-
baseKey(): Key$1;
|
|
3172
|
-
getName(): string;
|
|
3173
|
-
getSchema(): Uint8Array;
|
|
3174
|
-
getWriteValidator(): Uint8Array;
|
|
3175
|
-
getReadFilter(): Uint8Array;
|
|
3176
|
-
readTxn(fn: (txn: ITxn) => Promise<void>, token?: ThreadToken): Promise<void>;
|
|
3177
|
-
writeTxn(fn: (txn: ITxn) => Promise<void>, token?: ThreadToken): Promise<void>;
|
|
3178
|
-
findByID(id: InstanceID$1, token?: ThreadToken): Promise<Object>;
|
|
3179
|
-
create(v: Uint8Array, token?: ThreadToken): Promise<InstanceID$1>;
|
|
3180
|
-
createMany(vs: Uint8Array[], token?: ThreadToken): Promise<InstanceID$1[]>;
|
|
3181
|
-
delete(id: InstanceID$1, token?: ThreadToken): Promise<void>;
|
|
3182
|
-
deleteMany(ids: InstanceID$1[], token?: ThreadToken): Promise<void>;
|
|
3183
|
-
save(v: Uint8Array, token?: ThreadToken): Promise<void>;
|
|
3184
|
-
saveMany(vs: Uint8Array[], token?: ThreadToken): Promise<void>;
|
|
3185
|
-
verify(v: Uint8Array, token?: ThreadToken): Promise<void>;
|
|
3186
|
-
verifyMany(vs: Uint8Array[], token?: ThreadToken): Promise<void>;
|
|
3187
|
-
has(id: InstanceID$1, token?: ThreadToken): Promise<boolean>;
|
|
3188
|
-
hasMany(ids: InstanceID$1[], token?: ThreadToken): Promise<boolean>;
|
|
3189
|
-
find(q: Query$1, token?: ThreadToken): Promise<Object[]>;
|
|
3190
|
-
modifiedSince(time: number, token?: ThreadToken): Promise<InstanceID$1[]>;
|
|
3191
|
-
validInstance(v: Uint8Array): void;
|
|
3192
|
-
validWrite(identity: Ed25519PubKey, e: Event): Promise<void>;
|
|
3193
|
-
filterRead(identity: Ed25519PubKey, instance: Uint8Array): Promise<Uint8Array | null>;
|
|
3194
|
-
}
|
|
3195
|
-
interface IDB {
|
|
3196
|
-
datastore: TxnDatastoreExtended;
|
|
3197
|
-
connector: Connector | null;
|
|
3198
|
-
dispatcher: Dispatcher | null;
|
|
3199
|
-
eventcodec: EventCodec;
|
|
3200
|
-
localEventsBus: LocalEventsBus | null;
|
|
3201
|
-
collections: Map<string, ICollection>;
|
|
3202
|
-
readTxn(collection: ICollection, fn: (txn: ITxn) => Promise<void>, token?: ThreadToken): Promise<void>;
|
|
3203
|
-
writeTxn(collection: ICollection, fn: (txn: ITxn) => Promise<void>, token?: ThreadToken): Promise<void>;
|
|
3204
|
-
notifyTxnEvents(node: IPLDNode, token?: ThreadToken): Promise<void>;
|
|
3205
|
-
}
|
|
3206
|
-
interface Event<T = any> {
|
|
3207
|
-
/** 事件时间戳 (Unix纳秒时间戳) */
|
|
3208
|
-
readonly timestamp: BigInt;
|
|
3209
|
-
/** 关联的实例ID */
|
|
3210
|
-
readonly instanceID: InstanceID$1;
|
|
3211
|
-
/** 所属集合名称 */
|
|
3212
|
-
readonly collection: string;
|
|
3213
|
-
/** 事件负载数据 */
|
|
3214
|
-
readonly payload: T;
|
|
3215
|
-
/** 序列化为Uint8Array */
|
|
3216
|
-
marshal(): Promise<Uint8Array>;
|
|
3217
|
-
}
|
|
3218
|
-
interface QueryResult {
|
|
3219
|
-
key: string;
|
|
3220
|
-
value: Uint8Array;
|
|
3221
|
-
size?: number;
|
|
3222
|
-
}
|
|
3223
|
-
interface QueryExt extends Query$1 {
|
|
3224
|
-
seekPrefix?: string;
|
|
3225
|
-
}
|
|
3226
|
-
interface Transaction {
|
|
3227
|
-
put(key: Key$1, value: Uint8Array): Promise<Key$1>;
|
|
3228
|
-
delete(key: Key$1): Promise<void>;
|
|
3229
|
-
get(key: Key$1): Promise<Uint8Array | undefined>;
|
|
3230
|
-
has(key: Key$1): Promise<boolean>;
|
|
3231
|
-
commit(): Promise<void>;
|
|
3232
|
-
discard(): void;
|
|
3233
|
-
query(q: Query$1): AsyncIterable<QueryResult>;
|
|
3234
|
-
queryExtended(q: QueryExt): AsyncIterable<QueryResult>;
|
|
3235
|
-
}
|
|
3236
|
-
interface DatastoreExtensions {
|
|
3237
|
-
newTransactionExtended(readOnly: boolean): Promise<Transaction>;
|
|
3238
|
-
queryExtended(q: QueryExt): AsyncIterable<QueryResult>;
|
|
3239
|
-
}
|
|
3240
|
-
interface TxnDatastoreExtended extends Datastore, DatastoreExtensions {
|
|
3241
|
-
batch(): Batch;
|
|
3242
|
-
newTransactionExtended(readOnly: boolean): Promise<Transaction>;
|
|
3243
|
-
}
|
|
3244
|
-
type IndexFunc = (collection: string, key: Key$1, txn: Transaction, oldData?: Uint8Array, newData?: Uint8Array) => Promise<void>;
|
|
3245
|
-
interface Action {
|
|
3246
|
-
type: CoreActionType;
|
|
3247
|
-
instanceID: InstanceID$1;
|
|
3248
|
-
collectionName: string;
|
|
3249
|
-
previous?: Uint8Array;
|
|
3250
|
-
current?: Uint8Array;
|
|
3251
|
-
}
|
|
3252
|
-
interface ReduceAction {
|
|
3253
|
-
type: CoreActionType;
|
|
3254
|
-
collection: string;
|
|
3255
|
-
instanceID: InstanceID$1;
|
|
3256
|
-
}
|
|
3257
|
-
interface EventCodec {
|
|
3258
|
-
reduce(events: Event[], store: TxnDatastoreExtended, baseKey: Key$1, indexFn: IndexFunc): Promise<ReduceAction[]>;
|
|
3259
|
-
create(actions: Action[]): Promise<[Event[], IPLDNode]>;
|
|
3260
|
-
eventsFromBytes(data: Uint8Array): Promise<Event[]>;
|
|
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
|
+
}
|
|
3261
3049
|
}
|
|
3262
3050
|
|
|
3263
3051
|
interface Context {
|
|
@@ -3326,105 +3114,319 @@ interface SymKey {
|
|
|
3326
3114
|
key: CryptoKey;
|
|
3327
3115
|
raw: Uint8Array;
|
|
3328
3116
|
}
|
|
3329
|
-
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 {
|
|
3330
3257
|
addr: Multiaddr;
|
|
3331
|
-
|
|
3332
|
-
constructor(addr: Multiaddr, id: ThreadID);
|
|
3333
|
-
getMultiaddrString(): string;
|
|
3258
|
+
expires: Date;
|
|
3334
3259
|
}
|
|
3335
|
-
interface
|
|
3336
|
-
|
|
3337
|
-
key: Key | undefined;
|
|
3338
|
-
logs: IThreadLogInfo[];
|
|
3339
|
-
addrs: ThreadMuliaddr[];
|
|
3340
|
-
getFirstPrivKeyLog(): IThreadLogInfo | undefined;
|
|
3260
|
+
interface DumpHeadBook {
|
|
3261
|
+
data: Record<string, Record<string, Head[]>>;
|
|
3341
3262
|
}
|
|
3342
|
-
interface
|
|
3343
|
-
|
|
3344
|
-
name: string;
|
|
3345
|
-
addrs: string[];
|
|
3346
|
-
key: string | undefined;
|
|
3263
|
+
interface DumpAddrBook {
|
|
3264
|
+
data: Record<string, Record<string, ExpiredAddress[]>>;
|
|
3347
3265
|
}
|
|
3348
|
-
|
|
3349
|
-
|
|
3350
|
-
|
|
3351
|
-
|
|
3352
|
-
|
|
3353
|
-
|
|
3354
|
-
|
|
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
|
+
};
|
|
3355
3273
|
}
|
|
3356
|
-
interface
|
|
3357
|
-
|
|
3358
|
-
|
|
3359
|
-
|
|
3360
|
-
|
|
3361
|
-
|
|
3362
|
-
|
|
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
|
+
};
|
|
3363
3281
|
}
|
|
3364
3282
|
|
|
3365
3283
|
/**
|
|
3366
|
-
*
|
|
3284
|
+
* Records with counters from a peer
|
|
3367
3285
|
*/
|
|
3368
|
-
|
|
3369
|
-
|
|
3370
|
-
|
|
3371
|
-
|
|
3372
|
-
|
|
3373
|
-
|
|
3374
|
-
|
|
3375
|
-
|
|
3376
|
-
|
|
3377
|
-
|
|
3378
|
-
|
|
3379
|
-
|
|
3380
|
-
|
|
3381
|
-
|
|
3382
|
-
|
|
3383
|
-
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>;
|
|
3384
3301
|
/**
|
|
3385
|
-
*
|
|
3302
|
+
* 与对等点交换边缘(状态信息)
|
|
3303
|
+
* @param threadIds threadID数组
|
|
3304
|
+
* @returns 无返回值
|
|
3386
3305
|
*/
|
|
3387
|
-
|
|
3388
|
-
|
|
3389
|
-
static fromSymKey(symKey: SymKey): SymmetricKey;
|
|
3306
|
+
exchangeEdges(threadIds: ThreadID[]): Promise<void>;
|
|
3307
|
+
private pushLogsHeadToPeer;
|
|
3390
3308
|
/**
|
|
3391
|
-
*
|
|
3309
|
+
* 获取threaddb 的本地边缘值(地址和头部)
|
|
3310
|
+
* 边缘值用于确定是否需要从远程对等点获取更新
|
|
3311
|
+
*
|
|
3312
|
+
* @param tid threaddb ID
|
|
3313
|
+
* @returns 地址边缘值和头部边缘值的对象
|
|
3314
|
+
* @throws 错误,包括特定的"No address edge"和"No heads edge"错误
|
|
3392
3315
|
*/
|
|
3393
|
-
|
|
3316
|
+
private localEdges;
|
|
3317
|
+
private edgeToBigInt;
|
|
3394
3318
|
/**
|
|
3395
|
-
*
|
|
3319
|
+
* 调度日志更新
|
|
3320
|
+
* @param tid threaddb ID
|
|
3396
3321
|
*/
|
|
3397
|
-
|
|
3322
|
+
scheduleUpdateLogs(tid: ThreadID): Promise<void>;
|
|
3398
3323
|
/**
|
|
3399
|
-
*
|
|
3324
|
+
* 调度记录更新
|
|
3325
|
+
* @param tid threaddb ID
|
|
3400
3326
|
*/
|
|
3401
|
-
|
|
3327
|
+
private scheduleUpdateRecords;
|
|
3402
3328
|
/**
|
|
3403
|
-
*
|
|
3329
|
+
* 构建获取记录的请求
|
|
3404
3330
|
*/
|
|
3405
|
-
|
|
3406
|
-
encrypt(plaintext: Uint8Array, exNonce?: Uint8Array): Promise<Uint8Array>;
|
|
3331
|
+
private buildGetRecordsRequest;
|
|
3407
3332
|
/**
|
|
3408
|
-
*
|
|
3333
|
+
* 获取threaddb 中的日志
|
|
3334
|
+
* @param tid threaddb ID
|
|
3335
|
+
* @param pid 对等点ID
|
|
3336
|
+
* @returns 日志信息数组
|
|
3409
3337
|
*/
|
|
3410
|
-
|
|
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>;
|
|
3411
3343
|
}
|
|
3412
|
-
|
|
3413
|
-
declare class
|
|
3414
|
-
private
|
|
3415
|
-
private
|
|
3416
|
-
|
|
3417
|
-
|
|
3418
|
-
|
|
3419
|
-
|
|
3420
|
-
|
|
3421
|
-
|
|
3422
|
-
|
|
3423
|
-
|
|
3424
|
-
|
|
3425
|
-
|
|
3426
|
-
|
|
3427
|
-
|
|
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>;
|
|
3428
3430
|
}
|
|
3429
3431
|
|
|
3430
3432
|
/**
|
|
@@ -3849,6 +3851,14 @@ interface IAuthOperations {
|
|
|
3849
3851
|
* @returns [状态码, 错误信息]
|
|
3850
3852
|
*/
|
|
3851
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>;
|
|
3852
3862
|
/**
|
|
3853
3863
|
* 创建APP访问账号,返回APP专用私钥
|
|
3854
3864
|
* @param appId 应用ID
|
|
@@ -3870,10 +3880,10 @@ interface IAuthOperations {
|
|
|
3870
3880
|
*/
|
|
3871
3881
|
isNftAccountBinded(nftAccount: string): Promise<[boolean | null, Error | null]>;
|
|
3872
3882
|
/**
|
|
3873
|
-
|
|
3874
|
-
|
|
3875
|
-
|
|
3876
|
-
|
|
3883
|
+
* 获取用户信息
|
|
3884
|
+
* @param nftAccount NFT账户
|
|
3885
|
+
* @returns 用户信息
|
|
3886
|
+
*/
|
|
3877
3887
|
getUserInfoWithNft(nftAccount: string): Promise<[User | null, Error | null]>;
|
|
3878
3888
|
/**
|
|
3879
3889
|
* 获取用户钱包信息
|
|
@@ -3905,6 +3915,42 @@ interface IAuthOperations {
|
|
|
3905
3915
|
* @returns 用户默认数据库信息
|
|
3906
3916
|
*/
|
|
3907
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;
|
|
3908
3954
|
}
|
|
3909
3955
|
|
|
3910
3956
|
/**
|
|
@@ -3933,6 +3979,7 @@ interface IDatabaseOperations {
|
|
|
3933
3979
|
* @returns 错误信息
|
|
3934
3980
|
*/
|
|
3935
3981
|
initDBManager(): Promise<Error | null>;
|
|
3982
|
+
resetDBManager(): void;
|
|
3936
3983
|
/**
|
|
3937
3984
|
* 创建新数据库
|
|
3938
3985
|
* @param name 数据库名称
|
|
@@ -27900,7 +27947,7 @@ declare class AuthModule implements DCModule, IAuthOperations {
|
|
|
27900
27947
|
* 账户登录
|
|
27901
27948
|
* @returns 是否登录成功
|
|
27902
27949
|
*/
|
|
27903
|
-
accountLoginWithWalletCall(accountInfo?: AccountInfo): Promise<Account
|
|
27950
|
+
accountLoginWithWalletCall(accountInfo?: AccountInfo): Promise<Account>;
|
|
27904
27951
|
/**
|
|
27905
27952
|
* 账户登录(钱包登录)不抛出异常
|
|
27906
27953
|
* @returns [账户信息, 错误信息]
|
|
@@ -27918,11 +27965,19 @@ declare class AuthModule implements DCModule, IAuthOperations {
|
|
|
27918
27965
|
* @returns [是否登录成功, 错误信息]
|
|
27919
27966
|
*/
|
|
27920
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>;
|
|
27921
27976
|
signWithWallet(payload: Uint8Array): Promise<Uint8Array>;
|
|
27922
27977
|
sign(payload: Uint8Array): Promise<[Uint8Array | null, Error | null]>;
|
|
27923
27978
|
decryptWithWallet(payload: Uint8Array): Promise<[Uint8Array | null, Error | null]>;
|
|
27924
|
-
signMessageWithWallet(data: SignReqMessage): Promise<SignResponseMessage | null>;
|
|
27925
|
-
signEIP712MessageWithWallet(data: EIP712SignReqMessage): Promise<SignResponseMessage | null>;
|
|
27979
|
+
signMessageWithWallet(data: SignReqMessage): Promise<[SignResponseMessage | null, Error | null]>;
|
|
27980
|
+
signEIP712MessageWithWallet(data: EIP712SignReqMessage): Promise<[SignResponseMessage | null, Error | null]>;
|
|
27926
27981
|
/**
|
|
27927
27982
|
* 将私钥绑定NFT账号(NFT账号+密码+安全码)
|
|
27928
27983
|
* @param account NFT账号
|
|
@@ -28143,6 +28198,7 @@ declare class DatabaseModule implements DCModule, IDatabaseOperations {
|
|
|
28143
28198
|
* 关闭数据库模块
|
|
28144
28199
|
*/
|
|
28145
28200
|
shutdown(): Promise<void>;
|
|
28201
|
+
resetDBManager(): Promise<void>;
|
|
28146
28202
|
/**
|
|
28147
28203
|
* 初始化数据库管理器
|
|
28148
28204
|
*/
|