Skip to content
This repository has been archived by the owner on Jan 7, 2025. It is now read-only.

Commit

Permalink
Move reading of auth-public-key into lower scope (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
dyedwiper authored Jul 29, 2024
1 parent 61a13e4 commit 49eac76
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions src/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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!')
Expand Down

0 comments on commit 49eac76

Please sign in to comment.