Skip to main content

Generate the X-Castle-Request-Token header minted by Castle's web SDK.

Project description

castle-token (Python)

Python bindings for the Rust castle-token crate — generate the X-Castle-Request-Token header minted by Castle's web SDK. The byte-exact wire format lives in the Rust core; this is a thin PyO3 wrapper.

pip install castle-token

Prebuilt abi3 wheels are published for Linux (manylinux + musllinux, x86-64 & arm64), macOS (x86-64 & arm64), and Windows (x64) — one wheel covers every CPython ≥ 3.9, so most installs need no Rust toolchain.

import castle_token as ct

token = ct.mint_token(
    cuid="00112233445566778899aabbccddeeff",
    pk="pk_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
    ig=225,
    hostname="id.example.com",          # the site the token is for (required)
    locale_profile=ct.LocaleProfile.preset("de-DE"),  # optional
    jitter=True,                        # optional: vary per-session signals
)
# send `token` as the X-Castle-Request-Token request header
  • mint_token(cuid, pk, ig, hostname, *, fingerprint=None, locale_profile=None, jitter=False, init_time_ms=None, now_ms=None) -> str
  • Fingerprint.chrome_148_macos(), load_devices(path), random_bundled_device()
  • LocaleProfile.preset(tag) / .en_us() / .de_de() / … / .new(...)
  • Errors raise CastleError.

Example

A runnable script is in examples/mint_token.pypython examples/mint_token.py.

Build from source

cd python && maturin develop      # or: pip install .

Releasing to PyPI (maintainers)

Wheels + sdist are built and published by .github/workflows/python-release.yml on a vX.Y.Z tag, via PyPI Trusted Publishing (OIDC — no API token stored).

One-time setup at https://pypi.org/manage/account/publishing/ — add a pending publisher (works before the project exists):

Field Value
PyPI project name castle-token
Owner 0x640480
Repository castle-rs
Workflow name python-release.yml
Environment pypi

Then create a GitHub environment named pypi (repo Settings → Environments); add manual-approval reviewers there if you want a release gate.

To cut a release: bump version in python/Cargo.toml (the wheel version is dynamic, read from it), commit, then:

git tag vX.Y.Z && git push origin vX.Y.Z

workflow_dispatch runs the same build matrix without publishing, for a dry run.

Project details


Download files

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

Source Distribution

castle_token-0.1.0.tar.gz (53.6 kB view details)

Uploaded Source

Built Distributions

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

castle_token-0.1.0-cp39-abi3-win_amd64.whl (401.2 kB view details)

Uploaded CPython 3.9+Windows x86-64

castle_token-0.1.0-cp39-abi3-musllinux_1_2_x86_64.whl (713.0 kB view details)

Uploaded CPython 3.9+musllinux: musl 1.2+ x86-64

castle_token-0.1.0-cp39-abi3-musllinux_1_2_aarch64.whl (680.2 kB view details)

Uploaded CPython 3.9+musllinux: musl 1.2+ ARM64

castle_token-0.1.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (505.4 kB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ x86-64

castle_token-0.1.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (504.6 kB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ ARM64

castle_token-0.1.0-cp39-abi3-macosx_11_0_arm64.whl (459.2 kB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

castle_token-0.1.0-cp39-abi3-macosx_10_12_x86_64.whl (460.4 kB view details)

Uploaded CPython 3.9+macOS 10.12+ x86-64

File details

Details for the file castle_token-0.1.0.tar.gz.

File metadata

  • Download URL: castle_token-0.1.0.tar.gz
  • Upload date:
  • Size: 53.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for castle_token-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e2ced3bdab499e4025c9a903c9030c16f1ec5fd37bcd4831576e368215b89bb3
MD5 160c1d21707bb91095ea453b9dd33ce6
BLAKE2b-256 096bfb5a41fd661d323a42e7a11c516034d9f13d00eb37597a120249d6b03a39

See more details on using hashes here.

Provenance

The following attestation bundles were made for castle_token-0.1.0.tar.gz:

Publisher: python-release.yml on 0x640480/castle-rs

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

File details

Details for the file castle_token-0.1.0-cp39-abi3-win_amd64.whl.

File metadata

  • Download URL: castle_token-0.1.0-cp39-abi3-win_amd64.whl
  • Upload date:
  • Size: 401.2 kB
  • Tags: CPython 3.9+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for castle_token-0.1.0-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 083a120718cb8de3b1948e9b9ef3b3b9819679515b5336bb2e92efd86fe98c90
MD5 8f52ed8393856f082246c8337cdcc48c
BLAKE2b-256 481d7fe763235f23bb5d21df95dfcc067cf83b9b62d88c4ca5937cd392ad6ece

See more details on using hashes here.

Provenance

The following attestation bundles were made for castle_token-0.1.0-cp39-abi3-win_amd64.whl:

Publisher: python-release.yml on 0x640480/castle-rs

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

File details

Details for the file castle_token-0.1.0-cp39-abi3-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for castle_token-0.1.0-cp39-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 20b51e6fcc049827ebf406e2b30a921e87108d1ab59bbac2373f02bcafa267ab
MD5 ba090dfeba0a193fad0029333f8571f9
BLAKE2b-256 ecc90c490edd516ad46b0ace0a2470125b0a6c2b38ea876a045848716d3dc589

See more details on using hashes here.

Provenance

The following attestation bundles were made for castle_token-0.1.0-cp39-abi3-musllinux_1_2_x86_64.whl:

Publisher: python-release.yml on 0x640480/castle-rs

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

File details

Details for the file castle_token-0.1.0-cp39-abi3-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for castle_token-0.1.0-cp39-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 e4f61fe04b729bf3e22fd2800a15065e49e738771afd6376287fe980aae83ae9
MD5 c9e72f090ad7fb97c3fbf2d22d9c8148
BLAKE2b-256 7536e7e0dcd43ba7ace118704f8f50f440f2705d79d9fec1bbae574476192965

See more details on using hashes here.

Provenance

The following attestation bundles were made for castle_token-0.1.0-cp39-abi3-musllinux_1_2_aarch64.whl:

Publisher: python-release.yml on 0x640480/castle-rs

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

File details

Details for the file castle_token-0.1.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for castle_token-0.1.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 6183e86113a44fd6215d6b8cd173995af16462dbe264411dac3ff27a7d60c214
MD5 0146bee370c5b11e21c922c9051c23dc
BLAKE2b-256 632c071aa13d3e855a58ed837b2118ed115e2a4b7f17ef4de16e4d5cd7b8d9b3

See more details on using hashes here.

Provenance

The following attestation bundles were made for castle_token-0.1.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: python-release.yml on 0x640480/castle-rs

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

File details

Details for the file castle_token-0.1.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for castle_token-0.1.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 06af1835f0905e7caa4938f0cd259bd439239e86a9ba96c006e958c42d944c9a
MD5 22a7b15ab220e4579a8a2b95c88df27e
BLAKE2b-256 9d3f4057ec6495095600cd6e934fbfd47decd3ba9ffe79bcf2692b77efca2b18

See more details on using hashes here.

Provenance

The following attestation bundles were made for castle_token-0.1.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: python-release.yml on 0x640480/castle-rs

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

File details

Details for the file castle_token-0.1.0-cp39-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for castle_token-0.1.0-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7999b36f6e84ea255241581baa9c8af8f2919cde7b4d718f59bf22eb4edd68e8
MD5 4c69926ca39d383121d19c1bbe976940
BLAKE2b-256 9e9bee46c3b605c4e53cf6fe3ec71c181ac6eac1dff7e7c2e99c426742e67959

See more details on using hashes here.

Provenance

The following attestation bundles were made for castle_token-0.1.0-cp39-abi3-macosx_11_0_arm64.whl:

Publisher: python-release.yml on 0x640480/castle-rs

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

File details

Details for the file castle_token-0.1.0-cp39-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for castle_token-0.1.0-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 99ea65cb1ae594ee81e7eb84dfbcc233260e21b2b63df7457a545dfc40971166
MD5 1cc5f26c585e34d190888d845ad01325
BLAKE2b-256 b78218408462aaf9de2fcc0d0ef8775accef9ae39d7012c10dbf29936dead203

See more details on using hashes here.

Provenance

The following attestation bundles were made for castle_token-0.1.0-cp39-abi3-macosx_10_12_x86_64.whl:

Publisher: python-release.yml on 0x640480/castle-rs

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