@spacesprotocol/libveritas 0.0.0-dev.20260325015123 → 0.0.0-dev.20260327154336
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/libveritas.d.ts +150 -0
- package/libveritas.js +121 -47
- package/libveritas_bg.wasm +0 -0
- package/package.json +12 -2
package/libveritas.d.ts
CHANGED
|
@@ -303,3 +303,153 @@ export function zoneIsBetterThan(a: any, b: any): boolean;
|
|
|
303
303
|
* Serialize a zone JS object to borsh bytes for storage.
|
|
304
304
|
*/
|
|
305
305
|
export function zoneToBytes(zone: any): Uint8Array;
|
|
306
|
+
|
|
307
|
+
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
308
|
+
|
|
309
|
+
export interface InitOutput {
|
|
310
|
+
readonly memory: WebAssembly.Memory;
|
|
311
|
+
readonly VERIFY_DEFAULT: () => number;
|
|
312
|
+
readonly VERIFY_DEV_MODE: () => number;
|
|
313
|
+
readonly VERIFY_ENABLE_SNARK: () => number;
|
|
314
|
+
readonly __wbg_anchors_free: (a: number, b: number) => void;
|
|
315
|
+
readonly __wbg_lookup_free: (a: number, b: number) => void;
|
|
316
|
+
readonly __wbg_message_free: (a: number, b: number) => void;
|
|
317
|
+
readonly __wbg_messagebuilder_free: (a: number, b: number) => void;
|
|
318
|
+
readonly __wbg_offchainrecords_free: (a: number, b: number) => void;
|
|
319
|
+
readonly __wbg_querycontext_free: (a: number, b: number) => void;
|
|
320
|
+
readonly __wbg_recordset_free: (a: number, b: number) => void;
|
|
321
|
+
readonly __wbg_verifiedmessage_free: (a: number, b: number) => void;
|
|
322
|
+
readonly __wbg_veritas_free: (a: number, b: number) => void;
|
|
323
|
+
readonly anchors_computeTrustSet: (a: number) => [number, number, number];
|
|
324
|
+
readonly anchors_from_json: (a: number, b: number) => [number, number, number];
|
|
325
|
+
readonly createCertificateChain: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
326
|
+
readonly decodeZone: (a: number, b: number) => [number, number, number];
|
|
327
|
+
readonly decode_certificate: (a: number, b: number) => [number, number, number];
|
|
328
|
+
readonly hash_signable_message: (a: number, b: number) => [number, number];
|
|
329
|
+
readonly lookup_advance: (a: number, b: any) => [number, number, number, number];
|
|
330
|
+
readonly lookup_expandZones: (a: number, b: any) => [number, number, number];
|
|
331
|
+
readonly lookup_new: (a: number, b: number) => [number, number, number];
|
|
332
|
+
readonly lookup_start: (a: number) => [number, number];
|
|
333
|
+
readonly message_from_bytes: (a: number, b: number) => [number, number, number];
|
|
334
|
+
readonly message_to_bytes: (a: number) => [number, number];
|
|
335
|
+
readonly message_update: (a: number, b: any) => [number, number];
|
|
336
|
+
readonly messagebuilder_addCert: (a: number, b: number, c: number) => [number, number];
|
|
337
|
+
readonly messagebuilder_addChain: (a: number, b: number, c: number) => [number, number];
|
|
338
|
+
readonly messagebuilder_addHandle: (a: number, b: number, c: number, d: number, e: number) => [number, number];
|
|
339
|
+
readonly messagebuilder_addRecords: (a: number, b: number, c: number, d: number, e: number) => [number, number];
|
|
340
|
+
readonly messagebuilder_addUpdate: (a: number, b: any) => [number, number];
|
|
341
|
+
readonly messagebuilder_build: (a: number, b: number, c: number) => [number, number, number];
|
|
342
|
+
readonly messagebuilder_chain_proof_request: (a: number) => [number, number, number];
|
|
343
|
+
readonly messagebuilder_new: () => number;
|
|
344
|
+
readonly offchainrecords_from: (a: number, b: number, c: number) => [number, number, number, number];
|
|
345
|
+
readonly querycontext_add_request: (a: number, b: number, c: number) => [number, number];
|
|
346
|
+
readonly querycontext_add_zone: (a: number, b: number, c: number) => [number, number];
|
|
347
|
+
readonly querycontext_new: () => number;
|
|
348
|
+
readonly record_blob: (a: number, b: number, c: number, d: number) => any;
|
|
349
|
+
readonly record_seq: (a: bigint) => any;
|
|
350
|
+
readonly record_txt: (a: number, b: number, c: number, d: number) => any;
|
|
351
|
+
readonly record_unknown: (a: number, b: number, c: number) => any;
|
|
352
|
+
readonly recordset_isEmpty: (a: number) => number;
|
|
353
|
+
readonly recordset_new: (a: number, b: number) => number;
|
|
354
|
+
readonly recordset_pack: (a: any) => [number, number, number];
|
|
355
|
+
readonly recordset_signingId: (a: number) => [number, number];
|
|
356
|
+
readonly recordset_toBytes: (a: number) => [number, number];
|
|
357
|
+
readonly recordset_unpack: (a: number) => [number, number, number];
|
|
358
|
+
readonly verifiedmessage_certificates: (a: number) => [number, number];
|
|
359
|
+
readonly verifiedmessage_message: (a: number) => number;
|
|
360
|
+
readonly verifiedmessage_message_bytes: (a: number) => [number, number];
|
|
361
|
+
readonly verifiedmessage_rootId: (a: number) => [number, number];
|
|
362
|
+
readonly verifiedmessage_zones: (a: number) => [number, number, number];
|
|
363
|
+
readonly verify_schnorr: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number];
|
|
364
|
+
readonly verify_spaces_message: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number];
|
|
365
|
+
readonly veritas_computeTrustSet: (a: number) => [number, number, number];
|
|
366
|
+
readonly veritas_is_finalized: (a: number, b: number) => number;
|
|
367
|
+
readonly veritas_new: (a: number) => [number, number, number];
|
|
368
|
+
readonly veritas_newest_anchor: (a: number) => number;
|
|
369
|
+
readonly veritas_oldest_anchor: (a: number) => number;
|
|
370
|
+
readonly veritas_sovereignty_for: (a: number, b: number) => [number, number];
|
|
371
|
+
readonly veritas_verify: (a: number, b: number, c: number) => [number, number, number];
|
|
372
|
+
readonly veritas_verifyWithOptions: (a: number, b: number, c: number, d: number) => [number, number, number];
|
|
373
|
+
readonly zoneIsBetterThan: (a: any, b: any) => [number, number, number];
|
|
374
|
+
readonly zoneToBytes: (a: any) => [number, number, number, number];
|
|
375
|
+
readonly sys_alloc_aligned: (a: number, b: number) => number;
|
|
376
|
+
readonly sys_alloc_words: (a: number) => number;
|
|
377
|
+
readonly sys_argc: () => number;
|
|
378
|
+
readonly sys_log: (a: number, b: number) => void;
|
|
379
|
+
readonly sys_argv: (a: number, b: number, c: number) => number;
|
|
380
|
+
readonly sys_bigint: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
381
|
+
readonly sys_bigint2_1: (a: number, b: number) => void;
|
|
382
|
+
readonly sys_bigint2_2: (a: number, b: number, c: number) => void;
|
|
383
|
+
readonly sys_bigint2_3: (a: number, b: number, c: number, d: number) => void;
|
|
384
|
+
readonly sys_bigint2_4: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
385
|
+
readonly sys_bigint2_5: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
386
|
+
readonly sys_bigint2_6: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
|
|
387
|
+
readonly sys_cycle_count: () => bigint;
|
|
388
|
+
readonly sys_exit: (a: number) => void;
|
|
389
|
+
readonly sys_fork: () => number;
|
|
390
|
+
readonly sys_getenv: (a: number, b: number, c: number, d: number) => number;
|
|
391
|
+
readonly sys_halt: (a: number, b: number) => void;
|
|
392
|
+
readonly sys_input: (a: number) => number;
|
|
393
|
+
readonly sys_keccak: (a: number, b: number) => number;
|
|
394
|
+
readonly sys_pause: (a: number, b: number) => void;
|
|
395
|
+
readonly sys_pipe: (a: number) => number;
|
|
396
|
+
readonly sys_poseidon2: (a: number, b: number, c: number, d: number) => void;
|
|
397
|
+
readonly sys_prove_keccak: (a: number, b: number) => void;
|
|
398
|
+
readonly sys_rand: (a: number, b: number) => void;
|
|
399
|
+
readonly sys_read: (a: number, b: number, c: number) => number;
|
|
400
|
+
readonly sys_sha_buffer: (a: number, b: number, c: number, d: number) => void;
|
|
401
|
+
readonly sys_sha_compress: (a: number, b: number, c: number, d: number) => void;
|
|
402
|
+
readonly sys_verify_integrity: (a: number, b: number) => void;
|
|
403
|
+
readonly sys_write: (a: number, b: number, c: number) => void;
|
|
404
|
+
readonly syscall_0: (a: number, b: number, c: number, d: number) => void;
|
|
405
|
+
readonly syscall_0_nr: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
406
|
+
readonly syscall_1: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
407
|
+
readonly syscall_1_nr: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
408
|
+
readonly syscall_2: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
409
|
+
readonly syscall_2_nr: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
|
|
410
|
+
readonly syscall_3: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
|
|
411
|
+
readonly syscall_3_nr: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
|
|
412
|
+
readonly syscall_4: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
|
|
413
|
+
readonly syscall_4_nr: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => void;
|
|
414
|
+
readonly syscall_5: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => void;
|
|
415
|
+
readonly syscall_5_nr: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number) => void;
|
|
416
|
+
readonly rustsecp256k1_v0_10_0_context_create: (a: number) => number;
|
|
417
|
+
readonly rustsecp256k1_v0_10_0_context_destroy: (a: number) => void;
|
|
418
|
+
readonly rustsecp256k1_v0_10_0_default_error_callback_fn: (a: number, b: number) => void;
|
|
419
|
+
readonly rustsecp256k1_v0_10_0_default_illegal_callback_fn: (a: number, b: number) => void;
|
|
420
|
+
readonly sys_panic: (a: number, b: number) => void;
|
|
421
|
+
readonly sys_verify_integrity2: (a: number, b: number) => void;
|
|
422
|
+
readonly sys_read_words: (a: number, b: number, c: number) => number;
|
|
423
|
+
readonly __wbg_record_free: (a: number, b: number) => void;
|
|
424
|
+
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
425
|
+
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
426
|
+
readonly __wbindgen_exn_store: (a: number) => void;
|
|
427
|
+
readonly __externref_table_alloc: () => number;
|
|
428
|
+
readonly __wbindgen_externrefs: WebAssembly.Table;
|
|
429
|
+
readonly __externref_table_dealloc: (a: number) => void;
|
|
430
|
+
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
431
|
+
readonly __externref_drop_slice: (a: number, b: number) => void;
|
|
432
|
+
readonly __wbindgen_start: () => void;
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
|
436
|
+
|
|
437
|
+
/**
|
|
438
|
+
* Instantiates the given `module`, which can either be bytes or
|
|
439
|
+
* a precompiled `WebAssembly.Module`.
|
|
440
|
+
*
|
|
441
|
+
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
|
|
442
|
+
*
|
|
443
|
+
* @returns {InitOutput}
|
|
444
|
+
*/
|
|
445
|
+
export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
|
|
446
|
+
|
|
447
|
+
/**
|
|
448
|
+
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
|
449
|
+
* for everything else, calls `WebAssembly.instantiate` directly.
|
|
450
|
+
*
|
|
451
|
+
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
|
|
452
|
+
*
|
|
453
|
+
* @returns {Promise<InitOutput>}
|
|
454
|
+
*/
|
|
455
|
+
export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
|
package/libveritas.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* @ts-self-types="./libveritas.d.ts" */
|
|
2
2
|
|
|
3
|
-
class Anchors {
|
|
3
|
+
export class Anchors {
|
|
4
4
|
__destroy_into_raw() {
|
|
5
5
|
const ptr = this.__wbg_ptr;
|
|
6
6
|
this.__wbg_ptr = 0;
|
|
@@ -37,12 +37,11 @@ class Anchors {
|
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
if (Symbol.dispose) Anchors.prototype[Symbol.dispose] = Anchors.prototype.free;
|
|
40
|
-
exports.Anchors = Anchors;
|
|
41
40
|
|
|
42
41
|
/**
|
|
43
42
|
* Batched iterative resolver for nested handle names.
|
|
44
43
|
*/
|
|
45
|
-
class Lookup {
|
|
44
|
+
export class Lookup {
|
|
46
45
|
__destroy_into_raw() {
|
|
47
46
|
const ptr = this.__wbg_ptr;
|
|
48
47
|
this.__wbg_ptr = 0;
|
|
@@ -107,12 +106,11 @@ class Lookup {
|
|
|
107
106
|
}
|
|
108
107
|
}
|
|
109
108
|
if (Symbol.dispose) Lookup.prototype[Symbol.dispose] = Lookup.prototype.free;
|
|
110
|
-
exports.Lookup = Lookup;
|
|
111
109
|
|
|
112
110
|
/**
|
|
113
111
|
* A message containing chain proofs and handle data.
|
|
114
112
|
*/
|
|
115
|
-
class Message {
|
|
113
|
+
export class Message {
|
|
116
114
|
static __wrap(ptr) {
|
|
117
115
|
ptr = ptr >>> 0;
|
|
118
116
|
const obj = Object.create(Message.prototype);
|
|
@@ -177,12 +175,11 @@ class Message {
|
|
|
177
175
|
}
|
|
178
176
|
}
|
|
179
177
|
if (Symbol.dispose) Message.prototype[Symbol.dispose] = Message.prototype.free;
|
|
180
|
-
exports.Message = Message;
|
|
181
178
|
|
|
182
179
|
/**
|
|
183
180
|
* Builder for constructing messages from update requests and chain proofs.
|
|
184
181
|
*/
|
|
185
|
-
class MessageBuilder {
|
|
182
|
+
export class MessageBuilder {
|
|
186
183
|
__destroy_into_raw() {
|
|
187
184
|
const ptr = this.__wbg_ptr;
|
|
188
185
|
this.__wbg_ptr = 0;
|
|
@@ -303,7 +300,6 @@ class MessageBuilder {
|
|
|
303
300
|
}
|
|
304
301
|
}
|
|
305
302
|
if (Symbol.dispose) MessageBuilder.prototype[Symbol.dispose] = MessageBuilder.prototype.free;
|
|
306
|
-
exports.MessageBuilder = MessageBuilder;
|
|
307
303
|
|
|
308
304
|
/**
|
|
309
305
|
* Helpers for constructing OffchainRecords (signed record sets).
|
|
@@ -314,7 +310,7 @@ exports.MessageBuilder = MessageBuilder;
|
|
|
314
310
|
* const bytes = OffchainRecords.from(rs, sig);
|
|
315
311
|
* ```
|
|
316
312
|
*/
|
|
317
|
-
class OffchainRecords {
|
|
313
|
+
export class OffchainRecords {
|
|
318
314
|
__destroy_into_raw() {
|
|
319
315
|
const ptr = this.__wbg_ptr;
|
|
320
316
|
this.__wbg_ptr = 0;
|
|
@@ -345,9 +341,8 @@ class OffchainRecords {
|
|
|
345
341
|
}
|
|
346
342
|
}
|
|
347
343
|
if (Symbol.dispose) OffchainRecords.prototype[Symbol.dispose] = OffchainRecords.prototype.free;
|
|
348
|
-
exports.OffchainRecords = OffchainRecords;
|
|
349
344
|
|
|
350
|
-
class QueryContext {
|
|
345
|
+
export class QueryContext {
|
|
351
346
|
__destroy_into_raw() {
|
|
352
347
|
const ptr = this.__wbg_ptr;
|
|
353
348
|
this.__wbg_ptr = 0;
|
|
@@ -391,7 +386,6 @@ class QueryContext {
|
|
|
391
386
|
}
|
|
392
387
|
}
|
|
393
388
|
if (Symbol.dispose) QueryContext.prototype[Symbol.dispose] = QueryContext.prototype.free;
|
|
394
|
-
exports.QueryContext = QueryContext;
|
|
395
389
|
|
|
396
390
|
/**
|
|
397
391
|
* Record constructors for building a RecordSet.
|
|
@@ -404,7 +398,7 @@ exports.QueryContext = QueryContext;
|
|
|
404
398
|
* ]);
|
|
405
399
|
* ```
|
|
406
400
|
*/
|
|
407
|
-
class Record {
|
|
401
|
+
export class Record {
|
|
408
402
|
__destroy_into_raw() {
|
|
409
403
|
const ptr = this.__wbg_ptr;
|
|
410
404
|
this.__wbg_ptr = 0;
|
|
@@ -462,7 +456,6 @@ class Record {
|
|
|
462
456
|
}
|
|
463
457
|
}
|
|
464
458
|
if (Symbol.dispose) Record.prototype[Symbol.dispose] = Record.prototype.free;
|
|
465
|
-
exports.Record = Record;
|
|
466
459
|
|
|
467
460
|
/**
|
|
468
461
|
* SIP-7 record set — wire-format encoded records.
|
|
@@ -477,7 +470,7 @@ exports.Record = Record;
|
|
|
477
470
|
* for (const r of rs.unpack()) { ... }
|
|
478
471
|
* ```
|
|
479
472
|
*/
|
|
480
|
-
class RecordSet {
|
|
473
|
+
export class RecordSet {
|
|
481
474
|
static __wrap(ptr) {
|
|
482
475
|
ptr = ptr >>> 0;
|
|
483
476
|
const obj = Object.create(RecordSet.prototype);
|
|
@@ -559,39 +552,35 @@ class RecordSet {
|
|
|
559
552
|
}
|
|
560
553
|
}
|
|
561
554
|
if (Symbol.dispose) RecordSet.prototype[Symbol.dispose] = RecordSet.prototype.free;
|
|
562
|
-
exports.RecordSet = RecordSet;
|
|
563
555
|
|
|
564
556
|
/**
|
|
565
557
|
* @returns {number}
|
|
566
558
|
*/
|
|
567
|
-
function VERIFY_DEFAULT() {
|
|
559
|
+
export function VERIFY_DEFAULT() {
|
|
568
560
|
const ret = wasm.VERIFY_DEFAULT();
|
|
569
561
|
return ret >>> 0;
|
|
570
562
|
}
|
|
571
|
-
exports.VERIFY_DEFAULT = VERIFY_DEFAULT;
|
|
572
563
|
|
|
573
564
|
/**
|
|
574
565
|
* @returns {number}
|
|
575
566
|
*/
|
|
576
|
-
function VERIFY_DEV_MODE() {
|
|
567
|
+
export function VERIFY_DEV_MODE() {
|
|
577
568
|
const ret = wasm.VERIFY_DEV_MODE();
|
|
578
569
|
return ret >>> 0;
|
|
579
570
|
}
|
|
580
|
-
exports.VERIFY_DEV_MODE = VERIFY_DEV_MODE;
|
|
581
571
|
|
|
582
572
|
/**
|
|
583
573
|
* @returns {number}
|
|
584
574
|
*/
|
|
585
|
-
function VERIFY_ENABLE_SNARK() {
|
|
575
|
+
export function VERIFY_ENABLE_SNARK() {
|
|
586
576
|
const ret = wasm.VERIFY_ENABLE_SNARK();
|
|
587
577
|
return ret >>> 0;
|
|
588
578
|
}
|
|
589
|
-
exports.VERIFY_ENABLE_SNARK = VERIFY_ENABLE_SNARK;
|
|
590
579
|
|
|
591
580
|
/**
|
|
592
581
|
* Result of verifying a message.
|
|
593
582
|
*/
|
|
594
|
-
class VerifiedMessage {
|
|
583
|
+
export class VerifiedMessage {
|
|
595
584
|
static __wrap(ptr) {
|
|
596
585
|
ptr = ptr >>> 0;
|
|
597
586
|
const obj = Object.create(VerifiedMessage.prototype);
|
|
@@ -660,9 +649,8 @@ class VerifiedMessage {
|
|
|
660
649
|
}
|
|
661
650
|
}
|
|
662
651
|
if (Symbol.dispose) VerifiedMessage.prototype[Symbol.dispose] = VerifiedMessage.prototype.free;
|
|
663
|
-
exports.VerifiedMessage = VerifiedMessage;
|
|
664
652
|
|
|
665
|
-
class Veritas {
|
|
653
|
+
export class Veritas {
|
|
666
654
|
__destroy_into_raw() {
|
|
667
655
|
const ptr = this.__wbg_ptr;
|
|
668
656
|
this.__wbg_ptr = 0;
|
|
@@ -767,7 +755,6 @@ class Veritas {
|
|
|
767
755
|
}
|
|
768
756
|
}
|
|
769
757
|
if (Symbol.dispose) Veritas.prototype[Symbol.dispose] = Veritas.prototype.free;
|
|
770
|
-
exports.Veritas = Veritas;
|
|
771
758
|
|
|
772
759
|
/**
|
|
773
760
|
* Create a .spacecert file from a subject name and certificate bytes.
|
|
@@ -777,7 +764,7 @@ exports.Veritas = Veritas;
|
|
|
777
764
|
* @param {Uint8Array[]} cert_bytes_list
|
|
778
765
|
* @returns {Uint8Array}
|
|
779
766
|
*/
|
|
780
|
-
function createCertificateChain(subject, cert_bytes_list) {
|
|
767
|
+
export function createCertificateChain(subject, cert_bytes_list) {
|
|
781
768
|
const ptr0 = passStringToWasm0(subject, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
782
769
|
const len0 = WASM_VECTOR_LEN;
|
|
783
770
|
const ptr1 = passArrayJsValueToWasm0(cert_bytes_list, wasm.__wbindgen_malloc);
|
|
@@ -790,14 +777,13 @@ function createCertificateChain(subject, cert_bytes_list) {
|
|
|
790
777
|
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
791
778
|
return v3;
|
|
792
779
|
}
|
|
793
|
-
exports.createCertificateChain = createCertificateChain;
|
|
794
780
|
|
|
795
781
|
/**
|
|
796
782
|
* Decode stored zone bytes to a plain JS object.
|
|
797
783
|
* @param {Uint8Array} bytes
|
|
798
784
|
* @returns {any}
|
|
799
785
|
*/
|
|
800
|
-
function decodeZone(bytes) {
|
|
786
|
+
export function decodeZone(bytes) {
|
|
801
787
|
const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
|
|
802
788
|
const len0 = WASM_VECTOR_LEN;
|
|
803
789
|
const ret = wasm.decodeZone(ptr0, len0);
|
|
@@ -806,14 +792,13 @@ function decodeZone(bytes) {
|
|
|
806
792
|
}
|
|
807
793
|
return takeFromExternrefTable0(ret[0]);
|
|
808
794
|
}
|
|
809
|
-
exports.decodeZone = decodeZone;
|
|
810
795
|
|
|
811
796
|
/**
|
|
812
797
|
* Decode stored certificate bytes to a JS object.
|
|
813
798
|
* @param {Uint8Array} bytes
|
|
814
799
|
* @returns {any}
|
|
815
800
|
*/
|
|
816
|
-
function decode_certificate(bytes) {
|
|
801
|
+
export function decode_certificate(bytes) {
|
|
817
802
|
const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
|
|
818
803
|
const len0 = WASM_VECTOR_LEN;
|
|
819
804
|
const ret = wasm.decode_certificate(ptr0, len0);
|
|
@@ -822,7 +807,6 @@ function decode_certificate(bytes) {
|
|
|
822
807
|
}
|
|
823
808
|
return takeFromExternrefTable0(ret[0]);
|
|
824
809
|
}
|
|
825
|
-
exports.decode_certificate = decode_certificate;
|
|
826
810
|
|
|
827
811
|
/**
|
|
828
812
|
* Hash a message with the Spaces signed-message prefix (SHA256).
|
|
@@ -830,7 +814,7 @@ exports.decode_certificate = decode_certificate;
|
|
|
830
814
|
* @param {Uint8Array} msg
|
|
831
815
|
* @returns {Uint8Array}
|
|
832
816
|
*/
|
|
833
|
-
function hash_signable_message(msg) {
|
|
817
|
+
export function hash_signable_message(msg) {
|
|
834
818
|
const ptr0 = passArray8ToWasm0(msg, wasm.__wbindgen_malloc);
|
|
835
819
|
const len0 = WASM_VECTOR_LEN;
|
|
836
820
|
const ret = wasm.hash_signable_message(ptr0, len0);
|
|
@@ -838,7 +822,6 @@ function hash_signable_message(msg) {
|
|
|
838
822
|
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
839
823
|
return v2;
|
|
840
824
|
}
|
|
841
|
-
exports.hash_signable_message = hash_signable_message;
|
|
842
825
|
|
|
843
826
|
/**
|
|
844
827
|
* Verify a raw Schnorr signature (no prefix, caller provides the 32-byte message hash).
|
|
@@ -846,7 +829,7 @@ exports.hash_signable_message = hash_signable_message;
|
|
|
846
829
|
* @param {Uint8Array} signature
|
|
847
830
|
* @param {Uint8Array} pubkey
|
|
848
831
|
*/
|
|
849
|
-
function verify_schnorr(msg_hash, signature, pubkey) {
|
|
832
|
+
export function verify_schnorr(msg_hash, signature, pubkey) {
|
|
850
833
|
const ptr0 = passArray8ToWasm0(msg_hash, wasm.__wbindgen_malloc);
|
|
851
834
|
const len0 = WASM_VECTOR_LEN;
|
|
852
835
|
const ptr1 = passArray8ToWasm0(signature, wasm.__wbindgen_malloc);
|
|
@@ -858,7 +841,6 @@ function verify_schnorr(msg_hash, signature, pubkey) {
|
|
|
858
841
|
throw takeFromExternrefTable0(ret[0]);
|
|
859
842
|
}
|
|
860
843
|
}
|
|
861
|
-
exports.verify_schnorr = verify_schnorr;
|
|
862
844
|
|
|
863
845
|
/**
|
|
864
846
|
* Verify a Schnorr signature over a message using the Spaces signed-message prefix.
|
|
@@ -866,7 +848,7 @@ exports.verify_schnorr = verify_schnorr;
|
|
|
866
848
|
* @param {Uint8Array} signature
|
|
867
849
|
* @param {Uint8Array} pubkey
|
|
868
850
|
*/
|
|
869
|
-
function verify_spaces_message(msg, signature, pubkey) {
|
|
851
|
+
export function verify_spaces_message(msg, signature, pubkey) {
|
|
870
852
|
const ptr0 = passArray8ToWasm0(msg, wasm.__wbindgen_malloc);
|
|
871
853
|
const len0 = WASM_VECTOR_LEN;
|
|
872
854
|
const ptr1 = passArray8ToWasm0(signature, wasm.__wbindgen_malloc);
|
|
@@ -878,7 +860,6 @@ function verify_spaces_message(msg, signature, pubkey) {
|
|
|
878
860
|
throw takeFromExternrefTable0(ret[0]);
|
|
879
861
|
}
|
|
880
862
|
}
|
|
881
|
-
exports.verify_spaces_message = verify_spaces_message;
|
|
882
863
|
|
|
883
864
|
/**
|
|
884
865
|
* Compare two zones — returns true if `a` is fresher/better than `b`.
|
|
@@ -886,21 +867,20 @@ exports.verify_spaces_message = verify_spaces_message;
|
|
|
886
867
|
* @param {any} b
|
|
887
868
|
* @returns {boolean}
|
|
888
869
|
*/
|
|
889
|
-
function zoneIsBetterThan(a, b) {
|
|
870
|
+
export function zoneIsBetterThan(a, b) {
|
|
890
871
|
const ret = wasm.zoneIsBetterThan(a, b);
|
|
891
872
|
if (ret[2]) {
|
|
892
873
|
throw takeFromExternrefTable0(ret[1]);
|
|
893
874
|
}
|
|
894
875
|
return ret[0] !== 0;
|
|
895
876
|
}
|
|
896
|
-
exports.zoneIsBetterThan = zoneIsBetterThan;
|
|
897
877
|
|
|
898
878
|
/**
|
|
899
879
|
* Serialize a zone JS object to borsh bytes for storage.
|
|
900
880
|
* @param {any} zone
|
|
901
881
|
* @returns {Uint8Array}
|
|
902
882
|
*/
|
|
903
|
-
function zoneToBytes(zone) {
|
|
883
|
+
export function zoneToBytes(zone) {
|
|
904
884
|
const ret = wasm.zoneToBytes(zone);
|
|
905
885
|
if (ret[3]) {
|
|
906
886
|
throw takeFromExternrefTable0(ret[2]);
|
|
@@ -909,7 +889,6 @@ function zoneToBytes(zone) {
|
|
|
909
889
|
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
910
890
|
return v1;
|
|
911
891
|
}
|
|
912
|
-
exports.zoneToBytes = zoneToBytes;
|
|
913
892
|
|
|
914
893
|
function __wbg_get_imports() {
|
|
915
894
|
const import0 = {
|
|
@@ -1259,7 +1238,15 @@ function takeFromExternrefTable0(idx) {
|
|
|
1259
1238
|
|
|
1260
1239
|
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
1261
1240
|
cachedTextDecoder.decode();
|
|
1241
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
1242
|
+
let numBytesDecoded = 0;
|
|
1262
1243
|
function decodeText(ptr, len) {
|
|
1244
|
+
numBytesDecoded += len;
|
|
1245
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
1246
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
1247
|
+
cachedTextDecoder.decode();
|
|
1248
|
+
numBytesDecoded = len;
|
|
1249
|
+
}
|
|
1263
1250
|
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
1264
1251
|
}
|
|
1265
1252
|
|
|
@@ -1278,8 +1265,95 @@ if (!('encodeInto' in cachedTextEncoder)) {
|
|
|
1278
1265
|
|
|
1279
1266
|
let WASM_VECTOR_LEN = 0;
|
|
1280
1267
|
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1268
|
+
let wasmModule, wasm;
|
|
1269
|
+
function __wbg_finalize_init(instance, module) {
|
|
1270
|
+
wasm = instance.exports;
|
|
1271
|
+
wasmModule = module;
|
|
1272
|
+
cachedDataViewMemory0 = null;
|
|
1273
|
+
cachedUint8ArrayMemory0 = null;
|
|
1274
|
+
wasm.__wbindgen_start();
|
|
1275
|
+
return wasm;
|
|
1276
|
+
}
|
|
1277
|
+
|
|
1278
|
+
async function __wbg_load(module, imports) {
|
|
1279
|
+
if (typeof Response === 'function' && module instanceof Response) {
|
|
1280
|
+
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
1281
|
+
try {
|
|
1282
|
+
return await WebAssembly.instantiateStreaming(module, imports);
|
|
1283
|
+
} catch (e) {
|
|
1284
|
+
const validResponse = module.ok && expectedResponseType(module.type);
|
|
1285
|
+
|
|
1286
|
+
if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
|
|
1287
|
+
console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
|
|
1288
|
+
|
|
1289
|
+
} else { throw e; }
|
|
1290
|
+
}
|
|
1291
|
+
}
|
|
1292
|
+
|
|
1293
|
+
const bytes = await module.arrayBuffer();
|
|
1294
|
+
return await WebAssembly.instantiate(bytes, imports);
|
|
1295
|
+
} else {
|
|
1296
|
+
const instance = await WebAssembly.instantiate(module, imports);
|
|
1297
|
+
|
|
1298
|
+
if (instance instanceof WebAssembly.Instance) {
|
|
1299
|
+
return { instance, module };
|
|
1300
|
+
} else {
|
|
1301
|
+
return instance;
|
|
1302
|
+
}
|
|
1303
|
+
}
|
|
1304
|
+
|
|
1305
|
+
function expectedResponseType(type) {
|
|
1306
|
+
switch (type) {
|
|
1307
|
+
case 'basic': case 'cors': case 'default': return true;
|
|
1308
|
+
}
|
|
1309
|
+
return false;
|
|
1310
|
+
}
|
|
1311
|
+
}
|
|
1312
|
+
|
|
1313
|
+
function initSync(module) {
|
|
1314
|
+
if (wasm !== undefined) return wasm;
|
|
1315
|
+
|
|
1316
|
+
|
|
1317
|
+
if (module !== undefined) {
|
|
1318
|
+
if (Object.getPrototypeOf(module) === Object.prototype) {
|
|
1319
|
+
({module} = module)
|
|
1320
|
+
} else {
|
|
1321
|
+
console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
|
|
1322
|
+
}
|
|
1323
|
+
}
|
|
1324
|
+
|
|
1325
|
+
const imports = __wbg_get_imports();
|
|
1326
|
+
if (!(module instanceof WebAssembly.Module)) {
|
|
1327
|
+
module = new WebAssembly.Module(module);
|
|
1328
|
+
}
|
|
1329
|
+
const instance = new WebAssembly.Instance(module, imports);
|
|
1330
|
+
return __wbg_finalize_init(instance, module);
|
|
1331
|
+
}
|
|
1332
|
+
|
|
1333
|
+
async function __wbg_init(module_or_path) {
|
|
1334
|
+
if (wasm !== undefined) return wasm;
|
|
1335
|
+
|
|
1336
|
+
|
|
1337
|
+
if (module_or_path !== undefined) {
|
|
1338
|
+
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
|
1339
|
+
({module_or_path} = module_or_path)
|
|
1340
|
+
} else {
|
|
1341
|
+
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
|
|
1342
|
+
}
|
|
1343
|
+
}
|
|
1344
|
+
|
|
1345
|
+
if (module_or_path === undefined) {
|
|
1346
|
+
module_or_path = new URL('libveritas_bg.wasm', import.meta.url);
|
|
1347
|
+
}
|
|
1348
|
+
const imports = __wbg_get_imports();
|
|
1349
|
+
|
|
1350
|
+
if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
|
|
1351
|
+
module_or_path = fetch(module_or_path);
|
|
1352
|
+
}
|
|
1353
|
+
|
|
1354
|
+
const { instance, module } = await __wbg_load(await module_or_path, imports);
|
|
1355
|
+
|
|
1356
|
+
return __wbg_finalize_init(instance, module);
|
|
1357
|
+
}
|
|
1358
|
+
|
|
1359
|
+
export { initSync, __wbg_init as default };
|
package/libveritas_bg.wasm
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,11 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spacesprotocol/libveritas",
|
|
3
|
-
"
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "0.0.0-dev.20260327154336",
|
|
4
5
|
"files": [
|
|
5
6
|
"libveritas_bg.wasm",
|
|
6
7
|
"libveritas.js",
|
|
7
8
|
"libveritas.d.ts"
|
|
8
9
|
],
|
|
9
10
|
"main": "libveritas.js",
|
|
10
|
-
"types": "libveritas.d.ts"
|
|
11
|
+
"types": "libveritas.d.ts",
|
|
12
|
+
"sideEffects": [
|
|
13
|
+
"./snippets/*"
|
|
14
|
+
],
|
|
15
|
+
"exports": {
|
|
16
|
+
".": {
|
|
17
|
+
"node": "./node.js",
|
|
18
|
+
"default": "./libveritas.js"
|
|
19
|
+
}
|
|
20
|
+
}
|
|
11
21
|
}
|