Authobjects. Adds authorization header to the request.
name: string- Name of fetch function. Used in logs and opossum stats.
enableCircuitBreaker?: boolean- Should use circuit breaker for requests. Defaults to
timeout?: number | false- Timeout for requests. Logged and thrown as errors. May cause circuit breaker to open. Defaults to
10000ms. Can be disabled by passing false.
treat400ResponsesAsErrors?: boolean- If
true, then too many 400 responses may cause the circuit to open. Either way these responses will be logged and thrown. Defaults to
logErrorResponseBody?: boolean- If
true, then non-200 response bodies will be consumed and included in the error object and logged as
opossum?: CircuitBreaker.Options- Allows overriding Opossum options.
error.name: string- "FetchError"
error.response: Response- The response object.
error.url: string- The requested url.
error.status: number- The response status code.
error.statusText: string- The response status text.
error.headers: Headers- The headers of the response.
error.response: Response- The response object. Body has not been consumed.
error.problem?: object- The parsed response body if the response has
error.problem?: object | string- The response body if
logErrorResponseBodywas set to
true. Parsed JSON or string depending on the response content type.
auto: Performs token exchange if an
Authobject is passed into fetch, otherwise fetches a non-user token.
issuer: string- the base URL of the IDP. We will request a token from
clientId: string- the client id to use in the client credential or token exchange grant.
clientSecret: string- the client secret to use in the client credential or token exchange grant.
scope: string- which scopes to request.
alwaysTokenExchange: boolean- Request token exchange even though the current authentication has all of the specified scopes. Defaults to false.
requestActorToken: boolean- Request a token for the actor (the real end-user) and removes information about the active delegation. This is useful for services that do not understand island.is delegation tokens or should always return data for the actor rather than the active delegation. Defaults to false.
useCache: boolean- Enables private caching for token exchange tokens. Requires
cacheManagerto be configured. This involves storing user-tokens between requests, so "Keep it secret. Keep it safe." Defaults to false.
buildCacheControlto configure cache control in a type-safe way:
overrideCacheControlonly affects GET responses, since you rarely want to cache POST requests. If you know what you're doing, then you can cache those as well:
innskra.island.isor serving data that is not specific to the authenticated user, then you may configure cache-control to support shared caching for authorized requests:
innskra.island.is, you can configure a private cache for that user. In this case, you need to pass a
Userobject (eg from @CurrentUser) to the fetch function: