@aotter/mantle 0.2.1 → 0.2.2-alpha.1

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.
Files changed (70) hide show
  1. package/dist/auth/routes.d.ts +3 -1
  2. package/dist/auth/routes.js +15 -2
  3. package/dist/build/compiler.d.ts +1 -0
  4. package/dist/build/compiler.js +1 -1
  5. package/dist/build/spec/kernel/diagnostic.d.ts +1 -1
  6. package/dist/bun/assets.d.ts +3 -1
  7. package/dist/bun/assets.js +4 -1
  8. package/dist/domain/describe/chunk-GMUORMOX.js +1 -0
  9. package/dist/domain/describe/index.js +1 -1
  10. package/dist/domain/describe/public.js +1 -1
  11. package/dist/domain/generated-tools.js +24 -9
  12. package/dist/infrastructure/bundle.js +30 -1
  13. package/dist/infrastructure/inputs.js +3 -2
  14. package/dist/infrastructure/wrangler.js +4 -3
  15. package/dist/kernel/authorization.d.ts +1 -0
  16. package/dist/kernel/authorization.js +12 -5
  17. package/dist/kernel/mcp-call.d.ts +3 -3
  18. package/dist/kernel/mcp-call.js +4 -4
  19. package/dist/kernel/mcp-handler.js +4 -3
  20. package/dist/kernel/mcp.d.ts +12 -10
  21. package/dist/kernel/mcp.js +1 -1
  22. package/dist/kernel/media-fetch.js +109 -0
  23. package/dist/kernel/media.d.ts +15 -2
  24. package/dist/kernel/media.js +138 -16
  25. package/dist/kernel/r2-media.d.ts +3 -2
  26. package/dist/kernel/r2-media.js +12 -8
  27. package/dist/kernel/result-meta.d.ts +10 -0
  28. package/dist/kernel/result-meta.js +1 -0
  29. package/dist/kernel/site-types.d.ts +54 -6
  30. package/dist/kernel/site.d.ts +1 -1
  31. package/dist/usecase/generate.js +2 -2
  32. package/dist/usecase/mcp-media.js +17 -5
  33. package/dist/usecase/mcp.js +6 -5
  34. package/dist/usecase/site.js +4 -2
  35. package/docs/examples/README.md +5 -1
  36. package/docs/examples/app-shell/README.md +5 -1
  37. package/docs/examples/app-shell/package.json +9 -9
  38. package/docs/examples/app-shell/src/jwks.ts +22 -0
  39. package/docs/examples/app-shell/src/service.ts +12 -1
  40. package/docs/examples/app-shell/wrangler.jsonc +1 -1
  41. package/docs/examples/club-events/README.md +10 -3
  42. package/docs/examples/club-events/manifests/club-events.yaml +42 -11
  43. package/docs/examples/club-events/smoke.mjs +31 -1
  44. package/docs/examples/club-events/src/handlers.ts +9 -8
  45. package/docs/examples/frontend-mcp-app/README.md +23 -0
  46. package/docs/examples/frontend-mcp-app/app.tsx +50 -0
  47. package/docs/examples/frontend-mcp-app/manifest.yaml +30 -0
  48. package/docs/examples/purchasing/README.md +9 -0
  49. package/docs/examples/purchasing/manifests/purchasing.yaml +18 -16
  50. package/docs/examples/purchasing/smoke.mjs +5 -0
  51. package/docs/examples/purchasing/wrangler.jsonc +1 -1
  52. package/docs/examples/recipes/wrangler.jsonc +1 -1
  53. package/docs/handbook/cloudflare/authentication.md +51 -0
  54. package/docs/handbook/cloudflare/deploy-and-operate.md +5 -0
  55. package/docs/handbook/cloudflare/media-r2.md +5 -2
  56. package/docs/handbook/cloudflare/service-entry.md +28 -7
  57. package/docs/handbook/examples/hub.md +1 -1
  58. package/docs/handbook/guides/mcp-apps.md +94 -18
  59. package/docs/handbook/guides/native-admin.md +29 -0
  60. package/docs/handbook/guides/performance.md +5 -1
  61. package/docs/handbook/guides/revisions.md +1 -1
  62. package/docs/handbook/guides/sql-patterns.md +33 -0
  63. package/docs/handbook/reference/authorization.md +1 -1
  64. package/docs/handbook/reference/describe.md +5 -0
  65. package/docs/handbook/reference/schema.md +19 -0
  66. package/docs/handbook/reference/site-config.md +2 -0
  67. package/docs/handbook/reference/surface.md +66 -10
  68. package/docs/handbook/releases/index.md +24 -1
  69. package/package.json +10 -10
  70. package/dist/domain/describe/chunk-CW7X5Q5T.js +0 -1
@@ -13,7 +13,7 @@ export interface AuthRoutesOptions {
13
13
  readonly providerId: string;
14
14
  readonly displayName?: string;
15
15
  } | {
16
- readonly kind: "email-otp" | "magic-link";
16
+ readonly kind: "email-otp" | "magic-link" | "passkey";
17
17
  })[];
18
18
  readonly connectedAppsPage?: string;
19
19
  }
@@ -21,6 +21,8 @@ export interface AuthRoutesOptions {
21
21
  export declare function authRoutes(loader: AuthLoader<AuthInstance & {
22
22
  handler(request: Request): Promise<Response>;
23
23
  }>, options: AuthRoutesOptions): (request: Request) => Promise<Response | null>;
24
+ /** Uniform public OTP failures; validation, expiry and attempt budgets remain Better Auth's. */
25
+ export declare function normalizeEmailOtpResponse(response: Response): Promise<Response>;
24
26
  /**
25
27
  * A dynamic registration whose every redirect URI is http on a loopback host and that names no application_type is a
26
28
  * native app (RFC 8252 7.3): local MCP clients register this way. Better Auth reads the missing type as `web`, which
@@ -2,7 +2,7 @@ import { ContractError } from "../kernel/contracts.js";
2
2
  import { checkOrigin, surfaceFailure } from "../kernel/surface-failure.js";
3
3
  import { draining } from "../kernel/drain.js";
4
4
  import { guardAuthAdminRequest } from "./admin.js";
5
- import { CONSENT, MAX_BODY, json, readBody, text } from "./route-http.js";
5
+ import { CONSENT, MAX_BODY, PRIVATE, json, readBody, text } from "./route-http.js";
6
6
  import { resolveCaller } from "./caller.js";
7
7
  const basePathOf = (options) => (options.basePath ?? "/api/auth").replace(/\/+$/, "");
8
8
  const WELL_KNOWN = /^\/\.well-known\/(oauth-authorization-server|oauth-protected-resource)(\/|$)/;
@@ -24,7 +24,7 @@ export function authRoutes(loader, options) {
24
24
  const bounded = request.body ? new Request(request, { body: await readBody(request) }) : request;
25
25
  await guardAuthAdminRequest(bounded, () => resolve(bounded), base);
26
26
  const registration = bounded.method === "POST" && pathname === `${base}/oauth2/register` ? await loopbackClientsAreNative(bounded) : bounded;
27
- return await normalizeAuthResponseCookies(await auth.handler(registration));
27
+ return await normalizeAuthResponseCookies(await normalizeEmailOtpResponse(await auth.handler(registration)));
28
28
  }
29
29
  catch (error) {
30
30
  return surfaceFailure(error, undefined, `auth ${route}`);
@@ -45,6 +45,19 @@ export function authRoutes(loader, options) {
45
45
  }
46
46
  });
47
47
  }
48
+ export async function normalizeEmailOtpResponse(response) {
49
+ if ((response.status !== 400 && response.status !== 403) ||
50
+ response.headers.get("content-type")?.split(";")[0]?.trim().toLowerCase() !== "application/json")
51
+ return response;
52
+ const error = await response.clone().json().catch(() => null);
53
+ if (!error || typeof error !== "object" || !("code" in error) || typeof error.code !== "string" ||
54
+ !["INVALID_OTP", "OTP_EXPIRED", "TOO_MANY_ATTEMPTS"].includes(error.code))
55
+ return response;
56
+ void response.body?.cancel().catch(() => { });
57
+ return Response.json({ code: "INVALID_OTP", message: "Invalid OTP" }, {
58
+ status: 400, statusText: "BAD_REQUEST", headers: { ...PRIVATE, "content-type": "application/json" },
59
+ });
60
+ }
48
61
  const LOOPBACK_HOSTS = new Set(["localhost", "127.0.0.1", "[::1]"]);
49
62
  export async function loopbackClientsAreNative(request) {
50
63
  const body = await readBody(request.clone()).then(JSON.parse).catch(error => { if (error instanceof ContractError)
@@ -26,6 +26,7 @@ export interface MediaPurposePolicy {
26
26
  readonly name: string;
27
27
  readonly required: readonly string[];
28
28
  readonly maxBytes: Readonly<Record<string, number>>;
29
+ readonly visibility?: "public" | "private";
29
30
  }
30
31
  export interface SiteIcon {
31
32
  readonly src: string;