@explorins/pers-sdk-react-native 1.5.11 → 1.5.13
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
|
@@ -151,12 +151,13 @@ export const useTransactionSigner = () => {
|
|
|
151
151
|
|
|
152
152
|
// Try to extract tenantId from JWT token if available
|
|
153
153
|
let tenantIdFromJWT: string | undefined;
|
|
154
|
+
let authToken: string | null | undefined;
|
|
154
155
|
if (authProvider.getToken) {
|
|
155
156
|
try {
|
|
156
|
-
|
|
157
|
-
if (
|
|
157
|
+
authToken = await authProvider.getToken();
|
|
158
|
+
if (authToken) {
|
|
158
159
|
// Decode JWT to get tenant information
|
|
159
|
-
const tokenParts =
|
|
160
|
+
const tokenParts = authToken.split('.');
|
|
160
161
|
if (tokenParts.length >= 2) {
|
|
161
162
|
const payload = JSON.parse(atob(tokenParts[1]));
|
|
162
163
|
console.log('[useTransactionSigner] JWT payload decoded:', payload);
|
|
@@ -249,13 +250,14 @@ export const useTransactionSigner = () => {
|
|
|
249
250
|
console.log('[useTransactionSigner] Initializing tenant for tenantId:', config.tenantId);
|
|
250
251
|
|
|
251
252
|
// We need to set the auth token first for tenant initialization
|
|
253
|
+
let authToken: string | null | undefined;
|
|
252
254
|
if (authProvider) {
|
|
253
255
|
try {
|
|
254
|
-
|
|
255
|
-
if (
|
|
256
|
+
authToken = await authProvider.getToken();
|
|
257
|
+
if (authToken) {
|
|
256
258
|
console.log('[useTransactionSigner] Setting auth token for tenant initialization');
|
|
257
259
|
(PersService as any).configure({
|
|
258
|
-
token:
|
|
260
|
+
token: authToken
|
|
259
261
|
});
|
|
260
262
|
}
|
|
261
263
|
} catch (tokenError) {
|
|
@@ -263,9 +265,29 @@ export const useTransactionSigner = () => {
|
|
|
263
265
|
}
|
|
264
266
|
}
|
|
265
267
|
|
|
266
|
-
await (PersService as any).initializeTenant(config.tenantId);
|
|
268
|
+
await (PersService as any).initializeTenant(config.tenantId, authToken);
|
|
267
269
|
console.log('[useTransactionSigner] Tenant initialized successfully');
|
|
268
270
|
|
|
271
|
+
// Get tenant data to extract project key manually
|
|
272
|
+
try {
|
|
273
|
+
const tenantData = await (PersService as any).getTenantById(config.tenantId, authToken);
|
|
274
|
+
console.log('[useTransactionSigner] Tenant data retrieved:', tenantData);
|
|
275
|
+
|
|
276
|
+
// Extract and set project key manually if initializeTenant didn't set it
|
|
277
|
+
const projectKey = tenantData.projectApiKey || tenantData.projectKey || tenantData.apiKey;
|
|
278
|
+
if (projectKey) {
|
|
279
|
+
console.log('[useTransactionSigner] Setting project key manually:', projectKey);
|
|
280
|
+
(PersService as any).configure({
|
|
281
|
+
token: authToken,
|
|
282
|
+
projectKey: projectKey
|
|
283
|
+
});
|
|
284
|
+
} else {
|
|
285
|
+
console.warn('[useTransactionSigner] No project key found in tenant data:', tenantData);
|
|
286
|
+
}
|
|
287
|
+
} catch (tenantError) {
|
|
288
|
+
console.error('[useTransactionSigner] Failed to retrieve tenant data for project key:', tenantError);
|
|
289
|
+
}
|
|
290
|
+
|
|
269
291
|
// Verify configuration
|
|
270
292
|
const persConfig = (PersService as any).getConfig();
|
|
271
293
|
console.log('[useTransactionSigner] PERS service config after tenant initialization:', persConfig);
|