Liking cljdoc? Tell your friends :D

altcha-clj.core


calculate-expiration-offsetclj/s

(calculate-expiration-offset start-ts-ms offset-secs)

Adds offset-secs * 1000 to the start-ts-ms timestamp value

Adds `offset-secs` * 1000 to the `start-ts-ms` timestamp value
sourceraw docstring

create-challengeclj/s

(create-challenge options)

Creates a challenge for the client to solve. options is a map of the following keys:

  • :algorithm - algorithm for creating a digest of the challenge, default is SHA-256. For ClojureScript, it will always be SHA-256. Can also be SHA-1 or SHA-512
  • :max-number - highest random number used for generating the challenge. Default is 1e6, represented as a fixed point integer.
  • :salt-len - length of the salt. Default is 12. Longer salts are more computationally expensive.
  • :expires - optional timestamp. This value will be implicitly bound if ttl is present by calling calculate-expiration-offset. See below. Usually you'll only need to set ttl
  • :ttl - Time-to-live in seconds. Needed for calculating challenge expiration time. You don't need to convert a string value to an integer here, it'll be converted for you. Note the difference between ttl and expires. Expires is returned by the handler, while ttl must be present in the challenge response salt to compare the hashes of the challenge in the initial challenge and the challenge response. current-time-ms is platform-specfic pseudocode placeholder here
  • :current-time - current UNIX millisecond timestamp. Pass this argument to make the calculation of challenge expiration more deterministic. Otherwise it will be generated as a side effect inside create-challenge
  • :hmac-key - required, the secret key for creating the HMAC signature (a string value, not a path)
  • :params - optional, additional parameters to include in the salt

Changing the following parameters to hardcoded values is not recommended outside development settings

  • :salt - optional, custom salt to use instead of generating oneo Used for validation
  • :number - optional, custom number to use instead of generating one
Creates a challenge for the client to solve.
options is a map of the following keys: 
- `:algorithm` - algorithm for creating a digest of the challenge, default is **SHA-256**.
   For ClojureScript, it will always be SHA-256.
   Can also be **SHA-1** or **SHA-512**
- `:max-number` - highest random number used for generating the challenge. Default is 1e6, represented as a fixed point integer.
- `:salt-len` - length of the salt. Default is 12. Longer salts are more computationally expensive.
- `:expires` - optional timestamp. This value will be implicitly bound if `ttl` 
is present 
by calling `calculate-expiration-offset`. See below. Usually you'll only need to set `ttl`
- `:ttl` - Time-to-live in seconds. Needed for calculating challenge expiration time.
You don't need to convert a string value to an integer here, it'll be converted for you.
Note the difference between `ttl` and `expires`. Expires is returned by the handler,
while ttl must be present in the challenge response salt to compare the hashes
of the challenge in the initial challenge and the challenge response.
`current-time-ms` is platform-specfic pseudocode placeholder here
- `:current-time` - current UNIX millisecond timestamp.
  Pass this argument to make the calculation of challenge expiration more 
  deterministic. Otherwise it will be generated as a side effect inside `create-challenge`
- `:hmac-key` - required, the secret key for creating the HMAC signature (a string value, not a path)
- `:params` - optional, additional parameters to include in the salt

Changing the following parameters to hardcoded values is not recommended outside development settings
- `:salt` - optional, custom salt to use instead of generating oneo
Used for validation
- `:number` - optional, custom number to use instead of generating one
sourceraw docstring

createChallengecljs

(createChallenge options)
source

hash-hexclj/s≠

clj
(hash-hex algorithm data)

Generates a hexadecimal string representation of the challenge message digest created using the selected algorithm

Generates a hexadecimal string representation of the challenge
message digest created using the selected algorithm
cljs
(hash-hex _ data)

Generates a hexadecimal string representation of the SHA-256 digest of the challenge message

Generates a hexadecimal string representation of the SHA-256 digest of the challenge message
source (clj)source (cljs)raw docstring

hmac-hexclj/s≠

(hmac-hex algorithm data key)
clj

Returns the HMAC-encoded value of the data. Params

  • algorithm - 'SHA-256', 'SHA-512' or 'SHA-1'
Returns the HMAC-encoded value of the data. Params
- `algorithm` - 'SHA-256', 'SHA-512' or 'SHA-1'
source (clj)source (cljs)raw docstring

random-bytesclj/s

(random-bytes n)
source (clj)source (cljs)

random-intclj/s

(random-int max)
source (clj)source (cljs)

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close