mirror of
https://github.com/QuantumNous/new-api.git
synced 2026-10-28 08:35:33 +08:00
fix(kling): accept single API keys (#7897)
This commit is contained in:
1 parent
783735607d
commit
a8535fac10
1 file changed
+5
-2
@@ -106,8 +106,11 @@ function viaGateway(ctx) {
|
||||
}
|
||||
|
||||
function tokenFor(ctx) {
|
||||
if (viaGateway(ctx)) return ctx.apiKey;
|
||||
const parts = ctx.apiKey.split("|");
|
||||
const apiKey = trimmed(ctx.apiKey);
|
||||
if (!apiKey) throw new Error("api_key is empty");
|
||||
if (viaGateway(ctx)) return apiKey;
|
||||
const parts = apiKey.split("|");
|
||||
if (parts.length === 1) return apiKey;
|
||||
if (parts.length !== 2) throw new Error("invalid api_key, required format is accessKey|secretKey");
|
||||
const now = utils.unixNow();
|
||||
return utils.jwtSignHS256({ iss: parts[0].trim(), exp: now + 1800, nbf: now - 5 }, parts[1].trim());
|
||||
|
||||
Reference in new issue
Block a user