Skip to main content

Crate ma_core

Crate ma_core 

Source
Expand description

§ma-core

A lean DIDComm service library for the ma ecosystem.

ma-core provides the building blocks for ma-capable endpoints:

  • DID documents — create, validate, resolve, and publish did:ma: documents to IPFS/IPNS (via Kubo on native targets). Use MaExtension to build the ma: extension field, and config::SecretBundle::build_document (config feature) as the single entry point for a complete, signed document.
  • Service inboxes — bounded, TTL-aware FIFO queues (Inbox) for receiving validated messages on named protocol services.
  • Outbound sending — fire-and-forget delivery of validated Message objects to remote endpoints, serialized to CBOR on the wire.
  • Endpoint abstraction — the MaEndpoint trait with pluggable transport backends.
  • Transport parsing — extract endpoint IDs and protocols from DID document service strings (/iroh/<id>/<protocol>).
  • Identity bootstrap — secure secret key generation and persistence.

§Services

Every endpoint should provide /ma/inbox/0.0.1 (the default inbox) when it wants to receive direct messages. Endpoints may optionally provide /ma/ipfs/0.0.1 to publish DID documents on behalf of others.

§Feature flags

§Platform support

Core types (Inbox, Service, transport parsing, validation) compile on all targets including wasm32-unknown-unknown.

§wasm vs native

  • ma-core supports both wasm and native targets.
  • All IPFS work (publish, pin, DID/IPNS resolution, content reads) is native only, through the Kubo RPC client (not(wasm32) + kubo feature).
  • wasm builds carry no IPFS backend: the DidDocumentResolver / IpnsPathResolver traits are the contract, and a wasm client supplies its own implementation (verified-fetch) or reaches Kubo through ma-runtime.
  • config serialization and SecretBundle crypto work on wasm.
  • config filesystem paths, CLI/env merging, and file I/O are native-only.

Re-exports§

pub use did::Did;
pub use did::DID_PREFIX;
pub use doc::now_iso_utc;
pub use doc::Document;
pub use doc::MaExtension;
pub use doc::Proof;
pub use doc::VerificationMethod;
pub use doc::DEFAULT_DID_CONTEXT;
pub use doc::DEFAULT_PROOF_PURPOSE;
pub use doc::DEFAULT_PROOF_TYPE;
pub use error::Error;
pub use error::MaError;
pub use error::Result;
pub use identity::generate_identity;
pub use identity::generate_identity_from_secret;
pub use identity::ipns_from_secret;
pub use identity::GeneratedIdentity;
pub use key::EncryptionKey;
pub use key::SigningKey;
pub use key::ASSERTION_METHOD_KEY_TYPE;
pub use key::CODEC_ED25519_PUB;
pub use key::CODEC_EDDSA_SIG;
pub use key::CODEC_X25519_PUB;
pub use key::KEY_AGREEMENT_KEY_TYPE;
pub use msg::decode_content;
pub use msg::encode_content;
pub use msg::Envelope;
pub use msg::Headers;
pub use msg::Message;
pub use msg::ReplayGuard;
pub use msg::DEFAULT_MAX_CLOCK_SKEW_SECS;
pub use msg::DEFAULT_MESSAGE_TTL_SECS;
pub use msg::DEFAULT_REPLAY_WINDOW_SECS;
pub use msg::MESSAGE_PREFIX;
pub use acl::check_cap;
pub use acl::is_principal_key;
pub use acl::is_valid_acl_key;
pub use acl::normalize_principal;
pub use acl::validate_acl_map;
pub use acl::AclMap;
pub use acl::CapabilityEntry;
pub use acl::CAP_ACL;
pub use acl::CAP_CREATE;
pub use acl::CAP_CRUD;
pub use acl::CAP_DELETE;
pub use acl::CAP_IDENTITY_PUBLISH;
pub use acl::CAP_INBOX;
pub use acl::CAP_IPFS;
pub use acl::CAP_READ;
pub use acl::CAP_UPDATE;
pub use acl::GROUP_PREFIX;
pub use acl::LOCAL_ENTITY_WILDCARD;
pub use service::Service;
pub use service::CONTENT_TYPE_CBOR;
pub use service::CONTENT_TYPE_TERM;
pub use service::CONTENT_TYPE_TERM_CBOR;
pub use service::CONTENT_TYPE_TERM_YAML;
pub use service::CRUD_PROTOCOL_ID;
pub use service::INBOX_PROTOCOL_ID;
pub use service::IPFS_PROTOCOL_ID;
pub use service::MESSAGE_TYPE_BROADCAST;
pub use service::MESSAGE_TYPE_CHAT;
pub use service::MESSAGE_TYPE_CRUD;
pub use service::MESSAGE_TYPE_CRUD_REPLY;
pub use service::MESSAGE_TYPE_DOC;
pub use service::MESSAGE_TYPE_EMOTE;
pub use service::MESSAGE_TYPE_IDENTITY_PUBLISH_REQUEST;
pub use service::MESSAGE_TYPE_IPFS_REQUEST;
pub use service::MESSAGE_TYPE_MESSAGE;
pub use inbox::Inbox;
pub use endpoint::MaEndpoint;
pub use transport::endpoint_id_from_transport;
pub use transport::endpoint_id_from_transport_value;
pub use transport::normalize_endpoint_id;
pub use transport::protocol_from_transport;
pub use transport::resolve_endpoint_for_protocol;
pub use transport::resolve_inbox_endpoint_id;
pub use transport::transport_string;
pub use identity::generate_secret_key_file;
pub use identity::load_secret_key_bytes;
pub use identity::socket_addr_to_multiaddr;
pub use config::MaArgs;
pub use config::BrowserIdentityExport;
pub use config::Config;
pub use config::SecretBundle;
pub use ipfs::resolver::DidDocumentResolver;
pub use ipfs::resolver::IpnsPathResolver;
pub use interfaces::DidPublisher;
pub use interfaces::IpfsPublisher;
pub use ipfs::*;

Modules§

acl
Capability-based access control for ma identities.
config
Configuration for ma-core-based daemons.
constants
did
doc
endpoint
Endpoint trait.
error
Error types for ma-core.
identity
Identity bootstrap helpers.
inbox
Service inbox — a bounded FIFO receive queue with per-message TTL.
interfaces
Trait interfaces for pluggable DID and IPFS publishing backends.
ipfs
IPFS-related APIs.
key
msg
service
Service trait for ma endpoint protocol handlers.
transport
Transport string parsing and endpoint resolution from DID documents.

Structs§

KuboDidResolver
Resolves DID documents and IPNS paths via a local Kubo daemon’s RPC API.
Outbox
A transport-agnostic write handle to a remote service.

Enums§

Ipld
Ipld

Constants§

CODEC_CBOR
CODEC_DAG_CBOR
CODEC_DAG_JSON
CODEC_IDENTITY
CODEC_JSON
CODEC_RAW

Functions§

cat_bytes
delete_local_pins_named_in_background
Schedule best-effort removal of all local recursive pins with this exact name, keeping only the current CID.
delete_remote_pins_named_in_background
Schedule best-effort removal of all remote pins with this exact name, keeping only the current CID.
in_flight_pin_name
The temporary name protecting a fresh pin while stale pins are removed.
ipfs_add
new_ma_endpoint
Create a default ma endpoint backend from 32-byte secret key material.
remote_pin_add_named
remote_pin_replace_named
Pin cid on the remote service and schedule best-effort replacement of stale pins with this name.