スキル frontend-api-client-with-jwt
📦

frontend-api-client-with-jwt

v1.0.0 中リスク

Next.jsでJWT処理を行うAPIクライアントを構築する

APIクライアントでJWT認証を管理するのは複雑で、エラーが起きやすいです。このスキルは、Next.jsアプリケーションで自動トークン更新、エラーハンドリング、一貫したレスポンス解析を備えた安全で中央集約型のAPI通信を実装するためのフレームワークを提供します。

対応: Claude Codex Code(CC)
📊 72 十分
1

スキルの ZIP をダウンロード

2

Claudeでアップロード

設定 → 機能 → スキル → スキルをアップロード に移動

3

オンにして使い始める

エージェントが読めるリソース

AI エージェント、クローラー、スクリプトがページ全体ではなく整理されたコンテキストを必要とする場合は、これらのリンクを使ってください。

テストする

「frontend-api-client-with-jwt」を使用しています。 Create an API client that handles JWT authentication

期待される結果:

  • ベースURLとタイムアウト設定を備えた中央集約型APIクライアントの構成
  • Bearerトークン形式でのAuthorizationヘッダー付与
  • 401レスポンスでトリガーされるトークン更新メカニズム
  • ユーザーフィードバックを伴う認証失敗時のエラーハンドリング
  • ログ記録とヘッダー注入のためのリクエストインターセプター

「frontend-api-client-with-jwt」を使用しています。 How do I handle token expiration in my Next.js app

期待される結果:

  • リクエスト前にトークンの有効期限を検証する
  • 期限切れ前にトークンを先回りして更新する
  • 更新失敗時はログインへリダイレクトする
  • 更新後のトークンを安全に保存する
  • 複数の同時リクエストにまたがる更新を調整する

「frontend-api-client-with-jwt」を使用しています。 What security considerations exist for JWT in frontend

期待される結果:

  • すべてのAPI通信でHTTPSを使用する
  • XSS攻撃を防ぐためにトークンを安全に保存する
  • 適切なCORS処理を実装する
  • エラーメッセージに機密データを露出させない
  • 処理前にレスポンスを検証する

セキュリティ監査

中リスク
v6 • 6/28/2026

The static findings are documentation terms in SKILL.md, not executable code, command execution, scanning, or exfiltration behavior. One semantic concern remains: the skill lists localStorage as a JWT storage option without enough warning about XSS exposure, so publication should include a security warning.

1
スキャンされたファイル
171
解析済み行数
3
Review items
0
False positives ignored

Confirmed security concerns (3)

Security-Sensitive Token Storage Guidance
Static verdict: TRUE POSITIVE as a guidance risk, not as executable malware. The skill lists browser storage options for JWT tokens, including localStorage, which can expose bearer tokens to XSS if used without strong safeguards.
The line explicitly names token storage mechanisms in JWT guidance. The file is prose rather than code, so the risk is insecure implementation advice rather than direct credential access.
False Positive: JWT and HTTP Status Terminology
Static verdict: FALSE POSITIVE. The weak cryptographic algorithm detections point to a JWT description and an HTTP 200-299 status range, with no cryptographic API, algorithm selection, or hashing implementation present.
Both locations are plain documentation text. I found no code path, crypto function, or recommendation to use a weak algorithm.
False Positive: Reconnaissance Terms in API Guidance
Static verdict: FALSE POSITIVE. The system and network reconnaissance detections are ordinary API-client documentation about valid tokens, HTTP 401 handling, context access, error messages, refresh performance, and token tests.
The referenced lines contain no shell commands, port scanning, host discovery, probing loops, or data collection behavior. They are conceptual guidance for API request handling and tests.
監査者: codex 監査履歴を表示 →

品質スコア

55
アーキテクチャ
100
保守性
87
コンテンツ
70
コミュニティ
56
セキュリティ
83
仕様準拠

作成できるもの

Next.js APIクライアントのアーキテクチャ

安全なJWTトークン処理と自動更新を備えたNext.jsアプリケーション向けの中央集約型APIクライアントを設計する。

認証フローの統合

クライアントおよびサーバーコンポーネント全体でトークン更新を伴うシームレスな認証フローを実装する。

React HookのAPIパターン

JWTトークンとエラーを一貫して処理するAPI通信向けのカスタムフックを構築する。

これらのプロンプトを試す

基本的なAPIクライアント設定
Create an API client in Next.js that automatically attaches JWT tokens to requests and handles token refresh on 401 errors.
トークン更新の実装
Implement automatic token refresh in a Next.js application before JWT expiration to prevent request failures.
エラーレスポンスの処理
Build error response parsing for an API client that identifies 401 and 403 errors and redirects users appropriately.
リクエストインターセプター
Create request interceptors for a Next.js API client that add authorization headers and log outgoing requests.

ベストプラクティス

  • JWTトークンを安全に保管し、APIリクエスト前に検証して不要な呼び出しを防ぐ
  • 401エラー後に反応的に行うのではなく、有効期限前に先回りしてトークン更新を実装する
  • 送信中のトークンを保護するため、すべてのAPI通信にHTTPSを使用する

回避

  • XSS保護なしにlocalStorageへJWTトークンを保存すると、スクリプト注入攻撃でトークンが露出する
  • エラーハンドリングなしでAPI呼び出しを行うとサイレント失敗が発生し、ユーザー体験が悪化する
  • 調整なしにトークン更新を実装すると、同時リクエストで競合状態が発生する

よくある質問

このスキルはNext.js App RouterとPages Routerに互換性がありますか?
はい、概念はNext.js App RouterとPages Routerの両方に適用できます。実装はコンテキストに応じて異なります。
同時にサポートされるAPIリクエストの最大数は?
固定の上限はありません。このフレームワークはブロッキングせずにリクエスト間のトークン更新を調整します。
既存の認証プロバイダーとはどのように統合されますか?
このスキルは任意のJWTベース認証向けのパターンを提供します。既存のトークン保存と更新エンドポイントに統合してください。
この実装ではトークンは安全に保存されますか?
このスキルは安全なパターンを説明します。実装はcookiesやsecure storageなどの保存方法に依存します。
トークン更新が繰り返し失敗する場合はどうすべきですか?
更新に失敗したらログインへリダイレクトします。保存済みトークンを削除し、明確なエラーメッセージを提供してください。
Axiosインターセプターを使う場合と比べてどう違いますか?
このスキルは類似のインターセプターパターンを提供します。実装はfetch、Axios、または任意のHTTPクライアントライブラリで行えます。

開発者情報

ファイル構成

📄 SKILL.md