Skip to content

Conversation

@mairas
Copy link
Contributor

@mairas mairas commented Jan 15, 2026

This PR supercedes the closed PR #2205.

Convert the token security module from JavaScript to TypeScript with full type annotations:

  • Add TypeScript interfaces for internal data structures (SKRequest, Principal, JWTPayload, LoginResponse, etc.)
  • Reuse existing types from security.ts and @signalk/server-api
  • Convert imports from require to ES module syntax
  • Add type annotations to all functions and parameters
  • Install @types/jsonwebtoken, @types/bcryptjs, @types/cookie-parser
  • Maintain CommonJS module.exports for backward compatibility

Bug fixes discovered during conversion:

  • Fix setPassword: was using array index with string (users[username]) instead of .find() - would have crashed on any password change
  • Fix requestedPermissions: now correctly stores as string per Device interface (was storing boolean, violating type contract)

Convert the token security module from JavaScript to TypeScript with
full type annotations:

- Add TypeScript interfaces for internal data structures (SKRequest,
  Principal, JWTPayload, LoginResponse, etc.)
- Reuse existing types from security.ts and @signalk/server-api
- Convert imports from require to ES module syntax
- Add type annotations to all functions and parameters
- Install @types/jsonwebtoken, @types/bcryptjs, @types/cookie-parser
- Maintain CommonJS module.exports for backward compatibility

Bug fixes discovered during conversion:
- Fix setPassword: was using array index with string (users[username])
  instead of .find() - would have crashed on any password change
- Fix requestedPermissions: now correctly stores as string per Device
  interface (was storing boolean, violating type contract)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant