# ConnectSupervisedPublisherOptions

URL: https://www.caprid.com/docs/reference/typescript/caprid/relay/index/interfaces/connectsupervisedpublisheroptions/

Defined in: [relay-sdks/ts/src/supervised-publisher.ts:39](https://github.com/caprids/relay-sdks/blob/main/ts/src/supervised-publisher.ts#L39)

Options for `connectSupervisedPublisher`: the shared connection options, the root namespace and the policy.

## Extends

- [`ConnectRelayOptions`](https://www.caprid.com/docs/reference/typescript/caprid/relay/index/interfaces/connectrelayoptions/)

## Properties

### connectTimeoutMs?

```ts
connectTimeoutMs?: number;
```

Defined in: [relay-sdks/ts/src/connect-session.ts:87](https://github.com/caprids/relay-sdks/blob/main/ts/src/connect-session.ts#L87)

Deadline for token resolution, transport connection, and protocol SETUP. Default 10 seconds, maximum 2147483647.

#### Inherited from

[`ConnectRelayOptions`](https://www.caprid.com/docs/reference/typescript/caprid/relay/index/interfaces/connectrelayoptions/).[`connectTimeoutMs`](https://www.caprid.com/docs/reference/typescript/caprid/relay/index/interfaces/connectrelayoptions/#connecttimeoutms)

***

### createTransport?

```ts
createTransport?: RelayTransportFactory;
```

Defined in: [relay-sdks/ts/src/connect-session.ts:93](https://github.com/caprids/relay-sdks/blob/main/ts/src/connect-session.ts#L93)

Create the transport. Defaults to the browser's WebTransport; a runtime without it, or whose
WebTransport cannot negotiate protocols, fails with `TRANSPORT_UNAVAILABLE` unless this is
supplied.

#### Inherited from

[`ConnectRelayOptions`](https://www.caprid.com/docs/reference/typescript/caprid/relay/index/interfaces/connectrelayoptions/).[`createTransport`](https://www.caprid.com/docs/reference/typescript/caprid/relay/index/interfaces/connectrelayoptions/#createtransport)

***

### getToken?

```ts
getToken?: () => 
  | string
  | RelayCredential
  | Promise<
  | string
  | RelayCredential
  | undefined>
  | undefined;
```

Defined in: [relay-sdks/ts/src/connect-session.ts:83](https://github.com/caprids/relay-sdks/blob/main/ts/src/connect-session.ts#L83)

Resolve a connection token. Relay carries it in the endpoint's jwt query parameter.
An explicit jwt in the URL wins, and the provider is not called in that case. An empty jwt
in the URL is a RangeError, raised before the provider or the transport is used. Return a
[RelayCredential](https://www.caprid.com/docs/reference/typescript/caprid/relay/index/interfaces/relaycredential/) to say when the token expires; for a bare token the connection reads
the JWT's `exp` claim, without verifying it. The provider runs once per connection: a live
session keeps the token it connected with until the relay ends it at that expiry.

#### Returns

  \| `string`
  \| [`RelayCredential`](https://www.caprid.com/docs/reference/typescript/caprid/relay/index/interfaces/relaycredential/)
  \| `Promise`\<
  \| `string`
  \| [`RelayCredential`](https://www.caprid.com/docs/reference/typescript/caprid/relay/index/interfaces/relaycredential/)
  \| `undefined`\>
  \| `undefined`

#### Inherited from

[`ConnectRelayOptions`](https://www.caprid.com/docs/reference/typescript/caprid/relay/index/interfaces/connectrelayoptions/).[`getToken`](https://www.caprid.com/docs/reference/typescript/caprid/relay/index/interfaces/connectrelayoptions/#gettoken)

***

### namespace

```ts
namespace: readonly string[];
```

Defined in: [relay-sdks/ts/src/supervised-publisher.ts:44](https://github.com/caprids/relay-sdks/blob/main/ts/src/supervised-publisher.ts#L44)

The root namespace. Each connection serves the root followed by one generation field the SDK chooses, so the
token must grant the root, not just one namespace under it.

***

### reconnect?

```ts
reconnect?: SupervisionBackoff;
```

Defined in: [relay-sdks/ts/src/supervised-publisher.ts:46](https://github.com/caprids/relay-sdks/blob/main/ts/src/supervised-publisher.ts#L46)

Backoff between connection attempts. Default from 500 ms, doubling up to 10 s, with jitter.

***

### rotateBeforeMs?

```ts
rotateBeforeMs?: number;
```

Defined in: [relay-sdks/ts/src/supervised-publisher.ts:51](https://github.com/caprids/relay-sdks/blob/main/ts/src/supervised-publisher.ts#L51)

How long before the connection's credential expires (`RelayPublisher.expiresAt`) the next generation is brought
up to replace it, make-before-break. Default 60 seconds; never earlier than halfway through the time left.

***

### signal?

```ts
signal?: AbortSignal;
```

Defined in: [relay-sdks/ts/src/connect-session.ts:85](https://github.com/caprids/relay-sdks/blob/main/ts/src/connect-session.ts#L85)

Aborting closes the connection, including after the connect call has resolved.

#### Inherited from

[`ConnectRelayOptions`](https://www.caprid.com/docs/reference/typescript/caprid/relay/index/interfaces/connectrelayoptions/).[`signal`](https://www.caprid.com/docs/reference/typescript/caprid/relay/index/interfaces/connectrelayoptions/#signal)

***

### url?

```ts
url?: string;
```

Defined in: [relay-sdks/ts/src/connect-session.ts:74](https://github.com/caprids/relay-sdks/blob/main/ts/src/connect-session.ts#L74)

Relay's HTTPS WebTransport endpoint, including any endpoint path. Left out, the connection dials
[DEFAULT\_ENDPOINT](https://www.caprid.com/docs/reference/typescript/caprid/relay/index/variables/default_endpoint/) rooted at the token's `root` claim, read without verifying the token: the URL `roomEndpoint`
builds from that root. `getToken` is then required, and a token that names no usable root is a TypeError or
RangeError before the transport is used. Pass `url` for another relay, region or room.

#### Inherited from

[`ConnectRelayOptions`](https://www.caprid.com/docs/reference/typescript/caprid/relay/index/interfaces/connectrelayoptions/).[`url`](https://www.caprid.com/docs/reference/typescript/caprid/relay/index/interfaces/connectrelayoptions/#url)

## Methods

### onGeneration()?

```ts
onGeneration?(info): void;
```

Defined in: [relay-sdks/ts/src/supervised-publisher.ts:57](https://github.com/caprids/relay-sdks/blob/main/ts/src/supervised-publisher.ts#L57)

Called once each generation's connection is up and every registered track is bound to it. On a rotation, once
the next generation is up and every track is registered on it; each track moves to it as described in `rotate()`. A throw stops the
supervisor with that error, as `onStatus` does.

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `info` | [`PublisherGeneration`](https://www.caprid.com/docs/reference/typescript/caprid/relay/index/interfaces/publishergeneration/) |

#### Returns

`void`

***

### onStatus()?

```ts
onStatus?(status, error?): void;
```

Defined in: [relay-sdks/ts/src/supervised-publisher.ts:63](https://github.com/caprids/relay-sdks/blob/main/ts/src/supervised-publisher.ts#L63)

Called on every status change; `error` is what ended the previous connection or failed the last attempt. A throw
stops the supervisor with that error: a pending `connectSupervisedPublisher` rejects with it and `closed` resolves
with it. A throw reporting `closed` rejects the `close()` that caused it; `closed` resolves either way.

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `status` | [`SupervisedStatus`](https://www.caprid.com/docs/reference/typescript/caprid/relay/index/type-aliases/supervisedstatus/) |
| `error?` | `unknown` |

#### Returns

`void`
