{"id":49418,"library":"ssb-schema-definitions","title":"SSB Schema Definitions","description":"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.","status":"active","version":"3.2.1","language":"javascript","source_language":"en","source_url":"https://github.com/ssbc/ssb-schema-definitions","tags":["javascript","schema","definitions","ssb","json","validation"],"install":[{"cmd":"npm install ssb-schema-definitions","lang":"bash","label":"npm"},{"cmd":"yarn add ssb-schema-definitions","lang":"bash","label":"yarn"},{"cmd":"pnpm add ssb-schema-definitions","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency for JSON validation","package":"is-my-json-valid","optional":true}],"imports":[{"note":"Package is CJS-only; no ESM exports. Use require().","wrong":"import Definitions from 'ssb-schema-definitions'","symbol":"Definitions","correct":"const Definitions = require('ssb-schema-definitions')"},{"note":"Definitions is a function that returns the definitions object. Must be called to get definitions.","wrong":"","symbol":"Definitions()","correct":"const schemaDefs = Definitions()"},{"note":"Reference definitions using JSON Schema $ref syntax after attaching Definitions() to schema definitions property.","wrong":"","symbol":"Schema definitions (via $ref)","correct":"{ $ref: '#/definitions/image' }"}],"quickstart":{"code":"const Definitions = require('ssb-schema-definitions')\nconst Validator = require('is-my-json-valid')\n\nconst schema = {\n  $schema: 'http://json-schema.org/schema#',\n  type: 'object',\n  required: ['type', 'tangles'],\n  properties: {\n    type: { type: 'string', pattern: '^profile/.*$' },\n    preferredName: { type: 'string' },\n    avatarImage: { $ref: '#/definitions/image' },\n    tangles: {\n      group: { $ref: '#/definitions/tangle/any' },\n      profile: { $ref: '#/definitions/tangle/root' }\n    },\n    recps: { $ref: '#/definitions/recipients/box2' }\n  },\n  additionalProperties: false,\n  definitions: Definitions()\n}\n\nconst isValid = Validator(schema)\nconst msg = { type: 'profile/update', tangles: { group: { root: null, previous: null }, profile: { root: null, previous: null } } }\nconsole.log(isValid(msg)) // true\nconsole.log(isValid.errors) // null","lang":"javascript","description":"Shows how to require the package, attach definitions to a schema, and validate an SSB message."},"warnings":[{"fix":"Attach the result to schema.definitions as shown in the quickstart.","message":"Definitions() now returns an object that must be attached to the schema's definitions property; previous versions may have exported differently.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Use 'recipients/box2' for new schemas; avoid 'recipients/box1' if possible.","message":"The 'recps' definition may change in future releases to support box2 only; box1 is deprecated.","severity":"deprecated","affected_versions":">=3.2.0"},{"fix":"Use require() instead of import.","message":"The package is CommonJS only; attempting ES imports will fail.","severity":"gotcha","affected_versions":"all"},{"fix":"Clone or deep copy if modifications are needed per schema.","message":"Modifying the returned definitions object directly can affect other schemas using the same definitions.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"search_vec":"'3.2.1':22 'across':55 'as-need':31 'cadenc':34 'central':37 'communiti':39 'community-maintain':38 'definit':3,8,61 'differenti':36 'duplic':52 'ecosystem':57 'error':54 'field':44 'imag':46 'is-my-json-valid':16 'javascript':59 'json':6,19,63 'key':35 'latest':25 'like':45 'maintain':40 'mention':47 'messag':14 'need':33 'object':42 'packag':58 'provid':4 'recipi':50 'reduc':51 'releas':27,28 'schema':2,7,41,60 'scuttlebutt':13 'secur':12 'ssb':1,11,56,62 'stabl':26 'standard':5 'tangl':48 'use':15 'valid':10,20,64 'version':21","created_at":"2026-06-07T17:01:41.004321+00:00","updated_at":"2026-06-07T17:01:41.004321+00:00","problems":[{"fix":"Call Definitions() to get the definitions object.","cause":"Definitions is a factory function that must be called to get the definitions object.","error":"require('ssb-schema-definitions') returns a function, not an object"},{"fix":"npm install is-my-json-valid","cause":"Missing peer dependency is-my-json-valid.","error":"Cannot find module 'is-my-json-valid'"},{"fix":"Use Definitions() without new.","cause":"Trying to use 'new Definitions()' but it's not a class.","error":"TypeError: Definitions is not a constructor"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/ssbc/ssb-schema-definitions#readme","github":"https://github.com/ssbc/ssb-schema-definitions","docs":null,"changelog":null,"pypi":null,"npm":"ssb-schema-definitions","openapi_spec":null,"status_page":null,"smithery":null,"categories":["storage"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}