@explorins/pers-sdk-react-native 1.5.29 → 1.5.31
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 +9 -0
- package/dist/index.js +27 -13
- package/dist/index.js.map +1 -1
- package/dist/providers/PersSDKProvider.d.ts.map +1 -1
- package/dist/providers/PersSDKProvider.js +15 -11
- package/dist/providers/react-native-auth-provider.d.ts +5 -0
- package/dist/providers/react-native-auth-provider.d.ts.map +1 -1
- package/dist/providers/react-native-auth-provider.js +12 -2
- package/package.json +1 -1
- package/src/providers/PersSDKProvider.tsx +19 -12
- package/src/providers/react-native-auth-provider.ts +20 -2
package/README.md
CHANGED
|
@@ -398,6 +398,15 @@ The `PersSDKProvider` accepts a `config` object allowing you to customize behavi
|
|
|
398
398
|
</PersSDKProvider>
|
|
399
399
|
```
|
|
400
400
|
|
|
401
|
+
### Storage Fallback Strategy
|
|
402
|
+
|
|
403
|
+
The SDK implements a robust **Hybrid Storage Strategy**:
|
|
404
|
+
1. **Primary**: Attempts to use **Android Keystore / iOS Keychain** (via `react-native-keychain`) for maximum security.
|
|
405
|
+
2. **Fallback**: If hardware storage is unavailable or fails, it automatically falls back to **AsyncStorage**.
|
|
406
|
+
3. **Web**: Uses `localStorage` automatically.
|
|
407
|
+
|
|
408
|
+
This ensures your app works reliably across all devices while prioritizing security where available.
|
|
409
|
+
|
|
401
410
|
### Custom Authentication Provider
|
|
402
411
|
|
|
403
412
|
The SDK automatically uses `ReactNativeSecureStorage` for React Native (iOS/Android) and `LocalStorageTokenStorage` for Web. You can customize this if needed:
|
package/dist/index.js
CHANGED
|
@@ -32215,16 +32215,26 @@ function createReactNativeAuthProvider(projectKey, config = {}) {
|
|
|
32215
32215
|
if (!projectKey || typeof projectKey !== 'string') {
|
|
32216
32216
|
throw new Error('createReactNativeAuthProvider: projectKey is required and must be a string');
|
|
32217
32217
|
}
|
|
32218
|
-
const { keyPrefix = `pers_${projectKey.slice(0, 8)}_`, debug = false, customStorage, authType = 'user' } = config;
|
|
32218
|
+
const { keyPrefix = `pers_${projectKey.slice(0, 8)}_`, debug = false, customStorage, authType = 'user', dpop } = config;
|
|
32219
32219
|
// Platform-specific storage selection
|
|
32220
32220
|
const tokenStorage = customStorage || (isWebPlatform
|
|
32221
32221
|
? new LocalStorageTokenStorage()
|
|
32222
32222
|
: new ReactNativeSecureStorage(keyPrefix));
|
|
32223
|
+
// Prepare DPoP config ensuring enabled is boolean (default true)
|
|
32224
|
+
const dpopConfig = dpop ? {
|
|
32225
|
+
enabled: dpop.enabled ?? true,
|
|
32226
|
+
cryptoProvider: dpop.cryptoProvider
|
|
32227
|
+
} : undefined;
|
|
32228
|
+
// DEBUG LOGGING
|
|
32229
|
+
if (debug) {
|
|
32230
|
+
console.log('[ReactNativeAuthProvider] Creating provider with DPoP config:', JSON.stringify(dpopConfig));
|
|
32231
|
+
}
|
|
32223
32232
|
// Return DefaultAuthProvider configured with platform-appropriate storage
|
|
32224
32233
|
return new DefaultAuthProvider({
|
|
32225
32234
|
authType,
|
|
32226
32235
|
projectKey,
|
|
32227
|
-
storage: tokenStorage
|
|
32236
|
+
storage: tokenStorage,
|
|
32237
|
+
dpop: dpopConfig
|
|
32228
32238
|
});
|
|
32229
32239
|
}
|
|
32230
32240
|
|
|
@@ -32548,6 +32558,17 @@ const PersSDKProvider = ({ children, config }) => {
|
|
|
32548
32558
|
try {
|
|
32549
32559
|
// Create HTTP client
|
|
32550
32560
|
const httpClient = new ReactNativeHttpClient();
|
|
32561
|
+
const dpopConfig = config.dpop ?? {};
|
|
32562
|
+
const isDpopEnabled = dpopConfig.enabled ?? true;
|
|
32563
|
+
// Prepare DPoP settings for Auth Provider
|
|
32564
|
+
const dpopSettings = {
|
|
32565
|
+
enabled: isDpopEnabled,
|
|
32566
|
+
cryptoProvider: dpopConfig.cryptoProvider
|
|
32567
|
+
};
|
|
32568
|
+
// Inject Native DPoP Provider (crypto-based) for mobile platforms if not already provided
|
|
32569
|
+
if (reactNative.Platform.OS !== 'web' && isDpopEnabled && !dpopSettings.cryptoProvider) {
|
|
32570
|
+
dpopSettings.cryptoProvider = new ReactNativeDPoPProvider();
|
|
32571
|
+
}
|
|
32551
32572
|
// Create platform-aware auth provider if not provided
|
|
32552
32573
|
let authProvider;
|
|
32553
32574
|
if (config.authProvider) {
|
|
@@ -32556,23 +32577,16 @@ const PersSDKProvider = ({ children, config }) => {
|
|
|
32556
32577
|
else {
|
|
32557
32578
|
// Use our platform-aware auth provider that automatically selects LocalStorage (web) or AsyncStorage (mobile)
|
|
32558
32579
|
authProvider = createReactNativeAuthProvider(config.apiProjectKey || 'default-project', {
|
|
32559
|
-
debug: false
|
|
32580
|
+
debug: false,
|
|
32581
|
+
dpop: dpopSettings
|
|
32560
32582
|
});
|
|
32561
32583
|
}
|
|
32562
32584
|
// Enhanced config with platform-appropriate auth provider
|
|
32563
32585
|
const sdkConfig = {
|
|
32564
32586
|
...config,
|
|
32565
|
-
authProvider
|
|
32587
|
+
authProvider,
|
|
32588
|
+
dpop: dpopSettings
|
|
32566
32589
|
};
|
|
32567
|
-
// Inject Native DPoP Provider (crypto-based) for mobile platforms
|
|
32568
|
-
// Web platforms use built-in WebCrypto provider by default
|
|
32569
|
-
if (reactNative.Platform.OS !== 'web' && (!config.dpop?.cryptoProvider)) {
|
|
32570
|
-
sdkConfig.dpop = {
|
|
32571
|
-
...(config.dpop || {}),
|
|
32572
|
-
enabled: config.dpop?.enabled ?? true,
|
|
32573
|
-
cryptoProvider: new ReactNativeDPoPProvider()
|
|
32574
|
-
};
|
|
32575
|
-
}
|
|
32576
32590
|
// Initialize PersSDK with platform-aware auth provider
|
|
32577
32591
|
const sdkInstance = new PersSDK(httpClient, sdkConfig);
|
|
32578
32592
|
setAuthProvider(authProvider);
|