@spacesprotocol/libveritas 0.0.0-dev.20260308023827 → 0.0.0-dev.20260318032333

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
@@ -16,13 +16,13 @@ export class Message {
16
16
  */
17
17
  to_bytes(): Uint8Array;
18
18
  /**
19
- * Update offchain data on this message.
19
+ * Update records on this message.
20
20
  *
21
21
  * Accepts a JS array of data update entries:
22
22
  * ```js
23
23
  * msg.update([
24
- * { name: "alice@bitcoin", offchainData: Uint8Array },
25
- * { name: "@bitcoin", delegateOffchainData: Uint8Array }
24
+ * { name: "alice@bitcoin", records: Uint8Array },
25
+ * { name: "@bitcoin", delegateRecords: Uint8Array }
26
26
  * ])
27
27
  * ```
28
28
  *
@@ -54,8 +54,8 @@ export class MessageBuilder {
54
54
  *
55
55
  * ```js
56
56
  * let builder = new MessageBuilder([
57
- * { name: "@bitcoin", offchainData: Uint8Array, cert: Uint8Array },
58
- * { name: "alice@bitcoin", offchainData: Uint8Array, cert: Uint8Array }
57
+ * { name: "@bitcoin", records: Uint8Array, cert: Uint8Array },
58
+ * { name: "alice@bitcoin", records: Uint8Array, cert: Uint8Array }
59
59
  * ])
60
60
  * ```
61
61
  */
@@ -63,16 +63,20 @@ export class MessageBuilder {
63
63
  }
64
64
 
65
65
  /**
66
- * Helpers for constructing OffchainData.
66
+ * Helpers for constructing OffchainRecords (signed record sets).
67
+ *
68
+ * ```js
69
+ * const rs = RecordSet.pack([Record.seq(0), Record.txt("btc", "bc1qtest")]);
70
+ * const sig = await wallet.signSchnorr(rs.signingId());
71
+ * const bytes = OffchainRecords.from(rs, sig);
72
+ * ```
67
73
  */
68
- export class OffchainData {
74
+ export class OffchainRecords {
69
75
  private constructor();
70
76
  free(): void;
71
77
  [Symbol.dispose](): void;
72
78
  /**
73
- * Create borsh-encoded OffchainData from a RecordSet and a 64-byte Schnorr signature.
74
- *
75
- * Consumes the RecordSet.
79
+ * Create borsh-encoded OffchainRecords from a RecordSet and 64-byte signature.
76
80
  */
77
81
  static from(record_set: RecordSet, signature: Uint8Array): Uint8Array;
78
82
  }
@@ -93,25 +97,63 @@ export class QueryContext {
93
97
  }
94
98
 
95
99
  /**
96
- * Serialized records ready to be signed.
100
+ * Record constructors for building a RecordSet.
97
101
  *
98
102
  * ```js
99
- * let rs = new RecordSet(1, { nostr: "npub1...", ipv4: "127.0.0.1" });
100
- * let sig = wallet.signSchnorr(rs.id());
101
- * let offchainBytes = OffchainData.from(rs, sig);
103
+ * const rs = RecordSet.pack([
104
+ * Record.txt("btc", "bc1qtest"),
105
+ * Record.blob("avatar", pngBytes),
106
+ * Record.unknown(0x10, raw),
107
+ * ]);
108
+ * ```
109
+ */
110
+ export class Record {
111
+ private constructor();
112
+ free(): void;
113
+ [Symbol.dispose](): void;
114
+ static blob(key: string, value: Uint8Array): any;
115
+ static seq(version: bigint): any;
116
+ static txt(key: string, value: string): any;
117
+ static unknown(rtype: number, rdata: Uint8Array): any;
118
+ }
119
+
120
+ /**
121
+ * SIP-7 record set — wire-format encoded records.
122
+ *
123
+ * ```js
124
+ * // Pack from records
125
+ * const rs = RecordSet.pack([Record.txt("btc", "bc1qtest")]);
126
+ * const wire = rs.toBytes();
127
+ *
128
+ * // Load from wire bytes
129
+ * const rs = new RecordSet(wire);
130
+ * for (const r of rs.unpack()) { ... }
102
131
  * ```
103
132
  */
104
133
  export class RecordSet {
105
134
  free(): void;
106
135
  [Symbol.dispose](): void;
136
+ isEmpty(): boolean;
137
+ /**
138
+ * Wrap raw wire bytes (lazy — no parsing until unpack).
139
+ */
140
+ constructor(data: Uint8Array);
141
+ /**
142
+ * Pack records into wire format.
143
+ */
144
+ static pack(records: any): RecordSet;
145
+ /**
146
+ * The 32-byte signing hash (Spaces signed-message prefix + SHA256).
147
+ */
148
+ signingId(): Uint8Array;
107
149
  /**
108
- * The 32-byte hash to sign.
150
+ * Raw wire bytes.
109
151
  */
110
- id(): Uint8Array;
152
+ toBytes(): Uint8Array;
111
153
  /**
112
- * Create a record set from a sequence number and a JS object of key-value pairs.
154
+ * Parse all records.
113
155
  */
114
- constructor(seq: number, records: any);
156
+ unpack(): any;
115
157
  }
116
158
 
117
159
  /**
@@ -147,6 +189,7 @@ export class VerifiedMessage {
147
189
  export class Veritas {
148
190
  free(): void;
149
191
  [Symbol.dispose](): void;
192
+ computeAnchorSetHash(): Uint8Array;
150
193
  is_finalized(commitment_height: number): boolean;
151
194
  constructor(anchors: any);
152
195
  newest_anchor(): number;
@@ -163,6 +206,7 @@ export class Zone {
163
206
  private constructor();
164
207
  free(): void;
165
208
  [Symbol.dispose](): void;
209
+ alias(): string | undefined;
166
210
  anchor(): number;
167
211
  handle(): string;
168
212
  is_better_than(other: Zone): boolean;
package/libveritas.js CHANGED
@@ -47,13 +47,13 @@ class Message {
47
47
  return v1;
48
48
  }
49
49
  /**
50
- * Update offchain data on this message.
50
+ * Update records on this message.
51
51
  *
52
52
  * Accepts a JS array of data update entries:
53
53
  * ```js
54
54
  * msg.update([
55
- * { name: "alice@bitcoin", offchainData: Uint8Array },
56
- * { name: "@bitcoin", delegateOffchainData: Uint8Array }
55
+ * { name: "alice@bitcoin", records: Uint8Array },
56
+ * { name: "@bitcoin", delegateRecords: Uint8Array }
57
57
  * ])
58
58
  * ```
59
59
  *
@@ -118,8 +118,8 @@ class MessageBuilder {
118
118
  *
119
119
  * ```js
120
120
  * let builder = new MessageBuilder([
121
- * { name: "@bitcoin", offchainData: Uint8Array, cert: Uint8Array },
122
- * { name: "alice@bitcoin", offchainData: Uint8Array, cert: Uint8Array }
121
+ * { name: "@bitcoin", records: Uint8Array, cert: Uint8Array },
122
+ * { name: "alice@bitcoin", records: Uint8Array, cert: Uint8Array }
123
123
  * ])
124
124
  * ```
125
125
  * @param {any} requests
@@ -138,23 +138,27 @@ if (Symbol.dispose) MessageBuilder.prototype[Symbol.dispose] = MessageBuilder.pr
138
138
  exports.MessageBuilder = MessageBuilder;
139
139
 
140
140
  /**
141
- * Helpers for constructing OffchainData.
141
+ * Helpers for constructing OffchainRecords (signed record sets).
142
+ *
143
+ * ```js
144
+ * const rs = RecordSet.pack([Record.seq(0), Record.txt("btc", "bc1qtest")]);
145
+ * const sig = await wallet.signSchnorr(rs.signingId());
146
+ * const bytes = OffchainRecords.from(rs, sig);
147
+ * ```
142
148
  */
143
- class OffchainData {
149
+ class OffchainRecords {
144
150
  __destroy_into_raw() {
145
151
  const ptr = this.__wbg_ptr;
146
152
  this.__wbg_ptr = 0;
147
- OffchainDataFinalization.unregister(this);
153
+ OffchainRecordsFinalization.unregister(this);
148
154
  return ptr;
149
155
  }
150
156
  free() {
151
157
  const ptr = this.__destroy_into_raw();
152
- wasm.__wbg_offchaindata_free(ptr, 0);
158
+ wasm.__wbg_offchainrecords_free(ptr, 0);
153
159
  }
154
160
  /**
155
- * Create borsh-encoded OffchainData from a RecordSet and a 64-byte Schnorr signature.
156
- *
157
- * Consumes the RecordSet.
161
+ * Create borsh-encoded OffchainRecords from a RecordSet and 64-byte signature.
158
162
  * @param {RecordSet} record_set
159
163
  * @param {Uint8Array} signature
160
164
  * @returns {Uint8Array}
@@ -163,7 +167,7 @@ class OffchainData {
163
167
  _assertClass(record_set, RecordSet);
164
168
  const ptr0 = passArray8ToWasm0(signature, wasm.__wbindgen_malloc);
165
169
  const len0 = WASM_VECTOR_LEN;
166
- const ret = wasm.offchaindata_from(record_set.__wbg_ptr, ptr0, len0);
170
+ const ret = wasm.offchainrecords_from(record_set.__wbg_ptr, ptr0, len0);
167
171
  if (ret[3]) {
168
172
  throw takeFromExternrefTable0(ret[2]);
169
173
  }
@@ -172,8 +176,8 @@ class OffchainData {
172
176
  return v2;
173
177
  }
174
178
  }
175
- if (Symbol.dispose) OffchainData.prototype[Symbol.dispose] = OffchainData.prototype.free;
176
- exports.OffchainData = OffchainData;
179
+ if (Symbol.dispose) OffchainRecords.prototype[Symbol.dispose] = OffchainRecords.prototype.free;
180
+ exports.OffchainRecords = OffchainRecords;
177
181
 
178
182
  class QueryContext {
179
183
  __destroy_into_raw() {
@@ -222,15 +226,97 @@ if (Symbol.dispose) QueryContext.prototype[Symbol.dispose] = QueryContext.protot
222
226
  exports.QueryContext = QueryContext;
223
227
 
224
228
  /**
225
- * Serialized records ready to be signed.
229
+ * Record constructors for building a RecordSet.
230
+ *
231
+ * ```js
232
+ * const rs = RecordSet.pack([
233
+ * Record.txt("btc", "bc1qtest"),
234
+ * Record.blob("avatar", pngBytes),
235
+ * Record.unknown(0x10, raw),
236
+ * ]);
237
+ * ```
238
+ */
239
+ class Record {
240
+ __destroy_into_raw() {
241
+ const ptr = this.__wbg_ptr;
242
+ this.__wbg_ptr = 0;
243
+ RecordFinalization.unregister(this);
244
+ return ptr;
245
+ }
246
+ free() {
247
+ const ptr = this.__destroy_into_raw();
248
+ wasm.__wbg_record_free(ptr, 0);
249
+ }
250
+ /**
251
+ * @param {string} key
252
+ * @param {Uint8Array} value
253
+ * @returns {any}
254
+ */
255
+ static blob(key, value) {
256
+ const ptr0 = passStringToWasm0(key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
257
+ const len0 = WASM_VECTOR_LEN;
258
+ const ptr1 = passArray8ToWasm0(value, wasm.__wbindgen_malloc);
259
+ const len1 = WASM_VECTOR_LEN;
260
+ const ret = wasm.record_blob(ptr0, len0, ptr1, len1);
261
+ return ret;
262
+ }
263
+ /**
264
+ * @param {bigint} version
265
+ * @returns {any}
266
+ */
267
+ static seq(version) {
268
+ const ret = wasm.record_seq(version);
269
+ return ret;
270
+ }
271
+ /**
272
+ * @param {string} key
273
+ * @param {string} value
274
+ * @returns {any}
275
+ */
276
+ static txt(key, value) {
277
+ const ptr0 = passStringToWasm0(key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
278
+ const len0 = WASM_VECTOR_LEN;
279
+ const ptr1 = passStringToWasm0(value, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
280
+ const len1 = WASM_VECTOR_LEN;
281
+ const ret = wasm.record_txt(ptr0, len0, ptr1, len1);
282
+ return ret;
283
+ }
284
+ /**
285
+ * @param {number} rtype
286
+ * @param {Uint8Array} rdata
287
+ * @returns {any}
288
+ */
289
+ static unknown(rtype, rdata) {
290
+ const ptr0 = passArray8ToWasm0(rdata, wasm.__wbindgen_malloc);
291
+ const len0 = WASM_VECTOR_LEN;
292
+ const ret = wasm.record_unknown(rtype, ptr0, len0);
293
+ return ret;
294
+ }
295
+ }
296
+ if (Symbol.dispose) Record.prototype[Symbol.dispose] = Record.prototype.free;
297
+ exports.Record = Record;
298
+
299
+ /**
300
+ * SIP-7 record set — wire-format encoded records.
226
301
  *
227
302
  * ```js
228
- * let rs = new RecordSet(1, { nostr: "npub1...", ipv4: "127.0.0.1" });
229
- * let sig = wallet.signSchnorr(rs.id());
230
- * let offchainBytes = OffchainData.from(rs, sig);
303
+ * // Pack from records
304
+ * const rs = RecordSet.pack([Record.txt("btc", "bc1qtest")]);
305
+ * const wire = rs.toBytes();
306
+ *
307
+ * // Load from wire bytes
308
+ * const rs = new RecordSet(wire);
309
+ * for (const r of rs.unpack()) { ... }
231
310
  * ```
232
311
  */
233
312
  class RecordSet {
313
+ static __wrap(ptr) {
314
+ ptr = ptr >>> 0;
315
+ const obj = Object.create(RecordSet.prototype);
316
+ obj.__wbg_ptr = ptr;
317
+ RecordSetFinalization.register(obj, obj.__wbg_ptr, obj);
318
+ return obj;
319
+ }
234
320
  __destroy_into_raw() {
235
321
  const ptr = this.__wbg_ptr;
236
322
  this.__wbg_ptr = 0;
@@ -242,31 +328,66 @@ class RecordSet {
242
328
  wasm.__wbg_recordset_free(ptr, 0);
243
329
  }
244
330
  /**
245
- * The 32-byte hash to sign.
246
- * @returns {Uint8Array}
331
+ * @returns {boolean}
247
332
  */
248
- id() {
249
- const ret = wasm.recordset_id(this.__wbg_ptr);
250
- if (ret[3]) {
251
- throw takeFromExternrefTable0(ret[2]);
333
+ isEmpty() {
334
+ const ret = wasm.recordset_isEmpty(this.__wbg_ptr);
335
+ return ret !== 0;
336
+ }
337
+ /**
338
+ * Wrap raw wire bytes (lazy — no parsing until unpack).
339
+ * @param {Uint8Array} data
340
+ */
341
+ constructor(data) {
342
+ const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
343
+ const len0 = WASM_VECTOR_LEN;
344
+ const ret = wasm.recordset_new(ptr0, len0);
345
+ this.__wbg_ptr = ret >>> 0;
346
+ RecordSetFinalization.register(this, this.__wbg_ptr, this);
347
+ return this;
348
+ }
349
+ /**
350
+ * Pack records into wire format.
351
+ * @param {any} records
352
+ * @returns {RecordSet}
353
+ */
354
+ static pack(records) {
355
+ const ret = wasm.recordset_pack(records);
356
+ if (ret[2]) {
357
+ throw takeFromExternrefTable0(ret[1]);
252
358
  }
359
+ return RecordSet.__wrap(ret[0]);
360
+ }
361
+ /**
362
+ * The 32-byte signing hash (Spaces signed-message prefix + SHA256).
363
+ * @returns {Uint8Array}
364
+ */
365
+ signingId() {
366
+ const ret = wasm.recordset_signingId(this.__wbg_ptr);
253
367
  var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
254
368
  wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
255
369
  return v1;
256
370
  }
257
371
  /**
258
- * Create a record set from a sequence number and a JS object of key-value pairs.
259
- * @param {number} seq
260
- * @param {any} records
372
+ * Raw wire bytes.
373
+ * @returns {Uint8Array}
261
374
  */
262
- constructor(seq, records) {
263
- const ret = wasm.recordset_new(seq, records);
375
+ toBytes() {
376
+ const ret = wasm.recordset_toBytes(this.__wbg_ptr);
377
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
378
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
379
+ return v1;
380
+ }
381
+ /**
382
+ * Parse all records.
383
+ * @returns {any}
384
+ */
385
+ unpack() {
386
+ const ret = wasm.recordset_unpack(this.__wbg_ptr);
264
387
  if (ret[2]) {
265
388
  throw takeFromExternrefTable0(ret[1]);
266
389
  }
267
- this.__wbg_ptr = ret[0] >>> 0;
268
- RecordSetFinalization.register(this, this.__wbg_ptr, this);
269
- return this;
390
+ return takeFromExternrefTable0(ret[0]);
270
391
  }
271
392
  }
272
393
  if (Symbol.dispose) RecordSet.prototype[Symbol.dispose] = RecordSet.prototype.free;
@@ -369,6 +490,15 @@ class Veritas {
369
490
  const ptr = this.__destroy_into_raw();
370
491
  wasm.__wbg_veritas_free(ptr, 0);
371
492
  }
493
+ /**
494
+ * @returns {Uint8Array}
495
+ */
496
+ computeAnchorSetHash() {
497
+ const ret = wasm.veritas_computeAnchorSetHash(this.__wbg_ptr);
498
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
499
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
500
+ return v1;
501
+ }
372
502
  /**
373
503
  * @param {number} commitment_height
374
504
  * @returns {boolean}
@@ -467,6 +597,18 @@ class Zone {
467
597
  const ptr = this.__destroy_into_raw();
468
598
  wasm.__wbg_zone_free(ptr, 0);
469
599
  }
600
+ /**
601
+ * @returns {string | undefined}
602
+ */
603
+ alias() {
604
+ const ret = wasm.zone_alias(this.__wbg_ptr);
605
+ let v1;
606
+ if (ret[0] !== 0) {
607
+ v1 = getStringFromWasm0(ret[0], ret[1]).slice();
608
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
609
+ }
610
+ return v1;
611
+ }
470
612
  /**
471
613
  * @returns {number}
472
614
  */
@@ -708,10 +850,6 @@ function __wbg_get_imports() {
708
850
  const ret = arg0.done;
709
851
  return ret;
710
852
  },
711
- __wbg_entries_e8a20ff8c9757101: function(arg0) {
712
- const ret = Object.entries(arg0);
713
- return ret;
714
- },
715
853
  __wbg_from_4bdf88943703fd48: function(arg0) {
716
854
  const ret = Array.from(arg0);
717
855
  return ret;
@@ -780,6 +918,18 @@ function __wbg_get_imports() {
780
918
  const ret = new Uint8Array(arg0);
781
919
  return ret;
782
920
  },
921
+ __wbg_new_a70fbab9066b301f: function() {
922
+ const ret = new Array();
923
+ return ret;
924
+ },
925
+ __wbg_new_ab79df5bd7c26067: function() {
926
+ const ret = new Object();
927
+ return ret;
928
+ },
929
+ __wbg_new_from_slice_22da9388ac046e50: function(arg0, arg1) {
930
+ const ret = new Uint8Array(getArrayU8FromWasm0(arg0, arg1));
931
+ return ret;
932
+ },
783
933
  __wbg_next_11b99ee6237339e3: function() { return handleError(function (arg0) {
784
934
  const ret = arg0.next();
785
935
  return ret;
@@ -795,6 +945,14 @@ function __wbg_get_imports() {
795
945
  __wbg_prototypesetcall_d62e5099504357e6: function(arg0, arg1, arg2) {
796
946
  Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
797
947
  },
948
+ __wbg_push_e87b0e732085a946: function(arg0, arg1) {
949
+ const ret = arg0.push(arg1);
950
+ return ret;
951
+ },
952
+ __wbg_set_7eaa4f96924fd6b3: function() { return handleError(function (arg0, arg1, arg2) {
953
+ const ret = Reflect.set(arg0, arg1, arg2);
954
+ return ret;
955
+ }, arguments); },
798
956
  __wbg_value_21fc78aab0322612: function(arg0) {
799
957
  const ret = arg0.value;
800
958
  return ret;
@@ -803,11 +961,21 @@ function __wbg_get_imports() {
803
961
  const ret = Zone.__wrap(arg0);
804
962
  return ret;
805
963
  },
806
- __wbindgen_cast_0000000000000001: function(arg0, arg1) {
964
+ __wbindgen_cast_0000000000000001: function(arg0) {
965
+ // Cast intrinsic for `F64 -> Externref`.
966
+ const ret = arg0;
967
+ return ret;
968
+ },
969
+ __wbindgen_cast_0000000000000002: function(arg0, arg1) {
807
970
  // Cast intrinsic for `Ref(String) -> Externref`.
808
971
  const ret = getStringFromWasm0(arg0, arg1);
809
972
  return ret;
810
973
  },
974
+ __wbindgen_cast_0000000000000003: function(arg0) {
975
+ // Cast intrinsic for `U64 -> Externref`.
976
+ const ret = BigInt.asUintN(64, arg0);
977
+ return ret;
978
+ },
811
979
  __wbindgen_init_externref_table: function() {
812
980
  const table = wasm.__wbindgen_externrefs;
813
981
  const offset = table.grow(4);
@@ -830,12 +998,15 @@ const MessageFinalization = (typeof FinalizationRegistry === 'undefined')
830
998
  const MessageBuilderFinalization = (typeof FinalizationRegistry === 'undefined')
831
999
  ? { register: () => {}, unregister: () => {} }
832
1000
  : new FinalizationRegistry(ptr => wasm.__wbg_messagebuilder_free(ptr >>> 0, 1));
833
- const OffchainDataFinalization = (typeof FinalizationRegistry === 'undefined')
1001
+ const OffchainRecordsFinalization = (typeof FinalizationRegistry === 'undefined')
834
1002
  ? { register: () => {}, unregister: () => {} }
835
- : new FinalizationRegistry(ptr => wasm.__wbg_offchaindata_free(ptr >>> 0, 1));
1003
+ : new FinalizationRegistry(ptr => wasm.__wbg_offchainrecords_free(ptr >>> 0, 1));
836
1004
  const QueryContextFinalization = (typeof FinalizationRegistry === 'undefined')
837
1005
  ? { register: () => {}, unregister: () => {} }
838
1006
  : new FinalizationRegistry(ptr => wasm.__wbg_querycontext_free(ptr >>> 0, 1));
1007
+ const RecordFinalization = (typeof FinalizationRegistry === 'undefined')
1008
+ ? { register: () => {}, unregister: () => {} }
1009
+ : new FinalizationRegistry(ptr => wasm.__wbg_record_free(ptr >>> 0, 1));
839
1010
  const RecordSetFinalization = (typeof FinalizationRegistry === 'undefined')
840
1011
  ? { register: () => {}, unregister: () => {} }
841
1012
  : new FinalizationRegistry(ptr => wasm.__wbg_recordset_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.20260308023827",
3
+ "version": "0.0.0-dev.20260318032333",
4
4
  "files": [
5
5
  "libveritas_bg.wasm",
6
6
  "libveritas.js",