Skip to main content

HTTP client library for interacting with AukiLabs domain data services

Project description

Domain HTTP

A cross-platform HTTP client library for interacting with posemesh domains on the Auki Network. Supports both native and WebAssembly (WASM) environments.

Authentication Modes

posemesh-domain-http supports multiple authentication methods, each providing different levels of access to domain data:

1. Sign in with App Credentials

  • How: Use your app's key and secret to authenticate.
  • Access:
    • Read access to all domains.
    • No write access—app credentials are intended for read-only operations.
  • Use case: Suitable for backend services or applications that need to fetch domain data but do not need to modify it.

2. Sign in with Auki User Credentials

  • How: Authenticate using a user's email and password.
  • Access:
    • Write access to domains owned by the user within the same organization.
    • Read access to all domains.
  • Use case: Use this mode when you need to allow users to manage (create, update, or delete) their own domains, as well as view other domains in the organization.

3. Authenticate with OIDC Access Token

  • How: Provide a valid OIDC (OpenID Connect) access token obtained from the authentication service.
  • Access:
    • Grants read and write access to domains, according to the roles assigned to the user.
  • Use case: Enables single sign-on and fine-grained access control. Permissions are determined by the user’s assigned roles.

Key Features:

  • Secure authentication and authorization with the Auki Network.
  • (not supported in Python) Efficient streaming download of domain data, enabling seamless handling of large datasets.
  • Flexible upload functionality for both creating and updating domain data.
  • Universal compatibility: JavaScript package works in browsers, Deno, and Node.js(v18+ with ReadableStream support).

Usage

The client_id parameter must not be empty.

  • Frontend applications: Use the device ID or user ID as the client_id.
  • Backend environments: Use a unique identifier that represents your service or application.

The purpose of client_id is to distinguish whether multiple accesses to a domain originate from the same client (for example, the same app instance on the same device). When this is the case, network credits will only be deducted once for repeated calls from the same client.

Rust Examples

For more examples, check /src/domain_client.rs.

use posemesh_domain_http::{DomainClient, DownloadQuery, ListDomainsQuery};

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = DomainClient::new_with_user_credential(
        &api_url,
        &dds_url,
        &client_id,
        &email,
        &password,
        true,
    )?;

    // List domains in the given organization, `all`, `own` or an organization id
    let query = ListDomainsQuery { org: "own".to_string(), portal_id: None, portal_short_id: None, domain_server_id: None };
    let domains = client.list_domains(query)?;
    println!("Domains: {:?}", domains);

    // Download all data for a domain
    let domain_id = "your-domain-id";
    let download_query = DownloadQuery { ids: vec![], name: None, data_type: None };
    let domain_data = client.download_domain_data(domain_id, download_query)?;
    for data in domain_data {
        println!("Data: {} ({} bytes)", data.metadata.name, data.metadata.size);
    }
    Ok(())
}

Python Exampels

For more examples, check /bindings/python/tests/test_basic.py.

from auki_domain_client import DomainClient, DownloadQuery, ListDomainsQuery
import os

# Authenticate using user credentials (with password recall)
client = DomainClient.new_with_user_credential(
    api_url, dds_url, client_id, email, password, True
)

# List domains in the given organization, `all`, `own` or an organization id
query = ListDomainsQuery(org="own", portal_id=None, portal_short_id=None, domain_server_id=None)
response = client.list_domains(query)
print("Domains:", response.domains)

# Download domain data
domain_id = "your-domain-id"
download_query = DownloadQuery(
    ids=[],  # All data
    name=None,
    data_type=None,
)
domain_data = client.download_domain_data(domain_id, download_query)
for data in domain_data:
    print(f"Name: {data.metadata['name']}, Size: {data.metadata['size']}")

JavaScript/Typescript Example

For more examples, check /bindings/javascript/tests/basic.test.ts

import { DomainClient, DownloadQuery, ListDomainsQuery, signInWithUserCredential } from "@auki/domain-client";

// Authenticate using user credentials
const client = await signInWithUserCredential(
  apiUrl,
  ddsUrl,
  clientId,
  email,
  password,
  true // remember password
);

// List domains in the given organization, `all`, `own` or an organization id
const response = await client.listDomains({org: "own"});
console.log("Domains:", response.domains);

// Download domain data
const domainId = "your-domain-id";
const domainData = await client.downloadDomainData(domainId, {ids:[]});

domainData.forEach((data) => {
  console.log(`Name: ${data.metadata.name}, Size: ${data.metadata.size}`);
});

client.free();

Changelog

See CHANGELOG.md for a list of features, bug fixes, and breaking changes.

Development

To build the domain-http crate locally for different platforms and for WebAssembly (WASM), follow these instructions:

1. Build for Native (Host) Platform

From the repository root, run:

cargo build -p posemesh-domain-http --release

2. Build for a Different Target Platform (Cross-Compile)

For cross-compiling, use cross. Install cross if you don't already have it:

cargo install cross

Then, build for your desired target. For example, to build for ARM64 Linux:

cross build -p posemesh-domain-http --release --target aarch64-unknown-linux-gnu

Replace aarch64-unknown-linux-gnu with the appropriate Rust target triple for your platform.

3. Generate wasm binding

use the provided Makefile task:

make build-domain-http TARGET=wasm

This will produce the WASM package in domain-http/bindings/javascript/pkg.

4. Generate Python binding

make build-domain-http TARGET=python

This will produce the python package in domain-http/bindings/python/.venv/lib/auki_domain_client.

5. Additional Notes

  • Make sure you have the required Rust target installed:
    rustup target add wasm32-unknown-unknown
    

Test

To run all tests (including both Rust and JS/WASM tests), use:

make unit-tests

This will run all unit and integration tests for both the Rust crate and the JavaScript/WASM package.

Publish

To publish a new version of this crate, follow these steps:

  1. Update the Version in Cargo.toml

    • If you are publishing a development/unstable release (such as during pre-release testing or RCs), increment the version in Cargo.toml to an unstable version suffix, such as:
      • 1.5.0-alpha.1
      • 1.5.0-beta.1
      • 1.5.0-rc.1
    • Only stable releases (e.g., 1.5.0, with no - suffix) are published to crates.io by CI.
    • Stable versions:
      • When you are ready for a stable release, bump the version to a new stable version (e.g., 1.5.0).
      • Update the changelog in README.md with the changes for the new release.
  2. Committing & PR

    • Always commit and push your version bump (and changelog update if stable) in your PR.
  3. Publishing

    • For stable versions: After merging your PR to the default branch, the CI will automatically build and publish the crate to crates.io and npm.js
    • For unstable/pre-release versions: You can publish manually if needed

Contributing

Contributions are welcome! Please ensure that all tests pass before submitting a pull request.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

auki_domain_client-1.5.2-py3-none-win_arm64.whl (2.0 MB view details)

Uploaded Python 3Windows ARM64

auki_domain_client-1.5.2-py3-none-win_amd64.whl (2.1 MB view details)

Uploaded Python 3Windows x86-64

auki_domain_client-1.5.2-py3-none-win32.whl (1.7 MB view details)

Uploaded Python 3Windows x86

auki_domain_client-1.5.2-py3-none-musllinux_1_2_x86_64.whl (2.2 MB view details)

Uploaded Python 3musllinux: musl 1.2+ x86-64

auki_domain_client-1.5.2-py3-none-musllinux_1_2_aarch64.whl (2.1 MB view details)

Uploaded Python 3musllinux: musl 1.2+ ARM64

auki_domain_client-1.5.2-py3-none-manylinux_2_28_x86_64.whl (2.2 MB view details)

Uploaded Python 3manylinux: glibc 2.28+ x86-64

auki_domain_client-1.5.2-py3-none-manylinux_2_28_aarch64.whl (2.0 MB view details)

Uploaded Python 3manylinux: glibc 2.28+ ARM64

auki_domain_client-1.5.2-py3-none-macosx_11_0_arm64.whl (1.9 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

auki_domain_client-1.5.2-py3-none-macosx_10_12_x86_64.whl (2.0 MB view details)

Uploaded Python 3macOS 10.12+ x86-64

File details

Details for the file auki_domain_client-1.5.2-py3-none-win_arm64.whl.

File metadata

File hashes

Hashes for auki_domain_client-1.5.2-py3-none-win_arm64.whl
Algorithm Hash digest
SHA256 f0e6530def0d3d2b04473d97268c95152eb90012fdb9f05a64be18c4423a7fbb
MD5 68e42d4099bf93eb769d7d1ce5e4d79c
BLAKE2b-256 904223156fda2b3902727c33a7c8e97f52f3e6bb36c23d133847c33fd7f05ad1

See more details on using hashes here.

Provenance

The following attestation bundles were made for auki_domain_client-1.5.2-py3-none-win_arm64.whl:

Publisher: build-and-publish.yml on aukilabs/posemesh

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file auki_domain_client-1.5.2-py3-none-win_amd64.whl.

File metadata

File hashes

Hashes for auki_domain_client-1.5.2-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 5f4ff127d99d7eb110c2c2c256406594dceb0ac8d99f0a4c6c27e8f93bb0fcf4
MD5 7b7cc104453f182ee771ae610aa55d0c
BLAKE2b-256 bca8146ab62d9aba8caf3f8d0133caf2ed0d299ff813a490a8e9bcd5d9129cd3

See more details on using hashes here.

Provenance

The following attestation bundles were made for auki_domain_client-1.5.2-py3-none-win_amd64.whl:

Publisher: build-and-publish.yml on aukilabs/posemesh

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file auki_domain_client-1.5.2-py3-none-win32.whl.

File metadata

File hashes

Hashes for auki_domain_client-1.5.2-py3-none-win32.whl
Algorithm Hash digest
SHA256 251b3d6fb2b01ce78bb4fdcea28ab6ab61f71bbeb17c6acfb68bec2ac07673a9
MD5 52a31cfe12a0795cfdc368672950b5d1
BLAKE2b-256 a5a87683a12d38b1b9ed02a8587e49077c373645e9557ef55928aec8590b2a26

See more details on using hashes here.

Provenance

The following attestation bundles were made for auki_domain_client-1.5.2-py3-none-win32.whl:

Publisher: build-and-publish.yml on aukilabs/posemesh

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file auki_domain_client-1.5.2-py3-none-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for auki_domain_client-1.5.2-py3-none-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 f8f5444938ee7d84bcf6494edbb053f00e2eb0c68a7fda799e032289f9c8413f
MD5 b0588c89375100164a781ab5f89420a6
BLAKE2b-256 40f9fe8fa37eae809f03030f560c2eaea449cbe910aadf1b622143ae214aa0c8

See more details on using hashes here.

Provenance

The following attestation bundles were made for auki_domain_client-1.5.2-py3-none-musllinux_1_2_x86_64.whl:

Publisher: build-and-publish.yml on aukilabs/posemesh

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file auki_domain_client-1.5.2-py3-none-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for auki_domain_client-1.5.2-py3-none-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 8c01c9037cfef2a4bc97f561869b052ff6b610e24641cb1cbeb983f6a5ca6f60
MD5 df515aaddd496947d9677a1600bc6c0a
BLAKE2b-256 995eee6e12f805c17da538715d177944f0f3ee543efdd2e8696dd3c5b10c349c

See more details on using hashes here.

Provenance

The following attestation bundles were made for auki_domain_client-1.5.2-py3-none-musllinux_1_2_aarch64.whl:

Publisher: build-and-publish.yml on aukilabs/posemesh

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file auki_domain_client-1.5.2-py3-none-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for auki_domain_client-1.5.2-py3-none-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 a9d354a53d2176a15acd22f474f3fe484a5d2edcff3be322b7daeb474e7a2f68
MD5 4a7a5e71306a187e22c10b713c309ae7
BLAKE2b-256 da819d4f86b87ac009cd39f97b0be3a06f639db92bab0dccd94de4daf3590fdc

See more details on using hashes here.

Provenance

The following attestation bundles were made for auki_domain_client-1.5.2-py3-none-manylinux_2_28_x86_64.whl:

Publisher: build-and-publish.yml on aukilabs/posemesh

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file auki_domain_client-1.5.2-py3-none-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for auki_domain_client-1.5.2-py3-none-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 cd09f305a9eae6a12c4c85ef0ed0676f6ea6110e74d8707c47a36377185488d1
MD5 21248662b410453adebf301ceb442d6d
BLAKE2b-256 ce1ca9f1105e914a486f8e64d5107ec134d916d9f0791904db08644e4e1669c7

See more details on using hashes here.

Provenance

The following attestation bundles were made for auki_domain_client-1.5.2-py3-none-manylinux_2_28_aarch64.whl:

Publisher: build-and-publish.yml on aukilabs/posemesh

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file auki_domain_client-1.5.2-py3-none-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for auki_domain_client-1.5.2-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6ca747e18ad233e0042842fa49c432ad62e4188244f5a8b9464d98ab188dcfc3
MD5 f0190202a1b53439fe61450a2b796252
BLAKE2b-256 43d18fe9f6053130f5da2c8eee23d1e8d85cbab3d261923819058dea7411dc30

See more details on using hashes here.

Provenance

The following attestation bundles were made for auki_domain_client-1.5.2-py3-none-macosx_11_0_arm64.whl:

Publisher: build-and-publish.yml on aukilabs/posemesh

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file auki_domain_client-1.5.2-py3-none-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for auki_domain_client-1.5.2-py3-none-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 52a1a36216d0b3a9d45692fed378ae246f8f5274d846539b5f00eaadba9fdc73
MD5 641c00b36cdcd76c1f233433400e110e
BLAKE2b-256 0208e96205504dff2a2a2cb2ddb2b6ee713d9e7bd468db1380ac9d996201e4f9

See more details on using hashes here.

Provenance

The following attestation bundles were made for auki_domain_client-1.5.2-py3-none-macosx_10_12_x86_64.whl:

Publisher: build-and-publish.yml on aukilabs/posemesh

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page