node-jwks-rsa 项目教程
1. 项目的目录结构及介绍
node-jwks-rsa/
├── __tests__/
│ └── jwksRsa.ts
├── examples/
│ └── basic.js
├── lib/
│ ├── cache.js
│ ├── errors.js
│ ├── index.js
│ ├── JwksClient.js
│ ├── rateLimit.js
│ └── utils.js
├── .eslintrc.js
├── .gitignore
├── .npmignore
├── .travis.yml
├── LICENSE
├── package.json
├── README.md
└── tsconfig.json
__tests__/
: 包含项目的测试文件。examples/
: 包含项目的基本使用示例。lib/
: 包含项目的主要逻辑文件,如缓存、错误处理、客户端等。.eslintrc.js
: ESLint 配置文件。.gitignore
: Git 忽略文件配置。.npmignore
: npm 忽略文件配置。.travis.yml
: Travis CI 配置文件。LICENSE
: 项目许可证。package.json
: 项目依赖和脚本配置。README.md
: 项目说明文档。tsconfig.json
: TypeScript 配置文件。
2. 项目的启动文件介绍
项目的启动文件主要是 lib/index.js
,这是项目的入口文件。它导出了 JwksClient
类,用于从 JWKS 端点获取 RSA 公钥。
// lib/index.js
module.exports = require('./JwksClient');
3. 项目的配置文件介绍
项目的配置文件主要是 package.json
,它包含了项目的依赖、脚本、版本等信息。
{
"name": "jwks-rsa",
"version": "2.0.1",
"description": "Library to retrieve RSA signing keys from a JWKS (JSON Web Key Set) endpoint.",
"main": "lib/index.js",
"scripts": {
"test": "mocha --recursive __tests__",
"lint": "eslint .",
"build": "tsc"
},
"dependencies": {
"jsonwebtoken": "^8.5.1",
"node-fetch": "^2.6.1"
},
"devDependencies": {
"@types/chai": "^4.2.11",
"@types/mocha": "^7.0.2",
"@types/node": "^13.13.5",
"chai": "^4.2.0",
"eslint": "^6.8.0",
"mocha": "^7.1.2",
"typescript": "^3.8.3"
},
"keywords": [
"jwks",
"rsa",
"auth0",
"jwt",
"jsonwebtoken"
],
"author": "Auth0",
"license": "MIT",
"repository": {
"type": "git",
"url": "git+https://github.com/auth0/node-jwks-rsa.git"
},
"bugs": {
"url": "https://github.com/auth0/node-jwks-rsa/issues"
},
"homepage": "https://github.com/auth0/node-jwks-rsa#readme"
}
name
: 项目名称。version
: 项目版本。description
: 项目描述。main
: 项目入口文件。scripts
: 项目脚本,如测试、lint、构建等。dependencies
: 项目运行时依赖。devDependencies
: 项目开发时依赖。keywords
: 项目关键词。author
: 项目作者。license
: 项目许可证。repository
: 项目仓库地址。bugs
: 项目问题追踪地址。homepage
: 项目主页地址。