@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.
- package/CapKitIntegrity.podspec +17 -0
- package/LICENSE +21 -0
- package/Package.swift +26 -0
- package/README.md +1104 -0
- package/android/build.gradle +104 -0
- package/android/src/main/AndroidManifest.xml +21 -0
- package/android/src/main/java/io/capkit/integrity/IntegrityCheckOptions.kt +37 -0
- package/android/src/main/java/io/capkit/integrity/IntegrityConfig.kt +59 -0
- package/android/src/main/java/io/capkit/integrity/IntegrityError.kt +40 -0
- package/android/src/main/java/io/capkit/integrity/IntegrityImpl.kt +319 -0
- package/android/src/main/java/io/capkit/integrity/IntegrityPlugin.kt +475 -0
- package/android/src/main/java/io/capkit/integrity/IntegrityReportBuilder.kt +130 -0
- package/android/src/main/java/io/capkit/integrity/IntegritySignalBuilder.kt +72 -0
- package/android/src/main/java/io/capkit/integrity/emulator/IntegrityEmulatorChecks.kt +38 -0
- package/android/src/main/java/io/capkit/integrity/filesystem/IntegrityFilesystemChecks.kt +51 -0
- package/android/src/main/java/io/capkit/integrity/hook/IntegrityHookChecks.kt +61 -0
- package/android/src/main/java/io/capkit/integrity/remote/IntegrityRemoteAttestor.kt +49 -0
- package/android/src/main/java/io/capkit/integrity/root/IntegrityRootDetector.kt +136 -0
- package/android/src/main/java/io/capkit/integrity/runtime/IntegrityRuntimeChecks.kt +87 -0
- package/android/src/main/java/io/capkit/integrity/ui/IntegrityBlockActivity.kt +173 -0
- package/android/src/main/java/io/capkit/integrity/ui/IntegrityUISignals.kt +57 -0
- package/android/src/main/java/io/capkit/integrity/utils/IntegrityLogger.kt +85 -0
- package/android/src/main/java/io/capkit/integrity/utils/IntegrityUtils.kt +105 -0
- package/android/src/main/res/.gitkeep +0 -0
- package/android/src/main/res/values/styles.xml +5 -0
- package/dist/docs.json +598 -0
- package/dist/esm/definitions.d.ts +554 -0
- package/dist/esm/definitions.js +56 -0
- package/dist/esm/definitions.js.map +1 -0
- package/dist/esm/index.d.ts +15 -0
- package/dist/esm/index.js +16 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/web.d.ts +32 -0
- package/dist/esm/web.js +51 -0
- package/dist/esm/web.js.map +1 -0
- package/dist/plugin.cjs.js +130 -0
- package/dist/plugin.cjs.js.map +1 -0
- package/dist/plugin.js +133 -0
- package/dist/plugin.js.map +1 -0
- package/ios/Sources/IntegrityPlugin/IntegrityCheckOptions.swift +41 -0
- package/ios/Sources/IntegrityPlugin/IntegrityConfig.swift +135 -0
- package/ios/Sources/IntegrityPlugin/IntegrityEntitlementChecks.swift +58 -0
- package/ios/Sources/IntegrityPlugin/IntegrityError.swift +49 -0
- package/ios/Sources/IntegrityPlugin/IntegrityImpl.swift +397 -0
- package/ios/Sources/IntegrityPlugin/IntegrityPlugin.swift +345 -0
- package/ios/Sources/IntegrityPlugin/IntegrityReportBuilder.swift +184 -0
- package/ios/Sources/IntegrityPlugin/Utils/IntegrityLogger.swift +69 -0
- package/ios/Sources/IntegrityPlugin/Utils/IntegrityUtils.swift +144 -0
- package/ios/Sources/IntegrityPlugin/Version.swift +16 -0
- package/ios/Sources/IntegrityPlugin/filesystem/IntegrityFilesystemChecks.swift +86 -0
- package/ios/Sources/IntegrityPlugin/hook/IntegrityHookChecks.swift +85 -0
- package/ios/Sources/IntegrityPlugin/jailbreak/IntegrityJailbreakDetector.swift +74 -0
- package/ios/Sources/IntegrityPlugin/jailbreak/IntegrityJailbreakUrlSchemeDetector.swift +42 -0
- package/ios/Sources/IntegrityPlugin/remote/IntegrityRemoteAttestor.swift +40 -0
- package/ios/Sources/IntegrityPlugin/runtime/IntegrityRuntimeChecks.swift +63 -0
- package/ios/Sources/IntegrityPlugin/simulator/IntegritySimulatorChecks.swift +20 -0
- package/ios/Sources/IntegrityPlugin/ui/IntegrityBlockViewController.swift +143 -0
- package/ios/Tests/IntegrityPluginTests/IntegrityPluginTests.swift +10 -0
- package/package.json +106 -0
|
@@ -0,0 +1,554 @@
|
|
|
1
|
+
import { PluginListenerHandle } from '@capacitor/core';
|
|
2
|
+
/**
|
|
3
|
+
* Capacitor configuration extension for the Integrity plugin.
|
|
4
|
+
*
|
|
5
|
+
* Configuration values defined here can be provided under the
|
|
6
|
+
* `plugins.Integrity` key inside `capacitor.config.ts`.
|
|
7
|
+
*
|
|
8
|
+
* These values are:
|
|
9
|
+
* - read natively at build/runtime
|
|
10
|
+
* - NOT accessible from JavaScript at runtime
|
|
11
|
+
* - treated as read-only static configuration
|
|
12
|
+
*
|
|
13
|
+
* @see https://capacitorjs.com/docs/plugins/configuration-values
|
|
14
|
+
*/
|
|
15
|
+
declare module '@capacitor/cli' {
|
|
16
|
+
interface PluginsConfig {
|
|
17
|
+
/**
|
|
18
|
+
* Configuration options for the Integrity plugin.
|
|
19
|
+
*/
|
|
20
|
+
Integrity?: IntegrityConfig;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Event payload emitted when a new integrity signal is detected.
|
|
25
|
+
*
|
|
26
|
+
* This event represents a *real-time observation* of a potential
|
|
27
|
+
* integrity-relevant condition on the device.
|
|
28
|
+
*
|
|
29
|
+
* IMPORTANT:
|
|
30
|
+
* - Signals are observational only.
|
|
31
|
+
* - Emitting a signal does NOT imply that the environment is compromised.
|
|
32
|
+
* - No blocking or enforcement is performed by the plugin.
|
|
33
|
+
*
|
|
34
|
+
* The host application is responsible for:
|
|
35
|
+
* - interpreting signals
|
|
36
|
+
* - correlating multiple signals
|
|
37
|
+
* - applying any security or UX policy
|
|
38
|
+
*
|
|
39
|
+
* @since 8.0.0
|
|
40
|
+
*/
|
|
41
|
+
export type IntegritySignalEvent = IntegritySignal;
|
|
42
|
+
/**
|
|
43
|
+
* Standardized error codes used by the Integrity plugin.
|
|
44
|
+
*
|
|
45
|
+
* Errors are delivered via Promise rejection with a structured
|
|
46
|
+
* `{ message, code }` object matching `IntegrityError`.
|
|
47
|
+
*
|
|
48
|
+
* @since 8.0.0
|
|
49
|
+
*/
|
|
50
|
+
export declare enum IntegrityErrorCode {
|
|
51
|
+
/** Required data is missing or the feature is not available. */
|
|
52
|
+
UNAVAILABLE = "UNAVAILABLE",
|
|
53
|
+
/** The user denied a required permission or the feature is disabled. */
|
|
54
|
+
PERMISSION_DENIED = "PERMISSION_DENIED",
|
|
55
|
+
/** The SSL pinning operation failed due to a runtime or initialization error. */
|
|
56
|
+
INIT_FAILED = "INIT_FAILED",
|
|
57
|
+
/** Invalid or unsupported input was provided. */
|
|
58
|
+
UNKNOWN_TYPE = "UNKNOWN_TYPE"
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Standard reason codes that MAY be used when presenting
|
|
62
|
+
* the integrity block page.
|
|
63
|
+
*
|
|
64
|
+
* These values are OPTIONAL and provided for convenience only.
|
|
65
|
+
* Applications may define and use their own custom reason strings.
|
|
66
|
+
*
|
|
67
|
+
* @since 8.0.0
|
|
68
|
+
*/
|
|
69
|
+
export declare enum IntegrityBlockReason {
|
|
70
|
+
COMPROMISED_ENVIRONMENT = "compromised_environment",
|
|
71
|
+
ROOT_DETECTED = "root_detected",
|
|
72
|
+
JAILBREAK_DETECTED = "jailbreak_detected",
|
|
73
|
+
EMULATOR_DETECTED = "emulator_detected",
|
|
74
|
+
DEBUG_ENVIRONMENT = "debug_environment",
|
|
75
|
+
INTEGRITY_FAILED = "integrity_failed"
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Static configuration options for the Integrity plugin.
|
|
79
|
+
*
|
|
80
|
+
* These values can be defined in `capacitor.config.ts` and are used
|
|
81
|
+
* natively as fallback values when runtime options are not provided.
|
|
82
|
+
*/
|
|
83
|
+
export interface IntegrityConfig {
|
|
84
|
+
/**
|
|
85
|
+
* Enables verbose native logging.
|
|
86
|
+
*
|
|
87
|
+
* When enabled, additional debug information is printed
|
|
88
|
+
* to the native console (Logcat on Android, Xcode on iOS).
|
|
89
|
+
*
|
|
90
|
+
* This option affects native logging behavior only and
|
|
91
|
+
* has no impact on the JavaScript API or runtime behavior.
|
|
92
|
+
*
|
|
93
|
+
* @default false
|
|
94
|
+
* @example true
|
|
95
|
+
* @since 8.0.0
|
|
96
|
+
*/
|
|
97
|
+
verboseLogging?: boolean;
|
|
98
|
+
/**
|
|
99
|
+
* Optional configuration for the integrity block page.
|
|
100
|
+
*
|
|
101
|
+
* This configuration controls the availability and source
|
|
102
|
+
* of a developer-provided HTML page that may be presented
|
|
103
|
+
* to the end user when the host application decides to do so.
|
|
104
|
+
*
|
|
105
|
+
* This configuration is:
|
|
106
|
+
* - read only by native code
|
|
107
|
+
* - immutable at runtime
|
|
108
|
+
* - NOT accessible from JavaScript
|
|
109
|
+
*
|
|
110
|
+
* The Integrity plugin will NEVER automatically present
|
|
111
|
+
* the block page. Presentation is always explicitly triggered
|
|
112
|
+
* by the host application via the public API.
|
|
113
|
+
*
|
|
114
|
+
* @since 8.0.0
|
|
115
|
+
*/
|
|
116
|
+
blockPage?: IntegrityBlockPageConfig;
|
|
117
|
+
/**
|
|
118
|
+
* Optional configuration for jailbreak URL scheme probing (iOS only).
|
|
119
|
+
*
|
|
120
|
+
* When enabled, the native iOS implementation may probe for
|
|
121
|
+
* known jailbreak-related applications using URL schemes
|
|
122
|
+
* such as `cydia://`.
|
|
123
|
+
*
|
|
124
|
+
* This configuration:
|
|
125
|
+
* - is read natively at runtime
|
|
126
|
+
* - is immutable
|
|
127
|
+
* - is NOT accessible from JavaScript
|
|
128
|
+
* - does NOT alter the public JavaScript API
|
|
129
|
+
*
|
|
130
|
+
* @since 8.0.0
|
|
131
|
+
*/
|
|
132
|
+
jailbreakUrlSchemes?: JailbreakUrlSchemesConfig;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
*
|
|
136
|
+
* @since 8.0.0
|
|
137
|
+
*/
|
|
138
|
+
export interface IntegrityBlockPageConfig {
|
|
139
|
+
/**
|
|
140
|
+
* Enables the block page feature.
|
|
141
|
+
*
|
|
142
|
+
* When set to false or omitted, calls to `presentBlockPage()`
|
|
143
|
+
* will be ignored or resolved as not presented.
|
|
144
|
+
*
|
|
145
|
+
* @default false
|
|
146
|
+
* @example true
|
|
147
|
+
* @since 8.0.0
|
|
148
|
+
*/
|
|
149
|
+
enabled?: boolean;
|
|
150
|
+
/**
|
|
151
|
+
* URL or local path of the HTML page to present.
|
|
152
|
+
*
|
|
153
|
+
* This value may reference:
|
|
154
|
+
* - a local file bundled with the application
|
|
155
|
+
* - a remote HTTPS URL
|
|
156
|
+
*
|
|
157
|
+
* Interpretation and loading are platform-specific
|
|
158
|
+
* and handled entirely by native code.
|
|
159
|
+
*
|
|
160
|
+
* @example 'integrity-block.html'
|
|
161
|
+
* @example 'https://example.com/integrity.html'
|
|
162
|
+
* @since 8.0.0
|
|
163
|
+
*/
|
|
164
|
+
url: string;
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Configuration for jailbreak URL scheme probing (iOS only).
|
|
168
|
+
*
|
|
169
|
+
* This configuration enables the Integrity plugin to probe for
|
|
170
|
+
* known jailbreak-related applications by checking whether
|
|
171
|
+
* specific URL schemes can be opened by the system.
|
|
172
|
+
*
|
|
173
|
+
* IMPORTANT:
|
|
174
|
+
* - This feature is **disabled by default**.
|
|
175
|
+
* - It is read natively and is NOT accessible from JavaScript at runtime.
|
|
176
|
+
* - Enabling this feature requires declaring the corresponding
|
|
177
|
+
* schemes in `LSApplicationQueriesSchemes` inside `Info.plist`.
|
|
178
|
+
* - This detection emits a LOW confidence signal and MUST NOT
|
|
179
|
+
* be treated as a standalone jailbreak decision.
|
|
180
|
+
*
|
|
181
|
+
* @since 8.0.0
|
|
182
|
+
*/
|
|
183
|
+
export interface JailbreakUrlSchemesConfig {
|
|
184
|
+
/**
|
|
185
|
+
* Enables jailbreak URL scheme probing.
|
|
186
|
+
*
|
|
187
|
+
* When set to false or omitted, no URL scheme probing
|
|
188
|
+
* will be performed by the native iOS implementation.
|
|
189
|
+
*
|
|
190
|
+
* @default false
|
|
191
|
+
* @example true
|
|
192
|
+
*/
|
|
193
|
+
enabled?: boolean;
|
|
194
|
+
/**
|
|
195
|
+
* List of URL schemes to probe.
|
|
196
|
+
*
|
|
197
|
+
* Each scheme should be provided WITHOUT the `://` suffix.
|
|
198
|
+
*
|
|
199
|
+
* @example ['cydia', 'sileo', 'zbra']
|
|
200
|
+
*/
|
|
201
|
+
schemes: string[];
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Category of a detected integrity signal.
|
|
205
|
+
*
|
|
206
|
+
* Categories are intentionally broad and stable.
|
|
207
|
+
* New detection techniques MUST reuse existing categories
|
|
208
|
+
* whenever possible to avoid breaking consumers.
|
|
209
|
+
*
|
|
210
|
+
* @since 8.0.0
|
|
211
|
+
*/
|
|
212
|
+
export type IntegritySignalCategory = 'root' | 'jailbreak' | 'emulator' | 'debug' | 'hook' | 'tamper' | 'environment';
|
|
213
|
+
/**
|
|
214
|
+
* Internal confidence levels used by native implementations.
|
|
215
|
+
*
|
|
216
|
+
* IMPORTANT:
|
|
217
|
+
* This enum is INTERNAL and MUST NOT be considered a public API.
|
|
218
|
+
* It exists to freeze semantic meaning and avoid string drift
|
|
219
|
+
* across platforms and future refactors.
|
|
220
|
+
*/
|
|
221
|
+
declare enum IntegrityConfidenceLevel {
|
|
222
|
+
LOW = "low",
|
|
223
|
+
MEDIUM = "medium",
|
|
224
|
+
HIGH = "high"
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* A single integrity signal detected on the current device.
|
|
228
|
+
*
|
|
229
|
+
* Signals represent *observations*, not decisions.
|
|
230
|
+
* Multiple signals MAY be combined by the host application
|
|
231
|
+
* to derive a security policy.
|
|
232
|
+
*
|
|
233
|
+
* Signals:
|
|
234
|
+
* - are emitted asynchronously
|
|
235
|
+
* - may occur at any time during the app lifecycle
|
|
236
|
+
* - may be emitted before or after the first call to `check()`
|
|
237
|
+
*
|
|
238
|
+
* @since 8.0.0
|
|
239
|
+
*/
|
|
240
|
+
export interface IntegritySignal {
|
|
241
|
+
/**
|
|
242
|
+
* Stable identifier for the signal.
|
|
243
|
+
*
|
|
244
|
+
* This value:
|
|
245
|
+
* - is stable across releases
|
|
246
|
+
* - MUST NOT be parsed or pattern-matched
|
|
247
|
+
* - is intended for analytics, logging, and policy evaluation
|
|
248
|
+
*/
|
|
249
|
+
id: string;
|
|
250
|
+
/**
|
|
251
|
+
* High-level category of the signal.
|
|
252
|
+
*
|
|
253
|
+
* Categories allow grouping related signals
|
|
254
|
+
* without relying on specific identifiers.
|
|
255
|
+
*/
|
|
256
|
+
category: IntegritySignalCategory;
|
|
257
|
+
/**
|
|
258
|
+
* Confidence level of the detection.
|
|
259
|
+
*
|
|
260
|
+
* This value expresses how strongly the signal correlates
|
|
261
|
+
* with a potentially compromised or risky environment.
|
|
262
|
+
*
|
|
263
|
+
* NOTE:
|
|
264
|
+
* Although typed as a string union in the public API,
|
|
265
|
+
* native implementations MUST only emit values defined
|
|
266
|
+
* by the internal IntegrityConfidenceLevel enum.
|
|
267
|
+
*/
|
|
268
|
+
confidence: IntegrityConfidenceLevel;
|
|
269
|
+
/**
|
|
270
|
+
* Optional human-readable description.
|
|
271
|
+
*
|
|
272
|
+
* This field:
|
|
273
|
+
* - is intended for diagnostics and debugging only
|
|
274
|
+
* - MAY be omitted or redacted in production builds
|
|
275
|
+
* - MUST NOT be relied upon programmatically
|
|
276
|
+
*/
|
|
277
|
+
description?: string;
|
|
278
|
+
/**
|
|
279
|
+
* Additional diagnostic metadata associated with the signal.
|
|
280
|
+
*
|
|
281
|
+
* Metadata provides granular details about the detection
|
|
282
|
+
* (e.g. matched filesystem paths, runtime artifacts,
|
|
283
|
+
* or environment properties) without altering the
|
|
284
|
+
* stable signal identifier.
|
|
285
|
+
*
|
|
286
|
+
* IMPORTANT:
|
|
287
|
+
* - Metadata is informational only.
|
|
288
|
+
* - Keys and values are NOT guaranteed to be stable.
|
|
289
|
+
* - Applications MUST NOT rely on specific metadata fields
|
|
290
|
+
* for security decisions.
|
|
291
|
+
*/
|
|
292
|
+
metadata?: Record<string, string | number | boolean>;
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* Summary of the execution environment in which
|
|
296
|
+
* the integrity check was performed.
|
|
297
|
+
*
|
|
298
|
+
* @since 8.0.0
|
|
299
|
+
*/
|
|
300
|
+
export interface IntegrityEnvironment {
|
|
301
|
+
/**
|
|
302
|
+
* Current platform.
|
|
303
|
+
*/
|
|
304
|
+
platform: 'ios' | 'android' | 'web';
|
|
305
|
+
/**
|
|
306
|
+
* Indicates whether the app is running
|
|
307
|
+
* in an emulator or simulator environment.
|
|
308
|
+
*/
|
|
309
|
+
isEmulator: boolean;
|
|
310
|
+
/**
|
|
311
|
+
* Indicates whether the app was built
|
|
312
|
+
* in debug/development mode.
|
|
313
|
+
*/
|
|
314
|
+
isDebugBuild: boolean;
|
|
315
|
+
}
|
|
316
|
+
/**
|
|
317
|
+
* Result object returned by `Integrity.check()`.
|
|
318
|
+
*
|
|
319
|
+
* This object aggregates all detected signals
|
|
320
|
+
and provides a provisional integrity score.
|
|
321
|
+
*
|
|
322
|
+
* @since 8.0.0
|
|
323
|
+
*/
|
|
324
|
+
export interface IntegrityReport {
|
|
325
|
+
/**
|
|
326
|
+
* Indicates whether the environment is considered compromised
|
|
327
|
+
* according to the current scoring model.
|
|
328
|
+
*/
|
|
329
|
+
compromised: boolean;
|
|
330
|
+
/**
|
|
331
|
+
* Provisional integrity score.
|
|
332
|
+
*
|
|
333
|
+
* The score ranges from 0 to 100 and is derived
|
|
334
|
+
* from the detected signals.
|
|
335
|
+
*/
|
|
336
|
+
score: number;
|
|
337
|
+
/**
|
|
338
|
+
* List of detected integrity signals.
|
|
339
|
+
*/
|
|
340
|
+
signals: IntegritySignal[];
|
|
341
|
+
/**
|
|
342
|
+
* Execution environment summary.
|
|
343
|
+
*/
|
|
344
|
+
environment: IntegrityEnvironment;
|
|
345
|
+
/**
|
|
346
|
+
* Unix timestamp (milliseconds) when the check was performed.
|
|
347
|
+
*/
|
|
348
|
+
timestamp: number;
|
|
349
|
+
/**
|
|
350
|
+
* Optional explanation metadata describing how the integrity score
|
|
351
|
+
* was derived from the detected signals.
|
|
352
|
+
*
|
|
353
|
+
* This field is informational only and MUST NOT be treated
|
|
354
|
+
* as a security decision or enforcement mechanism.
|
|
355
|
+
*
|
|
356
|
+
* @since 8.0.0
|
|
357
|
+
*/
|
|
358
|
+
scoreExplanation?: IntegrityScoreExplanation;
|
|
359
|
+
}
|
|
360
|
+
/**
|
|
361
|
+
* Describes how the integrity score was derived.
|
|
362
|
+
*
|
|
363
|
+
* This structure provides transparency and auditability
|
|
364
|
+
* without exposing internal scoring algorithms.
|
|
365
|
+
*
|
|
366
|
+
* @since 8.0.0
|
|
367
|
+
*/
|
|
368
|
+
export interface IntegrityScoreExplanation {
|
|
369
|
+
/**
|
|
370
|
+
* Total number of detected signals.
|
|
371
|
+
*/
|
|
372
|
+
totalSignals: number;
|
|
373
|
+
/**
|
|
374
|
+
* Breakdown of signals by confidence level.
|
|
375
|
+
*/
|
|
376
|
+
byConfidence: {
|
|
377
|
+
high: number;
|
|
378
|
+
medium: number;
|
|
379
|
+
low: number;
|
|
380
|
+
};
|
|
381
|
+
/**
|
|
382
|
+
* List of signal identifiers that contributed to the score.
|
|
383
|
+
*/
|
|
384
|
+
contributors: string[];
|
|
385
|
+
}
|
|
386
|
+
/**
|
|
387
|
+
* Options controlling the behavior of `Integrity.check()`.
|
|
388
|
+
*
|
|
389
|
+
* These options influence *how* checks are performed,
|
|
390
|
+
not *what* the public API returns.
|
|
391
|
+
*
|
|
392
|
+
* @since 8.0.0
|
|
393
|
+
*/
|
|
394
|
+
export interface IntegrityCheckOptions {
|
|
395
|
+
/**
|
|
396
|
+
* Desired strictness level.
|
|
397
|
+
*
|
|
398
|
+
* Higher levels may enable additional heuristics
|
|
399
|
+
* at the cost of performance.
|
|
400
|
+
*/
|
|
401
|
+
level?: 'basic' | 'standard' | 'strict';
|
|
402
|
+
/**
|
|
403
|
+
* Includes additional debug information
|
|
404
|
+
* in the returned signals when enabled.
|
|
405
|
+
*/
|
|
406
|
+
includeDebugInfo?: boolean;
|
|
407
|
+
}
|
|
408
|
+
/**
|
|
409
|
+
* Options for presenting the integrity block page.
|
|
410
|
+
*
|
|
411
|
+
* @since 8.0.0
|
|
412
|
+
*/
|
|
413
|
+
export interface PresentBlockPageOptions {
|
|
414
|
+
/**
|
|
415
|
+
* Optional reason code passed to the block page.
|
|
416
|
+
*
|
|
417
|
+
* This value may be used for analytics,
|
|
418
|
+
* localization, or user messaging.
|
|
419
|
+
*
|
|
420
|
+
* @since 8.0.0
|
|
421
|
+
*/
|
|
422
|
+
reason?: string;
|
|
423
|
+
/**
|
|
424
|
+
* Whether the block page can be dismissed by the user.
|
|
425
|
+
*
|
|
426
|
+
* Defaults to false.
|
|
427
|
+
* In production environments, this should typically remain disabled.
|
|
428
|
+
*
|
|
429
|
+
* @default false
|
|
430
|
+
* @since 8.0.0
|
|
431
|
+
*/
|
|
432
|
+
dismissible?: boolean;
|
|
433
|
+
}
|
|
434
|
+
/**
|
|
435
|
+
* Result object returned by `presentBlockPage()`.
|
|
436
|
+
*
|
|
437
|
+
* @since 8.0.0
|
|
438
|
+
*/
|
|
439
|
+
export interface PresentBlockPageResult {
|
|
440
|
+
/**
|
|
441
|
+
* Indicates whether the block page was actually presented.
|
|
442
|
+
*/
|
|
443
|
+
presented: boolean;
|
|
444
|
+
}
|
|
445
|
+
/**
|
|
446
|
+
* Result returned by the getPluginVersion method.
|
|
447
|
+
*/
|
|
448
|
+
export interface PluginVersionResult {
|
|
449
|
+
/** The native version string of the plugin. */
|
|
450
|
+
version: string;
|
|
451
|
+
}
|
|
452
|
+
/**
|
|
453
|
+
* Structured error object returned by Integrity plugin operations.
|
|
454
|
+
*
|
|
455
|
+
* This object allows consumers to handle errors without relying
|
|
456
|
+
* on exception-based control flow.
|
|
457
|
+
*
|
|
458
|
+
* @since 8.0.0
|
|
459
|
+
*/
|
|
460
|
+
export interface IntegrityError {
|
|
461
|
+
/**
|
|
462
|
+
* Human-readable error description.
|
|
463
|
+
*/
|
|
464
|
+
message: string;
|
|
465
|
+
/**
|
|
466
|
+
* Machine-readable error code.
|
|
467
|
+
*/
|
|
468
|
+
code: IntegrityErrorCode;
|
|
469
|
+
}
|
|
470
|
+
/**
|
|
471
|
+
* Public JavaScript API for the Integrity Capacitor plugin.
|
|
472
|
+
*
|
|
473
|
+
* This interface defines a stable, platform-agnostic API.
|
|
474
|
+
* All methods behave consistently across Android, iOS, and Web.
|
|
475
|
+
*/
|
|
476
|
+
export interface IntegrityPlugin {
|
|
477
|
+
/**
|
|
478
|
+
* Executes a runtime integrity check.
|
|
479
|
+
*
|
|
480
|
+
* @example
|
|
481
|
+
* ```ts
|
|
482
|
+
* const report = await Integrity.check();
|
|
483
|
+
* ```
|
|
484
|
+
*
|
|
485
|
+
* @since 8.0.0
|
|
486
|
+
*/
|
|
487
|
+
check(options?: IntegrityCheckOptions): Promise<IntegrityReport>;
|
|
488
|
+
/**
|
|
489
|
+
* Presents the configured integrity block page, if enabled.
|
|
490
|
+
*
|
|
491
|
+
* The plugin never decides *when* this method should be called.
|
|
492
|
+
* Invocation is entirely controlled by the host application.
|
|
493
|
+
*
|
|
494
|
+
* @example
|
|
495
|
+
* ```ts
|
|
496
|
+
* await Integrity.presentBlockPage({ reason: 'integrity_failed' });
|
|
497
|
+
* ```
|
|
498
|
+
*
|
|
499
|
+
* @since 8.0.0
|
|
500
|
+
*/
|
|
501
|
+
presentBlockPage(options?: PresentBlockPageOptions): Promise<PresentBlockPageResult>;
|
|
502
|
+
/**
|
|
503
|
+
* Returns the native plugin version.
|
|
504
|
+
*
|
|
505
|
+
* The returned version corresponds to the native implementation
|
|
506
|
+
* bundled with the application.
|
|
507
|
+
*
|
|
508
|
+
* @returns A promise resolving to the plugin version.
|
|
509
|
+
*
|
|
510
|
+
* @example
|
|
511
|
+
* ```ts
|
|
512
|
+
* const { version } = await Integrity.getPluginVersion();
|
|
513
|
+
* ```
|
|
514
|
+
*
|
|
515
|
+
* @since 8.0.0
|
|
516
|
+
*/
|
|
517
|
+
getPluginVersion(): Promise<PluginVersionResult>;
|
|
518
|
+
/**
|
|
519
|
+
* Registers a listener for real-time integrity signals.
|
|
520
|
+
*
|
|
521
|
+
* The provided callback is invoked every time a new integrity
|
|
522
|
+
* signal is detected by the native layer.
|
|
523
|
+
*
|
|
524
|
+
* BEHAVIOR:
|
|
525
|
+
* - Signals may be emitted at any time after plugin initialization.
|
|
526
|
+
* - Signals detected before listener registration MAY be delivered
|
|
527
|
+
* immediately after registration.
|
|
528
|
+
* - No guarantees are made about signal frequency or ordering
|
|
529
|
+
* across platforms.
|
|
530
|
+
*
|
|
531
|
+
* IMPORTANT:
|
|
532
|
+
* - This listener is non-blocking.
|
|
533
|
+
* - The plugin does NOT enforce any policy based on signals.
|
|
534
|
+
*
|
|
535
|
+
* @param eventName The event to listen for ('integritySignal').
|
|
536
|
+
* @param listenerFunc Callback invoked with the detected signal.
|
|
537
|
+
* @returns A Promise resolving to a `PluginListenerHandle`.
|
|
538
|
+
*
|
|
539
|
+
* @since 8.0.0
|
|
540
|
+
*/
|
|
541
|
+
addListener(eventName: 'integritySignal', listenerFunc: (signal: IntegritySignalEvent) => void): Promise<PluginListenerHandle>;
|
|
542
|
+
/**
|
|
543
|
+
* Removes all registered listeners for this plugin.
|
|
544
|
+
*
|
|
545
|
+
* NOTE:
|
|
546
|
+
* - Removing listeners does NOT stop signal detection natively.
|
|
547
|
+
* - Signals may continue to be detected and buffered
|
|
548
|
+
* until a listener is registered again.
|
|
549
|
+
*
|
|
550
|
+
* @since 8.0.0
|
|
551
|
+
*/
|
|
552
|
+
removeAllListeners(): Promise<void>;
|
|
553
|
+
}
|
|
554
|
+
export {};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/// <reference types="@capacitor/cli" />
|
|
2
|
+
// -----------------------------------------------------------------------------
|
|
3
|
+
// Enums
|
|
4
|
+
// -----------------------------------------------------------------------------
|
|
5
|
+
/**
|
|
6
|
+
* Standardized error codes used by the Integrity plugin.
|
|
7
|
+
*
|
|
8
|
+
* Errors are delivered via Promise rejection with a structured
|
|
9
|
+
* `{ message, code }` object matching `IntegrityError`.
|
|
10
|
+
*
|
|
11
|
+
* @since 8.0.0
|
|
12
|
+
*/
|
|
13
|
+
export var IntegrityErrorCode;
|
|
14
|
+
(function (IntegrityErrorCode) {
|
|
15
|
+
/** Required data is missing or the feature is not available. */
|
|
16
|
+
IntegrityErrorCode["UNAVAILABLE"] = "UNAVAILABLE";
|
|
17
|
+
/** The user denied a required permission or the feature is disabled. */
|
|
18
|
+
IntegrityErrorCode["PERMISSION_DENIED"] = "PERMISSION_DENIED";
|
|
19
|
+
/** The SSL pinning operation failed due to a runtime or initialization error. */
|
|
20
|
+
IntegrityErrorCode["INIT_FAILED"] = "INIT_FAILED";
|
|
21
|
+
/** Invalid or unsupported input was provided. */
|
|
22
|
+
IntegrityErrorCode["UNKNOWN_TYPE"] = "UNKNOWN_TYPE";
|
|
23
|
+
})(IntegrityErrorCode || (IntegrityErrorCode = {}));
|
|
24
|
+
/**
|
|
25
|
+
* Standard reason codes that MAY be used when presenting
|
|
26
|
+
* the integrity block page.
|
|
27
|
+
*
|
|
28
|
+
* These values are OPTIONAL and provided for convenience only.
|
|
29
|
+
* Applications may define and use their own custom reason strings.
|
|
30
|
+
*
|
|
31
|
+
* @since 8.0.0
|
|
32
|
+
*/
|
|
33
|
+
export var IntegrityBlockReason;
|
|
34
|
+
(function (IntegrityBlockReason) {
|
|
35
|
+
IntegrityBlockReason["COMPROMISED_ENVIRONMENT"] = "compromised_environment";
|
|
36
|
+
IntegrityBlockReason["ROOT_DETECTED"] = "root_detected";
|
|
37
|
+
IntegrityBlockReason["JAILBREAK_DETECTED"] = "jailbreak_detected";
|
|
38
|
+
IntegrityBlockReason["EMULATOR_DETECTED"] = "emulator_detected";
|
|
39
|
+
IntegrityBlockReason["DEBUG_ENVIRONMENT"] = "debug_environment";
|
|
40
|
+
IntegrityBlockReason["INTEGRITY_FAILED"] = "integrity_failed";
|
|
41
|
+
})(IntegrityBlockReason || (IntegrityBlockReason = {}));
|
|
42
|
+
/**
|
|
43
|
+
* Internal confidence levels used by native implementations.
|
|
44
|
+
*
|
|
45
|
+
* IMPORTANT:
|
|
46
|
+
* This enum is INTERNAL and MUST NOT be considered a public API.
|
|
47
|
+
* It exists to freeze semantic meaning and avoid string drift
|
|
48
|
+
* across platforms and future refactors.
|
|
49
|
+
*/
|
|
50
|
+
var IntegrityConfidenceLevel;
|
|
51
|
+
(function (IntegrityConfidenceLevel) {
|
|
52
|
+
IntegrityConfidenceLevel["LOW"] = "low";
|
|
53
|
+
IntegrityConfidenceLevel["MEDIUM"] = "medium";
|
|
54
|
+
IntegrityConfidenceLevel["HIGH"] = "high";
|
|
55
|
+
})(IntegrityConfidenceLevel || (IntegrityConfidenceLevel = {}));
|
|
56
|
+
//# sourceMappingURL=definitions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAAA,wCAAwC;AAkDxC,gFAAgF;AAChF,QAAQ;AACR,gFAAgF;AAEhF;;;;;;;GAOG;AACH,MAAM,CAAN,IAAY,kBAYX;AAZD,WAAY,kBAAkB;IAC5B,gEAAgE;IAChE,iDAA2B,CAAA;IAE3B,wEAAwE;IACxE,6DAAuC,CAAA;IAEvC,iFAAiF;IACjF,iDAA2B,CAAA;IAE3B,iDAAiD;IACjD,mDAA6B,CAAA;AAC/B,CAAC,EAZW,kBAAkB,KAAlB,kBAAkB,QAY7B;AAED;;;;;;;;GAQG;AACH,MAAM,CAAN,IAAY,oBAOX;AAPD,WAAY,oBAAoB;IAC9B,2EAAmD,CAAA;IACnD,uDAA+B,CAAA;IAC/B,iEAAyC,CAAA;IACzC,+DAAuC,CAAA;IACvC,+DAAuC,CAAA;IACvC,6DAAqC,CAAA;AACvC,CAAC,EAPW,oBAAoB,KAApB,oBAAoB,QAO/B;AAsJD;;;;;;;GAOG;AACH,IAAK,wBAIJ;AAJD,WAAK,wBAAwB;IAC3B,uCAAW,CAAA;IACX,6CAAiB,CAAA;IACjB,yCAAa,CAAA;AACf,CAAC,EAJI,wBAAwB,KAAxB,wBAAwB,QAI5B"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file index.ts
|
|
3
|
+
* Main entry point for the Integrity Capacitor Plugin.
|
|
4
|
+
* This file handles the registration of the plugin with the Capacitor core runtime
|
|
5
|
+
* and exports all necessary types for consumers.
|
|
6
|
+
*/
|
|
7
|
+
import { IntegrityPlugin } from './definitions';
|
|
8
|
+
/**
|
|
9
|
+
* The Integrity plugin instance.
|
|
10
|
+
* It automatically lazy-loads the web implementation if running in a browser environment.
|
|
11
|
+
* Use this instance to access all ssl pinning functionality.
|
|
12
|
+
*/
|
|
13
|
+
declare const Integrity: IntegrityPlugin;
|
|
14
|
+
export * from './definitions';
|
|
15
|
+
export { Integrity };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Import the `registerPlugin` method from the Capacitor core library.
|
|
3
|
+
* This method is used to register a custom plugin.
|
|
4
|
+
*/
|
|
5
|
+
import { registerPlugin } from '@capacitor/core';
|
|
6
|
+
/**
|
|
7
|
+
* The Integrity plugin instance.
|
|
8
|
+
* It automatically lazy-loads the web implementation if running in a browser environment.
|
|
9
|
+
* Use this instance to access all ssl pinning functionality.
|
|
10
|
+
*/
|
|
11
|
+
const Integrity = registerPlugin('Integrity', {
|
|
12
|
+
web: () => import('./web').then((m) => new m.IntegrityWeb()),
|
|
13
|
+
});
|
|
14
|
+
export * from './definitions';
|
|
15
|
+
export { Integrity };
|
|
16
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAWjD;;;;GAIG;AACH,MAAM,SAAS,GAAG,cAAc,CAAkB,WAAW,EAAE;IAC7D,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,YAAY,EAAE,CAAC;CAC7D,CAAC,CAAC;AAEH,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,SAAS,EAAE,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { WebPlugin } from '@capacitor/core';
|
|
2
|
+
import { IntegrityPlugin, IntegrityReport, PresentBlockPageResult, PluginVersionResult } from './definitions';
|
|
3
|
+
/**
|
|
4
|
+
* Web implementation of the Integrity plugin.
|
|
5
|
+
*
|
|
6
|
+
* This implementation exists to preserve API parity
|
|
7
|
+
* across all platforms.
|
|
8
|
+
*
|
|
9
|
+
* The Web platform does NOT provide native integrity signals.
|
|
10
|
+
* Therefore, most methods are explicitly unavailable.
|
|
11
|
+
*/
|
|
12
|
+
export declare class IntegrityWeb extends WebPlugin implements IntegrityPlugin {
|
|
13
|
+
constructor();
|
|
14
|
+
/**
|
|
15
|
+
* Executes a runtime integrity check.
|
|
16
|
+
*
|
|
17
|
+
* On Web, this feature is not available.
|
|
18
|
+
*/
|
|
19
|
+
check(): Promise<IntegrityReport>;
|
|
20
|
+
/**
|
|
21
|
+
* Presents the integrity block page.
|
|
22
|
+
*
|
|
23
|
+
* On Web, this feature is not available.
|
|
24
|
+
*/
|
|
25
|
+
presentBlockPage(): Promise<PresentBlockPageResult>;
|
|
26
|
+
/**
|
|
27
|
+
* Returns the plugin version.
|
|
28
|
+
*
|
|
29
|
+
* On Web, this represents the JavaScript package version.
|
|
30
|
+
*/
|
|
31
|
+
getPluginVersion(): Promise<PluginVersionResult>;
|
|
32
|
+
}
|