@explorins/pers-sdk-react-native 2.3.6 → 2.3.8
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/LICENSE +21 -0
- package/README.md +1266 -1244
- package/dist/__tests__/PersSDKProvider.test.js +33 -0
- package/dist/hooks/useBusiness.d.ts +2 -2
- package/dist/hooks/useBusiness.d.ts.map +1 -1
- package/dist/hooks/useBusiness.js +2 -2
- package/dist/hooks/useIPFSUrl.d.ts +3 -3
- package/dist/hooks/useIPFSUrl.d.ts.map +1 -1
- package/dist/hooks/useIPFSUrl.js +7 -7
- package/dist/hooks/useTransactions.d.ts.map +1 -1
- package/dist/hooks/useTransactions.js +13 -5
- package/dist/hooks/useWeb3.js +4 -4
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2412 -492
- package/dist/index.js.map +1 -1
- package/dist/providers/PersSDKProvider.d.ts +4 -0
- package/dist/providers/PersSDKProvider.d.ts.map +1 -1
- package/dist/providers/PersSDKProvider.js +14 -0
- package/dist/providers/react-native-http-client.d.ts +2 -0
- package/dist/providers/react-native-http-client.d.ts.map +1 -1
- package/dist/providers/react-native-http-client.js +5 -2
- package/dist/storage/rn-secure-storage.d.ts.map +1 -1
- package/dist/storage/rn-secure-storage.js +21 -8
- package/package.json +3 -3
- package/src/__tests__/PersSDKProvider.test.tsx +484 -420
- package/src/__tests__/setup.ts +40 -40
- package/src/hooks/index.ts +60 -60
- package/src/hooks/useAnalytics.ts +327 -327
- package/src/hooks/useAuth.ts +265 -265
- package/src/hooks/useBookings.ts +191 -191
- package/src/hooks/useBusiness.ts +251 -251
- package/src/hooks/useCampaigns.ts +500 -500
- package/src/hooks/useDonations.ts +66 -66
- package/src/hooks/useEvents.ts +372 -372
- package/src/hooks/useFiles.ts +155 -155
- package/src/hooks/useIPFSUrl.ts +192 -192
- package/src/hooks/usePurchases.ts +65 -65
- package/src/hooks/useRedemptions.ts +467 -467
- package/src/hooks/useTenants.ts +72 -72
- package/src/hooks/useTokenBalances.ts +385 -385
- package/src/hooks/useTokens.ts +313 -313
- package/src/hooks/useTransactionSigner.ts +611 -611
- package/src/hooks/useTransactions.ts +299 -290
- package/src/hooks/useTriggerSources.ts +301 -301
- package/src/hooks/useUserStatus.ts +61 -61
- package/src/hooks/useUsers.ts +167 -167
- package/src/hooks/useWeb3.ts +355 -355
- package/src/index.ts +777 -774
- package/src/polyfills/index.ts +160 -160
- package/src/polyfills/web3-polyfills.ts +97 -97
- package/src/providers/PersSDKProvider.tsx +393 -374
- package/src/providers/react-native-auth-provider.ts +110 -110
- package/src/providers/react-native-http-client.ts +150 -145
- package/src/providers/rn-dpop-provider.ts +190 -190
- package/src/storage/async-storage-token-storage.ts +185 -185
- package/src/storage/rn-secure-storage.ts +182 -170
- package/src/types/react-native-globals.d.ts +45 -45
- package/src/utils/index.ts +8 -8
- package/src/utils/platform-detection.ts +86 -86
- package/dist/index-CzLxqePZ.js +0 -7717
- package/dist/index-CzLxqePZ.js.map +0 -1
package/src/hooks/useTenants.ts
CHANGED
|
@@ -1,73 +1,73 @@
|
|
|
1
|
-
import { useCallback } from 'react';
|
|
2
|
-
import { usePersSDK } from '../providers/PersSDKProvider';
|
|
3
|
-
import type { TenantPublicDTO, TenantClientConfigDTO, AdminDTO, PaginatedResponseDTO } from '@explorins/pers-sdk';
|
|
4
|
-
|
|
5
|
-
export const useTenants = () => {
|
|
6
|
-
const { sdk, isInitialized } = usePersSDK();
|
|
7
|
-
|
|
8
|
-
const getTenantInfo = useCallback(async (): Promise<TenantPublicDTO> => {
|
|
9
|
-
if (!isInitialized || !sdk) {
|
|
10
|
-
throw new Error('SDK not initialized. Call initialize() first.');
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
try {
|
|
14
|
-
const result = await sdk.tenants.getTenantInfo();
|
|
15
|
-
return result;
|
|
16
|
-
} catch (error) {
|
|
17
|
-
console.error('Failed to fetch tenant info:', error);
|
|
18
|
-
throw error;
|
|
19
|
-
}
|
|
20
|
-
}, [sdk, isInitialized]);
|
|
21
|
-
|
|
22
|
-
const getClientConfig = useCallback(async (): Promise<TenantClientConfigDTO> => {
|
|
23
|
-
if (!isInitialized || !sdk) {
|
|
24
|
-
throw new Error('SDK not initialized. Call initialize() first.');
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
try {
|
|
28
|
-
const result = await sdk.tenants.getClientConfig();
|
|
29
|
-
return result;
|
|
30
|
-
} catch (error) {
|
|
31
|
-
console.error('Failed to fetch client config:', error);
|
|
32
|
-
throw error;
|
|
33
|
-
}
|
|
34
|
-
}, [sdk, isInitialized]);
|
|
35
|
-
|
|
36
|
-
const getLoginToken = useCallback(async (): Promise<string> => {
|
|
37
|
-
if (!isInitialized || !sdk) {
|
|
38
|
-
throw new Error('SDK not initialized. Call initialize() first.');
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
try {
|
|
42
|
-
const result = await sdk.tenants.getLoginToken();
|
|
43
|
-
return result;
|
|
44
|
-
} catch (error) {
|
|
45
|
-
console.error('Failed to fetch login token:', error);
|
|
46
|
-
throw error;
|
|
47
|
-
}
|
|
48
|
-
}, [sdk, isInitialized]);
|
|
49
|
-
|
|
50
|
-
const getAdmins = useCallback(async (): Promise<PaginatedResponseDTO<AdminDTO>> => {
|
|
51
|
-
if (!isInitialized || !sdk) {
|
|
52
|
-
throw new Error('SDK not initialized. Call initialize() first.');
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
try {
|
|
56
|
-
const result = await sdk.tenants.getAdmins();
|
|
57
|
-
return result;
|
|
58
|
-
} catch (error) {
|
|
59
|
-
console.error('Failed to fetch admins:', error);
|
|
60
|
-
throw error;
|
|
61
|
-
}
|
|
62
|
-
}, [sdk, isInitialized]);
|
|
63
|
-
|
|
64
|
-
return {
|
|
65
|
-
getTenantInfo,
|
|
66
|
-
getClientConfig,
|
|
67
|
-
getLoginToken,
|
|
68
|
-
getAdmins,
|
|
69
|
-
isAvailable: isInitialized && !!sdk?.tenants,
|
|
70
|
-
};
|
|
71
|
-
};
|
|
72
|
-
|
|
1
|
+
import { useCallback } from 'react';
|
|
2
|
+
import { usePersSDK } from '../providers/PersSDKProvider';
|
|
3
|
+
import type { TenantPublicDTO, TenantClientConfigDTO, AdminDTO, PaginatedResponseDTO } from '@explorins/pers-sdk';
|
|
4
|
+
|
|
5
|
+
export const useTenants = () => {
|
|
6
|
+
const { sdk, isInitialized } = usePersSDK();
|
|
7
|
+
|
|
8
|
+
const getTenantInfo = useCallback(async (): Promise<TenantPublicDTO> => {
|
|
9
|
+
if (!isInitialized || !sdk) {
|
|
10
|
+
throw new Error('SDK not initialized. Call initialize() first.');
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
try {
|
|
14
|
+
const result = await sdk.tenants.getTenantInfo();
|
|
15
|
+
return result;
|
|
16
|
+
} catch (error) {
|
|
17
|
+
console.error('Failed to fetch tenant info:', error);
|
|
18
|
+
throw error;
|
|
19
|
+
}
|
|
20
|
+
}, [sdk, isInitialized]);
|
|
21
|
+
|
|
22
|
+
const getClientConfig = useCallback(async (): Promise<TenantClientConfigDTO> => {
|
|
23
|
+
if (!isInitialized || !sdk) {
|
|
24
|
+
throw new Error('SDK not initialized. Call initialize() first.');
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
try {
|
|
28
|
+
const result = await sdk.tenants.getClientConfig();
|
|
29
|
+
return result;
|
|
30
|
+
} catch (error) {
|
|
31
|
+
console.error('Failed to fetch client config:', error);
|
|
32
|
+
throw error;
|
|
33
|
+
}
|
|
34
|
+
}, [sdk, isInitialized]);
|
|
35
|
+
|
|
36
|
+
const getLoginToken = useCallback(async (): Promise<string> => {
|
|
37
|
+
if (!isInitialized || !sdk) {
|
|
38
|
+
throw new Error('SDK not initialized. Call initialize() first.');
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
try {
|
|
42
|
+
const result = await sdk.tenants.getLoginToken();
|
|
43
|
+
return result;
|
|
44
|
+
} catch (error) {
|
|
45
|
+
console.error('Failed to fetch login token:', error);
|
|
46
|
+
throw error;
|
|
47
|
+
}
|
|
48
|
+
}, [sdk, isInitialized]);
|
|
49
|
+
|
|
50
|
+
const getAdmins = useCallback(async (): Promise<PaginatedResponseDTO<AdminDTO>> => {
|
|
51
|
+
if (!isInitialized || !sdk) {
|
|
52
|
+
throw new Error('SDK not initialized. Call initialize() first.');
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
try {
|
|
56
|
+
const result = await sdk.tenants.getAdmins();
|
|
57
|
+
return result;
|
|
58
|
+
} catch (error) {
|
|
59
|
+
console.error('Failed to fetch admins:', error);
|
|
60
|
+
throw error;
|
|
61
|
+
}
|
|
62
|
+
}, [sdk, isInitialized]);
|
|
63
|
+
|
|
64
|
+
return {
|
|
65
|
+
getTenantInfo,
|
|
66
|
+
getClientConfig,
|
|
67
|
+
getLoginToken,
|
|
68
|
+
getAdmins,
|
|
69
|
+
isAvailable: isInitialized && !!sdk?.tenants,
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
|
|
73
73
|
export type TenantHook = ReturnType<typeof useTenants>;
|