pendra 0.15.1 → 0.15.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/dist/index.js +30 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +30 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1331,7 +1331,7 @@ var Rerank = class {
|
|
|
1331
1331
|
};
|
|
1332
1332
|
|
|
1333
1333
|
// src/version.ts
|
|
1334
|
-
var VERSION = "0.15.
|
|
1334
|
+
var VERSION = "0.15.2";
|
|
1335
1335
|
var USER_AGENT = `pendra-node/${VERSION}`;
|
|
1336
1336
|
|
|
1337
1337
|
// src/_privateInferenceEngine.ts
|
|
@@ -1341,6 +1341,25 @@ var PrivateInferenceError = class extends Error {
|
|
|
1341
1341
|
this.name = "PrivateInferenceError";
|
|
1342
1342
|
}
|
|
1343
1343
|
};
|
|
1344
|
+
var FINGERPRINT_RE = /^[0-9a-f]{64}$/;
|
|
1345
|
+
function parsePinnedFingerprints(pin) {
|
|
1346
|
+
if (typeof pin !== "string") {
|
|
1347
|
+
throw new PrivateInferenceError(`pinnedFingerprint must be a string, got ${typeof pin}.`);
|
|
1348
|
+
}
|
|
1349
|
+
const fps = pin.split(",").map((f) => f.trim().toLowerCase()).filter((f) => f.length > 0);
|
|
1350
|
+
if (fps.length === 0) {
|
|
1351
|
+
throw new PrivateInferenceError(
|
|
1352
|
+
"pinnedFingerprint was set but contains no fingerprint. Pass the 64-character fingerprint shown in the console, or leave it unset to use automatic trust."
|
|
1353
|
+
);
|
|
1354
|
+
}
|
|
1355
|
+
const bad = fps.filter((f) => !FINGERPRINT_RE.test(f)).sort();
|
|
1356
|
+
if (bad.length > 0) {
|
|
1357
|
+
throw new PrivateInferenceError(
|
|
1358
|
+
`pinnedFingerprint "${bad[0]}" is not a valid fingerprint: expected 64 hexadecimal characters, as shown in the console.`
|
|
1359
|
+
);
|
|
1360
|
+
}
|
|
1361
|
+
return new Set(fps);
|
|
1362
|
+
}
|
|
1344
1363
|
function defaultTofuPath() {
|
|
1345
1364
|
const env = typeof process !== "undefined" ? process.env : void 0;
|
|
1346
1365
|
if (env?.PENDRA_TOFU_PATH) return env.PENDRA_TOFU_PATH;
|
|
@@ -1359,8 +1378,8 @@ var PrivateInferenceEngine = class {
|
|
|
1359
1378
|
this.orgPubs = null;
|
|
1360
1379
|
this.baseUrl = opts.baseUrl.replace(/\/$/, "");
|
|
1361
1380
|
this.apiKey = opts.apiKey;
|
|
1362
|
-
const
|
|
1363
|
-
this.pinnedFingerprints =
|
|
1381
|
+
const pin = opts.pinnedFingerprint;
|
|
1382
|
+
this.pinnedFingerprints = pin === null || pin === void 0 ? null : parsePinnedFingerprints(pin);
|
|
1364
1383
|
this.affinitySalt = opts.affinitySalt ?? null;
|
|
1365
1384
|
this.tofuPath = opts.tofuPath || defaultTofuPath();
|
|
1366
1385
|
}
|
|
@@ -1556,12 +1575,19 @@ var Pendra = class {
|
|
|
1556
1575
|
}
|
|
1557
1576
|
let pinnedFingerprint;
|
|
1558
1577
|
if (typeof piOpt === "object" && piOpt !== null) {
|
|
1578
|
+
for (const key of Object.keys(piOpt)) {
|
|
1579
|
+
if (key !== "pinnedFingerprint") {
|
|
1580
|
+
throw new TypeError(
|
|
1581
|
+
`Unknown privateInference option "${key}". Accepted options: pinnedFingerprint.`
|
|
1582
|
+
);
|
|
1583
|
+
}
|
|
1584
|
+
}
|
|
1559
1585
|
this.privateInferenceEnabled = true;
|
|
1560
1586
|
pinnedFingerprint = piOpt.pinnedFingerprint;
|
|
1561
1587
|
} else {
|
|
1562
1588
|
this.privateInferenceEnabled = Boolean(piOpt);
|
|
1563
1589
|
}
|
|
1564
|
-
pinnedFingerprint = pinnedFingerprint ?? env?.PENDRA_PINNED_ORG_FINGERPRINT
|
|
1590
|
+
pinnedFingerprint = pinnedFingerprint ?? (env?.PENDRA_PINNED_ORG_FINGERPRINT || void 0);
|
|
1565
1591
|
if (this.privateInferenceEnabled) {
|
|
1566
1592
|
const affinitySalt = env?.PENDRA_AFFINITY_SALT ? new TextEncoder().encode(env.PENDRA_AFFINITY_SALT) : null;
|
|
1567
1593
|
this._piEngine = new PrivateInferenceEngine({
|