@explorins/pers-sdk 2.1.37 → 2.1.40
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/business/api/business-api.d.ts +4 -0
- package/dist/business/api/business-api.d.ts.map +1 -1
- package/dist/business/index.d.ts +1 -1
- package/dist/business/index.d.ts.map +1 -1
- package/dist/business.cjs +1 -1
- package/dist/business.js +1 -1
- package/dist/chunks/{base-token-service-BGuuZX4b.js → base-token-service-N1gwRD8N.js} +2 -2
- package/dist/chunks/{base-token-service-BGuuZX4b.js.map → base-token-service-N1gwRD8N.js.map} +1 -1
- package/dist/chunks/{base-token-service-DSye0WD2.cjs → base-token-service-W7TU23qU.cjs} +2 -2
- package/dist/chunks/{base-token-service-DSye0WD2.cjs.map → base-token-service-W7TU23qU.cjs.map} +1 -1
- package/dist/chunks/{business-membership-service-B9ItWZ2_.cjs → business-membership-service-Dkb780NX.cjs} +21 -1
- package/dist/chunks/business-membership-service-Dkb780NX.cjs.map +1 -0
- package/dist/chunks/{business-membership-service-CPcE-AW0.js → business-membership-service-NLoqoFpG.js} +21 -1
- package/dist/chunks/business-membership-service-NLoqoFpG.js.map +1 -0
- package/dist/chunks/{pers-sdk-DemghJ3a.cjs → pers-sdk-CBvzmlL_.cjs} +158 -77
- package/dist/chunks/pers-sdk-CBvzmlL_.cjs.map +1 -0
- package/dist/chunks/{pers-sdk-Dds2lB27.js → pers-sdk-DuDWwRWC.js} +158 -77
- package/dist/chunks/pers-sdk-DuDWwRWC.js.map +1 -0
- package/dist/chunks/{redemption-service-Dc_0Kzd0.cjs → redemption-service-KamEndzB.cjs} +7 -1
- package/dist/chunks/{redemption-service-Dc_0Kzd0.cjs.map → redemption-service-KamEndzB.cjs.map} +1 -1
- package/dist/chunks/{redemption-service-DWhZgrZT.js → redemption-service-w0GMdF0m.js} +7 -1
- package/dist/chunks/{redemption-service-DWhZgrZT.js.map → redemption-service-w0GMdF0m.js.map} +1 -1
- package/dist/chunks/{token-service-qRSYG9uT.js → token-service-BcuDj292.js} +79 -14
- package/dist/chunks/token-service-BcuDj292.js.map +1 -0
- package/dist/chunks/{token-service-BJqu5Xap.cjs → token-service-CnnrCOsg.cjs} +79 -14
- package/dist/chunks/token-service-CnnrCOsg.cjs.map +1 -0
- package/dist/chunks/{web3-manager-Dvcq4xmn.js → web3-manager-B-IsluxI.js} +770 -34
- package/dist/chunks/web3-manager-B-IsluxI.js.map +1 -0
- package/dist/chunks/{web3-manager-C-JflQ86.cjs → web3-manager-NJaeBrci.cjs} +770 -32
- package/dist/chunks/web3-manager-NJaeBrci.cjs.map +1 -0
- package/dist/core/auth/refresh-manager.d.ts +12 -2
- package/dist/core/auth/refresh-manager.d.ts.map +1 -1
- package/dist/core/auth/services/auth-service.d.ts +4 -1
- package/dist/core/auth/services/auth-service.d.ts.map +1 -1
- package/dist/core/pers-api-client.d.ts.map +1 -1
- package/dist/core.cjs +4 -4
- package/dist/core.js +4 -4
- package/dist/index.cjs +5 -5
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -5
- package/dist/managers/redemption-manager.d.ts +13 -0
- package/dist/managers/redemption-manager.d.ts.map +1 -1
- package/dist/managers/token-manager.d.ts +66 -40
- package/dist/managers/token-manager.d.ts.map +1 -1
- package/dist/managers/web3-manager.d.ts +69 -1
- package/dist/managers/web3-manager.d.ts.map +1 -1
- package/dist/node.cjs +4 -4
- package/dist/node.js +4 -4
- package/dist/package.json +3 -3
- package/dist/redemption/services/redemption-service.d.ts +4 -0
- package/dist/redemption/services/redemption-service.d.ts.map +1 -1
- package/dist/redemption.cjs +1 -1
- package/dist/redemption.js +1 -1
- package/dist/token/api/token-api.d.ts +50 -12
- package/dist/token/api/token-api.d.ts.map +1 -1
- package/dist/token/index.d.ts +1 -1
- package/dist/token/index.d.ts.map +1 -1
- package/dist/token/services/token-service.d.ts +40 -9
- package/dist/token/services/token-service.d.ts.map +1 -1
- package/dist/token.cjs +2 -2
- package/dist/token.js +2 -2
- package/dist/trigger-source/api/trigger-source-api.d.ts +9 -10
- package/dist/trigger-source/api/trigger-source-api.d.ts.map +1 -1
- package/dist/trigger-source/index.d.ts +1 -0
- package/dist/trigger-source/index.d.ts.map +1 -1
- package/dist/trigger-source/models/index.d.ts +5 -13
- package/dist/trigger-source/models/index.d.ts.map +1 -1
- package/dist/trigger-source/services/trigger-source-service.d.ts +3 -11
- package/dist/trigger-source/services/trigger-source-service.d.ts.map +1 -1
- package/dist/trigger-source.cjs +20 -1
- package/dist/trigger-source.cjs.map +1 -1
- package/dist/trigger-source.js +20 -1
- package/dist/trigger-source.js.map +1 -1
- package/dist/web3/domain/services/balance-manager.d.ts +160 -0
- package/dist/web3/domain/services/balance-manager.d.ts.map +1 -0
- package/dist/web3/domain/services/index.d.ts +2 -0
- package/dist/web3/domain/services/index.d.ts.map +1 -1
- package/dist/web3/domain/services/token-collection-manager.d.ts +155 -0
- package/dist/web3/domain/services/token-collection-manager.d.ts.map +1 -0
- package/dist/web3/domain/services/token-domain.service.d.ts.map +1 -1
- package/dist/web3/index.d.ts +1 -0
- package/dist/web3/index.d.ts.map +1 -1
- package/dist/web3/infrastructure/api/web3-api.d.ts +16 -0
- package/dist/web3/infrastructure/api/web3-api.d.ts.map +1 -1
- package/dist/web3-manager.cjs +1 -1
- package/dist/web3-manager.js +1 -1
- package/dist/web3.cjs +4 -2
- package/dist/web3.cjs.map +1 -1
- package/dist/web3.js +2 -2
- package/package.json +3 -3
- package/dist/chunks/business-membership-service-B9ItWZ2_.cjs.map +0 -1
- package/dist/chunks/business-membership-service-CPcE-AW0.js.map +0 -1
- package/dist/chunks/pers-sdk-Dds2lB27.js.map +0 -1
- package/dist/chunks/pers-sdk-DemghJ3a.cjs.map +0 -1
- package/dist/chunks/token-service-BJqu5Xap.cjs.map +0 -1
- package/dist/chunks/token-service-qRSYG9uT.js.map +0 -1
- package/dist/chunks/web3-manager-C-JflQ86.cjs.map +0 -1
- package/dist/chunks/web3-manager-Dvcq4xmn.js.map +0 -1
|
@@ -2,10 +2,10 @@ import { AccountOwnerType, MembershipRole, WebhookMethod, WebhookExecutionStatus
|
|
|
2
2
|
import { i as isTokenExpired, d as decodeJwtPayload, e as getTokenTimeToLive, E as ErrorUtils, A as AuthenticationError, b as PersApiError } from './index--OssIds0.js';
|
|
3
3
|
import { UserService, UserApi } from '../user.js';
|
|
4
4
|
import { createUserStatusSDK } from '../user-status.js';
|
|
5
|
-
import { a as TokenService, T as TokenApi } from './token-service-
|
|
6
|
-
import { B as BusinessApi, b as BusinessService, a as BusinessMembershipApi, c as BusinessMembershipService } from './business-membership-service-
|
|
5
|
+
import { a as TokenService, T as TokenApi } from './token-service-BcuDj292.js';
|
|
6
|
+
import { B as BusinessApi, b as BusinessService, a as BusinessMembershipApi, c as BusinessMembershipService } from './business-membership-service-NLoqoFpG.js';
|
|
7
7
|
import { CampaignService, CampaignApi } from '../campaign.js';
|
|
8
|
-
import { a as RedemptionService, R as RedemptionApi } from './redemption-service-
|
|
8
|
+
import { a as RedemptionService, R as RedemptionApi } from './redemption-service-w0GMdF0m.js';
|
|
9
9
|
import { a as TransactionService, T as TransactionApi } from './transaction-request.builder-BZ6Uq6Qe.js';
|
|
10
10
|
import { a as PaymentService, P as PurchaseApi } from './payment-service-IvM6rryM.js';
|
|
11
11
|
import { T as TenantManager } from './tenant-manager-xmYKBFGu.js';
|
|
@@ -502,6 +502,9 @@ class AuthService {
|
|
|
502
502
|
* Extracts context (tenantId/businessId) from the current refresh token to ensure
|
|
503
503
|
* the recovered session maintains the same context.
|
|
504
504
|
*
|
|
505
|
+
* This is a PUBLIC method that can be called by TokenRefreshManager when internal
|
|
506
|
+
* refresh fails, to try external (provider token) recovery before giving up.
|
|
507
|
+
*
|
|
505
508
|
* @returns true if session was successfully recovered
|
|
506
509
|
*/
|
|
507
510
|
async attemptProviderTokenRecovery() {
|
|
@@ -654,6 +657,8 @@ class TokenRefreshManager {
|
|
|
654
657
|
// Retry configuration for transient failures
|
|
655
658
|
this.MAX_RETRY_ATTEMPTS = 3;
|
|
656
659
|
this.RETRY_DELAY_MS = 1000;
|
|
660
|
+
// Active refresh promise for deduplication
|
|
661
|
+
this.activeRefreshPromise = null;
|
|
657
662
|
}
|
|
658
663
|
/**
|
|
659
664
|
* Ensures the access token is valid, refreshing if needed.
|
|
@@ -754,11 +759,27 @@ class TokenRefreshManager {
|
|
|
754
759
|
return new Promise(resolve => setTimeout(resolve, ms));
|
|
755
760
|
}
|
|
756
761
|
/**
|
|
757
|
-
*
|
|
762
|
+
* Attempt token refresh: internal first, then provider token fallback.
|
|
763
|
+
* DEDUPLICATES concurrent calls - all callers share the same promise.
|
|
758
764
|
*/
|
|
759
765
|
async attemptInternalRefresh() {
|
|
760
|
-
|
|
761
|
-
|
|
766
|
+
if (this.activeRefreshPromise) {
|
|
767
|
+
return this.activeRefreshPromise;
|
|
768
|
+
}
|
|
769
|
+
this.activeRefreshPromise = (async () => {
|
|
770
|
+
const result = await this.attemptRefreshWithRetry();
|
|
771
|
+
if (result.success)
|
|
772
|
+
return result;
|
|
773
|
+
// Internal failed - try provider token recovery
|
|
774
|
+
const recovered = await this.authService.attemptProviderTokenRecovery();
|
|
775
|
+
return recovered ? { success: true, retryable: false } : result;
|
|
776
|
+
})();
|
|
777
|
+
try {
|
|
778
|
+
return await this.activeRefreshPromise;
|
|
779
|
+
}
|
|
780
|
+
finally {
|
|
781
|
+
this.activeRefreshPromise = null;
|
|
782
|
+
}
|
|
762
783
|
}
|
|
763
784
|
}
|
|
764
785
|
|
|
@@ -1564,7 +1585,7 @@ class DefaultAuthProvider {
|
|
|
1564
1585
|
/** SDK package name */
|
|
1565
1586
|
const SDK_NAME = "@explorins/pers-sdk";
|
|
1566
1587
|
/** SDK version - injected from package.json at build time */
|
|
1567
|
-
const SDK_VERSION = "2.1.
|
|
1588
|
+
const SDK_VERSION = "2.1.40";
|
|
1568
1589
|
/** Full SDK identifier for headers */
|
|
1569
1590
|
const SDK_USER_AGENT = `${SDK_NAME}/${SDK_VERSION}`;
|
|
1570
1591
|
|
|
@@ -1674,12 +1695,16 @@ class PersApiClient {
|
|
|
1674
1695
|
}
|
|
1675
1696
|
const { retryCount = 0, responseType = 'json', bypassAuth = false } = options || {};
|
|
1676
1697
|
const url = `${this.apiRoot}${endpoint}`;
|
|
1677
|
-
//
|
|
1698
|
+
// TOKEN VALIDATION: Ensure token is valid before request
|
|
1699
|
+
// This blocks the request until token validation completes - prevents 401s from expired tokens
|
|
1678
1700
|
if (!bypassAuth && this.mergedConfig.authProvider && retryCount === 0) {
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1701
|
+
try {
|
|
1702
|
+
await this.ensureValidToken();
|
|
1703
|
+
}
|
|
1704
|
+
catch (error) {
|
|
1705
|
+
console.debug('[PersApiClient] Token validation failed:', error);
|
|
1706
|
+
// Continue with request - it will fail with 401 and trigger retry logic
|
|
1707
|
+
}
|
|
1683
1708
|
}
|
|
1684
1709
|
const requestOptions = {
|
|
1685
1710
|
headers: await this.getHeaders(!bypassAuth, method, url),
|
|
@@ -1707,49 +1732,63 @@ class PersApiClient {
|
|
|
1707
1732
|
return result;
|
|
1708
1733
|
}
|
|
1709
1734
|
catch (error) {
|
|
1710
|
-
// Error handling - proactive token refresh should prevent most 401s
|
|
1711
1735
|
const status = ErrorUtils.getStatus(error);
|
|
1712
1736
|
const errorMessage = ErrorUtils.getMessage(error);
|
|
1713
|
-
// Handle 401 errors
|
|
1737
|
+
// Handle 401 Unauthorized errors
|
|
1714
1738
|
if (status === 401) {
|
|
1715
1739
|
const backendError = ErrorUtils.extractBackendErrorDetails(error);
|
|
1716
|
-
//
|
|
1717
|
-
//
|
|
1718
|
-
//
|
|
1740
|
+
// ===========================================
|
|
1741
|
+
// FATAL AUTH ERRORS → Immediate logout
|
|
1742
|
+
// ===========================================
|
|
1743
|
+
// Fatal codes: REFRESH_TOKEN_EXPIRED, TOKEN_REVOKED, INVALID_REFRESH_TOKEN, etc.
|
|
1719
1744
|
if (this.authService.isFatalAuthError(backendError.code)) {
|
|
1720
|
-
|
|
1745
|
+
console.warn(`[PersApiClient] Fatal auth error: ${backendError.code}`);
|
|
1721
1746
|
await this.authService.handleAuthFailure();
|
|
1722
1747
|
this.emitErrorEvent(backendError, errorMessage, endpoint, method, status, error);
|
|
1723
1748
|
throw new AuthenticationError(errorMessage, endpoint, method, backendError);
|
|
1724
1749
|
}
|
|
1725
|
-
//
|
|
1750
|
+
// ===========================================
|
|
1751
|
+
// REFRESH REQUEST FAILED → Logout (prevents infinite loop)
|
|
1752
|
+
// ===========================================
|
|
1726
1753
|
if (options?.isRefreshRequest) {
|
|
1727
|
-
|
|
1754
|
+
console.warn('[PersApiClient] Refresh request itself failed with 401');
|
|
1728
1755
|
await this.authService.handleAuthFailure();
|
|
1729
1756
|
this.emitErrorEvent(backendError, errorMessage, endpoint, method, status, error);
|
|
1730
1757
|
throw new AuthenticationError(errorMessage, endpoint, method, backendError);
|
|
1731
1758
|
}
|
|
1732
|
-
//
|
|
1759
|
+
// ===========================================
|
|
1760
|
+
// RETRYABLE 401 (TOKEN_EXPIRED) → Try refresh, then retry
|
|
1761
|
+
// ===========================================
|
|
1733
1762
|
if (retryCount === 0 && this.mergedConfig.authProvider) {
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
// Retry with new token
|
|
1744
|
-
return await this.request(method, endpoint, body, { ...options, retryCount: 1 });
|
|
1745
|
-
}
|
|
1763
|
+
const refreshResult = await this.refreshManager.attemptInternalRefresh();
|
|
1764
|
+
if (refreshResult.success) {
|
|
1765
|
+
// Refresh succeeded → retry request with new token
|
|
1766
|
+
this._events?.emitSuccess({
|
|
1767
|
+
type: 'token_refreshed',
|
|
1768
|
+
domain: 'authentication',
|
|
1769
|
+
userMessage: 'Authentication token refreshed',
|
|
1770
|
+
});
|
|
1771
|
+
return await this.request(method, endpoint, body, { ...options, retryCount: 1 });
|
|
1746
1772
|
}
|
|
1747
|
-
|
|
1748
|
-
|
|
1773
|
+
// Refresh failed - check if it's a definitive failure
|
|
1774
|
+
if (!refreshResult.retryable) {
|
|
1775
|
+
// Non-retryable failure (e.g., refresh token expired) → logout
|
|
1776
|
+
console.warn('[PersApiClient] Refresh failed with non-retryable error, logging out');
|
|
1777
|
+
await this.authService.handleAuthFailure();
|
|
1749
1778
|
}
|
|
1779
|
+
else {
|
|
1780
|
+
// Retryable failure (network error, etc.) → DON'T logout, let app retry later
|
|
1781
|
+
console.warn('[PersApiClient] Refresh failed with retryable error, NOT logging out');
|
|
1782
|
+
}
|
|
1783
|
+
this.emitErrorEvent(backendError, errorMessage, endpoint, method, status, error);
|
|
1784
|
+
throw new AuthenticationError(errorMessage, endpoint, method, backendError);
|
|
1750
1785
|
}
|
|
1751
|
-
//
|
|
1752
|
-
|
|
1786
|
+
// ===========================================
|
|
1787
|
+
// RETRY FAILED (retryCount > 0) → Something wrong, but DON'T logout
|
|
1788
|
+
// ===========================================
|
|
1789
|
+
// We already refreshed successfully, but retry still got 401
|
|
1790
|
+
// This is unexpected - don't logout, let app investigate
|
|
1791
|
+
console.warn('[PersApiClient] Retry with new token still got 401 - not logging out');
|
|
1753
1792
|
this.emitErrorEvent(backendError, errorMessage, endpoint, method, status, error);
|
|
1754
1793
|
throw new AuthenticationError(errorMessage, endpoint, method, backendError);
|
|
1755
1794
|
}
|
|
@@ -3262,10 +3301,11 @@ class UserStatusManager {
|
|
|
3262
3301
|
* ```
|
|
3263
3302
|
*/
|
|
3264
3303
|
class TokenManager {
|
|
3265
|
-
constructor(apiClient) {
|
|
3304
|
+
constructor(apiClient, eventEmitter) {
|
|
3266
3305
|
this.apiClient = apiClient;
|
|
3267
3306
|
const tokenApi = new TokenApi(apiClient);
|
|
3268
3307
|
this.tokenService = new TokenService(tokenApi);
|
|
3308
|
+
this.eventEmitter = eventEmitter;
|
|
3269
3309
|
}
|
|
3270
3310
|
/**
|
|
3271
3311
|
* Get all available tokens
|
|
@@ -3414,16 +3454,17 @@ class TokenManager {
|
|
|
3414
3454
|
return this.tokenService.getTokenByContractAddress(contractAddress, contractTokenId);
|
|
3415
3455
|
}
|
|
3416
3456
|
/**
|
|
3417
|
-
* Get all token metadata with filtering and
|
|
3457
|
+
* Get all token metadata with filtering, pagination, and include relations
|
|
3418
3458
|
*
|
|
3419
|
-
* Retrieves token metadata (rewards/stamps) with server-side filtering
|
|
3459
|
+
* Retrieves token metadata (rewards/stamps) with server-side filtering, pagination,
|
|
3460
|
+
* and optional include relations for additional data.
|
|
3420
3461
|
* Useful for displaying rewards (ERC1155) or stamps (ERC721) in admin tables.
|
|
3421
3462
|
* Non-admin users always get active metadata only.
|
|
3422
3463
|
*
|
|
3423
|
-
* @param options - Filter and
|
|
3464
|
+
* @param options - Filter, pagination, and include options
|
|
3424
3465
|
* @returns Promise resolving to paginated token metadata
|
|
3425
3466
|
*
|
|
3426
|
-
* @example Get paginated rewards
|
|
3467
|
+
* @example Get paginated rewards with counts
|
|
3427
3468
|
* ```typescript
|
|
3428
3469
|
* const rewards = await sdk.tokens.getTokenMetadata({
|
|
3429
3470
|
* tokenType: 'ERC1155',
|
|
@@ -3431,19 +3472,26 @@ class TokenManager {
|
|
|
3431
3472
|
* page: 1,
|
|
3432
3473
|
* limit: 10,
|
|
3433
3474
|
* sortBy: 'name',
|
|
3434
|
-
* sortOrder: 'ASC'
|
|
3475
|
+
* sortOrder: 'ASC',
|
|
3476
|
+
* include: ['mintCount', 'burnCount', 'token']
|
|
3435
3477
|
* });
|
|
3436
3478
|
*
|
|
3437
|
-
*
|
|
3438
|
-
*
|
|
3479
|
+
* rewards.data.forEach(r => {
|
|
3480
|
+
* console.log(`${r.name}: ${r.mintCount} minted, ${r.burnCount} burned`);
|
|
3481
|
+
* console.log(`Contract: ${r.included?.token?.contractAddress}`);
|
|
3482
|
+
* });
|
|
3439
3483
|
* ```
|
|
3440
3484
|
*
|
|
3441
|
-
* @example Get stamps with
|
|
3485
|
+
* @example Get stamps with owner business
|
|
3442
3486
|
* ```typescript
|
|
3443
3487
|
* const stamps = await sdk.tokens.getTokenMetadata({
|
|
3444
3488
|
* tokenType: 'ERC721',
|
|
3445
3489
|
* search: 'gold',
|
|
3446
|
-
*
|
|
3490
|
+
* include: ['ownerBusiness', 'token']
|
|
3491
|
+
* });
|
|
3492
|
+
*
|
|
3493
|
+
* stamps.data.forEach(s => {
|
|
3494
|
+
* console.log(`${s.name} owned by ${s.included?.ownerBusiness?.displayName}`);
|
|
3447
3495
|
* });
|
|
3448
3496
|
* ```
|
|
3449
3497
|
*/
|
|
@@ -3451,31 +3499,27 @@ class TokenManager {
|
|
|
3451
3499
|
return this.tokenService.getTokenMetadata(options);
|
|
3452
3500
|
}
|
|
3453
3501
|
/**
|
|
3454
|
-
* Get rewards (ERC1155 token metadata) with filtering and
|
|
3502
|
+
* Get rewards (ERC1155 token metadata) with filtering, pagination, and include relations
|
|
3455
3503
|
*
|
|
3456
3504
|
* Convenience method for fetching reward metadata. Rewards are ERC1155 tokens
|
|
3457
3505
|
* that represent collectible items, vouchers, or other redeemable rewards.
|
|
3458
3506
|
*
|
|
3459
|
-
* @param options - Filter and
|
|
3507
|
+
* @param options - Filter, pagination, and include options (tokenType is set automatically)
|
|
3460
3508
|
* @returns Promise resolving to paginated reward metadata
|
|
3461
3509
|
*
|
|
3462
|
-
* @example Get active rewards
|
|
3510
|
+
* @example Get active rewards with mint counts
|
|
3463
3511
|
* ```typescript
|
|
3464
3512
|
* const rewards = await sdk.tokens.getRewards({
|
|
3465
3513
|
* active: true,
|
|
3466
|
-
* limit: 10
|
|
3514
|
+
* limit: 10,
|
|
3515
|
+
* include: ['mintCount', 'burnCount', 'token', 'ownerBusiness']
|
|
3467
3516
|
* });
|
|
3468
3517
|
*
|
|
3469
|
-
*
|
|
3470
|
-
*
|
|
3471
|
-
*
|
|
3472
|
-
*
|
|
3473
|
-
*
|
|
3474
|
-
* ```typescript
|
|
3475
|
-
* const discountRewards = await sdk.tokens.getRewards({
|
|
3476
|
-
* search: 'discount',
|
|
3477
|
-
* sortBy: 'name',
|
|
3478
|
-
* sortOrder: 'ASC'
|
|
3518
|
+
* rewards.data.forEach(r => {
|
|
3519
|
+
* console.log(`${r.name}: ${r.mintCount ?? 0} minted`);
|
|
3520
|
+
* if (r.included?.token) {
|
|
3521
|
+
* console.log(` Chain: ${r.included.token.chainId}, Contract: ${r.included.token.contractAddress}`);
|
|
3522
|
+
* }
|
|
3479
3523
|
* });
|
|
3480
3524
|
* ```
|
|
3481
3525
|
*/
|
|
@@ -3483,31 +3527,27 @@ class TokenManager {
|
|
|
3483
3527
|
return this.tokenService.getRewards(options);
|
|
3484
3528
|
}
|
|
3485
3529
|
/**
|
|
3486
|
-
* Get stamps (ERC721 token metadata) with filtering and
|
|
3530
|
+
* Get stamps (ERC721 token metadata) with filtering, pagination, and include relations
|
|
3487
3531
|
*
|
|
3488
3532
|
* Convenience method for fetching stamp metadata. Stamps are ERC721 tokens
|
|
3489
3533
|
* that represent achievements, badges, or collectible status markers.
|
|
3490
3534
|
*
|
|
3491
|
-
* @param options - Filter and
|
|
3535
|
+
* @param options - Filter, pagination, and include options (tokenType is set automatically)
|
|
3492
3536
|
* @returns Promise resolving to paginated stamp metadata
|
|
3493
3537
|
*
|
|
3494
|
-
* @example Get active stamps
|
|
3538
|
+
* @example Get active stamps with all includes
|
|
3495
3539
|
* ```typescript
|
|
3496
3540
|
* const stamps = await sdk.tokens.getStamps({
|
|
3497
3541
|
* active: true,
|
|
3498
|
-
* limit: 10
|
|
3542
|
+
* limit: 10,
|
|
3543
|
+
* include: ['mintCount', 'burnCount', 'token', 'ownerBusiness']
|
|
3499
3544
|
* });
|
|
3500
3545
|
*
|
|
3501
|
-
*
|
|
3502
|
-
*
|
|
3503
|
-
*
|
|
3504
|
-
*
|
|
3505
|
-
*
|
|
3506
|
-
* ```typescript
|
|
3507
|
-
* const goldStamps = await sdk.tokens.getStamps({
|
|
3508
|
-
* tags: ['gold', 'premium'],
|
|
3509
|
-
* sortBy: 'createdAt',
|
|
3510
|
-
* sortOrder: 'DESC'
|
|
3546
|
+
* stamps.data.forEach(s => {
|
|
3547
|
+
* console.log(`${s.name}: ${s.mintCount ?? 0} minted`);
|
|
3548
|
+
* if (s.included?.ownerBusiness) {
|
|
3549
|
+
* console.log(` Owner: ${s.included.ownerBusiness.displayName}`);
|
|
3550
|
+
* }
|
|
3511
3551
|
* });
|
|
3512
3552
|
* ```
|
|
3513
3553
|
*/
|
|
@@ -3605,6 +3645,32 @@ class TokenManager {
|
|
|
3605
3645
|
async toggleTokenActive(tokenId) {
|
|
3606
3646
|
return this.tokenService.toggleTokenActive(tokenId);
|
|
3607
3647
|
}
|
|
3648
|
+
/**
|
|
3649
|
+
* Admin: Delete token metadata (soft delete)
|
|
3650
|
+
*
|
|
3651
|
+
* Soft deletes token metadata by setting deletedAt timestamp.
|
|
3652
|
+
* Requires administrator privileges. Will fail with 409 Conflict
|
|
3653
|
+
* if metadata is currently in use by active campaigns or redemptions.
|
|
3654
|
+
*
|
|
3655
|
+
* @param metadataId - ID of the token metadata to delete
|
|
3656
|
+
* @throws {PersApiError} When not authenticated as admin
|
|
3657
|
+
* @throws {PersApiError} 409 Conflict if metadata is in use
|
|
3658
|
+
*
|
|
3659
|
+
* @example
|
|
3660
|
+
* ```typescript
|
|
3661
|
+
* try {
|
|
3662
|
+
* await sdk.tokens.deleteTokenMetadata('metadata-123');
|
|
3663
|
+
* console.log('Token metadata deleted');
|
|
3664
|
+
* } catch (error) {
|
|
3665
|
+
* if (error.statusCode === 409) {
|
|
3666
|
+
* console.log('Cannot delete: metadata is used by campaigns/redemptions');
|
|
3667
|
+
* }
|
|
3668
|
+
* }
|
|
3669
|
+
* ```
|
|
3670
|
+
*/
|
|
3671
|
+
async deleteTokenMetadata(metadataId) {
|
|
3672
|
+
return this.tokenService.deleteTokenMetadata(metadataId);
|
|
3673
|
+
}
|
|
3608
3674
|
/**
|
|
3609
3675
|
* Get the full token SDK for advanced operations
|
|
3610
3676
|
*
|
|
@@ -5998,6 +6064,21 @@ class RedemptionManager {
|
|
|
5998
6064
|
async deleteRedemptionType(id) {
|
|
5999
6065
|
return this.redemptionService.deleteRedemptionType(id);
|
|
6000
6066
|
}
|
|
6067
|
+
/**
|
|
6068
|
+
* Delete a redemption (soft delete)
|
|
6069
|
+
*
|
|
6070
|
+
* @param id - Redemption ID to delete
|
|
6071
|
+
* @returns Promise resolving to true if deleted successfully
|
|
6072
|
+
*
|
|
6073
|
+
* @example
|
|
6074
|
+
* ```typescript
|
|
6075
|
+
* const success = await sdk.redemptions.deleteRedemption('redemption-123');
|
|
6076
|
+
* console.log('Deleted:', success);
|
|
6077
|
+
* ```
|
|
6078
|
+
*/
|
|
6079
|
+
async deleteRedemption(id) {
|
|
6080
|
+
return this.redemptionService.deleteRedemption(id);
|
|
6081
|
+
}
|
|
6001
6082
|
/**
|
|
6002
6083
|
* Get the full redemption service for advanced operations
|
|
6003
6084
|
*
|
|
@@ -10468,7 +10549,7 @@ class PersSDK {
|
|
|
10468
10549
|
*/
|
|
10469
10550
|
get tokens() {
|
|
10470
10551
|
if (!this._tokens) {
|
|
10471
|
-
this._tokens = new TokenManager(this.apiClient);
|
|
10552
|
+
this._tokens = new TokenManager(this.apiClient, this._events);
|
|
10472
10553
|
}
|
|
10473
10554
|
return this._tokens;
|
|
10474
10555
|
}
|
|
@@ -10820,4 +10901,4 @@ function createPersSDK(httpClient, config) {
|
|
|
10820
10901
|
}
|
|
10821
10902
|
|
|
10822
10903
|
export { AuthStatus as A, BusinessManager as B, CampaignManager as C, DefaultAuthProvider as D, WebhookManager as E, FATAL_AUTH_CODES as F, WalletEventsManager as G, FileApi as H, IndexedDBTokenStorage as I, FileService as J, ApiKeyApi as K, LocalStorageTokenStorage as L, MemoryTokenStorage as M, WebhookApi as N, WebhookService as O, PersSDK as P, PersEventsClient as Q, RedemptionManager as R, SDK_NAME as S, TokenManager as T, UserManager as U, createPersEventsClient as V, WebDPoPCryptoProvider as W, AuthTokenManager as a, AUTH_STORAGE_KEYS as b, createPersSDK as c, DPOP_STORAGE_KEYS as d, SDK_VERSION as e, SDK_USER_AGENT as f, PersApiClient as g, DEFAULT_PERS_CONFIG as h, buildApiRoot as i, buildWalletEventsWsUrl as j, StaticJwtAuthProvider as k, AuthApi as l, mergeWithDefaults as m, isFatalAuthErrorInMessage as n, AuthService as o, DPoPManager as p, PersEventEmitter as q, AuthManager as r, UserStatusManager as s, TransactionManager as t, PurchaseManager as u, FileManager as v, ApiKeyManager as w, AnalyticsManager as x, DonationManager as y, TriggerSourceManager as z };
|
|
10823
|
-
//# sourceMappingURL=pers-sdk-
|
|
10904
|
+
//# sourceMappingURL=pers-sdk-DuDWwRWC.js.map
|