@explorins/pers-signer 1.0.9 → 1.0.11
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/dist/browser.cjs.js +4 -68
- package/dist/browser.cjs.js.map +1 -1
- package/dist/browser.d.ts +0 -8
- package/dist/browser.esm.js +4 -68
- package/dist/browser.esm.js.map +1 -1
- package/dist/index.cjs.js +4 -68
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +0 -8
- package/dist/index.esm.js +4 -68
- package/dist/index.esm.js.map +1 -1
- package/dist/react-native.cjs.js +4 -68
- package/dist/react-native.cjs.js.map +1 -1
- package/dist/react-native.d.ts +0 -8
- package/dist/react-native.esm.js +4 -68
- package/dist/react-native.esm.js.map +1 -1
- package/package.json +2 -2
package/dist/browser.cjs.js
CHANGED
|
@@ -310,18 +310,6 @@ class PersService {
|
|
|
310
310
|
if (cached) {
|
|
311
311
|
return cached;
|
|
312
312
|
}
|
|
313
|
-
// Check storage cache (if available)
|
|
314
|
-
const storedTenant = this.getTenantFromStorage(tenantId);
|
|
315
|
-
if (storedTenant) {
|
|
316
|
-
// Restore to memory cache
|
|
317
|
-
this.tenantCache.set(tenantId, storedTenant);
|
|
318
|
-
// Update current project key
|
|
319
|
-
const projectKey = storedTenant.projectApiKey || storedTenant.projectKey || storedTenant.apiKey;
|
|
320
|
-
if (projectKey) {
|
|
321
|
-
this.currentProjectKey = projectKey;
|
|
322
|
-
}
|
|
323
|
-
return storedTenant;
|
|
324
|
-
}
|
|
325
313
|
try {
|
|
326
314
|
const headers = {
|
|
327
315
|
'accept': 'application/json',
|
|
@@ -358,9 +346,8 @@ class PersService {
|
|
|
358
346
|
}
|
|
359
347
|
}
|
|
360
348
|
const tenantData = await response.json();
|
|
361
|
-
// Cache the tenant data
|
|
349
|
+
// Cache the tenant data in memory only
|
|
362
350
|
this.tenantCache.set(tenantId, tenantData);
|
|
363
|
-
this.storeTenantInStorage(tenantId, tenantData);
|
|
364
351
|
// Update current project key (check multiple possible property names)
|
|
365
352
|
this.currentProjectKey = tenantData.projectKey || tenantData.projectApiKey || tenantData.apiKey;
|
|
366
353
|
return tenantData;
|
|
@@ -379,7 +366,7 @@ class PersService {
|
|
|
379
366
|
static async initializeTenant(tenantId, authToken) {
|
|
380
367
|
const tenantData = await this.getTenantById(tenantId, authToken);
|
|
381
368
|
// Update service configuration with tenant's project key
|
|
382
|
-
const projectKey = tenantData.projectApiKey
|
|
369
|
+
const projectKey = tenantData.projectApiKey;
|
|
383
370
|
if (projectKey) {
|
|
384
371
|
this.currentProjectKey = projectKey;
|
|
385
372
|
}
|
|
@@ -399,56 +386,12 @@ class PersService {
|
|
|
399
386
|
console.error('No project key available. Current tenant cache:', Array.from(this.tenantCache.keys()));
|
|
400
387
|
throw new Error('No project key available. Please initialize tenant or configure project key.');
|
|
401
388
|
}
|
|
402
|
-
/**
|
|
403
|
-
* Get cached tenant data (platform-agnostic)
|
|
404
|
-
*/
|
|
405
|
-
static getTenantFromStorage(tenantId) {
|
|
406
|
-
try {
|
|
407
|
-
// Only use localStorage if available (web environment)
|
|
408
|
-
if (typeof localStorage !== 'undefined') {
|
|
409
|
-
const cached = localStorage.getItem(`tenant_${tenantId}`);
|
|
410
|
-
if (cached) {
|
|
411
|
-
const tenantData = JSON.parse(cached);
|
|
412
|
-
return tenantData;
|
|
413
|
-
}
|
|
414
|
-
}
|
|
415
|
-
}
|
|
416
|
-
catch (error) {
|
|
417
|
-
console.warn('Failed to parse cached tenant data:', error);
|
|
418
|
-
}
|
|
419
|
-
return null;
|
|
420
|
-
}
|
|
421
|
-
/**
|
|
422
|
-
* Store tenant data (platform-agnostic)
|
|
423
|
-
*/
|
|
424
|
-
static storeTenantInStorage(tenantId, tenantData) {
|
|
425
|
-
try {
|
|
426
|
-
// Only use localStorage if available (web environment)
|
|
427
|
-
if (typeof localStorage !== 'undefined') {
|
|
428
|
-
localStorage.setItem(`tenant_${tenantId}`, JSON.stringify(tenantData));
|
|
429
|
-
}
|
|
430
|
-
}
|
|
431
|
-
catch (error) {
|
|
432
|
-
// Silent fail for storage issues
|
|
433
|
-
}
|
|
434
|
-
}
|
|
435
389
|
/**
|
|
436
390
|
* Clear tenant cache and reset project key
|
|
437
391
|
*/
|
|
438
392
|
static clearTenantCache() {
|
|
439
393
|
this.tenantCache.clear();
|
|
440
394
|
this.currentProjectKey = null;
|
|
441
|
-
// Clear from cache as well (platform-agnostic)
|
|
442
|
-
const keysToRemove = [];
|
|
443
|
-
if (typeof localStorage !== 'undefined') {
|
|
444
|
-
for (let i = 0; i < localStorage.length; i++) {
|
|
445
|
-
const key = localStorage.key(i);
|
|
446
|
-
if (key?.startsWith('tenant_')) {
|
|
447
|
-
keysToRemove.push(key);
|
|
448
|
-
}
|
|
449
|
-
}
|
|
450
|
-
}
|
|
451
|
-
keysToRemove.forEach(key => localStorage.removeItem(key));
|
|
452
395
|
}
|
|
453
396
|
/**
|
|
454
397
|
* Authenticates a user with the PERS backend using their auth token
|
|
@@ -1352,9 +1295,8 @@ class TransactionSigningService {
|
|
|
1352
1295
|
// Validate transaction status is signable
|
|
1353
1296
|
const isSignable = SIGNABLE_STATUSES.some(status => status === transactionStatus);
|
|
1354
1297
|
if (!isSignable) {
|
|
1355
|
-
// Create
|
|
1298
|
+
// Create status info for UI using TransactionErrorHandler
|
|
1356
1299
|
const statusInfo = TransactionErrorHandler.createStatusInfo(transactionId, transactionStatus);
|
|
1357
|
-
localStorage.setItem('transaction_status', JSON.stringify(statusInfo));
|
|
1358
1300
|
throw { shouldShowStatus: true, statusInfo };
|
|
1359
1301
|
}
|
|
1360
1302
|
// Authenticate with PERS using backend signer token to set up signing account
|
|
@@ -1364,7 +1306,6 @@ class TransactionSigningService {
|
|
|
1364
1306
|
// Update PERS access token with the new one that has signing account linked
|
|
1365
1307
|
const newPersAccessToken = persSignerAuth.accessToken;
|
|
1366
1308
|
if (newPersAccessToken) {
|
|
1367
|
-
localStorage.setItem('pers_access_token', newPersAccessToken);
|
|
1368
1309
|
updatedPersAccessToken = newPersAccessToken;
|
|
1369
1310
|
}
|
|
1370
1311
|
}
|
|
@@ -1389,12 +1330,7 @@ class TransactionSigningService {
|
|
|
1389
1330
|
* Validate and prepare wallet for signing
|
|
1390
1331
|
*/
|
|
1391
1332
|
async prepareWallet(authTokens, ethersProviderUrl) {
|
|
1392
|
-
//
|
|
1393
|
-
const walletRegistrationFailed = localStorage.getItem('wallet_registration_failed') === 'true';
|
|
1394
|
-
if (walletRegistrationFailed) {
|
|
1395
|
-
const errorDetails = localStorage.getItem('wallet_error_details') || 'Unknown wallet error';
|
|
1396
|
-
throw TransactionErrorHandler.createError(exports.TransactionSigningErrorCode.WALLET_NOT_AVAILABLE, `Wallet not available for transaction signing. Registration failed: ${errorDetails}. Please refresh the page and complete wallet setup.`);
|
|
1397
|
-
}
|
|
1333
|
+
// Wallet validation will be handled through API responses - no localStorage needed
|
|
1398
1334
|
let walletData;
|
|
1399
1335
|
try {
|
|
1400
1336
|
walletData = await WalletService.listWallets(authTokens.backendAuthToken);
|