Project import generated by Copybara.

GitOrigin-RevId: 63746295f1a5ab5a619056791995793d65529e62
diff --git a/src/ajax/addsecuritykey.php b/src/ajax/addsecuritykey.php
new file mode 100644
index 0000000..9a98fd0
--- /dev/null
+++ b/src/ajax/addsecuritykey.php
@@ -0,0 +1,16 @@
+<?php
+require_once(__DIR__."/../core.php");
+security::checkType(security::WORKER, security::METHOD_NOTFOUND);
+secondFactor::checkAvailability();
+
+if ($_SERVER['REQUEST_METHOD'] !== "POST") {
+  api::error('This method should be called with POST.');
+}
+
+try {
+  $result = secondFactor::createRegistrationChallenge();
+} catch (Throwable $e) {
+  api::error('An unexpected error occurred: ' . $e->getMessage());
+}
+
+api::write($result);