@oxy.so/contracts 2.0.0 → 2.2.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 (53) hide show
  1. package/dist/cjs/.tsbuildinfo +1 -1
  2. package/dist/cjs/accountEmail.js +83 -0
  3. package/dist/cjs/federationInstanceFetch.js +44 -0
  4. package/dist/cjs/identityLink.js +89 -0
  5. package/dist/cjs/identityProof.js +6 -29
  6. package/dist/cjs/index.js +36 -49
  7. package/dist/cjs/linkedAccounts.js +34 -1
  8. package/dist/cjs/notifications.js +20 -1
  9. package/dist/cjs/webauthn.js +50 -21
  10. package/dist/esm/.tsbuildinfo +1 -1
  11. package/dist/esm/accountEmail.js +80 -0
  12. package/dist/esm/federationInstanceFetch.js +41 -0
  13. package/dist/esm/identityLink.js +84 -0
  14. package/dist/esm/identityProof.js +6 -29
  15. package/dist/esm/index.js +8 -10
  16. package/dist/esm/linkedAccounts.js +33 -0
  17. package/dist/esm/notifications.js +19 -0
  18. package/dist/esm/webauthn.js +49 -20
  19. package/dist/types/.tsbuildinfo +1 -1
  20. package/dist/types/accountEmail.d.ts +98 -0
  21. package/dist/types/accountGraph.d.ts +4 -4
  22. package/dist/types/agency.d.ts +2 -2
  23. package/dist/types/deviceSession.d.ts +4 -4
  24. package/dist/types/externalIdentity.d.ts +8 -8
  25. package/dist/types/federationInstanceFetch.d.ts +63 -0
  26. package/dist/types/identityLink.d.ts +210 -0
  27. package/dist/types/identityProof.d.ts +15 -42
  28. package/dist/types/index.d.ts +7 -8
  29. package/dist/types/inference/accountBilling.d.ts +2 -2
  30. package/dist/types/inference/aliaModelRelease.d.ts +8 -8
  31. package/dist/types/inference/embeddings.d.ts +16 -16
  32. package/dist/types/inference/errors.d.ts +8 -8
  33. package/dist/types/inference/inbox.d.ts +8 -8
  34. package/dist/types/inference/modelDocumentation.d.ts +8 -8
  35. package/dist/types/inference/providerConnection.d.ts +20 -20
  36. package/dist/types/inference/request.d.ts +16 -16
  37. package/dist/types/inference/streamEvents.d.ts +20 -20
  38. package/dist/types/keyRecovery.d.ts +4 -4
  39. package/dist/types/linkedAccounts.d.ts +33 -0
  40. package/dist/types/notifications.d.ts +26 -0
  41. package/dist/types/sessionStatus.d.ts +2 -2
  42. package/dist/types/userResponse.d.ts +4 -4
  43. package/dist/types/webauthn.d.ts +102 -214
  44. package/package.json +1 -1
  45. package/dist/cjs/identityMove.js +0 -156
  46. package/dist/cjs/identityRecovery.js +0 -51
  47. package/dist/cjs/webIdentityCarrier.js +0 -181
  48. package/dist/esm/identityMove.js +0 -148
  49. package/dist/esm/identityRecovery.js +0 -48
  50. package/dist/esm/webIdentityCarrier.js +0 -178
  51. package/dist/types/identityMove.d.ts +0 -185
  52. package/dist/types/identityRecovery.d.ts +0 -246
  53. package/dist/types/webIdentityCarrier.d.ts +0 -1130
@@ -0,0 +1,98 @@
1
+ /**
2
+ * Recovery email contracts (ADR 0029 D3).
3
+ *
4
+ * A web account is a username, a passkey and a recovery email. The email is
5
+ * proven by a 6-digit code sent to it, and the proof is a short-lived one-use
6
+ * ticket the next step spends:
7
+ *
8
+ * - `signup`: the ticket lets `POST /webauthn/register/verify` create the
9
+ * account with that email;
10
+ * - `recovery`: the person names their username or email, the code goes to the
11
+ * account's recovery email, and the ticket lets them register a new passkey
12
+ * for that account.
13
+ *
14
+ * `start` answers the same whether or not an account exists, so neither purpose
15
+ * tells anyone which emails or usernames have an Oxy account. An account with a
16
+ * Commons key has no recovery email: it recovers in Commons.
17
+ */
18
+ import { z } from 'zod';
19
+ export declare const EMAIL_VERIFICATION_PURPOSES: readonly ["signup", "recovery"];
20
+ export type EmailVerificationPurpose = (typeof EMAIL_VERIFICATION_PURPOSES)[number];
21
+ /** Digits in a code. */
22
+ export declare const EMAIL_CODE_LENGTH = 6;
23
+ /** How long a code can be confirmed. */
24
+ export declare const EMAIL_CODE_TTL_MS: number;
25
+ /** Wrong codes before a verification is spent and a new code is needed. */
26
+ export declare const EMAIL_CODE_MAX_ATTEMPTS = 5;
27
+ /** How long a confirmed code's ticket can be spent. */
28
+ export declare const EMAIL_TICKET_TTL_MS: number;
29
+ /** An email address as the API stores it: trimmed and lowercase. */
30
+ export declare const emailAddressSchema: z.ZodString;
31
+ /** An opaque one-use ticket (32 random bytes, base64url). */
32
+ export declare const emailTicketSchema: z.ZodString;
33
+ /** `POST /auth/email/verify/start` */
34
+ export declare const emailVerificationStartRequestSchema: z.ZodDiscriminatedUnion<"purpose", [z.ZodObject<{
35
+ purpose: z.ZodLiteral<"signup">;
36
+ email: z.ZodString;
37
+ }, "strict", z.ZodTypeAny, {
38
+ purpose: "signup";
39
+ email: string;
40
+ }, {
41
+ purpose: "signup";
42
+ email: string;
43
+ }>, z.ZodObject<{
44
+ purpose: z.ZodLiteral<"recovery">;
45
+ /** The account's username, or its recovery email. */
46
+ identifier: z.ZodString;
47
+ }, "strict", z.ZodTypeAny, {
48
+ purpose: "recovery";
49
+ identifier: string;
50
+ }, {
51
+ purpose: "recovery";
52
+ identifier: string;
53
+ }>]>;
54
+ export type EmailVerificationStartRequest = z.infer<typeof emailVerificationStartRequestSchema>;
55
+ export interface EmailVerificationStartResponse {
56
+ /** Names this verification in `confirm`. Returned whether or not a code was sent. */
57
+ verificationId: string;
58
+ /** Unix milliseconds after which the code is refused. */
59
+ expiresAt: number;
60
+ }
61
+ export declare const emailVerificationStartResponseSchema: z.ZodType<EmailVerificationStartResponse>;
62
+ /** `POST /auth/email/verify/confirm` */
63
+ export declare const emailVerificationConfirmRequestSchema: z.ZodObject<{
64
+ verificationId: z.ZodString;
65
+ code: z.ZodString;
66
+ }, "strict", z.ZodTypeAny, {
67
+ code: string;
68
+ verificationId: string;
69
+ }, {
70
+ code: string;
71
+ verificationId: string;
72
+ }>;
73
+ export type EmailVerificationConfirmRequest = z.infer<typeof emailVerificationConfirmRequestSchema>;
74
+ export interface EmailVerificationConfirmResponse {
75
+ ticket: string;
76
+ /** Unix milliseconds after which the ticket is refused. */
77
+ expiresAt: number;
78
+ /** Recovery only: the account the ticket recovers. `null` for sign-up. */
79
+ username: string | null;
80
+ }
81
+ export declare const emailVerificationConfirmResponseSchema: z.ZodType<EmailVerificationConfirmResponse>;
82
+ /**
83
+ * Stable error codes (`error.code` in the API error body). Clients map these
84
+ * through their localization, never the English message.
85
+ */
86
+ export declare const EMAIL_VERIFICATION_ERROR_CODES: {
87
+ /** The code is wrong, or its verification expired or was spent. */
88
+ readonly codeInvalid: "EMAIL_CODE_INVALID";
89
+ /** Too many wrong codes: request a new one. */
90
+ readonly tooManyAttempts: "EMAIL_CODE_TOO_MANY_ATTEMPTS";
91
+ /** The ticket is unknown, expired, spent, or for another email or purpose. */
92
+ readonly ticketInvalid: "EMAIL_TICKET_INVALID";
93
+ /** A sign-up without a confirmed recovery email. */
94
+ readonly ticketRequired: "EMAIL_TICKET_REQUIRED";
95
+ /** This server cannot send mail. */
96
+ readonly unavailable: "EMAIL_UNAVAILABLE";
97
+ };
98
+ export type EmailVerificationErrorCode = (typeof EMAIL_VERIFICATION_ERROR_CODES)[keyof typeof EMAIL_VERIFICATION_ERROR_CODES];
@@ -315,8 +315,8 @@ export declare const createAccountRequestSchema: z.ZodEffects<z.ZodObject<{
315
315
  */
316
316
  isPrivateAccount: z.ZodOptional<z.ZodBoolean>;
317
317
  }, "strip", z.ZodTypeAny, {
318
- kind: "bot" | "organization" | "project" | "channel";
319
318
  username: string;
319
+ kind: "bot" | "organization" | "project" | "channel";
320
320
  parentAccountId?: string | undefined;
321
321
  name?: {
322
322
  first?: string | undefined;
@@ -330,8 +330,8 @@ export declare const createAccountRequestSchema: z.ZodEffects<z.ZodObject<{
330
330
  accountCategories?: ("security" | "news" | "politics" | "business" | "startup" | "finance" | "crypto" | "marketplace" | "retail" | "real_estate" | "agency" | "landlord" | "cooperative" | "architecture" | "technology" | "software" | "ai" | "automation" | "science" | "education" | "books" | "health" | "fitness" | "sports" | "gaming" | "music" | "film" | "podcast" | "art" | "photography" | "comedy" | "food" | "travel" | "fashion" | "home_garden" | "diy" | "automotive" | "animals" | "family" | "nonprofit" | "government" | "community" | "activism" | "environment" | "religion" | "other")[] | undefined;
331
331
  isPrivateAccount?: boolean | undefined;
332
332
  }, {
333
- kind: "bot" | "organization" | "project" | "channel";
334
333
  username: string;
334
+ kind: "bot" | "organization" | "project" | "channel";
335
335
  parentAccountId?: string | undefined;
336
336
  name?: {
337
337
  first?: string | undefined;
@@ -345,8 +345,8 @@ export declare const createAccountRequestSchema: z.ZodEffects<z.ZodObject<{
345
345
  accountCategories?: ("security" | "news" | "politics" | "business" | "startup" | "finance" | "crypto" | "marketplace" | "retail" | "real_estate" | "agency" | "landlord" | "cooperative" | "architecture" | "technology" | "software" | "ai" | "automation" | "science" | "education" | "books" | "health" | "fitness" | "sports" | "gaming" | "music" | "film" | "podcast" | "art" | "photography" | "comedy" | "food" | "travel" | "fashion" | "home_garden" | "diy" | "automotive" | "animals" | "family" | "nonprofit" | "government" | "community" | "activism" | "environment" | "religion" | "other")[] | undefined;
346
346
  isPrivateAccount?: boolean | undefined;
347
347
  }>, {
348
- kind: "bot" | "organization" | "project" | "channel";
349
348
  username: string;
349
+ kind: "bot" | "organization" | "project" | "channel";
350
350
  parentAccountId?: string | undefined;
351
351
  name?: {
352
352
  first?: string | undefined;
@@ -360,8 +360,8 @@ export declare const createAccountRequestSchema: z.ZodEffects<z.ZodObject<{
360
360
  accountCategories?: ("security" | "news" | "politics" | "business" | "startup" | "finance" | "crypto" | "marketplace" | "retail" | "real_estate" | "agency" | "landlord" | "cooperative" | "architecture" | "technology" | "software" | "ai" | "automation" | "science" | "education" | "books" | "health" | "fitness" | "sports" | "gaming" | "music" | "film" | "podcast" | "art" | "photography" | "comedy" | "food" | "travel" | "fashion" | "home_garden" | "diy" | "automotive" | "animals" | "family" | "nonprofit" | "government" | "community" | "activism" | "environment" | "religion" | "other")[] | undefined;
361
361
  isPrivateAccount?: boolean | undefined;
362
362
  }, {
363
- kind: "bot" | "organization" | "project" | "channel";
364
363
  username: string;
364
+ kind: "bot" | "organization" | "project" | "channel";
365
365
  parentAccountId?: string | undefined;
366
366
  name?: {
367
367
  first?: string | undefined;
@@ -190,6 +190,7 @@ export declare const delegationGrantSchema: z.ZodObject<{
190
190
  createdAt: z.ZodString;
191
191
  updatedAt: z.ZodString;
192
192
  }, "strict", z.ZodTypeAny, {
193
+ expiresAt: string | null;
193
194
  ownerAccountId: string;
194
195
  id: string;
195
196
  actor: {
@@ -223,11 +224,11 @@ export declare const delegationGrantSchema: z.ZodObject<{
223
224
  }[];
224
225
  maximumAutonomy: "read_only" | "draft" | "execute_on_request" | "autonomous";
225
226
  canRedelegate: boolean;
226
- expiresAt: string | null;
227
227
  revokedAt: string | null;
228
228
  createdAt: string;
229
229
  updatedAt: string;
230
230
  }, {
231
+ expiresAt: string | null;
231
232
  ownerAccountId: string;
232
233
  id: string;
233
234
  actor: {
@@ -251,7 +252,6 @@ export declare const delegationGrantSchema: z.ZodObject<{
251
252
  capabilityPackages: ("security" | "finance" | "read" | "create" | "publish" | "communicate" | "administer" | "delegate")[];
252
253
  capabilities: string[];
253
254
  maximumAutonomy: "read_only" | "draft" | "execute_on_request" | "autonomous";
254
- expiresAt: string | null;
255
255
  createdAt: string;
256
256
  updatedAt: string;
257
257
  toolOverrides?: {
@@ -353,13 +353,13 @@ export declare const deviceBackgroundCredentialResponseSchema: z.ZodObject<{
353
353
  accountId: z.ZodString;
354
354
  expiresAt: z.ZodString;
355
355
  }, "strip", z.ZodTypeAny, {
356
- accountId: string;
357
356
  expiresAt: string;
357
+ accountId: string;
358
358
  deviceId: string;
359
359
  secret: string;
360
360
  }, {
361
- accountId: string;
362
361
  expiresAt: string;
362
+ accountId: string;
363
363
  deviceId: string;
364
364
  secret: string;
365
365
  }>;
@@ -398,12 +398,12 @@ export declare const deviceBackgroundTokenResponseSchema: z.ZodObject<{
398
398
  expiresAt: z.ZodString;
399
399
  accountId: z.ZodString;
400
400
  }, "strip", z.ZodTypeAny, {
401
- accountId: string;
402
401
  expiresAt: string;
402
+ accountId: string;
403
403
  accessToken: string;
404
404
  }, {
405
- accountId: string;
406
405
  expiresAt: string;
406
+ accountId: string;
407
407
  accessToken: string;
408
408
  }>;
409
409
  export type DeviceBackgroundCredentialResponse = z.infer<typeof deviceBackgroundCredentialResponseSchema>;
@@ -253,6 +253,7 @@ export declare const resolveExternalIdentityResponseSchema: z.ZodEffects<z.ZodOb
253
253
  sourceUserId: string;
254
254
  }[];
255
255
  redirectedUserIds: string[];
256
+ email?: string | undefined;
256
257
  kind?: "bot" | "personal" | "organization" | "project" | "channel" | undefined;
257
258
  bio?: string | undefined;
258
259
  avatar?: string | null | undefined;
@@ -263,7 +264,6 @@ export declare const resolveExternalIdentityResponseSchema: z.ZodEffects<z.ZodOb
263
264
  did?: string | undefined;
264
265
  verifiedDomains?: import("./identity").VerifiedDomain[] | undefined;
265
266
  _id?: string | undefined;
266
- email?: string | undefined;
267
267
  phone?: string | undefined;
268
268
  address?: string | undefined;
269
269
  birthday?: string | undefined;
@@ -307,6 +307,7 @@ export declare const resolveExternalIdentityResponseSchema: z.ZodEffects<z.ZodOb
307
307
  sourceUserId: string;
308
308
  }[];
309
309
  redirectedUserIds: string[];
310
+ email?: string | undefined;
310
311
  kind?: "bot" | "personal" | "organization" | "project" | "channel" | undefined;
311
312
  bio?: string | undefined;
312
313
  avatar?: string | null | undefined;
@@ -317,7 +318,6 @@ export declare const resolveExternalIdentityResponseSchema: z.ZodEffects<z.ZodOb
317
318
  did?: string | undefined;
318
319
  verifiedDomains?: import("./identity").VerifiedDomain[] | undefined;
319
320
  _id?: string | undefined;
320
- email?: string | undefined;
321
321
  phone?: string | undefined;
322
322
  address?: string | undefined;
323
323
  birthday?: string | undefined;
@@ -361,6 +361,7 @@ export declare const resolveExternalIdentityResponseSchema: z.ZodEffects<z.ZodOb
361
361
  sourceUserId: string;
362
362
  }[];
363
363
  redirectedUserIds: string[];
364
+ email?: string | undefined;
364
365
  kind?: "bot" | "personal" | "organization" | "project" | "channel" | undefined;
365
366
  bio?: string | undefined;
366
367
  avatar?: string | null | undefined;
@@ -371,7 +372,6 @@ export declare const resolveExternalIdentityResponseSchema: z.ZodEffects<z.ZodOb
371
372
  did?: string | undefined;
372
373
  verifiedDomains?: import("./identity").VerifiedDomain[] | undefined;
373
374
  _id?: string | undefined;
374
- email?: string | undefined;
375
375
  phone?: string | undefined;
376
376
  address?: string | undefined;
377
377
  birthday?: string | undefined;
@@ -415,6 +415,7 @@ export declare const resolveExternalIdentityResponseSchema: z.ZodEffects<z.ZodOb
415
415
  sourceUserId: string;
416
416
  }[];
417
417
  redirectedUserIds: string[];
418
+ email?: string | undefined;
418
419
  kind?: "bot" | "personal" | "organization" | "project" | "channel" | undefined;
419
420
  bio?: string | undefined;
420
421
  avatar?: string | null | undefined;
@@ -425,7 +426,6 @@ export declare const resolveExternalIdentityResponseSchema: z.ZodEffects<z.ZodOb
425
426
  did?: string | undefined;
426
427
  verifiedDomains?: import("./identity").VerifiedDomain[] | undefined;
427
428
  _id?: string | undefined;
428
- email?: string | undefined;
429
429
  phone?: string | undefined;
430
430
  address?: string | undefined;
431
431
  birthday?: string | undefined;
@@ -491,6 +491,7 @@ export declare const lookupExternalIdentitiesResponseSchema: z.ZodObject<{
491
491
  }>, "many">;
492
492
  redirectedUserIds: z.ZodArray<z.ZodString, "many">;
493
493
  }, "strip", z.ZodTypeAny, {
494
+ identifier: string;
494
495
  userId: string | null;
495
496
  externalIdentities: {
496
497
  canonicalAcct: string;
@@ -501,8 +502,8 @@ export declare const lookupExternalIdentitiesResponseSchema: z.ZodObject<{
501
502
  sourceUserId: string;
502
503
  }[];
503
504
  redirectedUserIds: string[];
504
- identifier: string;
505
505
  }, {
506
+ identifier: string;
506
507
  userId: string | null;
507
508
  externalIdentities: {
508
509
  canonicalAcct: string;
@@ -513,10 +514,10 @@ export declare const lookupExternalIdentitiesResponseSchema: z.ZodObject<{
513
514
  sourceUserId: string;
514
515
  }[];
515
516
  redirectedUserIds: string[];
516
- identifier: string;
517
517
  }>, "many">;
518
518
  }, "strip", z.ZodTypeAny, {
519
519
  identities: {
520
+ identifier: string;
520
521
  userId: string | null;
521
522
  externalIdentities: {
522
523
  canonicalAcct: string;
@@ -527,10 +528,10 @@ export declare const lookupExternalIdentitiesResponseSchema: z.ZodObject<{
527
528
  sourceUserId: string;
528
529
  }[];
529
530
  redirectedUserIds: string[];
530
- identifier: string;
531
531
  }[];
532
532
  }, {
533
533
  identities: {
534
+ identifier: string;
534
535
  userId: string | null;
535
536
  externalIdentities: {
536
537
  canonicalAcct: string;
@@ -541,7 +542,6 @@ export declare const lookupExternalIdentitiesResponseSchema: z.ZodObject<{
541
542
  sourceUserId: string;
542
543
  }[];
543
544
  redirectedUserIds: string[];
544
- identifier: string;
545
545
  }[];
546
546
  }>;
547
547
  export type ExternalIdentityReference = z.infer<typeof externalIdentityReferenceSchema>;
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Wire contract for `POST /federation/instance-fetch/sign`: Oxy's INSTANCE
3
+ * actor signs one ActivityPub GET for a first-party service, so the service can
4
+ * read an instance running in authorized-fetch ("secure") mode without holding
5
+ * a key.
6
+ *
7
+ * The caller sends a URL, never a signing string: Oxy builds the string itself
8
+ * (`(request-target): get <path>`, `host`, `date`), the method is always GET
9
+ * and the key is always the instance actor's. The caller sends the returned
10
+ * headers, unchanged, on exactly that URL, within the few minutes remote
11
+ * servers accept a `Date` for. A redirect is a new URL and needs a new
12
+ * signature.
13
+ *
14
+ * Needs a service token whose application holds the privileged
15
+ * `federation:instance-fetch` scope.
16
+ *
17
+ * Platform-agnostic — zod only.
18
+ */
19
+ import { z } from 'zod';
20
+ /** The longest URL Oxy will sign (the same cap as its own safe fetch). */
21
+ export declare const INSTANCE_FETCH_MAX_URL_LENGTH = 2048;
22
+ export declare const instanceFetchSignRequestSchema: z.ZodObject<{
23
+ /** The absolute public `https://` URL the caller is about to GET. */
24
+ url: z.ZodString;
25
+ }, "strict", z.ZodTypeAny, {
26
+ url: string;
27
+ }, {
28
+ url: string;
29
+ }>;
30
+ export type InstanceFetchSignRequest = z.infer<typeof instanceFetchSignRequestSchema>;
31
+ export declare const instanceFetchSignResponseSchema: z.ZodObject<{
32
+ /** The instance actor's key, e.g. `https://oxy.so/ap/users/instance#main-key`. */
33
+ keyId: z.ZodString;
34
+ /** Send all three on the GET, as they are. */
35
+ headers: z.ZodObject<{
36
+ Host: z.ZodString;
37
+ Date: z.ZodString;
38
+ Signature: z.ZodString;
39
+ }, "strict", z.ZodTypeAny, {
40
+ Host: string;
41
+ Date: string;
42
+ Signature: string;
43
+ }, {
44
+ Host: string;
45
+ Date: string;
46
+ Signature: string;
47
+ }>;
48
+ }, "strict", z.ZodTypeAny, {
49
+ keyId: string;
50
+ headers: {
51
+ Host: string;
52
+ Date: string;
53
+ Signature: string;
54
+ };
55
+ }, {
56
+ keyId: string;
57
+ headers: {
58
+ Host: string;
59
+ Date: string;
60
+ Signature: string;
61
+ };
62
+ }>;
63
+ export type InstanceFetchSignResponse = z.infer<typeof instanceFetchSignResponseSchema>;
@@ -0,0 +1,210 @@
1
+ /**
2
+ * Linking Commons to a passkey account (ADR 0029 D3) — the two-device relay.
3
+ *
4
+ * A passkey account links a Commons root once, and becomes self-custodied: its
5
+ * recovery email is deleted and its phrase in Commons is how it gets back in.
6
+ * The authority is the same as `POST /auth/link` (ADR 0024 D8): a root proof
7
+ * (`link_identity`) by the key Commons holds, and a fresh assertion by one of
8
+ * the account's passkeys over the SAME one-use challenge. Only the transport is
9
+ * new, because the two factors live on two devices:
10
+ *
11
+ * 1. auth.oxy.so (signed in) opens a link request → `{ linkId, challenge }`,
12
+ * shown as a QR (`oxycommons://link?id=…&c=…`).
13
+ * 2. Commons scans it, reads the request (the account's id and username),
14
+ * signs the root proof over the challenge and posts it with its key.
15
+ * 3. Both screens show the same 6-digit code, derived from the link id and
16
+ * that key (`deriveIdentityLinkCode` in `@oxy.so/core`); the person checks
17
+ * they match, so a photographed QR cannot slip another key in.
18
+ * 4. auth.oxy.so asserts the passkey over the challenge and completes: the
19
+ * account gains the root, loses the email, and Commons signs in with it.
20
+ *
21
+ * The server stores only the challenge's hash; the challenge travels in the QR.
22
+ */
23
+ import { z } from 'zod';
24
+ export declare const IDENTITY_LINK_STATUSES: readonly ["pending", "signed", "completed", "cancelled"];
25
+ export type IdentityLinkStatus = (typeof IDENTITY_LINK_STATUSES)[number];
26
+ /** The scheme and host Commons routes a link QR to. */
27
+ export declare const IDENTITY_LINK_QR_PREFIX = "oxycommons://link";
28
+ export declare const identityLinkIdSchema: z.ZodString;
29
+ /** The QR auth.oxy.so shows: the request's id and the challenge Commons signs. */
30
+ export declare function buildIdentityLinkQrPayload(linkId: string, challenge: string): string;
31
+ /** The request a scanned code names, or `null` for anything that is not a link QR. */
32
+ export declare function parseIdentityLinkQrPayload(raw: string): {
33
+ linkId: string;
34
+ challenge: string;
35
+ } | null;
36
+ /** `POST /identity/link` */
37
+ export interface IdentityLinkCreateResponse {
38
+ linkId: string;
39
+ /** The one-use `link_identity` proof challenge, hex. */
40
+ challenge: string;
41
+ /** Unix milliseconds. */
42
+ expiresAt: number;
43
+ qrPayload: string;
44
+ }
45
+ export declare const identityLinkCreateResponseSchema: z.ZodType<IdentityLinkCreateResponse>;
46
+ /** `GET /identity/link/:linkId` — what both devices poll. */
47
+ export interface IdentityLinkState {
48
+ status: IdentityLinkStatus;
49
+ /** The account being linked: the proof's subject and actor. */
50
+ userId: string;
51
+ username: string | null;
52
+ /** The key Commons signed with, once it has. */
53
+ publicKey: string | null;
54
+ audience: string;
55
+ expiresAt: number;
56
+ }
57
+ export declare const identityLinkStateSchema: z.ZodType<IdentityLinkState>;
58
+ /** `POST /identity/link/:linkId/proof` — from Commons, no bearer. */
59
+ export declare const identityLinkProofRequestSchema: z.ZodObject<{
60
+ publicKey: z.ZodString;
61
+ proof: z.ZodObject<{
62
+ v: z.ZodLiteral<2>;
63
+ challenge: z.ZodString;
64
+ expiresAt: z.ZodNumber;
65
+ signature: z.ZodString;
66
+ }, "strip", z.ZodTypeAny, {
67
+ expiresAt: number;
68
+ signature: string;
69
+ v: 2;
70
+ challenge: string;
71
+ }, {
72
+ expiresAt: number;
73
+ signature: string;
74
+ v: 2;
75
+ challenge: string;
76
+ }>;
77
+ }, "strict", z.ZodTypeAny, {
78
+ publicKey: string;
79
+ proof: {
80
+ expiresAt: number;
81
+ signature: string;
82
+ v: 2;
83
+ challenge: string;
84
+ };
85
+ }, {
86
+ publicKey: string;
87
+ proof: {
88
+ expiresAt: number;
89
+ signature: string;
90
+ v: 2;
91
+ challenge: string;
92
+ };
93
+ }>;
94
+ export type IdentityLinkProofRequest = z.infer<typeof identityLinkProofRequestSchema>;
95
+ /** `POST /identity/link/:linkId/options` — WebAuthn request options over the challenge. */
96
+ export declare const identityLinkOptionsRequestSchema: z.ZodObject<{
97
+ challenge: z.ZodString;
98
+ }, "strict", z.ZodTypeAny, {
99
+ challenge: string;
100
+ }, {
101
+ challenge: string;
102
+ }>;
103
+ export type IdentityLinkOptionsRequest = z.infer<typeof identityLinkOptionsRequestSchema>;
104
+ /** `POST /identity/link/:linkId/complete` — the passkey assertion over the challenge. */
105
+ export declare const identityLinkCompleteRequestSchema: z.ZodObject<{
106
+ assertion: z.ZodObject<{
107
+ id: z.ZodString;
108
+ rawId: z.ZodString;
109
+ type: z.ZodLiteral<"public-key">;
110
+ response: z.ZodObject<{
111
+ clientDataJSON: z.ZodString;
112
+ authenticatorData: z.ZodString;
113
+ signature: z.ZodString;
114
+ userHandle: z.ZodOptional<z.ZodString>;
115
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
116
+ clientDataJSON: z.ZodString;
117
+ authenticatorData: z.ZodString;
118
+ signature: z.ZodString;
119
+ userHandle: z.ZodOptional<z.ZodString>;
120
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
121
+ clientDataJSON: z.ZodString;
122
+ authenticatorData: z.ZodString;
123
+ signature: z.ZodString;
124
+ userHandle: z.ZodOptional<z.ZodString>;
125
+ }, z.ZodTypeAny, "passthrough">>;
126
+ clientExtensionResults: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
127
+ authenticatorAttachment: z.ZodOptional<z.ZodString>;
128
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
129
+ id: z.ZodString;
130
+ rawId: z.ZodString;
131
+ type: z.ZodLiteral<"public-key">;
132
+ response: z.ZodObject<{
133
+ clientDataJSON: z.ZodString;
134
+ authenticatorData: z.ZodString;
135
+ signature: z.ZodString;
136
+ userHandle: z.ZodOptional<z.ZodString>;
137
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
138
+ clientDataJSON: z.ZodString;
139
+ authenticatorData: z.ZodString;
140
+ signature: z.ZodString;
141
+ userHandle: z.ZodOptional<z.ZodString>;
142
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
143
+ clientDataJSON: z.ZodString;
144
+ authenticatorData: z.ZodString;
145
+ signature: z.ZodString;
146
+ userHandle: z.ZodOptional<z.ZodString>;
147
+ }, z.ZodTypeAny, "passthrough">>;
148
+ clientExtensionResults: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
149
+ authenticatorAttachment: z.ZodOptional<z.ZodString>;
150
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
151
+ id: z.ZodString;
152
+ rawId: z.ZodString;
153
+ type: z.ZodLiteral<"public-key">;
154
+ response: z.ZodObject<{
155
+ clientDataJSON: z.ZodString;
156
+ authenticatorData: z.ZodString;
157
+ signature: z.ZodString;
158
+ userHandle: z.ZodOptional<z.ZodString>;
159
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
160
+ clientDataJSON: z.ZodString;
161
+ authenticatorData: z.ZodString;
162
+ signature: z.ZodString;
163
+ userHandle: z.ZodOptional<z.ZodString>;
164
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
165
+ clientDataJSON: z.ZodString;
166
+ authenticatorData: z.ZodString;
167
+ signature: z.ZodString;
168
+ userHandle: z.ZodOptional<z.ZodString>;
169
+ }, z.ZodTypeAny, "passthrough">>;
170
+ clientExtensionResults: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
171
+ authenticatorAttachment: z.ZodOptional<z.ZodString>;
172
+ }, z.ZodTypeAny, "passthrough">>;
173
+ }, "strict", z.ZodTypeAny, {
174
+ assertion: {
175
+ type: "public-key";
176
+ id: string;
177
+ rawId: string;
178
+ response: {
179
+ signature: string;
180
+ clientDataJSON: string;
181
+ authenticatorData: string;
182
+ userHandle?: string | undefined;
183
+ } & {
184
+ [k: string]: unknown;
185
+ };
186
+ clientExtensionResults?: Record<string, unknown> | undefined;
187
+ authenticatorAttachment?: string | undefined;
188
+ } & {
189
+ [k: string]: unknown;
190
+ };
191
+ }, {
192
+ assertion: {
193
+ type: "public-key";
194
+ id: string;
195
+ rawId: string;
196
+ response: {
197
+ signature: string;
198
+ clientDataJSON: string;
199
+ authenticatorData: string;
200
+ userHandle?: string | undefined;
201
+ } & {
202
+ [k: string]: unknown;
203
+ };
204
+ clientExtensionResults?: Record<string, unknown> | undefined;
205
+ authenticatorAttachment?: string | undefined;
206
+ } & {
207
+ [k: string]: unknown;
208
+ };
209
+ }>;
210
+ export type IdentityLinkCompleteRequest = z.infer<typeof identityLinkCompleteRequestSchema>;