@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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTransactionSigner.d.ts","sourceRoot":"","sources":["../../src/hooks/useTransactionSigner.ts"],"names":[],"mappings":"AA6EA,UAAU,wBAAwB;IAChC,OAAO,EAAE,OAAO,CAAC;IACjB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAKD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,eAAO,MAAM,oBAAoB;
|
|
1
|
+
{"version":3,"file":"useTransactionSigner.d.ts","sourceRoot":"","sources":["../../src/hooks/useTransactionSigner.ts"],"names":[],"mappings":"AA6EA,UAAU,wBAAwB;IAChC,OAAO,EAAE,OAAO,CAAC;IACjB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAKD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,eAAO,MAAM,oBAAoB;IAgM7B;;OAEG;2BAvE2C,MAAM,KAAG,QAAQ,wBAAwB,CAAC;IA0ExF;;OAEG;gCAjJgD;QACnD,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,iBAAiB,CAAC,EAAE,MAAM,CAAC;KAC5B;IAgJC;;OAEG;;IAGH;;OAEG;;CAGN,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAAG,UAAU,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAE5E;;GAEG;AACH,YAAY,EAAE,wBAAwB,EAAE,CAAC"}
|
|
@@ -71,12 +71,21 @@ const DEFAULT_ETHERS_PROVIDER = "https://sepolia.infura.io/v3/2781b4b5242343d5b0
|
|
|
71
71
|
* ```
|
|
72
72
|
*/
|
|
73
73
|
export const useTransactionSigner = () => {
|
|
74
|
-
const { sdk, isInitialized, isAuthenticated, user } = usePersSDK();
|
|
74
|
+
const { sdk, isInitialized, isAuthenticated, user, authProvider } = usePersSDK();
|
|
75
75
|
const [isSignerInitialized, setIsSignerInitialized] = useState(false);
|
|
76
76
|
const signerSDKRef = useRef(null);
|
|
77
77
|
// Auto-initialize signer when user is authenticated and real SDK is available
|
|
78
78
|
useEffect(() => {
|
|
79
|
-
|
|
79
|
+
console.log('[useTransactionSigner] useEffect triggered:', {
|
|
80
|
+
isInitialized,
|
|
81
|
+
isAuthenticated,
|
|
82
|
+
hasUser: !!user,
|
|
83
|
+
isSignerInitialized,
|
|
84
|
+
hasSDK: !!sdk,
|
|
85
|
+
hasAuthProvider: !!authProvider,
|
|
86
|
+
hasCreatePersSignerSDK: !!createPersSignerSDK
|
|
87
|
+
});
|
|
88
|
+
if (isInitialized && isAuthenticated && user && !isSignerInitialized && sdk && authProvider) {
|
|
80
89
|
console.log('[useTransactionSigner] Auto-initializing PERS transaction signer...');
|
|
81
90
|
// Get configuration from the PERS SDK
|
|
82
91
|
const sdkConfig = sdk.config || {};
|
|
@@ -92,7 +101,7 @@ export const useTransactionSigner = () => {
|
|
|
92
101
|
console.error('[useTransactionSigner] Auto-initialization failed:', error);
|
|
93
102
|
});
|
|
94
103
|
}
|
|
95
|
-
}, [isInitialized, isAuthenticated, user, isSignerInitialized, sdk]);
|
|
104
|
+
}, [isInitialized, isAuthenticated, user, isSignerInitialized, sdk, authProvider]);
|
|
96
105
|
/**
|
|
97
106
|
* Initialize the blockchain signer with configuration
|
|
98
107
|
*
|
|
@@ -194,8 +203,7 @@ export const useTransactionSigner = () => {
|
|
|
194
203
|
email: currentUser.email || jwtUserInfo.email,
|
|
195
204
|
id: currentUser.id || jwtUserInfo.userId
|
|
196
205
|
};
|
|
197
|
-
// Get PERS access token from the
|
|
198
|
-
const authProvider = sdk.authProvider || sdk._authProvider;
|
|
206
|
+
// Get PERS access token from the auth provider
|
|
199
207
|
console.log('[useTransactionSigner] Auth provider found:', !!authProvider);
|
|
200
208
|
const persAccessToken = authProvider ? await authProvider.getToken() : '';
|
|
201
209
|
console.log('[useTransactionSigner] PERS access token extracted:', persAccessToken ? 'Token found' : 'No token');
|
|
@@ -203,7 +211,7 @@ export const useTransactionSigner = () => {
|
|
|
203
211
|
console.log('[useTransactionSigner] Authenticating user with signer:', signerUserInfo.identifier);
|
|
204
212
|
const signerUser = await signerSDKRef.current.authenticateUser({
|
|
205
213
|
...signerUserInfo,
|
|
206
|
-
persAccessToken: persAccessToken
|
|
214
|
+
persAccessToken: persAccessToken || undefined
|
|
207
215
|
});
|
|
208
216
|
// Sign the PERS transaction using JWT
|
|
209
217
|
console.log('[useTransactionSigner] Signing PERS transaction with JWT containing transaction data');
|
package/dist/index.js
CHANGED
|
@@ -30313,12 +30313,21 @@ const DEFAULT_ETHERS_PROVIDER = "https://sepolia.infura.io/v3/2781b4b5242343d5b0
|
|
|
30313
30313
|
* ```
|
|
30314
30314
|
*/
|
|
30315
30315
|
const useTransactionSigner = () => {
|
|
30316
|
-
const { sdk, isInitialized, isAuthenticated, user } = usePersSDK();
|
|
30316
|
+
const { sdk, isInitialized, isAuthenticated, user, authProvider } = usePersSDK();
|
|
30317
30317
|
const [isSignerInitialized, setIsSignerInitialized] = react.useState(false);
|
|
30318
30318
|
const signerSDKRef = react.useRef(null);
|
|
30319
30319
|
// Auto-initialize signer when user is authenticated and real SDK is available
|
|
30320
30320
|
react.useEffect(() => {
|
|
30321
|
-
|
|
30321
|
+
console.log('[useTransactionSigner] useEffect triggered:', {
|
|
30322
|
+
isInitialized,
|
|
30323
|
+
isAuthenticated,
|
|
30324
|
+
hasUser: !!user,
|
|
30325
|
+
isSignerInitialized,
|
|
30326
|
+
hasSDK: !!sdk,
|
|
30327
|
+
hasAuthProvider: !!authProvider,
|
|
30328
|
+
hasCreatePersSignerSDK: !!createPersSignerSDK
|
|
30329
|
+
});
|
|
30330
|
+
if (isInitialized && isAuthenticated && user && !isSignerInitialized && sdk && authProvider) {
|
|
30322
30331
|
console.log('[useTransactionSigner] Auto-initializing PERS transaction signer...');
|
|
30323
30332
|
// Get configuration from the PERS SDK
|
|
30324
30333
|
const sdkConfig = sdk.config || {};
|
|
@@ -30334,7 +30343,7 @@ const useTransactionSigner = () => {
|
|
|
30334
30343
|
console.error('[useTransactionSigner] Auto-initialization failed:', error);
|
|
30335
30344
|
});
|
|
30336
30345
|
}
|
|
30337
|
-
}, [isInitialized, isAuthenticated, user, isSignerInitialized, sdk]);
|
|
30346
|
+
}, [isInitialized, isAuthenticated, user, isSignerInitialized, sdk, authProvider]);
|
|
30338
30347
|
/**
|
|
30339
30348
|
* Initialize the blockchain signer with configuration
|
|
30340
30349
|
*
|
|
@@ -30436,8 +30445,7 @@ const useTransactionSigner = () => {
|
|
|
30436
30445
|
email: currentUser.email || jwtUserInfo.email,
|
|
30437
30446
|
id: currentUser.id || jwtUserInfo.userId
|
|
30438
30447
|
};
|
|
30439
|
-
// Get PERS access token from the
|
|
30440
|
-
const authProvider = sdk.authProvider || sdk._authProvider;
|
|
30448
|
+
// Get PERS access token from the auth provider
|
|
30441
30449
|
console.log('[useTransactionSigner] Auth provider found:', !!authProvider);
|
|
30442
30450
|
const persAccessToken = authProvider ? await authProvider.getToken() : '';
|
|
30443
30451
|
console.log('[useTransactionSigner] PERS access token extracted:', persAccessToken ? 'Token found' : 'No token');
|
|
@@ -30445,7 +30453,7 @@ const useTransactionSigner = () => {
|
|
|
30445
30453
|
console.log('[useTransactionSigner] Authenticating user with signer:', signerUserInfo.identifier);
|
|
30446
30454
|
const signerUser = await signerSDKRef.current.authenticateUser({
|
|
30447
30455
|
...signerUserInfo,
|
|
30448
|
-
persAccessToken: persAccessToken
|
|
30456
|
+
persAccessToken: persAccessToken || undefined
|
|
30449
30457
|
});
|
|
30450
30458
|
// Sign the PERS transaction using JWT
|
|
30451
30459
|
console.log('[useTransactionSigner] Signing PERS transaction with JWT containing transaction data');
|