{"library":"ssb-typescript","title":"Secure Scuttlebutt TypeScript Types","type":"library","description":"ssb-typescript provides comprehensive TypeScript type definitions for the Secure Scuttlebutt (SSB) protocol, enabling developers to build SSB applications with strong type safety. It defines core SSB concepts such as `FeedId`, `MsgId`, `BlobId`, and various message interfaces like `Msg`, `UnboxedMsg`, and `Content` (which is a union of specific content types like `PostContent`, `ContactContent`, `VoteContent`, `BlogContent`, and more). The current stable version is 2.8.0. As a type-only package, its release cadence is typically driven by changes in the underlying SSB protocol or common application patterns, rather than frequent functional updates. Its key differentiator is providing a standardized, community-maintained set of types for the decentralized SSB ecosystem, helping to ensure interoperability and reduce development errors when working with SSB data structures.","language":"javascript","status":"active","last_verified":"Wed Apr 22","install":{"commands":["npm install ssb-typescript"],"cli":null},"imports":["import { Msg } from 'ssb-typescript';","import { FeedId, MsgId, BlobId } from 'ssb-typescript';","import { Content, PostContent } from 'ssb-typescript';"],"auth":{"required":false,"env_vars":[]},"links":{"homepage":null,"github":"https://github.com/ssbc/ssb-typescript","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/ssb-typescript","openapi_spec":null,"status_page":null,"smithery":null},"quickstart":{"code":"import { Msg, PostContent, FeedId, MsgId, Content } from 'ssb-typescript';\n\n// Example FeedId, MsgId, BlobId (standard SSB identifiers)\nconst exampleFeedId: FeedId = '@HXjeG7t2p8zU9gT0t2p8zU9gT0t2p8zU9gT0t2p8zU9gT0.ed25519';\nconst exampleMsgId: MsgId = '%mS3G7t2p8zU9gT0t2p8zU9gT0t2p8zU9gT0t2p8zU9gT0.sha256';\nconst exampleRootMsgId: MsgId = '%mS3G7t2p8zU9gT0t2p8zU9gT0t2p8zU9gT0t2p8zU9gT0.sha256';\n\n// Define a PostContent message\nconst postContent: PostContent = {\n  type: 'post',\n  text: 'Hello, Secure Scuttlebutt! This is a test post from ssb-typescript.',\n  channel: 'testing',\n  mentions: [], // Empty array for no mentions\n  root: exampleRootMsgId,\n};\n\n// Define an SSB Message wrapper\nconst ssbMessage: Msg<PostContent> = {\n  key: exampleMsgId,\n  value: {\n    previous: '%prevMsgId.sha256',\n    author: exampleFeedId,\n    sequence: 123,\n    timestamp: 1678886400000, // UTC epoch milliseconds\n    hash: 'sha256',\n    content: postContent,\n    signature: 'fake-signature-string-here',\n  },\n  timestamp: 1678886400000,\n};\n\n// Demonstrate generic Content type usage\nconst genericContent: Content = {\n    type: 'contact',\n    contact: exampleFeedId,\n    following: true\n};\n\nconsole.log('Example SSB Post Message:', JSON.stringify(ssbMessage, null, 2));\nconsole.log('Example generic Content:', JSON.stringify(genericContent, null, 2));\n\n// To compile and run this example:\n// 1. Install dependencies: `npm install typescript ssb-typescript ts-node`\n// 2. Save the code as `example.ts`.\n// 3. Execute: `npx ts-node example.ts`","lang":"typescript","description":"This quickstart demonstrates how to define common SSB types like `FeedId`, `MsgId`, `PostContent`, and the full `Msg` interface using the provided type definitions.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}