Download the PHP package vzool/dove.php without Composer
On this page you can find all versions of the php package vzool/dove.php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download vzool/dove.php
More information about vzool/dove.php
Files in vzool/dove.php
Package dove.php
Short Description Dove Notification File System (DNFS)
License MIT
Homepage https://github.com/vzool/dove.php
Informations about the package dove.php
:bird: Dove Notification File System (DNFS)
Dove is a notification system based on the file storage system to deliver messages, it is working as a one-direction stream of data from the server to the clients. So, the server just puts the messages, and later the clients will check for any updates on their own schedules.
DNFS by default will store all its data in .dove
directory in the same directory where dove.php
is located, this can be changed by $path
argument in the constructor:
Dove doesn't process the sent or received data in any way like encryption or encoding, so it just acts like a bridge to transfer data from server to clients. If you have some concerns like binary data just encode them by using base64
and to maintain privacy use encryption, all that were left to the developer choices.
"Expiration of Messages" is temporarily stored in request memory when a new instance of Dove object is created, by default its value is zero which means disabled, otherwise it will be in days. If the expiration is disabled the DNFS will store all the messages without deleting any. So, the delete operation after expiration is calculated and old messages are removed when a Pull call is performed with a specific client.
DNFS is a lazy actor which it does not require any scheduled job to be active in order to do its job, it is only waiting for client action to update the status of the message.
"Integrity" is a part of zero-trust that Dove hopes to offer, and it has many options:
In general, the generation of hash and signature will happen when a new message is pushed by the Push
command and verification occurs when the Read
command is called.
The fastest option is Dove::INTEGRITY_DISABLED
then (Dove::INTEGRITY_GENERATE_HASH
or Dove::INTEGRITY_VERIFY_HASH
), then (Dove::INTEGRITY_GENERATE_SIGNATURE
or Dove::INTEGRITY_VERIFY_SIGNATURE
), while the slowest option is Dove::INTEGRITY_ALL
which it depends on the message size. So, you have to do benchmarking in order to select the best option.
To start the server it behaves similarly to the Dove
constructor:
For integrity parameter is a bitwise variable which you can combine multiple options at once like the following:
:no_entry: Cryptography Matrix
Cryptography is only limited as an option to message integrity while transfer only, Dove
deliver the messages as it is, without any encoding or encryption of the message contents.
Function | Cipher | Optional | Changeable |
---|---|---|---|
Client Reference | BLAKE2b | No | No |
Message Hash | SHA-256 | Yes | No |
Message Signature | Ed25519 | Yes | No |
Signature Encoding | base64 | Yes | No |
Times Encyption | Xsals20 + Poly1305 | No | No |
Times Encoding | base64url | No | No |
:sparkles: Motivation
The main idea came from the Passky-Server project chats on the discord server about what happened to the LastPass data breach, which affects Personally Identifiable Information (PII) and lets a bad actor uses that information to stage a Phishing-Attack. There were many ideas shared, one of them was Zica Zajc who is a great man and the CEO of Passky project, he suggested that the server can store the messages and the clients will check them later. So, I thought it will be a better for everyone to consildate this idea into a usable library.
:eyes: Anatomy
Dove is a very small library that is less than 180 LOC (lines of code), and the core implementation took only about 59%, 10% for HTTP handling and the rest is for testing.
Yes, one single file has them all, dove.php
file contains the implementation, HTTP router, and testing, isn't this great? :yum::v:
In fact, Dove is a special library in which you can use the single file dove.php
, or install it via composer without any namespaces required. Both of these methods will make you use the full functions of the library.
Dove Storage Data Structure (DSDS)
The .dove
directory can be in a public path with a directory listing feature if it does support by the web server, but you can also put it in a private location and DNFS will be the only access point to those data.
REST API Pull Request
That was a list of times, in descending order from the newest to the old. So, by selecting a time you can ask for the latest messages after that time, or read the message contents.
REST API Pull Request After Some Time
REST API Pull Request After Last Time
REST API Read Request
DNFS tries to implement zero-trust by making a clear border between inside and outside, so it always encodes times automatically, and the key used to encode/decode will be changed automatically, according to dove.php
contents, file state and location.
If dove.php
identity changed then .dove
entire folder will be deleted automatically.
So, if the client got some time references then the dove.php
contents got updated somehow or the file location changed, then the old references will not work unless the client asks for new references, and then the client can get the rest of the messages with updated references.
REST API Read Request with Invalid Signature
Here the signature is invalid while the hash is valid because the hash is about the message content only, while the signature involves the source code of dove.php
itself as the source of truth, which has changed and makes all new keypair, then all past signatures are invalid by default.
In a normal situation, and while messages are in transmission the dove.php
file should not be changed, except if there is an urgent update, so the developer later can decide if this is acceptable or cancel all messages and create new ones if needed.
REST API Read Request with Missing Message
:office: Requirements
- PHP 7.3+
:anchor: Installation & Usage
Dove project will do its best to be compatible with all its released versions, so in future development releases, there will be no breaking changes.
:wrench: Single File Library (Server-Side)
The whole library is just a single file called dove.php
, so you can just copy and paste it where ever is relevant to you.
Use the following when you want to process messages:
Then, to handle client requests run the following:
:musical_note: Composer Dependency Manager for PHP (Server-Side)
Use the following when you want to process messages:
Then, to handle client requests only include this in the path of $_REQUEST
and it will handle the requests automatically.
:earth_africa: HTTP REST API (Client-Side) [GET/POST/ANY]
-
Pull all times of messages:
http://localhost:8080/dove.php?client=abdelaziz&cmd=pull
orhttp://localhost:8080/dove.php?client=abdelaziz
-
Pull the latest times of messages after the time (369):
http://localhost:8080/dove.php?client=abdelaziz&cmd=pull&time=369
orhttp://localhost:8080/dove.php?&client=abdelaziz&time=369
- Read a message in its time
http://localhost:8080/dove.php?client=abdelaziz&cmd=read&time=369
:checkered_flag: Benchmark
- CPU: 3.7 GHz 6-Core Intel Core i5
- RAM: 72 GB 2667 MHz DDR4
- OS: masOS Ventura 13.1
You can run your own benchmarks on your PC with the following command php benchmark.php
:microscope: Test
It should work without any issues, otherwise, an exception will be thrown.
:crystal_ball: Future Development
DNFS
library can be part of your own Cloud ecosystem in which there are installed applications for services in the client's device and those app clients pull status and notification from the cloud on regular basis, just like Google they have "Google Play Services" or Huawei with their app HMS (Huawei Mobile Services), of course, Google and Huawei are big companies which they always building their own technology infrastructure, but, Dove
can give you something that tasty, simple and reliable.
Don't forget that Google company started from the Garage, So start building your Garage. :joy::v: