Initiate Registration
HTTP Method: POST
const aesEncrypt = async (
plainText: string,
encryptionKey: BufferSource,
keyFormat: "raw" = "raw",
keyLength: number = 256
) => {
if (!encryptionKey) {
throw Error("Encryption key not initialized");
}
const encoder = new TextEncoder();
const data = encoder.encode(plainText);
let cryptoKey: CryptoKey;
let encrypted: ArrayBuffer;
try {
cryptoKey = await importKey(keyFormat, encryptionKey, { name: "AES-GCM", length: keyLength }, [
"encrypt",
]);
const iv = cryptoObj.getRandomValues(new Uint8Array(12)); // Initialization vector
// Same encrypt function from "Unauthenticated Requests" guide.
encrypted = await encrypt({ name: "AES-GCM", iv }, cryptoKey, data);
const combined = new Uint8Array(iv.length + encrypted.byteLength);
combined.set(iv, 0);
combined.set(new Uint8Array(encrypted), iv.length);
return btoa(String.fromCharCode.apply(null, combined));
} catch (error) {
console.error("AES-GCM Encryption error:", error);
throw error;
}
};Response Spec
Request Example
Response Example
Last updated