linted
Some checks failed
CI/CD / test (push) Failing after 20s
CI/CD / deploy (push) Has been skipped

This commit is contained in:
Untone 2024-02-17 14:38:03 +03:00
parent c374f54307
commit c1103a54e8
2 changed files with 5 additions and 7 deletions

View File

@ -5,7 +5,7 @@ import {
ValidateJWTTokenInput,
ValidateJWTTokenResponse,
} from '@authorizerdev/authorizer-js'
import Server, { onAuthenticatePayload } from '@hocuspocus/server';
import Server, { onAuthenticatePayload } from '@hocuspocus/server'
const authorizer = new Authorizer({
clientID: process.env.AUTHORIZER_CLIENT_ID,
@ -19,7 +19,6 @@ const server = await Server.configure({
connection.requiresAuthentication = true
},
async onAuthenticate(data: onAuthenticatePayload) {
if (data.requestHeaders) {
const params: ValidateJWTTokenInput = {
token_type: 'access_token',
@ -33,12 +32,11 @@ const server = await Server.configure({
console.debug(`user_id: ${user} roles: ${roles}`)
return {
id: user,
roles
roles,
}
}
} else {
console.error('no valid auth token presented')
throw new Error("Not authorized!")
}
throw new Error('Not authorized!')
}
}
},

View File

@ -5,7 +5,7 @@
"main": "index.ts",
"type": "module",
"scripts": {
"fix": "npx @biomejs/biome check --fix --apply-unsafe .",
"fix": "npx @biomejs/biome check --apply-unsafe .",
"start": "npx tsc index.ts"
},
"repository": {