1 import { UserRole } from '@shared/models'
2 import { MOAuthToken } from '@server/typings/models'
4 export type RegisterServerAuthOptions = RegisterServerAuthPassOptions | RegisterServerAuthExternalOptions
6 export interface RegisterServerAuthPassOptions {
7 // Authentication name (a plugin can register multiple auth strategies)
10 // Called by PeerTube when a user from your plugin logged out
13 // Weight of this authentication so PeerTube tries the auth methods in DESC weight order
16 // Your plugin can hook PeerTube access/refresh token validity
17 // So you can control for your plugin the user session lifetime
18 hookTokenValidity?(options: { token: MOAuthToken, type: 'access' | 'refresh' }): Promise<{ valid: boolean }>
20 // Used by PeerTube to login a user
21 // Returns null if the login failed, or { username, email } on success
33 export interface RegisterServerAuthExternalOptions {
34 // Authentication name (a plugin can register multiple auth strategies)
40 export interface RegisterServerAuthExternalResult {
41 onAuth (options: { username: string, email: string }): void