sigv4

    Download zip
    Version
    0.2.0
    License
    Apache-2.0
    Last updated
    22 hours ago
    Downloads
    5

    Dependencies

    #kaashyapan/sigv4

    Used by kaashyapan/s3

    Credentials

    pub(all) struct Credentials {
    access_key_id : String
    secret_access_key : String
    session_token : String?
    } derive(Eq)

    Credentials::Credentials

    fn Credentials::Credentials(access_key_id : String, secret_access_key : String, session_token? : String) -> Credentials

    canonical_query

    fn canonical_query(query : Map[String, String]) -> String

    Serialize a query map into its canonical form: keys and values percent-encoded, entries sorted byte-wise by encoded key (then value). Note: String::compare must not be used here — SigV4 requires pure byte-wise lexicographic ordering.

    percent_encode

    fn percent_encode(input : StringView, slash_okay? : Bool) -> String

    Percent-encode a string per RFC 3986 (everything but the unreserved characters), as required for SigV4 canonical query strings. If slash_okay is set, / is left unescaped (used for URI paths).

    presign_query

    fn presign_query(meth : String, path : String, host : String, credentials : Credentials, region : String, service : String, timestamp : String, expires : Int, signed_headers? : Map[String, String]) -> Map[String, String]

    Build the query parameters of a presigned URL: the X-Amz-* authorization parameters plus the computed X-Amz-Signature. The payload is always treated as UNSIGNED-PAYLOAD, as required for presigned URLs. Only host plus the names in signed_headers are included in the signature; the caller is responsible for sending those headers verbatim with the request.

    sign_headers

    fn sign_headers(meth : String, path : String, query : Map[String, String], headers : Map[String, String], payload_hash : String, credentials : Credentials, region : String, service : String, timestamp : String) -> Map[String, String]

    Sign a request with AWS Signature Version 4 and return the headers to send, including the Authorization header. The request method is given as an uppercase HTTP verb (e.g. "GET"), path must already be the canonical URI path, and payload_hash is the hex SHA-256 of the body (or "UNSIGNED-PAYLOAD").

    signing_key

    fn signing_key(secret : String, date : String, region : String, service : String) -> FixedArray[Byte]

    Derive the SigV4 signing key for the given date, region and service.

    Source Files