@explorins/pers-sdk-react-native 1.5.21 → 1.5.23
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/useRedemptions.d.ts +1 -1
- package/dist/hooks/useRedemptions.d.ts.map +1 -1
- package/dist/hooks/useRedemptions.js +4 -4
- package/dist/index.js +75 -32
- package/dist/index.js.map +1 -1
- 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/useRedemptions.ts +4 -4
- package/src/providers/react-native-http-client.ts +9 -7
|
@@ -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;;;;;;;;GAQG;AACH,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;;;;;GAKG;AACH,MAAM,WAAW,UAAU;IACzB,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;IAC1D,IAAI,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;IACtE,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,CAAC,CAAC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NativeHttpClient {
|
|
|
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.23",
|
|
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.28",
|
|
43
43
|
"@explorins/pers-shared": "^2.1.44",
|
|
44
44
|
"@explorins/pers-signer": "^1.0.18",
|
|
45
45
|
"@explorins/web3-ts": "^0.3.75",
|
|
@@ -47,17 +47,17 @@ export const useRedemptions = () => {
|
|
|
47
47
|
}
|
|
48
48
|
}, [sdk, isInitialized, isAuthenticated]);
|
|
49
49
|
|
|
50
|
-
const
|
|
50
|
+
const redeem = useCallback(async (redemptionId: string): Promise<RedemptionRedeemRequestResponseDTO> => {
|
|
51
51
|
if (!isInitialized || !sdk) {
|
|
52
52
|
throw new Error('SDK not initialized. Call initialize() first.');
|
|
53
53
|
}
|
|
54
54
|
if (!isAuthenticated) {
|
|
55
|
-
throw new Error('SDK not authenticated.
|
|
55
|
+
throw new Error('SDK not authenticated. redeem requires authentication.');
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
try {
|
|
59
59
|
console.log('Redeeming redemption:', redemptionId);
|
|
60
|
-
const result = await sdk.redemptions.
|
|
60
|
+
const result = await sdk.redemptions.redeem(redemptionId);
|
|
61
61
|
|
|
62
62
|
// Check if result has signing fields and sign transaction if required and signer is available
|
|
63
63
|
console.log('Redemption processed successfully:', result);
|
|
@@ -181,7 +181,7 @@ export const useRedemptions = () => {
|
|
|
181
181
|
return {
|
|
182
182
|
getActiveRedemptions,
|
|
183
183
|
getUserRedemptions,
|
|
184
|
-
|
|
184
|
+
redeem,
|
|
185
185
|
getRedemptionTypes,
|
|
186
186
|
createRedemption,
|
|
187
187
|
getAllRedemptions,
|
|
@@ -89,17 +89,19 @@ export class ReactNativeHttpClient implements HttpClient {
|
|
|
89
89
|
const response = await fetch(fullUrl, config);
|
|
90
90
|
|
|
91
91
|
if (!response.ok) {
|
|
92
|
-
//
|
|
93
|
-
let
|
|
92
|
+
// Get raw error response for ErrorUtils to handle
|
|
93
|
+
let errorText = '';
|
|
94
94
|
try {
|
|
95
|
-
|
|
96
|
-
if (errorBody) {
|
|
97
|
-
errorMessage += ` - ${errorBody}`;
|
|
98
|
-
}
|
|
95
|
+
errorText = await response.text();
|
|
99
96
|
} catch (e) {
|
|
100
97
|
// Ignore errors when reading error body
|
|
101
98
|
}
|
|
102
|
-
|
|
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;
|
|
103
105
|
}
|
|
104
106
|
|
|
105
107
|
// Handle different response types
|