
Research
Malicious npm Packages Impersonate Flashbots SDKs, Targeting Ethereum Wallet Credentials
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
adonis-shopping-cart
Advanced tools
Basic Shopping Cart functionality for AdonisJS v5
The Cart is using @adonisjs/session
to store the data, please ensure you have this package installed and configured.
# npm
npm i adonis-shopping-cart
Register and configure package with AdonisJS
# npm
node ace configure adonis-shopping-cart
Update variable value in .env
file of your project, the default CART_VAT
is 20%.
Assume that the VAT is already included in the item price.
Example:
Item price: £100.00
Sub total: £80.00
Vat: £20.00 (based on 20% VAT rate)
Total: £100.00
CART_VAT=20
Number format Locale and Options can be specified in config/cart.ts
// default format values
format:{
locale: 'en-GB',
options: { style: 'currency', currency: 'GBP' },
},
Cart accepts items of CartItem
Type
{
id: number;
name: string;
price: number;
priceFormat: string;
quantity: number;
attributes: [key: string];
}
{
id: 1234,
name: 'Classic T-Shirt',
price: 21.99,
priceFormat: '£21.99',
quantity: 1,
attributes: {
image: 'https://image.url',
color: 'white',
size: 'M',
// more attributes
}
}
Cart creates unique rowId for each item by hashing item.attributes
object allowing to distinguish items with the different atributes, for eaxmple:
To update an item in the Cart use add
method, it will find the item in the Cart and update it or create a new item
Cart.add(item);
let rowId = "lcoLo4tYTGnCn9pqnSgRLqeYV/KAbgDtfXeRUwRL24k=";
let item ={
"id": 1,
"price": 22.5,
"priceFormat": "£22.50",
"name": "A green door",
"quantity": 4,
"attributes": {
"image": "https://tailwindui.com/img/ecommerce-images/shopping-cart-page-01-product-01.jpg",
"color": "sky",
"size": "s"
}
Cart.update(rowId:string, item:CartItem);
Cart.remove(item);
//or
Cart.removeByRowId(rowId);
Cart.getContent()
{
"lcoLo4tYTGnCn9pqnSgRLqeYV/KAbgDtfXeRUwRL24k=": { // rowId
"id": 1,
"price": 22.5,
"priceFormat": "£22.50",
"name": "A green door",
"quantity": 4,
"attributes": {
"image": "https://tailwindui.com/img/ecommerce-images/shopping-cart-page-01-product-01.jpg",
"color": "sky",
"size": "s"
}
},
"fLBUy2jj8rI1KcBvI0G2MV1nPD2pkoySPUeBjIp6U30=": { // rowId
"id": 2,
"price": 24.5,
"priceFormat": "£24.50",
"name": "Basic Tee",
"quantity": 1,
"attributes": {
"image": "https://tailwindui.com/img/ecommerce-images/shopping-cart-page-01-product-02.jpg",
"color": "pink",
"size": "s"
}
}
}
// has Cart given item
Cart.has(rowId:string):boolean
// Shipping Amount
Cart.setShippingAmmount(10): void
Cart.getShiping():string // "£10.00"
Cart.getShipingNumber():number // 10
// subTotal - (subTotal * VAT)
Cart.getSubtotal(): string // "£22.50"
//subTotal * VAT
Cart.getVat():string // "£4.50"
Cart.getVatNumber():number // 4.50
// subTotal + VAT + Shipping
Cart.getTotal():string // "£27.00"
Cart.getTotalNumber():number // 27
// calculate quantity of all items in Cart
Cart.getTotalQuantity():number // 1
import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'
import Cart from '@ioc:Adonis/Addons/Cart'
export default class CartController {
public async add({ request }: HttpContextContract) {
let data = request.body()
Cart.add(data)
...
}
npm run clean
npm run test
FAQs
Adonis Shopping Cart
The npm package adonis-shopping-cart receives a total of 0 weekly downloads. As such, adonis-shopping-cart popularity was classified as not popular.
We found that adonis-shopping-cart demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.