@capgo/capacitor-verisoul 8.0.1
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/CapgoCapacitorVerisoul.podspec +18 -0
- package/LICENSE +373 -0
- package/Package.swift +30 -0
- package/README.md +179 -0
- package/android/build.gradle +76 -0
- package/android/src/main/AndroidManifest.xml +4 -0
- package/android/src/main/kotlin/app/capgo/verisoul/Verisoul.kt +45 -0
- package/android/src/main/kotlin/app/capgo/verisoul/VerisoulErrorCodes.kt +7 -0
- package/android/src/main/kotlin/app/capgo/verisoul/VerisoulPlugin.kt +120 -0
- package/android/src/main/res/.gitkeep +0 -0
- package/dist/docs.json +206 -0
- package/dist/esm/definitions.d.ts +63 -0
- package/dist/esm/definitions.js +2 -0
- package/dist/esm/definitions.js.map +1 -0
- package/dist/esm/index.d.ts +4 -0
- package/dist/esm/index.js +7 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/web.d.ts +8 -0
- package/dist/esm/web.js +18 -0
- package/dist/esm/web.js.map +1 -0
- package/dist/plugin.cjs.js +30 -0
- package/dist/plugin.cjs.js.map +1 -0
- package/dist/plugin.js +33 -0
- package/dist/plugin.js.map +1 -0
- package/ios/Sources/VerisoulPlugin/Verisoul.swift +39 -0
- package/ios/Sources/VerisoulPlugin/VerisoulPlugin.swift +68 -0
- package/ios/Tests/VerisoulPluginTests/VerisoulTests.swift +10 -0
- package/package.json +88 -0
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
package app.capgo.verisoul
|
|
2
|
+
|
|
3
|
+
import ai.verisoul.sdk.InternalVerisoulCore
|
|
4
|
+
import ai.verisoul.sdk.SDKType
|
|
5
|
+
import ai.verisoul.sdk.Verisoul
|
|
6
|
+
import ai.verisoul.sdk.VerisoulEnvironment
|
|
7
|
+
import ai.verisoul.sdk.helpers.webview.VerisoulSessionCallback
|
|
8
|
+
import android.content.Context
|
|
9
|
+
import android.view.MotionEvent
|
|
10
|
+
|
|
11
|
+
class VerisoulBridge(private val context: Context) {
|
|
12
|
+
|
|
13
|
+
private val environments = mapOf(
|
|
14
|
+
"dev" to VerisoulEnvironment.Dev,
|
|
15
|
+
"prod" to VerisoulEnvironment.Prod,
|
|
16
|
+
"production" to VerisoulEnvironment.Prod,
|
|
17
|
+
"sandbox" to VerisoulEnvironment.Sandbox,
|
|
18
|
+
"staging" to VerisoulEnvironment.Sandbox,
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
fun configure(environment: String, projectId: String) {
|
|
22
|
+
val env = environments[environment] ?: throw IllegalArgumentException("Invalid environment value: $environment")
|
|
23
|
+
|
|
24
|
+
InternalVerisoulCore.sdkType = SDKType.ReactNative
|
|
25
|
+
Verisoul.init(context, env, projectId)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
fun getSessionId(callback: VerisoulSessionCallback) {
|
|
29
|
+
Verisoul.getSessionId(callback)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
fun reinitialize() {
|
|
33
|
+
Verisoul.reinitialize()
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
fun recordTouchEvent(x: Float, y: Float, action: Int) {
|
|
37
|
+
val now = System.currentTimeMillis()
|
|
38
|
+
val event = MotionEvent.obtain(now, now, action, x, y, 0)
|
|
39
|
+
try {
|
|
40
|
+
Verisoul.onTouchEvent(event)
|
|
41
|
+
} finally {
|
|
42
|
+
event.recycle()
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
package app.capgo.verisoul
|
|
2
|
+
|
|
3
|
+
import ai.verisoul.sdk.VerisoulException
|
|
4
|
+
import ai.verisoul.sdk.helpers.webview.VerisoulSessionCallback
|
|
5
|
+
import com.getcapacitor.JSObject
|
|
6
|
+
import com.getcapacitor.Plugin
|
|
7
|
+
import com.getcapacitor.PluginCall
|
|
8
|
+
import com.getcapacitor.PluginMethod
|
|
9
|
+
import com.getcapacitor.annotation.CapacitorPlugin
|
|
10
|
+
import android.view.MotionEvent
|
|
11
|
+
|
|
12
|
+
@CapacitorPlugin(name = "Verisoul")
|
|
13
|
+
class VerisoulPlugin : Plugin() {
|
|
14
|
+
|
|
15
|
+
private val implementation by lazy { VerisoulBridge(context) }
|
|
16
|
+
|
|
17
|
+
@PluginMethod
|
|
18
|
+
fun configure(call: PluginCall) {
|
|
19
|
+
val environment = call.getString("environment")
|
|
20
|
+
val projectId = call.getString("projectId")
|
|
21
|
+
|
|
22
|
+
if (environment.isNullOrBlank()) {
|
|
23
|
+
call.reject("environment is required", VerisoulErrorCodes.INVALID_ENVIRONMENT)
|
|
24
|
+
return
|
|
25
|
+
}
|
|
26
|
+
if (projectId.isNullOrBlank()) {
|
|
27
|
+
call.reject("projectId is required")
|
|
28
|
+
return
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
try {
|
|
32
|
+
implementation.configure(environment, projectId)
|
|
33
|
+
call.resolve()
|
|
34
|
+
} catch (exception: Throwable) {
|
|
35
|
+
rejectVerisoul(call, "SDK configuration failed", exception)
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
@PluginMethod
|
|
40
|
+
fun getSessionId(call: PluginCall) {
|
|
41
|
+
try {
|
|
42
|
+
implementation.getSessionId(object : VerisoulSessionCallback {
|
|
43
|
+
override fun onFailure(exception: Throwable) {
|
|
44
|
+
rejectVerisoul(call, "Failed to retrieve session ID", exception)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
override fun onSuccess(sessionId: String) {
|
|
48
|
+
val ret = JSObject().apply {
|
|
49
|
+
put("sessionId", sessionId)
|
|
50
|
+
}
|
|
51
|
+
call.resolve(ret)
|
|
52
|
+
}
|
|
53
|
+
})
|
|
54
|
+
} catch (exception: Throwable) {
|
|
55
|
+
rejectVerisoul(call, "Failed to retrieve session ID", exception)
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
@PluginMethod
|
|
60
|
+
fun reinitialize(call: PluginCall) {
|
|
61
|
+
try {
|
|
62
|
+
implementation.reinitialize()
|
|
63
|
+
call.resolve()
|
|
64
|
+
} catch (exception: Throwable) {
|
|
65
|
+
rejectVerisoul(call, "Failed to reinitialize SDK", exception)
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
@PluginMethod
|
|
70
|
+
fun recordTouchEvent(call: PluginCall) {
|
|
71
|
+
val x = call.getFloat("x")
|
|
72
|
+
val y = call.getFloat("y")
|
|
73
|
+
val action = parseAction(call.getString("action"), call.getInt("action"))
|
|
74
|
+
|
|
75
|
+
if (x == null || y == null || action == null) {
|
|
76
|
+
call.reject("x, y, and action are required")
|
|
77
|
+
return
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
try {
|
|
81
|
+
implementation.recordTouchEvent(x, y, action)
|
|
82
|
+
call.resolve()
|
|
83
|
+
} catch (exception: Throwable) {
|
|
84
|
+
rejectVerisoul(call, "Failed to record touch event", exception)
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
private fun parseAction(actionString: String?, actionInt: Int?): Int? {
|
|
89
|
+
return when (actionString) {
|
|
90
|
+
"down" -> MotionEvent.ACTION_DOWN
|
|
91
|
+
"up" -> MotionEvent.ACTION_UP
|
|
92
|
+
"move" -> MotionEvent.ACTION_MOVE
|
|
93
|
+
else -> when (actionInt) {
|
|
94
|
+
0 -> MotionEvent.ACTION_DOWN
|
|
95
|
+
1 -> MotionEvent.ACTION_UP
|
|
96
|
+
2 -> MotionEvent.ACTION_MOVE
|
|
97
|
+
else -> null
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
private fun rejectVerisoul(call: PluginCall, prefix: String, exception: Throwable) {
|
|
103
|
+
val code = (exception as? VerisoulException)?.code ?: errorCodeFromMessage(exception)
|
|
104
|
+
call.reject("$prefix: ${exception.message}", code, exception.asException())
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
private fun errorCodeFromMessage(exception: Throwable): String {
|
|
108
|
+
val message = exception.message.orEmpty().uppercase()
|
|
109
|
+
return when {
|
|
110
|
+
message.contains("ENVIRONMENT") -> VerisoulErrorCodes.INVALID_ENVIRONMENT
|
|
111
|
+
message.contains("WEBVIEW") -> VerisoulErrorCodes.WEBVIEW_UNAVAILABLE
|
|
112
|
+
message.contains("SESSION") -> VerisoulErrorCodes.SESSION_UNAVAILABLE
|
|
113
|
+
else -> "UNKNOWN_ERROR"
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
private fun Throwable.asException(): Exception {
|
|
118
|
+
return this as? Exception ?: Exception(this)
|
|
119
|
+
}
|
|
120
|
+
}
|
|
File without changes
|
package/dist/docs.json
ADDED
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
{
|
|
2
|
+
"api": {
|
|
3
|
+
"name": "VerisoulPlugin",
|
|
4
|
+
"slug": "verisoulplugin",
|
|
5
|
+
"docs": "",
|
|
6
|
+
"tags": [],
|
|
7
|
+
"methods": [
|
|
8
|
+
{
|
|
9
|
+
"name": "configure",
|
|
10
|
+
"signature": "(options: ConfigureOptions) => Promise<void>",
|
|
11
|
+
"parameters": [
|
|
12
|
+
{
|
|
13
|
+
"name": "options",
|
|
14
|
+
"docs": "",
|
|
15
|
+
"type": "ConfigureOptions"
|
|
16
|
+
}
|
|
17
|
+
],
|
|
18
|
+
"returns": "Promise<void>",
|
|
19
|
+
"tags": [],
|
|
20
|
+
"docs": "Initialize Verisoul. Call this once, early in app startup.",
|
|
21
|
+
"complexTypes": [
|
|
22
|
+
"ConfigureOptions"
|
|
23
|
+
],
|
|
24
|
+
"slug": "configure"
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"name": "getSessionId",
|
|
28
|
+
"signature": "() => Promise<SessionIdResult>",
|
|
29
|
+
"parameters": [],
|
|
30
|
+
"returns": "Promise<SessionIdResult>",
|
|
31
|
+
"tags": [],
|
|
32
|
+
"docs": "Return the current Verisoul session identifier.\n\nThe value may take a few seconds to become available after `configure()`.",
|
|
33
|
+
"complexTypes": [
|
|
34
|
+
"SessionIdResult"
|
|
35
|
+
],
|
|
36
|
+
"slug": "getsessionid"
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"name": "reinitialize",
|
|
40
|
+
"signature": "() => Promise<void>",
|
|
41
|
+
"parameters": [],
|
|
42
|
+
"returns": "Promise<void>",
|
|
43
|
+
"tags": [],
|
|
44
|
+
"docs": "Reset Verisoul signal collection and create a fresh session.\n\nUse this when account context changes, for example after logout/login.",
|
|
45
|
+
"complexTypes": [],
|
|
46
|
+
"slug": "reinitialize"
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
"name": "recordTouchEvent",
|
|
50
|
+
"signature": "(options: RecordTouchEventOptions) => Promise<void>",
|
|
51
|
+
"parameters": [
|
|
52
|
+
{
|
|
53
|
+
"name": "options",
|
|
54
|
+
"docs": "",
|
|
55
|
+
"type": "RecordTouchEventOptions"
|
|
56
|
+
}
|
|
57
|
+
],
|
|
58
|
+
"returns": "Promise<void>",
|
|
59
|
+
"tags": [],
|
|
60
|
+
"docs": "Forward a touch event to Verisoul.\n\nAndroid uses this for bot-detection touch signals. iOS resolves without\nwork because the iOS SDK does not expose a matching public API.",
|
|
61
|
+
"complexTypes": [
|
|
62
|
+
"RecordTouchEventOptions"
|
|
63
|
+
],
|
|
64
|
+
"slug": "recordtouchevent"
|
|
65
|
+
}
|
|
66
|
+
],
|
|
67
|
+
"properties": []
|
|
68
|
+
},
|
|
69
|
+
"interfaces": [
|
|
70
|
+
{
|
|
71
|
+
"name": "ConfigureOptions",
|
|
72
|
+
"slug": "configureoptions",
|
|
73
|
+
"docs": "",
|
|
74
|
+
"tags": [],
|
|
75
|
+
"methods": [],
|
|
76
|
+
"properties": [
|
|
77
|
+
{
|
|
78
|
+
"name": "environment",
|
|
79
|
+
"tags": [],
|
|
80
|
+
"docs": "Verisoul project environment.\n\nUse `prod` or `production` for production traffic and `sandbox` for testing.",
|
|
81
|
+
"complexTypes": [
|
|
82
|
+
"VerisoulEnvironment"
|
|
83
|
+
],
|
|
84
|
+
"type": "VerisoulEnvironment"
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
"name": "projectId",
|
|
88
|
+
"tags": [],
|
|
89
|
+
"docs": "Verisoul project identifier.",
|
|
90
|
+
"complexTypes": [],
|
|
91
|
+
"type": "string"
|
|
92
|
+
}
|
|
93
|
+
]
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
"name": "SessionIdResult",
|
|
97
|
+
"slug": "sessionidresult",
|
|
98
|
+
"docs": "",
|
|
99
|
+
"tags": [],
|
|
100
|
+
"methods": [],
|
|
101
|
+
"properties": [
|
|
102
|
+
{
|
|
103
|
+
"name": "sessionId",
|
|
104
|
+
"tags": [],
|
|
105
|
+
"docs": "Verisoul session identifier. Send this value to your backend before calling\nVerisoul's server-side assessment APIs.",
|
|
106
|
+
"complexTypes": [],
|
|
107
|
+
"type": "string"
|
|
108
|
+
}
|
|
109
|
+
]
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
"name": "RecordTouchEventOptions",
|
|
113
|
+
"slug": "recordtoucheventoptions",
|
|
114
|
+
"docs": "",
|
|
115
|
+
"tags": [],
|
|
116
|
+
"methods": [],
|
|
117
|
+
"properties": [
|
|
118
|
+
{
|
|
119
|
+
"name": "x",
|
|
120
|
+
"tags": [],
|
|
121
|
+
"docs": "Touch X coordinate in view pixels.",
|
|
122
|
+
"complexTypes": [],
|
|
123
|
+
"type": "number"
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
"name": "y",
|
|
127
|
+
"tags": [],
|
|
128
|
+
"docs": "Touch Y coordinate in view pixels.",
|
|
129
|
+
"complexTypes": [],
|
|
130
|
+
"type": "number"
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
"name": "action",
|
|
134
|
+
"tags": [],
|
|
135
|
+
"docs": "Touch action. Android forwards this to the native Verisoul SDK.\n\niOS currently ignores this method because the Verisoul iOS SDK does not\nexpose the same public touch-event hook.",
|
|
136
|
+
"complexTypes": [
|
|
137
|
+
"VerisoulTouchAction"
|
|
138
|
+
],
|
|
139
|
+
"type": "VerisoulTouchAction"
|
|
140
|
+
}
|
|
141
|
+
]
|
|
142
|
+
}
|
|
143
|
+
],
|
|
144
|
+
"enums": [],
|
|
145
|
+
"typeAliases": [
|
|
146
|
+
{
|
|
147
|
+
"name": "VerisoulEnvironment",
|
|
148
|
+
"slug": "verisoulenvironment",
|
|
149
|
+
"docs": "",
|
|
150
|
+
"types": [
|
|
151
|
+
{
|
|
152
|
+
"text": "'dev'",
|
|
153
|
+
"complexTypes": []
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
"text": "'sandbox'",
|
|
157
|
+
"complexTypes": []
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
"text": "'staging'",
|
|
161
|
+
"complexTypes": []
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
"text": "'prod'",
|
|
165
|
+
"complexTypes": []
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
"text": "'production'",
|
|
169
|
+
"complexTypes": []
|
|
170
|
+
}
|
|
171
|
+
]
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
"name": "VerisoulTouchAction",
|
|
175
|
+
"slug": "verisoultouchaction",
|
|
176
|
+
"docs": "",
|
|
177
|
+
"types": [
|
|
178
|
+
{
|
|
179
|
+
"text": "'down'",
|
|
180
|
+
"complexTypes": []
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
"text": "'up'",
|
|
184
|
+
"complexTypes": []
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
"text": "'move'",
|
|
188
|
+
"complexTypes": []
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
"text": "0",
|
|
192
|
+
"complexTypes": []
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
"text": "1",
|
|
196
|
+
"complexTypes": []
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
"text": "2",
|
|
200
|
+
"complexTypes": []
|
|
201
|
+
}
|
|
202
|
+
]
|
|
203
|
+
}
|
|
204
|
+
],
|
|
205
|
+
"pluginConfigs": []
|
|
206
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
export type VerisoulEnvironment = 'dev' | 'sandbox' | 'staging' | 'prod' | 'production';
|
|
2
|
+
export type VerisoulTouchAction = 'down' | 'up' | 'move' | 0 | 1 | 2;
|
|
3
|
+
export interface ConfigureOptions {
|
|
4
|
+
/**
|
|
5
|
+
* Verisoul project environment.
|
|
6
|
+
*
|
|
7
|
+
* Use `prod` or `production` for production traffic and `sandbox` for testing.
|
|
8
|
+
*/
|
|
9
|
+
environment: VerisoulEnvironment;
|
|
10
|
+
/**
|
|
11
|
+
* Verisoul project identifier.
|
|
12
|
+
*/
|
|
13
|
+
projectId: string;
|
|
14
|
+
}
|
|
15
|
+
export interface SessionIdResult {
|
|
16
|
+
/**
|
|
17
|
+
* Verisoul session identifier. Send this value to your backend before calling
|
|
18
|
+
* Verisoul's server-side assessment APIs.
|
|
19
|
+
*/
|
|
20
|
+
sessionId: string;
|
|
21
|
+
}
|
|
22
|
+
export interface RecordTouchEventOptions {
|
|
23
|
+
/**
|
|
24
|
+
* Touch X coordinate in view pixels.
|
|
25
|
+
*/
|
|
26
|
+
x: number;
|
|
27
|
+
/**
|
|
28
|
+
* Touch Y coordinate in view pixels.
|
|
29
|
+
*/
|
|
30
|
+
y: number;
|
|
31
|
+
/**
|
|
32
|
+
* Touch action. Android forwards this to the native Verisoul SDK.
|
|
33
|
+
*
|
|
34
|
+
* iOS currently ignores this method because the Verisoul iOS SDK does not
|
|
35
|
+
* expose the same public touch-event hook.
|
|
36
|
+
*/
|
|
37
|
+
action: VerisoulTouchAction;
|
|
38
|
+
}
|
|
39
|
+
export interface VerisoulPlugin {
|
|
40
|
+
/**
|
|
41
|
+
* Initialize Verisoul. Call this once, early in app startup.
|
|
42
|
+
*/
|
|
43
|
+
configure(options: ConfigureOptions): Promise<void>;
|
|
44
|
+
/**
|
|
45
|
+
* Return the current Verisoul session identifier.
|
|
46
|
+
*
|
|
47
|
+
* The value may take a few seconds to become available after `configure()`.
|
|
48
|
+
*/
|
|
49
|
+
getSessionId(): Promise<SessionIdResult>;
|
|
50
|
+
/**
|
|
51
|
+
* Reset Verisoul signal collection and create a fresh session.
|
|
52
|
+
*
|
|
53
|
+
* Use this when account context changes, for example after logout/login.
|
|
54
|
+
*/
|
|
55
|
+
reinitialize(): Promise<void>;
|
|
56
|
+
/**
|
|
57
|
+
* Forward a touch event to Verisoul.
|
|
58
|
+
*
|
|
59
|
+
* Android uses this for bot-detection touch signals. iOS resolves without
|
|
60
|
+
* work because the iOS SDK does not expose a matching public API.
|
|
61
|
+
*/
|
|
62
|
+
recordTouchEvent(options: RecordTouchEventOptions): Promise<void>;
|
|
63
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["export type VerisoulEnvironment = 'dev' | 'sandbox' | 'staging' | 'prod' | 'production';\n\nexport type VerisoulTouchAction = 'down' | 'up' | 'move' | 0 | 1 | 2;\n\nexport interface ConfigureOptions {\n /**\n * Verisoul project environment.\n *\n * Use `prod` or `production` for production traffic and `sandbox` for testing.\n */\n environment: VerisoulEnvironment;\n\n /**\n * Verisoul project identifier.\n */\n projectId: string;\n}\n\nexport interface SessionIdResult {\n /**\n * Verisoul session identifier. Send this value to your backend before calling\n * Verisoul's server-side assessment APIs.\n */\n sessionId: string;\n}\n\nexport interface RecordTouchEventOptions {\n /**\n * Touch X coordinate in view pixels.\n */\n x: number;\n\n /**\n * Touch Y coordinate in view pixels.\n */\n y: number;\n\n /**\n * Touch action. Android forwards this to the native Verisoul SDK.\n *\n * iOS currently ignores this method because the Verisoul iOS SDK does not\n * expose the same public touch-event hook.\n */\n action: VerisoulTouchAction;\n}\n\nexport interface VerisoulPlugin {\n /**\n * Initialize Verisoul. Call this once, early in app startup.\n */\n configure(options: ConfigureOptions): Promise<void>;\n\n /**\n * Return the current Verisoul session identifier.\n *\n * The value may take a few seconds to become available after `configure()`.\n */\n getSessionId(): Promise<SessionIdResult>;\n\n /**\n * Reset Verisoul signal collection and create a fresh session.\n *\n * Use this when account context changes, for example after logout/login.\n */\n reinitialize(): Promise<void>;\n\n /**\n * Forward a touch event to Verisoul.\n *\n * Android uses this for bot-detection touch signals. iOS resolves without\n * work because the iOS SDK does not expose a matching public API.\n */\n recordTouchEvent(options: RecordTouchEventOptions): Promise<void>;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAIjD,MAAM,QAAQ,GAAG,cAAc,CAAiB,UAAU,EAAE;IAC1D,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,CAAC;CAC5D,CAAC,CAAC;AAEH,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,QAAQ,EAAE,CAAC","sourcesContent":["import { registerPlugin } from '@capacitor/core';\n\nimport type { VerisoulPlugin } from './definitions';\n\nconst Verisoul = registerPlugin<VerisoulPlugin>('Verisoul', {\n web: () => import('./web').then((m) => new m.VerisoulWeb()),\n});\n\nexport * from './definitions';\nexport { Verisoul };\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { WebPlugin } from '@capacitor/core';
|
|
2
|
+
import type { ConfigureOptions, RecordTouchEventOptions, SessionIdResult, VerisoulPlugin } from './definitions';
|
|
3
|
+
export declare class VerisoulWeb extends WebPlugin implements VerisoulPlugin {
|
|
4
|
+
configure(_options: ConfigureOptions): Promise<void>;
|
|
5
|
+
getSessionId(): Promise<SessionIdResult>;
|
|
6
|
+
reinitialize(): Promise<void>;
|
|
7
|
+
recordTouchEvent(_options: RecordTouchEventOptions): Promise<void>;
|
|
8
|
+
}
|
package/dist/esm/web.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { WebPlugin } from '@capacitor/core';
|
|
2
|
+
export class VerisoulWeb extends WebPlugin {
|
|
3
|
+
async configure(_options) {
|
|
4
|
+
void _options;
|
|
5
|
+
throw this.unimplemented('Verisoul native SDK is not available on web.');
|
|
6
|
+
}
|
|
7
|
+
async getSessionId() {
|
|
8
|
+
throw this.unimplemented('Verisoul native SDK is not available on web.');
|
|
9
|
+
}
|
|
10
|
+
async reinitialize() {
|
|
11
|
+
throw this.unimplemented('Verisoul native SDK is not available on web.');
|
|
12
|
+
}
|
|
13
|
+
async recordTouchEvent(_options) {
|
|
14
|
+
void _options;
|
|
15
|
+
throw this.unimplemented('Verisoul native SDK is not available on web.');
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=web.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAI5C,MAAM,OAAO,WAAY,SAAQ,SAAS;IACxC,KAAK,CAAC,SAAS,CAAC,QAA0B;QACxC,KAAK,QAAQ,CAAC;QACd,MAAM,IAAI,CAAC,aAAa,CAAC,8CAA8C,CAAC,CAAC;IAC3E,CAAC;IAED,KAAK,CAAC,YAAY;QAChB,MAAM,IAAI,CAAC,aAAa,CAAC,8CAA8C,CAAC,CAAC;IAC3E,CAAC;IAED,KAAK,CAAC,YAAY;QAChB,MAAM,IAAI,CAAC,aAAa,CAAC,8CAA8C,CAAC,CAAC;IAC3E,CAAC;IAED,KAAK,CAAC,gBAAgB,CAAC,QAAiC;QACtD,KAAK,QAAQ,CAAC;QACd,MAAM,IAAI,CAAC,aAAa,CAAC,8CAA8C,CAAC,CAAC;IAC3E,CAAC;CACF","sourcesContent":["import { WebPlugin } from '@capacitor/core';\n\nimport type { ConfigureOptions, RecordTouchEventOptions, SessionIdResult, VerisoulPlugin } from './definitions';\n\nexport class VerisoulWeb extends WebPlugin implements VerisoulPlugin {\n async configure(_options: ConfigureOptions): Promise<void> {\n void _options;\n throw this.unimplemented('Verisoul native SDK is not available on web.');\n }\n\n async getSessionId(): Promise<SessionIdResult> {\n throw this.unimplemented('Verisoul native SDK is not available on web.');\n }\n\n async reinitialize(): Promise<void> {\n throw this.unimplemented('Verisoul native SDK is not available on web.');\n }\n\n async recordTouchEvent(_options: RecordTouchEventOptions): Promise<void> {\n void _options;\n throw this.unimplemented('Verisoul native SDK is not available on web.');\n }\n}\n"]}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var core = require('@capacitor/core');
|
|
4
|
+
|
|
5
|
+
const Verisoul = core.registerPlugin('Verisoul', {
|
|
6
|
+
web: () => Promise.resolve().then(function () { return web; }).then((m) => new m.VerisoulWeb()),
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
class VerisoulWeb extends core.WebPlugin {
|
|
10
|
+
async configure(_options) {
|
|
11
|
+
throw this.unimplemented('Verisoul native SDK is not available on web.');
|
|
12
|
+
}
|
|
13
|
+
async getSessionId() {
|
|
14
|
+
throw this.unimplemented('Verisoul native SDK is not available on web.');
|
|
15
|
+
}
|
|
16
|
+
async reinitialize() {
|
|
17
|
+
throw this.unimplemented('Verisoul native SDK is not available on web.');
|
|
18
|
+
}
|
|
19
|
+
async recordTouchEvent(_options) {
|
|
20
|
+
throw this.unimplemented('Verisoul native SDK is not available on web.');
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
var web = /*#__PURE__*/Object.freeze({
|
|
25
|
+
__proto__: null,
|
|
26
|
+
VerisoulWeb: VerisoulWeb
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
exports.Verisoul = Verisoul;
|
|
30
|
+
//# sourceMappingURL=plugin.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.cjs.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst Verisoul = registerPlugin('Verisoul', {\n web: () => import('./web').then((m) => new m.VerisoulWeb()),\n});\nexport * from './definitions';\nexport { Verisoul };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class VerisoulWeb extends WebPlugin {\n async configure(_options) {\n void _options;\n throw this.unimplemented('Verisoul native SDK is not available on web.');\n }\n async getSessionId() {\n throw this.unimplemented('Verisoul native SDK is not available on web.');\n }\n async reinitialize() {\n throw this.unimplemented('Verisoul native SDK is not available on web.');\n }\n async recordTouchEvent(_options) {\n void _options;\n throw this.unimplemented('Verisoul native SDK is not available on web.');\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;;AACK,MAAC,QAAQ,GAAGA,mBAAc,CAAC,UAAU,EAAE;AAC5C,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,WAAW,EAAE,CAAC;AAC/D,CAAC;;ACFM,MAAM,WAAW,SAASC,cAAS,CAAC;AAC3C,IAAI,MAAM,SAAS,CAAC,QAAQ,EAAE;AAE9B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,8CAA8C,CAAC;AAChF,IAAI;AACJ,IAAI,MAAM,YAAY,GAAG;AACzB,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,8CAA8C,CAAC;AAChF,IAAI;AACJ,IAAI,MAAM,YAAY,GAAG;AACzB,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,8CAA8C,CAAC;AAChF,IAAI;AACJ,IAAI,MAAM,gBAAgB,CAAC,QAAQ,EAAE;AAErC,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,8CAA8C,CAAC;AAChF,IAAI;AACJ;;;;;;;;;"}
|
package/dist/plugin.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
var capacitorVerisoul = (function (exports, core) {
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const Verisoul = core.registerPlugin('Verisoul', {
|
|
5
|
+
web: () => Promise.resolve().then(function () { return web; }).then((m) => new m.VerisoulWeb()),
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
class VerisoulWeb extends core.WebPlugin {
|
|
9
|
+
async configure(_options) {
|
|
10
|
+
throw this.unimplemented('Verisoul native SDK is not available on web.');
|
|
11
|
+
}
|
|
12
|
+
async getSessionId() {
|
|
13
|
+
throw this.unimplemented('Verisoul native SDK is not available on web.');
|
|
14
|
+
}
|
|
15
|
+
async reinitialize() {
|
|
16
|
+
throw this.unimplemented('Verisoul native SDK is not available on web.');
|
|
17
|
+
}
|
|
18
|
+
async recordTouchEvent(_options) {
|
|
19
|
+
throw this.unimplemented('Verisoul native SDK is not available on web.');
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
var web = /*#__PURE__*/Object.freeze({
|
|
24
|
+
__proto__: null,
|
|
25
|
+
VerisoulWeb: VerisoulWeb
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
exports.Verisoul = Verisoul;
|
|
29
|
+
|
|
30
|
+
return exports;
|
|
31
|
+
|
|
32
|
+
})({}, capacitorExports);
|
|
33
|
+
//# sourceMappingURL=plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst Verisoul = registerPlugin('Verisoul', {\n web: () => import('./web').then((m) => new m.VerisoulWeb()),\n});\nexport * from './definitions';\nexport { Verisoul };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class VerisoulWeb extends WebPlugin {\n async configure(_options) {\n void _options;\n throw this.unimplemented('Verisoul native SDK is not available on web.');\n }\n async getSessionId() {\n throw this.unimplemented('Verisoul native SDK is not available on web.');\n }\n async reinitialize() {\n throw this.unimplemented('Verisoul native SDK is not available on web.');\n }\n async recordTouchEvent(_options) {\n void _options;\n throw this.unimplemented('Verisoul native SDK is not available on web.');\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;AACK,UAAC,QAAQ,GAAGA,mBAAc,CAAC,UAAU,EAAE;IAC5C,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,WAAW,EAAE,CAAC;IAC/D,CAAC;;ICFM,MAAM,WAAW,SAASC,cAAS,CAAC;IAC3C,IAAI,MAAM,SAAS,CAAC,QAAQ,EAAE;IAE9B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,8CAA8C,CAAC;IAChF,IAAI;IACJ,IAAI,MAAM,YAAY,GAAG;IACzB,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,8CAA8C,CAAC;IAChF,IAAI;IACJ,IAAI,MAAM,YAAY,GAAG;IACzB,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,8CAA8C,CAAC;IAChF,IAAI;IACJ,IAAI,MAAM,gBAAgB,CAAC,QAAQ,EAAE;IAErC,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,8CAA8C,CAAC;IAChF,IAAI;IACJ;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
import VerisoulSDK
|
|
3
|
+
|
|
4
|
+
@objc public class VerisoulBridge: NSObject {
|
|
5
|
+
private let environments: [String: VerisoulEnvironment] = [
|
|
6
|
+
"dev": .dev,
|
|
7
|
+
"prod": .prod,
|
|
8
|
+
"production": .prod,
|
|
9
|
+
"sandbox": .sandbox,
|
|
10
|
+
"staging": .staging
|
|
11
|
+
]
|
|
12
|
+
|
|
13
|
+
@objc public func configure(environment: String, projectId: String) throws {
|
|
14
|
+
guard let env = environments[environment] else {
|
|
15
|
+
throw VerisoulBridgeError.invalidEnvironment(environment)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
try VerisoulSDK.Verisoul.shared.configure(env: env, projectId: projectId)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
@objc public func getSessionId() async throws -> String {
|
|
22
|
+
return try await VerisoulSDK.Verisoul.shared.session()
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
@objc public func reinitialize() {
|
|
26
|
+
VerisoulSDK.Verisoul.shared.reinitialize()
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
enum VerisoulBridgeError: LocalizedError {
|
|
31
|
+
case invalidEnvironment(String)
|
|
32
|
+
|
|
33
|
+
var errorDescription: String? {
|
|
34
|
+
switch self {
|
|
35
|
+
case .invalidEnvironment(let environment):
|
|
36
|
+
return "Invalid environment value: \(environment)"
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|