@agent-native/core 0.158.7 → 0.158.9

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.
@@ -62,11 +62,11 @@ export declare const postAwareness: import("h3").EventHandlerWithFetch<import("h
62
62
  error: string;
63
63
  states?: undefined;
64
64
  } | {
65
- error?: undefined;
66
65
  states: {
67
66
  clientId: number;
68
67
  state: string;
69
68
  }[];
69
+ error?: undefined;
70
70
  }>>;
71
71
  /**
72
72
  * GET /_agent-native/collab/:docId/users
@@ -77,9 +77,9 @@ export declare const getActiveUsers: import("h3").EventHandlerWithFetch<import("
77
77
  error: string;
78
78
  users?: undefined;
79
79
  } | {
80
- error?: undefined;
81
80
  users: {
82
81
  clientId: number;
83
82
  lastSeen: number;
84
83
  }[];
84
+ error?: undefined;
85
85
  }>>;
@@ -17,11 +17,11 @@ declare const _default: import("../../action.js").ActionDefinition<{
17
17
  id?: undefined;
18
18
  provider?: undefined;
19
19
  } | {
20
- error?: undefined;
21
20
  configured?: undefined;
22
21
  connectPath?: undefined;
23
22
  url: string;
24
23
  id: string;
25
24
  provider: string;
25
+ error?: undefined;
26
26
  }>;
27
27
  export default _default;
@@ -48,8 +48,8 @@ export declare function handleUpdateResource(event: any): Promise<import("./stor
48
48
  }>;
49
49
  /** DELETE /_agent-native/resources/:id — delete a resource */
50
50
  export declare function handleDeleteResource(event: any): Promise<{
51
- ok?: undefined;
52
51
  error: string;
52
+ ok?: undefined;
53
53
  } | {
54
54
  error?: undefined;
55
55
  ok: boolean;
@@ -1545,33 +1545,35 @@ function magicLinkStoredIdentifier(token) {
1545
1545
  return crypto.createHash("sha256").update(token).digest("base64url");
1546
1546
  }
1547
1547
  function redactMagicLinkUrl(value, baseURL) {
1548
- try {
1549
- const url = new URL(value, baseURL);
1548
+ const redactUrl = (url, depth) => {
1550
1549
  for (const key of ["token", "flow_id", "verifier", "state"]) {
1551
1550
  if (url.searchParams.has(key))
1552
1551
  url.searchParams.set(key, "[redacted]");
1553
1552
  }
1553
+ if (depth >= 4)
1554
+ return;
1554
1555
  for (const key of [
1555
1556
  "callbackURL",
1556
1557
  "newUserCallbackURL",
1557
1558
  "errorCallbackURL",
1559
+ "return",
1558
1560
  ]) {
1559
1561
  const callback = url.searchParams.get(key);
1560
1562
  if (!callback)
1561
1563
  continue;
1562
1564
  try {
1563
1565
  const callbackURL = new URL(callback, url.origin);
1564
- for (const nestedKey of ["flow_id", "verifier", "state"]) {
1565
- if (callbackURL.searchParams.has(nestedKey)) {
1566
- callbackURL.searchParams.set(nestedKey, "[redacted]");
1567
- }
1568
- }
1566
+ redactUrl(callbackURL, depth + 1);
1569
1567
  url.searchParams.set(key, callbackURL.toString());
1570
1568
  }
1571
1569
  catch {
1572
1570
  url.searchParams.set(key, "[invalid]");
1573
1571
  }
1574
1572
  }
1573
+ };
1574
+ try {
1575
+ const url = new URL(value, baseURL);
1576
+ redactUrl(url, 0);
1575
1577
  return `${url.pathname}${url.search}`;
1576
1578
  }
1577
1579
  catch {
@@ -27,6 +27,27 @@ async function assertBetterAuthUserIdentityColumns() {
27
27
  throw new Error(`Cannot repair the Better Auth "user" table because required identity column(s) are missing: ${missing.join(", ")}. Restore the existing user schema before deploying this migration.`);
28
28
  }
29
29
  }
30
+ /**
31
+ * Better Auth encrypts persisted JWT private keys with the current auth
32
+ * secret. If that secret is rotated, the old row remains the newest key and
33
+ * every token-producing request fails before it can mint a replacement. Mark
34
+ * active rows expired during the release so Better Auth rotates the signing
35
+ * key without touching users or sessions. The JWKS endpoint keeps expired
36
+ * keys during its grace period, so already-issued short-lived tokens remain
37
+ * verifiable while the new key propagates.
38
+ */
39
+ async function expireJwksKeysAfterAuthSecretRotation() {
40
+ const { getDbExec, isPostgres } = await import("../db/client.js");
41
+ const now = isPostgres() ? new Date().toISOString() : Date.now();
42
+ const table = isPostgres() ? '"jwks"' : "jwks";
43
+ const result = await getDbExec().execute({
44
+ sql: `UPDATE ${table} SET expires_at = ? WHERE expires_at IS NULL OR expires_at > ?`,
45
+ args: [now, now],
46
+ });
47
+ if (result.rowsAffected > 0) {
48
+ console.info(`[auth] Expired ${result.rowsAffected} Better Auth JWKS key(s) after auth-secret rotation; public keys remain in the verification grace period.`);
49
+ }
50
+ }
30
51
  /**
31
52
  * Better Auth's framework-owned schema. This is deliberately a release
32
53
  * migration, not a fallback inside `getBetterAuth()`: request functions must
@@ -247,6 +268,12 @@ export const BETTER_AUTH_MIGRATIONS = [
247
268
  `,
248
269
  },
249
270
  },
271
+ {
272
+ version: 4,
273
+ name: "better-auth-jwks-key-rotation-recovery",
274
+ sql: {},
275
+ run: expireJwksKeysAfterAuthSecretRotation,
276
+ },
250
277
  ];
251
278
  export async function runBetterAuthMigrations(nitroApp) {
252
279
  await runMigrations(BETTER_AUTH_MIGRATIONS, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agent-native/core",
3
- "version": "0.158.7",
3
+ "version": "0.158.9",
4
4
  "description": "Framework for agent-native application development — where AI agents and UI share SQL state, actions, and context",
5
5
  "homepage": "https://github.com/BuilderIO/agent-native#readme",
6
6
  "bugs": {
@@ -425,8 +425,8 @@
425
425
  "y-protocols": "^1.0.7",
426
426
  "yjs": "^13.6.31",
427
427
  "zod": "^4.3.6",
428
- "@agent-native/recap-cli": "0.5.4",
429
- "@agent-native/toolkit": "^0.16.3"
428
+ "@agent-native/toolkit": "^0.16.3",
429
+ "@agent-native/recap-cli": "0.5.4"
430
430
  },
431
431
  "devDependencies": {
432
432
  "@ai-sdk/anthropic": "^3.0.71",