mirror of
https://github.com/hansjone/oclaw.git
synced 2026-10-09 12:30:44 +08:00
Register /uds-auth/qr-start and fix crypto imports for QR login.
This commit is contained in:
parent
3aca99ca93
commit
c9ca785155
1 changed files with 8 additions and 2 deletions
|
|
@ -8,6 +8,7 @@ import { readFile, writeFile } from 'node:fs/promises'
|
|||
import { resolve, dirname } from 'node:path'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
import { createRequire } from 'node:module'
|
||||
import { createHash, randomBytes } from 'node:crypto'
|
||||
|
||||
const __dirname = dirname(fileURLToPath(import.meta.url))
|
||||
const require = createRequire(import.meta.url)
|
||||
|
|
@ -144,8 +145,8 @@ async function loadQRCodeLib() {
|
|||
function createQrChallenge(config = _currentConfig || {}) {
|
||||
const loginSystemCode = String(config.loginSystemCode || CONFIG_DEFAULTS.loginSystemCode)
|
||||
const originSystemCode = String(config.originSystemCode || '')
|
||||
const qrCodeKey = crypto.randomBytes(16).toString('hex')
|
||||
const qrCodeValue = crypto.randomBytes(16).toString('hex')
|
||||
const qrCodeKey = randomBytes(16).toString('hex')
|
||||
const qrCodeValue = randomBytes(16).toString('hex')
|
||||
const qrCodeStr = `TwoDIMAuth:${qrCodeKey}:${qrCodeValue}`
|
||||
return { qrCodeStr, qrCodeKey, qrCodeValue, loginSystemCode, originSystemCode }
|
||||
}
|
||||
|
|
@ -511,6 +512,11 @@ async function handleAllRoutes(req, res) {
|
|||
return await handleQRCode(req, res)
|
||||
}
|
||||
|
||||
// QR 挑战(扫码登录入口)
|
||||
if (pathname === '/uds-auth/qr-start' && (method === 'GET' || method === 'POST')) {
|
||||
return await handleQrStart(req, res)
|
||||
}
|
||||
|
||||
// QR 代理
|
||||
if (pathname === '/uds-auth/qr-proxy' && method === 'POST') {
|
||||
return await handleQRProxy(req, res)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue