Compare commits
34 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
10dbf786b5 | ||
|
|
518fcbaf4d | ||
|
|
40c23c61ef | ||
|
|
18c5f72cf2 | ||
|
|
67af5584fb | ||
|
|
4495b2209c | ||
|
|
105ca2aa70 | ||
|
|
f31176085c | ||
|
|
29c223652c | ||
|
|
d79bec2312 | ||
|
|
0bbb412e97 | ||
|
|
e5f400749e | ||
|
|
85d72b7b28 | ||
|
|
7a745a30db | ||
|
|
712b880ab2 | ||
|
|
b80fed3245 | ||
|
|
20ab94aa3e | ||
|
|
5d697fbcef | ||
|
|
c6dbf6d195 | ||
|
|
1e2d4156a5 | ||
|
|
7d60b77c62 | ||
|
|
5c7bf224c3 | ||
|
|
494fcc0f9a | ||
|
|
edacd27aef | ||
|
|
81d602e381 | ||
|
|
d59ded5cde | ||
|
|
399415c6b8 | ||
|
|
4679300a64 | ||
|
|
9864040456 | ||
|
|
dcc33ac513 | ||
|
|
950b858af7 | ||
|
|
b413f2bf3a | ||
|
|
7c962a4924 | ||
|
|
30f5ededa3 |
3
.gitignore
vendored
@ -193,6 +193,7 @@ ClientBin/
|
|||||||
*.pfx
|
*.pfx
|
||||||
*.publishsettings
|
*.publishsettings
|
||||||
node_modules/
|
node_modules/
|
||||||
|
dist/
|
||||||
orleans.codegen.cs
|
orleans.codegen.cs
|
||||||
.directory
|
.directory
|
||||||
|
|
||||||
@ -262,5 +263,3 @@ __pycache__/
|
|||||||
*.pyc
|
*.pyc
|
||||||
|
|
||||||
|
|
||||||
**/*docker-compose/LetsEncryptServer/acme
|
|
||||||
**/*docker-compose/LetsEncryptServer/cache
|
|
||||||
845
LICENSE.md
@ -1,675 +1,174 @@
|
|||||||
### GNU GENERAL PUBLIC LICENSE
|
Apache License
|
||||||
|
Version 2.0, January 2004
|
||||||
Version 3, 29 June 2007
|
http://www.apache.org/licenses/
|
||||||
|
|
||||||
Copyright (C) 2007 Free Software Foundation, Inc.
|
---
|
||||||
<https://fsf.org/>
|
|
||||||
|
## TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||||
Everyone is permitted to copy and distribute verbatim copies of this
|
|
||||||
license document, but changing it is not allowed.
|
### 1. Definitions
|
||||||
|
|
||||||
### Preamble
|
"License" shall mean the terms and conditions for use, reproduction,
|
||||||
|
and distribution as defined by Sections 1 through 9 of this document.
|
||||||
The GNU General Public License is a free, copyleft license for
|
|
||||||
software and other kinds of works.
|
"Licensor" shall mean the copyright owner or entity authorized by
|
||||||
|
the copyright owner that is granting the License.
|
||||||
The licenses for most software and other practical works are designed
|
|
||||||
to take away your freedom to share and change the works. By contrast,
|
"Legal Entity" shall mean the union of the acting entity and all
|
||||||
the GNU General Public License is intended to guarantee your freedom
|
other entities that control, are controlled by, or are under common
|
||||||
to share and change all versions of a program--to make sure it remains
|
control with that entity. For the purposes of this definition,
|
||||||
free software for all its users. We, the Free Software Foundation, use
|
"control" means (i) the power, direct or indirect, to cause the
|
||||||
the GNU General Public License for most of our software; it applies
|
direction or management of such entity, whether by contract or
|
||||||
also to any other work released this way by its authors. You can apply
|
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||||
it to your programs, too.
|
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||||
|
|
||||||
When we speak of free software, we are referring to freedom, not
|
"You" (or "Your") shall mean an individual or Legal Entity
|
||||||
price. Our General Public Licenses are designed to make sure that you
|
exercising permissions granted by this License.
|
||||||
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
|
"Source" form shall mean the preferred form for making modifications,
|
||||||
want it, that you can change the software or use pieces of it in new
|
including but not limited to software source code, documentation
|
||||||
free programs, and that you know you can do these things.
|
source, and configuration files.
|
||||||
|
|
||||||
To protect your rights, we need to prevent others from denying you
|
"Object" form shall mean any form resulting from mechanical
|
||||||
these rights or asking you to surrender the rights. Therefore, you
|
transformation or translation of a Source form, including but not
|
||||||
have certain responsibilities if you distribute copies of the
|
limited to compiled object code, generated documentation, and
|
||||||
software, or if you modify it: responsibilities to respect the freedom
|
conversions to other media types.
|
||||||
of others.
|
|
||||||
|
"Work" shall mean the work of authorship, whether in Source or
|
||||||
For example, if you distribute copies of such a program, whether
|
Object form, made available under the License, as indicated by a
|
||||||
gratis or for a fee, you must pass on to the recipients the same
|
copyright notice that is included in or attached to the work
|
||||||
freedoms that you received. You must make sure that they, too, receive
|
(an example is provided in the Appendix below).
|
||||||
or can get the source code. And you must show them these terms so they
|
|
||||||
know their rights.
|
"Derivative Works" shall mean any work, whether in Source or Object
|
||||||
|
form, that is based on (or derived from) the Work and for which the
|
||||||
Developers that use the GNU GPL protect your rights with two steps:
|
editorial revisions, annotations, elaborations, or other modifications
|
||||||
(1) assert copyright on the software, and (2) offer you this License
|
represent, as a whole, an original work of authorship. For the purposes
|
||||||
giving you legal permission to copy, distribute and/or modify it.
|
of this License, Derivative Works shall not include works that remain
|
||||||
|
separable from, or merely link (or bind by name) to the interfaces of,
|
||||||
For the developers' and authors' protection, the GPL clearly explains
|
the Work and Derivative Works thereof.
|
||||||
that there is no warranty for this free software. For both users' and
|
|
||||||
authors' sake, the GPL requires that modified versions be marked as
|
"Contribution" shall mean any work of authorship, including
|
||||||
changed, so that their problems will not be attributed erroneously to
|
the original version of the Work and any modifications or additions
|
||||||
authors of previous versions.
|
to that Work or Derivative Works thereof, that is intentionally
|
||||||
|
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||||
Some devices are designed to deny users access to install or run
|
or by an individual or Legal Entity authorized to submit on behalf of
|
||||||
modified versions of the software inside them, although the
|
the copyright owner. For the purposes of this definition, "submitted"
|
||||||
manufacturer can do so. This is fundamentally incompatible with the
|
means any form of electronic, verbal, or written communication sent
|
||||||
aim of protecting users' freedom to change the software. The
|
to the Licensor or its representatives, including but not limited to
|
||||||
systematic pattern of such abuse occurs in the area of products for
|
communication on electronic mailing lists, source code control systems,
|
||||||
individuals to use, which is precisely where it is most unacceptable.
|
and issue tracking systems that are managed by, or on behalf of, the
|
||||||
Therefore, we have designed this version of the GPL to prohibit the
|
Licensor for the purpose of discussing and improving the Work, but
|
||||||
practice for those products. If such problems arise substantially in
|
excluding communication that is conspicuously marked or otherwise
|
||||||
other domains, we stand ready to extend this provision to those
|
designated in writing by the copyright owner as "Not a Contribution."
|
||||||
domains in future versions of the GPL, as needed to protect the
|
|
||||||
freedom of users.
|
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||||
|
on behalf of whom a Contribution has been received by Licensor and
|
||||||
Finally, every program is threatened constantly by software patents.
|
subsequently incorporated within the Work.
|
||||||
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
|
### 2. Grant of Copyright License
|
||||||
assures that patents cannot be used to render the program non-free.
|
|
||||||
|
Subject to the terms and conditions of this License, each Contributor
|
||||||
The precise terms and conditions for copying, distribution and
|
hereby grants to You a perpetual, worldwide, non-exclusive, no-charge,
|
||||||
modification follow.
|
royalty-free, irrevocable copyright license to reproduce, prepare
|
||||||
|
Derivative Works of, publicly display, publicly perform, sublicense,
|
||||||
### TERMS AND CONDITIONS
|
and distribute the Work and such Derivative Works in Source or Object
|
||||||
|
form.
|
||||||
#### 0. Definitions.
|
|
||||||
|
---
|
||||||
"This License" refers to version 3 of the GNU General Public License.
|
|
||||||
|
### 3. Grant of Patent License
|
||||||
"Copyright" also means copyright-like laws that apply to other kinds
|
|
||||||
of works, such as semiconductor masks.
|
Subject to the terms and conditions of this License, each Contributor
|
||||||
|
hereby grants to You a perpetual, worldwide, non-exclusive, no-charge,
|
||||||
"The Program" refers to any copyrightable work licensed under this
|
royalty-free, irrevocable (except as stated in this section) patent
|
||||||
License. Each licensee is addressed as "you". "Licensees" and
|
license to make, have made, use, offer to sell, sell, import, and
|
||||||
"recipients" may be individuals or organizations.
|
otherwise transfer the Work, where such license applies only to those
|
||||||
|
patent claims licensable by such Contributor that are necessarily
|
||||||
To "modify" a work means to copy from or adapt all or part of the work
|
infringed by their Contribution(s) alone or by combination of their
|
||||||
in a fashion requiring copyright permission, other than the making of
|
Contribution(s) with the Work to which such Contribution(s) was
|
||||||
an exact copy. The resulting work is called a "modified version" of
|
submitted.
|
||||||
the earlier work or a work "based on" the earlier work.
|
|
||||||
|
If You institute patent litigation against any entity (including a
|
||||||
A "covered work" means either the unmodified Program or a work based
|
cross-claim or counterclaim in a lawsuit) alleging that the Work or a
|
||||||
on the Program.
|
Contribution incorporated within the Work constitutes direct or
|
||||||
|
contributory patent infringement, then any patent licenses granted to
|
||||||
To "propagate" a work means to do anything with it that, without
|
You under this License for that Work shall terminate as of the date
|
||||||
permission, would make you directly or secondarily liable for
|
such litigation is filed.
|
||||||
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.
|
### 4. Redistribution
|
||||||
|
|
||||||
To "convey" a work means any kind of propagation that enables other
|
You may reproduce and distribute copies of the Work or Derivative Works
|
||||||
parties to make or receive copies. Mere interaction with a user
|
thereof in any medium, with or without modifications, and in Source or
|
||||||
through a computer network, with no transfer of a copy, is not
|
Object form, provided that You meet the following conditions:
|
||||||
conveying.
|
|
||||||
|
- (a) You must give any other recipients of the Work or Derivative Works
|
||||||
An interactive user interface displays "Appropriate Legal Notices" to
|
a copy of this License; and
|
||||||
the extent that it includes a convenient and prominently visible
|
- (b) You must cause any modified files to carry prominent notices
|
||||||
feature that (1) displays an appropriate copyright notice, and (2)
|
stating that You changed the files; and
|
||||||
tells the user that there is no warranty for the work (except to the
|
- (c) You must retain, in the Source form of any Derivative Works that
|
||||||
extent that warranties are provided), that licensees may convey the
|
You distribute, all copyright, patent, trademark, and attribution
|
||||||
work under this License, and how to view a copy of this License. If
|
notices from the Source form of the Work, excluding those notices that
|
||||||
the interface presents a list of user commands or options, such as a
|
do not pertain to any part of the Derivative Works; and
|
||||||
menu, a prominent item in the list meets this criterion.
|
- (d) If the Work includes a "NOTICE" text file as part of its
|
||||||
|
distribution, then any Derivative Works that You distribute must
|
||||||
#### 1. Source Code.
|
include a readable copy of the attribution notices contained within
|
||||||
|
such NOTICE file, excluding those notices that do not pertain to any
|
||||||
The "source code" for a work means the preferred form of the work for
|
part of the Derivative Works, in at least one of the following places:
|
||||||
making modifications to it. "Object code" means any non-source form of
|
within a NOTICE text file distributed as part of the Derivative Works;
|
||||||
a work.
|
within the Source form or documentation, if provided along with the
|
||||||
|
Derivative Works; or, within a display generated by the Derivative
|
||||||
A "Standard Interface" means an interface that either is an official
|
Works, if and wherever such third-party notices normally appear.
|
||||||
standard defined by a recognized standards body, or, in the case of
|
|
||||||
interfaces specified for a particular programming language, one that
|
The contents of the NOTICE file are for informational purposes only and
|
||||||
is widely used among developers working in that language.
|
do not modify the License.
|
||||||
|
|
||||||
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
|
### 5. Submission of Contributions
|
||||||
Component, and (b) serves only to enable use of the work with that
|
|
||||||
Major Component, or to implement a Standard Interface for which an
|
Unless You explicitly state otherwise, any Contribution intentionally
|
||||||
implementation is available to the public in source code form. A
|
submitted for inclusion in the Work by You to the Licensor shall be
|
||||||
"Major Component", in this context, means a major essential component
|
under the terms and conditions of this License, without any additional
|
||||||
(kernel, window system, and so on) of the specific operating system
|
terms or conditions.
|
||||||
(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
|
### 6. Trademarks
|
||||||
the source code needed to generate, install, and (for an executable
|
|
||||||
work) run the object code and to modify the work, including scripts to
|
This License does not grant permission to use the trade names,
|
||||||
control those activities. However, it does not include the work's
|
trademarks, service marks, or product names of the Licensor, except as
|
||||||
System Libraries, or general-purpose tools or generally available free
|
required for reasonable and customary use in describing the origin of
|
||||||
programs which are used unmodified in performing those activities but
|
the Work and reproducing the content of the NOTICE file.
|
||||||
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,
|
### 7. Disclaimer of Warranty
|
||||||
such as by intimate data communication or control flow between those
|
|
||||||
subprograms and other parts of the work.
|
Unless required by applicable law or agreed to in writing, Licensor
|
||||||
|
provides the Work (and each Contributor provides its Contributions) on
|
||||||
The Corresponding Source need not include anything that users can
|
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
|
||||||
regenerate automatically from other parts of the Corresponding Source.
|
express or implied.
|
||||||
|
|
||||||
The Corresponding Source for a work in source code form is that same
|
---
|
||||||
work.
|
|
||||||
|
### 8. Limitation of Liability
|
||||||
#### 2. Basic Permissions.
|
|
||||||
|
In no event and under no legal theory, whether in tort (including
|
||||||
All rights granted under this License are granted for the term of
|
negligence), contract, or otherwise, unless required by applicable law,
|
||||||
copyright on the Program, and are irrevocable provided the stated
|
shall any Contributor be liable to You for damages arising from the use
|
||||||
conditions are met. This License explicitly affirms your unlimited
|
of the Work.
|
||||||
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.
|
### 9. Accepting Warranty or Additional Liability
|
||||||
|
|
||||||
You may make, run and propagate covered works that you do not convey,
|
While redistributing the Work or Derivative Works thereof, You may
|
||||||
without conditions so long as your license otherwise remains in force.
|
choose to offer support or warranty at Your own responsibility.
|
||||||
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
|
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>.
|
|
||||||
|
|||||||
BIN
assets/chrome_IvvCTtYcbi.png
Normal file
|
After Width: | Height: | Size: 24 KiB |
BIN
assets/chrome_KJw6epn11q.png
Normal file
|
After Width: | Height: | Size: 107 KiB |
BIN
assets/chrome_RPsKiPwaDC.png
Normal file
|
After Width: | Height: | Size: 113 KiB |
BIN
assets/chrome_YYr4z77ROv.png
Normal file
|
After Width: | Height: | Size: 14 KiB |
BIN
assets/chrome_hTAVSZW6fb.png
Normal file
|
After Width: | Height: | Size: 56 KiB |
BIN
assets/chrome_j5MltyeUfB.png
Normal file
|
After Width: | Height: | Size: 18 KiB |
BIN
assets/chrome_vPdHf2afpO.png
Normal file
|
After Width: | Height: | Size: 32 KiB |
BIN
assets/chrome_ydyMattQYU.png
Normal file
|
After Width: | Height: | Size: 45 KiB |
@ -1,24 +0,0 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<TargetFramework>net8.0</TargetFramework>
|
|
||||||
<Nullable>enable</Nullable>
|
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
|
||||||
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.19.6" />
|
|
||||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<ProjectReference Include="..\Models\Models.csproj" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<None Update="build_and_deploy.sh">
|
|
||||||
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
|
|
||||||
</None>
|
|
||||||
</ItemGroup>
|
|
||||||
</Project>
|
|
||||||
@ -1,37 +0,0 @@
|
|||||||
|
|
||||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
|
||||||
# Visual Studio Version 17
|
|
||||||
VisualStudioVersion = 17.5.002.0
|
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Agent - Backup (1)", "Agent - Backup (1).csproj", "{392E9E34-E17C-4118-9C83-52AF52A56E54}"
|
|
||||||
EndProject
|
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Agent - Backup", "Agent - Backup.csproj", "{18049E33-180E-41F1-8343-5BCD4755B2A8}"
|
|
||||||
EndProject
|
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Agent", "Agent.csproj", "{2C1A9C83-0B26-450C-A874-0B8DBD251B0F}"
|
|
||||||
EndProject
|
|
||||||
Global
|
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
|
||||||
Debug|Any CPU = Debug|Any CPU
|
|
||||||
Release|Any CPU = Release|Any CPU
|
|
||||||
EndGlobalSection
|
|
||||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
|
||||||
{392E9E34-E17C-4118-9C83-52AF52A56E54}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{392E9E34-E17C-4118-9C83-52AF52A56E54}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{392E9E34-E17C-4118-9C83-52AF52A56E54}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{392E9E34-E17C-4118-9C83-52AF52A56E54}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{18049E33-180E-41F1-8343-5BCD4755B2A8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{18049E33-180E-41F1-8343-5BCD4755B2A8}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{18049E33-180E-41F1-8343-5BCD4755B2A8}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{18049E33-180E-41F1-8343-5BCD4755B2A8}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{2C1A9C83-0B26-450C-A874-0B8DBD251B0F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{2C1A9C83-0B26-450C-A874-0B8DBD251B0F}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{2C1A9C83-0B26-450C-A874-0B8DBD251B0F}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{2C1A9C83-0B26-450C-A874-0B8DBD251B0F}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
EndGlobalSection
|
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
|
||||||
HideSolutionNode = FALSE
|
|
||||||
EndGlobalSection
|
|
||||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
|
||||||
SolutionGuid = {281E7450-1EDC-4E77-B04F-C14F65273D90}
|
|
||||||
EndGlobalSection
|
|
||||||
EndGlobal
|
|
||||||
@ -1,28 +0,0 @@
|
|||||||
using Microsoft.AspNetCore.Mvc.Filters;
|
|
||||||
using Microsoft.AspNetCore.Mvc;
|
|
||||||
using Microsoft.Extensions.Options;
|
|
||||||
|
|
||||||
namespace MaksIT.Agent.AuthorizationFilters;
|
|
||||||
|
|
||||||
public class ApiKeyAuthorizationFilter : IAuthorizationFilter {
|
|
||||||
|
|
||||||
private readonly Configuration _appSettings;
|
|
||||||
|
|
||||||
public ApiKeyAuthorizationFilter(
|
|
||||||
IOptions<Configuration> appSettings
|
|
||||||
) {
|
|
||||||
_appSettings = appSettings.Value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void OnAuthorization(AuthorizationFilterContext context) {
|
|
||||||
if (!context.HttpContext.Request.Headers.TryGetValue("X-API-KEY", out var extractedApiKey)) {
|
|
||||||
context.Result = new UnauthorizedResult();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!_appSettings.ApiKey.Equals(extractedApiKey)) {
|
|
||||||
context.Result = new UnauthorizedResult();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,29 +0,0 @@
|
|||||||
namespace MaksIT.Agent {
|
|
||||||
public class Configuration {
|
|
||||||
|
|
||||||
private string? _apiKey;
|
|
||||||
public string ApiKey {
|
|
||||||
get {
|
|
||||||
var env = Environment.GetEnvironmentVariable("MAKS-IT_AGENT_API_KEY");
|
|
||||||
return env ?? _apiKey ?? string.Empty;
|
|
||||||
}
|
|
||||||
|
|
||||||
set {
|
|
||||||
_apiKey = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private string? _certsPath;
|
|
||||||
public string CertsPath {
|
|
||||||
get {
|
|
||||||
var env = Environment.GetEnvironmentVariable("MAKS-IT_AGENT_CERTS_PATH");
|
|
||||||
return env ?? _certsPath ?? string.Empty;
|
|
||||||
}
|
|
||||||
|
|
||||||
set {
|
|
||||||
_certsPath = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,35 +0,0 @@
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
|
||||||
using Microsoft.Extensions.Options;
|
|
||||||
|
|
||||||
using MaksIT.Models.Agent.Requests;
|
|
||||||
using MaksIT.Agent.AuthorizationFilters;
|
|
||||||
|
|
||||||
namespace MaksIT.Agent.Controllers;
|
|
||||||
|
|
||||||
[ApiController]
|
|
||||||
[Route("[controller]")]
|
|
||||||
[ServiceFilter(typeof(ApiKeyAuthorizationFilter))]
|
|
||||||
public class CertsController : ControllerBase {
|
|
||||||
|
|
||||||
private readonly Configuration _appSettings;
|
|
||||||
private readonly ILogger<CertsController> _logger;
|
|
||||||
|
|
||||||
public CertsController(
|
|
||||||
IOptions<Configuration> appSettings,
|
|
||||||
ILogger<CertsController> logger
|
|
||||||
) {
|
|
||||||
_logger = logger;
|
|
||||||
_appSettings = appSettings.Value;
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpPost("[action]")]
|
|
||||||
public IActionResult Upload([FromBody] CertsUploadRequest requestData) {
|
|
||||||
_logger.LogInformation("Uploading certificates");
|
|
||||||
|
|
||||||
foreach (var (fileName, fileContent) in requestData.Certs) {
|
|
||||||
System.IO.File.WriteAllText(Path.Combine(_appSettings.CertsPath, fileName), fileContent);
|
|
||||||
}
|
|
||||||
|
|
||||||
return Ok("Certificates uploaded successfully");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,17 +0,0 @@
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
|
||||||
|
|
||||||
using MaksIT.Agent.AuthorizationFilters;
|
|
||||||
|
|
||||||
namespace Agent.Controllers {
|
|
||||||
|
|
||||||
[ApiController]
|
|
||||||
[Route("[controller]")]
|
|
||||||
[ServiceFilter(typeof(ApiKeyAuthorizationFilter))]
|
|
||||||
public class HelloWorldController : ControllerBase {
|
|
||||||
|
|
||||||
[HttpGet]
|
|
||||||
public IActionResult Get() {
|
|
||||||
return Ok("Hello, World!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,57 +0,0 @@
|
|||||||
using System.Diagnostics;
|
|
||||||
|
|
||||||
using Microsoft.AspNetCore.Mvc;
|
|
||||||
using Microsoft.Extensions.Options;
|
|
||||||
|
|
||||||
using MaksIT.Agent.AuthorizationFilters;
|
|
||||||
using MaksIT.Models.Agent.Requests;
|
|
||||||
|
|
||||||
namespace MaksIT.Agent.Controllers;
|
|
||||||
|
|
||||||
[ApiController]
|
|
||||||
[Route("[controller]")]
|
|
||||||
[ServiceFilter(typeof(ApiKeyAuthorizationFilter))]
|
|
||||||
public class ServiceController : ControllerBase {
|
|
||||||
|
|
||||||
private readonly Configuration _appSettings;
|
|
||||||
|
|
||||||
public ServiceController(
|
|
||||||
IOptions<Configuration> appSettings
|
|
||||||
) {
|
|
||||||
_appSettings = appSettings.Value;
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpPost("[action]")]
|
|
||||||
public IActionResult Reload([FromBody] ServiceReloadRequest requestData) {
|
|
||||||
var serviceName = requestData.ServiceName;
|
|
||||||
|
|
||||||
try {
|
|
||||||
var processStartInfo = new ProcessStartInfo {
|
|
||||||
FileName = "/bin/systemctl",
|
|
||||||
Arguments = $"reload {serviceName}",
|
|
||||||
RedirectStandardOutput = true,
|
|
||||||
RedirectStandardError = true,
|
|
||||||
UseShellExecute = false,
|
|
||||||
CreateNoWindow = true
|
|
||||||
};
|
|
||||||
|
|
||||||
using (var process = new Process { StartInfo = processStartInfo }) {
|
|
||||||
process.Start();
|
|
||||||
process.WaitForExit();
|
|
||||||
|
|
||||||
var output = process.StandardOutput.ReadToEnd();
|
|
||||||
var error = process.StandardError.ReadToEnd();
|
|
||||||
|
|
||||||
if (process.ExitCode != 0) {
|
|
||||||
return StatusCode(500, $"Error reloading service: {error}");
|
|
||||||
}
|
|
||||||
|
|
||||||
return Ok($"Service {serviceName} reloaded successfully: {output}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex) {
|
|
||||||
return StatusCode(500, $"Exception: {ex.Message}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@ -1,37 +0,0 @@
|
|||||||
using MaksIT.Agent;
|
|
||||||
using MaksIT.Agent.AuthorizationFilters;
|
|
||||||
|
|
||||||
var builder = WebApplication.CreateBuilder(args);
|
|
||||||
|
|
||||||
// Extract configuration
|
|
||||||
var configuration = builder.Configuration;
|
|
||||||
|
|
||||||
// Configure strongly typed settings objects
|
|
||||||
var configurationSection = configuration.GetSection("Configuration");
|
|
||||||
var appSettings = configurationSection.Get<Configuration>() ?? throw new ArgumentNullException();
|
|
||||||
|
|
||||||
// Allow configurations to be available through IOptions<Configuration>
|
|
||||||
builder.Services.Configure<Configuration>(configurationSection);
|
|
||||||
|
|
||||||
// Add services to the container.
|
|
||||||
|
|
||||||
builder.Services.AddControllers();
|
|
||||||
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
|
||||||
builder.Services.AddEndpointsApiExplorer();
|
|
||||||
builder.Services.AddSwaggerGen();
|
|
||||||
|
|
||||||
builder.Services.AddScoped<ApiKeyAuthorizationFilter>();
|
|
||||||
|
|
||||||
var app = builder.Build();
|
|
||||||
|
|
||||||
// Configure the HTTP request pipeline.
|
|
||||||
if (app.Environment.IsDevelopment()) {
|
|
||||||
app.UseSwagger();
|
|
||||||
app.UseSwaggerUI();
|
|
||||||
}
|
|
||||||
|
|
||||||
app.UseAuthorization();
|
|
||||||
|
|
||||||
app.MapControllers();
|
|
||||||
|
|
||||||
app.Run();
|
|
||||||
@ -1,40 +0,0 @@
|
|||||||
{
|
|
||||||
"profiles": {
|
|
||||||
"http": {
|
|
||||||
"commandName": "Project",
|
|
||||||
"launchBrowser": true,
|
|
||||||
"launchUrl": "swagger",
|
|
||||||
"environmentVariables": {
|
|
||||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
|
||||||
},
|
|
||||||
"dotnetRunMessages": true,
|
|
||||||
"applicationUrl": "http://localhost:5000"
|
|
||||||
},
|
|
||||||
"IIS Express": {
|
|
||||||
"commandName": "IISExpress",
|
|
||||||
"launchBrowser": true,
|
|
||||||
"launchUrl": "swagger",
|
|
||||||
"environmentVariables": {
|
|
||||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"Container (Dockerfile)": {
|
|
||||||
"commandName": "Docker",
|
|
||||||
"launchBrowser": true,
|
|
||||||
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/swagger",
|
|
||||||
"environmentVariables": {
|
|
||||||
"ASPNETCORE_HTTP_PORTS": "5000"
|
|
||||||
},
|
|
||||||
"publishAllPorts": true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"$schema": "http://json.schemastore.org/launchsettings.json",
|
|
||||||
"iisSettings": {
|
|
||||||
"windowsAuthentication": false,
|
|
||||||
"anonymousAuthentication": true,
|
|
||||||
"iisExpress": {
|
|
||||||
"applicationUrl": "http://localhost:7748",
|
|
||||||
"sslPort": 0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,6 +0,0 @@
|
|||||||
@ServiceReloader_HostAddress = http://localhost:5186
|
|
||||||
|
|
||||||
GET {{ServiceReloader_HostAddress}}/weatherforecast/
|
|
||||||
Accept: application/json
|
|
||||||
|
|
||||||
###
|
|
||||||
@ -1,14 +0,0 @@
|
|||||||
{
|
|
||||||
"Logging": {
|
|
||||||
"LogLevel": {
|
|
||||||
"Default": "Information",
|
|
||||||
"Microsoft.AspNetCore": "Warning"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"AllowedHosts": "*",
|
|
||||||
|
|
||||||
"Configuration": {
|
|
||||||
"ApiKey": "UGnCaElLLJClHgUeet/yr7vNvPf13b1WkDJQMfsiP6I=",
|
|
||||||
"CertsPath": "/etc/haproxy/certs"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,77 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# Variables
|
|
||||||
SERVICE_NAME="maks-it-agent"
|
|
||||||
SERVICE_PORT="5000"
|
|
||||||
SERVICE_FILE="/etc/systemd/system/$SERVICE_NAME.service"
|
|
||||||
INSTALL_DIR="/opt/$SERVICE_NAME"
|
|
||||||
DOTNET_EXEC="/usr/bin/dotnet"
|
|
||||||
EXEC_CMD="$DOTNET_EXEC $INSTALL_DIR/Agent.dll --urls \"http://*:$SERVICE_PORT\""
|
|
||||||
APPSETTINGS_FILE="appsettings.json"
|
|
||||||
NO_NEW_KEY_FLAG="--no-new-key"
|
|
||||||
|
|
||||||
# Update package index and install the Microsoft package repository
|
|
||||||
# sudo rpm -Uvh https://packages.microsoft.com/config/centos/8/packages-microsoft-prod.rpm
|
|
||||||
sudo dnf install -y dotnet-sdk-8.0
|
|
||||||
|
|
||||||
# Check if the service exists and stop it if it does
|
|
||||||
if systemctl list-units --full -all | grep -Fq "$SERVICE_NAME.service"; then
|
|
||||||
sudo systemctl stop $SERVICE_NAME.service
|
|
||||||
sudo systemctl disable $SERVICE_NAME.service
|
|
||||||
sudo rm -f $SERVICE_FILE
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Clean up the old files if they exist
|
|
||||||
sudo rm -rf $INSTALL_DIR
|
|
||||||
|
|
||||||
# Create the application directory
|
|
||||||
sudo mkdir -p $INSTALL_DIR
|
|
||||||
|
|
||||||
# Update appsettings.json if --no-new-key flag is not provided
|
|
||||||
if [[ "$1" != "$NO_NEW_KEY_FLAG" ]]; then
|
|
||||||
NEW_API_KEY=$(openssl rand -base64 32)
|
|
||||||
jq --arg newApiKey "$NEW_API_KEY" '.Configuration.ApiKey = $newApiKey' $APPSETTINGS_FILE > tmp.$$.json && mv tmp.$$.json $APPSETTINGS_FILE
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Build and publish the .NET application
|
|
||||||
sudo dotnet build Agent.csproj --configuration Release
|
|
||||||
sudo dotnet publish Agent.csproj -c Release -o $INSTALL_DIR
|
|
||||||
|
|
||||||
# Create the systemd service unit file
|
|
||||||
sudo bash -c "cat > $SERVICE_FILE <<EOL
|
|
||||||
[Unit]
|
|
||||||
Description=Maks-IT Agent
|
|
||||||
After=network.target
|
|
||||||
|
|
||||||
[Service]
|
|
||||||
WorkingDirectory=$INSTALL_DIR
|
|
||||||
ExecStart=$EXEC_CMD
|
|
||||||
Restart=always
|
|
||||||
RestartSec=10
|
|
||||||
KillSignal=SIGINT
|
|
||||||
SyslogIdentifier=dotnet-servicereloader
|
|
||||||
User=root
|
|
||||||
Environment=ASPNETCORE_ENVIRONMENT=Production
|
|
||||||
|
|
||||||
[Install]
|
|
||||||
WantedBy=multi-user.target
|
|
||||||
EOL"
|
|
||||||
|
|
||||||
# Reload systemd to recognize the new service, enable it to start on boot, and start the service now
|
|
||||||
sudo systemctl daemon-reload
|
|
||||||
sudo systemctl enable --now $SERVICE_NAME.service
|
|
||||||
|
|
||||||
# Create the firewall service rule
|
|
||||||
echo '<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<service>
|
|
||||||
<short>Maks-IT Agent</short>
|
|
||||||
<port protocol="tcp" port="'$SERVICE_PORT'"/>
|
|
||||||
</service>' > /etc/firewalld/services/maks-it-agent.xml
|
|
||||||
|
|
||||||
sleep 10
|
|
||||||
|
|
||||||
# Add the services to the firewall
|
|
||||||
firewall-cmd --permanent --add-service=maks-it-agent
|
|
||||||
|
|
||||||
# Reload the firewall
|
|
||||||
firewall-cmd --reload
|
|
||||||
@ -1,12 +0,0 @@
|
|||||||
{
|
|
||||||
"extends": [
|
|
||||||
"next/core-web-vitals",
|
|
||||||
"plugin:prettier/recommended"
|
|
||||||
],
|
|
||||||
"rules": {
|
|
||||||
"prettier/prettier": "error",
|
|
||||||
"semi": "off",
|
|
||||||
"quotes": "off",
|
|
||||||
"indent": "off"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
36
src/ClientApp/.gitignore
vendored
@ -1,36 +0,0 @@
|
|||||||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
|
|
||||||
|
|
||||||
# dependencies
|
|
||||||
/node_modules
|
|
||||||
/.pnp
|
|
||||||
.pnp.js
|
|
||||||
.yarn/install-state.gz
|
|
||||||
|
|
||||||
# testing
|
|
||||||
/coverage
|
|
||||||
|
|
||||||
# next.js
|
|
||||||
/.next/
|
|
||||||
/out/
|
|
||||||
|
|
||||||
# production
|
|
||||||
/build
|
|
||||||
|
|
||||||
# misc
|
|
||||||
.DS_Store
|
|
||||||
*.pem
|
|
||||||
|
|
||||||
# debug
|
|
||||||
npm-debug.log*
|
|
||||||
yarn-debug.log*
|
|
||||||
yarn-error.log*
|
|
||||||
|
|
||||||
# local env files
|
|
||||||
.env*.local
|
|
||||||
|
|
||||||
# vercel
|
|
||||||
.vercel
|
|
||||||
|
|
||||||
# typescript
|
|
||||||
*.tsbuildinfo
|
|
||||||
next-env.d.ts
|
|
||||||
@ -1,25 +0,0 @@
|
|||||||
# Ignore artifacts:
|
|
||||||
build
|
|
||||||
coverage
|
|
||||||
dist
|
|
||||||
node_modules
|
|
||||||
|
|
||||||
# Ignore all configuration files:
|
|
||||||
*.config.js
|
|
||||||
*.config.ts
|
|
||||||
|
|
||||||
# Ignore specific files:
|
|
||||||
package-lock.json
|
|
||||||
yarn.lock
|
|
||||||
|
|
||||||
# Ignore logs:
|
|
||||||
*.log
|
|
||||||
|
|
||||||
# Ignore minified files:
|
|
||||||
*.min.js
|
|
||||||
|
|
||||||
# Ignore compiled code:
|
|
||||||
*.d.ts
|
|
||||||
|
|
||||||
# Ignore specific directories:
|
|
||||||
public
|
|
||||||
@ -1,7 +0,0 @@
|
|||||||
{
|
|
||||||
"singleQuote": true,
|
|
||||||
"semi": false,
|
|
||||||
"tabWidth": 2,
|
|
||||||
"endOfLine": "crlf",
|
|
||||||
"trailingComma": "none"
|
|
||||||
}
|
|
||||||
23
src/ClientApp/.vscode/settings.json
vendored
@ -1,23 +0,0 @@
|
|||||||
{
|
|
||||||
"editor.tabSize": 2,
|
|
||||||
"editor.codeActionsOnSave": {
|
|
||||||
"source.fixAll.eslint": "explicit"
|
|
||||||
},
|
|
||||||
"[javascript]": {
|
|
||||||
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
|
||||||
},
|
|
||||||
"[typescript]": {
|
|
||||||
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
|
||||||
},
|
|
||||||
"[typescriptreact]": {
|
|
||||||
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
|
||||||
},
|
|
||||||
"[json]": {
|
|
||||||
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
|
||||||
},
|
|
||||||
"eslint.validate": [
|
|
||||||
"javascript",
|
|
||||||
"typescript",
|
|
||||||
"typescriptreact"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
@ -1,33 +0,0 @@
|
|||||||
enum ApiRoutes {
|
|
||||||
ACCOUNTS = 'api/accounts',
|
|
||||||
|
|
||||||
ACCOUNT = 'api/account',
|
|
||||||
ACCOUNT_ID = 'api/account/{accountId}',
|
|
||||||
|
|
||||||
ACCOUNT_ID_CONTACTS = 'api/account/{accountId}/contacts',
|
|
||||||
ACCOUNT_ID_CONTACT_ID = 'api/account/{accountId}/contact/{index}',
|
|
||||||
|
|
||||||
ACCOUNT_ID_HOSTNAMES = 'api/account/{accountId}/hostnames',
|
|
||||||
ACCOUNT_ID_HOSTNAME_ID = 'api/account/{accountId}/hostname/{index}'
|
|
||||||
|
|
||||||
// CERTS_FLOW_CONFIGURE_CLIENT = `api/CertsFlow/ConfigureClient`,
|
|
||||||
// CERTS_FLOW_TERMS_OF_SERVICE = `api/CertsFlow/TermsOfService/{sessionId}`,
|
|
||||||
// CERTS_FLOW_INIT = `api/CertsFlow/Init/{sessionId}/{accountId}`,
|
|
||||||
// CERTS_FLOW_NEW_ORDER = `api/CertsFlow/NewOrder/{sessionId}`,
|
|
||||||
// CERTS_FLOW_GET_ORDER = `api/CertsFlow/GetOrder/{sessionId}`,
|
|
||||||
// CERTS_FLOW_GET_CERTIFICATES = `api/CertsFlow/GetCertificates/{sessionId}`,
|
|
||||||
// CERTS_FLOW_APPLY_CERTIFICATES = `api/CertsFlow/ApplyCertificates/{sessionId}`,
|
|
||||||
// CERTS_FLOW_HOSRS_WITH_UPCOMING_SSL_EXPIRY = `api/CertsFlow/HostsWithUpcomingSslExpiry/{sessionId}`
|
|
||||||
}
|
|
||||||
|
|
||||||
const GetApiRoute = (route: ApiRoutes, ...args: string[]): string => {
|
|
||||||
let result: string = route
|
|
||||||
args.forEach((arg) => {
|
|
||||||
result = result.replace(/{.*?}/, arg)
|
|
||||||
})
|
|
||||||
// TODO: need env var
|
|
||||||
return `http://localhost:8080/${result}`
|
|
||||||
//return `http://websrv0001.corp.maks-it.com:8080/${result}`
|
|
||||||
}
|
|
||||||
|
|
||||||
export { GetApiRoute, ApiRoutes }
|
|
||||||
@ -1,38 +0,0 @@
|
|||||||
# Use the specific Node.js version 20.14.0 image as the base image for building the app
|
|
||||||
FROM node:20.14.0-alpine AS build
|
|
||||||
|
|
||||||
# Set the working directory inside the container
|
|
||||||
WORKDIR /app
|
|
||||||
|
|
||||||
# Copy the package.json and package-lock.json files to the working directory
|
|
||||||
COPY ClientApp/package*.json ./
|
|
||||||
|
|
||||||
# Install the project dependencies
|
|
||||||
RUN npm install
|
|
||||||
|
|
||||||
# Copy the rest of the application code to the working directory
|
|
||||||
COPY ClientApp .
|
|
||||||
|
|
||||||
# Build the Next.js application for production
|
|
||||||
RUN npm run build
|
|
||||||
|
|
||||||
# Use the same Node.js image for running the app
|
|
||||||
FROM node:20.14.0-alpine AS production
|
|
||||||
|
|
||||||
# Set the working directory inside the container
|
|
||||||
WORKDIR /app
|
|
||||||
|
|
||||||
# Copy the package.json and package-lock.json files to the working directory
|
|
||||||
COPY ClientApp/package*.json ./
|
|
||||||
|
|
||||||
# Install only production dependencies
|
|
||||||
RUN npm install --only=production
|
|
||||||
|
|
||||||
# Copy the built Next.js application from the build stage to the current directory
|
|
||||||
COPY --from=build /app ./
|
|
||||||
|
|
||||||
# Expose port 3000 to access the application
|
|
||||||
EXPOSE 3000
|
|
||||||
|
|
||||||
# Start the Next.js server
|
|
||||||
CMD ["npm", "start"]
|
|
||||||
@ -1,36 +0,0 @@
|
|||||||
This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app).
|
|
||||||
|
|
||||||
## Getting Started
|
|
||||||
|
|
||||||
First, run the development server:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
npm run dev
|
|
||||||
# or
|
|
||||||
yarn dev
|
|
||||||
# or
|
|
||||||
pnpm dev
|
|
||||||
# or
|
|
||||||
bun dev
|
|
||||||
```
|
|
||||||
|
|
||||||
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
|
|
||||||
|
|
||||||
You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file.
|
|
||||||
|
|
||||||
This project uses [`next/font`](https://nextjs.org/docs/basic-features/font-optimization) to automatically optimize and load Inter, a custom Google Font.
|
|
||||||
|
|
||||||
## Learn More
|
|
||||||
|
|
||||||
To learn more about Next.js, take a look at the following resources:
|
|
||||||
|
|
||||||
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
|
|
||||||
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
|
|
||||||
|
|
||||||
You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome!
|
|
||||||
|
|
||||||
## Deploy on Vercel
|
|
||||||
|
|
||||||
The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.
|
|
||||||
|
|
||||||
Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details.
|
|
||||||
@ -1,10 +0,0 @@
|
|||||||
const AboutPage = () => {
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<h1 className="text-2xl font-bold">About</h1>
|
|
||||||
<p>This is the about page content.</p>
|
|
||||||
</>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export default AboutPage
|
|
||||||
@ -1,10 +0,0 @@
|
|||||||
const ContactPage = () => {
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<h1 className="text-2xl font-bold">Contact Us</h1>
|
|
||||||
<p>This is the contact page content.</p>
|
|
||||||
</>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export default ContactPage
|
|
||||||
|
Before Width: | Height: | Size: 25 KiB |
@ -1,3 +0,0 @@
|
|||||||
@tailwind base;
|
|
||||||
@tailwind components;
|
|
||||||
@tailwind utilities;
|
|
||||||
@ -1,97 +0,0 @@
|
|||||||
'use client'
|
|
||||||
|
|
||||||
import React, { FC, useState, useEffect, useRef } from 'react'
|
|
||||||
import { SideMenu } from '@/components/sidemenu'
|
|
||||||
import { TopMenu } from '@/components/topmenu'
|
|
||||||
import { Footer } from '@/components/footer'
|
|
||||||
import { OffCanvas } from '@/components/offcanvas'
|
|
||||||
import { Loader } from '@/components/loader'
|
|
||||||
import { Metadata } from 'next'
|
|
||||||
import { Toast } from '@/components/toast'
|
|
||||||
import { Provider } from 'react-redux'
|
|
||||||
import { store } from '@/redux/store'
|
|
||||||
import './globals.css'
|
|
||||||
|
|
||||||
const metadata: Metadata = {
|
|
||||||
title: 'Create Next App',
|
|
||||||
description: 'Generated by create next app'
|
|
||||||
}
|
|
||||||
|
|
||||||
const Layout: FC<{ children: React.ReactNode }> = ({ children }) => {
|
|
||||||
const [isSidebarCollapsed, setIsSidebarCollapsed] = useState(false)
|
|
||||||
const [isManuallyCollapsed, setManuallyCollapsed] = useState(false)
|
|
||||||
|
|
||||||
const init = useRef(false)
|
|
||||||
|
|
||||||
const toggleSidebar = () => {
|
|
||||||
setIsSidebarCollapsed((prev) => !prev)
|
|
||||||
}
|
|
||||||
|
|
||||||
const manuallyToggleSidebar = () => {
|
|
||||||
setManuallyCollapsed((prev) => !prev)
|
|
||||||
toggleSidebar()
|
|
||||||
}
|
|
||||||
|
|
||||||
const handleResize = () => {
|
|
||||||
if (!isManuallyCollapsed) {
|
|
||||||
if (window.innerWidth <= 768) {
|
|
||||||
if (!isSidebarCollapsed) setIsSidebarCollapsed(true)
|
|
||||||
} else {
|
|
||||||
if (isSidebarCollapsed) setIsSidebarCollapsed(false)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (isManuallyCollapsed) return
|
|
||||||
|
|
||||||
if (window.innerWidth > 768 && isSidebarCollapsed) {
|
|
||||||
setIsSidebarCollapsed(false)
|
|
||||||
} else if (window.innerWidth <= 768 && !isSidebarCollapsed) {
|
|
||||||
setIsSidebarCollapsed(true)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (!init.current) {
|
|
||||||
handleResize()
|
|
||||||
init.current = true
|
|
||||||
}
|
|
||||||
|
|
||||||
window.addEventListener('resize', handleResize)
|
|
||||||
return () => {
|
|
||||||
window.removeEventListener('resize', handleResize)
|
|
||||||
}
|
|
||||||
}, [isSidebarCollapsed, isManuallyCollapsed])
|
|
||||||
|
|
||||||
const [isOffCanvasOpen, setIsOffCanvasOpen] = useState(false)
|
|
||||||
|
|
||||||
const toggleOffCanvas = () => {
|
|
||||||
setIsOffCanvasOpen((prev) => !prev)
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<html lang="en">
|
|
||||||
<body className="h-screen overflow-hidden flex flex-col">
|
|
||||||
<Provider store={store}>
|
|
||||||
<Loader />
|
|
||||||
|
|
||||||
<div className="flex flex-1 overflow-hidden">
|
|
||||||
<SideMenu
|
|
||||||
isCollapsed={isSidebarCollapsed}
|
|
||||||
toggleSidebar={manuallyToggleSidebar}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<div className="flex flex-col flex-1 overflow-hidden">
|
|
||||||
<TopMenu />
|
|
||||||
<main className="flex-1 p-4 overflow-y-auto">{children}</main>
|
|
||||||
<Footer className="flex-shrink-0" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<Toast />
|
|
||||||
</Provider>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export default Layout
|
|
||||||
@ -1,193 +0,0 @@
|
|||||||
'use client'
|
|
||||||
|
|
||||||
import { ApiRoutes, GetApiRoute } from '@/ApiRoutes'
|
|
||||||
import { httpService } from '@/services/HttpService'
|
|
||||||
import { FormEvent, useEffect, useRef, useState } from 'react'
|
|
||||||
import {
|
|
||||||
CustomButton,
|
|
||||||
CustomCheckbox,
|
|
||||||
CustomEnumSelect,
|
|
||||||
CustomInput,
|
|
||||||
CustomRadioGroup
|
|
||||||
} from '@/controls'
|
|
||||||
import {
|
|
||||||
GetAccountResponse,
|
|
||||||
toCacheAccount
|
|
||||||
} from '@/models/letsEncryptServer/account/responses/GetAccountResponse'
|
|
||||||
import { deepCopy, enumToArray } from '../functions'
|
|
||||||
import { CacheAccount } from '@/entities/CacheAccount'
|
|
||||||
import { ChallengeTypes } from '@/entities/ChallengeTypes'
|
|
||||||
import { FaPlus, FaTrash } from 'react-icons/fa'
|
|
||||||
import { PageContainer } from '@/components/pageContainer'
|
|
||||||
import { OffCanvas } from '@/components/offcanvas'
|
|
||||||
import { AccountEdit } from '@/partials/accoutEdit'
|
|
||||||
import { get } from 'http'
|
|
||||||
|
|
||||||
export default function Page() {
|
|
||||||
const [accounts, setAccounts] = useState<CacheAccount[]>([])
|
|
||||||
const [editingAccount, setEditingAccount] = useState<CacheAccount | null>(
|
|
||||||
null
|
|
||||||
)
|
|
||||||
|
|
||||||
const init = useRef(false)
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (init.current) return
|
|
||||||
|
|
||||||
console.log('Fetching accounts')
|
|
||||||
|
|
||||||
const fetchAccounts = async () => {
|
|
||||||
const newAccounts: CacheAccount[] = []
|
|
||||||
const gatAccountsResult = await httpService.get<GetAccountResponse[]>(
|
|
||||||
GetApiRoute(ApiRoutes.ACCOUNTS)
|
|
||||||
)
|
|
||||||
|
|
||||||
if (!gatAccountsResult.isSuccess) return
|
|
||||||
|
|
||||||
gatAccountsResult.data?.forEach((account) => {
|
|
||||||
newAccounts.push(toCacheAccount(account))
|
|
||||||
})
|
|
||||||
|
|
||||||
setAccounts(newAccounts)
|
|
||||||
}
|
|
||||||
|
|
||||||
fetchAccounts()
|
|
||||||
init.current = true
|
|
||||||
}, [])
|
|
||||||
|
|
||||||
const handleAccountUpdate = (updatedAccount: CacheAccount) => {
|
|
||||||
setAccounts(
|
|
||||||
accounts.map((account) =>
|
|
||||||
account.accountId === updatedAccount.accountId
|
|
||||||
? updatedAccount
|
|
||||||
: account
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
const deleteAccount = (accountId: string) => {
|
|
||||||
setAccounts(accounts.filter((account) => account.accountId !== accountId))
|
|
||||||
setEditingAccount(null)
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<PageContainer title="LetsEncrypt Auto Renew">
|
|
||||||
{accounts.map((account) => (
|
|
||||||
<div
|
|
||||||
key={account.accountId}
|
|
||||||
className="bg-white shadow-lg rounded-lg p-6 mb-6"
|
|
||||||
>
|
|
||||||
<div className="flex justify-between items-center mb-4">
|
|
||||||
<h2 className="text-2xl font-semibold">
|
|
||||||
Account: {account.accountId}
|
|
||||||
</h2>
|
|
||||||
<CustomButton
|
|
||||||
onClick={() => {
|
|
||||||
setEditingAccount(account)
|
|
||||||
}}
|
|
||||||
className="bg-blue-500 text-white px-3 py-1 rounded"
|
|
||||||
>
|
|
||||||
Edit
|
|
||||||
</CustomButton>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="mb-4">
|
|
||||||
<h3 className="text-xl font-medium mb-2">
|
|
||||||
Description: {account.description}
|
|
||||||
</h3>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="mb-4">
|
|
||||||
<CustomCheckbox
|
|
||||||
checked={account.isDisabled}
|
|
||||||
label="Disabled"
|
|
||||||
disabled={true}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="mb-4">
|
|
||||||
<h3 className="text-xl font-medium mb-2">Contacts:</h3>
|
|
||||||
<ul className="list-disc list-inside pl-4 mb-2">
|
|
||||||
{account.contacts.map((contact) => (
|
|
||||||
<li key={contact} className="text-gray-700 mb-2">
|
|
||||||
{contact}
|
|
||||||
</li>
|
|
||||||
))}
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
<div className="mb-4">
|
|
||||||
<CustomEnumSelect
|
|
||||||
title="Challenge Type"
|
|
||||||
enumType={ChallengeTypes}
|
|
||||||
selectedValue={account.challengeType}
|
|
||||||
disabled={true}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div className="mb-4">
|
|
||||||
<h3 className="text-xl font-medium mb-2">Hostnames:</h3>
|
|
||||||
<ul className="list-disc list-inside pl-4 mb-2">
|
|
||||||
{account.hostnames?.map((hostname) => (
|
|
||||||
<li key={hostname.hostname} className="text-gray-700 mb-2">
|
|
||||||
<div className="inline-flex">
|
|
||||||
{hostname.hostname} - {hostname.expires.toDateString()} -
|
|
||||||
<span
|
|
||||||
className={`ml-2 px-2 py-1 rounded ${
|
|
||||||
hostname.isUpcomingExpire
|
|
||||||
? 'bg-yellow-200 text-yellow-800'
|
|
||||||
: 'bg-green-200 text-green-800'
|
|
||||||
}`}
|
|
||||||
>
|
|
||||||
{hostname.isUpcomingExpire
|
|
||||||
? 'Upcoming'
|
|
||||||
: 'Not Upcoming'}
|
|
||||||
</span>
|
|
||||||
<CustomCheckbox
|
|
||||||
checked={hostname.isDisabled}
|
|
||||||
label="Disabled"
|
|
||||||
disabled={true}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</li>
|
|
||||||
))}
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="mb-4">
|
|
||||||
<CustomRadioGroup
|
|
||||||
options={[
|
|
||||||
{ value: 'staging', label: 'Staging' },
|
|
||||||
{ value: 'production', label: 'Production' }
|
|
||||||
]}
|
|
||||||
initialValue={account.isStaging ? 'staging' : 'production'}
|
|
||||||
title="LetsEncrypt Environment"
|
|
||||||
className=""
|
|
||||||
radioClassName=""
|
|
||||||
errorClassName="text-red-500 text-sm mt-1"
|
|
||||||
disabled={true}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
))}
|
|
||||||
</PageContainer>
|
|
||||||
|
|
||||||
<OffCanvas
|
|
||||||
title="Edit Account"
|
|
||||||
isOpen={editingAccount !== null}
|
|
||||||
onClose={() => setEditingAccount(null)}
|
|
||||||
>
|
|
||||||
{editingAccount && (
|
|
||||||
<AccountEdit
|
|
||||||
account={editingAccount}
|
|
||||||
onCancel={() => setEditingAccount(null)}
|
|
||||||
onDelete={deleteAccount}
|
|
||||||
onSubmit={(account) => {
|
|
||||||
setEditingAccount(null)
|
|
||||||
handleAccountUpdate(account)
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
</OffCanvas>
|
|
||||||
</>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
@ -1,326 +0,0 @@
|
|||||||
'use client'
|
|
||||||
|
|
||||||
import { FormEvent, useCallback, useState } from 'react'
|
|
||||||
import {
|
|
||||||
useValidation,
|
|
||||||
isBypass,
|
|
||||||
isValidContact,
|
|
||||||
isValidHostname
|
|
||||||
} from '@/hooks/useValidation'
|
|
||||||
import {
|
|
||||||
CustomButton,
|
|
||||||
CustomEnumSelect,
|
|
||||||
CustomInput,
|
|
||||||
CustomRadioGroup
|
|
||||||
} from '@/controls'
|
|
||||||
import { FaTrash, FaPlus } from 'react-icons/fa'
|
|
||||||
import { deepCopy } from '../../functions'
|
|
||||||
import {
|
|
||||||
PostAccountRequest,
|
|
||||||
validatePostAccountRequest
|
|
||||||
} from '@/models/letsEncryptServer/account/requests/PostAccountRequest'
|
|
||||||
import { useAppDispatch } from '@/redux/store'
|
|
||||||
import { showToast } from '@/redux/slices/toastSlice'
|
|
||||||
import { ChallengeTypes } from '@/entities/ChallengeTypes'
|
|
||||||
import { GetAccountResponse } from '@/models/letsEncryptServer/account/responses/GetAccountResponse'
|
|
||||||
import { httpService } from '@/services/HttpService'
|
|
||||||
import { ApiRoutes, GetApiRoute } from '@/ApiRoutes'
|
|
||||||
import { PageContainer } from '@/components/pageContainer'
|
|
||||||
|
|
||||||
const RegisterPage = () => {
|
|
||||||
const [account, setAccount] = useState<PostAccountRequest>({
|
|
||||||
description: '',
|
|
||||||
contacts: [],
|
|
||||||
challengeType: ChallengeTypes.http01,
|
|
||||||
hostnames: [],
|
|
||||||
isStaging: true
|
|
||||||
})
|
|
||||||
|
|
||||||
const [newHostname, setNewHostname] = useState('')
|
|
||||||
const [newContact, setNewContact] = useState('')
|
|
||||||
|
|
||||||
const dispatch = useAppDispatch()
|
|
||||||
|
|
||||||
const {
|
|
||||||
value: description,
|
|
||||||
error: descriptionError,
|
|
||||||
handleChange: handleDescriptionChange,
|
|
||||||
reset: resetDescription
|
|
||||||
} = useValidation<string>({
|
|
||||||
defaultValue: '',
|
|
||||||
externalValue: account.description,
|
|
||||||
setExternalValue: (newDescription) => {
|
|
||||||
setAccount((prev) => {
|
|
||||||
const newAccount = deepCopy(prev)
|
|
||||||
newAccount.description = newDescription
|
|
||||||
return newAccount
|
|
||||||
})
|
|
||||||
},
|
|
||||||
validateFn: isBypass,
|
|
||||||
errorMessage: ''
|
|
||||||
})
|
|
||||||
|
|
||||||
const {
|
|
||||||
value: contact,
|
|
||||||
error: contactError,
|
|
||||||
handleChange: handleContactChange,
|
|
||||||
reset: resetContact
|
|
||||||
} = useValidation<string>({
|
|
||||||
defaultValue: '',
|
|
||||||
externalValue: newContact,
|
|
||||||
setExternalValue: setNewContact,
|
|
||||||
validateFn: isValidContact,
|
|
||||||
errorMessage: 'Invalid contact. Must be a valid email or phone number.'
|
|
||||||
})
|
|
||||||
|
|
||||||
const {
|
|
||||||
value: hostname,
|
|
||||||
error: hostnameError,
|
|
||||||
handleChange: handleHostnameChange,
|
|
||||||
reset: resetHostname
|
|
||||||
} = useValidation<string>({
|
|
||||||
defaultValue: '',
|
|
||||||
externalValue: newHostname,
|
|
||||||
setExternalValue: setNewHostname,
|
|
||||||
validateFn: isValidHostname,
|
|
||||||
errorMessage: 'Invalid hostname format.'
|
|
||||||
})
|
|
||||||
|
|
||||||
const {
|
|
||||||
value: challengeType,
|
|
||||||
error: challengeTypeError,
|
|
||||||
handleChange: handleChallengeTypeChange,
|
|
||||||
reset: resetChallengeType
|
|
||||||
} = useValidation<string>({
|
|
||||||
defaultValue: ChallengeTypes.http01,
|
|
||||||
externalValue: account.challengeType,
|
|
||||||
setExternalValue: (newChallengeType) => {
|
|
||||||
setAccount((prev) => {
|
|
||||||
const newAccount = deepCopy(prev)
|
|
||||||
newAccount.challengeType = newChallengeType
|
|
||||||
return newAccount
|
|
||||||
})
|
|
||||||
},
|
|
||||||
validateFn: isBypass,
|
|
||||||
errorMessage: ''
|
|
||||||
})
|
|
||||||
|
|
||||||
const handleAddContact = () => {
|
|
||||||
if (contactError !== '') {
|
|
||||||
resetContact()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
setAccount((prev) => {
|
|
||||||
const newAccount = deepCopy(prev)
|
|
||||||
if (!newAccount.contacts.includes(contact)) {
|
|
||||||
newAccount.contacts.push(contact)
|
|
||||||
}
|
|
||||||
return newAccount
|
|
||||||
})
|
|
||||||
|
|
||||||
resetContact()
|
|
||||||
}
|
|
||||||
|
|
||||||
const handleDeleteContact = (contact: string) => {
|
|
||||||
setAccount((prev) => {
|
|
||||||
const newAccount = deepCopy(prev)
|
|
||||||
newAccount.contacts = newAccount.contacts.filter((c) => c !== contact)
|
|
||||||
return newAccount
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
const handleAddHostname = () => {
|
|
||||||
if (hostnameError !== '') {
|
|
||||||
resetHostname()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
setAccount((prev) => {
|
|
||||||
const newAccount = deepCopy(prev)
|
|
||||||
if (!newAccount.hostnames.includes(hostname)) {
|
|
||||||
newAccount.hostnames.push(hostname)
|
|
||||||
}
|
|
||||||
return newAccount
|
|
||||||
})
|
|
||||||
|
|
||||||
resetHostname()
|
|
||||||
}
|
|
||||||
|
|
||||||
const handleDeleteHostname = (hostname: string) => {
|
|
||||||
setAccount((prev) => {
|
|
||||||
const newAccount = deepCopy(prev)
|
|
||||||
newAccount.hostnames = newAccount.hostnames.filter((h) => h !== hostname)
|
|
||||||
return newAccount
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
const handleSubmit = async (e: FormEvent<HTMLFormElement>) => {
|
|
||||||
e.preventDefault()
|
|
||||||
|
|
||||||
const errors = validatePostAccountRequest(account)
|
|
||||||
|
|
||||||
if (errors.length > 0) {
|
|
||||||
errors.forEach((error) => {
|
|
||||||
dispatch(showToast({ message: error, type: 'error' }))
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
dispatch(
|
|
||||||
showToast({ message: 'Request model is valid', type: 'success' })
|
|
||||||
)
|
|
||||||
|
|
||||||
httpService
|
|
||||||
.post<
|
|
||||||
PostAccountRequest,
|
|
||||||
GetAccountResponse
|
|
||||||
>(GetApiRoute(ApiRoutes.ACCOUNT), account)
|
|
||||||
.then((response) => {
|
|
||||||
console.log(response)
|
|
||||||
dispatch(showToast({ message: 'Account created', type: 'success' }))
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<PageContainer title="Register LetsEncrypt Account">
|
|
||||||
<form onSubmit={handleSubmit}>
|
|
||||||
<div className="mb-4">
|
|
||||||
<CustomInput
|
|
||||||
value={description}
|
|
||||||
onChange={handleDescriptionChange}
|
|
||||||
placeholder="Account Description"
|
|
||||||
type="text"
|
|
||||||
error={descriptionError}
|
|
||||||
title="Description"
|
|
||||||
inputClassName="border p-2 rounded w-full"
|
|
||||||
errorClassName="text-red-500 text-sm mt-1"
|
|
||||||
className="mr-2 flex-grow"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div className="mb-4">
|
|
||||||
<h3 className="text-xl font-medium mb-2">Contacts:</h3>
|
|
||||||
<ul className="list-disc list-inside pl-4 mb-2">
|
|
||||||
{account.contacts.map((contact) => (
|
|
||||||
<li
|
|
||||||
key={contact}
|
|
||||||
className="text-gray-700 flex justify-between items-center mb-2"
|
|
||||||
>
|
|
||||||
{contact}
|
|
||||||
<CustomButton
|
|
||||||
type="button"
|
|
||||||
onClick={() => handleDeleteContact(contact)}
|
|
||||||
className="bg-red-500 text-white p-2 rounded ml-2"
|
|
||||||
>
|
|
||||||
<FaTrash />
|
|
||||||
</CustomButton>
|
|
||||||
</li>
|
|
||||||
))}
|
|
||||||
</ul>
|
|
||||||
<div className="flex items-center mb-4">
|
|
||||||
<CustomInput
|
|
||||||
value={contact}
|
|
||||||
onChange={handleContactChange}
|
|
||||||
placeholder="Add contact"
|
|
||||||
type="text"
|
|
||||||
error={contactError}
|
|
||||||
title="New Contact"
|
|
||||||
inputClassName="border p-2 rounded w-full"
|
|
||||||
errorClassName="text-red-500 text-sm mt-1"
|
|
||||||
className="mr-2 flex-grow"
|
|
||||||
/>
|
|
||||||
<CustomButton
|
|
||||||
type="button"
|
|
||||||
onClick={handleAddContact}
|
|
||||||
className="bg-green-500 text-white p-2 rounded ml-2"
|
|
||||||
>
|
|
||||||
<FaPlus />
|
|
||||||
</CustomButton>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div className="mb-4">
|
|
||||||
<CustomEnumSelect
|
|
||||||
error={challengeTypeError}
|
|
||||||
title="Challenge Type"
|
|
||||||
enumType={ChallengeTypes}
|
|
||||||
selectedValue={challengeType}
|
|
||||||
onChange={handleChallengeTypeChange}
|
|
||||||
selectBoxClassName="border p-2 rounded w-full"
|
|
||||||
errorClassName="text-red-500 text-sm mt-1"
|
|
||||||
className="mr-2 flex-grow"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="mb-4">
|
|
||||||
<h3 className="text-xl font-medium mb-2">Hostnames:</h3>
|
|
||||||
<ul className="list-disc list-inside pl-4 mb-2">
|
|
||||||
{account.hostnames.map((hostname) => (
|
|
||||||
<li
|
|
||||||
key={hostname}
|
|
||||||
className="text-gray-700 flex justify-between items-center mb-2"
|
|
||||||
>
|
|
||||||
{hostname}
|
|
||||||
<CustomButton
|
|
||||||
type="button"
|
|
||||||
onClick={() => handleDeleteHostname(hostname)}
|
|
||||||
className="bg-red-500 text-white p-2 rounded ml-2"
|
|
||||||
>
|
|
||||||
<FaTrash />
|
|
||||||
</CustomButton>
|
|
||||||
</li>
|
|
||||||
))}
|
|
||||||
</ul>
|
|
||||||
<div className="flex items-center">
|
|
||||||
<CustomInput
|
|
||||||
value={hostname}
|
|
||||||
onChange={handleHostnameChange}
|
|
||||||
placeholder="Add hostname"
|
|
||||||
type="text"
|
|
||||||
error={hostnameError}
|
|
||||||
title="New Hostname"
|
|
||||||
inputClassName="border p-2 rounded w-full"
|
|
||||||
errorClassName="text-red-500 text-sm mt-1"
|
|
||||||
className="mr-2 flex-grow"
|
|
||||||
/>
|
|
||||||
<CustomButton
|
|
||||||
type="button"
|
|
||||||
onClick={handleAddHostname}
|
|
||||||
className="bg-green-500 text-white p-2 rounded ml-2"
|
|
||||||
>
|
|
||||||
<FaPlus />
|
|
||||||
</CustomButton>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="mb-4">
|
|
||||||
<CustomRadioGroup
|
|
||||||
options={[
|
|
||||||
{ value: 'staging', label: 'Staging' },
|
|
||||||
{ value: 'production', label: 'Production' }
|
|
||||||
]}
|
|
||||||
initialValue={account.isStaging ? 'staging' : 'production'}
|
|
||||||
onChange={(value) => {
|
|
||||||
setAccount((prev) => {
|
|
||||||
const newAccount = deepCopy(prev)
|
|
||||||
newAccount.isStaging = value === 'staging'
|
|
||||||
return newAccount
|
|
||||||
})
|
|
||||||
}}
|
|
||||||
title="LetsEncrypt Environment"
|
|
||||||
className=""
|
|
||||||
radioClassName=""
|
|
||||||
errorClassName="text-red-500 text-sm mt-1"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<CustomButton
|
|
||||||
type="submit"
|
|
||||||
className="bg-green-500 text-white px-3 py-1 rounded"
|
|
||||||
>
|
|
||||||
Create Account
|
|
||||||
</CustomButton>
|
|
||||||
</form>
|
|
||||||
</PageContainer>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export default RegisterPage
|
|
||||||
@ -1,16 +0,0 @@
|
|||||||
import React from 'react'
|
|
||||||
|
|
||||||
interface FooterProps {
|
|
||||||
className?: string
|
|
||||||
}
|
|
||||||
|
|
||||||
const Footer = (props: FooterProps) => {
|
|
||||||
const { className } = props
|
|
||||||
return (
|
|
||||||
<footer className={`bg-gray-900 text-white text-center p-4 ${className}`}>
|
|
||||||
<p>{`© ${new Date().getFullYear()} MAKS-IT`}</p>
|
|
||||||
</footer>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export { Footer }
|
|
||||||
@ -1,40 +0,0 @@
|
|||||||
// components/Loader.tsx
|
|
||||||
import React, { useEffect } from 'react'
|
|
||||||
import { useSelector, useDispatch } from 'react-redux'
|
|
||||||
import { RootState } from '@/redux/store'
|
|
||||||
import { reset } from '@/redux/slices/loaderSlice'
|
|
||||||
import './loader.css'
|
|
||||||
|
|
||||||
const Loader: React.FC = () => {
|
|
||||||
const dispatch = useDispatch()
|
|
||||||
const activeRequests = useSelector(
|
|
||||||
(state: RootState) => state.loader.activeRequests
|
|
||||||
)
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
let timeout: NodeJS.Timeout | null = null
|
|
||||||
if (activeRequests > 0) {
|
|
||||||
timeout = setTimeout(() => {
|
|
||||||
dispatch(reset())
|
|
||||||
}, 120000) // Adjust the timeout as necessary
|
|
||||||
}
|
|
||||||
|
|
||||||
return () => {
|
|
||||||
if (timeout) {
|
|
||||||
clearTimeout(timeout)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, [activeRequests, dispatch])
|
|
||||||
|
|
||||||
if (activeRequests === 0) {
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className="loader-overlay">
|
|
||||||
<span className="loader"></span>
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export { Loader }
|
|
||||||
@ -1,49 +0,0 @@
|
|||||||
.loader-overlay {
|
|
||||||
position: fixed;
|
|
||||||
top: 0;
|
|
||||||
left: 0;
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
background: rgba(0, 0, 0, 0.1); /* 10% transparent background */
|
|
||||||
display: flex;
|
|
||||||
justify-content: center;
|
|
||||||
align-items: center;
|
|
||||||
z-index: 9999;
|
|
||||||
flex-direction: column;
|
|
||||||
}
|
|
||||||
|
|
||||||
.loader {
|
|
||||||
width: 48px;
|
|
||||||
height: 48px;
|
|
||||||
display: inline-block;
|
|
||||||
position: relative;
|
|
||||||
}
|
|
||||||
.loader::after,
|
|
||||||
.loader::before {
|
|
||||||
content: '';
|
|
||||||
box-sizing: border-box;
|
|
||||||
width: 48px;
|
|
||||||
height: 48px;
|
|
||||||
border-radius: 50%;
|
|
||||||
background: #FFF;
|
|
||||||
position: absolute;
|
|
||||||
left: 0;
|
|
||||||
top: 0;
|
|
||||||
animation: animloader 2s linear infinite;
|
|
||||||
}
|
|
||||||
.loader::after {
|
|
||||||
animation-delay: 1s;
|
|
||||||
}
|
|
||||||
|
|
||||||
@keyframes animloader {
|
|
||||||
0% {
|
|
||||||
transform: scale(0);
|
|
||||||
opacity: 1;
|
|
||||||
}
|
|
||||||
100% {
|
|
||||||
transform: scale(1);
|
|
||||||
opacity: 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@ -1,40 +0,0 @@
|
|||||||
import React, { FC } from 'react'
|
|
||||||
|
|
||||||
interface OffCanvasProps {
|
|
||||||
title?: string
|
|
||||||
children: React.ReactNode
|
|
||||||
isOpen: boolean
|
|
||||||
onClose?: () => void
|
|
||||||
}
|
|
||||||
|
|
||||||
const OffCanvas: FC<OffCanvasProps> = (props) => {
|
|
||||||
const { title, children, isOpen, onClose } = props
|
|
||||||
|
|
||||||
const handleOnClose = () => {
|
|
||||||
onClose?.()
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div
|
|
||||||
className={`fixed inset-0 bg-gray-800 bg-opacity-50 z-50 transform transition-transform duration-300 ${
|
|
||||||
isOpen ? 'translate-x-0' : 'translate-x-full'
|
|
||||||
}`}
|
|
||||||
onClick={handleOnClose}
|
|
||||||
>
|
|
||||||
<div
|
|
||||||
className="absolute top-0 right-0 bg-white max-w-full md:max-w-md lg:max-w-lg xl:max-w-xl h-full shadow-lg overflow-y-auto"
|
|
||||||
onClick={(e) => e.stopPropagation()}
|
|
||||||
>
|
|
||||||
<div className="p-4">
|
|
||||||
{title && <h2 className="text-xl font-bold">{title}</h2>}
|
|
||||||
<button onClick={handleOnClose} className="mt-4 text-red-500">
|
|
||||||
Close
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
<div className="p-4">{children}</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export { OffCanvas }
|
|
||||||
@ -1,19 +0,0 @@
|
|||||||
interface PageContainerProps {
|
|
||||||
title?: string
|
|
||||||
children: React.ReactNode
|
|
||||||
}
|
|
||||||
|
|
||||||
const PageContainer: React.FC<PageContainerProps> = (props) => {
|
|
||||||
const { title, children } = props
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className="container mx-auto p-4">
|
|
||||||
{title && (
|
|
||||||
<h1 className="text-4xl font-bold text-center mb-8">{title}</h1>
|
|
||||||
)}
|
|
||||||
{children}
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export { PageContainer }
|
|
||||||
@ -1,50 +0,0 @@
|
|||||||
import React, { FC } from 'react'
|
|
||||||
import { FaHome, FaUserPlus, FaBars, FaSyncAlt } from 'react-icons/fa'
|
|
||||||
import Link from 'next/link'
|
|
||||||
|
|
||||||
interface SideMenuProps {
|
|
||||||
isCollapsed: boolean
|
|
||||||
toggleSidebar: () => void
|
|
||||||
}
|
|
||||||
|
|
||||||
const menuItems = [
|
|
||||||
{ icon: <FaSyncAlt />, label: 'Auto Renew', path: '/' },
|
|
||||||
{ icon: <FaUserPlus />, label: 'Register', path: '/register' }
|
|
||||||
]
|
|
||||||
|
|
||||||
const SideMenu: FC<SideMenuProps> = ({ isCollapsed, toggleSidebar }) => {
|
|
||||||
return (
|
|
||||||
<div
|
|
||||||
className={`flex flex-col bg-gray-800 text-white transition-all duration-300 ${isCollapsed ? 'w-16' : 'w-64'} h-full`}
|
|
||||||
>
|
|
||||||
<div className="flex items-center h-16 bg-gray-900 relative">
|
|
||||||
<button onClick={toggleSidebar} className="absolute left-4">
|
|
||||||
<FaBars />
|
|
||||||
</button>
|
|
||||||
<h1
|
|
||||||
className={`${isCollapsed ? 'hidden' : 'block'} text-2xl font-bold ml-12`}
|
|
||||||
>
|
|
||||||
Certs UI
|
|
||||||
</h1>
|
|
||||||
</div>
|
|
||||||
<nav className="flex-1">
|
|
||||||
<ul>
|
|
||||||
{menuItems.map((item, index) => (
|
|
||||||
<li key={index} className="hover:bg-gray-700">
|
|
||||||
<Link href={item.path} className="flex items-center w-full p-4">
|
|
||||||
<span className={`${isCollapsed ? 'mr-0' : 'mr-4'}`}>
|
|
||||||
{item.icon}
|
|
||||||
</span>
|
|
||||||
<span className={`${isCollapsed ? 'hidden' : 'block'}`}>
|
|
||||||
{item.label}
|
|
||||||
</span>
|
|
||||||
</Link>
|
|
||||||
</li>
|
|
||||||
))}
|
|
||||||
</ul>
|
|
||||||
</nav>
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export { SideMenu }
|
|
||||||
@ -1,53 +0,0 @@
|
|||||||
// components/Toast.tsx
|
|
||||||
import React, { useEffect } from 'react'
|
|
||||||
import { ToastContainer, toast } from 'react-toastify'
|
|
||||||
import 'react-toastify/dist/ReactToastify.css'
|
|
||||||
import { useDispatch, useSelector } from 'react-redux'
|
|
||||||
import { RootState } from '@/redux/store'
|
|
||||||
import { clearToast, removeToast } from '@/redux/slices/toastSlice'
|
|
||||||
|
|
||||||
const Toast = () => {
|
|
||||||
const dispatch = useDispatch()
|
|
||||||
const toastState = useSelector((state: RootState) => state.toast)
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
toastState.messages.forEach((toastMessage) => {
|
|
||||||
switch (toastMessage.type) {
|
|
||||||
case 'success':
|
|
||||||
toast.success(toastMessage.message)
|
|
||||||
break
|
|
||||||
case 'error':
|
|
||||||
toast.error(toastMessage.message)
|
|
||||||
break
|
|
||||||
case 'info':
|
|
||||||
toast.info(toastMessage.message)
|
|
||||||
break
|
|
||||||
case 'warning':
|
|
||||||
toast.warn(toastMessage.message)
|
|
||||||
break
|
|
||||||
default:
|
|
||||||
toast(toastMessage.message)
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
dispatch(removeToast(toastMessage.id))
|
|
||||||
})
|
|
||||||
}, [toastState, dispatch])
|
|
||||||
|
|
||||||
return (
|
|
||||||
<ToastContainer
|
|
||||||
position="bottom-right"
|
|
||||||
theme="dark"
|
|
||||||
autoClose={5000}
|
|
||||||
hideProgressBar={false}
|
|
||||||
newestOnTop={false}
|
|
||||||
closeOnClick
|
|
||||||
rtl={false}
|
|
||||||
pauseOnFocusLoss
|
|
||||||
draggable
|
|
||||||
pauseOnHover
|
|
||||||
/>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export { Toast }
|
|
||||||
@ -1,52 +0,0 @@
|
|||||||
'use client' // Add this line
|
|
||||||
|
|
||||||
import React, { FC, useState } from 'react'
|
|
||||||
import { FaCog, FaBars } from 'react-icons/fa'
|
|
||||||
import Link from 'next/link'
|
|
||||||
|
|
||||||
interface TopMenuProps {}
|
|
||||||
|
|
||||||
const TopMenu: FC<TopMenuProps> = () => {
|
|
||||||
const [isMenuOpen, setIsMenuOpen] = useState(false)
|
|
||||||
|
|
||||||
const toggleMenu = () => {
|
|
||||||
setIsMenuOpen(!isMenuOpen)
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<header className="bg-gray-900 text-white flex items-center p-4">
|
|
||||||
<nav className="flex-1 flex justify-between items-center h-8">
|
|
||||||
<ul className="hidden md:flex space-x-4">
|
|
||||||
<li className="hover:bg-gray-700 p-2 rounded">
|
|
||||||
<Link href="/">Home</Link>
|
|
||||||
</li>
|
|
||||||
<li className="hover:bg-gray-700 p-2 rounded">
|
|
||||||
<Link href="/about">About</Link>
|
|
||||||
</li>
|
|
||||||
<li className="hover:bg-gray-700 p-2 rounded">
|
|
||||||
<Link href="/contact">Contact</Link>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
{isMenuOpen && (
|
|
||||||
<ul className="absolute top-16 right-0 bg-gray-900 w-48 md:hidden">
|
|
||||||
<li className="hover:bg-gray-700 p-2">
|
|
||||||
<Link href="/">Home</Link>
|
|
||||||
</li>
|
|
||||||
<li className="hover:bg-gray-700 p-2">
|
|
||||||
<Link href="/about">About</Link>
|
|
||||||
</li>
|
|
||||||
<li className="hover:bg-gray-700 p-2">
|
|
||||||
<Link href="/contact">Contact</Link>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
)}
|
|
||||||
</nav>
|
|
||||||
<button onClick={toggleMenu} className="md:hidden">
|
|
||||||
<FaBars />
|
|
||||||
</button>
|
|
||||||
</header>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export { TopMenu }
|
|
||||||
@ -1,33 +0,0 @@
|
|||||||
'use client'
|
|
||||||
import React, { FC } from 'react'
|
|
||||||
|
|
||||||
interface CustomButtonProps {
|
|
||||||
onClick?: () => void
|
|
||||||
className?: string
|
|
||||||
children: React.ReactNode
|
|
||||||
disabled?: boolean
|
|
||||||
type?: 'button' | 'submit' | 'reset'
|
|
||||||
}
|
|
||||||
|
|
||||||
const CustomButton: FC<CustomButtonProps> = (props) => {
|
|
||||||
const {
|
|
||||||
onClick,
|
|
||||||
className = '',
|
|
||||||
children,
|
|
||||||
disabled = false,
|
|
||||||
type = 'button'
|
|
||||||
} = props
|
|
||||||
|
|
||||||
return (
|
|
||||||
<button
|
|
||||||
onClick={onClick}
|
|
||||||
className={className}
|
|
||||||
disabled={disabled}
|
|
||||||
type={type}
|
|
||||||
>
|
|
||||||
{children}
|
|
||||||
</button>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export { CustomButton }
|
|
||||||
@ -1,57 +0,0 @@
|
|||||||
// components/CustomCheckbox.tsx
|
|
||||||
import React, { FC } from 'react'
|
|
||||||
|
|
||||||
interface CustomCheckboxProps {
|
|
||||||
checked: boolean
|
|
||||||
onChange?: (checked: boolean) => void
|
|
||||||
label?: string
|
|
||||||
checkboxClassName?: string
|
|
||||||
labelClassName?: string
|
|
||||||
error?: string
|
|
||||||
errorClassName?: string
|
|
||||||
className?: string
|
|
||||||
readOnly?: boolean
|
|
||||||
disabled?: boolean
|
|
||||||
}
|
|
||||||
|
|
||||||
const CustomCheckbox: FC<CustomCheckboxProps> = (props) => {
|
|
||||||
const {
|
|
||||||
checked,
|
|
||||||
onChange,
|
|
||||||
label,
|
|
||||||
checkboxClassName = '',
|
|
||||||
labelClassName = '',
|
|
||||||
error,
|
|
||||||
errorClassName = '',
|
|
||||||
className = '',
|
|
||||||
readOnly = false,
|
|
||||||
disabled = false
|
|
||||||
} = props
|
|
||||||
|
|
||||||
const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
||||||
if (!readOnly && !disabled) {
|
|
||||||
onChange?.(e.target.checked)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className={`flex flex-col ${className}`}>
|
|
||||||
<label className={`flex items-center ${labelClassName}`}>
|
|
||||||
<input
|
|
||||||
type="checkbox"
|
|
||||||
checked={checked}
|
|
||||||
onChange={handleChange}
|
|
||||||
className={`mr-2 ${checkboxClassName}`}
|
|
||||||
readOnly={readOnly}
|
|
||||||
disabled={disabled}
|
|
||||||
/>
|
|
||||||
{label && <span>{label}</span>}
|
|
||||||
</label>
|
|
||||||
{error && (
|
|
||||||
<p className={`text-red-500 mt-1 ${errorClassName}`}>{error}</p>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export { CustomCheckbox }
|
|
||||||
@ -1,28 +0,0 @@
|
|||||||
import React from 'react'
|
|
||||||
import {
|
|
||||||
CustomSelect,
|
|
||||||
CustomSelectOption,
|
|
||||||
CustomSelectPropsBase
|
|
||||||
} from './customSelect'
|
|
||||||
import { enumToArray } from '@/functions'
|
|
||||||
|
|
||||||
interface CustomEnumSelectProps extends CustomSelectPropsBase {
|
|
||||||
enumType: any
|
|
||||||
}
|
|
||||||
|
|
||||||
const CustomEnumSelect: React.FC<CustomEnumSelectProps> = (props) => {
|
|
||||||
const { enumType, ...customSelectProps } = props
|
|
||||||
|
|
||||||
const options = enumToArray(enumType).map((item) => {
|
|
||||||
const option: CustomSelectOption = {
|
|
||||||
value: `${item.value}`,
|
|
||||||
label: item.key
|
|
||||||
}
|
|
||||||
|
|
||||||
return option
|
|
||||||
})
|
|
||||||
|
|
||||||
return <CustomSelect options={options} {...customSelectProps} />
|
|
||||||
}
|
|
||||||
|
|
||||||
export { CustomEnumSelect }
|
|
||||||
@ -1,60 +0,0 @@
|
|||||||
// components/CustomInput.tsx
|
|
||||||
'use client'
|
|
||||||
import React, { FC } from 'react'
|
|
||||||
|
|
||||||
interface CustomInputProps {
|
|
||||||
value: string
|
|
||||||
onChange?: (value: string) => void
|
|
||||||
placeholder?: string
|
|
||||||
type: 'text' | 'password' | 'email' | 'number' | 'tel' | 'url'
|
|
||||||
error?: string
|
|
||||||
title?: string
|
|
||||||
inputClassName?: string
|
|
||||||
errorClassName?: string
|
|
||||||
className?: string
|
|
||||||
readOnly?: boolean
|
|
||||||
disabled?: boolean
|
|
||||||
children?: React.ReactNode // Added for additional elements
|
|
||||||
}
|
|
||||||
|
|
||||||
const CustomInput: FC<CustomInputProps> = ({
|
|
||||||
value,
|
|
||||||
onChange,
|
|
||||||
placeholder = '',
|
|
||||||
type = 'text',
|
|
||||||
error,
|
|
||||||
title,
|
|
||||||
inputClassName = '',
|
|
||||||
errorClassName = '',
|
|
||||||
className = '',
|
|
||||||
readOnly = false,
|
|
||||||
disabled = false,
|
|
||||||
children // Added for additional elements
|
|
||||||
}) => {
|
|
||||||
const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
||||||
onChange?.(e.target.value)
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className={`flex flex-col ${className}`}>
|
|
||||||
{title && <label className="mb-1">{title}</label>}
|
|
||||||
<div className="flex items-center">
|
|
||||||
<input
|
|
||||||
type={type}
|
|
||||||
value={value}
|
|
||||||
onChange={handleChange}
|
|
||||||
placeholder={placeholder}
|
|
||||||
className={`flex-grow ${inputClassName}`}
|
|
||||||
readOnly={readOnly}
|
|
||||||
disabled={disabled}
|
|
||||||
/>
|
|
||||||
{children && <div className="ml-2">{children}</div>}
|
|
||||||
</div>
|
|
||||||
{error && (
|
|
||||||
<p className={`text-red-500 mt-1 ${errorClassName}`}>{error}</p>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export { CustomInput }
|
|
||||||
@ -1,77 +0,0 @@
|
|||||||
// components/CustomRadioGroup.tsx
|
|
||||||
import React, { useState, useEffect } from 'react'
|
|
||||||
|
|
||||||
interface CustomRadioOption {
|
|
||||||
value: string
|
|
||||||
label: string
|
|
||||||
}
|
|
||||||
|
|
||||||
interface CustomRadioGroupProps {
|
|
||||||
options: CustomRadioOption[]
|
|
||||||
initialValue?: string
|
|
||||||
onChange?: (value: string) => void
|
|
||||||
title?: string
|
|
||||||
error?: string
|
|
||||||
className?: string
|
|
||||||
radioClassName?: string
|
|
||||||
errorClassName?: string
|
|
||||||
readOnly?: boolean
|
|
||||||
disabled?: boolean
|
|
||||||
}
|
|
||||||
|
|
||||||
const CustomRadioGroup: React.FC<CustomRadioGroupProps> = ({
|
|
||||||
options,
|
|
||||||
initialValue,
|
|
||||||
onChange,
|
|
||||||
title,
|
|
||||||
error,
|
|
||||||
className = '',
|
|
||||||
radioClassName = '',
|
|
||||||
errorClassName = '',
|
|
||||||
readOnly = false,
|
|
||||||
disabled = false
|
|
||||||
}) => {
|
|
||||||
const [selectedValue, setSelectedValue] = useState(initialValue || '')
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (initialValue) {
|
|
||||||
setSelectedValue(initialValue)
|
|
||||||
}
|
|
||||||
}, [initialValue])
|
|
||||||
|
|
||||||
const handleOptionChange = (value: string) => {
|
|
||||||
if (!readOnly && !disabled) {
|
|
||||||
setSelectedValue(value)
|
|
||||||
onChange?.(value)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className={`flex flex-col ${className}`}>
|
|
||||||
{title && <label className="mb-1">{title}</label>}
|
|
||||||
<div className="flex flex-col">
|
|
||||||
{options.map((option) => (
|
|
||||||
<label
|
|
||||||
key={option.value}
|
|
||||||
className={`flex items-center mb-2 ${disabled ? 'opacity-50 cursor-not-allowed' : 'cursor-pointer'}`}
|
|
||||||
>
|
|
||||||
<input
|
|
||||||
type="radio"
|
|
||||||
value={option.value}
|
|
||||||
checked={selectedValue === option.value}
|
|
||||||
onChange={() => handleOptionChange(option.value)}
|
|
||||||
className={`mr-2 ${radioClassName}`}
|
|
||||||
disabled={disabled}
|
|
||||||
/>
|
|
||||||
{option.label}
|
|
||||||
</label>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
{error && (
|
|
||||||
<p className={`text-red-500 mt-1 ${errorClassName}`}>{error}</p>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export { CustomRadioGroup }
|
|
||||||
@ -1,125 +0,0 @@
|
|||||||
import React, { useRef, useEffect, useState } from 'react'
|
|
||||||
import { FaChevronDown, FaChevronUp } from 'react-icons/fa'
|
|
||||||
|
|
||||||
export interface CustomSelectOption {
|
|
||||||
value: string
|
|
||||||
label: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface CustomSelectPropsBase {
|
|
||||||
selectedValue: string | null | undefined
|
|
||||||
onChange?: (value: string) => void
|
|
||||||
readOnly?: boolean
|
|
||||||
disabled?: boolean
|
|
||||||
title?: string
|
|
||||||
error?: string
|
|
||||||
className?: string
|
|
||||||
selectBoxClassName?: string
|
|
||||||
errorClassName?: string
|
|
||||||
}
|
|
||||||
|
|
||||||
interface CustomSelectProps extends CustomSelectPropsBase {
|
|
||||||
options: CustomSelectOption[]
|
|
||||||
}
|
|
||||||
|
|
||||||
const CustomSelect: React.FC<CustomSelectProps> = ({
|
|
||||||
options,
|
|
||||||
selectedValue,
|
|
||||||
onChange,
|
|
||||||
readOnly = false,
|
|
||||||
disabled = false,
|
|
||||||
title,
|
|
||||||
error,
|
|
||||||
className = '',
|
|
||||||
selectBoxClassName = '',
|
|
||||||
errorClassName = ''
|
|
||||||
}) => {
|
|
||||||
const [isOpen, setIsOpen] = useState(false)
|
|
||||||
const selectBoxRef = useRef<HTMLDivElement>(null)
|
|
||||||
|
|
||||||
const handleToggle = () => {
|
|
||||||
if (!readOnly && !disabled) {
|
|
||||||
setIsOpen(!isOpen)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const handleOptionClick = (option: CustomSelectOption) => {
|
|
||||||
if (!readOnly && !disabled) {
|
|
||||||
onChange?.(option.value)
|
|
||||||
setIsOpen(false)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const handleClickOutside = (event: MouseEvent) => {
|
|
||||||
if (
|
|
||||||
selectBoxRef.current &&
|
|
||||||
!selectBoxRef.current.contains(event.target as Node)
|
|
||||||
) {
|
|
||||||
setIsOpen(false)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
document.addEventListener('mousedown', handleClickOutside)
|
|
||||||
return () => {
|
|
||||||
document.removeEventListener('mousedown', handleClickOutside)
|
|
||||||
}
|
|
||||||
}, [])
|
|
||||||
|
|
||||||
const selectedOption =
|
|
||||||
options.find((option) => option.value === selectedValue) || null
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className={`flex flex-col ${className}`} ref={selectBoxRef}>
|
|
||||||
{title && <label className="mb-1 text-gray-700">{title}</label>}
|
|
||||||
<div
|
|
||||||
className={`relative w-64 ${disabled ? 'opacity-50 cursor-not-allowed' : readOnly ? 'cursor-not-allowed' : ''}`}
|
|
||||||
>
|
|
||||||
<div
|
|
||||||
className={`p-2 border rounded flex justify-between items-center ${
|
|
||||||
disabled
|
|
||||||
? 'border-gray-200 bg-gray-100 text-gray-500'
|
|
||||||
: readOnly
|
|
||||||
? 'border-gray-300 bg-white cursor-not-allowed'
|
|
||||||
: 'border-gray-300 bg-white cursor-pointer hover:border-gray-400'
|
|
||||||
} ${selectBoxClassName}`}
|
|
||||||
onClick={handleToggle}
|
|
||||||
>
|
|
||||||
<span className={`${disabled ? 'text-gray-500' : ''}`}>
|
|
||||||
{selectedOption ? selectedOption.label : 'Select an option'}
|
|
||||||
</span>
|
|
||||||
|
|
||||||
{isOpen ? (
|
|
||||||
<FaChevronUp
|
|
||||||
className={`ml-2 ${disabled ? 'text-gray-500' : ''}`}
|
|
||||||
/>
|
|
||||||
) : (
|
|
||||||
<FaChevronDown
|
|
||||||
className={`ml-2 ${disabled ? 'text-gray-500' : ''}`}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{isOpen && (
|
|
||||||
<ul className="absolute z-10 w-full mt-1 bg-white border border-gray-300 rounded shadow-lg max-h-60 overflow-y-auto">
|
|
||||||
{options.map((option) => (
|
|
||||||
<li
|
|
||||||
key={option.value}
|
|
||||||
className={'p-2'}
|
|
||||||
onClick={() => handleOptionClick(option)}
|
|
||||||
>
|
|
||||||
{option.label}
|
|
||||||
</li>
|
|
||||||
))}
|
|
||||||
</ul>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{error && (
|
|
||||||
<p className={`text-red-500 mt-1 ${errorClassName}`}>{error}</p>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export { CustomSelect }
|
|
||||||
@ -1,15 +0,0 @@
|
|||||||
import { CustomButton } from './customButton'
|
|
||||||
import { CustomInput } from './customInput'
|
|
||||||
import { CustomCheckbox } from './customCheckbox'
|
|
||||||
import { CustomSelect } from './customSelect'
|
|
||||||
import { CustomEnumSelect } from './customEnumSelect'
|
|
||||||
import { CustomRadioGroup } from './customRadioGroup'
|
|
||||||
|
|
||||||
export {
|
|
||||||
CustomButton,
|
|
||||||
CustomInput,
|
|
||||||
CustomCheckbox,
|
|
||||||
CustomSelect,
|
|
||||||
CustomEnumSelect,
|
|
||||||
CustomRadioGroup
|
|
||||||
}
|
|
||||||
@ -1,40 +0,0 @@
|
|||||||
import { PatchOperation } from '@/models/PatchOperation'
|
|
||||||
import { CacheAccountHostname } from './CacheAccountHostname'
|
|
||||||
import { PatchAccountRequest } from '@/models/letsEncryptServer/account/requests/PatchAccountRequest'
|
|
||||||
|
|
||||||
export interface CacheAccount {
|
|
||||||
accountId: string
|
|
||||||
isDisabled: boolean
|
|
||||||
description: string
|
|
||||||
contacts: string[]
|
|
||||||
challengeType?: string
|
|
||||||
hostnames?: CacheAccountHostname[]
|
|
||||||
isEditMode: boolean
|
|
||||||
isStaging: boolean
|
|
||||||
}
|
|
||||||
|
|
||||||
const toPatchAccountRequest = (account: CacheAccount): PatchAccountRequest => {
|
|
||||||
return {
|
|
||||||
description: { op: PatchOperation.None, value: account.description },
|
|
||||||
isDisabled: { op: PatchOperation.None, value: account.isDisabled },
|
|
||||||
contacts: account.contacts.map((contact, index) => ({
|
|
||||||
index: index,
|
|
||||||
op: PatchOperation.None,
|
|
||||||
value: contact
|
|
||||||
})),
|
|
||||||
hostnames: account.hostnames?.map((hostname, index) => ({
|
|
||||||
hostname: {
|
|
||||||
index: index,
|
|
||||||
op: PatchOperation.None,
|
|
||||||
value: hostname.hostname
|
|
||||||
},
|
|
||||||
isDisabled: {
|
|
||||||
index: index,
|
|
||||||
op: PatchOperation.None,
|
|
||||||
value: hostname.isDisabled
|
|
||||||
}
|
|
||||||
}))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export { toPatchAccountRequest }
|
|
||||||
@ -1,41 +0,0 @@
|
|||||||
const deepCopy = <T>(input: T): T => {
|
|
||||||
const map = new Map()
|
|
||||||
|
|
||||||
const clone = (item: any): any => {
|
|
||||||
if (item === null || typeof item !== 'object') {
|
|
||||||
return item
|
|
||||||
}
|
|
||||||
|
|
||||||
if (map.has(item)) {
|
|
||||||
return map.get(item)
|
|
||||||
}
|
|
||||||
|
|
||||||
let result: any
|
|
||||||
|
|
||||||
if (Array.isArray(item)) {
|
|
||||||
result = []
|
|
||||||
map.set(item, result)
|
|
||||||
item.forEach((element, index) => {
|
|
||||||
result[index] = clone(element)
|
|
||||||
})
|
|
||||||
} else if (item instanceof Date) {
|
|
||||||
result = new Date(item)
|
|
||||||
map.set(item, result)
|
|
||||||
} else if (item instanceof RegExp) {
|
|
||||||
result = new RegExp(item)
|
|
||||||
map.set(item, result)
|
|
||||||
} else {
|
|
||||||
result = Object.create(Object.getPrototypeOf(item))
|
|
||||||
map.set(item, result)
|
|
||||||
Object.keys(item).forEach((key) => {
|
|
||||||
result[key] = clone(item[key])
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
|
|
||||||
return clone(input)
|
|
||||||
}
|
|
||||||
|
|
||||||
export { deepCopy }
|
|
||||||
@ -1,45 +0,0 @@
|
|||||||
interface EnumKeyValue {
|
|
||||||
key: string
|
|
||||||
value: string | number
|
|
||||||
}
|
|
||||||
|
|
||||||
const enumToArray = <T extends { [key: string]: string | number }>(
|
|
||||||
enumObj: T
|
|
||||||
): EnumKeyValue[] => {
|
|
||||||
return Object.keys(enumObj)
|
|
||||||
.filter((key) => isNaN(Number(key))) // Ensure that only string keys are considered
|
|
||||||
.map((key) => ({
|
|
||||||
key,
|
|
||||||
value: enumObj[key as keyof typeof enumObj]
|
|
||||||
}))
|
|
||||||
.map((entry) => ({
|
|
||||||
key: entry.key,
|
|
||||||
value:
|
|
||||||
typeof entry.value === 'string' && !isNaN(Number(entry.value))
|
|
||||||
? Number(entry.value)
|
|
||||||
: entry.value
|
|
||||||
}))
|
|
||||||
}
|
|
||||||
|
|
||||||
const enumToObject = <T extends { [key: string]: string | number }>(
|
|
||||||
enumObj: T
|
|
||||||
): { [key: string]: EnumKeyValue } => {
|
|
||||||
return Object.keys(enumObj)
|
|
||||||
.filter((key) => isNaN(Number(key))) // Ensure that only string keys are considered
|
|
||||||
.reduce(
|
|
||||||
(acc, key) => {
|
|
||||||
const value = enumObj[key as keyof typeof enumObj]
|
|
||||||
acc[key] = {
|
|
||||||
key,
|
|
||||||
value:
|
|
||||||
typeof value === 'string' && !isNaN(Number(value))
|
|
||||||
? Number(value)
|
|
||||||
: value
|
|
||||||
}
|
|
||||||
return acc
|
|
||||||
},
|
|
||||||
{} as { [key: string]: EnumKeyValue }
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export { enumToArray, enumToObject }
|
|
||||||
@ -1,4 +0,0 @@
|
|||||||
import { deepCopy } from './deepCopy'
|
|
||||||
import { enumToArray, enumToObject } from './enums'
|
|
||||||
|
|
||||||
export { deepCopy, enumToArray, enumToObject }
|
|
||||||
@ -1,82 +0,0 @@
|
|||||||
import { useState, useEffect, useCallback } from 'react'
|
|
||||||
|
|
||||||
// Helper functions for validation
|
|
||||||
const isBypass = (value: any) => true
|
|
||||||
const isValidEmail = (email: string) => /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email)
|
|
||||||
const isValidPhoneNumber = (phone: string) => /^\+?[1-9]\d{1,14}$/.test(phone)
|
|
||||||
const isValidContact = (contact: string) =>
|
|
||||||
isValidEmail(contact) || isValidPhoneNumber(contact)
|
|
||||||
const isValidHostname = (hostname: string) =>
|
|
||||||
/^(?!:\/\/)([a-zA-Z0-9-_]{1,63}\.?)+[a-zA-Z]{2,6}$/.test(hostname)
|
|
||||||
|
|
||||||
// Props interface for useValidation hook
|
|
||||||
interface UseValidationProps<T> {
|
|
||||||
externalValue: T
|
|
||||||
setExternalValue: (value: T) => void
|
|
||||||
validateFn: (value: T) => boolean
|
|
||||||
errorMessage: string
|
|
||||||
emptyFieldMessage?: string
|
|
||||||
defaultValue: T
|
|
||||||
}
|
|
||||||
|
|
||||||
// Custom hook for input validation
|
|
||||||
const useValidation = <T extends string | number | Date | boolean>(
|
|
||||||
props: UseValidationProps<T>
|
|
||||||
) => {
|
|
||||||
const {
|
|
||||||
externalValue,
|
|
||||||
setExternalValue,
|
|
||||||
validateFn,
|
|
||||||
errorMessage,
|
|
||||||
emptyFieldMessage = 'This field cannot be empty.',
|
|
||||||
defaultValue
|
|
||||||
} = props
|
|
||||||
|
|
||||||
const [internalValue, setInternalValue] = useState(externalValue)
|
|
||||||
const [error, setError] = useState('')
|
|
||||||
|
|
||||||
const validate = useCallback(
|
|
||||||
(value: T) => {
|
|
||||||
const stringValue =
|
|
||||||
value instanceof Date ? value.toISOString() : value.toString().trim()
|
|
||||||
if (stringValue === '') {
|
|
||||||
setError(emptyFieldMessage)
|
|
||||||
} else if (!validateFn(value)) {
|
|
||||||
setError(errorMessage)
|
|
||||||
} else {
|
|
||||||
setError('')
|
|
||||||
}
|
|
||||||
},
|
|
||||||
[emptyFieldMessage, errorMessage, validateFn]
|
|
||||||
)
|
|
||||||
|
|
||||||
const handleChange = useCallback(
|
|
||||||
(newValue: T) => {
|
|
||||||
setInternalValue(newValue)
|
|
||||||
setExternalValue(newValue)
|
|
||||||
validate(newValue)
|
|
||||||
},
|
|
||||||
[setExternalValue, validate]
|
|
||||||
)
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
setInternalValue(externalValue)
|
|
||||||
validate(externalValue)
|
|
||||||
}, [externalValue, validate])
|
|
||||||
|
|
||||||
const reset = useCallback(() => {
|
|
||||||
setInternalValue(defaultValue)
|
|
||||||
setError('')
|
|
||||||
}, [defaultValue])
|
|
||||||
|
|
||||||
return { value: internalValue, error, handleChange, reset }
|
|
||||||
}
|
|
||||||
|
|
||||||
export {
|
|
||||||
useValidation,
|
|
||||||
isBypass,
|
|
||||||
isValidEmail,
|
|
||||||
isValidPhoneNumber,
|
|
||||||
isValidContact,
|
|
||||||
isValidHostname
|
|
||||||
}
|
|
||||||
@ -1,7 +0,0 @@
|
|||||||
import { PatchOperation } from './PatchOperation'
|
|
||||||
|
|
||||||
export interface PatchAction<T> {
|
|
||||||
op: PatchOperation // Enum for operation type
|
|
||||||
index?: number // Index for the operation (for arrays/lists)
|
|
||||||
value?: T // Value for the operation
|
|
||||||
}
|
|
||||||
@ -1,6 +0,0 @@
|
|||||||
export enum PatchOperation {
|
|
||||||
Add,
|
|
||||||
Remove,
|
|
||||||
Replace,
|
|
||||||
None
|
|
||||||
}
|
|
||||||
@ -1,9 +0,0 @@
|
|||||||
import { PatchAction } from '@/models/PatchAction'
|
|
||||||
import { PatchHostnameRequest } from './PatchHostnameRequest'
|
|
||||||
|
|
||||||
export interface PatchAccountRequest {
|
|
||||||
description?: PatchAction<string>
|
|
||||||
isDisabled?: PatchAction<boolean>
|
|
||||||
contacts?: PatchAction<string>[]
|
|
||||||
hostnames?: PatchHostnameRequest[]
|
|
||||||
}
|
|
||||||
@ -1,6 +0,0 @@
|
|||||||
import { PatchAction } from '@/models/PatchAction'
|
|
||||||
|
|
||||||
export interface PatchHostnameRequest {
|
|
||||||
hostname?: PatchAction<string>
|
|
||||||
isDisabled?: PatchAction<boolean>
|
|
||||||
}
|
|
||||||
@ -1,57 +0,0 @@
|
|||||||
import { isValidContact, isValidHostname } from '@/hooks/useValidation'
|
|
||||||
|
|
||||||
export interface PostAccountRequest {
|
|
||||||
description: string
|
|
||||||
contacts: string[]
|
|
||||||
challengeType: string
|
|
||||||
hostnames: string[]
|
|
||||||
isStaging: boolean
|
|
||||||
}
|
|
||||||
|
|
||||||
const validatePostAccountRequest = (
|
|
||||||
request: PostAccountRequest | null
|
|
||||||
): string[] => {
|
|
||||||
const errors: string[] = []
|
|
||||||
|
|
||||||
if (request === null) {
|
|
||||||
errors.push('Request is null')
|
|
||||||
return errors
|
|
||||||
}
|
|
||||||
|
|
||||||
// Validate description
|
|
||||||
if (request.description === '') {
|
|
||||||
errors.push('Description cannot be empty')
|
|
||||||
}
|
|
||||||
|
|
||||||
// Validate contacts
|
|
||||||
if (request.contacts.length === 0) {
|
|
||||||
errors.push('Contacts cannot be empty')
|
|
||||||
}
|
|
||||||
|
|
||||||
request.contacts.forEach((contact) => {
|
|
||||||
if (!isValidContact(contact)) {
|
|
||||||
errors.push(`Invalid contact: ${contact}`)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
// Validate challenge type
|
|
||||||
if (request.challengeType === '') {
|
|
||||||
errors.push('Challenge type cannot be empty')
|
|
||||||
}
|
|
||||||
|
|
||||||
// Validate hostnames
|
|
||||||
if (request.hostnames.length === 0) {
|
|
||||||
errors.push('Hostnames cannot be empty')
|
|
||||||
}
|
|
||||||
|
|
||||||
request.hostnames.forEach((hostname) => {
|
|
||||||
if (!isValidHostname(hostname)) {
|
|
||||||
errors.push(`Invalid hostname: ${hostname}`)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
// Return the array of errors
|
|
||||||
return errors
|
|
||||||
}
|
|
||||||
|
|
||||||
export { validatePostAccountRequest }
|
|
||||||
@ -1,6 +0,0 @@
|
|||||||
export interface GetHostnameResponse {
|
|
||||||
hostname: string
|
|
||||||
expires: string
|
|
||||||
isUpcomingExpire: boolean
|
|
||||||
isDisabled: boolean
|
|
||||||
}
|
|
||||||
@ -1,4 +0,0 @@
|
|||||||
/** @type {import('next').NextConfig} */
|
|
||||||
const nextConfig = {};
|
|
||||||
|
|
||||||
export default nextConfig;
|
|
||||||
5065
src/ClientApp/package-lock.json
generated
@ -1,36 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "my-nextjs-app",
|
|
||||||
"version": "0.1.0",
|
|
||||||
"private": true,
|
|
||||||
"scripts": {
|
|
||||||
"dev": "next dev",
|
|
||||||
"build": "next build",
|
|
||||||
"start": "next start",
|
|
||||||
"lint": "next lint"
|
|
||||||
},
|
|
||||||
"dependencies": {
|
|
||||||
"@heroicons/react": "^2.1.3",
|
|
||||||
"@reduxjs/toolkit": "^2.2.5",
|
|
||||||
"next": "14.2.3",
|
|
||||||
"react": "^18",
|
|
||||||
"react-dom": "^18",
|
|
||||||
"react-icons": "^5.2.1",
|
|
||||||
"react-redux": "^9.1.2",
|
|
||||||
"react-toastify": "^10.0.5",
|
|
||||||
"uuid": "^10.0.0"
|
|
||||||
},
|
|
||||||
"devDependencies": {
|
|
||||||
"@types/node": "^20",
|
|
||||||
"@types/react": "^18",
|
|
||||||
"@types/react-dom": "^18",
|
|
||||||
"@types/uuid": "^10.0.0",
|
|
||||||
"eslint": "^8",
|
|
||||||
"eslint-config-next": "14.2.3",
|
|
||||||
"eslint-config-prettier": "^9.1.0",
|
|
||||||
"eslint-plugin-prettier": "^5.1.3",
|
|
||||||
"postcss": "^8",
|
|
||||||
"prettier": "^3.3.2",
|
|
||||||
"tailwindcss": "^3.4.1",
|
|
||||||
"typescript": "^5"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,446 +0,0 @@
|
|||||||
'use client'
|
|
||||||
|
|
||||||
import { Dispatch, FormEvent, SetStateAction, useEffect, useState } from 'react'
|
|
||||||
import {
|
|
||||||
useValidation,
|
|
||||||
isValidEmail,
|
|
||||||
isValidHostname,
|
|
||||||
isBypass
|
|
||||||
} from '@/hooks/useValidation'
|
|
||||||
import {
|
|
||||||
CustomButton,
|
|
||||||
CustomCheckbox,
|
|
||||||
CustomEnumSelect,
|
|
||||||
CustomInput,
|
|
||||||
CustomRadioGroup
|
|
||||||
} from '@/controls'
|
|
||||||
import { CacheAccount, toPatchAccountRequest } from '@/entities/CacheAccount'
|
|
||||||
import { FaPlus, FaTrash } from 'react-icons/fa'
|
|
||||||
import { ChallengeTypes } from '@/entities/ChallengeTypes'
|
|
||||||
import { deepCopy } from '@/functions'
|
|
||||||
import { ApiRoutes, GetApiRoute } from '@/ApiRoutes'
|
|
||||||
import { httpService } from '@/services/HttpService'
|
|
||||||
import { PatchAccountRequest } from '@/models/letsEncryptServer/account/requests/PatchAccountRequest'
|
|
||||||
import { PatchOperation } from '@/models/PatchOperation'
|
|
||||||
import { useAppDispatch } from '@/redux/store'
|
|
||||||
import { showToast } from '@/redux/slices/toastSlice'
|
|
||||||
import {
|
|
||||||
GetAccountResponse,
|
|
||||||
toCacheAccount
|
|
||||||
} from '@/models/letsEncryptServer/account/responses/GetAccountResponse'
|
|
||||||
|
|
||||||
interface AccountEditProps {
|
|
||||||
account: CacheAccount
|
|
||||||
onCancel?: () => void
|
|
||||||
onDelete: (accountId: string) => void
|
|
||||||
onSubmit: (account: CacheAccount) => void
|
|
||||||
}
|
|
||||||
|
|
||||||
const AccountEdit: React.FC<AccountEditProps> = (props) => {
|
|
||||||
const { account, onCancel, onDelete, onSubmit } = props
|
|
||||||
|
|
||||||
const dispatch = useAppDispatch()
|
|
||||||
|
|
||||||
const [newAccount, setNewAccount] = useState<PatchAccountRequest>(
|
|
||||||
toPatchAccountRequest(account)
|
|
||||||
)
|
|
||||||
|
|
||||||
const [newContact, setNewContact] = useState('')
|
|
||||||
const [newHostname, setNewHostname] = useState('')
|
|
||||||
|
|
||||||
const {
|
|
||||||
value: description,
|
|
||||||
error: descriptionError,
|
|
||||||
handleChange: handleDescriptionChange
|
|
||||||
} = useValidation<string>({
|
|
||||||
defaultValue: '',
|
|
||||||
externalValue: newAccount.description?.value ?? '',
|
|
||||||
setExternalValue: (newDescription) => {
|
|
||||||
setNewAccount((prev) => {
|
|
||||||
const newAccount = deepCopy(prev)
|
|
||||||
newAccount.description = {
|
|
||||||
op:
|
|
||||||
newDescription !== account.description
|
|
||||||
? PatchOperation.Replace
|
|
||||||
: PatchOperation.None,
|
|
||||||
value: newDescription
|
|
||||||
}
|
|
||||||
return newAccount
|
|
||||||
})
|
|
||||||
},
|
|
||||||
validateFn: isBypass,
|
|
||||||
errorMessage: ''
|
|
||||||
})
|
|
||||||
|
|
||||||
const {
|
|
||||||
value: contact,
|
|
||||||
error: contactError,
|
|
||||||
handleChange: handleContactChange,
|
|
||||||
reset: resetContact
|
|
||||||
} = useValidation<string>({
|
|
||||||
defaultValue: '',
|
|
||||||
externalValue: newContact,
|
|
||||||
setExternalValue: setNewContact,
|
|
||||||
validateFn: isValidEmail,
|
|
||||||
errorMessage: 'Invalid email format.'
|
|
||||||
})
|
|
||||||
|
|
||||||
const {
|
|
||||||
value: hostname,
|
|
||||||
error: hostnameError,
|
|
||||||
handleChange: handleHostnameChange,
|
|
||||||
reset: resetHostname
|
|
||||||
} = useValidation<string>({
|
|
||||||
defaultValue: '',
|
|
||||||
externalValue: newHostname,
|
|
||||||
setExternalValue: setNewHostname,
|
|
||||||
validateFn: isValidHostname,
|
|
||||||
errorMessage: 'Invalid hostname format.'
|
|
||||||
})
|
|
||||||
|
|
||||||
const handleIsDisabledChange = (value: boolean) => {
|
|
||||||
setNewAccount((prev) => {
|
|
||||||
const newAccount = deepCopy(prev)
|
|
||||||
newAccount.isDisabled = {
|
|
||||||
op:
|
|
||||||
value !== account.isDisabled
|
|
||||||
? PatchOperation.Replace
|
|
||||||
: PatchOperation.None,
|
|
||||||
value
|
|
||||||
}
|
|
||||||
return newAccount
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
const handleAddContact = () => {
|
|
||||||
if (newContact === '' || contactError) return
|
|
||||||
|
|
||||||
// Check if the contact already exists in the account
|
|
||||||
const contactExists = newAccount.contacts?.some(
|
|
||||||
(contact) => contact.value === newContact
|
|
||||||
)
|
|
||||||
|
|
||||||
if (contactExists) {
|
|
||||||
// Optionally, handle the duplicate contact case, e.g., show an error message
|
|
||||||
dispatch(
|
|
||||||
showToast({ message: 'Contact already exists.', type: 'warning' })
|
|
||||||
)
|
|
||||||
resetContact()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// If the contact does not exist, add it
|
|
||||||
setNewAccount((prev) => {
|
|
||||||
const newAccount = deepCopy(prev)
|
|
||||||
newAccount.contacts?.push({ op: PatchOperation.Add, value: newContact })
|
|
||||||
return newAccount
|
|
||||||
})
|
|
||||||
|
|
||||||
resetContact()
|
|
||||||
}
|
|
||||||
|
|
||||||
const handleDeleteContact = (contact: string) => {
|
|
||||||
setNewAccount((prev) => {
|
|
||||||
const newAccount = deepCopy(prev)
|
|
||||||
newAccount.contacts = newAccount.contacts
|
|
||||||
?.map((c) => {
|
|
||||||
if (c.value === contact && c.op !== PatchOperation.Add)
|
|
||||||
c.op = PatchOperation.Remove
|
|
||||||
return c
|
|
||||||
})
|
|
||||||
.filter((c) => !(c.value === contact && c.op === PatchOperation.Add))
|
|
||||||
|
|
||||||
console.log(newAccount.contacts)
|
|
||||||
|
|
||||||
return newAccount
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
const handleAddHostname = () => {
|
|
||||||
if (newHostname === '' || hostnameError) return
|
|
||||||
|
|
||||||
// Check if the hostname already exists in the account
|
|
||||||
const hostnameExists = newAccount.hostnames?.some(
|
|
||||||
(hostname) => hostname.hostname?.value === newHostname
|
|
||||||
)
|
|
||||||
|
|
||||||
if (hostnameExists) {
|
|
||||||
// Optionally, handle the duplicate hostname case, e.g., show an error message
|
|
||||||
dispatch(
|
|
||||||
showToast({ message: 'Hostname already exists.', type: 'warning' })
|
|
||||||
)
|
|
||||||
resetHostname()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// If the hostname does not exist, add it
|
|
||||||
setNewAccount((prev) => {
|
|
||||||
const newAccount = deepCopy(prev)
|
|
||||||
newAccount.hostnames?.push({
|
|
||||||
hostname: { op: PatchOperation.Add, value: newHostname },
|
|
||||||
isDisabled: { op: PatchOperation.Add, value: false }
|
|
||||||
})
|
|
||||||
return newAccount
|
|
||||||
})
|
|
||||||
|
|
||||||
resetHostname()
|
|
||||||
}
|
|
||||||
|
|
||||||
const handleHostnameDisabledChange = (hostname: string, value: boolean) => {
|
|
||||||
setNewAccount((prev) => {
|
|
||||||
const newAccount = deepCopy(prev)
|
|
||||||
const targetHostname = newAccount.hostnames?.find(
|
|
||||||
(h) => h.hostname?.value === hostname
|
|
||||||
)
|
|
||||||
if (targetHostname) {
|
|
||||||
targetHostname.isDisabled = {
|
|
||||||
op:
|
|
||||||
value !== targetHostname.isDisabled?.value
|
|
||||||
? PatchOperation.Replace
|
|
||||||
: PatchOperation.None,
|
|
||||||
value
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return newAccount
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
const handleDeleteHostname = (hostname: string) => {
|
|
||||||
setNewAccount((prev) => {
|
|
||||||
const newAccount = deepCopy(prev)
|
|
||||||
newAccount.hostnames = newAccount.hostnames
|
|
||||||
?.map((h) => {
|
|
||||||
if (
|
|
||||||
h.hostname?.value === hostname &&
|
|
||||||
h.hostname?.op !== PatchOperation.Add
|
|
||||||
)
|
|
||||||
h.hostname.op = PatchOperation.Remove
|
|
||||||
return h
|
|
||||||
})
|
|
||||||
.filter(
|
|
||||||
(h) =>
|
|
||||||
!(
|
|
||||||
h.hostname?.value === hostname &&
|
|
||||||
h.hostname?.op === PatchOperation.Add
|
|
||||||
)
|
|
||||||
)
|
|
||||||
return newAccount
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
const handleCancel = () => {
|
|
||||||
onCancel?.()
|
|
||||||
}
|
|
||||||
|
|
||||||
const handleSubmit = async (e: FormEvent<HTMLFormElement>) => {
|
|
||||||
e.preventDefault()
|
|
||||||
|
|
||||||
if (!newAccount) return
|
|
||||||
|
|
||||||
httpService
|
|
||||||
.patch<
|
|
||||||
PatchAccountRequest,
|
|
||||||
GetAccountResponse
|
|
||||||
>(GetApiRoute(ApiRoutes.ACCOUNT_ID, account.accountId), newAccount)
|
|
||||||
.then((response) => {
|
|
||||||
if (response.isSuccess && response.data) {
|
|
||||||
onSubmit?.(toCacheAccount(response.data))
|
|
||||||
} else {
|
|
||||||
// Optionally, handle the error case, e.g., show an error message
|
|
||||||
dispatch(
|
|
||||||
showToast({ message: 'Failed to update account.', type: 'error' })
|
|
||||||
)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
const handleDelete = (accountId: string) => {
|
|
||||||
httpService
|
|
||||||
.delete(GetApiRoute(ApiRoutes.ACCOUNT_ID, accountId))
|
|
||||||
.then((response) => {
|
|
||||||
if (response.isSuccess) {
|
|
||||||
onDelete?.(accountId)
|
|
||||||
} else {
|
|
||||||
// Optionally, handle the error case, e.g., show an error message
|
|
||||||
dispatch(
|
|
||||||
showToast({ message: 'Failed to detele account.', type: 'error' })
|
|
||||||
)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<form onSubmit={handleSubmit}>
|
|
||||||
<div className="mb-4">
|
|
||||||
<CustomInput
|
|
||||||
value={description}
|
|
||||||
onChange={handleDescriptionChange}
|
|
||||||
placeholder="Add new description"
|
|
||||||
type="text"
|
|
||||||
error={descriptionError}
|
|
||||||
title="Description"
|
|
||||||
inputClassName="border p-2 rounded w-full"
|
|
||||||
errorClassName="text-red-500 text-sm mt-1"
|
|
||||||
className="mr-2 w-full"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="mb-4">
|
|
||||||
<CustomCheckbox
|
|
||||||
checked={newAccount.isDisabled?.value ?? false}
|
|
||||||
label="Disabled"
|
|
||||||
onChange={handleIsDisabledChange}
|
|
||||||
className="mr-2"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="mb-4">
|
|
||||||
<h3 className="text-xl font-medium mb-2">Contacts:</h3>
|
|
||||||
<ul className="list-disc list-inside pl-4 mb-2">
|
|
||||||
{newAccount.contacts
|
|
||||||
?.filter((contact) => contact.op !== PatchOperation.Remove)
|
|
||||||
.map((contact) => (
|
|
||||||
<li key={contact.value} className="text-gray-700 mb-2">
|
|
||||||
<div className="inline-flex">
|
|
||||||
{contact.value}
|
|
||||||
<CustomButton
|
|
||||||
type="button"
|
|
||||||
onClick={() => handleDeleteContact(contact.value ?? '')}
|
|
||||||
className="bg-red-500 text-white p-2 rounded ml-2"
|
|
||||||
>
|
|
||||||
<FaTrash />
|
|
||||||
</CustomButton>
|
|
||||||
</div>
|
|
||||||
</li>
|
|
||||||
))}
|
|
||||||
</ul>
|
|
||||||
<div className="flex items-center mb-4">
|
|
||||||
<CustomInput
|
|
||||||
value={contact}
|
|
||||||
onChange={handleContactChange}
|
|
||||||
placeholder="Add new contact"
|
|
||||||
type="email"
|
|
||||||
error={contactError}
|
|
||||||
title="New Contact"
|
|
||||||
inputClassName="border p-2 rounded w-full"
|
|
||||||
errorClassName="text-red-500 text-sm mt-1"
|
|
||||||
className="mr-2 w-full"
|
|
||||||
/>
|
|
||||||
<CustomButton
|
|
||||||
type="button"
|
|
||||||
onClick={handleAddContact}
|
|
||||||
className="bg-green-500 text-white p-2 rounded ml-2"
|
|
||||||
>
|
|
||||||
<FaPlus />
|
|
||||||
</CustomButton>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="mb-4">
|
|
||||||
<CustomEnumSelect
|
|
||||||
title="Challenge Type"
|
|
||||||
enumType={ChallengeTypes}
|
|
||||||
selectedValue={account.challengeType}
|
|
||||||
className="mr-2 w-full"
|
|
||||||
disabled={true}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div>
|
|
||||||
<h3 className="text-xl font-medium mb-2">Hostnames:</h3>
|
|
||||||
<ul className="list-disc list-inside pl-4 mb-2">
|
|
||||||
{newAccount.hostnames
|
|
||||||
?.filter(
|
|
||||||
(hostname) => hostname.hostname?.op !== PatchOperation.Remove
|
|
||||||
)
|
|
||||||
.map((hostname) => (
|
|
||||||
<li key={hostname.hostname?.value} className="text-gray-700 mb-2">
|
|
||||||
<div className="inline-flex items-center">
|
|
||||||
{hostname.hostname?.value} -{' '}
|
|
||||||
<CustomCheckbox
|
|
||||||
className="ml-2"
|
|
||||||
checked={hostname.isDisabled?.value ?? false}
|
|
||||||
label="Disabled"
|
|
||||||
onChange={(value) =>
|
|
||||||
handleHostnameDisabledChange(
|
|
||||||
hostname.hostname?.value ?? '',
|
|
||||||
value
|
|
||||||
)
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<CustomButton
|
|
||||||
type="button"
|
|
||||||
onClick={() =>
|
|
||||||
handleDeleteHostname(hostname.hostname?.value ?? '')
|
|
||||||
}
|
|
||||||
className="bg-red-500 text-white p-2 rounded ml-2"
|
|
||||||
>
|
|
||||||
<FaTrash />
|
|
||||||
</CustomButton>
|
|
||||||
</li>
|
|
||||||
))}
|
|
||||||
</ul>
|
|
||||||
<div className="flex items-center">
|
|
||||||
<CustomInput
|
|
||||||
value={hostname}
|
|
||||||
onChange={handleHostnameChange}
|
|
||||||
placeholder="Add new hostname"
|
|
||||||
type="text"
|
|
||||||
error={hostnameError}
|
|
||||||
title="New Hostname"
|
|
||||||
inputClassName="border p-2 rounded w-full"
|
|
||||||
errorClassName="text-red-500 text-sm mt-1"
|
|
||||||
className="mr-2 w-full"
|
|
||||||
/>
|
|
||||||
<CustomButton
|
|
||||||
type="button"
|
|
||||||
onClick={handleAddHostname}
|
|
||||||
className="bg-green-500 text-white p-2 rounded ml-2"
|
|
||||||
>
|
|
||||||
<FaPlus />
|
|
||||||
</CustomButton>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div className="mb-4">
|
|
||||||
<CustomRadioGroup
|
|
||||||
options={[
|
|
||||||
{ value: 'staging', label: 'Staging' },
|
|
||||||
{ value: 'production', label: 'Production' }
|
|
||||||
]}
|
|
||||||
initialValue={account.isStaging ? 'staging' : 'production'}
|
|
||||||
title="LetsEncrypt Environment"
|
|
||||||
className="mr-2 w-full"
|
|
||||||
radioClassName=""
|
|
||||||
errorClassName="text-red-500 text-sm mt-1"
|
|
||||||
disabled={true}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div className="flex justify-between mt-4">
|
|
||||||
<CustomButton
|
|
||||||
type="button"
|
|
||||||
onClick={() => handleDelete(account.accountId)}
|
|
||||||
className="bg-red-500 text-white p-2 rounded"
|
|
||||||
>
|
|
||||||
<FaTrash />
|
|
||||||
</CustomButton>
|
|
||||||
<CustomButton
|
|
||||||
type="button"
|
|
||||||
onClick={handleCancel}
|
|
||||||
className="bg-yellow-500 text-white p-2 rounded"
|
|
||||||
>
|
|
||||||
Cancel
|
|
||||||
</CustomButton>
|
|
||||||
<CustomButton
|
|
||||||
type="submit"
|
|
||||||
className="bg-green-500 text-white p-2 rounded"
|
|
||||||
>
|
|
||||||
Save
|
|
||||||
</CustomButton>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export { AccountEdit }
|
|
||||||
@ -1,8 +0,0 @@
|
|||||||
/** @type {import('postcss-load-config').Config} */
|
|
||||||
const config = {
|
|
||||||
plugins: {
|
|
||||||
tailwindcss: {},
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
export default config;
|
|
||||||
@ -1 +0,0 @@
|
|||||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 394 80"><path fill="#000" d="M262 0h68.5v12.7h-27.2v66.6h-13.6V12.7H262V0ZM149 0v12.7H94v20.4h44.3v12.6H94v21h55v12.6H80.5V0h68.7zm34.3 0h-17.8l63.8 79.4h17.9l-32-39.7 32-39.6h-17.9l-23 28.6-23-28.6zm18.3 56.7-9-11-27.1 33.7h17.8l18.3-22.7z"/><path fill="#000" d="M81 79.3 17 0H0v79.3h13.6V17l50.2 62.3H81Zm252.6-.4c-1 0-1.8-.4-2.5-1s-1.1-1.6-1.1-2.6.3-1.8 1-2.5 1.6-1 2.6-1 1.8.3 2.5 1a3.4 3.4 0 0 1 .6 4.3 3.7 3.7 0 0 1-3 1.8zm23.2-33.5h6v23.3c0 2.1-.4 4-1.3 5.5a9.1 9.1 0 0 1-3.8 3.5c-1.6.8-3.5 1.3-5.7 1.3-2 0-3.7-.4-5.3-1s-2.8-1.8-3.7-3.2c-.9-1.3-1.4-3-1.4-5h6c.1.8.3 1.6.7 2.2s1 1.2 1.6 1.5c.7.4 1.5.5 2.4.5 1 0 1.8-.2 2.4-.6a4 4 0 0 0 1.6-1.8c.3-.8.5-1.8.5-3V45.5zm30.9 9.1a4.4 4.4 0 0 0-2-3.3 7.5 7.5 0 0 0-4.3-1.1c-1.3 0-2.4.2-3.3.5-.9.4-1.6 1-2 1.6a3.5 3.5 0 0 0-.3 4c.3.5.7.9 1.3 1.2l1.8 1 2 .5 3.2.8c1.3.3 2.5.7 3.7 1.2a13 13 0 0 1 3.2 1.8 8.1 8.1 0 0 1 3 6.5c0 2-.5 3.7-1.5 5.1a10 10 0 0 1-4.4 3.5c-1.8.8-4.1 1.2-6.8 1.2-2.6 0-4.9-.4-6.8-1.2-2-.8-3.4-2-4.5-3.5a10 10 0 0 1-1.7-5.6h6a5 5 0 0 0 3.5 4.6c1 .4 2.2.6 3.4.6 1.3 0 2.5-.2 3.5-.6 1-.4 1.8-1 2.4-1.7a4 4 0 0 0 .8-2.4c0-.9-.2-1.6-.7-2.2a11 11 0 0 0-2.1-1.4l-3.2-1-3.8-1c-2.8-.7-5-1.7-6.6-3.2a7.2 7.2 0 0 1-2.4-5.7 8 8 0 0 1 1.7-5 10 10 0 0 1 4.3-3.5c2-.8 4-1.2 6.4-1.2 2.3 0 4.4.4 6.2 1.2 1.8.8 3.2 2 4.3 3.4 1 1.4 1.5 3 1.5 5h-5.8z"/></svg>
|
|
||||||
|
Before Width: | Height: | Size: 1.3 KiB |
@ -1 +0,0 @@
|
|||||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 283 64"><path fill="black" d="M141 16c-11 0-19 7-19 18s9 18 20 18c7 0 13-3 16-7l-7-5c-2 3-6 4-9 4-5 0-9-3-10-7h28v-3c0-11-8-18-19-18zm-9 15c1-4 4-7 9-7s8 3 9 7h-18zm117-15c-11 0-19 7-19 18s9 18 20 18c6 0 12-3 16-7l-8-5c-2 3-5 4-8 4-5 0-9-3-11-7h28l1-3c0-11-8-18-19-18zm-10 15c2-4 5-7 10-7s8 3 9 7h-19zm-39 3c0 6 4 10 10 10 4 0 7-2 9-5l8 5c-3 5-9 8-17 8-11 0-19-7-19-18s8-18 19-18c8 0 14 3 17 8l-8 5c-2-3-5-5-9-5-6 0-10 4-10 10zm83-29v46h-9V5h9zM37 0l37 64H0L37 0zm92 5-27 48L74 5h10l18 30 17-30h10zm59 12v10l-3-1c-6 0-10 4-10 10v15h-9V17h9v9c0-5 6-9 13-9z"/></svg>
|
|
||||||
|
Before Width: | Height: | Size: 629 B |
@ -1,31 +0,0 @@
|
|||||||
// loaderSlice.ts
|
|
||||||
import { createSlice, PayloadAction } from '@reduxjs/toolkit'
|
|
||||||
|
|
||||||
interface LoaderState {
|
|
||||||
activeRequests: number
|
|
||||||
}
|
|
||||||
|
|
||||||
const initialState: LoaderState = {
|
|
||||||
activeRequests: 0
|
|
||||||
}
|
|
||||||
|
|
||||||
const loaderSlice = createSlice({
|
|
||||||
name: 'loader',
|
|
||||||
initialState,
|
|
||||||
reducers: {
|
|
||||||
increment: (state) => {
|
|
||||||
state.activeRequests += 1
|
|
||||||
},
|
|
||||||
decrement: (state) => {
|
|
||||||
if (state.activeRequests > 0) {
|
|
||||||
state.activeRequests -= 1
|
|
||||||
}
|
|
||||||
},
|
|
||||||
reset: (state) => {
|
|
||||||
state.activeRequests = 0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
export const { increment, decrement, reset } = loaderSlice.actions
|
|
||||||
export default loaderSlice.reducer
|
|
||||||
@ -1,42 +0,0 @@
|
|||||||
// store/toastSlice.ts
|
|
||||||
import { createSlice, PayloadAction } from '@reduxjs/toolkit'
|
|
||||||
import { v4 as uuidv4 } from 'uuid' // Assuming UUID is used for generating unique IDs
|
|
||||||
|
|
||||||
interface ToastMessage {
|
|
||||||
id: string // Add an id field
|
|
||||||
message: string
|
|
||||||
type: 'success' | 'error' | 'info' | 'warning'
|
|
||||||
}
|
|
||||||
|
|
||||||
interface ToastState {
|
|
||||||
messages: ToastMessage[]
|
|
||||||
}
|
|
||||||
|
|
||||||
const initialState: ToastState = {
|
|
||||||
messages: []
|
|
||||||
}
|
|
||||||
|
|
||||||
const toastSlice = createSlice({
|
|
||||||
name: 'toast',
|
|
||||||
initialState,
|
|
||||||
reducers: {
|
|
||||||
showToast: (state, action: PayloadAction<Omit<ToastMessage, 'id'>>) => {
|
|
||||||
// Generate a unique ID for each toast message
|
|
||||||
const id = uuidv4()
|
|
||||||
const newMessage = { ...action.payload, id }
|
|
||||||
state.messages.push(newMessage)
|
|
||||||
},
|
|
||||||
clearToast: (state) => {
|
|
||||||
state.messages = []
|
|
||||||
},
|
|
||||||
removeToast: (state, action: PayloadAction<string>) => {
|
|
||||||
// Remove a specific toast message by ID
|
|
||||||
state.messages = state.messages.filter(
|
|
||||||
(message) => message.id !== action.payload
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
export const { showToast, clearToast, removeToast } = toastSlice.actions
|
|
||||||
export default toastSlice.reducer
|
|
||||||
@ -1,25 +0,0 @@
|
|||||||
import { configureStore } from '@reduxjs/toolkit'
|
|
||||||
import {
|
|
||||||
TypedUseSelectorHook,
|
|
||||||
useDispatch,
|
|
||||||
useSelector,
|
|
||||||
useStore
|
|
||||||
} from 'react-redux'
|
|
||||||
import loaderReducer from '@/redux/slices/loaderSlice'
|
|
||||||
import toastReducer from '@/redux/slices/toastSlice'
|
|
||||||
|
|
||||||
export const store = configureStore({
|
|
||||||
reducer: {
|
|
||||||
loader: loaderReducer,
|
|
||||||
toast: toastReducer
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
export type RootState = ReturnType<typeof store.getState>
|
|
||||||
export type AppDispatch = typeof store.dispatch
|
|
||||||
export type AppStore = typeof store
|
|
||||||
|
|
||||||
// Use throughout your app instead of plain `useDispatch` and `useSelector`
|
|
||||||
export const useAppDispatch = () => useDispatch<AppDispatch>()
|
|
||||||
export const useAppSelector: TypedUseSelectorHook<RootState> = useSelector
|
|
||||||
export const useAppStore = () => useStore<AppStore>()
|
|
||||||
@ -1,304 +0,0 @@
|
|||||||
import { store } from '@/redux/store'
|
|
||||||
import { increment, decrement } from '@/redux/slices/loaderSlice'
|
|
||||||
import { showToast } from '@/redux/slices/toastSlice'
|
|
||||||
import { PatchOperation } from '@/models/PatchOperation'
|
|
||||||
|
|
||||||
interface HttpResponse<T> {
|
|
||||||
data: T | null
|
|
||||||
status: number
|
|
||||||
isSuccess: boolean
|
|
||||||
}
|
|
||||||
|
|
||||||
interface RequestInterceptor {
|
|
||||||
(req: XMLHttpRequest): void
|
|
||||||
}
|
|
||||||
|
|
||||||
interface ResponseInterceptor<T> {
|
|
||||||
(response: T | null, error: ProblemDetails | null): T | void
|
|
||||||
}
|
|
||||||
|
|
||||||
interface ProblemDetails {
|
|
||||||
Title: string
|
|
||||||
Detail: string | null
|
|
||||||
Status: number
|
|
||||||
}
|
|
||||||
|
|
||||||
interface HttpServiceCallbacks {
|
|
||||||
onIncrement?: () => void
|
|
||||||
onDecrement?: () => void
|
|
||||||
onShowToast?: (message: string, type: 'info' | 'error') => void
|
|
||||||
}
|
|
||||||
|
|
||||||
class HttpService {
|
|
||||||
private requestInterceptors: RequestInterceptor[] = []
|
|
||||||
private responseInterceptors: Array<ResponseInterceptor<any>> = []
|
|
||||||
private callbacks: HttpServiceCallbacks
|
|
||||||
|
|
||||||
constructor(callbacks: HttpServiceCallbacks) {
|
|
||||||
this.callbacks = callbacks
|
|
||||||
}
|
|
||||||
|
|
||||||
private invokeIncrement(): void {
|
|
||||||
this.callbacks.onIncrement?.()
|
|
||||||
}
|
|
||||||
|
|
||||||
private invokeDecrement(): void {
|
|
||||||
this.callbacks.onDecrement?.()
|
|
||||||
}
|
|
||||||
|
|
||||||
private invokeShowToast(message: string, type: 'info' | 'error'): void {
|
|
||||||
this.callbacks.onShowToast?.(message, type)
|
|
||||||
}
|
|
||||||
|
|
||||||
private async request<TResponse>(
|
|
||||||
method: string,
|
|
||||||
url: string,
|
|
||||||
data?: any
|
|
||||||
): Promise<HttpResponse<TResponse>> {
|
|
||||||
const xhr = new XMLHttpRequest()
|
|
||||||
xhr.open(method, url)
|
|
||||||
|
|
||||||
this.handleRequestInterceptors(xhr)
|
|
||||||
|
|
||||||
if (data && typeof data !== 'string') {
|
|
||||||
xhr.setRequestHeader('Content-Type', 'application/json')
|
|
||||||
}
|
|
||||||
|
|
||||||
this.invokeIncrement()
|
|
||||||
|
|
||||||
return new Promise<HttpResponse<TResponse>>((resolve) => {
|
|
||||||
xhr.onload = () => this.handleLoad<TResponse>(xhr, resolve)
|
|
||||||
xhr.onerror = () => this.handleNetworkError(resolve)
|
|
||||||
xhr.send(data ? JSON.stringify(data) : null)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
private cleanObject = (obj: any): any => {
|
|
||||||
if (Array.isArray(obj)) {
|
|
||||||
const cleanedArray = obj
|
|
||||||
.map(this.cleanObject)
|
|
||||||
.filter((item) => item !== null && item !== undefined)
|
|
||||||
return cleanedArray.length > 0 ? cleanedArray : null
|
|
||||||
} else if (typeof obj === 'object' && obj !== null) {
|
|
||||||
if (obj.op !== undefined && obj.op === PatchOperation.None) {
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
const cleanedObject: any = {}
|
|
||||||
Object.keys(obj).forEach((key) => {
|
|
||||||
const cleanedValue = this.cleanObject(obj[key])
|
|
||||||
if (cleanedValue !== null) {
|
|
||||||
cleanedObject[key] = cleanedValue
|
|
||||||
}
|
|
||||||
})
|
|
||||||
return Object.keys(cleanedObject).length > 0 ? cleanedObject : null
|
|
||||||
}
|
|
||||||
return obj
|
|
||||||
}
|
|
||||||
|
|
||||||
private handleRequestInterceptors(xhr: XMLHttpRequest): void {
|
|
||||||
this.requestInterceptors.forEach((interceptor) => {
|
|
||||||
try {
|
|
||||||
interceptor(xhr)
|
|
||||||
} catch (error) {
|
|
||||||
const problemDetails = this.createProblemDetails(
|
|
||||||
'Request Interceptor Error',
|
|
||||||
error,
|
|
||||||
0
|
|
||||||
)
|
|
||||||
this.showProblemDetails(problemDetails)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
private handleResponseInterceptors<TResponse>(
|
|
||||||
response: TResponse | null,
|
|
||||||
error: ProblemDetails | null
|
|
||||||
): TResponse | null {
|
|
||||||
this.responseInterceptors.forEach((interceptor) => {
|
|
||||||
try {
|
|
||||||
interceptor(response, error)
|
|
||||||
} catch (e) {
|
|
||||||
const problemDetails = this.createProblemDetails(
|
|
||||||
'Response Interceptor Error',
|
|
||||||
e,
|
|
||||||
0
|
|
||||||
)
|
|
||||||
this.showProblemDetails(problemDetails)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
return response
|
|
||||||
}
|
|
||||||
|
|
||||||
private handleLoad<TResponse>(
|
|
||||||
xhr: XMLHttpRequest,
|
|
||||||
resolve: (value: HttpResponse<TResponse>) => void
|
|
||||||
): void {
|
|
||||||
this.invokeDecrement()
|
|
||||||
if (xhr.status >= 200 && xhr.status < 300) {
|
|
||||||
this.handleSuccessfulResponse<TResponse>(xhr, resolve)
|
|
||||||
} else {
|
|
||||||
this.handleErrorResponse(xhr, resolve)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private handleSuccessfulResponse<TResponse>(
|
|
||||||
xhr: XMLHttpRequest,
|
|
||||||
resolve: (value: HttpResponse<TResponse>) => void
|
|
||||||
): void {
|
|
||||||
try {
|
|
||||||
if (xhr.response) {
|
|
||||||
const response = JSON.parse(xhr.response)
|
|
||||||
resolve({
|
|
||||||
data: this.handleResponseInterceptors(response, null) as TResponse,
|
|
||||||
status: xhr.status,
|
|
||||||
isSuccess: true
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
resolve({
|
|
||||||
data: null,
|
|
||||||
status: xhr.status,
|
|
||||||
isSuccess: true
|
|
||||||
})
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
const problemDetails = this.createProblemDetails(
|
|
||||||
'Response Parse Error',
|
|
||||||
error,
|
|
||||||
xhr.status
|
|
||||||
)
|
|
||||||
this.showProblemDetails(problemDetails)
|
|
||||||
resolve({
|
|
||||||
data: null,
|
|
||||||
status: xhr.status,
|
|
||||||
isSuccess: false
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private handleErrorResponse<TResponse>(
|
|
||||||
xhr: XMLHttpRequest,
|
|
||||||
resolve: (value: HttpResponse<TResponse>) => void
|
|
||||||
): void {
|
|
||||||
const problemDetails = this.createProblemDetails(
|
|
||||||
xhr.statusText,
|
|
||||||
xhr.responseText,
|
|
||||||
xhr.status
|
|
||||||
)
|
|
||||||
this.showProblemDetails(problemDetails)
|
|
||||||
resolve({
|
|
||||||
data: this.handleResponseInterceptors(null, problemDetails),
|
|
||||||
status: xhr.status,
|
|
||||||
isSuccess: false
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
private handleNetworkError<TResponse>(
|
|
||||||
resolve: (value: HttpResponse<TResponse>) => void
|
|
||||||
): void {
|
|
||||||
const problemDetails = this.createProblemDetails('Network Error', null, 0)
|
|
||||||
this.showProblemDetails(problemDetails)
|
|
||||||
resolve({
|
|
||||||
data: this.handleResponseInterceptors(null, problemDetails),
|
|
||||||
status: 0,
|
|
||||||
isSuccess: false
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
private createProblemDetails(
|
|
||||||
title: string,
|
|
||||||
detail: any,
|
|
||||||
status: number
|
|
||||||
): ProblemDetails {
|
|
||||||
return {
|
|
||||||
Title: title,
|
|
||||||
Detail:
|
|
||||||
detail instanceof Error ? detail.message : JSON.parse(detail)?.detail,
|
|
||||||
Status: status
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private showProblemDetails(problemDetails: ProblemDetails): void {
|
|
||||||
if (problemDetails.Detail) {
|
|
||||||
const errorMessages = problemDetails.Detail.split(',')
|
|
||||||
errorMessages.forEach((message) => {
|
|
||||||
this.invokeShowToast(message.trim(), 'error')
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
this.invokeShowToast('Unknown error', 'error')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public async get<TResponse>(url: string): Promise<HttpResponse<TResponse>> {
|
|
||||||
return await this.request<TResponse>('GET', url)
|
|
||||||
}
|
|
||||||
|
|
||||||
public async post<TRequest, TResponse>(
|
|
||||||
url: string,
|
|
||||||
data: TRequest
|
|
||||||
): Promise<HttpResponse<TResponse>> {
|
|
||||||
return await this.request<TResponse>('POST', url, data)
|
|
||||||
}
|
|
||||||
|
|
||||||
public async put<TRequest, TResponse>(
|
|
||||||
url: string,
|
|
||||||
data: TRequest
|
|
||||||
): Promise<HttpResponse<TResponse>> {
|
|
||||||
return await this.request<TResponse>('PUT', url, data)
|
|
||||||
}
|
|
||||||
|
|
||||||
public async patch<TRequest, TResponse>(
|
|
||||||
url: string,
|
|
||||||
data: TRequest
|
|
||||||
): Promise<HttpResponse<TResponse>> {
|
|
||||||
// Clean the data before sending the patch request
|
|
||||||
const cleanedData = this.cleanObject(data)
|
|
||||||
|
|
||||||
console.log('Cleaned patch data:', cleanedData)
|
|
||||||
return await this.request<TResponse>('PATCH', url, cleanedData)
|
|
||||||
}
|
|
||||||
|
|
||||||
public async delete(url: string): Promise<HttpResponse<null>> {
|
|
||||||
return await this.request<null>('DELETE', url)
|
|
||||||
}
|
|
||||||
|
|
||||||
public addRequestInterceptor(interceptor: RequestInterceptor): void {
|
|
||||||
this.requestInterceptors.push(interceptor)
|
|
||||||
}
|
|
||||||
|
|
||||||
public addResponseInterceptor<TResponse>(
|
|
||||||
interceptor: ResponseInterceptor<TResponse>
|
|
||||||
): void {
|
|
||||||
this.responseInterceptors.push(interceptor)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Instance of HttpService
|
|
||||||
const httpService = new HttpService({
|
|
||||||
onIncrement: () => store.dispatch(increment()),
|
|
||||||
onDecrement: () => store.dispatch(decrement()),
|
|
||||||
onShowToast: (message: string, type: 'info' | 'error') =>
|
|
||||||
store.dispatch(showToast({ message, type }))
|
|
||||||
})
|
|
||||||
|
|
||||||
// Add loader state handling via interceptors
|
|
||||||
httpService.addRequestInterceptor((xhr) => {
|
|
||||||
// Additional request logic can be added here
|
|
||||||
})
|
|
||||||
|
|
||||||
httpService.addResponseInterceptor((response, error) => {
|
|
||||||
// Additional response logic can be added here
|
|
||||||
return response
|
|
||||||
})
|
|
||||||
|
|
||||||
export { httpService }
|
|
||||||
|
|
||||||
// Example usage of the httpService
|
|
||||||
// async function fetchData() {
|
|
||||||
// const response = await httpService.get<any>('/api/data');
|
|
||||||
// if (response.isSuccess) {
|
|
||||||
// console.log('Data received:', response.data);
|
|
||||||
// } else {
|
|
||||||
// console.error('Failed to fetch data, status code:', response.status);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
@ -1,20 +0,0 @@
|
|||||||
import type { Config } from "tailwindcss";
|
|
||||||
|
|
||||||
const config: Config = {
|
|
||||||
content: [
|
|
||||||
"./pages/**/*.{js,ts,jsx,tsx,mdx}",
|
|
||||||
"./components/**/*.{js,ts,jsx,tsx,mdx}",
|
|
||||||
"./app/**/*.{js,ts,jsx,tsx,mdx}",
|
|
||||||
],
|
|
||||||
theme: {
|
|
||||||
extend: {
|
|
||||||
backgroundImage: {
|
|
||||||
"gradient-radial": "radial-gradient(var(--tw-gradient-stops))",
|
|
||||||
"gradient-conic":
|
|
||||||
"conic-gradient(from 180deg at 50% 50%, var(--tw-gradient-stops))",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
plugins: [],
|
|
||||||
};
|
|
||||||
export default config;
|
|
||||||
@ -1,26 +0,0 @@
|
|||||||
{
|
|
||||||
"compilerOptions": {
|
|
||||||
"lib": ["dom", "dom.iterable", "esnext"],
|
|
||||||
"allowJs": true,
|
|
||||||
"skipLibCheck": true,
|
|
||||||
"strict": true,
|
|
||||||
"noEmit": true,
|
|
||||||
"esModuleInterop": true,
|
|
||||||
"module": "esnext",
|
|
||||||
"moduleResolution": "bundler",
|
|
||||||
"resolveJsonModule": true,
|
|
||||||
"isolatedModules": true,
|
|
||||||
"jsx": "preserve",
|
|
||||||
"incremental": true,
|
|
||||||
"plugins": [
|
|
||||||
{
|
|
||||||
"name": "next"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"paths": {
|
|
||||||
"@/*": ["./*"]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
|
|
||||||
"exclude": ["node_modules"]
|
|
||||||
}
|
|
||||||
@ -1,20 +0,0 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<TargetFramework>net8.0</TargetFramework>
|
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
|
||||||
<Nullable>enable</Nullable>
|
|
||||||
<RootNamespace>MaksIT.$(MSBuildProjectName.Replace(" ", "_"))</RootNamespace>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<Compile Remove="Abstractions\**" />
|
|
||||||
<EmbeddedResource Remove="Abstractions\**" />
|
|
||||||
<None Remove="Abstractions\**" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.1" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
|
||||||
@ -1,36 +0,0 @@
|
|||||||
using System.Text.Json.Serialization;
|
|
||||||
using System.Text.Json;
|
|
||||||
|
|
||||||
namespace MaksIT.Core.Extensions;
|
|
||||||
public static class ObjectExtensions {
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
///
|
|
||||||
/// </summary>
|
|
||||||
/// <typeparam name="T"></typeparam>
|
|
||||||
/// <param name="obj"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public static string ToJson<T>(this T? obj) => obj.ToJson(null);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
///
|
|
||||||
/// </summary>
|
|
||||||
/// <typeparam name="T"></typeparam>
|
|
||||||
/// <param name="obj"></param>
|
|
||||||
/// <param name="converters"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public static string ToJson<T>(this T? obj, List<JsonConverter>? converters) {
|
|
||||||
if (obj == null)
|
|
||||||
return "{}";
|
|
||||||
|
|
||||||
var options = new JsonSerializerOptions {
|
|
||||||
PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
|
|
||||||
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull,
|
|
||||||
WriteIndented = true
|
|
||||||
};
|
|
||||||
|
|
||||||
converters?.ForEach(x => options.Converters.Add(x));
|
|
||||||
|
|
||||||
return JsonSerializer.Serialize(obj, options);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,55 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Text.Json.Serialization;
|
|
||||||
using System.Text.Json;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace MaksIT.Core.Extensions;
|
|
||||||
public static class StringExtensions {
|
|
||||||
/// <summary>
|
|
||||||
/// Converts JSON string to object
|
|
||||||
/// </summary>
|
|
||||||
/// <typeparam name="T"></typeparam>
|
|
||||||
/// <param name="s"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public static T? ToObject<T>(this string? s) => ToObjectCore<T>(s, null);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
///
|
|
||||||
/// </summary>
|
|
||||||
/// <typeparam name="T"></typeparam>
|
|
||||||
/// <param name="s"></param>
|
|
||||||
/// <param name="converters"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public static T? ToObject<T>(this string? s, List<JsonConverter> converters) => ToObjectCore<T>(s, converters);
|
|
||||||
|
|
||||||
private static T? ToObjectCore<T>(string? s, List<JsonConverter>? converters) {
|
|
||||||
var options = new JsonSerializerOptions {
|
|
||||||
PropertyNameCaseInsensitive = true
|
|
||||||
};
|
|
||||||
|
|
||||||
converters?.ForEach(x => options.Converters.Add(x));
|
|
||||||
|
|
||||||
return s != null
|
|
||||||
? JsonSerializer.Deserialize<T>(s, options)
|
|
||||||
: default;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Guid? ToNullabeGuid(this string? s) {
|
|
||||||
if (Guid.TryParse(s, out var result)) {
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Guid ToGuid(this string s) {
|
|
||||||
if (Guid.TryParse(s, out var result)) {
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Guid.Empty;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,105 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Concurrent;
|
|
||||||
using System.Threading;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
public class LockManager : IDisposable {
|
|
||||||
private readonly SemaphoreSlim _semaphore = new SemaphoreSlim(1, 1);
|
|
||||||
private readonly ConcurrentDictionary<int, int> _reentrantCounts = new ConcurrentDictionary<int, int>();
|
|
||||||
|
|
||||||
public async Task<T> ExecuteWithLockAsync<T>(Func<Task<T>> action) {
|
|
||||||
var threadId = Thread.CurrentThread.ManagedThreadId;
|
|
||||||
|
|
||||||
if (!_reentrantCounts.ContainsKey(threadId)) {
|
|
||||||
_reentrantCounts[threadId] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_reentrantCounts[threadId] == 0) {
|
|
||||||
await _semaphore.WaitAsync();
|
|
||||||
}
|
|
||||||
|
|
||||||
_reentrantCounts[threadId]++;
|
|
||||||
try {
|
|
||||||
return await action();
|
|
||||||
}
|
|
||||||
finally {
|
|
||||||
_reentrantCounts[threadId]--;
|
|
||||||
if (_reentrantCounts[threadId] == 0) {
|
|
||||||
_semaphore.Release();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task ExecuteWithLockAsync(Func<Task> action) {
|
|
||||||
var threadId = Thread.CurrentThread.ManagedThreadId;
|
|
||||||
|
|
||||||
if (!_reentrantCounts.ContainsKey(threadId)) {
|
|
||||||
_reentrantCounts[threadId] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_reentrantCounts[threadId] == 0) {
|
|
||||||
await _semaphore.WaitAsync();
|
|
||||||
}
|
|
||||||
|
|
||||||
_reentrantCounts[threadId]++;
|
|
||||||
try {
|
|
||||||
await action();
|
|
||||||
}
|
|
||||||
finally {
|
|
||||||
_reentrantCounts[threadId]--;
|
|
||||||
if (_reentrantCounts[threadId] == 0) {
|
|
||||||
_semaphore.Release();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<T> ExecuteWithLockAsync<T>(Func<T> action) {
|
|
||||||
var threadId = Thread.CurrentThread.ManagedThreadId;
|
|
||||||
|
|
||||||
if (!_reentrantCounts.ContainsKey(threadId)) {
|
|
||||||
_reentrantCounts[threadId] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_reentrantCounts[threadId] == 0) {
|
|
||||||
await _semaphore.WaitAsync();
|
|
||||||
}
|
|
||||||
|
|
||||||
_reentrantCounts[threadId]++;
|
|
||||||
try {
|
|
||||||
return await Task.Run(action);
|
|
||||||
}
|
|
||||||
finally {
|
|
||||||
_reentrantCounts[threadId]--;
|
|
||||||
if (_reentrantCounts[threadId] == 0) {
|
|
||||||
_semaphore.Release();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task ExecuteWithLockAsync(Action action) {
|
|
||||||
var threadId = Thread.CurrentThread.ManagedThreadId;
|
|
||||||
|
|
||||||
if (!_reentrantCounts.ContainsKey(threadId)) {
|
|
||||||
_reentrantCounts[threadId] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_reentrantCounts[threadId] == 0) {
|
|
||||||
await _semaphore.WaitAsync();
|
|
||||||
}
|
|
||||||
|
|
||||||
_reentrantCounts[threadId]++;
|
|
||||||
try {
|
|
||||||
await Task.Run(action);
|
|
||||||
}
|
|
||||||
finally {
|
|
||||||
_reentrantCounts[threadId]--;
|
|
||||||
if (_reentrantCounts[threadId] == 0) {
|
|
||||||
_semaphore.Release();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Dispose() {
|
|
||||||
_semaphore.Dispose();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,24 +0,0 @@
|
|||||||
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace MaksIT.Core.Logger;
|
|
||||||
|
|
||||||
public class MyCustomLogger : ILogger {
|
|
||||||
public IDisposable? BeginScope<TState>(TState state) where TState : notnull {
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool IsEnabled(LogLevel logLevel) {
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Exception? exception, Func<TState, Exception?, string> formatter) {
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@ -1,19 +0,0 @@
|
|||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Concurrent;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace MaksIT.Core.Logger;
|
|
||||||
|
|
||||||
public class MyCustomLoggerProvider : ILoggerProvider {
|
|
||||||
public ILogger CreateLogger(string categoryName) {
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Dispose() {
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,8 +0,0 @@
|
|||||||
using Microsoft.Extensions.Logging;
|
|
||||||
|
|
||||||
|
|
||||||
namespace MaksIT.Core.Logger;
|
|
||||||
|
|
||||||
public static class MyCustomLoggerExtensions {
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,13 +0,0 @@
|
|||||||
using System.Runtime.InteropServices;
|
|
||||||
|
|
||||||
namespace MaksIT.Core;
|
|
||||||
public static class OperatingSystem {
|
|
||||||
public static bool IsWindows() =>
|
|
||||||
RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
|
|
||||||
|
|
||||||
public static bool IsMacOS() =>
|
|
||||||
RuntimeInformation.IsOSPlatform(OSPlatform.OSX);
|
|
||||||
|
|
||||||
public static bool IsLinux() =>
|
|
||||||
RuntimeInformation.IsOSPlatform(OSPlatform.Linux);
|
|
||||||
}
|
|
||||||
9
src/Deploy-Helm.bat
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
@echo off
|
||||||
|
|
||||||
|
REM Change directory to the location of the script
|
||||||
|
cd /d %~dp0
|
||||||
|
|
||||||
|
REM Invoke the PowerShell script (Release-NuGetPackage.ps1) in the same directory
|
||||||
|
powershell -ExecutionPolicy Bypass -File "%~dp0Deploy-Helm.ps1"
|
||||||
|
|
||||||
|
pause
|
||||||
68
src/Deploy-Helm.ps1
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
# Set variables
|
||||||
|
$projectName = "certs-ui"
|
||||||
|
$namespace = "certs-ui"
|
||||||
|
$chartPath = "./helm"
|
||||||
|
$harborUrl = "cr.maks-it.com"
|
||||||
|
|
||||||
|
# Retrieve and decode username:password from environment variable (Base64)
|
||||||
|
try {
|
||||||
|
$decoded = [Text.Encoding]::UTF8.GetString([Convert]::FromBase64String($Env:CR_MAKS_IT))
|
||||||
|
} catch {
|
||||||
|
Write-Error "Failed to decode CR_MAKS_IT as Base64. Expected base64('username:password')."
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
# Split decoded credentials
|
||||||
|
$creds = $decoded -split ':', 2
|
||||||
|
$harborUsername = $creds[0]
|
||||||
|
$harborPassword = $creds[1]
|
||||||
|
|
||||||
|
# Verify environment variable
|
||||||
|
if (-not $harborUsername -or -not $harborPassword) {
|
||||||
|
Write-Error "Decoded CR_MAKS_IT must be in the format 'username:password'."
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
# Ensure namespace exists
|
||||||
|
if (-not (kubectl get ns $namespace -o name 2>$null)) {
|
||||||
|
Write-Output "Creating namespace '$namespace'..."
|
||||||
|
kubectl create namespace $namespace | Out-Null
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Write-Output "Namespace '$namespace' already exists."
|
||||||
|
}
|
||||||
|
|
||||||
|
# Create or update Docker registry pull secret
|
||||||
|
Write-Output "Creating or updating image pull secret..."
|
||||||
|
kubectl -n $namespace create secret docker-registry cr-maksit-pull `
|
||||||
|
--docker-server=$harborUrl `
|
||||||
|
--docker-username=$harborUsername `
|
||||||
|
--docker-password=$harborPassword `
|
||||||
|
--docker-email="devnull@maks-it.com" `
|
||||||
|
--dry-run=client -o yaml | kubectl apply -f - | Out-Null
|
||||||
|
|
||||||
|
# Lint Helm chart
|
||||||
|
Write-Output "Linting Helm chart..."
|
||||||
|
helm lint $chartPath
|
||||||
|
|
||||||
|
# Render Helm chart to verify output (optional)
|
||||||
|
Write-Output "Rendering Helm chart for validation..."
|
||||||
|
helm template $projectName $chartPath -n $namespace | Out-Null
|
||||||
|
|
||||||
|
# Generate a unique rollout value (current Unix timestamp)
|
||||||
|
$rollme = [int][double]::Parse((Get-Date -UFormat %s))
|
||||||
|
|
||||||
|
# Deploy Helm release
|
||||||
|
Write-Output "Deploying Helm release '$projectName'..."
|
||||||
|
helm upgrade --install $projectName $chartPath -n $namespace `
|
||||||
|
--set imagePullSecret.create=false `
|
||||||
|
--set imagePullSecrets[0].name=cr-maksit-pull `
|
||||||
|
--set-string "rollme=$rollme"
|
||||||
|
|
||||||
|
# Check deployment status
|
||||||
|
Write-Output "Waiting for deployment rollout..."
|
||||||
|
kubectl -n $namespace rollout status deployment/$projectName-reverseproxy
|
||||||
|
|
||||||
|
# Display service details
|
||||||
|
Write-Output "Service information:"
|
||||||
|
kubectl -n $namespace get svc $projectName-reverseproxy
|
||||||
@ -1,84 +0,0 @@
|
|||||||
|
|
||||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
|
||||||
# Visual Studio Version 17
|
|
||||||
VisualStudioVersion = 17.6.33815.320
|
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LetsEncrypt", "LetsEncrypt\LetsEncrypt.csproj", "{7DE431E5-889C-434E-AD02-9F89D7A0ED27}"
|
|
||||||
EndProject
|
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LetsEncryptConsole", "LetsEncryptConsole\LetsEncryptConsole.csproj", "{2E4BE41E-E442-4CB8-824E-9888FFAA1BEF}"
|
|
||||||
EndProject
|
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Core", "Core\Core.csproj", "{27A58A5F-B52A-44F2-9639-84C6F02EA75D}"
|
|
||||||
EndProject
|
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SSHProvider", "SSHProvider\SSHProvider.csproj", "{B6556305-D728-4368-A22C-93079C236808}"
|
|
||||||
EndProject
|
|
||||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{3374FDB1-C95E-4103-8E14-5BBF0BDC4E9D}"
|
|
||||||
EndProject
|
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SSHProviderTests", "Tests\SSHSerivceTests\SSHProviderTests.csproj", "{3937760A-FFB3-4A8C-ABD1-CDDCE1D977C4}"
|
|
||||||
EndProject
|
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LetsEncryptServer", "LetsEncryptServer\LetsEncryptServer.csproj", "{B5F39E04-C2E3-49BF-82C2-9DEBAA949E3D}"
|
|
||||||
EndProject
|
|
||||||
Project("{E53339B2-1760-4266-BCC7-CA923CBCF16C}") = "docker-compose", "docker-compose.dcproj", "{0233E43F-435D-4309-B20C-ECD4BFBD2E63}"
|
|
||||||
EndProject
|
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Agent", "Agent\Agent.csproj", "{871BDED3-C6AE-437D-9B45-3AA3F184D002}"
|
|
||||||
EndProject
|
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Models", "Models\Models.csproj", "{6814169B-D4D0-40B2-9FA9-89997DD44C30}"
|
|
||||||
EndProject
|
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ReverseProxy", "ReverseProxy\ReverseProxy.csproj", "{BE051147-7AB7-4358-9C24-5CB40FAFF4FC}"
|
|
||||||
EndProject
|
|
||||||
Global
|
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
|
||||||
Debug|Any CPU = Debug|Any CPU
|
|
||||||
Release|Any CPU = Release|Any CPU
|
|
||||||
EndGlobalSection
|
|
||||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
|
||||||
{7DE431E5-889C-434E-AD02-9F89D7A0ED27}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{7DE431E5-889C-434E-AD02-9F89D7A0ED27}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{7DE431E5-889C-434E-AD02-9F89D7A0ED27}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{7DE431E5-889C-434E-AD02-9F89D7A0ED27}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{2E4BE41E-E442-4CB8-824E-9888FFAA1BEF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{2E4BE41E-E442-4CB8-824E-9888FFAA1BEF}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{2E4BE41E-E442-4CB8-824E-9888FFAA1BEF}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{2E4BE41E-E442-4CB8-824E-9888FFAA1BEF}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{27A58A5F-B52A-44F2-9639-84C6F02EA75D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{27A58A5F-B52A-44F2-9639-84C6F02EA75D}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{27A58A5F-B52A-44F2-9639-84C6F02EA75D}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{27A58A5F-B52A-44F2-9639-84C6F02EA75D}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{B6556305-D728-4368-A22C-93079C236808}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{B6556305-D728-4368-A22C-93079C236808}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{B6556305-D728-4368-A22C-93079C236808}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{B6556305-D728-4368-A22C-93079C236808}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{3937760A-FFB3-4A8C-ABD1-CDDCE1D977C4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{3937760A-FFB3-4A8C-ABD1-CDDCE1D977C4}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{3937760A-FFB3-4A8C-ABD1-CDDCE1D977C4}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{3937760A-FFB3-4A8C-ABD1-CDDCE1D977C4}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{B5F39E04-C2E3-49BF-82C2-9DEBAA949E3D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{B5F39E04-C2E3-49BF-82C2-9DEBAA949E3D}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{B5F39E04-C2E3-49BF-82C2-9DEBAA949E3D}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{B5F39E04-C2E3-49BF-82C2-9DEBAA949E3D}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{0233E43F-435D-4309-B20C-ECD4BFBD2E63}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{0233E43F-435D-4309-B20C-ECD4BFBD2E63}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{0233E43F-435D-4309-B20C-ECD4BFBD2E63}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{0233E43F-435D-4309-B20C-ECD4BFBD2E63}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{871BDED3-C6AE-437D-9B45-3AA3F184D002}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{871BDED3-C6AE-437D-9B45-3AA3F184D002}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{871BDED3-C6AE-437D-9B45-3AA3F184D002}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{871BDED3-C6AE-437D-9B45-3AA3F184D002}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{6814169B-D4D0-40B2-9FA9-89997DD44C30}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{6814169B-D4D0-40B2-9FA9-89997DD44C30}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{6814169B-D4D0-40B2-9FA9-89997DD44C30}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{6814169B-D4D0-40B2-9FA9-89997DD44C30}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{BE051147-7AB7-4358-9C24-5CB40FAFF4FC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{BE051147-7AB7-4358-9C24-5CB40FAFF4FC}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{BE051147-7AB7-4358-9C24-5CB40FAFF4FC}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{BE051147-7AB7-4358-9C24-5CB40FAFF4FC}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
EndGlobalSection
|
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
|
||||||
HideSolutionNode = FALSE
|
|
||||||
EndGlobalSection
|
|
||||||
GlobalSection(NestedProjects) = preSolution
|
|
||||||
{3937760A-FFB3-4A8C-ABD1-CDDCE1D977C4} = {3374FDB1-C95E-4103-8E14-5BBF0BDC4E9D}
|
|
||||||
EndGlobalSection
|
|
||||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
|
||||||
SolutionGuid = {B78BD325-B2C1-456C-8EA8-42F9B89E0351}
|
|
||||||
EndGlobalSection
|
|
||||||
EndGlobal
|
|
||||||
11
src/LetsEncrypt/Entities/ChalengeType.cs
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
|
|
||||||
|
namespace MaksIT.LetsEncrypt.Entities;
|
||||||
|
|
||||||
|
public enum ChalengeType {
|
||||||
|
[Display(Name = "http-01")]
|
||||||
|
http,
|
||||||
|
[Display(Name = "dns-01")]
|
||||||
|
dns,
|
||||||
|
}
|
||||||
16
src/LetsEncrypt/Entities/ContentType.cs
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
|
|
||||||
|
namespace MaksIT.LetsEncrypt.Entities;
|
||||||
|
|
||||||
|
public enum ContentType
|
||||||
|
{
|
||||||
|
[Display(Name = "application/jose+json")]
|
||||||
|
JoseJson,
|
||||||
|
[Display(Name = "application/problem+json")]
|
||||||
|
ProblemJson,
|
||||||
|
[Display(Name = "application/pem-certificate-chain")]
|
||||||
|
PemCertificateChain,
|
||||||
|
[Display(Name = "application/json")]
|
||||||
|
Json
|
||||||
|
}
|
||||||
11
src/LetsEncrypt/Entities/Jws/ACMEJwsHeader.cs
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
using MaksIT.Core.Security.JWS;
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
|
namespace MaksIT.LetsEncrypt.Entities.Jws;
|
||||||
|
public class ACMEJwsHeader : JwsHeader {
|
||||||
|
[JsonPropertyName("url")]
|
||||||
|
public string? Url { get; set; }
|
||||||
|
|
||||||
|
[JsonPropertyName("nonce")]
|
||||||
|
public string? Nonce { get; set; }
|
||||||
|
}
|
||||||
@ -1,104 +0,0 @@
|
|||||||
// https://tools.ietf.org/html/rfc7517
|
|
||||||
|
|
||||||
using System.Text.Json.Serialization;
|
|
||||||
|
|
||||||
namespace MaksIT.LetsEncrypt.Entities.Jws;
|
|
||||||
public class Jwk {
|
|
||||||
/// <summary>
|
|
||||||
/// "kty" (Key Type) Parameter
|
|
||||||
/// <para>
|
|
||||||
/// The "kty" (key type) parameter identifies the cryptographic algorithm
|
|
||||||
/// family used with the key, such as "RSA" or "EC".
|
|
||||||
/// </para>
|
|
||||||
/// </summary>
|
|
||||||
[JsonPropertyName("kty")]
|
|
||||||
public string? KeyType { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// "kid" (Key ID) Parameter
|
|
||||||
/// <para>
|
|
||||||
/// The "kid" (key ID) parameter is used to match a specific key. This
|
|
||||||
/// is used, for instance, to choose among a set of keys within a JWK Set
|
|
||||||
/// during key rollover. The structure of the "kid" value is
|
|
||||||
/// unspecified.
|
|
||||||
/// </para>
|
|
||||||
/// </summary>
|
|
||||||
[JsonPropertyName("kid")]
|
|
||||||
public string? KeyId { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// "use" (Public Key Use) Parameter
|
|
||||||
/// <para>
|
|
||||||
/// The "use" (public key use) parameter identifies the intended use of
|
|
||||||
/// the public key. The "use" parameter is employed to indicate whether
|
|
||||||
/// a public key is used for encrypting data or verifying the signature
|
|
||||||
/// on data.
|
|
||||||
/// </para>
|
|
||||||
/// </summary>
|
|
||||||
[JsonPropertyName("use")]
|
|
||||||
public string? Use { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The the modulus value for the public RSA key. It is represented as the Base64URL encoding of value's big endian representation.
|
|
||||||
/// </summary>
|
|
||||||
[JsonPropertyName("n")]
|
|
||||||
public string? Modulus { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The exponent value for the public RSA key. It is represented as the Base64URL encoding of value's big endian representation.
|
|
||||||
/// </summary>
|
|
||||||
[JsonPropertyName("e")]
|
|
||||||
public string? Exponent { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The private exponent. It is represented as the Base64URL encoding of the value's big endian representation.
|
|
||||||
/// </summary>
|
|
||||||
[JsonPropertyName("d")]
|
|
||||||
public string? D { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The first prime factor. It is represented as the Base64URL encoding of the value's big endian representation.
|
|
||||||
/// </summary>
|
|
||||||
[JsonPropertyName("p")]
|
|
||||||
public string? P { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The second prime factor. It is represented as the Base64URL encoding of the value's big endian representation.
|
|
||||||
/// </summary>
|
|
||||||
[JsonPropertyName("q")]
|
|
||||||
public string? Q { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The first factor Chinese Remainder Theorem exponent. It is represented as the Base64URL encoding of the value's big endian representation.
|
|
||||||
/// </summary>
|
|
||||||
[JsonPropertyName("dp")]
|
|
||||||
public string? DP { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The second factor Chinese Remainder Theorem exponent. It is represented as the Base64URL encoding of the value's big endian representation.
|
|
||||||
/// </summary>
|
|
||||||
[JsonPropertyName("dq")]
|
|
||||||
public string? DQ { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The first Chinese Remainder Theorem coefficient. It is represented as the Base64URL encoding of the value's big endian representation.
|
|
||||||
/// </summary>
|
|
||||||
[JsonPropertyName("qi")]
|
|
||||||
public string? InverseQ { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The other primes information, should they exist, null or an empty list if not specified.
|
|
||||||
/// </summary>
|
|
||||||
[JsonPropertyName("oth")]
|
|
||||||
public string? OthInf { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// "alg" (Algorithm) Parameter
|
|
||||||
/// <para>
|
|
||||||
/// The "alg" (algorithm) parameter identifies the algorithm intended for
|
|
||||||
/// use with the key.
|
|
||||||
/// </para>
|
|
||||||
/// </summary>
|
|
||||||
[JsonPropertyName("alg")]
|
|
||||||
public string? Algorithm { get; set; }
|
|
||||||
}
|
|
||||||
@ -1,36 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Text.Json.Serialization;
|
|
||||||
|
|
||||||
namespace MaksIT.LetsEncrypt.Entities.Jws;
|
|
||||||
|
|
||||||
|
|
||||||
public class JwsMessage {
|
|
||||||
|
|
||||||
public string? Protected { get; set; }
|
|
||||||
|
|
||||||
public string? Payload { get; set; }
|
|
||||||
|
|
||||||
public string? Signature { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public class JwsHeader {
|
|
||||||
|
|
||||||
[JsonPropertyName("alg")]
|
|
||||||
public string? Algorithm { get; set; }
|
|
||||||
|
|
||||||
[JsonPropertyName("jwk")]
|
|
||||||
public Jwk? Key { get; set; }
|
|
||||||
|
|
||||||
|
|
||||||
[JsonPropertyName("kid")]
|
|
||||||
public string? KeyId { get; set; }
|
|
||||||
|
|
||||||
public string? Nonce { get; set; }
|
|
||||||
|
|
||||||
public Uri? Url { get; set; }
|
|
||||||
|
|
||||||
|
|
||||||
[JsonPropertyName("Host")]
|
|
||||||
public string? Host { get; set; }
|
|
||||||
}
|
|
||||||
@ -1,4 +1,5 @@
|
|||||||
namespace MaksIT.LetsEncrypt.Entities {
|
namespace MaksIT.LetsEncrypt.Entities;
|
||||||
|
|
||||||
public class CachedHostname {
|
public class CachedHostname {
|
||||||
public string Hostname { get; set; }
|
public string Hostname { get; set; }
|
||||||
public DateTime Expires { get; set; }
|
public DateTime Expires { get; set; }
|
||||||
@ -13,4 +14,3 @@
|
|||||||
IsDisabled = isDisabled;
|
IsDisabled = isDisabled;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|||||||
@ -2,8 +2,8 @@
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Security.Cryptography;
|
using System.Security.Cryptography;
|
||||||
using System.Security.Cryptography.X509Certificates;
|
using System.Security.Cryptography.X509Certificates;
|
||||||
|
using MaksIT.Core.Security.JWK;
|
||||||
|
|
||||||
using MaksIT.LetsEncrypt.Entities.Jws;
|
|
||||||
|
|
||||||
namespace MaksIT.LetsEncrypt.Entities;
|
namespace MaksIT.LetsEncrypt.Entities;
|
||||||
|
|
||||||
@ -18,7 +18,7 @@ public class RegistrationCache {
|
|||||||
public required string Description { get; set; }
|
public required string Description { get; set; }
|
||||||
public required string[] Contacts { get; set; }
|
public required string[] Contacts { get; set; }
|
||||||
public required bool IsStaging { get; set; }
|
public required bool IsStaging { get; set; }
|
||||||
public string? ChallengeType { get; set; }
|
public required string ChallengeType { get; set; }
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
@ -118,4 +118,23 @@ public class RegistrationCache {
|
|||||||
foreach (var host in hostsToRemove)
|
foreach (var host in hostsToRemove)
|
||||||
CachedCerts.Remove(host);
|
CachedCerts.Remove(host);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public Dictionary<string, string> GetCertsPemPerHostname() {
|
||||||
|
var result = new Dictionary<string, string>();
|
||||||
|
if (CachedCerts == null)
|
||||||
|
return result;
|
||||||
|
|
||||||
|
foreach (var kvp in CachedCerts) {
|
||||||
|
var hostname = kvp.Key;
|
||||||
|
var cert = kvp.Value;
|
||||||
|
if (!string.IsNullOrEmpty(cert.Cert) && !string.IsNullOrEmpty(cert.PrivatePem)) {
|
||||||
|
result[hostname] = $"{cert.Cert}\n{cert.PrivatePem}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,10 +1,5 @@
|
|||||||
using System;
|
namespace MaksIT.LetsEncrypt.Entities.LetsEncrypt;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace MaksIT.LetsEncrypt.Entities.LetsEncrypt {
|
|
||||||
public enum RevokeReason {
|
public enum RevokeReason {
|
||||||
Unspecified = 0,
|
Unspecified = 0,
|
||||||
KeyCompromise = 1,
|
KeyCompromise = 1,
|
||||||
@ -15,4 +10,3 @@ namespace MaksIT.LetsEncrypt.Entities.LetsEncrypt {
|
|||||||
PrivilegeWithdrawn = 6,
|
PrivilegeWithdrawn = 6,
|
||||||
AaCompromise = 7
|
AaCompromise = 7
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|||||||
@ -1,19 +1,17 @@
|
|||||||
using MaksIT.LetsEncrypt.Models.Responses;
|
using MaksIT.Core.Security.JWK;
|
||||||
|
using MaksIT.LetsEncrypt.Models.Responses;
|
||||||
using MaksIT.LetsEncrypt.Services;
|
using MaksIT.LetsEncrypt.Services;
|
||||||
using System;
|
using System.Security.Cryptography;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
namespace MaksIT.LetsEncrypt.Entities.LetsEncrypt;
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace MaksIT.LetsEncrypt.Entities.LetsEncrypt {
|
|
||||||
public class State {
|
public class State {
|
||||||
public bool IsStaging { get; set; }
|
public bool IsStaging { get; set; }
|
||||||
public AcmeDirectory? Directory { get; set; }
|
public AcmeDirectory? Directory { get; set; }
|
||||||
public JwsService? JwsService { get; set; }
|
|
||||||
public Order? CurrentOrder { get; set; }
|
public Order? CurrentOrder { get; set; }
|
||||||
public List<AuthorizationChallengeChallenge> Challenges { get; } = new List<AuthorizationChallengeChallenge>();
|
public List<AuthorizationChallengeChallenge> Challenges { get; } = new List<AuthorizationChallengeChallenge>();
|
||||||
public string? Nonce { get; set; }
|
|
||||||
public RegistrationCache? Cache { get; set; }
|
public RegistrationCache? Cache { get; set; }
|
||||||
}
|
public Jwk? Jwk { get; set; }
|
||||||
|
public RSA? Rsa { get; set; }
|
||||||
}
|
}
|
||||||
|
|||||||
16
src/LetsEncrypt/Entities/OrderStatus.cs
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
|
|
||||||
|
namespace MaksIT.LetsEncrypt.Entities;
|
||||||
|
|
||||||
|
public enum OrderStatus
|
||||||
|
{
|
||||||
|
[Display(Name = "pending")]
|
||||||
|
Pending,
|
||||||
|
[Display(Name = "valid")]
|
||||||
|
Valid,
|
||||||
|
[Display(Name = "ready")]
|
||||||
|
Ready,
|
||||||
|
[Display(Name = "processing")]
|
||||||
|
Processing
|
||||||
|
}
|
||||||
@ -1,7 +1,8 @@
|
|||||||
using MaksIT.Core.Extensions;
|
using MaksIT.LetsEncrypt.Models.Responses;
|
||||||
using MaksIT.LetsEncrypt.Models.Responses;
|
|
||||||
|
|
||||||
namespace MaksIT.LetsEncrypt.Exceptions;
|
namespace MaksIT.LetsEncrypt.Exceptions;
|
||||||
|
|
||||||
public class LetsEncrytException : Exception {
|
public class LetsEncrytException : Exception {
|
||||||
|
|
||||||
public Problem? Problem { get; }
|
public Problem? Problem { get; }
|
||||||
|
|||||||
@ -1,9 +1,9 @@
|
|||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
|
||||||
using MaksIT.LetsEncrypt.Services;
|
using MaksIT.LetsEncrypt.Services;
|
||||||
using Microsoft.Extensions.Configuration;
|
|
||||||
|
|
||||||
namespace MaksIT.LetsEncrypt.Extensions;
|
namespace MaksIT.LetsEncrypt.Extensions;
|
||||||
|
|
||||||
public static class ServiceCollectionExtensions {
|
public static class ServiceCollectionExtensions {
|
||||||
public static void RegisterLetsEncrypt(this IServiceCollection services, ILetsEncryptConfiguration appSettings) {
|
public static void RegisterLetsEncrypt(this IServiceCollection services, ILetsEncryptConfiguration appSettings) {
|
||||||
|
|
||||||
|
|||||||