@explorins/pers-sdk-react-native 1.5.20 → 1.5.22
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/hooks/useAnalytics.d.ts +6 -2
- package/dist/hooks/useAnalytics.d.ts.map +1 -1
- package/dist/hooks/useTransactionSigner.d.ts +2 -2
- package/dist/hooks/useTransactionSigner.d.ts.map +1 -1
- package/dist/hooks/useWeb3.d.ts +8 -2
- package/dist/hooks/useWeb3.d.ts.map +1 -1
- package/dist/index.js +73 -26
- package/dist/index.js.map +1 -1
- package/dist/providers/react-native-auth-provider.d.ts +0 -1
- package/dist/providers/react-native-auth-provider.d.ts.map +1 -1
- package/dist/providers/react-native-auth-provider.js +0 -1
- package/dist/providers/react-native-http-client.d.ts +15 -0
- package/dist/providers/react-native-http-client.d.ts.map +1 -1
- package/dist/providers/react-native-http-client.js +7 -7
- package/package.json +2 -2
- package/src/hooks/useAnalytics.ts +6 -2
- package/src/hooks/useTransactionSigner.ts +2 -2
- package/src/hooks/useWeb3.ts +8 -1
- package/src/providers/react-native-auth-provider.ts +0 -1
- package/src/providers/react-native-http-client.ts +24 -7
|
@@ -15,8 +15,10 @@ interface TransactionAnalyticsGroupByExpression {
|
|
|
15
15
|
}
|
|
16
16
|
/**
|
|
17
17
|
* Request DTO for transaction analytics
|
|
18
|
+
*
|
|
19
|
+
* @interface TransactionAnalyticsRequestDTO
|
|
18
20
|
*/
|
|
19
|
-
interface TransactionAnalyticsRequestDTO {
|
|
21
|
+
export interface TransactionAnalyticsRequestDTO {
|
|
20
22
|
filters?: TransactionAnalyticsFilters;
|
|
21
23
|
groupBy?: TransactionAnalyticsGroupBy[];
|
|
22
24
|
groupByExpressions?: TransactionAnalyticsGroupByExpression[];
|
|
@@ -50,8 +52,10 @@ interface TransactionAnalyticsResultItem {
|
|
|
50
52
|
}
|
|
51
53
|
/**
|
|
52
54
|
* Response DTO for transaction analytics
|
|
55
|
+
*
|
|
56
|
+
* @interface TransactionAnalyticsResponseDTO
|
|
53
57
|
*/
|
|
54
|
-
interface TransactionAnalyticsResponseDTO {
|
|
58
|
+
export interface TransactionAnalyticsResponseDTO {
|
|
55
59
|
results: TransactionAnalyticsResultItem[];
|
|
56
60
|
totalGroups: number;
|
|
57
61
|
metadata: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAnalytics.d.ts","sourceRoot":"","sources":["../../src/hooks/useAnalytics.ts"],"names":[],"mappings":"AAIA,UAAU,2BAA2B;IACnC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED,KAAK,2BAA2B,GAC5B,OAAO,GAAG,MAAM,GAAG,KAAK,GAAG,MAAM,GAAG,SAAS,GAC7C,WAAW,GAAG,QAAQ,GAAG,SAAS,GAAG,oBAAoB,GAAG,MAAM,GAClE,eAAe,GAAG,kBAAkB,GAAG,UAAU,GAAG,aAAa,GAAG,iBAAiB,GAAG,oBAAoB,GAAG,WAAW,CAAC;AAE/H,KAAK,0BAA0B,GAC3B,OAAO,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,CAAC;AAE5C,UAAU,qCAAqC;IAC7C,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;CACf;AAED
|
|
1
|
+
{"version":3,"file":"useAnalytics.d.ts","sourceRoot":"","sources":["../../src/hooks/useAnalytics.ts"],"names":[],"mappings":"AAIA,UAAU,2BAA2B;IACnC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED,KAAK,2BAA2B,GAC5B,OAAO,GAAG,MAAM,GAAG,KAAK,GAAG,MAAM,GAAG,SAAS,GAC7C,WAAW,GAAG,QAAQ,GAAG,SAAS,GAAG,oBAAoB,GAAG,MAAM,GAClE,eAAe,GAAG,kBAAkB,GAAG,UAAU,GAAG,aAAa,GAAG,iBAAiB,GAAG,oBAAoB,GAAG,WAAW,CAAC;AAE/H,KAAK,0BAA0B,GAC3B,OAAO,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,CAAC;AAE5C,UAAU,qCAAqC;IAC7C,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;;GAIG;AACH,MAAM,WAAW,8BAA8B;IAC7C,OAAO,CAAC,EAAE,2BAA2B,CAAC;IACtC,OAAO,CAAC,EAAE,2BAA2B,EAAE,CAAC;IACxC,kBAAkB,CAAC,EAAE,qCAAqC,EAAE,CAAC;IAC7D,OAAO,CAAC,EAAE,0BAA0B,EAAE,CAAC;IACvC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,cAAc,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC;IAChC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,UAAU,8BAA8B;IACtC,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IAClD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;;GAIG;AACH,MAAM,WAAW,+BAA+B;IAC9C,OAAO,EAAE,8BAA8B,EAAE,CAAC;IAC1C,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE;QACR,aAAa,EAAE,MAAM,CAAC;KACvB,CAAC;CACH;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,eAAO,MAAM,YAAY;uCAwBqC,8BAA8B,KAAG,QAAQ,+BAA+B,CAAC;;CAmBtI,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG,UAAU,CAAC,OAAO,YAAY,CAAC,CAAC"}
|
|
@@ -12,7 +12,7 @@ type TransactionSigningResult = import('@explorins/pers-signer/react-native').Tr
|
|
|
12
12
|
* @property {boolean} isSignerInitialized - Whether the signer SDK has been initialized
|
|
13
13
|
* @property {boolean} isSignerAvailable - Whether signing functionality is fully available
|
|
14
14
|
*/
|
|
15
|
-
interface TransactionSignerHook {
|
|
15
|
+
export interface TransactionSignerHook {
|
|
16
16
|
signAndSubmitTransactionWithJWT: (jwt: string) => Promise<SubmissionResult>;
|
|
17
17
|
isSignerInitialized: boolean;
|
|
18
18
|
isSignerAvailable: boolean;
|
|
@@ -206,5 +206,5 @@ export declare const useTransactionSigner: () => TransactionSignerHook;
|
|
|
206
206
|
* @see {@link TransactionSigningResult} - Transaction signing result details
|
|
207
207
|
* @see {@link TransactionSignerHook} - Hook return interface
|
|
208
208
|
*/
|
|
209
|
-
export type { SubmissionResult, AuthenticatedUser, TransactionSigningResult
|
|
209
|
+
export type { SubmissionResult, AuthenticatedUser, TransactionSigningResult };
|
|
210
210
|
//# sourceMappingURL=useTransactionSigner.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTransactionSigner.d.ts","sourceRoot":"","sources":["../../src/hooks/useTransactionSigner.ts"],"names":[],"mappings":"AAMA,KAAK,gBAAgB,GAAG,OAAO,qCAAqC,EAAE,gBAAgB,CAAC;AACvF,KAAK,iBAAiB,GAAG,OAAO,qCAAqC,EAAE,iBAAiB,CAAC;AACzF,KAAK,wBAAwB,GAAG,OAAO,qCAAqC,EAAE,wBAAwB,CAAC;AAcvG;;;;;;;;;;GAUG;AACH,
|
|
1
|
+
{"version":3,"file":"useTransactionSigner.d.ts","sourceRoot":"","sources":["../../src/hooks/useTransactionSigner.ts"],"names":[],"mappings":"AAMA,KAAK,gBAAgB,GAAG,OAAO,qCAAqC,EAAE,gBAAgB,CAAC;AACvF,KAAK,iBAAiB,GAAG,OAAO,qCAAqC,EAAE,iBAAiB,CAAC;AACzF,KAAK,wBAAwB,GAAG,OAAO,qCAAqC,EAAE,wBAAwB,CAAC;AAcvG;;;;;;;;;;GAUG;AACH,MAAM,WAAW,qBAAqB;IACpC,+BAA+B,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,gBAAgB,CAAC,CAAC;IAC5E,mBAAmB,EAAE,OAAO,CAAC;IAC7B,iBAAiB,EAAE,OAAO,CAAC;CAC5B;AAKD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgLG;AACH,eAAO,MAAM,oBAAoB,QAAO,qBA4LvC,CAAC;AAEF;;;;;;;;;;GAUG;AACH,YAAY,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,CAAC"}
|
package/dist/hooks/useWeb3.d.ts
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import type { TokenBalance, TokenBalanceRequest, TokenCollectionRequest, TokenCollection, TokenMetadata } from '@explorins/pers-sdk/web3';
|
|
2
2
|
import type { ChainData } from '@explorins/pers-sdk/web3-chain';
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Wallet information interface
|
|
5
|
+
*
|
|
6
|
+
* @interface WalletInfo
|
|
7
|
+
* @property {string | null} address - Wallet address if connected
|
|
8
|
+
* @property {boolean} isConnected - Whether wallet is connected
|
|
9
|
+
*/
|
|
10
|
+
export interface WalletInfo {
|
|
4
11
|
address: string | null;
|
|
5
12
|
isConnected: boolean;
|
|
6
13
|
}
|
|
@@ -70,5 +77,4 @@ export declare const useWeb3: () => {
|
|
|
70
77
|
isAvailable: boolean;
|
|
71
78
|
};
|
|
72
79
|
export type Web3Hook = ReturnType<typeof useWeb3>;
|
|
73
|
-
export {};
|
|
74
80
|
//# sourceMappingURL=useWeb3.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useWeb3.d.ts","sourceRoot":"","sources":["../../src/hooks/useWeb3.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,YAAY,EACZ,mBAAmB,EACnB,sBAAsB,EACtB,eAAe,EACf,aAAa,EACd,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAEhE,
|
|
1
|
+
{"version":3,"file":"useWeb3.d.ts","sourceRoot":"","sources":["../../src/hooks/useWeb3.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,YAAY,EACZ,mBAAmB,EACnB,sBAAsB,EACtB,eAAe,EACf,aAAa,EACd,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAEhE;;;;;;GAMG;AACH,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,WAAW,EAAE,OAAO,CAAC;CACtB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoDG;AACH,eAAO,MAAM,OAAO;+BA0BkC,mBAAmB,KAAG,QAAQ,YAAY,CAAC;gCAmC1C,mBAAmB,KAAG,QAAQ,aAAa,GAAG,IAAI,CAAC;kCAejD,sBAAsB,KAAG,QAAQ,eAAe,CAAC;0BAezD,MAAM,WAAW,MAAM,KAAG,QAAQ,MAAM,CAAC;wCAe3B,MAAM,WAAW,MAAM,KAAG,QAAQ,aAAa,GAAG,IAAI,CAAC;gCAe/D,MAAM,KAAG,QAAQ,SAAS,GAAG,IAAI,CAAC;8BAepC,MAAM,WAAW,MAAM,QAAQ,SAAS,GAAG,IAAI,KAAG,QAAQ,MAAM,CAAC;yBAexE,QAAQ,UAAU,GAAG,IAAI,CAAC;;;CA2BvE,CAAC;AAEF,MAAM,MAAM,QAAQ,GAAG,UAAU,CAAC,OAAO,OAAO,CAAC,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -22632,17 +22632,21 @@ class ErrorUtils {
|
|
|
22632
22632
|
if (typeof error !== 'object' || error === null)
|
|
22633
22633
|
return false;
|
|
22634
22634
|
const err = error;
|
|
22635
|
-
|
|
22636
|
-
|
|
22637
|
-
|
|
22635
|
+
// Check for explicit token expired indicators
|
|
22636
|
+
if (err?.code === 'TOKEN_EXPIRED' || err?.errorCode === 'TOKEN_EXPIRED') {
|
|
22637
|
+
return true;
|
|
22638
|
+
}
|
|
22639
|
+
// Check in response data
|
|
22640
|
+
const apiError = err?.response?.data || err;
|
|
22638
22641
|
if (apiError?.code === 'TOKEN_EXPIRED' || apiError?.errorCode === 'TOKEN_EXPIRED') {
|
|
22639
22642
|
return true;
|
|
22640
22643
|
}
|
|
22641
|
-
// Any 401
|
|
22644
|
+
// Any 401 error is treated as token expiration
|
|
22645
|
+
const status = err?.status || err?.statusCode || err?.response?.status;
|
|
22642
22646
|
if (status === 401) {
|
|
22643
22647
|
return true;
|
|
22644
22648
|
}
|
|
22645
|
-
// Check for token-related messages
|
|
22649
|
+
// Check for token-related messages
|
|
22646
22650
|
const message = apiError?.message || err?.message || '';
|
|
22647
22651
|
if (message && typeof message === 'string') {
|
|
22648
22652
|
const lowerMessage = message.toLowerCase();
|
|
@@ -22659,8 +22663,9 @@ class ErrorUtils {
|
|
|
22659
22663
|
if (typeof error !== 'object' || error === null)
|
|
22660
22664
|
return 'Unknown error';
|
|
22661
22665
|
const err = error;
|
|
22662
|
-
|
|
22663
|
-
|
|
22666
|
+
// Try structured error first
|
|
22667
|
+
const apiError = err?.response?.data || err;
|
|
22668
|
+
return apiError?.message || apiError?.detail || apiError?.userMessage || err?.message || 'Request failed';
|
|
22664
22669
|
}
|
|
22665
22670
|
/**
|
|
22666
22671
|
* Fast status code extraction
|
|
@@ -22669,6 +22674,7 @@ class ErrorUtils {
|
|
|
22669
22674
|
if (typeof error !== 'object' || error === null)
|
|
22670
22675
|
return null;
|
|
22671
22676
|
const err = error;
|
|
22677
|
+
// Direct properties first
|
|
22672
22678
|
return err?.status || err?.statusCode || err?.response?.status || null;
|
|
22673
22679
|
}
|
|
22674
22680
|
/**
|
|
@@ -22678,11 +22684,14 @@ class ErrorUtils {
|
|
|
22678
22684
|
if (typeof error !== 'object' || error === null)
|
|
22679
22685
|
return false;
|
|
22680
22686
|
const err = error;
|
|
22681
|
-
// Check explicit retryable property
|
|
22687
|
+
// Check explicit retryable property
|
|
22688
|
+
const apiError = err?.response?.data || err;
|
|
22689
|
+
if (typeof apiError?.retryable === 'boolean')
|
|
22690
|
+
return apiError.retryable;
|
|
22682
22691
|
if (typeof err?.retryable === 'boolean')
|
|
22683
22692
|
return err.retryable;
|
|
22684
|
-
//
|
|
22685
|
-
const status =
|
|
22693
|
+
// Status-based check
|
|
22694
|
+
const status = this.getStatus(error);
|
|
22686
22695
|
return status === null || status >= 500 || status === 429;
|
|
22687
22696
|
}
|
|
22688
22697
|
/**
|
|
@@ -22694,6 +22703,11 @@ class ErrorUtils {
|
|
|
22694
22703
|
// Try to extract structured error response from HTTP error
|
|
22695
22704
|
if (error && typeof error === 'object') {
|
|
22696
22705
|
const httpError = error;
|
|
22706
|
+
// Use centralized parsing for React Native HTTP client format
|
|
22707
|
+
const parsedError = this.parseHttpClientError(error);
|
|
22708
|
+
if (parsedError && typeof parsedError === 'object') {
|
|
22709
|
+
return parsedError;
|
|
22710
|
+
}
|
|
22697
22711
|
// Check if error has response data (common in HTTP clients)
|
|
22698
22712
|
if (httpError.response?.data) {
|
|
22699
22713
|
return httpError.response.data;
|
|
@@ -22729,6 +22743,38 @@ class ErrorUtils {
|
|
|
22729
22743
|
};
|
|
22730
22744
|
}
|
|
22731
22745
|
}
|
|
22746
|
+
/**
|
|
22747
|
+
* Parse React Native HTTP client error format
|
|
22748
|
+
* Handles format: "HTTP 401: Unauthorized - {json}"
|
|
22749
|
+
*/
|
|
22750
|
+
static parseHttpClientError(error) {
|
|
22751
|
+
try {
|
|
22752
|
+
if (typeof error === 'object' && error !== null) {
|
|
22753
|
+
const err = error;
|
|
22754
|
+
const message = err?.message || '';
|
|
22755
|
+
if (typeof message === 'string' && message.includes('HTTP') && message.includes(' - ')) {
|
|
22756
|
+
// Extract JSON part after " - "
|
|
22757
|
+
const jsonStart = message.lastIndexOf(' - ');
|
|
22758
|
+
if (jsonStart !== -1) {
|
|
22759
|
+
const jsonStr = message.substring(jsonStart + 3);
|
|
22760
|
+
if (jsonStr.trim()) {
|
|
22761
|
+
try {
|
|
22762
|
+
return JSON.parse(jsonStr);
|
|
22763
|
+
}
|
|
22764
|
+
catch {
|
|
22765
|
+
// If JSON parsing fails, return the raw string as message
|
|
22766
|
+
return { message: jsonStr };
|
|
22767
|
+
}
|
|
22768
|
+
}
|
|
22769
|
+
}
|
|
22770
|
+
}
|
|
22771
|
+
}
|
|
22772
|
+
return null;
|
|
22773
|
+
}
|
|
22774
|
+
catch {
|
|
22775
|
+
return null;
|
|
22776
|
+
}
|
|
22777
|
+
}
|
|
22732
22778
|
/**
|
|
22733
22779
|
* Check if error is from PERS API (uses @explorins/pers-shared format)
|
|
22734
22780
|
*/
|
|
@@ -26091,13 +26137,11 @@ class TokenRefreshManager {
|
|
|
26091
26137
|
if (isTokenExpired(token, this.tokenRefreshMarginSeconds)) {
|
|
26092
26138
|
const refreshSuccess = await this.attemptInternalRefresh();
|
|
26093
26139
|
if (!refreshSuccess) {
|
|
26094
|
-
// Failed to refresh - delegate cleanup to AuthService
|
|
26095
26140
|
await this.authService.handleAuthFailure();
|
|
26096
26141
|
}
|
|
26097
26142
|
}
|
|
26098
26143
|
}
|
|
26099
26144
|
catch (error) {
|
|
26100
|
-
// Delegate token cleanup to AuthService for consistency
|
|
26101
26145
|
await this.authService.handleAuthFailure();
|
|
26102
26146
|
}
|
|
26103
26147
|
}
|
|
@@ -26107,7 +26151,6 @@ class TokenRefreshManager {
|
|
|
26107
26151
|
return true;
|
|
26108
26152
|
}
|
|
26109
26153
|
catch (error) {
|
|
26110
|
-
// Check if this is a 401 error and set auth failure flag
|
|
26111
26154
|
const isAuthError = error && typeof error === 'object' && 'status' in error && error.status === 401;
|
|
26112
26155
|
if (isAuthError) {
|
|
26113
26156
|
await this.authService.handleAuthFailure();
|
|
@@ -26342,6 +26385,7 @@ class PersApiClient {
|
|
|
26342
26385
|
await this.ensureValidToken();
|
|
26343
26386
|
}
|
|
26344
26387
|
catch (error) {
|
|
26388
|
+
this.initializationPromise = null;
|
|
26345
26389
|
console.debug('[PersApiClient] Startup token validation failed:', error);
|
|
26346
26390
|
}
|
|
26347
26391
|
}
|
|
@@ -26359,14 +26403,15 @@ class PersApiClient {
|
|
|
26359
26403
|
* @returns Promise that resolves when token validation is complete
|
|
26360
26404
|
*/
|
|
26361
26405
|
async ensureValidToken() {
|
|
26362
|
-
if (!this.mergedConfig.authProvider)
|
|
26406
|
+
if (!this.mergedConfig.authProvider) {
|
|
26363
26407
|
return;
|
|
26408
|
+
}
|
|
26364
26409
|
return this.refreshManager.ensureValidToken();
|
|
26365
26410
|
}
|
|
26366
26411
|
async ensureInitialized() {
|
|
26367
26412
|
if (this.initializationPromise) {
|
|
26368
26413
|
await this.initializationPromise;
|
|
26369
|
-
this.initializationPromise = null;
|
|
26414
|
+
this.initializationPromise = null;
|
|
26370
26415
|
}
|
|
26371
26416
|
}
|
|
26372
26417
|
/* private async attemptInternalRefresh(): Promise<boolean> {
|
|
@@ -26376,11 +26421,14 @@ class PersApiClient {
|
|
|
26376
26421
|
* Make a request with proper headers, auth, and error handling
|
|
26377
26422
|
*/
|
|
26378
26423
|
async request(method, endpoint, body, options) {
|
|
26379
|
-
|
|
26424
|
+
if (!options?.isRefreshRequest) {
|
|
26425
|
+
await this.ensureInitialized();
|
|
26426
|
+
}
|
|
26380
26427
|
const { retryCount = 0, responseType = 'json', bypassAuth = false } = options || {};
|
|
26381
26428
|
const url = `${this.apiRoot}${endpoint}`;
|
|
26382
|
-
//
|
|
26429
|
+
// SMART TOKEN VALIDATION: Only check if we suspect the token might be expired
|
|
26383
26430
|
if (!bypassAuth && this.mergedConfig.authProvider && retryCount === 0) {
|
|
26431
|
+
// Fire-and-forget validation - don't block the request unless we know there's an issue
|
|
26384
26432
|
this.ensureValidToken().catch(error => {
|
|
26385
26433
|
console.debug('[PersApiClient] Background token validation failed:', error);
|
|
26386
26434
|
});
|
|
@@ -26432,7 +26480,7 @@ class PersApiClient {
|
|
|
26432
26480
|
}
|
|
26433
26481
|
}
|
|
26434
26482
|
catch (refreshError) {
|
|
26435
|
-
//
|
|
26483
|
+
// console.error('[PersApiClient] Token refresh failed:', refreshError);
|
|
26436
26484
|
}
|
|
26437
26485
|
}
|
|
26438
26486
|
// Auth failure - let AuthService handle cleanup and notify app
|
|
@@ -31759,7 +31807,6 @@ const isWebPlatform = reactNative.Platform.OS === 'web';
|
|
|
31759
31807
|
* - Mobile: Uses AsyncStorageTokenStorage (React Native specific)
|
|
31760
31808
|
*
|
|
31761
31809
|
* @param projectKey - PERS project key
|
|
31762
|
-
* @param authApi - Optional auth API instance
|
|
31763
31810
|
* @param config - Configuration options
|
|
31764
31811
|
* @returns DefaultAuthProvider configured for the current platform
|
|
31765
31812
|
*/
|
|
@@ -31824,18 +31871,18 @@ class ReactNativeHttpClient {
|
|
|
31824
31871
|
try {
|
|
31825
31872
|
const response = await fetch(fullUrl, config);
|
|
31826
31873
|
if (!response.ok) {
|
|
31827
|
-
//
|
|
31828
|
-
let
|
|
31874
|
+
// Get raw error response for ErrorUtils to handle
|
|
31875
|
+
let errorText = '';
|
|
31829
31876
|
try {
|
|
31830
|
-
|
|
31831
|
-
if (errorBody) {
|
|
31832
|
-
errorMessage += ` - ${errorBody}`;
|
|
31833
|
-
}
|
|
31877
|
+
errorText = await response.text();
|
|
31834
31878
|
}
|
|
31835
31879
|
catch (e) {
|
|
31836
31880
|
// Ignore errors when reading error body
|
|
31837
31881
|
}
|
|
31838
|
-
|
|
31882
|
+
// Create simple error with HTTP status and raw response
|
|
31883
|
+
const httpError = new Error(`HTTP ${response.status}: ${response.statusText} - ${errorText}`);
|
|
31884
|
+
httpError.status = response.status;
|
|
31885
|
+
throw httpError;
|
|
31839
31886
|
}
|
|
31840
31887
|
// Handle different response types
|
|
31841
31888
|
switch (options?.responseType) {
|