@oxy.so/contracts 4.16.0 → 4.21.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.
- package/dist/cjs/accountAccess.js +72 -0
- package/dist/cjs/accountEmail.js +12 -34
- package/dist/cjs/accountGraph.js +22 -320
- package/dist/cjs/agency.js +112 -1
- package/dist/cjs/agentKeys.js +11 -13
- package/dist/cjs/applicationRoles.js +211 -0
- package/dist/cjs/client/accountEmail.js +48 -0
- package/dist/cjs/client/accountGraph.js +323 -0
- package/dist/cjs/client/agentKeys.js +77 -0
- package/dist/cjs/client/check.js +475 -0
- package/dist/cjs/client/deviceBoot.js +22 -0
- package/dist/cjs/client/deviceDirectory.js +51 -0
- package/dist/cjs/client/deviceSession.js +63 -0
- package/dist/cjs/client/externalIdentity.js +19 -0
- package/dist/cjs/client/identity.js +45 -0
- package/dist/cjs/client/identityLink.js +55 -0
- package/dist/cjs/client/identityProof.js +109 -0
- package/dist/cjs/client/index.js +211 -0
- package/dist/cjs/client/organizations.js +114 -0
- package/dist/cjs/client/products.js +153 -0
- package/dist/cjs/client/recommendations.js +33 -0
- package/dist/cjs/client/reputation.js +41 -0
- package/dist/cjs/client/safety.js +196 -0
- package/dist/cjs/client/sessionStatus.js +23 -0
- package/dist/cjs/client/signIn.js +159 -0
- package/dist/cjs/client/userResponse.js +15 -0
- package/dist/cjs/client/username.js +173 -0
- package/dist/cjs/deviceSession.js +3 -16
- package/dist/cjs/identityLink.js +13 -34
- package/dist/cjs/identityProof.js +18 -106
- package/dist/cjs/index.js +13 -3
- package/dist/cjs/organizations.js +21 -41
- package/dist/cjs/reputation.js +3 -34
- package/dist/cjs/safety.js +430 -1
- package/dist/cjs/serviceToken.js +14 -0
- package/dist/cjs/signIn.js +33 -111
- package/dist/cjs/username.js +23 -158
- package/dist/esm/accountAccess.js +69 -0
- package/dist/esm/accountEmail.js +4 -32
- package/dist/esm/accountGraph.js +4 -309
- package/dist/esm/agency.js +111 -0
- package/dist/esm/agentKeys.js +4 -10
- package/dist/esm/applicationRoles.js +207 -0
- package/dist/esm/client/accountEmail.js +45 -0
- package/dist/esm/client/accountGraph.js +314 -0
- package/dist/esm/client/agentKeys.js +74 -0
- package/dist/esm/client/check.js +436 -0
- package/dist/esm/client/deviceBoot.js +19 -0
- package/dist/esm/client/deviceDirectory.js +48 -0
- package/dist/esm/client/deviceSession.js +60 -0
- package/dist/esm/client/externalIdentity.js +16 -0
- package/dist/esm/client/identity.js +42 -0
- package/dist/esm/client/identityLink.js +50 -0
- package/dist/esm/client/identityProof.js +104 -0
- package/dist/esm/client/index.js +37 -0
- package/dist/esm/client/organizations.js +111 -0
- package/dist/esm/client/products.js +150 -0
- package/dist/esm/client/recommendations.js +30 -0
- package/dist/esm/client/reputation.js +37 -0
- package/dist/esm/client/safety.js +193 -0
- package/dist/esm/client/sessionStatus.js +20 -0
- package/dist/esm/client/signIn.js +153 -0
- package/dist/esm/client/userResponse.js +12 -0
- package/dist/esm/client/username.js +167 -0
- package/dist/esm/deviceSession.js +1 -15
- package/dist/esm/identityLink.js +4 -27
- package/dist/esm/identityProof.js +4 -99
- package/dist/esm/index.js +4 -1
- package/dist/esm/organizations.js +4 -31
- package/dist/esm/reputation.js +1 -32
- package/dist/esm/safety.js +423 -0
- package/dist/esm/serviceToken.js +11 -0
- package/dist/esm/signIn.js +4 -96
- package/dist/esm/username.js +4 -148
- package/dist/types/accountAccess.d.ts +128 -0
- package/dist/types/accountEmail.d.ts +4 -36
- package/dist/types/accountGraph.d.ts +12 -208
- package/dist/types/agency.d.ts +351 -26
- package/dist/types/agentKeys.d.ts +14 -12
- package/dist/types/applicationRoles.d.ts +438 -0
- package/dist/types/client/accountEmail.d.ts +44 -0
- package/dist/types/client/accountGraph.d.ts +203 -0
- package/dist/types/client/agentKeys.d.ts +113 -0
- package/dist/types/client/check.d.ts +187 -0
- package/dist/types/client/deviceBoot.d.ts +6 -0
- package/dist/types/client/deviceDirectory.d.ts +134 -0
- package/dist/types/client/deviceSession.d.ts +91 -0
- package/dist/types/client/externalIdentity.d.ts +14 -0
- package/dist/types/client/identity.d.ts +8 -0
- package/dist/types/client/identityLink.d.ts +21 -0
- package/dist/types/client/identityProof.d.ts +73 -0
- package/dist/types/client/index.d.ts +37 -0
- package/dist/types/client/organizations.d.ts +167 -0
- package/dist/types/client/products.d.ts +145 -0
- package/dist/types/client/recommendations.d.ts +27 -0
- package/dist/types/client/reputation.d.ts +28 -0
- package/dist/types/client/safety.d.ts +213 -0
- package/dist/types/client/sessionStatus.d.ts +19 -0
- package/dist/types/client/signIn.d.ts +107 -0
- package/dist/types/client/userResponse.d.ts +7 -0
- package/dist/types/client/username.d.ts +126 -0
- package/dist/types/deviceDirectory.d.ts +28 -28
- package/dist/types/deviceSession.d.ts +5 -16
- package/dist/types/email/messages.d.ts +2 -2
- package/dist/types/externalIdentity.d.ts +15 -15
- package/dist/types/identityLink.d.ts +3 -11
- package/dist/types/identityProof.d.ts +2 -65
- package/dist/types/index.d.ts +5 -2
- package/dist/types/inference/accountBilling.d.ts +2 -2
- package/dist/types/inference/catalogue.d.ts +22 -22
- package/dist/types/inference/decisions.d.ts +10 -10
- package/dist/types/inference/embeddings.d.ts +16 -16
- package/dist/types/inference/errors.d.ts +8 -8
- package/dist/types/inference/inbox.d.ts +8 -8
- package/dist/types/inference/privateAutoExecution.d.ts +6 -6
- package/dist/types/inference/providerConnection.d.ts +4 -4
- package/dist/types/inference/realtime.d.ts +92 -92
- package/dist/types/inference/request.d.ts +48 -48
- package/dist/types/inference/streamEvents.d.ts +16 -16
- package/dist/types/inference/usage.d.ts +4 -4
- package/dist/types/oauth.d.ts +2 -2
- package/dist/types/organizations.d.ts +8 -10
- package/dist/types/products/access.d.ts +4 -4
- package/dist/types/products/billing.d.ts +3 -0
- package/dist/types/reputation.d.ts +1 -11
- package/dist/types/safety.d.ts +2374 -2
- package/dist/types/serviceToken.d.ts +11 -0
- package/dist/types/sessionStatus.d.ts +2 -2
- package/dist/types/signIn.d.ts +11 -94
- package/dist/types/userResponse.d.ts +22 -22
- package/dist/types/username.d.ts +1 -96
- package/package.json +24 -20
- package/dist/cjs/.tsbuildinfo +0 -1
- package/dist/esm/.tsbuildinfo +0 -1
- package/dist/types/.tsbuildinfo +0 -1
package/dist/esm/username.js
CHANGED
|
@@ -99,100 +99,10 @@
|
|
|
99
99
|
* knows what is taken, and it must not pretend to.
|
|
100
100
|
*/
|
|
101
101
|
import { z } from 'zod';
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
export
|
|
106
|
-
/** The 400 / inline-validation copy for every path that rejects a handle. */
|
|
107
|
-
export const USERNAME_INVALID_MESSAGE = 'Username must be 3-30 characters, use only letters, numbers, hyphens and underscores, ' +
|
|
108
|
-
'start and end with a letter or number, and never repeat a separator';
|
|
109
|
-
/**
|
|
110
|
-
* Exact-match handles nobody may newly claim, regardless of account kind.
|
|
111
|
-
*
|
|
112
|
-
* This is NOT a namespace tightening like the bot suffix — it is a list of
|
|
113
|
-
* names withheld from `users_lower_username_key` before anybody asks for
|
|
114
|
-
* them. Compared against the same normalization the unique index applies
|
|
115
|
-
* (`lower(btrim(username))`), so `Admin`, ` ADMIN ` and `admin` are the one
|
|
116
|
-
* name this list means.
|
|
117
|
-
*
|
|
118
|
-
* `oxy`, `mention`, `homiio`, `clarity`, `faircoin`, `astro` and `mercaria`
|
|
119
|
-
* are deliberately NOT here: each already has an `organization`/`project`
|
|
120
|
-
* row, so the unique index already refuses a second one, and `oxy` is the
|
|
121
|
-
* name `USERNAME_MIN_LENGTH` is pinned against in
|
|
122
|
-
* `__tests__/username.test.ts` — listing it would make
|
|
123
|
-
* `usernameSchema.safeParse('oxy')` fail and falsify that comment. A brand
|
|
124
|
-
* with no account of its own yet (measured 2026-09-18: Alia, Allo, TNP,
|
|
125
|
-
* Kaana, Bloom) has no row to protect it, so it is listed until one exists.
|
|
126
|
-
*/
|
|
127
|
-
export const RESERVED_USERNAMES = new Set([
|
|
128
|
-
// Oxy product lines with no account row of their own yet.
|
|
129
|
-
'alia',
|
|
130
|
-
'allo',
|
|
131
|
-
'tnp',
|
|
132
|
-
'kaana',
|
|
133
|
-
'bloom',
|
|
134
|
-
// System / role words a signup impersonating staff or Oxy itself would reach for.
|
|
135
|
-
'admin',
|
|
136
|
-
'administrator',
|
|
137
|
-
'root',
|
|
138
|
-
'superadmin',
|
|
139
|
-
'super',
|
|
140
|
-
'superuser',
|
|
141
|
-
'support',
|
|
142
|
-
'staff',
|
|
143
|
-
'moderator',
|
|
144
|
-
'mod',
|
|
145
|
-
'security',
|
|
146
|
-
'system',
|
|
147
|
-
'official',
|
|
148
|
-
'help',
|
|
149
|
-
'noreply',
|
|
150
|
-
'anonymous',
|
|
151
|
-
'everyone',
|
|
152
|
-
'owner',
|
|
153
|
-
]);
|
|
154
|
-
/** The 400 / inline-validation copy for a handle on {@link RESERVED_USERNAMES}. */
|
|
155
|
-
export const RESERVED_USERNAME_MESSAGE = 'This username is reserved and cannot be registered';
|
|
156
|
-
/**
|
|
157
|
-
* {@link RESERVED_USERNAMES}, minus `alia`, checked against each `-`/`_`
|
|
158
|
-
* separated SEGMENT of a candidate rather than the whole string — so
|
|
159
|
-
* `official-oxy`, `super-admin` and `team-kaana` are refused the same as the
|
|
160
|
-
* bare words, without banning every word that merely CONTAINS one as a
|
|
161
|
-
* substring (`superman`, `modern`, `grassroot`, `homeowner` all stay legal:
|
|
162
|
-
* none of them separates the reserved word from the rest with `-` or `_`).
|
|
163
|
-
*
|
|
164
|
-
* `alia` is excluded because `alia-` is the live internal-cost-centre
|
|
165
|
-
* namespace: `alia-production-chat` is a minted account and
|
|
166
|
-
* `alia-research` / `alia-voice` / `alia-evaluations` are pinned as legal
|
|
167
|
-
* slugs in `__tests__/username.test.ts` and `internalCostCenterSpecs.test.ts`.
|
|
168
|
-
* Segment-matching `alia` would refuse all four. The bare word `alia` is
|
|
169
|
-
* still refused — {@link RESERVED_USERNAMES} above catches it exactly.
|
|
170
|
-
*/
|
|
171
|
-
const RESERVED_USERNAME_SEGMENTS = new Set([...RESERVED_USERNAMES].filter((word) => word !== 'alia'));
|
|
172
|
-
/** The 400 / inline-validation copy for a handle that is only digits. */
|
|
173
|
-
export const NUMERIC_USERNAME_MESSAGE = 'Username cannot be only numbers';
|
|
174
|
-
/**
|
|
175
|
-
* Alphanumeric runs joined by single separators, as a SOURCE string.
|
|
176
|
-
*
|
|
177
|
-
* A string rather than a literal because the OpenAPI docblocks that publish this
|
|
178
|
-
* rule (`POST /auth/register`, `PUT /users/:userId`) must quote it verbatim, and
|
|
179
|
-
* `usernamePolicySingleSource.test.ts` compares them against THIS constant. A
|
|
180
|
-
* published `pattern:` that drifts from the enforced rule is a lie told to every
|
|
181
|
-
* client that generates from the spec, and it is exactly the kind of copy nobody
|
|
182
|
-
* notices going stale.
|
|
183
|
-
*
|
|
184
|
-
* Deliberately NOT re-exported from the package barrel: it exists for the
|
|
185
|
-
* schema below and for that one gate. Anything validating a username uses
|
|
186
|
-
* {@link usernameSchema}, so there is no second way to ask the question.
|
|
187
|
-
*
|
|
188
|
-
* Written as an unambiguous alternation rather than a lookahead: every character
|
|
189
|
-
* belongs to exactly one branch, so matching is linear and there is no
|
|
190
|
-
* backtracking to bound. It also carries no `\p{…}` property escape, which
|
|
191
|
-
* mobile Hermes throws on at runtime — this module is reachable from every React
|
|
192
|
-
* Native consumer.
|
|
193
|
-
*/
|
|
194
|
-
export const USERNAME_PATTERN_SOURCE = '^[A-Za-z0-9]+(?:[-_][A-Za-z0-9]+)*$';
|
|
195
|
-
const USERNAME_PATTERN = new RegExp(USERNAME_PATTERN_SOURCE);
|
|
102
|
+
// The Zod-free half of this contract lives in `./client/` (`@oxy.so/contracts/client`);
|
|
103
|
+
// it is re-exported here so the root entry is unchanged.
|
|
104
|
+
import { USERNAME_MIN_LENGTH, USERNAME_MAX_LENGTH, USERNAME_INVALID_MESSAGE, RESERVED_USERNAMES, RESERVED_USERNAME_MESSAGE, NUMERIC_USERNAME_MESSAGE, BOT_USERNAME_SUFFIX, BOT_USERNAME_INVALID_MESSAGE, RESERVED_USERNAME_SEGMENTS, USERNAME_PATTERN, } from './client/username.js';
|
|
105
|
+
export { USERNAME_MIN_LENGTH, USERNAME_MAX_LENGTH, USERNAME_INVALID_MESSAGE, RESERVED_USERNAMES, RESERVED_USERNAME_MESSAGE, NUMERIC_USERNAME_MESSAGE, USERNAME_PATTERN_SOURCE, stripDisallowedUsernameCharacters, BOT_USERNAME_SUFFIX, BOT_USERNAME_INVALID_MESSAGE, applyBotUsernameSuffix, } from './client/username.js';
|
|
196
106
|
/**
|
|
197
107
|
* The one username policy, as a schema.
|
|
198
108
|
*
|
|
@@ -223,36 +133,6 @@ export const usernameSchema = z
|
|
|
223
133
|
export function isValidUsername(candidate) {
|
|
224
134
|
return usernameSchema.safeParse(candidate).success;
|
|
225
135
|
}
|
|
226
|
-
/**
|
|
227
|
-
* Drop the characters the policy forbids, for an input field that filters
|
|
228
|
-
* keystrokes.
|
|
229
|
-
*
|
|
230
|
-
* This is a TYPING aid and nothing else — the result still has to pass
|
|
231
|
-
* {@link usernameSchema}, which is what decides. It does not lower-case (case is
|
|
232
|
-
* preserved, see the header) and it cannot repair a name: a value that is too
|
|
233
|
-
* short, edge-separated or doubly-separated comes back unchanged and fails
|
|
234
|
-
* validation with a message, which is the outcome the coercing rules this
|
|
235
|
-
* replaces used to hide.
|
|
236
|
-
*/
|
|
237
|
-
export function stripDisallowedUsernameCharacters(input) {
|
|
238
|
-
return input.replace(/[^A-Za-z0-9_-]/g, '');
|
|
239
|
-
}
|
|
240
|
-
/**
|
|
241
|
-
* The label a bot's handle ends in — the ONE exception the policy carries.
|
|
242
|
-
*
|
|
243
|
-
* Lower-case here because it is what a generator appends; the comparison that
|
|
244
|
-
* enforces it folds case, so `MyBot` satisfies it just as `mybot` does.
|
|
245
|
-
*
|
|
246
|
-
* Deliberately NOT re-exported from the package barrel, for the same reason
|
|
247
|
-
* {@link USERNAME_PATTERN_SOURCE} is not: it exists for the schema and the
|
|
248
|
-
* generator aid below. A consumer that wants to SAY the rule uses
|
|
249
|
-
* {@link BOT_USERNAME_INVALID_MESSAGE}, which already quotes it, and one that
|
|
250
|
-
* wants to APPLY it uses {@link applyBotUsernameSuffix} — so there is no second
|
|
251
|
-
* way to spell the check.
|
|
252
|
-
*/
|
|
253
|
-
export const BOT_USERNAME_SUFFIX = 'bot';
|
|
254
|
-
/** The 400 / inline-validation copy for a bot handle that carries no label. */
|
|
255
|
-
export const BOT_USERNAME_INVALID_MESSAGE = `A bot account's username must end in "${BOT_USERNAME_SUFFIX}"`;
|
|
256
136
|
/**
|
|
257
137
|
* The username policy for an account of kind `bot`: everything above, plus a
|
|
258
138
|
* handle that ends in {@link BOT_USERNAME_SUFFIX}.
|
|
@@ -327,27 +207,3 @@ export const botUsernameSchema = usernameSchema.refine((username) => username.to
|
|
|
327
207
|
export function usernameSchemaForAccountKind(kind) {
|
|
328
208
|
return kind === 'bot' ? botUsernameSchema : usernameSchema;
|
|
329
209
|
}
|
|
330
|
-
/**
|
|
331
|
-
* Label a proposed bot handle, so a generator PROPOSES something the server will
|
|
332
|
-
* accept.
|
|
333
|
-
*
|
|
334
|
-
* Alia builds an agent's handle from its display name; without this it would
|
|
335
|
-
* propose `garden-helper` for a bot and be 400ed on submit, which is the same
|
|
336
|
-
* "suggest, then refuse" defect the minimum length already caused once.
|
|
337
|
-
*
|
|
338
|
-
* It appends and never inserts: a separator is the caller's choice, so
|
|
339
|
-
* `garden-helper` becomes `garden-helperbot` while a caller who typed
|
|
340
|
-
* `garden-helper-` gets `garden-helper-bot`. It truncates to leave room rather
|
|
341
|
-
* than overflowing {@link USERNAME_MAX_LENGTH}.
|
|
342
|
-
*
|
|
343
|
-
* Like {@link stripDisallowedUsernameCharacters} it is an aid, not a decision: it
|
|
344
|
-
* cannot repair a handle the base policy refuses, and the result still has to
|
|
345
|
-
* pass {@link botUsernameSchema}.
|
|
346
|
-
*/
|
|
347
|
-
export function applyBotUsernameSuffix(candidate) {
|
|
348
|
-
const trimmed = candidate.trim();
|
|
349
|
-
if (trimmed.toLowerCase().endsWith(BOT_USERNAME_SUFFIX)) {
|
|
350
|
-
return trimmed;
|
|
351
|
-
}
|
|
352
|
-
return trimmed.slice(0, USERNAME_MAX_LENGTH - BOT_USERNAME_SUFFIX.length) + BOT_USERNAME_SUFFIX;
|
|
353
|
-
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wire contract for `GET /internal/accounts/:accountId/access/:userId`: Oxy
|
|
3
|
+
* answers a trusted first-party service's question "may this person act FOR
|
|
4
|
+
* that account, and with what?" with no session of that person in the request.
|
|
5
|
+
*
|
|
6
|
+
* It exists for the account Oxy never lets anybody act AS: a `channel`
|
|
7
|
+
* ({@link isDelegatedActAsEligibleKind} refuses it). An app publishes to a
|
|
8
|
+
* channel with ITS OWN credential, on behalf of a member Oxy vouches for here,
|
|
9
|
+
* so nobody holds a bearer that speaks as the channel. A long-running import
|
|
10
|
+
* (Oxy Move) has only a service token and `X-Oxy-User-Id`, which the
|
|
11
|
+
* user-facing `GET /accounts/:id/members` refuses; this is its answer.
|
|
12
|
+
*
|
|
13
|
+
* Needs a service token whose application is platform-trusted AND holds the
|
|
14
|
+
* privileged {@link ACCOUNTS_MEMBERSHIP_READ_SCOPE}. The answer is always 200:
|
|
15
|
+
* `access` is `null` for no active membership, an archived account, an unknown
|
|
16
|
+
* account and an unclaimed directory account alike. Callers must treat every
|
|
17
|
+
* other status as a refusal (fail closed), and must not cache the answer longer
|
|
18
|
+
* than the action it authorizes.
|
|
19
|
+
*
|
|
20
|
+
* Platform-agnostic — zod only.
|
|
21
|
+
*/
|
|
22
|
+
import { z } from 'zod';
|
|
23
|
+
/**
|
|
24
|
+
* The scope the endpoint requires.
|
|
25
|
+
*
|
|
26
|
+
* Privileged (staff-granted). Channel membership is sensitive because a channel
|
|
27
|
+
* is anonymous: its members are the people behind a voice that is published
|
|
28
|
+
* without their names, and "is this person a member of that channel" is
|
|
29
|
+
* exactly the fact the channel exists to withhold.
|
|
30
|
+
*/
|
|
31
|
+
export declare const ACCOUNTS_MEMBERSHIP_READ_SCOPE: "accounts:membership:read";
|
|
32
|
+
/**
|
|
33
|
+
* Where the access comes from.
|
|
34
|
+
*
|
|
35
|
+
* - `self` — the person IS the account (a personal account asked about itself).
|
|
36
|
+
* - `direct` — an active membership row on the account.
|
|
37
|
+
* - `inherited` — an active, cascading membership on an ancestor account.
|
|
38
|
+
*/
|
|
39
|
+
export declare const ACCOUNT_ACCESS_SOURCES: readonly ["self", "direct", "inherited"];
|
|
40
|
+
export type AccountAccessSource = (typeof ACCOUNT_ACCESS_SOURCES)[number];
|
|
41
|
+
export declare const accountAccessSourceSchema: z.ZodEnum<["self", "direct", "inherited"]>;
|
|
42
|
+
/**
|
|
43
|
+
* One person's EFFECTIVE access over one account.
|
|
44
|
+
*
|
|
45
|
+
* `role` and `permissions` are strings rather than closed enums on purpose: the
|
|
46
|
+
* role and permission vocabularies are the API's, they grow, and a consumer
|
|
47
|
+
* pinned to an older contracts release must keep reading new ones. Gate on
|
|
48
|
+
* `permissions` (the role's baseline adjusted by per-member grants and
|
|
49
|
+
* revokes), never on `role`.
|
|
50
|
+
*/
|
|
51
|
+
export declare const accountAccessGrantSchema: z.ZodObject<{
|
|
52
|
+
role: z.ZodString;
|
|
53
|
+
permissions: z.ZodArray<z.ZodString, "many">;
|
|
54
|
+
/** Only an active membership grants access, so this is the one value. */
|
|
55
|
+
status: z.ZodLiteral<"active">;
|
|
56
|
+
source: z.ZodEnum<["self", "direct", "inherited"]>;
|
|
57
|
+
}, "strip", z.ZodTypeAny, {
|
|
58
|
+
status: "active";
|
|
59
|
+
role: string;
|
|
60
|
+
permissions: string[];
|
|
61
|
+
source: "self" | "direct" | "inherited";
|
|
62
|
+
}, {
|
|
63
|
+
status: "active";
|
|
64
|
+
role: string;
|
|
65
|
+
permissions: string[];
|
|
66
|
+
source: "self" | "direct" | "inherited";
|
|
67
|
+
}>;
|
|
68
|
+
export type AccountAccessGrant = z.infer<typeof accountAccessGrantSchema>;
|
|
69
|
+
export declare const accountAccessVerdictSchema: z.ZodEffects<z.ZodObject<{
|
|
70
|
+
accountId: z.ZodString;
|
|
71
|
+
/** `null` when no such account exists. */
|
|
72
|
+
kind: z.ZodNullable<z.ZodEnum<["personal", "organization", "project", "bot", "channel"]>>;
|
|
73
|
+
/** `null` means: this person may not act for this account. */
|
|
74
|
+
access: z.ZodNullable<z.ZodObject<{
|
|
75
|
+
role: z.ZodString;
|
|
76
|
+
permissions: z.ZodArray<z.ZodString, "many">;
|
|
77
|
+
/** Only an active membership grants access, so this is the one value. */
|
|
78
|
+
status: z.ZodLiteral<"active">;
|
|
79
|
+
source: z.ZodEnum<["self", "direct", "inherited"]>;
|
|
80
|
+
}, "strip", z.ZodTypeAny, {
|
|
81
|
+
status: "active";
|
|
82
|
+
role: string;
|
|
83
|
+
permissions: string[];
|
|
84
|
+
source: "self" | "direct" | "inherited";
|
|
85
|
+
}, {
|
|
86
|
+
status: "active";
|
|
87
|
+
role: string;
|
|
88
|
+
permissions: string[];
|
|
89
|
+
source: "self" | "direct" | "inherited";
|
|
90
|
+
}>>;
|
|
91
|
+
}, "strip", z.ZodTypeAny, {
|
|
92
|
+
kind: "organization" | "personal" | "project" | "bot" | "channel" | null;
|
|
93
|
+
accountId: string;
|
|
94
|
+
access: {
|
|
95
|
+
status: "active";
|
|
96
|
+
role: string;
|
|
97
|
+
permissions: string[];
|
|
98
|
+
source: "self" | "direct" | "inherited";
|
|
99
|
+
} | null;
|
|
100
|
+
}, {
|
|
101
|
+
kind: "organization" | "personal" | "project" | "bot" | "channel" | null;
|
|
102
|
+
accountId: string;
|
|
103
|
+
access: {
|
|
104
|
+
status: "active";
|
|
105
|
+
role: string;
|
|
106
|
+
permissions: string[];
|
|
107
|
+
source: "self" | "direct" | "inherited";
|
|
108
|
+
} | null;
|
|
109
|
+
}>, {
|
|
110
|
+
kind: "organization" | "personal" | "project" | "bot" | "channel" | null;
|
|
111
|
+
accountId: string;
|
|
112
|
+
access: {
|
|
113
|
+
status: "active";
|
|
114
|
+
role: string;
|
|
115
|
+
permissions: string[];
|
|
116
|
+
source: "self" | "direct" | "inherited";
|
|
117
|
+
} | null;
|
|
118
|
+
}, {
|
|
119
|
+
kind: "organization" | "personal" | "project" | "bot" | "channel" | null;
|
|
120
|
+
accountId: string;
|
|
121
|
+
access: {
|
|
122
|
+
status: "active";
|
|
123
|
+
role: string;
|
|
124
|
+
permissions: string[];
|
|
125
|
+
source: "self" | "direct" | "inherited";
|
|
126
|
+
} | null;
|
|
127
|
+
}>;
|
|
128
|
+
export type AccountAccessVerdict = z.infer<typeof accountAccessVerdictSchema>;
|
|
@@ -13,23 +13,8 @@
|
|
|
13
13
|
* (`reauth`) use the same code, through their own routes (`signIn.ts`).
|
|
14
14
|
*/
|
|
15
15
|
import { z } from 'zod';
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
* - `signin`: the code (and link) of an email sign-in (`POST /auth/signin/email/start`).
|
|
19
|
-
* - `reauth`: a signed-in person proving it is them before a sensitive step
|
|
20
|
-
* (`POST /users/me/reauth/email`): a password, an authenticator, deleting the
|
|
21
|
-
* account, linking Commons.
|
|
22
|
-
*/
|
|
23
|
-
export declare const EMAIL_VERIFICATION_PURPOSES: readonly ["signup", "signin", "reauth"];
|
|
24
|
-
export type EmailVerificationPurpose = (typeof EMAIL_VERIFICATION_PURPOSES)[number];
|
|
25
|
-
/** Digits in a code. */
|
|
26
|
-
export declare const EMAIL_CODE_LENGTH = 6;
|
|
27
|
-
/** How long a code can be confirmed. */
|
|
28
|
-
export declare const EMAIL_CODE_TTL_MS: number;
|
|
29
|
-
/** Wrong codes before a verification is spent and a new code is needed. */
|
|
30
|
-
export declare const EMAIL_CODE_MAX_ATTEMPTS = 5;
|
|
31
|
-
/** How long a confirmed code's ticket can be spent. */
|
|
32
|
-
export declare const EMAIL_TICKET_TTL_MS: number;
|
|
16
|
+
export { EMAIL_VERIFICATION_PURPOSES, EMAIL_CODE_LENGTH, EMAIL_CODE_TTL_MS, EMAIL_CODE_MAX_ATTEMPTS, EMAIL_TICKET_TTL_MS, EMAIL_VERIFICATION_ERROR_CODES, } from './client/accountEmail';
|
|
17
|
+
export type { EmailVerificationPurpose, EmailVerificationErrorCode } from './client/accountEmail';
|
|
33
18
|
/** An email address as the API stores it: trimmed and lowercase. */
|
|
34
19
|
export declare const emailAddressSchema: z.ZodString;
|
|
35
20
|
/** An opaque one-use ticket (32 random bytes, base64url). */
|
|
@@ -39,11 +24,11 @@ export declare const emailVerificationStartRequestSchema: z.ZodObject<{
|
|
|
39
24
|
purpose: z.ZodLiteral<"signup">;
|
|
40
25
|
email: z.ZodString;
|
|
41
26
|
}, "strict", z.ZodTypeAny, {
|
|
42
|
-
purpose: "signup";
|
|
43
27
|
email: string;
|
|
44
|
-
}, {
|
|
45
28
|
purpose: "signup";
|
|
29
|
+
}, {
|
|
46
30
|
email: string;
|
|
31
|
+
purpose: "signup";
|
|
47
32
|
}>;
|
|
48
33
|
export type EmailVerificationStartRequest = z.infer<typeof emailVerificationStartRequestSchema>;
|
|
49
34
|
export interface EmailVerificationStartResponse {
|
|
@@ -71,20 +56,3 @@ export interface EmailVerificationConfirmResponse {
|
|
|
71
56
|
expiresAt: number;
|
|
72
57
|
}
|
|
73
58
|
export declare const emailVerificationConfirmResponseSchema: z.ZodType<EmailVerificationConfirmResponse>;
|
|
74
|
-
/**
|
|
75
|
-
* Stable error codes (`error.code` in the API error body). Clients map these
|
|
76
|
-
* through their localization, never the English message.
|
|
77
|
-
*/
|
|
78
|
-
export declare const EMAIL_VERIFICATION_ERROR_CODES: {
|
|
79
|
-
/** The code is wrong, or its verification expired or was spent. */
|
|
80
|
-
readonly codeInvalid: "EMAIL_CODE_INVALID";
|
|
81
|
-
/** Too many wrong codes: request a new one. */
|
|
82
|
-
readonly tooManyAttempts: "EMAIL_CODE_TOO_MANY_ATTEMPTS";
|
|
83
|
-
/** The ticket is unknown, expired, spent, or for another email or purpose. */
|
|
84
|
-
readonly ticketInvalid: "EMAIL_TICKET_INVALID";
|
|
85
|
-
/** A sign-up without a confirmed email. */
|
|
86
|
-
readonly ticketRequired: "EMAIL_TICKET_REQUIRED";
|
|
87
|
-
/** This server cannot send mail. */
|
|
88
|
-
readonly unavailable: "EMAIL_UNAVAILABLE";
|
|
89
|
-
};
|
|
90
|
-
export type EmailVerificationErrorCode = (typeof EMAIL_VERIFICATION_ERROR_CODES)[keyof typeof EMAIL_VERIFICATION_ERROR_CODES];
|