Product
Socket Now Supports uv.lock Files
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
@gasket/core
Advanced tools
npm install @gasket/core
Add a gasket.js
file to the root of your project.
This can be a .js
extension if your package.json has the type
field set to module
.
It is also possible to use with a .ts
extension if you have TypeScript configured.
// gasket.js
import { makeGasket } from '@gasket/core';
import LoggerPlugin from '@gasket/plugin-logger';
import MyPlugin from './my-plugin';
export default makeGasket({
plugins: [
LoggerPlugin,
MyPlugin
]
});
You can now import the Gasket instance from your gasket.js
file into your
application code.
With a Gasket, you can fire actions that will trigger lifecycles hooked
by plugins which encapsulate functionality allowing reuse across many applications.
A plugin is a module that exports a name
and hooks
object
(See Plugins Guide).
In your gasket.js
file, you can import plugins and add them to the plugins
array of the Gasket configuration.
When a new Gasket is created, there are three lifecycles executed in the following order:
The init
lifecycle allows the earliest entry to setting up a Gasket instance.
It can be used for setting up an initial state.
// gasket-plugin-example.js
const name = 'gasket-plugin-example';
let _initializedTime;
const hooks = {
init(gasket) {
_initializedTime = Date.now();
}
};
export default { name, hooks };
While it is possible to attach properties to the gasket
instance, it is not
recommended.
If a plugin needs to make properties available to other plugins, it should
register an action that can be executed to retrieve the value.
// gasket-plugin-example.js
const name = 'gasket-plugin-example';
let _initializedTime;
const hooks = {
init(gasket) {
- gasket.initializedTime = Date.now();
+ _initializedTime = Date.now();
},
+ actions() {
+ return {
+ getInitializedTime() {
+ return _initializedTime;
+ }
+ }
+ },
configure(gasket) {
- const time = gasket.initializedTime;
+ const time = gasket.actions.getInitializedTime();
}
};
export default { name, hooks };
The actions
lifecycle is the second lifecycle executed when a Gasket is created.
This will let plugins register actions that can be fired by the application code
where the Gasket is imported, or in other plugins.
// gasket-plugin-example.js
const name = 'gasket-plugin-example';
const hooks = {
actions(gasket) {
return {
async getDoodads() {
if(gasket.config.example) {
const dodaads = await gasket.exec('dodaads');
return dodaads.flat()
}
}
}
}
};
export default { name, hooks };
The configure
lifecycle is the first lifecycle executed when a Gasket is
instantiated.
This allows any registered plugins to adjust the configuration before further
lifecycles are executed.
// gasket-plugin-example.js
const name = 'gasket-plugin-example';
const hooks = {
configure(gasket, gasketConfig) {
// Modify the configuration
return {
...gasketConfig,
example: true
};
}
};
export default { name, hooks };
In this example, we register an action getDoodads
that will only execute if the
example
configuration is set to true
.
It will then execute the doodads
lifecycle, allowing any registered plugin to
provide doodads.
FAQs
Entry point to setting up Gasket instances
We found that @gasket/core demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers 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.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
Research
Security News
Socket researchers have discovered multiple malicious npm packages targeting Solana private keys, abusing Gmail to exfiltrate the data and drain Solana wallets.
Security News
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.