@niscorp/vex 0.2.0 → 0.2.2
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/CHANGELOG.md +40 -0
- package/DESIGN.md +12 -0
- package/DOCS.md +11 -2
- package/README.md +2 -1
- package/dist/adapters/express/index.cjs +139 -2
- package/dist/adapters/express/index.cjs.map +1 -1
- package/dist/adapters/express/index.js +1 -1
- package/dist/adapters/hono/index.cjs +139 -2
- package/dist/adapters/hono/index.cjs.map +1 -1
- package/dist/adapters/hono/index.js +1 -1
- package/dist/{chunk-5CBKESBJ.js → chunk-HCEH55PP.js} +159 -11
- package/dist/chunk-HCEH55PP.js.map +1 -0
- package/dist/index.cjs +157 -22
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +3 -17
- package/dist/index.js.map +1 -1
- package/package.json +9 -8
- package/dist/chunk-5CBKESBJ.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { handleDiscovery, handleQuery, handleFingerprintPatch, handleFingerprintDelete } from '../../chunk-
|
|
1
|
+
import { handleDiscovery, handleQuery, handleFingerprintPatch, handleFingerprintDelete } from '../../chunk-HCEH55PP.js';
|
|
2
2
|
import '../../chunk-HF25Q53I.js';
|
|
3
3
|
|
|
4
4
|
// src/adapters/express/index.ts
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
var hono = require('hono');
|
|
4
4
|
var zod = require('zod');
|
|
5
|
-
var crypto = require('crypto');
|
|
6
5
|
var strata = require('@niscorp/strata');
|
|
7
6
|
|
|
8
7
|
// src/adapters/hono/index.ts
|
|
@@ -185,6 +184,144 @@ var isEntryFresh = (entry, currentFingerprint) => {
|
|
|
185
184
|
const stale = entry.schemaFingerprint !== void 0 && currentFingerprint !== void 0 && entry.schemaFingerprint !== currentFingerprint;
|
|
186
185
|
return !expired && !stale;
|
|
187
186
|
};
|
|
187
|
+
|
|
188
|
+
// src/utils/sha256.ts
|
|
189
|
+
var ROUND_CONSTANTS = new Uint32Array([
|
|
190
|
+
1116352408,
|
|
191
|
+
1899447441,
|
|
192
|
+
3049323471,
|
|
193
|
+
3921009573,
|
|
194
|
+
961987163,
|
|
195
|
+
1508970993,
|
|
196
|
+
2453635748,
|
|
197
|
+
2870763221,
|
|
198
|
+
3624381080,
|
|
199
|
+
310598401,
|
|
200
|
+
607225278,
|
|
201
|
+
1426881987,
|
|
202
|
+
1925078388,
|
|
203
|
+
2162078206,
|
|
204
|
+
2614888103,
|
|
205
|
+
3248222580,
|
|
206
|
+
3835390401,
|
|
207
|
+
4022224774,
|
|
208
|
+
264347078,
|
|
209
|
+
604807628,
|
|
210
|
+
770255983,
|
|
211
|
+
1249150122,
|
|
212
|
+
1555081692,
|
|
213
|
+
1996064986,
|
|
214
|
+
2554220882,
|
|
215
|
+
2821834349,
|
|
216
|
+
2952996808,
|
|
217
|
+
3210313671,
|
|
218
|
+
3336571891,
|
|
219
|
+
3584528711,
|
|
220
|
+
113926993,
|
|
221
|
+
338241895,
|
|
222
|
+
666307205,
|
|
223
|
+
773529912,
|
|
224
|
+
1294757372,
|
|
225
|
+
1396182291,
|
|
226
|
+
1695183700,
|
|
227
|
+
1986661051,
|
|
228
|
+
2177026350,
|
|
229
|
+
2456956037,
|
|
230
|
+
2730485921,
|
|
231
|
+
2820302411,
|
|
232
|
+
3259730800,
|
|
233
|
+
3345764771,
|
|
234
|
+
3516065817,
|
|
235
|
+
3600352804,
|
|
236
|
+
4094571909,
|
|
237
|
+
275423344,
|
|
238
|
+
430227734,
|
|
239
|
+
506948616,
|
|
240
|
+
659060556,
|
|
241
|
+
883997877,
|
|
242
|
+
958139571,
|
|
243
|
+
1322822218,
|
|
244
|
+
1537002063,
|
|
245
|
+
1747873779,
|
|
246
|
+
1955562222,
|
|
247
|
+
2024104815,
|
|
248
|
+
2227730452,
|
|
249
|
+
2361852424,
|
|
250
|
+
2428436474,
|
|
251
|
+
2756734187,
|
|
252
|
+
3204031479,
|
|
253
|
+
3329325298
|
|
254
|
+
]);
|
|
255
|
+
var BLOCK_BYTES = 64;
|
|
256
|
+
var rotateRight = (word, bits) => word >>> bits | word << 32 - bits;
|
|
257
|
+
var wordHex = (word) => (word >>> 0).toString(16).padStart(8, "0");
|
|
258
|
+
var sha256Hex = (text) => {
|
|
259
|
+
const bytes = new TextEncoder().encode(text);
|
|
260
|
+
const padded = new Uint8Array(Math.ceil((bytes.length + 9) / BLOCK_BYTES) * BLOCK_BYTES);
|
|
261
|
+
padded.set(bytes);
|
|
262
|
+
padded[bytes.length] = 128;
|
|
263
|
+
const view = new DataView(padded.buffer);
|
|
264
|
+
const bitLength = bytes.length * 8;
|
|
265
|
+
view.setUint32(padded.length - 8, Math.floor(bitLength / 4294967296));
|
|
266
|
+
view.setUint32(padded.length - 4, bitLength >>> 0);
|
|
267
|
+
let h0 = 1779033703;
|
|
268
|
+
let h1 = 3144134277;
|
|
269
|
+
let h2 = 1013904242;
|
|
270
|
+
let h3 = 2773480762;
|
|
271
|
+
let h4 = 1359893119;
|
|
272
|
+
let h5 = 2600822924;
|
|
273
|
+
let h6 = 528734635;
|
|
274
|
+
let h7 = 1541459225;
|
|
275
|
+
const schedule = new Uint32Array(64);
|
|
276
|
+
for (let offset = 0; offset < padded.length; offset += BLOCK_BYTES) {
|
|
277
|
+
for (let i = 0; i < 16; i += 1) schedule[i] = view.getUint32(offset + i * 4);
|
|
278
|
+
for (let i = 16; i < 64; i += 1) {
|
|
279
|
+
const w15 = schedule[i - 15] ?? 0;
|
|
280
|
+
const w2 = schedule[i - 2] ?? 0;
|
|
281
|
+
const s0 = rotateRight(w15, 7) ^ rotateRight(w15, 18) ^ w15 >>> 3;
|
|
282
|
+
const s1 = rotateRight(w2, 17) ^ rotateRight(w2, 19) ^ w2 >>> 10;
|
|
283
|
+
schedule[i] = (schedule[i - 16] ?? 0) + s0 + (schedule[i - 7] ?? 0) + s1;
|
|
284
|
+
}
|
|
285
|
+
let a = h0;
|
|
286
|
+
let b = h1;
|
|
287
|
+
let c = h2;
|
|
288
|
+
let d = h3;
|
|
289
|
+
let e = h4;
|
|
290
|
+
let f = h5;
|
|
291
|
+
let g = h6;
|
|
292
|
+
let h = h7;
|
|
293
|
+
for (let i = 0; i < 64; i += 1) {
|
|
294
|
+
const sum1 = rotateRight(e, 6) ^ rotateRight(e, 11) ^ rotateRight(e, 25);
|
|
295
|
+
const choice = e & f ^ ~e & g;
|
|
296
|
+
const temp1 = h + sum1 + choice + (ROUND_CONSTANTS[i] ?? 0) + (schedule[i] ?? 0) | 0;
|
|
297
|
+
const sum0 = rotateRight(a, 2) ^ rotateRight(a, 13) ^ rotateRight(a, 22);
|
|
298
|
+
const majority = a & b ^ a & c ^ b & c;
|
|
299
|
+
const temp2 = sum0 + majority | 0;
|
|
300
|
+
h = g;
|
|
301
|
+
g = f;
|
|
302
|
+
f = e;
|
|
303
|
+
e = d + temp1 | 0;
|
|
304
|
+
d = c;
|
|
305
|
+
c = b;
|
|
306
|
+
b = a;
|
|
307
|
+
a = temp1 + temp2 | 0;
|
|
308
|
+
}
|
|
309
|
+
h0 = h0 + a | 0;
|
|
310
|
+
h1 = h1 + b | 0;
|
|
311
|
+
h2 = h2 + c | 0;
|
|
312
|
+
h3 = h3 + d | 0;
|
|
313
|
+
h4 = h4 + e | 0;
|
|
314
|
+
h5 = h5 + f | 0;
|
|
315
|
+
h6 = h6 + g | 0;
|
|
316
|
+
h7 = h7 + h | 0;
|
|
317
|
+
}
|
|
318
|
+
return wordHex(h0) + wordHex(h1) + wordHex(h2) + wordHex(h3) + wordHex(h4) + wordHex(h5) + wordHex(h6) + wordHex(h7);
|
|
319
|
+
};
|
|
320
|
+
|
|
321
|
+
// src/utils/canonical.ts
|
|
322
|
+
var hashText = (text) => sha256Hex(text);
|
|
323
|
+
|
|
324
|
+
// src/cache/hash.ts
|
|
188
325
|
var computeSchemaFingerprint = (schema) => {
|
|
189
326
|
const byName = (a, b) => a.name.localeCompare(b.name);
|
|
190
327
|
const stable = {
|
|
@@ -214,7 +351,7 @@ var computeSchemaFingerprint = (schema) => {
|
|
|
214
351
|
}))
|
|
215
352
|
}))
|
|
216
353
|
};
|
|
217
|
-
return
|
|
354
|
+
return hashText(JSON.stringify(stable));
|
|
218
355
|
};
|
|
219
356
|
|
|
220
357
|
// src/errors.ts
|