@oxy.so/contracts 4.16.0 → 4.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. package/dist/cjs/.tsbuildinfo +1 -1
  2. package/dist/cjs/accountEmail.js +12 -34
  3. package/dist/cjs/accountGraph.js +22 -320
  4. package/dist/cjs/agentKeys.js +11 -13
  5. package/dist/cjs/client/accountEmail.js +48 -0
  6. package/dist/cjs/client/accountGraph.js +323 -0
  7. package/dist/cjs/client/agentKeys.js +77 -0
  8. package/dist/cjs/client/check.js +466 -0
  9. package/dist/cjs/client/deviceBoot.js +22 -0
  10. package/dist/cjs/client/deviceDirectory.js +51 -0
  11. package/dist/cjs/client/deviceSession.js +63 -0
  12. package/dist/cjs/client/externalIdentity.js +19 -0
  13. package/dist/cjs/client/identity.js +45 -0
  14. package/dist/cjs/client/identityLink.js +55 -0
  15. package/dist/cjs/client/identityProof.js +109 -0
  16. package/dist/cjs/client/index.js +190 -0
  17. package/dist/cjs/client/organizations.js +114 -0
  18. package/dist/cjs/client/products.js +153 -0
  19. package/dist/cjs/client/recommendations.js +33 -0
  20. package/dist/cjs/client/reputation.js +41 -0
  21. package/dist/cjs/client/safety.js +15 -0
  22. package/dist/cjs/client/sessionStatus.js +23 -0
  23. package/dist/cjs/client/signIn.js +157 -0
  24. package/dist/cjs/client/userResponse.js +15 -0
  25. package/dist/cjs/client/username.js +173 -0
  26. package/dist/cjs/deviceSession.js +3 -16
  27. package/dist/cjs/identityLink.js +13 -34
  28. package/dist/cjs/identityProof.js +18 -106
  29. package/dist/cjs/organizations.js +21 -41
  30. package/dist/cjs/reputation.js +3 -34
  31. package/dist/cjs/signIn.js +33 -111
  32. package/dist/cjs/username.js +23 -158
  33. package/dist/esm/.tsbuildinfo +1 -1
  34. package/dist/esm/accountEmail.js +4 -32
  35. package/dist/esm/accountGraph.js +4 -309
  36. package/dist/esm/agentKeys.js +4 -10
  37. package/dist/esm/client/accountEmail.js +45 -0
  38. package/dist/esm/client/accountGraph.js +314 -0
  39. package/dist/esm/client/agentKeys.js +74 -0
  40. package/dist/esm/client/check.js +428 -0
  41. package/dist/esm/client/deviceBoot.js +19 -0
  42. package/dist/esm/client/deviceDirectory.js +48 -0
  43. package/dist/esm/client/deviceSession.js +60 -0
  44. package/dist/esm/client/externalIdentity.js +16 -0
  45. package/dist/esm/client/identity.js +42 -0
  46. package/dist/esm/client/identityLink.js +50 -0
  47. package/dist/esm/client/identityProof.js +104 -0
  48. package/dist/esm/client/index.js +37 -0
  49. package/dist/esm/client/organizations.js +111 -0
  50. package/dist/esm/client/products.js +150 -0
  51. package/dist/esm/client/recommendations.js +30 -0
  52. package/dist/esm/client/reputation.js +37 -0
  53. package/dist/esm/client/safety.js +12 -0
  54. package/dist/esm/client/sessionStatus.js +20 -0
  55. package/dist/esm/client/signIn.js +151 -0
  56. package/dist/esm/client/userResponse.js +12 -0
  57. package/dist/esm/client/username.js +167 -0
  58. package/dist/esm/deviceSession.js +1 -15
  59. package/dist/esm/identityLink.js +4 -27
  60. package/dist/esm/identityProof.js +4 -99
  61. package/dist/esm/organizations.js +4 -31
  62. package/dist/esm/reputation.js +1 -32
  63. package/dist/esm/signIn.js +4 -96
  64. package/dist/esm/username.js +4 -148
  65. package/dist/types/.tsbuildinfo +1 -1
  66. package/dist/types/accountEmail.d.ts +2 -34
  67. package/dist/types/accountGraph.d.ts +12 -208
  68. package/dist/types/agency.d.ts +24 -24
  69. package/dist/types/agentKeys.d.ts +8 -6
  70. package/dist/types/client/accountEmail.d.ts +44 -0
  71. package/dist/types/client/accountGraph.d.ts +203 -0
  72. package/dist/types/client/agentKeys.d.ts +113 -0
  73. package/dist/types/client/check.d.ts +184 -0
  74. package/dist/types/client/deviceBoot.d.ts +6 -0
  75. package/dist/types/client/deviceDirectory.d.ts +134 -0
  76. package/dist/types/client/deviceSession.d.ts +91 -0
  77. package/dist/types/client/externalIdentity.d.ts +14 -0
  78. package/dist/types/client/identity.d.ts +8 -0
  79. package/dist/types/client/identityLink.d.ts +21 -0
  80. package/dist/types/client/identityProof.d.ts +73 -0
  81. package/dist/types/client/index.d.ts +37 -0
  82. package/dist/types/client/organizations.d.ts +167 -0
  83. package/dist/types/client/products.d.ts +145 -0
  84. package/dist/types/client/recommendations.d.ts +27 -0
  85. package/dist/types/client/reputation.d.ts +28 -0
  86. package/dist/types/client/safety.d.ts +13 -0
  87. package/dist/types/client/sessionStatus.d.ts +19 -0
  88. package/dist/types/client/signIn.d.ts +107 -0
  89. package/dist/types/client/userResponse.d.ts +7 -0
  90. package/dist/types/client/username.d.ts +126 -0
  91. package/dist/types/deviceDirectory.d.ts +28 -28
  92. package/dist/types/deviceSession.d.ts +1 -12
  93. package/dist/types/externalIdentity.d.ts +11 -11
  94. package/dist/types/identityLink.d.ts +3 -11
  95. package/dist/types/identityProof.d.ts +2 -65
  96. package/dist/types/inference/decisions.d.ts +10 -10
  97. package/dist/types/inference/embeddings.d.ts +16 -16
  98. package/dist/types/inference/errors.d.ts +8 -8
  99. package/dist/types/inference/inbox.d.ts +8 -8
  100. package/dist/types/inference/privateAutoExecution.d.ts +6 -6
  101. package/dist/types/inference/realtime.d.ts +30 -30
  102. package/dist/types/inference/request.d.ts +28 -28
  103. package/dist/types/inference/streamEvents.d.ts +16 -16
  104. package/dist/types/inference/usage.d.ts +4 -4
  105. package/dist/types/oauth.d.ts +2 -2
  106. package/dist/types/organizations.d.ts +8 -10
  107. package/dist/types/products/billing.d.ts +3 -0
  108. package/dist/types/reputation.d.ts +1 -11
  109. package/dist/types/sessionStatus.d.ts +2 -2
  110. package/dist/types/signIn.d.ts +6 -89
  111. package/dist/types/userResponse.d.ts +20 -20
  112. package/dist/types/username.d.ts +1 -96
  113. package/package.json +20 -1
@@ -0,0 +1,145 @@
1
+ /**
2
+ * Product access, plans, checkout and subscription checks, without Zod.
3
+ * Schemas: `../products/*.ts`.
4
+ *
5
+ * Part of `@oxy.so/contracts/client`: never import `zod` here (see `./check.ts`).
6
+ */
7
+ export declare const subjectProductAccessQueryCheck: import("./check").Check<{
8
+ schemaVersion: 1;
9
+ subjectAccountId: string & import("zod").BRAND<"OxyAccountId">;
10
+ productId: string;
11
+ }>;
12
+ export declare const subjectProductAccessCheck: import("./check").Check<{
13
+ schemaVersion: 1;
14
+ subjectAccountId: string & import("zod").BRAND<"OxyAccountId">;
15
+ capabilities: {
16
+ key: string;
17
+ grantIds: string[];
18
+ }[];
19
+ evaluatedAt: string;
20
+ productId: string;
21
+ quotas: {
22
+ key: string;
23
+ unit: string;
24
+ included: number;
25
+ combination: "maximum" | "sum" | "exclusive";
26
+ grantIds: string[];
27
+ }[];
28
+ conflicts: {
29
+ key: string;
30
+ reason: "combination_mismatch" | "unit_mismatch" | "exclusive_overlap" | "unsafe_total";
31
+ grantIds: string[];
32
+ }[];
33
+ }>;
34
+ export declare const personalPlanCatalogueCheck: import("./check").Check<{
35
+ schemaVersion: 1;
36
+ state: "unconfigured" | "configured";
37
+ purchase: "unavailable";
38
+ plans: {
39
+ kind: "oxy_one";
40
+ displayName: string;
41
+ audience: "personal";
42
+ benefits: {
43
+ displayName: string;
44
+ benefit: {
45
+ kind: "capability";
46
+ key: string;
47
+ productId: string;
48
+ } | {
49
+ kind: "quota";
50
+ key: string;
51
+ unit: string;
52
+ included: number;
53
+ productId: string;
54
+ combination: "maximum" | "sum" | "exclusive";
55
+ };
56
+ }[];
57
+ offerId: string;
58
+ offerVersion: number;
59
+ price?: {
60
+ currency: string;
61
+ amountMinorUnits: number;
62
+ interval: "month";
63
+ trial: "none";
64
+ taxTreatment: "inclusive";
65
+ merchantTotal: "final";
66
+ } | undefined;
67
+ }[];
68
+ }>;
69
+ export declare const personalPlanCheckoutRequestCheck: import("./check").Check<{
70
+ idempotencyKey: string;
71
+ offerId: string;
72
+ offerVersion: number;
73
+ expectedSubjectAccountId: string & import("zod").BRAND<"OxyAccountId">;
74
+ }>;
75
+ export declare const personalPlanCheckoutResultCheck: import("./check").Check<{
76
+ reason: "provider_unconfigured" | "offer_unconfigured" | "price_unconfigured";
77
+ state: "unconfigured";
78
+ } | {
79
+ state: "pending";
80
+ intentId: string;
81
+ checkoutUrl?: string | undefined;
82
+ } | {
83
+ state: "closed";
84
+ intentId: string;
85
+ } | {
86
+ state: "fulfilled";
87
+ intentId: string;
88
+ }>;
89
+ export declare const productSubscriptionsResponseCheck: import("./check").Check<{
90
+ subscriptions: {
91
+ status: "active" | "incomplete" | "canceled" | "incomplete_expired" | "past_due" | "paused" | "trialing" | "unpaid";
92
+ sourceId: string;
93
+ cancelAtPeriodEnd: boolean;
94
+ period: {
95
+ start: string;
96
+ end: string;
97
+ };
98
+ canCancel: boolean;
99
+ offers: {
100
+ displayName: string;
101
+ period: {
102
+ start: string;
103
+ end: string;
104
+ };
105
+ offerId: string;
106
+ offerVersion: number;
107
+ origin: "bundle" | "individual";
108
+ segmentId: string;
109
+ current: boolean;
110
+ products: {
111
+ id: string;
112
+ displayName: string;
113
+ }[];
114
+ }[];
115
+ }[];
116
+ }>;
117
+ export declare const subscriptionCreditGrantsResponseCheck: import("./check").Check<{
118
+ grants: {
119
+ createdAt: string;
120
+ id: string;
121
+ granted: number;
122
+ remaining: number;
123
+ period: {
124
+ start: string;
125
+ end: string;
126
+ };
127
+ origin: "subscription_payment" | "subscription_proration" | "subscription_promotional_grant";
128
+ invoiceId: string;
129
+ consumed: number;
130
+ clawed: number;
131
+ promotionId: string | null;
132
+ }[];
133
+ }>;
134
+ export declare const cancelProductSubscriptionCheck: import("./check").Check<{
135
+ sourceId: string;
136
+ actionId?: string | undefined;
137
+ expectedSubjectAccountId?: (string & import("zod").BRAND<"OxyAccountId">) | undefined;
138
+ }>;
139
+ export declare const productSubscriptionCancellationResultCheck: import("./check").Check<{
140
+ sourceId: string;
141
+ cancelAtPeriodEnd: true;
142
+ } | {
143
+ sourceId: string;
144
+ reconciliationPending: true;
145
+ }>;
@@ -0,0 +1,27 @@
1
+ /**
2
+ * The recommendation-request check, without Zod. Schemas: `../recommendations.ts`.
3
+ *
4
+ * Part of `@oxy.so/contracts/client`: never import `zod` here (see `./check.ts`).
5
+ */
6
+ export declare const recommendationRequestCheck: import("./check").Check<{
7
+ limit?: number | undefined;
8
+ clientId?: string | undefined;
9
+ offset?: number | undefined;
10
+ excludeTypes?: ("agent" | "federated" | "automated")[] | undefined;
11
+ excludeIds?: string[] | undefined;
12
+ boosts?: {
13
+ userIds: string[];
14
+ weight: number;
15
+ reason?: string | undefined;
16
+ }[] | undefined;
17
+ signalWeights?: {
18
+ verified?: number | undefined;
19
+ graph?: number | undefined;
20
+ completeness?: number | undefined;
21
+ curation?: number | undefined;
22
+ interest?: number | undefined;
23
+ appBoost?: number | undefined;
24
+ repCandidate?: number | undefined;
25
+ affinity?: number | undefined;
26
+ } | undefined;
27
+ }>;
@@ -0,0 +1,28 @@
1
+ /**
2
+ * The reputation view guard, without Zod. Schemas: `../reputation.ts`.
3
+ *
4
+ * Part of `@oxy.so/contracts/client`: never import `zod` here (see `./check.ts`).
5
+ */
6
+ import type { ReputationBalance, ReputationBalanceView } from '../reputation';
7
+ /**
8
+ * The fields the full {@link ReputationBalance} carries beyond the public
9
+ * {@link ReputationBalanceSummary} that the API sends ALL-OR-NOTHING. The
10
+ * runtime discriminant between the two views.
11
+ *
12
+ * The V2 blocks (`conduct`, `contribution`, …) are deliberately NOT listed:
13
+ * they are optional on the wire, so requiring them here would make a balance
14
+ * from a server that predates them fail to narrow, hiding the whole private
15
+ * view. Read a V2 block by checking that block.
16
+ */
17
+ export declare const FULL_BALANCE_FIELDS: readonly ["positive", "negative", "breakdown", "influence", "reliability", "recalculatedAt", "updatedAt"];
18
+ /**
19
+ * Whether a balance came back as the SUBJECT view, and so carries the
20
+ * breakdown / influence / reliability blocks.
21
+ *
22
+ * Checks every extra field rather than one representative: the point of the
23
+ * guard is that the caller then dereferences those blocks, so a partial payload
24
+ * must not narrow.
25
+ *
26
+ * @param balance - A balance from `getReputationBalance`.
27
+ */
28
+ export declare function isFullReputationBalance(balance: ReputationBalanceView): balance is ReputationBalance;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Profile-access checks, without Zod. Schemas: `../safety.ts`.
3
+ *
4
+ * Part of `@oxy.so/contracts/client`: never import `zod` here (see `./check.ts`).
5
+ */
6
+ export declare const profileAccessInputCheck: import("./check").Check<{
7
+ subjectAccountId: string;
8
+ }>;
9
+ export declare const profileAccessDecisionCheck: import("./check").Check<{
10
+ allowed: boolean;
11
+ reason: "unavailable" | "owner" | "public" | "private" | "blocked";
12
+ policyVersion: "1";
13
+ }>;
@@ -0,0 +1,19 @@
1
+ /**
2
+ * The public-application check, without Zod. Schemas: `../sessionStatus.ts`.
3
+ *
4
+ * Part of `@oxy.so/contracts/client`: never import `zod` here (see `./check.ts`).
5
+ */
6
+ export declare const publicApplicationCheck: import("./check").Check<{
7
+ type: "system" | "internal" | "first_party" | "third_party";
8
+ name: string;
9
+ id: string;
10
+ scopes: string[];
11
+ isOfficial: boolean;
12
+ isInternal: boolean;
13
+ websiteUrl?: string | undefined;
14
+ description?: string | undefined;
15
+ icon?: string | undefined;
16
+ privacyPolicyUrl?: string | undefined;
17
+ termsUrl?: string | undefined;
18
+ developerName?: string | undefined;
19
+ }>;
@@ -0,0 +1,107 @@
1
+ /**
2
+ * Sign-in constants, guards and response checks, without Zod. Schemas: `../signIn.ts`.
3
+ *
4
+ * Part of `@oxy.so/contracts/client`: never import `zod` here (see `./check.ts`).
5
+ */
6
+ import type { EmailSignInChooseAccount, EmailSignInLinkResponse, EmailSignInPending, EmailSignInStartResponse, EmailSignInStepResult, SecondFactorRequired, SignInMethods, TotpBackupCodesResponse, TotpEnrollResponse } from '../signIn';
7
+ /** How long the link in a sign-in email can be opened. */
8
+ export declare const EMAIL_SIGNIN_LINK_TTL_MS: number;
9
+ /** How long a second-factor challenge can be answered. */
10
+ export declare const SIGNIN_SECOND_FACTOR_TTL_MS: number;
11
+ /** Wrong second-factor codes one challenge accepts. */
12
+ export declare const SIGNIN_SECOND_FACTOR_MAX_ATTEMPTS = 5;
13
+ /** Shortest password Oxy accepts when one is set. */
14
+ export declare const PASSWORD_MIN_LENGTH = 10;
15
+ /** Longest password Oxy accepts (characters). */
16
+ export declare const PASSWORD_MAX_LENGTH = 256;
17
+ /** Digits in an authenticator code. */
18
+ export declare const TOTP_DIGITS = 6;
19
+ /** Seconds each authenticator code lasts. */
20
+ export declare const TOTP_PERIOD_SECONDS = 30;
21
+ /** Backup codes issued when an authenticator is enabled or they are regenerated. */
22
+ export declare const TOTP_BACKUP_CODE_COUNT = 10;
23
+ /**
24
+ * The long sign-in code: ten characters of Crockford base32 without the
25
+ * look-alikes (no 0, O, 1, I, L, U), shown as `XXXXX-XXXXX`. An account whose
26
+ * sign-in codes were guessed at too often today (the per-account ceiling) is
27
+ * sent this instead of 6 digits for the rest of the day, so its owner can still
28
+ * type a code while guessing one is infeasible.
29
+ */
30
+ export declare const EMAIL_SIGNIN_LONG_CODE_ALPHABET = "23456789ABCDEFGHJKMNPQRSTVWXYZ";
31
+ export declare const EMAIL_SIGNIN_LONG_CODE_LENGTH = 10;
32
+ /**
33
+ * Normalise a typed sign-in code: 6 digits stay as they are; a long code is
34
+ * upper-cased with its dash and spaces removed. Anything else is returned
35
+ * trimmed (and will simply be wrong).
36
+ */
37
+ export declare function normalizeEmailSignInCode(code: string): string;
38
+ /**
39
+ * How long, once the email is proven, the person has to choose which of its
40
+ * accounts signs in.
41
+ */
42
+ export declare const EMAIL_SIGNIN_CHOICE_TTL_MS: number;
43
+ /** Most accounts one email can hold; sign-up refuses another past it. */
44
+ export declare const EMAIL_ACCOUNTS_MAX = 20;
45
+ /** Narrow a {@link SignInStepResult}. */
46
+ export declare function isSecondFactorRequired(result: EmailSignInStepResult | EmailSignInPending): result is SecondFactorRequired;
47
+ /** Narrow an {@link EmailSignInStepResult}. */
48
+ export declare function isEmailSignInChooseAccount(result: EmailSignInStepResult | EmailSignInPending): result is EmailSignInChooseAccount;
49
+ /**
50
+ * What a re-verification email code confirms. The code is bound to it: a code
51
+ * asked for one change never authorises another, and the email names it.
52
+ */
53
+ export declare const REAUTH_ACTIONS: readonly ["change_password", "totp", "link_commons", "delete_account", "credentials_manage"];
54
+ export type ReauthAction = (typeof REAUTH_ACTIONS)[number];
55
+ /**
56
+ * Stable error codes (`error.code` in the API error body). Clients map these
57
+ * through their localization, never the English message.
58
+ */
59
+ export declare const SIGN_IN_ERROR_CODES: {
60
+ /** Wrong identifier or password — never says which. */
61
+ readonly invalidCredentials: "SIGNIN_INVALID_CREDENTIALS";
62
+ /** The request is unknown, expired, spent, or its secret is wrong. */
63
+ readonly requestInvalid: "SIGNIN_REQUEST_INVALID";
64
+ /** The link is unknown, expired or already used. */
65
+ readonly linkInvalid: "SIGNIN_LINK_INVALID";
66
+ /** The link was opened in another browser: type the code in the app instead. */
67
+ readonly linkOtherDevice: "SIGNIN_LINK_OTHER_DEVICE";
68
+ /** The second-factor challenge or its code is wrong, expired or spent. */
69
+ readonly secondFactorInvalid: "SECOND_FACTOR_INVALID";
70
+ /** Too many failures for this account: wait and try again. */
71
+ readonly locked: "SIGNIN_LOCKED";
72
+ /** The step needs a fresh proof (`reauth`). */
73
+ readonly reauthRequired: "REAUTH_REQUIRED";
74
+ /** The fresh proof was wrong. */
75
+ readonly reauthInvalid: "REAUTH_INVALID";
76
+ /** The account has an authenticator: the proof must carry its code. */
77
+ readonly totpRequired: "TOTP_REQUIRED";
78
+ /** Enrolling or confirming an authenticator that is already on. */
79
+ readonly totpAlreadyEnabled: "TOTP_ALREADY_ENABLED";
80
+ /** Disabling, confirming or regenerating codes with no authenticator (or no pending one). */
81
+ readonly totpNotEnabled: "TOTP_NOT_ENABLED";
82
+ /** The code the authenticator showed at enrolment is wrong. */
83
+ readonly totpCodeInvalid: "TOTP_CODE_INVALID";
84
+ /** Only official Oxy apps and auth.oxy.so may sign people in here. */
85
+ readonly originNotAllowed: "SIGNIN_ORIGIN_NOT_ALLOWED";
86
+ /** The username is taken. */
87
+ readonly usernameTaken: "USERNAME_TAKEN";
88
+ /** The email already holds `EMAIL_ACCOUNTS_MAX` accounts: no sign-up adds another. */
89
+ readonly emailAccountsFull: "EMAIL_ACCOUNTS_FULL";
90
+ };
91
+ export type SignInErrorCode = (typeof SIGN_IN_ERROR_CODES)[keyof typeof SIGN_IN_ERROR_CODES];
92
+ export declare const emailSignInStartResponseCheck: import("./check").Check<EmailSignInStartResponse>;
93
+ export declare const emailSignInLinkResponseCheck: import("./check").Check<EmailSignInLinkResponse>;
94
+ export declare const secondFactorRequiredCheck: import("./check").Check<SecondFactorRequired>;
95
+ export declare const emailSignInPendingCheck: import("./check").Check<EmailSignInPending>;
96
+ export declare const emailSignInChooseAccountCheck: import("./check").Check<EmailSignInChooseAccount>;
97
+ export declare const signInMethodsCheck: import("./check").Check<SignInMethods>;
98
+ export declare const totpEnrollResponseCheck: import("./check").Check<TotpEnrollResponse>;
99
+ export declare const totpBackupCodesResponseCheck: import("./check").Check<TotpBackupCodesResponse>;
100
+ export declare const reauthProofCheck: import("./check").Check<{
101
+ password?: string | undefined;
102
+ emailCode?: {
103
+ code: string;
104
+ verificationId: string;
105
+ } | undefined;
106
+ totpCode?: string | undefined;
107
+ }>;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * User-response checks, without Zod. Schemas: `../userResponse.ts`.
3
+ *
4
+ * Part of `@oxy.so/contracts/client`: never import `zod` here (see `./check.ts`).
5
+ */
6
+ import type { UserNameResponse } from '../userResponse';
7
+ export declare const userNameCheck: import("./check").Check<UserNameResponse>;
@@ -0,0 +1,126 @@
1
+ /**
2
+ * The username policy, without Zod. Schemas: `../username.ts`.
3
+ *
4
+ * Part of `@oxy.so/contracts/client`: never import `zod` here (see `./check.ts`).
5
+ */
6
+ import type { AccountKind } from './accountGraph';
7
+ import { type Check } from './check';
8
+ /** Shortest storable handle. `oxy` sets the floor. */
9
+ export declare const USERNAME_MIN_LENGTH = 3;
10
+ /** Longest storable handle, and the `maxLength` an input field should carry. */
11
+ export declare const USERNAME_MAX_LENGTH = 30;
12
+ /** The 400 / inline-validation copy for every path that rejects a handle. */
13
+ export declare const USERNAME_INVALID_MESSAGE: string;
14
+ /**
15
+ * Exact-match handles nobody may newly claim, regardless of account kind.
16
+ *
17
+ * This is NOT a namespace tightening like the bot suffix — it is a list of
18
+ * names withheld from `users_lower_username_key` before anybody asks for
19
+ * them. Compared against the same normalization the unique index applies
20
+ * (`lower(btrim(username))`), so `Admin`, ` ADMIN ` and `admin` are the one
21
+ * name this list means.
22
+ *
23
+ * `oxy`, `mention`, `homiio`, `clarity`, `faircoin`, `astro` and `mercaria`
24
+ * are deliberately NOT here: each already has an `organization`/`project`
25
+ * row, so the unique index already refuses a second one, and `oxy` is the
26
+ * name `USERNAME_MIN_LENGTH` is pinned against in
27
+ * `__tests__/username.test.ts` — listing it would make
28
+ * `usernameSchema.safeParse('oxy')` fail and falsify that comment. A brand
29
+ * with no account of its own yet (measured 2026-09-18: Alia, Allo, TNP,
30
+ * Kaana, Bloom) has no row to protect it, so it is listed until one exists.
31
+ */
32
+ export declare const RESERVED_USERNAMES: ReadonlySet<string>;
33
+ /** The 400 / inline-validation copy for a handle on {@link RESERVED_USERNAMES}. */
34
+ export declare const RESERVED_USERNAME_MESSAGE = "This username is reserved and cannot be registered";
35
+ /**
36
+ * {@link RESERVED_USERNAMES}, minus `alia`, checked against each `-`/`_`
37
+ * separated SEGMENT of a candidate rather than the whole string — so
38
+ * `official-oxy`, `super-admin` and `team-kaana` are refused the same as the
39
+ * bare words, without banning every word that merely CONTAINS one as a
40
+ * substring (`superman`, `modern`, `grassroot`, `homeowner` all stay legal:
41
+ * none of them separates the reserved word from the rest with `-` or `_`).
42
+ *
43
+ * `alia` is excluded because `alia-` is the live internal-cost-centre
44
+ * namespace: `alia-production-chat` is a minted account and
45
+ * `alia-research` / `alia-voice` / `alia-evaluations` are pinned as legal
46
+ * slugs in `__tests__/username.test.ts` and `internalCostCenterSpecs.test.ts`.
47
+ * Segment-matching `alia` would refuse all four. The bare word `alia` is
48
+ * still refused — {@link RESERVED_USERNAMES} above catches it exactly.
49
+ */
50
+ export declare const RESERVED_USERNAME_SEGMENTS: ReadonlySet<string>;
51
+ /** The 400 / inline-validation copy for a handle that is only digits. */
52
+ export declare const NUMERIC_USERNAME_MESSAGE = "Username cannot be only numbers";
53
+ /**
54
+ * Alphanumeric runs joined by single separators, as a SOURCE string.
55
+ *
56
+ * A string rather than a literal because the OpenAPI docblocks that publish this
57
+ * rule (`POST /auth/register`, `PUT /users/:userId`) must quote it verbatim, and
58
+ * `usernamePolicySingleSource.test.ts` compares them against THIS constant. A
59
+ * published `pattern:` that drifts from the enforced rule is a lie told to every
60
+ * client that generates from the spec, and it is exactly the kind of copy nobody
61
+ * notices going stale.
62
+ *
63
+ * Deliberately NOT re-exported from the package barrel: it exists for the
64
+ * schema below and for that one gate. Anything validating a username uses
65
+ * {@link usernameSchema}, so there is no second way to ask the question.
66
+ *
67
+ * Written as an unambiguous alternation rather than a lookahead: every character
68
+ * belongs to exactly one branch, so matching is linear and there is no
69
+ * backtracking to bound. It also carries no `\p{…}` property escape, which
70
+ * mobile Hermes throws on at runtime — this module is reachable from every React
71
+ * Native consumer.
72
+ */
73
+ export declare const USERNAME_PATTERN_SOURCE = "^[A-Za-z0-9]+(?:[-_][A-Za-z0-9]+)*$";
74
+ export declare const USERNAME_PATTERN: RegExp;
75
+ /**
76
+ * Drop the characters the policy forbids, for an input field that filters
77
+ * keystrokes.
78
+ *
79
+ * This is a TYPING aid and nothing else — the result still has to pass
80
+ * {@link usernameSchema}, which is what decides. It does not lower-case (case is
81
+ * preserved, see the header) and it cannot repair a name: a value that is too
82
+ * short, edge-separated or doubly-separated comes back unchanged and fails
83
+ * validation with a message, which is the outcome the coercing rules this
84
+ * replaces used to hide.
85
+ */
86
+ export declare function stripDisallowedUsernameCharacters(input: string): string;
87
+ /**
88
+ * The label a bot's handle ends in — the ONE exception the policy carries.
89
+ *
90
+ * Lower-case here because it is what a generator appends; the comparison that
91
+ * enforces it folds case, so `MyBot` satisfies it just as `mybot` does.
92
+ *
93
+ * Deliberately NOT re-exported from the package barrel, for the same reason
94
+ * {@link USERNAME_PATTERN_SOURCE} is not: it exists for the schema and the
95
+ * generator aid below. A consumer that wants to SAY the rule uses
96
+ * {@link BOT_USERNAME_INVALID_MESSAGE}, which already quotes it, and one that
97
+ * wants to APPLY it uses {@link applyBotUsernameSuffix} — so there is no second
98
+ * way to spell the check.
99
+ */
100
+ export declare const BOT_USERNAME_SUFFIX = "bot";
101
+ /** The 400 / inline-validation copy for a bot handle that carries no label. */
102
+ export declare const BOT_USERNAME_INVALID_MESSAGE = "A bot account's username must end in \"bot\"";
103
+ /**
104
+ * Label a proposed bot handle, so a generator PROPOSES something the server will
105
+ * accept.
106
+ *
107
+ * Alia builds an agent's handle from its display name; without this it would
108
+ * propose `garden-helper` for a bot and be 400ed on submit, which is the same
109
+ * "suggest, then refuse" defect the minimum length already caused once.
110
+ *
111
+ * It appends and never inserts: a separator is the caller's choice, so
112
+ * `garden-helper` becomes `garden-helperbot` while a caller who typed
113
+ * `garden-helper-` gets `garden-helper-bot`. It truncates to leave room rather
114
+ * than overflowing {@link USERNAME_MAX_LENGTH}.
115
+ *
116
+ * Like {@link stripDisallowedUsernameCharacters} it is an aid, not a decision: it
117
+ * cannot repair a handle the base policy refuses, and the result still has to
118
+ * pass {@link botUsernameSchema}.
119
+ */
120
+ export declare function applyBotUsernameSuffix(candidate: string): string;
121
+ /** The username policy as a check — the twin of `usernameSchema`, same messages. */
122
+ export declare const usernameCheck: Check<string>;
123
+ /** A bot's username: the policy plus the `bot` suffix — the twin of `botUsernameSchema`. */
124
+ export declare const botUsernameCheck: Check<string>;
125
+ /** The twin of `usernameSchemaForAccountKind`. */
126
+ export declare function usernameCheckForAccountKind(kind: AccountKind | null | undefined): Check<string>;