@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
|
@@ -28,7 +28,6 @@ export interface ReactNativeAuthConfig {
|
|
|
28
28
|
* - Mobile: Uses AsyncStorageTokenStorage (React Native specific)
|
|
29
29
|
*
|
|
30
30
|
* @param projectKey - PERS project key
|
|
31
|
-
* @param authApi - Optional auth API instance
|
|
32
31
|
* @param config - Configuration options
|
|
33
32
|
* @returns DefaultAuthProvider configured for the current platform
|
|
34
33
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react-native-auth-provider.d.ts","sourceRoot":"","sources":["../../src/providers/react-native-auth-provider.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAE,mBAAmB,EAAW,QAAQ,EAA4B,MAAM,0BAA0B,CAAC;AAE5G,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAK7D;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,gCAAgC;IAChC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,2BAA2B;IAC3B,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,0CAA0C;IAC1C,aAAa,CAAC,EAAE,YAAY,CAAC;IAC7B,4CAA4C;IAC5C,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB;AAED
|
|
1
|
+
{"version":3,"file":"react-native-auth-provider.d.ts","sourceRoot":"","sources":["../../src/providers/react-native-auth-provider.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAE,mBAAmB,EAAW,QAAQ,EAA4B,MAAM,0BAA0B,CAAC;AAE5G,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAK7D;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,gCAAgC;IAChC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,2BAA2B;IAC3B,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,0CAA0C;IAC1C,aAAa,CAAC,EAAE,YAAY,CAAC;IAC7B,4CAA4C;IAC5C,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,6BAA6B,CAC3C,UAAU,EAAE,MAAM,EAClB,MAAM,GAAE,qBAA0B,GACjC,mBAAmB,CAyBrB"}
|
|
@@ -18,7 +18,6 @@ const isWebPlatform = Platform.OS === 'web';
|
|
|
18
18
|
* - Mobile: Uses AsyncStorageTokenStorage (React Native specific)
|
|
19
19
|
*
|
|
20
20
|
* @param projectKey - PERS project key
|
|
21
|
-
* @param authApi - Optional auth API instance
|
|
22
21
|
* @param config - Configuration options
|
|
23
22
|
* @returns DefaultAuthProvider configured for the current platform
|
|
24
23
|
*/
|
|
@@ -4,12 +4,27 @@
|
|
|
4
4
|
* This implementation properly implements the core SDK's HttpClient interface
|
|
5
5
|
* and uses fetch API which is available in React Native.
|
|
6
6
|
*/
|
|
7
|
+
/**
|
|
8
|
+
* Request options for HTTP client operations
|
|
9
|
+
*
|
|
10
|
+
* @interface RequestOptions
|
|
11
|
+
* @property {Record<string, string>} [headers] - HTTP headers to include
|
|
12
|
+
* @property {Record<string, string>} [params] - URL parameters
|
|
13
|
+
* @property {number} [timeout] - Request timeout in milliseconds
|
|
14
|
+
* @property {'json' | 'blob' | 'text' | 'arraybuffer'} [responseType] - Expected response type
|
|
15
|
+
*/
|
|
7
16
|
export interface RequestOptions {
|
|
8
17
|
headers?: Record<string, string>;
|
|
9
18
|
params?: Record<string, string>;
|
|
10
19
|
timeout?: number;
|
|
11
20
|
responseType?: 'json' | 'blob' | 'text' | 'arraybuffer';
|
|
12
21
|
}
|
|
22
|
+
/**
|
|
23
|
+
* HTTP Client interface for React Native
|
|
24
|
+
*
|
|
25
|
+
* @interface HttpClient
|
|
26
|
+
* @template T - Response type
|
|
27
|
+
*/
|
|
13
28
|
export interface HttpClient {
|
|
14
29
|
get<T>(url: string, options?: RequestOptions): Promise<T>;
|
|
15
30
|
post<T>(url: string, body: any, options?: RequestOptions): Promise<T>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react-native-http-client.d.ts","sourceRoot":"","sources":["../../src/providers/react-native-http-client.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,WAAW,cAAc;IAC7B,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,aAAa,CAAC;CACzD;AAED,MAAM,WAAW,UAAU;IACzB,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,CAAC,CAAC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AAC,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,CAAC,CAAC;IAI3E,MAAM,CAAC,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,CAAC,CAAC;YAI1D,OAAO;IAwErB,OAAO,CAAC,QAAQ;CAcjB"}
|
|
@@ -42,18 +42,18 @@ export class ReactNativeHttpClient {
|
|
|
42
42
|
try {
|
|
43
43
|
const response = await fetch(fullUrl, config);
|
|
44
44
|
if (!response.ok) {
|
|
45
|
-
//
|
|
46
|
-
let
|
|
45
|
+
// Get raw error response for ErrorUtils to handle
|
|
46
|
+
let errorText = '';
|
|
47
47
|
try {
|
|
48
|
-
|
|
49
|
-
if (errorBody) {
|
|
50
|
-
errorMessage += ` - ${errorBody}`;
|
|
51
|
-
}
|
|
48
|
+
errorText = await response.text();
|
|
52
49
|
}
|
|
53
50
|
catch (e) {
|
|
54
51
|
// Ignore errors when reading error body
|
|
55
52
|
}
|
|
56
|
-
|
|
53
|
+
// Create simple error with HTTP status and raw response
|
|
54
|
+
const httpError = new Error(`HTTP ${response.status}: ${response.statusText} - ${errorText}`);
|
|
55
|
+
httpError.status = response.status;
|
|
56
|
+
throw httpError;
|
|
57
57
|
}
|
|
58
58
|
// Handle different response types
|
|
59
59
|
switch (options?.responseType) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@explorins/pers-sdk-react-native",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.22",
|
|
4
4
|
"description": "React Native SDK for PERS Platform - Tourism Loyalty System with Blockchain Transaction Signing and WebAuthn Authentication",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"@dfns/sdk": "^0.8.1",
|
|
41
41
|
"@dfns/sdk-react-native": "^0.8.1",
|
|
42
|
-
"@explorins/pers-sdk": "^1.6.
|
|
42
|
+
"@explorins/pers-sdk": "^1.6.27",
|
|
43
43
|
"@explorins/pers-shared": "^2.1.44",
|
|
44
44
|
"@explorins/pers-signer": "^1.0.18",
|
|
45
45
|
"@explorins/web3-ts": "^0.3.75",
|
|
@@ -27,8 +27,10 @@ interface TransactionAnalyticsGroupByExpression {
|
|
|
27
27
|
|
|
28
28
|
/**
|
|
29
29
|
* Request DTO for transaction analytics
|
|
30
|
+
*
|
|
31
|
+
* @interface TransactionAnalyticsRequestDTO
|
|
30
32
|
*/
|
|
31
|
-
interface TransactionAnalyticsRequestDTO {
|
|
33
|
+
export interface TransactionAnalyticsRequestDTO {
|
|
32
34
|
filters?: TransactionAnalyticsFilters;
|
|
33
35
|
groupBy?: TransactionAnalyticsGroupBy[];
|
|
34
36
|
groupByExpressions?: TransactionAnalyticsGroupByExpression[];
|
|
@@ -64,8 +66,10 @@ interface TransactionAnalyticsResultItem {
|
|
|
64
66
|
|
|
65
67
|
/**
|
|
66
68
|
* Response DTO for transaction analytics
|
|
69
|
+
*
|
|
70
|
+
* @interface TransactionAnalyticsResponseDTO
|
|
67
71
|
*/
|
|
68
|
-
interface TransactionAnalyticsResponseDTO {
|
|
72
|
+
export interface TransactionAnalyticsResponseDTO {
|
|
69
73
|
results: TransactionAnalyticsResultItem[];
|
|
70
74
|
totalGroups: number;
|
|
71
75
|
metadata: {
|
|
@@ -31,7 +31,7 @@ try {
|
|
|
31
31
|
* @property {boolean} isSignerInitialized - Whether the signer SDK has been initialized
|
|
32
32
|
* @property {boolean} isSignerAvailable - Whether signing functionality is fully available
|
|
33
33
|
*/
|
|
34
|
-
interface TransactionSignerHook {
|
|
34
|
+
export interface TransactionSignerHook {
|
|
35
35
|
signAndSubmitTransactionWithJWT: (jwt: string) => Promise<SubmissionResult>;
|
|
36
36
|
isSignerInitialized: boolean;
|
|
37
37
|
isSignerAvailable: boolean;
|
|
@@ -418,4 +418,4 @@ export const useTransactionSigner = (): TransactionSignerHook => {
|
|
|
418
418
|
* @see {@link TransactionSigningResult} - Transaction signing result details
|
|
419
419
|
* @see {@link TransactionSignerHook} - Hook return interface
|
|
420
420
|
*/
|
|
421
|
-
export type { SubmissionResult, AuthenticatedUser, TransactionSigningResult
|
|
421
|
+
export type { SubmissionResult, AuthenticatedUser, TransactionSigningResult };
|
package/src/hooks/useWeb3.ts
CHANGED
|
@@ -9,7 +9,14 @@ import type {
|
|
|
9
9
|
} from '@explorins/pers-sdk/web3';
|
|
10
10
|
import type { ChainData } from '@explorins/pers-sdk/web3-chain';
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
/**
|
|
13
|
+
* Wallet information interface
|
|
14
|
+
*
|
|
15
|
+
* @interface WalletInfo
|
|
16
|
+
* @property {string | null} address - Wallet address if connected
|
|
17
|
+
* @property {boolean} isConnected - Whether wallet is connected
|
|
18
|
+
*/
|
|
19
|
+
export interface WalletInfo {
|
|
13
20
|
address: string | null;
|
|
14
21
|
isConnected: boolean;
|
|
15
22
|
}
|
|
@@ -36,7 +36,6 @@ export interface ReactNativeAuthConfig {
|
|
|
36
36
|
* - Mobile: Uses AsyncStorageTokenStorage (React Native specific)
|
|
37
37
|
*
|
|
38
38
|
* @param projectKey - PERS project key
|
|
39
|
-
* @param authApi - Optional auth API instance
|
|
40
39
|
* @param config - Configuration options
|
|
41
40
|
* @returns DefaultAuthProvider configured for the current platform
|
|
42
41
|
*/
|
|
@@ -5,6 +5,15 @@
|
|
|
5
5
|
* and uses fetch API which is available in React Native.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
+
/**
|
|
9
|
+
* Request options for HTTP client operations
|
|
10
|
+
*
|
|
11
|
+
* @interface RequestOptions
|
|
12
|
+
* @property {Record<string, string>} [headers] - HTTP headers to include
|
|
13
|
+
* @property {Record<string, string>} [params] - URL parameters
|
|
14
|
+
* @property {number} [timeout] - Request timeout in milliseconds
|
|
15
|
+
* @property {'json' | 'blob' | 'text' | 'arraybuffer'} [responseType] - Expected response type
|
|
16
|
+
*/
|
|
8
17
|
export interface RequestOptions {
|
|
9
18
|
headers?: Record<string, string>;
|
|
10
19
|
params?: Record<string, string>;
|
|
@@ -12,6 +21,12 @@ export interface RequestOptions {
|
|
|
12
21
|
responseType?: 'json' | 'blob' | 'text' | 'arraybuffer';
|
|
13
22
|
}
|
|
14
23
|
|
|
24
|
+
/**
|
|
25
|
+
* HTTP Client interface for React Native
|
|
26
|
+
*
|
|
27
|
+
* @interface HttpClient
|
|
28
|
+
* @template T - Response type
|
|
29
|
+
*/
|
|
15
30
|
export interface HttpClient {
|
|
16
31
|
get<T>(url: string, options?: RequestOptions): Promise<T>;
|
|
17
32
|
post<T>(url: string, body: any, options?: RequestOptions): Promise<T>;
|
|
@@ -74,17 +89,19 @@ export class ReactNativeHttpClient implements HttpClient {
|
|
|
74
89
|
const response = await fetch(fullUrl, config);
|
|
75
90
|
|
|
76
91
|
if (!response.ok) {
|
|
77
|
-
//
|
|
78
|
-
let
|
|
92
|
+
// Get raw error response for ErrorUtils to handle
|
|
93
|
+
let errorText = '';
|
|
79
94
|
try {
|
|
80
|
-
|
|
81
|
-
if (errorBody) {
|
|
82
|
-
errorMessage += ` - ${errorBody}`;
|
|
83
|
-
}
|
|
95
|
+
errorText = await response.text();
|
|
84
96
|
} catch (e) {
|
|
85
97
|
// Ignore errors when reading error body
|
|
86
98
|
}
|
|
87
|
-
|
|
99
|
+
|
|
100
|
+
// Create simple error with HTTP status and raw response
|
|
101
|
+
const httpError = new Error(`HTTP ${response.status}: ${response.statusText} - ${errorText}`);
|
|
102
|
+
(httpError as any).status = response.status;
|
|
103
|
+
|
|
104
|
+
throw httpError;
|
|
88
105
|
}
|
|
89
106
|
|
|
90
107
|
// Handle different response types
|