@pithy-sh/auth 0.15.3 → 0.17.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.
Files changed (209) hide show
  1. package/README.md +4 -0
  2. package/dist/attestation/appAttest/assertion.d.ts +32 -0
  3. package/dist/attestation/appAttest/assertion.d.ts.map +1 -0
  4. package/dist/attestation/appAttest/assertion.js +59 -0
  5. package/dist/attestation/appAttest/attestation.d.ts +49 -0
  6. package/dist/attestation/appAttest/attestation.d.ts.map +1 -0
  7. package/dist/attestation/appAttest/attestation.js +111 -0
  8. package/dist/attestation/appAttest/authData.d.ts +24 -0
  9. package/dist/attestation/appAttest/authData.d.ts.map +1 -0
  10. package/dist/attestation/appAttest/authData.js +32 -0
  11. package/dist/attestation/appAttest/base64.d.ts +8 -0
  12. package/dist/attestation/appAttest/base64.d.ts.map +1 -0
  13. package/dist/attestation/appAttest/base64.js +27 -0
  14. package/dist/attestation/appAttest/bytes.d.ts +7 -0
  15. package/dist/attestation/appAttest/bytes.d.ts.map +1 -0
  16. package/dist/attestation/appAttest/bytes.js +19 -0
  17. package/dist/attestation/appAttest/cbor.d.ts +20 -0
  18. package/dist/attestation/appAttest/cbor.d.ts.map +1 -0
  19. package/dist/attestation/appAttest/cbor.js +96 -0
  20. package/dist/attestation/appAttest/der.d.ts +38 -0
  21. package/dist/attestation/appAttest/der.d.ts.map +1 -0
  22. package/dist/attestation/appAttest/der.js +106 -0
  23. package/dist/attestation/appAttest/keys.d.ts +15 -0
  24. package/dist/attestation/appAttest/keys.d.ts.map +1 -0
  25. package/dist/attestation/appAttest/keys.js +37 -0
  26. package/dist/attestation/appAttest/root.d.ts +9 -0
  27. package/dist/attestation/appAttest/root.d.ts.map +1 -0
  28. package/dist/attestation/appAttest/root.js +12 -0
  29. package/dist/attestation/appAttest/verifier.d.ts +39 -0
  30. package/dist/attestation/appAttest/verifier.d.ts.map +1 -0
  31. package/dist/attestation/appAttest/verifier.js +121 -0
  32. package/dist/attestation/appAttest/x509.d.ts +50 -0
  33. package/dist/attestation/appAttest/x509.d.ts.map +1 -0
  34. package/dist/attestation/appAttest/x509.js +163 -0
  35. package/dist/attestation/challenge.d.ts +26 -0
  36. package/dist/attestation/challenge.d.ts.map +1 -0
  37. package/dist/attestation/challenge.js +47 -0
  38. package/dist/attestation/config.d.ts +72 -0
  39. package/dist/attestation/config.d.ts.map +1 -0
  40. package/dist/attestation/config.js +52 -0
  41. package/dist/attestation/errors.d.ts +30 -0
  42. package/dist/attestation/errors.d.ts.map +1 -0
  43. package/dist/attestation/errors.js +45 -0
  44. package/dist/attestation/gate.d.ts +27 -0
  45. package/dist/attestation/gate.d.ts.map +1 -0
  46. package/dist/attestation/gate.js +78 -0
  47. package/dist/attestation/playIntegrity/google.d.ts +47 -0
  48. package/dist/attestation/playIntegrity/google.d.ts.map +1 -0
  49. package/dist/attestation/playIntegrity/google.js +178 -0
  50. package/dist/attestation/playIntegrity/verdict.d.ts +40 -0
  51. package/dist/attestation/playIntegrity/verdict.d.ts.map +1 -0
  52. package/dist/attestation/playIntegrity/verdict.js +93 -0
  53. package/dist/attestation/playIntegrity/verifier.d.ts +22 -0
  54. package/dist/attestation/playIntegrity/verifier.d.ts.map +1 -0
  55. package/dist/attestation/playIntegrity/verifier.js +64 -0
  56. package/dist/attestation/verifier.d.ts +60 -0
  57. package/dist/attestation/verifier.d.ts.map +1 -0
  58. package/dist/attestation/verifier.js +46 -0
  59. package/dist/attestation/wire.d.ts +42 -0
  60. package/dist/attestation/wire.d.ts.map +1 -0
  61. package/dist/attestation/wire.js +72 -0
  62. package/dist/capability.d.ts +49 -6
  63. package/dist/capability.d.ts.map +1 -1
  64. package/dist/capability.js +42 -7
  65. package/dist/client/api.d.ts +37 -24
  66. package/dist/client/api.d.ts.map +1 -1
  67. package/dist/client/api.js +52 -41
  68. package/dist/client/attestation.d.ts +148 -0
  69. package/dist/client/attestation.d.ts.map +1 -0
  70. package/dist/client/attestation.js +321 -0
  71. package/dist/client/projection.d.ts +29 -4
  72. package/dist/client/projection.d.ts.map +1 -1
  73. package/dist/data/appAttestKey.d.ts +30 -0
  74. package/dist/data/appAttestKey.d.ts.map +1 -0
  75. package/dist/data/appAttestKey.js +25 -0
  76. package/dist/data/attestationChallenge.d.ts +17 -0
  77. package/dist/data/attestationChallenge.d.ts.map +1 -0
  78. package/dist/data/attestationChallenge.js +19 -0
  79. package/dist/data/tables.d.ts +19 -1
  80. package/dist/data/tables.d.ts.map +1 -1
  81. package/dist/data/tables.js +6 -2
  82. package/dist/data/userLifecycle.d.ts +1 -0
  83. package/dist/data/userLifecycle.d.ts.map +1 -1
  84. package/dist/data/userLifecycle.js +3 -2
  85. package/dist/hooks/runtime.d.ts +32 -0
  86. package/dist/hooks/runtime.d.ts.map +1 -0
  87. package/dist/hooks/runtime.js +25 -0
  88. package/dist/http/adminRoutes.d.ts.map +1 -1
  89. package/dist/http/adminRoutes.js +4 -2
  90. package/dist/http/devLoginRoute.js +3 -3
  91. package/dist/http/resolve.d.ts.map +1 -1
  92. package/dist/http/resolve.js +3 -2
  93. package/dist/http/responses.d.ts +15 -0
  94. package/dist/http/responses.d.ts.map +1 -1
  95. package/dist/http/responses.js +13 -2
  96. package/dist/http/routes.d.ts +5 -1
  97. package/dist/http/routes.d.ts.map +1 -1
  98. package/dist/http/routes.js +92 -25
  99. package/dist/http/schemas.d.ts +7 -0
  100. package/dist/http/schemas.d.ts.map +1 -1
  101. package/dist/http/schemas.js +7 -1
  102. package/dist/index.js +1 -1
  103. package/dist/instance/secrets.d.ts +86 -7
  104. package/dist/instance/secrets.d.ts.map +1 -1
  105. package/dist/instance/secrets.js +54 -8
  106. package/dist/lifecycle/erasure.d.ts.map +1 -1
  107. package/dist/lifecycle/erasure.js +2 -1
  108. package/dist/lifecycle/hooks.d.ts +18 -10
  109. package/dist/lifecycle/hooks.d.ts.map +1 -1
  110. package/dist/lifecycle/request.d.ts +2 -1
  111. package/dist/lifecycle/request.d.ts.map +1 -1
  112. package/dist/lifecycle/request.js +4 -1
  113. package/dist/lifecycle/transitions.d.ts +24 -16
  114. package/dist/lifecycle/transitions.d.ts.map +1 -1
  115. package/dist/lifecycle/transitions.js +27 -16
  116. package/dist/migrations/0009_attestation_challenges.d.ts +9 -0
  117. package/dist/migrations/0009_attestation_challenges.d.ts.map +1 -0
  118. package/dist/migrations/0009_attestation_challenges.js +21 -0
  119. package/dist/migrations/0010_app_attest_keys.d.ts +9 -0
  120. package/dist/migrations/0010_app_attest_keys.d.ts.map +1 -0
  121. package/dist/migrations/0010_app_attest_keys.js +17 -0
  122. package/dist/migrations/0011_retained_basis_key.d.ts +10 -0
  123. package/dist/migrations/0011_retained_basis_key.d.ts.map +1 -0
  124. package/dist/migrations/0011_retained_basis_key.js +18 -0
  125. package/dist/migrations/set.d.ts +4 -1
  126. package/dist/migrations/set.d.ts.map +1 -1
  127. package/dist/migrations/set.js +8 -2
  128. package/dist/purge/run.d.ts +11 -11
  129. package/dist/purge/run.d.ts.map +1 -1
  130. package/dist/purge/run.js +9 -8
  131. package/dist/purge/workflow.d.ts +7 -1
  132. package/dist/purge/workflow.d.ts.map +1 -1
  133. package/dist/purge/workflow.js +6 -2
  134. package/dist/seeds/devSession.js +1 -1
  135. package/dist/test-utils/appAttestDevice.d.ts +92 -0
  136. package/dist/test-utils/appAttestDevice.d.ts.map +1 -0
  137. package/dist/test-utils/appAttestDevice.js +282 -0
  138. package/dist/test-utils/appAttestSample.d.ts +22 -0
  139. package/dist/test-utils/appAttestSample.d.ts.map +1 -0
  140. package/dist/test-utils/appAttestSample.js +24 -0
  141. package/dist/test-utils/googlePlay.d.ts +47 -0
  142. package/dist/test-utils/googlePlay.d.ts.map +1 -0
  143. package/dist/test-utils/googlePlay.js +117 -0
  144. package/dist/test-utils/liveApp.d.ts +76 -36
  145. package/dist/test-utils/liveApp.d.ts.map +1 -1
  146. package/dist/test-utils/liveApp.js +16 -5
  147. package/dist/test-utils/rollbackThrough.d.ts +11 -0
  148. package/dist/test-utils/rollbackThrough.d.ts.map +1 -0
  149. package/dist/test-utils/rollbackThrough.js +16 -0
  150. package/dist/test-utils/scopedBackend.d.ts +25 -0
  151. package/dist/test-utils/scopedBackend.d.ts.map +1 -1
  152. package/dist/test-utils/scopedBackend.js +1 -1
  153. package/dist/version.generated.d.ts +1 -1
  154. package/dist/version.generated.js +1 -1
  155. package/docs/account-lifecycle.md +46 -10
  156. package/docs/attestation.md +173 -0
  157. package/package.json +5 -5
  158. package/pithy.manifest.json +14 -0
  159. package/src/attestation/appAttest/assertion.ts +65 -0
  160. package/src/attestation/appAttest/attestation.ts +159 -0
  161. package/src/attestation/appAttest/authData.ts +45 -0
  162. package/src/attestation/appAttest/base64.ts +29 -0
  163. package/src/attestation/appAttest/bytes.ts +18 -0
  164. package/src/attestation/appAttest/cbor.ts +116 -0
  165. package/src/attestation/appAttest/der.ts +126 -0
  166. package/src/attestation/appAttest/keys.ts +57 -0
  167. package/src/attestation/appAttest/root.ts +13 -0
  168. package/src/attestation/appAttest/verifier.ts +113 -0
  169. package/src/attestation/appAttest/x509.ts +209 -0
  170. package/src/attestation/challenge.ts +56 -0
  171. package/src/attestation/config.ts +118 -0
  172. package/src/attestation/errors.ts +60 -0
  173. package/src/attestation/gate.ts +105 -0
  174. package/src/attestation/playIntegrity/google.ts +239 -0
  175. package/src/attestation/playIntegrity/verdict.ts +149 -0
  176. package/src/attestation/playIntegrity/verifier.ts +77 -0
  177. package/src/attestation/verifier.ts +87 -0
  178. package/src/attestation/wire.ts +79 -0
  179. package/src/capability.ts +85 -16
  180. package/src/client/api.ts +73 -40
  181. package/src/client/attestation.ts +404 -0
  182. package/src/client/projection.ts +29 -4
  183. package/src/data/appAttestKey.ts +45 -0
  184. package/src/data/attestationChallenge.ts +23 -0
  185. package/src/data/tables.ts +5 -1
  186. package/src/data/userLifecycle.ts +9 -2
  187. package/src/hooks/runtime.ts +41 -0
  188. package/src/http/adminRoutes.ts +14 -7
  189. package/src/http/resolve.ts +8 -4
  190. package/src/http/responses.ts +29 -1
  191. package/src/http/routes.ts +128 -38
  192. package/src/http/schemas.ts +24 -0
  193. package/src/instance/secrets.ts +88 -9
  194. package/src/lifecycle/erasure.ts +2 -1
  195. package/src/lifecycle/hooks.ts +22 -10
  196. package/src/lifecycle/request.ts +4 -1
  197. package/src/lifecycle/transitions.ts +47 -28
  198. package/src/migrations/0009_attestation_challenges.ts +28 -0
  199. package/src/migrations/0010_app_attest_keys.ts +27 -0
  200. package/src/migrations/0011_retained_basis_key.ts +19 -0
  201. package/src/migrations/set.ts +7 -1
  202. package/src/purge/run.ts +29 -17
  203. package/src/purge/workflow.ts +7 -3
  204. package/src/test-utils/appAttestDevice.ts +399 -0
  205. package/src/test-utils/appAttestSample.ts +20 -0
  206. package/src/test-utils/googlePlay.ts +144 -0
  207. package/src/test-utils/liveApp.ts +31 -5
  208. package/src/test-utils/rollbackThrough.ts +24 -0
  209. package/src/version.generated.ts +1 -1
@@ -0,0 +1,25 @@
1
+ // SPDX-FileCopyrightText: 2026 Pithy
2
+ // SPDX-License-Identifier: MIT
3
+ //#region src/hooks/runtime.ts
4
+ /**
5
+ * The runtime for a hook fired inside a request: the request's env, and its `waitUntil` bound to the context.
6
+ *
7
+ * Hono's `executionCtx` getter throws when the request carries none, as under `app.request()` with no context, so
8
+ * that case reads as absent rather than failing the hook's caller.
9
+ */
10
+ function requestRuntime(c) {
11
+ const env = c.env;
12
+ let ctx;
13
+ try {
14
+ ctx = c.executionCtx;
15
+ } catch {
16
+ ctx = void 0;
17
+ }
18
+ if (!ctx) return { env };
19
+ return {
20
+ env,
21
+ waitUntil: ctx.waitUntil.bind(ctx)
22
+ };
23
+ }
24
+ //#endregion
25
+ export { requestRuntime };
@@ -1 +1 @@
1
- {"version":3,"file":"adminRoutes.d.ts","sourceRoot":"","sources":["../../src/http/adminRoutes.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0CAA0C,CAAC;AAS7E,OAAO,KAAK,EAAW,IAAI,EAAE,MAAM,MAAM,CAAC;AAe1C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAgUhD;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,UAAU,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,YAAY,CAAC,KAAK,IAAI,CA4hB7F"}
1
+ {"version":3,"file":"adminRoutes.d.ts","sourceRoot":"","sources":["../../src/http/adminRoutes.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0CAA0C,CAAC;AAU7E,OAAO,KAAK,EAAW,IAAI,EAAE,MAAM,MAAM,CAAC;AAe1C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAgUhD;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,UAAU,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,YAAY,CAAC,KAAK,IAAI,CAkiB7F"}
@@ -23,6 +23,7 @@ import { describeRoute } from "@pithy-sh/core/src/http/routeSpec";
23
23
  import { validate } from "@pithy-sh/core/src/http/validation";
24
24
  import { MAX_PAGE_SIZE } from "@pithy-sh/core/src/data/cursor";
25
25
  import { requireControlPlane } from "@pithy-sh/core/src/controlPlane/http/guard";
26
+ import { composedTranslator } from "@pithy-sh/core/src/i18n/composed";
26
27
  import { workflowBindingFor } from "@pithy-sh/core/src/workflow/dispatch";
27
28
  //#region src/http/adminRoutes.ts
28
29
  /**
@@ -605,7 +606,8 @@ function registerAuthAdminRoutes(wiring) {
605
606
  ...call.audit
606
607
  }, async () => {
607
608
  const database = db(c, wiring);
608
- await requirePresent(database, userId);
609
+ const { locale } = await requirePresent(database, userId);
610
+ const t = composedTranslator(wiring.composed ?? [], locale);
609
611
  return purgeExports(wiring.purgeSteps ?? [], {
610
612
  subject: {
611
613
  type: "user",
@@ -613,7 +615,7 @@ function registerAuthAdminRoutes(wiring) {
613
615
  },
614
616
  env: c.env,
615
617
  address: () => purgeAddress(database, userId)
616
- });
618
+ }, t ? (key) => t.maybe(key) : void 0);
617
619
  }, () => false);
618
620
  await emitControlPlaneAction(c.var.emit, {
619
621
  action: AuthAuditActions.adminUserExported,
@@ -1,18 +1,18 @@
1
1
  // SPDX-FileCopyrightText: 2026 Pithy
2
2
  // SPDX-License-Identifier: MIT
3
+ import { resolveSessionSecret } from "../instance/secrets.js";
3
4
  import { Session } from "../data/betterAuth.js";
4
5
  import { authDatabase } from "../data/tables.js";
5
- import { resolveSessionSecret } from "../instance/secrets.js";
6
6
  import { DEV_SESSION_COOKIE_NAME, signCookieValue, verifyDevLoginClaim } from "../seeds/devSession.js";
7
7
  import { resolveDb } from "./resolve.js";
8
8
  import { NotFoundError } from "@pithy-sh/core/src/error/pithyError";
9
9
  import { z } from "zod";
10
- import { ambientEnv, compositionEnvironment } from "@pithy-sh/core/src/env/ambient";
10
+ import { LOCAL_ENVIRONMENT } from "@pithy-sh/core/src/naming/environment";
11
11
  import { commandName, pithyCommand } from "@pithy-sh/core/src/cli/command";
12
+ import { ambientEnv, compositionEnvironment } from "@pithy-sh/core/src/env/ambient";
12
13
  import { isContinuousIntegration } from "@pithy-sh/core/src/env/ci";
13
14
  import { describeRoute } from "@pithy-sh/core/src/http/routeSpec";
14
15
  import { validate } from "@pithy-sh/core/src/http/validation";
15
- import { LOCAL_ENVIRONMENT } from "@pithy-sh/core/src/naming/environment";
16
16
  import { DEV_LOGIN_CLAIM_PARAM, DEV_LOGIN_ROUTE } from "@pithy-sh/core/src/seed/devLogin";
17
17
  //#region src/http/devLoginRoute.ts
18
18
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"resolve.d.ts","sourceRoot":"","sources":["../../src/http/resolve.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAE5D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0CAA0C,CAAC;AAK7E,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACpC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAGhD,OAAO,EAAE,KAAK,YAAY,EAAY,MAAM,kBAAkB,CAAC;AAwB/D,2GAA2G;AAC3G,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,EAAE,MAAM,GAAG,UAAU,CASvF;AA0BD,wBAAgB,eAAe,CAAC,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,EAAE,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,YAAY,CAAC,CAMnG"}
1
+ {"version":3,"file":"resolve.d.ts","sourceRoot":"","sources":["../../src/http/resolve.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAE5D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0CAA0C,CAAC;AAK7E,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACpC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAIhD,OAAO,EAAE,KAAK,YAAY,EAAY,MAAM,kBAAkB,CAAC;AAwB/D,2GAA2G;AAC3G,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,EAAE,MAAM,GAAG,UAAU,CASvF;AA0BD,wBAAgB,eAAe,CAAC,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,EAAE,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,YAAY,CAAC,CAMnG"}
@@ -1,9 +1,10 @@
1
1
  // SPDX-FileCopyrightText: 2026 Pithy
2
2
  // SPDX-License-Identifier: MIT
3
+ import { resolveAppleCredentials, resolveFacebookCredentials, resolveGithubCredentials, resolveGoogleCredentials, resolveMicrosoftCredentials, resolveSessionSecrets } from "../instance/secrets.js";
3
4
  import { authDatabase } from "../data/tables.js";
4
5
  import { baseURLResolver } from "./baseUrl.js";
5
- import { resolveAppleCredentials, resolveFacebookCredentials, resolveGithubCredentials, resolveGoogleCredentials, resolveMicrosoftCredentials, resolveSessionSecrets } from "../instance/secrets.js";
6
6
  import { makeSendAuthEmail } from "../email/send.js";
7
+ import { requestRuntime } from "../hooks/runtime.js";
7
8
  import { resolveProvider } from "../instance/providers.js";
8
9
  import { makeAuth } from "../instance/auth.js";
9
10
  import { ensureJwksSealedUnderCurrent } from "../instance/jwksReencryption.js";
@@ -90,7 +91,7 @@ async function buildAuthInstance(c, wiring) {
90
91
  const baseURL = baseURLResolver(cfg.baseURL)(c.req.raw);
91
92
  return makeAuth({
92
93
  db: authDatabase(d1),
93
- ...listener ? { onSessionRevoked: (session) => listener(session, d1) } : {},
94
+ ...listener ? { onSessionRevoked: (session) => listener(session, d1, requestRuntime(c)) } : {},
94
95
  secret,
95
96
  sessionSecrets,
96
97
  baseURL,
@@ -434,6 +434,7 @@ export declare const AdminUserExportResponse: z.ZodObject<{
434
434
  retain: "retain";
435
435
  }>>;
436
436
  basis: z.ZodOptional<z.ZodString>;
437
+ basisKey: z.ZodOptional<z.ZodString>;
437
438
  state: z.ZodLiteral<"exported">;
438
439
  data: z.ZodRecord<z.ZodString, z.ZodUnknown>;
439
440
  }, z.core.$strip>, z.ZodObject<{
@@ -444,6 +445,7 @@ export declare const AdminUserExportResponse: z.ZodObject<{
444
445
  retain: "retain";
445
446
  }>>;
446
447
  basis: z.ZodOptional<z.ZodString>;
448
+ basisKey: z.ZodOptional<z.ZodString>;
447
449
  state: z.ZodLiteral<"not_exported">;
448
450
  }, z.core.$strip>, z.ZodObject<{
449
451
  capability: z.ZodString;
@@ -453,6 +455,7 @@ export declare const AdminUserExportResponse: z.ZodObject<{
453
455
  retain: "retain";
454
456
  }>>;
455
457
  basis: z.ZodOptional<z.ZodString>;
458
+ basisKey: z.ZodOptional<z.ZodString>;
456
459
  state: z.ZodLiteral<"unavailable">;
457
460
  }, z.core.$strip>], "state">>;
458
461
  }, z.core.$strip>;
@@ -470,6 +473,18 @@ export declare const HandoffExchangeResponse: z.ZodObject<{
470
473
  expiresAt: z.ZodISODateTime;
471
474
  }, z.core.$strip>;
472
475
  export type HandoffExchangeResponse = z.output<typeof HandoffExchangeResponse>;
476
+ /** `POST {base}/attestation/challenge`. */
477
+ export declare const AttestationChallengeResponse: z.ZodObject<{
478
+ challenge: z.ZodString;
479
+ expiresAt: z.ZodISODateTime;
480
+ }, z.core.$strip>;
481
+ export type AttestationChallengeResponse = z.output<typeof AttestationChallengeResponse>;
482
+ /** `POST {base}/attestation/ios/keys`. */
483
+ export declare const AppAttestKeyResponse: z.ZodObject<{
484
+ keyId: z.ZodString;
485
+ registeredAt: z.ZodISODateTime;
486
+ }, z.core.$strip>;
487
+ export type AppAttestKeyResponse = z.output<typeof AppAttestKeyResponse>;
473
488
  /** One of the caller's own registered devices. */
474
489
  export declare const MyDeviceView: z.ZodObject<{
475
490
  id: z.ZodString;
@@ -1 +1 @@
1
- {"version":3,"file":"responses.d.ts","sourceRoot":"","sources":["../../src/http/responses.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAyCxB,kDAAkD;AAClD,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;iBAuCsF,CAAC;AACjH,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,aAAa,CAAC,CAAC;AAE3D,2FAA2F;AAC3F,eAAO,MAAM,gBAAgB;;;;;;;;iBAUiF,CAAC;AAC/G,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAEjE,0GAA0G;AAC1G,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;iBAawF,CAAC;AACrH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,eAAe,CAAC,CAAC;AAE/D,qEAAqE;AACrE,eAAO,MAAM,kBAAkB;;;;;;;;;;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C,CAAC,MAAM,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAEvE,6BAA6B;AAC7B,eAAO,MAAM,uBAAuB;;;iBASyD,CAAC;AAC9F,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAE/E,2CAA2C;AAC3C,eAAO,MAAM,4BAA4B;;;iBAS0B,CAAC;AACpE,MAAM,MAAM,4BAA4B,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,4BAA4B,CAAC,CAAC;AAEzF,0CAA0C;AAC1C,eAAO,MAAM,oBAAoB;;;iBAKoC,CAAC;AACtE,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAEzE,kDAAkD;AAClD,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;iBAcwC,CAAC;AAClE,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,YAAY,CAAC,CAAC;AAEzD,4BAA4B;AAC5B,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;iBAIqB,CAAC;AACpD,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAEnE,oCAAoC;AACpC,eAAO,MAAM,sBAAsB;;iBAEyE,CAAC;AAC7G,MAAM,MAAM,sBAAsB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAE7E;;;GAGG;AACH,eAAO,MAAM,qBAAqB;;;;iBAU2E,CAAC;AAC9G,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,qBAAqB,CAAC,CAAC"}
@@ -269,7 +269,8 @@ const exportEntry = {
269
269
  capability: z.string().describe("The capability whose rows these are — the purge step that erases or keeps them."),
270
270
  summary: z.string().describe("What that capability's purge erases, anonymizes or keeps, in its own sentence."),
271
271
  disposition: z.enum(["erase", "retain"]).optional().describe("What a purge does with these rows: `erase` (erased or anonymized) or `retain` (kept, for the reason in `basis`) (#814). Absent from a Worker that predates it, where every entry is `erase`."),
272
- basis: z.string().optional().describe("For a `retain` entry, why the rows are kept, in one sentence written for the person — `Kept for tax records.` Absent for `erase`.")
272
+ basis: z.string().optional().describe("For a `retain` entry, why the rows are kept, in one sentence written for the person and in their stored locale where a catalog translates it — `Kept for tax records.` Absent for `erase`."),
273
+ basisKey: z.string().optional().describe("For a `retain` entry, the catalog key `basis` was translated from, under the capability's own domain — `payments/purge.retained`. Absent when the capability names none, for `erase`, and from a Worker that predates it.")
273
274
  };
274
275
  /** One capability's part of an export. */
275
276
  const AdminUserExportEntry = z.discriminatedUnion("state", [
@@ -313,6 +314,16 @@ const HandoffExchangeResponse = z.object({
313
314
  token: z.string().describe("The raw session token: the bearer credential for `Authorization: Bearer`, and the refresh credential `/token/rotate` takes. Hold it in secure storage."),
314
315
  expiresAt: z.iso.datetime().describe("When the session lapses unless it is rotated first, ISO-8601.")
315
316
  }).describe("The session a redirect sign-in made, handed to the native app that started it.");
317
+ /** `POST {base}/attestation/challenge`. */
318
+ const AttestationChallengeResponse = z.object({
319
+ challenge: z.string().describe("The challenge: 32 random bytes, unpadded base64url. Good once, on one send route, until `expiresAt`. The platform's assertion is made over SHA-256 of these characters followed by that request's exact body."),
320
+ expiresAt: z.iso.datetime().describe("When the challenge stops being accepted, ISO-8601.")
321
+ }).describe("A single-use challenge for a native app attestation.");
322
+ /** `POST {base}/attestation/ios/keys`. */
323
+ const AppAttestKeyResponse = z.object({
324
+ keyId: z.string().describe("The key identifier, as the request sent it. Assertions name it as `keyId`."),
325
+ registeredAt: z.iso.datetime().describe("When the key was registered, ISO-8601.")
326
+ }).describe("An App Attest key this server verified and registered.");
316
327
  /** One of the caller's own registered devices. */
317
328
  const MyDeviceView = z.object({
318
329
  id: z.string().describe("The client-generated device id it registered at sign-in."),
@@ -341,4 +352,4 @@ const AccountDeleteResponse = z.object({
341
352
  mailed: z.boolean().describe("Whether the deletion-scheduled mail, with the purge date and how to ask for the account back, was sent.")
342
353
  }).describe("The caller's own account, deleted: when its data will be erased, and whether they were mailed.");
343
354
  //#endregion
344
- export { AccountDeleteResponse, AdminDeviceRevokeResponse, AdminDeviceView, AdminDevicesResponse, AdminRevokeResponse, AdminSessionView, AdminUserDeleteResponse, AdminUserExportResponse, AdminUserReinstateResponse, AdminUserResponse, AdminUserRestoreResponse, AdminUserSuspendResponse, AdminUserView, AdminUsersResponse, AdminVerificationView, AdminVerificationsResponse, AuthUserExport, HandoffExchangeResponse, MyDeviceRevokeResponse, MyDeviceView, MyDevicesResponse, TokenRotateResponse, VerificationTypeCounts };
355
+ export { AccountDeleteResponse, AdminDeviceRevokeResponse, AdminDeviceView, AdminDevicesResponse, AdminRevokeResponse, AdminSessionView, AdminUserDeleteResponse, AdminUserExportResponse, AdminUserReinstateResponse, AdminUserResponse, AdminUserRestoreResponse, AdminUserSuspendResponse, AdminUserView, AdminUsersResponse, AdminVerificationView, AdminVerificationsResponse, AppAttestKeyResponse, AttestationChallengeResponse, AuthUserExport, HandoffExchangeResponse, MyDeviceRevokeResponse, MyDeviceView, MyDevicesResponse, TokenRotateResponse, VerificationTypeCounts };
@@ -3,10 +3,12 @@
3
3
  import type { PithyHonoEnv } from "@pithy-sh/core/src/capability/capability";
4
4
  import type { Hono } from "hono";
5
5
  import type { AuthWiring } from "../capability";
6
+ /** The routes that send a sign-in email, under `basePath`: the ones Turnstile and attestation gate. */
7
+ export declare const SEND_ROUTES: readonly ["/sign-in/magic-link", "/email-otp/send-verification-otp"];
6
8
  /**
7
9
  * Register the auth routes onto the backend's Hono app.
8
10
  *
9
- * Order matters: turnstile gates the human-initiated send routes (only when composed), Pithy's own
11
+ * Order matters: Turnstile and attestation gate the send routes ({@link SEND_ROUTES}), Pithy's own
10
12
  * routes are registered before the catch-all so they win, and Better Auth owns everything else under
11
13
  * `basePath`. A handler that returns a Response ends the chain, so the specific routes never fall
12
14
  * through to the catch-all. (The tier-1 edge rate limiter is contributed as capability *middleware*, so
@@ -17,6 +19,8 @@ import type { AuthWiring } from "../capability";
17
19
  * | Route | Verification | Input |
18
20
  * | -------------------------- | --------------- | --------------------------- |
19
21
  * | `POST /token/rotate` | bearer/session | none — the credential only |
22
+ * | `POST /attestation/challenge` | public | none |
23
+ * | `POST /attestation/ios/keys` | public | json `AppAttestKeyBody` |
20
24
  * | `GET /sign-in/social/start` | public | query `SocialSignInStartQuery` |
21
25
  * | `POST /handoff` | public | json `HandoffExchangeBody` |
22
26
  * | `GET /devices` | bearer/session | none |
@@ -1 +1 @@
1
- {"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../../src/http/routes.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0CAA0C,CAAC;AAS7E,OAAO,KAAK,EAAW,IAAI,EAAE,MAAM,MAAM,CAAC;AAG1C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAkDhD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,UAAU,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,YAAY,CAAC,KAAK,IAAI,CAyKtF"}
1
+ {"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../../src/http/routes.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0CAA0C,CAAC;AAU7E,OAAO,KAAK,EAAW,IAAI,EAAE,MAAM,MAAM,CAAC;AAU1C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAsDhD,uGAAuG;AACvG,eAAO,MAAM,WAAW,YAAI,qBAAqB,EAAE,kCAAkC,CAAU,CAAC;AAMhG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,UAAU,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,YAAY,CAAC,KAAK,IAAI,CAgNtF"}
@@ -1,5 +1,10 @@
1
1
  // SPDX-FileCopyrightText: 2026 Pithy
2
2
  // SPDX-License-Identifier: MIT
3
+ import { attestationIsConfigured } from "../attestation/config.js";
4
+ import { issueChallenge } from "../attestation/challenge.js";
5
+ import { registerAppAttestKey } from "../attestation/appAttest/verifier.js";
6
+ import { AttestationFailedError } from "../attestation/errors.js";
7
+ import { PLATFORM_VERIFIERS } from "../attestation/verifier.js";
3
8
  import { authDatabase } from "../data/tables.js";
4
9
  import { correlation, emitDenied, emitDeviceRevoked, emitTokenRefresh, emitTokenReuseDetected } from "../audit/emit.js";
5
10
  import { deleteDevice, deviceSessionTokens, listDevices } from "../device/registry.js";
@@ -11,11 +16,13 @@ import { PROFILE_IMAGE_PATH } from "../profile/profile.js";
11
16
  import { collapseProviderRefusal } from "./providerRefusal.js";
12
17
  import { getAuthInstance, resolveDb } from "./resolve.js";
13
18
  import { userSessionTokens } from "../admin/users.js";
19
+ import { APPLE_APP_ATTESTATION_ROOT } from "../attestation/appAttest/root.js";
20
+ import { assertAttestationBlock, sendGate } from "../attestation/gate.js";
14
21
  import { lifecycleDeps } from "../lifecycle/request.js";
15
22
  import { deleteUser } from "../lifecycle/transitions.js";
16
23
  import { consumeSession, findConsumedToken, pruneConsumedTokens, recordConsumedToken, revokeFamily } from "../token/rotation.js";
17
- import { AccountDeleteResponse, HandoffExchangeResponse, MyDeviceRevokeResponse, MyDevicesResponse, TokenRotateResponse } from "./responses.js";
18
- import { DeleteAccountBody, HandoffExchangeBody, RevokeDeviceBody, SocialSignInStartQuery } from "./schemas.js";
24
+ import { AccountDeleteResponse, AppAttestKeyResponse, AttestationChallengeResponse, HandoffExchangeResponse, MyDeviceRevokeResponse, MyDevicesResponse, TokenRotateResponse } from "./responses.js";
25
+ import { AppAttestKeyBody, DeleteAccountBody, HandoffExchangeBody, RevokeDeviceBody, SocialSignInStartQuery } from "./schemas.js";
19
26
  import { accountDeletionView } from "./views.js";
20
27
  import { registerAuthAdminRoutes } from "./adminRoutes.js";
21
28
  import { guardErrorCallbackURL } from "./errorCallbackUrl.js";
@@ -29,6 +36,7 @@ import { validate } from "@pithy-sh/core/src/http/validation";
29
36
  import { STORED_IMAGE_HEADERS, storedImageBytes } from "@pithy-sh/core/src/image/storedImage";
30
37
  import { requireSameOrigin } from "@pithy-sh/core/src/http/sameOrigin";
31
38
  import { announceSessionRotated } from "@pithy-sh/core/src/session/rotated";
39
+ import { workerIdentity } from "@pithy-sh/core/src/worker/identity";
32
40
  import { turnstile } from "@pithy-sh/turnstile/src/http/middleware";
33
41
  //#region src/http/routes.ts
34
42
  /**
@@ -40,13 +48,15 @@ const BETTER_AUTH_ANSWER = {
40
48
  description: "Better Auth's own answer. See its endpoint reference.",
41
49
  contentType: "application/json"
42
50
  };
51
+ /** The routes that send a sign-in email, under `basePath`: the ones Turnstile and attestation gate. */
52
+ const SEND_ROUTES = ["/sign-in/magic-link", "/email-otp/send-verification-otp"];
43
53
  function db(c, wiring) {
44
54
  return authDatabase(resolveDb(c.env, wiring.config.database));
45
55
  }
46
56
  /**
47
57
  * Register the auth routes onto the backend's Hono app.
48
58
  *
49
- * Order matters: turnstile gates the human-initiated send routes (only when composed), Pithy's own
59
+ * Order matters: Turnstile and attestation gate the send routes ({@link SEND_ROUTES}), Pithy's own
50
60
  * routes are registered before the catch-all so they win, and Better Auth owns everything else under
51
61
  * `basePath`. A handler that returns a Response ends the chain, so the specific routes never fall
52
62
  * through to the catch-all. (The tier-1 edge rate limiter is contributed as capability *middleware*, so
@@ -57,6 +67,8 @@ function db(c, wiring) {
57
67
  * | Route | Verification | Input |
58
68
  * | -------------------------- | --------------- | --------------------------- |
59
69
  * | `POST /token/rotate` | bearer/session | none — the credential only |
70
+ * | `POST /attestation/challenge` | public | none |
71
+ * | `POST /attestation/ios/keys` | public | json `AppAttestKeyBody` |
60
72
  * | `GET /sign-in/social/start` | public | query `SocialSignInStartQuery` |
61
73
  * | `POST /handoff` | public | json `HandoffExchangeBody` |
62
74
  * | `GET /devices` | bearer/session | none |
@@ -79,16 +91,33 @@ function createAuthRoutes(wiring) {
79
91
  return (app) => {
80
92
  const base = wiring.config.basePath;
81
93
  const csrf = requireSameOrigin();
82
- if (wiring.turnstile) {
83
- const { mode, token } = wiring.turnstile;
84
- const guard = turnstile({
85
- mode,
86
- field: token.field,
87
- header: token.header,
88
- action: TURNSTILE_LOGIN_ACTION
89
- });
90
- app.use(`${base}/sign-in/magic-link`, guard);
91
- app.use(`${base}/email-otp/send-verification-otp`, guard);
94
+ const humanity = wiring.turnstile ? turnstile({
95
+ mode: wiring.turnstile.mode,
96
+ field: wiring.turnstile.token.field,
97
+ header: wiring.turnstile.token.header,
98
+ action: TURNSTILE_LOGIN_ACTION
99
+ }) : void 0;
100
+ const { attestation } = wiring.config;
101
+ const guard = attestationIsConfigured(attestation) ? sendGate({
102
+ attestation,
103
+ database: wiring.config.database,
104
+ verifiers: wiring.attestationVerifiers ?? PLATFORM_VERIFIERS,
105
+ turnstile: humanity
106
+ }) : humanity;
107
+ if (guard) for (const path of SEND_ROUTES) app.use(`${base}${path}`, guard);
108
+ if (attestationIsConfigured(attestation)) {
109
+ app.post(`${base}/attestation/challenge`, describeRoute({
110
+ summary: "Issue a single-use challenge for a native app attestation.",
111
+ description: "A native app asks for one before each send. It attests over SHA-256 of the challenge followed by the send's exact body, and sends the result in the `x-pithy-attestation` header: unpadded base64url over the JSON `{ platform, challenge, assertion, keyId? }`. The challenge is good once, pass or fail, until `expiresAt`. An environment with no attestation block answers `auth/attestation_config`.",
112
+ verification: ["public"],
113
+ responses: { 200: AttestationChallengeResponse }
114
+ }), (c) => issueAttestationChallenge(c, wiring));
115
+ app.post(`${base}/attestation/ios/keys`, describeRoute({
116
+ summary: "Register an iOS app's App Attest key, with Apple's attestation of it.",
117
+ description: "Once per key, before its first assertion. The app asks for a challenge, passes SHA-256 of its characters to `attestKey` as the client data hash, and sends the key id and the attestation object here. The certificate chain must lead to Apple App Attestation Root CA, the `rpIdHash` must be an allowed app's, and the key must be from Apple's production environment, or from either in dev, staging and a feature deployment. Then each send carries an assertion by this key in `x-pithy-attestation`. Any check that fails, a key already registered included, answers `auth/attestation_failed`; an environment with no attestation block answers `auth/attestation_config`.",
118
+ verification: ["public"],
119
+ responses: { 200: AppAttestKeyResponse }
120
+ }), validate("json", AppAttestKeyBody), (c) => registerIosKey(c, wiring, c.req.valid("json")));
92
121
  }
93
122
  app.post(`${base}/token/rotate`, describeRoute({
94
123
  summary: "Trade the current session token for its successor, and a JWT for services outside this Worker.",
@@ -190,9 +219,9 @@ function isSignInAttempt(path) {
190
219
  * (`better-call@1.4.0`, `dist/router.mjs:83-89`), which renders an `APIError` as a Response and returns
191
220
  * it. The throw is swallowed one frame later by the library that asked for it.
192
221
  *
193
- * So the `emitDenied` call this replaces — gated on catching an `APIError` — had never run once. No
194
- * failed one-time code, no bad magic link, no refused OAuth callback has ever reached
195
- * `pithy_audit_events`, which is the largest class of security event this capability has (#449).
222
+ * A refusal recorded by catching an `APIError` would therefore never be recorded: no failed one-time code,
223
+ * no bad magic link, no refused OAuth callback, which is the largest class of security event this
224
+ * capability has.
196
225
  *
197
226
  * **The body is cloned, never consumed.** The Response is handed back to the caller untouched: Better
198
227
  * Auth's own flat shape is a contract adopters read through `createAuthClient`, and the browser client
@@ -216,12 +245,11 @@ async function auditRefusal(c, response) {
216
245
  /**
217
246
  * Delegate to Better Auth's fetch handler, and record what it refused.
218
247
  *
219
- * **The answer is returned exactly as Better Auth wrote it.** Re-homing its flat `{ message, code }`
220
- * into the kit envelope was tried and taken back out: `packages/auth/README.md` documents
221
- * `createAuthClient` from `better-auth/client` as a first-class client surface (#271), and
222
- * `@better-fetch/fetch` builds its error as `{ ...parsedBody, status }` — so rewriting the body would
223
- * make `error.code` `undefined` for every adopter on the documented path. The wire is Better Auth's
224
- * contract. `readFailure` in `../client/api` learns to read it instead (#449).
248
+ * **The answer is returned exactly as Better Auth wrote it, never re-homed in the kit envelope.**
249
+ * `packages/auth/README.md` documents `createAuthClient` from `better-auth/client` as a first-class client
250
+ * surface, and `@better-fetch/fetch` builds its error as `{ ...parsedBody, status }`, so rewriting the body
251
+ * would make `error.code` `undefined` for every adopter on the documented path. The wire is Better Auth's
252
+ * contract, and `readFailure` in `../client/api` reads it.
225
253
  *
226
254
  * The `catch` covers what better-call genuinely hands on: a non-`APIError` throw from an endpoint
227
255
  * (`router.mjs:88`), and a throw from a plugin's `onRequest` hook, which runs outside the router's own
@@ -281,7 +309,7 @@ const ROTATION_REUSE_GRACE_MS = 3e4;
281
309
  * token + refresh token. This is the "refresh credential rotates on use" primitive Better Auth does not
282
310
  * provide natively.
283
311
  *
284
- * Two hardenings over a naive rotate (#59):
312
+ * Two hardenings over a naive rotate:
285
313
  * - **Reuse detection.** A presented token that no longer resolves to a live session but was previously
286
314
  * consumed is a replayed refresh token — the compromise signal for rotated refresh tokens
287
315
  * (RFC 6819 §5.2.2.3). The whole family is revoked and the attempt denied. (Covers the bearer refresh
@@ -382,7 +410,7 @@ async function listMyDevices(c, wiring) {
382
410
  return c.json({ devices: await listDevices(db(c, wiring), userId) });
383
411
  }
384
412
  /**
385
- * Delete the caller's own account (#622): soft, on the configured window, audited as `auth/user_self_deleted`
413
+ * Delete the caller's own account: soft, on the configured window, audited as `auth/user_self_deleted`
386
414
  * with them as the actor, and every session they hold ended after the columns are written — through Better
387
415
  * Auth's adapter, so `onSessionRevoked` hears each. No reason: a person leaving owes nobody one.
388
416
  */
@@ -463,5 +491,44 @@ async function serveMyImage(c, wiring) {
463
491
  ...STORED_IMAGE_HEADERS
464
492
  } });
465
493
  }
494
+ /**
495
+ * Verify an App Attest attestation against the environment's iOS apps and, when it holds, store the
496
+ * key so its later assertions verify. A failed attestation answers `auth/attestation_failed`.
497
+ */
498
+ async function registerIosKey(c, wiring, body) {
499
+ const environment = workerIdentity(c.env).environment;
500
+ const settings = assertAttestationBlock(wiring.config.attestation, environment);
501
+ const now = /* @__PURE__ */ new Date();
502
+ const verdict = await registerAppAttestKey({
503
+ db: db(c, wiring),
504
+ challenge: body.challenge,
505
+ keyId: body.keyId,
506
+ attestation: body.attestation,
507
+ apps: settings.ios,
508
+ environment,
509
+ root: wiring.appAttestRoot ?? APPLE_APP_ATTESTATION_ROOT,
510
+ now
511
+ });
512
+ if (!verdict.ok) throw new AttestationFailedError({ detail: verdict.reason });
513
+ c.header("cache-control", "no-store");
514
+ return c.json({
515
+ keyId: body.keyId,
516
+ registeredAt: now.toISOString()
517
+ });
518
+ }
519
+ /** Issue an attestation challenge, where this environment has a block to judge its use by. */
520
+ async function issueAttestationChallenge(c, wiring) {
521
+ const { attestation } = wiring.config;
522
+ assertAttestationBlock(attestation, workerIdentity(c.env).environment);
523
+ const issued = await issueChallenge(db(c, wiring), {
524
+ now: /* @__PURE__ */ new Date(),
525
+ expiresIn: attestation.challengeExpiresIn
526
+ });
527
+ c.header("cache-control", "no-store");
528
+ return c.json({
529
+ challenge: issued.challenge,
530
+ expiresAt: issued.expiresAt.toISOString()
531
+ });
532
+ }
466
533
  //#endregion
467
- export { createAuthRoutes };
534
+ export { SEND_ROUTES, createAuthRoutes };
@@ -33,6 +33,13 @@ export declare const HandoffExchangeBody: z.ZodObject<{
33
33
  verifier: z.ZodString;
34
34
  }, z.core.$strip>;
35
35
  export type HandoffExchangeBody = z.output<typeof HandoffExchangeBody>;
36
+ /** `POST {base}/attestation/ios/keys`: an App Attest key and Apple's attestation of it. */
37
+ export declare const AppAttestKeyBody: z.ZodObject<{
38
+ challenge: z.ZodString;
39
+ keyId: z.ZodString;
40
+ attestation: z.ZodString;
41
+ }, z.core.$strip>;
42
+ export type AppAttestKeyBody = z.output<typeof AppAttestKeyBody>;
36
43
  /** The providers a native app can sign in with through the system browser: every redirect provider auth offers. */
37
44
  export declare const RedirectProvider: z.ZodEnum<{
38
45
  apple: "apple";
@@ -1 +1 @@
1
- {"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../src/http/schemas.ts"],"names":[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,eAAe,CAAC,CAAC;AAE/D;;;;GAIG;AACH,eAAO,MAAM,cAAc;;kBAOoB,CAAC;AAChD,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,cAAc,CAAC,CAAC;AAE7D;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB;;iBAM+E,CAAC;AAC9G,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,iBAAiB,CAAC,CAAC"}
@@ -36,6 +36,12 @@ const HandoffExchangeBody = z.object({
36
36
  code: z.string().min(1).max(256).describe("The one-time code from the `code` parameter of the deep link the sign-in returned to."),
37
37
  verifier: z.string().min(1).max(256).describe("The random verifier the app made before the sign-in started: 43 to 128 characters from `A-Z a-z 0-9 - . _ ~`, as RFC 7636 shapes it. Its S256 digest is the `handoff_challenge` the sign-in's `callbackURL` carried.")
38
38
  }).describe("The code a native app trades for its session after a redirect sign-in, with the verifier that binds it.");
39
+ /** `POST {base}/attestation/ios/keys`: an App Attest key and Apple's attestation of it. */
40
+ const AppAttestKeyBody = z.object({
41
+ challenge: z.string().min(1).max(128).describe("A challenge from `POST {base}/attestation/challenge`. The app passes SHA-256 of its characters to `attestKey` as the client data hash. Spent by this request, pass or fail."),
42
+ keyId: z.string().min(1).max(256).describe("The key identifier `generateKey` returned, base64 as Apple hands it over."),
43
+ attestation: z.string().min(1).max(16384).describe("The attestation object `attestKey` returned, base64 as Apple hands it over.")
44
+ }).describe("A new App Attest key for this server to verify and register before the app makes assertions with it.");
39
45
  /** The providers a native app can sign in with through the system browser: every redirect provider auth offers. */
40
46
  const RedirectProvider = z.enum([
41
47
  "apple",
@@ -188,4 +194,4 @@ const ExportUserBody = z.object({ reason: LifecycleReason.describe("Why this per
188
194
  */
189
195
  const DeleteAccountBody = z.object({ confirm: z.literal(true).describe("Must be `true`. The person confirmed, in your app, that they want their account deleted.") }).describe("A self-service deletion: the person's own confirmation. Always soft, on the configured window.");
190
196
  //#endregion
191
- export { DeleteAccountBody, DeleteUserBody, DeletionMode, ExportUserBody, HandoffExchangeBody, ListDevicesQuery, ListUsersQuery, ListVerificationsQuery, RedirectProvider, ReinstateUserBody, RestoreUserBody, RevokeDeviceBody, RevokeSessionBody, SearchUsersBody, SocialSignInStartQuery, SuspendUserBody, UserIdParam };
197
+ export { AppAttestKeyBody, DeleteAccountBody, DeleteUserBody, DeletionMode, ExportUserBody, HandoffExchangeBody, ListDevicesQuery, ListUsersQuery, ListVerificationsQuery, RedirectProvider, ReinstateUserBody, RestoreUserBody, RevokeDeviceBody, RevokeSessionBody, SearchUsersBody, SocialSignInStartQuery, SuspendUserBody, UserIdParam };
package/dist/index.js CHANGED
@@ -1,9 +1,9 @@
1
1
  // SPDX-FileCopyrightText: 2026 Pithy
2
2
  // SPDX-License-Identifier: MIT
3
+ import { AUTH_APPLE_CREDENTIALS, AUTH_GOOGLE_CREDENTIALS, AUTH_SESSION_SECRET, AppleOAuthCredentials, GoogleOAuthCredentials, authSecretsRegistry } from "./instance/secrets.js";
3
4
  import { AuthAuditActions } from "./audit/actions.js";
4
5
  import { DevicePlatform } from "./data/device.js";
5
6
  import { authDatabase } from "./data/tables.js";
6
- import { AUTH_APPLE_CREDENTIALS, AUTH_GOOGLE_CREDENTIALS, AUTH_SESSION_SECRET, AppleOAuthCredentials, GoogleOAuthCredentials, authSecretsRegistry } from "./instance/secrets.js";
7
7
  import { DEVICE_HEADERS } from "./device/registry.js";
8
8
  import { requireAuth } from "./http/middleware.js";
9
9
  import { RecentSignInOptions, requireRecentSignIn } from "./http/recentSignIn.js";