@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
package/README.md CHANGED
@@ -70,6 +70,10 @@ An account can be suspended or deleted, and the kit refuses it at every door. An
70
70
 
71
71
  **Every purge can be proved.** The purge records an audit event per step and on completion, and names the step it stopped at when it gives up. `GET /control-plane/erasure/user/:userId`, under `erasure:read`, attests one account's erasure from that record: when it was deleted, by which kind of actor and why, soft or hard, each step erased or kept with its reason, the purge's state, and the audit event behind each step by id and chain position. `GET /control-plane/erasure?since&until` counts every purge in a period and names each failed or overdue one. Nothing about the person crosses but the id. [`docs/CONTROL-PLANE.md` §12](../../docs/CONTROL-PLANE.md#erasure) has the shape.
72
72
 
73
+ ## Native app attestation
74
+
75
+ A native app has no Turnstile widget, so auth's send routes take an Apple App Attest or Google Play Integrity attestation in its place. **Either passes**: a request carrying an attestation in the `x-pithy-attestation` header is judged by attestation alone, and a failure is final; a request without one goes to Turnstile when turnstile is composed, and is refused with `auth/attestation_missing` when it is not and the environment has a block. Configure it per environment on `auth({ attestation: { environments: { prod: { mode: "enforce", ios: [{ teamId, bundleId }], android: [{ packageName }] } } } })`. The app asks `POST /auth/attestation/challenge` for a single-use challenge and attests over SHA-256 of the challenge followed by the request body. An iOS app registers each App Attest key once at `POST /auth/attestation/ios/keys`; auth checks Apple's certificate chain against the pinned App Attestation root, stores the key, and from then on verifies each assertion's signature and requires its counter to rise. An environment set to `test` also accepts the documented test assertion, `pithy-test-attestation`, so simulators, emulators and CI get through; a Worker accepts it only where its `ENVIRONMENT` is `dev`, `staging` or `feature`, whatever the config says, `pithy doctor` reports a production environment set to `test`, and `pithy deploy` refuses one. An Android app sends a Play Integrity token whose `requestHash` is the unpadded base64url of that digest; the Worker decodes it through Google with the service account stored as `auth-play-integrity-service-account`, and requires the package, `PLAY_RECOGNIZED`, `MEETS_DEVICE_INTEGRITY` and a fresh timestamp. A refusal is `auth/attestation_missing` (400), `auth/attestation_failed` (403: a stale, reused or unknown challenge, an App Attest key that does not register, or an assertion or verdict that does not verify) or `auth/attestation_config` (500: the server cannot judge it, including a missing service account or Google refusing it), each with the reason in `detail`. No new dependency: verification runs on WebCrypto. The client in `src/client/attestation` registers an iOS key and asserts with it, requests a Play Integrity token on Android, and takes the platform as an injected adapter, so `@expo/app-integrity` is the app's dependency and never this package's. [`docs/attestation.md`](docs/attestation.md) has the config, where to find the Team ID, bundle id and package name, how to create and link the service account, the wire format, the client, test mode and the codes.
76
+
73
77
  ## Verification ledger
74
78
 
75
79
  Every sign-in link and code auth sends is recorded in `pithy_auth_verification_outcomes`: its type (`magic_link` or `otp`), the verification row that carries it, the account it signs in to, the `pithy_email_jobs` id of the mail that carried it, and when it was issued, expires and was used. Never the token, never the address. Better Auth deletes a verification on its first use, so without this a used link leaves nothing behind and an unused one looks like one still waiting. A sign-up has no account when its link is sent: its row joins to its mail by the job id, and gains the account when the link is used. The row is written when the email seam answers, so a withheld mail is recorded with its suppressed job and a failed one with none, and it is stamped when the link or code creates a session. A wrong code moves the row with it, so the right one entered next still stamps it. A management client reads it through `GET /auth/admin/verifications`, under `auth:verifications:read`: over `since`/`until` (the last 30 days by default), the counts by type of issued, used, expired unused and still pending, and the rows, newest first and paged, narrowed by `type` or `state` if asked. Join `emailJobId` to `email:jobs:read` and `email:suppressions:read` to see which sign-ins failed because the mail did not land. The purge erases an account's rows with the rest of it, and the export carries them.
@@ -0,0 +1,32 @@
1
+ // SPDX-FileCopyrightText: 2026 Pithy
2
+ // SPDX-License-Identifier: MIT
3
+ /** The checks an assertion can fail, each named in the refusal's `detail`. */
4
+ export type AppAttestAssertionCheck = "format" | "rpIdHash" | "signature" | "counter";
5
+ /** What {@link verifyAppAttestAssertion} judges. */
6
+ export interface AppAttestAssertionInput {
7
+ /** The assertion, decoded from the base64 `generateAssertion` hands over. */
8
+ assertion: Uint8Array;
9
+ /** The registered key's P-256 public point. */
10
+ publicKey: Uint8Array;
11
+ /** The App ID the key was registered for. */
12
+ appId: string;
13
+ /** What the app passed to `generateAssertion`. */
14
+ clientDataHash: Uint8Array;
15
+ /** The counter stored from the key's last accepted assertion, or 0 after registration. */
16
+ counter: number;
17
+ }
18
+ export type AppAttestAssertionResult = {
19
+ ok: true;
20
+ counter: number;
21
+ } | {
22
+ ok: false;
23
+ check: AppAttestAssertionCheck;
24
+ reason: string;
25
+ };
26
+ /**
27
+ * Verify an App Attest assertion, Apple's way: the signature is the key's ECDSA P-256 SHA-256 signature over
28
+ * SHA-256 of the authenticator data and the client data hash, the `rpIdHash` is the key's app's, and the counter is
29
+ * above the stored one. Answers the new counter, which the caller stores only if it is still above the stored one.
30
+ */
31
+ export declare function verifyAppAttestAssertion(input: AppAttestAssertionInput): Promise<AppAttestAssertionResult>;
32
+ //# sourceMappingURL=assertion.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assertion.d.ts","sourceRoot":"","sources":["../../../src/attestation/appAttest/assertion.ts"],"names":[],"mappings":"AAQA,8EAA8E;AAC9E,MAAM,MAAM,uBAAuB,GAAG,QAAQ,GAAG,UAAU,GAAG,WAAW,GAAG,SAAS,CAAC;AAEtF,oDAAoD;AACpD,MAAM,WAAW,uBAAuB;IACtC,6EAA6E;IAC7E,SAAS,EAAE,UAAU,CAAC;IACtB,+CAA+C;IAC/C,SAAS,EAAE,UAAU,CAAC;IACtB,6CAA6C;IAC7C,KAAK,EAAE,MAAM,CAAC;IACd,kDAAkD;IAClD,cAAc,EAAE,UAAU,CAAC;IAC3B,0FAA0F;IAC1F,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,MAAM,wBAAwB,GAChC;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GAC7B;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,uBAAuB,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAElE;;;;GAIG;AACH,wBAAsB,wBAAwB,CAAC,KAAK,EAAE,uBAAuB,GAAG,OAAO,CAAC,wBAAwB,CAAC,CA8BhH"}
@@ -0,0 +1,59 @@
1
+ // SPDX-FileCopyrightText: 2026 Pithy
2
+ // SPDX-License-Identifier: MIT
3
+ import { readAuthenticatorData } from "./authData.js";
4
+ import { equalBytes, sha256 } from "./bytes.js";
5
+ import { CborError, cborBytes, decodeCbor } from "./cbor.js";
6
+ import { verifyEcdsa } from "./x509.js";
7
+ //#region src/attestation/appAttest/assertion.ts
8
+ /**
9
+ * Verify an App Attest assertion, Apple's way: the signature is the key's ECDSA P-256 SHA-256 signature over
10
+ * SHA-256 of the authenticator data and the client data hash, the `rpIdHash` is the key's app's, and the counter is
11
+ * above the stored one. Answers the new counter, which the caller stores only if it is still above the stored one.
12
+ */
13
+ async function verifyAppAttestAssertion(input) {
14
+ let signature;
15
+ let authenticatorData;
16
+ try {
17
+ const decoded = decodeCbor(input.assertion);
18
+ signature = cborBytes(decoded, "signature");
19
+ authenticatorData = cborBytes(decoded, "authenticatorData");
20
+ } catch (cause) {
21
+ if (!(cause instanceof CborError)) throw cause;
22
+ return {
23
+ ok: false,
24
+ check: "format",
25
+ reason: `the assertion is not CBOR: ${cause.message}`
26
+ };
27
+ }
28
+ const data = authenticatorData === void 0 ? void 0 : readAuthenticatorData(authenticatorData);
29
+ if (signature === void 0 || authenticatorData === void 0 || data === void 0) return {
30
+ ok: false,
31
+ check: "format",
32
+ reason: "the assertion lacks a signature or authenticator data"
33
+ };
34
+ if (!equalBytes(data.rpIdHash, await sha256(new TextEncoder().encode(input.appId)))) return {
35
+ ok: false,
36
+ check: "rpIdHash",
37
+ reason: `the rpIdHash is not SHA-256 of ${input.appId}`
38
+ };
39
+ const nonce = await sha256(authenticatorData, input.clientDataHash);
40
+ if (!await verifyEcdsa({
41
+ curve: "P-256",
42
+ point: input.publicKey
43
+ }, "SHA-256", signature, nonce)) return {
44
+ ok: false,
45
+ check: "signature",
46
+ reason: "the signature does not verify with the registered key"
47
+ };
48
+ if (data.counter <= input.counter) return {
49
+ ok: false,
50
+ check: "counter",
51
+ reason: `the counter ${data.counter} does not increase on the stored ${input.counter}`
52
+ };
53
+ return {
54
+ ok: true,
55
+ counter: data.counter
56
+ };
57
+ }
58
+ //#endregion
59
+ export { verifyAppAttestAssertion };
@@ -0,0 +1,49 @@
1
+ // SPDX-FileCopyrightText: 2026 Pithy
2
+ // SPDX-License-Identifier: MIT
3
+ import type { AppleAppIdentity } from "../config";
4
+ /** The App Attest environment an AAGUID names. */
5
+ export type AppAttestEnvironment = "production" | "development";
6
+ /** The checks an attestation can fail, each named in the refusal's `detail`. */
7
+ export type AppAttestationCheck = "format" | "chain" | "nonce" | "keyId" | "rpIdHash" | "counter" | "aaguid" | "credentialId";
8
+ /** A key an attestation proved, ready to store. */
9
+ export interface AttestedAppAttestKey {
10
+ /** The key id: SHA-256 of {@link publicKey}. */
11
+ keyId: Uint8Array;
12
+ /** The P-256 public key, as an X9.62 uncompressed point. */
13
+ publicKey: Uint8Array;
14
+ /** The App ID the attestation was made for, `<TeamID>.<bundleId>`. */
15
+ appId: string;
16
+ environment: AppAttestEnvironment;
17
+ }
18
+ /** What {@link verifyAppAttestation} judges. */
19
+ export interface AppAttestationInput {
20
+ /** The attestation object, decoded from the base64 `attestKey` hands over. */
21
+ attestation: Uint8Array;
22
+ /** The key id, decoded from the base64 `generateKey` hands over. */
23
+ keyId: Uint8Array;
24
+ /** What the app passed to `attestKey`. */
25
+ clientDataHash: Uint8Array;
26
+ /** The apps allowed to attest. */
27
+ apps: readonly AppleAppIdentity[];
28
+ /** Whether a development AAGUID is accepted. A production one always is. */
29
+ allowDevelopment: boolean;
30
+ /** The root CA the chain must lead to, DER. */
31
+ root: Uint8Array;
32
+ now: Date;
33
+ }
34
+ export type AppAttestationResult = {
35
+ ok: true;
36
+ key: AttestedAppAttestKey;
37
+ } | {
38
+ ok: false;
39
+ check: AppAttestationCheck;
40
+ reason: string;
41
+ };
42
+ /**
43
+ * Verify an App Attest attestation object, Apple's way: the certificate chain leads to `root`, the leaf's nonce
44
+ * extension is SHA-256 of the authenticator data and the client data hash, the leaf's key hashes to the key id,
45
+ * the `rpIdHash` is an allowed app's, the counter is zero, the AAGUID is an accepted environment's, and the
46
+ * credential id is the key id. Answers the first check that fails.
47
+ */
48
+ export declare function verifyAppAttestation(input: AppAttestationInput): Promise<AppAttestationResult>;
49
+ //# sourceMappingURL=attestation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"attestation.d.ts","sourceRoot":"","sources":["../../../src/attestation/appAttest/attestation.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAOlD,kDAAkD;AAClD,MAAM,MAAM,oBAAoB,GAAG,YAAY,GAAG,aAAa,CAAC;AAEhE,gFAAgF;AAChF,MAAM,MAAM,mBAAmB,GAC3B,QAAQ,GACR,OAAO,GACP,OAAO,GACP,OAAO,GACP,UAAU,GACV,SAAS,GACT,QAAQ,GACR,cAAc,CAAC;AAEnB,mDAAmD;AACnD,MAAM,WAAW,oBAAoB;IACnC,gDAAgD;IAChD,KAAK,EAAE,UAAU,CAAC;IAClB,4DAA4D;IAC5D,SAAS,EAAE,UAAU,CAAC;IACtB,sEAAsE;IACtE,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,oBAAoB,CAAC;CACnC;AAED,gDAAgD;AAChD,MAAM,WAAW,mBAAmB;IAClC,8EAA8E;IAC9E,WAAW,EAAE,UAAU,CAAC;IACxB,oEAAoE;IACpE,KAAK,EAAE,UAAU,CAAC;IAClB,0CAA0C;IAC1C,cAAc,EAAE,UAAU,CAAC;IAC3B,kCAAkC;IAClC,IAAI,EAAE,SAAS,gBAAgB,EAAE,CAAC;IAClC,4EAA4E;IAC5E,gBAAgB,EAAE,OAAO,CAAC;IAC1B,+CAA+C;IAC/C,IAAI,EAAE,UAAU,CAAC;IACjB,GAAG,EAAE,IAAI,CAAC;CACX;AAED,MAAM,MAAM,oBAAoB,GAC5B;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,GAAG,EAAE,oBAAoB,CAAA;CAAE,GACvC;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,mBAAmB,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAsC9D;;;;;GAKG;AACH,wBAAsB,oBAAoB,CAAC,KAAK,EAAE,mBAAmB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CA4DpG"}
@@ -0,0 +1,111 @@
1
+ // SPDX-FileCopyrightText: 2026 Pithy
2
+ // SPDX-License-Identifier: MIT
3
+ import { readAttestedAuthenticatorData } from "./authData.js";
4
+ import { equalBytes, sha256 } from "./bytes.js";
5
+ import { CborError, cborBytes, cborText, decodeCbor } from "./cbor.js";
6
+ import { DerError, derChildren, expectTag, readDer } from "./der.js";
7
+ import { parseCertificate, verifyChain } from "./x509.js";
8
+ //#region src/attestation/appAttest/attestation.ts
9
+ /** The leaf extension holding the nonce: a SEQUENCE holding `[1]` holding an OCTET STRING. */
10
+ const NONCE_EXTENSION = "1.2.840.113635.100.8.2";
11
+ const AAGUIDS = {
12
+ production: new Uint8Array([
13
+ ...new TextEncoder().encode("appattest"),
14
+ 0,
15
+ 0,
16
+ 0,
17
+ 0,
18
+ 0,
19
+ 0,
20
+ 0
21
+ ]),
22
+ development: new TextEncoder().encode("appattestdevelop")
23
+ };
24
+ const refuse = (check, reason) => ({
25
+ ok: false,
26
+ check,
27
+ reason
28
+ });
29
+ /** `apple-appattest` statement parts, or `undefined` for anything else. */
30
+ function statement(value) {
31
+ if (cborText(value, "fmt") !== "apple-appattest") return void 0;
32
+ const authData = cborBytes(value, "authData");
33
+ const attStmt = value instanceof Map ? value.get("attStmt") : void 0;
34
+ const x5c = attStmt instanceof Map ? attStmt.get("x5c") : void 0;
35
+ if (authData === void 0 || !Array.isArray(x5c) || !x5c.every((cert) => cert instanceof Uint8Array)) return;
36
+ return {
37
+ x5c,
38
+ authData
39
+ };
40
+ }
41
+ function nonceOf(leaf) {
42
+ const value = leaf.extensions.get(NONCE_EXTENSION);
43
+ if (value === void 0) return void 0;
44
+ try {
45
+ const [tagged] = derChildren(expectTag(readDer(value), 48, "the nonce extension"));
46
+ if (tagged?.tag !== 161) return void 0;
47
+ const [nonce] = derChildren(tagged);
48
+ return expectTag(nonce, 4, "the nonce").content;
49
+ } catch (cause) {
50
+ if (cause instanceof DerError) return void 0;
51
+ throw cause;
52
+ }
53
+ }
54
+ /**
55
+ * Verify an App Attest attestation object, Apple's way: the certificate chain leads to `root`, the leaf's nonce
56
+ * extension is SHA-256 of the authenticator data and the client data hash, the leaf's key hashes to the key id,
57
+ * the `rpIdHash` is an allowed app's, the counter is zero, the AAGUID is an accepted environment's, and the
58
+ * credential id is the key id. Answers the first check that fails.
59
+ */
60
+ async function verifyAppAttestation(input) {
61
+ let parts;
62
+ try {
63
+ parts = statement(decodeCbor(input.attestation));
64
+ } catch (cause) {
65
+ if (!(cause instanceof CborError)) throw cause;
66
+ return refuse("format", `the attestation object is not CBOR: ${cause.message}`);
67
+ }
68
+ if (parts === void 0) return refuse("format", "the attestation object is not an apple-appattest statement");
69
+ if (parts.x5c.length !== 2) return refuse("chain", "x5c does not hold exactly the leaf and the intermediate");
70
+ let chain;
71
+ let root;
72
+ try {
73
+ chain = parts.x5c.map(parseCertificate);
74
+ root = parseCertificate(input.root);
75
+ } catch (cause) {
76
+ if (!(cause instanceof DerError)) throw cause;
77
+ return refuse("chain", `a certificate does not parse: ${cause.message}`);
78
+ }
79
+ const chained = await verifyChain(chain, root, input.now);
80
+ if (!chained.ok) return refuse("chain", chained.reason);
81
+ const leaf = chain[0];
82
+ const nonce = nonceOf(leaf);
83
+ if (nonce === void 0) return refuse("nonce", "the leaf certificate carries no nonce extension");
84
+ if (!equalBytes(nonce, await sha256(parts.authData, input.clientDataHash))) return refuse("nonce", "the leaf certificate's nonce is not bound to this challenge");
85
+ if (leaf.publicKey.curve !== "P-256") return refuse("keyId", "the leaf certificate's key is not on P-256");
86
+ if (!equalBytes(await sha256(leaf.publicKey.point), input.keyId)) return refuse("keyId", "the leaf certificate's key does not hash to the key id");
87
+ const authData = readAttestedAuthenticatorData(parts.authData);
88
+ if (authData === void 0) return refuse("format", "the authenticator data is too short");
89
+ let appId;
90
+ for (const app of input.apps) {
91
+ const candidate = `${app.teamId}.${app.bundleId}`;
92
+ if (equalBytes(await sha256(new TextEncoder().encode(candidate)), authData.rpIdHash)) appId = candidate;
93
+ }
94
+ if (appId === void 0) return refuse("rpIdHash", "the rpIdHash is not SHA-256 of an allowed app's App ID");
95
+ if (authData.counter !== 0) return refuse("counter", `an attestation's counter is ${authData.counter}, not 0`);
96
+ const environment = Object.keys(AAGUIDS).find((name) => equalBytes(AAGUIDS[name], authData.aaguid));
97
+ if (environment === void 0) return refuse("aaguid", "the AAGUID is neither App Attest environment's");
98
+ if (environment === "development" && !input.allowDevelopment) return refuse("aaguid", "a development AAGUID is refused here: only production keys are accepted");
99
+ if (!equalBytes(authData.credentialId, input.keyId)) return refuse("credentialId", "the credential id is not the key id");
100
+ return {
101
+ ok: true,
102
+ key: {
103
+ keyId: input.keyId,
104
+ publicKey: leaf.publicKey.point,
105
+ appId,
106
+ environment
107
+ }
108
+ };
109
+ }
110
+ //#endregion
111
+ export { verifyAppAttestation };
@@ -0,0 +1,24 @@
1
+ // SPDX-FileCopyrightText: 2026 Pithy
2
+ // SPDX-License-Identifier: MIT
3
+ /** The authenticator data App Attest signs over, as far as a verifier reads it. */
4
+ export interface AuthenticatorData {
5
+ /** SHA-256 of the App ID, `<TeamID>.<bundleId>`. */
6
+ rpIdHash: Uint8Array;
7
+ /** How many assertions the key has made: 0 in an attestation, then strictly increasing. */
8
+ counter: number;
9
+ }
10
+ /** An attestation's authenticator data, which also carries the attested credential. */
11
+ export interface AttestedAuthenticatorData extends AuthenticatorData {
12
+ /** `appattestdevelop`, or `appattest` and seven zero bytes. */
13
+ aaguid: Uint8Array;
14
+ /** The key id the credential was created under. */
15
+ credentialId: Uint8Array;
16
+ }
17
+ /** Read an assertion's authenticator data, or answer `undefined` when it is too short to hold one. */
18
+ export declare function readAuthenticatorData(bytes: Uint8Array): AuthenticatorData | undefined;
19
+ /**
20
+ * Read an attestation's authenticator data, through the credential id. What follows it, the COSE key and any
21
+ * extensions, is not read: the public key is taken from the certificate, whose digest the key id must match.
22
+ */
23
+ export declare function readAttestedAuthenticatorData(bytes: Uint8Array): AttestedAuthenticatorData | undefined;
24
+ //# sourceMappingURL=authData.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authData.d.ts","sourceRoot":"","sources":["../../../src/attestation/appAttest/authData.ts"],"names":[],"mappings":"AAGA,mFAAmF;AACnF,MAAM,WAAW,iBAAiB;IAChC,oDAAoD;IACpD,QAAQ,EAAE,UAAU,CAAC;IACrB,2FAA2F;IAC3F,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,uFAAuF;AACvF,MAAM,WAAW,yBAA0B,SAAQ,iBAAiB;IAClE,+DAA+D;IAC/D,MAAM,EAAE,UAAU,CAAC;IACnB,mDAAmD;IACnD,YAAY,EAAE,UAAU,CAAC;CAC1B;AAKD,sGAAsG;AACtG,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,UAAU,GAAG,iBAAiB,GAAG,SAAS,CAItF;AAED;;;GAGG;AACH,wBAAgB,6BAA6B,CAAC,KAAK,EAAE,UAAU,GAAG,yBAAyB,GAAG,SAAS,CAWtG"}
@@ -0,0 +1,32 @@
1
+ // SPDX-FileCopyrightText: 2026 Pithy
2
+ // SPDX-License-Identifier: MIT
3
+ //#region src/attestation/appAttest/authData.ts
4
+ /** The header every authenticator data starts with: `rpIdHash`, flags, counter. */
5
+ const HEADER = 37;
6
+ /** Read an assertion's authenticator data, or answer `undefined` when it is too short to hold one. */
7
+ function readAuthenticatorData(bytes) {
8
+ if (bytes.length < HEADER) return void 0;
9
+ const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
10
+ return {
11
+ rpIdHash: bytes.slice(0, 32),
12
+ counter: view.getUint32(33)
13
+ };
14
+ }
15
+ /**
16
+ * Read an attestation's authenticator data, through the credential id. What follows it, the COSE key and any
17
+ * extensions, is not read: the public key is taken from the certificate, whose digest the key id must match.
18
+ */
19
+ function readAttestedAuthenticatorData(bytes) {
20
+ const header = readAuthenticatorData(bytes);
21
+ if (header === void 0 || bytes.length < 55) return void 0;
22
+ const length = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength).getUint16(53);
23
+ const start = 55;
24
+ if (bytes.length < start + length) return void 0;
25
+ return {
26
+ ...header,
27
+ aaguid: bytes.slice(HEADER, 53),
28
+ credentialId: bytes.slice(start, start + length)
29
+ };
30
+ }
31
+ //#endregion
32
+ export { readAttestedAuthenticatorData, readAuthenticatorData };
@@ -0,0 +1,8 @@
1
+ // SPDX-FileCopyrightText: 2026 Pithy
2
+ // SPDX-License-Identifier: MIT
3
+ /**
4
+ * Decode base64 as Apple's APIs hand it over (standard alphabet, padded) or as a client may re-encode it
5
+ * (url alphabet, unpadded). Answers `undefined` for anything else, never a best guess.
6
+ */
7
+ export declare function decodeBase64(value: string): Uint8Array | undefined;
8
+ //# sourceMappingURL=base64.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base64.d.ts","sourceRoot":"","sources":["../../../src/attestation/appAttest/base64.ts"],"names":[],"mappings":"AAMA;;;GAGG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS,CAkBlE"}
@@ -0,0 +1,27 @@
1
+ // SPDX-FileCopyrightText: 2026 Pithy
2
+ // SPDX-License-Identifier: MIT
3
+ //#region src/attestation/appAttest/base64.ts
4
+ const BASE64 = /^[A-Za-z0-9+/]*={0,2}$/;
5
+ const BASE64URL = /^[A-Za-z0-9_-]*$/;
6
+ /**
7
+ * Decode base64 as Apple's APIs hand it over (standard alphabet, padded) or as a client may re-encode it
8
+ * (url alphabet, unpadded). Answers `undefined` for anything else, never a best guess.
9
+ */
10
+ function decodeBase64(value) {
11
+ let standard;
12
+ if (BASE64.test(value)) {
13
+ if (value.includes("=") && value.length % 4 !== 0) return void 0;
14
+ standard = value.replace(/=+$/, "");
15
+ } else if (BASE64URL.test(value)) standard = value.replace(/-/g, "+").replace(/_/g, "/");
16
+ else return;
17
+ if (standard.length % 4 === 1) return void 0;
18
+ let binary;
19
+ try {
20
+ binary = atob(standard + "=".repeat((4 - standard.length % 4) % 4));
21
+ } catch {
22
+ return;
23
+ }
24
+ return Uint8Array.from(binary, (char) => char.charCodeAt(0));
25
+ }
26
+ //#endregion
27
+ export { decodeBase64 };
@@ -0,0 +1,7 @@
1
+ // SPDX-FileCopyrightText: 2026 Pithy
2
+ // SPDX-License-Identifier: MIT
3
+ /** Whether two byte strings are equal. Every input compared here is public, so the early exit leaks nothing. */
4
+ export declare function equalBytes(a: Uint8Array, b: Uint8Array): boolean;
5
+ /** SHA-256 over the parts, in order. */
6
+ export declare function sha256(...parts: Uint8Array[]): Promise<Uint8Array>;
7
+ //# sourceMappingURL=bytes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bytes.d.ts","sourceRoot":"","sources":["../../../src/attestation/appAttest/bytes.ts"],"names":[],"mappings":"AAGA,gHAAgH;AAChH,wBAAgB,UAAU,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,UAAU,GAAG,OAAO,CAEhE;AAED,wCAAwC;AACxC,wBAAsB,MAAM,CAAC,GAAG,KAAK,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC,UAAU,CAAC,CAQxE"}
@@ -0,0 +1,19 @@
1
+ // SPDX-FileCopyrightText: 2026 Pithy
2
+ // SPDX-License-Identifier: MIT
3
+ //#region src/attestation/appAttest/bytes.ts
4
+ /** Whether two byte strings are equal. Every input compared here is public, so the early exit leaks nothing. */
5
+ function equalBytes(a, b) {
6
+ return a.length === b.length && a.every((byte, i) => byte === b[i]);
7
+ }
8
+ /** SHA-256 over the parts, in order. */
9
+ async function sha256(...parts) {
10
+ const message = new Uint8Array(parts.reduce((total, part) => total + part.length, 0));
11
+ let offset = 0;
12
+ for (const part of parts) {
13
+ message.set(part, offset);
14
+ offset += part.length;
15
+ }
16
+ return new Uint8Array(await crypto.subtle.digest("SHA-256", message));
17
+ }
18
+ //#endregion
19
+ export { equalBytes, sha256 };
@@ -0,0 +1,20 @@
1
+ // SPDX-FileCopyrightText: 2026 Pithy
2
+ // SPDX-License-Identifier: MIT
3
+ /**
4
+ * A CBOR reader for what App Attest sends (RFC 8949): unsigned and negative integers, byte and text strings,
5
+ * arrays, maps, `true`, `false` and `null`, all of definite length. Anything else, and any byte left over, is
6
+ * a {@link CborError}, because every input here is attacker-supplied.
7
+ */
8
+ /** A decoded CBOR value. Maps keep their keys' own types, so an integer key never collides with a text one. */
9
+ export type CborValue = number | boolean | null | string | Uint8Array | CborValue[] | Map<CborValue, CborValue>;
10
+ /** The input is not CBOR this reader accepts. */
11
+ export declare class CborError extends Error {
12
+ name: string;
13
+ }
14
+ /** Decode exactly one CBOR item that fills `bytes`. Throws {@link CborError} on anything else. */
15
+ export declare function decodeCbor(bytes: Uint8Array): CborValue;
16
+ /** The byte-string field `key` of a decoded map, or `undefined` when it is absent, or not a map or bytes. */
17
+ export declare function cborBytes(value: CborValue, key: string): Uint8Array | undefined;
18
+ /** The text field `key` of a decoded map, or `undefined` when it is absent, or not a map or text. */
19
+ export declare function cborText(value: CborValue, key: string): string | undefined;
20
+ //# sourceMappingURL=cbor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cbor.d.ts","sourceRoot":"","sources":["../../../src/attestation/appAttest/cbor.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AAEH,+GAA+G;AAC/G,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,MAAM,GAAG,UAAU,GAAG,SAAS,EAAE,GAAG,GAAG,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;AAEhH,iDAAiD;AACjD,qBAAa,SAAU,SAAQ,KAAK;IACzB,IAAI,SAAe;CAC7B;AAkFD,kGAAkG;AAClG,wBAAgB,UAAU,CAAC,KAAK,EAAE,UAAU,GAAG,SAAS,CAKvD;AAED,6GAA6G;AAC7G,wBAAgB,SAAS,CAAC,KAAK,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS,CAG/E;AAED,qGAAqG;AACrG,wBAAgB,QAAQ,CAAC,KAAK,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAG1E"}
@@ -0,0 +1,96 @@
1
+ // SPDX-FileCopyrightText: 2026 Pithy
2
+ // SPDX-License-Identifier: MIT
3
+ //#region src/attestation/appAttest/cbor.ts
4
+ /** The input is not CBOR this reader accepts. */
5
+ var CborError = class extends Error {
6
+ name = "CborError";
7
+ };
8
+ const MAX_DEPTH = 16;
9
+ var Reader = class {
10
+ offset = 0;
11
+ bytes;
12
+ constructor(bytes) {
13
+ this.bytes = bytes;
14
+ }
15
+ take(length) {
16
+ if (length > this.bytes.length - this.offset) throw new CborError("CBOR runs past the end of its input");
17
+ const slice = this.bytes.subarray(this.offset, this.offset + length);
18
+ this.offset += length;
19
+ return slice;
20
+ }
21
+ byte() {
22
+ return this.take(1)[0];
23
+ }
24
+ argument(additional) {
25
+ if (additional < 24) return additional;
26
+ const width = additional === 24 ? 1 : additional === 25 ? 2 : additional === 26 ? 4 : additional === 27 ? 8 : 0;
27
+ if (width === 0) throw new CborError(`CBOR additional information ${additional} is not supported`);
28
+ let value = 0;
29
+ for (const byte of this.take(width)) value = value * 256 + byte;
30
+ if (!Number.isSafeInteger(value)) throw new CborError("CBOR integer is past 2^53");
31
+ return value;
32
+ }
33
+ value(depth) {
34
+ if (depth > MAX_DEPTH) throw new CborError("CBOR is nested too deep");
35
+ const initial = this.byte();
36
+ const major = initial >> 5;
37
+ const additional = initial & 31;
38
+ if (major === 7) {
39
+ if (additional === 20) return false;
40
+ if (additional === 21) return true;
41
+ if (additional === 22) return null;
42
+ throw new CborError(`CBOR simple value or float ${additional} is not supported`);
43
+ }
44
+ if (major === 6) throw new CborError("CBOR tags are not supported");
45
+ const argument = this.argument(additional);
46
+ switch (major) {
47
+ case 0: return argument;
48
+ case 1: return -1 - argument;
49
+ case 2: return this.take(argument).slice();
50
+ case 3: try {
51
+ return new TextDecoder("utf-8", {
52
+ fatal: true,
53
+ ignoreBOM: true
54
+ }).decode(this.take(argument));
55
+ } catch (cause) {
56
+ if (cause instanceof CborError) throw cause;
57
+ throw new CborError("CBOR text string is not UTF-8");
58
+ }
59
+ case 4: {
60
+ if (argument > this.bytes.length - this.offset) throw new CborError("CBOR array runs past the end of its input");
61
+ const items = [];
62
+ for (let i = 0; i < argument; i++) items.push(this.value(depth + 1));
63
+ return items;
64
+ }
65
+ default: {
66
+ if (argument * 2 > this.bytes.length - this.offset) throw new CborError("CBOR map runs past the end of its input");
67
+ const map = /* @__PURE__ */ new Map();
68
+ for (let i = 0; i < argument; i++) {
69
+ const key = this.value(depth + 1);
70
+ if (map.has(key)) throw new CborError("CBOR map repeats a key");
71
+ map.set(key, this.value(depth + 1));
72
+ }
73
+ return map;
74
+ }
75
+ }
76
+ }
77
+ };
78
+ /** Decode exactly one CBOR item that fills `bytes`. Throws {@link CborError} on anything else. */
79
+ function decodeCbor(bytes) {
80
+ const reader = new Reader(bytes);
81
+ const value = reader.value(0);
82
+ if (reader.offset !== bytes.length) throw new CborError("CBOR has bytes after its one item");
83
+ return value;
84
+ }
85
+ /** The byte-string field `key` of a decoded map, or `undefined` when it is absent, or not a map or bytes. */
86
+ function cborBytes(value, key) {
87
+ const field = value instanceof Map ? value.get(key) : void 0;
88
+ return field instanceof Uint8Array ? field : void 0;
89
+ }
90
+ /** The text field `key` of a decoded map, or `undefined` when it is absent, or not a map or text. */
91
+ function cborText(value, key) {
92
+ const field = value instanceof Map ? value.get(key) : void 0;
93
+ return typeof field === "string" ? field : void 0;
94
+ }
95
+ //#endregion
96
+ export { CborError, cborBytes, cborText, decodeCbor };
@@ -0,0 +1,38 @@
1
+ // SPDX-FileCopyrightText: 2026 Pithy
2
+ // SPDX-License-Identifier: MIT
3
+ /**
4
+ * A DER reader (X.690) for the certificates App Attest sends: definite, minimal lengths, low tag numbers. Anything
5
+ * else is a {@link DerError}, because every input here is attacker-supplied.
6
+ */
7
+ /** The input is not DER this reader accepts. */
8
+ export declare class DerError extends Error {
9
+ name: string;
10
+ }
11
+ /** One DER element. */
12
+ export interface DerNode {
13
+ /** The identifier octet: class, constructed bit and tag number. */
14
+ tag: number;
15
+ /** The content octets. */
16
+ content: Uint8Array;
17
+ /** The whole element, identifier and length included: what a signature over it covers. */
18
+ raw: Uint8Array;
19
+ }
20
+ export declare const DER_INTEGER = 2;
21
+ export declare const DER_BIT_STRING = 3;
22
+ export declare const DER_OCTET_STRING = 4;
23
+ export declare const DER_OID = 6;
24
+ export declare const DER_BOOLEAN = 1;
25
+ export declare const DER_SEQUENCE = 48;
26
+ /** Read exactly one element that fills `bytes`. */
27
+ export declare function readDer(bytes: Uint8Array): DerNode;
28
+ /** The elements inside a constructed element, in order. */
29
+ export declare function derChildren(node: DerNode): DerNode[];
30
+ /** Assert `node` carries `tag`, naming `what` when it does not. */
31
+ export declare function expectTag(node: DerNode | undefined, tag: number, what: string): DerNode;
32
+ /** An INTEGER's content octets, two's complement big-endian. */
33
+ export declare function derInteger(node: DerNode | undefined): Uint8Array;
34
+ /** An OBJECT IDENTIFIER in dotted form. */
35
+ export declare function derOid(node: DerNode | undefined): string;
36
+ /** A UTCTime or GeneralizedTime, which RFC 5280 requires in UTC to the second. */
37
+ export declare function derTime(node: DerNode | undefined): Date;
38
+ //# sourceMappingURL=der.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"der.d.ts","sourceRoot":"","sources":["../../../src/attestation/appAttest/der.ts"],"names":[],"mappings":"AAGA;;;GAGG;AAEH,gDAAgD;AAChD,qBAAa,QAAS,SAAQ,KAAK;IACxB,IAAI,SAAc;CAC5B;AAED,uBAAuB;AACvB,MAAM,WAAW,OAAO;IACtB,mEAAmE;IACnE,GAAG,EAAE,MAAM,CAAC;IACZ,0BAA0B;IAC1B,OAAO,EAAE,UAAU,CAAC;IACpB,0FAA0F;IAC1F,GAAG,EAAE,UAAU,CAAC;CACjB;AAED,eAAO,MAAM,WAAW,IAAO,CAAC;AAChC,eAAO,MAAM,cAAc,IAAO,CAAC;AACnC,eAAO,MAAM,gBAAgB,IAAO,CAAC;AACrC,eAAO,MAAM,OAAO,IAAO,CAAC;AAC5B,eAAO,MAAM,WAAW,IAAO,CAAC;AAChC,eAAO,MAAM,YAAY,KAAO,CAAC;AA6BjC,mDAAmD;AACnD,wBAAgB,OAAO,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAIlD;AAED,2DAA2D;AAC3D,wBAAgB,WAAW,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,EAAE,CAUpD;AAED,mEAAmE;AACnE,wBAAgB,SAAS,CAAC,IAAI,EAAE,OAAO,GAAG,SAAS,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAGvF;AAED,gEAAgE;AAChE,wBAAgB,UAAU,CAAC,IAAI,EAAE,OAAO,GAAG,SAAS,GAAG,UAAU,CAEhE;AAED,2CAA2C;AAC3C,wBAAgB,MAAM,CAAC,IAAI,EAAE,OAAO,GAAG,SAAS,GAAG,MAAM,CAiBxD;AAED,kFAAkF;AAClF,wBAAgB,OAAO,CAAC,IAAI,EAAE,OAAO,GAAG,SAAS,GAAG,IAAI,CAgBvD"}