krapio
Library referenceClasses

KrunkerOAuth

Login with Krunker: OAuth 2.0 authorization code flow with PKCE (S256), refresh token rotation and revocation. nothing is stored here, the verifier, the state and the tokens are yours to keep; the token calls are sent once and never retried, since a code and a refresh token are both spent by the first attempt

Constructors

Constructor

new KrunkerOAuth(options?): KrunkerOAuth;

Parameters

ParameterType
options?Partial<OAuthOptions>

Returns

KrunkerOAuth

Accessors

configured

Get Signature

get configured(): boolean;

false without a client id, every call but discovery throws KrunkerConfigError then

Returns

boolean


isPublic

Get Signature

get isPublic(): boolean;

true when no secret was given: a public client, read scopes only, authenticated by PKCE alone

Returns

boolean

Methods

authorizeUrl()

authorizeUrl(query): string;

the consent page url to redirect the player to; nothing is sent

Parameters

ParameterType
queryAuthorizeQuery

Returns

string


discovery()

discovery(): Promise<OAuthDiscovery>;

GET /.well-known/oauth-authorization-server, the endpoints and scopes as the server lists them (RFC 8414)

Returns

Promise<OAuthDiscovery>


exchangeCode()

exchangeCode(exchange): Promise<OAuthTokens>;

POST /oauth/token with grant_type=authorization_code; the code is good for 60 seconds and one attempt, failed or not

Parameters

ParameterType
exchangeCodeExchange

Returns

Promise<OAuthTokens>


refresh()

refresh(refreshToken): Promise<OAuthTokens>;

POST /oauth/token with grant_type=refresh_token. the reply carries a new refresh token and the old one is spent: store the new one right away and never refresh the same player's tokens concurrently, a second use of a refresh token revokes the whole sign-in

Parameters

ParameterType
refreshTokenstring

Returns

Promise<OAuthTokens>


revoke()

revoke(token): Promise<void>;

POST /oauth/revoke (RFC 7009): a refresh token takes its whole chain with it, an access token only itself. answers 200 for any token, valid or not; the app stays connected for the player

Parameters

ParameterType
tokenstring

Returns

Promise<void>

On this page