@explorins/pers-sdk-react-native 1.5.6 → 1.5.7

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.6",
3
+ "version": "1.5.7",
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",
@@ -123,13 +123,13 @@ const DEFAULT_ETHERS_PROVIDER = "https://sepolia.infura.io/v3/2781b4b5242343d5b0
123
123
  * ```
124
124
  */
125
125
  export const useTransactionSigner = () => {
126
- const { sdk, isInitialized, isAuthenticated, user } = usePersSDK();
126
+ const { sdk, isInitialized, isAuthenticated, user, authProvider } = usePersSDK();
127
127
  const [isSignerInitialized, setIsSignerInitialized] = useState(false);
128
128
  const signerSDKRef = useRef<PersSignerSDKInstance | null>(null);
129
129
 
130
130
  // Auto-initialize signer when user is authenticated and real SDK is available
131
131
  useEffect(() => {
132
- if (isInitialized && isAuthenticated && user && !isSignerInitialized && sdk) {
132
+ if (isInitialized && isAuthenticated && user && !isSignerInitialized && sdk && authProvider) {
133
133
  console.log('[useTransactionSigner] Auto-initializing PERS transaction signer...');
134
134
 
135
135
  // Get configuration from the PERS SDK
@@ -147,7 +147,7 @@ export const useTransactionSigner = () => {
147
147
  console.error('[useTransactionSigner] Auto-initialization failed:', error);
148
148
  });
149
149
  }
150
- }, [isInitialized, isAuthenticated, user, isSignerInitialized, sdk]);
150
+ }, [isInitialized, isAuthenticated, user, isSignerInitialized, sdk, authProvider]);
151
151
 
152
152
  /**
153
153
  * Initialize the blockchain signer with configuration
@@ -263,8 +263,7 @@ export const useTransactionSigner = () => {
263
263
  id: currentUser.id || jwtUserInfo.userId
264
264
  };
265
265
 
266
- // Get PERS access token from the main SDK
267
- const authProvider = (sdk as any).authProvider || (sdk as any)._authProvider;
266
+ // Get PERS access token from the auth provider
268
267
  console.log('[useTransactionSigner] Auth provider found:', !!authProvider);
269
268
  const persAccessToken = authProvider ? await authProvider.getToken() : '';
270
269
  console.log('[useTransactionSigner] PERS access token extracted:', persAccessToken ? 'Token found' : 'No token');
@@ -273,7 +272,7 @@ export const useTransactionSigner = () => {
273
272
  console.log('[useTransactionSigner] Authenticating user with signer:', signerUserInfo.identifier);
274
273
  const signerUser = await signerSDKRef.current.authenticateUser({
275
274
  ...signerUserInfo,
276
- persAccessToken: persAccessToken
275
+ persAccessToken: persAccessToken || undefined
277
276
  });
278
277
 
279
278
  // Sign the PERS transaction using JWT