Restaurant’s API key
The restaurant’s API key is a unique string which serves as an authorization for communication. POS must allow the restaurant to enter the API key. The restaurant generates the API key in Qerko’s web administration (opens in a new tab) and then it should be typed into the POS.
Typos in the API key can be checked like this:
function verifyApiKey(apiKey: string): boolean {
const KEY_LENGTH = 29;
if (apiKey.length != KEY_LENGTH) {
return false;
}
const HASH_LENGTH = 4
let base = apiKey.substr(0, apiKey.length - HASH_LENGTH);
let hash = apiKey.substr(apiKey.length - HASH_LENGTH, HASH_LENGTH);
return hex(sha1(base)).toLowerCase().startsWith(hash);
}