amb-nostr-converter (0.0.0-d216541)
Installation
registry=npm install amb-nostr-converter@0.0.0-d216541"amb-nostr-converter": "0.0.0-d216541"About this package
AMB-Nostr Converter
A TypeScript library for converting between AMB ("Allgemeines Metadatenprofil für Bildungsressourcen" - General Metadata Profile for Learning Resources) and Nostr educational events (kind:30142).
Overview
Bidirectional conversion between:
- AMB: JSON-LD based metadata format for educational resources (used by European OER initiatives)
- Nostr: Decentralized protocol for social media and content distribution
Usable as a library or CLI tool.
Installation
npm install amb-nostr-converter --registry=https://git.edufeed.org/api/packages/edufeed/npm/
For the latest development build (published on every push to main):
npm install amb-nostr-converter@dev --registry=https://git.edufeed.org/api/packages/edufeed/npm/
Quick Start
As a Library
import { ambToNostr, nostrToAmb, AmbLearningResource } from 'amb-nostr-converter';
const resource: AmbLearningResource = {
"@context": ["https://w3id.org/kim/amb/context.jsonld"],
"id": "https://example.org/course123",
"type": ["LearningResource", "Course"],
"name": "Introduction to TypeScript",
"creator": [{ "type": "Person", "name": "Jane Smith" }],
"description": "Learn TypeScript fundamentals",
"keywords": ["TypeScript", "Programming"],
"license": { "id": "https://creativecommons.org/licenses/by-sa/4.0/" }
};
// Convert to Nostr event
const result = ambToNostr(resource, { pubkey: 'your-nostr-public-key-hex' });
if (result.success) {
console.log('Nostr Event:', result.data);
// Convert back to AMB
const ambResult = nostrToAmb(result.data!);
}
As a CLI Tool
# AMB → Nostr
amb-convert amb:nostr course.json -o event.json
# Nostr → AMB
amb-convert nostr:amb event.json -o recovered.json
# Pretty-print and pipe
amb-convert amb:nostr course.json -p | jq .tags
# Sign events with private key
amb-convert amb:nostr course.json --nsec nsec1...
# Batch convert JSONL
amb-convert amb:nostr resources.jsonl --nsec $NOSTR_NSEC -o events.jsonl
CLI Reference
| Option | Description | Direction |
|---|---|---|
<direction> |
amb:nostr or nostr:amb |
Required |
[input] |
Input file path (omit for stdin) | Both |
-o, --output <file> |
Output file path (omit for stdout) | Both |
-p, --pretty |
Pretty-print JSON | Both |
--tags |
Output only tags array | AMB→Nostr |
--nsec <key> |
Sign with private key (nsec or hex) | AMB→Nostr |
--private-key <key> |
Sign with private key (hex or nsec) | AMB→Nostr |
Batch Processing (JSONL)
JSONL input (one JSON object per line) is auto-detected. Errors on individual lines are reported with line numbers and don't stop processing of remaining lines.
cat resources.jsonl | amb-convert amb:nostr --nsec $NOSTR_NSEC -o events.jsonl
When converting multiple events, each event gets an incrementing created_at timestamp (base time + 1 second per event). This ensures relay clients that use cursor-based pagination on created_at can load all events correctly.
Event Signing
When --nsec or --private-key is provided (both accept nsec1 or hex format):
- Public key is automatically derived
- Event ID and Schnorr signature are generated
- Output includes
id,sig, and correctpubkeyfields
Development
npm install
npm run build
npm test
Related Projects
- AMB Sitemap Parser - Parse sitemaps and extract AMB educational metadata from web pages
- AMB Specification - General Metadata Profile for Learning Resources
- AMB-NIP (kind 30142) - Nostr event spec for AMB
- Nostr Protocol - Notes and Other Stuff Transmitted by Relays
Dependencies
Dependencies
| ID | Version |
|---|---|
| chalk | ^5.6.2 |
| commander | ^14.0.2 |
| jsonld | ^8.3.3 |
| nostr-tools | ^1.17.0 |
| uuid | ^9.0.1 |
| zod | ^3.25.76 |
Development dependencies
| ID | Version |
|---|---|
| @types/node | ^18.19.130 |
| @types/uuid | ^9.0.8 |
| @vitest/coverage-v8 | ^2.1.8 |
| @vitest/ui | ^2.1.8 |
| eslint | ^8.57.1 |
| husky | ^8.0.3 |
| prettier | ^3.6.2 |
| typedoc | ^0.26.0 |
| typescript | ^5.6.0 |
| vitest | ^2.1.8 |