Installations
npm install fetch-to-curl
Developer
leoek
Developer Guide
Module System
CommonJS
Min. Node Version
Typescript Support
Yes
Node Version
NPM Version
Statistics
69 Stars
107 Commits
13 Forks
2 Watching
3 Branches
8 Contributors
Updated on 07 Nov 2024
Languages
JavaScript (84.45%)
HTML (15.55%)
Total Downloads
Cumulative downloads
Total Downloads
3,521,987
Last day
11.1%
5,220
Compared to previous day
Last week
1.1%
22,832
Compared to previous week
Last month
-10.7%
100,686
Compared to previous month
Last year
22%
1,135,302
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
fetch request to curl
This module was inspired by http-to-curl. Use it to generate curl requests with the inputs you would usually use for javascripts fetch. However it does not patch any modules like http-to-curl. It is just a wrapper to generate the curl string. This ensures that there are no side effects with your actual usage of fetch.
Also note that the goal of this library is to be as simple and minimal as possible. This also means that there are zero dependencies :tada:
Installation
1yarn add fetch-to-curl
or
1npm install fetch-to-curl
Usage
1import { fetchToCurl } from 'fetch-to-curl'; 2// or In case there is no support for Es Modules in your environment: 3// const { fetchToCurl } = require("fetch-to-curl") 4 5const url = 'https://jsonplaceholder.typicode.com/posts/1'; 6const options = { 7 headers: { 8 Authorization: "BASIC SOMEBASE64STRING" 9 }, 10 method: 'get' 11}; 12// Log yopur request 13console.log(fetchToCurl(url, options)); 14// Do your request 15fetch(url, options); 16 17// Output 18curl "https://jsonplaceholder.typicode.com/posts/1" -X GET -H "Authorization: BASIC SOMEBASE64STRING" 19 20// You can also pass a single Request object 21console.log(fetchToCurl({ 22 url: "https://jsonplaceholder.typicode.com/posts/1" 23 headers: { 24 Authorization: "BASIC SOMEBASE64STRING" 25 }, 26 method: 'get' 27})); 28 29// and/or a Headers object as you would to with fetch 30console.log(fetchToCurl({ 31 url: "https://jsonplaceholder.typicode.com/posts/1" 32 headers: new Headers({ 33 Authorization: "BASIC SOMEBASE64STRING" 34 }), 35 method: 'get' 36})) 37
Playground and usage without package manager
There is a minimal example of usage without package manager available which allows to directly test this in the browser console. (view source - playground.html)
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
SAST tool detected but not run on all commits
Details
- Info: SAST configuration detected: CodeQL
- Warn: 4 commits out of 28 are checked with a SAST tool
Reason
Found 4/6 approved changesets -- score normalized to 6
Reason
5 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv
- Warn: Project is vulnerable to: GHSA-gcx4-mw62-g8wm
- Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw
Reason
1 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/codeql-analysis.yml:42: update your workflow using https://app.stepsecurity.io/secureworkflow/leoek/fetch-to-curl/codeql-analysis.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/codeql-analysis.yml:46: update your workflow using https://app.stepsecurity.io/secureworkflow/leoek/fetch-to-curl/codeql-analysis.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/codeql-analysis.yml:57: update your workflow using https://app.stepsecurity.io/secureworkflow/leoek/fetch-to-curl/codeql-analysis.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/codeql-analysis.yml:71: update your workflow using https://app.stepsecurity.io/secureworkflow/leoek/fetch-to-curl/codeql-analysis.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/nodejs.yml:16: update your workflow using https://app.stepsecurity.io/secureworkflow/leoek/fetch-to-curl/nodejs.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/nodejs.yml:21: update your workflow using https://app.stepsecurity.io/secureworkflow/leoek/fetch-to-curl/nodejs.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/publish.yml:14: update your workflow using https://app.stepsecurity.io/secureworkflow/leoek/fetch-to-curl/publish.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/publish.yml:19: update your workflow using https://app.stepsecurity.io/secureworkflow/leoek/fetch-to-curl/publish.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/testCoverage.yml:13: update your workflow using https://app.stepsecurity.io/secureworkflow/leoek/fetch-to-curl/testCoverage.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/testCoverage.yml:18: update your workflow using https://app.stepsecurity.io/secureworkflow/leoek/fetch-to-curl/testCoverage.yml/master?enable=pin
- Info: 0 out of 10 GitHub-owned GitHubAction dependencies pinned
Reason
detected GitHub workflow tokens with excessive permissions
Details
- Info: jobLevel 'contents' permission set to 'read': .github/workflows/codeql-analysis.yml:29
- Info: jobLevel 'actions' permission set to 'read': .github/workflows/codeql-analysis.yml:28
- Warn: no topLevel permission defined: .github/workflows/codeql-analysis.yml:1
- Warn: no topLevel permission defined: .github/workflows/nodejs.yml:1
- Warn: no topLevel permission defined: .github/workflows/publish.yml:1
- Warn: no topLevel permission defined: .github/workflows/testCoverage.yml:1
- Info: no jobLevel write permissions found
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
Project has not signed or included provenance with any releases.
Details
- Warn: release artifact 0.6.0 not signed: https://api.github.com/repos/leoek/fetch-to-curl/releases/86295380
- Warn: release artifact 0.5.2 not signed: https://api.github.com/repos/leoek/fetch-to-curl/releases/37979128
- Warn: release artifact 0.5.1 not signed: https://api.github.com/repos/leoek/fetch-to-curl/releases/35806440
- Warn: release artifact 0.5.0 not signed: https://api.github.com/repos/leoek/fetch-to-curl/releases/35666489
- Warn: release artifact 0.4.0 not signed: https://api.github.com/repos/leoek/fetch-to-curl/releases/26438176
- Warn: release artifact 0.6.0 does not have provenance: https://api.github.com/repos/leoek/fetch-to-curl/releases/86295380
- Warn: release artifact 0.5.2 does not have provenance: https://api.github.com/repos/leoek/fetch-to-curl/releases/37979128
- Warn: release artifact 0.5.1 does not have provenance: https://api.github.com/repos/leoek/fetch-to-curl/releases/35806440
- Warn: release artifact 0.5.0 does not have provenance: https://api.github.com/repos/leoek/fetch-to-curl/releases/35666489
- Warn: release artifact 0.4.0 does not have provenance: https://api.github.com/repos/leoek/fetch-to-curl/releases/26438176
Score
4
/10
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn MoreOther packages similar to fetch-to-curl
convert-fetch-to-curl
Example to convert fetch to curl
r2curl
Node.js Request Wrapper (axios, fetch, ..) to cURL Command String
@sentry/cli
A command line utility to work with Sentry. https://docs.sentry.io/hosted/learn/cli/
node-fetch
A light-weight module that brings Fetch API to node.js