@explorins/pers-sdk-react-native 1.5.5 → 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.5",
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,18 +123,20 @@ 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
136
136
  const sdkConfig = (sdk as any).config || {};
137
+ console.log('[useTransactionSigner] SDK config:', sdkConfig);
137
138
  const apiProjectKey = sdkConfig.apiProjectKey || 'demo-project-key';
139
+ console.log('[useTransactionSigner] Extracted API project key:', apiProjectKey);
138
140
  const tenantId = sdkConfig.tenantId || 'vq-demo';
139
141
 
140
142
  initializeSigner({
@@ -145,7 +147,7 @@ export const useTransactionSigner = () => {
145
147
  console.error('[useTransactionSigner] Auto-initialization failed:', error);
146
148
  });
147
149
  }
148
- }, [isInitialized, isAuthenticated, user, isSignerInitialized, sdk]);
150
+ }, [isInitialized, isAuthenticated, user, isSignerInitialized, sdk, authProvider]);
149
151
 
150
152
  /**
151
153
  * Initialize the blockchain signer with configuration
@@ -179,12 +181,21 @@ export const useTransactionSigner = () => {
179
181
  // Configure the PERS service with the project key before creating SDK
180
182
  if (config?.projectKey) {
181
183
  console.log('[useTransactionSigner] Configuring PERS service with project key:', config.projectKey);
182
- // Import and configure the PERS service
183
- const { PersService } = await import('@explorins/pers-signer/react-native');
184
- (PersService as any).configure({
185
- projectKey: config.projectKey
186
- });
187
- console.log('[useTransactionSigner] PERS service configured with project key');
184
+ try {
185
+ // Import and configure the PERS service
186
+ const { PersService } = await import('@explorins/pers-signer/react-native');
187
+ console.log('[useTransactionSigner] PersService imported successfully');
188
+ (PersService as any).configure({
189
+ projectKey: config.projectKey
190
+ });
191
+ console.log('[useTransactionSigner] PERS service configured with project key');
192
+
193
+ // Verify configuration
194
+ const persConfig = (PersService as any).getConfig();
195
+ console.log('[useTransactionSigner] PERS service config after configuration:', persConfig);
196
+ } catch (configError) {
197
+ console.error('[useTransactionSigner] Failed to configure PERS service:', configError);
198
+ }
188
199
  }
189
200
 
190
201
  const signerSDK = await createPersSignerSDK({
@@ -252,15 +263,16 @@ export const useTransactionSigner = () => {
252
263
  id: currentUser.id || jwtUserInfo.userId
253
264
  };
254
265
 
255
- // Get PERS access token from the main SDK
256
- const authProvider = (sdk as any).authProvider || (sdk as any)._authProvider;
266
+ // Get PERS access token from the auth provider
267
+ console.log('[useTransactionSigner] Auth provider found:', !!authProvider);
257
268
  const persAccessToken = authProvider ? await authProvider.getToken() : '';
269
+ console.log('[useTransactionSigner] PERS access token extracted:', persAccessToken ? 'Token found' : 'No token');
258
270
 
259
271
  // Authenticate user with blockchain signer and pass PERS token
260
272
  console.log('[useTransactionSigner] Authenticating user with signer:', signerUserInfo.identifier);
261
273
  const signerUser = await signerSDKRef.current.authenticateUser({
262
274
  ...signerUserInfo,
263
- persAccessToken: persAccessToken
275
+ persAccessToken: persAccessToken || undefined
264
276
  });
265
277
 
266
278
  // Sign the PERS transaction using JWT