@explorins/pers-sdk-react-native 1.5.6 → 1.5.8
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
|
@@ -123,13 +123,23 @@ 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
|
-
|
|
132
|
+
console.log('[useTransactionSigner] useEffect triggered:', {
|
|
133
|
+
isInitialized,
|
|
134
|
+
isAuthenticated,
|
|
135
|
+
hasUser: !!user,
|
|
136
|
+
isSignerInitialized,
|
|
137
|
+
hasSDK: !!sdk,
|
|
138
|
+
hasAuthProvider: !!authProvider,
|
|
139
|
+
hasCreatePersSignerSDK: !!createPersSignerSDK
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
if (isInitialized && isAuthenticated && user && !isSignerInitialized && sdk && authProvider) {
|
|
133
143
|
console.log('[useTransactionSigner] Auto-initializing PERS transaction signer...');
|
|
134
144
|
|
|
135
145
|
// Get configuration from the PERS SDK
|
|
@@ -147,7 +157,7 @@ export const useTransactionSigner = () => {
|
|
|
147
157
|
console.error('[useTransactionSigner] Auto-initialization failed:', error);
|
|
148
158
|
});
|
|
149
159
|
}
|
|
150
|
-
}, [isInitialized, isAuthenticated, user, isSignerInitialized, sdk]);
|
|
160
|
+
}, [isInitialized, isAuthenticated, user, isSignerInitialized, sdk, authProvider]);
|
|
151
161
|
|
|
152
162
|
/**
|
|
153
163
|
* Initialize the blockchain signer with configuration
|
|
@@ -263,8 +273,7 @@ export const useTransactionSigner = () => {
|
|
|
263
273
|
id: currentUser.id || jwtUserInfo.userId
|
|
264
274
|
};
|
|
265
275
|
|
|
266
|
-
// Get PERS access token from the
|
|
267
|
-
const authProvider = (sdk as any).authProvider || (sdk as any)._authProvider;
|
|
276
|
+
// Get PERS access token from the auth provider
|
|
268
277
|
console.log('[useTransactionSigner] Auth provider found:', !!authProvider);
|
|
269
278
|
const persAccessToken = authProvider ? await authProvider.getToken() : '';
|
|
270
279
|
console.log('[useTransactionSigner] PERS access token extracted:', persAccessToken ? 'Token found' : 'No token');
|
|
@@ -273,7 +282,7 @@ export const useTransactionSigner = () => {
|
|
|
273
282
|
console.log('[useTransactionSigner] Authenticating user with signer:', signerUserInfo.identifier);
|
|
274
283
|
const signerUser = await signerSDKRef.current.authenticateUser({
|
|
275
284
|
...signerUserInfo,
|
|
276
|
-
persAccessToken: persAccessToken
|
|
285
|
+
persAccessToken: persAccessToken || undefined
|
|
277
286
|
});
|
|
278
287
|
|
|
279
288
|
// Sign the PERS transaction using JWT
|