@explorins/pers-sdk-react-native 1.5.18 → 1.5.21
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/README.md +336 -234
- package/dist/hooks/index.d.ts +1 -1
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/useAnalytics.d.ts +6 -2
- package/dist/hooks/useAnalytics.d.ts.map +1 -1
- package/dist/hooks/useAuth.d.ts +1 -1
- package/dist/hooks/useAuth.d.ts.map +1 -1
- package/dist/hooks/useAuth.js +7 -7
- package/dist/hooks/useRedemptions.d.ts.map +1 -1
- package/dist/hooks/useRedemptions.js +4 -4
- package/dist/hooks/useTenants.d.ts.map +1 -1
- package/dist/hooks/useTenants.js +0 -1
- package/dist/hooks/useTransactionSigner.d.ts +186 -53
- package/dist/hooks/useTransactionSigner.d.ts.map +1 -1
- package/dist/hooks/useTransactionSigner.js +285 -102
- package/dist/hooks/useTransactions.d.ts +2 -2
- package/dist/hooks/useTransactions.d.ts.map +1 -1
- package/dist/hooks/useTransactions.js +9 -10
- package/dist/hooks/useWeb3.d.ts +8 -2
- package/dist/hooks/useWeb3.d.ts.map +1 -1
- package/dist/index.d.ts +211 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +21061 -18475
- package/dist/index.js.map +1 -1
- package/dist/providers/PersSDKProvider.d.ts +2 -8
- package/dist/providers/PersSDKProvider.d.ts.map +1 -1
- package/dist/providers/PersSDKProvider.js +16 -31
- package/dist/providers/react-native-auth-provider.d.ts +24 -36
- package/dist/providers/react-native-auth-provider.d.ts.map +1 -1
- package/dist/providers/react-native-auth-provider.js +35 -146
- 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/storage/async-storage-token-storage.d.ts +22 -0
- package/dist/storage/async-storage-token-storage.d.ts.map +1 -0
- package/dist/storage/async-storage-token-storage.js +113 -0
- package/package.json +16 -11
- package/src/hooks/index.ts +1 -1
- package/src/hooks/useAnalytics.ts +6 -2
- package/src/hooks/useAuth.ts +7 -7
- package/src/hooks/useRedemptions.ts +5 -7
- package/src/hooks/useTenants.ts +0 -1
- package/src/hooks/useTransactionSigner.ts +322 -166
- package/src/hooks/useTransactions.ts +12 -11
- package/src/hooks/useWeb3.ts +8 -1
- package/src/index.ts +243 -7
- package/src/providers/PersSDKProvider.tsx +21 -40
- package/src/providers/react-native-auth-provider.ts +58 -176
- package/src/providers/react-native-http-client.ts +15 -0
- package/src/storage/async-storage-token-storage.ts +133 -0
|
@@ -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: {
|
package/src/hooks/useAuth.ts
CHANGED
|
@@ -79,7 +79,7 @@ export const useAuth = () => {
|
|
|
79
79
|
console.log(`Logging in as ${userType}...`);
|
|
80
80
|
|
|
81
81
|
// Set token in auth provider
|
|
82
|
-
await authProvider.
|
|
82
|
+
await authProvider.setAccessToken(jwtToken);
|
|
83
83
|
|
|
84
84
|
// Perform login using the manager
|
|
85
85
|
const result = await sdk.auth.loginWithToken(jwtToken, userType);
|
|
@@ -124,12 +124,12 @@ export const useAuth = () => {
|
|
|
124
124
|
try {
|
|
125
125
|
console.log('Logging in with raw user data...');
|
|
126
126
|
|
|
127
|
-
// Use the raw data login from the
|
|
128
|
-
const result = await sdk.
|
|
127
|
+
// Use the raw data login from the auth manager
|
|
128
|
+
const result = await sdk.auth.loginWithRawData(rawUserData);
|
|
129
129
|
|
|
130
130
|
// Set token from result
|
|
131
131
|
if (result.accessToken) {
|
|
132
|
-
await authProvider.
|
|
132
|
+
await authProvider.setAccessToken(result.accessToken);
|
|
133
133
|
}
|
|
134
134
|
|
|
135
135
|
const userData = result.user;
|
|
@@ -168,7 +168,7 @@ export const useAuth = () => {
|
|
|
168
168
|
console.log('Logging out...');
|
|
169
169
|
|
|
170
170
|
if (authProvider) {
|
|
171
|
-
await authProvider.
|
|
171
|
+
await authProvider.clearTokens();
|
|
172
172
|
}
|
|
173
173
|
|
|
174
174
|
setAuthenticationState(null, null, false);
|
|
@@ -272,11 +272,11 @@ export const useAuth = () => {
|
|
|
272
272
|
* console.log('Auth is valid:', isValid);
|
|
273
273
|
* ```
|
|
274
274
|
*/
|
|
275
|
-
const hasValidAuth = useCallback((): boolean => {
|
|
275
|
+
const hasValidAuth = useCallback(async (): Promise<boolean> => {
|
|
276
276
|
if (!sdk) {
|
|
277
277
|
return false;
|
|
278
278
|
}
|
|
279
|
-
return sdk.auth.hasValidAuth();
|
|
279
|
+
return await sdk.auth.hasValidAuth();
|
|
280
280
|
}, [sdk]);
|
|
281
281
|
|
|
282
282
|
return {
|
|
@@ -1,19 +1,17 @@
|
|
|
1
1
|
import { useCallback } from 'react';
|
|
2
2
|
import { usePersSDK } from '../providers/PersSDKProvider';
|
|
3
|
-
import { useTransactionSigner } from './useTransactionSigner';
|
|
4
|
-
import type { TransactionSigningResult } from './useTransactionSigner';
|
|
3
|
+
import { SubmissionResult, useTransactionSigner } from './useTransactionSigner';
|
|
5
4
|
import type {
|
|
6
5
|
RedemptionCreateRequestDTO,
|
|
7
6
|
RedemptionDTO,
|
|
8
7
|
RedemptionRedeemDTO,
|
|
9
8
|
RedemptionRedeemRequestResponseDTO,
|
|
10
9
|
RedemptionTypeDTO,
|
|
11
|
-
TokenUnitCreateRequestDTO
|
|
12
10
|
} from '@explorins/pers-shared';
|
|
13
11
|
|
|
14
12
|
export const useRedemptions = () => {
|
|
15
13
|
const { sdk, isInitialized, isAuthenticated } = usePersSDK();
|
|
16
|
-
const {
|
|
14
|
+
const { signAndSubmitTransactionWithJWT, isSignerAvailable } = useTransactionSigner();
|
|
17
15
|
|
|
18
16
|
const getActiveRedemptions = useCallback(async (): Promise<RedemptionDTO[]> => {
|
|
19
17
|
if (!isInitialized || !sdk) {
|
|
@@ -70,7 +68,7 @@ export const useRedemptions = () => {
|
|
|
70
68
|
console.log('Transaction requires blockchain signing, processing with WebAuthn signer...');
|
|
71
69
|
|
|
72
70
|
try {
|
|
73
|
-
const signingResult:
|
|
71
|
+
const signingResult: SubmissionResult = await signAndSubmitTransactionWithJWT(txToken);
|
|
74
72
|
console.log('Blockchain signing result:', signingResult);
|
|
75
73
|
if (signingResult.success) {
|
|
76
74
|
console.log('Transaction signed successfully:', signingResult.transactionHash);
|
|
@@ -78,7 +76,7 @@ export const useRedemptions = () => {
|
|
|
78
76
|
return {
|
|
79
77
|
...result,
|
|
80
78
|
transactionHash: signingResult.transactionHash,
|
|
81
|
-
signature: signingResult.signature,
|
|
79
|
+
// signature: signingResult.signature,
|
|
82
80
|
isSigned: true,
|
|
83
81
|
signedAt: new Date().toISOString()
|
|
84
82
|
} as RedemptionRedeemRequestResponseDTO;
|
|
@@ -101,7 +99,7 @@ export const useRedemptions = () => {
|
|
|
101
99
|
console.error('Failed to redeem redemption:', error);
|
|
102
100
|
throw error;
|
|
103
101
|
}
|
|
104
|
-
}, [sdk, isInitialized, isAuthenticated,
|
|
102
|
+
}, [sdk, isInitialized, isAuthenticated, signAndSubmitTransactionWithJWT, isSignerAvailable]);
|
|
105
103
|
|
|
106
104
|
// Admin methods
|
|
107
105
|
const createRedemption = useCallback(async (redemptionData: RedemptionCreateRequestDTO): Promise<RedemptionDTO> => {
|
package/src/hooks/useTenants.ts
CHANGED