@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.
- package/CapKitSSLPinning.podspec +17 -0
- package/LICENSE +21 -0
- package/Package.swift +25 -0
- package/README.md +750 -0
- package/android/build.gradle +103 -0
- package/android/src/main/AndroidManifest.xml +3 -0
- package/android/src/main/java/io/capkit/sslpinning/SSLPinningConfig.kt +22 -0
- package/android/src/main/java/io/capkit/sslpinning/SSLPinningImpl.kt +188 -0
- package/android/src/main/java/io/capkit/sslpinning/SSLPinningPlugin.kt +82 -0
- package/android/src/main/java/io/capkit/sslpinning/utils/SSLPinningLogger.kt +85 -0
- package/android/src/main/java/io/capkit/sslpinning/utils/SSLPinningUtils.kt +44 -0
- package/android/src/main/res/.gitkeep +0 -0
- package/dist/cli/fingerprint.js +163 -0
- package/dist/cli/fingerprint.js.map +1 -0
- package/dist/docs.json +430 -0
- package/dist/esm/cli/fingerprint.d.ts +1 -0
- package/dist/esm/cli/fingerprint.js +161 -0
- package/dist/esm/cli/fingerprint.js.map +1 -0
- package/dist/esm/definitions.d.ts +285 -0
- package/dist/esm/definitions.js +18 -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 +58 -0
- package/dist/esm/web.js +54 -0
- package/dist/esm/web.js.map +1 -0
- package/dist/plugin.cjs.js +95 -0
- package/dist/plugin.cjs.js.map +1 -0
- package/dist/plugin.js +98 -0
- package/dist/plugin.js.map +1 -0
- package/ios/Sources/SSLPinningPlugin/SSLPinningConfig.swift +79 -0
- package/ios/Sources/SSLPinningPlugin/SSLPinningDelegate.swift +81 -0
- package/ios/Sources/SSLPinningPlugin/SSLPinningImpl.swift +111 -0
- package/ios/Sources/SSLPinningPlugin/SSLPinningPlugin.swift +116 -0
- package/ios/Sources/SSLPinningPlugin/Utils/SSLPinningLogger.swift +57 -0
- package/ios/Sources/SSLPinningPlugin/Utils/SSLPinningUtils.swift +47 -0
- package/ios/Sources/SSLPinningPlugin/Version.swift +16 -0
- package/ios/Tests/SSLPinningPluginTests/SSLPinningPluginTests.swift +5 -0
- package/package.json +117 -0
- package/scripts/chmod.js +34 -0
- package/scripts/sync-version.js +49 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fingerprint.js","sources":["../esm/cli/fingerprint.js"],"sourcesContent":["import crypto from 'crypto';\nimport fs from 'fs/promises';\nimport https from 'https';\nimport { createRequire } from 'module';\nimport yargs from 'yargs';\nimport { hideBin } from 'yargs/helpers';\nconst require = createRequire(import.meta.url);\nconst pkg = require('../../package.json');\nasync function getCertificate(domain, insecure) {\n return new Promise((resolve, reject) => {\n const options = {\n host: domain,\n port: 443,\n method: 'GET',\n rejectUnauthorized: !insecure,\n };\n const req = https.request(options, (res) => {\n var _a, _b, _c;\n const socket = res.socket;\n const cert = (_a = socket === null || socket === void 0 ? void 0 : socket.getPeerCertificate) === null || _a === void 0 ? void 0 : _a.call(socket, true);\n if (!(cert === null || cert === void 0 ? void 0 : cert.raw)) {\n reject(new Error('Unable to retrieve peer certificate'));\n return;\n }\n const fingerprint = crypto\n .createHash('sha256')\n .update(cert.raw)\n .digest('hex')\n .match(/.{2}/g)\n .join(':')\n .toUpperCase();\n resolve({\n domain,\n subject: (_b = cert.subject) !== null && _b !== void 0 ? _b : {},\n issuer: (_c = cert.issuer) !== null && _c !== void 0 ? _c : {},\n validFrom: cert.valid_from,\n validTo: cert.valid_to,\n fingerprint,\n });\n });\n req.on('error', reject);\n req.end();\n });\n}\nfunction formatOutput(results, mode, format) {\n const fingerprints = results.map((r) => r.fingerprint);\n switch (format) {\n case 'fingerprints':\n return `export const fingerprints = ${JSON.stringify(fingerprints, null, 2)};`;\n case 'capacitor': {\n if (mode === 'single') {\n return `plugins: {\n SSLPinning: {\n fingerprint: \"${fingerprints[0]}\"\n }\n}`;\n }\n return `plugins: {\n SSLPinning: {\n fingerprints: ${JSON.stringify(fingerprints, null, 4)}\n }\n}`;\n }\n case 'capacitor-plugin': {\n if (mode === 'single') {\n return `SSLPinning: {\n fingerprint: \"${fingerprints[0]}\"\n}`;\n }\n return `SSLPinning: {\n fingerprints: ${JSON.stringify(fingerprints, null, 4)}\n}`;\n }\n case 'capacitor-json': {\n if (mode === 'single') {\n return JSON.stringify({\n plugins: {\n SSLPinning: {\n fingerprint: fingerprints[0],\n },\n },\n }, null, 2);\n }\n return JSON.stringify({\n plugins: {\n SSLPinning: {\n fingerprints,\n },\n },\n }, null, 2);\n }\n case 'json':\n default:\n return JSON.stringify(results, null, 2);\n }\n}\nasync function main() {\n var _a, _b, _c;\n const argv = await yargs(hideBin(process.argv))\n .usage('Usage: $0 <domains...> [options]')\n .version(pkg.version)\n .option('out', {\n alias: 'o',\n type: 'string',\n description: 'Output file path',\n })\n .option('format', {\n alias: 'f',\n type: 'string',\n choices: ['json', 'fingerprints', 'capacitor', 'capacitor-plugin', 'capacitor-json'],\n default: 'json',\n description: 'Output format',\n })\n .option('mode', {\n type: 'string',\n choices: ['single', 'multi'],\n default: 'single',\n description: 'Fingerprint mode (single or multi)',\n })\n .option('insecure', {\n type: 'boolean',\n default: true,\n description: 'Allow insecure TLS connections (disables certificate validation)',\n })\n .demandCommand(1, 'At least one domain is required')\n .help().argv;\n const domains = argv._;\n const results = [];\n console.log('Fetching certificates...\\n');\n for (const domain of domains) {\n try {\n const certInfo = await getCertificate(domain, argv.insecure);\n results.push(certInfo);\n console.log(`Domain: ${certInfo.domain}`);\n console.log(`Subject: ${(_a = certInfo.subject.CN) !== null && _a !== void 0 ? _a : '-'}`);\n console.log(`Issuer: ${(_b = certInfo.issuer.CN) !== null && _b !== void 0 ? _b : '-'}`);\n console.log(`Valid From: ${certInfo.validFrom}`);\n console.log(`Valid To: ${certInfo.validTo}`);\n console.log(`SHA256 Fingerprint: ${certInfo.fingerprint}`);\n console.log('-------------------\\n');\n }\n catch (err) {\n console.error(`Error fetching cert for ${domain}: ${(_c = err === null || err === void 0 ? void 0 : err.message) !== null && _c !== void 0 ? _c : err}`);\n console.log('-------------------\\n');\n }\n }\n const output = formatOutput(results, argv.mode, argv.format);\n if (argv.out) {\n await fs.writeFile(argv.out, output);\n console.log(`Results written to ${argv.out}`);\n }\n else {\n console.log(output);\n }\n process.exit(0);\n}\nmain().catch((err) => {\n console.error(err);\n process.exit(1);\n});\n//# sourceMappingURL=fingerprint.js.map"],"names":["require"],"mappings":";;;;;;;;AAMA,MAAMA,SAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC;AAC9C,MAAM,GAAG,GAAGA,SAAO,CAAC,oBAAoB,CAAC;AACzC,eAAe,cAAc,CAAC,MAAM,EAAE,QAAQ,EAAE;AAChD,IAAI,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,KAAK;AAC5C,QAAQ,MAAM,OAAO,GAAG;AACxB,YAAY,IAAI,EAAE,MAAM;AACxB,YAAY,IAAI,EAAE,GAAG;AACrB,YAAY,MAAM,EAAE,KAAK;AACzB,YAAY,kBAAkB,EAAE,CAAC,QAAQ;AACzC,SAAS;AACT,QAAQ,MAAM,GAAG,GAAG,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,GAAG,KAAK;AACpD,YAAY,IAAI,EAAE,EAAE,EAAE,EAAE,EAAE;AAC1B,YAAY,MAAM,MAAM,GAAG,GAAG,CAAC,MAAM;AACrC,YAAY,MAAM,IAAI,GAAG,CAAC,EAAE,GAAG,MAAM,KAAK,IAAI,IAAI,MAAM,KAAK,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC,kBAAkB,MAAM,IAAI,IAAI,EAAE,KAAK,MAAM,GAAG,MAAM,GAAG,EAAE,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC;AACpK,YAAY,IAAI,EAAE,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,MAAM,GAAG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K,IAAI,IAAI,GAAG,KAAK,MAAM,GAAG,MAAM,GAAG,GAAG,CAAC,OAAO,MAAM,IAAI,IAAI,EAAE,KAAK,MAAM,GAAG,EAAE,GAAG,GAAG,CAAC,CAAC,CAAC;AACpK,YAAY,OAAO,CAAC,GAAG,CAAC,uBAAuB,CAAC;AAChD,QAAQ;AACR,IAAI;AACJ,IAAI,MAAM,MAAM,GAAG,YAAY,CAAC,OAAO,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC;AAChE,IAAI,IAAI,IAAI,CAAC,GAAG,EAAE;AAClB,QAAQ,MAAM,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,EAAE,MAAM,CAAC;AAC5C,QAAQ,OAAO,CAAC,GAAG,CAAC,CAAC,mBAAmB,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AACrD,IAAI;AACJ,SAAS;AACT,QAAQ,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC;AAC3B,IAAI;AACJ,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;AACnB;AACA,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,KAAK;AACtB,IAAI,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC;AACtB,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;AACnB,CAAC,CAAC"}
|
package/dist/docs.json
ADDED
|
@@ -0,0 +1,430 @@
|
|
|
1
|
+
{
|
|
2
|
+
"api": {
|
|
3
|
+
"name": "SSLPinningPlugin",
|
|
4
|
+
"slug": "sslpinningplugin",
|
|
5
|
+
"docs": "Interface defining the structure of an SSL Certificate Checker Plugin.\n\nImplementations of this interface should provide the logic for checking\nthe status and details of an SSL certificate based on the provided options.",
|
|
6
|
+
"tags": [],
|
|
7
|
+
"methods": [
|
|
8
|
+
{
|
|
9
|
+
"name": "checkCertificate",
|
|
10
|
+
"signature": "() => Promise<SSLPinningResult>",
|
|
11
|
+
"parameters": [],
|
|
12
|
+
"returns": "Promise<SSLPinningResult>",
|
|
13
|
+
"tags": [
|
|
14
|
+
{
|
|
15
|
+
"name": "param",
|
|
16
|
+
"text": "options - Options for checking the SSL certificate."
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"name": "returns",
|
|
20
|
+
"text": "A promise resolving to the result of the SSL certificate check."
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"name": "throws",
|
|
24
|
+
"text": "SSLPinningError if the check fails."
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"name": "example",
|
|
28
|
+
"text": "```typescript\nimport { SSLPinning } from '@cap-kit/ssl-pinning';\n\nconst result = await SSLPinning.checkCertificate({\n url: 'https://example.com',\n 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'\n});\n\nconsole.log('SSL Pinning Result:', result);\n```"
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"name": "since",
|
|
32
|
+
"text": "0.0.14"
|
|
33
|
+
}
|
|
34
|
+
],
|
|
35
|
+
"docs": "Check the SSL certificate of a server.",
|
|
36
|
+
"complexTypes": [
|
|
37
|
+
"SSLPinningResult"
|
|
38
|
+
],
|
|
39
|
+
"slug": "checkcertificate"
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"name": "checkCertificate",
|
|
43
|
+
"signature": "(options: SSLPinningOptions) => Promise<SSLPinningResult>",
|
|
44
|
+
"parameters": [
|
|
45
|
+
{
|
|
46
|
+
"name": "options",
|
|
47
|
+
"docs": "- Options for checking the SSL certificate.",
|
|
48
|
+
"type": "SSLPinningOptions"
|
|
49
|
+
}
|
|
50
|
+
],
|
|
51
|
+
"returns": "Promise<SSLPinningResult>",
|
|
52
|
+
"tags": [
|
|
53
|
+
{
|
|
54
|
+
"name": "param",
|
|
55
|
+
"text": "options - Options for checking the SSL certificate."
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
"name": "returns",
|
|
59
|
+
"text": "A promise resolving to the result of the SSL certificate check."
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
"name": "throws",
|
|
63
|
+
"text": "SSLPinningError if the check fails."
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
"name": "example",
|
|
67
|
+
"text": "```typescript\nimport { SSLPinning } from '@cap-kit/ssl-pinning';\n\nconst result = await SSLPinning.checkCertificate({\n url: 'https://example.com',\n 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'\n});\n\nconsole.log('SSL Pinning Result:', result);\n```"
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
"name": "since",
|
|
71
|
+
"text": "0.0.14"
|
|
72
|
+
}
|
|
73
|
+
],
|
|
74
|
+
"docs": "Check the SSL certificate of a server.",
|
|
75
|
+
"complexTypes": [
|
|
76
|
+
"SSLPinningResult",
|
|
77
|
+
"SSLPinningOptions"
|
|
78
|
+
],
|
|
79
|
+
"slug": "checkcertificate"
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
"name": "checkCertificates",
|
|
83
|
+
"signature": "() => Promise<SSLPinningResult[]>",
|
|
84
|
+
"parameters": [],
|
|
85
|
+
"returns": "Promise<SSLPinningResult[]>",
|
|
86
|
+
"tags": [
|
|
87
|
+
{
|
|
88
|
+
"name": "returns",
|
|
89
|
+
"text": "A promise resolving to an array of results for each SSL certificate check."
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
"name": "throws",
|
|
93
|
+
"text": "SSLPinningError if any of the checks fail."
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
"name": "example",
|
|
97
|
+
"text": "```typescript\nimport { SSLPinning } from '@cap-kit/ssl-pinning';\n\nconst results = await SSLPinning.checkCertificates();\n\nresults.forEach(result => {\n console.log('SSL Pinning Result:', result);\n});\n```"
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
"name": "since",
|
|
101
|
+
"text": "0.0.15"
|
|
102
|
+
}
|
|
103
|
+
],
|
|
104
|
+
"docs": "Check the SSL certificates of multiple servers.",
|
|
105
|
+
"complexTypes": [
|
|
106
|
+
"SSLPinningResult"
|
|
107
|
+
],
|
|
108
|
+
"slug": "checkcertificates"
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
"name": "checkCertificates",
|
|
112
|
+
"signature": "(options: SSLPinningMultiOptions[]) => Promise<SSLPinningResult[]>",
|
|
113
|
+
"parameters": [
|
|
114
|
+
{
|
|
115
|
+
"name": "options",
|
|
116
|
+
"docs": "- Options for checking the SSL certificates.",
|
|
117
|
+
"type": "SSLPinningMultiOptions[]"
|
|
118
|
+
}
|
|
119
|
+
],
|
|
120
|
+
"returns": "Promise<SSLPinningResult[]>",
|
|
121
|
+
"tags": [
|
|
122
|
+
{
|
|
123
|
+
"name": "returns",
|
|
124
|
+
"text": "A promise resolving to an array of results for each SSL certificate check."
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
"name": "throws",
|
|
128
|
+
"text": "SSLPinningError if any of the checks fail."
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
"name": "param",
|
|
132
|
+
"text": "options - Options for checking the SSL certificates."
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
"name": "example",
|
|
136
|
+
"text": "```typescript\nimport { SSLPinning } from '@cap-kit/ssl-pinning';\n\nconst results = await SSLPinning.checkCertificates([\n {\n url: 'https://example.com',\n 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']\n },\n {\n url: 'https://another-example.com',\n 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']\n }\n]);\n\nresults.forEach(result => {\n console.log('SSL Pinning Result:', result);\n});\n```"
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
"name": "since",
|
|
140
|
+
"text": "0.0.15"
|
|
141
|
+
}
|
|
142
|
+
],
|
|
143
|
+
"docs": "Check the SSL certificates of multiple servers.",
|
|
144
|
+
"complexTypes": [
|
|
145
|
+
"SSLPinningResult",
|
|
146
|
+
"SSLPinningMultiOptions"
|
|
147
|
+
],
|
|
148
|
+
"slug": "checkcertificates"
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
"name": "getPluginVersion",
|
|
152
|
+
"signature": "() => Promise<PluginVersionResult>",
|
|
153
|
+
"parameters": [],
|
|
154
|
+
"returns": "Promise<PluginVersionResult>",
|
|
155
|
+
"tags": [
|
|
156
|
+
{
|
|
157
|
+
"name": "returns",
|
|
158
|
+
"text": "A promise resolving to the plugin version."
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
"name": "example",
|
|
162
|
+
"text": "```ts\nconst { version } = await SSLPinning.getPluginVersion();\n```"
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
"name": "since",
|
|
166
|
+
"text": "0.0.15"
|
|
167
|
+
}
|
|
168
|
+
],
|
|
169
|
+
"docs": "Returns the native plugin version.\n\nThe returned version corresponds to the native implementation\nbundled with the application.",
|
|
170
|
+
"complexTypes": [
|
|
171
|
+
"PluginVersionResult"
|
|
172
|
+
],
|
|
173
|
+
"slug": "getpluginversion"
|
|
174
|
+
}
|
|
175
|
+
],
|
|
176
|
+
"properties": []
|
|
177
|
+
},
|
|
178
|
+
"interfaces": [
|
|
179
|
+
{
|
|
180
|
+
"name": "SSLPinningResult",
|
|
181
|
+
"slug": "sslpinningresult",
|
|
182
|
+
"docs": "Result returned by the SSL certificate check.\n\nNOTE:\nOn iOS (Swift Package Manager), errors are returned\nas part of the resolved result object rather than\nPromise rejections.",
|
|
183
|
+
"tags": [],
|
|
184
|
+
"methods": [],
|
|
185
|
+
"properties": [
|
|
186
|
+
{
|
|
187
|
+
"name": "subject",
|
|
188
|
+
"tags": [
|
|
189
|
+
{
|
|
190
|
+
"text": "Android",
|
|
191
|
+
"name": "platform"
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
"text": "\"CN=example.com, O=Example Corp, C=US\"",
|
|
195
|
+
"name": "example"
|
|
196
|
+
}
|
|
197
|
+
],
|
|
198
|
+
"docs": "The subject of the certificate, representing the entity the certificate is issued to.",
|
|
199
|
+
"complexTypes": [],
|
|
200
|
+
"type": "string | undefined"
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
"name": "issuer",
|
|
204
|
+
"tags": [
|
|
205
|
+
{
|
|
206
|
+
"text": "\"CN=Example CA, O=Example Corp, C=US\"",
|
|
207
|
+
"name": "example"
|
|
208
|
+
}
|
|
209
|
+
],
|
|
210
|
+
"docs": "The issuer of the certificate, indicating the certificate authority that issued it.\nResults may vary slightly between iOS and Android platforms.",
|
|
211
|
+
"complexTypes": [],
|
|
212
|
+
"type": "string | undefined"
|
|
213
|
+
},
|
|
214
|
+
{
|
|
215
|
+
"name": "validFrom",
|
|
216
|
+
"tags": [
|
|
217
|
+
{
|
|
218
|
+
"text": "Android",
|
|
219
|
+
"name": "platform"
|
|
220
|
+
},
|
|
221
|
+
{
|
|
222
|
+
"text": "\"2023-01-01T00:00:00Z\"",
|
|
223
|
+
"name": "example"
|
|
224
|
+
}
|
|
225
|
+
],
|
|
226
|
+
"docs": "The start date from which the certificate is valid.\nFormat: ISO 8601 string or platform-specific date representation.",
|
|
227
|
+
"complexTypes": [],
|
|
228
|
+
"type": "string | undefined"
|
|
229
|
+
},
|
|
230
|
+
{
|
|
231
|
+
"name": "validTo",
|
|
232
|
+
"tags": [
|
|
233
|
+
{
|
|
234
|
+
"text": "Android",
|
|
235
|
+
"name": "platform"
|
|
236
|
+
},
|
|
237
|
+
{
|
|
238
|
+
"text": "\"2024-01-01T00:00:00Z\"",
|
|
239
|
+
"name": "example"
|
|
240
|
+
}
|
|
241
|
+
],
|
|
242
|
+
"docs": "The end date until which the certificate is valid.\nFormat: ISO 8601 string or platform-specific date representation.",
|
|
243
|
+
"complexTypes": [],
|
|
244
|
+
"type": "string | undefined"
|
|
245
|
+
},
|
|
246
|
+
{
|
|
247
|
+
"name": "expectedFingerprint",
|
|
248
|
+
"tags": [],
|
|
249
|
+
"docs": "The fingerprint that is expected to match the certificate's actual fingerprint.\nThis is typically provided in the SSLPinningOptions.",
|
|
250
|
+
"complexTypes": [],
|
|
251
|
+
"type": "string | undefined"
|
|
252
|
+
},
|
|
253
|
+
{
|
|
254
|
+
"name": "actualFingerprint",
|
|
255
|
+
"tags": [
|
|
256
|
+
{
|
|
257
|
+
"text": "\"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\"",
|
|
258
|
+
"name": "example"
|
|
259
|
+
}
|
|
260
|
+
],
|
|
261
|
+
"docs": "The actual fingerprint of the SSL certificate retrieved from the server.",
|
|
262
|
+
"complexTypes": [],
|
|
263
|
+
"type": "string | undefined"
|
|
264
|
+
},
|
|
265
|
+
{
|
|
266
|
+
"name": "fingerprintMatched",
|
|
267
|
+
"tags": [],
|
|
268
|
+
"docs": "Indicates whether the actual fingerprint matches the expected fingerprint.\n`true` if they match, `false` otherwise.",
|
|
269
|
+
"complexTypes": [],
|
|
270
|
+
"type": "boolean | undefined"
|
|
271
|
+
},
|
|
272
|
+
{
|
|
273
|
+
"name": "error",
|
|
274
|
+
"tags": [
|
|
275
|
+
{
|
|
276
|
+
"text": "\"Unable to retrieve certificate from the server.\"",
|
|
277
|
+
"name": "example"
|
|
278
|
+
}
|
|
279
|
+
],
|
|
280
|
+
"docs": "A descriptive error message if an issue occurred during the SSL certificate check.",
|
|
281
|
+
"complexTypes": [],
|
|
282
|
+
"type": "string | undefined"
|
|
283
|
+
}
|
|
284
|
+
]
|
|
285
|
+
},
|
|
286
|
+
{
|
|
287
|
+
"name": "SSLPinningOptions",
|
|
288
|
+
"slug": "sslpinningoptions",
|
|
289
|
+
"docs": "Options for checking a single SSL certificate.",
|
|
290
|
+
"tags": [],
|
|
291
|
+
"methods": [],
|
|
292
|
+
"properties": [
|
|
293
|
+
{
|
|
294
|
+
"name": "url",
|
|
295
|
+
"tags": [
|
|
296
|
+
{
|
|
297
|
+
"text": "\"https://example.com\"",
|
|
298
|
+
"name": "example"
|
|
299
|
+
}
|
|
300
|
+
],
|
|
301
|
+
"docs": "The URL of the server whose SSL certificate needs to be checked.",
|
|
302
|
+
"complexTypes": [],
|
|
303
|
+
"type": "string"
|
|
304
|
+
},
|
|
305
|
+
{
|
|
306
|
+
"name": "fingerprint",
|
|
307
|
+
"tags": [],
|
|
308
|
+
"docs": "The expected fingerprint of the SSL certificate to validate against.\nThis is typically a hash string such as SHA-256.",
|
|
309
|
+
"complexTypes": [],
|
|
310
|
+
"type": "string"
|
|
311
|
+
}
|
|
312
|
+
]
|
|
313
|
+
},
|
|
314
|
+
{
|
|
315
|
+
"name": "SSLPinningMultiOptions",
|
|
316
|
+
"slug": "sslpinningmultioptions",
|
|
317
|
+
"docs": "Options for checking multiple SSL certificates.",
|
|
318
|
+
"tags": [],
|
|
319
|
+
"methods": [],
|
|
320
|
+
"properties": [
|
|
321
|
+
{
|
|
322
|
+
"name": "url",
|
|
323
|
+
"tags": [
|
|
324
|
+
{
|
|
325
|
+
"text": "\"https://example.com\"",
|
|
326
|
+
"name": "example"
|
|
327
|
+
}
|
|
328
|
+
],
|
|
329
|
+
"docs": "The URL of the server whose SSL certificate needs to be checked.",
|
|
330
|
+
"complexTypes": [],
|
|
331
|
+
"type": "string"
|
|
332
|
+
},
|
|
333
|
+
{
|
|
334
|
+
"name": "fingerprints",
|
|
335
|
+
"tags": [],
|
|
336
|
+
"docs": "The expected fingerprints of the SSL certificate to validate against.\nThis is typically an array of hash strings such as SHA-256.",
|
|
337
|
+
"complexTypes": [],
|
|
338
|
+
"type": "string[]"
|
|
339
|
+
}
|
|
340
|
+
]
|
|
341
|
+
},
|
|
342
|
+
{
|
|
343
|
+
"name": "PluginVersionResult",
|
|
344
|
+
"slug": "pluginversionresult",
|
|
345
|
+
"docs": "Result returned by the getPluginVersion method.",
|
|
346
|
+
"tags": [],
|
|
347
|
+
"methods": [],
|
|
348
|
+
"properties": [
|
|
349
|
+
{
|
|
350
|
+
"name": "version",
|
|
351
|
+
"tags": [],
|
|
352
|
+
"docs": "The native version string of the plugin.",
|
|
353
|
+
"complexTypes": [],
|
|
354
|
+
"type": "string"
|
|
355
|
+
}
|
|
356
|
+
]
|
|
357
|
+
}
|
|
358
|
+
],
|
|
359
|
+
"enums": [],
|
|
360
|
+
"typeAliases": [],
|
|
361
|
+
"pluginConfigs": [
|
|
362
|
+
{
|
|
363
|
+
"name": "SSLPinning",
|
|
364
|
+
"slug": "sslpinning",
|
|
365
|
+
"properties": [
|
|
366
|
+
{
|
|
367
|
+
"name": "verboseLogging",
|
|
368
|
+
"tags": [
|
|
369
|
+
{
|
|
370
|
+
"text": "true",
|
|
371
|
+
"name": "example"
|
|
372
|
+
},
|
|
373
|
+
{
|
|
374
|
+
"text": "false",
|
|
375
|
+
"name": "default"
|
|
376
|
+
},
|
|
377
|
+
{
|
|
378
|
+
"text": "0.0.15",
|
|
379
|
+
"name": "since"
|
|
380
|
+
}
|
|
381
|
+
],
|
|
382
|
+
"docs": "Enables detailed logging in the native console (Logcat/Xcode).\nUseful for debugging sensor data flow and lifecycle events.",
|
|
383
|
+
"complexTypes": [],
|
|
384
|
+
"type": "boolean | undefined"
|
|
385
|
+
},
|
|
386
|
+
{
|
|
387
|
+
"name": "fingerprint",
|
|
388
|
+
"tags": [
|
|
389
|
+
{
|
|
390
|
+
"text": "\"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\"",
|
|
391
|
+
"name": "example"
|
|
392
|
+
},
|
|
393
|
+
{
|
|
394
|
+
"text": "undefined",
|
|
395
|
+
"name": "default"
|
|
396
|
+
},
|
|
397
|
+
{
|
|
398
|
+
"text": "0.0.14",
|
|
399
|
+
"name": "since"
|
|
400
|
+
}
|
|
401
|
+
],
|
|
402
|
+
"docs": "Default fingerprint used by checkCertificate()\nif no arguments are provided.",
|
|
403
|
+
"complexTypes": [],
|
|
404
|
+
"type": "string | undefined"
|
|
405
|
+
},
|
|
406
|
+
{
|
|
407
|
+
"name": "fingerprints",
|
|
408
|
+
"tags": [
|
|
409
|
+
{
|
|
410
|
+
"text": "[\"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\"]",
|
|
411
|
+
"name": "example"
|
|
412
|
+
},
|
|
413
|
+
{
|
|
414
|
+
"text": "undefined",
|
|
415
|
+
"name": "default"
|
|
416
|
+
},
|
|
417
|
+
{
|
|
418
|
+
"text": "0.0.15",
|
|
419
|
+
"name": "since"
|
|
420
|
+
}
|
|
421
|
+
],
|
|
422
|
+
"docs": "Default fingerprints used by checkCertificates()\nif no arguments are provided.",
|
|
423
|
+
"complexTypes": [],
|
|
424
|
+
"type": "string[] | undefined"
|
|
425
|
+
}
|
|
426
|
+
],
|
|
427
|
+
"docs": "Configuration options for the SSLPinning plugin."
|
|
428
|
+
}
|
|
429
|
+
]
|
|
430
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import crypto from 'crypto';
|
|
2
|
+
import fs from 'fs/promises';
|
|
3
|
+
import https from 'https';
|
|
4
|
+
import { createRequire } from 'module';
|
|
5
|
+
import yargs from 'yargs';
|
|
6
|
+
import { hideBin } from 'yargs/helpers';
|
|
7
|
+
const require = createRequire(import.meta.url);
|
|
8
|
+
const pkg = require('../../package.json');
|
|
9
|
+
async function getCertificate(domain, insecure) {
|
|
10
|
+
return new Promise((resolve, reject) => {
|
|
11
|
+
const options = {
|
|
12
|
+
host: domain,
|
|
13
|
+
port: 443,
|
|
14
|
+
method: 'GET',
|
|
15
|
+
rejectUnauthorized: !insecure,
|
|
16
|
+
};
|
|
17
|
+
const req = https.request(options, (res) => {
|
|
18
|
+
var _a, _b, _c;
|
|
19
|
+
const socket = res.socket;
|
|
20
|
+
const cert = (_a = socket === null || socket === void 0 ? void 0 : socket.getPeerCertificate) === null || _a === void 0 ? void 0 : _a.call(socket, true);
|
|
21
|
+
if (!(cert === null || cert === void 0 ? void 0 : cert.raw)) {
|
|
22
|
+
reject(new Error('Unable to retrieve peer certificate'));
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
const fingerprint = crypto
|
|
26
|
+
.createHash('sha256')
|
|
27
|
+
.update(cert.raw)
|
|
28
|
+
.digest('hex')
|
|
29
|
+
.match(/.{2}/g)
|
|
30
|
+
.join(':')
|
|
31
|
+
.toUpperCase();
|
|
32
|
+
resolve({
|
|
33
|
+
domain,
|
|
34
|
+
subject: (_b = cert.subject) !== null && _b !== void 0 ? _b : {},
|
|
35
|
+
issuer: (_c = cert.issuer) !== null && _c !== void 0 ? _c : {},
|
|
36
|
+
validFrom: cert.valid_from,
|
|
37
|
+
validTo: cert.valid_to,
|
|
38
|
+
fingerprint,
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
req.on('error', reject);
|
|
42
|
+
req.end();
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
function formatOutput(results, mode, format) {
|
|
46
|
+
const fingerprints = results.map((r) => r.fingerprint);
|
|
47
|
+
switch (format) {
|
|
48
|
+
case 'fingerprints':
|
|
49
|
+
return `export const fingerprints = ${JSON.stringify(fingerprints, null, 2)};`;
|
|
50
|
+
case 'capacitor': {
|
|
51
|
+
if (mode === 'single') {
|
|
52
|
+
return `plugins: {
|
|
53
|
+
SSLPinning: {
|
|
54
|
+
fingerprint: "${fingerprints[0]}"
|
|
55
|
+
}
|
|
56
|
+
}`;
|
|
57
|
+
}
|
|
58
|
+
return `plugins: {
|
|
59
|
+
SSLPinning: {
|
|
60
|
+
fingerprints: ${JSON.stringify(fingerprints, null, 4)}
|
|
61
|
+
}
|
|
62
|
+
}`;
|
|
63
|
+
}
|
|
64
|
+
case 'capacitor-plugin': {
|
|
65
|
+
if (mode === 'single') {
|
|
66
|
+
return `SSLPinning: {
|
|
67
|
+
fingerprint: "${fingerprints[0]}"
|
|
68
|
+
}`;
|
|
69
|
+
}
|
|
70
|
+
return `SSLPinning: {
|
|
71
|
+
fingerprints: ${JSON.stringify(fingerprints, null, 4)}
|
|
72
|
+
}`;
|
|
73
|
+
}
|
|
74
|
+
case 'capacitor-json': {
|
|
75
|
+
if (mode === 'single') {
|
|
76
|
+
return JSON.stringify({
|
|
77
|
+
plugins: {
|
|
78
|
+
SSLPinning: {
|
|
79
|
+
fingerprint: fingerprints[0],
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
}, null, 2);
|
|
83
|
+
}
|
|
84
|
+
return JSON.stringify({
|
|
85
|
+
plugins: {
|
|
86
|
+
SSLPinning: {
|
|
87
|
+
fingerprints,
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
}, null, 2);
|
|
91
|
+
}
|
|
92
|
+
case 'json':
|
|
93
|
+
default:
|
|
94
|
+
return JSON.stringify(results, null, 2);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
async function main() {
|
|
98
|
+
var _a, _b, _c;
|
|
99
|
+
const argv = await yargs(hideBin(process.argv))
|
|
100
|
+
.usage('Usage: $0 <domains...> [options]')
|
|
101
|
+
.version(pkg.version)
|
|
102
|
+
.option('out', {
|
|
103
|
+
alias: 'o',
|
|
104
|
+
type: 'string',
|
|
105
|
+
description: 'Output file path',
|
|
106
|
+
})
|
|
107
|
+
.option('format', {
|
|
108
|
+
alias: 'f',
|
|
109
|
+
type: 'string',
|
|
110
|
+
choices: ['json', 'fingerprints', 'capacitor', 'capacitor-plugin', 'capacitor-json'],
|
|
111
|
+
default: 'json',
|
|
112
|
+
description: 'Output format',
|
|
113
|
+
})
|
|
114
|
+
.option('mode', {
|
|
115
|
+
type: 'string',
|
|
116
|
+
choices: ['single', 'multi'],
|
|
117
|
+
default: 'single',
|
|
118
|
+
description: 'Fingerprint mode (single or multi)',
|
|
119
|
+
})
|
|
120
|
+
.option('insecure', {
|
|
121
|
+
type: 'boolean',
|
|
122
|
+
default: true,
|
|
123
|
+
description: 'Allow insecure TLS connections (disables certificate validation)',
|
|
124
|
+
})
|
|
125
|
+
.demandCommand(1, 'At least one domain is required')
|
|
126
|
+
.help().argv;
|
|
127
|
+
const domains = argv._;
|
|
128
|
+
const results = [];
|
|
129
|
+
console.log('Fetching certificates...\n');
|
|
130
|
+
for (const domain of domains) {
|
|
131
|
+
try {
|
|
132
|
+
const certInfo = await getCertificate(domain, argv.insecure);
|
|
133
|
+
results.push(certInfo);
|
|
134
|
+
console.log(`Domain: ${certInfo.domain}`);
|
|
135
|
+
console.log(`Subject: ${(_a = certInfo.subject.CN) !== null && _a !== void 0 ? _a : '-'}`);
|
|
136
|
+
console.log(`Issuer: ${(_b = certInfo.issuer.CN) !== null && _b !== void 0 ? _b : '-'}`);
|
|
137
|
+
console.log(`Valid From: ${certInfo.validFrom}`);
|
|
138
|
+
console.log(`Valid To: ${certInfo.validTo}`);
|
|
139
|
+
console.log(`SHA256 Fingerprint: ${certInfo.fingerprint}`);
|
|
140
|
+
console.log('-------------------\n');
|
|
141
|
+
}
|
|
142
|
+
catch (err) {
|
|
143
|
+
console.error(`Error fetching cert for ${domain}: ${(_c = err === null || err === void 0 ? void 0 : err.message) !== null && _c !== void 0 ? _c : err}`);
|
|
144
|
+
console.log('-------------------\n');
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
const output = formatOutput(results, argv.mode, argv.format);
|
|
148
|
+
if (argv.out) {
|
|
149
|
+
await fs.writeFile(argv.out, output);
|
|
150
|
+
console.log(`Results written to ${argv.out}`);
|
|
151
|
+
}
|
|
152
|
+
else {
|
|
153
|
+
console.log(output);
|
|
154
|
+
}
|
|
155
|
+
process.exit(0);
|
|
156
|
+
}
|
|
157
|
+
main().catch((err) => {
|
|
158
|
+
console.error(err);
|
|
159
|
+
process.exit(1);
|
|
160
|
+
});
|
|
161
|
+
//# sourceMappingURL=fingerprint.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fingerprint.js","sourceRoot":"","sources":["../../../src/cli/fingerprint.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,MAAM,aAAa,CAAC;AAC7B,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AACvC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAExC,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC/C,MAAM,GAAG,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;AAc1C,KAAK,UAAU,cAAc,CAAC,MAAc,EAAE,QAAiB;IAC7D,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,MAAM,OAAO,GAAyB;YACpC,IAAI,EAAE,MAAM;YACZ,IAAI,EAAE,GAAG;YACT,MAAM,EAAE,KAAK;YACb,kBAAkB,EAAE,CAAC,QAAQ;SAC9B,CAAC;QAEF,MAAM,GAAG,GAAG,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE;;YACzC,MAAM,MAAM,GAAQ,GAAG,CAAC,MAAM,CAAC;YAC/B,MAAM,IAAI,GAAG,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,kBAAkB,uDAAG,IAAI,CAAC,CAAC;YAEhD,IAAI,CAAC,CAAA,IAAI,aAA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