friend-assistant 0.1.70 → 0.1.71

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/BUILD.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "friend-assistant",
3
- "version": "0.1.70",
4
- "builtAt": "2026-11-06T17:56:02.443Z"
3
+ "version": "0.1.71",
4
+ "builtAt": "2026-11-06T18:32:08.662Z"
5
5
  }
package/dist/friend.mjs CHANGED
@@ -8674,23 +8674,37 @@ var SESSION_TTL_MS = 7 * 24 * 3600 * 1e3;
8674
8674
  var LOGIN_TRIES = 3;
8675
8675
  var PAIR_TTL_MS = 5 * 60 * 1e3;
8676
8676
  var sha256 = (s) => createHash6("sha256").update(s).digest("hex");
8677
- function scryptAsync(secret, salt) {
8677
+ var SCRYPT_N = 131072;
8678
+ var LEGACY_N = 16384;
8679
+ var cost = SCRYPT_N;
8680
+ function scryptAsync(secret, salt, N) {
8678
8681
  return new Promise(
8679
- (res, rej) => scrypt(secret, salt, 64, { N: 16384, r: 8, p: 1 }, (err, key2) => err ? rej(err) : res(key2))
8682
+ (res, rej) => scrypt(secret, salt, 64, { N, r: 8, p: 1, maxmem: 256 * 1024 * 1024 }, (err, key2) => err ? rej(err) : res(key2))
8680
8683
  );
8681
8684
  }
8682
8685
  async function hashSecret(secret) {
8683
8686
  const salt = randomBytes4(16);
8684
- const key2 = await scryptAsync(secret, salt);
8685
- return `scrypt$${salt.toString("hex")}$${key2.toString("hex")}`;
8687
+ const key2 = await scryptAsync(secret, salt, cost);
8688
+ return `scrypt2$${cost}$${salt.toString("hex")}$${key2.toString("hex")}`;
8686
8689
  }
8687
8690
  async function verifySecret(secret, stored) {
8688
- const [alg, saltHex, keyHex] = stored.split("$");
8689
- if (alg !== "scrypt" || !saltHex || !keyHex) return false;
8691
+ const parts = stored.split("$");
8692
+ let N;
8693
+ let saltHex;
8694
+ let keyHex;
8695
+ if (parts[0] === "scrypt" && parts.length === 3) {
8696
+ N = LEGACY_N;
8697
+ [, saltHex, keyHex] = parts;
8698
+ } else if (parts[0] === "scrypt2" && parts.length === 4 && (Number(parts[1]) === SCRYPT_N || Number(parts[1]) === cost)) {
8699
+ N = Number(parts[1]);
8700
+ [, , saltHex, keyHex] = parts;
8701
+ } else return false;
8702
+ if (!saltHex || !keyHex) return false;
8690
8703
  const expected = Buffer.from(keyHex, "hex");
8691
- const actual = await scryptAsync(secret, Buffer.from(saltHex, "hex"));
8704
+ const actual = await scryptAsync(secret, Buffer.from(saltHex, "hex"), N);
8692
8705
  return expected.length === actual.length && timingSafeEqual2(expected, actual);
8693
8706
  }
8707
+ var outdated = (stored) => !stored.startsWith(`scrypt2$${cost}$`);
8694
8708
  var Auth = class _Auth {
8695
8709
  constructor(db, audit, clock2 = Date.now) {
8696
8710
  this.db = db;
@@ -8745,6 +8759,7 @@ var Auth = class _Auth {
8745
8759
  throw new Error("Invalid credentials");
8746
8760
  }
8747
8761
  succeeded();
8762
+ if (row2 && outdated(row2.h)) this.db.prepare("update owner set password_hash = ? where id = 1").run(await hashSecret(password));
8748
8763
  const token = randomBytes4(32).toString("hex");
8749
8764
  const expiresAt = this.clock() + SESSION_TTL_MS;
8750
8765
  this.db.prepare("insert into sessions (token_hash, kind, expires_at, ip) values (?, 'web', ?, ?)").run(sha256(token), expiresAt, ip);
@@ -8772,8 +8787,10 @@ var Auth = class _Auth {
8772
8787
  const succeeded = this.begin("pin", ip);
8773
8788
  const row2 = this.db.prepare("select pin_hash h from owner where id = 1").get();
8774
8789
  const ok2 = row2 ? await verifySecret(pin, row2.h) : false;
8775
- if (ok2) succeeded();
8776
- else this.audit.log("owner", "pin.fail", { ip });
8790
+ if (ok2) {
8791
+ succeeded();
8792
+ if (row2 && outdated(row2.h)) this.db.prepare("update owner set pin_hash = ? where id = 1").run(await hashSecret(pin));
8793
+ } else this.audit.log("owner", "pin.fail", { ip });
8777
8794
  return ok2;
8778
8795
  }
8779
8796
  /** Checks a new password and/or PIN the same way setup does. Returns the problem, or null when both are fine. */
@@ -16787,6 +16804,17 @@ function createGateway(deps) {
16787
16804
  return reply.code(421).send({ error: "Unknown host" });
16788
16805
  }
16789
16806
  });
16807
+ app.addHook("onSend", async (req, reply, payload) => {
16808
+ const set = (name, value) => {
16809
+ if (!reply.hasHeader(name)) reply.header(name, value);
16810
+ };
16811
+ set("x-content-type-options", "nosniff");
16812
+ set("x-frame-options", "SAMEORIGIN");
16813
+ set("referrer-policy", "no-referrer");
16814
+ set("content-security-policy", "frame-ancestors 'self'; object-src 'none'; base-uri 'self'; form-action 'self'");
16815
+ if (isSecure(req)) set("strict-transport-security", "max-age=15552000");
16816
+ return payload;
16817
+ });
16790
16818
  const MISSES_PER_MINUTE = 30;
16791
16819
  const misses = /* @__PURE__ */ new Map();
16792
16820
  const allowMiss = (ip) => {
@@ -20252,7 +20280,7 @@ function currentSelf() {
20252
20280
  // ../server/src/system/npm.ts
20253
20281
  import { spawn as spawn9 } from "node:child_process";
20254
20282
  var PACKAGE = "friend-assistant";
20255
- var runningVersion = () => true ? "0.1.70" : "development";
20283
+ var runningVersion = () => true ? "0.1.71" : "development";
20256
20284
  async function npmLatest(fetchFn = fetch, timeoutMs = 1e4) {
20257
20285
  try {
20258
20286
  const res = await fetchFn(`https://registry.npmjs.org/${PACKAGE}/latest`, { headers: { accept: "application/json" }, signal: AbortSignal.timeout(timeoutMs) });
@@ -25541,7 +25569,7 @@ import { appendFileSync } from "node:fs";
25541
25569
  import { join as join34 } from "node:path";
25542
25570
  var PACKAGE2 = "friend-assistant";
25543
25571
  var real2 = {
25544
- current: () => true ? "0.1.70" : "development",
25572
+ current: () => true ? "0.1.71" : "development",
25545
25573
  latest: () => new Promise((resolve13) => {
25546
25574
  const child = crossSpawn5("npm", ["view", PACKAGE2, "version", "--prefer-online"], { stdio: ["ignore", "pipe", "ignore"] });
25547
25575
  let out = "";
@@ -25859,7 +25887,7 @@ async function run(argv, io2) {
25859
25887
  case "version":
25860
25888
  case "--version":
25861
25889
  case "-v":
25862
- io2.out(true ? "0.1.70" : "development");
25890
+ io2.out(true ? "0.1.71" : "development");
25863
25891
  return 0;
25864
25892
  case "lan":
25865
25893
  return await lanCommand(rest, io2);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "friend-assistant",
3
- "version": "0.1.70",
3
+ "version": "0.1.71",
4
4
  "description": "A self-hosted personal AI assistant for your own PC: a full-screen stage, voice, tools with your approval, and your Claude subscription or a local model.",
5
5
  "keywords": ["ai", "assistant", "jarvis", "voice", "claude", "ollama", "mcp", "self-hosted"],
6
6
  "license": "UNLICENSED",