@gsb-core/core
Version:
GSB core services and classes for platform-independent web applications
116 lines (115 loc) • 4.12 kB
TypeScript
/**
* GSB Configuration - Core settings and tenant management
* Consolidated version with improved tenant handling
*/
export declare function setLocalStorage(key: string, value: string, duration?: number): void;
export declare function getLocalStorage(key: string): string | null;
export declare function removeLocalStorage(key: string): void;
export declare function getEnvVar(key: string, defaultValue: string): string;
export declare function checkAllEnvVars(varName: string): string;
/**
* Get the base domain for GSB services
* @returns The base domain
*/
export declare function getGsbBaseDomain(): string;
/**
* Get the API URL for GSB services
* @returns The API URL
*/
export declare function getGsbApiUrl(): string | undefined;
export declare function getGsbLangCode(): string | undefined;
export declare function getGsbLangStorageKey(): string;
/**
* Get the default tenant code from environment variables
* @returns The default tenant code from environment variables, or an empty string if not found.
*/
export declare function getDefaultTenant(): string;
/**
* Get the current GSB tenant code
* Prioritizes GSB_SETTINGS, then environment variables, then localStorage.
* @returns The current active tenant code
*/
export declare function getGsbTenantCode(): string | undefined;
/**
* Set the active GSB tenant code
* @param tenantCode The tenant code to set as active
*/
export declare function setGsbTenantCode(tenantCode: string): void;
/**
* Set the GSB API URL.
* @param apiUrl The API URL to set.
*/
export declare function setGsbApiUrl(apiUrl: string | undefined): void;
/**
* Set the GSB language code.
/**
* Set the GSB language code.
* @param langCode The language code to set.
*/
export declare function setGsbLangCode(langCode: string | undefined): void;
export declare function setGsbLangStorageKey(langStorageKey: string | undefined): void;
/**
* Set the GSB token.
* @param token The token to set.
*/
export declare function setGsbToken(token: string | undefined): void;
/**
* Get the GSB token.
* Prioritizes GSB_SETTINGS, then environment variables, then localStorage for the current tenant.
*/
export declare function getGsbToken(): string | undefined;
/**
* Check if multi-tenant mode is enabled
*/
export declare function isMultiTenantEnabled(): boolean;
/**
* Parse tenant code from hostname
* @param hostname The hostname to extract tenant from
* @returns Tenant code or null if using main domain
*/
export declare function getTenantFromHostname(hostname: string): string | null;
/**
* Extract tenant code from a JWT token
* @param token The JWT token
* @returns The tenant code or undefined
*/
export declare function extractTenantCodeFromToken(token: string): string | undefined;
/**
* Get a token from environment variables based on tenant code (for development)
* @param tenantCode The tenant code
* @returns The token from environment if available, or null
*/
export declare function getEnvToken(): string | undefined;
/**
* Storage key helper for tokens
* @param tenantCode The tenant code
* @returns Storage key for the tenant's token
*/
export declare function getTokenStorageKey(tenantCode: string): string;
/**
* Storage key helper for user data
* @param tenantCode The tenant code
* @returns Storage key for the tenant's user data
*/
export declare function getUserDataStorageKey(tenantCode: string): string;
/**
* Get available tenants from storage
*/
export declare function getAvailableTenants(): string[];
/**
* @deprecated Use setGsbTenantCode and appropriate auth service methods to clear tokens.
*/
export declare function clearGsbAuth(): void;
/**
* GSB Environment Configuration
*/
export declare const GSB_CONFIG: {
readonly BASE_DOMAIN: string;
readonly TENANT_CODE: string | undefined;
API_URL(tenantCode?: string, baseDomain?: string): string;
readonly LANG_CODE: string | undefined;
readonly LANG_STORAGE_KEY: string | undefined;
readonly ENABLE_MULTI_TENANT: boolean;
extractTenantCode: typeof extractTenantCodeFromToken;
getTenantUrl(tenantCode: string): string;
};