@bendyline/gezk 1.0.7 → 1.0.8
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/dist/index.d.ts +12 -1
- package/dist/index.js +143 -0
- package/dist/node.d.ts +1 -1
- package/dist/node.js +143 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1104,4 +1104,15 @@ declare function spatialManifest(locations: Array<{
|
|
|
1104
1104
|
*/
|
|
1105
1105
|
declare const QUERY_STOP_WORDS: ReadonlySet<string>;
|
|
1106
1106
|
|
|
1107
|
-
|
|
1107
|
+
/**
|
|
1108
|
+
* Synchronous SHA-256 for code that cannot wait on WebCrypto (async only):
|
|
1109
|
+
* a live index hashing chunk text inside one write transaction. Pure, so it
|
|
1110
|
+
* runs in a browser, a Web Worker or a mobile WebView; `./node` keeps using
|
|
1111
|
+
* `node:crypto`, and the two agree byte for byte (`sha256.test.ts`).
|
|
1112
|
+
*/
|
|
1113
|
+
/** SHA-256 digest of `data` (a string is hashed as UTF-8). */
|
|
1114
|
+
declare function sha256(data: Uint8Array | string): Uint8Array;
|
|
1115
|
+
/** Lowercase hex SHA-256 of `data` (a string is hashed as UTF-8). */
|
|
1116
|
+
declare function sha256Hex(data: Uint8Array | string): string;
|
|
1117
|
+
|
|
1118
|
+
export { ASSETS_PREFIX, ArtifactDigestSchema, BODY_CODEC_MIN_BYTES, type CatalogDocument, CatalogDocumentSchema, DEFAULT_EMBEDDING_ONNX_FILE, DEFAULT_EMBEDDING_TOKENIZER_FILE, type EmbeddingMedia, EmbeddingMediaSchema, type EmbeddingModelFile, EmbeddingModelFileSchema, GEZK_APPLICATION_ID, GEZK_EARTH_RADIUS_METERS, GEZK_FORMAT_GENERATIONS, GEZK_FORMAT_VERSION, GEZK_INDEX_SCHEMA_VERSION, GEZK_MANIFEST_KIND, GEZK_MIME_TYPE, GEZK_REGISTRY_KIND, GEZK_SUPPORTED_FORMAT_VERSIONS, GEZK_SUPPORTED_INDEX_SCHEMA_VERSIONS, type GezkFormatVersion, type GezkIndexSchemaVersion, KNOWLEDGE_ASSET_PATH_PATTERN, KNOWLEDGE_ASSET_TYPES, KNOWLEDGE_ID_PATTERN, KNOWLEDGE_MANIFEST_INDEX_SCHEMA_VERSIONS, KNOWLEDGE_MEDIA_ASSET_TYPES, KNOWLEDGE_VERSION_PATTERN, type KnowledgeAssetExtension, type KnowledgeAssetKind, type KnowledgeAssetModality, KnowledgeAssetPathSchema, type KnowledgeBounds, KnowledgeBoundsSchema, type KnowledgeCatalogManifest, KnowledgeCatalogManifestSchema, KnowledgeChunkUidSchema, type KnowledgeChunkingProfile, KnowledgeChunkingProfileSchema, KnowledgeDocumentIdSchema, type KnowledgeDocumentMeta, KnowledgeDocumentMetaSchema, type KnowledgeEmbeddingProfile, KnowledgeEmbeddingProfileSchema, KnowledgeIdSchema, type KnowledgeImageAssetExtension, type KnowledgeLocation, KnowledgeLocationSchema, KnowledgeLocationsSchema, KnowledgeManifestFileSchema, type KnowledgeMediaAssetExtension, KnowledgeOrdinalSchema, type KnowledgeRadius, KnowledgeRadiusSchema, type KnowledgeRegistryEntry, KnowledgeRegistryEntrySchema, type KnowledgeRegistryIndex, KnowledgeRegistryIndexSchema, type KnowledgeSignature, KnowledgeSignatureSchema, type KnowledgeSpatialManifest, KnowledgeSpatialManifestSchema, type KnowledgeTocReference, KnowledgeTocReferenceSchema, type KnowledgeUri, type KnowledgeVectorEncoding, KnowledgeVectorEncodingSchema, KnowledgeVersionSchema, LICENSE_NOTICE_PATH, MANIFEST_PATH, MAX_DOCUMENT_LOCATIONS, MAX_KNOWLEDGE_ASSETS_TOTAL_BYTES, MAX_KNOWLEDGE_ASSET_BYTES, MAX_KNOWLEDGE_ASSET_COUNT, MAX_KNOWLEDGE_ASSET_PATH_LENGTH, MAX_KNOWLEDGE_DOCUMENT_BYTES, MAX_KNOWLEDGE_DOCUMENT_META_BYTES, MAX_KNOWLEDGE_MEDIA_ASSETS_TOTAL_BYTES, MAX_KNOWLEDGE_MEDIA_ASSET_BYTES, MAX_KNOWLEDGE_TOPIC_DEPTH, MIMETYPE_PATH, QUERY_STOP_WORDS, README_PATH, ROUTER_DB_PATH, ROUTER_DDL, RepoRelativePathSchema, SHARD_DDL, SHARD_DDL_V4, SHARD_DDL_V5, SOURCE_NOTICES_PATH, Sha256HexSchema, type SourceNotices, SourceNoticesSchema, ZIP_FIXED_MTIME, assetContentType, assetExtension, assetKindForExtension, assetModality, canonicalizeJson, centerVector, documentSlug, embeddingProfileArtifacts, embeddingProfileCenter, embeddingProfileCenterProblem, embeddingProfileMinimumFormat, embeddingProfileSourceDimensions, embeddingProfileTruncationProblem, formatAtLeast, formatKnowledgeUri, isKnowledgeAssetPath, isKnowledgeMediaAssetPath, isSupportedFormatVersion, isSupportedIndexSchemaVersion, knowledgeAssetLimitsProblem, l2Normalize, locationDistanceMeters, locationInBounds, maxKnowledgeAssetBytes, normalizeLongitude, parseKnowledgeUri, profileUnitVector, quantizeBinary, quantizeBinaryForProfile, quantizeInt8, radiusBounds, rerankScore, sameVectorSpace, sha256, sha256Hex, shardDdlFor, sniffAssetType, spatialManifest, svgInertnessProblem, topicSortKeyForOrder };
|
package/dist/index.js
CHANGED
|
@@ -1366,6 +1366,147 @@ var QUERY_STOP_WORDS = /* @__PURE__ */ new Set([
|
|
|
1366
1366
|
"shouldn",
|
|
1367
1367
|
"couldn"
|
|
1368
1368
|
]);
|
|
1369
|
+
|
|
1370
|
+
// src/sha256.ts
|
|
1371
|
+
var K = new Uint32Array([
|
|
1372
|
+
1116352408,
|
|
1373
|
+
1899447441,
|
|
1374
|
+
3049323471,
|
|
1375
|
+
3921009573,
|
|
1376
|
+
961987163,
|
|
1377
|
+
1508970993,
|
|
1378
|
+
2453635748,
|
|
1379
|
+
2870763221,
|
|
1380
|
+
3624381080,
|
|
1381
|
+
310598401,
|
|
1382
|
+
607225278,
|
|
1383
|
+
1426881987,
|
|
1384
|
+
1925078388,
|
|
1385
|
+
2162078206,
|
|
1386
|
+
2614888103,
|
|
1387
|
+
3248222580,
|
|
1388
|
+
3835390401,
|
|
1389
|
+
4022224774,
|
|
1390
|
+
264347078,
|
|
1391
|
+
604807628,
|
|
1392
|
+
770255983,
|
|
1393
|
+
1249150122,
|
|
1394
|
+
1555081692,
|
|
1395
|
+
1996064986,
|
|
1396
|
+
2554220882,
|
|
1397
|
+
2821834349,
|
|
1398
|
+
2952996808,
|
|
1399
|
+
3210313671,
|
|
1400
|
+
3336571891,
|
|
1401
|
+
3584528711,
|
|
1402
|
+
113926993,
|
|
1403
|
+
338241895,
|
|
1404
|
+
666307205,
|
|
1405
|
+
773529912,
|
|
1406
|
+
1294757372,
|
|
1407
|
+
1396182291,
|
|
1408
|
+
1695183700,
|
|
1409
|
+
1986661051,
|
|
1410
|
+
2177026350,
|
|
1411
|
+
2456956037,
|
|
1412
|
+
2730485921,
|
|
1413
|
+
2820302411,
|
|
1414
|
+
3259730800,
|
|
1415
|
+
3345764771,
|
|
1416
|
+
3516065817,
|
|
1417
|
+
3600352804,
|
|
1418
|
+
4094571909,
|
|
1419
|
+
275423344,
|
|
1420
|
+
430227734,
|
|
1421
|
+
506948616,
|
|
1422
|
+
659060556,
|
|
1423
|
+
883997877,
|
|
1424
|
+
958139571,
|
|
1425
|
+
1322822218,
|
|
1426
|
+
1537002063,
|
|
1427
|
+
1747873779,
|
|
1428
|
+
1955562222,
|
|
1429
|
+
2024104815,
|
|
1430
|
+
2227730452,
|
|
1431
|
+
2361852424,
|
|
1432
|
+
2428436474,
|
|
1433
|
+
2756734187,
|
|
1434
|
+
3204031479,
|
|
1435
|
+
3329325298
|
|
1436
|
+
]);
|
|
1437
|
+
var encoder = new TextEncoder();
|
|
1438
|
+
function sha256(data) {
|
|
1439
|
+
const bytes = typeof data === "string" ? encoder.encode(data) : data;
|
|
1440
|
+
const bitLength = bytes.length * 8;
|
|
1441
|
+
const blocks = Math.ceil((bytes.length + 9) / 64);
|
|
1442
|
+
const padded = new Uint8Array(blocks * 64);
|
|
1443
|
+
padded.set(bytes);
|
|
1444
|
+
padded[bytes.length] = 128;
|
|
1445
|
+
const view = new DataView(padded.buffer);
|
|
1446
|
+
view.setUint32(padded.length - 8, Math.floor(bitLength / 4294967296));
|
|
1447
|
+
view.setUint32(padded.length - 4, bitLength >>> 0);
|
|
1448
|
+
let h0 = 1779033703;
|
|
1449
|
+
let h1 = 3144134277;
|
|
1450
|
+
let h2 = 1013904242;
|
|
1451
|
+
let h3 = 2773480762;
|
|
1452
|
+
let h4 = 1359893119;
|
|
1453
|
+
let h5 = 2600822924;
|
|
1454
|
+
let h6 = 528734635;
|
|
1455
|
+
let h7 = 1541459225;
|
|
1456
|
+
const w = new Uint32Array(64);
|
|
1457
|
+
for (let block = 0; block < blocks; block++) {
|
|
1458
|
+
const base = block * 64;
|
|
1459
|
+
for (let t = 0; t < 16; t++) w[t] = view.getUint32(base + t * 4);
|
|
1460
|
+
for (let t = 16; t < 64; t++) {
|
|
1461
|
+
const x = w[t - 15];
|
|
1462
|
+
const y = w[t - 2];
|
|
1463
|
+
const s0 = (x >>> 7 | x << 25) ^ (x >>> 18 | x << 14) ^ x >>> 3;
|
|
1464
|
+
const s1 = (y >>> 17 | y << 15) ^ (y >>> 19 | y << 13) ^ y >>> 10;
|
|
1465
|
+
w[t] = w[t - 16] + s0 + w[t - 7] + s1 >>> 0;
|
|
1466
|
+
}
|
|
1467
|
+
let a = h0;
|
|
1468
|
+
let b = h1;
|
|
1469
|
+
let c = h2;
|
|
1470
|
+
let d = h3;
|
|
1471
|
+
let e = h4;
|
|
1472
|
+
let f = h5;
|
|
1473
|
+
let g = h6;
|
|
1474
|
+
let h = h7;
|
|
1475
|
+
for (let t = 0; t < 64; t++) {
|
|
1476
|
+
const S1 = (e >>> 6 | e << 26) ^ (e >>> 11 | e << 21) ^ (e >>> 25 | e << 7);
|
|
1477
|
+
const ch = e & f ^ ~e & g;
|
|
1478
|
+
const t1 = h + S1 + ch + K[t] + w[t] >>> 0;
|
|
1479
|
+
const S0 = (a >>> 2 | a << 30) ^ (a >>> 13 | a << 19) ^ (a >>> 22 | a << 10);
|
|
1480
|
+
const maj = a & b ^ a & c ^ b & c;
|
|
1481
|
+
const t2 = S0 + maj >>> 0;
|
|
1482
|
+
h = g;
|
|
1483
|
+
g = f;
|
|
1484
|
+
f = e;
|
|
1485
|
+
e = d + t1 >>> 0;
|
|
1486
|
+
d = c;
|
|
1487
|
+
c = b;
|
|
1488
|
+
b = a;
|
|
1489
|
+
a = t1 + t2 >>> 0;
|
|
1490
|
+
}
|
|
1491
|
+
h0 = h0 + a >>> 0;
|
|
1492
|
+
h1 = h1 + b >>> 0;
|
|
1493
|
+
h2 = h2 + c >>> 0;
|
|
1494
|
+
h3 = h3 + d >>> 0;
|
|
1495
|
+
h4 = h4 + e >>> 0;
|
|
1496
|
+
h5 = h5 + f >>> 0;
|
|
1497
|
+
h6 = h6 + g >>> 0;
|
|
1498
|
+
h7 = h7 + h >>> 0;
|
|
1499
|
+
}
|
|
1500
|
+
const out = new Uint8Array(32);
|
|
1501
|
+
const outView = new DataView(out.buffer);
|
|
1502
|
+
[h0, h1, h2, h3, h4, h5, h6, h7].forEach((word, index) => outView.setUint32(index * 4, word));
|
|
1503
|
+
return out;
|
|
1504
|
+
}
|
|
1505
|
+
function sha256Hex(data) {
|
|
1506
|
+
let hex = "";
|
|
1507
|
+
for (const byte of sha256(data)) hex += byte.toString(16).padStart(2, "0");
|
|
1508
|
+
return hex;
|
|
1509
|
+
}
|
|
1369
1510
|
export {
|
|
1370
1511
|
ASSETS_PREFIX,
|
|
1371
1512
|
ArtifactDigestSchema,
|
|
@@ -1470,6 +1611,8 @@ export {
|
|
|
1470
1611
|
radiusBounds,
|
|
1471
1612
|
rerankScore,
|
|
1472
1613
|
sameVectorSpace,
|
|
1614
|
+
sha256,
|
|
1615
|
+
sha256Hex,
|
|
1473
1616
|
shardDdlFor,
|
|
1474
1617
|
sniffAssetType,
|
|
1475
1618
|
spatialManifest,
|
package/dist/node.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { KnowledgeCatalogManifest, KnowledgeRegistryIndex } from './index.js';
|
|
2
|
-
export { ASSETS_PREFIX, ArtifactDigestSchema, BODY_CODEC_MIN_BYTES, CatalogDocument, CatalogDocumentSchema, DEFAULT_EMBEDDING_ONNX_FILE, DEFAULT_EMBEDDING_TOKENIZER_FILE, EmbeddingMedia, EmbeddingMediaSchema, EmbeddingModelFile, EmbeddingModelFileSchema, GEZK_APPLICATION_ID, GEZK_EARTH_RADIUS_METERS, GEZK_FORMAT_GENERATIONS, GEZK_FORMAT_VERSION, GEZK_INDEX_SCHEMA_VERSION, GEZK_MANIFEST_KIND, GEZK_MIME_TYPE, GEZK_REGISTRY_KIND, GEZK_SUPPORTED_FORMAT_VERSIONS, GEZK_SUPPORTED_INDEX_SCHEMA_VERSIONS, GezkFormatVersion, GezkIndexSchemaVersion, KNOWLEDGE_ASSET_PATH_PATTERN, KNOWLEDGE_ASSET_TYPES, KNOWLEDGE_ID_PATTERN, KNOWLEDGE_MANIFEST_INDEX_SCHEMA_VERSIONS, KNOWLEDGE_MEDIA_ASSET_TYPES, KNOWLEDGE_VERSION_PATTERN, KnowledgeAssetExtension, KnowledgeAssetKind, KnowledgeAssetModality, KnowledgeAssetPathSchema, KnowledgeBounds, KnowledgeBoundsSchema, KnowledgeCatalogManifestSchema, KnowledgeChunkUidSchema, KnowledgeChunkingProfile, KnowledgeChunkingProfileSchema, KnowledgeDocumentIdSchema, KnowledgeDocumentMeta, KnowledgeDocumentMetaSchema, KnowledgeEmbeddingProfile, KnowledgeEmbeddingProfileSchema, KnowledgeIdSchema, KnowledgeImageAssetExtension, KnowledgeLocation, KnowledgeLocationSchema, KnowledgeLocationsSchema, KnowledgeManifestFileSchema, KnowledgeMediaAssetExtension, KnowledgeOrdinalSchema, KnowledgeRadius, KnowledgeRadiusSchema, KnowledgeRegistryEntry, KnowledgeRegistryEntrySchema, KnowledgeRegistryIndexSchema, KnowledgeSignature, KnowledgeSignatureSchema, KnowledgeSpatialManifest, KnowledgeSpatialManifestSchema, KnowledgeTocReference, KnowledgeTocReferenceSchema, KnowledgeUri, KnowledgeVectorEncoding, KnowledgeVectorEncodingSchema, KnowledgeVersionSchema, LICENSE_NOTICE_PATH, MANIFEST_PATH, MAX_DOCUMENT_LOCATIONS, MAX_KNOWLEDGE_ASSETS_TOTAL_BYTES, MAX_KNOWLEDGE_ASSET_BYTES, MAX_KNOWLEDGE_ASSET_COUNT, MAX_KNOWLEDGE_ASSET_PATH_LENGTH, MAX_KNOWLEDGE_DOCUMENT_BYTES, MAX_KNOWLEDGE_DOCUMENT_META_BYTES, MAX_KNOWLEDGE_MEDIA_ASSETS_TOTAL_BYTES, MAX_KNOWLEDGE_MEDIA_ASSET_BYTES, MAX_KNOWLEDGE_TOPIC_DEPTH, MIMETYPE_PATH, QUERY_STOP_WORDS, README_PATH, ROUTER_DB_PATH, ROUTER_DDL, RepoRelativePathSchema, SHARD_DDL, SHARD_DDL_V4, SHARD_DDL_V5, SOURCE_NOTICES_PATH, Sha256HexSchema, SourceNotices, SourceNoticesSchema, ZIP_FIXED_MTIME, assetContentType, assetExtension, assetKindForExtension, assetModality, canonicalizeJson, centerVector, documentSlug, embeddingProfileArtifacts, embeddingProfileCenter, embeddingProfileCenterProblem, embeddingProfileMinimumFormat, embeddingProfileSourceDimensions, embeddingProfileTruncationProblem, formatAtLeast, formatKnowledgeUri, isKnowledgeAssetPath, isKnowledgeMediaAssetPath, isSupportedFormatVersion, isSupportedIndexSchemaVersion, knowledgeAssetLimitsProblem, l2Normalize, locationDistanceMeters, locationInBounds, maxKnowledgeAssetBytes, normalizeLongitude, parseKnowledgeUri, profileUnitVector, quantizeBinary, quantizeBinaryForProfile, quantizeInt8, radiusBounds, rerankScore, sameVectorSpace, shardDdlFor, sniffAssetType, spatialManifest, svgInertnessProblem, topicSortKeyForOrder } from './index.js';
|
|
2
|
+
export { ASSETS_PREFIX, ArtifactDigestSchema, BODY_CODEC_MIN_BYTES, CatalogDocument, CatalogDocumentSchema, DEFAULT_EMBEDDING_ONNX_FILE, DEFAULT_EMBEDDING_TOKENIZER_FILE, EmbeddingMedia, EmbeddingMediaSchema, EmbeddingModelFile, EmbeddingModelFileSchema, GEZK_APPLICATION_ID, GEZK_EARTH_RADIUS_METERS, GEZK_FORMAT_GENERATIONS, GEZK_FORMAT_VERSION, GEZK_INDEX_SCHEMA_VERSION, GEZK_MANIFEST_KIND, GEZK_MIME_TYPE, GEZK_REGISTRY_KIND, GEZK_SUPPORTED_FORMAT_VERSIONS, GEZK_SUPPORTED_INDEX_SCHEMA_VERSIONS, GezkFormatVersion, GezkIndexSchemaVersion, KNOWLEDGE_ASSET_PATH_PATTERN, KNOWLEDGE_ASSET_TYPES, KNOWLEDGE_ID_PATTERN, KNOWLEDGE_MANIFEST_INDEX_SCHEMA_VERSIONS, KNOWLEDGE_MEDIA_ASSET_TYPES, KNOWLEDGE_VERSION_PATTERN, KnowledgeAssetExtension, KnowledgeAssetKind, KnowledgeAssetModality, KnowledgeAssetPathSchema, KnowledgeBounds, KnowledgeBoundsSchema, KnowledgeCatalogManifestSchema, KnowledgeChunkUidSchema, KnowledgeChunkingProfile, KnowledgeChunkingProfileSchema, KnowledgeDocumentIdSchema, KnowledgeDocumentMeta, KnowledgeDocumentMetaSchema, KnowledgeEmbeddingProfile, KnowledgeEmbeddingProfileSchema, KnowledgeIdSchema, KnowledgeImageAssetExtension, KnowledgeLocation, KnowledgeLocationSchema, KnowledgeLocationsSchema, KnowledgeManifestFileSchema, KnowledgeMediaAssetExtension, KnowledgeOrdinalSchema, KnowledgeRadius, KnowledgeRadiusSchema, KnowledgeRegistryEntry, KnowledgeRegistryEntrySchema, KnowledgeRegistryIndexSchema, KnowledgeSignature, KnowledgeSignatureSchema, KnowledgeSpatialManifest, KnowledgeSpatialManifestSchema, KnowledgeTocReference, KnowledgeTocReferenceSchema, KnowledgeUri, KnowledgeVectorEncoding, KnowledgeVectorEncodingSchema, KnowledgeVersionSchema, LICENSE_NOTICE_PATH, MANIFEST_PATH, MAX_DOCUMENT_LOCATIONS, MAX_KNOWLEDGE_ASSETS_TOTAL_BYTES, MAX_KNOWLEDGE_ASSET_BYTES, MAX_KNOWLEDGE_ASSET_COUNT, MAX_KNOWLEDGE_ASSET_PATH_LENGTH, MAX_KNOWLEDGE_DOCUMENT_BYTES, MAX_KNOWLEDGE_DOCUMENT_META_BYTES, MAX_KNOWLEDGE_MEDIA_ASSETS_TOTAL_BYTES, MAX_KNOWLEDGE_MEDIA_ASSET_BYTES, MAX_KNOWLEDGE_TOPIC_DEPTH, MIMETYPE_PATH, QUERY_STOP_WORDS, README_PATH, ROUTER_DB_PATH, ROUTER_DDL, RepoRelativePathSchema, SHARD_DDL, SHARD_DDL_V4, SHARD_DDL_V5, SOURCE_NOTICES_PATH, Sha256HexSchema, SourceNotices, SourceNoticesSchema, ZIP_FIXED_MTIME, assetContentType, assetExtension, assetKindForExtension, assetModality, canonicalizeJson, centerVector, documentSlug, embeddingProfileArtifacts, embeddingProfileCenter, embeddingProfileCenterProblem, embeddingProfileMinimumFormat, embeddingProfileSourceDimensions, embeddingProfileTruncationProblem, formatAtLeast, formatKnowledgeUri, isKnowledgeAssetPath, isKnowledgeMediaAssetPath, isSupportedFormatVersion, isSupportedIndexSchemaVersion, knowledgeAssetLimitsProblem, l2Normalize, locationDistanceMeters, locationInBounds, maxKnowledgeAssetBytes, normalizeLongitude, parseKnowledgeUri, profileUnitVector, quantizeBinary, quantizeBinaryForProfile, quantizeInt8, radiusBounds, rerankScore, sameVectorSpace, sha256, sha256Hex, shardDdlFor, sniffAssetType, spatialManifest, svgInertnessProblem, topicSortKeyForOrder } from './index.js';
|
|
3
3
|
import 'zod';
|
|
4
4
|
|
|
5
5
|
/**
|
package/dist/node.js
CHANGED
|
@@ -1367,6 +1367,147 @@ var QUERY_STOP_WORDS = /* @__PURE__ */ new Set([
|
|
|
1367
1367
|
"couldn"
|
|
1368
1368
|
]);
|
|
1369
1369
|
|
|
1370
|
+
// src/sha256.ts
|
|
1371
|
+
var K = new Uint32Array([
|
|
1372
|
+
1116352408,
|
|
1373
|
+
1899447441,
|
|
1374
|
+
3049323471,
|
|
1375
|
+
3921009573,
|
|
1376
|
+
961987163,
|
|
1377
|
+
1508970993,
|
|
1378
|
+
2453635748,
|
|
1379
|
+
2870763221,
|
|
1380
|
+
3624381080,
|
|
1381
|
+
310598401,
|
|
1382
|
+
607225278,
|
|
1383
|
+
1426881987,
|
|
1384
|
+
1925078388,
|
|
1385
|
+
2162078206,
|
|
1386
|
+
2614888103,
|
|
1387
|
+
3248222580,
|
|
1388
|
+
3835390401,
|
|
1389
|
+
4022224774,
|
|
1390
|
+
264347078,
|
|
1391
|
+
604807628,
|
|
1392
|
+
770255983,
|
|
1393
|
+
1249150122,
|
|
1394
|
+
1555081692,
|
|
1395
|
+
1996064986,
|
|
1396
|
+
2554220882,
|
|
1397
|
+
2821834349,
|
|
1398
|
+
2952996808,
|
|
1399
|
+
3210313671,
|
|
1400
|
+
3336571891,
|
|
1401
|
+
3584528711,
|
|
1402
|
+
113926993,
|
|
1403
|
+
338241895,
|
|
1404
|
+
666307205,
|
|
1405
|
+
773529912,
|
|
1406
|
+
1294757372,
|
|
1407
|
+
1396182291,
|
|
1408
|
+
1695183700,
|
|
1409
|
+
1986661051,
|
|
1410
|
+
2177026350,
|
|
1411
|
+
2456956037,
|
|
1412
|
+
2730485921,
|
|
1413
|
+
2820302411,
|
|
1414
|
+
3259730800,
|
|
1415
|
+
3345764771,
|
|
1416
|
+
3516065817,
|
|
1417
|
+
3600352804,
|
|
1418
|
+
4094571909,
|
|
1419
|
+
275423344,
|
|
1420
|
+
430227734,
|
|
1421
|
+
506948616,
|
|
1422
|
+
659060556,
|
|
1423
|
+
883997877,
|
|
1424
|
+
958139571,
|
|
1425
|
+
1322822218,
|
|
1426
|
+
1537002063,
|
|
1427
|
+
1747873779,
|
|
1428
|
+
1955562222,
|
|
1429
|
+
2024104815,
|
|
1430
|
+
2227730452,
|
|
1431
|
+
2361852424,
|
|
1432
|
+
2428436474,
|
|
1433
|
+
2756734187,
|
|
1434
|
+
3204031479,
|
|
1435
|
+
3329325298
|
|
1436
|
+
]);
|
|
1437
|
+
var encoder = new TextEncoder();
|
|
1438
|
+
function sha256(data) {
|
|
1439
|
+
const bytes = typeof data === "string" ? encoder.encode(data) : data;
|
|
1440
|
+
const bitLength = bytes.length * 8;
|
|
1441
|
+
const blocks = Math.ceil((bytes.length + 9) / 64);
|
|
1442
|
+
const padded = new Uint8Array(blocks * 64);
|
|
1443
|
+
padded.set(bytes);
|
|
1444
|
+
padded[bytes.length] = 128;
|
|
1445
|
+
const view = new DataView(padded.buffer);
|
|
1446
|
+
view.setUint32(padded.length - 8, Math.floor(bitLength / 4294967296));
|
|
1447
|
+
view.setUint32(padded.length - 4, bitLength >>> 0);
|
|
1448
|
+
let h0 = 1779033703;
|
|
1449
|
+
let h1 = 3144134277;
|
|
1450
|
+
let h2 = 1013904242;
|
|
1451
|
+
let h3 = 2773480762;
|
|
1452
|
+
let h4 = 1359893119;
|
|
1453
|
+
let h5 = 2600822924;
|
|
1454
|
+
let h6 = 528734635;
|
|
1455
|
+
let h7 = 1541459225;
|
|
1456
|
+
const w = new Uint32Array(64);
|
|
1457
|
+
for (let block = 0; block < blocks; block++) {
|
|
1458
|
+
const base = block * 64;
|
|
1459
|
+
for (let t = 0; t < 16; t++) w[t] = view.getUint32(base + t * 4);
|
|
1460
|
+
for (let t = 16; t < 64; t++) {
|
|
1461
|
+
const x = w[t - 15];
|
|
1462
|
+
const y = w[t - 2];
|
|
1463
|
+
const s0 = (x >>> 7 | x << 25) ^ (x >>> 18 | x << 14) ^ x >>> 3;
|
|
1464
|
+
const s1 = (y >>> 17 | y << 15) ^ (y >>> 19 | y << 13) ^ y >>> 10;
|
|
1465
|
+
w[t] = w[t - 16] + s0 + w[t - 7] + s1 >>> 0;
|
|
1466
|
+
}
|
|
1467
|
+
let a = h0;
|
|
1468
|
+
let b = h1;
|
|
1469
|
+
let c = h2;
|
|
1470
|
+
let d = h3;
|
|
1471
|
+
let e = h4;
|
|
1472
|
+
let f = h5;
|
|
1473
|
+
let g = h6;
|
|
1474
|
+
let h = h7;
|
|
1475
|
+
for (let t = 0; t < 64; t++) {
|
|
1476
|
+
const S1 = (e >>> 6 | e << 26) ^ (e >>> 11 | e << 21) ^ (e >>> 25 | e << 7);
|
|
1477
|
+
const ch = e & f ^ ~e & g;
|
|
1478
|
+
const t1 = h + S1 + ch + K[t] + w[t] >>> 0;
|
|
1479
|
+
const S0 = (a >>> 2 | a << 30) ^ (a >>> 13 | a << 19) ^ (a >>> 22 | a << 10);
|
|
1480
|
+
const maj = a & b ^ a & c ^ b & c;
|
|
1481
|
+
const t2 = S0 + maj >>> 0;
|
|
1482
|
+
h = g;
|
|
1483
|
+
g = f;
|
|
1484
|
+
f = e;
|
|
1485
|
+
e = d + t1 >>> 0;
|
|
1486
|
+
d = c;
|
|
1487
|
+
c = b;
|
|
1488
|
+
b = a;
|
|
1489
|
+
a = t1 + t2 >>> 0;
|
|
1490
|
+
}
|
|
1491
|
+
h0 = h0 + a >>> 0;
|
|
1492
|
+
h1 = h1 + b >>> 0;
|
|
1493
|
+
h2 = h2 + c >>> 0;
|
|
1494
|
+
h3 = h3 + d >>> 0;
|
|
1495
|
+
h4 = h4 + e >>> 0;
|
|
1496
|
+
h5 = h5 + f >>> 0;
|
|
1497
|
+
h6 = h6 + g >>> 0;
|
|
1498
|
+
h7 = h7 + h >>> 0;
|
|
1499
|
+
}
|
|
1500
|
+
const out = new Uint8Array(32);
|
|
1501
|
+
const outView = new DataView(out.buffer);
|
|
1502
|
+
[h0, h1, h2, h3, h4, h5, h6, h7].forEach((word, index) => outView.setUint32(index * 4, word));
|
|
1503
|
+
return out;
|
|
1504
|
+
}
|
|
1505
|
+
function sha256Hex(data) {
|
|
1506
|
+
let hex = "";
|
|
1507
|
+
for (const byte of sha256(data)) hex += byte.toString(16).padStart(2, "0");
|
|
1508
|
+
return hex;
|
|
1509
|
+
}
|
|
1510
|
+
|
|
1370
1511
|
// src/node/ids.ts
|
|
1371
1512
|
import { createHash } from "crypto";
|
|
1372
1513
|
function chunkUid(documentId, ordinal, chunkText) {
|
|
@@ -1596,6 +1737,8 @@ export {
|
|
|
1596
1737
|
radiusBounds,
|
|
1597
1738
|
rerankScore,
|
|
1598
1739
|
sameVectorSpace,
|
|
1740
|
+
sha256,
|
|
1741
|
+
sha256Hex,
|
|
1599
1742
|
shardDdlFor,
|
|
1600
1743
|
signManifest,
|
|
1601
1744
|
signRegistryIndex,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bendyline/gezk",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.8",
|
|
4
4
|
"description": "The gezk knowledge-catalog format: manifest and registry schemas, id grammars, knowledge:// references, vector quantization, SQLite DDL, canonical JSON, and Ed25519 manifest signatures.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|