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