No description
  • TypeScript 99.3%
  • JavaScript 0.7%
Find a file
@s.roertgen d216541d31
All checks were successful
Publish Dev Build / publish (push) Successful in 25s
fix bulk conversion pagination by using incrementing created_at timestamps
When converting multiple events via JSONL, all events previously received the
same created_at timestamp. This caused cursor-based relay pagination to skip
events. Each event now gets base_timestamp + index, ensuring unique values.
2026-02-05 09:37:32 +01:00
.forgejo/workflows test new publishing workflow 2026-01-30 12:38:31 +01:00
src fix bulk conversion pagination by using incrementing created_at timestamps 2026-02-05 09:37:32 +01:00
tests full amb compliance, improved cli pipeline piping 2026-01-30 06:59:22 +01:00
.gitignore update gitignore 2026-01-28 21:10:11 +01:00
CLAUDE.md fix bulk conversion pagination by using incrementing created_at timestamps 2026-02-05 09:37:32 +01:00
LICENSE Add license 2025-12-01 20:41:08 +01:00
package-lock.json change git repoq, remove r-tag 2026-01-26 12:39:52 +01:00
package.json full amb compliance, improved cli pipeline piping 2026-01-30 06:59:22 +01:00
README.md fix bulk conversion pagination by using incrementing created_at timestamps 2026-02-05 09:37:32 +01:00
tsconfig.base.json inital commit 2025-12-01 06:39:38 +01:00
tsconfig.json inital commit 2025-12-01 06:39:38 +01:00
tsconfig.types.json inital commit 2025-12-01 06:39:38 +01:00
vitest.config.ts inital commit 2025-12-01 06:39:38 +01:00

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 correct pubkey fields

Development

npm install
npm run build
npm test