@progalaxyelabs/ngx-stonescriptphp-client 1.2.0 → 1.3.1
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
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { ModuleWithProviders, OnInit } from '@angular/core';
|
|
2
|
+
import { ModuleWithProviders, OnInit, EventEmitter } from '@angular/core';
|
|
3
3
|
import { BehaviorSubject, Observable } from 'rxjs';
|
|
4
4
|
import * as i1 from '@angular/common';
|
|
5
5
|
|
|
@@ -216,9 +216,22 @@ declare class AuthService {
|
|
|
216
216
|
private tokens;
|
|
217
217
|
private signinStatus;
|
|
218
218
|
private environment;
|
|
219
|
+
private readonly USER_STORAGE_KEY;
|
|
219
220
|
private userSubject;
|
|
220
221
|
user$: Observable<User | null>;
|
|
221
222
|
constructor(tokens: TokenService, signinStatus: SigninStatusService, environment: MyEnvironmentModel);
|
|
223
|
+
/**
|
|
224
|
+
* Restore user from localStorage
|
|
225
|
+
*/
|
|
226
|
+
private restoreUser;
|
|
227
|
+
/**
|
|
228
|
+
* Save user to localStorage
|
|
229
|
+
*/
|
|
230
|
+
private saveUser;
|
|
231
|
+
/**
|
|
232
|
+
* Update user subject and persist to localStorage
|
|
233
|
+
*/
|
|
234
|
+
private updateUser;
|
|
222
235
|
/**
|
|
223
236
|
* Login with email and password
|
|
224
237
|
*/
|
|
@@ -273,6 +286,66 @@ declare class AuthService {
|
|
|
273
286
|
* Get current user (synchronous)
|
|
274
287
|
*/
|
|
275
288
|
getCurrentUser(): User | null;
|
|
289
|
+
/**
|
|
290
|
+
* Register a new user AND create a new tenant (organization)
|
|
291
|
+
* This is used when a user wants to create their own organization
|
|
292
|
+
*/
|
|
293
|
+
registerTenant(data: {
|
|
294
|
+
tenantName: string;
|
|
295
|
+
tenantSlug: string;
|
|
296
|
+
displayName?: string;
|
|
297
|
+
email?: string;
|
|
298
|
+
password?: string;
|
|
299
|
+
provider: AuthProvider;
|
|
300
|
+
}): Promise<{
|
|
301
|
+
success: boolean;
|
|
302
|
+
message?: string;
|
|
303
|
+
tenant?: {
|
|
304
|
+
id: string;
|
|
305
|
+
name: string;
|
|
306
|
+
slug: string;
|
|
307
|
+
};
|
|
308
|
+
user?: {
|
|
309
|
+
id: string;
|
|
310
|
+
email: string;
|
|
311
|
+
name: string;
|
|
312
|
+
};
|
|
313
|
+
access_token?: string;
|
|
314
|
+
}>;
|
|
315
|
+
/**
|
|
316
|
+
* Register tenant with OAuth provider
|
|
317
|
+
* Opens popup window for OAuth flow
|
|
318
|
+
*/
|
|
319
|
+
private registerTenantWithOAuth;
|
|
320
|
+
/**
|
|
321
|
+
* Get all tenant memberships for the authenticated user
|
|
322
|
+
*/
|
|
323
|
+
getTenantMemberships(): Promise<{
|
|
324
|
+
memberships: Array<{
|
|
325
|
+
tenant_id: string;
|
|
326
|
+
slug: string;
|
|
327
|
+
name: string;
|
|
328
|
+
role: string;
|
|
329
|
+
status: string;
|
|
330
|
+
last_accessed?: string;
|
|
331
|
+
}>;
|
|
332
|
+
}>;
|
|
333
|
+
/**
|
|
334
|
+
* Select a tenant for the current session
|
|
335
|
+
* Updates the JWT token with tenant context
|
|
336
|
+
*/
|
|
337
|
+
selectTenant(tenantId: string): Promise<{
|
|
338
|
+
success: boolean;
|
|
339
|
+
message?: string;
|
|
340
|
+
access_token?: string;
|
|
341
|
+
}>;
|
|
342
|
+
/**
|
|
343
|
+
* Check if a tenant slug is available
|
|
344
|
+
*/
|
|
345
|
+
checkTenantSlugAvailable(slug: string): Promise<{
|
|
346
|
+
available: boolean;
|
|
347
|
+
suggestion?: string;
|
|
348
|
+
}>;
|
|
276
349
|
/**
|
|
277
350
|
* @deprecated Use getCurrentUser()?.user_id instead
|
|
278
351
|
*/
|
|
@@ -317,6 +390,27 @@ declare class AuthService {
|
|
|
317
390
|
* @deprecated Check if user exists by calling /api/auth/check-email endpoint
|
|
318
391
|
*/
|
|
319
392
|
getUserProfile(email: string): Promise<User | null>;
|
|
393
|
+
/**
|
|
394
|
+
* Check if user has completed onboarding (has a tenant)
|
|
395
|
+
*/
|
|
396
|
+
checkOnboardingStatus(identityId: string): Promise<{
|
|
397
|
+
onboarded: boolean;
|
|
398
|
+
tenant_slug?: string;
|
|
399
|
+
tenant_name?: string;
|
|
400
|
+
role?: string;
|
|
401
|
+
}>;
|
|
402
|
+
/**
|
|
403
|
+
* Complete tenant onboarding (create tenant with country + org name)
|
|
404
|
+
*/
|
|
405
|
+
completeTenantOnboarding(countryCode: string, tenantName: string): Promise<{
|
|
406
|
+
tenant: {
|
|
407
|
+
id: string;
|
|
408
|
+
slug: string;
|
|
409
|
+
name: string;
|
|
410
|
+
};
|
|
411
|
+
access_token: string;
|
|
412
|
+
refresh_token: string;
|
|
413
|
+
}>;
|
|
320
414
|
static ɵfac: i0.ɵɵFactoryDeclaration<AuthService, never>;
|
|
321
415
|
static ɵprov: i0.ɵɵInjectableDeclaration<AuthService>;
|
|
322
416
|
}
|
|
@@ -374,5 +468,203 @@ declare class RegisterComponent {
|
|
|
374
468
|
static ɵcmp: i0.ɵɵComponentDeclaration<RegisterComponent, "lib-register", never, {}, {}, never, never, true, never>;
|
|
375
469
|
}
|
|
376
470
|
|
|
377
|
-
|
|
378
|
-
|
|
471
|
+
interface TenantMembership {
|
|
472
|
+
tenant_id: string;
|
|
473
|
+
slug: string;
|
|
474
|
+
name: string;
|
|
475
|
+
role: string;
|
|
476
|
+
status: string;
|
|
477
|
+
last_accessed?: string;
|
|
478
|
+
}
|
|
479
|
+
interface TenantSelectedEvent {
|
|
480
|
+
tenantId: string;
|
|
481
|
+
tenantSlug: string;
|
|
482
|
+
role: string;
|
|
483
|
+
}
|
|
484
|
+
declare class TenantLoginComponent implements OnInit {
|
|
485
|
+
private auth;
|
|
486
|
+
title: string;
|
|
487
|
+
providers: AuthProvider[];
|
|
488
|
+
showTenantSelector: boolean;
|
|
489
|
+
autoSelectSingleTenant: boolean;
|
|
490
|
+
allowTenantCreation: boolean;
|
|
491
|
+
tenantSelectorTitle: string;
|
|
492
|
+
tenantSelectorDescription: string;
|
|
493
|
+
continueButtonText: string;
|
|
494
|
+
registerLinkText: string;
|
|
495
|
+
registerLinkAction: string;
|
|
496
|
+
createTenantLinkText: string;
|
|
497
|
+
createTenantLinkAction: string;
|
|
498
|
+
tenantSelected: EventEmitter<TenantSelectedEvent>;
|
|
499
|
+
createTenant: EventEmitter<void>;
|
|
500
|
+
email: string;
|
|
501
|
+
password: string;
|
|
502
|
+
error: string;
|
|
503
|
+
loading: boolean;
|
|
504
|
+
useOAuth: boolean;
|
|
505
|
+
oauthProviders: AuthProvider[];
|
|
506
|
+
showingTenantSelector: boolean;
|
|
507
|
+
memberships: TenantMembership[];
|
|
508
|
+
selectedTenantId: string | null;
|
|
509
|
+
userName: string;
|
|
510
|
+
constructor(auth: AuthService);
|
|
511
|
+
ngOnInit(): void;
|
|
512
|
+
isProviderEnabled(provider: AuthProvider): boolean;
|
|
513
|
+
getProviderLabel(provider: AuthProvider): string;
|
|
514
|
+
getProviderIcon(provider: AuthProvider): string | undefined;
|
|
515
|
+
toggleAuthMethod(event: Event): void;
|
|
516
|
+
onEmailLogin(): Promise<void>;
|
|
517
|
+
onOAuthLogin(provider: AuthProvider): Promise<void>;
|
|
518
|
+
handlePostAuthFlow(): Promise<void>;
|
|
519
|
+
selectTenantItem(tenantId: string): void;
|
|
520
|
+
onContinueWithTenant(): Promise<void>;
|
|
521
|
+
selectAndContinue(membership: TenantMembership): Promise<void>;
|
|
522
|
+
formatRole(role: string): string;
|
|
523
|
+
formatLastAccessed(dateStr: string): string;
|
|
524
|
+
onCreateTenantClick(event: Event): void;
|
|
525
|
+
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>;
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
interface TenantCreatedEvent {
|
|
530
|
+
tenant: {
|
|
531
|
+
id: string;
|
|
532
|
+
name: string;
|
|
533
|
+
slug: string;
|
|
534
|
+
};
|
|
535
|
+
user: {
|
|
536
|
+
id: string;
|
|
537
|
+
email: string;
|
|
538
|
+
name: string;
|
|
539
|
+
};
|
|
540
|
+
}
|
|
541
|
+
declare class TenantRegisterComponent implements OnInit {
|
|
542
|
+
private auth;
|
|
543
|
+
title: string;
|
|
544
|
+
providers: AuthProvider[];
|
|
545
|
+
requireTenantName: boolean;
|
|
546
|
+
tenantSectionTitle: string;
|
|
547
|
+
tenantNameLabel: string;
|
|
548
|
+
tenantNamePlaceholder: string;
|
|
549
|
+
tenantSlugLabel: string;
|
|
550
|
+
tenantSlugPlaceholder: string;
|
|
551
|
+
urlPreviewEnabled: boolean;
|
|
552
|
+
urlPreviewPrefix: string;
|
|
553
|
+
userSectionTitle: string;
|
|
554
|
+
oauthDescription: string;
|
|
555
|
+
ownershipTitle: string;
|
|
556
|
+
ownershipMessage: string;
|
|
557
|
+
submitButtonText: string;
|
|
558
|
+
loginLinkText: string;
|
|
559
|
+
loginLinkAction: string;
|
|
560
|
+
tenantCreated: EventEmitter<TenantCreatedEvent>;
|
|
561
|
+
navigateToLogin: EventEmitter<void>;
|
|
562
|
+
tenantName: string;
|
|
563
|
+
tenantSlug: string;
|
|
564
|
+
displayName: string;
|
|
565
|
+
email: string;
|
|
566
|
+
password: string;
|
|
567
|
+
confirmPassword: string;
|
|
568
|
+
error: string;
|
|
569
|
+
success: string;
|
|
570
|
+
loading: boolean;
|
|
571
|
+
loadingText: string;
|
|
572
|
+
checkingSlug: boolean;
|
|
573
|
+
slugAvailable: boolean;
|
|
574
|
+
slugError: string;
|
|
575
|
+
useEmailPassword: boolean;
|
|
576
|
+
oauthProviders: AuthProvider[];
|
|
577
|
+
constructor(auth: AuthService);
|
|
578
|
+
ngOnInit(): void;
|
|
579
|
+
isProviderEnabled(provider: AuthProvider): boolean;
|
|
580
|
+
getProviderLabel(provider: AuthProvider): string;
|
|
581
|
+
getProviderIcon(provider: AuthProvider): string | undefined;
|
|
582
|
+
onTenantNameChange(): void;
|
|
583
|
+
checkSlugAvailability(): Promise<void>;
|
|
584
|
+
toggleAuthMethod(event: Event): void;
|
|
585
|
+
isFormValid(): boolean;
|
|
586
|
+
onOAuthRegister(provider: AuthProvider): Promise<void>;
|
|
587
|
+
onRegister(): Promise<void>;
|
|
588
|
+
onLoginClick(event: Event): void;
|
|
589
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<TenantRegisterComponent, never>;
|
|
590
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<TenantRegisterComponent, "lib-tenant-register", never, { "title": { "alias": "title"; "required": false; }; "providers": { "alias": "providers"; "required": false; }; "requireTenantName": { "alias": "requireTenantName"; "required": false; }; "tenantSectionTitle": { "alias": "tenantSectionTitle"; "required": false; }; "tenantNameLabel": { "alias": "tenantNameLabel"; "required": false; }; "tenantNamePlaceholder": { "alias": "tenantNamePlaceholder"; "required": false; }; "tenantSlugLabel": { "alias": "tenantSlugLabel"; "required": false; }; "tenantSlugPlaceholder": { "alias": "tenantSlugPlaceholder"; "required": false; }; "urlPreviewEnabled": { "alias": "urlPreviewEnabled"; "required": false; }; "urlPreviewPrefix": { "alias": "urlPreviewPrefix"; "required": false; }; "userSectionTitle": { "alias": "userSectionTitle"; "required": false; }; "oauthDescription": { "alias": "oauthDescription"; "required": false; }; "ownershipTitle": { "alias": "ownershipTitle"; "required": false; }; "ownershipMessage": { "alias": "ownershipMessage"; "required": false; }; "submitButtonText": { "alias": "submitButtonText"; "required": false; }; "loginLinkText": { "alias": "loginLinkText"; "required": false; }; "loginLinkAction": { "alias": "loginLinkAction"; "required": false; }; }, { "tenantCreated": "tenantCreated"; "navigateToLogin": "navigateToLogin"; }, never, never, true, never>;
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
/**
|
|
594
|
+
* Dialog wrapper for TenantLoginComponent
|
|
595
|
+
*
|
|
596
|
+
* Usage with Angular Material Dialog:
|
|
597
|
+
* ```typescript
|
|
598
|
+
* const dialogRef = this.dialog.open(TenantLoginDialogComponent, {
|
|
599
|
+
* width: '450px',
|
|
600
|
+
* data: {
|
|
601
|
+
* providers: ['google'],
|
|
602
|
+
* showTenantSelector: true
|
|
603
|
+
* }
|
|
604
|
+
* });
|
|
605
|
+
*
|
|
606
|
+
* dialogRef.afterClosed().subscribe(result => {
|
|
607
|
+
* if (result && result.tenantId) {
|
|
608
|
+
* console.log('Logged in to tenant:', result.tenantSlug);
|
|
609
|
+
* // Redirect to dashboard
|
|
610
|
+
* }
|
|
611
|
+
* });
|
|
612
|
+
* ```
|
|
613
|
+
*
|
|
614
|
+
* Usage with custom dialog service:
|
|
615
|
+
* ```typescript
|
|
616
|
+
* const dialog = this.dialogService.open(TenantLoginDialogComponent, {
|
|
617
|
+
* providers: ['google', 'emailPassword'],
|
|
618
|
+
* autoSelectSingleTenant: true
|
|
619
|
+
* });
|
|
620
|
+
* ```
|
|
621
|
+
*/
|
|
622
|
+
declare class TenantLoginDialogComponent {
|
|
623
|
+
data: any;
|
|
624
|
+
dialogRef: any;
|
|
625
|
+
constructor(injectedData?: any, injectedDialogRef?: any);
|
|
626
|
+
onTenantSelected(event: TenantSelectedEvent): void;
|
|
627
|
+
onCreateTenant(): void;
|
|
628
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<TenantLoginDialogComponent, [{ optional: true; }, { optional: true; }]>;
|
|
629
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<TenantLoginDialogComponent, "lib-tenant-login-dialog", never, {}, {}, never, never, true, never>;
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
/**
|
|
633
|
+
* Dialog wrapper for TenantRegisterComponent
|
|
634
|
+
*
|
|
635
|
+
* Usage with Angular Material Dialog:
|
|
636
|
+
* ```typescript
|
|
637
|
+
* const dialogRef = this.dialog.open(TenantRegisterDialogComponent, {
|
|
638
|
+
* width: '500px',
|
|
639
|
+
* data: {
|
|
640
|
+
* providers: ['google'],
|
|
641
|
+
* tenantNameLabel: 'Store Name'
|
|
642
|
+
* }
|
|
643
|
+
* });
|
|
644
|
+
*
|
|
645
|
+
* dialogRef.afterClosed().subscribe(result => {
|
|
646
|
+
* if (result && result.tenant) {
|
|
647
|
+
* console.log('Tenant created:', result.tenant);
|
|
648
|
+
* }
|
|
649
|
+
* });
|
|
650
|
+
* ```
|
|
651
|
+
*
|
|
652
|
+
* Usage with custom dialog service:
|
|
653
|
+
* ```typescript
|
|
654
|
+
* const dialog = this.dialogService.open(TenantRegisterDialogComponent, {
|
|
655
|
+
* providers: ['google', 'emailPassword']
|
|
656
|
+
* });
|
|
657
|
+
* ```
|
|
658
|
+
*/
|
|
659
|
+
declare class TenantRegisterDialogComponent {
|
|
660
|
+
data: any;
|
|
661
|
+
dialogRef: any;
|
|
662
|
+
constructor(injectedData?: any, injectedDialogRef?: any);
|
|
663
|
+
onTenantCreated(event: TenantCreatedEvent): void;
|
|
664
|
+
onNavigateToLogin(): void;
|
|
665
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<TenantRegisterDialogComponent, [{ optional: true; }, { optional: true; }]>;
|
|
666
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<TenantRegisterDialogComponent, "lib-tenant-register-dialog", never, {}, {}, never, never, true, never>;
|
|
667
|
+
}
|
|
668
|
+
|
|
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 };
|