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.3-py3-none-win_arm64.whl (2.0 MB view details)

Uploaded Python 3Windows ARM64

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

Uploaded Python 3Windows x86-64

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

Uploaded Python 3Windows x86

auki_domain_client-1.5.3-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.3-py3-none-musllinux_1_2_aarch64.whl (2.1 MB view details)

Uploaded Python 3musllinux: musl 1.2+ ARM64

auki_domain_client-1.5.3-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.3-py3-none-manylinux_2_28_aarch64.whl (2.0 MB view details)

Uploaded Python 3manylinux: glibc 2.28+ ARM64

auki_domain_client-1.5.3-py3-none-macosx_11_0_arm64.whl (2.0 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

auki_domain_client-1.5.3-py3-none-macosx_10_12_x86_64.whl (2.1 MB view details)

Uploaded Python 3macOS 10.12+ x86-64

File details

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

File metadata

File hashes

Hashes for auki_domain_client-1.5.3-py3-none-win_arm64.whl
Algorithm Hash digest
SHA256 0220f0f4559533c1865eee23842ae95b1b84d2462de766f2443fa9c48aca9d38
MD5 de57f5c02b2e8fe0df31d95793724203
BLAKE2b-256 41a1fb545afcdc6364362828dd7631bd7b33dac342fcfd9b81268c6f6b9b1b20

See more details on using hashes here.

Provenance

The following attestation bundles were made for auki_domain_client-1.5.3-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.3-py3-none-win_amd64.whl.

File metadata

File hashes

Hashes for auki_domain_client-1.5.3-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 c6b16bde6e3229ebbb4521d417058230853b16ed802cb9743b88f0a663811763
MD5 8705603e8b0d716e1cf853dfee928c53
BLAKE2b-256 f52e1632ae3b4172bffc01ac26c61126fdfad2256961d48205bfeebca7739cc6

See more details on using hashes here.

Provenance

The following attestation bundles were made for auki_domain_client-1.5.3-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.3-py3-none-win32.whl.

File metadata

File hashes

Hashes for auki_domain_client-1.5.3-py3-none-win32.whl
Algorithm Hash digest
SHA256 512a8494d0f0b7698cd8da78d8d328adbdc46cd9ad40d0c1c2175bc09e20d467
MD5 dd627c90705105ac81926b8bd9f94cda
BLAKE2b-256 a72ef2740c54902b8b7a379a8da79873229b25e671f5abbaae8c51eac2238b26

See more details on using hashes here.

Provenance

The following attestation bundles were made for auki_domain_client-1.5.3-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.3-py3-none-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for auki_domain_client-1.5.3-py3-none-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 c0e76b8bc80a6167c7a07ff04e952775db3d0a12e94e98f618a2ae25d1849963
MD5 1c093a35c19f3a0615a865a4c92826da
BLAKE2b-256 cebd996d8ce76a8db8993b94f6495ec0cfe2dbaaf5954bb0e93c5fa11d054b8a

See more details on using hashes here.

Provenance

The following attestation bundles were made for auki_domain_client-1.5.3-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.3-py3-none-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for auki_domain_client-1.5.3-py3-none-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 8fb51db2a844123f5a270dce0598de6a8f261160bbd36beb2f9d3324a7a80d87
MD5 0ef17dc0a7171f0c72c8f076a81ac5e3
BLAKE2b-256 adeb2a9c99cb55197dc9a173201858639bc50e15d69f1a08e57e34c03583d582

See more details on using hashes here.

Provenance

The following attestation bundles were made for auki_domain_client-1.5.3-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.3-py3-none-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for auki_domain_client-1.5.3-py3-none-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 7aa532273136473a6e30188e0ca0f69c7724a1e1134b77463536be4ede88d1c7
MD5 7038595a91f400873a756e55f08c27e9
BLAKE2b-256 bb067c8912aa14a1ba7ef723ee6a7171228509fb24a1a81d4e1ed055b4b6deb4

See more details on using hashes here.

Provenance

The following attestation bundles were made for auki_domain_client-1.5.3-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.3-py3-none-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for auki_domain_client-1.5.3-py3-none-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 668199d9fdf2b27e1579d8258181930af8b0f29e1f8e76c94ad9f0d6dab45c53
MD5 f36ea26f066ae0b256f51fa8aecbf5ca
BLAKE2b-256 ca340fa26acafa61d5688a50bad1101896f23a37ed0e50279f59798d9cc997a9

See more details on using hashes here.

Provenance

The following attestation bundles were made for auki_domain_client-1.5.3-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.3-py3-none-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for auki_domain_client-1.5.3-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2e322d4feac62c603270526bd080048b9dc87ff77a15b73ead689e879f01586b
MD5 34fca4c94d2135fae5cf6ccec5dea017
BLAKE2b-256 ce1140ec2e28030d01abe41e8258c4091a709fa80577027ad9276edd0685ead0

See more details on using hashes here.

Provenance

The following attestation bundles were made for auki_domain_client-1.5.3-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.3-py3-none-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for auki_domain_client-1.5.3-py3-none-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 425ba12b722f341fc67df89375619ecdcb0575486284f6f4b72ab7d510595273
MD5 6a731110eb0ef2cd88e3b06cd7aa6a19
BLAKE2b-256 eabe4f582ad264a2a3b32f9e9d2bb89498c1f1f8bba6ac625288279dcaea18b6

See more details on using hashes here.

Provenance

The following attestation bundles were made for auki_domain_client-1.5.3-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