@byline/client 5.1.2 → 5.1.3

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.
@@ -18,8 +18,8 @@ export interface SessionCookieTokens {
18
18
  refreshTokenExpiresAt: Date;
19
19
  }
20
20
  /**
21
- * Write both access and refresh cookies. Called after sign-in and after
22
- * every transparent refresh in `getAdminRequestContext()`.
21
+ * Write both access and refresh cookies. Called after a successful sign-in
22
+ * and after a confirmed rotation in the explicit renewal server fn.
23
23
  *
24
24
  * `maxAge` is derived from each token's own expiry claim so the browser
25
25
  * drops the cookies at the same moment the server would reject them —
@@ -27,8 +27,9 @@ export interface SessionCookieTokens {
27
27
  */
28
28
  export declare function setSessionCookies(tokens: SessionCookieTokens): void;
29
29
  /**
30
- * Clear both session cookies. Called on sign-out and on any auth failure
31
- * during `getAdminRequestContext()` (ensures the browser does not keep
32
- * trying a token that the server has already rejected).
30
+ * Clear both session cookies. Called only after a confirmed sign-out or a
31
+ * successful self-service password change. Authentication and renewal
32
+ * failures deliberately do not clear cookies: a late failure response must
33
+ * not erase credentials that a concurrent renewal or sign-in just installed.
33
34
  */
34
35
  export declare function clearSessionCookies(): void;
@@ -11,13 +11,15 @@
11
11
  * Two separate httpOnly cookies, one for each token half:
12
12
  *
13
13
  * - `byline_access_token` — short-lived JWT; sent on every request.
14
- * - `byline_refresh_token` — long-lived opaque string; sent back only
15
- * when the access cookie is missing or
16
- * expired, to mint a new access token.
14
+ * - `byline_refresh_token` — long-lived opaque string; consumed only by
15
+ * the explicit renewal endpoint to mint a
16
+ * replacement access token.
17
17
  *
18
- * Presenting "one session" to the user is a function of the middleware —
19
- * `getAdminRequestContext()` transparently refreshes the access cookie
20
- * using the refresh cookie, so the UI layer doesn't have to care.
18
+ * Renewal is explicit, not implicit. `getAdminRequestContext()` only
19
+ * verifies the access cookie and never writes or clears cookies; the
20
+ * browser transport calls the host's CSRF-protected renewal server fn
21
+ * after a pre-handler `ERR_ACCESS_EXPIRED` outcome, and that endpoint is
22
+ * the only place refresh rotation writes new cookies.
21
23
  *
22
24
  * All cookies set here use:
23
25
  * - `httpOnly: true` — inaccessible to JavaScript (XSS-hardened).
@@ -44,8 +46,8 @@ export function readRefreshTokenCookie() {
44
46
  return getHostRequestBridge().getCookie(REFRESH_TOKEN_COOKIE);
45
47
  }
46
48
  /**
47
- * Write both access and refresh cookies. Called after sign-in and after
48
- * every transparent refresh in `getAdminRequestContext()`.
49
+ * Write both access and refresh cookies. Called after a successful sign-in
50
+ * and after a confirmed rotation in the explicit renewal server fn.
49
51
  *
50
52
  * `maxAge` is derived from each token's own expiry claim so the browser
51
53
  * drops the cookies at the same moment the server would reject them —
@@ -72,9 +74,10 @@ export function setSessionCookies(tokens) {
72
74
  });
73
75
  }
74
76
  /**
75
- * Clear both session cookies. Called on sign-out and on any auth failure
76
- * during `getAdminRequestContext()` (ensures the browser does not keep
77
- * trying a token that the server has already rejected).
77
+ * Clear both session cookies. Called only after a confirmed sign-out or a
78
+ * successful self-service password change. Authentication and renewal
79
+ * failures deliberately do not clear cookies: a late failure response must
80
+ * not erase credentials that a concurrent renewal or sign-in just installed.
78
81
  */
79
82
  export function clearSessionCookies() {
80
83
  const bridge = getHostRequestBridge();
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@byline/client",
3
3
  "private": false,
4
4
  "license": "MPL-2.0",
5
- "version": "5.1.2",
5
+ "version": "5.1.3",
6
6
  "engines": {
7
7
  "node": ">=20.9.0"
8
8
  },
@@ -44,8 +44,8 @@
44
44
  ],
45
45
  "dependencies": {
46
46
  "uuid": "^14.0.2",
47
- "@byline/auth": "5.1.2",
48
- "@byline/core": "5.1.2"
47
+ "@byline/auth": "5.1.3",
48
+ "@byline/core": "5.1.3"
49
49
  },
50
50
  "devDependencies": {
51
51
  "@biomejs/biome": "2.5.12",
@@ -57,8 +57,8 @@
57
57
  "tsc-alias": "^1.9.4",
58
58
  "typescript": "^7.0.2",
59
59
  "vitest": "^5.0.0",
60
- "@byline/db-postgres": "5.1.2",
61
- "@byline/search-postgres": "5.1.2"
60
+ "@byline/search-postgres": "5.1.3",
61
+ "@byline/db-postgres": "5.1.3"
62
62
  },
63
63
  "publishConfig": {
64
64
  "access": "public",