Registry / storage / ssb-schema-definitions

ssb-schema-definitions

JSON →
library3.2.1jsnpmunverified

Provides standardized JSON Schema definitions for validating SSB (Secure Scuttlebutt) messages using is-my-json-valid. Version 3.2.1 is the latest stable release. Released on an as-needed cadence. Key differentiator: centralized, community-maintained schema objects for fields like image, mentions, tangles, and recipients, reducing duplication and errors across SSB ecosystem packages.

npm install ssb-schema-definitions
INSTALL
IMPORT
SIG · SSB-SCHEMA-DEFINIT
S
ssb-schema-definitions
storagejavascriptv3.2.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Definitions
const Definitions = require('ssb-schema-definitions')
import Definitions from 'ssb-schema-definitions'
Package is CJS-only; no ESM exports. Use require().
Definitions()
const schemaDefs = Definitions()
Definitions is a function that returns the definitions object. Must be called to get definitions.
Schema definitions (via $ref)
{ $ref: '#/definitions/image' }
Reference definitions using JSON Schema $ref syntax after attaching Definitions() to schema definitions property.

Shows how to require the package, attach definitions to a schema, and validate an SSB message.

const Definitions = require('ssb-schema-definitions') const Validator = require('is-my-json-valid') const schema = { $schema: 'http://json-schema.org/schema#', type: 'object', required: ['type', 'tangles'], properties: { type: { type: 'string', pattern: '^profile/.*$' }, preferredName: { type: 'string' }, avatarImage: { $ref: '#/definitions/image' }, tangles: { group: { $ref: '#/definitions/tangle/any' }, profile: { $ref: '#/definitions/tangle/root' } }, recps: { $ref: '#/definitions/recipients/box2' } }, additionalProperties: false, definitions: Definitions() } const isValid = Validator(schema) const msg = { type: 'profile/update', tangles: { group: { root: null, previous: null }, profile: { root: null, previous: null } } } console.log(isValid(msg)) // true console.log(isValid.errors) // null
Debug
Known issues
breakingDefinitions() now returns an object that must be attached to the schema's definitions property; previous versions may have exported differently.
fix
Attach the result to schema.definitions as shown in the quickstart.
affects: >=3.0.0
deprecatedThe 'recps' definition may change in future releases to support box2 only; box1 is deprecated.
fix
Use 'recipients/box2' for new schemas; avoid 'recipients/box1' if possible.
affects: >=3.2.0
gotchaThe package is CommonJS only; attempting ES imports will fail.
fix
Use require() instead of import.
affects: all
gotchaModifying the returned definitions object directly can affect other schemas using the same definitions.
fix
Clone or deep copy if modifications are needed per schema.
affects: all
Errors
Common errors & fixes
require('ssb-schema-definitions') returns a function, not an object
Definitions is a factory function that must be called to get the definitions object.
fix
Call Definitions() to get the definitions object.
Cannot find module 'is-my-json-valid'
Missing peer dependency is-my-json-valid.
fix
npm install is-my-json-valid
TypeError: Definitions is not a constructor
Trying to use 'new Definitions()' but it's not a class.
fix
Use Definitions() without new.
Upgrade
Version history
3.2.1latest on npm
Audit
Dependencies
is-my-json-validoptionalpeer dependency for JSON validation
Agent activity
24 hits · last 30 days
node
20
OpenAI (training)
1
Resources
ssb-schema-definitions — npm install ssb-schema-definitions · libregistry