Skip to Content
This project is in active development. Features and behaviors may change without notice.
DocumentationAPI ReferenceMethodsgenerateEncryptedToken

generateEncryptedToken

Type: generateEncryptedToken(content?: string): Promise<APIResult<string>>

generateEncryptedToken() is an asynchronous method that generates an encrypted token string by adding an HMAC to the specified Scratch username and then encrypting it using AES-GCM.

TypeScript
const = await .().("exampleUser");

Parameters

OptionTypeDescription
contentstringScratch username to encrypt

Return Value

  • Promise<APIResult<string>> — On success, returns an object containing the encrypted session ID (token)

Example Usage

TypeScript
const = await .().("KiryuToa"); if (.) { .("Encrypted token:", .); } else { .("Error:", .); }

Notes

  • The token can be decrypted and verified for tampering using extractUserWithVerify().
  • This token is intended to be stored in localStorage or cookies on the client side for later session validation.
Last updated on