Open fengmk2 opened 2 years ago
实现 login with web
npm login
npm login --registry=https://registry.npmmirror.com --verbose ∞
npm verb cli /.nvs/node/18.12.0/arm64/bin/node /.npm-global/bin/npm
npm info using npm@9.0.1
npm info using node@v18.12.0
npm verb title npm login
npm verb argv "login" "--registry" "https://registry.npmmirror.com" "--loglevel" "verbose"
npm verb logfile logs-max:10 dir:/.npm/_logs/2022-10-28T01_32_03_071Z-
npm verb logfile /.npm/_logs/2022-10-28T01_32_03_071Z-debug-0.log
npm notice Log in on https://registry.npmmirror.com/
npm verb web login before first POST
npm http fetch POST 404 https://registry.npmmirror.com/-/v1/login 169ms
npm verb stack WebLoginNotSupported: Web login not supported
npm verb stack at /.npm-global/lib/node_modules/npm/node_modules/npm-profile/lib/index.js:96:13
npm verb stack at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
npm verb stack at async Object.login (//.npm-global/lib/node_modules/npm/lib/utils/auth.js:47:11)
npm verb stack at async Login.exec (/.npm-global/lib/node_modules/npm/lib/commands/login.js:35:35)
npm verb stack at async module.exports (/.npm-global/lib/node_modules/npm/lib/cli.js:133:5)
npm verb statusCode 404
npm verb cwd /git/github.com/cnpm/cnpm
npm verb Darwin 21.6.0
npm verb node v18.12.0
npm verb npm v9.0.1
npm ERR! code ENYI
npm ERR! Web login not supported
npm verb exit 1
npm verb code 1
这样看来好像得先有一个 web 登录界面😭
哈哈,外网应该不需要,内网直接跳登陆服务回来直接转发就好(
@MondoGao 哈哈,不是所有私有部署都会包装一下 npm 的,很多还是直接使用 npm 修改 registry 来使用。
使用 authing.cn 的能力,结合 tegg 的 module 能力,做一个 authing module。
npm http fetch POST 200 https://registry.npmjs.org/-/v1/login 893ms
npm verb web auth got response {
npm verb web auth loginUrl: 'https://www.npmjs.com/login?next=/login/cli/xxxxx,
npm verb web auth doneUrl: 'https://registry.npmjs.org/-/v1/done?sessionId=xxx'
npm verb web auth }
npm verb web auth opening url pair
Login at:
https://www.npmjs.com/login?next=/login/cli/xxxxxxx
Press ENTER to open in the browser...npm http fetch GET 202 https://registry.npmjs.org/-/v1/done?sessionId=npm_*** 268ms
npm http fetch GET 202 https://registry.npmjs.org/-/v1/done?sessionId=npm_*** 268ms
npm http fetch GET 202 https://registry.npmjs.org/-/v1/done?sessionId=npm_*** 266ms
登录成功的界面提示
baseauth 搞定
接下来需要做一个 authing.cn 的 示例
https://github.blog/changelog/2022-10-24-npm-v9-0-0-released/
login and adduser are now separate commands that send different data to the registry.
login with web
check doneUrl