react-native-linkedin-oauth2 1.2.5 → 1.2.6

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 (2) hide show
  1. package/README.md +44 -26
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -117,24 +117,25 @@ export default App;
117
117
 
118
118
  ### LinkedInModal Props
119
119
 
120
- | Prop | Type | Required | Default | Description |
121
- | ---------------- | ----------------------------------------------- | -------- | ---------------------------- | --------------------------------------------------------- |
122
- | `isVisible` | `boolean` | ✅ | - | Controls the visibility of the modal |
123
- | `clientId` | `string` | ✅ | - | Your LinkedIn Client ID |
124
- | `clientSecret` | `string` | | - | Your LinkedIn Client Secret |
125
- | `redirectUri` | `string` | ✅ | - | The redirect URI registered in LinkedIn Developer Console |
126
- | `scope` | `string` | ❌ | `'openid email profile'` | Space-separated list of OAuth scopes |
127
- | `onSuccess` | `(user: LinkedInProfile) => void` | ❌ | `() => {}` | Callback invoked when authentication succeeds |
128
- | `onError` | `(error: Error) => void` | ❌ | `() => {}` | Callback invoked when an error occurs |
129
- | `onClose` | `() => void` | ❌ | `() => {}` | Callback invoked when the modal is closed |
130
- | `onLogout` | `() => void` | ❌ | `() => {}` | Callback invoked when logout completes |
131
- | `logout` | `boolean` | ❌ | `false` | If true, shows LinkedIn logout page instead of login |
132
- | `closeOnSuccess` | `boolean` | ❌ | `true` | Automatically close modal after successful login |
133
- | `renderHeader` | `(props: { onClose: () => void }) => ReactNode` | ❌ | - | Custom header component |
134
- | `renderLoading` | `() => ReactNode` | ❌ | - | Custom loading indicator |
135
- | `containerStyle` | `StyleProp<ViewStyle>` | ❌ | - | Style for the container SafeAreaView |
136
- | `wrapperStyle` | `StyleProp<ViewStyle>` | ❌ | - | Style for the wrapper View |
137
- | `modalProps` | `Partial<Omit<ModalProps, 'visible'>>` | ❌ | `{ animationType: 'slide' }` | Additional props for React Native Modal |
120
+ | Prop | Type | Required | Default | Description |
121
+ | ---------------- | ----------------------------------------------- | -------- | ---------------------------- | ---------------------------------------------------------------------------------------------------------------------------------- |
122
+ | `isVisible` | `boolean` | ✅ | - | Controls the visibility of the modal |
123
+ | `clientId` | `string` | ✅ | - | Your LinkedIn Client ID |
124
+ | `clientSecret` | `string` | ⚠️ | - | Required unless `logout` or `secureMode` is true |
125
+ | `redirectUri` | `string` | ✅ | - | The redirect URI registered in LinkedIn Developer Console |
126
+ | `secureMode` | `boolean` | ❌ | `false` | If true, returns auth code instead of handling secret |
127
+ | `scope` | `string` | ❌ | `'openid email profile'` | Space-separated list of OAuth scopes |
128
+ | `onSuccess` | `(data: any) => void` | ❌ | `() => {}` | Callback invoked when authentication succeeds (returns `LinkedInProfile` normally, or `string` (authCode) if `secureMode` is true) |
129
+ | `onError` | `(error: Error) => void` | ❌ | `() => {}` | Callback invoked when an error occurs |
130
+ | `onClose` | `() => void` | ❌ | `() => {}` | Callback invoked when the modal is closed |
131
+ | `onLogout` | `() => void` | ❌ | `() => {}` | Callback invoked when logout completes |
132
+ | `logout` | `boolean` | ❌ | `false` | If true, shows LinkedIn logout page instead of login |
133
+ | `closeOnSuccess` | `boolean` | ❌ | `true` | Automatically close modal after successful login |
134
+ | `renderHeader` | `(props: { onClose: () => void }) => ReactNode` | ❌ | - | Custom header component |
135
+ | `renderLoading` | `() => ReactNode` | ❌ | - | Custom loading indicator |
136
+ | `containerStyle` | `StyleProp<ViewStyle>` | ❌ | - | Style for the container SafeAreaView |
137
+ | `wrapperStyle` | `StyleProp<ViewStyle>` | ❌ | - | Style for the wrapper View |
138
+ | `modalProps` | `Partial<Omit<ModalProps, 'visible'>>` | ❌ | `{ animationType: 'slide' }` | Additional props for React Native Modal |
138
139
 
139
140
  ### LinkedInProfile Type
140
141
 
@@ -549,13 +550,13 @@ export default App;
549
550
 
550
551
  **Problem:** You're seeing a warning about missing `clientId`, `clientSecret`, or `redirectUri`.
551
552
 
552
- **Solution:** Ensure all three required props are provided:
553
+ **Solution:** Ensure required props are provided based on your mode:
553
554
 
554
555
  ```tsx
555
556
  <LinkedInModal
556
557
  isVisible={true}
557
558
  clientId="YOUR_CLIENT_ID" // ✅ Required
558
- clientSecret="YOUR_CLIENT_SECRET" // ✅ Required
559
+ clientSecret="YOUR_CLIENT_SECRET" // ✅ Required if secureMode is false
559
560
  redirectUri="YOUR_REDIRECT_URI" // ✅ Required
560
561
  // ...other props
561
562
  />
@@ -631,15 +632,32 @@ export default App;
631
632
  > [!CAUTION]
632
633
  > **Client Secret Exposure:** The `clientSecret` is included in your React Native app bundle, which means it can be extracted by determined users. For maximum security, consider implementing a backend proxy that handles the token exchange instead of doing it directly in the mobile app.
633
634
 
634
- ### Recommended Secure Implementation
635
+ ### Recommended Secure Implementation (`secureMode`)
635
636
 
636
- Instead of passing the `clientSecret` directly:
637
+ Instead of passing the `clientSecret` directly to the mobile app, use `secureMode`:
637
638
 
638
- 1. Create a backend endpoint that accepts the authorization code
639
- 2. Have your backend exchange the code for a token using the `clientSecret`
640
- 3. Return the profile data (or your own JWT) to the mobile app
639
+ ```tsx
640
+ <LinkedInModal
641
+ isVisible={showModal}
642
+ clientId="YOUR_CLIENT_ID"
643
+ // No clientSecret needed!
644
+ redirectUri="https://yourapp.com/auth/linkedin/callback"
645
+ secureMode={true}
646
+ onSuccess={async authCode => {
647
+ // 1. Send authCode to your secure backend
648
+ const response = await fetch('https://your-backend.com/api/linkedin/auth', {
649
+ method: 'POST',
650
+ body: JSON.stringify({ code: authCode }),
651
+ });
652
+ // 2. Backend exchanges code for token using clientSecret
653
+ // 3. Return the profile data (or your own JWT) to mobile app
654
+ const data = await response.json();
655
+ }}
656
+ onClose={() => setShowModal(false)}
657
+ />
658
+ ```
641
659
 
642
- This way, the `clientSecret` stays secure on your server.
660
+ This way, the `clientSecret` stays completely secure on your server.
643
661
 
644
662
  ## 📄 TypeScript Support
645
663
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-linkedin-oauth2",
3
- "version": "1.2.5",
3
+ "version": "1.2.6",
4
4
  "description": "A simple package to integrate Linkedin OAuth2 in React Native Apps",
5
5
  "scripts": {
6
6
  "test": "jest",