@avora-labs/meta-forge 1.4.0 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@avora-labs/meta-forge",
3
- "version": "1.4.0",
3
+ "version": "1.6.0",
4
4
  "description": "AvoraMetaForge — A meta-driven Angular framework. Define entire applications through structured TypeScript metadata.",
5
5
  "keywords": [
6
6
  "angular",
@@ -1421,6 +1421,12 @@ interface GlobalAuthMeta {
1421
1421
  headerName?: string;
1422
1422
  /** Token prefix (default: 'Bearer ') */
1423
1423
  tokenPrefix?: string;
1424
+ /**
1425
+ * Enable development mock-login mode.
1426
+ * When true, AuthService skips real API calls and generates a fake JWT locally.
1427
+ * Set this only in dev/demo configs — never in production AppMeta.
1428
+ */
1429
+ mock?: boolean;
1424
1430
  /**
1425
1431
  * AvoraMetaForge Built-in Native Auth UI
1426
1432
  * Let the framework handle auth screens for you using the AmfAuthShell.
@@ -1433,6 +1439,8 @@ interface GlobalAuthMeta {
1433
1439
  brandName?: string;
1434
1440
  /** Custom tagline for auth pages */
1435
1441
  brandTagline?: string;
1442
+ /** Enable OTP two-step verification flow on login */
1443
+ requireOtp?: boolean;
1436
1444
  };
1437
1445
  }
1438
1446
  interface AppBrandingMeta {
@@ -1968,56 +1976,6 @@ declare class MetaStateService {
1968
1976
  static ɵprov: i0.ɵɵInjectableDeclaration<MetaStateService>;
1969
1977
  }
1970
1978
 
1971
- interface AuthUser {
1972
- id?: string;
1973
- email?: string;
1974
- name?: string;
1975
- roles?: string[];
1976
- permissions?: string[];
1977
- avatar?: string;
1978
- [key: string]: any;
1979
- }
1980
- declare class MetaAuthService {
1981
- private readonly state;
1982
- private readonly apiService;
1983
- private config;
1984
- private refreshTimer;
1985
- /** Initialize auth from AppMeta config */
1986
- configure(authConfig: GlobalAuthMeta): void;
1987
- /** Store auth token and update state */
1988
- setToken(token: string, refreshToken?: string): void;
1989
- /** Get current token */
1990
- getToken(): string | null;
1991
- /** Get current refresh token */
1992
- getRefreshToken(): string | null;
1993
- /** Check if user is authenticated */
1994
- isAuthenticated(): boolean;
1995
- /** Set the current user */
1996
- setUser(user: AuthUser): void;
1997
- /** Get current user */
1998
- getUser(): AuthUser | null;
1999
- /** Check if user has a specific role */
2000
- hasRole(role: string): boolean;
2001
- /** Check if user has ANY of the specified roles */
2002
- hasAnyRole(roles: string[]): boolean;
2003
- /** Check if user has a specific permission */
2004
- hasPermission(permission: string): boolean;
2005
- /** Check if user has ALL specified permissions */
2006
- hasAllPermissions(permissions: string[]): boolean;
2007
- /** Perform login via configured endpoint */
2008
- login(credentials: Record<string, any>): Promise<any>;
2009
- /** Perform logout */
2010
- logout(): Promise<void>;
2011
- /** Refresh the auth token */
2012
- refreshAuthToken(): Promise<string | null>;
2013
- private scheduleTokenRefresh;
2014
- private getStorage;
2015
- private getStoredToken;
2016
- private getFromStorage;
2017
- static ɵfac: i0.ɵɵFactoryDeclaration<MetaAuthService, never>;
2018
- static ɵprov: i0.ɵɵInjectableDeclaration<MetaAuthService>;
2019
- }
2020
-
2021
1979
  declare class PluginRegistryService {
2022
1980
  private plugins;
2023
1981
  register(plugin: AvoraMetaForgePlugin): void;
@@ -2216,6 +2174,49 @@ declare class PageHeaderSectionComponent implements MetaSectionComponent<PageHea
2216
2174
  static ɵcmp: i0.ɵɵComponentDeclaration<PageHeaderSectionComponent, "amf-page-header", never, { "config": { "alias": "config"; "required": false; }; "context": { "alias": "context"; "required": false; }; }, {}, never, never, true, never>;
2217
2175
  }
2218
2176
 
2177
+ interface AuthUser {
2178
+ id?: string;
2179
+ email?: string;
2180
+ name?: string;
2181
+ roles?: string[];
2182
+ permissions?: string[];
2183
+ avatar?: string;
2184
+ role?: string;
2185
+ [key: string]: any;
2186
+ }
2187
+ declare class AuthService {
2188
+ private readonly state;
2189
+ private readonly apiService;
2190
+ private readonly router;
2191
+ private config;
2192
+ private refreshTimer;
2193
+ private isDevMode;
2194
+ private readonly REDIRECT_KEY;
2195
+ readonly user: Signal<AuthUser | null>;
2196
+ readonly isAuthenticated: Signal<boolean>;
2197
+ configure(authConfig: GlobalAuthMeta, isDevMode?: boolean): void;
2198
+ setToken(token: string, refreshToken?: string): void;
2199
+ getToken(): string | null;
2200
+ getRefreshToken(): string | null;
2201
+ setUser(user: AuthUser): void;
2202
+ getUserProfile(): AuthUser | null;
2203
+ hasRole(role: string | string[]): boolean;
2204
+ hasPermission(permission: string): boolean;
2205
+ login(credentials: Record<string, any>, preventRedirect?: boolean): Promise<any>;
2206
+ logout(): Promise<void>;
2207
+ private _mockLogin;
2208
+ storeRedirectUrl(url: string): void;
2209
+ private handleRedirect;
2210
+ isTokenExpired(token?: string | null): boolean;
2211
+ refreshAuthToken(): Promise<string | null>;
2212
+ private scheduleTokenRefresh;
2213
+ private getStorage;
2214
+ private getStoredToken;
2215
+ private getFromStorage;
2216
+ static ɵfac: i0.ɵɵFactoryDeclaration<AuthService, never>;
2217
+ static ɵprov: i0.ɵɵInjectableDeclaration<AuthService>;
2218
+ }
2219
+
2219
2220
  interface NavItem {
2220
2221
  label: string;
2221
2222
  icon?: string;
@@ -2334,7 +2335,7 @@ declare const APP_META_CONFIG_TOKEN: InjectionToken<AppMeta>;
2334
2335
  * Returns a synchronous function — Angular waits for it to complete
2335
2336
  * before performing the initial navigation.
2336
2337
  */
2337
- declare function initializeAvoraMetaForge(registry: ComponentRegistryService, routerService: MetaRouterService, apiService: MetaApiService, stateService: MetaStateService, authService: MetaAuthService, actionDispatcher: ActionDispatcherService, conditionEvaluator: ConditionEvaluatorService, pluginRegistry: PluginRegistryService, navService: NavigationService, appConfigService: AppConfigService, config: AppMeta): () => void;
2338
+ declare function initializeAvoraMetaForge(registry: ComponentRegistryService, routerService: MetaRouterService, apiService: MetaApiService, stateService: MetaStateService, authService: AuthService, actionDispatcher: ActionDispatcherService, conditionEvaluator: ConditionEvaluatorService, pluginRegistry: PluginRegistryService, navService: NavigationService, appConfigService: AppConfigService, config: AppMeta): () => void;
2338
2339
  /**
2339
2340
  * Call this in app.config.ts to wire up AvoraMetaForge:
2340
2341
  *
@@ -2342,133 +2343,16 @@ declare function initializeAvoraMetaForge(registry: ComponentRegistryService, ro
2342
2343
  */
2343
2344
  declare function provideAvoraMetaForge(config: AppMeta): Provider[];
2344
2345
 
2345
- interface UserProfile {
2346
- id: string;
2347
- name: string;
2348
- email: string;
2349
- avatar: string;
2350
- role: string;
2351
- company: string;
2352
- }
2353
- /**
2354
- * ╔══════════════════════════════════════════════════════════════════╗
2355
- * ║ DEMO / PROTOTYPE AUTH SERVICE — NOT FOR PRODUCTION ║
2356
- * ╠══════════════════════════════════════════════════════════════════╣
2357
- * ║ This service simulates authentication entirely on the client. ║
2358
- * ║ The login() method accepts ANY email and password and creates ║
2359
- * ║ a fake JWT-shaped token. There is NO real credential check. ║
2360
- * ║ ║
2361
- * ║ Purpose: let framework developers demo the full auth UI flow ║
2362
- * ║ (login → guard → interceptor → logout) without a live backend. ║
2363
- * ║ ║
2364
- * ║ ── TO SWITCH TO REAL AUTH ─────────────────────────────────── ║
2365
- * ║ Option A (recommended): Use MetaAuthService directly. ║
2366
- * ║ • Configure `auth.loginEndpoint` in AppMeta to a real endpoint ║
2367
- * ║ • Remove mock:true from that endpoint definition ║
2368
- * ║ • MetaAuthService handles token storage + auto-refresh ║
2369
- * ║ ║
2370
- * ║ Option B: Keep this service but replace _mockLogin() body with ║
2371
- * ║ a real HTTP call (e.g. via HttpClient or MetaApiService). ║
2372
- * ║ ║
2373
- * ║ See FRAMEWORK_GUIDE.md §3 for a step-by-step migration guide. ║
2374
- * ╚══════════════════════════════════════════════════════════════════╝
2375
- */
2376
- declare class AuthService {
2377
- private router;
2378
- /**
2379
- * Sentinel flag — always `true` on this demo implementation.
2380
- * Production code can check `AuthService.IS_MOCK_AUTH` to detect
2381
- * whether real authentication is wired up.
2382
- */
2383
- static readonly IS_MOCK_AUTH = true;
2384
- private readonly TOKEN_KEY;
2385
- private readonly USER_KEY;
2386
- private readonly REDIRECT_KEY;
2387
- private readonly _user;
2388
- readonly user: i0.Signal<UserProfile | null>;
2389
- readonly isAuthenticated: i0.Signal<boolean>;
2390
- constructor(router: Router);
2391
- private getInitialUser;
2392
- /**
2393
- * Authenticate a user.
2394
- *
2395
- * ⚠️ DEMO IMPLEMENTATION — accepts any credentials.
2396
- * Internally delegates to `_mockLogin()` which fabricates a JWT-shaped
2397
- * token without contacting any server.
2398
- *
2399
- * To use real auth, replace the body of `_mockLogin()` (or this method)
2400
- * with an actual API call. See FRAMEWORK_GUIDE.md §3.
2401
- */
2402
- login(email: string, password: string): boolean;
2403
- /**
2404
- * ── MOCK IMPLEMENTATION ──────────────────────────────────────────
2405
- * Generates a fake JWT-shaped token and stores a fabricated user profile.
2406
- * This method has NO security — it accepts any email/password pair.
2407
- * It exists purely to allow testing the auth UI flow without a backend.
2408
- * ─────────────────────────────────────────────────────────────────
2409
- */
2410
- private _mockLogin;
2411
- /** Clear session and navigate to login */
2412
- logout(): void;
2413
- /** Get the raw token string */
2414
- getToken(): string | null;
2415
- /** Get the current user profile */
2416
- getUserProfile(): UserProfile | null;
2417
- /** Check if the current user has a specific role */
2418
- hasRole(role: string | string[]): boolean;
2419
- /** Store the URL the user was trying to access before being redirected to login */
2420
- storeRedirectUrl(url: string): void;
2421
- /** Check if the mock token is expired */
2422
- isTokenExpired(token?: string | null): boolean;
2423
- static ɵfac: i0.ɵɵFactoryDeclaration<AuthService, never>;
2424
- static ɵprov: i0.ɵɵInjectableDeclaration<AuthService>;
2425
- }
2426
-
2427
2346
  /**
2428
2347
  * Functional auth guard (CanActivateFn).
2429
2348
  * - Checks if a valid (non-expired) token exists via AuthService.
2430
2349
  * - Stores the attempted URL for post-login redirect.
2431
2350
  * - Redirects unauthenticated users to /login.
2432
- *
2433
- * \u2500\u2500 CURRENT (DEMO) BEHAVIOUR \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
2434
- * Delegates to `AuthService` (the demo/mock auth service).
2435
- * The token it checks is a locally-generated fake JWT \u2014 no server
2436
- * validation occurs. The guard correctly protects routes in the demo
2437
- * but will let any fabricated token through.
2438
- *
2439
- * \u2500\u2500 PRODUCTION MIGRATION PATH \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
2440
- * Option A \u2014 Use the framework\u2019s built-in MetaGuard:
2441
- * Set `guard: { requireAuth: true, redirectTo: '/login' }` on any
2442
- * PageMeta definition. MetaGuard already reads from MetaAuthService
2443
- * and handles role/permission checks declaratively.
2444
- *
2445
- * Option B \u2014 Keep this guard but swap the auth service:
2446
- * Replace `inject(AuthService)` with `inject(MetaAuthService)` and
2447
- * call `.isAuthenticated()` on it once real tokens are in flight.
2448
- *
2449
- * See FRAMEWORK_GUIDE.md \u00a73 for step-by-step migration instructions.
2450
2351
  */
2451
2352
  declare const authGuard: CanActivateFn;
2452
2353
 
2453
2354
  /**
2454
2355
  * HTTP Interceptor — Bearer token injection + 401 global logout.
2455
- *
2456
- * ── CURRENT (DEMO) BEHAVIOUR ──────────────────────────────────────────────
2457
- * Reads the Bearer token from `AuthService` (the demo/mock service).
2458
- * The token is a fake JWT-shaped string generated locally — it will be
2459
- * rejected by any real API server that validates JWT signatures.
2460
- *
2461
- * ── PRODUCTION MIGRATION PATH ────────────────────────────────────────────
2462
- * Option A — Swap the token source (minimal change):
2463
- * Replace `authService.getToken()` with a call to `MetaAuthService.getToken()`
2464
- * once you have a real login endpoint producing real JWTs.
2465
- *
2466
- * Option B — Remove this interceptor entirely:
2467
- * Use AvoraMetaForge’s built-in auth injection via `ApiEndpointMeta.auth`.
2468
- * Set `auth: { type: 'bearer', token: 'state:auth.token' }` on each endpoint
2469
- * and MetaApiService will inject it automatically. No interceptor needed.
2470
- *
2471
- * See FRAMEWORK_GUIDE.md §3 for step-by-step instructions.
2472
2356
  */
2473
2357
  declare const authInterceptor: HttpInterceptorFn;
2474
2358
 
@@ -2527,5 +2411,5 @@ declare class LayoutComponent {
2527
2411
  static ɵcmp: i0.ɵɵComponentDeclaration<LayoutComponent, "app-layout", never, {}, {}, never, never, true, never>;
2528
2412
  }
2529
2413
 
2530
- export { APP_META_CONFIG_TOKEN, AccordionSectionComponent, ActionDispatcherService, AmfDialogHostComponent, AmfDrawerHostComponent, AppConfigService, AuthService, CardSectionComponent, ComponentRegistryService, ConditionEvaluatorService, FormRendererComponent, LayoutComponent, LayoutType, META_SECTION_CONFIG, META_SECTION_CONTEXT, MetaApiService, MetaAuthService, MetaModalHostComponent, MetaPageComponent, MetaRendererComponent, MetaRouterService, MetaStateService, NotificationService, PageHeaderSectionComponent, PluginRegistryService, RepeaterFieldComponent, StatsGridSectionComponent, StepperFormRendererComponent, TableRendererComponent, ThemeService, authGuard, authInterceptor, getAmfRoutes, initializeAvoraMetaForge, metaCanDeactivateGuard, metaGuard, provideAvoraMetaForge };
2531
- export type { AccordionMeta, AccordionPanelMeta, ActionMeta, ActionType, AggregateRowMeta, AlertMeta, ApiActionConfig, ApiAuthMeta, ApiEndpointMeta, ApiPaginationMeta, AppBrandingMeta, AppMeta, AuthUser, AutosaveMeta, AvoraMetaForgePlugin, BreadcrumbMeta, CacheMeta, CardMeta, CellType, ClearStateActionConfig, ColumnEditValidatorMeta, ColumnMeta, ComputeFieldMeta, ConditionMeta, ConditionOperator, ConditionalActionConfig, ConfirmActionConfig, CopyToClipboardActionConfig, CrossFieldValidatorMeta, CustomComponentMeta, DelayActionConfig, DialogConfig, DispatchMultipleActionConfig, DividerMeta, DownloadFileActionConfig, DrawerActionConfig, EmitActionConfig, EmptyStateMeta, EnvironmentConfig, FieldMeta, FieldType, FocusActionConfig, FooterLinkMeta, ForEachActionConfig, FormLayout, FormMeta, FormStepMeta, GlobalAuthMeta, GuardMeta, HtmlMeta, HttpMethod$1 as HttpMethod, IframeMeta, LayoutConfigMeta, LayoutMeta, LayoutTypeKey, LoadingActionConfig, LogActionConfig, MetaSectionComponent, ModalActionConfig, NavGroupMeta, NavItemMeta, NavigateActionConfig, Notification, NotificationType, NotifyActionConfig, OpenUrlActionConfig, OptionMeta, PageHeaderActionMeta, PageHeaderMeta, PageMeta, PaginationMeta, PatchFormActionConfig, PrintActionConfig, ReloadTableActionConfig, ResetFormActionConfig, ResolverMeta, RetryMeta, RowClassMeta, ScrollToActionConfig, SectionMeta, ServerPaginationConfig, SetStateActionConfig, SetTitleActionConfig, SpacerMeta, StatCardMeta, StateChange, StatsGridMeta, StorageActionConfig, SubmitFormActionConfig, TabMeta, TableActionMeta, TableFilterMeta, TableMeta, TabsMeta, ThemeMeta, TimelineItemMeta, TimelineMeta, ToggleClassActionConfig, TransformContextActionConfig, TransformMeta, UserProfile, ValidatorMeta };
2414
+ export { APP_META_CONFIG_TOKEN, AccordionSectionComponent, ActionDispatcherService, AmfDialogHostComponent, AmfDrawerHostComponent, AppConfigService, AuthService, CardSectionComponent, ComponentRegistryService, ConditionEvaluatorService, FormRendererComponent, LayoutComponent, LayoutType, META_SECTION_CONFIG, META_SECTION_CONTEXT, MetaApiService, MetaModalHostComponent, MetaPageComponent, MetaRendererComponent, MetaRouterService, MetaStateService, NotificationService, PageHeaderSectionComponent, PluginRegistryService, RepeaterFieldComponent, StatsGridSectionComponent, StepperFormRendererComponent, TableRendererComponent, ThemeService, authGuard, authInterceptor, getAmfRoutes, initializeAvoraMetaForge, metaCanDeactivateGuard, metaGuard, provideAvoraMetaForge };
2415
+ export type { AccordionMeta, AccordionPanelMeta, ActionMeta, ActionType, AggregateRowMeta, AlertMeta, ApiActionConfig, ApiAuthMeta, ApiEndpointMeta, ApiPaginationMeta, AppBrandingMeta, AppMeta, AuthUser, AutosaveMeta, AvoraMetaForgePlugin, BreadcrumbMeta, CacheMeta, CardMeta, CellType, ClearStateActionConfig, ColumnEditValidatorMeta, ColumnMeta, ComputeFieldMeta, ConditionMeta, ConditionOperator, ConditionalActionConfig, ConfirmActionConfig, CopyToClipboardActionConfig, CrossFieldValidatorMeta, CustomComponentMeta, DelayActionConfig, DialogConfig, DispatchMultipleActionConfig, DividerMeta, DownloadFileActionConfig, DrawerActionConfig, EmitActionConfig, EmptyStateMeta, EnvironmentConfig, FieldMeta, FieldType, FocusActionConfig, FooterLinkMeta, ForEachActionConfig, FormLayout, FormMeta, FormStepMeta, GlobalAuthMeta, GuardMeta, HtmlMeta, HttpMethod$1 as HttpMethod, IframeMeta, LayoutConfigMeta, LayoutMeta, LayoutTypeKey, LoadingActionConfig, LogActionConfig, MetaSectionComponent, ModalActionConfig, NavGroupMeta, NavItemMeta, NavigateActionConfig, Notification, NotificationType, NotifyActionConfig, OpenUrlActionConfig, OptionMeta, PageHeaderActionMeta, PageHeaderMeta, PageMeta, PaginationMeta, PatchFormActionConfig, PrintActionConfig, ReloadTableActionConfig, ResetFormActionConfig, ResolverMeta, RetryMeta, RowClassMeta, ScrollToActionConfig, SectionMeta, ServerPaginationConfig, SetStateActionConfig, SetTitleActionConfig, SpacerMeta, StatCardMeta, StateChange, StatsGridMeta, StorageActionConfig, SubmitFormActionConfig, TabMeta, TableActionMeta, TableFilterMeta, TableMeta, TabsMeta, ThemeMeta, TimelineItemMeta, TimelineMeta, ToggleClassActionConfig, TransformContextActionConfig, TransformMeta, ValidatorMeta };