Identica extension fixes

This commit is contained in:
Pinga 2025-07-02 12:58:52 +03:00
parent 12c5fa3eb1
commit d7708f6fb6
5 changed files with 17 additions and 28 deletions

View file

@ -472,7 +472,7 @@ Each command section below includes real-world XML request and response samples
xsi:schemaLocation="https://namingo.org/epp/identica-1.0 identica-1.0.xsd">
<identica:nin type="personal">1234567890</identica:nin>
<identica:status>2</identica:status>
<identica:date>2025-07-02T10:34:00.000Z</identica:date>
<identica:date>2025-07-02 10:34:00.000</identica:date>
<identica:details>admin42|api|Validated via national ID system</identica:details>
</identica:infData>
</extension>
@ -556,7 +556,7 @@ Each command section below includes real-world XML request and response samples
xsi:schemaLocation="https://namingo.org/epp/identica-1.0 identica-1.0.xsd">
<identica:nin type="personal">1234567890</identica:nin>
<identica:status>2</identica:status>
<identica:date>2025-07-02T10:34:00.000Z</identica:date>
<identica:date>2025-07-02 10:34:00.000</identica:date>
<identica:details>admin42|api|Validated via national ID system</identica:details>
</identica:update>
</extension>

View file

@ -620,7 +620,7 @@ class EppWriter {
// Validation timestamp
if (!empty($resp['validation_stamp'])) {
$stamp = new \DateTime($resp['validation_stamp']);
$writer->writeElement('identica:date', $stamp->format('Y-m-d\TH:i:s.v\Z'));
$writer->writeElement('identica:date', $stamp->format('Y-m-d H:i:s.v'));
}
// Validation log

View file

@ -328,11 +328,11 @@ function processContactCreate($conn, $db, $xml, $clid, $database_type, $trans) {
}
}
$obj_ext = $xml->xpath('//identica:create')[0] ?? null;
$identicaCreate = $xml->xpath('//identica:create') ?? null;
if ($obj_ext) {
$nin = (string)$obj_ext->xpath('identica:nin')[0] ?? '';
$nin_type = (string)$obj_ext->xpath('identica:nin/@type')[0] ?? '';
if ($identicaCreate) {
$nin = (string) ($xml->xpath('//identica:nin[1]')[0] ?? null);
$nin_type = (string) ($xml->xpath('//identica:nin/@type[1]')[0] ?? null);
if (!preg_match('/\d/', $nin)) {
sendEppError($conn, $db, 2005, 'NIN should contain one or more numbers', $clTRID, $trans);

View file

@ -420,24 +420,12 @@ function processContactUpdate($conn, $db, $xml, $clid, $database_type, $trans) {
}
$identicaUpdateResults = $xml->xpath('//identica:update');
if (!empty($identicaUpdateResults)) {
$identica_update = $identicaUpdateResults[0];
} else {
$identica_update = null;
}
if ($identica_update) {
$nin = (string)$identica_update->xpath('//identica:nin[1]')[0];
$nin_type = (string)$identica_update->xpath('//identica:nin/@type[1]')[0];
$status = $identica_update->xpath('//identica:status[1]');
$statusDate = $identica_update->xpath('//identica:date[1]');
$statusDetails = $identica_update->xpath('//identica:details[1]');
$validation = isset($status[0]) ? (string)$status[0] : null;
$validation_stamp = isset($statusDate[0]) ? (string)$statusDate[0] : null;
$validation_log = isset($statusDetails[0]) ? (string)$statusDetails[0] : null;
if (isset($identicaUpdate)) {
$nin = (string) ($xml->xpath('//identica:nin[1]')[0] ?? null);
$nin_type = (string) ($xml->xpath('//identica:nin/@type[1]')[0] ?? null);
$validation = (string) ($xml->xpath('//identica:status[1]')[0] ?? null);
$validation_stamp = (string) ($xml->xpath('//identica:date[1]')[0] ?? null);
$validation_log = (string) ($xml->xpath('//identica:details[1]')[0] ?? null);
if (!preg_match('/\d/', $nin)) {
sendEppError($conn, $db, 2005, 'NIN should contain one or more numbers', $clTRID, $trans);
@ -454,8 +442,8 @@ function processContactUpdate($conn, $db, $xml, $clid, $database_type, $trans) {
return;
}
if ($validation_stamp !== null && !preg_match('/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,3})?Z$/', $validation_stamp)) {
sendEppError($conn, $db, 2005, 'Invalid status date format. Use ISO 8601 format like 2025-07-02T12:00:00.000Z', $clTRID, $trans);
if ($validation_stamp !== null && \DateTime::createFromFormat('Y-m-d H:i:s.u', $validation_stamp) === false) {
sendEppError($conn, $db, 2005, 'Validation date must be in format Y-m-d H:i:s.v (e.g. 2025-07-02 10:34:00.000)', $clTRID, $trans);
return;
}
@ -724,7 +712,7 @@ function processContactUpdate($conn, $db, $xml, $clid, $database_type, $trans) {
}
if ($identica_update) {
if ($identicaUpdate) {
$query = "
UPDATE contact
SET nin = ?, nin_type = ?, validation = ?, validation_stamp = ?, validation_log = ?, upid = ?, lastupdate = CURRENT_TIMESTAMP(3)

View file

@ -200,6 +200,7 @@ $server->handle(function (Connection $conn) use ($table, $eppExtensionsTable, $p
$xml->registerXPathNamespace('mark', 'urn:ietf:params:xml:ns:mark-1.0');
$xml->registerXPathNamespace('allocationToken', 'urn:ietf:params:xml:ns:allocationToken-1.0');
$xml->registerXPathNamespace('loginSec', 'urn:ietf:params:xml:ns:epp:loginSec-1.0');
$xml->registerXPathNamespace('identica', 'https://namingo.org/epp/identica-1.0');
if ($xml->getName() != 'epp') {
sendEppError($conn, $pdo, 2001, 'Root element must be <epp>');