vanhecke/celmex/3.0.0

Unavailable. Nobody can download this version any more, with elm or with the Lamdera compiler: github.com/vanhecke/celmex is gone (deleted or private); Software Heritage not asked yet (this run's --swh-calls were used up); no fork with the same repo name found; no cached copy. Use another version.

Details

Cortex.Auth

Advanced-API Auth signing for Cortex. Each authenticated request carries a SHA-256 hash of apiKey ++ nonce ++ timestamp plus three sidecar headers.

Opaque container for an Advanced API key pair. Construct via credentials; the raw apiKey is kept inaccessible to prevent accidental logging.

type Stamp

Opaque container for the timestamp + nonce pair that signs a single request. The timestamp is milliseconds since epoch; the nonce is a random string of at least 32 characters per the Cortex Advanced Auth spec.

{ apiKeyId : String
, apiKey : String
}

Build a Credentials from the raw API Key ID and API Key strings (typically sourced from CORTEX_API_KEY_ID / CORTEX_API_KEY).

{ timestamp : Int
, nonce : String
}
-> Stamp

Build a Stamp from a millis-since-epoch timestamp and a random nonce.

sign : Credentials -> Stamp -> List Header

Produce the four Advanced API Auth headers.

hash =
    SHA256.toHex (SHA256.fromString (apiKey ++ nonce ++ String.fromInt timestamp))

Headers sent:

  • Authorization: the hex SHA-256 hash
  • x-xdr-auth-id: the API key ID
  • x-xdr-timestamp: millis since epoch (as string)
  • x-xdr-nonce: the nonce string
nonceGenerator : Generator String

Generate a 64-character random nonce from [A-Za-z0-9]. Suitable for browser use where crypto.randomBytes is unavailable. The CLI uses Node's crypto.randomBytes instead.