From 5d33a655bb3699aba430fdd7335e43cdf0d4b773 Mon Sep 17 00:00:00 2001 From: Matt Cowley Date: Wed, 25 Feb 2026 23:00:02 +0000 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=A4=96=20Merge=20PR=20#74568=20Add=20?= =?UTF-8?q?types=20for=20is-deflate=20by=20@MattIPv4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- types/is-deflate/.npmignore | 5 +++++ types/is-deflate/index.d.ts | 3 +++ types/is-deflate/is-deflate-tests.ts | 3 +++ types/is-deflate/package.json | 18 ++++++++++++++++++ types/is-deflate/tsconfig.json | 19 +++++++++++++++++++ 5 files changed, 48 insertions(+) create mode 100644 types/is-deflate/.npmignore create mode 100644 types/is-deflate/index.d.ts create mode 100644 types/is-deflate/is-deflate-tests.ts create mode 100644 types/is-deflate/package.json create mode 100644 types/is-deflate/tsconfig.json diff --git a/types/is-deflate/.npmignore b/types/is-deflate/.npmignore new file mode 100644 index 00000000000000..93e307400a5456 --- /dev/null +++ b/types/is-deflate/.npmignore @@ -0,0 +1,5 @@ +* +!**/*.d.ts +!**/*.d.cts +!**/*.d.mts +!**/*.d.*.ts diff --git a/types/is-deflate/index.d.ts b/types/is-deflate/index.d.ts new file mode 100644 index 00000000000000..96e08a2045467c --- /dev/null +++ b/types/is-deflate/index.d.ts @@ -0,0 +1,3 @@ +export = is_deflate; + +declare function is_deflate(buf: Buffer | Uint8Array): boolean; diff --git a/types/is-deflate/is-deflate-tests.ts b/types/is-deflate/is-deflate-tests.ts new file mode 100644 index 00000000000000..44709609bfcc90 --- /dev/null +++ b/types/is-deflate/is-deflate-tests.ts @@ -0,0 +1,3 @@ +/// +import isDeflate from "is-deflate"; +isDeflate(Buffer.from("blah blah")); diff --git a/types/is-deflate/package.json b/types/is-deflate/package.json new file mode 100644 index 00000000000000..6e6df2483eb856 --- /dev/null +++ b/types/is-deflate/package.json @@ -0,0 +1,18 @@ +{ + "private": true, + "name": "@types/is-deflate", + "version": "1.0.9999", + "projects": [ + "https://github.com/watson/is-deflate#readme" + ], + "devDependencies": { + "@types/is-deflate": "workspace:.", + "@types/node": "*" + }, + "owners": [ + { + "name": "Matt Cowley", + "githubUsername": "MattIPv4" + } + ] +} diff --git a/types/is-deflate/tsconfig.json b/types/is-deflate/tsconfig.json new file mode 100644 index 00000000000000..f32666113fdf46 --- /dev/null +++ b/types/is-deflate/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "module": "node16", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictFunctionTypes": true, + "strictNullChecks": true, + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "is-deflate-tests.ts" + ] +} From 51ccb0aacf524906eaf5aa5e163d59b6305b4f01 Mon Sep 17 00:00:00 2001 From: Tony Gies Date: Wed, 25 Feb 2026 18:59:42 -0600 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=A4=96=20Merge=20PR=20#74543=20[@type?= =?UTF-8?q?s/node]=20tls.Certificate:=20widen=20DN=20fields=20to=20string?= =?UTF-8?q?=20|=20string[]=20by=20@tgies?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- types/node/node-tests/tls.ts | 27 +++++++++++++++++++++++++++ types/node/tls.d.ts | 14 +++++++------- types/node/v20/test/tls.ts | 27 +++++++++++++++++++++++++++ types/node/v20/tls.d.ts | 14 +++++++------- types/node/v22/test/tls.ts | 27 +++++++++++++++++++++++++++ types/node/v22/tls.d.ts | 14 +++++++------- types/node/v24/test/tls.ts | 27 +++++++++++++++++++++++++++ types/node/v24/tls.d.ts | 14 +++++++------- 8 files changed, 136 insertions(+), 28 deletions(-) diff --git a/types/node/node-tests/tls.ts b/types/node/node-tests/tls.ts index 84bfa124392eb1..5b72a0eabdbe0b 100644 --- a/types/node/node-tests/tls.ts +++ b/types/node/node-tests/tls.ts @@ -314,6 +314,33 @@ import { const r00ts: readonly string[] = rootCertificates; } +// Certificate DN fields are optional and can be string or string[] (multi-valued) +{ + const tlsSocket = connect({}); + const peerCert = tlsSocket.getPeerCertificate(); + const subject = peerCert.subject; + + // Fields are optional and may be string or string[] + const cn: string | string[] | undefined = subject.CN; + const ou: string | string[] | undefined = subject.OU; + const o: string | string[] | undefined = subject.O; + + // Type narrowing with Array.isArray + if (Array.isArray(subject.OU)) { + const ous: string[] = subject.OU; + } else { + const ou: string | undefined = subject.OU; + } + + // Arbitrary DN attributes via index signature + const email: string | string[] | undefined = subject["emailAddress"]; + const dc: string | string[] | undefined = subject["DC"]; + + // Issuer has the same shape + const issuer = peerCert.issuer; + const issuerCN: string | string[] | undefined = issuer.CN; +} + { const _options: TlsOptions = {}; const _server = new Server(_options, (socket) => {}); diff --git a/types/node/tls.d.ts b/types/node/tls.d.ts index 5c45f93774f058..635ee3e7ddebd9 100644 --- a/types/node/tls.d.ts +++ b/types/node/tls.d.ts @@ -15,31 +15,31 @@ declare module "node:tls" { import * as stream from "stream"; const CLIENT_RENEG_LIMIT: number; const CLIENT_RENEG_WINDOW: number; - interface Certificate { + interface Certificate extends NodeJS.Dict { /** * Country code. */ - C: string; + C?: string | string[]; /** * Street. */ - ST: string; + ST?: string | string[]; /** * Locality. */ - L: string; + L?: string | string[]; /** * Organization. */ - O: string; + O?: string | string[]; /** * Organizational unit. */ - OU: string; + OU?: string | string[]; /** * Common name. */ - CN: string; + CN?: string | string[]; } interface PeerCertificate { /** diff --git a/types/node/v20/test/tls.ts b/types/node/v20/test/tls.ts index 7d0298cca28178..c4fc7ebc4fbdf8 100644 --- a/types/node/v20/test/tls.ts +++ b/types/node/v20/test/tls.ts @@ -325,6 +325,33 @@ import { const r00ts: readonly string[] = rootCertificates; } +// Certificate DN fields are optional and can be string or string[] (multi-valued) +{ + const tlsSocket = connect({}); + const peerCert = tlsSocket.getPeerCertificate(); + const subject = peerCert.subject; + + // Fields are optional and may be string or string[] + const cn: string | string[] | undefined = subject.CN; + const ou: string | string[] | undefined = subject.OU; + const o: string | string[] | undefined = subject.O; + + // Type narrowing with Array.isArray + if (Array.isArray(subject.OU)) { + const ous: string[] = subject.OU; + } else { + const ou: string | undefined = subject.OU; + } + + // Arbitrary DN attributes via index signature + const email: string | string[] | undefined = subject["emailAddress"]; + const dc: string | string[] | undefined = subject["DC"]; + + // Issuer has the same shape + const issuer = peerCert.issuer; + const issuerCN: string | string[] | undefined = issuer.CN; +} + { const _options: TlsOptions = {}; const _server = new Server(_options, (socket) => {}); diff --git a/types/node/v20/tls.d.ts b/types/node/v20/tls.d.ts index 0b819a1779e450..7ecc2331f2f8a2 100644 --- a/types/node/v20/tls.d.ts +++ b/types/node/v20/tls.d.ts @@ -15,31 +15,31 @@ declare module "tls" { import * as stream from "stream"; const CLIENT_RENEG_LIMIT: number; const CLIENT_RENEG_WINDOW: number; - interface Certificate { + interface Certificate extends NodeJS.Dict { /** * Country code. */ - C: string; + C?: string | string[]; /** * Street. */ - ST: string; + ST?: string | string[]; /** * Locality. */ - L: string; + L?: string | string[]; /** * Organization. */ - O: string; + O?: string | string[]; /** * Organizational unit. */ - OU: string; + OU?: string | string[]; /** * Common name. */ - CN: string; + CN?: string | string[]; } interface PeerCertificate { /** diff --git a/types/node/v22/test/tls.ts b/types/node/v22/test/tls.ts index 29559361ad00e7..e587ab13f7ee42 100644 --- a/types/node/v22/test/tls.ts +++ b/types/node/v22/test/tls.ts @@ -329,6 +329,33 @@ import { const r00ts: readonly string[] = rootCertificates; } +// Certificate DN fields are optional and can be string or string[] (multi-valued) +{ + const tlsSocket = connect({}); + const peerCert = tlsSocket.getPeerCertificate(); + const subject = peerCert.subject; + + // Fields are optional and may be string or string[] + const cn: string | string[] | undefined = subject.CN; + const ou: string | string[] | undefined = subject.OU; + const o: string | string[] | undefined = subject.O; + + // Type narrowing with Array.isArray + if (Array.isArray(subject.OU)) { + const ous: string[] = subject.OU; + } else { + const ou: string | undefined = subject.OU; + } + + // Arbitrary DN attributes via index signature + const email: string | string[] | undefined = subject["emailAddress"]; + const dc: string | string[] | undefined = subject["DC"]; + + // Issuer has the same shape + const issuer = peerCert.issuer; + const issuerCN: string | string[] | undefined = issuer.CN; +} + { const _options: TlsOptions = {}; const _server = new Server(_options, (socket) => {}); diff --git a/types/node/v22/tls.d.ts b/types/node/v22/tls.d.ts index 84dc89f3b14e15..51770320bb5ee6 100644 --- a/types/node/v22/tls.d.ts +++ b/types/node/v22/tls.d.ts @@ -15,31 +15,31 @@ declare module "tls" { import * as stream from "stream"; const CLIENT_RENEG_LIMIT: number; const CLIENT_RENEG_WINDOW: number; - interface Certificate { + interface Certificate extends NodeJS.Dict { /** * Country code. */ - C: string; + C?: string | string[]; /** * Street. */ - ST: string; + ST?: string | string[]; /** * Locality. */ - L: string; + L?: string | string[]; /** * Organization. */ - O: string; + O?: string | string[]; /** * Organizational unit. */ - OU: string; + OU?: string | string[]; /** * Common name. */ - CN: string; + CN?: string | string[]; } interface PeerCertificate { /** diff --git a/types/node/v24/test/tls.ts b/types/node/v24/test/tls.ts index 29559361ad00e7..e587ab13f7ee42 100644 --- a/types/node/v24/test/tls.ts +++ b/types/node/v24/test/tls.ts @@ -329,6 +329,33 @@ import { const r00ts: readonly string[] = rootCertificates; } +// Certificate DN fields are optional and can be string or string[] (multi-valued) +{ + const tlsSocket = connect({}); + const peerCert = tlsSocket.getPeerCertificate(); + const subject = peerCert.subject; + + // Fields are optional and may be string or string[] + const cn: string | string[] | undefined = subject.CN; + const ou: string | string[] | undefined = subject.OU; + const o: string | string[] | undefined = subject.O; + + // Type narrowing with Array.isArray + if (Array.isArray(subject.OU)) { + const ous: string[] = subject.OU; + } else { + const ou: string | undefined = subject.OU; + } + + // Arbitrary DN attributes via index signature + const email: string | string[] | undefined = subject["emailAddress"]; + const dc: string | string[] | undefined = subject["DC"]; + + // Issuer has the same shape + const issuer = peerCert.issuer; + const issuerCN: string | string[] | undefined = issuer.CN; +} + { const _options: TlsOptions = {}; const _server = new Server(_options, (socket) => {}); diff --git a/types/node/v24/tls.d.ts b/types/node/v24/tls.d.ts index 1e51dabf37afee..db044ac01c4d72 100644 --- a/types/node/v24/tls.d.ts +++ b/types/node/v24/tls.d.ts @@ -15,31 +15,31 @@ declare module "tls" { import * as stream from "stream"; const CLIENT_RENEG_LIMIT: number; const CLIENT_RENEG_WINDOW: number; - interface Certificate { + interface Certificate extends NodeJS.Dict { /** * Country code. */ - C: string; + C?: string | string[]; /** * Street. */ - ST: string; + ST?: string | string[]; /** * Locality. */ - L: string; + L?: string | string[]; /** * Organization. */ - O: string; + O?: string | string[]; /** * Organizational unit. */ - OU: string; + OU?: string | string[]; /** * Common name. */ - CN: string; + CN?: string | string[]; } interface PeerCertificate { /**