Propósito:
Permite que un usuario se identifique como tal en un servidor de establecimiento, luego este puede usar el token devuelto para usarlo en otras funciones. el token obtenido expira como en 40 minutos luego de su último uso.
Si ya estaba identificado, devolverá el mismo token.
Esta función requiere recibir un hash del password, actualmente usamos una función destructiva y simple.
Usar CommandClass GETMEMBERS para obtener un listado de establecimientos a los que se le podría entrar.
CLANES:
Un servidor de establecimiento puede pertenecer a un CLAN, (agrupación de servidores sincronizados, ejemplo. franquicias), se debe usar la función _GETCLANMEMBERS para obtener el listado de las distintas sucursales o establecimientos miembros, a los que pertenece el servidor al que le estamos entrando.
Por ejemplo de uso de CLAN: Se puede estar queriendo entrar a la SUCURSAL_A para usar la cuenta en la sucursal A, pero la cuenta pertenece o fue creada en la sucursal B. Entonces, en el parámetro Target Server, se indicará a qué servidor queremos entrar (CyberName) o sea Param1=SucursalA, pero la cuenta pertenece a la SucursalB, entonces, en Param2=Juan@SucursalB (Param2 = complete UserName).
Pero si la cuenta pertenece al mismo servidor al que queremos entrar, no se pone el @SucursalB, Entonces, Param1=SucursalA, Param2=Juan.
Esto puede ser algo confuso, porque en un clan, donde se unen distintos servidores, puede haber un Juan registrado en un local, y otro Juan registrado en otro local, cada uno perteneciendo a un servidor/establecimiento dado, pero su cuenta se puede abrir en otros establecimientos del clan. Cuando en UserName no se pone el @ significa que va a ser una cuenta local al servidor a donde le estamos entrando, pero si es una cuenta externa (de otro servidor asociado), se debe especificar el @Sucursal, _GETCLANMEMBERS nos devuelve el listado de sucursales/miembros asociados.ATRIBUTOS / ROLES:
Esta función devuelve un valor indicando los atributos de la cuenta identificada, donde cada bit de su valor numérico tiene un signficiado.
ENGLISH:
Purpose:
It allow an user to login in the target server that belong to an establishment, so, then it can use the token it returns to be used in others functions as input parameter. The obtained token expires 40 min. after its last use.
If the user is already loged, it will return the same token.
This function requires to receive the user’s password, this function support to receive a destructive hash in representation of the password, and not the raw password.
Important, previously use the function _GETCLANMEMBERS for add support to clans and more details.
This function also returns the Attribs parameter, a numerical value where each boolean BIT has an independent meaning matching the privileges that the account has on the target server. The client-side script can use this value to show more functionality than a non-privileged user.
Minimum version for the target server required: v17.7.5.
The output parameter "Attribs" bitmap
-------------------------------------------------------------------------
bits 7 6 5 4 3 2 1 0
ADMIN ACEPTED BAN ADMIN READ BAN BAN BAN
SISTEMA CONTRACT FLULPY CUENTAS ONLY PRIVATE PUBLIC ACCOUNT
FOLDER PUBLIC FOLDER FOLDER
FOLDER
------------------------------------------------------------------------
-------------------------------------------------------------------------
bits 15 14 13 12 11 10 9 8
ES ES PUEDE SONG NO BAN WRITE NO
OPERADOR MULTI- CREAR MANAGER LIMIT ADD ON PUBMSG
DE SALON SESSION CUENTAS ATTRIB SONGS SONG FLULPY
-------------------------------------------------------------------------
-------------------------------------------------------------------------
bits 23 22 21 20 19 18 17 16
NO CAN NO IS CUOTA CUOTA NO ES
MAINTAIN SEND OPEN MONITOR EXCEDIDA EXCEDIDA CUOTA GERENTE
FEE ALERT MAINTAIN AVISADO AVISAR DE SALON
-------------------------------------------------------------------------
-------------------------------------------------------------------------
bits 30 29 28 27 26 25 24
BUFFET NO NO SOLO ES CAN'T
SPY MY TOTAL 1 TESORERO COMPLAIN
CASHBOX CASHBOX MANTEN. OR SUGEST
-------------------------------------------------------------------------
Input parameters:
- CommandClass = _LOGIN
- Param1 = target CyberName.
- Param2 = complete UserName.
- Param3 = PasswordHash.
Saying “complete UserName” we reffers on the case that the target server belong in a clan, and the user account is not local from the target server, so he must write the @MemberName aswell. See _GETCLANMEMBERS for more details.
Output:
[{“ResponseClass”: “ERROR”, “Param1”: “message”, … }]
[{“ResponseClass”: “DATA”, “Param1”: “Email”}]
[{“ResponseClass”: “OK”, “Param1”: “CyberName”, “Param2”: “Complete UserName”, “Param3”: “Session Token”, “Param4”: “Attribs”…}]
Example of usage:
In TYPESCRIPT (angular) requires that compile target is atleast ES2020 at tsconfig.json
it also requires to add a module using the CLI in your project, using the following command in the command console positioned in the main project directory:
npm install bigint-typescript-definitions
in tsconfig.json file search and replace to:
"target": "es2020",
"module": "es2020",
"lib": [
"ES2020",
PWCrypt(Value: string): string // Hasher.
{
var X:bigint = 0x63FD126An;
var Y:bigint = 0x387FA4n;
var Z:bigint = 2938475n;
if (Value.length > 0)
{
for (let c = 0; c < Value.length; c++)
{
Y = Y * BigInt(Value.charCodeAt(c) & 255);
Y = Y ^ X;
Y = Y & 0x7FFFFFn;
Z = Z ^ Y;
Z = Z & 0x3FFFFFFn;
Z = Z * 2n;
Z = Z + BigInt(Value.charCodeAt(c) & 1);
X = Y + Z;
}
}
var A = "";
var B = "";
var C = "";
A = X.toString();
B = Z.toString();
C = Y.toString();
return A + B + C;
}
JS with the required password hasher (in PHP lines).
ECHO '<script src="BigInteger.min.js"></script>'; // Library for the 64bits integer library.
ECHO '<script type="text/javascript">';
ECHO 'function pwd_handler(form)'; // Function called onsubmit.
ECHO '{';
ECHO " if (form.PassRaw.value != '')"; // Only if something is writed.
ECHO ' {';
ECHO ' form.Pass.value = PWCrypt(form.PassRaw.value);'; // This calls the hasher.
ECHO " form.PassRaw.value = '';"; // This erase the raw password.
ECHO ' }';
ECHO '}';
ECHO 'function PWCrypt(Value)'; // Hasher.
ECHO '{';
ECHO ' var X = bigInt(0x63FD126An);';
ECHO ' var Y = bigInt(0x387FA4n);';
ECHO ' var Z = bigInt(2938475n);';
ECHO ' if (Value.length > 0)';
ECHO ' {';
ECHO ' for (let c = 0; c < Value.length; c++)';
ECHO ' {';
ECHO ' Y = Y.multiply(Value.charCodeAt(c) & 255);';
ECHO ' Y = Y.xor(X);';
ECHO ' Y = Y.and(0x7FFFFFn);';
ECHO ' Z = Z.xor(Y);';
ECHO ' Z = Z.and(0x3FFFFFFn);';
ECHO ' Z = Z.multiply(2);';
ECHO ' Z = Z.add(Value.charCodeAt(c) & 1);';
ECHO ' X = Y.add(Z);';
ECHO ' }';
ECHO ' }';
ECHO ' var A = ""; B = ""; C = "";';
ECHO ' A = X.toString();';
ECHO ' B = Z.toString();';
ECHO ' C = Y.toString();';
ECHO ' return A + B + C;';
ECHO '}';
ECHO '</script>';
Example of login form using the above hasher (in PHP lines).
Note: this PHP example don’t support clans.
ECHO '<form method="post" onsubmit="pwd_handler(this);">'; // onsubmit calls the hasher.
ECHO '<p>Ingrese USER / PASSWORD para el LAN:' . $CyberName . '</p>';
ECHO '<input type="text" name="UserName" value=""><br><br>';
ECHO '<input type="password" name="PassRaw" value=""><br><br>'; // It will be empty after the hasher.
ECHO '<input type="hidden" name="Pass" value="">'; // Field for the hidden hash of the password.
ECHO '<input type="hidden" name="CyberName" value="' . $CyberName . '"><br><br>';
ECHO '<input type="submit" value="JOIN">';
ECHO '</form>';
