@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,205 @@
|
|
|
1
|
+
import * as asn1js from 'asn1js';
|
|
2
|
+
export declare const asn1: typeof asn1js;
|
|
3
|
+
declare function jsBigIntToBuffer(value: bigint): Buffer;
|
|
4
|
+
declare function jsIntegerToBigInt(value: asn1js.Integer | number): bigint;
|
|
5
|
+
export type ASN1AnyJS = ASN1AnyJS[] | bigint | number | Date | Buffer | ASN1OID | ASN1Set | ASN1ContextTag | ASN1BitString | ASN1Date | ASN1String | string | boolean | null | undefined;
|
|
6
|
+
type ASN1AnyASN = InstanceType<typeof asn1js.Sequence> | InstanceType<typeof asn1js.Set> | InstanceType<typeof asn1js.Integer> | InstanceType<typeof asn1js.GeneralizedTime> | InstanceType<typeof asn1js.Null> | InstanceType<typeof asn1js.OctetString> | InstanceType<typeof asn1js.BitString> | InstanceType<typeof asn1js.ObjectIdentifier> | InstanceType<typeof asn1js.Constructed> | InstanceType<typeof asn1js.Boolean> | InstanceType<typeof asn1js.PrintableString> | InstanceType<typeof asn1js.IA5String> | InstanceType<typeof asn1js.Utf8String> | undefined;
|
|
7
|
+
interface ASN1Object {
|
|
8
|
+
type: string;
|
|
9
|
+
}
|
|
10
|
+
export interface ASN1OID extends ASN1Object {
|
|
11
|
+
type: 'oid';
|
|
12
|
+
oid: string;
|
|
13
|
+
}
|
|
14
|
+
export interface ASN1Set extends ASN1Object {
|
|
15
|
+
type: 'set';
|
|
16
|
+
name: ASN1OID;
|
|
17
|
+
value: string | ASN1String;
|
|
18
|
+
}
|
|
19
|
+
interface ASN1ExplicitContextTag extends ASN1Object {
|
|
20
|
+
type: 'context';
|
|
21
|
+
kind: 'explicit';
|
|
22
|
+
value: number;
|
|
23
|
+
contains: ASN1AnyJS;
|
|
24
|
+
}
|
|
25
|
+
interface ASN1ImplicitContextTag extends ASN1Object {
|
|
26
|
+
type: 'context';
|
|
27
|
+
kind: 'implicit';
|
|
28
|
+
value: number;
|
|
29
|
+
contains: ArrayBuffer | ASN1AnyJS;
|
|
30
|
+
}
|
|
31
|
+
export type ASN1ContextTag = ASN1ExplicitContextTag | ASN1ImplicitContextTag;
|
|
32
|
+
export interface ASN1BitString extends ASN1Object {
|
|
33
|
+
type: 'bitstring';
|
|
34
|
+
value: Buffer;
|
|
35
|
+
unusedBits?: number;
|
|
36
|
+
}
|
|
37
|
+
export interface ASN1Date extends ASN1Object {
|
|
38
|
+
type: 'date';
|
|
39
|
+
kind?: 'utc' | 'general' | 'default';
|
|
40
|
+
date: Date;
|
|
41
|
+
}
|
|
42
|
+
export interface ASN1String extends ASN1Object {
|
|
43
|
+
type: 'string';
|
|
44
|
+
kind: 'printable' | 'ia5' | 'utf8';
|
|
45
|
+
value: string;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Validation function for {@link isValidSequenceSchema}
|
|
49
|
+
*/
|
|
50
|
+
export type ASN1SequenceValidation = ((arg: unknown) => boolean)[];
|
|
51
|
+
/**
|
|
52
|
+
* Checks if an ASN.1 sequence is valid based on a provided validation schema.
|
|
53
|
+
*/
|
|
54
|
+
export declare function isValidSequenceSchema(input: unknown[], schema: ASN1SequenceValidation): boolean;
|
|
55
|
+
declare function jsJStoASN1(input: Readonly<ASN1AnyJS>): Exclude<ASN1AnyASN, undefined>;
|
|
56
|
+
declare function jsJStoASN1(input: Readonly<ASN1AnyJS>, allowUndefined: true): ASN1AnyASN;
|
|
57
|
+
declare function jsASN1toJS(input: ArrayBuffer): ASN1AnyJS;
|
|
58
|
+
declare const ASN1toJS: typeof jsASN1toJS, JStoASN1: typeof jsJStoASN1, ASN1IntegerToBigInt: typeof jsIntegerToBigInt, ASN1BigIntToBuffer: typeof jsBigIntToBuffer;
|
|
59
|
+
export declare namespace ValidateASN1 {
|
|
60
|
+
export type Schema = keyof BasicSchemaMap | {
|
|
61
|
+
choice: Schema[];
|
|
62
|
+
} | {
|
|
63
|
+
sequenceOf: Schema;
|
|
64
|
+
} | {
|
|
65
|
+
optional: Schema;
|
|
66
|
+
} | {
|
|
67
|
+
type: 'context';
|
|
68
|
+
kind: 'implicit' | 'explicit';
|
|
69
|
+
contains: Schema;
|
|
70
|
+
value: number;
|
|
71
|
+
} | {
|
|
72
|
+
type: 'oid';
|
|
73
|
+
oid: string;
|
|
74
|
+
} | {
|
|
75
|
+
type: 'string';
|
|
76
|
+
kind: 'printable';
|
|
77
|
+
} | {
|
|
78
|
+
type: 'string';
|
|
79
|
+
kind: 'ia5';
|
|
80
|
+
} | {
|
|
81
|
+
type: 'string';
|
|
82
|
+
kind: 'utf8';
|
|
83
|
+
} | {
|
|
84
|
+
type: 'date';
|
|
85
|
+
kind: 'utc';
|
|
86
|
+
} | {
|
|
87
|
+
type: 'date';
|
|
88
|
+
kind: 'general';
|
|
89
|
+
} | readonly [Schema, ...Schema[]];
|
|
90
|
+
type BasicSchemaMap = {
|
|
91
|
+
[ValidateASN1.IsAny]: ASN1AnyJS;
|
|
92
|
+
[ValidateASN1.IsUnknown]: unknown;
|
|
93
|
+
[ValidateASN1.IsDate]: Date;
|
|
94
|
+
[ValidateASN1.IsAnyDate]: ASN1Date;
|
|
95
|
+
[ValidateASN1.IsString]: string;
|
|
96
|
+
[ValidateASN1.IsAnyString]: ASN1String;
|
|
97
|
+
[ValidateASN1.IsOctetString]: Buffer;
|
|
98
|
+
[ValidateASN1.IsBitString]: ASN1BitString;
|
|
99
|
+
[ValidateASN1.IsInteger]: bigint;
|
|
100
|
+
[ValidateASN1.IsBoolean]: boolean;
|
|
101
|
+
[ValidateASN1.IsOID]: ASN1OID;
|
|
102
|
+
[ValidateASN1.IsSet]: ASN1Set;
|
|
103
|
+
[ValidateASN1.IsNull]: null;
|
|
104
|
+
};
|
|
105
|
+
export type SchemaMap<T extends Schema> = T extends keyof BasicSchemaMap ? BasicSchemaMap[T] : T extends {
|
|
106
|
+
choice: Schema[];
|
|
107
|
+
} ? SchemaMap<T['choice'][number]> : T extends {
|
|
108
|
+
choice: readonly Schema[];
|
|
109
|
+
} ? SchemaMap<T['choice'][number]> : T extends {
|
|
110
|
+
sequenceOf: Schema;
|
|
111
|
+
} ? SchemaMap<T['sequenceOf']>[] : T extends {
|
|
112
|
+
optional: Schema;
|
|
113
|
+
} ? SchemaMap<T['optional']> | undefined : T extends {
|
|
114
|
+
type: 'context';
|
|
115
|
+
kind: infer U extends 'implicit' | 'explicit';
|
|
116
|
+
value: number;
|
|
117
|
+
contains: Schema;
|
|
118
|
+
} ? Omit<ASN1ContextTag, 'contains' | 'value' | 'kind'> & {
|
|
119
|
+
contains: SchemaMap<T['contains']>;
|
|
120
|
+
value: T['value'];
|
|
121
|
+
kind: U;
|
|
122
|
+
} : T extends {
|
|
123
|
+
type: 'oid';
|
|
124
|
+
oid: string;
|
|
125
|
+
} ? Omit<ASN1OID, 'oid'> & {
|
|
126
|
+
oid: T['oid'];
|
|
127
|
+
} : T extends {
|
|
128
|
+
type: 'string';
|
|
129
|
+
kind: 'printable' | 'ia5' | 'utf8';
|
|
130
|
+
} ? Omit<ASN1String, 'kind'> & {
|
|
131
|
+
kind: T['kind'];
|
|
132
|
+
} : T extends {
|
|
133
|
+
type: 'date';
|
|
134
|
+
kind: 'general' | 'utc';
|
|
135
|
+
} ? Omit<ASN1Date, 'kind'> & {
|
|
136
|
+
kind: T['kind'];
|
|
137
|
+
} : T extends readonly [Schema, ...Schema[]] ? {
|
|
138
|
+
[K in keyof T]: T[K] extends Schema ? SchemaMap<T[K]> : never;
|
|
139
|
+
} : never;
|
|
140
|
+
export {};
|
|
141
|
+
}
|
|
142
|
+
export declare class ValidateASN1<T extends ValidateASN1.Schema> {
|
|
143
|
+
#private;
|
|
144
|
+
static readonly IsAny: unique symbol;
|
|
145
|
+
static readonly IsUnknown: unique symbol;
|
|
146
|
+
static readonly IsDate: unique symbol;
|
|
147
|
+
static readonly IsAnyDate: unique symbol;
|
|
148
|
+
static readonly IsString: unique symbol;
|
|
149
|
+
static readonly IsAnyString: unique symbol;
|
|
150
|
+
static readonly IsOctetString: unique symbol;
|
|
151
|
+
static readonly IsBitString: unique symbol;
|
|
152
|
+
static readonly IsInteger: unique symbol;
|
|
153
|
+
static readonly IsBoolean: unique symbol;
|
|
154
|
+
static readonly IsOID: unique symbol;
|
|
155
|
+
static readonly IsSet: unique symbol;
|
|
156
|
+
static readonly IsNull: unique symbol;
|
|
157
|
+
/**
|
|
158
|
+
* Interpret an untagged type as a specific universal tag
|
|
159
|
+
*/
|
|
160
|
+
private static interpretASN1Tag;
|
|
161
|
+
/**
|
|
162
|
+
* Given a schema, validate the ASN.1 object against it and return the
|
|
163
|
+
* object as the validated type
|
|
164
|
+
*/
|
|
165
|
+
static againstSchema<T extends ValidateASN1.Schema>(input: ASN1AnyJS, schema: T): ValidateASN1.SchemaMap<T>;
|
|
166
|
+
constructor(schema: T);
|
|
167
|
+
validate(input: ASN1AnyJS): ValidateASN1.SchemaMap<T>;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Create a Mutable type from a given Readonly type
|
|
171
|
+
*
|
|
172
|
+
* Does not handle all possible objects, but those used
|
|
173
|
+
* within the ASN1 encoder/decoder
|
|
174
|
+
*/
|
|
175
|
+
type Mutable<T> = T extends Buffer | ArrayBuffer | Date ? T : T extends object ? {
|
|
176
|
+
-readonly [K in keyof T]: Mutable<T[K]>;
|
|
177
|
+
} : T;
|
|
178
|
+
/**
|
|
179
|
+
* An ASN.1 object which contains the DER encoded value as well as the
|
|
180
|
+
* unencoded value
|
|
181
|
+
*/
|
|
182
|
+
export declare class BufferStorageASN1<T extends ASN1AnyJS | Readonly<ASN1AnyJS> = Readonly<ASN1AnyJS>, S extends ValidateASN1.Schema | undefined = undefined> {
|
|
183
|
+
#private;
|
|
184
|
+
static readonly Validate: typeof ValidateASN1;
|
|
185
|
+
static readonly isInstance: (obj: any, strict?: boolean) => obj is BufferStorageASN1<string | number | bigint | boolean | Buffer | ASN1AnyJS[] | Date | ASN1OID | ASN1Set | ASN1ExplicitContextTag | ASN1ImplicitContextTag | ASN1BitString | ASN1Date | ASN1String | readonly ASN1AnyJS[] | Readonly<Buffer> | Readonly<Date> | Readonly<ASN1OID> | Readonly<ASN1Set> | Readonly<ASN1ExplicitContextTag> | Readonly<ASN1ImplicitContextTag> | Readonly<ASN1BitString> | Readonly<ASN1Date> | Readonly<ASN1String> | null | undefined, ValidateASN1.Schema | undefined>;
|
|
186
|
+
constructor(input: T | ArrayBuffer, schema?: S);
|
|
187
|
+
getDER(): ArrayBuffer;
|
|
188
|
+
getDERBuffer(): Buffer;
|
|
189
|
+
getASN1(): S extends undefined ? Mutable<T> : Mutable<ValidateASN1.SchemaMap<Exclude<S, undefined>>>;
|
|
190
|
+
}
|
|
191
|
+
export { ASN1toJS, JStoASN1, ASN1IntegerToBigInt, ASN1BigIntToBuffer };
|
|
192
|
+
export declare const _Testing: {
|
|
193
|
+
native: {
|
|
194
|
+
ASN1toJS: typeof jsASN1toJS;
|
|
195
|
+
JStoASN1: typeof jsJStoASN1;
|
|
196
|
+
ASN1BigIntToBuffer: typeof jsBigIntToBuffer;
|
|
197
|
+
ASN1IntegerToBigInt: typeof jsIntegerToBigInt;
|
|
198
|
+
} | undefined;
|
|
199
|
+
js: {
|
|
200
|
+
ASN1toJS: typeof jsASN1toJS;
|
|
201
|
+
JStoASN1: typeof jsJStoASN1;
|
|
202
|
+
ASN1BigIntToBuffer: typeof jsBigIntToBuffer;
|
|
203
|
+
ASN1IntegerToBigInt: typeof jsIntegerToBigInt;
|
|
204
|
+
};
|
|
205
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Class to store a BitField
|
|
3
|
+
* Simple array of 0/1 values
|
|
4
|
+
*/
|
|
5
|
+
export default class BitField {
|
|
6
|
+
#private;
|
|
7
|
+
static isInstance: (obj: any, strict?: boolean) => obj is BitField;
|
|
8
|
+
constructor(data?: BitField | bigint | number[]);
|
|
9
|
+
set(offset: number | bigint, value: boolean | 0 | 1): void;
|
|
10
|
+
get size(): number;
|
|
11
|
+
get(offset: number | bigint): boolean;
|
|
12
|
+
get bigint(): bigint;
|
|
13
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { BloomFilter } from 'bloom-filters';
|
|
2
|
+
export { BloomFilter };
|
|
3
|
+
export declare function serializeBloomFilter(filter: BloomFilter): string;
|
|
4
|
+
export declare function serializeBloomFilter(filter: undefined): undefined;
|
|
5
|
+
export declare function serializeBloomFilter(filter: BloomFilter | undefined): string | undefined;
|
|
6
|
+
export declare function deserializeBloomFilter(input: string): BloomFilter;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import zlib from 'zlib';
|
|
2
|
+
/**
|
|
3
|
+
* RFC 4648 Base32 Decoder
|
|
4
|
+
*/
|
|
5
|
+
export declare function DecodeBase32(data: string, length: number): ArrayBuffer;
|
|
6
|
+
/**
|
|
7
|
+
* RFC 4648 Base32 Encoder
|
|
8
|
+
*/
|
|
9
|
+
export declare function EncodeBase32(data: ArrayBuffer): string;
|
|
10
|
+
export declare function DecodeBase64(data: string): ArrayBuffer;
|
|
11
|
+
export declare function EncodeBase64(data: ArrayBuffer): string;
|
|
12
|
+
export declare function ZlibInflate(data: ArrayBuffer, options?: zlib.ZlibOptions): ArrayBuffer;
|
|
13
|
+
export declare function ZlibDeflate(data: ArrayBuffer, options?: zlib.ZlibOptions): ArrayBuffer;
|
|
14
|
+
export declare class BufferStorage {
|
|
15
|
+
#private;
|
|
16
|
+
readonly storageKind: string;
|
|
17
|
+
static isInstance: (obj: any, strict?: boolean) => obj is BufferStorage;
|
|
18
|
+
constructor(key: bigint | ArrayBuffer | string, length: number);
|
|
19
|
+
get(): ArrayBuffer;
|
|
20
|
+
get length(): number;
|
|
21
|
+
getBuffer(): Buffer;
|
|
22
|
+
toString(encoding?: 'hex' | 'base32' | 'base64'): string;
|
|
23
|
+
toBigInt(): bigint;
|
|
24
|
+
compare(compareWith: typeof this | undefined | null): boolean;
|
|
25
|
+
compareHexString(compareWith: BufferStorage | string | undefined | null): boolean;
|
|
26
|
+
}
|
|
27
|
+
export default BufferStorage;
|
|
@@ -0,0 +1,340 @@
|
|
|
1
|
+
import * as ASN1 from './asn1';
|
|
2
|
+
import Account from '../account';
|
|
3
|
+
import * as HashLib from './hash';
|
|
4
|
+
/**
|
|
5
|
+
* De-normalized mapped Certificate Schema, for use in type annotations since
|
|
6
|
+
* we do not want to expose such a complex type
|
|
7
|
+
*/
|
|
8
|
+
type CertificateSchema = [
|
|
9
|
+
tbsCertificate: [
|
|
10
|
+
version: {
|
|
11
|
+
type: 'context';
|
|
12
|
+
value: 0;
|
|
13
|
+
kind: 'explicit';
|
|
14
|
+
contains: bigint;
|
|
15
|
+
},
|
|
16
|
+
serialNumber: bigint,
|
|
17
|
+
signatureAlgorithm: ASN1.ASN1OID[],
|
|
18
|
+
issuer: ASN1.ASN1Set[],
|
|
19
|
+
validityPeriod: [
|
|
20
|
+
notBefore: ASN1.ASN1Date,
|
|
21
|
+
notAfter: ASN1.ASN1Date
|
|
22
|
+
],
|
|
23
|
+
subject: ASN1.ASN1Set[],
|
|
24
|
+
subjectPublicKey: [
|
|
25
|
+
algorithm: ASN1.ASN1OID[],
|
|
26
|
+
publicKey: ASN1.ASN1BitString
|
|
27
|
+
],
|
|
28
|
+
extensions: {
|
|
29
|
+
type: 'context';
|
|
30
|
+
value: 3;
|
|
31
|
+
kind: 'explicit';
|
|
32
|
+
contains: ([
|
|
33
|
+
id: ASN1.ASN1OID,
|
|
34
|
+
critical: boolean,
|
|
35
|
+
value: Buffer
|
|
36
|
+
] | [
|
|
37
|
+
id: ASN1.ASN1OID,
|
|
38
|
+
value: Buffer
|
|
39
|
+
])[];
|
|
40
|
+
} | undefined
|
|
41
|
+
],
|
|
42
|
+
signatureAlgorithm: ASN1.ASN1OID[],
|
|
43
|
+
signature: ASN1.ASN1BitString
|
|
44
|
+
];
|
|
45
|
+
type CertificateBuilderParams = {
|
|
46
|
+
/**
|
|
47
|
+
* Subject for the certificate, to store as the public key within the certificate
|
|
48
|
+
*/
|
|
49
|
+
subjectPublicKey: Account;
|
|
50
|
+
/**
|
|
51
|
+
* Subject Distinguished Name (DN) for the certificate
|
|
52
|
+
*/
|
|
53
|
+
subjectDN?: {
|
|
54
|
+
name: string;
|
|
55
|
+
value: string;
|
|
56
|
+
}[];
|
|
57
|
+
/**
|
|
58
|
+
* Issuer for the certificate, to sign the certificate with
|
|
59
|
+
*/
|
|
60
|
+
issuer: Account;
|
|
61
|
+
/**
|
|
62
|
+
* Issuer Distinguished Name (DN) for the certificate
|
|
63
|
+
*/
|
|
64
|
+
issuerDN?: {
|
|
65
|
+
name: string;
|
|
66
|
+
value: string;
|
|
67
|
+
}[];
|
|
68
|
+
/**
|
|
69
|
+
* Validity period of the certificate to begin on
|
|
70
|
+
*/
|
|
71
|
+
validFrom: Date;
|
|
72
|
+
/**
|
|
73
|
+
* Validity period of the certificate to end (expire) on
|
|
74
|
+
*/
|
|
75
|
+
validTo: Date;
|
|
76
|
+
/**
|
|
77
|
+
* Serial number for the certificate
|
|
78
|
+
*/
|
|
79
|
+
serial: bigint | number;
|
|
80
|
+
/**
|
|
81
|
+
* Is a certificate authority ?
|
|
82
|
+
*
|
|
83
|
+
* Default is true if the Subject === Issuer and false otherwise
|
|
84
|
+
*/
|
|
85
|
+
isCA?: boolean;
|
|
86
|
+
/**
|
|
87
|
+
* Include common/default certificate extensions ?
|
|
88
|
+
*
|
|
89
|
+
* Default is true
|
|
90
|
+
*/
|
|
91
|
+
includeCommonExts?: boolean;
|
|
92
|
+
/**
|
|
93
|
+
* Hashing library to use
|
|
94
|
+
*/
|
|
95
|
+
hashLib: {
|
|
96
|
+
hash: (...args: Parameters<typeof HashLib.Hash>) => ReturnType<typeof HashLib.Hash>;
|
|
97
|
+
name: string;
|
|
98
|
+
};
|
|
99
|
+
};
|
|
100
|
+
export declare class CertificateBuilder {
|
|
101
|
+
#private;
|
|
102
|
+
constructor(params?: Partial<CertificateBuilderParams>);
|
|
103
|
+
/**
|
|
104
|
+
* Construct an extension
|
|
105
|
+
*/
|
|
106
|
+
protected static extension(oid: string, value: Parameters<typeof ASN1.JStoASN1>[0], critical?: boolean): [{
|
|
107
|
+
type: "oid";
|
|
108
|
+
oid: string;
|
|
109
|
+
}, value: Buffer] | [{
|
|
110
|
+
type: "oid";
|
|
111
|
+
oid: string;
|
|
112
|
+
}, critical: boolean, value: Buffer];
|
|
113
|
+
/**
|
|
114
|
+
* Convert a KeetaNet Account to a Key ID (for Subject Key Identifier)
|
|
115
|
+
*/
|
|
116
|
+
private accountToKeyId;
|
|
117
|
+
/**
|
|
118
|
+
* Produce the extensions to include in this certificate
|
|
119
|
+
*/
|
|
120
|
+
protected addExtensions(params: CertificateBuilderParams): Promise<([{
|
|
121
|
+
type: "oid";
|
|
122
|
+
oid: string;
|
|
123
|
+
}, value: Buffer] | [{
|
|
124
|
+
type: "oid";
|
|
125
|
+
oid: string;
|
|
126
|
+
}, critical: boolean, value: Buffer])[]>;
|
|
127
|
+
/**
|
|
128
|
+
* Compute the final params as required
|
|
129
|
+
*/
|
|
130
|
+
private getFinalParams;
|
|
131
|
+
/**
|
|
132
|
+
* Create a certificate
|
|
133
|
+
*/
|
|
134
|
+
buildDER(params?: Partial<CertificateBuilderParams>): Promise<ArrayBuffer>;
|
|
135
|
+
build(params?: Partial<CertificateBuilderParams>): Promise<Certificate>;
|
|
136
|
+
}
|
|
137
|
+
type CertificateOptions = {
|
|
138
|
+
/**
|
|
139
|
+
* The moment at which the certificate is being validated, or null if the
|
|
140
|
+
* moment is indeterminate and unknowable -- in which case the certificate
|
|
141
|
+
* validity period is not checked
|
|
142
|
+
*/
|
|
143
|
+
moment?: Date | null;
|
|
144
|
+
/**
|
|
145
|
+
* Certificate store to use for verifying the certificate
|
|
146
|
+
*/
|
|
147
|
+
store?: {
|
|
148
|
+
/**
|
|
149
|
+
* Root certificates
|
|
150
|
+
*/
|
|
151
|
+
root?: Set<Certificate>;
|
|
152
|
+
/**
|
|
153
|
+
* Intermediate certificates
|
|
154
|
+
*/
|
|
155
|
+
intermediate?: Set<Certificate>;
|
|
156
|
+
};
|
|
157
|
+
/**
|
|
158
|
+
* Indicate this certificate is a root certificate that we trust --
|
|
159
|
+
* it will get a "chain" parameter even if no "store" is provided
|
|
160
|
+
* or if it is not in the store. This is because otherwise we would
|
|
161
|
+
* need to load trusted certificates twice, once for the store and
|
|
162
|
+
* once for the chain.
|
|
163
|
+
*/
|
|
164
|
+
isTrustedRoot?: boolean;
|
|
165
|
+
};
|
|
166
|
+
export declare class Certificate {
|
|
167
|
+
#private;
|
|
168
|
+
/**
|
|
169
|
+
* The Certificate Builder
|
|
170
|
+
*/
|
|
171
|
+
static readonly Builder: typeof CertificateBuilder;
|
|
172
|
+
/**
|
|
173
|
+
* The serial number of the certificate
|
|
174
|
+
*/
|
|
175
|
+
readonly serial: bigint;
|
|
176
|
+
/**
|
|
177
|
+
* The timestamp at which the certificate becomes valid
|
|
178
|
+
*/
|
|
179
|
+
readonly notBefore: Date;
|
|
180
|
+
/**
|
|
181
|
+
* The timestamp at which the certificate expires
|
|
182
|
+
*/
|
|
183
|
+
readonly notAfter: Date;
|
|
184
|
+
/**
|
|
185
|
+
* The Subject DN of the certificate as a string --- for informational purposes only
|
|
186
|
+
*/
|
|
187
|
+
readonly subject: string;
|
|
188
|
+
/**
|
|
189
|
+
* The Issuer DN of the certificate as a string --- for informational purposes only
|
|
190
|
+
*/
|
|
191
|
+
readonly issuer: string;
|
|
192
|
+
/**
|
|
193
|
+
* The Subject of the certificate as a KeetaNet Account, derived from the
|
|
194
|
+
* public key in the certificate
|
|
195
|
+
*/
|
|
196
|
+
readonly subjectPublicKey: Account;
|
|
197
|
+
/**
|
|
198
|
+
* The moment at which the certificate was validated
|
|
199
|
+
*/
|
|
200
|
+
readonly moment: Date | null;
|
|
201
|
+
/**
|
|
202
|
+
* Chain, if a store is provided
|
|
203
|
+
*/
|
|
204
|
+
readonly chain?: Certificate[];
|
|
205
|
+
/**
|
|
206
|
+
* Basic Extensions
|
|
207
|
+
*/
|
|
208
|
+
readonly baseExtensions?: {
|
|
209
|
+
/**
|
|
210
|
+
* Basic Constraints
|
|
211
|
+
*/
|
|
212
|
+
basicConstraints?: [
|
|
213
|
+
ca: boolean,
|
|
214
|
+
pathLenConstraint?: bigint
|
|
215
|
+
];
|
|
216
|
+
/**
|
|
217
|
+
* Subject Key Identifier
|
|
218
|
+
*/
|
|
219
|
+
subjectKeyIdentifier?: Buffer;
|
|
220
|
+
/**
|
|
221
|
+
* Authority Key Identifier
|
|
222
|
+
*/
|
|
223
|
+
authorityKeyIdentifier?: {
|
|
224
|
+
type: 'context';
|
|
225
|
+
value: 0;
|
|
226
|
+
contains: Buffer;
|
|
227
|
+
};
|
|
228
|
+
};
|
|
229
|
+
/**
|
|
230
|
+
* The complete SubjectDN
|
|
231
|
+
*/
|
|
232
|
+
protected subjectDN: CertificateSchema[0][5];
|
|
233
|
+
/**
|
|
234
|
+
* The complete IssuerDN
|
|
235
|
+
*/
|
|
236
|
+
protected issuerDN: CertificateSchema[0][3];
|
|
237
|
+
/**
|
|
238
|
+
* Object type ID for @see Certificate.isCertificate
|
|
239
|
+
*/
|
|
240
|
+
private static certificateObjectTypeID;
|
|
241
|
+
/**
|
|
242
|
+
* Is a certificate object?
|
|
243
|
+
*/
|
|
244
|
+
static isCertificate(value: unknown): value is Certificate;
|
|
245
|
+
constructor(input: Certificate | ArrayBuffer | Buffer | string, options?: CertificateOptions);
|
|
246
|
+
/**
|
|
247
|
+
* Finalize construction of the certificate -- if this method is
|
|
248
|
+
* replaced in a subclass, remember to call it at the end of the
|
|
249
|
+
* subclass constructor or the certificate will not be fully
|
|
250
|
+
* constructed
|
|
251
|
+
*/
|
|
252
|
+
protected finalizeConstruction(): void;
|
|
253
|
+
/**
|
|
254
|
+
* Process remaining extensions
|
|
255
|
+
*/
|
|
256
|
+
protected processExtensions(): void;
|
|
257
|
+
/**
|
|
258
|
+
* Process an extension -- returns true if the extension was processed
|
|
259
|
+
*
|
|
260
|
+
* This is intended to be overridden by subclasses for processing
|
|
261
|
+
* custom extensions
|
|
262
|
+
*/
|
|
263
|
+
protected processExtension(id: string, value: ArrayBuffer): boolean;
|
|
264
|
+
/**
|
|
265
|
+
* Verifies that a certificate is self-signed
|
|
266
|
+
*/
|
|
267
|
+
isSelfSigned(): boolean;
|
|
268
|
+
/**
|
|
269
|
+
* Verifies that the certificate is was signed by the given account or certificate
|
|
270
|
+
*/
|
|
271
|
+
verify(account: Account | Certificate): boolean;
|
|
272
|
+
/**
|
|
273
|
+
* Verify against a given certificate store
|
|
274
|
+
*/
|
|
275
|
+
verifyChain(store: NonNullable<CertificateOptions['store']>, _ignore_seenCerts?: Set<Certificate>): Certificate[] | null;
|
|
276
|
+
/**
|
|
277
|
+
* Check if the certificate is valid at a given moment
|
|
278
|
+
*/
|
|
279
|
+
checkValid(moment?: Date | null): boolean;
|
|
280
|
+
checkValid(moment?: Date | null, reason?: false): boolean;
|
|
281
|
+
checkValid(moment?: Date | null, reason?: true): {
|
|
282
|
+
valid: true;
|
|
283
|
+
} | {
|
|
284
|
+
valid: false;
|
|
285
|
+
reason: string;
|
|
286
|
+
};
|
|
287
|
+
/**
|
|
288
|
+
* Assert that the certificate is valid at a given moment
|
|
289
|
+
*/
|
|
290
|
+
assertValid(moment?: Date | null): void;
|
|
291
|
+
/**
|
|
292
|
+
* Check if the certificate is issued by a given issuer
|
|
293
|
+
*/
|
|
294
|
+
checkIssued(issuer: Certificate): boolean;
|
|
295
|
+
checkIssued(issuer: Certificate, reason: true): {
|
|
296
|
+
issued: true;
|
|
297
|
+
} | {
|
|
298
|
+
issued: false;
|
|
299
|
+
reason: string;
|
|
300
|
+
};
|
|
301
|
+
/**
|
|
302
|
+
* Get the issuer certificate (if known)
|
|
303
|
+
*/
|
|
304
|
+
getIssuerCertificate(): Certificate | null;
|
|
305
|
+
/**
|
|
306
|
+
* Get the root certificate (if known)
|
|
307
|
+
*/
|
|
308
|
+
getRootCertificate(): Certificate | null;
|
|
309
|
+
/**
|
|
310
|
+
* Get the issuer account
|
|
311
|
+
*/
|
|
312
|
+
getIssuerAccount(): Account | null;
|
|
313
|
+
private assertConstructed;
|
|
314
|
+
/**
|
|
315
|
+
* Compare the certificate with another certificate and return true if they
|
|
316
|
+
* are the same
|
|
317
|
+
*/
|
|
318
|
+
equals(other: Certificate): boolean;
|
|
319
|
+
/**
|
|
320
|
+
* If this certificate can be trusted to have been validated to a trusted Root CA
|
|
321
|
+
*/
|
|
322
|
+
get trusted(): boolean;
|
|
323
|
+
/**
|
|
324
|
+
* Get the certificate as a DER encoded ArrayBuffer
|
|
325
|
+
*/
|
|
326
|
+
toDER(): ArrayBuffer;
|
|
327
|
+
/**
|
|
328
|
+
* Get the certificate as a PEM encoded string
|
|
329
|
+
*/
|
|
330
|
+
toPEM(): string;
|
|
331
|
+
/**
|
|
332
|
+
* Compute a hash of the certificate
|
|
333
|
+
*/
|
|
334
|
+
hash(): string;
|
|
335
|
+
/**
|
|
336
|
+
* Get a JSON representation of the certificate
|
|
337
|
+
*/
|
|
338
|
+
toJSON(includeChain?: boolean): any;
|
|
339
|
+
}
|
|
340
|
+
export default Certificate;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { Vote, VoteStaple } from '../vote';
|
|
2
|
+
import type Account from '../account';
|
|
3
|
+
import type { Block, BlockHash } from '../block';
|
|
4
|
+
import type Permissions from '../permissions';
|
|
5
|
+
export type JSONSerializable = string | number | boolean | null | JSONSerializable[] | {
|
|
6
|
+
[key: string]: JSONSerializable;
|
|
7
|
+
};
|
|
8
|
+
export type JSONSerializableObject = {
|
|
9
|
+
[key: string]: JSONSerializable;
|
|
10
|
+
};
|
|
11
|
+
type JSONUnsupportedTypes = Date | BlockHash | Account | bigint | Permissions | Vote | Block | VoteStaple;
|
|
12
|
+
type JSONSupportedObject<T> = {
|
|
13
|
+
[Property in keyof T]: Exclude<T[Property], JSONUnsupportedTypes>;
|
|
14
|
+
};
|
|
15
|
+
type JSONSupportedValue<T> = JSONSupportedObject<T>[any];
|
|
16
|
+
export type JSONSupported<T> = JSONSupportedObject<T> | JSONSupportedValue<T>;
|
|
17
|
+
export type ToJSONSerializableOptions = {
|
|
18
|
+
debugUnsafe?: boolean;
|
|
19
|
+
addBinary?: boolean;
|
|
20
|
+
};
|
|
21
|
+
export type ToJSONSerializable<T> = T extends bigint ? string : T extends Date ? string : T extends Buffer ? string : T extends {
|
|
22
|
+
toJSONSerializable(): infer U;
|
|
23
|
+
} ? U : T extends {
|
|
24
|
+
toJSON(): infer U;
|
|
25
|
+
} ? ToJSONSerializable<U> : T extends Account<infer K extends typeof Account.AccountKeyAlgorithm[keyof typeof Account.AccountKeyAlgorithm]> ? ReturnType<Account<K>['publicKeyString']['get']> : T extends BlockHash ? string : T extends Permissions ? [string, string] : T extends Vote ? ReturnType<Vote['toJSON']> & {
|
|
26
|
+
'$binary': string;
|
|
27
|
+
} : T extends VoteStaple ? ReturnType<VoteStaple['toJSON']> & {
|
|
28
|
+
'$binary': string;
|
|
29
|
+
} : T extends Block ? ReturnType<Block['toJSON']> & {
|
|
30
|
+
'$binary': string;
|
|
31
|
+
} : T extends JSONSerializable ? T : T extends object ? {
|
|
32
|
+
[K in keyof T]: ToJSONSerializable<T[K]>;
|
|
33
|
+
} : never;
|
|
34
|
+
export declare function toJSONSerializable(data: JSONSupported<any>, opts?: ToJSONSerializableOptions): JSONSupported<any> & JSONSerializable;
|
|
35
|
+
/** @deprecated -- move to toJSON methods */
|
|
36
|
+
interface WithConversionClass<T, Y> {
|
|
37
|
+
toJSONSerializablePrefix: string;
|
|
38
|
+
toJSONSerializable(value: T, options: ToJSONSerializableOptions): Y;
|
|
39
|
+
isInstance(value: any): value is T;
|
|
40
|
+
new (...args: any[]): T;
|
|
41
|
+
}
|
|
42
|
+
/** @deprecated -- move to toJSON methods */
|
|
43
|
+
export declare function RegisterSerializable(name: string): <X, Y>(target: WithConversionClass<X, Y>) => void;
|
|
44
|
+
export declare function objectToBuffer(data: JSONSupported<any>, opts?: ToJSONSerializableOptions): Buffer;
|
|
45
|
+
export declare function parseHexBigIntString(input: string): bigint;
|
|
46
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { AttributeValue, DynamoDB } from '@aws-sdk/client-dynamodb';
|
|
2
|
+
/**
|
|
3
|
+
* Execute some code and if a DynamoDB error occurs that is retryable, retry
|
|
4
|
+
* the execution
|
|
5
|
+
*/
|
|
6
|
+
export declare function dynamoDBExecuteRetryable<T>(code: () => Promise<T>, id: string): ReturnType<typeof code>;
|
|
7
|
+
type AttributeValueStringMap = {
|
|
8
|
+
[key: string]: string;
|
|
9
|
+
};
|
|
10
|
+
type AttributeValueMap = {
|
|
11
|
+
[key: string]: AttributeValue;
|
|
12
|
+
};
|
|
13
|
+
export declare function dynamoDBGetItem(dynamodb: DynamoDB, table: string, keys: AttributeValueStringMap, consistent?: boolean): Promise<undefined | AttributeValueMap>;
|
|
14
|
+
export declare function dynamoDBPaginatedScan(dynamodb: DynamoDB, scanArgs: Parameters<DynamoDB['scan']>[0], code: (page: AttributeValueMap[]) => Promise<any>, ordered?: boolean): Promise<void>;
|
|
15
|
+
export declare function getTableState(dynamodb: DynamoDB, table: string): Promise<string>;
|
|
16
|
+
export declare function waitForTableToBe(dynamodb: DynamoDB, table: string, state: string): Promise<void>;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare function convertPublicKey(pk: Uint8Array): Uint8Array | null;
|
|
2
|
+
export declare function convertSecretKey(sk: Uint8Array): Uint8Array;
|
|
3
|
+
declare const _default: {
|
|
4
|
+
convertSecretKey: typeof convertSecretKey;
|
|
5
|
+
convertPublicKey: typeof convertPublicKey;
|
|
6
|
+
};
|
|
7
|
+
export default _default;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hashing function name to use with key derivation and public key checksums
|
|
3
|
+
*/
|
|
4
|
+
export declare const HashFunctionName = "sha3-256";
|
|
5
|
+
/**
|
|
6
|
+
* Length of the hash function
|
|
7
|
+
*/
|
|
8
|
+
export declare const HashFunctionLength = 32;
|
|
9
|
+
/**
|
|
10
|
+
* Hash some data
|
|
11
|
+
*/
|
|
12
|
+
export declare function Hash(data: Buffer, len?: number): ArrayBuffer;
|
|
13
|
+
export declare namespace Hash {
|
|
14
|
+
var functionName: string;
|
|
15
|
+
var functionLength: number;
|
|
16
|
+
}
|
|
17
|
+
export default Hash;
|