@spacesprotocol/libveritas 0.0.0-dev.20260320120512 → 0.0.0-dev.20260322184924

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 CHANGED
@@ -8,6 +8,31 @@ export class Anchors {
8
8
  constructor(json: string);
9
9
  }
10
10
 
11
+ /**
12
+ * Batched iterative resolver for nested handle names.
13
+ */
14
+ export class Lookup {
15
+ free(): void;
16
+ [Symbol.dispose](): void;
17
+ /**
18
+ * Feed zones from a resolveAll response.
19
+ * Returns the next batch of handles to look up (empty = done).
20
+ */
21
+ advance(zones: any): string[];
22
+ /**
23
+ * Expand zone handles using the alias map accumulated during resolution.
24
+ */
25
+ expandZones(zones: any): any;
26
+ /**
27
+ * Create a lookup from an array of handle name strings.
28
+ */
29
+ constructor(names: string[]);
30
+ /**
31
+ * Returns the first batch of handles to look up.
32
+ */
33
+ start(): string[];
34
+ }
35
+
11
36
  /**
12
37
  * A message containing chain proofs and handle data.
13
38
  */
@@ -52,6 +77,10 @@ export class MessageBuilder {
52
77
  * Add all certificates from a .spacecert chain.
53
78
  */
54
79
  addChain(chain_bytes: Uint8Array): void;
80
+ /**
81
+ * Add a .spacecert chain with records.
82
+ */
83
+ addHandle(chain_bytes: Uint8Array, records_bytes: Uint8Array): void;
55
84
  /**
56
85
  * Add records for a handle.
57
86
  */
@@ -178,6 +207,12 @@ export class RecordSet {
178
207
  unpack(): any;
179
208
  }
180
209
 
210
+ export function VERIFY_DEFAULT(): number;
211
+
212
+ export function VERIFY_DEV_MODE(): number;
213
+
214
+ export function VERIFY_ENABLE_SNARK(): number;
215
+
181
216
  /**
182
217
  * Result of verifying a message.
183
218
  */
@@ -218,10 +253,13 @@ export class Veritas {
218
253
  oldest_anchor(): number;
219
254
  sovereignty_for(commitment_height: number): string;
220
255
  /**
221
- * Verify a message against a query context.
256
+ * Verify a message with default options.
257
+ */
258
+ verify(ctx: QueryContext, msg: Message): VerifiedMessage;
259
+ /**
260
+ * Verify a message with option flags (combine with bitwise OR).
222
261
  */
223
- verify_message(ctx: QueryContext, msg: Message): VerifiedMessage;
224
- static withOptions(anchors: Anchors, expand_names: boolean, dev_mode: boolean): Veritas;
262
+ verifyWithOptions(ctx: QueryContext, msg: Message, options: number): VerifiedMessage;
225
263
  }
226
264
 
227
265
  /**
package/libveritas.js CHANGED
@@ -38,6 +38,76 @@ class Anchors {
38
38
  if (Symbol.dispose) Anchors.prototype[Symbol.dispose] = Anchors.prototype.free;
39
39
  exports.Anchors = Anchors;
40
40
 
41
+ /**
42
+ * Batched iterative resolver for nested handle names.
43
+ */
44
+ class Lookup {
45
+ __destroy_into_raw() {
46
+ const ptr = this.__wbg_ptr;
47
+ this.__wbg_ptr = 0;
48
+ LookupFinalization.unregister(this);
49
+ return ptr;
50
+ }
51
+ free() {
52
+ const ptr = this.__destroy_into_raw();
53
+ wasm.__wbg_lookup_free(ptr, 0);
54
+ }
55
+ /**
56
+ * Feed zones from a resolveAll response.
57
+ * Returns the next batch of handles to look up (empty = done).
58
+ * @param {any} zones
59
+ * @returns {string[]}
60
+ */
61
+ advance(zones) {
62
+ const ret = wasm.lookup_advance(this.__wbg_ptr, zones);
63
+ if (ret[3]) {
64
+ throw takeFromExternrefTable0(ret[2]);
65
+ }
66
+ var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
67
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
68
+ return v1;
69
+ }
70
+ /**
71
+ * Expand zone handles using the alias map accumulated during resolution.
72
+ * @param {any} zones
73
+ * @returns {any}
74
+ */
75
+ expandZones(zones) {
76
+ const ret = wasm.lookup_expandZones(this.__wbg_ptr, zones);
77
+ if (ret[2]) {
78
+ throw takeFromExternrefTable0(ret[1]);
79
+ }
80
+ return takeFromExternrefTable0(ret[0]);
81
+ }
82
+ /**
83
+ * Create a lookup from an array of handle name strings.
84
+ * @param {string[]} names
85
+ */
86
+ constructor(names) {
87
+ const ptr0 = passArrayJsValueToWasm0(names, wasm.__wbindgen_malloc);
88
+ const len0 = WASM_VECTOR_LEN;
89
+ const ret = wasm.lookup_new(ptr0, len0);
90
+ if (ret[2]) {
91
+ throw takeFromExternrefTable0(ret[1]);
92
+ }
93
+ this.__wbg_ptr = ret[0] >>> 0;
94
+ LookupFinalization.register(this, this.__wbg_ptr, this);
95
+ return this;
96
+ }
97
+ /**
98
+ * Returns the first batch of handles to look up.
99
+ * @returns {string[]}
100
+ */
101
+ start() {
102
+ const ret = wasm.lookup_start(this.__wbg_ptr);
103
+ var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
104
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
105
+ return v1;
106
+ }
107
+ }
108
+ if (Symbol.dispose) Lookup.prototype[Symbol.dispose] = Lookup.prototype.free;
109
+ exports.Lookup = Lookup;
110
+
41
111
  /**
42
112
  * A message containing chain proofs and handle data.
43
113
  */
@@ -146,6 +216,21 @@ class MessageBuilder {
146
216
  throw takeFromExternrefTable0(ret[0]);
147
217
  }
148
218
  }
219
+ /**
220
+ * Add a .spacecert chain with records.
221
+ * @param {Uint8Array} chain_bytes
222
+ * @param {Uint8Array} records_bytes
223
+ */
224
+ addHandle(chain_bytes, records_bytes) {
225
+ const ptr0 = passArray8ToWasm0(chain_bytes, wasm.__wbindgen_malloc);
226
+ const len0 = WASM_VECTOR_LEN;
227
+ const ptr1 = passArray8ToWasm0(records_bytes, wasm.__wbindgen_malloc);
228
+ const len1 = WASM_VECTOR_LEN;
229
+ const ret = wasm.messagebuilder_addHandle(this.__wbg_ptr, ptr0, len0, ptr1, len1);
230
+ if (ret[1]) {
231
+ throw takeFromExternrefTable0(ret[0]);
232
+ }
233
+ }
149
234
  /**
150
235
  * Add records for a handle.
151
236
  * @param {string} handle
@@ -475,6 +560,33 @@ class RecordSet {
475
560
  if (Symbol.dispose) RecordSet.prototype[Symbol.dispose] = RecordSet.prototype.free;
476
561
  exports.RecordSet = RecordSet;
477
562
 
563
+ /**
564
+ * @returns {number}
565
+ */
566
+ function VERIFY_DEFAULT() {
567
+ const ret = wasm.VERIFY_DEFAULT();
568
+ return ret >>> 0;
569
+ }
570
+ exports.VERIFY_DEFAULT = VERIFY_DEFAULT;
571
+
572
+ /**
573
+ * @returns {number}
574
+ */
575
+ function VERIFY_DEV_MODE() {
576
+ const ret = wasm.VERIFY_DEV_MODE();
577
+ return ret >>> 0;
578
+ }
579
+ exports.VERIFY_DEV_MODE = VERIFY_DEV_MODE;
580
+
581
+ /**
582
+ * @returns {number}
583
+ */
584
+ function VERIFY_ENABLE_SNARK() {
585
+ const ret = wasm.VERIFY_ENABLE_SNARK();
586
+ return ret >>> 0;
587
+ }
588
+ exports.VERIFY_ENABLE_SNARK = VERIFY_ENABLE_SNARK;
589
+
478
590
  /**
479
591
  * Result of verifying a message.
480
592
  */
@@ -556,13 +668,6 @@ if (Symbol.dispose) VerifiedMessage.prototype[Symbol.dispose] = VerifiedMessage.
556
668
  exports.VerifiedMessage = VerifiedMessage;
557
669
 
558
670
  class Veritas {
559
- static __wrap(ptr) {
560
- ptr = ptr >>> 0;
561
- const obj = Object.create(Veritas.prototype);
562
- obj.__wbg_ptr = ptr;
563
- VeritasFinalization.register(obj, obj.__wbg_ptr, obj);
564
- return obj;
565
- }
566
671
  __destroy_into_raw() {
567
672
  const ptr = this.__wbg_ptr;
568
673
  this.__wbg_ptr = 0;
@@ -634,33 +739,35 @@ class Veritas {
634
739
  }
635
740
  }
636
741
  /**
637
- * Verify a message against a query context.
742
+ * Verify a message with default options.
638
743
  * @param {QueryContext} ctx
639
744
  * @param {Message} msg
640
745
  * @returns {VerifiedMessage}
641
746
  */
642
- verify_message(ctx, msg) {
747
+ verify(ctx, msg) {
643
748
  _assertClass(ctx, QueryContext);
644
749
  _assertClass(msg, Message);
645
- const ret = wasm.veritas_verify_message(this.__wbg_ptr, ctx.__wbg_ptr, msg.__wbg_ptr);
750
+ const ret = wasm.veritas_verify(this.__wbg_ptr, ctx.__wbg_ptr, msg.__wbg_ptr);
646
751
  if (ret[2]) {
647
752
  throw takeFromExternrefTable0(ret[1]);
648
753
  }
649
754
  return VerifiedMessage.__wrap(ret[0]);
650
755
  }
651
756
  /**
652
- * @param {Anchors} anchors
653
- * @param {boolean} expand_names
654
- * @param {boolean} dev_mode
655
- * @returns {Veritas}
757
+ * Verify a message with option flags (combine with bitwise OR).
758
+ * @param {QueryContext} ctx
759
+ * @param {Message} msg
760
+ * @param {number} options
761
+ * @returns {VerifiedMessage}
656
762
  */
657
- static withOptions(anchors, expand_names, dev_mode) {
658
- _assertClass(anchors, Anchors);
659
- const ret = wasm.veritas_withOptions(anchors.__wbg_ptr, expand_names, dev_mode);
763
+ verifyWithOptions(ctx, msg, options) {
764
+ _assertClass(ctx, QueryContext);
765
+ _assertClass(msg, Message);
766
+ const ret = wasm.veritas_verifyWithOptions(this.__wbg_ptr, ctx.__wbg_ptr, msg.__wbg_ptr, options);
660
767
  if (ret[2]) {
661
768
  throw takeFromExternrefTable0(ret[1]);
662
769
  }
663
- return Veritas.__wrap(ret[0]);
770
+ return VerifiedMessage.__wrap(ret[0]);
664
771
  }
665
772
  }
666
773
  if (Symbol.dispose) Veritas.prototype[Symbol.dispose] = Veritas.prototype.free;
@@ -909,6 +1016,9 @@ function __wbg_get_imports() {
909
1016
  const AnchorsFinalization = (typeof FinalizationRegistry === 'undefined')
910
1017
  ? { register: () => {}, unregister: () => {} }
911
1018
  : new FinalizationRegistry(ptr => wasm.__wbg_anchors_free(ptr >>> 0, 1));
1019
+ const LookupFinalization = (typeof FinalizationRegistry === 'undefined')
1020
+ ? { register: () => {}, unregister: () => {} }
1021
+ : new FinalizationRegistry(ptr => wasm.__wbg_lookup_free(ptr >>> 0, 1));
912
1022
  const MessageFinalization = (typeof FinalizationRegistry === 'undefined')
913
1023
  ? { register: () => {}, unregister: () => {} }
914
1024
  : new FinalizationRegistry(ptr => wasm.__wbg_message_free(ptr >>> 0, 1));
@@ -1011,6 +1121,17 @@ function debugString(val) {
1011
1121
  return className;
1012
1122
  }
1013
1123
 
1124
+ function getArrayJsValueFromWasm0(ptr, len) {
1125
+ ptr = ptr >>> 0;
1126
+ const mem = getDataViewMemory0();
1127
+ const result = [];
1128
+ for (let i = ptr; i < ptr + 4 * len; i += 4) {
1129
+ result.push(wasm.__wbindgen_externrefs.get(mem.getUint32(i, true)));
1130
+ }
1131
+ wasm.__externref_drop_slice(ptr, len);
1132
+ return result;
1133
+ }
1134
+
1014
1135
  function getArrayU8FromWasm0(ptr, len) {
1015
1136
  ptr = ptr >>> 0;
1016
1137
  return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
@@ -1057,6 +1178,16 @@ function passArray8ToWasm0(arg, malloc) {
1057
1178
  return ptr;
1058
1179
  }
1059
1180
 
1181
+ function passArrayJsValueToWasm0(array, malloc) {
1182
+ const ptr = malloc(array.length * 4, 4) >>> 0;
1183
+ for (let i = 0; i < array.length; i++) {
1184
+ const add = addToExternrefTable0(array[i]);
1185
+ getDataViewMemory0().setUint32(ptr + 4 * i, add, true);
1186
+ }
1187
+ WASM_VECTOR_LEN = array.length;
1188
+ return ptr;
1189
+ }
1190
+
1060
1191
  function passStringToWasm0(arg, malloc, realloc) {
1061
1192
  if (realloc === undefined) {
1062
1193
  const buf = cachedTextEncoder.encode(arg);
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spacesprotocol/libveritas",
3
- "version": "0.0.0-dev.20260320120512",
3
+ "version": "0.0.0-dev.20260322184924",
4
4
  "files": [
5
5
  "libveritas_bg.wasm",
6
6
  "libveritas.js",