Skip to content

feat: handle tls.SecurePair depreciation #126

@AugustinMauroy

Description

@AugustinMauroy

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

Metadata

Metadata

Assignees

No one assigned

    Projects

    Status

    🔖 Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions