otpless-headless-rn 1.0.6 → 1.0.8
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 +215 -2
- package/android/build.gradle +1 -1
- package/android/src/main/java/com/otplessheadlessrn/OtplessReactNativeModule.kt +22 -6
- package/android/src/main/java/com/otplessheadlessrn/utils.kt +95 -0
- package/ios/OtplessHeadlessRN.m +2 -2
- package/ios/OtplessHeadlessRN.swift +2 -2
- package/lib/commonjs/index.js +29 -6
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/models.js +2 -0
- package/lib/commonjs/models.js.map +1 -0
- package/lib/module/index.js +15 -6
- package/lib/module/index.js.map +1 -1
- package/lib/module/models.js +2 -0
- package/lib/module/models.js.map +1 -0
- package/lib/typescript/index.d.ts +5 -1
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/models.d.ts +23 -0
- package/lib/typescript/models.d.ts.map +1 -0
- package/otpless-headless-rn.podspec +1 -1
- package/package.json +1 -1
- package/src/index.tsx +21 -6
- package/src/models.tsx +90 -0
- package/ios/OtplessHeadlessRN.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -7
- package/ios/OtplessHeadlessRN.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
- package/ios/OtplessHeadlessRN.xcodeproj/project.xcworkspace/xcuserdata/sparsh.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/ios/OtplessHeadlessRN.xcodeproj/xcuserdata/sparsh.xcuserdatad/xcschemes/xcschememanagement.plist +0 -14
package/README.md
CHANGED
|
@@ -2,14 +2,227 @@
|
|
|
2
2
|
<img src="https://github.com/otpless-tech/Otpless-iOS-SDK/blob/main/otpless.svg" height="80"/>
|
|
3
3
|
</p>
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
|
|
6
|
+
# OTPLESS react native headless SDK
|
|
7
|
+
|
|
8
|
+
The new Authentication SDK offers significantly improved speed, reliability, and security, ensuring a seamless authentication and integration experience. We strongly recommend upgrading by removing the old SDK and following the steps below.
|
|
9
|
+
|
|
10
|
+
## Install OTPLESS SDK Dependency
|
|
11
|
+
|
|
6
12
|
[](https://badge.fury.io/js/otpless-headless-rn)
|
|
7
13
|
[](https://www.npmjs.com/package/otpless-headless-rn)
|
|
8
14
|
|
|
9
15
|
|
|
10
16
|
## Installation
|
|
17
|
+
Install the OTPLESS SDK dependency by running the following command in your terminal at the root of your React Native project:
|
|
18
|
+
|
|
19
|
+
```
|
|
20
|
+
npm i otpless-headless-rn
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
# Configure Sign up/Sign in
|
|
24
|
+
|
|
25
|
+
### Import
|
|
26
|
+
|
|
27
|
+
```javascript
|
|
28
|
+
import { OtplessHeadlessModule } from 'otpless-headless-rn';
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
```javascript
|
|
33
|
+
const headlessModule = new OtplessHeadlessModule();
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
```javascript
|
|
37
|
+
useEffect(() => {
|
|
38
|
+
headlessModule.initialize("YOUR_APPID")
|
|
39
|
+
headlessModule.setResponseCallback(onHeadlessResult);
|
|
40
|
+
return () => {
|
|
41
|
+
headlessModule.clearListener();
|
|
42
|
+
headlessModule.cleanup();
|
|
43
|
+
};
|
|
44
|
+
}, []);
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
# Initiate Authentication
|
|
48
|
+
|
|
49
|
+
## Phone Auth
|
|
50
|
+
|
|
51
|
+
### Request
|
|
52
|
+
```javascript
|
|
53
|
+
const startPhoneAuth = (phoneNumber: string, countryCode: string) => {
|
|
54
|
+
const request = {
|
|
55
|
+
phone: phoneNumber,
|
|
56
|
+
countryCode
|
|
57
|
+
};
|
|
58
|
+
headlessModule.start(request);
|
|
59
|
+
};
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### Verify
|
|
63
|
+
|
|
64
|
+
```javascript
|
|
65
|
+
const verifyPhoneOtp = (phoneNumber: string, countryCode: string, otp: string) => {
|
|
66
|
+
const request = {
|
|
67
|
+
phone: phoneNumber,
|
|
68
|
+
countryCode,
|
|
69
|
+
otp
|
|
70
|
+
};
|
|
71
|
+
headlessModule.start(request);
|
|
72
|
+
};
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
# Response Handling
|
|
76
|
+
|
|
77
|
+
```javascript
|
|
78
|
+
const onHeadlessResult = (result: any) => {
|
|
79
|
+
headlessModule.commitResponse(result);
|
|
80
|
+
const responseType = result.responseType;
|
|
81
|
+
|
|
82
|
+
switch (responseType) {
|
|
83
|
+
case "SDK_READY": {
|
|
84
|
+
// Notify that SDK is ready
|
|
85
|
+
console.log("SDK is ready");
|
|
86
|
+
break;
|
|
87
|
+
}
|
|
88
|
+
case "FAILED": {
|
|
89
|
+
console.log("SDK initialization failed");
|
|
90
|
+
// Handle SDK initialization failure
|
|
91
|
+
break;
|
|
92
|
+
}
|
|
93
|
+
case "INITIATE": {
|
|
94
|
+
// Notify that headless authentication has been initiated
|
|
95
|
+
if (result.statusCode == 200) {
|
|
96
|
+
console.log("Headless authentication initiated");
|
|
97
|
+
const authType = result.response.authType; // This is the authentication type
|
|
98
|
+
if (authType === "OTP") {
|
|
99
|
+
// Take user to OTP verification screen
|
|
100
|
+
} else if (authType === "SILENT_AUTH") {
|
|
101
|
+
// Handle Silent Authentication initiation by showing
|
|
102
|
+
// loading status for SNA flow.
|
|
103
|
+
}
|
|
104
|
+
} else {
|
|
105
|
+
// Handle initiation error.
|
|
106
|
+
// To handle initiation error response, please refer to the error handling section.
|
|
107
|
+
if (Platform.OS === 'ios') {
|
|
108
|
+
handleInitiateErrorIOS(result.response);
|
|
109
|
+
} else if (Platform.OS === 'android') {
|
|
110
|
+
handleInitiateErrorAndroid(result.response);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
break;
|
|
114
|
+
}
|
|
115
|
+
case "OTP_AUTO_READ": {
|
|
116
|
+
// OTP_AUTO_READ is triggered only in Android devices for WhatsApp and SMS.
|
|
117
|
+
if (Platform.OS === "android") {
|
|
118
|
+
const otp = result.response.otp;
|
|
119
|
+
console.log(`OTP Received: ${otp}`);
|
|
120
|
+
}
|
|
121
|
+
break;
|
|
122
|
+
}
|
|
123
|
+
case "VERIFY": {
|
|
124
|
+
// notify that verification has failed.
|
|
125
|
+
if (result.response.authType == "SILENT_AUTH") {
|
|
126
|
+
if (result.statusCode == 9106) {
|
|
127
|
+
// Silent Authentication and all fallback authentication methods in SmartAuth have failed.
|
|
128
|
+
// The transaction cannot proceed further.
|
|
129
|
+
// Handle the scenario to gracefully exit the authentication flow
|
|
130
|
+
} else {
|
|
131
|
+
// Silent Authentication failed.
|
|
132
|
+
// If SmartAuth is enabled, the INITIATE response
|
|
133
|
+
// will include the next available authentication method configured in the dashboard.
|
|
134
|
+
}
|
|
135
|
+
} else {
|
|
136
|
+
// To handle verification failed response, please refer to the error handling section.
|
|
137
|
+
if (Platform.OS === 'ios') {
|
|
138
|
+
handleVerifyErrorIOS(result.response);
|
|
139
|
+
} else if (Platform.OS === 'android') {
|
|
140
|
+
handleVerifyErrorAndroid(result.response);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
break;
|
|
145
|
+
}
|
|
146
|
+
case "DELIVERY_STATUS": {
|
|
147
|
+
// This function is called when delivery is successful for your authType.
|
|
148
|
+
const authType = result.response.authType;
|
|
149
|
+
// It is the authentication type (OTP, MAGICLINK, OTP_LINK) for which the delivery status is being sent
|
|
150
|
+
const deliveryChannel = result.response.deliveryChannel;
|
|
151
|
+
// It is the delivery channel (SMS, WHATSAPP, etc) on which the authType has been delivered
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
case "ONETAP": {
|
|
155
|
+
const token = result.response.token;
|
|
156
|
+
if (token != null) {
|
|
157
|
+
console.log(`OneTap Data: ${token}`);
|
|
158
|
+
// Process token and proceed.
|
|
159
|
+
}
|
|
160
|
+
break;
|
|
161
|
+
}
|
|
162
|
+
case "FALLBACK_TRIGGERED": {
|
|
163
|
+
// A fallback occurs when an OTP delivery attempt on one channel fails,
|
|
164
|
+
// and the system automatically retries via the subsequent channel selected on Otpless Dashboard.
|
|
165
|
+
// For example, if a merchant opts for SmartAuth with primary channal as WhatsApp and secondary channel as SMS,
|
|
166
|
+
// in that case, if OTP delivery on WhatsApp fails, the system will automatically retry via SMS.
|
|
167
|
+
// The response will contain the deliveryChannel to which the OTP has been sent.
|
|
168
|
+
if (response.response.deliveryChannel != null) {
|
|
169
|
+
const newDeliveryChannel = response.response.deliveryChannel
|
|
170
|
+
// This is the deliveryChannel to which the OTP has been sent
|
|
171
|
+
}
|
|
172
|
+
break;
|
|
173
|
+
}
|
|
174
|
+
default: {
|
|
175
|
+
console.warn(`Unknown response type: ${responseType}`);
|
|
176
|
+
break;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
};
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
## Android manifest update
|
|
184
|
+
Add Network Security Config inside your android/app/src/main/AndroidManifest.xml file into your <application> code block (Only required if you are using the SNA feature):
|
|
185
|
+
|
|
186
|
+
```xml
|
|
187
|
+
android:networkSecurityConfig="@xml/otpless_network_security_config"
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
## Ios info.plist update
|
|
191
|
+
|
|
192
|
+
Add the following block to your info.plist file (Only required if you are using the SNA feature):
|
|
193
|
+
|
|
194
|
+
```xml
|
|
195
|
+
<dict>
|
|
196
|
+
<key>NSAllowsArbitraryLoads</key>
|
|
197
|
+
<true/>
|
|
198
|
+
<key>NSExceptionDomains</key>
|
|
199
|
+
<dict>
|
|
200
|
+
<key>80.in.safr.sekuramobile.com</key>
|
|
201
|
+
<dict>
|
|
202
|
+
<key>NSIncludesSubdomains</key>
|
|
203
|
+
<true/>
|
|
204
|
+
<key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>
|
|
205
|
+
<true/>
|
|
206
|
+
<key>NSTemporaryExceptionMinimumTLSVersion</key>
|
|
207
|
+
<string>TLSv1.1</string>
|
|
208
|
+
</dict>
|
|
209
|
+
<key>partnerapi.jio.com</key>
|
|
210
|
+
<dict>
|
|
211
|
+
<key>NSIncludesSubdomains</key>
|
|
212
|
+
<true/>
|
|
213
|
+
<key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>
|
|
214
|
+
<true/>
|
|
215
|
+
<key>NSTemporaryExceptionMinimumTLSVersion</key>
|
|
216
|
+
<string>TLSv1.1</string>
|
|
217
|
+
</dict>
|
|
218
|
+
</dict>
|
|
219
|
+
</dict>
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
</br></br></br>
|
|
223
|
+
# Note
|
|
11
224
|
|
|
12
|
-
|
|
225
|
+
For complete documentation and other login feature explore, follow the following guide here: [installation guide here](https://otpless.com/docs/frontend-sdks/app-sdks/react-native/new/headless/headless)
|
|
13
226
|
|
|
14
227
|
## Author
|
|
15
228
|
|
package/android/build.gradle
CHANGED
|
@@ -74,7 +74,7 @@ dependencies {
|
|
|
74
74
|
//noinspection GradleDynamicVersion
|
|
75
75
|
implementation "com.facebook.react:react-native:+"
|
|
76
76
|
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
|
77
|
-
implementation ("io.github.otpless-tech:otpless-headless-sdk:0.
|
|
77
|
+
implementation ("io.github.otpless-tech:otpless-headless-sdk:0.3.0")
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
if (isNewArchitectureEnabled()) {
|
|
@@ -3,14 +3,16 @@ package com.otplessheadlessrn
|
|
|
3
3
|
import android.app.Activity
|
|
4
4
|
import android.content.Intent
|
|
5
5
|
import androidx.appcompat.app.AppCompatActivity
|
|
6
|
+
import androidx.fragment.app.FragmentActivity
|
|
6
7
|
import androidx.lifecycle.lifecycleScope
|
|
7
8
|
import com.facebook.react.bridge.ActivityEventListener
|
|
8
|
-
import com.facebook.react.bridge.
|
|
9
|
+
import com.facebook.react.bridge.Promise
|
|
9
10
|
import com.facebook.react.bridge.ReactApplicationContext
|
|
10
11
|
import com.facebook.react.bridge.ReactContextBaseJavaModule
|
|
11
12
|
import com.facebook.react.bridge.ReactMethod
|
|
12
13
|
import com.facebook.react.bridge.ReadableMap
|
|
13
14
|
import com.facebook.react.modules.core.DeviceEventManagerModule
|
|
15
|
+
import com.otpless.longclaw.tc.OTScopeRequest
|
|
14
16
|
import com.otpless.v2.android.sdk.dto.OtplessChannelType
|
|
15
17
|
import com.otpless.v2.android.sdk.dto.OtplessRequest
|
|
16
18
|
import com.otpless.v2.android.sdk.dto.OtplessResponse
|
|
@@ -59,12 +61,9 @@ class OtplessHeadlessRNModule(private val reactContext: ReactApplicationContext)
|
|
|
59
61
|
}
|
|
60
62
|
|
|
61
63
|
@ReactMethod
|
|
62
|
-
fun isWhatsappInstalled(
|
|
64
|
+
fun isWhatsappInstalled(promise: Promise) {
|
|
63
65
|
val hasWhatsapp = OtplessUtils.isWhatsAppInstalled(reactContext)
|
|
64
|
-
|
|
65
|
-
it.put("hasWhatsapp", hasWhatsapp)
|
|
66
|
-
}
|
|
67
|
-
callback.invoke(convertJsonToMap(json))
|
|
66
|
+
promise.resolve(hasWhatsapp)
|
|
68
67
|
}
|
|
69
68
|
|
|
70
69
|
@ReactMethod
|
|
@@ -78,6 +77,17 @@ class OtplessHeadlessRNModule(private val reactContext: ReactApplicationContext)
|
|
|
78
77
|
}
|
|
79
78
|
}
|
|
80
79
|
|
|
80
|
+
@ReactMethod
|
|
81
|
+
fun initTrueCaller(requestMap: ReadableMap, promise: Promise) {
|
|
82
|
+
val request = parseTrueCallerRequest(requestMap)
|
|
83
|
+
val scopes = parseTrueCallerScope(requestMap)
|
|
84
|
+
val result = OtplessSDK.initTrueCaller(currentActivity!!, request) {
|
|
85
|
+
OTScopeRequest.ActivityRequest(currentActivity as FragmentActivity, scopes)
|
|
86
|
+
}
|
|
87
|
+
debugLog("init truecaller result: $result")
|
|
88
|
+
promise.resolve(result)
|
|
89
|
+
}
|
|
90
|
+
|
|
81
91
|
@ReactMethod
|
|
82
92
|
fun start(data: ReadableMap) {
|
|
83
93
|
val otplessRequest = OtplessRequest()
|
|
@@ -151,6 +161,12 @@ class OtplessHeadlessRNModule(private val reactContext: ReactApplicationContext)
|
|
|
151
161
|
OtplessSDK.cleanup()
|
|
152
162
|
}
|
|
153
163
|
|
|
164
|
+
@ReactMethod
|
|
165
|
+
fun setDevLogging(devLogging: Boolean) {
|
|
166
|
+
debugLog("dev logging: $devLogging")
|
|
167
|
+
OtplessSDK.devLogging = devLogging
|
|
168
|
+
}
|
|
169
|
+
|
|
154
170
|
companion object {
|
|
155
171
|
const val NAME = "OtplessHeadlessRN"
|
|
156
172
|
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
package com.otplessheadlessrn
|
|
2
2
|
|
|
3
|
+
import android.graphics.Color
|
|
4
|
+
import android.util.Log
|
|
3
5
|
import com.facebook.react.bridge.ReadableArray
|
|
4
6
|
import com.facebook.react.bridge.ReadableMap
|
|
5
7
|
import com.facebook.react.bridge.ReadableType
|
|
@@ -7,9 +9,18 @@ import com.facebook.react.bridge.WritableArray
|
|
|
7
9
|
import com.facebook.react.bridge.WritableMap
|
|
8
10
|
import com.facebook.react.bridge.WritableNativeArray
|
|
9
11
|
import com.facebook.react.bridge.WritableNativeMap
|
|
12
|
+
import com.otpless.longclaw.tc.OTButtonShape
|
|
13
|
+
import com.otpless.longclaw.tc.OTCtaText
|
|
14
|
+
import com.otpless.longclaw.tc.OTFooterType
|
|
15
|
+
import com.otpless.longclaw.tc.OTHeadingConsent
|
|
16
|
+
import com.otpless.longclaw.tc.OTLoginPrefixText
|
|
17
|
+
import com.otpless.longclaw.tc.OTScope
|
|
18
|
+
import com.otpless.longclaw.tc.OTVerifyOption
|
|
19
|
+
import com.otpless.longclaw.tc.OtplessTruecallerRequest
|
|
10
20
|
import org.json.JSONArray
|
|
11
21
|
import org.json.JSONException
|
|
12
22
|
import org.json.JSONObject
|
|
23
|
+
import java.util.Locale
|
|
13
24
|
|
|
14
25
|
|
|
15
26
|
internal fun convertMapToJson(map: ReadableMap?): JSONObject? {
|
|
@@ -119,3 +130,87 @@ internal fun convertJsonToArray(jsonArray: JSONArray): WritableArray {
|
|
|
119
130
|
}
|
|
120
131
|
return array
|
|
121
132
|
}
|
|
133
|
+
|
|
134
|
+
internal fun parseTrueCallerRequest(requestMap: ReadableMap): OtplessTruecallerRequest {
|
|
135
|
+
val trueCallerRequestMap = requestMap.getMap("trueCallerRequest") ?: return OtplessTruecallerRequest()
|
|
136
|
+
// parsing footer type
|
|
137
|
+
val footerType: OTFooterType? = trueCallerRequestMap.getString("footerType")?.let { str ->
|
|
138
|
+
OTFooterType.values().firstOrNull { it.name.equals(str, ignoreCase = true) }
|
|
139
|
+
}
|
|
140
|
+
// parsing button shape
|
|
141
|
+
val shape: OTButtonShape? = trueCallerRequestMap.getString("shape")?.let { str ->
|
|
142
|
+
OTButtonShape.values().firstOrNull { it.name.equals(str, ignoreCase = true) }
|
|
143
|
+
}
|
|
144
|
+
// parsing verify option
|
|
145
|
+
val verifyOption: OTVerifyOption? = trueCallerRequestMap.getString("verifyOption")?.let { str ->
|
|
146
|
+
OTVerifyOption.values().firstOrNull { it.name.equals(str, ignoreCase = true) }
|
|
147
|
+
}
|
|
148
|
+
// parsing heading option
|
|
149
|
+
val heading: OTHeadingConsent? = trueCallerRequestMap.getString("heading")?.let { str ->
|
|
150
|
+
OTHeadingConsent.values().firstOrNull { it.name.equals(str, ignoreCase = true) }
|
|
151
|
+
}
|
|
152
|
+
// parsing login prefix text
|
|
153
|
+
val loginPrefixText: OTLoginPrefixText? = trueCallerRequestMap.getString("loginPrefixText")?.let { str ->
|
|
154
|
+
OTLoginPrefixText.values().firstOrNull { it.name.equals(str, ignoreCase = true) }
|
|
155
|
+
}
|
|
156
|
+
// parsing cta text
|
|
157
|
+
val ctaText: OTCtaText? = trueCallerRequestMap.getString("ctaText")?.let { str ->
|
|
158
|
+
OTCtaText.values().firstOrNull { it.name.equals(str, ignoreCase = true) }
|
|
159
|
+
}
|
|
160
|
+
// parsing locale
|
|
161
|
+
val locale: Locale? = trueCallerRequestMap.getString("locale")?.let { str ->
|
|
162
|
+
try {
|
|
163
|
+
parseLocale(str)
|
|
164
|
+
} catch (ignore: Exception) {
|
|
165
|
+
null
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
// parsing button color and button color text
|
|
169
|
+
val buttonColor: Int? = trueCallerRequestMap.getString("buttonColor")?.let { hex -> fromHexStringToInt(hex) }
|
|
170
|
+
val buttonTextColor: Int? = trueCallerRequestMap.getString("buttonTextColor")?.let { hex -> fromHexStringToInt(hex) }
|
|
171
|
+
// add the parsing logic for request map
|
|
172
|
+
return OtplessTruecallerRequest(
|
|
173
|
+
footerType = footerType, shape = shape, verifyOption = verifyOption, heading = heading,
|
|
174
|
+
loginPrefixText = loginPrefixText, ctaText = ctaText, locale = locale, buttonColor = buttonColor, buttonTextColor = buttonTextColor
|
|
175
|
+
)
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
internal fun fromHexStringToInt(hex: String): Int? = try {
|
|
179
|
+
Color.parseColor(hex)
|
|
180
|
+
} catch (ex: Exception) {
|
|
181
|
+
null
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
internal fun parseTrueCallerScope(requestMap: ReadableMap): List<OTScope> {
|
|
185
|
+
val scopeArray = requestMap.getArray("scope")
|
|
186
|
+
if (scopeArray != null && scopeArray.size() != 0) {
|
|
187
|
+
val scopes = mutableListOf<OTScope>()
|
|
188
|
+
for (index in 0 until scopeArray.size()) {
|
|
189
|
+
val value = scopeArray.getString(index)
|
|
190
|
+
val scopeType = OTScope.values().firstOrNull { it.name.equals(value, ignoreCase = true)} ?: continue
|
|
191
|
+
scopes.add(scopeType)
|
|
192
|
+
}
|
|
193
|
+
return scopes
|
|
194
|
+
} else {
|
|
195
|
+
return listOf(OTScope.OPEN_ID, OTScope.PHONE, OTScope.PROFILE)
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
private const val LOGTAG = "OtplessHeadlessRN"
|
|
201
|
+
|
|
202
|
+
internal fun debugLog(message: String) {
|
|
203
|
+
if (BuildConfig.DEBUG) {
|
|
204
|
+
Log.d(LOGTAG, message)
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
// locale parsing language and country
|
|
209
|
+
internal fun parseLocale(str: String): Locale? {
|
|
210
|
+
val parts = str.split('-', '_')
|
|
211
|
+
return if (parts.size == 2) {
|
|
212
|
+
Locale(parts[0], parts[1])
|
|
213
|
+
} else {
|
|
214
|
+
null
|
|
215
|
+
}
|
|
216
|
+
}
|
package/ios/OtplessHeadlessRN.m
CHANGED
|
@@ -11,8 +11,6 @@ RCT_EXTERN_METHOD(setResponseCallback)
|
|
|
11
11
|
|
|
12
12
|
RCT_EXTERN_METHOD(start:(NSDictionary *)request)
|
|
13
13
|
|
|
14
|
-
RCT_EXTERN_METHOD(enableDebugLogging:(BOOL)enable)
|
|
15
|
-
|
|
16
14
|
RCT_EXTERN_METHOD(commitResponse: (nullable NSDictionary *) response)
|
|
17
15
|
|
|
18
16
|
RCT_EXTERN_METHOD(cleanup)
|
|
@@ -25,5 +23,7 @@ RCT_EXTERN_METHOD(performOneTap: (NSDictionary *)request)
|
|
|
25
23
|
|
|
26
24
|
RCT_EXTERN_METHOD(authorizeViaPasskey: (NSDictionary *)request)
|
|
27
25
|
|
|
26
|
+
RCT_EXTERN_METHOD(setDevLogging:(BOOL)enable)
|
|
27
|
+
|
|
28
28
|
@end
|
|
29
29
|
|
|
@@ -78,8 +78,8 @@ class OtplessHeadlessRN: RCTEventEmitter, OtplessResponseDelegate {
|
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
-
@objc(
|
|
82
|
-
func
|
|
81
|
+
@objc(setDevLogging:)
|
|
82
|
+
func setDevLogging(enable: Bool) {
|
|
83
83
|
if enable {
|
|
84
84
|
Otpless.shared.setLoggerDelegate(self)
|
|
85
85
|
}
|
package/lib/commonjs/index.js
CHANGED
|
@@ -3,8 +3,23 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
var _exportNames = {
|
|
7
|
+
OtplessHeadlessModule: true
|
|
8
|
+
};
|
|
6
9
|
exports.OtplessHeadlessModule = void 0;
|
|
7
10
|
var _reactNative = require("react-native");
|
|
11
|
+
var _models = require("./models");
|
|
12
|
+
Object.keys(_models).forEach(function (key) {
|
|
13
|
+
if (key === "default" || key === "__esModule") return;
|
|
14
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
15
|
+
if (key in exports && exports[key] === _models[key]) return;
|
|
16
|
+
Object.defineProperty(exports, key, {
|
|
17
|
+
enumerable: true,
|
|
18
|
+
get: function () {
|
|
19
|
+
return _models[key];
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
});
|
|
8
23
|
const LINKING_ERROR = `The package 'otpless-headless-rn' doesn't seem to be linked. Make sure: \n\n` + _reactNative.Platform.select({
|
|
9
24
|
ios: "- You have run 'pod install'\n",
|
|
10
25
|
default: ''
|
|
@@ -44,13 +59,12 @@ class OtplessHeadlessModule {
|
|
|
44
59
|
}
|
|
45
60
|
|
|
46
61
|
// Checks if whatsapp is installed on android device
|
|
47
|
-
|
|
62
|
+
async isWhatsappInstalledForAndroid() {
|
|
48
63
|
if (_reactNative.Platform.OS === 'android') {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
return;
|
|
64
|
+
// Android-specific code
|
|
65
|
+
return await OtplessHeadlessRN.isWhatsappInstalled();
|
|
66
|
+
} else {
|
|
67
|
+
return false;
|
|
54
68
|
}
|
|
55
69
|
}
|
|
56
70
|
cleanup() {
|
|
@@ -61,6 +75,15 @@ class OtplessHeadlessModule {
|
|
|
61
75
|
OtplessHeadlessRN.decimateAll();
|
|
62
76
|
}
|
|
63
77
|
}
|
|
78
|
+
setDevLogging(enable) {
|
|
79
|
+
OtplessHeadlessRN.setDevLogging(enable);
|
|
80
|
+
}
|
|
81
|
+
async initTrueCaller(requestMap) {
|
|
82
|
+
if (_reactNative.Platform.OS === 'android') {
|
|
83
|
+
return await OtplessHeadlessRN.initTrueCaller(requestMap);
|
|
84
|
+
}
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
64
87
|
}
|
|
65
88
|
exports.OtplessHeadlessModule = OtplessHeadlessModule;
|
|
66
89
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNative","require","LINKING_ERROR","Platform","select","ios","default","OtplessHeadlessRN","NativeModules","Proxy","
|
|
1
|
+
{"version":3,"names":["_reactNative","require","_models","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","LINKING_ERROR","Platform","select","ios","default","OtplessHeadlessRN","NativeModules","Proxy","Error","OtplessHeadlessModule","eventEmitter","constructor","clearListener","_this$eventEmitter","removeAllListeners","initialize","appId","loginUri","NativeEventEmitter","setResponseCallback","callback","_this$eventEmitter2","addListener","start","input","commitResponse","response","isWhatsappInstalledForAndroid","OS","isWhatsappInstalled","cleanup","decimateAll","toLowerCase","setDevLogging","enable","initTrueCaller","requestMap"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AA8FA,IAAAC,OAAA,GAAAD,OAAA;AAAAE,MAAA,CAAAC,IAAA,CAAAF,OAAA,EAAAG,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAJ,OAAA,CAAAI,GAAA;EAAAH,MAAA,CAAAS,cA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AACc,mBAAmB,CAAC,CAAC;EACzC;EAEAI,KAAKA,CAACC,KAAU,EAAE;IAChBnB,iBAAiB,CAACkB,KAAK,CAACC,KAAK,CAAC;EAChC;EAEAC,cAAcA,CAACC,QAAa,EAAE;IAC5BrB,iBAAiB,CAACoB,cAAc,CAACC,QAAQ,CAAC;EAC5C;;EAEA;EACA,MAAMC,6BAA6BA,CAAA,EAAqB;IACtD,IAAI1B,qBAAQ,CAAC2B,EAAE,KAAK,SAAS,EAAE;MAC7B;MACA,OAAO,MAAMvB,iBAAiB,CAACwB,mBAAmB,CAAC,CAAC;IACtD,CAAC,MAAM;MACL,OAAO,KAAK;IACd;EACF;EAEAC,OAAOA,CAAA,EAAG;IACRzB,iBAAiB,CAACyB,OAAO,CAAC,CAAC;EAC7B;EAEAC,WAAWA,CAAA,EAAG;IACZ,IAAI9B,qBAAQ,CAAC2B,EAAE,CAACI,WAAW,CAAC,CAAC,KAAK,KAAK,EAAE;MACvC3B,iBAAiB,CAAC0B,WAAW,CAAC,CAAC;IACjC;EACF;EAEAE,aAAaA,CAACC,MAAe,EAAE;IAC7B7B,iBAAiB,CAAC4B,aAAa,CAACC,MAAM,CAAC;EACzC;EAEA,MAAMC,cAAcA,CAACC,UAAoC,EAAoB;IAC3E,IAAInC,qBAAQ,CAAC2B,EAAE,KAAK,SAAS,EAAE;MAC7B,OAAO,MAAMvB,iBAAiB,CAAC8B,cAAc,CAACC,UAAU,CAAC;IAC3D;IACA,OAAO,KAAK;EACd;AAEF;AAACxC,OAAA,CAAAa,qBAAA,GAAAA,qBAAA","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../src","sources":["models.tsx"],"mappings":"","ignoreList":[]}
|
package/lib/module/index.js
CHANGED
|
@@ -38,13 +38,12 @@ class OtplessHeadlessModule {
|
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
// Checks if whatsapp is installed on android device
|
|
41
|
-
|
|
41
|
+
async isWhatsappInstalledForAndroid() {
|
|
42
42
|
if (Platform.OS === 'android') {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
return;
|
|
43
|
+
// Android-specific code
|
|
44
|
+
return await OtplessHeadlessRN.isWhatsappInstalled();
|
|
45
|
+
} else {
|
|
46
|
+
return false;
|
|
48
47
|
}
|
|
49
48
|
}
|
|
50
49
|
cleanup() {
|
|
@@ -55,6 +54,16 @@ class OtplessHeadlessModule {
|
|
|
55
54
|
OtplessHeadlessRN.decimateAll();
|
|
56
55
|
}
|
|
57
56
|
}
|
|
57
|
+
setDevLogging(enable) {
|
|
58
|
+
OtplessHeadlessRN.setDevLogging(enable);
|
|
59
|
+
}
|
|
60
|
+
async initTrueCaller(requestMap) {
|
|
61
|
+
if (Platform.OS === 'android') {
|
|
62
|
+
return await OtplessHeadlessRN.initTrueCaller(requestMap);
|
|
63
|
+
}
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
58
66
|
}
|
|
59
67
|
export { OtplessHeadlessModule };
|
|
68
|
+
export * from './models';
|
|
60
69
|
//# sourceMappingURL=index.js.map
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["NativeModules","Platform","NativeEventEmitter","LINKING_ERROR","select","ios","default","OtplessHeadlessRN","Proxy","get","Error","OtplessHeadlessModule","eventEmitter","constructor","clearListener","_this$eventEmitter","removeAllListeners","initialize","appId","loginUri","setResponseCallback","callback","_this$eventEmitter2","addListener","start","input","commitResponse","response","
|
|
1
|
+
{"version":3,"names":["NativeModules","Platform","NativeEventEmitter","LINKING_ERROR","select","ios","default","OtplessHeadlessRN","Proxy","get","Error","OtplessHeadlessModule","eventEmitter","constructor","clearListener","_this$eventEmitter","removeAllListeners","initialize","appId","loginUri","setResponseCallback","callback","_this$eventEmitter2","addListener","start","input","commitResponse","response","isWhatsappInstalledForAndroid","OS","isWhatsappInstalled","cleanup","decimateAll","toLowerCase","setDevLogging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mBAAmB,CAAC,CAAC;EACzC;EAEAI,KAAKA,CAACC,KAAU,EAAE;IAChBlB,iBAAiB,CAACiB,KAAK,CAACC,KAAK,CAAC;EAChC;EAEAC,cAAcA,CAACC,QAAa,EAAE;IAC5BpB,iBAAiB,CAACmB,cAAc,CAACC,QAAQ,CAAC;EAC5C;;EAEA;EACA,MAAMC,6BAA6BA,CAAA,EAAqB;IACtD,IAAI3B,QAAQ,CAAC4B,EAAE,KAAK,SAAS,EAAE;MAC7B;MACA,OAAO,MAAMtB,iBAAiB,CAACuB,mBAAmB,CAAC,CAAC;IACtD,CAAC,MAAM;MACL,OAAO,KAAK;IACd;EACF;EAEAC,OAAOA,CAAA,EAAG;IACRxB,iBAAiB,CAACwB,OAAO,CAAC,CAAC;EAC7B;EAEAC,WAAWA,CAAA,EAAG;IACZ,IAAI/B,QAAQ,CAAC4B,EAAE,CAACI,WAAW,CAAC,CAAC,KAAK,KAAK,EAAE;MACvC1B,iBAAiB,CAACyB,WAAW,CAAC,CAAC;IACjC;EACF;EAEAE,aAAaA,CAACC,MAAe,EAAE;IAC7B5B,iBAAiB,CAAC2B,aAAa,CAACC,MAAM,CAAC;EACzC;EAEA,MAAMC,cAAcA,CAACC,UAAoC,EAAoB;IAC3E,IAAIpC,QAAQ,CAAC4B,EAAE,KAAK,SAAS,EAAE;MAC7B,OAAO,MAAMtB,iBAAiB,CAAC6B,cAAc,CAACC,UAAU,CAAC;IAC3D;IACA,OAAO,KAAK;EACd;AAEF;AAGA,SAAS1B,qBAAqB;AAC9B,cAAc,UAAU","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../src","sources":["models.tsx"],"mappings":"","ignoreList":[]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { OtplessTruecallerRequest } from './models';
|
|
1
2
|
interface OtplessResultCallback {
|
|
2
3
|
(result: any): void;
|
|
3
4
|
}
|
|
@@ -9,9 +10,12 @@ declare class OtplessHeadlessModule {
|
|
|
9
10
|
setResponseCallback(callback: OtplessResultCallback): void;
|
|
10
11
|
start(input: any): void;
|
|
11
12
|
commitResponse(response: any): void;
|
|
12
|
-
|
|
13
|
+
isWhatsappInstalledForAndroid(): Promise<boolean>;
|
|
13
14
|
cleanup(): void;
|
|
14
15
|
decimateAll(): void;
|
|
16
|
+
setDevLogging(enable: boolean): void;
|
|
17
|
+
initTrueCaller(requestMap: OtplessTruecallerRequest): Promise<boolean>;
|
|
15
18
|
}
|
|
16
19
|
export { OtplessHeadlessModule };
|
|
20
|
+
export * from './models';
|
|
17
21
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,UAAU,CAAC;AAqBzD,UAAU,qBAAqB;IAC7B,CAAC,MAAM,EAAE,GAAG,GAAG,IAAI,CAAC;CACrB;AAED,cAAM,qBAAqB;IACzB,OAAO,CAAC,YAAY,CAAmC;;IAMvD,aAAa;IAIb,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,GAAE,MAAM,GAAG,IAAW;IAQxD,mBAAmB,CAAC,QAAQ,EAAE,qBAAqB;IAMnD,KAAK,CAAC,KAAK,EAAE,GAAG;IAIhB,cAAc,CAAC,QAAQ,EAAE,GAAG;IAKtB,6BAA6B,IAAI,OAAO,CAAC,OAAO,CAAC;IASvD,OAAO;IAIP,WAAW;IAMX,aAAa,CAAC,MAAM,EAAE,OAAO;IAIvB,cAAc,CAAC,UAAU,EAAE,wBAAwB,GAAG,OAAO,CAAC,OAAO,CAAC;CAO7E;AAGD,OAAO,EAAE,qBAAqB,EAAE,CAAC;AACjC,cAAc,UAAU,CAAA"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export interface OtplessTruecallerRequest {
|
|
2
|
+
trueCallerRequest?: OtplessTruecallerConfig;
|
|
3
|
+
scope: Array<OTScope>;
|
|
4
|
+
}
|
|
5
|
+
export interface OtplessTruecallerConfig {
|
|
6
|
+
footerType?: OTFooterType;
|
|
7
|
+
shape?: OTButtonShape;
|
|
8
|
+
verifyOption?: OTVerifyOption;
|
|
9
|
+
heading?: OTHeadingConsent;
|
|
10
|
+
loginPrefixText?: OTLoginPrefixText;
|
|
11
|
+
ctaText?: OTCtaText;
|
|
12
|
+
locale?: string;
|
|
13
|
+
buttonColor?: number;
|
|
14
|
+
buttonTextColor?: number;
|
|
15
|
+
}
|
|
16
|
+
export type OTScope = "profile" | "phone" | "open_id" | "offline_access" | "email" | "address";
|
|
17
|
+
export type OTFooterType = 'footer_type_skip' | 'footer_type_another_mobile_no' | 'footer_type_another_method' | 'footer_type_manually' | 'footer_type_later';
|
|
18
|
+
export type OTButtonShape = 'button_shape_rounded' | 'button_shape_rectangle';
|
|
19
|
+
export type OTVerifyOption = 'option_verify_only_tc_users' | 'option_verify_all_users';
|
|
20
|
+
export type OTHeadingConsent = 'sdk_consent_heading_log_in_to' | 'sdk_consent_heading_sign_up_with' | 'sdk_consent_heading_sign_in_to' | 'sdk_consent_heading_verify_number_with' | 'sdk_consent_heading_register_with' | 'sdk_consent_heading_get_started_with' | 'sdk_consent_heading_proceed_with' | 'sdk_consent_heading_verify_with' | 'sdk_consent_heading_verify_profile_with' | 'sdk_consent_heading_verify_your_profile_with' | 'sdk_consent_heading_verify_phone_no_with' | 'sdk_consent_heading_verify_your_no_with' | 'sdk_consent_heading_continue_with' | 'sdk_consent_heading_complete_order_with' | 'sdk_consent_heading_place_order_with' | 'sdk_consent_heading_complete_booking_with' | 'sdk_consent_heading_checkout_with' | 'sdk_consent_heading_manage_details_with' | 'sdk_consent_heading_manage_your_details_with' | 'sdk_consent_heading_login_to_with_one_tap' | 'sdk_consent_heading_subscribe_to' | 'sdk_consent_heading_get_updates_from' | 'sdk_consent_heading_continue_reading_on' | 'sdk_consent_heading_get_new_updates_from' | 'sdk_consent_heading_login_signup_with';
|
|
21
|
+
export type OTLoginPrefixText = 'login_text_prefix_to_get_started' | 'login_text_prefix_to_continue' | 'login_text_prefix_to_place_order' | 'login_text_prefix_to_complete_your_purchase' | 'login_text_prefix_to_checkout' | 'login_text_prefix_to_complete_your_booking' | 'login_text_prefix_to_proceed_with_your_booking' | 'login_text_prefix_to_continue_with_your_booking' | 'login_text_prefix_to_get_details' | 'login_text_prefix_to_view_more' | 'login_text_prefix_to_continue_reading' | 'login_text_prefix_to_proceed' | 'login_text_prefix_for_new_updates' | 'login_text_prefix_to_get_updates' | 'login_text_prefix_to_subscribe' | 'login_text_prefix_to_subscribe_and_get_updates';
|
|
22
|
+
export type OTCtaText = 'cta_text_proceed' | 'cta_text_continue' | 'cta_text_accept' | 'cta_text_confirm';
|
|
23
|
+
//# sourceMappingURL=models.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"models.d.ts","sourceRoot":"","sources":["../../src/models.tsx"],"names":[],"mappings":"AACA,MAAM,WAAW,wBAAwB;IACrC,iBAAiB,CAAC,EAAE,uBAAuB,CAAC;IAC5C,KAAK,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;CACzB;AAGD,MAAM,WAAW,uBAAuB;IACtC,UAAU,CAAC,EAAE,YAAY,CAAC;IAC1B,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,YAAY,CAAC,EAAE,cAAc,CAAC;IAC9B,OAAO,CAAC,EAAE,gBAAgB,CAAC;IAC3B,eAAe,CAAC,EAAE,iBAAiB,CAAC;IACpC,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,MAAM,OAAO,GAAG,SAAS,GAAG,OA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dependency 'OtplessBM/Core', '1.1.6'
|
|
21
21
|
s.swift_versions = ['5.5']
|
|
22
22
|
|
|
23
23
|
# Don't install the dependencies when we run `pod install` in the old architecture.
|
package/package.json
CHANGED
package/src/index.tsx
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { NativeModules, Platform, NativeEventEmitter } from 'react-native';
|
|
2
|
+
import type { OtplessTruecallerRequest } from './models';
|
|
3
|
+
|
|
2
4
|
|
|
3
5
|
|
|
4
6
|
const LINKING_ERROR =
|
|
@@ -56,13 +58,12 @@ class OtplessHeadlessModule {
|
|
|
56
58
|
}
|
|
57
59
|
|
|
58
60
|
// Checks if whatsapp is installed on android device
|
|
59
|
-
|
|
61
|
+
async isWhatsappInstalledForAndroid(): Promise<boolean> {
|
|
60
62
|
if (Platform.OS === 'android') {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
return
|
|
63
|
+
// Android-specific code
|
|
64
|
+
return await OtplessHeadlessRN.isWhatsappInstalled()
|
|
65
|
+
} else {
|
|
66
|
+
return false
|
|
66
67
|
}
|
|
67
68
|
}
|
|
68
69
|
|
|
@@ -75,6 +76,20 @@ class OtplessHeadlessModule {
|
|
|
75
76
|
OtplessHeadlessRN.decimateAll();
|
|
76
77
|
}
|
|
77
78
|
}
|
|
79
|
+
|
|
80
|
+
setDevLogging(enable: boolean) {
|
|
81
|
+
OtplessHeadlessRN.setDevLogging(enable)
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
async initTrueCaller(requestMap: OtplessTruecallerRequest): Promise<boolean> {
|
|
85
|
+
if (Platform.OS === 'android') {
|
|
86
|
+
return await OtplessHeadlessRN.initTrueCaller(requestMap);
|
|
87
|
+
}
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
|
|
78
91
|
}
|
|
79
92
|
|
|
93
|
+
|
|
80
94
|
export { OtplessHeadlessModule };
|
|
95
|
+
export * from './models'
|
package/src/models.tsx
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
|
|
2
|
+
export interface OtplessTruecallerRequest {
|
|
3
|
+
trueCallerRequest?: OtplessTruecallerConfig;
|
|
4
|
+
scope: Array<OTScope>;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
export interface OtplessTruecallerConfig {
|
|
9
|
+
footerType?: OTFooterType;
|
|
10
|
+
shape?: OTButtonShape;
|
|
11
|
+
verifyOption?: OTVerifyOption;
|
|
12
|
+
heading?: OTHeadingConsent;
|
|
13
|
+
loginPrefixText?: OTLoginPrefixText;
|
|
14
|
+
ctaText?: OTCtaText;
|
|
15
|
+
locale?: string; // assuming this is a locale string like 'en-US'
|
|
16
|
+
buttonColor?: number; // assuming Int maps to a numeric type (e.g. hex color)
|
|
17
|
+
buttonTextColor?: number;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export type OTScope = "profile" | "phone" | "open_id" | "offline_access" | "email" | "address";
|
|
21
|
+
|
|
22
|
+
export type OTFooterType =
|
|
23
|
+
| 'footer_type_skip'
|
|
24
|
+
| 'footer_type_another_mobile_no'
|
|
25
|
+
| 'footer_type_another_method'
|
|
26
|
+
| 'footer_type_manually'
|
|
27
|
+
| 'footer_type_later';
|
|
28
|
+
|
|
29
|
+
export type OTButtonShape =
|
|
30
|
+
| 'button_shape_rounded'
|
|
31
|
+
| 'button_shape_rectangle';
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
export type OTVerifyOption =
|
|
35
|
+
| 'option_verify_only_tc_users'
|
|
36
|
+
| 'option_verify_all_users';
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
export type OTHeadingConsent =
|
|
40
|
+
| 'sdk_consent_heading_log_in_to'
|
|
41
|
+
| 'sdk_consent_heading_sign_up_with'
|
|
42
|
+
| 'sdk_consent_heading_sign_in_to'
|
|
43
|
+
| 'sdk_consent_heading_verify_number_with'
|
|
44
|
+
| 'sdk_consent_heading_register_with'
|
|
45
|
+
| 'sdk_consent_heading_get_started_with'
|
|
46
|
+
| 'sdk_consent_heading_proceed_with'
|
|
47
|
+
| 'sdk_consent_heading_verify_with'
|
|
48
|
+
| 'sdk_consent_heading_verify_profile_with'
|
|
49
|
+
| 'sdk_consent_heading_verify_your_profile_with'
|
|
50
|
+
| 'sdk_consent_heading_verify_phone_no_with'
|
|
51
|
+
| 'sdk_consent_heading_verify_your_no_with'
|
|
52
|
+
| 'sdk_consent_heading_continue_with'
|
|
53
|
+
| 'sdk_consent_heading_complete_order_with'
|
|
54
|
+
| 'sdk_consent_heading_place_order_with'
|
|
55
|
+
| 'sdk_consent_heading_complete_booking_with'
|
|
56
|
+
| 'sdk_consent_heading_checkout_with'
|
|
57
|
+
| 'sdk_consent_heading_manage_details_with'
|
|
58
|
+
| 'sdk_consent_heading_manage_your_details_with'
|
|
59
|
+
| 'sdk_consent_heading_login_to_with_one_tap'
|
|
60
|
+
| 'sdk_consent_heading_subscribe_to'
|
|
61
|
+
| 'sdk_consent_heading_get_updates_from'
|
|
62
|
+
| 'sdk_consent_heading_continue_reading_on'
|
|
63
|
+
| 'sdk_consent_heading_get_new_updates_from'
|
|
64
|
+
| 'sdk_consent_heading_login_signup_with';
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
export type OTLoginPrefixText =
|
|
68
|
+
| 'login_text_prefix_to_get_started'
|
|
69
|
+
| 'login_text_prefix_to_continue'
|
|
70
|
+
| 'login_text_prefix_to_place_order'
|
|
71
|
+
| 'login_text_prefix_to_complete_your_purchase'
|
|
72
|
+
| 'login_text_prefix_to_checkout'
|
|
73
|
+
| 'login_text_prefix_to_complete_your_booking'
|
|
74
|
+
| 'login_text_prefix_to_proceed_with_your_booking'
|
|
75
|
+
| 'login_text_prefix_to_continue_with_your_booking'
|
|
76
|
+
| 'login_text_prefix_to_get_details'
|
|
77
|
+
| 'login_text_prefix_to_view_more'
|
|
78
|
+
| 'login_text_prefix_to_continue_reading'
|
|
79
|
+
| 'login_text_prefix_to_proceed'
|
|
80
|
+
| 'login_text_prefix_for_new_updates'
|
|
81
|
+
| 'login_text_prefix_to_get_updates'
|
|
82
|
+
| 'login_text_prefix_to_subscribe'
|
|
83
|
+
| 'login_text_prefix_to_subscribe_and_get_updates';
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
export type OTCtaText =
|
|
87
|
+
| 'cta_text_proceed'
|
|
88
|
+
| 'cta_text_continue'
|
|
89
|
+
| 'cta_text_accept'
|
|
90
|
+
| 'cta_text_confirm';
|
|
Binary file
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
3
|
-
<plist version="1.0">
|
|
4
|
-
<dict>
|
|
5
|
-
<key>SchemeUserState</key>
|
|
6
|
-
<dict>
|
|
7
|
-
<key>OtplessReactNative.xcscheme_^#shared#^_</key>
|
|
8
|
-
<dict>
|
|
9
|
-
<key>orderHint</key>
|
|
10
|
-
<integer>0</integer>
|
|
11
|
-
</dict>
|
|
12
|
-
</dict>
|
|
13
|
-
</dict>
|
|
14
|
-
</plist>
|