@c9up/warden 0.2.2 → 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.
- package/dist/configure.d.ts +6 -0
- package/dist/configure.d.ts.map +1 -1
- package/dist/configure.js +2 -21
- package/dist/configure.js.map +1 -1
- package/dist/stubs.d.ts +14 -0
- package/dist/stubs.d.ts.map +1 -0
- package/dist/stubs.js +15 -0
- package/dist/stubs.js.map +1 -0
- package/index.win32-x64-msvc.node +0 -0
- package/package.json +4 -3
- package/src/configure.ts +8 -24
- package/src/stubs.ts +16 -0
- package/stubs/config/auth.stub +23 -0
package/dist/configure.d.ts
CHANGED
|
@@ -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 {};
|
package/dist/configure.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configure.d.ts","sourceRoot":"","sources":["../src/configure.ts"],"names":[],"mappings":"
|
|
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.
|
|
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 ...')`
|
package/dist/configure.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configure.js","sourceRoot":"","sources":["../src/configure.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,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"}
|
package/dist/stubs.d.ts
ADDED
|
@@ -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
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@c9up/warden",
|
|
3
|
-
"version": "0.2.
|
|
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.
|
|
54
|
+
"@c9up/ream": "^0.2.26"
|
|
54
55
|
},
|
|
55
56
|
"peerDependenciesMeta": {
|
|
56
57
|
"@c9up/ream": {
|
|
@@ -63,7 +64,7 @@
|
|
|
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.
|
|
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",
|
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.
|
|
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
|
+
})
|