{"record":{"id":"17e9bbe6533033b4","repo":"ruvnet/ruflo","slug":"invalid-length","errorCode":"INVALID_LENGTH","errorMessage":"Token length must be at least 16 bytes","messagePattern":"Token length must be at least 16 bytes","errorType":"exception","errorClass":"TokenGeneratorError","httpStatus":null,"severity":"error","filePath":"v3/@claude-flow/security/src/token-generator.ts","lineNumber":109,"sourceCode":" * const signed = generator.generateSignedToken({ userId: '123' });\n *\n * // Verify signed token\n * const isValid = generator.verifySignedToken(signed.combined);\n * ```\n */\nexport class TokenGenerator {\n  private readonly config: Required<TokenConfig>;\n\n  constructor(config: TokenConfig = {}) {\n    this.config = {\n      defaultLength: config.defaultLength ?? 32,\n      encoding: config.encoding ?? 'base64url',\n      hmacSecret: config.hmacSecret ?? '',\n      defaultExpiration: config.defaultExpiration ?? 3600,\n    };\n\n    if (this.config.defaultLength < 16) {\n      throw new TokenGeneratorError(\n        'Token length must be at least 16 bytes',\n        'INVALID_LENGTH'\n      );\n    }\n  }\n\n  /**\n   * Generates a random token.\n   *\n   * @param length - Token length in bytes\n   * @returns Random token string\n   */\n  generate(length?: number): string {\n    const len = length ?? this.config.defaultLength;\n    const buffer = randomBytes(len);\n    return this.encode(buffer);\n  }\n","sourceCodeStart":91,"sourceCodeEnd":127,"githubUrl":"https://github.com/ruvnet/ruflo/blob/fa13ee4ad60ac2090b1480656eb233521790d640/v3/@claude-flow/security/src/token-generator.ts#L91-L127","documentation":"TokenGenerator constructor guard: the effective defaultLength (config value or the 32-byte default) is below 16 bytes. Tokens shorter than 16 bytes of entropy are brute-forceable, so the generator refuses to construct rather than issue weak tokens.","triggerScenarios":"Thrown at v3/@claude-flow/security/src/token-generator.ts:109 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Generate the token with at least 16 bytes of entropy (e.g. randomBytes(32)).","Fix configuration that supplies a shorter token length."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"fa13ee4ad60ac2090b1480656eb233521790d640","analyzedAt":"2026-08-18T21:34:22.708Z","contentChangedAt":"2026-08-18T21:34:22.708Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}