@storyshelf/auth-oauth 0.1.0
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/README.md +68 -0
- package/dist/index.d.mts +34 -0
- package/dist/index.mjs +150 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +61 -0
package/README.md
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# @storyshelf/auth-oauth
|
|
2
|
+
|
|
3
|
+
An OAuth/OIDC auth adapter for StoryShelf: authenticates users against an OpenID Connect provider (e.g. Keycloak) via the authorization-code flow. Sessions are HMAC-signed cookies with a 7-day TTL.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
nub add @storyshelf/auth-oauth
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
or
|
|
12
|
+
|
|
13
|
+
```sh
|
|
14
|
+
npm install @storyshelf/auth-oauth
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Quick start
|
|
18
|
+
|
|
19
|
+
```ts
|
|
20
|
+
import { createOAuthAuth } from "@storyshelf/auth-oauth";
|
|
21
|
+
import { createShelfRouter } from "@storyshelf/core";
|
|
22
|
+
|
|
23
|
+
const auth = createOAuthAuth({
|
|
24
|
+
issuer: process.env.OIDC_ISSUER!,
|
|
25
|
+
clientId: process.env.OIDC_CLIENT_ID!,
|
|
26
|
+
clientSecret: process.env.OIDC_CLIENT_SECRET!,
|
|
27
|
+
secret: process.env.SHELF_SECRET!, // session signing secret
|
|
28
|
+
redirectUrl: process.env.OIDC_REDIRECT_URL!,
|
|
29
|
+
scopes: ["openid", "email", "profile"], // optional
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
const app = createShelfRouter({ database, storage, auth });
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## API
|
|
36
|
+
|
|
37
|
+
### `OAuthAuthOptions`
|
|
38
|
+
|
|
39
|
+
```ts
|
|
40
|
+
interface OAuthAuthOptions {
|
|
41
|
+
issuer: string; // OIDC issuer base URL
|
|
42
|
+
clientId: string; // OIDC client id
|
|
43
|
+
clientSecret: string; // OIDC client secret
|
|
44
|
+
secret: string; // secret used to HMAC-sign session cookies
|
|
45
|
+
redirectUrl: string; // callback/redirect URI registered with the provider
|
|
46
|
+
scopes?: string[]; // defaults to ["openid", "email", "profile"]
|
|
47
|
+
}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### `createOAuthAuth(options: OAuthAuthOptions): OAuthAuth`
|
|
51
|
+
|
|
52
|
+
Returns an `OAuthAuth`, which extends `AuthAdapter` with an extra method:
|
|
53
|
+
|
|
54
|
+
```ts
|
|
55
|
+
interface OAuthAuth extends AuthAdapter {
|
|
56
|
+
loginUrl(state: string): string;
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
- `loginUrl(state)` — builds the authorization URL to redirect users to your OIDC provider.
|
|
61
|
+
- `handleCallback(callback)` — exchanges the authorization code for a token and fetches the userinfo endpoint, returning an `AuthUser` or `null`.
|
|
62
|
+
- `check(request)`, `createSession(user)`, `destroySession(sessionId)` — the standard `AuthAdapter` interface, with sessions verified using timing-safe comparison.
|
|
63
|
+
|
|
64
|
+
## How it fits in
|
|
65
|
+
|
|
66
|
+
`auth-oauth` is the `auth` option for `createShelfRouter` when you want to sign in with an existing identity provider. When supplied, the router redirects unauthenticated UI requests to `loginUrl` and handles the OIDC callback to establish a session.
|
|
67
|
+
|
|
68
|
+
See `docs/architecture.md` and ADR 0008.
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import __tsdown_shims_path from 'node:path';
|
|
2
|
+
import __tsdown_shims_url from 'node:url';
|
|
3
|
+
import { AuthAdapter } from "@storyshelf/core/adapter/auth";
|
|
4
|
+
//#region src/index.d.ts
|
|
5
|
+
/** Options for configuring an OAuth/OIDC auth adapter. */
|
|
6
|
+
interface OAuthAuthOptions {
|
|
7
|
+
/** OIDC issuer base URL. */
|
|
8
|
+
issuer: string;
|
|
9
|
+
/** OAuth client ID. */
|
|
10
|
+
clientId: string;
|
|
11
|
+
/** OAuth client secret. */
|
|
12
|
+
clientSecret: string;
|
|
13
|
+
/** Secret used to sign and verify session cookies. */
|
|
14
|
+
secret: string;
|
|
15
|
+
/** Redirect URL registered with the OIDC provider. */
|
|
16
|
+
redirectUrl: string;
|
|
17
|
+
/** Optional OAuth scopes. Defaults to `openid`, `email`, `profile`. */
|
|
18
|
+
scopes?: string[];
|
|
19
|
+
}
|
|
20
|
+
/** Auth adapter that authenticates against an OAuth/OIDC provider. */
|
|
21
|
+
interface OAuthAuth extends AuthAdapter {
|
|
22
|
+
/** Build the provider authorization URL for a login flow with the given anti-CSRF `state`. */
|
|
23
|
+
loginUrl(state: string): string;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Create an OAuth/OIDC auth adapter.
|
|
27
|
+
*
|
|
28
|
+
* @param options - OIDC provider and session configuration.
|
|
29
|
+
* @returns An OAuthAuth instance.
|
|
30
|
+
*/
|
|
31
|
+
declare function createOAuthAuth(options: OAuthAuthOptions): OAuthAuth;
|
|
32
|
+
//#endregion
|
|
33
|
+
export { OAuthAuth, OAuthAuthOptions, createOAuthAuth };
|
|
34
|
+
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import "node:path";
|
|
2
|
+
import "node:url";
|
|
3
|
+
import.meta.url;
|
|
4
|
+
import { SESSION_COOKIE } from "@storyshelf/core/adapter/auth";
|
|
5
|
+
import { createHmac, timingSafeEqual } from "node:crypto";
|
|
6
|
+
//#region src/index.ts
|
|
7
|
+
const SESSION_TTL_MS = 6048e5;
|
|
8
|
+
function hmacHex(secret, value) {
|
|
9
|
+
return createHmac("sha256", secret).update(value).digest("hex");
|
|
10
|
+
}
|
|
11
|
+
function equalStrings(left, right) {
|
|
12
|
+
const leftBuffer = Buffer.from(left);
|
|
13
|
+
const rightBuffer = Buffer.from(right);
|
|
14
|
+
return leftBuffer.length === rightBuffer.length && timingSafeEqual(leftBuffer, rightBuffer);
|
|
15
|
+
}
|
|
16
|
+
function encodePayload(payload) {
|
|
17
|
+
return Buffer.from(JSON.stringify(payload)).toString("base64url");
|
|
18
|
+
}
|
|
19
|
+
function decodePayload(body) {
|
|
20
|
+
try {
|
|
21
|
+
return JSON.parse(Buffer.from(body, "base64url").toString("utf8"));
|
|
22
|
+
} catch {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
function signPayload(secret, payload) {
|
|
27
|
+
const body = encodePayload(payload);
|
|
28
|
+
return `${body}.${hmacHex(secret, body)}`;
|
|
29
|
+
}
|
|
30
|
+
function verifyPayload(secret, token) {
|
|
31
|
+
const dot = token.lastIndexOf(".");
|
|
32
|
+
if (dot === -1) return null;
|
|
33
|
+
const body = token.slice(0, dot);
|
|
34
|
+
const signature = token.slice(dot + 1);
|
|
35
|
+
if (!equalStrings(hmacHex(secret, body), signature)) return null;
|
|
36
|
+
return decodePayload(body);
|
|
37
|
+
}
|
|
38
|
+
function readCookie(request, name) {
|
|
39
|
+
const header = request.headers.get("cookie");
|
|
40
|
+
if (!header) return;
|
|
41
|
+
for (const part of header.split(";")) {
|
|
42
|
+
const eq = part.indexOf("=");
|
|
43
|
+
if (eq === -1) continue;
|
|
44
|
+
if (part.slice(0, eq).trim() === name) return part.slice(eq + 1).trim();
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
function toUser(payload) {
|
|
48
|
+
return {
|
|
49
|
+
id: payload.userId,
|
|
50
|
+
email: payload.email,
|
|
51
|
+
name: payload.name,
|
|
52
|
+
avatarUrl: payload.avatarUrl,
|
|
53
|
+
role: payload.role
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
function buildLoginUrl(options, scopes, state) {
|
|
57
|
+
const params = new URLSearchParams({
|
|
58
|
+
client_id: options.clientId,
|
|
59
|
+
redirect_uri: options.redirectUrl,
|
|
60
|
+
response_type: "code",
|
|
61
|
+
scope: scopes.join(" "),
|
|
62
|
+
state
|
|
63
|
+
});
|
|
64
|
+
return `${options.issuer}/protocol/openid-connect/auth?${params.toString()}`;
|
|
65
|
+
}
|
|
66
|
+
async function exchangeCode(options, code) {
|
|
67
|
+
const body = new URLSearchParams({
|
|
68
|
+
grant_type: "authorization_code",
|
|
69
|
+
code,
|
|
70
|
+
client_id: options.clientId,
|
|
71
|
+
client_secret: options.clientSecret,
|
|
72
|
+
redirect_uri: options.redirectUrl
|
|
73
|
+
});
|
|
74
|
+
const response = await fetch(`${options.issuer}/protocol/openid-connect/token`, {
|
|
75
|
+
method: "POST",
|
|
76
|
+
headers: { "content-type": "application/x-www-form-urlencoded" },
|
|
77
|
+
body: body.toString()
|
|
78
|
+
});
|
|
79
|
+
if (!response.ok) return null;
|
|
80
|
+
return (await response.json()).access_token ?? null;
|
|
81
|
+
}
|
|
82
|
+
async function fetchUserInfo(options, accessToken) {
|
|
83
|
+
const response = await fetch(`${options.issuer}/protocol/openid-connect/userinfo`, { headers: { authorization: `Bearer ${accessToken}` } });
|
|
84
|
+
if (!response.ok) return null;
|
|
85
|
+
const info = await response.json();
|
|
86
|
+
if (!info.sub) return null;
|
|
87
|
+
return {
|
|
88
|
+
id: info.sub,
|
|
89
|
+
email: info.email ?? "",
|
|
90
|
+
name: info.name ?? info.email ?? info.sub,
|
|
91
|
+
avatarUrl: info.picture,
|
|
92
|
+
role: "member"
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Create an OAuth/OIDC auth adapter.
|
|
97
|
+
*
|
|
98
|
+
* @param options - OIDC provider and session configuration.
|
|
99
|
+
* @returns An OAuthAuth instance.
|
|
100
|
+
*/
|
|
101
|
+
function createOAuthAuth(options) {
|
|
102
|
+
const { secret } = options;
|
|
103
|
+
const scopes = options.scopes ?? [
|
|
104
|
+
"openid",
|
|
105
|
+
"email",
|
|
106
|
+
"profile"
|
|
107
|
+
];
|
|
108
|
+
const check = async (request) => {
|
|
109
|
+
const token = readCookie(request, SESSION_COOKIE);
|
|
110
|
+
if (!token) return null;
|
|
111
|
+
const payload = verifyPayload(secret, token);
|
|
112
|
+
if (!payload || payload.expiresAt <= Date.now()) return null;
|
|
113
|
+
return toUser(payload);
|
|
114
|
+
};
|
|
115
|
+
const createSession = async (user) => {
|
|
116
|
+
const payload = {
|
|
117
|
+
userId: user.id,
|
|
118
|
+
email: user.email,
|
|
119
|
+
name: user.name,
|
|
120
|
+
avatarUrl: user.avatarUrl,
|
|
121
|
+
role: user.role,
|
|
122
|
+
expiresAt: Date.now() + SESSION_TTL_MS
|
|
123
|
+
};
|
|
124
|
+
return signPayload(secret, payload);
|
|
125
|
+
};
|
|
126
|
+
const handleCallback = async (callback) => {
|
|
127
|
+
const token = await exchangeCode(options, callback.code);
|
|
128
|
+
if (!token) return null;
|
|
129
|
+
return fetchUserInfo(options, token);
|
|
130
|
+
};
|
|
131
|
+
return {
|
|
132
|
+
metadata: {
|
|
133
|
+
name: "OAuth",
|
|
134
|
+
version: "0.1.0",
|
|
135
|
+
description: "OAuth/OIDC auth adapter",
|
|
136
|
+
kind: "oauth"
|
|
137
|
+
},
|
|
138
|
+
check,
|
|
139
|
+
createSession,
|
|
140
|
+
async destroySession() {
|
|
141
|
+
await Promise.resolve();
|
|
142
|
+
},
|
|
143
|
+
handleCallback,
|
|
144
|
+
loginUrl: (state) => buildLoginUrl(options, scopes, state)
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
//#endregion
|
|
148
|
+
export { createOAuthAuth };
|
|
149
|
+
|
|
150
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["import { SESSION_COOKIE, type AuthAdapter, type AuthCallback, type AuthUser } from \"@storyshelf/core/adapter/auth\";\nimport { createHmac, timingSafeEqual } from \"node:crypto\";\n\ndeclare const __PKG_VERSION__: string;\n\nconst SESSION_TTL_MS = 7 * 24 * 60 * 60 * 1000;\n\ninterface SessionPayload {\n userId: string;\n email: string;\n name: string;\n avatarUrl?: string;\n role: AuthUser[\"role\"];\n expiresAt: number;\n}\n\ninterface TokenResponse {\n access_token?: string;\n}\n\ninterface UserInfoResponse {\n sub?: string;\n email?: string;\n name?: string;\n picture?: string;\n}\n\n/** Options for configuring an OAuth/OIDC auth adapter. */\nexport interface OAuthAuthOptions {\n /** OIDC issuer base URL. */\n issuer: string;\n /** OAuth client ID. */\n clientId: string;\n /** OAuth client secret. */\n clientSecret: string;\n /** Secret used to sign and verify session cookies. */\n secret: string;\n /** Redirect URL registered with the OIDC provider. */\n redirectUrl: string;\n /** Optional OAuth scopes. Defaults to `openid`, `email`, `profile`. */\n scopes?: string[];\n}\n\n/** Auth adapter that authenticates against an OAuth/OIDC provider. */\nexport interface OAuthAuth extends AuthAdapter {\n /** Build the provider authorization URL for a login flow with the given anti-CSRF `state`. */\n loginUrl(state: string): string;\n}\n\nfunction hmacHex(secret: string, value: string): string {\n return createHmac(\"sha256\", secret).update(value).digest(\"hex\");\n}\n\nfunction equalStrings(left: string, right: string): boolean {\n const leftBuffer = Buffer.from(left);\n const rightBuffer = Buffer.from(right);\n return leftBuffer.length === rightBuffer.length && timingSafeEqual(leftBuffer, rightBuffer);\n}\n\nfunction encodePayload(payload: SessionPayload): string {\n return Buffer.from(JSON.stringify(payload)).toString(\"base64url\");\n}\n\nfunction decodePayload(body: string): SessionPayload | null {\n try {\n return JSON.parse(Buffer.from(body, \"base64url\").toString(\"utf8\")) as SessionPayload;\n } catch {\n return null;\n }\n}\n\nfunction signPayload(secret: string, payload: SessionPayload): string {\n const body = encodePayload(payload);\n return `${body}.${hmacHex(secret, body)}`;\n}\n\nfunction verifyPayload(secret: string, token: string): SessionPayload | null {\n const dot = token.lastIndexOf(\".\");\n if (dot === -1) {\n return null;\n }\n const body = token.slice(0, dot);\n const signature = token.slice(dot + 1);\n if (!equalStrings(hmacHex(secret, body), signature)) {\n return null;\n }\n return decodePayload(body);\n}\n\nfunction readCookie(request: Request, name: string): string | undefined {\n const header = request.headers.get(\"cookie\");\n if (!header) {\n return undefined;\n }\n for (const part of header.split(\";\")) {\n const eq = part.indexOf(\"=\");\n if (eq === -1) {\n continue;\n }\n if (part.slice(0, eq).trim() === name) {\n return part.slice(eq + 1).trim();\n }\n }\n return undefined;\n}\n\nfunction toUser(payload: SessionPayload): AuthUser {\n return {\n id: payload.userId,\n email: payload.email,\n name: payload.name,\n avatarUrl: payload.avatarUrl,\n role: payload.role,\n };\n}\n\nfunction buildLoginUrl(options: OAuthAuthOptions, scopes: string[], state: string): string {\n const params = new URLSearchParams({\n client_id: options.clientId,\n redirect_uri: options.redirectUrl,\n response_type: \"code\",\n scope: scopes.join(\" \"),\n state,\n });\n return `${options.issuer}/protocol/openid-connect/auth?${params.toString()}`;\n}\n\nasync function exchangeCode(options: OAuthAuthOptions, code: string): Promise<string | null> {\n const body = new URLSearchParams({\n grant_type: \"authorization_code\",\n code,\n client_id: options.clientId,\n client_secret: options.clientSecret,\n redirect_uri: options.redirectUrl,\n });\n const response = await fetch(`${options.issuer}/protocol/openid-connect/token`, {\n method: \"POST\",\n headers: { \"content-type\": \"application/x-www-form-urlencoded\" },\n body: body.toString(),\n });\n if (!response.ok) {\n return null;\n }\n const data = (await response.json()) as TokenResponse;\n return data.access_token ?? null;\n}\n\nasync function fetchUserInfo(\n options: OAuthAuthOptions,\n accessToken: string,\n): Promise<AuthUser | null> {\n const response = await fetch(`${options.issuer}/protocol/openid-connect/userinfo`, {\n headers: { authorization: `Bearer ${accessToken}` },\n });\n if (!response.ok) {\n return null;\n }\n const info = (await response.json()) as UserInfoResponse;\n if (!info.sub) {\n return null;\n }\n return {\n id: info.sub,\n email: info.email ?? \"\",\n name: info.name ?? info.email ?? info.sub,\n avatarUrl: info.picture,\n role: \"member\",\n };\n}\n\n/**\n * Create an OAuth/OIDC auth adapter.\n *\n * @param options - OIDC provider and session configuration.\n * @returns An OAuthAuth instance.\n */\nexport function createOAuthAuth(options: OAuthAuthOptions): OAuthAuth {\n const { secret } = options;\n const scopes = options.scopes ?? [\"openid\", \"email\", \"profile\"];\n\n // Async is required by the AuthAdapter interface, though the logic is synchronous.\n // eslint-disable-next-line require-await\n const check = async (request: Request): Promise<AuthUser | null> => {\n const token = readCookie(request, SESSION_COOKIE);\n if (!token) {\n return null;\n }\n const payload = verifyPayload(secret, token);\n if (!payload || payload.expiresAt <= Date.now()) {\n return null;\n }\n return toUser(payload);\n };\n\n // eslint-disable-next-line require-await\n const createSession = async (user: AuthUser): Promise<string> => {\n const payload: SessionPayload = {\n userId: user.id,\n email: user.email,\n name: user.name,\n avatarUrl: user.avatarUrl,\n role: user.role,\n expiresAt: Date.now() + SESSION_TTL_MS,\n };\n return signPayload(secret, payload);\n };\n\n const handleCallback = async (callback: AuthCallback): Promise<AuthUser | null> => {\n const token = await exchangeCode(options, callback.code);\n if (!token) {\n return null;\n }\n return fetchUserInfo(options, token);\n };\n\n return {\n metadata: {\n name: \"OAuth\",\n version: typeof __PKG_VERSION__ === \"undefined\" ? \"0.0.0\" : __PKG_VERSION__, // oxlint-disable-line unicorn/no-typeof-undefined\n description: \"OAuth/OIDC auth adapter\",\n kind: \"oauth\",\n },\n check,\n createSession,\n async destroySession() {\n await Promise.resolve();\n },\n handleCallback,\n loginUrl: (state: string) => buildLoginUrl(options, scopes, state),\n };\n}\n"],"mappings":";;;;;;AAKA,MAAM,iBAAiB;AA4CvB,SAAS,QAAQ,QAAgB,OAAuB;CACtD,OAAO,WAAW,UAAU,MAAM,CAAC,CAAC,OAAO,KAAK,CAAC,CAAC,OAAO,KAAK;AAChE;AAEA,SAAS,aAAa,MAAc,OAAwB;CAC1D,MAAM,aAAa,OAAO,KAAK,IAAI;CACnC,MAAM,cAAc,OAAO,KAAK,KAAK;CACrC,OAAO,WAAW,WAAW,YAAY,UAAU,gBAAgB,YAAY,WAAW;AAC5F;AAEA,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CAGA,MAAM,gBAAgB,OAAO,SAAoC;EAC/D,MAAM,UAA0B;GAC9B,QAAQ,KAAK;GACb,OAAO,KAAK;GACZ,MAAM,KAAK;GACX,WAAW,KAAK;GAChB,MAAM,KAAK;GACX,WAAW,KAAK,IAAI,IAAI;EAC1B;EACA,OAAO,YAAY,QAAQ,OAAO;CACpC;CAEA,MAAM,iBAAiB,OAAO,aAAqD;EACjF,MAAM,QAAQ,MAAM,aAAa,SAAS,SAAS,IAAI;EACvD,IAAI,CAAC,OACH,OAAO;EAET,OAAO,cAAc,SAAS,KAAK;CACrC;CAEA,OAAO;EACL,UAAU;GACR,MAAM;GACN,SAAA;GACA,aAAa;GACb,MAAM;EACR;EACA;EACA;EACA,MAAM,iBAAiB;GACrB,MAAM,QAAQ,QAAQ;EACxB;EACA;EACA,WAAW,UAAkB,cAAc,SAAS,QAAQ,KAAK;CACnE;AACF"}
|
package/package.json
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@storyshelf/auth-oauth",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "OIDC authorization-code auth adapter for StoryShelf.",
|
|
6
|
+
"author": {
|
|
7
|
+
"name": "Siddhant Gupta",
|
|
8
|
+
"url": "https://guptasiddhant.com"
|
|
9
|
+
},
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"sideEffects": false,
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "git+https://github.com/GuptaSiddhant/storyshelf.git",
|
|
15
|
+
"directory": "packages/auth-oauth"
|
|
16
|
+
},
|
|
17
|
+
"homepage": "https://github.com/GuptaSiddhant/storyshelf#readme",
|
|
18
|
+
"bugs": {
|
|
19
|
+
"url": "https://github.com/GuptaSiddhant/storyshelf/issues"
|
|
20
|
+
},
|
|
21
|
+
"publishConfig": {
|
|
22
|
+
"access": "public",
|
|
23
|
+
"exports": {
|
|
24
|
+
".": "./dist/index.mjs",
|
|
25
|
+
"./package.json": "./package.json"
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
"files": [
|
|
29
|
+
"dist"
|
|
30
|
+
],
|
|
31
|
+
"scripts": {
|
|
32
|
+
"build": "tsdown",
|
|
33
|
+
"dev": "tsdown -w",
|
|
34
|
+
"fmt": "oxfmt -c ../../.oxfmtrc.json ./src",
|
|
35
|
+
"lint": "oxlint --type-aware --type-check ./src",
|
|
36
|
+
"test": "vitest run",
|
|
37
|
+
"prepublishOnly": "nub run build"
|
|
38
|
+
},
|
|
39
|
+
"dependencies": {
|
|
40
|
+
"@storyshelf/core": "workspace:*",
|
|
41
|
+
"hono": "^4.11.0"
|
|
42
|
+
},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"@types/node": "catalog:",
|
|
45
|
+
"@vitest/coverage-v8": "catalog:",
|
|
46
|
+
"oxfmt": "catalog:",
|
|
47
|
+
"oxlint": "catalog:",
|
|
48
|
+
"oxlint-tsgolint": "catalog:",
|
|
49
|
+
"tsdown": "catalog:",
|
|
50
|
+
"typescript": "catalog:",
|
|
51
|
+
"vitest": "catalog:"
|
|
52
|
+
},
|
|
53
|
+
"types": "./dist/index.d.mts",
|
|
54
|
+
"exports": {
|
|
55
|
+
".": {
|
|
56
|
+
"source": "./src/index.ts",
|
|
57
|
+
"default": "./dist/index.mjs"
|
|
58
|
+
},
|
|
59
|
+
"./package.json": "./package.json"
|
|
60
|
+
}
|
|
61
|
+
}
|