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 };
    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)
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 } from "@auki/domain-client";

// Authenticate using user credentials
const client = await DomainClient.new_with_user_credential(
  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}`);
});

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

Uploaded Python 3Windows ARM64

auki_domain_client-1.4.0-py3-none-win_amd64.whl (2.0 MB view details)

Uploaded Python 3Windows x86-64

auki_domain_client-1.4.0-py3-none-win32.whl (1.6 MB view details)

Uploaded Python 3Windows x86

auki_domain_client-1.4.0-py3-none-musllinux_1_2_x86_64.whl (2.1 MB view details)

Uploaded Python 3musllinux: musl 1.2+ x86-64

auki_domain_client-1.4.0-py3-none-musllinux_1_2_aarch64.whl (2.0 MB view details)

Uploaded Python 3musllinux: musl 1.2+ ARM64

auki_domain_client-1.4.0-py3-none-manylinux_2_28_x86_64.whl (2.1 MB view details)

Uploaded Python 3manylinux: glibc 2.28+ x86-64

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

Uploaded Python 3manylinux: glibc 2.28+ ARM64

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

Uploaded Python 3macOS 11.0+ ARM64

auki_domain_client-1.4.0-py3-none-macosx_10_12_x86_64.whl (1.9 MB view details)

Uploaded Python 3macOS 10.12+ x86-64

File details

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

File metadata

File hashes

Hashes for auki_domain_client-1.4.0-py3-none-win_arm64.whl
Algorithm Hash digest
SHA256 ba2e7c692e601231b9c560377b669166cd0010ed0978c4168db0652fcfb3adb7
MD5 00f5d0abce21675fb8fc2ff6d6291c30
BLAKE2b-256 ce0b76e9cda545225464ecbdcbef8443334856c0e922916b1c6b68b02fe29d99

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for auki_domain_client-1.4.0-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 3c09c5690a2983fc0a9337e344a79b94d478d84c9a30c091811a1858ed4ac97a
MD5 aa20c5408ee60cc9a3dc5892e5fb8916
BLAKE2b-256 71e135e0df8e5a7b15a773cd6dd7db788a62521b2083a69b580e3725d00a51a0

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for auki_domain_client-1.4.0-py3-none-win32.whl
Algorithm Hash digest
SHA256 4e3599465ee63f10600343a1bc17c57f19ff94000c9e15e7578a45fad3e64174
MD5 7e09e97a513e3c50fbf6eee0abcb9875
BLAKE2b-256 44aa214df7dfac6c5518bf1e39863d195948e8ae3e114e5a33e534e3cbf54c76

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for auki_domain_client-1.4.0-py3-none-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 4109de0b58599fd0c7ffcff20f11959f06287c5a300a256128731619c2cbc526
MD5 b17f9acffb5e8d2fc7f22c3ec5a077f8
BLAKE2b-256 8f244854d3808524421daf984c881abf366e0392f37a001977d03b8664b8d80d

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for auki_domain_client-1.4.0-py3-none-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 59269c208ac69219546279152b7737a7f5af50cfd0f9e6e20dfbd6784dd5e59b
MD5 6fac4ac6dc9c2a5121242fa3657ee111
BLAKE2b-256 a45a4d25e5010f3b60d1f1736d64955a59142059b542b57f2bc5bd4c91ebbbe8

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for auki_domain_client-1.4.0-py3-none-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 dbff3a85d6b9246f2b950877f01af3d6242c183b25e5d0d10efb001fd455bfa2
MD5 0aaa07f5b8b0f64489780f2fc33b24c1
BLAKE2b-256 f35a1cf366236ca272293d75ff902b88f26d6d8e91c3d8e3e1a4c7ba5c0fc590

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for auki_domain_client-1.4.0-py3-none-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 922ad421c60cf2f9e86ca2dea4c9401962847f3ed0f596fb2d47a7bcde2d8e99
MD5 e55194dbc66d5a49ac8bb2ed10ae4494
BLAKE2b-256 fbd28551536e39b0cf38f64138758e70db0d6734e97c2929cccf292939468aa2

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for auki_domain_client-1.4.0-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c307f778c1ae511952907a746fe0fd81646acee5a437109d8c1408a8752c611f
MD5 d9f4f12a3812ee42139f352ff183ba3b
BLAKE2b-256 8a37e3f41760beaae0a69f35bbae42a22d60609db026825c5d7dd3baa5d43277

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for auki_domain_client-1.4.0-py3-none-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 1b6d3720b11647fec60f7c4f88bd2f5dff9d160861da74033103245a118c6e5d
MD5 aaa8a4f72575a17c61d431509a0d139a
BLAKE2b-256 a8a7279a096a9a94a95211efe338c0bd44616bae5fe30acc2cea1c1a71a5700c

See more details on using hashes here.

Provenance

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