@progalaxyelabs/ngx-stonescriptphp-client 1.4.0 → 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;
@@ -217,13 +241,14 @@ declare class ApiConnectionService {
217
241
  static ɵprov: i0.ɵɵInjectableDeclaration<ApiConnectionService>;
218
242
  }
219
243
 
220
- type AuthProvider = 'google' | 'linkedin' | 'apple' | 'microsoft' | 'github' | 'emailPassword';
244
+ type AuthProvider = 'google' | 'linkedin' | 'apple' | 'microsoft' | 'github' | 'zoho' | 'emailPassword';
221
245
  interface User {
222
- user_id: number;
246
+ user_id?: number;
247
+ id?: string;
223
248
  email: string;
224
- display_name: string;
249
+ display_name?: string;
225
250
  photo_url?: string;
226
- is_email_verified: boolean;
251
+ is_email_verified?: boolean;
227
252
  }
228
253
  interface AuthResult {
229
254
  success: boolean;
@@ -235,9 +260,59 @@ declare class AuthService {
235
260
  private signinStatus;
236
261
  private environment;
237
262
  private readonly USER_STORAGE_KEY;
263
+ private readonly ACTIVE_AUTH_SERVER_KEY;
238
264
  private userSubject;
239
265
  user$: Observable<User | null>;
266
+ private activeAuthServer;
240
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;
241
316
  /**
242
317
  * Restore user from localStorage
243
318
  */
@@ -252,50 +327,72 @@ declare class AuthService {
252
327
  private updateUser;
253
328
  /**
254
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)
255
333
  */
256
- loginWithEmail(email: string, password: string): Promise<AuthResult>;
334
+ loginWithEmail(email: string, password: string, serverName?: string): Promise<AuthResult>;
257
335
  /**
258
336
  * Login with Google OAuth (popup window)
337
+ * @param serverName - Optional: Specify which auth server to use (for multi-server mode)
259
338
  */
260
- loginWithGoogle(): Promise<AuthResult>;
339
+ loginWithGoogle(serverName?: string): Promise<AuthResult>;
261
340
  /**
262
341
  * Login with GitHub OAuth (popup window)
342
+ * @param serverName - Optional: Specify which auth server to use (for multi-server mode)
263
343
  */
264
- loginWithGitHub(): Promise<AuthResult>;
344
+ loginWithGitHub(serverName?: string): Promise<AuthResult>;
265
345
  /**
266
346
  * Login with LinkedIn OAuth (popup window)
347
+ * @param serverName - Optional: Specify which auth server to use (for multi-server mode)
267
348
  */
268
- loginWithLinkedIn(): Promise<AuthResult>;
349
+ loginWithLinkedIn(serverName?: string): Promise<AuthResult>;
269
350
  /**
270
351
  * Login with Apple OAuth (popup window)
352
+ * @param serverName - Optional: Specify which auth server to use (for multi-server mode)
271
353
  */
272
- loginWithApple(): Promise<AuthResult>;
354
+ loginWithApple(serverName?: string): Promise<AuthResult>;
273
355
  /**
274
356
  * Login with Microsoft OAuth (popup window)
357
+ * @param serverName - Optional: Specify which auth server to use (for multi-server mode)
358
+ */
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)
275
363
  */
276
- loginWithMicrosoft(): Promise<AuthResult>;
364
+ loginWithZoho(serverName?: string): Promise<AuthResult>;
277
365
  /**
278
366
  * Generic provider-based login (supports all OAuth providers)
279
367
  * @param provider - The provider identifier
368
+ * @param serverName - Optional: Specify which auth server to use (for multi-server mode)
280
369
  */
281
- loginWithProvider(provider: AuthProvider): Promise<AuthResult>;
370
+ loginWithProvider(provider: AuthProvider, serverName?: string): Promise<AuthResult>;
282
371
  /**
283
372
  * Generic OAuth login handler
284
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)
285
376
  */
286
377
  private loginWithOAuth;
287
378
  /**
288
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)
289
384
  */
290
- register(email: string, password: string, displayName: string): Promise<AuthResult>;
385
+ register(email: string, password: string, displayName: string, serverName?: string): Promise<AuthResult>;
291
386
  /**
292
387
  * Sign out user
388
+ * @param serverName - Optional: Specify which auth server to logout from (for multi-server mode)
293
389
  */
294
- signout(): Promise<void>;
390
+ signout(serverName?: string): Promise<void>;
295
391
  /**
296
392
  * Check for active session (call on app init)
393
+ * @param serverName - Optional: Specify which auth server to check (for multi-server mode)
297
394
  */
298
- checkSession(): Promise<boolean>;
395
+ checkSession(serverName?: string): Promise<boolean>;
299
396
  /**
300
397
  * Check if user is authenticated
301
398
  */
@@ -337,8 +434,9 @@ declare class AuthService {
337
434
  private registerTenantWithOAuth;
338
435
  /**
339
436
  * Get all tenant memberships for the authenticated user
437
+ * @param serverName - Optional: Specify which auth server to query (for multi-server mode)
340
438
  */
341
- getTenantMemberships(): Promise<{
439
+ getTenantMemberships(serverName?: string): Promise<{
342
440
  memberships: Array<{
343
441
  tenant_id: string;
344
442
  slug: string;
@@ -351,16 +449,20 @@ declare class AuthService {
351
449
  /**
352
450
  * Select a tenant for the current session
353
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)
354
454
  */
355
- selectTenant(tenantId: string): Promise<{
455
+ selectTenant(tenantId: string, serverName?: string): Promise<{
356
456
  success: boolean;
357
457
  message?: string;
358
458
  access_token?: string;
359
459
  }>;
360
460
  /**
361
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)
362
464
  */
363
- checkTenantSlugAvailable(slug: string): Promise<{
465
+ checkTenantSlugAvailable(slug: string, serverName?: string): Promise<{
364
466
  available: boolean;
365
467
  suggestion?: string;
366
468
  }>;
@@ -407,11 +509,13 @@ declare class AuthService {
407
509
  /**
408
510
  * @deprecated Check if user exists by calling /api/auth/check-email endpoint
409
511
  */
410
- getUserProfile(email: string): Promise<User | null>;
512
+ getUserProfile(email: string, serverName?: string): Promise<User | null>;
411
513
  /**
412
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)
413
517
  */
414
- checkOnboardingStatus(identityId: string): Promise<{
518
+ checkOnboardingStatus(identityId: string, serverName?: string): Promise<{
415
519
  onboarded: boolean;
416
520
  tenant_slug?: string;
417
521
  tenant_name?: string;
@@ -419,8 +523,11 @@ declare class AuthService {
419
523
  }>;
420
524
  /**
421
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)
422
529
  */
423
- completeTenantOnboarding(countryCode: string, tenantName: string): Promise<{
530
+ completeTenantOnboarding(countryCode: string, tenantName: string, serverName?: string): Promise<{
424
531
  tenant: {
425
532
  id: string;
426
533
  slug: string;
@@ -720,4 +827,4 @@ declare class TenantRegisterDialogComponent {
720
827
  }
721
828
 
722
829
  export { ApiConnectionService, ApiResponse, AuthPageComponent, AuthService, CsrfService, DbService, LoginDialogComponent, MyEnvironmentModel, NgxStoneScriptPhpClientModule, RegisterComponent, SigninStatusService, TenantLoginComponent, TenantLoginDialogComponent, TenantRegisterComponent, TenantRegisterDialogComponent, TokenService, VerifyStatus };
723
- export type { AuthConfig, AuthMode, AuthProvider, AuthResult, TenantCreatedEvent, TenantMembership, TenantSelectedEvent, User };
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.4.0",
3
+ "version": "1.5.0",
4
4
  "description": "Angular client library for StoneScriptPHP backend framework",
5
5
  "keywords": [
6
6
  "angular",