Skip to main content

paykit_lib/
lib.rs

1#![doc = include_str!("../README.md")]
2#![deny(rustdoc::broken_intra_doc_links)]
3
4mod allowance;
5mod app;
6mod app_registry;
7mod delivery_confirmation;
8mod encrypted_link;
9mod encrypted_link_recovery;
10mod error;
11mod event;
12mod noise_key;
13mod noise_key_authorization;
14mod payment_amount;
15mod payment_endpoint;
16mod payment_reference;
17mod payment_request;
18mod private_payment_list;
19mod pubky_routing;
20mod receipt;
21mod shared_wire;
22mod validation;
23
24#[doc(inline)]
25pub use allowance::{
26    add_decimal_amounts, allowance_period_window, check_allowance_time, compare_decimal_amounts,
27    evaluate_allowance, match_allowance_request, parse_allowance_event_message,
28    send_allowance_acceptance, send_allowance_end, send_allowance_proposal,
29    send_allowance_rejection, serialize_allowance_event, AllowanceAcceptance, AllowanceAmountRange,
30    AllowanceEnd, AllowanceEvaluation, AllowanceEvaluationBlock, AllowanceEvaluationInput,
31    AllowanceEvent, AllowanceEventMessage, AllowanceId, AllowancePeriod, AllowancePeriodKind,
32    AllowancePeriodLimit, AllowancePeriodUnit, AllowancePeriodWindow, AllowanceProposal,
33    AllowanceRejection, AllowanceRole, AllowanceTerms, AllowanceTermsBuilder, AllowanceUsageEntry,
34};
35#[doc(inline)]
36pub use app::PaykitAppId;
37#[doc(inline)]
38pub use app_registry::{
39    create_paykit_app_registry, get_paykit_app_registry, get_paykit_app_registry_with_revision,
40    parse_paykit_app_registry_json, serialize_paykit_app_registry, update_paykit_app_registry,
41    PaykitApp, PaykitAppCapabilities, PaykitAppRegistry, INITIAL_PAYKIT_KEY_GENERATION,
42    PAYKIT_APP_REGISTRY_MAX_APPS, PAYKIT_APP_REGISTRY_MAX_BYTES,
43    PAYKIT_APP_REGISTRY_MAX_ENDPOINT_DEFAULTS,
44};
45#[doc(inline)]
46pub use delivery_confirmation::{
47    parse_delivery_confirmation_json, serialize_delivery_confirmation, DeliveryConfirmation,
48};
49#[doc(inline)]
50pub use encrypted_link::{
51    accept_encrypted_link, advance_handshake, clear_encrypted_link_outbox, close_encrypted_link,
52    initiate_encrypted_link, restore_encrypted_link, restore_encrypted_link_from_config,
53    restore_encrypted_link_handshake, restore_encrypted_link_handshake_from_config, EncryptedLink,
54    EncryptedLinkHandshake, EncryptedLinkHandshakeSnapshot, EncryptedLinkRecoveryContext,
55    EncryptedLinkSnapshot, HandshakeAdvanceError, HandshakeProgress,
56    PreparedEncryptedLinkHandshakeStep, PreparedPrivateApplicationMessageReceive,
57    PreparedPrivateApplicationMessageSend, PrivateApplicationMessage, PrivateMessageKind,
58    DEFAULT_MAX_RECOVERY_ATTEMPTS, DEFAULT_MAX_SEND_RETRIES,
59    PRIVATE_APPLICATION_MESSAGE_RECEIVE_LIMIT,
60};
61#[doc(inline)]
62pub use encrypted_link_recovery::{
63    encrypted_link_recovery_marker_paths, fetch_encrypted_link_recovery_marker,
64    parse_encrypted_link_recovery_marker_json, publish_encrypted_link_recovery_marker,
65    remove_encrypted_link_recovery_marker, serialize_encrypted_link_recovery_marker,
66    EncryptedLinkRecoveryMarker,
67};
68#[doc(inline)]
69pub use error::PaykitError;
70#[doc(inline)]
71pub use event::EventId;
72#[doc(inline)]
73pub use noise_key::{derive_paykit_noise_public_key, derive_paykit_noise_secret_key};
74#[doc(inline)]
75pub use noise_key_authorization::{
76    get_paykit_noise_key_authorization, publish_paykit_noise_key_authorization,
77    PaykitNoiseKeyAuthorization,
78};
79#[doc(inline)]
80pub use payment_amount::PaymentAmount;
81#[doc(inline)]
82pub use payment_endpoint::{
83    create_payment_endpoint, get_payment_endpoint, get_payment_endpoint_with_revision,
84    get_payment_list, get_payment_list_with_budget, get_payment_list_with_limits,
85    is_payment_list_limit_exceeded, remove_payment_endpoint, remove_payment_endpoint_if_revision,
86    set_payment_endpoint, update_payment_endpoint, PaymentEndpointIdentifier,
87    PaymentEndpointPayload, PaymentList, PAYMENT_ENDPOINT_PAYLOAD_MAX_BYTES,
88    PAYMENT_LIST_MAX_ENDPOINTS,
89};
90#[doc(inline)]
91pub use payment_reference::{PaymentReference, PAYMENT_REFERENCE_MAX_LEN};
92#[doc(inline)]
93pub use payment_request::{
94    parse_payment_request_event_message, send_payment_conversion_quote, send_payment_proof,
95    send_payment_request, send_payment_request_acceptance, send_payment_request_cancellation,
96    send_payment_request_rejection, serialize_payment_request_event, BillingPeriod, ConversionRate,
97    PaymentConversion, PaymentConversionQuote, PaymentDeadline, PaymentProof, PaymentRequest,
98    PaymentRequestAcceptance, PaymentRequestCancellation, PaymentRequestEvent,
99    PaymentRequestEventMessage, PaymentRequestId, PaymentRequestRejection, PaymentRequestTerms,
100    PaymentRequestTermsBuilder, Recurrence, RecurrenceConfig, RecurrenceUnit,
101};
102#[doc(inline)]
103pub use private_payment_list::{
104    parse_private_payment_list_json, serialize_private_payment_list_json, set_private_payment_list,
105    PrivatePaymentList,
106};
107#[doc(inline)]
108pub use pubky::PublicKey;
109pub use pubky_noise;
110#[doc(inline)]
111pub use pubky_routing::{
112    content_revision, delete_resource_if_revision, fetch_payment_endpoint_revision,
113    fetch_resource_revision, is_write_conflict, list_payment_endpoint_identifiers,
114    put_resource_if_revision, with_write_lock, PAYKIT_APP_REGISTRY_PATH,
115    PAYKIT_ENCRYPTED_LINK_RECOVERY_PATH_PREFIX, PAYKIT_NOISE_KEY_AUTHORIZATION_PATH,
116    PAYKIT_PATH_PREFIX, PAYKIT_PRIVATE_PATH_PREFIX, PAYKIT_SHARED_STATE_PATH,
117    PAYKIT_SHARED_STATE_WRITE_PATH_PREFIX,
118};
119#[doc(inline)]
120pub use receipt::{
121    decrypt_receipt, parse_receipt_access_event_message, parse_receipt_access_json,
122    prepare_receipt, prepare_receipt_for_recipient, send_receipt_access,
123    serialize_receipt_access_json, store_prepared_receipt, PreparedReceipt, Receipt, ReceiptAccess,
124    ReceiptAccessEventMessage, ReceiptDecryptionKey, ReceiptDraft, ReceiptId,
125    ENCRYPTED_RECEIPT_MAX_BYTES,
126};
127
128/// Common result alias for Paykit operations.
129pub type Result<T> = std::result::Result<T, PaykitError>;
130
131#[cfg(test)]
132mod tests;