@spacesprotocol/libveritas 0.0.0-dev.20260306102312 → 0.0.0-dev.20260306131110

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/README.md CHANGED
@@ -16,27 +16,27 @@ npm install @spacesprotocol/libveritas
16
16
  import { Veritas, QueryContext } from "@spacesprotocol/libveritas";
17
17
 
18
18
  // Load trust anchors
19
- const veritas = new Veritas(anchors, false);
19
+ const veritas = new Veritas(anchors);
20
20
 
21
- console.log(`Anchors: ${veritas.oldest_anchor()} .. ${veritas.newest_anchor()}`);
21
+ console.log(`Anchors: ${veritas.oldestAnchor()} .. ${veritas.newestAnchor()}`);
22
22
 
23
23
  // Build query context (empty = verify all handles)
24
24
  const ctx = new QueryContext();
25
- ctx.add_request("alice@bitcoin");
25
+ ctx.addRequest("alice@bitcoin");
26
26
 
27
27
  // Verify a message (binary data from relay)
28
- const result = veritas.verify_message(ctx, messageBytes);
28
+ const result = veritas.verifyMessage(ctx, messageBytes);
29
29
 
30
30
  // Inspect verified zones
31
31
  for (const zone of result.zones()) {
32
32
  console.log(`${zone.handle()} -> ${zone.sovereignty()}`);
33
33
 
34
34
  // Store zone for later comparison
35
- const bytes = zone.to_bytes();
35
+ const bytes = zone.toBytes();
36
36
  }
37
37
 
38
38
  // Compare zones
39
- const better = newerZone.is_better_than(olderZone);
39
+ const better = newerZone.isBetterThan(olderZone);
40
40
 
41
41
  // Get certificates
42
42
  for (const cert of result.certificates()) {
@@ -57,18 +57,18 @@ let offchainBytes = OffchainData.from(rs, sig);
57
57
  // Build a message with certificates and offchain data
58
58
  let builder = new MessageBuilder([
59
59
  { name: "@bitcoin", cert: rootCertBytes },
60
- { name: "alice@bitcoin", offchain_data: offchainBytes, cert: leafCertBytes },
60
+ { name: "alice@bitcoin", offchainData: offchainBytes, cert: leafCertBytes },
61
61
  ]);
62
62
 
63
63
  // Get the chain proof request to send to a provider
64
- let request = builder.chain_proof_request();
64
+ let request = builder.chainProofRequest();
65
65
 
66
66
  // ... send request to provider, get chain proof back ...
67
67
 
68
68
  let msg = builder.build(chainProofBytes);
69
69
 
70
70
  // Serialize for transport
71
- let bytes = msg.to_bytes();
71
+ let bytes = msg.toBytes();
72
72
  ```
73
73
 
74
74
  ### Updating offchain data
@@ -82,10 +82,10 @@ let sig = wallet.signSchnorr(rs.id());
82
82
  let offchainBytes = OffchainData.from(rs, sig);
83
83
 
84
84
  msg.update([
85
- { name: "alice@bitcoin", offchain_data: offchainBytes },
85
+ { name: "alice@bitcoin", offchainData: offchainBytes },
86
86
  ]);
87
87
 
88
- let updatedBytes = msg.to_bytes();
88
+ let updatedBytes = msg.toBytes();
89
89
  ```
90
90
 
91
91
  ## Building from source
package/libveritas.d.ts CHANGED
@@ -148,7 +148,7 @@ export class Veritas {
148
148
  free(): void;
149
149
  [Symbol.dispose](): void;
150
150
  is_finalized(commitment_height: number): boolean;
151
- constructor(anchors: any, dev_mode: boolean);
151
+ constructor(anchors: any);
152
152
  newest_anchor(): number;
153
153
  oldest_anchor(): number;
154
154
  sovereignty_for(commitment_height: number): string;
@@ -156,6 +156,7 @@ export class Veritas {
156
156
  * Verify a message against a query context.
157
157
  */
158
158
  verify_message(ctx: QueryContext, msg: Uint8Array): VerifiedMessage;
159
+ static withDevMode(anchors: any): Veritas;
159
160
  }
160
161
 
161
162
  export class Zone {
package/libveritas.js CHANGED
@@ -352,6 +352,13 @@ if (Symbol.dispose) VerifiedMessage.prototype[Symbol.dispose] = VerifiedMessage.
352
352
  exports.VerifiedMessage = VerifiedMessage;
353
353
 
354
354
  class Veritas {
355
+ static __wrap(ptr) {
356
+ ptr = ptr >>> 0;
357
+ const obj = Object.create(Veritas.prototype);
358
+ obj.__wbg_ptr = ptr;
359
+ VeritasFinalization.register(obj, obj.__wbg_ptr, obj);
360
+ return obj;
361
+ }
355
362
  __destroy_into_raw() {
356
363
  const ptr = this.__wbg_ptr;
357
364
  this.__wbg_ptr = 0;
@@ -372,10 +379,9 @@ class Veritas {
372
379
  }
373
380
  /**
374
381
  * @param {any} anchors
375
- * @param {boolean} dev_mode
376
382
  */
377
- constructor(anchors, dev_mode) {
378
- const ret = wasm.veritas_new(anchors, dev_mode);
383
+ constructor(anchors) {
384
+ const ret = wasm.veritas_new(anchors);
379
385
  if (ret[2]) {
380
386
  throw takeFromExternrefTable0(ret[1]);
381
387
  }
@@ -429,6 +435,17 @@ class Veritas {
429
435
  }
430
436
  return VerifiedMessage.__wrap(ret[0]);
431
437
  }
438
+ /**
439
+ * @param {any} anchors
440
+ * @returns {Veritas}
441
+ */
442
+ static withDevMode(anchors) {
443
+ const ret = wasm.veritas_withDevMode(anchors);
444
+ if (ret[2]) {
445
+ throw takeFromExternrefTable0(ret[1]);
446
+ }
447
+ return Veritas.__wrap(ret[0]);
448
+ }
432
449
  }
433
450
  if (Symbol.dispose) Veritas.prototype[Symbol.dispose] = Veritas.prototype.free;
434
451
  exports.Veritas = Veritas;
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spacesprotocol/libveritas",
3
- "version": "0.0.0-dev.20260306102312",
3
+ "version": "0.0.0-dev.20260306131110",
4
4
  "files": [
5
5
  "libveritas_bg.wasm",
6
6
  "libveritas.js",