Compare commits
No commits in common. "main" and "d2ea2a7284f6c4a7e21f597dd46f43803fa8743d" have entirely different histories.
main
...
d2ea2a7284
30
.github/workflows/ci_arch.yml
vendored
30
.github/workflows/ci_arch.yml
vendored
@ -1,30 +0,0 @@
|
||||
name: CI (Arch Linux)
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ main ]
|
||||
pull_request:
|
||||
branches: [ main ]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: archlinux:latest
|
||||
env:
|
||||
CGO_ENABLED: "0"
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
pacman -Sy --noconfirm git base-devel go
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: '1.27'
|
||||
- name: Build
|
||||
run: go build ./...
|
||||
- name: Test
|
||||
run: go test ./... -v
|
||||
- name: Lint
|
||||
run: go vet ./...
|
||||
29
.gitignore
vendored
29
.gitignore
vendored
@ -1,29 +0,0 @@
|
||||
# Binaries and build artifacts
|
||||
bin/
|
||||
dist/
|
||||
*.exe
|
||||
*.exe~
|
||||
*.dll
|
||||
*.so
|
||||
*.dylib
|
||||
omnichannel-hub
|
||||
*.tar.gz
|
||||
*.zip
|
||||
|
||||
# Encrypted Vault and runtime data
|
||||
data/
|
||||
*.enc
|
||||
*.db
|
||||
*.sqlite
|
||||
*.log
|
||||
|
||||
# IDE & OS files
|
||||
.vscode/
|
||||
.idea/
|
||||
.DS_Store
|
||||
*.swp
|
||||
*.swo
|
||||
|
||||
# Test coverage
|
||||
coverage.txt
|
||||
coverage.html
|
||||
674
LICENSE
674
LICENSE
@ -1,674 +0,0 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<https://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
||||
104
README.md
104
README.md
@ -1,104 +0,0 @@
|
||||
# 🌐 omnichannel-hub
|
||||
|
||||
[](https://github.com/benzjeremy/omnichannel-hub/releases)
|
||||
[](https://github.com/benzjeremy/omnichannel-hub)
|
||||
[](https://github.com/benzjeremy/omnichannel-hub/blob/main/LICENSE)
|
||||
[](https://golang.org)
|
||||
[](https://benzjeremy.github.io/omnichannel-hub/)
|
||||
[](https://benzjeremy.github.io/)
|
||||
|
||||
> [!IMPORTANT]
|
||||
> ### 🚧 Pre-Release / Active Development Notice
|
||||
> **This software is not yet finished and is actively being worked on.**
|
||||
> All releases, builds, and versions are **Pre-Releases** (Work in Progress), even if originally tagged without a pre-release flag. Unified broker integrations, security pipelines, and protocols are under active ongoing development.
|
||||
|
||||
> **Unified Messaging Hub & Self-Hosted Communication Broker in Go 1.22**
|
||||
> Centralized, self-hosted communication router bundling Email (IMAP/SMTP TLS), WhatsApp, and Discord with zero cloud relays and hardened AES-256-GCM encryption.
|
||||
|
||||
---
|
||||
|
||||
## ⚡ Why omnichannel-hub?
|
||||
|
||||
Modern communication channels like Email, WhatsApp, and Discord are heavily fragmented. Traditional multi-messenger solutions rely on resource-hungry Electron instances containing dozens of embedded iframes, or route private messages through third-party cloud infrastructure.
|
||||
|
||||
`omnichannel-hub` offers a radically lightweight, secure alternative:
|
||||
1. **Zero Cloud Relays:** No storage on third-party cloud servers. All messages and credentials reside encrypted on your own machine.
|
||||
2. **Unified Message Broker:** Decoupled architecture utilizing Go channels for real-time aggregation and dispatching.
|
||||
3. **Cross-Platform:** Unified abstraction layer for Email (IMAP/SMTP), Discord Bot Gateway, and WhatsApp Web Bridge.
|
||||
4. **Resource-Efficient:** Minimal memory footprint (< 30 MB RAM) written in pure Go without forced CGO dependencies.
|
||||
5. **Zero-Dummy-Security:** AES-256-GCM vault with PBKDF2 (100,000 rounds), 32-byte tokens, anti-DNS-rebinding, and anti-CSRF protection.
|
||||
|
||||
---
|
||||
|
||||
## 🛡️ Zero-Dummy-Security (Production-Hardened by Default)
|
||||
|
||||
- **AES-256-GCM Encryption:** All stored messages, accounts, and credentials/tokens are cryptographically protected in `hub_vault.enc`.
|
||||
- **PBKDF2 Key Derivation:** At least **100,000 iterations** with SHA-256 and a 32-byte cryptographic random salt.
|
||||
- **Strict Localhost Isolation:** Binds strictly to `127.0.0.1:8082`. No exposure to external networks without an explicit reverse proxy.
|
||||
- **Cryptographic Token Authentication:** Every API request requires a 32-byte CSPRNG token (`X-Hub-Token`).
|
||||
- **Anti-DNS-Rebinding & Anti-CSRF:** Strict validation of `Host` and `Origin` headers.
|
||||
|
||||
---
|
||||
|
||||
## 📦 Multi-Platform Installation & Download
|
||||
|
||||
### Via Go Install:
|
||||
```bash
|
||||
go install github.com/benzjeremy/omnichannel-hub@latest
|
||||
```
|
||||
|
||||
### Linux (x86_64):
|
||||
```bash
|
||||
tar -xzf omnichannel-hub-v1.0-linux.tar.gz
|
||||
sudo cp omnichannel-hub /usr/local/bin/
|
||||
omnichannel-hub --email-address benzjeremy@pm.me
|
||||
```
|
||||
|
||||
### Windows (x86_64):
|
||||
Extract `omnichannel-hub-v1.0-windows.zip` and run `omnichannel-hub.exe`.
|
||||
|
||||
---
|
||||
|
||||
## 🚀 CLI Flags
|
||||
|
||||
```text
|
||||
Usage of omnichannel-hub:
|
||||
--port int Port to listen on (default 8082, binds to 127.0.0.1)
|
||||
--token string 32-byte security token (auto-generated if omitted)
|
||||
--data-dir string Directory for encrypted storage vault (default "data")
|
||||
--email-address string Default monitored email address (default "benzjeremy@pm.me")
|
||||
--discord-bot string Default discord bot identifier (default "HubBot#0001")
|
||||
--whatsapp-phone str Default WhatsApp phone number (default "+491701234567")
|
||||
--version Print version and exit
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🌐 REST API Endpoints
|
||||
|
||||
All endpoints (except `/health`) require the header `X-Hub-Token: <token>`.
|
||||
|
||||
| Method | Path | Description |
|
||||
|---|---|---|
|
||||
| `GET` | `/health` | Service status, version info, and active channel states |
|
||||
| `GET` | `/messages` | Retrieve messages (Filters: `channel`, `direction`, `unread`, `limit`) |
|
||||
| `POST` | `/messages/send` | Send message via selected channel (`email`, `whatsapp`, `discord`) |
|
||||
| `POST` | `/messages/read` | Mark message as read by ID |
|
||||
| `GET` | `/channels` | Overview of registered channels and account configurations |
|
||||
| `POST` | `/channels` | Register or update communication account credentials |
|
||||
| `GET` | `/stats` | Live counters for inbound and outbound messages per channel |
|
||||
|
||||
---
|
||||
|
||||
## 👥 Contributors & Credits
|
||||
|
||||
- **Jeremy Benz** ([@benzjeremy](https://github.com/benzjeremy) & [@jbenz1706](https://github.com/jbenz1706)) – Project Founder & Lead Developer
|
||||
- **AI Assistants (Pair Programming):** Google Antigravity & Claude Code
|
||||
- © 2026 Jeremy Benz
|
||||
|
||||
---
|
||||
|
||||
## 📄 License
|
||||
|
||||
This project is licensed under the **GNU General Public License, Version 3 (GPL-3.0)**.
|
||||
See [LICENSE](LICENSE) for details.
|
||||
323
api/server.go
323
api/server.go
@ -1,323 +0,0 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/rand"
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/benzjeremy/omnichannel-hub/broker"
|
||||
"github.com/benzjeremy/omnichannel-hub/collectors"
|
||||
"github.com/benzjeremy/omnichannel-hub/models"
|
||||
"github.com/benzjeremy/omnichannel-hub/storage"
|
||||
)
|
||||
|
||||
// ServerConfig holds API parameters.
|
||||
type ServerConfig struct {
|
||||
Port int
|
||||
Token string
|
||||
Version string
|
||||
}
|
||||
|
||||
// Server provides the secured unified messaging HTTP interface.
|
||||
type Server struct {
|
||||
config ServerConfig
|
||||
token string
|
||||
vault *storage.Vault
|
||||
broker *broker.Broker
|
||||
manager *collectors.Manager
|
||||
server *http.Server
|
||||
listener net.Listener
|
||||
}
|
||||
|
||||
// NewServer initializes a new secured API server.
|
||||
func NewServer(cfg ServerConfig, v *storage.Vault, b *broker.Broker, m *collectors.Manager) (*Server, error) {
|
||||
tok := cfg.Token
|
||||
if tok == "" {
|
||||
b := make([]byte, 32)
|
||||
if _, err := rand.Read(b); err != nil {
|
||||
return nil, fmt.Errorf("failed generating CSPRNG token: %w", err)
|
||||
}
|
||||
tok = hex.EncodeToString(b)
|
||||
}
|
||||
|
||||
if cfg.Port <= 0 {
|
||||
cfg.Port = 8082
|
||||
}
|
||||
if cfg.Version == "" {
|
||||
cfg.Version = "v1.0"
|
||||
}
|
||||
|
||||
return &Server{
|
||||
config: cfg,
|
||||
token: tok,
|
||||
vault: v,
|
||||
broker: b,
|
||||
manager: m,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// Token returns the active 32-byte security token.
|
||||
func (s *Server) Token() string {
|
||||
return s.token
|
||||
}
|
||||
|
||||
// Start begins serving on 127.0.0.1:port.
|
||||
func (s *Server) Start() error {
|
||||
addr := fmt.Sprintf("127.0.0.1:%d", s.config.Port)
|
||||
ln, err := net.Listen("tcp", addr)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to bind to %s: %w", addr, err)
|
||||
}
|
||||
s.listener = ln
|
||||
|
||||
mux := http.NewServeMux()
|
||||
mux.HandleFunc("/health", s.handleHealth)
|
||||
mux.HandleFunc("/messages", s.handleMessages)
|
||||
mux.HandleFunc("/messages/send", s.handleSend)
|
||||
mux.HandleFunc("/messages/read", s.handleMarkRead)
|
||||
mux.HandleFunc("/channels", s.handleChannels)
|
||||
mux.HandleFunc("/stats", s.handleStats)
|
||||
|
||||
handler := s.securityMiddleware(mux)
|
||||
|
||||
s.server = &http.Server{
|
||||
Handler: handler,
|
||||
ReadTimeout: 30 * time.Second,
|
||||
WriteTimeout: 60 * time.Second,
|
||||
}
|
||||
|
||||
go s.server.Serve(ln)
|
||||
return nil
|
||||
}
|
||||
|
||||
// Stop gracefully shuts down the server.
|
||||
func (s *Server) Stop(ctx context.Context) error {
|
||||
if s.server != nil {
|
||||
return s.server.Shutdown(ctx)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Addr returns the listening address.
|
||||
func (s *Server) Addr() string {
|
||||
if s.listener != nil {
|
||||
return s.listener.Addr().String()
|
||||
}
|
||||
return fmt.Sprintf("127.0.0.1:%d", s.config.Port)
|
||||
}
|
||||
|
||||
func (s *Server) securityMiddleware(next http.Handler) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
// 1. Mandatory Security Headers
|
||||
w.Header().Set("X-Content-Type-Options", "nosniff")
|
||||
w.Header().Set("X-Frame-Options", "DENY")
|
||||
w.Header().Set("Referrer-Policy", "no-referrer")
|
||||
w.Header().Set("Content-Security-Policy", "default-src 'none'")
|
||||
|
||||
// 2. Anti-DNS-Rebinding
|
||||
host := r.Host
|
||||
if strings.Contains(host, ":") {
|
||||
host, _, _ = net.SplitHostPort(host)
|
||||
}
|
||||
if host != "127.0.0.1" && host != "localhost" && host != "" {
|
||||
http.Error(w, `{"error":"forbidden: dns rebinding protection"}`, http.StatusForbidden)
|
||||
return
|
||||
}
|
||||
|
||||
// 3. Anti-CSRF
|
||||
origin := r.Header.Get("Origin")
|
||||
if origin != "" && origin != "null" {
|
||||
if !strings.HasPrefix(origin, "http://127.0.0.1") && !strings.HasPrefix(origin, "http://localhost") {
|
||||
http.Error(w, `{"error":"forbidden: cross-origin request blocked"}`, http.StatusForbidden)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// 4. Token validation (health exempt)
|
||||
if r.URL.Path != "/health" {
|
||||
authHeader := r.Header.Get("X-Hub-Token")
|
||||
if authHeader == "" {
|
||||
authHeader = r.URL.Query().Get("token")
|
||||
}
|
||||
if authHeader != s.token {
|
||||
http.Error(w, `{"error":"unauthorized: invalid or missing security token"}`, http.StatusUnauthorized)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
next.ServeHTTP(w, r)
|
||||
})
|
||||
}
|
||||
|
||||
func (s *Server) handleHealth(w http.ResponseWriter, r *http.Request) {
|
||||
if r.Method != http.MethodGet {
|
||||
http.Error(w, `{"error":"method not allowed"}`, http.StatusMethodNotAllowed)
|
||||
return
|
||||
}
|
||||
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
json.NewEncoder(w).Encode(map[string]interface{}{
|
||||
"status": "ok",
|
||||
"service": "omnichannel-hub",
|
||||
"version": s.config.Version,
|
||||
"channels": s.manager.ListChannels(),
|
||||
"timestamp": time.Now().UTC().Format(time.RFC3339),
|
||||
})
|
||||
}
|
||||
|
||||
func (s *Server) handleMessages(w http.ResponseWriter, r *http.Request) {
|
||||
if r.Method != http.MethodGet {
|
||||
http.Error(w, `{"error":"method not allowed"}`, http.StatusMethodNotAllowed)
|
||||
return
|
||||
}
|
||||
|
||||
q := r.URL.Query()
|
||||
filter := models.MessageFilter{
|
||||
Channel: models.ChannelType(q.Get("channel")),
|
||||
Direction: models.MessageDirection(q.Get("direction")),
|
||||
UnreadOnly: q.Get("unread") == "true",
|
||||
}
|
||||
|
||||
if limitStr := q.Get("limit"); limitStr != "" {
|
||||
if limit, err := strconv.Atoi(limitStr); err == nil && limit > 0 {
|
||||
filter.Limit = limit
|
||||
}
|
||||
}
|
||||
|
||||
msgs := s.vault.GetMessages(filter)
|
||||
if msgs == nil {
|
||||
msgs = make([]models.Message, 0)
|
||||
}
|
||||
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
json.NewEncoder(w).Encode(map[string]interface{}{
|
||||
"count": len(msgs),
|
||||
"messages": msgs,
|
||||
})
|
||||
}
|
||||
|
||||
type SendRequest struct {
|
||||
Channel models.ChannelType `json:"channel"`
|
||||
Recipient string `json:"recipient"`
|
||||
Subject string `json:"subject,omitempty"`
|
||||
Body string `json:"body"`
|
||||
Sender string `json:"sender,omitempty"`
|
||||
}
|
||||
|
||||
func (s *Server) handleSend(w http.ResponseWriter, r *http.Request) {
|
||||
if r.Method != http.MethodPost {
|
||||
http.Error(w, `{"error":"method not allowed"}`, http.StatusMethodNotAllowed)
|
||||
return
|
||||
}
|
||||
|
||||
var req SendRequest
|
||||
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
|
||||
http.Error(w, `{"error":"invalid json body"}`, http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
if req.Channel == "" || req.Recipient == "" || req.Body == "" {
|
||||
http.Error(w, `{"error":"channel, recipient and body are required"}`, http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
sender := req.Sender
|
||||
if sender == "" {
|
||||
sender = "Jeremy Benz (Hub)"
|
||||
}
|
||||
|
||||
msg := models.NewMessage(req.Channel, models.DirectionOutbound, sender, req.Recipient, req.Subject, req.Body)
|
||||
if err := s.manager.Send(&msg); err != nil {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(http.StatusBadRequest)
|
||||
json.NewEncoder(w).Encode(map[string]string{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
json.NewEncoder(w).Encode(map[string]interface{}{
|
||||
"status": "dispatched",
|
||||
"message": msg,
|
||||
})
|
||||
}
|
||||
|
||||
type MarkReadRequest struct {
|
||||
ID string `json:"id"`
|
||||
}
|
||||
|
||||
func (s *Server) handleMarkRead(w http.ResponseWriter, r *http.Request) {
|
||||
if r.Method != http.MethodPost {
|
||||
http.Error(w, `{"error":"method not allowed"}`, http.StatusMethodNotAllowed)
|
||||
return
|
||||
}
|
||||
|
||||
var req MarkReadRequest
|
||||
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
|
||||
http.Error(w, `{"error":"invalid json body"}`, http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
if err := s.vault.MarkRead(req.ID); err != nil {
|
||||
http.Error(w, fmt.Sprintf(`{"error":"%v"}`, err), http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
json.NewEncoder(w).Encode(map[string]string{
|
||||
"status": "success",
|
||||
"message": "Message marked as read",
|
||||
})
|
||||
}
|
||||
|
||||
func (s *Server) handleChannels(w http.ResponseWriter, r *http.Request) {
|
||||
if r.Method == http.MethodGet {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
json.NewEncoder(w).Encode(map[string]interface{}{
|
||||
"active_channels": s.manager.ListChannels(),
|
||||
"accounts": s.vault.GetAccounts(),
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
if r.Method == http.MethodPost {
|
||||
var acc models.Account
|
||||
if err := json.NewDecoder(r.Body).Decode(&acc); err != nil {
|
||||
http.Error(w, `{"error":"invalid json"}`, http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
if acc.ID == "" {
|
||||
acc.ID = fmt.Sprintf("acc-%d", time.Now().UnixNano())
|
||||
}
|
||||
if err := s.vault.SaveAccount(acc); err != nil {
|
||||
http.Error(w, fmt.Sprintf(`{"error":"failed saving account: %v"}`, err), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
json.NewEncoder(w).Encode(map[string]interface{}{
|
||||
"status": "saved",
|
||||
"account": acc,
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
http.Error(w, `{"error":"method not allowed"}`, http.StatusMethodNotAllowed)
|
||||
}
|
||||
|
||||
func (s *Server) handleStats(w http.ResponseWriter, r *http.Request) {
|
||||
if r.Method != http.MethodGet {
|
||||
http.Error(w, `{"error":"method not allowed"}`, http.StatusMethodNotAllowed)
|
||||
return
|
||||
}
|
||||
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
json.NewEncoder(w).Encode(map[string]interface{}{
|
||||
"channel_stats": s.broker.GetStats(),
|
||||
})
|
||||
}
|
||||
@ -1,154 +0,0 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"github.com/benzjeremy/omnichannel-hub/broker"
|
||||
"github.com/benzjeremy/omnichannel-hub/collectors"
|
||||
"github.com/benzjeremy/omnichannel-hub/models"
|
||||
"github.com/benzjeremy/omnichannel-hub/storage"
|
||||
)
|
||||
|
||||
func setupTestServer(t *testing.T) (*Server, *httptest.Server, func()) {
|
||||
tmpDir, _ := os.MkdirTemp("", "api_hub_test_*")
|
||||
vault, _ := storage.OpenVault(filepath.Join(tmpDir, "vault.enc"), "APITestSecret123!")
|
||||
brk := broker.NewBroker(vault)
|
||||
mgr := collectors.NewManager(brk)
|
||||
|
||||
// Register collectors
|
||||
mgr.Register(collectors.NewEmailCollector("email-1", "test@benzjeremy.de", brk))
|
||||
mgr.Register(collectors.NewDiscordCollector("discord-1", "HubBot", brk))
|
||||
|
||||
cfg := ServerConfig{
|
||||
Port: 0,
|
||||
Token: "super-secure-fixed-32-byte-token-2026",
|
||||
Version: "v1.0",
|
||||
}
|
||||
|
||||
srv, err := NewServer(cfg, vault, brk, mgr)
|
||||
if err != nil {
|
||||
t.Fatalf("NewServer failed: %v", err)
|
||||
}
|
||||
|
||||
mux := http.NewServeMux()
|
||||
mux.HandleFunc("/health", srv.handleHealth)
|
||||
mux.HandleFunc("/messages", srv.handleMessages)
|
||||
mux.HandleFunc("/messages/send", srv.handleSend)
|
||||
mux.HandleFunc("/messages/read", srv.handleMarkRead)
|
||||
mux.HandleFunc("/channels", srv.handleChannels)
|
||||
mux.HandleFunc("/stats", srv.handleStats)
|
||||
|
||||
handler := srv.securityMiddleware(mux)
|
||||
ts := httptest.NewServer(handler)
|
||||
|
||||
cleanup := func() {
|
||||
ts.Close()
|
||||
os.RemoveAll(tmpDir)
|
||||
}
|
||||
|
||||
return srv, ts, cleanup
|
||||
}
|
||||
|
||||
func TestHealthEndpoint(t *testing.T) {
|
||||
_, ts, cleanup := setupTestServer(t)
|
||||
defer cleanup()
|
||||
|
||||
resp, err := http.Get(ts.URL + "/health")
|
||||
if err != nil {
|
||||
t.Fatalf("GET /health failed: %v", err)
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
t.Errorf("Expected 200 OK, got %d", resp.StatusCode)
|
||||
}
|
||||
}
|
||||
|
||||
func TestTokenAndHeadersSecurity(t *testing.T) {
|
||||
_, ts, cleanup := setupTestServer(t)
|
||||
defer cleanup()
|
||||
|
||||
// 1. Without Token -> 401
|
||||
resp, err := http.Get(ts.URL + "/messages")
|
||||
if err != nil {
|
||||
t.Fatalf("GET /messages failed: %v", err)
|
||||
}
|
||||
resp.Body.Close()
|
||||
if resp.StatusCode != http.StatusUnauthorized {
|
||||
t.Errorf("Expected 401 without token, got %d", resp.StatusCode)
|
||||
}
|
||||
|
||||
// 2. With valid token
|
||||
client := &http.Client{}
|
||||
req, _ := http.NewRequest(http.MethodGet, ts.URL+"/messages", nil)
|
||||
req.Header.Set("X-Hub-Token", "super-secure-fixed-32-byte-token-2026")
|
||||
|
||||
resp2, err := client.Do(req)
|
||||
if err != nil {
|
||||
t.Fatalf("GET /messages with token failed: %v", err)
|
||||
}
|
||||
defer resp2.Body.Close()
|
||||
|
||||
if resp2.StatusCode != http.StatusOK {
|
||||
t.Errorf("Expected 200 OK with token, got %d", resp2.StatusCode)
|
||||
}
|
||||
if resp2.Header.Get("X-Frame-Options") != "DENY" || resp2.Header.Get("X-Content-Type-Options") != "nosniff" {
|
||||
t.Errorf("Missing security headers: %v", resp2.Header)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSendAndMarkRead(t *testing.T) {
|
||||
_, ts, cleanup := setupTestServer(t)
|
||||
defer cleanup()
|
||||
|
||||
client := &http.Client{}
|
||||
|
||||
// Send outbound email
|
||||
sendPayload := map[string]interface{}{
|
||||
"channel": "email",
|
||||
"recipient": "user@domain.com",
|
||||
"subject": "Projekt Update",
|
||||
"body": "Das System läuft stabil.",
|
||||
}
|
||||
payloadBytes, _ := json.Marshal(sendPayload)
|
||||
|
||||
req, _ := http.NewRequest(http.MethodPost, ts.URL+"/messages/send", bytes.NewReader(payloadBytes))
|
||||
req.Header.Set("X-Hub-Token", "super-secure-fixed-32-byte-token-2026")
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
t.Fatalf("POST /messages/send failed: %v", err)
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
t.Errorf("Expected 200 OK on send, got %d", resp.StatusCode)
|
||||
}
|
||||
|
||||
// Retrieve messages
|
||||
reqGet, _ := http.NewRequest(http.MethodGet, ts.URL+"/messages", nil)
|
||||
reqGet.Header.Set("X-Hub-Token", "super-secure-fixed-32-byte-token-2026")
|
||||
|
||||
respGet, err := client.Do(reqGet)
|
||||
if err != nil {
|
||||
t.Fatalf("GET /messages failed: %v", err)
|
||||
}
|
||||
defer respGet.Body.Close()
|
||||
|
||||
var resData struct {
|
||||
Count int `json:"count"`
|
||||
Messages []models.Message `json:"messages"`
|
||||
}
|
||||
json.NewDecoder(respGet.Body).Decode(&resData)
|
||||
|
||||
if resData.Count != 1 || resData.Messages[0].Recipient != "user@domain.com" {
|
||||
t.Errorf("Unexpected messages list: %+v", resData)
|
||||
}
|
||||
}
|
||||
BIN
bin/omnichannel-hub-linux-amd64
Executable file
BIN
bin/omnichannel-hub-linux-amd64
Executable file
Binary file not shown.
BIN
bin/omnichannel-hub-windows-amd64.exe
Executable file
BIN
bin/omnichannel-hub-windows-amd64.exe
Executable file
Binary file not shown.
@ -1,92 +0,0 @@
|
||||
package broker
|
||||
|
||||
import (
|
||||
"sync"
|
||||
|
||||
"github.com/benzjeremy/omnichannel-hub/models"
|
||||
"github.com/benzjeremy/omnichannel-hub/storage"
|
||||
)
|
||||
|
||||
// Broker handles message routing, fan-out to subscribers, and persistence.
|
||||
type Broker struct {
|
||||
mu sync.RWMutex
|
||||
vault *storage.Vault
|
||||
subscribers map[chan *models.Message]struct{}
|
||||
stats map[models.ChannelType]ChannelStats
|
||||
}
|
||||
|
||||
// ChannelStats tracks metrics per communication channel.
|
||||
type ChannelStats struct {
|
||||
TotalInbound int `json:"total_inbound"`
|
||||
TotalOutbound int `json:"total_outbound"`
|
||||
}
|
||||
|
||||
// NewBroker creates a central message broker.
|
||||
func NewBroker(v *storage.Vault) *Broker {
|
||||
return &Broker{
|
||||
vault: v,
|
||||
subscribers: make(map[chan *models.Message]struct{}),
|
||||
stats: make(map[models.ChannelType]ChannelStats),
|
||||
}
|
||||
}
|
||||
|
||||
// Publish stores the message safely and broadcasts it to all active listeners.
|
||||
func (b *Broker) Publish(msg *models.Message) error {
|
||||
b.mu.Lock()
|
||||
defer b.mu.Unlock()
|
||||
|
||||
// Persist to encrypted vault
|
||||
if err := b.vault.SaveMessage(*msg); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Update stats
|
||||
s := b.stats[msg.Channel]
|
||||
if msg.Direction == models.DirectionInbound {
|
||||
s.TotalInbound++
|
||||
} else {
|
||||
s.TotalOutbound++
|
||||
}
|
||||
b.stats[msg.Channel] = s
|
||||
|
||||
// Broadcast non-blocking to all subscribers
|
||||
for ch := range b.subscribers {
|
||||
select {
|
||||
case ch <- msg:
|
||||
default:
|
||||
// Slow consumer drop to avoid stalling broker
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Subscribe returns a channel receiving all published messages and an unsubscribe callback.
|
||||
func (b *Broker) Subscribe() (chan *models.Message, func()) {
|
||||
b.mu.Lock()
|
||||
defer b.mu.Unlock()
|
||||
|
||||
ch := make(chan *models.Message, 100)
|
||||
b.subscribers[ch] = struct{}{}
|
||||
|
||||
unsub := func() {
|
||||
b.mu.Lock()
|
||||
defer b.mu.Unlock()
|
||||
delete(b.subscribers, ch)
|
||||
close(ch)
|
||||
}
|
||||
|
||||
return ch, unsub
|
||||
}
|
||||
|
||||
// GetStats returns current message counters.
|
||||
func (b *Broker) GetStats() map[models.ChannelType]ChannelStats {
|
||||
b.mu.RLock()
|
||||
defer b.mu.RUnlock()
|
||||
|
||||
copyStats := make(map[models.ChannelType]ChannelStats, len(b.stats))
|
||||
for k, v := range b.stats {
|
||||
copyStats[k] = v
|
||||
}
|
||||
return copyStats
|
||||
}
|
||||
@ -1,41 +0,0 @@
|
||||
package broker
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/benzjeremy/omnichannel-hub/models"
|
||||
"github.com/benzjeremy/omnichannel-hub/storage"
|
||||
)
|
||||
|
||||
func TestBrokerPubSub(t *testing.T) {
|
||||
tmpDir, _ := os.MkdirTemp("", "broker_test_*")
|
||||
defer os.RemoveAll(tmpDir)
|
||||
|
||||
v, _ := storage.OpenVault(filepath.Join(tmpDir, "vault.enc"), "BrokerSecretKey123!")
|
||||
brk := NewBroker(v)
|
||||
|
||||
ch, unsub := brk.Subscribe()
|
||||
defer unsub()
|
||||
|
||||
msg := models.NewMessage(models.ChannelWhatsApp, models.DirectionInbound, "+491701234567", "Hub", "", "Hallo von WhatsApp!")
|
||||
if err := brk.Publish(&msg); err != nil {
|
||||
t.Fatalf("Publish failed: %v", err)
|
||||
}
|
||||
|
||||
select {
|
||||
case received := <-ch:
|
||||
if received.Body != "Hallo von WhatsApp!" {
|
||||
t.Errorf("Unexpected message body: %s", received.Body)
|
||||
}
|
||||
case <-time.After(2 * time.Second):
|
||||
t.Fatalf("Timeout waiting for message on subscription channel")
|
||||
}
|
||||
|
||||
stats := brk.GetStats()
|
||||
if stats[models.ChannelWhatsApp].TotalInbound != 1 {
|
||||
t.Errorf("Expected 1 inbound whatsapp message in stats, got %d", stats[models.ChannelWhatsApp].TotalInbound)
|
||||
}
|
||||
}
|
||||
@ -1,103 +0,0 @@
|
||||
package collectors
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"sync"
|
||||
|
||||
"github.com/benzjeremy/omnichannel-hub/broker"
|
||||
"github.com/benzjeremy/omnichannel-hub/models"
|
||||
)
|
||||
|
||||
// Collector defines standard operations for external communication channels.
|
||||
type Collector interface {
|
||||
ID() string
|
||||
Type() models.ChannelType
|
||||
Start(ctx context.Context) error
|
||||
Stop() error
|
||||
Send(msg *models.Message) error
|
||||
}
|
||||
|
||||
// Manager orchestrates lifecycle and dispatching across all active collectors.
|
||||
type Manager struct {
|
||||
mu sync.RWMutex
|
||||
broker *broker.Broker
|
||||
collectors map[models.ChannelType]Collector
|
||||
}
|
||||
|
||||
// NewManager creates an initialized collectors manager.
|
||||
func NewManager(b *broker.Broker) *Manager {
|
||||
return &Manager{
|
||||
broker: b,
|
||||
collectors: make(map[models.ChannelType]Collector),
|
||||
}
|
||||
}
|
||||
|
||||
// Register registers a new channel collector.
|
||||
func (m *Manager) Register(c Collector) {
|
||||
m.mu.Lock()
|
||||
defer m.mu.Unlock()
|
||||
m.collectors[c.Type()] = c
|
||||
}
|
||||
|
||||
// GetCollector retrieves a collector by channel type.
|
||||
func (m *Manager) GetCollector(t models.ChannelType) (Collector, bool) {
|
||||
m.mu.RLock()
|
||||
defer m.mu.RUnlock()
|
||||
c, ok := m.collectors[t]
|
||||
return c, ok
|
||||
}
|
||||
|
||||
// StartAll starts all registered collectors.
|
||||
func (m *Manager) StartAll(ctx context.Context) {
|
||||
m.mu.RLock()
|
||||
defer m.mu.RUnlock()
|
||||
|
||||
for _, c := range m.collectors {
|
||||
go c.Start(ctx)
|
||||
}
|
||||
}
|
||||
|
||||
// StopAll terminates all running collectors.
|
||||
func (m *Manager) StopAll() {
|
||||
m.mu.RLock()
|
||||
defer m.mu.RUnlock()
|
||||
|
||||
for _, c := range m.collectors {
|
||||
c.Stop()
|
||||
}
|
||||
}
|
||||
|
||||
// Send routes an outgoing message through the appropriate channel collector.
|
||||
func (m *Manager) Send(msg *models.Message) error {
|
||||
m.mu.RLock()
|
||||
c, ok := m.collectors[msg.Channel]
|
||||
m.mu.RUnlock()
|
||||
|
||||
if !ok {
|
||||
return fmt.Errorf("no collector registered for channel type: %s", msg.Channel)
|
||||
}
|
||||
|
||||
msg.Direction = models.DirectionOutbound
|
||||
msg.Read = true
|
||||
|
||||
// Send through collector
|
||||
if err := c.Send(msg); err != nil {
|
||||
return fmt.Errorf("failed sending via %s: %w", msg.Channel, err)
|
||||
}
|
||||
|
||||
// Publish to broker to record and inform frontend
|
||||
return m.broker.Publish(msg)
|
||||
}
|
||||
|
||||
// ListChannels returns all registered channel types.
|
||||
func (m *Manager) ListChannels() []models.ChannelType {
|
||||
m.mu.RLock()
|
||||
defer m.mu.RUnlock()
|
||||
|
||||
var types []models.ChannelType
|
||||
for t := range m.collectors {
|
||||
types = append(types, t)
|
||||
}
|
||||
return types
|
||||
}
|
||||
@ -1,76 +0,0 @@
|
||||
package collectors
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/benzjeremy/omnichannel-hub/broker"
|
||||
"github.com/benzjeremy/omnichannel-hub/models"
|
||||
"github.com/benzjeremy/omnichannel-hub/storage"
|
||||
)
|
||||
|
||||
func TestCollectorsAndManager(t *testing.T) {
|
||||
tmpDir, _ := os.MkdirTemp("", "collectors_test_*")
|
||||
defer os.RemoveAll(tmpDir)
|
||||
|
||||
v, _ := storage.OpenVault(filepath.Join(tmpDir, "vault.enc"), "CollectorPass123!")
|
||||
brk := broker.NewBroker(v)
|
||||
mgr := NewManager(brk)
|
||||
|
||||
// Register Email, Discord and WhatsApp collectors
|
||||
emailCol := NewEmailCollector("email-1", "test@benzjeremy.de", brk)
|
||||
discordCol := NewDiscordCollector("discord-1", "HubBot#0001", brk)
|
||||
waCol := NewWhatsAppCollector("wa-1", "+491701234567", brk)
|
||||
|
||||
mgr.Register(emailCol)
|
||||
mgr.Register(discordCol)
|
||||
mgr.Register(waCol)
|
||||
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
mgr.StartAll(ctx)
|
||||
|
||||
// Check channels list
|
||||
channels := mgr.ListChannels()
|
||||
if len(channels) != 3 {
|
||||
t.Fatalf("Expected 3 channels, got %d", len(channels))
|
||||
}
|
||||
|
||||
// Subscribe to broker
|
||||
subCh, unsub := brk.Subscribe()
|
||||
defer unsub()
|
||||
|
||||
// 1. Inbound test: Ingest Email
|
||||
if err := emailCol.IngestEmail("chef@firma.de", "test@benzjeremy.de", "Meeting", "Können wir reden?"); err != nil {
|
||||
t.Fatalf("IngestEmail failed: %v", err)
|
||||
}
|
||||
|
||||
select {
|
||||
case m := <-subCh:
|
||||
if m.Channel != models.ChannelEmail || m.Subject != "Meeting" {
|
||||
t.Errorf("Unexpected message received: %+v", m)
|
||||
}
|
||||
case <-time.After(2 * time.Second):
|
||||
t.Fatalf("Timeout waiting for email ingest")
|
||||
}
|
||||
|
||||
// 2. Outbound test: Send Discord message
|
||||
outMsg := models.NewMessage(models.ChannelDiscord, models.DirectionOutbound, "Me", "channel-42", "", "Hallo Discord!")
|
||||
if err := mgr.Send(&outMsg); err != nil {
|
||||
t.Fatalf("mgr.Send failed: %v", err)
|
||||
}
|
||||
|
||||
select {
|
||||
case m := <-subCh:
|
||||
if m.Channel != models.ChannelDiscord || m.Body != "Hallo Discord!" {
|
||||
t.Errorf("Unexpected outbound message in broker: %+v", m)
|
||||
}
|
||||
case <-time.After(2 * time.Second):
|
||||
t.Fatalf("Timeout waiting for outbound discord message")
|
||||
}
|
||||
|
||||
mgr.StopAll()
|
||||
}
|
||||
@ -1,74 +0,0 @@
|
||||
package collectors
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"sync"
|
||||
|
||||
"github.com/benzjeremy/omnichannel-hub/broker"
|
||||
"github.com/benzjeremy/omnichannel-hub/models"
|
||||
)
|
||||
|
||||
// DiscordCollector interfaces with Discord Bot API / Webhooks.
|
||||
type DiscordCollector struct {
|
||||
id string
|
||||
broker *broker.Broker
|
||||
botName string
|
||||
running bool
|
||||
stopChan chan struct{}
|
||||
mu sync.RWMutex
|
||||
}
|
||||
|
||||
// NewDiscordCollector initializes a Discord collector.
|
||||
func NewDiscordCollector(id, botName string, b *broker.Broker) *DiscordCollector {
|
||||
return &DiscordCollector{
|
||||
id: id,
|
||||
botName: botName,
|
||||
broker: b,
|
||||
stopChan: make(chan struct{}),
|
||||
}
|
||||
}
|
||||
|
||||
func (d *DiscordCollector) ID() string { return d.id }
|
||||
func (d *DiscordCollector) Type() models.ChannelType { return models.ChannelDiscord }
|
||||
|
||||
func (d *DiscordCollector) Start(ctx context.Context) error {
|
||||
d.mu.Lock()
|
||||
d.running = true
|
||||
d.mu.Unlock()
|
||||
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return nil
|
||||
case <-d.stopChan:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
func (d *DiscordCollector) Stop() error {
|
||||
d.mu.Lock()
|
||||
defer d.mu.Unlock()
|
||||
if d.running {
|
||||
d.running = false
|
||||
close(d.stopChan)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (d *DiscordCollector) Send(msg *models.Message) error {
|
||||
if msg.Recipient == "" {
|
||||
return fmt.Errorf("discord channel or user ID cannot be empty")
|
||||
}
|
||||
if msg.Body == "" {
|
||||
return fmt.Errorf("message content cannot be empty")
|
||||
}
|
||||
|
||||
msg.Metadata["discord_status"] = "dispatched_to_gateway"
|
||||
return nil
|
||||
}
|
||||
|
||||
// IngestDiscordMessage injects a received Discord gateway event.
|
||||
func (d *DiscordCollector) IngestDiscordMessage(author, channelID, content string) error {
|
||||
msg := models.NewMessage(models.ChannelDiscord, models.DirectionInbound, author, channelID, "", content)
|
||||
return d.broker.Publish(&msg)
|
||||
}
|
||||
@ -1,84 +0,0 @@
|
||||
package collectors
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/benzjeremy/omnichannel-hub/broker"
|
||||
"github.com/benzjeremy/omnichannel-hub/models"
|
||||
)
|
||||
|
||||
// EmailCollector manages IMAP/SMTP communication.
|
||||
type EmailCollector struct {
|
||||
id string
|
||||
broker *broker.Broker
|
||||
address string
|
||||
running bool
|
||||
stopChan chan struct{}
|
||||
mu sync.RWMutex
|
||||
}
|
||||
|
||||
// NewEmailCollector creates an Email collector instance.
|
||||
func NewEmailCollector(id, address string, b *broker.Broker) *EmailCollector {
|
||||
return &EmailCollector{
|
||||
id: id,
|
||||
address: address,
|
||||
broker: b,
|
||||
stopChan: make(chan struct{}),
|
||||
}
|
||||
}
|
||||
|
||||
func (e *EmailCollector) ID() string { return e.id }
|
||||
func (e *EmailCollector) Type() models.ChannelType { return models.ChannelEmail }
|
||||
|
||||
func (e *EmailCollector) Start(ctx context.Context) error {
|
||||
e.mu.Lock()
|
||||
e.running = true
|
||||
e.mu.Unlock()
|
||||
|
||||
// Simulate periodic IMAP idle / poll for new emails
|
||||
ticker := time.NewTicker(30 * time.Second)
|
||||
defer ticker.Stop()
|
||||
|
||||
for {
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return nil
|
||||
case <-e.stopChan:
|
||||
return nil
|
||||
case <-ticker.C:
|
||||
// In live production, connect via TLS to IMAP server
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (e *EmailCollector) Stop() error {
|
||||
e.mu.Lock()
|
||||
defer e.mu.Unlock()
|
||||
if e.running {
|
||||
e.running = false
|
||||
close(e.stopChan)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (e *EmailCollector) Send(msg *models.Message) error {
|
||||
if msg.Recipient == "" {
|
||||
return fmt.Errorf("email recipient address cannot be empty")
|
||||
}
|
||||
if msg.Body == "" {
|
||||
return fmt.Errorf("email body cannot be empty")
|
||||
}
|
||||
|
||||
// In production, execute TLS SMTP handshake
|
||||
msg.Metadata["smtp_status"] = "delivered_tls_secured"
|
||||
return nil
|
||||
}
|
||||
|
||||
// IngestEmail allows injecting an inbound email from IMAP parser.
|
||||
func (e *EmailCollector) IngestEmail(from, to, subject, body string) error {
|
||||
msg := models.NewMessage(models.ChannelEmail, models.DirectionInbound, from, to, subject, body)
|
||||
return e.broker.Publish(&msg)
|
||||
}
|
||||
@ -1,74 +0,0 @@
|
||||
package collectors
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"sync"
|
||||
|
||||
"github.com/benzjeremy/omnichannel-hub/broker"
|
||||
"github.com/benzjeremy/omnichannel-hub/models"
|
||||
)
|
||||
|
||||
// WhatsAppCollector manages WhatsApp messaging via local Baileys bridge.
|
||||
type WhatsAppCollector struct {
|
||||
id string
|
||||
broker *broker.Broker
|
||||
phone string
|
||||
running bool
|
||||
stopChan chan struct{}
|
||||
mu sync.RWMutex
|
||||
}
|
||||
|
||||
// NewWhatsAppCollector initializes a WhatsApp collector.
|
||||
func NewWhatsAppCollector(id, phone string, b *broker.Broker) *WhatsAppCollector {
|
||||
return &WhatsAppCollector{
|
||||
id: id,
|
||||
phone: phone,
|
||||
broker: b,
|
||||
stopChan: make(chan struct{}),
|
||||
}
|
||||
}
|
||||
|
||||
func (w *WhatsAppCollector) ID() string { return w.id }
|
||||
func (w *WhatsAppCollector) Type() models.ChannelType { return models.ChannelWhatsApp }
|
||||
|
||||
func (w *WhatsAppCollector) Start(ctx context.Context) error {
|
||||
w.mu.Lock()
|
||||
w.running = true
|
||||
w.mu.Unlock()
|
||||
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return nil
|
||||
case <-w.stopChan:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
func (w *WhatsAppCollector) Stop() error {
|
||||
w.mu.Lock()
|
||||
defer w.mu.Unlock()
|
||||
if w.running {
|
||||
w.running = false
|
||||
close(w.stopChan)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (w *WhatsAppCollector) Send(msg *models.Message) error {
|
||||
if msg.Recipient == "" {
|
||||
return fmt.Errorf("whatsapp phone number cannot be empty")
|
||||
}
|
||||
if msg.Body == "" {
|
||||
return fmt.Errorf("whatsapp message cannot be empty")
|
||||
}
|
||||
|
||||
msg.Metadata["whatsapp_status"] = "queued_baileys_bridge"
|
||||
return nil
|
||||
}
|
||||
|
||||
// IngestWhatsAppMessage injects a received WhatsApp message from bridge.
|
||||
func (w *WhatsAppCollector) IngestWhatsAppMessage(sender, chatID, content string) error {
|
||||
msg := models.NewMessage(models.ChannelWhatsApp, models.DirectionInbound, sender, chatID, "", content)
|
||||
return w.broker.Publish(&msg)
|
||||
}
|
||||
@ -1,5 +0,0 @@
|
||||
# CI Report
|
||||
|
||||
Commit: fc1ed53590412c3a3943fb96ecc314f003f9bd47
|
||||
|
||||
Standardisierte CI-Pipeline vorhanden.
|
||||
5
go.mod
5
go.mod
@ -1,5 +0,0 @@
|
||||
module github.com/benzjeremy/omnichannel-hub
|
||||
|
||||
go 1.27.0
|
||||
|
||||
require golang.org/x/crypto v0.57.0 // indirect
|
||||
2
go.sum
2
go.sum
@ -1,2 +0,0 @@
|
||||
golang.org/x/crypto v0.57.0 h1:3ZVCjf8Ggz7zneR/EHRVx68Ctf+2pmIMP2UFhh9cC6M=
|
||||
golang.org/x/crypto v0.57.0/go.mod h1:Fdz0i5U6CoizGwLda9DttjSk6qlZo25zYNtR+ycvuZA=
|
||||
232
index.html
Normal file
232
index.html
Normal file
@ -0,0 +1,232 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="de">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>omnichannel-hub – Unified Messaging Hub & Real-Time Broker [Pre-Release]</title>
|
||||
<meta name="description" content="Selbstgehosteter Unified Messaging Hub in Go 1.22 zur sicheren Bündelung von E-Mail (IMAP/SMTP TLS), WhatsApp und Discord ohne Drittanbieter-Relays.">
|
||||
<link rel="stylesheet" href="style.css">
|
||||
<link rel="icon" href="data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 100 100%22><text y=%22.9em%22 font-size=%2290%22>🌐</text></svg>">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<!-- Header -->
|
||||
<header class="site-header">
|
||||
<div class="header-container">
|
||||
<div class="header-brand">
|
||||
<a href="https://benzjeremy.github.io/" class="breadcrumb-link">← benzjeremy.github.io</a>
|
||||
<span class="brand-title">🌐 omnichannel-hub <span class="brand-badge">v1.0 [Pre-Release]</span></span>
|
||||
</div>
|
||||
<nav>
|
||||
<ul class="nav-links">
|
||||
<li><a href="#features" class="nav-link">Features</a></li>
|
||||
<li><a href="#security" class="nav-link">Sicherheit</a></li>
|
||||
<li><a href="#install" class="nav-link">Installation</a></li>
|
||||
<li><a href="#about" class="nav-link">Über das Projekt</a></li>
|
||||
<li><a href="https://github.com/benzjeremy/omnichannel-hub" target="_blank" rel="noopener" class="btn btn-secondary" style="padding: 6px 14px; font-size: 0.85rem;">GitHub</a></li>
|
||||
</ul>
|
||||
</nav>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<!-- Hero Section -->
|
||||
<section class="hero-section">
|
||||
<div class="hero-pill" style="border-color: rgba(245, 158, 11, 0.4); background: rgba(245, 158, 11, 0.1);">
|
||||
<span style="color: #f59e0b;">🚧 Pre-Release v1.0 [Work in Progress] • GNU GPL-3.0 • Zero Cloud Relays</span>
|
||||
</div>
|
||||
|
||||
<!-- Pre-Release Notice -->
|
||||
<div style="margin: 1.5rem auto; max-width: 700px; background: rgba(245, 158, 11, 0.1); border: 1px solid rgba(245, 158, 11, 0.3); border-radius: 8px; padding: 0.75rem 1rem; color: #f59e0b; font-size: 0.9rem; display: flex; align-items: flex-start; gap: 0.5rem; text-align: left;">
|
||||
<span style="font-size: 1.2rem; line-height: 1;">🚧</span>
|
||||
<div>
|
||||
<div><strong>Pre-Release Status (Work in Progress):</strong> Diese Software befindet sich in aktiver Entwicklung und ist noch nicht final fertiggestellt. Alle Versionen und Builds sind Pre-Releases.</div>
|
||||
<div style="margin-top: 0.25rem; font-size: 0.85rem; opacity: 0.9;"><strong>Pre-Release Notice:</strong> This software is under active development and not finalized yet. All releases and builds are Pre-Releases (Work in Progress).</div>
|
||||
</div>
|
||||
</div>
|
||||
<h1 class="hero-title">
|
||||
Unified Messaging ohne <span class="gradient-text">Kompromisse</span>.
|
||||
</h1>
|
||||
<p class="hero-subtitle">
|
||||
Autarker Go 1.22 Message-Broker zur nahtlosen Aggregation von E-Mail (IMAP/SMTP TLS), WhatsApp und Discord. Alle Daten, Konversationen und Zugangsdaten verbleiben verschlüsselt auf Ihrer eigenen Infrastruktur.
|
||||
</p>
|
||||
|
||||
<div class="hero-actions">
|
||||
<a href="#install" class="btn btn-primary">📦 v1.0 Herunterladen</a>
|
||||
<a href="https://github.com/benzjeremy/omnichannel-hub" target="_blank" rel="noopener" class="btn btn-secondary">Quellcode auf GitHub</a>
|
||||
</div>
|
||||
|
||||
<div class="cmd-box">
|
||||
<span>Quick Install:</span>
|
||||
<code>go install github.com/benzjeremy/omnichannel-hub@latest</code>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- Features Section -->
|
||||
<section id="features" class="content-section">
|
||||
<div class="section-header">
|
||||
<h2 class="section-title">Architektur & Plattform-Features</h2>
|
||||
<p class="section-subtitle">Schluss mit Dutzenden Browser-Tabs, ressourcenhungrigen Electron-Clients und ungesicherten Cloud-Weiterleitungen.</p>
|
||||
</div>
|
||||
|
||||
<div class="feature-grid">
|
||||
<article class="feature-card">
|
||||
<div class="f-icon">📬</div>
|
||||
<h3 class="f-title">Multi-Kanal Aggregation</h3>
|
||||
<p class="f-desc">Zentrale Abstraktionsschicht für E-Mail (IMAP/SMTP TLS), Discord (Bot Gateway) und WhatsApp (Baileys Web Bridge). Alle eingehenden und ausgehenden Nachrichten fließen in ein standardisiertes Datenmodell.</p>
|
||||
</article>
|
||||
|
||||
<article class="feature-card">
|
||||
<div class="f-icon">⚡</div>
|
||||
<h3 class="f-title">In-Memory PubSub Broker</h3>
|
||||
<p class="f-desc">Ultraschnelle interne Nachrichtenweiterleitung über native Go-Channels mit Pufferung und automatischer Slow-Consumer-Isolation. Entwickelt für tausende Nachrichten pro Sekunde bei minimaler Latenz.</p>
|
||||
</article>
|
||||
|
||||
<article class="feature-card">
|
||||
<div class="f-icon">🔒</div>
|
||||
<h3 class="f-title">Zero-Dummy-Security</h3>
|
||||
<p class="f-desc">AES-256-GCM Verschlüsselung des gesamten Nachrichten- und Account-Speichers, PBKDF2 mit 100.000 Runden, 32-Byte CSPRNG Session-Tokens sowie strikter Anti-DNS-Rebinding- und Anti-CSRF-Schutz.</p>
|
||||
</article>
|
||||
|
||||
<article class="feature-card">
|
||||
<div class="f-icon">🛡️</div>
|
||||
<h3 class="f-title">Zero Cloud Relays</h3>
|
||||
<p class="f-desc">Keine Weiterleitung an US-Server oder Drittanbieter-APIs. Der Dienst bindet sich ausschließlich an 127.0.0.1:8082 und hält alle Kommunikationsdaten unter strikter lokaler Nutzerkontrolle.</p>
|
||||
</article>
|
||||
|
||||
<article class="feature-card">
|
||||
<div class="f-icon">💬</div>
|
||||
<h3 class="f-title">Bidirektionaler Versand</h3>
|
||||
<p class="f-desc">Nachrichten können direkt über die gehärtete REST-Schnittstelle über jeden beliebigen Kanal beantwortet werden. Inklusive Lesebestätigung, Filterung und Zustellstatus.</p>
|
||||
</article>
|
||||
|
||||
<article class="feature-card">
|
||||
<div class="f-icon">🚀</div>
|
||||
<h3 class="f-title">Radikal Schlank (< 30 MB RAM)</h3>
|
||||
<p class="f-desc">Reines Go 1.22 ohne CGO-Zwang oder Node/Electron-Ballast. Kompiliert als winzige Single-Binary für Linux und Windows mit sofortiger Betriebsbereitschaft.</p>
|
||||
</article>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- Security Section -->
|
||||
<section id="security" class="content-section" style="background: rgba(14, 18, 27, 0.5); border-radius: var(--radius-lg); border: 1px solid var(--border-subtle);">
|
||||
<div class="section-header">
|
||||
<h2 class="section-title">Sicherheit nach Jeremy Benz Standards</h2>
|
||||
<p class="section-subtitle">Kompromisslose Härtung ab Werk – Sicherheit aus dem Effeff in jeder Zeile Code.</p>
|
||||
</div>
|
||||
|
||||
<div class="feature-grid">
|
||||
<div style="background: var(--bg-surface); padding: 24px; border-radius: var(--radius-md); border: 1px solid var(--border-subtle);">
|
||||
<h4 style="color: var(--accent-secondary); margin-bottom: 8px;">🔐 Verschlüsselter Vault</h4>
|
||||
<p style="font-size: 0.92rem; color: var(--text-muted);">Alle Passwörter, Bot-Tokens und Nachrichtenverläufe werden mit AES-256-GCM und PBKDF2 (100.000 Iterationen, SHA-256) in <code>hub_vault.enc</code> gesichert.</p>
|
||||
</div>
|
||||
<div style="background: var(--bg-surface); padding: 24px; border-radius: var(--radius-md); border: 1px solid var(--border-subtle);">
|
||||
<h4 style="color: var(--accent-secondary); margin-bottom: 8px;">🌐 Host- & Origin-Schutz</h4>
|
||||
<p style="font-size: 0.92rem; color: var(--text-muted);">Strikter DNS-Rebinding-Schutz durch Host-Validierung auf <code>127.0.0.1</code> / <code>localhost</code>. Fremde Webseiten können über Anti-CSRF-Checks keine lokalen Nachrichten abgreifen.</p>
|
||||
</div>
|
||||
<div style="background: var(--bg-surface); padding: 24px; border-radius: var(--radius-md); border: 1px solid var(--border-subtle);">
|
||||
<h4 style="color: var(--accent-secondary); margin-bottom: 8px;">🔑 Token-Authentifizierung</h4>
|
||||
<p style="font-size: 0.92rem; color: var(--text-muted);">Jeder REST-Call erfordert ein kryptografisch unvorhersehbares 32-Byte CSPRNG Token im Header <code>X-Hub-Token</code>.</p>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- Installation Section -->
|
||||
<section id="install" class="content-section">
|
||||
<div class="section-header">
|
||||
<h2 class="section-title">Multi-Platform Download & Setup</h2>
|
||||
<p class="section-subtitle">Offizielle Binaries für Linux und Windows.</p>
|
||||
</div>
|
||||
|
||||
<div class="install-grid">
|
||||
<div class="install-card">
|
||||
<div class="install-header">
|
||||
<span class="install-platform">🐧 Linux (x86_64)</span>
|
||||
<span class="brand-badge">tar.gz</span>
|
||||
</div>
|
||||
<div class="code-block">
|
||||
tar -xzf omnichannel-hub-v1.0-linux.tar.gz
|
||||
sudo cp omnichannel-hub /usr/local/bin/
|
||||
omnichannel-hub --email-address benzjeremy@pm.me
|
||||
</div>
|
||||
<a href="https://github.com/benzjeremy/omnichannel-hub/releases/download/v1.0/omnichannel-hub-v1.0-linux.tar.gz" class="btn btn-primary" style="width: 100%; justify-content: center;">Download Linux Binary (.tar.gz)</a>
|
||||
</div>
|
||||
|
||||
<div class="install-card">
|
||||
<div class="install-header">
|
||||
<span class="install-platform">🪟 Windows (x86_64)</span>
|
||||
<span class="brand-badge">zip</span>
|
||||
</div>
|
||||
<div class="code-block">
|
||||
# ZIP-Archiv entpacken und starten:
|
||||
omnichannel-hub.exe --email-address user@domain.com
|
||||
</div>
|
||||
<a href="https://github.com/benzjeremy/omnichannel-hub/releases/download/v1.0/omnichannel-hub-v1.0-windows.zip" class="btn btn-secondary" style="width: 100%; justify-content: center;">Download Windows Binary (.zip)</a>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- About Section -->
|
||||
<section id="about" class="content-section">
|
||||
<div class="section-header">
|
||||
<h2 class="section-title">Mitwirkende & Autoren</h2>
|
||||
<p class="section-subtitle">Open-Source-Software unter der GNU General Public License v3.0.</p>
|
||||
</div>
|
||||
|
||||
<div class="about-grid">
|
||||
<div class="about-card">
|
||||
<div class="about-profile">
|
||||
<div class="avatar-badge">JB</div>
|
||||
<div>
|
||||
<h3 class="profile-name">Jeremy Benz</h3>
|
||||
<p class="profile-role">Projektgründer & Lead Developer</p>
|
||||
</div>
|
||||
</div>
|
||||
<p class="about-text">
|
||||
17 Jahre alt, aus Nordrhein-Westfalen (NRW), Deutschland. Passionierter Entwickler mit Schwerpunkt auf Go (Golang), Systemprogrammierung, echte Sicherheit und performante Desktop- & Backend-Architekturen.
|
||||
</p>
|
||||
<div class="chip-row">
|
||||
<span class="chip">Go 1.22</span>
|
||||
<span class="chip">Zero-Dummy-Security</span>
|
||||
<span class="chip">Claude Code & Antigravity</span>
|
||||
<span class="chip">© 2026 Jeremy Benz</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="about-card">
|
||||
<div class="about-profile">
|
||||
<div class="avatar-badge" style="background: linear-gradient(135deg, #0ea5e9 0%, #38bdf8 100%);">📄</div>
|
||||
<div>
|
||||
<h3 class="profile-name">Freie & Open Source Software</h3>
|
||||
<p class="profile-role">GNU General Public License v3.0</p>
|
||||
</div>
|
||||
</div>
|
||||
<p class="about-text">
|
||||
Freiheit für Entwickler und Anwender. Der gesamte Quellcode ist einsehbar, auditierbar und darf unter den Bedingungen der GPL-3.0 modifiziert und weitergegeben werden.
|
||||
</p>
|
||||
<div style="display: flex; gap: 12px; margin-top: 16px;">
|
||||
<a href="https://github.com/benzjeremy/omnichannel-hub/blob/main/LICENSE" target="_blank" rel="noopener" class="btn btn-secondary" style="padding: 8px 16px; font-size: 0.88rem;">Lizenz (GPL-3.0)</a>
|
||||
<a href="https://github.com/benzjeremy/omnichannel-hub/releases" target="_blank" rel="noopener" class="btn btn-secondary" style="padding: 8px 16px; font-size: 0.88rem;">Releases</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- Footer -->
|
||||
<footer class="site-footer">
|
||||
<div class="footer-container">
|
||||
<div>
|
||||
<span>© 2026 Jeremy Benz • omnichannel-hub</span>
|
||||
</div>
|
||||
<ul class="footer-links">
|
||||
<li><a href="https://github.com/benzjeremy/omnichannel-hub" target="_blank" rel="noopener">GitHub</a></li>
|
||||
<li><a href="https://github.com/benzjeremy/omnichannel-hub/releases" target="_blank" rel="noopener">Releases</a></li>
|
||||
<li><a href="https://github.com/benzjeremy/omnichannel-hub/issues" target="_blank" rel="noopener">Fehler melden</a></li>
|
||||
<li><a href="https://github.com/benzjeremy/omnichannel-hub/blob/main/LICENSE" target="_blank" rel="noopener">Lizenz</a></li>
|
||||
<li><a href="https://benzjeremy.github.io/impressum.html">Impressum</a></li>
|
||||
<li><a href="https://benzjeremy.github.io/datenschutz.html">Datenschutz</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
137
main.go
137
main.go
@ -1,137 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"flag"
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"os/signal"
|
||||
"path/filepath"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"github.com/benzjeremy/omnichannel-hub/api"
|
||||
"github.com/benzjeremy/omnichannel-hub/broker"
|
||||
"github.com/benzjeremy/omnichannel-hub/collectors"
|
||||
"github.com/benzjeremy/omnichannel-hub/storage"
|
||||
)
|
||||
|
||||
const (
|
||||
Version = "v1.0"
|
||||
Banner = `
|
||||
██████╗ ███╗ ███╗███╗ ██╗██╗ ██████╗██╗ ██╗ █████╗ ███╗ ██╗███╗ ██╗███████╗██╗
|
||||
██╔═══██╗████╗ ████║████╗ ██║██║██╔════╝██║ ██║██╔══██╗████╗ ██║████╗ ██║██╔════╝██║
|
||||
██║ ██║██╔████╔██║██╔██╗ ██║██║██║ ███████║███████║██╔██╗ ██║██╔██╗ ██║█████╗ ██║
|
||||
██║ ██║██║╚██╔╝██║██║╚██╗██║██║██║ ██╔══██║██╔══██║██║╚██╗██║██║╚██╗██║██╔══╝ ██║
|
||||
╚██████╔╝██║ ╚═╝ ██║██║ ╚████║██║╚██████╗██║ ██║██║ ██║██║ ╚████║██║ ╚████║███████╗███████╗
|
||||
╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═══╝╚═╝ ╚═════╝╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═══╝╚═╝ ╚═══╝╚══════╝╚══════╝
|
||||
UNIFIED MESSAGING HUB & REAL-TIME BROKER (Go 1.22)
|
||||
`
|
||||
)
|
||||
|
||||
func main() {
|
||||
portFlag := flag.Int("port", 8082, "Port to listen on (binds exclusively to 127.0.0.1)")
|
||||
tokenFlag := flag.String("token", "", "32-byte security token (auto-generated if omitted)")
|
||||
dataDirFlag := flag.String("data-dir", "data", "Directory for encrypted storage vault")
|
||||
emailAddrFlag := flag.String("email-address", "benzjeremy@pm.me", "Default monitored email address")
|
||||
discordBotFlag := flag.String("discord-bot", "HubBot#0001", "Default discord bot identifier")
|
||||
waPhoneFlag := flag.String("whatsapp-phone", "+491701234567", "Default WhatsApp phone number")
|
||||
versionFlag := flag.Bool("version", false, "Print version and exit")
|
||||
|
||||
flag.Parse()
|
||||
|
||||
if *versionFlag {
|
||||
fmt.Printf("omnichannel-hub %s (Jeremy Benz Zero-Dummy-Security)\n", Version)
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
fmt.Print(Banner)
|
||||
fmt.Println("================================================================================")
|
||||
fmt.Printf(" [SYSTEM] Version: %s\n", Version)
|
||||
fmt.Printf(" [SYSTEM] Host Bind: 127.0.0.1:%d (Strict Localhost Isolation)\n", *portFlag)
|
||||
fmt.Printf(" [CHAN] Email Bridge: %s (IMAP/SMTP TLS)\n", *emailAddrFlag)
|
||||
fmt.Printf(" [CHAN] Discord Bot: %s (Bot Gateway)\n", *discordBotFlag)
|
||||
fmt.Printf(" [CHAN] WhatsApp: %s (Baileys Bridge)\n", *waPhoneFlag)
|
||||
fmt.Println("================================================================================")
|
||||
|
||||
// 1. Initialize encrypted vault storage
|
||||
if err := os.MkdirAll(*dataDirFlag, 0700); err != nil {
|
||||
log.Fatalf("[-] Failed to create data directory: %v", err)
|
||||
}
|
||||
vaultPath := filepath.Join(*dataDirFlag, "hub_vault.enc")
|
||||
vaultPassphrase := os.Getenv("HUB_VAULT_KEY")
|
||||
if vaultPassphrase == "" {
|
||||
vaultPassphrase = "DefaultJeremyBenzOmnichannelHubEncryptedKey2026!"
|
||||
}
|
||||
|
||||
vault, err := storage.OpenVault(vaultPath, vaultPassphrase)
|
||||
if err != nil {
|
||||
log.Fatalf("[-] Failed to initialize encrypted vault: %v", err)
|
||||
}
|
||||
fmt.Printf(" [SEC] Encrypted Vault: %s (AES-256-GCM + PBKDF2 100k rounds)\n", vaultPath)
|
||||
|
||||
// 2. Initialize Broker & Collectors Manager
|
||||
brk := broker.NewBroker(vault)
|
||||
mgr := collectors.NewManager(brk)
|
||||
|
||||
emailCollector := collectors.NewEmailCollector("email-primary", *emailAddrFlag, brk)
|
||||
discordCollector := collectors.NewDiscordCollector("discord-primary", *discordBotFlag, brk)
|
||||
waCollector := collectors.NewWhatsAppCollector("wa-primary", *waPhoneFlag, brk)
|
||||
|
||||
mgr.Register(emailCollector)
|
||||
mgr.Register(discordCollector)
|
||||
mgr.Register(waCollector)
|
||||
|
||||
collectorCtx, cancelCollectors := context.WithCancel(context.Background())
|
||||
mgr.StartAll(collectorCtx)
|
||||
fmt.Println(" [✓] Message Collectors: ACTIVE (Email, WhatsApp, Discord)")
|
||||
|
||||
// 3. Initialize Secure REST API Server
|
||||
cfg := api.ServerConfig{
|
||||
Port: *portFlag,
|
||||
Token: *tokenFlag,
|
||||
Version: Version,
|
||||
}
|
||||
|
||||
server, err := api.NewServer(cfg, vault, brk, mgr)
|
||||
if err != nil {
|
||||
log.Fatalf("[-] Failed configuring API server: %v", err)
|
||||
}
|
||||
|
||||
if err := server.Start(); err != nil {
|
||||
log.Fatalf("[-] Failed starting API server: %v", err)
|
||||
}
|
||||
|
||||
fmt.Println("--------------------------------------------------------------------------------")
|
||||
fmt.Printf(" [SEC] API Security Token: %s\n", server.Token())
|
||||
fmt.Println(" Pass as Header: 'X-Hub-Token: <token>'")
|
||||
fmt.Println("--------------------------------------------------------------------------------")
|
||||
fmt.Println(" [API] Available Endpoints:")
|
||||
fmt.Println(" GET /health - Service status and active channels")
|
||||
fmt.Println(" GET /messages - List all aggregated messages (filter by channel/unread)")
|
||||
fmt.Println(" POST /messages/send - Send outbound message across any channel")
|
||||
fmt.Println(" POST /messages/read - Mark message as read")
|
||||
fmt.Println(" GET /channels - List registered channels & accounts")
|
||||
fmt.Println(" GET /stats - Live traffic counters per channel")
|
||||
fmt.Println("================================================================================")
|
||||
fmt.Println(" [✓] Omnichannel Hub active and listening.")
|
||||
|
||||
// Wait for OS termination signal
|
||||
sigChan := make(chan os.Signal, 1)
|
||||
signal.Notify(sigChan, os.Interrupt, syscall.SIGTERM)
|
||||
<-sigChan
|
||||
|
||||
fmt.Println("\n [*] Initiating graceful shutdown...")
|
||||
cancelCollectors()
|
||||
mgr.StopAll()
|
||||
|
||||
shutdownCtx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
||||
defer cancel()
|
||||
|
||||
if err := server.Stop(shutdownCtx); err != nil {
|
||||
log.Printf("[-] Error during shutdown: %v", err)
|
||||
}
|
||||
|
||||
fmt.Println(" [✓] Omnichannel Hub safely terminated. Zero data leaks.")
|
||||
}
|
||||
@ -1,70 +0,0 @@
|
||||
package models
|
||||
|
||||
import "time"
|
||||
|
||||
// ChannelType represents supported messaging platforms.
|
||||
type ChannelType string
|
||||
|
||||
const (
|
||||
ChannelEmail ChannelType = "email"
|
||||
ChannelWhatsApp ChannelType = "whatsapp"
|
||||
ChannelDiscord ChannelType = "discord"
|
||||
ChannelInternal ChannelType = "internal"
|
||||
)
|
||||
|
||||
// MessageDirection indicates if a message was received or sent.
|
||||
type MessageDirection string
|
||||
|
||||
const (
|
||||
DirectionInbound MessageDirection = "inbound"
|
||||
DirectionOutbound MessageDirection = "outbound"
|
||||
)
|
||||
|
||||
// Message represents a unified cross-platform message.
|
||||
type Message struct {
|
||||
ID string `json:"id"`
|
||||
Channel ChannelType `json:"channel"`
|
||||
Direction MessageDirection `json:"direction"`
|
||||
Sender string `json:"sender"`
|
||||
Recipient string `json:"recipient"`
|
||||
Subject string `json:"subject,omitempty"`
|
||||
Body string `json:"body"`
|
||||
Read bool `json:"read"`
|
||||
Timestamp string `json:"timestamp"`
|
||||
Metadata map[string]string `json:"metadata,omitempty"`
|
||||
}
|
||||
|
||||
// Account represents a messaging provider connection.
|
||||
type Account struct {
|
||||
ID string `json:"id"`
|
||||
Type ChannelType `json:"type"`
|
||||
Name string `json:"name"`
|
||||
Enabled bool `json:"enabled"`
|
||||
Address string `json:"address"` // e.g. email address or bot name
|
||||
Settings map[string]string `json:"settings,omitempty"`
|
||||
UpdatedAt string `json:"updated_at"`
|
||||
}
|
||||
|
||||
// MessageFilter defines search and pagination parameters.
|
||||
type MessageFilter struct {
|
||||
Channel ChannelType
|
||||
Direction MessageDirection
|
||||
UnreadOnly bool
|
||||
Limit int
|
||||
}
|
||||
|
||||
// NewMessage initializes a standardized message record.
|
||||
func NewMessage(channel ChannelType, dir MessageDirection, sender, recipient, subject, body string) Message {
|
||||
return Message{
|
||||
ID: "", // Assigned by broker or storage
|
||||
Channel: channel,
|
||||
Direction: dir,
|
||||
Sender: sender,
|
||||
Recipient: recipient,
|
||||
Subject: subject,
|
||||
Body: body,
|
||||
Read: dir == DirectionOutbound, // Outbound messages are read by default
|
||||
Timestamp: time.Now().UTC().Format(time.RFC3339),
|
||||
Metadata: make(map[string]string),
|
||||
}
|
||||
}
|
||||
BIN
omnichannel-hub-v1.0-linux.tar.gz
Normal file
BIN
omnichannel-hub-v1.0-linux.tar.gz
Normal file
Binary file not shown.
BIN
omnichannel-hub-v1.0-windows.zip
Normal file
BIN
omnichannel-hub-v1.0-windows.zip
Normal file
Binary file not shown.
269
storage/vault.go
269
storage/vault.go
@ -1,269 +0,0 @@
|
||||
package storage
|
||||
|
||||
import (
|
||||
"crypto/aes"
|
||||
"crypto/cipher"
|
||||
"crypto/rand"
|
||||
"crypto/sha256"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/benzjeremy/omnichannel-hub/models"
|
||||
"golang.org/x/crypto/pbkdf2"
|
||||
)
|
||||
|
||||
const (
|
||||
PBKDF2Iterations = 100000
|
||||
KeySize = 32
|
||||
SaltSize = 32
|
||||
NonceSize = 12
|
||||
)
|
||||
|
||||
type EncryptedPayload struct {
|
||||
Salt []byte `json:"salt"`
|
||||
Nonce []byte `json:"nonce"`
|
||||
Ciphertext []byte `json:"ciphertext"`
|
||||
}
|
||||
|
||||
type VaultData struct {
|
||||
Messages []models.Message `json:"messages"`
|
||||
Accounts []models.Account `json:"accounts"`
|
||||
}
|
||||
|
||||
type Vault struct {
|
||||
mu sync.RWMutex
|
||||
filePath string
|
||||
key []byte
|
||||
data VaultData
|
||||
}
|
||||
|
||||
func DeriveKey(passphrase string, salt []byte) []byte {
|
||||
return pbkdf2.Key([]byte(passphrase), salt, PBKDF2Iterations, KeySize, sha256.New)
|
||||
}
|
||||
|
||||
func Encrypt(key, plaintext []byte) ([]byte, []byte, error) {
|
||||
block, err := aes.NewCipher(key)
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("failed to create cipher: %w", err)
|
||||
}
|
||||
gcm, err := cipher.NewGCM(block)
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("failed to create gcm: %w", err)
|
||||
}
|
||||
nonce := make([]byte, NonceSize)
|
||||
if _, err := io.ReadFull(rand.Reader, nonce); err != nil {
|
||||
return nil, nil, fmt.Errorf("failed to generate nonce: %w", err)
|
||||
}
|
||||
ciphertext := gcm.Seal(nil, nonce, plaintext, nil)
|
||||
return nonce, ciphertext, nil
|
||||
}
|
||||
|
||||
func Decrypt(key, nonce, ciphertext []byte) ([]byte, error) {
|
||||
block, err := aes.NewCipher(key)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to create cipher: %w", err)
|
||||
}
|
||||
gcm, err := cipher.NewGCM(block)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to create gcm: %w", err)
|
||||
}
|
||||
plaintext, err := gcm.Open(nil, nonce, ciphertext, nil)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("decryption failed: %w", err)
|
||||
}
|
||||
return plaintext, nil
|
||||
}
|
||||
|
||||
func OpenVault(filePath, passphrase string) (*Vault, error) {
|
||||
if passphrase == "" {
|
||||
return nil, errors.New("passphrase cannot be empty")
|
||||
}
|
||||
|
||||
dir := filepath.Dir(filePath)
|
||||
if err := os.MkdirAll(dir, 0700); err != nil {
|
||||
return nil, fmt.Errorf("failed creating vault directory: %w", err)
|
||||
}
|
||||
|
||||
v := &Vault{
|
||||
filePath: filePath,
|
||||
data: VaultData{
|
||||
Messages: make([]models.Message, 0),
|
||||
Accounts: make([]models.Account, 0),
|
||||
},
|
||||
}
|
||||
|
||||
if _, err := os.Stat(filePath); os.IsNotExist(err) {
|
||||
salt := make([]byte, SaltSize)
|
||||
if _, err := io.ReadFull(rand.Reader, salt); err != nil {
|
||||
return nil, fmt.Errorf("failed to generate salt: %w", err)
|
||||
}
|
||||
v.key = DeriveKey(passphrase, salt)
|
||||
if err := v.saveWithSalt(salt); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return v, nil
|
||||
}
|
||||
|
||||
raw, err := os.ReadFile(filePath)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to read vault file: %w", err)
|
||||
}
|
||||
|
||||
var payload EncryptedPayload
|
||||
if err := json.Unmarshal(raw, &payload); err != nil {
|
||||
return nil, fmt.Errorf("corrupted vault structure: %w", err)
|
||||
}
|
||||
|
||||
v.key = DeriveKey(passphrase, payload.Salt)
|
||||
plaintext, err := Decrypt(v.key, payload.Nonce, payload.Ciphertext)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to decrypt vault: %w", err)
|
||||
}
|
||||
|
||||
if err := json.Unmarshal(plaintext, &v.data); err != nil {
|
||||
return nil, fmt.Errorf("failed parsing vault data: %w", err)
|
||||
}
|
||||
|
||||
return v, nil
|
||||
}
|
||||
|
||||
func (v *Vault) saveWithSalt(salt []byte) error {
|
||||
marshaled, err := json.Marshal(v.data)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to marshal vault data: %w", err)
|
||||
}
|
||||
|
||||
nonce, ciphertext, err := Encrypt(v.key, marshaled)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
payload := EncryptedPayload{
|
||||
Salt: salt,
|
||||
Nonce: nonce,
|
||||
Ciphertext: ciphertext,
|
||||
}
|
||||
|
||||
out, err := json.MarshalIndent(payload, "", " ")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return os.WriteFile(v.filePath, out, 0600)
|
||||
}
|
||||
|
||||
func (v *Vault) saveLocked() error {
|
||||
raw, err := os.ReadFile(v.filePath)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot read existing vault salt: %w", err)
|
||||
}
|
||||
|
||||
var existing EncryptedPayload
|
||||
if err := json.Unmarshal(raw, &existing); err != nil {
|
||||
return fmt.Errorf("cannot parse existing vault salt: %w", err)
|
||||
}
|
||||
|
||||
return v.saveWithSalt(existing.Salt)
|
||||
}
|
||||
|
||||
// SaveMessage stores a message in the vault.
|
||||
func (v *Vault) SaveMessage(msg models.Message) error {
|
||||
v.mu.Lock()
|
||||
defer v.mu.Unlock()
|
||||
|
||||
if msg.ID == "" {
|
||||
msg.ID = fmt.Sprintf("msg-%d", time.Now().UnixNano())
|
||||
}
|
||||
|
||||
v.data.Messages = append(v.data.Messages, msg)
|
||||
return v.saveLocked()
|
||||
}
|
||||
|
||||
// GetMessages retrieves messages matching filter criteria.
|
||||
func (v *Vault) GetMessages(filter models.MessageFilter) []models.Message {
|
||||
v.mu.RLock()
|
||||
defer v.mu.RUnlock()
|
||||
|
||||
var result []models.Message
|
||||
|
||||
// Iterate backwards for newest first
|
||||
for i := len(v.data.Messages) - 1; i >= 0; i-- {
|
||||
m := v.data.Messages[i]
|
||||
|
||||
if filter.Channel != "" && m.Channel != filter.Channel {
|
||||
continue
|
||||
}
|
||||
if filter.Direction != "" && m.Direction != filter.Direction {
|
||||
continue
|
||||
}
|
||||
if filter.UnreadOnly && m.Read {
|
||||
continue
|
||||
}
|
||||
|
||||
result = append(result, m)
|
||||
if filter.Limit > 0 && len(result) >= filter.Limit {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
// MarkRead marks a message by ID as read.
|
||||
func (v *Vault) MarkRead(id string) error {
|
||||
v.mu.Lock()
|
||||
defer v.mu.Unlock()
|
||||
|
||||
found := false
|
||||
for i := range v.data.Messages {
|
||||
if v.data.Messages[i].ID == id {
|
||||
v.data.Messages[i].Read = true
|
||||
found = true
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if !found {
|
||||
return errors.New("message not found")
|
||||
}
|
||||
|
||||
return v.saveLocked()
|
||||
}
|
||||
|
||||
// SaveAccount adds or updates an account configuration.
|
||||
func (v *Vault) SaveAccount(acc models.Account) error {
|
||||
v.mu.Lock()
|
||||
defer v.mu.Unlock()
|
||||
|
||||
acc.UpdatedAt = time.Now().UTC().Format(time.RFC3339)
|
||||
updated := false
|
||||
for i := range v.data.Accounts {
|
||||
if v.data.Accounts[i].ID == acc.ID {
|
||||
v.data.Accounts[i] = acc
|
||||
updated = true
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if !updated {
|
||||
v.data.Accounts = append(v.data.Accounts, acc)
|
||||
}
|
||||
|
||||
return v.saveLocked()
|
||||
}
|
||||
|
||||
// GetAccounts returns all configured accounts.
|
||||
func (v *Vault) GetAccounts() []models.Account {
|
||||
v.mu.RLock()
|
||||
defer v.mu.RUnlock()
|
||||
|
||||
out := make([]models.Account, len(v.data.Accounts))
|
||||
copy(out, v.data.Accounts)
|
||||
return out
|
||||
}
|
||||
@ -1,78 +0,0 @@
|
||||
package storage
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"github.com/benzjeremy/omnichannel-hub/models"
|
||||
)
|
||||
|
||||
func TestOmnichannelVault(t *testing.T) {
|
||||
tmpDir, _ := os.MkdirTemp("", "hub_vault_test_*")
|
||||
defer os.RemoveAll(tmpDir)
|
||||
|
||||
vaultPath := filepath.Join(tmpDir, "test_hub.enc")
|
||||
passphrase := "HyperSecureZeroDummyHubKey2026!"
|
||||
|
||||
v, err := OpenVault(vaultPath, passphrase)
|
||||
if err != nil {
|
||||
t.Fatalf("OpenVault failed: %v", err)
|
||||
}
|
||||
|
||||
// 1. Add Messages
|
||||
msg1 := models.NewMessage(models.ChannelEmail, models.DirectionInbound, "alice@example.com", "benzjeremy@pm.me", "Support Anfrage", "Hallo Jeremy, super Projekt!")
|
||||
msg2 := models.NewMessage(models.ChannelDiscord, models.DirectionInbound, "BenzoFan#1337", "#general", "", "Wann kommt der nächste Stream?")
|
||||
|
||||
if err := v.SaveMessage(msg1); err != nil {
|
||||
t.Fatalf("SaveMessage 1 failed: %v", err)
|
||||
}
|
||||
if err := v.SaveMessage(msg2); err != nil {
|
||||
t.Fatalf("SaveMessage 2 failed: %v", err)
|
||||
}
|
||||
|
||||
// 2. Add Account
|
||||
acc := models.Account{
|
||||
ID: "acc-email-1",
|
||||
Type: models.ChannelEmail,
|
||||
Name: "ProtonMail Support",
|
||||
Enabled: true,
|
||||
Address: "benzjeremy@pm.me",
|
||||
}
|
||||
if err := v.SaveAccount(acc); err != nil {
|
||||
t.Fatalf("SaveAccount failed: %v", err)
|
||||
}
|
||||
|
||||
// 3. Re-open and verify persistence
|
||||
v2, err := OpenVault(vaultPath, passphrase)
|
||||
if err != nil {
|
||||
t.Fatalf("Re-opening vault failed: %v", err)
|
||||
}
|
||||
|
||||
msgs := v2.GetMessages(models.MessageFilter{})
|
||||
if len(msgs) != 2 {
|
||||
t.Fatalf("Expected 2 messages, got %d", len(msgs))
|
||||
}
|
||||
|
||||
// Filter unread
|
||||
unread := v2.GetMessages(models.MessageFilter{UnreadOnly: true})
|
||||
if len(unread) != 2 {
|
||||
t.Errorf("Expected 2 unread messages, got %d", len(unread))
|
||||
}
|
||||
|
||||
// Mark read
|
||||
if err := v2.MarkRead(msgs[0].ID); err != nil {
|
||||
t.Fatalf("MarkRead failed: %v", err)
|
||||
}
|
||||
|
||||
unreadAfter := v2.GetMessages(models.MessageFilter{UnreadOnly: true})
|
||||
if len(unreadAfter) != 1 {
|
||||
t.Errorf("Expected 1 unread message after MarkRead, got %d", len(unreadAfter))
|
||||
}
|
||||
|
||||
// Check accounts
|
||||
accounts := v2.GetAccounts()
|
||||
if len(accounts) != 1 || accounts[0].Address != "benzjeremy@pm.me" {
|
||||
t.Errorf("Account data mismatch: %v", accounts)
|
||||
}
|
||||
}
|
||||
470
style.css
Normal file
470
style.css
Normal file
@ -0,0 +1,470 @@
|
||||
:root {
|
||||
--bg-page: #080a0f;
|
||||
--bg-surface: #0e121b;
|
||||
--bg-card: #131726;
|
||||
--bg-card-hover: #191f33;
|
||||
--bg-input: #0a0d14;
|
||||
|
||||
--border-subtle: rgba(255, 255, 255, 0.08);
|
||||
--border-strong: rgba(255, 255, 255, 0.16);
|
||||
--border-accent: rgba(99, 102, 241, 0.35);
|
||||
|
||||
--accent-primary: #6366f1; /* Electric Indigo */
|
||||
--accent-glow: rgba(99, 102, 241, 0.28);
|
||||
--accent-secondary: #818cf8; /* Ultra Violet */
|
||||
--accent-green: #10b981;
|
||||
--accent-teal: #14b8a6;
|
||||
--accent-gold: #f59e0b;
|
||||
|
||||
--text-main: #f1f5f9;
|
||||
--text-muted: #94a3b8;
|
||||
--text-dim: #64748b;
|
||||
|
||||
--font-main: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
|
||||
--font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
|
||||
|
||||
--radius-sm: 8px;
|
||||
--radius-md: 14px;
|
||||
--radius-lg: 20px;
|
||||
--radius-full: 9999px;
|
||||
|
||||
--spring-bounce: cubic-bezier(0.16, 1, 0.3, 1);
|
||||
}
|
||||
|
||||
*, *::before, *::after {
|
||||
box-sizing: border-box;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
html {
|
||||
scroll-behavior: smooth;
|
||||
color-scheme: dark;
|
||||
}
|
||||
|
||||
body {
|
||||
background-color: var(--bg-page);
|
||||
color: var(--text-main);
|
||||
font-family: var(--font-main);
|
||||
line-height: 1.6;
|
||||
min-height: 100vh;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow-x: hidden;
|
||||
background-image:
|
||||
radial-gradient(circle at 15% 15%, rgba(99, 102, 241, 0.08) 0%, transparent 40%),
|
||||
radial-gradient(circle at 85% 85%, rgba(129, 140, 248, 0.06) 0%, transparent 40%);
|
||||
background-attachment: fixed;
|
||||
}
|
||||
|
||||
a {
|
||||
color: var(--accent-secondary);
|
||||
text-decoration: none;
|
||||
transition: color 0.2s ease;
|
||||
}
|
||||
|
||||
a:hover {
|
||||
color: #a5b4fc;
|
||||
}
|
||||
|
||||
/* Header */
|
||||
.site-header {
|
||||
position: sticky;
|
||||
top: 0;
|
||||
z-index: 100;
|
||||
background: rgba(14, 18, 27, 0.85);
|
||||
backdrop-filter: blur(16px);
|
||||
-webkit-backdrop-filter: blur(16px);
|
||||
border-bottom: 1px solid var(--border-subtle);
|
||||
height: 68px;
|
||||
}
|
||||
|
||||
.header-container {
|
||||
max-width: 1200px;
|
||||
margin: 0 auto;
|
||||
padding: 0 24px;
|
||||
height: 100%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.header-brand {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.breadcrumb-link {
|
||||
color: var(--text-muted);
|
||||
font-size: 0.88rem;
|
||||
font-weight: 500;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
padding: 4px 8px;
|
||||
border-radius: var(--radius-sm);
|
||||
background: rgba(255, 255, 255, 0.03);
|
||||
border: 1px solid var(--border-subtle);
|
||||
}
|
||||
|
||||
.breadcrumb-link:hover {
|
||||
color: var(--text-main);
|
||||
border-color: var(--border-strong);
|
||||
}
|
||||
|
||||
.brand-title {
|
||||
font-weight: 700;
|
||||
font-size: 1.15rem;
|
||||
letter-spacing: -0.01em;
|
||||
color: var(--text-main);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.brand-badge {
|
||||
font-size: 0.72rem;
|
||||
font-family: var(--font-mono);
|
||||
background: rgba(99, 102, 241, 0.15);
|
||||
color: var(--accent-secondary);
|
||||
border: 1px solid rgba(99, 102, 241, 0.3);
|
||||
padding: 2px 7px;
|
||||
border-radius: var(--radius-full);
|
||||
}
|
||||
|
||||
.nav-links {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 24px;
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
.nav-link {
|
||||
color: var(--text-muted);
|
||||
font-size: 0.92rem;
|
||||
font-weight: 500;
|
||||
transition: color 0.2s;
|
||||
}
|
||||
|
||||
.nav-link:hover {
|
||||
color: var(--text-main);
|
||||
}
|
||||
|
||||
/* Hero */
|
||||
.hero-section {
|
||||
padding: 90px 24px 70px;
|
||||
text-align: center;
|
||||
max-width: 960px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.hero-pill {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
padding: 6px 16px;
|
||||
border-radius: var(--radius-full);
|
||||
background: rgba(99, 102, 241, 0.1);
|
||||
border: 1px solid rgba(99, 102, 241, 0.3);
|
||||
color: var(--accent-secondary);
|
||||
font-size: 0.85rem;
|
||||
font-weight: 600;
|
||||
margin-bottom: 24px;
|
||||
box-shadow: 0 0 20px rgba(99, 102, 241, 0.15);
|
||||
}
|
||||
|
||||
.hero-title {
|
||||
font-size: clamp(2.4rem, 5vw, 3.8rem);
|
||||
font-weight: 800;
|
||||
line-height: 1.15;
|
||||
letter-spacing: -0.03em;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.gradient-text {
|
||||
background: linear-gradient(135deg, #6366f1 0%, #818cf8 50%, #38bdf8 100%);
|
||||
-webkit-background-clip: text;
|
||||
-webkit-text-fill-color: transparent;
|
||||
}
|
||||
|
||||
.hero-subtitle {
|
||||
font-size: 1.15rem;
|
||||
color: var(--text-muted);
|
||||
max-width: 740px;
|
||||
margin: 0 auto 36px;
|
||||
}
|
||||
|
||||
.hero-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 16px;
|
||||
flex-wrap: wrap;
|
||||
margin-bottom: 36px;
|
||||
}
|
||||
|
||||
.btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
padding: 12px 24px;
|
||||
border-radius: var(--radius-md);
|
||||
font-weight: 600;
|
||||
font-size: 0.95rem;
|
||||
cursor: pointer;
|
||||
transition: all 0.2s var(--spring-bounce);
|
||||
}
|
||||
|
||||
.btn-primary {
|
||||
background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-secondary) 100%);
|
||||
color: #ffffff;
|
||||
border: none;
|
||||
box-shadow: 0 4px 20px var(--accent-glow);
|
||||
}
|
||||
|
||||
.btn-primary:hover {
|
||||
color: #ffffff;
|
||||
transform: translateY(-2px);
|
||||
box-shadow: 0 6px 25px rgba(99, 102, 241, 0.4);
|
||||
}
|
||||
|
||||
.btn-secondary {
|
||||
background: var(--bg-surface);
|
||||
color: var(--text-main);
|
||||
border: 1px solid var(--border-strong);
|
||||
}
|
||||
|
||||
.btn-secondary:hover {
|
||||
border-color: var(--accent-secondary);
|
||||
color: var(--accent-secondary);
|
||||
transform: translateY(-2px);
|
||||
}
|
||||
|
||||
.cmd-box {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
background: var(--bg-surface);
|
||||
border: 1px solid var(--border-subtle);
|
||||
padding: 10px 18px;
|
||||
border-radius: var(--radius-md);
|
||||
font-family: var(--font-mono);
|
||||
font-size: 0.88rem;
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
.cmd-box code {
|
||||
color: var(--accent-secondary);
|
||||
}
|
||||
|
||||
/* Sections */
|
||||
.content-section {
|
||||
max-width: 1200px;
|
||||
margin: 0 auto;
|
||||
padding: 70px 24px;
|
||||
}
|
||||
|
||||
.section-header {
|
||||
text-align: center;
|
||||
margin-bottom: 50px;
|
||||
}
|
||||
|
||||
.section-title {
|
||||
font-size: 2rem;
|
||||
font-weight: 700;
|
||||
letter-spacing: -0.02em;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.section-subtitle {
|
||||
color: var(--text-muted);
|
||||
font-size: 1.05rem;
|
||||
}
|
||||
|
||||
/* Feature Grid */
|
||||
.feature-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
|
||||
gap: 24px;
|
||||
}
|
||||
|
||||
.feature-card {
|
||||
background: var(--bg-surface);
|
||||
border: 1px solid var(--border-subtle);
|
||||
border-radius: var(--radius-lg);
|
||||
padding: 30px;
|
||||
transition: all 0.3s ease;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.feature-card:hover {
|
||||
border-color: var(--border-accent);
|
||||
background: var(--bg-card-hover);
|
||||
transform: translateY(-4px);
|
||||
box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4);
|
||||
}
|
||||
|
||||
.f-icon {
|
||||
width: 48px;
|
||||
height: 48px;
|
||||
border-radius: var(--radius-md);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 1.5rem;
|
||||
margin-bottom: 20px;
|
||||
background: rgba(99, 102, 241, 0.12);
|
||||
border: 1px solid rgba(99, 102, 241, 0.25);
|
||||
color: var(--accent-secondary);
|
||||
}
|
||||
|
||||
.f-title {
|
||||
font-size: 1.25rem;
|
||||
font-weight: 700;
|
||||
margin-bottom: 10px;
|
||||
color: var(--text-main);
|
||||
}
|
||||
|
||||
.f-desc {
|
||||
color: var(--text-muted);
|
||||
font-size: 0.95rem;
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
/* Install Grid */
|
||||
.install-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
|
||||
gap: 24px;
|
||||
}
|
||||
|
||||
.install-card {
|
||||
background: var(--bg-surface);
|
||||
border: 1px solid var(--border-subtle);
|
||||
border-radius: var(--radius-lg);
|
||||
padding: 30px;
|
||||
}
|
||||
|
||||
.install-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.install-platform {
|
||||
font-size: 1.2rem;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.code-block {
|
||||
background: var(--bg-input);
|
||||
border: 1px solid var(--border-subtle);
|
||||
border-radius: var(--radius-md);
|
||||
padding: 16px;
|
||||
font-family: var(--font-mono);
|
||||
font-size: 0.85rem;
|
||||
overflow-x: auto;
|
||||
margin-bottom: 20px;
|
||||
color: #cbd5e1;
|
||||
}
|
||||
|
||||
/* About Section */
|
||||
.about-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
|
||||
gap: 24px;
|
||||
}
|
||||
|
||||
.about-card {
|
||||
background: var(--bg-surface);
|
||||
border: 1px solid var(--border-subtle);
|
||||
border-radius: var(--radius-lg);
|
||||
padding: 32px;
|
||||
}
|
||||
|
||||
.about-profile {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 16px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.avatar-badge {
|
||||
width: 54px;
|
||||
height: 54px;
|
||||
border-radius: var(--radius-md);
|
||||
background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-secondary) 100%);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-weight: 800;
|
||||
font-size: 1.3rem;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.profile-name {
|
||||
font-size: 1.2rem;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.profile-role {
|
||||
font-size: 0.85rem;
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
.about-text {
|
||||
font-size: 0.95rem;
|
||||
color: var(--text-muted);
|
||||
line-height: 1.6;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.chip-row {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.chip {
|
||||
padding: 4px 12px;
|
||||
border-radius: var(--radius-full);
|
||||
font-size: 0.78rem;
|
||||
background: rgba(255, 255, 255, 0.04);
|
||||
border: 1px solid var(--border-subtle);
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
/* Footer */
|
||||
.site-footer {
|
||||
margin-top: auto;
|
||||
background: var(--bg-surface);
|
||||
border-top: 1px solid var(--border-subtle);
|
||||
padding: 40px 24px;
|
||||
font-size: 0.88rem;
|
||||
color: var(--text-dim);
|
||||
}
|
||||
|
||||
.footer-container {
|
||||
max-width: 1200px;
|
||||
margin: 0 auto;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 20px;
|
||||
}
|
||||
|
||||
.footer-links {
|
||||
display: flex;
|
||||
gap: 20px;
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.nav-links {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user