Security News
pnpm 10.0.0 Blocks Lifecycle Scripts by Default
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
@mozilla/nimbus-shared
Advanced tools
This is a place to define data and schemas used across Project Nimbus.
This is a place to define data and schemas used across Project Nimbus.
Any data that moves between systems should have Typescript types defined here, which will be automatically converted to JSON Schema. Any data that needs to be re-used by multiple systems should be stored here to be shared.
Install this package
$ npm install --save @mozilla/nimbus-shared
Import it.
import nimbus from "@mozilla/nimbus-shared";
JSON Schemas can be accessed in nimbus.schemas
:
import { schemas } from "@mozilla.nimbus-shared";
schemas.normandy.ConsoleLogArguments;
// {"$schema": "http://json-schema.org/draft-07/schema#", ...}
Helper functions to validate objects against those schemas can be found in nimbus.typeGuards
.
import { typeGuards } from "@mozilla/nimbus-shared";
typeGuards.normandy_checkConsoleLogArguments({});
/*
* {
* ok: false,
* errors: [
* {
* keyword: 'required',
* dataPath: '',
* schemaPath: '#/definitions/ConsoleLogArguments/required',
* params: [Object],
* message: "should have required property 'message'"
* }
* ]
* }
*/
typeGuards.normandy_checkConsoleLogArguments({ message: "It works!" });
/*
* {
* ok: true,
* errors: null
* }
*/
As well as everything available from JS, the original types the schemas are generated from are
available in the types
export of the library. Additionally, well-typed guards and assertions are
available in typeGuards
.
import { types, typeGuards } from "@mozilla/nimbus-shared";
let incomingJson: object = { message: "json from the server" };
// incoming JSON is a generic object with no type information
if (typeGuards.normandy_isConsoleLogArguments(incomingJson)) {
// incomingJson has been narrowed to `types.normandy.ConsoleLogArguments
} else {
// Something is wrong, and the types don't match what we expected.
}
const message: types.messaging.SimpleCFRMessage = { id: "incomplete-message" };
// Error: missing the following properties from type 'SimpleCFRMessage': template, trigger, content
const userInput = { arbitrary: "json" };
typeGuards.normandy_assertAddonRollbackArguments(userInput);
// userInput has now been asserted to be of type `normandy.AddonRollbackArguments`.
// If it wasn't the previous line would have thrown an error.
Basic native support is available via the PyPI package mozilla-nimbus-shared
. The only function is
exposed is one to validate an object against a named schema.
from mozilla_nimbus_shared import check_schema
# Throws an error with details of the problems
check_schema("normandy/ConsoleLogArguments", {})
# Returns True
check_schema("normandy/ConsoleLogArguments", {"message": "hello, world!"})
For other applications, consider using the NPM package and loading the schemas directly from the
filesystem. After installing this package via npm
, the schemas will be available at
node_modules/@mozilla/nimbus-shared/schemas/<group>/<type>.json
. Please leave an issue on this
repository if you have a use case not covered by the above.
Node 14 is required to work on this repository, though will not be required for the eventual bundled outputs prepared for other systems.
Common tasks are defined as Make targets:
make install # Install dependencies with NPM
make lint # Run static analysis
make build # Build output files
make test # Test
Dependencies are managed with npm. Use npm install --save
and npm install --save-dev
to add new
dependencies.
TBD
FAQs
This is a place to define data and schemas used across Project Nimbus.
The npm package @mozilla/nimbus-shared receives a total of 15 weekly downloads. As such, @mozilla/nimbus-shared popularity was classified as not popular.
We found that @mozilla/nimbus-shared demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 16 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.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
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.