@pithy-sh/auth 0.15.2 → 0.16.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 (169) 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 +40 -0
  63. package/dist/capability.d.ts.map +1 -1
  64. package/dist/capability.js +38 -5
  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 +18 -1
  80. package/dist/data/tables.d.ts.map +1 -1
  81. package/dist/data/tables.js +6 -2
  82. package/dist/http/devLoginRoute.js +3 -3
  83. package/dist/http/resolve.js +1 -1
  84. package/dist/http/responses.d.ts +12 -0
  85. package/dist/http/responses.d.ts.map +1 -1
  86. package/dist/http/responses.js +11 -1
  87. package/dist/http/routes.d.ts +5 -1
  88. package/dist/http/routes.d.ts.map +1 -1
  89. package/dist/http/routes.js +92 -25
  90. package/dist/http/schemas.d.ts +7 -0
  91. package/dist/http/schemas.d.ts.map +1 -1
  92. package/dist/http/schemas.js +7 -1
  93. package/dist/index.js +1 -1
  94. package/dist/instance/secrets.d.ts +86 -7
  95. package/dist/instance/secrets.d.ts.map +1 -1
  96. package/dist/instance/secrets.js +54 -8
  97. package/dist/migrations/0009_attestation_challenges.d.ts +9 -0
  98. package/dist/migrations/0009_attestation_challenges.d.ts.map +1 -0
  99. package/dist/migrations/0009_attestation_challenges.js +21 -0
  100. package/dist/migrations/0010_app_attest_keys.d.ts +9 -0
  101. package/dist/migrations/0010_app_attest_keys.d.ts.map +1 -0
  102. package/dist/migrations/0010_app_attest_keys.js +17 -0
  103. package/dist/migrations/set.d.ts +3 -1
  104. package/dist/migrations/set.d.ts.map +1 -1
  105. package/dist/migrations/set.js +6 -2
  106. package/dist/seeds/devSession.js +1 -1
  107. package/dist/test-utils/appAttestDevice.d.ts +92 -0
  108. package/dist/test-utils/appAttestDevice.d.ts.map +1 -0
  109. package/dist/test-utils/appAttestDevice.js +282 -0
  110. package/dist/test-utils/appAttestSample.d.ts +22 -0
  111. package/dist/test-utils/appAttestSample.d.ts.map +1 -0
  112. package/dist/test-utils/appAttestSample.js +24 -0
  113. package/dist/test-utils/googlePlay.d.ts +47 -0
  114. package/dist/test-utils/googlePlay.d.ts.map +1 -0
  115. package/dist/test-utils/googlePlay.js +117 -0
  116. package/dist/test-utils/liveApp.d.ts +76 -36
  117. package/dist/test-utils/liveApp.d.ts.map +1 -1
  118. package/dist/test-utils/liveApp.js +16 -5
  119. package/dist/test-utils/rollbackThrough.d.ts +11 -0
  120. package/dist/test-utils/rollbackThrough.d.ts.map +1 -0
  121. package/dist/test-utils/rollbackThrough.js +16 -0
  122. package/dist/test-utils/scopedBackend.d.ts +25 -0
  123. package/dist/test-utils/scopedBackend.d.ts.map +1 -1
  124. package/dist/test-utils/scopedBackend.js +1 -1
  125. package/dist/version.generated.d.ts +1 -1
  126. package/dist/version.generated.js +1 -1
  127. package/docs/attestation.md +173 -0
  128. package/package.json +5 -5
  129. package/pithy.manifest.json +14 -0
  130. package/src/attestation/appAttest/assertion.ts +65 -0
  131. package/src/attestation/appAttest/attestation.ts +159 -0
  132. package/src/attestation/appAttest/authData.ts +45 -0
  133. package/src/attestation/appAttest/base64.ts +29 -0
  134. package/src/attestation/appAttest/bytes.ts +18 -0
  135. package/src/attestation/appAttest/cbor.ts +116 -0
  136. package/src/attestation/appAttest/der.ts +126 -0
  137. package/src/attestation/appAttest/keys.ts +57 -0
  138. package/src/attestation/appAttest/root.ts +13 -0
  139. package/src/attestation/appAttest/verifier.ts +113 -0
  140. package/src/attestation/appAttest/x509.ts +209 -0
  141. package/src/attestation/challenge.ts +56 -0
  142. package/src/attestation/config.ts +118 -0
  143. package/src/attestation/errors.ts +60 -0
  144. package/src/attestation/gate.ts +105 -0
  145. package/src/attestation/playIntegrity/google.ts +239 -0
  146. package/src/attestation/playIntegrity/verdict.ts +149 -0
  147. package/src/attestation/playIntegrity/verifier.ts +77 -0
  148. package/src/attestation/verifier.ts +87 -0
  149. package/src/attestation/wire.ts +79 -0
  150. package/src/capability.ts +64 -8
  151. package/src/client/api.ts +73 -40
  152. package/src/client/attestation.ts +404 -0
  153. package/src/client/projection.ts +29 -4
  154. package/src/data/appAttestKey.ts +45 -0
  155. package/src/data/attestationChallenge.ts +23 -0
  156. package/src/data/tables.ts +5 -1
  157. package/src/http/responses.ts +22 -0
  158. package/src/http/routes.ts +128 -38
  159. package/src/http/schemas.ts +24 -0
  160. package/src/instance/secrets.ts +88 -9
  161. package/src/migrations/0009_attestation_challenges.ts +28 -0
  162. package/src/migrations/0010_app_attest_keys.ts +27 -0
  163. package/src/migrations/set.ts +5 -1
  164. package/src/test-utils/appAttestDevice.ts +399 -0
  165. package/src/test-utils/appAttestSample.ts +20 -0
  166. package/src/test-utils/googlePlay.ts +144 -0
  167. package/src/test-utils/liveApp.ts +31 -5
  168. package/src/test-utils/rollbackThrough.ts +24 -0
  169. package/src/version.generated.ts +1 -1
@@ -0,0 +1,321 @@
1
+ // SPDX-FileCopyrightText: 2026 Pithy
2
+ // SPDX-License-Identifier: MIT
3
+ import { AUTH_UNREADABLE, callAuth } from "./api.js";
4
+ //#region src/client/attestation.ts
5
+ /**
6
+ * A native app's attestation on the two send routes: a challenge from the Worker, the platform's assertion over
7
+ * that challenge and the send's exact body, and the one header that carries both.
8
+ *
9
+ * **The platform is an injected adapter.** {@link appAttestAttester} and {@link playIntegrityAttester} take
10
+ * `@expo/app-integrity`'s functions as a structural argument, so this package never depends on it: the scaffolded
11
+ * React Native app installs it and hands it in, and a web-only or server-only project installs nothing for this.
12
+ * {@link testAttester} sends the documented test assertion, for simulators, emulators and CI.
13
+ *
14
+ * Nothing here throws. A platform that will not attest, and a Worker that will not issue a challenge, are each an
15
+ * {@link AuthFailure}.
16
+ */
17
+ /** The request header the attestation travels in. The Worker's own name for it is in `../attestation/wire`. */
18
+ const ATTESTATION_HEADER = "x-pithy-attestation";
19
+ /** The assertion a `test` environment accepts in place of a real one. */
20
+ const ATTESTATION_TEST_ASSERTION = "pithy-test-attestation";
21
+ /** Where an App Attest key id is kept between launches, by default. */
22
+ const APP_ATTEST_KEY_STORAGE_KEY = "pithy.attestation.appAttestKey";
23
+ /** The platform would not attest: no App Attest on this device, Play services missing, or a key it refused. */
24
+ const ATTESTATION_UNAVAILABLE = {
25
+ code: "client/attestation_unavailable",
26
+ message: "This device couldn't prove it is running the app.",
27
+ action: "Try again. If it keeps happening, update the app or sign in on another device."
28
+ };
29
+ /**
30
+ * The Worker refused a call an attester made through its {@link AttestationTransport}. Thrown by an attester and
31
+ * answered by the send as {@link AttestationRefusedError.failure}, so a refused registration reaches the screen with
32
+ * the Worker's code rather than as {@link ATTESTATION_UNAVAILABLE}.
33
+ */
34
+ var AttestationRefusedError = class extends Error {
35
+ failure;
36
+ constructor(failure) {
37
+ super(failure.message);
38
+ this.name = "AttestationRefusedError";
39
+ this.failure = failure;
40
+ }
41
+ };
42
+ /** The test assertion from `platform`. A `test` environment accepts it; nothing else does. */
43
+ function testAttester(platform) {
44
+ return {
45
+ platform,
46
+ attest: async () => ({ assertion: ATTESTATION_TEST_ASSERTION })
47
+ };
48
+ }
49
+ /** A stored key id read back, or `null` when the value is not one this module wrote. */
50
+ function readKeyId(raw) {
51
+ if (raw === null) return null;
52
+ try {
53
+ const parsed = JSON.parse(raw);
54
+ if (typeof parsed !== "object" || parsed === null) return null;
55
+ const { keyId } = parsed;
56
+ return typeof keyId === "string" && keyId !== "" ? keyId : null;
57
+ } catch {
58
+ return null;
59
+ }
60
+ }
61
+ /**
62
+ * Apple App Attest.
63
+ *
64
+ * **A key is registered once, then asserts.** With no registered key, a send generates one, asks the Worker for a
65
+ * challenge, has Apple attest the key over it, and posts the attestation object to `/attestation/ios/keys`. The key
66
+ * is kept in `store`, the Keychain on a phone, only when that route answers success; a key it refused, or that never
67
+ * reached it, is never asserted with, and the next send registers another. Then that send, and every later one,
68
+ * asserts with the key over its own challenge and exact body.
69
+ *
70
+ * **A key that stops working is replaced.** A key the device can no longer assert with, which is what a Keychain
71
+ * entry outliving a reinstall or a restore leaves, is dropped and a new one registered on the same send, unless
72
+ * another send has registered one meanwhile, which this send then asserts with. A send the Worker refuses with
73
+ * `auth/attestation_failed` drops the key that send used, through {@link Attester.refused}, so the next send
74
+ * registers a new one; a refusal arriving after a newer key replaced it leaves the newer key alone.
75
+ *
76
+ * **Sends share their work.** The stored key id is read once per launch however many sends start together, and
77
+ * one registration at a time serves every send waiting on a key.
78
+ *
79
+ * **What the module is handed is what the Worker hashes.** `@expo/app-integrity` hashes the string it is handed into
80
+ * `clientDataHash`. Registration hands it the challenge alone, whose SHA-256 is the binding over the challenge and an
81
+ * empty body; an assertion hands it the challenge followed by the send's body, whose SHA-256 is the send's binding.
82
+ */
83
+ function appAttestAttester(input) {
84
+ const { module, store } = input;
85
+ const key = input.storageKey ?? "pithy.attestation.appAttestKey";
86
+ let held;
87
+ let loading = null;
88
+ let registering = null;
89
+ /** The key id in hand, read from `store` once. A key kept or forgotten while the read ran wins over it. */
90
+ function load() {
91
+ if (held !== void 0) return Promise.resolve(held);
92
+ loading ??= (async () => {
93
+ let read;
94
+ try {
95
+ read = readKeyId(await store.getItem(key));
96
+ } catch {
97
+ read = null;
98
+ }
99
+ if (held === void 0) held = read;
100
+ return held;
101
+ })();
102
+ return loading;
103
+ }
104
+ async function keep(keyId) {
105
+ held = keyId;
106
+ try {
107
+ await store.setItem(key, JSON.stringify({ keyId }));
108
+ } catch {}
109
+ }
110
+ async function forget() {
111
+ held = null;
112
+ try {
113
+ await store.deleteItem(key);
114
+ } catch {}
115
+ }
116
+ /** Generate a key, have Apple attest it over a fresh challenge, and register it. Kept only once registered. */
117
+ async function register(transport) {
118
+ const keyId = await module.generateKeyAsync();
119
+ const issued = await transport.challenge();
120
+ if (!issued.ok) throw new AttestationRefusedError(issued.failure);
121
+ const attestation = await module.attestKeyAsync(keyId, issued.value);
122
+ const registered = await transport.registerAppAttestKey({
123
+ challenge: issued.value,
124
+ keyId,
125
+ attestation
126
+ });
127
+ if (!registered.ok) throw new AttestationRefusedError(registered.failure);
128
+ await keep(keyId);
129
+ return keyId;
130
+ }
131
+ /** One registration at a time, so two sends at once register one key between them. */
132
+ function registerOnce(transport) {
133
+ registering ??= register(transport).finally(() => {
134
+ registering = null;
135
+ });
136
+ return registering;
137
+ }
138
+ return {
139
+ platform: "ios",
140
+ available: module.isSupported,
141
+ async attest(request, transport) {
142
+ const message = `${request.challenge}${request.body}`;
143
+ const tried = /* @__PURE__ */ new Set();
144
+ let current = await load();
145
+ while (current !== null && !tried.has(current)) {
146
+ tried.add(current);
147
+ try {
148
+ return {
149
+ assertion: await module.generateAssertionAsync(current, message),
150
+ keyId: current
151
+ };
152
+ } catch {
153
+ if (held === current) await forget();
154
+ }
155
+ current = held ?? null;
156
+ }
157
+ const keyId = await registerOnce(transport);
158
+ return {
159
+ assertion: await module.generateAssertionAsync(keyId, message),
160
+ keyId
161
+ };
162
+ },
163
+ async refused(proof) {
164
+ if (proof.keyId !== void 0 && proof.keyId === held) await forget();
165
+ }
166
+ };
167
+ }
168
+ /**
169
+ * Google Play Integrity, standard requests. The provider is prepared for the Google Cloud project the app is linked
170
+ * to in Play Console, and prepared again after any failure, since the module does not prepare an invalid provider
171
+ * again by itself; each send asks for a token whose `requestHash` is the binding's base64url. With no project
172
+ * number there is nothing to prepare, and {@link Attester.available} is `false`.
173
+ */
174
+ function playIntegrityAttester(input) {
175
+ const { module, cloudProjectNumber } = input;
176
+ let prepared = null;
177
+ const prepare = () => {
178
+ prepared ??= module.prepareIntegrityTokenProviderAsync(cloudProjectNumber ?? "").catch((failure) => {
179
+ prepared = null;
180
+ throw failure;
181
+ });
182
+ return prepared;
183
+ };
184
+ return {
185
+ platform: "android",
186
+ available: cloudProjectNumber !== null && cloudProjectNumber !== "",
187
+ async attest(request) {
188
+ await prepare();
189
+ try {
190
+ return { assertion: await module.requestIntegrityCheckAsync(base64Url(request.binding)) };
191
+ } catch (failure) {
192
+ prepared = null;
193
+ throw failure;
194
+ }
195
+ }
196
+ };
197
+ }
198
+ /** Unpadded base64url, the encoding the attestation header and Play Integrity's `requestHash` take. */
199
+ function base64Url(bytes) {
200
+ const alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
201
+ let out = "";
202
+ for (let at = 0; at < bytes.length; at += 3) {
203
+ const a = bytes[at] ?? 0;
204
+ const b = bytes[at + 1] ?? 0;
205
+ const c = bytes[at + 2] ?? 0;
206
+ const triple = a << 16 | b << 8 | c;
207
+ const chars = Math.min(4, Math.ceil((bytes.length - at) * 8 / 6));
208
+ for (let index = 0; index < chars; index += 1) out += alphabet[triple >> 18 - index * 6 & 63];
209
+ }
210
+ return out;
211
+ }
212
+ /** SHA-256 over Web Crypto, where the platform has it. React Native passes `expo-crypto`'s instead. */
213
+ async function webDigest(bytes) {
214
+ return new Uint8Array(await crypto.subtle.digest("SHA-256", bytes));
215
+ }
216
+ /** Whether a value is the challenge route's answer. */
217
+ function isChallenge(value) {
218
+ if (typeof value !== "object" || value === null) return false;
219
+ const { challenge } = value;
220
+ return typeof challenge === "string" && challenge !== "";
221
+ }
222
+ /** Whether a value is the key registration route's answer. */
223
+ function isRegistration(value) {
224
+ if (typeof value !== "object" || value === null) return false;
225
+ const { keyId } = value;
226
+ return typeof keyId === "string" && keyId !== "";
227
+ }
228
+ /** The Worker calls an attester makes, over `options`. */
229
+ function transportOver(options) {
230
+ const post = (body) => ({
231
+ method: "POST",
232
+ headers: { "content-type": "application/json" },
233
+ body: JSON.stringify(body)
234
+ });
235
+ return {
236
+ async challenge() {
237
+ const issued = await callAuth("/attestation/challenge", post({}), options, isChallenge);
238
+ return issued.ok ? {
239
+ ok: true,
240
+ value: issued.value.challenge
241
+ } : issued;
242
+ },
243
+ async registerAppAttestKey(input) {
244
+ const registered = await callAuth("/attestation/ios/keys", post(input), options, isRegistration);
245
+ if (!registered.ok) return registered;
246
+ return registered.value.keyId === input.keyId ? {
247
+ ok: true,
248
+ value: void 0
249
+ } : {
250
+ ok: false,
251
+ failure: AUTH_UNREADABLE
252
+ };
253
+ }
254
+ };
255
+ }
256
+ /**
257
+ * The attestation a gated send takes as `options.attestation`: one challenge per send, the attester's assertion
258
+ * over it and the body, and the header that carries them. `options` reaches the challenge route the way every
259
+ * other auth call does, so on a phone it is the bearer session's.
260
+ */
261
+ function createAttestation(input) {
262
+ const { attester, digest: _digest, attestation: _attestation, gate: _gate, ...options } = input;
263
+ const digest = input.digest ?? webDigest;
264
+ const transport = transportOver(options);
265
+ const proofs = /* @__PURE__ */ new WeakMap();
266
+ return {
267
+ async attest(body) {
268
+ const issued = await transport.challenge();
269
+ if (!issued.ok) return issued;
270
+ const challenge = issued.value;
271
+ const encoder = new TextEncoder();
272
+ const prefix = encoder.encode(challenge);
273
+ const bytes = encoder.encode(body);
274
+ const message = new Uint8Array(prefix.length + bytes.length);
275
+ message.set(prefix, 0);
276
+ message.set(bytes, prefix.length);
277
+ let proof;
278
+ try {
279
+ proof = await attester.attest({
280
+ challenge,
281
+ body,
282
+ binding: await digest(message)
283
+ }, transport);
284
+ } catch (failure) {
285
+ if (failure instanceof AttestationRefusedError) return {
286
+ ok: false,
287
+ failure: failure.failure
288
+ };
289
+ return {
290
+ ok: false,
291
+ failure: ATTESTATION_UNAVAILABLE
292
+ };
293
+ }
294
+ if (typeof proof.assertion !== "string" || proof.assertion === "") return {
295
+ ok: false,
296
+ failure: AUTH_UNREADABLE
297
+ };
298
+ const presented = {
299
+ platform: attester.platform,
300
+ challenge,
301
+ assertion: proof.assertion,
302
+ ...proof.keyId === void 0 ? {} : { keyId: proof.keyId }
303
+ };
304
+ const headers = { [ATTESTATION_HEADER]: base64Url(encoder.encode(JSON.stringify(presented))) };
305
+ proofs.set(headers, proof);
306
+ return {
307
+ ok: true,
308
+ value: headers
309
+ };
310
+ },
311
+ async refused(_failure, headers) {
312
+ const proof = proofs.get(headers);
313
+ if (proof === void 0) return;
314
+ try {
315
+ await attester.refused?.(proof);
316
+ } catch {}
317
+ }
318
+ };
319
+ }
320
+ //#endregion
321
+ export { APP_ATTEST_KEY_STORAGE_KEY, ATTESTATION_HEADER, ATTESTATION_TEST_ASSERTION, ATTESTATION_UNAVAILABLE, AttestationRefusedError, appAttestAttester, base64Url, createAttestation, playIntegrityAttester, testAttester };
@@ -16,7 +16,7 @@
16
16
  *
17
17
  * **This is the only statement of the shape.** `@pithy-sh/ui-react`'s `templates/client-env.d.ts` — the
18
18
  * ambient declaration `pithy ui add react` copies into an adopter's Worker — is generated from this type
19
- * by `@pithy-sh/vite`'s `clientEnvDeclaration.ts` (#398). The unions and the per-field doc comments below
19
+ * by `@pithy-sh/vite`'s `clientEnvDeclaration.ts`. The unions and the per-field doc comments below
20
20
  * are emitted verbatim, so what is written here is what a screen author reads.
21
21
  */
22
22
  export type AuthClientProjection = {
@@ -52,9 +52,8 @@ export type AuthClientProjection = {
52
52
  *
53
53
  * **A second fact from {@link signUpEnabled}, and the screen needs both.** That one answers for
54
54
  * magic link and OTP; this answers per provider. A project can let email create accounts while
55
- * GitHub only signs existing ones in — which is the configuration #554 exists for — and with only
56
- * the global flag a screen renders "Signing in creates one." directly beneath a button that will
57
- * refuse (#559).
55
+ * GitHub only signs existing ones in, and with only the global flag a screen would promise an
56
+ * account directly beneath a button that will refuse.
58
57
  *
59
58
  * Optional, so a screen copied before this landed keeps compiling and reads `undefined` as "no
60
59
  * provider objects" — the state every project was in until now.
@@ -75,5 +74,31 @@ export type AuthClientProjection = {
75
74
  otpLength: number;
76
75
  /** Whether signing in may provision a new user. Drives the sign-up copy. */
77
76
  signUpEnabled: boolean;
77
+ /**
78
+ * Native app attestation in this environment, when it has an attestation block. Absent, the send routes
79
+ * take no attestation, and a native app passes the humanity check as a web page does.
80
+ *
81
+ * Optional, so a screen copied before it existed keeps compiling.
82
+ */
83
+ attestation?: {
84
+ /**
85
+ * `test` where the Worker accepts the documented test assertion, so a simulator, an emulator or CI sends
86
+ * it; `enforce` where only a real App Attest or Play Integrity assertion passes.
87
+ */
88
+ mode: "enforce" | "test";
89
+ /**
90
+ * Whether a phone on each platform can pass by attesting here. Under `enforce`, `false` where the block
91
+ * allows no app for that platform or the Worker has no verifier for it, so that platform's phones pass the
92
+ * humanity check.
93
+ *
94
+ * Optional, so a screen copied before it existed keeps compiling; absent reads as both `true`.
95
+ */
96
+ platforms?: {
97
+ /** Whether an iPhone can pass with App Attest, or the test assertion. */
98
+ ios: boolean;
99
+ /** Whether an Android phone can pass with Play Integrity, or the test assertion. */
100
+ android: boolean;
101
+ };
102
+ };
78
103
  };
79
104
  //# sourceMappingURL=projection.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"projection.d.ts","sourceRoot":"","sources":["../../src/client/projection.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,MAAM,oBAAoB,GAC5B;IACE,mGAAmG;IACnG,OAAO,EAAE,KAAK,CAAC;CAChB,GACD;IACE,uCAAuC;IACvC,OAAO,EAAE,IAAI,CAAC;IACd,4DAA4D;IAC5D,QAAQ,EAAE,MAAM,CAAC;IACjB;;;;;;;OAOG;IACH,SAAS,EAAE;QACT,8CAA8C;QAC9C,MAAM,EAAE,OAAO,CAAC;QAChB,6CAA6C;QAC7C,KAAK,EAAE,OAAO,CAAC;QACf,gDAAgD;QAChD,QAAQ,EAAE,OAAO,CAAC;QAClB,8CAA8C;QAC9C,MAAM,EAAE,OAAO,CAAC;QAChB,iDAAiD;QACjD,SAAS,EAAE,OAAO,CAAC;KACpB,CAAC;IACF;;;;;;;;;;;OAWG;IACH,cAAc,CAAC,EAAE;QACf,sDAAsD;QACtD,MAAM,EAAE,OAAO,CAAC;QAChB,sDAAsD;QACtD,KAAK,EAAE,OAAO,CAAC;QACf,wDAAwD;QACxD,QAAQ,EAAE,OAAO,CAAC;QAClB,sDAAsD;QACtD,MAAM,EAAE,OAAO,CAAC;QAChB,yDAAyD;QACzD,SAAS,EAAE,OAAO,CAAC;KACpB,CAAC;IACF,4CAA4C;IAC5C,SAAS,EAAE,MAAM,CAAC;IAClB,4EAA4E;IAC5E,aAAa,EAAE,OAAO,CAAC;CACxB,CAAC"}
1
+ {"version":3,"file":"projection.d.ts","sourceRoot":"","sources":["../../src/client/projection.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,MAAM,oBAAoB,GAC5B;IACE,mGAAmG;IACnG,OAAO,EAAE,KAAK,CAAC;CAChB,GACD;IACE,uCAAuC;IACvC,OAAO,EAAE,IAAI,CAAC;IACd,4DAA4D;IAC5D,QAAQ,EAAE,MAAM,CAAC;IACjB;;;;;;;OAOG;IACH,SAAS,EAAE;QACT,8CAA8C;QAC9C,MAAM,EAAE,OAAO,CAAC;QAChB,6CAA6C;QAC7C,KAAK,EAAE,OAAO,CAAC;QACf,gDAAgD;QAChD,QAAQ,EAAE,OAAO,CAAC;QAClB,8CAA8C;QAC9C,MAAM,EAAE,OAAO,CAAC;QAChB,iDAAiD;QACjD,SAAS,EAAE,OAAO,CAAC;KACpB,CAAC;IACF;;;;;;;;;;OAUG;IACH,cAAc,CAAC,EAAE;QACf,sDAAsD;QACtD,MAAM,EAAE,OAAO,CAAC;QAChB,sDAAsD;QACtD,KAAK,EAAE,OAAO,CAAC;QACf,wDAAwD;QACxD,QAAQ,EAAE,OAAO,CAAC;QAClB,sDAAsD;QACtD,MAAM,EAAE,OAAO,CAAC;QAChB,yDAAyD;QACzD,SAAS,EAAE,OAAO,CAAC;KACpB,CAAC;IACF,4CAA4C;IAC5C,SAAS,EAAE,MAAM,CAAC;IAClB,4EAA4E;IAC5E,aAAa,EAAE,OAAO,CAAC;IACvB;;;;;OAKG;IACH,WAAW,CAAC,EAAE;QACZ;;;WAGG;QACH,IAAI,EAAE,SAAS,GAAG,MAAM,CAAC;QACzB;;;;;;WAMG;QACH,SAAS,CAAC,EAAE;YACV,yEAAyE;YACzE,GAAG,EAAE,OAAO,CAAC;YACb,oFAAoF;YACpF,OAAO,EAAE,OAAO,CAAC;SAClB,CAAC;KACH,CAAC;CACH,CAAC"}
@@ -0,0 +1,30 @@
1
+ // SPDX-FileCopyrightText: 2026 Pithy
2
+ // SPDX-License-Identifier: MIT
3
+ import { z } from "zod";
4
+ /** The App Attest environment a key was attested in, as its AAGUID names it. */
5
+ export declare const AppAttestEnvironment: z.ZodEnum<{
6
+ development: "development";
7
+ production: "production";
8
+ }>;
9
+ export type AppAttestEnvironment = z.output<typeof AppAttestEnvironment>;
10
+ /**
11
+ * `pithy_auth_app_attest_keys`: an App Attest key an iOS app registered with an attestation Apple signed.
12
+ *
13
+ * One row per key, written once by the key route and then only its counter and last use, by each assertion that
14
+ * verifies (`../attestation/appAttest/keys.ts`). A key belongs to one install of the app, not to a person: it is
15
+ * registered before anybody signs in, and names no user.
16
+ */
17
+ export declare const AppAttestKey: z.ZodObject<{
18
+ id: z.ZodString;
19
+ publicKey: z.ZodString;
20
+ appId: z.ZodString;
21
+ environment: z.ZodEnum<{
22
+ development: "development";
23
+ production: "production";
24
+ }>;
25
+ counter: z.ZodNumber;
26
+ createdAt: z.ZodCodec<z.ZodUnion<readonly [z.ZodNumber, z.ZodString, z.ZodDate]>, z.ZodDate>;
27
+ lastUsedAt: z.ZodNullable<z.ZodCodec<z.ZodUnion<readonly [z.ZodNumber, z.ZodString, z.ZodDate]>, z.ZodDate>>;
28
+ }, z.core.$strip>;
29
+ export type AppAttestKey = z.output<typeof AppAttestKey>;
30
+ //# sourceMappingURL=appAttestKey.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"appAttestKey.d.ts","sourceRoot":"","sources":["../../src/data/appAttestKey.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,gFAAgF;AAChF,eAAO,MAAM,oBAAoB;;;EAI9B,CAAC;AACJ,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAEzE;;;;;;GAMG;AACH,eAAO,MAAM,YAAY;;;;;;;;;;;iBAsBkD,CAAC;AAC5E,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,YAAY,CAAC,CAAC"}
@@ -0,0 +1,25 @@
1
+ // SPDX-FileCopyrightText: 2026 Pithy
2
+ // SPDX-License-Identifier: MIT
3
+ import { z } from "zod";
4
+ import { SQLiteDate } from "@pithy-sh/core/src/data/codecs";
5
+ //#region src/data/appAttestKey.ts
6
+ /** The App Attest environment a key was attested in, as its AAGUID names it. */
7
+ const AppAttestEnvironment = z.enum(["production", "development"]).describe("The App Attest environment a key was attested in: `production` for TestFlight and App Store builds, `development` for a build carrying the development App Attest entitlement.");
8
+ /**
9
+ * `pithy_auth_app_attest_keys`: an App Attest key an iOS app registered with an attestation Apple signed.
10
+ *
11
+ * One row per key, written once by the key route and then only its counter and last use, by each assertion that
12
+ * verifies (`../attestation/appAttest/keys.ts`). A key belongs to one install of the app, not to a person: it is
13
+ * registered before anybody signs in, and names no user.
14
+ */
15
+ const AppAttestKey = z.object({
16
+ id: z.string().describe("Primary key: the App Attest key id, unpadded base64url of its 32 bytes, SHA-256 of `publicKey`."),
17
+ publicKey: z.string().describe("The key's P-256 public key, an X9.62 uncompressed point, unpadded base64url. Assertions verify with it."),
18
+ appId: z.string().describe("The App ID the key was attested for: `<TeamID>.<bundleId>`."),
19
+ environment: AppAttestEnvironment,
20
+ counter: z.number().int().nonnegative().describe("The counter of the last assertion accepted, 0 at registration. Each assertion must exceed it."),
21
+ createdAt: SQLiteDate.describe("When the key was registered. Ms-epoch in SQLite."),
22
+ lastUsedAt: SQLiteDate.nullable().describe("When an assertion by this key last verified, or null before the first. Ms-epoch in SQLite.")
23
+ }).describe("A registered App Attest key in `pithy_auth_app_attest_keys`.");
24
+ //#endregion
25
+ export { AppAttestEnvironment, AppAttestKey };
@@ -0,0 +1,17 @@
1
+ // SPDX-FileCopyrightText: 2026 Pithy
2
+ // SPDX-License-Identifier: MIT
3
+ import { z } from "zod";
4
+ /**
5
+ * `pithy_auth_attestation_challenges`: a challenge the challenge route issued and nobody has presented yet.
6
+ *
7
+ * Keyed by the challenge's SHA-256, so a read of the table hands nobody a usable challenge. A row is deleted
8
+ * when its challenge is presented, pass or fail, which is what makes a challenge single-use, and issuing deletes
9
+ * the rows that ran out unpresented (`../attestation/challenge.ts`). It names no person and no device.
10
+ */
11
+ export declare const AttestationChallenge: z.ZodObject<{
12
+ id: z.ZodString;
13
+ issuedAt: z.ZodCodec<z.ZodUnion<readonly [z.ZodNumber, z.ZodString, z.ZodDate]>, z.ZodDate>;
14
+ expiresAt: z.ZodCodec<z.ZodUnion<readonly [z.ZodNumber, z.ZodString, z.ZodDate]>, z.ZodDate>;
15
+ }, z.core.$strip>;
16
+ export type AttestationChallenge = z.output<typeof AttestationChallenge>;
17
+ //# sourceMappingURL=attestationChallenge.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"attestationChallenge.d.ts","sourceRoot":"","sources":["../../src/data/attestationChallenge.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB;;;;iBAQkE,CAAC;AACpG,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,oBAAoB,CAAC,CAAC"}
@@ -0,0 +1,19 @@
1
+ // SPDX-FileCopyrightText: 2026 Pithy
2
+ // SPDX-License-Identifier: MIT
3
+ import { z } from "zod";
4
+ import { SQLiteDate } from "@pithy-sh/core/src/data/codecs";
5
+ //#region src/data/attestationChallenge.ts
6
+ /**
7
+ * `pithy_auth_attestation_challenges`: a challenge the challenge route issued and nobody has presented yet.
8
+ *
9
+ * Keyed by the challenge's SHA-256, so a read of the table hands nobody a usable challenge. A row is deleted
10
+ * when its challenge is presented, pass or fail, which is what makes a challenge single-use, and issuing deletes
11
+ * the rows that ran out unpresented (`../attestation/challenge.ts`). It names no person and no device.
12
+ */
13
+ const AttestationChallenge = z.object({
14
+ id: z.string().describe("Primary key: the unpadded base64url SHA-256 of the challenge. The challenge itself is never stored."),
15
+ issuedAt: SQLiteDate.describe("When the challenge was issued. Ms-epoch in SQLite."),
16
+ expiresAt: SQLiteDate.describe("When the challenge stops being accepted. Ms-epoch in SQLite. Indexed.")
17
+ }).describe("An issued, unpresented attestation challenge in `pithy_auth_attestation_challenges`.");
18
+ //#endregion
19
+ export { AttestationChallenge };
@@ -9,7 +9,7 @@ import type { Kysely } from "kysely";
9
9
  * (whose Kysely adapter wraps this same Kysely), the device registry, and the migration.
10
10
  *
11
11
  * The first six tables are Better-Auth-managed; `pithyAuthDevices`, `pithyAuthRotatedTokens`,
12
- * `pithyAuthUserLifecycle` and `pithyAuthVerificationOutcomes` are ours. Setting Better Auth's `modelName` to these exact camelCase keys lets the one `CamelCasePlugin`
12
+ * `pithyAuthUserLifecycle`, `pithyAuthVerificationOutcomes`, `pithyAuthAttestationChallenges` and `pithyAuthAppAttestKeys` are ours. Setting Better Auth's `modelName` to these exact camelCase keys lets the one `CamelCasePlugin`
13
13
  * own the camelCase ↔ snake_case boundary uniformly for both Better Auth's queries and our migration DDL.
14
14
  */
15
15
  export declare const authTables: {
@@ -146,6 +146,23 @@ export declare const authTables: {
146
146
  expiresAt: import("zod").ZodCodec<import("zod").ZodUnion<readonly [import("zod").ZodNumber, import("zod").ZodString, import("zod").ZodDate]>, import("zod").ZodDate>;
147
147
  usedAt: import("zod").ZodNullable<import("zod").ZodCodec<import("zod").ZodUnion<readonly [import("zod").ZodNumber, import("zod").ZodString, import("zod").ZodDate]>, import("zod").ZodDate>>;
148
148
  }, import("zod/v4/core").$strip>;
149
+ pithyAuthAttestationChallenges: import("zod").ZodObject<{
150
+ id: import("zod").ZodString;
151
+ issuedAt: import("zod").ZodCodec<import("zod").ZodUnion<readonly [import("zod").ZodNumber, import("zod").ZodString, import("zod").ZodDate]>, import("zod").ZodDate>;
152
+ expiresAt: import("zod").ZodCodec<import("zod").ZodUnion<readonly [import("zod").ZodNumber, import("zod").ZodString, import("zod").ZodDate]>, import("zod").ZodDate>;
153
+ }, import("zod/v4/core").$strip>;
154
+ pithyAuthAppAttestKeys: import("zod").ZodObject<{
155
+ id: import("zod").ZodString;
156
+ publicKey: import("zod").ZodString;
157
+ appId: import("zod").ZodString;
158
+ environment: import("zod").ZodEnum<{
159
+ development: "development";
160
+ production: "production";
161
+ }>;
162
+ counter: import("zod").ZodNumber;
163
+ createdAt: import("zod").ZodCodec<import("zod").ZodUnion<readonly [import("zod").ZodNumber, import("zod").ZodString, import("zod").ZodDate]>, import("zod").ZodDate>;
164
+ lastUsedAt: import("zod").ZodNullable<import("zod").ZodCodec<import("zod").ZodUnion<readonly [import("zod").ZodNumber, import("zod").ZodString, import("zod").ZodDate]>, import("zod").ZodDate>>;
165
+ }, import("zod/v4/core").$strip>;
149
166
  };
150
167
  export type AuthTables = typeof authTables;
151
168
  /** The typed Kysely view over the auth tables — shared by the Better-Auth adapter and the device registry. */
@@ -1 +1 @@
1
- {"version":3,"file":"tables.d.ts","sourceRoot":"","sources":["../../src/data/tables.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAkB,KAAK,cAAc,EAAE,MAAM,4BAA4B,CAAC;AACjF,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAOrC;;;;;;;;GAQG;AACH,eAAO,MAAM,UAAU;IACrB,cAAc;;;;;;;;;;;;;;;IACd,iBAAiB;;;;;;;;;;;;;IACjB,iBAAiB;;;;;;;;;;;;;;;;IACjB,sBAAsB;;;;;;;;IACtB,aAAa;;;;;;;;;IACb,kBAAkB;;;;;;IAClB,gBAAgB;;;;;;;;;;;;;;;;;IAChB,sBAAsB;;;;;;IACtB,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IACtB,6BAA6B;;;;;;;;;;;;;CAC9B,CAAC;AACF,MAAM,MAAM,UAAU,GAAG,OAAO,UAAU,CAAC;AAE3C,8GAA8G;AAC9G,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC,CAAC;AAE9D,yGAAyG;AACzG,wBAAgB,YAAY,CAAC,EAAE,EAAE,UAAU,GAAG,YAAY,CAEzD"}
1
+ {"version":3,"file":"tables.d.ts","sourceRoot":"","sources":["../../src/data/tables.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAkB,KAAK,cAAc,EAAE,MAAM,4BAA4B,CAAC;AACjF,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AASrC;;;;;;;;GAQG;AACH,eAAO,MAAM,UAAU;IACrB,cAAc;;;;;;;;;;;;;;;IACd,iBAAiB;;;;;;;;;;;;;IACjB,iBAAiB;;;;;;;;;;;;;;;;IACjB,sBAAsB;;;;;;;;IACtB,aAAa;;;;;;;;;IACb,kBAAkB;;;;;;IAClB,gBAAgB;;;;;;;;;;;;;;;;;IAChB,sBAAsB;;;;;;IACtB,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IACtB,6BAA6B;;;;;;;;;;;;;IAC7B,8BAA8B;;;;;IAC9B,sBAAsB;;;;;;;;;;;;CACvB,CAAC;AACF,MAAM,MAAM,UAAU,GAAG,OAAO,UAAU,CAAC;AAE3C,8GAA8G;AAC9G,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC,CAAC;AAE9D,yGAAyG;AACzG,wBAAgB,YAAY,CAAC,EAAE,EAAE,UAAU,GAAG,YAAY,CAEzD"}
@@ -1,5 +1,7 @@
1
1
  // SPDX-FileCopyrightText: 2026 Pithy
2
2
  // SPDX-License-Identifier: MIT
3
+ import { AttestationChallenge } from "./attestationChallenge.js";
4
+ import { AppAttestKey } from "./appAttestKey.js";
3
5
  import { Account, Jwks, RateLimit, Session, User, Verification } from "./betterAuth.js";
4
6
  import { Device } from "./device.js";
5
7
  import { RotatedToken } from "./rotatedToken.js";
@@ -13,7 +15,7 @@ import { createDatabase } from "@pithy-sh/core/src/data/db";
13
15
  * (whose Kysely adapter wraps this same Kysely), the device registry, and the migration.
14
16
  *
15
17
  * The first six tables are Better-Auth-managed; `pithyAuthDevices`, `pithyAuthRotatedTokens`,
16
- * `pithyAuthUserLifecycle` and `pithyAuthVerificationOutcomes` are ours. Setting Better Auth's `modelName` to these exact camelCase keys lets the one `CamelCasePlugin`
18
+ * `pithyAuthUserLifecycle`, `pithyAuthVerificationOutcomes`, `pithyAuthAttestationChallenges` and `pithyAuthAppAttestKeys` are ours. Setting Better Auth's `modelName` to these exact camelCase keys lets the one `CamelCasePlugin`
17
19
  * own the camelCase ↔ snake_case boundary uniformly for both Better Auth's queries and our migration DDL.
18
20
  */
19
21
  const authTables = {
@@ -26,7 +28,9 @@ const authTables = {
26
28
  pithyAuthDevices: Device,
27
29
  pithyAuthRotatedTokens: RotatedToken,
28
30
  pithyAuthUserLifecycle: UserLifecycleEvent,
29
- pithyAuthVerificationOutcomes: VerificationOutcome
31
+ pithyAuthVerificationOutcomes: VerificationOutcome,
32
+ pithyAuthAttestationChallenges: AttestationChallenge,
33
+ pithyAuthAppAttestKeys: AppAttestKey
30
34
  };
31
35
  /** Build the auth Kysely over a D1 binding. Carries `CamelCasePlugin`, so query code stays camelCase. */
32
36
  function authDatabase(d1) {
@@ -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,8 +1,8 @@
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
7
  import { resolveProvider } from "../instance/providers.js";
8
8
  import { makeAuth } from "../instance/auth.js";
@@ -470,6 +470,18 @@ export declare const HandoffExchangeResponse: z.ZodObject<{
470
470
  expiresAt: z.ZodISODateTime;
471
471
  }, z.core.$strip>;
472
472
  export type HandoffExchangeResponse = z.output<typeof HandoffExchangeResponse>;
473
+ /** `POST {base}/attestation/challenge`. */
474
+ export declare const AttestationChallengeResponse: z.ZodObject<{
475
+ challenge: z.ZodString;
476
+ expiresAt: z.ZodISODateTime;
477
+ }, z.core.$strip>;
478
+ export type AttestationChallengeResponse = z.output<typeof AttestationChallengeResponse>;
479
+ /** `POST {base}/attestation/ios/keys`. */
480
+ export declare const AppAttestKeyResponse: z.ZodObject<{
481
+ keyId: z.ZodString;
482
+ registeredAt: z.ZodISODateTime;
483
+ }, z.core.$strip>;
484
+ export type AppAttestKeyResponse = z.output<typeof AppAttestKeyResponse>;
473
485
  /** One of the caller's own registered devices. */
474
486
  export declare const MyDeviceView: z.ZodObject<{
475
487
  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;;;;;;;;;;;;;;;;;;;iBAKQ,CAAC;AACxC,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAoDrE,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAY3B,CAAC;AACJ,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,MAAM,CA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