@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.
Files changed (49) hide show
  1. package/README.md +336 -234
  2. package/dist/hooks/index.d.ts +1 -1
  3. package/dist/hooks/index.d.ts.map +1 -1
  4. package/dist/hooks/useAnalytics.d.ts +6 -2
  5. package/dist/hooks/useAnalytics.d.ts.map +1 -1
  6. package/dist/hooks/useAuth.d.ts +1 -1
  7. package/dist/hooks/useAuth.d.ts.map +1 -1
  8. package/dist/hooks/useAuth.js +7 -7
  9. package/dist/hooks/useRedemptions.d.ts.map +1 -1
  10. package/dist/hooks/useRedemptions.js +4 -4
  11. package/dist/hooks/useTenants.d.ts.map +1 -1
  12. package/dist/hooks/useTenants.js +0 -1
  13. package/dist/hooks/useTransactionSigner.d.ts +186 -53
  14. package/dist/hooks/useTransactionSigner.d.ts.map +1 -1
  15. package/dist/hooks/useTransactionSigner.js +285 -102
  16. package/dist/hooks/useTransactions.d.ts +2 -2
  17. package/dist/hooks/useTransactions.d.ts.map +1 -1
  18. package/dist/hooks/useTransactions.js +9 -10
  19. package/dist/hooks/useWeb3.d.ts +8 -2
  20. package/dist/hooks/useWeb3.d.ts.map +1 -1
  21. package/dist/index.d.ts +211 -1
  22. package/dist/index.d.ts.map +1 -1
  23. package/dist/index.js +21061 -18475
  24. package/dist/index.js.map +1 -1
  25. package/dist/providers/PersSDKProvider.d.ts +2 -8
  26. package/dist/providers/PersSDKProvider.d.ts.map +1 -1
  27. package/dist/providers/PersSDKProvider.js +16 -31
  28. package/dist/providers/react-native-auth-provider.d.ts +24 -36
  29. package/dist/providers/react-native-auth-provider.d.ts.map +1 -1
  30. package/dist/providers/react-native-auth-provider.js +35 -146
  31. package/dist/providers/react-native-http-client.d.ts +15 -0
  32. package/dist/providers/react-native-http-client.d.ts.map +1 -1
  33. package/dist/storage/async-storage-token-storage.d.ts +22 -0
  34. package/dist/storage/async-storage-token-storage.d.ts.map +1 -0
  35. package/dist/storage/async-storage-token-storage.js +113 -0
  36. package/package.json +16 -11
  37. package/src/hooks/index.ts +1 -1
  38. package/src/hooks/useAnalytics.ts +6 -2
  39. package/src/hooks/useAuth.ts +7 -7
  40. package/src/hooks/useRedemptions.ts +5 -7
  41. package/src/hooks/useTenants.ts +0 -1
  42. package/src/hooks/useTransactionSigner.ts +322 -166
  43. package/src/hooks/useTransactions.ts +12 -11
  44. package/src/hooks/useWeb3.ts +8 -1
  45. package/src/index.ts +243 -7
  46. package/src/providers/PersSDKProvider.tsx +21 -40
  47. package/src/providers/react-native-auth-provider.ts +58 -176
  48. package/src/providers/react-native-http-client.ts +15 -0
  49. package/src/storage/async-storage-token-storage.ts +133 -0
package/dist/index.d.ts CHANGED
@@ -1,9 +1,219 @@
1
+ /**
2
+ * @fileoverview PERS SDK for React Native - Tourism Loyalty System
3
+ *
4
+ * A comprehensive React Native SDK for integrating with the PERS (Phygital Experience Rewards System)
5
+ * platform. Provides complete functionality for tourism loyalty applications including user management,
6
+ * token operations, business integrations, campaign management, and blockchain transaction signing.
7
+ *
8
+ * **Key Features:**
9
+ * - Secure authentication with React Native Keychain integration
10
+ * - Token management (earn, redeem, transfer, balance checking)
11
+ * - Business and campaign management
12
+ * - Blockchain transaction signing with WebAuthn
13
+ * - React Native optimized with automatic polyfills
14
+ * - Type-safe interfaces with comprehensive TypeScript support
15
+ * - Analytics and reporting capabilities
16
+ * - Donation and charitable giving features
17
+ *
18
+ * @example
19
+ * **Quick Start:**
20
+ * ```typescript
21
+ * import { PersSDKProvider, usePersSDK, useTransactionSigner } from '@explorins/pers-sdk-react-native';
22
+ *
23
+ * // 1. Wrap your app with the provider
24
+ * function App() {
25
+ * return (
26
+ * <PersSDKProvider config={{ apiUrl: 'https://api.pers.ninja' }}>
27
+ * <YourApp />
28
+ * </PersSDKProvider>
29
+ * );
30
+ * }
31
+ *
32
+ * // 2. Use hooks in your components
33
+ * function RewardScreen() {
34
+ * const { user, isAuthenticated, earnTokens } = usePersSDK();
35
+ * const { signAndSubmitTransactionWithJWT } = useTransactionSigner();
36
+ *
37
+ * // Your reward logic here...
38
+ * }
39
+ * ```
40
+ *
41
+ * @version 1.5.19
42
+ * @author eXplorins
43
+ * @license MIT
44
+ */
1
45
  import './polyfills';
2
- export { ReactNativeAuthProvider, type ReactNativeAuthConfig } from './providers/react-native-auth-provider';
46
+ /**
47
+ * React Native-specific authentication provider with secure keychain integration
48
+ *
49
+ * Provides secure token storage using React Native Keychain, biometric authentication,
50
+ * and automatic token refresh capabilities.
51
+ *
52
+ * @see {@link createReactNativeAuthProvider} - Factory function for auth provider
53
+ * @see {@link ReactNativeAuthConfig} - Configuration interface
54
+ */
55
+ export { createReactNativeAuthProvider, type ReactNativeAuthConfig } from './providers/react-native-auth-provider';
56
+ /**
57
+ * Secure token storage using React Native AsyncStorage
58
+ *
59
+ * Provides encrypted token storage with automatic cleanup and secure key management.
60
+ * Integrates with React Native Keychain for enhanced security on supported devices.
61
+ *
62
+ * @see {@link AsyncStorageTokenStorage} - Secure storage implementation
63
+ */
64
+ export { AsyncStorageTokenStorage, } from './storage/async-storage-token-storage';
65
+ /**
66
+ * Main PERS SDK provider and context for React Native applications
67
+ *
68
+ * The PersSDKProvider should wrap your entire app to provide PERS functionality
69
+ * throughout your component tree. Use usePersSDK hook to access SDK features.
70
+ *
71
+ * @example
72
+ * ```typescript
73
+ * import { PersSDKProvider, usePersSDK } from '@explorins/pers-sdk-react-native';
74
+ *
75
+ * function App() {
76
+ * return (
77
+ * <PersSDKProvider config={{
78
+ * apiUrl: 'https://api.pers.ninja',
79
+ * tenantId: 'your-tenant-id'
80
+ * }}>
81
+ * <NavigationContainer>
82
+ * <YourAppContent />
83
+ * </NavigationContainer>
84
+ * </PersSDKProvider>
85
+ * );
86
+ * }
87
+ *
88
+ * function YourComponent() {
89
+ * const { user, isAuthenticated, earnTokens } = usePersSDK();
90
+ * // Use PERS functionality here...
91
+ * }
92
+ * ```
93
+ *
94
+ * @see {@link PersSDKProvider} - Main provider component
95
+ * @see {@link usePersSDK} - Hook to access SDK functionality
96
+ * @see {@link PersConfig} - Provider configuration interface
97
+ * @see {@link PersSDKContext} - Context type definition
98
+ */
3
99
  export { PersSDKProvider, usePersSDK, type PersConfig, type PersSDKContext } from './providers/PersSDKProvider';
100
+ /**
101
+ * Comprehensive React hooks for PERS platform integration
102
+ *
103
+ * These hooks provide the primary interface for interacting with the PERS platform
104
+ * in React Native applications. Each hook is optimized for specific functionality
105
+ * and includes automatic error handling, loading states, and real-time updates.
106
+ *
107
+ * **Authentication & User Management:**
108
+ * - `useAuth` - User authentication, login, logout, registration
109
+ * - `useUsers` - User profile management and data operations
110
+ * - `useUserStatus` - Real-time user status and activity monitoring
111
+ *
112
+ * **Token & Financial Operations:**
113
+ * - `useTokens` - Token balance, earning, and management
114
+ * - `useTransactions` - Transaction history and monitoring
115
+ * - `useTransactionSigner` - **⭐ Blockchain transaction signing**
116
+ * - `usePurchases` - Purchase history and payment processing
117
+ * - `useDonations` - Charitable giving and donation management
118
+ *
119
+ * **Business & Campaign Management:**
120
+ * - `useBusiness` - Business profile and operations
121
+ * - `useCampaigns` - Marketing campaigns and promotions
122
+ * - `useRedemptions` - Reward redemption and fulfillment
123
+ *
124
+ * **Platform & Analytics:**
125
+ * - `useTenants` - Multi-tenant configuration and management
126
+ * - `useAnalytics` - Usage analytics and reporting
127
+ * - `useFiles` - File upload and management
128
+ * - `useWeb3` - Blockchain integration and wallet operations
129
+ *
130
+ * @example
131
+ * **Token Operations:**
132
+ * ```typescript
133
+ * import { useTokens, useTransactionSigner } from '@explorins/pers-sdk-react-native';
134
+ *
135
+ * function TokenScreen() {
136
+ * const { balance, earnTokens, redeemTokens } = useTokens();
137
+ * const { signAndSubmitTransactionWithJWT } = useTransactionSigner();
138
+ *
139
+ * const handleEarn = async (amount: number) => {
140
+ * const result = await earnTokens({ amount, source: 'reward' });
141
+ * console.log('Earned tokens:', result);
142
+ * };
143
+ *
144
+ * const handleRedeem = async (amount: number) => {
145
+ * const redemption = await redeemTokens({ amount });
146
+ * const txResult = await signAndSubmitTransactionWithJWT(redemption.jwtToken);
147
+ * console.log('Redemption completed:', txResult.transactionHash);
148
+ * };
149
+ * }
150
+ * ```
151
+ *
152
+ * @example
153
+ * **Campaign Integration:**
154
+ * ```typescript
155
+ * import { useCampaigns, useAuth } from '@explorins/pers-sdk-react-native';
156
+ *
157
+ * function CampaignScreen() {
158
+ * const { activeCampaigns, participateInCampaign } = useCampaigns();
159
+ * const { user } = useAuth();
160
+ *
161
+ * const handleParticipate = async (campaignId: string) => {
162
+ * const result = await participateInCampaign(campaignId, {
163
+ * userId: user?.id,
164
+ * participationData: { source: 'mobile_app' }
165
+ * });
166
+ * };
167
+ * }
168
+ * ```
169
+ */
4
170
  export { useAuth, useTokens, useTransactions, useTransactionSigner, useBusiness, useCampaigns, useRedemptions, useWeb3, usePurchases, useTenants, useUsers, useUserStatus, useFiles, useAnalytics, useDonations } from './hooks';
171
+ /**
172
+ * React Native-optimized HTTP client with automatic request/response handling
173
+ *
174
+ * Provides platform-specific networking with proper error handling, timeout management,
175
+ * and React Native compatibility. Automatically handles headers, authentication tokens,
176
+ * and response parsing.
177
+ */
5
178
  export { ReactNativeHttpClient } from './providers/react-native-http-client';
179
+ /**
180
+ * React Native polyfill utilities for web compatibility
181
+ *
182
+ * Automatically initializes required polyfills for crypto, URL, and other web APIs
183
+ * that may not be available in React Native environments. These are typically
184
+ * loaded automatically, but manual initialization is available for advanced use cases.
185
+ *
186
+ * @see {@link initializeReactNativePolyfills} - Manual polyfill initialization
187
+ */
6
188
  export { initializeReactNativePolyfills } from './polyfills';
189
+ /**
190
+ * Re-export all types and utilities from the shared PERS library
191
+ *
192
+ * This includes all core types, DTOs, enums, and utility functions used across
193
+ * the PERS platform. These types ensure consistency between different SDK versions
194
+ * and platform implementations.
195
+ *
196
+ * **Included Types:**
197
+ * - User and authentication types (UserDTO, AuthenticationResult, etc.)
198
+ * - Token and transaction types (TokenDTO, TransactionDTO, etc.)
199
+ * - Business and campaign types (BusinessDTO, CampaignDTO, etc.)
200
+ * - API request/response types for all endpoints
201
+ * - Error types and status enums
202
+ *
203
+ * @see {@link https://github.com/eXplorins/pers-shared} - Shared library documentation
204
+ */
7
205
  export * from '@explorins/pers-shared';
206
+ /**
207
+ * Re-export Web3 and blockchain-related types from base SDK
208
+ *
209
+ * Provides TypeScript definitions for Web3 operations, token management,
210
+ * and blockchain interactions. These types are used by the transaction
211
+ * signing hooks and Web3 integration features.
212
+ *
213
+ * @see {@link TokenBalanceRequest} - Request structure for token balance queries
214
+ * @see {@link TokenBalance} - Token balance response data
215
+ * @see {@link TokenMetadata} - Token metadata and details
216
+ * @see {@link TokenCollection} - Collection of tokens for batch operations
217
+ */
8
218
  export type { TokenBalanceRequest, TokenBalance, TokenMetadata, TokenCollection, TokenCollectionRequest } from '@explorins/pers-sdk/web3';
9
219
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,aAAa,CAAC;AAGrB,OAAO,EACL,uBAAuB,EACvB,KAAK,qBAAqB,EAC3B,MAAM,wCAAwC,CAAC;AAGhD,OAAO,EACL,eAAe,EACf,UAAU,EACV,KAAK,UAAU,EACf,KAAK,cAAc,EACpB,MAAM,6BAA6B,CAAC;AAGrC,OAAO,EACL,OAAO,EACP,SAAS,EACT,eAAe,EACf,oBAAoB,EACpB,WAAW,EACX,YAAY,EACZ,cAAc,EACd,OAAO,EACP,YAAY,EACZ,UAAU,EACV,QAAQ,EACR,aAAa,EACb,QAAQ,EACR,YAAY,EACZ,YAAY,EACb,MAAM,SAAS,CAAC;AAEjB,OAAO,EACL,qBAAqB,EACtB,MAAM,sCAAsC,CAAC;AAG9C,OAAO,EACL,8BAA8B,EAC/B,MAAM,aAAa,CAAC;AAGrB,cAAc,wBAAwB,CAAC;AAGvC,YAAY,EACV,mBAAm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