@idealyst/oauth-client 1.2.112 → 1.2.113
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 +3 -3
- package/package.json +3 -3
- package/src/oauth-client.native.ts +14 -3
package/README.md
CHANGED
|
@@ -24,12 +24,12 @@ yarn add @idealyst/oauth-client
|
|
|
24
24
|
|
|
25
25
|
#### For React Native:
|
|
26
26
|
```bash
|
|
27
|
-
npm install
|
|
27
|
+
npm install react-native-inappbrowser-reborn
|
|
28
28
|
# Then for iOS:
|
|
29
29
|
cd ios && pod install
|
|
30
30
|
```
|
|
31
31
|
|
|
32
|
-
This provides `ASWebAuthenticationSession` on iOS (in-app auth sheet, no redirect prompt) and `Chrome Custom Tabs` on Android (in-app browser overlay).
|
|
32
|
+
This provides `ASWebAuthenticationSession` on iOS (in-app auth sheet, no redirect prompt) and `Chrome Custom Tabs` on Android (in-app browser overlay).
|
|
33
33
|
|
|
34
34
|
#### For Web:
|
|
35
35
|
No additional dependencies required.
|
|
@@ -137,7 +137,7 @@ Add intent filter to `android/app/src/main/AndroidManifest.xml`:
|
|
|
137
137
|
|
|
138
138
|
### In-App Auth Session (Automatic)
|
|
139
139
|
|
|
140
|
-
The client uses `
|
|
140
|
+
The client uses `react-native-inappbrowser-reborn` to handle the OAuth flow within an in-app browser session. On iOS this uses `ASWebAuthenticationSession` which avoids the "Open in App?" system prompt that occurs with Safari redirects. On Android it uses Chrome Custom Tabs. No manual deep link listener setup is required.
|
|
141
141
|
|
|
142
142
|
## API Reference
|
|
143
143
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@idealyst/oauth-client",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.113",
|
|
4
4
|
"description": "Universal OAuth2 client for web and React Native",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"module": "src/index.ts",
|
|
@@ -38,14 +38,14 @@
|
|
|
38
38
|
"@types/react-native": "^0.73.0",
|
|
39
39
|
"react": "^19.1.0",
|
|
40
40
|
"react-native": "^0.80.1",
|
|
41
|
-
"
|
|
41
|
+
"react-native-inappbrowser-reborn": "^3.7.0",
|
|
42
42
|
"tsup": "^8.3.5",
|
|
43
43
|
"typescript": "^5.7.3"
|
|
44
44
|
},
|
|
45
45
|
"peerDependencies": {
|
|
46
46
|
"@idealyst/storage": "^1.2.30",
|
|
47
47
|
"react-native": ">=0.60.0",
|
|
48
|
-
"
|
|
48
|
+
"react-native-inappbrowser-reborn": ">=3.0.0"
|
|
49
49
|
},
|
|
50
50
|
"files": [
|
|
51
51
|
"dist",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { OAuthClient, OAuthConfig, OAuthResult, OAuthCallbackParams } from './types'
|
|
2
|
-
import
|
|
2
|
+
import { InAppBrowser } from 'react-native-inappbrowser-reborn'
|
|
3
3
|
|
|
4
4
|
export class NativeOAuthClient<T = OAuthResult> implements OAuthClient<T> {
|
|
5
5
|
private config: OAuthConfig<T>
|
|
@@ -12,8 +12,19 @@ export class NativeOAuthClient<T = OAuthResult> implements OAuthClient<T> {
|
|
|
12
12
|
const state = this.generateState()
|
|
13
13
|
const oauthUrl = this.buildOAuthUrl(state)
|
|
14
14
|
|
|
15
|
-
// Use
|
|
16
|
-
const
|
|
15
|
+
// Use InAppBrowser's auth session (ASWebAuthenticationSession on iOS, Chrome Custom Tabs on Android)
|
|
16
|
+
const redirectScheme = new URL(this.config.redirectUrl).protocol.slice(0, -1)
|
|
17
|
+
|
|
18
|
+
if (!(await InAppBrowser.isAvailable())) {
|
|
19
|
+
throw new Error('InAppBrowser is not available on this device')
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const result = await InAppBrowser.openAuth(oauthUrl, redirectScheme, {
|
|
23
|
+
ephemeralWebSession: false,
|
|
24
|
+
showTitle: false,
|
|
25
|
+
enableUrlBarHiding: true,
|
|
26
|
+
enableDefaultShare: false,
|
|
27
|
+
})
|
|
17
28
|
|
|
18
29
|
if (result.type === 'cancel' || result.type === 'dismiss') {
|
|
19
30
|
throw new Error('User cancelled the authorization')
|