@takuhon/api 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/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright 2026 Takuhon contributors
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/NOTICE ADDED
@@ -0,0 +1,10 @@
1
+ @takuhon/api
2
+ Copyright 2026 Takuhon contributors
3
+
4
+ This product includes software developed by the Takuhon project
5
+ (https://github.com/takuhon-dev/takuhon).
6
+
7
+ Licensed under the Apache License, Version 2.0 (see LICENSE).
8
+
9
+ Third-party dependencies retain their own licenses; see this package's
10
+ node_modules listing for details.
package/README.md ADDED
@@ -0,0 +1,13 @@
1
+ # @takuhon/api
2
+
3
+ Hono-based HTTP route handlers, RFC 7807 Problem Details error envelope, and response builders for Takuhon.
4
+
5
+ Ships:
6
+
7
+ - `createPublicApp({ storage })` — public profile read endpoints, JSON-LD output, `/.well-known/takuhon.json`
8
+ - `createAdminApiApp({ storage, bearerToken, originAllowlist, cachePurger, auditLogger })` — `PUT`/`DELETE /api/admin/profile` with optimistic locking (`If-Match`), audit logging, and edge-cache purging
9
+ - `createAdminUiApp()` — minimal HTML admin editor (token + JSON textarea + Save/Delete)
10
+ - `CachePurger` and `AuditLogger` dependency-injection interfaces (with `noopCachePurger` / `noopAuditLogger` no-op implementations)
11
+ - `buildProblem` / `problemResponse` helpers and the `ProblemDetails` / `ErrorSlug` types for RFC 7807 error envelopes
12
+
13
+ The package is framework-agnostic Hono — adapters (`@takuhon/cloudflare`, `@takuhon/static`, …) compose these factories with a storage backend and a runtime.
@@ -0,0 +1,150 @@
1
+ import { Context, Hono } from 'hono';
2
+ import { ContentfulStatusCode } from 'hono/utils/http-status';
3
+ import { TakuhonStorage, Takuhon } from '@takuhon/core';
4
+
5
+ /**
6
+ * RFC 7807 problem type slugs used by takuhon. The 11 below are the
7
+ * Spec-defined values (api.md §5.1); `methodNotAllowed` is added locally
8
+ * for the 405 path that the Spec leaves unnamed.
9
+ */
10
+ declare const ERROR_SLUGS: {
11
+ readonly badRequest: "bad-request";
12
+ readonly unauthorized: "unauthorized";
13
+ readonly forbidden: "forbidden";
14
+ readonly notFound: "not-found";
15
+ readonly methodNotAllowed: "method-not-allowed";
16
+ readonly conflict: "conflict";
17
+ readonly payloadTooLarge: "payload-too-large";
18
+ readonly unsupportedMediaType: "unsupported-media-type";
19
+ readonly validationFailed: "validation-failed";
20
+ readonly tooManyRequests: "too-many-requests";
21
+ readonly internal: "internal";
22
+ readonly serviceUnavailable: "service-unavailable";
23
+ };
24
+ type ErrorSlug = (typeof ERROR_SLUGS)[keyof typeof ERROR_SLUGS];
25
+ interface ProblemFieldError {
26
+ path: string;
27
+ message: string;
28
+ }
29
+ interface ProblemDetails {
30
+ type: string;
31
+ title: string;
32
+ status: number;
33
+ detail: string;
34
+ instance: string;
35
+ errors?: ProblemFieldError[];
36
+ currentVersion?: string;
37
+ }
38
+ interface BuildProblemInput {
39
+ slug: ErrorSlug;
40
+ status: number;
41
+ title: string;
42
+ detail: string;
43
+ instance: string;
44
+ errors?: ProblemFieldError[];
45
+ currentVersion?: string;
46
+ }
47
+ declare function buildProblem(input: BuildProblemInput): ProblemDetails;
48
+ interface ProblemResponseInput {
49
+ slug: ErrorSlug;
50
+ status: ContentfulStatusCode;
51
+ title: string;
52
+ detail: string;
53
+ errors?: ProblemFieldError[];
54
+ currentVersion?: string;
55
+ }
56
+ declare function problemResponse(c: Context, input: ProblemResponseInput): Response;
57
+
58
+ interface PublicAppDeps {
59
+ storage: TakuhonStorage;
60
+ /**
61
+ * Returned when storage reports NotFoundError. Adapters that ship a
62
+ * bundled example fixture (e.g. @takuhon/cloudflare) pass a thunk that
63
+ * returns the validated document so initial-onboarding requests still
64
+ * succeed before the first admin write.
65
+ */
66
+ fallback?: () => Takuhon;
67
+ }
68
+ declare function createPublicApp(deps: PublicAppDeps): Hono;
69
+
70
+ /**
71
+ * Structured audit-log emitter for admin actions (per security.md §5).
72
+ *
73
+ * Phase 3.4 covers the auth + profile-write events. Asset events
74
+ * (`admin.asset.upload`, `admin.asset.delete`) join the union when Phase 3.5
75
+ * lands. Adapters bind a concrete sink (Cloudflare uses `console.log`, which
76
+ * Workers Tail / Logpush captures); tests inject a `vi.fn()` recorder.
77
+ */
78
+ type AuditEventType = 'admin.auth.success' | 'admin.auth.failure' | 'admin.profile.update' | 'admin.profile.delete' | 'admin.cache.purge';
79
+ interface AuditEvent {
80
+ type: AuditEventType;
81
+ /** ISO-8601 UTC timestamp generated at the call site. */
82
+ timestamp: string;
83
+ /**
84
+ * Actor identity. `tokenHash` is `sha256:<hex>` over the presented Bearer
85
+ * token, or `sha256:absent` when no token was supplied. The raw token is
86
+ * never logged.
87
+ */
88
+ actor?: {
89
+ tokenHash: string;
90
+ };
91
+ request: {
92
+ method: string;
93
+ path: string;
94
+ /** Originating client IP from `cf-connecting-ip`; undefined off-Cloudflare. */
95
+ ip?: string;
96
+ };
97
+ result: {
98
+ status: number;
99
+ /** Opaque storage version emitted by `TakuhonStorage.saveProfile`. */
100
+ version?: string;
101
+ };
102
+ }
103
+ type AuditLogger = (event: AuditEvent) => void;
104
+ /** Default sink that discards events; useful for tests and bare runtimes. */
105
+ declare const noopAuditLogger: AuditLogger;
106
+
107
+ /**
108
+ * Cache invalidation contract for admin write paths.
109
+ *
110
+ * `@takuhon/api` stays adapter-neutral, so the actual edge-cache calls live
111
+ * in each adapter (Cloudflare's `caches.default.delete`, future runtimes'
112
+ * equivalents). Tests inject a recording implementation to assert that the
113
+ * admin handlers fire the right purge after a successful write.
114
+ */
115
+ interface CachePurger {
116
+ /** Called after a successful `PUT /api/admin/profile`. */
117
+ profileUpdated(): Promise<void>;
118
+ /** Called after a successful `DELETE /api/admin/profile`. */
119
+ profileDeleted(): Promise<void>;
120
+ }
121
+ /**
122
+ * No-op default: callers that don't run on an edge cache (Node dev server,
123
+ * unit tests that don't care about purge calls) can pass this in.
124
+ */
125
+ declare const noopCachePurger: CachePurger;
126
+
127
+ interface AdminApiAppDeps {
128
+ storage: TakuhonStorage;
129
+ /** Returns the configured admin token, or undefined if no secret is set. */
130
+ getAdminToken: () => string | undefined;
131
+ /** Allowlist of origins permitted for browser-originating admin requests. */
132
+ getAdminOrigins: () => string[];
133
+ cachePurger: CachePurger;
134
+ auditLogger: AuditLogger;
135
+ }
136
+ /**
137
+ * Hono factory for `/api/admin/profile`. Mounted by adapters at `/api/admin`
138
+ * (so the sub-app sees `/profile` as the route path).
139
+ */
140
+ declare function createAdminApiApp(deps: AdminApiAppDeps): Hono;
141
+
142
+ /**
143
+ * Hono factory for the `/admin` HTML editor. Mounted by adapters at
144
+ * `/admin` (so the sub-app sees `/` as its root path). Each request gets a
145
+ * freshly-generated nonce shared between the CSP header and the inline
146
+ * `<style>` / `<script>` tags.
147
+ */
148
+ declare function createAdminUiApp(): Hono;
149
+
150
+ export { type AdminApiAppDeps, type AuditEvent, type AuditEventType, type AuditLogger, type BuildProblemInput, type CachePurger, ERROR_SLUGS, type ErrorSlug, type ProblemDetails, type ProblemFieldError, type ProblemResponseInput, type PublicAppDeps, buildProblem, createAdminApiApp, createAdminUiApp, createPublicApp, noopAuditLogger, noopCachePurger, problemResponse };
package/dist/index.js ADDED
@@ -0,0 +1,597 @@
1
+ // src/error-envelope.ts
2
+ var ERROR_SLUGS = {
3
+ badRequest: "bad-request",
4
+ unauthorized: "unauthorized",
5
+ forbidden: "forbidden",
6
+ notFound: "not-found",
7
+ methodNotAllowed: "method-not-allowed",
8
+ conflict: "conflict",
9
+ payloadTooLarge: "payload-too-large",
10
+ unsupportedMediaType: "unsupported-media-type",
11
+ validationFailed: "validation-failed",
12
+ tooManyRequests: "too-many-requests",
13
+ internal: "internal",
14
+ serviceUnavailable: "service-unavailable"
15
+ };
16
+ var TYPE_BASE = "https://takuhon.org/errors";
17
+ function buildProblem(input) {
18
+ const out = {
19
+ type: `${TYPE_BASE}/${input.slug}`,
20
+ title: input.title,
21
+ status: input.status,
22
+ detail: input.detail,
23
+ instance: input.instance
24
+ };
25
+ if (input.errors !== void 0) out.errors = input.errors;
26
+ if (input.currentVersion !== void 0) out.currentVersion = input.currentVersion;
27
+ return out;
28
+ }
29
+ function problemResponse(c, input) {
30
+ const body = buildProblem({
31
+ slug: input.slug,
32
+ status: input.status,
33
+ title: input.title,
34
+ detail: input.detail,
35
+ instance: new URL(c.req.url).pathname,
36
+ errors: input.errors,
37
+ currentVersion: input.currentVersion
38
+ });
39
+ return c.body(JSON.stringify(body), input.status, {
40
+ "content-type": "application/problem+json; charset=utf-8"
41
+ });
42
+ }
43
+
44
+ // src/public-app.ts
45
+ import {
46
+ NotFoundError,
47
+ SCHEMA_VERSION,
48
+ generateJsonLd,
49
+ normalize,
50
+ resolveLocale,
51
+ schema
52
+ } from "@takuhon/core";
53
+ import { Hono } from "hono";
54
+ var FALLBACK_VERSION = "bundled-fixture";
55
+ var PUBLIC_CSP = [
56
+ "default-src 'self'",
57
+ "img-src 'self' data:",
58
+ "style-src 'self' 'unsafe-inline'",
59
+ "script-src 'self'",
60
+ "font-src 'self'",
61
+ "connect-src 'self'",
62
+ "frame-ancestors 'none'",
63
+ "base-uri 'self'",
64
+ "form-action 'self'",
65
+ "upgrade-insecure-requests"
66
+ ].join("; ");
67
+ async function loadProfile(deps) {
68
+ try {
69
+ return await deps.storage.getProfile();
70
+ } catch (e) {
71
+ if (e instanceof NotFoundError && deps.fallback) {
72
+ return { data: deps.fallback(), version: FALLBACK_VERSION };
73
+ }
74
+ throw e;
75
+ }
76
+ }
77
+ function createPublicApp(deps) {
78
+ const app = new Hono();
79
+ app.use("*", async (c, next) => {
80
+ await next();
81
+ const h = c.res.headers;
82
+ h.set("strict-transport-security", "max-age=63072000; includeSubDomains; preload");
83
+ h.set("x-content-type-options", "nosniff");
84
+ h.set("x-frame-options", "DENY");
85
+ h.set("referrer-policy", "strict-origin-when-cross-origin");
86
+ h.set("permissions-policy", "camera=(), microphone=(), geolocation=(), interest-cohort=()");
87
+ h.set("content-security-policy", PUBLIC_CSP);
88
+ });
89
+ app.onError(
90
+ (err, c) => problemResponse(c, {
91
+ slug: ERROR_SLUGS.internal,
92
+ status: 500,
93
+ title: "Internal Error",
94
+ detail: err instanceof Error ? err.message : "Unknown failure"
95
+ })
96
+ );
97
+ app.notFound(
98
+ (c) => problemResponse(c, {
99
+ slug: ERROR_SLUGS.notFound,
100
+ status: 404,
101
+ title: "Not Found",
102
+ detail: `No route matches ${new URL(c.req.url).pathname}.`
103
+ })
104
+ );
105
+ app.get("/", (c) => c.text("takuhon \u2014 visit /api/profile or /api/schema\n"));
106
+ app.get("/api/profile", async (c) => {
107
+ const lang = c.req.query("lang");
108
+ const { data, version } = await loadProfile(deps);
109
+ const localized = resolveLocale(normalize(data), lang);
110
+ const body = {
111
+ data: localized,
112
+ meta: {
113
+ schemaVersion: localized.schemaVersion,
114
+ locale: localized.resolvedLocale,
115
+ updatedAt: localized.meta.updatedAt
116
+ }
117
+ };
118
+ c.header("etag", `"${version}"`);
119
+ c.header("cache-control", "public, max-age=300, s-maxage=300");
120
+ return c.json(body);
121
+ });
122
+ app.get("/api/schema", (c) => c.json(schema));
123
+ app.get("/api/jsonld", async (c) => {
124
+ const lang = c.req.query("lang");
125
+ const { data, version } = await loadProfile(deps);
126
+ const localized = resolveLocale(normalize(data), lang);
127
+ const ld = generateJsonLd(localized);
128
+ c.header("etag", `"${version}"`);
129
+ c.header("cache-control", "public, max-age=300, s-maxage=300");
130
+ c.header("content-type", "application/ld+json; charset=utf-8");
131
+ return c.body(JSON.stringify(ld));
132
+ });
133
+ app.get("/takuhon.json", async (c) => {
134
+ const { data, version } = await loadProfile(deps);
135
+ c.header("etag", `"${version}"`);
136
+ c.header("cache-control", "public, max-age=300");
137
+ return c.json(data);
138
+ });
139
+ app.get("/.well-known/takuhon.json", (c) => {
140
+ c.header("cache-control", "public, max-age=3600");
141
+ return c.json({
142
+ schemaVersion: SCHEMA_VERSION,
143
+ schemaUrl: "/api/schema",
144
+ profile: "/api/profile",
145
+ jsonld: "/api/jsonld",
146
+ export: "/api/export",
147
+ canonical: "/takuhon.json"
148
+ });
149
+ });
150
+ app.on(
151
+ ["POST", "PUT", "PATCH", "DELETE"],
152
+ "*",
153
+ (c) => problemResponse(c, {
154
+ slug: ERROR_SLUGS.methodNotAllowed,
155
+ status: 405,
156
+ title: "Method Not Allowed",
157
+ detail: `${c.req.method} ${new URL(c.req.url).pathname} is not supported on the public app.`
158
+ })
159
+ );
160
+ return app;
161
+ }
162
+
163
+ // src/admin/admin-api-app.ts
164
+ import {
165
+ ConflictError,
166
+ normalize as normalize2,
167
+ validate
168
+ } from "@takuhon/core";
169
+ import { Hono as Hono2 } from "hono";
170
+
171
+ // src/admin/bearer.ts
172
+ function constantTimeEqual(a, b) {
173
+ const len = a.length > b.length ? a.length : b.length;
174
+ let diff = a.length === b.length ? 0 : 1;
175
+ for (let i = 0; i < len; i++) {
176
+ const ai = a[i] ?? 0;
177
+ const bi = b[i] ?? 0;
178
+ diff |= ai ^ bi;
179
+ }
180
+ return diff === 0;
181
+ }
182
+ async function sha256Hex(input) {
183
+ const buf = await crypto.subtle.digest("SHA-256", new TextEncoder().encode(input));
184
+ const bytes = new Uint8Array(buf);
185
+ let out = "";
186
+ for (const b of bytes) {
187
+ out += b.toString(16).padStart(2, "0");
188
+ }
189
+ return out;
190
+ }
191
+ async function getActorTokenHash(c) {
192
+ const header = c.req.header("authorization") ?? "";
193
+ const m = /^Bearer\s+(.+)$/i.exec(header);
194
+ const token = m?.[1] ?? "";
195
+ if (token === "") return "sha256:absent";
196
+ return `sha256:${await sha256Hex(token)}`;
197
+ }
198
+ function bearerMiddleware(opts) {
199
+ return async (c, next) => {
200
+ const expected = opts.getAdminToken();
201
+ const header = c.req.header("authorization") ?? "";
202
+ const match = /^Bearer\s+(.+)$/i.exec(header);
203
+ const presented = match?.[1];
204
+ const isOk = expected !== void 0 && presented !== void 0 && constantTimeEqual(new TextEncoder().encode(presented), new TextEncoder().encode(expected));
205
+ const tokenHash = await getActorTokenHash(c);
206
+ const baseRequest = {
207
+ method: c.req.method,
208
+ path: new URL(c.req.url).pathname,
209
+ ip: c.req.header("cf-connecting-ip")
210
+ };
211
+ if (!isOk) {
212
+ opts.auditLogger({
213
+ type: "admin.auth.failure",
214
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
215
+ actor: { tokenHash },
216
+ request: baseRequest,
217
+ result: { status: 401 }
218
+ });
219
+ return problemResponse(c, {
220
+ slug: ERROR_SLUGS.unauthorized,
221
+ status: 401,
222
+ title: "Unauthorized",
223
+ detail: "Bearer token missing or invalid."
224
+ });
225
+ }
226
+ opts.auditLogger({
227
+ type: "admin.auth.success",
228
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
229
+ actor: { tokenHash },
230
+ request: baseRequest,
231
+ result: { status: 200 }
232
+ });
233
+ await next();
234
+ };
235
+ }
236
+
237
+ // src/admin/origin.ts
238
+ function originMiddleware(opts) {
239
+ return async (c, next) => {
240
+ const allow = opts.getAdminOrigins();
241
+ if (allow.length === 0) {
242
+ await next();
243
+ return;
244
+ }
245
+ const origin = c.req.header("origin");
246
+ if (origin !== void 0 && !allow.includes(origin)) {
247
+ return problemResponse(c, {
248
+ slug: ERROR_SLUGS.forbidden,
249
+ status: 403,
250
+ title: "Forbidden",
251
+ detail: `Origin ${origin} is not in the admin allowlist.`
252
+ });
253
+ }
254
+ await next();
255
+ };
256
+ }
257
+
258
+ // src/admin/admin-api-app.ts
259
+ var ADMIN_API_CSP = ["default-src 'none'", "frame-ancestors 'none'", "base-uri 'none'"].join(
260
+ "; "
261
+ );
262
+ function toFieldError(e) {
263
+ return { path: `#${e.pointer}`, message: e.message };
264
+ }
265
+ function stripETag(raw) {
266
+ const trimmed = raw.trim();
267
+ if (trimmed.startsWith('"') && trimmed.endsWith('"') && trimmed.length >= 2) {
268
+ return trimmed.slice(1, -1);
269
+ }
270
+ return trimmed;
271
+ }
272
+ function createAdminApiApp(deps) {
273
+ const app = new Hono2();
274
+ app.use("*", async (c, next) => {
275
+ await next();
276
+ const h = c.res.headers;
277
+ h.set("strict-transport-security", "max-age=63072000; includeSubDomains; preload");
278
+ h.set("x-content-type-options", "nosniff");
279
+ h.set("x-frame-options", "DENY");
280
+ h.set("referrer-policy", "strict-origin-when-cross-origin");
281
+ h.set("permissions-policy", "camera=(), microphone=(), geolocation=(), interest-cohort=()");
282
+ h.set("content-security-policy", ADMIN_API_CSP);
283
+ h.set("cache-control", "private, no-store");
284
+ });
285
+ app.use("*", originMiddleware({ getAdminOrigins: deps.getAdminOrigins }));
286
+ app.use(
287
+ "*",
288
+ bearerMiddleware({ getAdminToken: deps.getAdminToken, auditLogger: deps.auditLogger })
289
+ );
290
+ app.onError(
291
+ (err, c) => problemResponse(c, {
292
+ slug: ERROR_SLUGS.internal,
293
+ status: 500,
294
+ title: "Internal Error",
295
+ detail: err instanceof Error ? err.message : "Unknown failure"
296
+ })
297
+ );
298
+ app.notFound(
299
+ (c) => problemResponse(c, {
300
+ slug: ERROR_SLUGS.notFound,
301
+ status: 404,
302
+ title: "Not Found",
303
+ detail: `No admin route matches ${new URL(c.req.url).pathname}.`
304
+ })
305
+ );
306
+ app.put("/profile", async (c) => {
307
+ const contentType = c.req.header("content-type") ?? "";
308
+ if (!contentType.toLowerCase().startsWith("application/json")) {
309
+ return problemResponse(c, {
310
+ slug: ERROR_SLUGS.unsupportedMediaType,
311
+ status: 415,
312
+ title: "Unsupported Media Type",
313
+ detail: `Content-Type must be application/json (got "${contentType}").`
314
+ });
315
+ }
316
+ let parsed;
317
+ try {
318
+ parsed = await c.req.json();
319
+ } catch {
320
+ return problemResponse(c, {
321
+ slug: ERROR_SLUGS.badRequest,
322
+ status: 400,
323
+ title: "Bad Request",
324
+ detail: "Request body is not valid JSON."
325
+ });
326
+ }
327
+ const result = validate(parsed);
328
+ if (!result.ok) {
329
+ return problemResponse(c, {
330
+ slug: ERROR_SLUGS.validationFailed,
331
+ status: 422,
332
+ title: "Validation Failed",
333
+ detail: `Schema validation failed (${String(result.errors.length)} error(s)).`,
334
+ errors: result.errors.map(toFieldError)
335
+ });
336
+ }
337
+ const data = result.data;
338
+ const ifMatchRaw = c.req.header("if-match");
339
+ const ifMatch = ifMatchRaw !== void 0 ? stripETag(ifMatchRaw) : void 0;
340
+ let saved;
341
+ try {
342
+ saved = await deps.storage.saveProfile(data, ifMatch);
343
+ } catch (e) {
344
+ if (e instanceof ConflictError) {
345
+ return problemResponse(c, {
346
+ slug: ERROR_SLUGS.conflict,
347
+ status: 409,
348
+ title: "Conflict",
349
+ detail: "Stored profile version does not match If-Match.",
350
+ currentVersion: e.currentVersion
351
+ });
352
+ }
353
+ throw e;
354
+ }
355
+ await deps.cachePurger.profileUpdated();
356
+ const updatedAt = (/* @__PURE__ */ new Date()).toISOString();
357
+ const tokenHash = await getActorTokenHash(c);
358
+ deps.auditLogger({
359
+ type: "admin.profile.update",
360
+ timestamp: updatedAt,
361
+ actor: { tokenHash },
362
+ request: {
363
+ method: "PUT",
364
+ path: new URL(c.req.url).pathname,
365
+ ip: c.req.header("cf-connecting-ip")
366
+ },
367
+ result: { status: 200, version: saved.version }
368
+ });
369
+ return c.json({
370
+ data: normalize2(data),
371
+ meta: {
372
+ schemaVersion: data.schemaVersion,
373
+ version: saved.version,
374
+ updatedAt
375
+ }
376
+ });
377
+ });
378
+ app.delete("/profile", async (c) => {
379
+ await deps.storage.deleteProfile();
380
+ await deps.cachePurger.profileDeleted();
381
+ const tokenHash = await getActorTokenHash(c);
382
+ deps.auditLogger({
383
+ type: "admin.profile.delete",
384
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
385
+ actor: { tokenHash },
386
+ request: {
387
+ method: "DELETE",
388
+ path: new URL(c.req.url).pathname,
389
+ ip: c.req.header("cf-connecting-ip")
390
+ },
391
+ result: { status: 204 }
392
+ });
393
+ return c.body(null, 204);
394
+ });
395
+ app.on(
396
+ ["POST", "PATCH"],
397
+ "/profile",
398
+ (c) => problemResponse(c, {
399
+ slug: ERROR_SLUGS.methodNotAllowed,
400
+ status: 405,
401
+ title: "Method Not Allowed",
402
+ detail: `${c.req.method} ${new URL(c.req.url).pathname} is not supported on the admin app.`
403
+ })
404
+ );
405
+ return app;
406
+ }
407
+
408
+ // src/admin/admin-ui-app.ts
409
+ import { Hono as Hono3 } from "hono";
410
+
411
+ // src/admin/admin-html.ts
412
+ function renderAdminHtml(nonce) {
413
+ return `<!doctype html>
414
+ <html lang="en">
415
+ <head>
416
+ <meta charset="utf-8">
417
+ <meta name="viewport" content="width=device-width, initial-scale=1">
418
+ <title>takuhon admin</title>
419
+ <style nonce="${nonce}">
420
+ body { font-family: system-ui, -apple-system, sans-serif; max-width: 960px; margin: 2rem auto; padding: 0 1rem; color: #222; }
421
+ h1 { font-size: 1.5rem; }
422
+ p.note { color: #555; }
423
+ label { display: block; margin: 1rem 0 0.25rem; font-weight: 600; }
424
+ input[type=password], textarea { width: 100%; box-sizing: border-box; padding: 0.5rem; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.9rem; border: 1px solid #999; border-radius: 4px; }
425
+ textarea { min-height: 24rem; }
426
+ .row { display: flex; gap: 0.5rem; margin-top: 1rem; }
427
+ button { padding: 0.5rem 1rem; font-size: 0.95rem; border: 1px solid #444; background: #fafafa; border-radius: 4px; cursor: pointer; }
428
+ button.danger { border-color: #b03; color: #b03; background: #fff5f5; }
429
+ #status { margin-top: 1rem; padding: 0.75rem; border-radius: 4px; white-space: pre-wrap; word-break: break-word; }
430
+ #status.ok { background: #e6f4ea; color: #1b5e20; border: 1px solid #82c891; }
431
+ #status.err { background: #fdecea; color: #b71c1c; border: 1px solid #ef9a9a; }
432
+ small.version { color: #555; }
433
+ </style>
434
+ </head>
435
+ <body>
436
+ <h1>takuhon admin</h1>
437
+ <p class="note">Edit the full <code>takuhon.json</code> document and Save. Optimistic locking via <code>If-Match</code> guards concurrent edits; the token is never sent over the URL.</p>
438
+ <label for="token">Admin token</label>
439
+ <input id="token" type="password" autocomplete="off" spellcheck="false">
440
+ <label for="payload">takuhon.json <small class="version" id="versionLabel"></small></label>
441
+ <textarea id="payload" spellcheck="false" autocapitalize="off" autocomplete="off"></textarea>
442
+ <div class="row">
443
+ <button id="save" type="button">Save</button>
444
+ <button id="delete" type="button" class="danger">Delete profile</button>
445
+ <button id="reload" type="button">Reload current</button>
446
+ </div>
447
+ <div id="status" hidden></div>
448
+ <script nonce="${nonce}">
449
+ (function () {
450
+ var tokenEl = document.getElementById('token');
451
+ var payloadEl = document.getElementById('payload');
452
+ var versionEl = document.getElementById('versionLabel');
453
+ var statusEl = document.getElementById('status');
454
+ var ifMatch = '';
455
+
456
+ function setStatus(message, ok) {
457
+ statusEl.textContent = message;
458
+ statusEl.className = ok ? 'ok' : 'err';
459
+ statusEl.hidden = false;
460
+ }
461
+ function setVersion(etag) {
462
+ ifMatch = etag || '';
463
+ versionEl.textContent = ifMatch ? '(current version: ' + ifMatch + ')' : '(no stored version)';
464
+ }
465
+ function getToken() {
466
+ var t = tokenEl.value.trim();
467
+ if (!t) { setStatus('Admin token is required.', false); return null; }
468
+ return t;
469
+ }
470
+ async function loadCurrent() {
471
+ try {
472
+ var res = await fetch('/takuhon.json', { cache: 'no-store' });
473
+ if (!res.ok) { setStatus('Failed to load /takuhon.json: ' + res.status, false); return; }
474
+ setVersion(res.headers.get('etag'));
475
+ var json = await res.json();
476
+ payloadEl.value = JSON.stringify(json, null, 2);
477
+ setStatus('Loaded current profile.', true);
478
+ } catch (e) {
479
+ setStatus('Network error loading current profile: ' + (e && e.message ? e.message : String(e)), false);
480
+ }
481
+ }
482
+ async function save() {
483
+ var token = getToken();
484
+ if (!token) return;
485
+ var body;
486
+ try {
487
+ body = JSON.parse(payloadEl.value);
488
+ } catch (e) {
489
+ setStatus('JSON parse error: ' + (e && e.message ? e.message : String(e)), false);
490
+ return;
491
+ }
492
+ var headers = { 'Content-Type': 'application/json', 'Authorization': 'Bearer ' + token };
493
+ if (ifMatch) headers['If-Match'] = ifMatch;
494
+ try {
495
+ var res = await fetch('/api/admin/profile', { method: 'PUT', headers: headers, body: JSON.stringify(body) });
496
+ var json = await res.json().catch(function () { return null; });
497
+ if (res.ok && json && json.meta && json.meta.version) {
498
+ setVersion('"' + json.meta.version + '"');
499
+ setStatus('Saved. New version: ' + json.meta.version, true);
500
+ } else {
501
+ setStatus('Save failed (' + res.status + '): ' + (json ? JSON.stringify(json, null, 2) : 'no body'), false);
502
+ }
503
+ } catch (e) {
504
+ setStatus('Network error during save: ' + (e && e.message ? e.message : String(e)), false);
505
+ }
506
+ }
507
+ async function deleteProfile() {
508
+ var token = getToken();
509
+ if (!token) return;
510
+ if (!confirm('Delete the profile? The bundled onboarding fixture will be shown until you save a new document.')) return;
511
+ var headers = { 'Authorization': 'Bearer ' + token };
512
+ try {
513
+ var res = await fetch('/api/admin/profile', { method: 'DELETE', headers: headers });
514
+ if (res.ok) {
515
+ payloadEl.value = '';
516
+ setVersion('');
517
+ setStatus('Deleted.', true);
518
+ } else {
519
+ var json = await res.json().catch(function () { return null; });
520
+ setStatus('Delete failed (' + res.status + '): ' + (json ? JSON.stringify(json, null, 2) : 'no body'), false);
521
+ }
522
+ } catch (e) {
523
+ setStatus('Network error during delete: ' + (e && e.message ? e.message : String(e)), false);
524
+ }
525
+ }
526
+
527
+ document.getElementById('save').addEventListener('click', save);
528
+ document.getElementById('delete').addEventListener('click', deleteProfile);
529
+ document.getElementById('reload').addEventListener('click', loadCurrent);
530
+ loadCurrent();
531
+ })();
532
+ </script>
533
+ </body>
534
+ </html>
535
+ `;
536
+ }
537
+
538
+ // src/admin/admin-ui-app.ts
539
+ function adminCsp(nonce) {
540
+ return [
541
+ "default-src 'self'",
542
+ "img-src 'self' blob:",
543
+ `style-src 'self' 'nonce-${nonce}'`,
544
+ `script-src 'self' 'nonce-${nonce}'`,
545
+ "font-src 'self'",
546
+ "connect-src 'self'",
547
+ "frame-ancestors 'none'",
548
+ "base-uri 'self'",
549
+ "form-action 'self'",
550
+ "require-trusted-types-for 'script'",
551
+ "upgrade-insecure-requests"
552
+ ].join("; ");
553
+ }
554
+ function generateNonce() {
555
+ const bytes = crypto.getRandomValues(new Uint8Array(16));
556
+ let bin = "";
557
+ for (const b of bytes) {
558
+ bin += String.fromCharCode(b);
559
+ }
560
+ return btoa(bin);
561
+ }
562
+ function createAdminUiApp() {
563
+ const app = new Hono3();
564
+ app.get("/", (c) => {
565
+ const nonce = generateNonce();
566
+ c.header("strict-transport-security", "max-age=63072000; includeSubDomains; preload");
567
+ c.header("x-content-type-options", "nosniff");
568
+ c.header("x-frame-options", "DENY");
569
+ c.header("referrer-policy", "strict-origin-when-cross-origin");
570
+ c.header("permissions-policy", "camera=(), microphone=(), geolocation=(), interest-cohort=()");
571
+ c.header("content-security-policy", adminCsp(nonce));
572
+ c.header("cache-control", "private, no-store");
573
+ return c.html(renderAdminHtml(nonce));
574
+ });
575
+ return app;
576
+ }
577
+
578
+ // src/admin/audit-logger.ts
579
+ var noopAuditLogger = () => {
580
+ };
581
+
582
+ // src/admin/cache-purger.ts
583
+ var noopCachePurger = {
584
+ profileUpdated: () => Promise.resolve(),
585
+ profileDeleted: () => Promise.resolve()
586
+ };
587
+ export {
588
+ ERROR_SLUGS,
589
+ buildProblem,
590
+ createAdminApiApp,
591
+ createAdminUiApp,
592
+ createPublicApp,
593
+ noopAuditLogger,
594
+ noopCachePurger,
595
+ problemResponse
596
+ };
597
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/error-envelope.ts","../src/public-app.ts","../src/admin/admin-api-app.ts","../src/admin/bearer.ts","../src/admin/origin.ts","../src/admin/admin-ui-app.ts","../src/admin/admin-html.ts","../src/admin/audit-logger.ts","../src/admin/cache-purger.ts"],"sourcesContent":["import type { Context } from 'hono';\nimport type { ContentfulStatusCode } from 'hono/utils/http-status';\n\n/**\n * RFC 7807 problem type slugs used by takuhon. The 11 below are the\n * Spec-defined values (api.md §5.1); `methodNotAllowed` is added locally\n * for the 405 path that the Spec leaves unnamed.\n */\nexport const ERROR_SLUGS = {\n badRequest: 'bad-request',\n unauthorized: 'unauthorized',\n forbidden: 'forbidden',\n notFound: 'not-found',\n methodNotAllowed: 'method-not-allowed',\n conflict: 'conflict',\n payloadTooLarge: 'payload-too-large',\n unsupportedMediaType: 'unsupported-media-type',\n validationFailed: 'validation-failed',\n tooManyRequests: 'too-many-requests',\n internal: 'internal',\n serviceUnavailable: 'service-unavailable',\n} as const;\n\nexport type ErrorSlug = (typeof ERROR_SLUGS)[keyof typeof ERROR_SLUGS];\n\nconst TYPE_BASE = 'https://takuhon.org/errors';\n\nexport interface ProblemFieldError {\n path: string;\n message: string;\n}\n\nexport interface ProblemDetails {\n type: string;\n title: string;\n status: number;\n detail: string;\n instance: string;\n errors?: ProblemFieldError[];\n currentVersion?: string;\n}\n\nexport interface BuildProblemInput {\n slug: ErrorSlug;\n status: number;\n title: string;\n detail: string;\n instance: string;\n errors?: ProblemFieldError[];\n currentVersion?: string;\n}\n\nexport function buildProblem(input: BuildProblemInput): ProblemDetails {\n const out: ProblemDetails = {\n type: `${TYPE_BASE}/${input.slug}`,\n title: input.title,\n status: input.status,\n detail: input.detail,\n instance: input.instance,\n };\n if (input.errors !== undefined) out.errors = input.errors;\n if (input.currentVersion !== undefined) out.currentVersion = input.currentVersion;\n return out;\n}\n\nexport interface ProblemResponseInput {\n slug: ErrorSlug;\n status: ContentfulStatusCode;\n title: string;\n detail: string;\n errors?: ProblemFieldError[];\n currentVersion?: string;\n}\n\nexport function problemResponse(c: Context, input: ProblemResponseInput): Response {\n const body = buildProblem({\n slug: input.slug,\n status: input.status,\n title: input.title,\n detail: input.detail,\n instance: new URL(c.req.url).pathname,\n errors: input.errors,\n currentVersion: input.currentVersion,\n });\n return c.body(JSON.stringify(body), input.status, {\n 'content-type': 'application/problem+json; charset=utf-8',\n });\n}\n","import {\n NotFoundError,\n SCHEMA_VERSION,\n generateJsonLd,\n normalize,\n resolveLocale,\n schema,\n type Takuhon,\n type TakuhonStorage,\n} from '@takuhon/core';\nimport { Hono } from 'hono';\n\nimport { ERROR_SLUGS, problemResponse } from './error-envelope.js';\n\nexport interface PublicAppDeps {\n storage: TakuhonStorage;\n /**\n * Returned when storage reports NotFoundError. Adapters that ship a\n * bundled example fixture (e.g. @takuhon/cloudflare) pass a thunk that\n * returns the validated document so initial-onboarding requests still\n * succeed before the first admin write.\n */\n fallback?: () => Takuhon;\n}\n\nconst FALLBACK_VERSION = 'bundled-fixture';\n\nconst PUBLIC_CSP = [\n \"default-src 'self'\",\n \"img-src 'self' data:\",\n \"style-src 'self' 'unsafe-inline'\",\n \"script-src 'self'\",\n \"font-src 'self'\",\n \"connect-src 'self'\",\n \"frame-ancestors 'none'\",\n \"base-uri 'self'\",\n \"form-action 'self'\",\n 'upgrade-insecure-requests',\n].join('; ');\n\nasync function loadProfile(deps: PublicAppDeps): Promise<{ data: Takuhon; version: string }> {\n try {\n return await deps.storage.getProfile();\n } catch (e) {\n if (e instanceof NotFoundError && deps.fallback) {\n return { data: deps.fallback(), version: FALLBACK_VERSION };\n }\n throw e;\n }\n}\n\nexport function createPublicApp(deps: PublicAppDeps): Hono {\n const app = new Hono();\n\n app.use('*', async (c, next) => {\n await next();\n const h = c.res.headers;\n h.set('strict-transport-security', 'max-age=63072000; includeSubDomains; preload');\n h.set('x-content-type-options', 'nosniff');\n h.set('x-frame-options', 'DENY');\n h.set('referrer-policy', 'strict-origin-when-cross-origin');\n h.set('permissions-policy', 'camera=(), microphone=(), geolocation=(), interest-cohort=()');\n h.set('content-security-policy', PUBLIC_CSP);\n });\n\n app.onError((err, c) =>\n problemResponse(c, {\n slug: ERROR_SLUGS.internal,\n status: 500,\n title: 'Internal Error',\n detail: err instanceof Error ? err.message : 'Unknown failure',\n }),\n );\n\n app.notFound((c) =>\n problemResponse(c, {\n slug: ERROR_SLUGS.notFound,\n status: 404,\n title: 'Not Found',\n detail: `No route matches ${new URL(c.req.url).pathname}.`,\n }),\n );\n\n app.get('/', (c) => c.text('takuhon — visit /api/profile or /api/schema\\n'));\n\n app.get('/api/profile', async (c) => {\n const lang = c.req.query('lang');\n const { data, version } = await loadProfile(deps);\n const localized = resolveLocale(normalize(data), lang);\n const body = {\n data: localized,\n meta: {\n schemaVersion: localized.schemaVersion,\n locale: localized.resolvedLocale,\n updatedAt: localized.meta.updatedAt,\n },\n };\n c.header('etag', `\"${version}\"`);\n c.header('cache-control', 'public, max-age=300, s-maxage=300');\n return c.json(body);\n });\n\n app.get('/api/schema', (c) => c.json(schema));\n\n app.get('/api/jsonld', async (c) => {\n const lang = c.req.query('lang');\n const { data, version } = await loadProfile(deps);\n const localized = resolveLocale(normalize(data), lang);\n const ld = generateJsonLd(localized);\n c.header('etag', `\"${version}\"`);\n c.header('cache-control', 'public, max-age=300, s-maxage=300');\n c.header('content-type', 'application/ld+json; charset=utf-8');\n return c.body(JSON.stringify(ld));\n });\n\n app.get('/takuhon.json', async (c) => {\n const { data, version } = await loadProfile(deps);\n c.header('etag', `\"${version}\"`);\n c.header('cache-control', 'public, max-age=300');\n return c.json(data);\n });\n\n app.get('/.well-known/takuhon.json', (c) => {\n c.header('cache-control', 'public, max-age=3600');\n return c.json({\n schemaVersion: SCHEMA_VERSION,\n schemaUrl: '/api/schema',\n profile: '/api/profile',\n jsonld: '/api/jsonld',\n export: '/api/export',\n canonical: '/takuhon.json',\n });\n });\n\n app.on(['POST', 'PUT', 'PATCH', 'DELETE'], '*', (c) =>\n problemResponse(c, {\n slug: ERROR_SLUGS.methodNotAllowed,\n status: 405,\n title: 'Method Not Allowed',\n detail: `${c.req.method} ${new URL(c.req.url).pathname} is not supported on the public app.`,\n }),\n );\n\n return app;\n}\n","import {\n ConflictError,\n normalize,\n validate,\n type Takuhon,\n type TakuhonStorage,\n type ValidationError,\n} from '@takuhon/core';\nimport { Hono } from 'hono';\n\nimport { ERROR_SLUGS, problemResponse, type ProblemFieldError } from '../error-envelope.js';\n\nimport type { AuditLogger } from './audit-logger.js';\nimport { bearerMiddleware, getActorTokenHash } from './bearer.js';\nimport type { CachePurger } from './cache-purger.js';\nimport { originMiddleware } from './origin.js';\n\n/**\n * Defense-in-depth CSP for JSON-only responses. Nothing renders here, so\n * `'none'` everywhere is the strongest stance the spec leaves room for.\n */\nconst ADMIN_API_CSP = [\"default-src 'none'\", \"frame-ancestors 'none'\", \"base-uri 'none'\"].join(\n '; ',\n);\n\nexport interface AdminApiAppDeps {\n storage: TakuhonStorage;\n /** Returns the configured admin token, or undefined if no secret is set. */\n getAdminToken: () => string | undefined;\n /** Allowlist of origins permitted for browser-originating admin requests. */\n getAdminOrigins: () => string[];\n cachePurger: CachePurger;\n auditLogger: AuditLogger;\n}\n\n/**\n * Map a core `ValidationError` to the RFC 7807 field-error shape. The leading\n * `#` produces a JSON Schema-style fragment reference (`#/profile/...`) that\n * matches the example in `api.md §5`.\n */\nfunction toFieldError(e: ValidationError): ProblemFieldError {\n return { path: `#${e.pointer}`, message: e.message };\n}\n\n/** Strip RFC 7232 double-quote delimiters from an `If-Match` header value. */\nfunction stripETag(raw: string): string {\n const trimmed = raw.trim();\n if (trimmed.startsWith('\"') && trimmed.endsWith('\"') && trimmed.length >= 2) {\n return trimmed.slice(1, -1);\n }\n return trimmed;\n}\n\n/**\n * Hono factory for `/api/admin/profile`. Mounted by adapters at `/api/admin`\n * (so the sub-app sees `/profile` as the route path).\n */\nexport function createAdminApiApp(deps: AdminApiAppDeps): Hono {\n const app = new Hono();\n\n app.use('*', async (c, next) => {\n await next();\n const h = c.res.headers;\n h.set('strict-transport-security', 'max-age=63072000; includeSubDomains; preload');\n h.set('x-content-type-options', 'nosniff');\n h.set('x-frame-options', 'DENY');\n h.set('referrer-policy', 'strict-origin-when-cross-origin');\n h.set('permissions-policy', 'camera=(), microphone=(), geolocation=(), interest-cohort=()');\n h.set('content-security-policy', ADMIN_API_CSP);\n h.set('cache-control', 'private, no-store');\n });\n\n app.use('*', originMiddleware({ getAdminOrigins: deps.getAdminOrigins }));\n app.use(\n '*',\n bearerMiddleware({ getAdminToken: deps.getAdminToken, auditLogger: deps.auditLogger }),\n );\n\n app.onError((err, c) =>\n problemResponse(c, {\n slug: ERROR_SLUGS.internal,\n status: 500,\n title: 'Internal Error',\n detail: err instanceof Error ? err.message : 'Unknown failure',\n }),\n );\n\n app.notFound((c) =>\n problemResponse(c, {\n slug: ERROR_SLUGS.notFound,\n status: 404,\n title: 'Not Found',\n detail: `No admin route matches ${new URL(c.req.url).pathname}.`,\n }),\n );\n\n app.put('/profile', async (c) => {\n const contentType = c.req.header('content-type') ?? '';\n if (!contentType.toLowerCase().startsWith('application/json')) {\n return problemResponse(c, {\n slug: ERROR_SLUGS.unsupportedMediaType,\n status: 415,\n title: 'Unsupported Media Type',\n detail: `Content-Type must be application/json (got \"${contentType}\").`,\n });\n }\n\n let parsed: unknown;\n try {\n parsed = await c.req.json();\n } catch {\n return problemResponse(c, {\n slug: ERROR_SLUGS.badRequest,\n status: 400,\n title: 'Bad Request',\n detail: 'Request body is not valid JSON.',\n });\n }\n\n const result = validate(parsed);\n if (!result.ok) {\n return problemResponse(c, {\n slug: ERROR_SLUGS.validationFailed,\n status: 422,\n title: 'Validation Failed',\n detail: `Schema validation failed (${String(result.errors.length)} error(s)).`,\n errors: result.errors.map(toFieldError),\n });\n }\n\n const data: Takuhon = result.data;\n const ifMatchRaw = c.req.header('if-match');\n const ifMatch = ifMatchRaw !== undefined ? stripETag(ifMatchRaw) : undefined;\n\n let saved: { version: string };\n try {\n saved = await deps.storage.saveProfile(data, ifMatch);\n } catch (e) {\n if (e instanceof ConflictError) {\n return problemResponse(c, {\n slug: ERROR_SLUGS.conflict,\n status: 409,\n title: 'Conflict',\n detail: 'Stored profile version does not match If-Match.',\n currentVersion: e.currentVersion,\n });\n }\n throw e;\n }\n\n await deps.cachePurger.profileUpdated();\n\n const updatedAt = new Date().toISOString();\n const tokenHash = await getActorTokenHash(c);\n deps.auditLogger({\n type: 'admin.profile.update',\n timestamp: updatedAt,\n actor: { tokenHash },\n request: {\n method: 'PUT',\n path: new URL(c.req.url).pathname,\n ip: c.req.header('cf-connecting-ip'),\n },\n result: { status: 200, version: saved.version },\n });\n\n return c.json({\n data: normalize(data),\n meta: {\n schemaVersion: data.schemaVersion,\n version: saved.version,\n updatedAt,\n },\n });\n });\n\n app.delete('/profile', async (c) => {\n await deps.storage.deleteProfile();\n await deps.cachePurger.profileDeleted();\n\n const tokenHash = await getActorTokenHash(c);\n deps.auditLogger({\n type: 'admin.profile.delete',\n timestamp: new Date().toISOString(),\n actor: { tokenHash },\n request: {\n method: 'DELETE',\n path: new URL(c.req.url).pathname,\n ip: c.req.header('cf-connecting-ip'),\n },\n result: { status: 204 },\n });\n\n return c.body(null, 204);\n });\n\n app.on(['POST', 'PATCH'], '/profile', (c) =>\n problemResponse(c, {\n slug: ERROR_SLUGS.methodNotAllowed,\n status: 405,\n title: 'Method Not Allowed',\n detail: `${c.req.method} ${new URL(c.req.url).pathname} is not supported on the admin app.`,\n }),\n );\n\n return app;\n}\n","import type { Context, Next } from 'hono';\n\nimport { ERROR_SLUGS, problemResponse } from '../error-envelope.js';\n\nimport type { AuditLogger } from './audit-logger.js';\n\n/**\n * Constant-time byte comparison.\n *\n * Iterates over `max(len(a), len(b))` bytes so wall-clock cost is independent\n * of *where* a mismatch occurs and of length differences (within the same\n * length class). Length-mismatch is folded into the accumulator so the\n * boolean result still discriminates correctly.\n *\n * This is intentionally a from-scratch implementation rather than\n * `crypto.subtle.timingSafeEqual`, which Cloudflare Workers exposes but\n * Node lacks — `@takuhon/api` is adapter-neutral.\n */\nexport function constantTimeEqual(a: Uint8Array, b: Uint8Array): boolean {\n const len = a.length > b.length ? a.length : b.length;\n let diff = a.length === b.length ? 0 : 1;\n for (let i = 0; i < len; i++) {\n const ai = a[i] ?? 0;\n const bi = b[i] ?? 0;\n diff |= ai ^ bi;\n }\n return diff === 0;\n}\n\n/** SHA-256 hex digest (lowercase) over a UTF-8 string. */\nexport async function sha256Hex(input: string): Promise<string> {\n const buf = await crypto.subtle.digest('SHA-256', new TextEncoder().encode(input));\n const bytes = new Uint8Array(buf);\n let out = '';\n for (const b of bytes) {\n out += b.toString(16).padStart(2, '0');\n }\n return out;\n}\n\n/**\n * Extracts the Bearer token from the request and returns a stable\n * `sha256:<hex>` digest used as the actor identity in audit logs. Returns\n * `sha256:absent` when no token is present.\n */\nexport async function getActorTokenHash(c: Context): Promise<string> {\n const header = c.req.header('authorization') ?? '';\n const m = /^Bearer\\s+(.+)$/i.exec(header);\n const token = m?.[1] ?? '';\n if (token === '') return 'sha256:absent';\n return `sha256:${await sha256Hex(token)}`;\n}\n\nexport interface BearerMiddlewareOptions {\n /**\n * Source of the expected admin token. Returns `undefined` when the deploy\n * has not provisioned a secret — in that case every request is rejected,\n * mirroring \"no admin access\" semantics.\n */\n getAdminToken: () => string | undefined;\n auditLogger: AuditLogger;\n}\n\n/**\n * Hono middleware that gates downstream handlers on a constant-time Bearer\n * token check. Emits an audit event for both success and failure.\n */\nexport function bearerMiddleware(opts: BearerMiddlewareOptions) {\n return async (c: Context, next: Next): Promise<Response | void> => {\n const expected = opts.getAdminToken();\n const header = c.req.header('authorization') ?? '';\n const match = /^Bearer\\s+(.+)$/i.exec(header);\n const presented = match?.[1];\n\n const isOk =\n expected !== undefined &&\n presented !== undefined &&\n constantTimeEqual(new TextEncoder().encode(presented), new TextEncoder().encode(expected));\n\n const tokenHash = await getActorTokenHash(c);\n const baseRequest = {\n method: c.req.method,\n path: new URL(c.req.url).pathname,\n ip: c.req.header('cf-connecting-ip'),\n };\n\n if (!isOk) {\n opts.auditLogger({\n type: 'admin.auth.failure',\n timestamp: new Date().toISOString(),\n actor: { tokenHash },\n request: baseRequest,\n result: { status: 401 },\n });\n return problemResponse(c, {\n slug: ERROR_SLUGS.unauthorized,\n status: 401,\n title: 'Unauthorized',\n detail: 'Bearer token missing or invalid.',\n });\n }\n\n opts.auditLogger({\n type: 'admin.auth.success',\n timestamp: new Date().toISOString(),\n actor: { tokenHash },\n request: baseRequest,\n result: { status: 200 },\n });\n\n await next();\n };\n}\n","import type { Context, Next } from 'hono';\n\nimport { ERROR_SLUGS, problemResponse } from '../error-envelope.js';\n\nexport interface OriginMiddlewareOptions {\n /**\n * Returns the allowlist of admin Origins (e.g.\n * `['https://admin.example.com']`). Empty list disables the check —\n * deploys are expected to populate the env before going to production,\n * with the trade-off documented in the adapter README.\n */\n getAdminOrigins: () => string[];\n}\n\n/**\n * Hono middleware that enforces a same-origin / allowlisted-origin policy\n * when configured. Requests without an `Origin` header (curl, server-to-\n * server, native apps) are allowed through; the Bearer token is the primary\n * auth boundary and the absence of `Origin` is itself an indicator that the\n * request did not originate from a browser CSRF context.\n */\nexport function originMiddleware(opts: OriginMiddlewareOptions) {\n return async (c: Context, next: Next): Promise<Response | void> => {\n const allow = opts.getAdminOrigins();\n if (allow.length === 0) {\n await next();\n return;\n }\n const origin = c.req.header('origin');\n if (origin !== undefined && !allow.includes(origin)) {\n return problemResponse(c, {\n slug: ERROR_SLUGS.forbidden,\n status: 403,\n title: 'Forbidden',\n detail: `Origin ${origin} is not in the admin allowlist.`,\n });\n }\n await next();\n };\n}\n","import { Hono } from 'hono';\n\nimport { renderAdminHtml } from './admin-html.js';\n\n/**\n * Per-request CSP (security.md §1.3). Differs from the public CSP:\n * - `img-src` drops `data:` and adds `blob:` for client-side previews.\n * - `style-src` and `script-src` drop `unsafe-inline` and pin a nonce.\n * - `require-trusted-types-for 'script'` blocks DOM-XSS sinks.\n */\nfunction adminCsp(nonce: string): string {\n return [\n \"default-src 'self'\",\n \"img-src 'self' blob:\",\n `style-src 'self' 'nonce-${nonce}'`,\n `script-src 'self' 'nonce-${nonce}'`,\n \"font-src 'self'\",\n \"connect-src 'self'\",\n \"frame-ancestors 'none'\",\n \"base-uri 'self'\",\n \"form-action 'self'\",\n \"require-trusted-types-for 'script'\",\n 'upgrade-insecure-requests',\n ].join('; ');\n}\n\nfunction generateNonce(): string {\n const bytes = crypto.getRandomValues(new Uint8Array(16));\n let bin = '';\n for (const b of bytes) {\n bin += String.fromCharCode(b);\n }\n return btoa(bin);\n}\n\n/**\n * Hono factory for the `/admin` HTML editor. Mounted by adapters at\n * `/admin` (so the sub-app sees `/` as its root path). Each request gets a\n * freshly-generated nonce shared between the CSP header and the inline\n * `<style>` / `<script>` tags.\n */\nexport function createAdminUiApp(): Hono {\n const app = new Hono();\n\n app.get('/', (c) => {\n const nonce = generateNonce();\n c.header('strict-transport-security', 'max-age=63072000; includeSubDomains; preload');\n c.header('x-content-type-options', 'nosniff');\n c.header('x-frame-options', 'DENY');\n c.header('referrer-policy', 'strict-origin-when-cross-origin');\n c.header('permissions-policy', 'camera=(), microphone=(), geolocation=(), interest-cohort=()');\n c.header('content-security-policy', adminCsp(nonce));\n c.header('cache-control', 'private, no-store');\n return c.html(renderAdminHtml(nonce));\n });\n\n return app;\n}\n","/**\n * Inline HTML for the minimal admin editor served at `GET /admin`.\n *\n * Single-page, no build step: a token input, a JSON textarea preloaded from\n * `/takuhon.json`, Save (PUT) and Delete (DELETE) buttons. The page operates\n * under a strict CSP (`script-src 'self' 'nonce-<n>'`,\n * `style-src 'self' 'nonce-<n>'`, `require-trusted-types-for 'script'`), so\n * both the inline `<script>` and `<style>` blocks carry the request-scoped\n * nonce. We avoid `innerHTML`/`eval` so Trusted Types is non-disruptive.\n */\nexport function renderAdminHtml(nonce: string): string {\n return `<!doctype html>\n<html lang=\"en\">\n<head>\n<meta charset=\"utf-8\">\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n<title>takuhon admin</title>\n<style nonce=\"${nonce}\">\nbody { font-family: system-ui, -apple-system, sans-serif; max-width: 960px; margin: 2rem auto; padding: 0 1rem; color: #222; }\nh1 { font-size: 1.5rem; }\np.note { color: #555; }\nlabel { display: block; margin: 1rem 0 0.25rem; font-weight: 600; }\ninput[type=password], textarea { width: 100%; box-sizing: border-box; padding: 0.5rem; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.9rem; border: 1px solid #999; border-radius: 4px; }\ntextarea { min-height: 24rem; }\n.row { display: flex; gap: 0.5rem; margin-top: 1rem; }\nbutton { padding: 0.5rem 1rem; font-size: 0.95rem; border: 1px solid #444; background: #fafafa; border-radius: 4px; cursor: pointer; }\nbutton.danger { border-color: #b03; color: #b03; background: #fff5f5; }\n#status { margin-top: 1rem; padding: 0.75rem; border-radius: 4px; white-space: pre-wrap; word-break: break-word; }\n#status.ok { background: #e6f4ea; color: #1b5e20; border: 1px solid #82c891; }\n#status.err { background: #fdecea; color: #b71c1c; border: 1px solid #ef9a9a; }\nsmall.version { color: #555; }\n</style>\n</head>\n<body>\n<h1>takuhon admin</h1>\n<p class=\"note\">Edit the full <code>takuhon.json</code> document and Save. Optimistic locking via <code>If-Match</code> guards concurrent edits; the token is never sent over the URL.</p>\n<label for=\"token\">Admin token</label>\n<input id=\"token\" type=\"password\" autocomplete=\"off\" spellcheck=\"false\">\n<label for=\"payload\">takuhon.json <small class=\"version\" id=\"versionLabel\"></small></label>\n<textarea id=\"payload\" spellcheck=\"false\" autocapitalize=\"off\" autocomplete=\"off\"></textarea>\n<div class=\"row\">\n <button id=\"save\" type=\"button\">Save</button>\n <button id=\"delete\" type=\"button\" class=\"danger\">Delete profile</button>\n <button id=\"reload\" type=\"button\">Reload current</button>\n</div>\n<div id=\"status\" hidden></div>\n<script nonce=\"${nonce}\">\n(function () {\n var tokenEl = document.getElementById('token');\n var payloadEl = document.getElementById('payload');\n var versionEl = document.getElementById('versionLabel');\n var statusEl = document.getElementById('status');\n var ifMatch = '';\n\n function setStatus(message, ok) {\n statusEl.textContent = message;\n statusEl.className = ok ? 'ok' : 'err';\n statusEl.hidden = false;\n }\n function setVersion(etag) {\n ifMatch = etag || '';\n versionEl.textContent = ifMatch ? '(current version: ' + ifMatch + ')' : '(no stored version)';\n }\n function getToken() {\n var t = tokenEl.value.trim();\n if (!t) { setStatus('Admin token is required.', false); return null; }\n return t;\n }\n async function loadCurrent() {\n try {\n var res = await fetch('/takuhon.json', { cache: 'no-store' });\n if (!res.ok) { setStatus('Failed to load /takuhon.json: ' + res.status, false); return; }\n setVersion(res.headers.get('etag'));\n var json = await res.json();\n payloadEl.value = JSON.stringify(json, null, 2);\n setStatus('Loaded current profile.', true);\n } catch (e) {\n setStatus('Network error loading current profile: ' + (e && e.message ? e.message : String(e)), false);\n }\n }\n async function save() {\n var token = getToken();\n if (!token) return;\n var body;\n try {\n body = JSON.parse(payloadEl.value);\n } catch (e) {\n setStatus('JSON parse error: ' + (e && e.message ? e.message : String(e)), false);\n return;\n }\n var headers = { 'Content-Type': 'application/json', 'Authorization': 'Bearer ' + token };\n if (ifMatch) headers['If-Match'] = ifMatch;\n try {\n var res = await fetch('/api/admin/profile', { method: 'PUT', headers: headers, body: JSON.stringify(body) });\n var json = await res.json().catch(function () { return null; });\n if (res.ok && json && json.meta && json.meta.version) {\n setVersion('\"' + json.meta.version + '\"');\n setStatus('Saved. New version: ' + json.meta.version, true);\n } else {\n setStatus('Save failed (' + res.status + '): ' + (json ? JSON.stringify(json, null, 2) : 'no body'), false);\n }\n } catch (e) {\n setStatus('Network error during save: ' + (e && e.message ? e.message : String(e)), false);\n }\n }\n async function deleteProfile() {\n var token = getToken();\n if (!token) return;\n if (!confirm('Delete the profile? The bundled onboarding fixture will be shown until you save a new document.')) return;\n var headers = { 'Authorization': 'Bearer ' + token };\n try {\n var res = await fetch('/api/admin/profile', { method: 'DELETE', headers: headers });\n if (res.ok) {\n payloadEl.value = '';\n setVersion('');\n setStatus('Deleted.', true);\n } else {\n var json = await res.json().catch(function () { return null; });\n setStatus('Delete failed (' + res.status + '): ' + (json ? JSON.stringify(json, null, 2) : 'no body'), false);\n }\n } catch (e) {\n setStatus('Network error during delete: ' + (e && e.message ? e.message : String(e)), false);\n }\n }\n\n document.getElementById('save').addEventListener('click', save);\n document.getElementById('delete').addEventListener('click', deleteProfile);\n document.getElementById('reload').addEventListener('click', loadCurrent);\n loadCurrent();\n})();\n</script>\n</body>\n</html>\n`;\n}\n","/**\n * Structured audit-log emitter for admin actions (per security.md §5).\n *\n * Phase 3.4 covers the auth + profile-write events. Asset events\n * (`admin.asset.upload`, `admin.asset.delete`) join the union when Phase 3.5\n * lands. Adapters bind a concrete sink (Cloudflare uses `console.log`, which\n * Workers Tail / Logpush captures); tests inject a `vi.fn()` recorder.\n */\nexport type AuditEventType =\n | 'admin.auth.success'\n | 'admin.auth.failure'\n | 'admin.profile.update'\n | 'admin.profile.delete'\n | 'admin.cache.purge';\n\nexport interface AuditEvent {\n type: AuditEventType;\n /** ISO-8601 UTC timestamp generated at the call site. */\n timestamp: string;\n /**\n * Actor identity. `tokenHash` is `sha256:<hex>` over the presented Bearer\n * token, or `sha256:absent` when no token was supplied. The raw token is\n * never logged.\n */\n actor?: { tokenHash: string };\n request: {\n method: string;\n path: string;\n /** Originating client IP from `cf-connecting-ip`; undefined off-Cloudflare. */\n ip?: string;\n };\n result: {\n status: number;\n /** Opaque storage version emitted by `TakuhonStorage.saveProfile`. */\n version?: string;\n };\n}\n\nexport type AuditLogger = (event: AuditEvent) => void;\n\n/** Default sink that discards events; useful for tests and bare runtimes. */\nexport const noopAuditLogger: AuditLogger = () => {\n /* no-op */\n};\n","/**\n * Cache invalidation contract for admin write paths.\n *\n * `@takuhon/api` stays adapter-neutral, so the actual edge-cache calls live\n * in each adapter (Cloudflare's `caches.default.delete`, future runtimes'\n * equivalents). Tests inject a recording implementation to assert that the\n * admin handlers fire the right purge after a successful write.\n */\nexport interface CachePurger {\n /** Called after a successful `PUT /api/admin/profile`. */\n profileUpdated(): Promise<void>;\n /** Called after a successful `DELETE /api/admin/profile`. */\n profileDeleted(): Promise<void>;\n}\n\n/**\n * No-op default: callers that don't run on an edge cache (Node dev server,\n * unit tests that don't care about purge calls) can pass this in.\n */\nexport const noopCachePurger: CachePurger = {\n profileUpdated: () => Promise.resolve(),\n profileDeleted: () => Promise.resolve(),\n};\n"],"mappings":";AAQO,IAAM,cAAc;AAAA,EACzB,YAAY;AAAA,EACZ,cAAc;AAAA,EACd,WAA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AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAwFtB;;;AD5HA,SAAS,SAAS,OAAuB;AACvC,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA,2BAA2B,KAAK;AAAA,IAChC,4BAA4B,KAAK;AAAA,IACjC;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,EAAE,KAAK,IAAI;AACb;AAEA,SAAS,gBAAwB;AAC/B,QAAM,QAAQ,OAAO,gBAAgB,IAAI,WAAW,EAAE,CAAC;AACvD,MAAI,MAAM;AACV,aAAW,KAAK,OAAO;AACrB,WAAO,OAAO,aAAa,CAAC;AAAA,EAC9B;AACA,SAAO,KAAK,GAAG;AACjB;AAQO,SAAS,mBAAyB;AACvC,QAAM,MAAM,IAAIC,MAAK;AAErB,MAAI,IAAI,KAAK,CAAC,MAAM;AAClB,UAAM,QAAQ,cAAc;AAC5B,MAAE,OAAO,6BAA6B,8CAA8C;AACpF,MAAE,OAAO,0BAA0B,SAAS;AAC5C,MAAE,OAAO,mBAAmB,MAAM;AAClC,MAAE,OAAO,mBAAmB,iCAAiC;AAC7D,MAAE,OAAO,sBAAsB,8DAA8D;AAC7F,MAAE,OAAO,2BAA2B,SAAS,KAAK,CAAC;AACnD,MAAE,OAAO,iBAAiB,mBAAmB;AAC7C,WAAO,EAAE,KAAK,gBAAgB,KAAK,CAAC;AAAA,EACtC,CAAC;AAED,SAAO;AACT;;;AEhBO,IAAM,kBAA+B,MAAM;AAElD;;;ACxBO,IAAM,kBAA+B;AAAA,EAC1C,gBAAgB,MAAM,QAAQ,QAAQ;AAAA,EACtC,gBAAgB,MAAM,QAAQ,QAAQ;AACxC;","names":["normalize","Hono","Hono","normalize","Hono","Hono"]}
package/package.json ADDED
@@ -0,0 +1,53 @@
1
+ {
2
+ "name": "@takuhon/api",
3
+ "version": "0.1.0",
4
+ "description": "Hono-based HTTP handlers, RFC 7807 error envelope, and response builders for takuhon",
5
+ "license": "Apache-2.0",
6
+ "author": "Takuhon contributors",
7
+ "homepage": "https://github.com/takuhon-dev/takuhon/tree/main/packages/api#readme",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/takuhon-dev/takuhon.git",
11
+ "directory": "packages/api"
12
+ },
13
+ "bugs": {
14
+ "url": "https://github.com/takuhon-dev/takuhon/issues"
15
+ },
16
+ "keywords": [
17
+ "takuhon",
18
+ "profile",
19
+ "api",
20
+ "hono",
21
+ "cloudflare-workers"
22
+ ],
23
+ "type": "module",
24
+ "main": "./dist/index.js",
25
+ "types": "./dist/index.d.ts",
26
+ "exports": {
27
+ ".": {
28
+ "types": "./dist/index.d.ts",
29
+ "import": "./dist/index.js"
30
+ }
31
+ },
32
+ "files": [
33
+ "dist",
34
+ "README.md",
35
+ "LICENSE",
36
+ "NOTICE"
37
+ ],
38
+ "publishConfig": {
39
+ "access": "public"
40
+ },
41
+ "engines": {
42
+ "node": ">=22.0.0"
43
+ },
44
+ "dependencies": {
45
+ "hono": "^4.12.19",
46
+ "@takuhon/core": "0.1.0"
47
+ },
48
+ "scripts": {
49
+ "typecheck": "tsc",
50
+ "build": "tsup src/index.ts --format esm --dts --clean --sourcemap",
51
+ "test": "vitest run"
52
+ }
53
+ }