@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/index.d.ts
CHANGED
|
@@ -301,14 +301,6 @@ declare class PersService {
|
|
|
301
301
|
* @returns The project key to use for API calls
|
|
302
302
|
*/
|
|
303
303
|
private static getProjectKey;
|
|
304
|
-
/**
|
|
305
|
-
* Get cached tenant data (platform-agnostic)
|
|
306
|
-
*/
|
|
307
|
-
private static getTenantFromStorage;
|
|
308
|
-
/**
|
|
309
|
-
* Store tenant data (platform-agnostic)
|
|
310
|
-
*/
|
|
311
|
-
private static storeTenantInStorage;
|
|
312
304
|
/**
|
|
313
305
|
* Clear tenant cache and reset project key
|
|
314
306
|
*/
|
package/dist/index.esm.js
CHANGED
|
@@ -526,18 +526,6 @@ class PersService {
|
|
|
526
526
|
if (cached) {
|
|
527
527
|
return cached;
|
|
528
528
|
}
|
|
529
|
-
// Check storage cache (if available)
|
|
530
|
-
const storedTenant = this.getTenantFromStorage(tenantId);
|
|
531
|
-
if (storedTenant) {
|
|
532
|
-
// Restore to memory cache
|
|
533
|
-
this.tenantCache.set(tenantId, storedTenant);
|
|
534
|
-
// Update current project key
|
|
535
|
-
const projectKey = storedTenant.projectApiKey || storedTenant.projectKey || storedTenant.apiKey;
|
|
536
|
-
if (projectKey) {
|
|
537
|
-
this.currentProjectKey = projectKey;
|
|
538
|
-
}
|
|
539
|
-
return storedTenant;
|
|
540
|
-
}
|
|
541
529
|
try {
|
|
542
530
|
const headers = {
|
|
543
531
|
'accept': 'application/json',
|
|
@@ -574,9 +562,8 @@ class PersService {
|
|
|
574
562
|
}
|
|
575
563
|
}
|
|
576
564
|
const tenantData = await response.json();
|
|
577
|
-
// Cache the tenant data
|
|
565
|
+
// Cache the tenant data in memory only
|
|
578
566
|
this.tenantCache.set(tenantId, tenantData);
|
|
579
|
-
this.storeTenantInStorage(tenantId, tenantData);
|
|
580
567
|
// Update current project key (check multiple possible property names)
|
|
581
568
|
this.currentProjectKey = tenantData.projectKey || tenantData.projectApiKey || tenantData.apiKey;
|
|
582
569
|
return tenantData;
|
|
@@ -595,7 +582,7 @@ class PersService {
|
|
|
595
582
|
static async initializeTenant(tenantId, authToken) {
|
|
596
583
|
const tenantData = await this.getTenantById(tenantId, authToken);
|
|
597
584
|
// Update service configuration with tenant's project key
|
|
598
|
-
const projectKey = tenantData.projectApiKey
|
|
585
|
+
const projectKey = tenantData.projectApiKey;
|
|
599
586
|
if (projectKey) {
|
|
600
587
|
this.currentProjectKey = projectKey;
|
|
601
588
|
}
|
|
@@ -615,56 +602,12 @@ class PersService {
|
|
|
615
602
|
console.error('No project key available. Current tenant cache:', Array.from(this.tenantCache.keys()));
|
|
616
603
|
throw new Error('No project key available. Please initialize tenant or configure project key.');
|
|
617
604
|
}
|
|
618
|
-
/**
|
|
619
|
-
* Get cached tenant data (platform-agnostic)
|
|
620
|
-
*/
|
|
621
|
-
static getTenantFromStorage(tenantId) {
|
|
622
|
-
try {
|
|
623
|
-
// Only use localStorage if available (web environment)
|
|
624
|
-
if (typeof localStorage !== 'undefined') {
|
|
625
|
-
const cached = localStorage.getItem(`tenant_${tenantId}`);
|
|
626
|
-
if (cached) {
|
|
627
|
-
const tenantData = JSON.parse(cached);
|
|
628
|
-
return tenantData;
|
|
629
|
-
}
|
|
630
|
-
}
|
|
631
|
-
}
|
|
632
|
-
catch (error) {
|
|
633
|
-
console.warn('Failed to parse cached tenant data:', error);
|
|
634
|
-
}
|
|
635
|
-
return null;
|
|
636
|
-
}
|
|
637
|
-
/**
|
|
638
|
-
* Store tenant data (platform-agnostic)
|
|
639
|
-
*/
|
|
640
|
-
static storeTenantInStorage(tenantId, tenantData) {
|
|
641
|
-
try {
|
|
642
|
-
// Only use localStorage if available (web environment)
|
|
643
|
-
if (typeof localStorage !== 'undefined') {
|
|
644
|
-
localStorage.setItem(`tenant_${tenantId}`, JSON.stringify(tenantData));
|
|
645
|
-
}
|
|
646
|
-
}
|
|
647
|
-
catch (error) {
|
|
648
|
-
// Silent fail for storage issues
|
|
649
|
-
}
|
|
650
|
-
}
|
|
651
605
|
/**
|
|
652
606
|
* Clear tenant cache and reset project key
|
|
653
607
|
*/
|
|
654
608
|
static clearTenantCache() {
|
|
655
609
|
this.tenantCache.clear();
|
|
656
610
|
this.currentProjectKey = null;
|
|
657
|
-
// Clear from cache as well (platform-agnostic)
|
|
658
|
-
const keysToRemove = [];
|
|
659
|
-
if (typeof localStorage !== 'undefined') {
|
|
660
|
-
for (let i = 0; i < localStorage.length; i++) {
|
|
661
|
-
const key = localStorage.key(i);
|
|
662
|
-
if (key?.startsWith('tenant_')) {
|
|
663
|
-
keysToRemove.push(key);
|
|
664
|
-
}
|
|
665
|
-
}
|
|
666
|
-
}
|
|
667
|
-
keysToRemove.forEach(key => localStorage.removeItem(key));
|
|
668
611
|
}
|
|
669
612
|
/**
|
|
670
613
|
* Authenticates a user with the PERS backend using their auth token
|
|
@@ -1469,9 +1412,8 @@ class TransactionSigningService {
|
|
|
1469
1412
|
// Validate transaction status is signable
|
|
1470
1413
|
const isSignable = SIGNABLE_STATUSES.some(status => status === transactionStatus);
|
|
1471
1414
|
if (!isSignable) {
|
|
1472
|
-
// Create
|
|
1415
|
+
// Create status info for UI using TransactionErrorHandler
|
|
1473
1416
|
const statusInfo = TransactionErrorHandler.createStatusInfo(transactionId, transactionStatus);
|
|
1474
|
-
localStorage.setItem('transaction_status', JSON.stringify(statusInfo));
|
|
1475
1417
|
throw { shouldShowStatus: true, statusInfo };
|
|
1476
1418
|
}
|
|
1477
1419
|
// Authenticate with PERS using backend signer token to set up signing account
|
|
@@ -1481,7 +1423,6 @@ class TransactionSigningService {
|
|
|
1481
1423
|
// Update PERS access token with the new one that has signing account linked
|
|
1482
1424
|
const newPersAccessToken = persSignerAuth.accessToken;
|
|
1483
1425
|
if (newPersAccessToken) {
|
|
1484
|
-
localStorage.setItem('pers_access_token', newPersAccessToken);
|
|
1485
1426
|
updatedPersAccessToken = newPersAccessToken;
|
|
1486
1427
|
}
|
|
1487
1428
|
}
|
|
@@ -1506,12 +1447,7 @@ class TransactionSigningService {
|
|
|
1506
1447
|
* Validate and prepare wallet for signing
|
|
1507
1448
|
*/
|
|
1508
1449
|
async prepareWallet(authTokens, ethersProviderUrl) {
|
|
1509
|
-
//
|
|
1510
|
-
const walletRegistrationFailed = localStorage.getItem('wallet_registration_failed') === 'true';
|
|
1511
|
-
if (walletRegistrationFailed) {
|
|
1512
|
-
const errorDetails = localStorage.getItem('wallet_error_details') || 'Unknown wallet error';
|
|
1513
|
-
throw TransactionErrorHandler.createError(TransactionSigningErrorCode.WALLET_NOT_AVAILABLE, `Wallet not available for transaction signing. Registration failed: ${errorDetails}. Please refresh the page and complete wallet setup.`);
|
|
1514
|
-
}
|
|
1450
|
+
// Wallet validation will be handled through API responses - no localStorage needed
|
|
1515
1451
|
let walletData;
|
|
1516
1452
|
try {
|
|
1517
1453
|
walletData = await WalletService.listWallets(authTokens.backendAuthToken);
|