@solcre-org/core-ui 2.21.0 → 2.23.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.
@@ -1128,7 +1128,7 @@
1128
1128
  "success": "Access validated successfully."
1129
1129
  },
1130
1130
  "errors": {
1131
- "missingCode": "The secure validation code was not found in the URL.",
1131
+ "missingToken": "The secure validation token was not found in the URL.",
1132
1132
  "validation": "An error occurred while validating secure access."
1133
1133
  }
1134
1134
  }
@@ -1132,7 +1132,7 @@
1132
1132
  "success": "Acceso validado correctamente."
1133
1133
  },
1134
1134
  "errors": {
1135
- "missingCode": "No se encontró el código de validación en la URL.",
1135
+ "missingToken": "No se encontró el token de validación en la URL.",
1136
1136
  "validation": "Ocurrió un error al validar el acceso seguro."
1137
1137
  }
1138
1138
  }
@@ -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.23.0',
17770
17770
  major: 2,
17771
- minor: 21,
17771
+ minor: 23,
17772
17772
  patch: 0,
17773
- timestamp: '2026-03-26T15:39:08.087Z',
17773
+ timestamp: '2026-03-26T19:43:25.143Z',
17774
17774
  buildDate: '26/3/2026'
17775
17775
  };
17776
17776
 
@@ -22082,17 +22082,18 @@ 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
+ queryParamName = input('token');
22086
22087
  validationEvent = output();
22087
22088
  loaderRequestID = 'secure-auth-loader';
22088
22089
  status = signal(SECURE_AUTH_SCREEN_STATUS.IDLE);
22089
22090
  errorMessageKey = signal(null);
22090
22091
  ngOnInit() {
22091
- const code = this.getCodeFromUrl();
22092
- if (!code) {
22093
- const error = new Error('Secure auth code was not found in the URL.');
22092
+ const token = this.getTokenFromUrl();
22093
+ if (!token) {
22094
+ const error = new Error('Secure auth token was not found in the URL.');
22094
22095
  this.status.set(SECURE_AUTH_SCREEN_STATUS.ERROR);
22095
- this.errorMessageKey.set('secureAuth.errors.missingCode');
22096
+ this.errorMessageKey.set('secureAuth.errors.missingToken');
22096
22097
  this.validationEvent.emit({
22097
22098
  type: SECURE_AUTH_VALIDATION_EVENT_TYPE.ERROR,
22098
22099
  error
@@ -22102,15 +22103,15 @@ class SecureAuth {
22102
22103
  this.status.set(SECURE_AUTH_SCREEN_STATUS.LOADING);
22103
22104
  this.errorMessageKey.set(null);
22104
22105
  this.loaderService.showLoader(this.loaderRequestID);
22105
- this.apiService.createObj(this.validationEndpoint(), { code }, false)
22106
+ this.apiService.createObj(this.validationEndpoint(), { token }, false)
22106
22107
  .pipe(switchMap((response) => {
22107
22108
  const responseData = this.getResponseData(response);
22108
22109
  const authToken = this.buildAuthToken(responseData);
22109
22110
  if (!authToken.token) {
22110
22111
  throw new Error('Secure auth validation response did not include a token.');
22111
22112
  }
22112
- this.loadSessionToken(authToken);
22113
- return this.notifyAuthenticatedSession().pipe(map((user) => ({
22113
+ this.loadSessionToken(authToken, responseData);
22114
+ return this.notifyAuthenticatedSession(responseData).pipe(map((user) => ({
22114
22115
  response,
22115
22116
  user
22116
22117
  })));
@@ -22120,7 +22121,7 @@ class SecureAuth {
22120
22121
  this.status.set(SECURE_AUTH_SCREEN_STATUS.SUCCESS);
22121
22122
  this.validationEvent.emit({
22122
22123
  type: SECURE_AUTH_VALIDATION_EVENT_TYPE.SUCCESS,
22123
- code,
22124
+ token,
22124
22125
  response,
22125
22126
  user
22126
22127
  });
@@ -22130,43 +22131,102 @@ class SecureAuth {
22130
22131
  this.errorMessageKey.set('secureAuth.errors.validation');
22131
22132
  this.validationEvent.emit({
22132
22133
  type: SECURE_AUTH_VALIDATION_EVENT_TYPE.ERROR,
22133
- code,
22134
+ token,
22134
22135
  error
22135
22136
  });
22136
22137
  }
22137
22138
  });
22138
22139
  }
22139
- getCodeFromUrl() {
22140
- return new URLSearchParams(window.location.search).get('code');
22140
+ getTokenFromUrl() {
22141
+ const queryParamName = this.queryParamName().trim() || 'token';
22142
+ return new URLSearchParams(window.location.search).get(queryParamName);
22141
22143
  }
22142
22144
  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.');
22145
+ const responseData = this.getObjectValue(response?.data);
22146
+ if (!responseData) {
22147
+ throw new Error('Secure auth validation response did not include a valid payload.');
22148
+ }
22149
+ if (this.getTokenValue(responseData)) {
22150
+ return responseData;
22151
+ }
22152
+ const nestedResponseData = this.getObjectValue(responseData['data']);
22153
+ if (nestedResponseData && this.getTokenValue(nestedResponseData)) {
22154
+ return nestedResponseData;
22146
22155
  }
22147
- return responseData;
22156
+ throw new Error('Secure auth validation response did not include a token payload.');
22148
22157
  }
22149
22158
  buildAuthToken(responseData) {
22150
22159
  return {
22151
- token: this.toStringValue(responseData['access_token'] ?? responseData['token']) ?? '',
22152
- refreshToken: this.toStringValue(responseData['refresh_token'] ?? responseData['refreshToken']) ?? ''
22160
+ token: this.getTokenValue(responseData) ?? '',
22161
+ refreshToken: this.getStringValue(responseData['refresh_token']) ?? this.getStringValue(responseData['refreshToken']) ?? ''
22153
22162
  };
22154
22163
  }
22155
- loadSessionToken(token) {
22164
+ loadSessionToken(token, responseData) {
22156
22165
  const tokenPayload = {
22157
22166
  access_token: token.token
22158
22167
  };
22159
22168
  if (token.refreshToken) {
22160
22169
  tokenPayload['refresh_token'] = token.refreshToken;
22161
22170
  }
22171
+ const responseUser = this.getObjectValue(responseData['user']);
22172
+ if (responseUser) {
22173
+ tokenPayload['user'] = responseUser;
22174
+ }
22162
22175
  this.authService.saveToken(tokenPayload);
22163
22176
  this.apiService.setAccessToken(token.token);
22164
22177
  }
22165
- toStringValue(value) {
22178
+ getTokenValue(responseData) {
22179
+ return this.getStringValue(responseData['access_token']) ?? this.getStringValue(responseData['token']);
22180
+ }
22181
+ getObjectValue(value) {
22182
+ return value && typeof value === 'object' && !Array.isArray(value)
22183
+ ? value
22184
+ : null;
22185
+ }
22186
+ buildAuthUser(responseData) {
22187
+ const user = this.getObjectValue(responseData['user']);
22188
+ if (!user) {
22189
+ return null;
22190
+ }
22191
+ const id = this.getNumberValue(user['id']);
22192
+ const name = this.getStringValue(user['name']) ?? this.getStringValue(user['first_name']) ?? this.getStringValue(user['firstName']) ?? '';
22193
+ const lastName = this.getStringValue(user['last_name']) ?? this.getStringValue(user['lastName']) ?? '';
22194
+ if (!name && !lastName && id === 0) {
22195
+ return null;
22196
+ }
22197
+ return {
22198
+ id,
22199
+ name,
22200
+ lastName,
22201
+ birthday: this.getStringValue(user['birthday']) ?? undefined,
22202
+ email: this.getStringValue(user['email']) ?? undefined,
22203
+ image: this.getStringValue(user['image']) ?? undefined,
22204
+ adUser: this.getStringValue(user['ad_user'] ?? user['adUser']) ?? undefined
22205
+ };
22206
+ }
22207
+ getNumberValue(value) {
22208
+ if (typeof value === 'number') {
22209
+ return value;
22210
+ }
22211
+ const stringValue = this.getStringValue(value);
22212
+ if (!stringValue) {
22213
+ return 0;
22214
+ }
22215
+ const numberValue = Number(stringValue);
22216
+ return Number.isNaN(numberValue) ? 0 : numberValue;
22217
+ }
22218
+ getStringValue(value) {
22166
22219
  return typeof value === 'string' && value.trim() !== '' ? value : null;
22167
22220
  }
22168
- notifyAuthenticatedSession() {
22221
+ notifyAuthenticatedSession(responseData) {
22169
22222
  const { meUri, checkTokenInsteadUserId } = this.authService.getConfig();
22223
+ const tokenUser = this.buildAuthUser(responseData);
22224
+ if (tokenUser) {
22225
+ this.authService.setLoggedUser(tokenUser);
22226
+ this.authService.onLoggedUserChange.emit(tokenUser);
22227
+ this.authService.checkAndNotifyState();
22228
+ return of(tokenUser);
22229
+ }
22170
22230
  if (meUri) {
22171
22231
  return this.authService.startData().pipe(map((user) => user));
22172
22232
  }
@@ -22178,7 +22238,7 @@ class SecureAuth {
22178
22238
  return of(null);
22179
22239
  }
22180
22240
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.6", ngImport: i0, type: SecureAuth, deps: [], target: i0.ɵɵFactoryTarget.Component });
22181
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.0.6", type: SecureAuth, isStandalone: true, selector: "core-secure-auth", inputs: { validationEndpoint: { classPropertyName: "validationEndpoint", publicName: "validationEndpoint", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { validationEvent: "validationEvent" }, ngImport: i0, template: "<core-loader [requestId]=\"loaderRequestID\" />\n<div class=\"u-heading u-push-t--xl u-push-b\">\n @if (status() === screenStatus.LOADING) {\n <p>{{ 'secureAuth.status.loading' | translate }}</p>\n } @else if (status() === screenStatus.SUCCESS) {\n <p>{{ 'secureAuth.status.success' | translate }}</p>\n } @else if (status() === screenStatus.ERROR) {\n <p><span class=\"icon-error\"></span> {{ (errorMessageKey() ?? 'secureAuth.errors.validation') | translate }}</p>\n }\n</div>\n", dependencies: [{ kind: "component", type: LoaderComponent, selector: "core-loader", inputs: ["imageUrl", "requestId"] }, { kind: "ngmodule", type: TranslateModule }, { kind: "pipe", type: i3.TranslatePipe, name: "translate" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
22241
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.0.6", type: SecureAuth, isStandalone: true, selector: "core-secure-auth", inputs: { validationEndpoint: { classPropertyName: "validationEndpoint", publicName: "validationEndpoint", isSignal: true, isRequired: false, transformFunction: null }, queryParamName: { classPropertyName: "queryParamName", publicName: "queryParamName", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { validationEvent: "validationEvent" }, ngImport: i0, template: "<core-loader [requestId]=\"loaderRequestID\" />\n<div class=\"u-heading u-push-t--xl u-push-b\">\n @if (status() === screenStatus.LOADING) {\n <p>{{ 'secureAuth.status.loading' | translate }}</p>\n } @else if (status() === screenStatus.SUCCESS) {\n <p>{{ 'secureAuth.status.success' | translate }}</p>\n } @else if (status() === screenStatus.ERROR) {\n <p><span class=\"icon-error\"></span> {{ (errorMessageKey() ?? 'secureAuth.errors.validation') | translate }}</p>\n }\n</div>\n", dependencies: [{ kind: "component", type: LoaderComponent, selector: "core-loader", inputs: ["imageUrl", "requestId"] }, { kind: "ngmodule", type: TranslateModule }, { kind: "pipe", type: i3.TranslatePipe, name: "translate" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
22182
22242
  }
22183
22243
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.6", ngImport: i0, type: SecureAuth, decorators: [{
22184
22244
  type: Component,