recover jsalmon unpacking - we'll need that for backward compatibility

This commit is contained in:
Mike Macgirvin 2024-01-28 09:31:44 +11:00
parent 868d8a3e7c
commit e7240a9867

View file

@ -73,8 +73,35 @@ class ActivityStreams
$this->valid = false;
}
}
// verify and unpack JSalmon signature if present
// This will only be the case for Zot6 packets
// JSalmon will be deprecated going forward.
if ($this->valid && is_array($this->data) && array_key_exists('signed', $this->data)) {
$ret = JSalmon::verify($this->data);
$tmp = JSalmon::unpack($this->data['data']);
if ($ret && $ret['success'] && $tmp) {
if ($ret['signer']) {
logger('Unpacked: ' . json_encode($tmp, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT), LOGGER_DATA, LOG_DEBUG);
$saved = json_encode($this->data, JSON_UNESCAPED_SLASHES);
$this->data = $tmp;
$this->raw = json_encode($tmp, JSON_UNESCAPED_SLASHES);
$this->meta['signer'] = $ret['signer'];
$this->meta['signed_data'] = $saved;
if ($ret['hubloc']) {
$this->meta['hubloc'] = $ret['hubloc'];
}
}
}
else {
logger('JSalmon verification failure.');
$this->valid = false;
}
}
}
// Attempt to assemble an Activity from what we were given.
if ($this->is_valid()) {