sigv4

Source   Edit  

Types

EncodedHeaders = tuple[signed: string, canonical: string]
Source   Edit  
PathNormal = enum
  Default,                  ## normalize paths to dereference `.` and `..` and de-dupe `/`
  S3                         ## do not normalize paths, and perform one less pass of escaping
Source   Edit  
SigningAlgo = enum
  SHA256 = "AWS4-HMAC-SHA256", SHA512 = "AWS4-HMAC-SHA512",
  UnsignedPayload = "UNSIGNED-PAYLOAD"
Source   Edit  

Procs

proc calculateSignature(secret: string; date: string; region: string;
                        service: string; tosign: string;
                        digest: SigningAlgo = SHA256): string {....raises: [],
    tags: [TimeEffect], forbids: [].}
compute a signature using secret, string-to-sign, and other details Source   Edit  
proc canonicalRequest(meth: HttpMethod; url: string; query: JsonNode;
                      headers: HttpHeaders; payload: string;
                      normalize: PathNormal = Default;
                      digest: SigningAlgo = SHA256): string {.
    ...raises: [Exception, KeyError, ValueError], tags: [RootEffect], forbids: [].}
produce the canonical request for signing purposes Source   Edit  
proc canonicalRequest(meth: HttpMethod; url: Uri; headers: HttpHeaders;
                      payload: string; digest: SigningAlgo = SHA256): string {.
    ...raises: [], tags: [], forbids: [].}
produce the canonical request for signing purposes Source   Edit  
proc credentialScope(region: string; service: string; date = ""): string {.
    ...raises: [], tags: [TimeEffect], forbids: [].}
combine region, service, and date into a scope Source   Edit  
proc hash(payload: string; digest: SigningAlgo): string {....raises: [], tags: [],
    forbids: [].}
hash an arbitrary string using the given algorithm Source   Edit  
proc makeDate(date: string = ""): string {....raises: [], tags: [TimeEffect],
    forbids: [].}
produce a date string as required for credentialScope, eg. YYYYMMDD Source   Edit  
proc makeDateTime(date: string = ""): string {....raises: [], tags: [TimeEffect],
    forbids: [].}
produce a date+time string as found in stringToSign, eg. YYYYMMDDTHHMMSSZ Source   Edit  
proc normalizeUrl(url: string; query: JsonNode; normalize: PathNormal = Default): Uri {.
    ...raises: [Exception, KeyError, ValueError], tags: [RootEffect], forbids: [].}
reorder and encode path and query components of a url Source   Edit  
proc normalizeUrl(url: Uri; query: JsonNode; normalize: PathNormal = Default): Uri {.
    ...raises: [Exception, KeyError, ValueError], tags: [RootEffect], forbids: [].}
reorder and encode path and query components of a url Source   Edit  
proc signedHeaders(headers: HttpHeaders): string {....raises: [], tags: [],
    forbids: [].}
calculate the list of signed headers Source   Edit  
proc stringToSign(hash: string; scope: string; date = "";
                  digest: SigningAlgo = SHA256): string {....raises: [],
    tags: [TimeEffect], forbids: [].}
combine signing algo, payload hash, credential scope, and date Source   Edit