@c9up/warden 0.2.1 → 0.2.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.
@@ -4,6 +4,12 @@ interface Codemods {
4
4
  writeFile(filePath: string, content: string, options?: {
5
5
  force?: boolean;
6
6
  }): Promise<void>;
7
+ makeUsingStub(stubsRoot: string, stubPath: string, state?: Record<string, string | number | boolean>, options?: {
8
+ force?: boolean;
9
+ }): Promise<{
10
+ path: string;
11
+ contents: string;
12
+ }>;
7
13
  }
8
14
  export declare function configure(codemods: Codemods): Promise<void>;
9
15
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"configure.d.ts","sourceRoot":"","sources":["../src/configure.ts"],"names":[],"mappings":"AAEA,UAAU,QAAQ;IACjB,WAAW,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/C,UAAU,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACxD,SAAS,CACR,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE,GAC3B,OAAO,CAAC,IAAI,CAAC,CAAC;CACjB;AAED,wBAAsB,SAAS,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CAiDjE"}
1
+ {"version":3,"file":"configure.d.ts","sourceRoot":"","sources":["../src/configure.ts"],"names":[],"mappings":"AAGA,UAAU,QAAQ;IACjB,WAAW,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/C,UAAU,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACxD,SAAS,CACR,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE,GAC3B,OAAO,CAAC,IAAI,CAAC,CAAC;IACjB,aAAa,CACZ,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,EAChB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,EACjD,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE,GAC3B,OAAO,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAC/C;AAED,wBAAsB,SAAS,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CA0BjE"}
package/dist/configure.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { randomBytes } from "node:crypto";
2
+ import { stubsRoot } from "./stubs.js";
2
3
  export async function configure(codemods) {
3
4
  const jwtSecret = randomBytes(32).toString("hex");
4
5
  await codemods.addProvider("@c9up/warden/provider");
@@ -6,27 +7,7 @@ export async function configure(codemods) {
6
7
  JWT_SECRET: jwtSecret,
7
8
  JWT_EXPIRY: "3600",
8
9
  });
9
- await codemods.writeFile("config/auth.ts", `import { defineConfig, jwtGuard } from '@c9up/warden'
10
-
11
- export default defineConfig({
12
- default: 'jwt',
13
- guards: {
14
- jwt: jwtGuard({
15
- secret: process.env.JWT_SECRET ?? '',
16
- // Seconds, or a duration string — JWT_EXPIRY=1h works as written.
17
- expiresIn: process.env.JWT_EXPIRY ?? 3600,
18
- // TODO: wire these to your user model (e.g. via your ORM).
19
- // The JWT guard needs both to issue and verify tokens.
20
- findUser: async (_id) => {
21
- throw new Error('TODO: implement findUser(id) for the JWT guard in config/auth.ts')
22
- },
23
- verifyCredentials: async (_email, _password) => {
24
- throw new Error('TODO: implement verifyCredentials(email, password) in config/auth.ts')
25
- },
26
- }),
27
- },
28
- })
29
- `);
10
+ await codemods.makeUsingStub(stubsRoot, "config/auth.stub");
30
11
  // Announce the TODOs on stderr so `ream add @c9up/warden` doesn't end
31
12
  // with a quiet success that the user reads as "auth is wired". The
32
13
  // generated config/auth.ts ships with `throw new Error('TODO ...')`
@@ -1 +1 @@
1
- {"version":3,"file":"configure.js","sourceRoot":"","sources":["../src/configure.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAY1C,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,QAAkB;IACjD,MAAM,SAAS,GAAG,WAAW,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IAClD,MAAM,QAAQ,CAAC,WAAW,CAAC,uBAAuB,CAAC,CAAC;IACpD,MAAM,QAAQ,CAAC,UAAU,CAAC;QACzB,UAAU,EAAE,SAAS;QACrB,UAAU,EAAE,MAAM;KAClB,CAAC,CAAC;IACH,MAAM,QAAQ,CAAC,SAAS,CACvB,gBAAgB,EAChB;;;;;;;;;;;;;;;;;;;;CAoBD,CACC,CAAC;IACF,sEAAsE;IACtE,mEAAmE;IACnE,oEAAoE;IACpE,qEAAqE;IACrE,qEAAqE;IACrE,4DAA4D;IAC5D,iEAAiE;IACjE,OAAO,CAAC,MAAM,CAAC,KAAK,CACnB;QACC,EAAE;QACF,wDAAwD;QACxD,uDAAuD;QACvD,wEAAwE;QACxE,qEAAqE;QACrE,sDAAsD;QACtD,EAAE;KACF,CAAC,IAAI,CAAC,IAAI,CAAC,CACZ,CAAC;AACH,CAAC"}
1
+ {"version":3,"file":"configure.js","sourceRoot":"","sources":["../src/configure.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAkBvC,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,QAAkB;IACjD,MAAM,SAAS,GAAG,WAAW,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IAClD,MAAM,QAAQ,CAAC,WAAW,CAAC,uBAAuB,CAAC,CAAC;IACpD,MAAM,QAAQ,CAAC,UAAU,CAAC;QACzB,UAAU,EAAE,SAAS;QACrB,UAAU,EAAE,MAAM;KAClB,CAAC,CAAC;IACH,MAAM,QAAQ,CAAC,aAAa,CAAC,SAAS,EAAE,kBAAkB,CAAC,CAAC;IAC5D,sEAAsE;IACtE,mEAAmE;IACnE,oEAAoE;IACpE,qEAAqE;IACrE,qEAAqE;IACrE,4DAA4D;IAC5D,iEAAiE;IACjE,OAAO,CAAC,MAAM,CAAC,KAAK,CACnB;QACC,EAAE;QACF,wDAAwD;QACxD,uDAAuD;QACvD,wEAAwE;QACxE,qEAAqE;QACrE,sDAAsD;QACtD,EAAE;KACF,CAAC,IAAI,CAAC,IAAI,CAAC,CACZ,CAAC;AACH,CAAC"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Where this package's stubs live.
3
+ *
4
+ * Its own module, as upstream keeps it: a stub root is a path a package
5
+ * publishes, and a caller importing it should not have to import the
6
+ * configure hook to get it.
7
+ *
8
+ * `import.meta.dirname` rather than a URL — upstream reads it straight off
9
+ * `import.meta`, and deriving it from `import.meta.url` breaks wherever that
10
+ * is not a `file://` URL, which is what a test runner serving modules over
11
+ * HTTP hands you.
12
+ */
13
+ export declare const stubsRoot: string;
14
+ //# sourceMappingURL=stubs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stubs.d.ts","sourceRoot":"","sources":["../src/stubs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAIH,eAAO,MAAM,SAAS,QAA2C,CAAC"}
package/dist/stubs.js ADDED
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Where this package's stubs live.
3
+ *
4
+ * Its own module, as upstream keeps it: a stub root is a path a package
5
+ * publishes, and a caller importing it should not have to import the
6
+ * configure hook to get it.
7
+ *
8
+ * `import.meta.dirname` rather than a URL — upstream reads it straight off
9
+ * `import.meta`, and deriving it from `import.meta.url` breaks wherever that
10
+ * is not a `file://` URL, which is what a test runner serving modules over
11
+ * HTTP hands you.
12
+ */
13
+ import { join } from "node:path";
14
+ export const stubsRoot = join(import.meta.dirname, "..", "stubs");
15
+ //# sourceMappingURL=stubs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stubs.js","sourceRoot":"","sources":["../src/stubs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,MAAM,CAAC,MAAM,SAAS,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC"}
Binary file
Binary file
Binary file
Binary file
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@c9up/warden",
3
- "version": "0.2.1",
3
+ "version": "0.2.3",
4
4
  "description": "Warden — Authentication & authorization for the Ream framework",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -10,6 +10,7 @@
10
10
  "LICENSE",
11
11
  "README.md",
12
12
  "dist",
13
+ "stubs",
13
14
  "index.*.node",
14
15
  "scripts",
15
16
  "src"
@@ -50,7 +51,7 @@
50
51
  },
51
52
  "peerDependencies": {
52
53
  "@c9up/quasar": "^0.1.0 || ^0.2.0",
53
- "@c9up/ream": "^0.2.0"
54
+ "@c9up/ream": "^0.2.26"
54
55
  },
55
56
  "peerDependenciesMeta": {
56
57
  "@c9up/ream": {
@@ -63,15 +64,16 @@
63
64
  "devDependencies": {
64
65
  "@biomejs/biome": "^2.5.12",
65
66
  "@c9up/quasar": "^0.1.0 || ^0.2.0",
66
- "@c9up/ream": "^0.2.0",
67
+ "@c9up/ream": "^0.2.25",
67
68
  "@types/node": "^22.20.1",
68
69
  "@vitest/coverage-v8": "4.1.11",
69
70
  "reflect-metadata": "^0.2.2",
70
71
  "typescript": "^6.0.3",
71
72
  "vitest": "4.1.11"
72
73
  },
74
+ "//engines": "Node 24, not 22, because AsyncLocalStorage sits on the request hot path — the container resolves through it, HttpContext is it, and the emitter reads it on every event. Node 24 backs it with AsyncContextFrame by default, and measured on that exact pattern (one context per request, six async boundaries, several reads) it costs 0.61 us per request instead of 1.55 us: 2.5x, on every request, for free. Before 24 the same mechanism existed only behind an experimental flag, and a framework cannot base its performance on a flag the application has to remember to pass. This is NOT 'track the current LTS' — security fixes still land in 22 until 2027, npm 11 is irrelevant under pnpm, and node:sqlite is not what atlas uses.",
73
75
  "engines": {
74
- "node": ">=22.0.0"
76
+ "node": ">=24.0.0"
75
77
  },
76
78
  "publishConfig": {
77
79
  "access": "public"
package/src/configure.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { randomBytes } from "node:crypto";
2
+ import { stubsRoot } from "./stubs.js";
2
3
 
3
4
  interface Codemods {
4
5
  addProvider(importPath: string): Promise<void>;
@@ -8,6 +9,12 @@ interface Codemods {
8
9
  content: string,
9
10
  options?: { force?: boolean },
10
11
  ): Promise<void>;
12
+ makeUsingStub(
13
+ stubsRoot: string,
14
+ stubPath: string,
15
+ state?: Record<string, string | number | boolean>,
16
+ options?: { force?: boolean },
17
+ ): Promise<{ path: string; contents: string }>;
11
18
  }
12
19
 
13
20
  export async function configure(codemods: Codemods): Promise<void> {
@@ -17,30 +24,7 @@ export async function configure(codemods: Codemods): Promise<void> {
17
24
  JWT_SECRET: jwtSecret,
18
25
  JWT_EXPIRY: "3600",
19
26
  });
20
- await codemods.writeFile(
21
- "config/auth.ts",
22
- `import { defineConfig, jwtGuard } from '@c9up/warden'
23
-
24
- export default defineConfig({
25
- default: 'jwt',
26
- guards: {
27
- jwt: jwtGuard({
28
- secret: process.env.JWT_SECRET ?? '',
29
- // Seconds, or a duration string — JWT_EXPIRY=1h works as written.
30
- expiresIn: process.env.JWT_EXPIRY ?? 3600,
31
- // TODO: wire these to your user model (e.g. via your ORM).
32
- // The JWT guard needs both to issue and verify tokens.
33
- findUser: async (_id) => {
34
- throw new Error('TODO: implement findUser(id) for the JWT guard in config/auth.ts')
35
- },
36
- verifyCredentials: async (_email, _password) => {
37
- throw new Error('TODO: implement verifyCredentials(email, password) in config/auth.ts')
38
- },
39
- }),
40
- },
41
- })
42
- `,
43
- );
27
+ await codemods.makeUsingStub(stubsRoot, "config/auth.stub");
44
28
  // Announce the TODOs on stderr so `ream add @c9up/warden` doesn't end
45
29
  // with a quiet success that the user reads as "auth is wired". The
46
30
  // generated config/auth.ts ships with `throw new Error('TODO ...')`
package/src/stubs.ts ADDED
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Where this package's stubs live.
3
+ *
4
+ * Its own module, as upstream keeps it: a stub root is a path a package
5
+ * publishes, and a caller importing it should not have to import the
6
+ * configure hook to get it.
7
+ *
8
+ * `import.meta.dirname` rather than a URL — upstream reads it straight off
9
+ * `import.meta`, and deriving it from `import.meta.url` breaks wherever that
10
+ * is not a `file://` URL, which is what a test runner serving modules over
11
+ * HTTP hands you.
12
+ */
13
+
14
+ import { join } from "node:path";
15
+
16
+ export const stubsRoot = join(import.meta.dirname, "..", "stubs");
@@ -0,0 +1,23 @@
1
+ ---
2
+ to: config/auth.ts
3
+ ---
4
+ import { defineConfig, jwtGuard } from '@c9up/warden'
5
+
6
+ export default defineConfig({
7
+ default: 'jwt',
8
+ guards: {
9
+ jwt: jwtGuard({
10
+ secret: process.env.JWT_SECRET ?? '',
11
+ // Seconds, or a duration string — JWT_EXPIRY=1h works as written.
12
+ expiresIn: process.env.JWT_EXPIRY ?? 3600,
13
+ // TODO: wire these to your user model (e.g. via your ORM).
14
+ // The JWT guard needs both to issue and verify tokens.
15
+ findUser: async (_id) => {
16
+ throw new Error('TODO: implement findUser(id) for the JWT guard in config/auth.ts')
17
+ },
18
+ verifyCredentials: async (_email, _password) => {
19
+ throw new Error('TODO: implement verifyCredentials(email, password) in config/auth.ts')
20
+ },
21
+ }),
22
+ },
23
+ })