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

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
@@ -13,30 +13,31 @@ npm install @spacesprotocol/libveritas
13
13
  ### Verifying a message
14
14
 
15
15
  ```javascript
16
- import { Veritas, QueryContext } from "@spacesprotocol/libveritas";
16
+ import { Veritas, QueryContext, Message } 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 msg = new Message(messageBytes);
29
+ const result = veritas.verifyMessage(ctx, msg);
29
30
 
30
31
  // Inspect verified zones
31
32
  for (const zone of result.zones()) {
32
33
  console.log(`${zone.handle()} -> ${zone.sovereignty()}`);
33
34
 
34
35
  // Store zone for later comparison
35
- const bytes = zone.to_bytes();
36
+ const bytes = zone.toBytes();
36
37
  }
37
38
 
38
39
  // Compare zones
39
- const better = newerZone.is_better_than(olderZone);
40
+ const better = newerZone.isBetterThan(olderZone);
40
41
 
41
42
  // Get certificates
42
43
  for (const cert of result.certificates()) {
@@ -57,18 +58,18 @@ let offchainBytes = OffchainData.from(rs, sig);
57
58
  // Build a message with certificates and offchain data
58
59
  let builder = new MessageBuilder([
59
60
  { name: "@bitcoin", cert: rootCertBytes },
60
- { name: "alice@bitcoin", offchain_data: offchainBytes, cert: leafCertBytes },
61
+ { name: "alice@bitcoin", offchainData: offchainBytes, cert: leafCertBytes },
61
62
  ]);
62
63
 
63
64
  // Get the chain proof request to send to a provider
64
- let request = builder.chain_proof_request();
65
+ let request = builder.chainProofRequest();
65
66
 
66
67
  // ... send request to provider, get chain proof back ...
67
68
 
68
69
  let msg = builder.build(chainProofBytes);
69
70
 
70
71
  // Serialize for transport
71
- let bytes = msg.to_bytes();
72
+ let bytes = msg.toBytes();
72
73
  ```
73
74
 
74
75
  ### Updating offchain data
@@ -82,10 +83,10 @@ let sig = wallet.signSchnorr(rs.id());
82
83
  let offchainBytes = OffchainData.from(rs, sig);
83
84
 
84
85
  msg.update([
85
- { name: "alice@bitcoin", offchain_data: offchainBytes },
86
+ { name: "alice@bitcoin", offchainData: offchainBytes },
86
87
  ]);
87
88
 
88
- let updatedBytes = msg.to_bytes();
89
+ let updatedBytes = msg.toBytes();
89
90
  ```
90
91
 
91
92
  ## Building from source
package/libveritas.d.ts CHANGED
@@ -148,14 +148,15 @@ 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;
155
155
  /**
156
156
  * Verify a message against a query context.
157
157
  */
158
- verify_message(ctx: QueryContext, msg: Uint8Array): VerifiedMessage;
158
+ verify_message(ctx: QueryContext, msg: Message): 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
  }
@@ -416,19 +422,29 @@ class Veritas {
416
422
  /**
417
423
  * Verify a message against a query context.
418
424
  * @param {QueryContext} ctx
419
- * @param {Uint8Array} msg
425
+ * @param {Message} msg
420
426
  * @returns {VerifiedMessage}
421
427
  */
422
428
  verify_message(ctx, msg) {
423
429
  _assertClass(ctx, QueryContext);
424
- const ptr0 = passArray8ToWasm0(msg, wasm.__wbindgen_malloc);
425
- const len0 = WASM_VECTOR_LEN;
426
- const ret = wasm.veritas_verify_message(this.__wbg_ptr, ctx.__wbg_ptr, ptr0, len0);
430
+ _assertClass(msg, Message);
431
+ const ret = wasm.veritas_verify_message(this.__wbg_ptr, ctx.__wbg_ptr, msg.__wbg_ptr);
427
432
  if (ret[2]) {
428
433
  throw takeFromExternrefTable0(ret[1]);
429
434
  }
430
435
  return VerifiedMessage.__wrap(ret[0]);
431
436
  }
437
+ /**
438
+ * @param {any} anchors
439
+ * @returns {Veritas}
440
+ */
441
+ static withDevMode(anchors) {
442
+ const ret = wasm.veritas_withDevMode(anchors);
443
+ if (ret[2]) {
444
+ throw takeFromExternrefTable0(ret[1]);
445
+ }
446
+ return Veritas.__wrap(ret[0]);
447
+ }
432
448
  }
433
449
  if (Symbol.dispose) Veritas.prototype[Symbol.dispose] = Veritas.prototype.free;
434
450
  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.20260306204125",
4
4
  "files": [
5
5
  "libveritas_bg.wasm",
6
6
  "libveritas.js",