Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
7703942
build: move to the bob 0.44 toolchain and drop the 0.3 code
SectionTN Oct 28, 2026
c01d62e
build: let lefthook install its git hooks
SectionTN Oct 28, 2026
1152389
feat: add the input rules for typed, pasted and autofilled text
SectionTN Oct 28, 2026
1111c24
feat: add cells, groups and development warnings
SectionTN Oct 28, 2026
72522a7
feat: add the useOTPField hook
SectionTN Oct 28, 2026
1b7892d
feat: add the useResendTimer hook
SectionTN Oct 28, 2026
28c8d7d
feat: add the OTPField component
SectionTN Oct 28, 2026
2a0691e
feat: animate the caret and errors and announce status changes
SectionTN Oct 28, 2026
18964a2
chore(example): keep the focused field above the keyboard
SectionTN Oct 28, 2026
47e5792
feat(android): read SMS codes through User Consent and the SMS Retriever
SectionTN Oct 28, 2026
84984b1
feat: fill the field from SMS on Android and WebOTP on web
SectionTN Oct 28, 2026
9dc0d81
feat(example): add the headless screen
SectionTN Oct 28, 2026
1ca1bbf
fix(web): render a disabled field as a disabled input
SectionTN Oct 29, 2026
e978ec7
test: add e2e tests for typing, paste, verifying and SMS
SectionTN Oct 29, 2026
3d18812
fix(android): pin auth-api-phone 18.3.0 so React Native 0.79 builds
SectionTN Oct 29, 2026
52ad08c
test: wait for the Looks tab before scrolling to a field
SectionTN Oct 29, 2026
1cfe747
ci: run checks, e2e on three platforms, the floor build and staged pu…
SectionTN Oct 29, 2026
c4df5ff
docs: add the banner and the showcase
SectionTN Oct 29, 2026
9c0b345
build: require React Native 0.86, the oldest maintained release
SectionTN Oct 29, 2026
4451388
chore: stop Biome from formatting Markdown
SectionTN Oct 30, 2026
22878fb
docs: rewrite the README and contributing guide, and add the agent skill
SectionTN Oct 30, 2026
cdaef34
fix(sms): go idle when enabled turns false while listening
SectionTN Oct 30, 2026
b92a35f
fix: size the built-in cells from cellStyle
SectionTN Oct 30, 2026
a85f0ee
fix: verify replaced codes and never stick in verifying
SectionTN Oct 30, 2026
865fb3b
fix(web): type and delete at the end wherever the caret sits
SectionTN Oct 30, 2026
2d62b66
fix(android): answer only the session that opened the consent sheet
SectionTN Oct 30, 2026
8772ed5
fix(sms): fill only a clear code and stop only your own listen
SectionTN Oct 30, 2026
249372c
fix: show the placeholder in the active cell when the caret is off
SectionTN Oct 30, 2026
5992e8e
fix: accept only single-unit characters in a custom RegExp type
SectionTN Oct 30, 2026
8e13e05
fix: end a pending check when a controlled value changes
SectionTN Oct 30, 2026
968edd2
chore(example): name the iOS workspace and scheme OTPKitExample
SectionTN Oct 30, 2026
217a55b
feat: export the option types as constants
SectionTN Oct 30, 2026
d306538
feat: take the SMS sender inside the sms prop
SectionTN Oct 30, 2026
b3b0a4a
feat: style cells with a function of the cell
SectionTN Oct 30, 2026
56c6f4c
fix(sms): need a digit when joining an alphanumeric SMS code
SectionTN Oct 30, 2026
565c3e5
fix(sms): drop a held SMS code when a clear ends the check
SectionTN Oct 30, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Bug report
description: Report a bug you can reproduce in react-native-otpkit.
labels: [bug]
body:
- type: markdown
attributes:
value: |
Fill in every field. A bug without a way to reproduce it is hard to fix, and the issue may be closed.
- type: checkboxes
attributes:
label: Before you open the issue
options:
- label: I tried the latest version of react-native-otpkit, in case the bug is already fixed.
required: true
- label: My app runs a [supported version](https://github.com/reactwg/react-native-releases/blob/main/docs/support.md) of React Native.
required: true
- label: I searched the existing issues for a duplicate.
required: true
- type: textarea
id: summary
attributes:
label: Bug summary
description: |
What happened, and what did you expect instead? Add error messages, stack traces, screenshots or a screen recording if you have them.
validations:
required: true
- type: input
id: library-version
attributes:
label: Library version
description: The react-native-otpkit version in your lockfile.
placeholder: "x.x.x"
validations:
required: true
- type: textarea
id: react-native-info
attributes:
label: Environment info
description: Paste the output of `react-native info`.
render: shell
validations:
required: true
- type: textarea
id: steps-to-reproduce
attributes:
label: Steps to reproduce
description: |
List the steps, and include the code that renders the field.
value: |
1. ...
2. ...
validations:
required: true
- type: input
id: reproducible-example
attributes:
label: Reproducible example repository
description: A link to a GitHub repository that reproduces the bug.
validations:
required: true
8 changes: 8 additions & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
blank_issues_enabled: true
contact_links:
- name: Feature request
url: https://github.com/SectionTN/react-native-otpkit/discussions/new?category=ideas
about: Suggest a feature in GitHub Discussions.
- name: Discussions on GitHub
url: https://github.com/SectionTN/react-native-otpkit/discussions
about: Ask a question or get help with your setup.
21 changes: 15 additions & 6 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,32 @@ runs:
using: composite
steps:
- name: Setup Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version-file: .nvmrc

- name: Cache dependencies
- name: Restore dependencies
id: yarn-cache
uses: actions/cache@v3
uses: actions/cache/restore@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
with:
path: |
**/node_modules
.yarn/cache
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}-${{ hashFiles('**/package.json') }}
.yarn/install-state.gz
key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }}-${{ hashFiles('**/package.json', '!node_modules/**') }}
restore-keys: |
${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }}
${{ runner.os }}-yarn-

- name: Install dependencies
if: steps.yarn-cache.outputs.cache-hit != 'true'
run: yarn install --immutable
shell: bash

- name: Cache dependencies
if: steps.yarn-cache.outputs.cache-hit != 'true'
uses: actions/cache/save@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
with:
path: |
**/node_modules
.yarn/install-state.gz
key: ${{ steps.yarn-cache.outputs.cache-primary-key }}
Binary file added .github/assets/otpkit-banner-dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .github/assets/otpkit-banner-light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .github/assets/otpkit-showcase.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .github/assets/otpkit-showcase.webp
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
170 changes: 152 additions & 18 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,55 +7,189 @@ on:
branches:
- main

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
lint:
check:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0

- name: Setup
uses: ./.github/actions/setup

- name: Lint files
- name: Lint
run: yarn lint

- name: Typecheck files
- name: Typecheck
run: yarn typecheck

test:
- name: Unit tests
run: yarn test

- name: Build package
run: yarn prepare

android:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0

- name: Setup
uses: ./.github/actions/setup

- name: Run unit tests
run: yarn test --maxWorkers=2 --coverage
- name: Install JDK
uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4.7.1
with:
distribution: zulu
java-version: "17"

build-library:
runs-on: ubuntu-latest
- name: Cache Gradle
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
with:
path: |
~/.gradle/wrapper
~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('yarn.lock') }}
restore-keys: |
${{ runner.os }}-gradle-

- name: Prebuild the example
working-directory: example
run: npx expo prebuild --platform android --no-install

- name: Kotlin unit tests
working-directory: example/android
run: ./gradlew :react-native-otpkit:testDebugUnitTest --no-daemon

- name: Build the release app for the emulator
working-directory: example/android
run: ./gradlew assembleRelease --no-daemon -PreactNativeArchitectures=x86_64

- name: Enable KVM
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm

- name: End-to-end tests
uses: reactivecircus/android-emulator-runner@a421e43855164a8197daf9d8d40fe71c6996bb0d # v2.38.0
env:
E2E_TELEMETRY_DISABLED: "1"
OTPKIT_APP_PATH: example/android/app/build/outputs/apk/release/app-release.apk
with:
api-level: 35
arch: x86_64
target: google_apis
# The default 320x640 dp screen is smaller than any current phone.
profile: pixel_6
script: |
yarn e2e --target android || (mkdir -p .e2e/artifacts; adb logcat -d > .e2e/artifacts/logcat.txt; adb shell dumpsys window | grep -E 'mCurrentFocus|mFocusedApp' > .e2e/artifacts/focus.txt; exit 1)

- name: Upload e2e artifacts
# The report also keeps the errors of attempts a retry passed.
if: ${{ !cancelled() }}
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: e2e-android
path: .e2e
include-hidden-files: true
if-no-files-found: warn
retention-days: 7

ios:
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0

- name: Setup
uses: ./.github/actions/setup

- name: Build package
run: yarn prepare
- name: Use Xcode 26
uses: maxim-lobanov/setup-xcode@60606e260d2fc5762a71e64e74b2174e8ea3c8bd # v1.6.0
with:
xcode-version: 26

- name: Prebuild the example
working-directory: example
run: npx expo prebuild --platform ios

- name: Build the release app for the simulator
working-directory: example/ios
run: >
xcodebuild -workspace OTPKitExample.xcworkspace -scheme OTPKitExample
-configuration Release -sdk iphonesimulator
-destination 'generic/platform=iOS Simulator'
-derivedDataPath build CODE_SIGNING_ALLOWED=NO build

- name: Boot the simulator and build the test runner
id: simulator
timeout-minutes: 30
run: |
udid=$(xcrun simctl create otpkit-e2e "iPhone 17" "iOS$(xcrun --sdk iphonesimulator --show-sdk-version)")
echo "udid=$udid" >> "$GITHUB_OUTPUT"
# agent-device's own cold boot builds its runner alongside and fails a 15 s simctl check.
xcrun simctl bootstatus "$udid" -b
# A cold runner build outlasts the e2e daemon's request timeout.
npx agent-device prepare ios-runner --platform ios --udid "$udid" --timeout 900000
npx agent-device daemon stop

- name: End-to-end tests
env:
E2E_IOS_DEVICE: ${{ steps.simulator.outputs.udid }}
E2E_TELEMETRY_DISABLED: "1"
OTPKIT_APP_PATH: example/ios/build/Build/Products/Release-iphonesimulator/OTPKitExample.app
run: yarn e2e --target ios

build-web:
- name: Upload e2e artifacts
# The report also keeps the errors of attempts a retry passed.
if: ${{ !cancelled() }}
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: e2e-ios
path: .e2e
include-hidden-files: true
if-no-files-found: warn
retention-days: 7

web:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0

- name: Setup
uses: ./.github/actions/setup

- name: Build example for Web
run: |
yarn example expo export:web
- name: Export the example for web
run: yarn e2e:web:build

- name: Install the browsers
run: npx --yes playwright-core@1.63.0 install --with-deps chromium webkit

- name: End-to-end tests on Chromium
env:
E2E_TELEMETRY_DISABLED: "1"
run: yarn e2e --target web

- name: End-to-end tests on WebKit
if: ${{ !cancelled() }}
env:
E2E_TELEMETRY_DISABLED: "1"
run: yarn e2e --target web-webkit

- name: Upload e2e artifacts
# The report also keeps the errors of attempts a retry passed.
if: ${{ !cancelled() }}
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: e2e-web
path: .e2e
include-hidden-files: true
if-no-files-found: warn
retention-days: 7
Loading
Loading