linted
This commit is contained in:
parent
c374f54307
commit
c1103a54e8
10
index.ts
10
index.ts
|
@ -5,7 +5,7 @@ import {
|
||||||
ValidateJWTTokenInput,
|
ValidateJWTTokenInput,
|
||||||
ValidateJWTTokenResponse,
|
ValidateJWTTokenResponse,
|
||||||
} from '@authorizerdev/authorizer-js'
|
} from '@authorizerdev/authorizer-js'
|
||||||
import Server, { onAuthenticatePayload } from '@hocuspocus/server';
|
import Server, { onAuthenticatePayload } from '@hocuspocus/server'
|
||||||
|
|
||||||
const authorizer = new Authorizer({
|
const authorizer = new Authorizer({
|
||||||
clientID: process.env.AUTHORIZER_CLIENT_ID,
|
clientID: process.env.AUTHORIZER_CLIENT_ID,
|
||||||
|
@ -19,7 +19,6 @@ const server = await Server.configure({
|
||||||
connection.requiresAuthentication = true
|
connection.requiresAuthentication = true
|
||||||
},
|
},
|
||||||
async onAuthenticate(data: onAuthenticatePayload) {
|
async onAuthenticate(data: onAuthenticatePayload) {
|
||||||
|
|
||||||
if (data.requestHeaders) {
|
if (data.requestHeaders) {
|
||||||
const params: ValidateJWTTokenInput = {
|
const params: ValidateJWTTokenInput = {
|
||||||
token_type: 'access_token',
|
token_type: 'access_token',
|
||||||
|
@ -33,12 +32,11 @@ const server = await Server.configure({
|
||||||
console.debug(`user_id: ${user} roles: ${roles}`)
|
console.debug(`user_id: ${user} roles: ${roles}`)
|
||||||
return {
|
return {
|
||||||
id: user,
|
id: user,
|
||||||
roles
|
roles,
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
console.error('no valid auth token presented')
|
|
||||||
throw new Error("Not authorized!")
|
|
||||||
}
|
}
|
||||||
|
console.error('no valid auth token presented')
|
||||||
|
throw new Error('Not authorized!')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
"main": "index.ts",
|
"main": "index.ts",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"fix": "npx @biomejs/biome check --fix --apply-unsafe .",
|
"fix": "npx @biomejs/biome check --apply-unsafe .",
|
||||||
"start": "npx tsc index.ts"
|
"start": "npx tsc index.ts"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user