@frank-auth/react
Version:
Flexible and customizable React UI components for Frank Authentication
237 lines • 6.76 kB
TypeScript
import { FrankAuthUIConfig, OrganizationConfig, UserType } from './types';
import { DEFAULT_ORGANIZATION_CONFIG } from './defaults';
import { ThemeManager } from './theme';
import { AppearanceManager } from './appearance';
/**
* Organization feature flags with granular control
*/
export interface OrganizationFeatureFlags {
authentication: {
signUp: boolean;
signIn: boolean;
passwordReset: boolean;
emailVerification: boolean;
phoneVerification: boolean;
socialAuth: boolean;
magicLink: boolean;
passkeys: boolean;
};
security: {
mfa: boolean;
mfaRequired: boolean;
sso: boolean;
sessionManagement: boolean;
auditLogs: boolean;
ipWhitelist: boolean;
deviceTrust: boolean;
riskAssessment: boolean;
};
userManagement: {
userProfiles: boolean;
userRoles: boolean;
userPermissions: boolean;
userInvitations: boolean;
userSuspension: boolean;
userDeletion: boolean;
bulkUserOperations: boolean;
};
organization: {
memberManagement: boolean;
roleManagement: boolean;
invitations: boolean;
customBranding: boolean;
customDomain: boolean;
webhooks: boolean;
apiAccess: boolean;
analytics: boolean;
};
ui: {
darkMode: boolean;
customThemes: boolean;
localization: boolean;
customCSS: boolean;
logoUpload: boolean;
colorCustomization: boolean;
layoutCustomization: boolean;
};
integrations: {
saml: boolean;
oidc: boolean;
ldap: boolean;
scim: boolean;
slack: boolean;
microsoft: boolean;
google: boolean;
github: boolean;
};
}
/**
* Organization limits and quotas
*/
export interface OrganizationLimits {
users: {
maxUsers: number;
maxEndUsers: number;
maxExternalUsers: number;
maxInternalUsers: number;
};
sessions: {
maxSessionsPerUser: number;
maxConcurrentSessions: number;
sessionTimeout: number;
maxSessionDuration: number;
};
api: {
monthlyRequestLimit: number;
rateLimit: number;
burstLimit: number;
maxWebhooks: number;
};
storage: {
maxLogoSize: number;
maxCustomCSSSize: number;
auditLogRetention: number;
maxCustomFields: number;
};
features: {
maxRoles: number;
maxPermissions: number;
maxIntegrations: number;
maxDomains: number;
};
}
/**
* Organization compliance settings
*/
export interface OrganizationCompliance {
dataRetention: {
userDataRetention: number;
auditLogRetention: number;
sessionLogRetention: number;
automaticDeletion: boolean;
};
privacy: {
gdprCompliant: boolean;
ccpaCompliant: boolean;
hipaaCompliant: boolean;
soc2Compliant: boolean;
dataProcessingAgreement: boolean;
};
security: {
encryptionAtRest: boolean;
encryptionInTransit: boolean;
keyRotation: boolean;
backupEncryption: boolean;
accessLogging: boolean;
};
reporting: {
complianceReports: boolean;
auditReports: boolean;
securityReports: boolean;
dataExport: boolean;
rightToBeForgotten: boolean;
};
}
/**
* Extended organization configuration
*/
export interface ExtendedOrganizationConfig extends OrganizationConfig {
features: OrganizationFeatureFlags;
limits: OrganizationLimits;
compliance: OrganizationCompliance;
tier: 'free' | 'starter' | 'professional' | 'enterprise';
isActive: boolean;
trialEndsAt?: Date;
subscriptionStatus: 'active' | 'trialing' | 'past_due' | 'canceled' | 'unpaid';
usage: {
currentUsers: number;
currentEndUsers: number;
monthlyApiRequests: number;
storageUsed: number;
lastActivityAt: Date;
};
}
export declare class OrganizationConfigManager {
private config;
private themeManager;
private appearanceManager;
private listeners;
constructor(organizationConfig: Partial<ExtendedOrganizationConfig>, themeManager?: ThemeManager, appearanceManager?: AppearanceManager);
/**
* Get current organization configuration
*/
getConfig(): ExtendedOrganizationConfig;
/**
* Update organization configuration
*/
updateConfig(updates: Partial<ExtendedOrganizationConfig>): void;
/**
* Check if a feature is enabled
*/
isFeatureEnabled(featurePath: string): boolean;
/**
* Check if a user type is allowed
*/
isUserTypeAllowed(userType: UserType): boolean;
/**
* Get user limits for a specific user type
*/
getUserLimits(userType: UserType): number;
/**
* Check if organization is within limits
*/
checkLimits(): {
withinLimits: boolean;
violations: Array<{
type: string;
current: number;
limit: number;
}>;
};
/**
* Get organization tier configuration
*/
getTierConfig(): {
name: string;
features: string[];
limits: Record<string, number>;
price?: string;
};
/**
* Generate UI configuration based on organization settings
*/
generateUIConfig(): Partial<FrankAuthUIConfig>;
/**
* Subscribe to configuration changes
*/
subscribe(callback: (config: ExtendedOrganizationConfig) => void): () => void;
/**
* Validate organization configuration
*/
validateConfig(): {
isValid: boolean;
errors: string[];
warnings: string[];
};
private mergeWithDefaults;
private applyOrganizationBranding;
private generateCustomTheme;
private generateCustomAppearance;
private generateLocalizationConfig;
private isValidUrl;
private notifyListeners;
}
/**
* Create organization configuration manager
*/
export declare function createOrganizationConfigManager(config: Partial<ExtendedOrganizationConfig>, themeManager?: ThemeManager, appearanceManager?: AppearanceManager): OrganizationConfigManager;
/**
* Transform organization settings from API to UI config
*/
export declare function transformOrganizationSettings(apiSettings: any): Partial<ExtendedOrganizationConfig>;
/**
* Get feature availability by tier
*/
export declare function getFeaturesByTier(tier: 'free' | 'starter' | 'professional' | 'enterprise'): Partial<OrganizationFeatureFlags>;
export { DEFAULT_ORGANIZATION_CONFIG, };
//# sourceMappingURL=organization.d.ts.map