Manta Developers
GitHub
Menu

@manta-eu/auth/web

Reference for @manta-eu/auth/web as it is on main.

Type Aliases

AnonymousCustomAppVisitor

AnonymousCustomAppVisitor = CustomAppUserGrantBase & object

A visitor your app has not identified, by your session id for them: they chat, and Manta keeps no memories.

Type Declaration

anonymousId

anonymousId: string

userId?

optional userId?: never


CustomAppUserAccessTokenOptions

CustomAppUserAccessTokenOptions = IdentifiedCustomAppUser | AnonymousCustomAppVisitor


CustomAppUserGrantBase

CustomAppUserGrantBase = object

Properties

apiUrl?

optional apiUrl?: string

Manta’s address, https://app.hiremanta.com unless you name another deployment.

clientId

clientId: string

The custom app’s client ID and secret, held only by the app’s server.

clientSecret

clientSecret: string

datastores?

optional datastores?: string[]

Narrows the token to these datastores; leave out to reach every datastore the app reaches.

teams?

optional teams?: string[]

Places the person in these teams of the app’s organization, by path like /Sales/EU, as a member of them. An empty list places them in no team; leaving it out places them in every team the app reaches.


IdentifiedCustomAppUser

IdentifiedCustomAppUser = CustomAppUserGrantBase & CustomAppUserProfile & object

A person your app knows: Manta keeps their chats under your id for them, and no memories.

Type Declaration

anonymousId?

optional anonymousId?: never

userId

userId: string


OidcClient

OidcClient = Omit<PublicClient, "baseUrl" | "realm"> & Realm & object

A client with a secret is an app’s own server; without one it is a public client, like the CLIs.

Type Declaration

clientSecret?

optional clientSecret?: string


PublicClient

PublicClient = object

Properties

baseUrl

baseUrl: string

clientId

clientId: string

realm

realm: string


StartWebLoginOptions

StartWebLoginOptions = object

Properties

idpHint?

optional idpHint?: string

offlineAccess?

optional offlineAccess?: boolean

redirectUri

redirectUri: string

scope?

optional scope?: string


WebLoginRoutes

WebLoginRoutes = object

Methods

handle()

handle(request): Promise<Response | undefined>

Answers the login, callback and logout paths; undefined for any other request.

Parameters
request

Request

Returns

Promise<Response | undefined>

session()

session(request, options?): Promise<WebSession>

The signed-in person’s access token, renewed when it is about to expire, or on renew.

Parameters
request

Request

options?

WebSessionOptions

Returns

Promise<WebSession>


WebLoginRoutesOptions

WebLoginRoutesOptions = object

Properties

afterLogin?

optional afterLogin?: string

Where people land after signing in (unless /login?returnTo= names a page) and after signing out.

afterLogout?

optional afterLogout?: string

appUrl

appUrl: string

Where the app runs, e.g. https://app.example.com; paths.callback under it must be a registered redirect URL.

client

client: OidcClient & object

A confidential client: a custom app’s client ID and secret, plus baseUrl and realm off hiremanta.com.

Type Declaration
clientSecret

clientSecret: string

cookieName?

optional cookieName?: string

Names the session cookie (manta_session by default); on https it gets the __Host- prefix.

fetchImpl?

optional fetchImpl?: FetchLike

idpHint?

optional idpHint?: string

offlineAccess?

optional offlineAccess?: boolean

paths?

optional paths?: object

callback?

optional callback?: string

login?

optional login?: string

logout?

optional logout?: string

sessionSecret

sessionSecret: string

At least 32 characters, kept on the server. Rotating it signs everyone out.

signOutOfManta?

optional signOutOfManta?: boolean

Off signs people out of this app only; on (the default) ends their Manta session too.


WebLoginStart

WebLoginStart = object

Properties

state

state: string

url

url: string

verifier

verifier: string


WebLogoutOptions

WebLogoutOptions = object

Properties

idToken?

optional idToken?: string

postLogoutRedirectUri?

optional postLogoutRedirectUri?: string

state?

optional state?: string


WebSession

WebSession = object

Properties

accessToken

accessToken: string | undefined

Absent when no one is signed in, or the session could not be renewed.

idToken?

optional idToken?: string

setCookies

setCookies: string[]

Set-Cookie values to add to the response: a renewed session, or one cleared after a refused renewal.


WebTokens

WebTokens = object

Properties

accessToken

accessToken: string

idToken?

optional idToken?: string

refreshToken?

optional refreshToken?: string

Functions

customAppUserAccessToken()

customAppUserAccessToken(options, fetchImpl?): Promise<string>

Gets a Manta access token for one of the app’s own users, or for an anonymous visitor. It sends the app’s client secret, so call it on the app’s server only; the token it returns may go to the browser.

Parameters

options

CustomAppUserAccessTokenOptions

fetchImpl?

FetchLike = fetch

Returns

Promise<string>


discoveryUrl()

discoveryUrl(target?): string

The OpenID Connect discovery document most libraries configure themselves from.

Parameters

target?

Realm

Returns

string


endWebLogin()

endWebLogin(client, refreshToken, fetchImpl?): Promise<boolean>

Revokes the refresh token, ending this app’s session only; false when Keycloak did not confirm.

Parameters

client

OidcClient

refreshToken

string

fetchImpl?

FetchLike

Returns

Promise<boolean>


finishWebLogin()

finishWebLogin(client, login, fetchImpl?): Promise<WebTokens>

Trades the callback for tokens; pass callbackUrl and state to have them checked too.

Parameters

client

OidcClient

login
callbackUrl?

string

code

string

redirectUri

string

state?

string

verifier

string

fetchImpl?

FetchLike

Returns

Promise<WebTokens>


isRefusedWebLogin()

isRefusedWebLogin(error): boolean

Parameters

error

unknown

Returns

boolean


issuerUrl()

issuerUrl(target?): string

The realm’s issuer, the iss of every token it signs.

Parameters

target?

Realm

Returns

string


refreshWebLogin()

refreshWebLogin(client, refreshToken, fetchImpl?): Promise<WebTokens | undefined>

Renews the access token; store the rotated refresh token it returns. undefined means sign in again.

Parameters

client

OidcClient

refreshToken

string

fetchImpl?

FetchLike

Returns

Promise<WebTokens | undefined>


startWebLogin()

startWebLogin(client, options): Promise<WebLoginStart>

Starts a sign-in; keep state and verifier in the person’s session for the callback.

Parameters

client

OidcClient

options

StartWebLoginOptions

Returns

Promise<WebLoginStart>


webLoginRoutes()

webLoginRoutes(options): WebLoginRoutes

Sign-in, callback and sign-out routes for a custom app’s server, on standard Request and Response.

Parameters

options

WebLoginRoutesOptions

Returns

WebLoginRoutes


webLogoutUrl()

webLogoutUrl(client, options?): string

Where to send the browser to sign out of Manta too; pass the latest idToken to skip Keycloak’s prompt.

Parameters

client

OidcClient

options?

WebLogoutOptions = {}

Returns

string


webSessionCookieName()

webSessionCookieName(appUrl, cookieName?): string

Parameters

appUrl

string | URL

cookieName?

string = "manta_session"

Returns

string

References

accessTokenExpiresAt

Re-exports accessTokenExpiresAt


cachedToken

Re-exports cachedToken


ClientCredentials

Re-exports ClientCredentials


defaultDeployment

Re-exports defaultDeployment


describeError

Re-exports describeError


FetchLike

Re-exports FetchLike


isTransientStatus

Re-exports isTransientStatus


mintWithClientCredentials

Re-exports mintWithClientCredentials


Realm

Re-exports Realm


RefusedRequestError

Re-exports RefusedRequestError


RenewableTokenSource

Re-exports RenewableTokenSource


TokenSource

Re-exports TokenSource


withRenewal

Re-exports withRenewal