@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,51 @@
1
+ import { WebPlugin } from '@capacitor/core';
2
+ /**
3
+ * Web implementation of the Integrity plugin.
4
+ *
5
+ * This implementation exists to preserve API parity
6
+ * across all platforms.
7
+ *
8
+ * The Web platform does NOT provide native integrity signals.
9
+ * Therefore, most methods are explicitly unavailable.
10
+ */
11
+ export class IntegrityWeb extends WebPlugin {
12
+ constructor() {
13
+ super();
14
+ }
15
+ // ---------------------------------------------------------------------------
16
+ // Check
17
+ // ---------------------------------------------------------------------------
18
+ /**
19
+ * Executes a runtime integrity check.
20
+ *
21
+ * On Web, this feature is not available.
22
+ */
23
+ async check() {
24
+ throw this.unimplemented('Integrity checks are not implemented on web.');
25
+ }
26
+ // ---------------------------------------------------------------------------
27
+ // PresentBlockPage
28
+ // ---------------------------------------------------------------------------
29
+ /**
30
+ * Presents the integrity block page.
31
+ *
32
+ * On Web, this feature is not available.
33
+ */
34
+ async presentBlockPage() {
35
+ // Web platform cannot present native block pages.
36
+ // Throw to satisfy TypeScript return flow analysis.
37
+ throw this.unavailable('Integrity block page is not available on the Web platform.');
38
+ }
39
+ // ---------------------------------------------------------------------------
40
+ // Plugin info
41
+ // ---------------------------------------------------------------------------
42
+ /**
43
+ * Returns the plugin version.
44
+ *
45
+ * On Web, this represents the JavaScript package version.
46
+ */
47
+ async getPluginVersion() {
48
+ return { version: 'web' };
49
+ }
50
+ }
51
+ //# 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;;;;;;;;GAQG;AACH,MAAM,OAAO,YAAa,SAAQ,SAAS;IACzC;QACE,KAAK,EAAE,CAAC;IACV,CAAC;IAED,8EAA8E;IAC9E,QAAQ;IACR,8EAA8E;IAE9E;;;;OAIG;IACH,KAAK,CAAC,KAAK;QACT,MAAM,IAAI,CAAC,aAAa,CAAC,8CAA8C,CAAC,CAAC;IAC3E,CAAC;IAED,8EAA8E;IAC9E,mBAAmB;IACnB,8EAA8E;IAE9E;;;;OAIG;IACH,KAAK,CAAC,gBAAgB;QACpB,kDAAkD;QAClD,oDAAoD;QACpD,MAAM,IAAI,CAAC,WAAW,CAAC,4DAA4D,CAAC,CAAC;IACvF,CAAC;IAED,8EAA8E;IAC9E,cAAc;IACd,8EAA8E;IAE9E;;;;OAIG;IACH,KAAK,CAAC,gBAAgB;QACpB,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;IAC5B,CAAC;CACF"}
@@ -0,0 +1,130 @@
1
+ 'use strict';
2
+
3
+ var core = require('@capacitor/core');
4
+
5
+ /// <reference types="@capacitor/cli" />
6
+ // -----------------------------------------------------------------------------
7
+ // Enums
8
+ // -----------------------------------------------------------------------------
9
+ /**
10
+ * Standardized error codes used by the Integrity plugin.
11
+ *
12
+ * Errors are delivered via Promise rejection with a structured
13
+ * `{ message, code }` object matching `IntegrityError`.
14
+ *
15
+ * @since 8.0.0
16
+ */
17
+ exports.IntegrityErrorCode = void 0;
18
+ (function (IntegrityErrorCode) {
19
+ /** Required data is missing or the feature is not available. */
20
+ IntegrityErrorCode["UNAVAILABLE"] = "UNAVAILABLE";
21
+ /** The user denied a required permission or the feature is disabled. */
22
+ IntegrityErrorCode["PERMISSION_DENIED"] = "PERMISSION_DENIED";
23
+ /** The SSL pinning operation failed due to a runtime or initialization error. */
24
+ IntegrityErrorCode["INIT_FAILED"] = "INIT_FAILED";
25
+ /** Invalid or unsupported input was provided. */
26
+ IntegrityErrorCode["UNKNOWN_TYPE"] = "UNKNOWN_TYPE";
27
+ })(exports.IntegrityErrorCode || (exports.IntegrityErrorCode = {}));
28
+ /**
29
+ * Standard reason codes that MAY be used when presenting
30
+ * the integrity block page.
31
+ *
32
+ * These values are OPTIONAL and provided for convenience only.
33
+ * Applications may define and use their own custom reason strings.
34
+ *
35
+ * @since 8.0.0
36
+ */
37
+ exports.IntegrityBlockReason = void 0;
38
+ (function (IntegrityBlockReason) {
39
+ IntegrityBlockReason["COMPROMISED_ENVIRONMENT"] = "compromised_environment";
40
+ IntegrityBlockReason["ROOT_DETECTED"] = "root_detected";
41
+ IntegrityBlockReason["JAILBREAK_DETECTED"] = "jailbreak_detected";
42
+ IntegrityBlockReason["EMULATOR_DETECTED"] = "emulator_detected";
43
+ IntegrityBlockReason["DEBUG_ENVIRONMENT"] = "debug_environment";
44
+ IntegrityBlockReason["INTEGRITY_FAILED"] = "integrity_failed";
45
+ })(exports.IntegrityBlockReason || (exports.IntegrityBlockReason = {}));
46
+ /**
47
+ * Internal confidence levels used by native implementations.
48
+ *
49
+ * IMPORTANT:
50
+ * This enum is INTERNAL and MUST NOT be considered a public API.
51
+ * It exists to freeze semantic meaning and avoid string drift
52
+ * across platforms and future refactors.
53
+ */
54
+ var IntegrityConfidenceLevel;
55
+ (function (IntegrityConfidenceLevel) {
56
+ IntegrityConfidenceLevel["LOW"] = "low";
57
+ IntegrityConfidenceLevel["MEDIUM"] = "medium";
58
+ IntegrityConfidenceLevel["HIGH"] = "high";
59
+ })(IntegrityConfidenceLevel || (IntegrityConfidenceLevel = {}));
60
+
61
+ /**
62
+ * Import the `registerPlugin` method from the Capacitor core library.
63
+ * This method is used to register a custom plugin.
64
+ */
65
+ /**
66
+ * The Integrity plugin instance.
67
+ * It automatically lazy-loads the web implementation if running in a browser environment.
68
+ * Use this instance to access all ssl pinning functionality.
69
+ */
70
+ const Integrity = core.registerPlugin('Integrity', {
71
+ web: () => Promise.resolve().then(function () { return web; }).then((m) => new m.IntegrityWeb()),
72
+ });
73
+
74
+ /**
75
+ * Web implementation of the Integrity plugin.
76
+ *
77
+ * This implementation exists to preserve API parity
78
+ * across all platforms.
79
+ *
80
+ * The Web platform does NOT provide native integrity signals.
81
+ * Therefore, most methods are explicitly unavailable.
82
+ */
83
+ class IntegrityWeb extends core.WebPlugin {
84
+ constructor() {
85
+ super();
86
+ }
87
+ // ---------------------------------------------------------------------------
88
+ // Check
89
+ // ---------------------------------------------------------------------------
90
+ /**
91
+ * Executes a runtime integrity check.
92
+ *
93
+ * On Web, this feature is not available.
94
+ */
95
+ async check() {
96
+ throw this.unimplemented('Integrity checks are not implemented on web.');
97
+ }
98
+ // ---------------------------------------------------------------------------
99
+ // PresentBlockPage
100
+ // ---------------------------------------------------------------------------
101
+ /**
102
+ * Presents the integrity block page.
103
+ *
104
+ * On Web, this feature is not available.
105
+ */
106
+ async presentBlockPage() {
107
+ // Web platform cannot present native block pages.
108
+ // Throw to satisfy TypeScript return flow analysis.
109
+ throw this.unavailable('Integrity block page is not available on the Web platform.');
110
+ }
111
+ // ---------------------------------------------------------------------------
112
+ // Plugin info
113
+ // ---------------------------------------------------------------------------
114
+ /**
115
+ * Returns the plugin version.
116
+ *
117
+ * On Web, this represents the JavaScript package version.
118
+ */
119
+ async getPluginVersion() {
120
+ return { version: 'web' };
121
+ }
122
+ }
123
+
124
+ var web = /*#__PURE__*/Object.freeze({
125
+ __proto__: null,
126
+ IntegrityWeb: IntegrityWeb
127
+ });
128
+
129
+ exports.Integrity = Integrity;
130
+ //# sourceMappingURL=plugin.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.cjs.js","sources":["esm/definitions.js","esm/index.js","esm/web.js"],"sourcesContent":["/// <reference types=\"@capacitor/cli\" />\n// -----------------------------------------------------------------------------\n// Enums\n// -----------------------------------------------------------------------------\n/**\n * Standardized error codes used by the Integrity plugin.\n *\n * Errors are delivered via Promise rejection with a structured\n * `{ message, code }` object matching `IntegrityError`.\n *\n * @since 8.0.0\n */\nexport var IntegrityErrorCode;\n(function (IntegrityErrorCode) {\n /** Required data is missing or the feature is not available. */\n IntegrityErrorCode[\"UNAVAILABLE\"] = \"UNAVAILABLE\";\n /** The user denied a required permission or the feature is disabled. */\n IntegrityErrorCode[\"PERMISSION_DENIED\"] = \"PERMISSION_DENIED\";\n /** The SSL pinning operation failed due to a runtime or initialization error. */\n IntegrityErrorCode[\"INIT_FAILED\"] = \"INIT_FAILED\";\n /** Invalid or unsupported input was provided. */\n IntegrityErrorCode[\"UNKNOWN_TYPE\"] = \"UNKNOWN_TYPE\";\n})(IntegrityErrorCode || (IntegrityErrorCode = {}));\n/**\n * Standard reason codes that MAY be used when presenting\n * the integrity block page.\n *\n * These values are OPTIONAL and provided for convenience only.\n * Applications may define and use their own custom reason strings.\n *\n * @since 8.0.0\n */\nexport var IntegrityBlockReason;\n(function (IntegrityBlockReason) {\n IntegrityBlockReason[\"COMPROMISED_ENVIRONMENT\"] = \"compromised_environment\";\n IntegrityBlockReason[\"ROOT_DETECTED\"] = \"root_detected\";\n IntegrityBlockReason[\"JAILBREAK_DETECTED\"] = \"jailbreak_detected\";\n IntegrityBlockReason[\"EMULATOR_DETECTED\"] = \"emulator_detected\";\n IntegrityBlockReason[\"DEBUG_ENVIRONMENT\"] = \"debug_environment\";\n IntegrityBlockReason[\"INTEGRITY_FAILED\"] = \"integrity_failed\";\n})(IntegrityBlockReason || (IntegrityBlockReason = {}));\n/**\n * Internal confidence levels used by native implementations.\n *\n * IMPORTANT:\n * This enum is INTERNAL and MUST NOT be considered a public API.\n * It exists to freeze semantic meaning and avoid string drift\n * across platforms and future refactors.\n */\nvar IntegrityConfidenceLevel;\n(function (IntegrityConfidenceLevel) {\n IntegrityConfidenceLevel[\"LOW\"] = \"low\";\n IntegrityConfidenceLevel[\"MEDIUM\"] = \"medium\";\n IntegrityConfidenceLevel[\"HIGH\"] = \"high\";\n})(IntegrityConfidenceLevel || (IntegrityConfidenceLevel = {}));\n//# sourceMappingURL=definitions.js.map","/**\n * Import the `registerPlugin` method from the Capacitor core library.\n * This method is used to register a custom plugin.\n */\nimport { registerPlugin } from '@capacitor/core';\n/**\n * The Integrity plugin instance.\n * It automatically lazy-loads the web implementation if running in a browser environment.\n * Use this instance to access all ssl pinning functionality.\n */\nconst Integrity = registerPlugin('Integrity', {\n web: () => import('./web').then((m) => new m.IntegrityWeb()),\n});\nexport * from './definitions';\nexport { Integrity };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\n/**\n * Web implementation of the Integrity plugin.\n *\n * This implementation exists to preserve API parity\n * across all platforms.\n *\n * The Web platform does NOT provide native integrity signals.\n * Therefore, most methods are explicitly unavailable.\n */\nexport class IntegrityWeb extends WebPlugin {\n constructor() {\n super();\n }\n // ---------------------------------------------------------------------------\n // Check\n // ---------------------------------------------------------------------------\n /**\n * Executes a runtime integrity check.\n *\n * On Web, this feature is not available.\n */\n async check() {\n throw this.unimplemented('Integrity checks are not implemented on web.');\n }\n // ---------------------------------------------------------------------------\n // PresentBlockPage\n // ---------------------------------------------------------------------------\n /**\n * Presents the integrity block page.\n *\n * On Web, this feature is not available.\n */\n async presentBlockPage() {\n // Web platform cannot present native block pages.\n // Throw to satisfy TypeScript return flow analysis.\n throw this.unavailable('Integrity block page is not available on the Web platform.');\n }\n // ---------------------------------------------------------------------------\n // Plugin info\n // ---------------------------------------------------------------------------\n /**\n * Returns the plugin version.\n *\n * On Web, this represents the JavaScript package version.\n */\n async getPluginVersion() {\n return { version: 'web' };\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["IntegrityErrorCode","IntegrityBlockReason","registerPlugin","WebPlugin"],"mappings":";;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACWA;AACX,CAAC,UAAU,kBAAkB,EAAE;AAC/B;AACA,IAAI,kBAAkB,CAAC,aAAa,CAAC,GAAG,aAAa;AACrD;AACA,IAAI,kBAAkB,CAAC,mBAAmB,CAAC,GAAG,mBAAmB;AACjE;AACA,IAAI,kBAAkB,CAAC,aAAa,CAAC,GAAG,aAAa;AACrD;AACA,IAAI,kBAAkB,CAAC,cAAc,CAAC,GAAG,cAA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AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI,MAAM,KAAK,GAAG;AAClB,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,8CAA8C,CAAC;AAChF,IAAI;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI,MAAM,gBAAgB,GAAG;AAC7B;AACA;AACA,QAAQ,MAAM,IAAI,CAAC,WAAW,CAAC,4DAA4D,CAAC;AAC5F,IAAI;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI,MAAM,gBAAgB,GAAG;AAC7B,QAAQ,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE;AACjC,IAAI;AACJ;;;;;;;;;"}
package/dist/plugin.js ADDED
@@ -0,0 +1,133 @@
1
+ var capacitorIntegrity = (function (exports, core) {
2
+ 'use strict';
3
+
4
+ /// <reference types="@capacitor/cli" />
5
+ // -----------------------------------------------------------------------------
6
+ // Enums
7
+ // -----------------------------------------------------------------------------
8
+ /**
9
+ * Standardized error codes used by the Integrity plugin.
10
+ *
11
+ * Errors are delivered via Promise rejection with a structured
12
+ * `{ message, code }` object matching `IntegrityError`.
13
+ *
14
+ * @since 8.0.0
15
+ */
16
+ exports.IntegrityErrorCode = void 0;
17
+ (function (IntegrityErrorCode) {
18
+ /** Required data is missing or the feature is not available. */
19
+ IntegrityErrorCode["UNAVAILABLE"] = "UNAVAILABLE";
20
+ /** The user denied a required permission or the feature is disabled. */
21
+ IntegrityErrorCode["PERMISSION_DENIED"] = "PERMISSION_DENIED";
22
+ /** The SSL pinning operation failed due to a runtime or initialization error. */
23
+ IntegrityErrorCode["INIT_FAILED"] = "INIT_FAILED";
24
+ /** Invalid or unsupported input was provided. */
25
+ IntegrityErrorCode["UNKNOWN_TYPE"] = "UNKNOWN_TYPE";
26
+ })(exports.IntegrityErrorCode || (exports.IntegrityErrorCode = {}));
27
+ /**
28
+ * Standard reason codes that MAY be used when presenting
29
+ * the integrity block page.
30
+ *
31
+ * These values are OPTIONAL and provided for convenience only.
32
+ * Applications may define and use their own custom reason strings.
33
+ *
34
+ * @since 8.0.0
35
+ */
36
+ exports.IntegrityBlockReason = void 0;
37
+ (function (IntegrityBlockReason) {
38
+ IntegrityBlockReason["COMPROMISED_ENVIRONMENT"] = "compromised_environment";
39
+ IntegrityBlockReason["ROOT_DETECTED"] = "root_detected";
40
+ IntegrityBlockReason["JAILBREAK_DETECTED"] = "jailbreak_detected";
41
+ IntegrityBlockReason["EMULATOR_DETECTED"] = "emulator_detected";
42
+ IntegrityBlockReason["DEBUG_ENVIRONMENT"] = "debug_environment";
43
+ IntegrityBlockReason["INTEGRITY_FAILED"] = "integrity_failed";
44
+ })(exports.IntegrityBlockReason || (exports.IntegrityBlockReason = {}));
45
+ /**
46
+ * Internal confidence levels used by native implementations.
47
+ *
48
+ * IMPORTANT:
49
+ * This enum is INTERNAL and MUST NOT be considered a public API.
50
+ * It exists to freeze semantic meaning and avoid string drift
51
+ * across platforms and future refactors.
52
+ */
53
+ var IntegrityConfidenceLevel;
54
+ (function (IntegrityConfidenceLevel) {
55
+ IntegrityConfidenceLevel["LOW"] = "low";
56
+ IntegrityConfidenceLevel["MEDIUM"] = "medium";
57
+ IntegrityConfidenceLevel["HIGH"] = "high";
58
+ })(IntegrityConfidenceLevel || (IntegrityConfidenceLevel = {}));
59
+
60
+ /**
61
+ * Import the `registerPlugin` method from the Capacitor core library.
62
+ * This method is used to register a custom plugin.
63
+ */
64
+ /**
65
+ * The Integrity plugin instance.
66
+ * It automatically lazy-loads the web implementation if running in a browser environment.
67
+ * Use this instance to access all ssl pinning functionality.
68
+ */
69
+ const Integrity = core.registerPlugin('Integrity', {
70
+ web: () => Promise.resolve().then(function () { return web; }).then((m) => new m.IntegrityWeb()),
71
+ });
72
+
73
+ /**
74
+ * Web implementation of the Integrity plugin.
75
+ *
76
+ * This implementation exists to preserve API parity
77
+ * across all platforms.
78
+ *
79
+ * The Web platform does NOT provide native integrity signals.
80
+ * Therefore, most methods are explicitly unavailable.
81
+ */
82
+ class IntegrityWeb extends core.WebPlugin {
83
+ constructor() {
84
+ super();
85
+ }
86
+ // ---------------------------------------------------------------------------
87
+ // Check
88
+ // ---------------------------------------------------------------------------
89
+ /**
90
+ * Executes a runtime integrity check.
91
+ *
92
+ * On Web, this feature is not available.
93
+ */
94
+ async check() {
95
+ throw this.unimplemented('Integrity checks are not implemented on web.');
96
+ }
97
+ // ---------------------------------------------------------------------------
98
+ // PresentBlockPage
99
+ // ---------------------------------------------------------------------------
100
+ /**
101
+ * Presents the integrity block page.
102
+ *
103
+ * On Web, this feature is not available.
104
+ */
105
+ async presentBlockPage() {
106
+ // Web platform cannot present native block pages.
107
+ // Throw to satisfy TypeScript return flow analysis.
108
+ throw this.unavailable('Integrity block page is not available on the Web platform.');
109
+ }
110
+ // ---------------------------------------------------------------------------
111
+ // Plugin info
112
+ // ---------------------------------------------------------------------------
113
+ /**
114
+ * Returns the plugin version.
115
+ *
116
+ * On Web, this represents the JavaScript package version.
117
+ */
118
+ async getPluginVersion() {
119
+ return { version: 'web' };
120
+ }
121
+ }
122
+
123
+ var web = /*#__PURE__*/Object.freeze({
124
+ __proto__: null,
125
+ IntegrityWeb: IntegrityWeb
126
+ });
127
+
128
+ exports.Integrity = Integrity;
129
+
130
+ return exports;
131
+
132
+ })({}, capacitorExports);
133
+ //# sourceMappingURL=plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.js","sources":["esm/definitions.js","esm/index.js","esm/web.js"],"sourcesContent":["/// <reference types=\"@capacitor/cli\" />\n// -----------------------------------------------------------------------------\n// Enums\n// -----------------------------------------------------------------------------\n/**\n * Standardized error codes used by the Integrity plugin.\n *\n * Errors are delivered via Promise rejection with a structured\n * `{ message, code }` object matching `IntegrityError`.\n *\n * @since 8.0.0\n */\nexport var IntegrityErrorCode;\n(function (IntegrityErrorCode) {\n /** Required data is missing or the feature is not available. */\n IntegrityErrorCode[\"UNAVAILABLE\"] = \"UNAVAILABLE\";\n /** The user denied a required permission or the feature is disabled. */\n IntegrityErrorCode[\"PERMISSION_DENIED\"] = \"PERMISSION_DENIED\";\n /** The SSL pinning operation failed due to a runtime or initialization error. */\n IntegrityErrorCode[\"INIT_FAILED\"] = \"INIT_FAILED\";\n /** Invalid or unsupported input was provided. */\n IntegrityErrorCode[\"UNKNOWN_TYPE\"] = \"UNKNOWN_TYPE\";\n})(IntegrityErrorCode || (IntegrityErrorCode = {}));\n/**\n * Standard reason codes that MAY be used when presenting\n * the integrity block page.\n *\n * These values are OPTIONAL and provided for convenience only.\n * Applications may define and use their own custom reason strings.\n *\n * @since 8.0.0\n */\nexport var IntegrityBlockReason;\n(function (IntegrityBlockReason) {\n IntegrityBlockReason[\"COMPROMISED_ENVIRONMENT\"] = \"compromised_environment\";\n IntegrityBlockReason[\"ROOT_DETECTED\"] = \"root_detected\";\n IntegrityBlockReason[\"JAILBREAK_DETECTED\"] = \"jailbreak_detected\";\n IntegrityBlockReason[\"EMULATOR_DETECTED\"] = \"emulator_detected\";\n IntegrityBlockReason[\"DEBUG_ENVIRONMENT\"] = \"debug_environment\";\n IntegrityBlockReason[\"INTEGRITY_FAILED\"] = \"integrity_failed\";\n})(IntegrityBlockReason || (IntegrityBlockReason = {}));\n/**\n * Internal confidence levels used by native implementations.\n *\n * IMPORTANT:\n * This enum is INTERNAL and MUST NOT be considered a public API.\n * It exists to freeze semantic meaning and avoid string drift\n * across platforms and future refactors.\n */\nvar IntegrityConfidenceLevel;\n(function (IntegrityConfidenceLevel) {\n IntegrityConfidenceLevel[\"LOW\"] = \"low\";\n IntegrityConfidenceLevel[\"MEDIUM\"] = \"medium\";\n IntegrityConfidenceLevel[\"HIGH\"] = \"high\";\n})(IntegrityConfidenceLevel || (IntegrityConfidenceLevel = {}));\n//# sourceMappingURL=definitions.js.map","/**\n * Import the `registerPlugin` method from the Capacitor core library.\n * This method is used to register a custom plugin.\n */\nimport { registerPlugin } from '@capacitor/core';\n/**\n * The Integrity plugin instance.\n * It automatically lazy-loads the web implementation if running in a browser environment.\n * Use this instance to access all ssl pinning functionality.\n */\nconst Integrity = registerPlugin('Integrity', {\n web: () => import('./web').then((m) => new m.IntegrityWeb()),\n});\nexport * from './definitions';\nexport { Integrity };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\n/**\n * Web implementation of the Integrity plugin.\n *\n * This implementation exists to preserve API parity\n * across all platforms.\n *\n * The Web platform does NOT provide native integrity signals.\n * Therefore, most methods are explicitly unavailable.\n */\nexport class IntegrityWeb extends WebPlugin {\n constructor() {\n super();\n }\n // ---------------------------------------------------------------------------\n // Check\n // ---------------------------------------------------------------------------\n /**\n * Executes a runtime integrity check.\n *\n * On Web, this feature is not available.\n */\n async check() {\n throw this.unimplemented('Integrity checks are not implemented on web.');\n }\n // ---------------------------------------------------------------------------\n // PresentBlockPage\n // ---------------------------------------------------------------------------\n /**\n * Presents the integrity block page.\n *\n * On Web, this feature is not available.\n */\n async presentBlockPage() {\n // Web platform cannot present native block pages.\n // Throw to satisfy TypeScript return flow analysis.\n throw this.unavailable('Integrity block page is not available on the Web platform.');\n }\n // ---------------------------------------------------------------------------\n // Plugin info\n // ---------------------------------------------------------------------------\n /**\n * Returns the plugin version.\n *\n * On Web, this represents the JavaScript package version.\n */\n async getPluginVersion() {\n return { version: 'web' };\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["IntegrityErrorCode","IntegrityBlockReason","registerPlugin","WebPlugin"],"mappings":";;;IAAA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;AACWA;IACX,CAAC,UAAU,kBAAkB,EAAE;IAC/B;IACA,IAAI,kBAAkB,CAAC,aAAa,CAAC,GAAG,aAAa;IACrD;IACA,IAAI,kBAAkB,CAAC,mBAAmB,CAAC,GAAG,mBAAmB;IACjE;IACA,IAAI,kBAAkB,CAAC,aAAa,CAAC,GAAG,aAAa;IACrD;IACA,IAAI,kBAAkB,CAAC,cAAc,CAAC,GAAG,cAAc;IACvD,CAAC,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IACA;IACA;IACA;IACA;IACA,IAAI,MAAM,KAAK,GAAG;IAClB,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,8CAA8C,CAAC;IAChF,IAAI;IACJ;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA,IAAI,MAAM,gBAAgB,GAAG;IAC7B;IACA;IACA,QAAQ,MAAM,IAAI,CAAC,WAAW,CAAC,4DAA4D,CAAC;IAC5F,IAAI;IACJ;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA,IAAI,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE;IACjC,IAAI;IACJ;;;;;;;;;;;;;;;"}
@@ -0,0 +1,41 @@
1
+ /**
2
+ Options controlling the behavior of `Integrity.check()`.
3
+
4
+ This model represents the JavaScript options object
5
+ passed to the native layer.
6
+
7
+ Design principles:
8
+ - Decodable from JS input
9
+ - Independent from Capacitor APIs
10
+ - Safe to use inside the native implementation layer
11
+ - Does NOT affect the public JS API shape
12
+
13
+ Notes:
14
+ - Default values are applied in the Plugin layer
15
+ - The Impl layer MUST NOT assume non-optional values
16
+ */
17
+ struct IntegrityCheckOptions: Decodable {
18
+
19
+ /**
20
+ Desired strictness level for integrity checks.
21
+
22
+ Supported values:
23
+ - "basic": minimal checks (root/jailbreak, emulator)
24
+ - "standard": adds debug and instrumentation heuristics
25
+ - "strict": enables all available checks
26
+
27
+ Defaults to "basic" when not provided.
28
+ */
29
+ let level: String?
30
+
31
+ /**
32
+ Whether additional debug information should be
33
+ included in returned integrity signals.
34
+
35
+ When enabled, signals MAY include a human-readable
36
+ `description` field intended for diagnostics only.
37
+
38
+ Defaults to false.
39
+ */
40
+ let includeDebugInfo: Bool?
41
+ }
@@ -0,0 +1,135 @@
1
+ import Foundation
2
+ import Capacitor
3
+
4
+ /**
5
+ Plugin configuration container.
6
+
7
+ This struct is responsible for reading and exposing
8
+ static configuration values defined under the
9
+ `Integrity` key in capacitor.config.ts.
10
+
11
+ Configuration rules:
12
+ - Read once during plugin initialization
13
+ - Treated as immutable runtime input
14
+ - Accessible only from native code
15
+ */
16
+ public struct IntegrityConfig {
17
+
18
+ // MARK: - Configuration Keys
19
+
20
+ /**
21
+ Centralized definition of configuration keys.
22
+ Avoids string duplication and typos.
23
+ */
24
+ private struct Keys {
25
+ static let verboseLogging = "verboseLogging"
26
+ static let blockPage = "blockPage"
27
+ static let blockPageEnabled = "enabled"
28
+ static let blockPageUrl = "url"
29
+
30
+ // Jailbreak URL scheme probing (opt-in)
31
+ static let jailbreakUrlSchemes = "jailbreakUrlSchemes"
32
+ static let jailbreakUrlSchemesEnabled = "enabled"
33
+ static let jailbreakUrlSchemesList = "schemes"
34
+ }
35
+
36
+ // MARK: - Public Configuration Values
37
+
38
+ /**
39
+ Enables verbose native logging.
40
+
41
+ When enabled, the plugin prints additional
42
+ debug information to the Xcode console.
43
+
44
+ Default: false
45
+ */
46
+ public let verboseLogging: Bool
47
+
48
+ /**
49
+ Optional configuration for the integrity block page.
50
+ */
51
+ public let blockPage: BlockPageConfig?
52
+
53
+ // Optional jailbreak URL scheme probing configuration
54
+ public let jailbreakUrlSchemes: JailbreakUrlSchemeConfig?
55
+
56
+ // MARK: - Defaults
57
+
58
+ private static let defaultVerboseLogging: Bool = false
59
+ // private static let defaultBlockPage
60
+ // private static let defaultBlockPageEnabled
61
+ // private static let defaultBlockPageUrl
62
+
63
+ // MARK: - Initialization
64
+
65
+ /**
66
+ Initializes the configuration by reading values
67
+ from the Capacitor PluginConfig.
68
+
69
+ - Parameter plugin: The CAPPlugin instance used
70
+ to access typed configuration values.
71
+ */
72
+ init(plugin: CAPPlugin) {
73
+ let config = plugin.getConfig()
74
+
75
+ // Verbose logging flag
76
+ self.verboseLogging =
77
+ config.getBoolean(
78
+ Keys.verboseLogging,
79
+ Self.defaultVerboseLogging
80
+ )
81
+
82
+ // Block page configuration
83
+ if let blockPageConfig = config.getObject(Keys.blockPage) {
84
+
85
+ let enabled =
86
+ blockPageConfig[Keys.blockPageEnabled] as? Bool ?? false
87
+
88
+ let url =
89
+ blockPageConfig[Keys.blockPageUrl] as? String
90
+
91
+ self.blockPage = BlockPageConfig(
92
+ enabled: enabled,
93
+ url: url
94
+ )
95
+ } else {
96
+ self.blockPage = nil
97
+ }
98
+
99
+ // Jailbreak URL scheme probing configuration (opt-in)
100
+ if let schemeConfig = config.getObject(Keys.jailbreakUrlSchemes) {
101
+ let enabled =
102
+ schemeConfig[Keys.jailbreakUrlSchemesEnabled] as? Bool ?? false
103
+
104
+ let schemes =
105
+ schemeConfig[Keys.jailbreakUrlSchemesList] as? [String] ?? []
106
+
107
+ self.jailbreakUrlSchemes = JailbreakUrlSchemeConfig(
108
+ enabled: enabled,
109
+ schemes: schemes
110
+ )
111
+ } else {
112
+ self.jailbreakUrlSchemes = nil
113
+ }
114
+ }
115
+ }
116
+
117
+ // MARK: - Block Page Config
118
+
119
+ /**
120
+ Configuration for the optional integrity block page.
121
+ */
122
+ public struct BlockPageConfig {
123
+ public let enabled: Bool
124
+ public let url: String?
125
+ }
126
+
127
+ // MARK: - Jailbreak Url Scheme Config
128
+
129
+ /**
130
+ Configuration for jailbreak URL scheme probing.
131
+ */
132
+ public struct JailbreakUrlSchemeConfig {
133
+ public let enabled: Bool
134
+ public let schemes: [String]
135
+ }
@@ -0,0 +1,58 @@
1
+ import Foundation
2
+
3
+ /**
4
+ Utility to verify the integrity of the application's entitlements
5
+ and provisioning profile.
6
+ */
7
+ internal struct IntegrityEntitlementChecks {
8
+
9
+ /**
10
+ Reads the embedded.mobileprovision file to extract entitlements.
11
+ NOTE: This is a complex check as the file is a CMS/PKCS7 signed message.
12
+ We perform a simplified string-based heuristic for performance.
13
+ */
14
+ static func checkEntitlements() -> [String: Any]? {
15
+ guard let path = Bundle.main.path(forResource: "embedded", ofType: "mobileprovision") else {
16
+ // If the file is missing in a production build, it's a signal
17
+ return ["error": "Provisioning profile missing"]
18
+ }
19
+
20
+ do {
21
+ let data = try Data(contentsOf: URL(fileURLWithPath: path))
22
+ // Convert to string to look for specific entitlement keys
23
+ // In a real RASP implementation, we would parse the full ASN.1/XML structure
24
+ if let content = String(data: data, encoding: .ascii) {
25
+ let hasGetTaskAllow = content.contains("<key>get-task-allow</key>\n\t\t<true/>")
26
+
27
+ // Extraction of Keychain Access Groups (Heuristic)
28
+ // Re-signed apps will have different or missing access groups.
29
+ var keychainGroups: [String] = []
30
+ if content.contains("<key>keychain-access-groups</key>") {
31
+ // Simple scan for common team-prefixed group patterns
32
+ let pattern = "<string>$(AppIdentifierPrefix)[^<]+"
33
+ if let regex = try? NSRegularExpression(pattern: pattern, options: []) {
34
+ let nsString = content as NSString
35
+ let results = regex.matches(
36
+ in: content,
37
+ options: [],
38
+ range: NSRange(location: 0, length: nsString.length)
39
+ )
40
+ keychainGroups = results.map { nsString.substring(with: $0.range)
41
+ .replacingOccurrences(of: "<string>$(AppIdentifierPrefix)", with: "") }
42
+ }
43
+ }
44
+
45
+ return [
46
+ "debuggable": hasGetTaskAllow,
47
+ "provisioning_present": true,
48
+ "keychain_groups_found": keychainGroups.count,
49
+ "has_keychain_access": !keychainGroups.isEmpty
50
+ ]
51
+ }
52
+ } catch {
53
+ return ["error": "Failed to read profile"]
54
+ }
55
+
56
+ return nil
57
+ }
58
+ }
@@ -0,0 +1,49 @@
1
+ import Foundation
2
+
3
+ /**
4
+ Native error model for the Integrity plugin (iOS).
5
+
6
+ This enum represents all error categories that can be
7
+ produced by the native implementation layer.
8
+
9
+ Architectural rules:
10
+ - Must NOT reference Capacitor
11
+ - Must NOT reference JavaScript
12
+ - Must be throwable from the Impl layer
13
+ - Mapping to JS-facing error codes happens ONLY in the Plugin layer
14
+ */
15
+ enum IntegrityError: Error {
16
+
17
+ /// Feature or capability is not available on this device or configuration
18
+ case unavailable(String)
19
+
20
+ /// Required permission was denied or not granted
21
+ case permissionDenied(String)
22
+
23
+ /// Plugin failed to initialize or perform a required operation
24
+ case initFailed(String)
25
+
26
+ /// Invalid or unsupported input was provided
27
+ case unknownType(String)
28
+
29
+ // MARK: - Human-readable message
30
+
31
+ /**
32
+ Human-readable error message.
33
+
34
+ This message is intended to be passed verbatim
35
+ to JavaScript via `call.reject(message, code)`.
36
+ */
37
+ var message: String {
38
+ switch self {
39
+ case .unavailable(let message):
40
+ return message
41
+ case .permissionDenied(let message):
42
+ return message
43
+ case .initFailed(let message):
44
+ return message
45
+ case .unknownType(let message):
46
+ return message
47
+ }
48
+ }
49
+ }