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.
@mini-apps/navigation
Advanced tools
A package to organize navigation in Mini Apps applications
yarn add @mini-apps/navigation
or
npm i @mini-apps/navigation
This package was created with aim on mobile applications. So, the main terms
which are used in this library are view
, modal
, popup
etc. You
should not wait for any Web based terms used in context of Navigator
. Here,
I tried to recreate a logic used in native mobile applications and waiting
for other developers contribution.
State
is like the one of the most often met terms in this project. It
is described with view
, modal
, popup
, params
and modifiers
.
Properties modal
and popup
are not required, but view
is. Normally,
there cannot be any situation when view is unknown, we should always show
something, so that is the reason why view
is required. params
is passed
custom dictionary.
Modifier
is a modification applied to state. It can be any string and can
be used for any purposes.
BrowserNavigator
is adopted for browser and works with window.history
. It
extends some Navigator
methods like on
, off
and go
with some extra
lines of code, which are written mostly to interact with browser's history.
It rewires such functions as window.history.pushState
and
window.history.replaceState
, so then, each history item has stable state,
which contains current location index and location history.
import {BrowserNavigator} from '@mini-apps/navigation';
const navigator = new BrowserNavigator();
When window.history
becomes available, it is required to call navigator
init, to make him override window.history.pushState
and
window.history.replaceState
and add event listener to window's popstate event.
navigator.init();
To cancel overrides and remove event listener:
navigator.unmount();
To make navigator initialization easier, there is a function
extractBrowserNavigatorSettings
which returns initial settings for navigator
if it is possible.
import {extractBrowserNavigatorSettings} from '@mini-apps/navigation';
// Extract settings from browsers history
const navigatorSettings = extractBrowserNavigatorSettings();
// Initialize with received settings
navigator.init(navigatorSettings ? navigatorSettings : undefined);
If first parameter in init
was not passed, navigator watches if current
history length is equal to 1, it understands that previously, it
was not mounted here before. It replaces current location with
modifier root
which indicates about root location.
When mount()
is called, navigator adds its own listener, which watches
for location changes and automatically updates internal location. The logic
is rather simple - it tries to extract location info from history item
state and correctly updates navigator. But in case of fail, it will recognize
pushed location as new one. So, it will try to parse it and push to navigator.
Otherwise, an error will be thrown.
FAQs
Navigation library for VK Mini Apps
The npm package @mini-apps/navigation receives a total of 4 weekly downloads. As such, @mini-apps/navigation popularity was classified as not popular.
We found that @mini-apps/navigation 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.