webstd

    Pure, zero-dependency WinterTC (ECMA-429) Web Standards primitives (Request, Response, Headers, URL, Cookie, Body, SSE/NDJSON) for MoonBit across all four targets

    web
    http
    url
    fetch
    wintertc
    standard
    Download zip
    Author
    Version
    0.1.1
    License
    MIT
    Last updated
    13 hours ago
    Downloads
    11

    #unmbt/webstd

    Zero-dependency WinterTC (ECMA-429) Web Standards primitives (Url, Method, status_reason, Headers, structured Cookie, Body, ByteStream, Request, Response, SseDecoder, NdjsonDecoder) supporting native, js, wasm, and wasm-gc.

    See SKILL.md and the workspace documentation in ../../docs/.

    Body

    using @unmbt/webstd/http { type Body }

    ByteStream

    异步流式载荷抽象(语言级 async 协程签名,生产代码零 core/async 依赖,四目标均可编译)
    using @unmbt/webstd/http { type Cookie }

    一等公民结构化 Cookie(支撑 ciallo-native 1:1 零重解析映射至 @std_http.Cookie,及 ciallo-js append("set-cookie");序列化时严格拒绝含 \r / \n / ; 控制字符以防头注入)

    CookieOptions

    CryptoError

    FormData

    FormEntry

    Headers

    大小写不敏感的多值 HTTP 头集合(保留同键多值顺序)

    Method

    using @unmbt/webstd/http { type Method }

    NdjsonDecoder

    纯同步增量 NDJSON 解码状态机(四目标全通测试)

    Request

    Response

    SameSite

    SseDecoder

    纯同步增量 SSE 解码状态机(处理跨 chunk 拆包与多字节 UTF-8,四目标全通测试)

    SseEvent

    一等公民 Server-Sent Events(SSE)结构化事件帧、泛型强类型事件帧与四目标纯同步增量解码器

    StreamError

    流式读写与载荷上限标准错误(防断连静默与 OOM)

    TransformStream

    Pure 4-target WinterTC TransformStream transformer over ByteStream chunks.

    TypedSseEvent

    Url

    using @unmbt/webstd/url { type Url }

    UrlError

    UrlPattern

    UrlPatternGroup

    UrlPatternResult

    WsCloseCode

    WsError

    WsMessage

    base64url_decode

    fn base64url_decode(input : StringView) -> Bytes raise
    CryptoError

    RFC 4648 URL-safe Base64 decoding (tolerates optional trailing '=' padding).

    base64url_encode

    fn base64url_encode(data : BytesView) -> String

    RFC 4648 URL-safe Base64 encoding without '=' padding (JWT / PASETO / WebCrypto).

    blake2b

    fn blake2b(data : BytesView, out_len? : Int, key? : BytesView) -> Bytes raise
    CryptoError

    RFC 7693 BLAKE2b hash/keyed-MAC (1..=64 bytes output, optional 0..=64 bytes key).

    bytes_to_hex

    fn bytes_to_hex(data : BytesView) -> String

    chacha20_xor

    fn chacha20_xor(key~ : BytesView, nonce~ : BytesView, counter? : UInt, data~ : BytesView) -> Bytes raise
    CryptoError

    RFC 8439 ChaCha20 XOR stream cipher (32-byte key, 12-byte nonce).

    constant_time_equal

    fn constant_time_equal(a : BytesView, b : BytesView) -> Bool

    Constant-time equality check for secret MACs, digests, and tokens.

    decode_query_component

    fn decode_query_component(input : StringView) -> String raise
    UrlError

    WHATWG URLSearchParams 查询参数编解码(先将 '+' 换空格再执行 '%XX' UTF-8 解码,拒绝 '%00' 与非法 UTF-8)

    encode_query_component

    fn encode_query_component(input : StringView) -> String

    fn format_set_cookie(name : StringView, value : StringView, options? :
    CookieOptions
    ) -> String

    hmac_sha256

    fn hmac_sha256(key~ : BytesView, data~ : BytesView) -> Bytes

    RFC 2104 / RFC 4231 HMAC-SHA256 returning 32-byte MAC.

    parse_cookies

    fn parse_cookies(header_value : StringView) -> Map[String, String]

    pbkdf2_hmac_sha256

    fn pbkdf2_hmac_sha256(password~ : BytesView, salt~ : BytesView, iterations~ : Int, dk_len~ : Int) -> Bytes raise
    CryptoError

    RFC 2898 PBKDF2-HMAC-SHA256 key derivation.

    percent_decode

    fn percent_decode(input : StringView) -> String raise
    UrlError

    严格 RFC 3986 路径单段解码(保留 '+' 原义,严禁在分段前解码 '%2F',拒绝 '%00' 与非法 UTF-8)

    percent_encode

    fn percent_encode(input : StringView) -> String

    sha256

    fn sha256(data : BytesView) -> Bytes

    FIPS 180-4 SHA-256 returning 32-byte digest.

    sha256_hex

    fn sha256_hex(data : BytesView) -> String

    status_reason

    fn status_reason(code : Int) -> String

    RFC 9110 标准 HTTP 状态短语(未知状态码回退 "",供 ciallo-native send_response 零分配调用)

    xchacha20_xor

    fn xchacha20_xor(key~ : BytesView, nonce~ : BytesView, counter? : UInt, data~ : BytesView) -> Bytes raise
    CryptoError

    XChaCha20 XOR stream cipher (32-byte key, 24-byte nonce) used by PASETO v4.local.

    Source Files