# ExternalResourcesOptions

## Content

# Interface: ExternalResourcesOptions

Configuration options for handling external resources required by
X.509 validation and related PDF security features.

This API provides hooks to fully control:
- URL resolution (proxying, rewriting, signing)
- network transport layer (custom fetch implementation)
- request/response lifecycle events (logging, caching, debugging)

## Properties

### afterResponse?

```ts
optional afterResponse?: (resource, responseData) => void;
```

Hook invoked after a successful resource response is received.

Provides access to both the request context and raw response data,
useful for caching, inspection, or telemetry.

#### Parameters

##### resource

[`ResourceProperties`](ResourceProperties)

##### responseData

`ArrayBuffer`

#### Returns

`void`

***

### beforeRequest?

```ts
optional beforeRequest?: (resource) => void;
```

Hook invoked immediately before a resource request is executed.

Can be used for:
- logging
- request tracing
- modifying external state (metrics, UI indicators)

#### Parameters

##### resource

[`ResourceProperties`](ResourceProperties)

#### Returns

`void`

***

### loader?

```ts
optional loader?: ResourceLoader;
```

Custom resource loader implementation.

If not provided, the library will use a default loader
based on the current runtime environment (browser or Node.js).

***

### onError?

```ts
optional onError?: (resource, err) => void;
```

Hook invoked when a resource request fails.

Useful for:
- retry strategies
- error reporting
- fallback logic (e.g., alternate OCSP/CRL endpoints)

#### Parameters

##### resource

[`ResourceProperties`](ResourceProperties)

##### err

`unknown`

#### Returns

`void`

***

### resolveUrl?

```ts
optional resolveUrl?: (ctx) => string | Promise<string>;
```

Optional URL resolver that allows rewriting or proxying
external resource URLs before they are fetched.

This is especially useful in browser environments where CORS restrictions
prevent direct access to certificate-related endpoints.

#### Parameters

##### ctx

[`ResourceProperties`](ResourceProperties)

#### Returns

`string` \| `Promise`&lt;`string`&gt;
