@mridang/webhint-hint-plumbline 0.2.0 → 0.3.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/dist/lib/tls/remote.d.ts +52 -0
- package/dist/lib/tls/remote.js +53 -0
- package/dist/lib/tls/remote.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { EphemeralKey } from './evaluate.js';
|
|
2
|
+
import type { TlsConnect } from './client.js';
|
|
3
|
+
/** The certificate facts the prober reads, named as Node names them. */
|
|
4
|
+
export interface RemoteCertificate {
|
|
5
|
+
subject: Record<string, string>;
|
|
6
|
+
issuer: Record<string, string>;
|
|
7
|
+
subjectaltname: string;
|
|
8
|
+
valid_from: string;
|
|
9
|
+
valid_to: string;
|
|
10
|
+
serialNumber: string;
|
|
11
|
+
fingerprint256: string;
|
|
12
|
+
keyType: string;
|
|
13
|
+
bits?: number;
|
|
14
|
+
asn1Curve?: string;
|
|
15
|
+
signatureAlgorithm: string;
|
|
16
|
+
}
|
|
17
|
+
/** What the prober answers. */
|
|
18
|
+
export interface RemoteHandshake {
|
|
19
|
+
protocol: string;
|
|
20
|
+
cipher: {
|
|
21
|
+
name: string;
|
|
22
|
+
standardName: string;
|
|
23
|
+
};
|
|
24
|
+
authorized: boolean;
|
|
25
|
+
authorizationError: string | null;
|
|
26
|
+
ephemeral: EphemeralKey | null;
|
|
27
|
+
/** DER, base64, leaf first. */
|
|
28
|
+
chain: string[] | null;
|
|
29
|
+
certificates: RemoteCertificate[] | null;
|
|
30
|
+
/** DER, base64. */
|
|
31
|
+
ocsp: string | null;
|
|
32
|
+
compression?: boolean;
|
|
33
|
+
}
|
|
34
|
+
/** What is asked of the prober. */
|
|
35
|
+
export interface RemoteRequest {
|
|
36
|
+
host: string;
|
|
37
|
+
port: number;
|
|
38
|
+
starttls?: 'smtp';
|
|
39
|
+
minVersion?: string;
|
|
40
|
+
maxVersion?: string;
|
|
41
|
+
/** An OpenSSL cipher list. */
|
|
42
|
+
ciphers?: string;
|
|
43
|
+
/** An OpenSSL signature algorithm list. */
|
|
44
|
+
sigalgs?: string;
|
|
45
|
+
/** Colon separated key exchange groups. */
|
|
46
|
+
ecdhCurve?: string;
|
|
47
|
+
requestOCSP?: boolean;
|
|
48
|
+
}
|
|
49
|
+
/** Makes one request to the prober; rejects when the handshake failed. */
|
|
50
|
+
export type RemoteCall = (request: RemoteRequest) => Promise<RemoteHandshake>;
|
|
51
|
+
/** A `TlsConnect` that asks the prober. */
|
|
52
|
+
export declare function remoteConnect(call: RemoteCall): TlsConnect;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { TLS_VERSIONS } from './constants.js';
|
|
2
|
+
/** The base64 text as bytes. */
|
|
3
|
+
function bytesOf(base64) {
|
|
4
|
+
return Buffer.from(base64, 'base64');
|
|
5
|
+
}
|
|
6
|
+
/** The leaf certificate as Node shows it, from what the prober read. */
|
|
7
|
+
function peerOf(certs, chain) {
|
|
8
|
+
const leaf = certs[0];
|
|
9
|
+
return {
|
|
10
|
+
subject: leaf?.subject ?? {},
|
|
11
|
+
issuer: leaf?.issuer ?? {},
|
|
12
|
+
subjectaltname: leaf?.subjectaltname,
|
|
13
|
+
valid_from: leaf?.valid_from,
|
|
14
|
+
valid_to: leaf?.valid_to,
|
|
15
|
+
serialNumber: leaf?.serialNumber,
|
|
16
|
+
fingerprint256: leaf?.fingerprint256,
|
|
17
|
+
bits: leaf?.bits,
|
|
18
|
+
asn1Curve: leaf?.asn1Curve,
|
|
19
|
+
raw: chain[0],
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
/** A `TlsConnect` that asks the prober. */
|
|
23
|
+
export function remoteConnect(call) {
|
|
24
|
+
return async (target, options) => {
|
|
25
|
+
const answer = await call({
|
|
26
|
+
host: target.host,
|
|
27
|
+
port: target.port,
|
|
28
|
+
...(target.starttls ? { starttls: target.starttls } : {}),
|
|
29
|
+
...(options.minVersion ? { minVersion: options.minVersion } : {}),
|
|
30
|
+
...(options.maxVersion ? { maxVersion: options.maxVersion } : {}),
|
|
31
|
+
...(options.ciphers ? { ciphers: options.ciphers } : {}),
|
|
32
|
+
...(options.sigalgs ? { sigalgs: options.sigalgs } : {}),
|
|
33
|
+
...(options.ecdhCurve ? { ecdhCurve: options.ecdhCurve } : {}),
|
|
34
|
+
...(options.requestOCSP ? { requestOCSP: true } : {}),
|
|
35
|
+
});
|
|
36
|
+
const chain = (answer.chain ?? []).map(bytesOf);
|
|
37
|
+
const protocol = TLS_VERSIONS.includes(answer.protocol)
|
|
38
|
+
? answer.protocol
|
|
39
|
+
: null;
|
|
40
|
+
const result = {
|
|
41
|
+
protocol,
|
|
42
|
+
cipher: answer.cipher,
|
|
43
|
+
ephemeral: answer.ephemeral,
|
|
44
|
+
authorized: answer.authorized,
|
|
45
|
+
authorizationError: answer.authorizationError,
|
|
46
|
+
chain,
|
|
47
|
+
peerCertificate: peerOf(answer.certificates ?? [], chain),
|
|
48
|
+
ocspResponse: answer.ocsp ? bytesOf(answer.ocsp) : null,
|
|
49
|
+
};
|
|
50
|
+
return result;
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=remote.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remote.js","sourceRoot":"","sources":["../../../src/lib/tls/remote.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,YAAY,EAAmB,MAAM,gBAAgB,CAAC;AAqD/D,gCAAgC;AAChC,SAAS,OAAO,CAAC,MAAc;IAC7B,OAAO,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;AACvC,CAAC;AAED,wEAAwE;AACxE,SAAS,MAAM,CACb,KAAmC,EACnC,KAAwB;IAExB,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;IACtB,OAAO;QACL,OAAO,EAAE,IAAI,EAAE,OAAO,IAAI,EAAE;QAC5B,MAAM,EAAE,IA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