@algorandfoundation/react-native-passkey-autofill 0.0.1 → 1.0.0-canary.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/.eslintrc.js +5 -0
- package/ARCHITECTURE.md +67 -0
- package/CONTRIBUTING.md +72 -0
- package/LICENSE +201 -0
- package/README.md +73 -5
- package/android/build.gradle +68 -0
- package/android/libs/dP256Android-release.aar +0 -0
- package/android/src/main/AndroidManifest.xml +32 -0
- package/android/src/main/java/co/algorand/passkeyautofill/CreatePasskeyActivity.kt +166 -0
- package/android/src/main/java/co/algorand/passkeyautofill/GetPasskeyActivity.kt +151 -0
- package/android/src/main/java/co/algorand/passkeyautofill/ReactNativePasskeyAutofillModule.kt +70 -0
- package/android/src/main/java/co/algorand/passkeyautofill/credentials/Credential.kt +11 -0
- package/android/src/main/java/co/algorand/passkeyautofill/credentials/CredentialRepository.kt +506 -0
- package/android/src/main/java/co/algorand/passkeyautofill/service/PasskeyAutofillCredentialProviderService.kt +217 -0
- package/android/src/main/res/values/strings.xml +3 -0
- package/android/src/main/res/xml/provider.xml +5 -0
- package/app.plugin.js +249 -0
- package/build/ReactNativePasskeyAutofill.types.d.ts +2 -0
- package/build/ReactNativePasskeyAutofill.types.d.ts.map +1 -0
- package/build/ReactNativePasskeyAutofill.types.js +2 -0
- package/build/ReactNativePasskeyAutofill.types.js.map +1 -0
- package/build/ReactNativePasskeyAutofillModule.d.ts +12 -0
- package/build/ReactNativePasskeyAutofillModule.d.ts.map +1 -0
- package/build/ReactNativePasskeyAutofillModule.js +4 -0
- package/build/ReactNativePasskeyAutofillModule.js.map +1 -0
- package/build/index.d.ts +3 -0
- package/build/index.d.ts.map +1 -0
- package/build/index.js +5 -0
- package/build/index.js.map +1 -0
- package/expo-module.config.json +10 -0
- package/ios/ReactNativePasskeyAutofill.podspec +29 -0
- package/ios/ReactNativePasskeyAutofillModule.swift +48 -0
- package/ios/ReactNativePasskeyAutofillView.swift +38 -0
- package/package.json +44 -8
- package/src/ReactNativePasskeyAutofill.types.ts +3 -0
- package/src/ReactNativePasskeyAutofillModule.ts +14 -0
- package/src/index.ts +4 -0
- package/tsconfig.json +9 -0
- package/index.js +0 -1
package/.eslintrc.js
ADDED
package/ARCHITECTURE.md
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# 🏗️ Architecture
|
|
2
|
+
|
|
3
|
+
This document describes the internal structure of the `react-native-passkey-autofill` module and how it works.
|
|
4
|
+
|
|
5
|
+
## Project Structure
|
|
6
|
+
|
|
7
|
+
The project follows the standard layout for an Expo module:
|
|
8
|
+
|
|
9
|
+
- `src/`: TypeScript source files for the module's JavaScript API.
|
|
10
|
+
- `android/`: Native Android implementation using Kotlin.
|
|
11
|
+
- `ios/`: Native iOS implementation using Swift.
|
|
12
|
+
- `example/`: An example app demonstrating the use of the module.
|
|
13
|
+
|
|
14
|
+
## How it works
|
|
15
|
+
|
|
16
|
+
The module provides an interface to interact with native Passkey AutoFill capabilities. It uses Expo's native module system to bridge the JavaScript code with the platform-specific implementations.
|
|
17
|
+
|
|
18
|
+
### TypeScript Layer (`src/`)
|
|
19
|
+
|
|
20
|
+
- `index.ts`: The entry point for the module, re-exporting the native module.
|
|
21
|
+
- `ReactNativePasskeyAutofillModule.ts`: Defines the `ReactNativePasskeyAutofillModule` class and its methods (`setMasterKey`, `setHdRootKeyId`, `getHdRootKeyId`, etc.).
|
|
22
|
+
- `ReactNativePasskeyAutofill.types.ts`: Defines types and interfaces used by the module.
|
|
23
|
+
|
|
24
|
+
### Android Implementation (`android/`)
|
|
25
|
+
|
|
26
|
+
The Android part is implemented using Kotlin and follows the Android Autofill Framework.
|
|
27
|
+
|
|
28
|
+
- `ReactNativePasskeyAutofillModule.kt`: The main class that exposes methods to React Native.
|
|
29
|
+
- `service/PasskeyAutofillCredentialProviderService.kt`: Implements the `CredentialProviderService` to handle Passkey AutoFill requests from the Android system.
|
|
30
|
+
- `credentials/`: Contains logic for managing credentials and interacting with the local storage.
|
|
31
|
+
- `GetPasskeyActivity.kt` and `CreatePasskeyActivity.kt`: Activities used to handle the UI flow for getting and creating passkeys.
|
|
32
|
+
|
|
33
|
+
#### The `CredentialProvider` and Chain of Trust
|
|
34
|
+
|
|
35
|
+
The `PasskeyAutofillCredentialProviderService` is the core of the Android implementation. It extends the Android Jetpack `CredentialProviderService` to provide passkeys directly to the system's Credential Manager.
|
|
36
|
+
|
|
37
|
+
##### What is `CredentialProviderService`?
|
|
38
|
+
Introduced in Android 14 (API level 34) and backported to Android 9 via the Jetpack Credentials library, this service allows password managers and other credential providers to integrate with the system's unified sign-in flow. When a user interacts with a sign-in or sign-up field, the system queries registered services to provide available credentials.
|
|
39
|
+
|
|
40
|
+
##### Handling the Chain of Trust
|
|
41
|
+
The "Chain of Trust" ensures that passkeys are only used by the legitimate owners of a domain or application. This is handled through several layers of validation:
|
|
42
|
+
|
|
43
|
+
1. **Digital Asset Links**: For a passkey to be used across a website and an Android app, the website must host a `/.well-known/assetlinks.json` file that explicitly authorizes the Android app (via its package name and certificate fingerprint). This establishes a cryptographically verified link between the web origin and the mobile application.
|
|
44
|
+
2. **Relying Party ID (rpId) Validation**: When the service receives a `BeginGetCredentialRequest` or `BeginCreateCredentialRequest`, it includes information about the `rpId` (e.g., `example.com`). The system and the provider must ensure that the requesting app is authorized to use credentials for that `rpId`.
|
|
45
|
+
3. **App Signature Verification**: The Android system verifies the signature of the app requesting the credential. It will only offer credentials to apps that can prove their identity through the Digital Asset Link chain.
|
|
46
|
+
4. **User Consent**: The `CredentialProviderService` does not directly return the credential. Instead, it returns a list of "Entries" (like `PublicKeyCredentialEntry`). When a user selects an entry, a `PendingIntent` is triggered, which typically launches an activity (like `GetPasskeyActivity`) to perform user verification (e.g., biometric check) before the actual passkey is released to the requesting app.
|
|
47
|
+
|
|
48
|
+
### iOS Implementation (`ios/`) [WIP]
|
|
49
|
+
|
|
50
|
+
The iOS part is implemented using Swift.
|
|
51
|
+
|
|
52
|
+
- `ReactNativePasskeyAutofillModule.swift`: Defines the native module for iOS.
|
|
53
|
+
- `ReactNativePasskeyAutofillView.swift`: If any native views are required.
|
|
54
|
+
|
|
55
|
+
## Native Module API
|
|
56
|
+
|
|
57
|
+
The following methods are exposed to the JavaScript layer:
|
|
58
|
+
|
|
59
|
+
- `setMasterKey(secret: string)`: Sets the master key for credential encryption/decryption.
|
|
60
|
+
- `setHdRootKeyId(id: string)`: Sets the ID for the HD root key.
|
|
61
|
+
- `getHdRootKeyId()`: Retrieves the current HD root key ID.
|
|
62
|
+
- `configureIntentActions(getPasskeyAction: string, createPasskeyAction: string)`: Configures the intent actions used for Passkey flows.
|
|
63
|
+
- `clearCredentials()`: Clears all stored credentials.
|
|
64
|
+
|
|
65
|
+
## Security Considerations
|
|
66
|
+
|
|
67
|
+
As this module handles sensitive information (Passkeys), it is crucial to ensure that keys and secrets are handled securely in the native layers. Master keys should be stored in secure storage (like Android Keystore or iOS Keychain).
|
package/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# 🤝 Contributing
|
|
2
|
+
|
|
3
|
+
Contributions are very welcome! Whether you are fixing a bug, adding a feature, or improving documentation, your help is appreciated.
|
|
4
|
+
|
|
5
|
+
## Getting Started
|
|
6
|
+
|
|
7
|
+
To get started with the project, follow these steps:
|
|
8
|
+
|
|
9
|
+
1. **Fork the repository** to your own GitHub account.
|
|
10
|
+
2. **Clone the repository** to your local machine.
|
|
11
|
+
3. **Install dependencies** at the root of the project:
|
|
12
|
+
```bash
|
|
13
|
+
npm install
|
|
14
|
+
```
|
|
15
|
+
4. **Build the project**:
|
|
16
|
+
```bash
|
|
17
|
+
npm run build
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Development Workflow
|
|
21
|
+
|
|
22
|
+
### Example App
|
|
23
|
+
|
|
24
|
+
The project includes an example app in the `example/` directory. You can use it to test your changes.
|
|
25
|
+
|
|
26
|
+
1. Navigate to the `example/` directory:
|
|
27
|
+
```bash
|
|
28
|
+
cd example
|
|
29
|
+
```
|
|
30
|
+
2. Install example dependencies:
|
|
31
|
+
```bash
|
|
32
|
+
npm install
|
|
33
|
+
```
|
|
34
|
+
3. Prebuild the example for Android or iOS:
|
|
35
|
+
```bash
|
|
36
|
+
npx expo prebuild
|
|
37
|
+
```
|
|
38
|
+
4. Run the example app:
|
|
39
|
+
```bash
|
|
40
|
+
npm run android # for Android
|
|
41
|
+
# or
|
|
42
|
+
npm run ios # for iOS
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Code Style
|
|
46
|
+
|
|
47
|
+
- Use Prettier for code formatting (run `npx prettier --write .` if available).
|
|
48
|
+
- Follow existing naming conventions and patterns in the codebase.
|
|
49
|
+
- Ensure all TypeScript types are correctly defined.
|
|
50
|
+
|
|
51
|
+
For more details on how the project is structured, see the [Architecture Guide](./ARCHITECTURE.md).
|
|
52
|
+
|
|
53
|
+
## Submitting a Pull Request
|
|
54
|
+
|
|
55
|
+
1. Create a new branch for your feature or bugfix:
|
|
56
|
+
```bash
|
|
57
|
+
git checkout -b feature/your-feature-name
|
|
58
|
+
```
|
|
59
|
+
2. Make your changes and commit them with a descriptive message.
|
|
60
|
+
3. Push your branch to your fork:
|
|
61
|
+
```bash
|
|
62
|
+
git push origin feature/your-feature-name
|
|
63
|
+
```
|
|
64
|
+
4. Open a Pull Request on the main repository.
|
|
65
|
+
|
|
66
|
+
## Reporting Issues
|
|
67
|
+
|
|
68
|
+
If you find a bug or have a feature request, please open an issue on the GitHub repository. Provide as much detail as possible, including steps to reproduce the issue.
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
Thank you for contributing!
|
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 Algorand Foundation
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,10 +1,78 @@
|
|
|
1
|
-
#
|
|
1
|
+
# 🔑 react-native-passkey-autofill
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Passkey AutoFill for React Native using DP256.
|
|
4
|
+
|
|
5
|
+
# 🚀 Get Started
|
|
6
|
+
|
|
7
|
+
For bare React Native projects, you must ensure that you have [installed and configured the `expo` package](https://docs.expo.dev/bare/installing-expo-modules/) before continuing.
|
|
8
|
+
|
|
9
|
+
### Add the package to your npm dependencies
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install react-native-passkey-autofill
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
### Configure for Android
|
|
16
|
+
|
|
17
|
+
To use this module on Android, you need to configure the AutoFill service in your `AndroidManifest.xml` or via the Expo plugin.
|
|
18
|
+
|
|
19
|
+
#### Expo Plugin Configuration
|
|
20
|
+
|
|
21
|
+
If you are using Expo, you can configure the plugin in your `app.json` or `app.config.js`:
|
|
22
|
+
|
|
23
|
+
```json
|
|
24
|
+
{
|
|
25
|
+
"expo": {
|
|
26
|
+
"plugins": [
|
|
27
|
+
[
|
|
28
|
+
"react-native-passkey-autofill",
|
|
29
|
+
{
|
|
30
|
+
"site": "https://your-fido-server.com",
|
|
31
|
+
"label": "My Custom Credential Provider"
|
|
32
|
+
}
|
|
33
|
+
]
|
|
34
|
+
]
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
- `site`: The URL of your FIDO server (default: `https://fido.shore-tech.net`).
|
|
40
|
+
- `label`: The name of the credential provider as it appears in Android settings (default: `My Credential Provider`).
|
|
4
41
|
|
|
5
42
|
## Usage
|
|
6
43
|
|
|
7
|
-
```
|
|
8
|
-
|
|
9
|
-
|
|
44
|
+
```typescript
|
|
45
|
+
import ReactNativePasskeyAutofill from '@algorandfoundation/react-native-passkey-autofill';
|
|
46
|
+
|
|
47
|
+
// 1. Set the master key for encryption (hex string)
|
|
48
|
+
await ReactNativePasskeyAutofill.setMasterKey(masterKeyHex);
|
|
49
|
+
|
|
50
|
+
// 2. Set the HD root key ID if applicable
|
|
51
|
+
await ReactNativePasskeyAutofill.setHdRootKeyId(hdRootKeyId);
|
|
52
|
+
|
|
53
|
+
// 3. Configure intent actions for the Passkey flows
|
|
54
|
+
await ReactNativePasskeyAutofill.configureIntentActions(
|
|
55
|
+
'your.package.name.GET_PASSKEY',
|
|
56
|
+
'your.package.name.CREATE_PASSKEY'
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
// Optional: Clear credentials
|
|
60
|
+
await ReactNativePasskeyAutofill.clearCredentials();
|
|
10
61
|
```
|
|
62
|
+
|
|
63
|
+
# 🤝 Contributing
|
|
64
|
+
|
|
65
|
+
Contributions are very welcome! Please refer to guidelines described in the [contributing guide](./CONTRIBUTING.md).
|
|
66
|
+
|
|
67
|
+
# 💖 Acknowledgements
|
|
68
|
+
|
|
69
|
+
This has been the commination of many different efforts and ideas. We would like to thank the following individuals and organizations for their contributions:
|
|
70
|
+
|
|
71
|
+
- [Bruno Martins](https://github.com/bmartins) the architect at [Algorand Foundation](https://github.com/algorandfoundation) for conceptualizing and guiding the project.
|
|
72
|
+
- [HashMapsData2Value](https://github.com/HashMapsData2Value) for his guidance and support in DP256 and XHD and his work on the native autofill libraries.
|
|
73
|
+
- [Will Beaumont](https://github.com/mjbeau) for working though integration within the Pera wallet
|
|
74
|
+
- [Michael T Chuang](https://github.com/michaeltchuang) for his work in KMP integrations and client libraries.
|
|
75
|
+
|
|
76
|
+
# 📄 License
|
|
77
|
+
|
|
78
|
+
This project is licensed under the Apache-2.0 License - see the [LICENSE](./LICENSE) file for details.
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
apply plugin: 'com.android.library'
|
|
2
|
+
|
|
3
|
+
group = 'co.algorand.passkeyautofill'
|
|
4
|
+
version = '0.1.0'
|
|
5
|
+
|
|
6
|
+
def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle")
|
|
7
|
+
apply from: expoModulesCorePlugin
|
|
8
|
+
applyKotlinExpoModulesCorePlugin()
|
|
9
|
+
useCoreDependencies()
|
|
10
|
+
useExpoPublishing()
|
|
11
|
+
|
|
12
|
+
// If you want to use the managed Android SDK versions from expo-modules-core, set this to true.
|
|
13
|
+
// The Android SDK versions will be bumped from time to time in SDK releases and may introduce breaking changes in your module code.
|
|
14
|
+
// Most of the time, you may like to manage the Android SDK versions yourself.
|
|
15
|
+
def useManagedAndroidSdkVersions = false
|
|
16
|
+
if (useManagedAndroidSdkVersions) {
|
|
17
|
+
useDefaultAndroidSdkVersions()
|
|
18
|
+
} else {
|
|
19
|
+
buildscript {
|
|
20
|
+
// Simple helper that allows the root project to override versions declared by this library.
|
|
21
|
+
ext.safeExtGet = { prop, fallback ->
|
|
22
|
+
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
project.android {
|
|
26
|
+
compileSdkVersion safeExtGet("compileSdkVersion", 36)
|
|
27
|
+
defaultConfig {
|
|
28
|
+
minSdkVersion safeExtGet("minSdkVersion", 24)
|
|
29
|
+
targetSdkVersion safeExtGet("targetSdkVersion", 36)
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
android {
|
|
35
|
+
namespace "co.algorand.passkeyautofill"
|
|
36
|
+
defaultConfig {
|
|
37
|
+
versionCode 1
|
|
38
|
+
versionName "0.1.0"
|
|
39
|
+
}
|
|
40
|
+
lintOptions {
|
|
41
|
+
abortOnError false
|
|
42
|
+
}
|
|
43
|
+
kotlinOptions {
|
|
44
|
+
freeCompilerArgs += ["-opt-in=kotlin.time.ExperimentalTime", "-opt-in=kotlin.RequiresOptIn"]
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
dependencies {
|
|
49
|
+
implementation "androidx.credentials:credentials:1.3.0"
|
|
50
|
+
implementation "androidx.credentials:credentials-play-services-auth:1.3.0"
|
|
51
|
+
implementation "androidx.appcompat:appcompat:1.7.0"
|
|
52
|
+
implementation "androidx.activity:activity-ktx:1.8.2"
|
|
53
|
+
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.8.4"
|
|
54
|
+
implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.8.4"
|
|
55
|
+
implementation "io.github.zhongwuzw:mmkv:2.3.0"
|
|
56
|
+
implementation "org.bouncycastle:bcprov-jdk18on:1.78.1"
|
|
57
|
+
implementation "androidx.datastore:datastore-preferences:1.1.1"
|
|
58
|
+
implementation(name: 'dP256Android-release', ext: 'aar')
|
|
59
|
+
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
|
60
|
+
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.8.0"
|
|
61
|
+
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.8.0"
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
repositories {
|
|
65
|
+
flatDir {
|
|
66
|
+
dirs 'libs'
|
|
67
|
+
}
|
|
68
|
+
}
|
|
Binary file
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
|
2
|
+
xmlns:tools="http://schemas.android.com/tools">
|
|
3
|
+
<application>
|
|
4
|
+
<service
|
|
5
|
+
android:name=".service.PasskeyAutofillCredentialProviderService"
|
|
6
|
+
android:enabled="true"
|
|
7
|
+
android:exported="true"
|
|
8
|
+
android:label="@string/passkey_autofill_label"
|
|
9
|
+
android:icon="@mipmap/ic_launcher"
|
|
10
|
+
android:permission="android.permission.BIND_CREDENTIAL_PROVIDER_SERVICE"
|
|
11
|
+
tools:targetApi="upside_down_cake">
|
|
12
|
+
<intent-filter>
|
|
13
|
+
<action android:name="android.service.credentials.CredentialProviderService" />
|
|
14
|
+
</intent-filter>
|
|
15
|
+
<meta-data
|
|
16
|
+
android:name="android.credentials.provider"
|
|
17
|
+
android:resource="@xml/provider" />
|
|
18
|
+
</service>
|
|
19
|
+
<activity android:name=".GetPasskeyActivity" android:exported="true">
|
|
20
|
+
<intent-filter>
|
|
21
|
+
<action android:name="co.algorand.passkeyautofill.GET_PASSKEY"/>
|
|
22
|
+
<category android:name="android.intent.category.DEFAULT"/>
|
|
23
|
+
</intent-filter>
|
|
24
|
+
</activity>
|
|
25
|
+
<activity android:name=".CreatePasskeyActivity" android:exported="true">
|
|
26
|
+
<intent-filter>
|
|
27
|
+
<action android:name="co.algorand.passkeyautofill.CREATE_PASSKEY"/>
|
|
28
|
+
<category android:name="android.intent.category.DEFAULT"/>
|
|
29
|
+
</intent-filter>
|
|
30
|
+
</activity>
|
|
31
|
+
</application>
|
|
32
|
+
</manifest>
|