Security News
Supply Chain Attack Detected in Solana's web3.js Library
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
Opinionated Typesafe http middleware library using fp-ts-routing and io-ts
Includes fp-ts
fp-ts-routing
and io-ts
npm i fp-ts-http
import { end, lit, int } from 'fp-ts-routing'
import * as io from "io-ts"
import { get, post, driver } from "fp-ts-http"
import { TMiddlewareStack } from 'fp-ts-http/lib/Middleware';
import { none } from 'fp-ts/lib/Option';
const stack: TMiddlewareStack = []
const userById = lit('users').then(int("userid"))
const stack2 = [...stack, ...get<{userid: number}, string>(userById.then(end), async(req) => {
return {
status: 200,
headers: none,
body: `fetched user ${req.path.userid}`
}
})]
const userMessages = userById.then(lit("messages"))
const userMessageDto = io.type({ message: io.string })
const stack3 = [...stack2, ...post<{userid: number}, {message: string}, string>(userMessages.then(end), userMessageDto, async(req) => {
return {
status: 200,
headers: none,
body: `post message "${req.body.message}" to user ${req.path.userid}`
}
})]
driver(stack3, 3000).run()
.then(() => console.log("server running"))
import { end, lit, query, str } from 'fp-ts-routing'
import * as io from "io-ts"
import { get, post, driver } from "."
import { TMiddlewareStack } from './Middleware';
import { none } from 'fp-ts/lib/Option';
import { NumberFromString, BooleanFromString, ArrayFromString } from './Query';
const stack: TMiddlewareStack = []
type TUsersPath = {
type: string;
}
const usersQuery = io.strict({
filter: io.union([ io.undefined, io.string ]),
validStatusCodes: io.union([ io.undefined, ArrayFromString<number>(NumberFromString) ]),
sortBy: io.union([ io.undefined, io.string]),
sortDirection: io.union([ io.undefined, BooleanFromString])
})
type TUsersQuery = io.TypeOf<typeof usersQuery>
type TUsersResponseBody = string
const users = lit("users").then(str("type"))
const stack2 = [...stack, ...get<TUsersPath, TUsersQuery, TUsersResponseBody>(users.then(end), usersQuery, async(req) => {
return {
status: 200,
headers: none,
body: await UserRepository.find({
type: req.path.type,
sortBy: req.path.sortBy,
sortDirection: req.path.sortDirection
})
}
})]
type TUserMessageDto = {
message: string
}
const userMessages = users.then(lit("messages"))
const userMessageDto = io.type({ message: io.string })
type TUserMessagesResponseBody = string
const stack3 = [...stack2, ...post<TUsersPath, TUsersQuery, TUserMessageDto, TUserMessagesResponseBody>(userMessages.then(end), usersQuery, userMessageDto, async(req) => {
const users = await UserRepository.find({
type: req.path.type,
sortBy: req.path.sortBy,
sortDirection: req.path.sortDirection
})
await Promise.all(users.map(async user => sendMessageToUser(user, req.body)))
return {
status: 200,
headers: none,
body: JSON.stringify(req.path)
}
})]
driver(stack3, 3000).run()
.then(() => console.log("server running"))
FAQs
Opinionated Typesafe http middleware library using fp-ts-routing and io-ts
We found that fp-ts-http 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.
Security News
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.