@peerbit/log 4.0.4 → 4.0.5
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/src/clock.d.ts.map +1 -1
- package/dist/src/clock.js +20 -11
- package/dist/src/clock.js.map +1 -1
- package/dist/src/entry-create.d.ts +26 -0
- package/dist/src/entry-create.d.ts.map +1 -0
- package/dist/src/entry-create.js +5 -0
- package/dist/src/entry-create.js.map +1 -0
- package/dist/src/entry-index.d.ts +2 -1
- package/dist/src/entry-index.d.ts.map +1 -1
- package/dist/src/entry-index.js +2 -1
- package/dist/src/entry-index.js.map +1 -1
- package/dist/src/entry-shallow.d.ts +29 -0
- package/dist/src/entry-shallow.d.ts.map +1 -0
- package/dist/src/entry-shallow.js +75 -0
- package/dist/src/entry-shallow.js.map +1 -0
- package/dist/src/entry-type.d.ts +5 -0
- package/dist/src/entry-type.d.ts.map +1 -0
- package/dist/src/entry-type.js +6 -0
- package/dist/src/entry-type.js.map +1 -0
- package/dist/src/entry-v0.d.ts +121 -0
- package/dist/src/entry-v0.d.ts.map +1 -0
- package/dist/src/entry-v0.js +465 -0
- package/dist/src/entry-v0.js.map +1 -0
- package/dist/src/entry.d.ts +31 -153
- package/dist/src/entry.d.ts.map +1 -1
- package/dist/src/entry.js +24 -581
- package/dist/src/entry.js.map +1 -1
- package/dist/src/heads-cache.d.ts +1 -1
- package/dist/src/heads-cache.d.ts.map +1 -1
- package/dist/src/heads-cache.js +0 -1
- package/dist/src/heads-cache.js.map +1 -1
- package/dist/src/index.d.ts +5 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +5 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/log.d.ts +6 -4
- package/dist/src/log.d.ts.map +1 -1
- package/dist/src/log.js +22 -82
- package/dist/src/log.js.map +1 -1
- package/dist/src/payload.d.ts +17 -0
- package/dist/src/payload.d.ts.map +1 -0
- package/dist/src/payload.js +53 -0
- package/dist/src/payload.js.map +1 -0
- package/dist/src/trim.d.ts +2 -1
- package/dist/src/trim.d.ts.map +1 -1
- package/dist/src/trim.js.map +1 -1
- package/package.json +3 -3
- package/src/clock.ts +3 -2
- package/src/entry-create.ts +30 -0
- package/src/entry-index.ts +3 -6
- package/src/entry-shallow.ts +61 -0
- package/src/entry-type.ts +4 -0
- package/src/entry-v0.ts +594 -0
- package/src/entry.ts +50 -693
- package/src/heads-cache.ts +1 -1
- package/src/index.ts +5 -0
- package/src/log.ts +23 -94
- package/src/payload.ts +44 -0
- package/src/trim.ts +2 -1
package/dist/src/entry.d.ts
CHANGED
|
@@ -1,172 +1,44 @@
|
|
|
1
1
|
import { type Blocks } from "@peerbit/blocks-interface";
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
2
|
+
import type { PublicSignKey, SignatureWithKey } from "@peerbit/crypto";
|
|
3
|
+
import type { Keychain } from "@peerbit/keychain";
|
|
4
4
|
import { LamportClock as Clock } from "./clock.js";
|
|
5
|
-
import {
|
|
6
|
-
import type {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
[key: string]: MaybeEncryptionPublicKey;
|
|
10
|
-
}>;
|
|
11
|
-
export interface EntryEncryption {
|
|
12
|
-
receiver: EncryptionTemplateMaybeEncrypted;
|
|
13
|
-
keypair: X25519Keypair;
|
|
14
|
-
}
|
|
15
|
-
export declare function toBufferLE(num: bigint, width: number): Uint8Array;
|
|
16
|
-
export declare function toBigIntLE(buf: Uint8Array): bigint;
|
|
5
|
+
import type { Encoding } from "./encoding.js";
|
|
6
|
+
import type { ShallowEntry } from "./entry-shallow.js";
|
|
7
|
+
import type { EntryType } from "./entry-type.js";
|
|
8
|
+
import type { Payload } from "./payload.js";
|
|
17
9
|
export type CanAppend<T> = (canAppend: Entry<T>) => Promise<boolean> | boolean;
|
|
18
|
-
export
|
|
19
|
-
|
|
20
|
-
encoding: Encoding<T>;
|
|
21
|
-
private _value?;
|
|
22
|
-
constructor(props: {
|
|
23
|
-
data: Uint8Array;
|
|
24
|
-
value?: T;
|
|
25
|
-
encoding: Encoding<T>;
|
|
26
|
-
});
|
|
27
|
-
equals(other: Payload<T>): boolean;
|
|
28
|
-
get isDecoded(): boolean;
|
|
29
|
-
get value(): T;
|
|
30
|
-
getValue(encoding?: Encoding<T>): T;
|
|
31
|
-
}
|
|
32
|
-
export interface EntryEncryptionTemplate<A, B, C> {
|
|
33
|
-
meta: A;
|
|
34
|
-
payload: B;
|
|
35
|
-
signatures: C;
|
|
36
|
-
}
|
|
37
|
-
export declare enum EntryType {
|
|
38
|
-
APPEND = 0,// Add more data
|
|
39
|
-
CUT = 1
|
|
40
|
-
}
|
|
41
|
-
export declare class Meta {
|
|
10
|
+
export type ShallowOrFullEntry<T> = ShallowEntry | Entry<T>;
|
|
11
|
+
interface Meta {
|
|
42
12
|
clock: Clock;
|
|
43
13
|
gid: string;
|
|
44
14
|
next: string[];
|
|
45
15
|
type: EntryType;
|
|
46
16
|
data?: Uint8Array;
|
|
47
|
-
constructor(properties: {
|
|
48
|
-
gid: string;
|
|
49
|
-
clock: Clock;
|
|
50
|
-
type: EntryType;
|
|
51
|
-
data?: Uint8Array;
|
|
52
|
-
next: string[];
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
export declare class Signatures {
|
|
56
|
-
signatures: MaybeEncrypted<SignatureWithKey>[];
|
|
57
|
-
constructor(properties?: {
|
|
58
|
-
signatures: MaybeEncrypted<SignatureWithKey>[];
|
|
59
|
-
});
|
|
60
|
-
equals(other: Signatures): boolean;
|
|
61
17
|
}
|
|
62
|
-
export
|
|
63
|
-
hash: string;
|
|
18
|
+
export interface Entry<T> {
|
|
64
19
|
meta: Meta;
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
constructor(properties: {
|
|
68
|
-
hash: string;
|
|
69
|
-
meta: Meta;
|
|
70
|
-
payloadSize: number;
|
|
71
|
-
head: boolean;
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
export type ShallowOrFullEntry<T> = ShallowEntry | Entry<T>;
|
|
75
|
-
export declare class Entry<T> implements EntryEncryptionTemplate<Meta, Payload<T>, SignatureWithKey[]> {
|
|
76
|
-
_meta: MaybeEncrypted<Meta>;
|
|
77
|
-
_payload: MaybeEncrypted<Payload<T>>;
|
|
78
|
-
_reserved?: Uint8Array;
|
|
79
|
-
_signatures?: Signatures;
|
|
20
|
+
payload: Payload<T>;
|
|
21
|
+
signatures: SignatureWithKey[];
|
|
80
22
|
hash: string;
|
|
23
|
+
size: number;
|
|
81
24
|
createdLocally?: boolean;
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
meta: MaybeEncrypted<Meta>;
|
|
88
|
-
reserved?: Uint8Array;
|
|
89
|
-
hash?: string;
|
|
90
|
-
createdLocally?: boolean;
|
|
91
|
-
});
|
|
92
|
-
init(props: {
|
|
25
|
+
publicKeys: PublicSignKey[];
|
|
26
|
+
toShallow(isHead: boolean): ShallowEntry;
|
|
27
|
+
}
|
|
28
|
+
export declare abstract class Entry<T> {
|
|
29
|
+
abstract init(props: {
|
|
93
30
|
keychain?: Keychain;
|
|
94
31
|
encoding: Encoding<T>;
|
|
95
32
|
} | Entry<T>): this;
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
getPayloadValue(): Promise<T>;
|
|
105
|
-
get publicKeys(): PublicSignKey[];
|
|
33
|
+
abstract getMeta(): Promise<Meta> | Meta;
|
|
34
|
+
abstract getNext(): Promise<string[]> | string[];
|
|
35
|
+
abstract verifySignatures(): Promise<boolean> | boolean;
|
|
36
|
+
abstract getSignatures(): Promise<SignatureWithKey[]> | SignatureWithKey[];
|
|
37
|
+
abstract getClock(): Promise<Clock> | Clock;
|
|
38
|
+
abstract equals(other: Entry<T>): boolean;
|
|
39
|
+
abstract getPayloadValue(): Promise<T> | T;
|
|
40
|
+
abstract toSignable(): Entry<T>;
|
|
106
41
|
getPublicKeys(): Promise<PublicSignKey[]>;
|
|
107
|
-
get next(): string[];
|
|
108
|
-
getNext(): Promise<string[]>;
|
|
109
|
-
private _size;
|
|
110
|
-
set size(number: number);
|
|
111
|
-
get size(): number;
|
|
112
|
-
/**
|
|
113
|
-
* Will only return signatures I can decrypt
|
|
114
|
-
* @returns signatures
|
|
115
|
-
*/
|
|
116
|
-
get signatures(): SignatureWithKey[];
|
|
117
|
-
/**
|
|
118
|
-
* Will only return signatures I can decrypt
|
|
119
|
-
* @returns signatures
|
|
120
|
-
*/
|
|
121
|
-
getSignatures(): Promise<SignatureWithKey[]>;
|
|
122
|
-
/**
|
|
123
|
-
* Will only verify signatures I can decrypt
|
|
124
|
-
* @returns true if all are verified
|
|
125
|
-
*/
|
|
126
|
-
verifySignatures(): Promise<boolean>;
|
|
127
|
-
static toSignable(entry: Entry<any>): Entry<any>;
|
|
128
|
-
toSignable(): Entry<any>;
|
|
129
|
-
equals(other: Entry<T>): boolean;
|
|
130
|
-
delete(store: Blocks): Promise<void>;
|
|
131
|
-
static createGid(seed?: Uint8Array): Promise<string>;
|
|
132
|
-
static create<T>(properties: {
|
|
133
|
-
store: Blocks;
|
|
134
|
-
data: T;
|
|
135
|
-
meta?: {
|
|
136
|
-
clock?: Clock;
|
|
137
|
-
gid?: string;
|
|
138
|
-
type?: EntryType;
|
|
139
|
-
gidSeed?: Uint8Array;
|
|
140
|
-
data?: Uint8Array;
|
|
141
|
-
next?: SortableEntry[];
|
|
142
|
-
};
|
|
143
|
-
encoding?: Encoding<T>;
|
|
144
|
-
canAppend?: CanAppend<T>;
|
|
145
|
-
encryption?: EntryEncryption;
|
|
146
|
-
identity: Identity;
|
|
147
|
-
signers?: ((data: Uint8Array) => Promise<SignatureWithKey> | SignatureWithKey)[];
|
|
148
|
-
}): Promise<Entry<T>>;
|
|
149
|
-
get payloadByteLength(): number;
|
|
150
|
-
toShallow(isHead: boolean): ShallowEntry;
|
|
151
|
-
/**
|
|
152
|
-
* Get the multihash of an Entry.
|
|
153
|
-
* @example
|
|
154
|
-
* const multfihash = await Entry.toMultihash(store, entry)
|
|
155
|
-
* console.log(multihash)
|
|
156
|
-
* // "Qm...Foo"
|
|
157
|
-
*/
|
|
158
|
-
static toMultihash<T>(store: Blocks, entry: Entry<T>): Promise<string>;
|
|
159
|
-
/**
|
|
160
|
-
* Create an Entry from a hash.
|
|
161
|
-
* @example
|
|
162
|
-
* const entry = await Entry.fromMultihash(store, "zd...Foo")
|
|
163
|
-
* console.log(entry)
|
|
164
|
-
* // { hash: "Zd...Foo", payload: "hello", next: [] }
|
|
165
|
-
*/
|
|
166
|
-
static fromMultihash<T>(store: Blocks, hash: string, options?: {
|
|
167
|
-
timeout?: number;
|
|
168
|
-
replicate?: boolean;
|
|
169
|
-
}): Promise<Entry<T>>;
|
|
170
42
|
/**
|
|
171
43
|
* Compares two entries.
|
|
172
44
|
* @param {Entry} a
|
|
@@ -174,6 +46,11 @@ export declare class Entry<T> implements EntryEncryptionTemplate<Meta, Payload<T
|
|
|
174
46
|
* @returns {number} 1 if a is greater, -1 is b is greater
|
|
175
47
|
*/
|
|
176
48
|
static compare<T>(a: Entry<T>, b: Entry<T>): any;
|
|
49
|
+
static toMultihash<T>(store: Blocks, entry: Entry<T>): Promise<string> | string;
|
|
50
|
+
static fromMultihash: <T_1>(store: Blocks, hash: string, options?: {
|
|
51
|
+
timeout?: number;
|
|
52
|
+
replicate?: boolean;
|
|
53
|
+
}) => Promise<Entry<T_1>>;
|
|
177
54
|
/**
|
|
178
55
|
* Check if an entry equals another entry.
|
|
179
56
|
* @param {Entry} a
|
|
@@ -197,4 +74,5 @@ export declare class Entry<T> implements EntryEncryptionTemplate<Meta, Payload<T
|
|
|
197
74
|
*/
|
|
198
75
|
static findDirectChildren<T>(entry: Entry<T>, values: Entry<T>[]): Entry<T>[];
|
|
199
76
|
}
|
|
77
|
+
export {};
|
|
200
78
|
//# sourceMappingURL=entry.d.ts.map
|
package/dist/src/entry.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entry.d.ts","sourceRoot":"","sources":["../../src/entry.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"entry.d.ts","sourceRoot":"","sources":["../../src/entry.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,KAAK,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACvE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,YAAY,IAAI,KAAK,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAE5C,MAAM,MAAM,SAAS,CAAC,CAAC,IAAI,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC,CAAC,KAAK,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;AAC/E,MAAM,MAAM,kBAAkB,CAAC,CAAC,IAAI,YAAY,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;AAE5D,UAAU,IAAI;IACb,KAAK,EAAE,KAAK,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,IAAI,EAAE,SAAS,CAAC;IAChB,IAAI,CAAC,EAAE,UAAU,CAAC;CAClB;AAED,MAAM,WAAW,KAAK,CAAC,CAAC;IACvB,IAAI,EAAE,IAAI,CAAC;IACX,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;IACpB,UAAU,EAAE,gBAAgB,EAAE,CAAC;IAC/B,IAAI,EAAE,MAAM,CAAC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