@mridang/webhint-hint-plumbline 0.13.0 → 0.14.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.
@@ -0,0 +1,54 @@
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
+ /** Where the issuer's certificate and an OCSP answer can be had, as Node names the keys. */
17
+ infoAccess?: Record<string, string[]>;
18
+ }
19
+ /** What the prober answers. */
20
+ export interface RemoteHandshake {
21
+ protocol: string;
22
+ cipher: {
23
+ name: string;
24
+ standardName: string;
25
+ };
26
+ authorized: boolean;
27
+ authorizationError: string | null;
28
+ ephemeral: EphemeralKey | null;
29
+ /** DER, base64, leaf first. */
30
+ chain: string[] | null;
31
+ certificates: RemoteCertificate[] | null;
32
+ /** DER, base64. */
33
+ ocsp: string | null;
34
+ compression?: boolean;
35
+ }
36
+ /** What is asked of the prober. */
37
+ export interface RemoteRequest {
38
+ host: string;
39
+ port: number;
40
+ starttls?: 'smtp';
41
+ minVersion?: string;
42
+ maxVersion?: string;
43
+ /** An OpenSSL cipher list. */
44
+ ciphers?: string;
45
+ /** An OpenSSL signature algorithm list. */
46
+ sigalgs?: string;
47
+ /** Colon separated key exchange groups. */
48
+ ecdhCurve?: string;
49
+ requestOCSP?: boolean;
50
+ }
51
+ /** Makes one request to the prober; rejects when the handshake failed. */
52
+ export type RemoteCall = (request: RemoteRequest) => Promise<RemoteHandshake>;
53
+ /** A `TlsConnect` that asks the prober. */
54
+ export declare function remoteConnect(call: RemoteCall): TlsConnect;
@@ -0,0 +1,54 @@
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
+ infoAccess: leaf?.infoAccess,
20
+ raw: chain[0],
21
+ };
22
+ }
23
+ /** A `TlsConnect` that asks the prober. */
24
+ export function remoteConnect(call) {
25
+ return async (target, options) => {
26
+ const answer = await call({
27
+ host: target.host,
28
+ port: target.port,
29
+ ...(target.starttls ? { starttls: target.starttls } : {}),
30
+ ...(options.minVersion ? { minVersion: options.minVersion } : {}),
31
+ ...(options.maxVersion ? { maxVersion: options.maxVersion } : {}),
32
+ ...(options.ciphers ? { ciphers: options.ciphers } : {}),
33
+ ...(options.sigalgs ? { sigalgs: options.sigalgs } : {}),
34
+ ...(options.ecdhCurve ? { ecdhCurve: options.ecdhCurve } : {}),
35
+ ...(options.requestOCSP ? { requestOCSP: true } : {}),
36
+ });
37
+ const chain = (answer.chain ?? []).map(bytesOf);
38
+ const protocol = TLS_VERSIONS.includes(answer.protocol)
39
+ ? answer.protocol
40
+ : null;
41
+ const result = {
42
+ protocol,
43
+ cipher: answer.cipher,
44
+ ephemeral: answer.ephemeral,
45
+ authorized: answer.authorized,
46
+ authorizationError: answer.authorizationError,
47
+ chain,
48
+ peerCertificate: peerOf(answer.certificates ?? [], chain),
49
+ ocspResponse: answer.ocsp ? bytesOf(answer.ocsp) : null,
50
+ };
51
+ return result;
52
+ };
53
+ }
54
+ //# sourceMappingURL=remote.js.map
@@ -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EAAE,EAAE,KAAK,CAAC;YACzD,YAAY,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI;SACxD,CAAC;QACF,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * What the hints take from webhint's core at run time, for a runtime that
3
+ * cannot load the core (a Cloudflare Worker: the core reads files and loads
4
+ * packages by name). The hints only need the scope names; the rest of webhint
5
+ * is types. `package.json` points `#hint` here under the `workerd` condition.
6
+ */
7
+ /** Where a hint applies: the site, a local project, or either. Same values as webhint's. */
8
+ export declare enum HintScope {
9
+ local = "local",
10
+ site = "site",
11
+ any = "any"
12
+ }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * What the hints take from webhint's core at run time, for a runtime that
3
+ * cannot load the core (a Cloudflare Worker: the core reads files and loads
4
+ * packages by name). The hints only need the scope names; the rest of webhint
5
+ * is types. `package.json` points `#hint` here under the `workerd` condition.
6
+ */
7
+ /** Where a hint applies: the site, a local project, or either. Same values as webhint's. */
8
+ export var HintScope;
9
+ (function (HintScope) {
10
+ HintScope["local"] = "local";
11
+ HintScope["site"] = "site";
12
+ HintScope["any"] = "any";
13
+ })(HintScope || (HintScope = {}));
14
+ //# sourceMappingURL=hint.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hint.js","sourceRoot":"","sources":["../../src/worker/hint.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,4FAA4F;AAC5F,MAAM,CAAN,IAAY,SAIX;AAJD,WAAY,SAAS;IACnB,4BAAe,CAAA;IACf,0BAAa,CAAA;IACb,wBAAW,CAAA;AACb,CAAC,EAJW,SAAS,KAAT,SAAS,QAIpB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mridang/webhint-hint-plumbline",
3
- "version": "0.13.0",
3
+ "version": "0.14.0",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "prepack": "tsc --build",
@@ -17,6 +17,7 @@
17
17
  },
18
18
  "imports": {
19
19
  "#hint": {
20
+ "workerd": "./dist/worker/hint.js",
20
21
  "default": "hint"
21
22
  },
22
23
  "#net": {