@cap-kit/integrity 8.0.0-next.6

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.
Files changed (59) hide show
  1. package/CapKitIntegrity.podspec +17 -0
  2. package/LICENSE +21 -0
  3. package/Package.swift +26 -0
  4. package/README.md +1104 -0
  5. package/android/build.gradle +104 -0
  6. package/android/src/main/AndroidManifest.xml +21 -0
  7. package/android/src/main/java/io/capkit/integrity/IntegrityCheckOptions.kt +37 -0
  8. package/android/src/main/java/io/capkit/integrity/IntegrityConfig.kt +59 -0
  9. package/android/src/main/java/io/capkit/integrity/IntegrityError.kt +40 -0
  10. package/android/src/main/java/io/capkit/integrity/IntegrityImpl.kt +319 -0
  11. package/android/src/main/java/io/capkit/integrity/IntegrityPlugin.kt +475 -0
  12. package/android/src/main/java/io/capkit/integrity/IntegrityReportBuilder.kt +130 -0
  13. package/android/src/main/java/io/capkit/integrity/IntegritySignalBuilder.kt +72 -0
  14. package/android/src/main/java/io/capkit/integrity/emulator/IntegrityEmulatorChecks.kt +38 -0
  15. package/android/src/main/java/io/capkit/integrity/filesystem/IntegrityFilesystemChecks.kt +51 -0
  16. package/android/src/main/java/io/capkit/integrity/hook/IntegrityHookChecks.kt +61 -0
  17. package/android/src/main/java/io/capkit/integrity/remote/IntegrityRemoteAttestor.kt +49 -0
  18. package/android/src/main/java/io/capkit/integrity/root/IntegrityRootDetector.kt +136 -0
  19. package/android/src/main/java/io/capkit/integrity/runtime/IntegrityRuntimeChecks.kt +87 -0
  20. package/android/src/main/java/io/capkit/integrity/ui/IntegrityBlockActivity.kt +173 -0
  21. package/android/src/main/java/io/capkit/integrity/ui/IntegrityUISignals.kt +57 -0
  22. package/android/src/main/java/io/capkit/integrity/utils/IntegrityLogger.kt +85 -0
  23. package/android/src/main/java/io/capkit/integrity/utils/IntegrityUtils.kt +105 -0
  24. package/android/src/main/res/.gitkeep +0 -0
  25. package/android/src/main/res/values/styles.xml +5 -0
  26. package/dist/docs.json +598 -0
  27. package/dist/esm/definitions.d.ts +554 -0
  28. package/dist/esm/definitions.js +56 -0
  29. package/dist/esm/definitions.js.map +1 -0
  30. package/dist/esm/index.d.ts +15 -0
  31. package/dist/esm/index.js +16 -0
  32. package/dist/esm/index.js.map +1 -0
  33. package/dist/esm/web.d.ts +32 -0
  34. package/dist/esm/web.js +51 -0
  35. package/dist/esm/web.js.map +1 -0
  36. package/dist/plugin.cjs.js +130 -0
  37. package/dist/plugin.cjs.js.map +1 -0
  38. package/dist/plugin.js +133 -0
  39. package/dist/plugin.js.map +1 -0
  40. package/ios/Sources/IntegrityPlugin/IntegrityCheckOptions.swift +41 -0
  41. package/ios/Sources/IntegrityPlugin/IntegrityConfig.swift +135 -0
  42. package/ios/Sources/IntegrityPlugin/IntegrityEntitlementChecks.swift +58 -0
  43. package/ios/Sources/IntegrityPlugin/IntegrityError.swift +49 -0
  44. package/ios/Sources/IntegrityPlugin/IntegrityImpl.swift +397 -0
  45. package/ios/Sources/IntegrityPlugin/IntegrityPlugin.swift +345 -0
  46. package/ios/Sources/IntegrityPlugin/IntegrityReportBuilder.swift +184 -0
  47. package/ios/Sources/IntegrityPlugin/Utils/IntegrityLogger.swift +69 -0
  48. package/ios/Sources/IntegrityPlugin/Utils/IntegrityUtils.swift +144 -0
  49. package/ios/Sources/IntegrityPlugin/Version.swift +16 -0
  50. package/ios/Sources/IntegrityPlugin/filesystem/IntegrityFilesystemChecks.swift +86 -0
  51. package/ios/Sources/IntegrityPlugin/hook/IntegrityHookChecks.swift +85 -0
  52. package/ios/Sources/IntegrityPlugin/jailbreak/IntegrityJailbreakDetector.swift +74 -0
  53. package/ios/Sources/IntegrityPlugin/jailbreak/IntegrityJailbreakUrlSchemeDetector.swift +42 -0
  54. package/ios/Sources/IntegrityPlugin/remote/IntegrityRemoteAttestor.swift +40 -0
  55. package/ios/Sources/IntegrityPlugin/runtime/IntegrityRuntimeChecks.swift +63 -0
  56. package/ios/Sources/IntegrityPlugin/simulator/IntegritySimulatorChecks.swift +20 -0
  57. package/ios/Sources/IntegrityPlugin/ui/IntegrityBlockViewController.swift +143 -0
  58. package/ios/Tests/IntegrityPluginTests/IntegrityPluginTests.swift +10 -0
  59. package/package.json +106 -0
@@ -0,0 +1,143 @@
1
+ import UIKit
2
+ import WebKit
3
+
4
+ /**
5
+ Dedicated view controller used to present the integrity block page.
6
+
7
+ ROLE:
8
+ This view controller is a pure UI component responsible for rendering
9
+ a blocking screen when the host application decides to interrupt
10
+ normal execution due to integrity-related conditions.
11
+
12
+ Responsibilities:
13
+ - Display a developer-provided HTML block page
14
+ - Support both remote URLs and bundled local assets
15
+ - Preserve query parameters for diagnostic or UX purposes
16
+ - Optionally allow user dismissal when explicitly enabled
17
+
18
+ This controller:
19
+ - is presented explicitly by the Integrity plugin
20
+ - never performs integrity checks
21
+ - never decides when it should be shown
22
+
23
+ Security note:
24
+ - By default, the block page is NOT dismissible
25
+ - Dismissal must be explicitly enabled by the host application
26
+ */
27
+ final class IntegrityBlockViewController: UIViewController {
28
+
29
+ // MARK: - Properties
30
+
31
+ /// URL or local asset path provided by the plugin.
32
+ /// Can include optional query parameters.
33
+ private let url: String
34
+
35
+ /// Whether the block page can be dismissed by the user.
36
+ /// When false, interactive dismissal is explicitly disabled.
37
+ private let dismissible: Bool
38
+
39
+ // MARK: - Initialization
40
+
41
+ /**
42
+ Designated initializer.
43
+
44
+ - Parameters:
45
+ - url: Remote URL or local asset path to load.
46
+ - dismissible: Whether the user is allowed to dismiss the block page.
47
+ */
48
+ init(url: String, dismissible: Bool) {
49
+ self.url = url
50
+ self.dismissible = dismissible
51
+ super.init(nibName: nil, bundle: nil)
52
+
53
+ // Prevent swipe-to-dismiss gestures unless explicitly allowed.
54
+ // This ensures the block page cannot be bypassed unintentionally.
55
+ self.isModalInPresentation = !dismissible
56
+ }
57
+
58
+ required init?(coder: NSCoder) {
59
+ fatalError("init(coder:) has not been implemented")
60
+ }
61
+
62
+ // MARK: - Lifecycle
63
+
64
+ override func viewDidLoad() {
65
+ super.viewDidLoad()
66
+
67
+ view.backgroundColor = .systemBackground
68
+
69
+ // Navigation bar (dismissible mode only) ------------------------------
70
+
71
+ // When dismissal is enabled, expose an explicit Close button.
72
+ // This is the ONLY supported way to dismiss a modal view controller on iOS.
73
+ if dismissible {
74
+ let closeButton = UIBarButtonItem(
75
+ title: "Close",
76
+ style: .done,
77
+ target: self,
78
+ action: #selector(closeTapped)
79
+ )
80
+ navigationItem.rightBarButtonItem = closeButton
81
+ }
82
+
83
+ // WebView setup -------------------------------------------------------
84
+
85
+ // Create an isolated WKWebView instance to render the block page.
86
+ // No custom message handlers or JS bridges are attached.
87
+ let configuration = WKWebViewConfiguration()
88
+ let webView = WKWebView(frame: .zero, configuration: configuration)
89
+
90
+ webView.translatesAutoresizingMaskIntoConstraints = false
91
+ view.addSubview(webView)
92
+
93
+ NSLayoutConstraint.activate([
94
+ webView.topAnchor.constraint(equalTo: view.topAnchor),
95
+ webView.bottomAnchor.constraint(equalTo: view.bottomAnchor),
96
+ webView.leadingAnchor.constraint(equalTo: view.leadingAnchor),
97
+ webView.trailingAnchor.constraint(equalTo: view.trailingAnchor)
98
+ ])
99
+
100
+ // URL handling --------------------------------------------------------
101
+
102
+ // Remote URLs (http / https) are loaded directly via URLRequest.
103
+ if url.starts(with: "http"), let remoteURL = URL(string: url) {
104
+ webView.load(URLRequest(url: remoteURL))
105
+ return
106
+ }
107
+
108
+ // Local asset loading with query support ------------------------------
109
+
110
+ // Example:
111
+ // url = "public/integrity-block.html?reason=integrity_failed"
112
+
113
+ let parts = url.split(separator: "?", maxSplits: 1)
114
+ let assetPath = String(parts[0])
115
+ let query = parts.count > 1 ? "?\(parts[1])" : ""
116
+
117
+ guard
118
+ let fileURL = Bundle.main.url(forResource: assetPath, withExtension: nil),
119
+ let html = try? String(contentsOf: fileURL, encoding: .utf8)
120
+ else {
121
+ // Fail silently if the asset cannot be loaded.
122
+ // The plugin layer is responsible for validating inputs.
123
+ return
124
+ }
125
+
126
+ // Create a synthetic base URL to preserve:
127
+ // - window.location.search (query parameters)
128
+ // - relative paths inside the HTML document
129
+ let baseURL = fileURL.deletingLastPathComponent()
130
+ let fakeURL = URL(string: baseURL.absoluteString + "/" + assetPath + query)
131
+
132
+ webView.loadHTMLString(html, baseURL: fakeURL)
133
+ }
134
+
135
+ // MARK: - Actions
136
+
137
+ /**
138
+ Dismisses the block page when dismissal is explicitly allowed.
139
+ */
140
+ @objc private func closeTapped() {
141
+ dismiss(animated: true)
142
+ }
143
+ }
@@ -0,0 +1,10 @@
1
+ import XCTest
2
+ @testable import Integrity
3
+
4
+ /**
5
+ Basic functional tests for the Integrity plugin native implementation.
6
+
7
+ These tests validate the core behavior of the implementation
8
+ independently from the Capacitor bridge.
9
+ */
10
+ class IntegrityPluginTests: XCTestCase {}
package/package.json ADDED
@@ -0,0 +1,106 @@
1
+ {
2
+ "name": "@cap-kit/integrity",
3
+ "version": "8.0.0-next.6",
4
+ "description": "Runtime integrity and environment signal detection for Capacitor v8 applications.",
5
+ "type": "module",
6
+ "private": false,
7
+ "engines": {
8
+ "node": ">=24.0.0",
9
+ "pnpm": ">=10.0.0"
10
+ },
11
+ "main": "dist/plugin.cjs.js",
12
+ "module": "dist/esm/index.js",
13
+ "types": "dist/esm/index.d.ts",
14
+ "unpkg": "dist/plugin.js",
15
+ "files": [
16
+ "android/src/main/",
17
+ "android/build.gradle",
18
+ "dist/",
19
+ "ios/Sources",
20
+ "ios/Tests",
21
+ "Package.swift",
22
+ "CapKitIntegrity.podspec",
23
+ "LICENSE"
24
+ ],
25
+ "author": "CapKit Team",
26
+ "license": "MIT",
27
+ "repository": {
28
+ "type": "git",
29
+ "url": "git+https://github.com/cap-kit/capacitor-plugins.git",
30
+ "directory": "packages/integrity"
31
+ },
32
+ "bugs": {
33
+ "url": "https://github.com/cap-kit/capacitor-plugins/issues"
34
+ },
35
+ "homepage": "https://github.com/cap-kit/capacitor-plugins/tree/main/packages/integrity#readme",
36
+ "keywords": [
37
+ "capacitor",
38
+ "capacitor-plugin",
39
+ "cap-kit",
40
+ "mobile",
41
+ "native",
42
+ "ios",
43
+ "android",
44
+ "integrity",
45
+ "environment",
46
+ "detection",
47
+ "root",
48
+ "jailbreak",
49
+ "emulator",
50
+ "security-signals"
51
+ ],
52
+ "publishConfig": {
53
+ "access": "public"
54
+ },
55
+ "devDependencies": {
56
+ "@capacitor/cli": "^8.0.2",
57
+ "@capacitor/android": "^8.0.2",
58
+ "@capacitor/core": "^8.0.2",
59
+ "@capacitor/docgen": "^0.3.1",
60
+ "@capacitor/ios": "^8.0.2",
61
+ "@eslint/eslintrc": "^3.3.3",
62
+ "@eslint/js": "^9.39.2",
63
+ "eslint": "^9.39.2",
64
+ "eslint-plugin-import": "^2.32.0",
65
+ "globals": "^17.3.0",
66
+ "prettier": "^3.8.1",
67
+ "prettier-plugin-java": "^2.8.1",
68
+ "rimraf": "^6.1.2",
69
+ "rollup": "^4.57.1",
70
+ "swiftlint": "^2.0.0",
71
+ "typescript": "^5.9.3",
72
+ "typescript-eslint": "^8.54.0"
73
+ },
74
+ "peerDependencies": {
75
+ "@capacitor/core": ">=8.0.2"
76
+ },
77
+ "capacitor": {
78
+ "ios": {
79
+ "src": "ios"
80
+ },
81
+ "android": {
82
+ "src": "android"
83
+ }
84
+ },
85
+ "scripts": {
86
+ "verify": "pnpm run verify:ios && pnpm run verify:android && pnpm run verify:web",
87
+ "verify:ios": "node ./scripts/sync-version.js && xcodebuild -scheme CapKitIntegrity -destination generic/platform=iOS",
88
+ "verify:android": "cd android && ./gradlew clean build && cd ..",
89
+ "verify:web": "pnpm run build",
90
+ "lint:android": "cd android && ./gradlew ktlintCheck",
91
+ "fmt:android": "cd android && ./gradlew ktlintFormat",
92
+ "lint": "pnpm run eslint . && pnpm run swiftlint lint --strict || true && pnpm run lint:android || true",
93
+ "format:check": "prettier --check \"**/*.{css,html,ts,js,java}\" --plugin=prettier-plugin-java",
94
+ "format": "eslint --fix . && prettier --write \"**/*.{css,html,ts,js,java}\" --plugin=prettier-plugin-java && pnpm run swiftlint --fix --format && pnpm run fmt:android",
95
+ "eslint": "eslint",
96
+ "prettier": "prettier \"**/*.{css,html,ts,js,java}\" --plugin=prettier-plugin-java",
97
+ "swiftlint": "node-swiftlint lint ios/Sources",
98
+ "docgen": "docgen --api IntegrityPlugin --output-readme README.md --output-json dist/docs.json",
99
+ "build": "node ./scripts/sync-version.js && pnpm run clean && pnpm run docgen && tsc && rollup -c rollup.config.mjs",
100
+ "clean": "rimraf ./dist",
101
+ "watch": "tsc --watch",
102
+ "test": "pnpm run verify",
103
+ "removePacked": "rimraf -g cap-kit-integrity-*.tgz",
104
+ "publish:locally": "pnpm run removePacked && pnpm run build && pnpm pack"
105
+ }
106
+ }