Skip to main content

Altcha

Support for Altcha, an open-source captcha that implements a security mechanism to prevent bots and ensure human interaction in the execution of services on the REST API.

Example of the complete configuration with default values:

"altcha": {
"enabled": true,
"algorithm": "PBKDF2/SHA-256",
"secret": "BY_DEFAULT_THE_SECRET_IS_AUTOGENERATE",
"keySecret": "BY_DEFAULT_THE_SECRET_KEY_IS_AUTOGENERATE",
"cost": 10000,
"counter": 10000,
"expires": 3600, // a SECONDS
"checkExpires": true
}
const altchaPayload = _req.getString("altcha");
if (_altcha.enabled() && !_altcha.verifySolution(altchaPayload)) {
_header.status(409);
_out.json(
_val.map()
.set("error", `invalid-altcha-payload`)
);
_exec.stop();
}


algorithm


_altcha.algorithm() : string

Description

The type of algorithm used in the cryptography.

Return

( string )

The code that identifies the encryption algorithm.


_altcha.algorithm(algorithm: string) : Altcha

Description

It defines the type of algorithm used in cryptography.

Attributes
NAMETYPEDESCRIPTION
algorithmstringCode that identifies the encryption algorithm.
Return

( Altcha )

Current instance of the Altcha resource.


challenge


_altcha.challenge() : Values

Description

Generates the challenge settings for the frontend widget.

Return

( Values )

Configuration data for the widget to process the challenge result.


checkExpires


_altcha.checkExpires() : boolean

Description

Obtains whether the expiration time should be checked or not.

Return

( boolean )

Check the expiration time or not.


_altcha.checkExpires(checkExpires: boolean) : Altcha

Description

Defines whether to check the expiration time or not.

Attributes
NAMETYPEDESCRIPTION
checkExpiresbooleanWhether it should check the expiration time or not.
Return

( Altcha )

Current instance of the Altcha resource.


cost


_altcha.cost() : long

Description

Number of iterations required to arrive at the derived key prefix.

Return

( long )

Brute force counting.


_altcha.cost(cost: int) : Altcha

Description

Defines the number of iterations required to arrive at the derived key prefix.

Attributes
NAMETYPEDESCRIPTION
costintThe number of the brute force count.
Return

( Altcha )

Current instance of the Altcha resource.


counter


_altcha.counter() : long

Description

In deterministic mode, the key prefix is calculated from the counter.

Return

( long )

Deterministic mode counter.


_altcha.counter(counter: int) : Altcha

Description

Defines, in deterministic mode, the counter that is used to calculate the key prefix.

Attributes
NAMETYPEDESCRIPTION
counterintThe counter value in deterministic mode.
Return

( Altcha )

Current instance of the Altcha resource.


enabled


_altcha.enabled() : boolean

Description

Retrieves whether Altcha is enabled.

Return

( boolean )

Whether it's active or not.


_altcha.enabled(enabled: boolean) : Altcha

Description

Defines whether Altcha is enabled.

Attributes
NAMETYPEDESCRIPTION
enabledbooleanWhether it should be activated or not.
Return

( Altcha )

Current instance of the Altcha resource.


expires


_altcha.expires() : int

Description

Get the expiration time in seconds.

Return

( int )

Expiration time in seconds.


_altcha.expires(expires: int) : Altcha

Description

Set the expiration time in seconds.

Attributes
NAMETYPEDESCRIPTION
expiresintThe time limit in seconds for expiration.
Return

( Altcha )

Current instance of the Altcha resource.


getAlgorithm


_altcha.getAlgorithm() : string

Description

The type of algorithm used in the cryptography.

Return

( string )

The code that identifies the encryption algorithm.


getCost


_altcha.getCost() : long

Description

Number of iterations required to arrive at the derived key prefix.

Return

( long )

Brute force counting.


getCounter


_altcha.getCounter() : long

Description

In deterministic mode, the key prefix is calculated from the counter.

Return

( long )

Deterministic mode counter.


getExpires


_altcha.getExpires() : int

Description

Get the expiration time in seconds.

Return

( int )

Expiration time in seconds.


getKeySecret


_altcha.getKeySecret() : string

Description

Obtain the secret signing key being used in the encryption.

Return

( string )

The secret signing key used in cryptography.


getSecret


_altcha.getSecret() : string

Description

Obtain the secret code that is being used in the encryption.

Return

( string )

The secret code used in cryptography.


isCheckExpires


_altcha.isCheckExpires() : boolean

Description

Obtains whether the expiration time should be checked or not.

Return

( boolean )

Check the expiration time or not.


isEnabled


_altcha.isEnabled() : boolean

Description

Retrieves whether Altcha is enabled.

Return

( boolean )

Whether it's active or not.


keySecret


_altcha.keySecret() : string

Description

Obtain the secret signing key being used in the encryption.

Return

( string )

The secret signing key used in cryptography.


_altcha.keySecret(keySecret: string) : Altcha

Description

Define the secret signing key that will be used in the encryption.

Attributes
NAMETYPEDESCRIPTION
keySecretstringThe secret signing key that the cryptography should use.
Return

( Altcha )

Current instance of the Altcha resource.


load


_altcha.load() : Altcha

Description

Loads the configurations related to the Altcha resource in the application.

Return

( Altcha )

Current instance of the Altcha resource.


secret


_altcha.secret() : string

Description

Obtain the secret code that is being used in the encryption.

Return

( string )

The secret code used in cryptography.


_altcha.secret(secret: string) : Altcha

Description

Define the secret code that will be used in the encryption.

Attributes
NAMETYPEDESCRIPTION
secretstringThe secret code that cryptography should use.
Return

( Altcha )

Current instance of the Altcha resource.


setAlgorithm


_altcha.setAlgorithm(algorithm: string) : Altcha

Description

It defines the type of algorithm used in cryptography.

Attributes
NAMETYPEDESCRIPTION
algorithmstringCode that identifies the encryption algorithm.
Return

( Altcha )

Current instance of the Altcha resource.


setCheckExpires


_altcha.setCheckExpires(checkExpires: boolean) : Altcha

Description

Defines whether to check the expiration time or not.

Attributes
NAMETYPEDESCRIPTION
checkExpiresbooleanWhether it should check the expiration time or not.
Return

( Altcha )

Current instance of the Altcha resource.


setCost


_altcha.setCost(cost: int) : Altcha

Description

Defines the number of iterations required to arrive at the derived key prefix.

Attributes
NAMETYPEDESCRIPTION
costintThe number of the brute force count.
Return

( Altcha )

Current instance of the Altcha resource.


setCounter


_altcha.setCounter(counter: int) : Altcha

Description

Defines, in deterministic mode, the counter that is used to calculate the key prefix.

Attributes
NAMETYPEDESCRIPTION
counterintThe counter value in deterministic mode.
Return

( Altcha )

Current instance of the Altcha resource.


setEnabled


_altcha.setEnabled(enabled: boolean) : Altcha

Description

Defines whether Altcha is enabled.

Attributes
NAMETYPEDESCRIPTION
enabledbooleanWhether it should be activated or not.
Return

( Altcha )

Current instance of the Altcha resource.


setExpires


_altcha.setExpires(expires: int) : Altcha

Description

Set the expiration time in seconds.

Attributes
NAMETYPEDESCRIPTION
expiresintThe time limit in seconds for expiration.
Return

( Altcha )

Current instance of the Altcha resource.


setKeySecret


_altcha.setKeySecret(keySecret: string) : Altcha

Description

Define the secret signing key that will be used in the encryption.

Attributes
NAMETYPEDESCRIPTION
keySecretstringThe secret signing key that the cryptography should use.
Return

( Altcha )

Current instance of the Altcha resource.


setSecret


_altcha.setSecret(secret: string) : Altcha

Description

Define the secret code that will be used in the encryption.

Attributes
NAMETYPEDESCRIPTION
secretstringThe secret code that cryptography should use.
Return

( Altcha )

Current instance of the Altcha resource.


verifySolution


_altcha.verifySolution(payload: string) : boolean

Description

Checks if the result of the challenge generated by the widget on the frontend is valid.

Attributes
NAMETYPEDESCRIPTION
payloadstring
Return

( boolean )

Whether the result of the challenge is valid or not.