Skip to content

Add requireUserAuthentication flag on addCredential (iOS only) #45

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions ios/AuthsignalPushModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ @interface RCT_EXTERN_MODULE(AuthsignalPushModule, NSObject)
rejecter:(RCTPromiseRejectBlock)reject)

RCT_EXTERN_METHOD(addCredential:(NSString)token
withRequireUserAuthentication:(BOOL)requireUserAuthentication
withKeychainAccess:(NSString)keychainAccess
resolver:(RCTPromiseResolveBlock)resolve
rejecter:(RCTPromiseRejectBlock)reject)
Expand Down
9 changes: 7 additions & 2 deletions ios/AuthsignalPushModule.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class AuthsignalPushModule: NSObject {

@objc func addCredential(
_ token: NSString?,
withRequireUserAuthentication requireUserAuthentication: Bool,
withKeychainAccess keychainAccess: NSString,
resolver resolve: @escaping RCTPromiseResolveBlock,
rejecter reject: @escaping RCTPromiseRejectBlock
Expand All @@ -61,11 +62,15 @@ class AuthsignalPushModule: NSObject {
}

let tokenStr = token as String?

let requireAuthentication = requireUserAuthentication as Bool
let keychainAccess = getKeychainAccess(value: keychainAccess as String?)

Task.init {
let response = await authsignal.addCredential(token: tokenStr, keychainAccess: keychainAccess)
let response = await authsignal.addCredential(
token: tokenStr,
keychainAccess: keychainAccess,
userPresenceRequired: requireAuthentication
)

if let error = response.error {
reject(response.errorCode ?? "unexpected_error", error, nil)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-native-authsignal",
"version": "1.3.2",
"version": "1.3.3",
"description": "The official Authsignal React Native library.",
"main": "lib/commonjs/index",
"module": "lib/module/index",
Expand Down
2 changes: 1 addition & 1 deletion react-native-authsignal.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Pod::Spec.new do |s|
s.source_files = "ios/**/*.{h,m,mm,swift}"

s.dependency "React-Core"
s.dependency 'Authsignal', '1.2.0'
s.dependency 'Authsignal', '1.2.1'

# Don't install the dependencies when we run `pod install` in the old architecture.
if ENV['RCT_NEW_ARCH_ENABLED'] == '1' then
Expand Down
8 changes: 7 additions & 1 deletion src/push.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const AuthsignalPushModule = NativeModules.AuthsignalPushModule

interface AddCredentialInput {
token?: string;
requireUserAuthentication?: boolean;
keychainAccess?: KeychainAccess;
}

Expand Down Expand Up @@ -66,14 +67,19 @@ export class AuthsignalPush {

async addCredential({
token,
requireUserAuthentication = false,
keychainAccess,
}: AddCredentialInput = {}): Promise<AuthsignalResponse<boolean>> {
await this.ensureModuleIsInitialized();

try {
const data =
Platform.OS === 'ios'
? await AuthsignalPushModule.addCredential(token, keychainAccess)
? await AuthsignalPushModule.addCredential(
token,
requireUserAuthentication,
keychainAccess
)
: await AuthsignalPushModule.addCredential(token);

return { data };
Expand Down
Loading