@solcre-org/core-ui 2.21.0 → 2.22.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.
@@ -17766,11 +17766,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.6", ngImpor
17766
17766
  // Este archivo es generado automáticamente por scripts/update-version.js
17767
17767
  // No edites manualmente este archivo
17768
17768
  const VERSION = {
17769
- full: '2.21.0',
17769
+ full: '2.22.0',
17770
17770
  major: 2,
17771
- minor: 21,
17771
+ minor: 22,
17772
17772
  patch: 0,
17773
- timestamp: '2026-03-26T15:39:08.087Z',
17773
+ timestamp: '2026-03-26T18:34:37.680Z',
17774
17774
  buildDate: '26/3/2026'
17775
17775
  };
17776
17776
 
@@ -22082,7 +22082,7 @@ class SecureAuth {
22082
22082
  authService = inject(AuthService);
22083
22083
  loaderService = inject(LoaderService);
22084
22084
  screenStatus = SECURE_AUTH_SCREEN_STATUS;
22085
- validationEndpoint = input('/auth/validate-secure-token');
22085
+ validationEndpoint = input('/api/auth/validate-secure-token');
22086
22086
  validationEvent = output();
22087
22087
  loaderRequestID = 'secure-auth-loader';
22088
22088
  status = signal(SECURE_AUTH_SCREEN_STATUS.IDLE);
@@ -22109,8 +22109,8 @@ class SecureAuth {
22109
22109
  if (!authToken.token) {
22110
22110
  throw new Error('Secure auth validation response did not include a token.');
22111
22111
  }
22112
- this.loadSessionToken(authToken);
22113
- return this.notifyAuthenticatedSession().pipe(map((user) => ({
22112
+ this.loadSessionToken(authToken, responseData);
22113
+ return this.notifyAuthenticatedSession(responseData).pipe(map((user) => ({
22114
22114
  response,
22115
22115
  user
22116
22116
  })));
@@ -22140,33 +22140,91 @@ class SecureAuth {
22140
22140
  return new URLSearchParams(window.location.search).get('code');
22141
22141
  }
22142
22142
  getResponseData(response) {
22143
- const responseData = response?.data;
22144
- if (!responseData || typeof responseData !== 'object' || Array.isArray(responseData)) {
22145
- throw new Error('Secure auth validation response did not include a token payload.');
22143
+ const responseData = this.getObjectValue(response?.data);
22144
+ if (!responseData) {
22145
+ throw new Error('Secure auth validation response did not include a valid payload.');
22146
22146
  }
22147
- return responseData;
22147
+ if (this.getTokenValue(responseData)) {
22148
+ return responseData;
22149
+ }
22150
+ const nestedResponseData = this.getObjectValue(responseData['data']);
22151
+ if (nestedResponseData && this.getTokenValue(nestedResponseData)) {
22152
+ return nestedResponseData;
22153
+ }
22154
+ throw new Error('Secure auth validation response did not include a token payload.');
22148
22155
  }
22149
22156
  buildAuthToken(responseData) {
22150
22157
  return {
22151
- token: this.toStringValue(responseData['access_token'] ?? responseData['token']) ?? '',
22152
- refreshToken: this.toStringValue(responseData['refresh_token'] ?? responseData['refreshToken']) ?? ''
22158
+ token: this.getTokenValue(responseData) ?? '',
22159
+ refreshToken: this.getStringValue(responseData['refresh_token']) ?? this.getStringValue(responseData['refreshToken']) ?? ''
22153
22160
  };
22154
22161
  }
22155
- loadSessionToken(token) {
22162
+ loadSessionToken(token, responseData) {
22156
22163
  const tokenPayload = {
22157
22164
  access_token: token.token
22158
22165
  };
22159
22166
  if (token.refreshToken) {
22160
22167
  tokenPayload['refresh_token'] = token.refreshToken;
22161
22168
  }
22169
+ const responseUser = this.getObjectValue(responseData['user']);
22170
+ if (responseUser) {
22171
+ tokenPayload['user'] = responseUser;
22172
+ }
22162
22173
  this.authService.saveToken(tokenPayload);
22163
22174
  this.apiService.setAccessToken(token.token);
22164
22175
  }
22165
- toStringValue(value) {
22176
+ getTokenValue(responseData) {
22177
+ return this.getStringValue(responseData['access_token']) ?? this.getStringValue(responseData['token']);
22178
+ }
22179
+ getObjectValue(value) {
22180
+ return value && typeof value === 'object' && !Array.isArray(value)
22181
+ ? value
22182
+ : null;
22183
+ }
22184
+ buildAuthUser(responseData) {
22185
+ const user = this.getObjectValue(responseData['user']);
22186
+ if (!user) {
22187
+ return null;
22188
+ }
22189
+ const id = this.getNumberValue(user['id']);
22190
+ const name = this.getStringValue(user['name']) ?? this.getStringValue(user['first_name']) ?? this.getStringValue(user['firstName']) ?? '';
22191
+ const lastName = this.getStringValue(user['last_name']) ?? this.getStringValue(user['lastName']) ?? '';
22192
+ if (!name && !lastName && id === 0) {
22193
+ return null;
22194
+ }
22195
+ return {
22196
+ id,
22197
+ name,
22198
+ lastName,
22199
+ birthday: this.getStringValue(user['birthday']) ?? undefined,
22200
+ email: this.getStringValue(user['email']) ?? undefined,
22201
+ image: this.getStringValue(user['image']) ?? undefined,
22202
+ adUser: this.getStringValue(user['ad_user'] ?? user['adUser']) ?? undefined
22203
+ };
22204
+ }
22205
+ getNumberValue(value) {
22206
+ if (typeof value === 'number') {
22207
+ return value;
22208
+ }
22209
+ const stringValue = this.getStringValue(value);
22210
+ if (!stringValue) {
22211
+ return 0;
22212
+ }
22213
+ const numberValue = Number(stringValue);
22214
+ return Number.isNaN(numberValue) ? 0 : numberValue;
22215
+ }
22216
+ getStringValue(value) {
22166
22217
  return typeof value === 'string' && value.trim() !== '' ? value : null;
22167
22218
  }
22168
- notifyAuthenticatedSession() {
22219
+ notifyAuthenticatedSession(responseData) {
22169
22220
  const { meUri, checkTokenInsteadUserId } = this.authService.getConfig();
22221
+ const tokenUser = this.buildAuthUser(responseData);
22222
+ if (tokenUser) {
22223
+ this.authService.setLoggedUser(tokenUser);
22224
+ this.authService.onLoggedUserChange.emit(tokenUser);
22225
+ this.authService.checkAndNotifyState();
22226
+ return of(tokenUser);
22227
+ }
22170
22228
  if (meUri) {
22171
22229
  return this.authService.startData().pipe(map((user) => user));
22172
22230
  }