react-native-credentials-manager 0.6.0 → 0.6.2
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 +8 -176
- package/android/src/main/java/com/credentialsmanager/handlers/CredentialHandler.kt +30 -6
- package/android/src/newarch/java/com/credentialsmanager/CredentialsManagerModule.kt +2 -0
- package/lib/commonjs/index.js +13 -28
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/index.js +13 -28
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/commonjs/src/NativeCredentialsManager.d.ts +3 -3
- package/lib/typescript/commonjs/src/NativeCredentialsManager.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/index.d.ts +12 -5
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
- package/lib/typescript/module/src/NativeCredentialsManager.d.ts +3 -3
- package/lib/typescript/module/src/NativeCredentialsManager.d.ts.map +1 -1
- package/lib/typescript/module/src/index.d.ts +12 -5
- package/lib/typescript/module/src/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/NativeCredentialsManager.ts +3 -3
- package/src/index.tsx +49 -33
package/README.md
CHANGED
|
@@ -20,7 +20,9 @@ A React Native library that implements the [Credential Manager](https://develope
|
|
|
20
20
|
|
|
21
21
|
## Platform Support
|
|
22
22
|
|
|
23
|
-
- ✅ **Android**:
|
|
23
|
+
- ✅ **Android**: Implementation with Credential Manager API (Android 4.4+ / API 19+)
|
|
24
|
+
- **Android 4.4+ (API 19+)**: Username/password storage and federated sign-in (Google Sign-In)
|
|
25
|
+
- **Android 9+ (API 28+)**: Full passkey (FIDO2/WebAuthn) support
|
|
24
26
|
- ✅ **iOS**: Full implementation with AuthenticationServices (iOS 16.0+)
|
|
25
27
|
|
|
26
28
|
### Platform-Specific Features
|
|
@@ -32,182 +34,12 @@ A React Native library that implements the [Credential Manager](https://develope
|
|
|
32
34
|
| Manual Password Storage | ✅ Credential Manager API | ❌ Not supported (iOS limitation) |
|
|
33
35
|
| Third-party Sign In | ✅ Google Sign In | ✅ Apple Sign In |
|
|
34
36
|
|
|
35
|
-
> [!NOTE] > **iOS Implementation**: This library strictly follows Apple's Authentication Services framework. Manual password storage is not supported on iOS as it's not part of Apple's official Authentication Services APIs. Use AutoFill passwords instead.
|
|
36
|
-
|
|
37
37
|
> [!IMPORTANT]
|
|
38
38
|
> 📚 **Documentation has moved!** The complete documentation is now available at [https://docs.benjamineruvieru.com/docs/react-native-credentials-manager/](https://docs.benjamineruvieru.com/docs/react-native-credentials-manager/)
|
|
39
39
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
When using this library, be aware that some parameters are platform-specific:
|
|
43
|
-
|
|
44
|
-
| Function | Parameter | Platform Support | Notes |
|
|
45
|
-
| ---------------------- | --------------------------------------- | ---------------- | ----------------------------------------------------------------- |
|
|
46
|
-
| `signUpWithPasskeys()` | `preferImmediatelyAvailableCredentials` | Android only | This parameter is ignored on iOS |
|
|
47
|
-
| `signUpWithPassword()` | All parameters | Android only | This function is not supported on iOS and will throw an error |
|
|
48
|
-
| `signIn()` | `googleSignIn` | Android only | This parameter is ignored on iOS |
|
|
49
|
-
| `signIn()` | `appleSignIn` | iOS only | This parameter is ignored on Android |
|
|
50
|
-
| `signUpWithGoogle()` | All parameters | Cross-platform | Uses Google Sign-In on Android, Apple Sign-In on iOS |
|
|
51
|
-
| `signUpWithApple()` | All parameters | iOS only | This function is not supported on Android and will throw an error |
|
|
52
|
-
|
|
53
|
-
### Handling Platform Differences
|
|
54
|
-
|
|
55
|
-
To handle these platform differences, you can use conditional code:
|
|
56
|
-
|
|
57
|
-
```typescript
|
|
58
|
-
// For passkey registration
|
|
59
|
-
await signUpWithPasskeys(
|
|
60
|
-
requestJson,
|
|
61
|
-
Platform.OS === 'android' ? true : false // preferImmediatelyAvailableCredentials
|
|
62
|
-
);
|
|
63
|
-
|
|
64
|
-
// For sign-in
|
|
65
|
-
await signIn(
|
|
66
|
-
[
|
|
67
|
-
'passkeys',
|
|
68
|
-
'password',
|
|
69
|
-
Platform.OS === 'android' ? 'google-signin' : 'apple-signin',
|
|
70
|
-
],
|
|
71
|
-
{
|
|
72
|
-
passkeys: passkeyParams,
|
|
73
|
-
...(Platform.OS === 'android'
|
|
74
|
-
? { googleSignIn: { serverClientId: 'your-client-id' } }
|
|
75
|
-
: { appleSignIn: { requestedScopes: ['fullName', 'email'] } }),
|
|
76
|
-
}
|
|
77
|
-
);
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
## iOS Setup Requirements
|
|
81
|
-
|
|
82
|
-
### 1. Associated Domains
|
|
83
|
-
|
|
84
|
-
Add the Associated Domains capability to your iOS app:
|
|
85
|
-
|
|
86
|
-
1. In Xcode, select your project
|
|
87
|
-
2. Go to Signing & Capabilities
|
|
88
|
-
3. Add "Associated Domains" capability
|
|
89
|
-
4. Add your domain with the `webcredentials` service: `webcredentials:yourdomain.com`
|
|
90
|
-
|
|
91
|
-
### 2. Apple App Site Association (AASA)
|
|
92
|
-
|
|
93
|
-
Ensure your domain has a proper AASA file at `https://yourdomain.com/.well-known/apple-app-site-association`:
|
|
94
|
-
|
|
95
|
-
```json
|
|
96
|
-
{
|
|
97
|
-
"webcredentials": {
|
|
98
|
-
"apps": ["TEAMID.com.yourcompany.yourapp"]
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
```
|
|
102
|
-
|
|
103
|
-
### 3. Apple Sign In Setup (Optional)
|
|
104
|
-
|
|
105
|
-
If using Apple Sign In, configure it in your Apple Developer account:
|
|
106
|
-
|
|
107
|
-
1. Enable "Sign In with Apple" capability in Xcode
|
|
108
|
-
2. Configure Sign In with Apple in your Apple Developer account
|
|
109
|
-
3. Add your app's bundle identifier to the Sign In with Apple configuration
|
|
110
|
-
|
|
111
|
-
## Quick Example
|
|
112
|
-
|
|
113
|
-
```typescript
|
|
114
|
-
import {
|
|
115
|
-
signUpWithPasskeys,
|
|
116
|
-
signUpWithPassword, // Android only - throws error on iOS
|
|
117
|
-
signUpWithGoogle, // Cross-platform: Google on Android, Apple on iOS
|
|
118
|
-
signUpWithApple, // iOS-specific function
|
|
119
|
-
signIn,
|
|
120
|
-
signOut,
|
|
121
|
-
type Credential,
|
|
122
|
-
type AppleCredential,
|
|
123
|
-
type GoogleCredential,
|
|
124
|
-
type AppleSignInParams,
|
|
125
|
-
type GoogleSignInParams,
|
|
126
|
-
} from 'react-native-credentials-manager';
|
|
127
|
-
|
|
128
|
-
// Sign up with passkey (works on both platforms)
|
|
129
|
-
const passkeyResult = await signUpWithPasskeys({
|
|
130
|
-
challenge: 'base64-challenge',
|
|
131
|
-
rp: { name: 'Your App', id: 'yourdomain.com' },
|
|
132
|
-
user: { id: 'user-id', name: 'username', displayName: 'User Name' },
|
|
133
|
-
// ... other WebAuthn options
|
|
134
|
-
});
|
|
135
|
-
|
|
136
|
-
// Password handling - platform differences
|
|
137
|
-
try {
|
|
138
|
-
// This will work on Android but throw an error on iOS
|
|
139
|
-
await signUpWithPassword({ username: 'user', password: 'pass' });
|
|
140
|
-
} catch (error) {
|
|
141
|
-
if (Platform.OS === 'ios') {
|
|
142
|
-
console.log(
|
|
143
|
-
'Manual password storage not supported on iOS. Use AutoFill instead.'
|
|
144
|
-
);
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
// Unified sign in (supports passkeys, AutoFill passwords, and platform sign-in)
|
|
149
|
-
const credential = await signIn(
|
|
150
|
-
['passkeys', 'password', 'google-signin'], // 'google-signin' becomes 'apple-signin' on iOS
|
|
151
|
-
{
|
|
152
|
-
passkeys: { challenge: 'base64-challenge', rpId: 'yourdomain.com' },
|
|
153
|
-
googleSignIn: { serverClientId: 'your-client-id' },
|
|
154
|
-
}
|
|
155
|
-
);
|
|
156
|
-
|
|
157
|
-
// Platform-specific sign-up methods
|
|
158
|
-
if (Platform.OS === 'ios') {
|
|
159
|
-
// Direct Apple Sign In (iOS only) - uses AuthenticationServices
|
|
160
|
-
const appleCredential = await signUpWithApple({
|
|
161
|
-
requestedScopes: ['fullName', 'email'],
|
|
162
|
-
});
|
|
163
|
-
} else {
|
|
164
|
-
// Google Sign In (Android only)
|
|
165
|
-
const googleCredential = await signUpWithGoogle({
|
|
166
|
-
serverClientId: 'your-client-id',
|
|
167
|
-
});
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
// Cross-platform sign-up (automatically uses the appropriate method)
|
|
171
|
-
const credential = await signUpWithGoogle({
|
|
172
|
-
serverClientId: 'your-client-id', // Used on Android, ignored on iOS
|
|
173
|
-
});
|
|
174
|
-
// Returns GoogleCredential on Android, AppleCredential on iOS
|
|
175
|
-
|
|
176
|
-
// Handle different credential types
|
|
177
|
-
if (credential.type === 'passkey') {
|
|
178
|
-
console.log('Passkey authentication:', credential.authenticationResponseJson);
|
|
179
|
-
} else if (credential.type === 'password') {
|
|
180
|
-
console.log('AutoFill Password:', credential.username, credential.password);
|
|
181
|
-
} else if (credential.type === 'google-signin') {
|
|
182
|
-
console.log('Google Sign In:', credential.idToken);
|
|
183
|
-
} else if (credential.type === 'apple-signin') {
|
|
184
|
-
console.log('Apple Sign In:', credential.idToken, credential.email);
|
|
185
|
-
}
|
|
186
|
-
```
|
|
187
|
-
|
|
188
|
-
## Cross-Platform Compatibility
|
|
189
|
-
|
|
190
|
-
The library provides excellent cross-platform compatibility while respecting platform limitations:
|
|
191
|
-
|
|
192
|
-
- **`signUpWithGoogle()`**: Cross-platform function
|
|
193
|
-
- Android: Uses Google Sign In
|
|
194
|
-
- iOS: Automatically uses Apple Sign In (AuthenticationServices)
|
|
195
|
-
- **`signUpWithApple()`**: iOS-specific function
|
|
196
|
-
- iOS: Uses Apple Sign In (AuthenticationServices)
|
|
197
|
-
- Android: Rejects with clear error message
|
|
198
|
-
- **`signUpWithPassword()`**: Platform-specific behavior
|
|
199
|
-
- Android: Uses Credential Manager API
|
|
200
|
-
- iOS: Rejects (manual storage not supported by AuthenticationServices)
|
|
201
|
-
- **AutoFill Passwords**: Available on both platforms through `signIn` method
|
|
202
|
-
- **Error handling**: Platform-specific errors are handled gracefully
|
|
203
|
-
|
|
204
|
-
## iOS AuthenticationServices Integration
|
|
205
|
-
|
|
206
|
-
The iOS implementation strictly follows Apple's Authentication Services framework:
|
|
207
|
-
|
|
208
|
-
- **Passkeys**: `ASAuthorizationPlatformPublicKeyCredentialProvider`
|
|
209
|
-
- **AutoFill Passwords**: `ASAuthorizationPasswordProvider`
|
|
210
|
-
- **Apple Sign In**: `ASAuthorizationAppleIDProvider`
|
|
211
|
-
- **No Custom Keychain**: Manual credential storage is handled by the system
|
|
40
|
+
> [!NOTE] > **iOS Implementation**: This library strictly follows Apple's Authentication Services framework. Manual password storage is not supported on iOS as it's not part of Apple's official Authentication Services APIs. Use AutoFill passwords instead.
|
|
212
41
|
|
|
213
|
-
|
|
42
|
+
> [!NOTE] > **Android Implementation**: Features are available based on Android version:
|
|
43
|
+
>
|
|
44
|
+
> - **API 19+**: Basic credential storage and Google Sign-In
|
|
45
|
+
> - **API 28+**: Passkey support added
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
package com.credentialsmanager.handlers
|
|
2
2
|
|
|
3
|
+
import android.app.Activity
|
|
3
4
|
import android.content.Context
|
|
4
5
|
import android.util.Log
|
|
5
6
|
import androidx.credentials.ClearCredentialStateRequest
|
|
@@ -16,6 +17,7 @@ import androidx.credentials.GetPublicKeyCredentialOption
|
|
|
16
17
|
import androidx.credentials.PasswordCredential
|
|
17
18
|
import androidx.credentials.PublicKeyCredential
|
|
18
19
|
import com.facebook.react.bridge.Arguments
|
|
20
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
19
21
|
import com.facebook.react.bridge.ReadableArray
|
|
20
22
|
import com.facebook.react.bridge.ReadableMap
|
|
21
23
|
import com.google.android.libraries.identity.googleid.GetGoogleIdOption
|
|
@@ -28,6 +30,23 @@ class CredentialHandler(
|
|
|
28
30
|
) {
|
|
29
31
|
private val credentialManager = CredentialManager.create(context)
|
|
30
32
|
|
|
33
|
+
// Helper function to get activity context
|
|
34
|
+
private fun getActivityContext(): Context {
|
|
35
|
+
if (context is ReactApplicationContext) {
|
|
36
|
+
val activity = context.currentActivity
|
|
37
|
+
if (activity != null) {
|
|
38
|
+
return activity
|
|
39
|
+
} else {
|
|
40
|
+
Log.w("CredentialManager", "No current activity found. UI operations may fail - ensure you're calling from the main/UI thread.")
|
|
41
|
+
}
|
|
42
|
+
} else {
|
|
43
|
+
Log.w("CredentialManager", "Context is not ReactApplicationContext. UI operations may fail.")
|
|
44
|
+
}
|
|
45
|
+
// If we can't get an activity context, use the original context
|
|
46
|
+
// This might still cause issues for UI operations, but it's better than null
|
|
47
|
+
return context
|
|
48
|
+
}
|
|
49
|
+
|
|
31
50
|
suspend fun signOut() {
|
|
32
51
|
credentialManager.clearCredentialState(ClearCredentialStateRequest())
|
|
33
52
|
}
|
|
@@ -45,9 +64,10 @@ class CredentialHandler(
|
|
|
45
64
|
preferImmediatelyAvailableCredentials = preferImmediatelyAvailableCredentials,
|
|
46
65
|
)
|
|
47
66
|
|
|
67
|
+
val activityContext = getActivityContext()
|
|
48
68
|
val response =
|
|
49
69
|
credentialManager.createCredential(
|
|
50
|
-
|
|
70
|
+
activityContext,
|
|
51
71
|
request,
|
|
52
72
|
) as CreatePublicKeyCredentialResponse
|
|
53
73
|
|
|
@@ -73,8 +93,9 @@ class CredentialHandler(
|
|
|
73
93
|
Log.d("CredentialManager", "Creating password credential for username: $username")
|
|
74
94
|
|
|
75
95
|
try {
|
|
96
|
+
val activityContext = getActivityContext()
|
|
76
97
|
val createPasswordRequest = CreatePasswordRequest(id = username, password = password)
|
|
77
|
-
credentialManager.createCredential(
|
|
98
|
+
credentialManager.createCredential(activityContext, createPasswordRequest)
|
|
78
99
|
} catch (e: Exception) {
|
|
79
100
|
Log.e("CredentialManager", "Error creating password credential", e)
|
|
80
101
|
throw e
|
|
@@ -120,17 +141,19 @@ class CredentialHandler(
|
|
|
120
141
|
}
|
|
121
142
|
|
|
122
143
|
val request = GetCredentialRequest(credentialOptions)
|
|
123
|
-
val
|
|
144
|
+
val activityContext = getActivityContext()
|
|
145
|
+
val result = credentialManager.getCredential(activityContext, request)
|
|
124
146
|
return handleSignInResult(result)
|
|
125
147
|
}
|
|
126
148
|
|
|
127
149
|
suspend fun getSavedCredentials(jsonString: String): ReadableMap? {
|
|
128
150
|
val getPublicKeyCredentialOption = GetPublicKeyCredentialOption(jsonString, null)
|
|
129
151
|
val getPasswordOption = GetPasswordOption()
|
|
152
|
+
val activityContext = getActivityContext()
|
|
130
153
|
|
|
131
154
|
val result =
|
|
132
155
|
credentialManager.getCredential(
|
|
133
|
-
|
|
156
|
+
activityContext,
|
|
134
157
|
GetCredentialRequest(
|
|
135
158
|
listOf(
|
|
136
159
|
getPublicKeyCredentialOption,
|
|
@@ -206,7 +229,7 @@ class CredentialHandler(
|
|
|
206
229
|
serverClientId: String,
|
|
207
230
|
autoSelectEnabled: Boolean,
|
|
208
231
|
): GetGoogleIdOption {
|
|
209
|
-
Log.d("CredentialManager", "getGoogleId - setFilterByAuthorizedAccounts: $setFilterByAuthorizedAccounts")
|
|
232
|
+
Log.d("CredentialManager", "getGoogleId - setFilterByAuthorizedAccounts: $setFilterByAuthorizedAccounts autoSelectEnabled: $autoSelectEnabled")
|
|
210
233
|
|
|
211
234
|
return GetGoogleIdOption
|
|
212
235
|
.Builder()
|
|
@@ -224,10 +247,11 @@ class CredentialHandler(
|
|
|
224
247
|
.addCredentialOption(googleIdOption)
|
|
225
248
|
.build()
|
|
226
249
|
|
|
250
|
+
val activityContext = getActivityContext()
|
|
227
251
|
val result =
|
|
228
252
|
credentialManager.getCredential(
|
|
229
253
|
request = request,
|
|
230
|
-
context =
|
|
254
|
+
context = activityContext,
|
|
231
255
|
)
|
|
232
256
|
|
|
233
257
|
return result
|
|
@@ -131,6 +131,8 @@ class CredentialsManagerModule(
|
|
|
131
131
|
val data = credentialHandler.handleSignInResult(result)
|
|
132
132
|
promise.resolve(data)
|
|
133
133
|
} catch (e: GetCredentialException) {
|
|
134
|
+
Log.d("CredentialManager", "First sign in attempt failed", e)
|
|
135
|
+
|
|
134
136
|
when (e) {
|
|
135
137
|
is NoCredentialException -> {
|
|
136
138
|
try {
|
package/lib/commonjs/index.js
CHANGED
|
@@ -20,8 +20,6 @@ function signUpWithPassword({
|
|
|
20
20
|
password
|
|
21
21
|
}) {
|
|
22
22
|
if (_reactNative.Platform.OS === 'ios') {
|
|
23
|
-
// iOS only supports AutoFill passwords through Apple's Authentication Services
|
|
24
|
-
// Manual password storage is not supported
|
|
25
23
|
return Promise.reject(new Error('Manual password storage is not supported on iOS. Use AutoFill passwords through signIn method instead.'));
|
|
26
24
|
}
|
|
27
25
|
return _NativeCredentialsManager.default.signUpWithPassword({
|
|
@@ -30,42 +28,29 @@ function signUpWithPassword({
|
|
|
30
28
|
});
|
|
31
29
|
}
|
|
32
30
|
function signIn(options, params) {
|
|
33
|
-
// Transform options for iOS compatibility
|
|
34
|
-
const processedOptions = options.map(option => {
|
|
35
|
-
if (option === 'google-signin' && _reactNative.Platform.OS === 'ios') {
|
|
36
|
-
// Automatically replace google-signin with apple-signin on iOS
|
|
37
|
-
return 'apple-signin';
|
|
38
|
-
}
|
|
39
|
-
return option;
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
// Prepare parameters for both platforms
|
|
43
31
|
const signInParams = {
|
|
44
|
-
|
|
45
|
-
googleSignIn: {
|
|
46
|
-
serverClientId: params?.googleSignIn?.serverClientId ?? '',
|
|
47
|
-
nonce: params?.googleSignIn?.nonce ?? '',
|
|
48
|
-
autoSelectEnabled: params?.googleSignIn?.autoSelectEnabled ?? true
|
|
49
|
-
}
|
|
32
|
+
passkeys: params.passkeys
|
|
50
33
|
};
|
|
34
|
+
if (options.includes('google-signin')) {
|
|
35
|
+
signInParams.googleSignIn = {
|
|
36
|
+
serverClientId: params.googleSignIn?.serverClientId ?? '',
|
|
37
|
+
nonce: params.googleSignIn?.nonce ?? '',
|
|
38
|
+
autoSelectEnabled: params.googleSignIn?.autoSelectEnabled ?? true
|
|
39
|
+
};
|
|
40
|
+
}
|
|
51
41
|
|
|
52
42
|
// If we have Apple Sign In option on iOS, add Apple params
|
|
53
|
-
if (_reactNative.Platform.OS === 'ios' &&
|
|
43
|
+
if (_reactNative.Platform.OS === 'ios' && options.includes('apple-signin')) {
|
|
54
44
|
signInParams.appleSignIn = {
|
|
55
|
-
nonce: params
|
|
56
|
-
requestedScopes: params
|
|
45
|
+
nonce: params.appleSignIn?.nonce ?? '',
|
|
46
|
+
requestedScopes: params.appleSignIn?.requestedScopes ?? ['fullName', 'email']
|
|
57
47
|
};
|
|
58
48
|
}
|
|
59
|
-
return _NativeCredentialsManager.default.signIn(
|
|
49
|
+
return _NativeCredentialsManager.default.signIn([...options], signInParams);
|
|
60
50
|
}
|
|
61
51
|
function signUpWithGoogle(params) {
|
|
62
52
|
if (_reactNative.Platform.OS === 'ios') {
|
|
63
|
-
|
|
64
|
-
// This provides seamless cross-platform compatibility
|
|
65
|
-
return signUpWithApple({
|
|
66
|
-
nonce: params.nonce,
|
|
67
|
-
requestedScopes: ['fullName', 'email']
|
|
68
|
-
});
|
|
53
|
+
return Promise.reject(new Error('Google Sign In is only available on Android. Use signUpWithApple on iOS.'));
|
|
69
54
|
}
|
|
70
55
|
return _NativeCredentialsManager.default.signUpWithGoogle({
|
|
71
56
|
...params,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_NativeCredentialsManager","_interopRequireDefault","require","_reactNative","e","__esModule","default","signUpWithPasskeys","requestJson","preferImmediatelyAvailableCredentials","CredentialsManager","signUpWithPassword","username","password","Platform","OS","Promise","reject","Error","signIn","options","params","
|
|
1
|
+
{"version":3,"names":["_NativeCredentialsManager","_interopRequireDefault","require","_reactNative","e","__esModule","default","signUpWithPasskeys","requestJson","preferImmediatelyAvailableCredentials","CredentialsManager","signUpWithPassword","username","password","Platform","OS","Promise","reject","Error","signIn","options","params","signInParams","passkeys","includes","googleSignIn","serverClientId","nonce","autoSelectEnabled","appleSignIn","requestedScopes","signUpWithGoogle","signUpWithApple","signOut"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;;;;;;;;;;AAAA,IAAAA,yBAAA,GAAAC,sBAAA,CAAAC,OAAA;AASA,IAAAC,YAAA,GAAAD,OAAA;AAAwC,SAAAD,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAsBjC,SAASG,kBAAkBA,CAChCC,WAAmB,EACnBC,qCAA8C,GAAG,KAAK,EACrC;EACjB,OAAOC,iCAAkB,CAACH,kBAAkB,CAC1CC,WAAW,EACXC,qCACF,CAAC;AACH;AAEO,SAASE,kBAAkBA,CAAC;EACjCC,QAAQ;EACRC;AAIF,CAAC,EAAmB;EAClB,IAAIC,qBAAQ,CAACC,EAAE,KAAK,KAAK,EAAE;IACzB,OAAOC,OAAO,CAACC,MAAM,CACnB,IAAIC,KAAK,CACP,wGACF,CACF,CAAC;EACH;EACA,OAAOR,iCAAkB,CAACC,kBAAkB,CAAC;IAAEE,QAAQ;IAAED;EAAS,CAAC,CAAC;AACtE;AAEO,SAASO,MAAMA,CACpBC,OAAU,EACVC,MAIC,EACyB;EAC1B,MAAMC,YAWL,GAAG;IACFC,QAAQ,EAAEF,MAAM,CAACE;EACnB,CAAC;EAED,IAAIH,OAAO,CAACI,QAAQ,CAAC,eAAe,CAAC,EAAE;IACrCF,YAAY,CAACG,YAAY,GAAG;MAC1BC,cAAc,EAAEL,MAAM,CAACI,YAAY,EAAEC,cAAc,IAAI,EAAE;MACzDC,KAAK,EAAEN,MAAM,CAACI,YAAY,EAAEE,KAAK,IAAI,EAAE;MACvCC,iBAAiB,EAAEP,MAAM,CAACI,YAAY,EAAEG,iBAAiB,IAAI;IAC/D,CAAC;EACH;;EAEA;EACA,IAAId,qBAAQ,CAACC,EAAE,KAAK,KAAK,IAAIK,OAAO,CAACI,QAAQ,CAAC,cAAc,CAAC,EAAE;IAC7DF,YAAY,CAACO,WAAW,GAAG;MACzBF,KAAK,EAAEN,MAAM,CAACQ,WAAW,EAAEF,KAAK,IAAI,EAAE;MACtCG,eAAe,EAAET,MAAM,CAACQ,WAAW,EAAEC,eAAe,IAAI,CACtD,UAAU,EACV,OAAO;IAEX,CAAC;EACH;EAEA,OAAOpB,iCAAkB,CAACS,MAAM,CAAC,CAAC,GAAGC,OAAO,CAAC,EAAEE,YAAY,CAAC;AAG9D;AAEO,SAASS,gBAAgBA,CAC9BV,MAA0B,EACC;EAC3B,IAAIP,qBAAQ,CAACC,EAAE,KAAK,KAAK,EAAE;IACzB,OAAOC,OAAO,CAACC,MAAM,CACnB,IAAIC,KAAK,CACP,0EACF,CACF,CAAC;EACH;EAEA,OAAOR,iCAAkB,CAACqB,gBAAgB,CAAC;IACzC,GAAGV,MAAM;IACTM,KAAK,EAAEN,MAAM,CAACM,KAAK,IAAI,EAAE;IACzBC,iBAAiB,EAAEP,MAAM,CAACO,iBAAiB,IAAI;EACjD,CAAC,CAAC;AACJ;AAEO,SAASI,eAAeA,CAC7BX,MAAyB,GAAG,CAAC,CAAC,EACJ;EAC1B,IAAIP,qBAAQ,CAACC,EAAE,KAAK,KAAK,EAAE;IACzB,OAAOC,OAAO,CAACC,MAAM,CACnB,IAAIC,KAAK,CACP,0EACF,CACF,CAAC;EACH;;EAEA;EACA,OAAOR,iCAAkB,CAACsB,eAAe,CAAC;IACxCL,KAAK,EAAEN,MAAM,CAACM,KAAK,IAAI,EAAE;IACzBG,eAAe,EAAET,MAAM,CAACS,eAAe,IAAI,CAAC,UAAU,EAAE,OAAO;EACjE,CAAC,CAAC;AACJ;AAEO,SAASG,OAAOA,CAAA,EAAkB;EACvC,OAAOvB,iCAAkB,CAACuB,OAAO,CAAC,CAAC;AACrC;;AAEA","ignoreList":[]}
|
package/lib/module/index.js
CHANGED
|
@@ -10,8 +10,6 @@ export function signUpWithPassword({
|
|
|
10
10
|
password
|
|
11
11
|
}) {
|
|
12
12
|
if (Platform.OS === 'ios') {
|
|
13
|
-
// iOS only supports AutoFill passwords through Apple's Authentication Services
|
|
14
|
-
// Manual password storage is not supported
|
|
15
13
|
return Promise.reject(new Error('Manual password storage is not supported on iOS. Use AutoFill passwords through signIn method instead.'));
|
|
16
14
|
}
|
|
17
15
|
return CredentialsManager.signUpWithPassword({
|
|
@@ -20,42 +18,29 @@ export function signUpWithPassword({
|
|
|
20
18
|
});
|
|
21
19
|
}
|
|
22
20
|
export function signIn(options, params) {
|
|
23
|
-
// Transform options for iOS compatibility
|
|
24
|
-
const processedOptions = options.map(option => {
|
|
25
|
-
if (option === 'google-signin' && Platform.OS === 'ios') {
|
|
26
|
-
// Automatically replace google-signin with apple-signin on iOS
|
|
27
|
-
return 'apple-signin';
|
|
28
|
-
}
|
|
29
|
-
return option;
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
// Prepare parameters for both platforms
|
|
33
21
|
const signInParams = {
|
|
34
|
-
|
|
35
|
-
googleSignIn: {
|
|
36
|
-
serverClientId: params?.googleSignIn?.serverClientId ?? '',
|
|
37
|
-
nonce: params?.googleSignIn?.nonce ?? '',
|
|
38
|
-
autoSelectEnabled: params?.googleSignIn?.autoSelectEnabled ?? true
|
|
39
|
-
}
|
|
22
|
+
passkeys: params.passkeys
|
|
40
23
|
};
|
|
24
|
+
if (options.includes('google-signin')) {
|
|
25
|
+
signInParams.googleSignIn = {
|
|
26
|
+
serverClientId: params.googleSignIn?.serverClientId ?? '',
|
|
27
|
+
nonce: params.googleSignIn?.nonce ?? '',
|
|
28
|
+
autoSelectEnabled: params.googleSignIn?.autoSelectEnabled ?? true
|
|
29
|
+
};
|
|
30
|
+
}
|
|
41
31
|
|
|
42
32
|
// If we have Apple Sign In option on iOS, add Apple params
|
|
43
|
-
if (Platform.OS === 'ios' &&
|
|
33
|
+
if (Platform.OS === 'ios' && options.includes('apple-signin')) {
|
|
44
34
|
signInParams.appleSignIn = {
|
|
45
|
-
nonce: params
|
|
46
|
-
requestedScopes: params
|
|
35
|
+
nonce: params.appleSignIn?.nonce ?? '',
|
|
36
|
+
requestedScopes: params.appleSignIn?.requestedScopes ?? ['fullName', 'email']
|
|
47
37
|
};
|
|
48
38
|
}
|
|
49
|
-
return CredentialsManager.signIn(
|
|
39
|
+
return CredentialsManager.signIn([...options], signInParams);
|
|
50
40
|
}
|
|
51
41
|
export function signUpWithGoogle(params) {
|
|
52
42
|
if (Platform.OS === 'ios') {
|
|
53
|
-
|
|
54
|
-
// This provides seamless cross-platform compatibility
|
|
55
|
-
return signUpWithApple({
|
|
56
|
-
nonce: params.nonce,
|
|
57
|
-
requestedScopes: ['fullName', 'email']
|
|
58
|
-
});
|
|
43
|
+
return Promise.reject(new Error('Google Sign In is only available on Android. Use signUpWithApple on iOS.'));
|
|
59
44
|
}
|
|
60
45
|
return CredentialsManager.signUpWithGoogle({
|
|
61
46
|
...params,
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["CredentialsManager","Platform","signUpWithPasskeys","requestJson","preferImmediatelyAvailableCredentials","signUpWithPassword","username","password","OS","Promise","reject","Error","signIn","options","params","
|
|
1
|
+
{"version":3,"names":["CredentialsManager","Platform","signUpWithPasskeys","requestJson","preferImmediatelyAvailableCredentials","signUpWithPassword","username","password","OS","Promise","reject","Error","signIn","options","params","signInParams","passkeys","includes","googleSignIn","serverClientId","nonce","autoSelectEnabled","appleSignIn","requestedScopes","signUpWithGoogle","signUpWithApple","signOut"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;AAAA,OAAOA,kBAAkB,MAAM,+BAA4B;AAS3D,SAASC,QAAQ,QAAQ,cAAc;AAsBvC,OAAO,SAASC,kBAAkBA,CAChCC,WAAmB,EACnBC,qCAA8C,GAAG,KAAK,EACrC;EACjB,OAAOJ,kBAAkB,CAACE,kBAAkB,CAC1CC,WAAW,EACXC,qCACF,CAAC;AACH;AAEA,OAAO,SAASC,kBAAkBA,CAAC;EACjCC,QAAQ;EACRC;AAIF,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AAkB,CAACwB,gBAAgB,CAAC;IACzC,GAAGV,MAAM;IACTM,KAAK,EAAEN,MAAM,CAACM,KAAK,IAAI,EAAE;IACzBC,iBAAiB,EAAEP,MAAM,CAACO,iBAAiB,IAAI;EACjD,CAAC,CAAC;AACJ;AAEA,OAAO,SAASI,eAAeA,CAC7BX,MAAyB,GAAG,CAAC,CAAC,EACJ;EAC1B,IAAIb,QAAQ,CAACO,EAAE,KAAK,KAAK,EAAE;IACzB,OAAOC,OAAO,CAACC,MAAM,CACnB,IAAIC,KAAK,CACP,0EACF,CACF,CAAC;EACH;;EAEA;EACA,OAAOX,kBAAkB,CAACyB,eAAe,CAAC;IACxCL,KAAK,EAAEN,MAAM,CAACM,KAAK,IAAI,EAAE;IACzBG,eAAe,EAAET,MAAM,CAACS,eAAe,IAAI,CAAC,UAAU,EAAE,OAAO;EACjE,CAAC,CAAC;AACJ;AAEA,OAAO,SAASG,OAAOA,CAAA,EAAkB;EACvC,OAAO1B,kBAAkB,CAAC0B,OAAO,CAAC,CAAC;AACrC;;AAEA","ignoreList":[]}
|
|
@@ -4,12 +4,12 @@ type CredObject = {
|
|
|
4
4
|
username: string;
|
|
5
5
|
password: string;
|
|
6
6
|
};
|
|
7
|
-
type PasswordCredential = {
|
|
7
|
+
export type PasswordCredential = {
|
|
8
8
|
type: 'password';
|
|
9
9
|
username: string;
|
|
10
10
|
password: string;
|
|
11
11
|
};
|
|
12
|
-
type PasskeyCredential = {
|
|
12
|
+
export type PasskeyCredential = {
|
|
13
13
|
type: 'passkey';
|
|
14
14
|
authenticationResponseJson: string;
|
|
15
15
|
};
|
|
@@ -57,7 +57,7 @@ export interface Spec extends TurboModule {
|
|
|
57
57
|
/**
|
|
58
58
|
* Sign in with various methods
|
|
59
59
|
* - 'passkeys': Supported on both platforms
|
|
60
|
-
* - 'password': Supported on
|
|
60
|
+
* - 'password': Supported on android
|
|
61
61
|
* - 'google-signin': Android only
|
|
62
62
|
* - 'apple-signin': iOS only (not available on Android)
|
|
63
63
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NativeCredentialsManager.d.ts","sourceRoot":"","sources":["../../../../src/NativeCredentialsManager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAGhD,MAAM,MAAM,YAAY,GACpB,UAAU,GACV,UAAU,GACV,eAAe,GACf,cAAc,CAAC;AAGnB,KAAK,UAAU,GAAG;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,
|
|
1
|
+
{"version":3,"file":"NativeCredentialsManager.d.ts","sourceRoot":"","sources":["../../../../src/NativeCredentialsManager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAGhD,MAAM,MAAM,YAAY,GACpB,UAAU,GACV,UAAU,GACV,eAAe,GACf,cAAc,CAAC;AAGnB,KAAK,UAAU,GAAG;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,IAAI,EAAE,UAAU,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAGF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,IAAI,EAAE,SAAS,CAAC;IAChB,0BAA0B,EAAE,MAAM,CAAC;CACpC,CAAC;AAGF,KAAK,kBAAkB,GAAG;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,cAAc,EAAE,MAAM,CAAC;IACvB,iBAAiB,EAAE,OAAO,CAAC;CAC5B,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,IAAI,EAAE,eAAe,CAAC;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC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AAE,iBAAiB,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;IAErE;;;OAGG;IACH,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1B;;AAED,wBAA4E"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Credential, GoogleCredential, AppleCredential, SignInOption } from './NativeCredentialsManager';
|
|
1
|
+
import type { Credential, GoogleCredential, AppleCredential, SignInOption, PasskeyCredential, PasswordCredential } from './NativeCredentialsManager';
|
|
2
2
|
type GoogleSignInParams = {
|
|
3
3
|
nonce?: string;
|
|
4
4
|
serverClientId: string;
|
|
@@ -8,18 +8,25 @@ type AppleSignInParams = {
|
|
|
8
8
|
nonce?: string;
|
|
9
9
|
requestedScopes?: ('fullName' | 'email')[];
|
|
10
10
|
};
|
|
11
|
+
type CredentialMap = {
|
|
12
|
+
'passkeys': PasskeyCredential;
|
|
13
|
+
'password': PasswordCredential;
|
|
14
|
+
'google-signin': GoogleCredential;
|
|
15
|
+
'apple-signin': AppleCredential;
|
|
16
|
+
};
|
|
17
|
+
type SignInResult<T extends readonly SignInOption[]> = CredentialMap[T[number]];
|
|
11
18
|
export declare function signUpWithPasskeys(requestJson: Object, preferImmediatelyAvailableCredentials?: boolean): Promise<Object>;
|
|
12
19
|
export declare function signUpWithPassword({ username, password, }: {
|
|
13
20
|
username: string;
|
|
14
21
|
password: string;
|
|
15
22
|
}): Promise<Object>;
|
|
16
|
-
export declare function signIn(options:
|
|
23
|
+
export declare function signIn<T extends readonly SignInOption[]>(options: T, params: {
|
|
17
24
|
passkeys?: Object;
|
|
18
25
|
googleSignIn?: GoogleSignInParams;
|
|
19
26
|
appleSignIn?: AppleSignInParams;
|
|
20
|
-
}): Promise<
|
|
21
|
-
export declare function signUpWithGoogle(params: GoogleSignInParams): Promise<GoogleCredential
|
|
27
|
+
}): Promise<SignInResult<T>>;
|
|
28
|
+
export declare function signUpWithGoogle(params: GoogleSignInParams): Promise<GoogleCredential>;
|
|
22
29
|
export declare function signUpWithApple(params?: AppleSignInParams): Promise<AppleCredential>;
|
|
23
30
|
export declare function signOut(): Promise<null>;
|
|
24
|
-
export type { Credential, GoogleCredential, AppleCredential, SignInOption, GoogleSignInParams, AppleSignInParams, };
|
|
31
|
+
export type { Credential, GoogleCredential, AppleCredential, SignInOption, GoogleSignInParams, AppleSignInParams, PasskeyCredential, PasswordCredential, };
|
|
25
32
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,UAAU,EACV,gBAAgB,EAChB,eAAe,EACf,YAAY,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,UAAU,EACV,gBAAgB,EAChB,eAAe,EACf,YAAY,EACZ,iBAAiB,EACjB,kBAAkB,EACnB,MAAM,4BAA4B,CAAC;AAGpC,KAAK,kBAAkB,GAAG;IACxB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,cAAc,EAAE,MAAM,CAAC;IACvB,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B,CAAC;AAEF,KAAK,iBAAiB,GAAG;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,eAAe,CAAC,EAAE,CAAC,UAAU,GAAG,OAAO,CAAC,EAAE,CAAC;CAC5C,CAAC;AAEF,KAAK,aAAa,GAAG;IACnB,UAAU,EAAE,iBAAiB,CAAC;IAC9B,UAAU,EAAE,kBAAkB,CAAC;IAC/B,eAAe,EAAE,gBAAgB,CAAC;IAClC,cAAc,EAAE,eAAe,CAAC;CACjC,CAAC;AAEF,KAAK,YAAY,CAAC,CAAC,SAAS,SAAS,YAAY,EAAE,IAAI,aAAa,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;AAEhF,wBAAgB,kBAAkB,CAChC,WAAW,EAAE,MAAM,EACnB,qCAAqC,GAAE,OAAe,GACrD,OAAO,CAAC,MAAM,CAAC,CAKjB;AAED,wBAAgB,kBAAkB,CAAC,EACjC,QAAQ,EACR,QAAQ,GACT,EAAE;IACD,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;CAClB,GAAG,OAAO,CAAC,MAAM,CAAC,CASlB;AAED,wBAAgB,MAAM,CAAC,CAAC,SAAS,SAAS,YAAY,EAAE,EACtD,OAAO,EAAE,CAAC,EACV,MAAM,EAAE;IACN,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,kBAAkB,CAAC;IAClC,WAAW,CAAC,EAAE,iBAAiB,CAAC;CACjC,GACA,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAsC1B;AAED,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,kBAAkB,GACzB,OAAO,CAAC,gBAAgB,CAAC,CAc3B;AAED,wBAAgB,eAAe,CAC7B,MAAM,GAAE,iBAAsB,GAC7B,OAAO,CAAC,eAAe,CAAC,CAc1B;AAED,wBAAgB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAEvC;AAGD,YAAY,EACV,UAAU,EACV,gBAAgB,EAChB,eAAe,EACf,YAAY,EACZ,kBAAkB,EAClB,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,GACnB,CAAC"}
|
|
@@ -4,12 +4,12 @@ type CredObject = {
|
|
|
4
4
|
username: string;
|
|
5
5
|
password: string;
|
|
6
6
|
};
|
|
7
|
-
type PasswordCredential = {
|
|
7
|
+
export type PasswordCredential = {
|
|
8
8
|
type: 'password';
|
|
9
9
|
username: string;
|
|
10
10
|
password: string;
|
|
11
11
|
};
|
|
12
|
-
type PasskeyCredential = {
|
|
12
|
+
export type PasskeyCredential = {
|
|
13
13
|
type: 'passkey';
|
|
14
14
|
authenticationResponseJson: string;
|
|
15
15
|
};
|
|
@@ -57,7 +57,7 @@ export interface Spec extends TurboModule {
|
|
|
57
57
|
/**
|
|
58
58
|
* Sign in with various methods
|
|
59
59
|
* - 'passkeys': Supported on both platforms
|
|
60
|
-
* - 'password': Supported on
|
|
60
|
+
* - 'password': Supported on android
|
|
61
61
|
* - 'google-signin': Android only
|
|
62
62
|
* - 'apple-signin': iOS only (not available on Android)
|
|
63
63
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NativeCredentialsManager.d.ts","sourceRoot":"","sources":["../../../../src/NativeCredentialsManager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAGhD,MAAM,MAAM,YAAY,GACpB,UAAU,GACV,UAAU,GACV,eAAe,GACf,cAAc,CAAC;AAGnB,KAAK,UAAU,GAAG;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,
|
|
1
|
+
{"version":3,"file":"NativeCredentialsManager.d.ts","sourceRoot":"","sources":["../../../../src/NativeCredentialsManager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAGhD,MAAM,MAAM,YAAY,GACpB,UAAU,GACV,UAAU,GACV,eAAe,GACf,cAAc,CAAC;AAGnB,KAAK,UAAU,GAAG;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,IAAI,EAAE,UAAU,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAGF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,IAAI,EAAE,SAAS,CAAC;IAChB,0BAA0B,EAAE,MAAM,CAAC;CACpC,CAAC;AAGF,KAAK,kBAAkB,GAAG;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,cAAc,EAAE,MAAM,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AClC,WAAW,CAAC,EAAE,iBAAiB,CAAC;KACjC,GACA,OAAO,CAAC,UAAU,CAAC,CAAC;IAEvB;;OAEG;IACH,gBAAgB,CAAC,MAAM,EAAE,kBAAkB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;IAExE;;;OAGG;IACH,eAAe,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;IAErE;;;OAGG;IACH,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1B;;AAED,wBAA4E"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Credential, GoogleCredential, AppleCredential, SignInOption } from './NativeCredentialsManager';
|
|
1
|
+
import type { Credential, GoogleCredential, AppleCredential, SignInOption, PasskeyCredential, PasswordCredential } from './NativeCredentialsManager';
|
|
2
2
|
type GoogleSignInParams = {
|
|
3
3
|
nonce?: string;
|
|
4
4
|
serverClientId: string;
|
|
@@ -8,18 +8,25 @@ type AppleSignInParams = {
|
|
|
8
8
|
nonce?: string;
|
|
9
9
|
requestedScopes?: ('fullName' | 'email')[];
|
|
10
10
|
};
|
|
11
|
+
type CredentialMap = {
|
|
12
|
+
'passkeys': PasskeyCredential;
|
|
13
|
+
'password': PasswordCredential;
|
|
14
|
+
'google-signin': GoogleCredential;
|
|
15
|
+
'apple-signin': AppleCredential;
|
|
16
|
+
};
|
|
17
|
+
type SignInResult<T extends readonly SignInOption[]> = CredentialMap[T[number]];
|
|
11
18
|
export declare function signUpWithPasskeys(requestJson: Object, preferImmediatelyAvailableCredentials?: boolean): Promise<Object>;
|
|
12
19
|
export declare function signUpWithPassword({ username, password, }: {
|
|
13
20
|
username: string;
|
|
14
21
|
password: string;
|
|
15
22
|
}): Promise<Object>;
|
|
16
|
-
export declare function signIn(options:
|
|
23
|
+
export declare function signIn<T extends readonly SignInOption[]>(options: T, params: {
|
|
17
24
|
passkeys?: Object;
|
|
18
25
|
googleSignIn?: GoogleSignInParams;
|
|
19
26
|
appleSignIn?: AppleSignInParams;
|
|
20
|
-
}): Promise<
|
|
21
|
-
export declare function signUpWithGoogle(params: GoogleSignInParams): Promise<GoogleCredential
|
|
27
|
+
}): Promise<SignInResult<T>>;
|
|
28
|
+
export declare function signUpWithGoogle(params: GoogleSignInParams): Promise<GoogleCredential>;
|
|
22
29
|
export declare function signUpWithApple(params?: AppleSignInParams): Promise<AppleCredential>;
|
|
23
30
|
export declare function signOut(): Promise<null>;
|
|
24
|
-
export type { Credential, GoogleCredential, AppleCredential, SignInOption, GoogleSignInParams, AppleSignInParams, };
|
|
31
|
+
export type { Credential, GoogleCredential, AppleCredential, SignInOption, GoogleSignInParams, AppleSignInParams, PasskeyCredential, PasswordCredential, };
|
|
25
32
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,UAAU,EACV,gBAAgB,EAChB,eAAe,EACf,YAAY,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,UAAU,EACV,gBAAgB,EAChB,eAAe,EACf,YAAY,EACZ,iBAAiB,EACjB,kBAAkB,EACnB,MAAM,4BAA4B,CAAC;AAGpC,KAAK,kBAAkB,GAAG;IACxB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,cAAc,EAAE,MAAM,CAAC;IACvB,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B,CAAC;AAEF,KAAK,iBAAiB,GAAG;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,eAAe,CAAC,EAAE,CAAC,UAAU,GAAG,OAAO,CAAC,EAAE,CAAC;CAC5C,CAAC;AAEF,KAAK,aAAa,GAAG;IACnB,UAAU,EAAE,iBAAiB,CAAC;IAC9B,UAAU,EAAE,kBAAkB,CAAC;IAC/B,eAAe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description": "A React Native library that implements the Credential Manager API for Android. This library allows you to manage passwords and passkeys in your React Native applications.",
|
|
5
5
|
"source": "./src/index.tsx",
|
|
6
6
|
"main": "./lib/commonjs/index.js",
|
|
@@ -13,14 +13,14 @@ type CredObject = {
|
|
|
13
13
|
password: string;
|
|
14
14
|
};
|
|
15
15
|
|
|
16
|
-
type PasswordCredential = {
|
|
16
|
+
export type PasswordCredential = {
|
|
17
17
|
type: 'password';
|
|
18
18
|
username: string;
|
|
19
19
|
password: string;
|
|
20
20
|
};
|
|
21
21
|
|
|
22
22
|
// Passkey authentication types
|
|
23
|
-
type PasskeyCredential = {
|
|
23
|
+
export type PasskeyCredential = {
|
|
24
24
|
type: 'passkey';
|
|
25
25
|
authenticationResponseJson: string;
|
|
26
26
|
};
|
|
@@ -87,7 +87,7 @@ export interface Spec extends TurboModule {
|
|
|
87
87
|
/**
|
|
88
88
|
* Sign in with various methods
|
|
89
89
|
* - 'passkeys': Supported on both platforms
|
|
90
|
-
* - 'password': Supported on
|
|
90
|
+
* - 'password': Supported on android
|
|
91
91
|
* - 'google-signin': Android only
|
|
92
92
|
* - 'apple-signin': iOS only (not available on Android)
|
|
93
93
|
*/
|
package/src/index.tsx
CHANGED
|
@@ -4,6 +4,8 @@ import type {
|
|
|
4
4
|
GoogleCredential,
|
|
5
5
|
AppleCredential,
|
|
6
6
|
SignInOption,
|
|
7
|
+
PasskeyCredential,
|
|
8
|
+
PasswordCredential,
|
|
7
9
|
} from './NativeCredentialsManager';
|
|
8
10
|
import { Platform } from 'react-native';
|
|
9
11
|
|
|
@@ -18,6 +20,15 @@ type AppleSignInParams = {
|
|
|
18
20
|
requestedScopes?: ('fullName' | 'email')[];
|
|
19
21
|
};
|
|
20
22
|
|
|
23
|
+
type CredentialMap = {
|
|
24
|
+
'passkeys': PasskeyCredential;
|
|
25
|
+
'password': PasswordCredential;
|
|
26
|
+
'google-signin': GoogleCredential;
|
|
27
|
+
'apple-signin': AppleCredential;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
type SignInResult<T extends readonly SignInOption[]> = CredentialMap[T[number]];
|
|
31
|
+
|
|
21
32
|
export function signUpWithPasskeys(
|
|
22
33
|
requestJson: Object,
|
|
23
34
|
preferImmediatelyAvailableCredentials: boolean = false
|
|
@@ -36,8 +47,6 @@ export function signUpWithPassword({
|
|
|
36
47
|
password: string;
|
|
37
48
|
}): Promise<Object> {
|
|
38
49
|
if (Platform.OS === 'ios') {
|
|
39
|
-
// iOS only supports AutoFill passwords through Apple's Authentication Services
|
|
40
|
-
// Manual password storage is not supported
|
|
41
50
|
return Promise.reject(
|
|
42
51
|
new Error(
|
|
43
52
|
'Manual password storage is not supported on iOS. Use AutoFill passwords through signIn method instead.'
|
|
@@ -47,57 +56,62 @@ export function signUpWithPassword({
|
|
|
47
56
|
return CredentialsManager.signUpWithPassword({ password, username });
|
|
48
57
|
}
|
|
49
58
|
|
|
50
|
-
export function signIn(
|
|
51
|
-
options:
|
|
59
|
+
export function signIn<T extends readonly SignInOption[]>(
|
|
60
|
+
options: T,
|
|
52
61
|
params: {
|
|
53
62
|
passkeys?: Object;
|
|
54
63
|
googleSignIn?: GoogleSignInParams;
|
|
55
64
|
appleSignIn?: AppleSignInParams;
|
|
56
65
|
}
|
|
57
|
-
): Promise<
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
serverClientId: params?.googleSignIn?.serverClientId ?? '',
|
|
72
|
-
nonce: params?.googleSignIn?.nonce ?? '',
|
|
73
|
-
autoSelectEnabled: params?.googleSignIn?.autoSelectEnabled ?? true,
|
|
74
|
-
},
|
|
66
|
+
): Promise<SignInResult<T>> {
|
|
67
|
+
const signInParams: {
|
|
68
|
+
passkeys?: Object;
|
|
69
|
+
googleSignIn?: {
|
|
70
|
+
serverClientId: string;
|
|
71
|
+
nonce: string;
|
|
72
|
+
autoSelectEnabled: boolean;
|
|
73
|
+
};
|
|
74
|
+
appleSignIn?: {
|
|
75
|
+
nonce: string;
|
|
76
|
+
requestedScopes: ('fullName' | 'email')[];
|
|
77
|
+
};
|
|
78
|
+
} = {
|
|
79
|
+
passkeys: params.passkeys,
|
|
75
80
|
};
|
|
76
81
|
|
|
82
|
+
if (options.includes('google-signin')) {
|
|
83
|
+
signInParams.googleSignIn = {
|
|
84
|
+
serverClientId: params.googleSignIn?.serverClientId ?? '',
|
|
85
|
+
nonce: params.googleSignIn?.nonce ?? '',
|
|
86
|
+
autoSelectEnabled: params.googleSignIn?.autoSelectEnabled ?? true,
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
|
|
77
90
|
// If we have Apple Sign In option on iOS, add Apple params
|
|
78
|
-
if (Platform.OS === 'ios' &&
|
|
91
|
+
if (Platform.OS === 'ios' && options.includes('apple-signin')) {
|
|
79
92
|
signInParams.appleSignIn = {
|
|
80
|
-
nonce: params
|
|
81
|
-
requestedScopes: params
|
|
93
|
+
nonce: params.appleSignIn?.nonce ?? '',
|
|
94
|
+
requestedScopes: params.appleSignIn?.requestedScopes ?? [
|
|
82
95
|
'fullName',
|
|
83
96
|
'email',
|
|
84
97
|
],
|
|
85
98
|
};
|
|
86
99
|
}
|
|
87
100
|
|
|
88
|
-
return CredentialsManager.signIn(
|
|
101
|
+
return CredentialsManager.signIn([...options], signInParams) as Promise<
|
|
102
|
+
SignInResult<T>
|
|
103
|
+
>;
|
|
89
104
|
}
|
|
90
105
|
|
|
91
106
|
export function signUpWithGoogle(
|
|
92
107
|
params: GoogleSignInParams
|
|
93
|
-
): Promise<GoogleCredential
|
|
108
|
+
): Promise<GoogleCredential> {
|
|
94
109
|
if (Platform.OS === 'ios') {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
}) as Promise<AppleCredential>;
|
|
110
|
+
return Promise.reject(
|
|
111
|
+
new Error(
|
|
112
|
+
'Google Sign In is only available on Android. Use signUpWithApple on iOS.'
|
|
113
|
+
)
|
|
114
|
+
);
|
|
101
115
|
}
|
|
102
116
|
|
|
103
117
|
return CredentialsManager.signUpWithGoogle({
|
|
@@ -137,4 +151,6 @@ export type {
|
|
|
137
151
|
SignInOption,
|
|
138
152
|
GoogleSignInParams,
|
|
139
153
|
AppleSignInParams,
|
|
154
|
+
PasskeyCredential,
|
|
155
|
+
PasswordCredential,
|
|
140
156
|
};
|