@progalaxyelabs/ngx-stonescriptphp-client 1.3.1 → 1.5.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/index.d.ts CHANGED
@@ -97,6 +97,17 @@ interface AuthConfig {
97
97
  */
98
98
  csrfHeaderName?: string;
99
99
  }
100
+ /**
101
+ * Authentication server configuration
102
+ */
103
+ interface AuthServerConfig {
104
+ /** Server URL (e.g., 'https://accounts.progalaxyelabs.com') */
105
+ url: string;
106
+ /** JWKS endpoint for token validation (optional, defaults to /api/auth/jwks) */
107
+ jwksEndpoint?: string;
108
+ /** Whether this is the default server */
109
+ default?: boolean;
110
+ }
100
111
  declare class MyEnvironmentModel {
101
112
  production: boolean;
102
113
  /**
@@ -105,10 +116,23 @@ declare class MyEnvironmentModel {
105
116
  */
106
117
  platformCode: string;
107
118
  /**
108
- * Accounts platform URL for centralized authentication
119
+ * Accounts platform URL for centralized authentication (single-server mode)
109
120
  * @example 'https://accounts.progalaxyelabs.com'
121
+ * @deprecated Use authServers for multi-server support
110
122
  */
111
123
  accountsUrl: string;
124
+ /**
125
+ * Multiple authentication servers configuration
126
+ * Enables platforms to authenticate against different identity providers
127
+ * @example
128
+ * ```typescript
129
+ * authServers: {
130
+ * customer: { url: 'https://auth.progalaxyelabs.com', default: true },
131
+ * employee: { url: 'https://admin-auth.progalaxyelabs.com' }
132
+ * }
133
+ * ```
134
+ */
135
+ authServers?: Record<string, AuthServerConfig>;
112
136
  firebase: {
113
137
  projectId: string;
114
138
  appId: string;
@@ -131,6 +155,24 @@ declare class MyEnvironmentModel {
131
155
  * @default { mode: 'cookie', refreshEndpoint: '/auth/refresh', useCsrf: true }
132
156
  */
133
157
  auth?: AuthConfig;
158
+ /**
159
+ * Branding configuration for auth components
160
+ * Allows platforms to customize login/register pages without creating wrappers
161
+ */
162
+ branding?: {
163
+ /** Application name displayed on auth pages */
164
+ appName: string;
165
+ /** URL to logo image */
166
+ logo?: string;
167
+ /** Primary brand color (hex) */
168
+ primaryColor?: string;
169
+ /** Gradient start color (hex) */
170
+ gradientStart?: string;
171
+ /** Gradient end color (hex) */
172
+ gradientEnd?: string;
173
+ /** Subtitle text displayed on auth pages */
174
+ subtitle?: string;
175
+ };
134
176
  }
135
177
 
136
178
  /**
@@ -199,13 +241,14 @@ declare class ApiConnectionService {
199
241
  static ɵprov: i0.ɵɵInjectableDeclaration<ApiConnectionService>;
200
242
  }
201
243
 
202
- type AuthProvider = 'google' | 'linkedin' | 'apple' | 'microsoft' | 'github' | 'emailPassword';
244
+ type AuthProvider = 'google' | 'linkedin' | 'apple' | 'microsoft' | 'github' | 'zoho' | 'emailPassword';
203
245
  interface User {
204
- user_id: number;
246
+ user_id?: number;
247
+ id?: string;
205
248
  email: string;
206
- display_name: string;
249
+ display_name?: string;
207
250
  photo_url?: string;
208
- is_email_verified: boolean;
251
+ is_email_verified?: boolean;
209
252
  }
210
253
  interface AuthResult {
211
254
  success: boolean;
@@ -217,9 +260,59 @@ declare class AuthService {
217
260
  private signinStatus;
218
261
  private environment;
219
262
  private readonly USER_STORAGE_KEY;
263
+ private readonly ACTIVE_AUTH_SERVER_KEY;
220
264
  private userSubject;
221
265
  user$: Observable<User | null>;
266
+ private activeAuthServer;
222
267
  constructor(tokens: TokenService, signinStatus: SigninStatusService, environment: MyEnvironmentModel);
268
+ /**
269
+ * Get the current accounts URL based on configuration
270
+ * Supports both single-server (accountsUrl) and multi-server (authServers) modes
271
+ * @param serverName - Optional server name for multi-server mode
272
+ */
273
+ private getAccountsUrl;
274
+ /**
275
+ * Get the default auth server name
276
+ */
277
+ private getDefaultAuthServer;
278
+ /**
279
+ * Restore active auth server from localStorage
280
+ */
281
+ private restoreActiveAuthServer;
282
+ /**
283
+ * Save active auth server to localStorage
284
+ */
285
+ private saveActiveAuthServer;
286
+ /**
287
+ * Get available auth servers
288
+ * @returns Array of server names or empty array if using single-server mode
289
+ */
290
+ getAvailableAuthServers(): string[];
291
+ /**
292
+ * Get current active auth server name
293
+ * @returns Server name or null if using single-server mode
294
+ */
295
+ getActiveAuthServer(): string | null;
296
+ /**
297
+ * Switch to a different auth server
298
+ * @param serverName - Name of the server to switch to
299
+ * @throws Error if server not found in configuration
300
+ */
301
+ switchAuthServer(serverName: string): void;
302
+ /**
303
+ * Get auth server configuration
304
+ * @param serverName - Optional server name (uses active server if not specified)
305
+ */
306
+ getAuthServerConfig(serverName?: string): AuthServerConfig | null;
307
+ /**
308
+ * Check if multi-server mode is enabled
309
+ */
310
+ isMultiServerMode(): boolean;
311
+ /**
312
+ * Hash UUID to numeric ID for backward compatibility
313
+ * Converts UUID string to a consistent numeric ID for legacy code
314
+ */
315
+ private hashUUID;
223
316
  /**
224
317
  * Restore user from localStorage
225
318
  */
@@ -234,50 +327,72 @@ declare class AuthService {
234
327
  private updateUser;
235
328
  /**
236
329
  * Login with email and password
330
+ * @param email - User email
331
+ * @param password - User password
332
+ * @param serverName - Optional: Specify which auth server to use (for multi-server mode)
237
333
  */
238
- loginWithEmail(email: string, password: string): Promise<AuthResult>;
334
+ loginWithEmail(email: string, password: string, serverName?: string): Promise<AuthResult>;
239
335
  /**
240
336
  * Login with Google OAuth (popup window)
337
+ * @param serverName - Optional: Specify which auth server to use (for multi-server mode)
241
338
  */
242
- loginWithGoogle(): Promise<AuthResult>;
339
+ loginWithGoogle(serverName?: string): Promise<AuthResult>;
243
340
  /**
244
341
  * Login with GitHub OAuth (popup window)
342
+ * @param serverName - Optional: Specify which auth server to use (for multi-server mode)
245
343
  */
246
- loginWithGitHub(): Promise<AuthResult>;
344
+ loginWithGitHub(serverName?: string): Promise<AuthResult>;
247
345
  /**
248
346
  * Login with LinkedIn OAuth (popup window)
347
+ * @param serverName - Optional: Specify which auth server to use (for multi-server mode)
249
348
  */
250
- loginWithLinkedIn(): Promise<AuthResult>;
349
+ loginWithLinkedIn(serverName?: string): Promise<AuthResult>;
251
350
  /**
252
351
  * Login with Apple OAuth (popup window)
352
+ * @param serverName - Optional: Specify which auth server to use (for multi-server mode)
253
353
  */
254
- loginWithApple(): Promise<AuthResult>;
354
+ loginWithApple(serverName?: string): Promise<AuthResult>;
255
355
  /**
256
356
  * Login with Microsoft OAuth (popup window)
357
+ * @param serverName - Optional: Specify which auth server to use (for multi-server mode)
257
358
  */
258
- loginWithMicrosoft(): Promise<AuthResult>;
359
+ loginWithMicrosoft(serverName?: string): Promise<AuthResult>;
360
+ /**
361
+ * Login with Zoho OAuth (popup window)
362
+ * @param serverName - Optional: Specify which auth server to use (for multi-server mode)
363
+ */
364
+ loginWithZoho(serverName?: string): Promise<AuthResult>;
259
365
  /**
260
366
  * Generic provider-based login (supports all OAuth providers)
261
367
  * @param provider - The provider identifier
368
+ * @param serverName - Optional: Specify which auth server to use (for multi-server mode)
262
369
  */
263
- loginWithProvider(provider: AuthProvider): Promise<AuthResult>;
370
+ loginWithProvider(provider: AuthProvider, serverName?: string): Promise<AuthResult>;
264
371
  /**
265
372
  * Generic OAuth login handler
266
373
  * Opens popup window and listens for postMessage
374
+ * @param provider - OAuth provider name
375
+ * @param serverName - Optional: Specify which auth server to use (for multi-server mode)
267
376
  */
268
377
  private loginWithOAuth;
269
378
  /**
270
379
  * Register new user
380
+ * @param email - User email
381
+ * @param password - User password
382
+ * @param displayName - Display name
383
+ * @param serverName - Optional: Specify which auth server to use (for multi-server mode)
271
384
  */
272
- register(email: string, password: string, displayName: string): Promise<AuthResult>;
385
+ register(email: string, password: string, displayName: string, serverName?: string): Promise<AuthResult>;
273
386
  /**
274
387
  * Sign out user
388
+ * @param serverName - Optional: Specify which auth server to logout from (for multi-server mode)
275
389
  */
276
- signout(): Promise<void>;
390
+ signout(serverName?: string): Promise<void>;
277
391
  /**
278
392
  * Check for active session (call on app init)
393
+ * @param serverName - Optional: Specify which auth server to check (for multi-server mode)
279
394
  */
280
- checkSession(): Promise<boolean>;
395
+ checkSession(serverName?: string): Promise<boolean>;
281
396
  /**
282
397
  * Check if user is authenticated
283
398
  */
@@ -319,8 +434,9 @@ declare class AuthService {
319
434
  private registerTenantWithOAuth;
320
435
  /**
321
436
  * Get all tenant memberships for the authenticated user
437
+ * @param serverName - Optional: Specify which auth server to query (for multi-server mode)
322
438
  */
323
- getTenantMemberships(): Promise<{
439
+ getTenantMemberships(serverName?: string): Promise<{
324
440
  memberships: Array<{
325
441
  tenant_id: string;
326
442
  slug: string;
@@ -333,16 +449,20 @@ declare class AuthService {
333
449
  /**
334
450
  * Select a tenant for the current session
335
451
  * Updates the JWT token with tenant context
452
+ * @param tenantId - Tenant ID to select
453
+ * @param serverName - Optional: Specify which auth server to use (for multi-server mode)
336
454
  */
337
- selectTenant(tenantId: string): Promise<{
455
+ selectTenant(tenantId: string, serverName?: string): Promise<{
338
456
  success: boolean;
339
457
  message?: string;
340
458
  access_token?: string;
341
459
  }>;
342
460
  /**
343
461
  * Check if a tenant slug is available
462
+ * @param slug - Tenant slug to check
463
+ * @param serverName - Optional: Specify which auth server to query (for multi-server mode)
344
464
  */
345
- checkTenantSlugAvailable(slug: string): Promise<{
465
+ checkTenantSlugAvailable(slug: string, serverName?: string): Promise<{
346
466
  available: boolean;
347
467
  suggestion?: string;
348
468
  }>;
@@ -389,11 +509,13 @@ declare class AuthService {
389
509
  /**
390
510
  * @deprecated Check if user exists by calling /api/auth/check-email endpoint
391
511
  */
392
- getUserProfile(email: string): Promise<User | null>;
512
+ getUserProfile(email: string, serverName?: string): Promise<User | null>;
393
513
  /**
394
514
  * Check if user has completed onboarding (has a tenant)
515
+ * @param identityId - User identity ID
516
+ * @param serverName - Optional: Specify which auth server to query (for multi-server mode)
395
517
  */
396
- checkOnboardingStatus(identityId: string): Promise<{
518
+ checkOnboardingStatus(identityId: string, serverName?: string): Promise<{
397
519
  onboarded: boolean;
398
520
  tenant_slug?: string;
399
521
  tenant_name?: string;
@@ -401,8 +523,11 @@ declare class AuthService {
401
523
  }>;
402
524
  /**
403
525
  * Complete tenant onboarding (create tenant with country + org name)
526
+ * @param countryCode - Country code
527
+ * @param tenantName - Tenant organization name
528
+ * @param serverName - Optional: Specify which auth server to use (for multi-server mode)
404
529
  */
405
- completeTenantOnboarding(countryCode: string, tenantName: string): Promise<{
530
+ completeTenantOnboarding(countryCode: string, tenantName: string, serverName?: string): Promise<{
406
531
  tenant: {
407
532
  id: string;
408
533
  slug: string;
@@ -428,46 +553,6 @@ declare class NgxStoneScriptPhpClientModule {
428
553
  static ɵinj: i0.ɵɵInjectorDeclaration<NgxStoneScriptPhpClientModule>;
429
554
  }
430
555
 
431
- declare class LoginDialogComponent implements OnInit {
432
- private auth;
433
- /**
434
- * REQUIRED: Which authentication providers to show in this dialog
435
- * @example ['google', 'linkedin', 'emailPassword']
436
- */
437
- providers: AuthProvider[];
438
- email: string;
439
- password: string;
440
- error: string;
441
- loading: boolean;
442
- oauthProviders: AuthProvider[];
443
- constructor(auth: AuthService);
444
- ngOnInit(): void;
445
- isProviderEnabled(provider: AuthProvider): boolean;
446
- getProviderLabel(provider: AuthProvider): string;
447
- getProviderIcon(provider: AuthProvider): string | undefined;
448
- onEmailLogin(): Promise<void>;
449
- onOAuthLogin(provider: AuthProvider): Promise<void>;
450
- onRegisterClick(event: Event): void;
451
- static ɵfac: i0.ɵɵFactoryDeclaration<LoginDialogComponent, never>;
452
- static ɵcmp: i0.ɵɵComponentDeclaration<LoginDialogComponent, "lib-login-dialog", never, { "providers": { "alias": "providers"; "required": false; }; }, {}, never, never, true, never>;
453
- }
454
-
455
- declare class RegisterComponent {
456
- private auth;
457
- displayName: string;
458
- email: string;
459
- password: string;
460
- confirmPassword: string;
461
- error: string;
462
- success: string;
463
- loading: boolean;
464
- constructor(auth: AuthService);
465
- onRegister(): Promise<void>;
466
- onLoginClick(event: Event): void;
467
- static ɵfac: i0.ɵɵFactoryDeclaration<RegisterComponent, never>;
468
- static ɵcmp: i0.ɵɵComponentDeclaration<RegisterComponent, "lib-register", never, {}, {}, never, never, true, never>;
469
- }
470
-
471
556
  interface TenantMembership {
472
557
  tenant_id: string;
473
558
  slug: string;
@@ -487,6 +572,7 @@ declare class TenantLoginComponent implements OnInit {
487
572
  providers: AuthProvider[];
488
573
  showTenantSelector: boolean;
489
574
  autoSelectSingleTenant: boolean;
575
+ prefillEmail?: string;
490
576
  allowTenantCreation: boolean;
491
577
  tenantSelectorTitle: string;
492
578
  tenantSelectorDescription: string;
@@ -501,6 +587,7 @@ declare class TenantLoginComponent implements OnInit {
501
587
  password: string;
502
588
  error: string;
503
589
  loading: boolean;
590
+ showPassword: boolean;
504
591
  useOAuth: boolean;
505
592
  oauthProviders: AuthProvider[];
506
593
  showingTenantSelector: boolean;
@@ -523,7 +610,78 @@ declare class TenantLoginComponent implements OnInit {
523
610
  formatLastAccessed(dateStr: string): string;
524
611
  onCreateTenantClick(event: Event): void;
525
612
  static ɵfac: i0.ɵɵFactoryDeclaration<TenantLoginComponent, never>;
526
- static ɵcmp: i0.ɵɵComponentDeclaration<TenantLoginComponent, "lib-tenant-login", never, { "title": { "alias": "title"; "required": false; }; "providers": { "alias": "providers"; "required": false; }; "showTenantSelector": { "alias": "showTenantSelector"; "required": false; }; "autoSelectSingleTenant": { "alias": "autoSelectSingleTenant"; "required": false; }; "allowTenantCreation": { "alias": "allowTenantCreation"; "required": false; }; "tenantSelectorTitle": { "alias": "tenantSelectorTitle"; "required": false; }; "tenantSelectorDescription": { "alias": "tenantSelectorDescription"; "required": false; }; "continueButtonText": { "alias": "continueButtonText"; "required": false; }; "registerLinkText": { "alias": "registerLinkText"; "required": false; }; "registerLinkAction": { "alias": "registerLinkAction"; "required": false; }; "createTenantLinkText": { "alias": "createTenantLinkText"; "required": false; }; "createTenantLinkAction": { "alias": "createTenantLinkAction"; "required": false; }; }, { "tenantSelected": "tenantSelected"; "createTenant": "createTenant"; }, never, never, true, never>;
613
+ static ɵcmp: i0.ɵɵComponentDeclaration<TenantLoginComponent, "lib-tenant-login", never, { "title": { "alias": "title"; "required": false; }; "providers": { "alias": "providers"; "required": false; }; "showTenantSelector": { "alias": "showTenantSelector"; "required": false; }; "autoSelectSingleTenant": { "alias": "autoSelectSingleTenant"; "required": false; }; "prefillEmail": { "alias": "prefillEmail"; "required": false; }; "allowTenantCreation": { "alias": "allowTenantCreation"; "required": false; }; "tenantSelectorTitle": { "alias": "tenantSelectorTitle"; "required": false; }; "tenantSelectorDescription": { "alias": "tenantSelectorDescription"; "required": false; }; "continueButtonText": { "alias": "continueButtonText"; "required": false; }; "registerLinkText": { "alias": "registerLinkText"; "required": false; }; "registerLinkAction": { "alias": "registerLinkAction"; "required": false; }; "createTenantLinkText": { "alias": "createTenantLinkText"; "required": false; }; "createTenantLinkAction": { "alias": "createTenantLinkAction"; "required": false; }; }, { "tenantSelected": "tenantSelected"; "createTenant": "createTenant"; }, never, never, true, never>;
614
+ }
615
+
616
+ declare class AuthPageComponent implements OnInit {
617
+ private environment;
618
+ providers: AuthProvider[];
619
+ authenticated: EventEmitter<TenantSelectedEvent>;
620
+ mode: 'login' | 'register';
621
+ appName: string;
622
+ logo?: string;
623
+ subtitle?: string;
624
+ gradientStyle: string;
625
+ constructor(environment: MyEnvironmentModel);
626
+ ngOnInit(): void;
627
+ onAuthenticated(event: TenantSelectedEvent): void;
628
+ /**
629
+ * Adjust color brightness (simple implementation)
630
+ * @param color Hex color (e.g., '#667eea')
631
+ * @param percent Percentage to darken (negative) or lighten (positive)
632
+ */
633
+ private adjustColor;
634
+ static ɵfac: i0.ɵɵFactoryDeclaration<AuthPageComponent, never>;
635
+ static ɵcmp: i0.ɵɵComponentDeclaration<AuthPageComponent, "lib-auth-page", never, { "providers": { "alias": "providers"; "required": false; }; }, { "authenticated": "authenticated"; }, never, never, true, never>;
636
+ }
637
+
638
+ declare class LoginDialogComponent implements OnInit {
639
+ private auth;
640
+ /**
641
+ * REQUIRED: Which authentication providers to show in this dialog
642
+ * @example ['google', 'linkedin', 'emailPassword']
643
+ */
644
+ providers: AuthProvider[];
645
+ email: string;
646
+ password: string;
647
+ error: string;
648
+ loading: boolean;
649
+ showPassword: boolean;
650
+ oauthProviders: AuthProvider[];
651
+ constructor(auth: AuthService);
652
+ ngOnInit(): void;
653
+ isProviderEnabled(provider: AuthProvider): boolean;
654
+ getProviderLabel(provider: AuthProvider): string;
655
+ getProviderIcon(provider: AuthProvider): string | undefined;
656
+ onEmailLogin(): Promise<void>;
657
+ onOAuthLogin(provider: AuthProvider): Promise<void>;
658
+ onRegisterClick(event: Event): void;
659
+ static ɵfac: i0.ɵɵFactoryDeclaration<LoginDialogComponent, never>;
660
+ static ɵcmp: i0.ɵɵComponentDeclaration<LoginDialogComponent, "lib-login-dialog", never, { "providers": { "alias": "providers"; "required": false; }; }, {}, never, never, true, never>;
661
+ }
662
+
663
+ declare class RegisterComponent {
664
+ private auth;
665
+ private environment;
666
+ navigateToLogin: EventEmitter<string>;
667
+ displayName: string;
668
+ email: string;
669
+ password: string;
670
+ confirmPassword: string;
671
+ error: string;
672
+ success: string;
673
+ loading: boolean;
674
+ showAccountLinkPrompt: boolean;
675
+ existingEmail: string;
676
+ showPassword: boolean;
677
+ showConfirmPassword: boolean;
678
+ constructor(auth: AuthService, environment: MyEnvironmentModel);
679
+ onRegister(): Promise<void>;
680
+ onLoginClick(event: Event): void;
681
+ linkExistingAccount(): void;
682
+ cancelLinking(): void;
683
+ static ɵfac: i0.ɵɵFactoryDeclaration<RegisterComponent, never>;
684
+ static ɵcmp: i0.ɵɵComponentDeclaration<RegisterComponent, "lib-register", never, {}, { "navigateToLogin": "navigateToLogin"; }, never, never, true, never>;
527
685
  }
528
686
 
529
687
  interface TenantCreatedEvent {
@@ -574,6 +732,8 @@ declare class TenantRegisterComponent implements OnInit {
574
732
  slugError: string;
575
733
  useEmailPassword: boolean;
576
734
  oauthProviders: AuthProvider[];
735
+ showPassword: boolean;
736
+ showConfirmPassword: boolean;
577
737
  constructor(auth: AuthService);
578
738
  ngOnInit(): void;
579
739
  isProviderEnabled(provider: AuthProvider): boolean;
@@ -666,5 +826,5 @@ declare class TenantRegisterDialogComponent {
666
826
  static ɵcmp: i0.ɵɵComponentDeclaration<TenantRegisterDialogComponent, "lib-tenant-register-dialog", never, {}, {}, never, never, true, never>;
667
827
  }
668
828
 
669
- export { ApiConnectionService, ApiResponse, AuthService, CsrfService, DbService, LoginDialogComponent, MyEnvironmentModel, NgxStoneScriptPhpClientModule, RegisterComponent, SigninStatusService, TenantLoginComponent, TenantLoginDialogComponent, TenantRegisterComponent, TenantRegisterDialogComponent, TokenService, VerifyStatus };
670
- export type { AuthConfig, AuthMode, AuthProvider, AuthResult, TenantCreatedEvent, TenantMembership, TenantSelectedEvent, User };
829
+ export { ApiConnectionService, ApiResponse, AuthPageComponent, AuthService, CsrfService, DbService, LoginDialogComponent, MyEnvironmentModel, NgxStoneScriptPhpClientModule, RegisterComponent, SigninStatusService, TenantLoginComponent, TenantLoginDialogComponent, TenantRegisterComponent, TenantRegisterDialogComponent, TokenService, VerifyStatus };
830
+ export type { AuthConfig, AuthMode, AuthProvider, AuthResult, AuthServerConfig, TenantCreatedEvent, TenantMembership, TenantSelectedEvent, User };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@progalaxyelabs/ngx-stonescriptphp-client",
3
- "version": "1.3.1",
3
+ "version": "1.5.0",
4
4
  "description": "Angular client library for StoneScriptPHP backend framework",
5
5
  "keywords": [
6
6
  "angular",