Skip to content

Interface: AccountsOptions ​

Defined in: server/accounts.ts:26

How Accounts behaves. Only secret is required.

Properties ​

PropertyTypeDescriptionDefined in
secretstringSigns guest and join tokens. The same secret tokenAuth uses. At least 16 characters.server/accounts.ts:28
prefix?stringWhere the HTTP API is served. Default "/api/accounts".server/accounts.ts:30
cookie?stringThe 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?numberHow long a session lasts since it was last used, in milliseconds. Default 30 days.server/accounts.ts:41
guestTtlSeconds?numberHow long a guest token lasts, in seconds. A guest renews it, keeping their id, before then. Default 30 days.server/accounts.ts:43
joinTokenTtlSeconds?numberHow 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?numberThe largest value one data key may hold, in bytes of JSON. Default 64 KiB.server/accounts.ts:56
maxDataKeys?numberHow many data keys one player may have. Default 100.server/accounts.ts:58
passwordResetTtlSeconds?numberHow long a password reset token lasts, in seconds. Default one hour.server/accounts.ts:81

Methods ​

normalizeName()? ​

ts
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 ​

ParameterType
namestring

Returns ​

string | null


verifyImportedPassword()? ​

ts
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 ​

ParameterType
hashstring
passwordstring

Returns ​

boolean | Promise<boolean>


sendPasswordReset()? ​

ts
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 ​

ParameterType
resetPasswordReset
requestRequest

Returns ​

void | Promise<void>

MIT licence. Tickflare is an independent project and is not affiliated with Cloudflare.