Commit 198ee2e for jssip.net

commit 198ee2e65c2bc66fa74b1782c299178680da7493
Author: José Luis Millán <jmillan@aliax.net>
Date:   Fri Dec 4 10:00:16 2026 +0100

    Docs: more

diff --git a/TODO.md b/TODO.md
new file mode 100644
index 0000000..434bb81
--- /dev/null
+++ b/TODO.md
@@ -0,0 +1,410 @@
+# TODO
+
+Loose ends noted while porting the library to TypeScript. None of them block
+the port.
+
+## Bugs
+
+### `UA.stop()` does not terminate notifiers
+
+`stop()` runs `terminate()` on every session and every subscriber, and `close()`
+on every applicant, but it does nothing about notifiers. A notifier that got its
+dialog has armed `_setExpiresTimer()`, so with the usual `Expires: 3600` a one
+hour `setTimeout` outlives the UA and keeps the process alive.
+
+Found because it hung the new `src/test/test-Dialog.ts`, which now works around
+it by calling `notifier.terminate()` before stopping the UA.
+
+### Hanging up before the ACK never sends the BYE
+
+RFC 3261 Section 15 forbids a callee from sending a BYE on a confirmed
+dialog until the ACK to its 2xx has arrived, so `RTCSession.terminate()`
+defers it. Neither of the two routes it sets up can fire:
+
+```ts
+// Save the dialog for later restoration.
+const dialog = this.#dialog;
+
+this.receiveRequest = ({ method }) => { /* send the BYE on the ACK */ };
+this.#incoming.server_transaction.on('stateChanged', () => { /* or on timeout */ });
+
+this.#ended('local', null, cause);
+```
+
+`#ended()` calls `#close()`, which terminates that dialog and sets
+`#dialog` to `null`. `Dialog.terminate()` takes it out of the UA table too,
+so the ACK no longer matches a dialog and is absorbed by
+`UA.receiveRequest()`; the reassigned `receiveRequest` is never reached.
+The transaction timeout route fails the same way one step later, since
+`sendRequest()` finds no dialog and only logs `no valid early dialog
+found`.
+
+The comment names an intent that nothing carries out: the dialog is saved
+but never restored. Either hold the dialog open until the ACK, or send the
+BYE without one.
+
+Whichever way it is fixed, the session has to stay registered with the UA
+until the BYE is sent, or `stop()` will close the transport out from under
+it. `UA.#isIdle()` already treats a live session as something to wait for,
+and deliberately does not wait on the INVITE server transaction: that one
+holds 'accepted' for Timer L whether or not the ACK ever arrives, so it
+says nothing about whether anything is outstanding.
+
+`src/test/test-RTCSession.ts` pins the current behaviour, with the
+expectation to flip once this is fixed.
+
+### `UA.stop()` has never closed its applicants
+
+The loop over the applicants in `stop()` could not work, on two counts:
+
+- The table was keyed by the applicant itself, `this._applicants[message] =
+  message`, so every `Message` and `Options` landed under the single key
+  `'[object Object]'` and overwrote the previous one. The TypeScript port
+  turned the table into a `Set`, which fixes that half.
+- Neither class exposes a `close()`. Both only have a private `#close()`, so
+  `applicant.close()` throws a `TypeError` straight into the empty `catch`
+  that wraps it.
+
+The second half is left as it was, since making it work is a decision about
+what stopping should do to a MESSAGE or OPTIONS that is still in flight:
+`#close()` marks the applicant closed and unregisters it from the UA, but the
+transaction carrying the request runs to completion either way, and
+`#isIdle()` does not look at applicants. Either give both classes a public
+`close()` and let `stop()` call it, or drop the loop.
+
+### `Subscription-State` is compared case sensitively
+
+The grammar matches the state case insensitively but stores the text as the
+peer wrote it, since `substate_value` ends in
+`data.state = input.substring(pos, offset)`:
+
+```js
+Grammar.parse('Active;expires=60', 'Subscription_State');
+// { state: 'Active', expires: 60 }
+```
+
+`Subscriber.#parseSubscriptionState()` then switches on that text against
+lowercase literals, so a NOTIFY carrying `Subscription-State: Active` falls
+through to `undefined`, is answered 400, and tears the subscription down with
+`WRONG_NOTIFY_RECEIVED`. The value is a token, so RFC 6665 makes it case
+insensitive and such a notifier is within its rights.
+
+Fix it in whichever of the two places: lowercase in the grammar action, or
+lowercase before the switch. The grammar is generated from
+`src/Grammar.pegjs`, and the same pattern is worth checking on the other
+rules that capture a matched literal.
+
+### A subscriber can be pushed back to its initial state by the peer
+
+`#parseSubscriptionState()` maps `init` and `notify_wait` to `State.INIT` and
+`State.WAITING_NOTIFY`, on top of the `pending`, `active` and `terminated` of
+RFC 6665. Those two are internal states of the subscriber, not values a
+notifier can legitimately send, but `extension_substate = token` lets any of
+them through the grammar.
+
+A NOTIFY with `Subscription-State: init` therefore sets the subscriber back to
+`INIT`, after which `subscribe()` takes the initial branch again and sends a
+second out of dialog SUBSCRIBE, re-registering the subscriber with the UA.
+Only the three states of the RFC should be accepted.
+
+### A notifier is unusable before `start()`, but says nothing
+
+Everything a `Notifier` sends goes through its dialog, which only exists once
+`start()` has run. Nothing guards that:
+
+- `terminate()` reaches `#sendNotify()`, which dereferences the dialog and
+  throws a bare `TypeError`.
+- `notify()` reads an expiry timestamp that is still `null`, so the remaining
+  seconds come out `NaN`, `NaN <= 0` is false, and the NOTIFY goes out with
+  `Subscription-State: active;expires=NaN` before failing on the dialog the
+  same way.
+
+Both are reachable from the documented API: `ua.notify()` hands back a
+notifier the application is told to configure before calling `start()`. They
+should throw `InvalidStateError` like the other methods do, which is what the
+non-null assertions in `Notifier.ts` currently stand in for.
+
+### `Info.send()` refuses a state that `RTCSession.sendInfo()` admits
+
+`RTCSession.sendInfo()` lets the call through in `STATUS_CONFIRMED`,
+`STATUS_WAITING_FOR_ACK` or `STATUS_1XX_RECEIVED`, then hands over to
+`Info.send()`, which checks the first two only. Sending an INFO on an early
+dialog therefore throws `InvalidStateError` out of a call the session had just
+accepted.
+
+`DTMF` has the same pair of checks and lists all three states, so the INFO
+carrying a tone does go out in the early dialog while the one carrying
+application data does not. Whichever way it is settled, the two checks should
+agree.
+
+### `'failed'` is unobservable on an early dialog creation error
+
+`RTCSession.init_incoming()` calls `_createDialog()` around line 420, but the
+session only reaches the application through the `newRTCSession` emitted around
+line 463. On failure `_createDialog()` calls `_failed()`, which emits `'failed'`
+on a session nobody holds and the `UA` has not registered, so nothing can be
+listening. Only the `_close()` inside `_failed()` has any effect, and the 400
+reply is all the peer gets.
+
+Emitting `newRTCSession` before attempting the dialog would fix it, but it would
+expose a session that is about to die. Only reachable for a malformed INVITE.
+
+## API decisions
+
+### No `causes` member fits a malformed request
+
+Both dialog creation failures in `RTCSession` report
+`_failed('remote', message, JsSIP_C.causes.INTERNAL_ERROR)`. The originator is
+right, but `INTERNAL_ERROR` implies the fault is ours when the cause is always
+the peer's message: no Contact, no Call-ID, or no From tag.
+
+There is no better fit in `JsSIP_C.causes`, and the cause reaches applications
+through the `failed` event, so adding a member (or reusing one) is an API
+decision rather than a cleanup.
+
+### Rename `C.STATUS_1XX_RECEIVED` on the next API break
+
+Every member of `RTCSession.C` is the matching `Status` member with a
+`STATUS_` prefix, except this one. `STATUS_1XX_RECEIVED` could not simply
+drop its prefix, because `1XX_RECEIVED` is not a valid identifier, so the
+enum member is `Status.PROVISIONAL_RESPONSE_RECEIVED` and the two names
+diverge:
+
+```ts
+C.STATUS_1XX_RECEIVED === Status.PROVISIONAL_RESPONSE_RECEIVED; // 2
+```
+
+Rename the constant to `STATUS_PROVISIONAL_RESPONSE_RECEIVED` whenever a
+breaking change is acceptable, so that the two agree. `C` is reachable as
+both `RTCSession.C` and `session.C`, and an application comparing
+`session.status` against it would break, hence the wait.
+
+Three other sites spell it the old way and should follow:
+
+- `RTCSession/DTMF.ts`, twice: the `DTMFSession` shim declares it, and
+  `send()` compares the session status against it.
+- `src/test/RTCSession/test-DTMF.ts`, in its stand-in for the session
+  states.
+
+The `DTMFSession` and `InfoSession` shims go away with the event based
+rework anyway, so this may resolve itself there.
+
+### `failed` on `Info` and `DTMF` carries neither a cause nor `'system'`
+
+Both pages document the event as `originator: 'remote'/'system'` plus a
+`cause` out of `JsSIP_C.causes` and a `response` that is `null` when the
+originator is `'system'`. Neither class ever emits that: the only `failed` is
+the one a final negative response produces, always `{ originator: 'remote',
+response }`.
+
+There is nothing to report a local failure with, either, because a transport
+error, a timeout or a dialog error is handed straight back to the session
+(`onTransportError()`, `onRequestTimeout()`, `onDialogError()`) and the `Info`
+or `DTMF` the application holds never hears about it.
+
+So either the pages are wrong or the classes are. Making them agree means
+adding a `'system'` failure to both, which is an API addition.
+
+### Most of `JsSIP.C` is reachable by accident
+
+`JsSIP.C` is the whole `Constants` module, so `JsSIP.C.INVITE`,
+`JsSIP.C.REASON_PHRASE` and the rest have always worked. The official
+documentation mentions none of them: the only `JsSIP.C` it ever writes is
+`JsSIP.C.causes`, which has a page of its own, and `sendDTMF()` documents its
+`transportType` as the bare `'INFO'` and `'RFC2833'` strings rather than
+through `DTMF_TRANSPORT`.
+
+Everything but `causes`, `Originator`, `Direction` and `DTMF_TRANSPORT` is
+therefore marked `@internal`, which keeps it out of the API reference and
+leaves it reachable at run time. Narrowing what `JsSIP.C` exposes is the
+follow up, and it is an API break.
+
+## Architecture
+
+### Stop passing parent classes down to their children
+
+Almost every class is handed the object that owns it: `UA` goes into
+`Transactions`, `RequestSender`, `SIPMessage` and `sanityCheck`, and `Dialog`
+is handed both the `UA` and its owner (`RTCSession`, `Subscriber` or
+`Notifier`), which `Dialog/RequestSender` then reads back out of it.
+
+That coupling is what forced the structural shims the TypeScript port had to
+invent. Most are gone now that every module is TypeScript and can name the
+real type, but two are left in `SIPMessage`, where a message holds the
+transaction carrying it:
+
+- `SIPMessage.ClientTransactionLike`
+- `SIPMessage.ServerTransactionLike`
+
+Naming the real types there would close the circle, since `Transactions`
+imports `SIPMessage` for the messages it carries.
+
+Replacing a shim with a real import is only half the point, though: the
+child still holds its parent in order to call back into it. The fix is to
+invert that, so a child emits an event and lets the parent react.
+
+Use the `EnhancedEventEmitter` of mediasoup-client for it, so the events are
+typed and the children stop depending on their parents at all. The two shims
+above then go away rather than being replaced by real imports, the
+`@internal` members in the entry below lose their reason to be public, and
+the `intentionallyNotExported` list in `typedoc.config.mjs` empties out.
+
+### Members that exist only to be reached across modules
+
+The structural shims are gone: every module that is handed the UA now says
+`import type { UA } from './UA'`, and `Dialog.DialogOwner` is the
+`RTCSession | Subscriber | Notifier` union it always described.
+
+What the coupling still costs is three members that cannot be private
+because something outside reaches for them. All are marked `@internal`:
+
+- `ua` on `RTCSession`, `Subscriber` and `Notifier`, which `Dialog` reads
+  out of its owner.
+- `UA.transactions`, which `Transactions.checkTransaction()` destructures
+  and `sanityCheck()` reads.
+- `UA.applicants`, which only `src/test/test-Options.ts` reads.
+
+The event based rework above is what removes the need for them.
+
+### Configuration and configuration loading need rework
+
+One concept is spread over three hand maintained types and two modules, and
+`UA.#loadConfig()` holds it together by mutating as it goes.
+
+**Three types for one thing.** `UA.UAConfiguration` is what an application
+passes, `Configuration.Configuration` is what the checks produce, and
+`UA.LoadedConfiguration` is what a running UA hands out. None of them is
+derived from another, so they drift: `UAConfiguration` is written by hand
+next to the `checks` object that actually decides what is accepted, and
+nothing ties the two together.
+
+`UAConfiguration` is the one the API reference documents, since it is what
+`new JsSIP.UA()` takes, so the parameter documentation lives there now. A
+derived `Configuration` would keep it in one place for good. Deriving it
+mechanically was tried and dropped: Typedoc carries the comments through a
+mapped type, but it renders the result as the type expression itself rather
+than as a list of parameters, which is the whole page.
+
+**`#loadConfig()` mutates rather than derives.** It starts from a copy of
+`DEFAULT_CONFIGURATION` and rewrites it in place, which is what forces the
+`WorkingConfiguration` to `LoadedConfiguration` cast in `UA.ts`:
+
+- `sockets` is `delete`d once the `Transport` has taken it, so the running
+  configuration does not match the type the checks filled in.
+- `no_answer_timeout` is multiplied by 1000, so the same parameter means
+  seconds before loading and milliseconds after.
+- `display_name` accepts a number so that `0` is usable, and is turned into
+  `'0'` afterwards, so its type is wider than what is ever stored.
+- `instance_id`, `jssip_id`, `hostport_params`, `registrar_server`,
+  `contact_uri`, `via_host` and `authorization_user` are all filled in or
+  computed, so the parameters are nullable in the type and never null in
+  practice.
+
+It should build and return a value of its own instead, which removes both the
+cast and the `WorkingConfiguration` type. There is a matching TODO at the top
+of `Configuration.ts`.
+
+**Three disagreeing lists of mutable parameters.** Which parameters can be
+changed at runtime is stated in three places that do not match:
+
+| | parameters |
+| --- | --- |
+| `UA.get()` | `authorization_user`, `realm`, `ha1`, `authorization_jwt` |
+| `UA.set()` | those four, plus `password`, `display_name`, `extra_headers` |
+| `writable_parameters` | those seven, plus `register` |
+
+So `register` is left writable by the sealing but `set('register')` refuses
+it, and `password`, `display_name` and `extra_headers` can be written but not
+read back. There should be one list, with `get()`, `set()` and the sealing
+all derived from it.
+
+**The sealing is a runtime restatement of the type.** The loop at the end of
+`#loadConfig()` walks every parameter and calls `Object.defineProperty()` to
+make it writable or not. A `Readonly<>` on everything but the mutable list
+would say the same thing to the compiler; the runtime seal is only worth
+keeping for applications that are not using TypeScript.
+
+### Expose entry points through `exports` and become an ES module
+
+The package is CommonJS and everything is reached through a single index,
+`src/JsSIP.js`, whose `module.exports` object names every public symbol. Do it
+the way rtp.js does instead: `"type": "module"` plus an `exports` map in
+`package.json` pointing at per area entry points, with `typedoc`, `types` and
+`default` conditions (the `typedoc` one must come first so that the docs are
+built from the sources and not from the built declarations).
+
+This also removes a workaround the current layout needs: `typedoc.config.mjs`
+has to set `entryPoints` by hand, because there is no `exports` map to read
+them from.
+
+The port to TypeScript is done and no source uses `export =` any more, so what
+is left in the way is:
+
+- `src/Grammar.js` is generated as CommonJS and would be parsed as an ES
+  module. It is the one source that stays JavaScript, so it has to be
+  either regenerated in another form or wrapped.
+- `src/Constants.ts` and `src/SIPMessage.ts` call `require()` at runtime.
+  `src/JsSIP.ts` used to read the package manifest the same way, and now
+  takes the name and version from placeholders the build fills in, the way
+  mediasoup-client does.
+- Relative imports would all need explicit `.js` extensions.
+
+It is a breaking change for applications on Node.js older than 22.12, which is
+the first version that can `require()` an ES module, so it belongs in a major
+release together with an `engines` field.
+
+### Three declarations of the same accept and reject options
+
+`Message.AcceptOptions` and `Options.AcceptOptions` are the same declaration
+written twice, and so are `Message.RejectOptions` and `Options.RejectOptions`.
+`RTCSession.RejectOptions` says the same thing again, with the two extra
+headers fields coming from `ExtraHeaders` instead of being written out.
+
+The three are what an application passes to `accept()` and `reject()` on an
+incoming request, so they are the same concept in every case. Declaring them
+once, where `ExtraHeaders` already lives, would leave one page in the API
+reference instead of five and one place to document the defaults.
+
+The shapes are identical, so a type alias per module keeps every current name
+working. Worth doing before the modules reach the API reference.
+
+## Style
+
+### Comment lines over the print width
+
+Fifteen comment lines exceed 80 columns, the worst being 109 in
+`Subscriber.js` `_scheduleSubscribe()`. They are verbatim from the original
+sources. Prettier does not reflow comments and ESLint has no `max-len` rule, so
+they pass; wrapping them means rewording someone else's prose. The clusters are:
+
+- `Subscriber.js`, the Chrome timer throttling explanation, 6 lines.
+- `RTCSession.js`, the RFC 3261 section 15 CANCEL note, 4 lines.
+- `Dialog.ts`, the `RFC3261 12.2.2` and `RFC6665 3.2` remote target notes.
+
+### Two conventions for the event type of a class
+
+The ported modules declare their events in one of two ways:
+
+- `UA.ts`, `RTCSession.ts`, `Notifier.ts`, `Subscriber.ts`, `Message.ts`,
+  `Options.ts` and `RTCSession/ReferSubscriber.ts` give the `EventMap`
+  tuples of arguments. The ones whose class takes an `eventHandlers` option
+  derive an `EventHandlers` from it with a mapped type.
+- `RTCSession/Info.ts` and `RTCSession/DTMF.ts` give the `EventMap` function
+  types directly, since nothing derives from it.
+
+So only the two smallest are left on the other form.
+
+Both read fine on their own, but the same name means two different shapes
+depending on the module, which shows in the API reference. Settle on the
+tuple form everywhere once the typed event surface is reworked with
+`EnhancedEventEmitter`, since that is what decides the shape in the end.
+
+### `typedoc.config.mjs` has the one remaining single line JSDoc
+
+```js
+/** @type {Partial<import('typedoc').TypeDocOptions>} */
+```
+
+Everywhere else `/**` sits alone on its line. This one is the canonical way to
+type a config export, and the file is outside the ESLint paths
+(`eslint.config.mjs`, `npm-scripts.mjs`, `src`), so it was left as is.
diff --git a/src/Configuration.ts b/src/Configuration.ts
index a3a1d20..6d426c8 100644
--- a/src/Configuration.ts
+++ b/src/Configuration.ts
@@ -1,3 +1,9 @@
+/**
+ * The validated form of what the application configures the UA with.
+ *
+ * @module Configuration
+ */
+
 import {
 	CONNECTION_RECOVERY_MAX_INTERVAL,
 	CONNECTION_RECOVERY_MIN_INTERVAL,
@@ -10,7 +16,7 @@ import * as Grammar from './Grammar';
 import { isSocket } from './Socket';
 import type { WeightedSocket } from './Socket';
 import { createRandomToken, isDecimal, isEmpty } from './Utils';
-import URI = require('./URI');
+import { URI } from './URI';

 // TODO: `UA` mutates this object in ways this type cannot express: it deletes
 // `sockets`, adds `jssip_id` and `hostport_params`, and rewrites
@@ -18,209 +24,44 @@ import URI = require('./URI');
 // value from this one instead of mutating it.

 /**
- * What a UA is configured with.
+ * What a UA is configured with, once every parameter has been validated and
+ * the ones written as text turned into their SIP types.
  *
- * Only {@link Configuration.uri} and {@link Configuration.sockets} are
- * mandatory. Every other parameter falls back to the default documented on
- * it.
+ * @remarks
+ * - Each parameter is described on `UAConfiguration`, which is what the
+ *   application gives the UA.
  *
- * @example
- * ```ts
- * const ua = new JsSIP.UA({
- *   uri: 'sip:alice@example.com',
- *   sockets: new JsSIP.WebSocketInterface('wss://sip.example.com'),
- *   password: 'secret',
- * });
- * ```
+ * @internal
  */
 export type Configuration = {
-	/**
-	 * Username used to authenticate, when it differs from the user part of
-	 * {@link Configuration.uri}.
-	 *
-	 * @defaultValue `null`
-	 */
 	authorization_user: string | null;
-	/**
-	 * The plain SIP authentication password.
-	 *
-	 * @defaultValue `null`
-	 *
-	 * @remarks
-	 * - It is deleted from memory after the first successful authentication,
-	 *   the resulting {@link Configuration.ha1} and {@link Configuration.realm}
-	 *   being stored instead.
-	 */
 	password: string | null;
-	/**
-	 * SIP authentication realm.
-	 *
-	 * @defaultValue `null`
-	 *
-	 * @remarks
-	 * - Only useful when the plain {@link Configuration.password} is not
-	 *   given, in which case {@link Configuration.ha1} is required too.
-	 */
 	realm: string | null;
-	/**
-	 * `HA1` hash of the credentials, for Digest authentication.
-	 *
-	 * @defaultValue `null`
-	 *
-	 * @remarks
-	 * - When given, and the plain {@link Configuration.password} is not,
-	 *   {@link Configuration.realm} is required too. Authentication is not
-	 *   feasible otherwise.
-	 */
 	ha1: string | null;
-	/**
-	 * Token used as authentication credential. Every outgoing request carries
-	 * an Authorization header field with the Bearer scheme and this value.
-	 *
-	 * @defaultValue `null`
-	 */
 	authorization_jwt: string | null;

-	/**
-	 * Descriptive name shown to the called party when calling or sending
-	 * messages.
-	 *
-	 * @defaultValue `null`
-	 *
-	 * @remarks
-	 * - It must NOT be enclosed between double quotes, even when it contains
-	 *   multi-byte symbols. The library always encloses it.
-	 * - A number is accepted because a `0` is a legitimate display name, which
-	 *   `UA` turns into `'0'`.
-	 */
 	display_name: string | number | null;
-	/**
-	 * Address of record of the UA, so its SIP address. The only mandatory
-	 * parameter together with {@link Configuration.sockets}.
-	 *
-	 * @defaultValue `null`
-	 */
 	uri: URI | null;
-	/**
-	 * URI to be used in the Contact header field.
-	 *
-	 * @defaultValue `null`
-	 *
-	 * @remarks
-	 * - Its host becomes {@link Configuration.via_host}. When it is not given,
-	 *   the Contact is built out of `via_host` instead.
-	 */
 	contact_uri: URI | null;

-	/**
-	 * UUID identifying this UA instance when using GRUU, announced in the
-	 * `+sip.instance` Contact parameter.
-	 *
-	 * @defaultValue `null`
-	 *
-	 * @remarks
-	 * - Accepted with or without the `uuid:` prefix.
-	 * - A random UUID is used when it is not given.
-	 */
 	instance_id: string | null;

-	/**
-	 * Whether every initial request carries a Route header field with the SIP
-	 * URI of the server. Some SIP outbound proxies require it.
-	 *
-	 * @defaultValue `false`
-	 */
 	use_preloaded_route: boolean;

-	/**
-	 * Whether to run the session timers of
-	 * [RFC 4028](https://datatracker.ietf.org/doc/html/rfc4028), which keep a
-	 * session alive by refreshing it.
-	 *
-	 * @defaultValue `true`
-	 */
 	session_timers: boolean;
-	/**
-	 * Request method used to refresh a session, either `UPDATE` or `INVITE`.
-	 *
-	 * @defaultValue `'UPDATE'`
-	 */
 	session_timers_refresh_method: string;
-	/**
-	 * Whether to force being the refresher of the session timers of outgoing
-	 * calls, which adds the `refresher=uac` parameter to the Session-Expires
-	 * header field of the initial INVITE.
-	 *
-	 * @defaultValue `false`
-	 */
 	session_timers_force_refresher: boolean;
-	/**
-	 * Time (in seconds) after which an incoming call is rejected if not
-	 * answered.
-	 *
-	 * @defaultValue `60`
-	 */
 	no_answer_timeout: number;

-	/**
-	 * Whether to register as soon as the UA starts.
-	 *
-	 * @defaultValue `true`
-	 */
 	register: boolean;
-	/**
-	 * How long (in seconds) a registration lasts before the UA refreshes it.
-	 *
-	 * @defaultValue `600`
-	 */
 	register_expires: number;
-	/**
-	 * Trail added to the tag of the From header field of each REGISTER
-	 * request, either a static string or a function returning one.
-	 *
-	 * @defaultValue `''`
-	 */
 	register_from_tag_trail: string | (() => string);
-	/**
-	 * URI of the registrar, which must be a SIP URI without username.
-	 *
-	 * @defaultValue `null`
-	 *
-	 * @remarks
-	 * - When not given it is taken from {@link Configuration.uri} by removing
-	 *   its username.
-	 */
 	registrar_server: URI | null;

-	/**
-	 * Transports the UA connects through. The only mandatory parameter
-	 * together with {@link Configuration.uri}.
-	 *
-	 * @defaultValue `null`
-	 *
-	 * @remarks
-	 * - A single {@link Socket}, an array of them, or an array of
-	 *   {@link WeightedSocket} to give each one a preference.
-	 */
 	sockets: WeightedSocket[] | null;
-	/**
-	 * Maximum interval (in seconds) between transport reconnection attempts.
-	 *
-	 * @defaultValue `30`
-	 */
 	connection_recovery_max_interval: number;
-	/**
-	 * Minimum interval (in seconds) between transport reconnection attempts.
-	 *
-	 * @defaultValue `2`
-	 */
 	connection_recovery_min_interval: number;

-	/**
-	 * Custom SIP header fields added to every request and response.
-	 *
-	 * @defaultValue `null`
-	 */
 	extra_headers: string[] | null;

 	/**
@@ -235,15 +76,6 @@ export type Configuration = {
 	 */
 	via_host: string;

-	/**
-	 * Value of the User-Agent header field present in SIP messages. By
-	 * default `JsSIP` followed by the code version, as
-	 * {@link Constants.USER_AGENT} gives it.
-	 *
-	 * @remarks
-	 * - Optional because, unlike every other parameter, it has no default. It
-	 *   only exists once the application configures it.
-	 */
 	user_agent?: string;
 };

diff --git a/src/Constants.ts b/src/Constants.ts
index 20c7b7e..cf9c1c8 100644
--- a/src/Constants.ts
+++ b/src/Constants.ts
@@ -1,3 +1,14 @@
+/**
+ * The causes reported in the `failed` and `ended` events, plus the values the
+ * other events and the options are typed with.
+ *
+ * @remarks
+ * - Reachable as `JsSIP.C` at runtime, which also carries the SIP constants
+ *   the library works with internally.
+ *
+ * @module Constants
+ */
+
 // `package.json` lives outside `rootDir` so it cannot be `import`ed. A plain
 // `require()` is not resolved by TypeScript against `rootDir`, so it is used
 // here instead.
@@ -7,16 +18,22 @@ const pkg = require('../package.json') as { title: string; version: string };
 /**
  * Value of the User-Agent header field of outgoing requests, unless the
  * `user_agent` configuration parameter overrides it.
+ *
+ * @internal
  */
 export const USER_AGENT = `${pkg.title} ${pkg.version}`;

 /**
  * The `sip` URI scheme.
+ *
+ * @internal
  */
 export const SIP = 'sip';

 /**
  * The `sips` URI scheme, which asks for the request to travel over TLS.
+ *
+ * @internal
  */
 export const SIPS = 'sips';

@@ -154,6 +171,8 @@ export enum causes {
 /**
  * The SIP response codes each {@link causes} member is reported for, indexed
  * by the name of the cause.
+ *
+ * @internal
  */
 export const SIP_ERROR_CAUSES: Record<string, number[]> = {
 	REDIRECTED: [300, 301, 302, 305, 380],
@@ -168,61 +187,85 @@ export const SIP_ERROR_CAUSES: Record<string, number[]> = {

 /**
  * The ACK request method.
+ *
+ * @internal
  */
 export const ACK = 'ACK';

 /**
  * The BYE request method.
+ *
+ * @internal
  */
 export const BYE = 'BYE';

 /**
  * The CANCEL request method.
+ *
+ * @internal
  */
 export const CANCEL = 'CANCEL';

 /**
  * The INFO request method.
+ *
+ * @internal
  */
 export const INFO = 'INFO';

 /**
  * The INVITE request method.
+ *
+ * @internal
  */
 export const INVITE = 'INVITE';

 /**
  * The MESSAGE request method.
+ *
+ * @internal
  */
 export const MESSAGE = 'MESSAGE';

 /**
  * The NOTIFY request method.
+ *
+ * @internal
  */
 export const NOTIFY = 'NOTIFY';

 /**
  * The OPTIONS request method.
+ *
+ * @internal
  */
 export const OPTIONS = 'OPTIONS';

 /**
  * The REGISTER request method.
+ *
+ * @internal
  */
 export const REGISTER = 'REGISTER';

 /**
  * The REFER request method.
+ *
+ * @internal
  */
 export const REFER = 'REFER';

 /**
  * The UPDATE request method.
+ *
+ * @internal
  */
 export const UPDATE = 'UPDATE';

 /**
  * The SUBSCRIBE request method.
+ *
+ * @internal
  */
 export const SUBSCRIBE = 'SUBSCRIBE';

@@ -253,6 +296,8 @@ export enum DTMF_TRANSPORT {
  * @remarks
  * - Taken from the
  *   [IANA SIP parameters registry](https://www.iana.org/assignments/sip-parameters).
+ *
+ * @internal
  */
 export const REASON_PHRASE: Record<number, string> = {
 	100: 'Trying',
@@ -332,6 +377,8 @@ export const REASON_PHRASE: Record<number, string> = {
 /**
  * Value of the Allow header field of outgoing messages, so the request
  * methods the library accepts.
+ *
+ * @internal
  */
 export const ALLOWED_METHODS =
 	'INVITE,ACK,CANCEL,BYE,UPDATE,MESSAGE,OPTIONS,REFER,INFO,NOTIFY,SUBSCRIBE';
@@ -339,11 +386,15 @@ export const ALLOWED_METHODS =
 /**
  * Value of the Accept header field of outgoing messages, so the body types
  * the library accepts.
+ *
+ * @internal
  */
 export const ACCEPTED_BODY_TYPES = 'application/sdp, application/dtmf-relay';

 /**
  * Value of the Max-Forwards header field of outgoing requests.
+ *
+ * @internal
  */
 export const MAX_FORWARDS = 69;

@@ -351,12 +402,16 @@ export const MAX_FORWARDS = 69;
  * Default session interval (in seconds) proposed in the Session-Expires
  * header field, as defined by
  * [RFC 4028](https://datatracker.ietf.org/doc/html/rfc4028).
+ *
+ * @internal
  */
 export const SESSION_EXPIRES = 90;

 /**
  * Lowest session interval (in seconds) the library accepts, announced in the
  * Min-SE header field.
+ *
+ * @internal
  */
 export const MIN_SESSION_EXPIRES = 60;

@@ -364,6 +419,8 @@ export const MIN_SESSION_EXPIRES = 60;
  * Longest the UA waits (in seconds) before retrying a lost transport, unless
  * the `connection_recovery_max_interval` configuration parameter overrides
  * it.
+ *
+ * @internal
  */
 export const CONNECTION_RECOVERY_MAX_INTERVAL = 30;

@@ -371,5 +428,7 @@ export const CONNECTION_RECOVERY_MAX_INTERVAL = 30;
  * Shortest the UA waits (in seconds) before retrying a lost transport, unless
  * the `connection_recovery_min_interval` configuration parameter overrides
  * it.
+ *
+ * @internal
  */
 export const CONNECTION_RECOVERY_MIN_INTERVAL = 2;
diff --git a/src/Dialog.ts b/src/Dialog.ts
index 85a57d0..8b0c433 100644
--- a/src/Dialog.ts
+++ b/src/Dialog.ts
@@ -10,8 +10,8 @@ import * as SIPMessage from './SIPMessage';
 import type { IncomingMessage, IncomingRequest } from './SIPMessage';
 import * as Transactions from './Transactions';
 import * as Utils from './Utils';
-import NameAddrHeader = require('./NameAddrHeader');
-import URI = require('./URI');
+import { NameAddrHeader } from './NameAddrHeader';
+import { URI } from './URI';

 const logger = new Logger('Dialog');

@@ -53,14 +53,32 @@ export class DialogError extends Error {
 export type DialogType = 'UAS' | 'UAC';

 /**
- * RFC 3261 12.1 dialog id. Its `toString()` is the key the `UA` indexes
- * dialogs by.
+ * Dialog id, as
+ * [RFC 3261 Section 12.1](https://datatracker.ietf.org/doc/html/rfc3261#section-12.1)
+ * defines it.
  *
+ * @remarks
+ * - Its `toString()` is the key the UA indexes dialogs by.
  */
 export type DialogId = {
+	/**
+	 * Value of the Call-ID header field of the request that created the
+	 * dialog.
+	 */
 	call_id: string;
+	/**
+	 * The local tag, so the one of the From header field for a UAC and the
+	 * one of the To header field for a UAS.
+	 */
 	local_tag: string;
+	/**
+	 * The remote tag, so the one of the To header field for a UAC and the one
+	 * of the From header field for a UAS.
+	 */
 	remote_tag: string;
+	/**
+	 * The three of them concatenated.
+	 */
 	toString(): string;
 };

diff --git a/src/Exceptions.ts b/src/Exceptions.ts
index a508508..2410904 100644
--- a/src/Exceptions.ts
+++ b/src/Exceptions.ts
@@ -1,3 +1,12 @@
+/**
+ * The errors the library throws.
+ *
+ * @remarks
+ * - Reachable as `JsSIP.Exceptions` at runtime.
+ *
+ * @module Exceptions
+ */
+
 /**
  * Error during UA configuration object load.
  *
diff --git a/src/Grammar.d.ts b/src/Grammar.d.ts
index b2064fc..94f2207 100644
--- a/src/Grammar.d.ts
+++ b/src/Grammar.d.ts
@@ -1,5 +1,5 @@
-import NameAddrHeader = require('./NameAddrHeader');
-import URI = require('./URI');
+import { NameAddrHeader } from './NameAddrHeader';
+import { URI } from './URI';

 /**
  * The result of `parse()`, whose shape depends on the start rule used.
diff --git a/src/Grammar.js b/src/Grammar.js
index baaf761..b7fa6c4 100644
--- a/src/Grammar.js
+++ b/src/Grammar.js
@@ -12199,8 +12199,8 @@ module.exports = (function(){
         }
         return { line: line, column: column };
       }
-        var URI = require('./URI');
-        var NameAddrHeader = require('./NameAddrHeader');
+        var URI = require('./URI').URI;
+        var NameAddrHeader = require('./NameAddrHeader').NameAddrHeader;
         var data = {};
       var result = parseFunctions[startRule]();
       /*
diff --git a/src/Grammar.pegjs b/src/Grammar.pegjs
index 303a744..d553a9f 100644
--- a/src/Grammar.pegjs
+++ b/src/Grammar.pegjs
@@ -1,6 +1,6 @@
 {
-  var URI = require('./URI');
-  var NameAddrHeader = require('./NameAddrHeader');
+  var URI = require('./URI').URI;
+  var NameAddrHeader = require('./NameAddrHeader').NameAddrHeader;

   var data = {};
 }
diff --git a/src/IncomingMessageBuilder.ts b/src/IncomingMessageBuilder.ts
index 47cd9eb..37f95ea 100644
--- a/src/IncomingMessageBuilder.ts
+++ b/src/IncomingMessageBuilder.ts
@@ -1,8 +1,8 @@
 import type { UA } from './UA';
 import { Logger } from './Logger';
 import * as Grammar from './Grammar';
-import NameAddrHeader = require('./NameAddrHeader');
-import URI = require('./URI');
+import { NameAddrHeader } from './NameAddrHeader';
+import { URI } from './URI';
 import {
 	IncomingMessage,
 	IncomingMessageParams,
diff --git a/src/JsSIP.ts b/src/JsSIP.ts
index 6adbbe4..5cc0057 100644
--- a/src/JsSIP.ts
+++ b/src/JsSIP.ts
@@ -7,8 +7,8 @@ import { RTCSession } from './RTCSession';
 import { UA } from './UA';
 import * as Utils from './Utils';
 import { WebSocketInterface } from './WebSocketInterface';
-import NameAddrHeader = require('./NameAddrHeader');
-import URI = require('./URI');
+import { NameAddrHeader } from './NameAddrHeader';
+import { URI } from './URI';

 export { C, Exceptions, Grammar, Utils };
 export { NameAddrHeader, RTCSession, UA, URI, WebSocketInterface };
diff --git a/src/Message.ts b/src/Message.ts
index 7263e18..fd3428c 100644
--- a/src/Message.ts
+++ b/src/Message.ts
@@ -1,3 +1,9 @@
+/**
+ * Instant messaging with SIP MESSAGE requests.
+ *
+ * @module Message
+ */
+
 import type { UA } from './UA';
 import { EventEmitter } from 'events';

@@ -13,8 +19,8 @@ import type {
 	OutgoingRequestParams,
 } from './SIPMessage';
 import * as Utils from './Utils';
-import NameAddrHeader = require('./NameAddrHeader');
-import URI = require('./URI');
+import { NameAddrHeader } from './NameAddrHeader';
+import { URI } from './URI';

 const logger = new Logger('Message');

@@ -22,7 +28,13 @@ const logger = new Logger('Message');
  * Reported when the MESSAGE got a 2xx response.
  */
 export type MessageSucceededEvent = {
+	/**
+	 * Always `'remote'`, since only the peer can accept a MESSAGE.
+	 */
 	originator: Originator;
+	/**
+	 * The 2xx response that accepted it.
+	 */
 	response: IncomingResponse;
 };

@@ -30,8 +42,18 @@ export type MessageSucceededEvent = {
  * Reported when the MESSAGE could not be delivered.
  */
 export type MessageFailedEvent = {
+	/**
+	 * `'remote'` when the peer answered with a negative response, `'system'`
+	 * when the request timed out or the transport failed.
+	 */
 	originator: Originator;
+	/**
+	 * The negative response, and `null` when the originator is `'system'`.
+	 */
 	response: IncomingResponse | null;
+	/**
+	 * Why the MESSAGE was not delivered.
+	 */
 	cause: JsSIP_C.causes;
 };

@@ -39,7 +61,13 @@ export type MessageFailedEvent = {
  * The events a {@link Message} emits.
  */
 export type MessageEventMap = {
+	/**
+	 * The MESSAGE got a final positive response.
+	 */
 	succeeded: [event: MessageSucceededEvent];
+	/**
+	 * The MESSAGE got no final positive response.
+	 */
 	failed: [event: MessageFailedEvent];
 };

@@ -85,7 +113,17 @@ export type SendMessageOptions = {
  * Options accepted by `accept()`.
  */
 export type AcceptOptions = {
+	/**
+	 * Whole `Name: value` header field lines to add to the response.
+	 */
 	extraHeaders?: string[] | null;
+	/**
+	 * Body of the response.
+	 *
+	 * @remarks
+	 * - Give its Content-Type header field in `extraHeaders`. A body with
+	 *   none is labelled `application/sdp`.
+	 */
 	body?: string;
 };

@@ -93,7 +131,17 @@ export type AcceptOptions = {
  * Options accepted by `reject()`.
  */
 export type RejectOptions = {
+	/**
+	 * Whole `Name: value` header field lines to add to the response.
+	 */
 	extraHeaders?: string[] | null;
+	/**
+	 * Body of the response.
+	 *
+	 * @remarks
+	 * - Give its Content-Type header field in `extraHeaders`. A body with
+	 *   none is labelled `application/sdp`.
+	 */
 	body?: string;
 	/**
 	 * Status code of the response, between 300 and 699.
@@ -113,12 +161,14 @@ export type RejectOptions = {
  *
  * @example
  * ```ts
- * ua.sendMessage('sip:bob@example.com', 'Hello there', {
+ * const message = ua.sendMessage('sip:bob@example.com', 'Hello there', {
  *   eventHandlers: {
  *     succeeded: () => console.log('delivered'),
  *     failed: ({ cause }) => console.log('not delivered', cause),
  *   },
  * });
+ *
+ * message.data = { conversation: 42 };
  * ```
  */
 export class Message extends EventEmitter<MessageEventMap> {
@@ -136,6 +186,15 @@ export class Message extends EventEmitter<MessageEventMap> {
 	// eslint-disable-next-line @typescript-eslint/no-explicit-any
 	#data: any;

+	/**
+	 * @param ua - The UA that sends or received the MESSAGE.
+	 *
+	 * @remarks
+	 * - What `ua.sendMessage()` calls, and what the UA builds for a received
+	 *   MESSAGE. The application must not call it.
+	 *
+	 * @internal
+	 */
 	constructor(ua: UA) {
 		super();

@@ -194,6 +253,8 @@ export class Message extends EventEmitter<MessageEventMap> {
 	 *
 	 * @param target - Address of the remote peer.
 	 * @param body - Content of the message.
+	 * @param options - Content type and extra header fields of the MESSAGE,
+	 *   plus the listeners to register before it goes out.
 	 *
 	 * @throws
 	 * - `TypeError` if `target` or `body` is not given, or if `target` cannot
@@ -289,6 +350,8 @@ export class Message extends EventEmitter<MessageEventMap> {
 	 *
 	 * @remarks
 	 * - Called by the `UA`. The application must not call it.
+	 *
+	 * @internal
 	 */
 	init_incoming(request: IncomingRequest): void {
 		this.#request = request;
@@ -307,6 +370,8 @@ export class Message extends EventEmitter<MessageEventMap> {
 	/**
 	 * Accept the incoming message, answering it with a 200.
 	 *
+	 * @param options - Body and extra header fields of the response.
+	 *
 	 * @throws
 	 * - {@link NotSupportedError} if the message is outgoing.
 	 * - `Error` if the message was already replied.
@@ -332,6 +397,9 @@ export class Message extends EventEmitter<MessageEventMap> {
 	/**
 	 * Reject the incoming message.
 	 *
+	 * @param options - Status code, reason phrase, body and extra header
+	 *   fields of the response.
+	 *
 	 * @throws
 	 * - {@link NotSupportedError} if the message is outgoing.
 	 * - `Error` if the message was already replied.
diff --git a/src/NameAddrHeader.ts b/src/NameAddrHeader.ts
index 417fab8..c9edd60 100644
--- a/src/NameAddrHeader.ts
+++ b/src/NameAddrHeader.ts
@@ -1,5 +1,13 @@
+/**
+ * The `name-addr` and `addr-spec` header field values of
+ * [RFC 3261](https://datatracker.ietf.org/doc/html/rfc3261).
+ *
+ * @module NameAddrHeader
+ */
+
 import * as Grammar from './Grammar';
-import URI = require('./URI');
+import { URI } from './URI';
+import type { Parameters } from './URI';

 /**
  * Represents a `name-addr` or an `addr-spec` value as stated in the BNF
@@ -23,7 +31,7 @@ import URI = require('./URI');
  * from.toString(); // '"Alice" <sip:alice@example.com>;tag=1928301774'
  * ```
  */
-class NameAddrHeader {
+export class NameAddrHeader {
 	/**
 	 * Parse the given string into a {@link NameAddrHeader}.
 	 *
@@ -49,7 +57,7 @@ class NameAddrHeader {

 	#uri: URI;
 	#display_name?: string;
-	#parameters: URI.Parameters;
+	#parameters: Parameters;

 	/**
 	 * @param uri - Address the header field points at.
@@ -60,11 +68,7 @@ class NameAddrHeader {
 	 * @throws
 	 * - `TypeError` if `uri` is not a {@link URI}.
 	 */
-	constructor(
-		uri: URI,
-		display_name?: string,
-		parameters?: URI.Parameters | null
-	) {
+	constructor(uri: URI, display_name?: string, parameters?: Parameters | null) {
 		// Checks.
 		if (!uri || !(uri instanceof URI)) {
 			throw new TypeError('missing or invalid "uri" parameter');
@@ -202,7 +206,7 @@ class NameAddrHeader {
 		return new NameAddrHeader(
 			this.#uri.clone(),
 			this.#display_name,
-			JSON.parse(JSON.stringify(this.#parameters)) as URI.Parameters
+			JSON.parse(JSON.stringify(this.#parameters)) as Parameters
 		);
 	}

@@ -241,8 +245,3 @@ class NameAddrHeader {
 		return body;
 	}
 }
-
-// NOTE: Exported with `export =` because the pegjs generated `Grammar.js` does
-// `var NameAddrHeader = require('./NameAddrHeader')` and then
-// `new NameAddrHeader(...)`.
-export = NameAddrHeader;
diff --git a/src/Notifier.ts b/src/Notifier.ts
index 809d0c2..a39d3bc 100644
--- a/src/Notifier.ts
+++ b/src/Notifier.ts
@@ -1,3 +1,9 @@
+/**
+ * The notifier side of a subscription.
+ *
+ * @module Notifier
+ */
+
 import type { UA } from './UA';
 import { EventEmitter } from 'events';

@@ -9,18 +15,45 @@ import { Logger } from './Logger';
 import type { IncomingRequest } from './SIPMessage';
 import * as Utils from './Utils';

+export type { DialogId } from './Dialog';
+
 const logger = new Logger('Notifier');

 /**
  * Why the notifier stopped, as reported by the `terminated` event.
  */
 export enum TerminationCode {
+	/**
+	 * No response to a NOTIFY arrived before its transaction timed out.
+	 */
 	NOTIFY_RESPONSE_TIMEOUT = 0,
+	/**
+	 * A NOTIFY could not be sent because the transport failed.
+	 */
 	NOTIFY_TRANSPORT_ERROR = 1,
+	/**
+	 * A NOTIFY was answered with a failure response, or the dialog it was
+	 * sent in no longer exists.
+	 */
 	NOTIFY_NON_OK_RESPONSE = 2,
+	/**
+	 * A NOTIFY was challenged and the configured credentials did not answer
+	 * the challenge.
+	 */
 	NOTIFY_AUTHENTICATION_FAILED = 3,
+	/**
+	 * {@link Notifier.terminate} sent the final NOTIFY.
+	 */
 	FINAL_NOTIFY_SENT = 4,
+	/**
+	 * The subscriber ended the subscription, with a SUBSCRIBE carrying
+	 * `Expires: 0`.
+	 */
 	UNSUBSCRIBE_RECEIVED = 5,
+	/**
+	 * The subscription ran out, so the final NOTIFY went out with a
+	 * `reason=timeout` parameter.
+	 */
 	SUBSCRIPTION_EXPIRED = 6,
 }

@@ -29,18 +62,30 @@ export enum TerminationCode {
  * every NOTIFY reports.
  */
 export enum State {
+	/**
+	 * The subscription was accepted but the event is not reported yet, so it
+	 * is waiting for whatever authorizes it.
+	 */
 	PENDING = 0,
+	/**
+	 * The subscription is authorized and the event is reported.
+	 */
 	ACTIVE = 1,
+	/**
+	 * The subscription is over and the notifier is of no further use.
+	 */
 	TERMINATED = 2,
 }

 /**
- * The constants the notifier exposes, both as a static and as an instance
- * member.
+ * The notifier termination codes and states.
  *
  * @remarks
  * - {@link TerminationCode} and {@link State} hold the same values under
- *   shorter names, and are what the notifier itself is typed with.
+ *   shorter names, and are what the notifier itself is typed with. For
+ *   internal use.
+ *
+ * @internal
  */
 export const C = {
 	// Termination codes.
@@ -109,7 +154,7 @@ export type NotifierOptions = {
 	 * How long (in seconds) the subscription lasts when the SUBSCRIBE carries
 	 * no Expires header field.
 	 *
-	 * @defaultValue {@link C.DEFAULT_EXPIRES_SEC}
+	 * @defaultValue `900`
 	 */
 	defaultExpires?: number;
 };
@@ -123,6 +168,21 @@ export type NotifierOptions = {
  *   `newSubscribe` event.
  * - Register the listeners first and call {@link Notifier.start} last, since
  *   `start()` reports the SUBSCRIBE that created the notifier.
+ *
+ * @example
+ * ```ts
+ * ua.on('newSubscribe', ({ request }) => {
+ *   const notifier = ua.notify(request, 'application/pidf+xml');
+ *
+ *   notifier.on('subscribe', isUnsubscribe => {
+ *     if (!isUnsubscribe) {
+ *       notifier.notify('<presence/>');
+ *     }
+ *   });
+ *
+ *   notifier.start();
+ * });
+ * ```
  */
 export class Notifier extends EventEmitter<NotifierEventMap> {
 	/**
@@ -133,6 +193,8 @@ export class Notifier extends EventEmitter<NotifierEventMap> {
 	 * - Called by the `UA`. The application must not call it.
 	 * - A SUBSCRIBE that does not pass {@link Notifier.checkSubscribe} is
 	 *   answered 405 and the callback is not invoked.
+	 *
+	 * @internal
 	 */
 	static init_incoming(request: IncomingRequest, callback: () => void): void {
 		try {
@@ -186,7 +248,9 @@ export class Notifier extends EventEmitter<NotifierEventMap> {
 	}

 	/**
-	 * The constants above, reachable without the instance.
+	 * {@link C}, reachable without the instance.
+	 *
+	 * @internal
 	 */
 	static get C(): typeof C {
 		return C;
@@ -216,21 +280,29 @@ export class Notifier extends EventEmitter<NotifierEventMap> {
 	 * @param subscribe - The SUBSCRIBE to accept.
 	 * @param contentType - Value of the Content-Type header field of every
 	 *   NOTIFY that carries a body.
+	 * @param options - What the notifier answers the SUBSCRIBE with.
 	 *
 	 * @throws
 	 * - `TypeError` if `contentType` is not given, or if the SUBSCRIBE does
 	 *   not pass {@link Notifier.checkSubscribe}.
+	 *
+	 * @remarks
+	 * - What `ua.notify()` calls. The application must not call it.
+	 *
+	 * @internal
 	 */
 	constructor(
 		ua: UA,
 		subscribe: IncomingRequest,
 		contentType: string,
-		{ extraHeaders, allowEvents, pending, defaultExpires }: NotifierOptions = {}
+		options: NotifierOptions = {}
 	) {
 		logger.debug('new');

 		super();

+		const { extraHeaders, allowEvents, pending, defaultExpires } = options;
+
 		if (!contentType) {
 			throw new TypeError('Not enough arguments. Missing contentType');
 		}
@@ -269,7 +341,9 @@ export class Notifier extends EventEmitter<NotifierEventMap> {
 	}

 	/**
-	 * The constants above.
+	 * {@link C}.
+	 *
+	 * @internal
 	 */
 	get C(): typeof C {
 		return C;
@@ -314,6 +388,8 @@ export class Notifier extends EventEmitter<NotifierEventMap> {
 	 * - Covers the fetch subscribe of
 	 *   [RFC 6665 Section 4.4.3](https://datatracker.ietf.org/doc/html/rfc6665#section-4.4.3),
 	 *   an initial SUBSCRIBE with `Expires: 0`.
+	 *
+	 * @internal
 	 */
 	receiveRequest(request: IncomingRequest): void {
 		if (request.method !== JsSIP_C.SUBSCRIBE) {
diff --git a/src/Options.ts b/src/Options.ts
index 5f37d1d..d7181fe 100644
--- a/src/Options.ts
+++ b/src/Options.ts
@@ -1,3 +1,9 @@
+/**
+ * Capability querying with SIP OPTIONS requests.
+ *
+ * @module Options
+ */
+
 import type { UA } from './UA';
 import { EventEmitter } from 'events';

@@ -9,8 +15,8 @@ import { RequestSender } from './RequestSender';
 import * as SIPMessage from './SIPMessage';
 import type { IncomingRequest, IncomingResponse } from './SIPMessage';
 import * as Utils from './Utils';
-import NameAddrHeader = require('./NameAddrHeader');
-import URI = require('./URI');
+import { NameAddrHeader } from './NameAddrHeader';
+import { URI } from './URI';

 const logger = new Logger('Options');

@@ -18,7 +24,14 @@ const logger = new Logger('Options');
  * Reported when the OPTIONS got a 2xx response.
  */
 export type OptionsSucceededEvent = {
+	/**
+	 * Always `'remote'`, since only the peer can answer an OPTIONS.
+	 */
 	originator: Originator;
+	/**
+	 * The 2xx response, whose Allow, Accept and Supported header fields
+	 * report what the peer can do.
+	 */
 	response: IncomingResponse;
 };

@@ -26,8 +39,18 @@ export type OptionsSucceededEvent = {
  * Reported when the OPTIONS could not be answered.
  */
 export type OptionsFailedEvent = {
+	/**
+	 * `'remote'` when the peer answered with a negative response, `'system'`
+	 * when the request timed out or the transport failed.
+	 */
 	originator: Originator;
+	/**
+	 * The negative response, and `null` when the originator is `'system'`.
+	 */
 	response: IncomingResponse | null;
+	/**
+	 * Why the OPTIONS was not answered.
+	 */
 	cause: JsSIP_C.causes;
 };

@@ -35,7 +58,13 @@ export type OptionsFailedEvent = {
  * The events an {@link Options} emits.
  */
 export type OptionsEventMap = {
+	/**
+	 * The OPTIONS got a final positive response.
+	 */
 	succeeded: [event: OptionsSucceededEvent];
+	/**
+	 * The OPTIONS got no final positive response.
+	 */
 	failed: [event: OptionsFailedEvent];
 };

@@ -72,7 +101,17 @@ export type SendOptionsOptions = {
  * Options accepted by `accept()`.
  */
 export type AcceptOptions = {
+	/**
+	 * Whole `Name: value` header field lines to add to the response.
+	 */
 	extraHeaders?: string[] | null;
+	/**
+	 * Body of the response.
+	 *
+	 * @remarks
+	 * - Give its Content-Type header field in `extraHeaders`. A body with
+	 *   none is labelled `application/sdp`.
+	 */
 	body?: string;
 };

@@ -80,7 +119,17 @@ export type AcceptOptions = {
  * Options accepted by `reject()`.
  */
 export type RejectOptions = {
+	/**
+	 * Whole `Name: value` header field lines to add to the response.
+	 */
 	extraHeaders?: string[] | null;
+	/**
+	 * Body of the response.
+	 *
+	 * @remarks
+	 * - Give its Content-Type header field in `extraHeaders`. A body with
+	 *   none is labelled `application/sdp`.
+	 */
 	body?: string;
 	/**
 	 * Status code of the response, between 300 and 699.
@@ -99,12 +148,14 @@ export type RejectOptions = {
  *
  * @example
  * ```ts
- * ua.sendOptions('sip:bob@example.com', undefined, {
+ * const options = ua.sendOptions('sip:bob@example.com', undefined, {
  *   eventHandlers: {
  *     succeeded: ({ response }) => console.log(response.getHeader('Allow')),
  *     failed: ({ cause }) => console.log('not answered', cause),
  *   },
  * });
+ *
+ * options.data = { probe: 'keepalive' };
  * ```
  */
 export class Options extends EventEmitter<OptionsEventMap> {
@@ -122,6 +173,15 @@ export class Options extends EventEmitter<OptionsEventMap> {
 	// eslint-disable-next-line @typescript-eslint/no-explicit-any
 	#data: any;

+	/**
+	 * @param ua - The UA that sends or received the OPTIONS.
+	 *
+	 * @remarks
+	 * - What `ua.sendOptions()` calls, and what the UA builds for a received
+	 *   OPTIONS. The application must not call it.
+	 *
+	 * @internal
+	 */
 	constructor(ua: UA) {
 		super();

@@ -183,6 +243,8 @@ export class Options extends EventEmitter<OptionsEventMap> {
 	 *
 	 * @param target - Address of the remote peer.
 	 * @param body - Content of the request, if any.
+	 * @param options - Content type and extra header fields of the OPTIONS,
+	 *   plus the listeners to register before it goes out.
 	 *
 	 * @throws
 	 * - `TypeError` if `target` is not given, or if it cannot be turned into a
@@ -260,6 +322,8 @@ export class Options extends EventEmitter<OptionsEventMap> {
 	 *
 	 * @remarks
 	 * - Called by the `UA`. The application must not call it.
+	 *
+	 * @internal
 	 */
 	init_incoming(request: IncomingRequest): void {
 		this.#request = request;
@@ -278,6 +342,8 @@ export class Options extends EventEmitter<OptionsEventMap> {
 	/**
 	 * Accept the incoming OPTIONS, answering it with a 200.
 	 *
+	 * @param options - Body and extra header fields of the response.
+	 *
 	 * @throws
 	 * - {@link NotSupportedError} if the OPTIONS is outgoing.
 	 * - `Error` if the OPTIONS was already replied.
@@ -303,6 +369,9 @@ export class Options extends EventEmitter<OptionsEventMap> {
 	/**
 	 * Reject the incoming OPTIONS.
 	 *
+	 * @param options - Status code, reason phrase, body and extra header
+	 *   fields of the response.
+	 *
 	 * @throws
 	 * - {@link NotSupportedError} if the OPTIONS is outgoing.
 	 * - `Error` if the OPTIONS was already replied.
diff --git a/src/RTCSession.ts b/src/RTCSession.ts
index fea5bee..1e025f5 100644
--- a/src/RTCSession.ts
+++ b/src/RTCSession.ts
@@ -29,8 +29,8 @@ import * as Timers from './Timers';
 import * as Transactions from './Transactions';
 import type { CallOptions, RTCSessionEvent, UA } from './UA';
 import * as Utils from './Utils';
-import NameAddrHeader = require('./NameAddrHeader');
-import URI = require('./URI');
+import { NameAddrHeader } from './NameAddrHeader';
+import { URI } from './URI';

 const logger = new Logger('RTCSession');

@@ -51,12 +51,13 @@ export enum Status {
 }

 /**
- * The constants a session exposes, both as a static and as an instance
- * member.
+ * The session states.
  *
  * @remarks
  * - {@link Status} holds the same values under shorter names, and is what
- *   the session itself is typed with.
+ *   the session itself is typed with. For internal use.
+ *
+ * @internal
  */
 export const C = {
 	// RTCSession states.
@@ -76,8 +77,7 @@ export const C = {
  * Whether the call was placed or received.
  *
  * @remarks
- * - An alias of {@link Constants.Direction}, kept under the name the library
- *   has always used for a session.
+ * - An alias of {@link Constants.Direction}.
  */
 export type SessionDirection = Direction;

@@ -412,7 +412,9 @@ export type RTCSessionEventHandlers = {

 export class RTCSession extends EventEmitter<RTCSessionEventMap> {
 	/**
-	 * The constants above, reachable without the instance.
+	 * {@link C}, reachable without the instance.
+	 *
+	 * @internal
 	 */
 	static get C(): typeof C {
 		return C;
@@ -570,7 +572,9 @@ export class RTCSession extends EventEmitter<RTCSessionEventMap> {
 	 */

 	/**
-	 * The constants above.
+	 * {@link C}.
+	 *
+	 * @internal
 	 */
 	get C(): typeof C {
 		return C;
diff --git a/src/RTCSession/ReferNotifier.ts b/src/RTCSession/ReferNotifier.ts
index da24da4..2540570 100644
--- a/src/RTCSession/ReferNotifier.ts
+++ b/src/RTCSession/ReferNotifier.ts
@@ -51,9 +51,8 @@ export class ReferNotifier {
 	 *
 	 * @param code - Status code reached by the transfer. From 200 on, the
 	 *   subscription is terminated.
-	 * @param reason - Reason phrase. The one
-	 *   {@link Constants.REASON_PHRASE} gives for the status code when not
-	 *   given.
+	 * @param reason - Reason phrase. The one the IANA registry gives for the
+	 *   status code when not given.
 	 */
 	notify(code: number, reason?: string): void {
 		logger.debug('notify()');
diff --git a/src/RTCSession/ReferSubscriber.ts b/src/RTCSession/ReferSubscriber.ts
index 4f37943..5d00997 100644
--- a/src/RTCSession/ReferSubscriber.ts
+++ b/src/RTCSession/ReferSubscriber.ts
@@ -10,7 +10,7 @@ import type {
 	OutgoingRequest,
 } from '../SIPMessage';
 import * as Utils from '../Utils';
-import URI = require('../URI');
+import { URI } from '../URI';

 const logger = new Logger('RTCSession:ReferSubscriber');

diff --git a/src/Registrator.ts b/src/Registrator.ts
index dbf84f5..f1e816e 100644
--- a/src/Registrator.ts
+++ b/src/Registrator.ts
@@ -1,3 +1,9 @@
+/**
+ * The REGISTER side of the UA.
+ *
+ * @module Registrator
+ */
+
 import type { UA } from './UA';
 import * as JsSIP_C from './Constants';
 import { Logger } from './Logger';
@@ -5,8 +11,8 @@ import { RequestSender } from './RequestSender';
 import * as SIPMessage from './SIPMessage';
 import type { IncomingResponse } from './SIPMessage';
 import * as Utils from './Utils';
-import NameAddrHeader = require('./NameAddrHeader');
-import URI = require('./URI');
+import { NameAddrHeader } from './NameAddrHeader';
+import { URI } from './URI';

 const logger = new Logger('Registrator');

@@ -36,7 +42,16 @@ export type UnregisterOptions = {
  * What the UA reports in its `registered` and `registrationRefreshed` events.
  */
 export type RegisteredEvent = {
+	/**
+	 * The 2xx response that confirmed the binding.
+	 */
 	response: IncomingResponse;
+	/**
+	 * How long (in seconds) the registrar granted the binding for. Taken from
+	 * the `expires` parameter of the Contact header field pointing at this UA,
+	 * from the Expires header field, or from the `register_expires`
+	 * configuration parameter when the response carries neither.
+	 */
 	expires: number;
 };

@@ -44,7 +59,15 @@ export type RegisteredEvent = {
  * What the UA reports in its `registrationFailed` and `unregistered` events.
  */
 export type UnregisteredEvent = {
+	/**
+	 * The response the event reports, and `null` when none arrived, so on a
+	 * request timeout, on a transport error and when the UA is stopped.
+	 */
 	response: IncomingResponse | null;
+	/**
+	 * Why the registration failed or the binding was given up. Not given when
+	 * a positive response to an un-REGISTER removed the binding.
+	 */
 	cause?: JsSIP_C.causes | null;
 };

@@ -72,6 +95,11 @@ export class Registrator {
 	// Forced to 1.
 	readonly #reg_id = 1;

+	/**
+	 * @param ua - The UA the registrator registers.
+	 *
+	 * @internal
+	 */
 	constructor(ua: UA) {
 		this.#ua = ua;

@@ -174,6 +202,11 @@ export class Registrator {

 	/**
 	 * Send a REGISTER request, refreshing the binding before it expires.
+	 *
+	 * @remarks
+	 * - What `ua.register()` calls.
+	 *
+	 * @internal
 	 */
 	register(): void {
 		if (this.#registering) {
@@ -402,6 +435,14 @@ export class Registrator {

 	/**
 	 * Send an un-REGISTER request, removing the binding.
+	 *
+	 * @param options - Whether to remove every binding of the address of
+	 *   record.
+	 *
+	 * @remarks
+	 * - What `ua.unregister()` calls.
+	 *
+	 * @internal
 	 */
 	unregister(options: UnregisterOptions = {}): void {
 		if (!this.#registered) {
@@ -477,6 +518,8 @@ export class Registrator {

 	/**
 	 * Un-register when the UA is stopped.
+	 *
+	 * @internal
 	 */
 	close(): void {
 		if (this.#registered) {
@@ -486,6 +529,8 @@ export class Registrator {

 	/**
 	 * Give the binding up when the transport goes down.
+	 *
+	 * @internal
 	 */
 	onTransportClosed(): void {
 		this.#registering = false;
diff --git a/src/SIPMessage.ts b/src/SIPMessage.ts
index 48a93ff..e2926e0 100644
--- a/src/SIPMessage.ts
+++ b/src/SIPMessage.ts
@@ -1,3 +1,14 @@
+/**
+ * The SIP messages the library sends and receives, and the types they are
+ * built from.
+ *
+ * @remarks
+ * - These are not exported by the package. The application gets them in the
+ *   events that report a message.
+ *
+ * @module SIPMessage
+ */
+
 import type { UA } from './UA';
 import type { EventEmitter } from 'events';

@@ -13,8 +24,8 @@ import {
 	newTag,
 	str_utf8_length,
 } from './Utils';
-import NameAddrHeader = require('./NameAddrHeader');
-import URI = require('./URI');
+import { NameAddrHeader } from './NameAddrHeader';
+import { URI } from './URI';

 // NOTE: `sdp-transform` ships no type declarations and `@types/sdp-transform`
 // is not a dependency of this project, so it is consumed through a `require()`
@@ -70,8 +81,7 @@ export type SDP = {
  * A header value as stored by an `OutgoingRequest`.
  *
  * @remarks
- * - It is not just `string` because `Max-Forwards` is stored as the
- *   {@link Constants.MAX_FORWARDS} number.
+ * - It is not just `string` because `Max-Forwards` is stored as a number.
  */
 export type OutgoingHeaderValue = string | number;

@@ -1106,9 +1116,8 @@ export class IncomingRequest extends IncomingMessage {
 	 * is retransmitted as the transaction requires.
 	 *
 	 * @param code - Status code of the response, between 100 and 699.
-	 * @param reason - Reason phrase. The one
-	 *   {@link Constants.REASON_PHRASE} gives for the status code when not
-	 *   given.
+	 * @param reason - Reason phrase. The one the IANA registry gives for the
+	 *   status code when not given.
 	 * @param extraHeaders - Whole `Name: value` header field lines to add to
 	 *   the response.
 	 * @param body - Body of the response, if any.
@@ -1118,6 +1127,10 @@ export class IncomingRequest extends IncomingMessage {
 	 * @throws
 	 * - `TypeError` if `code` is not between 100 and 699.
 	 *
+	 * @remarks
+	 * - A body with no Content-Type header field among `extraHeaders` is
+	 *   labelled `application/sdp`.
+	 *
 	 * @example
 	 * ```ts
 	 * request.reply(486); // Busy Here
@@ -1238,7 +1251,14 @@ export class IncomingRequest extends IncomingMessage {
 		if (body) {
 			const length = str_utf8_length(body);

-			response += 'Content-Type: application/sdp\r\n';
+			// Only label the body when the caller did not, or the response would
+			// carry two Content-Type header fields.
+			if (
+				!extraHeaders.some(header => /^\s*(content-type|c)\s*:/i.test(header))
+			) {
+				response += 'Content-Type: application/sdp\r\n';
+			}
+
 			response += `Content-Length: ${length}\r\n\r\n`;
 			response += body;
 		} else {
@@ -1258,9 +1278,8 @@ export class IncomingRequest extends IncomingMessage {
 	 * transaction, so the response is sent once and never retransmitted.
 	 *
 	 * @param code - Status code of the response, between 100 and 699.
-	 * @param reason - Reason phrase. The one
-	 *   {@link Constants.REASON_PHRASE} gives for the status code when not
-	 *   given.
+	 * @param reason - Reason phrase. The one the IANA registry gives for the
+	 *   status code when not given.
 	 *
 	 * @throws
 	 * - `TypeError` if `code` is not between 100 and 699.
diff --git a/src/Socket.ts b/src/Socket.ts
index 07705f2..ebcf021 100644
--- a/src/Socket.ts
+++ b/src/Socket.ts
@@ -1,3 +1,9 @@
+/**
+ * The interface an application implements to give the library a transport.
+ *
+ * @module Socket
+ */
+
 import { Logger } from './Logger';
 import { isFunction, isString } from './Utils';
 import * as Grammar from './Grammar';
@@ -127,6 +133,15 @@ export interface WeightedSocket {
 	weight?: number;
 }

+/**
+ * Whether the given value implements {@link Socket}.
+ *
+ * @param socket - The value to check.
+ *
+ * @returns Whether it can be given to the UA as a socket.
+ *
+ * @internal
+ */
 export const isSocket = (socket: unknown): socket is Socket => {
 	// Ignore if an array is given.
 	if (Array.isArray(socket)) {
diff --git a/src/Subscriber.ts b/src/Subscriber.ts
index f45e1c9..db08ea3 100644
--- a/src/Subscriber.ts
+++ b/src/Subscriber.ts
@@ -1,3 +1,9 @@
+/**
+ * The subscriber side of a subscription.
+ *
+ * @module Subscriber
+ */
+
 import type { UA } from './UA';
 import { EventEmitter } from 'events';

@@ -15,7 +21,9 @@ import type {
 	OutgoingRequestParams,
 } from './SIPMessage';
 import * as Utils from './Utils';
-import URI = require('./URI');
+import { URI } from './URI';
+
+export type { DialogId } from './Dialog';

 const logger = new Logger('Subscriber');

@@ -23,14 +31,48 @@ const logger = new Logger('Subscriber');
  * Why the subscription ended, as reported by the `terminated` event.
  */
 export enum TerminationCode {
+	/**
+	 * No response to a SUBSCRIBE arrived before its transaction timed out.
+	 */
 	SUBSCRIBE_RESPONSE_TIMEOUT = 0,
+	/**
+	 * A SUBSCRIBE could not be sent because the transport failed.
+	 */
 	SUBSCRIBE_TRANSPORT_ERROR = 1,
+	/**
+	 * A SUBSCRIBE was answered with a failure response.
+	 */
 	SUBSCRIBE_NON_OK_RESPONSE = 2,
+	/**
+	 * A SUBSCRIBE was accepted with a 2xx carrying no Contact header field,
+	 * which leaves no dialog to run the subscription in.
+	 */
 	SUBSCRIBE_WRONG_OK_RESPONSE = 3,
+	/**
+	 * A SUBSCRIBE was challenged and the configured credentials did not
+	 * answer the challenge.
+	 */
 	SUBSCRIBE_AUTHENTICATION_FAILED = 4,
+	/**
+	 * The final NOTIFY did not arrive within 32 seconds of the un-SUBSCRIBE
+	 * being accepted.
+	 */
 	UNSUBSCRIBE_TIMEOUT = 5,
+	/**
+	 * The notifier ended the subscription, with a NOTIFY whose
+	 * Subscription-State header field reads `terminated`.
+	 */
 	FINAL_NOTIFY_RECEIVED = 6,
+	/**
+	 * A NOTIFY arrived that the subscription cannot take: one with no Event
+	 * or Subscription-State header field, one whose Event does not match the
+	 * SUBSCRIBE, or one whose subscription state is not a known one.
+	 */
 	WRONG_NOTIFY_RECEIVED = 7,
+	/**
+	 * The UA was stopped while the un-SUBSCRIBE waited for its final NOTIFY,
+	 * which a stopped UA would drop.
+	 */
 	UA_STOPPED = 8,
 }

@@ -43,20 +85,38 @@ export enum TerminationCode {
  *   `ACTIVE`.
  */
 export enum State {
+	/**
+	 * The notifier took the subscription but is not reporting the event yet.
+	 */
 	PENDING = 0,
+	/**
+	 * The notifier is reporting the event.
+	 */
 	ACTIVE = 1,
+	/**
+	 * The subscription is over and the subscriber is of no further use.
+	 */
 	TERMINATED = 2,
+	/**
+	 * Built, with nothing sent yet.
+	 */
 	INIT = 3,
+	/**
+	 * The initial SUBSCRIBE went out and the first NOTIFY, the one saying
+	 * whether the subscription is pending or active, has not arrived.
+	 */
 	WAITING_NOTIFY = 4,
 }

 /**
- * The constants the subscriber exposes, both as a static and as an instance
- * member.
+ * The subscriber termination codes and states.
  *
  * @remarks
  * - {@link TerminationCode} and {@link State} hold the same values under
- *   shorter names, and are what the subscriber itself is typed with.
+ *   shorter names, and are what the subscriber itself is typed with. For
+ *   internal use.
+ *
+ * @internal
  */
 export const C = {
 	// Termination codes.
@@ -130,7 +190,7 @@ export type SubscriberOptions = {
 	/**
 	 * How long (in seconds) to ask the subscription to last.
 	 *
-	 * @defaultValue {@link C.DEFAULT_EXPIRES_SEC}
+	 * @defaultValue `900`
 	 */
 	expires?: number;
 	/**
@@ -171,10 +231,24 @@ type QueuedSubscribe = {
  * @remarks
  * - Applications get one from `UA.subscribe()`, and nothing is sent until
  *   {@link Subscriber.subscribe} is called.
+ *
+ * @example
+ * ```ts
+ * const subscriber = ua.subscribe(
+ *   'sip:bob@example.com',
+ *   'presence',
+ *   'application/pidf+xml'
+ * );
+ *
+ * subscriber.on('notify', (isFinal, request, body) => console.log(body));
+ * subscriber.subscribe();
+ * ```
  */
 export class Subscriber extends EventEmitter<SubscriberEventMap> {
 	/**
-	 * The constants above, reachable without the instance.
+	 * {@link C}, reachable without the instance.
+	 *
+	 * @internal
 	 */
 	static get C(): typeof C {
 		return C;
@@ -224,29 +298,32 @@ export class Subscriber extends EventEmitter<SubscriberEventMap> {
 	 * @param eventName - Value of the Event header field, so the event name
 	 *   optionally followed by `;id=xxx`.
 	 * @param accept - Value of the Accept header field.
+	 * @param options - What the subscriber sends the SUBSCRIBE with.
 	 *
 	 * @throws
 	 * - `TypeError` if `target`, `eventName` or `accept` is missing, if
 	 *   `eventName` is not a valid Event header field value, or if `target`
 	 *   is not a valid target.
+	 *
+	 * @remarks
+	 * - What `ua.subscribe()` calls. The application must not call it.
+	 *
+	 * @internal
 	 */
 	constructor(
 		ua: UA,
 		target: string | URI,
 		eventName: string,
 		accept: string,
-		{
-			expires,
-			contentType,
-			allowEvents,
-			params,
-			extraHeaders,
-		}: SubscriberOptions = {}
+		options: SubscriberOptions = {}
 	) {
 		logger.debug('new');

 		super();

+		let { expires } = options;
+		const { contentType, allowEvents, params, extraHeaders } = options;
+
 		// Check that arguments are defined.
 		if (!target) {
 			throw new TypeError('Not enough arguments: Missing target');
@@ -332,7 +409,9 @@ export class Subscriber extends EventEmitter<SubscriberEventMap> {
 	}

 	/**
-	 * The constants above.
+	 * {@link C}.
+	 *
+	 * @internal
 	 */
 	get C(): typeof C {
 		return C;
@@ -394,6 +473,8 @@ export class Subscriber extends EventEmitter<SubscriberEventMap> {
 	 * - [RFC 6665 Section 4.1.2.4](https://datatracker.ietf.org/doc/html/rfc6665#section-4.1.2.4):
 	 *   the first NOTIFY may arrive before the 2xx response to the initial
 	 *   SUBSCRIBE, in which case it is the one creating the dialog.
+	 *
+	 * @internal
 	 */
 	matchEarlyNotify(
 		call_id: string | undefined,
@@ -413,6 +494,8 @@ export class Subscriber extends EventEmitter<SubscriberEventMap> {
 	 *
 	 * @remarks
 	 * - Called by the `UA`. The application must not call it.
+	 *
+	 * @internal
 	 */
 	receiveEarlyNotify(request: IncomingRequest): void {
 		let dialog;
@@ -444,6 +527,8 @@ export class Subscriber extends EventEmitter<SubscriberEventMap> {
 	 * @remarks
 	 * - Called by the `Dialog`. The application must not call it.
 	 * - Anything other than a NOTIFY is answered 405.
+	 *
+	 * @internal
 	 */
 	receiveRequest(request: IncomingRequest): void {
 		if (request.method !== JsSIP_C.NOTIFY) {
@@ -601,7 +686,7 @@ export class Subscriber extends EventEmitter<SubscriberEventMap> {
 	 *
 	 * @remarks
 	 * - The subscriber stays alive until the final NOTIFY arrives, or for
-	 *   {@link C.FINAL_NOTIFY_TIMEOUT_SEC} seconds if it never does.
+	 *   32 seconds if it never does.
 	 * - Calling it again while that is pending does nothing.
 	 */
 	terminate(body: string | null = null): void {
diff --git a/src/UA.ts b/src/UA.ts
index 91bc410..33172e9 100644
--- a/src/UA.ts
+++ b/src/UA.ts
@@ -41,7 +41,7 @@ import type {
 	TransportDisconnectedEvent,
 } from './Transport';
 import * as Utils from './Utils';
-import URI = require('./URI');
+import { URI } from './URI';

 const logger = new Logger('UA');

@@ -56,9 +56,21 @@ const CLOSE_TIMEOUT = 2000;
  * What the UA is doing, which {@link UA.status} reports.
  */
 export enum Status {
+	/**
+	 * Configured and not started, or stopped and started again.
+	 */
 	INIT = 0,
+	/**
+	 * The transport is connected.
+	 */
 	READY = 1,
+	/**
+	 * `stop()` was called. Incoming requests are dropped from here on.
+	 */
 	USER_CLOSED = 2,
+	/**
+	 * The configuration was refused, or the transport is down.
+	 */
 	NOT_READY = 3,
 }

@@ -66,16 +78,25 @@ export enum Status {
  * Why a UA that is not ready got there.
  */
 export enum ErrorCode {
+	/**
+	 * A configuration parameter was missing or invalid, so the UA was never
+	 * built.
+	 */
 	CONFIGURATION_ERROR = 1,
+	/**
+	 * The transport is down.
+	 */
 	NETWORK_ERROR = 2,
 }

 /**
- * The constants the UA exposes, both as a static and as an instance member.
+ * The UA statuses and error codes.
  *
  * @remarks
  * - {@link Status} and {@link ErrorCode} hold the same values under shorter
- *   names, and are what the UA itself is typed with.
+ *   names, and are what the UA itself is typed with. For internal use.
+ *
+ * @internal
  */
 export const C = {
 	// UA status codes.
@@ -92,36 +113,202 @@ export const C = {
 /**
  * What an application configures a UA with.
  *
- * @remarks
- * - Every parameter is described on {@link Configuration}, which is the
- *   validated form of this one. `uri`, `contact_uri` and `registrar_server`
- *   are written as strings here and parsed into a `URI`.
+ * Only {@link UAConfiguration.uri} and {@link UAConfiguration.sockets} are
+ * mandatory. Every other parameter falls back to the default documented on
+ * it.
+ *
+ * @example
+ * ```ts
+ * const ua = new JsSIP.UA({
+ *   uri: 'sip:alice@example.com',
+ *   sockets: new JsSIP.WebSocketInterface('wss://sip.example.com'),
+ *   password: 'secret',
+ * });
+ * ```
  */
 export type UAConfiguration = {
 	// Mandatory parameters.
+	/**
+	 * Transports the UA connects through. The only mandatory parameter
+	 * together with {@link UAConfiguration.uri}.
+	 *
+	 * @remarks
+	 * - A single {@link Socket}, an array of them, or an array of
+	 *   {@link WeightedSocket} to give each one a preference.
+	 */
 	sockets: Socket | Socket[] | WeightedSocket[];
+	/**
+	 * Address of record of the UA, so its SIP address. The only mandatory
+	 * parameter together with {@link UAConfiguration.sockets}.
+	 */
 	uri: string;
 	// Optional parameters.
+	/**
+	 * Token used as authentication credential. Every outgoing request carries
+	 * an Authorization header field with the Bearer scheme and this value.
+	 *
+	 * @defaultValue `null`
+	 */
 	authorization_jwt?: string;
+	/**
+	 * Username used to authenticate, when it differs from the user part of
+	 * {@link UAConfiguration.uri}.
+	 *
+	 * @defaultValue `null`
+	 */
 	authorization_user?: string;
+	/**
+	 * Maximum interval (in seconds) between transport reconnection attempts.
+	 *
+	 * @defaultValue `30`
+	 */
 	connection_recovery_max_interval?: number;
+	/**
+	 * Minimum interval (in seconds) between transport reconnection attempts.
+	 *
+	 * @defaultValue `2`
+	 */
 	connection_recovery_min_interval?: number;
+	/**
+	 * URI to be used in the Contact header field.
+	 *
+	 * @defaultValue `null`
+	 *
+	 * @remarks
+	 * - Its host is the one the UA announces in the `sent-by` of the Via
+	 *   header field. When it is not given, both are built out of a random
+	 *   `.invalid` host name.
+	 */
 	contact_uri?: string;
+	/**
+	 * Descriptive name shown to the called party when calling or sending
+	 * messages.
+	 *
+	 * @defaultValue `null`
+	 *
+	 * @remarks
+	 * - It must NOT be enclosed between double quotes, even when it contains
+	 *   multi-byte symbols. The library always encloses it.
+	 */
 	display_name?: string;
+	/**
+	 * UUID identifying this UA instance when using GRUU, announced in the
+	 * `+sip.instance` Contact parameter.
+	 *
+	 * @defaultValue `null`
+	 *
+	 * @remarks
+	 * - Accepted with or without the `uuid:` prefix.
+	 * - A random UUID is used when it is not given.
+	 */
 	instance_id?: string;
+	/**
+	 * Time (in seconds) after which an incoming call is rejected if not
+	 * answered.
+	 *
+	 * @defaultValue `60`
+	 */
 	no_answer_timeout?: number;
+	/**
+	 * Whether to run the session timers of
+	 * [RFC 4028](https://datatracker.ietf.org/doc/html/rfc4028), which keep a
+	 * session alive by refreshing it.
+	 *
+	 * @defaultValue `true`
+	 */
 	session_timers?: boolean;
+	/**
+	 * Request method used to refresh a session, either `UPDATE` or `INVITE`.
+	 *
+	 * @defaultValue `'UPDATE'`
+	 */
 	session_timers_refresh_method?: string;
+	/**
+	 * Whether to force being the refresher of the session timers of outgoing
+	 * calls, which adds the `refresher=uac` parameter to the Session-Expires
+	 * header field of the initial INVITE.
+	 *
+	 * @defaultValue `false`
+	 */
 	session_timers_force_refresher?: boolean;
+	/**
+	 * The plain SIP authentication password.
+	 *
+	 * @defaultValue `null`
+	 *
+	 * @remarks
+	 * - It is deleted from memory after the first successful authentication,
+	 *   the resulting {@link UAConfiguration.ha1} and
+	 *   {@link UAConfiguration.realm} being stored instead.
+	 */
 	password?: string;
+	/**
+	 * SIP authentication realm.
+	 *
+	 * @defaultValue `null`
+	 *
+	 * @remarks
+	 * - Only useful when the plain {@link UAConfiguration.password} is not
+	 *   given, in which case {@link UAConfiguration.ha1} is required too.
+	 */
 	realm?: string;
+	/**
+	 * `HA1` hash of the credentials, for Digest authentication.
+	 *
+	 * @defaultValue `null`
+	 *
+	 * @remarks
+	 * - When given, and the plain {@link UAConfiguration.password} is not,
+	 *   {@link UAConfiguration.realm} is required too. Authentication is not
+	 *   feasible otherwise.
+	 */
 	ha1?: string;
+	/**
+	 * Whether to register as soon as the UA starts.
+	 *
+	 * @defaultValue `true`
+	 */
 	register?: boolean;
+	/**
+	 * How long (in seconds) a registration lasts before the UA refreshes it.
+	 *
+	 * @defaultValue `600`
+	 */
 	register_expires?: number;
+	/**
+	 * Trail added to the tag of the From header field of each REGISTER
+	 * request, either a static string or a function returning one.
+	 *
+	 * @defaultValue `''`
+	 */
 	register_from_tag_trail?: string | (() => string);
+	/**
+	 * URI of the registrar, which must be a SIP URI without username.
+	 *
+	 * @defaultValue `null`
+	 *
+	 * @remarks
+	 * - When not given it is taken from {@link UAConfiguration.uri} by
+	 *   removing its username.
+	 */
 	registrar_server?: string;
+	/**
+	 * Whether every initial request carries a Route header field with the SIP
+	 * URI of the server. Some SIP outbound proxies require it.
+	 *
+	 * @defaultValue `false`
+	 */
 	use_preloaded_route?: boolean;
+	/**
+	 * Value of the User-Agent header field present in SIP messages. By
+	 * default `JsSIP` followed by the library version.
+	 */
 	user_agent?: string;
+	/**
+	 * Custom SIP header fields added to every request and response.
+	 *
+	 * @defaultValue `null`
+	 */
 	extra_headers?: string[];
 };

@@ -131,7 +318,9 @@ export type UAConfiguration = {
  *
  * @remarks
  * - The parameters a UA computes for itself are set, and `sockets` is gone:
- *   it is consumed by the {@link Transport} and removed.
+ *   it is consumed by the `Transport` and removed.
+ *
+ * @internal
  */
 export type LoadedConfiguration = Omit<
 	Configuration,
@@ -237,8 +426,17 @@ export type CallOptions = AnswerOptions & {
  * Reported when a call comes in.
  */
 export type IncomingRTCSessionEvent = {
+	/**
+	 * Always `'remote'`, since the remote peer placed the call.
+	 */
 	originator: 'remote';
+	/**
+	 * The session, which has been neither answered nor rejected yet.
+	 */
 	session: RTCSession;
+	/**
+	 * The INVITE that created it.
+	 */
 	request: IncomingRequest;
 };

@@ -246,11 +444,23 @@ export type IncomingRTCSessionEvent = {
  * Reported when a call goes out.
  */
 export type OutgoingRTCSessionEvent = {
+	/**
+	 * Always `'local'`, since the local user placed the call.
+	 */
 	originator: 'local';
+	/**
+	 * The session, reported before its INVITE goes out.
+	 */
 	session: RTCSession;
+	/**
+	 * The INVITE about to be sent.
+	 */
 	request: OutgoingRequest;
 };

+/**
+ * Reported for a call in either direction, which `originator` tells apart.
+ */
 export type RTCSessionEvent = IncomingRTCSessionEvent | OutgoingRTCSessionEvent;

 /**
@@ -279,8 +489,18 @@ export type UnRegisteredEvent = UnregisteredEvent;
  * Reported when a MESSAGE comes in.
  */
 export type IncomingMessageEvent = {
+	/**
+	 * Always `'remote'`, since the remote peer sent the MESSAGE.
+	 */
 	originator: 'remote';
+	/**
+	 * The message, which a listener may `accept()` or `reject()`. It is
+	 * answered 200 once every listener has run without replying.
+	 */
 	message: Message;
+	/**
+	 * The MESSAGE received.
+	 */
 	request: IncomingRequest;
 };

@@ -288,8 +508,17 @@ export type IncomingMessageEvent = {
  * Reported when a MESSAGE goes out.
  */
 export type OutgoingMessageEvent = {
+	/**
+	 * Always `'local'`, since the local user sent the MESSAGE.
+	 */
 	originator: 'local';
+	/**
+	 * The message, reported before its MESSAGE goes out.
+	 */
 	message: Message;
+	/**
+	 * The MESSAGE about to be sent.
+	 */
 	request: OutgoingRequest;
 };

@@ -297,8 +526,18 @@ export type OutgoingMessageEvent = {
  * Reported when an OPTIONS comes in.
  */
 export type IncomingOptionsEvent = {
+	/**
+	 * Always `'remote'`, since the remote peer sent the OPTIONS.
+	 */
 	originator: 'remote';
+	/**
+	 * The query, which a listener may `accept()` or `reject()`. It is
+	 * answered 200 once every listener has run without replying.
+	 */
 	message: Options;
+	/**
+	 * The OPTIONS received.
+	 */
 	request: IncomingRequest;
 };

@@ -306,8 +545,17 @@ export type IncomingOptionsEvent = {
  * Reported when an OPTIONS goes out.
  */
 export type OutgoingOptionsEvent = {
+	/**
+	 * Always `'local'`, since the local user sent the OPTIONS.
+	 */
 	originator: 'local';
+	/**
+	 * The query, reported before its OPTIONS goes out.
+	 */
 	message: Options;
+	/**
+	 * The OPTIONS about to be sent.
+	 */
 	request: OutgoingRequest;
 };

@@ -317,9 +565,13 @@ export type OutgoingOptionsEvent = {
  */
 export type SipEventEvent = {
 	/**
-	 * Parsed Event header field of the request.
+	 * Parsed Event header field of the request, so its `event` name and the
+	 * `params` that follow it.
 	 */
 	event: unknown;
+	/**
+	 * The request received.
+	 */
 	request: IncomingRequest;
 };

@@ -327,20 +579,77 @@ export type SipEventEvent = {
  * The events a {@link UA} emits.
  */
 export type UAEventMap = {
+	/**
+	 * A socket is being connected, once per attempt.
+	 */
 	connecting: [event: ConnectingEvent];
+	/**
+	 * The transport is connected.
+	 */
 	connected: [event: ConnectedEvent];
+	/**
+	 * The transport is gone, whether an attempt failed or an established
+	 * connection dropped. The UA keeps trying to recover it on its own.
+	 */
 	disconnected: [event: DisconnectEvent];
+	/**
+	 * The UA is registered.
+	 */
 	registered: [event: RegisteredEvent];
+	/**
+	 * An existing registration was refreshed before it ran out.
+	 */
 	registrationRefreshed: [event: RegisteredEvent];
+	/**
+	 * The binding is gone, either because `unregister()` removed it or
+	 * because refreshing it failed.
+	 */
 	unregistered: [event: UnRegisteredEvent];
+	/**
+	 * The UA could not register.
+	 */
 	registrationFailed: [event: UnRegisteredEvent];
+	/**
+	 * The registration is about to run out.
+	 *
+	 * @remarks
+	 * - A listener takes the refresh over: it has to call `register()`
+	 *   itself, or the registration expires. Useful to fetch a token before
+	 *   registering again. The UA refreshes on its own when nothing is
+	 *   listening.
+	 */
 	registrationExpiring: [];
+	/**
+	 * A call was placed or received, which `originator` tells apart.
+	 */
 	newRTCSession: [event: RTCSessionEvent];
+	/**
+	 * A MESSAGE was sent or received, which `originator` tells apart.
+	 */
 	newMessage: [event: IncomingMessageEvent | OutgoingMessageEvent];
+	/**
+	 * An OPTIONS was sent or received, which `originator` tells apart.
+	 */
 	newOptions: [event: IncomingOptionsEvent | OutgoingOptionsEvent];
+	/**
+	 * An out of dialog NOTIFY arrived that no subscriber is waiting for.
+	 */
 	sipEvent: [event: SipEventEvent];
+	/**
+	 * A SUBSCRIBE arrived that belongs to no notifier.
+	 *
+	 * @remarks
+	 * - A listener accepts it by calling `notify()` with the request, and
+	 *   declines it by doing nothing, which answers 405.
+	 */
 	newSubscribe: [event: SipEventEvent];
+	/**
+	 * @internal
+	 */
 	newTransaction: [event: { transaction: Transactions.Transaction }];
+	/**
+	 * @internal
+	 */
 	transactionDestroyed: [event: { transaction: Transactions.Transaction }];
 };

@@ -367,7 +676,9 @@ export type UAEventMap = {
  */
 export class UA extends EventEmitter<UAEventMap> {
 	/**
-	 * The constants above, reachable without the instance.
+	 * {@link C}, reachable without the instance.
+	 *
+	 * @internal
 	 */
 	static get C(): typeof C {
 		return C;
@@ -442,7 +753,9 @@ export class UA extends EventEmitter<UAEventMap> {
 	}

 	/**
-	 * The constants above.
+	 * {@link C}.
+	 *
+	 * @internal
 	 */
 	get C(): typeof C {
 		return C;
@@ -464,6 +777,8 @@ export class UA extends EventEmitter<UAEventMap> {

 	/**
 	 * The configuration, as the UA validated and completed it.
+	 *
+	 * @internal
 	 */
 	get configuration(): LoadedConfiguration {
 		return this.#configuration as LoadedConfiguration;
@@ -471,6 +786,8 @@ export class UA extends EventEmitter<UAEventMap> {

 	/**
 	 * The transport the UA sends and receives through.
+	 *
+	 * @internal
 	 */
 	get transport(): Transport {
 		return this.#transport;
@@ -608,6 +925,14 @@ export class UA extends EventEmitter<UAEventMap> {
 	 * Subscribe to an event the peer reports. Nothing is sent until
 	 * `subscribe()` is called on the result.
 	 *
+	 * @param target - Who to subscribe to.
+	 * @param eventName - Value of the Event header field, so the event name
+	 *   optionally followed by `;id=xxx`.
+	 * @param accept - Value of the Accept header field.
+	 * @param options - What the subscriber sends the SUBSCRIBE with.
+	 *
+	 * @returns The subscriber, with no listener registered yet.
+	 *
 	 * @throws
 	 * - `TypeError` if an argument is missing or the target is not a valid
 	 *   one.
@@ -627,9 +952,17 @@ export class UA extends EventEmitter<UAEventMap> {
 	 * Accept a subscription the peer asked for. Nothing is sent until
 	 * `start()` is called on the result.
 	 *
+	 * @param subscribe - The SUBSCRIBE to accept, as the `newSubscribe` event
+	 *   reported it.
+	 * @param contentType - Value of the Content-Type header field of every
+	 *   NOTIFY that carries a body.
+	 * @param options - What the notifier answers the SUBSCRIBE with.
+	 *
+	 * @returns The notifier, with no listener registered yet.
+	 *
 	 * @throws
-	 * - `TypeError` if the content type is missing or the SUBSCRIBE is not
-	 *   one a notifier can be built on.
+	 * - `TypeError` if the content type is missing, or if the SUBSCRIBE does
+	 *   not pass {@link Notifier.checkSubscribe}.
 	 */
 	notify(
 		subscribe: IncomingRequest,
@@ -735,6 +1068,11 @@ export class UA extends EventEmitter<UAEventMap> {
 	/**
 	 * Turn a string into the SIP URI a request can be sent to, filling in the
 	 * host of the UA when the string carries none.
+	 *
+	 * @remarks
+	 * - What every class that takes a target calls on the UA.
+	 *
+	 * @internal
 	 */
 	normalizeTarget(target: string | URI): URI | undefined {
 		return Utils.normalizeTarget(target, this.configuration.hostport_params);
diff --git a/src/URI.ts b/src/URI.ts
index b9ae1db..28894c4 100644
--- a/src/URI.ts
+++ b/src/URI.ts
@@ -1,7 +1,31 @@
+/**
+ * The SIP URI, and the types its parameters and headers are held in.
+ *
+ * @module URI
+ */
+
 import { SIP } from './Constants';
 import { escapeUser, headerize } from './Utils';
 import * as Grammar from './Grammar';

+/**
+ * Scheme of a SIP URI. `sip` and `sips` are the ones SIP defines, but the
+ * grammar accepts any other.
+ */
+export type URIScheme = 'sip' | string;
+
+/**
+ * URI parameters, indexed by their lowercased name. A parameter with no
+ * value, such as the `lr` of a loose route, is held as `null`.
+ */
+export type Parameters = Record<string, string | null>;
+
+/**
+ * URI headers, indexed by their capitalized name. A header may appear
+ * several times, hence the array.
+ */
+export type Headers = Record<string, string[]>;
+
 /**
  * Represents a SIP URI and provides a set of attributes and methods to
  * retrieve and set the different parts of a URI.
@@ -20,7 +44,7 @@ import * as Grammar from './Grammar';
  * uri.toAor(); // 'sip:alice@example.com'
  * ```
  */
-class URI {
+export class URI {
 	/**
 	 * Parse the given string into a {@link URI}.
 	 *
@@ -45,8 +69,8 @@ class URI {
 	#user?: string;
 	#host: string;
 	#port?: number | null;
-	#parameters: URI.Parameters;
-	#headers: URI.Headers;
+	#parameters: Parameters;
+	#headers: Headers;

 	/**
 	 * @param scheme - URI scheme, `sip` when not given.
@@ -60,12 +84,12 @@ class URI {
 	 * - `TypeError` if `host` is not given.
 	 */
 	constructor(
-		scheme: URI.URIScheme | undefined,
+		scheme: URIScheme | undefined,
 		user: string | undefined,
 		host: string,
 		port?: number | null,
-		parameters: URI.Parameters = {},
-		headers: URI.Headers = {}
+		parameters: Parameters = {},
+		headers: Headers = {}
 	) {
 		// Checks.
 		if (!host) {
@@ -313,8 +337,8 @@ class URI {
 			this.#user,
 			this.#host,
 			this.#port,
-			JSON.parse(JSON.stringify(this.#parameters)) as URI.Parameters,
-			JSON.parse(JSON.stringify(this.#headers)) as URI.Headers
+			JSON.parse(JSON.stringify(this.#parameters)) as Parameters,
+			JSON.parse(JSON.stringify(this.#headers)) as Headers
 		);
 	}

@@ -392,28 +416,3 @@ class URI {
 		return aor;
 	}
 }
-
-// NOTE: `URI` is exported with `export =` because the pegjs generated
-// `Grammar.js` does `var URI = require('./URI')` and then `new URI(...)`.
-// The types below are merged into the `URI` namespace so that they remain
-// reachable.
-// eslint-disable-next-line @typescript-eslint/no-namespace
-declare namespace URI {
-	/**
-	 * Scheme of a SIP URI. `sip` and `sips` are the ones SIP defines, but the
-	 * grammar accepts any other.
-	 */
-	type URIScheme = 'sip' | string;
-	/**
-	 * URI parameters, indexed by their lowercased name. A parameter with no
-	 * value, such as the `lr` of a loose route, is held as `null`.
-	 */
-	type Parameters = Record<string, string | null>;
-	/**
-	 * URI headers, indexed by their capitalized name. A header may appear
-	 * several times, hence the array.
-	 */
-	type Headers = Record<string, string[]>;
-}
-
-export = URI;
diff --git a/src/Utils.ts b/src/Utils.ts
index cce5451..1fa88ec 100644
--- a/src/Utils.ts
+++ b/src/Utils.ts
@@ -1,9 +1,6 @@
 import { SIP, SIP_ERROR_CAUSES, causes } from './Constants';
 import * as Grammar from './Grammar';
-// `URI` is exported with `export =` (CommonJS style) because the pegjs generated
-// `Grammar.js` does `var URI = require('./URI'); new URI(...)`.
-
-import URI = require('./URI');
+import { URI } from './URI';

 export const str_utf8_length = (string: string): number =>
 	unescape(encodeURIComponent(string)).length;
diff --git a/src/WebSocketInterface.ts b/src/WebSocketInterface.ts
index 9758578..16486b7 100644
--- a/src/WebSocketInterface.ts
+++ b/src/WebSocketInterface.ts
@@ -1,3 +1,9 @@
+/**
+ * The {@link Socket} implementation the library ships with.
+ *
+ * @module WebSocketInterface
+ */
+
 import { Logger } from './Logger';
 import * as Grammar from './Grammar';
 import type { Socket } from './Socket';
@@ -91,7 +97,10 @@ export class WebSocketInterface implements Socket {
 	 * The transport announced in the Via header field of outgoing requests,
 	 * derived from the scheme of the given URI. Always uppercase.
 	 *
-	 * @example `WSS`
+	 * @example
+	 * ```ts
+	 * socket.via_transport; // 'WSS'
+	 * ```
 	 */
 	get via_transport(): string {
 		return this.#via_transport;
@@ -105,7 +114,10 @@ export class WebSocketInterface implements Socket {
 	 * The SIP URI of the server, derived from the host and port of the given
 	 * WebSocket URI.
 	 *
-	 * @example `sip:sip.example.com:8443;transport=ws`
+	 * @example
+	 * ```ts
+	 * socket.sip_uri; // 'sip:sip.example.com:8443;transport=ws'
+	 * ```
 	 */
 	get sip_uri(): string {
 		return this.#sip_uri;
diff --git a/src/public.ts b/src/public.ts
deleted file mode 100644
index c72bb7e..0000000
--- a/src/public.ts
+++ /dev/null
@@ -1,52 +0,0 @@
-/**
- * The JavaScript SIP library.
- *
- * ```ts
- * import * as JsSIP from 'jssip';
- * ```
- *
- * @remarks
- * - This is the API reference generated from the sources. It currently covers
- *   the modules already ported to TypeScript. The rest are added here as the
- *   port advances.
- *
- * @packageDocumentation
- */
-
-import NameAddrHeader = require('./NameAddrHeader');
-import URI = require('./URI');
-
-export { URI, NameAddrHeader };
-
-/**
- * The SIP messages the library sends and receives, and the types they are
- * built from.
- *
- * @remarks
- * - These are not exported by the package. The application gets them in the
- *   events that report a message.
- */
-export * as SIPMessage from './SIPMessage';
-
-export { type Socket, type WeightedSocket } from './Socket';
-
-export { WebSocketInterface } from './WebSocketInterface';
-
-export { type Configuration } from './Configuration';
-
-/**
- * SIP constants, response reason phrases and the causes reported in the
- * `failed` and `ended` events.
- *
- * @remarks
- * - Reachable as `JsSIP.C` at runtime.
- */
-export * as Constants from './Constants';
-
-/**
- * The errors the library throws.
- *
- * @remarks
- * - Reachable as `JsSIP.Exceptions` at runtime.
- */
-export * as Exceptions from './Exceptions';
diff --git a/src/test/RTCSession/test-ReferSubscriber.ts b/src/test/RTCSession/test-ReferSubscriber.ts
index c45ad3d..388df99 100644
--- a/src/test/RTCSession/test-ReferSubscriber.ts
+++ b/src/test/RTCSession/test-ReferSubscriber.ts
@@ -13,7 +13,7 @@ import type {
 	IncomingResponse,
 	OutgoingRequest,
 } from '../../SIPMessage';
-import URI = require('../../URI');
+import { URI } from '../../URI';

 const TARGET = 'sip:bob@example.com';
 const CALL_ID = 'a84b4c76e66710';
diff --git a/src/test/test-Message.ts b/src/test/test-Message.ts
index b620cd5..370fbae 100644
--- a/src/test/test-Message.ts
+++ b/src/test/test-Message.ts
@@ -6,6 +6,7 @@ import {
 	buildRequest,
 	buildResponse,
 	header,
+	headers,
 } from './include/sipMessage';
 import TestSocket from './include/TestSocket';
 import { startUA, stopUA } from './include/ua';
@@ -130,7 +131,12 @@ class PlainSocket extends TestSocket {}
  */
 async function receiveMessage(
 	onNewMessage?: (message: Message) => void
-): Promise<{ status: number | undefined; seen?: string; error?: unknown }> {
+): Promise<{
+	status: number | undefined;
+	response?: string;
+	seen?: string;
+	error?: unknown;
+}> {
 	const callId = 'the-call-id';
 	const socket = new PlainSocket();
 	const ua = new UA({ sockets: socket, uri: AOR, register: false });
@@ -168,7 +174,12 @@ async function receiveMessage(
 	await delay(50);
 	await stopUA(ua);

-	return { status: socket.statusFor(callId), seen, error };
+	return {
+		status: socket.statusFor(callId),
+		response: socket.responses('MESSAGE')[0],
+		seen,
+		error,
+	};
 }

 describe('incoming MESSAGE', () => {
@@ -198,6 +209,42 @@ describe('incoming MESSAGE', () => {
 		expect(received.status).toBe(200);
 	});

+	test('accept() labels a body it is given no content type for', async () => {
+		const received = await receiveMessage(message =>
+			message.accept({ body: 'v=0' })
+		);
+
+		expect(headers(received.response!, 'Content-Type')).toEqual([
+			'application/sdp',
+		]);
+		expect(body(received.response!)).toBe('v=0');
+	});
+
+	test('accept() keeps the content type it is given, just the one', async () => {
+		const received = await receiveMessage(message =>
+			message.accept({
+				body: 'Got it',
+				extraHeaders: ['Content-Type: text/plain'],
+			})
+		);
+
+		expect(headers(received.response!, 'Content-Type')).toEqual(['text/plain']);
+		expect(body(received.response!)).toBe('Got it');
+	});
+
+	test('reject() keeps the content type it is given, just the one', async () => {
+		const received = await receiveMessage(message =>
+			message.reject({
+				status_code: 488,
+				body: 'No way',
+				extraHeaders: ['Content-Type: text/plain'],
+			})
+		);
+
+		expect(received.status).toBe(488);
+		expect(headers(received.response!, 'Content-Type')).toEqual(['text/plain']);
+	});
+
 	test('replying twice is refused', async () => {
 		const received = await receiveMessage(message => {
 			message.accept();
diff --git a/typedoc.config.mjs b/typedoc.config.mjs
index 8f8dd85..1eb7f1b 100644
--- a/typedoc.config.mjs
+++ b/typedoc.config.mjs
@@ -1,14 +1,19 @@
 /**
  * Configuration for Typedoc.
  *
- * NOTE: The entry point is the source `src/public.ts` rather than the built
+ * NOTE: The entry points are the sources rather than the built
  * `lib/JsSIP.d.ts`, so that the documentation is the one written inline in the
  * sources and it can be generated without building first.
  *
+ * NOTE: There is one entry point per module, so that each one gets its own
+ * page and names only have to be unique within a module. A single entry point
+ * re-exporting everything would instead make the several `C`, `Status`,
+ * `State`, `TerminationCode`, `AcceptOptions` and `RejectOptions` ambiguous.
+ * The name of the page comes from the `@module` tag at the top of the file.
+ *
  * NOTE: `validation.notDocumented` plus `treatWarningsAsErrors` make
- * `npm run docs:check` fail when anything reachable from `src/public.ts` is
- * undocumented. Modules are added to `src/public.ts` as they are ported to
- * TypeScript and documented.
+ * `npm run docs:check` fail when anything an entry point exports is
+ * undocumented. Modules are added to `entryPoints` as they are documented.
  *
  * NOTE: `intentionallyNotExported` silences `validation.notExported` for the
  * types that public members refer to but that are not part of the public API.
@@ -16,15 +21,27 @@
  * modules that are not documented yet. Each entry goes away as the port
  * advances.
  *
- * NOTE: `projectDocuments` is not set on purpose. With a single entry point it
- * makes Typedoc keep a module wrapper, so every page ends up under the name of
- * the entry file ('public.Socket.html' rather than 'Socket.html'). The README
- * is already the landing page through `readme`.
+ * NOTE: `projectDocuments` is not set on purpose. The README is already the
+ * landing page through `readme`.
  */

 /** @type {Partial<import('typedoc').TypeDocOptions>} */
 const config = {
-	entryPoints: ['src/public.ts'],
+	entryPoints: [
+		'src/Constants.ts',
+		'src/Exceptions.ts',
+		'src/Message.ts',
+		'src/NameAddrHeader.ts',
+		'src/Notifier.ts',
+		'src/Options.ts',
+		'src/Registrator.ts',
+		'src/SIPMessage.ts',
+		'src/Socket.ts',
+		'src/Subscriber.ts',
+		'src/UA.ts',
+		'src/URI.ts',
+		'src/WebSocketInterface.ts',
+	],
 	out: 'docs',
 	skipErrorChecking: false,
 	exclude: ['src/**/*.d.ts', 'src/test/**/*.ts'],
@@ -45,8 +62,15 @@ const config = {
 	readme: 'README.md',
 	intentionallyNotExported: [
 		// Ported but not documented yet.
+		'AnswerOptions',
+		'RTCSession',
+		'RTCSessionEventMap',
+		'TerminateOptions',
+		// Not part of the public API.
 		'Transport',
-		'UA',
+		'TransportConnectingEvent',
+		'TransportConnectedEvent',
+		'TransportDisconnectedEvent',
 		// Declared in the hand written `Grammar.d.ts`, which is excluded above.
 		'Grammar',
 		'ViaHeader',