sdk/lib/generators
Functions
'Read the “', Functions, '” section'generateRandomIDNumber()
'Read the “', generateRandomIDNumber(), '” section'function generateRandomIDNumber(length: number): number
Defined in: studiocms/packages/studiocms/src/sdk/lib/generators.ts:9
Generates a random ID number with the specified length.
Parameters
'Read the “', Parameters, '” section'number
The length of the random ID number to generate.
number
A random ID number with the specified length.
generateRandomPassword()
'Read the “', generateRandomPassword(), '” section'function generateRandomPassword(length: number): string
Defined in: studiocms/packages/studiocms/src/sdk/lib/generators.ts:40
Generates a random password of the specified length.
Parameters
'Read the “', Parameters, '” section'number
The length of the password to generate.
string
A randomly generated password string containing uppercase letters, lowercase letters, and digits.
generateToken()
'Read the “', generateToken(), '” section'function generateToken(userId: string): string
Defined in: studiocms/packages/studiocms/src/sdk/lib/generators.ts:19
Generates a JSON Web Token (JWT) for a given user ID.
Parameters
'Read the “', Parameters, '” section'string
The unique identifier of the user for whom the token is being generated.
string
A signed JWT string that expires in 3 hours.
testToken()
'Read the “', testToken(), '” section'function testToken(token: string): any
Defined in: studiocms/packages/studiocms/src/sdk/lib/generators.ts:30
Verifies the provided JWT token using the CMS encryption key.
Parameters
'Read the “', Parameters, '” section'string
The JWT token to be verified.
any
The decoded token if verification is successful.
Will throw an error if the token is invalid or verification fails.