@getstrata/core 0.5.62 → 0.5.63

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/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # @getstrata/core changelog
2
2
 
3
+ ## 0.5.63
4
+
5
+ - Flash cookies honor `FLASH_COOKIE_NAME` (default `workhub_flash`) so sibling apps do not inherit WorkHub’s cookie name.
6
+
3
7
  ## 0.5.62
4
8
 
5
9
  Laravel URL signing, Bun-native markdown mail, and session-auth cleanup.
package/README.md CHANGED
@@ -82,7 +82,7 @@ import type { Migration } from "@getstrata/core/database/migrations/types";
82
82
  Package name: **`@getstrata/core`** (npm org [`@getstrata`](https://www.npmjs.com/org/getstrata)).
83
83
 
84
84
  1. Add `NPM_TOKEN` to GitHub repository secrets.
85
- 2. Tag a release: `git tag v0.5.62 && git push origin v0.5.62`
85
+ 2. Tag a release: `git tag v0.5.64 && git push origin v0.5.64`
86
86
  3. [Release workflow](../../.github/workflows/release.yml) builds and runs `npm publish --access public`.
87
87
 
88
88
  Previously published as `@eyk-workhub/framework@0.1.0`, deprecated in favor of this package.
@@ -1,3 +1,5 @@
1
+ declare const FLASH_COOKIE = "workhub_flash";
2
+ declare function flashCookieName(): string;
1
3
  type FlashLevel = "success" | "error" | "info";
2
4
  interface FlashMessage {
3
5
  level: FlashLevel;
@@ -9,4 +11,4 @@ declare function pullFlash(request: Request): FlashMessage | null;
9
11
  declare function flashResponse(response: Response, message: FlashMessage): Response;
10
12
  declare function withFlashClear(response: Response): Response;
11
13
  export type { FlashLevel, FlashMessage };
12
- export { clearFlashCookie, createFlashCookie, flashResponse, pullFlash, withFlashClear };
14
+ export { clearFlashCookie, createFlashCookie, FLASH_COOKIE, flashCookieName, flashResponse, pullFlash, withFlashClear, };
@@ -3,6 +3,9 @@
3
3
  import { createHmac, timingSafeEqual } from "crypto";
4
4
  var FLASH_COOKIE = "workhub_flash";
5
5
  var FLASH_TTL_MS = 60 * 1000;
6
+ function flashCookieName() {
7
+ return process.env.FLASH_COOKIE_NAME?.trim() || FLASH_COOKIE;
8
+ }
6
9
  function resolveFlashSecret() {
7
10
  return process.env.SESSION_SECRET?.trim() || process.env.OAUTH_STATE_SECRET?.trim() || "workhub-dev-flash-secret";
8
11
  }
@@ -17,7 +20,7 @@ function readFlashCookie(request) {
17
20
  }
18
21
  for (const part of cookieHeader.split(";")) {
19
22
  const [name, ...rest] = part.trim().split("=");
20
- if (name === FLASH_COOKIE) {
23
+ if (name === flashCookieName()) {
21
24
  return decodeURIComponent(rest.join("="));
22
25
  }
23
26
  }
@@ -67,10 +70,10 @@ function createFlashCookie(message) {
67
70
  const payload = Buffer.from(JSON.stringify(message), "utf8").toString("base64url");
68
71
  const issuedAt = Date.now();
69
72
  const value = signFlashPayload(payload, issuedAt);
70
- return `${FLASH_COOKIE}=${encodeURIComponent(value)}; Path=/; HttpOnly; SameSite=Lax; Max-Age=60`;
73
+ return `${flashCookieName()}=${encodeURIComponent(value)}; Path=/; HttpOnly; SameSite=Lax; Max-Age=60`;
71
74
  }
72
75
  function clearFlashCookie() {
73
- return `${FLASH_COOKIE}=; Path=/; HttpOnly; SameSite=Lax; Max-Age=0`;
76
+ return `${flashCookieName()}=; Path=/; HttpOnly; SameSite=Lax; Max-Age=0`;
74
77
  }
75
78
  function pullFlash(request) {
76
79
  const cookieValue = readFlashCookie(request);
@@ -3,6 +3,9 @@
3
3
  import { createHmac, timingSafeEqual } from "crypto";
4
4
  var FLASH_COOKIE = "workhub_flash";
5
5
  var FLASH_TTL_MS = 60 * 1000;
6
+ function flashCookieName() {
7
+ return process.env.FLASH_COOKIE_NAME?.trim() || FLASH_COOKIE;
8
+ }
6
9
  function resolveFlashSecret() {
7
10
  return process.env.SESSION_SECRET?.trim() || process.env.OAUTH_STATE_SECRET?.trim() || "workhub-dev-flash-secret";
8
11
  }
@@ -17,7 +20,7 @@ function readFlashCookie(request) {
17
20
  }
18
21
  for (const part of cookieHeader.split(";")) {
19
22
  const [name, ...rest] = part.trim().split("=");
20
- if (name === FLASH_COOKIE) {
23
+ if (name === flashCookieName()) {
21
24
  return decodeURIComponent(rest.join("="));
22
25
  }
23
26
  }
@@ -67,10 +70,10 @@ function createFlashCookie(message) {
67
70
  const payload = Buffer.from(JSON.stringify(message), "utf8").toString("base64url");
68
71
  const issuedAt = Date.now();
69
72
  const value = signFlashPayload(payload, issuedAt);
70
- return `${FLASH_COOKIE}=${encodeURIComponent(value)}; Path=/; HttpOnly; SameSite=Lax; Max-Age=60`;
73
+ return `${flashCookieName()}=${encodeURIComponent(value)}; Path=/; HttpOnly; SameSite=Lax; Max-Age=60`;
71
74
  }
72
75
  function clearFlashCookie() {
73
- return `${FLASH_COOKIE}=; Path=/; HttpOnly; SameSite=Lax; Max-Age=0`;
76
+ return `${flashCookieName()}=; Path=/; HttpOnly; SameSite=Lax; Max-Age=0`;
74
77
  }
75
78
  function pullFlash(request) {
76
79
  const cookieValue = readFlashCookie(request);
@@ -98,8 +101,10 @@ function withFlashClear(response) {
98
101
  });
99
102
  }
100
103
  export {
104
+ FLASH_COOKIE,
101
105
  clearFlashCookie,
102
106
  createFlashCookie,
107
+ flashCookieName,
103
108
  flashResponse,
104
109
  pullFlash,
105
110
  withFlashClear
@@ -524,6 +524,9 @@ function resolveCsrfTokenForRequest(request) {
524
524
  import { createHmac, timingSafeEqual as timingSafeEqual2 } from "crypto";
525
525
  var FLASH_COOKIE = "workhub_flash";
526
526
  var FLASH_TTL_MS = 60 * 1000;
527
+ function flashCookieName() {
528
+ return process.env.FLASH_COOKIE_NAME?.trim() || FLASH_COOKIE;
529
+ }
527
530
  function resolveFlashSecret() {
528
531
  return process.env.SESSION_SECRET?.trim() || process.env.OAUTH_STATE_SECRET?.trim() || "workhub-dev-flash-secret";
529
532
  }
@@ -538,7 +541,7 @@ function readFlashCookie(request) {
538
541
  }
539
542
  for (const part of cookieHeader.split(";")) {
540
543
  const [name, ...rest] = part.trim().split("=");
541
- if (name === FLASH_COOKIE) {
544
+ if (name === flashCookieName()) {
542
545
  return decodeURIComponent(rest.join("="));
543
546
  }
544
547
  }
@@ -588,10 +591,10 @@ function createFlashCookie(message) {
588
591
  const payload = Buffer.from(JSON.stringify(message), "utf8").toString("base64url");
589
592
  const issuedAt = Date.now();
590
593
  const value = signFlashPayload(payload, issuedAt);
591
- return `${FLASH_COOKIE}=${encodeURIComponent(value)}; Path=/; HttpOnly; SameSite=Lax; Max-Age=60`;
594
+ return `${flashCookieName()}=${encodeURIComponent(value)}; Path=/; HttpOnly; SameSite=Lax; Max-Age=60`;
592
595
  }
593
596
  function clearFlashCookie() {
594
- return `${FLASH_COOKIE}=; Path=/; HttpOnly; SameSite=Lax; Max-Age=0`;
597
+ return `${flashCookieName()}=; Path=/; HttpOnly; SameSite=Lax; Max-Age=0`;
595
598
  }
596
599
  function pullFlash(request) {
597
600
  const cookieValue = readFlashCookie(request);
package/dist/index.js CHANGED
@@ -4660,6 +4660,9 @@ function createCsrfProtection(secret, options = {}) {
4660
4660
  import { createHmac, timingSafeEqual as timingSafeEqual3 } from "crypto";
4661
4661
  var FLASH_COOKIE = "workhub_flash";
4662
4662
  var FLASH_TTL_MS = 60 * 1000;
4663
+ function flashCookieName() {
4664
+ return process.env.FLASH_COOKIE_NAME?.trim() || FLASH_COOKIE;
4665
+ }
4663
4666
  function resolveFlashSecret() {
4664
4667
  return process.env.SESSION_SECRET?.trim() || process.env.OAUTH_STATE_SECRET?.trim() || "workhub-dev-flash-secret";
4665
4668
  }
@@ -4674,7 +4677,7 @@ function readFlashCookie(request) {
4674
4677
  }
4675
4678
  for (const part of cookieHeader.split(";")) {
4676
4679
  const [name, ...rest] = part.trim().split("=");
4677
- if (name === FLASH_COOKIE) {
4680
+ if (name === flashCookieName()) {
4678
4681
  return decodeURIComponent(rest.join("="));
4679
4682
  }
4680
4683
  }
@@ -4721,7 +4724,7 @@ function parseFlashCookie(cookieValue) {
4721
4724
  }
4722
4725
  }
4723
4726
  function clearFlashCookie() {
4724
- return `${FLASH_COOKIE}=; Path=/; HttpOnly; SameSite=Lax; Max-Age=0`;
4727
+ return `${flashCookieName()}=; Path=/; HttpOnly; SameSite=Lax; Max-Age=0`;
4725
4728
  }
4726
4729
  function pullFlash(request) {
4727
4730
  const cookieValue = readFlashCookie(request);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getstrata/core",
3
- "version": "0.5.62",
3
+ "version": "0.5.63",
4
4
  "description": "Strata — Laravel-inspired Bun framework public API",
5
5
  "type": "module",
6
6
  "license": "MIT",