@explorins/pers-sdk-react-native 1.5.10 → 1.5.12

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@explorins/pers-sdk-react-native",
3
- "version": "1.5.10",
3
+ "version": "1.5.12",
4
4
  "description": "React Native SDK for PERS Platform - Tourism Loyalty System with Manager Pattern Architecture",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -151,12 +151,13 @@ export const useTransactionSigner = () => {
151
151
 
152
152
  // Try to extract tenantId from JWT token if available
153
153
  let tenantIdFromJWT: string | undefined;
154
+ let authToken: string | null | undefined;
154
155
  if (authProvider.getToken) {
155
156
  try {
156
- const token = await authProvider.getToken();
157
- if (token) {
157
+ authToken = await authProvider.getToken();
158
+ if (authToken) {
158
159
  // Decode JWT to get tenant information
159
- const tokenParts = token.split('.');
160
+ const tokenParts = authToken.split('.');
160
161
  if (tokenParts.length >= 2) {
161
162
  const payload = JSON.parse(atob(tokenParts[1]));
162
163
  console.log('[useTransactionSigner] JWT payload decoded:', payload);
@@ -242,20 +243,21 @@ export const useTransactionSigner = () => {
242
243
  console.error('[useTransactionSigner] Failed to configure PERS service:', configError);
243
244
  }
244
245
  } else if (config?.tenantId) {
245
- console.log('[useTransactionSigner] No project key provided, will initialize tenant environment with tenantId:', config.tenantId);
246
+ console.log('[useTransactionSigner] No project key provided, will initialize tenant with tenantId:', config.tenantId);
246
247
  try {
247
248
  // Import and initialize tenant environment to get project key
248
249
  const { PersService } = await import('@explorins/pers-signer/react-native');
249
- console.log('[useTransactionSigner] Initializing tenant environment for tenantId:', config.tenantId);
250
+ console.log('[useTransactionSigner] Initializing tenant for tenantId:', config.tenantId);
250
251
 
251
252
  // We need to set the auth token first for tenant initialization
253
+ let authToken: string | null | undefined;
252
254
  if (authProvider) {
253
255
  try {
254
- const token = await authProvider.getToken();
255
- if (token) {
256
+ authToken = await authProvider.getToken();
257
+ if (authToken) {
256
258
  console.log('[useTransactionSigner] Setting auth token for tenant initialization');
257
259
  (PersService as any).configure({
258
- token: token
260
+ token: authToken
259
261
  });
260
262
  }
261
263
  } catch (tokenError) {
@@ -263,14 +265,14 @@ export const useTransactionSigner = () => {
263
265
  }
264
266
  }
265
267
 
266
- await (PersService as any).initTenantEnvironment(config.tenantId);
267
- console.log('[useTransactionSigner] Tenant environment initialized successfully');
268
+ await (PersService as any).initializeTenant(config.tenantId, authToken);
269
+ console.log('[useTransactionSigner] Tenant initialized successfully');
268
270
 
269
271
  // Verify configuration
270
272
  const persConfig = (PersService as any).getConfig();
271
273
  console.log('[useTransactionSigner] PERS service config after tenant initialization:', persConfig);
272
274
  } catch (configError) {
273
- console.error('[useTransactionSigner] Failed to initialize tenant environment:', configError);
275
+ console.error('[useTransactionSigner] Failed to initialize tenant:', configError);
274
276
  }
275
277
  }
276
278