@adonisjs/auth
Version:
Official authentication provider for Adonis framework
56 lines (55 loc) • 1.81 kB
TypeScript
/**
* We use CRC32 just to add a recognizable checksum to tokens. This helps
* secret scanning tools like https://docs.github.com/en/github/administering-a-repository/about-secret-scanning easily detect tokens generated by a given program.
*
* You can learn more about appending checksum to a hash here in this Github
* article. https://github.blog/2021-04-05-behind-githubs-new-authentication-token-formats/
*
* Code taken from:
* https://github.com/tsxper/crc32/blob/main/src/CRC32.ts
*/
/**
* CRC32 implementation for adding recognizable checksums to tokens.
* This helps secret scanning tools easily detect tokens generated by AdonisJS.
*
* @example
* const crc = new CRC32()
* const checksum = crc.calculate('my-secret-token')
* console.log('Checksum:', checksum)
*/
export declare class CRC32 {
#private;
/**
* Calculate CRC32 checksum for a string input
*
* @param input - The string to calculate checksum for
*
* @example
* const crc = new CRC32()
* const checksum = crc.calculate('hello-world')
* console.log('CRC32:', checksum)
*/
calculate(input: string): number;
/**
* Calculate CRC32 checksum for a string
*
* @param input - The string to process
*
* @example
* const crc = new CRC32()
* const result = crc.forString('test-string')
*/
forString(input: string): number;
/**
* Calculate CRC32 checksum for byte array
*
* @param bytes - The byte array to process
* @param accumulator - Optional accumulator for chained calculations
*
* @example
* const crc = new CRC32()
* const bytes = new TextEncoder().encode('hello')
* const result = crc.forBytes(bytes)
*/
forBytes(bytes: Uint8Array, accumulator?: number): number;
}