Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Flexible JavaScript URL router.
A Taskworld, our frontend is very complex. Many parts can be affected by the URL independently.
The URLs in the app has gone through several iterations and efforts need to be made to ensure backwards compatibility.
ave is created to handle all our routing needs.
This library is based on url-mapper
and uniloc
project.
import { createRouteMapper } from 'ave'
Give it an dictionary of Route Definition Objects, and it will create a Route Mapper.
routes
An Object whose keys are route name and values are Route Definition Objects, each contains these keys:
route
(required) A String representing the route. They can have placeholders. e.g.: /project/:projectAltId
aliases
An Array of String that contains the possible aliases for this route.redirect
A Function which will redirect this route to another route during route resolution.format
A Function which will redirect this route to another route during URL generation.
To protect against bugs, the resulting route must redirect back to this route.Redirect and format is an advanced feature, which will be discussed later. Here’s an example router.
const simpleRouter = createRouteMapper([
home: { route: '/' },
about: { route: '/about' },
post: { route: '/posts/:postId', aliases: [ '/forum/post/:postId' ] },
])
Resolves the path
String into a Route Object.
path
A String representing the path to resolve.name
A String representing the route’s name.options
An Object containing the options from placeholders or query.null
if desired route is not found.simpleRouter.resolve('/')
// =>
simpleRouter.resolve('/posts/123')
// =>
simpleRouter.resolve('/forum/post/123?page=2')
// =>
simpleRouter.resolve('/oops')
// =>
Generates a path String based on the given Route Object. This is the reverse of resolve
.
routeObject
A Route Object as described above.options
did not contain all the required placeholders defined in the route definition.simpleRouter.generate({ name: 'home', options: { } })
// =>
simpleRouter.generate({ name: 'home', options: { page: '2' } })
// =>
simpleRouter.generate({ name: 'post', options: { postId: '123' } })
// =>
Returns the Route Definition Object for a route named by the String name
.
simpleRouter.getRouteDefinitionByName('post')
// =>
As mentioned above, you can store extra keys in Route Definition Objects.
At Taskworld we add render(options)
function to each Route Definition Object,
and have the React component call it. e.g.
const appRouter = createRouteMapper([
projects: {
route: '/',
aliases: [ '/projects' ],
render: ({ }) => <ProjectListPage />
},
project: {
route: '/project/:projectId',
render ({ projectId }) => <ProjectPage projectId={projectId} />
}
])
const Application = ({ path }) => {
const route = appRouter.resolve(path)
const content = (route
? simpleRouter.getRouteDefinitionByName(route.name).render(route.options)
: <NotFound />
)
return <AppLayout route={route}>{content}</AppLayout>
}
To be written
To be written
FAQs
Flexible JavaScript URL router.
The npm package ave receives a total of 14 weekly downloads. As such, ave popularity was classified as not popular.
We found that ave 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
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.