@cap-kit/ssl-pinning 8.0.0-next.0

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 (42) hide show
  1. package/CapKitSSLPinning.podspec +17 -0
  2. package/LICENSE +21 -0
  3. package/Package.swift +25 -0
  4. package/README.md +750 -0
  5. package/android/build.gradle +103 -0
  6. package/android/src/main/AndroidManifest.xml +3 -0
  7. package/android/src/main/java/io/capkit/sslpinning/SSLPinningConfig.kt +22 -0
  8. package/android/src/main/java/io/capkit/sslpinning/SSLPinningImpl.kt +188 -0
  9. package/android/src/main/java/io/capkit/sslpinning/SSLPinningPlugin.kt +82 -0
  10. package/android/src/main/java/io/capkit/sslpinning/utils/SSLPinningLogger.kt +85 -0
  11. package/android/src/main/java/io/capkit/sslpinning/utils/SSLPinningUtils.kt +44 -0
  12. package/android/src/main/res/.gitkeep +0 -0
  13. package/dist/cli/fingerprint.js +163 -0
  14. package/dist/cli/fingerprint.js.map +1 -0
  15. package/dist/docs.json +430 -0
  16. package/dist/esm/cli/fingerprint.d.ts +1 -0
  17. package/dist/esm/cli/fingerprint.js +161 -0
  18. package/dist/esm/cli/fingerprint.js.map +1 -0
  19. package/dist/esm/definitions.d.ts +285 -0
  20. package/dist/esm/definitions.js +18 -0
  21. package/dist/esm/definitions.js.map +1 -0
  22. package/dist/esm/index.d.ts +15 -0
  23. package/dist/esm/index.js +16 -0
  24. package/dist/esm/index.js.map +1 -0
  25. package/dist/esm/web.d.ts +58 -0
  26. package/dist/esm/web.js +54 -0
  27. package/dist/esm/web.js.map +1 -0
  28. package/dist/plugin.cjs.js +95 -0
  29. package/dist/plugin.cjs.js.map +1 -0
  30. package/dist/plugin.js +98 -0
  31. package/dist/plugin.js.map +1 -0
  32. package/ios/Sources/SSLPinningPlugin/SSLPinningConfig.swift +79 -0
  33. package/ios/Sources/SSLPinningPlugin/SSLPinningDelegate.swift +81 -0
  34. package/ios/Sources/SSLPinningPlugin/SSLPinningImpl.swift +111 -0
  35. package/ios/Sources/SSLPinningPlugin/SSLPinningPlugin.swift +116 -0
  36. package/ios/Sources/SSLPinningPlugin/Utils/SSLPinningLogger.swift +57 -0
  37. package/ios/Sources/SSLPinningPlugin/Utils/SSLPinningUtils.swift +47 -0
  38. package/ios/Sources/SSLPinningPlugin/Version.swift +16 -0
  39. package/ios/Tests/SSLPinningPluginTests/SSLPinningPluginTests.swift +5 -0
  40. package/package.json +117 -0
  41. package/scripts/chmod.js +34 -0
  42. package/scripts/sync-version.js +49 -0
@@ -0,0 +1,285 @@
1
+ /**
2
+ * Extension of the Capacitor CLI configuration to include specific settings for People.
3
+ * This allows users to configure the plugin via capacitor.config.ts or capacitor.config.json.
4
+ */
5
+ declare module '@capacitor/cli' {
6
+ interface PluginsConfig {
7
+ /**
8
+ * Configuration options for the SSLPinning plugin.
9
+ */
10
+ SSLPinning?: SSLPinningConfig;
11
+ }
12
+ }
13
+ /**
14
+ * Standardized error codes for programmatic handling of ssl pinning failures.
15
+ * @since 0.0.15
16
+ */
17
+ export declare enum SSLPinningErrorCode {
18
+ /** The device does not have the requested hardware. */
19
+ UNAVAILABLE = "UNAVAILABLE",
20
+ /** The user denied the permission or the feature is disabled in settings. */
21
+ PERMISSION_DENIED = "PERMISSION_DENIED",
22
+ /** The ssl pinning failed to initialize (e.g., runtime error or Looper failure). */
23
+ INIT_FAILED = "INIT_FAILED",
24
+ /** The requested ssl pinning type is not valid or not supported by the plugin. */
25
+ UNKNOWN_TYPE = "UNKNOWN_TYPE"
26
+ }
27
+ /**
28
+ * Configuration options for initializing the People plugin.
29
+ * These values can be set in capacitor.config.ts.
30
+ */
31
+ export interface SSLPinningConfig {
32
+ /**
33
+ * Enables detailed logging in the native console (Logcat/Xcode).
34
+ * Useful for debugging sensor data flow and lifecycle events.
35
+ * @example true
36
+ * @default false
37
+ *
38
+ * @since 0.0.15
39
+ */
40
+ verboseLogging?: boolean;
41
+ /**
42
+ * Default fingerprint used by checkCertificate()
43
+ * if no arguments are provided.
44
+ * @example "50:4B:A1:B5:48:96:71:F3:9F:87:7E:0A:09:FD:3E:1B:C0:4F:AA:9F:FC:83:3E:A9:3A:00:78:88:F8:BA:60:26"
45
+ * @default undefined
46
+ *
47
+ * @since 0.0.14
48
+ */
49
+ fingerprint?: string;
50
+ /**
51
+ * Default fingerprints used by checkCertificates()
52
+ * if no arguments are provided.
53
+ * @example ["50:4B:A1:B5:48:96:71:F3:9F:87:7E:0A:09:FD:3E:1B:C0:4F:AA:9F:FC:83:3E:A9:3A:00:78:88:F8:BA:60:26"]
54
+ * @default undefined
55
+ *
56
+ * @since 0.0.15
57
+ */
58
+ fingerprints?: string[];
59
+ }
60
+ /**
61
+ * Options for checking a single SSL certificate.
62
+ */
63
+ export interface SSLPinningOptions {
64
+ /**
65
+ * The URL of the server whose SSL certificate needs to be checked.
66
+ * @example "https://example.com"
67
+ */
68
+ url: string;
69
+ /**
70
+ * The expected fingerprint of the SSL certificate to validate against.
71
+ * This is typically a hash string such as SHA-256.
72
+ */
73
+ fingerprint: string;
74
+ }
75
+ /**
76
+ * Options for checking multiple SSL certificates.
77
+ */
78
+ export interface SSLPinningMultiOptions {
79
+ /**
80
+ * The URL of the server whose SSL certificate needs to be checked.
81
+ * @example "https://example.com"
82
+ */
83
+ url: string;
84
+ /**
85
+ * The expected fingerprints of the SSL certificate to validate against.
86
+ * This is typically an array of hash strings such as SHA-256.
87
+ */
88
+ fingerprints: string[];
89
+ }
90
+ /**
91
+ * Result returned by the SSL certificate check.
92
+ *
93
+ * NOTE:
94
+ * On iOS (Swift Package Manager), errors are returned
95
+ * as part of the resolved result object rather than
96
+ * Promise rejections.
97
+ */
98
+ export interface SSLPinningResult {
99
+ /**
100
+ * The subject of the certificate, representing the entity the certificate is issued to.
101
+ * @platform Android
102
+ * @example "CN=example.com, O=Example Corp, C=US"
103
+ */
104
+ subject?: string;
105
+ /**
106
+ * The issuer of the certificate, indicating the certificate authority that issued it.
107
+ * Results may vary slightly between iOS and Android platforms.
108
+ * @example "CN=Example CA, O=Example Corp, C=US"
109
+ */
110
+ issuer?: string;
111
+ /**
112
+ * The start date from which the certificate is valid.
113
+ * Format: ISO 8601 string or platform-specific date representation.
114
+ * @platform Android
115
+ * @example "2023-01-01T00:00:00Z"
116
+ */
117
+ validFrom?: string;
118
+ /**
119
+ * The end date until which the certificate is valid.
120
+ * Format: ISO 8601 string or platform-specific date representation.
121
+ * @platform Android
122
+ * @example "2024-01-01T00:00:00Z"
123
+ */
124
+ validTo?: string;
125
+ /**
126
+ * The fingerprint that is expected to match the certificate's actual fingerprint.
127
+ * This is typically provided in the SSLPinningOptions.
128
+ */
129
+ expectedFingerprint?: string;
130
+ /**
131
+ * The actual fingerprint of the SSL certificate retrieved from the server.
132
+ * @example "50:4B:A1:B5:48:96:71:F3:9F:87:7E:0A:09:FD:3E:1B:C0:4F:AA:9F:FC:83:3E:A9:3A:00:78:88:F8:BA:60:26"
133
+ */
134
+ actualFingerprint?: string;
135
+ /**
136
+ * Indicates whether the actual fingerprint matches the expected fingerprint.
137
+ * `true` if they match, `false` otherwise.
138
+ */
139
+ fingerprintMatched?: boolean;
140
+ /**
141
+ * A descriptive error message if an issue occurred during the SSL certificate check.
142
+ * @example "Unable to retrieve certificate from the server."
143
+ */
144
+ error?: string;
145
+ }
146
+ /**
147
+ * Result returned by the getPluginVersion method.
148
+ */
149
+ export interface PluginVersionResult {
150
+ /** The native version string of the plugin. */
151
+ version: string;
152
+ }
153
+ /**
154
+ * Error object returned by ssl pinning operations.
155
+ * Includes the ssl pinning type and a descriptive message.
156
+ */
157
+ export interface SSLPinningError {
158
+ /** A descriptive error message */
159
+ message: string;
160
+ /** Standardized error code */
161
+ code: SSLPinningErrorCode;
162
+ }
163
+ /**
164
+ * Result returned by the getPluginVersion method.
165
+ */
166
+ export interface PluginVersionResult {
167
+ /** The native version string of the plugin. */
168
+ version: string;
169
+ }
170
+ /**
171
+ * Interface defining the structure of an SSL Certificate Checker Plugin.
172
+ *
173
+ * Implementations of this interface should provide the logic for checking
174
+ * the status and details of an SSL certificate based on the provided options.
175
+ */
176
+ export interface SSLPinningPlugin {
177
+ /**
178
+ * Check the SSL certificate of a server.
179
+ *
180
+ * @param options - Options for checking the SSL certificate.
181
+ * @returns A promise resolving to the result of the SSL certificate check.
182
+ * @throws SSLPinningError if the check fails.
183
+ *
184
+ * @example
185
+ * ```typescript
186
+ * import { SSLPinning } from '@cap-kit/ssl-pinning';
187
+ *
188
+ * const result = await SSLPinning.checkCertificate({
189
+ * url: 'https://example.com',
190
+ * fingerprint: '50:4B:A1:B5:48:96:71:F3:9F:87:7E:0A:09:FD:3E:1B:C0:4F:AA:9F:FC:83:3E:A9:3A:00:78:88:F8:BA:60:26'
191
+ * });
192
+ *
193
+ * console.log('SSL Pinning Result:', result);
194
+ * ```
195
+ *
196
+ * @since 0.0.14
197
+ */
198
+ checkCertificate(): Promise<SSLPinningResult>;
199
+ /**
200
+ * Check the SSL certificate of a server.
201
+ * @param options - Options for checking the SSL certificate.
202
+ * @returns A promise resolving to the result of the SSL certificate check.
203
+ * @throws SSLPinningError if the check fails.
204
+ *
205
+ * @example
206
+ * ```typescript
207
+ * import { SSLPinning } from '@cap-kit/ssl-pinning';
208
+ *
209
+ * const result = await SSLPinning.checkCertificate({
210
+ * url: 'https://example.com',
211
+ * fingerprint: '50:4B:A1:B5:48:96:71:F3:9F:87:7E:0A:09:FD:3E:1B:C0:4F:AA:9F:FC:83:3E:A9:3A:00:78:88:F8:BA:60:26'
212
+ * });
213
+ *
214
+ * console.log('SSL Pinning Result:', result);
215
+ * ```
216
+ *
217
+ * @since 0.0.14
218
+ */
219
+ checkCertificate(options: SSLPinningOptions): Promise<SSLPinningResult>;
220
+ /**
221
+ * Check the SSL certificates of multiple servers.
222
+ *
223
+ * @returns A promise resolving to an array of results for each SSL certificate check.
224
+ * @throws SSLPinningError if any of the checks fail.
225
+ *
226
+ * @example
227
+ * ```typescript
228
+ * import { SSLPinning } from '@cap-kit/ssl-pinning';
229
+ *
230
+ * const results = await SSLPinning.checkCertificates();
231
+ *
232
+ * results.forEach(result => {
233
+ * console.log('SSL Pinning Result:', result);
234
+ * });
235
+ * ```
236
+ *
237
+ * @since 0.0.15
238
+ */
239
+ checkCertificates(): Promise<SSLPinningResult[]>;
240
+ /**
241
+ * Check the SSL certificates of multiple servers.
242
+ * @returns A promise resolving to an array of results for each SSL certificate check.
243
+ * @throws SSLPinningError if any of the checks fail.
244
+ * @param options - Options for checking the SSL certificates.
245
+ *
246
+ * @example
247
+ * ```typescript
248
+ * import { SSLPinning } from '@cap-kit/ssl-pinning';
249
+ *
250
+ * const results = await SSLPinning.checkCertificates([
251
+ * {
252
+ * url: 'https://example.com',
253
+ * fingerprints: ['50:4B:A1:B5:48:96:71:F3:9F:87:7E:0A:09:FD:3E:1B:C0:4F:AA:9F:FC:83:3E:A9:3A:00:78:88:F8:BA:60:26']
254
+ * },
255
+ * {
256
+ * url: 'https://another-example.com',
257
+ * fingerprints: ['AB:CD:EF:12:34:56:78:90:AB:CD:EF:12:34:56:78:90:AB:CD:EF:12:34:56:78:90:AB:CD:EF:12:34:56:78:90']
258
+ * }
259
+ * ]);
260
+ *
261
+ * results.forEach(result => {
262
+ * console.log('SSL Pinning Result:', result);
263
+ * });
264
+ * ```
265
+ *
266
+ * @since 0.0.15
267
+ */
268
+ checkCertificates(options: SSLPinningMultiOptions[]): Promise<SSLPinningResult[]>;
269
+ /**
270
+ * Returns the native plugin version.
271
+ *
272
+ * The returned version corresponds to the native implementation
273
+ * bundled with the application.
274
+ *
275
+ * @returns A promise resolving to the plugin version.
276
+ *
277
+ * @example
278
+ * ```ts
279
+ * const { version } = await SSLPinning.getPluginVersion();
280
+ * ```
281
+ *
282
+ * @since 0.0.15
283
+ */
284
+ getPluginVersion(): Promise<PluginVersionResult>;
285
+ }
@@ -0,0 +1,18 @@
1
+ /// <reference types="@capacitor/cli" />
2
+ // -- Enums --
3
+ /**
4
+ * Standardized error codes for programmatic handling of ssl pinning failures.
5
+ * @since 0.0.15
6
+ */
7
+ export var SSLPinningErrorCode;
8
+ (function (SSLPinningErrorCode) {
9
+ /** The device does not have the requested hardware. */
10
+ SSLPinningErrorCode["UNAVAILABLE"] = "UNAVAILABLE";
11
+ /** The user denied the permission or the feature is disabled in settings. */
12
+ SSLPinningErrorCode["PERMISSION_DENIED"] = "PERMISSION_DENIED";
13
+ /** The ssl pinning failed to initialize (e.g., runtime error or Looper failure). */
14
+ SSLPinningErrorCode["INIT_FAILED"] = "INIT_FAILED";
15
+ /** The requested ssl pinning type is not valid or not supported by the plugin. */
16
+ SSLPinningErrorCode["UNKNOWN_TYPE"] = "UNKNOWN_TYPE";
17
+ })(SSLPinningErrorCode || (SSLPinningErrorCode = {}));
18
+ //# sourceMappingURL=definitions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAAA,wCAAwC;AAexC,cAAc;AAEd;;;GAGG;AACH,MAAM,CAAN,IAAY,mBASX;AATD,WAAY,mBAAmB;IAC7B,uDAAuD;IACvD,kDAA2B,CAAA;IAC3B,6EAA6E;IAC7E,8DAAuC,CAAA;IACvC,oFAAoF;IACpF,kDAA2B,CAAA;IAC3B,kFAAkF;IAClF,oDAA6B,CAAA;AAC/B,CAAC,EATW,mBAAmB,KAAnB,mBAAmB,QAS9B"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * @file index.ts
3
+ * Main entry point for the SSLPinning 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 { SSLPinningPlugin } from './definitions';
8
+ /**
9
+ * The SSLPinning 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 SSLPinning: SSLPinningPlugin;
14
+ export * from './definitions';
15
+ export { SSLPinning };
@@ -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 SSLPinning 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 SSLPinning = registerPlugin('SSLPinning', {
12
+ web: () => import('./web').then((m) => new m.SSLPinningWeb()),
13
+ });
14
+ export * from './definitions';
15
+ export { SSLPinning };
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,UAAU,GAAG,cAAc,CAAmB,YAAY,EAAE;IAChE,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,aAAa,EAAE,CAAC;CAC9D,CAAC,CAAC;AAEH,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,UAAU,EAAE,CAAC"}
@@ -0,0 +1,58 @@
1
+ /**
2
+ * This module provides a web implementation of the SSLPinningPlugin.
3
+ * The functionality is limited in a web context due to the lack of SSL certificate inspection capabilities in browsers.
4
+ *
5
+ * The implementation adheres to the SSLPinningPlugin interface but provides fallback behavior
6
+ * because browsers do not allow direct inspection of SSL certificate details.
7
+ */
8
+ import { WebPlugin } from '@capacitor/core';
9
+ import { PluginVersionResult, SSLPinningMultiOptions, SSLPinningOptions, SSLPinningPlugin, SSLPinningResult } from './definitions';
10
+ /**
11
+ * Web implementation of the SSLPinningPlugin interface.
12
+ *
13
+ * This class is intended to be used in a browser environment and handles scenarios where SSL certificate
14
+ * checking is unsupported. It implements the methods defined by the SSLPinningPlugin
15
+ * interface but returns standardized error responses to indicate the lack of functionality in web contexts.
16
+ */
17
+ export declare class SSLPinningWeb extends WebPlugin implements SSLPinningPlugin {
18
+ /**
19
+ * Checks a single SSL certificate against the expected fingerprint.
20
+ * @param options - The options for checking the certificate.
21
+ * @returns A promise that resolves to the result of the certificate check.
22
+ */
23
+ checkCertificate(): Promise<SSLPinningResult>;
24
+ /**
25
+ * Checks a single SSL certificate against the expected fingerprint.
26
+ * @param options - The options for checking the certificate.
27
+ * @returns A promise that resolves to the result of the certificate check.
28
+ */
29
+ checkCertificate(_: SSLPinningOptions): Promise<SSLPinningResult>;
30
+ /**
31
+ * Checks multiple SSL certificates against their expected fingerprints.
32
+ * @return A promise that resolves to an array of results for each certificate check.
33
+ * @throws CapacitorException indicating unimplemented functionality.
34
+ */
35
+ checkCertificates(): Promise<SSLPinningResult[]>;
36
+ /**
37
+ * Checks multiple SSL certificates against their expected fingerprints.
38
+ * @param options - The options for checking multiple certificates.
39
+ * @return A promise that resolves to an array of results for each certificate check.
40
+ * @throws CapacitorException indicating unimplemented functionality.
41
+ */
42
+ checkCertificates(_: SSLPinningMultiOptions[]): Promise<SSLPinningResult[]>;
43
+ /**
44
+ * Returns the plugin version.
45
+ *
46
+ * @returns The current plugin version.
47
+ */
48
+ getPluginVersion(): Promise<PluginVersionResult>;
49
+ /**
50
+ * Creates a standardized exception for unimplemented methods.
51
+ *
52
+ * This utility method centralizes the creation of exceptions for functionality that is not supported
53
+ * on the current platform, ensuring consistency in error reporting.
54
+ *
55
+ * @returns {CapacitorException} An exception with the code `Unimplemented` and a descriptive message.
56
+ */
57
+ private createUnimplementedError;
58
+ }
@@ -0,0 +1,54 @@
1
+ /**
2
+ * This module provides a web implementation of the SSLPinningPlugin.
3
+ * The functionality is limited in a web context due to the lack of SSL certificate inspection capabilities in browsers.
4
+ *
5
+ * The implementation adheres to the SSLPinningPlugin interface but provides fallback behavior
6
+ * because browsers do not allow direct inspection of SSL certificate details.
7
+ */
8
+ import { CapacitorException, ExceptionCode, WebPlugin } from '@capacitor/core';
9
+ /**
10
+ * Web implementation of the SSLPinningPlugin interface.
11
+ *
12
+ * This class is intended to be used in a browser environment and handles scenarios where SSL certificate
13
+ * checking is unsupported. It implements the methods defined by the SSLPinningPlugin
14
+ * interface but returns standardized error responses to indicate the lack of functionality in web contexts.
15
+ */
16
+ export class SSLPinningWeb extends WebPlugin {
17
+ /**
18
+ * Checks a single SSL certificate against the expected fingerprint.
19
+ * @return A promise that resolves to the result of the certificate check.
20
+ * @throws CapacitorException indicating unimplemented functionality.
21
+ */
22
+ async checkCertificate() {
23
+ throw this.createUnimplementedError();
24
+ }
25
+ /**
26
+ * Checks multiple SSL certificates against their expected fingerprints.
27
+ * @return A promise that resolves to an array of results for each certificate check.
28
+ * @throws CapacitorException indicating unimplemented functionality.
29
+ */
30
+ async checkCertificates() {
31
+ throw this.createUnimplementedError();
32
+ }
33
+ // --- Plugin Info ---
34
+ /**
35
+ * Returns the plugin version.
36
+ *
37
+ * @returns The current plugin version.
38
+ */
39
+ async getPluginVersion() {
40
+ return { version: 'web' };
41
+ }
42
+ /**
43
+ * Creates a standardized exception for unimplemented methods.
44
+ *
45
+ * This utility method centralizes the creation of exceptions for functionality that is not supported
46
+ * on the current platform, ensuring consistency in error reporting.
47
+ *
48
+ * @returns {CapacitorException} An exception with the code `Unimplemented` and a descriptive message.
49
+ */
50
+ createUnimplementedError() {
51
+ return new CapacitorException('This plugin method is not implemented on this platform.', ExceptionCode.Unimplemented);
52
+ }
53
+ }
54
+ //# sourceMappingURL=web.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAU/E;;;;;;GAMG;AACH,MAAM,OAAO,aAAc,SAAQ,SAAS;IAe1C;;;;OAIG;IACH,KAAK,CAAC,gBAAgB;QACpB,MAAM,IAAI,CAAC,wBAAwB,EAAE,CAAC;IACxC,CAAC;IAiBD;;;;OAIG;IACH,KAAK,CAAC,iBAAiB;QACrB,MAAM,IAAI,CAAC,wBAAwB,EAAE,CAAC;IACxC,CAAC;IAED,sBAAsB;IAEtB;;;;OAIG;IACH,KAAK,CAAC,gBAAgB;QACpB,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;IAC5B,CAAC;IAED;;;;;;;OAOG;IACK,wBAAwB;QAC9B,OAAO,IAAI,kBAAkB,CAC3B,yDAAyD,EACzD,aAAa,CAAC,aAAa,CAC5B,CAAC;IACJ,CAAC;CACF"}
@@ -0,0 +1,95 @@
1
+ 'use strict';
2
+
3
+ var core = require('@capacitor/core');
4
+
5
+ /// <reference types="@capacitor/cli" />
6
+ // -- Enums --
7
+ /**
8
+ * Standardized error codes for programmatic handling of ssl pinning failures.
9
+ * @since 0.0.15
10
+ */
11
+ exports.SSLPinningErrorCode = void 0;
12
+ (function (SSLPinningErrorCode) {
13
+ /** The device does not have the requested hardware. */
14
+ SSLPinningErrorCode["UNAVAILABLE"] = "UNAVAILABLE";
15
+ /** The user denied the permission or the feature is disabled in settings. */
16
+ SSLPinningErrorCode["PERMISSION_DENIED"] = "PERMISSION_DENIED";
17
+ /** The ssl pinning failed to initialize (e.g., runtime error or Looper failure). */
18
+ SSLPinningErrorCode["INIT_FAILED"] = "INIT_FAILED";
19
+ /** The requested ssl pinning type is not valid or not supported by the plugin. */
20
+ SSLPinningErrorCode["UNKNOWN_TYPE"] = "UNKNOWN_TYPE";
21
+ })(exports.SSLPinningErrorCode || (exports.SSLPinningErrorCode = {}));
22
+
23
+ /**
24
+ * Import the `registerPlugin` method from the Capacitor core library.
25
+ * This method is used to register a custom plugin.
26
+ */
27
+ /**
28
+ * The SSLPinning plugin instance.
29
+ * It automatically lazy-loads the web implementation if running in a browser environment.
30
+ * Use this instance to access all ssl pinning functionality.
31
+ */
32
+ const SSLPinning = core.registerPlugin('SSLPinning', {
33
+ web: () => Promise.resolve().then(function () { return web; }).then((m) => new m.SSLPinningWeb()),
34
+ });
35
+
36
+ /**
37
+ * This module provides a web implementation of the SSLPinningPlugin.
38
+ * The functionality is limited in a web context due to the lack of SSL certificate inspection capabilities in browsers.
39
+ *
40
+ * The implementation adheres to the SSLPinningPlugin interface but provides fallback behavior
41
+ * because browsers do not allow direct inspection of SSL certificate details.
42
+ */
43
+ /**
44
+ * Web implementation of the SSLPinningPlugin interface.
45
+ *
46
+ * This class is intended to be used in a browser environment and handles scenarios where SSL certificate
47
+ * checking is unsupported. It implements the methods defined by the SSLPinningPlugin
48
+ * interface but returns standardized error responses to indicate the lack of functionality in web contexts.
49
+ */
50
+ class SSLPinningWeb extends core.WebPlugin {
51
+ /**
52
+ * Checks a single SSL certificate against the expected fingerprint.
53
+ * @return A promise that resolves to the result of the certificate check.
54
+ * @throws CapacitorException indicating unimplemented functionality.
55
+ */
56
+ async checkCertificate() {
57
+ throw this.createUnimplementedError();
58
+ }
59
+ /**
60
+ * Checks multiple SSL certificates against their expected fingerprints.
61
+ * @return A promise that resolves to an array of results for each certificate check.
62
+ * @throws CapacitorException indicating unimplemented functionality.
63
+ */
64
+ async checkCertificates() {
65
+ throw this.createUnimplementedError();
66
+ }
67
+ // --- Plugin Info ---
68
+ /**
69
+ * Returns the plugin version.
70
+ *
71
+ * @returns The current plugin version.
72
+ */
73
+ async getPluginVersion() {
74
+ return { version: 'web' };
75
+ }
76
+ /**
77
+ * Creates a standardized exception for unimplemented methods.
78
+ *
79
+ * This utility method centralizes the creation of exceptions for functionality that is not supported
80
+ * on the current platform, ensuring consistency in error reporting.
81
+ *
82
+ * @returns {CapacitorException} An exception with the code `Unimplemented` and a descriptive message.
83
+ */
84
+ createUnimplementedError() {
85
+ return new core.CapacitorException('This plugin method is not implemented on this platform.', core.ExceptionCode.Unimplemented);
86
+ }
87
+ }
88
+
89
+ var web = /*#__PURE__*/Object.freeze({
90
+ __proto__: null,
91
+ SSLPinningWeb: SSLPinningWeb
92
+ });
93
+
94
+ exports.SSLPinning = SSLPinning;
95
+ //# 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// -- Enums --\n/**\n * Standardized error codes for programmatic handling of ssl pinning failures.\n * @since 0.0.15\n */\nexport var SSLPinningErrorCode;\n(function (SSLPinningErrorCode) {\n /** The device does not have the requested hardware. */\n SSLPinningErrorCode[\"UNAVAILABLE\"] = \"UNAVAILABLE\";\n /** The user denied the permission or the feature is disabled in settings. */\n SSLPinningErrorCode[\"PERMISSION_DENIED\"] = \"PERMISSION_DENIED\";\n /** The ssl pinning failed to initialize (e.g., runtime error or Looper failure). */\n SSLPinningErrorCode[\"INIT_FAILED\"] = \"INIT_FAILED\";\n /** The requested ssl pinning type is not valid or not supported by the plugin. */\n SSLPinningErrorCode[\"UNKNOWN_TYPE\"] = \"UNKNOWN_TYPE\";\n})(SSLPinningErrorCode || (SSLPinningErrorCode = {}));\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 SSLPinning 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 SSLPinning = registerPlugin('SSLPinning', {\n web: () => import('./web').then((m) => new m.SSLPinningWeb()),\n});\nexport * from './definitions';\nexport { SSLPinning };\n//# sourceMappingURL=index.js.map","/**\n * This module provides a web implementation of the SSLPinningPlugin.\n * The functionality is limited in a web context due to the lack of SSL certificate inspection capabilities in browsers.\n *\n * The implementation adheres to the SSLPinningPlugin interface but provides fallback behavior\n * because browsers do not allow direct inspection of SSL certificate details.\n */\nimport { CapacitorException, ExceptionCode, WebPlugin } from '@capacitor/core';\n/**\n * Web implementation of the SSLPinningPlugin interface.\n *\n * This class is intended to be used in a browser environment and handles scenarios where SSL certificate\n * checking is unsupported. It implements the methods defined by the SSLPinningPlugin\n * interface but returns standardized error responses to indicate the lack of functionality in web contexts.\n */\nexport class SSLPinningWeb extends WebPlugin {\n /**\n * Checks a single SSL certificate against the expected fingerprint.\n * @return A promise that resolves to the result of the certificate check.\n * @throws CapacitorException indicating unimplemented functionality.\n */\n async checkCertificate() {\n throw this.createUnimplementedError();\n }\n /**\n * Checks multiple SSL certificates against their expected fingerprints.\n * @return A promise that resolves to an array of results for each certificate check.\n * @throws CapacitorException indicating unimplemented functionality.\n */\n async checkCertificates() {\n throw this.createUnimplementedError();\n }\n // --- Plugin Info ---\n /**\n * Returns the plugin version.\n *\n * @returns The current plugin version.\n */\n async getPluginVersion() {\n return { version: 'web' };\n }\n /**\n * Creates a standardized exception for unimplemented methods.\n *\n * This utility method centralizes the creation of exceptions for functionality that is not supported\n * on the current platform, ensuring consistency in error reporting.\n *\n * @returns {CapacitorException} An exception with the code `Unimplemented` and a descriptive message.\n */\n createUnimplementedError() {\n return new CapacitorException('This plugin method is not implemented on this platform.', ExceptionCode.Unimplemented);\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["SSLPinningErrorCode","registerPlugin","WebPlugin","CapacitorException","ExceptionCode"],"mappings":";;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACWA;AACX,CAAC,UAAU,mBAAmB,EAAE;AAChC;AACA,IAAI,mBAAmB,CAAC,aAAa,CAAC,GAAG,aAAa;AACtD;AACA,IAAI,mBAAmB,CAAC,mBAAmB,CAAC,GAAG,mBAAmB;AAClE;AACA,IAAI,mBAAmB,CAAC,aAAa,CAAC,GAAG,aAAa;AACtD;AACA,IAAI,mBAAmB,CAAC,cAAc,CAAC,GAAG,cAAc;AACxD,CAAC,EAAEA,2BAAmB,KAAKA,2BAAmB,GAAG,EAAE,CAAC,CAAC;;AChBrD;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACK,MAAC,UAAU,GAAGC,mBAAc,CAAC,YAAY,EAAE;AAChD,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,aAAa,EAAE,CAAC;AACjE,CAAC;;ACZD;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAM,aAAa,SAASC,cAAS,CAAC;AAC7C;AACA;AACA;AACA;AACA;AACA,IAAI,MAAM,gBAAgB,GAAG;AAC7B,QAAQ,MAAM,IAAI,CAAC,wBAAwB,EAAE;AAC7C,IAAI;AACJ;AACA;AACA;AACA;AACA;AACA,IAAI,MAAM,iBAAiB,GAAG;AAC9B,QAAQ,MAAM,IAAI,CAAC,wBAAwB,EAAE;AAC7C,IAAI;AACJ;AACA;AACA;AACA;AACA;AACA;AACA,IAAI,MAAM,gBAAgB,GAAG;AAC7B,QAAQ,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE;AACjC,IAAI;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI,wBAAwB,GAAG;AAC/B,QAAQ,OAAO,IAAIC,uBAAkB,CAAC,yDAAyD,EAAEC,kBAAa,CAAC,aAAa,CAAC;AAC7H,IAAI;AACJ;;;;;;;;;"}
package/dist/plugin.js ADDED
@@ -0,0 +1,98 @@
1
+ var capacitorSSLPinning = (function (exports, core) {
2
+ 'use strict';
3
+
4
+ /// <reference types="@capacitor/cli" />
5
+ // -- Enums --
6
+ /**
7
+ * Standardized error codes for programmatic handling of ssl pinning failures.
8
+ * @since 0.0.15
9
+ */
10
+ exports.SSLPinningErrorCode = void 0;
11
+ (function (SSLPinningErrorCode) {
12
+ /** The device does not have the requested hardware. */
13
+ SSLPinningErrorCode["UNAVAILABLE"] = "UNAVAILABLE";
14
+ /** The user denied the permission or the feature is disabled in settings. */
15
+ SSLPinningErrorCode["PERMISSION_DENIED"] = "PERMISSION_DENIED";
16
+ /** The ssl pinning failed to initialize (e.g., runtime error or Looper failure). */
17
+ SSLPinningErrorCode["INIT_FAILED"] = "INIT_FAILED";
18
+ /** The requested ssl pinning type is not valid or not supported by the plugin. */
19
+ SSLPinningErrorCode["UNKNOWN_TYPE"] = "UNKNOWN_TYPE";
20
+ })(exports.SSLPinningErrorCode || (exports.SSLPinningErrorCode = {}));
21
+
22
+ /**
23
+ * Import the `registerPlugin` method from the Capacitor core library.
24
+ * This method is used to register a custom plugin.
25
+ */
26
+ /**
27
+ * The SSLPinning plugin instance.
28
+ * It automatically lazy-loads the web implementation if running in a browser environment.
29
+ * Use this instance to access all ssl pinning functionality.
30
+ */
31
+ const SSLPinning = core.registerPlugin('SSLPinning', {
32
+ web: () => Promise.resolve().then(function () { return web; }).then((m) => new m.SSLPinningWeb()),
33
+ });
34
+
35
+ /**
36
+ * This module provides a web implementation of the SSLPinningPlugin.
37
+ * The functionality is limited in a web context due to the lack of SSL certificate inspection capabilities in browsers.
38
+ *
39
+ * The implementation adheres to the SSLPinningPlugin interface but provides fallback behavior
40
+ * because browsers do not allow direct inspection of SSL certificate details.
41
+ */
42
+ /**
43
+ * Web implementation of the SSLPinningPlugin interface.
44
+ *
45
+ * This class is intended to be used in a browser environment and handles scenarios where SSL certificate
46
+ * checking is unsupported. It implements the methods defined by the SSLPinningPlugin
47
+ * interface but returns standardized error responses to indicate the lack of functionality in web contexts.
48
+ */
49
+ class SSLPinningWeb extends core.WebPlugin {
50
+ /**
51
+ * Checks a single SSL certificate against the expected fingerprint.
52
+ * @return A promise that resolves to the result of the certificate check.
53
+ * @throws CapacitorException indicating unimplemented functionality.
54
+ */
55
+ async checkCertificate() {
56
+ throw this.createUnimplementedError();
57
+ }
58
+ /**
59
+ * Checks multiple SSL certificates against their expected fingerprints.
60
+ * @return A promise that resolves to an array of results for each certificate check.
61
+ * @throws CapacitorException indicating unimplemented functionality.
62
+ */
63
+ async checkCertificates() {
64
+ throw this.createUnimplementedError();
65
+ }
66
+ // --- Plugin Info ---
67
+ /**
68
+ * Returns the plugin version.
69
+ *
70
+ * @returns The current plugin version.
71
+ */
72
+ async getPluginVersion() {
73
+ return { version: 'web' };
74
+ }
75
+ /**
76
+ * Creates a standardized exception for unimplemented methods.
77
+ *
78
+ * This utility method centralizes the creation of exceptions for functionality that is not supported
79
+ * on the current platform, ensuring consistency in error reporting.
80
+ *
81
+ * @returns {CapacitorException} An exception with the code `Unimplemented` and a descriptive message.
82
+ */
83
+ createUnimplementedError() {
84
+ return new core.CapacitorException('This plugin method is not implemented on this platform.', core.ExceptionCode.Unimplemented);
85
+ }
86
+ }
87
+
88
+ var web = /*#__PURE__*/Object.freeze({
89
+ __proto__: null,
90
+ SSLPinningWeb: SSLPinningWeb
91
+ });
92
+
93
+ exports.SSLPinning = SSLPinning;
94
+
95
+ return exports;
96
+
97
+ })({}, capacitorExports);
98
+ //# sourceMappingURL=plugin.js.map