@omelhorsite/sdk 0.2.0 → 0.4.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 (96) hide show
  1. package/README.md +112 -130
  2. package/dist/index.js +4800 -610
  3. package/dist/types/client.d.ts +60 -3
  4. package/dist/types/http.d.ts +444 -19
  5. package/dist/types/index.d.ts +5 -1
  6. package/dist/types/internal/attachments.d.ts +17 -0
  7. package/dist/types/internal/helpers.d.ts +9 -0
  8. package/dist/types/listing.d.ts +90 -0
  9. package/dist/types/resources/account.d.ts +71 -5
  10. package/dist/types/resources/admin/authorizedApplications.d.ts +133 -0
  11. package/dist/types/resources/admin/chests.d.ts +51 -0
  12. package/dist/types/resources/admin/eventAlerts.d.ts +60 -0
  13. package/dist/types/resources/admin/identities.d.ts +99 -0
  14. package/dist/types/resources/admin/index.d.ts +77 -0
  15. package/dist/types/resources/admin/jobs.d.ts +97 -0
  16. package/dist/types/resources/admin/myOauthApplications.d.ts +282 -0
  17. package/dist/types/resources/admin/notepads.d.ts +49 -0
  18. package/dist/types/resources/admin/oauthApplications.d.ts +309 -0
  19. package/dist/types/resources/admin/quotas.d.ts +114 -0
  20. package/dist/types/resources/admin/shortLinks.d.ts +201 -0
  21. package/dist/types/resources/admin/types.d.ts +222 -0
  22. package/dist/types/resources/admin/vocalSeparations.d.ts +98 -0
  23. package/dist/types/resources/admin.d.ts +1841 -0
  24. package/dist/types/resources/auth/index.d.ts +39 -0
  25. package/dist/types/resources/auth/passkeys.d.ts +652 -0
  26. package/dist/types/resources/auth/sessions.d.ts +844 -0
  27. package/dist/types/resources/chests.d.ts +54 -3
  28. package/dist/types/resources/content/analysis.d.ts +62 -0
  29. package/dist/types/resources/content/blogs.d.ts +471 -0
  30. package/dist/types/resources/content/feedbacks.d.ts +263 -0
  31. package/dist/types/resources/content/index.d.ts +52 -0
  32. package/dist/types/resources/content/intel/articles.d.ts +230 -0
  33. package/dist/types/resources/content/intel/config.d.ts +135 -0
  34. package/dist/types/resources/content/intel/index.d.ts +53 -0
  35. package/dist/types/resources/content/intel/items.d.ts +91 -0
  36. package/dist/types/resources/content/intel/reports.d.ts +108 -0
  37. package/dist/types/resources/content/intel/scripts.d.ts +152 -0
  38. package/dist/types/resources/content/intel/sources.d.ts +236 -0
  39. package/dist/types/resources/content/intel/stats.d.ts +105 -0
  40. package/dist/types/resources/content/intel/types.d.ts +86 -0
  41. package/dist/types/resources/content/jokes.d.ts +93 -0
  42. package/dist/types/resources/content/notifications.d.ts +147 -0
  43. package/dist/types/resources/content/serviceUsages.d.ts +73 -0
  44. package/dist/types/resources/content/servicesStatus.d.ts +194 -0
  45. package/dist/types/resources/content/siteConfig.d.ts +43 -0
  46. package/dist/types/resources/content/spaceInvaders.d.ts +154 -0
  47. package/dist/types/resources/content.d.ts +2775 -0
  48. package/dist/types/resources/dynamicQrs.d.ts +39 -3
  49. package/dist/types/resources/forms.d.ts +176 -35
  50. package/dist/types/resources/index.d.ts +19 -8
  51. package/dist/types/resources/ipLookup.d.ts +20 -4
  52. package/dist/types/resources/jobs.d.ts +69 -25
  53. package/dist/types/resources/library/annotations.d.ts +162 -0
  54. package/dist/types/resources/library/books.d.ts +534 -0
  55. package/dist/types/resources/library/chat.d.ts +259 -0
  56. package/dist/types/resources/library/index.d.ts +39 -0
  57. package/dist/types/resources/library/shelves.d.ts +237 -0
  58. package/dist/types/resources/library/types.d.ts +120 -0
  59. package/dist/types/resources/library.d.ts +1433 -0
  60. package/dist/types/resources/linkTrees.d.ts +142 -30
  61. package/dist/types/resources/media.d.ts +351 -0
  62. package/dist/types/resources/movies/addons.d.ts +388 -0
  63. package/dist/types/resources/movies/collections.d.ts +352 -0
  64. package/dist/types/resources/movies/index.d.ts +29 -0
  65. package/dist/types/resources/movies/types.d.ts +50 -0
  66. package/dist/types/resources/movies/watchProgress.d.ts +277 -0
  67. package/dist/types/resources/movies.d.ts +1160 -0
  68. package/dist/types/resources/music/artists.d.ts +1068 -0
  69. package/dist/types/resources/music/imports.d.ts +941 -0
  70. package/dist/types/resources/music/index.d.ts +61 -0
  71. package/dist/types/resources/music/playlists.d.ts +1027 -0
  72. package/dist/types/resources/music/social.d.ts +1132 -0
  73. package/dist/types/resources/music/songs.d.ts +1167 -0
  74. package/dist/types/resources/notepads.d.ts +4 -1
  75. package/dist/types/resources/quotas.d.ts +7 -1
  76. package/dist/types/resources/realtime.d.ts +855 -0
  77. package/dist/types/resources/shortLinks.d.ts +49 -5
  78. package/dist/types/resources/social/groupChats.d.ts +458 -0
  79. package/dist/types/resources/social/index.d.ts +19 -0
  80. package/dist/types/resources/social/messages.d.ts +424 -0
  81. package/dist/types/resources/social/relationships.d.ts +322 -0
  82. package/dist/types/resources/social/types.d.ts +37 -0
  83. package/dist/types/resources/social.d.ts +1348 -0
  84. package/dist/types/resources/storage/upload.d.ts +158 -11
  85. package/dist/types/resources/storage.d.ts +111 -27
  86. package/dist/types/resources/tickets.d.ts +101 -13
  87. package/dist/types/resources/tools/backgroundRemoval.d.ts +18 -3
  88. package/dist/types/resources/tools/captions.d.ts +448 -21
  89. package/dist/types/resources/tools/downloader.d.ts +21 -0
  90. package/dist/types/resources/tools/index.d.ts +57 -15
  91. package/dist/types/resources/tools/jumpstyle.d.ts +50 -17
  92. package/dist/types/resources/tools/transcription.d.ts +35 -13
  93. package/dist/types/resources/tools/upscale.d.ts +23 -3
  94. package/dist/types/resources/tools/vocalSeparation.d.ts +30 -13
  95. package/dist/types/types.d.ts +249 -17
  96. package/package.json +2 -1
@@ -0,0 +1,844 @@
1
+ /**
2
+ * The `sessions` namespace: establishing a credential, ending it, and the
3
+ * two-step email flows that create an account, reset a password, move an
4
+ * address or delete the account.
5
+ *
6
+ * This is the module the rest of the SDK stands on. Every other namespace
7
+ * assumes a credential already exists; this one is where it comes from.
8
+ *
9
+ * ## What a credential actually is
10
+ *
11
+ * A `Session` row, and nothing more. `POST /sessions` writes one and hands back
12
+ * its `token`, which is a `SecureRandom.uuid`. That UUID IS the credential.
13
+ *
14
+ * There is no JWT, no signature to verify, no `exp`, no refresh token and no
15
+ * rotation. A session token never expires on its own: it lives until the row is
16
+ * deleted, which happens on sign-out, when an administrator deactivates the
17
+ * account (`User#deactivate!` runs `sessions.delete_all`), or when someone
18
+ * deletes it in the database. Do not build refresh logic against this - there
19
+ * is nothing to refresh, and a client that "renews" by signing in again just
20
+ * accumulates rows in the user's device list and fires a login alert each time.
21
+ *
22
+ * The OAuth 2 / OIDC tokens under `oms.auth` are a DIFFERENT credential with a
23
+ * different lifecycle (they do expire, they do refresh, they carry scopes).
24
+ * Both are accepted by the API. This module is only about the session kind.
25
+ *
26
+ * ## Three ways the server reads it, and the one that bites
27
+ *
28
+ * `Session.candidate_tokens` collects, in this order:
29
+ *
30
+ * 1. the `Authorization` header,
31
+ * 2. the `token` request parameter (query string or body),
32
+ * 3. the `oms_session` cookie.
33
+ *
34
+ * and `Session.resolve_from_request` tries each until one resolves to a LIVE
35
+ * row, so a stale header no longer permanently shadows a good cookie on API
36
+ * requests. (`ApplicationCable::Connection` is the exception: the WebSocket
37
+ * handshake takes the FIRST candidate, not the first live one, so a stale
38
+ * header there really does beat a good `?token=`.)
39
+ *
40
+ * The header is parsed as `header["Bearer:".length..]`, which is a BLIND SLICE
41
+ * OF THE FIRST SEVEN CHARACTERS. Nothing checks that those seven characters
42
+ * spell anything:
43
+ *
44
+ * - `Bearer <token>` works (7 chars: `Bearer` plus the space),
45
+ * - `Bearer:<token>` also works, which is where the constant's name comes from,
46
+ * - a bare token with NO prefix does NOT work. Its first seven characters are
47
+ * eaten, the remainder matches no row, and the request is answered as
48
+ * anonymous. The failure is a 401 on an endpoint that needs auth, or - far
49
+ * worse - a silently empty list on one that does not, with no hint anywhere
50
+ * that a credential was sent and mangled.
51
+ *
52
+ * The SDK's transport always writes `Bearer ${token}`, so this only matters if
53
+ * you build the header yourself, or if you store a token that already carries a
54
+ * prefix and then let the transport add a second one.
55
+ *
56
+ * ## Cookie mode and token mode
57
+ *
58
+ * Sign-in works in BOTH, and the difference is only in what you do with the
59
+ * answer. See {@link AuthSessionsNamespace.signIn}.
60
+ *
61
+ * The cookie is named `oms_session` ({@link SESSION_COOKIE_NAME}) and is set by
62
+ * every session-minting endpoint with `httpOnly`, `secure` in production,
63
+ * `SameSite=Lax`, `path=/`, a one-year expiry and NO `Domain` attribute, which
64
+ * makes it host-only: it belongs to `backend.omelhorsite.pt` alone and is never
65
+ * sent to a sibling subdomain. `omelhorsite.pt` and `backend.omelhorsite.pt`
66
+ * share a registrable domain, so a call from the web app is cross-ORIGIN but
67
+ * same-SITE, and `SameSite=Lax` still lets the cookie ride along. A page on a
68
+ * genuinely different site (the `pages.dev` staging build, where `pages.dev` is
69
+ * a public suffix) can never receive it, no CORS header can change that, and
70
+ * such a page must use token mode instead.
71
+ *
72
+ * ## No CSRF token exists
73
+ *
74
+ * The backend is an `ActionController::API` and `protect_from_forgery` is never
75
+ * enabled. There is no CSRF token to fetch, no header to echo, and nothing in
76
+ * this SDK that omits one. For browsers the entire cross-site defence is
77
+ * `SameSite=Lax` on the cookie; bearer clients are unaffected because a
78
+ * cross-site page cannot make the browser attach an `Authorization` header.
79
+ *
80
+ * ## What lives elsewhere
81
+ *
82
+ * Deliberately NOT re-implemented here, because `oms.account` already owns it
83
+ * and two implementations of one endpoint drift:
84
+ *
85
+ * - `oms.account.sessions.list()` / `.update()` - the device-management screen,
86
+ * `GET /sessions` and `PATCH /sessions/:id`;
87
+ * - `oms.account.me()`, `.get()`, `.byHandle()`, `.profile()`, `.search()`,
88
+ * `.update()`, `.follow()`, `.picture()` - the user read and write surface.
89
+ *
90
+ * `DELETE /users/:id` is also absent, and that one is not a delegation: the
91
+ * route cannot succeed for anybody. `UsersController#destroy` checks for an
92
+ * administrator and then calls `super`, and `CrudActions#destroy` asks
93
+ * `resource.destroyable_by?(Current.user)` - which on `User` is
94
+ * `alias destroyable_by? creatable_by?`, and `creatable_by?` returns `false`
95
+ * unconditionally. Every caller, administrator included, gets
96
+ * `401 "You are not authorized to destroy this resource"`. Use
97
+ * {@link AuthSessionsNamespace.deactivateUser} for the operational need, or
98
+ * {@link AuthSessionsNamespace.deleteAccountStart} for a user deleting
99
+ * themselves, which is a different code path and does work.
100
+ */
101
+ import { Resource } from "../../http";
102
+ import type { ListParams } from "../../listing";
103
+ import type { AccountSession, User } from "../account";
104
+ import type { Id, Paginated, RequestOptions } from "../../types";
105
+ /**
106
+ * Name of the httpOnly cookie the backend sets on every session-minting
107
+ * response.
108
+ *
109
+ * Exported for hosts that need to recognise it (a proxy forwarding it, a native
110
+ * client emptying its cookie jar), NOT for reading it: it is `httpOnly`, so
111
+ * `document.cookie` never contains it and no amount of trying will change that.
112
+ * That is the entire point of cookie mode.
113
+ */
114
+ export declare const SESSION_COOKIE_NAME = "oms_session";
115
+ /**
116
+ * The seven characters the server slices off the `Authorization` header before
117
+ * looking the token up, spelled the way the Rails source spells them
118
+ * (`"Bearer:".length`).
119
+ *
120
+ * Present so the number 7 appears somewhere other than a comment. The transport
121
+ * writes `"Bearer "` (with a space), which is the same length; both forms work
122
+ * and a token with no prefix at all does not. See the module note.
123
+ */
124
+ export declare const SESSION_BEARER_PREFIX_LENGTH = 7;
125
+ /**
126
+ * Digits in an email verification code (`EmailVerification::CODE_LENGTH`).
127
+ *
128
+ * Six, numeric only, zero-padded. This is a deliberate product decision on this
129
+ * project rather than an accident: a code a person can read off a phone and
130
+ * type on a numeric keypad, made safe by a hard attempt budget rather than by
131
+ * length. See {@link VERIFICATION_CODE_MAX_ATTEMPTS}.
132
+ */
133
+ export declare const VERIFICATION_CODE_LENGTH = 6;
134
+ /**
135
+ * Wrong guesses an issued code survives (`EmailVerification::MAX_ATTEMPTS`).
136
+ *
137
+ * This is the counterweight to a six-digit code, and it is per CODE, not per IP:
138
+ * rack-attack only throttles by address, so an attacker rotating through a
139
+ * botnet would otherwise walk a million-key space at 10 guesses a minute per
140
+ * address. The budget closes that regardless of where the guesses come from.
141
+ *
142
+ * The exact arithmetic, because off-by-one matters when you are deciding
143
+ * whether to let a user try again: `register_failed_attempt` destroys the code
144
+ * when `attempts + 1 >= MAX_ATTEMPTS`, starting from `attempts = 0`. So four
145
+ * wrong guesses are survivable and the FIFTH burns the code. Burning is
146
+ * permanent - the row is deleted, not locked - and it also fires a
147
+ * `verification_burned` security alert to the owner. The user's only route
148
+ * forward is a fresh `*_start` call, which is throttled at 4 a minute and 20 an
149
+ * hour per IP, so a client that lets someone mash a code field will lock them
150
+ * out of the flow for the rest of the hour.
151
+ *
152
+ * Validate the shape locally with {@link isVerificationCode} before spending an
153
+ * attempt on something that cannot possibly be right.
154
+ */
155
+ export declare const VERIFICATION_CODE_MAX_ATTEMPTS = 5;
156
+ /**
157
+ * How long an issued code stays valid (`EmailVerification::EXPIRES_IN`), in
158
+ * milliseconds. Fifteen minutes.
159
+ *
160
+ * Expiry is enforced by an `active` scope plus an opportunistic purge on every
161
+ * issue and every verify, so an expired code behaves exactly like a wrong one:
162
+ * `404 "Invalid Verification"`, indistinguishable from the status alone. Show
163
+ * the user a countdown rather than making them find out.
164
+ */
165
+ export declare const VERIFICATION_CODE_TTL_MS: number;
166
+ /**
167
+ * How long an OAuth handoff ticket stays valid (`SessionsController::TICKET_TTL`),
168
+ * in milliseconds. Two minutes.
169
+ *
170
+ * The signature window is only half the story - the ticket is also one-time.
171
+ * See {@link AuthSessionsNamespace.adopt}.
172
+ */
173
+ export declare const OAUTH_TICKET_TTL_MS: number;
174
+ /**
175
+ * Every value the `device_type` column accepts, as the server's own enum
176
+ * spells them.
177
+ *
178
+ * The server picks one by parsing the `User-Agent` of the sign-in request, and
179
+ * the user can rename it afterwards through `oms.account.sessions.update()`.
180
+ * The list is mostly a joke, with one entry that is not:
181
+ *
182
+ * **`"teapot"` suppresses alerts.** `Session#alert_login` and
183
+ * `#alert_returning_activity` both bail out for a teapot session, which is how
184
+ * the backend's own background jobs sign in without paging the owner on every
185
+ * run. Do not relabel a real user's device as a teapot to quieten notifications:
186
+ * you are turning off the only signal that a stolen token is being used.
187
+ */
188
+ export declare const SESSION_DEVICE_TYPES: readonly ["tablet", "console", "fridge", "teapot", "toaster", "air_conditioner", "car", "blender", "vacuum_cleaner", "washing_machine", "lawn_mower", "microwave", "hair_dryer", "electric_toothbrush", "desktop", "laptop", "television", "mobile", "space_ship", "time_machine", "hoverboard", "teleporter", "magic_carpet", "unicorn", "flying_broom", "submarine", "hot_air_balloon", "keychain", "alarm_clock", "radio", "record_player", "other"];
189
+ /** One of {@link SESSION_DEVICE_TYPES}. */
190
+ export type SessionDeviceType = (typeof SESSION_DEVICE_TYPES)[number];
191
+ /**
192
+ * True when `value` has the shape of an email verification code: exactly
193
+ * {@link VERIFICATION_CODE_LENGTH} ASCII digits.
194
+ *
195
+ * Purely local, and worth calling before every `*Complete` method. A malformed
196
+ * code cannot match anything, but sending it still costs one of the five
197
+ * guesses the live code has ({@link VERIFICATION_CODE_MAX_ATTEMPTS}) and one of
198
+ * the ten requests a minute the IP is allowed. A user who pastes a code with a
199
+ * trailing space should not lose a fifth of their budget to whitespace.
200
+ *
201
+ * The server normalises with `strip`, so surrounding whitespace is forgiven
202
+ * there; this returns `false` for it anyway, so a caller can trim before
203
+ * sending rather than relying on the remote side to be lenient.
204
+ */
205
+ export declare function isVerificationCode(value: string): boolean;
206
+ /** Credentials for {@link AuthSessionsNamespace.signIn}. */
207
+ export interface SignInInput {
208
+ /** Normalised server-side with `strip.downcase`; send it as the user typed it. */
209
+ readonly email: string;
210
+ /**
211
+ * Compared with `User.authenticate_by`, which is timing-safe: a wrong
212
+ * password and an unknown address take the same time and give the same
213
+ * message, so this endpoint cannot be used to test whether an account exists.
214
+ */
215
+ readonly password: string;
216
+ }
217
+ /**
218
+ * What `POST /sessions` answers with: the session record plus, ONCE, the token.
219
+ *
220
+ * This is `SessionBlueprint`'s `:token` view, which is the base view plus one
221
+ * field - Blueprinter views inherit, they do not replace - so everything an
222
+ * ordinary {@link AccountSession} carries is here too, including the inlined
223
+ * `user`. That inline user saves a round trip: there is no need to call
224
+ * `oms.account.me()` straight after signing in.
225
+ *
226
+ * `token` appears in this response and in NO other. Nothing else in the API
227
+ * ever renders it again: `GET /sessions` and `GET /sessions/mine` return the
228
+ * base view, which has no `token` field. Lose it and the only way back is to
229
+ * sign in again, minting another row.
230
+ */
231
+ export interface SignedInSession extends AccountSession {
232
+ /**
233
+ * The credential. A bare UUID, no prefix.
234
+ *
235
+ * Store it where the platform stores secrets (Keychain / Keystore via
236
+ * SecureStore on React Native, the OS keyring for the CLI). Do NOT store it
237
+ * when you are in cookie mode - see {@link AuthSessionsNamespace.signIn}.
238
+ */
239
+ readonly token: string;
240
+ /** The signed-in user, rendered inline. Always present on this view. */
241
+ readonly user: User;
242
+ }
243
+ /**
244
+ * What `POST /sessions/adopt` answers with. Two fields short of a session: the
245
+ * endpoint returns only the token, not the record.
246
+ */
247
+ export interface AdoptedSession {
248
+ /** The credential, same kind of value as {@link SignedInSession.token}. */
249
+ readonly token: string;
250
+ }
251
+ /** What `GET /sessions/oauth_ticket` answers with. */
252
+ export interface SessionOAuthTicket {
253
+ /**
254
+ * A signed id for the current session, scoped to the `oauth` purpose and good
255
+ * for {@link OAUTH_TICKET_TTL_MS}. It is NOT a session token and cannot
256
+ * authenticate an API call; the only thing that accepts it is the OAuth link
257
+ * flow, which trades it back for a session through
258
+ * {@link AuthSessionsNamespace.adopt}.
259
+ */
260
+ readonly ticket: string;
261
+ }
262
+ /** Arguments for {@link AuthSessionsNamespace.signUpComplete}. */
263
+ export interface SignUpInput {
264
+ /** The address the code was sent to. Must match `signUpStart` exactly. */
265
+ readonly email: string;
266
+ /** The six digits from the email. */
267
+ readonly code: string;
268
+ /**
269
+ * Display name, 1 to 50 characters. The `handle` is NOT settable here: the
270
+ * server generates one from this name in a `before_create` hook. Change it
271
+ * afterwards with `oms.account.update({ handle })`.
272
+ */
273
+ readonly name: string;
274
+ /** The password. The backend enforces no minimum beyond presence. */
275
+ readonly password: string;
276
+ }
277
+ /** Arguments for {@link AuthSessionsNamespace.resetPasswordComplete}. */
278
+ export interface ResetPasswordInput {
279
+ /** The address the code was sent to. */
280
+ readonly email: string;
281
+ /** The six digits from the email. */
282
+ readonly code: string;
283
+ /** The new password. This is the only field the call changes. */
284
+ readonly password: string;
285
+ }
286
+ /** Arguments for {@link AuthSessionsNamespace.changeEmailComplete}. */
287
+ export interface ChangeEmailInput {
288
+ /** The NEW address, identical to the one passed to `changeEmailStart`. */
289
+ readonly email: string;
290
+ /** The six digits sent to the address currently on the account. */
291
+ readonly prevEmailCode: string;
292
+ /** The six digits sent to the new address. */
293
+ readonly newEmailCode: string;
294
+ }
295
+ /** Filter columns of `GET /users`, on top of {@link BASE_FILTER_COLUMNS}. */
296
+ export declare const USER_FILTER_COLUMNS: readonly ["name", "handle"];
297
+ /** Filters for {@link AuthSessionsNamespace.listUsers}. */
298
+ export interface ListUsersParams extends ListParams<(typeof USER_FILTER_COLUMNS)[number]> {
299
+ /** Substring match on the display name, accent-folded and case-insensitive. */
300
+ readonly name?: string;
301
+ /** Substring match on the handle, accent-folded and case-insensitive. */
302
+ readonly handle?: string;
303
+ /** Exact handle. Cheaper and less surprising than `handle` for a lookup. */
304
+ readonly exactHandle?: string;
305
+ }
306
+ /**
307
+ * The `sessions` namespace, reachable as `oms.sessions`.
308
+ *
309
+ * Named `AuthSessionsNamespace` rather than `SessionsNamespace` because the
310
+ * SDK already has an `AuthNamespace` for OAuth and the RFC 8628 device grant,
311
+ * and the two are genuinely different credentials rather than two spellings of
312
+ * one. Nothing here touches OAuth except {@link adopt} and {@link oauthTicket},
313
+ * which are the two places the browser OAuth flow hands control back to a
314
+ * session.
315
+ */
316
+ export declare class AuthSessionsNamespace extends Resource {
317
+ /**
318
+ * `POST /sessions` - trades an email and a password for a session token.
319
+ *
320
+ * Answers `201` with {@link SignedInSession}: the session row, the signed-in
321
+ * user inline, and the token, which appears here and nowhere else ever again.
322
+ *
323
+ * ## What to do with the answer, per mode
324
+ *
325
+ * **Token mode** (React Native, the CLI, anything not served from
326
+ * `omelhorsite.pt`): store `token` in the platform's secret store and build a
327
+ * client with it. The client you called this on has no credential, and adding
328
+ * one to an existing client is not possible - `Oms` takes its token at
329
+ * construction.
330
+ *
331
+ * ```ts
332
+ * const anon = new Oms({ baseUrl });
333
+ * const session = await anon.sessions.signIn({ email, password });
334
+ * await secureStore.set("oms_token", session.token);
335
+ * const oms = new Oms({ baseUrl, token: session.token });
336
+ * ```
337
+ *
338
+ * **Cookie mode** (`new Oms({ sessionCookie: true })`, a first-party page on
339
+ * `omelhorsite.pt` or `music.omelhorsite.pt`): the response carries
340
+ * `Set-Cookie: oms_session=...` and, because the transport sends
341
+ * `credentials: "include"`, the browser stores it. The SAME client is
342
+ * authenticated from the next call onwards; there is nothing to construct and
343
+ * nothing to store.
344
+ *
345
+ * ```ts
346
+ * const oms = new Oms({ sessionCookie: true });
347
+ * await oms.sessions.signIn({ email, password });
348
+ * const me = await oms.account.me(); // already authenticated
349
+ * ```
350
+ *
351
+ * **In cookie mode, throw the token away.** It is still in the response body,
352
+ * in plain JSON, readable by any script on the page - the httpOnly cookie
353
+ * cannot hide what the body already said. Persisting it to `localStorage`
354
+ * re-creates precisely the XSS-exfiltratable copy the cookie mode exists to
355
+ * eliminate, and it also gives you a second credential that outlives the
356
+ * first: sign out, and the cookie dies while the stored token keeps working.
357
+ * The web app is explicit about this - `persistSessionToken` writes only a
358
+ * non-sensitive `authed` flag when `isCookieAuth()`, and actively purges any
359
+ * legacy token it finds.
360
+ *
361
+ * Note that an `Oms` cannot be both: passing `sessionCookie: true` together
362
+ * with a token throws a `TypeError` at construction, deliberately, so that no
363
+ * request ever carries two credentials and leaves the server to choose.
364
+ *
365
+ * ## Cost and failure
366
+ *
367
+ * Throttled to **10 POSTs per minute per IP** (`login/ip`), which is a
368
+ * password-guessing bound and is keyed by address, so several users behind
369
+ * one NAT share it. The throttle matches a normalised path, so `/sessions/`,
370
+ * `//sessions` and `/sessions.json` all count against the same bucket - that
371
+ * gap was closed.
372
+ *
373
+ * Every successful sign-in creates a row AND fires a Discord alert to the
374
+ * owner. Signing in once per process invocation is how a device list fills up
375
+ * with a hundred identical entries; persist the token instead.
376
+ *
377
+ * Retries: an ambiguous network failure is NOT replayed, because this is a
378
+ * `POST` and the transport only replays safe methods by default. That is the
379
+ * right default here - a replay after a lost response mints a second session.
380
+ * A `429` IS still waited out and retried, which on a login screen can mean a
381
+ * silent minute-long pause; pass `retry: false` if you would rather show the
382
+ * user the rate-limit error immediately.
383
+ *
384
+ * Send a meaningful `clientName` on the `Oms` (it becomes `X-Oms-Client`) and,
385
+ * where the platform lets you set it, a real `User-Agent`: the server derives
386
+ * the session's `name`, `description` and `device_type` from the User-Agent of
387
+ * THIS request, and a blank one produces an unhelpful row in the user's own
388
+ * device list that they cannot fix except by renaming it.
389
+ *
390
+ * @throws {OmsAuthError} 401 `"Invalid email address or password."` for a
391
+ * wrong password, an unknown address, and a deactivated account alike. The
392
+ * three are not distinguishable, on purpose. (Deactivation is enforced as a
393
+ * validation on `Session` create, so it fails at the same place.)
394
+ * @throws {OmsQuotaError} 429 once the per-IP login budget is spent.
395
+ */
396
+ signIn(input: SignInInput, options?: RequestOptions): Promise<SignedInSession>;
397
+ /**
398
+ * `DELETE /sessions/:id` - ends the session THIS credential is using.
399
+ *
400
+ * ## THE `:id` IS IGNORED. THIS ALWAYS DESTROYS THE CALLING SESSION.
401
+ *
402
+ * `SessionsController#destroy` does not look the path segment up. It does not
403
+ * call `resource`. It reads `Current.session`, destroys that, clears the
404
+ * cookie and answers `204`. So `DELETE /sessions/<any string at all>` means
405
+ * "log ME out", and there is no way through this API to revoke a different
406
+ * device. The web app's own "sign out this other device" button has always
407
+ * signed the user out of the browser they clicked it in.
408
+ *
409
+ * That is why this method takes no id. A signature that accepted one would be
410
+ * describing behaviour the server does not have, and the mistake it invites -
411
+ * passing a row from the device list - logs the user out of the wrong device
412
+ * with a `204` that looks like success.
413
+ *
414
+ * To actually end someone else's sessions there is exactly one lever, and it
415
+ * is administrative: {@link deactivateUser} runs `sessions.delete_all` on the
416
+ * target.
417
+ *
418
+ * ## What it does on the wire
419
+ *
420
+ * One request, to the literal path `/sessions/current`. The segment is a
421
+ * placeholder and it is spelled to read as one. `oms.account.sessions.revokeCurrent()`
422
+ * does the same thing in two requests, resolving the real id first so the call
423
+ * stays correct if the backend is ever fixed to honour the id; this one
424
+ * spends a single round trip and covers that case with a fallback instead,
425
+ * re-resolving through `GET /sessions/mine` and retrying if the placeholder
426
+ * ever starts answering 404.
427
+ *
428
+ * ## It does not throw when there was nothing to sign out of
429
+ *
430
+ * A dead, missing or already-revoked credential answers `404 "Session not
431
+ * found."` or `401`, and both are resolved rather than raised: you asked for
432
+ * the session to be gone and it is gone. Sign-out is idempotent, it usually
433
+ * runs while an app is tearing down, and a throw there strands clients with a
434
+ * credential they have decided to stop using. Everything else - a network
435
+ * failure, a 500, a 429 - is raised normally.
436
+ *
437
+ * Clear your own stored credential regardless of what this resolves to. The
438
+ * server side is best-effort; the client side is the part you control.
439
+ *
440
+ * In cookie mode the response also carries a cookie deletion, so the browser
441
+ * forgets it and the same client is anonymous from the next call onwards.
442
+ */
443
+ signOut(options?: RequestOptions): Promise<void>;
444
+ /**
445
+ * `GET /sessions/mine` - the session the current credential resolves to.
446
+ *
447
+ * The cheapest liveness check there is, and the one the web app and the
448
+ * native app both boot with: a `200` means the stored credential still names
449
+ * a row, a `401` means it does not and the user must sign in again. Identical
450
+ * to `oms.account.sessions.current()`; both are here because "am I still
451
+ * signed in" belongs to the sign-in lifecycle and "which devices are signed
452
+ * in" belongs to the account screen.
453
+ *
454
+ * Returns the base `SessionBlueprint` view, with the owner inlined under
455
+ * `user` and WITHOUT `token`. There is no route that hands a token back.
456
+ *
457
+ * `/sessions/mine` is the whole spelling. There is NO `GET /sessions/current`:
458
+ * `resources :sessions` is declared `only: [:index, :create, :update,
459
+ * :destroy]`, so `show` is not routed and a GET to `/sessions/current` is a
460
+ * 404. (It IS a live path on DELETE, where it is the placeholder id
461
+ * {@link signOut} uses, which is exactly the sort of coincidence that makes
462
+ * the wrong spelling look plausible.)
463
+ *
464
+ * Note that reaching this endpoint at all rewrites `last_used_at` and can
465
+ * fire the "user is active again" alert, so it is not free of side effects
466
+ * and is not a good thing to poll.
467
+ *
468
+ * Counts against the general authenticated ceiling, 600 a minute. Careful
469
+ * with the failure case: a request whose token does not resolve is billed to
470
+ * the ANONYMOUS per-IP bucket of 120 a minute instead, so a client that
471
+ * retries a dead credential in a loop can rate-limit every user sharing that
472
+ * address.
473
+ *
474
+ * @throws {OmsAuthError} 401 when the credential is absent or dead.
475
+ * @throws {OmsApiError} 404 `"Session not found."` when the credential
476
+ * resolved to nothing but the request still reached the action.
477
+ */
478
+ current(options?: RequestOptions): Promise<AccountSession>;
479
+ /**
480
+ * `POST /sessions/adopt` - trades a one-time OAuth ticket for a session.
481
+ *
482
+ * The last step of the browser OAuth flow. The provider round trip happens on
483
+ * the API host; its callback redirects the browser back to
484
+ * `https://omelhorsite.pt/account/oauth/callback?ticket=...` (hardcoded to
485
+ * `Rails.configuration.frontend_url`, not configurable per client), and the
486
+ * page hands that ticket here. The ticket exists so the session token itself
487
+ * never travels in a URL, a browser history entry or a `Referer`.
488
+ *
489
+ * Unauthenticated by design: this IS the sign-in step. Call it on a client
490
+ * with no credential. Answers `201 {"token": "..."}` and sets the cookie,
491
+ * exactly like {@link signIn}, so the same "which mode am I in" reasoning
492
+ * applies to the token it returns.
493
+ *
494
+ * ## MUST NOT BE RETRIED, and this method enforces that
495
+ *
496
+ * The ticket is one-time on the server. Redemption is claimed atomically with
497
+ * `Rails.cache.write(..., unless_exist: true)` before the session is adopted,
498
+ * and a second presentation of the same ticket gets the same `401 "Invalid or
499
+ * expired ticket."` as a forged one. So a retry after an ambiguous failure -
500
+ * a torn connection, a lost response - burns the ticket and reports a login
501
+ * failure for a login that actually SUCCEEDED. The user is left staring at an
502
+ * error page while the browser quietly holds a valid session cookie.
503
+ *
504
+ * This method therefore passes `retry: false` and a caller cannot override it
505
+ * back on. If the call fails ambiguously, the honest recovery is to check
506
+ * {@link current} before deciding anything: if it answers, you are signed in.
507
+ *
508
+ * The app-side documentation (`oms-music/docs/auth-account.md`, section 6)
509
+ * says the ticket is "not single-use server-side" and that the web enforces
510
+ * single use client-side with a sessionStorage nonce. THAT IS OUT OF DATE.
511
+ * The Rails code enforces it, and it is the enforcement that makes a retry
512
+ * destructive. When the doc and the Rails disagree, the Rails wins.
513
+ *
514
+ * Tickets are also short-lived, {@link OAUTH_TICKET_TTL_MS} (two minutes), so
515
+ * do not stash one to redeem later.
516
+ *
517
+ * @throws {OmsAuthError} 401 `"Invalid or expired ticket."` for a forged
518
+ * ticket, an expired one, and an already-redeemed one alike.
519
+ */
520
+ adopt(ticket: string, options?: RequestOptions): Promise<AdoptedSession>;
521
+ /**
522
+ * `GET /sessions/oauth_ticket` - mints a short-lived ticket for the current
523
+ * session, so the session token itself never crosses a subdomain boundary.
524
+ *
525
+ * Only the web app needs this, and only for one thing: linking an OAuth
526
+ * provider to an account that is already signed in. That flow is a full-page
527
+ * navigation to `backend.omelhorsite.pt/auth/link/<provider>`, and a
528
+ * navigation cannot carry an `Authorization` header. The cookie is host-only
529
+ * on the API host, so it does not help either. The alternative would be
530
+ * `?token=<the session token>` in a URL that lands in browser history and in
531
+ * a `Referer`, which is exactly what this endpoint exists to avoid.
532
+ *
533
+ * Native and CLI clients have no such constraint and do not need this: they
534
+ * hold the token already.
535
+ *
536
+ * The result is scoped to the `oauth` purpose and expires after
537
+ * {@link OAUTH_TICKET_TTL_MS}. It authenticates nothing else - an API call
538
+ * carrying it as a bearer token is anonymous - and it is spent by the first
539
+ * {@link adopt} that redeems it. Mint one per navigation, never cache it.
540
+ *
541
+ * Requires a live session. Counts against the general authenticated ceiling.
542
+ *
543
+ * @throws {OmsApiError} 404 `"Session not found."` when there is no live
544
+ * session behind the credential.
545
+ */
546
+ oauthTicket(options?: RequestOptions): Promise<SessionOAuthTicket>;
547
+ /**
548
+ * `POST /users/create_start` - emails a six-digit code to an address that
549
+ * does not have an account yet.
550
+ *
551
+ * Step one of two. Nothing is created here: the row appears only when
552
+ * {@link signUpComplete} presents the code back. Anonymous, and it must be -
553
+ * the caller has no account yet.
554
+ *
555
+ * Answers `200` with a BARE JSON STRING, not an object:
556
+ * `"Verification code sent to your email."`. Several endpoints in this
557
+ * namespace do that; the transport parses it into a `string`, so read it as
558
+ * one and do not reach for a `.message` that is not there.
559
+ *
560
+ * This is the one `*_start` in the family that leaks whether an address is
561
+ * registered: it answers `409 "Email already registered."` when it is. That
562
+ * is a deliberate trade for a usable signup form, and it is why
563
+ * {@link resetPasswordStart} does the opposite.
564
+ *
565
+ * Issuing a code DELETES any live code for the same address and reason
566
+ * (`where(reason:, email:).delete_all` before insert). One code per flow per
567
+ * address, always. A user who asks for a second code and then types the first
568
+ * one gets `404 "Invalid Verification"` and, worse, spends one of the five
569
+ * guesses belonging to the code they cannot see. Tell them the old code is
570
+ * dead when they request a new one.
571
+ *
572
+ * Throttled hard, and shared across all four `*_start` endpoints of the
573
+ * family: **4 per minute AND 20 per hour, per IP**. Both windows apply. This
574
+ * is anti-email-bombing, and the hourly one is what a "resend code" button
575
+ * with no cooldown will hit. Put a client-side cooldown on that button.
576
+ *
577
+ * @throws {OmsApiError} 409 when the address already has an account.
578
+ * @throws {OmsApiError} 422 with an array of validation messages when the
579
+ * address is not a valid email.
580
+ * @throws {OmsQuotaError} 429 on either the per-minute or the hourly bucket.
581
+ */
582
+ signUpStart(email: string, options?: RequestOptions): Promise<string>;
583
+ /**
584
+ * `POST /users/create_end` - presents the code and creates the account.
585
+ *
586
+ * Answers `201` with the new {@link User}. Anonymous.
587
+ *
588
+ * ## IT DOES NOT SIGN YOU IN
589
+ *
590
+ * No session is created and no token is returned. The account exists and the
591
+ * caller is still anonymous. Follow it immediately with {@link signIn} using
592
+ * the same email and password - that is what both the web app and the native
593
+ * app do, and forgetting it is the classic "signup worked but the app is
594
+ * still on the login screen" bug.
595
+ *
596
+ * ```ts
597
+ * await oms.sessions.signUpStart(email);
598
+ * // user reads the email, types six digits
599
+ * await oms.sessions.signUpComplete({ email, code, name, password });
600
+ * const session = await oms.sessions.signIn({ email, password });
601
+ * ```
602
+ *
603
+ * `handle` cannot be chosen here even though the column exists: the parameter
604
+ * is not permitted on this action, and a `before_create` hook generates one
605
+ * from `name`. Let the user change it afterwards with
606
+ * `oms.account.update({ handle })`, where 15 characters is the ceiling.
607
+ *
608
+ * Consuming the code also stamps `email_verified_at`, inside the same create.
609
+ * The address is proven, so a freshly signed-up account is never in the
610
+ * "verify your email" limbo.
611
+ *
612
+ * Throttled to **10 a minute per IP**, shared with the other three `*_end`
613
+ * endpoints. Remember the per-code budget is separate and much smaller:
614
+ * {@link VERIFICATION_CODE_MAX_ATTEMPTS} wrong guesses destroy the code
615
+ * outright.
616
+ *
617
+ * @throws {OmsApiError} 404 `"Invalid Verification"` for a wrong code, an
618
+ * expired code, a code issued for a different address, and a code that has
619
+ * already been burned. All four look identical.
620
+ * @throws {OmsApiError} 422 with validation messages when the code was right
621
+ * but the account could not be created - a name that is too long, an
622
+ * address taken in the meantime. The code is CONSUMED by then, so the user
623
+ * has to restart at {@link signUpStart}.
624
+ */
625
+ signUpComplete(input: SignUpInput, options?: RequestOptions): Promise<User>;
626
+ /**
627
+ * `POST /users/reset_password_start` - emails a reset code, if the address is
628
+ * registered.
629
+ *
630
+ * Anonymous. **Always answers `200` with the same bare string**, whether or
631
+ * not the address exists: `"If that email is registered, password reset
632
+ * instructions have been sent."`. That is anti-enumeration, and it is the
633
+ * deliberate opposite of {@link signUpStart}, which does tell you. Do not
634
+ * present this result to the user as confirmation that mail is on its way to
635
+ * a real account, because it is not evidence of that.
636
+ *
637
+ * A real send also fires a `password_reset_started` security alert to the
638
+ * owner.
639
+ *
640
+ * Same throttle family as every other `*_start`: **4 a minute and 20 an hour
641
+ * per IP**, shared.
642
+ */
643
+ resetPasswordStart(email: string, options?: RequestOptions): Promise<string>;
644
+ /**
645
+ * `POST /users/reset_password_end` - presents the code and sets a new
646
+ * password.
647
+ *
648
+ * Anonymous, and answers `200` with the updated {@link User}. `password` is
649
+ * the ONLY field it writes; anything else in the body is dropped.
650
+ *
651
+ * It does NOT sign you in and it does NOT revoke other sessions. Resetting a
652
+ * password because it may have leaked leaves every existing session token
653
+ * alive, since a session is a row and not a signature over the password. If
654
+ * you are building a "my account was compromised" flow, changing the password
655
+ * is not enough on its own, and this API gives a user no way to end their own
656
+ * other sessions ({@link signOut} only ends the caller's). Escalating to an
657
+ * administrator and {@link deactivateUser} is the only lever that clears them.
658
+ *
659
+ * Consuming the code stamps `email_verified_at`: proving control of the
660
+ * mailbox verifies the address even if it never was verified before.
661
+ *
662
+ * Throttled to **10 a minute per IP**, shared with the other `*_end`
663
+ * endpoints, on top of the per-code budget of
664
+ * {@link VERIFICATION_CODE_MAX_ATTEMPTS}.
665
+ *
666
+ * @throws {OmsApiError} 404 `"Invalid Verification"` for a wrong, expired,
667
+ * burned or mismatched code; also `"User not found."` in the narrow race
668
+ * where the account is deleted between the code being verified and the row
669
+ * being loaded.
670
+ * @throws {OmsApiError} 422 with validation messages when the new password is
671
+ * rejected. The code is already consumed at that point.
672
+ */
673
+ resetPasswordComplete(input: ResetPasswordInput, options?: RequestOptions): Promise<User>;
674
+ /**
675
+ * `POST /users/update_email_start` - emails TWO codes: one to the address
676
+ * currently on the account, one to the address it is moving to.
677
+ *
678
+ * Requires a live session. One HTTP request, two `EmailVerification` rows,
679
+ * two different reasons (`email_update_prev` and `email_update_new`), and
680
+ * {@link changeEmailComplete} needs both codes back. Proving control of the
681
+ * new mailbox alone is not enough: an attacker sitting on a hijacked session
682
+ * would otherwise move the account to an address they own and lock the real
683
+ * owner out permanently.
684
+ *
685
+ * The old address is read from the session, never from the arguments, so
686
+ * there is nothing to spoof: `email` here is the NEW address only.
687
+ *
688
+ * The two issues are not atomic. The previous-address code is issued first,
689
+ * and if the new address fails validation the call answers `422` with the old
690
+ * code already sent and live. Harmless, but expect users to report a code
691
+ * arriving for a change that "failed".
692
+ *
693
+ * Answers `200` with the bare string `"Email update instructions sent."`.
694
+ *
695
+ * Same shared `*_start` throttle: **4 a minute and 20 an hour per IP**. Note
696
+ * that this is one request even though it sends two emails, so it costs one
697
+ * unit of the budget, not two.
698
+ *
699
+ * @throws {OmsAuthError} 401 without a live session.
700
+ * @throws {OmsApiError} 422 with validation messages when either address is
701
+ * not a valid email.
702
+ */
703
+ changeEmailStart(newEmail: string, options?: RequestOptions): Promise<string>;
704
+ /**
705
+ * `POST /users/update_email_end` - presents both codes and moves the address.
706
+ *
707
+ * Requires a live session; answers `200` with the updated {@link User}.
708
+ *
709
+ * Both codes are checked BEFORE either is consumed (the controller verifies
710
+ * twice with `destroy: false`, then verifies again to consume), so getting
711
+ * one right and one wrong burns neither. What it does still cost is an
712
+ * attempt against BOTH live codes: a wrong guess charges
713
+ * `register_failed_attempt` on the code for that reason, so a user typing the
714
+ * two codes into the wrong boxes spends one of the five guesses on each. With
715
+ * two codes in play the per-code budget is easier to exhaust than anywhere
716
+ * else in this family - validate with {@link isVerificationCode} first, and
717
+ * label the two inputs unmistakably.
718
+ *
719
+ * Consuming both stamps `email_verified_at`, since both mailboxes are proven.
720
+ *
721
+ * Throttled to **10 a minute per IP**, shared with the other `*_end`
722
+ * endpoints.
723
+ *
724
+ * @throws {OmsAuthError} 401 without a live session.
725
+ * @throws {OmsApiError} 404 `"Invalid Verification"` when either code is
726
+ * wrong, expired or burned. The message does not say which one.
727
+ * @throws {OmsApiError} 422 with validation messages when the new address is
728
+ * rejected at write time - already taken, malformed. Both codes are
729
+ * consumed by then and the flow restarts at {@link changeEmailStart}.
730
+ */
731
+ changeEmailComplete(input: ChangeEmailInput, options?: RequestOptions): Promise<User>;
732
+ /**
733
+ * `POST /users/destroy_start` - emails a deletion code to the address on the
734
+ * account.
735
+ *
736
+ * Requires a live session. The address is taken from the session, so a user
737
+ * can only ever start deleting themselves; there is no argument and nothing
738
+ * to point at somebody else.
739
+ *
740
+ * Not in the same league as the other flows: {@link deleteAccountComplete}
741
+ * destroys the row and everything hanging off it. Make the confirmation
742
+ * unmistakable, and note that the code is the only thing standing between a
743
+ * hijacked session and a deleted account.
744
+ *
745
+ * Answers `200` with the bare string `"User deletion instructions sent."`.
746
+ * Shared `*_start` throttle: **4 a minute and 20 an hour per IP**.
747
+ *
748
+ * Included here even though it is the one pair of routes the sibling
749
+ * documentation does not list, because nothing else in the SDK covers it and
750
+ * a user who cannot delete their account has no exit.
751
+ *
752
+ * @throws {OmsAuthError} 401 without a live session.
753
+ */
754
+ deleteAccountStart(options?: RequestOptions): Promise<string>;
755
+ /**
756
+ * `POST /users/destroy_end` - presents the code and DESTROYS THE ACCOUNT.
757
+ *
758
+ * Requires a live session. Irreversible: `user.destroy` runs, taking the
759
+ * user's sessions, files, music library and everything else that cascades
760
+ * from the row. There is no soft-delete on this path and no undo.
761
+ * {@link deactivateUser} is the reversible operation, and it is
762
+ * administrators only.
763
+ *
764
+ * Answers `200` with an empty body. The credential is dead the moment this
765
+ * resolves - the sessions went with the user - so discard the client and
766
+ * every stored token; do not try to {@link signOut} afterwards.
767
+ *
768
+ * Throttled to **10 a minute per IP**, shared with the other `*_end`
769
+ * endpoints, plus the per-code budget.
770
+ *
771
+ * @throws {OmsAuthError} 401 without a live session.
772
+ * @throws {OmsApiError} 404 `"Invalid Verification"` for a wrong, expired or
773
+ * burned code.
774
+ * @throws {OmsApiError} 500 with the model's error messages when the record
775
+ * could not be destroyed - a foreign key that refused to cascade. The
776
+ * account survives; the code does not.
777
+ */
778
+ deleteAccountComplete(code: string, options?: RequestOptions): Promise<void>;
779
+ /**
780
+ * `GET /users` - the user roster.
781
+ *
782
+ * Requires a credential, and any authenticated account can enumerate the
783
+ * whole table: `User.viewable_by` is `->(user) { all }`. What an ordinary
784
+ * caller does NOT get is the privileged columns - `group`, `email`, `gender`,
785
+ * `last_seen_at`, `sessions_count`, `deactivated_at` and
786
+ * `allowed_to_use_spotify` are all rendered conditionally, so an absent key
787
+ * means "not visible to you", never "empty".
788
+ *
789
+ * This used to be anonymous and is not any more, precisely so that the roster
790
+ * could not be harvested. For a picker, prefer `oms.account.search()`: it is
791
+ * anonymous, capped at eight rows, and returns only id, handle and name.
792
+ *
793
+ * Only `name` and `handle` are filterable. Any other key is a `400 "Unknown
794
+ * search filter"` - this DSL fails closed rather than ignoring what it does
795
+ * not recognise.
796
+ *
797
+ * Deactivated accounts are NOT filtered out of this listing (the `active`
798
+ * scope is applied by `users#search`, not by the index), so a roster shows
799
+ * them; an administrator can tell by `deactivated_at`, and nobody else can.
800
+ *
801
+ * Index responses carry an `ETag`, so a repeat can answer `304` with no body.
802
+ * Counts against the general authenticated ceiling, 600 a minute.
803
+ */
804
+ listUsers(params?: ListUsersParams, options?: RequestOptions): Promise<Paginated<User>>;
805
+ /**
806
+ * `POST /users/:id/deactivate` - administrators only. Suspends an account.
807
+ *
808
+ * ## This is also the only way to revoke somebody's sessions
809
+ *
810
+ * `User#deactivate!` stamps `deactivated_at` and runs `sessions.delete_all`
811
+ * in the same transaction, so every device the target is signed in on is
812
+ * logged out at once, and `Session`'s create validation then refuses to mint
813
+ * a new one. It is the single lever in this API that ends a session other
814
+ * than the caller's own - {@link signOut} cannot, and neither can anything in
815
+ * `oms.account.sessions`. If a token has leaked, this is the response.
816
+ *
817
+ * Reversible with {@link reactivateUser}, which clears the stamp. The old
818
+ * sessions do not come back; the user signs in again.
819
+ *
820
+ * Answers `200` with the target {@link User}.
821
+ *
822
+ * @throws {OmsAuthError} 401 `"Admins only."` for a non-administrator, and
823
+ * also for an anonymous caller.
824
+ * @throws {OmsApiError} 400 `"Cannot deactivate yourself."` - the guard that
825
+ * stops an administrator locking themselves out.
826
+ * @throws {OmsApiError} 404 `"User not found."`
827
+ */
828
+ deactivateUser(id: Id, options?: RequestOptions): Promise<User>;
829
+ /**
830
+ * `POST /users/:id/reactivate` - administrators only. Clears
831
+ * `deactivated_at`.
832
+ *
833
+ * The account can sign in again from the next request. It does NOT restore
834
+ * the sessions {@link deactivateUser} deleted, so every device has to sign in
835
+ * fresh. Answers `200` with the target {@link User}.
836
+ *
837
+ * Unlike deactivation there is no self-guard, because reactivating yourself
838
+ * is not reachable: a deactivated administrator has no session to call with.
839
+ *
840
+ * @throws {OmsAuthError} 401 `"Admins only."`
841
+ * @throws {OmsApiError} 404 `"User not found."`
842
+ */
843
+ reactivateUser(id: Id, options?: RequestOptions): Promise<User>;
844
+ }