opendating-protocol
v0.1.0
Published
OpenDating protocol — types, constants, validators, crypto helpers. Zero Cloudflare/Worker/D1 dependencies.
Maintainers
Readme
opendating-protocol
OpenDating protocol — types, constants, validators, crypto helpers.
Zero Cloudflare/Worker/D1/Durable Object dependencies.
Install
npm install opendating-protocolUsage
import {
OPENDATING_PROTOCOL,
OPENDATING_VERSION,
createEnvelope,
buildGiftWrap,
generateKeypair,
nip44Encrypt,
nip44Decrypt,
OD_ERROR_CODES,
} from 'opendating-protocol';
// Generate a user keypair
const user = generateKeypair();
// Build a system.ping request
const envelope = createEnvelope('system.ping', crypto.randomUUID(), {});
// Wrap it for a service
const { giftWrap } = await buildGiftWrap(
78,
JSON.stringify(envelope),
user.privateKey,
user.publicKey,
servicePubkey,
);
// Publish to relay
ws.send(JSON.stringify(['EVENT', giftWrap]));Crypto submodule
import {
getConversationKey,
nip44Encrypt,
nip44Decrypt,
signEvent,
} from 'opendating-protocol/crypto';Contents
constants.ts— Protocol ID, version, service roles, featuresversion.ts— Version compatibility + negotiationenvelope.ts— Envelope construction, validation, freshnessmessage-types.ts— Message type registry with payload validatorserrors.ts— Standard error codes + messagescapabilities.ts— Capability reporting + NIP-11 advertisementvalidation.ts— Runtime request validationcrypto/encryption.ts— NIP-44 v2 (ChaCha20 + HMAC-SHA256, verified against official vectors)crypto/gift-wrap.ts— NIP-59 gift wrap construction (unsigned rumors, randomized timestamps)crypto/service-signer.ts— Keypair management + validation
NOT included
- Cloudflare Workers / D1 / Durable Objects / R2
- Relay implementation
- Backend service logic
- Moderation infrastructure
- Server secrets
License
MIT
