universa-core2 2.0.0-alpha.1
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/LICENSE +8 -0
- package/LICENSE.BSD-3-Clause +30 -0
- package/LICENSE.GPL-2.0 +339 -0
- package/README.md +718 -0
- package/dist/.gitkeep +0 -0
- package/dist/index.cjs +2140 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +611 -0
- package/dist/index.mjs +80 -0
- package/package.json +67 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,611 @@
|
|
|
1
|
+
import * as unicrypto from 'unicrypto';
|
|
2
|
+
import { PublicKey, KeyAddress, BossSerializable, PrivateKey, SymmetricKey } from 'unicrypto';
|
|
3
|
+
export * from 'unicrypto';
|
|
4
|
+
|
|
5
|
+
type RoleDictionary = {
|
|
6
|
+
[roleName: string]: Role;
|
|
7
|
+
};
|
|
8
|
+
declare abstract class Role {
|
|
9
|
+
name: string;
|
|
10
|
+
resolve(roles: RoleDictionary, nestedLevel?: number): Role;
|
|
11
|
+
availableFor(options: AvailableForOptions): Promise<boolean>;
|
|
12
|
+
getSimpleAddress(roles: RoleDictionary, ignoreRefs?: boolean): Promise<KeyAddress | null>;
|
|
13
|
+
}
|
|
14
|
+
interface AvailableForOptions {
|
|
15
|
+
keys?: Array<PublicKey>;
|
|
16
|
+
addresses?: Array<KeyAddress>;
|
|
17
|
+
roles?: RoleDictionary;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
interface HashIdSerialized {
|
|
21
|
+
composite3: Uint8Array;
|
|
22
|
+
}
|
|
23
|
+
declare class HashId implements BossSerializable {
|
|
24
|
+
composite3: Uint8Array;
|
|
25
|
+
constructor(composite3: Uint8Array);
|
|
26
|
+
static calculate(bin: Uint8Array): Promise<HashId>;
|
|
27
|
+
get base64(): string;
|
|
28
|
+
equals(hashId: HashId): boolean;
|
|
29
|
+
static className: string;
|
|
30
|
+
serializeToBOSS(): {
|
|
31
|
+
composite3: Uint8Array<ArrayBufferLike>;
|
|
32
|
+
};
|
|
33
|
+
static deserializeFromBOSS(serialized: HashIdSerialized): HashId;
|
|
34
|
+
static unpack(bin: Uint8Array): HashId;
|
|
35
|
+
pack(): Uint8Array<ArrayBufferLike>;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
declare enum ReferenceType {
|
|
39
|
+
TYPE_TRANSACTIONAL = 1,
|
|
40
|
+
TYPE_EXISTING_DEFINITION = 2,
|
|
41
|
+
TYPE_EXISTING_STATE = 3
|
|
42
|
+
}
|
|
43
|
+
declare class Reference implements BossSerializable {
|
|
44
|
+
static className: string;
|
|
45
|
+
static TYPE_TRANSACTIONAL: ReferenceType;
|
|
46
|
+
static TYPE_EXISTING_DEFINITION: ReferenceType;
|
|
47
|
+
static TYPE_EXISTING_STATE: ReferenceType;
|
|
48
|
+
fields: Array<any>;
|
|
49
|
+
roles: Array<any>;
|
|
50
|
+
signedBy: Array<any>;
|
|
51
|
+
transactionalId: any;
|
|
52
|
+
required: boolean;
|
|
53
|
+
name: string;
|
|
54
|
+
type: ReferenceType;
|
|
55
|
+
where: any;
|
|
56
|
+
constructor(name: string, type: ReferenceType, where: any);
|
|
57
|
+
serializeToBOSS(): {
|
|
58
|
+
fields: any[];
|
|
59
|
+
roles: any[];
|
|
60
|
+
signed_by: any[];
|
|
61
|
+
transactional_id: any;
|
|
62
|
+
required: boolean;
|
|
63
|
+
name: string;
|
|
64
|
+
type: ReferenceType;
|
|
65
|
+
where: any;
|
|
66
|
+
};
|
|
67
|
+
static deserializeFromBOSS(serialized: any): Reference;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
interface RoleLinkSerialized {
|
|
71
|
+
name: string;
|
|
72
|
+
target_name: string;
|
|
73
|
+
}
|
|
74
|
+
declare class RoleLink implements Role, BossSerializable {
|
|
75
|
+
name: string;
|
|
76
|
+
targetName: string;
|
|
77
|
+
constructor(name: string, targetName: string);
|
|
78
|
+
resolve(roles?: RoleDictionary, nestedLevel?: number): Role;
|
|
79
|
+
getSimpleAddress(roles?: RoleDictionary, ignoreRefs?: boolean): Promise<KeyAddress | null>;
|
|
80
|
+
availableFor(options: AvailableForOptions): Promise<boolean>;
|
|
81
|
+
static className: string;
|
|
82
|
+
serializeToBOSS(): {
|
|
83
|
+
name: string;
|
|
84
|
+
target_name: string;
|
|
85
|
+
};
|
|
86
|
+
static deserializeFromBOSS(serialized: RoleLinkSerialized): RoleLink;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
type Params = {
|
|
90
|
+
[key: string]: any;
|
|
91
|
+
};
|
|
92
|
+
declare class Permission {
|
|
93
|
+
name: string;
|
|
94
|
+
role: Role;
|
|
95
|
+
params: Params;
|
|
96
|
+
constructor(role: Role, params: Params, name?: string);
|
|
97
|
+
static DefaultName: string;
|
|
98
|
+
static makeLink(name: string, roleName: string): RoleLink;
|
|
99
|
+
availableFor(options: AvailableForOptions): Promise<boolean>;
|
|
100
|
+
serializeToBOSS(): {
|
|
101
|
+
name: string;
|
|
102
|
+
role: Role;
|
|
103
|
+
} & Params;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
interface State {
|
|
107
|
+
createdAt: Date;
|
|
108
|
+
expiresAt: Date;
|
|
109
|
+
owner: Role;
|
|
110
|
+
creator: Role;
|
|
111
|
+
data: any;
|
|
112
|
+
revision: number;
|
|
113
|
+
roles: RoleDictionary;
|
|
114
|
+
parent: HashId | null;
|
|
115
|
+
origin: HashId | null;
|
|
116
|
+
branchId?: string | null;
|
|
117
|
+
references?: Array<Reference>;
|
|
118
|
+
}
|
|
119
|
+
interface Definition {
|
|
120
|
+
issuer: Role;
|
|
121
|
+
permissions: {
|
|
122
|
+
[id: string]: Permission;
|
|
123
|
+
};
|
|
124
|
+
createdAt: Date;
|
|
125
|
+
data: any;
|
|
126
|
+
references?: Array<Reference>;
|
|
127
|
+
}
|
|
128
|
+
interface UniversaContractSerialized {
|
|
129
|
+
api_level: number;
|
|
130
|
+
definition: any;
|
|
131
|
+
state: any;
|
|
132
|
+
transactional?: any;
|
|
133
|
+
}
|
|
134
|
+
interface ContractCreateOptions {
|
|
135
|
+
createdAt?: Date;
|
|
136
|
+
expiresAt?: Date | string;
|
|
137
|
+
}
|
|
138
|
+
declare class UniversaContract implements BossSerializable {
|
|
139
|
+
apiLevel: number;
|
|
140
|
+
definition: Definition;
|
|
141
|
+
state: State;
|
|
142
|
+
transactional: any;
|
|
143
|
+
constructor(apiLevel: number, definition: Definition, state: State, transactional: any);
|
|
144
|
+
static create(issuer: Role, options?: ContractCreateOptions): UniversaContract;
|
|
145
|
+
get issuer(): Role;
|
|
146
|
+
get owner(): Role;
|
|
147
|
+
set owner(role: Role);
|
|
148
|
+
get creator(): Role;
|
|
149
|
+
set creator(role: Role);
|
|
150
|
+
get parent(): HashId | null;
|
|
151
|
+
get origin(): HashId | null;
|
|
152
|
+
addPermission(permission: Permission): void;
|
|
153
|
+
removePermission(permissionId: string): void;
|
|
154
|
+
setParent(id: HashId): void;
|
|
155
|
+
setOrigin(id: HashId): void;
|
|
156
|
+
setCreatorTo(roleName: string): void;
|
|
157
|
+
incrementRevision(): void;
|
|
158
|
+
static className: string;
|
|
159
|
+
serializeToBOSS(): UniversaContractSerialized;
|
|
160
|
+
static deserializeFromBOSS(serialized: UniversaContractSerialized): UniversaContract;
|
|
161
|
+
resetTransactional(): void;
|
|
162
|
+
createTransactional(id: string | null): void;
|
|
163
|
+
addReference(ref: Reference): void;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
interface CapsuleOptions {
|
|
167
|
+
new?: Array<HashId>;
|
|
168
|
+
revoking?: Array<HashId>;
|
|
169
|
+
}
|
|
170
|
+
interface CreateCapsuleOptions {
|
|
171
|
+
definitionData?: any;
|
|
172
|
+
stateData?: any;
|
|
173
|
+
createdAt?: Date;
|
|
174
|
+
expiresAt?: Date | string;
|
|
175
|
+
permissions?: Array<Permission>;
|
|
176
|
+
owner?: Role;
|
|
177
|
+
}
|
|
178
|
+
declare class Capsule {
|
|
179
|
+
contract: UniversaContract;
|
|
180
|
+
new: Array<HashId>;
|
|
181
|
+
revoking: Array<HashId>;
|
|
182
|
+
constructor(contract: UniversaContract, options?: CapsuleOptions);
|
|
183
|
+
static unpack(bin: Uint8Array): Capsule;
|
|
184
|
+
static create(issuer: Role, options?: CreateCapsuleOptions): Capsule;
|
|
185
|
+
get issuer(): Role;
|
|
186
|
+
get owner(): Role;
|
|
187
|
+
set owner(role: Role);
|
|
188
|
+
get creator(): Role;
|
|
189
|
+
set creator(role: Role);
|
|
190
|
+
get parent(): HashId | null;
|
|
191
|
+
get origin(): HashId | null;
|
|
192
|
+
get definition(): Definition;
|
|
193
|
+
get state(): State;
|
|
194
|
+
get transactional(): any;
|
|
195
|
+
pack(): Uint8Array<ArrayBufferLike>;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
interface ContractOptions {
|
|
199
|
+
type?: string;
|
|
200
|
+
version?: number;
|
|
201
|
+
binary?: Uint8Array;
|
|
202
|
+
}
|
|
203
|
+
interface signedByOptions {
|
|
204
|
+
address?: KeyAddress;
|
|
205
|
+
publicKey?: PublicKey;
|
|
206
|
+
}
|
|
207
|
+
declare class Contract {
|
|
208
|
+
type: string;
|
|
209
|
+
version: number;
|
|
210
|
+
signatures: Array<Uint8Array>;
|
|
211
|
+
data: Uint8Array;
|
|
212
|
+
capsule: Capsule;
|
|
213
|
+
binary: Uint8Array | null;
|
|
214
|
+
constructor(data: Uint8Array, signatures?: Array<Uint8Array>, options?: ContractOptions);
|
|
215
|
+
get issuer(): Role;
|
|
216
|
+
get owner(): Role;
|
|
217
|
+
set owner(role: Role);
|
|
218
|
+
get creator(): Role;
|
|
219
|
+
set creator(role: Role);
|
|
220
|
+
setCreatorTo(roleName: string): void;
|
|
221
|
+
get parent(): HashId | null;
|
|
222
|
+
get origin(): HashId | null;
|
|
223
|
+
get definition(): Definition;
|
|
224
|
+
get state(): State;
|
|
225
|
+
get transactional(): any;
|
|
226
|
+
hashId(): Promise<HashId>;
|
|
227
|
+
getSignatureKeys(): Promise<PublicKey[]>;
|
|
228
|
+
isSignedBy(options: signedByOptions): Promise<boolean>;
|
|
229
|
+
sign(privateKey: PrivateKey): Promise<void>;
|
|
230
|
+
static create(issuer: Role, options: CreateCapsuleOptions): Contract;
|
|
231
|
+
packData(): void;
|
|
232
|
+
pack(): Uint8Array<ArrayBufferLike>;
|
|
233
|
+
createRevision(createdAt?: Date): Promise<Contract>;
|
|
234
|
+
static unpack(binary: Uint8Array): Contract;
|
|
235
|
+
resetTransactional(): void;
|
|
236
|
+
createTransactional(id: string | null): void;
|
|
237
|
+
addReference(ref: Reference): void;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
interface TransactionPackOptions {
|
|
241
|
+
subItems?: Array<Uint8Array>;
|
|
242
|
+
referencedItems?: Array<Uint8Array>;
|
|
243
|
+
tags?: {
|
|
244
|
+
[tag: string]: HashId;
|
|
245
|
+
};
|
|
246
|
+
keys?: Array<Uint8Array>;
|
|
247
|
+
}
|
|
248
|
+
interface TaggedItem {
|
|
249
|
+
hashId: HashId;
|
|
250
|
+
contract: Contract;
|
|
251
|
+
}
|
|
252
|
+
declare class TransactionPack implements BossSerializable {
|
|
253
|
+
contract: Contract;
|
|
254
|
+
subItems: {
|
|
255
|
+
[hashId64: string]: Contract;
|
|
256
|
+
};
|
|
257
|
+
referencedItems: {
|
|
258
|
+
[hashId64: string]: Contract;
|
|
259
|
+
};
|
|
260
|
+
taggedItems: {
|
|
261
|
+
[tag: string]: TaggedItem;
|
|
262
|
+
};
|
|
263
|
+
ready: Promise<void>;
|
|
264
|
+
constructor(contractPacked: Uint8Array, options?: TransactionPackOptions);
|
|
265
|
+
getItem(hashId: HashId): Promise<Contract>;
|
|
266
|
+
getTag(tag: string): Promise<TaggedItem>;
|
|
267
|
+
addTag(tag: string, hashId: HashId): Promise<void>;
|
|
268
|
+
addSubItem(itemPacked: Uint8Array): Promise<void>;
|
|
269
|
+
addReferencedItem(itemPacked: Uint8Array): Promise<void>;
|
|
270
|
+
pack(): Promise<Uint8Array<ArrayBufferLike>>;
|
|
271
|
+
static unpack(packed: Uint8Array): TransactionPack;
|
|
272
|
+
static className: string;
|
|
273
|
+
serializeToBOSS(): {
|
|
274
|
+
contract: Uint8Array<ArrayBufferLike> | null;
|
|
275
|
+
subItems: Uint8Array<ArrayBufferLike>[];
|
|
276
|
+
referencedItems: Uint8Array<ArrayBufferLike>[];
|
|
277
|
+
tags: {
|
|
278
|
+
[tag: string]: HashId;
|
|
279
|
+
};
|
|
280
|
+
};
|
|
281
|
+
static deserializeFromBOSS(serialized: any): TransactionPack;
|
|
282
|
+
sign(key: PrivateKey): Promise<void>;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
declare class Compound {
|
|
286
|
+
tpack: TransactionPack;
|
|
287
|
+
constructor(tpack: TransactionPack);
|
|
288
|
+
static unpack(bin: Uint8Array): Compound;
|
|
289
|
+
pack(): Promise<Uint8Array<ArrayBufferLike>>;
|
|
290
|
+
private getDefinitionContracts;
|
|
291
|
+
getTags(): Array<string>;
|
|
292
|
+
sign(privateKey: PrivateKey): Promise<void>;
|
|
293
|
+
getTag(tag: string): Promise<TransactionPack | null>;
|
|
294
|
+
getItem(hashId: HashId): Promise<Contract>;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
interface PaymentOptions {
|
|
298
|
+
isTestnet?: boolean;
|
|
299
|
+
createdAt?: Date;
|
|
300
|
+
}
|
|
301
|
+
declare class Parcel implements BossSerializable {
|
|
302
|
+
paymentBin: Uint8Array;
|
|
303
|
+
payloadBin: Uint8Array;
|
|
304
|
+
hashId: HashId;
|
|
305
|
+
payment: TransactionPack;
|
|
306
|
+
payload: TransactionPack;
|
|
307
|
+
constructor(payment: Uint8Array, payload: Uint8Array, hashId: HashId);
|
|
308
|
+
static className: string;
|
|
309
|
+
serializeToBOSS(): {
|
|
310
|
+
payment: Uint8Array<ArrayBufferLike>;
|
|
311
|
+
payload: Uint8Array<ArrayBufferLike>;
|
|
312
|
+
hashId: HashId;
|
|
313
|
+
};
|
|
314
|
+
static deserializeFromBOSS(serialized: any): Parcel;
|
|
315
|
+
static create(payment: Uint8Array, payload: Uint8Array): Promise<Parcel>;
|
|
316
|
+
static createPayment(amount: number, upack: TransactionPack, options?: PaymentOptions): Promise<TransactionPack>;
|
|
317
|
+
pack(): Uint8Array<ArrayBufferLike>;
|
|
318
|
+
static unpack(bin: Uint8Array): Parcel;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
type Primitive = string | number | Date | null | undefined;
|
|
322
|
+
type Dict = {
|
|
323
|
+
[key: string]: Primitive | Dict;
|
|
324
|
+
};
|
|
325
|
+
interface Cancelable<T> extends Promise<T> {
|
|
326
|
+
cancel(): Cancelable<T>;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
declare class KeyRecord implements BossSerializable {
|
|
330
|
+
keyPacked: Uint8Array;
|
|
331
|
+
keyLoader: Promise<PublicKey>;
|
|
332
|
+
key: PublicKey | null;
|
|
333
|
+
extra: Dict;
|
|
334
|
+
constructor(keyPacked: Uint8Array, extra?: Dict, key?: PublicKey);
|
|
335
|
+
getKey(): Promise<PublicKey>;
|
|
336
|
+
setExtra(extra: Dict): void;
|
|
337
|
+
static create(key: PublicKey, extra?: Dict): KeyRecord;
|
|
338
|
+
static className: string;
|
|
339
|
+
serializeToBOSS(): {
|
|
340
|
+
key: {
|
|
341
|
+
__t: string;
|
|
342
|
+
packed: Uint8Array<ArrayBufferLike>;
|
|
343
|
+
};
|
|
344
|
+
} & Dict;
|
|
345
|
+
static deserializeFromBOSS(serialized: any): KeyRecord;
|
|
346
|
+
pack(): Uint8Array<ArrayBufferLike>;
|
|
347
|
+
static unpack(bin: Uint8Array): KeyRecord;
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
interface RoleSimpleOptions {
|
|
351
|
+
keys?: Array<PublicKey>;
|
|
352
|
+
addresses?: Array<KeyAddress>;
|
|
353
|
+
keyRecords?: Array<KeyRecord>;
|
|
354
|
+
anonIds?: Array<any>;
|
|
355
|
+
}
|
|
356
|
+
declare class RoleSimple implements Role, BossSerializable {
|
|
357
|
+
name: string;
|
|
358
|
+
keyRecords: Array<KeyRecord>;
|
|
359
|
+
addresses: Array<KeyAddress>;
|
|
360
|
+
anonIds: Array<any>;
|
|
361
|
+
constructor(name: string, options: RoleSimpleOptions);
|
|
362
|
+
resolve(roles: RoleDictionary, nestedLevel?: number): this;
|
|
363
|
+
getSimpleAddress(roles?: RoleDictionary, ignoreRefs?: boolean): Promise<KeyAddress | null>;
|
|
364
|
+
availableFor(options: AvailableForOptions): Promise<boolean>;
|
|
365
|
+
static className: string;
|
|
366
|
+
serializeToBOSS(): {
|
|
367
|
+
name: string;
|
|
368
|
+
keys: KeyRecord[];
|
|
369
|
+
addresses: KeyAddress[];
|
|
370
|
+
anonIds: any[];
|
|
371
|
+
};
|
|
372
|
+
static deserializeFromBOSS(serialized: any): RoleSimple;
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
declare enum MODES {
|
|
376
|
+
ANY = "ANY",
|
|
377
|
+
ALL = "ALL",
|
|
378
|
+
QUORUM = "QUORUM"
|
|
379
|
+
}
|
|
380
|
+
interface RoleListOptions {
|
|
381
|
+
mode: MODES;
|
|
382
|
+
roleNames?: Array<string>;
|
|
383
|
+
roles?: Array<Role>;
|
|
384
|
+
quorumSize?: number;
|
|
385
|
+
}
|
|
386
|
+
declare class RoleList implements Role, BossSerializable {
|
|
387
|
+
name: string;
|
|
388
|
+
mode: MODES;
|
|
389
|
+
roles: Array<Role>;
|
|
390
|
+
quorumSize: number;
|
|
391
|
+
constructor(name: string, options: RoleListOptions);
|
|
392
|
+
static MODES: typeof MODES;
|
|
393
|
+
resolve(roles?: RoleDictionary, nestedLevel?: number): RoleList;
|
|
394
|
+
getSimpleAddress(roles?: RoleDictionary, ignoreRefs?: boolean): Promise<unicrypto.KeyAddress | null>;
|
|
395
|
+
availableFor(options: AvailableForOptions): Promise<boolean>;
|
|
396
|
+
static className: string;
|
|
397
|
+
serializeToBOSS(): {
|
|
398
|
+
name: string;
|
|
399
|
+
mode: MODES;
|
|
400
|
+
roles: Role[];
|
|
401
|
+
quorumSize: number;
|
|
402
|
+
};
|
|
403
|
+
static deserializeFromBOSS(serialized: any): RoleList;
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
declare class RevokePermission extends Permission implements BossSerializable {
|
|
407
|
+
static DefaultName: string;
|
|
408
|
+
static className: string;
|
|
409
|
+
constructor(role: Role, name?: string);
|
|
410
|
+
static create(roleName: string, name?: string): RevokePermission;
|
|
411
|
+
static deserializeFromBOSS(serialized: any): RevokePermission;
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
declare class ChangeOwnerPermission extends Permission implements BossSerializable {
|
|
415
|
+
static DefaultName: string;
|
|
416
|
+
static className: string;
|
|
417
|
+
constructor(role: Role, name?: string);
|
|
418
|
+
static create(roleName: string, name?: string): ChangeOwnerPermission;
|
|
419
|
+
static deserializeFromBOSS(serialized: any): ChangeOwnerPermission;
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
type ModifyPrimitive = null | string | number | Date;
|
|
423
|
+
interface ModifyDataParams {
|
|
424
|
+
fields: {
|
|
425
|
+
[key: string]: Array<ModifyPrimitive>;
|
|
426
|
+
};
|
|
427
|
+
}
|
|
428
|
+
declare class ModifyDataPermission extends Permission implements BossSerializable {
|
|
429
|
+
params: ModifyDataParams;
|
|
430
|
+
static className: string;
|
|
431
|
+
static DefaultName: string;
|
|
432
|
+
constructor(role: Role, params: ModifyDataParams, name?: string);
|
|
433
|
+
static create(roleName: string, params: ModifyDataParams, name?: string): ModifyDataPermission;
|
|
434
|
+
static deserializeFromBOSS(serialized: any): ModifyDataPermission;
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
interface ChangeNumberParams {
|
|
438
|
+
field_name: string;
|
|
439
|
+
min_value?: string | number;
|
|
440
|
+
min_step?: string | number;
|
|
441
|
+
max_value?: string | number;
|
|
442
|
+
max_step?: string | number;
|
|
443
|
+
}
|
|
444
|
+
declare class ChangeNumberPermission extends Permission implements BossSerializable {
|
|
445
|
+
params: ChangeNumberParams;
|
|
446
|
+
static className: string;
|
|
447
|
+
static DefaultName: string;
|
|
448
|
+
constructor(role: Role, params: ChangeNumberParams, name?: string);
|
|
449
|
+
static create(roleName: string, params: ChangeNumberParams, name?: string): ChangeNumberPermission;
|
|
450
|
+
static deserializeFromBOSS(serialized: any): ChangeNumberPermission;
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
interface SplitJoinParams {
|
|
454
|
+
field_name: string;
|
|
455
|
+
min_value?: string | number;
|
|
456
|
+
min_unit?: string | number;
|
|
457
|
+
join_match_fields: Array<string>;
|
|
458
|
+
}
|
|
459
|
+
declare class SplitJoinPermission extends Permission implements BossSerializable {
|
|
460
|
+
params: SplitJoinParams;
|
|
461
|
+
static className: string;
|
|
462
|
+
static DefaultName: string;
|
|
463
|
+
constructor(role: Role, params: SplitJoinParams, name?: string);
|
|
464
|
+
static create(roleName: string, params: SplitJoinParams, name?: string): SplitJoinPermission;
|
|
465
|
+
static deserializeFromBOSS(serialized: any): SplitJoinPermission;
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
interface NodeInfo {
|
|
469
|
+
name: string;
|
|
470
|
+
number: number;
|
|
471
|
+
domain_urls: Array<string>;
|
|
472
|
+
direct_urls: Array<string>;
|
|
473
|
+
key: Uint8Array | string;
|
|
474
|
+
}
|
|
475
|
+
declare class Node {
|
|
476
|
+
id: string | undefined;
|
|
477
|
+
key: PublicKey | undefined;
|
|
478
|
+
name: string;
|
|
479
|
+
http: string;
|
|
480
|
+
https: string;
|
|
481
|
+
ready: Promise<void>;
|
|
482
|
+
keyBIN: Uint8Array;
|
|
483
|
+
number: number;
|
|
484
|
+
domainURLs: Set<string>;
|
|
485
|
+
directURLs: Set<string>;
|
|
486
|
+
constructor(info: NodeInfo);
|
|
487
|
+
getId(): Promise<string | undefined>;
|
|
488
|
+
getPublicKey(): Promise<PublicKey | undefined>;
|
|
489
|
+
equals(node: Node): Promise<boolean>;
|
|
490
|
+
info(): {
|
|
491
|
+
name: string;
|
|
492
|
+
number: number;
|
|
493
|
+
domain_urls: string[];
|
|
494
|
+
direct_urls: string[];
|
|
495
|
+
key: string;
|
|
496
|
+
};
|
|
497
|
+
getTopology(directConnection?: boolean): Promise<any>;
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
type NodeDictionary = {
|
|
501
|
+
[id: string]: Node;
|
|
502
|
+
};
|
|
503
|
+
interface PackedTopology {
|
|
504
|
+
list: Array<NodeInfo>;
|
|
505
|
+
updated: number;
|
|
506
|
+
}
|
|
507
|
+
type TopologyInput = PackedTopology | Array<NodeInfo>;
|
|
508
|
+
declare class Topology {
|
|
509
|
+
nodes: NodeDictionary;
|
|
510
|
+
updatedAt: Date;
|
|
511
|
+
constructor(nodes: NodeDictionary, updatedAt: Date);
|
|
512
|
+
update(directConnection?: boolean): Promise<void>;
|
|
513
|
+
size(): number;
|
|
514
|
+
pack(): {
|
|
515
|
+
list: any[];
|
|
516
|
+
updated: number;
|
|
517
|
+
};
|
|
518
|
+
getRandomNode(): Node;
|
|
519
|
+
getRandomNodeId(): string;
|
|
520
|
+
getNode(id: string): Node;
|
|
521
|
+
static load(input: TopologyInput): Promise<Topology>;
|
|
522
|
+
static load(input: unknown): Promise<Topology>;
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
declare class NodeConnection {
|
|
526
|
+
node: Node;
|
|
527
|
+
authKey: PrivateKey;
|
|
528
|
+
nodeURL: string;
|
|
529
|
+
sessionId: number | undefined;
|
|
530
|
+
sessionKey: SymmetricKey | undefined;
|
|
531
|
+
version: number | undefined;
|
|
532
|
+
nodePublicKey: PublicKey | undefined;
|
|
533
|
+
constructor(node: Node, authKey: PrivateKey, directConnection?: boolean);
|
|
534
|
+
connect(): Promise<this>;
|
|
535
|
+
command(name: string, params?: any, requestOptions?: any): Promise<any>;
|
|
536
|
+
request(path: string, params?: any, requestOptions?: any): Cancelable<any>;
|
|
537
|
+
static request(method: string, url: string, options?: any): Cancelable<any>;
|
|
538
|
+
static xchangeRequest(method: string, url: string, options?: any): Cancelable<any>;
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
interface NetworkOptions {
|
|
542
|
+
topologyKey?: string;
|
|
543
|
+
topology?: Topology;
|
|
544
|
+
topologyFile?: string;
|
|
545
|
+
directConnection?: boolean;
|
|
546
|
+
}
|
|
547
|
+
interface ContractState {
|
|
548
|
+
isApproved: boolean;
|
|
549
|
+
isTestnet: boolean;
|
|
550
|
+
states: any;
|
|
551
|
+
}
|
|
552
|
+
interface NetworkApproval {
|
|
553
|
+
id: Uint8Array;
|
|
554
|
+
meanTime: Date;
|
|
555
|
+
stdevSeconds: number;
|
|
556
|
+
trustLevel: number;
|
|
557
|
+
}
|
|
558
|
+
interface ParcelState {
|
|
559
|
+
payment: ItemResult;
|
|
560
|
+
payload: ItemResult;
|
|
561
|
+
}
|
|
562
|
+
interface ItemResult {
|
|
563
|
+
createdAt: Date | null;
|
|
564
|
+
extra: any;
|
|
565
|
+
__type: string;
|
|
566
|
+
isTestnet: boolean;
|
|
567
|
+
state: string;
|
|
568
|
+
haveCopy: boolean;
|
|
569
|
+
lockedById: any;
|
|
570
|
+
expiresAt: Date | null;
|
|
571
|
+
errors: any;
|
|
572
|
+
}
|
|
573
|
+
type ConnectionDict = {
|
|
574
|
+
[id: string]: NodeConnection;
|
|
575
|
+
};
|
|
576
|
+
declare class Network {
|
|
577
|
+
options: NetworkOptions;
|
|
578
|
+
connections: ConnectionDict;
|
|
579
|
+
topologyKey: string;
|
|
580
|
+
directConnection: boolean;
|
|
581
|
+
ready: Promise<void>;
|
|
582
|
+
authKey: PrivateKey;
|
|
583
|
+
setReady: any;
|
|
584
|
+
rejectReady: any;
|
|
585
|
+
topology: Topology | undefined;
|
|
586
|
+
timeOffset: number | null;
|
|
587
|
+
timeUpdatedAt: number | null;
|
|
588
|
+
private readyState;
|
|
589
|
+
private connecting;
|
|
590
|
+
constructor(privateKey: PrivateKey, options?: NetworkOptions);
|
|
591
|
+
private resetReady;
|
|
592
|
+
size(): number;
|
|
593
|
+
getLastTopology(): Promise<Topology>;
|
|
594
|
+
saveNewTopology(): void;
|
|
595
|
+
connect(): Promise<this>;
|
|
596
|
+
private performConnect;
|
|
597
|
+
nodeConnection(nodeId: string): Promise<NodeConnection>;
|
|
598
|
+
getRandomConnection(): Promise<NodeConnection>;
|
|
599
|
+
command(name: string, options?: any, connection?: NodeConnection, requestOptions?: any): Cancelable<any>;
|
|
600
|
+
getState(id: HashId | Uint8Array | string, connection?: NodeConnection, requestOptions?: any): Cancelable<any>;
|
|
601
|
+
checkParcel(id: Uint8Array | string): Cancelable<any>;
|
|
602
|
+
checkContract(id: HashId | Uint8Array | string, trustLevel: number): Promise<NetworkApproval | null>;
|
|
603
|
+
isApprovedExtended(id: Uint8Array | string, trustLevel: number, onNodeResponse?: (response: any) => void): Promise<ContractState>;
|
|
604
|
+
isApproved(id: Uint8Array | string, trustLevel: number): Promise<boolean>;
|
|
605
|
+
now(): Date;
|
|
606
|
+
loadNetworkTime(): Promise<void>;
|
|
607
|
+
static getCost(tpack: TransactionPack): Promise<any>;
|
|
608
|
+
registerParcel(parcel: Parcel): Promise<ParcelState>;
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
export { Capsule, ChangeNumberPermission, ChangeOwnerPermission, Compound, Contract, type Definition, HashId, KeyRecord, ModifyDataPermission, Network, type NetworkApproval, Node, Parcel, Reference, RevokePermission, type RoleDictionary, RoleLink, RoleList, RoleSimple, SplitJoinPermission, type State, Topology, TransactionPack, UniversaContract };
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import core from './index.cjs';
|
|
2
|
+
|
|
3
|
+
export const {
|
|
4
|
+
AES,
|
|
5
|
+
AESCTRTransformer,
|
|
6
|
+
AbstractKey,
|
|
7
|
+
BigInteger,
|
|
8
|
+
Boss,
|
|
9
|
+
CRC32,
|
|
10
|
+
Capsule,
|
|
11
|
+
ChangeNumberPermission,
|
|
12
|
+
ChangeOwnerPermission,
|
|
13
|
+
Compound,
|
|
14
|
+
Contract,
|
|
15
|
+
CryptoWorker,
|
|
16
|
+
DiffieHellman,
|
|
17
|
+
ExtendedSignature,
|
|
18
|
+
HMAC,
|
|
19
|
+
HashId,
|
|
20
|
+
KeyAddress,
|
|
21
|
+
KeyInfo,
|
|
22
|
+
KeyRecord,
|
|
23
|
+
ModifyDataPermission,
|
|
24
|
+
Network,
|
|
25
|
+
Node,
|
|
26
|
+
Parcel,
|
|
27
|
+
PrivateKey,
|
|
28
|
+
PublicKey,
|
|
29
|
+
Reference,
|
|
30
|
+
RevokePermission,
|
|
31
|
+
RoleLink,
|
|
32
|
+
RoleList,
|
|
33
|
+
RoleSimple,
|
|
34
|
+
SHA,
|
|
35
|
+
SignedRecord,
|
|
36
|
+
SplitJoinPermission,
|
|
37
|
+
SymmetricKey,
|
|
38
|
+
Topology,
|
|
39
|
+
TransactionPack,
|
|
40
|
+
UniversaContract,
|
|
41
|
+
arrayToByteString,
|
|
42
|
+
bigIntToByteArray,
|
|
43
|
+
byteArrayToBigInt,
|
|
44
|
+
byteStringToArray,
|
|
45
|
+
byteStringToBytes,
|
|
46
|
+
bytes,
|
|
47
|
+
bytesToByteString,
|
|
48
|
+
bytesToHex,
|
|
49
|
+
bytesToText,
|
|
50
|
+
concatBytes,
|
|
51
|
+
crc32,
|
|
52
|
+
decode58,
|
|
53
|
+
decode64,
|
|
54
|
+
decode64Short,
|
|
55
|
+
defaultPSSConfig,
|
|
56
|
+
defaultSignatureConfig,
|
|
57
|
+
dirname,
|
|
58
|
+
encode58,
|
|
59
|
+
encode64,
|
|
60
|
+
encode64Short,
|
|
61
|
+
guid,
|
|
62
|
+
hashId,
|
|
63
|
+
hexToBytes,
|
|
64
|
+
isBrowser,
|
|
65
|
+
isNode,
|
|
66
|
+
isWorker,
|
|
67
|
+
isWorkerAvailable,
|
|
68
|
+
keysEqual,
|
|
69
|
+
pbkdf2,
|
|
70
|
+
randomAlnums,
|
|
71
|
+
randomBytes,
|
|
72
|
+
rsa,
|
|
73
|
+
setup,
|
|
74
|
+
shortId,
|
|
75
|
+
textToBytes,
|
|
76
|
+
textToHex,
|
|
77
|
+
unicryptoReady
|
|
78
|
+
} = core;
|
|
79
|
+
|
|
80
|
+
export default core;
|