Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
@medusajs/medusa-js
Advanced tools
The Medusa JS Client provides easy access to the Medusa API from a client written in Typescript.
See our API reference.
Install the package with:
npm install @medusajs/medusa-js
# or
yarn add @medusajs/medusa-js
Import Medusa as a default import and initiate it:
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa()
const { cart } = await medusa.carts.create({})
Authentication can be achieved in two ways using the medusa-js
client, either by utilizing API keys or by using cookie based authentication, each with their own unique use case.
API keys can only be used for admin functionality in Medusa because only users of the admin system have api keys. To use API keys for authentication the key should be used when medusa-js
is initialized with a config object as described below.
Authentication using cookies is done automatically by Axios when authenticating using the auth
endpoints. After authentication all subsequent calls will be authenticated.
note: Cookie based authentication cannot be used in plain node.js
applications due to the limitations of axios and useCredentials
not setting the Cookie
request header when set-cookie
is present in the response headers. For pure node.js
applications use authentication with api keys(see above)
The package can be initialized with several options:
const medusa = new Medusa({
maxRetries: 3,
baseUrl: "https://api.example.com",
})
Option | Default | Description |
---|---|---|
maxRetries | 0 | The amount of times a request is retried. |
baseUrl | 'http://localhost:9000' | The url to which requests are made to. |
apiKey | '' | Optional api key used for authenticating admin requests . |
FAQs
Client for Medusa Commerce Rest API
The npm package @medusajs/medusa-js receives a total of 18,230 weekly downloads. As such, @medusajs/medusa-js popularity was classified as popular.
We found that @medusajs/medusa-js demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.