@spacesprotocol/libveritas 0.0.0-dev.20260320120512 → 0.0.0-dev.20260320153157
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 +35 -3
- package/libveritas.js +121 -16
- package/libveritas_bg.wasm +0 -0
- package/package.json +1 -1
package/libveritas.d.ts
CHANGED
|
@@ -8,6 +8,31 @@ export class Anchors {
|
|
|
8
8
|
constructor(json: string);
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
+
/**
|
|
12
|
+
* Batched iterative resolver for nested handle names.
|
|
13
|
+
*/
|
|
14
|
+
export class Lookup {
|
|
15
|
+
free(): void;
|
|
16
|
+
[Symbol.dispose](): void;
|
|
17
|
+
/**
|
|
18
|
+
* Feed zones from a resolveAll response.
|
|
19
|
+
* Returns the next batch of handles to look up (empty = done).
|
|
20
|
+
*/
|
|
21
|
+
advance(zones: any): string[];
|
|
22
|
+
/**
|
|
23
|
+
* Expand zone handles using the alias map accumulated during resolution.
|
|
24
|
+
*/
|
|
25
|
+
expandZones(zones: any): any;
|
|
26
|
+
/**
|
|
27
|
+
* Create a lookup from an array of handle name strings.
|
|
28
|
+
*/
|
|
29
|
+
constructor(names: string[]);
|
|
30
|
+
/**
|
|
31
|
+
* Returns the first batch of handles to look up.
|
|
32
|
+
*/
|
|
33
|
+
start(): string[];
|
|
34
|
+
}
|
|
35
|
+
|
|
11
36
|
/**
|
|
12
37
|
* A message containing chain proofs and handle data.
|
|
13
38
|
*/
|
|
@@ -52,6 +77,10 @@ export class MessageBuilder {
|
|
|
52
77
|
* Add all certificates from a .spacecert chain.
|
|
53
78
|
*/
|
|
54
79
|
addChain(chain_bytes: Uint8Array): void;
|
|
80
|
+
/**
|
|
81
|
+
* Add a .spacecert chain with records.
|
|
82
|
+
*/
|
|
83
|
+
addHandle(chain_bytes: Uint8Array, records_bytes: Uint8Array): void;
|
|
55
84
|
/**
|
|
56
85
|
* Add records for a handle.
|
|
57
86
|
*/
|
|
@@ -218,10 +247,13 @@ export class Veritas {
|
|
|
218
247
|
oldest_anchor(): number;
|
|
219
248
|
sovereignty_for(commitment_height: number): string;
|
|
220
249
|
/**
|
|
221
|
-
* Verify a message
|
|
250
|
+
* Verify a message with default options (expand_names: true, dev_mode: false).
|
|
251
|
+
*/
|
|
252
|
+
verify(ctx: QueryContext, msg: Message): VerifiedMessage;
|
|
253
|
+
/**
|
|
254
|
+
* Verify a message with explicit options.
|
|
222
255
|
*/
|
|
223
|
-
|
|
224
|
-
static withOptions(anchors: Anchors, expand_names: boolean, dev_mode: boolean): Veritas;
|
|
256
|
+
verifyWithOptions(ctx: QueryContext, msg: Message, expand_names: boolean, dev_mode: boolean): VerifiedMessage;
|
|
225
257
|
}
|
|
226
258
|
|
|
227
259
|
/**
|
package/libveritas.js
CHANGED
|
@@ -38,6 +38,76 @@ class Anchors {
|
|
|
38
38
|
if (Symbol.dispose) Anchors.prototype[Symbol.dispose] = Anchors.prototype.free;
|
|
39
39
|
exports.Anchors = Anchors;
|
|
40
40
|
|
|
41
|
+
/**
|
|
42
|
+
* Batched iterative resolver for nested handle names.
|
|
43
|
+
*/
|
|
44
|
+
class Lookup {
|
|
45
|
+
__destroy_into_raw() {
|
|
46
|
+
const ptr = this.__wbg_ptr;
|
|
47
|
+
this.__wbg_ptr = 0;
|
|
48
|
+
LookupFinalization.unregister(this);
|
|
49
|
+
return ptr;
|
|
50
|
+
}
|
|
51
|
+
free() {
|
|
52
|
+
const ptr = this.__destroy_into_raw();
|
|
53
|
+
wasm.__wbg_lookup_free(ptr, 0);
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Feed zones from a resolveAll response.
|
|
57
|
+
* Returns the next batch of handles to look up (empty = done).
|
|
58
|
+
* @param {any} zones
|
|
59
|
+
* @returns {string[]}
|
|
60
|
+
*/
|
|
61
|
+
advance(zones) {
|
|
62
|
+
const ret = wasm.lookup_advance(this.__wbg_ptr, zones);
|
|
63
|
+
if (ret[3]) {
|
|
64
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
65
|
+
}
|
|
66
|
+
var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
|
|
67
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
68
|
+
return v1;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Expand zone handles using the alias map accumulated during resolution.
|
|
72
|
+
* @param {any} zones
|
|
73
|
+
* @returns {any}
|
|
74
|
+
*/
|
|
75
|
+
expandZones(zones) {
|
|
76
|
+
const ret = wasm.lookup_expandZones(this.__wbg_ptr, zones);
|
|
77
|
+
if (ret[2]) {
|
|
78
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
79
|
+
}
|
|
80
|
+
return takeFromExternrefTable0(ret[0]);
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Create a lookup from an array of handle name strings.
|
|
84
|
+
* @param {string[]} names
|
|
85
|
+
*/
|
|
86
|
+
constructor(names) {
|
|
87
|
+
const ptr0 = passArrayJsValueToWasm0(names, wasm.__wbindgen_malloc);
|
|
88
|
+
const len0 = WASM_VECTOR_LEN;
|
|
89
|
+
const ret = wasm.lookup_new(ptr0, len0);
|
|
90
|
+
if (ret[2]) {
|
|
91
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
92
|
+
}
|
|
93
|
+
this.__wbg_ptr = ret[0] >>> 0;
|
|
94
|
+
LookupFinalization.register(this, this.__wbg_ptr, this);
|
|
95
|
+
return this;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Returns the first batch of handles to look up.
|
|
99
|
+
* @returns {string[]}
|
|
100
|
+
*/
|
|
101
|
+
start() {
|
|
102
|
+
const ret = wasm.lookup_start(this.__wbg_ptr);
|
|
103
|
+
var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
|
|
104
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
105
|
+
return v1;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
if (Symbol.dispose) Lookup.prototype[Symbol.dispose] = Lookup.prototype.free;
|
|
109
|
+
exports.Lookup = Lookup;
|
|
110
|
+
|
|
41
111
|
/**
|
|
42
112
|
* A message containing chain proofs and handle data.
|
|
43
113
|
*/
|
|
@@ -146,6 +216,21 @@ class MessageBuilder {
|
|
|
146
216
|
throw takeFromExternrefTable0(ret[0]);
|
|
147
217
|
}
|
|
148
218
|
}
|
|
219
|
+
/**
|
|
220
|
+
* Add a .spacecert chain with records.
|
|
221
|
+
* @param {Uint8Array} chain_bytes
|
|
222
|
+
* @param {Uint8Array} records_bytes
|
|
223
|
+
*/
|
|
224
|
+
addHandle(chain_bytes, records_bytes) {
|
|
225
|
+
const ptr0 = passArray8ToWasm0(chain_bytes, wasm.__wbindgen_malloc);
|
|
226
|
+
const len0 = WASM_VECTOR_LEN;
|
|
227
|
+
const ptr1 = passArray8ToWasm0(records_bytes, wasm.__wbindgen_malloc);
|
|
228
|
+
const len1 = WASM_VECTOR_LEN;
|
|
229
|
+
const ret = wasm.messagebuilder_addHandle(this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
230
|
+
if (ret[1]) {
|
|
231
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
149
234
|
/**
|
|
150
235
|
* Add records for a handle.
|
|
151
236
|
* @param {string} handle
|
|
@@ -556,13 +641,6 @@ if (Symbol.dispose) VerifiedMessage.prototype[Symbol.dispose] = VerifiedMessage.
|
|
|
556
641
|
exports.VerifiedMessage = VerifiedMessage;
|
|
557
642
|
|
|
558
643
|
class Veritas {
|
|
559
|
-
static __wrap(ptr) {
|
|
560
|
-
ptr = ptr >>> 0;
|
|
561
|
-
const obj = Object.create(Veritas.prototype);
|
|
562
|
-
obj.__wbg_ptr = ptr;
|
|
563
|
-
VeritasFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
564
|
-
return obj;
|
|
565
|
-
}
|
|
566
644
|
__destroy_into_raw() {
|
|
567
645
|
const ptr = this.__wbg_ptr;
|
|
568
646
|
this.__wbg_ptr = 0;
|
|
@@ -634,33 +712,36 @@ class Veritas {
|
|
|
634
712
|
}
|
|
635
713
|
}
|
|
636
714
|
/**
|
|
637
|
-
* Verify a message
|
|
715
|
+
* Verify a message with default options (expand_names: true, dev_mode: false).
|
|
638
716
|
* @param {QueryContext} ctx
|
|
639
717
|
* @param {Message} msg
|
|
640
718
|
* @returns {VerifiedMessage}
|
|
641
719
|
*/
|
|
642
|
-
|
|
720
|
+
verify(ctx, msg) {
|
|
643
721
|
_assertClass(ctx, QueryContext);
|
|
644
722
|
_assertClass(msg, Message);
|
|
645
|
-
const ret = wasm.
|
|
723
|
+
const ret = wasm.veritas_verify(this.__wbg_ptr, ctx.__wbg_ptr, msg.__wbg_ptr);
|
|
646
724
|
if (ret[2]) {
|
|
647
725
|
throw takeFromExternrefTable0(ret[1]);
|
|
648
726
|
}
|
|
649
727
|
return VerifiedMessage.__wrap(ret[0]);
|
|
650
728
|
}
|
|
651
729
|
/**
|
|
652
|
-
*
|
|
730
|
+
* Verify a message with explicit options.
|
|
731
|
+
* @param {QueryContext} ctx
|
|
732
|
+
* @param {Message} msg
|
|
653
733
|
* @param {boolean} expand_names
|
|
654
734
|
* @param {boolean} dev_mode
|
|
655
|
-
* @returns {
|
|
735
|
+
* @returns {VerifiedMessage}
|
|
656
736
|
*/
|
|
657
|
-
|
|
658
|
-
_assertClass(
|
|
659
|
-
|
|
737
|
+
verifyWithOptions(ctx, msg, expand_names, dev_mode) {
|
|
738
|
+
_assertClass(ctx, QueryContext);
|
|
739
|
+
_assertClass(msg, Message);
|
|
740
|
+
const ret = wasm.veritas_verifyWithOptions(this.__wbg_ptr, ctx.__wbg_ptr, msg.__wbg_ptr, expand_names, dev_mode);
|
|
660
741
|
if (ret[2]) {
|
|
661
742
|
throw takeFromExternrefTable0(ret[1]);
|
|
662
743
|
}
|
|
663
|
-
return
|
|
744
|
+
return VerifiedMessage.__wrap(ret[0]);
|
|
664
745
|
}
|
|
665
746
|
}
|
|
666
747
|
if (Symbol.dispose) Veritas.prototype[Symbol.dispose] = Veritas.prototype.free;
|
|
@@ -909,6 +990,9 @@ function __wbg_get_imports() {
|
|
|
909
990
|
const AnchorsFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
910
991
|
? { register: () => {}, unregister: () => {} }
|
|
911
992
|
: new FinalizationRegistry(ptr => wasm.__wbg_anchors_free(ptr >>> 0, 1));
|
|
993
|
+
const LookupFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
994
|
+
? { register: () => {}, unregister: () => {} }
|
|
995
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_lookup_free(ptr >>> 0, 1));
|
|
912
996
|
const MessageFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
913
997
|
? { register: () => {}, unregister: () => {} }
|
|
914
998
|
: new FinalizationRegistry(ptr => wasm.__wbg_message_free(ptr >>> 0, 1));
|
|
@@ -1011,6 +1095,17 @@ function debugString(val) {
|
|
|
1011
1095
|
return className;
|
|
1012
1096
|
}
|
|
1013
1097
|
|
|
1098
|
+
function getArrayJsValueFromWasm0(ptr, len) {
|
|
1099
|
+
ptr = ptr >>> 0;
|
|
1100
|
+
const mem = getDataViewMemory0();
|
|
1101
|
+
const result = [];
|
|
1102
|
+
for (let i = ptr; i < ptr + 4 * len; i += 4) {
|
|
1103
|
+
result.push(wasm.__wbindgen_externrefs.get(mem.getUint32(i, true)));
|
|
1104
|
+
}
|
|
1105
|
+
wasm.__externref_drop_slice(ptr, len);
|
|
1106
|
+
return result;
|
|
1107
|
+
}
|
|
1108
|
+
|
|
1014
1109
|
function getArrayU8FromWasm0(ptr, len) {
|
|
1015
1110
|
ptr = ptr >>> 0;
|
|
1016
1111
|
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
@@ -1057,6 +1152,16 @@ function passArray8ToWasm0(arg, malloc) {
|
|
|
1057
1152
|
return ptr;
|
|
1058
1153
|
}
|
|
1059
1154
|
|
|
1155
|
+
function passArrayJsValueToWasm0(array, malloc) {
|
|
1156
|
+
const ptr = malloc(array.length * 4, 4) >>> 0;
|
|
1157
|
+
for (let i = 0; i < array.length; i++) {
|
|
1158
|
+
const add = addToExternrefTable0(array[i]);
|
|
1159
|
+
getDataViewMemory0().setUint32(ptr + 4 * i, add, true);
|
|
1160
|
+
}
|
|
1161
|
+
WASM_VECTOR_LEN = array.length;
|
|
1162
|
+
return ptr;
|
|
1163
|
+
}
|
|
1164
|
+
|
|
1060
1165
|
function passStringToWasm0(arg, malloc, realloc) {
|
|
1061
1166
|
if (realloc === undefined) {
|
|
1062
1167
|
const buf = cachedTextEncoder.encode(arg);
|
package/libveritas_bg.wasm
CHANGED
|
Binary file
|