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.mjs
CHANGED
|
@@ -1285,7 +1285,7 @@ var Rerank = class {
|
|
|
1285
1285
|
};
|
|
1286
1286
|
|
|
1287
1287
|
// src/version.ts
|
|
1288
|
-
var VERSION = "0.15.
|
|
1288
|
+
var VERSION = "0.15.2";
|
|
1289
1289
|
var USER_AGENT = `pendra-node/${VERSION}`;
|
|
1290
1290
|
|
|
1291
1291
|
// src/_privateInferenceEngine.ts
|
|
@@ -1295,6 +1295,25 @@ var PrivateInferenceError = class extends Error {
|
|
|
1295
1295
|
this.name = "PrivateInferenceError";
|
|
1296
1296
|
}
|
|
1297
1297
|
};
|
|
1298
|
+
var FINGERPRINT_RE = /^[0-9a-f]{64}$/;
|
|
1299
|
+
function parsePinnedFingerprints(pin) {
|
|
1300
|
+
if (typeof pin !== "string") {
|
|
1301
|
+
throw new PrivateInferenceError(`pinnedFingerprint must be a string, got ${typeof pin}.`);
|
|
1302
|
+
}
|
|
1303
|
+
const fps = pin.split(",").map((f) => f.trim().toLowerCase()).filter((f) => f.length > 0);
|
|
1304
|
+
if (fps.length === 0) {
|
|
1305
|
+
throw new PrivateInferenceError(
|
|
1306
|
+
"pinnedFingerprint was set but contains no fingerprint. Pass the 64-character fingerprint shown in the console, or leave it unset to use automatic trust."
|
|
1307
|
+
);
|
|
1308
|
+
}
|
|
1309
|
+
const bad = fps.filter((f) => !FINGERPRINT_RE.test(f)).sort();
|
|
1310
|
+
if (bad.length > 0) {
|
|
1311
|
+
throw new PrivateInferenceError(
|
|
1312
|
+
`pinnedFingerprint "${bad[0]}" is not a valid fingerprint: expected 64 hexadecimal characters, as shown in the console.`
|
|
1313
|
+
);
|
|
1314
|
+
}
|
|
1315
|
+
return new Set(fps);
|
|
1316
|
+
}
|
|
1298
1317
|
function defaultTofuPath() {
|
|
1299
1318
|
const env = typeof process !== "undefined" ? process.env : void 0;
|
|
1300
1319
|
if (env?.PENDRA_TOFU_PATH) return env.PENDRA_TOFU_PATH;
|
|
@@ -1313,8 +1332,8 @@ var PrivateInferenceEngine = class {
|
|
|
1313
1332
|
this.orgPubs = null;
|
|
1314
1333
|
this.baseUrl = opts.baseUrl.replace(/\/$/, "");
|
|
1315
1334
|
this.apiKey = opts.apiKey;
|
|
1316
|
-
const
|
|
1317
|
-
this.pinnedFingerprints =
|
|
1335
|
+
const pin = opts.pinnedFingerprint;
|
|
1336
|
+
this.pinnedFingerprints = pin === null || pin === void 0 ? null : parsePinnedFingerprints(pin);
|
|
1318
1337
|
this.affinitySalt = opts.affinitySalt ?? null;
|
|
1319
1338
|
this.tofuPath = opts.tofuPath || defaultTofuPath();
|
|
1320
1339
|
}
|
|
@@ -1510,12 +1529,19 @@ var Pendra = class {
|
|
|
1510
1529
|
}
|
|
1511
1530
|
let pinnedFingerprint;
|
|
1512
1531
|
if (typeof piOpt === "object" && piOpt !== null) {
|
|
1532
|
+
for (const key of Object.keys(piOpt)) {
|
|
1533
|
+
if (key !== "pinnedFingerprint") {
|
|
1534
|
+
throw new TypeError(
|
|
1535
|
+
`Unknown privateInference option "${key}". Accepted options: pinnedFingerprint.`
|
|
1536
|
+
);
|
|
1537
|
+
}
|
|
1538
|
+
}
|
|
1513
1539
|
this.privateInferenceEnabled = true;
|
|
1514
1540
|
pinnedFingerprint = piOpt.pinnedFingerprint;
|
|
1515
1541
|
} else {
|
|
1516
1542
|
this.privateInferenceEnabled = Boolean(piOpt);
|
|
1517
1543
|
}
|
|
1518
|
-
pinnedFingerprint = pinnedFingerprint ?? env?.PENDRA_PINNED_ORG_FINGERPRINT
|
|
1544
|
+
pinnedFingerprint = pinnedFingerprint ?? (env?.PENDRA_PINNED_ORG_FINGERPRINT || void 0);
|
|
1519
1545
|
if (this.privateInferenceEnabled) {
|
|
1520
1546
|
const affinitySalt = env?.PENDRA_AFFINITY_SALT ? new TextEncoder().encode(env.PENDRA_AFFINITY_SALT) : null;
|
|
1521
1547
|
this._piEngine = new PrivateInferenceEngine({
|