
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.
JavaScript Finite State Machine Router
jFSMRouter (JavaScript Finite State Machine Router) is a JavaScript class that implements a Finite State Machine (FSM) integrated with a hash-based router for browsers. It allows centralized management of states, transitions, and routes.
The class uses the Singleton pattern: only one global instance exists, which you can access with:
import jFSMRouter from 'https://example.org/jFSMRouter.js';
const router = jFSMRouter();
States represent the logical steps of your application.
router.StateAdd('home'); // Adds the "home" state
true if the state is successfully created.router.StateDel('home'); // Removes the "home" state
function onEnter(prev, next) { console.log(`Entering ${next}`); }
function onLeave(curr, next) { console.log(`Leaving ${curr}`); }
router.StateOnEnterAdd('home', onEnter);
router.StateOnLeaveAdd('home', onLeave);
To remove hooks:
router.StateOnEnterDel('home', onEnter);
router.StateOnLeaveDel('home', onLeave);
Transitions define permissions and hooks between two states.
router.TransitionAdd('home', 'about');
router.TransitionDel('home', 'about');
false.function before() { return confirm('Go to the About page?'); }
async function after() { console.log('Transition completed'); }
router.TransitionOnBeforeAdd('home', 'about', before);
router.TransitionOnAfterAdd('home', 'about', after);
To remove hooks:
router.TransitionOnBeforeDel('home', 'about', before);
router.TransitionOnAfterDel('home', 'about', after);
Each route is associated with a valid state.
// path: '/user/:id[09]'
router.RouteAdd(
'home', // required state
'/user/:id[09]', // path with variables
(pathDef, actual, vars) => { console.log(vars.id); },
() => true, // optional availability function
(pathDef, actual, vars) => { console.warn('Access denied'); } // 403
);
:name[AZ09], :num[09], :str[AZ].router.RouteDel('/user/:id[09]');
router.RouteSpecialAdd(404, () => { /* page not found */ });
router.RouteSpecialAdd(403, () => { /* access denied */ });
router.RouteSpecialAdd(500, () => { /* internal error */ });
To force navigation:
router.Trigger('user/123'); // sets the hash and triggers routing
hashchange listener calls CheckHash().<!DOCTYPE html>
<html>
<head><title>jFSMRouter Demo</title></head>
<body>
<script type="module">
import jFMSRouter from 'https://example.org/jFSMRouter.js';
const router = jFSMRouter();
// Define states
router.StateAdd('home');
router.StateAdd('user');
// State hooks
router.StateOnEnterAdd('home', () => console.log('Entered Home'));
router.StateOnEnterAdd('user', (_, prev) => console.log(`User ${prev}→user`));
// Transitions
router.TransitionAdd('home', 'user');
// Routing
router.RouteSpecialAdd(404, () => document.body.innerHTML = '<h1>404 Not Found</h1>');
router.RouteAdd(
'home', '/home', () => alert('Welcome!')
);
router.RouteAdd(
'user', '/user/:id[09]', (pd, act, { id }) =>
document.body.innerHTML = `<h1>User ${id}</h1>`
);
// Initial startup (if hash already present)
router.CheckHash();
</script>
</body>
</html>
Notes:
Duplicate path id exception).FAQs
Hash router meet a finite state machine
We found that jfsmrouter 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
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.