@progalaxyelabs/ngx-stonescriptphp-client 1.9.0 → 1.10.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.
@@ -200,6 +200,12 @@ class MyEnvironmentModel {
200
200
  messagingSenderId: '',
201
201
  measurementId: ''
202
202
  };
203
+ /**
204
+ * Platform's own API base URL (e.g., '//api.medstoreapp.in')
205
+ * Used to route registration through the platform API proxy instead of auth directly
206
+ * @example '//api.medstoreapp.in'
207
+ */
208
+ apiUrl;
203
209
  apiServer = { host: '' };
204
210
  chatServer = { host: '' };
205
211
  /**
@@ -775,6 +781,20 @@ class AuthService {
775
781
  isMultiServerMode() {
776
782
  return !!(this.environment.authServers && Object.keys(this.environment.authServers).length > 0);
777
783
  }
784
+ /**
785
+ * Get the platform's own API base URL
786
+ * Used for routes that go through the platform API proxy (e.g. register-tenant)
787
+ * @throws Error if no API URL is configured
788
+ */
789
+ getPlatformApiUrl() {
790
+ if (this.environment.apiUrl) {
791
+ return this.environment.apiUrl;
792
+ }
793
+ if (this.environment.apiServer?.host) {
794
+ return this.environment.apiServer.host;
795
+ }
796
+ throw new Error('No platform API URL configured. Set apiUrl in environment config.');
797
+ }
778
798
  /**
779
799
  * Hash UUID to numeric ID for backward compatibility
780
800
  * Converts UUID string to a consistent numeric ID for legacy code
@@ -1150,9 +1170,9 @@ class AuthService {
1150
1170
  if (data.provider !== 'emailPassword') {
1151
1171
  return await this.registerTenantWithOAuth(data.tenantName, data.tenantSlug, data.provider);
1152
1172
  }
1153
- // Email/password registration
1154
- const accountsUrl = this.getAccountsUrl();
1155
- const response = await fetch(`${accountsUrl}/api/auth/register-tenant`, {
1173
+ // Email/password registration — route through platform API proxy
1174
+ const apiUrl = this.getPlatformApiUrl();
1175
+ const response = await fetch(`${apiUrl}/auth/register-tenant`, {
1156
1176
  method: 'POST',
1157
1177
  headers: { 'Content-Type': 'application/json' },
1158
1178
  credentials: 'include',
@@ -1475,8 +1495,9 @@ class AuthService {
1475
1495
  if (!accessToken) {
1476
1496
  throw new Error('Not authenticated');
1477
1497
  }
1478
- const accountsUrl = this.getAccountsUrl(serverName);
1479
- const response = await fetch(`${accountsUrl}/api/auth/register-tenant`, {
1498
+ // Route through platform API proxy — PHP API adds platform_secret header
1499
+ const apiUrl = this.getPlatformApiUrl();
1500
+ const response = await fetch(`${apiUrl}/auth/register-tenant`, {
1480
1501
  method: 'POST',
1481
1502
  headers: {
1482
1503
  'Content-Type': 'application/json',