@blackcode_sa/metaestetics-api 1.12.55 → 1.12.57

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.
@@ -7932,9 +7932,21 @@ async function createFreeConsultationInfrastructure(db) {
7932
7932
  contraindications: [],
7933
7933
  // No contraindications for consultation
7934
7934
  benefits: [
7935
- "IMPROVED_PATIENT_UNDERSTANDING",
7936
- "BETTER_TREATMENT_PLANNING",
7937
- "ENHANCED_PATIENT_CONFIDENCE"
7935
+ {
7936
+ id: "IMPROVED_PATIENT_UNDERSTANDING",
7937
+ name: "Improved Patient Understanding",
7938
+ description: "Helps patients better understand their treatment options and expected outcomes"
7939
+ },
7940
+ {
7941
+ id: "BETTER_TREATMENT_PLANNING",
7942
+ name: "Better Treatment Planning",
7943
+ description: "Enables more effective treatment planning based on patient needs and goals"
7944
+ },
7945
+ {
7946
+ id: "ENHANCED_PATIENT_CONFIDENCE",
7947
+ name: "Enhanced Patient Confidence",
7948
+ description: "Builds patient confidence through clear communication and professional guidance"
7949
+ }
7938
7950
  ],
7939
7951
  certificationRequirement: {
7940
7952
  minimumLevel: "aesthetician" /* AESTHETICIAN */,
@@ -7870,9 +7870,21 @@ async function createFreeConsultationInfrastructure(db) {
7870
7870
  contraindications: [],
7871
7871
  // No contraindications for consultation
7872
7872
  benefits: [
7873
- "IMPROVED_PATIENT_UNDERSTANDING",
7874
- "BETTER_TREATMENT_PLANNING",
7875
- "ENHANCED_PATIENT_CONFIDENCE"
7873
+ {
7874
+ id: "IMPROVED_PATIENT_UNDERSTANDING",
7875
+ name: "Improved Patient Understanding",
7876
+ description: "Helps patients better understand their treatment options and expected outcomes"
7877
+ },
7878
+ {
7879
+ id: "BETTER_TREATMENT_PLANNING",
7880
+ name: "Better Treatment Planning",
7881
+ description: "Enables more effective treatment planning based on patient needs and goals"
7882
+ },
7883
+ {
7884
+ id: "ENHANCED_PATIENT_CONFIDENCE",
7885
+ name: "Enhanced Patient Confidence",
7886
+ description: "Builds patient confidence through clear communication and professional guidance"
7887
+ }
7876
7888
  ],
7877
7889
  certificationRequirement: {
7878
7890
  minimumLevel: "aesthetician" /* AESTHETICIAN */,
package/dist/index.js CHANGED
@@ -3846,6 +3846,11 @@ var AUTH_ERRORS = {
3846
3846
  "AUTH/INVALID_ROLE",
3847
3847
  400
3848
3848
  ),
3849
+ UNAUTHORIZED_ROLE: new AuthError(
3850
+ "You do not have permission to access the clinic application. This account is registered as a patient. Please use the mobile app to access your patient account.",
3851
+ "AUTH/UNAUTHORIZED_ROLE",
3852
+ 403
3853
+ ),
3849
3854
  // Authentication errors
3850
3855
  NOT_AUTHENTICATED: new AuthError(
3851
3856
  "User is not authenticated",
@@ -11596,7 +11601,8 @@ var AuthService = class extends BaseService {
11596
11601
  const user = await this.userService.getOrCreateUser(firebaseUser);
11597
11602
  if (!((_a = user.roles) == null ? void 0 : _a.includes("clinic_admin" /* CLINIC_ADMIN */))) {
11598
11603
  console.error("[AUTH] User is not a clinic admin:", user.uid);
11599
- throw AUTH_ERRORS.INVALID_ROLE;
11604
+ await this.auth.signOut();
11605
+ throw AUTH_ERRORS.UNAUTHORIZED_ROLE;
11600
11606
  }
11601
11607
  if (!user.adminProfile) {
11602
11608
  console.error("[AUTH] User has no admin profile:", user.uid);
package/dist/index.mjs CHANGED
@@ -3764,6 +3764,11 @@ var AUTH_ERRORS = {
3764
3764
  "AUTH/INVALID_ROLE",
3765
3765
  400
3766
3766
  ),
3767
+ UNAUTHORIZED_ROLE: new AuthError(
3768
+ "You do not have permission to access the clinic application. This account is registered as a patient. Please use the mobile app to access your patient account.",
3769
+ "AUTH/UNAUTHORIZED_ROLE",
3770
+ 403
3771
+ ),
3767
3772
  // Authentication errors
3768
3773
  NOT_AUTHENTICATED: new AuthError(
3769
3774
  "User is not authenticated",
@@ -11695,7 +11700,8 @@ var AuthService = class extends BaseService {
11695
11700
  const user = await this.userService.getOrCreateUser(firebaseUser);
11696
11701
  if (!((_a = user.roles) == null ? void 0 : _a.includes("clinic_admin" /* CLINIC_ADMIN */))) {
11697
11702
  console.error("[AUTH] User is not a clinic admin:", user.uid);
11698
- throw AUTH_ERRORS.INVALID_ROLE;
11703
+ await this.auth.signOut();
11704
+ throw AUTH_ERRORS.UNAUTHORIZED_ROLE;
11699
11705
  }
11700
11706
  if (!user.adminProfile) {
11701
11707
  console.error("[AUTH] User has no admin profile:", user.uid);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@blackcode_sa/metaestetics-api",
3
3
  "private": false,
4
- "version": "1.12.55",
4
+ "version": "1.12.57",
5
5
  "description": "Firebase authentication service with anonymous upgrade support",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.mjs",
@@ -110,9 +110,21 @@ async function createFreeConsultationInfrastructure(db: admin.firestore.Firestor
110
110
  blockingConditions: [], // No blocking conditions for consultation
111
111
  contraindications: [], // No contraindications for consultation
112
112
  benefits: [
113
- 'IMPROVED_PATIENT_UNDERSTANDING',
114
- 'BETTER_TREATMENT_PLANNING',
115
- 'ENHANCED_PATIENT_CONFIDENCE',
113
+ {
114
+ id: 'IMPROVED_PATIENT_UNDERSTANDING',
115
+ name: 'Improved Patient Understanding',
116
+ description: 'Helps patients better understand their treatment options and expected outcomes',
117
+ },
118
+ {
119
+ id: 'BETTER_TREATMENT_PLANNING',
120
+ name: 'Better Treatment Planning',
121
+ description: 'Enables more effective treatment planning based on patient needs and goals',
122
+ },
123
+ {
124
+ id: 'ENHANCED_PATIENT_CONFIDENCE',
125
+ name: 'Enhanced Patient Confidence',
126
+ description: 'Builds patient confidence through clear communication and professional guidance',
127
+ },
116
128
  ],
117
129
  certificationRequirement: {
118
130
  minimumLevel: CertificationLevel.AESTHETICIAN,
@@ -26,6 +26,11 @@ export const AUTH_ERRORS = {
26
26
  "AUTH/INVALID_ROLE",
27
27
  400
28
28
  ),
29
+ UNAUTHORIZED_ROLE: new AuthError(
30
+ "You do not have permission to access the clinic application. This account is registered as a patient. Please use the mobile app to access your patient account.",
31
+ "AUTH/UNAUTHORIZED_ROLE",
32
+ 403
33
+ ),
29
34
 
30
35
  // Authentication errors
31
36
  NOT_AUTHENTICATED: new AuthError(
@@ -480,7 +480,9 @@ export class AuthService extends BaseService {
480
480
  // Check if user has clinic_admin role
481
481
  if (!user.roles?.includes(UserRole.CLINIC_ADMIN)) {
482
482
  console.error('[AUTH] User is not a clinic admin:', user.uid);
483
- throw AUTH_ERRORS.INVALID_ROLE;
483
+ // Sign out the user immediately for security
484
+ await this.auth.signOut();
485
+ throw AUTH_ERRORS.UNAUTHORIZED_ROLE;
484
486
  }
485
487
 
486
488
  // Check and get admin profile
@@ -314,7 +314,9 @@ export class AuthServiceV2 extends BaseService {
314
314
  // Check if user has clinic_admin role
315
315
  if (!user.roles?.includes(UserRole.CLINIC_ADMIN)) {
316
316
  console.error("[AUTH] User is not a clinic admin:", user.uid);
317
- throw AUTH_ERRORS.INVALID_ROLE;
317
+ // Sign out the user immediately for security
318
+ await this.auth.signOut();
319
+ throw AUTH_ERRORS.UNAUTHORIZED_ROLE;
318
320
  }
319
321
 
320
322
  // Check and get admin profile