Implement end-to-end encrypted buyer/seller messaging
Wire format (internal/message): sealed boxes to the listing's device key (X25519 + HKDF + ChaCha20-Poly1305), padded, proof-of-work stamped, with signed owner replies and address grants. Relay validation, bounded queues, gossip on per-region message topics and sync (store, p2p). Owner side (internal/inbox, API): inbox with hidden link messages and a per-day new-thread limit, replies, grants, and a private per-listing address. Public POST/GET /api/v1/messages for buyers. Browser: noble-based sealing and reply verification checked against a Go fixture, contact form, conversation view, message list, de/en strings. Docs: PROTOCOL.md messaging section matches the implementation. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
+7
-7
@@ -11,10 +11,10 @@ import { sha256 } from "@noble/hashes/sha2.js";
|
||||
import { canonicalize } from "./jcs.ts";
|
||||
|
||||
const LISTING_CONTEXT = "allmende-listing-v1\n";
|
||||
const CERT_CONTEXT = "allmende-cert-v1\n";
|
||||
export const CERT_CONTEXT = "allmende-cert-v1\n";
|
||||
|
||||
const DAY = 86_400;
|
||||
const MAX_CERT_LIFETIME = 366 * DAY;
|
||||
export const MAX_CERT_LIFETIME = 366 * DAY;
|
||||
const MAX_LISTING_LIFETIME = 30 * DAY;
|
||||
const MAX_CLOCK_SKEW = 10 * 60;
|
||||
|
||||
@@ -87,7 +87,7 @@ export interface Options {
|
||||
|
||||
const enc = new TextEncoder();
|
||||
|
||||
function hexBytes(s: unknown, bytes: number): Uint8Array | null {
|
||||
export function hexBytes(s: unknown, bytes: number): Uint8Array | null {
|
||||
if (typeof s !== "string" || s.length !== bytes * 2 || !/^[0-9a-f]+$/.test(s)) {
|
||||
return null;
|
||||
}
|
||||
@@ -108,21 +108,21 @@ export function leadingZeroBits(bytes: Uint8Array): number {
|
||||
return n;
|
||||
}
|
||||
|
||||
function without(o: object, key: string): Record<string, unknown> {
|
||||
export function without(o: object, key: string): Record<string, unknown> {
|
||||
const copy = { ...(o as Record<string, unknown>) };
|
||||
delete copy[key];
|
||||
return copy;
|
||||
}
|
||||
|
||||
function isObject(v: unknown): v is Record<string, unknown> {
|
||||
export function isObject(v: unknown): v is Record<string, unknown> {
|
||||
return typeof v === "object" && v !== null && !Array.isArray(v);
|
||||
}
|
||||
|
||||
function safeInt(v: unknown): v is number {
|
||||
export function safeInt(v: unknown): v is number {
|
||||
return typeof v === "number" && Number.isSafeInteger(v);
|
||||
}
|
||||
|
||||
function signedBy(
|
||||
export function signedBy(
|
||||
context: string,
|
||||
signed: unknown,
|
||||
sigHex: unknown,
|
||||
|
||||
Reference in New Issue
Block a user