@progalaxyelabs/ngx-stonescriptphp-client 1.8.2 → 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.
|
@@ -10,9 +10,15 @@ class ApiResponse {
|
|
|
10
10
|
status;
|
|
11
11
|
data;
|
|
12
12
|
message;
|
|
13
|
-
|
|
13
|
+
get success() {
|
|
14
|
+
return this.status === 'ok';
|
|
15
|
+
}
|
|
16
|
+
get errors() {
|
|
17
|
+
return this.message ? [this.message] : [];
|
|
18
|
+
}
|
|
19
|
+
constructor(status, data = null, message = '') {
|
|
14
20
|
this.status = status;
|
|
15
|
-
this.data = data;
|
|
21
|
+
this.data = data || null;
|
|
16
22
|
this.message = message;
|
|
17
23
|
}
|
|
18
24
|
onOk(callback) {
|
|
@@ -194,6 +200,12 @@ class MyEnvironmentModel {
|
|
|
194
200
|
messagingSenderId: '',
|
|
195
201
|
measurementId: ''
|
|
196
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;
|
|
197
209
|
apiServer = { host: '' };
|
|
198
210
|
chatServer = { host: '' };
|
|
199
211
|
/**
|
|
@@ -769,6 +781,20 @@ class AuthService {
|
|
|
769
781
|
isMultiServerMode() {
|
|
770
782
|
return !!(this.environment.authServers && Object.keys(this.environment.authServers).length > 0);
|
|
771
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
|
+
}
|
|
772
798
|
/**
|
|
773
799
|
* Hash UUID to numeric ID for backward compatibility
|
|
774
800
|
* Converts UUID string to a consistent numeric ID for legacy code
|
|
@@ -1144,9 +1170,9 @@ class AuthService {
|
|
|
1144
1170
|
if (data.provider !== 'emailPassword') {
|
|
1145
1171
|
return await this.registerTenantWithOAuth(data.tenantName, data.tenantSlug, data.provider);
|
|
1146
1172
|
}
|
|
1147
|
-
// Email/password registration
|
|
1148
|
-
const
|
|
1149
|
-
const response = await fetch(`${
|
|
1173
|
+
// Email/password registration — route through platform API proxy
|
|
1174
|
+
const apiUrl = this.getPlatformApiUrl();
|
|
1175
|
+
const response = await fetch(`${apiUrl}/auth/register-tenant`, {
|
|
1150
1176
|
method: 'POST',
|
|
1151
1177
|
headers: { 'Content-Type': 'application/json' },
|
|
1152
1178
|
credentials: 'include',
|
|
@@ -1469,8 +1495,9 @@ class AuthService {
|
|
|
1469
1495
|
if (!accessToken) {
|
|
1470
1496
|
throw new Error('Not authenticated');
|
|
1471
1497
|
}
|
|
1472
|
-
|
|
1473
|
-
const
|
|
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`, {
|
|
1474
1501
|
method: 'POST',
|
|
1475
1502
|
headers: {
|
|
1476
1503
|
'Content-Type': 'application/json',
|