Skip to content

Commit 07dd005

Browse files
authored
Add back optional action param to inapp verify (#64)
1 parent 1362904 commit 07dd005

File tree

8 files changed

+25
-10
lines changed

8 files changed

+25
-10
lines changed

android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,5 +77,5 @@ dependencies {
7777

7878
implementation "androidx.browser:browser:1.2.0"
7979

80-
implementation("com.authsignal:authsignal-android:3.0.1")
80+
implementation("com.authsignal:authsignal-android:3.0.2")
8181
}

android/src/main/java/com/authsignal/react/AuthsignalInAppModule.kt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,12 @@ class AuthsignalInAppModule(private val reactContext: ReactApplicationContext) :
101101
}
102102

103103
@ReactMethod
104-
fun verify(promise: Promise) {
104+
fun verify(
105+
action: String?,
106+
promise: Promise
107+
) {
105108
launch(promise) {
106-
val response = it.verify()
109+
val response = it.verify(action)
107110

108111
if (response.error != null) {
109112
val errorCode = response.errorCode ?: defaultError

ios/AuthsignalInAppModule.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ @interface RCT_EXTERN_MODULE(AuthsignalInAppModule, NSObject)
2020
RCT_EXTERN_METHOD(removeCredential:(RCTPromiseResolveBlock)resolve
2121
rejecter:(RCTPromiseRejectBlock)reject)
2222

23-
RCT_EXTERN_METHOD(verify:(RCTPromiseResolveBlock)resolve
23+
RCT_EXTERN_METHOD(verify:(NSString)action
24+
resolver:(RCTPromiseResolveBlock)resolve
2425
rejecter:(RCTPromiseRejectBlock)reject)
2526

2627
@end

ios/AuthsignalInAppModule.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,16 +111,19 @@ class AuthsignalInAppModule: NSObject {
111111
}
112112

113113
@objc func verify(
114-
_ resolve: @escaping RCTPromiseResolveBlock,
114+
_ action: NSString?,
115+
resolver resolve: @escaping RCTPromiseResolveBlock,
115116
rejecter reject: @escaping RCTPromiseRejectBlock
116117
) -> Void {
117118
guard let authsignal = authsignal else {
118119
resolve(nil)
119120
return
120121
}
122+
123+
let actionStr = action as String?
121124

122125
Task.init {
123-
let response = await authsignal.verify()
126+
let response = await authsignal.verify(action: actionStr)
124127

125128
if let error = response.error {
126129
reject(response.errorCode ?? "unexpected_error", error, nil)

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-authsignal",
3-
"version": "2.0.1",
3+
"version": "2.0.2",
44
"description": "The official Authsignal React Native library.",
55
"main": "lib/commonjs/index",
66
"module": "lib/module/index",

react-native-authsignal.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Pod::Spec.new do |s|
1717
s.source_files = "ios/**/*.{h,m,mm,swift}"
1818

1919
s.dependency "React-Core"
20-
s.dependency 'Authsignal', '2.0.1'
20+
s.dependency 'Authsignal', '2.0.2'
2121

2222
# Don't install the dependencies when we run `pod install` in the old architecture.
2323
if ENV['RCT_NEW_ARCH_ENABLED'] == '1' then

src/inapp.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { handleErrorCodes, LINKING_ERROR } from './error';
33
import type {
44
AuthsignalResponse,
55
AppCredential,
6+
InAppVerifyRequest,
67
InAppVerifyResponse,
78
AddCredentialInput,
89
} from './types';
@@ -96,11 +97,14 @@ export class AuthsignalInApp {
9697
return handleErrorCodes(ex);
9798
}
9899
}
99-
async verify(): Promise<AuthsignalResponse<InAppVerifyResponse>> {
100+
101+
async verify({ action }: InAppVerifyRequest = {}): Promise<
102+
AuthsignalResponse<InAppVerifyResponse>
103+
> {
100104
await this.ensureModuleIsInitialized();
101105

102106
try {
103-
const data = await AuthsignalInAppModule.verify();
107+
const data = await AuthsignalInAppModule.verify(action);
104108

105109
return { data };
106110
} catch (ex) {

src/types.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,10 @@ export interface UpdateChallengeInput {
8383
verificationCode?: string | null;
8484
}
8585

86+
export interface InAppVerifyRequest {
87+
action?: string;
88+
}
89+
8690
export interface InAppVerifyResponse {
8791
token: string;
8892
userId: string;

0 commit comments

Comments
 (0)