Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | 1x | import { GleeQuoreAuthFunction, GleeQuoreAuthFunctionEvent } from '../index.d.js'
interface AuthFunctionInfo {
clientAuth?: GleeQuoreAuthFunction
serverAuth?: GleeQuoreAuthFunction
}
export const authFunctions: Map<string, AuthFunctionInfo> = new Map()
export async function register(serverName: string, authInfo: AuthFunctionInfo) {
authFunctions.set(serverName, authInfo)
}
export async function triggerAuth(params: GleeQuoreAuthFunctionEvent) {
const { serverName, done } = params
const auth = authFunctions.get(serverName)
Iif (!auth) {
console.error(`Missing Authentication function file. Cannot find ${serverName}.ts or ${serverName}.js`)
done(false, 422, 'Cannot find authentication file')
return
}
//run serverAuth function with passed parameters
await auth.serverAuth(params)
}
export async function clientAuthConfig(serverName: string) {
//get client credentials
return authFunctions.get(serverName)?.clientAuth
}
|