Skip to content

feat: DEP0093: crypto.fips is deprecated and replaced #175

@AugustinMauroy

Description

@AugustinMauroy

Description

This codemod should migrate crypto.fips property usage to crypto.getFips() and crypto.setFips(). It's useful to migrate code that uses the deprecated crypto.fips property which has been replaced with dedicated functions.

It should replace property reads with crypto.getFips() calls. It should replace property assignments with crypto.setFips() calls. It should handle both CommonJS and ESM imports. It should preserve FIPS mode configuration logic.

Examples

Case 1

Before:

const crypto = require("node:crypto");
if (crypto.fips) {
  console.log("FIPS mode is enabled");
}

After:

const crypto = require("node:crypto");
if (crypto.getFips()) {
  console.log("FIPS mode is enabled");
}

Case 2

Before:

const crypto = require("node:crypto");
crypto.fips = true;

After:

const crypto = require("node:crypto");
crypto.setFips(true);

Case 3

Before:

const crypto = require("node:crypto");
if (process.env.ENABLE_FIPS === "true") {
  crypto.fips = true;
}
console.log("FIPS enabled:", crypto.fips);

After:

const crypto = require("node:crypto");
if (process.env.ENABLE_FIPS === "true") {
  crypto.setFips(true);
}
console.log("FIPS enabled:", crypto.getFips());

Case 4

Before:

import crypto from "node:crypto";
const fipsStatus = crypto.fips;
crypto.fips = !fipsStatus;

After:

import crypto from "node:crypto";
const fipsStatus = crypto.getFips();
crypto.setFips(!fipsStatus);

REFS

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    Status

    🏗 In progress

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions