Compare commits
62 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
06ba5e8e2c | ||
|
|
4543cfd02b | ||
|
|
c3efd64702 | ||
|
|
00276301da | ||
|
|
4c92f6c25b | ||
|
|
098fa91515 | ||
|
|
1c68cc63b8 | ||
|
|
d7721ff80e | ||
|
|
4fc9cfdcea | ||
|
|
bd54f6e6c3 | ||
|
|
23d143aabe | ||
|
|
c6d5b3fd1e | ||
|
|
86a31999bf | ||
|
|
bbd6fc5617 | ||
|
|
8a3e42a159 | ||
|
|
d8cb164de9 | ||
|
|
f43bd04157 | ||
|
|
3c9b432bd1 | ||
|
|
1b22b8688d | ||
|
|
685a174806 | ||
|
|
f70742cf18 | ||
|
|
830f3e7d3e | ||
|
|
0f4c4cbeac | ||
|
|
df835155ba | ||
|
|
76e0883595 | ||
|
|
05821bdea5 | ||
|
|
c971ee94b2 | ||
|
|
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 | ||
| 35eec5d864 |
17
.cursor/maksit-skills.json
Normal file
@ -0,0 +1,17 @@
|
||||
{
|
||||
"$schema": "homelab-maksit-skills-manifest-v2",
|
||||
"sharedSkillsRoot": "E:\\Users\\maksym\\source\\repos\\private\\homelab\\ai\\skills",
|
||||
"sharedSkills": [
|
||||
"common/csharp",
|
||||
"common/maksit-layering",
|
||||
"common/maksit-auth-rbac",
|
||||
"common/maksit-identity-tokens",
|
||||
"common/maksit-patch",
|
||||
"common/maksit-ha",
|
||||
"common/maksit-reverse-proxy",
|
||||
"common/react-typescript",
|
||||
"common/helm",
|
||||
"common/maksit-repo-maintenance",
|
||||
"local-ollama"
|
||||
]
|
||||
}
|
||||
23
.cursor/rules/maksit-skills.mdc
Normal file
@ -0,0 +1,23 @@
|
||||
---
|
||||
description: Load MaksIT agent skills from homelab common/
|
||||
globs: "**/*.{cs,csproj,slnx,ts,tsx,json,md,ps1,yml,yaml}"
|
||||
alwaysApply: true
|
||||
---
|
||||
|
||||
# MaksIT skills (maksit-certs-ui)
|
||||
|
||||
Complementary skills (no precedence). Read each `SKILL.md` when relevant:
|
||||
|
||||
1. `E:\Users\maksym\source\repos\private\homelab\ai\skills\common\csharp\SKILL.md`
|
||||
2. `E:\Users\maksym\source\repos\private\homelab\ai\skills\common\maksit-layering\SKILL.md`
|
||||
3. `E:\Users\maksym\source\repos\private\homelab\ai\skills\common\maksit-auth-rbac\SKILL.md`
|
||||
4. `E:\Users\maksym\source\repos\private\homelab\ai\skills\common\maksit-identity-tokens\SKILL.md`
|
||||
5. `E:\Users\maksym\source\repos\private\homelab\ai\skills\common\maksit-patch\SKILL.md`
|
||||
6. `E:\Users\maksym\source\repos\private\homelab\ai\skills\common\maksit-ha\SKILL.md`
|
||||
7. `E:\Users\maksym\source\repos\private\homelab\ai\skills\common\maksit-reverse-proxy\SKILL.md`
|
||||
8. `E:\Users\maksym\source\repos\private\homelab\ai\skills\common\react-typescript\SKILL.md`
|
||||
9. `E:\Users\maksym\source\repos\private\homelab\ai\skills\common\helm\SKILL.md`
|
||||
10. `E:\Users\maksym\source\repos\private\homelab\ai\skills\common\maksit-repo-maintenance\SKILL.md`
|
||||
11. `E:\Users\maksym\source\repos\private\homelab\ai\skills\local-ollama\SKILL.md` — local Ollama offload (`@local-ollama`)
|
||||
|
||||
Manifest: `.cursor/maksit-skills.json`.
|
||||
6
.gitignore
vendored
@ -261,6 +261,6 @@ paket-files/
|
||||
__pycache__/
|
||||
*.pyc
|
||||
|
||||
|
||||
**/*docker-compose/LetsEncryptServer/acme
|
||||
**/*docker-compose/LetsEncryptServer/cache
|
||||
# Custom
|
||||
dist/
|
||||
![Uu]tils/**
|
||||
21
AGENTS.md
Normal file
@ -0,0 +1,21 @@
|
||||
# Agent instructions (maksit-certs-ui)
|
||||
|
||||
Complementary skills (no precedence). Homelab paths use `sharedSkills` in `.cursor/maksit-skills.json`.
|
||||
|
||||
| Skill | Path |
|
||||
|-------|------|
|
||||
| csharp | [SKILL.md](E:\Users\maksym\source\repos\private\homelab\ai\skills\common\csharp\SKILL.md) |
|
||||
| maksit-layering | [SKILL.md](E:\Users\maksym\source\repos\private\homelab\ai\skills\common\maksit-layering\SKILL.md) |
|
||||
| maksit-auth-rbac | [SKILL.md](E:\Users\maksym\source\repos\private\homelab\ai\skills\common\maksit-auth-rbac\SKILL.md) |
|
||||
| maksit-identity-tokens | [SKILL.md](E:\Users\maksym\source\repos\private\homelab\ai\skills\common\maksit-identity-tokens\SKILL.md) |
|
||||
| maksit-patch | [SKILL.md](E:\Users\maksym\source\repos\private\homelab\ai\skills\common\maksit-patch\SKILL.md) |
|
||||
| maksit-ha | [SKILL.md](E:\Users\maksym\source\repos\private\homelab\ai\skills\common\maksit-ha\SKILL.md) |
|
||||
| maksit-reverse-proxy | [SKILL.md](E:\Users\maksym\source\repos\private\homelab\ai\skills\common\maksit-reverse-proxy\SKILL.md) |
|
||||
| react-typescript | [SKILL.md](E:\Users\maksym\source\repos\private\homelab\ai\skills\common\react-typescript\SKILL.md) |
|
||||
| helm | [SKILL.md](E:\Users\maksym\source\repos\private\homelab\ai\skills\common\helm\SKILL.md) |
|
||||
| maksit-repo-maintenance | [SKILL.md](E:\Users\maksym\source\repos\private\homelab\ai\skills\common\maksit-repo-maintenance\SKILL.md) |
|
||||
| local-ollama | [SKILL.md](E:\Users\maksym\source\repos\private\homelab\ai\skills\local-ollama\SKILL.md) |
|
||||
|
||||
Manifest: `.cursor/maksit-skills.json`.
|
||||
|
||||
**Contributors:** pick the skill that matches the task; **source code** is authoritative.
|
||||
218
CHANGELOG.md
Normal file
@ -0,0 +1,218 @@
|
||||
# Changelog
|
||||
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [3.5.2] - 2026-06-04
|
||||
|
||||
**Release status:** **3.3.4** is the last published release. **3.5.2** is a patch on **3.5.1** (documentation consolidation, dependency bumps).
|
||||
|
||||
### Changed
|
||||
|
||||
- **Documentation:** Removed **`assets/docs/`** topic guides (layering, HA, auth, RBAC, proxy, patch, PowerShell); README and CONTRIBUTING point contributors at **[AGENTS.md](AGENTS.md)** (homelab `common/maksit-*` skills); operator-facing health and HA notes stay in README and Helm **`NOTES.txt`**.
|
||||
- **Helm:** **`NOTES.txt`** health probe note is self-contained (no link to removed HA doc).
|
||||
- **Dependencies:** **MaksIT.Core** **1.6.7**, **MaksIT.Results** **2.0.2** (host, Engine, Client.Tests).
|
||||
|
||||
## [3.5.1] - 2026-06-02
|
||||
|
||||
**Release status:** **3.3.4** is the last published release. **3.5.1** is a patch on **3.5.0** (startup health, Helm secrets alignment, RBAC docs, Web UI token refresh).
|
||||
|
||||
### Breaking
|
||||
|
||||
- **Helm secrets (`certsServerSecrets`):** Renamed **`authSecret`** → **`jwtSecret`**, **`authPepper`** → **`passwordPepper`**. Bootstrap admin username moved from ConfigMap to secrets as **`adminUsername`** (removed **`certsServerConfig.configuration.certsEngineConfiguration.admin.username`**). Update custom values and external secret templates before upgrade.
|
||||
|
||||
### Added
|
||||
|
||||
- **`GET /health/startup`:** JSON snapshot of phased database and bootstrap startup (`CertsStartupState`, `IDatabaseStartupObserver`, `DatabaseStartupPhaseRunner`).
|
||||
- **Web UI:** **`webUiAuthRefresh.ts`** — single in-flight JWT refresh shared by axios (and **`resolveWebUiAccessToken`** for future SignalR hubs).
|
||||
- **Docs:** **`assets/docs/RBAC_REFERENCE.md`**, **`assets/docs/USER_AND_API_KEY_RBAC.md`**; README RBAC overview and table-of-contents links.
|
||||
- **E2E:** **`src/e2e-tests/README.md`** — PowerShell API-key E2E credentials and compose URL guidance (replaces **`MaksIT.CertsUI.Client.Tests/README.E2E.md`**).
|
||||
|
||||
### Changed
|
||||
|
||||
- **`GET /health/ready`:** Returns **HTTP 503** until bootstrap coordination completes (`CertsStartupState.IsApplicationReady`), then checks PostgreSQL as before.
|
||||
- **`RunMigrationsService`:** Reports phased startup; waits on maintenance database **`postgres`** before **`EnsureDatabaseExists`** and on the application database before **`MigrateUp`**.
|
||||
- **`SchemaSyncService`:** Reports **`schema_sync`** phase via **`IDatabaseStartupObserver`** (no-op timing when **`AutoSyncSchema`** is false).
|
||||
- **`InitializationHostedService`:** Records bootstrap coordination phase success/failure in **`CertsStartupState`**.
|
||||
- **`CertsEngineConfiguration.ConnectionString`:** **`required`** in host configuration (no empty default).
|
||||
- **`IdentityDomainService`:** Configuration field and error messages use **`CertsEngineConfiguration`** naming (not Vault-era **`VaultEngineConfiguration`**).
|
||||
- **Helm:** Server **`startupProbe`** on **`/health/ready`** (up to ~5 minutes); readiness **`initialDelaySeconds`** reduced to **5**; **`NOTES.txt`** documents **`/health/startup`** and external Postgres.
|
||||
- **README / Compose examples:** Admin username in **`appsecrets.json`** only; JWT/pepper placeholder names aligned with Helm.
|
||||
- **Dependencies:** linq2db **6.3.0**, Microsoft.Extensions.\* **10.0.8**, Npgsql **10.0.3**, Swashbuckle **10.2.1**, Testcontainers.PostgreSql **4.12.0**, **Microsoft.NET.Test.Sdk** **18.6.0**, PowerShell **System.Management.Automation** **7.6.2**.
|
||||
|
||||
### Removed
|
||||
|
||||
- **`MaksIT.CertsUI.Client.Tests`:** **`CertsUiApiKeyE2ETests`** and **`README.E2E.md`** (API-key E2E remains under **`src/e2e-tests/`** and PowerShell scripts).
|
||||
|
||||
### Upgrade notes (from 3.5.0)
|
||||
|
||||
- **Helm:** Rename secret keys in **`certsServerSecrets`** and set **`adminUsername`**; remove admin username from non-secret ConfigMap overrides if you duplicated it there.
|
||||
- **Probes:** Use **`/health/startup`** for startup diagnostics; keep load balancers on **`/health/ready`** (503 until the cluster has a bootstrapped user).
|
||||
|
||||
## [3.5.0] - 2026-05-24
|
||||
|
||||
**Release status:** **3.3.4** is the last published release. **3.5.0** consolidates all changes since **3.3.4** (HA, Engine/Vault alignment, client libraries, Web UI shared packages).
|
||||
|
||||
### Breaking
|
||||
|
||||
- **HA / interactive ACME:** Removed **`IPrimaryReplicaWorkload`**, **`PrimaryReplicaGate`**, **`PrimaryReplicaShutdownHostedService`**, and **`CertsFlowPrimaryReplica`**. All replicas may run configure-client, init, orders, challenge completion, certificate download, apply, and revoke. The API no longer returns **HTTP 503** with **`urn:maksit:certs-ui:primary-replica-required`**. Clients that retried on that signal should use normal error semantics only.
|
||||
- **HTTP-01 challenge:** **`AcmeChallengeAsync`** no longer writes tokens under **`AcmeFolder`** or reads legacy on-disk files. Challenge text is served from PostgreSQL only; ingress must reach **`GET /.well-known/acme-challenge/{token}`** on this app (or equivalent).
|
||||
- **Startup / filesystem:** Removed the shared **`init`** marker under **`DataFolder`**, **`AcmeFolder`**, and **`DataFolder`** settings, and default server **acme**/**data** PVC mounts. Followers wait until the database reports at least one user.
|
||||
- **Configuration:** **`CertsUIEngineConfiguration`** renamed to **`CertsEngineConfiguration`** in appsettings, Helm **`values.yaml`**, and secrets templates.
|
||||
- **Engine layout:** **`Persistance`** → **`Persistence`**; **`CertsLinq2DbMapping`** → **`CertsUILinq2DbMapping`**.
|
||||
- **Engine query ports (Vault-style):** **`IUserQueryService`**, **`IApiKeyQueryService`**, and **`IApiKeyEntityScopeQueryService`** use synchronous **`Search`** / **`Count`** with optional **`Expression<Func<TDto, bool>>?`** predicates, **`skip` / `limit`**, and **`Result`** types — not async paged **`Search…Async`** with string filters.
|
||||
- **ACME session persistence:** **`IAcmeSessionStore`**, **`AcmePostgresSessionStore`**, **`AcmeSessionSnapshot`**, and **`AcmeSessionJsonSerializer`** removed. **`ILetsEncryptService`** depends on **`IAcmeSessionPersistenceService`** (**`AcmeSessionPersistenceServiceLinq2Db`**) for **`acme_sessions`** JSON load/save.
|
||||
- **`ICertsFlowDomainService`:** Constructor takes **`IRegistrationCacheDomainService`** instead of **`IRegistrationCachePersistenceService`**.
|
||||
- **Web UI:** Removed the in-repo shared UI stack (layout, DataTable, form editors, deep/enum helpers, local toast). The SPA depends on **`@maks-it.com/webui-core`**, **`webui-components`**, and **`webui-contracts`** (private npm registry; **`src/MaksIT.WebUI/.npmrc`**).
|
||||
- **E2E tests:** **`CertsUiApiKeyE2ETests`** removed from **`MaksIT.CertsUI.Tests`**; API-key E2E lives in **`MaksIT.CertsUI.Client.Tests`** (`Category=E2E`).
|
||||
- **Terms of Service API:** Interactive ACME uses only **`GET /api/certs/{sessionId}/terms-of-service`** (stateless **`isStaging`** variant removed).
|
||||
- **Startup migrations:** Removed legacy EF-era baseline, **`VersionInfo` → `version_info`** rename repair, PascalCase → snake_case column repair, and **`RunMigrationsService.BaselineVersion`**. **`MigrateUp`** expects schema managed only by in-process FluentMigrator migrations.
|
||||
- **Database:** **`users.JwtTokensJson`** removed; sessions live in **`jwt_tokens`** only (no duplicate JSON on **`users`**).
|
||||
- **Deprecated host:** Removed legacy **`MaksIT.Webapi`** and **`MaksIT.Webapi.Tests`** in favor of **`MaksIT.CertsUI`** / **`MaksIT.CertsUI.Tests`**.
|
||||
|
||||
### Added
|
||||
|
||||
- **`MaksIT.CertsUI.Client`:** HTTP client library with API key auth (**`ICertsUIClient`**, **`CertsUIClient`**, **`ServiceCollectionExtensions`**, **`CertsUIApiException`**).
|
||||
- **`MaksIT.CertsUI.Contracts`:** Shared wire types (**`AccountResponse`**, **`HostnameResponse`**, **`RuntimeInstanceIdResponse`**).
|
||||
- **`MaksIT.CertsUI.Client.PowerShell`:** Binary module (**`Connect-CertsUI`**, **`Get-CertsUIAccounts`**, **`Invoke-CertsUICreateAccount`**, etc.; requires **PowerShell 7** on **.NET 10**).
|
||||
- **`MaksIT.CertsUI.Client.Tests`:** Unit tests plus relocated API-key E2E suite.
|
||||
- **PowerShell E2E:** **`src/e2e-tests/`** scenarios and **`Test-CertsUiApiKeyE2E.ps1`** / **`.bat`** (Vault-style **`CERTSUI_E2E_CREDENTIALS`**).
|
||||
- **Docs:** **`assets/docs/POWERSHELL_CLIENT_MODULE.md`**, **`assets/docs/ARCHITECTURE_LAYERING.md`**, HA and login architecture docs; **[CONTRIBUTING.md](CONTRIBUTING.md)** links layering doc and **`dotnet test`** guidance.
|
||||
- **New backend host:** **`MaksIT.CertsUI`** WebAPI with controllers, JWT and JWT-or-API-key authorization, hosted services, and mapping/configuration abstractions.
|
||||
- **Engine platform:** Domain-oriented **`MaksIT.CertsUI.Engine`** (`Domain`, `Dto`, `DomainServices`, `Persistence`, `QueryServices`, `Infrastructure`, `FluentMigrations`) with Linq2Db mappings and migration services.
|
||||
- **Engine (Vault parity):** **`EntityScopeBase`**; **`UserAuthorization`** / **`ApiKeyAuthorization`** aggregates; split **`UserEntityScope`** / **`ApiKeyEntityScope`**; **`IdentityDomainService`** / **`ApiKeyDomainService`** refactor aligned with MaksIT.Vault.
|
||||
- **`ExpressionCompose`** for composing nested Linq2Db predicates.
|
||||
- **`IRegistrationCacheDomainService`** / **`RegistrationCacheDomainService`**, **`RegistrationCachePayloadDocument`**, and **`RegistrationCachePayloadJsonTests`**.
|
||||
- **`IAcmeSessionPersistenceService`**, **`AcmeSessionPersistenceServiceLinq2Db`**, and **`AcmeSessionPayloadMapper`** for PostgreSQL-backed ACME **`State`**.
|
||||
- **`PostgresStartupWait`** — waits for PostgreSQL and retries FluentMigrator **`MigrateUp`** on transient startup failures.
|
||||
- **API / RBAC:** **`GetActingJwtTokenData`** maps API keys to a synthetic **`JwtTokenData`** principal; **`RbacHelpers.EnsureActorMayAssignGlobalAdmin`** / **`EnsureActorMayPatchGlobalAdminFlag`**.
|
||||
- **HA runtime coordination:** DB-backed HTTP-01 challenge persistence and runtime leases (**`acme_http_challenges`**, **`app_runtime_leases`**, **`acme_sessions`**, **`terms_of_service_cache`**); coordinated bootstrap and renewal execution.
|
||||
- **Kubernetes:** Per-component Helm **`replicaCount`**, PodDisruptionBudget support, health endpoints (**`/health/live`**, **`/health/ready`**), optional **`kubernetesUpstreamHosts`** for in-cluster YARP upstreams.
|
||||
- **LetsEncrypt:** Per-host ACME rate-limit cooldown on **`RegistrationCache`**; **`AcmeProblemKind`** enumeration; in-memory **`AcmeSessionStore`** (later superseded by PostgreSQL persistence); partial **`LetsEncryptService`** files; **`State.TryGetAccountKey`**; **`LetsEncrypt.Tests`** for retry parsing and cooldown JSON.
|
||||
- **Frontend:** Users/API Keys pages and forms; identity/API-key UX with list/filter/paging (later migrated to **`webui-*`** packages).
|
||||
- **Test suite:** **`MaksIT.CertsUI.Tests`** and **`MaksIT.CertsUI.Engine.Tests`** with Postgres/WebAPI fixtures.
|
||||
- **Release tooling:** **`DotNetDockerPush`** per-image **`versionEnvFiles`** (temporary **`VITE_APP_VERSION`** rewrite) and optional per-image **`contextPath`** (upstreamed to **maksit-repoutils** 1.0.11).
|
||||
- **Helm / config:** **`certsEngineConfiguration.autoSyncSchema`** (default **`true`**) for add-only column sync on startup.
|
||||
|
||||
### Changed
|
||||
|
||||
- **Identity / API key controllers:** Use **`GetActingJwtTokenData`** instead of JWT-only **`GetJwtTokenData`** for user and API-key CRUD/search.
|
||||
- **IdentityService** / **ApiKeyService:** Build predicates and call **`Count`** + **`Search`** on query services; thin-search wiring (Pattern B).
|
||||
- **Web UI:** Migrated to **`@maks-it.com/webui-*`** packages; **`createWebUiHttpClient`**; **`apiRoutes.ts`**; pages under **`src/pages/`**; **`webUi/dataSources.ts`**; models reorganized under domain folders aligned with **`webui-contracts`**. Earlier step: **`axiosConfig`** helpers return **`{ payload, status, ok }`**.
|
||||
- **ACME sessions:** Let's Encrypt client **`State`** persisted in PostgreSQL **`acme_sessions`** so any replica can continue after load balancing.
|
||||
- **LetsEncrypt / `HttpClient`:** **`ConfigureClient`** uses absolute ACME directory URL instead of assigning **`BaseAddress`** on the shared client.
|
||||
- **`CertsFlowDomainService`:** **`PurgeStaleHttpChallengesAsync`** (HTTP-01 cleanup); **`AutoRenewal`** calls it before renewal work; skips hostnames in ACME cooldown window.
|
||||
- **`LetsEncryptService`:** Uses **`IAcmeSessionPersistenceService`**; dropped **`Newtonsoft.Json`** from Engine (STJ-only JSON paths).
|
||||
- **`CacheService`:** Thin façade over **`IRegistrationCacheDomainService`**.
|
||||
- **Bootstrap / renewal:** **`InitializationHostedService`** acquires **`certs-ui-bootstrap`** (**`RuntimeLeaseNames.BootstrapCoordinator`**) for empty-database admin creation, then releases. **`AutoRenewal`** acquires **`certs-ui-renewal-sweep`** (**`RuntimeLeaseNames.RenewalSweep`**) per sweep. Lease name **`certs-ui-primary`** replaced by bootstrap and renewal sweep constants.
|
||||
- **HA / ToS cache:** Terms of Service PDF caching moved from pod filesystem to PostgreSQL **`terms_of_service_cache`** with TTL/HTTP validators.
|
||||
- **FluentMigrator:** Standard **`VersionInfo`** table and columns; **`.ScanIn(…).For.All()`** discovery; migrations run in **`Program.cs`** after **`Build()`** before hosted services; logged host/database and migration count; coordination DDL repair after **`MigrateUp`** when tables missing despite applied version.
|
||||
- **Schema sync:** **`AutoSyncSchema`** add-only (**`ADD COLUMN IF NOT EXISTS`**; no DROP); desired map includes **`users.IsActive`**, **`TwoFactorSharedKey`**.
|
||||
- **Docker Compose / Helm:** YARP upstream env vars for in-cluster vs Compose hostnames; **`components.server.service.sessionAffinity`** defaults to **`false`** (stateless LB); **`certsClientRuntime.apiUrl`** defaults to **`/api`**; optional **`preStop`** sleep and **`terminationGracePeriodSeconds`** for rolling updates.
|
||||
- **Container image:** **`MaksIT.CertsUI`** Dockerfile installs **`libgssapi-krb5-2`** for Npgsql GSS support on slim images.
|
||||
- **Namespace and solution layout:** Standardized around **`MaksIT.CertsUI*`** host/engine split; ACME contracts moved from legacy **`Entities`/`Models`** into **`Domain`** / **`Dto`**.
|
||||
- **LetsEncrypt:** Broader nullable annotations; **`CachedHostname`** primary constructor; certificate loading via **`X509Certificate2.CreateFromPem`** / **`X509CertificateLoader.LoadCertificate`**.
|
||||
- **Integration tests:** **`InMemoryUserStore`**, **`CacheServiceTests`**, **`CertsFlowServiceTests`**, **`ApiKeyQueryServiceIntegrationTests`**, **`AccountServicePatchAccountIntegrationTests`** aligned with new ports.
|
||||
- **README:** Architecture references, HA guidance, E2E instructions for dotnet test and PowerShell scenarios.
|
||||
|
||||
### Fixed
|
||||
|
||||
- **Startup / HA:** Bootstrap lease no longer blocks extra replicas when users already exist; cooperative cancel on host shutdown; **`CoordinationTableProvisioner`** with explicit **`public.*`** DDL; **`RuntimeLeaseServiceNpgsql`** uses **`public.app_runtime_leases`**; post-migrate verification for coordination tables.
|
||||
- **FluentMigrator:** Empty connection string no longer puts runner in connectionless/preview mode; throw when engine connection string missing; maintenance DB bootstrap warns instead of failing when role cannot **`CREATE DATABASE`**.
|
||||
- **Identity / PostgreSQL:** **`users.JwtTokensJson`** column dropped; new inserts no longer hit **`23502`**; token rows normalized into **`jwt_tokens`**.
|
||||
- **Helm / reverseproxy:** YARP upstreams no longer default to unresolvable Compose hostnames in Kubernetes when **`kubernetesUpstreamHosts`** is enabled.
|
||||
- **LetsEncrypt:** **`RevokeCertificate`** fails correctly on non-success; disposes HTTP response on success; **`NewOrder`** logs authorization status; **`TryGetCachedCertificate`** returns **`false`** when private key blob missing.
|
||||
- **`AccountService.PatchAccountAsync`:** Returns account built from cache after reload, not stale in-memory instance.
|
||||
- **WebUI Terms of Service:** PDF worker loaded from Vite-bundled asset (**`pdf.worker.min.mjs?url`**) for dev and production.
|
||||
|
||||
### Removed
|
||||
|
||||
- **`CertsFlowPrimaryReplica`**, **`PrimaryReplicaRequiredObjectResult`**, **`CertsFlowResultExtensions`** / **`ToCertsFlowActionResult`**; **`CertsFlowController`** uses **`ToActionResult()`**.
|
||||
- **Web UI (local):** **`DataTable`**, **`FormLayout`**, **`Layout`**, **`LazyLoadTable`**, editor components, **`Toast`**, **`Offcanvas`**, **`useFormState`**, **`localStorage/identity`**, legacy **`functions/`** / **`models/`** trees superseded by **`webui-*`** packages.
|
||||
- **Web UI:** Primary-replica **503** auto-retry in **`axiosConfig.ts`**.
|
||||
- **Configuration / Helm:** **`AcmeFolder`**, **`DataFolder`**, default **acme**/**data** PVC mounts; **`AddMemoryCache()`** host registration (unused).
|
||||
- **Legacy engine layout:** Obsolete top-level engine files, old **`.vscode`** project files.
|
||||
|
||||
### Upgrade notes (from 3.3.4)
|
||||
|
||||
**3.3.4** is the last published release. **3.5.0** uses a new host, PostgreSQL-backed registration cache, and FluentMigrator schema — there is no in-place migration of Let's Encrypt account material from **3.3.4**. Use backup → install → restore:
|
||||
|
||||
1. **On 3.3.4 (before upgrade):** Sign in to the Web UI, open **Utilities**, and **Download cache files** (full registration-cache ZIP). Store the file safely — it contains your Let's Encrypt account keys and cached certificate data. Optionally export Postman/API backups of any other settings you rely on.
|
||||
2. **Prepare 3.5.0:** Provision a **new empty PostgreSQL database** (or drop and recreate the engine database). Update Helm/secrets: rename **`certsUIEngineConfiguration`** → **`certsEngineConfiguration`**, set **`ConnectionString`**, and remove legacy **`acme`** / **`data`** bind mounts from **`docker-compose.override.yml`** if present.
|
||||
3. **Deploy 3.5.0:** Install the new server, client, and reverse-proxy images (pin tags to **`3.5.0`**, not **`latest`**). On first start, FluentMigrator creates the schema; bootstrap creates the default admin when the database has no users.
|
||||
4. **Restore accounts:** Sign in on **3.5.0**, open **Utilities**, and **Upload cache files** with the ZIP from step 1. Verify accounts and certificates in the UI before decommissioning **3.3.4**.
|
||||
5. **Re-create operators:** Users, API keys, and JWT sessions from **3.3.4** are not migrated automatically — recreate users/API keys in **3.5.0** as needed.
|
||||
|
||||
**Also check when upgrading:**
|
||||
|
||||
- **Operations:** Retarget alerts from lease **`certs-ui-primary`** to **`certs-ui-bootstrap`** and **`certs-ui-renewal-sweep`**.
|
||||
- **Web UI build:** Configure npm auth for **`@maks-it.com/*`** (see **`src/MaksIT.WebUI/.npmrc`**) when building the client image locally.
|
||||
- **E2E:** **`dotnet test`** on **`MaksIT.CertsUI.Client.Tests`** with **`Category=E2E`**; set **`CERTSUI_E2E_EXPECT_MIN_DISTINCT_INSTANCES=2`** for HA (PowerShell E2E defaults to **1** for Docker Compose).
|
||||
- **Repo utils:** **`utils/`** refreshed from **maksit-repoutils** 1.0.14 (`engines/`, `plugins/`, `modules/`, `tools/`). Run **`utils\Invoke-ReleasePackage.bat`** for release; **`utils\Invoke-TestEngine.bat`** for tests and coverage badges; refresh via **`utils\Update-RepoUtils.bat`** (set **`dryRun`: false** in **`utils/tools/Update-RepoUtils/scriptSettings.json`**).
|
||||
|
||||
## [3.3.4] - 2026-04-01
|
||||
|
||||
### Added
|
||||
|
||||
- `MaksIT.Webapi.Tests`: service-level unit tests (settings, cache, identity, agent, account, certs flow) and domain tests for `Settings`.
|
||||
- Postman collections under `src/Postman` updated to match current `MaksIT.Webapi` routes, JWT flow, and cache endpoints.
|
||||
|
||||
### Fixed
|
||||
|
||||
- WebUI Terms of Service (Let's Encrypt): PDF viewer loads `pdfjs-dist` worker from a Vite-bundled asset (`pdf.worker.min.mjs?url`) so rendering works in dev and production instead of failing on missing or wrong worker URLs.
|
||||
- `AccountService.PatchAccountAsync` returns the account built from the cache after reload, not a stale in-memory instance.
|
||||
|
||||
## [3.3.3] - 2025-12-20
|
||||
|
||||
### Changed
|
||||
|
||||
- Relicensed project from GPL-3.0 to Apache-2.0.
|
||||
|
||||
## [3.3.2] - 2025-12-20
|
||||
|
||||
### Changed
|
||||
|
||||
- Minimal Helm chart and documentation improvements.
|
||||
|
||||
## [3.3.1] - 2025-11-22
|
||||
|
||||
### Changed
|
||||
|
||||
- Public release following the v3.3.0 pre-release.
|
||||
|
||||
## [3.3.0] - 2025-11-15
|
||||
|
||||
### Changed
|
||||
|
||||
- Pre-release of the v3.3.x line.
|
||||
|
||||
## [3.2.0] - 2025-09-11
|
||||
|
||||
### Added
|
||||
|
||||
- New WebUI with authentication.
|
||||
|
||||
## [3.1.0] - 2024-08-11
|
||||
|
||||
### Changed
|
||||
|
||||
- Stabilized release following v3.0.0.
|
||||
|
||||
## [3.0.0] - 2024-05-31
|
||||
|
||||
### Added
|
||||
|
||||
- WebAPI and containerization.
|
||||
|
||||
## [2.0.0] - 2019-11-01
|
||||
|
||||
### Changed
|
||||
|
||||
- Dependency injection pattern implementation.
|
||||
|
||||
## [1.0.0] - 2019-06-29
|
||||
|
||||
### Added
|
||||
|
||||
- Initial release.
|
||||
59
CONTRIBUTING.md
Normal file
@ -0,0 +1,59 @@
|
||||
# Contributing to MaksIT.CertsUI
|
||||
|
||||
Thank you for your interest in improving this project. This document describes how to set up a development environment, what we expect from contributions, and where to get help.
|
||||
|
||||
## License
|
||||
|
||||
By contributing, you agree that your contributions will be licensed under the same terms as the project. See [LICENSE.md](LICENSE.md) (Apache License 2.0).
|
||||
|
||||
## What to contribute
|
||||
|
||||
Useful contributions include bug fixes, documentation improvements, Helm chart updates, and small, focused feature changes that fit the architecture described in [README.md](README.md) (single agent, HTTP-01, and related limitations).
|
||||
|
||||
Large or architectural changes are best discussed first (see [Contact](#contact)) so effort aligns with project goals.
|
||||
|
||||
## Architecture and code layout
|
||||
|
||||
**Canonical (contributors / AI agents):** [AGENTS.md](AGENTS.md) — homelab shared skills via `.cursor/maksit-skills.json`.
|
||||
|
||||
**Summary:** `MaksIT.CertsUI.Engine` holds domain, PostgreSQL persistence (Linq2Db), migrations, and ACME engine code; it returns `MaksIT.Results` types, not HTTP responses. `MaksIT.CertsUI` is the web host (controllers, app services, ProblemDetails). Before changing filters or identity/API-key services, read **maksit-auth-rbac** and **maksit-layering** (listed in AGENTS.md).
|
||||
|
||||
## Development setup
|
||||
|
||||
### Prerequisites
|
||||
|
||||
- [.NET SDK](https://dotnet.microsoft.com/download) compatible with the `TargetFramework` values in the `.csproj` files under `src/` (the main solution currently targets **.NET 10**).
|
||||
- Optional but recommended for end-to-end checks: **Docker** or **Podman**, as in the README installation sections.
|
||||
- **Visual Studio 2022** (17.14+) or another editor with C# support works well; the solution file is `src/MaksIT.CertsUI.slnx` (SLNX; requires a recent `dotnet` SDK, e.g. 9.0.200+).
|
||||
|
||||
### Build
|
||||
|
||||
From the repository root:
|
||||
|
||||
```bash
|
||||
dotnet build src/MaksIT.CertsUI.slnx -c Release
|
||||
```
|
||||
|
||||
Use `Debug` while iterating locally if you prefer.
|
||||
|
||||
### Run the stack locally
|
||||
|
||||
Follow [README.md](README.md) for Podman Compose, Docker Compose, or Kubernetes (Helm). That is the supported way to exercise the WebAPI, WebUI, and reverse proxy together.
|
||||
|
||||
**Automated tests:** CI runs `utils/engines/test` (Engine, Client, and main test projects). From the repo root: `dotnet test src/MaksIT.CertsUI.Engine.Tests`, `dotnet test src/MaksIT.CertsUI.Client.Tests` (mock HTTP only), and `dotnet test src/MaksIT.CertsUI.Tests` (Testcontainers PostgreSQL for integration tests). **E2E** against a live deployment is manual only: [`src/e2e-tests/README.md`](src/e2e-tests/README.md). For UI-only or deployment changes, manual verification through the WebUI and compose or cluster setup still applies.
|
||||
|
||||
## Pull requests
|
||||
|
||||
1. **Branch from the branch the maintainers use for integration** (often `dev` or `main`—check the default on the host repository).
|
||||
2. **Keep changes scoped**—one logical fix or feature per PR makes review and history easier.
|
||||
3. **Describe the change** in the PR: what problem it solves, how you tested it, and any operational impact (config, Helm values, images).
|
||||
4. **Update [CHANGELOG.md](CHANGELOG.md)** when the change is user-visible (behavior, security, deployment, or notable docs). Add entries under a new version heading or an `[Unreleased]` section at the top, following the existing [Keep a Changelog](https://keepachangelog.com/) style.
|
||||
5. **Avoid unrelated formatting or drive-by refactors** in the same PR as functional changes.
|
||||
|
||||
## Security issues
|
||||
|
||||
Please do not open a public issue for undisclosed security vulnerabilities. Report them privately using the contact in [README.md](README.md) (Contact section) so they can be handled responsibly.
|
||||
|
||||
## Contact
|
||||
|
||||
Questions and coordination: see **Contact** in [README.md](README.md).
|
||||
845
LICENSE.md
@ -1,675 +1,174 @@
|
||||
### GNU GENERAL PUBLIC LICENSE
|
||||
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc.
|
||||
<https://fsf.org/>
|
||||
|
||||
Everyone is permitted to copy and distribute verbatim copies of this
|
||||
license document, but changing it is not allowed.
|
||||
|
||||
### Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom
|
||||
to share and change all versions of a program--to make sure it remains
|
||||
free software for all its users. We, the Free Software Foundation, use
|
||||
the GNU General Public License for most of our software; it applies
|
||||
also to any other work released this way by its authors. You can apply
|
||||
it to your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you
|
||||
have certain responsibilities if you distribute copies of the
|
||||
software, or if you modify it: responsibilities to respect the freedom
|
||||
of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the
|
||||
manufacturer can do so. This is fundamentally incompatible with the
|
||||
aim of protecting users' freedom to change the software. The
|
||||
systematic pattern of such abuse occurs in the area of products for
|
||||
individuals to use, which is precisely where it is most unacceptable.
|
||||
Therefore, we have designed this version of the GPL to prohibit the
|
||||
practice for those products. If such problems arise substantially in
|
||||
other domains, we stand ready to extend this provision to those
|
||||
domains in future versions of the GPL, as needed to protect the
|
||||
freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish
|
||||
to avoid the special danger that patents applied to a free program
|
||||
could make it effectively proprietary. To prevent this, the GPL
|
||||
assures that patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
### TERMS AND CONDITIONS
|
||||
|
||||
#### 0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds
|
||||
of works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of
|
||||
an exact copy. The resulting work is called a "modified version" of
|
||||
the earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user
|
||||
through a computer network, with no transfer of a copy, is not
|
||||
conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices" to
|
||||
the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
#### 1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work for
|
||||
making modifications to it. "Object code" means any non-source form of
|
||||
a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users can
|
||||
regenerate automatically from other parts of the Corresponding Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that same
|
||||
work.
|
||||
|
||||
#### 2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not convey,
|
||||
without conditions so long as your license otherwise remains in force.
|
||||
You may convey covered works to others for the sole purpose of having
|
||||
them make modifications exclusively for you, or provide you with
|
||||
facilities for running those works, provided that you comply with the
|
||||
terms of this License in conveying all material for which you do not
|
||||
control copyright. Those thus making or running the covered works for
|
||||
you must do so exclusively on your behalf, under your direction and
|
||||
control, on terms that prohibit them from making any copies of your
|
||||
copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under the
|
||||
conditions stated below. Sublicensing is not allowed; section 10 makes
|
||||
it unnecessary.
|
||||
|
||||
#### 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such
|
||||
circumvention is effected by exercising rights under this License with
|
||||
respect to the covered work, and you disclaim any intention to limit
|
||||
operation or modification of the work as a means of enforcing, against
|
||||
the work's users, your or third parties' legal rights to forbid
|
||||
circumvention of technological measures.
|
||||
|
||||
#### 4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
#### 5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these
|
||||
conditions:
|
||||
|
||||
- a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
- b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under
|
||||
section 7. This requirement modifies the requirement in section 4
|
||||
to "keep intact all notices".
|
||||
- c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
- d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
#### 6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms of
|
||||
sections 4 and 5, provided that you also convey the machine-readable
|
||||
Corresponding Source under the terms of this License, in one of these
|
||||
ways:
|
||||
|
||||
- a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
- b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the Corresponding
|
||||
Source from a network server at no charge.
|
||||
- c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
- d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
- e) Convey the object code using peer-to-peer transmission,
|
||||
provided you inform other peers where the object code and
|
||||
Corresponding Source of the work are being offered to the general
|
||||
public at no charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal,
|
||||
family, or household purposes, or (2) anything designed or sold for
|
||||
incorporation into a dwelling. In determining whether a product is a
|
||||
consumer product, doubtful cases shall be resolved in favor of
|
||||
coverage. For a particular product received by a particular user,
|
||||
"normally used" refers to a typical or common use of that class of
|
||||
product, regardless of the status of the particular user or of the way
|
||||
in which the particular user actually uses, or expects or is expected
|
||||
to use, the product. A product is a consumer product regardless of
|
||||
whether the product has substantial commercial, industrial or
|
||||
non-consumer uses, unless such uses represent the only significant
|
||||
mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to
|
||||
install and execute modified versions of a covered work in that User
|
||||
Product from a modified version of its Corresponding Source. The
|
||||
information must suffice to ensure that the continued functioning of
|
||||
the modified object code is in no case prevented or interfered with
|
||||
solely because modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or
|
||||
updates for a work that has been modified or installed by the
|
||||
recipient, or for the User Product in which it has been modified or
|
||||
installed. Access to a network may be denied when the modification
|
||||
itself materially and adversely affects the operation of the network
|
||||
or violates the rules and protocols for communication across the
|
||||
network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
#### 7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders
|
||||
of that material) supplement the terms of this License with terms:
|
||||
|
||||
- a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
- b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
- c) Prohibiting misrepresentation of the origin of that material,
|
||||
or requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
- d) Limiting the use for publicity purposes of names of licensors
|
||||
or authors of the material; or
|
||||
- e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
- f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions
|
||||
of it) with contractual assumptions of liability to the recipient,
|
||||
for any liability that these contractual assumptions directly
|
||||
impose on those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions; the
|
||||
above requirements apply either way.
|
||||
|
||||
#### 8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your license
|
||||
from a particular copyright holder is reinstated (a) provisionally,
|
||||
unless and until the copyright holder explicitly and finally
|
||||
terminates your license, and (b) permanently, if the copyright holder
|
||||
fails to notify you of the violation by some reasonable means prior to
|
||||
60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
#### 9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or run
|
||||
a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
#### 10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
#### 11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims owned
|
||||
or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within the
|
||||
scope of its coverage, prohibits the exercise of, or is conditioned on
|
||||
the non-exercise of one or more of the rights that are specifically
|
||||
granted under this License. You may not convey a covered work if you
|
||||
are a party to an arrangement with a third party that is in the
|
||||
business of distributing software, under which you make payment to the
|
||||
third party based on the extent of your activity of conveying the
|
||||
work, and under which the third party grants, to any of the parties
|
||||
who would receive the covered work from you, a discriminatory patent
|
||||
license (a) in connection with copies of the covered work conveyed by
|
||||
you (or copies made from those copies), or (b) primarily for and in
|
||||
connection with specific products or compilations that contain the
|
||||
covered work, unless you entered into that arrangement, or that patent
|
||||
license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
#### 12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under
|
||||
this License and any other pertinent obligations, then as a
|
||||
consequence you may not convey it at all. For example, if you agree to
|
||||
terms that obligate you to collect a royalty for further conveying
|
||||
from those to whom you convey the Program, the only way you could
|
||||
satisfy both those terms and this License would be to refrain entirely
|
||||
from conveying the Program.
|
||||
|
||||
#### 13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
#### 14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions
|
||||
of the GNU General Public License from time to time. Such new versions
|
||||
will be similar in spirit to the present version, but may differ in
|
||||
detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies that a certain numbered version of the GNU General Public
|
||||
License "or any later version" applies to it, you have the option of
|
||||
following the terms and conditions either of that numbered version or
|
||||
of any later version published by the Free Software Foundation. If the
|
||||
Program does not specify a version number of the GNU General Public
|
||||
License, you may choose any version ever published by the Free
|
||||
Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future versions
|
||||
of the GNU General Public License can be used, that proxy's public
|
||||
statement of acceptance of a version permanently authorizes you to
|
||||
choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
#### 15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT
|
||||
WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND
|
||||
PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE
|
||||
DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR
|
||||
CORRECTION.
|
||||
|
||||
#### 16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR
|
||||
CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES
|
||||
ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT
|
||||
NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR
|
||||
LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM
|
||||
TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER
|
||||
PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
#### 17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
---
|
||||
|
||||
## TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
### 1. Definitions
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but not
|
||||
limited to compiled object code, generated documentation, and
|
||||
conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"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
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
---
|
||||
|
||||
### 2. Grant of Copyright License
|
||||
|
||||
Subject to the terms and conditions of this License, each Contributor
|
||||
hereby grants to You a perpetual, worldwide, non-exclusive, no-charge,
|
||||
royalty-free, irrevocable copyright license to reproduce, prepare
|
||||
Derivative Works of, publicly display, publicly perform, sublicense,
|
||||
and distribute the Work and such Derivative Works in Source or Object
|
||||
form.
|
||||
|
||||
---
|
||||
|
||||
### 3. Grant of Patent License
|
||||
|
||||
Subject to the terms and conditions of this License, each Contributor
|
||||
hereby grants to You a perpetual, worldwide, non-exclusive, no-charge,
|
||||
royalty-free, irrevocable (except as stated in this section) patent
|
||||
license to make, have made, use, offer to sell, sell, import, and
|
||||
otherwise transfer the Work, where such license applies only to those
|
||||
patent claims licensable by such Contributor that are necessarily
|
||||
infringed by their Contribution(s) alone or by combination of their
|
||||
Contribution(s) with the Work to which such Contribution(s) was
|
||||
submitted.
|
||||
|
||||
If You institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work or a
|
||||
Contribution incorporated within the Work constitutes direct or
|
||||
contributory patent infringement, then any patent licenses granted to
|
||||
You under this License for that Work shall terminate as of the date
|
||||
such litigation is filed.
|
||||
|
||||
---
|
||||
|
||||
### 4. Redistribution
|
||||
|
||||
You may reproduce and distribute copies of the Work or Derivative Works
|
||||
thereof in any medium, with or without modifications, and in Source or
|
||||
Object form, provided that You meet the following conditions:
|
||||
|
||||
- (a) You must give any other recipients of the Work or Derivative Works
|
||||
a copy of this License; and
|
||||
- (b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
- (c) You must retain, in the Source form of any Derivative Works that
|
||||
You distribute, all copyright, patent, trademark, and attribution
|
||||
notices from the Source form of the Work, excluding those notices that
|
||||
do not pertain to any part of the Derivative Works; and
|
||||
- (d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained within
|
||||
such NOTICE file, excluding those notices that do not pertain to any
|
||||
part of the Derivative Works, in at least one of the following places:
|
||||
within a NOTICE text file distributed as part of the Derivative Works;
|
||||
within the Source form or documentation, if provided along with the
|
||||
Derivative Works; or, within a display generated by the Derivative
|
||||
Works, if and wherever such third-party notices normally appear.
|
||||
|
||||
The contents of the NOTICE file are for informational purposes only and
|
||||
do not modify the License.
|
||||
|
||||
---
|
||||
|
||||
### 5. Submission of Contributions
|
||||
|
||||
Unless You explicitly state otherwise, any Contribution intentionally
|
||||
submitted for inclusion in the Work by You to the Licensor shall be
|
||||
under the terms and conditions of this License, without any additional
|
||||
terms or conditions.
|
||||
|
||||
---
|
||||
|
||||
### 6. Trademarks
|
||||
|
||||
This License does not grant permission to use the trade names,
|
||||
trademarks, service marks, or product names of the Licensor, except as
|
||||
required for reasonable and customary use in describing the origin of
|
||||
the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
---
|
||||
|
||||
### 7. Disclaimer of Warranty
|
||||
|
||||
Unless required by applicable law or agreed to in writing, Licensor
|
||||
provides the Work (and each Contributor provides its Contributions) on
|
||||
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
|
||||
express or implied.
|
||||
|
||||
---
|
||||
|
||||
### 8. Limitation of Liability
|
||||
|
||||
In no event and under no legal theory, whether in tort (including
|
||||
negligence), contract, or otherwise, unless required by applicable law,
|
||||
shall any Contributor be liable to You for damages arising from the use
|
||||
of the Work.
|
||||
|
||||
---
|
||||
|
||||
### 9. Accepting Warranty or Additional Liability
|
||||
|
||||
While redistributing the Work or Derivative Works thereof, You may
|
||||
choose to offer support or warranty at Your own responsibility.
|
||||
|
||||
---
|
||||
|
||||
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>.
|
||||
|
||||
21
assets/badges/coverage-branches.svg
Normal file
@ -0,0 +1,21 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="147.5" height="20" role="img" aria-label="Branch Coverage: 8.2%">
|
||||
<title>Branch Coverage: 8.2%</title>
|
||||
<linearGradient id="s" x2="0" y2="100%">
|
||||
<stop offset="0" stop-color="#bbb" stop-opacity=".1"/>
|
||||
<stop offset="1" stop-opacity=".1"/>
|
||||
</linearGradient>
|
||||
<clipPath id="r">
|
||||
<rect width="147.5" height="20" rx="3" fill="#fff"/>
|
||||
</clipPath>
|
||||
<g clip-path="url(#r)">
|
||||
<rect width="107.5" height="20" fill="#555"/>
|
||||
<rect x="107.5" width="40" height="20" fill="#e05d44"/>
|
||||
<rect width="147.5" height="20" fill="url(#s)"/>
|
||||
</g>
|
||||
<g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" text-rendering="geometricPrecision" font-size="11">
|
||||
<text aria-hidden="true" x="53.75" y="15" fill="#010101" fill-opacity=".3">Branch Coverage</text>
|
||||
<text x="53.75" y="14" fill="#fff">Branch Coverage</text>
|
||||
<text aria-hidden="true" x="127.5" y="15" fill="#010101" fill-opacity=".3">8.2%</text>
|
||||
<text x="127.5" y="14" fill="#fff">8.2%</text>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.0 KiB |
21
assets/badges/coverage-lines.svg
Normal file
@ -0,0 +1,21 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="137" height="20" role="img" aria-label="Line Coverage: 16.8%">
|
||||
<title>Line Coverage: 16.8%</title>
|
||||
<linearGradient id="s" x2="0" y2="100%">
|
||||
<stop offset="0" stop-color="#bbb" stop-opacity=".1"/>
|
||||
<stop offset="1" stop-opacity=".1"/>
|
||||
</linearGradient>
|
||||
<clipPath id="r">
|
||||
<rect width="137" height="20" rx="3" fill="#fff"/>
|
||||
</clipPath>
|
||||
<g clip-path="url(#r)">
|
||||
<rect width="94.5" height="20" fill="#555"/>
|
||||
<rect x="94.5" width="42.5" height="20" fill="#fe7d37"/>
|
||||
<rect width="137" height="20" fill="url(#s)"/>
|
||||
</g>
|
||||
<g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" text-rendering="geometricPrecision" font-size="11">
|
||||
<text aria-hidden="true" x="47.25" y="15" fill="#010101" fill-opacity=".3">Line Coverage</text>
|
||||
<text x="47.25" y="14" fill="#fff">Line Coverage</text>
|
||||
<text aria-hidden="true" x="115.75" y="15" fill="#010101" fill-opacity=".3">16.8%</text>
|
||||
<text x="115.75" y="14" fill="#fff">16.8%</text>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.0 KiB |
21
assets/badges/coverage-methods.svg
Normal file
@ -0,0 +1,21 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="150" height="20" role="img" aria-label="Method Coverage: 21.8%">
|
||||
<title>Method Coverage: 21.8%</title>
|
||||
<linearGradient id="s" x2="0" y2="100%">
|
||||
<stop offset="0" stop-color="#bbb" stop-opacity=".1"/>
|
||||
<stop offset="1" stop-opacity=".1"/>
|
||||
</linearGradient>
|
||||
<clipPath id="r">
|
||||
<rect width="150" height="20" rx="3" fill="#fff"/>
|
||||
</clipPath>
|
||||
<g clip-path="url(#r)">
|
||||
<rect width="107.5" height="20" fill="#555"/>
|
||||
<rect x="107.5" width="42.5" height="20" fill="#dfb317"/>
|
||||
<rect width="150" height="20" fill="url(#s)"/>
|
||||
</g>
|
||||
<g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" text-rendering="geometricPrecision" font-size="11">
|
||||
<text aria-hidden="true" x="53.75" y="15" fill="#010101" fill-opacity=".3">Method Coverage</text>
|
||||
<text x="53.75" y="14" fill="#fff">Method Coverage</text>
|
||||
<text aria-hidden="true" x="128.75" y="15" fill="#010101" fill-opacity=".3">21.8%</text>
|
||||
<text x="128.75" y="14" fill="#fff">21.8%</text>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.0 KiB |
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 |
6
package-lock.json
generated
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"name": "maksit-certs-ui",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {}
|
||||
}
|
||||
@ -32,6 +32,7 @@
|
||||
]
|
||||
},
|
||||
"deploy": {
|
||||
"type": "helm",
|
||||
"steps": []
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
# When build context is MaksIT/ (parent of maksit-certs-ui and maksit-webui).
|
||||
**/.classpath
|
||||
**/.dockerignore
|
||||
**/.env
|
||||
@ -19,12 +20,14 @@
|
||||
**/node_modules
|
||||
**/npm-debug.log
|
||||
**/obj
|
||||
**/dist
|
||||
**/secrets.dev.yaml
|
||||
**/values.dev.yaml
|
||||
maksit-vault/
|
||||
LICENSE
|
||||
README.md
|
||||
!**/.gitignore
|
||||
!.git/HEAD
|
||||
!.git/config
|
||||
!.git/packed-refs
|
||||
!.git/refs/heads/**
|
||||
!.git/refs/heads/**
|
||||
|
||||
@ -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,8 +0,0 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -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);
|
||||
}
|
||||
10
src/Directory.Build.props
Normal file
@ -0,0 +1,10 @@
|
||||
<Project>
|
||||
<!-- Applies to SDK-style .csproj under src/ (excludes Microsoft.Docker.Sdk compose projects). -->
|
||||
<PropertyGroup Condition="'$(UsingMicrosoftNETSdk)' == 'true'">
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
<AnalysisLevel>latest</AnalysisLevel>
|
||||
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
@ -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
|
||||
33
src/LetsEncrypt/.vscode/launch.json
vendored
@ -1,33 +0,0 @@
|
||||
{
|
||||
// Use IntelliSense to find out which attributes exist for C# debugging
|
||||
// Use hover for the description of the existing attributes
|
||||
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": ".NET Core Launch (console)",
|
||||
"type": "coreclr",
|
||||
"request": "launch",
|
||||
"logging": {
|
||||
"engineLogging": false,
|
||||
"moduleLoad": false,
|
||||
"exceptions": false,
|
||||
"browserStdOut": false
|
||||
},
|
||||
"preLaunchTask": "build",
|
||||
// If you have changed target frameworks, make sure to update the program path.
|
||||
"program": "${workspaceFolder}/bin/Debug/net5.0/LetsEncrypt.dll",
|
||||
"args": [],
|
||||
"cwd": "${workspaceFolder}",
|
||||
// For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
|
||||
"console": "internalConsole",
|
||||
"stopAtEntry": false
|
||||
},
|
||||
{
|
||||
"name": ".NET Core Attach",
|
||||
"type": "coreclr",
|
||||
"request": "attach",
|
||||
"processId": "${command:pickProcess}"
|
||||
}
|
||||
]
|
||||
}
|
||||