@manta-eu/auth/web
Reference for @manta-eu/auth/web as it is on main.
Classes
RefusedRequestError
Extends
Error
Constructors
Constructor
new RefusedRequestError(
message,status):RefusedRequestError
Parameters
message
string
status
number
Returns
Overrides
Error.constructor
Properties
cause?
optionalcause?:unknown
Inherited from
Error.cause
message
message:
string
Inherited from
Error.message
name
name:
string
Inherited from
Error.name
stack?
optionalstack?:string
Inherited from
Error.stack
status
readonlystatus:number
stackTraceLimit
staticstackTraceLimit:number
The Error.stackTraceLimit property specifies the number of stack frames
collected by a stack trace (whether generated by new Error().stack or
Error.captureStackTrace(obj)).
The default value is 10 but may be set to any valid JavaScript number. Changes
will affect any stack trace captured after the value has been changed.
If set to a non-number value, or set to a negative number, stack traces will not capture any frames.
Inherited from
Error.stackTraceLimit
Methods
captureStackTrace()
staticcaptureStackTrace(targetObject,constructorOpt?):void
Creates a .stack property on targetObject, which when accessed returns
a string representing the location in the code at which
Error.captureStackTrace() was called.
const myObject = {};
Error.captureStackTrace(myObject);
myObject.stack; // Similar to `new Error().stack`
The first line of the trace will be prefixed with
${myObject.name}: ${myObject.message}.
The optional constructorOpt argument accepts a function. If given, all frames
above constructorOpt, including constructorOpt, will be omitted from the
generated stack trace.
The constructorOpt argument is useful for hiding implementation
details of error generation from the user. For instance:
function a() {
b();
}
function b() {
c();
}
function c() {
// Create an error without stack trace to avoid calculating the stack trace twice.
const { stackTraceLimit } = Error;
Error.stackTraceLimit = 0;
const error = new Error();
Error.stackTraceLimit = stackTraceLimit;
// Capture the stack trace above function b
Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace
throw error;
}
a();
Parameters
targetObject
object
constructorOpt?
Function
Returns
void
Inherited from
Error.captureStackTrace
prepareStackTrace()
staticprepareStackTrace(err,stackTraces):any
Parameters
err
Error
stackTraces
CallSite[]
Returns
any
See
https://v8.dev/docs/stack-trace-api#customizing-stack-traces
Inherited from
Error.prepareStackTrace
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?
optionaluserId?:never
ClientCredentials
ClientCredentials =
Realm&object
Type Declaration
clientId
clientId:
string
clientSecret
clientSecret:
string
scope?
optionalscope?:string
CustomAppUserAccessTokenOptions
CustomAppUserAccessTokenOptions =
IdentifiedCustomAppUser|AnonymousCustomAppVisitor
CustomAppUserGrantBase
CustomAppUserGrantBase =
object
Properties
apiUrl?
optionalapiUrl?: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?
optionaldatastores?:string[]
Narrows the token to these datastores; leave out to reach every datastore the app reaches.
teams?
optionalteams?: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.
FetchLike
FetchLike = (
url,init) =>Promise<Response>
Parameters
url
string
init
RequestInit
Returns
Promise<Response>
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?
optionalanonymousId?: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?
optionalclientSecret?:string
PublicClient
PublicClient =
object
Properties
baseUrl
baseUrl:
string
clientId
clientId:
string
realm
realm:
string
RenewableTokenSource
RenewableTokenSource =
TokenSource&object
Type Declaration
renew
renew: (
rejected?) =>void
Parameters
rejected?
string
Returns
void
StartWebLoginOptions
StartWebLoginOptions =
object
Properties
idpHint?
optionalidpHint?:string
offlineAccess?
optionalofflineAccess?:boolean
redirectUri
redirectUri:
string
scope?
optionalscope?:string
TokenSource
TokenSource = () =>
Promise<string>
Returns
Promise<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):Promise<WebSession>
The signed-in person’s access token, renewed when it is about to expire.
Parameters
request
Request
Returns
Promise<WebSession>
WebLoginRoutesOptions
WebLoginRoutesOptions =
object
Properties
afterLogin?
optionalafterLogin?:string
Where people land after signing in (unless /login?returnTo= names a page) and after signing out.
afterLogout?
optionalafterLogout?: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?
optionalcookieName?:string
fetchImpl?
optionalfetchImpl?:FetchLike
idpHint?
optionalidpHint?:string
offlineAccess?
optionalofflineAccess?:boolean
paths?
optionalpaths?:object
callback?
optionalcallback?:string
login?
optionallogin?:string
logout?
optionallogout?:string
sessionSecret
sessionSecret:
string
At least 32 characters, kept on the server. Rotating it signs everyone out.
signOutOfManta?
optionalsignOutOfManta?: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?
optionalidToken?:string
postLogoutRedirectUri?
optionalpostLogoutRedirectUri?:string
state?
optionalstate?:string
WebSession
WebSession =
object
Properties
accessToken
accessToken:
string|undefined
Absent when no one is signed in, or the session could not be renewed.
idToken?
optionalidToken?: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?
optionalidToken?:string
refreshToken?
optionalrefreshToken?:string
Functions
accessTokenExpiresAt()
accessTokenExpiresAt(
accessToken,now):number
Parameters
accessToken
string
now
number
Returns
number
cachedToken()
cachedToken(
mint,clock?):RenewableTokenSource
Parameters
mint
clock?
() => number
Returns
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>
describeError()
describeError(
error):string
Parameters
error
unknown
Returns
string
discoveryUrl()
discoveryUrl(
target?):string
The OpenID Connect discovery document most libraries configure themselves from.
Parameters
target?
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
refreshToken
string
fetchImpl?
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
login
callbackUrl?
string
code
string
redirectUri
string
state?
string
verifier
string
fetchImpl?
Returns
Promise<WebTokens>
issuerUrl()
issuerUrl(
target?):string
The realm’s issuer, the iss of every token it signs.
Parameters
target?
Returns
string
isTransientStatus()
isTransientStatus(
status):boolean
Parameters
status
number
Returns
boolean
mintWithClientCredentials()
mintWithClientCredentials(
credentials,fetchImpl?):Promise<string>
Parameters
credentials
fetchImpl?
FetchLike = fetch
Returns
Promise<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
refreshToken
string
fetchImpl?
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
options
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
Returns
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
options?
WebLogoutOptions = {}
Returns
string
withRenewal()
withRenewal<
T>(token,call):Promise<T>
Type Parameters
T
T
Parameters
token
call
(accessToken) => Promise<T>
Returns
Promise<T>
References
defaultDeployment
Re-exports defaultDeployment
Realm
Re-exports Realm