From 695ee31fbd0a818ec5e3ba8a62d35270864c4d7d Mon Sep 17 00:00:00 2001 From: juancarmore Date: Tue, 25 Mar 2025 13:02:40 +0100 Subject: [PATCH] typings: Add authentication preferences and update global preferences --- typings/src/auth-preferences.ts | 84 +++++++++++++++++++++++++++++++ typings/src/global-preferences.ts | 35 ++++++------- typings/src/index.ts | 1 + 3 files changed, 103 insertions(+), 17 deletions(-) create mode 100644 typings/src/auth-preferences.ts diff --git a/typings/src/auth-preferences.ts b/typings/src/auth-preferences.ts new file mode 100644 index 0000000..ddab136 --- /dev/null +++ b/typings/src/auth-preferences.ts @@ -0,0 +1,84 @@ +export interface AuthenticationPreferences { + authMode: AuthMode; + method: ValidAuthMethod; +} + +/** + * Authentication modes available to enter a room. + */ +export const enum AuthMode { + NONE = 'none', // No authentication required + MODERATORS_ONLY = 'moderators_only', // Only moderators need authentication + ALL_USERS = 'all_users' // All users need authentication +} + +/** + * Authentication method base interface. + */ +export interface AuthMethod { + type: AuthType; +} + +/** + * Enum for authentication types. + */ +export const enum AuthType { + SINGLE_USER = 'single-user' + // MULTI_USER = 'multi-user', + // OAUTH_ONLY = 'oauth-only' +} + +/** + * Authentication method: Single user with fixed credentials. + */ +export interface SingleUserAuth extends AuthMethod { + type: AuthType.SINGLE_USER; + credentials: SingleUserCredentials; +} + +/** + * Authentication method: Multiple users with optional OAuth integration. + */ +// export interface MultiUserAuth extends AuthMethod { +// type: AuthType.MULTI_USER; +// oauthProviders?: OAuthProviderConfig[]; +// } + +/** + * Authentication method: Only OAuth authentication. + */ +// export interface OAuthOnlyAuth extends AuthMethod { +// type: AuthType.OAUTH_ONLY; +// oauthProviders: OAuthProviderConfig[]; +// } + +/** + * Union type for allowed authentication methods. + */ +export type ValidAuthMethod = SingleUserAuth /* | MultiUserAuth | OAuthOnlyAuth */; + +/** + * Configuration for a single user login method. + */ +export interface SingleUserCredentials { + username: string; + passwordHash: string; +} + +/** + * Configuration for OAuth authentication. + */ +// export interface OAuthProviderConfig { +// provider: OAuthProvider; +// clientId: string; +// clientSecret: string; +// redirectUri: string; +// } + +/** + * Supported OAuth providers. + */ +// export const enum OAuthProvider { +// GOOGLE = 'google', +// GITHUB = 'github' +// } diff --git a/typings/src/global-preferences.ts b/typings/src/global-preferences.ts index 3783620..d0c15ba 100644 --- a/typings/src/global-preferences.ts +++ b/typings/src/global-preferences.ts @@ -1,27 +1,28 @@ +import { AuthenticationPreferences } from './auth-preferences.js'; + /** * Represents global preferences for OpenVidu Meet. */ export interface GlobalPreferences { - projectId: string; - // roomFeaturesPreferences: RoomFeaturesPreferences; - webhooksPreferences: WebhookPreferences; - // securityPreferences: SecurityPreferences; + projectId: string; + // roomFeaturesPreferences: RoomFeaturesPreferences; + webhooksPreferences: WebhookPreferences; + securityPreferences: SecurityPreferences; } export interface WebhookPreferences { - enabled: boolean; - url: string; - // events: WebhookEvent[]; + enabled: boolean; + url: string; + // events: WebhookEvent[]; } -// export interface SecurityPreferences { -// authentication: AuthenticationPreferences; -// e2eEncryption: {} +export interface SecurityPreferences { + authentication: AuthenticationPreferences; + roomCreationPolicy: RoomCreationPolicy; + // e2eEncryption: {}; +} -// } - -// export interface AuthenticationPreferences { -// requiresAuthentication: boolean; -// authenticationMethod: AuthMethod; // Método de autenticación -// userAccessControl: UserAccessControl; // Control sobre quién puede acceder y cómo -// } +export interface RoomCreationPolicy { + allowRoomCreation: boolean; + requireAuthentication: boolean; +} diff --git a/typings/src/index.ts b/typings/src/index.ts index 00de806..1b0c978 100644 --- a/typings/src/index.ts +++ b/typings/src/index.ts @@ -1,4 +1,5 @@ export * from './global-preferences.js'; +export * from './auth-preferences.js'; export * from './room-preferences.js'; export * from './participant.js'; export * from './token.js';