npm.io
1.0.1 • Published 3h ago

@appport/protocol

Licence
Apache-2.0
Version
1.0.1
Deps
0
Size
142 kB
Vulns
0
Weekly
0

@appport/protocol

The AppPort wire contract: envelope types, error codes, naming rules, manifest shapes, structural validation and compatibility analysis.

This package is pure. It has no runtime dependencies and knows nothing about transports, servers or clients — which is what makes it safe to depend on from a browser bundle, an Electron preload script or a CLI.

import { createRequest, parseClientEnvelope, PROTOCOL_ID } from "@appport/protocol";

const request = createRequest({
  requestId: "req_01J...",
  capability: { name: "documents.save", version: 1 },
  input: { documentId: "doc_1", content: "hello" }
});

parseClientEnvelope(request); // throws AppPortError on a malformed envelope

What is here

Module Contents
version appport/1, conformance levels
envelopes request, response, event, subscribe, stream envelopes and guards
validate protocol-level structural validation, decode and encode
errors the standard error codes and AppPortError
names capability, event, permission and application-id grammar
ids ULID-based identifier helpers
manifest manifest, discovery and transport descriptor types
jsonschema the JSON Schema subset published in manifests
session Principal and Session
operations long-running operation records
blob binary references
compatibility breaking vs non-breaking manifest diffing

Names are checked, not merely typed: electron.documents.save and ipc.saveDocument are rejected, because a capability name that encodes a transport breaks the protocol's central invariant.