iya-sts
    Preparing search index...

    A static application's OAuth 2.0 client: PKCE, DPoP and the tokens.

    Hierarchy (View Summary)

    Index
    • Makes the client.

      Parameters

      • env: any

        the browser's objects: fetch, crypto (WebCrypto), location, history, document, sessionStorage, navigator, window, and, for a test, now (milliseconds; Date.now where left out)

      • prefix: string

        the realm's path prefix, '' in the default realm

      • options: SpaClientOptions

        the client's id, its scope and the shell's attributes

      Returns export=

    accessToken: string
    accountChannel: any
    accountKey: string
    accounts: any
    clientId: string
    elsewhere: any
    env: any
    expiresAt: number
    freshScopes: string[]
    identity: number
    identityController: any
    issuerPrefix: string
    key: any
    metadata: any
    nonce: string
    prefix: string
    publicJwk: any
    refreshToken: string
    scope: string
    stepActions: any = null

    What the step's bar's buttons do, for a test that presses one.

    stepping: any
    subject: string
    writeGrants: Record<string, WriteGrant>
    writeScopes: string[]
    CALLBACK_CHANNEL: "sts-spa-callback" = 'sts-spa-callback'
    CALLBACK_HANDOFF_MS: 1000
    FRESH_MAX_AGE_S: 300

    How recent a sign-in a scope in freshScopes asks for before a person is asked to sign in again, in seconds (max_age).

    INTERACTION_ERRORS: string[] = ...

    The authorization errors a silent step answers that a sign-in in the window can mend (OpenID Connect Core section 3.1.2.6).

    SIGNIN_KEYS: string[] = ...
    STEP_CHANNEL: "sts-spa-step" = 'sts-spa-step'

    The channel a second authorization's callback answers on.

    STEP_STATE_PREFIX: "step." = 'step.'

    The state prefix that marks a second authorization's callback.

    STORAGE_PROBE: "sts-storage-probe" = 'sts-storage-probe'

    The key a write is tried under, and removed at once.

    WEBCRYPTO_CALLS: string[] = ...

    The WebCrypto calls a sign-in makes, each a method of crypto.subtle.

    WRITE_EARLY_MS: number = ...

    How long before a write token's end it is no longer sent, in milliseconds.

    WRITE_HOLD_MS: number = ...

    The longest a write token is used, in milliseconds, whatever its own lifetime.

    • Announces that this tab changed the browser's account list.

      Parameters

      • change: string

        added, signed-out, forgotten or changed

      Returns void

      nothing

    • The authorization server's metadata for this realm (RFC 8414), once.

      Returns Promise<any>

      the metadata, or {} where it cannot be read

    • The authorization request's URL: pushed first where the realm requires it, the query otherwise.

      Parameters

      • params: any

        the request's parameters, client_id among them

      Returns Promise<string>

      the URL to send the browser to

    • The application's authorization request, with extra added: scope, prompt, max_age.

      Parameters

      • state: string

        the state

      • verifier: string

        the PKCE verifier

      • Optionalextra: any

        what this request adds or replaces

      Returns Promise<string>

      the URL

    • Opens the step's window, or offers to, and waits for its callback's answer or the person's Cancel.

      Parameters

      • channel: any

        the channel the callback answers on

      • request: any

        { state, url }

      • words: any

        stepWords()

      • message: string

        what the bar says meanwhile

      Returns Promise<any>

      the answer { code, iss, error, error_description }, or { cancelled: true }

    • The parameters of the authorization response this page was loaded with, from the fragment or, for a realm that offers only the query, the query.

      Returns any

      the parameters

    • Discards what this client holds for the identity that just ended: the tokens, the subject, the DPoP key and its nonce, and the metadata. A key is made again for the next sign-in, as a page load makes one.

      Returns void

      nothing

    • Draws the step's bar over the page, which stays as it is under it.

      Parameters

      • message: string

        what it says

      • actions: any

        { open, cancel }, each a function or null; null for a bar that only says something and closes with its button

      Returns void

      nothing

    • Stops using a write token: it was refused, or a sign-in replaced it.

      Parameters

      • Optionalresource: string

        the resource indicator, or nothing for every one

      Returns void

      nothing

    • Ends the identity requests are sent for: every request in flight is aborted, and an answer to one sent before is not believed.

      Returns void

      nothing

    • A form's fields as an object: a repeated name is an array, the pressed button's name and value are included, and the CSRF field a form drawn by the server carried is left out (an API call is not a form post).

      Parameters

      • form: any

        the form element

      • submitter: any

        the button pressed, if any

      Returns any

      the fields

    • At the application's callback in a step's window: hands the answer to the page that opened it and closes, redeeming nothing.

      Parameters

      • query: any

        the opened authorization response

      • path: string

        the callback's path, which the address is put back to

      Returns boolean

      whether this was a step's callback

    • Offers this callback to the tab that started the sign-in.

      A same-device wallet opens the verifier's return in a new tab. The passkey, when one is asked for, finishes there, and the authorization server then sends that tab to this callback. The PKCE record was written in the tab that called beginSignIn and never left it, so this tab cannot redeem the code. It asks that tab to load this address. The code rides only on the answer to a tab that said it holds the record. No answer within a second, and this tab finishes the refusal itself.

      Parameters

      • query: any

        the opened authorization response

      Returns Promise<boolean>

      whether a tab accepted the callback

    • The login_hint a sign-in sends: what the caller names, else the tab's account, else none.

      Parameters

      • extra: any

        what the sign-in was started with: login_hint ('' for none at all, as Sign in with another account asks)

      Returns string

      the hint, or ''

    • The abort signal of the identity requests are being sent for now.

      Returns any

      the signal, or undefined where the browser has no AbortController

    • RFC 9207's iss on the authorization response, where the server sends one (ASVS 5.0.0 10.2.2): it must name this server.

      Parameters

      • query: any

        the response's parameters

      Returns Promise<boolean>

      false when the response came from somebody else

    • The address of a path at the realm that issued the tokens in hand (issuerPrefix, #2200): the authorization server's endpoints, the callback a token is redeemed at, and the resource a token is for. The realm on screen's where none was recorded, or it is that realm.

      Parameters

      • path: string

        /oauth2/token, /admin/callback, /admin-api

      Returns string

      the absolute URL

    • Keeps the tab's account, or forgets it.

      Parameters

      • account: any

        { sub, username }, or null to forget it

      Returns void

      nothing

    • Keeps the nonce a response carried, for the next proof.

      Parameters

      • res: any

        a fetch response

      Returns void

      nothing

    • Keeps the tokens a token endpoint answered with.

      Parameters

      • json: any

        the token response

      Returns void

      nothing

    • Where a browser with no window or no channel goes instead: a sign-in on this page, asking for scope. It loses the write waiting.

      Parameters

      • scope: string

        the scope to sign in with

      • prompt: string

        login, or '' for none

      Returns Promise<void>

      nothing

    • Listens for changes to the browser's account list, once: each change reads the list again and hands it to then, and changes nothing else.

      Parameters

      • then: (list: any) => void

        draws the menu again from the list

      Returns void

      nothing

    • The nonce of a sign-in whose PKCE verifier this is.

      Parameters

      • verifier: string

        the sign-in's PKCE verifier

      Returns Promise<string>

      the nonce, base64url

    • Whether an ID Token carries the nonce of the sign-in that verifier began.

      Parameters

      • idToken: any

        the compact JWT the token endpoint answered

      • verifier: string

        the sign-in's PKCE verifier

      Returns Promise<boolean>

      whether the nonce is there and is that sign-in's

    • The words a page without session storage draws, in the page's language: browser.noStorage.title and browser.noStorage.text, and the translator they came from.

      Parameters

      • namespace: string

        the surface's catalog namespace

      Returns Promise<any>

      { t, title, text }

    • The words a page without WebCrypto draws, in the page's language: the namespace's noWebCrypto.title and noWebCrypto.text, and the translator they came from (with the footer's words in it).

      Parameters

      • namespace: string

        the surface's catalog namespace (consoleRuntime, portal, report)

      Returns Promise<any>

      { t, title, text }

    • The translator a page drawn before sign-in says a problem with: the namespace's catalogs (and, with every WebI18n, the browser one), or none where no catalog can be had, so the English is drawn.

      Parameters

      • namespace: string

        the surface's catalog namespace

      Returns Promise<any>

      the translator

    • Makes a DPoP proof for one request.

      Parameters

      • method: string

        the request's method

      • url: string

        the request's URL; its query and fragment are dropped

      • accessToken: string

        the access token it is sent with, or ''

      Returns Promise<string>

      the proof

    • Calls an operation that takes no token, sending an object as JSON, and reads its JSON.

      Parameters

      • method: string

        GET or POST

      • path: string

        the path under the realm

      • Optionalbody: any

        for a POST, an object

      • Optionalheaders: any

      Returns Promise<any>

      { status, json, res }, json null where the body was not JSON

    • Random bytes, base64url.

      Parameters

      • n: number

        how many bytes

      Returns string

      the encoding

    • Reads the browser's account list, keeps it, and keeps the tab's account from it: the signed-in subject's username, or forgets the account where the list is off.

      Parameters

      • username: string

        the signed-in person's username as the application knows it, for a subject the list does not name

      Returns Promise<any>

      the list

    • Saves a file an answer carried as base64.

      Parameters

      • name: string

        its file name

      • mime: string

        its media type

      • base64: string

        its bytes

      Returns void

      nothing

    • Hands a blob to the browser as a download.

      Parameters

      • name: string

        the file's name

      • blob: Blob

        its contents

      Returns void

      nothing

    • Saves text as a file.

      Parameters

      • name: string

        the file's name

      • mime: string

        its media type

      • text: string

        its contents

      Returns void

      nothing

    • SHA-256 of a string, base64url.

      Parameters

      • text: string

        the string

      Returns Promise<string>

      the digest's encoding

    • One second authorization, the body of stepUp().

      Parameters

      • resource: string

        the resource indicator

      • wanted: string[]

        the scopes asked for

      • held: string[]

        the scopes the write token in hand carries

      • fresh: boolean

        whether a fresh sign-in is asked for

      Returns Promise<boolean>

      whether a write token carrying every scope asked for is held

    • Gets a write token carrying the scopes a refusal named, by a second authorization, and keeps it for its resource.

      Parameters

      • resource: string

        the resource indicator the write was for

      • named: string[]

        the scopes the refusal named

      • Optionalfresh: boolean

        whether a fresh sign-in is asked for whatever is named

      Returns Promise<boolean>

      true when a write token carrying every scope asked for is held and the write may be sent again; false otherwise

    • The words of the step's bar, in English. A runtime with a translator overrides this with its catalog's.

      Returns any

      { pending, blocked, signIn, fresh, open, cancel, refused, other, failed }

    • The token a request is sent with: a GET's is always the read token, anything else the write token for its resource while one is held.

      Parameters

      • method: string

        the request's method

      • resource: string

        the resource indicator

      Returns string

      the token, or '' where none is held

    • Posts a form to the token endpoint with a DPoP proof.

      Parameters

      • form: any

        the form fields

      Returns Promise<any>

      the response's JSON and status

    • This realm's address for one of its paths: on this origin, or on the listener that answers the path where the shell named one.

      Parameters

      • path: string

        /oauth2/token, /web/locales/catalogs.json

      Returns string

      the absolute URL

    • The scopes a write token for a resource carries, while it is held.

      Parameters

      • resource: string

        the resource indicator

      Returns string[]

      the scope values

    • The write token for a resource while it may still be sent, or ''.

      Parameters

      • resource: string

        the resource indicator the token is audienced to

      Returns string

      the token, or ''

    • Whether an answer is for the subject asked for: the one subject check the console's popup made first (#508) and every switch makes now (#561).

      Parameters

      • expected: string

        the subject asked for

      • idToken: any

        the ID Token the token endpoint answered

      Returns boolean

      whether its sub is that subject

    • One attribute of the shell's <html> element.

      Parameters

      • env: any

        the browser's objects

      • name: string

        the attribute, data-sts-build

      Returns string

      its value, or '' where it is absent

    • Base64url without padding.

      Parameters

      • bytes: Uint8Array

        the bytes

      Returns string

      the encoding

    • Reads the shell's data-sts-* attributes into bases by path segment.

      Parameters

      • env: any

        the browser's objects; its document is read

      • attributes: Record<string, string>

        the attribute for each first path segment

      Returns any

      the bases, without a trailing slash, '' where absent

    • Whether the browser check marked this document as one this browser cannot run.

      Parameters

      • doc: any

        the document

      Returns boolean

      true where <html data-sts-unsupported="1">

    • The link to what this service needs from a browser (#2220), as a paragraph, in the page's language: what each "this browser cannot" page carries.

      Parameters

      • t: any

        the page's translator, or null

      Returns string

      the markup

    • A string claim of an ID Token, read without verifying it.

      Parameters

      • idToken: any

        the compact JWT, or nothing

      • name: string

        the claim

      Returns string

      its value, or ''

    • Form-encodes parameters, a value that is an array as the parameter repeated — RFC 8707's resource, which a client asking for two resources sends twice (#607). URLSearchParams(object) would join the array with commas into one value naming no resource.

      Parameters

      • params: any

        the parameters

      Returns string

      the encoded form

    • Bytes of a base64url string.

      Parameters

      • text: string

        the encoding

      Returns Uint8Array

      the bytes

    • The scopes a 403's insufficient_scope challenge names (RFC 6750 section 3.1), or none for any other answer.

      Parameters

      • res: any

        a fetch response

      Returns string[]

      the scope values named

    • Splits a path at a surface's base: the realm prefix before it.

      Parameters

      • pathname: string

        a path, /realm/acme/portal/keys or /portal

      • base: string

        the surface's first path, /portal

      Returns string

      the prefix, '' in the default realm and where the path is not under the base

    • Parses a query string into an object, the last value of a repeated name winning as express's own parser does for a single value.

      Parameters

      • search: string

        ?a=1&b=2 or ''

      Returns any

      the query

    • Prefixes every root-relative href, action, formaction and src not already in the realm.

      Parameters

      • html: string

        the page

      • prefix: string

        the realm's path prefix, or '' for the default realm

      Returns string

      the page with its links in the realm

    • Whether this browser lacks the sessionStorage a sign-in needs: there is none, or a write to it throws.

      Parameters

      • env: any

        the browser's objects; env.sessionStorage is asked

      Returns boolean

      true when a sign-in could not keep its record

    • Moves a sign-in step's id from a link's query to its fragment (#1454). /authn/spnego stays: RFC 4559's exchange has no script to read one.

      Parameters

      • href: string

        the link

      Returns string

      the link to use

    • Takes a step's id off an API address, for a header (#1454).

      Parameters

      • path: string

        the operation's address

      Returns any

      the address, and the headers that carry what left it

    • The window's sessionStorage, or null where reading it throws (a browser that blocks site data refuses the property itself).

      Parameters

      • w: any

        the window

      Returns any

      the storage, or null

    • The sub of an ID Token, read without verifying it.

      Parameters

      • idToken: any

        the compact JWT, or nothing

      Returns string

      the subject, or ''

    • WebCrypto's names for a JWS algorithm: how its key is imported and how a signature is verified, or null for one WebCrypto does not do.

      Parameters

      • alg: string

        the JWS alg

      Returns any

      { importAs, verifyAs }, or null

    • Whether this browser lacks what a sign-in needs from WebCrypto.

      Parameters

      • env: any

        the browser's objects; env.crypto is asked

      Returns boolean

      true when crypto, crypto.getRandomValues or any of WEBCRYPTO_CALLS on crypto.subtle is missing