Skip to content

Provider

Defined in: @types/oidc-provider/index.d.ts:1517

  • Application

new Provider(issuer, configuration?): Provider

Defined in: @types/oidc-provider/index.d.ts:1518

string

Configuration

Provider

Koa.constructor

readonly AccessToken: typeof AccessToken

Defined in: @types/oidc-provider/index.d.ts:2182


readonly app: Application

Defined in: @types/oidc-provider/index.d.ts:1525


readonly AuthorizationCode: typeof AuthorizationCode

Defined in: @types/oidc-provider/index.d.ts:2185


readonly BackchannelAuthenticationRequest: typeof BackchannelAuthenticationRequest

Defined in: @types/oidc-provider/index.d.ts:2190


readonly BaseToken: typeof BaseToken

Defined in: @types/oidc-provider/index.d.ts:2191


readonly Client: typeof Client

Defined in: @types/oidc-provider/index.d.ts:2181


readonly ClientCredentials: typeof ClientCredentials

Defined in: @types/oidc-provider/index.d.ts:2188


context: BaseContext & DefaultContext

Defined in: @types/koa/index.d.ts:453

Koa.context


ctxStorage: AsyncLocalStorage<DefaultContext> | undefined

Defined in: @types/koa/index.d.ts:458

Koa.ctxStorage


readonly currentContext: DefaultContext | undefined

Defined in: @types/koa/index.d.ts:542

return current context from async local storage

Koa.currentContext


readonly DeviceCode: typeof DeviceCode

Defined in: @types/oidc-provider/index.d.ts:2189


env: string

Defined in: @types/koa/index.d.ts:452

Koa.env


readonly Grant: typeof Grant

Defined in: @types/oidc-provider/index.d.ts:2180


readonly IdToken: typeof IdToken

Defined in: @types/oidc-provider/index.d.ts:2192


readonly InitialAccessToken: typeof InitialAccessToken

Defined in: @types/oidc-provider/index.d.ts:2183


readonly Interaction: typeof Interaction

Defined in: @types/oidc-provider/index.d.ts:2196


readonly issuer: string

Defined in: @types/oidc-provider/index.d.ts:1520


keys: string[] | Keygrip

Defined in: @types/koa/index.d.ts:457

Koa.keys


maxIpsCount: number

Defined in: @types/koa/index.d.ts:449

Koa.maxIpsCount


middleware: Middleware<DefaultState, DefaultContext, any>[]

Defined in: @types/koa/index.d.ts:450

Koa.middleware


readonly OIDCContext: typeof OIDCContext

Defined in: @types/oidc-provider/index.d.ts:2194


proxy: boolean

Defined in: @types/koa/index.d.ts:447

Koa.proxy


proxyIpHeader: string

Defined in: @types/koa/index.d.ts:448

Koa.proxyIpHeader


readonly PushedAuthorizationRequest: typeof PushedAuthorizationRequest

Defined in: @types/oidc-provider/index.d.ts:2187


readonly RefreshToken: typeof RefreshToken

Defined in: @types/oidc-provider/index.d.ts:2184


readonly RegistrationAccessToken: typeof RegistrationAccessToken

Defined in: @types/oidc-provider/index.d.ts:2186


readonly ReplayDetection: typeof ReplayDetection

Defined in: @types/oidc-provider/index.d.ts:2193


request: BaseRequest

Defined in: @types/koa/index.d.ts:454

Koa.request


response: BaseResponse

Defined in: @types/koa/index.d.ts:455

Koa.response


readonly Session: typeof Session

Defined in: @types/oidc-provider/index.d.ts:2195


silent: boolean

Defined in: @types/koa/index.d.ts:456

Koa.silent


subdomainOffset: number

Defined in: @types/koa/index.d.ts:451

Koa.subdomainOffset


static captureRejections: boolean

Defined in: @types/node/events.d.ts:425

Value: boolean

Change the default captureRejections option on all new EventEmitter objects.

v13.4.0, v12.16.0

Koa.captureRejections


readonly static captureRejectionSymbol: typeof captureRejectionSymbol

Defined in: @types/node/events.d.ts:418

Value: Symbol.for('nodejs.rejection')

See how to write a custom rejection handler.

v13.4.0, v12.16.0

Koa.captureRejectionSymbol


static defaultMaxListeners: number

Defined in: @types/node/events.d.ts:464

By default, a maximum of 10 listeners can be registered for any single event. This limit can be changed for individual EventEmitter instances using the emitter.setMaxListeners(n) method. To change the default for allEventEmitter instances, the events.defaultMaxListeners property can be used. If this value is not a positive number, a RangeError is thrown.

Take caution when setting the events.defaultMaxListeners because the change affects all EventEmitter instances, including those created before the change is made. However, calling emitter.setMaxListeners(n) still has precedence over events.defaultMaxListeners.

This is not a hard limit. The EventEmitter instance will allow more listeners to be added but will output a trace warning to stderr indicating that a “possible EventEmitter memory leak” has been detected. For any single EventEmitter, the emitter.getMaxListeners() and emitter.setMaxListeners() methods can be used to temporarily avoid this warning:

import { EventEmitter } from 'node:events';
const emitter = new EventEmitter();
emitter.setMaxListeners(emitter.getMaxListeners() + 1);
emitter.once('event', () => {
// do stuff
emitter.setMaxListeners(Math.max(emitter.getMaxListeners() - 1, 0));
});

The --trace-warnings command-line flag can be used to display the stack trace for such warnings.

The emitted warning can be inspected with process.on('warning') and will have the additional emitter, type, and count properties, referring to the event emitter instance, the event’s name and the number of attached listeners, respectively. Its name property is set to 'MaxListenersExceededWarning'.

v0.11.2

Koa.defaultMaxListeners


readonly static errorMonitor: typeof errorMonitor

Defined in: @types/node/events.d.ts:411

This symbol shall be used to install a listener for only monitoring 'error' events. Listeners installed using this symbol are called before the regular 'error' listeners are called.

Installing a listener using this symbol does not change the behavior once an 'error' event is emitted. Therefore, the process will still crash if no regular 'error' listener is installed.

v13.6.0, v12.17.0

Koa.errorMonitor

get static ctx(): KoaContextWithOIDC | undefined

Defined in: @types/oidc-provider/index.d.ts:1527

KoaContextWithOIDC | undefined

optional [captureRejectionSymbol]<K>(error, event, …args): void

Defined in: @types/node/events.d.ts:103

K

Error

string | symbol

AnyRest

void

Koa.[captureRejectionSymbol]


addListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1562

Alias for emitter.on(eventName, listener).

"access_token.destroyed"

(accessToken) => void

this

v0.1.26

Koa.addListener

addListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1563

"access_token.saved"

(accessToken) => void

this

Koa.addListener

addListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1564

"access_token.issued"

(accessToken) => void

this

Koa.addListener

addListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1565

"authorization_code.saved"

(authorizationCode) => void

this

Koa.addListener

addListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1566

"authorization_code.destroyed"

(authorizationCode) => void

this

Koa.addListener

addListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1567

"authorization_code.consumed"

(authorizationCode) => void

this

Koa.addListener

addListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1568

"device_code.saved"

(deviceCode) => void

this

Koa.addListener

addListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1569

"device_code.destroyed"

(deviceCode) => void

this

Koa.addListener

addListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1570

"device_code.consumed"

(deviceCode) => void

this

Koa.addListener

addListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1571

"backchannel_authentication_request.saved"

(deviceCode) => void

this

Koa.addListener

addListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1572

"backchannel_authentication_request.destroyed"

(deviceCode) => void

this

Koa.addListener

addListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1576

"backchannel_authentication_request.consumed"

(deviceCode) => void

this

Koa.addListener

addListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1577

"client_credentials.destroyed"

(clientCredentials) => void

this

Koa.addListener

addListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1578

"client_credentials.saved"

(clientCredentials) => void

this

Koa.addListener

addListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1579

"client_credentials.issued"

(clientCredentials) => void

this

Koa.addListener

addListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1580

"interaction.destroyed"

(interaction) => void

this

Koa.addListener

addListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1581

"interaction.saved"

(interaction) => void

this

Koa.addListener

addListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1582

"session.destroyed"

(session) => void

this

Koa.addListener

addListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1583

"session.saved"

(session) => void

this

Koa.addListener

addListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1584

"grant.destroyed"

(grant) => void

this

Koa.addListener

addListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1585

"grant.saved"

(grant) => void

this

Koa.addListener

addListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1586

"replay_detection.destroyed"

(replayDetection) => void

this

Koa.addListener

addListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1587

"replay_detection.saved"

(replayDetection) => void

this

Koa.addListener

addListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1588

"pushed_authorization_request.destroyed"

(pushedAuthorizationRequest) => void

this

Koa.addListener

addListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1592

"pushed_authorization_request.saved"

(pushedAuthorizationRequest) => void

this

Koa.addListener

addListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1596

"registration_access_token.destroyed"

(registrationAccessToken) => void

this

Koa.addListener

addListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1600

"registration_access_token.saved"

(registrationAccessToken) => void

this

Koa.addListener

addListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1604

"refresh_token.destroyed"

(refreshToken) => void

this

Koa.addListener

addListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1605

"refresh_token.saved"

(refreshToken) => void

this

Koa.addListener

addListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1606

"refresh_token.consumed"

(refreshToken) => void

this

Koa.addListener

addListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1607

"authorization.accepted"

(ctx) => void

this

Koa.addListener

addListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1608

"authorization.success"

(ctx) => void

this

Koa.addListener

addListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1609

"authorization.error"

(ctx, err) => void

this

Koa.addListener

addListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1613

"end_session.success"

(ctx) => void

this

Koa.addListener

addListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1614

"end_session.error"

(ctx, err) => void

this

Koa.addListener

addListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1618

"grant.success"

(ctx) => void

this

Koa.addListener

addListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1619

"interaction.ended"

(ctx) => void

this

Koa.addListener

addListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1620

"interaction.started"

(ctx, interaction) => void

this

Koa.addListener

addListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1624

"grant.error"

(ctx, err) => void

this

Koa.addListener

addListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1625

"grant.revoked"

(ctx, grantId) => void

this

Koa.addListener

addListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1626

"backchannel.success"

(ctx, client, accountId, sid) => void

this

Koa.addListener

addListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1630

"backchannel.error"

(ctx, err, client, accountId, sid) => void

this

Koa.addListener

addListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1634

"pushed_authorization_request.success"

(ctx) => void

this

Koa.addListener

addListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1635

"pushed_authorization_request.error"

(ctx, err) => void

this

Koa.addListener

addListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1639

"registration_update.success"

(ctx, client) => void

this

Koa.addListener

addListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1643

"registration_update.error"

(ctx, err) => void

this

Koa.addListener

addListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1647

"registration_delete.success"

(ctx, client) => void

this

Koa.addListener

addListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1651

"registration_delete.error"

(ctx, err) => void

this

Koa.addListener

addListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1655

"registration_create.success"

(ctx, client) => void

this

Koa.addListener

addListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1659

"registration_create.error"

(ctx, err) => void

this

Koa.addListener

addListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1663

"introspection.error"

(ctx, err) => void

this

Koa.addListener

addListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1667

"registration_read.error"

(ctx, err) => void

this

Koa.addListener

addListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1671

"jwks.error"

(ctx, err) => void

this

Koa.addListener

addListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1672

"discovery.error"

(ctx, err) => void

this

Koa.addListener

addListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1676

"userinfo.error"

(ctx, err) => void

this

Koa.addListener

addListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1680

"revocation.error"

(ctx, err) => void

this

Koa.addListener

addListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1684

"server_error"

(ctx, err) => void

this

Koa.addListener


backchannelResult(request, result, opts?): Promise<void>

Defined in: @types/oidc-provider/index.d.ts:1529

string | BackchannelAuthenticationRequest

string | OIDCProviderError | Grant

string

string[]

number

Promise<void>


callback(): (req, res) => Promise<void>

Defined in: @types/koa/index.d.ts:520

Return a request handler callback for node’s native http/http2 server.

(req, res) => Promise<void>

Koa.callback


createContext<StateT>(req, res): ParameterizedContext<StateT>

Defined in: @types/koa/index.d.ts:527

Initialize a new context.

StateT = DefaultState

IncomingMessage

ServerResponse

ParameterizedContext<StateT>

private

Koa.createContext


emit<K>(eventName, …args): boolean

Defined in: @types/node/events.d.ts:904

Synchronously calls each of the listeners registered for the event named eventName, in the order they were registered, passing the supplied arguments to each.

Returns true if the event had listeners, false otherwise.

import { EventEmitter } from 'node:events';
const myEmitter = new EventEmitter();
// First listener
myEmitter.on('event', function firstListener() {
console.log('Helloooo! first listener');
});
// Second listener
myEmitter.on('event', function secondListener(arg1, arg2) {
console.log(`event with parameters ${arg1}, ${arg2} in second listener`);
});
// Third listener
myEmitter.on('event', function thirdListener(...args) {
const parameters = args.join(', ');
console.log(`event with parameters ${parameters} in third listener`);
});
console.log(myEmitter.listeners('event'));
myEmitter.emit('event', 1, 2, 3, 4, 5);
// Prints:
// [
// [Function: firstListener],
// [Function: secondListener],
// [Function: thirdListener]
// ]
// Helloooo! first listener
// event with parameters 1, 2 in second listener
// event with parameters 1, 2, 3, 4, 5 in third listener

K

string | symbol

AnyRest

boolean

v0.1.26

Koa.emit


eventNames(): (string | symbol)[]

Defined in: @types/node/events.d.ts:967

Returns an array listing the events for which the emitter has registered listeners. The values in the array are strings or Symbols.

import { EventEmitter } from 'node:events';
const myEE = new EventEmitter();
myEE.on('foo', () => {});
myEE.on('bar', () => {});
const sym = Symbol('symbol');
myEE.on(sym, () => {});
console.log(myEE.eventNames());
// Prints: [ 'foo', 'bar', Symbol(symbol) ]

(string | symbol)[]

v6.0.0

Koa.eventNames


getMaxListeners(): number

Defined in: @types/node/events.d.ts:819

Returns the current max listener value for the EventEmitter which is either set by emitter.setMaxListeners(n) or defaults to EventEmitter.defaultMaxListeners.

number

v1.0.0

Koa.getMaxListeners


inspect(): any

Defined in: @types/koa/index.d.ts:499

Return JSON representation. We only bother showing settings.

any

Koa.inspect


interactionDetails(req, res): Promise<Interaction>

Defined in: @types/oidc-provider/index.d.ts:1549

IncomingMessage | Http2ServerRequest

ServerResponse<IncomingMessage> | Http2ServerResponse<Http2ServerRequest>

Promise<Interaction>


interactionFinished(req, res, result, options?): Promise<void>

Defined in: @types/oidc-provider/index.d.ts:1542

IncomingMessage | Http2ServerRequest

ServerResponse<IncomingMessage> | Http2ServerResponse<Http2ServerRequest>

InteractionResults

boolean

Promise<void>


interactionResult(req, res, result, options?): Promise<string>

Defined in: @types/oidc-provider/index.d.ts:1535

IncomingMessage | Http2ServerRequest

ServerResponse<IncomingMessage> | Http2ServerResponse<Http2ServerRequest>

InteractionResults

boolean

Promise<string>


listen(port?, hostname?, backlog?, listeningListener?): Server

Defined in: @types/koa/index.d.ts:485

Shorthand for:

http.createServer(app.callback()).listen(…)

number

string

number

() => void

Server

Koa.listen

listen(port, hostname?, listeningListener?): Server

Defined in: @types/koa/index.d.ts:486

Shorthand for:

http.createServer(app.callback()).listen(…)

number

string

() => void

Server

Koa.listen

listen(port, backlog?, listeningListener?): Server

Defined in: @types/koa/index.d.ts:487

Shorthand for:

http.createServer(app.callback()).listen(…)

number

number

() => void

Server

Koa.listen

listen(port, listeningListener?): Server

Defined in: @types/koa/index.d.ts:488

Shorthand for:

http.createServer(app.callback()).listen(…)

number

() => void

Server

Koa.listen

listen(path, backlog?, listeningListener?): Server

Defined in: @types/koa/index.d.ts:489

Shorthand for:

http.createServer(app.callback()).listen(…)

string

number

() => void

Server

Koa.listen

listen(path, listeningListener?): Server

Defined in: @types/koa/index.d.ts:490

Shorthand for:

http.createServer(app.callback()).listen(…)

string

() => void

Server

Koa.listen

listen(options, listeningListener?): Server

Defined in: @types/koa/index.d.ts:491

Shorthand for:

http.createServer(app.callback()).listen(…)

ListenOptions

() => void

Server

Koa.listen

listen(handle, backlog?, listeningListener?): Server

Defined in: @types/koa/index.d.ts:492

Shorthand for:

http.createServer(app.callback()).listen(…)

any

number

() => void

Server

Koa.listen

listen(handle, listeningListener?): Server

Defined in: @types/koa/index.d.ts:493

Shorthand for:

http.createServer(app.callback()).listen(…)

any

() => void

Server

Koa.listen


listenerCount<K>(eventName, listener?): number

Defined in: @types/node/events.d.ts:913

Returns the number of listeners listening for the event named eventName. If listener is provided, it will return how many times the listener is found in the list of the listeners of the event.

K

string | symbol

The name of the event being listened for

Function

The event handler function

number

v3.2.0

Koa.listenerCount


listeners<K>(eventName): Function[]

Defined in: @types/node/events.d.ts:832

Returns a copy of the array of listeners for the event named eventName.

server.on('connection', (stream) => {
console.log('someone connected!');
});
console.log(util.inspect(server.listeners('connection')));
// Prints: [ [Function] ]

K

string | symbol

Function[]

v0.1.26

Koa.listeners


off<K>(eventName, listener): this

Defined in: @types/node/events.d.ts:792

Alias for emitter.removeListener().

K

string | symbol

(…args) => void

this

v10.0.0

Koa.off


on(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1686

Adds the listener function to the end of the listeners array for the event named eventName. No checks are made to see if the listener has already been added. Multiple calls passing the same combination of eventName and listener will result in the listener being added, and called, multiple times.

server.on('connection', (stream) => {
console.log('someone connected!');
});

Returns a reference to the EventEmitter, so that calls can be chained.

By default, event listeners are invoked in the order they are added. The emitter.prependListener() method can be used as an alternative to add the event listener to the beginning of the listeners array.

import { EventEmitter } from 'node:events';
const myEE = new EventEmitter();
myEE.on('foo', () => console.log('a'));
myEE.prependListener('foo', () => console.log('b'));
myEE.emit('foo');
// Prints:
// b
// a

"access_token.destroyed"

(accessToken) => void

The callback function

this

v0.1.101

Koa.on

on(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1687

"access_token.saved"

(accessToken) => void

this

Koa.on

on(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1688

"access_token.issued"

(accessToken) => void

this

Koa.on

on(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1689

"authorization_code.saved"

(authorizationCode) => void

this

Koa.on

on(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1690

"authorization_code.destroyed"

(authorizationCode) => void

this

Koa.on

on(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1691

"authorization_code.consumed"

(authorizationCode) => void

this

Koa.on

on(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1692

"device_code.saved"

(deviceCode) => void

this

Koa.on

on(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1693

"device_code.destroyed"

(deviceCode) => void

this

Koa.on

on(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1694

"device_code.consumed"

(deviceCode) => void

this

Koa.on

on(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1695

"backchannel_authentication_request.saved"

(deviceCode) => void

this

Koa.on

on(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1696

"backchannel_authentication_request.destroyed"

(deviceCode) => void

this

Koa.on

on(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1697

"backchannel_authentication_request.consumed"

(deviceCode) => void

this

Koa.on

on(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1698

"client_credentials.destroyed"

(clientCredentials) => void

this

Koa.on

on(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1699

"client_credentials.saved"

(clientCredentials) => void

this

Koa.on

on(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1700

"client_credentials.issued"

(clientCredentials) => void

this

Koa.on

on(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1701

"interaction.destroyed"

(interaction) => void

this

Koa.on

on(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1702

"interaction.saved"

(interaction) => void

this

Koa.on

on(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1703

"session.destroyed"

(session) => void

this

Koa.on

on(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1704

"session.saved"

(session) => void

this

Koa.on

on(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1705

"grant.destroyed"

(grant) => void

this

Koa.on

on(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1706

"grant.saved"

(grant) => void

this

Koa.on

on(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1707

"replay_detection.destroyed"

(replayDetection) => void

this

Koa.on

on(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1708

"replay_detection.saved"

(replayDetection) => void

this

Koa.on

on(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1709

"pushed_authorization_request.destroyed"

(pushedAuthorizationRequest) => void

this

Koa.on

on(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1713

"pushed_authorization_request.saved"

(pushedAuthorizationRequest) => void

this

Koa.on

on(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1717

"registration_access_token.destroyed"

(registrationAccessToken) => void

this

Koa.on

on(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1721

"registration_access_token.saved"

(registrationAccessToken) => void

this

Koa.on

on(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1725

"refresh_token.destroyed"

(refreshToken) => void

this

Koa.on

on(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1726

"refresh_token.saved"

(refreshToken) => void

this

Koa.on

on(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1727

"refresh_token.consumed"

(refreshToken) => void

this

Koa.on

on(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1728

"authorization.accepted"

(ctx) => void

this

Koa.on

on(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1729

"authorization.success"

(ctx) => void

this

Koa.on

on(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1730

"authorization.error"

(ctx, err) => void

this

Koa.on

on(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1731

"end_session.success"

(ctx) => void

this

Koa.on

on(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1732

"end_session.error"

(ctx, err) => void

this

Koa.on

on(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1733

"grant.success"

(ctx) => void

this

Koa.on

on(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1734

"interaction.ended"

(ctx) => void

this

Koa.on

on(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1735

"interaction.started"

(ctx, interaction) => void

this

Koa.on

on(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1736

"grant.error"

(ctx, err) => void

this

Koa.on

on(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1737

"grant.revoked"

(ctx, grantId) => void

this

Koa.on

on(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1738

"backchannel.success"

(ctx, client, accountId, sid) => void

this

Koa.on

on(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1742

"backchannel.error"

(ctx, err, client, accountId, sid) => void

this

Koa.on

on(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1746

"pushed_authorization_request.success"

(ctx) => void

this

Koa.on

on(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1747

"pushed_authorization_request.error"

(ctx, err) => void

this

Koa.on

on(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1751

"registration_update.success"

(ctx, client) => void

this

Koa.on

on(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1752

"registration_update.error"

(ctx, err) => void

this

Koa.on

on(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1756

"registration_delete.success"

(ctx, client) => void

this

Koa.on

on(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1757

"registration_delete.error"

(ctx, err) => void

this

Koa.on

on(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1761

"registration_create.success"

(ctx, client) => void

this

Koa.on

on(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1762

"registration_create.error"

(ctx, err) => void

this

Koa.on

on(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1766

"introspection.error"

(ctx, err) => void

this

Koa.on

on(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1767

"registration_read.error"

(ctx, err) => void

this

Koa.on

on(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1771

"jwks.error"

(ctx, err) => void

this

Koa.on

on(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1772

"discovery.error"

(ctx, err) => void

this

Koa.on

on(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1773

"userinfo.error"

(ctx, err) => void

this

Koa.on

on(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1774

"revocation.error"

(ctx, err) => void

this

Koa.on

on(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1775

"server_error"

(ctx, err) => void

this

Koa.on


once(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1777

Adds a one-time listener function for the event named eventName. The next time eventName is triggered, this listener is removed and then invoked.

server.once('connection', (stream) => {
console.log('Ah, we have our first user!');
});

Returns a reference to the EventEmitter, so that calls can be chained.

By default, event listeners are invoked in the order they are added. The emitter.prependOnceListener() method can be used as an alternative to add the event listener to the beginning of the listeners array.

import { EventEmitter } from 'node:events';
const myEE = new EventEmitter();
myEE.once('foo', () => console.log('a'));
myEE.prependOnceListener('foo', () => console.log('b'));
myEE.emit('foo');
// Prints:
// b
// a

"access_token.destroyed"

(accessToken) => void

The callback function

this

v0.3.0

Koa.once

once(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1778

"access_token.saved"

(accessToken) => void

this

Koa.once

once(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1779

"access_token.issued"

(accessToken) => void

this

Koa.once

once(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1780

"authorization_code.saved"

(authorizationCode) => void

this

Koa.once

once(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1781

"authorization_code.destroyed"

(authorizationCode) => void

this

Koa.once

once(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1782

"authorization_code.consumed"

(authorizationCode) => void

this

Koa.once

once(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1783

"device_code.saved"

(deviceCode) => void

this

Koa.once

once(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1784

"device_code.destroyed"

(deviceCode) => void

this

Koa.once

once(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1785

"device_code.consumed"

(deviceCode) => void

this

Koa.once

once(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1786

"backchannel_authentication_request.saved"

(deviceCode) => void

this

Koa.once

once(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1787

"backchannel_authentication_request.destroyed"

(deviceCode) => void

this

Koa.once

once(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1788

"backchannel_authentication_request.consumed"

(deviceCode) => void

this

Koa.once

once(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1789

"client_credentials.destroyed"

(clientCredentials) => void

this

Koa.once

once(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1790

"client_credentials.saved"

(clientCredentials) => void

this

Koa.once

once(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1791

"client_credentials.issued"

(clientCredentials) => void

this

Koa.once

once(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1792

"interaction.destroyed"

(interaction) => void

this

Koa.once

once(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1793

"interaction.saved"

(interaction) => void

this

Koa.once

once(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1794

"session.destroyed"

(session) => void

this

Koa.once

once(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1795

"session.saved"

(session) => void

this

Koa.once

once(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1796

"grant.destroyed"

(grant) => void

this

Koa.once

once(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1797

"grant.saved"

(grant) => void

this

Koa.once

once(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1798

"replay_detection.destroyed"

(replayDetection) => void

this

Koa.once

once(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1799

"replay_detection.saved"

(replayDetection) => void

this

Koa.once

once(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1800

"pushed_authorization_request.destroyed"

(pushedAuthorizationRequest) => void

this

Koa.once

once(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1804

"pushed_authorization_request.saved"

(pushedAuthorizationRequest) => void

this

Koa.once

once(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1808

"registration_access_token.destroyed"

(registrationAccessToken) => void

this

Koa.once

once(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1812

"registration_access_token.saved"

(registrationAccessToken) => void

this

Koa.once

once(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1816

"refresh_token.destroyed"

(refreshToken) => void

this

Koa.once

once(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1817

"refresh_token.saved"

(refreshToken) => void

this

Koa.once

once(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1818

"refresh_token.consumed"

(refreshToken) => void

this

Koa.once

once(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1819

"authorization.accepted"

(ctx) => void

this

Koa.once

once(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1820

"authorization.success"

(ctx) => void

this

Koa.once

once(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1821

"authorization.error"

(ctx, err) => void

this

Koa.once

once(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1825

"end_session.success"

(ctx) => void

this

Koa.once

once(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1826

"end_session.error"

(ctx, err) => void

this

Koa.once

once(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1827

"grant.success"

(ctx) => void

this

Koa.once

once(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1828

"interaction.ended"

(ctx) => void

this

Koa.once

once(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1829

"interaction.started"

(ctx, interaction) => void

this

Koa.once

once(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1830

"grant.error"

(ctx, err) => void

this

Koa.once

once(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1831

"grant.revoked"

(ctx, grantId) => void

this

Koa.once

once(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1832

"backchannel.success"

(ctx, client, accountId, sid) => void

this

Koa.once

once(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1836

"backchannel.error"

(ctx, err, client, accountId, sid) => void

this

Koa.once

once(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1840

"pushed_authorization_request.success"

(ctx) => void

this

Koa.once

once(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1841

"pushed_authorization_request.error"

(ctx, err) => void

this

Koa.once

once(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1845

"registration_update.success"

(ctx, client) => void

this

Koa.once

once(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1846

"registration_update.error"

(ctx, err) => void

this

Koa.once

once(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1850

"registration_delete.success"

(ctx, client) => void

this

Koa.once

once(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1851

"registration_delete.error"

(ctx, err) => void

this

Koa.once

once(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1855

"registration_create.success"

(ctx, client) => void

this

Koa.once

once(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1856

"registration_create.error"

(ctx, err) => void

this

Koa.once

once(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1860

"introspection.error"

(ctx, err) => void

this

Koa.once

once(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1864

"registration_read.error"

(ctx, err) => void

this

Koa.once

once(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1868

"jwks.error"

(ctx, err) => void

this

Koa.once

once(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1869

"discovery.error"

(ctx, err) => void

this

Koa.once

once(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1870

"userinfo.error"

(ctx, err) => void

this

Koa.once

once(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1871

"revocation.error"

(ctx, err) => void

this

Koa.once

once(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1872

"server_error"

(ctx, err) => void

this

Koa.once


onerror(err): void

Defined in: @types/koa/index.d.ts:537

Default error handler.

Error

void

private

Koa.onerror


prependListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1874

Adds the listener function to the beginning of the listeners array for the event named eventName. No checks are made to see if the listener has already been added. Multiple calls passing the same combination of eventName and listener will result in the listener being added, and called, multiple times.

server.prependListener('connection', (stream) => {
console.log('someone connected!');
});

Returns a reference to the EventEmitter, so that calls can be chained.

"access_token.destroyed"

(accessToken) => void

The callback function

this

v6.0.0

Koa.prependListener

prependListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1875

"access_token.saved"

(accessToken) => void

this

Koa.prependListener

prependListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1876

"access_token.issued"

(accessToken) => void

this

Koa.prependListener

prependListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1877

"authorization_code.saved"

(authorizationCode) => void

this

Koa.prependListener

prependListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1878

"authorization_code.destroyed"

(authorizationCode) => void

this

Koa.prependListener

prependListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1882

"authorization_code.consumed"

(authorizationCode) => void

this

Koa.prependListener

prependListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1886

"device_code.saved"

(deviceCode) => void

this

Koa.prependListener

prependListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1887

"device_code.destroyed"

(deviceCode) => void

this

Koa.prependListener

prependListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1888

"device_code.consumed"

(deviceCode) => void

this

Koa.prependListener

prependListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1889

"backchannel_authentication_request.saved"

(deviceCode) => void

this

Koa.prependListener

prependListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1893

"backchannel_authentication_request.destroyed"

(deviceCode) => void

this

Koa.prependListener

prependListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1897

"backchannel_authentication_request.consumed"

(deviceCode) => void

this

Koa.prependListener

prependListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1901

"client_credentials.destroyed"

(clientCredentials) => void

this

Koa.prependListener

prependListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1905

"client_credentials.saved"

(clientCredentials) => void

this

Koa.prependListener

prependListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1906

"client_credentials.issued"

(clientCredentials) => void

this

Koa.prependListener

prependListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1907

"interaction.destroyed"

(interaction) => void

this

Koa.prependListener

prependListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1908

"interaction.saved"

(interaction) => void

this

Koa.prependListener

prependListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1909

"session.destroyed"

(session) => void

this

Koa.prependListener

prependListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1910

"session.saved"

(session) => void

this

Koa.prependListener

prependListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1911

"grant.destroyed"

(grant) => void

this

Koa.prependListener

prependListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1912

"grant.saved"

(grant) => void

this

Koa.prependListener

prependListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1913

"replay_detection.destroyed"

(replayDetection) => void

this

Koa.prependListener

prependListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1914

"replay_detection.saved"

(replayDetection) => void

this

Koa.prependListener

prependListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1915

"pushed_authorization_request.destroyed"

(pushedAuthorizationRequest) => void

this

Koa.prependListener

prependListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1919

"pushed_authorization_request.saved"

(pushedAuthorizationRequest) => void

this

Koa.prependListener

prependListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1923

"registration_access_token.destroyed"

(registrationAccessToken) => void

this

Koa.prependListener

prependListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1927

"registration_access_token.saved"

(registrationAccessToken) => void

this

Koa.prependListener

prependListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1931

"refresh_token.destroyed"

(refreshToken) => void

this

Koa.prependListener

prependListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1932

"refresh_token.saved"

(refreshToken) => void

this

Koa.prependListener

prependListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1933

"refresh_token.consumed"

(refreshToken) => void

this

Koa.prependListener

prependListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1934

"authorization.accepted"

(ctx) => void

this

Koa.prependListener

prependListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1935

"authorization.success"

(ctx) => void

this

Koa.prependListener

prependListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1936

"authorization.error"

(ctx, err) => void

this

Koa.prependListener

prependListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1940

"end_session.success"

(ctx) => void

this

Koa.prependListener

prependListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1941

"end_session.error"

(ctx, err) => void

this

Koa.prependListener

prependListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1945

"grant.success"

(ctx) => void

this

Koa.prependListener

prependListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1946

"interaction.ended"

(ctx) => void

this

Koa.prependListener

prependListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1947

"interaction.started"

(ctx, interaction) => void

this

Koa.prependListener

prependListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1951

"grant.error"

(ctx, err) => void

this

Koa.prependListener

prependListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1955

"grant.revoked"

(ctx, grantId) => void

this

Koa.prependListener

prependListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1956

"backchannel.success"

(ctx, client, accountId, sid) => void

this

Koa.prependListener

prependListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1960

"backchannel.error"

(ctx, err, client, accountId, sid) => void

this

Koa.prependListener

prependListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1964

"pushed_authorization_request.success"

(ctx) => void

this

Koa.prependListener

prependListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1965

"pushed_authorization_request.error"

(ctx, err) => void

this

Koa.prependListener

prependListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1969

"registration_update.success"

(ctx, client) => void

this

Koa.prependListener

prependListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1973

"registration_update.error"

(ctx, err) => void

this

Koa.prependListener

prependListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1977

"registration_delete.success"

(ctx, client) => void

this

Koa.prependListener

prependListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1981

"registration_delete.error"

(ctx, err) => void

this

Koa.prependListener

prependListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1985

"registration_create.success"

(ctx, client) => void

this

Koa.prependListener

prependListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1989

"registration_create.error"

(ctx, err) => void

this

Koa.prependListener

prependListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1993

"introspection.error"

(ctx, err) => void

this

Koa.prependListener

prependListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:1997

"registration_read.error"

(ctx, err) => void

this

Koa.prependListener

prependListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:2001

"jwks.error"

(ctx, err) => void

this

Koa.prependListener

prependListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:2005

"discovery.error"

(ctx, err) => void

this

Koa.prependListener

prependListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:2009

"userinfo.error"

(ctx, err) => void

this

Koa.prependListener

prependListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:2013

"revocation.error"

(ctx, err) => void

this

Koa.prependListener

prependListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:2017

"server_error"

(ctx, err) => void

this

Koa.prependListener


prependOnceListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:2019

Adds a one-timelistener function for the event named eventName to the beginning of the listeners array. The next time eventName is triggered, this listener is removed, and then invoked.

server.prependOnceListener('connection', (stream) => {
console.log('Ah, we have our first user!');
});

Returns a reference to the EventEmitter, so that calls can be chained.

"access_token.destroyed"

(accessToken) => void

The callback function

this

v6.0.0

Koa.prependOnceListener

prependOnceListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:2020

"access_token.saved"

(accessToken) => void

this

Koa.prependOnceListener

prependOnceListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:2021

"access_token.issued"

(accessToken) => void

this

Koa.prependOnceListener

prependOnceListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:2022

"authorization_code.saved"

(authorizationCode) => void

this

Koa.prependOnceListener

prependOnceListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:2026

"authorization_code.destroyed"

(authorizationCode) => void

this

Koa.prependOnceListener

prependOnceListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:2030

"authorization_code.consumed"

(authorizationCode) => void

this

Koa.prependOnceListener

prependOnceListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:2034

"device_code.saved"

(deviceCode) => void

this

Koa.prependOnceListener

prependOnceListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:2035

"device_code.destroyed"

(deviceCode) => void

this

Koa.prependOnceListener

prependOnceListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:2036

"device_code.consumed"

(deviceCode) => void

this

Koa.prependOnceListener

prependOnceListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:2037

"backchannel_authentication_request.saved"

(deviceCode) => void

this

Koa.prependOnceListener

prependOnceListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:2041

"backchannel_authentication_request.destroyed"

(deviceCode) => void

this

Koa.prependOnceListener

prependOnceListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:2045

"backchannel_authentication_request.consumed"

(deviceCode) => void

this

Koa.prependOnceListener

prependOnceListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:2049

"client_credentials.destroyed"

(clientCredentials) => void

this

Koa.prependOnceListener

prependOnceListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:2053

"client_credentials.saved"

(clientCredentials) => void

this

Koa.prependOnceListener

prependOnceListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:2057

"client_credentials.issued"

(clientCredentials) => void

this

Koa.prependOnceListener

prependOnceListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:2061

"interaction.destroyed"

(interaction) => void

this

Koa.prependOnceListener

prependOnceListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:2062

"interaction.saved"

(interaction) => void

this

Koa.prependOnceListener

prependOnceListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:2063

"session.destroyed"

(session) => void

this

Koa.prependOnceListener

prependOnceListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:2064

"session.saved"

(session) => void

this

Koa.prependOnceListener

prependOnceListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:2065

"grant.destroyed"

(grant) => void

this

Koa.prependOnceListener

prependOnceListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:2066

"grant.saved"

(grant) => void

this

Koa.prependOnceListener

prependOnceListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:2067

"replay_detection.destroyed"

(replayDetection) => void

this

Koa.prependOnceListener

prependOnceListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:2071

"replay_detection.saved"

(replayDetection) => void

this

Koa.prependOnceListener

prependOnceListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:2072

"pushed_authorization_request.destroyed"

(pushedAuthorizationRequest) => void

this

Koa.prependOnceListener

prependOnceListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:2076

"pushed_authorization_request.saved"

(pushedAuthorizationRequest) => void

this

Koa.prependOnceListener

prependOnceListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:2080

"registration_access_token.destroyed"

(registrationAccessToken) => void

this

Koa.prependOnceListener

prependOnceListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:2084

"registration_access_token.saved"

(registrationAccessToken) => void

this

Koa.prependOnceListener

prependOnceListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:2088

"refresh_token.destroyed"

(refreshToken) => void

this

Koa.prependOnceListener

prependOnceListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:2089

"refresh_token.saved"

(refreshToken) => void

this

Koa.prependOnceListener

prependOnceListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:2090

"refresh_token.consumed"

(refreshToken) => void

this

Koa.prependOnceListener

prependOnceListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:2091

"authorization.accepted"

(ctx) => void

this

Koa.prependOnceListener

prependOnceListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:2092

"authorization.success"

(ctx) => void

this

Koa.prependOnceListener

prependOnceListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:2093

"authorization.error"

(ctx, err) => void

this

Koa.prependOnceListener

prependOnceListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:2097

"end_session.success"

(ctx) => void

this

Koa.prependOnceListener

prependOnceListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:2098

"end_session.error"

(ctx, err) => void

this

Koa.prependOnceListener

prependOnceListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:2102

"grant.success"

(ctx) => void

this

Koa.prependOnceListener

prependOnceListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:2103

"interaction.ended"

(ctx) => void

this

Koa.prependOnceListener

prependOnceListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:2104

"interaction.started"

(ctx, interaction) => void

this

Koa.prependOnceListener

prependOnceListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:2108

"grant.error"

(ctx, err) => void

this

Koa.prependOnceListener

prependOnceListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:2112

"grant.revoked"

(ctx, grantId) => void

this

Koa.prependOnceListener

prependOnceListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:2113

"backchannel.success"

(ctx, client, accountId, sid) => void

this

Koa.prependOnceListener

prependOnceListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:2117

"backchannel.error"

(ctx, err, client, accountId, sid) => void

this

Koa.prependOnceListener

prependOnceListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:2121

"pushed_authorization_request.success"

(ctx) => void

this

Koa.prependOnceListener

prependOnceListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:2125

"pushed_authorization_request.error"

(ctx, err) => void

this

Koa.prependOnceListener

prependOnceListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:2129

"registration_update.success"

(ctx, client) => void

this

Koa.prependOnceListener

prependOnceListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:2133

"registration_update.error"

(ctx, err) => void

this

Koa.prependOnceListener

prependOnceListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:2137

"registration_delete.success"

(ctx, client) => void

this

Koa.prependOnceListener

prependOnceListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:2141

"registration_delete.error"

(ctx, err) => void

this

Koa.prependOnceListener

prependOnceListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:2145

"registration_create.success"

(ctx, client) => void

this

Koa.prependOnceListener

prependOnceListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:2149

"registration_create.error"

(ctx, err) => void

this

Koa.prependOnceListener

prependOnceListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:2153

"introspection.error"

(ctx, err) => void

this

Koa.prependOnceListener

prependOnceListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:2157

"registration_read.error"

(ctx, err) => void

this

Koa.prependOnceListener

prependOnceListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:2161

"jwks.error"

(ctx, err) => void

this

Koa.prependOnceListener

prependOnceListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:2165

"discovery.error"

(ctx, err) => void

this

Koa.prependOnceListener

prependOnceListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:2169

"userinfo.error"

(ctx, err) => void

this

Koa.prependOnceListener

prependOnceListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:2173

"revocation.error"

(ctx, err) => void

this

Koa.prependOnceListener

prependOnceListener(event, listener): this

Defined in: @types/oidc-provider/index.d.ts:2177

"server_error"

(ctx, err) => void

this

Koa.prependOnceListener


rawListeners<K>(eventName): Function[]

Defined in: @types/node/events.d.ts:863

Returns a copy of the array of listeners for the event named eventName, including any wrappers (such as those created by .once()).

import { EventEmitter } from 'node:events';
const emitter = new EventEmitter();
emitter.once('log', () => console.log('log once'));
// Returns a new Array with a function `onceWrapper` which has a property
// `listener` which contains the original listener bound above
const listeners = emitter.rawListeners('log');
const logFnWrapper = listeners[0];
// Logs "log once" to the console and does not unbind the `once` event
logFnWrapper.listener();
// Logs "log once" to the console and removes the listener
logFnWrapper();
emitter.on('log', () => console.log('log persistently'));
// Will return a new Array with a single function bound by `.on()` above
const newListeners = emitter.rawListeners('log');
// Logs "log persistently" twice
newListeners[0]();
emitter.emit('log');

K

string | symbol

Function[]

v9.4.0

Koa.rawListeners


registerGrantType(name, handler, params?, duplicates?): void

Defined in: @types/oidc-provider/index.d.ts:1554

string

(ctx, next) => CanBePromise<void>

string | string[] | Set<string>

string | string[] | Set<string>

void


removeAllListeners(eventName?): this

Defined in: @types/node/events.d.ts:803

Removes all listeners, or those of the specified eventName.

It is bad practice to remove listeners added elsewhere in the code, particularly when the EventEmitter instance was created by some other component or module (e.g. sockets or file streams).

Returns a reference to the EventEmitter, so that calls can be chained.

string | symbol

this

v0.1.26

Koa.removeAllListeners


removeListener<K>(eventName, listener): this

Defined in: @types/node/events.d.ts:787

Removes the specified listener from the listener array for the event named eventName.

const callback = (stream) => {
console.log('someone connected!');
};
server.on('connection', callback);
// ...
server.removeListener('connection', callback);

removeListener() will remove, at most, one instance of a listener from the listener array. If any single listener has been added multiple times to the listener array for the specified eventName, then removeListener() must be called multiple times to remove each instance.

Once an event is emitted, all listeners attached to it at the time of emitting are called in order. This implies that any removeListener() or removeAllListeners() calls after emitting and before the last listener finishes execution will not remove them fromemit() in progress. Subsequent events behave as expected.

import { EventEmitter } from 'node:events';
class MyEmitter extends EventEmitter {}
const myEmitter = new MyEmitter();
const callbackA = () => {
console.log('A');
myEmitter.removeListener('event', callbackB);
};
const callbackB = () => {
console.log('B');
};
myEmitter.on('event', callbackA);
myEmitter.on('event', callbackB);
// callbackA removes listener callbackB but it will still be called.
// Internal listener array at time of emit [callbackA, callbackB]
myEmitter.emit('event');
// Prints:
// A
// B
// callbackB is now removed.
// Internal listener array [callbackA]
myEmitter.emit('event');
// Prints:
// A

Because listeners are managed using an internal array, calling this will change the position indices of any listener registered after the listener being removed. This will not impact the order in which listeners are called, but it means that any copies of the listener array as returned by the emitter.listeners() method will need to be recreated.

When a single function has been added as a handler multiple times for a single event (as in the example below), removeListener() will remove the most recently added instance. In the example the once('ping') listener is removed:

import { EventEmitter } from 'node:events';
const ee = new EventEmitter();
function pong() {
console.log('pong');
}
ee.on('ping', pong);
ee.once('ping', pong);
ee.removeListener('ping', pong);
ee.emit('ping');
ee.emit('ping');

Returns a reference to the EventEmitter, so that calls can be chained.

K

string | symbol

(…args) => void

this

v0.1.26

Koa.removeListener


setMaxListeners(n): this

Defined in: @types/node/events.d.ts:813

By default EventEmitters will print a warning if more than 10 listeners are added for a particular event. This is a useful default that helps finding memory leaks. The emitter.setMaxListeners() method allows the limit to be modified for this specific EventEmitter instance. The value can be set to Infinity (or 0) to indicate an unlimited number of listeners.

Returns a reference to the EventEmitter, so that calls can be chained.

number

this

v0.3.5

Koa.setMaxListeners


toJSON(): any

Defined in: @types/koa/index.d.ts:505

Return JSON representation. We only bother showing settings.

any

Koa.toJSON


use<NewStateT, NewContextT>(middleware): Application<DefaultState & NewStateT, DefaultContext & NewContextT>

Defined in: @types/koa/index.d.ts:512

Use the given middleware fn.

Old-style middleware will be converted.

NewStateT = { }

NewContextT = { }

Middleware<DefaultState & NewStateT, DefaultContext & NewContextT>

Application<DefaultState & NewStateT, DefaultContext & NewContextT>

Koa.use


static addAbortListener(signal, resource): Disposable

Defined in: @types/node/events.d.ts:403

Listens once to the abort event on the provided signal.

Listening to the abort event on abort signals is unsafe and may lead to resource leaks since another third party with the signal can call e.stopImmediatePropagation(). Unfortunately Node.js cannot change this since it would violate the web standard. Additionally, the original API makes it easy to forget to remove listeners.

This API allows safely using AbortSignals in Node.js APIs by solving these two issues by listening to the event such that stopImmediatePropagation does not prevent the listener from running.

Returns a disposable so that it may be unsubscribed from more easily.

import { addAbortListener } from 'node:events';
function example(signal) {
let disposable;
try {
signal.addEventListener('abort', (e) => e.stopImmediatePropagation());
disposable = addAbortListener(signal, (e) => {
// Do something when signal is aborted.
});
} finally {
disposable?.[Symbol.dispose]();
}
}

AbortSignal

(event) => void

Disposable

Disposable that removes the abort listener.

v20.5.0

Koa.addAbortListener


static getEventListeners(emitter, name): Function[]

Defined in: @types/node/events.d.ts:325

Returns a copy of the array of listeners for the event named eventName.

For EventEmitters this behaves exactly the same as calling .listeners on the emitter.

For EventTargets this is the only way to get the event listeners for the event target. This is useful for debugging and diagnostic purposes.

import { getEventListeners, EventEmitter } from 'node:events';
{
const ee = new EventEmitter();
const listener = () => console.log('Events are fun');
ee.on('foo', listener);
console.log(getEventListeners(ee, 'foo')); // [ [Function: listener] ]
}
{
const et = new EventTarget();
const listener = () => console.log('Events are fun');
et.addEventListener('foo', listener);
console.log(getEventListeners(et, 'foo')); // [ [Function: listener] ]
}

EventTarget | EventEmitter<DefaultEventMap>

string | symbol

Function[]

v15.2.0, v14.17.0

Koa.getEventListeners


static getMaxListeners(emitter): number

Defined in: @types/node/events.d.ts:354

Returns the currently set max amount of listeners.

For EventEmitters this behaves exactly the same as calling .getMaxListeners on the emitter.

For EventTargets this is the only way to get the max event listeners for the event target. If the number of event handlers on a single EventTarget exceeds the max set, the EventTarget will print a warning.

import { getMaxListeners, setMaxListeners, EventEmitter } from 'node:events';
{
const ee = new EventEmitter();
console.log(getMaxListeners(ee)); // 10
setMaxListeners(11, ee);
console.log(getMaxListeners(ee)); // 11
}
{
const et = new EventTarget();
console.log(getMaxListeners(et)); // 10
setMaxListeners(11, et);
console.log(getMaxListeners(et)); // 11
}

EventTarget | EventEmitter<DefaultEventMap>

number

v19.9.0

Koa.getMaxListeners


static listenerCount(emitter, eventName): number

Defined in: @types/node/events.d.ts:297

A class method that returns the number of listeners for the given eventName registered on the given emitter.

import { EventEmitter, listenerCount } from 'node:events';
const myEmitter = new EventEmitter();
myEmitter.on('event', () => {});
myEmitter.on('event', () => {});
console.log(listenerCount(myEmitter, 'event'));
// Prints: 2

EventEmitter

The emitter to query

string | symbol

The event name

number

v0.9.12

Koa.listenerCount


static on(emitter, eventName, options?): AsyncIterator<any[]>

Defined in: @types/node/events.d.ts:270

import { on, EventEmitter } from 'node:events';
import process from 'node:process';
const ee = new EventEmitter();
// Emit later on
process.nextTick(() => {
ee.emit('foo', 'bar');
ee.emit('foo', 42);
});
for await (const event of on(ee, 'foo')) {
// The execution of this inner block is synchronous and it
// processes one event at a time (even with await). Do not use
// if concurrent execution is required.
console.log(event); // prints ['bar'] [42]
}
// Unreachable here

Returns an AsyncIterator that iterates eventName events. It will throw if the EventEmitter emits 'error'. It removes all listeners when exiting the loop. The value returned by each iteration is an array composed of the emitted event arguments.

An AbortSignal can be used to cancel waiting on events:

import { on, EventEmitter } from 'node:events';
import process from 'node:process';
const ac = new AbortController();
(async () => {
const ee = new EventEmitter();
// Emit later on
process.nextTick(() => {
ee.emit('foo', 'bar');
ee.emit('foo', 42);
});
for await (const event of on(ee, 'foo', { signal: ac.signal })) {
// The execution of this inner block is synchronous and it
// processes one event at a time (even with await). Do not use
// if concurrent execution is required.
console.log(event); // prints ['bar'] [42]
}
// Unreachable here
})();
process.nextTick(() => ac.abort());

Use the close option to specify an array of event names that will end the iteration:

import { on, EventEmitter } from 'node:events';
import process from 'node:process';
const ee = new EventEmitter();
// Emit later on
process.nextTick(() => {
ee.emit('foo', 'bar');
ee.emit('foo', 42);
ee.emit('close');
});
for await (const event of on(ee, 'foo', { close: ['close'] })) {
console.log(event); // prints ['bar'] [42]
}
// the loop will exit after 'close' is emitted
console.log('done'); // prints 'done'

EventEmitter

string | symbol

StaticEventEmitterIteratorOptions

AsyncIterator<any[]>

An AsyncIterator that iterates eventName events emitted by the emitter

v13.6.0, v12.16.0

Koa.on

static on(emitter, eventName, options?): AsyncIterator<any[]>

Defined in: @types/node/events.d.ts:275

import { on, EventEmitter } from 'node:events';
import process from 'node:process';
const ee = new EventEmitter();
// Emit later on
process.nextTick(() => {
ee.emit('foo', 'bar');
ee.emit('foo', 42);
});
for await (const event of on(ee, 'foo')) {
// The execution of this inner block is synchronous and it
// processes one event at a time (even with await). Do not use
// if concurrent execution is required.
console.log(event); // prints ['bar'] [42]
}
// Unreachable here

Returns an AsyncIterator that iterates eventName events. It will throw if the EventEmitter emits 'error'. It removes all listeners when exiting the loop. The value returned by each iteration is an array composed of the emitted event arguments.

An AbortSignal can be used to cancel waiting on events:

import { on, EventEmitter } from 'node:events';
import process from 'node:process';
const ac = new AbortController();
(async () => {
const ee = new EventEmitter();
// Emit later on
process.nextTick(() => {
ee.emit('foo', 'bar');
ee.emit('foo', 42);
});
for await (const event of on(ee, 'foo', { signal: ac.signal })) {
// The execution of this inner block is synchronous and it
// processes one event at a time (even with await). Do not use
// if concurrent execution is required.
console.log(event); // prints ['bar'] [42]
}
// Unreachable here
})();
process.nextTick(() => ac.abort());

Use the close option to specify an array of event names that will end the iteration:

import { on, EventEmitter } from 'node:events';
import process from 'node:process';
const ee = new EventEmitter();
// Emit later on
process.nextTick(() => {
ee.emit('foo', 'bar');
ee.emit('foo', 42);
ee.emit('close');
});
for await (const event of on(ee, 'foo', { close: ['close'] })) {
console.log(event); // prints ['bar'] [42]
}
// the loop will exit after 'close' is emitted
console.log('done'); // prints 'done'

EventTarget

string

StaticEventEmitterIteratorOptions

AsyncIterator<any[]>

An AsyncIterator that iterates eventName events emitted by the emitter

v13.6.0, v12.16.0

Koa.on


static once(emitter, eventName, options?): Promise<any[]>

Defined in: @types/node/events.d.ts:184

Creates a Promise that is fulfilled when the EventEmitter emits the given event or that is rejected if the EventEmitter emits 'error' while waiting. The Promise will resolve with an array of all the arguments emitted to the given event.

This method is intentionally generic and works with the web platform EventTarget interface, which has no special'error' event semantics and does not listen to the 'error' event.

import { once, EventEmitter } from 'node:events';
import process from 'node:process';
const ee = new EventEmitter();
process.nextTick(() => {
ee.emit('myevent', 42);
});
const [value] = await once(ee, 'myevent');
console.log(value);
const err = new Error('kaboom');
process.nextTick(() => {
ee.emit('error', err);
});
try {
await once(ee, 'myevent');
} catch (err) {
console.error('error happened', err);
}

The special handling of the 'error' event is only used when events.once() is used to wait for another event. If events.once() is used to wait for the ‘error' event itself, then it is treated as any other kind of event without special handling:

import { EventEmitter, once } from 'node:events';
const ee = new EventEmitter();
once(ee, 'error')
.then(([err]) => console.log('ok', err.message))
.catch((err) => console.error('error', err.message));
ee.emit('error', new Error('boom'));
// Prints: ok boom

An AbortSignal can be used to cancel waiting for the event:

import { EventEmitter, once } from 'node:events';
const ee = new EventEmitter();
const ac = new AbortController();
async function foo(emitter, event, signal) {
try {
await once(emitter, event, { signal });
console.log('event emitted!');
} catch (error) {
if (error.name === 'AbortError') {
console.error('Waiting for the event was canceled!');
} else {
console.error('There was an error', error.message);
}
}
}
foo(ee, 'foo', ac.signal);
ac.abort(); // Abort waiting for the event
ee.emit('foo'); // Prints: Waiting for the event was canceled!

EventEmitter

string | symbol

StaticEventEmitterOptions

Promise<any[]>

v11.13.0, v10.16.0

Koa.once

static once(emitter, eventName, options?): Promise<any[]>

Defined in: @types/node/events.d.ts:189

Creates a Promise that is fulfilled when the EventEmitter emits the given event or that is rejected if the EventEmitter emits 'error' while waiting. The Promise will resolve with an array of all the arguments emitted to the given event.

This method is intentionally generic and works with the web platform EventTarget interface, which has no special'error' event semantics and does not listen to the 'error' event.

import { once, EventEmitter } from 'node:events';
import process from 'node:process';
const ee = new EventEmitter();
process.nextTick(() => {
ee.emit('myevent', 42);
});
const [value] = await once(ee, 'myevent');
console.log(value);
const err = new Error('kaboom');
process.nextTick(() => {
ee.emit('error', err);
});
try {
await once(ee, 'myevent');
} catch (err) {
console.error('error happened', err);
}

The special handling of the 'error' event is only used when events.once() is used to wait for another event. If events.once() is used to wait for the ‘error' event itself, then it is treated as any other kind of event without special handling:

import { EventEmitter, once } from 'node:events';
const ee = new EventEmitter();
once(ee, 'error')
.then(([err]) => console.log('ok', err.message))
.catch((err) => console.error('error', err.message));
ee.emit('error', new Error('boom'));
// Prints: ok boom

An AbortSignal can be used to cancel waiting for the event:

import { EventEmitter, once } from 'node:events';
const ee = new EventEmitter();
const ac = new AbortController();
async function foo(emitter, event, signal) {
try {
await once(emitter, event, { signal });
console.log('event emitted!');
} catch (error) {
if (error.name === 'AbortError') {
console.error('Waiting for the event was canceled!');
} else {
console.error('There was an error', error.message);
}
}
}
foo(ee, 'foo', ac.signal);
ac.abort(); // Abort waiting for the event
ee.emit('foo'); // Prints: Waiting for the event was canceled!

EventTarget

string

StaticEventEmitterOptions

Promise<any[]>

v11.13.0, v10.16.0

Koa.once


static setMaxListeners(n?, …eventTargets): void

Defined in: @types/node/events.d.ts:369

import { setMaxListeners, EventEmitter } from 'node:events';
const target = new EventTarget();
const emitter = new EventEmitter();
setMaxListeners(5, target, emitter);

number

A non-negative number. The maximum number of listeners per EventTarget event.

…(EventTarget | EventEmitter<DefaultEventMap>)[]

Zero or more {EventTarget} or {EventEmitter} instances. If none are specified, n is set as the default max for all newly created {EventTarget} and {EventEmitter} objects.

void

v15.4.0

Koa.setMaxListeners