# timjam/passport-fast-jwt architecture

> Architecture diagram of the GitHub repository timjam/passport-fast-jwt, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/timjam/passport-fast-jwt
- Repository: https://github.com/timjam/passport-fast-jwt
- Video tour (about a minute): https://gitdiagram.com/timjam/passport-fast-jwt/video

## Overview

Passport-Fast-JWT is a small Passport strategy adapter: it extracts a request token, verifies it with fast-jwt, then delegates application-specific identity resolution to a callback that reports success, failure, or error through Passport. The extractor options and callback behavior are documented in the README; source confirms the strategy’s dispatch and helper calls. Application lookup is consumer-owned, not implemented in this repository.

Main entry points: [`src/strategy.ts`](https://github.com/timjam/passport-fast-jwt/blob/main/src/strategy.ts) (JwtStrategy), [`src/extractors.ts`](https://github.com/timjam/passport-fast-jwt/blob/main/src/extractors.ts) (Extractors), [`src/helpers/parseAuthHeader.ts`](https://github.com/timjam/passport-fast-jwt/blob/main/src/helpers/parseAuthHeader.ts) (Auth parser), [`src/helpers/isDefined.ts`](https://github.com/timjam/passport-fast-jwt/blob/main/src/helpers/isDefined.ts) (Defined filter)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_strategy["JWT strategy"]
  node_strategy_impl["JwtStrategy<br/>[strategy.ts]"]
end

subgraph group_extraction["Token extraction"]
  node_extractors["Extractors<br/>[extractors.ts]"]
  node_auth_parse["Auth parser<br/>[parseAuthHeader.ts]"]
  node_defined["Defined filter<br/>[isDefined.ts]"]
end

subgraph group_public["Public API"]
  node_index["Exports<br/>[index.ts]"]
end

node_consumer(("Passport application"))
node_fastjwt["fast-jwt"]
node_app_callback["Identity callback"]
node_passport["Passport"]
node_request(("HTTP request"))

node_consumer -->|"imports"| node_index
node_consumer -->|"configures"| node_strategy_impl
node_consumer -->|"selects extractor"| node_extractors
node_request -->|"authenticates"| node_strategy_impl
node_strategy_impl -->|"extracts token"| node_extractors
node_extractors -->|"parses scheme"| node_auth_parse
node_extractors -->|"filters tokens"| node_defined
node_strategy_impl -->|"creates verifier / verifies token"| node_fastjwt
node_strategy_impl -->|"passes verified sections"| node_app_callback
node_app_callback -->|"reports outcome"| node_passport
node_strategy_impl -->|"dispatches success, fail, error"| node_passport

click node_index "https://github.com/timjam/passport-fast-jwt/blob/main/src/index.ts"
click node_strategy_impl "https://github.com/timjam/passport-fast-jwt/blob/main/src/strategy.ts"
click node_extractors "https://github.com/timjam/passport-fast-jwt/blob/main/src/extractors.ts"
click node_auth_parse "https://github.com/timjam/passport-fast-jwt/blob/main/src/helpers/parseAuthHeader.ts"
click node_defined "https://github.com/timjam/passport-fast-jwt/blob/main/src/helpers/isDefined.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_strategy_impl toneBlue
class node_extractors,node_auth_parse,node_defined toneAmber
class node_index,node_request toneMint
class node_consumer,node_fastjwt,node_app_callback,node_passport toneIndigo
```

## Components

### JWT strategy

- [JwtStrategy](https://github.com/timjam/passport-fast-jwt/blob/main/src/strategy.ts): `src/strategy.ts`

### Token extraction

- [Extractors](https://github.com/timjam/passport-fast-jwt/blob/main/src/extractors.ts): `src/extractors.ts`
- [Auth parser](https://github.com/timjam/passport-fast-jwt/blob/main/src/helpers/parseAuthHeader.ts): `src/helpers/parseAuthHeader.ts`
- [Defined filter](https://github.com/timjam/passport-fast-jwt/blob/main/src/helpers/isDefined.ts): `src/helpers/isDefined.ts`

### Public API

- [Exports](https://github.com/timjam/passport-fast-jwt/blob/main/src/index.ts): `src/index.ts`

### Other components

- **Passport application**
- **fast-jwt**
- **Identity callback**
- **Passport**
- **HTTP request**

## Connections

- Passport application → Exports: imports
- Passport application → JwtStrategy: configures
- Passport application → Extractors: selects extractor
- HTTP request → JwtStrategy: authenticates
- JwtStrategy → Extractors: extracts token
- Extractors → Auth parser: parses scheme
- Extractors → Defined filter: filters tokens
- JwtStrategy → fast-jwt: creates verifier / verifies token
- JwtStrategy → Identity callback: passes verified sections
- Identity callback → Passport: reports outcome
- JwtStrategy → Passport: dispatches success, fail, error
