Complete Authentication
To complete registration you'll need the same header values as used in Initiate Authentication
Request Spec
HTTP Method: POST
Headers:
X-Scope-Id: A UUID string representing the application scope.
X-Encrypted-Key: A string containing the encrypted key for secure communication.
X-Encrypted-User: The user input encrypted using the encryption key
Body:
encrypted_assertion: A string containing the encrypted user assertion data.
To create an encrypted_assertion, first have to decrypt the encrypted_request_challenge from the response in Initiate Authentication, with the following functions.
const cryptoObj = typeof window !== "undefined" ? window.crypto : crypto;
const decrypt = async (algo, key, data) => {
try {
const decryptedResult = await cryptoObj.subtle.decrypt(algo, key, data);
return decryptedResult;
} catch (error) {
console.error("Decryption error:", error);
throw error;
}
};
const aesDecrypt = async (
cipherText: string,
encryptionKey: BufferSource,
keyFormat: "raw" = "raw",
keyLength: number = 256
) => {
if (!encryptionKey) {
throw Error("Encryption key not initialized");
}
let cryptoKey: CryptoKey;
let decryptedData: ArrayBuffer;
try {
const combined = Uint8Array.from(atob(cipherText), (c) => c.charCodeAt(0));
const iv = combined.slice(0, 12);
const encryptedData = combined.slice(12);
cryptoKey = await importKey(keyFormat, encryptionKey, { name: "AES-GCM", length: keyLength }, [
"decrypt",
]);
decryptedData = await decrypt({ name: "AES-GCM", iv }, cryptoKey, encryptedData);
const decoder = new TextDecoder();
return decoder.decode(new Uint8Array(decryptedData));
} catch (error) {
console.error("AES-GCM Decryption error:", error);
throw error;
}
};You can then encrypt the attestation with your AES Key and send it as part of the request
challenge_id: A UUID string representing the unique challenge for this authentication request, returned from Initiate Authentication
Encrypt user for headers.
Response Spec
Body:
encrypted_jwt: A string containing the encrypted JSON Web Token (JWT) if authentication is successful.
Request Example
Response Example
Last updated