@spacesprotocol/libveritas 0.0.0-dev.20260306225014 → 0.0.0-dev.20260317233723

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
  /**
@@ -163,6 +205,7 @@ export class Zone {
163
205
  private constructor();
164
206
  free(): void;
165
207
  [Symbol.dispose](): void;
208
+ alias(): string | undefined;
166
209
  anchor(): number;
167
210
  handle(): string;
168
211
  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.
226
230
  *
227
231
  * ```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);
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.
301
+ *
302
+ * ```js
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}
374
+ */
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}
261
384
  */
262
- constructor(seq, records) {
263
- const ret = wasm.recordset_new(seq, records);
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;
@@ -467,6 +588,18 @@ class Zone {
467
588
  const ptr = this.__destroy_into_raw();
468
589
  wasm.__wbg_zone_free(ptr, 0);
469
590
  }
591
+ /**
592
+ * @returns {string | undefined}
593
+ */
594
+ alias() {
595
+ const ret = wasm.zone_alias(this.__wbg_ptr);
596
+ let v1;
597
+ if (ret[0] !== 0) {
598
+ v1 = getStringFromWasm0(ret[0], ret[1]).slice();
599
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
600
+ }
601
+ return v1;
602
+ }
470
603
  /**
471
604
  * @returns {number}
472
605
  */
@@ -708,10 +841,6 @@ function __wbg_get_imports() {
708
841
  const ret = arg0.done;
709
842
  return ret;
710
843
  },
711
- __wbg_entries_e8a20ff8c9757101: function(arg0) {
712
- const ret = Object.entries(arg0);
713
- return ret;
714
- },
715
844
  __wbg_from_4bdf88943703fd48: function(arg0) {
716
845
  const ret = Array.from(arg0);
717
846
  return ret;
@@ -780,6 +909,18 @@ function __wbg_get_imports() {
780
909
  const ret = new Uint8Array(arg0);
781
910
  return ret;
782
911
  },
912
+ __wbg_new_a70fbab9066b301f: function() {
913
+ const ret = new Array();
914
+ return ret;
915
+ },
916
+ __wbg_new_ab79df5bd7c26067: function() {
917
+ const ret = new Object();
918
+ return ret;
919
+ },
920
+ __wbg_new_from_slice_22da9388ac046e50: function(arg0, arg1) {
921
+ const ret = new Uint8Array(getArrayU8FromWasm0(arg0, arg1));
922
+ return ret;
923
+ },
783
924
  __wbg_next_11b99ee6237339e3: function() { return handleError(function (arg0) {
784
925
  const ret = arg0.next();
785
926
  return ret;
@@ -795,6 +936,14 @@ function __wbg_get_imports() {
795
936
  __wbg_prototypesetcall_d62e5099504357e6: function(arg0, arg1, arg2) {
796
937
  Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
797
938
  },
939
+ __wbg_push_e87b0e732085a946: function(arg0, arg1) {
940
+ const ret = arg0.push(arg1);
941
+ return ret;
942
+ },
943
+ __wbg_set_7eaa4f96924fd6b3: function() { return handleError(function (arg0, arg1, arg2) {
944
+ const ret = Reflect.set(arg0, arg1, arg2);
945
+ return ret;
946
+ }, arguments); },
798
947
  __wbg_value_21fc78aab0322612: function(arg0) {
799
948
  const ret = arg0.value;
800
949
  return ret;
@@ -803,11 +952,21 @@ function __wbg_get_imports() {
803
952
  const ret = Zone.__wrap(arg0);
804
953
  return ret;
805
954
  },
806
- __wbindgen_cast_0000000000000001: function(arg0, arg1) {
955
+ __wbindgen_cast_0000000000000001: function(arg0) {
956
+ // Cast intrinsic for `F64 -> Externref`.
957
+ const ret = arg0;
958
+ return ret;
959
+ },
960
+ __wbindgen_cast_0000000000000002: function(arg0, arg1) {
807
961
  // Cast intrinsic for `Ref(String) -> Externref`.
808
962
  const ret = getStringFromWasm0(arg0, arg1);
809
963
  return ret;
810
964
  },
965
+ __wbindgen_cast_0000000000000003: function(arg0) {
966
+ // Cast intrinsic for `U64 -> Externref`.
967
+ const ret = BigInt.asUintN(64, arg0);
968
+ return ret;
969
+ },
811
970
  __wbindgen_init_externref_table: function() {
812
971
  const table = wasm.__wbindgen_externrefs;
813
972
  const offset = table.grow(4);
@@ -830,12 +989,15 @@ const MessageFinalization = (typeof FinalizationRegistry === 'undefined')
830
989
  const MessageBuilderFinalization = (typeof FinalizationRegistry === 'undefined')
831
990
  ? { register: () => {}, unregister: () => {} }
832
991
  : new FinalizationRegistry(ptr => wasm.__wbg_messagebuilder_free(ptr >>> 0, 1));
833
- const OffchainDataFinalization = (typeof FinalizationRegistry === 'undefined')
992
+ const OffchainRecordsFinalization = (typeof FinalizationRegistry === 'undefined')
834
993
  ? { register: () => {}, unregister: () => {} }
835
- : new FinalizationRegistry(ptr => wasm.__wbg_offchaindata_free(ptr >>> 0, 1));
994
+ : new FinalizationRegistry(ptr => wasm.__wbg_offchainrecords_free(ptr >>> 0, 1));
836
995
  const QueryContextFinalization = (typeof FinalizationRegistry === 'undefined')
837
996
  ? { register: () => {}, unregister: () => {} }
838
997
  : new FinalizationRegistry(ptr => wasm.__wbg_querycontext_free(ptr >>> 0, 1));
998
+ const RecordFinalization = (typeof FinalizationRegistry === 'undefined')
999
+ ? { register: () => {}, unregister: () => {} }
1000
+ : new FinalizationRegistry(ptr => wasm.__wbg_record_free(ptr >>> 0, 1));
839
1001
  const RecordSetFinalization = (typeof FinalizationRegistry === 'undefined')
840
1002
  ? { register: () => {}, unregister: () => {} }
841
1003
  : 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.20260306225014",
3
+ "version": "0.0.0-dev.20260317233723",
4
4
  "files": [
5
5
  "libveritas_bg.wasm",
6
6
  "libveritas.js",