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

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
@@ -1,6 +1,13 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
3
 
4
+ export class Anchors {
5
+ free(): void;
6
+ [Symbol.dispose](): void;
7
+ computeAnchorSetHash(): Uint8Array;
8
+ constructor(json: string);
9
+ }
10
+
4
11
  /**
5
12
  * A message containing chain proofs and handle data.
6
13
  */
@@ -37,6 +44,22 @@ export class Message {
37
44
  export class MessageBuilder {
38
45
  free(): void;
39
46
  [Symbol.dispose](): void;
47
+ /**
48
+ * Add a single certificate.
49
+ */
50
+ addCert(cert_bytes: Uint8Array): void;
51
+ /**
52
+ * Add all certificates from a .spacecert chain.
53
+ */
54
+ addChain(chain_bytes: Uint8Array): void;
55
+ /**
56
+ * Add records for a handle.
57
+ */
58
+ addRecords(handle: string, records_bytes: Uint8Array): void;
59
+ /**
60
+ * Add a full data update (records + optional delegate records).
61
+ */
62
+ addUpdate(entry: any): void;
40
63
  /**
41
64
  * Build the message from a borsh-encoded ChainProof.
42
65
  *
@@ -50,16 +73,15 @@ export class MessageBuilder {
50
73
  */
51
74
  chain_proof_request(): any;
52
75
  /**
53
- * Create a builder from a JS array of update requests.
76
+ * Create an empty builder.
54
77
  *
55
78
  * ```js
56
- * let builder = new MessageBuilder([
57
- * { name: "@bitcoin", records: Uint8Array, cert: Uint8Array },
58
- * { name: "alice@bitcoin", records: Uint8Array, cert: Uint8Array }
59
- * ])
79
+ * let builder = new MessageBuilder()
80
+ * builder.addChain(chainBytes)
81
+ * builder.addRecords("alice@bitcoin", recordsBytes)
60
82
  * ```
61
83
  */
62
- constructor(requests: any);
84
+ constructor();
63
85
  }
64
86
 
65
87
  /**
@@ -191,7 +213,7 @@ export class Veritas {
191
213
  [Symbol.dispose](): void;
192
214
  computeAnchorSetHash(): Uint8Array;
193
215
  is_finalized(commitment_height: number): boolean;
194
- constructor(anchors: any);
216
+ constructor(anchors: Anchors);
195
217
  newest_anchor(): number;
196
218
  oldest_anchor(): number;
197
219
  sovereignty_for(commitment_height: number): string;
@@ -199,7 +221,7 @@ export class Veritas {
199
221
  * Verify a message against a query context.
200
222
  */
201
223
  verify_message(ctx: QueryContext, msg: Message): VerifiedMessage;
202
- static withDevMode(anchors: any): Veritas;
224
+ static withOptions(anchors: Anchors, expand_names: boolean, dev_mode: boolean): Veritas;
203
225
  }
204
226
 
205
227
  /**
package/libveritas.js CHANGED
@@ -1,5 +1,43 @@
1
1
  /* @ts-self-types="./libveritas.d.ts" */
2
2
 
3
+ class Anchors {
4
+ __destroy_into_raw() {
5
+ const ptr = this.__wbg_ptr;
6
+ this.__wbg_ptr = 0;
7
+ AnchorsFinalization.unregister(this);
8
+ return ptr;
9
+ }
10
+ free() {
11
+ const ptr = this.__destroy_into_raw();
12
+ wasm.__wbg_anchors_free(ptr, 0);
13
+ }
14
+ /**
15
+ * @returns {Uint8Array}
16
+ */
17
+ computeAnchorSetHash() {
18
+ const ret = wasm.anchors_computeAnchorSetHash(this.__wbg_ptr);
19
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
20
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
21
+ return v1;
22
+ }
23
+ /**
24
+ * @param {string} json
25
+ */
26
+ constructor(json) {
27
+ const ptr0 = passStringToWasm0(json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
28
+ const len0 = WASM_VECTOR_LEN;
29
+ const ret = wasm.anchors_from_json(ptr0, len0);
30
+ if (ret[2]) {
31
+ throw takeFromExternrefTable0(ret[1]);
32
+ }
33
+ this.__wbg_ptr = ret[0] >>> 0;
34
+ AnchorsFinalization.register(this, this.__wbg_ptr, this);
35
+ return this;
36
+ }
37
+ }
38
+ if (Symbol.dispose) Anchors.prototype[Symbol.dispose] = Anchors.prototype.free;
39
+ exports.Anchors = Anchors;
40
+
3
41
  /**
4
42
  * A message containing chain proofs and handle data.
5
43
  */
@@ -84,6 +122,55 @@ class MessageBuilder {
84
122
  const ptr = this.__destroy_into_raw();
85
123
  wasm.__wbg_messagebuilder_free(ptr, 0);
86
124
  }
125
+ /**
126
+ * Add a single certificate.
127
+ * @param {Uint8Array} cert_bytes
128
+ */
129
+ addCert(cert_bytes) {
130
+ const ptr0 = passArray8ToWasm0(cert_bytes, wasm.__wbindgen_malloc);
131
+ const len0 = WASM_VECTOR_LEN;
132
+ const ret = wasm.messagebuilder_addCert(this.__wbg_ptr, ptr0, len0);
133
+ if (ret[1]) {
134
+ throw takeFromExternrefTable0(ret[0]);
135
+ }
136
+ }
137
+ /**
138
+ * Add all certificates from a .spacecert chain.
139
+ * @param {Uint8Array} chain_bytes
140
+ */
141
+ addChain(chain_bytes) {
142
+ const ptr0 = passArray8ToWasm0(chain_bytes, wasm.__wbindgen_malloc);
143
+ const len0 = WASM_VECTOR_LEN;
144
+ const ret = wasm.messagebuilder_addChain(this.__wbg_ptr, ptr0, len0);
145
+ if (ret[1]) {
146
+ throw takeFromExternrefTable0(ret[0]);
147
+ }
148
+ }
149
+ /**
150
+ * Add records for a handle.
151
+ * @param {string} handle
152
+ * @param {Uint8Array} records_bytes
153
+ */
154
+ addRecords(handle, records_bytes) {
155
+ const ptr0 = passStringToWasm0(handle, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
156
+ const len0 = WASM_VECTOR_LEN;
157
+ const ptr1 = passArray8ToWasm0(records_bytes, wasm.__wbindgen_malloc);
158
+ const len1 = WASM_VECTOR_LEN;
159
+ const ret = wasm.messagebuilder_addRecords(this.__wbg_ptr, ptr0, len0, ptr1, len1);
160
+ if (ret[1]) {
161
+ throw takeFromExternrefTable0(ret[0]);
162
+ }
163
+ }
164
+ /**
165
+ * Add a full data update (records + optional delegate records).
166
+ * @param {any} entry
167
+ */
168
+ addUpdate(entry) {
169
+ const ret = wasm.messagebuilder_addUpdate(this.__wbg_ptr, entry);
170
+ if (ret[1]) {
171
+ throw takeFromExternrefTable0(ret[0]);
172
+ }
173
+ }
87
174
  /**
88
175
  * Build the message from a borsh-encoded ChainProof.
89
176
  *
@@ -114,22 +201,17 @@ class MessageBuilder {
114
201
  return takeFromExternrefTable0(ret[0]);
115
202
  }
116
203
  /**
117
- * Create a builder from a JS array of update requests.
204
+ * Create an empty builder.
118
205
  *
119
206
  * ```js
120
- * let builder = new MessageBuilder([
121
- * { name: "@bitcoin", records: Uint8Array, cert: Uint8Array },
122
- * { name: "alice@bitcoin", records: Uint8Array, cert: Uint8Array }
123
- * ])
207
+ * let builder = new MessageBuilder()
208
+ * builder.addChain(chainBytes)
209
+ * builder.addRecords("alice@bitcoin", recordsBytes)
124
210
  * ```
125
- * @param {any} requests
126
211
  */
127
- constructor(requests) {
128
- const ret = wasm.messagebuilder_new(requests);
129
- if (ret[2]) {
130
- throw takeFromExternrefTable0(ret[1]);
131
- }
132
- this.__wbg_ptr = ret[0] >>> 0;
212
+ constructor() {
213
+ const ret = wasm.messagebuilder_new();
214
+ this.__wbg_ptr = ret >>> 0;
133
215
  MessageBuilderFinalization.register(this, this.__wbg_ptr, this);
134
216
  return this;
135
217
  }
@@ -464,7 +546,10 @@ class VerifiedMessage {
464
546
  */
465
547
  zones() {
466
548
  const ret = wasm.verifiedmessage_zones(this.__wbg_ptr);
467
- return ret;
549
+ if (ret[2]) {
550
+ throw takeFromExternrefTable0(ret[1]);
551
+ }
552
+ return takeFromExternrefTable0(ret[0]);
468
553
  }
469
554
  }
470
555
  if (Symbol.dispose) VerifiedMessage.prototype[Symbol.dispose] = VerifiedMessage.prototype.free;
@@ -506,10 +591,11 @@ class Veritas {
506
591
  return ret !== 0;
507
592
  }
508
593
  /**
509
- * @param {any} anchors
594
+ * @param {Anchors} anchors
510
595
  */
511
596
  constructor(anchors) {
512
- const ret = wasm.veritas_new(anchors);
597
+ _assertClass(anchors, Anchors);
598
+ const ret = wasm.veritas_new(anchors.__wbg_ptr);
513
599
  if (ret[2]) {
514
600
  throw takeFromExternrefTable0(ret[1]);
515
601
  }
@@ -563,11 +649,14 @@ class Veritas {
563
649
  return VerifiedMessage.__wrap(ret[0]);
564
650
  }
565
651
  /**
566
- * @param {any} anchors
652
+ * @param {Anchors} anchors
653
+ * @param {boolean} expand_names
654
+ * @param {boolean} dev_mode
567
655
  * @returns {Veritas}
568
656
  */
569
- static withDevMode(anchors) {
570
- const ret = wasm.veritas_withDevMode(anchors);
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);
571
660
  if (ret[2]) {
572
661
  throw takeFromExternrefTable0(ret[1]);
573
662
  }
@@ -703,22 +792,6 @@ function __wbg_get_imports() {
703
792
  const ret = Error(getStringFromWasm0(arg0, arg1));
704
793
  return ret;
705
794
  },
706
- __wbg_Number_a5a435bd7bbec835: function(arg0) {
707
- const ret = Number(arg0);
708
- return ret;
709
- },
710
- __wbg_String_8564e559799eccda: function(arg0, arg1) {
711
- const ret = String(arg1);
712
- const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
713
- const len1 = WASM_VECTOR_LEN;
714
- getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
715
- getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
716
- },
717
- __wbg___wbindgen_boolean_get_c0f3f60bac5a78d1: function(arg0) {
718
- const v = arg0;
719
- const ret = typeof(v) === 'boolean' ? v : undefined;
720
- return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
721
- },
722
795
  __wbg___wbindgen_debug_string_5398f5bb970e0daa: function(arg0, arg1) {
723
796
  const ret = debugString(arg1);
724
797
  const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
@@ -726,31 +799,14 @@ function __wbg_get_imports() {
726
799
  getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
727
800
  getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
728
801
  },
729
- __wbg___wbindgen_in_41dbb8413020e076: function(arg0, arg1) {
730
- const ret = arg0 in arg1;
731
- return ret;
732
- },
733
- __wbg___wbindgen_is_function_3c846841762788c1: function(arg0) {
734
- const ret = typeof(arg0) === 'function';
735
- return ret;
736
- },
737
802
  __wbg___wbindgen_is_null_0b605fc6b167c56f: function(arg0) {
738
803
  const ret = arg0 === null;
739
804
  return ret;
740
805
  },
741
- __wbg___wbindgen_is_object_781bc9f159099513: function(arg0) {
742
- const val = arg0;
743
- const ret = typeof(val) === 'object' && val !== null;
744
- return ret;
745
- },
746
806
  __wbg___wbindgen_is_undefined_52709e72fb9f179c: function(arg0) {
747
807
  const ret = arg0 === undefined;
748
808
  return ret;
749
809
  },
750
- __wbg___wbindgen_jsval_loose_eq_5bcc3bed3c69e72b: function(arg0, arg1) {
751
- const ret = arg0 == arg1;
752
- return ret;
753
- },
754
810
  __wbg___wbindgen_number_get_34bb9d9dcfa21373: function(arg0, arg1) {
755
811
  const obj = arg1;
756
812
  const ret = typeof(obj) === 'number' ? obj : undefined;
@@ -768,22 +824,10 @@ function __wbg_get_imports() {
768
824
  __wbg___wbindgen_throw_6ddd609b62940d55: function(arg0, arg1) {
769
825
  throw new Error(getStringFromWasm0(arg0, arg1));
770
826
  },
771
- __wbg_call_e133b57c9155d22c: function() { return handleError(function (arg0, arg1) {
772
- const ret = arg0.call(arg1);
773
- return ret;
774
- }, arguments); },
775
- __wbg_done_08ce71ee07e3bd17: function(arg0) {
776
- const ret = arg0.done;
777
- return ret;
778
- },
779
827
  __wbg_from_4bdf88943703fd48: function(arg0) {
780
828
  const ret = Array.from(arg0);
781
829
  return ret;
782
830
  },
783
- __wbg_get_326e41e095fb2575: function() { return handleError(function (arg0, arg1) {
784
- const ret = Reflect.get(arg0, arg1);
785
- return ret;
786
- }, arguments); },
787
831
  __wbg_get_3ef1eba1850ade27: function() { return handleError(function (arg0, arg1) {
788
832
  const ret = Reflect.get(arg0, arg1);
789
833
  return ret;
@@ -792,46 +836,6 @@ function __wbg_get_imports() {
792
836
  const ret = arg0[arg1 >>> 0];
793
837
  return ret;
794
838
  },
795
- __wbg_get_unchecked_329cfe50afab7352: function(arg0, arg1) {
796
- const ret = arg0[arg1 >>> 0];
797
- return ret;
798
- },
799
- __wbg_get_with_ref_key_6412cf3094599694: function(arg0, arg1) {
800
- const ret = arg0[arg1];
801
- return ret;
802
- },
803
- __wbg_instanceof_ArrayBuffer_101e2bf31071a9f6: function(arg0) {
804
- let result;
805
- try {
806
- result = arg0 instanceof ArrayBuffer;
807
- } catch (_) {
808
- result = false;
809
- }
810
- const ret = result;
811
- return ret;
812
- },
813
- __wbg_instanceof_Uint8Array_740438561a5b956d: function(arg0) {
814
- let result;
815
- try {
816
- result = arg0 instanceof Uint8Array;
817
- } catch (_) {
818
- result = false;
819
- }
820
- const ret = result;
821
- return ret;
822
- },
823
- __wbg_isArray_33b91feb269ff46e: function(arg0) {
824
- const ret = Array.isArray(arg0);
825
- return ret;
826
- },
827
- __wbg_isSafeInteger_ecd6a7f9c3e053cd: function(arg0) {
828
- const ret = Number.isSafeInteger(arg0);
829
- return ret;
830
- },
831
- __wbg_iterator_d8f549ec8fb061b1: function() {
832
- const ret = Symbol.iterator;
833
- return ret;
834
- },
835
839
  __wbg_length_b3416cf66a5452c8: function(arg0) {
836
840
  const ret = arg0.length;
837
841
  return ret;
@@ -840,10 +844,6 @@ function __wbg_get_imports() {
840
844
  const ret = arg0.length;
841
845
  return ret;
842
846
  },
843
- __wbg_new_5f486cdf45a04d78: function(arg0) {
844
- const ret = new Uint8Array(arg0);
845
- return ret;
846
- },
847
847
  __wbg_new_a70fbab9066b301f: function() {
848
848
  const ret = new Array();
849
849
  return ret;
@@ -856,14 +856,6 @@ function __wbg_get_imports() {
856
856
  const ret = new Uint8Array(getArrayU8FromWasm0(arg0, arg1));
857
857
  return ret;
858
858
  },
859
- __wbg_next_11b99ee6237339e3: function() { return handleError(function (arg0) {
860
- const ret = arg0.next();
861
- return ret;
862
- }, arguments); },
863
- __wbg_next_e01a967809d1aa68: function(arg0) {
864
- const ret = arg0.next;
865
- return ret;
866
- },
867
859
  __wbg_parse_e9eddd2a82c706eb: function() { return handleError(function (arg0, arg1) {
868
860
  const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
869
861
  return ret;
@@ -879,10 +871,10 @@ function __wbg_get_imports() {
879
871
  const ret = Reflect.set(arg0, arg1, arg2);
880
872
  return ret;
881
873
  }, arguments); },
882
- __wbg_value_21fc78aab0322612: function(arg0) {
883
- const ret = arg0.value;
874
+ __wbg_stringify_5ae93966a84901ac: function() { return handleError(function (arg0) {
875
+ const ret = JSON.stringify(arg0);
884
876
  return ret;
885
- },
877
+ }, arguments); },
886
878
  __wbindgen_cast_0000000000000001: function(arg0) {
887
879
  // Cast intrinsic for `F64 -> Externref`.
888
880
  const ret = arg0;
@@ -914,6 +906,9 @@ function __wbg_get_imports() {
914
906
  };
915
907
  }
916
908
 
909
+ const AnchorsFinalization = (typeof FinalizationRegistry === 'undefined')
910
+ ? { register: () => {}, unregister: () => {} }
911
+ : new FinalizationRegistry(ptr => wasm.__wbg_anchors_free(ptr >>> 0, 1));
917
912
  const MessageFinalization = (typeof FinalizationRegistry === 'undefined')
918
913
  ? { register: () => {}, unregister: () => {} }
919
914
  : new FinalizationRegistry(ptr => wasm.__wbg_message_free(ptr >>> 0, 1));
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spacesprotocol/libveritas",
3
- "version": "0.0.0-dev.20260318155541",
3
+ "version": "0.0.0-dev.20260320120512",
4
4
  "files": [
5
5
  "libveritas_bg.wasm",
6
6
  "libveritas.js",