Host Functions
Plugins import five host functions from the extism:host/user namespace. All five are stubbed as no-ops during automated verification so describe() can execute offline.
| Function | Purpose |
|---|---|
sp_http |
Perform an allowlisted HTTPS request |
sp_credential |
Read a user credential value by key |
sp_media_chunk |
Read a byte range from an attached media file |
sp_hmac_sha1 |
Compute an HMAC-SHA1 signature |
sp_sleep_ms |
Sleep for rate-limit backoff or polling |
sp_http
Sends an HTTPS request. Requests to hosts not listed in describe().allowed_domains are rejected by the host.
Input JSON:
{
"method": "POST",
"url": "https://bsky.social/xrpc/com.atproto.repo.createRecord",
"headers": {
"Content-Type": "application/json",
"Authorization": "Bearer <token>"
},
"body_base64": "eyJyZXBvIjoiLi4uIn0="
}
Output JSON:
{
"status": 200,
"headers": {
"content-type": "application/json"
},
"body_base64": "eyJ1cmkiOiJhdDovLy4uLiJ9"
}
sp_credential
Reads a credential value declared in describe().credential_fields from the user's local keychain.
- Input: UTF-8 field key (for example,
"app_password"). - Output: UTF-8 credential value, or an empty string if unset.
sp_media_chunk
Streams media attachment bytes in chunks so large images or videos do not exceed Wasm memory limits.
Input JSON:
{
"attachment_id": "att_01",
"offset": 0,
"length": 65536
}
- Output: Raw binary bytes for the range
[offset, offset + length).
sp_hmac_sha1
Computes a base64-encoded HMAC-SHA1 digest (useful for OAuth 1.0a request signing).
Input JSON:
{
"key": "<signing-key>",
"message": "<signature-base-string>"
}
- Output: Base64-encoded 20-byte digest.
sp_sleep_ms
Pauses execution for rate-limit backoff (429) or asynchronous media-processing polls (clamped by the host to a safe maximum per call).
- Input: Milliseconds as a string (for example,
"1000") or JSON{ "ms": 1000 }. - Output: Empty.