
Security News
/Research
Wallet-Draining npm Package Impersonates Nodemailer to Hijack Crypto Transactions
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
@resourge/history-store
Advanced tools
`@resourge/history-store` is a lightweight JavaScript utility for managing and subscribing to navigation events using the browser's History API. It simplifies tracking URL changes and enables seamless state management for single-page applications (SPAs).
@resourge/history-store
is a lightweight JavaScript utility for managing and subscribing to navigation events using the browser's History API. It simplifies tracking URL changes and enables seamless state management for single-page applications (SPAs).
Unified Navigation State Management
: Consistent API for both web and React Native environments.Subscription-Based Updates
: Subscribe to URL changes and respond in real-time.Custom Navigation Actions
: Specify custom navigation actions or replace the current history state.Install using Yarn:
yarn add @resourge/history-store
or NPM:
npm install @resourge/history-store --save
yarn add @resourge/history-store react-native-url-polyfill
or NPM:
npm install @resourge/history-store react-native-url-polyfill --save
To start using @resourge/history-store
, simply import and interact with the HistoryStore
instance:
// Browser
import { HistoryStore } from '@resourge/history-store';
// react-native
// import { HistoryStore } from '@resourge/history-store/mobile';
// Subscribe to URL changes
const unsubscribe = HistoryStore.subscribe(() => {
const [currentUrl, action, previous] = HistoryStore.getValue();
console.log('Current URL:', currentUrl.href);
console.log('Action:', action);
if (previous) {
console.log('Previous URL:', previous[0].href);
}
});
// Navigate to a new URL
HistoryStore.navigate(new URL('/new-page', window.location.href));
// Unsubscribe when done
unsubscribe();
subscribe(notification: () => void): () => void
Adds a callback function that will be triggered on URL change. Returns an unsubscribe function to remove the subscription.
const unsubscribe = HistoryStore.subscribe(() => {
console.log('URL changed!');
});
getValue(): StoreValue
Returns the current navigation state, which is a tuple containing:
url
: The current URL
.action
: The type of action that triggered the change.previousValue
: (Optional) A tuple containing the previous URL
and action.const [url, action, previous] = HistoryStore.getValue();
navigate(url: URL, options?: NavigateOptions): void
Navigates to a specified URL
. The optional NavigateOptions
can be used to define the navigation action or whether to replace the current history state.
Web:
url
: The current URL
.options.action
: The navigation action type (e.g., push
, replace
).options.replace
: If true
, replaces the current navigation state instead of pushing a new one.react-native:
url
: The current URL
.options.action
: The navigation action type (e.g., push
, replace
).options.replace
: If true
, replaces the current navigation state instead of pushing a new one.config.stack
: If true
, clears all navigation entries after the current URL before adding a new entry.HistoryStore.navigate(new URL('/new-page', window.location.href), { replace: true });
createNewUrlWithSearch(url: URL, newSearch: string, hash?: boolean): URL
Creates a new URL instance with an updated search string. Optionally updates the hash if specified.
url
: The original URL
.newSearch
: The new search string to be set.hash
: If true
, updates the URL hash with the new search string.import { createNewUrlWithSearch } from '@resourge/history-store/utils';
const newUrl = createNewUrlWithSearch(new URL('/path', window.location.origin), 'foo=bar', true);
parseParams<T extends Record<string, any>>(paramValues: T): string
Converts parameters into a search string.
paramValues
: An object representing the parameters.import { parseParams } from '@resourge/history-store/utils';
const searchString = parseParams({ foo: 'bar', nested: { key: 'value' } });
parseSearchParams<T extends Record<string, any>>(searchParams: URLSearchParams, defaultParams?: T): T
Converts search parameters into an object with primitive values.
searchParams
: An instance of URLSearchParams
.defaultParams
: Optional default parameters to merge with the parsed result.import { parseSearchParams } from '@resourge/history-store/utils';
const params = parseSearchParams(new URLSearchParams('foo=bar&nested[key]=value'));
parseSearch<T extends Record<string, any>>(search: string, defaultParams?: T): T
Converts a search string into an object with primitive values.
search
: The search string (e.g., ?foo=bar&nested[key]=value
).defaultParams
: Optional default parameters to merge with the parsed result.import { parseSearch } from '@resourge/history-store/utils';
const params = parseSearch('?foo=bar&nested[key]=value');
MIT Licensed.
FAQs
`@resourge/history-store` is a lightweight JavaScript utility for managing and subscribing to navigation events using the browser's History API. It simplifies tracking URL changes and enables seamless state management for single-page applications (SPAs).
The npm package @resourge/history-store receives a total of 41 weekly downloads. As such, @resourge/history-store popularity was classified as not popular.
We found that @resourge/history-store demonstrated a healthy version release cadence and project activity because the last version was released less than 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
/Research
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
Security News
/Research
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.