@keetanetwork/keetanet-client 0.10.2
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/._version.d.ts +0 -0
- package/LICENSE +35 -0
- package/api/index.d.ts +181 -0
- package/api/node.d.ts +216 -0
- package/api/vote.d.ts +25 -0
- package/client/builder.d.ts +129 -0
- package/client/client_common_tests.d.ts +72 -0
- package/client/index-browser.d.ts +243 -0
- package/client/index-browser.js +141899 -0
- package/client/index.d.ts +243 -0
- package/client/index.js +89118 -0
- package/config/index.d.ts +62 -0
- package/lib/account.d.ts +544 -0
- package/lib/block/index.d.ts +181 -0
- package/lib/block/operations.d.ts +407 -0
- package/lib/bootstrap.d.ts +27 -0
- package/lib/error/account.d.ts +9 -0
- package/lib/error/block.d.ts +9 -0
- package/lib/error/client.d.ts +9 -0
- package/lib/error/index.d.ts +20 -0
- package/lib/error/kv.d.ts +9 -0
- package/lib/error/ledger.d.ts +12 -0
- package/lib/error/permissions.d.ts +9 -0
- package/lib/error/vote.d.ts +9 -0
- package/lib/index.d.ts +39 -0
- package/lib/kv/index.d.ts +22 -0
- package/lib/kv/index.test.data.d.ts +9 -0
- package/lib/kv/kv_dynamodb.d.ts +20 -0
- package/lib/kv/kv_memory.d.ts +17 -0
- package/lib/kv/kv_redis.d.ts +22 -0
- package/lib/kv/providers.d.ts +9 -0
- package/lib/ledger/cache.d.ts +14 -0
- package/lib/ledger/common.d.ts +115 -0
- package/lib/ledger/db_dynamodb.d.ts +129 -0
- package/lib/ledger/db_memory.d.ts +6 -0
- package/lib/ledger/db_postgres.d.ts +70 -0
- package/lib/ledger/db_spanner.d.ts +116 -0
- package/lib/ledger/db_spanner_helper.d.ts +487 -0
- package/lib/ledger/db_sqlite.d.ts +64 -0
- package/lib/ledger/drivers.d.ts +7 -0
- package/lib/ledger/effects.d.ts +78 -0
- package/lib/ledger/index.d.ts +312 -0
- package/lib/ledger/types.d.ts +49 -0
- package/lib/node/index.d.ts +114 -0
- package/lib/node/local.d.ts +30 -0
- package/lib/node/timing.d.ts +12 -0
- package/lib/node/utils.d.ts +4 -0
- package/lib/p2p.d.ts +300 -0
- package/lib/permissions.d.ts +121 -0
- package/lib/pubsub/index.d.ts +7 -0
- package/lib/pubsub/providers.d.ts +7 -0
- package/lib/pubsub/ps_memory.d.ts +9 -0
- package/lib/pubsub/ps_redis.d.ts +10 -0
- package/lib/stats.d.ts +51 -0
- package/lib/utils/asn1.d.ts +205 -0
- package/lib/utils/bitfield.d.ts +13 -0
- package/lib/utils/bloom.d.ts +6 -0
- package/lib/utils/buffer.d.ts +27 -0
- package/lib/utils/certificate.d.ts +340 -0
- package/lib/utils/conversion.d.ts +46 -0
- package/lib/utils/dynamodb.d.ts +17 -0
- package/lib/utils/ed2curve.d.ts +7 -0
- package/lib/utils/hash.d.ts +17 -0
- package/lib/utils/helper.d.ts +67 -0
- package/lib/utils/helper_testing.d.ts +37 -0
- package/lib/utils/initial.d.ts +32 -0
- package/lib/utils/never.d.ts +7 -0
- package/lib/utils/redis.d.ts +11 -0
- package/lib/vote.d.ts +273 -0
- package/package.json +35 -0
- package/version.d.ts +2 -0
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { JSONSerializable } from './conversion';
|
|
2
|
+
export type DistributiveOmit<T, P extends PropertyKey> = T extends T ? Omit<T, P> : never;
|
|
3
|
+
export declare function bufferToArrayBuffer(input: Buffer): ArrayBuffer;
|
|
4
|
+
/**
|
|
5
|
+
* Check if a value is an integer or a bigint.
|
|
6
|
+
*/
|
|
7
|
+
export declare function isIntegerOrBigInt(value: unknown): boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Check if a value is a Buffer. This exists due to an inconsistency with the
|
|
10
|
+
* way `Buffer.isBuffer` is defined in `@types/node` and differs from similar
|
|
11
|
+
* functionality such as `Array.isArray`. This leads `Buffer.isBuffer` to
|
|
12
|
+
* result in an unbound method reference error despite being a static call.
|
|
13
|
+
* Eslint Rule: eslint@typescript-eslint/unbound-method
|
|
14
|
+
*/
|
|
15
|
+
export declare function isBuffer(value: unknown): value is Buffer;
|
|
16
|
+
export declare function arrayRepeat<T>(value: T, length: number): T[];
|
|
17
|
+
/**
|
|
18
|
+
* Waits a specific number of ticks and then resolves
|
|
19
|
+
*/
|
|
20
|
+
export declare function waitTicks(ticks: number): Promise<void>;
|
|
21
|
+
/**
|
|
22
|
+
* Returns env variable, or default
|
|
23
|
+
* Throws if neither are defined
|
|
24
|
+
*/
|
|
25
|
+
export declare function env(name: string, defaultValue?: string): string;
|
|
26
|
+
/**
|
|
27
|
+
* Generate a random string from length provided (default 32)
|
|
28
|
+
*/
|
|
29
|
+
export declare function randomString(requestedLength?: number): string;
|
|
30
|
+
export declare function randomInt(min: number, max: number): number;
|
|
31
|
+
export declare function asleep(time_ms: number): Promise<void>;
|
|
32
|
+
export declare function promiseGenerator<T>(): {
|
|
33
|
+
promise: Promise<T>;
|
|
34
|
+
resolve: (value: T) => void;
|
|
35
|
+
reject: (error: any) => void;
|
|
36
|
+
};
|
|
37
|
+
export declare function internalLogger(nodeAlias: string | undefined, level: string, from: string, ...message: any[]): void;
|
|
38
|
+
export declare function objectToBuffer(input: any): Buffer;
|
|
39
|
+
export declare function debugPrintableObject(input: any): JSONSerializable;
|
|
40
|
+
interface Constructor<T> {
|
|
41
|
+
new (...args: any[]): T;
|
|
42
|
+
}
|
|
43
|
+
interface IsInstance<T> {
|
|
44
|
+
check(obj: any, strict?: boolean): obj is T;
|
|
45
|
+
}
|
|
46
|
+
export declare function checkableGenerator<P extends Constructor<T>, T = InstanceType<P>>(parent: P, defaultStrict?: boolean): IsInstance<T>['check'];
|
|
47
|
+
export type DeepMutable<T> = {
|
|
48
|
+
-readonly [P in keyof T]: DeepMutable<T[P]>;
|
|
49
|
+
};
|
|
50
|
+
interface WithIsInstance<Inst> extends Constructor<Inst> {
|
|
51
|
+
isInstance(arg: any): arg is Inst;
|
|
52
|
+
}
|
|
53
|
+
type EncodeFunc<Inst, Enc> = (a: Inst) => Enc;
|
|
54
|
+
type DecodeFunc<Inst, Enc> = (a: Enc) => Inst;
|
|
55
|
+
type CanBeArray<T> = T | T[];
|
|
56
|
+
export interface InstanceSet<Instance, Encoded = string> extends Set<Encoded> {
|
|
57
|
+
add(data: CanBeArray<Instance | Encoded>): this;
|
|
58
|
+
delete(data: Instance | Encoded): boolean;
|
|
59
|
+
has(data: Instance | Encoded): boolean;
|
|
60
|
+
decodedArray: Instance[];
|
|
61
|
+
encodedArray: Encoded[];
|
|
62
|
+
}
|
|
63
|
+
export interface InstanceSetConstructor<Instance, Encoded> {
|
|
64
|
+
new (data?: (Instance | Encoded)[]): InstanceSet<Instance, Encoded>;
|
|
65
|
+
}
|
|
66
|
+
export declare function setGenerator<P extends WithIsInstance<Instance>, E extends EncodeFunc<Instance, Encoded>, D extends DecodeFunc<Instance, Encoded>, Instance = InstanceType<P>, Encoded = ReturnType<E>>(parent: P, rawEncode: E, rawDecode: D): InstanceSetConstructor<Instance, Encoded>;
|
|
67
|
+
export {};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import Account from '../account';
|
|
2
|
+
import LocalNode from '../node/local';
|
|
3
|
+
import { VoteStaple } from '../vote';
|
|
4
|
+
import type { Block } from '../block';
|
|
5
|
+
export declare const testingNetworkId: bigint;
|
|
6
|
+
type NodeConfig = ConstructorParameters<typeof LocalNode>[0];
|
|
7
|
+
export declare function canListenOn(ip: string): Promise<boolean>;
|
|
8
|
+
export declare function findListenableIP(checkIPs: string[]): Promise<string | null>;
|
|
9
|
+
export declare function findListenableBindingForTest(options?: Pick<CreateTestNodeOptions, 'simulatedPhysicalNetwork'>): Promise<{
|
|
10
|
+
ip: string;
|
|
11
|
+
port: number;
|
|
12
|
+
}>;
|
|
13
|
+
export type CreateTestNodeOptions = {
|
|
14
|
+
name?: string;
|
|
15
|
+
peerNodes?: LocalNode[];
|
|
16
|
+
enableP2P?: boolean;
|
|
17
|
+
p2p?: Partial<NodeConfig['p2p']>;
|
|
18
|
+
ledger?: Partial<NodeConfig['ledger']>;
|
|
19
|
+
initialTrustedAccount?: Account;
|
|
20
|
+
createInitialVoteStaple?: boolean;
|
|
21
|
+
nodeConfig?: Partial<Omit<NodeConfig, 'p2p' | 'ledger' | 'initialTrustedAccount'>>;
|
|
22
|
+
simulatedPhysicalNetwork?: boolean;
|
|
23
|
+
};
|
|
24
|
+
export interface LocalNodeWithPrivateKey extends LocalNode {
|
|
25
|
+
config: NodeConfig & Required<Pick<NodeConfig, 'ledgerPrivateKey'>>;
|
|
26
|
+
}
|
|
27
|
+
export declare function createTestNode(account: Account, options?: CreateTestNodeOptions): Promise<LocalNodeWithPrivateKey>;
|
|
28
|
+
export declare function getVotesFromSingleNode(node: LocalNode, fromAccount: Account, toAccount: Account, headBlock: Block | null): Promise<VoteStaple>;
|
|
29
|
+
/**
|
|
30
|
+
* Run a command and get its output
|
|
31
|
+
*/
|
|
32
|
+
export declare function run(command: string, stdin: Buffer): {
|
|
33
|
+
output?: string;
|
|
34
|
+
ok: boolean;
|
|
35
|
+
};
|
|
36
|
+
declare let testMethod: (..._ignore_args: any[]) => any;
|
|
37
|
+
export { testMethod };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import Account from '../account';
|
|
2
|
+
import Block from '../block';
|
|
3
|
+
import type { VoteStaple } from '../vote';
|
|
4
|
+
interface BaseGenerationConfig {
|
|
5
|
+
network: bigint;
|
|
6
|
+
initialTrustedAccount: Account;
|
|
7
|
+
voteSerial?: bigint;
|
|
8
|
+
}
|
|
9
|
+
interface InitialConfigSupply extends BaseGenerationConfig {
|
|
10
|
+
addSupply: {
|
|
11
|
+
recipient: Account;
|
|
12
|
+
amount: bigint;
|
|
13
|
+
delegate: boolean;
|
|
14
|
+
delegateTo?: Account;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
type BlocksAlwaysReturn = {
|
|
18
|
+
networkAddress: Block;
|
|
19
|
+
baseToken: Block;
|
|
20
|
+
initialTrustedAccount: Block;
|
|
21
|
+
};
|
|
22
|
+
type BlocksWithAddSupply = BlocksAlwaysReturn & {
|
|
23
|
+
recipient: Block;
|
|
24
|
+
recipientSupply?: Block;
|
|
25
|
+
};
|
|
26
|
+
type InitialGenResponse<B extends BlocksAlwaysReturn> = {
|
|
27
|
+
voteStaple: VoteStaple;
|
|
28
|
+
blocks: B;
|
|
29
|
+
};
|
|
30
|
+
export declare function generateInitialVoteStaple(options: InitialConfigSupply): Promise<InitialGenResponse<BlocksWithAddSupply>>;
|
|
31
|
+
export declare function generateInitialVoteStaple(options: BaseGenerationConfig): Promise<InitialGenResponse<BlocksAlwaysReturn>>;
|
|
32
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { RedisClientType } from 'redis';
|
|
2
|
+
export { RedisClientType };
|
|
3
|
+
/**
|
|
4
|
+
* Single Redis Pool Client/Connection
|
|
5
|
+
*/
|
|
6
|
+
export declare class RedisClient {
|
|
7
|
+
#private;
|
|
8
|
+
constructor(host: string, password: string, port?: number);
|
|
9
|
+
destroy(): Promise<void>;
|
|
10
|
+
run<T>(code: (conn: RedisClientType) => Promise<T>): Promise<T>;
|
|
11
|
+
}
|
package/lib/vote.d.ts
ADDED
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
import { Block, BlockHash } from './block';
|
|
2
|
+
import type { BlockJSON, BlockJSONOutput } from './block';
|
|
3
|
+
import Account from './account';
|
|
4
|
+
import type { ASN1Date } from './utils/asn1';
|
|
5
|
+
import type { JSONSupported, ToJSONSerializableOptions } from './utils/conversion';
|
|
6
|
+
import BufferStorage from './utils/buffer';
|
|
7
|
+
/**
|
|
8
|
+
* Representation of the vote
|
|
9
|
+
*/
|
|
10
|
+
export interface VoteJSON {
|
|
11
|
+
issuer: string | Account;
|
|
12
|
+
serial: string | bigint;
|
|
13
|
+
blocks: string[] | BlockHash[];
|
|
14
|
+
validityFrom: string | Date;
|
|
15
|
+
validityTo: string | Date;
|
|
16
|
+
signature: string | ArrayBuffer;
|
|
17
|
+
}
|
|
18
|
+
export interface VoteJSONOutput extends JSONSupported<VoteJSON> {
|
|
19
|
+
$permanent: boolean;
|
|
20
|
+
$trusted: boolean;
|
|
21
|
+
$uid: string;
|
|
22
|
+
}
|
|
23
|
+
export interface VoteStapleJSON {
|
|
24
|
+
blocks: BlockJSON[] | BlockJSONOutput[];
|
|
25
|
+
votes: VoteJSON[] | VoteJSONOutput[];
|
|
26
|
+
}
|
|
27
|
+
declare class VoteHash extends BufferStorage {
|
|
28
|
+
static isInstance: (obj: any, strict?: boolean) => obj is VoteHash;
|
|
29
|
+
readonly storageKind = "VoteHash";
|
|
30
|
+
constructor(blockhash: ConstructorParameters<typeof BufferStorage>[0]);
|
|
31
|
+
}
|
|
32
|
+
type CertificateOID = {
|
|
33
|
+
type: 'oid';
|
|
34
|
+
oid: string;
|
|
35
|
+
};
|
|
36
|
+
type CertificateVersionInfo = {
|
|
37
|
+
type: 'context';
|
|
38
|
+
value: number;
|
|
39
|
+
kind: 'explicit';
|
|
40
|
+
contains: bigint;
|
|
41
|
+
};
|
|
42
|
+
type CertificateIssuerOrSubject = {
|
|
43
|
+
type: 'set';
|
|
44
|
+
name: CertificateOID;
|
|
45
|
+
value: {
|
|
46
|
+
type: 'string';
|
|
47
|
+
kind: 'utf8';
|
|
48
|
+
value: string;
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
type CertificateValidity = (ASN1Date | Date);
|
|
52
|
+
type CertificatePublicKeyInfo = [CertificateOID[], {
|
|
53
|
+
type: 'bitstring';
|
|
54
|
+
value: Buffer;
|
|
55
|
+
}];
|
|
56
|
+
type CertificateExtensions = {
|
|
57
|
+
type: 'context';
|
|
58
|
+
value: number;
|
|
59
|
+
kind: 'explicit';
|
|
60
|
+
contains: [
|
|
61
|
+
[
|
|
62
|
+
CertificateOID,
|
|
63
|
+
boolean,
|
|
64
|
+
Buffer
|
|
65
|
+
]
|
|
66
|
+
];
|
|
67
|
+
};
|
|
68
|
+
type CertificateSchema = [
|
|
69
|
+
version: CertificateVersionInfo,
|
|
70
|
+
serial: bigint,
|
|
71
|
+
signatureAlgo: CertificateOID[],
|
|
72
|
+
issuer: CertificateIssuerOrSubject[],
|
|
73
|
+
validity: [CertificateValidity, CertificateValidity],
|
|
74
|
+
subject: CertificateIssuerOrSubject[],
|
|
75
|
+
publicKey: CertificatePublicKeyInfo,
|
|
76
|
+
extensions: CertificateExtensions
|
|
77
|
+
];
|
|
78
|
+
/**
|
|
79
|
+
* Parse a set of distinguished names
|
|
80
|
+
*/
|
|
81
|
+
declare function findRDN(input: any[], findOID: string): any;
|
|
82
|
+
declare function blockHashesFromVote(input: Buffer): BlockHash[];
|
|
83
|
+
/**
|
|
84
|
+
* A map for VoteBlockHashes
|
|
85
|
+
*/
|
|
86
|
+
export declare class VoteBlockHashMap<ValueType = unknown> implements Map<VoteBlockHash, ValueType> {
|
|
87
|
+
#private;
|
|
88
|
+
constructor();
|
|
89
|
+
[Symbol.iterator](): IterableIterator<[VoteBlockHash, ValueType]>;
|
|
90
|
+
[Symbol.toStringTag]: string;
|
|
91
|
+
add(key: VoteBlockHash, value: ValueType): this;
|
|
92
|
+
delete(key: VoteBlockHash): boolean;
|
|
93
|
+
get(key: VoteBlockHash): ValueType | undefined;
|
|
94
|
+
forEach(callbackfn: (value: ValueType, key: VoteBlockHash, map: Map<VoteBlockHash, ValueType>) => void, thisArg?: any): void;
|
|
95
|
+
has(key: VoteBlockHash): boolean;
|
|
96
|
+
set(key: VoteBlockHash, value: ValueType): this;
|
|
97
|
+
get size(): number;
|
|
98
|
+
entries(): IterableIterator<[VoteBlockHash, ValueType]>;
|
|
99
|
+
keys(): IterableIterator<VoteBlockHash>;
|
|
100
|
+
values(): IterableIterator<ValueType>;
|
|
101
|
+
clear(): void;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* A VoteBlockHash is a hash of the blocks in a vote staple or vote staple
|
|
105
|
+
* it is a unique ID for the vote or vote staples contents regardless of which
|
|
106
|
+
* votes are included in the staple -- every vote in a vote staple has the same
|
|
107
|
+
* VoteBlockHash.
|
|
108
|
+
*/
|
|
109
|
+
export declare class VoteBlockHash extends BufferStorage {
|
|
110
|
+
static isInstance: (obj: any, strict?: boolean) => obj is VoteBlockHash;
|
|
111
|
+
static readonly Map: typeof VoteBlockHashMap;
|
|
112
|
+
readonly storageKind = "VoteBlockHash";
|
|
113
|
+
get hashFunctionName(): string;
|
|
114
|
+
static fromBlockHashes(blockHashes: BlockHash[]): VoteBlockHash;
|
|
115
|
+
static fromVote(vote: PossiblyExpiredVote | Vote): VoteBlockHash;
|
|
116
|
+
static fromVoteStaple(voteStaple: VoteStaple): VoteBlockHash;
|
|
117
|
+
constructor(stapleHash: ConstructorParameters<typeof BufferStorage>[0]);
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Options for Votes
|
|
121
|
+
*/
|
|
122
|
+
type VoteOptions = {
|
|
123
|
+
/**
|
|
124
|
+
* The instant at which a vote's expiration is validated against (default is moment of instantiation)
|
|
125
|
+
*/
|
|
126
|
+
now?: Date;
|
|
127
|
+
};
|
|
128
|
+
export declare class PossiblyExpiredVote {
|
|
129
|
+
#private;
|
|
130
|
+
readonly issuer: Account;
|
|
131
|
+
readonly serial: bigint;
|
|
132
|
+
readonly blocks: BlockHash[];
|
|
133
|
+
readonly validityFrom: Date;
|
|
134
|
+
readonly validityTo: Date;
|
|
135
|
+
readonly signature: ArrayBuffer;
|
|
136
|
+
readonly $trusted: boolean;
|
|
137
|
+
readonly $permanent: boolean;
|
|
138
|
+
readonly $uid: string;
|
|
139
|
+
protected static allowedSlop: number;
|
|
140
|
+
protected static permanentVoteThreshold: number;
|
|
141
|
+
static Staple: typeof VoteStaple;
|
|
142
|
+
static Builder: typeof VoteBuilder;
|
|
143
|
+
static readonly VoteBlocksHash: typeof VoteBlockHash;
|
|
144
|
+
static isInstance: (obj: any, strict?: boolean) => obj is PossiblyExpiredVote;
|
|
145
|
+
static isValidJSON(voteJSON: VoteJSON | VoteJSONOutput): voteJSON is VoteJSON | VoteJSONOutput;
|
|
146
|
+
static fromJSON(voteJSON: VoteJSON | VoteJSONOutput, options?: VoteOptions): PossiblyExpiredVote | Vote;
|
|
147
|
+
constructor(vote: Buffer | ArrayBuffer | PossiblyExpiredVote | Uint8Array | string | VoteJSON | VoteJSONOutput, options?: VoteOptions);
|
|
148
|
+
toBytes(): ArrayBuffer;
|
|
149
|
+
get hash(): VoteHash;
|
|
150
|
+
get blocksHash(): VoteBlockHash;
|
|
151
|
+
toString(): string;
|
|
152
|
+
toJSON(): VoteJSONOutput;
|
|
153
|
+
protected expirationCheckMoment(): number;
|
|
154
|
+
get expired(): boolean;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* A vote is a certificate issued indicating that the issuer "vouches" for the
|
|
158
|
+
* blocks specified will fit into the ledger of the operator/issuer.
|
|
159
|
+
*/
|
|
160
|
+
export declare class Vote extends PossiblyExpiredVote {
|
|
161
|
+
readonly possiblyExpired = false;
|
|
162
|
+
static isInstance: (obj: any, strict?: boolean) => obj is Vote;
|
|
163
|
+
constructor(vote: Buffer | ArrayBuffer | Vote | PossiblyExpiredVote | string | VoteJSON | VoteJSONOutput, options?: VoteOptions);
|
|
164
|
+
static toJSONSerializablePrefix: string;
|
|
165
|
+
static toJSONSerializable(value: Vote, opts: ToJSONSerializableOptions): {
|
|
166
|
+
[x: string]: any;
|
|
167
|
+
$permanent: boolean;
|
|
168
|
+
$trusted: boolean;
|
|
169
|
+
$uid: string;
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* A vote staple is a distributable block consisting of one or more blocks
|
|
174
|
+
* and one or more votes.
|
|
175
|
+
*/
|
|
176
|
+
declare class VoteStapleHash extends BufferStorage {
|
|
177
|
+
static isInstance: (obj: any, strict?: boolean) => obj is VoteStapleHash;
|
|
178
|
+
readonly storageKind = "VoteStapleHash";
|
|
179
|
+
get hashFunctionName(): string;
|
|
180
|
+
constructor(stapleHash: ConstructorParameters<typeof BufferStorage>[0]);
|
|
181
|
+
}
|
|
182
|
+
export declare class VoteStaple {
|
|
183
|
+
#private;
|
|
184
|
+
static readonly VoteBlockHash: typeof VoteBlockHash;
|
|
185
|
+
/**
|
|
186
|
+
* Construct a new staple from votes and blocks
|
|
187
|
+
*/
|
|
188
|
+
static fromVotesAndBlocks(votes: Vote[], blocks: Block[], voteOptions?: VoteOptions): VoteStaple;
|
|
189
|
+
/**
|
|
190
|
+
* Convert a list of Votes and Blocks into a VoteStaple
|
|
191
|
+
* This is slightly different from VoteStaple.fromVotesAndBlocks in
|
|
192
|
+
* that it will filter the supplied votes to only include those that
|
|
193
|
+
* are permanent if any permanent votes are present, otherwise only
|
|
194
|
+
* temporary votes will be included
|
|
195
|
+
*
|
|
196
|
+
* Additionally, it will filter out any votes that are expired
|
|
197
|
+
*/
|
|
198
|
+
static fromVotesAndBlocksWithFiltering(votes: PossiblyExpiredVote[], blocks: Block[], opts: Parameters<typeof VoteStaple['fromVotesAndBlocks']>[2]): VoteStaple | null;
|
|
199
|
+
static fromVotesAndBlocksToHashMap(votes: PossiblyExpiredVote[], blocks: Block[], opts: Parameters<typeof VoteStaple['fromVotesAndBlocks']>[2] & {
|
|
200
|
+
voteBlockHashes?: VoteBlockHash[];
|
|
201
|
+
}): VoteBlockHashMap<VoteStaple | null>;
|
|
202
|
+
static isValidJSON(staple: VoteStapleJSON): boolean;
|
|
203
|
+
static fromJSON(staple: VoteStapleJSON, voteOptions?: VoteOptions): VoteStaple;
|
|
204
|
+
static isInstance: (obj: any, strict?: boolean) => obj is VoteStaple;
|
|
205
|
+
/**
|
|
206
|
+
* Construct a new staple from a message buffer
|
|
207
|
+
*/
|
|
208
|
+
constructor(votesStapled: ArrayBuffer | Buffer | VoteStapleJSON | string, voteOptions?: VoteOptions);
|
|
209
|
+
/**
|
|
210
|
+
* Get the serialized version
|
|
211
|
+
*/
|
|
212
|
+
toBytes(uncompressed?: boolean): ArrayBuffer;
|
|
213
|
+
toString(): string;
|
|
214
|
+
/**
|
|
215
|
+
* Get the serialized version as JSON
|
|
216
|
+
*/
|
|
217
|
+
toJSON(): {
|
|
218
|
+
votes: VoteJSONOutput[];
|
|
219
|
+
blocks: BlockJSONOutput[];
|
|
220
|
+
};
|
|
221
|
+
/**
|
|
222
|
+
* Hash of the Vote Staple -- this is the hash of the data in the
|
|
223
|
+
* canonical form of the staple, which may be different from
|
|
224
|
+
* the hash of the data passed into the this object.
|
|
225
|
+
*/
|
|
226
|
+
get hash(): VoteStapleHash;
|
|
227
|
+
/**
|
|
228
|
+
* Get the hash of the blockhashes in the staple -- this is a stable ID
|
|
229
|
+
* for the staple regardless of which votes are included in the staple.
|
|
230
|
+
*/
|
|
231
|
+
get blocksHash(): VoteBlockHash;
|
|
232
|
+
/**
|
|
233
|
+
* Get the votes for this staple
|
|
234
|
+
*/
|
|
235
|
+
get votes(): Vote[];
|
|
236
|
+
/**
|
|
237
|
+
* Get the blocks for this staple
|
|
238
|
+
*/
|
|
239
|
+
get blocks(): Block[];
|
|
240
|
+
/**
|
|
241
|
+
* Get the timestamp of the staple
|
|
242
|
+
*
|
|
243
|
+
* This is the average of the timestamps of the votes, unless a
|
|
244
|
+
* particular account is specified then that timestamp is used
|
|
245
|
+
* if it issued a vote in the staple.
|
|
246
|
+
*/
|
|
247
|
+
timestamp(preferRep?: Account): Date;
|
|
248
|
+
static toJSONSerializablePrefix: string;
|
|
249
|
+
static toJSONSerializable(value: VoteStaple, opts: ToJSONSerializableOptions): {
|
|
250
|
+
votes: VoteJSONOutput[];
|
|
251
|
+
blocks: BlockJSONOutput[];
|
|
252
|
+
$binary?: string;
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
export declare class VoteBuilder {
|
|
256
|
+
#private;
|
|
257
|
+
static isInstance: (obj: any, strict?: boolean) => obj is VoteBuilder;
|
|
258
|
+
constructor(account: Account, blocks?: (Block | BlockHash)[]);
|
|
259
|
+
addBlocks(blocks: (Block | BlockHash | string)[]): void;
|
|
260
|
+
addBlock(block: Block | BlockHash | string): void;
|
|
261
|
+
generateVoteData(serial: bigint, validTo: Date, validFrom: Date): {
|
|
262
|
+
voteData: ArrayBuffer;
|
|
263
|
+
tbsCertificate: CertificateSchema;
|
|
264
|
+
signatureInfo: CertificateOID[];
|
|
265
|
+
};
|
|
266
|
+
createVote(voteData: ArrayBuffer, tbsCertificate: CertificateSchema, signatureInfo: CertificateOID[], signature: BufferStorage, voteOptions?: VoteOptions): Vote;
|
|
267
|
+
seal(serial: bigint, validTo: Date | null, validFrom?: Date, voteOptions?: VoteOptions): Promise<Vote>;
|
|
268
|
+
}
|
|
269
|
+
export default Vote;
|
|
270
|
+
export declare const Testing: {
|
|
271
|
+
findRDN: typeof findRDN;
|
|
272
|
+
blockHashesFromVote: typeof blockHashesFromVote;
|
|
273
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@keetanetwork/keetanet-client",
|
|
3
|
+
"repository": "https://github.com/keetanetwork/node.git",
|
|
4
|
+
"version": "0.10.2",
|
|
5
|
+
"description": "KeetaNet Client TypeScript Reference Implementation",
|
|
6
|
+
"files": [
|
|
7
|
+
"**/*.js",
|
|
8
|
+
"**/*.d.ts"
|
|
9
|
+
],
|
|
10
|
+
"types": "./client/index.d.ts",
|
|
11
|
+
"author": "Keeta Token Genesis LLC",
|
|
12
|
+
"license": "see LICENSE",
|
|
13
|
+
"devDependencies": {
|
|
14
|
+
"@noble/curves": "1.6.0",
|
|
15
|
+
"@safeheron/crypto-ecies": "1.0.0",
|
|
16
|
+
"asn1js": "2.4.0",
|
|
17
|
+
"ecies-25519": "1.3.1",
|
|
18
|
+
"ecies-geth": "1.7.3",
|
|
19
|
+
"elliptic": "6.6.0",
|
|
20
|
+
"futoin-hkdf": "1.5.3",
|
|
21
|
+
"isomorphic-ws": "5.0.0",
|
|
22
|
+
"node-fetch": "2.7.0",
|
|
23
|
+
"rfc4648": "1.5.4",
|
|
24
|
+
"uuid": "11.0.3",
|
|
25
|
+
"ws": "8.18.0"
|
|
26
|
+
},
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"secp256k1": "5.0.1"
|
|
29
|
+
},
|
|
30
|
+
"optionalDependencies": {
|
|
31
|
+
"@keetanetwork/asn1-napi-rs": "1.1.9"
|
|
32
|
+
},
|
|
33
|
+
"browser": "./client/index-browser.js",
|
|
34
|
+
"main": "./client/index.js"
|
|
35
|
+
}
|
package/version.d.ts
ADDED