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
| Parameter | Type |
|---|---|
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
| Parameter | Type |
|---|---|
query | AuthorizeQuery |
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
| Parameter | Type |
|---|---|
exchange | CodeExchange |
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
| Parameter | Type |
|---|---|
refreshToken | string |
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
| Parameter | Type |
|---|---|
token | string |
Returns
Promise<void>