-
-
Notifications
You must be signed in to change notification settings - Fork 18
feat(tls.createSecureContext): introduce #156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 5 commits
21b6e0b
144c006
f65c839
8f7bae7
0b4c417
e36f7be
6525cfd
a56c4bb
e6bf56e
9ac7b8b
74d8025
81b8480
7b8633f
55bddce
c08282f
202b99f
67579ea
f36f0ee
21ce469
1a8b640
dfeb476
b3f8bef
f3dde78
884a44d
015cd21
152e90f
c0fd8e0
d057380
f721b00
adc08e3
7dbb6b2
c3fc053
44015c1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# `crypto.createCredentials` DEP0010 | ||
|
||
This recipe provides a guide for migrating from the deprecated `crypto.createCredentials` method in Node.js. | ||
|
||
See [DEP0010](https://nodejs.org/api/deprecations.html#DEP0010). | ||
|
||
## Examples | ||
|
||
**Before:** | ||
|
||
```js | ||
0hmX marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// Using the deprecated createCredentials from node:crypto | ||
const { createCredentials } = require('node:crypto'); | ||
|
||
const credentials = createCredentials({ | ||
key: privateKey, | ||
cert: certificate, | ||
ca: [caCertificate] | ||
}); | ||
|
||
// Using destructuring with ES module imports | ||
import { createCredentials } from 'node:crypto'; | ||
|
||
const credentials = createCredentials({ | ||
key: privateKey, | ||
cert: certificate, | ||
ca: [caCertificate] | ||
}); | ||
0hmX marked this conversation as resolved.
Show resolved
Hide resolved
|
||
``` | ||
|
||
**After:** | ||
|
||
```js | ||
0hmX marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// Updated to use createSecureContext from node:tls | ||
const { createSecureContext } = require('node:tls'); | ||
|
||
const credentials = createSecureContext({ | ||
key: privateKey, | ||
cert: certificate, | ||
ca: [caCertificate] | ||
}); | ||
|
||
// Updated ES module import | ||
import { createSecureContext } from 'node:tls'; | ||
|
||
const credentials = createSecureContext({ | ||
key: privateKey, | ||
cert: certificate, | ||
ca: [caCertificate] | ||
}); | ||
0hmX marked this conversation as resolved.
Show resolved
Hide resolved
|
||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
schema_version: "1.0" | ||
name: "@nodejs/crypto-create-credentials" | ||
|
||
version: 1.0.0 | ||
description: Handle DEP0010 via transforming `crypto.createCredentials` to `tls.createSecureContext` | ||
author: 0hmx | ||
license: MIT | ||
workflow: workflow.yaml | ||
category: migration | ||
|
||
targets: | ||
languages: | ||
- javascript | ||
- typescript | ||
|
||
keywords: | ||
- transformation | ||
- migration | ||
|
||
registry: | ||
access: public | ||
visibility: public | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"name": "@nodejs/crypto-create-credentials", | ||
"version": "1.0.0", | ||
"description": "Handle DEP0010 via transforming `crypto.createCredentials` to `tls.createSecureContext` with the appropriate options.", | ||
"type": "module", | ||
"scripts": { | ||
"test": "npx codemod@next jssg test -l typescript ./src/workflow.ts ./" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/nodejs/userland-migrations.git", | ||
"directory": "recipes/crypto-create-credentials", | ||
"bugs": "https://github.com/nodejs/userland-migrations/issues" | ||
0hmX marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}, | ||
"author": "0hmx", | ||
"license": "MIT", | ||
"homepage": "https://github.com/nodejs/userland-migrations/blob/main/recipes/crypto-create-credentials/README.md", | ||
"devDependencies": { | ||
"@codemod.com/jssg-types": "^1.0.3" | ||
}, | ||
"dependencies": { | ||
"@nodejs/codemod-utils": "*" | ||
} | ||
} |
Uh oh!
There was an error while loading. Please reload this page.