nodejs / nodejs/userland-migrations
feat: handle `tls.SecurePair` depreciation
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 85
- Forks
- 55
- Avg merge
- 3d 11h
- Merged PRs (30d)
- 9
Description
Description
This codemod should migrate tls.SecurePair to tls.TLSSocket. It's useful to migrate code that uses the deprecated tls.SecurePair class which has been removed.
It should handle both constructor usage and method calls on SecurePair instances.
It should support both tls.SecurePair direct usage and destructured imports from tls module.
Example
Case 1
Before:
const tls = require('node:tls');
// Using tls.SecurePair constructor
const pair = new tls.SecurePair();
const cleartext = pair.cleartext;
const encrypted = pair.encrypted;
// Direct import
const { SecurePair } = require('node:tls');
const pair2 = new SecurePair();
After:
const tls = require('node:tls');
// Using tls.TLSSocket instead
const socket = new tls.TLSSocket(socket);
// Note: Direct migration may require additional context-specific changes
// as SecurePair and TLSSocket have different APIs
// Direct import
const { TLSSocket } = require('node:tls');
const socket2 = new TLSSocket(socket);
Case 2
Before:
import tls from 'node:tls';
// Using tls.SecurePair constructor
const pair = new tls.SecurePair();
const cleartext = pair.cleartext;
const encrypted = pair.encrypted;
// Direct import
import { SecurePair } from 'node:tls';
const pair2 = new SecurePair();
After:
import tls from 'node:tls';
// Using tls.TLSSocket instead
const socket = new tls.TLSSocket(socket);
// Note: Direct migration may require additional context-specific changes
// as SecurePair and TLSSocket have different APIs
// Direct import
import { TLSSocket } from 'node:tls';
const socket2 = new TLSSocket(socket);
REFS
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the existing codemod conventions for Node.js API migrations and their tests. Cover CommonJS and ESM forms, both tls.SecurePair and destructured SecurePair usage, and constructor or instance-member references described in the examples. Done means those examples migrate toward tls.TLSSocket while preserving the noted context-specific limitation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- node.js, typescript
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100