@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.
@@ -0,0 +1,68 @@
1
+ import Foundation
2
+ import Capacitor
3
+
4
+ @objc(VerisoulPlugin)
5
+ public class VerisoulPlugin: CAPPlugin, CAPBridgedPlugin {
6
+ public let identifier = "VerisoulPlugin"
7
+ public let jsName = "Verisoul"
8
+ public let pluginMethods: [CAPPluginMethod] = [
9
+ CAPPluginMethod(name: "configure", returnType: CAPPluginReturnPromise),
10
+ CAPPluginMethod(name: "getSessionId", returnType: CAPPluginReturnPromise),
11
+ CAPPluginMethod(name: "reinitialize", returnType: CAPPluginReturnPromise),
12
+ CAPPluginMethod(name: "recordTouchEvent", returnType: CAPPluginReturnPromise)
13
+ ]
14
+
15
+ private let implementation = VerisoulBridge()
16
+
17
+ @objc func configure(_ call: CAPPluginCall) {
18
+ guard let environment = call.getString("environment") else {
19
+ call.reject("environment is required", "INVALID_ENVIRONMENT")
20
+ return
21
+ }
22
+ guard let projectId = call.getString("projectId"), !projectId.isEmpty else {
23
+ call.reject("projectId is required")
24
+ return
25
+ }
26
+
27
+ do {
28
+ try implementation.configure(environment: environment, projectId: projectId)
29
+ call.resolve()
30
+ } catch {
31
+ call.reject(error.localizedDescription, errorCode(for: error), error)
32
+ }
33
+ }
34
+
35
+ @objc func getSessionId(_ call: CAPPluginCall) {
36
+ Task {
37
+ do {
38
+ let sessionId = try await implementation.getSessionId()
39
+ call.resolve(["sessionId": sessionId])
40
+ } catch {
41
+ call.reject(error.localizedDescription, errorCode(for: error), error)
42
+ }
43
+ }
44
+ }
45
+
46
+ @objc func reinitialize(_ call: CAPPluginCall) {
47
+ implementation.reinitialize()
48
+ call.resolve()
49
+ }
50
+
51
+ @objc func recordTouchEvent(_ call: CAPPluginCall) {
52
+ call.resolve()
53
+ }
54
+
55
+ private func errorCode(for error: Error) -> String {
56
+ let description = error.localizedDescription.uppercased()
57
+ if description.contains("ENVIRONMENT") {
58
+ return "INVALID_ENVIRONMENT"
59
+ }
60
+ if description.contains("WEBVIEW") {
61
+ return "WEBVIEW_UNAVAILABLE"
62
+ }
63
+ if description.contains("SESSION") {
64
+ return "SESSION_UNAVAILABLE"
65
+ }
66
+ return "UNKNOWN_ERROR"
67
+ }
68
+ }
@@ -0,0 +1,10 @@
1
+ import XCTest
2
+ @testable import VerisoulPlugin
3
+
4
+ class VerisoulTests: XCTestCase {
5
+ func testInvalidEnvironmentThrows() {
6
+ let implementation = VerisoulBridge()
7
+
8
+ XCTAssertThrowsError(try implementation.configure(environment: "invalid", projectId: "project"))
9
+ }
10
+ }
package/package.json ADDED
@@ -0,0 +1,88 @@
1
+ {
2
+ "name": "@capgo/capacitor-verisoul",
3
+ "version": "8.0.1",
4
+ "description": "Capacitor plugin for Verisoul fraud prevention sessions.",
5
+ "main": "dist/plugin.cjs.js",
6
+ "module": "dist/esm/index.js",
7
+ "types": "dist/esm/index.d.ts",
8
+ "unpkg": "dist/plugin.js",
9
+ "files": [
10
+ "android/src/main/",
11
+ "android/build.gradle",
12
+ "dist/",
13
+ "ios/Sources",
14
+ "ios/Tests",
15
+ "Package.swift",
16
+ "CapgoCapacitorVerisoul.podspec"
17
+ ],
18
+ "author": "Martin Donadieu <martin@capgo.app>",
19
+ "license": "MPL-2.0",
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "git+https://github.com/Cap-go/capacitor-verisoul.git"
23
+ },
24
+ "bugs": {
25
+ "url": "https://github.com/Cap-go/capacitor-verisoul/issues"
26
+ },
27
+ "homepage": "https://github.com/Cap-go/capacitor-verisoul",
28
+ "keywords": [
29
+ "capacitor",
30
+ "verisoul",
31
+ "fraud",
32
+ "bot-detection",
33
+ "device-integrity"
34
+ ],
35
+ "scripts": {
36
+ "verify": "bun run verify:ios && bun run verify:android && bun run verify:web",
37
+ "verify:ios": "xcodebuild -scheme CapgoCapacitorVerisoul -destination generic/platform=iOS",
38
+ "verify:android": "cd android && ./gradlew clean build test && cd ..",
39
+ "verify:web": "bun run build",
40
+ "lint": "bun run eslint && bun run prettier -- --check && bun run swiftlint -- lint",
41
+ "fmt": "bun run eslint -- --fix && bun run prettier -- --write && bun run swiftlint -- --fix --format",
42
+ "eslint": "eslint \"**/*.ts\"",
43
+ "prettier": "prettier-pretty-check \"**/*.{css,html,ts,js,java}\" --plugin=prettier-plugin-java",
44
+ "swiftlint": "node-swiftlint",
45
+ "docgen": "docgen --api VerisoulPlugin --output-readme README.md --output-json dist/docs.json",
46
+ "build": "bun run clean && bun run docgen && tsc && rollup -c rollup.config.mjs",
47
+ "clean": "rimraf ./dist",
48
+ "watch": "tsc --watch",
49
+ "prepublishOnly": "bun run build",
50
+ "check:wiring": "node scripts/check-capacitor-plugin-wiring.mjs"
51
+ },
52
+ "devDependencies": {
53
+ "@capacitor/android": "^8.3.4",
54
+ "@capacitor/cli": "^8.3.4",
55
+ "@capacitor/core": "^8.3.4",
56
+ "@capacitor/docgen": "^0.3.1",
57
+ "@capacitor/ios": "^8.3.4",
58
+ "@eslint/js": "^10.0.1",
59
+ "@ionic/prettier-config": "^4.0.0",
60
+ "@ionic/swiftlint-config": "^2.0.0",
61
+ "@types/node": "^25.9.1",
62
+ "eslint": "^10.4.0",
63
+ "eslint-config-prettier": "^10.1.8",
64
+ "eslint-plugin-import": "^2.32.0",
65
+ "husky": "^9.1.7",
66
+ "prettier": "^3.8.3",
67
+ "prettier-plugin-java": "^2.9.2",
68
+ "prettier-pretty-check": "^0.2.0",
69
+ "rimraf": "^6.1.3",
70
+ "rollup": "^4.60.4",
71
+ "swiftlint": "^2.0.0",
72
+ "typescript": "^6.0.3",
73
+ "typescript-eslint": "^8.59.4"
74
+ },
75
+ "peerDependencies": {
76
+ "@capacitor/core": ">=8.0.0"
77
+ },
78
+ "prettier": "@ionic/prettier-config",
79
+ "swiftlint": "@ionic/swiftlint-config",
80
+ "capacitor": {
81
+ "ios": {
82
+ "src": "ios"
83
+ },
84
+ "android": {
85
+ "src": "android"
86
+ }
87
+ }
88
+ }