sunuid-sdk 1.0.37 → 1.0.38

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.
@@ -2117,6 +2117,8 @@
2117
2117
  key: "sanitizeRequestData",
2118
2118
  value: function sanitizeRequestData(data) {
2119
2119
  var sanitized = {};
2120
+
2121
+ // D'abord, copier tous les champs de data
2120
2122
  for (var _i = 0, _Object$entries = Object.entries(data); _i < _Object$entries.length; _i++) {
2121
2123
  var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
2122
2124
  key = _Object$entries$_i[0],
@@ -2130,19 +2132,12 @@
2130
2132
  }
2131
2133
  }
2132
2134
 
2133
- // Ajouter les credentials dans le body (API SunuID les attend ici)
2135
+ // Ensuite, ajouter/écraser les credentials (API SunuID les attend ici)
2134
2136
  // Utiliser les vraies valeurs (originales) si disponibles, sinon les valeurs directes
2135
2137
  sanitized.client_id = this.config.originalClientId || this.config.clientId;
2136
2138
  sanitized.secret_id = this.config.originalSecretId || this.config.secretId;
2137
2139
 
2138
- // Debug: Vérifier les credentials
2139
- console.log('🔍 Credentials dans sanitizeRequestData - clientId:', this.config.clientId);
2140
- console.log('🔍 Credentials dans sanitizeRequestData - secretId:', this.config.secretId ? '***' + this.config.secretId.slice(-4) : 'null');
2141
- console.log('🔍 Credentials dans sanitizeRequestData - sanitizedClientId:', sanitized.client_id);
2142
- console.log('🔍 Credentials dans sanitizeRequestData - sanitizedSecretId:', sanitized.secret_id ? '***' + sanitized.secret_id.slice(-4) : 'null');
2143
- console.log('🔍 Credentials dans sanitizeRequestData - data complet:', JSON.stringify(sanitized, null, 2));
2144
-
2145
- // Debug: Vérifier les credentials
2140
+ // Debug: Vérifier les credentials et les données
2146
2141
  console.log('🔍 Credentials dans sanitizeRequestData - clientId:', this.config.clientId);
2147
2142
  console.log('🔍 Credentials dans sanitizeRequestData - secretId:', this.config.secretId ? '***' + this.config.secretId.slice(-4) : 'null');
2148
2143
  console.log('🔍 Credentials dans sanitizeRequestData - sanitizedClientId:', sanitized.client_id);
@@ -2179,7 +2174,7 @@
2179
2174
  key: "fetchPartnerInfo",
2180
2175
  value: (function () {
2181
2176
  var _fetchPartnerInfo = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee17() {
2182
- var response, authTest, _t12;
2177
+ var response, data, partnerId, _t12;
2183
2178
  return _regenerator().w(function (_context18) {
2184
2179
  while (1) switch (_context18.p = _context18.n) {
2185
2180
  case 0:
@@ -2193,32 +2188,46 @@
2193
2188
  case 1:
2194
2189
  response = _context18.v;
2195
2190
  console.log('📋 Réponse debug API:', response);
2196
- if (response.success && response.authentication && response.authentication.auth_test) {
2197
- authTest = response.authentication.auth_test;
2198
- this.config.partnerId = authTest.partner_id;
2199
2191
 
2200
- // Récupérer le service_id depuis la réponse
2201
- if (response.service_id) {
2202
- this.config.serviceId = response.service_id;
2203
- } else {
2204
- // Fallback: utiliser le partner_id comme service_id
2205
- this.config.serviceId = authTest.partner_id;
2192
+ // Vérifier la structure de la réponse
2193
+ if (response.success && response.data) {
2194
+ data = response.data; // Essayer de récupérer le partner_id depuis différentes structures possibles
2195
+ partnerId = null;
2196
+ if (data.partner_id) {
2197
+ partnerId = data.partner_id;
2198
+ } else if (data.authentication && data.authentication.auth_test && data.authentication.auth_test.partner_id) {
2199
+ partnerId = data.authentication.auth_test.partner_id;
2200
+ } else if (data.auth_test && data.auth_test.partner_id) {
2201
+ partnerId = data.auth_test.partner_id;
2206
2202
  }
2203
+ if (partnerId) {
2204
+ this.config.partnerId = partnerId;
2205
+
2206
+ // Récupérer le service_id depuis la réponse
2207
+ if (data.service_id) {
2208
+ this.config.serviceId = data.service_id;
2209
+ } else {
2210
+ // Fallback: utiliser le partner_id comme service_id
2211
+ this.config.serviceId = partnerId;
2212
+ }
2207
2213
 
2208
- // Utiliser le partner_id pour déterminer le nom du partenaire
2209
- // Pour l'instant, on utilise une logique simple basée sur l'ID
2210
- if (authTest.partner_id === 21) {
2211
- this.config.partnerName = 'Fayma';
2214
+ // Utiliser le partner_id pour déterminer le nom du partenaire
2215
+ if (partnerId === 21) {
2216
+ this.config.partnerName = 'Fayma';
2217
+ } else {
2218
+ this.config.partnerName = "Partner_".concat(partnerId);
2219
+ }
2220
+ console.log('✅ Informations partenaire récupérées:', {
2221
+ partnerName: this.config.partnerName,
2222
+ partnerId: this.config.partnerId,
2223
+ serviceId: this.config.serviceId
2224
+ });
2212
2225
  } else {
2213
- this.config.partnerName = "Partner_".concat(authTest.partner_id);
2226
+ console.warn('⚠️ Partner ID non trouvé dans la réponse, utilisation du partner_id par défaut');
2227
+ this.config.partnerName = "Partner_".concat(this.config.partnerId || 'unknown');
2214
2228
  }
2215
- console.log('✅ Informations partenaire récupérées:', {
2216
- partnerName: this.config.partnerName,
2217
- partnerId: this.config.partnerId,
2218
- serviceId: this.config.serviceId
2219
- });
2220
2229
  } else {
2221
- console.warn('⚠️ Impossible de récupérer les informations du partenaire, utilisation du partner_id');
2230
+ console.warn('⚠️ Structure de réponse invalide, utilisation du partner_id par défaut');
2222
2231
  this.config.partnerName = "Partner_".concat(this.config.partnerId || 'unknown');
2223
2232
  }
2224
2233
  _context18.n = 3;