Visitar URL original
feat(gax): export ensurePqcCurvesConfigured and verify TLS secure context by danieljbruce · Pull Request #9800 · googleapis/google-cloud-node · GitHub
Skip to content

feat(gax): export ensurePqcCurvesConfigured and verify TLS secure context - #9800

Draft
danieljbruce wants to merge 2 commits into
feat/gax-pqc-mlkem1024-part-2from
feat/gax-pqc-mlkem1024-part-3
Draft

danieljbruce wants to merge 2 commits into
feat/gax-pqc-mlkem1024-part-2from
feat/gax-pqc-mlkem1024-part-3

Conversation

@danieljbruce

@danieljbruce danieljbruce commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Description

This change exports the PQC curve helper from the package root.

Impact

Consumers and tests can directly invoke and verify PQC curve setup.

Stack

# PR Branch Base Role
1 #9798 feat/gax-pqc-mlkem1024-part-1 main Code PR 1 of 3 (src/grpc.ts ensurePqcCurvesConfigured)
2 #9799 feat/gax-pqc-mlkem1024-part-2 feat/gax-pqc-mlkem1024-part-1 Code PR 2 of 3 (GrpcClient constructor PQC curve check)
3 (this PR) #9800 feat/gax-pqc-mlkem1024-part-3 feat/gax-pqc-mlkem1024-part-2 Code PR 3 of 3 (src/index.ts export & TLS context verification)
4 #9802 feat/gax-pqc-mlkem1024-part-3-style-maintenance feat/gax-pqc-mlkem1024-part-3 [Style Maintenance] PR

Changes

  • Exported ensurePqcCurvesConfigured from core/packages/gax/src/index.ts alongside GrpcClient.
  • Added unit test in core/packages/gax/test/unit/grpc.ts verifying tls.createSecureContext succeeds with both the configured tls.DEFAULT_ECDH_CURVE and explicit 'MLKEM1024'.

Testing

  • Steps to Reproduce: Verify MLKEM1024 (0x0202) TLS 1.3 advertisement and handshake negotiation from the terminal by running pnpm --dir core/packages/gax run compile && curl -fsSL https://gist.githubusercontent.com/danieljbruce/3880337b200084e1da370a616e9b211c/raw/repro-pqc-mlkem1024.mjs | node --input-type=module - (see repro-pqc-mlkem1024.mjs Gist).
  • Verified targeted unit tests on Node.js (node bin/run-test.cjs --no-c8 core/packages/gax/build/test/unit/grpc.js) and Bun (JS_RUNTIME=bun MOCHA_PARALLEL=false bun --bun bin/run-test.cjs --no-c8 core/packages/gax/build/test/unit/grpc.js).
  • Verified strict lint and type checking across the stack via node ./bin/linter.mjs --strict.

Alternatives

  • Keeping ensurePqcCurvesConfigured internal to src/grpc.ts was rejected because exporting it from google-gax allows REST-only callers and integration tests to explicitly verify or re-trigger PQC curve configuration.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request exports the ensurePqcCurvesConfigured function from the main entry point and adds a unit test to verify that a valid TLS secure context is created supporting both X25519MLKEM768 and MLKEM1024. The review feedback recommends avoiding direct mutation of the imported tls module (tls.DEFAULT_ECDH_CURVE) within the test, as mutating shared built-in modules can cause runtime errors in environments with frozen module namespaces and lead to flaky tests.

Comment thread core/packages/gax/test/unit/grpc.ts Outdated
Comment on lines +963 to +974
it('creates a valid TLS secure context supporting both X25519MLKEM768 (0x11ec) and MLKEM1024 (0x0202)', () => {
tls.DEFAULT_ECDH_CURVE = 'auto';
ensurePqcCurvesConfigured();
const defaultCtx = tls.createSecureContext({
ecdhCurve: tls.DEFAULT_ECDH_CURVE,
});
const mlkem1024Ctx = tls.createSecureContext({
ecdhCurve: 'MLKEM1024',
});
assert.ok(defaultCtx);
assert.ok(mlkem1024Ctx);
});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Avoid directly mutating imported or shared built-in modules (such as the 'tls' module) in tests, as this can cause runtime errors in environments with frozen module namespaces (like native ES Modules) and lead to flaky tests. Instead, verify behavior through other side effects or use proper mocking/stubbing libraries.

References
  1. Avoid directly mutating imported or shared built-in modules (such as the 'path' module) in tests, as this can cause runtime errors in environments with frozen module namespaces (like native ES Modules) and lead to flaky tests. Instead, verify behavior through other side effects (e.g., monitoring file system cleanup operations) or use proper mocking/stubbing libraries.

export {
ClientStub,
ClientStubOptions,
ensurePqcCurvesConfigured,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Generated] Re-exports ensurePqcCurvesConfigured from ./grpc at the top-level google-gax package entry point.

Comment on lines +962 to +974

it('creates a valid TLS secure context supporting both X25519MLKEM768 (0x11ec) and MLKEM1024 (0x0202)', () => {
tls.DEFAULT_ECDH_CURVE = 'auto';
ensurePqcCurvesConfigured();
const defaultCtx = tls.createSecureContext({
ecdhCurve: tls.DEFAULT_ECDH_CURVE,
});
const mlkem1024Ctx = tls.createSecureContext({
ecdhCurve: 'MLKEM1024',
});
assert.ok(defaultCtx);
assert.ok(mlkem1024Ctx);
});

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Generated] Verifies that tls.createSecureContext succeeds both with the configured tls.DEFAULT_ECDH_CURVE (supporting X25519MLKEM768 0x11ec and MLKEM1024 0x0202) and with explicit ecdhCurve: 'MLKEM1024'.

@danieljbruce
danieljbruce force-pushed the feat/gax-pqc-mlkem1024-part-3 branch from b7d3fc3 to fa3e49c Compare November 2, 2026 20:16
Comment on lines +30 to +33
import {
ensurePqcCurvesConfigured as indexEnsurePqcCurvesConfigured,
protobuf,
} from '../../src/index';

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Generated] Update core/packages/gax/test/unit/grpc.ts (lines 30-33 in import {afterEach, describe, it, beforeEach} from 'mocha';): +4/-1 line(s) for this stacked change block.

@danieljbruce

Copy link
Copy Markdown
Contributor Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request exports ensurePqcCurvesConfigured from the package index and adds a unit test to verify that valid TLS secure contexts are created supporting both X25519MLKEM768 and MLKEM1024. Feedback suggests avoiding direct mutation of the imported tls module's properties (specifically tls.DEFAULT_ECDH_CURVE) within tests, as this can cause runtime errors in environments with frozen module namespaces and lead to flaky tests.

Comment on lines +1070 to +1079
tls.DEFAULT_ECDH_CURVE = 'auto';
ensurePqcCurvesConfigured();
const defaultCtx = tls.createSecureContext({
ecdhCurve: tls.DEFAULT_ECDH_CURVE,
});
const mlkem1024Ctx = tls.createSecureContext({
ecdhCurve: 'MLKEM1024',
});
assert.ok(defaultCtx);
assert.ok(mlkem1024Ctx);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Avoid directly mutating imported or shared built-in modules (such as the 'tls' module) in tests, as this can cause runtime errors in environments with frozen module namespaces (like native ES Modules) and lead to flaky tests. Instead, use proper mocking/stubbing libraries to stub tls.DEFAULT_ECDH_CURVE or verify behavior through other side effects.

References
  1. Avoid directly mutating imported or shared built-in modules (such as the 'path' module) in tests, as this can cause runtime errors in environments with frozen module namespaces (like native ES Modules) and lead to flaky tests. Instead, verify behavior through other side effects (e.g., monitoring file system cleanup operations) or use proper mocking/stubbing libraries.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant