From 42ea97de4b8877d25fba0fc4267aef8a2716adf9 Mon Sep 17 00:00:00 2001 From: dyedwiper Date: Mon, 22 Jul 2024 10:57:59 +0200 Subject: [PATCH] Move reading of auth-public-key into lower scope --- src/server.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/server.js b/src/server.js index df1640a..a7ab829 100644 --- a/src/server.js +++ b/src/server.js @@ -8,9 +8,6 @@ import * as json from 'lib0/json' import { registerYWebsocketServer } from '../src/ws.js' import * as promise from 'lib0/promise' -const wsServerPublicKey = await ecdsa.importKeyJwk(json.parse(env.ensureConf('auth-public-key'))) -// const wsServerPrivateKey = await ecdsa.importKeyJwk(json.parse(env.ensureConf('auth-private-key'))) - class YWebsocketServer { /** * @param {uws.TemplatedApp} app @@ -52,6 +49,7 @@ export const createYWebsocketServer = async ({ throw new Error('Missing Token') } // verify that the user has a valid token + const wsServerPublicKey = await ecdsa.importKeyJwk(json.parse(env.ensureConf('auth-public-key'))) const { payload: userToken } = await jwt.verifyJwt(wsServerPublicKey, token) if (userToken.yuserid == null) { throw new Error('Missing userid in user token!')