@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.
|
@@ -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;IAsL7B;;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,16 +71,18 @@ 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
|
-
if (isInitialized && isAuthenticated && user && !isSignerInitialized && sdk) {
|
|
79
|
+
if (isInitialized && isAuthenticated && user && !isSignerInitialized && sdk && authProvider) {
|
|
80
80
|
console.log('[useTransactionSigner] Auto-initializing PERS transaction signer...');
|
|
81
81
|
// Get configuration from the PERS SDK
|
|
82
82
|
const sdkConfig = sdk.config || {};
|
|
83
|
+
console.log('[useTransactionSigner] SDK config:', sdkConfig);
|
|
83
84
|
const apiProjectKey = sdkConfig.apiProjectKey || 'demo-project-key';
|
|
85
|
+
console.log('[useTransactionSigner] Extracted API project key:', apiProjectKey);
|
|
84
86
|
const tenantId = sdkConfig.tenantId || 'vq-demo';
|
|
85
87
|
initializeSigner({
|
|
86
88
|
tenantId: tenantId,
|
|
@@ -90,7 +92,7 @@ export const useTransactionSigner = () => {
|
|
|
90
92
|
console.error('[useTransactionSigner] Auto-initialization failed:', error);
|
|
91
93
|
});
|
|
92
94
|
}
|
|
93
|
-
}, [isInitialized, isAuthenticated, user, isSignerInitialized, sdk]);
|
|
95
|
+
}, [isInitialized, isAuthenticated, user, isSignerInitialized, sdk, authProvider]);
|
|
94
96
|
/**
|
|
95
97
|
* Initialize the blockchain signer with configuration
|
|
96
98
|
*
|
|
@@ -117,12 +119,21 @@ export const useTransactionSigner = () => {
|
|
|
117
119
|
// Configure the PERS service with the project key before creating SDK
|
|
118
120
|
if (config?.projectKey) {
|
|
119
121
|
console.log('[useTransactionSigner] Configuring PERS service with project key:', config.projectKey);
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
122
|
+
try {
|
|
123
|
+
// Import and configure the PERS service
|
|
124
|
+
const { PersService } = await import('@explorins/pers-signer/react-native');
|
|
125
|
+
console.log('[useTransactionSigner] PersService imported successfully');
|
|
126
|
+
PersService.configure({
|
|
127
|
+
projectKey: config.projectKey
|
|
128
|
+
});
|
|
129
|
+
console.log('[useTransactionSigner] PERS service configured with project key');
|
|
130
|
+
// Verify configuration
|
|
131
|
+
const persConfig = PersService.getConfig();
|
|
132
|
+
console.log('[useTransactionSigner] PERS service config after configuration:', persConfig);
|
|
133
|
+
}
|
|
134
|
+
catch (configError) {
|
|
135
|
+
console.error('[useTransactionSigner] Failed to configure PERS service:', configError);
|
|
136
|
+
}
|
|
126
137
|
}
|
|
127
138
|
const signerSDK = await createPersSignerSDK({
|
|
128
139
|
tenantId: config?.tenantId,
|
|
@@ -183,14 +194,15 @@ export const useTransactionSigner = () => {
|
|
|
183
194
|
email: currentUser.email || jwtUserInfo.email,
|
|
184
195
|
id: currentUser.id || jwtUserInfo.userId
|
|
185
196
|
};
|
|
186
|
-
// Get PERS access token from the
|
|
187
|
-
|
|
197
|
+
// Get PERS access token from the auth provider
|
|
198
|
+
console.log('[useTransactionSigner] Auth provider found:', !!authProvider);
|
|
188
199
|
const persAccessToken = authProvider ? await authProvider.getToken() : '';
|
|
200
|
+
console.log('[useTransactionSigner] PERS access token extracted:', persAccessToken ? 'Token found' : 'No token');
|
|
189
201
|
// Authenticate user with blockchain signer and pass PERS token
|
|
190
202
|
console.log('[useTransactionSigner] Authenticating user with signer:', signerUserInfo.identifier);
|
|
191
203
|
const signerUser = await signerSDKRef.current.authenticateUser({
|
|
192
204
|
...signerUserInfo,
|
|
193
|
-
persAccessToken: persAccessToken
|
|
205
|
+
persAccessToken: persAccessToken || undefined
|
|
194
206
|
});
|
|
195
207
|
// Sign the PERS transaction using JWT
|
|
196
208
|
console.log('[useTransactionSigner] Signing PERS transaction with JWT containing transaction data');
|
package/dist/index.js
CHANGED
|
@@ -30313,16 +30313,18 @@ 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
|
-
if (isInitialized && isAuthenticated && user && !isSignerInitialized && sdk) {
|
|
30321
|
+
if (isInitialized && isAuthenticated && user && !isSignerInitialized && sdk && authProvider) {
|
|
30322
30322
|
console.log('[useTransactionSigner] Auto-initializing PERS transaction signer...');
|
|
30323
30323
|
// Get configuration from the PERS SDK
|
|
30324
30324
|
const sdkConfig = sdk.config || {};
|
|
30325
|
+
console.log('[useTransactionSigner] SDK config:', sdkConfig);
|
|
30325
30326
|
const apiProjectKey = sdkConfig.apiProjectKey || 'demo-project-key';
|
|
30327
|
+
console.log('[useTransactionSigner] Extracted API project key:', apiProjectKey);
|
|
30326
30328
|
const tenantId = sdkConfig.tenantId || 'vq-demo';
|
|
30327
30329
|
initializeSigner({
|
|
30328
30330
|
tenantId: tenantId,
|
|
@@ -30332,7 +30334,7 @@ const useTransactionSigner = () => {
|
|
|
30332
30334
|
console.error('[useTransactionSigner] Auto-initialization failed:', error);
|
|
30333
30335
|
});
|
|
30334
30336
|
}
|
|
30335
|
-
}, [isInitialized, isAuthenticated, user, isSignerInitialized, sdk]);
|
|
30337
|
+
}, [isInitialized, isAuthenticated, user, isSignerInitialized, sdk, authProvider]);
|
|
30336
30338
|
/**
|
|
30337
30339
|
* Initialize the blockchain signer with configuration
|
|
30338
30340
|
*
|
|
@@ -30359,12 +30361,21 @@ const useTransactionSigner = () => {
|
|
|
30359
30361
|
// Configure the PERS service with the project key before creating SDK
|
|
30360
30362
|
if (config?.projectKey) {
|
|
30361
30363
|
console.log('[useTransactionSigner] Configuring PERS service with project key:', config.projectKey);
|
|
30362
|
-
|
|
30363
|
-
|
|
30364
|
-
|
|
30365
|
-
|
|
30366
|
-
|
|
30367
|
-
|
|
30364
|
+
try {
|
|
30365
|
+
// Import and configure the PERS service
|
|
30366
|
+
const { PersService } = await Promise.resolve().then(function () { return require('./react-native.esm-BtyCg4n1.js'); });
|
|
30367
|
+
console.log('[useTransactionSigner] PersService imported successfully');
|
|
30368
|
+
PersService.configure({
|
|
30369
|
+
projectKey: config.projectKey
|
|
30370
|
+
});
|
|
30371
|
+
console.log('[useTransactionSigner] PERS service configured with project key');
|
|
30372
|
+
// Verify configuration
|
|
30373
|
+
const persConfig = PersService.getConfig();
|
|
30374
|
+
console.log('[useTransactionSigner] PERS service config after configuration:', persConfig);
|
|
30375
|
+
}
|
|
30376
|
+
catch (configError) {
|
|
30377
|
+
console.error('[useTransactionSigner] Failed to configure PERS service:', configError);
|
|
30378
|
+
}
|
|
30368
30379
|
}
|
|
30369
30380
|
const signerSDK = await createPersSignerSDK({
|
|
30370
30381
|
tenantId: config?.tenantId,
|
|
@@ -30425,14 +30436,15 @@ const useTransactionSigner = () => {
|
|
|
30425
30436
|
email: currentUser.email || jwtUserInfo.email,
|
|
30426
30437
|
id: currentUser.id || jwtUserInfo.userId
|
|
30427
30438
|
};
|
|
30428
|
-
// Get PERS access token from the
|
|
30429
|
-
|
|
30439
|
+
// Get PERS access token from the auth provider
|
|
30440
|
+
console.log('[useTransactionSigner] Auth provider found:', !!authProvider);
|
|
30430
30441
|
const persAccessToken = authProvider ? await authProvider.getToken() : '';
|
|
30442
|
+
console.log('[useTransactionSigner] PERS access token extracted:', persAccessToken ? 'Token found' : 'No token');
|
|
30431
30443
|
// Authenticate user with blockchain signer and pass PERS token
|
|
30432
30444
|
console.log('[useTransactionSigner] Authenticating user with signer:', signerUserInfo.identifier);
|
|
30433
30445
|
const signerUser = await signerSDKRef.current.authenticateUser({
|
|
30434
30446
|
...signerUserInfo,
|
|
30435
|
-
persAccessToken: persAccessToken
|
|
30447
|
+
persAccessToken: persAccessToken || undefined
|
|
30436
30448
|
});
|
|
30437
30449
|
// Sign the PERS transaction using JWT
|
|
30438
30450
|
console.log('[useTransactionSigner] Signing PERS transaction with JWT containing transaction data');
|