Interface: AccountsOptions
Defined in: server/accounts.ts:26
How Accounts behaves. Only secret is required.
Properties
| Property | Type | Description | Defined in |
|---|---|---|---|
secret | string | Signs guest and join tokens. The same secret tokenAuth uses. At least 16 characters. | server/accounts.ts:28 |
prefix? | string | Where the HTTP API is served. Default "/api/accounts". | server/accounts.ts:30 |
cookie? | string | The session cookie's name. Default "tf_session". | server/accounts.ts:32 |
sameSite? | "Lax" | "Strict" | The session cookie's SameSite. "Lax" (the default) keeps players signed in when they follow a link to your game; "Strict" does not send the cookie on that first page load. A cookie set for an allowed origin of its own is "None" either way, or it could not be used there. | server/accounts.ts:39 |
sessionTtlMs? | number | How long a session lasts since it was last used, in milliseconds. Default 30 days. | server/accounts.ts:41 |
guestTtlSeconds? | number | How long a guest token lasts, in seconds. A guest renews it, keeping their id, before then. Default 30 days. | server/accounts.ts:43 |
joinTokenTtlSeconds? | number | How long a join token from /token lasts, in seconds. Default ten minutes. | server/accounts.ts:45 |
allowedOrigins? | string[] | Browser origins, besides the API's own, that may make signed-in requests with the session cookie: where your game's pages are served from if that is another origin. Anything else is refused, which is what stops another site from acting as a signed-in player. | server/accounts.ts:52 |
data? | Record<string, DataPolicy> | Policies per data key. Keys not listed are private and server-written. | server/accounts.ts:54 |
maxDataBytes? | number | The largest value one data key may hold, in bytes of JSON. Default 64 KiB. | server/accounts.ts:56 |
maxDataKeys? | number | How many data keys one player may have. Default 100. | server/accounts.ts:58 |
passwordResetTtlSeconds? | number | How long a password reset token lasts, in seconds. Default one hour. | server/accounts.ts:81 |
Methods
normalizeName()?
normalizeName?(name): string | null;Defined in: server/accounts.ts:65
Your own rules for account names, in place of the default (3 to 24 letters, digits, spaces, dots, dashes and underscores). Return the name as it should be stored, or null to refuse it. Uniqueness is checked after, ignoring case, spaces, dots, dashes and underscores.
Parameters
| Parameter | Type |
|---|---|
name | string |
Returns
string | null
verifyImportedPassword()?
verifyImportedPassword?(hash, password): boolean | Promise<boolean>;Defined in: server/accounts.ts:71
Checks a password against a hash this module did not make, so accounts imported from another service keep working. On success the password is hashed again the usual way. Return false for hashes you do not recognise.
Parameters
| Parameter | Type |
|---|---|
hash | string |
password | string |
Returns
boolean | Promise<boolean>
sendPasswordReset()?
sendPasswordReset?(reset, request): void | Promise<void>;Defined in: server/accounts.ts:79
Sends a player the link to set a new password: Tickflare makes the token, and sending the email is yours to do, with whichever mail service you use. Setting this turns POST /forgot on. Put reset.token in a link to a page of yours that asks for a new password and sends both to POST /reset.
Parameters
| Parameter | Type |
|---|---|
reset | PasswordReset |
request | Request |
Returns
void | Promise<void>